kiban-design-system 1.1.5-hotfix.0 → 1.1.6-hotfix.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -2247,11 +2247,53 @@ const useTheme = () => {
|
|
|
2247
2247
|
* @param {string} InputTextProps.ariaLabel - Label to use in automatic tests
|
|
2248
2248
|
* @returns {symbol} - Element Select
|
|
2249
2249
|
*/
|
|
2250
|
-
const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, selected, onChange, searchPlaceholder, searchLabel, helperText, isHelperMode, isDisabled = false,
|
|
2250
|
+
const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, selected, onChange, searchPlaceholder, searchLabel, helperText, isHelperMode, isDisabled = false, tooltip, isDanger, isReadOnly = false, id, emptyState, onBlur, isRequired, tooltipLabel, action, showSearch = true, }) => {
|
|
2251
2251
|
const [isActivePopover, setIsActive] = useState(false);
|
|
2252
2252
|
const selectActivatorRef = useRef(null);
|
|
2253
2253
|
const [parentCoord, setParentCoords] = useState();
|
|
2254
|
+
const [search, setSearch] = useState('');
|
|
2255
|
+
const [sectionsFiltered, setSectionsFiltered] = useState(sections);
|
|
2256
|
+
const [itemsFiltered, setItemsFiltered] = useState(items);
|
|
2254
2257
|
const { theme } = useTheme();
|
|
2258
|
+
const handleOnSearch = (value) => {
|
|
2259
|
+
setSearch(value || '');
|
|
2260
|
+
if (value) {
|
|
2261
|
+
if (sections) {
|
|
2262
|
+
const newSections = [];
|
|
2263
|
+
sections.forEach((section) => {
|
|
2264
|
+
const { items: itemsSection } = section;
|
|
2265
|
+
if (!itemsSection)
|
|
2266
|
+
newSections.push(section);
|
|
2267
|
+
else {
|
|
2268
|
+
const newItems = itemsSection.filter((item) => item.label
|
|
2269
|
+
.toLocaleLowerCase()
|
|
2270
|
+
.includes(search.toLocaleLowerCase()));
|
|
2271
|
+
newSections.push(Object.assign(Object.assign({}, section), { items: newItems }));
|
|
2272
|
+
}
|
|
2273
|
+
});
|
|
2274
|
+
setSectionsFiltered(newSections);
|
|
2275
|
+
}
|
|
2276
|
+
if (items) {
|
|
2277
|
+
const newItems = items.filter((item) => item.label
|
|
2278
|
+
.toLocaleLowerCase()
|
|
2279
|
+
.includes(search.toLocaleLowerCase()));
|
|
2280
|
+
setItemsFiltered(newItems);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
else {
|
|
2284
|
+
setSectionsFiltered(sections);
|
|
2285
|
+
setItemsFiltered(items);
|
|
2286
|
+
}
|
|
2287
|
+
};
|
|
2288
|
+
let totalItems = 0;
|
|
2289
|
+
if (sections) {
|
|
2290
|
+
sections.forEach((section) => {
|
|
2291
|
+
if (section.items)
|
|
2292
|
+
totalItems += section.items.length;
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
if (items)
|
|
2296
|
+
totalItems = items.length;
|
|
2255
2297
|
const handleClickSelectReadOnlyOutside = (event) => {
|
|
2256
2298
|
if (selectActivatorRef.current &&
|
|
2257
2299
|
!selectActivatorRef.current.contains(event.target)) {
|
|
@@ -2266,6 +2308,12 @@ const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, se
|
|
|
2266
2308
|
};
|
|
2267
2309
|
}
|
|
2268
2310
|
}, [isActivePopover]);
|
|
2311
|
+
useEffect(() => {
|
|
2312
|
+
setSectionsFiltered(sections);
|
|
2313
|
+
}, [sections]);
|
|
2314
|
+
useEffect(() => {
|
|
2315
|
+
setItemsFiltered(items);
|
|
2316
|
+
}, [items]);
|
|
2269
2317
|
const handleOpenPopover = () => setIsActive(!isActivePopover);
|
|
2270
2318
|
const removeTag = (event, value) => {
|
|
2271
2319
|
event.stopPropagation();
|
|
@@ -2357,9 +2405,10 @@ const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, se
|
|
|
2357
2405
|
}, [action]);
|
|
2358
2406
|
const actionIconProp = action && action.icon ? { icon: action.icon, outlined: true } : undefined;
|
|
2359
2407
|
const actionMarkup = action ? (jsxs(Fragment, { children: [(items === null || items === void 0 ? void 0 : items.length) ? jsx(Divider, {}, void 0) : null, jsx(AlphaButton, Object.assign({ isLink: true, isTertiary: true, onClick: handleActionClick, icon: actionIconProp, iconPosition: action.iconPosition, theme: (theme === null || theme === void 0 ? void 0 : theme.toLowerCase()) || undefined }, { children: action.content }), void 0)] }, void 0)) : null;
|
|
2408
|
+
const searchMarkup = totalItems > 10 && showSearch ? (jsx("div", Object.assign({ className: 'Select__search' }, { children: jsx(InputText, { placeholder: searchPlaceholder, icon: 'Search', value: search, label: searchLabel, onChange: handleOnSearch }, void 0) }), void 0)) : null;
|
|
2360
2409
|
const renderInput = () => (jsx("div", Object.assign({ id: id }, { children: jsxs(Popover$1, Object.assign({ isActive: isReadOnly ? false : isActivePopover, activator: jsxs("div", Object.assign({ "aria-label": ariaLabel, tabIndex: 0, className: clasessSelect, id: `select-${id}`, onKeyDown: onKeyDown, onClick: handleClickSelect, onBlur: onBlur }, { children: [selected && selected.length > 0 && (jsx("div", Object.assign({ className: 'Select__selected' }, { children: isMultiple
|
|
2361
2410
|
? selected === null || selected === void 0 ? void 0 : selected.map((option, index) => (jsx("div", Object.assign({ className: 'Select__tag-container' }, { children: jsx(Tag, Object.assign({ onRemove: (evt) => removeTag(evt, option), isDisabled: isDisabled, isDanger: isDanger }, { children: getLabelOption(option) }), void 0) }), `Select-tag--${index}`)))
|
|
2362
|
-
: selected === null || selected === void 0 ? void 0 : selected.map((option, index) => (jsx("span", { children: getLabelOption(option) }, `option-${index}`))) }), void 0)), (!selected || selected.length <= 0) && placeholder && (jsx("div", Object.assign({ className: 'Select__placeholder' }, { children: placeholder }), void 0)), jsx("div", Object.assign({ className: 'Select__icon', onClick: handleOnClickIcon }, { children: jsx(Icon, { name: isActivePopover && !isReadOnly ? 'ChevronUp' : 'ChevronDown' }, void 0) }), void 0)] }), void 0), isFullWidth: true, onClose: () => setIsActive(false) }, { children: [
|
|
2411
|
+
: selected === null || selected === void 0 ? void 0 : selected.map((option, index) => (jsx("span", { children: getLabelOption(option) }, `option-${index}`))) }), void 0)), (!selected || selected.length <= 0) && placeholder && (jsx("div", Object.assign({ className: 'Select__placeholder' }, { children: placeholder }), void 0)), jsx("div", Object.assign({ className: 'Select__icon', onClick: handleOnClickIcon }, { children: jsx(Icon, { name: isActivePopover && !isReadOnly ? 'ChevronUp' : 'ChevronDown' }, void 0) }), void 0)] }), void 0), isFullWidth: true, onClose: () => setIsActive(false) }, { children: [searchMarkup, emptyState && (jsx(Popover$1.Pane, { children: jsx("div", Object.assign({ className: 'emptyState__container' }, { children: emptyState }), void 0) }, void 0)), !emptyState && (jsxs(Popover$1.Pane, { children: [jsx(OptionList, { sections: sectionsFiltered, items: itemsFiltered, isMultiple: isMultiple, onChange: (value) => {
|
|
2363
2412
|
if (!isMultiple) {
|
|
2364
2413
|
handleOpenPopover();
|
|
2365
2414
|
}
|
|
@@ -28683,6 +28732,13 @@ const Content = ({ children, hasPane = false, height }) => (jsx("div", Object.as
|
|
|
28683
28732
|
* @param {boolean} ModalProps.hasPane - Validate if it has Pane
|
|
28684
28733
|
*/
|
|
28685
28734
|
const Modal = ({ ariaLabel, children, isOpen, media, onClose, position, primaryAction, secondaryActions, extraAction, hideFooter = false, hideHeader = false, size = 'medium', title, hasPane = false, id, mediaTheme, height, }) => {
|
|
28735
|
+
const handleOnKeyUp = (event) => {
|
|
28736
|
+
if (isOpen && event.key == 'Escape' && onClose)
|
|
28737
|
+
onClose();
|
|
28738
|
+
};
|
|
28739
|
+
useEffect(() => {
|
|
28740
|
+
document.addEventListener('keyup', handleOnKeyUp);
|
|
28741
|
+
});
|
|
28686
28742
|
useEffect(() => {
|
|
28687
28743
|
if (isOpen)
|
|
28688
28744
|
document.body.style.overflow = 'hidden';
|
|
@@ -28890,13 +28946,15 @@ const PanelHeader = ({ alt = '', icon, image, title, onClose, headerExtraActions
|
|
|
28890
28946
|
|
|
28891
28947
|
const MAIN_CLASS$4 = 'Panel';
|
|
28892
28948
|
const Panel = ({ children, position, height, isOpen, id, alt = '', icon, image, title, onClose, headerExtraActions, theme = 'CLOUD', positionButtons = 'flex-end', primaryAction, secondaryActions, extraAction, }) => {
|
|
28893
|
-
const className =
|
|
28894
|
-
`${MAIN_CLASS$4}__container`,
|
|
28895
|
-
position && `${MAIN_CLASS$4}__container--is-${position}`,
|
|
28896
|
-
]
|
|
28897
|
-
.filter(Boolean)
|
|
28898
|
-
.join(' ');
|
|
28949
|
+
const className = cssClassName(`${MAIN_CLASS$4}__container`, position && `is-${position}`);
|
|
28899
28950
|
const maxHeightStyle = { height: height };
|
|
28951
|
+
const handleOnKeyUp = (event) => {
|
|
28952
|
+
if (isOpen && event.key == 'Escape' && onClose)
|
|
28953
|
+
onClose();
|
|
28954
|
+
};
|
|
28955
|
+
useEffect(() => {
|
|
28956
|
+
document.addEventListener('keyup', handleOnKeyUp);
|
|
28957
|
+
});
|
|
28900
28958
|
return (jsx(Fragment, { children: isOpen &&
|
|
28901
28959
|
createPortal(jsxs("div", Object.assign({ id: id, className: className, style: maxHeightStyle }, { children: [jsx(PanelHeader, { alt: alt, icon: icon, image: image, title: title, onClose: onClose, theme: theme, headerExtraActions: headerExtraActions }, void 0), jsx("div", Object.assign({ className: `${MAIN_CLASS$4}__body` }, { children: children }), void 0), jsx(PanelFooter, { positionButtons: positionButtons, primaryAction: primaryAction, secondaryActions: secondaryActions, extraAction: extraAction }, void 0)] }), void 0), document.querySelector('body')) }, void 0));
|
|
28902
28960
|
};
|