@gv-tech/ui-web 2.29.2 → 2.29.4

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 (265) hide show
  1. package/dist/accordion.cjs +1 -1
  2. package/dist/accordion.mjs +53 -1
  3. package/dist/alert-dialog.cjs +1 -1
  4. package/dist/alert-dialog.mjs +99 -1
  5. package/dist/alert.cjs +1 -1
  6. package/dist/alert.mjs +1 -1
  7. package/dist/aspect-ratio.cjs +1 -1
  8. package/dist/aspect-ratio.mjs +10 -1
  9. package/dist/attachment.cjs +1 -1
  10. package/dist/attachment.mjs +25 -24
  11. package/dist/avatar.cjs +1 -1
  12. package/dist/avatar.mjs +49 -1
  13. package/dist/badge.cjs +1 -1
  14. package/dist/badge.mjs +5 -4
  15. package/dist/breadcrumb.cjs +1 -1
  16. package/dist/breadcrumb.mjs +12 -11
  17. package/dist/bubble.cjs +1 -1
  18. package/dist/bubble.mjs +4 -3
  19. package/dist/button-group.cjs +1 -1
  20. package/dist/button-group.mjs +12 -11
  21. package/dist/button.cjs +1 -1
  22. package/dist/button.mjs +4 -3
  23. package/dist/calendar.cjs +1 -1
  24. package/dist/calendar.mjs +97 -1
  25. package/dist/card.cjs +1 -1
  26. package/dist/card.mjs +1 -1
  27. package/dist/carousel.cjs +1 -1
  28. package/dist/carousel.mjs +107 -1
  29. package/dist/chart.cjs +2 -2
  30. package/dist/chart.mjs +1 -1
  31. package/dist/checkbox.cjs +1 -1
  32. package/dist/checkbox.mjs +19 -1
  33. package/dist/collapsible.cjs +1 -1
  34. package/dist/collapsible.mjs +12 -12
  35. package/dist/combobox.cjs +1 -1
  36. package/dist/combobox.mjs +161 -1
  37. package/dist/command.cjs +1 -1
  38. package/dist/command.mjs +89 -1
  39. package/dist/context-menu.cjs +1 -1
  40. package/dist/context-menu.mjs +123 -1
  41. package/dist/dialog.cjs +1 -1
  42. package/dist/dialog.mjs +40 -40
  43. package/dist/direction.cjs +1 -1
  44. package/dist/direction.mjs +7 -7
  45. package/dist/drawer.cjs +1 -1
  46. package/dist/drawer.mjs +1 -1
  47. package/dist/dropdown-menu.cjs +1 -1
  48. package/dist/dropdown-menu.mjs +126 -1
  49. package/dist/empty.cjs +1 -1
  50. package/dist/empty.mjs +1 -1
  51. package/dist/field.cjs +1 -1
  52. package/dist/field.mjs +36 -36
  53. package/dist/form.cjs +1 -1
  54. package/dist/form.mjs +36 -36
  55. package/dist/hover-card.cjs +1 -1
  56. package/dist/hover-card.mjs +30 -1
  57. package/dist/index.cjs +1 -1
  58. package/dist/index.mjs +36 -36
  59. package/dist/input-group.cjs +1 -1
  60. package/dist/input-group.mjs +26 -26
  61. package/dist/input-otp.cjs +1 -1
  62. package/dist/input-otp.mjs +45 -1
  63. package/dist/input.cjs +1 -1
  64. package/dist/input.mjs +1 -1
  65. package/dist/item.cjs +1 -1
  66. package/dist/item.mjs +28 -27
  67. package/dist/kbd.cjs +1 -1
  68. package/dist/kbd.mjs +1 -1
  69. package/dist/label.cjs +1 -1
  70. package/dist/label.mjs +13 -1
  71. package/dist/marker.cjs +1 -1
  72. package/dist/marker.mjs +4 -3
  73. package/dist/menubar.cjs +1 -1
  74. package/dist/menubar.mjs +133 -1
  75. package/dist/message-scroller.cjs +1 -1
  76. package/dist/message-scroller.mjs +59 -1
  77. package/dist/message.cjs +1 -1
  78. package/dist/message.mjs +1 -1
  79. package/dist/native-select.cjs +1 -1
  80. package/dist/native-select.mjs +1 -1
  81. package/dist/navigation-menu.cjs +1 -1
  82. package/dist/navigation-menu.mjs +79 -1
  83. package/dist/pagination.cjs +1 -1
  84. package/dist/pagination.mjs +14 -14
  85. package/dist/popover.cjs +1 -1
  86. package/dist/popover.mjs +54 -1
  87. package/dist/progress.cjs +1 -1
  88. package/dist/progress.mjs +19 -1
  89. package/dist/questionnaire.cjs +1 -1
  90. package/dist/questionnaire.mjs +168 -1
  91. package/dist/radio-group.cjs +1 -1
  92. package/dist/radio-group.mjs +25 -1
  93. package/dist/resizable.cjs +1 -1
  94. package/dist/resizable.mjs +26 -1
  95. package/dist/rolldown-runtime-BocRIvOZ.js +1 -0
  96. package/dist/scroll-area.cjs +1 -1
  97. package/dist/scroll-area.mjs +35 -1
  98. package/dist/scroll-to-top.cjs +1 -1
  99. package/dist/search.cjs +1 -1
  100. package/dist/search.mjs +1 -1
  101. package/dist/select.cjs +1 -1
  102. package/dist/select.mjs +98 -1
  103. package/dist/separator.cjs +1 -1
  104. package/dist/separator.mjs +15 -1
  105. package/dist/sheet.cjs +1 -1
  106. package/dist/sheet.mjs +38 -38
  107. package/dist/{sidebar-C2ax_A0G.mjs → sidebar-DrU3nKaL.mjs} +138 -134
  108. package/dist/sidebar-uOtFHnBs.js +1 -0
  109. package/dist/sidebar.cjs +1 -1
  110. package/dist/sidebar.mjs +3 -1
  111. package/dist/skeleton.cjs +1 -1
  112. package/dist/skeleton.mjs +1 -1
  113. package/dist/slider.cjs +1 -1
  114. package/dist/slider.mjs +34 -1
  115. package/dist/spinner.cjs +1 -1
  116. package/dist/spinner.mjs +1 -1
  117. package/dist/support-fab.cjs +1 -1
  118. package/dist/switch.cjs +1 -1
  119. package/dist/switch.mjs +18 -1
  120. package/dist/table-of-contents.cjs +1 -1
  121. package/dist/table.cjs +1 -1
  122. package/dist/table.mjs +1 -1
  123. package/dist/tabs.cjs +1 -1
  124. package/dist/tabs.mjs +44 -1
  125. package/dist/text.cjs +1 -1
  126. package/dist/textarea.cjs +1 -1
  127. package/dist/textarea.mjs +1 -1
  128. package/dist/{theme-toggle-BSMwXb8o.mjs → theme-toggle-9KtAIRxy.mjs} +6 -6
  129. package/dist/theme-toggle-DkNI3bfh.js +1 -0
  130. package/dist/theme-toggle.cjs +1 -1
  131. package/dist/theme-toggle.mjs +2 -1
  132. package/dist/toast.cjs +1 -1
  133. package/dist/toast.mjs +52 -1
  134. package/dist/{toaster-D2BV6jez.mjs → toaster-8RrHPtlc.mjs} +8 -8
  135. package/dist/toaster-AFud4l6l.js +1 -0
  136. package/dist/toaster.cjs +1 -1
  137. package/dist/toaster.mjs +2 -1
  138. package/dist/toggle-group.cjs +1 -1
  139. package/dist/toggle-group.mjs +49 -1
  140. package/dist/toggle.cjs +1 -1
  141. package/dist/toggle.mjs +35 -1
  142. package/dist/tooltip.cjs +1 -1
  143. package/dist/tooltip.mjs +34 -1
  144. package/package.json +2 -1
  145. package/dist/accordion-Bd0-CZQn.js +0 -1
  146. package/dist/accordion-Cf6DNbLH.mjs +0 -244
  147. package/dist/alert-dialog-BxFH0Lwn.mjs +0 -180
  148. package/dist/alert-dialog-C6vNmGBL.js +0 -1
  149. package/dist/aspect-ratio-CdQevcDV.mjs +0 -38
  150. package/dist/aspect-ratio-Z4Nkc56X.js +0 -1
  151. package/dist/avatar-B5PWwGhY.mjs +0 -136
  152. package/dist/avatar-CFhYRM52.js +0 -1
  153. package/dist/calendar-D5qgt2o2.js +0 -1
  154. package/dist/calendar-DIqXNjOR.mjs +0 -3029
  155. package/dist/carousel-D-xEqRCX.js +0 -1
  156. package/dist/carousel-DPjWmM_A.mjs +0 -1169
  157. package/dist/checkbox-DEPm1BBc.mjs +0 -184
  158. package/dist/checkbox-DI9Hn_e_.js +0 -1
  159. package/dist/chunk-HBS6WEDP-D2-yWzIN.js +0 -1
  160. package/dist/chunk-HBS6WEDP-DD8ZmxRM.mjs +0 -62
  161. package/dist/combobox-C4y8AbZX.mjs +0 -5644
  162. package/dist/combobox-boXp-mix.js +0 -3
  163. package/dist/command-BnW6UIVk.js +0 -1
  164. package/dist/command-Cbsp7PBx.mjs +0 -542
  165. package/dist/context-menu-CwsdFpx1.js +0 -1
  166. package/dist/context-menu-FNgV55ZV.mjs +0 -315
  167. package/dist/dist-7YyzJonC.mjs +0 -39
  168. package/dist/dist-AlmToDtO.mjs +0 -17
  169. package/dist/dist-B76UOZbx.mjs +0 -40
  170. package/dist/dist-B7Ph9-T6.mjs +0 -44
  171. package/dist/dist-B7jnFMko.js +0 -1
  172. package/dist/dist-BOiFyvyS.mjs +0 -10
  173. package/dist/dist-BQkDLAY7.js +0 -1
  174. package/dist/dist-Bal96K8t.js +0 -1
  175. package/dist/dist-Blgp9lfa.js +0 -1
  176. package/dist/dist-BnlI08Je.mjs +0 -96
  177. package/dist/dist-Bu-uFV1C.mjs +0 -191
  178. package/dist/dist-C2BHd5i1.mjs +0 -460
  179. package/dist/dist-C516Vwxy.mjs +0 -116
  180. package/dist/dist-CBlqVBTk.js +0 -1
  181. package/dist/dist-CDcZ8WMF.js +0 -1
  182. package/dist/dist-CDksSmTD.mjs +0 -189
  183. package/dist/dist-CF-qVmmV.js +0 -1
  184. package/dist/dist-CIgGRTmJ.js +0 -1
  185. package/dist/dist-CJqVmdrU.js +0 -1
  186. package/dist/dist-COqM3IM6.mjs +0 -89
  187. package/dist/dist-CbWpCWog.mjs +0 -180
  188. package/dist/dist-CcGLWbPa.mjs +0 -19
  189. package/dist/dist-Cn4F8XlY.mjs +0 -220
  190. package/dist/dist-CoTs6T03.js +0 -1
  191. package/dist/dist-Co_xSt6d.js +0 -1
  192. package/dist/dist-Cu0GG-3j.mjs +0 -15
  193. package/dist/dist-DJqkhIXb.js +0 -1
  194. package/dist/dist-DKI-XYwI.mjs +0 -98
  195. package/dist/dist-DQeXXRYL.mjs +0 -201
  196. package/dist/dist-DW2ltK5-.js +0 -1
  197. package/dist/dist-DWcKY_sJ.js +0 -1
  198. package/dist/dist-DZiOPWLp.js +0 -1
  199. package/dist/dist-DdAeWIwf.js +0 -1
  200. package/dist/dist-DhubV_gU.mjs +0 -4
  201. package/dist/dist-DmY7elIQ.js +0 -1
  202. package/dist/dist-DoWtzxYc.mjs +0 -684
  203. package/dist/dist-DuQlxGyN.js +0 -1
  204. package/dist/dist-KFF7QKuL.js +0 -1
  205. package/dist/dist-RXrZgzkO.js +0 -1
  206. package/dist/dist-R_G5UQRm.js +0 -1
  207. package/dist/dist-dwRwxUPt.mjs +0 -22
  208. package/dist/dist-fzmUl3YX.mjs +0 -553
  209. package/dist/dist-hBsne-A2.mjs +0 -92
  210. package/dist/dist-ljiGYyay.mjs +0 -29
  211. package/dist/dist-pqMcQ1Nk.js +0 -1
  212. package/dist/dist-zmnQp5Xf.js +0 -1
  213. package/dist/dropdown-menu-ChuqZeix.js +0 -1
  214. package/dist/dropdown-menu-DU7KNoXP.mjs +0 -311
  215. package/dist/es2015-BooeZGhO.mjs +0 -554
  216. package/dist/es2015-Dggv0vx3.js +0 -41
  217. package/dist/floating-ui.react-dom-2hihjuTL.mjs +0 -1057
  218. package/dist/floating-ui.react-dom-BtFIezY4.js +0 -1
  219. package/dist/hover-card-BeqCs_2R.js +0 -1
  220. package/dist/hover-card-w8PmCyw2.mjs +0 -176
  221. package/dist/input-otp-Bn_Uy1mR.mjs +0 -398
  222. package/dist/input-otp-CTRB_0Xp.js +0 -20
  223. package/dist/label-Da0kELfR.mjs +0 -26
  224. package/dist/label-JMa1tFfC.js +0 -1
  225. package/dist/menubar-B7sRxpE4.mjs +0 -405
  226. package/dist/menubar-Bd-QKMcw.js +0 -1
  227. package/dist/message-scroller-B8AU0v3Y.mjs +0 -805
  228. package/dist/message-scroller-BJb4Mh_I.js +0 -1
  229. package/dist/navigation-menu-B-RwfscB.mjs +0 -638
  230. package/dist/navigation-menu-kPwxYZCR.js +0 -1
  231. package/dist/popover-Cq5cTNtC.js +0 -1
  232. package/dist/popover-T6Ra737i.mjs +0 -241
  233. package/dist/progress-e9YzxvRo.mjs +0 -90
  234. package/dist/progress-iUSEI7J9.js +0 -6
  235. package/dist/questionnaire-BLCvUX1C.mjs +0 -1137
  236. package/dist/questionnaire-CcymIPae.js +0 -1
  237. package/dist/radio-group-BKpiDcIb.mjs +0 -264
  238. package/dist/radio-group-DPEzCmxe.js +0 -1
  239. package/dist/resizable-ByF0NmN9.mjs +0 -2153
  240. package/dist/resizable-oL3v42zT.js +0 -1
  241. package/dist/rolldown-runtime-D7yIeQp2.mjs +0 -13
  242. package/dist/rolldown-runtime-DbbDpzbe.js +0 -1
  243. package/dist/scroll-area-BzNeOQ6C.mjs +0 -568
  244. package/dist/scroll-area-s4_ZJK59.js +0 -1
  245. package/dist/select-B_nRxX2Y.mjs +0 -831
  246. package/dist/select-j5_dph9S.js +0 -1
  247. package/dist/separator-Bn-3XUSJ.js +0 -1
  248. package/dist/separator-CCcMNS78.mjs +0 -38
  249. package/dist/sidebar-Cnem2n5A.js +0 -1
  250. package/dist/slider-B2PUTc7W.mjs +0 -484
  251. package/dist/slider-wZuXwuib.js +0 -1
  252. package/dist/switch-CD675xU7.js +0 -1
  253. package/dist/switch-ikzIzrme.mjs +0 -172
  254. package/dist/tabs-DCm5zOYB.mjs +0 -158
  255. package/dist/tabs-fcahDQDp.js +0 -1
  256. package/dist/theme-toggle-BGTJsIA-.js +0 -1
  257. package/dist/toast-C31v9P1K.js +0 -1
  258. package/dist/toast-vU5ISM03.mjs +0 -445
  259. package/dist/toaster-CaJyOCyC.js +0 -1
  260. package/dist/toggle-CSZdCCwX.js +0 -1
  261. package/dist/toggle-Cv9YYwLI.mjs +0 -58
  262. package/dist/toggle-group-RT8wyBwK.js +0 -1
  263. package/dist/toggle-group-qvjasXS-.mjs +0 -166
  264. package/dist/tooltip-7ERoN5mV.mjs +0 -386
  265. package/dist/tooltip-CC9_spXT.js +0 -1
