@jskit-ai/material-web 0.1.5 → 0.1.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/CHANGELOG.md +1 -0
- package/README.md +35 -0
- package/package.json +3 -2
- package/scripts/patch-vuetify-loaders.mjs +216 -0
- package/test/fixtures/idle-loaders/App.vue +72 -0
- package/test/fixtures/idle-loaders/index.html +2 -0
- package/test/fixtures/idle-loaders/main.js +10 -0
- package/test/fixtures/vuetify-4.3.3/LICENSE.md +21 -0
- package/test/fixtures/vuetify-4.3.3/lib/components/VProgressCircular/VProgressCircular.js +209 -0
- package/test/fixtures/vuetify-4.3.3/lib/components/VProgressLinear/VProgressLinear.js +322 -0
- package/test/fixtures/vuetify-4.3.3/lib/labs/VLoadingIndicator/VLoadingIndicator.js +76 -0
- package/test/vite.config.js +37 -0
- package/test/vuetifyIdleLoaders.browser.test.js +102 -0
- package/test/vuetifyLoaderPatch.test.js +202 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, Fragment as _Fragment, createVNode as _createVNode } from "vue";
|
|
2
|
+
// Styles
|
|
3
|
+
import "./VProgressLinear.css";
|
|
4
|
+
|
|
5
|
+
// Composables
|
|
6
|
+
import { useBackgroundColor, useTextColor } from "../../composables/color.js";
|
|
7
|
+
import { makeComponentProps } from "../../composables/component.js";
|
|
8
|
+
import { useElementIntersection } from "../../composables/intersectionObserver.js";
|
|
9
|
+
import { useRtl } from "../../composables/locale.js";
|
|
10
|
+
import { makeLocationProps, useLocation } from "../../composables/location.js";
|
|
11
|
+
import { useProxiedModel } from "../../composables/proxiedModel.js";
|
|
12
|
+
import { useResizeObserver } from "../../composables/resizeObserver.js";
|
|
13
|
+
import { makeRevealProps, useReveal } from "../../composables/reveal.js";
|
|
14
|
+
import { makeRoundedProps, useRounded } from "../../composables/rounded.js";
|
|
15
|
+
import { makeTagProps } from "../../composables/tag.js";
|
|
16
|
+
import { makeThemeProps, provideTheme } from "../../composables/theme.js";
|
|
17
|
+
import { useToggleScope } from "../../composables/toggleScope.js"; // Utilities
|
|
18
|
+
import { computed, shallowRef, toRef, Transition } from 'vue';
|
|
19
|
+
import { makeChunksProps, useChunks } from "./chunks.js";
|
|
20
|
+
import { useWavy, WAVE_AMPLITUDE } from "./wavy.js";
|
|
21
|
+
import { clamp, convertToUnit, genericComponent, isNullOrUndefined, isObject, propsFactory, useRender } from "../../util/index.js"; // Types
|
|
22
|
+
export const makeVProgressLinearProps = propsFactory({
|
|
23
|
+
absolute: Boolean,
|
|
24
|
+
active: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
bgColor: String,
|
|
29
|
+
bgOpacity: [Number, String],
|
|
30
|
+
bufferValue: {
|
|
31
|
+
type: [Number, String],
|
|
32
|
+
default: 0
|
|
33
|
+
},
|
|
34
|
+
bufferColor: String,
|
|
35
|
+
bufferOpacity: [Number, String],
|
|
36
|
+
clickable: Boolean,
|
|
37
|
+
color: String,
|
|
38
|
+
height: {
|
|
39
|
+
type: [Number, String],
|
|
40
|
+
default: 4
|
|
41
|
+
},
|
|
42
|
+
indeterminate: Boolean,
|
|
43
|
+
max: {
|
|
44
|
+
type: [Number, String],
|
|
45
|
+
default: 100
|
|
46
|
+
},
|
|
47
|
+
modelValue: {
|
|
48
|
+
type: [Number, String],
|
|
49
|
+
default: 0
|
|
50
|
+
},
|
|
51
|
+
opacity: [Number, String],
|
|
52
|
+
reverse: Boolean,
|
|
53
|
+
shape: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'flat',
|
|
56
|
+
validator: v => ['flat', 'wavy'].includes(v)
|
|
57
|
+
},
|
|
58
|
+
stopIndicator: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: undefined
|
|
61
|
+
},
|
|
62
|
+
stream: Boolean,
|
|
63
|
+
striped: Boolean,
|
|
64
|
+
roundedBar: Boolean,
|
|
65
|
+
transition: {
|
|
66
|
+
type: [Boolean, Object],
|
|
67
|
+
default: undefined
|
|
68
|
+
},
|
|
69
|
+
...makeChunksProps(),
|
|
70
|
+
...makeComponentProps(),
|
|
71
|
+
...makeLocationProps({
|
|
72
|
+
location: 'top'
|
|
73
|
+
}),
|
|
74
|
+
...makeRevealProps(),
|
|
75
|
+
...makeRoundedProps(),
|
|
76
|
+
...makeTagProps(),
|
|
77
|
+
...makeThemeProps()
|
|
78
|
+
}, 'VProgressLinear');
|
|
79
|
+
export const VProgressLinear = genericComponent()({
|
|
80
|
+
name: 'VProgressLinear',
|
|
81
|
+
props: makeVProgressLinearProps(),
|
|
82
|
+
emits: {
|
|
83
|
+
'update:modelValue': value => true
|
|
84
|
+
},
|
|
85
|
+
setup(props, {
|
|
86
|
+
slots
|
|
87
|
+
}) {
|
|
88
|
+
const root = shallowRef();
|
|
89
|
+
const progress = useProxiedModel(props, 'modelValue');
|
|
90
|
+
const {
|
|
91
|
+
isRtl,
|
|
92
|
+
rtlClasses
|
|
93
|
+
} = useRtl();
|
|
94
|
+
const {
|
|
95
|
+
themeClasses
|
|
96
|
+
} = provideTheme(props);
|
|
97
|
+
const {
|
|
98
|
+
locationStyles
|
|
99
|
+
} = useLocation(props);
|
|
100
|
+
const {
|
|
101
|
+
textColorClasses,
|
|
102
|
+
textColorStyles
|
|
103
|
+
} = useTextColor(() => props.color);
|
|
104
|
+
const {
|
|
105
|
+
backgroundColorClasses,
|
|
106
|
+
backgroundColorStyles
|
|
107
|
+
} = useBackgroundColor(() => props.bgColor || props.color);
|
|
108
|
+
const {
|
|
109
|
+
backgroundColorClasses: bufferColorClasses,
|
|
110
|
+
backgroundColorStyles: bufferColorStyles
|
|
111
|
+
} = useBackgroundColor(() => props.bufferColor || props.bgColor || props.color);
|
|
112
|
+
const {
|
|
113
|
+
backgroundColorClasses: barColorClasses,
|
|
114
|
+
backgroundColorStyles: barColorStyles
|
|
115
|
+
} = useBackgroundColor(() => props.color);
|
|
116
|
+
const {
|
|
117
|
+
textColorClasses: trackColorClasses,
|
|
118
|
+
textColorStyles: trackColorStyles
|
|
119
|
+
} = useTextColor(() => props.bgColor);
|
|
120
|
+
const {
|
|
121
|
+
roundedClasses,
|
|
122
|
+
roundedStyles
|
|
123
|
+
} = useRounded(props);
|
|
124
|
+
const {
|
|
125
|
+
isIntersecting
|
|
126
|
+
} = useElementIntersection(root);
|
|
127
|
+
const {
|
|
128
|
+
state: revealState,
|
|
129
|
+
duration: revealDuration
|
|
130
|
+
} = useReveal(props);
|
|
131
|
+
const max = computed(() => parseFloat(props.max));
|
|
132
|
+
const height = computed(() => convertToUnit(props.height));
|
|
133
|
+
const normalizedBuffer = computed(() => clamp(parseFloat(props.bufferValue) / max.value * 100, 0, 100));
|
|
134
|
+
const normalizedValue = computed(() => revealState.value === 'initial' ? 0 : clamp(parseFloat(progress.value) / max.value * 100, 0, 100));
|
|
135
|
+
const isReversed = computed(() => isRtl.value !== props.reverse);
|
|
136
|
+
const transitionDuration = computed(() => props.transition === false ? undefined : convertToUnit(isObject(props.transition) ? props.transition.duration : undefined, 'ms'));
|
|
137
|
+
const bgOpacity = toRef(() => isNullOrUndefined(props.bgOpacity) ? undefined : parseFloat(props.bgOpacity));
|
|
138
|
+
const isWavy = toRef(() => props.shape === 'wavy');
|
|
139
|
+
// undefined keeps split without the stop until the next major
|
|
140
|
+
const hasStopIndicator = toRef(() => !props.indeterminate && (isWavy.value ? props.stopIndicator !== false : props.variant === 'split' && props.stopIndicator === true));
|
|
141
|
+
const transitionName = computed(() => props.indeterminate ? 'fade-transition' : 'slide-x-transition');
|
|
142
|
+
const containerWidth = shallowRef(0);
|
|
143
|
+
const {
|
|
144
|
+
hasChunks,
|
|
145
|
+
splitStyles,
|
|
146
|
+
chunksMaskStyles,
|
|
147
|
+
snapValueToChunk
|
|
148
|
+
} = useChunks(props, containerWidth, normalizedValue, normalizedBuffer, isReversed);
|
|
149
|
+
useToggleScope(() => hasChunks.value || isWavy.value, () => {
|
|
150
|
+
useResizeObserver(root, entries => {
|
|
151
|
+
containerWidth.value = entries[0].contentRect.width;
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
const bufferWidth = computed(() => {
|
|
155
|
+
return hasChunks.value ? snapValueToChunk(normalizedBuffer.value) : normalizedBuffer.value;
|
|
156
|
+
});
|
|
157
|
+
const barWidth = computed(() => {
|
|
158
|
+
return hasChunks.value ? snapValueToChunk(normalizedValue.value) : normalizedValue.value;
|
|
159
|
+
});
|
|
160
|
+
const {
|
|
161
|
+
geometry,
|
|
162
|
+
svgEl,
|
|
163
|
+
waveEl
|
|
164
|
+
} = useWavy(props, {
|
|
165
|
+
containerWidth,
|
|
166
|
+
value: normalizedValue,
|
|
167
|
+
isActive: () => props.active && isIntersecting.value,
|
|
168
|
+
duration: () => {
|
|
169
|
+
if (revealState.value === 'pending') return revealDuration.value;
|
|
170
|
+
const duration = getComputedStyle(root.value).getPropertyValue('--v-progress-linear-transition-duration').trim();
|
|
171
|
+
return parseFloat(duration) * (duration.endsWith('ms') ? 1 : 1000);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
function handleClick(e) {
|
|
175
|
+
if (!root.value) return;
|
|
176
|
+
const {
|
|
177
|
+
left,
|
|
178
|
+
right,
|
|
179
|
+
width
|
|
180
|
+
} = root.value.getBoundingClientRect();
|
|
181
|
+
const value = isReversed.value ? width - e.clientX + (right - width) : e.clientX - left;
|
|
182
|
+
progress.value = Math.round(value / width * max.value);
|
|
183
|
+
}
|
|
184
|
+
function renderBackgroundBar() {
|
|
185
|
+
return _createElementVNode("div", {
|
|
186
|
+
"class": _normalizeClass(['v-progress-linear__background', backgroundColorClasses.value]),
|
|
187
|
+
"style": _normalizeStyle([backgroundColorStyles.value, {
|
|
188
|
+
opacity: bgOpacity.value,
|
|
189
|
+
width: props.stream ? 0 : undefined
|
|
190
|
+
}, props.indeterminate ? {} : splitStyles.value?.background])
|
|
191
|
+
}, null);
|
|
192
|
+
}
|
|
193
|
+
function renderWavy() {
|
|
194
|
+
if (!geometry.value) return null;
|
|
195
|
+
const {
|
|
196
|
+
width,
|
|
197
|
+
stroke,
|
|
198
|
+
wavelength,
|
|
199
|
+
center,
|
|
200
|
+
end,
|
|
201
|
+
gap,
|
|
202
|
+
track,
|
|
203
|
+
wave,
|
|
204
|
+
offset
|
|
205
|
+
} = geometry.value;
|
|
206
|
+
function renderTrack() {
|
|
207
|
+
return _createElementVNode("path", {
|
|
208
|
+
"class": _normalizeClass(['v-progress-linear__track', trackColorClasses.value]),
|
|
209
|
+
"style": _normalizeStyle([trackColorStyles.value, {
|
|
210
|
+
opacity: bgOpacity.value
|
|
211
|
+
}]),
|
|
212
|
+
"d": track,
|
|
213
|
+
"pathLength": "100"
|
|
214
|
+
}, null);
|
|
215
|
+
}
|
|
216
|
+
function renderWave(bar) {
|
|
217
|
+
return _createElementVNode("path", {
|
|
218
|
+
"class": _normalizeClass(['v-progress-linear__wave', bar]),
|
|
219
|
+
"d": wave,
|
|
220
|
+
"pathLength": 100 + offset
|
|
221
|
+
}, null);
|
|
222
|
+
}
|
|
223
|
+
return _createElementVNode("svg", {
|
|
224
|
+
"ref": svgEl,
|
|
225
|
+
"class": _normalizeClass(['v-progress-linear__wavy', {
|
|
226
|
+
'v-progress-linear__wavy--indeterminate': props.indeterminate
|
|
227
|
+
}, textColorClasses.value]),
|
|
228
|
+
"style": _normalizeStyle([textColorStyles.value, {
|
|
229
|
+
'--v-progress-linear-stroke': convertToUnit(stroke),
|
|
230
|
+
'--v-progress-linear-wavelength': convertToUnit(wavelength),
|
|
231
|
+
'--v-progress-linear-wave-offset': offset,
|
|
232
|
+
'--v-progress-linear-wave-gap': gap
|
|
233
|
+
}]),
|
|
234
|
+
"viewBox": `0 0 ${width} ${center * 2}`
|
|
235
|
+
}, [props.indeterminate ? _createElementVNode(_Fragment, null, [renderTrack(), renderTrack(), renderTrack(), renderWave('long'), renderWave('short')]) : _createElementVNode(_Fragment, null, [renderTrack(), hasStopIndicator.value && _createElementVNode("circle", {
|
|
236
|
+
"class": "v-progress-linear__stop",
|
|
237
|
+
"cx": end,
|
|
238
|
+
"cy": center
|
|
239
|
+
}, null), _createElementVNode("path", {
|
|
240
|
+
"ref": waveEl,
|
|
241
|
+
"class": "v-progress-linear__wave"
|
|
242
|
+
}, null)])]);
|
|
243
|
+
}
|
|
244
|
+
useRender(() => _createVNode(props.tag, {
|
|
245
|
+
"ref": root,
|
|
246
|
+
"class": _normalizeClass(['v-progress-linear', {
|
|
247
|
+
'v-progress-linear--absolute': props.absolute,
|
|
248
|
+
'v-progress-linear--active': props.active && isIntersecting.value,
|
|
249
|
+
'v-progress-linear--reverse': isReversed.value,
|
|
250
|
+
'v-progress-linear--rounded': props.rounded,
|
|
251
|
+
'v-progress-linear--rounded-bar': props.roundedBar,
|
|
252
|
+
'v-progress-linear--striped': props.striped,
|
|
253
|
+
'v-progress-linear--clickable': props.clickable,
|
|
254
|
+
'v-progress-linear--no-transition': props.transition === false,
|
|
255
|
+
'v-progress-linear--revealing': ['initial', 'pending'].includes(revealState.value),
|
|
256
|
+
'v-progress-linear--variant-split': props.variant === 'split',
|
|
257
|
+
'v-progress-linear--shape-wavy': isWavy.value
|
|
258
|
+
}, roundedClasses.value, themeClasses.value, rtlClasses.value, props.class]),
|
|
259
|
+
"style": _normalizeStyle([{
|
|
260
|
+
bottom: props.location === 'bottom' ? 0 : undefined,
|
|
261
|
+
top: props.location === 'top' ? 0 : undefined,
|
|
262
|
+
height: !props.active ? 0 : isWavy.value ? convertToUnit(parseFloat(props.height) + 2 * WAVE_AMPLITUDE) : height.value,
|
|
263
|
+
'--v-progress-linear-height': height.value,
|
|
264
|
+
'--v-progress-linear-transition-duration': transitionDuration.value,
|
|
265
|
+
'--v-progress-reveal-duration': `${revealDuration.value}ms`,
|
|
266
|
+
'--v-progress-chunk-gap': convertToUnit(props.chunkGap),
|
|
267
|
+
...(props.absolute ? locationStyles.value : {})
|
|
268
|
+
}, isWavy.value ? undefined : chunksMaskStyles.value, roundedStyles.value, props.style]),
|
|
269
|
+
"role": "progressbar",
|
|
270
|
+
"aria-hidden": props.active ? 'false' : 'true',
|
|
271
|
+
"aria-valuemin": "0",
|
|
272
|
+
"aria-valuemax": props.max,
|
|
273
|
+
"aria-valuenow": props.indeterminate ? undefined : Math.min(parseFloat(progress.value), max.value),
|
|
274
|
+
"onClick": props.clickable && handleClick
|
|
275
|
+
}, {
|
|
276
|
+
default: () => [isWavy.value ? renderWavy() : _createElementVNode(_Fragment, null, [props.stream && _createElementVNode("div", {
|
|
277
|
+
"key": "stream",
|
|
278
|
+
"class": _normalizeClass(['v-progress-linear__stream', textColorClasses.value]),
|
|
279
|
+
"style": {
|
|
280
|
+
...textColorStyles.value,
|
|
281
|
+
[isReversed.value ? 'left' : 'right']: `calc(${height.value} * -1)`,
|
|
282
|
+
borderTop: `calc(${height.value} / 2) dotted`,
|
|
283
|
+
opacity: props.bufferOpacity != null ? parseFloat(props.bufferOpacity) : undefined,
|
|
284
|
+
top: `calc(50% - ${height.value} / 4)`,
|
|
285
|
+
width: convertToUnit(100 - normalizedBuffer.value, '%'),
|
|
286
|
+
'--v-progress-linear-stream-to': `calc(${height.value} * ${isReversed.value ? 1 : -1})`
|
|
287
|
+
}
|
|
288
|
+
}, null), (props.variant !== 'split' || !props.indeterminate) && renderBackgroundBar(), _createElementVNode("div", {
|
|
289
|
+
"class": _normalizeClass(['v-progress-linear__buffer', bufferColorClasses.value]),
|
|
290
|
+
"style": _normalizeStyle([bufferColorStyles.value, {
|
|
291
|
+
opacity: props.bufferOpacity != null ? parseFloat(props.bufferOpacity) : undefined,
|
|
292
|
+
width: convertToUnit(bufferWidth.value, '%')
|
|
293
|
+
}, splitStyles.value?.buffer])
|
|
294
|
+
}, null), hasStopIndicator.value && _createElementVNode("div", {
|
|
295
|
+
"class": _normalizeClass(['v-progress-linear__stop', barColorClasses.value]),
|
|
296
|
+
"style": _normalizeStyle(barColorStyles.value)
|
|
297
|
+
}, null), _createVNode(Transition, {
|
|
298
|
+
"name": transitionName.value
|
|
299
|
+
}, {
|
|
300
|
+
default: () => [!props.indeterminate ? _createElementVNode("div", {
|
|
301
|
+
"class": _normalizeClass(['v-progress-linear__determinate', barColorClasses.value]),
|
|
302
|
+
"style": _normalizeStyle([barColorStyles.value, {
|
|
303
|
+
width: convertToUnit(barWidth.value, '%')
|
|
304
|
+
}, splitStyles.value?.bar])
|
|
305
|
+
}, null) : _createElementVNode("div", {
|
|
306
|
+
"class": "v-progress-linear__indeterminate"
|
|
307
|
+
}, [props.variant === 'split' && _createElementVNode(_Fragment, null, [renderBackgroundBar(), renderBackgroundBar(), renderBackgroundBar()]), ['long', 'short'].map(bar => _createElementVNode("div", {
|
|
308
|
+
"key": bar,
|
|
309
|
+
"class": _normalizeClass(['v-progress-linear__indeterminate', bar, barColorClasses.value]),
|
|
310
|
+
"style": _normalizeStyle(barColorStyles.value)
|
|
311
|
+
}, null))])]
|
|
312
|
+
})]), slots.default && _createElementVNode("div", {
|
|
313
|
+
"class": "v-progress-linear__content"
|
|
314
|
+
}, [slots.default({
|
|
315
|
+
value: normalizedValue.value,
|
|
316
|
+
buffer: normalizedBuffer.value
|
|
317
|
+
})])]
|
|
318
|
+
}));
|
|
319
|
+
return {};
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
//# sourceMappingURL=VProgressLinear.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createVNode as _createVNode } from "vue";
|
|
2
|
+
// Styles
|
|
3
|
+
import "./VLoadingIndicator.css";
|
|
4
|
+
|
|
5
|
+
// Composables
|
|
6
|
+
import { useTextColor } from "../../composables/color.js";
|
|
7
|
+
import { makeComponentProps } from "../../composables/component.js";
|
|
8
|
+
import { useElementIntersection } from "../../composables/intersectionObserver.js";
|
|
9
|
+
import { makeSizeProps, useSize } from "../../composables/size.js";
|
|
10
|
+
import { makeTagProps } from "../../composables/tag.js";
|
|
11
|
+
import { makeThemeProps, provideTheme } from "../../composables/theme.js";
|
|
12
|
+
import { useToggleScope } from "../../composables/toggleScope.js"; // Utilities
|
|
13
|
+
import { onScopeDispose, shallowRef, toRef } from 'vue';
|
|
14
|
+
import { morphPath } from "./shapes.js";
|
|
15
|
+
import { convertToUnit, genericComponent, PREFERS_REDUCED_MOTION, propsFactory, useRender } from "../../util/index.js";
|
|
16
|
+
export const makeVLoadingIndicatorProps = propsFactory({
|
|
17
|
+
color: String,
|
|
18
|
+
contained: Boolean,
|
|
19
|
+
shapeSize: [Number, String],
|
|
20
|
+
...makeComponentProps(),
|
|
21
|
+
...makeSizeProps(),
|
|
22
|
+
...makeTagProps(),
|
|
23
|
+
...makeThemeProps()
|
|
24
|
+
}, 'VLoadingIndicator');
|
|
25
|
+
export const VLoadingIndicator = genericComponent()({
|
|
26
|
+
name: 'VLoadingIndicator',
|
|
27
|
+
props: makeVLoadingIndicatorProps(),
|
|
28
|
+
setup(props) {
|
|
29
|
+
const root = shallowRef();
|
|
30
|
+
const {
|
|
31
|
+
themeClasses
|
|
32
|
+
} = provideTheme(props);
|
|
33
|
+
const {
|
|
34
|
+
sizeClasses,
|
|
35
|
+
sizeStyles
|
|
36
|
+
} = useSize(props);
|
|
37
|
+
const {
|
|
38
|
+
textColorClasses,
|
|
39
|
+
textColorStyles
|
|
40
|
+
} = useTextColor(() => props.color);
|
|
41
|
+
const {
|
|
42
|
+
isIntersecting
|
|
43
|
+
} = useElementIntersection(root);
|
|
44
|
+
const elapsed = shallowRef(0);
|
|
45
|
+
const path = toRef(() => morphPath(elapsed.value));
|
|
46
|
+
useToggleScope(() => isIntersecting.value && !PREFERS_REDUCED_MOTION(), () => {
|
|
47
|
+
const start = performance.now() - elapsed.value;
|
|
48
|
+
let frame = requestAnimationFrame(tick);
|
|
49
|
+
function tick(now) {
|
|
50
|
+
// rAF timestamp is the frame start, which can precede the performance.now() taken above
|
|
51
|
+
elapsed.value = Math.max(0, now - start);
|
|
52
|
+
frame = requestAnimationFrame(tick);
|
|
53
|
+
}
|
|
54
|
+
onScopeDispose(() => cancelAnimationFrame(frame));
|
|
55
|
+
});
|
|
56
|
+
useRender(() => _createVNode(props.tag, {
|
|
57
|
+
"ref": root,
|
|
58
|
+
"class": _normalizeClass(['v-loading-indicator', {
|
|
59
|
+
'v-loading-indicator--contained': props.contained
|
|
60
|
+
}, themeClasses.value, sizeClasses.value, textColorClasses.value, props.class]),
|
|
61
|
+
"style": _normalizeStyle([sizeStyles.value, textColorStyles.value, {
|
|
62
|
+
'--v-loading-indicator-shape-size': convertToUnit(props.shapeSize)
|
|
63
|
+
}, props.style]),
|
|
64
|
+
"role": "progressbar"
|
|
65
|
+
}, {
|
|
66
|
+
default: () => [_createElementVNode("svg", {
|
|
67
|
+
"class": "v-loading-indicator__shape",
|
|
68
|
+
"viewBox": "-1 -1 2 2"
|
|
69
|
+
}, [_createElementVNode("path", {
|
|
70
|
+
"d": path.value
|
|
71
|
+
}, null)])]
|
|
72
|
+
}));
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=VLoadingIndicator.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import vue from "@vitejs/plugin-vue";
|
|
5
|
+
import { defineConfig } from "vite";
|
|
6
|
+
import { PATCH, TARGETS, patchSource } from "../scripts/patch-vuetify-loaders.mjs";
|
|
7
|
+
|
|
8
|
+
// JSKIT_VUETIFY_LOADERS=published serves Vuetify's three loader modules as Vuetify publishes them, and =patched as
|
|
9
|
+
// material-web's install patch leaves them, whatever this checkout's install did to node_modules. Vuetify stays out of
|
|
10
|
+
// dependency pre-bundling, so its modules come through this plugin.
|
|
11
|
+
const LOADERS = process.env.JSKIT_VUETIFY_LOADERS;
|
|
12
|
+
if (!["published", "patched"].includes(LOADERS)) throw new Error("Set JSKIT_VUETIFY_LOADERS to published or patched.");
|
|
13
|
+
const LOADER_MODULES = Object.entries(TARGETS).filter(([file]) => file.startsWith("lib/"));
|
|
14
|
+
|
|
15
|
+
function vuetifyLoaders() {
|
|
16
|
+
return {
|
|
17
|
+
name: "jskit-vuetify-loaders",
|
|
18
|
+
enforce: "pre",
|
|
19
|
+
async load(id) {
|
|
20
|
+
const file = id.split("?")[0];
|
|
21
|
+
const [target, loaders] = LOADER_MODULES.find(([module]) => file.endsWith(`/vuetify/${module}`)) ?? [];
|
|
22
|
+
if (!target) return null;
|
|
23
|
+
const published = (await readFile(file, "utf8")).replaceAll(PATCH, "");
|
|
24
|
+
if (LOADERS === "published") return published;
|
|
25
|
+
const patched = patchSource(published, loaders);
|
|
26
|
+
if (!patched.source) throw new Error(`${target}: ${patched.changed}`);
|
|
27
|
+
return patched.source;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
root: fileURLToPath(new URL("./fixtures/idle-loaders", import.meta.url)),
|
|
34
|
+
plugins: [vuetifyLoaders(), vue()],
|
|
35
|
+
optimizeDeps: { exclude: ["vuetify"], include: ["vue", "@vuetify/v0"] },
|
|
36
|
+
server: { host: "127.0.0.1" }
|
|
37
|
+
});
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { chromium, expect } from "@playwright/test";
|
|
6
|
+
import { createChromiumLaunchOptions, startViteFixture, stopProcess } from "../../../tooling/testUtils/browserFixture.mjs";
|
|
7
|
+
|
|
8
|
+
const TEST_ROOT = fileURLToPath(new URL(".", import.meta.url));
|
|
9
|
+
const SKIP = process.env.JSKIT_MATERIAL_WEB_BROWSER === "1" ? false : "set JSKIT_MATERIAL_WEB_BROWSER=1";
|
|
10
|
+
const FIELDS = 300;
|
|
11
|
+
|
|
12
|
+
// Opens the fixture with Vuetify's loader modules as published or as material-web's install patch leaves them
|
|
13
|
+
// (vite.config.js), and fails on any page error.
|
|
14
|
+
async function withLoaders(loaders, run) {
|
|
15
|
+
const vite = await startViteFixture({ fixtureRoot: TEST_ROOT, configFile: "vite.config.js", env: { JSKIT_VUETIFY_LOADERS: loaders } });
|
|
16
|
+
let browser;
|
|
17
|
+
try {
|
|
18
|
+
browser = await chromium.launch(createChromiumLaunchOptions());
|
|
19
|
+
const page = await browser.newPage({ baseURL: vite.baseURL, viewport: { width: 1280, height: 800 } });
|
|
20
|
+
const errors = [];
|
|
21
|
+
page.on("pageerror", (error) => errors.push(error.message));
|
|
22
|
+
const result = await run(page);
|
|
23
|
+
assert.deepEqual(errors, [], `${loaders}: page errors`);
|
|
24
|
+
return result;
|
|
25
|
+
} finally {
|
|
26
|
+
await browser?.close();
|
|
27
|
+
await stopProcess(vite);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function mountFields(page) {
|
|
32
|
+
await page.goto("/?view=fields", { waitUntil: "networkidle" });
|
|
33
|
+
await page.waitForFunction(() => typeof window.mountFields === "function");
|
|
34
|
+
return page.evaluate((count) => window.mountFields(count), FIELDS);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const runningAnimations = (locator) => locator.evaluate(
|
|
38
|
+
(element) => element.getAnimations({ subtree: true }).filter((animation) => animation.playState === "running").length
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// A progress indicator's classes (without the reveal transition's passing one) and size.
|
|
42
|
+
async function describeProgress(locator) {
|
|
43
|
+
return locator.evaluate((element) => {
|
|
44
|
+
const { width, height } = element.getBoundingClientRect();
|
|
45
|
+
return { classes: [...element.classList].filter((name) => !name.endsWith("--revealing")).sort(), width, height };
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function expectAnimating(locator, name) {
|
|
50
|
+
await expect.poll(() => runningAnimations(locator), { message: `${name} animates` }).toBeGreaterThan(0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// What the three loaders show once they settle: the loading field's bar and the circular progress at the top, and the
|
|
54
|
+
// bar below the fold before and after it scrolls into view (which takes the other two out of view); each animates
|
|
55
|
+
// while in view.
|
|
56
|
+
async function showLoaders(page) {
|
|
57
|
+
await page.goto("/?view=loaders", { waitUntil: "networkidle" });
|
|
58
|
+
const loadingBar = page.getByTestId("loading-field").locator(".v-field__loader .v-progress-linear");
|
|
59
|
+
const circular = page.getByTestId("circular").locator(".v-progress-circular");
|
|
60
|
+
const belowFold = page.getByTestId("below-fold").locator(".v-progress-linear");
|
|
61
|
+
await expect(loadingBar).toHaveClass(/v-progress-linear--active/u);
|
|
62
|
+
await expectAnimating(loadingBar, "the loading field's bar");
|
|
63
|
+
await expect(circular).toHaveClass(/v-progress-circular--visible/u);
|
|
64
|
+
await expect(circular.locator("svg circle")).not.toHaveCount(0);
|
|
65
|
+
await expectAnimating(circular, "the circular progress");
|
|
66
|
+
const shown = { loadingBar: await describeProgress(loadingBar), circular: await describeProgress(circular) };
|
|
67
|
+
// Off screen, the intersection observer reports the bar hidden, so it stays inactive until it scrolls into view.
|
|
68
|
+
await expect(belowFold).not.toHaveClass(/v-progress-linear--active/u);
|
|
69
|
+
shown.belowFoldBefore = await describeProgress(belowFold);
|
|
70
|
+
await belowFold.scrollIntoViewIfNeeded();
|
|
71
|
+
await expect(belowFold).toHaveClass(/v-progress-linear--active/u);
|
|
72
|
+
await expectAnimating(belowFold, "the bar scrolled into view");
|
|
73
|
+
shown.belowFoldAfter = await describeProgress(belowFold);
|
|
74
|
+
return shown;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
test("300 fields mount with no layout read from their idle loaders once patched; Vuetify as published reads one per field", {
|
|
78
|
+
skip: SKIP,
|
|
79
|
+
timeout: 180_000
|
|
80
|
+
}, async (t) => {
|
|
81
|
+
const published = await withLoaders("published", mountFields);
|
|
82
|
+
const patched = await withLoaders("patched", mountFields);
|
|
83
|
+
t.diagnostic(`${FIELDS} fields, getBoundingClientRect() on .v-progress-linear while mounting: as published ` +
|
|
84
|
+
`${published.progressReads} (${Math.round(published.milliseconds)} ms to mount), patched ${patched.progressReads} ` +
|
|
85
|
+
`(${Math.round(patched.milliseconds)} ms); reads of anything else ${published.otherReads} and ${patched.otherReads}`);
|
|
86
|
+
assert.equal(patched.progressReads, 0, "the patched idle loaders read no layout while the fields mount");
|
|
87
|
+
assert.equal(
|
|
88
|
+
published.progressReads,
|
|
89
|
+
FIELDS,
|
|
90
|
+
"Vuetify as published no longer reads layout in its idle loaders, so vuetifyjs/vuetify#23393 is fixed: remove " +
|
|
91
|
+
"material-web's install patch (scripts/patch-vuetify-loaders.mjs), its tests and this one"
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("patched loaders look as published: a loading field's bar, a circular progress and a bar scrolled into view show and animate", {
|
|
96
|
+
skip: SKIP,
|
|
97
|
+
timeout: 180_000
|
|
98
|
+
}, async () => {
|
|
99
|
+
const published = await withLoaders("published", showLoaders);
|
|
100
|
+
const patched = await withLoaders("patched", showLoaders);
|
|
101
|
+
assert.deepEqual(patched, published);
|
|
102
|
+
});
|