@timeax/form-palette 0.0.28 → 0.0.29

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.js CHANGED
@@ -7785,7 +7785,11 @@ function SelectTrigger({
7785
7785
  icon: Icon3 = ChevronDown,
7786
7786
  ...props
7787
7787
  }) {
7788
- return /* @__PURE__ */ jsxRuntime.jsxs(
7788
+ const content = !props.asChild ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7789
+ children,
7790
+ Icon3 && /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Icon3, { className: "size-4 opacity-50" }) })
7791
+ ] }) : children;
7792
+ return /* @__PURE__ */ jsxRuntime.jsx(
7789
7793
  SelectPrimitive__namespace.Trigger,
7790
7794
  {
7791
7795
  "data-slot": "select-trigger",
@@ -7795,10 +7799,7 @@ function SelectTrigger({
7795
7799
  className
7796
7800
  ),
7797
7801
  ...props,
7798
- children: [
7799
- children,
7800
- /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Icon, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Icon3, { className: "size-4 opacity-50" }) })
7801
- ]
7802
+ children: content
7802
7803
  }
7803
7804
  );
7804
7805
  }
@@ -16423,9 +16424,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16423
16424
  const filteredItems = React10__namespace.useMemo(() => {
16424
16425
  if (!query) return items;
16425
16426
  const q2 = query.toLowerCase();
16426
- return items.filter(
16427
- (it) => it.labelText.toLowerCase().includes(q2)
16428
- );
16427
+ return items.filter((it) => it.labelText.toLowerCase().includes(q2));
16429
16428
  }, [items, query]);
16430
16429
  const [visibleCount, setVisibleCount] = React10__namespace.useState(
16431
16430
  () => virtualScroll ? Math.min(virtualScrollPageSize, filteredItems.length) : filteredItems.length
@@ -16436,9 +16435,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16436
16435
  setVisibleCount(filteredItems.length);
16437
16436
  return;
16438
16437
  }
16439
- setVisibleCount(
16440
- Math.min(virtualScrollPageSize, filteredItems.length)
16441
- );
16438
+ setVisibleCount(Math.min(virtualScrollPageSize, filteredItems.length));
16442
16439
  }, [virtualScroll, filteredItems.length, virtualScrollPageSize]);
16443
16440
  const handleListScroll = React10__namespace.useCallback(() => {
16444
16441
  if (!virtualScroll) return;
@@ -16453,7 +16450,12 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16453
16450
  return Math.min(next, filteredItems.length);
16454
16451
  });
16455
16452
  }
16456
- }, [virtualScroll, filteredItems.length, virtualScrollPageSize, virtualScrollThreshold]);
16453
+ }, [
16454
+ virtualScroll,
16455
+ filteredItems.length,
16456
+ virtualScrollPageSize,
16457
+ virtualScrollThreshold
16458
+ ]);
16457
16459
  const renderedItems = React10__namespace.useMemo(
16458
16460
  () => virtualScroll ? filteredItems.slice(0, visibleCount) : filteredItems,
16459
16461
  [filteredItems, visibleCount, virtualScroll]
@@ -16463,9 +16465,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16463
16465
  var _a2, _b2, _c;
16464
16466
  if (!onValue) return;
16465
16467
  const primitive = (_a2 = valueMap.get(rawKey)) != null ? _a2 : rawKey;
16466
- const item = (_b2 = items.find(
16467
- (it) => String(it.value) === String(primitive)
16468
- )) != null ? _b2 : null;
16468
+ const item = (_b2 = items.find((it) => String(it.value) === String(primitive))) != null ? _b2 : null;
16469
16469
  const detail = {
16470
16470
  source: "variant",
16471
16471
  raw: (_c = item == null ? void 0 : item.raw) != null ? _c : primitive,
@@ -16513,7 +16513,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16513
16513
  const selectedValue = value;
16514
16514
  const renderable = button != null ? button : children;
16515
16515
  const content = (() => {
16516
- var _a2, _b2, _c, _d;
16516
+ var _a2, _b2, _c, _d, _e;
16517
16517
  if (typeof renderable === "function") {
16518
16518
  return renderable({
16519
16519
  open,
@@ -16527,7 +16527,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16527
16527
  if (iconNode) {
16528
16528
  return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex items-center justify-center", children: iconNode });
16529
16529
  }
16530
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_d = selectedItem == null ? void 0 : selectedItem.labelNode) != null ? _d : placeholder != null ? placeholder : "Select..." });
16530
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: (_e = (_d = selectedItem == null ? void 0 : selectedItem.labelNode) != null ? _d : placeholder) != null ? _e : "Select..." });
16531
16531
  })();
16532
16532
  return /* @__PURE__ */ jsxRuntime.jsx(
16533
16533
  "button",
@@ -16648,75 +16648,70 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16648
16648
  },
