kiban-design-system 1.0.239-alpha.0 → 1.0.241-alpha.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/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.props.d.ts +6 -8
- package/dist/index.css.map +1 -1
- package/dist/index.js +55 -6
- package/dist/index.js.map +1 -1
- package/dist/utils/formatFileSize.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1032,6 +1032,17 @@ const isComponentTypeOf = (childComponent, parentComponent) => {
|
|
|
1032
1032
|
return Components.some((Component) => typeof type !== 'string' && type === Component);
|
|
1033
1033
|
};
|
|
1034
1034
|
|
|
1035
|
+
function formatFileSize(bytes) {
|
|
1036
|
+
const units = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
1037
|
+
let unitIndex = 0;
|
|
1038
|
+
let size = bytes;
|
|
1039
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
1040
|
+
size /= 1024;
|
|
1041
|
+
unitIndex += 1;
|
|
1042
|
+
}
|
|
1043
|
+
return `${size.toFixed(2)} ${units[unitIndex]}`;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1035
1046
|
const cssClassName = (mainClass, ...classes) => {
|
|
1036
1047
|
const filteredClasses = classes
|
|
1037
1048
|
.filter(Boolean)
|
|
@@ -2247,11 +2258,44 @@ const useTheme = () => {
|
|
|
2247
2258
|
* @param {string} InputTextProps.ariaLabel - Label to use in automatic tests
|
|
2248
2259
|
* @returns {symbol} - Element Select
|
|
2249
2260
|
*/
|
|
2250
|
-
const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, selected, onChange, searchPlaceholder, searchLabel, helperText, isHelperMode, isDisabled = false,
|
|
2261
|
+
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
2262
|
const [isActivePopover, setIsActive] = useState(false);
|
|
2252
2263
|
const selectActivatorRef = useRef(null);
|
|
2253
2264
|
const [parentCoord, setParentCoords] = useState();
|
|
2265
|
+
const [search, setSearch] = useState('');
|
|
2266
|
+
const [sectionsFiltered, setSectionsFiltered] = useState(sections);
|
|
2267
|
+
const [itemsFiltered, setItemsFiltered] = useState(items);
|
|
2254
2268
|
const { theme } = useTheme();
|
|
2269
|
+
const handleOnSearch = (value) => {
|
|
2270
|
+
setSearch(value || '');
|
|
2271
|
+
if (value) {
|
|
2272
|
+
if (sections) {
|
|
2273
|
+
const newSections = [];
|
|
2274
|
+
sections.forEach((section) => {
|
|
2275
|
+
const { items: itemsSection } = section;
|
|
2276
|
+
if (!itemsSection)
|
|
2277
|
+
newSections.push(section);
|
|
2278
|
+
else {
|
|
2279
|
+
const newItems = itemsSection.filter((item) => item.label
|
|
2280
|
+
.toLocaleLowerCase()
|
|
2281
|
+
.includes(search.toLocaleLowerCase()));
|
|
2282
|
+
newSections.push(Object.assign(Object.assign({}, section), { items: newItems }));
|
|
2283
|
+
}
|
|
2284
|
+
});
|
|
2285
|
+
setSectionsFiltered(newSections);
|
|
2286
|
+
}
|
|
2287
|
+
if (items) {
|
|
2288
|
+
const newItems = items.filter((item) => item.label
|
|
2289
|
+
.toLocaleLowerCase()
|
|
2290
|
+
.includes(search.toLocaleLowerCase()));
|
|
2291
|
+
setItemsFiltered(newItems);
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
else {
|
|
2295
|
+
setSectionsFiltered(sections);
|
|
2296
|
+
setItemsFiltered(items);
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2255
2299
|
let totalItems = 0;
|
|
2256
2300
|
if (sections) {
|
|
2257
2301
|
sections.forEach((section) => {
|
|
@@ -2275,6 +2319,12 @@ const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, se
|
|
|
2275
2319
|
};
|
|
2276
2320
|
}
|
|
2277
2321
|
}, [isActivePopover]);
|
|
2322
|
+
useEffect(() => {
|
|
2323
|
+
setSectionsFiltered(sections);
|
|
2324
|
+
}, [sections]);
|
|
2325
|
+
useEffect(() => {
|
|
2326
|
+
setItemsFiltered(items);
|
|
2327
|
+
}, [items]);
|
|
2278
2328
|
const handleOpenPopover = () => setIsActive(!isActivePopover);
|
|
2279
2329
|
const removeTag = (event, value) => {
|
|
2280
2330
|
event.stopPropagation();
|
|
@@ -2366,11 +2416,10 @@ const Select = ({ ariaLabel, items, sections, isMultiple, placeholder, label, se
|
|
|
2366
2416
|
}, [action]);
|
|
2367
2417
|
const actionIconProp = action && action.icon ? { icon: action.icon, outlined: true } : undefined;
|
|
2368
2418
|
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;
|
|
2369
|
-
const
|
|
2370
|
-
const searchMarkup = onSearchChange && showSearch ? (jsx("div", Object.assign({ className: 'Select__search' }, { children: jsx(InputText, { placeholder: searchPlaceholder, icon: 'Search', value: search, label: searchLabel, onChange: (value) => onSearchChange && onSearchChange(value) }, void 0) }), void 0)) : null;
|
|
2419
|
+
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;
|
|
2371
2420
|
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
|
|
2372
2421
|
? 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}`)))
|
|
2373
|
-
: 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:
|
|
2422
|
+
: 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) => {
|
|
2374
2423
|
if (!isMultiple) {
|
|
2375
2424
|
handleOpenPopover();
|
|
2376
2425
|
}
|
|
@@ -23595,7 +23644,7 @@ var pako = {
|
|
|
23595
23644
|
* @returns {symbol} - Element FileItem
|
|
23596
23645
|
* @param {string} InputTextProps.ariaLabel - Label to use in automatic tests
|
|
23597
23646
|
*/
|
|
23598
|
-
const FileItem = ({ ariaLabel, name, addon, onDelete, size = 0, }) => (jsxs("div", Object.assign({ className: 'File' }, { children: [jsxs("div", Object.assign({ className: 'File__content__left' }, { children: [jsx(Icon, { name: 'Paperclip' }, void 0), jsx("p", Object.assign({ className: ' File__content__nameFile' }, { children: name }), void 0)] }), void 0), jsxs("div", Object.assign({ className: 'File__content__right' }, { children: [jsxs("button", Object.assign({ "aria-label": `${ariaLabel}-delete`, className: 'ButtonDeleteFile', onClick: onDelete }, { children: [jsx(Fragment, { children: addon }, void 0), jsx(Icon, { name: 'Close' }, void 0)] }), void 0),
|
|
23647
|
+
const FileItem = ({ ariaLabel, name, addon, onDelete, size = 0, }) => (jsxs("div", Object.assign({ className: 'File' }, { children: [jsxs("div", Object.assign({ className: 'File__content__left' }, { children: [jsx(Icon, { name: 'Paperclip' }, void 0), jsx("p", Object.assign({ className: ' File__content__nameFile' }, { children: name }), void 0)] }), void 0), jsxs("div", Object.assign({ className: 'File__content__right' }, { children: [jsxs("button", Object.assign({ "aria-label": `${ariaLabel}-delete`, className: 'ButtonDeleteFile', onClick: onDelete }, { children: [jsx(Fragment, { children: addon }, void 0), jsx(Icon, { name: 'Close' }, void 0)] }), void 0), jsx("p", Object.assign({ className: 'File__content__fileSize' }, { children: formatFileSize(size) }), void 0)] }), void 0)] }), void 0));
|
|
23599
23648
|
|
|
23600
23649
|
/**
|
|
23601
23650
|
* FileDrop is a component to upload files in any project
|
|
@@ -30529,5 +30578,5 @@ const AlphaSegmentedControl = ({ children, title, segments, selected, onSelected
|
|
|
30529
30578
|
return (jsxs("div", Object.assign({ className: `${MAINCLASS}__Container` }, { children: [headerMarkup, contentMarkup] }), void 0));
|
|
30530
30579
|
};
|
|
30531
30580
|
|
|
30532
|
-
export { ActionList, Alert, AlertProvider, AlphaAttributeInput, AlphaBadge, AlphaButton, AlphaChip, AlphaFilterControl, AlphaGraphicCard, AlphaIcon, AlphaInlineError, AlphaInputDate, InputTag$1 as AlphaInputTag, AlphaInputText, AlphaLabel, AlphaLabelledField, AlphaMultiSelectionPicker, AlphaSegmentedControl, AlphaSpinner, AlphaStepper, AlphaTag, AlphaTile, AlphaTooltip, Totalizer as AlphaTotalizer, AlphaZipCodeInput, AnnotatedSection, Avatar, Badge, Banner, Button, CalendarPicker, Card, Checkbox, ChoiceList, Collapsible, Connector, Container, Cover, DataTable, DatePicker, DeletableSection, Divider, DynamicForm, EmptyState, ErrorIcon, FileDownloader, Filedrop, FilterControl, Filters, Footer, Form, FormField, FormLayout, Frame, Grid, GridItem, Header$1 as Header, Icon, IconButton, IndexList, InlineEdit, InputPhoneNumber, InputTag, InputText, JsonViewer, Label, Link, ListInfo, Loader, Logo, Media, Modal, ModalHeader, Nip, OptionList, Page, PageActions, Pagination, Pane, Panel, PanelFooter, PanelHeader, PendingIcon, Popover$1 as Popover, Progress, RadioButton, SectionForm, Select, SideMenu, SkeletonInput, SkeletonMedia, SkeletonTabs, SkeletonText, SkeletonTitle, SortableList, Spinner, Stack, StepDefault, SuccessIcon, Table, Tabs, Tag, ThemeProvider, ThreadItem, Thumbnail, Tile, TimeSelector, Title, Toggle, Tooltip, WarningIcon, capitalize, cssClassName, formatDate, isComponentTypeOf, isValidIcon, themeClassConverter, useShowAlert, useTheme };
|
|
30581
|
+
export { ActionList, Alert, AlertProvider, AlphaAttributeInput, AlphaBadge, AlphaButton, AlphaChip, AlphaFilterControl, AlphaGraphicCard, AlphaIcon, AlphaInlineError, AlphaInputDate, InputTag$1 as AlphaInputTag, AlphaInputText, AlphaLabel, AlphaLabelledField, AlphaMultiSelectionPicker, AlphaSegmentedControl, AlphaSpinner, AlphaStepper, AlphaTag, AlphaTile, AlphaTooltip, Totalizer as AlphaTotalizer, AlphaZipCodeInput, AnnotatedSection, Avatar, Badge, Banner, Button, CalendarPicker, Card, Checkbox, ChoiceList, Collapsible, Connector, Container, Cover, DataTable, DatePicker, DeletableSection, Divider, DynamicForm, EmptyState, ErrorIcon, FileDownloader, Filedrop, FilterControl, Filters, Footer, Form, FormField, FormLayout, Frame, Grid, GridItem, Header$1 as Header, Icon, IconButton, IndexList, InlineEdit, InputPhoneNumber, InputTag, InputText, JsonViewer, Label, Link, ListInfo, Loader, Logo, Media, Modal, ModalHeader, Nip, OptionList, Page, PageActions, Pagination, Pane, Panel, PanelFooter, PanelHeader, PendingIcon, Popover$1 as Popover, Progress, RadioButton, SectionForm, Select, SideMenu, SkeletonInput, SkeletonMedia, SkeletonTabs, SkeletonText, SkeletonTitle, SortableList, Spinner, Stack, StepDefault, SuccessIcon, Table, Tabs, Tag, ThemeProvider, ThreadItem, Thumbnail, Tile, TimeSelector, Title, Toggle, Tooltip, WarningIcon, capitalize, cssClassName, formatDate, formatFileSize, isComponentTypeOf, isValidIcon, themeClassConverter, useShowAlert, useTheme };
|
|
30533
30582
|
//# sourceMappingURL=index.js.map
|