@volverjs/ui-vue 0.0.14 → 0.0.15
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/dist/Volver.d.ts +5 -5
- package/dist/components/VvAction/VvAction.es.js +26 -26
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/index.d.ts +1 -44
- package/dist/components/VvAlert/VvAlert.es.js +43 -44
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +54 -55
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +34 -34
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +186 -187
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +215 -217
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +235 -237
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -2
- package/dist/components/VvCheckboxGroup/index.d.ts +1 -78
- package/dist/components/VvCombobox/VvCombobox.es.js +810 -813
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +1 -1
- package/dist/components/VvCombobox/index.d.ts +2 -2
- package/dist/components/VvDropdown/VvDropdown.es.js +4 -4
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +50 -50
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +30 -31
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +415 -418
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.es.js +595 -588
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
- package/dist/components/VvInputText/index.d.ts +3 -3
- package/dist/components/VvNav/VvNav.es.js +63 -63
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNavItem/VvNavItem.es.js +41 -41
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +222 -224
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +234 -236
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -2
- package/dist/components/VvRadioGroup/index.d.ts +1 -78
- package/dist/components/VvSelect/VvSelect.es.js +200 -203
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +1 -1
- package/dist/components/VvSelect/index.d.ts +2 -2
- package/dist/components/VvTab/VvTab.es.js +35 -35
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +341 -344
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/index.es.js +1965 -1958
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/index.es.js +34 -34
- package/dist/composables/index.umd.js +2 -2
- package/dist/composables/useModifiers.d.ts +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/directives/index.es.js +22 -22
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-contextmenu.es.js +13 -13
- package/dist/directives/v-contextmenu.umd.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +19 -19
- package/dist/index.umd.js +1 -1
- package/dist/json-render/index.es.js +1877 -1870
- package/dist/json-render/index.umd.js +1 -1
- package/dist/props/index.d.ts +1 -1
- package/dist/resolvers/unplugin.es.js +28 -28
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/types/alert.d.ts +1 -1
- package/dist/types/nav.d.ts +1 -1
- package/dist/utils/ObjectUtilities.d.ts +0 -6
- package/package.json +1 -1
- package/src/Volver.ts +8 -6
- package/src/components/VvAction/index.ts +1 -3
- package/src/components/VvButton/VvButton.vue +1 -1
- package/src/components/VvCheckboxGroup/index.ts +1 -3
- package/src/components/VvCombobox/VvCombobox.vue +3 -3
- package/src/components/VvDropdown/VvDropdown.vue +8 -8
- package/src/components/VvIcon/VvIcon.vue +3 -6
- package/src/components/VvInputFile/VvInputFile.vue +6 -6
- package/src/components/VvInputText/VvInputText.vue +95 -78
- package/src/components/VvRadioGroup/index.ts +1 -3
- package/src/composables/useBlurhash.ts +1 -1
- package/src/composables/useDebouncedInput.ts +1 -1
- package/src/composables/useDefaults.ts +55 -44
- package/src/composables/useModifiers.ts +1 -1
- package/src/index.ts +2 -2
- package/src/resolvers/unplugin.ts +6 -6
- package/src/types/alert.ts +1 -1
- package/src/types/nav.ts +1 -1
- package/src/utils/DateUtilities.ts +3 -3
- package/src/utils/DomUtilities.ts +7 -1
- package/src/utils/ObjectUtilities.ts +60 -59
|
@@ -10,6 +10,53 @@ type VueProp
|
|
|
10
10
|
| BooleanConstructor
|
|
11
11
|
| PropType<unknown>
|
|
12
12
|
|
|
13
|
+
type PropDefinition
|
|
14
|
+
= | VueProp
|
|
15
|
+
| VueProp[]
|
|
16
|
+
| { type: VueProp | VueProp[], default?: unknown }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns the value a prop should take: either the provided `propValue` or the
|
|
20
|
+
* `componentDefault` when `propValue` still matches the prop definition default.
|
|
21
|
+
* The three checks are intentionally independent (an array definition satisfies
|
|
22
|
+
* both `Array.isArray` and `typeof === 'object'`).
|
|
23
|
+
*/
|
|
24
|
+
function resolveDefaultedProp(
|
|
25
|
+
definition: PropDefinition,
|
|
26
|
+
propValue: unknown,
|
|
27
|
+
componentDefault: unknown,
|
|
28
|
+
): unknown {
|
|
29
|
+
let value = propValue
|
|
30
|
+
// array of types
|
|
31
|
+
if (Array.isArray(definition) && definition.length) {
|
|
32
|
+
const typeFunction = definition[0] as <T>() => T
|
|
33
|
+
if (typeFunction() === propValue) {
|
|
34
|
+
value = componentDefault
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// single type
|
|
38
|
+
if (typeof definition === 'function') {
|
|
39
|
+
const typeFunction = definition as <T>() => T
|
|
40
|
+
if (typeFunction() === propValue) {
|
|
41
|
+
value = componentDefault
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// object with type and default
|
|
45
|
+
if (typeof definition === 'object') {
|
|
46
|
+
let defaultValue = (definition as { default: unknown }).default
|
|
47
|
+
if (typeof defaultValue === 'function') {
|
|
48
|
+
defaultValue = defaultValue()
|
|
49
|
+
}
|
|
50
|
+
const matches = typeof defaultValue === 'object'
|
|
51
|
+
? JSON.stringify(defaultValue) === JSON.stringify(propValue)
|
|
52
|
+
: defaultValue === propValue
|
|
53
|
+
if (matches) {
|
|
54
|
+
value = componentDefault
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return value
|
|
58
|
+
}
|
|
59
|
+
|
|
13
60
|
export function useDefaults<Definition>(
|
|
14
61
|
componentName: string,
|
|
15
62
|
propsDefinition: Definition,
|
|
@@ -18,7 +65,7 @@ export function useDefaults<Definition>(
|
|
|
18
65
|
const volver = useVolver()
|
|
19
66
|
|
|
20
67
|
const volverComponentDefaults = computed(() => {
|
|
21
|
-
if (!volver
|
|
68
|
+
if (!volver?.defaults.value?.[componentName]) {
|
|
22
69
|
return undefined
|
|
23
70
|
}
|
|
24
71
|
return volver.defaults.value[componentName]
|
|
@@ -38,49 +85,13 @@ export function useDefaults<Definition>(
|
|
|
38
85
|
const simplifiedProps = props as Record<string, unknown>
|
|
39
86
|
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
40
87
|
const propValue = simplifiedProps[key]
|
|
41
|
-
acc[key] =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
}
|
|
88
|
+
acc[key] = key in componentDefaults
|
|
89
|
+
? resolveDefaultedProp(
|
|
90
|
+
simplifiedPropsDefinition[key],
|
|
91
|
+
propValue,
|
|
92
|
+
componentDefaults[key],
|
|
93
|
+
)
|
|
94
|
+
: propValue
|
|
84
95
|
return acc
|
|
85
96
|
}, {} as Record<string, unknown>) as Readonly<
|
|
86
97
|
ExtractPropTypes<Definition>
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Volver
|
|
1
|
+
import type { Volver } from './Volver'
|
|
2
2
|
import VolverPlugin from './Volver'
|
|
3
3
|
|
|
4
4
|
export { VolverPlugin }
|
|
5
5
|
export * from './types'
|
|
6
|
-
export type { Volver, VolverOptions }
|
|
6
|
+
export type { Volver, VolverOptions } from './Volver'
|
|
7
7
|
|
|
8
8
|
// https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
|
|
9
9
|
// Add custom property and extend vue type definition
|
|
@@ -35,12 +35,12 @@ export interface VolverResolverOptions {
|
|
|
35
35
|
cherryPick?: boolean
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const STYLE_EXCLUDE = ['vv-icon', 'vv-action']
|
|
38
|
+
const STYLE_EXCLUDE = new Set(['vv-icon', 'vv-action'])
|
|
39
39
|
const VOLVER_PREFIX = 'vv'
|
|
40
|
-
const DIRECTIVES = ['v-tooltip', 'v-contextmenu']
|
|
40
|
+
const DIRECTIVES = new Set(['v-tooltip', 'v-contextmenu'])
|
|
41
41
|
|
|
42
42
|
export function getStyleNames(kebabName: string) {
|
|
43
|
-
if (STYLE_EXCLUDE.
|
|
43
|
+
if (STYLE_EXCLUDE.has(kebabName)) {
|
|
44
44
|
return undefined
|
|
45
45
|
}
|
|
46
46
|
if (kebabName === 'vv-dropdown') {
|
|
@@ -125,7 +125,7 @@ export function VolverResolver({
|
|
|
125
125
|
`${VOLVER_PREFIX}-`,
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
-
if (ignore
|
|
128
|
+
if (ignore?.includes(kebabName)) {
|
|
129
129
|
return
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -153,11 +153,11 @@ export function VolverResolver({
|
|
|
153
153
|
const kebabName = `v-${kebabCase(name)}`
|
|
154
154
|
|
|
155
155
|
// filter directive
|
|
156
|
-
if (!DIRECTIVES.
|
|
156
|
+
if (!DIRECTIVES.has(kebabName)) {
|
|
157
157
|
return
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
if (ignore
|
|
160
|
+
if (ignore?.includes(kebabName)) {
|
|
161
161
|
return
|
|
162
162
|
}
|
|
163
163
|
|
package/src/types/alert.ts
CHANGED
package/src/types/nav.ts
CHANGED
|
@@ -12,14 +12,14 @@ const padTwoDigits = (num: number) => num.toString().padStart(2, '0')
|
|
|
12
12
|
* @param dateString
|
|
13
13
|
* @returns True if valid ISO date string
|
|
14
14
|
* @example
|
|
15
|
-
* isDateIsoString('2021-12-31T23:59:59') // true
|
|
15
|
+
* isDateIsoString('2021-12-31T23:59:59.000Z') // true
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
// Canonical UTC form, matching what `Date.prototype.toISOString()` produces.
|
|
18
|
+
const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/
|
|
18
19
|
export function isDateIsoString(dateString: unknown) {
|
|
19
20
|
if (typeof dateString !== 'string') {
|
|
20
21
|
return false
|
|
21
22
|
}
|
|
22
|
-
// Support both with/without milliseconds and timezone variations
|
|
23
23
|
if (!ISO_DATE_REGEX.test(dateString)) {
|
|
24
24
|
return false
|
|
25
25
|
}
|
|
@@ -2,9 +2,15 @@ export function findScrollContainer(element: HTMLElement | null) {
|
|
|
2
2
|
if (!element) {
|
|
3
3
|
return undefined
|
|
4
4
|
}
|
|
5
|
+
if (
|
|
6
|
+
typeof globalThis.getComputedStyle !== 'function'
|
|
7
|
+
|| typeof document === 'undefined'
|
|
8
|
+
) {
|
|
9
|
+
return undefined
|
|
10
|
+
}
|
|
5
11
|
let parent = element.parentElement
|
|
6
12
|
while (parent) {
|
|
7
|
-
const { overflow } =
|
|
13
|
+
const { overflow } = globalThis.getComputedStyle(parent)
|
|
8
14
|
if (overflow.split(' ').every(item => item === 'auto' || item === 'scroll')) {
|
|
9
15
|
return parent
|
|
10
16
|
}
|
|
@@ -22,67 +22,69 @@ export function equals(obj1: any, obj2: any, field?: string) {
|
|
|
22
22
|
* @returns {boolean}
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
if (a
|
|
27
|
-
return
|
|
25
|
+
function deepEqualsArray(a: any[], b: any[]) {
|
|
26
|
+
if (a.length !== b.length)
|
|
27
|
+
return false
|
|
28
|
+
for (let i = a.length; i-- !== 0;) {
|
|
29
|
+
if (!deepEquals(a[i], b[i]))
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let i, length, key
|
|
33
|
-
|
|
34
|
-
if (arrA && arrB) {
|
|
35
|
-
length = a.length
|
|
36
|
-
if (length !== b.length)
|
|
37
|
-
return false
|
|
38
|
-
for (i = length; i-- !== 0;) {
|
|
39
|
-
if (!deepEquals(a[i], b[i]))
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
35
|
+
function deepEqualsObject(a: any, b: any) {
|
|
36
|
+
const keys = Object.keys(a)
|
|
37
|
+
const { length } = keys
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
if (length !== Object.keys(b).length)
|
|
40
|
+
return false
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
for (let i = length; i-- !== 0;) {
|
|
43
|
+
if (!Object.hasOwn(b, keys[i]))
|
|
47
44
|
return false
|
|
45
|
+
}
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
if (dateA !== dateB)
|
|
47
|
+
for (let i = length; i-- !== 0;) {
|
|
48
|
+
const key = keys[i]
|
|
49
|
+
if (!deepEquals(a[key], b[key]))
|
|
53
50
|
return false
|
|
54
|
-
|
|
55
|
-
return a.getTime() === b.getTime()
|
|
51
|
+
}
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
return true
|
|
54
|
+
}
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return a.toString() === b.toString()
|
|
56
|
+
export function deepEquals(a: any, b: any) {
|
|
57
|
+
if (a === b)
|
|
58
|
+
return true
|
|
64
59
|
|
|
65
|
-
|
|
60
|
+
if (!a || !b || typeof a !== 'object' || typeof b !== 'object')
|
|
61
|
+
return Number.isNaN(a) && Number.isNaN(b)
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
const arrA = Array.isArray(a)
|
|
64
|
+
const arrB = Array.isArray(b)
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
if (arrA !== arrB)
|
|
67
|
+
return false
|
|
68
|
+
if (arrA && arrB)
|
|
69
|
+
return deepEqualsArray(a, b)
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return false
|
|
75
|
-
}
|
|
71
|
+
const dateA = a instanceof Date
|
|
72
|
+
const dateB = b instanceof Date
|
|
76
73
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
74
|
+
if (dateA !== dateB)
|
|
75
|
+
return false
|
|
76
|
+
if (dateA && dateB)
|
|
77
|
+
return a.getTime() === b.getTime()
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
const regexpA = a instanceof RegExp
|
|
80
|
+
const regexpB = b instanceof RegExp
|
|
81
|
+
|
|
82
|
+
if (regexpA !== regexpB)
|
|
83
|
+
return false
|
|
84
|
+
if (regexpA && regexpB)
|
|
85
|
+
return a.toString() === b.toString()
|
|
86
|
+
|
|
87
|
+
return deepEqualsObject(a, b)
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
/**
|
|
@@ -95,20 +97,19 @@ export function resolveFieldData(data: Record<string, unknown>, field: string) {
|
|
|
95
97
|
if (data && Object.keys(data).length && field) {
|
|
96
98
|
if (!field.includes('.')) {
|
|
97
99
|
return data[field]
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
103
|
-
if (data == null) {
|
|
104
|
-
return null
|
|
105
|
-
}
|
|
100
|
+
}
|
|
101
|
+
const fields = field.split('.')
|
|
102
|
+
let value = data
|
|
106
103
|
|
|
107
|
-
|
|
104
|
+
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
105
|
+
if (value == null) {
|
|
106
|
+
return null
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
value = value[fields[i]] as Record<string, unknown>
|
|
111
110
|
}
|
|
111
|
+
|
|
112
|
+
return value
|
|
112
113
|
} else {
|
|
113
114
|
return null
|
|
114
115
|
}
|
|
@@ -120,7 +121,7 @@ export function resolveFieldData(data: Record<string, unknown>, field: string) {
|
|
|
120
121
|
*/
|
|
121
122
|
|
|
122
123
|
export function isFunction(obj: any) {
|
|
123
|
-
return !!(obj
|
|
124
|
+
return !!(obj?.constructor && obj.call && obj.apply)
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
/**
|
|
@@ -151,7 +152,7 @@ export function findIndexInList<Type = unknown>(value: Type, list: Type[]) {
|
|
|
151
152
|
* @returns {boolean} the index
|
|
152
153
|
*/
|
|
153
154
|
export function contains<Type = unknown>(value: Type, list: Type[]) {
|
|
154
|
-
if (value != null && list
|
|
155
|
+
if (value != null && list?.length) {
|
|
155
156
|
for (const val of list) {
|
|
156
157
|
if (equals(value, val)) {
|
|
157
158
|
return true
|