@@ -1,1137 +0,0 @@
1
- import { n as e, r as t, t as n } from "./chunk-HBS6WEDP-DD8ZmxRM.mjs";
2
- import { t as r } from "./dist-DoWtzxYc.mjs";
3
- import { buttonVariants as i } from "./button.mjs";
4
- import { CheckIcon as a } from "lucide-react";
5
- import * as o from "react";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
- // ../../node_modules/.bun/@shadcn+react@0.3.1+0ac650c021fb1b59/node_modules/@shadcn/react/dist/questionnaire/index.js
8
- var l = o.createContext(null), u = o.createContext(null), d = o.createContext(null);
9
- function f(e) {
10
- let t = o.useContext(u);
11
- if (!t) throw Error(`${e} must be used within a Questionnaire.Root component.`);
12
- return t;
13
- }
14
- function p(e) {
15
- let t = o.useContext(l);
16
- if (!t) throw Error(`${e} must be used within a Questionnaire.Choice component.`);
17
- return t;
18
- }
19
- function m(e) {
20
- let t = o.useContext(d);
21
- if (!t) throw Error(`${e} must be used within a Questionnaire.Item component.`);
22
- return t;
23
- }
24
- function h(e) {
25
- return Array.isArray(e) ? e.some((e) => String(e).trim().length > 0) : e != null && String(e).trim().length > 0;
26
- }
27
- function g(e) {
28
- return e === "letters" ? Array.from({ length: 26 }, (e, t) => String.fromCharCode(65 + t)) : e === "numbers" ? Array.from({ length: 9 }, (e, t) => String(t + 1)) : [];
29
- }
30
- function _(e, t) {
31
- let n = t === "letters" ? e.toUpperCase() : e;
32
- return g(t).includes(n) ? n : null;
33
- }
34
- function v(e, t) {
35
- return [e, t ? "Enter" : null].filter(Boolean).join(" ") || void 0;
36
- }
37
- function y(e) {
38
- return e.type === "choice" ? e.element.checked : e.element.hasAttribute("name") && h(e.element.value);
39
- }
40
- function b(e) {
41
- return e?.type === "input" && [
42
- "email",
43
- "password",
44
- "search",
45
- "tel",
46
- "text",
47
- "url"
48
- ].includes(e.element.type) && !h(e.element.value);
49
- }
50
- function x(e) {
51
- return e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? !0 : e instanceof HTMLInputElement ? ![
52
- "button",
53
- "checkbox",
54
- "radio",
55
- "reset",
56
- "submit"
57
- ].includes(e.type) : e instanceof HTMLElement && e.isContentEditable;
58
- }
59
- function S(e) {
60
- return e instanceof HTMLInputElement && e.type === "radio";
61
- }
62
- function C(e, t) {
63
- if (e.element === t.element) return 0;
64
- let n = e.element.compareDocumentPosition(t.element);
65
- return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
66
- }
67
- function w(e, t) {
68
- if (e.element === t.element) return 0;
69
- let n = e.element.compareDocumentPosition(t.element);
70
- return n & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : n & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
71
- }
72
- function T({ checked: e, defaultChecked: t = !1, disabled: n = !1, onChange: r, value: i }) {
73
- let { disabled: a, hasInputAnswer: s, invalid: c, multiple: l, name: u, registerAnswerControl: d, registerAnswerSelection: f, required: p, resetVersion: h, selectedAnswerIds: g, setAnswerDefault: _, setAnswerSelectionFromInteraction: y, shortcutByAnswerId: b, shortcutByChoiceValue: x, status: S, syncControlledAnswerSelection: C } = m("Questionnaire.Choice"), w = o.useId(), [T, E] = o.useState(null), ee = o.useRef(t), D = e !== void 0, O = a || n, k = g.includes(w), A = D ? S !== "skipped" && e : k, j = l ? "checkbox" : "radio", M = x?.get(i) ?? b.get(w) ?? null;
74
- o.useLayoutEffect(() => f(w, ee.current), [w, f]), o.useLayoutEffect(() => _(w, t), [
75
- w,
76
- t,
77
- _
78
- ]), o.useLayoutEffect(() => {
79
- if (T) return d({
80
- disabled: O,
81
- element: T,
82
- id: w,
83
- ownDisabled: n,
84
- type: "choice",
85
- value: i
86
- });
87
- }, [
88
- w,
89
- n,
90
- O,
91
- T,
92
- d,
93
- i
94
- ]), o.useLayoutEffect(() => {
95
- D && C(w, e);
96
- }, [
97
- w,
98
- D,
99
- e,
100
- h,
101
- C
102
- ]), o.useLayoutEffect(() => {
103
- T && (T.defaultChecked = D ? e : t, h > 0 && (T.checked = A));
104
- }, [
105
- A,
106
- D,
107
- e,
108
- t,
109
- T,
110
- h
111
- ]);
112
- function N(t) {
113
- if (r?.(t), !t.defaultPrevented) {
114
- if (!D) {
115
- y(w, t.target.checked);
116
- return;
117
- }
118
- S === "skipped" && e === t.target.checked && y(w, e);
119
- }
120
- }
121
- let P = {
122
- checked: A,
123
- disabled: O,
124
- invalid: c,
125
- shortcut: M,
126
- type: j
127
- };
128
- return {
129
- inputProps: {
130
- ref: E,
131
- "aria-invalid": c || void 0,
132
- "aria-keyshortcuts": v(M, !O && A),
133
- checked: A,
134
- disabled: O,
135
- id: w,
136
- name: S === "skipped" ? void 0 : u,
137
- onChange: N,
138
- required: p && !l && !s,
139
- type: j,
140
- value: i
141
- },
142
- state: P
143
- };
144
- }
145
- function E({ defaultValue: e, disabled: n = !1, onChange: r, ref: i, type: a = "text", value: s }) {
146
- let { disabled: c, invalid: l, name: u, registerAnswerControl: d, registerAnswerSelection: f, resetVersion: p, selectedAnswerIds: g, setAnswerDefault: _, setAnswerSelectionFromInteraction: y, syncControlledAnswerSelection: b } = m("Questionnaire.Input"), x = o.useId(), S = o.useRef(null), C = o.useRef(h(e)), w = s !== void 0, T = h(e), E = h(s), [ee, D] = o.useState(T), O = c || n, k = w ? E : ee, A = g.includes(x);
147
- o.useLayoutEffect(() => f(x, C.current), [x, f]), o.useLayoutEffect(() => _(x, T), [
148
- T,
149
- x,
150
- _
151
- ]), o.useLayoutEffect(() => {
152
- let e = S.current;
153
- if (e) return d({
154
- disabled: O,
155
- element: e,
156
- id: x,
157
- type: "input"
158
- });
159
- }, [
160
- O,
161
- x,
162
- d
163
- ]), o.useLayoutEffect(() => {
164
- w ? b(x, E) : p > 0 && D(T);
165
- }, [
166
- w,
167
- E,
168
- s,
169
- T,
170
- x,
171
- p,
172
- b
173
- ]), o.useLayoutEffect(() => {
174
- let e = S.current;
175
- !e || !w || (e.defaultValue = String(s));
176
- }, [w, s]);
177
- function j(e) {
178
- if (r?.(e), e.defaultPrevented) return;
179
- let t = e.target.value.trim().length > 0;
180
- w || (D(t), y(x, t));
181
- }
182
- let M = {
183
- disabled: O,
184
- filled: k,
185
- invalid: l
186
- }, N = o.useCallback((e) => {
187
- S.current = e, t(i)?.(e);
188
- }, [i]);
189
- return {
190
- inputProps: {
191
- "aria-invalid": l || void 0,
192
- "aria-keyshortcuts": v(null, !O && k && A),
193
- defaultValue: w ? void 0 : e,
194
- disabled: O,
195
- form: A ? void 0 : "",
196
- id: x,
197
- name: A ? u : void 0,
198
- onChange: j,
199
- ref: N,
200
- type: a,
201
- value: w ? s : void 0
202
- },
203
- state: M
204
- };
205
- }
206
- function ee(e) {
207
- return e === void 0 ? null : {
208
- enabledItems: e.filter((e) => !e.disabled),
209
- itemByName: new Map(e.map((e) => [e.name, e])),
210
- items: e
211
- };
212
- }
213
- function D(e, t) {
214
- if (!e) return t ?? null;
215
- let n = t ? e.itemByName.get(t) : void 0;
216
- return n && !n.disabled ? n.name : e.enabledItems[0]?.name ?? null;
217
- }
218
- function O(e, t) {
219
- let n = /* @__PURE__ */ new Map();
220
- if (!e || !t) return n;
221
- let r = g(t), i = 0;
222
- for (let t of e.choices ?? []) {
223
- if (t.disabled) continue;
224
- let e = r[i];
225
- if (!e) break;
226
- n.set(t.value, e), i += 1;
227
- }
228
- return n;
229
- }
230
- function k(e, t) {
231
- let n = [], r = /* @__PURE__ */ new Set();
232
- for (let t of e.items) {
233
- r.has(t.name) && n.push(`Item name "${t.name}" is defined more than once.`), r.add(t.name);
234
- let e = /* @__PURE__ */ new Set();
235
- for (let r of t.choices ?? []) e.has(r.value) && n.push(`Choice value "${r.value}" is defined more than once in item "${t.name}".`), e.add(r.value);
236
- }
237
- if (t) {
238
- let r = e.itemByName.get(t);
239
- (!r || r.disabled) && n.push(`defaultItem "${t}" does not identify an enabled item. The first enabled item will be used instead.`);
240
- }
241
- return n;
242
- }
243
- function A(e, t, n) {
244
- let r = [], i = new Map(t.map((e) => [e.name, e]));
245
- for (let t of e.items) {
246
- let e = i.get(t.name);
247
- if (!e) {
248
- t.disabled || r.push(`Item "${t.name}" is defined but has no rendered Questionnaire.Item.`);
249
- continue;
250
- }
251
- e.disabled !== !!t.disabled && r.push(`Item "${t.name}" has different disabled values in Root.items and Questionnaire.Item.`), e.required !== !!t.required && r.push(`Item "${t.name}" has different required values in Root.items and Questionnaire.Item.`);
252
- let a = t.choices ?? [], o = new Map(a.map((e) => [e.value, e])), s = new Map(e.choices.map((e) => [e.value, e]));
253
- for (let e of a) {
254
- let n = s.get(e.value);
255
- n ? n.disabled !== !!e.disabled && r.push(`Choice "${e.value}" in item "${t.name}" has different disabled values in Root.items and Questionnaire.Choice.`) : r.push(`Choice "${e.value}" is defined for item "${t.name}" but has no rendered Questionnaire.Choice.`);
256
- }
257
- if (n) {
258
- for (let n of e.choices) o.has(n.value) || r.push(`Rendered choice "${n.value}" in item "${t.name}" is missing from Root.items and will not receive a shortcut.`);
259
- let n = a.filter((e) => !e.disabled).map((e) => e.value), i = e.choices.filter((e) => !e.disabled).map((e) => e.value);
260
- n.length > 0 && n.length === i.length && n.every((e) => i.includes(e)) && n.some((e, t) => e !== i[t]) && r.push(`Choice order for item "${t.name}" differs between Root.items and the rendered Questionnaire.Choice elements.`);
261
- }
262
- }
263
- for (let n of t) !n.disabled && !e.itemByName.has(n.name) && r.push(`Rendered item "${n.name}" is missing from Root.items and is excluded from the questionnaire collection.`);
264
- return r;
265
- }
266
- function j({ "aria-describedby": e, "aria-keyshortcuts": n, disabled: r = !1, invalid: i = !1, multiple: a = !1, name: s, onStatusChange: c, ref: l, required: u = !1 }) {
267
- let { activeItemName: d, domVersion: p, first: m, itemDefinitionByName: h, last: _, nativeValidation: v, registerItem: C, shortcuts: T } = f("Questionnaire.Item"), [E, ee] = o.useState(null), [D, k] = o.useState([]), [A, j] = o.useState(!1), [M, N] = o.useState([]), [P, F] = o.useState(!1), [I, L] = o.useState(0), [R, z] = o.useState([]), [te, B] = o.useState([]), V = o.useRef([]), ne = o.useRef(a), H = o.useRef(a);
268
- ne.current = a;
269
- let U = !r && d === s, W = o.useMemo(() => [...D].sort(w), [D, p]), G = o.useMemo(() => W.filter((e) => !e.disabled), [W]), K = G.some((e) => M.includes(e.id)), q = P ? "skipped" : K ? "answered" : "unanswered", J = q === "skipped" && !u, Y = r || J || !i && q === "answered", X = !r && !J && (i || A && !Y), re = G.some((e) => e.type === "input"), ie = o.useRef(q), ae = h?.get(s), Z = o.useMemo(() => h ? O(ae, T) : null, [
270
- ae,
271
- h,
272
- T
273
- ]), Q = o.useMemo(() => {
274
- if (Z) return /* @__PURE__ */ new Map();
275
- let e = g(T), t = G.filter((e) => e.type === "choice");
276
- return new Map(t.slice(0, e.length).map((t, n) => [t.id, e[n]]));
277
- }, [
278
- G,
279
- Z,
280
- T
281
- ]), oe = o.useCallback((e) => (k((t) => [...t.filter((t) => t.element !== e.element && t.id !== e.id), e]), () => {
282
- k((t) => t.filter((t) => t !== e));
283
- }), []);
284
- o.useLayoutEffect(() => {
285
- ie.current !== q && (ie.current = q, c?.(q));
286
- }, [c, q]);
287
- let $ = o.useCallback((e, t) => {
288
- N((n) => t ? a ? n.includes(e) ? n : [...n, e] : [e] : n.filter((t) => t !== e));
289
- }, [a]), se = o.useCallback((e, t) => {
290
- F(!1), $(e, t);
291
- }, [$]), ce = o.useCallback((e, t) => {
292
- t && F(!1), $(e, t);
293
- }, [$]), le = o.useCallback((e, t) => (t && (V.current = [...V.current.filter((t) => t !== e), e], N((t) => ne.current ? t.includes(e) ? t : [...t, e] : t.length ? t : [e])), () => {
294
- V.current = V.current.filter((t) => t !== e), N((t) => t.filter((t) => t !== e));
295
- }), []), ue = o.useCallback((e, t) => {
296
- t ? V.current = V.current.includes(e) ? V.current : [...V.current, e] : V.current = V.current.filter((t) => t !== e);
297
- }, []), de = o.useCallback((e) => (z((t) => t.includes(e) ? t : [...t, e]), () => {
298
- z((t) => t.filter((t) => t !== e));
299
- }), []), fe = o.useCallback((e) => (B((t) => t.includes(e) ? t : [...t, e]), () => {
300
- B((t) => t.filter((t) => t !== e));
301
- }), []), pe = o.useCallback(() => {
302
- if (j(!0), !Y) return !1;
303
- if (!v) return !0;
304
- let e = G.find((e) => y(e) && e.element.willValidate && !e.element.validity.valid);
305
- return !e || (e.element.focus(), e.element.reportValidity(), !1);
306
- }, [
307
- G,
308
- v,
309
- Y
310
- ]), me = o.useCallback(() => {
311
- E?.focus();
312
- }, [E]), he = o.useCallback(() => {
313
- let e = E?.querySelector("input[data-filled][name]:not(:disabled)"), t = E?.querySelector("input:not([type=hidden]):not(:disabled), textarea:not(:disabled)");
314
- (e ?? t ?? E)?.focus();
315
- }, [E]), ge = o.useCallback(() => {
316
- j(!1), F(!1), N(a ? [...V.current] : V.current.slice(0, 1)), L((e) => e + 1);
317
- }, [a]), _e = o.useCallback(() => {
318
- u || (N([]), F(!0));
319
- }, [u]);
320
- o.useLayoutEffect(() => {
321
- let e = H.current;
322
- H.current = a, e && !a && N((e) => {
323
- let t = G.find((t) => e.includes(t.id));
324
- return t ? [t.id] : [];
325
- });
326
- }, [G, a]);
327
- let ve = o.useCallback((e) => G.find((t) => t.element === e) ?? null, [G]), ye = o.useCallback((e) => {
328
- if (Z) {
329
- let t = Array.from(Z.entries()).find(([, t]) => t === e)?.[0];
330
- return G.find((e) => e.type === "choice" && e.value === t) ?? null;
331
- }
332
- let t = Array.from(Q.entries()).find(([, t]) => t === e)?.[0];
333
- return G.find((e) => e.id === t) ?? null;
334
- }, [
335
- G,
336
- Q,
337
- Z
338
- ]), be = o.useCallback((e, t) => {
339
- let n = G.findIndex((t) => t.element === e), r = n < 0 ? null : G[n] ?? null;
340
- if (!G.length || x(e) && !b(r) || n < 0 && e !== E) return !1;
341
- let i = n < 0 ? G.find(y) ?? (t === "next" ? G[0] : G[G.length - 1]) : G[(n + (t === "next" ? 1 : -1) + G.length) % G.length];
342
- return !i || i.element === e || n >= 0 && S(e) && S(i.element) ? !1 : (i.element.focus(), i.type === "choice" && S(i.element) && i.element.click(), !0);
343
- }, [G, E]);
344
- o.useLayoutEffect(() => {
345
- if (E) return C({
346
- choices: W.flatMap((e) => e.type === "choice" ? [{
347
- disabled: e.ownDisabled,
348
- value: e.value
349
- }] : []),
350
- disabled: r,
351
- element: E,
352
- focus: me,
353
- focusInvalid: he,
354
- getAnswerByElement: ve,
355
- getAnswerByShortcut: ye,
356
- moveAnswerFocus: be,
357
- name: s,
358
- required: u,
359
- reset: ge,
360
- skip: _e,
361
- status: q,
362
- validate: pe
363
- });
364
- }, [
365
- W,
366
- r,
367
- E,
368
- me,
369
- he,
370
- ve,
371
- ye,
372
- be,
373
- s,
374
- C,
375
- u,
376
- ge,
377
- _e,
378
- q,
379
- pe
380
- ]);
381
- let xe = o.useMemo(() => ({
382
- active: U,
383
- disabled: r,
384
- hasInputAnswer: re,
385
- invalid: X,
386
- multiple: a,
387
- name: s,
388
- registerAnswerControl: oe,
389
- registerAnswerSelection: le,
390
- registerDescription: de,
391
- registerError: fe,
392
- required: u,
393
- resetVersion: I,
394
- selectedAnswerIds: M,
395
- setAnswerDefault: ue,
396
- setAnswerSelectionFromInteraction: se,
397
- shortcutByAnswerId: Q,
398
- shortcutByChoiceValue: Z,
399
- shortcuts: T,
400
- status: q,
401
- syncControlledAnswerSelection: ce
402
- }), [
403
- U,
404
- r,
405
- re,
406
- X,
407
- a,
408
- s,
409
- oe,
410
- le,
411
- de,
412
- fe,
413
- u,
414
- I,
415
- M,
416
- ue,
417
- se,
418
- Q,
419
- Z,
420
- T,
421
- q,
422
- ce
423
- ]), Se = o.useCallback((e) => {
424
- ee(e), t(l)?.(e);
425
- }, [l]), Ce = [
426
- ...R,
427
- ...X ? te : [],
428
- e
429
- ].filter(Boolean).join(" ") || void 0, we = [
430
- n,
431
- U ? "Meta+Enter Control+Enter" : void 0,
432
- U && G.length ? "ArrowUp ArrowDown" : void 0,
433
- U && !m ? "ArrowLeft" : void 0,
434
- U && !_ && q !== "unanswered" ? "ArrowRight" : void 0
435
- ].filter(Boolean).join(" ") || void 0;
436
- return {
437
- context: xe,
438
- itemProps: {
439
- "aria-describedby": Ce,
440
- "aria-invalid": X || void 0,
441
- "aria-keyshortcuts": we,
442
- disabled: r,
443
- hidden: !U,
444
- inert: !U,
445
- ref: Se,
446
- tabIndex: -1
447
- },
448
- state: {
449
- active: U,
450
- disabled: r,
451
- invalid: X,
452
- multiple: a,
453
- required: u,
454
- status: q
455
- }
456
- };
457
- }
458
- function M({ defaultItem: e, item: n, items: r, noValidate: i, onItemChange: a, onReset: s, onSubmit: c, ref: l, shortcuts: u }) {
459
- let d = o.useMemo(() => ee(r), [r]), [f, p] = o.useState([]), [m, h] = o.useState(() => D(d, e)), [g, v] = o.useState(null), [b, w] = o.useState(0), T = o.useRef(null), E = n !== void 0, O = E ? n : m, j = o.useRef(O), M = i === !1, N = u ?? null, P = o.useRef(/* @__PURE__ */ new Set());
460
- o.useLayoutEffect(() => {
461
- if (process.env.NODE_ENV === "production") return;
462
- if (!d || !g) {
463
- P.current.clear();
464
- return;
465
- }
466
- let t = !1;
467
- return queueMicrotask(() => {
468
- if (t) return;
469
- let n = [...k(d, e), ...A(d, f, N)], r = new Set(n);
470
- r.forEach((e) => {
471
- P.current.has(e) || console.warn(`[Questionnaire] ${e}`);
472
- }), P.current = r;
473
- }), () => {
474
- t = !0;
475
- };
476
- }, [
477
- d,
478
- e,
479
- f,
480
- g,
481
- N
482
- ]), o.useLayoutEffect(() => {
483
- if (!g || typeof MutationObserver > "u") return;
484
- let e = new MutationObserver(() => {
485
- w((e) => e + 1);
486
- });
487
- return e.observe(g, {
488
- childList: !0,
489
- subtree: !0
490
- }), () => e.disconnect();
491
- }, [g]);
492
- let F = o.useMemo(() => f.filter((e) => !e.disabled).sort(C), [b, f]), I = o.useMemo(() => new Map(F.map((e) => [e.name, e])), [F]), L = d?.enabledItems ?? F, R = L.findIndex((e) => e.name === O), z = R < 0 || !O ? null : I.get(O) ?? null, te = O ? d?.itemByName.get(O) : void 0, B = R < 0 ? null : te ? !!te.required : z?.required ?? !1, V = R < 0 ? null : z?.status ?? (O ? "unanswered" : null), ne = o.useMemo(() => d ? d.enabledItems.flatMap((e) => {
493
- let t = I.get(e.name);
494
- return t ? [t] : [];
495
- }) : F, [
496
- d,
497
- I,
498
- F
499
- ]), H = L.length, U = R < 0 ? 0 : R + 1, W = H > 0 && R === 0, G = H > 0 && R === H - 1, K = o.useCallback((e, t = "item") => {
500
- e !== O && (T.current = {
501
- name: e,
502
- target: t
503
- }, E || h(e), a?.(e));
504
- }, [
505
- O,
506
- E,
507
- a
508
- ]);
509
- o.useLayoutEffect(() => {
510
- if (H === 0) return;
511
- if (R < 0) {
512
- if (!E && O === null) {
513
- h(L[0].name);
514
- return;
515
- }
516
- K(L[0].name);
517
- return;
518
- }
519
- let e = T.current, t = j.current !== O;
520
- j.current = O, !e || e.name !== O ? E && t && (T.current = null, z?.focus()) : (e.target === "invalid" ? z?.focusInvalid() : z?.focus(), T.current = null);
521
- }, [
522
- z,
523
- O,
524
- E,
525
- R,
526
- L,
527
- K,
528
- H
529
- ]);
530
- let q = o.useCallback((e) => (p((t) => [...t.filter((t) => t.element !== e.element && t.name !== e.name), e]), () => {
531
- p((t) => t.filter((t) => t !== e));
532
- }), []), J = o.useCallback(() => {
533
- R <= 0 || K(L[R - 1].name);
534
- }, [
535
- R,
536
- L,
537
- K
538
- ]), Y = o.useCallback(() => {
539
- if (!(!z || R >= H - 1)) {
540
- if (!z.validate()) {
541
- z.focusInvalid();
542
- return;
543
- }
544
- K(L[R + 1].name);
545
- }
546
- }, [
547
- z,
548
- R,
549
- L,
550
- K,
551
- H
552
- ]), X = o.useCallback(() => {
553
- if (z) {
554
- if (!z.validate()) {
555
- z.focusInvalid();
556
- return;
557
- }
558
- if (G) {
559
- g?.requestSubmit();
560
- return;
561
- }
562
- K(L[R + 1].name);
563
- }
564
- }, [
565
- z,
566
- R,
567
- G,
568
- L,
569
- g,
570
- K
571
- ]), re = o.useCallback(() => {
572
- if (z && !z.required) {
573
- if (z.skip(), !G) {
574
- K(L[R + 1].name);
575
- return;
576
- }
577
- queueMicrotask(() => {
578
- g?.requestSubmit();
579
- });
580
- }
581
- }, [
582
- z,
583
- R,
584
- G,
585
- L,
586
- g,
587
- K
588
- ]);
589
- function ie(t) {
590
- if (s?.(t), t.defaultPrevented) return;
591
- for (let e of f) e.reset();
592
- let n = d ? D(d, e) : F.find((t) => t.name === e)?.name ?? F[0]?.name;
593
- n && K(n);
594
- }
595
- function ae(e) {
596
- let t = ne.find((e) => !e.validate());
597
- t ? (e.preventDefault(), K(t.name, "invalid"), t.name === O && (t.focusInvalid(), T.current = null)) : c?.(e);
598
- }
599
- function Z(e) {
600
- if (e.defaultPrevented || e.nativeEvent.isComposing || e.keyCode === 229 || !z || !(e.target instanceof Element)) return;
601
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey) {
602
- e.preventDefault(), e.repeat || X();
603
- return;
604
- }
605
- if (e.metaKey || e.ctrlKey || e.altKey) return;
606
- if ((e.key === "ArrowUp" || e.key === "ArrowDown") && z.moveAnswerFocus(e.target, e.key === "ArrowDown" ? "next" : "previous")) {
607
- e.preventDefault();
608
- return;
609
- }
610
- if ((e.key === "ArrowLeft" || e.key === "ArrowRight") && !x(e.target) && !S(e.target)) {
611
- if (e.preventDefault(), e.repeat) return;
612
- e.key === "ArrowLeft" ? J() : z.status !== "unanswered" && Y();
613
- return;
614
- }
615
- if (e.key === "Enter") {
616
- let t = z.getAnswerByElement(e.target);
617
- if (!t) return;
618
- e.preventDefault(), !e.repeat && y(t) && X();
619
- return;
620
- }
621
- if (!N || x(e.target)) return;
622
- let t = _(e.key, N), n = t ? z.getAnswerByShortcut(t) : null;
623
- n && (e.preventDefault(), !e.repeat && (n.element.focus(), n.type === "choice" && n.element.click()));
624
- }
625
- let Q = {
626
- current: U,
627
- first: W,
628
- last: G,
629
- total: H
630
- }, oe = o.useMemo(() => ({
631
- ...Q,
632
- activeItem: z,
633
- activeItemName: O,
634
- activeItemRequired: B,
635
- activeItemStatus: V,
636
- domVersion: b,
637
- goNext: Y,
638
- goPrevious: J,
639
- itemDefinitionByName: d?.itemByName ?? null,
640
- nativeValidation: M,
641
- registerItem: q,
642
- shortcuts: N,
643
- skipCurrent: re
644
- }), [
645
- z,
646
- O,
647
- B,
648
- V,
649
- d,
650
- U,
651
- b,
652
- W,
653
- Y,
654
- J,
655
- G,
656
- M,
657
- q,
658
- N,
659
- re,
660
- H
661
- ]), $ = o.useCallback((e) => {
662
- v(e), t(l)?.(e);
663
- }, [l]);
664
- return {
665
- context: oe,
666
- rootProps: {
667
- "data-shortcuts": N ?? void 0,
668
- onKeyDown: Z,
669
- onReset: ie,
670
- onSubmit: ae,
671
- ref: $
672
- },
673
- state: Q
674
- };
675
- }
676
- function N({ defaultItem: t, item: r, items: i, noValidate: a = !0, onItemChange: o, onReset: c, onSubmit: l, ref: d, shortcuts: f, ...p }) {
677
- let { context: m, rootProps: h, state: g } = M({
678
- defaultItem: t,
679
- item: r,
680
- items: i,
681
- noValidate: a,
682
- onItemChange: o,
683
- onReset: c,
684
- onSubmit: l,
685
- ref: d,
686
- shortcuts: f
687
- }), _ = n({
688
- defaultTagName: "form",
689
- props: e({
690
- ...h,
691
- noValidate: a
692
- }, p),
693
- state: g
694
- });
695
- return s(u.Provider, {
696
- value: m,
697
- children: _
698
- });
699
- }
700
- function P({ children: t, render: r, ...i }) {
701
- let { current: a, first: o, last: s, total: c } = f("Questionnaire.Progress"), l = c ? `Question ${a} of ${c}` : void 0;
702
- return n({
703
- defaultTagName: "div",
704
- props: e({
705
- "aria-label": "Questionnaire progress",
706
- "aria-live": "polite",
707
- "aria-valuemax": c || void 0,
708
- "aria-valuemin": c ? 1 : void 0,
709
- "aria-valuenow": c ? a : void 0,
710
- "aria-valuetext": l,
711
- children: t ?? l,
712
- role: "progressbar"
713
- }, i),
714
- render: r,
715
- state: {
716
- current: a,
717
- first: o,
718
- last: s,
719
- total: c
720
- }
721
- });
722
- }
723
- function F({ "aria-describedby": t, "aria-keyshortcuts": r, children: i, disabled: a = !1, invalid: o = !1, multiple: c = !1, name: l, onStatusChange: u, ref: f, required: p = !1, ...m }) {
724
- let { context: h, itemProps: g, state: _ } = j({
725
- "aria-describedby": t,
726
- "aria-keyshortcuts": r,
727
- disabled: a,
728
- invalid: o,
729
- multiple: c,
730
- name: l,
731
- onStatusChange: u,
732
- ref: f,
733
- required: p
734
- }), v = n({
735
- defaultTagName: "fieldset",
736
- props: e({
737
- ...g,
738
- children: i
739
- }, m),
740
- state: _,
741
- stateAttributesMapping: { active: (e) => ({ "data-active": e ? "" : void 0 }) }
742
- });
743
- return s(d.Provider, {
744
- value: h,
745
- children: v
746
- });
747
- }
748
- function I({ render: e, ...t }) {
749
- return m("Questionnaire.Title"), n({
750
- defaultTagName: "legend",
751
- props: t,
752
- render: e
753
- });
754
- }
755
- function L({ id: t, render: r, ...i }) {
756
- let { registerDescription: a } = m("Questionnaire.Description"), s = o.useId(), c = t ?? s;
757
- return o.useLayoutEffect(() => a(c), [c, a]), n({
758
- defaultTagName: "p",
759
- props: e({ id: c }, i),
760
- render: r
761
- });
762
- }
763
- function R({ render: e, ...t }) {
764
- let { shortcuts: r } = m("Questionnaire.Choices");
765
- return n({
766
- defaultTagName: "div",
767
- props: t,
768
- render: e,
769
- state: { shortcuts: r }
770
- });
771
- }
772
- function z({ checked: t, children: r, defaultChecked: i = !1, disabled: a = !1, onChange: o, render: c, value: u, ...d }) {
773
- let { inputProps: f, state: p } = T({
774
- checked: t,
775
- defaultChecked: i,
776
- disabled: a,
777
- onChange: o,
778
- value: u
779
- }), m = n({
780
- defaultTagName: "label",
781
- props: e({ children: r }, d),
782
- render: c,
783
- state: p,
784
- stateAttributesMapping: { checked: (e) => ({
785
- "data-checked": e ? "" : void 0,
786
- "data-unchecked": e ? void 0 : ""
787
- }) }
788
- });
789
- return s(l.Provider, {
790
- value: {
791
- inputProps: f,
792
- state: p
793
- },
794
- children: m
795
- });
796
- }
797
- function te({ render: t, ...r }) {
798
- let { inputProps: i, state: a } = p("Questionnaire.ChoiceInput");
799
- return n({
800
- defaultTagName: "input",
801
- props: e(i, r),
802
- render: t,
803
- state: a,
804
- stateAttributesMapping: { checked: (e) => ({
805
- "data-checked": e ? "" : void 0,
806
- "data-unchecked": e ? void 0 : ""
807
- }) }
808
- });
809
- }
810
- function B({ render: e, ...t }) {
811
- return p("Questionnaire.ChoiceLabel"), n({
812
- defaultTagName: "span",
813
- props: t,
814
- render: e
815
- });
816
- }
817
- function V({ children: t, render: r, ...i }) {
818
- let { state: a } = p("Questionnaire.ChoiceShortcut"), o = { shortcut: a.shortcut };
819
- return n({
820
- defaultTagName: "span",
821
- props: e({
822
- "aria-hidden": !0,
823
- children: t ?? a.shortcut,
824
- hidden: a.shortcut === null
825
- }, i),
826
- render: r,
827
- state: o
828
- });
829
- }
830
- function ne({ defaultValue: t, disabled: r = !1, onChange: i, ref: a, render: o, type: s = "text", value: c, ...l }) {
831
- let { inputProps: u, state: d } = E({
832
- defaultValue: t,
833
- disabled: r,
834
- onChange: i,
835
- ref: a,
836
- type: s,
837
- value: c
838
- });
839
- return n({
840
- defaultTagName: "input",
841
- props: e(u, l),
842
- render: o,
843
- state: d,
844
- stateAttributesMapping: { filled: (e) => ({
845
- "data-empty": e ? void 0 : "",
846
- "data-filled": e ? "" : void 0
847
- }) }
848
- });
849
- }
850
- function H({ children: t, id: r, render: i, ...a }) {
851
- let { invalid: s, registerError: c, required: l } = m("Questionnaire.Error"), u = o.useId(), d = r ?? u;
852
- return o.useLayoutEffect(() => c(d), [d, c]), n({
853
- defaultTagName: "p",
854
- props: e({
855
- children: t ?? (l ? "Choose an answer to continue." : "Choose an answer or skip this question."),
856
- hidden: !s,
857
- id: d,
858
- role: s ? "alert" : void 0
859
- }, a),
860
- render: i,
861
- state: { invalid: s }
862
- });
863
- }
864
- function U({ children: e, disabled: t = !1, onClick: n, render: r, tabIndex: i, type: a = "button", ...o }) {
865
- let s = f("Questionnaire.Previous"), c = s.total > 1 && !s.first;
866
- function l(e) {
867
- n?.(e), e.defaultPrevented || s.goPrevious();
868
- }
869
- return q({
870
- children: e ?? "Previous",
871
- disabled: t,
872
- onClick: l,
873
- props: o,
874
- render: r,
875
- status: s.activeItemStatus,
876
- tabIndex: i,
877
- type: a,
878
- visible: c
879
- });
880
- }
881
- function W({ children: e, disabled: t = !1, onClick: n, render: r, tabIndex: i, type: a = "button", ...o }) {
882
- let s = f("Questionnaire.Skip"), c = s.activeItemRequired === !1;
883
- function l(e) {
884
- n?.(e), e.defaultPrevented || s.skipCurrent();
885
- }
886
- return q({
887
- children: e ?? "Skip",
888
- disabled: t,
889
- onClick: l,
890
- props: o,
891
- render: r,
892
- status: s.activeItemStatus,
893
- tabIndex: i,
894
- type: a,
895
- visible: c
896
- });
897
- }
898
- function G({ children: e, disabled: t = !1, onClick: n, render: r, tabIndex: i, type: a = "button", ...o }) {
899
- let s = f("Questionnaire.Next"), c = s.total > 1 && !s.last;
900
- function l(e) {
901
- n?.(e), e.defaultPrevented || s.goNext();
902
- }
903
- return q({
904
- children: e ?? "Next",
905
- disabled: t,
906
- onClick: l,
907
- props: o,
908
- render: r,
909
- shortcut: "Enter",
910
- status: s.activeItemStatus,
911
- tabIndex: i,
912
- type: a,
913
- visible: c
914
- });
915
- }
916
- function K({ children: e, disabled: t = !1, render: n, tabIndex: r, type: i = "submit", ...a }) {
917
- let o = f("Questionnaire.Submit"), s = o.total > 0 && o.last;
918
- return q({
919
- children: e ?? "Submit",
920
- disabled: t,
921
- props: a,
922
- render: n,
923
- shortcut: "Enter",
924
- status: o.activeItemStatus,
925
- tabIndex: r,
926
- type: i,
927
- visible: s
928
- });
929
- }
930
- function q({ children: t, disabled: r, onClick: i, props: a, render: o, shortcut: s, status: c, tabIndex: l, type: u, visible: d }) {
931
- let f = d && !r ? s ?? null : null, p = {
932
- disabled: r,
933
- shortcut: f,
934
- status: c,
935
- visible: d
936
- };
937
- return n({
938
- defaultTagName: "button",
939
- props: e({
940
- "aria-hidden": !d || void 0,
941
- "aria-keyshortcuts": f ?? void 0,
942
- children: t,
943
- disabled: r,
944
- hidden: !d,
945
- inert: !d,
946
- onClick: i,
947
- tabIndex: d ? l : -1,
948
- type: u
949
- }, a),
950
- render: o,
951
- state: p,
952
- stateAttributesMapping: { visible: (e) => ({
953
- "data-hidden": e ? void 0 : "",
954
- "data-visible": e ? "" : void 0
955
- }) }
956
- });
957
- }
958
- var J = {
959
- Root: N,
960
- Progress: P,
961
- Item: F,
962
- Title: I,
963
- Description: L,
964
- Choices: R,
965
- Choice: z,
966
- ChoiceInput: te,
967
- ChoiceLabel: B,
968
- ChoiceShortcut: V,
969
- Input: ne,
970
- Error: H,
971
- Previous: U,
972
- Skip: W,
973
- Next: G,
974
- Submit: K
975
- };
976
- // src/questionnaire.tsx
977
- function Y({ className: e, ...t }) {
978
- return /* @__PURE__ */ s(J.Root, {
979
- "data-slot": "questionnaire",
980
- className: r("flex w-full min-w-0 flex-col gap-4", e),
981
- ...t
982
- });
983
- }
984
- function X({ className: e, ...t }) {
985
- return /* @__PURE__ */ s(J.Progress, {
986
- "data-slot": "questionnaire-progress",
987
- className: r("text-muted-foreground min-h-[1lh] w-fit min-w-[14ch] text-xs font-medium tabular-nums", e),
988
- ...t
989
- });
990
- }
991
- function re({ className: e, ...t }) {
992
- return /* @__PURE__ */ s(J.Item, {
993
- "data-slot": "questionnaire-item",
994
- className: r("flex min-w-0 flex-col gap-4 border-0 p-0 outline-none", e),
995
- ...t
996
- });
997
- }
998
- function ie({ className: e, ...t }) {
999
- return /* @__PURE__ */ s(J.Title, {
1000
- "data-slot": "questionnaire-title",
1001
- className: r("text-base leading-snug font-medium text-pretty [&:not(:has(~[data-slot=questionnaire-description]))]:mb-4", e),
1002
- ...t
1003
- });
1004
- }
1005
- function ae({ className: e, ...t }) {
1006
- return /* @__PURE__ */ s(J.Description, {
1007
- "data-slot": "questionnaire-description",
1008
- className: r("text-muted-foreground text-sm text-pretty", e),
1009
- ...t
1010
- });
1011
- }
1012
- function Z({ className: e, ...t }) {
1013
- return /* @__PURE__ */ s(J.Choices, {
1014
- "data-slot": "questionnaire-choices",
1015
- className: r("group/questionnaire-choices grid min-w-0 gap-2", e),
1016
- ...t
1017
- });
1018
- }
1019
- function Q({ children: e, className: t, ...n }) {
1020
- return /* @__PURE__ */ c(J.Choice, {
1021
- "data-slot": "questionnaire-choice",
1022
- className: r("group/questionnaire-choice border-input hover:bg-muted/50 has-[>input:focus-visible]:border-ring has-[>input:focus-visible]:ring-ring/50 data-invalid:border-destructive dark:bg-input/20 data-checked:border-primary/40 data-checked:bg-muted dark:data-checked:bg-muted relative flex min-h-11 cursor-pointer items-start gap-2.5 rounded-lg border bg-transparent px-3 py-2.5 text-start text-sm transition-colors outline-none select-none has-[>input:focus-visible]:ring-3", "data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50", t),
1023
- ...n,
1024
- children: [
1025
- /* @__PURE__ */ s(J.ChoiceInput, {
1026
- "data-slot": "questionnaire-choice-input",
1027
- className: "absolute inset-0 z-10 size-full cursor-pointer opacity-0"
1028
- }),
1029
- /* @__PURE__ */ c("span", {
1030
- "aria-hidden": "true",
1031
- "data-slot": "questionnaire-choice-indicator",
1032
- className: "border-input group-data-checked/questionnaire-choice:border-primary group-data-checked/questionnaire-choice:bg-primary group-data-checked/questionnaire-choice:text-primary-foreground dark:bg-input/30 dark:group-data-checked/questionnaire-choice:bg-primary pointer-events-none relative flex size-4 shrink-0 translate-y-[--spacing(0.45)] items-center justify-center rounded-[4px] border group-has-data-[slot=questionnaire-choice-description]/questionnaire-choice:translate-y-0.5 group-data-[type=radio]/questionnaire-choice:rounded-full",
1033
- children: [/* @__PURE__ */ s("span", {
1034
- "data-slot": "questionnaire-choice-indicator-dot",
1035
- className: "bg-primary-foreground hidden size-2 rounded-full group-data-checked/questionnaire-choice:block group-data-[type=checkbox]/questionnaire-choice:hidden"
1036
- }), /* @__PURE__ */ s(a, {
1037
- "data-slot": "questionnaire-choice-indicator-check",
1038
- className: "hidden size-3.5 group-data-checked/questionnaire-choice:block group-data-[type=radio]/questionnaire-choice:hidden"
1039
- })]
1040
- }),
1041
- /* @__PURE__ */ s(J.ChoiceLabel, {
1042
- "data-slot": "questionnaire-choice-label",
1043
- className: "flex min-w-0 flex-1 flex-col gap-0.5 leading-snug",
1044
- children: e
1045
- }),
1046
- /* @__PURE__ */ s(J.ChoiceShortcut, {
1047
- "data-slot": "questionnaire-choice-shortcut",
1048
- className: "border-input bg-background text-muted-foreground pointer-events-none ms-auto hidden size-5 shrink-0 translate-y-[--spacing(0.45)] items-center justify-center rounded-md border font-mono text-[0.625rem] leading-none font-medium group-has-data-[slot=questionnaire-choice-description]/questionnaire-choice:translate-y-0.5 group-data-[shortcut]/questionnaire-choice:inline-flex"
1049
- })
1050
- ]
1051
- });
1052
- }
1053
- function oe({ className: e, ...t }) {
1054
- return /* @__PURE__ */ s("span", {
1055
- "data-slot": "questionnaire-choice-description",
1056
- className: r("text-muted-foreground", e),
1057
- ...t
1058
- });
1059
- }
1060
- function $({ className: e, ...t }) {
1061
- return /* @__PURE__ */ s("div", {
1062
- "data-slot": "questionnaire-input-wrapper",
1063
- className: "group/questionnaire-input relative w-full min-w-0",
1064
- children: /* @__PURE__ */ s(J.Input, {
1065
- "data-slot": "questionnaire-input",
1066
- className: r("border-input focus-visible:border-ring focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 h-8 min-h-11 w-full min-w-0 rounded-lg border bg-transparent px-2.5 py-1 text-base transition-[color,box-shadow,background-color] outline-none focus-visible:ring-3 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3 sm:min-h-0 md:text-sm", "selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground", e),
1067
- ...t
1068
- })
1069
- });
1070
- }
1071
- function se({ className: e, ...t }) {
1072
- return /* @__PURE__ */ s(J.Error, {
1073
- "data-slot": "questionnaire-error",
1074
- className: r("text-destructive mt-2 text-sm", e),
1075
- ...t
1076
- });
1077
- }
1078
- function ce({ className: e, ...t }) {
1079
- return /* @__PURE__ */ s("div", {
1080
- "data-slot": "questionnaire-actions",
1081
- className: r("grid min-h-11 w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:min-h-8", e),
1082
- ...t
1083
- });
1084
- }
1085
- function le({ children: e, className: t, size: n = "default", variant: a = "outline", ...o }) {
1086
- return /* @__PURE__ */ s(J.Previous, {
1087
- "data-slot": "questionnaire-previous",
1088
- "data-size": n,
1089
- "data-variant": a,
1090
- className: r(i({
1091
- size: n,
1092
- variant: a
1093
- }), "col-start-1 row-start-1 min-h-11 justify-self-start sm:min-h-0", t),
1094
- ...o,
1095
- children: e ?? "Previous"
1096
- });
1097
- }
1098
- function ue({ children: e, className: t, size: n = "default", variant: a = "outline", ...o }) {
1099
- return /* @__PURE__ */ s(J.Skip, {
1100
- "data-slot": "questionnaire-skip",
1101
- "data-size": n,
1102
- "data-variant": a,
1103
- className: r(i({
1104
- size: n,
1105
- variant: a
1106
- }), "col-start-2 row-start-1 min-h-11 justify-self-end sm:min-h-0", t),
1107
- ...o,
1108
- children: e ?? "Skip"
1109
- });
1110
- }
1111
- function de({ children: e, className: t, size: n = "default", variant: a = "default", ...o }) {
1112
- return /* @__PURE__ */ s(J.Next, {
1113
- "data-slot": "questionnaire-next",
1114
- "data-size": n,
1115
- "data-variant": a,
1116
- className: r(i({
1117
- size: n,
1118
- variant: a
1119
- }), "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0", t),
1120
- ...o,
1121
- children: e ?? "Next"
1122
- });
1123
- }
1124
- function fe({ children: e, className: t, size: n = "default", variant: a = "default", ...o }) {
1125
- return /* @__PURE__ */ s(J.Submit, {
1126
- "data-slot": "questionnaire-submit",
1127
- "data-size": n,
1128
- "data-variant": a,
1129
- className: r(i({
1130
- size: n,
1131
- variant: a
1132
- }), "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0", t),
1133
- ...o,
1134
- children: e ?? "Submit"
1135
- });
1136
- }
1137
- export { Z as a, $ as c, le as d, X as f, ie as h, oe as i, re as l, fe as m, ce as n, ae as o, ue as p, Q as r, se as s, Y as t, de as u };