winduum 3.0.0-next.3 → 3.0.0-next.5
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 +1 -1
- package/src/components/carousel/index.js +25 -10
- package/src/components/dialog/index.js +4 -0
- package/src/components/drawer/index.js +1 -2
- package/src/components/form/index.js +5 -4
- package/src/components/toast/default.css +6 -0
- package/src/components/toast/index.js +2 -1
- package/src/components/toaster/index.js +18 -0
- package/tailwindcss/utilities/position.css +24 -0
package/package.json
CHANGED
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
* @param {HTMLElement} element
|
|
3
3
|
* @param {object} options
|
|
4
4
|
* @param {number} [options.direction=1]
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {'left' | 'top'} [options.position='left']
|
|
5
|
+
* @param {boolean} [options.vertical=false]
|
|
7
6
|
* @param {number} [options.ratio=0.85]
|
|
8
7
|
* @returns void
|
|
9
8
|
*/
|
|
10
|
-
export const scrollBy = (element, { direction = 1,
|
|
9
|
+
export const scrollBy = (element, { direction = 1, vertical = false, ratio = 0.85 }) => {
|
|
10
|
+
const { distance, position } = vertical
|
|
11
|
+
? {
|
|
12
|
+
distance: element.clientHeight * ratio,
|
|
13
|
+
position: 'top',
|
|
14
|
+
}
|
|
15
|
+
: {
|
|
16
|
+
distance: element.clientWidth * ratio,
|
|
17
|
+
position: 'left',
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
element.scrollBy({
|
|
12
21
|
[position]: (distance ?? element.clientWidth * ratio) * direction,
|
|
13
22
|
})
|
|
@@ -18,15 +27,21 @@ export const scrollBy = (element, { direction = 1, distance, position = 'left',
|
|
|
18
27
|
* @param {object} options
|
|
19
28
|
* @param {HTMLButtonElement | null} [options.prevElement]
|
|
20
29
|
* @param {HTMLButtonElement | null} [options.nextElement]
|
|
21
|
-
* @param {boolean}
|
|
22
|
-
* @param {boolean} [options.scrollEnd]
|
|
23
|
-
* @param {boolean} [options.scrollNone]
|
|
30
|
+
* @param {boolean} vertical
|
|
24
31
|
* @returns void
|
|
25
32
|
*/
|
|
26
|
-
export const toggleScrollState = (element, { prevElement, nextElement,
|
|
27
|
-
scrollStart
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
export const toggleScrollState = (element, { prevElement, nextElement, vertical = false }) => {
|
|
34
|
+
const { scrollStart, scrollEnd, scrollNone } = vertical
|
|
35
|
+
? {
|
|
36
|
+
scrollStart: element.scrollTop <= 0,
|
|
37
|
+
scrollEnd: element.scrollTop >= element.scrollHeight - element.clientHeight,
|
|
38
|
+
scrollNone: !(element.scrollHeight - element.clientHeight),
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
scrollStart: element.scrollLeft <= 0,
|
|
42
|
+
scrollEnd: element.scrollLeft >= element.scrollWidth - element.clientWidth,
|
|
43
|
+
scrollNone: !(element.scrollWidth - element.clientWidth),
|
|
44
|
+
}
|
|
30
45
|
|
|
31
46
|
if (prevElement) prevElement.disabled = scrollStart
|
|
32
47
|
if (nextElement) nextElement.disabled = scrollEnd
|
|
@@ -5,3 +5,7 @@ document.documentElement.addEventListener('click', ({ target }) => {
|
|
|
5
5
|
target?.close()
|
|
6
6
|
}
|
|
7
7
|
})
|
|
8
|
+
|
|
9
|
+
new ResizeObserver(() => {
|
|
10
|
+
document.documentElement.style.setProperty('--default-scrollbar-width', `${Math.max(0, window.innerWidth - document.body.clientWidth)}px`)
|
|
11
|
+
}).observe(document.body)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {
|
|
2
|
+
* @param {SubmitEvent & { target: HTMLFormElement }} event
|
|
3
3
|
* @param {import("./").ValidateFormOptions} options
|
|
4
4
|
* @returns void
|
|
5
5
|
*/
|
|
@@ -23,7 +23,7 @@ export const validateForm = (event, options = {}) => {
|
|
|
23
23
|
event.target.querySelector(':invalid').scrollIntoView(options.scrollOptions)
|
|
24
24
|
event.target.querySelector(':invalid').focus()
|
|
25
25
|
}
|
|
26
|
-
else {
|
|
26
|
+
else if (options.submitterLoadingAttribute) {
|
|
27
27
|
event?.submitter?.setAttribute(options.submitterLoadingAttribute, '')
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -58,9 +58,10 @@ export const validateField = (element, options = {}) => {
|
|
|
58
58
|
...options,
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const validationElement = /** @type {HTMLInputElement} */ (element.querySelector(options.selector))
|
|
62
|
+
|
|
63
|
+
if (!validationElement) return
|
|
62
64
|
|
|
63
|
-
const validationElement = element.querySelector(options.selector)
|
|
64
65
|
const validationMessage = options.validationMessage ?? validationElement.dataset.validationMessage ?? validationElement.validationMessage
|
|
65
66
|
const infoParentElement = validationElement?.closest(options.infoParentSelector)
|
|
66
67
|
const endParentElement = validationElement.closest(options.endParentSelector)
|
|
@@ -9,6 +9,7 @@ export const closeToast = async (element, options = {}) => {
|
|
|
9
9
|
options = {
|
|
10
10
|
closedAttribute: 'data-closed',
|
|
11
11
|
heightProperty: '--x-toast-block-size',
|
|
12
|
+
remove: true,
|
|
12
13
|
...options,
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -31,7 +32,7 @@ export const closeToast = async (element, options = {}) => {
|
|
|
31
32
|
export const showToast = async (element, options = {}) => {
|
|
32
33
|
options = {
|
|
33
34
|
openAttribute: 'data-open',
|
|
34
|
-
autoHide:
|
|
35
|
+
autoHide: 7500,
|
|
35
36
|
heightProperty: '--x-toast-block-size',
|
|
36
37
|
close: {},
|
|
37
38
|
...options,
|
|
@@ -10,3 +10,21 @@ export const closeToaster = (element, options = {}) => {
|
|
|
10
10
|
closeToast(toast, options),
|
|
11
11
|
)
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @returns MutationObserver
|
|
16
|
+
*/
|
|
17
|
+
export const toasterObserver = () => {
|
|
18
|
+
return new MutationObserver((mutations) => {
|
|
19
|
+
for (const { target } of mutations) {
|
|
20
|
+
if (target.children.length > 0) {
|
|
21
|
+
if (!target.matches(':popover-open')) {
|
|
22
|
+
target?.showPopover?.()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
target?.hidePopover?.()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
transform-origin: top;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/*
|
|
9
10
|
@container anchored(fallback: flip-block) {
|
|
10
11
|
> * {
|
|
11
12
|
transform-origin: bottom;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
*/
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
@utility bottom-start {
|
|
@@ -21,11 +23,13 @@
|
|
|
21
23
|
transform-origin: top left;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
/*
|
|
24
27
|
@container anchored(fallback: flip-block) {
|
|
25
28
|
> * {
|
|
26
29
|
transform-origin: bottom left;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
32
|
+
*/
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
@utility bottom-end {
|
|
@@ -36,11 +40,13 @@
|
|
|
36
40
|
transform-origin: top right;
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
/*
|
|
39
44
|
@container anchored(fallback: flip-block) {
|
|
40
45
|
> * {
|
|
41
46
|
transform-origin: bottom right;
|
|
42
47
|
}
|
|
43
48
|
}
|
|
49
|
+
*/
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
@utility top {
|
|
@@ -51,11 +57,13 @@
|
|
|
51
57
|
transform-origin: bottom;
|
|
52
58
|
}
|
|
53
59
|
|
|
60
|
+
/*
|
|
54
61
|
@container anchored(fallback: flip-block) {
|
|
55
62
|
> * {
|
|
56
63
|
transform-origin: top;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
66
|
+
*/
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
@utility top-start {
|
|
@@ -66,11 +74,13 @@
|
|
|
66
74
|
transform-origin: bottom left;
|
|
67
75
|
}
|
|
68
76
|
|
|
77
|
+
/*
|
|
69
78
|
@container anchored(fallback: flip-block) {
|
|
70
79
|
> * {
|
|
71
80
|
transform-origin: top left;
|
|
72
81
|
}
|
|
73
82
|
}
|
|
83
|
+
*/
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
@utility top-end {
|
|
@@ -81,11 +91,13 @@
|
|
|
81
91
|
transform-origin: bottom right;
|
|
82
92
|
}
|
|
83
93
|
|
|
94
|
+
/*
|
|
84
95
|
@container anchored(fallback: flip-block) {
|
|
85
96
|
> * {
|
|
86
97
|
transform-origin: top right;
|
|
87
98
|
}
|
|
88
99
|
}
|
|
100
|
+
*/
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
@utility left {
|
|
@@ -96,11 +108,13 @@
|
|
|
96
108
|
transform-origin: right;
|
|
97
109
|
}
|
|
98
110
|
|
|
111
|
+
/*
|
|
99
112
|
@container anchored(fallback: flip-block) {
|
|
100
113
|
> * {
|
|
101
114
|
transform-origin: left;
|
|
102
115
|
}
|
|
103
116
|
}
|
|
117
|
+
*/
|
|
104
118
|
}
|
|
105
119
|
|
|
106
120
|
@utility left-start {
|
|
@@ -111,11 +125,13 @@
|
|
|
111
125
|
transform-origin: right top;
|
|
112
126
|
}
|
|
113
127
|
|
|
128
|
+
/*
|
|
114
129
|
@container anchored(fallback: flip-block) {
|
|
115
130
|
> * {
|
|
116
131
|
transform-origin: left top;
|
|
117
132
|
}
|
|
118
133
|
}
|
|
134
|
+
*/
|
|
119
135
|
}
|
|
120
136
|
|
|
121
137
|
@utility left-end {
|
|
@@ -126,11 +142,13 @@
|
|
|
126
142
|
transform-origin: right bottom;
|
|
127
143
|
}
|
|
128
144
|
|
|
145
|
+
/*
|
|
129
146
|
@container anchored(fallback: flip-block) {
|
|
130
147
|
> * {
|
|
131
148
|
transform-origin: left bottom;
|
|
132
149
|
}
|
|
133
150
|
}
|
|
151
|
+
*/
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
@utility right {
|
|
@@ -141,11 +159,13 @@
|
|
|
141
159
|
transform-origin: left;
|
|
142
160
|
}
|
|
143
161
|
|
|
162
|
+
/*
|
|
144
163
|
@container anchored(fallback: flip-block) {
|
|
145
164
|
> * {
|
|
146
165
|
transform-origin: right;
|
|
147
166
|
}
|
|
148
167
|
}
|
|
168
|
+
*/
|
|
149
169
|
}
|
|
150
170
|
|
|
151
171
|
@utility right-start {
|
|
@@ -156,11 +176,13 @@
|
|
|
156
176
|
transform-origin: left top;
|
|
157
177
|
}
|
|
158
178
|
|
|
179
|
+
/*
|
|
159
180
|
@container anchored(fallback: flip-block) {
|
|
160
181
|
> * {
|
|
161
182
|
transform-origin: right top;
|
|
162
183
|
}
|
|
163
184
|
}
|
|
185
|
+
*/
|
|
164
186
|
}
|
|
165
187
|
|
|
166
188
|
@utility right-end {
|
|
@@ -171,9 +193,11 @@
|
|
|
171
193
|
transform-origin: left bottom;
|
|
172
194
|
}
|
|
173
195
|
|
|
196
|
+
/*
|
|
174
197
|
@container anchored(fallback: flip-block) {
|
|
175
198
|
> * {
|
|
176
199
|
transform-origin: right bottom;
|
|
177
200
|
}
|
|
178
201
|
}
|
|
202
|
+
*/
|
|
179
203
|
}
|