fis-component 0.1.14 → 0.1.16

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 CHANGED
@@ -68635,7 +68635,7 @@ const normalizeText = (value) => {
68635
68635
  .trim();
68636
68636
  };
68637
68637
 
68638
- const FISMenuSelect = ({ placeholder, groups, size = "md", multi = false, selectedValues = [], onChangeSelected, searchValue = "", onSearchChange, loading = false, noData = false, noResult = false, combobox, className, onClickMenu, loadingText = "Data loading...", noDataText = "No data", noResultText = "No result", removeSelectedText = "Remove selected", selectedGroupLabel = "Selected", maxHeight, focusSearchInput = true, onPopupScroll, normalizeTextSearch = false, }) => {
68638
+ const FISMenuSelect = ({ placeholder, groups, size = "md", multi = false, selectedValues = [], onChangeSelected, searchValue = "", onSearchChange, loading = false, noData = false, noResult = false, combobox, className, onClickMenu, loadingText = "Data loading...", noDataText = "No data", noResultText = "No result", removeSelectedText = "Remove selected", selectedGroupLabel = "Selected", maxHeight, focusSearchInput = true, onPopupScroll, normalizeTextSearch = false, renderOption, }) => {
68639
68639
  const [localSearch, setLocalSearch] = React.useState(searchValue);
68640
68640
  const [debouncedSearchValue, setDebouncedSearchValue] = React.useState(searchValue);
68641
68641
  const searchInputRef = React.useRef(null);
@@ -68739,7 +68739,7 @@ const FISMenuSelect = ({ placeholder, groups, size = "md", multi = false, select
68739
68739
  searchInputRef.current.focus();
68740
68740
  }
68741
68741
  }, [focusSearchInput]);
68742
- return (jsxRuntime.jsxs(DivContainerSC$4, { "$maxHeight": maxHeight, className: className, children: [showInput && !combobox && (jsxRuntime.jsx(DivSearchSC, { children: jsxRuntime.jsx(FISInputText, { iconPrefix: jsxRuntime.jsx(SearchIcon, {}), placeholder: placeholder, value: search, onChange: handleSearchChange, ref: searchInputRef }) })), loading && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(FISProgressCircular, { size: size, variant: "indeterminate" }), jsxRuntime.jsx(PTitleSC$2, { children: loadingText })] })), !loading && noData && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(DivIconDataSC, { children: jsxRuntime.jsx(NoDataIcon, {}) }), jsxRuntime.jsx(PTitleSC$2, { children: noDataText })] })), !loading && !noData && (shouldShowNoResult || noResult) && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(DivIconDataSC, { children: jsxRuntime.jsx(NoResultIcon, {}) }), jsxRuntime.jsx(PTitleSC$2, { children: noResultText })] })), !shouldShowNoResult && !noData && !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuContent, { "$removeSelectedGroup": !!removeSelectedGroup, onScroll: onPopupScroll, children: groupsToRender.map((group, index) => (jsxRuntime.jsxs(DivWrapperSC$4, { children: [index !== 0 && jsxRuntime.jsx(FISMenuSection, { withDivider: true }), group?.groupLabel && (jsxRuntime.jsx(FISMenuSection, { label: group?.groupLabel })), group.items.map((item, idx) => (jsxRuntime.jsx(FISTooltip, { title: item.label, variant: "primary", children: jsxRuntime.jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => handleItemClick(item), selected: selectedValues.includes(item.value), type: "select" }) }, idx)))] }, index))) }), removeSelectedGroup && (jsxRuntime.jsx(FixedBottomSection, { children: jsxRuntime.jsx(DivWrapperSC$4, { children: removeSelectedGroup.items.map((item, idx) => (jsxRuntime.jsx(FISTooltip, { title: item.label, variant: "primary", children: jsxRuntime.jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => onChangeSelected?.([]), type: "select", iconPrefix: jsxRuntime.jsx(RemoveIcon, {}), negative: true }) }, idx))) }) }))] }))] }));
68742
+ return (jsxRuntime.jsxs(DivContainerSC$4, { "$maxHeight": maxHeight, className: className, children: [showInput && !combobox && (jsxRuntime.jsx(DivSearchSC, { children: jsxRuntime.jsx(FISInputText, { iconPrefix: jsxRuntime.jsx(SearchIcon, {}), placeholder: placeholder, value: search, onChange: handleSearchChange, ref: searchInputRef }) })), loading && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(FISProgressCircular, { size: size, variant: "indeterminate" }), jsxRuntime.jsx(PTitleSC$2, { children: loadingText })] })), !loading && noData && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(DivIconDataSC, { children: jsxRuntime.jsx(NoDataIcon, {}) }), jsxRuntime.jsx(PTitleSC$2, { children: noDataText })] })), !loading && !noData && (shouldShowNoResult || noResult) && (jsxRuntime.jsxs(DivLoaderSC, { children: [jsxRuntime.jsx(DivIconDataSC, { children: jsxRuntime.jsx(NoResultIcon, {}) }), jsxRuntime.jsx(PTitleSC$2, { children: noResultText })] })), !shouldShowNoResult && !noData && !loading && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MenuContent, { "$removeSelectedGroup": !!removeSelectedGroup, onScroll: onPopupScroll, children: groupsToRender.map((group, index) => (jsxRuntime.jsxs(DivWrapperSC$4, { children: [index !== 0 && jsxRuntime.jsx(FISMenuSection, { withDivider: true }), group?.groupLabel && (jsxRuntime.jsx(FISMenuSection, { label: group?.groupLabel })), group.items.map((item, idx) => (jsxRuntime.jsx(FISTooltip, { title: item.label, variant: "primary", children: renderOption ? (jsxRuntime.jsx("div", { onClick: () => handleItemClick(item), children: renderOption(item) })) : (jsxRuntime.jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => handleItemClick(item), selected: selectedValues.includes(item.value), type: "select" })) }, idx)))] }, index))) }), removeSelectedGroup && (jsxRuntime.jsx(FixedBottomSection, { children: jsxRuntime.jsx(DivWrapperSC$4, { children: removeSelectedGroup.items.map((item, idx) => (jsxRuntime.jsx(FISTooltip, { title: item.label, variant: "primary", children: jsxRuntime.jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => onChangeSelected?.([]), type: "select", iconPrefix: jsxRuntime.jsx(RemoveIcon, {}), negative: true }) }, idx))) }) }))] }))] }));
68743
68743
  };
