@elliemae/ds-pills 2.2.0-alpha.2 → 2.2.0-beta.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/cjs/components/Pill.js +49 -56
- package/cjs/components/PillButton.js +52 -54
- package/cjs/components/PillGroup.js +53 -61
- package/cjs/components/index.js +17 -30
- package/cjs/components/styled.js +78 -228
- package/cjs/components/types/DropdownPill.js +77 -79
- package/cjs/components/types/InputPill.js +48 -58
- package/cjs/components/types/LabelPill.js +38 -44
- package/cjs/components/types/ReadOnlyPill.js +43 -48
- package/cjs/components/types/RemovablePill.js +53 -60
- package/cjs/components/types/ValuePill.js +43 -48
- package/cjs/components/types/index.js +19 -33
- package/cjs/deprecated/DropdownPill.js +101 -80
- package/cjs/deprecated/InputPill.js +69 -67
- package/cjs/deprecated/LabeledDropdownPills.js +96 -92
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +94 -91
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +114 -106
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +127 -119
- package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js +15 -39
- package/cjs/deprecated/LabeledPills.js +52 -65
- package/cjs/deprecated/OverflowPill.js +53 -59
- package/cjs/deprecated/Pill.js +82 -67
- package/cjs/deprecated/PillGroup.js +68 -68
- package/cjs/deprecated/ReadOnlyPill.js +94 -93
- package/cjs/deprecated/RemovablePill.js +57 -61
- package/cjs/deprecated/index.js +33 -43
- package/cjs/index.d.js +2 -27
- package/cjs/index.js +43 -37
- package/cjs/props.js +46 -72
- package/cjs/utils.js +25 -43
- package/esm/components/Pill.js +31 -18
- package/esm/components/PillButton.js +39 -22
- package/esm/components/PillGroup.js +38 -28
- package/esm/components/index.js +3 -5
- package/esm/components/styled.js +66 -205
- package/esm/components/types/DropdownPill.js +67 -50
- package/esm/components/types/InputPill.js +35 -25
- package/esm/components/types/LabelPill.js +29 -15
- package/esm/components/types/ReadOnlyPill.js +34 -19
- package/esm/components/types/RemovablePill.js +44 -31
- package/esm/components/types/ValuePill.js +34 -19
- package/esm/components/types/index.js +6 -8
- package/esm/deprecated/DropdownPill.js +86 -49
- package/esm/deprecated/InputPill.js +59 -38
- package/esm/deprecated/LabeledDropdownPills.js +81 -59
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +84 -60
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +94 -65
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +108 -79
- package/esm/deprecated/LabeledDropdownPillsTypes/utils.js +10 -9
- package/esm/deprecated/LabeledPills.js +41 -34
- package/esm/deprecated/OverflowPill.js +37 -25
- package/esm/deprecated/Pill.js +71 -39
- package/esm/deprecated/PillGroup.js +56 -39
- package/esm/deprecated/ReadOnlyPill.js +79 -60
- package/esm/deprecated/RemovablePill.js +45 -30
- package/esm/deprecated/index.js +8 -14
- package/esm/index.d.js +1 -2
- package/esm/index.js +11 -8
- package/esm/props.js +36 -42
- package/esm/utils.js +23 -16
- package/package.json +15 -15
- package/types/components/PillGroup.d.ts +1 -1
- package/types/deprecated/DropdownPill.d.ts +1 -10
- package/types/deprecated/LabeledDropdownPills.d.ts +1 -12
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.d.ts +1 -3
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.d.ts +1 -3
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.d.ts +0 -1
- package/types/deprecated/LabeledPills.d.ts +1 -8
- package/types/deprecated/OverflowPill.d.ts +1 -5
- package/types/deprecated/Pill.d.ts +1 -9
- package/types/deprecated/PillGroup.d.ts +1 -7
- package/types/deprecated/ReadOnlyPill.d.ts +1 -8
- package/types/deprecated/RemovablePill.d.ts +1 -7
- package/cjs/components/Pill.js.map +0 -7
- package/cjs/components/PillButton.js.map +0 -7
- package/cjs/components/PillGroup.js.map +0 -7
- package/cjs/components/index.js.map +0 -7
- package/cjs/components/styled.js.map +0 -7
- package/cjs/components/types/DropdownPill.js.map +0 -7
- package/cjs/components/types/InputPill.js.map +0 -7
- package/cjs/components/types/LabelPill.js.map +0 -7
- package/cjs/components/types/ReadOnlyPill.js.map +0 -7
- package/cjs/components/types/RemovablePill.js.map +0 -7
- package/cjs/components/types/ValuePill.js.map +0 -7
- package/cjs/components/types/index.js.map +0 -7
- package/cjs/deprecated/DropdownPill.js.map +0 -7
- package/cjs/deprecated/InputPill.js.map +0 -7
- package/cjs/deprecated/LabeledDropdownPills.js.map +0 -7
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
- package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
- package/cjs/deprecated/LabeledPills.js.map +0 -7
- package/cjs/deprecated/OverflowPill.js.map +0 -7
- package/cjs/deprecated/Pill.js.map +0 -7
- package/cjs/deprecated/PillGroup.js.map +0 -7
- package/cjs/deprecated/ReadOnlyPill.js.map +0 -7
- package/cjs/deprecated/RemovablePill.js.map +0 -7
- package/cjs/deprecated/index.js.map +0 -7
- package/cjs/index.d.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/props.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/esm/components/Pill.js.map +0 -7
- package/esm/components/PillButton.js.map +0 -7
- package/esm/components/PillGroup.js.map +0 -7
- package/esm/components/index.js.map +0 -7
- package/esm/components/styled.js.map +0 -7
- package/esm/components/types/DropdownPill.js.map +0 -7
- package/esm/components/types/InputPill.js.map +0 -7
- package/esm/components/types/LabelPill.js.map +0 -7
- package/esm/components/types/ReadOnlyPill.js.map +0 -7
- package/esm/components/types/RemovablePill.js.map +0 -7
- package/esm/components/types/ValuePill.js.map +0 -7
- package/esm/components/types/index.js.map +0 -7
- package/esm/deprecated/DropdownPill.js.map +0 -7
- package/esm/deprecated/InputPill.js.map +0 -7
- package/esm/deprecated/LabeledDropdownPills.js.map +0 -7
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +0 -7
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +0 -7
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +0 -7
- package/esm/deprecated/LabeledDropdownPillsTypes/utils.js.map +0 -7
- package/esm/deprecated/LabeledPills.js.map +0 -7
- package/esm/deprecated/OverflowPill.js.map +0 -7
- package/esm/deprecated/Pill.js.map +0 -7
- package/esm/deprecated/PillGroup.js.map +0 -7
- package/esm/deprecated/ReadOnlyPill.js.map +0 -7
- package/esm/deprecated/RemovablePill.js.map +0 -7
- package/esm/deprecated/index.js.map +0 -7
- package/esm/index.d.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/props.js.map +0 -7
- package/esm/utils.js.map +0 -7
|
@@ -1,102 +1,126 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
5
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
12
|
+
import { createElement } from 'react';
|
|
13
|
+
import { isFunction, addOrRemove } from '@elliemae/ds-utilities';
|
|
14
|
+
import { PillGroup } from '../PillGroup.js';
|
|
15
|
+
import { RemovablePill } from '../RemovablePill.js';
|
|
16
|
+
import { DropdownPill } from '../DropdownPill.js';
|
|
17
|
+
import { jsx } from 'react/jsx-runtime';
|
|
18
|
+
|
|
19
|
+
const _excluded = ["label", "options", "value", "onChange", "onRemove", "value", "placeholder", "onFocusNextGroup", "onFocusPreviousGroup", "onFocusGroupSet", "maxWidth", "minWidth"];
|
|
20
|
+
|
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
+
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
+
|
|
7
25
|
function renderMenuItems(options, factory) {
|
|
8
26
|
return options.map((option, index) => {
|
|
9
|
-
const ItemComponent = factory(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
const ItemComponent = factory('radio');
|
|
28
|
+
|
|
29
|
+
if (option.type === 'submenu') {
|
|
30
|
+
const SubmenuComponent = factory('submenu');
|
|
31
|
+
const ChildComponent = factory('selection-group');
|
|
32
|
+
return /*#__PURE__*/createElement(SubmenuComponent, _objectSpread(_objectSpread({}, option), {}, {
|
|
15
33
|
key: option.id,
|
|
16
34
|
item: option
|
|
17
|
-
},
|
|
18
|
-
...option,
|
|
35
|
+
}), /*#__PURE__*/jsx(ChildComponent, _objectSpread(_objectSpread({}, option), {}, {
|
|
19
36
|
id: option.id,
|
|
20
37
|
item: option,
|
|
21
38
|
items: option.items,
|
|
22
|
-
itemValueAccessor:
|
|
39
|
+
itemValueAccessor: item => item,
|
|
23
40
|
multi: true
|
|
24
|
-
}));
|
|
41
|
+
})));
|
|
25
42
|
}
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/createElement(ItemComponent, _objectSpread(_objectSpread({}, option), {}, {
|
|
28
45
|
key: option.id || index,
|
|
29
46
|
item: option
|
|
30
|
-
});
|
|
47
|
+
}));
|
|
31
48
|
});
|
|
32
49
|
}
|
|
50
|
+
|
|
33
51
|
const getSubmenuOptionLabelById = (options, id) => {
|
|
34
|
-
const index = options.findIndex(
|
|
35
|
-
return index ? options[index].label :
|
|
52
|
+
const index = options.findIndex(option => option.id === id);
|
|
53
|
+
return index ? options[index].label : '';
|
|
36
54
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
|
|
56
|
+
function LabeledDropdownCascadeMenuPill(_ref) {
|
|
57
|
+
let {
|
|
58
|
+
label,
|
|
59
|
+
options,
|
|
60
|
+
value: optionValue,
|
|
61
|
+
onChange,
|
|
62
|
+
onRemove,
|
|
63
|
+
value: selection = {},
|
|
64
|
+
placeholder = '---',
|
|
65
|
+
onFocusNextGroup,
|
|
66
|
+
onFocusPreviousGroup,
|
|
67
|
+
onFocusGroupSet,
|
|
68
|
+
maxWidth,
|
|
69
|
+
minWidth
|
|
70
|
+
} = _ref,
|
|
71
|
+
menuProps = _objectWithoutProperties(_ref, _excluded);
|
|
72
|
+
|
|
52
73
|
const selectionId = Object.keys(selection)[0];
|
|
53
|
-
const selectionValues = selection[selectionId] ||
|
|
74
|
+
const selectionValues = selection[selectionId] || '';
|
|
54
75
|
const dropdownLabel = Array.isArray(selectionValues) ? getSubmenuOptionLabelById(options, selectionId) : selectionValues;
|
|
55
|
-
|
|
76
|
+
|
|
77
|
+
const handleSelectChange = _ref2 => {
|
|
78
|
+
let {
|
|
79
|
+
item,
|
|
80
|
+
group
|
|
81
|
+
} = _ref2;
|
|
82
|
+
|
|
56
83
|
if (isFunction(onChange)) {
|
|
57
84
|
const nextSelection = group ? {
|
|
58
|
-
[group.id]: addOrRemove([...selection[group.id] || []], item,
|
|
85
|
+
[group.id]: addOrRemove([...(selection[group.id] || [])], item, o => o.id)
|
|
59
86
|
} : {
|
|
60
87
|
[item.id]: item.label
|
|
61
88
|
};
|
|
62
89
|
onChange(nextSelection);
|
|
63
90
|
}
|
|
64
91
|
};
|
|
65
|
-
|
|
92
|
+
|
|
93
|
+
const removeOption = option => {
|
|
66
94
|
if (isFunction(onChange)) {
|
|
67
95
|
const nextSelection = {
|
|
68
|
-
[selectionId]: selectionValues.filter(
|
|
96
|
+
[selectionId]: selectionValues.filter(val => option.id !== val.id)
|
|
69
97
|
};
|
|
70
98
|
onChange(nextSelection);
|
|
71
99
|
}
|
|
100
|
+
|
|
72
101
|
onRemove(option);
|
|
73
102
|
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
103
|
+
|
|
104
|
+
return /*#__PURE__*/_jsx(PillGroup, {
|
|
105
|
+
onFocusGroupSet: onFocusGroupSet,
|
|
106
|
+
onFocusNextGroup: onFocusNextGroup,
|
|
107
|
+
onFocusPreviousGroup: onFocusPreviousGroup
|
|
108
|
+
}, void 0, /*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
|
|
80
109
|
itemsRenderer: renderMenuItems,
|
|
81
110
|
label: dropdownLabel || placeholder,
|
|
82
|
-
maxWidth,
|
|
83
|
-
minWidth,
|
|
111
|
+
maxWidth: maxWidth,
|
|
112
|
+
minWidth: minWidth,
|
|
84
113
|
onSelectChange: handleSelectChange,
|
|
85
|
-
options,
|
|
114
|
+
options: options,
|
|
86
115
|
selection: {
|
|
87
|
-
[selectionId]: Array.isArray(selectionValues) ? selectionValues.map(
|
|
116
|
+
[selectionId]: Array.isArray(selectionValues) ? selectionValues.map(v => v.id) : selectionValues
|
|
88
117
|
},
|
|
89
118
|
singleGroupSelection: true,
|
|
90
119
|
variant: "title"
|
|
91
|
-
}), Array.isArray(selectionValues) && selectionValues.map(
|
|
92
|
-
key: option.id,
|
|
120
|
+
})), Array.isArray(selectionValues) && selectionValues.map(option => /*#__PURE__*/_jsx(RemovablePill, {
|
|
93
121
|
label: option.label,
|
|
94
122
|
onRemove: () => removeOption(option)
|
|
95
|
-
})));
|
|
123
|
+
}, option.id)));
|
|
96
124
|
}
|
|
97
|
-
|
|
98
|
-
export {
|
|
99
|
-
LabeledDropdownCascadeMenuPill,
|
|
100
|
-
LabeledDropdownCascadeMenuPill_default as default
|
|
101
|
-
};
|
|
102
|
-
//# sourceMappingURL=LabeledDropdownCascadeMenuPill.js.map
|
|
125
|
+
|
|
126
|
+
export { LabeledDropdownCascadeMenuPill as default };
|
|
@@ -1,22 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
13
|
+
import { find } from 'lodash';
|
|
14
|
+
import { isFunction, addOrRemove } from '@elliemae/ds-utilities';
|
|
15
|
+
import { RemovablePill } from '../RemovablePill.js';
|
|
16
|
+
import { Pill } from '../Pill.js';
|
|
17
|
+
import { OverflowPill } from '../OverflowPill.js';
|
|
18
|
+
import { DropdownPill } from '../DropdownPill.js';
|
|
19
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
20
|
+
|
|
21
|
+
const _excluded = ["label", "options", "value", "onSelect", "onRemove", "onChange", "maxWidth", "minWidth"];
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
+
function LabeledDropdownMultiPills(_ref) {
|
|
27
|
+
let {
|
|
28
|
+
label,
|
|
29
|
+
options = [],
|
|
30
|
+
value = [],
|
|
31
|
+
onSelect = () => null,
|
|
32
|
+
onRemove = () => null,
|
|
33
|
+
onChange,
|
|
34
|
+
// if this is defined, then it's calculating the next result onSelect or onRemove
|
|
35
|
+
maxWidth,
|
|
36
|
+
minWidth
|
|
37
|
+
} = _ref,
|
|
38
|
+
menuProps = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
|
|
20
40
|
const [totalDefaultOptions, setTotalDefaultOptions] = useState(0);
|
|
21
41
|
const [selectedOptions, setSelectedOptions] = useState(value);
|
|
22
42
|
const [allOptions, setAllOptions] = useState(options);
|
|
@@ -24,19 +44,28 @@ function LabeledDropdownMultiPills({
|
|
|
24
44
|
const overflowQuantity = 3;
|
|
25
45
|
useEffect(() => setSelectedOptions(value), [value]);
|
|
26
46
|
useEffect(() => {
|
|
27
|
-
const newOptions = allOptions.filter(
|
|
47
|
+
const newOptions = allOptions.filter(option => option.fixedItem);
|
|
48
|
+
|
|
28
49
|
if (newOptions.length > 0) {
|
|
29
50
|
setSelectedOptions(newOptions);
|
|
30
51
|
}
|
|
52
|
+
|
|
31
53
|
setTotalDefaultOptions(newOptions.length);
|
|
32
54
|
}, []);
|
|
33
55
|
useEffect(() => {
|
|
34
56
|
if (totalDefaultOptions) {
|
|
35
|
-
const newOptions = allOptions.map(
|
|
36
|
-
if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, {
|
|
37
|
-
|
|
57
|
+
const newOptions = allOptions.map(opt => {
|
|
58
|
+
if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, {
|
|
59
|
+
id: opt.id
|
|
60
|
+
})) {
|
|
61
|
+
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
62
|
+
fixedItem: true
|
|
63
|
+
});
|
|
38
64
|
}
|
|
39
|
-
|
|
65
|
+
|
|
66
|
+
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
67
|
+
fixedItem: false
|
|
68
|
+
});
|
|
40
69
|
});
|
|
41
70
|
setAllOptions(newOptions);
|
|
42
71
|
}
|
|
@@ -47,70 +76,70 @@ function LabeledDropdownMultiPills({
|
|
|
47
76
|
setOverflowOptions(overflow);
|
|
48
77
|
}
|
|
49
78
|
}, [selectedOptions]);
|
|
50
|
-
const selectOption = useCallback(
|
|
79
|
+
const selectOption = useCallback(option => {
|
|
51
80
|
if (!option.fixedItem) {
|
|
52
81
|
if (isFunction(onChange)) {
|
|
53
|
-
const nextValue = addOrRemove(selectedOptions, option,
|
|
82
|
+
const nextValue = addOrRemove(selectedOptions, option, item => item.id);
|
|
54
83
|
setSelectedOptions(nextValue);
|
|
55
84
|
onChange(nextValue);
|
|
56
85
|
}
|
|
86
|
+
|
|
57
87
|
onSelect(option);
|
|
58
88
|
}
|
|
59
89
|
}, [selectedOptions]);
|
|
60
|
-
const removeOption = useCallback(
|
|
90
|
+
const removeOption = useCallback(option => {
|
|
61
91
|
if (!option.fixedItem || selectedOptions.length > totalDefaultOptions) {
|
|
62
92
|
if (isFunction(onChange)) {
|
|
63
|
-
const nextValue = selectedOptions.filter(
|
|
93
|
+
const nextValue = selectedOptions.filter(val => option.id !== val.id);
|
|
64
94
|
setSelectedOptions(nextValue);
|
|
65
95
|
onChange(nextValue);
|
|
66
96
|
}
|
|
97
|
+
|
|
67
98
|
onRemove(option);
|
|
68
99
|
}
|
|
69
100
|
}, [selectedOptions]);
|
|
101
|
+
|
|
70
102
|
const typeOfPill = () => {
|
|
71
103
|
if (selectedOptions.length > totalDefaultOptions) {
|
|
72
104
|
return RemovablePill;
|
|
73
105
|
}
|
|
106
|
+
|
|
74
107
|
return Pill;
|
|
75
108
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
id: "multi-selection-views",
|
|
109
|
+
|
|
110
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
111
|
+
children: [/*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
|
|
112
|
+
focusOnOpen: false,
|
|
113
|
+
label: label,
|
|
114
|
+
maxWidth: maxWidth,
|
|
115
|
+
minWidth: minWidth,
|
|
116
|
+
onSelectMenuItem: selectOption,
|
|
117
|
+
options: [_objectSpread(_objectSpread({}, menuProps), {}, {
|
|
118
|
+
type: 'SelectionGroup',
|
|
119
|
+
id: 'multi-selection-views',
|
|
88
120
|
multi: true,
|
|
89
121
|
items: allOptions
|
|
122
|
+
})],
|
|
123
|
+
selection: {
|
|
124
|
+
'multi-selection-views': selectedOptions ? selectedOptions.map(o => o.id) : ''
|
|
125
|
+
},
|
|
126
|
+
variant: "title"
|
|
127
|
+
})), selectedOptions && selectedOptions.map((option, index) => {
|
|
128
|
+
const TypeOfPill = typeOfPill();
|
|
129
|
+
|
|
130
|
+
if (index < overflowQuantity) {
|
|
131
|
+
return /*#__PURE__*/_jsx(TypeOfPill, {
|
|
132
|
+
label: option.label,
|
|
133
|
+
onRemove: () => removeOption(option)
|
|
134
|
+
}, option.id);
|
|
90
135
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (index < overflowQuantity) {
|
|
99
|
-
return /* @__PURE__ */ React2.createElement(TypeOfPill, {
|
|
100
|
-
key: option.id,
|
|
101
|
-
label: option.label,
|
|
102
|
-
onRemove: () => removeOption(option)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
106
|
-
}), selectedOptions && selectedOptions.length > overflowQuantity && /* @__PURE__ */ React2.createElement(OverflowPill, {
|
|
107
|
-
label: `+ ${selectedOptions.length - overflowQuantity}`,
|
|
108
|
-
options: overflowOptions
|
|
109
|
-
}));
|
|
136
|
+
|
|
137
|
+
return null;
|
|
138
|
+
}), selectedOptions && selectedOptions.length > overflowQuantity && /*#__PURE__*/_jsx(OverflowPill, {
|
|
139
|
+
label: "+ ".concat(selectedOptions.length - overflowQuantity),
|
|
140
|
+
options: overflowOptions
|
|
141
|
+
})]
|
|
142
|
+
});
|
|
110
143
|
}
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
LabeledDropdownMultiPills,
|
|
114
|
-
LabeledDropdownMultiPill_default as default
|
|
115
|
-
};
|
|
116
|
-
//# sourceMappingURL=LabeledDropdownMultiPill.js.map
|
|
144
|
+
|
|
145
|
+
export { LabeledDropdownMultiPills as default };
|
|
@@ -1,30 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
|
+
import { useState, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
13
|
+
import { usePrevious, useShouldRecalculate, isFunction, isString } from '@elliemae/ds-utilities';
|
|
14
|
+
import { DropdownPill } from '../DropdownPill.js';
|
|
15
|
+
import { InputPill } from '../InputPill.js';
|
|
16
|
+
import { Pill } from '../Pill.js';
|
|
17
|
+
import { RemovablePill } from '../RemovablePill.js';
|
|
18
|
+
import { hasOptionChanged } from './utils.js';
|
|
19
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
20
|
+
|
|
21
|
+
var _Pill;
|
|
22
|
+
|
|
23
|
+
const _excluded = ["label", "labelIsValue", "options", "value", "onSelect", "onChange", "maxWidth", "minWidth", "fixed"],
|
|
24
|
+
_excluded2 = ["input", "onChangeInput"];
|
|
25
|
+
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
+
function LabeledDropdownSinglePill(_ref) {
|
|
30
|
+
let {
|
|
31
|
+
label,
|
|
32
|
+
labelIsValue = false,
|
|
33
|
+
options,
|
|
34
|
+
value,
|
|
35
|
+
onSelect = () => null,
|
|
36
|
+
onChange,
|
|
37
|
+
maxWidth,
|
|
38
|
+
minWidth,
|
|
39
|
+
fixed = false
|
|
40
|
+
} = _ref,
|
|
41
|
+
menuProps = _objectWithoutProperties(_ref, _excluded);
|
|
42
|
+
|
|
22
43
|
const [optionValue, setOptionValue] = useState(value);
|
|
23
44
|
const prevOptions = usePrevious(options);
|
|
24
45
|
const areOptionsEqual = useShouldRecalculate(hasOptionChanged(prevOptions, options));
|
|
25
46
|
useEffect(() => setOptionValue(value), [value]);
|
|
26
47
|
useEffect(() => {
|
|
27
|
-
const selectedValue = options.find(
|
|
48
|
+
const selectedValue = options.find(option => option.selected);
|
|
49
|
+
|
|
28
50
|
if (selectedValue) {
|
|
29
51
|
setOptionValue(selectedValue);
|
|
30
52
|
} else if (!selectedValue) {
|
|
@@ -33,93 +55,100 @@ function LabeledDropdownSinglePill({
|
|
|
33
55
|
}, [areOptionsEqual]);
|
|
34
56
|
useLayoutEffect(() => {
|
|
35
57
|
if (optionValue) {
|
|
36
|
-
const selectedValue = options.find(
|
|
58
|
+
const selectedValue = options.find(option => option.id === optionValue.id);
|
|
37
59
|
setOptionValue(selectedValue);
|
|
38
60
|
}
|
|
39
61
|
}, [options]);
|
|
40
|
-
const selectOption = useCallback(
|
|
62
|
+
const selectOption = useCallback(option => {
|
|
41
63
|
if (isFunction(onChange)) {
|
|
42
64
|
onChange(option);
|
|
43
65
|
}
|
|
66
|
+
|
|
44
67
|
setOptionValue(option);
|
|
45
68
|
onSelect(option);
|
|
46
69
|
}, [onChange, onSelect]);
|
|
47
|
-
const onChangeInputValue = useCallback(
|
|
48
|
-
|
|
70
|
+
const onChangeInputValue = useCallback(_ref2 => {
|
|
71
|
+
let {
|
|
72
|
+
target: {
|
|
73
|
+
value: inputValue
|
|
74
|
+
}
|
|
75
|
+
} = _ref2;
|
|
76
|
+
const {
|
|
77
|
+
onChangeInput
|
|
78
|
+
} = optionValue;
|
|
49
79
|
onChangeInput && onChangeInput(inputValue);
|
|
50
80
|
}, [optionValue]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const {
|
|
81
|
+
|
|
82
|
+
const removeOption = removedOption => {
|
|
83
|
+
const {
|
|
84
|
+
onRemove
|
|
85
|
+
} = menuProps;
|
|
86
|
+
const {
|
|
87
|
+
onChangeInput
|
|
88
|
+
} = optionValue;
|
|
54
89
|
setOptionValue(null);
|
|
55
|
-
onChangeInput && onChangeInput(
|
|
56
|
-
|
|
90
|
+
onChangeInput && onChangeInput('');
|
|
91
|
+
|
|
92
|
+
const newOption = _objectSpread(_objectSpread({}, removedOption), {}, {
|
|
93
|
+
input: ''
|
|
94
|
+
});
|
|
95
|
+
|
|
57
96
|
onRemove && onRemove(newOption, removedOption);
|
|
58
97
|
};
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
|
|
99
|
+
const renderPill = (option, fixed) => {
|
|
100
|
+
const {
|
|
101
|
+
input,
|
|
102
|
+
onChangeInput
|
|
103
|
+
} = option,
|
|
104
|
+
otherProps = _objectWithoutProperties(option, _excluded2);
|
|
105
|
+
|
|
61
106
|
let SelectedPill;
|
|
107
|
+
|
|
62
108
|
if (isString(input)) {
|
|
63
109
|
SelectedPill = InputPill;
|
|
64
|
-
} else if (
|
|
110
|
+
} else if (fixed) {
|
|
65
111
|
SelectedPill = Pill;
|
|
66
112
|
} else {
|
|
67
113
|
SelectedPill = RemovablePill;
|
|
68
114
|
}
|
|
69
|
-
|
|
70
|
-
|
|
115
|
+
|
|
116
|
+
return /*#__PURE__*/jsx(SelectedPill, _objectSpread({
|
|
71
117
|
label: option.label,
|
|
72
118
|
onChange: onChangeInputValue,
|
|
73
|
-
onRemove:
|
|
74
|
-
value: input
|
|
75
|
-
|
|
76
|
-
});
|
|
119
|
+
onRemove: e => removeOption(option),
|
|
120
|
+
value: input
|
|
121
|
+
}, otherProps), option.id);
|
|
77
122
|
};
|
|
123
|
+
|
|
78
124
|
const renderSelection = () => {
|
|
79
125
|
if (!labelIsValue) {
|
|
80
|
-
if (optionValue)
|
|
81
|
-
|
|
82
|
-
return /* @__PURE__ */ React2.createElement(Pill, {
|
|
126
|
+
if (optionValue) return renderPill(optionValue, fixed);
|
|
127
|
+
return _Pill || (_Pill = /*#__PURE__*/_jsx(Pill, {
|
|
83
128
|
label: "-"
|
|
84
|
-
});
|
|
129
|
+
}));
|
|
85
130
|
}
|
|
86
131
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
id: "multi-selection-views",
|
|
132
|
+
|
|
133
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
134
|
+
children: [/*#__PURE__*/jsx(DropdownPill, _objectSpread(_objectSpread({}, menuProps), {}, {
|
|
135
|
+
label: !labelIsValue ? label : optionValue === null || optionValue === void 0 ? void 0 : optionValue.label,
|
|
136
|
+
maxWidth: maxWidth,
|
|
137
|
+
minWidth: minWidth,
|
|
138
|
+
onSelectMenuItem: selectOption,
|
|
139
|
+
options: [_objectSpread(_objectSpread({}, menuProps), {}, {
|
|
140
|
+
type: 'SelectionGroup',
|
|
141
|
+
id: 'multi-selection-views',
|
|
98
142
|
multi: false,
|
|
99
143
|
items: options,
|
|
100
144
|
closeOnClick: true
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})
|
|
145
|
+
})],
|
|
146
|
+
selection: {
|
|
147
|
+
'multi-selection-views': optionValue ? [optionValue === null || optionValue === void 0 ? void 0 : optionValue.id] : ''
|
|
148
|
+
},
|
|
149
|
+
variant: "title"
|
|
150
|
+
})), renderSelection()]
|
|
151
|
+
});
|
|
108
152
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
labelIsValue: PropTypes.bool,
|
|
112
|
-
options: PropTypes.array,
|
|
113
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
114
|
-
onSelect: PropTypes.func,
|
|
115
|
-
onChange: PropTypes.func,
|
|
116
|
-
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
117
|
-
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
118
|
-
fixed: PropTypes.bool
|
|
119
|
-
};
|
|
120
|
-
var LabeledDropdownSinglePill_default = LabeledDropdownSinglePill;
|
|
121
|
-
export {
|
|
122
|
-
LabeledDropdownSinglePill,
|
|
123
|
-
LabeledDropdownSinglePill_default as default
|
|
124
|
-
};
|
|
125
|
-
//# sourceMappingURL=LabeledDropdownSinglePill.js.map
|
|
153
|
+
|
|
154
|
+
export { LabeledDropdownSinglePill as default };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { isEqual } from '@elliemae/ds-utilities';
|
|
4
|
+
import { omit } from 'lodash';
|
|
5
|
+
|
|
4
6
|
const hasOptionChanged = (prevOptions, options) => {
|
|
5
7
|
if (prevOptions && options) {
|
|
6
|
-
const prevOptionsOmited = prevOptions.map(
|
|
7
|
-
const optionsOmited = options.map(
|
|
8
|
+
const prevOptionsOmited = prevOptions.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
|
|
9
|
+
const optionsOmited = options.map(option => omit(option, ['input', 'onChangeInput', 'mask']));
|
|
8
10
|
return isEqual(prevOptionsOmited, optionsOmited);
|
|
9
11
|
}
|
|
12
|
+
|
|
10
13
|
return false;
|
|
11
14
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=utils.js.map
|
|
15
|
+
|
|
16
|
+
export { hasOptionChanged };
|