@volverjs/ui-vue 0.0.10-beta.4 → 0.0.10-beta.41
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/LICENSE +1 -1
- package/README.md +146 -49
- package/auto-imports.d.ts +7 -2
- package/bin/icons.cjs +1 -1
- package/bin/icons.js +27 -20
- package/dist/Volver.d.ts +11 -11
- package/dist/components/VvAccordion/VvAccordion.es.js +190 -101
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +30 -8
- package/dist/components/VvAccordion/index.d.ts +8 -9
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +450 -170
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +58 -13
- package/dist/components/VvAccordionGroup/index.d.ts +14 -6
- package/dist/components/VvAction/VvAction.es.js +84 -33
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +57 -22
- package/dist/components/VvAction/index.d.ts +25 -9
- package/dist/components/VvAlert/VvAlert.es.js +228 -193
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +24 -14
- package/dist/components/VvAlert/index.d.ts +17 -9
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +549 -485
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +16 -9
- package/dist/components/VvAlertGroup/index.d.ts +7 -15
- package/dist/components/VvAvatar/VvAvatar.es.js +65 -22
- package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
- package/dist/components/VvAvatar/VvAvatar.vue.d.ts +12 -4
- package/dist/components/VvAvatar/index.d.ts +4 -1
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +128 -49
- package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
- package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +10 -3
- package/dist/components/VvAvatarGroup/index.d.ts +4 -1
- package/dist/components/VvBadge/VvBadge.es.js +77 -28
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.vue.d.ts +12 -4
- package/dist/components/VvBadge/index.d.ts +4 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +276 -60
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +27 -7
- package/dist/components/VvBreadcrumb/index.d.ts +6 -10
- package/dist/components/VvButton/VvButton.es.js +307 -262
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +94 -40
- package/dist/components/VvButton/index.d.ts +51 -29
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +95 -40
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +31 -11
- package/dist/components/VvButtonGroup/index.d.ts +11 -2
- package/dist/components/VvCard/VvCard.es.js +86 -36
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCard/VvCard.vue.d.ts +12 -4
- package/dist/components/VvCard/index.d.ts +4 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +315 -251
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +106 -34
- package/dist/components/VvCheckbox/index.d.ts +47 -14
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +238 -129
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +101 -30
- package/dist/components/VvCheckboxGroup/index.d.ts +45 -12
- package/dist/components/VvCombobox/VvCombobox.es.js +1377 -1059
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +606 -680
- package/dist/components/VvCombobox/index.d.ts +488 -26
- package/dist/components/VvDialog/VvDialog.es.js +180 -176
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDialog/VvDialog.vue.d.ts +13 -4
- package/dist/components/VvDialog/index.d.ts +5 -0
- package/dist/components/VvDropdown/VvDropdown.es.js +165 -94
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +111 -81
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +66 -25
- package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +13 -1
- package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +12 -4
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +35 -7
- package/dist/components/VvDropdown/index.d.ts +52 -10
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +163 -53
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +335 -8
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +63 -20
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +188 -80
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +24 -97
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +23 -66
- package/dist/components/VvIcon/index.d.ts +33 -48
- package/dist/components/VvInputFile/VvInputFile.es.js +1789 -0
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -0
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +391 -0
- package/dist/components/VvInputFile/index.d.ts +210 -0
- package/dist/components/VvInputText/VvInputClearAction.d.ts +7 -5
- package/dist/components/VvInputText/VvInputPasswordAction.d.ts +10 -8
- package/dist/components/VvInputText/VvInputStepAction.d.ts +2 -2
- package/dist/components/VvInputText/VvInputText.es.js +1489 -563
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +207 -57
- package/dist/components/VvInputText/index.d.ts +105 -30
- package/dist/components/VvNav/VvNav.es.js +160 -75
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/VvNav.vue.d.ts +32 -9
- package/dist/components/VvNav/VvNavItem.vue.d.ts +1 -1
- package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
- package/dist/components/VvNav/index.d.ts +5 -2
- package/dist/components/VvNavItem/VvNavItem.es.js +100 -39
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +73 -27
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.vue.d.ts +10 -3
- package/dist/components/VvProgress/index.d.ts +4 -1
- package/dist/components/VvRadio/VvRadio.es.js +313 -250
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +103 -31
- package/dist/components/VvRadio/index.d.ts +50 -17
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +236 -128
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +101 -30
- package/dist/components/VvRadioGroup/index.d.ts +45 -12
- package/dist/components/VvSelect/VvSelect.es.js +367 -300
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +232 -203
- package/dist/components/VvSelect/index.d.ts +195 -15
- package/dist/components/VvTab/VvTab.es.js +222 -97
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTab/VvTab.vue.d.ts +31 -7
- package/dist/components/VvTab/index.d.ts +4 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +258 -248
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +156 -49
- package/dist/components/VvTextarea/index.d.ts +68 -19
- package/dist/components/VvTooltip/VvTooltip.es.js +83 -30
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +13 -6
- package/dist/components/VvTooltip/index.d.ts +5 -2
- package/dist/components/common/HintSlot.d.ts +4 -5
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.es.js +4575 -2534
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +101 -6
- package/dist/composables/alert/useInjectAlert.d.ts +1 -6
- package/dist/composables/dropdown/useInjectDropdown.d.ts +3 -23
- package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -4
- package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
- package/dist/composables/group/useProvideGroupState.d.ts +3 -3
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.es.js +94 -5
- package/dist/composables/index.umd.js +1 -1
- package/dist/composables/useBlurhash.d.ts +7 -0
- package/dist/composables/useComponentFocus.d.ts +1 -1
- package/dist/composables/useComponentIcon.d.ts +9 -8
- package/dist/composables/useOptions.d.ts +4 -4
- package/dist/composables/usePersistence.d.ts +3 -0
- package/dist/composables/useUniqueId.d.ts +1 -1
- package/dist/composables/useVolver.d.ts +1 -1
- package/dist/constants.d.ts +34 -32
- package/dist/directives/index.d.ts +3 -5
- package/dist/directives/index.es.js +104 -45
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-contextmenu.es.js +1 -1
- package/dist/directives/v-contextmenu.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +101 -39
- package/dist/directives/v-tooltip.umd.js +1 -1
- package/dist/icons.es.js +267 -267
- package/dist/icons.umd.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +92 -18
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +272 -81
- package/dist/resolvers/unplugin.d.ts +6 -1
- package/dist/resolvers/unplugin.es.js +87 -10
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/Accordion/Accordion.settings.d.ts +2 -57
- package/dist/stories/AccordionGroup/AccordionGroup.settings.d.ts +2 -66
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -127
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +1437 -495
- package/dist/stories/Alert/Alert.settings.d.ts +2 -109
- package/dist/stories/Alert/AlertModifiers.stories.d.ts +1 -1
- package/dist/stories/Alert/AlertSlots.stories.d.ts +1 -1
- package/dist/stories/AlertGroup/AlertGroup.settings.d.ts +2 -85
- package/dist/stories/AlertGroup/AlertGroupPosition.stories.d.ts +1 -1
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +1 -1
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +2 -2
- package/dist/stories/AvatarGroup/AvatarGroup.settings.d.ts +2 -38
- package/dist/stories/Badge/Badge.settings.d.ts +2 -26
- package/dist/stories/Badge/Badge.test.d.ts +1 -1
- package/dist/stories/Blurhash/BlurhashComposable.stories.d.ts +4 -0
- package/dist/stories/Breadcrumb/Breadcrumb.settings.d.ts +2 -18
- package/dist/stories/Breadcrumb/Breadcrumb.test.d.ts +1 -1
- package/dist/stories/Button/Button.settings.d.ts +2 -194
- package/dist/stories/ButtonGroup/ButtonGroup.settings.d.ts +2 -40
- package/dist/stories/Card/Card.settings.d.ts +2 -63
- package/dist/stories/Checkbox/Checkbox.settings.d.ts +2 -132
- package/dist/stories/CheckboxGroup/CheckboxGroup.settings.d.ts +1 -141
- package/dist/stories/Combobox/Combobox.settings.d.ts +2 -609
- package/dist/stories/Combobox/Combobox.stories.d.ts +1 -0
- package/dist/stories/Combobox/ComboboxMultiple.stories.d.ts +1 -0
- package/dist/stories/Dialog/Dialog.settings.d.ts +2 -47
- package/dist/stories/Dialog/DialogModifiers.stories.d.ts +8 -0
- package/dist/stories/Dropdown/Dropdown.settings.d.ts +2 -205
- package/dist/stories/Icon/Icon.settings.d.ts +3 -68
- package/dist/stories/InputFile/InputFile.settings.d.ts +6 -0
- package/dist/stories/InputFile/InputFile.stories.d.ts +12 -0
- package/dist/stories/InputFile/InputFileDropArea.stories.d.ts +9 -0
- package/dist/stories/InputFile/InputFileIconPosition.stories.d.ts +8 -0
- package/dist/stories/InputFile/InputFileSlots.stories.d.ts +7 -0
- package/dist/stories/InputText/InputText.settings.d.ts +2 -438
- package/dist/stories/Nav/Nav.settings.d.ts +2 -10
- package/dist/stories/Progress/Progress.settings.d.ts +2 -27
- package/dist/stories/Radio/Radio.settings.d.ts +1 -110
- package/dist/stories/RadioGroup/RadioGroup.settings.d.ts +1 -141
- package/dist/stories/Select/Select.settings.d.ts +2 -246
- package/dist/stories/Select/Select.stories.d.ts +1 -0
- package/dist/stories/Tab/Tab.settings.d.ts +2 -15
- package/dist/stories/Textarea/Textarea.settings.d.ts +2 -287
- package/dist/stories/argTypes.d.ts +27 -866
- package/dist/test/expect.d.ts +1 -1
- package/dist/test/options.d.ts +1 -1
- package/dist/test/sleep.d.ts +1 -1
- package/dist/types/alert.d.ts +9 -7
- package/dist/types/blurhash.d.ts +12 -0
- package/dist/types/generic.d.ts +1 -2
- package/dist/types/group.d.ts +37 -15
- package/dist/types/index.d.ts +7 -0
- package/dist/types/input-file.d.ts +16 -0
- package/dist/types/nav.d.ts +2 -2
- package/dist/utils/ObjectUtilities.d.ts +7 -8
- package/dist/workers/blurhash.d.ts +1 -0
- package/package.json +239 -246
- package/src/Volver.ts +245 -234
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordion/VvAccordion.vue +163 -100
- package/src/components/VvAccordion/index.ts +64 -79
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +223 -105
- package/src/components/VvAccordionGroup/index.ts +42 -42
- package/src/components/VvAction/VvAction.vue +144 -130
- package/src/components/VvAlert/VvAlert.vue +72 -70
- package/src/components/VvAlert/index.ts +149 -147
- package/src/components/VvAlertGroup/VvAlertGroup.vue +57 -56
- package/src/components/VvAlertGroup/index.ts +101 -117
- package/src/components/VvAvatar/VvAvatar.vue +20 -14
- package/src/components/VvAvatar/index.ts +5 -5
- package/src/components/VvAvatarGroup/VvAvatarGroup.vue +58 -53
- package/src/components/VvAvatarGroup/index.ts +21 -21
- package/src/components/VvBadge/VvBadge.vue +15 -14
- package/src/components/VvBadge/index.ts +2 -2
- package/src/components/VvBreadcrumb/VvBreadcrumb.vue +50 -48
- package/src/components/VvBreadcrumb/index.ts +3 -9
- package/src/components/VvButton/VvButton.vue +163 -152
- package/src/components/VvButton/index.ts +103 -110
- package/src/components/VvButtonGroup/VvButtonGroup.vue +72 -64
- package/src/components/VvButtonGroup/index.ts +22 -21
- package/src/components/VvCard/VvCard.vue +30 -30
- package/src/components/VvCard/index.ts +2 -2
- package/src/components/VvCheckbox/VvCheckbox.vue +185 -183
- package/src/components/VvCheckbox/index.ts +44 -44
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +88 -87
- package/src/components/VvCombobox/VvCombobox.vue +639 -619
- package/src/components/VvCombobox/index.ts +206 -164
- package/src/components/VvDialog/VvDialog.vue +141 -129
- package/src/components/VvDialog/index.ts +38 -36
- package/src/components/VvDropdown/VvDropdown.vue +466 -445
- package/src/components/VvDropdown/VvDropdownAction.vue +37 -39
- package/src/components/VvDropdown/VvDropdownItem.vue +30 -26
- package/src/components/VvDropdown/VvDropdownOptgroup.vue +13 -12
- package/src/components/VvDropdown/VvDropdownOption.vue +47 -64
- package/src/components/VvDropdown/index.ts +61 -27
- package/src/components/VvIcon/README.md +1 -1
- package/src/components/VvIcon/VvIcon.vue +133 -133
- package/src/components/VvIcon/index.ts +84 -97
- package/src/components/VvInputFile/VvInputFile.vue +402 -0
- package/src/components/VvInputFile/index.ts +141 -0
- package/src/components/VvInputText/VvInputClearAction.ts +51 -47
- package/src/components/VvInputText/VvInputPasswordAction.ts +66 -62
- package/src/components/VvInputText/VvInputStepAction.ts +43 -43
- package/src/components/VvInputText/VvInputText.vue +638 -516
- package/src/components/VvInputText/VvInputTextActions.ts +86 -86
- package/src/components/VvInputText/index.ts +200 -185
- package/src/components/VvNav/VvNav.vue +40 -36
- package/src/components/VvNav/VvNavItem.vue +12 -12
- package/src/components/VvNav/VvNavSeparator.vue +6 -6
- package/src/components/VvNav/index.ts +2 -2
- package/src/components/VvProgress/VvProgress.vue +27 -27
- package/src/components/VvProgress/index.ts +28 -28
- package/src/components/VvRadio/VvRadio.vue +115 -112
- package/src/components/VvRadio/index.ts +28 -28
- package/src/components/VvRadioGroup/VvRadioGroup.vue +91 -90
- package/src/components/VvSelect/VvSelect.vue +262 -241
- package/src/components/VvSelect/index.ts +88 -63
- package/src/components/VvTab/VvTab.vue +79 -69
- package/src/components/VvTab/index.ts +12 -12
- package/src/components/VvTextarea/VvTextarea.vue +218 -219
- package/src/components/VvTextarea/index.ts +35 -35
- package/src/components/VvTooltip/VvTooltip.vue +22 -16
- package/src/components/VvTooltip/index.ts +12 -12
- package/src/components/common/HintSlot.ts +149 -150
- package/src/components/index.ts +10 -0
- package/src/composables/alert/useAlert.ts +76 -73
- package/src/composables/alert/useInjectAlert.ts +1 -1
- package/src/composables/alert/useProvideAlert.ts +10 -10
- package/src/composables/dropdown/useInjectDropdown.ts +6 -6
- package/src/composables/dropdown/useProvideDropdown.ts +63 -63
- package/src/composables/group/useInjectedGroupState.ts +46 -42
- package/src/composables/group/useProvideGroupState.ts +9 -15
- package/src/composables/index.ts +1 -0
- package/src/composables/useBlurhash.ts +68 -0
- package/src/composables/useComponentFocus.ts +9 -9
- package/src/composables/useComponentIcon.ts +36 -35
- package/src/composables/useDebouncedInput.ts +25 -25
- package/src/composables/useDefaults.ts +77 -76
- package/src/composables/useModifiers.ts +29 -29
- package/src/composables/useOptions.ts +52 -43
- package/src/composables/usePersistence.ts +74 -0
- package/src/composables/useTextCount.ts +44 -44
- package/src/composables/useUniqueId.ts +3 -2
- package/src/composables/useVolver.ts +1 -1
- package/src/constants.ts +97 -82
- package/src/directives/index.ts +3 -6
- package/src/directives/v-contextmenu.ts +34 -34
- package/src/directives/v-tooltip.ts +18 -9
- package/src/index.ts +6 -4
- package/src/props/index.ts +457 -380
- package/src/resolvers/unplugin.ts +146 -136
- package/src/shims.d.ts +4 -5
- package/src/stories/Accordion/Accordion.settings.ts +51 -50
- package/src/stories/Accordion/Accordion.stories.ts +21 -21
- package/src/stories/Accordion/Accordion.test.ts +56 -54
- package/src/stories/Accordion/AccordionSlots.stories.ts +13 -13
- package/src/stories/AccordionGroup/AccordionGroup.settings.ts +70 -67
- package/src/stories/AccordionGroup/AccordionGroup.stories.ts +41 -39
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +49 -45
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +35 -35
- package/src/stories/Alert/Alert.settings.ts +117 -116
- package/src/stories/Alert/Alert.stories.ts +30 -30
- package/src/stories/Alert/Alert.test.ts +78 -80
- package/src/stories/Alert/AlertModifiers.stories.ts +45 -45
- package/src/stories/Alert/AlertSlots.stories.ts +35 -35
- package/src/stories/AlertGroup/AlertGroup.settings.ts +107 -105
- package/src/stories/AlertGroup/AlertGroup.stories.ts +25 -25
- package/src/stories/AlertGroup/AlertGroup.test.ts +67 -69
- package/src/stories/AlertGroup/AlertGroupPosition.stories.ts +68 -68
- package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +23 -23
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +58 -58
- package/src/stories/Avatar/Avatar.settings.ts +29 -29
- package/src/stories/Avatar/Avatar.stories.ts +23 -23
- package/src/stories/Avatar/Avatar.test.ts +22 -24
- package/src/stories/Avatar/AvatarBadge.stories.ts +15 -15
- package/src/stories/Avatar/AvatarModifiers.stories.ts +61 -61
- package/src/stories/Avatar/AvatarSlots.stories.ts +18 -18
- package/src/stories/AvatarGroup/AvatarGroup.settings.ts +54 -53
- package/src/stories/AvatarGroup/AvatarGroup.stories.ts +17 -17
- package/src/stories/AvatarGroup/AvatarGroup.test.ts +24 -26
- package/src/stories/AvatarGroup/AvatarGroupModifiers.stories.ts +15 -15
- package/src/stories/AvatarGroup/AvatarGroupSlotDefault.stories.ts +17 -17
- package/src/stories/Badge/Badge.settings.ts +21 -20
- package/src/stories/Badge/Badge.stories.ts +24 -24
- package/src/stories/Badge/Badge.test.ts +8 -8
- package/src/stories/Badge/BadgeSlots.stories.ts +10 -10
- package/src/stories/Blurhash/BlurhashComposable.stories.ts +196 -0
- package/src/stories/Breadcrumb/Breadcrumb.settings.ts +35 -34
- package/src/stories/Breadcrumb/Breadcrumb.stories.ts +23 -23
- package/src/stories/Breadcrumb/Breadcrumb.test.ts +44 -43
- package/src/stories/Breadcrumb/BreadcrumbSlots.stories.ts +17 -17
- package/src/stories/Button/Button.settings.ts +146 -150
- package/src/stories/Button/Button.stories.ts +19 -19
- package/src/stories/Button/Button.test.ts +41 -42
- package/src/stories/Button/ButtonIcon.stories.ts +42 -42
- package/src/stories/Button/ButtonLink.stories.ts +24 -24
- package/src/stories/Button/ButtonLoading.stories.ts +22 -22
- package/src/stories/Button/ButtonModifiers.stories.ts +91 -91
- package/src/stories/Button/ButtonSlots.stories.ts +47 -47
- package/src/stories/Button/ButtonState.stories.ts +23 -23
- package/src/stories/Button/ButtonToggle.stories.ts +30 -30
- package/src/stories/ButtonGroup/ButtonGroup.settings.ts +33 -24
- package/src/stories/ButtonGroup/ButtonGroup.stories.ts +20 -20
- package/src/stories/ButtonGroup/ButtonGroup.test.ts +23 -26
- package/src/stories/ButtonGroup/ButtonGroupModifiers.stories.ts +20 -20
- package/src/stories/ButtonGroup/ButtonGroupSlots.stories.ts +18 -18
- package/src/stories/ButtonGroup/ButtonGroupToggle.stories.ts +22 -22
- package/src/stories/Card/Card.settings.ts +49 -48
- package/src/stories/Card/Card.stories.ts +22 -22
- package/src/stories/Card/Card.test.ts +14 -16
- package/src/stories/Card/CardSlots.stories.ts +42 -42
- package/src/stories/Checkbox/Checkbox.settings.ts +36 -35
- package/src/stories/Checkbox/Checkbox.stories.ts +57 -57
- package/src/stories/Checkbox/Checkbox.test.ts +63 -66
- package/src/stories/Checkbox/CheckboxBinary.stories.ts +18 -18
- package/src/stories/Checkbox/CheckboxSlots.stories.ts +15 -15
- package/src/stories/CheckboxGroup/CheckboxGroup.settings.ts +9 -9
- package/src/stories/CheckboxGroup/CheckboxGroup.stories.ts +50 -50
- package/src/stories/CheckboxGroup/CheckboxGroup.test.ts +63 -67
- package/src/stories/CheckboxGroup/CheckboxGroupOptions.stories.ts +34 -34
- package/src/stories/CheckboxGroup/CheckboxGroupSlots.stories.ts +23 -23
- package/src/stories/Combobox/Combobox.settings.ts +407 -384
- package/src/stories/Combobox/Combobox.stories.ts +116 -107
- package/src/stories/Combobox/Combobox.test.ts +91 -91
- package/src/stories/Combobox/ComboboxIconPosition.stories.ts +25 -24
- package/src/stories/Combobox/ComboboxMultiple.stories.ts +32 -22
- package/src/stories/Combobox/ComboboxOptions.stories.ts +81 -84
- package/src/stories/Combobox/ComboboxSlots.stories.ts +56 -55
- package/src/stories/Dialog/Dialog.settings.ts +49 -40
- package/src/stories/Dialog/Dialog.stories.ts +28 -28
- package/src/stories/Dialog/Dialog.test.ts +49 -54
- package/src/stories/Dialog/DialogModifiers.stories.ts +42 -0
- package/src/stories/Dialog/DialogSlots.stories.ts +20 -20
- package/src/stories/Dropdown/Dropdown.settings.ts +63 -62
- package/src/stories/Dropdown/Dropdown.stories.ts +59 -59
- package/src/stories/Dropdown/Dropdown.test.ts +9 -13
- package/src/stories/Dropdown/DropdownContextmenuDirective.stories.ts +16 -16
- package/src/stories/Dropdown/DropdownMultilevel.stories.ts +18 -18
- package/src/stories/Dropdown/DropdownSlots.stories.ts +50 -50
- package/src/stories/Icon/Icon.settings.ts +66 -65
- package/src/stories/Icon/Icon.stories.ts +28 -29
- package/src/stories/Icon/IconsCollection.stories.ts +22 -22
- package/src/stories/InputFile/InputFile.settings.ts +37 -0
- package/src/stories/InputFile/InputFile.stories.ts +89 -0
- package/src/stories/InputFile/InputFileDropArea.stories.ts +56 -0
- package/src/stories/InputFile/InputFileIconPosition.stories.ts +43 -0
- package/src/stories/InputFile/InputFileSlots.stories.ts +33 -0
- package/src/stories/InputText/InputText.settings.ts +246 -244
- package/src/stories/InputText/InputText.stories.ts +67 -67
- package/src/stories/InputText/InputText.test.ts +118 -121
- package/src/stories/InputText/InputTextIconPosition.stories.ts +24 -24
- package/src/stories/InputText/InputTextLength.stories.ts +33 -33
- package/src/stories/InputText/InputTextMask.stories.ts +91 -91
- package/src/stories/InputText/InputTextMinMax.stories.ts +30 -30
- package/src/stories/InputText/InputTextSlots.stories.ts +20 -20
- package/src/stories/InputText/InputTextType.stories.ts +70 -70
- package/src/stories/Nav/Nav.settings.ts +27 -27
- package/src/stories/Nav/Nav.stories.ts +18 -18
- package/src/stories/Nav/Nav.test.ts +10 -12
- package/src/stories/Nav/NavModifiers.stories.ts +25 -25
- package/src/stories/Progress/Progress.settings.ts +24 -23
- package/src/stories/Progress/Progress.stories.ts +23 -23
- package/src/stories/Progress/Progress.test.ts +4 -4
- package/src/stories/Radio/Radio.settings.ts +9 -9
- package/src/stories/Radio/Radio.stories.ts +47 -47
- package/src/stories/Radio/Radio.test.ts +54 -57
- package/src/stories/Radio/RadioSlots.stories.ts +15 -15
- package/src/stories/RadioGroup/RadioGroup.settings.ts +9 -9
- package/src/stories/RadioGroup/RadioGroup.stories.ts +51 -52
- package/src/stories/RadioGroup/RadioGroup.test.ts +63 -67
- package/src/stories/RadioGroup/RadioGroupOptions.stories.ts +35 -35
- package/src/stories/RadioGroup/RadioGroupSlots.stories.ts +23 -23
- package/src/stories/Select/Select.settings.ts +71 -70
- package/src/stories/Select/Select.stories.ts +75 -66
- package/src/stories/Select/Select.test.ts +67 -70
- package/src/stories/Select/SelectIconPosition.stories.ts +27 -26
- package/src/stories/Select/SelectOptions.stories.ts +55 -55
- package/src/stories/Select/SelectSlots.stories.ts +21 -20
- package/src/stories/Tab/Tab.settings.ts +34 -34
- package/src/stories/Tab/Tab.stories.ts +17 -17
- package/src/stories/Tab/Tab.test.ts +17 -19
- package/src/stories/Textarea/Textarea.settings.ts +79 -77
- package/src/stories/Textarea/Textarea.stories.ts +63 -63
- package/src/stories/Textarea/Textarea.test.ts +70 -73
- package/src/stories/Textarea/TextareaLength.stories.ts +33 -33
- package/src/stories/Textarea/TextareaSlots.stories.ts +20 -20
- package/src/stories/Textarea/TextareatIconPosition.stories.ts +24 -24
- package/src/stories/Tooltip/Tooltip.settings.ts +16 -17
- package/src/stories/Tooltip/Tooltip.stories.ts +18 -18
- package/src/stories/Tooltip/Tooltip.test.ts +53 -54
- package/src/stories/Tooltip/TooltipDirective.stories.ts +37 -37
- package/src/stories/argTypes.ts +506 -505
- package/src/test/expect.ts +72 -77
- package/src/test/options.ts +17 -16
- package/src/test/sleep.ts +3 -2
- package/src/test/types.d.ts +11 -11
- package/src/types/alert.ts +21 -17
- package/src/types/blurhash.ts +21 -0
- package/src/types/generic.ts +2 -3
- package/src/types/group.ts +34 -26
- package/src/types/index.ts +7 -0
- package/src/types/input-file.ts +18 -0
- package/src/types/nav.ts +13 -14
- package/src/utils/ObjectUtilities.ts +192 -188
- package/src/workers/blurhash.ts +9 -0
|
@@ -1,103 +1,90 @@
|
|
|
1
|
-
import type { PropType } from 'vue'
|
|
2
1
|
import type { IconifyIconOnLoad, IconifyRenderMode } from '@iconify/vue'
|
|
3
2
|
|
|
3
|
+
export const ACTION_ICONS = {
|
|
4
|
+
showPassword: 'eye-on',
|
|
5
|
+
hidePassword: 'eye-off',
|
|
6
|
+
showDatePicker: 'calendar',
|
|
7
|
+
showTimePicker: 'time',
|
|
8
|
+
showColorPicker: 'color',
|
|
9
|
+
clear: 'close',
|
|
10
|
+
add: 'add',
|
|
11
|
+
remove: 'trash',
|
|
12
|
+
edit: 'edit',
|
|
13
|
+
download: 'download',
|
|
14
|
+
} as const
|
|
15
|
+
|
|
4
16
|
export enum IconPrefix {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
simple = 'simple',
|
|
18
|
+
normal = 'normal',
|
|
19
|
+
detailed = 'detailed',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type VvIconProps = {
|
|
23
|
+
/**
|
|
24
|
+
* Icon name
|
|
25
|
+
* Can be the full composition of iconify name "@{provider}:{prefix}:{name}" or "{prefix}:{name}" or "{name}"
|
|
26
|
+
* https://docs.iconify.design/api/providers.html#provider-in-icon-name
|
|
27
|
+
*/
|
|
28
|
+
name: string
|
|
29
|
+
color?: string
|
|
30
|
+
width?: string | number
|
|
31
|
+
height?: string | number
|
|
32
|
+
/**
|
|
33
|
+
* If custom collection is not added with "addCollection" DS class method, this prop could not be used
|
|
34
|
+
* Icon provider: https://docs.iconify.design/api/providers.html#provider-in-icon-name
|
|
35
|
+
*/
|
|
36
|
+
provider?: string
|
|
37
|
+
/**
|
|
38
|
+
* @default 'normal'
|
|
39
|
+
* The name of icon set.
|
|
40
|
+
* Icon default options prefix: simple | normal | detailed
|
|
41
|
+
*/
|
|
42
|
+
prefix?: IconPrefix | string
|
|
43
|
+
/**
|
|
44
|
+
* Url remote SVG icon
|
|
45
|
+
*/
|
|
46
|
+
src?: string
|
|
47
|
+
horizontalFlip?: boolean
|
|
48
|
+
verticalFlip?: boolean
|
|
49
|
+
/**
|
|
50
|
+
* String alternative to "horizontalFlip" and "verticalFlip".
|
|
51
|
+
* Example: https://docs.iconify.design/icon-components/vue/transform.html
|
|
52
|
+
*/
|
|
53
|
+
flip?: string
|
|
54
|
+
/**
|
|
55
|
+
* Icon render mode
|
|
56
|
+
* 'style' = 'bg' or 'mask', depending on icon content
|
|
57
|
+
* 'bg' = span with style using `background`
|
|
58
|
+
* 'mask' = span with style using `mask`
|
|
59
|
+
* 'svg' = svg
|
|
60
|
+
* Iconify doc: https://docs.iconify.design/iconify-icon/modes.html
|
|
61
|
+
*/
|
|
62
|
+
mode?: IconifyRenderMode
|
|
63
|
+
/**
|
|
64
|
+
* Toggles inline or block mode
|
|
65
|
+
* Example https://docs.iconify.design/icon-components/vue/inline.html
|
|
66
|
+
*/
|
|
67
|
+
inline?: boolean
|
|
68
|
+
/**
|
|
69
|
+
* rotates icon
|
|
70
|
+
* Example https://docs.iconify.design/icon-components/vue/transform.html
|
|
71
|
+
*/
|
|
72
|
+
rotate?: number | string
|
|
73
|
+
/**
|
|
74
|
+
* A callback that is called when icon data has been loaded
|
|
75
|
+
*/
|
|
76
|
+
onLoad?: IconifyIconOnLoad
|
|
77
|
+
/**
|
|
78
|
+
* SVG icon string
|
|
79
|
+
*/
|
|
80
|
+
svg?: string
|
|
81
|
+
/**
|
|
82
|
+
* Icon modifiers: vv-icon css helper classes, value/s are concatened with prefix 'vv-icon--'
|
|
83
|
+
* @values string | string[]
|
|
84
|
+
*/
|
|
85
|
+
modifiers?: string | string[]
|
|
8
86
|
}
|
|
9
87
|
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
* Color
|
|
13
|
-
*/
|
|
14
|
-
color: String,
|
|
15
|
-
/**
|
|
16
|
-
* Width
|
|
17
|
-
*/
|
|
18
|
-
width: {
|
|
19
|
-
type: [String, Number],
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* Height
|
|
23
|
-
*/
|
|
24
|
-
height: {
|
|
25
|
-
type: [String, Number],
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* Icon name
|
|
29
|
-
* Can be the full composition of iconify name "@{provider}:{prefix}:{name}" or "{prefix}:{name}" or "{name}"
|
|
30
|
-
* https://docs.iconify.design/api/providers.html#provider-in-icon-name
|
|
31
|
-
*/
|
|
32
|
-
name: {
|
|
33
|
-
type: String,
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* By default 'vv'
|
|
38
|
-
* If custom collection is not added with "addCollection" DS class method, this prop could not be used
|
|
39
|
-
* Icon provider: https://docs.iconify.design/api/providers.html#provider-in-icon-name
|
|
40
|
-
*/
|
|
41
|
-
provider: {
|
|
42
|
-
type: String,
|
|
43
|
-
},
|
|
44
|
-
/**
|
|
45
|
-
* The name of icon set.
|
|
46
|
-
* Icon default options prefix: simple | normal | detailed
|
|
47
|
-
*/
|
|
48
|
-
prefix: {
|
|
49
|
-
type: String as PropType<`${IconPrefix}` | string>,
|
|
50
|
-
default: 'normal',
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* Url remote SVG icon
|
|
54
|
-
*/
|
|
55
|
-
src: String,
|
|
56
|
-
/**
|
|
57
|
-
* Horizontal flip
|
|
58
|
-
*/
|
|
59
|
-
horizontalFlip: Boolean,
|
|
60
|
-
/**
|
|
61
|
-
* Vertical flip
|
|
62
|
-
*/
|
|
63
|
-
verticalFlip: Boolean,
|
|
64
|
-
/**
|
|
65
|
-
* String alternative to "horizontalFlip" and "verticalFlip".
|
|
66
|
-
* Example: https://docs.iconify.design/icon-components/vue/transform.html
|
|
67
|
-
*/
|
|
68
|
-
flip: String,
|
|
69
|
-
/**
|
|
70
|
-
* Icon render mode
|
|
71
|
-
* 'style' = 'bg' or 'mask', depending on icon content
|
|
72
|
-
* 'bg' = span with style using `background`
|
|
73
|
-
* 'mask' = span with style using `mask`
|
|
74
|
-
* 'svg' = svg
|
|
75
|
-
* Iconify doc: https://docs.iconify.design/iconify-icon/modes.html
|
|
76
|
-
*/
|
|
77
|
-
mode: String as PropType<`${IconifyRenderMode}`>,
|
|
78
|
-
/**
|
|
79
|
-
* Toggles inline or block mode
|
|
80
|
-
* Example https://docs.iconify.design/icon-components/vue/inline.html
|
|
81
|
-
*/
|
|
82
|
-
inline: Boolean,
|
|
83
|
-
/**
|
|
84
|
-
* rotates icon
|
|
85
|
-
* Example https://docs.iconify.design/icon-components/vue/transform.html
|
|
86
|
-
*/
|
|
87
|
-
rotate: [Number, String],
|
|
88
|
-
/**
|
|
89
|
-
* A callback that is called when icon data has been loaded
|
|
90
|
-
*/
|
|
91
|
-
onLoad: Function as PropType<IconifyIconOnLoad>,
|
|
92
|
-
/**
|
|
93
|
-
* SVG icon string
|
|
94
|
-
*/
|
|
95
|
-
svg: String,
|
|
96
|
-
/**
|
|
97
|
-
* Icon modifiers: vv-icon css helper classes, value/s are concatened with prefix 'vv-icon--'
|
|
98
|
-
* @values string | string[]
|
|
99
|
-
*/
|
|
100
|
-
modifiers: {
|
|
101
|
-
type: [String, Array] as PropType<string | string[]>,
|
|
102
|
-
},
|
|
88
|
+
export const VvIconPropsDefaults = {
|
|
89
|
+
prefix: IconPrefix.normal,
|
|
103
90
|
}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useVModel } from '@vueuse/core'
|
|
3
|
+
import { computed, onBeforeUnmount, ref } from 'vue'
|
|
4
|
+
import Sortable from 'vuedraggable'
|
|
5
|
+
import type { UploadedFile } from '../../types'
|
|
6
|
+
import VvButton from '../VvButton/VvButton.vue'
|
|
7
|
+
import VvIcon from '../VvIcon/VvIcon.vue'
|
|
8
|
+
import HintSlotFactory from '../common/HintSlot'
|
|
9
|
+
import { type VvInputFileEvents, VvInputFileProps } from '.'
|
|
10
|
+
|
|
11
|
+
// props, emit, slots and attrs
|
|
12
|
+
const props = defineProps(VvInputFileProps)
|
|
13
|
+
const emit = defineEmits<VvInputFileEvents>()
|
|
14
|
+
const slots = useSlots()
|
|
15
|
+
|
|
16
|
+
// props merged with volver defaults (now only for labels)
|
|
17
|
+
const propsDefaults = useDefaults<typeof VvInputFileProps>(
|
|
18
|
+
'VvInputFile',
|
|
19
|
+
VvInputFileProps,
|
|
20
|
+
props,
|
|
21
|
+
)
|
|
22
|
+
const { modifiers, id, readonly, icon, iconPosition, iconDownload }
|
|
23
|
+
= toRefs(props)
|
|
24
|
+
const hasId = useUniqueId(id)
|
|
25
|
+
const hasHintId = computed(() => `${hasId.value}-hint`)
|
|
26
|
+
|
|
27
|
+
const hasProgress = computed(() => {
|
|
28
|
+
if (!props.progress) {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
const progress
|
|
32
|
+
= typeof props.progress === 'string'
|
|
33
|
+
? Number.parseInt(props.progress)
|
|
34
|
+
: props.progress
|
|
35
|
+
return progress > 0 && progress < 100
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const { hasIconBefore, hasIconAfter } = useComponentIcon(icon, iconPosition)
|
|
39
|
+
const { hasIcon: hasIconDownload } = useComponentIcon(iconDownload)
|
|
40
|
+
|
|
41
|
+
// styles
|
|
42
|
+
const bemCssClasses = useModifiers(
|
|
43
|
+
'vv-input-file',
|
|
44
|
+
modifiers,
|
|
45
|
+
computed(() => ({
|
|
46
|
+
'dragging': isDragging.value,
|
|
47
|
+
'loading': props.loading && !hasProgress.value,
|
|
48
|
+
'valid': props.valid === true,
|
|
49
|
+
'invalid': props.invalid === true,
|
|
50
|
+
'icon-before': !!hasIconBefore.value,
|
|
51
|
+
'icon-after': !!hasIconAfter.value,
|
|
52
|
+
'drop-area': hasDropArea.value,
|
|
53
|
+
})),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
HintSlot,
|
|
58
|
+
hasHintLabelOrSlot,
|
|
59
|
+
hasInvalidLabelOrSlot,
|
|
60
|
+
hintSlotScope,
|
|
61
|
+
} = HintSlotFactory(propsDefaults, slots)
|
|
62
|
+
|
|
63
|
+
const localModelValue = useVModel(props, 'modelValue', emit)
|
|
64
|
+
const files = computed({
|
|
65
|
+
get: () => {
|
|
66
|
+
if (
|
|
67
|
+
!localModelValue.value
|
|
68
|
+
|| (!Array.isArray(localModelValue.value)
|
|
69
|
+
&& !(localModelValue.value as File)?.name)
|
|
70
|
+
) {
|
|
71
|
+
return []
|
|
72
|
+
}
|
|
73
|
+
return Array.isArray(localModelValue.value)
|
|
74
|
+
? localModelValue.value
|
|
75
|
+
: [localModelValue.value]
|
|
76
|
+
},
|
|
77
|
+
set: (value) => {
|
|
78
|
+
if (isMultiple.value) {
|
|
79
|
+
localModelValue.value = value
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
localModelValue.value = value?.[0]
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const hasMax = computed(() => {
|
|
87
|
+
return typeof props.max === 'string' ? Number.parseInt(props.max) : props.max
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const hasDropArea = computed(() => {
|
|
91
|
+
return props.dropArea && !readonly.value
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const isMultiple = computed(() => {
|
|
95
|
+
if (!props.multiple) {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
if (!hasMax.value) {
|
|
99
|
+
return true
|
|
100
|
+
}
|
|
101
|
+
return hasMax.value - files.value.length > 1
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const isDragging = ref(false)
|
|
105
|
+
|
|
106
|
+
const inputEl = ref<HTMLInputElement>()
|
|
107
|
+
function onDragenter() {
|
|
108
|
+
isDragging.value = true
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function onDragleave() {
|
|
112
|
+
isDragging.value = false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function onDrop(event: DragEvent) {
|
|
116
|
+
if (!event.dataTransfer?.files) {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
isDragging.value = false
|
|
120
|
+
addFiles(event.dataTransfer?.files)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function onChange() {
|
|
124
|
+
if (!inputEl.value?.files) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
addFiles(inputEl.value.files)
|
|
128
|
+
inputEl.value.value = ''
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function addFiles(uploadedFiles: FileList) {
|
|
132
|
+
if (!props.multiple) {
|
|
133
|
+
if (Array.isArray(localModelValue.value)) {
|
|
134
|
+
localModelValue.value = [...uploadedFiles]
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
localModelValue.value = uploadedFiles[0]
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
let toReturn: (File | UploadedFile)[] = []
|
|
141
|
+
if (!Array.isArray(localModelValue.value) && localModelValue.value) {
|
|
142
|
+
toReturn = [localModelValue.value]
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
toReturn
|
|
146
|
+
= localModelValue.value && Array.isArray(localModelValue.value)
|
|
147
|
+
? [...localModelValue.value]
|
|
148
|
+
: toReturn
|
|
149
|
+
}
|
|
150
|
+
for (const file of uploadedFiles) {
|
|
151
|
+
if (hasMax.value && toReturn.length >= hasMax.value) {
|
|
152
|
+
break
|
|
153
|
+
}
|
|
154
|
+
toReturn.push(file)
|
|
155
|
+
}
|
|
156
|
+
localModelValue.value = toReturn
|
|
157
|
+
selectedFileIndex.value = toReturn.length - 1
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function onClickDropArea() {
|
|
161
|
+
if (!inputEl.value) {
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
if (!readonly.value) {
|
|
165
|
+
inputEl.value.click()
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function onClickRemoveFile(index: number) {
|
|
170
|
+
const toRemove = !Array.isArray(localModelValue.value) ? localModelValue.value : localModelValue.value[index]
|
|
171
|
+
if (!toRemove) {
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
emit('remove', toRemove)
|
|
175
|
+
if (!Array.isArray(localModelValue.value)) {
|
|
176
|
+
localModelValue.value = undefined
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
if (selectedFileIndex.value === index) {
|
|
180
|
+
selectedFileIndex.value = 0
|
|
181
|
+
}
|
|
182
|
+
const newModelValue = [...localModelValue.value]
|
|
183
|
+
newModelValue.splice(index, 1)
|
|
184
|
+
localModelValue.value = newModelValue
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const selectedFileIndex = ref(0)
|
|
188
|
+
const PREVIEW_MIME_TYPES = ['image/jpeg', 'image/png']
|
|
189
|
+
const previewSrc = computed(() => {
|
|
190
|
+
if (files.value.length === 0) {
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
if (!files.value[selectedFileIndex.value]) {
|
|
194
|
+
return undefined
|
|
195
|
+
}
|
|
196
|
+
if (files.value[selectedFileIndex.value] instanceof File) {
|
|
197
|
+
const currentFile = files.value[selectedFileIndex.value] as File
|
|
198
|
+
if (!PREVIEW_MIME_TYPES.includes(currentFile.type)) {
|
|
199
|
+
return undefined
|
|
200
|
+
}
|
|
201
|
+
return URL.createObjectURL(currentFile)
|
|
202
|
+
}
|
|
203
|
+
const currentFile = files.value[selectedFileIndex.value] as UploadedFile
|
|
204
|
+
if (currentFile.thumbnailUrl) {
|
|
205
|
+
return currentFile.thumbnailUrl
|
|
206
|
+
}
|
|
207
|
+
if (!PREVIEW_MIME_TYPES.includes(currentFile.type)) {
|
|
208
|
+
return undefined
|
|
209
|
+
}
|
|
210
|
+
return currentFile.url
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
watch(previewSrc, (_newValue, oldValue) => {
|
|
214
|
+
if (oldValue) {
|
|
215
|
+
URL.revokeObjectURL(oldValue)
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
onBeforeUnmount(() => {
|
|
220
|
+
if (previewSrc.value) {
|
|
221
|
+
URL.revokeObjectURL(previewSrc.value)
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
function sizeInKiB(size?: number) {
|
|
226
|
+
if (!size) {
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
return Math.floor(size / 1024)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function onClickDownloadFile(file: File | UploadedFile) {
|
|
233
|
+
emit('download', file)
|
|
234
|
+
const href = file instanceof File ? URL.createObjectURL(file) : file.url
|
|
235
|
+
if (!href) {
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
const link = document.createElement('a')
|
|
239
|
+
link.href = href
|
|
240
|
+
link.setAttribute('download', file.name)
|
|
241
|
+
document.body.appendChild(link)
|
|
242
|
+
link.click()
|
|
243
|
+
document.body.removeChild(link)
|
|
244
|
+
URL.revokeObjectURL(link.href)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function onClickSelectFile(index: number) {
|
|
248
|
+
selectedFileIndex.value = index
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const dropdAreaActionLabel = computed(() => {
|
|
252
|
+
if (files.value.length === 0 || isMultiple.value) {
|
|
253
|
+
return props.labelAdd
|
|
254
|
+
}
|
|
255
|
+
return props.labelReplace
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
const dropAreaActionIcon = computed(() => {
|
|
259
|
+
if (files.value.length === 0 || isMultiple.value) {
|
|
260
|
+
return props.iconAdd
|
|
261
|
+
}
|
|
262
|
+
return props.iconReplace
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
function onSortEnd({ newIndex }: { newIndex: number | null }) {
|
|
266
|
+
if (newIndex !== null) {
|
|
267
|
+
selectedFileIndex.value = newIndex
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
</script>
|
|
271
|
+
|
|
272
|
+
<script lang="ts">
|
|
273
|
+
export default {
|
|
274
|
+
name: 'VvInputFile',
|
|
275
|
+
}
|
|
276
|
+
</script>
|
|
277
|
+
|
|
278
|
+
<template>
|
|
279
|
+
<div :class="bemCssClasses">
|
|
280
|
+
<label v-if="label" :for="hasId">
|
|
281
|
+
{{ label }}
|
|
282
|
+
</label>
|
|
283
|
+
<div
|
|
284
|
+
v-if="hasDropArea"
|
|
285
|
+
class="vv-input-file__drop-area"
|
|
286
|
+
@dragenter.prevent.stop="onDragenter"
|
|
287
|
+
@dragleave.prevent.stop="onDragleave"
|
|
288
|
+
@drop.prevent.stop="onDrop"
|
|
289
|
+
@dragover.prevent.stop
|
|
290
|
+
@click.stop="onClickDropArea"
|
|
291
|
+
>
|
|
292
|
+
<slot name="drop-area">
|
|
293
|
+
<picture class="vv-input-file__preview">
|
|
294
|
+
<img
|
|
295
|
+
v-if="previewSrc"
|
|
296
|
+
:src="previewSrc"
|
|
297
|
+
:alt="files[selectedFileIndex].name"
|
|
298
|
+
>
|
|
299
|
+
</picture>
|
|
300
|
+
<VvButton
|
|
301
|
+
v-if="!readonly"
|
|
302
|
+
modifiers="action"
|
|
303
|
+
:label="!previewSrc ? dropdAreaActionLabel : undefined"
|
|
304
|
+
:title="previewSrc ? dropdAreaActionLabel : undefined"
|
|
305
|
+
:class="{
|
|
306
|
+
'vv-input-file__drop-area-action': previewSrc,
|
|
307
|
+
}"
|
|
308
|
+
:icon="dropAreaActionIcon"
|
|
309
|
+
@click.stop="onClickDropArea"
|
|
310
|
+
/>
|
|
311
|
+
</slot>
|
|
312
|
+
</div>
|
|
313
|
+
<div class="vv-input-file__wrapper">
|
|
314
|
+
<VvIcon v-if="hasIconBefore" v-bind="hasIconBefore" />
|
|
315
|
+
<input
|
|
316
|
+
:id="hasId"
|
|
317
|
+
ref="inputEl"
|
|
318
|
+
type="file"
|
|
319
|
+
:readonly="readonly"
|
|
320
|
+
:placeholder="placeholder"
|
|
321
|
+
:aria-describedby="hasHintLabelOrSlot ? hasHintId : undefined"
|
|
322
|
+
:aria-invalid="invalid"
|
|
323
|
+
:aria-errormessage="
|
|
324
|
+
hasInvalidLabelOrSlot ? hasHintId : undefined
|
|
325
|
+
"
|
|
326
|
+
:multiple="isMultiple"
|
|
327
|
+
:accept="accept"
|
|
328
|
+
:capture="capture"
|
|
329
|
+
:name="name"
|
|
330
|
+
@change="onChange"
|
|
331
|
+
>
|
|
332
|
+
<progress
|
|
333
|
+
v-if="hasProgress"
|
|
334
|
+
class="vv-input-file__progress"
|
|
335
|
+
:value="progress"
|
|
336
|
+
max="100"
|
|
337
|
+
>
|
|
338
|
+
{{ progress }}%
|
|
339
|
+
</progress>
|
|
340
|
+
<VvIcon v-if="hasIconAfter" v-bind="hasIconAfter" />
|
|
341
|
+
</div>
|
|
342
|
+
<Sortable
|
|
343
|
+
v-model="files"
|
|
344
|
+
tag="ul"
|
|
345
|
+
class="vv-input-file__list"
|
|
346
|
+
item-key="name"
|
|
347
|
+
:move="() => sortable"
|
|
348
|
+
@end="onSortEnd"
|
|
349
|
+
>
|
|
350
|
+
<template #item="{ element: file, index }">
|
|
351
|
+
<li
|
|
352
|
+
class="vv-input-file__item"
|
|
353
|
+
:class="{
|
|
354
|
+
'active':
|
|
355
|
+
index === selectedFileIndex
|
|
356
|
+
&& hasDropArea
|
|
357
|
+
&& files.length > 1,
|
|
358
|
+
'cursor-move': sortable,
|
|
359
|
+
}"
|
|
360
|
+
@click.stop="onClickSelectFile(index)"
|
|
361
|
+
>
|
|
362
|
+
<button
|
|
363
|
+
v-if="hasIconDownload"
|
|
364
|
+
type="button"
|
|
365
|
+
class="vv-input-file__item-action"
|
|
366
|
+
:title="labelDownload"
|
|
367
|
+
@click.stop="onClickDownloadFile(file)"
|
|
368
|
+
>
|
|
369
|
+
<VvIcon v-bind="hasIconDownload" />
|
|
370
|
+
</button>
|
|
371
|
+
<div class="vv-input-file__item-name">
|
|
372
|
+
{{ file.name }}
|
|
373
|
+
</div>
|
|
374
|
+
<small class="vv-input-file__item-info">
|
|
375
|
+
{{ sizeInKiB(file.size) }} KB
|
|
376
|
+
</small>
|
|
377
|
+
<button
|
|
378
|
+
v-if="!readonly"
|
|
379
|
+
type="button"
|
|
380
|
+
class="vv-input-file__item-remove"
|
|
381
|
+
:title="labelRemove"
|
|
382
|
+
@click.stop="onClickRemoveFile(index)"
|
|
383
|
+
/>
|
|
384
|
+
</li>
|
|
385
|
+
</template>
|
|
386
|
+
</Sortable>
|
|
387
|
+
<HintSlot :id="hasHintId" class="vv-input-file__hint">
|
|
388
|
+
<template v-if="$slots.hint" #hint>
|
|
389
|
+
<slot name="hint" v-bind="hintSlotScope" />
|
|
390
|
+
</template>
|
|
391
|
+
<template v-if="$slots.loading" #loading>
|
|
392
|
+
<slot name="loading" v-bind="hintSlotScope" />
|
|
393
|
+
</template>
|
|
394
|
+
<template v-if="$slots.valid" #valid>
|
|
395
|
+
<slot name="valid" v-bind="hintSlotScope" />
|
|
396
|
+
</template>
|
|
397
|
+
<template v-if="$slots.invalid" #invalid>
|
|
398
|
+
<slot name="invalid" v-bind="hintSlotScope" />
|
|
399
|
+
</template>
|
|
400
|
+
</HintSlot>
|
|
401
|
+
</div>
|
|
402
|
+
</template>
|