@cmdniels/uikit 1.4.5 → 1.4.7
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.
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
2
|
-
|
|
3
|
-
export default Select;
|
|
2
|
+
export default function Select({ children, items, ...props }: SelectPrimitive.Root.Props<unknown, boolean | undefined>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
14
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
3
|
-
|
|
4
|
-
|
|
15
|
+
import { useMemo, Children, isValidElement } from "react";
|
|
16
|
+
function extractItemsFromChildren(children, items) {
|
|
17
|
+
Children.forEach(children, (child) => {
|
|
18
|
+
if (isValidElement(child)) {
|
|
19
|
+
const props = child.props;
|
|
20
|
+
if (props.value !== undefined && props.children) {
|
|
21
|
+
items.push({ value: props.value, label: props.children });
|
|
22
|
+
}
|
|
23
|
+
if (props.children) {
|
|
24
|
+
extractItemsFromChildren(props.children, items);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export default function Select(_a) {
|
|
30
|
+
var { children, items } = _a, props = __rest(_a, ["children", "items"]);
|
|
31
|
+
const autoItems = useMemo(() => {
|
|
32
|
+
if (items) {
|
|
33
|
+
return items;
|
|
34
|
+
}
|
|
35
|
+
;
|
|
36
|
+
const itemsArray = [];
|
|
37
|
+
extractItemsFromChildren(children, itemsArray);
|
|
38
|
+
return itemsArray;
|
|
39
|
+
}, [children, items]);
|
|
40
|
+
return (_jsx(SelectPrimitive.Root, Object.assign({}, props, { items: autoItems, children: children })));
|
|
41
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
2
|
-
export default function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function SelectItem({ className, children, value, ...props }: SelectPrimitive.Item.Props): import("react/jsx-runtime").JSX.Element;
|
|
@@ -15,6 +15,6 @@ import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
|
15
15
|
import { IconCheck } from "@tabler/icons-react";
|
|
16
16
|
import cn from "../../cn";
|
|
17
17
|
export default function SelectItem(_a) {
|
|
18
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
19
|
-
return (_jsxs(SelectPrimitive.Item, Object.assign({ "data-slot": "select-item", className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className) }, props, { children: [_jsx(SelectPrimitive.ItemText, { className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap", children: children }), _jsx(SelectPrimitive.ItemIndicator, { render: _jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }), children: _jsx(IconCheck, { className: "pointer-events-none" }) })] })));
|
|
18
|
+
var { className, children, value } = _a, props = __rest(_a, ["className", "children", "value"]);
|
|
19
|
+
return (_jsxs(SelectPrimitive.Item, Object.assign({ "data-slot": "select-item", className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className), value: value }, props, { children: [_jsx(SelectPrimitive.ItemText, { className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap", children: children }), _jsx(SelectPrimitive.ItemIndicator, { render: _jsx("span", { className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center" }), children: _jsx(IconCheck, { className: "pointer-events-none" }) })] })));
|
|
20
20
|
}
|