@nuxt/ui 2.18.4 → 3.0.0-alpha.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 +18 -1
- package/cli/commands/init.mjs +83 -0
- package/cli/index.mjs +15 -0
- package/cli/package.json +13 -0
- package/cli/templates.mjs +171 -0
- package/cli/utils.mjs +17 -0
- package/dist/module.d.mts +10 -26
- package/dist/module.d.ts +10 -26
- package/dist/module.json +3 -3
- package/dist/module.mjs +2620 -152
- package/dist/runtime/assets/css/animations.css +1 -0
- package/dist/runtime/components/Accordion.vue +67 -0
- package/dist/runtime/components/Accordion.vue.d.ts +492 -0
- package/dist/runtime/components/Alert.vue +78 -0
- package/dist/runtime/components/Alert.vue.d.ts +548 -0
- package/dist/runtime/components/App.vue +32 -0
- package/dist/runtime/components/App.vue.d.ts +25 -0
- package/dist/runtime/components/Avatar.vue +48 -0
- package/dist/runtime/components/Avatar.vue.d.ts +384 -0
- package/dist/runtime/components/AvatarGroup.vue +74 -0
- package/dist/runtime/components/AvatarGroup.vue.d.ts +381 -0
- package/dist/runtime/components/Badge.vue +24 -0
- package/dist/runtime/components/Badge.vue.d.ts +422 -0
- package/dist/runtime/components/Breadcrumb.vue +60 -0
- package/dist/runtime/components/Breadcrumb.vue.d.ts +307 -0
- package/dist/runtime/components/Button.vue +55 -0
- package/dist/runtime/components/Button.vue.d.ts +949 -0
- package/dist/runtime/components/ButtonGroup.vue +29 -0
- package/dist/runtime/components/ButtonGroup.vue.d.ts +182 -0
- package/dist/runtime/components/Card.vue +33 -0
- package/dist/runtime/components/Card.vue.d.ts +191 -0
- package/dist/runtime/components/Checkbox.vue +89 -0
- package/dist/runtime/components/Checkbox.vue.d.ts +819 -0
- package/dist/runtime/components/Chip.vue +43 -0
- package/dist/runtime/components/Chip.vue.d.ts +590 -0
- package/dist/runtime/components/Collapsible.vue +33 -0
- package/dist/runtime/components/Collapsible.vue.d.ts +159 -0
- package/dist/runtime/components/CommandPalette.vue +210 -0
- package/dist/runtime/components/CommandPalette.vue.d.ts +684 -0
- package/dist/runtime/components/Container.vue +20 -0
- package/dist/runtime/components/Container.vue.d.ts +27 -0
- package/dist/runtime/components/ContextMenu.vue +51 -0
- package/dist/runtime/components/ContextMenu.vue.d.ts +796 -0
- package/dist/runtime/components/ContextMenuContent.vue +108 -0
- package/dist/runtime/components/ContextMenuContent.vue.d.ts +0 -0
- package/dist/runtime/components/Drawer.vue +73 -0
- package/dist/runtime/components/Drawer.vue.d.ts +343 -0
- package/dist/runtime/components/DropdownMenu.vue +55 -0
- package/dist/runtime/components/DropdownMenu.vue.d.ts +815 -0
- package/dist/runtime/components/DropdownMenuContent.vue +111 -0
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +0 -0
- package/dist/runtime/components/Form.vue +206 -0
- package/dist/runtime/components/Form.vue.d.ts +39 -0
- package/dist/runtime/components/FormField.vue +82 -0
- package/dist/runtime/components/FormField.vue.d.ts +356 -0
- package/dist/runtime/components/Icon.vue +16 -0
- package/dist/runtime/components/Icon.vue.d.ts +17 -0
- package/dist/runtime/components/Input.vue +140 -0
- package/dist/runtime/components/Input.vue.d.ts +1137 -0
- package/dist/runtime/components/InputMenu.vue +264 -0
- package/dist/runtime/components/InputMenu.vue.d.ts +2121 -0
- package/dist/runtime/components/Kbd.vue +27 -0
- package/dist/runtime/components/Kbd.vue.d.ts +169 -0
- package/dist/runtime/components/Link.vue +83 -0
- package/dist/runtime/components/Link.vue.d.ts +76 -0
- package/dist/runtime/components/LinkBase.vue +50 -0
- package/dist/runtime/components/LinkBase.vue.d.ts +49 -0
- package/dist/runtime/components/Modal.vue +100 -0
- package/dist/runtime/components/Modal.vue.d.ts +319 -0
- package/dist/runtime/components/ModalProvider.vue +12 -0
- package/dist/runtime/components/NavigationMenu.vue +125 -0
- package/dist/runtime/components/NavigationMenu.vue.d.ts +1789 -0
- package/dist/runtime/components/Pagination.vue +80 -0
- package/dist/runtime/components/Pagination.vue.d.ts +295 -0
- package/dist/runtime/components/Popover.vue +52 -0
- package/dist/runtime/components/Popover.vue.d.ts +197 -0
- package/dist/runtime/components/Progress.vue +126 -0
- package/dist/runtime/components/Progress.vue.d.ts +1781 -0
- package/dist/runtime/components/RadioGroup.vue +111 -0
- package/dist/runtime/components/RadioGroup.vue.d.ts +1715 -0
- package/dist/runtime/components/Select.vue +148 -0
- package/dist/runtime/components/Select.vue.d.ts +1569 -0
- package/dist/runtime/components/SelectMenu.vue +208 -0
- package/dist/runtime/components/SelectMenu.vue.d.ts +1661 -0
- package/dist/runtime/components/Separator.vue +47 -0
- package/dist/runtime/components/Separator.vue.d.ts +0 -0
- package/dist/runtime/components/Skeleton.vue +19 -0
- package/dist/runtime/components/Skeleton.vue.d.ts +26 -0
- package/dist/runtime/components/Slideover.vue +101 -0
- package/dist/runtime/components/Slideover.vue.d.ts +375 -0
- package/dist/runtime/components/SlideoverProvider.vue +12 -0
- package/dist/runtime/components/Slider.vue +83 -0
- package/dist/runtime/components/Slider.vue.d.ts +0 -0
- package/dist/runtime/components/Switch.vue +80 -0
- package/dist/runtime/components/Switch.vue.d.ts +1676 -0
- package/dist/runtime/components/Tabs.vue +61 -0
- package/dist/runtime/components/Tabs.vue.d.ts +934 -0
- package/dist/runtime/components/Textarea.vue +149 -0
- package/dist/runtime/components/Textarea.vue.d.ts +1133 -0
- package/dist/runtime/components/Toast.vue +112 -0
- package/dist/runtime/components/Toast.vue.d.ts +0 -0
- package/dist/runtime/components/Toaster.vue +109 -0
- package/dist/runtime/components/Toaster.vue.d.ts +362 -0
- package/dist/runtime/components/Tooltip.vue +52 -0
- package/dist/runtime/components/Tooltip.vue.d.ts +248 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +7 -5
- package/dist/runtime/composables/defineShortcuts.js +94 -65
- package/dist/runtime/composables/useAvatarGroup.d.ts +10 -0
- package/dist/runtime/composables/useAvatarGroup.js +10 -0
- package/dist/runtime/composables/useButtonGroup.d.ts +12 -17
- package/dist/runtime/composables/useButtonGroup.js +6 -56
- package/dist/runtime/composables/useComponentIcons.d.ts +26 -0
- package/dist/runtime/composables/useComponentIcons.js +26 -0
- package/dist/runtime/composables/useFormField.d.ts +31 -0
- package/dist/runtime/composables/useFormField.js +50 -0
- package/dist/runtime/composables/useKbd.d.ts +28 -0
- package/dist/runtime/composables/useKbd.js +46 -0
- package/dist/runtime/composables/useModal.d.ts +8 -4
- package/dist/runtime/composables/useModal.js +1 -0
- package/dist/runtime/composables/useSlideover.d.ts +9 -5
- package/dist/runtime/composables/useSlideover.js +3 -2
- package/dist/runtime/composables/useToast.d.ts +9 -17
- package/dist/runtime/composables/useToast.js +27 -13
- package/dist/runtime/plugins/colors.d.ts +0 -2
- package/dist/runtime/plugins/colors.js +9 -17
- package/dist/runtime/plugins/modal.d.ts +0 -0
- package/dist/runtime/plugins/slideover.d.ts +0 -0
- package/dist/runtime/plugins/{slideovers.js → slideover.js} +3 -3
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/component.d.ts +17 -14
- package/dist/runtime/types/component.js +0 -0
- package/dist/runtime/types/form.d.ts +63 -32
- package/dist/runtime/types/form.js +12 -0
- package/dist/runtime/types/index.d.ts +41 -30
- package/dist/runtime/types/index.js +42 -31
- package/dist/runtime/types/utils.d.ts +13 -32
- package/dist/runtime/types/utils.js +0 -0
- package/dist/runtime/utils/form.d.ts +15 -0
- package/dist/runtime/utils/form.js +66 -0
- package/dist/runtime/utils/fuse.d.ts +4 -0
- package/dist/runtime/utils/fuse.js +63 -0
- package/dist/runtime/utils/index.d.ts +4 -10
- package/dist/runtime/utils/index.js +40 -60
- package/dist/runtime/utils/link.d.ts +58 -71
- package/dist/runtime/utils/link.js +4 -124
- package/package.json +47 -45
- package/dist/runtime/components/data/Table.vue +0 -355
- package/dist/runtime/components/data/Table.vue.d.ts +0 -439
- package/dist/runtime/components/elements/Accordion.vue +0 -185
- package/dist/runtime/components/elements/Accordion.vue.d.ts +0 -223
- package/dist/runtime/components/elements/Alert.vue +0 -139
- package/dist/runtime/components/elements/Alert.vue.d.ts +0 -194
- package/dist/runtime/components/elements/Avatar.vue +0 -160
- package/dist/runtime/components/elements/Avatar.vue.d.ts +0 -255
- package/dist/runtime/components/elements/AvatarGroup.d.ts +0 -56
- package/dist/runtime/components/elements/AvatarGroup.js +0 -58
- package/dist/runtime/components/elements/Badge.vue +0 -75
- package/dist/runtime/components/elements/Badge.vue.d.ts +0 -109
- package/dist/runtime/components/elements/Button.vue +0 -193
- package/dist/runtime/components/elements/Button.vue.d.ts +0 -504
- package/dist/runtime/components/elements/ButtonGroup.d.ts +0 -153
- package/dist/runtime/components/elements/ButtonGroup.js +0 -51
- package/dist/runtime/components/elements/Carousel.vue +0 -165
- package/dist/runtime/components/elements/Carousel.vue.d.ts +0 -159
- package/dist/runtime/components/elements/Chip.vue +0 -85
- package/dist/runtime/components/elements/Chip.vue.d.ts +0 -162
- package/dist/runtime/components/elements/Dropdown.vue +0 -254
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +0 -254
- package/dist/runtime/components/elements/Icon.vue +0 -30
- package/dist/runtime/components/elements/Icon.vue.d.ts +0 -47
- package/dist/runtime/components/elements/Kbd.vue +0 -59
- package/dist/runtime/components/elements/Kbd.vue.d.ts +0 -86
- package/dist/runtime/components/elements/Link.vue +0 -95
- package/dist/runtime/components/elements/Link.vue.d.ts +0 -225
- package/dist/runtime/components/elements/Meter.vue +0 -170
- package/dist/runtime/components/elements/Meter.vue.d.ts +0 -279
- package/dist/runtime/components/elements/MeterGroup.d.ts +0 -135
- package/dist/runtime/components/elements/MeterGroup.js +0 -159
- package/dist/runtime/components/elements/Progress.vue +0 -203
- package/dist/runtime/components/elements/Progress.vue.d.ts +0 -280
- package/dist/runtime/components/forms/Checkbox.vue +0 -143
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +0 -179
- package/dist/runtime/components/forms/Form.vue +0 -219
- package/dist/runtime/components/forms/Form.vue.d.ts +0 -53
- package/dist/runtime/components/forms/FormGroup.vue +0 -128
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +0 -169
- package/dist/runtime/components/forms/Input.vue +0 -300
- package/dist/runtime/components/forms/Input.vue.d.ts +0 -482
- package/dist/runtime/components/forms/InputMenu.vue +0 -439
- package/dist/runtime/components/forms/InputMenu.vue.d.ts +0 -700
- package/dist/runtime/components/forms/Radio.vue +0 -140
- package/dist/runtime/components/forms/Radio.vue.d.ts +0 -168
- package/dist/runtime/components/forms/RadioGroup.vue +0 -145
- package/dist/runtime/components/forms/RadioGroup.vue.d.ts +0 -176
- package/dist/runtime/components/forms/Range.vue +0 -173
- package/dist/runtime/components/forms/Range.vue.d.ts +0 -268
- package/dist/runtime/components/forms/Select.vue +0 -322
- package/dist/runtime/components/forms/Select.vue.d.ts +0 -471
- package/dist/runtime/components/forms/SelectMenu.vue +0 -546
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +0 -754
- package/dist/runtime/components/forms/Textarea.vue +0 -231
- package/dist/runtime/components/forms/Textarea.vue.d.ts +0 -436
- package/dist/runtime/components/forms/Toggle.vue +0 -171
- package/dist/runtime/components/forms/Toggle.vue.d.ts +0 -262
- package/dist/runtime/components/layout/Card.vue +0 -63
- package/dist/runtime/components/layout/Card.vue.d.ts +0 -89
- package/dist/runtime/components/layout/Container.vue +0 -48
- package/dist/runtime/components/layout/Container.vue.d.ts +0 -53
- package/dist/runtime/components/layout/Divider.vue +0 -108
- package/dist/runtime/components/layout/Divider.vue.d.ts +0 -198
- package/dist/runtime/components/layout/Skeleton.vue +0 -46
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +0 -53
- package/dist/runtime/components/navigation/Breadcrumb.vue +0 -82
- package/dist/runtime/components/navigation/Breadcrumb.vue.d.ts +0 -95
- package/dist/runtime/components/navigation/CommandPalette.vue +0 -345
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +0 -390
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +0 -152
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +0 -60
- package/dist/runtime/components/navigation/HorizontalNavigation.vue +0 -102
- package/dist/runtime/components/navigation/HorizontalNavigation.vue.d.ts +0 -99
- package/dist/runtime/components/navigation/Pagination.vue +0 -270
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +0 -260
- package/dist/runtime/components/navigation/Tabs.vue +0 -163
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +0 -165
- package/dist/runtime/components/navigation/VerticalNavigation.vue +0 -105
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +0 -113
- package/dist/runtime/components/overlays/ContextMenu.vue +0 -85
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +0 -126
- package/dist/runtime/components/overlays/Modal.vue +0 -122
- package/dist/runtime/components/overlays/Modal.vue.d.ts +0 -166
- package/dist/runtime/components/overlays/Modals.client.vue +0 -18
- package/dist/runtime/components/overlays/Notification.vue +0 -212
- package/dist/runtime/components/overlays/Notification.vue.d.ts +0 -235
- package/dist/runtime/components/overlays/Notifications.vue +0 -69
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +0 -66
- package/dist/runtime/components/overlays/Popover.vue +0 -213
- package/dist/runtime/components/overlays/Popover.vue.d.ts +0 -220
- package/dist/runtime/components/overlays/Slideover.vue +0 -152
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +0 -167
- package/dist/runtime/components/overlays/Slideovers.client.vue +0 -18
- package/dist/runtime/components/overlays/Tooltip.vue +0 -127
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +0 -165
- package/dist/runtime/composables/useCarouselScroll.d.ts +0 -2
- package/dist/runtime/composables/useCarouselScroll.js +0 -37
- package/dist/runtime/composables/useCopyToClipboard.d.ts +0 -10
- package/dist/runtime/composables/useCopyToClipboard.js +0 -26
- package/dist/runtime/composables/useFormGroup.d.ts +0 -18
- package/dist/runtime/composables/useFormGroup.js +0 -45
- package/dist/runtime/composables/usePopper.d.ts +0 -268
- package/dist/runtime/composables/usePopper.js +0 -94
- package/dist/runtime/composables/useShortcuts.d.ts +0 -12
- package/dist/runtime/composables/useShortcuts.js +0 -26
- package/dist/runtime/composables/useTimer.d.ts +0 -8
- package/dist/runtime/composables/useTimer.js +0 -51
- package/dist/runtime/composables/useUI.d.ts +0 -10
- package/dist/runtime/composables/useUI.js +0 -24
- package/dist/runtime/plugins/modals.d.ts +0 -2
- package/dist/runtime/plugins/slideovers.d.ts +0 -2
- package/dist/runtime/types/accordion.d.ts +0 -9
- package/dist/runtime/types/alert.d.ts +0 -12
- package/dist/runtime/types/avatar.d.ts +0 -17
- package/dist/runtime/types/badge.d.ts +0 -15
- package/dist/runtime/types/breadcrumb.d.ts +0 -10
- package/dist/runtime/types/button.d.ts +0 -31
- package/dist/runtime/types/chip.d.ts +0 -15
- package/dist/runtime/types/clipboard.d.ts +0 -3
- package/dist/runtime/types/command-palette.d.ts +0 -29
- package/dist/runtime/types/divider.d.ts +0 -3
- package/dist/runtime/types/dropdown.d.ts +0 -15
- package/dist/runtime/types/form-group.d.ts +0 -5
- package/dist/runtime/types/horizontal-navigation.d.ts +0 -13
- package/dist/runtime/types/input.d.ts +0 -8
- package/dist/runtime/types/kbd.d.ts +0 -5
- package/dist/runtime/types/link.d.ts +0 -12
- package/dist/runtime/types/meter.d.ts +0 -5
- package/dist/runtime/types/modal.d.ts +0 -18
- package/dist/runtime/types/notification.d.ts +0 -24
- package/dist/runtime/types/popper.d.ts +0 -17
- package/dist/runtime/types/progress.d.ts +0 -6
- package/dist/runtime/types/range.d.ts +0 -7
- package/dist/runtime/types/select.d.ts +0 -8
- package/dist/runtime/types/slideover.d.ts +0 -16
- package/dist/runtime/types/tabs.d.ts +0 -8
- package/dist/runtime/types/textarea.d.ts +0 -8
- package/dist/runtime/types/toggle.d.ts +0 -7
- package/dist/runtime/types/tooltip.d.ts +0 -7
- package/dist/runtime/types/vertical-navigation.d.ts +0 -13
- package/dist/runtime/ui.config/data/table.d.ts +0 -81
- package/dist/runtime/ui.config/data/table.js +0 -80
- package/dist/runtime/ui.config/elements/accordion.d.ts +0 -23
- package/dist/runtime/ui.config/elements/accordion.js +0 -22
- package/dist/runtime/ui.config/elements/alert.d.ts +0 -41
- package/dist/runtime/ui.config/elements/alert.js +0 -40
- package/dist/runtime/ui.config/elements/avatar.d.ts +0 -60
- package/dist/runtime/ui.config/elements/avatar.js +0 -59
- package/dist/runtime/ui.config/elements/avatarGroup.d.ts +0 -6
- package/dist/runtime/ui.config/elements/avatarGroup.js +0 -5
- package/dist/runtime/ui.config/elements/badge.d.ts +0 -34
- package/dist/runtime/ui.config/elements/badge.js +0 -33
- package/dist/runtime/ui.config/elements/button.d.ts +0 -81
- package/dist/runtime/ui.config/elements/button.js +0 -80
- package/dist/runtime/ui.config/elements/buttonGroup.d.ts +0 -101
- package/dist/runtime/ui.config/elements/buttonGroup.js +0 -19
- package/dist/runtime/ui.config/elements/carousel.d.ts +0 -27
- package/dist/runtime/ui.config/elements/carousel.js +0 -26
- package/dist/runtime/ui.config/elements/chip.d.ts +0 -35
- package/dist/runtime/ui.config/elements/chip.js +0 -34
- package/dist/runtime/ui.config/elements/dropdown.d.ts +0 -59
- package/dist/runtime/ui.config/elements/dropdown.js +0 -57
- package/dist/runtime/ui.config/elements/kbd.d.ts +0 -17
- package/dist/runtime/ui.config/elements/kbd.js +0 -16
- package/dist/runtime/ui.config/elements/meter.d.ts +0 -77
- package/dist/runtime/ui.config/elements/meter.js +0 -76
- package/dist/runtime/ui.config/elements/meterGroup.d.ts +0 -52
- package/dist/runtime/ui.config/elements/meterGroup.js +0 -24
- package/dist/runtime/ui.config/elements/progress.d.ts +0 -75
- package/dist/runtime/ui.config/elements/progress.js +0 -74
- package/dist/runtime/ui.config/forms/checkbox.d.ts +0 -19
- package/dist/runtime/ui.config/forms/checkbox.js +0 -18
- package/dist/runtime/ui.config/forms/formGroup.d.ts +0 -26
- package/dist/runtime/ui.config/forms/formGroup.js +0 -26
- package/dist/runtime/ui.config/forms/input.d.ts +0 -110
- package/dist/runtime/ui.config/forms/input.js +0 -109
- package/dist/runtime/ui.config/forms/inputMenu.d.ts +0 -64
- package/dist/runtime/ui.config/forms/inputMenu.js +0 -62
- package/dist/runtime/ui.config/forms/radio.d.ts +0 -18
- package/dist/runtime/ui.config/forms/radio.js +0 -17
- package/dist/runtime/ui.config/forms/radioGroup.d.ts +0 -9
- package/dist/runtime/ui.config/forms/radioGroup.js +0 -8
- package/dist/runtime/ui.config/forms/range.d.ts +0 -64
- package/dist/runtime/ui.config/forms/range.js +0 -63
- package/dist/runtime/ui.config/forms/select.d.ts +0 -111
- package/dist/runtime/ui.config/forms/select.js +0 -13
- package/dist/runtime/ui.config/forms/selectMenu.d.ts +0 -70
- package/dist/runtime/ui.config/forms/selectMenu.js +0 -32
- package/dist/runtime/ui.config/forms/textarea.d.ts +0 -109
- package/dist/runtime/ui.config/forms/textarea.js +0 -10
- package/dist/runtime/ui.config/forms/toggle.d.ts +0 -63
- package/dist/runtime/ui.config/forms/toggle.js +0 -62
- package/dist/runtime/ui.config/index.d.ts +0 -43
- package/dist/runtime/ui.config/index.js +0 -43
- package/dist/runtime/ui.config/layout/card.d.ts +0 -24
- package/dist/runtime/ui.config/layout/card.js +0 -23
- package/dist/runtime/ui.config/layout/container.d.ts +0 -6
- package/dist/runtime/ui.config/layout/container.js +0 -5
- package/dist/runtime/ui.config/layout/divider.d.ts +0 -52
- package/dist/runtime/ui.config/layout/divider.js +0 -51
- package/dist/runtime/ui.config/layout/skeleton.d.ts +0 -6
- package/dist/runtime/ui.config/layout/skeleton.js +0 -5
- package/dist/runtime/ui.config/navigation/breadcrumb.d.ts +0 -21
- package/dist/runtime/ui.config/navigation/breadcrumb.js +0 -20
- package/dist/runtime/ui.config/navigation/commandPalette.d.ts +0 -72
- package/dist/runtime/ui.config/navigation/commandPalette.js +0 -71
- package/dist/runtime/ui.config/navigation/horizontalNavigation.d.ts +0 -27
- package/dist/runtime/ui.config/navigation/horizontalNavigation.js +0 -26
- package/dist/runtime/ui.config/navigation/pagination.d.ts +0 -35
- package/dist/runtime/ui.config/navigation/pagination.js +0 -34
- package/dist/runtime/ui.config/navigation/tabs.d.ts +0 -35
- package/dist/runtime/ui.config/navigation/tabs.js +0 -34
- package/dist/runtime/ui.config/navigation/verticalNavigation.d.ts +0 -34
- package/dist/runtime/ui.config/navigation/verticalNavigation.js +0 -33
- package/dist/runtime/ui.config/overlays/contextMenu.d.ts +0 -31
- package/dist/runtime/ui.config/overlays/contextMenu.js +0 -25
- package/dist/runtime/ui.config/overlays/modal.d.ts +0 -36
- package/dist/runtime/ui.config/overlays/modal.js +0 -37
- package/dist/runtime/ui.config/overlays/notification.d.ts +0 -50
- package/dist/runtime/ui.config/overlays/notification.js +0 -50
- package/dist/runtime/ui.config/overlays/notifications.d.ts +0 -7
- package/dist/runtime/ui.config/overlays/notifications.js +0 -6
- package/dist/runtime/ui.config/overlays/popover.d.ts +0 -47
- package/dist/runtime/ui.config/overlays/popover.js +0 -41
- package/dist/runtime/ui.config/overlays/slideover.d.ts +0 -35
- package/dist/runtime/ui.config/overlays/slideover.js +0 -36
- package/dist/runtime/ui.config/overlays/tooltip.d.ts +0 -37
- package/dist/runtime/ui.config/overlays/tooltip.js +0 -34
- package/dist/runtime/ui.config/popper.d.ts +0 -8
- package/dist/runtime/ui.config/popper.js +0 -9
- package/dist/runtime/ui.css +0 -1
- package/dist/runtime/utils/colors.d.ts +0 -11
- package/dist/runtime/utils/colors.js +0 -307
- package/dist/runtime/utils/lodash.d.ts +0 -2
- package/dist/runtime/utils/lodash.js +0 -23
- package/dist/runtime/plugins/{modals.js → modal.js} +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import theme from "#build/ui/dropdown-menu";
|
|
4
|
+
const dropdownMenu = tv(theme)();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts" generic="T extends DropdownMenuItem">
|
|
8
|
+
import { computed } from 'vue'
|
|
9
|
+
import { DropdownMenu } from 'radix-vue/namespaced'
|
|
10
|
+
import { useForwardPropsEmits } from 'radix-vue'
|
|
11
|
+
import { reactiveOmit, createReusableTemplate } from '@vueuse/core'
|
|
12
|
+
import { useAppConfig } from '#imports'
|
|
13
|
+
import ULinkBase from './LinkBase.vue'
|
|
14
|
+
import ULink from './Link.vue'
|
|
15
|
+
import UAvatar from './Avatar.vue'
|
|
16
|
+
import UIcon from './Icon.vue'
|
|
17
|
+
import UKbd from './Kbd.vue'
|
|
18
|
+
import { omit } from '../utils'
|
|
19
|
+
import { pickLinkProps } from '../utils/link'
|
|
20
|
+
|
|
21
|
+
const props = defineProps<DropdownMenuContentProps<T>>()
|
|
22
|
+
const emits = defineEmits<DropdownMenuContentEmits>()
|
|
23
|
+
const slots = defineSlots<DropdownMenuContentSlots<T>>()
|
|
24
|
+
|
|
25
|
+
const appConfig = useAppConfig()
|
|
26
|
+
const contentProps = useForwardPropsEmits(reactiveOmit(props, 'sub', 'items', 'portal', 'class', 'ui'), emits)
|
|
27
|
+
const proxySlots = omit(slots, ['default']) as Record<string, DropdownMenuContentSlots<T>[string]>
|
|
28
|
+
|
|
29
|
+
const [DefineItemTemplate, ReuseItemTemplate] = createReusableTemplate<{ item: DropdownMenuItem, active?: boolean, index: number }>()
|
|
30
|
+
|
|
31
|
+
const groups = computed(() => props.items?.length ? (Array.isArray(props.items[0]) ? props.items : [props.items]) as T[][] : [])
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<DefineItemTemplate v-slot="{ item, active, index }">
|
|
36
|
+
<slot :name="item.slot || 'item'" :item="(item as T)" :index="index">
|
|
37
|
+
<slot :name="item.slot ? `${item.slot}-leading`: 'item-leading'" :item="(item as T)" :active="active" :index="index">
|
|
38
|
+
<UAvatar v-if="item.avatar" :size="((props.uiOverride?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="ui.itemLeadingAvatar({ class: uiOverride?.itemLeadingAvatar, active })" />
|
|
39
|
+
<UIcon v-else-if="item.icon" :name="item.icon" :class="ui.itemLeadingIcon({ class: uiOverride?.itemLeadingIcon, active })" />
|
|
40
|
+
</slot>
|
|
41
|
+
|
|
42
|
+
<span v-if="item.label || !!slots[item.slot ? `${item.slot}-label`: 'item-label']" :class="ui.itemLabel({ class: uiOverride?.itemLabel, active })">
|
|
43
|
+
<slot :name="item.slot ? `${item.slot}-label`: 'item-label'" :item="(item as T)" :active="active" :index="index">
|
|
44
|
+
{{ item.label }}
|
|
45
|
+
</slot>
|
|
46
|
+
|
|
47
|
+
<UIcon v-if="item.target === '_blank'" :name="appConfig.ui.icons.external" :class="ui.itemLabelExternalIcon({ class: uiOverride?.itemLabelExternalIcon, active })" />
|
|
48
|
+
</span>
|
|
49
|
+
|
|
50
|
+
<span v-if="item.children?.length || item.kbds?.length || !!slots[item.slot ? `${item.slot}-trailing`: 'item-trailing']" :class="ui.itemTrailing({ class: uiOverride?.itemTrailing })">
|
|
51
|
+
<slot :name="item.slot ? `${item.slot}-trailing`: 'item-trailing'" :item="(item as T)" :active="active" :index="index">
|
|
52
|
+
<UIcon v-if="item.children?.length" :name="appConfig.ui.icons.chevronRight" :class="ui.itemTrailingIcon({ class: uiOverride?.itemTrailingIcon, active })" />
|
|
53
|
+
<span v-else-if="item.kbds?.length" :class="ui.itemTrailingKbds({ class: uiOverride?.itemTrailingKbds })">
|
|
54
|
+
<UKbd v-for="(kbd, kbdIndex) in item.kbds" :key="kbdIndex" :size="((props.uiOverride?.itemTrailingKbdsSize || ui.itemTrailingKbdsSize()) as KbdProps['size'])" v-bind="typeof kbd === 'string' ? { value: kbd } : kbd" />
|
|
55
|
+
</span>
|
|
56
|
+
</slot>
|
|
57
|
+
</span>
|
|
58
|
+
</slot>
|
|
59
|
+
</DefineItemTemplate>
|
|
60
|
+
|
|
61
|
+
<DropdownMenu.Portal :disabled="!portal">
|
|
62
|
+
<component :is="sub ? DropdownMenu.SubContent : DropdownMenu.Content" :class="props.class" v-bind="contentProps">
|
|
63
|
+
<DropdownMenu.Group v-for="(group, groupIndex) in groups" :key="`group-${groupIndex}`" :class="ui.group({ class: uiOverride?.group })">
|
|
64
|
+
<template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
|
|
65
|
+
<DropdownMenu.Label v-if="item.type === 'label'" :class="ui.label({ class: uiOverride?.label })">
|
|
66
|
+
<ReuseItemTemplate :item="item" :index="index" />
|
|
67
|
+
</DropdownMenu.Label>
|
|
68
|
+
<DropdownMenu.Separator v-else-if="item.type === 'separator'" :class="ui.separator({ class: uiOverride?.separator })" />
|
|
69
|
+
<DropdownMenu.Sub v-else-if="item?.children?.length" :open="item.open" :default-open="item.defaultOpen">
|
|
70
|
+
<DropdownMenu.SubTrigger
|
|
71
|
+
as="button"
|
|
72
|
+
type="button"
|
|
73
|
+
:disabled="item.disabled"
|
|
74
|
+
:text-value="item.label"
|
|
75
|
+
:class="ui.item({ class: uiOverride?.item })"
|
|
76
|
+
>
|
|
77
|
+
<ReuseItemTemplate :item="item" :index="index" />
|
|
78
|
+
</DropdownMenu.SubTrigger>
|
|
79
|
+
|
|
80
|
+
<UDropdownMenuContent
|
|
81
|
+
sub
|
|
82
|
+
:class="props.class"
|
|
83
|
+
:ui="ui"
|
|
84
|
+
:ui-override="uiOverride"
|
|
85
|
+
:portal="portal"
|
|
86
|
+
:items="item.children"
|
|
87
|
+
side="right"
|
|
88
|
+
align="start"
|
|
89
|
+
:align-offset="-4"
|
|
90
|
+
:side-offset="3"
|
|
91
|
+
v-bind="item.content"
|
|
92
|
+
>
|
|
93
|
+
<template v-for="(_, name) in proxySlots" #[name]="slotData: any">
|
|
94
|
+
<slot :name="name" v-bind="slotData" />
|
|
95
|
+
</template>
|
|
96
|
+
</UDropdownMenuContent>
|
|
97
|
+
</DropdownMenu.Sub>
|
|
98
|
+
<DropdownMenu.Item v-else as-child :disabled="item.disabled" :text-value="item.label" @select="item.select">
|
|
99
|
+
<ULink v-slot="{ active, ...slotProps }" v-bind="pickLinkProps(item as Omit<DropdownMenuItem, 'type'>)" custom>
|
|
100
|
+
<ULinkBase v-bind="slotProps" :class="ui.item({ class: [uiOverride?.item, item.class], active })">
|
|
101
|
+
<ReuseItemTemplate :item="item" :active="active" :index="index" />
|
|
102
|
+
</ULinkBase>
|
|
103
|
+
</ULink>
|
|
104
|
+
</DropdownMenu.Item>
|
|
105
|
+
</template>
|
|
106
|
+
</DropdownMenu.Group>
|
|
107
|
+
|
|
108
|
+
<slot />
|
|
109
|
+
</component>
|
|
110
|
+
</DropdownMenu.Portal>
|
|
111
|
+
</template>
|
|
File without changes
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import _appConfig from "#build/app.config";
|
|
4
|
+
import theme from "#build/ui/form";
|
|
5
|
+
const appConfig = _appConfig;
|
|
6
|
+
const form = tv({ extend: tv(theme), ...appConfig.ui?.form || {} });
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup generic="T extends object">
|
|
10
|
+
import { provide, inject, nextTick, ref, onUnmounted, onMounted, computed, useId } from 'vue'
|
|
11
|
+
import { useEventBus } from '@vueuse/core'
|
|
12
|
+
import { formOptionsInjectionKey, formInputsInjectionKey, formBusInjectionKey } from '../composables/useFormField'
|
|
13
|
+
import { getYupErrors, isYupSchema, getValibotError, isValibotSchema, getZodErrors, isZodSchema, getJoiErrors, isJoiSchema } from '../utils/form'
|
|
14
|
+
import { FormValidationException } from '../types/form'
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<FormProps<T>>(), {
|
|
17
|
+
validateOn() {
|
|
18
|
+
return ['input', 'blur', 'change'] as FormInputEvents[]
|
|
19
|
+
},
|
|
20
|
+
validateOnInputDelay: 300
|
|
21
|
+
})
|
|
22
|
+
const emits = defineEmits<FormEmits<T>>()
|
|
23
|
+
defineSlots<FormSlots>()
|
|
24
|
+
|
|
25
|
+
const formId = props.id ?? useId()
|
|
26
|
+
|
|
27
|
+
const bus = useEventBus<FormEvent>(`form-${formId}`)
|
|
28
|
+
const parentBus = inject(
|
|
29
|
+
formBusInjectionKey,
|
|
30
|
+
undefined
|
|
31
|
+
)
|
|
32
|
+
provide(formBusInjectionKey, bus)
|
|
33
|
+
|
|
34
|
+
const nestedForms = ref<Map<string | number, { validate: () => any }>>(new Map())
|
|
35
|
+
|
|
36
|
+
onMounted(async () => {
|
|
37
|
+
bus.on(async (event) => {
|
|
38
|
+
if (event.type === 'attach') {
|
|
39
|
+
nestedForms.value.set(event.formId, { validate: event.validate })
|
|
40
|
+
} else if (event.type === 'detach') {
|
|
41
|
+
nestedForms.value.delete(event.formId)
|
|
42
|
+
} else if (props.validateOn?.includes(event.type as FormInputEvents)) {
|
|
43
|
+
await _validate({ name: event.name, silent: true, nested: false })
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
onUnmounted(() => {
|
|
49
|
+
bus.reset()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
onMounted(async () => {
|
|
53
|
+
if (parentBus) {
|
|
54
|
+
await nextTick()
|
|
55
|
+
parentBus.emit({ type: 'attach', validate: _validate, formId })
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
onUnmounted(() => {
|
|
60
|
+
if (parentBus) {
|
|
61
|
+
parentBus.emit({ type: 'detach', formId })
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
provide(formOptionsInjectionKey, computed(() => ({
|
|
66
|
+
disabled: props.disabled,
|
|
67
|
+
validateOnInputDelay: props.validateOnInputDelay
|
|
68
|
+
})))
|
|
69
|
+
|
|
70
|
+
const errors = ref<FormErrorWithId[]>([])
|
|
71
|
+
provide('form-errors', errors)
|
|
72
|
+
|
|
73
|
+
const inputs = ref<Record<string, string>>({})
|
|
74
|
+
provide(formInputsInjectionKey, inputs)
|
|
75
|
+
|
|
76
|
+
function resolveErrorIds(errs: FormError[]): FormErrorWithId[] {
|
|
77
|
+
return errs.map(err => ({
|
|
78
|
+
...err,
|
|
79
|
+
id: inputs.value[err.name]
|
|
80
|
+
}))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function getErrors(): Promise<FormErrorWithId[]> {
|
|
84
|
+
let errs = props.validate ? (await props.validate(props.state)) ?? [] : []
|
|
85
|
+
|
|
86
|
+
if (props.schema) {
|
|
87
|
+
if (isZodSchema(props.schema)) {
|
|
88
|
+
errs = errs.concat(await getZodErrors(props.state, props.schema))
|
|
89
|
+
} else if (isYupSchema(props.schema)) {
|
|
90
|
+
errs = errs.concat(await getYupErrors(props.state, props.schema))
|
|
91
|
+
} else if (isJoiSchema(props.schema)) {
|
|
92
|
+
errs = errs.concat(await getJoiErrors(props.state, props.schema))
|
|
93
|
+
} else if (isValibotSchema(props.schema)) {
|
|
94
|
+
errs = errs.concat(await getValibotError(props.state, props.schema))
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error('Form validation failed: Unsupported form schema')
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return resolveErrorIds(errs)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function _validate(opts: { name?: string | string[], silent?: boolean, nested?: boolean } = { silent: false, nested: true }): Promise<T | false> {
|
|
104
|
+
const names = opts.name && !Array.isArray(opts.name) ? [opts.name] : opts.name
|
|
105
|
+
|
|
106
|
+
const nestedValidatePromises = !names && opts.nested
|
|
107
|
+
? Array.from(nestedForms.value.values()).map(
|
|
108
|
+
({ validate }) => validate().then(() => undefined).catch((error: Error) => {
|
|
109
|
+
if (!(error instanceof FormValidationException)) {
|
|
110
|
+
throw error
|
|
111
|
+
}
|
|
112
|
+
return error
|
|
113
|
+
})
|
|
114
|
+
)
|
|
115
|
+
: []
|
|
116
|
+
|
|
117
|
+
if (names) {
|
|
118
|
+
const otherErrors = errors.value.filter(error => !names!.includes(error.name))
|
|
119
|
+
const pathErrors = (await getErrors()).filter(error => names!.includes(error.name)
|
|
120
|
+
)
|
|
121
|
+
errors.value = otherErrors.concat(pathErrors)
|
|
122
|
+
} else {
|
|
123
|
+
errors.value = await getErrors()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const childErrors = nestedValidatePromises ? await Promise.all(nestedValidatePromises) : []
|
|
127
|
+
if (errors.value.length + childErrors.length > 0) {
|
|
128
|
+
if (opts.silent) return false
|
|
129
|
+
throw new FormValidationException(formId, errors.value, childErrors)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return props.state as T
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function onSubmit(payload: Event) {
|
|
136
|
+
const event = payload as SubmitEvent
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await _validate({ nested: true })
|
|
140
|
+
const submitEvent: FormSubmitEvent<any> = {
|
|
141
|
+
...event,
|
|
142
|
+
data: props.state
|
|
143
|
+
}
|
|
144
|
+
emits('submit', submitEvent)
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (!(error instanceof FormValidationException)) {
|
|
147
|
+
throw error
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const errorEvent: FormErrorEvent = {
|
|
151
|
+
...event,
|
|
152
|
+
errors: error.errors,
|
|
153
|
+
childrens: error.childrens
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
emits('error', errorEvent)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
defineExpose<Form<T>>({
|
|
161
|
+
validate: _validate,
|
|
162
|
+
errors,
|
|
163
|
+
|
|
164
|
+
setErrors(errs: FormError[], name?: string) {
|
|
165
|
+
if (name) {
|
|
166
|
+
errors.value = errors.value
|
|
167
|
+
.filter(error => error.name !== name)
|
|
168
|
+
.concat(resolveErrorIds(errs))
|
|
169
|
+
} else {
|
|
170
|
+
errors.value = resolveErrorIds(errs)
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
async submit() {
|
|
175
|
+
await onSubmit(new Event('submit'))
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
getErrors(name?: string) {
|
|
179
|
+
if (name) {
|
|
180
|
+
return errors.value.filter(err => err.name === name)
|
|
181
|
+
}
|
|
182
|
+
return errors.value
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
clear(name?: string) {
|
|
186
|
+
if (name) {
|
|
187
|
+
errors.value = errors.value.filter(err => err.name !== name)
|
|
188
|
+
} else {
|
|
189
|
+
errors.value = []
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
disabled: computed(() => props.disabled)
|
|
194
|
+
})
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<component
|
|
199
|
+
:is="parentBus ? 'div' : 'form'"
|
|
200
|
+
:id="formId"
|
|
201
|
+
:class="form({ class: props.class })"
|
|
202
|
+
@submit.prevent="onSubmit"
|
|
203
|
+
>
|
|
204
|
+
<slot />
|
|
205
|
+
</component>
|
|
206
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, Form } from '../types/form.js';
|
|
2
|
+
export interface FormProps<T extends object> {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
schema?: FormSchema<T>;
|
|
5
|
+
state: Partial<T>;
|
|
6
|
+
validate?: (state: Partial<T>) => Promise<FormError[]>;
|
|
7
|
+
validateOn?: FormInputEvents[];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
validateOnInputDelay?: number;
|
|
10
|
+
class?: any;
|
|
11
|
+
}
|
|
12
|
+
export interface FormEmits<T extends object> {
|
|
13
|
+
(e: 'submit', payload: FormSubmitEvent<T>): void;
|
|
14
|
+
(e: 'error', payload: FormErrorEvent): void;
|
|
15
|
+
}
|
|
16
|
+
export interface FormSlots {
|
|
17
|
+
default(props?: {}): any;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
20
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
21
|
+
readonly onError?: ((payload: FormErrorEvent) => any) | undefined;
|
|
22
|
+
readonly onSubmit?: ((payload: FormSubmitEvent<T>) => any) | undefined;
|
|
23
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<{}> & Readonly<{
|
|
24
|
+
onError?: ((payload: FormErrorEvent) => any) | undefined;
|
|
25
|
+
onSubmit?: ((payload: FormSubmitEvent<T>) => any) | undefined;
|
|
26
|
+
}>, never>, "onSubmit" | "onError"> & FormProps<T>> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
|
|
27
|
+
expose(exposed: import("vue").ShallowUnwrapRef<Form<T>>): void;
|
|
28
|
+
attrs: any;
|
|
29
|
+
slots: Readonly<FormSlots> & FormSlots;
|
|
30
|
+
emit: FormEmits<T>;
|
|
31
|
+
}>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}> & {
|
|
34
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
35
|
+
};
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_PrettifyLocal<T> = {
|
|
38
|
+
[K in keyof T]: T[K];
|
|
39
|
+
} & {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
import _appConfig from "#build/app.config";
|
|
4
|
+
import theme from "#build/ui/form-field";
|
|
5
|
+
const appConfig = _appConfig;
|
|
6
|
+
const formField = tv({ extend: tv(theme), ...appConfig.ui?.formField || {} });
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed, ref, inject, provide, type Ref, useId } from 'vue'
|
|
11
|
+
import { Label } from 'radix-vue'
|
|
12
|
+
import { formFieldInjectionKey } from '../composables/useFormField'
|
|
13
|
+
import type { FormError } from '../types/form'
|
|
14
|
+
|
|
15
|
+
const props = defineProps<FormFieldProps>()
|
|
16
|
+
const slots = defineSlots<FormFieldSlots>()
|
|
17
|
+
|
|
18
|
+
const ui = computed(() => formField({
|
|
19
|
+
size: props.size,
|
|
20
|
+
required: props.required
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
const formErrors = inject<Ref<FormError[]> | null>('form-errors', null)
|
|
24
|
+
|
|
25
|
+
const error = computed(() => {
|
|
26
|
+
return (props.error && typeof props.error === 'string')
|
|
27
|
+
|| typeof props.error === 'boolean'
|
|
28
|
+
? props.error
|
|
29
|
+
: formErrors?.value?.find(error => error.name === props.name)?.message
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const id = ref(useId())
|
|
33
|
+
|
|
34
|
+
provide(formFieldInjectionKey, computed(() => ({
|
|
35
|
+
id: id.value,
|
|
36
|
+
error: error.value,
|
|
37
|
+
name: props.name,
|
|
38
|
+
size: props.size,
|
|
39
|
+
eagerValidation: props.eagerValidation,
|
|
40
|
+
validateOnInputDelay: props.validateOnInputDelay
|
|
41
|
+
})))
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
46
|
+
<div :class="ui.wrapper({ class: props.ui?.wrapper })">
|
|
47
|
+
<div v-if="label || !!slots.label" :class="ui.labelWrapper({ class: props.ui?.labelWrapper })">
|
|
48
|
+
<Label :for="id" :class="ui.label({ class: props.ui?.label })">
|
|
49
|
+
<slot name="label" :label="label">
|
|
50
|
+
{{ label }}
|
|
51
|
+
</slot>
|
|
52
|
+
</Label>
|
|
53
|
+
<span v-if="hint || !!slots.hint" :class="ui.hint({ class: props.ui?.hint })">
|
|
54
|
+
<slot name="hint" :hint="hint">
|
|
55
|
+
{{ hint }}
|
|
56
|
+
</slot>
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<p v-if="description || !!slots.description" :class="ui.description({ class: props.ui?.description })">
|
|
61
|
+
<slot name="description" :description="description">
|
|
62
|
+
{{ description }}
|
|
63
|
+
</slot>
|
|
64
|
+
</p>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div :class="[label && ui.container({ class: props.ui?.container })]">
|
|
68
|
+
<slot :error="error" />
|
|
69
|
+
|
|
70
|
+
<p v-if="(typeof error === 'string' && error) || !!slots.error" :class="ui.error({ class: props.ui?.error })">
|
|
71
|
+
<slot name="error" :error="error">
|
|
72
|
+
{{ error }}
|
|
73
|
+
</slot>
|
|
74
|
+
</p>
|
|
75
|
+
<p v-else-if="help || !!slots.help" :class="ui.help({ class: props.ui?.help })">
|
|
76
|
+
<slot name="help" :help="help">
|
|
77
|
+
{{ help }}
|
|
78
|
+
</slot>
|
|
79
|
+
</p>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|