@jskit-ai/material-web 0.1.4 → 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.
@@ -0,0 +1,209 @@
1
+ import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, Fragment as _Fragment, createVNode as _createVNode } from "vue";
2
+ // Styles
3
+ import "./VProgressCircular.css";
4
+
5
+ // Components
6
+ import { circularWavePath, hasWave } from "../VProgressLinear/waves.js"; // Composables
7
+ import { useTextColor } from "../../composables/color.js";
8
+ import { makeComponentProps } from "../../composables/component.js";
9
+ import { useElementIntersection } from "../../composables/intersectionObserver.js";
10
+ import { useElementSize } from "../../composables/resizeObserver.js";
11
+ import { makeRevealProps, useReveal } from "../../composables/reveal.js";
12
+ import { makeSizeProps, useSize } from "../../composables/size.js";
13
+ import { makeTagProps } from "../../composables/tag.js";
14
+ import { makeThemeProps, provideTheme } from "../../composables/theme.js"; // Utilities
15
+ import { computed, shallowRef, toRef } from 'vue';
16
+ import { clamp, convertToUnit, genericComponent, isObject, PREFERS_REDUCED_MOTION, propsFactory, useRender } from "../../util/index.js"; // Types
17
+ // in px, scaled to the viewBox
18
+ const WAVE_AMPLITUDE = 1.6;
19
+ const WAVELENGTH = 15;
20
+ const WAVE_GAP = 4;
21
+ export const makeVProgressCircularProps = propsFactory({
22
+ bgColor: String,
23
+ color: String,
24
+ indeterminate: [Boolean, String],
25
+ rounded: Boolean,
26
+ modelValue: {
27
+ type: [Number, String],
28
+ default: 0
29
+ },
30
+ rotate: {
31
+ type: [Number, String],
32
+ default: 0
33
+ },
34
+ shape: {
35
+ type: String,
36
+ default: 'flat',
37
+ validator: v => ['flat', 'wavy'].includes(v)
38
+ },
39
+ variant: {
40
+ type: String,
41
+ default: undefined,
42
+ validator: v => ['split'].includes(v)
43
+ },
44
+ transition: {
45
+ type: [Boolean, Object],
46
+ default: undefined
47
+ },
48
+ width: {
49
+ type: [Number, String],
50
+ default: 4
51
+ },
52
+ ...makeComponentProps(),
53
+ ...makeRevealProps(),
54
+ ...makeSizeProps(),
55
+ ...makeTagProps({
56
+ tag: 'div'
57
+ }),
58
+ ...makeThemeProps()
59
+ }, 'VProgressCircular');
60
+ export const VProgressCircular = genericComponent()({
61
+ name: 'VProgressCircular',
62
+ props: makeVProgressCircularProps(),
63
+ setup(props, {
64
+ slots
65
+ }) {
66
+ const MAGIC_RADIUS_CONSTANT = 20;
67
+ const CIRCUMFERENCE = 2 * Math.PI * MAGIC_RADIUS_CONSTANT;
68
+ const root = shallowRef();
69
+ const {
70
+ themeClasses
71
+ } = provideTheme(props);
72
+ const {
73
+ sizeClasses,
74
+ sizeStyles
75
+ } = useSize(props);
76
+ const {
77
+ textColorClasses,
78
+ textColorStyles
79
+ } = useTextColor(() => props.color);
80
+ const {
81
+ textColorClasses: underlayColorClasses,
82
+ textColorStyles: underlayColorStyles
83
+ } = useTextColor(() => props.bgColor);
84
+ const {
85
+ width: containerWidth
86
+ } = useElementSize(root);
87
+ const {
88
+ isIntersecting
89
+ } = useElementIntersection(root);
90
+ const {
91
+ state: revealState,
92
+ duration: revealDuration
93
+ } = useReveal(props);
94
+ const normalizedValue = toRef(() => revealState.value === 'initial' ? 0 : clamp(parseFloat(props.modelValue), 0, 100));
95
+ const width = toRef(() => Number(props.width));
96
+ const transitionDuration = toRef(() => props.transition === false ? undefined : convertToUnit(isObject(props.transition) ? props.transition.duration : undefined, 'ms'));
97
+ const size = toRef(() => {
98
+ // Get size from element if size prop value is small, large etc
99
+ return sizeStyles.value ? Number(props.size) : containerWidth.value ? containerWidth.value : Math.max(width.value, 32);
100
+ });
101
+ const diameter = toRef(() => MAGIC_RADIUS_CONSTANT / (1 - width.value / size.value) * 2);
102
+ const strokeWidth = toRef(() => width.value / size.value * diameter.value);
103
+ const strokeDashOffset = toRef(() => {
104
+ const baseLength = (100 - normalizedValue.value) / 100 * CIRCUMFERENCE;
105
+ return props.rounded && normalizedValue.value > 0 && normalizedValue.value < 100 ? convertToUnit(Math.min(CIRCUMFERENCE - 0.01, baseLength + strokeWidth.value)) : convertToUnit(baseLength);
106
+ });
107
+ const startAngle = computed(() => {
108
+ const baseAngle = Number(props.rotate);
109
+ return props.rounded ? baseAngle + strokeWidth.value / 2 / CIRCUMFERENCE * 360 : baseAngle;
110
+ });
111
+ const isWavy = toRef(() => props.shape === 'wavy');
112
+ const geometry = computed(() => {
113
+ if (props.variant !== 'split' && !isWavy.value) return undefined;
114
+ const scale = diameter.value / size.value;
115
+ const radius = MAGIC_RADIUS_CONSTANT;
116
+ const amplitude = isWavy.value && (props.indeterminate || hasWave(normalizedValue.value)) ? WAVE_AMPLITUDE * scale : 0;
117
+ const waves = Math.max(3, Math.floor(CIRCUMFERENCE / (WAVELENGTH * scale)));
118
+ const center = diameter.value / 2;
119
+ const arc = `A ${radius} ${radius} 0 1 1`;
120
+ const roundCaps = props.rounded || isWavy.value;
121
+ return {
122
+ waves,
123
+ linecap: roundCaps ? 'round' : 'butt',
124
+ // round caps reach half a stroke into the gap from each side
125
+ gap: (WAVE_GAP * scale + (roundCaps ? strokeWidth.value : 0)) / CIRCUMFERENCE * 100,
126
+ // two turns so the indeterminate track can wrap past the start
127
+ track: `M ${center + radius} ${center}` + ` ${arc} ${center - radius} ${center} ${arc} ${center + radius} ${center}`.repeat(2),
128
+ // peaks sit on the track and troughs dip inward, so a flat wave lands on the track
129
+ wave: circularWavePath(center, radius - amplitude, amplitude, waves)
130
+ };
131
+ });
132
+ useRender(() => _createVNode(props.tag, {
133
+ "ref": root,
134
+ "class": _normalizeClass(['v-progress-circular', {
135
+ 'v-progress-circular--indeterminate': !!props.indeterminate,
136
+ 'v-progress-circular--visible': isIntersecting.value,
137
+ 'v-progress-circular--variant-split': props.variant === 'split',
138
+ 'v-progress-circular--shape-wavy': isWavy.value,
139
+ 'v-progress-circular--disable-shrink': props.indeterminate && (props.indeterminate === 'disable-shrink' || PREFERS_REDUCED_MOTION()),
140
+ 'v-progress-circular--revealing': ['initial', 'pending'].includes(revealState.value),
141
+ 'v-progress-circular--no-transition': props.transition === false
142
+ }, themeClasses.value, sizeClasses.value, textColorClasses.value, props.class]),
143
+ "style": _normalizeStyle([sizeStyles.value, textColorStyles.value, {
144
+ '--v-progress-reveal-duration': `${revealDuration.value}ms`,
145
+ '--v-progress-circular-transition-duration': transitionDuration.value
146
+ }, props.style]),
147
+ "role": "progressbar",
148
+ "aria-valuemin": "0",
149
+ "aria-valuemax": "100",
150
+ "aria-valuenow": props.indeterminate ? undefined : normalizedValue.value
151
+ }, {
152
+ default: () => [_createElementVNode("svg", {
153
+ "style": {
154
+ transform: `rotate(calc(-90deg + ${startAngle.value}deg))`
155
+ },
156
+ "xmlns": "http://www.w3.org/2000/svg",
157
+ "viewBox": `0 0 ${diameter.value} ${diameter.value}`
158
+ }, [geometry.value ? _createElementVNode("g", {
159
+ "class": "v-progress-circular__split",
160
+ "style": {
161
+ '--v-progress-circular-value': normalizedValue.value,
162
+ '--v-progress-circular-stroke': convertToUnit(strokeWidth.value),
163
+ '--v-progress-circular-waves': geometry.value.waves,
164
+ '--v-progress-circular-gap': geometry.value.gap
165
+ }
166
+ }, [_createElementVNode("path", {
167
+ "class": _normalizeClass(['v-progress-circular__underlay', 'v-progress-circular__track', underlayColorClasses.value]),
168
+ "style": _normalizeStyle(underlayColorStyles.value),
169
+ "d": geometry.value.track,
170
+ "pathLength": "200",
171
+ "stroke-linecap": geometry.value.linecap
172
+ }, null), _createElementVNode("path", {
173
+ "class": "v-progress-circular__wave",
174
+ "style": {
175
+ d: `path("${geometry.value.wave}")`
176
+ },
177
+ "d": geometry.value.wave,
178
+ "pathLength": 100 + 100 / geometry.value.waves,
179
+ "stroke-linecap": geometry.value.linecap
180
+ }, null)]) : _createElementVNode(_Fragment, null, [_createElementVNode("circle", {
181
+ "class": _normalizeClass(['v-progress-circular__underlay', underlayColorClasses.value]),
182
+ "style": _normalizeStyle(underlayColorStyles.value),
183
+ "fill": "transparent",
184
+ "cx": "50%",
185
+ "cy": "50%",
186
+ "r": MAGIC_RADIUS_CONSTANT,
187
+ "stroke-width": strokeWidth.value,
188
+ "stroke-dasharray": CIRCUMFERENCE,
189
+ "stroke-dashoffset": 0
190
+ }, null), _createElementVNode("circle", {
191
+ "class": "v-progress-circular__overlay",
192
+ "fill": "transparent",
193
+ "cx": "50%",
194
+ "cy": "50%",
195
+ "r": MAGIC_RADIUS_CONSTANT,
196
+ "stroke-width": strokeWidth.value,
197
+ "stroke-dasharray": CIRCUMFERENCE,
198
+ "stroke-dashoffset": strokeDashOffset.value,
199
+ "stroke-linecap": props.rounded ? 'round' : undefined
200
+ }, null)])]), slots.default && _createElementVNode("div", {
201
+ "class": "v-progress-circular__content"
202
+ }, [slots.default({
203
+ value: normalizedValue.value
204
+ })])]
205
+ }));
206
+ return {};
207
+ }
208
+ });
209
+ //# sourceMappingURL=VProgressCircular.js.map
@@ -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
@@ -153,6 +153,10 @@ test("the Vuetify options follow the system scheme on the md3 blueprint with Mat
153
153
  assert.equal(options.defaults.VSnackbar.color, "inverse-surface");
154
154
  // A button with `to` is active only on exactly its route.
155
155
  assert.equal(options.defaults.VBtn.exact, true);
156
+ // Fields keep their supporting-text line, so an error or hint appears without moving the form below it.
157
+ for (const field of ["VAutocomplete", "VCombobox", "VFileInput", "VSelect", "VTextarea", "VTextField"]) {
158
+ assert.deepEqual(options.defaults[field], { variant: "outlined" }, field);
159
+ }
156
160
  assert.throws(() => createMaterialVuetifyOptions({ icons: { "my-leaf": "M0 0" } }), /camelCase/u);
157
161
  });