68744
68744
  FISMenuSelect.displayName = "FISMenuSelect";
68745
68745
 
@@ -71323,7 +71323,7 @@ const DivInputWrapperSC$2 = styled.div `
71323
71323
  display: inline-block;
71324
71324
  width: 100%;
71325
71325
  `;
71326
- const DivDropdownMenuSC$1 = styled.div `
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$1, { 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) => {
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 = false, loading = false, onButtonClick, onIconClick, } = props;
74393
- return (jsxRuntime.jsxs(DivContainerSC$1, { ref: ref, 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: activeButton, loading: loading, onButtonClick: onButtonClick, "aria-label": `${label} main action` }), jsxRuntime.jsx(SplitButtonIcon$1, { size: size, variant: variant, disabled: disabled || loading, activeIcon: activeIcon, onIconClick: onIconClick, "aria-label": "Toggle dropdown", "aria-expanded": activeIcon })] }));
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
 
@@ -74868,6 +74962,7 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
74868
74962
  onSearchChange,
74869
74963
  maxHeight,
74870
74964
  onPopupScroll,
74965
+ renderOption,
74871
74966
  ...restProps,
74872
74967
  }), [
74873
74968
  options,
@@ -74882,6 +74977,7 @@ const FISSelect = React.forwardRef(({ className, style, size = "md", options, va
74882
74977
  onSearchChange,
74883
74978
  maxHeight,
74884
74979
  onPopupScroll,
74980
+ renderOption,
74885
74981
  restProps,
74886
74982
  ]);
74887
74983
  React.useEffect(() => {