@luscii-healthtech/web-ui 2.16.4 → 2.17.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.
- package/dist/components/CheckboxList/CheckboxList.types.d.ts +2 -0
- package/dist/components/CheckboxList/CheckboxListItem.d.ts +1 -1
- package/dist/web-ui.cjs.development.js +42 -14
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +42 -14
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ export interface CheckboxGroupItemProps {
|
|
|
19
19
|
id: string;
|
|
20
20
|
label: string;
|
|
21
21
|
isChecked?: boolean;
|
|
22
|
+
isDisabled?: boolean;
|
|
22
23
|
onChange: (event: CheckboxChangeEvent) => void;
|
|
23
24
|
className?: string;
|
|
24
25
|
}
|
|
@@ -26,6 +27,7 @@ export interface CheckboxListItem {
|
|
|
26
27
|
id: string;
|
|
27
28
|
label: string;
|
|
28
29
|
isChecked?: boolean;
|
|
30
|
+
isDisabled?: boolean;
|
|
29
31
|
className?: string;
|
|
30
32
|
}
|
|
31
33
|
export interface CheckboxGroup {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CheckboxGroupItemProps } from "./CheckboxList.types";
|
|
3
|
-
export declare const CheckboxListItem: ({ id, label, isChecked, onChange, className, }: CheckboxGroupItemProps) => JSX.Element;
|
|
3
|
+
export declare const CheckboxListItem: ({ id, label, isChecked, isDisabled, onChange, className, }: CheckboxGroupItemProps) => JSX.Element;
|
|
@@ -4022,6 +4022,7 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
|
|
|
4022
4022
|
var id = _ref.id,
|
|
4023
4023
|
label = _ref.label,
|
|
4024
4024
|
isChecked = _ref.isChecked,
|
|
4025
|
+
isDisabled = _ref.isDisabled,
|
|
4025
4026
|
onChange = _ref.onChange,
|
|
4026
4027
|
className = _ref.className;
|
|
4027
4028
|
|
|
@@ -4036,6 +4037,10 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
|
|
|
4036
4037
|
var handleItemClick = function handleItemClick(event) {
|
|
4037
4038
|
event.stopPropagation();
|
|
4038
4039
|
|
|
4040
|
+
if (isDisabled) {
|
|
4041
|
+
return;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4039
4044
|
if (onChange) {
|
|
4040
4045
|
onChange({
|
|
4041
4046
|
id: id,
|
|
@@ -4068,6 +4073,7 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
|
|
|
4068
4073
|
className: "mr-auto"
|
|
4069
4074
|
}), /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
4070
4075
|
isChecked: checked,
|
|
4076
|
+
isDisabled: isDisabled,
|
|
4071
4077
|
onChange: handleCheckboxClick,
|
|
4072
4078
|
id: id
|
|
4073
4079
|
}));
|
|
@@ -4097,30 +4103,49 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
4097
4103
|
collapsed = _useState2[0],
|
|
4098
4104
|
setCollapsed = _useState2[1];
|
|
4099
4105
|
|
|
4106
|
+
var _useState3 = React.useState(false),
|
|
4107
|
+
isDisabled = _useState3[0],
|
|
4108
|
+
setIsDisabled = _useState3[1];
|
|
4109
|
+
|
|
4100
4110
|
React.useEffect(function () {
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
});
|
|
4111
|
+
var enabledItems = items.filter(function (item) {
|
|
4112
|
+
return !item.isDisabled;
|
|
4113
|
+
});
|
|
4105
4114
|
|
|
4106
|
-
|
|
4107
|
-
setGroupCheckboxState(CheckboxState.CHECKED);
|
|
4108
|
-
} else if (!indeterminate && !items[0].isChecked) {
|
|
4109
|
-
setGroupCheckboxState(CheckboxState.UNCHECKED);
|
|
4110
|
-
} else {
|
|
4111
|
-
setGroupCheckboxState(CheckboxState.INDETERMINATE);
|
|
4112
|
-
}
|
|
4113
|
-
} else {
|
|
4115
|
+
if (enabledItems.length === 0) {
|
|
4114
4116
|
setGroupCheckboxState(CheckboxState.UNCHECKED);
|
|
4117
|
+
return;
|
|
4115
4118
|
}
|
|
4119
|
+
|
|
4120
|
+
var indeterminate = enabledItems.some(function (item) {
|
|
4121
|
+
return item.isChecked !== enabledItems[0].isChecked;
|
|
4122
|
+
});
|
|
4123
|
+
|
|
4124
|
+
if (indeterminate) {
|
|
4125
|
+
setGroupCheckboxState(CheckboxState.INDETERMINATE);
|
|
4126
|
+
return;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
if (enabledItems[0].isChecked) {
|
|
4130
|
+
setGroupCheckboxState(CheckboxState.CHECKED);
|
|
4131
|
+
} else if (!enabledItems[0].isChecked) {
|
|
4132
|
+
setGroupCheckboxState(CheckboxState.UNCHECKED);
|
|
4133
|
+
}
|
|
4134
|
+
|
|
4135
|
+
setIsDisabled(!enabledItems.some(function (item) {
|
|
4136
|
+
return !item.isDisabled;
|
|
4137
|
+
}));
|
|
4116
4138
|
}, [items]);
|
|
4117
4139
|
|
|
4118
4140
|
var handleGroupClick = function handleGroupClick(event) {
|
|
4119
4141
|
event.stopPropagation();
|
|
4142
|
+
var enabledItems = items.filter(function (item) {
|
|
4143
|
+
return !item.isDisabled;
|
|
4144
|
+
});
|
|
4120
4145
|
|
|
4121
4146
|
if ((groupCheckboxState === CheckboxState.CHECKED || groupCheckboxState === CheckboxState.INDETERMINATE) && onChange) {
|
|
4122
4147
|
//if checked or indeterminate >> make all items unchecked
|
|
4123
|
-
|
|
4148
|
+
enabledItems.forEach(function (item) {
|
|
4124
4149
|
return onChange({
|
|
4125
4150
|
id: item.id,
|
|
4126
4151
|
newCheckedValue: false
|
|
@@ -4128,7 +4153,7 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
4128
4153
|
});
|
|
4129
4154
|
} else if (onChange) {
|
|
4130
4155
|
// else if unchecked >> make all items checked
|
|
4131
|
-
|
|
4156
|
+
enabledItems.forEach(function (item) {
|
|
4132
4157
|
return onChange({
|
|
4133
4158
|
id: item.id,
|
|
4134
4159
|
newCheckedValue: true
|
|
@@ -4168,6 +4193,7 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
4168
4193
|
onChange: handleGroupClick,
|
|
4169
4194
|
className: "ml-auto",
|
|
4170
4195
|
isChecked: groupCheckboxState === CheckboxState.CHECKED,
|
|
4196
|
+
isDisabled: isDisabled,
|
|
4171
4197
|
isIndeterminate: groupCheckboxState === CheckboxState.INDETERMINATE
|
|
4172
4198
|
})), !collapsed && items.map(function (item) {
|
|
4173
4199
|
return /*#__PURE__*/React__default.createElement(CheckboxListItem, {
|
|
@@ -4176,6 +4202,7 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
4176
4202
|
label: item.label,
|
|
4177
4203
|
onChange: onChange,
|
|
4178
4204
|
isChecked: item.isChecked,
|
|
4205
|
+
isDisabled: item.isDisabled,
|
|
4179
4206
|
className: "ml-10 my-1"
|
|
4180
4207
|
});
|
|
4181
4208
|
}));
|
|
@@ -4204,6 +4231,7 @@ var CheckboxList = function CheckboxList(_ref) {
|
|
|
4204
4231
|
label: item.label,
|
|
4205
4232
|
onChange: onChange,
|
|
4206
4233
|
isChecked: item.isChecked,
|
|
4234
|
+
isDisabled: item.isDisabled,
|
|
4207
4235
|
className: "my-1"
|
|
4208
4236
|
});
|
|
4209
4237
|
});
|