@gv-tech/ui-web 2.29.1 → 2.29.3

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