@ntbjs/react-components 2.0.0-rc.26 → 2.0.0-rc.27
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/build/{ActionButton-03dc5f67.js → ActionButton-4db754c3.js} +17 -24
- package/build/{Alert-8a511bdc.js → Alert-e6847a22.js} +29 -36
- package/build/{Badge-aa4cd9c1.js → Badge-d93586a9.js} +35 -42
- package/build/{Button-2e26f5da.js → Button-179a2fe4.js} +83 -90
- package/build/{Checkbox-0b8faf49.js → Checkbox-4a5fd716.js} +45 -52
- package/build/{CompactAutocompleteSelect-797778cb.js → CompactAutocompleteSelect-52c49513.js} +116 -125
- package/build/{CompactStarRating-da21b53f.js → CompactStarRating-9af2f427.js} +76 -101
- package/build/{CompactTextInput-d56aec71.js → CompactTextInput-42ca5d42.js} +104 -129
- package/build/InputGroup-1294d190.js +23 -0
- package/build/{MultiLevelCheckboxSelect-d229cf98.js → MultiLevelCheckboxSelect-d8044c88.js} +139 -167
- package/build/{MultiSelect-d7920eb1.js → MultiSelect-9f497e62.js} +81 -90
- package/build/{Popover-c4be47ea.js → Popover-20050b91.js} +35 -44
- package/build/{Radio-150fb2c9.js → Radio-73ca3ae2.js} +28 -35
- package/build/SectionSeparator-f47760a2.js +31 -0
- package/build/{Switch-d2d6e9ec.js → Switch-ecf3122b.js} +35 -42
- package/build/Tab-04d435c3.js +32 -0
- package/build/{Tabs-b06c0e24.js → Tabs-74d1ea8a.js} +37 -44
- package/build/{TextArea-26d3c8a1.js → TextArea-1e5b9201.js} +105 -113
- package/build/{TextInput-3a567daa.js → TextInput-fab35842.js} +78 -86
- package/build/Tooltip-c1d1199e.js +65 -0
- package/build/{VerificationStatusIcon-9876b68f.js → VerificationStatusIcon-49cb1c1b.js} +19 -44
- package/build/{_rollupPluginBabelHelpers-4b342fad.js → _rollupPluginBabelHelpers-c245b26a.js} +1 -3
- package/build/arrow-forward-ad12c5f3.js +15 -0
- package/build/close-a5d37608.js +15 -0
- package/build/data/Alert/index.js +6 -12
- package/build/data/Badge/index.js +5 -11
- package/build/data/Popover/index.js +10 -16
- package/build/data/Tab/index.js +5 -11
- package/build/data/Tabs/index.js +7 -13
- package/build/data/Tooltip/index.js +7 -13
- package/build/data/index.js +16 -30
- package/build/{defaultTheme-d9a7342e.js → defaultTheme-1bcc2541.js} +3 -7
- package/build/edit-note-283a0e15.js +15 -0
- package/build/expand-more-c5523c46.js +15 -0
- package/build/inputs/ActionButton/index.js +6 -12
- package/build/inputs/Button/index.js +13 -19
- package/build/inputs/Checkbox/index.js +6 -12
- package/build/inputs/CompactAutocompleteSelect/index.js +23 -29
- package/build/inputs/CompactStarRating/index.js +17 -23
- package/build/inputs/CompactTextInput/index.js +19 -25
- package/build/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.js +26 -0
- package/build/inputs/MultiSelect/index.js +10 -16
- package/build/inputs/Radio/index.js +7 -13
- package/build/inputs/Switch/index.js +6 -12
- package/build/inputs/TextArea/index.js +20 -26
- package/build/inputs/TextInput/index.js +9 -15
- package/build/inputs/index.js +40 -60
- package/build/layout/InputGroup/index.js +5 -11
- package/build/layout/SectionSeparator/index.js +5 -11
- package/build/layout/index.js +6 -15
- package/build/{shift-away-subtle-158617af.js → shift-away-subtle-0dd94a03.js} +3 -5
- package/build/ssr/index.js +1 -12
- package/build/warning-circle-24f3efcd.js +15 -0
- package/build/{AssetAction-d081e4b7.js → widgets/AssetGallery/AssetGallery.js} +601 -622
- package/build/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.js +127 -0
- package/build/widgets/ContextMenu/ContextMenu.js +26 -0
- package/build/{ContextMenuItem-3967010d.js → widgets/ContextMenu/ContextMenuItem/ContextMenuItem.js} +23 -48
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.js +37 -0
- package/build/{InfoCard-d0fdf377.js → widgets/InfoCard/InfoCard.js} +27 -34
- package/build/widgets/Instructions/Instructions.js +255 -0
- package/build/{ProgressBar-2d26c1fb.js → widgets/ProgressBar/ProgressBar.js} +39 -46
- package/package.json +1 -1
- package/build/AssetPreviewTopBar-623cfa18.js +0 -152
- package/build/ContextMenu-82f9d728.js +0 -33
- package/build/InputGroup-8d4a4644.js +0 -30
- package/build/Instructions-af191987.js +0 -274
- package/build/SectionSeparator-e06c7660.js +0 -38
- package/build/Tab-ccbca1f2.js +0 -39
- package/build/Tooltip-d5882b82.js +0 -73
- package/build/arrow-forward-d7c77ae3.js +0 -37
- package/build/close-1751121a.js +0 -37
- package/build/edit-note-cefe2215.js +0 -37
- package/build/expand-more-d74e2bd2.js +0 -37
- package/build/widgets/AssetGallery/index.js +0 -55
- package/build/widgets/AssetPreview/AssetPreviewTopBar/index.js +0 -12
- package/build/widgets/ContextMenu/ContextMenuItem/index.js +0 -11
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/index.js +0 -44
- package/build/widgets/ContextMenu/index.js +0 -11
- package/build/widgets/InfoCard/index.js +0 -12
- package/build/widgets/Instructions/index.js +0 -33
- package/build/widgets/ProgressBar/index.js +0 -12
- package/build/widgets/index.js +0 -65
|
@@ -1,79 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var useUpdateEffect = require('@restart/hooks/useUpdateEffect');
|
|
21
|
-
|
|
22
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
function _interopNamespace(e) {
|
|
25
|
-
if (e && e.__esModule) return e;
|
|
26
|
-
var n = Object.create(null);
|
|
27
|
-
if (e) {
|
|
28
|
-
Object.keys(e).forEach(function (k) {
|
|
29
|
-
if (k !== 'default') {
|
|
30
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return e[k]; }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
n["default"] = e;
|
|
39
|
-
return Object.freeze(n);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
44
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
45
|
-
var useUpdateEffect__default = /*#__PURE__*/_interopDefaultLegacy(useUpdateEffect);
|
|
1
|
+
import { _ as _extends$1 } from './_rollupPluginBabelHelpers-c245b26a.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default, { useState, useMemo, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
|
4
|
+
import { a as applyDefaultTheme, P as PropTypes } from './defaultTheme-1bcc2541.js';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import './Alert-e6847a22.js';
|
|
7
|
+
import './Badge-d93586a9.js';
|
|
8
|
+
import { P as Popover } from './Popover-20050b91.js';
|
|
9
|
+
import './Tab-04d435c3.js';
|
|
10
|
+
import './Tabs-74d1ea8a.js';
|
|
11
|
+
import './Tooltip-c1d1199e.js';
|
|
12
|
+
import './VerificationStatusIcon-49cb1c1b.js';
|
|
13
|
+
import { C as Checkbox } from './Checkbox-4a5fd716.js';
|
|
14
|
+
import { isEmpty, uniq, isEqual, isArray, isFunction } from 'lodash';
|
|
15
|
+
import { T as TextInput } from './TextInput-fab35842.js';
|
|
16
|
+
import './InputGroup-1294d190.js';
|
|
17
|
+
import { S as SectionSeparator } from './SectionSeparator-f47760a2.js';
|
|
18
|
+
import { S as SvgClose } from './close-a5d37608.js';
|
|
19
|
+
import useUpdateEffect from '@restart/hooks/useUpdateEffect';
|
|
46
20
|
|
|
47
21
|
var _path;
|
|
48
22
|
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); }
|
|
49
23
|
function SvgSearch(props) {
|
|
50
|
-
return /*#__PURE__*/
|
|
24
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
51
25
|
xmlns: "http://www.w3.org/2000/svg",
|
|
52
26
|
viewBox: "0 0 24 24"
|
|
53
|
-
}, props), _path || (_path = /*#__PURE__*/
|
|
27
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
54
28
|
fill: "currentColor",
|
|
55
29
|
d: "M17.153 15.094h-1.084l-.385-.37a8.933 8.933 0 10-.96.96l.37.385v1.084L21.955 24 24 21.955zm-8.234 0a6.175 6.175 0 116.175-6.175 6.167 6.167 0 01-6.175 6.175z"
|
|
56
30
|
})));
|
|
57
31
|
}
|
|
58
32
|
|
|
59
|
-
const MultiLevelCheckbox$1 =
|
|
33
|
+
const MultiLevelCheckbox$1 = styled.fieldset.attrs(applyDefaultTheme)`
|
|
60
34
|
padding: 0;
|
|
61
35
|
border: 0;
|
|
62
36
|
margin: 0;
|
|
63
37
|
`;
|
|
64
|
-
const MultiLevelCheckboxLegend =
|
|
38
|
+
const MultiLevelCheckboxLegend = styled.legend.attrs(applyDefaultTheme)`
|
|
65
39
|
line-height: 1.2;
|
|
66
40
|
font-size: 0.75rem;
|
|
67
41
|
padding: 0 0 4px;
|
|
68
42
|
letter-spacing: 0.03em;
|
|
69
43
|
${props => props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'))}
|
|
70
44
|
`;
|
|
71
|
-
const MultiLevelCheckboxNoResults =
|
|
45
|
+
const MultiLevelCheckboxNoResults = styled.div.attrs(applyDefaultTheme)`
|
|
72
46
|
text-align: center;
|
|
73
47
|
opacity: 0.7;
|
|
74
48
|
font-size: 0.875rem;
|
|
75
49
|
`;
|
|
76
|
-
const CheckboxTreeChildren =
|
|
50
|
+
const CheckboxTreeChildren = styled.div.attrs(applyDefaultTheme)`
|
|
77
51
|
display: grid;
|
|
78
52
|
grid-template-rows: 0fr;
|
|
79
53
|
padding-left: 28px;
|
|
@@ -83,19 +57,19 @@ const CheckboxTreeChildren = styled__default["default"].div.attrs(defaultTheme.a
|
|
|
83
57
|
overflow: hidden;
|
|
84
58
|
}
|
|
85
59
|
|
|
86
|
-
${props => props.$expanded &&
|
|
60
|
+
${props => props.$expanded && css`
|
|
87
61
|
grid-template-rows: 1fr;
|
|
88
62
|
`}
|
|
89
63
|
}
|
|
90
64
|
`;
|
|
91
|
-
const CheckboxTree$1 =
|
|
65
|
+
const CheckboxTree$1 = styled.div.attrs(applyDefaultTheme)`
|
|
92
66
|
width: fit-content;
|
|
93
67
|
`;
|
|
94
|
-
const CheckboxTreeCheckboxContainer =
|
|
68
|
+
const CheckboxTreeCheckboxContainer = styled.div.attrs(applyDefaultTheme)`
|
|
95
69
|
position: relative;
|
|
96
70
|
margin-top: 4px;
|
|
97
71
|
`;
|
|
98
|
-
const ExpandTreeButton =
|
|
72
|
+
const ExpandTreeButton = styled.button.attrs(applyDefaultTheme)`
|
|
99
73
|
-webkit-appearance: none;
|
|
100
74
|
background: none;
|
|
101
75
|
border: none;
|
|
@@ -110,7 +84,7 @@ const ExpandTreeButton = styled__default["default"].button.attrs(defaultTheme.ap
|
|
|
110
84
|
transform: rotate(-90deg);
|
|
111
85
|
transition: transform 250ms;
|
|
112
86
|
|
|
113
|
-
${props => props.$expanded &&
|
|
87
|
+
${props => props.$expanded && css`
|
|
114
88
|
transform: rotate(0deg);
|
|
115
89
|
`}
|
|
116
90
|
}
|
|
@@ -120,7 +94,7 @@ const ExpandTreeButton = styled__default["default"].button.attrs(defaultTheme.ap
|
|
|
120
94
|
function findChildValues(node) {
|
|
121
95
|
const result = [];
|
|
122
96
|
function traverse(node) {
|
|
123
|
-
if (
|
|
97
|
+
if (isArray(node.children) && node.children.length > 0) {
|
|
124
98
|
node.children.forEach(child => {
|
|
125
99
|
result.push(child.value);
|
|
126
100
|
traverse(child);
|
|
@@ -131,7 +105,7 @@ function findChildValues(node) {
|
|
|
131
105
|
return result;
|
|
132
106
|
}
|
|
133
107
|
function hasChildrenSelected(node, targetValue, checkedValues) {
|
|
134
|
-
if (!
|
|
108
|
+
if (!isArray(node.children) || node.children.length === 0) {
|
|
135
109
|
return false;
|
|
136
110
|
}
|
|
137
111
|
if (node.children.some(childNode => checkedValues.includes(childNode.value))) {
|
|
@@ -162,7 +136,7 @@ function getLabelByValue(targetValue, nodes) {
|
|
|
162
136
|
}
|
|
163
137
|
return null;
|
|
164
138
|
}
|
|
165
|
-
const MultiLevelCheckbox = React__default
|
|
139
|
+
const MultiLevelCheckbox = React__default.forwardRef(function MultiLevelCheckbox({
|
|
166
140
|
options,
|
|
167
141
|
checked,
|
|
168
142
|
search,
|
|
@@ -171,9 +145,9 @@ const MultiLevelCheckbox = React__default["default"].forwardRef(function MultiLe
|
|
|
171
145
|
onChange,
|
|
172
146
|
...props
|
|
173
147
|
}, forwardedRef) {
|
|
174
|
-
const [internalChecked, setInternalChecked] =
|
|
175
|
-
const anySearchResults =
|
|
176
|
-
if (
|
|
148
|
+
const [internalChecked, setInternalChecked] = useState(includeAllChildren(checked, options));
|
|
149
|
+
const anySearchResults = useMemo(() => {
|
|
150
|
+
if (isEmpty(search)) {
|
|
177
151
|
return true;
|
|
178
152
|
}
|
|
179
153
|
return options.some(node => {
|
|
@@ -200,23 +174,23 @@ const MultiLevelCheckbox = React__default["default"].forwardRef(function MultiLe
|
|
|
200
174
|
fillSiblings(nodes);
|
|
201
175
|
return newChecked;
|
|
202
176
|
}
|
|
203
|
-
const onAdd =
|
|
204
|
-
setInternalChecked(prevChecked =>
|
|
177
|
+
const onAdd = useCallback(values => {
|
|
178
|
+
setInternalChecked(prevChecked => uniq(includeAllChildren([...prevChecked, ...values], options)));
|
|
205
179
|
}, [options]);
|
|
206
|
-
const onRemove =
|
|
180
|
+
const onRemove = useCallback(values => {
|
|
207
181
|
setInternalChecked(prevChecked => includeAllChildren(prevChecked.filter(v => !values.includes(v)), options, false));
|
|
208
182
|
}, [options]);
|
|
209
|
-
|
|
183
|
+
useEffect(() => {
|
|
210
184
|
onChange([...internalChecked].sort());
|
|
211
185
|
}, [internalChecked, onChange]);
|
|
212
|
-
|
|
213
|
-
if (!
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (!isEqual([...checked].sort(), [...internalChecked].sort())) {
|
|
214
188
|
setInternalChecked(includeAllChildren(checked, options));
|
|
215
189
|
}
|
|
216
190
|
}, [checked, options]);
|
|
217
|
-
return React__default
|
|
191
|
+
return React__default.createElement(MultiLevelCheckbox$1, _extends$1({}, props, {
|
|
218
192
|
ref: forwardedRef
|
|
219
|
-
}), label && React__default
|
|
193
|
+
}), label && React__default.createElement(MultiLevelCheckboxLegend, null, label), options.map(node => React__default.createElement(CheckboxTree, {
|
|
220
194
|
key: node.value,
|
|
221
195
|
nodes: options,
|
|
222
196
|
node: node,
|
|
@@ -224,30 +198,30 @@ const MultiLevelCheckbox = React__default["default"].forwardRef(function MultiLe
|
|
|
224
198
|
onAdd: onAdd,
|
|
225
199
|
onRemove: onRemove,
|
|
226
200
|
search: search
|
|
227
|
-
})), !anySearchResults && React__default
|
|
201
|
+
})), !anySearchResults && React__default.createElement(MultiLevelCheckboxNoResults, null, noResultsText));
|
|
228
202
|
});
|
|
229
|
-
const NodeType =
|
|
230
|
-
label:
|
|
231
|
-
value:
|
|
203
|
+
const NodeType = PropTypes.shape({
|
|
204
|
+
label: PropTypes.string.isRequired,
|
|
205
|
+
value: PropTypes.any.isRequired,
|
|
232
206
|
children: NodeType
|
|
233
207
|
});
|
|
234
208
|
MultiLevelCheckbox.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
235
|
-
options:
|
|
236
|
-
label:
|
|
237
|
-
value:
|
|
238
|
-
children:
|
|
209
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
210
|
+
label: PropTypes.string.isRequired,
|
|
211
|
+
value: PropTypes.any.isRequired,
|
|
212
|
+
children: PropTypes.array
|
|
239
213
|
})),
|
|
240
|
-
checked:
|
|
241
|
-
label:
|
|
242
|
-
search:
|
|
243
|
-
noResultsText:
|
|
244
|
-
onChange:
|
|
214
|
+
checked: PropTypes.array.isRequired,
|
|
215
|
+
label: PropTypes.string,
|
|
216
|
+
search: PropTypes.string,
|
|
217
|
+
noResultsText: PropTypes.string,
|
|
218
|
+
onChange: PropTypes.func.isRequired
|
|
245
219
|
} : {};
|
|
246
220
|
MultiLevelCheckbox.defaultProps = {
|
|
247
221
|
options: [],
|
|
248
222
|
noResultsText: 'No results.'
|
|
249
223
|
};
|
|
250
|
-
const CheckboxTree = React__default
|
|
224
|
+
const CheckboxTree = React__default.memo(function CheckboxTree({
|
|
251
225
|
node,
|
|
252
226
|
nodes,
|
|
253
227
|
checked,
|
|
@@ -255,37 +229,37 @@ const CheckboxTree = React__default["default"].memo(function CheckboxTree({
|
|
|
255
229
|
onRemove,
|
|
256
230
|
search = ''
|
|
257
231
|
}) {
|
|
258
|
-
const [expanded, setExpanded] =
|
|
259
|
-
const [expandedBySearch, setExpandedBySearch] =
|
|
260
|
-
const onChange =
|
|
232
|
+
const [expanded, setExpanded] = useState(false);
|
|
233
|
+
const [expandedBySearch, setExpandedBySearch] = useState(false);
|
|
234
|
+
const onChange = useCallback(event => {
|
|
261
235
|
if (event.target.checked) {
|
|
262
236
|
onAdd([event.target.value, ...findChildValues(node)]);
|
|
263
237
|
} else {
|
|
264
238
|
onRemove([event.target.value, ...findChildValues(node)]);
|
|
265
239
|
}
|
|
266
240
|
}, [onAdd, onRemove]);
|
|
267
|
-
const onChildrenAdd =
|
|
241
|
+
const onChildrenAdd = useCallback(newValues => {
|
|
268
242
|
if (hasAllChildrenSelected(node, '', [...newValues, ...checked])) {
|
|
269
243
|
return onAdd([node.value, ...newValues]);
|
|
270
244
|
}
|
|
271
245
|
onAdd(newValues);
|
|
272
246
|
}, [node, checked, onAdd]);
|
|
273
|
-
const hideOption =
|
|
274
|
-
if (
|
|
247
|
+
const hideOption = useMemo(() => {
|
|
248
|
+
if (isEmpty(search)) {
|
|
275
249
|
return;
|
|
276
250
|
}
|
|
277
251
|
const childValues = findChildValues(node);
|
|
278
252
|
return ![node.value, ...childValues].map(v => getLabelByValue(v, nodes)).some(v => v.match(new RegExp(search, 'i')));
|
|
279
253
|
}, [node, nodes, search]);
|
|
280
|
-
|
|
254
|
+
useEffect(() => {
|
|
281
255
|
const childValues = findChildValues(node);
|
|
282
|
-
const expandBySearch = !
|
|
256
|
+
const expandBySearch = !isEmpty(search) && [node.value, ...childValues].map(v => getLabelByValue(v, nodes)).some(v => v.match(new RegExp(search, 'i')));
|
|
283
257
|
setExpandedBySearch(expandBySearch);
|
|
284
258
|
}, [search, nodes, node.value]);
|
|
285
259
|
if (hideOption) {
|
|
286
260
|
return null;
|
|
287
261
|
}
|
|
288
|
-
return React__default
|
|
262
|
+
return React__default.createElement(CheckboxTree$1, null, React__default.createElement(CheckboxTreeCheckboxContainer, null, isArray(node.children) && node.children.length > 0 && React__default.createElement(ExpandTreeButton, {
|
|
289
263
|
$expanded: expanded || expandedBySearch,
|
|
290
264
|
type: "button",
|
|
291
265
|
onClick: () => {
|
|
@@ -298,14 +272,14 @@ const CheckboxTree = React__default["default"].memo(function CheckboxTree({
|
|
|
298
272
|
return false;
|
|
299
273
|
});
|
|
300
274
|
}
|
|
301
|
-
}, React__default
|
|
275
|
+
}, React__default.createElement("svg", {
|
|
302
276
|
xmlns: "http://www.w3.org/2000/svg",
|
|
303
277
|
viewBox: "0 0 12 7.4"
|
|
304
|
-
}, React__default
|
|
278
|
+
}, React__default.createElement("path", {
|
|
305
279
|
fill: "currentColor",
|
|
306
280
|
d: "m6,7.4L0,1.4,1.4,0l4.6,4.6L10.6,0l1.4,1.4-6,6Z",
|
|
307
281
|
strokeWidth: "0"
|
|
308
|
-
}))), React__default
|
|
282
|
+
}))), React__default.createElement(Checkbox, {
|
|
309
283
|
style: {
|
|
310
284
|
paddingLeft: 24
|
|
311
285
|
},
|
|
@@ -315,9 +289,9 @@ const CheckboxTree = React__default["default"].memo(function CheckboxTree({
|
|
|
315
289
|
checked: hasChildrenSelected(node, node.value, checked) || checked.includes(node.value),
|
|
316
290
|
value: node.value,
|
|
317
291
|
onChange: onChange
|
|
318
|
-
})), node.children && React__default
|
|
292
|
+
})), node.children && React__default.createElement(CheckboxTreeChildren, {
|
|
319
293
|
$expanded: expanded || expandedBySearch
|
|
320
|
-
}, React__default
|
|
294
|
+
}, React__default.createElement("div", null, node.children.map(childNode => React__default.createElement(CheckboxTree, {
|
|
321
295
|
key: childNode.value,
|
|
322
296
|
checked: checked.filter(c => [childNode.value, ...findChildValues(childNode)].includes(c)),
|
|
323
297
|
onAdd: onChildrenAdd,
|
|
@@ -326,36 +300,36 @@ const CheckboxTree = React__default["default"].memo(function CheckboxTree({
|
|
|
326
300
|
nodes: nodes,
|
|
327
301
|
search: search
|
|
328
302
|
})))));
|
|
329
|
-
},
|
|
303
|
+
}, isEqual);
|
|
330
304
|
CheckboxTree.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
331
|
-
node:
|
|
332
|
-
label:
|
|
333
|
-
value:
|
|
334
|
-
children:
|
|
335
|
-
label:
|
|
336
|
-
value:
|
|
337
|
-
children:
|
|
305
|
+
node: PropTypes.shape({
|
|
306
|
+
label: PropTypes.string.isRequired,
|
|
307
|
+
value: PropTypes.any.isRequired,
|
|
308
|
+
children: PropTypes.arrayOf(PropTypes.shape({
|
|
309
|
+
label: PropTypes.string.isRequired,
|
|
310
|
+
value: PropTypes.any.isRequired,
|
|
311
|
+
children: PropTypes.arrayOf(PropTypes.any)
|
|
338
312
|
}))
|
|
339
313
|
}),
|
|
340
|
-
nodes:
|
|
341
|
-
label:
|
|
342
|
-
value:
|
|
343
|
-
children:
|
|
344
|
-
label:
|
|
345
|
-
value:
|
|
346
|
-
children:
|
|
314
|
+
nodes: PropTypes.arrayOf(PropTypes.shape({
|
|
315
|
+
label: PropTypes.string.isRequired,
|
|
316
|
+
value: PropTypes.any.isRequired,
|
|
317
|
+
children: PropTypes.arrayOf(PropTypes.shape({
|
|
318
|
+
label: PropTypes.string.isRequired,
|
|
319
|
+
value: PropTypes.any.isRequired,
|
|
320
|
+
children: PropTypes.arrayOf(PropTypes.any)
|
|
347
321
|
}))
|
|
348
322
|
})),
|
|
349
|
-
checked:
|
|
350
|
-
search:
|
|
351
|
-
onAdd:
|
|
352
|
-
onRemove:
|
|
323
|
+
checked: PropTypes.array.isRequired,
|
|
324
|
+
search: PropTypes.string,
|
|
325
|
+
onAdd: PropTypes.func.isRequired,
|
|
326
|
+
onRemove: PropTypes.func.isRequired
|
|
353
327
|
} : {};
|
|
354
328
|
|
|
355
|
-
const MultiLevelCheckboxSelect$1 =
|
|
329
|
+
const MultiLevelCheckboxSelect$1 = styled.div.attrs(applyDefaultTheme)`
|
|
356
330
|
font-family: ${props => props.theme.primaryFontFamily};
|
|
357
331
|
`;
|
|
358
|
-
const MultiLevelCheckboxSelectInput =
|
|
332
|
+
const MultiLevelCheckboxSelectInput = styled.div.attrs(applyDefaultTheme)`
|
|
359
333
|
position: relative;
|
|
360
334
|
border: 1px solid;
|
|
361
335
|
${props => props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'))}
|
|
@@ -372,7 +346,7 @@ const MultiLevelCheckboxSelectInput = styled__default["default"].div.attrs(defau
|
|
|
372
346
|
${props => props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'), 1)}
|
|
373
347
|
}
|
|
374
348
|
`;
|
|
375
|
-
const Item =
|
|
349
|
+
const Item = styled.div.attrs(applyDefaultTheme)`
|
|
376
350
|
display: flex;
|
|
377
351
|
align-items: center;
|
|
378
352
|
background: #272727;
|
|
@@ -381,10 +355,10 @@ const Item = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme
|
|
|
381
355
|
height: 26px;
|
|
382
356
|
border-radius: 3px;
|
|
383
357
|
`;
|
|
384
|
-
const ItemLabel =
|
|
358
|
+
const ItemLabel = styled.div.attrs(applyDefaultTheme)`
|
|
385
359
|
padding: 0 5px 0 8px;
|
|
386
360
|
`;
|
|
387
|
-
const ItemRemoveButton =
|
|
361
|
+
const ItemRemoveButton = styled.button.attrs(applyDefaultTheme)`
|
|
388
362
|
color: inherit;
|
|
389
363
|
border: none;
|
|
390
364
|
background: none;
|
|
@@ -404,7 +378,7 @@ const ItemRemoveButton = styled__default["default"].button.attrs(defaultTheme.ap
|
|
|
404
378
|
display: block;
|
|
405
379
|
}
|
|
406
380
|
`;
|
|
407
|
-
const Label =
|
|
381
|
+
const Label = styled.div.attrs(applyDefaultTheme)`
|
|
408
382
|
position: absolute;
|
|
409
383
|
top: -8px;
|
|
410
384
|
left: 7px;
|
|
@@ -417,37 +391,37 @@ const Label = styled__default["default"].div.attrs(defaultTheme.applyDefaultThem
|
|
|
417
391
|
${props => props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'))}
|
|
418
392
|
${props => props.theme.themeProp('background', `linear-gradient(0deg, ${props.theme.getColor('gray-900')} calc(50% + 1px), transparent 50%)`, `linear-gradient(0deg, ${props.theme.getColor('white')} calc(50% + 1px), transparent 50%)`)}
|
|
419
393
|
`;
|
|
420
|
-
const Placeholder =
|
|
394
|
+
const Placeholder = styled.div.attrs(applyDefaultTheme)`
|
|
421
395
|
font-size: 0.875rem;
|
|
422
396
|
line-height: 26px;
|
|
423
397
|
padding-left: 4px;
|
|
424
398
|
opacity: 0.4;
|
|
425
399
|
`;
|
|
426
|
-
const PopoverContainer =
|
|
400
|
+
const PopoverContainer = styled.div.attrs(applyDefaultTheme)`
|
|
427
401
|
max-height: inherit;
|
|
428
402
|
display: flex;
|
|
429
403
|
flex-direction: column;
|
|
430
404
|
`;
|
|
431
|
-
const PopoverHeader =
|
|
405
|
+
const PopoverHeader = styled.div.attrs(applyDefaultTheme)`
|
|
432
406
|
${props => props.theme.themeProp('background', props.theme.getColor('gray-700'), props.theme.getColor('white'))}
|
|
433
407
|
`;
|
|
434
|
-
const SearchContainer =
|
|
408
|
+
const SearchContainer = styled.div.attrs(applyDefaultTheme)`
|
|
435
409
|
padding: 12px 8px;
|
|
436
410
|
`;
|
|
437
|
-
const OptionsContainer =
|
|
411
|
+
const OptionsContainer = styled.div.attrs(applyDefaultTheme)`
|
|
438
412
|
padding: 12px 8px;
|
|
439
413
|
overflow: auto;
|
|
440
414
|
box-sizing: border-box;
|
|
441
415
|
`;
|
|
442
416
|
|
|
443
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ?
|
|
417
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
444
418
|
|
|
445
419
|
function useEventListener(eventName, handler, element, options) {
|
|
446
|
-
const savedHandler =
|
|
420
|
+
const savedHandler = useRef(handler);
|
|
447
421
|
useIsomorphicLayoutEffect(() => {
|
|
448
422
|
savedHandler.current = handler;
|
|
449
423
|
}, [handler]);
|
|
450
|
-
|
|
424
|
+
useEffect(() => {
|
|
451
425
|
const targetElement = element?.current ?? window;
|
|
452
426
|
if (!(targetElement && targetElement.addEventListener)) return;
|
|
453
427
|
const listener = event => savedHandler.current(event);
|
|
@@ -468,7 +442,7 @@ function useOnClickOutside(ref, handler, mouseEvent = 'mousedown') {
|
|
|
468
442
|
});
|
|
469
443
|
}
|
|
470
444
|
|
|
471
|
-
const MultiLevelCheckboxSelect = React__default
|
|
445
|
+
const MultiLevelCheckboxSelect = React__default.forwardRef(function MultiLevelCheckboxSelect({
|
|
472
446
|
label,
|
|
473
447
|
options,
|
|
474
448
|
checked: checkedProp,
|
|
@@ -478,16 +452,16 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
478
452
|
onParentChange,
|
|
479
453
|
...props
|
|
480
454
|
}, forwardedRef) {
|
|
481
|
-
const inputRef =
|
|
482
|
-
const popoverContentRef =
|
|
483
|
-
const searchInputRef =
|
|
484
|
-
const [searchString, setSearchString] =
|
|
485
|
-
const [open, setOpen] =
|
|
486
|
-
const handleClickInside =
|
|
455
|
+
const inputRef = useRef(null);
|
|
456
|
+
const popoverContentRef = useRef(null);
|
|
457
|
+
const searchInputRef = useRef(null);
|
|
458
|
+
const [searchString, setSearchString] = useState('');
|
|
459
|
+
const [open, setOpen] = useState(false);
|
|
460
|
+
const handleClickInside = useCallback(() => {
|
|
487
461
|
setOpen(true);
|
|
488
462
|
searchInputRef.current?.focus();
|
|
489
463
|
}, []);
|
|
490
|
-
const handleKeyDown =
|
|
464
|
+
const handleKeyDown = useCallback(event => {
|
|
491
465
|
if (!open) return;
|
|
492
466
|
if (event.key === 'Escape') {
|
|
493
467
|
setOpen(false);
|
|
@@ -503,7 +477,7 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
503
477
|
setOpen(false);
|
|
504
478
|
};
|
|
505
479
|
useOnClickOutside(inputRef, handleClickOutside);
|
|
506
|
-
const checked =
|
|
480
|
+
const checked = useMemo(() => {
|
|
507
481
|
const checkedParents = [];
|
|
508
482
|
function iterate(nodes) {
|
|
509
483
|
nodes.forEach(node => {
|
|
@@ -518,7 +492,7 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
518
492
|
iterate(options);
|
|
519
493
|
return checkedParents.sort();
|
|
520
494
|
}, [JSON.stringify(options), JSON.stringify(checkedProp)]);
|
|
521
|
-
const getLabelByValue =
|
|
495
|
+
const getLabelByValue = useCallback((targetValue, nodes = options) => {
|
|
522
496
|
for (const node of nodes) {
|
|
523
497
|
if (node.value === targetValue) {
|
|
524
498
|
return node.label;
|
|
@@ -532,7 +506,7 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
532
506
|
}
|
|
533
507
|
return null;
|
|
534
508
|
}, [options]);
|
|
535
|
-
const removeItem =
|
|
509
|
+
const removeItem = useCallback(value => {
|
|
536
510
|
let node = null;
|
|
537
511
|
function findNodeByValue(options, value) {
|
|
538
512
|
for (let i = 0; i < options.length; i++) {
|
|
@@ -552,14 +526,14 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
552
526
|
onChange(checkedProp.filter(value => !valuesToRemove.includes(value)));
|
|
553
527
|
}
|
|
554
528
|
}, [options, checkedProp]);
|
|
555
|
-
|
|
556
|
-
if (
|
|
529
|
+
useUpdateEffect(() => {
|
|
530
|
+
if (isFunction(onParentChange)) {
|
|
557
531
|
onParentChange(checked);
|
|
558
532
|
}
|
|
559
533
|
}, [checked]);
|
|
560
|
-
return React__default
|
|
534
|
+
return React__default.createElement(MultiLevelCheckboxSelect$1, _extends$1({
|
|
561
535
|
ref: forwardedRef
|
|
562
|
-
}, props), React__default
|
|
536
|
+
}, props), React__default.createElement(Popover, {
|
|
563
537
|
visible: open,
|
|
564
538
|
arrow: false,
|
|
565
539
|
placement: 'bottom',
|
|
@@ -580,53 +554,51 @@ const MultiLevelCheckboxSelect = React__default["default"].forwardRef(function M
|
|
|
580
554
|
state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`;
|
|
581
555
|
}
|
|
582
556
|
}],
|
|
583
|
-
content: React__default
|
|
557
|
+
content: React__default.createElement(PopoverContainer, {
|
|
584
558
|
ref: popoverContentRef
|
|
585
|
-
}, React__default
|
|
559
|
+
}, React__default.createElement(PopoverHeader, null, React__default.createElement(SearchContainer, null, React__default.createElement(TextInput, {
|
|
586
560
|
ref: searchInputRef,
|
|
587
561
|
onBlur: e => {
|
|
588
562
|
if (open) {
|
|
589
563
|
e.target.focus();
|
|
590
564
|
}
|
|
591
565
|
},
|
|
592
|
-
icon: React__default
|
|
566
|
+
icon: React__default.createElement(SvgSearch, null),
|
|
593
567
|
value: searchString,
|
|
594
568
|
onChange: e => setSearchString(e.target.value)
|
|
595
|
-
})), React__default
|
|
569
|
+
})), React__default.createElement(SectionSeparator, null)), React__default.createElement(OptionsContainer, null, React__default.createElement(MultiLevelCheckbox, {
|
|
596
570
|
options: options,
|
|
597
571
|
checked: checkedProp,
|
|
598
572
|
search: searchString,
|
|
599
573
|
noResultsText: noResultsText,
|
|
600
574
|
onChange: onChange
|
|
601
575
|
})))
|
|
602
|
-
}, React__default
|
|
576
|
+
}, React__default.createElement(MultiLevelCheckboxSelectInput, {
|
|
603
577
|
tabIndex: "0",
|
|
604
578
|
ref: inputRef
|
|
605
|
-
}, label && React__default
|
|
579
|
+
}, label && React__default.createElement(Label, null, label), checked.length === 0 && React__default.createElement(Placeholder, null, placeholder), checked.map(option => React__default.createElement(Item, {
|
|
606
580
|
key: option
|
|
607
|
-
}, React__default
|
|
581
|
+
}, React__default.createElement(ItemLabel, null, getLabelByValue(option)), React__default.createElement(ItemRemoveButton, {
|
|
608
582
|
onClick: () => {
|
|
609
583
|
removeItem(option);
|
|
610
584
|
}
|
|
611
|
-
}, React__default
|
|
585
|
+
}, React__default.createElement(SvgClose, null)))))));
|
|
612
586
|
});
|
|
613
587
|
MultiLevelCheckboxSelect.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
614
|
-
label:
|
|
615
|
-
placeholder:
|
|
616
|
-
options:
|
|
617
|
-
label:
|
|
618
|
-
value:
|
|
619
|
-
children:
|
|
588
|
+
label: PropTypes.string,
|
|
589
|
+
placeholder: PropTypes.string,
|
|
590
|
+
options: PropTypes.arrayOf(PropTypes.shape({
|
|
591
|
+
label: PropTypes.string.isRequired,
|
|
592
|
+
value: PropTypes.any.isRequired,
|
|
593
|
+
children: PropTypes.arrayOf(NodeType)
|
|
620
594
|
})).isRequired,
|
|
621
|
-
checked:
|
|
622
|
-
noResultsText:
|
|
623
|
-
onChange:
|
|
624
|
-
onParentChange:
|
|
595
|
+
checked: PropTypes.array.isRequired,
|
|
596
|
+
noResultsText: PropTypes.string,
|
|
597
|
+
onChange: PropTypes.func.isRequired,
|
|
598
|
+
onParentChange: PropTypes.func
|
|
625
599
|
} : {};
|
|
626
600
|
MultiLevelCheckboxSelect.defaultProps = {
|
|
627
601
|
checked: []
|
|
628
602
|
};
|
|
629
603
|
|
|
630
|
-
|
|
631
|
-
exports.MultiLevelCheckboxSelect = MultiLevelCheckboxSelect;
|
|
632
|
-
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
604
|
+
export { MultiLevelCheckbox as M, MultiLevelCheckboxSelect as a, useIsomorphicLayoutEffect as u };
|