fis-component 0.0.73 → 0.0.76

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.
@@ -15,3 +15,4 @@ export declare const Disabled: import("@storybook/core/csf").AnnotatedStoryFn<im
15
15
  export declare const NumberType: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, NumberSelectStoryProps>;
16
16
  export declare const CustomMaxHeight: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
17
17
  export declare const TextEllipsis: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
18
+ export declare const PlaceholderDemo: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, SingleSelectStoryProps>;
@@ -9,10 +9,11 @@ export interface SelectOption<T = string | number> {
9
9
  value: T;
10
10
  }[];
11
11
  }
12
- type BaseSelectProps<T extends string | number> = 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" | "placeholder"> & Omit<SelectFieldProps, "value" | "onChange"> & {
13
13
  options: SelectOption<T>[];
14
14
  message?: string;
15
15
  disabled?: boolean;
16
+ placeholder?: string;
16
17
  placeholderSearch?: string;
17
18
  positive?: boolean;
18
19
  multiDisplayText?: (count: number) => string;
package/dist/esm/index.js CHANGED
@@ -70536,9 +70536,12 @@ ${({ $disabled }) => {
70536
70536
  `;
70537
70537
  const SpanLabel$1 = styled.span `
70538
70538
  margin: 0;
70539
- display: flex;
70540
- align-items: center;
70541
- justify-content: center;
70539
+ overflow: hidden;
70540
+ text-overflow: ellipsis;
70541
+ white-space: nowrap;
70542
+ // display: flex;
70543
+ // align-items: center;
70544
+ // justify-content: center;
70542
70545
 
70543
70546
  &.no-padding {
70544
70547
  padding-right: 0;
@@ -70701,6 +70704,7 @@ const MultipleValue = ({ options, onRemove }) => {
70701
70704
  const [hiddenTagCount, setHiddenTagCount] = useState(0);
70702
70705
  const theme = useTheme$1();
70703
70706
  const calculateVisibleTags = useCallback(() => {
70707
+ // Đảm bảo containerRef đã được khởi tạo và có phần tử
70704
70708
  if (!containerRef.current || options.length === 0)
70705
70709
  return;
70706
70710
  const container = containerRef.current;
@@ -70712,7 +70716,7 @@ const MultipleValue = ({ options, onRemove }) => {
70712
70716
  for (let i = 0; i < options.length; i++) {
70713
70717
  const tagElement = tagRefs.current[i];
70714
70718
  if (!tagElement)
70715
- continue;
70719
+ continue; // Skip if tag ref is null
70716
70720
  const tagWidth = tagElement.offsetWidth;
70717
70721
  if (firstTotalWidth + tagWidth + gap <= containerClientWidth) {
70718
70722
  newFirstTag.push(options[i]);
@@ -70762,14 +70766,39 @@ const MultipleValue = ({ options, onRemove }) => {
70762
70766
  const isVisible = useCallback((option) => firstTag.some((t) => t.value === option.value) ||
70763
70767
  secondTag.some((t) => t.value === option.value), [firstTag, secondTag]);
70764
70768
  useLayoutEffect$2(() => {
70769
+ // Tạo một flag để theo dõi trạng thái mounted
70770
+ let isMounted = true;
70771
+ // Sử dụng RAF để đảm bảo DOM đã render
70772
+ let rafId = requestAnimationFrame(() => {
70773
+ // Chỉ tính toán nếu component vẫn mounted
70774
+ if (isMounted && containerRef.current) {
70775
+ calculateVisibleTags();
70776
+ }
70777
+ });
70778
+ // Tạo ResizeObserver để theo dõi khi container được render và có kích thước
70779
+ const resizeObserver = new ResizeObserver(() => {
70780
+ if (isMounted && containerRef.current) {
70781
+ calculateVisibleTags();
70782
+ }
70783
+ });
70784
+ // Observe container nếu nó đã tồn tại
70785
+ if (containerRef.current) {
70786
+ resizeObserver.observe(containerRef.current);
70787
+ }
70765
70788
  const handleResize = () => {
70766
- calculateVisibleTags();
70789
+ if (isMounted) {
70790
+ calculateVisibleTags();
70791
+ }
70767
70792
  };
70768
- calculateVisibleTags();
70769
70793
  window.addEventListener("resize", handleResize);
70770
- return () => window.removeEventListener("resize", handleResize);
70794
+ return () => {
70795
+ isMounted = false;
70796
+ cancelAnimationFrame(rafId);
70797
+ resizeObserver.disconnect();
70798
+ window.removeEventListener("resize", handleResize);
70799
+ };
70771
70800
  }, [calculateVisibleTags, options]);
70772
- return (jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }, `${option.value}-${index}`) }))), hiddenTagCount > 0 && (jsx(DivTagSC, { "$isVisible": true, children: jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
70801
+ return (jsxs(DivChipButtonWrapperSC, { ref: containerRef, children: [options.map((option, index) => (jsx(DivChipButtonSC, { "$isVisible": isVisible(option), children: jsx(FISChipButton, { ref: (el) => (tagRefs.current[index] = el), size: "xs", label: option.label, closeable: true, onClickClose: () => handleRemove(option) }) }, `${option.value}-${index}`))), hiddenTagCount > 0 && (jsx(DivTagSC, { "$isVisible": true, children: jsx(FISChipButton, { label: `+${hiddenTagCount}`, size: "xs" }) }))] }));
70773
70802
  };
70774
70803
 
70775
70804
  const FISCombobox = forwardRef(({ className, options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, noResultText = "Không tìm thấy kết quả", maxHeight, ...restProps }, ref) => {
@@ -73391,7 +73420,7 @@ function isMenuSize(value) {
73391
73420
  return value === "sm" || value === "md";
73392
73421
  }
73393
73422
 
73394
- const FISSelect = forwardRef(({ className, style, size = "md", options, value, disabled = false, textLabel = "", iconLabel, required, negative, message, positive, multi, placeholderSearch, loading, onChange, renderOption, onClickIconLabel, displayValue, multiDisplayText, searchValue, onSearchChange, portal, maxHeight, ...restProps }, ref) => {
73423
+ 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, ...restProps }, ref) => {
73395
73424
  const [isOpen, setIsOpen] = useState(false);
73396
73425
  const [referenceElement, setReferenceElement] = useState(null);
73397
73426
  const [popperElement, setPopperElement] = useState(null);
@@ -73530,7 +73559,7 @@ const FISSelect = forwardRef(({ className, style, size = "md", options, value, d
73530
73559
  document.addEventListener("mousedown", handleClickOutside);
73531
73560
  return () => document.removeEventListener("mousedown", handleClickOutside);
73532
73561
  }, [referenceElement, popperElement]);
73533
- return (jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsx(FISSelectItem, { ...restProps, ref: ref, size: size, iconSuffix: isOpen ? jsx(ArrowUpIcon, {}) : jsx(ArrowDownIcon, {}), value: computedDisplayValue(), disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsx(SelectedTagsWrapper, { children: jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsx(Portal, { portal: portal, children: jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
73562
+ return (jsxs(DivWrapperSC$1, { className: className, style: style, children: [(textLabel || iconLabel) && (jsx(FISInputLabel, { textLabel: textLabel, required: required, iconLabel: iconLabel, onClickIconLabel: onClickIconLabel })), jsx(DivInputWrapperSC, { ref: setReferenceElement, onClick: handleToggle, "$hasValue": !!value, children: jsx(FISSelectItem, { ...restProps, ref: ref, size: size, placeholder: placeholder, iconSuffix: isOpen ? jsx(ArrowUpIcon, {}) : jsx(ArrowDownIcon, {}), value: computedDisplayValue(), disabled: disabled, activeDropdown: isOpen, negative: negative }) }), message && (jsx(SpanHintSC$3, { className: classNames({ disabled, negative, positive }), children: message })), multi && value.length > 0 && (jsx(SelectedTagsWrapper, { children: jsx(MultipleValue, { options: selectedItems, onRemove: handleOptionRemove }) })), isOpen && (jsx(Portal, { portal: portal, children: jsx(DivDropdownMenuSC, { ref: setPopperElement, style: {
73534
73563
  ...styles.popper,
73535
73564
  width: referenceElement?.offsetWidth,
73536
73565
  zIndex: 9999,