@volverjs/ui-vue 0.0.10-beta.3 → 0.0.10-beta.31
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 +106 -10
- package/auto-imports.d.ts +7 -2
- package/bin/icons.cjs +1 -1
- package/bin/icons.js +22 -15
- package/dist/Volver.d.ts +1 -1
- package/dist/components/VvAccordion/VvAccordion.es.js +192 -103
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +160 -8
- package/dist/components/VvAccordion/index.d.ts +8 -9
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +451 -172
- 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 +78 -27
- 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 +204 -171
- 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 +250 -188
- 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 +6 -14
- package/dist/components/VvAvatar/VvAvatar.es.js +61 -21
- 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 +118 -48
- 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 +78 -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 +291 -252
- 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 +81 -40
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +24 -11
- package/dist/components/VvButtonGroup/index.d.ts +8 -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 +177 -120
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +105 -33
- package/dist/components/VvCheckbox/index.d.ts +47 -14
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +190 -107
- 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 +806 -581
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +171 -104
- package/dist/components/VvCombobox/index.d.ts +62 -26
- package/dist/components/VvDialog/VvDialog.es.js +140 -153
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDialog/VvDialog.vue.d.ts +4 -4
- package/dist/components/VvDropdown/VvDropdown.es.js +138 -71
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +101 -75
- 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 +152 -39
- 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 +23 -96
- 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 +1777 -0
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -0
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +359 -0
- package/dist/components/VvInputFile/index.d.ts +200 -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 +1237 -324
- 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 +99 -29
- package/dist/components/VvNav/VvNav.es.js +135 -56
- 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 +91 -33
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +72 -26
- 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 +160 -103
- 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 +190 -107
- 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 +251 -238
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +117 -44
- package/dist/components/VvSelect/index.d.ts +48 -14
- package/dist/components/VvTab/VvTab.es.js +191 -75
- 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 +232 -224
- 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 +79 -29
- 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 +1 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.es.js +3534 -1650
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +99 -4
- 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 +92 -3
- package/dist/composables/index.umd.js +1 -1
- package/dist/composables/useBlurhash.d.ts +7 -0
- package/dist/composables/useComponentIcon.d.ts +9 -8
- package/dist/composables/usePersistence.d.ts +2 -0
- 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 +99 -43
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +97 -38
- 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 +90 -16
- 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/AccordionGroup/AccordionGroup.stories.d.ts +143 -89
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +1075 -492
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +1 -1
- package/dist/stories/Blurhash/BlurhashComposable.stories.d.ts +4 -0
- package/dist/stories/Button/Button.settings.d.ts +0 -1
- package/dist/stories/Combobox/Combobox.settings.d.ts +8 -0
- package/dist/stories/Icon/Icon.settings.d.ts +1 -0
- package/dist/stories/InputFile/InputFile.settings.d.ts +56 -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/Tab/Tab.settings.d.ts +2 -15
- package/dist/test/expect.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 +0 -1
- package/dist/workers/blurhash.d.ts +1 -0
- package/package.json +78 -78
- package/src/Volver.ts +31 -20
- 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 +121 -58
- package/src/components/VvAccordion/index.ts +8 -23
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +164 -47
- package/src/components/VvAccordionGroup/index.ts +6 -6
- package/src/components/VvAction/VvAction.vue +17 -5
- package/src/components/VvAlert/index.ts +14 -9
- package/src/components/VvAlertGroup/index.ts +3 -15
- package/src/components/VvBreadcrumb/VvBreadcrumb.vue +20 -19
- package/src/components/VvBreadcrumb/index.ts +2 -8
- package/src/components/VvButton/VvButton.vue +17 -7
- package/src/components/VvButton/index.ts +9 -16
- package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
- package/src/components/VvCheckbox/index.ts +2 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
- package/src/components/VvCombobox/VvCombobox.vue +15 -12
- package/src/components/VvCombobox/index.ts +4 -0
- package/src/components/VvDropdown/VvDropdown.vue +11 -2
- package/src/components/VvDropdown/VvDropdownItem.vue +4 -1
- package/src/components/VvDropdown/VvDropdownOption.vue +4 -21
- package/src/components/VvDropdown/index.ts +35 -1
- package/src/components/VvIcon/VvIcon.vue +2 -2
- package/src/components/VvIcon/index.ts +35 -48
- package/src/components/VvInputFile/VvInputFile.vue +395 -0
- package/src/components/VvInputFile/index.ts +135 -0
- package/src/components/VvInputText/VvInputClearAction.ts +10 -6
- package/src/components/VvInputText/VvInputPasswordAction.ts +13 -9
- package/src/components/VvInputText/VvInputText.vue +141 -33
- package/src/components/VvInputText/index.ts +31 -16
- package/src/components/VvNav/VvNav.vue +4 -2
- package/src/components/VvRadio/index.ts +5 -5
- package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
- package/src/components/VvSelect/VvSelect.vue +5 -8
- package/src/components/VvTab/VvTab.vue +5 -1
- package/src/components/VvTextarea/VvTextarea.vue +6 -9
- package/src/components/index.ts +10 -0
- package/src/composables/alert/useAlert.ts +12 -9
- package/src/composables/dropdown/useProvideDropdown.ts +4 -4
- package/src/composables/group/useInjectedGroupState.ts +20 -16
- package/src/composables/group/useProvideGroupState.ts +10 -15
- package/src/composables/index.ts +1 -0
- package/src/composables/useBlurhash.ts +76 -0
- package/src/composables/useComponentIcon.ts +15 -14
- package/src/composables/usePersistence.ts +76 -0
- package/src/composables/useUniqueId.ts +2 -2
- package/src/constants.ts +47 -32
- package/src/directives/index.ts +3 -6
- package/src/directives/v-tooltip.ts +19 -10
- package/src/index.ts +3 -1
- package/src/props/index.ts +108 -31
- package/src/resolvers/unplugin.ts +24 -14
- package/src/stories/Accordion/Accordion.test.ts +1 -1
- package/src/stories/AccordionGroup/AccordionGroup.settings.ts +2 -2
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +17 -11
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
- package/src/stories/Alert/Alert.test.ts +1 -1
- package/src/stories/AlertGroup/AlertGroup.test.ts +1 -1
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +2 -2
- package/src/stories/Avatar/Avatar.test.ts +1 -1
- package/src/stories/AvatarGroup/AvatarGroup.test.ts +1 -1
- package/src/stories/Badge/Badge.test.ts +1 -1
- package/src/stories/Blurhash/BlurhashComposable.stories.ts +195 -0
- package/src/stories/Button/Button.settings.ts +1 -4
- package/src/stories/Button/Button.test.ts +1 -1
- package/src/stories/ButtonGroup/ButtonGroup.test.ts +1 -1
- package/src/stories/Card/Card.test.ts +1 -1
- package/src/stories/Checkbox/Checkbox.test.ts +1 -1
- package/src/stories/CheckboxGroup/CheckboxGroup.test.ts +1 -1
- package/src/stories/Combobox/Combobox.settings.ts +8 -0
- package/src/stories/Combobox/Combobox.test.ts +1 -1
- package/src/stories/Dialog/Dialog.test.ts +2 -2
- package/src/stories/Dropdown/Dropdown.test.ts +1 -1
- package/src/stories/Icon/Icon.settings.ts +3 -3
- package/src/stories/InputFile/InputFile.settings.ts +36 -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.test.ts +1 -1
- package/src/stories/Nav/Nav.test.ts +1 -1
- package/src/stories/Progress/Progress.test.ts +1 -1
- package/src/stories/Radio/Radio.test.ts +1 -1
- package/src/stories/RadioGroup/RadioGroup.test.ts +1 -1
- package/src/stories/Select/Select.test.ts +1 -1
- package/src/stories/Tab/Tab.settings.ts +2 -2
- package/src/stories/Tab/Tab.test.ts +1 -1
- package/src/stories/Textarea/Textarea.test.ts +1 -1
- package/src/stories/Tooltip/Tooltip.test.ts +1 -1
- package/src/stories/argTypes.ts +1 -1
- package/src/test/expect.ts +2 -4
- package/src/types/alert.ts +11 -7
- package/src/types/blurhash.ts +21 -0
- package/src/types/generic.ts +3 -3
- package/src/types/group.ts +22 -14
- package/src/types/index.ts +7 -0
- package/src/types/input-file.ts +18 -0
- package/src/types/nav.ts +2 -3
- package/src/utils/ObjectUtilities.ts +0 -11
- package/src/workers/blurhash.ts +9 -0
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
import type { Ref } from 'vue'
|
|
2
|
-
import type GroupState from '../../types/group'
|
|
1
|
+
import type { Ref, InjectionKey } from 'vue'
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Injects a group state
|
|
6
5
|
*/
|
|
7
|
-
export function useInjectedGroupState<GroupStateType
|
|
8
|
-
groupKey:
|
|
6
|
+
export function useInjectedGroupState<GroupStateType>(
|
|
7
|
+
groupKey: InjectionKey<GroupStateType>,
|
|
9
8
|
) {
|
|
10
9
|
// Get group state
|
|
11
|
-
const group = inject<
|
|
10
|
+
const group = inject<GroupStateType | undefined>(groupKey, undefined)
|
|
12
11
|
|
|
13
12
|
// Check if component is in group
|
|
14
|
-
const isInGroup = computed(() =>
|
|
13
|
+
const isInGroup = computed(() => group !== undefined)
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Get a group or local property
|
|
18
17
|
*/
|
|
19
|
-
function getGroupOrLocalRef<
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
function getGroupOrLocalRef<
|
|
19
|
+
TProps extends object,
|
|
20
|
+
TName extends keyof GroupStateType,
|
|
21
|
+
>(
|
|
22
|
+
propName: TName,
|
|
23
|
+
props: TProps,
|
|
22
24
|
emit?: (event: string, ...args: unknown[]) => void,
|
|
23
25
|
) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
const groupPropValue = group?.[propName] as Ref | undefined
|
|
27
|
+
if (groupPropValue) {
|
|
26
28
|
return computed({
|
|
27
29
|
get() {
|
|
28
|
-
return groupPropValue
|
|
30
|
+
return groupPropValue.value
|
|
29
31
|
},
|
|
30
32
|
set(value: unknown) {
|
|
31
33
|
groupPropValue.value = value
|
|
32
34
|
},
|
|
33
|
-
})
|
|
35
|
+
}) as GroupStateType[TName]
|
|
34
36
|
}
|
|
35
|
-
const propRef = toRef(props, propName as keyof
|
|
37
|
+
const propRef = toRef(props, propName as unknown as keyof TProps)
|
|
36
38
|
return computed({
|
|
37
39
|
get() {
|
|
38
40
|
return propRef.value
|
|
39
41
|
},
|
|
40
42
|
set(value: unknown) {
|
|
41
|
-
if (emit)
|
|
43
|
+
if (emit) {
|
|
44
|
+
emit(`update:${propName as string}`, value)
|
|
45
|
+
}
|
|
42
46
|
},
|
|
43
|
-
})
|
|
47
|
+
}) as GroupStateType[TName]
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
return {
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Ref, InjectionKey } from 'vue'
|
|
2
|
+
import type { Emitter } from 'mitt'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Share part of the state of the component with all its children.
|
|
5
|
-
* @param {IGroupState} groupState the group state with all group options
|
|
6
6
|
*/
|
|
7
|
-
export function useProvideGroupState<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
throw Error("One or more groupState props aren't ref.")
|
|
16
|
-
provide(
|
|
17
|
-
groupState.key,
|
|
18
|
-
computed(() => groupState),
|
|
19
|
-
)
|
|
7
|
+
export function useProvideGroupState<
|
|
8
|
+
TGroupState extends Record<
|
|
9
|
+
string,
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
Ref<unknown> | Emitter<any>
|
|
12
|
+
>,
|
|
13
|
+
>(key: InjectionKey<TGroupState>, groupState: TGroupState) {
|
|
14
|
+
provide(key, groupState)
|
|
20
15
|
}
|
package/src/composables/index.ts
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { wrap } from 'comlink'
|
|
2
|
+
import pica from 'pica'
|
|
3
|
+
import type { BlurhashWorkerType } from '@/types/blurhash'
|
|
4
|
+
import BlurhashWorker from '@/workers/blurhash?worker&inline'
|
|
5
|
+
|
|
6
|
+
const remoteFunction = wrap<BlurhashWorkerType>(new BlurhashWorker())
|
|
7
|
+
|
|
8
|
+
function loadImage(src: string): Promise<CanvasImageSource> {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const img = new Image()
|
|
11
|
+
img.onload = () => resolve(img)
|
|
12
|
+
img.onerror = (...args) => reject(args)
|
|
13
|
+
img.src = src
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getWidthHeightFromMaxSize = (
|
|
18
|
+
width: number,
|
|
19
|
+
height: number,
|
|
20
|
+
maxSize: number,
|
|
21
|
+
) => {
|
|
22
|
+
if (width > height) {
|
|
23
|
+
return {
|
|
24
|
+
width: maxSize,
|
|
25
|
+
height: Math.round(maxSize * (height / width)),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
width: Math.round(maxSize * (width / height)),
|
|
30
|
+
height: maxSize,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const resizeImage = async (
|
|
35
|
+
image: ImageBitmap | HTMLImageElement | HTMLCanvasElement | File | Blob,
|
|
36
|
+
width: number,
|
|
37
|
+
height: number,
|
|
38
|
+
) => {
|
|
39
|
+
const resizer = new pica()
|
|
40
|
+
const canvas = document.createElement('canvas')
|
|
41
|
+
canvas.width = width
|
|
42
|
+
canvas.height = height
|
|
43
|
+
const result = await resizer.resize(image, canvas)
|
|
44
|
+
return result.getContext('2d')?.getImageData(0, 0, width, height).data
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const useBlurhash = () => {
|
|
48
|
+
async function encode(file: File) {
|
|
49
|
+
const imageUrl = URL.createObjectURL(file)
|
|
50
|
+
const image = await loadImage(imageUrl)
|
|
51
|
+
if ('width' in image && 'height' in image) {
|
|
52
|
+
const { width: newWidth, height: newHeight } =
|
|
53
|
+
getWidthHeightFromMaxSize(
|
|
54
|
+
image.width as number,
|
|
55
|
+
image.height as number,
|
|
56
|
+
32,
|
|
57
|
+
)
|
|
58
|
+
const imageData = await resizeImage(
|
|
59
|
+
image as ImageBitmap,
|
|
60
|
+
newWidth,
|
|
61
|
+
newHeight,
|
|
62
|
+
)
|
|
63
|
+
if (imageData) {
|
|
64
|
+
return remoteFunction.encode(
|
|
65
|
+
imageData,
|
|
66
|
+
newWidth,
|
|
67
|
+
newHeight,
|
|
68
|
+
4,
|
|
69
|
+
4,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { encode, decode: remoteFunction.decode, loadImage }
|
|
76
|
+
}
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
|
+
import type { VvIconProps } from '../components/VvIcon'
|
|
2
3
|
import { Position, Side } from '../constants'
|
|
3
4
|
|
|
4
5
|
export function useComponentIcon(
|
|
5
|
-
icon
|
|
6
|
-
iconPosition
|
|
6
|
+
icon?: Ref<string | VvIconProps | undefined>,
|
|
7
|
+
iconPosition?: Ref<string | undefined>,
|
|
7
8
|
) {
|
|
9
|
+
const hasIcon = computed(() => {
|
|
10
|
+
if (typeof icon?.value === 'string') {
|
|
11
|
+
return { name: icon?.value }
|
|
12
|
+
}
|
|
13
|
+
return icon?.value
|
|
14
|
+
})
|
|
8
15
|
const hasIconBefore = computed(() =>
|
|
9
|
-
|
|
16
|
+
iconPosition?.value === Position.before ? hasIcon.value : undefined,
|
|
10
17
|
)
|
|
11
18
|
const hasIconAfter = computed(() =>
|
|
12
|
-
|
|
19
|
+
iconPosition?.value === Position.after ? hasIcon.value : undefined,
|
|
13
20
|
)
|
|
14
21
|
const hasIconLeft = computed(() =>
|
|
15
|
-
|
|
22
|
+
iconPosition?.value === Side.left ? hasIcon.value : undefined,
|
|
16
23
|
)
|
|
17
24
|
const hasIconRight = computed(() =>
|
|
18
|
-
|
|
25
|
+
iconPosition?.value === Side.right ? hasIcon.value : undefined,
|
|
19
26
|
)
|
|
20
27
|
const hasIconTop = computed(() =>
|
|
21
|
-
|
|
28
|
+
iconPosition?.value === Side.top ? hasIcon.value : undefined,
|
|
22
29
|
)
|
|
23
30
|
const hasIconBottom = computed(() =>
|
|
24
|
-
|
|
31
|
+
iconPosition?.value === Side.bottom ? hasIcon.value : undefined,
|
|
25
32
|
)
|
|
26
|
-
const hasIcon = computed(() => {
|
|
27
|
-
if (typeof icon?.value === 'string') {
|
|
28
|
-
return { name: icon?.value }
|
|
29
|
-
}
|
|
30
|
-
return icon?.value
|
|
31
|
-
})
|
|
32
33
|
return {
|
|
33
34
|
hasIcon,
|
|
34
35
|
hasIconLeft,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { StorageType } from '@/constants'
|
|
2
|
+
|
|
3
|
+
export const usePersistence = <T>(
|
|
4
|
+
storageKey: Ref<string | undefined> | undefined,
|
|
5
|
+
storageType: Ref<`${StorageType}`> | `${StorageType}` = StorageType.local,
|
|
6
|
+
defaultValue?: T,
|
|
7
|
+
) => {
|
|
8
|
+
const localValue: Ref<T | undefined> = ref()
|
|
9
|
+
if (defaultValue) {
|
|
10
|
+
localValue.value = defaultValue
|
|
11
|
+
}
|
|
12
|
+
let storageValue: Ref<T | undefined> | undefined
|
|
13
|
+
if (storageKey) {
|
|
14
|
+
watch(
|
|
15
|
+
storageKey,
|
|
16
|
+
(newKey, oldKey) => {
|
|
17
|
+
const storage =
|
|
18
|
+
unref(storageType) === StorageType.session
|
|
19
|
+
? sessionStorage
|
|
20
|
+
: localStorage
|
|
21
|
+
if (oldKey && oldKey !== newKey) {
|
|
22
|
+
storage.removeItem(oldKey)
|
|
23
|
+
}
|
|
24
|
+
if (newKey) {
|
|
25
|
+
storageValue = useStorage(
|
|
26
|
+
newKey,
|
|
27
|
+
storageValue?.value ?? localValue.value,
|
|
28
|
+
storage,
|
|
29
|
+
)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
storageValue = undefined
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
immediate: true,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
if (isRef(storageType)) {
|
|
40
|
+
watch(storageType, (newType, oldType) => {
|
|
41
|
+
if (storageKey?.value) {
|
|
42
|
+
if (newType) {
|
|
43
|
+
const storage =
|
|
44
|
+
newType === StorageType.session
|
|
45
|
+
? sessionStorage
|
|
46
|
+
: localStorage
|
|
47
|
+
storageValue = useStorage(
|
|
48
|
+
storageKey.value,
|
|
49
|
+
storageValue?.value ?? localValue.value,
|
|
50
|
+
storage,
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
if (oldType && oldType !== newType) {
|
|
54
|
+
const oldStorage =
|
|
55
|
+
oldType === StorageType.session
|
|
56
|
+
? sessionStorage
|
|
57
|
+
: localStorage
|
|
58
|
+
oldStorage.removeItem(storageKey.value)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return computed<T | undefined>({
|
|
65
|
+
get: () => {
|
|
66
|
+
return storageValue?.value ?? localValue.value
|
|
67
|
+
},
|
|
68
|
+
set: (value) => {
|
|
69
|
+
if (storageValue) {
|
|
70
|
+
storageValue.value = value
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
localValue.value = value
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
}
|
package/src/constants.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import type { InjectionKey, Ref } from 'vue'
|
|
2
2
|
import type { Emitter } from 'mitt'
|
|
3
3
|
import type { Volver } from './Volver'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
AccordionGroupState,
|
|
6
|
+
InputGroupState,
|
|
7
|
+
ButtonGroupState,
|
|
8
|
+
AlertGroupState,
|
|
9
|
+
AlertModifier,
|
|
10
|
+
} from './types'
|
|
5
11
|
|
|
6
12
|
export const DEFAULT_ICONIFY_PROVIDER = 'vv'
|
|
7
13
|
|
|
14
|
+
export enum StorageType {
|
|
15
|
+
local = 'local',
|
|
16
|
+
session = 'session',
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
export enum Strategy {
|
|
9
20
|
absolute = 'absolute',
|
|
10
21
|
fixed = 'fixed',
|
|
@@ -62,26 +73,30 @@ export enum DropdownItemRole {
|
|
|
62
73
|
presentation = 'presentation',
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
export enum
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_parent = '_parent',
|
|
69
|
-
_top = '_top',
|
|
76
|
+
export enum AlertRole {
|
|
77
|
+
alert = 'alert',
|
|
78
|
+
alertdialog = 'alertdialog',
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
// volver
|
|
73
82
|
export const INJECTION_KEY_VOLVER = Symbol.for('volver') as InjectionKey<Volver>
|
|
74
83
|
|
|
75
84
|
// groups
|
|
76
|
-
export const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export const
|
|
85
|
+
export const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
86
|
+
'buttonGroup',
|
|
87
|
+
) as InjectionKey<ButtonGroupState>
|
|
88
|
+
export const INJECTION_KEY_RADIO_GROUP = Symbol.for(
|
|
89
|
+
'radioGroup',
|
|
90
|
+
) as InjectionKey<InputGroupState>
|
|
91
|
+
export const INJECTION_KEY_CHECK_GROUP = Symbol.for(
|
|
92
|
+
'checkGroup',
|
|
93
|
+
) as InjectionKey<InputGroupState>
|
|
94
|
+
export const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
|
|
95
|
+
'accordionGroup',
|
|
96
|
+
) as InjectionKey<AccordionGroupState>
|
|
80
97
|
|
|
81
98
|
// dropdown
|
|
82
|
-
export
|
|
83
|
-
'dropdownTrigger',
|
|
84
|
-
) as InjectionKey<{
|
|
99
|
+
export type DropdownTriggerState = {
|
|
85
100
|
id?: Ref<string | number>
|
|
86
101
|
reference?: Ref<HTMLElement | null>
|
|
87
102
|
bus?: Emitter<{
|
|
@@ -95,27 +110,33 @@ export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
|
95
110
|
'aria-haspopup': boolean
|
|
96
111
|
'aria-expanded': boolean
|
|
97
112
|
}>
|
|
98
|
-
}
|
|
113
|
+
}
|
|
114
|
+
export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
115
|
+
'dropdownTrigger',
|
|
116
|
+
) as InjectionKey<DropdownTriggerState>
|
|
117
|
+
|
|
118
|
+
export type DropdownItemState = {
|
|
119
|
+
role?: Ref<`${DropdownItemRole}`>
|
|
120
|
+
expanded?: Ref<boolean>
|
|
121
|
+
focused?: Ref<boolean>
|
|
122
|
+
hovered?: Ref<boolean>
|
|
123
|
+
}
|
|
99
124
|
export const INJECTION_KEY_DROPDOWN_ITEM = Symbol.for(
|
|
100
125
|
'dropdownItem',
|
|
101
|
-
) as InjectionKey<
|
|
102
|
-
|
|
126
|
+
) as InjectionKey<DropdownItemState>
|
|
127
|
+
|
|
128
|
+
export type DropdownActionState = {
|
|
129
|
+
role?: Ref<`${ActionRoles}`>
|
|
103
130
|
expanded?: Ref<boolean>
|
|
104
|
-
}
|
|
131
|
+
}
|
|
105
132
|
export const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
|
|
106
133
|
'dropdownAction',
|
|
107
|
-
) as InjectionKey<
|
|
108
|
-
role?: Ref<`${ActionRoles}`>
|
|
109
|
-
expanded?: Ref<boolean>
|
|
110
|
-
}>
|
|
134
|
+
) as InjectionKey<DropdownActionState>
|
|
111
135
|
|
|
112
136
|
// alert
|
|
113
137
|
export const INJECTION_KEY_ALERT_GROUP = Symbol.for(
|
|
114
138
|
'alertGroup',
|
|
115
|
-
) as InjectionKey<
|
|
116
|
-
name?: Ref<string | undefined>
|
|
117
|
-
bus?: Emitter<{ close: string }>
|
|
118
|
-
}>
|
|
139
|
+
) as InjectionKey<AlertGroupState>
|
|
119
140
|
export const DEFAULT_ALERT_AUTO_CLOSE = 10000
|
|
120
141
|
export const DEFAULT_ALERT_MODIFIERS = 'info'
|
|
121
142
|
export const DEFAULT_ALERT_DISMISSABLE = true
|
|
@@ -124,15 +145,9 @@ export const DEFAULT_ALERT_INFO_ICON = 'information'
|
|
|
124
145
|
export const DEFAULT_ALERT_SUCCESS_ICON = 'check-circle'
|
|
125
146
|
export const DEFAULT_ALERT_WARNING_ICON = 'warning'
|
|
126
147
|
export const DEFAULT_ALERT_DANGER_ICON = 'error'
|
|
127
|
-
export const DefaultAlertIconMap = new Map<
|
|
148
|
+
export const DefaultAlertIconMap = new Map<AlertModifier, string>([
|
|
128
149
|
['success', DEFAULT_ALERT_SUCCESS_ICON],
|
|
129
150
|
['info', DEFAULT_ALERT_INFO_ICON],
|
|
130
151
|
['warning', DEFAULT_ALERT_WARNING_ICON],
|
|
131
152
|
['danger', DEFAULT_ALERT_DANGER_ICON],
|
|
132
153
|
])
|
|
133
|
-
// {
|
|
134
|
-
// success: DEFAULT_ALERT_SUCCESS_ICON,
|
|
135
|
-
// info: DEFAULT_ALERT_INFO_ICON,
|
|
136
|
-
// warning: DEFAULT_ALERT_WARNING_ICON,
|
|
137
|
-
// danger: DEFAULT_ALERT_DANGER_ICON,
|
|
138
|
-
// }
|
package/src/directives/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import vTooltip from '../directives/v-tooltip'
|
|
2
|
+
import vContextmenu from '../directives/v-contextmenu'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
tooltip,
|
|
6
|
-
contextmenu,
|
|
7
|
-
}
|
|
4
|
+
export { vTooltip, vContextmenu }
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { render, type Directive, type DirectiveBinding } from 'vue'
|
|
2
2
|
import VvTooltip from '../components/VvTooltip/VvTooltip.vue'
|
|
3
|
-
import
|
|
3
|
+
import { Side } from '../constants'
|
|
4
4
|
|
|
5
|
-
const tooltip: Directive = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
const tooltip: Directive = (() => {
|
|
6
|
+
return {
|
|
7
|
+
beforeMount(el: HTMLElement, binding: DirectiveBinding) {
|
|
8
|
+
const tooltip = h(VvTooltip, {
|
|
9
|
+
value: binding.value,
|
|
10
|
+
position: binding.arg as Side,
|
|
11
|
+
})
|
|
12
|
+
render(tooltip, el)
|
|
13
|
+
},
|
|
14
|
+
updated(el: HTMLElement, binding: DirectiveBinding) {
|
|
15
|
+
const tooltip = h(VvTooltip, {
|
|
16
|
+
value: binding.value,
|
|
17
|
+
position: binding.arg as Side,
|
|
18
|
+
})
|
|
19
|
+
render(tooltip, el)
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
})()
|
|
14
23
|
|
|
15
24
|
export default tooltip
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import VolverPlugin from './Volver'
|
|
2
|
-
import type { Volver } from './Volver'
|
|
2
|
+
import type { Volver, VolverOptions } from './Volver'
|
|
3
3
|
|
|
4
4
|
export { VolverPlugin }
|
|
5
|
+
export * from './types'
|
|
6
|
+
export type { Volver, VolverOptions }
|
|
5
7
|
|
|
6
8
|
// https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
|
|
7
9
|
// Add custom property and extend vue type definition
|