158
162
 
@@ -208,6 +212,20 @@ test("material.css holds the exact-size rules without Sass or !important", async
208
212
  assert.match(css, /\.text-on-surface-variant \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);/u);
209
213
  });
210
214
 
215
+ // Vuetify gives an on-* role only the class ".on-<role>", so color="on-<role>" finds no text-on-<role> class unless
216
+ // material.css has one: it has one for every Material 3 on-* role the scheme defines (surface-light is a Vuetify-only
217
+ // name, so its on-surface-light is not one), and none for a role the scheme lacks.
218
+ test("material.css has a text-on-* class for every Material 3 on-* role of the scheme", async () => {
219
+ const css = await readFile(path.join(PACKAGE_ROOT, "src/client/material.css"), "utf8");
220
+ const onRoles = Object.keys(materialThemes("#6750A4").light.colors)
221
+ .filter((role) => role.startsWith("on-") && role !== "on-surface-light")
222
+ .sort();
223
+ const classes = [...css.matchAll(/^ {2}\.text-(on-[a-z-]+) \{\s*color: rgb\(var\(--v-theme-(on-[a-z-]+)\)\);\s*\}/gmu)];
224
+ for (const [, name, role] of classes) assert.equal(name, role, `.text-${name} reads its own role`);
225
+ assert.deepEqual(classes.map(([, name]) => name).sort(), onRoles);
226
+ assert.ok(onRoles.includes("on-primary-fixed-variant") && onRoles.includes("on-surface-container-high"), onRoles.join(", "));
227
+ });
228
+
211
229
  test("segmented buttons and filter chips select in secondary-container; a menu's own list is the menu's container", () => {
212
230
  const { defaults } = createMaterialVuetifyOptions();
213
231
  assert.deepEqual(defaults.VBtnToggle, {
@@ -290,11 +308,13 @@ test("material.css draws segmented buttons, filter chips, fixed tabs and dialog
290
308
  css,
291
309
  /\.v-input:not\(\.v-input--error, \.v-input--disabled\) > \.v-input__details \.v-messages \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
292
310
  );
293
- // So is an inactive, uncoloured list item's subtitle.
311
+ // So is an inactive, uncoloured list item's subtitle; every enabled item's subtitle, an active one's included, is
312
+ // at full strength in the item's own colour.
294
313
  assert.match(
295
314
  css,
296
- /\.v-list-item:not\(\.v-list-item--active, \.v-list-item--disabled, \[class\*=" text-"\]\) \.v-list-item-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*opacity: 1;/u
315
+ /\.v-list-item:not\(\.v-list-item--active, \.v-list-item--disabled, \[class\*=" text-"\]\) \.v-list-item-subtitle \{\s*color: rgb\(var\(--v-theme-on-surface-variant\)\);\s*\}/u
297
316
  );
317
+ assert.match(css, /\.v-list-item:not\(\.v-list-item--disabled\) \.v-list-item-subtitle \{\s*opacity: 1;\s*\}/u);
298
318
  // A disabled container button is on-surface 12% and 38%, unlayered over its colour class.
299
319
  assert.match(
300
320
  css,