@vhyxui/react 0.1.2-alpha.2 → 0.2.0-alpha

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.
Files changed (53) hide show
  1. package/dist/{Badge-Fuc7l-1E.js → Badge-Bbxb4wyt.js} +7 -7
  2. package/dist/{Badge-RM7n86Rq.cjs → Badge-SBO9tGzn.cjs} +1 -1
  3. package/dist/{Button-D7eX45GC.js → Button-DDMc7-3S.js} +28 -28
  4. package/dist/{Button-AkUYT9eN.cjs → Button-akOSYEu9.cjs} +1 -1
  5. package/dist/Card-DSCA-Igh.cjs +1 -0
  6. package/dist/Card-Dh9Pcmfa.js +79 -0
  7. package/dist/Popover-BHGX_cC4.cjs +1 -0
  8. package/dist/Popover-u9vlClum.js +211 -0
  9. package/dist/Select-CGfKq69f.cjs +1 -0
  10. package/dist/Select-DHalg36V.js +344 -0
  11. package/dist/SelectField-DG7SlT9m.cjs +1 -0
  12. package/dist/SelectField-DTfYCDWa.js +49 -0
  13. package/dist/{Spinner-CZSz1OpT.js → Spinner-BYi9eTfl.js} +19 -19
  14. package/dist/Spinner-CeIDpqkx.cjs +1 -0
  15. package/dist/TextField-C3r-6jr6.cjs +1 -0
  16. package/dist/TextField-DtXQQJJk.js +31 -0
  17. package/dist/TextareaField-CpqPinvx.js +31 -0
  18. package/dist/TextareaField-D234Lyi_.cjs +1 -0
  19. package/dist/badge.cjs +1 -1
  20. package/dist/badge.js +1 -1
  21. package/dist/button.cjs +1 -1
  22. package/dist/button.js +1 -1
  23. package/dist/card.cjs +1 -1
  24. package/dist/card.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.ts +129 -6
  27. package/dist/index.js +47 -41
  28. package/dist/popover.cjs +1 -1
  29. package/dist/popover.d.ts +7 -1
  30. package/dist/popover.js +1 -1
  31. package/dist/select.cjs +1 -1
  32. package/dist/select.d.ts +19 -5
  33. package/dist/select.js +1 -1
  34. package/dist/selectfield.cjs +1 -0
  35. package/dist/selectfield.d.ts +82 -0
  36. package/dist/selectfield.js +4 -0
  37. package/dist/spinner.cjs +1 -1
  38. package/dist/spinner.js +1 -1
  39. package/dist/style.css +1 -1
  40. package/dist/textareafield.cjs +1 -0
  41. package/dist/textareafield.d.ts +84 -0
  42. package/dist/textareafield.js +4 -0
  43. package/dist/textfield.cjs +1 -0
  44. package/dist/textfield.d.ts +82 -0
  45. package/dist/textfield.js +4 -0
  46. package/package.json +16 -1
  47. package/dist/Card-D7ZNeWtE.js +0 -75
  48. package/dist/Card-d5xrWgQS.cjs +0 -1
  49. package/dist/Popover-BPFkS4xn.cjs +0 -1
  50. package/dist/Popover-MxUovsIt.js +0 -194
  51. package/dist/Select-C9yB2B8M.cjs +0 -1
  52. package/dist/Select-DjeJOdb7.js +0 -327
  53. package/dist/Spinner-BZGPmp9c.cjs +0 -1
