@sustaina/shared-ui 1.51.0 → 1.51.1

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/index.d.mts CHANGED
@@ -1805,6 +1805,8 @@ type ComboboxProps<TData extends OptionData> = React$1.AriaAttributes & Omit<Vir
1805
1805
  onOpenChange?: (isOpen: boolean) => void;
1806
1806
  showValueWhenNoMatch?: boolean;
1807
1807
  virtual?: boolean;
1808
+ isLoading?: boolean;
1809
+ loadingContent?: React$1.ReactNode;
1808
1810
  };
1809
1811
  declare const Combobox: <TData extends OptionData>(props: ComboboxProps<TData> & React$1.RefAttributes<HTMLButtonElement>) => React$1.ReactElement | null;
1810
1812
 
package/dist/index.d.ts CHANGED
@@ -1805,6 +1805,8 @@ type ComboboxProps<TData extends OptionData> = React$1.AriaAttributes & Omit<Vir
1805
1805
  onOpenChange?: (isOpen: boolean) => void;
1806
1806
  showValueWhenNoMatch?: boolean;
1807
1807
  virtual?: boolean;
1808
+ isLoading?: boolean;
1809
+ loadingContent?: React$1.ReactNode;
1808
1810
  };
1809
1811
  declare const Combobox: <TData extends OptionData>(props: ComboboxProps<TData> & React$1.RefAttributes<HTMLButtonElement>) => React$1.ReactElement | null;
1810
1812
 
package/dist/index.js CHANGED
@@ -16470,6 +16470,8 @@ var ComboboxInner = ({
16470
16470
  onOpenChange,
16471
16471
  onClear,
16472
16472
  virtual = true,
16473
+ isLoading,
16474
+ loadingContent,
16473
16475
  ...props
16474
16476
  }, ref) => {
16475
16477
  const { getLabelField, getValueField } = useFieldNames_default({ fieldNames });
@@ -16488,6 +16490,9 @@ var ComboboxInner = ({
16488
16490
  });
16489
16491
  }, [getValueField, options, selectedValue]);
16490
16492
  const renderValue = React__namespace.useMemo(() => {
16493
+ if (isLoading) {
16494
+ return loadingContent ?? "Loading...";
16495
+ }
16491
16496
  if (!selectedValue) return placeholder2;
16492
16497
  if (currentSelectedOption) {
16493
16498
  return getLabelField(currentSelectedOption);
@@ -16496,7 +16501,15 @@ var ComboboxInner = ({
16496
16501
  return selectedValue;
16497
16502
  }
16498
16503
  return null;
16499
- }, [currentSelectedOption, getLabelField, placeholder2, selectedValue, showValueWhenNoMatch]);
16504
+ }, [
16505
+ currentSelectedOption,
16506
+ getLabelField,
16507
+ placeholder2,
16508
+ selectedValue,
16509
+ showValueWhenNoMatch,
16510
+ isLoading,
16511
+ loadingContent
16512
+ ]);
16500
16513
  const handleSelect = React__namespace.useCallback(
16501
16514
  (selected, option) => {
16502
16515
  setSelectedValue(selected);
@@ -16512,13 +16525,13 @@ var ComboboxInner = ({
16512
16525
  );
16513
16526
  const handleOpenPopover = React__namespace.useCallback(
16514
16527
  (isOpen) => {
16515
- if (disabled) return;
16528
+ if (disabled || isLoading) return;
16516
16529
  setOpenPopover(isOpen);
16517
16530
  if (typeof onOpenChange === "function") {
16518
16531
  onOpenChange(isOpen);
16519
16532
  }
16520
16533
  },
16521
- [disabled, onOpenChange, setOpenPopover]
16534
+ [disabled, isLoading, onOpenChange, setOpenPopover]
16522
16535
  );
16523
16536
  const handleClear = React__namespace.useCallback(
16524
16537
  (event) => {
@@ -16549,7 +16562,8 @@ var ComboboxInner = ({
16549
16562
  className
16550
16563
  ),
16551
16564
  "data-state": openPopover ? "open" : "closed",
16552
- disabled,
16565
+ "data-loading": isLoading,
16566
+ disabled: disabled || isLoading,
16553
16567
  onFocus,
16554
16568
  onBlur,
16555
16569
  "data-testid": `combobox-trigger-${name}`,
@@ -16558,14 +16572,14 @@ var ComboboxInner = ({
16558
16572
  /* @__PURE__ */ jsxRuntime.jsx(
16559
16573
  truncated_default,
16560
16574
  {
16561
- className: cn(!selectedValue && "text-sus-gray-1"),
16575
+ className: cn(!selectedValue && !isLoading && "text-sus-gray-1"),
16562
16576
  tooltipProps: { disabled: true },
16563
16577
  children: renderValue
16564
16578
  }
16565
16579
  ),
16566
16580
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
16567
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4 opacity-50" }),
16568
- showClear && selectedValue && /* @__PURE__ */ jsxRuntime.jsx(
16581
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: "sm", className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4 opacity-50" }),
16582
+ showClear && selectedValue && !isLoading && /* @__PURE__ */ jsxRuntime.jsx(
16569
16583
  "span",
16570
16584
  {
16571
16585
  role: "button",