fis-component 0.1.15 → 0.1.17
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/cjs/index.js +101 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/src/assets/icons/DownloadIcon.d.ts +3 -0
- package/dist/cjs/types/src/assets/icons/index.d.ts +1 -0
- package/dist/cjs/types/src/components/SplitButton/SplitButton.stories.d.ts +1 -0
- package/dist/cjs/types/src/components/SplitButton/index.d.ts +2 -0
- package/dist/cjs/types/src/components/SplitButton/styles.d.ts +1 -0
- package/dist/cjs/types/src/components/SplitButton/types.d.ts +7 -0
- package/dist/esm/index.js +101 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/src/assets/icons/DownloadIcon.d.ts +3 -0
- package/dist/esm/types/src/assets/icons/index.d.ts +1 -0
- package/dist/esm/types/src/components/SplitButton/SplitButton.stories.d.ts +1 -0
- package/dist/esm/types/src/components/SplitButton/index.d.ts +2 -0
- package/dist/esm/types/src/components/SplitButton/styles.d.ts +1 -0
- package/dist/esm/types/src/components/SplitButton/types.d.ts +7 -0
- package/dist/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -71323,7 +71323,7 @@ const DivInputWrapperSC$2 = styled.div `
|
|
|
71323
71323
|
display: inline-block;
|
|
71324
71324
|
width: 100%;
|
|
71325
71325
|
`;
|
|
71326
|
-
const DivDropdownMenuSC$
|
|
71326
|
+
const DivDropdownMenuSC$2 = styled.div `
|
|
71327
71327
|
margin-top: ${getTheme("com/select/vertical-gap")};
|
|
71328
71328
|
`;
|
|
71329
71329
|
const SelectedTagsWrapper$1 = styled.div `
|
|
@@ -72169,7 +72169,7 @@ const FISCombobox = React.forwardRef(({ className, options, value, disabled = fa
|
|
|
72169
72169
|
}, [filteredOptions, searchValue]);
|
|
72170
72170
|
return (jsxRuntime.jsxs(DivWrapperSC$3, { className: className, children: [(textLabel || iconLabel) && (jsxRuntime.jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxRuntime.jsx(DivInputWrapperSC$2, { ref: setReferenceElement, onClick: handleToggle, children: jsxRuntime.jsx(FISInputField, { ...restProps, ref: ref, iconSuffix: isOpen ? jsxRuntime.jsx(ArrowUpIcon, {}) : jsxRuntime.jsx(ArrowDownIcon, {}), value: isOpen && searchValue !== undefined
|
|
72171
72171
|
? searchValue
|
|
72172
|
-
: computedDisplayValue, disabled: disabled, onClickSuffix: handleToggle, onChange: handleInputChange, onKeyDown: handleInputKeyDown, "$isPointer": true }) }), message && (jsxRuntime.jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsxRuntime.jsx(SelectedTagsWrapper$1, { children: jsxRuntime.jsx(MultipleValue, { options: selectedOptions, onRemove: handleOptionRemove }) })), isOpen && (jsxRuntime.jsx(Portal, { children: jsxRuntime.jsx(DivDropdownMenuSC$
|
|
72172
|
+
: computedDisplayValue, disabled: disabled, onClickSuffix: handleToggle, onChange: handleInputChange, onKeyDown: handleInputKeyDown, "$isPointer": true }) }), message && (jsxRuntime.jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsxRuntime.jsx(SelectedTagsWrapper$1, { children: jsxRuntime.jsx(MultipleValue, { options: selectedOptions, onRemove: handleOptionRemove }) })), isOpen && (jsxRuntime.jsx(Portal, { children: jsxRuntime.jsx(DivDropdownMenuSC$2, { ref: setPopperElement, style: { ...styles.popper, width: referenceElement?.offsetWidth }, ...attributes.popper, children: jsxRuntime.jsx(FISMenuSelect, { groups: filteredOptions, placeholder: placeholderSearch, loading: loading, multi: multi, combobox: true, noResult: hasNoResults, noResultText: noResultText, maxHeight: maxHeight, selectedValues: multi ? value : value ? [value] : [], onChangeSelected: (values) => {
|
|
72173
72173
|
if (multi) {
|
|
72174
72174
|
onChange(values);
|
|
72175
72175
|
}
|
|
@@ -73421,6 +73421,9 @@ FISProgressLinear.displayName = "FISProgressLinear";
|
|
|
73421
73421
|
const DivContainerSC$1 = styled.div `
|
|
73422
73422
|
display: inline-flex;
|
|
73423
73423
|
`;
|
|
73424
|
+
const DivDropdownMenuSC$1 = styled.div `
|
|
73425
|
+
margin-top: ${getTheme("com/select/vertical-gap")};
|
|
73426
|
+
`;
|
|
73424
73427
|
const ButtonItem = styled.button `
|
|
73425
73428
|
display: flex;
|
|
73426
73429
|
justify-content: center;
|
|
@@ -74389,8 +74392,99 @@ const SplitButtonIcon = ({ size, variant, onIconClick, disabled = false, activeI
|
|
|
74389
74392
|
var SplitButtonIcon$1 = React.memo(SplitButtonIcon);
|
|
74390
74393
|
|
|
74391
74394
|
const FISSplitButton = React.forwardRef((props, ref) => {
|
|
74392
|
-
const { className, label, icon, size = "md", variant = "primary", disabled = false, activeButton = false, activeIcon
|
|
74393
|
-
|
|
74395
|
+
const { className, label, icon, size = "md", variant = "primary", disabled = false, activeButton = false, activeIcon, loading = false, onButtonClick, onIconClick, menuProps, portal, } = props;
|
|
74396
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
74397
|
+
const [referenceElement, setReferenceElement] = React.useState(null);
|
|
74398
|
+
const [popperElement, setPopperElement] = React.useState(null);
|
|
74399
|
+
const hasMenu = !!menuProps?.groups;
|
|
74400
|
+
const isMenuOpen = hasMenu && isOpen;
|
|
74401
|
+
const isButtonActive = isMenuOpen || activeButton;
|
|
74402
|
+
const isIconActive = isMenuOpen || !!activeIcon;
|
|
74403
|
+
const menuSize = menuProps?.size ?? (size === "lg" ? "lg" : "md");
|
|
74404
|
+
const isActionMenu = !!menuProps?.onMenuItemClick;
|
|
74405
|
+
const popperOptions = React.useMemo(() => ({
|
|
74406
|
+
modifiers: [
|
|
74407
|
+
{ name: "preventOverflow", options: { padding: 0, altAxis: true } },
|
|
74408
|
+
{
|
|
74409
|
+
name: "offset",
|
|
74410
|
+
options: {
|
|
74411
|
+
offset: [0, 4],
|
|
74412
|
+
},
|
|
74413
|
+
},
|
|
74414
|
+
],
|
|
74415
|
+
placement: "bottom-start",
|
|
74416
|
+
strategy: "fixed",
|
|
74417
|
+
}), []);
|
|
74418
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);
|
|
74419
|
+
const handleContainerRef = React.useCallback((node) => {
|
|
74420
|
+
setReferenceElement(node);
|
|
74421
|
+
if (typeof ref === "function") {
|
|
74422
|
+
ref(node);
|
|
74423
|
+
return;
|
|
74424
|
+
}
|
|
74425
|
+
if (ref) {
|
|
74426
|
+
ref.current =
|
|
74427
|
+
node;
|
|
74428
|
+
}
|
|
74429
|
+
}, [ref]);
|
|
74430
|
+
const handleIconClick = React.useCallback(() => {
|
|
74431
|
+
if (hasMenu) {
|
|
74432
|
+
setIsOpen((prev) => !prev);
|
|
74433
|
+
}
|
|
74434
|
+
onIconClick?.();
|
|
74435
|
+
}, [hasMenu, onIconClick]);
|
|
74436
|
+
const handleButtonClick = React.useCallback(() => {
|
|
74437
|
+
if (hasMenu) {
|
|
74438
|
+
setIsOpen(true);
|
|
74439
|
+
return;
|
|
74440
|
+
}
|
|
74441
|
+
onButtonClick?.();
|
|
74442
|
+
}, [hasMenu, onButtonClick]);
|
|
74443
|
+
const handleMenuClick = React.useCallback(() => {
|
|
74444
|
+
if (!menuProps?.multi) {
|
|
74445
|
+
setIsOpen(false);
|
|
74446
|
+
}
|
|
74447
|
+
menuProps?.onClickMenu?.();
|
|
74448
|
+
}, [menuProps]);
|
|
74449
|
+
const handleChangeSelected = React.useCallback((values) => {
|
|
74450
|
+
if (menuProps?.onMenuItemClick) {
|
|
74451
|
+
const clickedValue = values[values.length - 1];
|
|
74452
|
+
const clickedItem = menuProps.groups
|
|
74453
|
+
.flatMap((group) => group.items)
|
|
74454
|
+
.find((item) => item.value === clickedValue);
|
|
74455
|
+
if (clickedItem) {
|
|
74456
|
+
menuProps.onMenuItemClick(clickedItem);
|
|
74457
|
+
setIsOpen(false);
|
|
74458
|
+
}
|
|
74459
|
+
return;
|
|
74460
|
+
}
|
|
74461
|
+
menuProps?.onChangeSelected?.(values);
|
|
74462
|
+
}, [menuProps]);
|
|
74463
|
+
React.useEffect(() => {
|
|
74464
|
+
if (!isMenuOpen)
|
|
74465
|
+
return;
|
|
74466
|
+
const handleClickOutside = (event) => {
|
|
74467
|
+
const target = event.target;
|
|
74468
|
+
if (referenceElement &&
|
|
74469
|
+
!referenceElement.contains(target) &&
|
|
74470
|
+
popperElement &&
|
|
74471
|
+
!popperElement.contains(target)) {
|
|
74472
|
+
setIsOpen(false);
|
|
74473
|
+
}
|
|
74474
|
+
};
|
|
74475
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
74476
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
74477
|
+
}, [isMenuOpen, popperElement, referenceElement]);
|
|
74478
|
+
React.useEffect(() => {
|
|
74479
|
+
if (disabled || loading || !hasMenu) {
|
|
74480
|
+
setIsOpen(false);
|
|
74481
|
+
}
|
|
74482
|
+
}, [disabled, hasMenu, loading]);
|
|
74483
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(DivContainerSC$1, { ref: handleContainerRef, className: className, role: "group", "aria-label": `${label} split button`, children: [jsxRuntime.jsx(SplitButtonItem$1, { icon: icon, label: label, size: size, variant: variant, disabled: disabled || loading, activeButton: isButtonActive, loading: loading, onButtonClick: handleButtonClick, "aria-label": `${label} main action`, "aria-haspopup": hasMenu ? "menu" : undefined, "aria-expanded": hasMenu ? isMenuOpen : undefined }), jsxRuntime.jsx(SplitButtonIcon$1, { size: size, variant: variant, disabled: disabled || loading, activeIcon: isIconActive, onIconClick: handleIconClick, "aria-label": "Toggle dropdown", "aria-expanded": isMenuOpen })] }), isMenuOpen && menuProps && (jsxRuntime.jsx(Portal, { portal: portal, children: jsxRuntime.jsx(DivDropdownMenuSC$1, { ref: setPopperElement, style: {
|
|
74484
|
+
...styles.popper,
|
|
74485
|
+
width: referenceElement?.offsetWidth,
|
|
74486
|
+
zIndex: 9999,
|
|
74487
|
+
}, ...attributes.popper, children: jsxRuntime.jsx(FISMenuSelect, { ...menuProps, size: menuSize, selectedValues: isActionMenu ? [] : menuProps.selectedValues, focusSearchInput: menuProps.focusSearchInput ?? false, onChangeSelected: handleChangeSelected, onClickMenu: handleMenuClick }) }) }))] }));
|
|
74394
74488
|
});
|
|
74395
74489
|
FISSplitButton.displayName = "FISSplitButton";
|
|
74396
74490
|
|
|
@@ -74725,7 +74819,7 @@ function isMenuSize(value) {
|
|
|
74725
74819
|
return value === "sm" || value === "md";
|
|
74726
74820
|
}
|
|
74727
74821
|
|
|
74728
|
-
const FISSelect = React.forwardRef(({ className, style, size = "md", options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholder, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, searchValue, onSearchChange, portal, maxHeight, onPopupScroll, onOpen, hideChip, tooltipTitle, tooltipVariant = "primary", ...restProps }, ref) => {
|
|
74822
|
+
const FISSelect = React.forwardRef(({ className, style, size = "md", options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholder, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, searchValue, onSearchChange, portal = true, maxHeight, onPopupScroll, onOpen, hideChip, tooltipTitle, tooltipVariant = "primary", ...restProps }, ref) => {
|
|
74729
74823
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
74730
74824
|
const [referenceElement, setReferenceElement] = React.useState(null);
|
|
74731
74825
|
const [popperElement, setPopperElement] = React.useState(null);
|
|
@@ -74757,8 +74851,8 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
|
|
|
74757
74851
|
},
|
|
74758
74852
|
],
|
|
74759
74853
|
placement: "bottom-start",
|
|
74760
|
-
strategy: "fixed",
|
|
74761
|
-
}), []);
|
|
74854
|
+
strategy: portal ? "fixed" : "absolute",
|
|
74855
|
+
}), [portal]);
|
|
74762
74856
|
const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);
|
|
74763
74857
|
const selectedItems = React.useMemo(() => {
|
|
74764
74858
|
const allItems = options.flatMap((group) => group.items);
|