winduum 3.0.0-next.5 → 3.0.0-next.6
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/package.json +12 -12
- package/src/components/form/index.d.ts +2 -9
- package/src/components/form/index.js +20 -53
- package/types/index.d.ts +2 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "winduum",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"main": "plugin/index.cjs",
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
"@floating-ui/dom": "^1.7.6",
|
|
24
24
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
25
25
|
"@stylistic/stylelint-config": "^5.0.0",
|
|
26
|
-
"@tailwindcss/vite": "^4.3.
|
|
26
|
+
"@tailwindcss/vite": "^4.3.2",
|
|
27
27
|
"@vitejs/plugin-vue": "^6.0.7",
|
|
28
28
|
"@webreflection/custom-elements-builtin": "^0.4.1",
|
|
29
|
-
"autoprefixer": "^10.5.
|
|
30
|
-
"dts-buddy": "^0.8.
|
|
31
|
-
"eslint": "^10.
|
|
29
|
+
"autoprefixer": "^10.5.2",
|
|
30
|
+
"dts-buddy": "^0.8.2",
|
|
31
|
+
"eslint": "^10.6.0",
|
|
32
32
|
"fast-glob": "^3.3.3",
|
|
33
|
-
"globals": "^17.
|
|
33
|
+
"globals": "^17.7.0",
|
|
34
34
|
"invokers-polyfill": "^1.0.3",
|
|
35
|
-
"postcss": "^8.5.
|
|
35
|
+
"postcss": "^8.5.16",
|
|
36
36
|
"postcss-custom-media": "^12.0.1",
|
|
37
37
|
"postcss-import": "^16.1.1",
|
|
38
38
|
"postcss-nesting": "^14.0.0",
|
|
39
39
|
"slide-element": "^2.3.1",
|
|
40
|
-
"stylelint": "^17.
|
|
40
|
+
"stylelint": "^17.14.0",
|
|
41
41
|
"stylelint-config-standard": "^40.0.0",
|
|
42
|
-
"tailwindcss": "^4.3.
|
|
42
|
+
"tailwindcss": "^4.3.2",
|
|
43
43
|
"typescript": "^6",
|
|
44
|
-
"vite": "^8.
|
|
45
|
-
"vue": "^3.5.
|
|
46
|
-
"webuum": "^0.1
|
|
44
|
+
"vite": "^8.1.3",
|
|
45
|
+
"vue": "^3.5.39",
|
|
46
|
+
"webuum": "^0.2.1"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"index.js",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export interface ValidateFormOptions {
|
|
2
|
-
|
|
2
|
+
validateSelector?: string
|
|
3
3
|
validateOptions?: ValidateFieldOptions
|
|
4
4
|
validateField?: typeof validateField
|
|
5
5
|
scrollOptions?: ScrollIntoViewOptions
|
|
@@ -10,20 +10,13 @@ export interface ValidateFieldOptions {
|
|
|
10
10
|
validate?: boolean
|
|
11
11
|
validationMessage?: string
|
|
12
12
|
selector?: string
|
|
13
|
-
ignoreMatch?: RegExp
|
|
14
13
|
validitySelector?: string
|
|
15
|
-
infoParentSelector?: string
|
|
16
|
-
infoSelector?: string
|
|
17
14
|
infoContent?: string
|
|
18
15
|
endParentSelector?: string
|
|
19
16
|
endSelector?: string
|
|
20
17
|
endContent?: string
|
|
21
|
-
validAttribute?: string
|
|
22
|
-
validIcon?: string | null
|
|
23
|
-
invalidAttribute?: string
|
|
24
18
|
invalidIcon?: string
|
|
25
|
-
activeAttribute?: string
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
|
|
29
|
-
export function validateField(element: HTMLElement
|
|
22
|
+
export function validateField(element: HTMLElement, options?: ValidateFieldOptions): void
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const validateForm = (event, options = {}) => {
|
|
7
7
|
options = {
|
|
8
|
-
|
|
8
|
+
validateSelector: '.x-field',
|
|
9
9
|
validateOptions: {
|
|
10
10
|
validate: true,
|
|
11
11
|
},
|
|
@@ -28,7 +28,7 @@ export const validateForm = (event, options = {}) => {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
event.target.querySelectorAll(options.
|
|
31
|
+
event.target.querySelectorAll(options.validateSelector).forEach((element) => {
|
|
32
32
|
options.validateField(element, options.validateOptions)
|
|
33
33
|
})
|
|
34
34
|
}
|
|
@@ -41,73 +41,40 @@ export const validateForm = (event, options = {}) => {
|
|
|
41
41
|
export const validateField = (element, options = {}) => {
|
|
42
42
|
options = {
|
|
43
43
|
validate: true,
|
|
44
|
-
selector: 'input:not([type="hidden"]), textarea, select',
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
infoParentSelector: '.x-field',
|
|
48
|
-
infoSelector: '.x-info',
|
|
49
|
-
infoContent: '<div class="x-info text-error validity"></div>',
|
|
44
|
+
selector: ':is(input:not([type="hidden"]), textarea, select):not([readonly], [data-novalidate])',
|
|
45
|
+
validitySelector: '[data-validity]',
|
|
46
|
+
infoContent: '<div class="x-info text-error" data-validity></div>',
|
|
50
47
|
endParentSelector: '.x-control',
|
|
51
48
|
endSelector: '.ms-auto',
|
|
52
49
|
endContent: '<div class="ms-auto"></div>',
|
|
53
|
-
|
|
54
|
-
validIcon: null,
|
|
55
|
-
invalidAttribute: 'data-invalid',
|
|
56
|
-
invalidIcon: '<svg class="text-error validity" aria-hidden="true"><use href="#icon-exclamation-circle"></use></svg>',
|
|
57
|
-
activeAttribute: 'data-active',
|
|
50
|
+
invalidIcon: '<svg class="text-error" data-validity aria-hidden="true"><use href="#icon-exclamation-circle"></use></svg>',
|
|
58
51
|
...options,
|
|
59
52
|
}
|
|
60
53
|
|
|
61
|
-
const
|
|
54
|
+
const validationElements = /** @type {HTMLInputElement[]} */ ([...element.querySelectorAll(options.selector)])
|
|
62
55
|
|
|
63
|
-
if (!
|
|
56
|
+
if (!validationElements.length || !options.validate) return
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
const infoParentElement = validationElement?.closest(options.infoParentSelector)
|
|
67
|
-
const endParentElement = validationElement.closest(options.endParentSelector)
|
|
68
|
-
const infoSelector = options.infoSelector + options.validitySelector
|
|
69
|
-
const endSelector = `${options.endSelector} ${options.validitySelector}`
|
|
58
|
+
element.querySelectorAll(options.validitySelector).forEach(el => el.remove())
|
|
70
59
|
|
|
71
|
-
const
|
|
72
|
-
if (!endParentElement || !icon) return
|
|
60
|
+
const invalidElements = validationElements.filter(validationElement => !validationElement.checkValidity())
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
element?.insertAdjacentHTML('beforeend', options.endContent)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
element.querySelector(options.endSelector).insertAdjacentHTML('afterbegin', icon)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (validationElement.value !== '') {
|
|
82
|
-
element.setAttribute(options.activeAttribute, '')
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
element.removeAttribute(options.activeAttribute)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!validationElement.outerHTML.match(options.ignoreMatch) && options.validate) {
|
|
89
|
-
element?.removeAttribute(options.validAttribute)
|
|
90
|
-
element?.removeAttribute(options.invalidAttribute)
|
|
62
|
+
if (!invalidElements.length) return
|
|
91
63
|
|
|
92
|
-
|
|
93
|
-
endParentElement
|
|
64
|
+
invalidElements.forEach((validationElement) => {
|
|
65
|
+
const endParentElement = validationElement.closest(options.endParentSelector)
|
|
94
66
|
|
|
95
|
-
if (
|
|
96
|
-
element.setAttribute(options.validAttribute, '')
|
|
67
|
+
if (!endParentElement || !options.invalidIcon) return
|
|
97
68
|
|
|
98
|
-
|
|
69
|
+
if (!endParentElement.querySelector(options.endSelector)) {
|
|
70
|
+
endParentElement.insertAdjacentHTML('beforeend', options.endContent)
|
|
99
71
|
}
|
|
100
|
-
else {
|
|
101
|
-
element.setAttribute(options.invalidAttribute, '')
|
|
102
72
|
|
|
103
|
-
|
|
73
|
+
endParentElement.querySelector(options.endSelector).insertAdjacentHTML('afterbegin', options.invalidIcon)
|
|
74
|
+
})
|
|
104
75
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
infoParentElement.querySelector(infoSelector).textContent = validationMessage
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
76
|
+
element.insertAdjacentHTML('beforeend', options.infoContent)
|
|
77
|
+
element.lastElementChild.textContent = options.validationMessage ?? invalidElements[0].dataset.validationMessage ?? invalidElements[0].validationMessage
|
|
111
78
|
}
|
|
112
79
|
|
|
113
80
|
export default {
|
package/types/index.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ declare module 'winduum/src/components/drawer' {
|
|
|
121
121
|
|
|
122
122
|
declare module 'winduum/src/components/form' {
|
|
123
123
|
export interface ValidateFormOptions {
|
|
124
|
-
|
|
124
|
+
validateSelector?: string
|
|
125
125
|
validateOptions?: ValidateFieldOptions
|
|
126
126
|
validateField?: typeof validateField
|
|
127
127
|
scrollOptions?: ScrollIntoViewOptions
|
|
@@ -132,23 +132,16 @@ declare module 'winduum/src/components/form' {
|
|
|
132
132
|
validate?: boolean
|
|
133
133
|
validationMessage?: string
|
|
134
134
|
selector?: string
|
|
135
|
-
ignoreMatch?: RegExp
|
|
136
135
|
validitySelector?: string
|
|
137
|
-
infoParentSelector?: string
|
|
138
|
-
infoSelector?: string
|
|
139
136
|
infoContent?: string
|
|
140
137
|
endParentSelector?: string
|
|
141
138
|
endSelector?: string
|
|
142
139
|
endContent?: string
|
|
143
|
-
validAttribute?: string
|
|
144
|
-
validIcon?: string | null
|
|
145
|
-
invalidAttribute?: string
|
|
146
140
|
invalidIcon?: string
|
|
147
|
-
activeAttribute?: string
|
|
148
141
|
}
|
|
149
142
|
|
|
150
143
|
export function validateForm(event: Event | SubmitEvent, options?: ValidateFormOptions): void
|
|
151
|
-
export function validateField(element: HTMLElement
|
|
144
|
+
export function validateField(element: HTMLElement, options?: ValidateFieldOptions): void
|
|
152
145
|
|
|
153
146
|
export {};
|
|
154
147
|
}
|