@widergy/energy-ui 3.29.0 → 3.30.1
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/CHANGELOG.md +14 -0
- package/dist/components/UTAutocomplete/index.js +0 -5
- package/dist/components/UTCheckList/index.js +12 -160
- package/dist/components/UTCheckList/versions/V0/index.js +174 -0
- package/dist/components/UTCheckList/{theme.js → versions/V0/theme.js} +2 -2
- package/dist/components/UTCheckList/versions/V1/README.MD +134 -0
- package/dist/components/UTCheckList/versions/V1/constants.js +10 -0
- package/dist/components/UTCheckList/versions/V1/index.js +151 -0
- package/dist/components/UTCheckList/versions/V1/styles.module.scss +40 -0
- package/dist/components/UTCheckList/versions/V1/utils.js +14 -0
- package/dist/components/UTCheckbox/index.js +12 -128
- package/dist/components/UTCheckbox/versions/V0/index.js +142 -0
- package/dist/components/UTCheckbox/{theme.js → versions/V0/theme.js} +1 -1
- package/dist/components/UTCheckbox/versions/V1/README.md +37 -0
- package/dist/components/UTCheckbox/versions/V1/constants.js +13 -0
- package/dist/components/UTCheckbox/versions/V1/index.js +93 -0
- package/dist/components/UTCheckbox/versions/V1/styles.module.scss +3 -0
- package/dist/components/UTCheckbox/versions/V1/theme.js +126 -0
- package/dist/components/UTFieldLabel/index.js +3 -2
- package/dist/components/UTLabel/constants.js +0 -2
- package/dist/components/UTTouchableWithoutFeedback/index.js +19 -10
- package/dist/components/UTTouchableWithoutFeedback/styles.module.scss +5 -0
- package/package.json +1 -1
- /package/dist/components/UTCheckList/{constants.js → versions/V0/constants.js} +0 -0
- /package/dist/components/UTCheckList/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
- /package/dist/components/UTCheckbox/{assets → versions/V0/assets}/checked.svg +0 -0
- /package/dist/components/UTCheckbox/{constants.js → versions/V0/constants.js} +0 -0
- /package/dist/components/UTCheckbox/{styles.module.scss → versions/V0/styles.module.scss} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [3.30.1](https://github.com/widergy/energy-ui/compare/v3.30.0...v3.30.1) (2024-10-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* rever inputProps ([#511](https://github.com/widergy/energy-ui/issues/511)) ([959e891](https://github.com/widergy/energy-ui/commit/959e891c600f51f91c76b00823c661752d70bc28))
|
|
7
|
+
|
|
8
|
+
# [3.30.0](https://github.com/widergy/energy-ui/compare/v3.29.0...v3.30.0) (2024-10-15)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add UTCheckbox and UTCheckList ([#509](https://github.com/widergy/energy-ui/issues/509)) ([5c7eabd](https://github.com/widergy/energy-ui/commit/5c7eabd8a9f6499affabf53ce8d98302beaaba5a))
|
|
14
|
+
|
|
1
15
|
# [3.29.0](https://github.com/widergy/energy-ui/compare/v3.28.0...v3.29.0) (2024-10-15)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -27,7 +27,6 @@ const UTAutocomplete = _ref => {
|
|
|
27
27
|
ArrowIcon,
|
|
28
28
|
autocompleteProps,
|
|
29
29
|
classes = {},
|
|
30
|
-
dataTestId,
|
|
31
30
|
disabled,
|
|
32
31
|
field,
|
|
33
32
|
fixedSizeListProps,
|
|
@@ -104,9 +103,6 @@ const UTAutocomplete = _ref => {
|
|
|
104
103
|
colorTheme: "error",
|
|
105
104
|
variant: "small"
|
|
106
105
|
}, errorMessage) : undefined,
|
|
107
|
-
inputProps: {
|
|
108
|
-
'data-testid': dataTestId
|
|
109
|
-
},
|
|
110
106
|
placeholder: placeholder,
|
|
111
107
|
variant: variant
|
|
112
108
|
}, textFieldProps))
|
|
@@ -116,7 +112,6 @@ UTAutocomplete.propTypes = {
|
|
|
116
112
|
ArrowIcon: _propTypes.elementType,
|
|
117
113
|
autocompleteProps: _propTypes.object,
|
|
118
114
|
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
119
|
-
dataTestId: _propTypes.string,
|
|
120
115
|
disabled: _propTypes.bool,
|
|
121
116
|
input: _formTypes.inputPropTypes.isRequired,
|
|
122
117
|
field: _formTypes.fieldType,
|
|
@@ -4,171 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = require("prop-types");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _FormHelperText = _interopRequireDefault(require("@material-ui/core/FormHelperText"));
|
|
12
|
-
var _WithTheme = _interopRequireDefault(require("../WithTheme"));
|
|
13
|
-
var _UTCheckbox = _interopRequireDefault(require("../UTCheckbox"));
|
|
14
|
-
var _classesUtils = require("../../utils/classesUtils");
|
|
15
|
-
var _UTLabel = _interopRequireDefault(require("../UTLabel"));
|
|
16
|
-
var _formTypes = require("../../types/formTypes");
|
|
17
|
-
var _theme = require("./theme");
|
|
18
|
-
var _constants = require("./constants");
|
|
19
|
-
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
9
|
+
var _V = _interopRequireDefault(require("./versions/V0"));
|
|
10
|
+
var _V2 = _interopRequireDefault(require("./versions/V1"));
|
|
20
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
24
12
|
const UTCheckList = _ref => {
|
|
25
|
-
var _field$configuration;
|
|
26
13
|
let {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
CustomCheckedIcon,
|
|
30
|
-
CustomUncheckedIcon,
|
|
31
|
-
customRowLabel: CustomRowLabel,
|
|
32
|
-
customSelectAllRowLabel: CustomSelectAllRowLabel,
|
|
33
|
-
classes: themeClasses = {},
|
|
34
|
-
className,
|
|
35
|
-
classNames,
|
|
36
|
-
disabled,
|
|
37
|
-
disabledItemTooltip,
|
|
38
|
-
field,
|
|
39
|
-
getSelectAllNewValues,
|
|
40
|
-
header,
|
|
41
|
-
headerLabel,
|
|
42
|
-
input,
|
|
43
|
-
labelKey,
|
|
44
|
-
list,
|
|
45
|
-
meta,
|
|
46
|
-
shouldShowErrors,
|
|
47
|
-
titleProps,
|
|
48
|
-
useCustomIcons,
|
|
49
|
-
valueKey,
|
|
50
|
-
withCheckRow,
|
|
51
|
-
withUpperTitle
|
|
14
|
+
version = 'V0',
|
|
15
|
+
...props
|
|
52
16
|
} = _ref;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const handleCheckAll = () => {
|
|
59
|
-
if (getSelectAllNewValues) {
|
|
60
|
-
input.onChange(getSelectAllNewValues());
|
|
61
|
-
} else if (list.length !== input.value.length) {
|
|
62
|
-
input.onChange(list.map(item => item[valueKey]));
|
|
63
|
-
} else {
|
|
64
|
-
input.onChange(null);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
(0, _react.useEffect)(() => {
|
|
68
|
-
if (allChecked) handleCheckAll();
|
|
69
|
-
}, []);
|
|
70
|
-
const classes = (0, _classesUtils.mergeClasses)(themeClasses, classNames);
|
|
71
|
-
const label = function () {
|
|
72
|
-
let key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
73
|
-
let item = arguments.length > 1 ? arguments[1] : undefined;
|
|
74
|
-
return key.map(keyValue => /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
75
|
-
variant: "xsmall",
|
|
76
|
-
className: classes.rowItem
|
|
77
|
-
}, item[keyValue]));
|
|
78
|
-
};
|
|
79
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
-
className: "".concat(_stylesModule.default.container, " ").concat(className)
|
|
81
|
-
}, shouldShowUpperTitle && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
82
|
-
className: classes.title
|
|
83
|
-
}, titleProps, {
|
|
84
|
-
withMarkdown: true
|
|
85
|
-
}), field.title), /*#__PURE__*/_react.default.createElement("div", {
|
|
86
|
-
className: header ? classes.tableHeader : classes.selectAll
|
|
87
|
-
}, header && header.map(item => /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
88
|
-
weight: "bold",
|
|
89
|
-
className: classes.headerItem,
|
|
90
|
-
key: item.text
|
|
91
|
-
}, item.text)), /*#__PURE__*/_react.default.createElement(_UTCheckbox.default, {
|
|
92
|
-
disabled: disabled,
|
|
93
|
-
onChange: handleCheckAll,
|
|
94
|
-
value: list.length === input.value.length,
|
|
95
|
-
label: header ? headerLabel : additionalInfo && additionalInfo.header || _constants.defaultAdditionalInfoHeader,
|
|
96
|
-
classNames: {
|
|
97
|
-
root: !header && classes.selectAllRowRoot,
|
|
98
|
-
checkedIcon: classes.checkedIcon,
|
|
99
|
-
uncheckedIcon: classes.uncheckedIcon
|
|
100
|
-
},
|
|
101
|
-
customRowLabel: CustomSelectAllRowLabel,
|
|
102
|
-
useCustomIcons: useCustomIcons,
|
|
103
|
-
CustomCheckedIcon: CustomCheckedIcon,
|
|
104
|
-
CustomUncheckedIcon: CustomUncheckedIcon
|
|
105
|
-
})), /*#__PURE__*/_react.default.createElement(_FormGroup.default, {
|
|
106
|
-
className: "".concat(_stylesModule.default.rows, " ").concat(classes.rowContainerClassName)
|
|
107
|
-
}, list.map(item => /*#__PURE__*/_react.default.createElement("div", {
|
|
108
|
-
className: "\n ".concat(_stylesModule.default.row, "\n ").concat(withCheckRow && classes.checkRowContainer, "\n ").concat(!(0, _array.isEmpty)(input.value) && !!input.value.find(val => val === item[valueKey]) && classes.customRowRootChecked, " "),
|
|
109
|
-
key: item[valueKey]
|
|
110
|
-
}, withCheckRow && label([valueKey, labelKey], item), /*#__PURE__*/_react.default.createElement(_UTCheckbox.default, {
|
|
111
|
-
disabled: disabled || item.disabled,
|
|
112
|
-
item: item,
|
|
113
|
-
key: item[valueKey],
|
|
114
|
-
value: input.value.indexOf(item[valueKey]) !== -1,
|
|
115
|
-
label: withCheckRow ? '' : item[labelKey],
|
|
116
|
-
onChange: () => handleChange(item[valueKey]),
|
|
117
|
-
customRowLabel: CustomRowLabel,
|
|
118
|
-
classNames: {
|
|
119
|
-
root: !withCheckRow && classes.customRowRoot,
|
|
120
|
-
checkedIcon: classes.checkedIcon,
|
|
121
|
-
uncheckedIcon: classes.uncheckedIcon,
|
|
122
|
-
label: classes.label
|
|
123
|
-
},
|
|
124
|
-
useCustomIcons: useCustomIcons,
|
|
125
|
-
CustomCheckedIcon: CustomCheckedIcon,
|
|
126
|
-
CustomUncheckedIcon: CustomUncheckedIcon,
|
|
127
|
-
tooltipContent: item.disabled && disabledItemTooltip ? disabledItemTooltip(item, list) : undefined
|
|
128
|
-
})))), additionalInfo && additionalInfo.footer && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, null, additionalInfo.footer), shouldShowErrors && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, {
|
|
129
|
-
error: true
|
|
130
|
-
}, meta && meta.error));
|
|
131
|
-
};
|
|
132
|
-
UTCheckList.defaultProps = {
|
|
133
|
-
list: []
|
|
17
|
+
const Component = {
|
|
18
|
+
V0: _V.default,
|
|
19
|
+
V1: _V2.default
|
|
20
|
+
}[version];
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(Component, props);
|
|
134
22
|
};
|
|
135
23
|
UTCheckList.propTypes = {
|
|
136
|
-
|
|
137
|
-
header: _propTypes.string,
|
|
138
|
-
footer: _propTypes.string
|
|
139
|
-
}),
|
|
140
|
-
allChecked: _propTypes.bool,
|
|
141
|
-
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
142
|
-
className: _propTypes.string,
|
|
143
|
-
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
144
|
-
CustomCheckedIcon: _propTypes.element,
|
|
145
|
-
customRowLabel: (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.element, _propTypes.string]),
|
|
146
|
-
customSelectAllRowLabel: (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.element, _propTypes.string]),
|
|
147
|
-
CustomUncheckedIcon: _propTypes.element,
|
|
148
|
-
disabled: _propTypes.bool,
|
|
149
|
-
disabledItemTooltip: _propTypes.func,
|
|
150
|
-
field: _formTypes.fieldType,
|
|
151
|
-
getSelectAllNewValues: _propTypes.func,
|
|
152
|
-
header: (0, _propTypes.shape)({
|
|
153
|
-
text: _propTypes.string
|
|
154
|
-
}),
|
|
155
|
-
headerLabel: _propTypes.string,
|
|
156
|
-
input: (0, _propTypes.shape)({
|
|
157
|
-
onChange: _propTypes.func,
|
|
158
|
-
value: _propTypes.any
|
|
159
|
-
}),
|
|
160
|
-
labelKey: _propTypes.string.isRequired,
|
|
161
|
-
list: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
162
|
-
id: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
|
|
163
|
-
label: _propTypes.string,
|
|
164
|
-
checked: _propTypes.bool
|
|
165
|
-
})),
|
|
166
|
-
meta: _formTypes.metaPropTypes,
|
|
167
|
-
shouldShowErrors: _propTypes.bool,
|
|
168
|
-
titleProps: _propTypes.object,
|
|
169
|
-
useCustomIcons: _propTypes.bool,
|
|
170
|
-
valueKey: _propTypes.string.isRequired,
|
|
171
|
-
withCheckRow: _propTypes.bool,
|
|
172
|
-
withUpperTitle: _propTypes.bool
|
|
24
|
+
version: _propTypes.string
|
|
173
25
|
};
|
|
174
|
-
var _default = exports.default =
|
|
26
|
+
var _default = exports.default = UTCheckList;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = require("prop-types");
|
|
9
|
+
var _array = require("@widergy/web-utils/lib/array");
|
|
10
|
+
var _FormGroup = _interopRequireDefault(require("@material-ui/core/FormGroup"));
|
|
11
|
+
var _FormHelperText = _interopRequireDefault(require("@material-ui/core/FormHelperText"));
|
|
12
|
+
var _WithTheme = _interopRequireDefault(require("../../../WithTheme"));
|
|
13
|
+
var _UTCheckbox = _interopRequireDefault(require("../../../UTCheckbox"));
|
|
14
|
+
var _classesUtils = require("../../../../utils/classesUtils");
|
|
15
|
+
var _UTLabel = _interopRequireDefault(require("../../../UTLabel"));
|
|
16
|
+
var _formTypes = require("../../../../types/formTypes");
|
|
17
|
+
var _theme = require("./theme");
|
|
18
|
+
var _constants = require("./constants");
|
|
19
|
+
var _stylesModule = _interopRequireDefault(require("./styles.module.scss"));
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
24
|
+
const UTCheckList = _ref => {
|
|
25
|
+
var _field$configuration;
|
|
26
|
+
let {
|
|
27
|
+
additionalInfo,
|
|
28
|
+
allChecked,
|
|
29
|
+
CustomCheckedIcon,
|
|
30
|
+
CustomUncheckedIcon,
|
|
31
|
+
customRowLabel: CustomRowLabel,
|
|
32
|
+
customSelectAllRowLabel: CustomSelectAllRowLabel,
|
|
33
|
+
classes: themeClasses = {},
|
|
34
|
+
className,
|
|
35
|
+
classNames,
|
|
36
|
+
disabled,
|
|
37
|
+
disabledItemTooltip,
|
|
38
|
+
field,
|
|
39
|
+
getSelectAllNewValues,
|
|
40
|
+
header,
|
|
41
|
+
headerLabel,
|
|
42
|
+
input,
|
|
43
|
+
labelKey,
|
|
44
|
+
list,
|
|
45
|
+
meta,
|
|
46
|
+
shouldShowErrors,
|
|
47
|
+
titleProps,
|
|
48
|
+
useCustomIcons,
|
|
49
|
+
valueKey,
|
|
50
|
+
withCheckRow,
|
|
51
|
+
withUpperTitle
|
|
52
|
+
} = _ref;
|
|
53
|
+
const shouldShowUpperTitle = (field === null || field === void 0 || (_field$configuration = field.configuration) === null || _field$configuration === void 0 ? void 0 : _field$configuration.ignore_title) && withUpperTitle;
|
|
54
|
+
const handleChange = id => {
|
|
55
|
+
const newValues = input.value.indexOf(id) === -1 ? [...input.value, id] : input.value.filter(elem => elem !== id);
|
|
56
|
+
input.onChange((0, _array.isEmpty)(newValues) ? null : newValues);
|
|
57
|
+
};
|
|
58
|
+
const handleCheckAll = () => {
|
|
59
|
+
if (getSelectAllNewValues) {
|
|
60
|
+
input.onChange(getSelectAllNewValues());
|
|
61
|
+
} else if (list.length !== input.value.length) {
|
|
62
|
+
input.onChange(list.map(item => item[valueKey]));
|
|
63
|
+
} else {
|
|
64
|
+
input.onChange(null);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
(0, _react.useEffect)(() => {
|
|
68
|
+
if (allChecked) handleCheckAll();
|
|
69
|
+
}, []);
|
|
70
|
+
const classes = (0, _classesUtils.mergeClasses)(themeClasses, classNames);
|
|
71
|
+
const label = function () {
|
|
72
|
+
let key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
73
|
+
let item = arguments.length > 1 ? arguments[1] : undefined;
|
|
74
|
+
return key.map(keyValue => /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
75
|
+
variant: "xsmall",
|
|
76
|
+
className: classes.rowItem
|
|
77
|
+
}, item[keyValue]));
|
|
78
|
+
};
|
|
79
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
+
className: "".concat(_stylesModule.default.container, " ").concat(className)
|
|
81
|
+
}, shouldShowUpperTitle && /*#__PURE__*/_react.default.createElement(_UTLabel.default, _extends({
|
|
82
|
+
className: classes.title
|
|
83
|
+
}, titleProps, {
|
|
84
|
+
withMarkdown: true
|
|
85
|
+
}), field.title), /*#__PURE__*/_react.default.createElement("div", {
|
|
86
|
+
className: header ? classes.tableHeader : classes.selectAll
|
|
87
|
+
}, header && header.map(item => /*#__PURE__*/_react.default.createElement(_UTLabel.default, {
|
|
88
|
+
weight: "bold",
|
|
89
|
+
className: classes.headerItem,
|
|
90
|
+
key: item.text
|
|
91
|
+
}, item.text)), /*#__PURE__*/_react.default.createElement(_UTCheckbox.default, {
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
onChange: handleCheckAll,
|
|
94
|
+
value: list.length === input.value.length,
|
|
95
|
+
label: header ? headerLabel : additionalInfo && additionalInfo.header || _constants.defaultAdditionalInfoHeader,
|
|
96
|
+
classNames: {
|
|
97
|
+
root: !header && classes.selectAllRowRoot,
|
|
98
|
+
checkedIcon: classes.checkedIcon,
|
|
99
|
+
uncheckedIcon: classes.uncheckedIcon
|
|
100
|
+
},
|
|
101
|
+
customRowLabel: CustomSelectAllRowLabel,
|
|
102
|
+
useCustomIcons: useCustomIcons,
|
|
103
|
+
CustomCheckedIcon: CustomCheckedIcon,
|
|
104
|
+
CustomUncheckedIcon: CustomUncheckedIcon
|
|
105
|
+
})), /*#__PURE__*/_react.default.createElement(_FormGroup.default, {
|
|
106
|
+
className: "".concat(_stylesModule.default.rows, " ").concat(classes.rowContainerClassName)
|
|
107
|
+
}, list.map(item => /*#__PURE__*/_react.default.createElement("div", {
|
|
108
|
+
className: "\n ".concat(_stylesModule.default.row, "\n ").concat(withCheckRow && classes.checkRowContainer, "\n ").concat(!(0, _array.isEmpty)(input.value) && !!input.value.find(val => val === item[valueKey]) && classes.customRowRootChecked, " "),
|
|
109
|
+
key: item[valueKey]
|
|
110
|
+
}, withCheckRow && label([valueKey, labelKey], item), /*#__PURE__*/_react.default.createElement(_UTCheckbox.default, {
|
|
111
|
+
disabled: disabled || item.disabled,
|
|
112
|
+
item: item,
|
|
113
|
+
key: item[valueKey],
|
|
114
|
+
value: input.value.indexOf(item[valueKey]) !== -1,
|
|
115
|
+
label: withCheckRow ? '' : item[labelKey],
|
|
116
|
+
onChange: () => handleChange(item[valueKey]),
|
|
117
|
+
customRowLabel: CustomRowLabel,
|
|
118
|
+
classNames: {
|
|
119
|
+
root: !withCheckRow && classes.customRowRoot,
|
|
120
|
+
checkedIcon: classes.checkedIcon,
|
|
121
|
+
uncheckedIcon: classes.uncheckedIcon,
|
|
122
|
+
label: classes.label
|
|
123
|
+
},
|
|
124
|
+
useCustomIcons: useCustomIcons,
|
|
125
|
+
CustomCheckedIcon: CustomCheckedIcon,
|
|
126
|
+
CustomUncheckedIcon: CustomUncheckedIcon,
|
|
127
|
+
tooltipContent: item.disabled && disabledItemTooltip ? disabledItemTooltip(item, list) : undefined
|
|
128
|
+
})))), additionalInfo && additionalInfo.footer && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, null, additionalInfo.footer), shouldShowErrors && /*#__PURE__*/_react.default.createElement(_FormHelperText.default, {
|
|
129
|
+
error: true
|
|
130
|
+
}, meta && meta.error));
|
|
131
|
+
};
|
|
132
|
+
UTCheckList.defaultProps = {
|
|
133
|
+
list: []
|
|
134
|
+
};
|
|
135
|
+
UTCheckList.propTypes = {
|
|
136
|
+
additionalInfo: (0, _propTypes.shape)({
|
|
137
|
+
header: _propTypes.string,
|
|
138
|
+
footer: _propTypes.string
|
|
139
|
+
}),
|
|
140
|
+
allChecked: _propTypes.bool,
|
|
141
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
142
|
+
className: _propTypes.string,
|
|
143
|
+
classNames: (0, _propTypes.objectOf)(_propTypes.string),
|
|
144
|
+
CustomCheckedIcon: _propTypes.element,
|
|
145
|
+
customRowLabel: (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.element, _propTypes.string]),
|
|
146
|
+
customSelectAllRowLabel: (0, _propTypes.oneOfType)([_propTypes.func, _propTypes.element, _propTypes.string]),
|
|
147
|
+
CustomUncheckedIcon: _propTypes.element,
|
|
148
|
+
disabled: _propTypes.bool,
|
|
149
|
+
disabledItemTooltip: _propTypes.func,
|
|
150
|
+
field: _formTypes.fieldType,
|
|
151
|
+
getSelectAllNewValues: _propTypes.func,
|
|
152
|
+
header: (0, _propTypes.shape)({
|
|
153
|
+
text: _propTypes.string
|
|
154
|
+
}),
|
|
155
|
+
headerLabel: _propTypes.string,
|
|
156
|
+
input: (0, _propTypes.shape)({
|
|
157
|
+
onChange: _propTypes.func,
|
|
158
|
+
value: _propTypes.any
|
|
159
|
+
}),
|
|
160
|
+
labelKey: _propTypes.string.isRequired,
|
|
161
|
+
list: (0, _propTypes.arrayOf)((0, _propTypes.shape)({
|
|
162
|
+
id: (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.string]),
|
|
163
|
+
label: _propTypes.string,
|
|
164
|
+
checked: _propTypes.bool
|
|
165
|
+
})),
|
|
166
|
+
meta: _formTypes.metaPropTypes,
|
|
167
|
+
shouldShowErrors: _propTypes.bool,
|
|
168
|
+
titleProps: _propTypes.object,
|
|
169
|
+
useCustomIcons: _propTypes.bool,
|
|
170
|
+
valueKey: _propTypes.string.isRequired,
|
|
171
|
+
withCheckRow: _propTypes.bool,
|
|
172
|
+
withUpperTitle: _propTypes.bool
|
|
173
|
+
};
|
|
174
|
+
var _default = exports.default = (0, _WithTheme.default)(_theme.retrieveStyle, _theme.retrieveMuiTheme)(UTCheckList);
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.retrieveStyle = exports.retrieveMuiTheme = void 0;
|
|
7
7
|
var _seamlessImmutable = require("seamless-immutable");
|
|
8
8
|
var _styles = require("@material-ui/core/styles");
|
|
9
|
-
var _colorsModule = _interopRequireDefault(require("
|
|
10
|
-
var _classesUtils = require("
|
|
9
|
+
var _colorsModule = _interopRequireDefault(require("../../../../scss/variables/colors.module.scss"));
|
|
10
|
+
var _classesUtils = require("../../../../utils/classesUtils");
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const retrieveMuiTheme = theme => (0, _styles.createTheme)({
|
|
13
13
|
typography: {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# UTCheckList
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTCheckList` is a customizable component that renders a list of checkboxes, allowing users to select multiple options from a provided list. It supports features like select all, indeterminate state, error display, and dynamic options. The "Select All" checkbox only affects options that are not disabled. Additionally, it allows for grouping options by category, with ungrouped options appearing first.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ----------------- | ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| classNames | objectOf(string) | | Custom class names to apply to different elements of the checklist (`root`, `header`, `checkboxesContainer`, `item`, `selectAll`). |
|
|
12
|
+
| error | string | | Error message to display. |
|
|
13
|
+
| horizontalSpacing | string | large | Spacing between the checkbox and the title horizontally. |
|
|
14
|
+
| isSimple | bool | false | Simplifies the selection process to only allow single checkbox selection. |
|
|
15
|
+
| onChange | func.isRequired | | Function to call when the selection changes. |
|
|
16
|
+
| options | arrayOf(shape) | | Array of options to be displayed as checkboxes. Each option is an object with `label`, `value`, `disabled`, `checked`, and optionally `category`. |
|
|
17
|
+
| required | bool | false | Indicates if the checklist is required. |
|
|
18
|
+
| reversed | bool | false | If true, reverses the order of title and checkbox. |
|
|
19
|
+
| selectAllLabel | string | | Label for the "Select All" checkbox. |
|
|
20
|
+
| showSelectAll | bool | true | Determines whether to show the "Select All" checkbox. |
|
|
21
|
+
| title | string | | Title for the checklist. |
|
|
22
|
+
| value | arrayOf(string) | [] | Array of selected values. |
|
|
23
|
+
| variant | string | | Variant style for the checklist. |
|
|
24
|
+
| verticalSpacing | string | large | Spacing between the checkbox items vertically. |
|
|
25
|
+
|
|
26
|
+
### Option Object
|
|
27
|
+
|
|
28
|
+
The `options` prop is an array of objects, each representing an option:
|
|
29
|
+
|
|
30
|
+
| Name | Type | Description |
|
|
31
|
+
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| category | string | (Optional) Category under which the option will be grouped. If not provided, the option will appear ungrouped at the top. |
|
|
33
|
+
| checked | bool | Indicates if the option is checked. |
|
|
34
|
+
| disabled | bool | Indicates if the option is disabled. |
|
|
35
|
+
| label | string | Label to display for the option. |
|
|
36
|
+
| value | string | Value of the option. |
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Basic Example
|
|
41
|
+
|
|
42
|
+
```jsx
|
|
43
|
+
import React from 'react';
|
|
44
|
+
import UTCheckList from './UTCheckList';
|
|
45
|
+
|
|
46
|
+
const options = [
|
|
47
|
+
{ label: 'Option 1', value: '1' },
|
|
48
|
+
{ label: 'Option 2', value: '2' },
|
|
49
|
+
{ label: 'Option 3', value: '3', disabled: true, checked: true }
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const Example = () => {
|
|
53
|
+
const [selectedOptions, setSelectedOptions] = React.useState([]);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<UTCheckList
|
|
57
|
+
error="Please select at least one option"
|
|
58
|
+
title="Select Options"
|
|
59
|
+
onChange={setSelectedOptions}
|
|
60
|
+
options={options}
|
|
61
|
+
required
|
|
62
|
+
selectAllLabel="Select All"
|
|
63
|
+
value={selectedOptions}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default Example;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Categorized Example
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
import React from 'react';
|
|
75
|
+
import UTCheckList from './UTCheckList';
|
|
76
|
+
|
|
77
|
+
const options = [
|
|
78
|
+
{ label: 'Option 1', value: '1' },
|
|
79
|
+
{ label: 'Option 2', value: '2', category: 'Group A' },
|
|
80
|
+
{ label: 'Option 3', value: '3', category: 'Group B', disabled: true },
|
|
81
|
+
{ label: 'Option 4', value: '4', category: 'Group A' }
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
const Example = () => {
|
|
85
|
+
const [selectedOptions, setSelectedOptions] = React.useState([]);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<UTCheckList
|
|
89
|
+
error="Please select at least one option"
|
|
90
|
+
title="Categorized CheckList"
|
|
91
|
+
onChange={setSelectedOptions}
|
|
92
|
+
options={options}
|
|
93
|
+
selectAllLabel="Select All"
|
|
94
|
+
value={selectedOptions}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default Example;
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Custom Styles Example
|
|
103
|
+
|
|
104
|
+
```jsx
|
|
105
|
+
import React from 'react';
|
|
106
|
+
import UTCheckList from './UTCheckList';
|
|
107
|
+
|
|
108
|
+
const customStyles = {
|
|
109
|
+
root: { padding: 10 },
|
|
110
|
+
checkboxesContainer: { backgroundColor: 'lightgrey' },
|
|
111
|
+
header: { color: 'blue' }
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const Example = () => {
|
|
115
|
+
const options = [
|
|
116
|
+
{ label: 'Option 1', value: '1' },
|
|
117
|
+
{ label: 'Option 2', value: '2' }
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const [selectedOptions, setSelectedOptions] = React.useState([]);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<UTCheckList
|
|
124
|
+
title="Custom Styled CheckList"
|
|
125
|
+
onChange={setSelectedOptions}
|
|
126
|
+
options={options}
|
|
127
|
+
style={customStyles}
|
|
128
|
+
value={selectedOptions}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default Example;
|
|
134
|
+
```
|