@@ -1,194 +0,0 @@
1
- import { j as p } from "./jsx-runtime-CL69jGNW.js";
2
- import R, { useState as E, useRef as b, useCallback as h, useEffect as C, useMemo as N, createContext as $, useContext as D } from "react";
3
- import G from "react-dom";
4
- import { popoverContract as V, Slot as B, VhyxUIError as z, VhyxUIErrorCode as H } from "@vhyxui/core";
5
- import { withAgentContract as J } from "@vhyxseal/react";
6
- import { u as K } from "./useId-BGRmH6iF.js";
7
- const W = "_trigger_5e049_1", Y = "_content_5e049_7", q = "_arrow_5e049_21", F = "_close_5e049_29", P = {
8
- trigger: W,
9
- content: Y,
10
- arrow: q,
11
- close: F
12
- }, L = $(null);
13
- function j(n) {
14
- const s = D(L);
15
- if (!s)
16
- throw new z({
17
- code: H.VHYXUI_MISSING_CONTEXT,
18
- message: `${n} must be used within <Popover>`,
19
- suggestion: "Wrap your component tree with <Popover>"
20
- });
21
- return s;
22
- }
23
- const S = R.forwardRef(
24
- ({
25
- open: n,
26
- defaultOpen: s = !1,
27
- onOpenChange: e,
28
- contract: f,
29
- children: v
30
- }, o) => {
31
- const r = K("vhyx-popover"), c = `${r}-trigger`, u = `${r}-content`, a = n !== void 0, [d, t] = E(s), i = a ? n : d, l = b(null), g = b(null), x = h(
32
- (m) => {
33
- a || t(m), e == null || e(m);
34
- },
35
- [a, e]
36
- );
37
- C(() => {
38
- if (!i) return;
39
- function m(w) {
40
- var y;
41
- w.key === "Escape" && (x(!1), (y = l.current) == null || y.focus());
42
- }
43
- return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
44
- }, [i, x]), C(() => {
45
- if (!i) return;
46
- function m(w) {
47
- var I, _;
48
- const y = w.target;
49
- (I = l.current) != null && I.contains(y) || (_ = g.current) != null && _.contains(y) || x(!1);
50
- }
51
- return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
52
- }, [i, x]);
53
- const U = N(
54
- () => ({ ...V, id: r, ...f }),
55
- [r, f]
56
- ), X = N(
57
- () => ({
58
- open: i,
59
- onOpenChange: x,
60
- triggerId: c,
61
- contentId: u,
62
- triggerRef: l,
63
- contentRef: g
64
- }),
65
- [i, x, c, u]
66
- );
67
- return /* @__PURE__ */ p.jsx(L.Provider, { value: X, children: /* @__PURE__ */ p.jsx(
68
- "div",
69
- {
70
- ref: o,
71
- "data-state": i ? "open" : "closed",
72
- "data-vhyx-contract": JSON.stringify(U),
73
- children: v
74
- }
75
- ) });
76
- }
77
- );
78
- S.displayName = "VhyxPopover";
79
- const T = R.forwardRef(
80
- ({ children: n, className: s, onClick: e, asChild: f = !1, ...v }, o) => {
81
- const r = j("Popover.Trigger"), c = h(
82
- (t) => {
83
- r.triggerRef.current = t, typeof o == "function" ? o(t) : o && (o.current = t);
84
- },
85
- [o, r.triggerRef]
86
- ), u = h(
87
- (t) => {
88
- e == null || e(t), r.onOpenChange(!r.open);
89
- },
90
- [e, r]
91
- ), a = [P.trigger, s].filter(Boolean).join(" "), d = {
92
- id: r.triggerId,
93
- "aria-haspopup": "dialog",
94
- "aria-expanded": r.open,
95
- "aria-controls": r.open ? r.contentId : void 0,
96
- onClick: u,
97
- className: a,
98
- ...v
99
- };
100
- return f ? /* @__PURE__ */ p.jsx(B, { ref: c, ...d, children: n }) : /* @__PURE__ */ p.jsx("button", { ref: c, type: "button", ...d, children: n });
101
- }
102
- );
103
- T.displayName = "VhyxPopoverTrigger";
104
- function A({
105
- children: n,
106
- className: s,
107
- side: e = "bottom",
108
- align: f = "center",
109
- ...v
110
- }) {
111
- const o = j("Popover.Content"), [r, c] = E({ top: 0, left: 0 });
112
- C(() => {
113
- if (!o.open || !o.triggerRef.current) return;
114
- const t = o.triggerRef.current.getBoundingClientRect(), i = 8;
115
- let l = 0, g = 0;
116
- e === "bottom" ? (l = t.bottom + i, g = t.left + t.width / 2) : e === "top" ? (l = t.top - i, g = t.left + t.width / 2) : e === "right" ? (l = t.top + t.height / 2, g = t.right + i) : (l = t.top + t.height / 2, g = t.left - i), c({ top: l, left: g });
117
- }, [o.open, o.triggerRef, e]);
118
- const u = h(
119
- (t) => {
120
- o.contentRef.current = t;
121
- },
122
- [o.contentRef]
123
- );
124
- if (!o.open) return null;
125
- const a = [P.content, s].filter(Boolean).join(" "), d = /* @__PURE__ */ p.jsx(
126
- "div",
127
- {
128
- ref: u,
129
- id: o.contentId,
130
- role: "dialog",
131
- "aria-modal": "false",
132
- "aria-labelledby": o.triggerId,
133
- className: a,
134
- "data-state": "open",
135
- "data-side": e,
136
- "data-align": f,
137
- style: {
138
- position: "fixed",
139
- top: r.top,
140
- left: r.left,
141
- zIndex: 450,
142
- // --vhyx-z-popover
143
- transform: "translateX(-50%)"
144
- },
145
- ...v,
146
- children: n
147
- }
148
- );
149
- return G.createPortal(d, document.body);
150
- }
151
- A.displayName = "VhyxPopoverContent";
152
- function M({ className: n, ...s }) {
153
- const e = [P.arrow, n].filter(Boolean).join(" ");
154
- return /* @__PURE__ */ p.jsx(
155
- "svg",
156
- {
157
- "aria-hidden": "true",
158
- className: e,
159
- viewBox: "0 0 10 5",
160
- ...s,
161
- children: /* @__PURE__ */ p.jsx("path", { d: "M0 5L5 0L10 5", fill: "currentColor" })
162
- }
163
- );
164
- }
165
- M.displayName = "VhyxPopoverArrow";
166
- const O = R.forwardRef(
167
- ({ children: n, className: s, onClick: e, asChild: f = !1, ...v }, o) => {
168
- const r = j("Popover.Close"), c = h(
169
- (d) => {
170
- e == null || e(d), r.onOpenChange(!1);
171
- },
172
- [e, r]
173
- ), u = [P.close, s].filter(Boolean).join(" "), a = {
174
- onClick: c,
175
- className: u,
176
- ...v
177
- };
178
- return f ? /* @__PURE__ */ p.jsx(B, { ref: o, ...a, children: n }) : /* @__PURE__ */ p.jsx("button", { ref: o, type: "button", ...a, children: n ?? "Close" });
179
- }
180
- );
181
- O.displayName = "VhyxPopoverClose";
182
- const Q = { ...V, id: "vhyxui-popover" }, Z = Object.assign(
183
- J(S, Q),
184
- {
185
- Trigger: T,
186
- Content: A,
187
- Arrow: M,
188
- Close: O
189
- }
190
- );
191
- Z.displayName = "VhyxPopover";
192
- export {
193
- Z as P
194
- };
@@ -1 +0,0 @@
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;
@@ -1,327 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
- "use strict";const n=require("./jsx-runtime-BRMkMA8J.cjs"),x=require("react"),d=require("@vhyxui/core"),u=require("@vhyxseal/react"),h="_spinner_1udc2_1",m={spinner:h},r={xs:12,sm:20,md:32,lg:48,xl:64},s=x.forwardRef(({size:t="md",variant:o="default",label:e="Loading",className:a,...c},p)=>{const l=[m.spinner,a].filter(Boolean).join(" ");return n.jsxRuntimeExports.jsxs("svg",{ref:p,role:"status","aria-label":e,width:r[t],height:r[t],viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:l,"data-size":t,"data-variant":o,...c,children:[n.jsxRuntimeExports.jsx("title",{children:e}),n.jsxRuntimeExports.jsx("circle",{cx:12,cy:12,r:9,strokeWidth:2.5,stroke:"currentColor",opacity:.2}),n.jsxRuntimeExports.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",strokeWidth:2.5,stroke:"currentColor",strokeLinecap:"round"})]})});s.displayName="VhyxSpinner";const j={...d.spinnerContract,id:"vhyxui-spinner"},i=u.withAgentContract(s,j);i.displayName="VhyxSpinner";exports.Spinner=i;