16649
16649
  children: [
16650
16650
  TriggerBody,
16651
- /* @__PURE__ */ jsxRuntime.jsxs(
16652
- SelectContent,
16653
- {
16654
- className: cn("min-w-32", contentClassName),
16655
- children: [
16656
- searchable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
16657
- Input,
16651
+ /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { className: cn("min-w-32", contentClassName), children: [
16652
+ searchable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-1", children: /* @__PURE__ */ jsxRuntime.jsx(
16653
+ Input,
16654
+ {
16655
+ autoFocus: true,
16656
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Search, { className: "size-4" }),
16657
+ value: query,
16658
+ onChange: (e4) => setQuery(e4.target.value),
16659
+ placeholder: searchPlaceholder != null ? searchPlaceholder : "Search...",
16660
+ size,
16661
+ density
16662
+ }
16663
+ ) }),
16664
+ items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: (_b = emptyLabel != null ? emptyLabel : emptySearchText) != null ? _b : "No options available" }) : (
16665
+ /* CASE 2: have options, but search filters everything out */
16666
+ filteredItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : (
16667
+ // CASE 3: normal list, possibly virtually paged
16668
+ /* @__PURE__ */ jsxRuntime.jsxs(
16669
+ "div",
16658
16670
  {
16659
- autoFocus: true,
16660
- icon: /* @__PURE__ */ jsxRuntime.jsx(Search, { className: "size-4" }),
16661
- value: query,
16662
- onChange: (e4) => setQuery(e4.target.value),
16663
- placeholder: searchPlaceholder != null ? searchPlaceholder : "Search...",
16664
- size,
16665
- density
16671
+ ref: listRef,
16672
+ className: "max-h-60 overflow-auto",
16673
+ onScroll: handleListScroll,
16674
+ children: [
16675
+ renderedItems.map((item, index) => {
16676
+ var _a2;
16677
+ const optionNode = /* @__PURE__ */ jsxRuntime.jsx(
16678
+ SelectItem,
16679
+ {
16680
+ value: String(item.value),
16681
+ disabled: item.disabled,
16682
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
16683
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-0.5 shrink-0", children: item.icon }),
16684
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
16685
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.labelNode }),
16686
+ item.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: item.description })
16687
+ ] })
16688
+ ] })
16689
+ },
16690
+ item.key
16691
+ );
16692
+ const renderer = (_a2 = item.render) != null ? _a2 : renderOption;
16693
+ if (!renderer) return optionNode;
16694
+ return renderer({
16695
+ item,
16696
+ selected: selectedItem != null && String(selectedItem.value) === String(item.value),
16697
+ index,
16698
+ option: optionNode,
16699
+ click() {
16700
+ if (disabled || readOnly || item.disabled)
16701
+ return;
16702
+ handleChange(String(item.value));
16703
+ setOpen(false);
16704
+ setQuery("");
16705
+ }
16706
+ });
16707
+ }),
16708
+ virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
16709
+ ]
16666
16710
  }
16667
- ) }),
16668
- items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: (_b = emptyLabel != null ? emptyLabel : emptySearchText) != null ? _b : "No options available" }) : (
16669
- /* CASE 2: have options, but search filters everything out */
16670
- filteredItems.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : (
16671
- // CASE 3: normal list, possibly virtually paged
16672
- /* @__PURE__ */ jsxRuntime.jsxs(
16673
- "div",
16674
- {
16675
- ref: listRef,
16676
- className: "max-h-60 overflow-auto",
16677
- onScroll: handleListScroll,
16678
- children: [
16679
- renderedItems.map((item, index) => {
16680
- var _a2;
16681
- const optionNode = /* @__PURE__ */ jsxRuntime.jsx(
16682
- SelectItem,
16683
- {
16684
- value: String(item.value),
16685
- disabled: item.disabled,
16686
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
16687
- item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mt-0.5 shrink-0", children: item.icon }),
16688
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
16689
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.labelNode }),
16690
- item.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: item.description })
16691
- ] })
16692
- ] })
16693
- },
16694
- item.key
16695
- );
16696
- const renderer = (_a2 = item.render) != null ? _a2 : renderOption;
16697
- if (!renderer) return optionNode;
16698
- return renderer({
16699
- item,
16700
- selected: selectedItem != null && String(selectedItem.value) === String(item.value),
16701
- index,
16702
- option: optionNode,
16703
- click() {
16704
- if (disabled || readOnly || item.disabled) return;
16705
- handleChange(String(item.value));
16706
- setOpen(false);
16707
- setQuery("");
16708
- }
16709
- });
16710
- }),
16711
- virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
16712
- ]
16713
- }
16714
- )
16715
- )
16716
16711
  )
16717
- ]
16718
- }
16719
- )
16712
+ )
16713
+ )
16714
+ ] })
16720
16715
  ]
16721
16716
  }
16722
16717
  );
@@ -16775,9 +16770,7 @@ var ShadcnSelectVariant = React10__namespace.forwardRef(function ShadcnSelectVar
16775
16770
  /* @__PURE__ */ jsxRuntime.jsx(
16776
16771
  "div",
16777
16772
  {
16778
- className: cn(
16779
- "flex-1 min-w-0 flex items-stretch"
16780
- ),
16773
+ className: cn("flex-1 min-w-0 flex items-stretch"),
16781
16774
  "data-slot": "select-region",
16782
16775
  children: SelectWithTrigger
16783
16776
  }