2019-12-14 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import styled, { css } from "styled-components";
|
2021-02-24 17:11:23 +00:00
|
|
|
import { tablet } from "@appserver/components/utils/device";
|
2019-12-14 13:16:01 +00:00
|
|
|
|
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
const Container = ({
|
2019-12-14 13:54:12 +00:00
|
|
|
displayType,
|
|
|
|
options,
|
|
|
|
groups,
|
|
|
|
isMultiSelect,
|
2019-12-19 08:42:13 +00:00
|
|
|
allowGroupSelection,
|
2019-12-14 13:54:12 +00:00
|
|
|
hasSelected,
|
|
|
|
...props
|
|
|
|
}) => <div {...props} />;
|
|
|
|
/* eslint-enable react/prop-types */
|
|
|
|
/* eslint-enable no-unused-vars */
|
|
|
|
|
|
|
|
const dropdownStyles = css`
|
|
|
|
grid-auto-rows: max-content;
|
2020-10-16 12:38:04 +00:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.groups && props.groups.length > 0
|
|
|
|
? css`
|
|
|
|
grid-template-areas: "column-options splitter column-groups" "footer footer footer";
|
|
|
|
`
|
|
|
|
: css`
|
|
|
|
grid-template-areas: "column-options column-groups" "footer footer";
|
|
|
|
`};
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
.column-groups {
|
|
|
|
box-sizing: border-box;
|
|
|
|
grid-area: column-groups;
|
|
|
|
|
|
|
|
display: grid;
|
|
|
|
/* background-color: gold; */
|
2020-02-05 20:55:56 +00:00
|
|
|
padding: 16px 16px 0 16px;
|
2019-12-27 12:46:38 +00:00
|
|
|
grid-row-gap: 2px;
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
grid-template-columns: 1fr;
|
2019-12-27 10:51:17 +00:00
|
|
|
grid-template-rows: 30px 1fr;
|
2019-12-14 13:54:12 +00:00
|
|
|
grid-template-areas: "header-groups" "body-groups";
|
|
|
|
|
|
|
|
.header-groups {
|
|
|
|
grid-area: header-groups;
|
2020-08-17 13:45:14 +00:00
|
|
|
|
|
|
|
.group_header {
|
|
|
|
line-height: 30px;
|
|
|
|
}
|
2019-12-14 13:54:12 +00:00
|
|
|
/* background-color: white; */
|
|
|
|
}
|
|
|
|
|
|
|
|
.body-groups {
|
|
|
|
grid-area: body-groups;
|
|
|
|
margin-left: -8px;
|
|
|
|
/* background-color: white; */
|
|
|
|
|
2020-08-17 13:45:14 +00:00
|
|
|
.row-group:first-child {
|
|
|
|
font-weight: 700;
|
|
|
|
}
|
|
|
|
|
2020-01-09 13:36:57 +00:00
|
|
|
.row-group {
|
|
|
|
box-sizing: border-box;
|
|
|
|
height: 32px;
|
|
|
|
cursor: pointer;
|
|
|
|
padding-top: 8px;
|
2019-12-14 13:54:12 +00:00
|
|
|
padding-left: 8px;
|
|
|
|
|
|
|
|
.group_checkbox {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
2020-01-09 13:36:57 +00:00
|
|
|
|
|
|
|
&:hover {
|
2020-08-17 13:45:14 +00:00
|
|
|
background-color: #eceef1;
|
2020-01-09 13:36:57 +00:00
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.row-group.selected {
|
|
|
|
background-color: #eceef1;
|
|
|
|
border-radius: 3px;
|
2019-12-14 13:54:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-05 20:55:56 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
|
|
|
props.groups &&
|
|
|
|
props.groups.length > 0 &&
|
|
|
|
css`
|
|
|
|
.splitter {
|
|
|
|
grid-area: splitter;
|
|
|
|
border-left: 1px solid #eceef1;
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
|
|
|
`}
|
2019-12-14 13:54:12 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
const asideStyles = css`
|
2020-08-20 14:39:57 +00:00
|
|
|
height: 100%;
|
2019-12-14 13:54:12 +00:00
|
|
|
grid-template-columns: 1fr;
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
2019-12-14 13:54:12 +00:00
|
|
|
props.isMultiSelect && props.hasSelected
|
|
|
|
? css`
|
|
|
|
grid-template-rows: 1fr 69px;
|
|
|
|
grid-template-areas: "column-options" "footer";
|
|
|
|
`
|
|
|
|
: css`
|
|
|
|
grid-template-rows: 1fr;
|
|
|
|
grid-template-areas: "column-options";
|
|
|
|
`}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledSelector = styled(Container)`
|
|
|
|
display: grid;
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
|
|
|
props.displayType === "dropdown" ? dropdownStyles : asideStyles}
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
.column-options {
|
|
|
|
grid-area: column-options;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
display: grid;
|
|
|
|
/* background-color: red; */
|
2020-02-05 20:55:56 +00:00
|
|
|
padding: 16px 16px 0 16px;
|
2019-12-27 12:46:38 +00:00
|
|
|
grid-row-gap: 2px;
|
2020-12-03 15:14:11 +00:00
|
|
|
overflow: hidden;
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
grid-template-columns: 1fr;
|
2020-10-16 12:38:04 +00:00
|
|
|
grid-template-rows: ${(props) =>
|
2019-12-14 13:54:12 +00:00
|
|
|
props.displayType === "aside"
|
2020-10-16 12:38:04 +00:00
|
|
|
? props.isMultiSelect &&
|
|
|
|
props.allowGroupSelection &&
|
|
|
|
props.options &&
|
|
|
|
props.options.length > 0
|
2019-12-19 07:06:15 +00:00
|
|
|
? props.groups && props.groups.length > 0
|
2019-12-14 13:54:12 +00:00
|
|
|
? "100px"
|
|
|
|
: "30px"
|
2020-10-16 12:38:04 +00:00
|
|
|
: props.groups && props.groups.length > 0
|
2020-12-03 15:14:11 +00:00
|
|
|
? "75px"
|
2020-10-16 12:38:04 +00:00
|
|
|
: "30px"
|
2019-12-27 10:51:17 +00:00
|
|
|
: "30px"} 1fr;
|
2019-12-14 13:54:12 +00:00
|
|
|
grid-template-areas: "header-options" "body-options";
|
|
|
|
|
|
|
|
.header-options {
|
|
|
|
grid-area: header-options;
|
2020-11-06 09:48:08 +00:00
|
|
|
margin-right: 2px;
|
2019-12-14 13:54:12 +00:00
|
|
|
/* background-color: white; */
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
2019-12-14 13:54:12 +00:00
|
|
|
props.displayType === "aside" &&
|
|
|
|
css`
|
|
|
|
display: grid;
|
2020-11-06 09:48:08 +00:00
|
|
|
grid-row-gap: 17px;
|
2019-12-14 13:54:12 +00:00
|
|
|
grid-template-columns: 1fr;
|
2020-10-16 12:38:04 +00:00
|
|
|
grid-template-rows: 30px 30px ${(props) =>
|
2019-12-14 13:16:01 +00:00
|
|
|
props.isMultiSelect &&
|
|
|
|
props.options &&
|
|
|
|
props.options.length > 0 &&
|
2019-12-14 13:54:12 +00:00
|
|
|
"30px"};
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
2019-12-14 13:54:12 +00:00
|
|
|
props.isMultiSelect && props.options && props.options.length > 0
|
|
|
|
? css`
|
|
|
|
grid-template-areas: "options_searcher" "options_group_selector" "options_group_select_all";
|
|
|
|
`
|
|
|
|
: css`
|
|
|
|
grid-template-areas: "options_searcher" "options_group_selector";
|
|
|
|
`}
|
|
|
|
|
|
|
|
.options_searcher {
|
|
|
|
grid-area: options_searcher;
|
2019-12-14 13:16:01 +00:00
|
|
|
}
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
.options_group_selector {
|
|
|
|
grid-area: options_group_selector;
|
|
|
|
}
|
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
${(props) =>
|
2019-12-14 13:54:12 +00:00
|
|
|
props.isMultiSelect &&
|
|
|
|
props.options &&
|
|
|
|
props.options.length > 0 &&
|
|
|
|
css`
|
|
|
|
.options_group_select_all {
|
|
|
|
grid-area: options_group_select_all;
|
|
|
|
}
|
|
|
|
`}
|
|
|
|
`}
|
2020-01-10 15:28:12 +00:00
|
|
|
|
2020-10-16 12:38:04 +00:00
|
|
|
.options_searcher {
|
|
|
|
div:first-child {
|
|
|
|
:hover {
|
|
|
|
border-color: #d0d5da;
|
|
|
|
}
|
|
|
|
|
|
|
|
:focus,
|
|
|
|
:focus-within {
|
|
|
|
border-color: #2da7db;
|
|
|
|
}
|
|
|
|
|
|
|
|
& > input::placeholder {
|
|
|
|
color: #a3a9ae;
|
2020-01-13 13:27:18 +00:00
|
|
|
}
|
2020-01-10 15:28:12 +00:00
|
|
|
}
|
2020-10-16 12:38:04 +00:00
|
|
|
}
|
2019-12-14 13:16:01 +00:00
|
|
|
}
|
2019-12-14 13:54:12 +00:00
|
|
|
|
|
|
|
.body-options {
|
|
|
|
grid-area: body-options;
|
|
|
|
margin-left: -8px;
|
2020-12-03 15:14:11 +00:00
|
|
|
margin-top: 2px;
|
2020-08-19 11:58:23 +00:00
|
|
|
|
|
|
|
@media ${tablet} {
|
|
|
|
width: 290px;
|
|
|
|
}
|
2020-10-16 12:38:04 +00:00
|
|
|
|
2019-12-14 13:54:12 +00:00
|
|
|
/* background-color: white; */
|
|
|
|
|
2020-01-09 13:36:57 +00:00
|
|
|
.row-option {
|
2019-12-14 13:54:12 +00:00
|
|
|
padding-left: 8px;
|
2019-12-27 12:46:38 +00:00
|
|
|
padding-top: 8px;
|
2020-01-09 13:36:57 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
height: 32px;
|
2020-08-20 14:39:57 +00:00
|
|
|
margin-top: 16px;
|
2020-01-09 13:36:57 +00:00
|
|
|
cursor: pointer;
|
2019-12-14 13:54:12 +00:00
|
|
|
|
2020-08-17 13:45:14 +00:00
|
|
|
&:hover {
|
|
|
|
background-color: #eceef1;
|
|
|
|
border-radius: 3px;
|
|
|
|
}
|
|
|
|
|
2020-02-07 07:00:35 +00:00
|
|
|
.option_checkbox {
|
2020-02-07 12:41:26 +00:00
|
|
|
width: 265px;
|
2020-02-07 07:00:35 +00:00
|
|
|
}
|
|
|
|
|
2019-12-14 13:54:12 +00:00
|
|
|
.option-info {
|
|
|
|
position: absolute;
|
2020-08-20 14:39:57 +00:00
|
|
|
top: 12px;
|
2019-12-14 13:54:12 +00:00
|
|
|
right: 10px;
|
2020-02-07 12:41:26 +00:00
|
|
|
padding: 8px 0 8px 8px;
|
|
|
|
margin-top: -8px;
|
2019-12-14 13:54:12 +00:00
|
|
|
}
|
2020-02-07 12:41:26 +00:00
|
|
|
|
|
|
|
/* .__react_component_tooltip {
|
|
|
|
left: 8px !important;
|
|
|
|
} */
|
2019-12-14 13:16:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-14 13:54:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.footer {
|
|
|
|
grid-area: footer;
|
|
|
|
}
|
|
|
|
`;
|
2019-12-14 13:16:01 +00:00
|
|
|
|
2019-12-14 13:54:12 +00:00
|
|
|
export default StyledSelector;
|