@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.mjs CHANGED
@@ -16428,6 +16428,8 @@ var ComboboxInner = ({
16428
16428
  onOpenChange,
16429
16429
  onClear,
16430
16430
  virtual = true,
16431
+ isLoading,
16432
+ loadingContent,
16431
16433
  ...props
16432
16434
  }, ref) => {
16433
16435
  const { getLabelField, getValueField } = useFieldNames_default({ fieldNames });
@@ -16446,6 +16448,9 @@ var ComboboxInner = ({
16446
16448
  });
16447
16449
  }, [getValueField, options, selectedValue]);
16448
16450
  const renderValue = React.useMemo(() => {
16451
+ if (isLoading) {
16452
+ return loadingContent ?? "Loading...";
16453
+ }
16449
16454
  if (!selectedValue) return placeholder2;
16450
16455
  if (currentSelectedOption) {
16451
16456
  return getLabelField(currentSelectedOption);
@@ -16454,7 +16459,15 @@ var ComboboxInner = ({
16454
16459
  return selectedValue;
16455
16460
  }
16456
16461
  return null;
16457
- }, [currentSelectedOption, getLabelField, placeholder2, selectedValue, showValueWhenNoMatch]);
16462
+ }, [
16463
+ currentSelectedOption,
16464
+ getLabelField,
16465
+ placeholder2,
16466
+ selectedValue,
16467
+ showValueWhenNoMatch,
16468
+ isLoading,
16469
+ loadingContent
16470
+ ]);
16458
16471
  const handleSelect = React.useCallback(
16459
16472
  (selected, option) => {
16460
16473
  setSelectedValue(selected);
@@ -16470,13 +16483,13 @@ var ComboboxInner = ({
16470
16483
  );
16471
16484
  const handleOpenPopover = React.useCallback(
16472
16485
  (isOpen) => {
16473
- if (disabled) return;
16486
+ if (disabled || isLoading) return;
16474
16487
  setOpenPopover(isOpen);
16475
16488
  if (typeof onOpenChange === "function") {
16476
16489
  onOpenChange(isOpen);
16477
16490
  }
16478
16491
  },
16479
- [disabled, onOpenChange, setOpenPopover]
16492
+ [disabled, isLoading, onOpenChange, setOpenPopover]
16480
16493
  );
16481
16494
  const handleClear = React.useCallback(
16482
16495
  (event) => {
@@ -16507,7 +16520,8 @@ var ComboboxInner = ({
16507
16520
  className
16508
16521
  ),
16509
16522
  "data-state": openPopover ? "open" : "closed",
16510
- disabled,
16523
+ "data-loading": isLoading,
16524
+ disabled: disabled || isLoading,
16511
16525
  onFocus,
16512
16526
  onBlur,
16513
16527
  "data-testid": `combobox-trigger-${name}`,
@@ -16516,14 +16530,14 @@ var ComboboxInner = ({
16516
16530
  /* @__PURE__ */ jsx(
16517
16531
  truncated_default,
16518
16532
  {
16519
- className: cn(!selectedValue && "text-sus-gray-1"),
16533
+ className: cn(!selectedValue && !isLoading && "text-sus-gray-1"),
16520
16534
  tooltipProps: { disabled: true },
16521
16535
  children: renderValue
16522
16536
  }
16523
16537
  ),
16524
16538
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
16525
- /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 opacity-50" }),
16526
- showClear && selectedValue && /* @__PURE__ */ jsx(
16539
+ isLoading ? /* @__PURE__ */ jsx(Spinner, { size: "sm", className: "size-4" }) : /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 opacity-50" }),
16540
+ showClear && selectedValue && !isLoading && /* @__PURE__ */ jsx(
16527
16541
  "span",
16528
16542
  {
16529
16543
  role: "button",