@asanchez-sa/abby 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +217 -2
- package/dist/_virtual/_rolldown/runtime.js +26 -0
- package/dist/agents/approvals.d.ts +46 -0
- package/dist/agents/approvals.js +58 -0
- package/dist/agents/changes.d.ts +21 -0
- package/dist/agents/changes.js +21 -0
- package/dist/agents/hooks.d.ts +20 -0
- package/dist/agents/hooks.js +58 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/index.js +9 -0
- package/dist/agents/run-tool.d.ts +44 -0
- package/dist/agents/run-tool.js +79 -0
- package/dist/agents/ui-sdk.d.ts +5 -0
- package/dist/agents/ui-sdk.js +3 -0
- package/dist/behaviors/canvas/index.d.ts +2 -0
- package/dist/behaviors/canvas/index.js +1 -0
- package/dist/behaviors/canvas/ui-sdk.d.ts +2 -0
- package/dist/behaviors/canvas/ui-sdk.js +1 -0
- package/dist/behaviors/drag-and-drop/index.d.ts +2 -0
- package/dist/behaviors/drag-and-drop/index.js +1 -0
- package/dist/behaviors/drag-and-drop/ui-sdk.d.ts +2 -0
- package/dist/behaviors/drag-and-drop/ui-sdk.js +1 -0
- package/dist/behaviors/dragging/index.d.ts +2 -0
- package/dist/behaviors/dragging/index.js +1 -0
- package/dist/behaviors/dragging/ui-sdk.d.ts +2 -0
- package/dist/behaviors/dragging/ui-sdk.js +1 -0
- package/dist/behaviors/focus/index.d.ts +2 -0
- package/dist/behaviors/focus/index.js +1 -0
- package/dist/behaviors/focus/ui-sdk.d.ts +2 -0
- package/dist/behaviors/focus/ui-sdk.js +1 -0
- package/dist/behaviors/lists/index.d.ts +3 -0
- package/dist/behaviors/lists/index.js +3 -0
- package/dist/behaviors/lists/ui-sdk.d.ts +3 -0
- package/dist/behaviors/lists/ui-sdk.js +3 -0
- package/dist/behaviors/popups/index.d.ts +3 -0
- package/dist/behaviors/popups/index.js +3 -0
- package/dist/behaviors/popups/ui-sdk.d.ts +3 -0
- package/dist/behaviors/popups/ui-sdk.js +3 -0
- package/dist/behaviors/preferences/index.d.ts +3 -0
- package/dist/behaviors/preferences/index.js +3 -0
- package/dist/behaviors/preferences/ui-sdk.d.ts +3 -0
- package/dist/behaviors/preferences/ui-sdk.js +3 -0
- package/dist/behaviors/selection/index.d.ts +3 -0
- package/dist/behaviors/selection/index.js +3 -0
- package/dist/behaviors/selection/indicator.d.ts +13 -0
- package/dist/behaviors/selection/indicator.js +20 -0
- package/dist/behaviors/selection/ui-sdk.d.ts +2 -0
- package/dist/behaviors/selection/ui-sdk.js +1 -0
- package/dist/behaviors/transitions/index.d.ts +3 -0
- package/dist/behaviors/transitions/index.js +3 -0
- package/dist/behaviors/transitions/ui-sdk.d.ts +3 -0
- package/dist/behaviors/transitions/ui-sdk.js +3 -0
- package/dist/behaviors/trees/index.d.ts +2 -0
- package/dist/behaviors/trees/index.js +1 -0
- package/dist/behaviors/trees/ui-sdk.d.ts +2 -0
- package/dist/behaviors/trees/ui-sdk.js +1 -0
- package/dist/components/accordion/accordion.d.ts +13 -0
- package/dist/components/accordion/accordion.js +165 -0
- package/dist/components/alert/alert.d.ts +13 -0
- package/dist/components/alert/alert.js +131 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +15 -0
- package/dist/components/alert-dialog/alert-dialog.js +257 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +7 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +57 -0
- package/dist/components/attachment/attachment.d.ts +48 -0
- package/dist/components/attachment/attachment.js +372 -0
- package/dist/components/autocomplete/autocomplete.d.ts +32 -0
- package/dist/components/autocomplete/autocomplete.js +466 -0
- package/dist/components/avatar/avatar.d.ts +6 -0
- package/dist/components/avatar/avatar.js +100 -0
- package/dist/components/avatar-group/avatar-group.d.ts +9 -0
- package/dist/components/avatar-group/avatar-group.js +75 -0
- package/dist/components/badge/badge.d.ts +15 -0
- package/dist/components/badge/badge.js +31 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +24 -0
- package/dist/components/breadcrumb/breadcrumb.js +279 -0
- package/dist/components/bubble/bubble.d.ts +26 -0
- package/dist/components/bubble/bubble.js +173 -0
- package/dist/components/button/button.d.ts +18 -0
- package/dist/components/button/button.js +91 -0
- package/dist/components/button-group/button-group.d.ts +15 -0
- package/dist/components/button-group/button-group.js +71 -0
- package/dist/components/calendar/calendar.d.ts +29 -0
- package/dist/components/calendar/calendar.js +453 -0
- package/dist/components/card/card.d.ts +14 -0
- package/dist/components/card/card.js +213 -0
- package/dist/components/carousel/carousel.d.ts +16 -0
- package/dist/components/carousel/carousel.js +364 -0
- package/dist/components/chain-of-thought/chain-of-thought.d.ts +72 -0
- package/dist/components/chain-of-thought/chain-of-thought.js +491 -0
- package/dist/components/chat/chat.d.ts +48 -0
- package/dist/components/chat/chat.js +207 -0
- package/dist/components/checkbox/checkbox.d.ts +10 -0
- package/dist/components/checkbox/checkbox.js +118 -0
- package/dist/components/checkpoint/checkpoint.d.ts +24 -0
- package/dist/components/checkpoint/checkpoint.js +178 -0
- package/dist/components/choice-cards/choice-cards.d.ts +38 -0
- package/dist/components/choice-cards/choice-cards.js +255 -0
- package/dist/components/code-block/code-block.d.ts +58 -0
- package/dist/components/code-block/code-block.js +506 -0
- package/dist/components/code-block/highlighter.js +96 -0
- package/dist/components/code-block/use-highlighted-code.d.ts +11 -0
- package/dist/components/code-block/use-highlighted-code.js +54 -0
- package/dist/components/collapsible/collapsible.d.ts +10 -0
- package/dist/components/collapsible/collapsible.js +92 -0
- package/dist/components/color-picker/color-picker.d.ts +17 -0
- package/dist/components/color-picker/color-picker.js +395 -0
- package/dist/components/combobox/combobox.d.ts +54 -0
- package/dist/components/combobox/combobox.js +683 -0
- package/dist/components/command/command.d.ts +23 -0
- package/dist/components/command/command.js +373 -0
- package/dist/components/command-dock/command-dock.d.ts +118 -0
- package/dist/components/command-dock/command-dock.js +944 -0
- package/dist/components/confirmation/confirmation.d.ts +58 -0
- package/dist/components/confirmation/confirmation.js +181 -0
- package/dist/components/context/context.d.ts +82 -0
- package/dist/components/context/context.js +490 -0
- package/dist/components/date-input/date-input.d.ts +16 -0
- package/dist/components/date-input/date-input.js +89 -0
- package/dist/components/date-picker/date-picker.d.ts +28 -0
- package/dist/components/date-picker/date-picker.js +361 -0
- package/dist/components/dialog/dialog.d.ts +14 -0
- package/dist/components/dialog/dialog.js +261 -0
- package/dist/components/drawer/drawer.d.ts +16 -0
- package/dist/components/drawer/drawer.js +309 -0
- package/dist/components/empty/empty.d.ts +18 -0
- package/dist/components/empty/empty.js +192 -0
- package/dist/components/field/field.d.ts +15 -0
- package/dist/components/field/field.js +261 -0
- package/dist/components/file-input/file-input.d.ts +12 -0
- package/dist/components/file-input/file-input.js +216 -0
- package/dist/components/file-tree/file-tree.d.ts +45 -0
- package/dist/components/file-tree/file-tree.js +283 -0
- package/dist/components/hover-card/hover-card.d.ts +10 -0
- package/dist/components/hover-card/hover-card.js +118 -0
- package/dist/components/icon/icon.d.ts +14 -0
- package/dist/components/icon/icon.js +60 -0
- package/dist/components/image-cropper/image-cropper.d.ts +15 -0
- package/dist/components/image-cropper/image-cropper.js +334 -0
- package/dist/components/inline-citation/inline-citation.d.ts +46 -0
- package/dist/components/inline-citation/inline-citation.js +269 -0
- package/dist/components/input/input.d.ts +9 -0
- package/dist/components/input/input.js +43 -0
- package/dist/components/input-group/input-group.d.ts +42 -0
- package/dist/components/input-group/input-group.js +192 -0
- package/dist/components/item/item.d.ts +32 -0
- package/dist/components/item/item.js +394 -0
- package/dist/components/kbd/kbd.d.ts +9 -0
- package/dist/components/kbd/kbd.js +75 -0
- package/dist/components/label/label.d.ts +6 -0
- package/dist/components/label/label.js +40 -0
- package/dist/components/link/link.d.ts +21 -0
- package/dist/components/link/link.js +126 -0
- package/dist/components/listbox/listbox.d.ts +20 -0
- package/dist/components/listbox/listbox.js +199 -0
- package/dist/components/marker/marker.d.ts +11 -0
- package/dist/components/marker/marker.js +88 -0
- package/dist/components/menu/menu.d.ts +38 -0
- package/dist/components/menu/menu.js +553 -0
- package/dist/components/menubar/menubar.d.ts +9 -0
- package/dist/components/menubar/menubar.js +47 -0
- package/dist/components/message/message.d.ts +44 -0
- package/dist/components/message/message.js +328 -0
- package/dist/components/message-scroller/message-scroller.d.ts +111 -0
- package/dist/components/message-scroller/message-scroller.js +957 -0
- package/dist/components/meter/meter.d.ts +8 -0
- package/dist/components/meter/meter.js +162 -0
- package/dist/components/model-selector/model-selector.d.ts +155 -0
- package/dist/components/model-selector/model-selector.js +905 -0
- package/dist/components/native-select/native-select.d.ts +27 -0
- package/dist/components/native-select/native-select.js +226 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +29 -0
- package/dist/components/navigation-menu/navigation-menu.js +318 -0
- package/dist/components/not-label.js +9 -0
- package/dist/components/note-editor/blocks.d.ts +22 -0
- package/dist/components/note-editor/blocks.js +245 -0
- package/dist/components/note-editor/diff.d.ts +19 -0
- package/dist/components/note-editor/diff.js +64 -0
- package/dist/components/note-editor/editor.js +249 -0
- package/dist/components/note-editor/note-editor.d.ts +109 -0
- package/dist/components/note-editor/note-editor.js +954 -0
- package/dist/components/note-editor/parts/comments.d.ts +24 -0
- package/dist/components/note-editor/parts/comments.js +336 -0
- package/dist/components/note-editor/parts/header.d.ts +25 -0
- package/dist/components/note-editor/parts/header.js +263 -0
- package/dist/components/note-editor/parts/history.d.ts +56 -0
- package/dist/components/note-editor/parts/history.js +409 -0
- package/dist/components/note-editor/parts/presence.d.ts +31 -0
- package/dist/components/note-editor/parts/presence.js +140 -0
- package/dist/components/note-editor/parts/suggestions.d.ts +45 -0
- package/dist/components/note-editor/parts/suggestions.js +316 -0
- package/dist/components/note-editor/parts/toolbar.d.ts +38 -0
- package/dist/components/note-editor/parts/toolbar.js +683 -0
- package/dist/components/note-editor/people.d.ts +84 -0
- package/dist/components/note-editor/people.js +276 -0
- package/dist/components/note-editor/person.d.ts +11 -0
- package/dist/components/note-editor/person.js +15 -0
- package/dist/components/note-place/note-place.d.ts +42 -0
- package/dist/components/note-place/note-place.js +256 -0
- package/dist/components/note-status/note-status.d.ts +59 -0
- package/dist/components/note-status/note-status.js +380 -0
- package/dist/components/number-input/number-input.d.ts +12 -0
- package/dist/components/number-input/number-input.js +252 -0
- package/dist/components/otp-input/otp-input.d.ts +12 -0
- package/dist/components/otp-input/otp-input.js +136 -0
- package/dist/components/pagination/pagination.d.ts +23 -0
- package/dist/components/pagination/pagination.js +218 -0
- package/dist/components/password-input/password-input.d.ts +11 -0
- package/dist/components/password-input/password-input.js +117 -0
- package/dist/components/plan/plan.d.ts +51 -0
- package/dist/components/plan/plan.js +320 -0
- package/dist/components/popover/popover.d.ts +16 -0
- package/dist/components/popover/popover.js +268 -0
- package/dist/components/preferences/preferences.d.ts +5 -0
- package/dist/components/preferences/preferences.js +18 -0
- package/dist/components/progress/progress.d.ts +8 -0
- package/dist/components/progress/progress.js +162 -0
- package/dist/components/prompt-input/prompt-input.d.ts +247 -0
- package/dist/components/prompt-input/prompt-input.js +1367 -0
- package/dist/components/questionnaire/questionnaire.d.ts +174 -0
- package/dist/components/questionnaire/questionnaire.js +1628 -0
- package/dist/components/queue/queue.d.ts +82 -0
- package/dist/components/queue/queue.js +471 -0
- package/dist/components/radio/radio.d.ts +7 -0
- package/dist/components/radio/radio.js +101 -0
- package/dist/components/rating/rating.d.ts +10 -0
- package/dist/components/rating/rating.js +95 -0
- package/dist/components/reasoning/reasoning.d.ts +50 -0
- package/dist/components/reasoning/reasoning.js +233 -0
- package/dist/components/resizable/resizable.d.ts +6 -0
- package/dist/components/resizable/resizable.js +100 -0
- package/dist/components/scroll-area/scroll-area.d.ts +17 -0
- package/dist/components/scroll-area/scroll-area.js +211 -0
- package/dist/components/segmented-control/segmented-control.d.ts +16 -0
- package/dist/components/segmented-control/segmented-control.js +142 -0
- package/dist/components/select/select.d.ts +43 -0
- package/dist/components/select/select.js +577 -0
- package/dist/components/separator/separator.d.ts +4 -0
- package/dist/components/separator/separator.js +38 -0
- package/dist/components/sheet/sheet.d.ts +24 -0
- package/dist/components/sheet/sheet.js +330 -0
- package/dist/components/sidebar/sidebar.d.ts +138 -0
- package/dist/components/sidebar/sidebar.js +1374 -0
- package/dist/components/skeleton/skeleton.d.ts +4 -0
- package/dist/components/skeleton/skeleton.js +40 -0
- package/dist/components/slider/slider.d.ts +9 -0
- package/dist/components/slider/slider.js +193 -0
- package/dist/components/sources/sources.d.ts +35 -0
- package/dist/components/sources/sources.js +209 -0
- package/dist/components/spinner/spinner.d.ts +11 -0
- package/dist/components/spinner/spinner.js +59 -0
- package/dist/components/stack-trace/parse-stack-trace.d.ts +21 -0
- package/dist/components/stack-trace/parse-stack-trace.js +61 -0
- package/dist/components/stack-trace/stack-trace.d.ts +79 -0
- package/dist/components/stack-trace/stack-trace.js +434 -0
- package/dist/components/subagent/subagent.d.ts +71 -0
- package/dist/components/subagent/subagent.js +450 -0
- package/dist/components/suggestion/suggestion.d.ts +21 -0
- package/dist/components/suggestion/suggestion.js +130 -0
- package/dist/components/switch/switch.d.ts +6 -0
- package/dist/components/switch/switch.js +70 -0
- package/dist/components/table/table.d.ts +19 -0
- package/dist/components/table/table.js +284 -0
- package/dist/components/table-of-contents/spy.js +84 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +92 -0
- package/dist/components/table-of-contents/table-of-contents.js +787 -0
- package/dist/components/tabs/tabs.d.ts +25 -0
- package/dist/components/tabs/tabs.js +273 -0
- package/dist/components/task/task.d.ts +40 -0
- package/dist/components/task/task.js +262 -0
- package/dist/components/terminal/terminal.d.ts +82 -0
- package/dist/components/terminal/terminal.js +457 -0
- package/dist/components/test-results/test-results.d.ts +127 -0
- package/dist/components/test-results/test-results.js +687 -0
- package/dist/components/textarea/textarea.d.ts +8 -0
- package/dist/components/textarea/textarea.js +43 -0
- package/dist/components/time-input/time-input.d.ts +7 -0
- package/dist/components/time-input/time-input.js +82 -0
- package/dist/components/timeline/timeline.d.ts +19 -0
- package/dist/components/timeline/timeline.js +247 -0
- package/dist/components/toast/toast.d.ts +12 -0
- package/dist/components/toast/toast.js +285 -0
- package/dist/components/toggle/toggle.d.ts +15 -0
- package/dist/components/toggle/toggle.js +137 -0
- package/dist/components/token-input/token-input.d.ts +7 -0
- package/dist/components/token-input/token-input.js +117 -0
- package/dist/components/tool/tool.d.ts +66 -0
- package/dist/components/tool/tool.js +413 -0
- package/dist/components/toolbar/toolbar.d.ts +91 -0
- package/dist/components/toolbar/toolbar.js +655 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/components/tooltip/tooltip.js +97 -0
- package/dist/components/trace/trace.d.ts +31 -0
- package/dist/components/trace/trace.js +309 -0
- package/dist/components/tree/tree.d.ts +13 -0
- package/dist/components/tree/tree.js +258 -0
- package/dist/components/trigger-menu/trigger-menu.d.ts +30 -0
- package/dist/components/trigger-menu/trigger-menu.js +352 -0
- package/dist/components/usage/usage.d.ts +132 -0
- package/dist/components/usage/usage.js +1368 -0
- package/dist/components/waterfall/waterfall.d.ts +20 -0
- package/dist/components/waterfall/waterfall.js +360 -0
- package/dist/components/week-strip/week-strip.d.ts +177 -0
- package/dist/components/week-strip/week-strip.js +1081 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.js +27 -0
- package/dist/core/ui-sdk.d.ts +3 -0
- package/dist/core/ui-sdk.js +3 -0
- package/dist/core/use-primitive-state.d.ts +14 -0
- package/dist/core/use-primitive-state.js +25 -0
- package/dist/styles/LICENSE-shadcn.md +21 -0
- package/dist/styles/color-scheme.css +32 -0
- package/dist/styles/components.css +303 -0
- package/dist/styles/index.css +41 -0
- package/dist/styles/tokens.css +474 -0
- package/dist/styles/typeset/shadcn.css +506 -0
- package/dist/styles/typeset.css +70 -0
- package/dist/styles/utilities.css +555 -0
- package/dist/tools/observe/index.d.ts +2 -0
- package/dist/tools/observe/index.js +3 -0
- package/dist/tools/observe/ui-sdk.d.ts +1 -0
- package/dist/tools/observe/ui-sdk.js +2 -0
- package/dist/tools/testing/check-agent.d.ts +28 -0
- package/dist/tools/testing/check-agent.js +42 -0
- package/dist/tools/testing/index.d.ts +4 -0
- package/dist/tools/testing/index.js +4 -0
- package/dist/tools/testing/ui-sdk.d.ts +1 -0
- package/dist/tools/testing/ui-sdk.js +2 -0
- package/dist/utilities/cn/index.d.ts +12 -0
- package/dist/utilities/cn/index.js +47 -0
- package/dist/utilities/color/index.d.ts +2 -0
- package/dist/utilities/color/index.js +3 -0
- package/dist/utilities/color/ui-sdk.d.ts +1 -0
- package/dist/utilities/color/ui-sdk.js +2 -0
- package/dist/utilities/date/index.d.ts +2 -0
- package/dist/utilities/date/index.js +6 -0
- package/dist/utilities/date/ui-sdk.d.ts +1 -0
- package/dist/utilities/date/ui-sdk.js +2 -0
- package/dist/utilities/image/index.d.ts +2 -0
- package/dist/utilities/image/index.js +3 -0
- package/dist/utilities/image/ui-sdk.d.ts +1 -0
- package/dist/utilities/image/ui-sdk.js +2 -0
- package/dist/utilities/mobile/index.d.ts +2 -0
- package/dist/utilities/mobile/index.js +1 -0
- package/dist/utilities/mobile/ui-sdk.d.ts +2 -0
- package/dist/utilities/mobile/ui-sdk.js +1 -0
- package/dist/utilities/number/index.d.ts +2 -0
- package/dist/utilities/number/index.js +3 -0
- package/dist/utilities/number/ui-sdk.d.ts +1 -0
- package/dist/utilities/number/ui-sdk.js +2 -0
- package/dist/utilities/platform/index.d.ts +3 -0
- package/dist/utilities/platform/index.js +14 -0
- package/dist/utilities/platform/ui-sdk.d.ts +3 -0
- package/dist/utilities/platform/ui-sdk.js +3 -0
- package/dist/utilities/storage/index.d.ts +2 -0
- package/dist/utilities/storage/index.js +1 -0
- package/dist/utilities/storage/ui-sdk.d.ts +2 -0
- package/dist/utilities/storage/ui-sdk.js +1 -0
- package/dist/utilities/text/index.d.ts +3 -0
- package/dist/utilities/text/index.js +3 -0
- package/dist/utilities/text/ui-sdk.d.ts +3 -0
- package/dist/utilities/text/ui-sdk.js +3 -0
- package/package.json +192 -4
- package/skills/agent-ready-ui/SKILL.md +229 -0
- package/skills/blocks/SKILL.md +262 -0
- package/skills/compose-screens/SKILL.md +354 -0
- package/skills/note-editor/SKILL.md +493 -0
- package/skills/note-status/SKILL.md +295 -0
- package/skills/setup/SKILL.md +136 -0
- package/skills/theming/SKILL.md +216 -0
- package/src/blocks/notes/adapters.ts +77 -0
- package/src/blocks/notes/data.ts +508 -0
- package/src/blocks/notes/notes-block.tsx +244 -0
- package/src/blocks/notes/parts/home.tsx +219 -0
- package/src/blocks/notes/parts/no-access.tsx +84 -0
- package/src/blocks/notes/parts/note-screen.tsx +412 -0
- package/src/blocks/notes/parts/notes-sidebar.tsx +277 -0
- package/src/blocks/notes/parts/panels.tsx +393 -0
- package/src/blocks/notes/parts/place.ts +15 -0
- package/src/blocks/notes/parts/review-dialog.tsx +159 -0
- package/src/blocks/notes/parts/share.tsx +172 -0
- package/src/blocks/notes/texts.ts +135 -0
- package/src/blocks/shell/adapters.ts +69 -0
- package/src/blocks/shell/data.ts +281 -0
- package/src/blocks/shell/parts/compose.tsx +292 -0
- package/src/blocks/shell/parts/home.tsx +203 -0
- package/src/blocks/shell/parts/marks.tsx +144 -0
- package/src/blocks/shell/parts/rail.tsx +166 -0
- package/src/blocks/shell/parts/rooms-column.tsx +326 -0
- package/src/blocks/shell/shell-block.tsx +210 -0
- package/src/blocks/shell/texts.ts +80 -0
|
@@ -0,0 +1,1628 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { checkedAttrs, createChange, definePrimitive, elements, idPart } from "../../core/ui-sdk.js";
|
|
3
|
+
import { usePrimitiveState } from "../../core/use-primitive-state.js";
|
|
4
|
+
import { core_exports } from "../../core/index.js";
|
|
5
|
+
import { cn, cnState } from "../../utilities/cn/index.js";
|
|
6
|
+
import "../../utilities/platform/index.js";
|
|
7
|
+
import { buttonVariants } from "../button/button.js";
|
|
8
|
+
import { Checkbox, CheckboxGroup, CheckboxIndicator } from "../checkbox/checkbox.js";
|
|
9
|
+
import { isRTL } from "../../utilities/platform/ui-sdk.js";
|
|
10
|
+
import { Input } from "../input/input.js";
|
|
11
|
+
import { Radio, RadioGroup, RadioIndicator } from "../radio/radio.js";
|
|
12
|
+
import { c } from "react/compiler-runtime";
|
|
13
|
+
import { Children, createContext, isValidElement, use, useId } from "react";
|
|
14
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { Progress } from "@ui-sdk/react/progress";
|
|
16
|
+
// src/components/questionnaire/questionnaire.tsx
|
|
17
|
+
const fromDefinitions = (items = []) => items.map((item) => ({
|
|
18
|
+
name: item.name,
|
|
19
|
+
required: Boolean(item.required),
|
|
20
|
+
disabled: Boolean(item.disabled),
|
|
21
|
+
multiple: Boolean(item.multiple),
|
|
22
|
+
choices: (item.choices ?? []).map((choice) => ({
|
|
23
|
+
value: choice.value,
|
|
24
|
+
disabled: Boolean(choice.disabled)
|
|
25
|
+
}))
|
|
26
|
+
}));
|
|
27
|
+
const enabledOf = (state) => state.items.filter((item) => !item.disabled);
|
|
28
|
+
const infoOf = (state, name) => state.items.find((item) => item.name === name);
|
|
29
|
+
const answersOf = (state, name) => state.values[name] ?? [];
|
|
30
|
+
function positionOf(state) {
|
|
31
|
+
const enabled = enabledOf(state);
|
|
32
|
+
const index = enabled.findIndex((item) => item.name === state.item);
|
|
33
|
+
return {
|
|
34
|
+
current: index + 1,
|
|
35
|
+
total: enabled.length,
|
|
36
|
+
first: index <= 0,
|
|
37
|
+
last: index === enabled.length - 1
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** The checked choices. Before its choices are known, every answer counts as one. */
|
|
41
|
+
function chosenOf(state, name, strict = false) {
|
|
42
|
+
const known = infoOf(state, name)?.choices ?? [];
|
|
43
|
+
const answers = answersOf(state, name);
|
|
44
|
+
if (known.length === 0) return strict ? [] : answers;
|
|
45
|
+
return answers.filter((answer) => known.some((choice) => choice.value === answer));
|
|
46
|
+
}
|
|
47
|
+
/** The freeform answer: the one that isn't a choice. */
|
|
48
|
+
function textOf(state, name) {
|
|
49
|
+
const info = infoOf(state, name);
|
|
50
|
+
if (!info) return "";
|
|
51
|
+
const answers = answersOf(state, name);
|
|
52
|
+
if (info.choices.length === 0) return answers[0] ?? "";
|
|
53
|
+
return answers.find((answer) => !info.choices.some((choice) => choice.value === answer)) ?? "";
|
|
54
|
+
}
|
|
55
|
+
function statusOf(state, name) {
|
|
56
|
+
if (answersOf(state, name).length > 0) return "answered";
|
|
57
|
+
return state.skipped.includes(name) ? "skipped" : "unanswered";
|
|
58
|
+
}
|
|
59
|
+
function validOf(state, info) {
|
|
60
|
+
const status = statusOf(state, info.name);
|
|
61
|
+
return info.disabled || status === "answered" || !info.required && status === "skipped";
|
|
62
|
+
}
|
|
63
|
+
function shortcutOf(state, name, value) {
|
|
64
|
+
if (!state.shortcuts) return void 0;
|
|
65
|
+
const index = (infoOf(state, name)?.choices ?? []).filter((choice) => !choice.disabled).findIndex((choice) => choice.value === value);
|
|
66
|
+
if (index === -1) return void 0;
|
|
67
|
+
if (state.shortcuts === "numbers") return index < 9 ? String(index + 1) : void 0;
|
|
68
|
+
return index < 26 ? String.fromCharCode(65 + index) : void 0;
|
|
69
|
+
}
|
|
70
|
+
const without = (list, entry) => list.filter((other) => other !== entry);
|
|
71
|
+
const withEntry = (list, entry) => list.includes(entry) ? list : [...list, entry];
|
|
72
|
+
const present = (on) => on ? "" : void 0;
|
|
73
|
+
const ANSWER = "[data-slot=\"radio\"]:not([data-disabled]),[data-slot=\"checkbox\"]:not([data-disabled]),[data-slot=\"input\"]:not([data-disabled])";
|
|
74
|
+
const TYPING = "input, textarea, select, [contenteditable]";
|
|
75
|
+
/**
|
|
76
|
+
* Not exported: its inferred type names ui-sdk types that aren't public, so
|
|
77
|
+
* the declaration build can't describe it from another module.
|
|
78
|
+
*/
|
|
79
|
+
const questionnaire = definePrimitive({
|
|
80
|
+
name: "questionnaire",
|
|
81
|
+
options: {
|
|
82
|
+
item: "string",
|
|
83
|
+
defaultItem: "string",
|
|
84
|
+
onItemChange: "callback",
|
|
85
|
+
values: "value",
|
|
86
|
+
defaultValues: "value",
|
|
87
|
+
onValuesChange: "callback",
|
|
88
|
+
items: "value",
|
|
89
|
+
shortcuts: "string",
|
|
90
|
+
noValidate: "boolean"
|
|
91
|
+
},
|
|
92
|
+
controlled: ["item", "values"],
|
|
93
|
+
state: (options) => {
|
|
94
|
+
const items = fromDefinitions(options.items);
|
|
95
|
+
return {
|
|
96
|
+
item: options.item ?? options.defaultItem ?? items.find((item) => !item.disabled)?.name ?? null,
|
|
97
|
+
values: options.values ?? options.defaultValues ?? {},
|
|
98
|
+
items,
|
|
99
|
+
skipped: [],
|
|
100
|
+
invalid: [],
|
|
101
|
+
described: [],
|
|
102
|
+
shortcuts: options.shortcuts ?? null,
|
|
103
|
+
noValidate: options.noValidate ?? true
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
sync: (options) => ({
|
|
107
|
+
...options.item === void 0 ? {} : { item: options.item },
|
|
108
|
+
...options.values === void 0 ? {} : { values: options.values },
|
|
109
|
+
shortcuts: options.shortcuts ?? null,
|
|
110
|
+
noValidate: options.noValidate ?? true
|
|
111
|
+
}),
|
|
112
|
+
api: (context) => {
|
|
113
|
+
const { store } = context;
|
|
114
|
+
const change = createChange(context);
|
|
115
|
+
const get = () => store.get();
|
|
116
|
+
const view = () => context.element("root")?.ownerDocument.defaultView;
|
|
117
|
+
const afterRender = (run) => view()?.requestAnimationFrame(run);
|
|
118
|
+
const focusItem = (name) => afterRender(() => context.element("item", name)?.focus());
|
|
119
|
+
const focusAnswer = (name) => afterRender(() => {
|
|
120
|
+
const el = context.element("item", name);
|
|
121
|
+
(el?.querySelector("[data-slot=\"radio\"][data-checked]:not([data-disabled])") ?? el?.querySelector(ANSWER) ?? el)?.focus();
|
|
122
|
+
});
|
|
123
|
+
const collect = () => {
|
|
124
|
+
const parts = elements(context, "item");
|
|
125
|
+
const choices = elements(context, "choice");
|
|
126
|
+
const items = parts.length === 0 ? fromDefinitions(context.options().items) : parts.map(({ props }) => ({
|
|
127
|
+
name: props.value,
|
|
128
|
+
required: Boolean(props.required),
|
|
129
|
+
disabled: Boolean(props.disabled),
|
|
130
|
+
multiple: Boolean(props.multiple),
|
|
131
|
+
choices: choices.filter((choice) => choice.props.item === props.value).map((choice) => ({
|
|
132
|
+
value: choice.props.value,
|
|
133
|
+
disabled: Boolean(choice.props.disabled)
|
|
134
|
+
}))
|
|
135
|
+
}));
|
|
136
|
+
if (JSON.stringify(items) !== JSON.stringify(get().items)) store.set({ items });
|
|
137
|
+
const state = get();
|
|
138
|
+
const enabled = enabledOf(state);
|
|
139
|
+
if (enabled.some((item) => item.name === state.item) || enabled.length === 0) return;
|
|
140
|
+
const from = state.items.findIndex((item) => item.name === state.item);
|
|
141
|
+
const wanted = context.options().defaultItem;
|
|
142
|
+
const next = from === -1 ? enabled.find((item) => item.name === wanted) ?? enabled[0] : state.items.slice(from).find((item) => !item.disabled) ?? enabled.at(-1);
|
|
143
|
+
if (!next) return;
|
|
144
|
+
if (from === -1 && context.options().item === void 0) store.set({ item: next.name });
|
|
145
|
+
else change("item", next.name, { reason: "item-removed" });
|
|
146
|
+
};
|
|
147
|
+
let scheduled = false;
|
|
148
|
+
const schedule = () => {
|
|
149
|
+
if (scheduled) return;
|
|
150
|
+
scheduled = true;
|
|
151
|
+
queueMicrotask(() => {
|
|
152
|
+
scheduled = false;
|
|
153
|
+
collect();
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
context.onOptions(schedule);
|
|
157
|
+
const track = (el) => {
|
|
158
|
+
schedule();
|
|
159
|
+
const Observer = el.ownerDocument.defaultView?.MutationObserver;
|
|
160
|
+
const observer = Observer ? new Observer(schedule) : void 0;
|
|
161
|
+
observer?.observe(el, {
|
|
162
|
+
attributes: true,
|
|
163
|
+
attributeFilter: [
|
|
164
|
+
"data-disabled",
|
|
165
|
+
"data-required",
|
|
166
|
+
"data-multiple"
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
return () => {
|
|
170
|
+
observer?.disconnect();
|
|
171
|
+
schedule();
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
let statuses = /* @__PURE__ */ new Map();
|
|
175
|
+
context.onDestroy(store.subscribe(() => {
|
|
176
|
+
const state = get();
|
|
177
|
+
const next = new Map(state.items.map((item) => [item.name, statusOf(state, item.name)]));
|
|
178
|
+
const before = statuses;
|
|
179
|
+
statuses = next;
|
|
180
|
+
for (const [name, status] of next) {
|
|
181
|
+
if ((before.get(name) ?? "unanswered") === status) continue;
|
|
182
|
+
context.props("item", name)?.onStatusChange?.(status);
|
|
183
|
+
}
|
|
184
|
+
}));
|
|
185
|
+
const write = (name, answers, details) => {
|
|
186
|
+
const values = { ...get().values };
|
|
187
|
+
if (answers.length > 0) values[name] = answers;
|
|
188
|
+
else delete values[name];
|
|
189
|
+
const changed = change("values", values, details);
|
|
190
|
+
if (changed) {
|
|
191
|
+
const state = get();
|
|
192
|
+
store.set({
|
|
193
|
+
skipped: without(state.skipped, name),
|
|
194
|
+
invalid: answers.length > 0 ? without(state.invalid, name) : state.invalid
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return changed;
|
|
198
|
+
};
|
|
199
|
+
const setChoices = (name, chosen, details) => {
|
|
200
|
+
const state = get();
|
|
201
|
+
const text = textOf(state, name);
|
|
202
|
+
if (!infoOf(state, name)?.multiple) return write(name, chosen.length > 0 ? chosen.slice(-1) : text ? [text] : [], details);
|
|
203
|
+
return write(name, text ? [...chosen, text] : chosen, details);
|
|
204
|
+
};
|
|
205
|
+
const setText = (name, text, details) => {
|
|
206
|
+
const state = get();
|
|
207
|
+
const chosen = chosenOf(state, name, true);
|
|
208
|
+
if (!infoOf(state, name)?.multiple) return write(name, text ? [text] : chosen, details);
|
|
209
|
+
return write(name, text ? [...chosen, text] : chosen, details);
|
|
210
|
+
};
|
|
211
|
+
const choose = (name, value, event) => {
|
|
212
|
+
const state = get();
|
|
213
|
+
const info = infoOf(state, name);
|
|
214
|
+
const choice = info?.choices.find((other) => other.value === value);
|
|
215
|
+
if (!info || !choice || choice.disabled) return false;
|
|
216
|
+
const chosen = chosenOf(state, name, true);
|
|
217
|
+
const next = !info.multiple ? [value] : chosen.includes(value) ? without(chosen, value) : [...chosen, value];
|
|
218
|
+
return setChoices(name, next, {
|
|
219
|
+
reason: "item-press",
|
|
220
|
+
event
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
const goTo = (name, details = { reason: "imperative" }) => {
|
|
224
|
+
const state = get();
|
|
225
|
+
const info = infoOf(state, name);
|
|
226
|
+
if (!info || info.disabled) return false;
|
|
227
|
+
if (state.item === name) return true;
|
|
228
|
+
const changed = change("item", name, details);
|
|
229
|
+
if (changed) focusItem(name);
|
|
230
|
+
return changed;
|
|
231
|
+
};
|
|
232
|
+
const check = (name) => {
|
|
233
|
+
const state = get();
|
|
234
|
+
const info = infoOf(state, name);
|
|
235
|
+
if (!info || validOf(state, info)) {
|
|
236
|
+
if (state.invalid.includes(name)) store.set({ invalid: without(state.invalid, name) });
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
store.set({ invalid: withEntry(state.invalid, name) });
|
|
240
|
+
focusAnswer(name);
|
|
241
|
+
return false;
|
|
242
|
+
};
|
|
243
|
+
const neighbor = (step) => {
|
|
244
|
+
const state = get();
|
|
245
|
+
const enabled = enabledOf(state);
|
|
246
|
+
const index = enabled.findIndex((item) => item.name === state.item);
|
|
247
|
+
return index === -1 ? void 0 : enabled[index + step]?.name;
|
|
248
|
+
};
|
|
249
|
+
const next = (event) => {
|
|
250
|
+
const active = get().item;
|
|
251
|
+
const target = neighbor(1);
|
|
252
|
+
if (!active || !check(active) || !target) return false;
|
|
253
|
+
return goTo(target, {
|
|
254
|
+
reason: "next-press",
|
|
255
|
+
event
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
const previous = (event) => {
|
|
259
|
+
const target = neighbor(-1);
|
|
260
|
+
return target ? goTo(target, {
|
|
261
|
+
reason: "previous-press",
|
|
262
|
+
event
|
|
263
|
+
}) : false;
|
|
264
|
+
};
|
|
265
|
+
const skip = (event) => {
|
|
266
|
+
const state = get();
|
|
267
|
+
const name = state.item;
|
|
268
|
+
const info = name ? infoOf(state, name) : void 0;
|
|
269
|
+
if (!name || !info || info.required) return false;
|
|
270
|
+
if (!write(name, [], {
|
|
271
|
+
reason: "skip-press",
|
|
272
|
+
event
|
|
273
|
+
})) return false;
|
|
274
|
+
const after = get();
|
|
275
|
+
store.set({
|
|
276
|
+
skipped: withEntry(after.skipped, name),
|
|
277
|
+
invalid: without(after.invalid, name)
|
|
278
|
+
});
|
|
279
|
+
const target = neighbor(1);
|
|
280
|
+
if (target) goTo(target, {
|
|
281
|
+
reason: "skip-press",
|
|
282
|
+
event
|
|
283
|
+
});
|
|
284
|
+
return true;
|
|
285
|
+
};
|
|
286
|
+
const form = () => context.element("root");
|
|
287
|
+
let explicit = false;
|
|
288
|
+
const submit = () => {
|
|
289
|
+
explicit = true;
|
|
290
|
+
try {
|
|
291
|
+
form()?.requestSubmit();
|
|
292
|
+
} finally {
|
|
293
|
+
explicit = false;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
/** Whether every enabled item is valid. Opens the first one that isn't. */
|
|
297
|
+
const validate = (event) => {
|
|
298
|
+
const state = get();
|
|
299
|
+
const invalid = enabledOf(state).filter((item) => !validOf(state, item)).map((item) => item.name);
|
|
300
|
+
store.set({ invalid });
|
|
301
|
+
const first = invalid[0];
|
|
302
|
+
if (!first) return true;
|
|
303
|
+
if (first !== state.item) change("item", first, {
|
|
304
|
+
reason: "validation",
|
|
305
|
+
event
|
|
306
|
+
});
|
|
307
|
+
focusAnswer(first);
|
|
308
|
+
return false;
|
|
309
|
+
};
|
|
310
|
+
const start = { ...get() };
|
|
311
|
+
/** Back to how it started: the first item, its default answers, nothing skipped or invalid. */
|
|
312
|
+
const restore = () => {
|
|
313
|
+
const state = get();
|
|
314
|
+
const wanted = context.options().defaultItem;
|
|
315
|
+
const enabled = enabledOf(state);
|
|
316
|
+
const first = (enabled.find((item) => item.name === wanted) ?? enabled[0])?.name;
|
|
317
|
+
change("values", context.options().defaultValues ?? start.values, { reason: "reset" });
|
|
318
|
+
if (first && first !== state.item) change("item", first, { reason: "reset" });
|
|
319
|
+
store.set({
|
|
320
|
+
skipped: [],
|
|
321
|
+
invalid: []
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
const proceed = (event) => positionOf(get()).last ? submit() : next(event);
|
|
325
|
+
let continued = false;
|
|
326
|
+
const settle = (event) => {
|
|
327
|
+
if (explicit || positionOf(get()).last) return validate(event);
|
|
328
|
+
continued = true;
|
|
329
|
+
queueMicrotask(() => continued = false);
|
|
330
|
+
next();
|
|
331
|
+
return false;
|
|
332
|
+
};
|
|
333
|
+
const keydown = (event) => {
|
|
334
|
+
const state = get();
|
|
335
|
+
const name = state.item;
|
|
336
|
+
const target = event.target;
|
|
337
|
+
if (!name || !target || event.isComposing || continued) return;
|
|
338
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
339
|
+
event.preventDefault();
|
|
340
|
+
proceed(event);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (event.metaKey || event.ctrlKey || event.altKey) return;
|
|
344
|
+
const typing = target.matches(TYPING);
|
|
345
|
+
if (event.key === "Enter") {
|
|
346
|
+
if (!target.matches("input")) return;
|
|
347
|
+
event.preventDefault();
|
|
348
|
+
proceed(event);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (typing) return;
|
|
352
|
+
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
353
|
+
if (target.closest("[role=\"radio\"]")) return;
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
if (!(event.key === "ArrowRight" !== isRTL(target))) previous(event);
|
|
356
|
+
else if (statusOf(state, name) !== "unanswered") next(event);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (event.key === "ArrowUp" || event.key === "ArrowDown") {
|
|
360
|
+
if (!target.matches("[role=\"checkbox\"]")) return;
|
|
361
|
+
const all = Array.from(context.element("item", name)?.querySelectorAll(ANSWER) ?? []);
|
|
362
|
+
const to = all[all.indexOf(target) + (event.key === "ArrowDown" ? 1 : -1)];
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
to?.focus();
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (!state.shortcuts || event.key.length !== 1) return;
|
|
368
|
+
const key = event.key.toUpperCase();
|
|
369
|
+
const choice = infoOf(state, name)?.choices.find((other) => shortcutOf(state, name, other.value) === key);
|
|
370
|
+
if (!choice) return;
|
|
371
|
+
event.preventDefault();
|
|
372
|
+
choose(name, choice.value, event);
|
|
373
|
+
context.element("choice", choiceKey(name, choice.value))?.querySelector(ANSWER)?.focus();
|
|
374
|
+
};
|
|
375
|
+
const describe = (entry) => {
|
|
376
|
+
store.set({ described: withEntry(get().described, entry) });
|
|
377
|
+
return () => store.set({ described: without(get().described, entry) });
|
|
378
|
+
};
|
|
379
|
+
return {
|
|
380
|
+
setChoices,
|
|
381
|
+
setText,
|
|
382
|
+
choose,
|
|
383
|
+
goTo: (name) => goTo(name),
|
|
384
|
+
next,
|
|
385
|
+
previous,
|
|
386
|
+
skip,
|
|
387
|
+
submit,
|
|
388
|
+
reset: () => form()?.reset(),
|
|
389
|
+
settle,
|
|
390
|
+
restore,
|
|
391
|
+
keydown,
|
|
392
|
+
track,
|
|
393
|
+
describe,
|
|
394
|
+
/** The items an agent can go to, named by their titles. */
|
|
395
|
+
steps: () => enabledOf(get()).map((item) => ({
|
|
396
|
+
value: item.name,
|
|
397
|
+
label: context.element("title", item.name)?.textContent?.trim() || item.name
|
|
398
|
+
}))
|
|
399
|
+
};
|
|
400
|
+
},
|
|
401
|
+
slots: (slot) => ({
|
|
402
|
+
root: slot({
|
|
403
|
+
state: (state) => positionOf(state),
|
|
404
|
+
attrs: (state) => {
|
|
405
|
+
const position = positionOf(state);
|
|
406
|
+
return {
|
|
407
|
+
"data-current": String(position.current),
|
|
408
|
+
"data-total": String(position.total),
|
|
409
|
+
"data-first": present(position.first),
|
|
410
|
+
"data-last": present(position.last),
|
|
411
|
+
"data-shortcuts": state.shortcuts ?? void 0
|
|
412
|
+
};
|
|
413
|
+
},
|
|
414
|
+
on: { keydown: (event, { api }) => api.keydown(event) }
|
|
415
|
+
}),
|
|
416
|
+
progress: slot({
|
|
417
|
+
state: (state) => positionOf(state),
|
|
418
|
+
attrs: (state) => {
|
|
419
|
+
const position = positionOf(state);
|
|
420
|
+
return {
|
|
421
|
+
"data-current": String(position.current),
|
|
422
|
+
"data-total": String(position.total),
|
|
423
|
+
"data-first": present(position.first),
|
|
424
|
+
"data-last": present(position.last)
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}),
|
|
428
|
+
item: slot({
|
|
429
|
+
props: {
|
|
430
|
+
value: "key",
|
|
431
|
+
required: "boolean",
|
|
432
|
+
multiple: "boolean",
|
|
433
|
+
disabled: "boolean",
|
|
434
|
+
invalid: "boolean",
|
|
435
|
+
onStatusChange: "callback"
|
|
436
|
+
},
|
|
437
|
+
state: (state, { key, props }) => ({
|
|
438
|
+
active: state.item === key,
|
|
439
|
+
status: statusOf(state, key),
|
|
440
|
+
invalid: Boolean(props.invalid) || state.invalid.includes(key),
|
|
441
|
+
disabled: Boolean(props.disabled)
|
|
442
|
+
}),
|
|
443
|
+
attrs: (state, { id, key, props }) => {
|
|
444
|
+
const active = state.item === key && !props.disabled;
|
|
445
|
+
const invalid = Boolean(props.invalid) || state.invalid.includes(key);
|
|
446
|
+
const describedBy = [state.described.includes(`description:${key}`) && `${id}-${idPart(key)}-description`, invalid && state.described.includes(`error:${key}`) && `${id}-${idPart(key)}-error`].filter(Boolean);
|
|
447
|
+
return {
|
|
448
|
+
tabindex: "-1",
|
|
449
|
+
hidden: active ? void 0 : "hidden",
|
|
450
|
+
inert: active ? void 0 : "true",
|
|
451
|
+
disabled: props.disabled ? "disabled" : void 0,
|
|
452
|
+
"aria-describedby": describedBy.join(" ") || void 0,
|
|
453
|
+
"data-active": present(active),
|
|
454
|
+
"data-status": statusOf(state, key),
|
|
455
|
+
"data-required": present(props.required),
|
|
456
|
+
"data-multiple": present(props.multiple),
|
|
457
|
+
"data-disabled": present(props.disabled),
|
|
458
|
+
"data-invalid": present(invalid)
|
|
459
|
+
};
|
|
460
|
+
},
|
|
461
|
+
bind: (el, part) => part.api.track(el)
|
|
462
|
+
}),
|
|
463
|
+
title: slot({
|
|
464
|
+
props: { value: "key" },
|
|
465
|
+
attrs: (_state, { id, key }) => ({ id: `${id}-${idPart(key)}-title` })
|
|
466
|
+
}),
|
|
467
|
+
description: slot({
|
|
468
|
+
props: { value: "key" },
|
|
469
|
+
attrs: (_state, { id, key }) => ({ id: `${id}-${idPart(key)}-description` }),
|
|
470
|
+
bind: (_el, part) => part.api.describe(`description:${part.key}`)
|
|
471
|
+
}),
|
|
472
|
+
choices: slot({
|
|
473
|
+
props: { value: "key" },
|
|
474
|
+
state: (state, { id, key }) => ({
|
|
475
|
+
chosen: chosenOf(state, key),
|
|
476
|
+
shortcuts: state.shortcuts,
|
|
477
|
+
labelledBy: `${id}-${idPart(key)}-title`
|
|
478
|
+
}),
|
|
479
|
+
attrs: (state) => ({ "data-shortcuts": state.shortcuts ?? void 0 })
|
|
480
|
+
}),
|
|
481
|
+
choice: slot({
|
|
482
|
+
props: {
|
|
483
|
+
id: "string",
|
|
484
|
+
item: "string",
|
|
485
|
+
value: "string",
|
|
486
|
+
multiple: "boolean",
|
|
487
|
+
disabled: "boolean",
|
|
488
|
+
invalid: "boolean"
|
|
489
|
+
},
|
|
490
|
+
state: (state, { props }) => ({
|
|
491
|
+
checked: chosenOf(state, props.item).includes(props.value),
|
|
492
|
+
disabled: Boolean(props.disabled),
|
|
493
|
+
invalid: Boolean(props.invalid) || state.invalid.includes(props.item),
|
|
494
|
+
shortcut: props.disabled ? void 0 : shortcutOf(state, props.item, props.value),
|
|
495
|
+
type: props.multiple ? "checkbox" : "radio"
|
|
496
|
+
}),
|
|
497
|
+
attrs: (state, { props }) => ({
|
|
498
|
+
...checkedAttrs(chosenOf(state, props.item).includes(props.value)),
|
|
499
|
+
"data-type": props.multiple ? "checkbox" : "radio",
|
|
500
|
+
"data-disabled": present(props.disabled),
|
|
501
|
+
"data-invalid": present(Boolean(props.invalid) || state.invalid.includes(props.item)),
|
|
502
|
+
"data-shortcut": props.disabled ? void 0 : shortcutOf(state, props.item, props.value)
|
|
503
|
+
}),
|
|
504
|
+
bind: (el, part) => part.api.track(el)
|
|
505
|
+
}),
|
|
506
|
+
input: slot({
|
|
507
|
+
props: {
|
|
508
|
+
value: "key",
|
|
509
|
+
required: "boolean",
|
|
510
|
+
disabled: "boolean",
|
|
511
|
+
invalid: "boolean"
|
|
512
|
+
},
|
|
513
|
+
state: (state, { key, props }) => ({
|
|
514
|
+
text: textOf(state, key),
|
|
515
|
+
filled: textOf(state, key) !== "",
|
|
516
|
+
disabled: Boolean(props.disabled),
|
|
517
|
+
invalid: Boolean(props.invalid) || state.invalid.includes(key)
|
|
518
|
+
}),
|
|
519
|
+
attrs: (state, { key, props }) => {
|
|
520
|
+
const filled = textOf(state, key) !== "";
|
|
521
|
+
return {
|
|
522
|
+
"data-filled": present(filled),
|
|
523
|
+
"data-empty": present(!filled),
|
|
524
|
+
"data-disabled": present(props.disabled),
|
|
525
|
+
"data-invalid": present(Boolean(props.invalid) || state.invalid.includes(key))
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
}),
|
|
529
|
+
error: slot({
|
|
530
|
+
props: {
|
|
531
|
+
value: "key",
|
|
532
|
+
required: "boolean",
|
|
533
|
+
disabled: "boolean",
|
|
534
|
+
invalid: "boolean"
|
|
535
|
+
},
|
|
536
|
+
present: (state, { key, props }) => Boolean(props.invalid) || state.invalid.includes(key),
|
|
537
|
+
state: (_state, { props }) => ({
|
|
538
|
+
invalid: true,
|
|
539
|
+
required: Boolean(props.required)
|
|
540
|
+
}),
|
|
541
|
+
attrs: (_state, { id, key }) => ({
|
|
542
|
+
id: `${id}-${idPart(key)}-error`,
|
|
543
|
+
"data-invalid": ""
|
|
544
|
+
}),
|
|
545
|
+
bind: (_el, part) => part.api.describe(`error:${part.key}`)
|
|
546
|
+
}),
|
|
547
|
+
previous: slot({
|
|
548
|
+
state: (state) => actionState(state, !positionOf(state).first, false),
|
|
549
|
+
attrs: (state) => actionAttrs(state, "button", !positionOf(state).first, false),
|
|
550
|
+
press: ({ api }, event) => void api.previous(event)
|
|
551
|
+
}),
|
|
552
|
+
skip: slot({
|
|
553
|
+
state: (state) => actionState(state, skippable(state), false),
|
|
554
|
+
attrs: (state) => actionAttrs(state, "button", skippable(state), false),
|
|
555
|
+
press: ({ api }, event) => void api.skip(event)
|
|
556
|
+
}),
|
|
557
|
+
next: slot({
|
|
558
|
+
state: (state) => actionState(state, !positionOf(state).last, true),
|
|
559
|
+
attrs: (state) => actionAttrs(state, "button", !positionOf(state).last, true),
|
|
560
|
+
press: ({ api }, event) => void api.next(event)
|
|
561
|
+
}),
|
|
562
|
+
submit: slot({
|
|
563
|
+
state: (state) => actionState(state, positionOf(state).last, true),
|
|
564
|
+
attrs: (state) => actionAttrs(state, "submit", positionOf(state).last, true)
|
|
565
|
+
})
|
|
566
|
+
}),
|
|
567
|
+
agent: {
|
|
568
|
+
actions: [
|
|
569
|
+
"next",
|
|
570
|
+
"previous",
|
|
571
|
+
"skip",
|
|
572
|
+
"goTo",
|
|
573
|
+
"submit",
|
|
574
|
+
"reset"
|
|
575
|
+
],
|
|
576
|
+
items: (api) => api.steps()
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
const choiceKey = (item, value) => `${item}\u001f${value}`;
|
|
580
|
+
function skippable(state) {
|
|
581
|
+
const info = state.item ? infoOf(state, state.item) : void 0;
|
|
582
|
+
return Boolean(info && !info.required);
|
|
583
|
+
}
|
|
584
|
+
const activeStatus = (state) => state.item ? statusOf(state, state.item) : "unanswered";
|
|
585
|
+
function actionState(state, visible, proceeds) {
|
|
586
|
+
return {
|
|
587
|
+
visible,
|
|
588
|
+
status: activeStatus(state),
|
|
589
|
+
shortcut: visible && proceeds ? "Enter" : void 0
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function actionAttrs(state, type, visible, proceeds) {
|
|
593
|
+
return {
|
|
594
|
+
type,
|
|
595
|
+
hidden: visible ? void 0 : "hidden",
|
|
596
|
+
"data-visible": present(visible),
|
|
597
|
+
"data-hidden": present(!visible),
|
|
598
|
+
"data-status": activeStatus(state),
|
|
599
|
+
"data-shortcut": visible && proceeds ? "Enter" : void 0,
|
|
600
|
+
"aria-keyshortcuts": visible && proceeds ? "Control+Enter Meta+Enter" : void 0
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
const QuestionnaireHandle = createContext(null);
|
|
604
|
+
function useQuestionnaireHandle() {
|
|
605
|
+
const handle = use(QuestionnaireHandle);
|
|
606
|
+
if (!handle) throw new Error("Questionnaire parts must be used within a Questionnaire.");
|
|
607
|
+
return handle;
|
|
608
|
+
}
|
|
609
|
+
const QuestionnaireItemScope = createContext(null);
|
|
610
|
+
function useItemScope() {
|
|
611
|
+
const scope = use(QuestionnaireItemScope);
|
|
612
|
+
if (!scope) throw new Error("This part must be used within a QuestionnaireItem.");
|
|
613
|
+
return scope;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Where the questionnaire stands and the methods that move it, for a component
|
|
617
|
+
* inside `Questionnaire`. It re-renders when the state changes.
|
|
618
|
+
*/
|
|
619
|
+
function useQuestionnaire() {
|
|
620
|
+
const $ = c(19);
|
|
621
|
+
const handle = useQuestionnaireHandle();
|
|
622
|
+
const state = usePrimitiveState(handle);
|
|
623
|
+
const t0 = state.item;
|
|
624
|
+
const t1 = state.values;
|
|
625
|
+
let t2;
|
|
626
|
+
if ($[0] !== state) {
|
|
627
|
+
t2 = state.item ? statusOf(state, state.item) : "unanswered";
|
|
628
|
+
$[0] = state;
|
|
629
|
+
$[1] = t2;
|
|
630
|
+
} else t2 = $[1];
|
|
631
|
+
let t3;
|
|
632
|
+
if ($[2] !== state) {
|
|
633
|
+
t3 = positionOf(state);
|
|
634
|
+
$[2] = state;
|
|
635
|
+
$[3] = t3;
|
|
636
|
+
} else t3 = $[3];
|
|
637
|
+
let t4;
|
|
638
|
+
let t5;
|
|
639
|
+
let t6;
|
|
640
|
+
if ($[4] !== handle.api) {
|
|
641
|
+
t4 = () => handle.api.next();
|
|
642
|
+
t5 = () => handle.api.previous();
|
|
643
|
+
t6 = () => handle.api.skip();
|
|
644
|
+
$[4] = handle.api;
|
|
645
|
+
$[5] = t4;
|
|
646
|
+
$[6] = t5;
|
|
647
|
+
$[7] = t6;
|
|
648
|
+
} else {
|
|
649
|
+
t4 = $[5];
|
|
650
|
+
t5 = $[6];
|
|
651
|
+
t6 = $[7];
|
|
652
|
+
}
|
|
653
|
+
let t7;
|
|
654
|
+
if ($[8] !== handle.api.goTo || $[9] !== handle.api.reset || $[10] !== handle.api.submit || $[11] !== state.item || $[12] !== state.values || $[13] !== t2 || $[14] !== t3 || $[15] !== t4 || $[16] !== t5 || $[17] !== t6) {
|
|
655
|
+
t7 = {
|
|
656
|
+
item: t0,
|
|
657
|
+
values: t1,
|
|
658
|
+
status: t2,
|
|
659
|
+
...t3,
|
|
660
|
+
goTo: handle.api.goTo,
|
|
661
|
+
next: t4,
|
|
662
|
+
previous: t5,
|
|
663
|
+
skip: t6,
|
|
664
|
+
submit: handle.api.submit,
|
|
665
|
+
reset: handle.api.reset
|
|
666
|
+
};
|
|
667
|
+
$[8] = handle.api.goTo;
|
|
668
|
+
$[9] = handle.api.reset;
|
|
669
|
+
$[10] = handle.api.submit;
|
|
670
|
+
$[11] = state.item;
|
|
671
|
+
$[12] = state.values;
|
|
672
|
+
$[13] = t2;
|
|
673
|
+
$[14] = t3;
|
|
674
|
+
$[15] = t4;
|
|
675
|
+
$[16] = t5;
|
|
676
|
+
$[17] = t6;
|
|
677
|
+
$[18] = t7;
|
|
678
|
+
} else t7 = $[18];
|
|
679
|
+
return t7;
|
|
680
|
+
}
|
|
681
|
+
function Questionnaire(t0) {
|
|
682
|
+
const $ = c(46);
|
|
683
|
+
let children;
|
|
684
|
+
let className;
|
|
685
|
+
let defaultItem;
|
|
686
|
+
let defaultValues;
|
|
687
|
+
let item;
|
|
688
|
+
let items;
|
|
689
|
+
let noValidate;
|
|
690
|
+
let onItemChange;
|
|
691
|
+
let onReset;
|
|
692
|
+
let onSubmit;
|
|
693
|
+
let onValuesChange;
|
|
694
|
+
let props;
|
|
695
|
+
let shortcuts;
|
|
696
|
+
let t1;
|
|
697
|
+
let values;
|
|
698
|
+
if ($[0] !== t0) {
|
|
699
|
+
({item, defaultItem, onItemChange, values, defaultValues, onValuesChange, items, shortcuts, noValidate, label: t1, onSubmit, onReset, className, children, ...props} = t0);
|
|
700
|
+
$[0] = t0;
|
|
701
|
+
$[1] = children;
|
|
702
|
+
$[2] = className;
|
|
703
|
+
$[3] = defaultItem;
|
|
704
|
+
$[4] = defaultValues;
|
|
705
|
+
$[5] = item;
|
|
706
|
+
$[6] = items;
|
|
707
|
+
$[7] = noValidate;
|
|
708
|
+
$[8] = onItemChange;
|
|
709
|
+
$[9] = onReset;
|
|
710
|
+
$[10] = onSubmit;
|
|
711
|
+
$[11] = onValuesChange;
|
|
712
|
+
$[12] = props;
|
|
713
|
+
$[13] = shortcuts;
|
|
714
|
+
$[14] = t1;
|
|
715
|
+
$[15] = values;
|
|
716
|
+
} else {
|
|
717
|
+
children = $[1];
|
|
718
|
+
className = $[2];
|
|
719
|
+
defaultItem = $[3];
|
|
720
|
+
defaultValues = $[4];
|
|
721
|
+
item = $[5];
|
|
722
|
+
items = $[6];
|
|
723
|
+
noValidate = $[7];
|
|
724
|
+
onItemChange = $[8];
|
|
725
|
+
onReset = $[9];
|
|
726
|
+
onSubmit = $[10];
|
|
727
|
+
onValuesChange = $[11];
|
|
728
|
+
props = $[12];
|
|
729
|
+
shortcuts = $[13];
|
|
730
|
+
t1 = $[14];
|
|
731
|
+
values = $[15];
|
|
732
|
+
}
|
|
733
|
+
const label = t1 === void 0 ? "Questionnaire" : t1;
|
|
734
|
+
let t2;
|
|
735
|
+
if ($[16] !== defaultItem || $[17] !== defaultValues || $[18] !== item || $[19] !== items || $[20] !== noValidate || $[21] !== onItemChange || $[22] !== onValuesChange || $[23] !== shortcuts || $[24] !== values) {
|
|
736
|
+
t2 = {
|
|
737
|
+
item,
|
|
738
|
+
defaultItem,
|
|
739
|
+
onItemChange,
|
|
740
|
+
values,
|
|
741
|
+
defaultValues,
|
|
742
|
+
onValuesChange,
|
|
743
|
+
items,
|
|
744
|
+
shortcuts,
|
|
745
|
+
noValidate
|
|
746
|
+
};
|
|
747
|
+
$[16] = defaultItem;
|
|
748
|
+
$[17] = defaultValues;
|
|
749
|
+
$[18] = item;
|
|
750
|
+
$[19] = items;
|
|
751
|
+
$[20] = noValidate;
|
|
752
|
+
$[21] = onItemChange;
|
|
753
|
+
$[22] = onValuesChange;
|
|
754
|
+
$[23] = shortcuts;
|
|
755
|
+
$[24] = values;
|
|
756
|
+
$[25] = t2;
|
|
757
|
+
} else t2 = $[25];
|
|
758
|
+
const handle = (0, core_exports.usePrimitive)(questionnaire, t2);
|
|
759
|
+
let t3;
|
|
760
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
761
|
+
t3 = {};
|
|
762
|
+
$[26] = t3;
|
|
763
|
+
} else t3 = $[26];
|
|
764
|
+
const t4 = props["aria-labelledby"] ? void 0 : label;
|
|
765
|
+
const t5 = noValidate ?? true;
|
|
766
|
+
let t6;
|
|
767
|
+
if ($[27] !== className) {
|
|
768
|
+
t6 = cnState("flex w-full min-w-0 flex-col gap-4", className);
|
|
769
|
+
$[27] = className;
|
|
770
|
+
$[28] = t6;
|
|
771
|
+
} else t6 = $[28];
|
|
772
|
+
let t7;
|
|
773
|
+
if ($[29] !== handle || $[30] !== onSubmit) {
|
|
774
|
+
t7 = (event) => {
|
|
775
|
+
if (handle.api.settle(event.nativeEvent)) onSubmit?.(event);
|
|
776
|
+
else event.preventDefault();
|
|
777
|
+
};
|
|
778
|
+
$[29] = handle;
|
|
779
|
+
$[30] = onSubmit;
|
|
780
|
+
$[31] = t7;
|
|
781
|
+
} else t7 = $[31];
|
|
782
|
+
let t8;
|
|
783
|
+
if ($[32] !== handle || $[33] !== onReset) {
|
|
784
|
+
t8 = (event_0) => {
|
|
785
|
+
onReset?.(event_0);
|
|
786
|
+
if (!event_0.defaultPrevented) handle.api.restore();
|
|
787
|
+
};
|
|
788
|
+
$[32] = handle;
|
|
789
|
+
$[33] = onReset;
|
|
790
|
+
$[34] = t8;
|
|
791
|
+
} else t8 = $[34];
|
|
792
|
+
let t9;
|
|
793
|
+
if ($[35] !== children || $[36] !== handle) {
|
|
794
|
+
t9 = (state) => /* @__PURE__ */ jsx(QuestionnaireHandle, {
|
|
795
|
+
value: handle,
|
|
796
|
+
children: typeof children === "function" ? children(state) : children
|
|
797
|
+
});
|
|
798
|
+
$[35] = children;
|
|
799
|
+
$[36] = handle;
|
|
800
|
+
$[37] = t9;
|
|
801
|
+
} else t9 = $[37];
|
|
802
|
+
let t10;
|
|
803
|
+
if ($[38] !== props || $[39] !== t4 || $[40] !== t5 || $[41] !== t6 || $[42] !== t7 || $[43] !== t8 || $[44] !== t9) {
|
|
804
|
+
t10 = {
|
|
805
|
+
"aria-label": t4,
|
|
806
|
+
noValidate: t5,
|
|
807
|
+
className: t6,
|
|
808
|
+
onSubmit: t7,
|
|
809
|
+
onReset: t8,
|
|
810
|
+
children: t9,
|
|
811
|
+
...props
|
|
812
|
+
};
|
|
813
|
+
$[38] = props;
|
|
814
|
+
$[39] = t4;
|
|
815
|
+
$[40] = t5;
|
|
816
|
+
$[41] = t6;
|
|
817
|
+
$[42] = t7;
|
|
818
|
+
$[43] = t8;
|
|
819
|
+
$[44] = t9;
|
|
820
|
+
$[45] = t10;
|
|
821
|
+
} else t10 = $[45];
|
|
822
|
+
return (0, core_exports.usePart)(handle, "root", t3, t10, "form");
|
|
823
|
+
}
|
|
824
|
+
/** "Question 1 of 3", counting the enabled items. Children replace the text. */
|
|
825
|
+
function QuestionnaireProgress(t0) {
|
|
826
|
+
const $ = c(15);
|
|
827
|
+
let children;
|
|
828
|
+
let className;
|
|
829
|
+
let props;
|
|
830
|
+
let t1;
|
|
831
|
+
if ($[0] !== t0) {
|
|
832
|
+
({label: t1, className, children, ...props} = t0);
|
|
833
|
+
$[0] = t0;
|
|
834
|
+
$[1] = children;
|
|
835
|
+
$[2] = className;
|
|
836
|
+
$[3] = props;
|
|
837
|
+
$[4] = t1;
|
|
838
|
+
} else {
|
|
839
|
+
children = $[1];
|
|
840
|
+
className = $[2];
|
|
841
|
+
props = $[3];
|
|
842
|
+
t1 = $[4];
|
|
843
|
+
}
|
|
844
|
+
const label = t1 === void 0 ? "Progress" : t1;
|
|
845
|
+
let t2;
|
|
846
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
847
|
+
t2 = {};
|
|
848
|
+
$[5] = t2;
|
|
849
|
+
} else t2 = $[5];
|
|
850
|
+
let t3;
|
|
851
|
+
if ($[6] !== className) {
|
|
852
|
+
t3 = cnState("min-h-[1lh] w-fit min-w-[14ch] text-xs font-medium text-muted-foreground tabular-nums", className);
|
|
853
|
+
$[6] = className;
|
|
854
|
+
$[7] = t3;
|
|
855
|
+
} else t3 = $[7];
|
|
856
|
+
let t4;
|
|
857
|
+
if ($[8] !== children || $[9] !== label) {
|
|
858
|
+
t4 = (state) => {
|
|
859
|
+
const text = `Question ${state.current} of ${state.total}`;
|
|
860
|
+
return /* @__PURE__ */ jsx(Progress, {
|
|
861
|
+
"aria-label": label,
|
|
862
|
+
value: state.current,
|
|
863
|
+
max: Math.max(state.total, 1),
|
|
864
|
+
getValueLabel: () => text,
|
|
865
|
+
children: typeof children === "function" ? children(state) : children ?? text
|
|
866
|
+
});
|
|
867
|
+
};
|
|
868
|
+
$[8] = children;
|
|
869
|
+
$[9] = label;
|
|
870
|
+
$[10] = t4;
|
|
871
|
+
} else t4 = $[10];
|
|
872
|
+
let t5;
|
|
873
|
+
if ($[11] !== props || $[12] !== t3 || $[13] !== t4) {
|
|
874
|
+
t5 = {
|
|
875
|
+
className: t3,
|
|
876
|
+
children: t4,
|
|
877
|
+
...props
|
|
878
|
+
};
|
|
879
|
+
$[11] = props;
|
|
880
|
+
$[12] = t3;
|
|
881
|
+
$[13] = t4;
|
|
882
|
+
$[14] = t5;
|
|
883
|
+
} else t5 = $[14];
|
|
884
|
+
return (0, core_exports.usePart)(questionnaire, "progress", t2, t5, "div");
|
|
885
|
+
}
|
|
886
|
+
function QuestionnaireItem(t0) {
|
|
887
|
+
const $ = c(29);
|
|
888
|
+
let children;
|
|
889
|
+
let className;
|
|
890
|
+
let name;
|
|
891
|
+
let onStatusChange;
|
|
892
|
+
let props;
|
|
893
|
+
let t1;
|
|
894
|
+
let t2;
|
|
895
|
+
let t3;
|
|
896
|
+
let t4;
|
|
897
|
+
if ($[0] !== t0) {
|
|
898
|
+
({name, required: t1, multiple: t2, disabled: t3, invalid: t4, onStatusChange, className, children, ...props} = t0);
|
|
899
|
+
$[0] = t0;
|
|
900
|
+
$[1] = children;
|
|
901
|
+
$[2] = className;
|
|
902
|
+
$[3] = name;
|
|
903
|
+
$[4] = onStatusChange;
|
|
904
|
+
$[5] = props;
|
|
905
|
+
$[6] = t1;
|
|
906
|
+
$[7] = t2;
|
|
907
|
+
$[8] = t3;
|
|
908
|
+
$[9] = t4;
|
|
909
|
+
} else {
|
|
910
|
+
children = $[1];
|
|
911
|
+
className = $[2];
|
|
912
|
+
name = $[3];
|
|
913
|
+
onStatusChange = $[4];
|
|
914
|
+
props = $[5];
|
|
915
|
+
t1 = $[6];
|
|
916
|
+
t2 = $[7];
|
|
917
|
+
t3 = $[8];
|
|
918
|
+
t4 = $[9];
|
|
919
|
+
}
|
|
920
|
+
const required = t1 === void 0 ? false : t1;
|
|
921
|
+
const multiple = t2 === void 0 ? false : t2;
|
|
922
|
+
const disabled = t3 === void 0 ? false : t3;
|
|
923
|
+
const invalid = t4 === void 0 ? false : t4;
|
|
924
|
+
let t5;
|
|
925
|
+
if ($[10] !== disabled || $[11] !== invalid || $[12] !== multiple || $[13] !== name || $[14] !== onStatusChange || $[15] !== required) {
|
|
926
|
+
t5 = {
|
|
927
|
+
value: name,
|
|
928
|
+
required,
|
|
929
|
+
multiple,
|
|
930
|
+
disabled,
|
|
931
|
+
invalid,
|
|
932
|
+
onStatusChange
|
|
933
|
+
};
|
|
934
|
+
$[10] = disabled;
|
|
935
|
+
$[11] = invalid;
|
|
936
|
+
$[12] = multiple;
|
|
937
|
+
$[13] = name;
|
|
938
|
+
$[14] = onStatusChange;
|
|
939
|
+
$[15] = required;
|
|
940
|
+
$[16] = t5;
|
|
941
|
+
} else t5 = $[16];
|
|
942
|
+
let t6;
|
|
943
|
+
if ($[17] !== className) {
|
|
944
|
+
t6 = cnState("flex min-w-0 flex-col gap-4 border-0 p-0 outline-none motion-enter", className);
|
|
945
|
+
$[17] = className;
|
|
946
|
+
$[18] = t6;
|
|
947
|
+
} else t6 = $[18];
|
|
948
|
+
let t7;
|
|
949
|
+
if ($[19] !== children || $[20] !== disabled || $[21] !== multiple || $[22] !== name || $[23] !== required) {
|
|
950
|
+
t7 = (state) => /* @__PURE__ */ jsx(QuestionnaireItemScope, {
|
|
951
|
+
value: {
|
|
952
|
+
name,
|
|
953
|
+
required,
|
|
954
|
+
multiple,
|
|
955
|
+
disabled,
|
|
956
|
+
invalid: state.invalid
|
|
957
|
+
},
|
|
958
|
+
children: typeof children === "function" ? children(state) : children
|
|
959
|
+
});
|
|
960
|
+
$[19] = children;
|
|
961
|
+
$[20] = disabled;
|
|
962
|
+
$[21] = multiple;
|
|
963
|
+
$[22] = name;
|
|
964
|
+
$[23] = required;
|
|
965
|
+
$[24] = t7;
|
|
966
|
+
} else t7 = $[24];
|
|
967
|
+
let t8;
|
|
968
|
+
if ($[25] !== props || $[26] !== t6 || $[27] !== t7) {
|
|
969
|
+
t8 = {
|
|
970
|
+
className: t6,
|
|
971
|
+
children: t7,
|
|
972
|
+
...props
|
|
973
|
+
};
|
|
974
|
+
$[25] = props;
|
|
975
|
+
$[26] = t6;
|
|
976
|
+
$[27] = t7;
|
|
977
|
+
$[28] = t8;
|
|
978
|
+
} else t8 = $[28];
|
|
979
|
+
return (0, core_exports.usePart)(questionnaire, "item", t5, t8, "fieldset");
|
|
980
|
+
}
|
|
981
|
+
/** The question, and the name of its answers. */
|
|
982
|
+
function QuestionnaireTitle(t0) {
|
|
983
|
+
const $ = c(10);
|
|
984
|
+
let className;
|
|
985
|
+
let props;
|
|
986
|
+
if ($[0] !== t0) {
|
|
987
|
+
({className, ...props} = t0);
|
|
988
|
+
$[0] = t0;
|
|
989
|
+
$[1] = className;
|
|
990
|
+
$[2] = props;
|
|
991
|
+
} else {
|
|
992
|
+
className = $[1];
|
|
993
|
+
props = $[2];
|
|
994
|
+
}
|
|
995
|
+
const { name } = useItemScope();
|
|
996
|
+
let t1;
|
|
997
|
+
if ($[3] !== name) {
|
|
998
|
+
t1 = { value: name };
|
|
999
|
+
$[3] = name;
|
|
1000
|
+
$[4] = t1;
|
|
1001
|
+
} else t1 = $[4];
|
|
1002
|
+
let t2;
|
|
1003
|
+
if ($[5] !== className) {
|
|
1004
|
+
t2 = cnState("p-0 text-heading-3 text-pretty [&:not(:has(~[data-slot=questionnaire-description]))]:mb-4", className);
|
|
1005
|
+
$[5] = className;
|
|
1006
|
+
$[6] = t2;
|
|
1007
|
+
} else t2 = $[6];
|
|
1008
|
+
let t3;
|
|
1009
|
+
if ($[7] !== props || $[8] !== t2) {
|
|
1010
|
+
t3 = {
|
|
1011
|
+
className: t2,
|
|
1012
|
+
...props
|
|
1013
|
+
};
|
|
1014
|
+
$[7] = props;
|
|
1015
|
+
$[8] = t2;
|
|
1016
|
+
$[9] = t3;
|
|
1017
|
+
} else t3 = $[9];
|
|
1018
|
+
return (0, core_exports.usePart)(questionnaire, "title", t1, t3, "legend");
|
|
1019
|
+
}
|
|
1020
|
+
function QuestionnaireDescription(t0) {
|
|
1021
|
+
const $ = c(10);
|
|
1022
|
+
let className;
|
|
1023
|
+
let props;
|
|
1024
|
+
if ($[0] !== t0) {
|
|
1025
|
+
({className, ...props} = t0);
|
|
1026
|
+
$[0] = t0;
|
|
1027
|
+
$[1] = className;
|
|
1028
|
+
$[2] = props;
|
|
1029
|
+
} else {
|
|
1030
|
+
className = $[1];
|
|
1031
|
+
props = $[2];
|
|
1032
|
+
}
|
|
1033
|
+
const { name } = useItemScope();
|
|
1034
|
+
let t1;
|
|
1035
|
+
if ($[3] !== name) {
|
|
1036
|
+
t1 = { value: name };
|
|
1037
|
+
$[3] = name;
|
|
1038
|
+
$[4] = t1;
|
|
1039
|
+
} else t1 = $[4];
|
|
1040
|
+
let t2;
|
|
1041
|
+
if ($[5] !== className) {
|
|
1042
|
+
t2 = cnState("text-sm text-pretty text-muted-foreground", className);
|
|
1043
|
+
$[5] = className;
|
|
1044
|
+
$[6] = t2;
|
|
1045
|
+
} else t2 = $[6];
|
|
1046
|
+
let t3;
|
|
1047
|
+
if ($[7] !== props || $[8] !== t2) {
|
|
1048
|
+
t3 = {
|
|
1049
|
+
className: t2,
|
|
1050
|
+
...props
|
|
1051
|
+
};
|
|
1052
|
+
$[7] = props;
|
|
1053
|
+
$[8] = t2;
|
|
1054
|
+
$[9] = t3;
|
|
1055
|
+
} else t3 = $[9];
|
|
1056
|
+
return (0, core_exports.usePart)(questionnaire, "description", t1, t3, "p");
|
|
1057
|
+
}
|
|
1058
|
+
/** The item's choices: a radio group, or a group of checkboxes in an item with `multiple`. */
|
|
1059
|
+
function QuestionnaireChoices(t0) {
|
|
1060
|
+
const $ = c(19);
|
|
1061
|
+
let children;
|
|
1062
|
+
let className;
|
|
1063
|
+
let props;
|
|
1064
|
+
if ($[0] !== t0) {
|
|
1065
|
+
({className, children, ...props} = t0);
|
|
1066
|
+
$[0] = t0;
|
|
1067
|
+
$[1] = children;
|
|
1068
|
+
$[2] = className;
|
|
1069
|
+
$[3] = props;
|
|
1070
|
+
} else {
|
|
1071
|
+
children = $[1];
|
|
1072
|
+
className = $[2];
|
|
1073
|
+
props = $[3];
|
|
1074
|
+
}
|
|
1075
|
+
const handle = useQuestionnaireHandle();
|
|
1076
|
+
const { name, multiple, disabled, invalid } = useItemScope();
|
|
1077
|
+
let t1;
|
|
1078
|
+
if ($[4] !== name) {
|
|
1079
|
+
t1 = { value: name };
|
|
1080
|
+
$[4] = name;
|
|
1081
|
+
$[5] = t1;
|
|
1082
|
+
} else t1 = $[5];
|
|
1083
|
+
let t2;
|
|
1084
|
+
if ($[6] !== className) {
|
|
1085
|
+
t2 = cnState("group/questionnaire-choices min-w-0", className);
|
|
1086
|
+
$[6] = className;
|
|
1087
|
+
$[7] = t2;
|
|
1088
|
+
} else t2 = $[7];
|
|
1089
|
+
let t3;
|
|
1090
|
+
if ($[8] !== children || $[9] !== disabled || $[10] !== handle || $[11] !== invalid || $[12] !== multiple || $[13] !== name) {
|
|
1091
|
+
t3 = (state) => multiple ? /* @__PURE__ */ jsx(CheckboxGroup, {
|
|
1092
|
+
name,
|
|
1093
|
+
value: state.chosen,
|
|
1094
|
+
disabled,
|
|
1095
|
+
"aria-labelledby": state.labelledBy,
|
|
1096
|
+
className: "gap-2",
|
|
1097
|
+
onValueChange: (chosen, details) => {
|
|
1098
|
+
if (details.reason === "reset") return;
|
|
1099
|
+
handle.api.setChoices(name, chosen, {
|
|
1100
|
+
reason: "item-press",
|
|
1101
|
+
event: details.event,
|
|
1102
|
+
source: details.source
|
|
1103
|
+
});
|
|
1104
|
+
},
|
|
1105
|
+
children
|
|
1106
|
+
}) : /* @__PURE__ */ jsx(RadioGroup, {
|
|
1107
|
+
name,
|
|
1108
|
+
value: state.chosen[0] ?? null,
|
|
1109
|
+
disabled,
|
|
1110
|
+
"aria-labelledby": state.labelledBy,
|
|
1111
|
+
"aria-invalid": invalid || void 0,
|
|
1112
|
+
className: "gap-2",
|
|
1113
|
+
onValueChange: (chosen_0, details_0) => {
|
|
1114
|
+
if (details_0.reason === "reset") return;
|
|
1115
|
+
handle.api.setChoices(name, chosen_0 === null ? [] : [chosen_0], {
|
|
1116
|
+
reason: "item-press",
|
|
1117
|
+
event: details_0.event,
|
|
1118
|
+
source: details_0.source
|
|
1119
|
+
});
|
|
1120
|
+
},
|
|
1121
|
+
children
|
|
1122
|
+
});
|
|
1123
|
+
$[8] = children;
|
|
1124
|
+
$[9] = disabled;
|
|
1125
|
+
$[10] = handle;
|
|
1126
|
+
$[11] = invalid;
|
|
1127
|
+
$[12] = multiple;
|
|
1128
|
+
$[13] = name;
|
|
1129
|
+
$[14] = t3;
|
|
1130
|
+
} else t3 = $[14];
|
|
1131
|
+
let t4;
|
|
1132
|
+
if ($[15] !== props || $[16] !== t2 || $[17] !== t3) {
|
|
1133
|
+
t4 = {
|
|
1134
|
+
className: t2,
|
|
1135
|
+
children: t3,
|
|
1136
|
+
...props
|
|
1137
|
+
};
|
|
1138
|
+
$[15] = props;
|
|
1139
|
+
$[16] = t2;
|
|
1140
|
+
$[17] = t3;
|
|
1141
|
+
$[18] = t4;
|
|
1142
|
+
} else t4 = $[18];
|
|
1143
|
+
return (0, core_exports.usePart)(questionnaire, "choices", t1, t4, "div");
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* One answer: a radio, or a checkbox in an item with `multiple`, with its text.
|
|
1147
|
+
* The text names the answer, for a screen reader and for an agent. A
|
|
1148
|
+
* `QuestionnaireChoiceDescription` placed directly inside describes it, and
|
|
1149
|
+
* stays out of that name.
|
|
1150
|
+
*/
|
|
1151
|
+
function QuestionnaireChoice(t0) {
|
|
1152
|
+
const $ = c(34);
|
|
1153
|
+
let children;
|
|
1154
|
+
let className;
|
|
1155
|
+
let props;
|
|
1156
|
+
let t1;
|
|
1157
|
+
let value;
|
|
1158
|
+
if ($[0] !== t0) {
|
|
1159
|
+
({value, disabled: t1, className, children, ...props} = t0);
|
|
1160
|
+
$[0] = t0;
|
|
1161
|
+
$[1] = children;
|
|
1162
|
+
$[2] = className;
|
|
1163
|
+
$[3] = props;
|
|
1164
|
+
$[4] = t1;
|
|
1165
|
+
$[5] = value;
|
|
1166
|
+
} else {
|
|
1167
|
+
children = $[1];
|
|
1168
|
+
className = $[2];
|
|
1169
|
+
props = $[3];
|
|
1170
|
+
t1 = $[4];
|
|
1171
|
+
value = $[5];
|
|
1172
|
+
}
|
|
1173
|
+
const disabled = t1 === void 0 ? false : t1;
|
|
1174
|
+
const { name, multiple, invalid } = useItemScope();
|
|
1175
|
+
const id = useId();
|
|
1176
|
+
let t2;
|
|
1177
|
+
let text;
|
|
1178
|
+
if ($[6] !== children) {
|
|
1179
|
+
const all = Children.toArray(children);
|
|
1180
|
+
const isDescription = _temp;
|
|
1181
|
+
let t3;
|
|
1182
|
+
if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1183
|
+
t3 = (child_0) => !isDescription(child_0);
|
|
1184
|
+
$[9] = t3;
|
|
1185
|
+
} else t3 = $[9];
|
|
1186
|
+
text = all.filter(t3);
|
|
1187
|
+
t2 = all.filter(isDescription);
|
|
1188
|
+
$[6] = children;
|
|
1189
|
+
$[7] = t2;
|
|
1190
|
+
$[8] = text;
|
|
1191
|
+
} else {
|
|
1192
|
+
t2 = $[7];
|
|
1193
|
+
text = $[8];
|
|
1194
|
+
}
|
|
1195
|
+
const descriptions = t2;
|
|
1196
|
+
const labelledBy = text.length > 0 ? `${id}-text` : void 0;
|
|
1197
|
+
const describedBy = descriptions.length > 0 ? `${id}-description` : void 0;
|
|
1198
|
+
let t3;
|
|
1199
|
+
if ($[10] !== name || $[11] !== value) {
|
|
1200
|
+
t3 = choiceKey(name, value);
|
|
1201
|
+
$[10] = name;
|
|
1202
|
+
$[11] = value;
|
|
1203
|
+
$[12] = t3;
|
|
1204
|
+
} else t3 = $[12];
|
|
1205
|
+
let t4;
|
|
1206
|
+
if ($[13] !== disabled || $[14] !== invalid || $[15] !== multiple || $[16] !== name || $[17] !== t3 || $[18] !== value) {
|
|
1207
|
+
t4 = {
|
|
1208
|
+
id: t3,
|
|
1209
|
+
item: name,
|
|
1210
|
+
value,
|
|
1211
|
+
multiple,
|
|
1212
|
+
disabled,
|
|
1213
|
+
invalid
|
|
1214
|
+
};
|
|
1215
|
+
$[13] = disabled;
|
|
1216
|
+
$[14] = invalid;
|
|
1217
|
+
$[15] = multiple;
|
|
1218
|
+
$[16] = name;
|
|
1219
|
+
$[17] = t3;
|
|
1220
|
+
$[18] = value;
|
|
1221
|
+
$[19] = t4;
|
|
1222
|
+
} else t4 = $[19];
|
|
1223
|
+
let t5;
|
|
1224
|
+
if ($[20] !== className) {
|
|
1225
|
+
t5 = cnState("group/questionnaire-choice relative flex min-h-11 cursor-pointer items-start gap-2.5 rounded-lg border border-input bg-transparent px-3 py-2.5 text-start text-sm transition-colors select-none hover:bg-muted/50 data-checked:border-brand data-checked:bg-muted data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 data-invalid:border-destructive dark:bg-input/20 dark:data-checked:bg-muted", className);
|
|
1226
|
+
$[20] = className;
|
|
1227
|
+
$[21] = t5;
|
|
1228
|
+
} else t5 = $[21];
|
|
1229
|
+
let t6;
|
|
1230
|
+
if ($[22] !== describedBy || $[23] !== descriptions || $[24] !== disabled || $[25] !== labelledBy || $[26] !== multiple || $[27] !== text || $[28] !== value) {
|
|
1231
|
+
t6 = (state) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1232
|
+
multiple ? /* @__PURE__ */ jsx(Checkbox, {
|
|
1233
|
+
value,
|
|
1234
|
+
disabled,
|
|
1235
|
+
"aria-invalid": state.invalid || void 0,
|
|
1236
|
+
"aria-keyshortcuts": state.shortcut,
|
|
1237
|
+
"aria-labelledby": labelledBy,
|
|
1238
|
+
"aria-describedby": describedBy,
|
|
1239
|
+
className: "translate-y-0.5",
|
|
1240
|
+
children: /* @__PURE__ */ jsx(CheckboxIndicator, {})
|
|
1241
|
+
}) : /* @__PURE__ */ jsx(Radio, {
|
|
1242
|
+
value,
|
|
1243
|
+
disabled,
|
|
1244
|
+
"aria-keyshortcuts": state.shortcut,
|
|
1245
|
+
"aria-labelledby": labelledBy,
|
|
1246
|
+
"aria-describedby": describedBy,
|
|
1247
|
+
className: "translate-y-0.5",
|
|
1248
|
+
children: /* @__PURE__ */ jsx(RadioIndicator, {})
|
|
1249
|
+
}),
|
|
1250
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1251
|
+
"data-slot": "questionnaire-choice-label",
|
|
1252
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5 leading-snug",
|
|
1253
|
+
children: [labelledBy && /* @__PURE__ */ jsx("span", {
|
|
1254
|
+
id: labelledBy,
|
|
1255
|
+
children: text
|
|
1256
|
+
}), describedBy && /* @__PURE__ */ jsx("span", {
|
|
1257
|
+
id: describedBy,
|
|
1258
|
+
className: "flex flex-col gap-0.5",
|
|
1259
|
+
children: descriptions
|
|
1260
|
+
})]
|
|
1261
|
+
}),
|
|
1262
|
+
state.shortcut && /* @__PURE__ */ jsx("span", {
|
|
1263
|
+
"aria-hidden": "true",
|
|
1264
|
+
"data-slot": "questionnaire-choice-shortcut",
|
|
1265
|
+
className: "pointer-events-none ms-auto inline-flex size-5 shrink-0 items-center justify-center rounded-sm border border-input bg-background font-mono text-xs leading-none font-medium text-muted-foreground",
|
|
1266
|
+
children: state.shortcut
|
|
1267
|
+
})
|
|
1268
|
+
] });
|
|
1269
|
+
$[22] = describedBy;
|
|
1270
|
+
$[23] = descriptions;
|
|
1271
|
+
$[24] = disabled;
|
|
1272
|
+
$[25] = labelledBy;
|
|
1273
|
+
$[26] = multiple;
|
|
1274
|
+
$[27] = text;
|
|
1275
|
+
$[28] = value;
|
|
1276
|
+
$[29] = t6;
|
|
1277
|
+
} else t6 = $[29];
|
|
1278
|
+
let t7;
|
|
1279
|
+
if ($[30] !== props || $[31] !== t5 || $[32] !== t6) {
|
|
1280
|
+
t7 = {
|
|
1281
|
+
className: t5,
|
|
1282
|
+
children: t6,
|
|
1283
|
+
...props
|
|
1284
|
+
};
|
|
1285
|
+
$[30] = props;
|
|
1286
|
+
$[31] = t5;
|
|
1287
|
+
$[32] = t6;
|
|
1288
|
+
$[33] = t7;
|
|
1289
|
+
} else t7 = $[33];
|
|
1290
|
+
return (0, core_exports.usePart)(questionnaire, "choice", t4, t7, "label");
|
|
1291
|
+
}
|
|
1292
|
+
/** More about a choice, under its text. Put it directly inside `QuestionnaireChoice`. */
|
|
1293
|
+
function _temp(child) {
|
|
1294
|
+
return isValidElement(child) && child.type === QuestionnaireChoiceDescription;
|
|
1295
|
+
}
|
|
1296
|
+
function QuestionnaireChoiceDescription(t0) {
|
|
1297
|
+
const $ = c(8);
|
|
1298
|
+
let className;
|
|
1299
|
+
let props;
|
|
1300
|
+
if ($[0] !== t0) {
|
|
1301
|
+
({className, ...props} = t0);
|
|
1302
|
+
$[0] = t0;
|
|
1303
|
+
$[1] = className;
|
|
1304
|
+
$[2] = props;
|
|
1305
|
+
} else {
|
|
1306
|
+
className = $[1];
|
|
1307
|
+
props = $[2];
|
|
1308
|
+
}
|
|
1309
|
+
let t1;
|
|
1310
|
+
if ($[3] !== className) {
|
|
1311
|
+
t1 = cn("text-muted-foreground", className);
|
|
1312
|
+
$[3] = className;
|
|
1313
|
+
$[4] = t1;
|
|
1314
|
+
} else t1 = $[4];
|
|
1315
|
+
let t2;
|
|
1316
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
1317
|
+
t2 = /* @__PURE__ */ jsx("span", {
|
|
1318
|
+
"data-slot": "questionnaire-choice-description",
|
|
1319
|
+
className: t1,
|
|
1320
|
+
...props
|
|
1321
|
+
});
|
|
1322
|
+
$[5] = props;
|
|
1323
|
+
$[6] = t1;
|
|
1324
|
+
$[7] = t2;
|
|
1325
|
+
} else t2 = $[7];
|
|
1326
|
+
return t2;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* A freeform answer, after `QuestionnaireChoices` or on its own. Name it with
|
|
1330
|
+
* `aria-label`: a placeholder isn't a name. Its text is the item's answer in
|
|
1331
|
+
* `values`, so it starts from `defaultValues` like the choices do.
|
|
1332
|
+
*/
|
|
1333
|
+
function QuestionnaireInput(t0) {
|
|
1334
|
+
const $ = c(16);
|
|
1335
|
+
let className;
|
|
1336
|
+
let disabled;
|
|
1337
|
+
let props;
|
|
1338
|
+
if ($[0] !== t0) {
|
|
1339
|
+
({className, disabled, ...props} = t0);
|
|
1340
|
+
$[0] = t0;
|
|
1341
|
+
$[1] = className;
|
|
1342
|
+
$[2] = disabled;
|
|
1343
|
+
$[3] = props;
|
|
1344
|
+
} else {
|
|
1345
|
+
className = $[1];
|
|
1346
|
+
disabled = $[2];
|
|
1347
|
+
props = $[3];
|
|
1348
|
+
}
|
|
1349
|
+
const handle = useQuestionnaireHandle();
|
|
1350
|
+
const scope = useItemScope();
|
|
1351
|
+
let t1;
|
|
1352
|
+
if ($[4] !== scope.disabled || $[5] !== scope.invalid || $[6] !== scope.name || $[7] !== scope.required) {
|
|
1353
|
+
t1 = {
|
|
1354
|
+
value: scope.name,
|
|
1355
|
+
required: scope.required,
|
|
1356
|
+
disabled: scope.disabled,
|
|
1357
|
+
invalid: scope.invalid
|
|
1358
|
+
};
|
|
1359
|
+
$[4] = scope.disabled;
|
|
1360
|
+
$[5] = scope.invalid;
|
|
1361
|
+
$[6] = scope.name;
|
|
1362
|
+
$[7] = scope.required;
|
|
1363
|
+
$[8] = t1;
|
|
1364
|
+
} else t1 = $[8];
|
|
1365
|
+
let t2;
|
|
1366
|
+
if ($[9] !== className || $[10] !== disabled || $[11] !== handle || $[12] !== props || $[13] !== scope.disabled || $[14] !== scope.name) {
|
|
1367
|
+
t2 = {
|
|
1368
|
+
className: "group/questionnaire-input relative w-full min-w-0 [[data-slot=questionnaire-choices]+&]:-mt-2",
|
|
1369
|
+
children: (state) => /* @__PURE__ */ jsx(Input, {
|
|
1370
|
+
name: state.filled ? scope.name : void 0,
|
|
1371
|
+
value: state.text,
|
|
1372
|
+
disabled: disabled || scope.disabled,
|
|
1373
|
+
"aria-invalid": state.invalid || void 0,
|
|
1374
|
+
className: cnState("min-h-11 sm:min-h-0", className),
|
|
1375
|
+
onValueChange: (text, details) => {
|
|
1376
|
+
if (details.reason === "reset") return;
|
|
1377
|
+
handle.api.setText(scope.name, text, {
|
|
1378
|
+
reason: "input-change",
|
|
1379
|
+
event: details.event,
|
|
1380
|
+
source: details.source
|
|
1381
|
+
});
|
|
1382
|
+
},
|
|
1383
|
+
...props
|
|
1384
|
+
})
|
|
1385
|
+
};
|
|
1386
|
+
$[9] = className;
|
|
1387
|
+
$[10] = disabled;
|
|
1388
|
+
$[11] = handle;
|
|
1389
|
+
$[12] = props;
|
|
1390
|
+
$[13] = scope.disabled;
|
|
1391
|
+
$[14] = scope.name;
|
|
1392
|
+
$[15] = t2;
|
|
1393
|
+
} else t2 = $[15];
|
|
1394
|
+
return (0, core_exports.usePart)(questionnaire, "input", t1, t2, "div");
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Shows once the item fails validation. Without children it says what the
|
|
1398
|
+
* item needs; children replace the message.
|
|
1399
|
+
*/
|
|
1400
|
+
function QuestionnaireError(t0) {
|
|
1401
|
+
const $ = c(15);
|
|
1402
|
+
let children;
|
|
1403
|
+
let className;
|
|
1404
|
+
let props;
|
|
1405
|
+
if ($[0] !== t0) {
|
|
1406
|
+
({className, children, ...props} = t0);
|
|
1407
|
+
$[0] = t0;
|
|
1408
|
+
$[1] = children;
|
|
1409
|
+
$[2] = className;
|
|
1410
|
+
$[3] = props;
|
|
1411
|
+
} else {
|
|
1412
|
+
children = $[1];
|
|
1413
|
+
className = $[2];
|
|
1414
|
+
props = $[3];
|
|
1415
|
+
}
|
|
1416
|
+
const scope = useItemScope();
|
|
1417
|
+
let t1;
|
|
1418
|
+
if ($[4] !== scope.disabled || $[5] !== scope.invalid || $[6] !== scope.name || $[7] !== scope.required) {
|
|
1419
|
+
t1 = {
|
|
1420
|
+
value: scope.name,
|
|
1421
|
+
required: scope.required,
|
|
1422
|
+
disabled: scope.disabled,
|
|
1423
|
+
invalid: scope.invalid
|
|
1424
|
+
};
|
|
1425
|
+
$[4] = scope.disabled;
|
|
1426
|
+
$[5] = scope.invalid;
|
|
1427
|
+
$[6] = scope.name;
|
|
1428
|
+
$[7] = scope.required;
|
|
1429
|
+
$[8] = t1;
|
|
1430
|
+
} else t1 = $[8];
|
|
1431
|
+
let t2;
|
|
1432
|
+
if ($[9] !== className) {
|
|
1433
|
+
t2 = cnState("text-sm text-destructive", className);
|
|
1434
|
+
$[9] = className;
|
|
1435
|
+
$[10] = t2;
|
|
1436
|
+
} else t2 = $[10];
|
|
1437
|
+
const t3 = children ?? _temp2;
|
|
1438
|
+
let t4;
|
|
1439
|
+
if ($[11] !== props || $[12] !== t2 || $[13] !== t3) {
|
|
1440
|
+
t4 = {
|
|
1441
|
+
className: t2,
|
|
1442
|
+
children: t3,
|
|
1443
|
+
...props
|
|
1444
|
+
};
|
|
1445
|
+
$[11] = props;
|
|
1446
|
+
$[12] = t2;
|
|
1447
|
+
$[13] = t3;
|
|
1448
|
+
$[14] = t4;
|
|
1449
|
+
} else t4 = $[14];
|
|
1450
|
+
return (0, core_exports.usePart)(questionnaire, "error", t1, t4, "p");
|
|
1451
|
+
}
|
|
1452
|
+
/** The row of navigation buttons: Previous at the start, the rest at the end. */
|
|
1453
|
+
function _temp2(state) {
|
|
1454
|
+
return state.required ? "Answer this question to continue." : "Answer or skip this question to continue.";
|
|
1455
|
+
}
|
|
1456
|
+
function QuestionnaireActions(t0) {
|
|
1457
|
+
const $ = c(8);
|
|
1458
|
+
let className;
|
|
1459
|
+
let props;
|
|
1460
|
+
if ($[0] !== t0) {
|
|
1461
|
+
({className, ...props} = t0);
|
|
1462
|
+
$[0] = t0;
|
|
1463
|
+
$[1] = className;
|
|
1464
|
+
$[2] = props;
|
|
1465
|
+
} else {
|
|
1466
|
+
className = $[1];
|
|
1467
|
+
props = $[2];
|
|
1468
|
+
}
|
|
1469
|
+
let t1;
|
|
1470
|
+
if ($[3] !== className) {
|
|
1471
|
+
t1 = cn("grid min-h-11 w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:min-h-9", className);
|
|
1472
|
+
$[3] = className;
|
|
1473
|
+
$[4] = t1;
|
|
1474
|
+
} else t1 = $[4];
|
|
1475
|
+
let t2;
|
|
1476
|
+
if ($[5] !== props || $[6] !== t1) {
|
|
1477
|
+
t2 = /* @__PURE__ */ jsx("div", {
|
|
1478
|
+
"data-slot": "questionnaire-actions",
|
|
1479
|
+
className: t1,
|
|
1480
|
+
...props
|
|
1481
|
+
});
|
|
1482
|
+
$[5] = props;
|
|
1483
|
+
$[6] = t1;
|
|
1484
|
+
$[7] = t2;
|
|
1485
|
+
} else t2 = $[7];
|
|
1486
|
+
return t2;
|
|
1487
|
+
}
|
|
1488
|
+
const look = (shown) => ({
|
|
1489
|
+
"data-variant": shown.variant,
|
|
1490
|
+
"data-size": shown.size
|
|
1491
|
+
});
|
|
1492
|
+
function useAction(slot, text, defaults, place, t0) {
|
|
1493
|
+
const $ = c(23);
|
|
1494
|
+
let children;
|
|
1495
|
+
let className;
|
|
1496
|
+
let props;
|
|
1497
|
+
let size;
|
|
1498
|
+
let variant;
|
|
1499
|
+
if ($[0] !== t0) {
|
|
1500
|
+
({variant, size, className, children, ...props} = t0);
|
|
1501
|
+
$[0] = t0;
|
|
1502
|
+
$[1] = children;
|
|
1503
|
+
$[2] = className;
|
|
1504
|
+
$[3] = props;
|
|
1505
|
+
$[4] = size;
|
|
1506
|
+
$[5] = variant;
|
|
1507
|
+
} else {
|
|
1508
|
+
children = $[1];
|
|
1509
|
+
className = $[2];
|
|
1510
|
+
props = $[3];
|
|
1511
|
+
size = $[4];
|
|
1512
|
+
variant = $[5];
|
|
1513
|
+
}
|
|
1514
|
+
const t1 = variant ?? defaults.variant;
|
|
1515
|
+
const t2 = size ?? defaults.size;
|
|
1516
|
+
let t3;
|
|
1517
|
+
let t4;
|
|
1518
|
+
let t5;
|
|
1519
|
+
let t6;
|
|
1520
|
+
let t7;
|
|
1521
|
+
let t8;
|
|
1522
|
+
if ($[6] !== className || $[7] !== place || $[8] !== slot || $[9] !== t1 || $[10] !== t2) {
|
|
1523
|
+
const shown = {
|
|
1524
|
+
variant: t1,
|
|
1525
|
+
size: t2
|
|
1526
|
+
};
|
|
1527
|
+
t5 = core_exports.usePart;
|
|
1528
|
+
t6 = questionnaire;
|
|
1529
|
+
t7 = slot;
|
|
1530
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1531
|
+
t8 = {};
|
|
1532
|
+
$[17] = t8;
|
|
1533
|
+
} else t8 = $[17];
|
|
1534
|
+
t3 = look(shown);
|
|
1535
|
+
t4 = cnState([
|
|
1536
|
+
buttonVariants(shown),
|
|
1537
|
+
place,
|
|
1538
|
+
"row-start-1 min-h-11 sm:min-h-0"
|
|
1539
|
+
], className);
|
|
1540
|
+
$[6] = className;
|
|
1541
|
+
$[7] = place;
|
|
1542
|
+
$[8] = slot;
|
|
1543
|
+
$[9] = t1;
|
|
1544
|
+
$[10] = t2;
|
|
1545
|
+
$[11] = t3;
|
|
1546
|
+
$[12] = t4;
|
|
1547
|
+
$[13] = t5;
|
|
1548
|
+
$[14] = t6;
|
|
1549
|
+
$[15] = t7;
|
|
1550
|
+
$[16] = t8;
|
|
1551
|
+
} else {
|
|
1552
|
+
t3 = $[11];
|
|
1553
|
+
t4 = $[12];
|
|
1554
|
+
t5 = $[13];
|
|
1555
|
+
t6 = $[14];
|
|
1556
|
+
t7 = $[15];
|
|
1557
|
+
t8 = $[16];
|
|
1558
|
+
}
|
|
1559
|
+
const t9 = children ?? text;
|
|
1560
|
+
let t10;
|
|
1561
|
+
if ($[18] !== props || $[19] !== t3 || $[20] !== t4 || $[21] !== t9) {
|
|
1562
|
+
t10 = {
|
|
1563
|
+
...t3,
|
|
1564
|
+
className: t4,
|
|
1565
|
+
children: t9,
|
|
1566
|
+
...props
|
|
1567
|
+
};
|
|
1568
|
+
$[18] = props;
|
|
1569
|
+
$[19] = t3;
|
|
1570
|
+
$[20] = t4;
|
|
1571
|
+
$[21] = t9;
|
|
1572
|
+
$[22] = t10;
|
|
1573
|
+
} else t10 = $[22];
|
|
1574
|
+
return t5(t6, t7, t8, t10, "button");
|
|
1575
|
+
}
|
|
1576
|
+
/** Back one item. Hidden on the first. */
|
|
1577
|
+
function QuestionnairePrevious(props) {
|
|
1578
|
+
const $ = c(1);
|
|
1579
|
+
let t0;
|
|
1580
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1581
|
+
t0 = {
|
|
1582
|
+
variant: "outline",
|
|
1583
|
+
size: "default"
|
|
1584
|
+
};
|
|
1585
|
+
$[0] = t0;
|
|
1586
|
+
} else t0 = $[0];
|
|
1587
|
+
return useAction("previous", "Previous", t0, "col-start-1 justify-self-start", props);
|
|
1588
|
+
}
|
|
1589
|
+
/** Leaves an optional item unanswered on purpose. Hidden on a required one. */
|
|
1590
|
+
function QuestionnaireSkip(props) {
|
|
1591
|
+
const $ = c(1);
|
|
1592
|
+
let t0;
|
|
1593
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1594
|
+
t0 = {
|
|
1595
|
+
variant: "outline",
|
|
1596
|
+
size: "default"
|
|
1597
|
+
};
|
|
1598
|
+
$[0] = t0;
|
|
1599
|
+
} else t0 = $[0];
|
|
1600
|
+
return useAction("skip", "Skip", t0, "col-start-2 justify-self-end", props);
|
|
1601
|
+
}
|
|
1602
|
+
/** Validates the item and moves on. Hidden on the last, where Submit shows. */
|
|
1603
|
+
function QuestionnaireNext(props) {
|
|
1604
|
+
const $ = c(1);
|
|
1605
|
+
let t0;
|
|
1606
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1607
|
+
t0 = {
|
|
1608
|
+
variant: "default",
|
|
1609
|
+
size: "default"
|
|
1610
|
+
};
|
|
1611
|
+
$[0] = t0;
|
|
1612
|
+
} else t0 = $[0];
|
|
1613
|
+
return useAction("next", "Next", t0, "col-start-3 justify-self-end", props);
|
|
1614
|
+
}
|
|
1615
|
+
/** Submits the form. Shows on the last item. */
|
|
1616
|
+
function QuestionnaireSubmit(props) {
|
|
1617
|
+
const $ = c(1);
|
|
1618
|
+
let t0;
|
|
1619
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1620
|
+
t0 = {
|
|
1621
|
+
variant: "default",
|
|
1622
|
+
size: "default"
|
|
1623
|
+
};
|
|
1624
|
+
$[0] = t0;
|
|
1625
|
+
} else t0 = $[0];
|
|
1626
|
+
return useAction("submit", "Submit", t0, "col-start-3 justify-self-end", props);
|
|
1627
|
+
}
|
|
1628
|
+
export { Questionnaire, QuestionnaireActions, QuestionnaireChoice, QuestionnaireChoiceDescription, QuestionnaireChoices, QuestionnaireDescription, QuestionnaireError, QuestionnaireInput, QuestionnaireItem, QuestionnaireNext, QuestionnairePrevious, QuestionnaireProgress, QuestionnaireSkip, QuestionnaireSubmit, QuestionnaireTitle, useQuestionnaire };
|