@vhyxui/react 0.1.0-alpha.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/Alert-BJ1O0bnK.cjs +1 -0
- package/dist/Alert-am3ANPTH.js +99 -0
- package/dist/Badge-Fuc7l-1E.js +38 -0
- package/dist/Badge-RM7n86Rq.cjs +1 -0
- package/dist/Breadcrumb-Db7ASomJ.js +90 -0
- package/dist/Breadcrumb-StitgXXx.cjs +1 -0
- package/dist/Button-B32xz0b5.js +58 -0
- package/dist/Button-CfYG4zkG.cjs +1 -0
- package/dist/Card-D7ZNeWtE.js +75 -0
- package/dist/Card-d5xrWgQS.cjs +1 -0
- package/dist/Checkbox-DWl91ci_.js +92 -0
- package/dist/Checkbox-DvkT6QP9.cjs +1 -0
- package/dist/Dialog-CtYu14zl.js +245 -0
- package/dist/Dialog-gPT4noD8.cjs +1 -0
- package/dist/Drawer-BFJxsPG1.js +246 -0
- package/dist/Drawer-BygSIQQn.cjs +1 -0
- package/dist/Field-Bv07PL2M.js +120 -0
- package/dist/Field-D6FSsUGj.cjs +1 -0
- package/dist/Input-Dqt5q33I.js +151 -0
- package/dist/Input-OFmZxiHe.cjs +1 -0
- package/dist/Pagination-C1h7OTgM.js +128 -0
- package/dist/Pagination-CmmcBPNz.cjs +1 -0
- package/dist/Popover-BPFkS4xn.cjs +1 -0
- package/dist/Popover-MxUovsIt.js +194 -0
- package/dist/Progress-DWLr6Bq2.js +75 -0
- package/dist/Progress-FO-4WX0i.cjs +1 -0
- package/dist/RadioItem-BfkTHBxQ.cjs +1 -0
- package/dist/RadioItem-CzHSS_qK.js +141 -0
- package/dist/Select-C9yB2B8M.cjs +1 -0
- package/dist/Select-DjeJOdb7.js +327 -0
- package/dist/Separator-C5lPGzes.cjs +1 -0
- package/dist/Separator-DQT58t90.js +52 -0
- package/dist/Spinner-Cd5tcOLS.js +61 -0
- package/dist/Spinner-DSHhLV-r.cjs +1 -0
- package/dist/Switch-BU_Tcttb.cjs +1 -0
- package/dist/Switch-DOAZfSV0.js +64 -0
- package/dist/Tabs-BTfm4LbV.js +220 -0
- package/dist/Tabs-DuU02-UD.cjs +1 -0
- package/dist/Textarea-CLrctxHU.js +104 -0
- package/dist/Textarea-H6evM8L4.cjs +1 -0
- package/dist/Toast-0acAjZTB.js +167 -0
- package/dist/Toast-ndaxbpcV.cjs +1 -0
- package/dist/Tooltip-BAmErB_g.js +107 -0
- package/dist/Tooltip-CCd6VRvZ.cjs +1 -0
- package/dist/VhyxUIProvider-C9NxI-tU.cjs +1 -0
- package/dist/VhyxUIProvider-D1vNoiIk.js +34 -0
- package/dist/alert.cjs +1 -0
- package/dist/alert.d.ts +25 -0
- package/dist/alert.js +4 -0
- package/dist/badge.cjs +1 -0
- package/dist/badge.d.ts +31 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb.cjs +1 -0
- package/dist/breadcrumb.d.ts +81 -0
- package/dist/breadcrumb.js +4 -0
- package/dist/button.cjs +1 -0
- package/dist/button.d.ts +36 -0
- package/dist/button.js +4 -0
- package/dist/card.cjs +1 -0
- package/dist/card.d.ts +72 -0
- package/dist/card.js +4 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.d.ts +33 -0
- package/dist/checkbox.js +4 -0
- package/dist/dialog.cjs +1 -0
- package/dist/dialog.d.ts +112 -0
- package/dist/dialog.js +4 -0
- package/dist/drawer.cjs +1 -0
- package/dist/drawer.d.ts +110 -0
- package/dist/drawer.js +4 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +116 -0
- package/dist/form.js +6 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1184 -0
- package/dist/index.js +83 -0
- package/dist/input.cjs +1 -0
- package/dist/input.d.ts +31 -0
- package/dist/input.js +4 -0
- package/dist/jsx-runtime-BRMkMA8J.cjs +22 -0
- package/dist/jsx-runtime-CL69jGNW.js +279 -0
- package/dist/pagination.cjs +1 -0
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.js +4 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.d.ts +72 -0
- package/dist/popover.js +4 -0
- package/dist/progress.cjs +1 -0
- package/dist/progress.d.ts +35 -0
- package/dist/progress.js +4 -0
- package/dist/radio.cjs +1 -0
- package/dist/radio.d.ts +47 -0
- package/dist/radio.js +5 -0
- package/dist/select.cjs +1 -0
- package/dist/select.d.ts +97 -0
- package/dist/select.js +4 -0
- package/dist/separator.cjs +1 -0
- package/dist/separator.d.ts +21 -0
- package/dist/separator.js +4 -0
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +24 -0
- package/dist/spinner.js +4 -0
- package/dist/style.css +1 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.d.ts +28 -0
- package/dist/switch.js +4 -0
- package/dist/tabs.cjs +1 -0
- package/dist/tabs.d.ts +59 -0
- package/dist/tabs.js +4 -0
- package/dist/test-utils.cjs +1 -0
- package/dist/test-utils.d.ts +5 -0
- package/dist/test-utils.js +12 -0
- package/dist/textarea.cjs +1 -0
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.js +4 -0
- package/dist/toast.cjs +1 -0
- package/dist/toast.d.ts +28 -0
- package/dist/toast.js +5 -0
- package/dist/tooltip.cjs +1 -0
- package/dist/tooltip.d.ts +32 -0
- package/dist/tooltip.js +4 -0
- package/dist/useId-BGRmH6iF.js +8 -0
- package/dist/useId-D2AEOm2G.cjs +1 -0
- package/package.json +170 -0
- package/style.css +1 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { j as m } from "./jsx-runtime-CL69jGNW.js";
|
|
2
|
+
import z, { useState as M, useRef as A, useCallback as x, useMemo as U, useContext as H, createContext as Q, useEffect as T } from "react";
|
|
3
|
+
import { radioContract as C } from "@vhyxui/core";
|
|
4
|
+
import { withAgentContract as X } from "@vhyxseal/react";
|
|
5
|
+
import { u as Y } from "./useId-BGRmH6iF.js";
|
|
6
|
+
const Z = "_group_16juf_3", $ = "_item_16juf_17", R = {
|
|
7
|
+
group: Z,
|
|
8
|
+
item: $,
|
|
9
|
+
"radio-indicator": "_radio-indicator_16juf_40",
|
|
10
|
+
"radio-dot": "_radio-dot_16juf_98",
|
|
11
|
+
"radio-label": "_radio-label_16juf_109"
|
|
12
|
+
}, D = Q(null);
|
|
13
|
+
function K() {
|
|
14
|
+
const r = H(D);
|
|
15
|
+
if (!r)
|
|
16
|
+
throw new Error(
|
|
17
|
+
"[VhyxUI] <RadioItem> must be used within <RadioGroup>. Wrap your RadioItem components with <RadioGroup>."
|
|
18
|
+
);
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
const J = z.forwardRef(
|
|
22
|
+
({
|
|
23
|
+
value: r,
|
|
24
|
+
defaultValue: v,
|
|
25
|
+
onValueChange: o,
|
|
26
|
+
disabled: h = !1,
|
|
27
|
+
orientation: a = "vertical",
|
|
28
|
+
size: i = "md",
|
|
29
|
+
contract: I,
|
|
30
|
+
className: c,
|
|
31
|
+
id: e,
|
|
32
|
+
children: f,
|
|
33
|
+
...l
|
|
34
|
+
}, y) => {
|
|
35
|
+
const w = Y("vhyx-radiogroup"), d = e ?? w, u = r !== void 0, [N, g] = M(v), j = u ? r : N, t = A(/* @__PURE__ */ new Map()), p = A([]), [E, S] = M(void 0), B = x(
|
|
36
|
+
(s, _) => {
|
|
37
|
+
_ ? (!t.current.has(s) && (p.current.push(s), p.current.length === 1 && S(s)), t.current.set(s, _)) : (t.current.delete(s), p.current = p.current.filter((n) => n !== s), S(p.current[0]));
|
|
38
|
+
},
|
|
39
|
+
[]
|
|
40
|
+
), O = x(
|
|
41
|
+
(s, _) => {
|
|
42
|
+
const n = p.current, G = n.indexOf(s);
|
|
43
|
+
if (G === -1) return;
|
|
44
|
+
const q = _ === "next" ? (G + 1) % n.length : (G - 1 + n.length) % n.length, b = n[q];
|
|
45
|
+
if (b === void 0) return;
|
|
46
|
+
const k = t.current.get(b);
|
|
47
|
+
!k || k.disabled || (k.focus(), u || g(b), o == null || o(b));
|
|
48
|
+
},
|
|
49
|
+
[u, o]
|
|
50
|
+
), F = x(
|
|
51
|
+
(s) => {
|
|
52
|
+
u || g(s), o == null || o(s);
|
|
53
|
+
},
|
|
54
|
+
[u, o]
|
|
55
|
+
), L = U(
|
|
56
|
+
() => ({ ...C, id: d, ...I }),
|
|
57
|
+
[d, I]
|
|
58
|
+
), P = U(
|
|
59
|
+
() => ({
|
|
60
|
+
value: j,
|
|
61
|
+
onValueChange: F,
|
|
62
|
+
disabled: h,
|
|
63
|
+
size: i,
|
|
64
|
+
groupId: d,
|
|
65
|
+
registerItem: B,
|
|
66
|
+
navigateItem: O,
|
|
67
|
+
firstValue: E
|
|
68
|
+
}),
|
|
69
|
+
[j, F, h, i, d, B, O, E]
|
|
70
|
+
), W = [R.group, c].filter(Boolean).join(" ");
|
|
71
|
+
return /* @__PURE__ */ m.jsx(D.Provider, { value: P, children: /* @__PURE__ */ m.jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
ref: y,
|
|
75
|
+
id: d,
|
|
76
|
+
role: "radiogroup",
|
|
77
|
+
"aria-orientation": a,
|
|
78
|
+
className: W,
|
|
79
|
+
"data-orientation": a,
|
|
80
|
+
"data-size": i,
|
|
81
|
+
"data-vhyx-contract": JSON.stringify(L),
|
|
82
|
+
...l,
|
|
83
|
+
children: f
|
|
84
|
+
}
|
|
85
|
+
) });
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
J.displayName = "VhyxRadioGroup";
|
|
89
|
+
const V = { ...C, id: "vhyxui-radio-group" }, tt = X(J, V);
|
|
90
|
+
tt.displayName = "VhyxRadioGroup";
|
|
91
|
+
const rt = z.forwardRef(
|
|
92
|
+
({ value: r, disabled: v, children: o, className: h, onClick: a, onKeyDown: i, ...I }, c) => {
|
|
93
|
+
const e = K(), f = e.value === r, l = v ?? e.disabled, y = A(null), w = x(
|
|
94
|
+
(t) => {
|
|
95
|
+
y.current = t, typeof c == "function" ? c(t) : c && (c.current = t);
|
|
96
|
+
},
|
|
97
|
+
[c]
|
|
98
|
+
);
|
|
99
|
+
T(() => (e.registerItem(r, y.current), () => {
|
|
100
|
+
e.registerItem(r, null);
|
|
101
|
+
}), [e, r]);
|
|
102
|
+
const d = x(
|
|
103
|
+
(t) => {
|
|
104
|
+
a == null || a(t), l || e.onValueChange(r);
|
|
105
|
+
},
|
|
106
|
+
[a, l, e, r]
|
|
107
|
+
), u = x(
|
|
108
|
+
(t) => {
|
|
109
|
+
i == null || i(t), t.key === "ArrowDown" || t.key === "ArrowRight" ? (t.preventDefault(), e.navigateItem(r, "next")) : (t.key === "ArrowUp" || t.key === "ArrowLeft") && (t.preventDefault(), e.navigateItem(r, "prev"));
|
|
110
|
+
},
|
|
111
|
+
[i, e, r]
|
|
112
|
+
), N = !e.value && e.firstValue === r, g = f || N ? 0 : -1, j = [R.item, h].filter(Boolean).join(" ");
|
|
113
|
+
return /* @__PURE__ */ m.jsxs(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
ref: w,
|
|
117
|
+
type: "button",
|
|
118
|
+
role: "radio",
|
|
119
|
+
"aria-checked": f,
|
|
120
|
+
disabled: l,
|
|
121
|
+
tabIndex: g,
|
|
122
|
+
onClick: d,
|
|
123
|
+
onKeyDown: u,
|
|
124
|
+
className: j,
|
|
125
|
+
"data-state": f ? "checked" : "unchecked",
|
|
126
|
+
"data-size": e.size,
|
|
127
|
+
"data-disabled": l ? !0 : void 0,
|
|
128
|
+
...I,
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ m.jsx("span", { className: R["radio-indicator"], children: f && /* @__PURE__ */ m.jsx("span", { className: R["radio-dot"] }) }),
|
|
131
|
+
o && /* @__PURE__ */ m.jsx("span", { className: R["radio-label"], children: o })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
rt.displayName = "VhyxRadioItem";
|
|
138
|
+
export {
|
|
139
|
+
tt as R,
|
|
140
|
+
rt as a
|
|
141
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("./jsx-runtime-BRMkMA8J.cjs"),e=require("react"),re=require("react-dom"),N=require("@vhyxui/core"),oe=require("@vhyxseal/react"),O=require("./useId-D2AEOm2G.cjs"),ce="_trigger_rs2m0_3",ie="_content_rs2m0_81",ae="_item_rs2m0_101",le="_group_rs2m0_142",ue="_label_rs2m0_148",de="_separator_rs2m0_160",R={trigger:ce,"trigger-value":"_trigger-value_rs2m0_62","trigger-icon":"_trigger-icon_rs2m0_70",content:ie,item:ae,"item-check":"_item-check_rs2m0_131",group:le,label:ue,separator:de},X=e.createContext(null);function D(s){const o=e.useContext(X);if(!o)throw new N.VhyxUIError({code:N.VhyxUIErrorCode.VHYXUI_MISSING_CONTEXT,message:`${s} must be used within <Select>`,suggestion:"Wrap your component tree with <Select>"});return o}const Y=e.forwardRef(({value:s,defaultValue:o,onValueChange:u,disabled:n=!1,size:d="md",placeholder:t,contract:h,children:g,className:i,...y},S)=>{const a=O.useId("vhyx-select-trigger"),f=O.useId("vhyx-select-content"),j=O.useId("vhyx-select"),x=s!==void 0,[I,r]=e.useState(o),v=x?s:I,[k,L]=e.useState(!1),[w,C]=e.useState(void 0),V=e.useRef(null),A=e.useRef(null),_=e.useRef(new Map),M=e.useRef([]),T=e.useRef(new Map),[q,B]=e.useState(void 0),H=e.useRef(v);H.current=v,e.useEffect(()=>{if(v===void 0){B(void 0);return}const c=_.current.get(v);B(c?c.label:void 0)},[v]);const z=e.useCallback((c,l,m)=>{_.current.has(c)||M.current.push(c);const b={label:l};m!==void 0&&(b.disabled=m),_.current.set(c,b),c===H.current&&B(l)},[]),U=e.useCallback(()=>q,[q]),W=e.useCallback(c=>{var b;const l=M.current.filter(E=>{var F;return!((F=_.current.get(E))!=null&&F.disabled)});if(l.length===0)return;let m;if(c==="home")m=l[0];else if(c==="end")m=l[l.length-1];else{const E=w!==void 0?l.indexOf(w):-1;m=c==="down"?l[Math.min(E+1,l.length-1)]:l[Math.max(E-1,0)]}m!==void 0&&(C(m),(b=T.current.get(m))==null||b.focus())},[w]),G=e.useCallback(c=>{var l;x||r(c),u==null||u(c),L(!1),C(void 0),(l=V.current)==null||l.focus()},[x,u]),P=e.useCallback(c=>{if(L(c),c){const l=v??M.current[0];C(l)}else C(void 0)},[v]),ne=e.useMemo(()=>({...N.selectContract,id:j,...h}),[j,h]),se=e.useMemo(()=>({value:v,onValueChange:G,open:k,onOpenChange:P,disabled:n,size:d,placeholder:t,triggerId:a,contentId:f,triggerRef:V,contentRef:A,focusedValue:w,setFocusedValue:C,registerItem:z,getSelectedLabel:U,navigateItems:W,itemElementsRef:T,itemOrderRef:M,itemRegistryRef:_}),[v,G,k,P,n,d,t,a,f,w,z,U,W]);return e.useEffect(()=>{if(!k)return;function c(l){var m;l.key==="Escape"&&(L(!1),C(void 0),(m=V.current)==null||m.focus())}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[k]),e.useEffect(()=>{if(!k)return;function c(l){var b,E;const m=l.target;(b=V.current)!=null&&b.contains(m)||(E=A.current)!=null&&E.contains(m)||(L(!1),C(void 0))}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[k]),p.jsxRuntimeExports.jsx(X.Provider,{value:se,children:p.jsxRuntimeExports.jsx("div",{ref:S,className:i,"data-size":d,"data-disabled":n?!0:void 0,"data-vhyx-contract":JSON.stringify(ne),...y,children:g})})});Y.displayName="VhyxSelect";const J=e.forwardRef(({icon:s,className:o,asChild:u=!1,...n},d)=>{const t=D("Select.Trigger"),h=t.getSelectedLabel(),g=e.useCallback(f=>{t.triggerRef.current=f,typeof d=="function"?d(f):d&&(d.current=f)},[d,t.triggerRef]),i=e.useCallback(()=>{t.disabled||t.onOpenChange(!t.open)},[t]),y=e.useCallback(f=>{(f.key==="ArrowDown"||f.key==="ArrowUp")&&(f.preventDefault(),t.open||t.onOpenChange(!0))},[t]),S=[R.trigger,o].filter(Boolean).join(" "),a={id:t.triggerId,role:"combobox","aria-haspopup":"listbox","aria-expanded":t.open,"aria-controls":t.open?t.contentId:void 0,disabled:t.disabled,onClick:i,onKeyDown:y,className:S,"data-size":t.size,"data-state":t.open?"open":"closed","data-placeholder":h?void 0:!0,...n};return u?p.jsxRuntimeExports.jsx(N.Slot,{ref:g,...a,children:n.children}):p.jsxRuntimeExports.jsxs("button",{ref:g,type:"button",...a,children:[p.jsxRuntimeExports.jsx("span",{className:R["trigger-value"],children:h??t.placeholder??"Select…"}),p.jsxRuntimeExports.jsx("span",{className:R["trigger-icon"],"aria-hidden":"true",children:s??p.jsxRuntimeExports.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:p.jsxRuntimeExports.jsx("path",{d:"M2.5 4.5L6 8L9.5 4.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})});J.displayName="VhyxSelectTrigger";function $({children:s,className:o,...u}){const n=D("Select.Content"),[d,t]=e.useState(!1),[h,g]=e.useState({position:"fixed",top:0,left:0,minWidth:0,zIndex:"var(--vhyx-z-dropdown)"});e.useEffect(()=>{t(!0)},[]),e.useEffect(()=>{var r;if(!n.open||!n.triggerRef.current)return;const a=n.triggerRef.current.getBoundingClientRect(),f=window.innerHeight-a.bottom,j=a.top,x=((r=n.contentRef.current)==null?void 0:r.scrollHeight)??300,I=f<x&&j>f;g({position:"fixed",top:I?a.top-x-4:a.bottom+4,left:a.left,minWidth:a.width,zIndex:"var(--vhyx-z-dropdown)",maxHeight:I?Math.min(x,j-8):Math.min(x,f-8),overflowY:"auto"})},[n.open,n.triggerRef]),e.useEffect(()=>{var a;!n.open||!n.focusedValue||(a=n.itemElementsRef.current.get(n.focusedValue))==null||a.focus()},[n.open]);const i=e.useCallback(a=>{n.contentRef.current=a},[n.contentRef]);if(!d)return null;const y=[R.content,o].filter(Boolean).join(" "),S=p.jsxRuntimeExports.jsx("div",{ref:i,id:n.contentId,role:"listbox","aria-labelledby":n.triggerId,className:y,"data-state":n.open?"open":"closed",style:h,...u,children:s});return re.createPortal(S,document.body)}$.displayName="VhyxSelectContent";const K=e.forwardRef(({value:s,disabled:o,children:u,className:n,onClick:d,onKeyDown:t,...h},g)=>{const i=D("Select.Item"),y=i.value===s,S=i.focusedValue===s,a=typeof u=="string"?u:"";e.useEffect(()=>{i.registerItem(s,a,o)},[i,s,a,o]);const f=e.useCallback(r=>{r?i.itemElementsRef.current.set(s,r):i.itemElementsRef.current.delete(s),typeof g=="function"?g(r):g&&(g.current=r)},[g,i,s]),j=e.useCallback(r=>{d==null||d(r),o||i.onValueChange(s)},[d,o,i,s]),x=e.useCallback(r=>{t==null||t(r),r.key==="Enter"||r.key===" "?(r.preventDefault(),o||i.onValueChange(s)):r.key==="ArrowDown"?(r.preventDefault(),i.navigateItems("down")):r.key==="ArrowUp"?(r.preventDefault(),i.navigateItems("up")):r.key==="Home"?(r.preventDefault(),i.navigateItems("home")):r.key==="End"&&(r.preventDefault(),i.navigateItems("end"))},[t,o,i,s]),I=[R.item,n].filter(Boolean).join(" ");return p.jsxRuntimeExports.jsxs("div",{ref:f,role:"option","aria-selected":y,"aria-disabled":o?!0:void 0,tabIndex:S?0:-1,onClick:j,onKeyDown:x,className:I,"data-state":y?"selected":"unselected","data-disabled":o?!0:void 0,"data-focused":S?!0:void 0,...h,children:[u,y&&p.jsxRuntimeExports.jsx("span",{className:R["item-check"],"aria-hidden":"true",children:p.jsxRuntimeExports.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:p.jsxRuntimeExports.jsx("polyline",{points:"2,6 5,9 10,3"})})})]})});K.displayName="VhyxSelectItem";function Q({children:s,className:o,...u}){const n=O.useId("vhyx-select-group-label"),d=[R.group,o].filter(Boolean).join(" ");return p.jsxRuntimeExports.jsx("div",{role:"group","aria-labelledby":n,className:d,...u,children:e.Children.map(s,t=>e.isValidElement(t)&&t.type.displayName==="VhyxSelectLabel"?e.cloneElement(t,{id:n}):t)})}Q.displayName="VhyxSelectGroup";function Z({children:s,className:o,...u}){const n=[R.label,o].filter(Boolean).join(" ");return p.jsxRuntimeExports.jsx("span",{className:n,...u,children:s})}Z.displayName="VhyxSelectLabel";function ee({className:s,...o}){const u=[R.separator,s].filter(Boolean).join(" ");return p.jsxRuntimeExports.jsx("hr",{"aria-hidden":"true",className:u,...o})}ee.displayName="VhyxSelectSeparator";const fe={...N.selectContract,id:"vhyxui-select"},te=Object.assign(oe.withAgentContract(Y,fe),{Trigger:J,Content:$,Item:K,Group:Q,Label:Z,Separator:ee});te.displayName="VhyxSelect";exports.Select=te;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { j as f } from "./jsx-runtime-CL69jGNW.js";
|
|
2
|
+
import L, { useState as E, useRef as N, useEffect as C, useCallback as m, useMemo as q, createContext as ae, useContext as le } from "react";
|
|
3
|
+
import de from "react-dom";
|
|
4
|
+
import { selectContract as K, Slot as ue, VhyxUIError as fe, VhyxUIErrorCode as pe } from "@vhyxui/core";
|
|
5
|
+
import { withAgentContract as ge } from "@vhyxseal/react";
|
|
6
|
+
import { u as T } from "./useId-BGRmH6iF.js";
|
|
7
|
+
const me = "_trigger_rs2m0_3", he = "_content_rs2m0_81", xe = "_item_rs2m0_101", ye = "_group_rs2m0_142", ve = "_label_rs2m0_148", Se = "_separator_rs2m0_160", S = {
|
|
8
|
+
trigger: me,
|
|
9
|
+
"trigger-value": "_trigger-value_rs2m0_62",
|
|
10
|
+
"trigger-icon": "_trigger-icon_rs2m0_70",
|
|
11
|
+
content: he,
|
|
12
|
+
item: xe,
|
|
13
|
+
"item-check": "_item-check_rs2m0_131",
|
|
14
|
+
group: ye,
|
|
15
|
+
label: ve,
|
|
16
|
+
separator: Se
|
|
17
|
+
}, Q = ae(null);
|
|
18
|
+
function H(n) {
|
|
19
|
+
const o = le(Q);
|
|
20
|
+
if (!o)
|
|
21
|
+
throw new fe({
|
|
22
|
+
code: pe.VHYXUI_MISSING_CONTEXT,
|
|
23
|
+
message: `${n} must be used within <Select>`,
|
|
24
|
+
suggestion: "Wrap your component tree with <Select>"
|
|
25
|
+
});
|
|
26
|
+
return o;
|
|
27
|
+
}
|
|
28
|
+
const Z = L.forwardRef(
|
|
29
|
+
({
|
|
30
|
+
value: n,
|
|
31
|
+
defaultValue: o,
|
|
32
|
+
onValueChange: l,
|
|
33
|
+
disabled: t = !1,
|
|
34
|
+
size: d = "md",
|
|
35
|
+
placeholder: e,
|
|
36
|
+
contract: x,
|
|
37
|
+
children: g,
|
|
38
|
+
className: c,
|
|
39
|
+
...y
|
|
40
|
+
}, b) => {
|
|
41
|
+
const i = T("vhyx-select-trigger"), u = T("vhyx-select-content"), R = T("vhyx-select"), h = n !== void 0, [j, r] = E(o), v = h ? n : j, [k, B] = E(!1), [V, I] = E(void 0), O = N(null), z = N(null), M = N(/* @__PURE__ */ new Map()), D = N([]), U = N(/* @__PURE__ */ new Map()), [W, A] = E(void 0), G = N(v);
|
|
42
|
+
G.current = v, C(() => {
|
|
43
|
+
if (v === void 0) {
|
|
44
|
+
A(void 0);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const s = M.current.get(v);
|
|
48
|
+
A(s ? s.label : void 0);
|
|
49
|
+
}, [v]);
|
|
50
|
+
const P = m(
|
|
51
|
+
(s, a, p) => {
|
|
52
|
+
M.current.has(s) || D.current.push(s);
|
|
53
|
+
const w = { label: a };
|
|
54
|
+
p !== void 0 && (w.disabled = p), M.current.set(s, w), s === G.current && A(a);
|
|
55
|
+
},
|
|
56
|
+
[]
|
|
57
|
+
), F = m(() => W, [W]), X = m(
|
|
58
|
+
(s) => {
|
|
59
|
+
var w;
|
|
60
|
+
const a = D.current.filter(
|
|
61
|
+
(_) => {
|
|
62
|
+
var $;
|
|
63
|
+
return !(($ = M.current.get(_)) != null && $.disabled);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
if (a.length === 0) return;
|
|
67
|
+
let p;
|
|
68
|
+
if (s === "home")
|
|
69
|
+
p = a[0];
|
|
70
|
+
else if (s === "end")
|
|
71
|
+
p = a[a.length - 1];
|
|
72
|
+
else {
|
|
73
|
+
const _ = V !== void 0 ? a.indexOf(V) : -1;
|
|
74
|
+
p = s === "down" ? a[Math.min(_ + 1, a.length - 1)] : a[Math.max(_ - 1, 0)];
|
|
75
|
+
}
|
|
76
|
+
p !== void 0 && (I(p), (w = U.current.get(p)) == null || w.focus());
|
|
77
|
+
},
|
|
78
|
+
[V]
|
|
79
|
+
), Y = m(
|
|
80
|
+
(s) => {
|
|
81
|
+
var a;
|
|
82
|
+
h || r(s), l == null || l(s), B(!1), I(void 0), (a = O.current) == null || a.focus();
|
|
83
|
+
},
|
|
84
|
+
[h, l]
|
|
85
|
+
), J = m(
|
|
86
|
+
(s) => {
|
|
87
|
+
if (B(s), s) {
|
|
88
|
+
const a = v ?? D.current[0];
|
|
89
|
+
I(a);
|
|
90
|
+
} else
|
|
91
|
+
I(void 0);
|
|
92
|
+
},
|
|
93
|
+
[v]
|
|
94
|
+
), ce = q(
|
|
95
|
+
() => ({ ...K, id: R, ...x }),
|
|
96
|
+
[R, x]
|
|
97
|
+
), ie = q(
|
|
98
|
+
() => ({
|
|
99
|
+
value: v,
|
|
100
|
+
onValueChange: Y,
|
|
101
|
+
open: k,
|
|
102
|
+
onOpenChange: J,
|
|
103
|
+
disabled: t,
|
|
104
|
+
size: d,
|
|
105
|
+
placeholder: e,
|
|
106
|
+
triggerId: i,
|
|
107
|
+
contentId: u,
|
|
108
|
+
triggerRef: O,
|
|
109
|
+
contentRef: z,
|
|
110
|
+
focusedValue: V,
|
|
111
|
+
setFocusedValue: I,
|
|
112
|
+
registerItem: P,
|
|
113
|
+
getSelectedLabel: F,
|
|
114
|
+
navigateItems: X,
|
|
115
|
+
itemElementsRef: U,
|
|
116
|
+
itemOrderRef: D,
|
|
117
|
+
itemRegistryRef: M
|
|
118
|
+
}),
|
|
119
|
+
[
|
|
120
|
+
v,
|
|
121
|
+
Y,
|
|
122
|
+
k,
|
|
123
|
+
J,
|
|
124
|
+
t,
|
|
125
|
+
d,
|
|
126
|
+
e,
|
|
127
|
+
i,
|
|
128
|
+
u,
|
|
129
|
+
V,
|
|
130
|
+
P,
|
|
131
|
+
F,
|
|
132
|
+
X
|
|
133
|
+
]
|
|
134
|
+
);
|
|
135
|
+
return C(() => {
|
|
136
|
+
if (!k) return;
|
|
137
|
+
function s(a) {
|
|
138
|
+
var p;
|
|
139
|
+
a.key === "Escape" && (B(!1), I(void 0), (p = O.current) == null || p.focus());
|
|
140
|
+
}
|
|
141
|
+
return document.addEventListener("keydown", s), () => document.removeEventListener("keydown", s);
|
|
142
|
+
}, [k]), C(() => {
|
|
143
|
+
if (!k) return;
|
|
144
|
+
function s(a) {
|
|
145
|
+
var w, _;
|
|
146
|
+
const p = a.target;
|
|
147
|
+
(w = O.current) != null && w.contains(p) || (_ = z.current) != null && _.contains(p) || (B(!1), I(void 0));
|
|
148
|
+
}
|
|
149
|
+
return document.addEventListener("mousedown", s), () => document.removeEventListener("mousedown", s);
|
|
150
|
+
}, [k]), /* @__PURE__ */ f.jsx(Q.Provider, { value: ie, children: /* @__PURE__ */ f.jsx(
|
|
151
|
+
"div",
|
|
152
|
+
{
|
|
153
|
+
ref: b,
|
|
154
|
+
className: c,
|
|
155
|
+
"data-size": d,
|
|
156
|
+
"data-disabled": t ? !0 : void 0,
|
|
157
|
+
"data-vhyx-contract": JSON.stringify(ce),
|
|
158
|
+
...y,
|
|
159
|
+
children: g
|
|
160
|
+
}
|
|
161
|
+
) });
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
Z.displayName = "VhyxSelect";
|
|
165
|
+
const ee = L.forwardRef(
|
|
166
|
+
({ icon: n, className: o, asChild: l = !1, ...t }, d) => {
|
|
167
|
+
const e = H("Select.Trigger"), x = e.getSelectedLabel(), g = m(
|
|
168
|
+
(u) => {
|
|
169
|
+
e.triggerRef.current = u, typeof d == "function" ? d(u) : d && (d.current = u);
|
|
170
|
+
},
|
|
171
|
+
[d, e.triggerRef]
|
|
172
|
+
), c = m(() => {
|
|
173
|
+
e.disabled || e.onOpenChange(!e.open);
|
|
174
|
+
}, [e]), y = m(
|
|
175
|
+
(u) => {
|
|
176
|
+
(u.key === "ArrowDown" || u.key === "ArrowUp") && (u.preventDefault(), e.open || e.onOpenChange(!0));
|
|
177
|
+
},
|
|
178
|
+
[e]
|
|
179
|
+
), b = [S.trigger, o].filter(Boolean).join(" "), i = {
|
|
180
|
+
id: e.triggerId,
|
|
181
|
+
role: "combobox",
|
|
182
|
+
"aria-haspopup": "listbox",
|
|
183
|
+
"aria-expanded": e.open,
|
|
184
|
+
"aria-controls": e.open ? e.contentId : void 0,
|
|
185
|
+
disabled: e.disabled,
|
|
186
|
+
onClick: c,
|
|
187
|
+
onKeyDown: y,
|
|
188
|
+
className: b,
|
|
189
|
+
"data-size": e.size,
|
|
190
|
+
"data-state": e.open ? "open" : "closed",
|
|
191
|
+
"data-placeholder": x ? void 0 : !0,
|
|
192
|
+
...t
|
|
193
|
+
};
|
|
194
|
+
return l ? /* @__PURE__ */ f.jsx(ue, { ref: g, ...i, children: t.children }) : /* @__PURE__ */ f.jsxs("button", { ref: g, type: "button", ...i, children: [
|
|
195
|
+
/* @__PURE__ */ f.jsx("span", { className: S["trigger-value"], children: x ?? e.placeholder ?? "Select…" }),
|
|
196
|
+
/* @__PURE__ */ f.jsx("span", { className: S["trigger-icon"], "aria-hidden": "true", children: n ?? /* @__PURE__ */ f.jsx("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 1.5, children: /* @__PURE__ */ f.jsx("path", { d: "M2.5 4.5L6 8L9.5 4.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
197
|
+
] });
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
ee.displayName = "VhyxSelectTrigger";
|
|
201
|
+
function te({ children: n, className: o, ...l }) {
|
|
202
|
+
const t = H("Select.Content"), [d, e] = E(!1), [x, g] = E({
|
|
203
|
+
position: "fixed",
|
|
204
|
+
top: 0,
|
|
205
|
+
left: 0,
|
|
206
|
+
minWidth: 0,
|
|
207
|
+
zIndex: "var(--vhyx-z-dropdown)"
|
|
208
|
+
});
|
|
209
|
+
C(() => {
|
|
210
|
+
e(!0);
|
|
211
|
+
}, []), C(() => {
|
|
212
|
+
var r;
|
|
213
|
+
if (!t.open || !t.triggerRef.current) return;
|
|
214
|
+
const i = t.triggerRef.current.getBoundingClientRect(), u = window.innerHeight - i.bottom, R = i.top, h = ((r = t.contentRef.current) == null ? void 0 : r.scrollHeight) ?? 300, j = u < h && R > u;
|
|
215
|
+
g({
|
|
216
|
+
position: "fixed",
|
|
217
|
+
top: j ? i.top - h - 4 : i.bottom + 4,
|
|
218
|
+
left: i.left,
|
|
219
|
+
minWidth: i.width,
|
|
220
|
+
zIndex: "var(--vhyx-z-dropdown)",
|
|
221
|
+
maxHeight: j ? Math.min(h, R - 8) : Math.min(h, u - 8),
|
|
222
|
+
overflowY: "auto"
|
|
223
|
+
});
|
|
224
|
+
}, [t.open, t.triggerRef]), C(() => {
|
|
225
|
+
var i;
|
|
226
|
+
!t.open || !t.focusedValue || (i = t.itemElementsRef.current.get(t.focusedValue)) == null || i.focus();
|
|
227
|
+
}, [t.open]);
|
|
228
|
+
const c = m(
|
|
229
|
+
(i) => {
|
|
230
|
+
t.contentRef.current = i;
|
|
231
|
+
},
|
|
232
|
+
[t.contentRef]
|
|
233
|
+
);
|
|
234
|
+
if (!d) return null;
|
|
235
|
+
const y = [S.content, o].filter(Boolean).join(" "), b = /* @__PURE__ */ f.jsx(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
ref: c,
|
|
239
|
+
id: t.contentId,
|
|
240
|
+
role: "listbox",
|
|
241
|
+
"aria-labelledby": t.triggerId,
|
|
242
|
+
className: y,
|
|
243
|
+
"data-state": t.open ? "open" : "closed",
|
|
244
|
+
style: x,
|
|
245
|
+
...l,
|
|
246
|
+
children: n
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
return de.createPortal(b, document.body);
|
|
250
|
+
}
|
|
251
|
+
te.displayName = "VhyxSelectContent";
|
|
252
|
+
const ne = L.forwardRef(
|
|
253
|
+
({ value: n, disabled: o, children: l, className: t, onClick: d, onKeyDown: e, ...x }, g) => {
|
|
254
|
+
const c = H("Select.Item"), y = c.value === n, b = c.focusedValue === n, i = typeof l == "string" ? l : "";
|
|
255
|
+
C(() => {
|
|
256
|
+
c.registerItem(n, i, o);
|
|
257
|
+
}, [c, n, i, o]);
|
|
258
|
+
const u = m(
|
|
259
|
+
(r) => {
|
|
260
|
+
r ? c.itemElementsRef.current.set(n, r) : c.itemElementsRef.current.delete(n), typeof g == "function" ? g(r) : g && (g.current = r);
|
|
261
|
+
},
|
|
262
|
+
[g, c, n]
|
|
263
|
+
), R = m(
|
|
264
|
+
(r) => {
|
|
265
|
+
d == null || d(r), o || c.onValueChange(n);
|
|
266
|
+
},
|
|
267
|
+
[d, o, c, n]
|
|
268
|
+
), h = m(
|
|
269
|
+
(r) => {
|
|
270
|
+
e == null || e(r), r.key === "Enter" || r.key === " " ? (r.preventDefault(), o || c.onValueChange(n)) : r.key === "ArrowDown" ? (r.preventDefault(), c.navigateItems("down")) : r.key === "ArrowUp" ? (r.preventDefault(), c.navigateItems("up")) : r.key === "Home" ? (r.preventDefault(), c.navigateItems("home")) : r.key === "End" && (r.preventDefault(), c.navigateItems("end"));
|
|
271
|
+
},
|
|
272
|
+
[e, o, c, n]
|
|
273
|
+
), j = [S.item, t].filter(Boolean).join(" ");
|
|
274
|
+
return /* @__PURE__ */ f.jsxs(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
ref: u,
|
|
278
|
+
role: "option",
|
|
279
|
+
"aria-selected": y,
|
|
280
|
+
"aria-disabled": o ? !0 : void 0,
|
|
281
|
+
tabIndex: b ? 0 : -1,
|
|
282
|
+
onClick: R,
|
|
283
|
+
onKeyDown: h,
|
|
284
|
+
className: j,
|
|
285
|
+
"data-state": y ? "selected" : "unselected",
|
|
286
|
+
"data-disabled": o ? !0 : void 0,
|
|
287
|
+
"data-focused": b ? !0 : void 0,
|
|
288
|
+
...x,
|
|
289
|
+
children: [
|
|
290
|
+
l,
|
|
291
|
+
y && /* @__PURE__ */ f.jsx("span", { className: S["item-check"], "aria-hidden": "true", children: /* @__PURE__ */ f.jsx("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", children: /* @__PURE__ */ f.jsx("polyline", { points: "2,6 5,9 10,3" }) }) })
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
ne.displayName = "VhyxSelectItem";
|
|
298
|
+
function re({ children: n, className: o, ...l }) {
|
|
299
|
+
const t = T("vhyx-select-group-label"), d = [S.group, o].filter(Boolean).join(" ");
|
|
300
|
+
return /* @__PURE__ */ f.jsx("div", { role: "group", "aria-labelledby": t, className: d, ...l, children: L.Children.map(n, (e) => L.isValidElement(e) && e.type.displayName === "VhyxSelectLabel" ? L.cloneElement(e, { id: t }) : e) });
|
|
301
|
+
}
|
|
302
|
+
re.displayName = "VhyxSelectGroup";
|
|
303
|
+
function oe({ children: n, className: o, ...l }) {
|
|
304
|
+
const t = [S.label, o].filter(Boolean).join(" ");
|
|
305
|
+
return /* @__PURE__ */ f.jsx("span", { className: t, ...l, children: n });
|
|
306
|
+
}
|
|
307
|
+
oe.displayName = "VhyxSelectLabel";
|
|
308
|
+
function se({ className: n, ...o }) {
|
|
309
|
+
const l = [S.separator, n].filter(Boolean).join(" ");
|
|
310
|
+
return /* @__PURE__ */ f.jsx("hr", { "aria-hidden": "true", className: l, ...o });
|
|
311
|
+
}
|
|
312
|
+
se.displayName = "VhyxSelectSeparator";
|
|
313
|
+
const be = { ...K, id: "vhyxui-select" }, we = Object.assign(
|
|
314
|
+
ge(Z, be),
|
|
315
|
+
{
|
|
316
|
+
Trigger: ee,
|
|
317
|
+
Content: te,
|
|
318
|
+
Item: ne,
|
|
319
|
+
Group: re,
|
|
320
|
+
Label: oe,
|
|
321
|
+
Separator: se
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
we.displayName = "VhyxSelect";
|
|
325
|
+
export {
|
|
326
|
+
we as S
|
|
327
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./jsx-runtime-BRMkMA8J.cjs"),x=require("react"),u=require("@vhyxui/core"),d=require("@vhyxseal/react"),j="_separator_2n49e_1",h="_line_2n49e_28",r={separator:j,"separator--labeled":"_separator--labeled_2n49e_21",line:h,"label-text":"_label-text_2n49e_34"},l=x.forwardRef(({orientation:a="horizontal",decorative:t=!0,label:s,className:o,...n},i)=>{const c={className:[r.separator,o].filter(Boolean).join(" "),"data-orientation":a,...t?{"aria-hidden":!0}:{role:"separator","aria-orientation":a},...n};return s&&a==="horizontal"?e.jsxRuntimeExports.jsxs("div",{ref:i,className:[r["separator--labeled"],o].filter(Boolean).join(" "),"data-orientation":a,...t?{"aria-hidden":!0}:{role:"separator","aria-orientation":a},...n,children:[e.jsxRuntimeExports.jsx("span",{className:r.line}),e.jsxRuntimeExports.jsx("span",{className:r["label-text"],children:s}),e.jsxRuntimeExports.jsx("span",{className:r.line})]}):e.jsxRuntimeExports.jsx("hr",{ref:i,...c})});l.displayName="VhyxSeparator";const m={...u.separatorContract,id:"vhyxui-separator"},p=d.withAgentContract(l,m);p.displayName="VhyxSeparator";exports.Separator=p;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { j as r } from "./jsx-runtime-CL69jGNW.js";
|
|
2
|
+
import c from "react";
|
|
3
|
+
import { separatorContract as d } from "@vhyxui/core";
|
|
4
|
+
import { withAgentContract as m } from "@vhyxseal/react";
|
|
5
|
+
const x = "_separator_2n49e_1", h = "_line_2n49e_28", e = {
|
|
6
|
+
separator: x,
|
|
7
|
+
"separator--labeled": "_separator--labeled_2n49e_21",
|
|
8
|
+
line: h,
|
|
9
|
+
"label-text": "_label-text_2n49e_34"
|
|
10
|
+
}, i = c.forwardRef(
|
|
11
|
+
({
|
|
12
|
+
orientation: a = "horizontal",
|
|
13
|
+
decorative: t = !0,
|
|
14
|
+
label: s,
|
|
15
|
+
className: o,
|
|
16
|
+
...n
|
|
17
|
+
}, l) => {
|
|
18
|
+
const p = {
|
|
19
|
+
className: [e.separator, o].filter(Boolean).join(" "),
|
|
20
|
+
"data-orientation": a,
|
|
21
|
+
...t ? { "aria-hidden": !0 } : { role: "separator", "aria-orientation": a },
|
|
22
|
+
...n
|
|
23
|
+
};
|
|
24
|
+
return s && a === "horizontal" ? /* @__PURE__ */ r.jsxs(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
ref: l,
|
|
28
|
+
className: [e["separator--labeled"], o].filter(Boolean).join(" "),
|
|
29
|
+
"data-orientation": a,
|
|
30
|
+
...t ? { "aria-hidden": !0 } : { role: "separator", "aria-orientation": a },
|
|
31
|
+
...n,
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ r.jsx("span", { className: e.line }),
|
|
34
|
+
/* @__PURE__ */ r.jsx("span", { className: e["label-text"], children: s }),
|
|
35
|
+
/* @__PURE__ */ r.jsx("span", { className: e.line })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
) : /* @__PURE__ */ r.jsx(
|
|
39
|
+
"hr",
|
|
40
|
+
{
|
|
41
|
+
ref: l,
|
|
42
|
+
...p
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
i.displayName = "VhyxSeparator";
|
|
48
|
+
const _ = { ...d, id: "vhyxui-separator" }, j = m(i, _);
|
|
49
|
+
j.displayName = "VhyxSeparator";
|
|
50
|
+
export {
|
|
51
|
+
j as S
|
|
52
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { j as r } from "./jsx-runtime-CL69jGNW.js";
|
|
2
|
+
import c from "react";
|
|
3
|
+
import { spinnerContract as l } from "@vhyxui/core";
|
|
4
|
+
import { withAgentContract as d } from "@vhyxseal/react";
|
|
5
|
+
const m = "_spinner_3wx6i_1", x = {
|
|
6
|
+
spinner: m
|
|
7
|
+
}, t = c.forwardRef(
|
|
8
|
+
({
|
|
9
|
+
size: s = "md",
|
|
10
|
+
variant: e = "default",
|
|
11
|
+
label: n = "Loading",
|
|
12
|
+
className: o,
|
|
13
|
+
...i
|
|
14
|
+
}, a) => {
|
|
15
|
+
const p = [x.spinner, o].filter(Boolean).join(" ");
|
|
16
|
+
return /* @__PURE__ */ r.jsxs(
|
|
17
|
+
"svg",
|
|
18
|
+
{
|
|
19
|
+
ref: a,
|
|
20
|
+
role: "status",
|
|
21
|
+
"aria-label": n,
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "none",
|
|
24
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25
|
+
className: p,
|
|
26
|
+
"data-size": s,
|
|
27
|
+
"data-variant": e,
|
|
28
|
+
...i,
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ r.jsx("title", { children: n }),
|
|
31
|
+
/* @__PURE__ */ r.jsx(
|
|
32
|
+
"circle",
|
|
33
|
+
{
|
|
34
|
+
cx: 12,
|
|
35
|
+
cy: 12,
|
|
36
|
+
r: 9,
|
|
37
|
+
strokeWidth: 2.5,
|
|
38
|
+
stroke: "currentColor",
|
|
39
|
+
opacity: 0.2
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ r.jsx(
|
|
43
|
+
"path",
|
|
44
|
+
{
|
|
45
|
+
d: "M12 3a9 9 0 0 1 9 9",
|
|
46
|
+
strokeWidth: 2.5,
|
|
47
|
+
stroke: "currentColor",
|
|
48
|
+
strokeLinecap: "round"
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
t.displayName = "VhyxSpinner";
|
|
57
|
+
const h = { ...l, id: "vhyxui-spinner" }, f = d(t, h);
|
|
58
|
+
f.displayName = "VhyxSpinner";
|
|
59
|
+
export {
|
|
60
|
+
f as S
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./jsx-runtime-BRMkMA8J.cjs"),x=require("react"),l=require("@vhyxui/core"),u=require("@vhyxseal/react"),d="_spinner_3wx6i_1",h={spinner:d},r=x.forwardRef(({size:s="md",variant:i="default",label:n="Loading",className:o,...a},c)=>{const p=[h.spinner,o].filter(Boolean).join(" ");return e.jsxRuntimeExports.jsxs("svg",{ref:c,role:"status","aria-label":n,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:p,"data-size":s,"data-variant":i,...a,children:[e.jsxRuntimeExports.jsx("title",{children:n}),e.jsxRuntimeExports.jsx("circle",{cx:12,cy:12,r:9,strokeWidth:2.5,stroke:"currentColor",opacity:.2}),e.jsxRuntimeExports.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",strokeWidth:2.5,stroke:"currentColor",strokeLinecap:"round"})]})});r.displayName="VhyxSpinner";const j={...l.spinnerContract,id:"vhyxui-spinner"},t=u.withAgentContract(r,j);t.displayName="VhyxSpinner";exports.Spinner=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("./jsx-runtime-BRMkMA8J.cjs"),s=require("react"),h=require("@vhyxui/core"),A=require("@vhyxseal/react"),J=require("./useId-D2AEOm2G.cjs"),O="_thumb_du6cw_38",m={switch:"_switch_du6cw_1",thumb:O},f=s.forwardRef(({checked:l,defaultChecked:S=!1,onCheckedChange:c,size:b="md",asChild:j=!1,contract:y,className:v,id:R,disabled:n,onClick:e,onKeyDown:r,children:_,...q},d)=>{const I=J.useId("vhyx-switch"),w=R??I,u=l!==void 0,[N,E]=s.useState(S),i=u?l:N,a=s.useCallback(()=>{if(n)return;const t=!i;u||E(t),c==null||c(t)},[n,i,u,c]),B=s.useCallback(t=>{e==null||e(t),a()},[e,a]),V=s.useCallback(t=>{r==null||r(t),t.key==="Enter"&&(t.preventDefault(),a())},[r,a]),k={...h.switchContract,id:w,...y},z=[m.switch,v].filter(Boolean).join(" "),x={id:w,role:"switch","aria-checked":i,disabled:n,onClick:B,onKeyDown:V,className:z,"data-state":i?"checked":"unchecked","data-size":b,"data-vhyx-contract":JSON.stringify(k),...q};return j?o.jsxRuntimeExports.jsx(h.Slot,{ref:d,...x,children:_}):o.jsxRuntimeExports.jsx("button",{ref:d,type:"button",...x,children:o.jsxRuntimeExports.jsx("span",{className:m.thumb})})});f.displayName="VhyxSwitch";const P={...h.switchContract,id:"vhyxui-switch"},p=A.withAgentContract(f,P);p.displayName="VhyxSwitch";exports.Switch=p;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { j as n } from "./jsx-runtime-CL69jGNW.js";
|
|
2
|
+
import J, { useState as O, useCallback as h } from "react";
|
|
3
|
+
import { switchContract as w, Slot as P } from "@vhyxui/core";
|
|
4
|
+
import { withAgentContract as q } from "@vhyxseal/react";
|
|
5
|
+
import { u as F } from "./useId-BGRmH6iF.js";
|
|
6
|
+
const G = "_thumb_du6cw_38", f = {
|
|
7
|
+
switch: "_switch_du6cw_1",
|
|
8
|
+
thumb: G
|
|
9
|
+
}, p = J.forwardRef(
|
|
10
|
+
({
|
|
11
|
+
checked: u,
|
|
12
|
+
defaultChecked: x = !1,
|
|
13
|
+
onCheckedChange: s,
|
|
14
|
+
size: S = "md",
|
|
15
|
+
asChild: y = !1,
|
|
16
|
+
contract: b,
|
|
17
|
+
className: j,
|
|
18
|
+
id: v,
|
|
19
|
+
disabled: e,
|
|
20
|
+
onClick: c,
|
|
21
|
+
onKeyDown: r,
|
|
22
|
+
children: _,
|
|
23
|
+
...N
|
|
24
|
+
}, l) => {
|
|
25
|
+
const I = F("vhyx-switch"), m = v ?? I, o = u !== void 0, [R, B] = O(x), a = o ? u : R, i = h(() => {
|
|
26
|
+
if (e) return;
|
|
27
|
+
const t = !a;
|
|
28
|
+
o || B(t), s == null || s(t);
|
|
29
|
+
}, [e, a, o, s]), E = h(
|
|
30
|
+
(t) => {
|
|
31
|
+
c == null || c(t), i();
|
|
32
|
+
},
|
|
33
|
+
[c, i]
|
|
34
|
+
), V = h(
|
|
35
|
+
(t) => {
|
|
36
|
+
r == null || r(t), t.key === "Enter" && (t.preventDefault(), i());
|
|
37
|
+
},
|
|
38
|
+
[r, i]
|
|
39
|
+
), z = {
|
|
40
|
+
...w,
|
|
41
|
+
id: m,
|
|
42
|
+
...b
|
|
43
|
+
}, A = [f.switch, j].filter(Boolean).join(" "), d = {
|
|
44
|
+
id: m,
|
|
45
|
+
role: "switch",
|
|
46
|
+
"aria-checked": a,
|
|
47
|
+
disabled: e,
|
|
48
|
+
onClick: E,
|
|
49
|
+
onKeyDown: V,
|
|
50
|
+
className: A,
|
|
51
|
+
"data-state": a ? "checked" : "unchecked",
|
|
52
|
+
"data-size": S,
|
|
53
|
+
"data-vhyx-contract": JSON.stringify(z),
|
|
54
|
+
...N
|
|
55
|
+
};
|
|
56
|
+
return y ? /* @__PURE__ */ n.jsx(P, { ref: l, ...d, children: _ }) : /* @__PURE__ */ n.jsx("button", { ref: l, type: "button", ...d, children: /* @__PURE__ */ n.jsx("span", { className: f.thumb }) });
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
p.displayName = "VhyxSwitch";
|
|
60
|
+
const H = { ...w, id: "vhyxui-switch" }, L = q(p, H);
|
|
61
|
+
L.displayName = "VhyxSwitch";
|
|
62
|
+
export {
|
|
63
|
+
L as S
|
|
64
|
+
};
|