@luscii-healthtech/web-ui 0.15.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ export interface CheckboxProps {
6
6
  explanation?: string;
7
7
  type?: "regular" | "switch";
8
8
  isChecked?: boolean;
9
+ isIndeterminate?: boolean;
9
10
  isDisabled?: boolean;
10
11
  name?: string;
11
12
  value?: string;
@@ -13,5 +14,5 @@ export interface CheckboxProps {
13
14
  className?: string;
14
15
  error?: boolean;
15
16
  }
16
- export declare const Checkbox: ({ id, text, explanation, type, isChecked, isDisabled, name, value, onChange, className, error, }: CheckboxProps) => JSX.Element;
17
+ export declare const Checkbox: ({ id, text, explanation, type, isChecked, isIndeterminate, isDisabled, name, value, onChange, className, error, }: CheckboxProps) => JSX.Element;
17
18
  export default Checkbox;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { CheckboxGroupProps } from "./CheckboxList.types";
3
+ export declare const CheckboxGroup: ({ title, items, onChange, className }: CheckboxGroupProps) => JSX.Element;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { CheckboxListProps } from "./CheckboxList.types";
3
+ export { CheckboxListProps };
4
+ export declare const CheckboxList: ({ groups, onChange, className, }: CheckboxListProps) => JSX.Element;
5
+ export default CheckboxList;
@@ -0,0 +1,37 @@
1
+ export declare enum CheckboxState {
2
+ CHECKED = "checked",
3
+ INDETERMINATE = "indeterminate",
4
+ UNCHECKED = "unchecked"
5
+ }
6
+ export interface CheckboxListProps {
7
+ groups: CheckboxGroup[];
8
+ onChange: (event: CheckboxChangeEvent) => void;
9
+ className?: string;
10
+ }
11
+ export interface CheckboxGroupProps {
12
+ title?: string;
13
+ items: CheckboxListItem[];
14
+ onChange: (event: CheckboxChangeEvent) => void;
15
+ className?: string;
16
+ }
17
+ export interface CheckboxGroupItemProps {
18
+ id: string;
19
+ label: string;
20
+ isChecked?: boolean;
21
+ onChange: (event: CheckboxChangeEvent) => void;
22
+ className?: string;
23
+ }
24
+ export interface CheckboxListItem {
25
+ id: string;
26
+ label: string;
27
+ isChecked?: boolean;
28
+ className?: string;
29
+ }
30
+ export interface CheckboxGroup {
31
+ title?: string;
32
+ items: CheckboxListItem[];
33
+ }
34
+ export interface CheckboxChangeEvent {
35
+ id: string;
36
+ newCheckedValue: boolean;
37
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { CheckboxGroupItemProps } from "./CheckboxList.types";
3
+ export declare const CheckboxListItem: ({ id, label, isChecked, onChange, className, }: CheckboxGroupItemProps) => JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from "./types/IconProps.type";
3
+ export declare const ChevronDownIcon: (props: IconProps) => JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from "./types/IconProps.type";
3
+ export declare const ChevronRightIcon: (props: IconProps) => JSX.Element;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export { TableFieldConfig, TableFieldContent, TableFieldText, TableFieldAction,
22
22
  export { LoadingIndicator, LoadingIndicatorProps, } from "./components/LoadingIndicator/LoadingIndicator";
23
23
  export { default as Menu } from "./components/Menu/Menu";
24
24
  export { List, ListProps, ListItemProps, OnAssetLoadErrorPayload, } from "./components/List/List";
25
+ export { CheckboxList, CheckboxListProps, } from "./components/CheckboxList/CheckboxList";
25
26
  export { MultiSelect } from "./components/MultiSelect/MultiSelect";
26
27
  export { NavLayout, NavMenuLayoutProps } from "./components/NavMenu/NavLayout";
27
28
  export { NavMenu, NavMenuElement } from "./components/NavMenu/NavMenu";
@@ -1269,6 +1269,11 @@ video {
1269
1269
  margin-right: 0;
1270
1270
  }
1271
1271
 
1272
+ .my-1 {
1273
+ margin-top: 0.25rem;
1274
+ margin-bottom: 0.25rem;
1275
+ }
1276
+
1272
1277
  .my-2 {
1273
1278
  margin-top: 0.5rem;
1274
1279
  margin-bottom: 0.5rem;
@@ -1358,6 +1363,10 @@ video {
1358
1363
  margin-top: 2rem;
1359
1364
  }
1360
1365
 
1366
+ .ml-10 {
1367
+ margin-left: 2.5rem;
1368
+ }
1369
+
1361
1370
  .mb-20 {
1362
1371
  margin-bottom: 5rem;
1363
1372
  }
@@ -946,7 +946,7 @@ function CenteredHero(_ref) {
946
946
  })));
947
947
  }
