@cmdniels/uikit 1.4.5 → 1.4.6
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,3 @@
|
|
|
1
1
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
2
|
-
declare const
|
|
3
|
-
export default Select;
|
|
2
|
+
export declare const SelectRegistryContext: import("react").Context<Map<unknown, string> | null>;
|
|
3
|
+
export default function Select({ children, ...props }: SelectPrimitive.Root.Props<unknown, boolean | undefined>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,21 @@
|
|
|
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
|
-
export
|
|
15
|
+
import { createContext, useRef } from "react";
|
|
16
|
+
export const SelectRegistryContext = createContext(null);
|
|
17
|
+
export default function Select(_a) {
|
|
18
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
19
|
+
const registryRef = useRef(new Map());
|
|
20
|
+
return (_jsx(SelectRegistryContext.Provider, { value: registryRef.current, children: _jsx(SelectPrimitive.Root, Object.assign({}, props, { itemToStringLabel: (value) => { var _a; return (_a = registryRef.current.get(value)) !== null && _a !== void 0 ? _a : String(value); }, children: children })) }));
|
|
21
|
+
}
|
|
@@ -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;
|
|
@@ -13,8 +13,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
15
15
|
import { IconCheck } from "@tabler/icons-react";
|
|
16
|
+
import { useContext, useEffect } from "react";
|
|
16
17
|
import cn from "../../cn";
|
|
18
|
+
import { SelectRegistryContext } from "./Select";
|
|
17
19
|
export default function SelectItem(_a) {
|
|
18
|
-
var { className, children } = _a, props = __rest(_a, ["className", "children"]);
|
|
19
|
-
|
|
20
|
+
var { className, children, value } = _a, props = __rest(_a, ["className", "children", "value"]);
|
|
21
|
+
const registry = useContext(SelectRegistryContext);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (registry && value !== undefined) {
|
|
24
|
+
const label = typeof children === "string" ? children : String(children);
|
|
25
|
+
registry.set(value, label);
|
|
26
|
+
}
|
|
27
|
+
}, [registry, value, children]);
|
|
28
|
+
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
29
|
}
|