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
|
@@ -28,6 +28,7 @@ export { default as ArrowUpIcon } from "./ArrowUpIcon";
|
|
|
28
28
|
export { default as CloseChipIcon } from "./CloseChipIcon";
|
|
29
29
|
export { default as TimeIcon } from "./TimeIcon";
|
|
30
30
|
export { default as DateIcon } from "./DateIcon";
|
|
31
|
+
export { default as DownloadIcon } from "./DownloadIcon";
|
|
31
32
|
export { default as ChevronSelectorIcon } from "./ChevronSelector";
|
|
32
33
|
export { default as EditIcon } from "./EditIcon";
|
|
33
34
|
export { default as DeleteIcon } from "./DeleteIcon";
|
|
@@ -14,5 +14,7 @@ declare const FISSplitButton: React.ForwardRefExoticComponent<{
|
|
|
14
14
|
onIconClick?: () => void;
|
|
15
15
|
} & {
|
|
16
16
|
className?: string;
|
|
17
|
+
menuProps?: import("./types").SplitButtonMenuProps;
|
|
18
|
+
portal?: boolean;
|
|
17
19
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
18
20
|
export default FISSplitButton;
|
|
@@ -8,6 +8,7 @@ export type SplitButtonProps = {
|
|
|
8
8
|
$loading?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare const DivContainerSC: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SplitButtonProps>> & string;
|
|
11
|
+
export declare const DivDropdownMenuSC: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
11
12
|
export declare const ButtonItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, SplitButtonProps>> & string;
|
|
12
13
|
export declare const ButtonIconItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, SplitButtonProps>> & string;
|
|
13
14
|
export declare const DivIconItemSC: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SplitButtonProps>> & string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import type { MenuItem, MenuProps, MenuSize } from "../MenuSelect/types";
|
|
2
3
|
export type SplitButtonSize = "xs" | "sm" | "md" | "lg";
|
|
3
4
|
export type SplitButtonVariant = "primary" | "secondary" | "tertiary" | "primary-white" | "secondary-white";
|
|
4
5
|
export type SplitButtonItemProps = {
|
|
@@ -16,6 +17,12 @@ export type SplitButtonIconProps = {
|
|
|
16
17
|
activeIcon?: boolean;
|
|
17
18
|
onIconClick?: () => void;
|
|
18
19
|
} & ComponentPropsWithoutRef<"button">;
|
|
20
|
+
export type SplitButtonMenuProps = Omit<MenuProps, "size"> & {
|
|
21
|
+
size?: MenuSize;
|
|
22
|
+
onMenuItemClick?: (item: MenuItem) => void;
|
|
23
|
+
};
|
|
19
24
|
export type SplitButtonProps = SplitButtonItemProps & SplitButtonIconProps & {
|
|
20
25
|
className?: string;
|
|
26
|
+
menuProps?: SplitButtonMenuProps;
|
|
27
|
+
portal?: boolean;
|
|
21
28
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -71303,7 +71303,7 @@ const DivInputWrapperSC$2 = styled.div `
|
|
|
71303
71303
|
display: inline-block;
|
|
71304
71304
|
width: 100%;
|
|
71305
71305
|
`;
|
|
71306
|
-
const DivDropdownMenuSC$
|
|
71306
|
+
const DivDropdownMenuSC$2 = styled.div `
|
|
71307
71307
|
margin-top: ${getTheme("com/select/vertical-gap")};
|
|
71308
71308
|
`;
|
|
71309
71309
|
const SelectedTagsWrapper$1 = styled.div `
|
|
@@ -72149,7 +72149,7 @@ const FISCombobox = forwardRef(({ className, options, value, disabled = false, t
|
|
|
72149
72149
|
}, [filteredOptions, searchValue]);
|
|
72150
72150
|
return (jsxs(DivWrapperSC$3, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsx(DivInputWrapperSC$2, { ref: setReferenceElement, onClick: handleToggle, children: jsx(FISInputField, { ...restProps, ref: ref, iconSuffix: isOpen ? jsx(ArrowUpIcon, {}) : jsx(ArrowDownIcon, {}), value: isOpen && searchValue !== undefined
|
|
72151
72151
|
? searchValue
|
|
72152
|
-
: computedDisplayValue, disabled: disabled, onClickSuffix: handleToggle, onChange: handleInputChange, onKeyDown: handleInputKeyDown, "$isPointer": true }) }), message && (jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsx(SelectedTagsWrapper$1, { children: jsx(MultipleValue, { options: selectedOptions, onRemove: handleOptionRemove }) })), isOpen && (jsx(Portal, { children: jsx(DivDropdownMenuSC$
|
|
72152
|
+
: computedDisplayValue, disabled: disabled, onClickSuffix: handleToggle, onChange: handleInputChange, onKeyDown: handleInputKeyDown, "$isPointer": true }) }), message && (jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsx(SelectedTagsWrapper$1, { children: jsx(MultipleValue, { options: selectedOptions, onRemove: handleOptionRemove }) })), isOpen && (jsx(Portal, { children: jsx(DivDropdownMenuSC$2, { ref: setPopperElement, style: { ...styles.popper, width: referenceElement?.offsetWidth }, ...attributes.popper, children: 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) => {
|
|
72153
72153
|
if (multi) {
|
|
72154
72154
|
onChange(values);
|
|
72155
72155
|
}
|
|
@@ -73401,6 +73401,9 @@ FISProgressLinear.displayName = "FISProgressLinear";
|
|
|
73401
73401
|
const DivContainerSC$1 = styled.div `
|
|
73402
73402
|
display: inline-flex;
|
|
73403
73403
|
`;
|
|
73404
|
+
const DivDropdownMenuSC$1 = styled.div `
|
|
73405
|
+
margin-top: ${getTheme("com/select/vertical-gap")};
|
|
73406
|
+
`;
|
|
73404
73407
|
const ButtonItem = styled.button `
|
|
73405
73408
|
display: flex;
|
|
73406
73409
|
justify-content: center;
|
|
@@ -74369,8 +74372,99 @@ const SplitButtonIcon$1 = ({ size, variant, onIconClick, disabled = false, activ
|
|
|
74369
74372
|
var SplitButtonIcon = memo(SplitButtonIcon$1);
|
|
74370
74373
|
|
|
74371
74374
|
const FISSplitButton = forwardRef((props, ref) => {
|
|
74372
|
-
const { className, label, icon, size = "md", variant = "primary", disabled = false, activeButton = false, activeIcon
|
|
74373
|
-
|
|
74375
|
+
const { className, label, icon, size = "md", variant = "primary", disabled = false, activeButton = false, activeIcon, loading = false, onButtonClick, onIconClick, menuProps, portal, } = props;
|
|
74376
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
74377
|
+
const [referenceElement, setReferenceElement] = useState(null);
|
|
74378
|
+
const [popperElement, setPopperElement] = useState(null);
|
|
74379
|
+
const hasMenu = !!menuProps?.groups;
|
|
74380
|
+
const isMenuOpen = hasMenu && isOpen;
|
|
74381
|
+
const isButtonActive = isMenuOpen || activeButton;
|
|
74382
|
+
const isIconActive = isMenuOpen || !!activeIcon;
|
|
74383
|
+
const menuSize = menuProps?.size ?? (size === "lg" ? "lg" : "md");
|
|
74384
|
+
const isActionMenu = !!menuProps?.onMenuItemClick;
|
|
74385
|
+
const popperOptions = useMemo$1(() => ({
|
|
74386
|
+
modifiers: [
|
|
74387
|
+
{ name: "preventOverflow", options: { padding: 0, altAxis: true } },
|
|
74388
|
+
{
|
|
74389
|
+
name: "offset",
|
|
74390
|
+
options: {
|
|
74391
|
+
offset: [0, 4],
|
|
74392
|
+
},
|
|
74393
|
+
},
|
|
74394
|
+
],
|
|
74395
|
+
placement: "bottom-start",
|
|
74396
|
+
strategy: "fixed",
|
|
74397
|
+
}), []);
|
|
74398
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);
|
|
74399
|
+
const handleContainerRef = useCallback((node) => {
|
|
74400
|
+
setReferenceElement(node);
|
|
74401
|
+
if (typeof ref === "function") {
|
|
74402
|
+
ref(node);
|
|
74403
|
+
return;
|
|
74404
|
+
}
|
|
74405
|
+
if (ref) {
|
|
74406
|
+
ref.current =
|
|
74407
|
+
node;
|
|
74408
|
+
}
|
|
74409
|
+
}, [ref]);
|
|
74410
|
+
const handleIconClick = useCallback(() => {
|
|
74411
|
+
if (hasMenu) {
|
|
74412
|
+
setIsOpen((prev) => !prev);
|
|
74413
|
+
}
|
|
74414
|
+
onIconClick?.();
|
|
74415
|
+
}, [hasMenu, onIconClick]);
|
|
74416
|
+
const handleButtonClick = useCallback(() => {
|
|
74417
|
+
if (hasMenu) {
|
|
74418
|
+
setIsOpen(true);
|
|
74419
|
+
return;
|
|
74420
|
+
}
|
|
74421
|
+
onButtonClick?.();
|
|
74422
|
+
}, [hasMenu, onButtonClick]);
|
|
74423
|
+
const handleMenuClick = useCallback(() => {
|
|
74424
|
+
if (!menuProps?.multi) {
|
|
74425
|
+
setIsOpen(false);
|
|
74426
|
+
}
|
|
74427
|
+
menuProps?.onClickMenu?.();
|
|
74428
|
+
}, [menuProps]);
|
|
74429
|
+
const handleChangeSelected = useCallback((values) => {
|
|
74430
|
+
if (menuProps?.onMenuItemClick) {
|
|
74431
|
+
const clickedValue = values[values.length - 1];
|
|
74432
|
+
const clickedItem = menuProps.groups
|
|
74433
|
+
.flatMap((group) => group.items)
|
|
74434
|
+
.find((item) => item.value === clickedValue);
|
|
74435
|
+
if (clickedItem) {
|
|
74436
|
+
menuProps.onMenuItemClick(clickedItem);
|
|
74437
|
+
setIsOpen(false);
|
|
74438
|
+
}
|
|
74439
|
+
return;
|
|
74440
|
+
}
|
|
74441
|
+
menuProps?.onChangeSelected?.(values);
|
|
74442
|
+
}, [menuProps]);
|
|
74443
|
+
useEffect(() => {
|
|
74444
|
+
if (!isMenuOpen)
|
|
74445
|
+
return;
|
|
74446
|
+
const handleClickOutside = (event) => {
|
|
74447
|
+
const target = event.target;
|
|
74448
|
+
if (referenceElement &&
|
|
74449
|
+
!referenceElement.contains(target) &&
|
|
74450
|
+
popperElement &&
|
|
74451
|
+
!popperElement.contains(target)) {
|
|
74452
|
+
setIsOpen(false);
|
|
74453
|
+
}
|
|
74454
|
+
};
|
|
74455
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
74456
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
74457
|
+
}, [isMenuOpen, popperElement, referenceElement]);
|
|
74458
|
+
useEffect(() => {
|
|
74459
|
+
if (disabled || loading || !hasMenu) {
|
|
74460
|
+
setIsOpen(false);
|
|
74461
|
+
}
|
|
74462
|
+
}, [disabled, hasMenu, loading]);
|
|
74463
|
+
return (jsxs(Fragment, { children: [jsxs(DivContainerSC$1, { ref: handleContainerRef, className: className, role: "group", "aria-label": `${label} split button`, children: [jsx(SplitButtonItem, { 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 }), jsx(SplitButtonIcon, { size: size, variant: variant, disabled: disabled || loading, activeIcon: isIconActive, onIconClick: handleIconClick, "aria-label": "Toggle dropdown", "aria-expanded": isMenuOpen })] }), isMenuOpen && menuProps && (jsx(Portal, { portal: portal, children: jsx(DivDropdownMenuSC$1, { ref: setPopperElement, style: {
|
|
74464
|
+
...styles.popper,
|
|
74465
|
+
width: referenceElement?.offsetWidth,
|
|
74466
|
+
zIndex: 9999,
|
|
74467
|
+
}, ...attributes.popper, children: jsx(FISMenuSelect, { ...menuProps, size: menuSize, selectedValues: isActionMenu ? [] : menuProps.selectedValues, focusSearchInput: menuProps.focusSearchInput ?? false, onChangeSelected: handleChangeSelected, onClickMenu: handleMenuClick }) }) }))] }));
|
|
74374
74468
|
});
|
|
74375
74469
|
FISSplitButton.displayName = "FISSplitButton";
|
|
74376
74470
|
|
|
@@ -74705,7 +74799,7 @@ function isMenuSize(value) {
|
|
|
74705
74799
|
return value === "sm" || value === "md";
|
|
74706
74800
|
}
|
|
74707
74801
|
|
|
74708
|
-
const FISSelect = 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) => {
|
|
74802
|
+
const FISSelect = 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) => {
|
|
74709
74803
|
const [isOpen, setIsOpen] = useState(false);
|
|
74710
74804
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
74711
74805
|
const [popperElement, setPopperElement] = useState(null);
|
|
@@ -74737,8 +74831,8 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
|
|
|
74737
74831
|
},
|
|
74738
74832
|
],
|
|
74739
74833
|
placement: "bottom-start",
|
|
74740
|
-
strategy: "fixed",
|
|
74741
|
-
}), []);
|
|
74834
|
+
strategy: portal ? "fixed" : "absolute",
|
|
74835
|
+
}), [portal]);
|
|
74742
74836
|
const { styles, attributes } = usePopper(referenceElement, popperElement, popperOptions);
|
|
74743
74837
|
const selectedItems = useMemo$1(() => {
|
|
74744
74838
|
const allItems = options.flatMap((group) => group.items);
|