948
948
 
949
- var css_248z$5 = ".cweb-checkbox {\n outline: none;\n transition: all 0.3s ease;\n}\n\n.cweb-checkbox .cweb-checkbox-input {\n position: absolute;\n -webkit-appearance: none;\n height: 1px;\n opacity: 0;\n width: 1px;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-label {\n display: flex;\n align-items: center;\n margin-bottom: 0;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-icon-container {\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n border: 1px solid #cccccc;\n border-radius: 4px;\n}\n\n.cweb-checkbox.type-regular.hasError .cweb-checkbox-icon-container {\n border: 1px solid #ff6266;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-icon {\n display: block;\n}\n\n.cweb-checkbox.type-regular.is-focused .cweb-checkbox-icon-container {\n border-color: #0074dd;\n}\n\n.cweb-checkbox.type-regular.is-checked .cweb-checkbox-icon {\n width: 0.5rem;\n height: 0.5rem;\n padding: 4px;\n background: url(\"data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 width%3D%2210%22 height%3D%228%22 viewBox%3D%220 0 10 8%22 fill%3D%22none%22%3E %3Cpath d%3D%22M9.207 0.792787C9.39447 0.980314 9.49979 1.23462 9.49979 1.49979C9.49979 1.76495 9.39447 2.01926 9.207 2.20679L4.207 7.20679C4.01947 7.39426 3.76516 7.49957 3.5 7.49957C3.23484 7.49957 2.98053 7.39426 2.793 7.20679L0.793 5.20679C0.610842 5.01818 0.510047 4.76558 0.512326 4.50339C0.514604 4.24119 0.619773 3.99038 0.805181 3.80497C0.990589 3.61956 1.2414 3.51439 1.5036 3.51211C1.7658 3.50983 2.0184 3.61063 2.207 3.79279L3.5 5.08579L7.793 0.792787C7.98053 0.605316 8.23484 0.5 8.5 0.5C8.76516 0.5 9.01947 0.605316 9.207 0.792787Z%22 fill%3D%22white%22%2F%3E%3C%2Fsvg%3E\") no-repeat center;\n background-size: contain;\n}\n\n.cweb-checkbox.type-regular.is-disabled.show-cross-when-disabled .cweb-checkbox-icon {\n width: 10px;\n height: 10px;\n background: url(\"data:image/svg+xml,%3Csvg width%3D%2211px%22 height%3D%2211px%22 viewBox%3D%220 0 11 11%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg stroke%3D%22none%22 stroke-width%3D%221%22 fill%3D%22none%22 fill-rule%3D%22evenodd%22 stroke-linecap%3D%22round%22%3E %3Cg transform%3D%22translate(-6.000000%2C -7.000000)%22 stroke%3D%22%232D2D2D%22 stroke-width%3D%222%22%3E %3Cpath d%3D%22M7%2C17 L16%2C8 M16%2C17 L7%2C8%22 %2F%3E %3C%2Fg%3E %3C%2Fg%3E%3C%2Fsvg%3E\") no-repeat center;\n background-size: contain;\n opacity: 0.6;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-label {\n display: flex;\n align-items: center;\n margin-bottom: 0;\n width: 56px;\n height: 28px;\n position: relative;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-icon-container {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #d1d5db;\n border-radius: 16px;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-icon-container:after {\n position: relative;\n display: block;\n content: \"\";\n height: 20px;\n width: 20px;\n top: 4px;\n left: 4px;\n background-color: white;\n border-radius: 50%;\n transition: all 0.2s ease;\n}\n\n.cweb-checkbox.type-switch.is-checked .cweb-checkbox-icon-container {\n background-color: #6abfa6;\n}\n\n.cweb-checkbox.type-switch.is-checked .cweb-checkbox-icon-container:after {\n left: 32px;\n}\n";
949
+ var css_248z$5 = ".cweb-checkbox {\n outline: none;\n transition: all 0.3s ease;\n}\n\n.cweb-checkbox .cweb-checkbox-input {\n position: absolute;\n -webkit-appearance: none;\n height: 1px;\n opacity: 0;\n width: 1px;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-label {\n display: flex;\n align-items: center;\n margin-bottom: 0;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-icon-container {\n width: 16px;\n height: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n border: 1px solid #cccccc;\n border-radius: 4px;\n}\n\n.cweb-checkbox.type-regular.hasError .cweb-checkbox-icon-container {\n border: 1px solid #ff6266;\n}\n\n.cweb-checkbox.type-regular .cweb-checkbox-icon {\n display: block;\n}\n\n.cweb-checkbox.type-regular.is-focused .cweb-checkbox-icon-container {\n border-color: #0074dd;\n}\n\n.cweb-checkbox.type-regular.is-checked .cweb-checkbox-icon {\n width: 0.5rem;\n height: 0.5rem;\n padding: 4px;\n background: url(\"data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 width%3D%2210%22 height%3D%228%22 viewBox%3D%220 0 10 8%22 fill%3D%22none%22%3E %3Cpath d%3D%22M9.207 0.792787C9.39447 0.980314 9.49979 1.23462 9.49979 1.49979C9.49979 1.76495 9.39447 2.01926 9.207 2.20679L4.207 7.20679C4.01947 7.39426 3.76516 7.49957 3.5 7.49957C3.23484 7.49957 2.98053 7.39426 2.793 7.20679L0.793 5.20679C0.610842 5.01818 0.510047 4.76558 0.512326 4.50339C0.514604 4.24119 0.619773 3.99038 0.805181 3.80497C0.990589 3.61956 1.2414 3.51439 1.5036 3.51211C1.7658 3.50983 2.0184 3.61063 2.207 3.79279L3.5 5.08579L7.793 0.792787C7.98053 0.605316 8.23484 0.5 8.5 0.5C8.76516 0.5 9.01947 0.605316 9.207 0.792787Z%22 fill%3D%22white%22%2F%3E%3C%2Fsvg%3E\") no-repeat center;\n background-size: contain;\n}\n\n.cweb-checkbox.type-regular.is-indeterminate .cweb-checkbox-icon {\n width: 0.5rem;\n height: 0.5rem;\n padding: 4px;\n background: url(\"data:image/svg+xml,%3Csvg width%3D%2210%22 height%3D%222%22 viewBox%3D%220 0 10 2%22 fill%3D%22none%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath d%3D%22M9 -4.37114e-08C9.55228 -1.95703e-08 10 0.447715 10 1C10 1.55228 9.55228 2 9 2L1 2C0.447716 2 -6.78525e-08 1.55228 -4.37114e-08 1C-1.95703e-08 0.447715 0.447715 -4.17544e-07 1 -3.93402e-07L9 -4.37114e-08Z%22 fill%3D%22white%22%2F%3E%3C%2Fsvg%3E\") no-repeat center;\n background-size: contain;\n}\n\n.cweb-checkbox.type-regular.is-disabled.show-cross-when-disabled .cweb-checkbox-icon {\n width: 10px;\n height: 10px;\n background: url(\"data:image/svg+xml,%3Csvg width%3D%2211px%22 height%3D%2211px%22 viewBox%3D%220 0 11 11%22 version%3D%221.1%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E %3Cg stroke%3D%22none%22 stroke-width%3D%221%22 fill%3D%22none%22 fill-rule%3D%22evenodd%22 stroke-linecap%3D%22round%22%3E %3Cg transform%3D%22translate(-6.000000%2C -7.000000)%22 stroke%3D%22%232D2D2D%22 stroke-width%3D%222%22%3E %3Cpath d%3D%22M7%2C17 L16%2C8 M16%2C17 L7%2C8%22 %2F%3E %3C%2Fg%3E %3C%2Fg%3E%3C%2Fsvg%3E\") no-repeat center;\n background-size: contain;\n opacity: 0.6;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-label {\n display: flex;\n align-items: center;\n margin-bottom: 0;\n width: 56px;\n height: 28px;\n position: relative;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-icon-container {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #d1d5db;\n border-radius: 16px;\n}\n\n.cweb-checkbox.type-switch .cweb-checkbox-icon-container:after {\n position: relative;\n display: block;\n content: \"\";\n height: 20px;\n width: 20px;\n top: 4px;\n left: 4px;\n background-color: white;\n border-radius: 50%;\n transition: all 0.2s ease;\n}\n\n.cweb-checkbox.type-switch.is-checked .cweb-checkbox-icon-container {\n background-color: #6abfa6;\n}\n\n.cweb-checkbox.type-switch.is-checked .cweb-checkbox-icon-container:after {\n left: 32px;\n}\n";
950
950
  styleInject(css_248z$5);
