@luscii-healthtech/web-ui 2.57.0 → 2.58.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.
@@ -1,2 +1,2 @@
1
1
  import { CheckboxGroupProps } from "./CheckboxList.types";
2
- export declare const CheckboxGroup: ({ title, items, onChange, className, hasDividers, isCollapsed, }: CheckboxGroupProps) => JSX.Element;
2
+ export declare const CheckboxGroup: ({ title, items, onChange, className, hasDividers, isCollapsed, collapsible, }: CheckboxGroupProps) => JSX.Element;
@@ -9,14 +9,22 @@ export interface CheckboxListProps {
9
9
  hasDividers?: boolean;
10
10
  className?: string;
11
11
  }
12
- export interface CheckboxGroupProps {
12
+ declare type WithCollapsible = {
13
+ /**
14
+ * When `false`, will prevent the checkbox list from being collapsed (also disabling clicking to expand/collapse)
15
+ * in the component and it will be displayed expanded by default.
16
+ * @default true
17
+ */
18
+ collapsible?: boolean;
19
+ };
20
+ export declare type CheckboxGroupProps = {
13
21
  title?: string;
14
22
  items: CheckboxListItem[];
15
23
  onChange: (event: CheckboxChangeEvent) => void;
16
24
  hasDividers?: boolean;
17
25
  className?: string;
18
26
  isCollapsed?: boolean;
19
- }
27
+ } & WithCollapsible;
20
28
  export interface CheckboxGroupItemProps {
21
29
  id: string;
22
30
  label: string;
@@ -32,12 +40,13 @@ export interface CheckboxListItem {
32
40
  isDisabled?: boolean;
33
41
  className?: string;
34
42
  }
35
- export interface CheckboxGroup {
43
+ export declare type CheckboxGroup = {
36
44
  title?: string;
37
45
  items: CheckboxListItem[];
38
46
  isCollapsed?: boolean;
39
- }
47
+ } & WithCollapsible;
40
48
  export interface CheckboxChangeEvent {
41
49
  id: string;
42
50
  newCheckedValue: boolean;
43
51
  }
52
+ export {};
@@ -66,7 +66,7 @@ export interface FieldCheckboxConfiguration extends FormFieldBaseConfiguration<O
66
66
  * Omiting `groups` and `onChange` here because these will be handled by
67
67
  * the `Control` component from react-hook-form.
68
68
  */
69
- export interface FieldCheckboxListConfiguration extends FormFieldBaseConfiguration<Omit<CheckboxListProps, "groups" | "onChange">> {
69
+ export interface FieldCheckboxListConfiguration extends FormFieldBaseConfiguration<Pick<CheckboxListProps, "hasDividers" | "className">> {
70
70
  type: "checkboxlist";
71
71
  }
72
72
  /**
@@ -1528,6 +1528,10 @@ video {
1528
1528
  margin-top: 1.25rem;
1529
1529
  }
1530
1530
 
1531
+ .ml-5 {
1532
+ margin-left: 1.25rem;
1533
+ }
1534
+
1531
1535
  .mt-6 {
1532
1536
  margin-top: 1.5rem;
1533
1537
  }
@@ -5678,13 +5678,20 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
5678
5678
  _ref$hasDividers = _ref.hasDividers,
5679
5679
  hasDividers = _ref$hasDividers === void 0 ? false : _ref$hasDividers,
5680
5680
  _ref$isCollapsed = _ref.isCollapsed,
5681
- isCollapsed = _ref$isCollapsed === void 0 ? true : _ref$isCollapsed;
5681
+ isCollapsed = _ref$isCollapsed === void 0 ? true : _ref$isCollapsed,
5682
+ _ref$collapsible = _ref.collapsible,
5683
+ collapsible = _ref$collapsible === void 0 ? true : _ref$collapsible;
5682
5684
 
5683
5685
  var _useState = React.useState(CheckboxState.UNCHECKED),
5684
5686
  groupCheckboxState = _useState[0],
5685
5687
  setGroupCheckboxState = _useState[1];
5688
+ /**
5689
+ * If the prop `collapsible` is set to false, the default state of this list will
5690
+ * be expanded, and no change event can update that state.
5691
+ */
5686
5692
 
5687
- var _useState2 = React.useState(isCollapsed),
5693
+
5694
+ var _useState2 = React.useState(collapsible ? isCollapsed : false),
5688
5695
  collapsed = _useState2[0],
5689
5696
  setCollapsed = _useState2[1];
5690
5697
 
@@ -5752,7 +5759,9 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
5752
5759
  event.stopPropagation();
5753
5760
  }
5754
5761
 
5755
- setCollapsed(!collapsed);
5762
+ if (collapsible) {
5763
+ setCollapsed(!collapsed);
5764
+ }
5756
5765
  };
5757
5766
 
5758
5767
  var checkedItemsCount = items == null ? void 0 : items.filter(function (item) {
@@ -5760,6 +5769,7 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
5760
5769
  }).length;
5761
5770
  var groupTitle = checkedItemsCount > 0 ? title + " (" + checkedItemsCount + ")" : title;
5762
5771
  var itemClassName = hasDividers ? "py-3 last:border-b-0 border-b border-slate-200" : "my-1";
5772
+ var CollapseStateChevron = collapsed ? ChevronRightIcon : ChevronDownIcon;
5763
5773
  return /*#__PURE__*/React__default.createElement("div", {
5764
5774
  className: classNames("flex flex-col ", className, {
5765
5775
  "last:border-b-0 border-b border-slate-200": hasDividers && isCollapsed,
@@ -5775,14 +5785,15 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
5775
5785
  }, /*#__PURE__*/React__default.createElement("div", {
5776
5786
  className: "h-6 cursor-pointer mr-auto flex flex-row items-center text-slate-300 hover:text-slate-500 transition duration-300",
5777
5787
  onClick: handleGroupCollapse
5778
- }, collapsed ? /*#__PURE__*/React__default.createElement(ChevronRightIcon, {
5779
- onClick: handleGroupCollapse
5780
- }) : /*#__PURE__*/React__default.createElement(ChevronDownIcon, {
5788
+ }, collapsible && /*#__PURE__*/React__default.createElement(CollapseStateChevron, {
5781
5789
  onClick: handleGroupCollapse
5782
5790
  }), /*#__PURE__*/React__default.createElement(Text, {
5783
5791
  type: "strong",
5784
5792
  text: groupTitle || "",
5785
- className: "ml-4"
5793
+ className: classNames({
5794
+ "ml-4": collapsible,
5795
+ "ml-1": !collapsible
5796
+ })
5786
5797
  }), " "), /*#__PURE__*/React__default.createElement(Checkbox, {
5787
5798
  onChange: handleGroupClick,
5788
5799
  className: "ml-auto",
@@ -5797,7 +5808,10 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
5797
5808
  onChange: onChange,
5798
5809
  isChecked: item.isChecked,
5799
5810
  isDisabled: item.isDisabled,
5800
- className: classNames("ml-10", itemClassName)
5811
+ className: classNames({
5812
+ "ml-10": collapsible,
5813
+ "ml-5": !collapsible
5814
+ }, itemClassName)
5801
5815
  });
5802
5816
  }));
5803
5817
  };
@@ -5818,6 +5832,7 @@ var CheckboxList = function CheckboxList(_ref) {
5818
5832
  items: group.items,
5819
5833
  title: group.title,
5820
5834
  isCollapsed: group.isCollapsed,
5835
+ collapsible: group.collapsible,
5821
5836
  onChange: onChange,
5822
5837
  hasDividers: hasDividers
5823
5838
  });