@elliemae/ds-pills 2.2.0 → 2.3.0-alpha.3
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 +56 -49
- package/cjs/components/Pill.js.map +7 -0
- package/cjs/components/PillButton.js +54 -52
- package/cjs/components/PillButton.js.map +7 -0
- package/cjs/components/PillGroup.js +61 -53
- package/cjs/components/PillGroup.js.map +7 -0
- package/cjs/components/index.js +30 -17
- package/cjs/components/index.js.map +7 -0
- package/cjs/components/styled.js +228 -78
- package/cjs/components/styled.js.map +7 -0
- package/cjs/components/types/DropdownPill.js +79 -77
- package/cjs/components/types/DropdownPill.js.map +7 -0
- package/cjs/components/types/InputPill.js +58 -48
- package/cjs/components/types/InputPill.js.map +7 -0
- package/cjs/components/types/LabelPill.js +44 -38
- package/cjs/components/types/LabelPill.js.map +7 -0
- package/cjs/components/types/ReadOnlyPill.js +48 -43
- package/cjs/components/types/ReadOnlyPill.js.map +7 -0
- package/cjs/components/types/RemovablePill.js +60 -53
- package/cjs/components/types/RemovablePill.js.map +7 -0
- package/cjs/components/types/ValuePill.js +48 -43
- package/cjs/components/types/ValuePill.js.map +7 -0
- package/cjs/components/types/index.js +33 -19
- package/cjs/components/types/index.js.map +7 -0
- package/cjs/deprecated/DropdownPill.js +80 -101
- package/cjs/deprecated/DropdownPill.js.map +7 -0
- package/cjs/deprecated/InputPill.js +67 -69
- package/cjs/deprecated/InputPill.js.map +7 -0
- package/cjs/deprecated/LabeledDropdownPills.js +92 -96
- package/cjs/deprecated/LabeledDropdownPills.js.map +7 -0
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +91 -94
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +7 -0
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +106 -114
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +7 -0
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +119 -127
- package/cjs/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +7 -0
- package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js +39 -15
- package/cjs/deprecated/LabeledDropdownPillsTypes/utils.js.map +7 -0
- package/cjs/deprecated/LabeledPills.js +65 -52
- package/cjs/deprecated/LabeledPills.js.map +7 -0
- package/cjs/deprecated/OverflowPill.js +59 -53
- package/cjs/deprecated/OverflowPill.js.map +7 -0
- package/cjs/deprecated/Pill.js +67 -82
- package/cjs/deprecated/Pill.js.map +7 -0
- package/cjs/deprecated/PillGroup.js +68 -68
- package/cjs/deprecated/PillGroup.js.map +7 -0
- package/cjs/deprecated/ReadOnlyPill.js +93 -94
- package/cjs/deprecated/ReadOnlyPill.js.map +7 -0
- package/cjs/deprecated/RemovablePill.js +61 -57
- package/cjs/deprecated/RemovablePill.js.map +7 -0
- package/cjs/deprecated/index.js +43 -33
- package/cjs/deprecated/index.js.map +7 -0
- package/cjs/index.d.js +27 -2
- package/cjs/index.d.js.map +7 -0
- package/cjs/index.js +37 -43
- package/cjs/index.js.map +7 -0
- package/cjs/props.js +72 -46
- package/cjs/props.js.map +7 -0
- package/cjs/utils.js +43 -25
- package/cjs/utils.js.map +7 -0
- package/esm/components/Pill.js +18 -31
- package/esm/components/Pill.js.map +7 -0
- package/esm/components/PillButton.js +22 -39
- package/esm/components/PillButton.js.map +7 -0
- package/esm/components/PillGroup.js +28 -38
- package/esm/components/PillGroup.js.map +7 -0
- package/esm/components/index.js +5 -3
- package/esm/components/index.js.map +7 -0
- package/esm/components/styled.js +205 -66
- package/esm/components/styled.js.map +7 -0
- package/esm/components/types/DropdownPill.js +50 -67
- package/esm/components/types/DropdownPill.js.map +7 -0
- package/esm/components/types/InputPill.js +25 -35
- package/esm/components/types/InputPill.js.map +7 -0
- package/esm/components/types/LabelPill.js +15 -29
- package/esm/components/types/LabelPill.js.map +7 -0
- package/esm/components/types/ReadOnlyPill.js +19 -34
- package/esm/components/types/ReadOnlyPill.js.map +7 -0
- package/esm/components/types/RemovablePill.js +31 -44
- package/esm/components/types/RemovablePill.js.map +7 -0
- package/esm/components/types/ValuePill.js +19 -34
- package/esm/components/types/ValuePill.js.map +7 -0
- package/esm/components/types/index.js +8 -6
- package/esm/components/types/index.js.map +7 -0
- package/esm/deprecated/DropdownPill.js +49 -86
- package/esm/deprecated/DropdownPill.js.map +7 -0
- package/esm/deprecated/InputPill.js +38 -59
- package/esm/deprecated/InputPill.js.map +7 -0
- package/esm/deprecated/LabeledDropdownPills.js +59 -81
- package/esm/deprecated/LabeledDropdownPills.js.map +7 -0
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js +60 -84
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.js.map +7 -0
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js +65 -94
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.js.map +7 -0
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js +79 -108
- package/esm/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.js.map +7 -0
- package/esm/deprecated/LabeledDropdownPillsTypes/utils.js +9 -10
- package/esm/deprecated/LabeledDropdownPillsTypes/utils.js.map +7 -0
- package/esm/deprecated/LabeledPills.js +34 -41
- package/esm/deprecated/LabeledPills.js.map +7 -0
- package/esm/deprecated/OverflowPill.js +25 -37
- package/esm/deprecated/OverflowPill.js.map +7 -0
- package/esm/deprecated/Pill.js +39 -71
- package/esm/deprecated/Pill.js.map +7 -0
- package/esm/deprecated/PillGroup.js +39 -56
- package/esm/deprecated/PillGroup.js.map +7 -0
- package/esm/deprecated/ReadOnlyPill.js +60 -79
- package/esm/deprecated/ReadOnlyPill.js.map +7 -0
- package/esm/deprecated/RemovablePill.js +30 -45
- package/esm/deprecated/RemovablePill.js.map +7 -0
- package/esm/deprecated/index.js +14 -8
- package/esm/deprecated/index.js.map +7 -0
- package/esm/index.d.js +2 -1
- package/esm/index.d.js.map +7 -0
- package/esm/index.js +8 -11
- package/esm/index.js.map +7 -0
- package/esm/props.js +42 -36
- package/esm/props.js.map +7 -0
- package/esm/utils.js +16 -23
- package/esm/utils.js.map +7 -0
- package/package.json +15 -15
- package/types/deprecated/LabeledDropdownPills.d.ts +1 -1
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownCascadeMenuPill.d.ts +3 -1
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.d.ts +3 -1
- package/types/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.d.ts +1 -0
|
@@ -1,42 +1,22 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { find } from "lodash";
|
|
4
|
+
import { isFunction, addOrRemove } from "@elliemae/ds-utilities";
|
|
5
|
+
import { RemovablePill } from "../RemovablePill";
|
|
6
|
+
import { Pill } from "../Pill";
|
|
7
|
+
import { OverflowPill } from "../OverflowPill";
|
|
8
|
+
import { DropdownPill } from "../DropdownPill";
|
|
9
|
+
function LabeledDropdownMultiPills({
|
|
10
|
+
label,
|
|
11
|
+
options = [],
|
|
12
|
+
value = [],
|
|
13
|
+
onSelect = () => null,
|
|
14
|
+
onRemove = () => null,
|
|
15
|
+
onChange,
|
|
16
|
+
maxWidth,
|
|
17
|
+
minWidth,
|
|
18
|
+
...menuProps
|
|
19
|
+
}) {
|
|
40
20
|
const [totalDefaultOptions, setTotalDefaultOptions] = useState(0);
|
|
41
21
|
const [selectedOptions, setSelectedOptions] = useState(value);
|
|
42
22
|
const [allOptions, setAllOptions] = useState(options);
|
|
@@ -44,28 +24,19 @@ function LabeledDropdownMultiPills(_ref) {
|
|
|
44
24
|
const overflowQuantity = 3;
|
|
45
25
|
useEffect(() => setSelectedOptions(value), [value]);
|
|
46
26
|
useEffect(() => {
|
|
47
|
-
const newOptions = allOptions.filter(option => option.fixedItem);
|
|
48
|
-
|
|
27
|
+
const newOptions = allOptions.filter((option) => option.fixedItem);
|
|
49
28
|
if (newOptions.length > 0) {
|
|
50
29
|
setSelectedOptions(newOptions);
|
|
51
30
|
}
|
|
52
|
-
|
|
53
31
|
setTotalDefaultOptions(newOptions.length);
|
|
54
32
|
}, []);
|
|
55
33
|
useEffect(() => {
|
|
56
34
|
if (totalDefaultOptions) {
|
|
57
|
-
const newOptions = allOptions.map(opt => {
|
|
58
|
-
if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, {
|
|
59
|
-
|
|
60
|
-
})) {
|
|
61
|
-
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
62
|
-
fixedItem: true
|
|
63
|
-
});
|
|
35
|
+
const newOptions = allOptions.map((opt) => {
|
|
36
|
+
if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, { id: opt.id })) {
|
|
37
|
+
return { ...opt, fixedItem: true };
|
|
64
38
|
}
|
|
65
|
-
|
|
66
|
-
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
67
|
-
fixedItem: false
|
|
68
|
-
});
|
|
39
|
+
return { ...opt, fixedItem: false };
|
|
69
40
|
});
|
|
70
41
|
setAllOptions(newOptions);
|
|
71
42
|
}
|
|
@@ -76,70 +47,70 @@ function LabeledDropdownMultiPills(_ref) {
|
|
|
76
47
|
setOverflowOptions(overflow);
|
|
77
48
|
}
|
|
78
49
|
}, [selectedOptions]);
|
|
79
|
-
const selectOption = useCallback(option => {
|
|
50
|
+
const selectOption = useCallback((option) => {
|
|
80
51
|
if (!option.fixedItem) {
|
|
81
52
|
if (isFunction(onChange)) {
|
|
82
|
-
const nextValue = addOrRemove(selectedOptions, option, item => item.id);
|
|
53
|
+
const nextValue = addOrRemove(selectedOptions, option, (item) => item.id);
|
|
83
54
|
setSelectedOptions(nextValue);
|
|
84
55
|
onChange(nextValue);
|
|
85
56
|
}
|
|
86
|
-
|
|
87
57
|
onSelect(option);
|
|
88
58
|
}
|
|
89
59
|
}, [selectedOptions]);
|
|
90
|
-
const removeOption = useCallback(option => {
|
|
60
|
+
const removeOption = useCallback((option) => {
|
|
91
61
|
if (!option.fixedItem || selectedOptions.length > totalDefaultOptions) {
|
|
92
62
|
if (isFunction(onChange)) {
|
|
93
|
-
const nextValue = selectedOptions.filter(val => option.id !== val.id);
|
|
63
|
+
const nextValue = selectedOptions.filter((val) => option.id !== val.id);
|
|
94
64
|
setSelectedOptions(nextValue);
|
|
95
65
|
onChange(nextValue);
|
|
96
66
|
}
|
|
97
|
-
|
|
98
67
|
onRemove(option);
|
|
99
68
|
}
|
|
100
69
|
}, [selectedOptions]);
|
|
101
|
-
|
|
102
70
|
const typeOfPill = () => {
|
|
103
71
|
if (selectedOptions.length > totalDefaultOptions) {
|
|
104
72
|
return RemovablePill;
|
|
105
73
|
}
|
|
106
|
-
|
|
107
74
|
return Pill;
|
|
108
75
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
76
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DropdownPill, {
|
|
77
|
+
...menuProps,
|
|
78
|
+
focusOnOpen: false,
|
|
79
|
+
label,
|
|
80
|
+
maxWidth,
|
|
81
|
+
minWidth,
|
|
82
|
+
onSelectMenuItem: selectOption,
|
|
83
|
+
options: [
|
|
84
|
+
{
|
|
85
|
+
...menuProps,
|
|
86
|
+
type: "SelectionGroup",
|
|
87
|
+
id: "multi-selection-views",
|
|
120
88
|
multi: true,
|
|
121
89
|
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);
|
|
135
90
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
91
|
+
],
|
|
92
|
+
selection: {
|
|
93
|
+
"multi-selection-views": selectedOptions ? selectedOptions.map((o) => o.id) : ""
|
|
94
|
+
},
|
|
95
|
+
variant: "title"
|
|
96
|
+
}), selectedOptions && selectedOptions.map((option, index) => {
|
|
97
|
+
const TypeOfPill = typeOfPill();
|
|
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
|
+
}));
|
|
143
110
|
}
|
|
144
|
-
|
|
145
|
-
export {
|
|
111
|
+
var LabeledDropdownMultiPill_default = LabeledDropdownMultiPills;
|
|
112
|
+
export {
|
|
113
|
+
LabeledDropdownMultiPills,
|
|
114
|
+
LabeledDropdownMultiPill_default as default
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=LabeledDropdownMultiPill.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/deprecated/LabeledDropdownPillsTypes/LabeledDropdownMultiPill.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useCallback } from 'react';\nimport { find } from 'lodash';\nimport { isFunction, addOrRemove } from '@elliemae/ds-utilities';\nimport { RemovablePill } from '../RemovablePill';\nimport { Pill } from '../Pill';\nimport { OverflowPill } from '../OverflowPill';\nimport { DropdownPill } from '../DropdownPill';\n\nfunction LabeledDropdownMultiPills({\n label,\n options = [],\n value = [],\n onSelect = () => null,\n onRemove = () => null,\n onChange, // if this is defined, then it's calculating the next result onSelect or onRemove\n maxWidth,\n minWidth,\n ...menuProps\n}) {\n const [totalDefaultOptions, setTotalDefaultOptions] = useState(0);\n const [selectedOptions, setSelectedOptions] = useState(value);\n const [allOptions, setAllOptions] = useState(options);\n const [overflowOptions, setOverflowOptions] = useState([]);\n\n const overflowQuantity = 3;\n\n useEffect(() => setSelectedOptions(value), [value]);\n\n useEffect(() => {\n const newOptions = allOptions.filter((option) => option.fixedItem);\n if (newOptions.length > 0) {\n setSelectedOptions(newOptions);\n }\n setTotalDefaultOptions(newOptions.length);\n }, []);\n\n useEffect(() => {\n if (totalDefaultOptions) {\n const newOptions = allOptions.map((opt) => {\n if (selectedOptions.length <= totalDefaultOptions && find(selectedOptions, { id: opt.id })) {\n return { ...opt, fixedItem: true };\n }\n return { ...opt, fixedItem: false };\n });\n\n setAllOptions(newOptions);\n }\n }, [onSelect, onRemove, selectedOptions]);\n\n useEffect(() => {\n if (selectedOptions.length > overflowQuantity) {\n const overflow = selectedOptions.filter((val, index) => index >= overflowQuantity);\n setOverflowOptions(overflow);\n }\n }, [selectedOptions]);\n\n const selectOption = useCallback(\n (option) => {\n if (!option.fixedItem) {\n if (isFunction(onChange)) {\n const nextValue = addOrRemove(selectedOptions, option, (item) => item.id);\n setSelectedOptions(nextValue);\n onChange(nextValue);\n }\n onSelect(option);\n }\n },\n [selectedOptions],\n );\n\n const removeOption = useCallback(\n (option) => {\n if (!option.fixedItem || selectedOptions.length > totalDefaultOptions) {\n if (isFunction(onChange)) {\n const nextValue = selectedOptions.filter((val) => option.id !== val.id);\n setSelectedOptions(nextValue);\n onChange(nextValue);\n }\n onRemove(option);\n }\n },\n [selectedOptions],\n );\n\n const typeOfPill = () => {\n if (selectedOptions.length > totalDefaultOptions) {\n return RemovablePill;\n }\n\n return Pill;\n };\n\n return (\n <>\n <DropdownPill\n {...menuProps}\n focusOnOpen={false}\n label={label}\n maxWidth={maxWidth}\n minWidth={minWidth}\n onSelectMenuItem={selectOption}\n options={[\n {\n ...menuProps,\n type: 'SelectionGroup',\n id: 'multi-selection-views',\n multi: true,\n items: allOptions,\n },\n ]}\n selection={{\n 'multi-selection-views': selectedOptions ? selectedOptions.map((o) => o.id) : '',\n }}\n variant=\"title\"\n />\n {selectedOptions &&\n selectedOptions.map((option, index) => {\n const TypeOfPill = typeOfPill();\n if (index < overflowQuantity) {\n return <TypeOfPill key={option.id} label={option.label} onRemove={() => removeOption(option)} />;\n }\n return null;\n })}\n {selectedOptions && selectedOptions.length > overflowQuantity && (\n <OverflowPill label={`+ ${selectedOptions.length - overflowQuantity}`} options={overflowOptions} />\n )}\n </>\n );\n}\n\nexport { LabeledDropdownMultiPills };\nexport default LabeledDropdownMultiPills;"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,mCAAmC;AAAA,EACjC;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EACjB,WAAW,MAAM;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,KACG;AAAA,GACF;AACD,QAAM,CAAC,qBAAqB,0BAA0B,SAAS;AAC/D,QAAM,CAAC,iBAAiB,sBAAsB,SAAS;AACvD,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAC7C,QAAM,CAAC,iBAAiB,sBAAsB,SAAS;AAEvD,QAAM,mBAAmB;AAEzB,YAAU,MAAM,mBAAmB,QAAQ,CAAC;AAE5C,YAAU,MAAM;AACd,UAAM,aAAa,WAAW,OAAO,CAAC,WAAW,OAAO;AACxD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;AAAA,QACN,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,OAAO;AAAA;AAAA;AAAA,IAGX,WAAW;AAAA,MACT,yBAAyB,kBAAkB,gBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM;AAAA;AAAA,IAEhF,SAAQ;AAAA,MAET,mBACC,gBAAgB,IAAI,CAAC,QAAQ,UAAU;AACrC,UAAM,aAAa;AACnB,QAAI,QAAQ,kBAAkB;AAC5B,aAAO,qCAAC,YAAD;AAAA,QAAY,KAAK,OAAO;AAAA,QAAI,OAAO,OAAO;AAAA,QAAO,UAAU,MAAM,aAAa;AAAA;AAAA;AAEvF,WAAO;AAAA,MAEV,mBAAmB,gBAAgB,SAAS,oBAC3C,qCAAC,cAAD;AAAA,IAAc,OAAO,KAAK,gBAAgB,SAAS;AAAA,IAAoB,SAAS;AAAA;AAAA;AAOxF,IAAO,mCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,52 +1,30 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useCallback, useState, useEffect, useLayoutEffect } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { isFunction, isString, useShouldRecalculate, usePrevious } from "@elliemae/ds-utilities";
|
|
5
|
+
import { DropdownPill } from "../DropdownPill";
|
|
6
|
+
import { InputPill } from "../InputPill";
|
|
7
|
+
import { Pill } from "../Pill";
|
|
8
|
+
import { RemovablePill } from "../RemovablePill";
|
|
9
|
+
import { hasOptionChanged } from "./utils";
|
|
10
|
+
function LabeledDropdownSinglePill({
|
|
11
|
+
label,
|
|
12
|
+
labelIsValue = false,
|
|
13
|
+
options,
|
|
14
|
+
value,
|
|
15
|
+
onSelect = () => null,
|
|
16
|
+
onChange,
|
|
17
|
+
maxWidth,
|
|
18
|
+
minWidth,
|
|
19
|
+
fixed = false,
|
|
20
|
+
...menuProps
|
|
21
|
+
}) {
|
|
43
22
|
const [optionValue, setOptionValue] = useState(value);
|
|
44
23
|
const prevOptions = usePrevious(options);
|
|
45
24
|
const areOptionsEqual = useShouldRecalculate(hasOptionChanged(prevOptions, options));
|
|
46
25
|
useEffect(() => setOptionValue(value), [value]);
|
|
47
26
|
useEffect(() => {
|
|
48
|
-
const selectedValue = options.find(option => option.selected);
|
|
49
|
-
|
|
27
|
+
const selectedValue = options.find((option) => option.selected);
|
|
50
28
|
if (selectedValue) {
|
|
51
29
|
setOptionValue(selectedValue);
|
|
52
30
|
} else if (!selectedValue) {
|
|
@@ -55,100 +33,93 @@ function LabeledDropdownSinglePill(_ref) {
|
|
|
55
33
|
}, [areOptionsEqual]);
|
|
56
34
|
useLayoutEffect(() => {
|
|
57
35
|
if (optionValue) {
|
|
58
|
-
const selectedValue = options.find(option => option.id === optionValue.id);
|
|
36
|
+
const selectedValue = options.find((option) => option.id === optionValue.id);
|
|
59
37
|
setOptionValue(selectedValue);
|
|
60
38
|
}
|
|
61
39
|
}, [options]);
|
|
62
|
-
const selectOption = useCallback(option => {
|
|
40
|
+
const selectOption = useCallback((option) => {
|
|
63
41
|
if (isFunction(onChange)) {
|
|
64
42
|
onChange(option);
|
|
65
43
|
}
|
|
66
|
-
|
|
67
44
|
setOptionValue(option);
|
|
68
45
|
onSelect(option);
|
|
69
46
|
}, [onChange, onSelect]);
|
|
70
|
-
const onChangeInputValue = useCallback(
|
|
71
|
-
|
|
72
|
-
target: {
|
|
73
|
-
value: inputValue
|
|
74
|
-
}
|
|
75
|
-
} = _ref2;
|
|
76
|
-
const {
|
|
77
|
-
onChangeInput
|
|
78
|
-
} = optionValue;
|
|
47
|
+
const onChangeInputValue = useCallback(({ target: { value: inputValue } }) => {
|
|
48
|
+
const { onChangeInput } = optionValue;
|
|
79
49
|
onChangeInput && onChangeInput(inputValue);
|
|
80
50
|
}, [optionValue]);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
onRemove
|
|
85
|
-
} = menuProps;
|
|
86
|
-
const {
|
|
87
|
-
onChangeInput
|
|
88
|
-
} = optionValue;
|
|
51
|
+
const removeOption = (removedOption) => {
|
|
52
|
+
const { onRemove } = menuProps;
|
|
53
|
+
const { onChangeInput } = optionValue;
|
|
89
54
|
setOptionValue(null);
|
|
90
|
-
onChangeInput && onChangeInput(
|
|
91
|
-
|
|
92
|
-
const newOption = _objectSpread(_objectSpread({}, removedOption), {}, {
|
|
93
|
-
input: ''
|
|
94
|
-
});
|
|
95
|
-
|
|
55
|
+
onChangeInput && onChangeInput("");
|
|
56
|
+
const newOption = { ...removedOption, input: "" };
|
|
96
57
|
onRemove && onRemove(newOption, removedOption);
|
|
97
58
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const {
|
|
101
|
-
input,
|
|
102
|
-
onChangeInput
|
|
103
|
-
} = option,
|
|
104
|
-
otherProps = _objectWithoutProperties(option, _excluded2);
|
|
105
|
-
|
|
59
|
+
const renderPill = (option, fixed2) => {
|
|
60
|
+
const { input, onChangeInput, ...otherProps } = option;
|
|
106
61
|
let SelectedPill;
|
|
107
|
-
|
|
108
62
|
if (isString(input)) {
|
|
109
63
|
SelectedPill = InputPill;
|
|
110
|
-
} else if (
|
|
64
|
+
} else if (fixed2) {
|
|
111
65
|
SelectedPill = Pill;
|
|
112
66
|
} else {
|
|
113
67
|
SelectedPill = RemovablePill;
|
|
114
68
|
}
|
|
115
|
-
|
|
116
|
-
|
|
69
|
+
return /* @__PURE__ */ React2.createElement(SelectedPill, {
|
|
70
|
+
key: option.id,
|
|
117
71
|
label: option.label,
|
|
118
72
|
onChange: onChangeInputValue,
|
|
119
|
-
onRemove: e => removeOption(option),
|
|
120
|
-
value: input
|
|
121
|
-
|
|
73
|
+
onRemove: (e) => removeOption(option, e),
|
|
74
|
+
value: input,
|
|
75
|
+
...otherProps
|
|
76
|
+
});
|
|
122
77
|
};
|
|
123
|
-
|
|
124
78
|
const renderSelection = () => {
|
|
125
79
|
if (!labelIsValue) {
|
|
126
|
-
if (optionValue)
|
|
127
|
-
|
|
80
|
+
if (optionValue)
|
|
81
|
+
return renderPill(optionValue, fixed);
|
|
82
|
+
return /* @__PURE__ */ React2.createElement(Pill, {
|
|
128
83
|
label: "-"
|
|
129
|
-
})
|
|
84
|
+
});
|
|
130
85
|
}
|
|
131
86
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
87
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(DropdownPill, {
|
|
88
|
+
...menuProps,
|
|
89
|
+
label: !labelIsValue ? label : optionValue?.label,
|
|
90
|
+
maxWidth,
|
|
91
|
+
minWidth,
|
|
92
|
+
onSelectMenuItem: selectOption,
|
|
93
|
+
options: [
|
|
94
|
+
{
|
|
95
|
+
...menuProps,
|
|
96
|
+
type: "SelectionGroup",
|
|
97
|
+
id: "multi-selection-views",
|
|
142
98
|
multi: false,
|
|
143
99
|
items: options,
|
|
144
100
|
closeOnClick: true
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
selection: {
|
|
104
|
+
"multi-selection-views": optionValue ? [optionValue?.id] : ""
|
|
105
|
+
},
|
|
106
|
+
variant: "title"
|
|
107
|
+
}), renderSelection());
|
|
152
108
|
}
|
|
153
|
-
|
|
154
|
-
|
|
109
|
+
LabeledDropdownSinglePill.propTypes = {
|
|
110
|
+
label: PropTypes.string,
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/deprecated/LabeledDropdownPillsTypes/LabeledDropdownSinglePill.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable mdx/no-unused-expressions */\n/* eslint-disable no-shadow */\n/* eslint-disable no-unused-expressions */\n/* eslint-disable max-lines */\nimport React, { useCallback, useState, useEffect, useLayoutEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { isFunction, isString, useShouldRecalculate, usePrevious } from '@elliemae/ds-utilities';\nimport { DropdownPill } from '../DropdownPill';\nimport { InputPill } from '../InputPill';\nimport { Pill } from '../Pill';\nimport { RemovablePill } from '../RemovablePill';\nimport { hasOptionChanged } from './utils';\n\nfunction LabeledDropdownSinglePill({\n label,\n labelIsValue = false,\n options,\n value,\n onSelect = () => null,\n onChange,\n maxWidth,\n minWidth,\n fixed = false,\n ...menuProps\n}) {\n const [optionValue, setOptionValue] = useState(value);\n const prevOptions = usePrevious(options);\n const areOptionsEqual = useShouldRecalculate(hasOptionChanged(prevOptions, options));\n\n useEffect(() => setOptionValue(value), [value]);\n\n useEffect(() => {\n const selectedValue = options.find((option) => option.selected);\n\n if (selectedValue) {\n setOptionValue(selectedValue);\n } else if (!selectedValue) {\n setOptionValue(options[0]);\n }\n }, [areOptionsEqual]);\n\n useLayoutEffect(() => {\n if (optionValue) {\n const selectedValue = options.find((option) => option.id === optionValue.id);\n setOptionValue(selectedValue);\n }\n }, [options]);\n\n const selectOption = useCallback(\n (option) => {\n if (isFunction(onChange)) {\n onChange(option);\n }\n setOptionValue(option);\n onSelect(option);\n },\n [onChange, onSelect],\n );\n\n const onChangeInputValue = useCallback(\n ({ target: { value: inputValue } }) => {\n const { onChangeInput } = optionValue;\n\n onChangeInput && onChangeInput(inputValue);\n },\n [optionValue],\n );\n\n const removeOption = (removedOption) => {\n const { onRemove } = menuProps;\n const { onChangeInput } = optionValue;\n setOptionValue(null);\n onChangeInput && onChangeInput('');\n const newOption = { ...removedOption, input: '' };\n onRemove && onRemove(newOption, removedOption);\n };\n\n const renderPill = (option, fixed) => {\n const { input, onChangeInput, ...otherProps } = option;\n let SelectedPill;\n if (isString(input)) {\n SelectedPill = InputPill;\n } else if (fixed) {\n SelectedPill = Pill;\n } else {\n SelectedPill = RemovablePill;\n }\n\n return (\n <SelectedPill\n key={option.id}\n label={option.label}\n onChange={onChangeInputValue}\n onRemove={(e) => removeOption(option, e)}\n value={input}\n {...otherProps}\n />\n );\n };\n\n const renderSelection = () => {\n if (!labelIsValue) {\n if (optionValue) return renderPill(optionValue, fixed);\n return <Pill label=\"-\" />;\n }\n };\n\n return (\n <>\n <DropdownPill\n {...menuProps}\n label={!labelIsValue ? label : optionValue?.label}\n maxWidth={maxWidth}\n minWidth={minWidth}\n onSelectMenuItem={selectOption}\n options={[\n {\n ...menuProps,\n type: 'SelectionGroup',\n id: 'multi-selection-views',\n multi: false,\n items: options,\n closeOnClick: true,\n },\n ]}\n selection={{\n 'multi-selection-views': optionValue ? [optionValue?.id] : '',\n }}\n variant=\"title\"\n />\n {renderSelection()}\n </>\n );\n}\n\nLabeledDropdownSinglePill.propTypes = {\n label: PropTypes.string,\n labelIsValue: PropTypes.bool,\n options: PropTypes.array,\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n onSelect: PropTypes.func,\n onChange: PropTypes.func,\n maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n f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
+
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { omit } from 'lodash';
|
|
5
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { isEqual } from "@elliemae/ds-utilities";
|
|
3
|
+
import { omit } from "lodash";
|
|
6
4
|
const hasOptionChanged = (prevOptions, options) => {
|
|
7
5
|
if (prevOptions && options) {
|
|
8
|
-
const prevOptionsOmited = prevOptions.map(option => omit(option, [
|
|
9
|
-
const optionsOmited = options.map(option => omit(option, [
|
|
6
|
+
const prevOptionsOmited = prevOptions.map((option) => omit(option, ["input", "onChangeInput", "mask"]));
|
|
7
|
+
const optionsOmited = options.map((option) => omit(option, ["input", "onChangeInput", "mask"]));
|
|
10
8
|
return isEqual(prevOptionsOmited, optionsOmited);
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
return false;
|
|
14
11
|
};
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export {
|
|
13
|
+
hasOptionChanged
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/deprecated/LabeledDropdownPillsTypes/utils.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isEqual } from '@elliemae/ds-utilities';\nimport { omit } from 'lodash';\n\nexport const hasOptionChanged = (prevOptions, options) => {\n if (prevOptions && options) {\n const prevOptionsOmited = prevOptions.map((option) => omit(option, ['input', 'onChangeInput', 'mask']));\n const optionsOmited = options.map((option) => omit(option, ['input', 'onChangeInput', 'mask']));\n\n return isEqual(prevOptionsOmited, optionsOmited);\n }\n\n return false;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEO,MAAM,mBAAmB,CAAC,aAAa,YAAY;AACxD,MAAI,eAAe,SAAS;AAC1B,UAAM,oBAAoB,YAAY,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,SAAS,iBAAiB;AAC9F,UAAM,gBAAgB,QAAQ,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,SAAS,iBAAiB;AAEtF,WAAO,QAAQ,mBAAmB;AAAA;AAGpC,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,53 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { PropTypes, describe } from
|
|
4
|
-
import { PillGroup } from
|
|
5
|
-
import { RemovablePill } from
|
|
6
|
-
import { Pill } from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { PropTypes, describe } from "react-desc";
|
|
4
|
+
import { PillGroup } from "./PillGroup";
|
|
5
|
+
import { RemovablePill } from "./RemovablePill";
|
|
6
|
+
import { Pill } from "./Pill";
|
|
7
|
+
function LabeledPills({
|
|
8
|
+
children,
|
|
9
|
+
label = "",
|
|
10
|
+
leftAddon,
|
|
11
|
+
onFocusGroupSet,
|
|
12
|
+
onFocusNextGroup,
|
|
13
|
+
onFocusPreviousGroup
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ React2.createElement(PillGroup, {
|
|
13
16
|
onFocusGroupSet,
|
|
14
17
|
onFocusNextGroup,
|
|
15
18
|
onFocusPreviousGroup
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
onFocusNextGroup: onFocusNextGroup,
|
|
20
|
-
onFocusPreviousGroup: onFocusPreviousGroup
|
|
21
|
-
}, void 0, /*#__PURE__*/_jsx(Pill, {
|
|
22
|
-
label: label,
|
|
23
|
-
leftAddon: leftAddon,
|
|
19
|
+
}, /* @__PURE__ */ React2.createElement(Pill, {
|
|
20
|
+
label,
|
|
21
|
+
leftAddon,
|
|
24
22
|
variant: "title",
|
|
25
23
|
"data-testid": "pill-title"
|
|
26
24
|
}), children);
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
const props = {
|
|
30
|
-
|
|
31
|
-
label: PropTypes.string.isRequired.description('pill text label'),
|
|
32
|
-
|
|
33
|
-
/** pill to add the label to */
|
|
27
|
+
label: PropTypes.string.isRequired.description("pill text label"),
|
|
34
28
|
children: PropTypes.arrayOf(PropTypes.shape({
|
|
35
|
-
type: PropTypes.oneOf([
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/** focus prev group callback */
|
|
45
|
-
onFocusPreviousGroup: PropTypes.func.description('focus prev group callback'),
|
|
46
|
-
|
|
47
|
-
/** focus group set callback */
|
|
48
|
-
onFocusGroupSet: PropTypes.func.description('focus group set callback')
|
|
29
|
+
type: PropTypes.oneOf([
|
|
30
|
+
PropTypes.instanceOf(Pill),
|
|
31
|
+
PropTypes.instanceOf(RemovablePill)
|
|
32
|
+
])
|
|
33
|
+
})).isRequired.description("pill to add the label to"),
|
|
34
|
+
leftAddon: PropTypes.node.description("addon component to left"),
|
|
35
|
+
onFocusNextGroup: PropTypes.func.description("focus next group callback"),
|
|
36
|
+
onFocusPreviousGroup: PropTypes.func.description("focus prev group callback"),
|
|
37
|
+
onFocusGroupSet: PropTypes.func.description("focus group set callback")
|
|
49
38
|
};
|
|
39
|
+
LabeledPills.propTypes = props;
|
|
50
40
|
const DSLabeledPillsWithSchema = describe(LabeledPills);
|
|
51
41
|
DSLabeledPillsWithSchema.propTypes = props;
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
export {
|
|
43
|
+
DSLabeledPillsWithSchema,
|
|
44
|
+
LabeledPills
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=LabeledPills.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/LabeledPills.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { PillGroup } from './PillGroup';\nimport { RemovablePill } from './RemovablePill';\nimport { Pill } from './Pill';\n\nfunction LabeledPills({\n children,\n label = '',\n leftAddon,\n onFocusGroupSet,\n onFocusNextGroup,\n onFocusPreviousGroup,\n}) {\n return (\n <PillGroup\n onFocusGroupSet={onFocusGroupSet}\n onFocusNextGroup={onFocusNextGroup}\n onFocusPreviousGroup={onFocusPreviousGroup}\n >\n <Pill\n label={label}\n leftAddon={leftAddon}\n variant=\"title\"\n data-testid=\"pill-title\"\n />\n {children}\n </PillGroup>\n );\n}\n\nconst props = {\n /** labeled pill text label */\n label: PropTypes.string.isRequired.description('pill text label'),\n /** pill to add the label to */\n children: PropTypes.arrayOf(\n PropTypes.shape({\n type: PropTypes.oneOf([\n PropTypes.instanceOf(Pill),\n PropTypes.instanceOf(RemovablePill),\n ]),\n }),\n ).isRequired.description('pill to add the label to'),\n /** addon component to left */\n leftAddon: PropTypes.node.description('addon component to left'),\n /** focus next group callback */\n onFocusNextGroup: PropTypes.func.description('focus next group callback'),\n /** focus prev group callback */\n onFocusPreviousGroup: PropTypes.func.description('focus prev group callback'),\n /** focus group set callback */\n onFocusGroupSet: PropTypes.func.description('focus group set callback'),\n};\n\nLabeledPills.propTypes = props;\n\nconst DSLabeledPillsWithSchema = describe(LabeledPills);\nDSLabeledPillsWithSchema.propTypes = props;\n\nexport { LabeledPills, DSLabeledPillsWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAEA,sBAAsB;AAAA,EACpB;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACC;AACD,SACE,qCAAC,WAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,KAEA,qCAAC,MAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA,SAAQ;AAAA,IACR,eAAY;AAAA,MAEb;AAAA;AAKP,MAAM,QAAQ;AAAA,EAEZ,OAAO,UAAU,OAAO,WAAW,YAAY;AAAA,EAE/C,UAAU,UAAU,QAClB,UAAU,MAAM;AAAA,IACd,MAAM,UAAU,MAAM;AAAA,MACpB,UAAU,WAAW;AAAA,MACrB,UAAU,WAAW;AAAA;AAAA,MAGzB,WAAW,YAAY;AAAA,EAEzB,WAAW,UAAU,KAAK,YAAY;AAAA,EAEtC,kBAAkB,UAAU,KAAK,YAAY;AAAA,EAE7C,sBAAsB,UAAU,KAAK,YAAY;AAAA,EAEjD,iBAAiB,UAAU,KAAK,YAAY;AAAA;AAG9C,aAAa,YAAY;AAEzB,MAAM,2BAA2B,SAAS;AAC1C,yBAAyB,YAAY;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|