951
951
 
952
952
  var Checkbox = function Checkbox(_ref) {
@@ -957,6 +957,8 @@ var Checkbox = function Checkbox(_ref) {
957
957
  type = _ref$type === void 0 ? "regular" : _ref$type,
958
958
  _ref$isChecked = _ref.isChecked,
959
959
  isChecked = _ref$isChecked === void 0 ? false : _ref$isChecked,
960
+ _ref$isIndeterminate = _ref.isIndeterminate,
961
+ isIndeterminate = _ref$isIndeterminate === void 0 ? false : _ref$isIndeterminate,
960
962
  isDisabled = _ref.isDisabled,
961
963
  name = _ref.name,
962
964
  value = _ref.value,
@@ -969,12 +971,18 @@ var Checkbox = function Checkbox(_ref) {
969
971
  setChecked = _useState[1];
970
972
 
971
973
  var _useState2 = React.useState(false),
972
- isFocused = _useState2[0],
973
- setIsFocused = _useState2[1];
974
+ indeterminate = _useState2[0],
975
+ setIndeterminate = _useState2[1];
974
976
 
977
+ var _useState3 = React.useState(false),
978
+ isFocused = _useState3[0],
979
+ setIsFocused = _useState3[1];
980
+
981
+ var checkboxRef = React__default.useRef(null);
975
982
  var containerClassName = classNames("cweb-checkbox", className, {
976
983
  "is-focused": isFocused,
977
- "is-checked": checked,
984
+ "is-checked": checked && !indeterminate,
985
+ "is-indeterminate": indeterminate,
978
986
  "opacity-50 cursor-not-allowed is-disabled": isDisabled,
979
987
  "type-regular": type === "regular",
980
988
  "type-switch": type === "switch",
@@ -982,10 +990,19 @@ var Checkbox = function Checkbox(_ref) {
982
990
  });
983
991
  React.useEffect(function () {
984
992
  setChecked(isChecked);
993
+ setIndeterminate(false);
985
994
  }, [isChecked]);
995
+ React.useEffect(function () {
996
+ setIndeterminate(isIndeterminate);
997
+ }, [isIndeterminate]);
998
+ React.useEffect(function () {
999
+ if (checkboxRef != null && checkboxRef.current) {
1000
+ checkboxRef.current.indeterminate = !indeterminate;
1001
+ }
1002
+ }, [indeterminate]);
986
1003
 
987
1004
  var handleChange = function handleChange(event) {
988
- setChecked(!checked);
1005
+ setIndeterminate(false);
989
1006
 
990
1007
  if (onChange) {
991
1008
  onChange(event);
@@ -1011,6 +1028,7 @@ var Checkbox = function Checkbox(_ref) {
1011
1028
  }
1012
1029
  }, /*#__PURE__*/React__default.createElement("input", {
1013
1030
  id: id,
1031
+ ref: checkboxRef,
1014
1032
  "data-test-id": "checkbox-" + name,
1015
1033
  className: "cweb-checkbox-input",
1016
1034
  name: name,
@@ -1023,9 +1041,9 @@ var Checkbox = function Checkbox(_ref) {
1023
1041
  onChange: handleChange
1024
1042
  }), /*#__PURE__*/React__default.createElement("span", {
1025
1043
  className: classNames("cweb-checkbox-icon-container", "transition-colors duration-300", {
1026
- "bg-primary": checked,
1027
- "bg-white": !checked,
1028
- "hover:bg-primary-dark": checked,
1044
+ "bg-primary": checked || indeterminate,
1045
+ "bg-white": !checked && !indeterminate,
1046
+ "hover:bg-primary-dark": checked || indeterminate,
1029
1047
  "outline-primary": isFocused,
1030
1048
  "cursor-not-allowed": isDisabled,
1031
1049
  "cursor-pointer": !isDisabled
@@ -2320,7 +2338,7 @@ function generateCustomStyles(hasError, isIE11) {
2320
2338
  };
2321
2339
  }
2322
2340
 
2323
- var CustomSelect = /*#__PURE__*/React__default.forwardRef(function (props) {
2341
+ var CustomSelect = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
2324
2342
  var className = props.className,
2325
2343
  styles = props.styles;
2326
2344
  var hasError = (className == null ? void 0 : className.includes("has-error")) || false;
@@ -2328,6 +2346,7 @@ var CustomSelect = /*#__PURE__*/React__default.forwardRef(function (props) {
2328
2346
  var customStyles = generateCustomStyles(hasError, isIE11);
2329
2347
  var mergedStyles = ReactSelect.mergeStyles(customStyles, styles);
2330
2348
  return /*#__PURE__*/React__default.createElement(ReactSelect__default, Object.assign({}, props, {
2349
+ ref: ref,
2331
2350
  className: classNames("customized-select", className),
2332
2351
  styles: mergedStyles
2333
2352
  }));
@@ -2793,6 +2812,219 @@ var List = function List(_ref) {
2793
2812
  })));
2794
2813
  };
2795
2814
 
2815
+ var CheckboxListItem = function CheckboxListItem(_ref) {
2816
+ var id = _ref.id,
2817
+ label = _ref.label,
2818
+ isChecked = _ref.isChecked,
2819
+ onChange = _ref.onChange,
2820
+ className = _ref.className;
2821
+
2822
+ var _useState = React.useState(isChecked || false),
2823
+ checked = _useState[0],
2824
+ setChecked = _useState[1];
2825
+
2826
+ React.useEffect(function () {
2827
+ setChecked(isChecked || false);
2828
+ }, [isChecked]);
2829
+
2830
+ var handleItemClick = function handleItemClick() {
2831
+ if (onChange) {
2832
+ onChange({
2833
+ id: id,
2834
+ newCheckedValue: !checked
2835
+ });
2836
+ }
2837
+
2838
+ setChecked(!checked);
2839
+ };
2840
+
2841
+ var handleCheckboxClick = function handleCheckboxClick(event) {
2842
+ var targetId = event.target.id;
2843
+ var newCheckedValue = event.target.checked;
2844
+
2845
+ if (onChange) {
2846
+ onChange({
2847
+ id: targetId,
2848
+ newCheckedValue: newCheckedValue
2849
+ });
2850
+ }
2851
+ };
2852
+
2853
+ return /*#__PURE__*/React__default.createElement("div", {
2854
+ className: classNames("flex flex-row space-between cursor-pointer", className),
2855
+ "item-id": id,
2856
+ onClick: handleItemClick
2857
+ }, /*#__PURE__*/React__default.createElement(Text, {
2858
+ text: label,
2859
+ className: "mr-auto"
2860
+ }), /*#__PURE__*/React__default.createElement(Checkbox, {
2861
+ isChecked: checked,
2862
+ onChange: handleCheckboxClick,
2863
+ id: id
2864
+ }));
2865
+ };
2866
+
2867
+ var ChevronRightIcon = function ChevronRightIcon(props) {
2868
+ return /*#__PURE__*/React__default.createElement("svg", {
2869
+ className: props.className,
2870
+ onClick: props.onClick,
2871
+ role: props.onClick ? "button" : undefined,
2872
+ width: "24",
2873
+ height: "24",
2874
+ viewBox: "0 0 24 24",
2875
+ fill: "none",
2876
+ xmlns: "http://www.w3.org/2000/svg"
2877
+ }, /*#__PURE__*/React__default.createElement("path", {
2878
+ d: "M9.31008 6.70978C8.92008 7.09978 8.92008 7.72978 9.31008 8.11978L13.1901 11.9998L9.31008 15.8798C8.92008 16.2698 8.92008 16.8998 9.31008 17.2898C9.70008 17.6798 10.3301 17.6798 10.7201 17.2898L15.3101 12.6998C15.7001 12.3098 15.7001 11.6798 15.3101 11.2898L10.7201 6.69978C10.3401 6.31978 9.70008 6.31978 9.31008 6.70978Z",
2879
+ fill: "currentColor"
2880
+ }));
2881
+ };
2882
+
2883
+ var ChevronDownIcon = function ChevronDownIcon(props) {
2884
+ return /*#__PURE__*/React__default.createElement("svg", {
2885
+ className: props.className,
2886
+ onClick: props.onClick,
2887
+ role: props.onClick ? "button" : undefined,
2888
+ width: "24",
2889
+ height: "24",
2890
+ viewBox: "0 0 24 24",
2891
+ fill: "none",
2892
+ xmlns: "http://www.w3.org/2000/svg"
2893
+ }, /*#__PURE__*/React__default.createElement("path", {
2894
+ d: "M17.5995 8.99904C17.2095 8.60904 16.5795 8.60904 16.1895 8.99904L12.3095 12.879L8.42955 8.99904C8.03955 8.60904 7.40955 8.60904 7.01955 8.99904C6.62955 9.38904 6.62955 10.019 7.01955 10.409L11.6095 14.999C11.9995 15.389 12.6295 15.389 13.0195 14.999L17.6095 10.409C17.9895 10.029 17.9895 9.38904 17.5995 8.99904Z",
2895
+ fill: "currentColor"
2896
+ }));
2897
+ };
2898
+
2899
+ var CheckboxState;
2900
+
2901
+ (function (CheckboxState) {
2902
+ CheckboxState["CHECKED"] = "checked";
2903
+ CheckboxState["INDETERMINATE"] = "indeterminate";
2904
+ CheckboxState["UNCHECKED"] = "unchecked";
2905
+ })(CheckboxState || (CheckboxState = {}));
2906
+
2907
+ var CheckboxGroup = function CheckboxGroup(_ref) {
2908
+ var title = _ref.title,
2909
+ items = _ref.items,
2910
+ onChange = _ref.onChange,
2911
+ className = _ref.className;
2912
+
2913
+ var _useState = React.useState(CheckboxState.UNCHECKED),
2914
+ groupCheckboxState = _useState[0],
2915
+ setGroupCheckboxState = _useState[1];
2916
+
2917
+ var _useState2 = React.useState(true),
2918
+ collapsed = _useState2[0],
2919
+ setCollapsed = _useState2[1];
2920
+
2921
+ React.useEffect(function () {
2922
+ if ((items == null ? void 0 : items.length) > 0) {
2923
+ var indeterminate = items.some(function (item) {
2924
+ return item.isChecked !== items[0].isChecked;
2925
+ });
2926
+
2927
+ if (!indeterminate && items[0].isChecked) {
2928
+ setGroupCheckboxState(CheckboxState.CHECKED);
2929
+ } else if (!indeterminate && !items[0].isChecked) {
2930
+ setGroupCheckboxState(CheckboxState.UNCHECKED);
2931
+ } else {
2932
+ setGroupCheckboxState(CheckboxState.INDETERMINATE);
2933
+ }
2934
+ } else {
2935
+ setGroupCheckboxState(CheckboxState.UNCHECKED);
2936
+ }
2937
+ }, [items]);
2938
+
2939
+ var handleGroupClick = function handleGroupClick() {
2940
+ if ((groupCheckboxState === CheckboxState.CHECKED || groupCheckboxState === CheckboxState.INDETERMINATE) && onChange) {
2941
+ //if checked or indeterminate >> make all items unchecked
2942
+ items.forEach(function (item) {
2943
+ return onChange({
2944
+ id: item.id,
2945
+ newCheckedValue: false
2946
+ });
2947
+ });
2948
+ } else if (onChange) {
2949
+ // else if unchecked >> make all items checked
2950
+ items.forEach(function (item) {
2951
+ return onChange({
2952
+ id: item.id,
2953
+ newCheckedValue: true
2954
+ });
2955
+ });
2956
+ }
2957
+ };
2958
+
2959
+ var handleGroupCollapse = function handleGroupCollapse() {
2960
+ setCollapsed(!collapsed);
2961
+ };
2962
+
2963
+ var checkedItemsCount = items == null ? void 0 : items.filter(function (item) {
2964
+ return item == null ? void 0 : item.isChecked;
2965
+ }).length;
2966
+ var groupTitle = checkedItemsCount > 0 ? title + " (" + checkedItemsCount + ")" : title;
2967
+ return /*#__PURE__*/React__default.createElement("div", {
2968
+ className: classNames("flex flex-col", className)
2969
+ }, title && /*#__PURE__*/React__default.createElement("div", {
2970
+ className: "flex flex-row my-1 items-center w-full space-between"
2971
+ }, /*#__PURE__*/React__default.createElement("div", {
2972
+ className: "h-6 cursor-pointer mr-auto flex flex-row items-center text-slate-300 hover:text-slate-500 transition duration-300",
2973
+ onClick: handleGroupCollapse
2974
+ }, collapsed ? /*#__PURE__*/React__default.createElement(ChevronRightIcon, {
2975
+ onClick: handleGroupCollapse
2976
+ }) : /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
2977
+ onClick: handleGroupCollapse
2978
+ }), /*#__PURE__*/React__default.createElement(Text, {
2979
+ type: "strong",
2980
+ text: groupTitle || "",
2981
+ className: " ml-4"
2982
+ }), " :"), /*#__PURE__*/React__default.createElement(Checkbox, {
2983
+ onChange: handleGroupClick,
2984
+ className: "ml-auto",
2985
+ isChecked: groupCheckboxState === CheckboxState.CHECKED,
2986
+ isIndeterminate: groupCheckboxState === CheckboxState.INDETERMINATE
2987
+ })), !collapsed && items.map(function (item) {
2988
+ return /*#__PURE__*/React__default.createElement(CheckboxListItem, {
2989
+ key: item.id,
2990
+ id: item.id,
2991
+ label: item.label,
2992
+ onChange: onChange,
2993
+ isChecked: item.isChecked,
2994
+ className: "ml-10 my-1"
2995
+ });
2996
+ }));
2997
+ };
2998
+
2999
+ var CheckboxList = function CheckboxList(_ref) {
3000
+ var groups = _ref.groups,
3001
+ onChange = _ref.onChange,
3002
+ className = _ref.className;
3003
+ return /*#__PURE__*/React__default.createElement("div", {
3004
+ className: classNames("flex flex-col", className)
3005
+ }, (groups == null ? void 0 : groups.length) > 0 && groups.map(function (group) {
3006
+ if (group.title) {
3007
+ return /*#__PURE__*/React__default.createElement(CheckboxGroup, {
3008
+ key: group.title,
3009
+ items: group.items,
3010
+ title: group.title,
3011
+ onChange: onChange
3012
+ });
3013
+ } else {
3014
+ return group.items.map(function (item) {
3015
+ return /*#__PURE__*/React__default.createElement(CheckboxListItem, {
3016
+ key: item.id,
3017
+ id: item.id,
3018
+ label: item.label,
3019
+ onChange: onChange,
3020
+ isChecked: item.isChecked,
3021
+ className: "my-1"
3022
+ });
3023
+ });
3024
+ }
3025
+ }));
3026
+ };
3027
+
2796
3028
  var TEXT_TYPE_OPTIONS = {
2797
3029
  DEFAULT: "default",
2798
3030
  STRONG: "strong",
@@ -5335,6 +5567,7 @@ exports.ChartIcon = ChartIcon;
5335
5567
  exports.ChatBoxIcon = ChatBoxIcon;
5336
5568
  exports.CheckIcon = CheckIcon;
5337
5569
  exports.Checkbox = Checkbox;
5570
+ exports.CheckboxList = CheckboxList;
5338
5571
  exports.ChevronDoubleIcon = ChevronDoubleIcon;
5339
5572
  exports.ConfirmationDialog = ConfirmationDialog;
5340
5573
  exports.CrossIcon = CrossIcon;