@volverjs/ui-vue 0.0.4 → 0.0.5-beta.2
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 +2 -2
- package/auto-imports.d.ts +12 -3
- package/bin/icons.cjs +1 -73
- package/dist/Volver.d.ts +19 -11
- package/dist/components/VvAccordion/VvAccordion.es.js +165 -106
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +4 -1
- package/dist/components/VvAccordion/index.d.ts +8 -3
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +264 -164
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +15 -12
- package/dist/components/VvAccordionGroup/index.d.ts +8 -0
- package/dist/components/VvAction/VvAction.es.js +276 -98
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +12 -12
- package/dist/components/VvAction/index.d.ts +2 -2
- package/dist/components/VvBadge/VvBadge.es.js +213 -44
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
- package/dist/components/VvBadge/index.d.ts +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +247 -75
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +11 -11
- package/dist/components/VvBreadcrumb/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +646 -360
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +18 -18
- package/dist/components/VvButton/index.d.ts +13 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +261 -79
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
- package/dist/components/VvButtonGroup/index.d.ts +1 -1
- package/dist/components/VvCard/VvCard.es.js +57 -38
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +562 -274
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +2 -2
- package/dist/components/VvCheckbox/index.d.ts +5 -5
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +661 -340
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +7 -7
- package/dist/components/VvCheckboxGroup/index.d.ts +3 -3
- package/dist/components/VvCombobox/VvCombobox.es.js +1546 -983
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +138 -51
- package/dist/components/VvCombobox/index.d.ts +41 -10
- package/dist/components/VvDialog/VvDialog.es.js +387 -141
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDialog/VvDialog.vue.d.ts +12 -3
- package/dist/components/VvDialog/index.d.ts +4 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +452 -244
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +130 -42
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +13 -13
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -2
- package/dist/components/VvDropdown/index.d.ts +40 -11
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +373 -160
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +43 -28
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +285 -90
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +113 -65
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +7 -7
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputPasswordAction.d.ts +2 -2
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +986 -462
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +100 -20
- package/dist/components/VvInputText/VvInputTextActions.d.ts +1 -1
- package/dist/components/VvInputText/index.d.ts +66 -13
- package/dist/components/VvProgress/VvProgress.es.js +216 -45
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
- package/dist/components/VvProgress/index.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +499 -238
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +2 -2
- package/dist/components/VvRadio/index.d.ts +5 -5
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +598 -304
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +7 -7
- package/dist/components/VvRadioGroup/index.d.ts +3 -3
- package/dist/components/VvSelect/VvSelect.es.js +631 -324
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +13 -13
- package/dist/components/VvSelect/index.d.ts +3 -3
- package/dist/components/VvTextarea/VvTextarea.es.js +676 -355
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +20 -20
- package/dist/components/VvTextarea/index.d.ts +4 -4
- package/dist/components/VvTooltip/VvTooltip.es.js +215 -47
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +7 -7
- package/dist/components/VvTooltip/index.d.ts +2 -2
- package/dist/components/index.es.js +3522 -2231
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/dropdown/useInjectDropdown.d.ts +1 -1
- package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -3
- package/dist/composables/group/useInjectedGroupState.d.ts +2 -2
- package/dist/composables/group/useProvideGroupState.d.ts +1 -1
- package/dist/composables/useComponentFocus.d.ts +1 -1
- package/dist/composables/useComponentIcon.d.ts +7 -7
- package/dist/composables/useDebouncedInput.d.ts +4 -1
- package/dist/composables/useDefaults.d.ts +2 -0
- package/dist/composables/useModifiers.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/composables/useTextCount.d.ts +3 -3
- package/dist/composables/useUniqueId.d.ts +1 -1
- package/dist/composables/useVolver.d.ts +1 -1
- package/dist/directives/index.d.ts +1 -0
- package/dist/directives/index.es.js +264 -55
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-contextmenu.d.ts +3 -0
- package/dist/directives/v-contextmenu.es.js +42 -0
- package/dist/directives/v-contextmenu.umd.js +1 -0
- package/dist/directives/v-tooltip.es.js +222 -53
- package/dist/directives/v-tooltip.umd.js +1 -1
- package/dist/icons.d.ts +3 -1
- package/dist/icons.es.js +40 -23
- package/dist/icons.umd.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.es.js +112 -3607
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +50 -18
- package/dist/resolvers/unplugin.d.ts +7 -1
- package/dist/resolvers/unplugin.es.js +77 -37
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/Combobox/Combobox.settings.d.ts +12 -0
- package/dist/stories/Dropdown/Dropdown.settings.d.ts +12 -0
- package/dist/stories/InputText/InputText.settings.d.ts +53 -0
- package/dist/stories/argTypes.d.ts +13 -1
- package/package.json +126 -40
- package/src/Volver.ts +49 -22
- 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 +19 -22
- package/src/components/VvAccordion/index.ts +12 -4
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +19 -10
- package/src/components/VvAccordionGroup/index.ts +8 -0
- package/src/components/VvAction/VvAction.vue +7 -7
- package/src/components/VvAction/index.ts +1 -1
- package/src/components/VvBadge/VvBadge.vue +2 -2
- package/src/components/VvBadge/index.ts +1 -1
- package/src/components/VvBreadcrumb/VvBreadcrumb.vue +3 -3
- package/src/components/VvButton/VvButton.vue +11 -11
- package/src/components/VvButton/index.ts +10 -9
- package/src/components/VvButtonGroup/VvButtonGroup.vue +4 -7
- package/src/components/VvButtonGroup/index.ts +1 -1
- package/src/components/VvCard/VvCard.vue +2 -2
- package/src/components/VvCheckbox/VvCheckbox.vue +3 -7
- package/src/components/VvCheckbox/index.ts +11 -7
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +7 -10
- package/src/components/VvCheckboxGroup/index.ts +1 -1
- package/src/components/VvCombobox/VvCombobox.vue +44 -26
- package/src/components/VvCombobox/index.ts +1 -1
- package/src/components/VvDialog/VvDialog.vue +28 -11
- package/src/components/VvDialog/index.ts +5 -2
- package/src/components/VvDropdown/VvDropdown.vue +7 -5
- package/src/components/VvDropdown/VvDropdownAction.vue +7 -5
- package/src/components/VvDropdown/VvDropdownOption.vue +17 -10
- package/src/components/VvDropdown/index.ts +3 -3
- package/src/components/VvIcon/VvIcon.vue +3 -3
- package/src/components/VvIcon/index.ts +3 -3
- package/src/components/VvInputText/VvInputClearAction.ts +2 -2
- package/src/components/VvInputText/VvInputPasswordAction.ts +3 -4
- package/src/components/VvInputText/VvInputStepAction.ts +3 -2
- package/src/components/VvInputText/VvInputText.vue +130 -37
- package/src/components/VvInputText/VvInputTextActions.ts +5 -8
- package/src/components/VvInputText/index.ts +62 -1
- package/src/components/VvProgress/VvProgress.vue +2 -2
- package/src/components/VvProgress/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +3 -7
- package/src/components/VvRadio/index.ts +11 -7
- package/src/components/VvRadioGroup/VvRadioGroup.vue +7 -10
- package/src/components/VvRadioGroup/index.ts +1 -1
- package/src/components/VvSelect/VvSelect.vue +4 -4
- package/src/components/VvSelect/index.ts +1 -1
- package/src/components/VvTextarea/VvTextarea.vue +6 -6
- package/src/components/VvTextarea/index.ts +1 -1
- package/src/components/VvTooltip/VvTooltip.vue +2 -2
- package/src/components/VvTooltip/index.ts +3 -3
- package/src/composables/dropdown/useInjectDropdown.ts +2 -2
- package/src/composables/dropdown/useProvideDropdown.ts +2 -2
- package/src/composables/group/useInjectedGroupState.ts +1 -1
- package/src/composables/group/useProvideGroupState.ts +1 -1
- package/src/composables/useComponentIcon.ts +1 -1
- package/src/composables/useDebouncedInput.ts +10 -3
- package/src/composables/useDefaults.ts +89 -0
- package/src/composables/useModifiers.ts +4 -2
- package/src/composables/useOptions.ts +1 -1
- package/src/composables/useVolver.ts +2 -2
- package/src/directives/index.ts +3 -1
- package/src/directives/v-contextmenu.ts +40 -0
- package/src/directives/v-tooltip.ts +2 -2
- package/src/icons.ts +1 -1
- package/src/index.ts +0 -2
- package/src/props/index.ts +20 -10
- package/src/resolvers/unplugin.ts +15 -1
- package/src/stories/Accordion/Accordion.stories.mdx +8 -2
- package/src/stories/Accordion/Accordion.test.ts +21 -15
- package/src/stories/Accordion/AccordionSlots.stories.mdx +8 -8
- package/src/stories/AccordionGroup/AccordionGroup.stories.mdx +17 -1
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +18 -12
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.mdx +1 -1
- package/src/stories/Dropdown/DropdownContextmenuDirective.stories.mdx +41 -0
- package/src/stories/InputText/InputText.settings.ts +53 -0
- package/src/stories/InputText/InputText.stories.mdx +40 -0
- package/src/stories/InputText/InputText.test.ts +5 -2
- package/src/stories/Tooltip/TooltipDirective.stories.mdx +1 -1
- package/src/stories/argTypes.ts +12 -2
- package/src/types/group.d.ts +5 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
type VueProp =
|
|
4
|
+
| StringConstructor
|
|
5
|
+
| NumberConstructor
|
|
6
|
+
| ObjectConstructor
|
|
7
|
+
| FunctionConstructor
|
|
8
|
+
| SymbolConstructor
|
|
9
|
+
| ArrayConstructor
|
|
10
|
+
| BooleanConstructor
|
|
11
|
+
| PropType<unknown>
|
|
12
|
+
|
|
13
|
+
export function useDefaults<Definition>(
|
|
14
|
+
componentName: string,
|
|
15
|
+
propsDefinition: Definition,
|
|
16
|
+
props: Readonly<ExtractPropTypes<Definition>>,
|
|
17
|
+
) {
|
|
18
|
+
const volver = useVolver()
|
|
19
|
+
|
|
20
|
+
const volverComponentDefaults = computed(() => {
|
|
21
|
+
if (!volver || !volver.defaults.value?.[componentName]) {
|
|
22
|
+
return undefined
|
|
23
|
+
}
|
|
24
|
+
return volver.defaults.value[componentName]
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
return computed(() => {
|
|
28
|
+
if (volverComponentDefaults.value === undefined) {
|
|
29
|
+
return props
|
|
30
|
+
}
|
|
31
|
+
const componentDefaults = volverComponentDefaults.value
|
|
32
|
+
const simplifiedPropsDefinition = propsDefinition as {
|
|
33
|
+
[key: string]:
|
|
34
|
+
| VueProp
|
|
35
|
+
| VueProp[]
|
|
36
|
+
| { type: VueProp | VueProp[]; default?: unknown }
|
|
37
|
+
}
|
|
38
|
+
const simplifiedProps = props as Record<string, unknown>
|
|
39
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
40
|
+
const propValue = simplifiedProps[key]
|
|
41
|
+
acc[key] = propValue
|
|
42
|
+
if (key in componentDefaults) {
|
|
43
|
+
// array of types
|
|
44
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
45
|
+
const typeArray = simplifiedPropsDefinition[
|
|
46
|
+
key
|
|
47
|
+
] as VueProp[]
|
|
48
|
+
if (typeArray.length) {
|
|
49
|
+
const typeFunction = typeArray[0] as <T>() => T
|
|
50
|
+
if (typeFunction === propValue) {
|
|
51
|
+
acc[key] = componentDefaults[key]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// single type
|
|
56
|
+
if (typeof simplifiedPropsDefinition[key] === 'function') {
|
|
57
|
+
const typeFunction = simplifiedPropsDefinition[key] as <
|
|
58
|
+
T,
|
|
59
|
+
>() => T
|
|
60
|
+
if (typeFunction() === propValue) {
|
|
61
|
+
acc[key] = componentDefaults[key]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// object with type and default
|
|
65
|
+
if (typeof simplifiedPropsDefinition[key] === 'object') {
|
|
66
|
+
let defaultValue = (
|
|
67
|
+
simplifiedPropsDefinition[key] as { default: unknown }
|
|
68
|
+
).default
|
|
69
|
+
if (typeof defaultValue === 'function') {
|
|
70
|
+
defaultValue = defaultValue()
|
|
71
|
+
}
|
|
72
|
+
if (typeof defaultValue === 'object') {
|
|
73
|
+
if (
|
|
74
|
+
JSON.stringify(defaultValue) ===
|
|
75
|
+
JSON.stringify(propValue)
|
|
76
|
+
) {
|
|
77
|
+
acc[key] = componentDefaults[key]
|
|
78
|
+
}
|
|
79
|
+
} else if (defaultValue === propValue) {
|
|
80
|
+
acc[key] = componentDefaults[key]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return acc
|
|
85
|
+
}, {} as Record<string, unknown>) as Readonly<
|
|
86
|
+
ExtractPropTypes<Definition>
|
|
87
|
+
>
|
|
88
|
+
})
|
|
89
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
export function
|
|
3
|
+
export function useModifiers(
|
|
4
4
|
prefix: string,
|
|
5
5
|
modifiers?: Ref<string | string[] | unknown | unknown[] | undefined>,
|
|
6
6
|
others?: Ref<Record<string, boolean>>,
|
|
@@ -17,7 +17,9 @@ export function useBemModifiers(
|
|
|
17
17
|
if (modifiersArray) {
|
|
18
18
|
if (Array.isArray(modifiersArray)) {
|
|
19
19
|
modifiersArray.forEach((modifier) => {
|
|
20
|
-
|
|
20
|
+
if (modifier) {
|
|
21
|
+
toReturn[`${prefix}--${modifier}`] = true
|
|
22
|
+
}
|
|
21
23
|
})
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { INJECTION_KEY_VOLVER } from '
|
|
2
|
-
import type { VolverInterface } from '
|
|
1
|
+
import { INJECTION_KEY_VOLVER } from '../constants'
|
|
2
|
+
import type { VolverInterface } from '../Volver'
|
|
3
3
|
|
|
4
4
|
export function useVolver() {
|
|
5
5
|
return inject<VolverInterface>(INJECTION_KEY_VOLVER)
|
package/src/directives/index.ts
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Directive, DirectiveBinding } from 'vue'
|
|
2
|
+
|
|
3
|
+
const contextmenu: Directive = {
|
|
4
|
+
beforeUpdate(el: HTMLElement, binding: DirectiveBinding) {
|
|
5
|
+
const clientX = ref(0)
|
|
6
|
+
const clientY = ref(0)
|
|
7
|
+
const virtualEl = {
|
|
8
|
+
getBoundingClientRect() {
|
|
9
|
+
return {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0,
|
|
12
|
+
x: clientX.value,
|
|
13
|
+
y: clientY.value,
|
|
14
|
+
top: clientY.value,
|
|
15
|
+
left: clientX.value,
|
|
16
|
+
right: clientX.value,
|
|
17
|
+
bottom: clientY.value,
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
if (binding.value?.init) {
|
|
22
|
+
binding.value.init?.(virtualEl)
|
|
23
|
+
}
|
|
24
|
+
el.addEventListener(
|
|
25
|
+
'contextmenu',
|
|
26
|
+
function (ev) {
|
|
27
|
+
if (binding.value?.show) {
|
|
28
|
+
ev.preventDefault()
|
|
29
|
+
clientX.value = ev.clientX
|
|
30
|
+
clientY.value = ev.clientY
|
|
31
|
+
binding.value.show?.()
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
false,
|
|
36
|
+
)
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default contextmenu
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, type Directive, type DirectiveBinding } from 'vue'
|
|
2
|
-
import VvTooltip from '
|
|
3
|
-
import type { Side } from '
|
|
2
|
+
import VvTooltip from '../components/VvTooltip/VvTooltip.vue'
|
|
3
|
+
import type { Side } from '../constants'
|
|
4
4
|
|
|
5
5
|
const tooltip: Directive = {
|
|
6
6
|
beforeMount(el: HTMLElement, binding: DirectiveBinding) {
|
package/src/icons.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import VolverPlugin from './Volver'
|
|
2
2
|
import type { Volver } from './Volver'
|
|
3
3
|
|
|
4
|
-
// export all components as vue plugin
|
|
5
|
-
export * from './components/index'
|
|
6
4
|
export { VolverPlugin }
|
|
7
5
|
|
|
8
6
|
// https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
|
package/src/props/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { PropType } from 'vue'
|
|
2
|
-
import type { Option } from '
|
|
2
|
+
import type { Option } from '../types/generic'
|
|
3
3
|
import type {
|
|
4
4
|
AutoPlacementOptions,
|
|
5
5
|
FlipOptions,
|
|
6
6
|
OffsetOptions,
|
|
7
7
|
ShiftOptions,
|
|
8
8
|
SizeOptions,
|
|
9
|
-
} from '
|
|
9
|
+
} from '../types/floating-ui'
|
|
10
10
|
import {
|
|
11
11
|
Placement,
|
|
12
12
|
Position,
|
|
13
13
|
Side,
|
|
14
14
|
AnchorTarget,
|
|
15
15
|
ButtonType,
|
|
16
|
-
} from '
|
|
16
|
+
} from '../constants'
|
|
17
17
|
|
|
18
18
|
export const LinkProps = {
|
|
19
19
|
/**
|
|
@@ -31,7 +31,7 @@ export const LinkProps = {
|
|
|
31
31
|
* Anchor target
|
|
32
32
|
*/
|
|
33
33
|
target: {
|
|
34
|
-
type: String as PropType
|
|
34
|
+
type: String as PropType<`${AnchorTarget}`>,
|
|
35
35
|
validator: (value: AnchorTarget) =>
|
|
36
36
|
Object.values(AnchorTarget).includes(value),
|
|
37
37
|
},
|
|
@@ -184,7 +184,7 @@ export const IconProps = {
|
|
|
184
184
|
* VvIcon position
|
|
185
185
|
*/
|
|
186
186
|
iconPosition: {
|
|
187
|
-
type: String as PropType
|
|
187
|
+
type: String as PropType<`${Position}`>,
|
|
188
188
|
default: Position.before,
|
|
189
189
|
validation: (value: Position) =>
|
|
190
190
|
Object.values(Position).includes(value),
|
|
@@ -226,7 +226,7 @@ export const DropdownProps = {
|
|
|
226
226
|
* Dropdown placement
|
|
227
227
|
*/
|
|
228
228
|
placement: {
|
|
229
|
-
type: String as PropType
|
|
229
|
+
type: String as PropType<`${Side}` | `${Placement}`>,
|
|
230
230
|
default: Side.bottom,
|
|
231
231
|
validator: (value: Side & Placement) => {
|
|
232
232
|
return (
|
|
@@ -235,6 +235,16 @@ export const DropdownProps = {
|
|
|
235
235
|
)
|
|
236
236
|
},
|
|
237
237
|
},
|
|
238
|
+
/**
|
|
239
|
+
* Dropdown strategy
|
|
240
|
+
*/
|
|
241
|
+
strategy: {
|
|
242
|
+
type: String as PropType<'fixed' | 'absolute'>,
|
|
243
|
+
default: 'absolute',
|
|
244
|
+
validator: (value: 'fixed' | 'absolute') => {
|
|
245
|
+
return ['fixed', 'absolute'].includes(value)
|
|
246
|
+
},
|
|
247
|
+
},
|
|
238
248
|
/**
|
|
239
249
|
* Dropdown show / hide transition name
|
|
240
250
|
*/
|
|
@@ -362,14 +372,14 @@ export const InputTextareaProps = {
|
|
|
362
372
|
* Available for input types: text, search, url, tel, email, password
|
|
363
373
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
|
|
364
374
|
*/
|
|
365
|
-
minlength: Number,
|
|
375
|
+
minlength: [String, Number],
|
|
366
376
|
/**
|
|
367
377
|
* Input / Textarea maxlength
|
|
368
378
|
* Maximum length (number of characters) of value
|
|
369
379
|
* Available for input types: text, search, url, tel, email, password
|
|
370
380
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
|
|
371
381
|
*/
|
|
372
|
-
maxlength: Number,
|
|
382
|
+
maxlength: [String, Number],
|
|
373
383
|
/**
|
|
374
384
|
* Input / Textarea placeholder
|
|
375
385
|
* Text that appears in the form control when it has no value set
|
|
@@ -419,7 +429,7 @@ export const CheckboxRadioGroupProps = {
|
|
|
419
429
|
/**
|
|
420
430
|
* Input value
|
|
421
431
|
*/
|
|
422
|
-
modelValue: [String, Array],
|
|
432
|
+
modelValue: [String, Array, Boolean, Number, Symbol],
|
|
423
433
|
/**
|
|
424
434
|
* Input name
|
|
425
435
|
*/
|
|
@@ -440,7 +450,7 @@ export const ActionProps = {
|
|
|
440
450
|
* Button type
|
|
441
451
|
*/
|
|
442
452
|
type: {
|
|
443
|
-
type: String
|
|
453
|
+
type: String as PropType<`${ButtonType}`>,
|
|
444
454
|
default: ButtonType.button,
|
|
445
455
|
validator: (value: ButtonType) =>
|
|
446
456
|
Object.values(ButtonType).includes(value),
|
|
@@ -33,13 +33,18 @@ export interface VolverResolverOptions {
|
|
|
33
33
|
* @default 'vv'
|
|
34
34
|
*/
|
|
35
35
|
prefix?: string
|
|
36
|
+
/**
|
|
37
|
+
* ignore components (kebab-case)
|
|
38
|
+
* @default undefined
|
|
39
|
+
*/
|
|
40
|
+
ignore?: string[]
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
const STYLE_EXCLUDE = ['vv-icon', 'vv-action']
|
|
39
44
|
const VOLVER_PREFIX = 'vv'
|
|
40
45
|
const DIRECTIVES = ['v-tooltip']
|
|
41
46
|
|
|
42
|
-
const getStyleNames = function (kebabName: string) {
|
|
47
|
+
export const getStyleNames = function (kebabName: string) {
|
|
43
48
|
if (STYLE_EXCLUDE.includes(kebabName)) {
|
|
44
49
|
return undefined
|
|
45
50
|
}
|
|
@@ -100,6 +105,7 @@ export function VolverResolver({
|
|
|
100
105
|
prefix = VOLVER_PREFIX,
|
|
101
106
|
importStyle,
|
|
102
107
|
directives,
|
|
108
|
+
ignore,
|
|
103
109
|
}: VolverResolverOptions = {}): ComponentResolver[] {
|
|
104
110
|
return [
|
|
105
111
|
{
|
|
@@ -116,6 +122,10 @@ export function VolverResolver({
|
|
|
116
122
|
`${VOLVER_PREFIX}-`,
|
|
117
123
|
)
|
|
118
124
|
|
|
125
|
+
if (ignore && ignore.includes(kebabName)) {
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
119
129
|
// import component
|
|
120
130
|
return {
|
|
121
131
|
from: `@volverjs/ui-vue/${kebabName}`,
|
|
@@ -137,6 +147,10 @@ export function VolverResolver({
|
|
|
137
147
|
return
|
|
138
148
|
}
|
|
139
149
|
|
|
150
|
+
if (ignore && ignore.includes(kebabName)) {
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
|
|
140
154
|
// import directive
|
|
141
155
|
return {
|
|
142
156
|
from: `@volverjs/ui-vue/${kebabName}`,
|
|
@@ -24,10 +24,10 @@ export const Template = (args, { argTypes }) => ({
|
|
|
24
24
|
template: /*html*/ `
|
|
25
25
|
<vv-accordion data-testId="element" v-bind="args" v-model="open">
|
|
26
26
|
<template #summary v-if="args.summary"><div v-html="args.summary"></div></template>
|
|
27
|
-
<template #
|
|
27
|
+
<template #default v-if="args.default"><div v-html="args.default"></div></template>
|
|
28
28
|
</vv-accordion>
|
|
29
29
|
<div class="mt-24">
|
|
30
|
-
|
|
30
|
+
{{ args.not ? 'Closed' : 'Opened'}}: <span data-testId="value">{{ open }}</span>
|
|
31
31
|
</div>
|
|
32
32
|
`,
|
|
33
33
|
})
|
|
@@ -37,3 +37,9 @@ export const Template = (args, { argTypes }) => ({
|
|
|
37
37
|
{Template.bind()}
|
|
38
38
|
</Story>
|
|
39
39
|
</Canvas>
|
|
40
|
+
|
|
41
|
+
<Canvas>
|
|
42
|
+
<Story name="Not" play={defaultTest} args={{ not: true }}>
|
|
43
|
+
{Template.bind()}
|
|
44
|
+
</Story>
|
|
45
|
+
</Canvas>
|
|
@@ -9,7 +9,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
9
9
|
)) as HTMLDetailsElement
|
|
10
10
|
const summary = element.getElementsByTagName('summary')[0]
|
|
11
11
|
const content = element.getElementsByClassName(
|
|
12
|
-
'vv-
|
|
12
|
+
'vv-accordion__content',
|
|
13
13
|
)[0] as HTMLElement
|
|
14
14
|
|
|
15
15
|
const modifiers =
|
|
@@ -30,30 +30,36 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
30
30
|
if (args.summary) {
|
|
31
31
|
const div = document.createElement('div')
|
|
32
32
|
div.innerHTML = args.summary
|
|
33
|
-
expect(summary).toHaveClass('vv-
|
|
33
|
+
expect(summary).toHaveClass('vv-accordion__summary')
|
|
34
34
|
expect(summary.innerText).toEqual(div.innerText)
|
|
35
35
|
} else if (args.title) {
|
|
36
|
-
expect(summary).toHaveClass('vv-
|
|
36
|
+
expect(summary).toHaveClass('vv-accordion__summary')
|
|
37
37
|
expect(summary.innerText).toEqual(args.title)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// open
|
|
41
41
|
if (!args.disabled) {
|
|
42
|
-
expect(element.open).toBe(false)
|
|
43
|
-
expect(
|
|
42
|
+
expect(element.open).toBe(args.not ? true : false)
|
|
43
|
+
expect(summary).toBeClicked()
|
|
44
44
|
await sleep()
|
|
45
|
-
expect(element.open).
|
|
46
|
-
expect(summary.getAttribute('aria-expanded')).toBe(
|
|
47
|
-
|
|
45
|
+
expect(element.open).toBe(args.not ? false : true)
|
|
46
|
+
expect(summary.getAttribute('aria-expanded')).toBe(
|
|
47
|
+
args.not ? 'false' : 'true',
|
|
48
|
+
)
|
|
49
|
+
expect(content.getAttribute('aria-hidden')).toBe(
|
|
50
|
+
args.not ? 'true' : 'false',
|
|
51
|
+
)
|
|
48
52
|
}
|
|
49
53
|
|
|
50
|
-
//
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
// default slot / content
|
|
55
|
+
if (element.open) {
|
|
56
|
+
if (args.default) {
|
|
57
|
+
const div = document.createElement('div')
|
|
58
|
+
div.innerHTML = args.default
|
|
59
|
+
expect(content.innerText).toEqual(div.innerText)
|
|
60
|
+
} else if (args.content) {
|
|
61
|
+
expect(content.innerText).toEqual(args.content)
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
// accessibility
|
|
@@ -11,18 +11,18 @@ import { defaultArgs, argTypes } from './Accordion.settings'
|
|
|
11
11
|
|
|
12
12
|
<Canvas>
|
|
13
13
|
<Story
|
|
14
|
-
name="
|
|
14
|
+
name="Default"
|
|
15
15
|
play={defaultTest}
|
|
16
16
|
args={{
|
|
17
|
-
|
|
17
|
+
default: `<strong data-testId="slot" class="font-bold text-brand-darken-1">Custom Details</strong>`,
|
|
18
18
|
}}
|
|
19
19
|
argTypes={{
|
|
20
|
-
|
|
20
|
+
content: {
|
|
21
21
|
control: {
|
|
22
22
|
disable: true,
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
|
|
25
|
+
summary: {
|
|
26
26
|
control: {
|
|
27
27
|
disable: true,
|
|
28
28
|
},
|
|
@@ -35,18 +35,18 @@ import { defaultArgs, argTypes } from './Accordion.settings'
|
|
|
35
35
|
|
|
36
36
|
<Canvas>
|
|
37
37
|
<Story
|
|
38
|
-
name="
|
|
38
|
+
name="Summary"
|
|
39
39
|
play={defaultTest}
|
|
40
40
|
args={{
|
|
41
|
-
|
|
41
|
+
summary: `<strong data-testId="slot" class="font-bold text-brand-darken-1">Custom Summary</strong>`,
|
|
42
42
|
}}
|
|
43
43
|
argTypes={{
|
|
44
|
-
|
|
44
|
+
title: {
|
|
45
45
|
control: {
|
|
46
46
|
disable: true,
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
|
-
|
|
49
|
+
details: {
|
|
50
50
|
control: {
|
|
51
51
|
disable: true,
|
|
52
52
|
},
|
|
@@ -24,7 +24,7 @@ export const Template = (args, { argTypes }) => ({
|
|
|
24
24
|
template: /*html*/ `
|
|
25
25
|
<vv-accordion-group data-testId="element" v-bind="args" v-model="selected" />
|
|
26
26
|
<div class="mt-24">
|
|
27
|
-
|
|
27
|
+
{{ args.not ? 'Closed' : 'Opened'}}: <span data-testId="value">{{ selected }}</span>
|
|
28
28
|
</div>
|
|
29
29
|
`,
|
|
30
30
|
})
|
|
@@ -35,8 +35,24 @@ export const Template = (args, { argTypes }) => ({
|
|
|
35
35
|
</Story>
|
|
36
36
|
</Canvas>
|
|
37
37
|
|
|
38
|
+
<Canvas>
|
|
39
|
+
<Story name="Not" play={defaultTest} args={{ not: true }}>
|
|
40
|
+
{Template.bind()}
|
|
41
|
+
</Story>
|
|
42
|
+
</Canvas>
|
|
43
|
+
|
|
38
44
|
<Canvas>
|
|
39
45
|
<Story name="Collapse" play={defaultTest} args={{ collapse: true }}>
|
|
40
46
|
{Template.bind()}
|
|
41
47
|
</Story>
|
|
42
48
|
</Canvas>
|
|
49
|
+
|
|
50
|
+
<Canvas>
|
|
51
|
+
<Story
|
|
52
|
+
name="Collapse Not"
|
|
53
|
+
play={defaultTest}
|
|
54
|
+
args={{ collapse: true, not: true }}
|
|
55
|
+
>
|
|
56
|
+
{Template.bind()}
|
|
57
|
+
</Story>
|
|
58
|
+
</Canvas>
|
|
@@ -8,6 +8,7 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
8
8
|
'element',
|
|
9
9
|
)) as HTMLElement
|
|
10
10
|
const firstChild = element.children[0] as HTMLDetailsElement
|
|
11
|
+
const firstChildSummary = firstChild.getElementsByTagName('summary')[0]
|
|
11
12
|
const value = (await within(canvasElement).findByTestId(
|
|
12
13
|
'value',
|
|
13
14
|
)) as HTMLElement
|
|
@@ -28,21 +29,26 @@ export async function defaultTest({ canvasElement, args }: PlayAttributes) {
|
|
|
28
29
|
|
|
29
30
|
// open
|
|
30
31
|
if (!args.disabled && args.items && args.items.length > 0) {
|
|
31
|
-
expect(firstChild.open).toBe(false)
|
|
32
|
-
expect(
|
|
32
|
+
expect(firstChild.open).toBe(args.not ? true : false)
|
|
33
|
+
expect(firstChildSummary).toBeClicked()
|
|
33
34
|
await sleep()
|
|
34
|
-
expect(firstChild.open).
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
JSON.stringify(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
expect(firstChild.open).toBe(args.not ? false : true)
|
|
36
|
+
if (firstChild.open) {
|
|
37
|
+
if (args.collapse) {
|
|
38
|
+
expect(JSON.stringify(JSON.parse(value.innerText))).toBe(
|
|
39
|
+
JSON.stringify([args.items[0].name]),
|
|
40
|
+
)
|
|
41
|
+
} else {
|
|
42
|
+
expect(value.innerText).toBe(args.items[0].name)
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
expect(firstChildSummary.getAttribute('aria-expanded')).toBe(
|
|
46
|
+
args.not ? 'false' : 'true',
|
|
47
|
+
)
|
|
43
48
|
const content = firstChild.lastChild as HTMLElement
|
|
44
|
-
expect(
|
|
45
|
-
|
|
49
|
+
expect(content.getAttribute('aria-hidden')).toBe(
|
|
50
|
+
args.not ? 'true' : 'false',
|
|
51
|
+
)
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
// accessibility
|
|
@@ -50,7 +50,7 @@ import { defaultArgs, argTypes } from './AccordionGroup.settings'
|
|
|
50
50
|
<vv-accordion name="a-3" title="Details 3" :content="content" />
|
|
51
51
|
</vv-accordion-group>
|
|
52
52
|
<div class="mt-24" >
|
|
53
|
-
|
|
53
|
+
Opened: <span data-testId="value">{{ selected }}</span>
|
|
54
54
|
</div>
|
|
55
55
|
`,
|
|
56
56
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import { Meta, Story, Canvas } from '@storybook/addon-docs'
|
|
3
|
+
import { defaultArgs, argTypes } from './Dropdown.settings'
|
|
4
|
+
import VvDropdown from '@/components/VvDropdown/VvDropdown.vue'
|
|
5
|
+
import VvDropdownAction from '@/components/VvDropdown/VvDropdownAction.vue'
|
|
6
|
+
import VvIcon from '@/components/VvIcon/VvIcon.vue'
|
|
7
|
+
|
|
8
|
+
<Meta title="Directives/Contextmenu" args={defaultArgs} argTypes={argTypes} />
|
|
9
|
+
|
|
10
|
+
export const Template = (args, { argTypes }) => ({
|
|
11
|
+
props: Object.keys(argTypes),
|
|
12
|
+
components: { VvDropdown, VvDropdownAction, VvIcon },
|
|
13
|
+
setup() {
|
|
14
|
+
const dropdownEl = ref(null)
|
|
15
|
+
return { args, dropdownEl }
|
|
16
|
+
},
|
|
17
|
+
template: /* html */ `
|
|
18
|
+
<div v-contextmenu="dropdownEl" class="w-full h-320 bg-surface-1 flex items-center justify-center">
|
|
19
|
+
<div class="text-word-2 text-18 uppercase w-150 text-center">Right click context menu</div>
|
|
20
|
+
</div>
|
|
21
|
+
<vv-dropdown v-bind="args" ref="dropdownEl">
|
|
22
|
+
<template #items>
|
|
23
|
+
<vv-dropdown-action>
|
|
24
|
+
<vv-icon name="add" /> Create
|
|
25
|
+
</vv-dropdown-action>
|
|
26
|
+
<vv-dropdown-action>
|
|
27
|
+
<vv-icon name="edit" /> Update
|
|
28
|
+
</vv-dropdown-action>
|
|
29
|
+
<vv-dropdown-action>
|
|
30
|
+
<vv-icon name="trash" /> Delete
|
|
31
|
+
</vv-dropdown-action>
|
|
32
|
+
</template>
|
|
33
|
+
</vv-dropdown>
|
|
34
|
+
`,
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
<Canvas>
|
|
38
|
+
<Story name="Default" args={{ placement: 'bottom-start' }}>
|
|
39
|
+
{Template.bind()}
|
|
40
|
+
</Story>
|
|
41
|
+
</Canvas>
|
|
@@ -196,6 +196,59 @@ export const argTypes = {
|
|
|
196
196
|
},
|
|
197
197
|
},
|
|
198
198
|
},
|
|
199
|
+
mask: {
|
|
200
|
+
description: 'Input mask, only for text type',
|
|
201
|
+
type: {
|
|
202
|
+
summary: 'string',
|
|
203
|
+
},
|
|
204
|
+
control: {
|
|
205
|
+
type: 'text',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
maskEager: {
|
|
209
|
+
description: 'Show mask before typing',
|
|
210
|
+
type: {
|
|
211
|
+
summary: 'boolean',
|
|
212
|
+
},
|
|
213
|
+
table: {
|
|
214
|
+
defaultValue: {
|
|
215
|
+
summary: false,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
maskReversed: {
|
|
220
|
+
description: 'Write typing reverse (ex. for numbers)',
|
|
221
|
+
type: {
|
|
222
|
+
summary: 'boolean',
|
|
223
|
+
},
|
|
224
|
+
table: {
|
|
225
|
+
defaultValue: {
|
|
226
|
+
summary: false,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
maskTokens: {
|
|
231
|
+
description: 'Add mask custom tokens',
|
|
232
|
+
type: {
|
|
233
|
+
summary: 'Object',
|
|
234
|
+
},
|
|
235
|
+
table: {
|
|
236
|
+
defaultValue: {
|
|
237
|
+
summary: 'undefined',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
maskTokensReplace: {
|
|
242
|
+
description: 'Replace default tokens',
|
|
243
|
+
type: {
|
|
244
|
+
summary: 'boolean',
|
|
245
|
+
},
|
|
246
|
+
table: {
|
|
247
|
+
defaultValue: {
|
|
248
|
+
summary: false,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
},
|
|
199
252
|
before: {
|
|
200
253
|
control: {
|
|
201
254
|
type: 'text',
|