@nuxt/ui 2.18.4 → 3.0.0-alpha.1
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 +19 -2
- package/cli/commands/init.mjs +83 -0
- package/cli/index.mjs +15 -0
- package/cli/node_modules/.ignored/citty/LICENSE +36 -0
- package/cli/node_modules/.ignored/citty/README.md +134 -0
- package/cli/node_modules/.ignored/citty/dist/index.cjs +475 -0
- package/cli/node_modules/.ignored/citty/dist/index.d.cts +80 -0
- package/cli/node_modules/.ignored/citty/dist/index.d.mts +80 -0
- package/cli/node_modules/.ignored/citty/dist/index.d.ts +80 -0
- package/cli/node_modules/.ignored/citty/dist/index.mjs +463 -0
- package/cli/node_modules/.ignored/citty/package.json +49 -0
- package/cli/node_modules/.ignored/consola/LICENSE +47 -0
- package/cli/node_modules/.ignored/consola/README.md +318 -0
- package/cli/node_modules/.ignored/consola/core.d.ts +1 -0
- package/cli/node_modules/.ignored/consola/dist/basic.cjs +32 -0
- package/cli/node_modules/.ignored/consola/dist/basic.d.ts +9 -0
- package/cli/node_modules/.ignored/consola/dist/basic.mjs +24 -0
- package/cli/node_modules/.ignored/consola/dist/browser.cjs +80 -0
- package/cli/node_modules/.ignored/consola/dist/browser.d.ts +7 -0
- package/cli/node_modules/.ignored/consola/dist/browser.mjs +72 -0
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.cjs +436 -0
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.mjs +429 -0
- package/cli/node_modules/.ignored/consola/dist/core.cjs +415 -0
- package/cli/node_modules/.ignored/consola/dist/core.d.ts +124 -0
- package/cli/node_modules/.ignored/consola/dist/core.mjs +410 -0
- package/cli/node_modules/.ignored/consola/dist/index.cjs +21 -0
- package/cli/node_modules/.ignored/consola/dist/index.d.ts +9 -0
- package/cli/node_modules/.ignored/consola/dist/index.mjs +8 -0
- package/cli/node_modules/.ignored/consola/dist/shared/consola.06ad8a64.mjs +62 -0
- package/cli/node_modules/.ignored/consola/dist/shared/consola.36c0034f.mjs +636 -0
- package/cli/node_modules/.ignored/consola/dist/shared/consola.4bbae468.cjs +645 -0
- package/cli/node_modules/.ignored/consola/dist/shared/consola.deac7d5a.cjs +65 -0
- package/cli/node_modules/.ignored/consola/dist/utils.cjs +308 -0
- package/cli/node_modules/.ignored/consola/dist/utils.d.ts +169 -0
- package/cli/node_modules/.ignored/consola/dist/utils.mjs +284 -0
- package/cli/node_modules/.ignored/consola/lib/index.cjs +9 -0
- package/cli/node_modules/.ignored/consola/package.json +101 -0
- package/cli/node_modules/.ignored/consola/utils.d.ts +1 -0
- package/cli/node_modules/.ignored/pathe/LICENSE +44 -0
- package/cli/node_modules/.ignored/pathe/README.md +69 -0
- package/cli/node_modules/.ignored/pathe/dist/index.cjs +23 -0
- package/cli/node_modules/.ignored/pathe/dist/index.d.cts +36 -0
- package/cli/node_modules/.ignored/pathe/dist/index.d.mts +36 -0
- package/cli/node_modules/.ignored/pathe/dist/index.d.ts +36 -0
- package/cli/node_modules/.ignored/pathe/dist/index.mjs +1 -0
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.1f0a373c.cjs +238 -0
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.ff20891b.mjs +221 -0
- package/cli/node_modules/.ignored/pathe/dist/utils.cjs +58 -0
- package/cli/node_modules/.ignored/pathe/dist/utils.d.cts +5 -0
- package/cli/node_modules/.ignored/pathe/dist/utils.d.mts +5 -0
- package/cli/node_modules/.ignored/pathe/dist/utils.d.ts +5 -0
- package/cli/node_modules/.ignored/pathe/dist/utils.mjs +54 -0
- package/cli/node_modules/.ignored/pathe/package.json +48 -0
- package/cli/node_modules/.ignored/pathe/utils.d.ts +1 -0
- package/cli/node_modules/.ignored/scule/LICENSE +21 -0
- package/cli/node_modules/.ignored/scule/README.md +149 -0
- package/cli/node_modules/.ignored/scule/dist/index.cjs +92 -0
- package/cli/node_modules/.ignored/scule/dist/index.d.cts +57 -0
- package/cli/node_modules/.ignored/scule/dist/index.d.mts +57 -0
- package/cli/node_modules/.ignored/scule/dist/index.d.ts +57 -0
- package/cli/node_modules/.ignored/scule/dist/index.mjs +80 -0
- package/cli/node_modules/.ignored/scule/package.json +43 -0
- package/cli/node_modules/.package-lock.json +33 -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 +4 -4
- package/dist/module.mjs +2574 -154
- package/dist/runtime/components/Accordion.vue +110 -0
- package/dist/runtime/components/Alert.vue +130 -0
- package/dist/runtime/components/App.vue +42 -0
- package/dist/runtime/components/Avatar.vue +69 -0
- package/dist/runtime/components/AvatarGroup.vue +98 -0
- package/dist/runtime/components/Badge.vue +46 -0
- package/dist/runtime/components/Breadcrumb.vue +98 -0
- package/dist/runtime/components/Button.vue +82 -0
- package/dist/runtime/components/ButtonGroup.vue +53 -0
- package/dist/runtime/components/Card.vue +52 -0
- package/dist/runtime/components/Checkbox.vue +128 -0
- package/dist/runtime/components/Chip.vue +76 -0
- package/dist/runtime/components/Collapsible.vue +54 -0
- package/dist/runtime/components/CommandPalette.vue +303 -0
- package/dist/runtime/components/Container.vue +36 -0
- package/dist/runtime/components/ContextMenu.vue +103 -0
- package/dist/runtime/components/ContextMenuContent.vue +122 -0
- package/dist/runtime/components/Drawer.vue +115 -0
- package/dist/runtime/components/DropdownMenu.vue +115 -0
- package/dist/runtime/components/DropdownMenuContent.vue +129 -0
- package/dist/runtime/components/Form.vue +227 -0
- package/dist/runtime/components/FormField.vue +107 -0
- package/dist/runtime/components/Icon.vue +26 -0
- package/dist/runtime/components/Input.vue +180 -0
- package/dist/runtime/components/InputMenu.vue +371 -0
- package/dist/runtime/components/Kbd.vue +49 -0
- package/dist/runtime/components/Link.vue +147 -0
- package/dist/runtime/components/LinkBase.vue +60 -0
- package/dist/runtime/components/Modal.vue +163 -0
- package/dist/runtime/components/ModalProvider.vue +12 -0
- package/dist/runtime/components/NavigationMenu.vue +195 -0
- package/dist/runtime/components/Pagination.vue +173 -0
- package/dist/runtime/components/Popover.vue +88 -0
- package/dist/runtime/components/Progress.vue +164 -0
- package/dist/runtime/components/RadioGroup.vue +159 -0
- package/dist/runtime/components/Select.vue +230 -0
- package/dist/runtime/components/SelectMenu.vue +306 -0
- package/dist/runtime/components/Separator.vue +82 -0
- package/dist/runtime/components/Skeleton.vue +31 -0
- package/dist/runtime/components/Slideover.vue +162 -0
- package/dist/runtime/components/SlideoverProvider.vue +12 -0
- package/dist/runtime/components/Slider.vue +113 -0
- package/dist/runtime/components/Switch.vue +124 -0
- package/dist/runtime/components/Tabs.vue +114 -0
- package/dist/runtime/components/Textarea.vue +189 -0
- package/dist/runtime/components/Toast.vue +161 -0
- package/dist/runtime/components/Toaster.vue +130 -0
- package/dist/runtime/components/Tooltip.vue +88 -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 +34 -0
- package/dist/runtime/composables/useFormField.js +54 -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/index.css +1 -0
- package/dist/runtime/plugins/colors.js +9 -17
- 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 +62 -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 +26 -71
- package/dist/runtime/utils/link.js +4 -124
- package/package.json +50 -49
- 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/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.d.ts → modal.d.ts} +0 -0
- package/dist/runtime/plugins/{modals.js → modal.js} +1 -1
- /package/dist/runtime/plugins/{slideovers.d.ts → slideover.d.ts} +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tv } from 'tailwind-variants'
|
|
3
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
4
|
+
import _appConfig from '#build/app.config'
|
|
5
|
+
import theme from '#build/ui/form'
|
|
6
|
+
import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, FormEvent, Form, FormErrorWithId } from '../types/form'
|
|
7
|
+
|
|
8
|
+
const appConfig = _appConfig as AppConfig & { ui: { form: Partial<typeof theme> } }
|
|
9
|
+
|
|
10
|
+
const form = tv({ extend: tv(theme), ...(appConfig.ui?.form || {}) })
|
|
11
|
+
|
|
12
|
+
export interface FormProps<T extends object> {
|
|
13
|
+
id?: string | number
|
|
14
|
+
schema?: FormSchema<T>
|
|
15
|
+
state: Partial<T>
|
|
16
|
+
validate?: (state: Partial<T>) => Promise<FormError[]>
|
|
17
|
+
validateOn?: FormInputEvents[]
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
validateOnInputDelay?: number
|
|
20
|
+
class?: any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface FormEmits<T extends object> {
|
|
24
|
+
(e: 'submit', payload: FormSubmitEvent<T>): void
|
|
25
|
+
(e: 'error', payload: FormErrorEvent): void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FormSlots {
|
|
29
|
+
default(props?: {}): any
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script lang="ts" setup generic="T extends object">
|
|
34
|
+
import { provide, inject, nextTick, ref, onUnmounted, onMounted, computed, useId } from 'vue'
|
|
35
|
+
import { useEventBus } from '@vueuse/core'
|
|
36
|
+
import { formOptionsInjectionKey, formInputsInjectionKey, formBusInjectionKey } from '../composables/useFormField'
|
|
37
|
+
import { getYupErrors, isYupSchema, getValibotError, isValibotSchema, getZodErrors, isZodSchema, getJoiErrors, isJoiSchema } from '../utils/form'
|
|
38
|
+
import { FormValidationException } from '../types/form'
|
|
39
|
+
|
|
40
|
+
const props = withDefaults(defineProps<FormProps<T>>(), {
|
|
41
|
+
validateOn() {
|
|
42
|
+
return ['input', 'blur', 'change'] as FormInputEvents[]
|
|
43
|
+
},
|
|
44
|
+
validateOnInputDelay: 300
|
|
45
|
+
})
|
|
46
|
+
const emits = defineEmits<FormEmits<T>>()
|
|
47
|
+
defineSlots<FormSlots>()
|
|
48
|
+
|
|
49
|
+
const formId = props.id ?? useId() as string
|
|
50
|
+
|
|
51
|
+
const bus = useEventBus<FormEvent>(`form-${formId}`)
|
|
52
|
+
const parentBus = inject(
|
|
53
|
+
formBusInjectionKey,
|
|
54
|
+
undefined
|
|
55
|
+
)
|
|
56
|
+
provide(formBusInjectionKey, bus)
|
|
57
|
+
|
|
58
|
+
const nestedForms = ref<Map<string | number, { validate: () => any }>>(new Map())
|
|
59
|
+
|
|
60
|
+
onMounted(async () => {
|
|
61
|
+
bus.on(async (event) => {
|
|
62
|
+
if (event.type === 'attach') {
|
|
63
|
+
nestedForms.value.set(event.formId, { validate: event.validate })
|
|
64
|
+
} else if (event.type === 'detach') {
|
|
65
|
+
nestedForms.value.delete(event.formId)
|
|
66
|
+
} else if (props.validateOn?.includes(event.type as FormInputEvents)) {
|
|
67
|
+
await _validate({ name: event.name, silent: true, nested: false })
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
onUnmounted(() => {
|
|
73
|
+
bus.reset()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
onMounted(async () => {
|
|
77
|
+
if (parentBus) {
|
|
78
|
+
await nextTick()
|
|
79
|
+
parentBus.emit({ type: 'attach', validate: _validate, formId })
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
onUnmounted(() => {
|
|
84
|
+
if (parentBus) {
|
|
85
|
+
parentBus.emit({ type: 'detach', formId })
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
provide(formOptionsInjectionKey, computed(() => ({
|
|
90
|
+
disabled: props.disabled,
|
|
91
|
+
validateOnInputDelay: props.validateOnInputDelay
|
|
92
|
+
})))
|
|
93
|
+
|
|
94
|
+
const errors = ref<FormErrorWithId[]>([])
|
|
95
|
+
provide('form-errors', errors)
|
|
96
|
+
|
|
97
|
+
const inputs = ref<Record<string, string>>({})
|
|
98
|
+
provide(formInputsInjectionKey, inputs)
|
|
99
|
+
|
|
100
|
+
function resolveErrorIds(errs: FormError[]): FormErrorWithId[] {
|
|
101
|
+
return errs.map(err => ({
|
|
102
|
+
...err,
|
|
103
|
+
id: inputs.value[err.name]
|
|
104
|
+
}))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function getErrors(): Promise<FormErrorWithId[]> {
|
|
108
|
+
let errs = props.validate ? (await props.validate(props.state)) ?? [] : []
|
|
109
|
+
|
|
110
|
+
if (props.schema) {
|
|
111
|
+
if (isZodSchema(props.schema)) {
|
|
112
|
+
errs = errs.concat(await getZodErrors(props.state, props.schema))
|
|
113
|
+
} else if (isYupSchema(props.schema)) {
|
|
114
|
+
errs = errs.concat(await getYupErrors(props.state, props.schema))
|
|
115
|
+
} else if (isJoiSchema(props.schema)) {
|
|
116
|
+
errs = errs.concat(await getJoiErrors(props.state, props.schema))
|
|
117
|
+
} else if (isValibotSchema(props.schema)) {
|
|
118
|
+
errs = errs.concat(await getValibotError(props.state, props.schema))
|
|
119
|
+
} else {
|
|
120
|
+
throw new Error('Form validation failed: Unsupported form schema')
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return resolveErrorIds(errs)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function _validate(opts: { name?: string | string[], silent?: boolean, nested?: boolean } = { silent: false, nested: true }): Promise<T | false> {
|
|
128
|
+
const names = opts.name && !Array.isArray(opts.name) ? [opts.name] : opts.name
|
|
129
|
+
|
|
130
|
+
const nestedValidatePromises = !names && opts.nested
|
|
131
|
+
? Array.from(nestedForms.value.values()).map(
|
|
132
|
+
({ validate }) => validate().then(() => undefined).catch((error: Error) => {
|
|
133
|
+
if (!(error instanceof FormValidationException)) {
|
|
134
|
+
throw error
|
|
135
|
+
}
|
|
136
|
+
return error
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
: []
|
|
140
|
+
|
|
141
|
+
if (names) {
|
|
142
|
+
const otherErrors = errors.value.filter(error => !names!.includes(error.name))
|
|
143
|
+
const pathErrors = (await getErrors()).filter(error => names!.includes(error.name)
|
|
144
|
+
)
|
|
145
|
+
errors.value = otherErrors.concat(pathErrors)
|
|
146
|
+
} else {
|
|
147
|
+
errors.value = await getErrors()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const childErrors = nestedValidatePromises ? await Promise.all(nestedValidatePromises) : []
|
|
151
|
+
if (errors.value.length + childErrors.length > 0) {
|
|
152
|
+
if (opts.silent) return false
|
|
153
|
+
throw new FormValidationException(formId, errors.value, childErrors)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return props.state as T
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function onSubmit(payload: Event) {
|
|
160
|
+
const event = payload as FormSubmitEvent<any>
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
await _validate({ nested: true })
|
|
164
|
+
event.data = props.state
|
|
165
|
+
emits('submit', event)
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (!(error instanceof FormValidationException)) {
|
|
168
|
+
throw error
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const errorEvent: FormErrorEvent = {
|
|
172
|
+
...event,
|
|
173
|
+
errors: error.errors,
|
|
174
|
+
childrens: error.childrens
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
emits('error', errorEvent)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
defineExpose<Form<T>>({
|
|
182
|
+
validate: _validate,
|
|
183
|
+
errors,
|
|
184
|
+
|
|
185
|
+
setErrors(errs: FormError[], name?: string) {
|
|
186
|
+
if (name) {
|
|
187
|
+
errors.value = errors.value
|
|
188
|
+
.filter(error => error.name !== name)
|
|
189
|
+
.concat(resolveErrorIds(errs))
|
|
190
|
+
} else {
|
|
191
|
+
errors.value = resolveErrorIds(errs)
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
async submit() {
|
|
196
|
+
await onSubmit(new Event('submit'))
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
getErrors(name?: string) {
|
|
200
|
+
if (name) {
|
|
201
|
+
return errors.value.filter(err => err.name === name)
|
|
202
|
+
}
|
|
203
|
+
return errors.value
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
clear(name?: string) {
|
|
207
|
+
if (name) {
|
|
208
|
+
errors.value = errors.value.filter(err => err.name !== name)
|
|
209
|
+
} else {
|
|
210
|
+
errors.value = []
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
disabled: computed(() => props.disabled)
|
|
215
|
+
})
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<template>
|
|
219
|
+
<component
|
|
220
|
+
:is="parentBus ? 'div' : 'form'"
|
|
221
|
+
:id="formId"
|
|
222
|
+
:class="form({ class: props.class })"
|
|
223
|
+
@submit.prevent="onSubmit"
|
|
224
|
+
>
|
|
225
|
+
<slot />
|
|
226
|
+
</component>
|
|
227
|
+
</template>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { tv, type VariantProps } from 'tailwind-variants'
|
|
3
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
4
|
+
import _appConfig from '#build/app.config'
|
|
5
|
+
import theme from '#build/ui/form-field'
|
|
6
|
+
|
|
7
|
+
const appConfig = _appConfig as AppConfig & { ui: { formField: Partial<typeof theme> } }
|
|
8
|
+
|
|
9
|
+
const formField = tv({ extend: tv(theme), ...(appConfig.ui?.formField || {}) })
|
|
10
|
+
|
|
11
|
+
type FormFieldVariants = VariantProps<typeof formField>
|
|
12
|
+
|
|
13
|
+
export interface FormFieldProps {
|
|
14
|
+
name?: string
|
|
15
|
+
label?: string
|
|
16
|
+
description?: string
|
|
17
|
+
help?: string
|
|
18
|
+
error?: string | boolean
|
|
19
|
+
hint?: string
|
|
20
|
+
size?: FormFieldVariants['size']
|
|
21
|
+
required?: boolean
|
|
22
|
+
eagerValidation?: boolean
|
|
23
|
+
validateOnInputDelay?: number
|
|
24
|
+
class?: any
|
|
25
|
+
ui?: Partial<typeof formField.slots>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FormFieldSlots {
|
|
29
|
+
label(props: { label?: string }): any
|
|
30
|
+
hint(props: { hint?: string }): any
|
|
31
|
+
description(props: { description?: string }): any
|
|
32
|
+
help(props: { help?: string }): any
|
|
33
|
+
error(props: { error?: string | boolean }): any
|
|
34
|
+
default(props: { error?: string | boolean }): any
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import { computed, ref, inject, provide, type Ref, useId } from 'vue'
|
|
40
|
+
import { Label } from 'radix-vue'
|
|
41
|
+
import { formFieldInjectionKey, inputIdInjectionKey } from '../composables/useFormField'
|
|
42
|
+
import type { FormError, FormFieldInjectedOptions } from '../types/form'
|
|
43
|
+
|
|
44
|
+
const props = defineProps<FormFieldProps>()
|
|
45
|
+
const slots = defineSlots<FormFieldSlots>()
|
|
46
|
+
|
|
47
|
+
const ui = computed(() => formField({
|
|
48
|
+
size: props.size,
|
|
49
|
+
required: props.required
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
const formErrors = inject<Ref<FormError[]> | null>('form-errors', null)
|
|
53
|
+
|
|
54
|
+
const error = computed(() => props.error || formErrors?.value?.find(error => error.name === props.name)?.message)
|
|
55
|
+
|
|
56
|
+
const id = ref(useId())
|
|
57
|
+
|
|
58
|
+
provide(inputIdInjectionKey, id)
|
|
59
|
+
|
|
60
|
+
provide(formFieldInjectionKey, computed(() => ({
|
|
61
|
+
error: error.value,
|
|
62
|
+
name: props.name,
|
|
63
|
+
size: props.size,
|
|
64
|
+
eagerValidation: props.eagerValidation,
|
|
65
|
+
validateOnInputDelay: props.validateOnInputDelay
|
|
66
|
+
}) as FormFieldInjectedOptions<FormFieldProps>))
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<div :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
71
|
+
<div :class="ui.wrapper({ class: props.ui?.wrapper })">
|
|
72
|
+
<div v-if="label || !!slots.label" :class="ui.labelWrapper({ class: props.ui?.labelWrapper })">
|
|
73
|
+
<Label :for="id" :class="ui.label({ class: props.ui?.label })">
|
|
74
|
+
<slot name="label" :label="label">
|
|
75
|
+
{{ label }}
|
|
76
|
+
</slot>
|
|
77
|
+
</Label>
|
|
78
|
+
<span v-if="hint || !!slots.hint" :class="ui.hint({ class: props.ui?.hint })">
|
|
79
|
+
<slot name="hint" :hint="hint">
|
|
80
|
+
{{ hint }}
|
|
81
|
+
</slot>
|
|
82
|
+
</span>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<p v-if="description || !!slots.description" :class="ui.description({ class: props.ui?.description })">
|
|
86
|
+
<slot name="description" :description="description">
|
|
87
|
+
{{ description }}
|
|
88
|
+
</slot>
|
|
89
|
+
</p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div :class="[label && ui.container({ class: props.ui?.container })]">
|
|
93
|
+
<slot :error="error" />
|
|
94
|
+
|
|
95
|
+
<p v-if="(typeof error === 'string' && error) || !!slots.error" :class="ui.error({ class: props.ui?.error })">
|
|
96
|
+
<slot name="error" :error="error">
|
|
97
|
+
{{ error }}
|
|
98
|
+
</slot>
|
|
99
|
+
</p>
|
|
100
|
+
<p v-else-if="help || !!slots.help" :class="ui.help({ class: props.ui?.help })">
|
|
101
|
+
<slot name="help" :help="help">
|
|
102
|
+
{{ help }}
|
|
103
|
+
</slot>
|
|
104
|
+
</p>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export interface IconProps {
|
|
3
|
+
name: string
|
|
4
|
+
mode?: 'svg' | 'css'
|
|
5
|
+
size?: string | number
|
|
6
|
+
customize?: (
|
|
7
|
+
content: string,
|
|
8
|
+
name?: string,
|
|
9
|
+
prefix?: string,
|
|
10
|
+
provider?: string
|
|
11
|
+
) => string
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { useForwardProps } from 'radix-vue'
|
|
17
|
+
import { reactivePick } from '@vueuse/core'
|
|
18
|
+
|
|
19
|
+
const props = defineProps<IconProps>()
|
|
20
|
+
|
|
21
|
+
const iconProps = useForwardProps(reactivePick(props, 'name', 'mode', 'size', 'customize'))
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<Icon v-bind="iconProps" />
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { InputHTMLAttributes } from 'vue'
|
|
3
|
+
import { tv, type VariantProps } from 'tailwind-variants'
|
|
4
|
+
import type { AppConfig } from '@nuxt/schema'
|
|
5
|
+
import _appConfig from '#build/app.config'
|
|
6
|
+
import theme from '#build/ui/input'
|
|
7
|
+
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
|
|
8
|
+
import type { PartialString } from '../types/utils'
|
|
9
|
+
|
|
10
|
+
const appConfig = _appConfig as AppConfig & { ui: { input: Partial<typeof theme> } }
|
|
11
|
+
|
|
12
|
+
const input = tv({ extend: tv(theme), ...(appConfig.ui?.input || {}) })
|
|
13
|
+
|
|
14
|
+
type InputVariants = VariantProps<typeof input>
|
|
15
|
+
|
|
16
|
+
export interface InputProps extends UseComponentIconsProps {
|
|
17
|
+
id?: string
|
|
18
|
+
name?: string
|
|
19
|
+
type?: InputHTMLAttributes['type']
|
|
20
|
+
/** The placeholder text when the input is empty. */
|
|
21
|
+
placeholder?: string
|
|
22
|
+
color?: InputVariants['color']
|
|
23
|
+
variant?: InputVariants['variant']
|
|
24
|
+
size?: InputVariants['size']
|
|
25
|
+
required?: boolean
|
|
26
|
+
autocomplete?: InputHTMLAttributes['autocomplete']
|
|
27
|
+
autofocus?: boolean
|
|
28
|
+
autofocusDelay?: number
|
|
29
|
+
disabled?: boolean
|
|
30
|
+
/** Highlight the ring color like a focus state. */
|
|
31
|
+
highlight?: boolean
|
|
32
|
+
class?: any
|
|
33
|
+
ui?: PartialString<typeof input.slots>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface InputEmits {
|
|
37
|
+
(e: 'update:modelValue', payload: string | number): void
|
|
38
|
+
(e: 'blur', event: FocusEvent): void
|
|
39
|
+
(e: 'change', event: Event): void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface InputSlots {
|
|
43
|
+
leading(props?: {}): any
|
|
44
|
+
default(props?: {}): any
|
|
45
|
+
trailing(props?: {}): any
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import { ref, computed, onMounted } from 'vue'
|
|
51
|
+
import { useButtonGroup } from '../composables/useButtonGroup'
|
|
52
|
+
import { useComponentIcons } from '../composables/useComponentIcons'
|
|
53
|
+
import { useFormField } from '../composables/useFormField'
|
|
54
|
+
import UIcon from './Icon.vue'
|
|
55
|
+
import { looseToNumber } from '../utils'
|
|
56
|
+
|
|
57
|
+
defineOptions({ inheritAttrs: false })
|
|
58
|
+
|
|
59
|
+
const props = withDefaults(defineProps<InputProps>(), {
|
|
60
|
+
type: 'text',
|
|
61
|
+
autocomplete: 'off',
|
|
62
|
+
autofocusDelay: 0
|
|
63
|
+
})
|
|
64
|
+
const emits = defineEmits<InputEmits>()
|
|
65
|
+
const slots = defineSlots<InputSlots>()
|
|
66
|
+
|
|
67
|
+
const [modelValue, modelModifiers] = defineModel<string | number>()
|
|
68
|
+
|
|
69
|
+
const { emitFormBlur, emitFormInput, emitFormChange, size: formGroupSize, color, id, name, highlight, disabled } = useFormField<InputProps>(props)
|
|
70
|
+
const { orientation, size: buttonGroupSize } = useButtonGroup<InputProps>(props)
|
|
71
|
+
const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponentIcons(props)
|
|
72
|
+
|
|
73
|
+
const inputSize = computed(() => buttonGroupSize.value || formGroupSize.value)
|
|
74
|
+
|
|
75
|
+
const ui = computed(() => input({
|
|
76
|
+
type: props.type as InputVariants['type'],
|
|
77
|
+
color: color.value,
|
|
78
|
+
variant: props.variant,
|
|
79
|
+
size: inputSize?.value,
|
|
80
|
+
loading: props.loading,
|
|
81
|
+
highlight: highlight.value,
|
|
82
|
+
leading: isLeading.value || !!slots.leading,
|
|
83
|
+
trailing: isTrailing.value || !!slots.trailing,
|
|
84
|
+
buttonGroup: orientation.value
|
|
85
|
+
}))
|
|
86
|
+
|
|
87
|
+
const inputRef = ref<HTMLInputElement | null>(null)
|
|
88
|
+
|
|
89
|
+
function autoFocus() {
|
|
90
|
+
if (props.autofocus) {
|
|
91
|
+
inputRef.value?.focus()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Custom function to handle the v-model properties
|
|
96
|
+
function updateInput(value: string) {
|
|
97
|
+
if (modelModifiers.trim) {
|
|
98
|
+
value = value.trim()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (modelModifiers.number || props.type === 'number') {
|
|
102
|
+
value = looseToNumber(value)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
modelValue.value = value
|
|
106
|
+
emitFormInput()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function onInput(event: Event) {
|
|
110
|
+
if (!modelModifiers.lazy) {
|
|
111
|
+
updateInput((event.target as HTMLInputElement).value)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function onChange(event: Event) {
|
|
116
|
+
const value = (event.target as HTMLInputElement).value
|
|
117
|
+
|
|
118
|
+
if (modelModifiers.lazy) {
|
|
119
|
+
updateInput(value)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Update trimmed input so that it has same behavior as native input https://github.com/vuejs/core/blob/5ea8a8a4fab4e19a71e123e4d27d051f5e927172/packages/runtime-dom/src/directives/vModel.ts#L63
|
|
123
|
+
if (modelModifiers.trim) {
|
|
124
|
+
(event.target as HTMLInputElement).value = value.trim()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
emitFormChange()
|
|
128
|
+
emits('change', event)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function onBlur(event: FocusEvent) {
|
|
132
|
+
emitFormBlur()
|
|
133
|
+
emits('blur', event)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
defineExpose({
|
|
137
|
+
inputRef
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
onMounted(() => {
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
autoFocus()
|
|
143
|
+
}, props.autofocusDelay)
|
|
144
|
+
})
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<template>
|
|
148
|
+
<div :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
149
|
+
<input
|
|
150
|
+
:id="id"
|
|
151
|
+
ref="inputRef"
|
|
152
|
+
:type="type"
|
|
153
|
+
:value="modelValue"
|
|
154
|
+
:name="name"
|
|
155
|
+
:placeholder="placeholder"
|
|
156
|
+
:class="ui.base({ class: props.ui?.base })"
|
|
157
|
+
:disabled="disabled"
|
|
158
|
+
:required="required"
|
|
159
|
+
:autocomplete="autocomplete"
|
|
160
|
+
v-bind="$attrs"
|
|
161
|
+
@input="onInput"
|
|
162
|
+
@blur="onBlur"
|
|
163
|
+
@change="onChange"
|
|
164
|
+
>
|
|
165
|
+
|
|
166
|
+
<slot />
|
|
167
|
+
|
|
168
|
+
<span v-if="isLeading || !!slots.leading" :class="ui.leading({ class: props.ui?.leading })">
|
|
169
|
+
<slot name="leading">
|
|
170
|
+
<UIcon v-if="leadingIconName" :name="leadingIconName" :class="ui.leadingIcon({ class: props.ui?.leadingIcon })" />
|
|
171
|
+
</slot>
|
|
172
|
+
</span>
|
|
173
|
+
|
|
174
|
+
<span v-if="isTrailing || !!slots.trailing" :class="ui.trailing({ class: props.ui?.trailing })">
|
|
175
|
+
<slot name="trailing">
|
|
176
|
+
<UIcon v-if="trailingIconName" :name="trailingIconName" :class="ui.trailingIcon({ class: props.ui?.trailingIcon })" />
|
|
177
|
+
</slot>
|
|
178
|
+
</span>
|
|
179
|
+
</div>
|
|
180
|
+
</template>
|