@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 +79 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7748,7 +7748,11 @@ function SelectTrigger({
|
|
|
7748
7748
|
icon: Icon3 = ChevronDown,
|
|
7749
7749
|
...props
|
|
7750
7750
|
}) {
|
|
7751
|
-
|
|
7751
|
+
const content = !props.asChild ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7752
|
+
children,
|
|
7753
|
+
Icon3 && /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(Icon3, { className: "size-4 opacity-50" }) })
|
|
7754
|
+
] }) : children;
|
|
7755
|
+
return /* @__PURE__ */ jsx(
|
|
7752
7756
|
SelectPrimitive.Trigger,
|
|
7753
7757
|
{
|
|
7754
7758
|
"data-slot": "select-trigger",
|
|
@@ -7758,10 +7762,7 @@ function SelectTrigger({
|
|
|
7758
7762
|
className
|
|
7759
7763
|
),
|
|
7760
7764
|
...props,
|
|
7761
|
-
children:
|
|
7762
|
-
children,
|
|
7763
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(Icon3, { className: "size-4 opacity-50" }) })
|
|
7764
|
-
]
|
|
7765
|
+
children: content
|
|
7765
7766
|
}
|
|
7766
7767
|
);
|
|
7767
7768
|
}
|
|
@@ -16386,9 +16387,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16386
16387
|
const filteredItems = React10.useMemo(() => {
|
|
16387
16388
|
if (!query) return items;
|
|
16388
16389
|
const q2 = query.toLowerCase();
|
|
16389
|
-
return items.filter(
|
|
16390
|
-
(it) => it.labelText.toLowerCase().includes(q2)
|
|
16391
|
-
);
|
|
16390
|
+
return items.filter((it) => it.labelText.toLowerCase().includes(q2));
|
|
16392
16391
|
}, [items, query]);
|
|
16393
16392
|
const [visibleCount, setVisibleCount] = React10.useState(
|
|
16394
16393
|
() => virtualScroll ? Math.min(virtualScrollPageSize, filteredItems.length) : filteredItems.length
|
|
@@ -16399,9 +16398,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16399
16398
|
setVisibleCount(filteredItems.length);
|
|
16400
16399
|
return;
|
|
16401
16400
|
}
|
|
16402
|
-
setVisibleCount(
|
|
16403
|
-
Math.min(virtualScrollPageSize, filteredItems.length)
|
|
16404
|
-
);
|
|
16401
|
+
setVisibleCount(Math.min(virtualScrollPageSize, filteredItems.length));
|
|
16405
16402
|
}, [virtualScroll, filteredItems.length, virtualScrollPageSize]);
|
|
16406
16403
|
const handleListScroll = React10.useCallback(() => {
|
|
16407
16404
|
if (!virtualScroll) return;
|
|
@@ -16416,7 +16413,12 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16416
16413
|
return Math.min(next, filteredItems.length);
|
|
16417
16414
|
});
|
|
16418
16415
|
}
|
|
16419
|
-
}, [
|
|
16416
|
+
}, [
|
|
16417
|
+
virtualScroll,
|
|
16418
|
+
filteredItems.length,
|
|
16419
|
+
virtualScrollPageSize,
|
|
16420
|
+
virtualScrollThreshold
|
|
16421
|
+
]);
|
|
16420
16422
|
const renderedItems = React10.useMemo(
|
|
16421
16423
|
() => virtualScroll ? filteredItems.slice(0, visibleCount) : filteredItems,
|
|
16422
16424
|
[filteredItems, visibleCount, virtualScroll]
|
|
@@ -16426,9 +16428,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16426
16428
|
var _a2, _b2, _c;
|
|
16427
16429
|
if (!onValue) return;
|
|
16428
16430
|
const primitive = (_a2 = valueMap.get(rawKey)) != null ? _a2 : rawKey;
|
|
16429
|
-
const item = (_b2 = items.find(
|
|
16430
|
-
(it) => String(it.value) === String(primitive)
|
|
16431
|
-
)) != null ? _b2 : null;
|
|
16431
|
+
const item = (_b2 = items.find((it) => String(it.value) === String(primitive))) != null ? _b2 : null;
|
|
16432
16432
|
const detail = {
|
|
16433
16433
|
source: "variant",
|
|
16434
16434
|
raw: (_c = item == null ? void 0 : item.raw) != null ? _c : primitive,
|
|
@@ -16476,7 +16476,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16476
16476
|
const selectedValue = value;
|
|
16477
16477
|
const renderable = button != null ? button : children;
|
|
16478
16478
|
const content = (() => {
|
|
16479
|
-
var _a2, _b2, _c, _d;
|
|
16479
|
+
var _a2, _b2, _c, _d, _e;
|
|
16480
16480
|
if (typeof renderable === "function") {
|
|
16481
16481
|
return renderable({
|
|
16482
16482
|
open,
|
|
@@ -16490,7 +16490,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16490
16490
|
if (iconNode) {
|
|
16491
16491
|
return /* @__PURE__ */ jsx("span", { className: "inline-flex items-center justify-center", children: iconNode });
|
|
16492
16492
|
}
|
|
16493
|
-
return /* @__PURE__ */ jsx("span", { className: "truncate", children: (_d = selectedItem == null ? void 0 : selectedItem.labelNode) != null ? _d : placeholder != null ?
|
|
16493
|
+
return /* @__PURE__ */ jsx("span", { className: "truncate", children: (_e = (_d = selectedItem == null ? void 0 : selectedItem.labelNode) != null ? _d : placeholder) != null ? _e : "Select..." });
|
|
16494
16494
|
})();
|
|
16495
16495
|
return /* @__PURE__ */ jsx(
|
|
16496
16496
|
"button",
|
|
@@ -16611,75 +16611,70 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16611
16611
|
},
|
|
16612
16612
|
children: [
|
|
16613
16613
|
TriggerBody,
|
|
16614
|
-
/* @__PURE__ */ jsxs(
|
|
16615
|
-
|
|
16616
|
-
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16614
|
+
/* @__PURE__ */ jsxs(SelectContent, { className: cn("min-w-32", contentClassName), children: [
|
|
16615
|
+
searchable && /* @__PURE__ */ jsx("div", { className: "p-1", children: /* @__PURE__ */ jsx(
|
|
16616
|
+
Input,
|
|
16617
|
+
{
|
|
16618
|
+
autoFocus: true,
|
|
16619
|
+
icon: /* @__PURE__ */ jsx(Search, { className: "size-4" }),
|
|
16620
|
+
value: query,
|
|
16621
|
+
onChange: (e4) => setQuery(e4.target.value),
|
|
16622
|
+
placeholder: searchPlaceholder != null ? searchPlaceholder : "Search...",
|
|
16623
|
+
size,
|
|
16624
|
+
density
|
|
16625
|
+
}
|
|
16626
|
+
) }),
|
|
16627
|
+
items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: (_b = emptyLabel != null ? emptyLabel : emptySearchText) != null ? _b : "No options available" }) : (
|
|
16628
|
+
/* CASE 2: have options, but search filters everything out */
|
|
16629
|
+
filteredItems.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : (
|
|
16630
|
+
// CASE 3: normal list, possibly virtually paged
|
|
16631
|
+
/* @__PURE__ */ jsxs(
|
|
16632
|
+
"div",
|
|
16621
16633
|
{
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16634
|
+
ref: listRef,
|
|
16635
|
+
className: "max-h-60 overflow-auto",
|
|
16636
|
+
onScroll: handleListScroll,
|
|
16637
|
+
children: [
|
|
16638
|
+
renderedItems.map((item, index) => {
|
|
16639
|
+
var _a2;
|
|
16640
|
+
const optionNode = /* @__PURE__ */ jsx(
|
|
16641
|
+
SelectItem,
|
|
16642
|
+
{
|
|
16643
|
+
value: String(item.value),
|
|
16644
|
+
disabled: item.disabled,
|
|
16645
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
16646
|
+
item.icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0", children: item.icon }),
|
|
16647
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
16648
|
+
/* @__PURE__ */ jsx("span", { children: item.labelNode }),
|
|
16649
|
+
item.description && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.description })
|
|
16650
|
+
] })
|
|
16651
|
+
] })
|
|
16652
|
+
},
|
|
16653
|
+
item.key
|
|
16654
|
+
);
|
|
16655
|
+
const renderer = (_a2 = item.render) != null ? _a2 : renderOption;
|
|
16656
|
+
if (!renderer) return optionNode;
|
|
16657
|
+
return renderer({
|
|
16658
|
+
item,
|
|
16659
|
+
selected: selectedItem != null && String(selectedItem.value) === String(item.value),
|
|
16660
|
+
index,
|
|
16661
|
+
option: optionNode,
|
|
16662
|
+
click() {
|
|
16663
|
+
if (disabled || readOnly || item.disabled)
|
|
16664
|
+
return;
|
|
16665
|
+
handleChange(String(item.value));
|
|
16666
|
+
setOpen(false);
|
|
16667
|
+
setQuery("");
|
|
16668
|
+
}
|
|
16669
|
+
});
|
|
16670
|
+
}),
|
|
16671
|
+
virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
|
|
16672
|
+
]
|
|
16629
16673
|
}
|
|
16630
|
-
) }),
|
|
16631
|
-
items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: (_b = emptyLabel != null ? emptyLabel : emptySearchText) != null ? _b : "No options available" }) : (
|
|
16632
|
-
/* CASE 2: have options, but search filters everything out */
|
|
16633
|
-
filteredItems.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-xs text-muted-foreground", children: emptySearchText != null ? emptySearchText : "No results found" }) : (
|
|
16634
|
-
// CASE 3: normal list, possibly virtually paged
|
|
16635
|
-
/* @__PURE__ */ jsxs(
|
|
16636
|
-
"div",
|
|
16637
|
-
{
|
|
16638
|
-
ref: listRef,
|
|
16639
|
-
className: "max-h-60 overflow-auto",
|
|
16640
|
-
onScroll: handleListScroll,
|
|
16641
|
-
children: [
|
|
16642
|
-
renderedItems.map((item, index) => {
|
|
16643
|
-
var _a2;
|
|
16644
|
-
const optionNode = /* @__PURE__ */ jsx(
|
|
16645
|
-
SelectItem,
|
|
16646
|
-
{
|
|
16647
|
-
value: String(item.value),
|
|
16648
|
-
disabled: item.disabled,
|
|
16649
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
16650
|
-
item.icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0", children: item.icon }),
|
|
16651
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
16652
|
-
/* @__PURE__ */ jsx("span", { children: item.labelNode }),
|
|
16653
|
-
item.description && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.description })
|
|
16654
|
-
] })
|
|
16655
|
-
] })
|
|
16656
|
-
},
|
|
16657
|
-
item.key
|
|
16658
|
-
);
|
|
16659
|
-
const renderer = (_a2 = item.render) != null ? _a2 : renderOption;
|
|
16660
|
-
if (!renderer) return optionNode;
|
|
16661
|
-
return renderer({
|
|
16662
|
-
item,
|
|
16663
|
-
selected: selectedItem != null && String(selectedItem.value) === String(item.value),
|
|
16664
|
-
index,
|
|
16665
|
-
option: optionNode,
|
|
16666
|
-
click() {
|
|
16667
|
-
if (disabled || readOnly || item.disabled) return;
|
|
16668
|
-
handleChange(String(item.value));
|
|
16669
|
-
setOpen(false);
|
|
16670
|
-
setQuery("");
|
|
16671
|
-
}
|
|
16672
|
-
});
|
|
16673
|
-
}),
|
|
16674
|
-
virtualScroll && renderedItems.length < filteredItems.length && /* @__PURE__ */ jsx("div", { className: "px-2 py-1 text-[10px] text-muted-foreground text-center", children: "Scroll to load more\u2026" })
|
|
16675
|
-
]
|
|
16676
|
-
}
|
|
16677
|
-
)
|
|
16678
|
-
)
|
|
16679
16674
|
)
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
)
|
|
16675
|
+
)
|
|
16676
|
+
)
|
|
16677
|
+
] })
|
|
16683
16678
|
]
|
|
16684
16679
|
}
|
|
16685
16680
|
);
|
|
@@ -16738,9 +16733,7 @@ var ShadcnSelectVariant = React10.forwardRef(function ShadcnSelectVariant2(props
|
|
|
16738
16733
|
/* @__PURE__ */ jsx(
|
|
16739
16734
|
"div",
|
|
16740
16735
|
{
|
|
16741
|
-
className: cn(
|
|
16742
|
-
"flex-1 min-w-0 flex items-stretch"
|
|
16743
|
-
),
|
|
16736
|
+
className: cn("flex-1 min-w-0 flex items-stretch"),
|
|
16744
16737
|
"data-slot": "select-region",
|
|
16745
16738
|
children: SelectWithTrigger
|
|
16746
16739
|
}
|