fis-component 0.0.57 → 0.0.58

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.
@@ -10,7 +10,7 @@ export interface ComboboxOption {
10
10
  }[];
11
11
  }
12
12
  export type SingleSelect<T> = {
13
- multi?: boolean;
13
+ multi?: false;
14
14
  value: T;
15
15
  onChange: (value: T) => void;
16
16
  displayValue?: (value: ComboboxOption) => string;
@@ -1,7 +1,7 @@
1
1
  export interface MenuItem {
2
2
  label: string;
3
3
  description?: string;
4
- value: string;
4
+ value: string | number;
5
5
  }
6
6
  export interface MenuGroup {
7
7
  groupLabel?: string;
@@ -16,8 +16,8 @@ export interface MenuProps {
16
16
  multi?: boolean;
17
17
  searchValue?: string;
18
18
  onSearchChange?: (value: string) => void;
19
- selectedValues?: string[];
20
- onChangeSelected?: (values: string[]) => void;
19
+ selectedValues?: (string | number)[];
20
+ onChangeSelected?: (values: (string | number)[]) => void;
21
21
  loading?: boolean;
22
22
  noData?: boolean;
23
23
  noResult?: boolean;
@@ -2,6 +2,7 @@ import { Meta } from "@storybook/react";
2
2
  import { SelectProps } from "./types";
3
3
  type SingleSelectStoryProps = SelectProps<string>;
4
4
  type MultiSelectStoryProps = SelectProps<string>;
5
+ type NumberSelectStoryProps = SelectProps<number>;
5
6
  declare const _default: Meta<SingleSelectStoryProps>;
6
7
  export default _default;
7
8
  export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
@@ -11,3 +12,4 @@ export declare const WithValidation: import("@storybook/core/csf").AnnotatedStor
11
12
  export declare const Loading: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
12
13
  export declare const LargeSize: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
13
14
  export declare const Disabled: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
15
+ export declare const NumberType: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, NumberSelectStoryProps>;
@@ -1,3 +1,3 @@
1
1
  import { SelectProps } from "./types";
2
- declare const FISSelect: import("react").ForwardRefExoticComponent<SelectProps<string> & import("react").RefAttributes<HTMLInputElement>>;
2
+ declare const FISSelect: import("react").ForwardRefExoticComponent<SelectProps<string | number> & import("react").RefAttributes<HTMLInputElement>>;
3
3
  export default FISSelect;
@@ -1,7 +1,7 @@
1
1
  import { InputLabelProps } from "../Input/InputLabel";
2
2
  import { MenuProps } from "../MenuSelect/types";
3
3
  import { SelectFieldProps } from "../SelectItem";
4
- export interface SelectOption<T = string> {
4
+ export interface SelectOption<T = string | number> {
5
5
  groupLabel?: string;
6
6
  items: {
7
7
  label: string;
@@ -9,7 +9,7 @@ export interface SelectOption<T = string> {
9
9
  value: T;
10
10
  }[];
11
11
  }
12
- type BaseSelectProps<T> = Partial<InputLabelProps> & Omit<MenuProps, "groups" | "multi" | "selectedValues" | "onChangeSelected" | "onClickMenu" | "size"> & Omit<SelectFieldProps, "value" | "onChange"> & {
12
+ type BaseSelectProps<T extends string | number> = Partial<InputLabelProps> & Omit<MenuProps, "groups" | "multi" | "selectedValues" | "onChangeSelected" | "onClickMenu" | "size"> & Omit<SelectFieldProps, "value" | "onChange"> & {
13
13
  options: SelectOption<T>[];
14
14
  message?: string;
15
15
  disabled?: boolean;
@@ -19,17 +19,17 @@ type BaseSelectProps<T> = Partial<InputLabelProps> & Omit<MenuProps, "groups" |
19
19
  renderOption?: (option: SelectOption<T>) => React.ReactNode;
20
20
  portal?: boolean;
21
21
  };
22
- export type SingleSelectProps<T> = BaseSelectProps<T> & {
22
+ export type SingleSelectProps<T extends string | number> = BaseSelectProps<T> & {
23
23
  multi?: false;
24
24
  value: T;
25
25
  onChange: (value: T) => void;
26
26
  displayValue?: (value: SelectOption<T>) => string;
27
27
  };
28
- export type MultiSelectProps<T> = BaseSelectProps<T> & {
28
+ export type MultiSelectProps<T extends string | number> = BaseSelectProps<T> & {
29
29
  multi: true;
30
30
  value: T[];
31
31
  onChange: (value: T[]) => void;
32
32
  displayValue?: (value: SelectOption<T>[]) => string;
33
33
  };
34
- export type SelectProps<T> = SingleSelectProps<T> | MultiSelectProps<T>;
34
+ export type SelectProps<T extends string | number> = SingleSelectProps<T> | MultiSelectProps<T>;
35
35
  export {};
package/dist/esm/index.js CHANGED
@@ -66337,7 +66337,7 @@ const PTitleSC$2 = styled.p `
66337
66337
  ${getTheme("Paragraph/Sm")}
66338
66338
  color: ${getTheme("com/menu/item/action/label/color-text/default")};
66339
66339
  `;
66340
- styled.div `
66340
+ const DivWrapperMenuSC = styled.div `
66341
66341
  display: flex;
66342
66342
  flex-direction: column;
66343
66343
  height: 100%;
@@ -67448,7 +67448,7 @@ const FISMenuSelect = ({ placeholder, groups, size = "md", multi = false, select
67448
67448
  onClickMenu?.();
67449
67449
  }
67450
67450
  };
67451
- return (jsxs(DivContainerSC$4, { className: className, children: [showInput && !combobox && (jsx(DivSearchSC, { children: jsx(FISInputText, { iconPrefix: jsx(SearchIcon, {}), placeholder: placeholder, value: search, onChange: handleSearchChange }) })), (shouldShowNoResult || noResult) && (jsxs(DivLoaderSC, { children: [jsx(DivIconDataSC, { children: jsx(NoResultIcon, {}) }), jsx(PTitleSC$2, { children: noResultText })] })), noData && (jsxs(DivLoaderSC, { children: [jsx(DivIconDataSC, { children: jsx(NoDataIcon, {}) }), jsx(PTitleSC$2, { children: noDataText })] })), loading && (jsxs(DivLoaderSC, { children: [jsx(FISProgressCircular, { size: size, variant: "indeterminate" }), jsx(PTitleSC$2, { children: loadingText })] })), !shouldShowNoResult && !noData && !loading && (jsxs(Fragment, { children: [jsx(MenuContent, { "$removeSelectedGroup": !!removeSelectedGroup, children: groupsToRender.map((group, index) => (jsxs(DivWrapperSC$4, { children: [index !== 0 && jsx(FISMenuSection, { withDivider: true }), group.groupLabel && group.groupLabel !== "" && (jsx(FISMenuSection, { label: group.groupLabel })), group.items.map((item, idx) => (jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => handleItemClick(item), selected: selectedValues.includes(item.value), type: "select" }, idx)))] }, index))) }), removeSelectedGroup && (jsx(FixedBottomSection, { children: jsx(DivWrapperSC$4, { children: removeSelectedGroup.items.map((item, idx) => (jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => onChangeSelected?.([]), type: "select", iconPrefix: jsx(RemoveIcon, {}), negative: true }, idx))) }) }))] }))] }));
67451
+ return (jsx(DivContainerSC$4, { className: className, children: jsxs(DivWrapperMenuSC, { children: [showInput && !combobox && (jsx(DivSearchSC, { children: jsx(FISInputText, { iconPrefix: jsx(SearchIcon, {}), placeholder: placeholder, value: search, onChange: handleSearchChange }) })), (shouldShowNoResult || noResult) && (jsxs(DivLoaderSC, { children: [jsx(DivIconDataSC, { children: jsx(NoResultIcon, {}) }), jsx(PTitleSC$2, { children: noResultText })] })), noData && (jsxs(DivLoaderSC, { children: [jsx(DivIconDataSC, { children: jsx(NoDataIcon, {}) }), jsx(PTitleSC$2, { children: noDataText })] })), loading && (jsxs(DivLoaderSC, { children: [jsx(FISProgressCircular, { size: size, variant: "indeterminate" }), jsx(PTitleSC$2, { children: loadingText })] })), !shouldShowNoResult && !noData && !loading && (jsxs(Fragment, { children: [jsx(MenuContent, { "$removeSelectedGroup": !!removeSelectedGroup, children: groupsToRender.map((group, index) => (jsxs(DivWrapperSC$4, { children: [index !== 0 && jsx(FISMenuSection, { withDivider: true }), group?.groupLabel && (jsx(FISMenuSection, { label: group?.groupLabel })), group.items.map((item, idx) => (jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => handleItemClick(item), selected: selectedValues.includes(item.value), type: "select" }, idx)))] }, index))) }), removeSelectedGroup && (jsx(FixedBottomSection, { children: jsx(DivWrapperSC$4, { children: removeSelectedGroup.items.map((item, idx) => (jsx(FISMenuItem, { title: item.label, description: item.description, size: size, onClickMenu: () => onChangeSelected?.([]), type: "select", iconPrefix: jsx(RemoveIcon, {}), negative: true }, idx))) }) }))] }))] }) }));
67452
67452
  };
67453
67453
  FISMenuSelect.displayName = "FISMenuSelect";
67454
67454
 
@@ -70912,6 +70912,19 @@ const FISInputTime = forwardRef((props, ref) => {
70912
70912
  const [inputValue, setInputValue] = useState("");
70913
70913
  const [timeValue, setTimeValue] = useState(null);
70914
70914
  const [isOpen, setIsOpen] = useState(false);
70915
+ const containerRef = useRef(null);
70916
+ useEffect(() => {
70917
+ const handleClickOutside = (event) => {
70918
+ if (containerRef.current &&
70919
+ !containerRef.current.contains(event.target)) {
70920
+ setIsOpen(false);
70921
+ }
70922
+ };
70923
+ document.addEventListener("mousedown", handleClickOutside);
70924
+ return () => {
70925
+ document.removeEventListener("mousedown", handleClickOutside);
70926
+ };
70927
+ }, []);
70915
70928
  const handleTimeChange = (time) => {
70916
70929
  setTimeValue(time);
70917
70930
  setInputValue(time ? time.format(format) : "");
@@ -70936,7 +70949,7 @@ const FISInputTime = forwardRef((props, ref) => {
70936
70949
  setIsOpen(open);
70937
70950
  }
70938
70951
  };
70939
- return (jsxs(DivContainerSC$2, { className: className, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputTimeSC, { children: [jsx(FISInputField, { ...rest, ref: ref, typeSuffix: "icon", iconSuffix: jsx(TimeIcon, {}), negative: negative, value: inputValue, onChange: handleInputChange, onFocus: handleClickInput, onClickSuffix: handleClickInput }), jsx(HiddenTimePickerSC, { format: format, value: timeValue, onChange: handleTimeChange, open: isOpen, onOpenChange: handleOpenChange, getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body })] }), message && (jsx(DivHintWrapperSC, { children: jsx(SpanHintSC, { className: classNames({
70952
+ return (jsxs(DivContainerSC$2, { className: className, ref: containerRef, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsxs(DivInputTimeSC, { children: [jsx(FISInputField, { ...rest, ref: ref, typeSuffix: "icon", iconSuffix: jsx(TimeIcon, {}), negative: negative, value: inputValue, onChange: handleInputChange, onFocus: handleClickInput, onClickSuffix: handleClickInput }), jsx(HiddenTimePickerSC, { format: format, value: timeValue, onChange: handleTimeChange, open: isOpen, onOpenChange: handleOpenChange, getPopupContainer: (triggerNode) => triggerNode.parentElement || document.body })] }), message && (jsx(DivHintWrapperSC, { children: jsx(SpanHintSC, { className: classNames({
70940
70953
  disabled: disabled,
70941
70954
  negative: negative,
70942
70955
  positive: positive,
@@ -73348,9 +73361,6 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
73348
73361
  const computedDisplayValue = useMemo$1(() => {
73349
73362
  if (multi) {
73350
73363
  const count = value.length;
73351
- if (count === 0) {
73352
- return "";
73353
- }
73354
73364
  return multiDisplayText
73355
73365
  ? multiDisplayText(count)
73356
73366
  : `Selected ${count.toString().padStart(2, "0")} option${count !== 1 ? "s" : ""}`;
@@ -73552,6 +73562,7 @@ const PaginationAntdSC = styled(Pagination) `
73552
73562
  `}
73553
73563
  `;
73554
73564
  const DivPaginationContainer = styled.div `
73565
+ width: 100%;
73555
73566
  display: flex;
73556
73567
  align-items: center;
73557
73568
  justify-content: space-between;
@@ -73604,7 +73615,7 @@ const FISPagination = ({ pageSize = LIMIT_DEFAULT, current = 1, total = 0, minim
73604
73615
  }
73605
73616
  return originalElement;
73606
73617
  };
73607
- return (jsxs(DivPaginationContainer, { children: [jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxs(DivPaginationContent, { children: [jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender }), jsx(FISSelect, { style: { width: "92px" }, size: "xs", options: [
73618
+ return (jsxs(DivPaginationContainer, { children: [jsx(SpanTotalSC, { children: showTotal ? showTotal(total, rangeRecords) : defaultShowTotal }), jsxs(DivPaginationContent, { children: [jsx(PaginationAntdSC, { ...mergedProps, "$minimize": Boolean(minimize), showSizeChanger: false, itemRender: itemRender }), jsx(FISSelect, { style: { width: "94px" }, size: "xs", options: [
73608
73619
  {
73609
73620
  groupLabel: "",
73610
73621
  items: (rest.pageSizeOptions || [10, 20, 50, 100]).map((size) => ({