ropav 0.0.7 → 0.0.9
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/accordion.css +10 -10
- package/dist/accordion.js +2 -4
- package/dist/alert.css +109 -0
- package/dist/alert.js +168 -0
- package/dist/aspect-ratio.css +17 -0
- package/dist/aspect-ratio.js +26 -0
- package/dist/avatar.css +97 -0
- package/dist/avatar.js +161 -0
- package/dist/badge.css +40 -115
- package/dist/badge.js +19 -18
- package/dist/base.css +609 -180
- package/dist/bem.js +0 -2
- package/dist/button-group.js +0 -2
- package/dist/button-link.css +161 -0
- package/dist/button-link.js +108 -0
- package/dist/button.css +50 -229
- package/dist/button.js +7 -11
- package/dist/card.css +50 -30
- package/dist/card.js +69 -38
- package/dist/check.js +12 -0
- package/dist/checkbox.css +16 -57
- package/dist/checkbox.js +14 -33
- package/dist/collapse.css +8 -8
- package/dist/collapse.js +4 -10
- package/dist/color-input.css +108 -0
- package/dist/color-input.js +344 -0
- package/dist/color-picker.css +304 -0
- package/dist/color-picker.js +717 -0
- package/dist/color-picker2.js +18 -0
- package/dist/color-swatch.css +50 -0
- package/dist/color-swatch.js +73 -0
- package/dist/color.js +190 -0
- package/dist/componentColors.js +206 -15
- package/dist/components/alert/alert.d.ts +30 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert/index.js +2 -0
- package/dist/components/alert/types.d.ts +20 -0
- package/dist/components/alert/useAlertColor.d.ts +3 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +21 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +2 -0
- package/dist/components/aspect-ratio/types.d.ts +3 -0
- package/dist/components/avatar/avatar.d.ts +24 -0
- package/dist/components/avatar/index.d.ts +3 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/avatar/types.d.ts +20 -0
- package/dist/components/avatar/useAvatarColor.d.ts +3 -0
- package/dist/components/badge/types.d.ts +2 -1
- package/dist/components/badge/useBadgeColor.d.ts +3 -8
- package/dist/components/button/types.d.ts +1 -0
- package/dist/components/button/useButtonColor.d.ts +3 -13
- package/dist/components/button-link/button-link.d.ts +27 -0
- package/dist/components/button-link/index.d.ts +2 -0
- package/dist/components/button-link/index.js +2 -0
- package/dist/components/button-link/types.d.ts +20 -0
- package/dist/components/card/card.d.ts +4 -0
- package/dist/components/card/types.d.ts +4 -0
- package/dist/components/checkbox/types.d.ts +1 -0
- package/dist/components/checkbox/useCheckbox.d.ts +2 -4
- package/dist/components/collapse/types.d.ts +0 -2
- package/dist/components/color-input/color-input.d.ts +29 -0
- package/dist/components/color-input/index.d.ts +2 -0
- package/dist/components/color-input/index.js +2 -0
- package/dist/components/color-input/types.d.ts +34 -0
- package/dist/components/color-input/useColorInput.d.ts +27 -0
- package/dist/components/color-input/useColorInputEyeDropper.d.ts +13 -0
- package/dist/components/color-input/useColorInputPopover.d.ts +11 -0
- package/dist/components/color-input/useColorInputValue.d.ts +8 -0
- package/dist/components/color-picker/color-picker-saturation.d.ts +21 -0
- package/dist/components/color-picker/color-picker-slider.d.ts +21 -0
- package/dist/components/color-picker/color-picker-utils.d.ts +23 -0
- package/dist/components/color-picker/color-picker.d.ts +23 -0
- package/dist/components/color-picker/index.d.ts +3 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/color-picker/types.d.ts +39 -0
- package/dist/components/color-picker/useColorPickerDrag.d.ts +11 -0
- package/dist/components/color-picker/useColorPickerSwatches.d.ts +21 -0
- package/dist/components/color-picker/useColorPickerValue.d.ts +15 -0
- package/dist/components/color-swatch/color-swatch.d.ts +21 -0
- package/dist/components/color-swatch/index.d.ts +2 -0
- package/dist/components/color-swatch/index.js +2 -0
- package/dist/components/color-swatch/types.d.ts +6 -0
- package/dist/components/color-swatch/useColorSwatchColor.d.ts +5 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +1 -1
- package/dist/components/field/types.d.ts +0 -2
- package/dist/components/field/useField.d.ts +1 -2
- package/dist/components/icon-button/types.d.ts +1 -0
- package/dist/components/input/types.d.ts +3 -0
- package/dist/components/modal/types.d.ts +0 -1
- package/dist/components/number-input/index.d.ts +2 -0
- package/dist/components/number-input/index.js +2 -0
- package/dist/components/number-input/number-input.d.ts +29 -0
- package/dist/components/number-input/types.d.ts +34 -0
- package/dist/components/number-input/useNumberInput.d.ts +31 -0
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +2 -1
- package/dist/components/popover/types.d.ts +6 -2
- package/dist/components/popover/usePopover.d.ts +5 -2
- package/dist/components/progress/types.d.ts +1 -1
- package/dist/components/radio/types.d.ts +3 -0
- package/dist/components/radio/useRadio.d.ts +2 -4
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/types.d.ts +3 -0
- package/dist/components/slider/index.d.ts +2 -1
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/range-slider.d.ts +45 -0
- package/dist/components/slider/types.d.ts +14 -2
- package/dist/components/slider/useRangeSlider.d.ts +59 -0
- package/dist/components/slider/useRangeSliderTooltipCollision.d.ts +7 -0
- package/dist/components/slider/useRangeSliderTooltipTransition.d.ts +4 -0
- package/dist/components/switch/useSwitch.d.ts +2 -3
- package/dist/components/tooltip/types.d.ts +1 -0
- package/dist/dropdown-menu.css +17 -17
- package/dist/dropdown-menu.js +0 -2
- package/dist/field.css +17 -17
- package/dist/field.js +56 -51
- package/dist/icon-button.css +57 -236
- package/dist/icon-button.js +5 -8
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -4
- package/dist/input.css +40 -46
- package/dist/input.js +39 -23
- package/dist/minus.js +12 -0
- package/dist/modal.css +37 -37
- package/dist/modal.js +10 -16
- package/dist/number-input.css +86 -0
- package/dist/number-input.js +350 -0
- package/dist/overlay.css +5 -5
- package/dist/overlay.js +3 -5
- package/dist/popover.css +62 -29
- package/dist/popover.js +25 -12
- package/dist/popover2.js +17 -0
- package/dist/progress.css +9 -30
- package/dist/progress.js +3 -8
- package/dist/radio.css +34 -62
- package/dist/radio.js +28 -18
- package/dist/select.css +105 -61
- package/dist/select.js +12 -10
- package/dist/slider.css +508 -41
- package/dist/slider.js +1122 -50
- package/dist/switch.css +19 -44
- package/dist/switch.js +4 -7
- package/dist/tabs.css +36 -36
- package/dist/tabs.js +1 -3
- package/dist/textarea.css +33 -25
- package/dist/textarea.js +0 -2
- package/dist/tooltip.css +7 -35
- package/dist/tooltip.js +13 -10
- package/dist/useButtonColor.js +16 -16
- package/dist/useClickOutside.js +0 -2
- package/dist/useCollapse.js +1 -3
- package/dist/useControlState.js +0 -2
- package/dist/useRequiredInject.js +0 -2
- package/dist/x.js +0 -2
- package/package.json +43 -7
- package/src/styles/_mixins.scss +25 -41
- package/src/styles/_tokens.scss +615 -182
- package/src/styles/_variables.scss +177 -49
- package/dist/accordion.js.map +0 -1
- package/dist/badge.js.map +0 -1
- package/dist/bem.js.map +0 -1
- package/dist/button-group.js.map +0 -1
- package/dist/button.js.map +0 -1
- package/dist/card.js.map +0 -1
- package/dist/checkbox.js.map +0 -1
- package/dist/collapse.js.map +0 -1
- package/dist/componentColors.js.map +0 -1
- package/dist/dropdown-menu.js.map +0 -1
- package/dist/field.js.map +0 -1
- package/dist/icon-button.js.map +0 -1
- package/dist/input.js.map +0 -1
- package/dist/modal.js.map +0 -1
- package/dist/overlay.js.map +0 -1
- package/dist/popover.js.map +0 -1
- package/dist/progress.js.map +0 -1
- package/dist/radio.js.map +0 -1
- package/dist/select.js.map +0 -1
- package/dist/slider.js.map +0 -1
- package/dist/switch.js.map +0 -1
- package/dist/tabs.js.map +0 -1
- package/dist/textarea.js.map +0 -1
- package/dist/tooltip.js.map +0 -1
- package/dist/useButtonColor.js.map +0 -1
- package/dist/useClickOutside.js.map +0 -1
- package/dist/useCollapse.js.map +0 -1
- package/dist/useControlState.js.map +0 -1
- package/dist/useRequiredInject.js.map +0 -1
- package/dist/x.js.map +0 -1
package/dist/slider.js
CHANGED
|
@@ -1,30 +1,11 @@
|
|
|
1
1
|
import './slider.css';
|
|
2
2
|
import { t as bem } from "./bem.js";
|
|
3
|
+
import { n as getComponentColorValue, t as componentColors } from "./componentColors.js";
|
|
3
4
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
4
5
|
import { t as useControlState } from "./useControlState.js";
|
|
5
6
|
import { n as useDelayedOpen, t as tooltip_default } from "./tooltip.js";
|
|
6
|
-
import { child, computed, createComponent, createFor, createIf, createInvoker, createSlot, defineVaporComponent, delegateEvents, next, on, renderEffect, setAttr, setClass, setClassName, setInsertionState, setProp, setStyle, setText, setValue, template, toDisplayString, txt, unref } from "vue";
|
|
7
|
-
//#region src/components/slider/types.ts
|
|
8
|
-
var sliderColors = [
|
|
9
|
-
"primary",
|
|
10
|
-
"secondary",
|
|
11
|
-
"success",
|
|
12
|
-
"warning",
|
|
13
|
-
"danger",
|
|
14
|
-
"info",
|
|
15
|
-
"neutral"
|
|
16
|
-
];
|
|
17
|
-
var sliderSizes = [
|
|
18
|
-
"xs",
|
|
19
|
-
"sm",
|
|
20
|
-
"md",
|
|
21
|
-
"lg",
|
|
22
|
-
"xl"
|
|
23
|
-
];
|
|
24
|
-
var sliderOrientations = ["horizontal", "vertical"];
|
|
25
|
-
//#endregion
|
|
7
|
+
import { child, computed, createComponent, createFor, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, next, nextTick, on, onBeforeUnmount, onMounted, onUpdated, ref, renderEffect, setAttr, setClass, setClassName, setInsertionState, setProp, setStyle, setText, setValue, template, toDisplayString, txt, unref, useId, useSlots, watch } from "vue";
|
|
26
8
|
//#region src/components/slider/useSlider.ts
|
|
27
|
-
var sliderColorNames = new Set(sliderColors);
|
|
28
9
|
var sliderMarkColorProperties = [
|
|
29
10
|
"--_rp-slider-mark-color",
|
|
30
11
|
"--_rp-slider-mark-label-color",
|
|
@@ -61,15 +42,10 @@ function getSliderValuePercent(value, min, max) {
|
|
|
61
42
|
return Math.min(100, Math.max(0, percent));
|
|
62
43
|
}
|
|
63
44
|
function getSliderMarkColorValue(color) {
|
|
64
|
-
|
|
65
|
-
return sliderColorNames.has(color) ? `var(--rp-color-${color})` : color;
|
|
45
|
+
return getComponentColorValue(color);
|
|
66
46
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
function getSliderCustomColorValue(color) {
|
|
71
|
-
if (!color || isSliderPresetColor(color)) return void 0;
|
|
72
|
-
return color;
|
|
47
|
+
function getSliderColorValue(color) {
|
|
48
|
+
return getComponentColorValue(color);
|
|
73
49
|
}
|
|
74
50
|
function setSliderStyleValue(style, property, value) {
|
|
75
51
|
if (value) style[property] = value;
|
|
@@ -132,7 +108,7 @@ function getSliderTrackStyle(props, valuePercent) {
|
|
|
132
108
|
"--_rp-slider-percent": `${valuePercent}%`,
|
|
133
109
|
"--_rp-slider-ratio": `${valuePercent / 100}`
|
|
134
110
|
};
|
|
135
|
-
setSliderStyleValue(style, "--_rp-slider-
|
|
111
|
+
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
136
112
|
for (const [property, propName, getValue] of sliderThumbStyleProps) setSliderStyleValue(style, property, getValue(props.thumbStyle?.[propName]));
|
|
137
113
|
return style;
|
|
138
114
|
}
|
|
@@ -179,7 +155,6 @@ function useSlider(props, emitUpdate) {
|
|
|
179
155
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
180
156
|
const tooltipContent = computed(() => String(formattedValue.value));
|
|
181
157
|
const rootClass = computed(() => bem("rp-slider", {
|
|
182
|
-
[`color-${props.color}`]: isSliderPresetColor(props.color),
|
|
183
158
|
[`size-${props.size}`]: Boolean(props.size),
|
|
184
159
|
vertical: props.orientation === "vertical",
|
|
185
160
|
marked: markItems.value.length > 0,
|
|
@@ -233,14 +208,14 @@ function useSlider(props, emitUpdate) {
|
|
|
233
208
|
}
|
|
234
209
|
//#endregion
|
|
235
210
|
//#region src/components/slider/slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
236
|
-
var t0 = template("<span data-v-c9655b1d class=rp-slider__label>");
|
|
237
|
-
var t1 = template("<span data-v-c9655b1d class=rp-slider__value aria-hidden=true>");
|
|
238
|
-
var t2 = template("<span data-v-c9655b1d class=rp-slider__header>");
|
|
239
|
-
var t3 = template("<span data-v-c9655b1d class=rp-slider__mark-label> ");
|
|
240
|
-
var t4 = template("<span data-v-c9655b1d><span data-v-c9655b1d class=rp-slider__mark-dot></span>");
|
|
241
|
-
var t5 = template("<span data-v-c9655b1d class=rp-slider__marks aria-hidden=true>");
|
|
242
|
-
var t6 = template("<span data-v-c9655b1d class=rp-slider__thumb aria-hidden=true><span data-v-c9655b1d class=rp-slider__thumb-content>");
|
|
243
|
-
var t7 = template("<span data-v-c9655b1d class=rp-slider__tooltip-anchor aria-hidden=true>", 2);
|
|
211
|
+
var t0$1 = template("<span data-v-c9655b1d class=rp-slider__label>");
|
|
212
|
+
var t1$1 = template("<span data-v-c9655b1d class=rp-slider__value aria-hidden=true>");
|
|
213
|
+
var t2$1 = template("<span data-v-c9655b1d class=rp-slider__header>");
|
|
214
|
+
var t3$1 = template("<span data-v-c9655b1d class=rp-slider__mark-label> ");
|
|
215
|
+
var t4$1 = template("<span data-v-c9655b1d><span data-v-c9655b1d class=rp-slider__mark-dot></span>");
|
|
216
|
+
var t5$1 = template("<span data-v-c9655b1d class=rp-slider__marks aria-hidden=true>");
|
|
217
|
+
var t6$1 = template("<span data-v-c9655b1d class=rp-slider__thumb aria-hidden=true><span data-v-c9655b1d class=rp-slider__thumb-content>");
|
|
218
|
+
var t7$1 = template("<span data-v-c9655b1d class=rp-slider__tooltip-anchor aria-hidden=true>", 2);
|
|
244
219
|
var t8 = template("<label data-v-c9655b1d><span data-v-c9655b1d class=rp-slider__track><span data-v-c9655b1d class=rp-slider__bar aria-hidden=true></span><input data-v-c9655b1d class=rp-slider__native type=range>", 1);
|
|
245
220
|
delegateEvents("input", "focusin", "focusout", "keydown");
|
|
246
221
|
//#endregion
|
|
@@ -307,17 +282,17 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
307
282
|
});
|
|
308
283
|
setInsertionState(n31, 0, 0);
|
|
309
284
|
createIf(() => $slots.default || $slots.value, () => {
|
|
310
|
-
const n10 = t2();
|
|
285
|
+
const n10 = t2$1();
|
|
311
286
|
setInsertionState(n10, null, 0);
|
|
312
287
|
createIf(() => $slots.default, () => {
|
|
313
|
-
const n5 = t0();
|
|
288
|
+
const n5 = t0$1();
|
|
314
289
|
setInsertionState(n5, null, 0);
|
|
315
290
|
createSlot("default", null, null, 1);
|
|
316
291
|
return n5;
|
|
317
292
|
});
|
|
318
293
|
setInsertionState(n10, null, 1);
|
|
319
294
|
createIf(() => $slots.value, () => {
|
|
320
|
-
const n9 = t1();
|
|
295
|
+
const n9 = t1$1();
|
|
321
296
|
setInsertionState(n9, null, 0);
|
|
322
297
|
createSlot("value", {
|
|
323
298
|
value: () => unref(normalizedValue),
|
|
@@ -351,10 +326,10 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
351
326
|
});
|
|
352
327
|
setInsertionState(n30, null, 2);
|
|
353
328
|
createIf(() => unref(markItems).length, () => {
|
|
354
|
-
const n20 = t5();
|
|
329
|
+
const n20 = t5$1();
|
|
355
330
|
setInsertionState(n20, null, 0);
|
|
356
331
|
createFor(() => unref(markItems), (_for_item0) => {
|
|
357
|
-
const n19 = t4();
|
|
332
|
+
const n19 = t4$1();
|
|
358
333
|
renderEffect(() => {
|
|
359
334
|
const _mark = _for_item0.value;
|
|
360
335
|
setClassName(n19, _mark.filled ? 1 : 0, " rp-slider__mark--filled", "rp-slider__mark");
|
|
@@ -362,7 +337,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
362
337
|
});
|
|
363
338
|
setInsertionState(n19, null, 1);
|
|
364
339
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
365
|
-
const n18 = t3();
|
|
340
|
+
const n18 = t3$1();
|
|
366
341
|
const x18 = txt(n18);
|
|
367
342
|
renderEffect(() => setText(x18, toDisplayString(_for_item0.value.label)));
|
|
368
343
|
return n18;
|
|
@@ -373,7 +348,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
373
348
|
});
|
|
374
349
|
setInsertionState(n30, null, 3);
|
|
375
350
|
createIf(() => $slots.thumb, () => {
|
|
376
|
-
const n25 = t6();
|
|
351
|
+
const n25 = t6$1();
|
|
377
352
|
setInsertionState(child(n25), null, 0);
|
|
378
353
|
createSlot("thumb", {
|
|
379
354
|
value: () => unref(normalizedValue),
|
|
@@ -396,7 +371,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
396
371
|
arrow: () => unref(tooltipArrow),
|
|
397
372
|
decorative: ""
|
|
398
373
|
}, () => {
|
|
399
|
-
return t7();
|
|
374
|
+
return t7$1();
|
|
400
375
|
});
|
|
401
376
|
});
|
|
402
377
|
on(n30, "mouseenter", (e) => unref(openTooltip)(e));
|
|
@@ -408,6 +383,1103 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
408
383
|
}
|
|
409
384
|
}), [["__scopeId", "data-v-c9655b1d"]]);
|
|
410
385
|
//#endregion
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
386
|
+
//#region src/components/slider/useRangeSlider.ts
|
|
387
|
+
var rangeSliderMarkColorProperties = [
|
|
388
|
+
"--_rp-range-slider-mark-color",
|
|
389
|
+
"--_rp-range-slider-mark-label-color",
|
|
390
|
+
"--_rp-range-slider-mark-filled-label-color",
|
|
391
|
+
"--_rp-range-slider-mark-ring-color"
|
|
392
|
+
];
|
|
393
|
+
function roundSliderNumber(value) {
|
|
394
|
+
return Number(value.toFixed(10));
|
|
395
|
+
}
|
|
396
|
+
function clamp(value, min, max) {
|
|
397
|
+
return Math.min(max, Math.max(min, value));
|
|
398
|
+
}
|
|
399
|
+
function getStepValueAtOrAbove(value, min, step) {
|
|
400
|
+
if (step === "any") return value;
|
|
401
|
+
return roundSliderNumber(min + Math.ceil((value - min) / step - 1e-10) * step);
|
|
402
|
+
}
|
|
403
|
+
function getStepValueAtOrBelow(value, min, step) {
|
|
404
|
+
if (step === "any") return value;
|
|
405
|
+
return roundSliderNumber(min + Math.floor((value - min) / step + 1e-10) * step);
|
|
406
|
+
}
|
|
407
|
+
function isSliderStepAligned(min, max, step) {
|
|
408
|
+
const stepCount = (max - min) / step;
|
|
409
|
+
return Math.abs(stepCount - Math.round(stepCount)) <= 1e-10;
|
|
410
|
+
}
|
|
411
|
+
function normalizeRangeSliderMinRange(minRange, min, max) {
|
|
412
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
413
|
+
const domain = bounds.max - bounds.min;
|
|
414
|
+
return Math.min(domain, Number.isFinite(minRange) && minRange > 0 ? minRange : 0);
|
|
415
|
+
}
|
|
416
|
+
function normalizeRangeSliderValue(value, min, max, step, minRange = 0) {
|
|
417
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
418
|
+
const safeStep = normalizeSliderStep(step);
|
|
419
|
+
const safeMinRange = normalizeRangeSliderMinRange(minRange, bounds.min, bounds.max);
|
|
420
|
+
const first = normalizeSliderValue(Array.isArray(value) ? Number(value[0]) : NaN, bounds.min, bounds.max, safeStep);
|
|
421
|
+
const second = normalizeSliderValue(Array.isArray(value) ? Number(value[1]) : NaN, bounds.min, bounds.max, safeStep);
|
|
422
|
+
const lower = Math.min(first, second);
|
|
423
|
+
const upper = Math.max(first, second);
|
|
424
|
+
if (upper - lower >= safeMinRange) return [lower, upper];
|
|
425
|
+
if (safeMinRange >= bounds.max - bounds.min) return [bounds.min, bounds.max];
|
|
426
|
+
const expandedUpper = getStepValueAtOrAbove(lower + safeMinRange, bounds.min, safeStep);
|
|
427
|
+
if (expandedUpper <= bounds.max) return [lower, expandedUpper];
|
|
428
|
+
const expandedLower = getStepValueAtOrBelow(bounds.max - safeMinRange, bounds.min, safeStep);
|
|
429
|
+
return [Math.max(bounds.min, expandedLower), bounds.max];
|
|
430
|
+
}
|
|
431
|
+
function getClosestRangeSliderThumb(value, range, activeThumb) {
|
|
432
|
+
const [lower, upper] = range;
|
|
433
|
+
if (value < lower) return "lower";
|
|
434
|
+
if (value > upper) return "upper";
|
|
435
|
+
const lowerDistance = Math.abs(value - lower);
|
|
436
|
+
const upperDistance = Math.abs(value - upper);
|
|
437
|
+
if (lowerDistance < upperDistance) return "lower";
|
|
438
|
+
if (upperDistance < lowerDistance) return "upper";
|
|
439
|
+
return activeThumb ?? "upper";
|
|
440
|
+
}
|
|
441
|
+
function setRangeSliderStyleValue(style, property, value) {
|
|
442
|
+
if (value) style[property] = value;
|
|
443
|
+
}
|
|
444
|
+
function getRangeSliderLengthValue(value) {
|
|
445
|
+
if (value == null || value === "") return void 0;
|
|
446
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
447
|
+
return value;
|
|
448
|
+
}
|
|
449
|
+
function getRangeSliderBorderValue(value) {
|
|
450
|
+
if (value == null || value === "") return void 0;
|
|
451
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px solid var(--_rp-range-slider-thumb-border)` : void 0;
|
|
452
|
+
return value;
|
|
453
|
+
}
|
|
454
|
+
var rangeSliderThumbStyleProps = [
|
|
455
|
+
[
|
|
456
|
+
"--_rp-range-slider-thumb-size",
|
|
457
|
+
"size",
|
|
458
|
+
getRangeSliderLengthValue
|
|
459
|
+
],
|
|
460
|
+
[
|
|
461
|
+
"--_rp-range-slider-thumb-border-style",
|
|
462
|
+
"border",
|
|
463
|
+
getRangeSliderBorderValue
|
|
464
|
+
],
|
|
465
|
+
[
|
|
466
|
+
"--_rp-range-slider-thumb-padding",
|
|
467
|
+
"padding",
|
|
468
|
+
getRangeSliderLengthValue
|
|
469
|
+
]
|
|
470
|
+
];
|
|
471
|
+
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
472
|
+
const [lowerPercent, upperPercent] = valuePercent;
|
|
473
|
+
const style = {
|
|
474
|
+
"--_rp-range-slider-lower-percent": `${lowerPercent}%`,
|
|
475
|
+
"--_rp-range-slider-upper-percent": `${upperPercent}%`,
|
|
476
|
+
"--_rp-range-slider-lower-ratio": `${lowerPercent / 100}`,
|
|
477
|
+
"--_rp-range-slider-upper-ratio": `${upperPercent / 100}`,
|
|
478
|
+
"--_rp-range-slider-tooltip-merged-percent": `${(lowerPercent + upperPercent) / 2}%`
|
|
479
|
+
};
|
|
480
|
+
setRangeSliderStyleValue(style, "--_rp-range-slider-color", getComponentColorValue(props.color));
|
|
481
|
+
for (const [property, propName, getValue] of rangeSliderThumbStyleProps) setRangeSliderStyleValue(style, property, getValue(props.thumbStyle?.[propName]));
|
|
482
|
+
return style;
|
|
483
|
+
}
|
|
484
|
+
function getRangeSliderMarkStyle(percent, color) {
|
|
485
|
+
const style = { "--_rp-range-slider-mark-position": `${percent}%` };
|
|
486
|
+
const colorValue = getComponentColorValue(color);
|
|
487
|
+
for (const property of rangeSliderMarkColorProperties) setRangeSliderStyleValue(style, property, colorValue);
|
|
488
|
+
return style;
|
|
489
|
+
}
|
|
490
|
+
function normalizeRangeSliderMark(mark) {
|
|
491
|
+
return typeof mark === "number" ? { value: mark } : mark;
|
|
492
|
+
}
|
|
493
|
+
function normalizeRangeSliderMarks(marks, min, max, value) {
|
|
494
|
+
return (marks ?? []).flatMap((markInput, index) => {
|
|
495
|
+
const mark = normalizeRangeSliderMark(markInput);
|
|
496
|
+
if (mark.hidden) return [];
|
|
497
|
+
const markValue = Number(mark.value);
|
|
498
|
+
if (!Number.isFinite(markValue)) return [];
|
|
499
|
+
const percent = getSliderValuePercent(markValue, min, max);
|
|
500
|
+
return {
|
|
501
|
+
key: `${markValue}-${index}`,
|
|
502
|
+
value: markValue,
|
|
503
|
+
label: mark.label,
|
|
504
|
+
hasLabel: mark.label != null,
|
|
505
|
+
filled: markValue >= value[0] && markValue <= value[1],
|
|
506
|
+
style: getRangeSliderMarkStyle(percent, mark.color)
|
|
507
|
+
};
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function getFormattedRangeSliderValue(value, formatter) {
|
|
511
|
+
return formatter ? [formatter(value[0]), formatter(value[1])] : value;
|
|
512
|
+
}
|
|
513
|
+
function getRangeSliderEndpointValueText(value, ariaValueText, formatter) {
|
|
514
|
+
if (typeof ariaValueText === "function") return String(ariaValueText(value));
|
|
515
|
+
if (ariaValueText != null && ariaValueText !== "") return String(ariaValueText);
|
|
516
|
+
if (formatter) return String(formatter(value));
|
|
517
|
+
}
|
|
518
|
+
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
519
|
+
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
520
|
+
return [getRangeSliderEndpointValueText(value[0], endpointValues[0], formatter), getRangeSliderEndpointValueText(value[1], endpointValues[1], formatter)];
|
|
521
|
+
}
|
|
522
|
+
function getRangeSliderTooltipOptions(tooltip) {
|
|
523
|
+
return typeof tooltip === "object" ? tooltip : {};
|
|
524
|
+
}
|
|
525
|
+
function getRangeSliderTooltipMode(tooltip) {
|
|
526
|
+
if (tooltip === false) return false;
|
|
527
|
+
if (typeof tooltip === "object") return tooltip.mode ?? "hover";
|
|
528
|
+
return tooltip;
|
|
529
|
+
}
|
|
530
|
+
function getThumbIndex(thumb) {
|
|
531
|
+
return thumb === "lower" ? 0 : 1;
|
|
532
|
+
}
|
|
533
|
+
function getOppositeThumb(thumb) {
|
|
534
|
+
return thumb === "lower" ? "upper" : "lower";
|
|
535
|
+
}
|
|
536
|
+
function getThumbFromTarget(target) {
|
|
537
|
+
const thumb = target?.closest?.("[data-range-slider-thumb]")?.getAttribute("data-range-slider-thumb");
|
|
538
|
+
return thumb === "lower" || thumb === "upper" ? thumb : void 0;
|
|
539
|
+
}
|
|
540
|
+
function getThumbInput(track, thumb) {
|
|
541
|
+
return track.querySelector(`.rp-range-slider__native--${thumb}, input[data-range-slider-thumb="${thumb}"]`);
|
|
542
|
+
}
|
|
543
|
+
function focusThumb(track, thumb) {
|
|
544
|
+
getThumbInput(track, thumb)?.focus({ preventScroll: true });
|
|
545
|
+
}
|
|
546
|
+
function useRangeSlider(props, emitUpdate) {
|
|
547
|
+
const control = useControlState(props);
|
|
548
|
+
const activeThumb = ref();
|
|
549
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
550
|
+
const valueStep = computed(() => normalizeSliderStep(props.step));
|
|
551
|
+
const nativeStep = computed(() => {
|
|
552
|
+
const step = valueStep.value;
|
|
553
|
+
if (step === "any") return step;
|
|
554
|
+
return isSliderStepAligned(bounds.value.min, bounds.value.max, step) ? step : "any";
|
|
555
|
+
});
|
|
556
|
+
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
557
|
+
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
558
|
+
const normalizedValue = computed(() => normalizeRangeSliderValue(props.modelValue, bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
559
|
+
const valuePercent = computed(() => [getSliderValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getSliderValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
560
|
+
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
561
|
+
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
562
|
+
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
563
|
+
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
564
|
+
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
565
|
+
const nativeMin = computed(() => {
|
|
566
|
+
if (normalizedMinRange.value === 0) return [bounds.value.min, bounds.value.min];
|
|
567
|
+
return [bounds.value.min, clamp(getStepValueAtOrAbove(normalizedValue.value[0] + normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max)];
|
|
568
|
+
});
|
|
569
|
+
const nativeMax = computed(() => {
|
|
570
|
+
if (normalizedMinRange.value === 0) return [bounds.value.max, bounds.value.max];
|
|
571
|
+
return [clamp(getStepValueAtOrBelow(normalizedValue.value[1] - normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max), bounds.value.max];
|
|
572
|
+
});
|
|
573
|
+
const markItems = computed(() => normalizeRangeSliderMarks(props.marks, bounds.value.min, bounds.value.max, normalizedValue.value));
|
|
574
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
575
|
+
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valuePercent.value));
|
|
576
|
+
const tooltipOptions = computed(() => getRangeSliderTooltipOptions(props.tooltip));
|
|
577
|
+
const tooltipMode = computed(() => getRangeSliderTooltipMode(props.tooltip));
|
|
578
|
+
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
579
|
+
const delayedTooltip = useDelayedOpen({
|
|
580
|
+
openDelay: () => tooltipOpenDelay.value,
|
|
581
|
+
disabled: () => tooltipMode.value !== "hover" || control.disabled
|
|
582
|
+
});
|
|
583
|
+
const tooltipInteractionReasons = ref({
|
|
584
|
+
lower: {
|
|
585
|
+
focus: false,
|
|
586
|
+
drag: false
|
|
587
|
+
},
|
|
588
|
+
upper: {
|
|
589
|
+
focus: false,
|
|
590
|
+
drag: false
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
const tooltipTrackHovered = ref(false);
|
|
594
|
+
const tooltipDismissed = ref(false);
|
|
595
|
+
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
596
|
+
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
597
|
+
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltip.isOpen.value && hasAnyTooltipInteractionReason() && !tooltipDismissed.value && !control.disabled);
|
|
598
|
+
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (props.orientation === "vertical" ? "left" : "top"));
|
|
599
|
+
const tooltipIds = computed(() => {
|
|
600
|
+
const baseId = tooltipOptions.value.id;
|
|
601
|
+
return baseId ? [`${baseId}-lower`, `${baseId}-upper`] : [void 0, void 0];
|
|
602
|
+
});
|
|
603
|
+
const mergedTooltipId = computed(() => {
|
|
604
|
+
const baseId = tooltipOptions.value.id;
|
|
605
|
+
return baseId ? `${baseId}-merged` : void 0;
|
|
606
|
+
});
|
|
607
|
+
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
608
|
+
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
609
|
+
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
610
|
+
const tooltipContent = computed(() => [String(formattedValue.value[0]), String(formattedValue.value[1])]);
|
|
611
|
+
const mergedTooltipContent = computed(() => `${tooltipContent.value[0]}–${tooltipContent.value[1]}`);
|
|
612
|
+
const rootClass = computed(() => bem("rp-range-slider", {
|
|
613
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
614
|
+
vertical: props.orientation === "vertical",
|
|
615
|
+
marked: markItems.value.length > 0,
|
|
616
|
+
"marks-with-labels": hasMarkLabels.value,
|
|
617
|
+
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
618
|
+
disabled: control.disabled,
|
|
619
|
+
invalid: control.invalid,
|
|
620
|
+
valid: control.valid && !control.invalid
|
|
621
|
+
}));
|
|
622
|
+
function getThumbUpdate(thumb, value, anchorValue = normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))]) {
|
|
623
|
+
const safeValue = normalizeSliderValue(value, bounds.value.min, bounds.value.max, valueStep.value);
|
|
624
|
+
if (normalizedMinRange.value > 0) {
|
|
625
|
+
const nextValue = [...normalizedValue.value];
|
|
626
|
+
nextValue[getThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax.value[0]) : Math.max(safeValue, nativeMin.value[1]);
|
|
627
|
+
return {
|
|
628
|
+
thumb,
|
|
629
|
+
value: nextValue
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
if (safeValue < anchorValue) return {
|
|
633
|
+
thumb: "lower",
|
|
634
|
+
value: [safeValue, anchorValue]
|
|
635
|
+
};
|
|
636
|
+
if (safeValue > anchorValue) return {
|
|
637
|
+
thumb: "upper",
|
|
638
|
+
value: [anchorValue, safeValue]
|
|
639
|
+
};
|
|
640
|
+
return {
|
|
641
|
+
thumb,
|
|
642
|
+
value: [safeValue, safeValue]
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function updateThumb(thumb, value, anchorValue) {
|
|
646
|
+
if (control.disabled) return thumb;
|
|
647
|
+
const update = getThumbUpdate(thumb, value, anchorValue);
|
|
648
|
+
activeThumb.value = update.thumb;
|
|
649
|
+
emitUpdate(update.value);
|
|
650
|
+
return update.thumb;
|
|
651
|
+
}
|
|
652
|
+
function onInput(thumb, event) {
|
|
653
|
+
const input = event.target;
|
|
654
|
+
transferFocusedThumb(input, thumb, updateThumb(thumb, input.valueAsNumber));
|
|
655
|
+
}
|
|
656
|
+
function hasThumbTooltipInteractionReason(thumb) {
|
|
657
|
+
const reasons = tooltipInteractionReasons.value[thumb];
|
|
658
|
+
return reasons.focus || reasons.drag;
|
|
659
|
+
}
|
|
660
|
+
function hasAnyTooltipInteractionReason() {
|
|
661
|
+
return tooltipTrackHovered.value || hasThumbTooltipInteractionReason("lower") || hasThumbTooltipInteractionReason("upper");
|
|
662
|
+
}
|
|
663
|
+
function syncTooltip() {
|
|
664
|
+
if (tooltipMode.value === "hover" && !control.disabled && hasAnyTooltipInteractionReason() && !tooltipDismissed.value) {
|
|
665
|
+
delayedTooltip.open();
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
delayedTooltip.closeImmediate();
|
|
669
|
+
}
|
|
670
|
+
function startTooltipInteraction(thumb, reason) {
|
|
671
|
+
activeThumb.value = thumb;
|
|
672
|
+
const wasActive = hasAnyTooltipInteractionReason();
|
|
673
|
+
const wasDismissed = tooltipDismissed.value;
|
|
674
|
+
tooltipInteractionReasons.value[thumb][reason] = true;
|
|
675
|
+
tooltipDismissed.value = false;
|
|
676
|
+
if (!wasActive || wasDismissed) syncTooltip();
|
|
677
|
+
}
|
|
678
|
+
function endTooltipInteraction(thumb, reason) {
|
|
679
|
+
tooltipInteractionReasons.value[thumb][reason] = false;
|
|
680
|
+
if (!hasAnyTooltipInteractionReason()) syncTooltip();
|
|
681
|
+
}
|
|
682
|
+
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
683
|
+
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
684
|
+
const track = input.closest(".rp-range-slider__track");
|
|
685
|
+
if (!track) return;
|
|
686
|
+
const nextInput = getThumbInput(track, nextThumb);
|
|
687
|
+
if (!nextInput) return;
|
|
688
|
+
const currentReasons = tooltipInteractionReasons.value[thumb];
|
|
689
|
+
if (currentReasons.focus) {
|
|
690
|
+
currentReasons.focus = false;
|
|
691
|
+
tooltipInteractionReasons.value[nextThumb].focus = true;
|
|
692
|
+
}
|
|
693
|
+
nextInput.focus({ preventScroll: true });
|
|
694
|
+
}
|
|
695
|
+
function resetTooltipInteractionReasons(thumb) {
|
|
696
|
+
const reasons = tooltipInteractionReasons.value[thumb];
|
|
697
|
+
reasons.focus = false;
|
|
698
|
+
reasons.drag = false;
|
|
699
|
+
}
|
|
700
|
+
function clearTooltipInteractions(thumb) {
|
|
701
|
+
resetTooltipInteractionReasons(thumb);
|
|
702
|
+
syncTooltip();
|
|
703
|
+
}
|
|
704
|
+
function resumeDismissedTooltip(thumb) {
|
|
705
|
+
activeThumb.value = thumb;
|
|
706
|
+
if (!tooltipDismissed.value) return;
|
|
707
|
+
tooltipDismissed.value = false;
|
|
708
|
+
syncTooltip();
|
|
709
|
+
}
|
|
710
|
+
function dismissTooltip() {
|
|
711
|
+
tooltipDismissed.value = true;
|
|
712
|
+
delayedTooltip.closeImmediate();
|
|
713
|
+
}
|
|
714
|
+
function onTooltipFocus(thumb) {
|
|
715
|
+
startTooltipInteraction(thumb, "focus");
|
|
716
|
+
}
|
|
717
|
+
function onTooltipBlur(thumb) {
|
|
718
|
+
endTooltipInteraction(thumb, "focus");
|
|
719
|
+
}
|
|
720
|
+
function onTooltipTrackMouseEnter() {
|
|
721
|
+
const wasActive = hasAnyTooltipInteractionReason();
|
|
722
|
+
const wasDismissed = tooltipDismissed.value;
|
|
723
|
+
tooltipTrackHovered.value = true;
|
|
724
|
+
tooltipDismissed.value = false;
|
|
725
|
+
if (!wasActive || wasDismissed) syncTooltip();
|
|
726
|
+
}
|
|
727
|
+
function onTooltipTrackMouseLeave() {
|
|
728
|
+
tooltipTrackHovered.value = false;
|
|
729
|
+
if (!hasAnyTooltipInteractionReason()) syncTooltip();
|
|
730
|
+
}
|
|
731
|
+
function openTooltip(thumb) {
|
|
732
|
+
startTooltipInteraction(thumb, "focus");
|
|
733
|
+
}
|
|
734
|
+
function closeTooltip(thumb) {
|
|
735
|
+
if (thumb) {
|
|
736
|
+
clearTooltipInteractions(thumb);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
resetTooltipInteractionReasons("lower");
|
|
740
|
+
resetTooltipInteractionReasons("upper");
|
|
741
|
+
tooltipTrackHovered.value = false;
|
|
742
|
+
syncTooltip();
|
|
743
|
+
}
|
|
744
|
+
function onTooltipKeydown(thumb, event) {
|
|
745
|
+
activeThumb.value = thumb;
|
|
746
|
+
if (event.key === "Escape") {
|
|
747
|
+
dismissTooltip();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
resumeDismissedTooltip(thumb);
|
|
751
|
+
if (!hasManualNativeKeyboard.value || valueStep.value === "any") return;
|
|
752
|
+
const index = getThumbIndex(thumb);
|
|
753
|
+
const currentValue = normalizedValue.value[index];
|
|
754
|
+
const pageStep = valueStep.value * 10;
|
|
755
|
+
let nextValue;
|
|
756
|
+
switch (event.key) {
|
|
757
|
+
case "ArrowRight":
|
|
758
|
+
case "ArrowUp":
|
|
759
|
+
nextValue = currentValue + valueStep.value;
|
|
760
|
+
break;
|
|
761
|
+
case "ArrowLeft":
|
|
762
|
+
case "ArrowDown":
|
|
763
|
+
nextValue = currentValue - valueStep.value;
|
|
764
|
+
break;
|
|
765
|
+
case "PageUp":
|
|
766
|
+
nextValue = currentValue + pageStep;
|
|
767
|
+
break;
|
|
768
|
+
case "PageDown":
|
|
769
|
+
nextValue = currentValue - pageStep;
|
|
770
|
+
break;
|
|
771
|
+
case "Home":
|
|
772
|
+
nextValue = nativeMin.value[index];
|
|
773
|
+
break;
|
|
774
|
+
case "End":
|
|
775
|
+
nextValue = nativeMax.value[index];
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
if (nextValue == null) return;
|
|
779
|
+
event.preventDefault();
|
|
780
|
+
const nextThumb = updateThumb(thumb, nextValue);
|
|
781
|
+
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
782
|
+
}
|
|
783
|
+
function getValueFromPointer(event, track) {
|
|
784
|
+
const vertical = props.orientation === "vertical";
|
|
785
|
+
const trackRect = track.getBoundingClientRect();
|
|
786
|
+
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
787
|
+
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : trackRect;
|
|
788
|
+
const length = vertical ? rect.height : rect.width;
|
|
789
|
+
if (length <= 0) return void 0;
|
|
790
|
+
const ratio = clamp((vertical ? rect.bottom - event.clientY : event.clientX - rect.left) / length, 0, 1);
|
|
791
|
+
return bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
792
|
+
}
|
|
793
|
+
let dragWindow = null;
|
|
794
|
+
let dragTrack = null;
|
|
795
|
+
let dragThumb = null;
|
|
796
|
+
let dragAnchorValue = null;
|
|
797
|
+
let dragPointerId;
|
|
798
|
+
function stopDragging() {
|
|
799
|
+
const stoppedThumb = dragThumb;
|
|
800
|
+
if (dragWindow) {
|
|
801
|
+
dragWindow.removeEventListener("pointermove", onPointerMove);
|
|
802
|
+
dragWindow.removeEventListener("pointerup", onPointerEnd);
|
|
803
|
+
dragWindow.removeEventListener("pointercancel", onPointerEnd);
|
|
804
|
+
}
|
|
805
|
+
dragWindow = null;
|
|
806
|
+
dragTrack = null;
|
|
807
|
+
dragThumb = null;
|
|
808
|
+
dragAnchorValue = null;
|
|
809
|
+
dragPointerId = void 0;
|
|
810
|
+
if (stoppedThumb) endTooltipInteraction(stoppedThumb, "drag");
|
|
811
|
+
}
|
|
812
|
+
function switchDraggingThumb(track, nextThumb) {
|
|
813
|
+
const previousThumb = dragThumb;
|
|
814
|
+
if (!previousThumb || previousThumb === nextThumb) return;
|
|
815
|
+
tooltipInteractionReasons.value[previousThumb].drag = false;
|
|
816
|
+
tooltipInteractionReasons.value[nextThumb].drag = true;
|
|
817
|
+
dragThumb = nextThumb;
|
|
818
|
+
activeThumb.value = nextThumb;
|
|
819
|
+
const previousInput = getThumbInput(track, previousThumb);
|
|
820
|
+
if (previousInput) transferFocusedThumb(previousInput, previousThumb, nextThumb);
|
|
821
|
+
}
|
|
822
|
+
function updateFromPointer(event, track) {
|
|
823
|
+
const value = getValueFromPointer(event, track);
|
|
824
|
+
if (value == null || !dragThumb) return;
|
|
825
|
+
switchDraggingThumb(track, updateThumb(dragThumb, value, dragAnchorValue ?? normalizedValue.value[getThumbIndex(getOppositeThumb(dragThumb))]));
|
|
826
|
+
}
|
|
827
|
+
function onPointerMove(event) {
|
|
828
|
+
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
829
|
+
if (!dragTrack || !dragThumb) {
|
|
830
|
+
stopDragging();
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
updateFromPointer(event, dragTrack);
|
|
834
|
+
}
|
|
835
|
+
function onPointerEnd(event) {
|
|
836
|
+
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
837
|
+
stopDragging();
|
|
838
|
+
}
|
|
839
|
+
function onTrackPointerDown(event) {
|
|
840
|
+
if (control.disabled || event.button !== 0 || event.isPrimary === false) return;
|
|
841
|
+
const track = event.currentTarget;
|
|
842
|
+
if (!track) return;
|
|
843
|
+
const pointerValue = getValueFromPointer(event, track);
|
|
844
|
+
if (pointerValue == null) return;
|
|
845
|
+
const thumb = getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(pointerValue, normalizedValue.value, activeThumb.value);
|
|
846
|
+
event.preventDefault();
|
|
847
|
+
stopDragging();
|
|
848
|
+
activeThumb.value = thumb;
|
|
849
|
+
focusThumb(track, thumb);
|
|
850
|
+
dragTrack = track;
|
|
851
|
+
dragThumb = thumb;
|
|
852
|
+
dragAnchorValue = normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))];
|
|
853
|
+
dragPointerId = Number.isFinite(event.pointerId) ? event.pointerId : void 0;
|
|
854
|
+
dragWindow = track.ownerDocument.defaultView;
|
|
855
|
+
startTooltipInteraction(thumb, "drag");
|
|
856
|
+
updateFromPointer(event, track);
|
|
857
|
+
dragWindow?.addEventListener("pointermove", onPointerMove);
|
|
858
|
+
dragWindow?.addEventListener("pointerup", onPointerEnd);
|
|
859
|
+
dragWindow?.addEventListener("pointercancel", onPointerEnd);
|
|
860
|
+
}
|
|
861
|
+
watch([tooltipMode, () => control.disabled], () => {
|
|
862
|
+
syncTooltip();
|
|
863
|
+
});
|
|
864
|
+
onBeforeUnmount(stopDragging);
|
|
865
|
+
return {
|
|
866
|
+
control,
|
|
867
|
+
nativeMin,
|
|
868
|
+
nativeMax,
|
|
869
|
+
nativeStep,
|
|
870
|
+
nativeNames,
|
|
871
|
+
nativeIds,
|
|
872
|
+
rootClass,
|
|
873
|
+
normalizedValue,
|
|
874
|
+
valuePercent,
|
|
875
|
+
formattedValue,
|
|
876
|
+
ariaLabels,
|
|
877
|
+
ariaValueText,
|
|
878
|
+
markItems,
|
|
879
|
+
trackStyle,
|
|
880
|
+
activeThumb,
|
|
881
|
+
tooltipVisible,
|
|
882
|
+
tooltipOpen,
|
|
883
|
+
tooltipPlacement,
|
|
884
|
+
tooltipIds,
|
|
885
|
+
mergedTooltipId,
|
|
886
|
+
tooltipColor,
|
|
887
|
+
tooltipOffset,
|
|
888
|
+
tooltipOpenDelay,
|
|
889
|
+
tooltipArrow,
|
|
890
|
+
tooltipContent,
|
|
891
|
+
mergedTooltipContent,
|
|
892
|
+
onInput,
|
|
893
|
+
onTrackPointerDown,
|
|
894
|
+
onTooltipFocus,
|
|
895
|
+
onTooltipBlur,
|
|
896
|
+
onTooltipTrackMouseEnter,
|
|
897
|
+
onTooltipTrackMouseLeave,
|
|
898
|
+
openTooltip,
|
|
899
|
+
closeTooltip,
|
|
900
|
+
onTooltipKeydown
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
905
|
+
var TOOLTIP_COLLISION_GAP = 4;
|
|
906
|
+
var TOOLTIP_COLLISION_RELEASE_GAP = 8;
|
|
907
|
+
var TOOLTIP_CONTENT_SELECTOR$1 = ".rp-tooltip__content";
|
|
908
|
+
function areRangeSliderTooltipRectsOverlapping(lower, upper, gap = TOOLTIP_COLLISION_GAP) {
|
|
909
|
+
if (lower.width <= 0 || lower.height <= 0 || upper.width <= 0 || upper.height <= 0) return false;
|
|
910
|
+
return lower.left < upper.right + gap && lower.right + gap > upper.left && lower.top < upper.bottom + gap && lower.bottom + gap > upper.top;
|
|
911
|
+
}
|
|
912
|
+
function useRangeSliderTooltipCollision(root) {
|
|
913
|
+
const tooltipsOverlapping = ref(false);
|
|
914
|
+
const observedElements = /* @__PURE__ */ new Set();
|
|
915
|
+
let resizeObserver;
|
|
916
|
+
let frameWindow;
|
|
917
|
+
let frameId;
|
|
918
|
+
let microtaskQueued = false;
|
|
919
|
+
let destroyed = false;
|
|
920
|
+
function setOverlapping(value) {
|
|
921
|
+
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
922
|
+
}
|
|
923
|
+
function getTooltipContents(el) {
|
|
924
|
+
return [el.querySelector(`.rp-range-slider__tooltip--lower ${TOOLTIP_CONTENT_SELECTOR$1}`), el.querySelector(`.rp-range-slider__tooltip--upper ${TOOLTIP_CONTENT_SELECTOR$1}`)];
|
|
925
|
+
}
|
|
926
|
+
function measure() {
|
|
927
|
+
if (destroyed) return;
|
|
928
|
+
const el = root.value;
|
|
929
|
+
if (!el) {
|
|
930
|
+
setOverlapping(false);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const [lower, upper] = getTooltipContents(el);
|
|
934
|
+
if (!lower || !upper) {
|
|
935
|
+
setOverlapping(false);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
const view = el.ownerDocument.defaultView;
|
|
939
|
+
if (!view || view.getComputedStyle(lower).display === "none" || view.getComputedStyle(upper).display === "none") {
|
|
940
|
+
setOverlapping(false);
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
setOverlapping(areRangeSliderTooltipRectsOverlapping(lower.getBoundingClientRect(), upper.getBoundingClientRect(), tooltipsOverlapping.value ? TOOLTIP_COLLISION_RELEASE_GAP : TOOLTIP_COLLISION_GAP));
|
|
944
|
+
}
|
|
945
|
+
function scheduleMeasure() {
|
|
946
|
+
if (destroyed || frameId != null || microtaskQueued) return;
|
|
947
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
948
|
+
if (view?.requestAnimationFrame) {
|
|
949
|
+
frameWindow = view;
|
|
950
|
+
frameId = view.requestAnimationFrame(() => {
|
|
951
|
+
frameId = void 0;
|
|
952
|
+
frameWindow = void 0;
|
|
953
|
+
measure();
|
|
954
|
+
});
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
microtaskQueued = true;
|
|
958
|
+
queueMicrotask(() => {
|
|
959
|
+
microtaskQueued = false;
|
|
960
|
+
measure();
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function refreshObservedElements() {
|
|
964
|
+
if (!resizeObserver) return;
|
|
965
|
+
const el = root.value;
|
|
966
|
+
const nextElements = /* @__PURE__ */ new Set();
|
|
967
|
+
if (el) {
|
|
968
|
+
nextElements.add(el);
|
|
969
|
+
for (const tooltip of getTooltipContents(el)) if (tooltip) nextElements.add(tooltip);
|
|
970
|
+
}
|
|
971
|
+
for (const observed of observedElements) if (!nextElements.has(observed)) resizeObserver.unobserve(observed);
|
|
972
|
+
for (const next of nextElements) if (!observedElements.has(next)) resizeObserver.observe(next);
|
|
973
|
+
observedElements.clear();
|
|
974
|
+
for (const next of nextElements) observedElements.add(next);
|
|
975
|
+
}
|
|
976
|
+
function onWindowResize() {
|
|
977
|
+
scheduleMeasure();
|
|
978
|
+
}
|
|
979
|
+
onMounted(() => {
|
|
980
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
981
|
+
if (view?.ResizeObserver) resizeObserver = new view.ResizeObserver(scheduleMeasure);
|
|
982
|
+
view?.addEventListener("resize", onWindowResize);
|
|
983
|
+
refreshObservedElements();
|
|
984
|
+
scheduleMeasure();
|
|
985
|
+
});
|
|
986
|
+
onUpdated(() => {
|
|
987
|
+
refreshObservedElements();
|
|
988
|
+
scheduleMeasure();
|
|
989
|
+
});
|
|
990
|
+
onBeforeUnmount(() => {
|
|
991
|
+
destroyed = true;
|
|
992
|
+
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
993
|
+
resizeObserver?.disconnect();
|
|
994
|
+
observedElements.clear();
|
|
995
|
+
if (frameId != null) frameWindow?.cancelAnimationFrame(frameId);
|
|
996
|
+
});
|
|
997
|
+
return { tooltipsOverlapping };
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
//#region src/components/slider/useRangeSliderTooltipTransition.ts
|
|
1001
|
+
var DEFAULT_TRANSITION_DURATION = 150;
|
|
1002
|
+
var DEFAULT_TRANSITION_EASING = "ease";
|
|
1003
|
+
var TOOLTIP_CONTENT_SELECTOR = ".rp-tooltip__content";
|
|
1004
|
+
var TRANSITION_EASING_PATTERN = /(?:cubic-bezier|linear|steps)\([^)]*\)|\b(?:ease-in-out|ease-in|ease-out|ease|linear|step-end|step-start)\b/;
|
|
1005
|
+
function getTooltip(root, kind) {
|
|
1006
|
+
return root.querySelector(`.rp-range-slider__tooltip--${kind}`);
|
|
1007
|
+
}
|
|
1008
|
+
function getTooltipCenter(tooltip) {
|
|
1009
|
+
const content = tooltip.querySelector(TOOLTIP_CONTENT_SELECTOR);
|
|
1010
|
+
if (!content) return;
|
|
1011
|
+
const rect = content.getBoundingClientRect();
|
|
1012
|
+
if (rect.width <= 0 || rect.height <= 0) return;
|
|
1013
|
+
return {
|
|
1014
|
+
x: rect.left + rect.width / 2,
|
|
1015
|
+
y: rect.top + rect.height / 2
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
function getTooltipSnapshot(tooltip) {
|
|
1019
|
+
const center = getTooltipCenter(tooltip);
|
|
1020
|
+
if (!center) return;
|
|
1021
|
+
const opacity = Number.parseFloat(tooltip.ownerDocument.defaultView.getComputedStyle(tooltip).opacity);
|
|
1022
|
+
return {
|
|
1023
|
+
center,
|
|
1024
|
+
opacity: Number.isFinite(opacity) ? opacity : 0
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
function getCarrierKind(root) {
|
|
1028
|
+
return root.dataset.activeThumb === "lower" ? "upper" : "lower";
|
|
1029
|
+
}
|
|
1030
|
+
function getTransitionOptions(root) {
|
|
1031
|
+
const transition = root.ownerDocument.defaultView.getComputedStyle(root).getPropertyValue("--rp-transition-fast").trim();
|
|
1032
|
+
const durationMatch = transition.match(/([\d.]+)(ms|s)/);
|
|
1033
|
+
if (!durationMatch) return {
|
|
1034
|
+
duration: DEFAULT_TRANSITION_DURATION,
|
|
1035
|
+
easing: DEFAULT_TRANSITION_EASING
|
|
1036
|
+
};
|
|
1037
|
+
const durationValue = Number.parseFloat(durationMatch[1]);
|
|
1038
|
+
return {
|
|
1039
|
+
duration: durationMatch[2] === "s" ? durationValue * 1e3 : durationValue,
|
|
1040
|
+
easing: transition.match(TRANSITION_EASING_PATTERN)?.[0] ?? DEFAULT_TRANSITION_EASING
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
function prefersReducedMotion(root) {
|
|
1044
|
+
return root.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
1045
|
+
}
|
|
1046
|
+
function getTranslate(from, base) {
|
|
1047
|
+
return `translate3d(${from.x - base.x}px, ${from.y - base.y}px, 0)`;
|
|
1048
|
+
}
|
|
1049
|
+
function useRangeSliderTooltipTransition(root, tooltipsOverlapping, value, activeThumb) {
|
|
1050
|
+
const animations = /* @__PURE__ */ new Set();
|
|
1051
|
+
let inferredCarrier;
|
|
1052
|
+
let frozenMergedContent;
|
|
1053
|
+
let frozenMergedTooltip;
|
|
1054
|
+
let heldSplitOpacity = [];
|
|
1055
|
+
let transitionId = 0;
|
|
1056
|
+
watch(activeThumb, () => {
|
|
1057
|
+
inferredCarrier = void 0;
|
|
1058
|
+
}, { flush: "sync" });
|
|
1059
|
+
watch(value, (next, previous) => {
|
|
1060
|
+
const lowerMoved = next[0] !== previous[0];
|
|
1061
|
+
if (lowerMoved !== (next[1] !== previous[1])) inferredCarrier = lowerMoved ? "upper" : "lower";
|
|
1062
|
+
else inferredCarrier = void 0;
|
|
1063
|
+
}, { flush: "sync" });
|
|
1064
|
+
function clearFrozenMergedPosition() {
|
|
1065
|
+
if (frozenMergedTooltip) {
|
|
1066
|
+
frozenMergedTooltip.style.removeProperty("left");
|
|
1067
|
+
frozenMergedTooltip.style.removeProperty("top");
|
|
1068
|
+
}
|
|
1069
|
+
if (frozenMergedContent) {
|
|
1070
|
+
const { element, height, width } = frozenMergedContent;
|
|
1071
|
+
if (width) element.style.width = width;
|
|
1072
|
+
else element.style.removeProperty("width");
|
|
1073
|
+
if (height) element.style.height = height;
|
|
1074
|
+
else element.style.removeProperty("height");
|
|
1075
|
+
}
|
|
1076
|
+
frozenMergedTooltip = void 0;
|
|
1077
|
+
frozenMergedContent = void 0;
|
|
1078
|
+
}
|
|
1079
|
+
function freezeMergedPosition(merged) {
|
|
1080
|
+
const style = merged.ownerDocument.defaultView.getComputedStyle(merged);
|
|
1081
|
+
const content = merged.querySelector(TOOLTIP_CONTENT_SELECTOR);
|
|
1082
|
+
merged.style.left = style.left;
|
|
1083
|
+
merged.style.top = style.top;
|
|
1084
|
+
frozenMergedTooltip = merged;
|
|
1085
|
+
if (content) {
|
|
1086
|
+
const rect = content.getBoundingClientRect();
|
|
1087
|
+
frozenMergedContent = {
|
|
1088
|
+
element: content,
|
|
1089
|
+
height: content.style.height,
|
|
1090
|
+
width: content.style.width
|
|
1091
|
+
};
|
|
1092
|
+
content.style.width = `${rect.width}px`;
|
|
1093
|
+
content.style.height = `${rect.height}px`;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
function clearHeldSplitOpacity() {
|
|
1097
|
+
for (const { element, opacity } of heldSplitOpacity) if (opacity) element.style.opacity = opacity;
|
|
1098
|
+
else element.style.removeProperty("opacity");
|
|
1099
|
+
heldSplitOpacity = [];
|
|
1100
|
+
}
|
|
1101
|
+
function holdSplitOpacity(merged, endpoints) {
|
|
1102
|
+
heldSplitOpacity = [merged, ...endpoints].map((element) => ({
|
|
1103
|
+
element,
|
|
1104
|
+
opacity: element.style.opacity
|
|
1105
|
+
}));
|
|
1106
|
+
merged.style.opacity = "1";
|
|
1107
|
+
for (const endpoint of endpoints) endpoint.style.opacity = "0";
|
|
1108
|
+
}
|
|
1109
|
+
function cancelAnimations() {
|
|
1110
|
+
for (const animation of animations) animation.cancel();
|
|
1111
|
+
animations.clear();
|
|
1112
|
+
}
|
|
1113
|
+
function animate(element, keyframes, options, onComplete) {
|
|
1114
|
+
let animation;
|
|
1115
|
+
try {
|
|
1116
|
+
animation = element.animate(keyframes, options);
|
|
1117
|
+
} catch {
|
|
1118
|
+
try {
|
|
1119
|
+
animation = element.animate(keyframes, {
|
|
1120
|
+
duration: DEFAULT_TRANSITION_DURATION,
|
|
1121
|
+
easing: DEFAULT_TRANSITION_EASING
|
|
1122
|
+
});
|
|
1123
|
+
} catch {
|
|
1124
|
+
onComplete?.();
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
animations.add(animation);
|
|
1129
|
+
let completed = false;
|
|
1130
|
+
const removeAnimation = () => {
|
|
1131
|
+
if (completed) return;
|
|
1132
|
+
completed = true;
|
|
1133
|
+
animations.delete(animation);
|
|
1134
|
+
onComplete?.();
|
|
1135
|
+
};
|
|
1136
|
+
animation.addEventListener("cancel", removeAnimation, { once: true });
|
|
1137
|
+
animation.addEventListener("finish", removeAnimation, { once: true });
|
|
1138
|
+
}
|
|
1139
|
+
watch(tooltipsOverlapping, async (overlapping) => {
|
|
1140
|
+
const el = root.value;
|
|
1141
|
+
if (!el) return;
|
|
1142
|
+
const lower = getTooltip(el, "lower");
|
|
1143
|
+
const upper = getTooltip(el, "upper");
|
|
1144
|
+
const merged = getTooltip(el, "merged");
|
|
1145
|
+
const carrier = getTooltip(el, inferredCarrier ?? getCarrierKind(el));
|
|
1146
|
+
inferredCarrier = void 0;
|
|
1147
|
+
if (!lower || !upper || !merged || !carrier) return;
|
|
1148
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
1149
|
+
for (const tooltip of [
|
|
1150
|
+
lower,
|
|
1151
|
+
upper,
|
|
1152
|
+
merged
|
|
1153
|
+
]) {
|
|
1154
|
+
const snapshot = getTooltipSnapshot(tooltip);
|
|
1155
|
+
if (snapshot) snapshots.set(tooltip, snapshot);
|
|
1156
|
+
}
|
|
1157
|
+
const carrierSnapshot = snapshots.get(carrier);
|
|
1158
|
+
const mergedSnapshot = snapshots.get(merged);
|
|
1159
|
+
const currentTransitionId = ++transitionId;
|
|
1160
|
+
await nextTick();
|
|
1161
|
+
if (currentTransitionId !== transitionId || root.value !== el) return;
|
|
1162
|
+
cancelAnimations();
|
|
1163
|
+
clearFrozenMergedPosition();
|
|
1164
|
+
clearHeldSplitOpacity();
|
|
1165
|
+
if (typeof merged.animate !== "function" || prefersReducedMotion(el)) return;
|
|
1166
|
+
const { duration, easing } = getTransitionOptions(el);
|
|
1167
|
+
if (duration <= 0) return;
|
|
1168
|
+
if (!overlapping) {
|
|
1169
|
+
freezeMergedPosition(merged);
|
|
1170
|
+
holdSplitOpacity(merged, [lower, upper]);
|
|
1171
|
+
}
|
|
1172
|
+
const mergedBaseCenter = getTooltipCenter(merged);
|
|
1173
|
+
const carrierCenter = getTooltipCenter(carrier);
|
|
1174
|
+
if (!mergedBaseCenter || !carrierCenter) {
|
|
1175
|
+
clearFrozenMergedPosition();
|
|
1176
|
+
clearHeldSplitOpacity();
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
const options = {
|
|
1180
|
+
duration,
|
|
1181
|
+
easing
|
|
1182
|
+
};
|
|
1183
|
+
const releaseFrozenPosition = overlapping ? void 0 : () => {
|
|
1184
|
+
if (currentTransitionId !== transitionId) return;
|
|
1185
|
+
clearFrozenMergedPosition();
|
|
1186
|
+
clearHeldSplitOpacity();
|
|
1187
|
+
};
|
|
1188
|
+
const mergedStartCenter = mergedSnapshot && mergedSnapshot.opacity > 0 ? mergedSnapshot.center : carrierSnapshot?.center ?? carrierCenter;
|
|
1189
|
+
const mergedEndCenter = overlapping ? mergedBaseCenter : carrierCenter;
|
|
1190
|
+
animate(merged, [{ transform: getTranslate(mergedStartCenter, mergedBaseCenter) }, { transform: getTranslate(mergedEndCenter, mergedBaseCenter) }], options, releaseFrozenPosition);
|
|
1191
|
+
}, { flush: "pre" });
|
|
1192
|
+
onBeforeUnmount(() => {
|
|
1193
|
+
transitionId += 1;
|
|
1194
|
+
cancelAnimations();
|
|
1195
|
+
clearFrozenMergedPosition();
|
|
1196
|
+
clearHeldSplitOpacity();
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
//#endregion
|
|
1200
|
+
//#region src/components/slider/range-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1201
|
+
var t0 = template("<span data-v-3fdd312a class=rp-range-slider__label>");
|
|
1202
|
+
var t1 = template("<span data-v-3fdd312a class=rp-range-slider__value aria-hidden=true>");
|
|
1203
|
+
var t2 = template("<span data-v-3fdd312a class=rp-range-slider__header>");
|
|
1204
|
+
var t3 = template("<span data-v-3fdd312a class=rp-range-slider__mark-label> ");
|
|
1205
|
+
var t4 = template("<span data-v-3fdd312a><span data-v-3fdd312a class=rp-range-slider__mark-dot></span>");
|
|
1206
|
+
var t5 = template("<span data-v-3fdd312a class=rp-range-slider__marks aria-hidden=true>");
|
|
1207
|
+
var t6 = template("<span data-v-3fdd312a class=rp-range-slider__tooltip-anchor>", 2);
|
|
1208
|
+
var t7 = template("<div data-v-3fdd312a role=group><span data-v-3fdd312a class=rp-range-slider__track><span data-v-3fdd312a class=rp-range-slider__bar aria-hidden=true></span><input data-v-3fdd312a class=\"rp-range-slider__native rp-range-slider__native--lower\"type=range><input data-v-3fdd312a class=\"rp-range-slider__native rp-range-slider__native--upper\"type=range><!><span data-v-3fdd312a class=rp-range-slider__thumbs aria-hidden=true><span data-v-3fdd312a class=\"rp-range-slider__thumb rp-range-slider__thumb--lower\"data-range-slider-thumb=lower><span data-v-3fdd312a class=rp-range-slider__thumb-content></span></span><span data-v-3fdd312a class=\"rp-range-slider__thumb rp-range-slider__thumb--upper\"data-range-slider-thumb=upper><span data-v-3fdd312a class=rp-range-slider__thumb-content>", 1);
|
|
1209
|
+
delegateEvents("input", "keydown", "pointerdown");
|
|
1210
|
+
//#endregion
|
|
1211
|
+
//#region src/components/slider/range-slider.vue
|
|
1212
|
+
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
1213
|
+
name: "RpRangeSlider",
|
|
1214
|
+
__name: "range-slider",
|
|
1215
|
+
props: {
|
|
1216
|
+
modelValue: {},
|
|
1217
|
+
minRange: { default: 0 },
|
|
1218
|
+
name: {},
|
|
1219
|
+
ariaLabel: { default: () => ["Minimum", "Maximum"] },
|
|
1220
|
+
ariaValueText: {},
|
|
1221
|
+
id: {},
|
|
1222
|
+
min: { default: 0 },
|
|
1223
|
+
max: { default: 100 },
|
|
1224
|
+
step: { default: 1 },
|
|
1225
|
+
marks: { default: () => [] },
|
|
1226
|
+
thumbStyle: {},
|
|
1227
|
+
tooltip: {
|
|
1228
|
+
type: [
|
|
1229
|
+
Boolean,
|
|
1230
|
+
String,
|
|
1231
|
+
Object
|
|
1232
|
+
],
|
|
1233
|
+
default: "hover"
|
|
1234
|
+
},
|
|
1235
|
+
formatValue: {},
|
|
1236
|
+
color: {},
|
|
1237
|
+
size: {},
|
|
1238
|
+
orientation: { default: "horizontal" },
|
|
1239
|
+
disabled: {
|
|
1240
|
+
type: Boolean,
|
|
1241
|
+
default: void 0
|
|
1242
|
+
},
|
|
1243
|
+
required: {
|
|
1244
|
+
type: Boolean,
|
|
1245
|
+
default: void 0
|
|
1246
|
+
},
|
|
1247
|
+
invalid: {
|
|
1248
|
+
type: Boolean,
|
|
1249
|
+
default: void 0
|
|
1250
|
+
},
|
|
1251
|
+
valid: {
|
|
1252
|
+
type: Boolean,
|
|
1253
|
+
default: void 0
|
|
1254
|
+
},
|
|
1255
|
+
describedby: {},
|
|
1256
|
+
labelledby: {}
|
|
1257
|
+
},
|
|
1258
|
+
emits: ["update:modelValue"],
|
|
1259
|
+
setup(__props, { emit: __emit, slots: $slots }) {
|
|
1260
|
+
const props = __props;
|
|
1261
|
+
const emit = __emit;
|
|
1262
|
+
const slots = useSlots();
|
|
1263
|
+
const generatedId = useId();
|
|
1264
|
+
const rangeSliderRef = ref(null);
|
|
1265
|
+
const labelId = computed(() => `${props.id ?? generatedId}-label`);
|
|
1266
|
+
const { control, nativeMin, nativeMax, nativeStep, nativeNames, nativeIds, rootClass, normalizedValue, valuePercent, formattedValue, ariaLabels, ariaValueText, markItems, trackStyle, activeThumb, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipIds, mergedTooltipId, tooltipColor, tooltipOffset, tooltipOpenDelay, tooltipArrow, tooltipContent, mergedTooltipContent, onInput, onTrackPointerDown, onTooltipFocus, onTooltipBlur, onTooltipTrackMouseEnter, onTooltipTrackMouseLeave, onTooltipKeydown } = useRangeSlider(props, (value) => {
|
|
1267
|
+
emit("update:modelValue", value);
|
|
1268
|
+
});
|
|
1269
|
+
const { tooltipsOverlapping } = useRangeSliderTooltipCollision(rangeSliderRef);
|
|
1270
|
+
useRangeSliderTooltipTransition(rangeSliderRef, tooltipsOverlapping, normalizedValue, activeThumb);
|
|
1271
|
+
const groupLabelledby = computed(() => {
|
|
1272
|
+
const values = [control.ariaLabelledby, slots.default ? labelId.value : void 0].flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
1273
|
+
return values.length ? Array.from(new Set(values)).join(" ") : void 0;
|
|
1274
|
+
});
|
|
1275
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
1276
|
+
const n43 = t7();
|
|
1277
|
+
const n42 = child(n43, 1);
|
|
1278
|
+
const n11 = next(child(n42), 1);
|
|
1279
|
+
const n12 = next(n11, 2);
|
|
1280
|
+
const n41 = next(n12, 3);
|
|
1281
|
+
const n40 = next(n41, 4);
|
|
1282
|
+
const n28 = child(n40);
|
|
1283
|
+
const n23 = child(n28);
|
|
1284
|
+
const n35 = next(n28, 1);
|
|
1285
|
+
const n30 = child(n35);
|
|
1286
|
+
renderEffect(() => {
|
|
1287
|
+
const _control = unref(control);
|
|
1288
|
+
setClass(n43, [unref(rootClass), {
|
|
1289
|
+
"rp-range-slider--custom-thumb": $slots.thumb,
|
|
1290
|
+
"rp-range-slider--tooltips-overlapping": unref(tooltipsOverlapping)
|
|
1291
|
+
}]);
|
|
1292
|
+
setAttr(n43, "data-active-thumb", unref(activeThumb));
|
|
1293
|
+
setAttr(n43, "data-disabled", _control.disabled || void 0);
|
|
1294
|
+
setStyle(n43, unref(trackStyle));
|
|
1295
|
+
setAttr(n43, "aria-labelledby", groupLabelledby.value);
|
|
1296
|
+
setAttr(n43, "aria-describedby", _control.ariaDescribedby);
|
|
1297
|
+
setAttr(n43, "aria-invalid", _control.invalid || void 0);
|
|
1298
|
+
setAttr(n43, "aria-required", _control.required || void 0);
|
|
1299
|
+
});
|
|
1300
|
+
setInsertionState(n43, 0, 0);
|
|
1301
|
+
createIf(() => $slots.default || $slots.value, () => {
|
|
1302
|
+
const n10 = t2();
|
|
1303
|
+
setInsertionState(n10, null, 0);
|
|
1304
|
+
createIf(() => $slots.default, () => {
|
|
1305
|
+
const n5 = t0();
|
|
1306
|
+
renderEffect(() => setProp(n5, "id", labelId.value));
|
|
1307
|
+
setInsertionState(n5, null, 0);
|
|
1308
|
+
createSlot("default", null, null, 1);
|
|
1309
|
+
return n5;
|
|
1310
|
+
});
|
|
1311
|
+
setInsertionState(n10, null, 1);
|
|
1312
|
+
createIf(() => $slots.value, () => {
|
|
1313
|
+
const n9 = t1();
|
|
1314
|
+
setInsertionState(n9, null, 0);
|
|
1315
|
+
createSlot("value", {
|
|
1316
|
+
value: () => unref(normalizedValue),
|
|
1317
|
+
formattedValue: () => unref(formattedValue),
|
|
1318
|
+
percent: () => unref(valuePercent)
|
|
1319
|
+
}, null, 1);
|
|
1320
|
+
return n9;
|
|
1321
|
+
});
|
|
1322
|
+
return n10;
|
|
1323
|
+
});
|
|
1324
|
+
n11.$evtinput = createInvoker(($event) => unref(onInput)("lower", $event));
|
|
1325
|
+
on(n11, "focus", () => unref(onTooltipFocus)("lower"));
|
|
1326
|
+
on(n11, "blur", () => unref(onTooltipBlur)("lower"));
|
|
1327
|
+
n11.$evtkeydown = createInvoker(($event) => unref(onTooltipKeydown)("lower", $event));
|
|
1328
|
+
n12.$evtinput = createInvoker(($event) => unref(onInput)("upper", $event));
|
|
1329
|
+
on(n12, "focus", () => unref(onTooltipFocus)("upper"));
|
|
1330
|
+
on(n12, "blur", () => unref(onTooltipBlur)("upper"));
|
|
1331
|
+
n12.$evtkeydown = createInvoker(($event) => unref(onTooltipKeydown)("upper", $event));
|
|
1332
|
+
renderEffect(() => {
|
|
1333
|
+
const _nativeIds = unref(nativeIds);
|
|
1334
|
+
const _nativeNames = unref(nativeNames);
|
|
1335
|
+
const _normalizedValue = unref(normalizedValue);
|
|
1336
|
+
const _nativeMin = unref(nativeMin);
|
|
1337
|
+
const _nativeMax = unref(nativeMax);
|
|
1338
|
+
const _nativeStep = unref(nativeStep);
|
|
1339
|
+
const _control = unref(control);
|
|
1340
|
+
const _ariaLabels = unref(ariaLabels);
|
|
1341
|
+
const _ariaValueText = unref(ariaValueText);
|
|
1342
|
+
const _control_disabled = _control.disabled;
|
|
1343
|
+
const _control_required = _control.required;
|
|
1344
|
+
const _control_ariaDescribedby = _control.ariaDescribedby;
|
|
1345
|
+
const _control_invalid = _control.invalid;
|
|
1346
|
+
setProp(n11, "id", _nativeIds[0]);
|
|
1347
|
+
setProp(n11, "name", _nativeNames[0]);
|
|
1348
|
+
setValue(n11, _normalizedValue[0]);
|
|
1349
|
+
setProp(n11, "min", _nativeMin[0]);
|
|
1350
|
+
setProp(n11, "max", _nativeMax[0]);
|
|
1351
|
+
setProp(n11, "step", _nativeStep);
|
|
1352
|
+
setProp(n11, "orient", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1353
|
+
setProp(n11, "disabled", _control_disabled || void 0);
|
|
1354
|
+
setProp(n11, "required", _control_required || void 0);
|
|
1355
|
+
setAttr(n11, "aria-label", _ariaLabels[0]);
|
|
1356
|
+
setAttr(n11, "aria-describedby", _control_ariaDescribedby);
|
|
1357
|
+
setAttr(n11, "aria-orientation", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1358
|
+
setAttr(n11, "aria-invalid", _control_invalid || void 0);
|
|
1359
|
+
setAttr(n11, "aria-required", _control_required || void 0);
|
|
1360
|
+
setAttr(n11, "aria-valuetext", _ariaValueText[0]);
|
|
1361
|
+
setProp(n12, "id", _nativeIds[1]);
|
|
1362
|
+
setProp(n12, "name", _nativeNames[1]);
|
|
1363
|
+
setValue(n12, _normalizedValue[1]);
|
|
1364
|
+
setProp(n12, "min", _nativeMin[1]);
|
|
1365
|
+
setProp(n12, "max", _nativeMax[1]);
|
|
1366
|
+
setProp(n12, "step", _nativeStep);
|
|
1367
|
+
setProp(n12, "orient", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1368
|
+
setProp(n12, "disabled", _control_disabled || void 0);
|
|
1369
|
+
setProp(n12, "required", _control_required || void 0);
|
|
1370
|
+
setAttr(n12, "aria-label", _ariaLabels[1]);
|
|
1371
|
+
setAttr(n12, "aria-describedby", _control_ariaDescribedby);
|
|
1372
|
+
setAttr(n12, "aria-orientation", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1373
|
+
setAttr(n12, "aria-invalid", _control_invalid || void 0);
|
|
1374
|
+
setAttr(n12, "aria-required", _control_required || void 0);
|
|
1375
|
+
setAttr(n12, "aria-valuetext", _ariaValueText[1]);
|
|
1376
|
+
});
|
|
1377
|
+
setInsertionState(n42, n41, 3);
|
|
1378
|
+
createIf(() => unref(markItems).length, () => {
|
|
1379
|
+
const n21 = t5();
|
|
1380
|
+
setInsertionState(n21, null, 0);
|
|
1381
|
+
createFor(() => unref(markItems), (_for_item0) => {
|
|
1382
|
+
const n20 = t4();
|
|
1383
|
+
renderEffect(() => {
|
|
1384
|
+
const _mark = _for_item0.value;
|
|
1385
|
+
setClassName(n20, _mark.filled ? 1 : 0, " rp-range-slider__mark--filled", "rp-range-slider__mark");
|
|
1386
|
+
setStyle(n20, _mark.style);
|
|
1387
|
+
});
|
|
1388
|
+
setInsertionState(n20, null, 1);
|
|
1389
|
+
createIf(() => _for_item0.value.hasLabel, () => {
|
|
1390
|
+
const n19 = t3();
|
|
1391
|
+
const x19 = txt(n19);
|
|
1392
|
+
renderEffect(() => setText(x19, toDisplayString(_for_item0.value.label)));
|
|
1393
|
+
return n19;
|
|
1394
|
+
});
|
|
1395
|
+
return n20;
|
|
1396
|
+
}, (mark) => mark.key, 9);
|
|
1397
|
+
return n21;
|
|
1398
|
+
});
|
|
1399
|
+
setInsertionState(n23, null, 0);
|
|
1400
|
+
createSlot("thumb", {
|
|
1401
|
+
thumb: "lower",
|
|
1402
|
+
index: "0",
|
|
1403
|
+
value: () => unref(normalizedValue)[0],
|
|
1404
|
+
formattedValue: () => unref(formattedValue)[0],
|
|
1405
|
+
percent: () => unref(valuePercent)[0]
|
|
1406
|
+
}, null, 1);
|
|
1407
|
+
setInsertionState(n28, null, 1);
|
|
1408
|
+
createIf(() => unref(tooltipVisible), () => {
|
|
1409
|
+
return createComponent(tooltip_default, {
|
|
1410
|
+
id: () => unref(tooltipIds)[0],
|
|
1411
|
+
class: "rp-range-slider__tooltip rp-range-slider__tooltip--lower",
|
|
1412
|
+
content: () => unref(tooltipContent)[0],
|
|
1413
|
+
placement: () => unref(tooltipPlacement),
|
|
1414
|
+
color: () => unref(tooltipColor),
|
|
1415
|
+
offset: () => unref(tooltipOffset),
|
|
1416
|
+
open: () => unref(tooltipOpen),
|
|
1417
|
+
"open-delay": () => unref(tooltipOpenDelay),
|
|
1418
|
+
arrow: () => unref(tooltipArrow),
|
|
1419
|
+
decorative: ""
|
|
1420
|
+
}, () => {
|
|
1421
|
+
return t6();
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
setInsertionState(n30, null, 0);
|
|
1425
|
+
createSlot("thumb", {
|
|
1426
|
+
thumb: "upper",
|
|
1427
|
+
index: "1",
|
|
1428
|
+
value: () => unref(normalizedValue)[1],
|
|
1429
|
+
formattedValue: () => unref(formattedValue)[1],
|
|
1430
|
+
percent: () => unref(valuePercent)[1]
|
|
1431
|
+
}, null, 1);
|
|
1432
|
+
setInsertionState(n35, null, 1);
|
|
1433
|
+
createIf(() => unref(tooltipVisible), () => {
|
|
1434
|
+
return createComponent(tooltip_default, {
|
|
1435
|
+
id: () => unref(tooltipIds)[1],
|
|
1436
|
+
class: "rp-range-slider__tooltip rp-range-slider__tooltip--upper",
|
|
1437
|
+
content: () => unref(tooltipContent)[1],
|
|
1438
|
+
placement: () => unref(tooltipPlacement),
|
|
1439
|
+
color: () => unref(tooltipColor),
|
|
1440
|
+
offset: () => unref(tooltipOffset),
|
|
1441
|
+
open: () => unref(tooltipOpen),
|
|
1442
|
+
"open-delay": () => unref(tooltipOpenDelay),
|
|
1443
|
+
arrow: () => unref(tooltipArrow),
|
|
1444
|
+
decorative: ""
|
|
1445
|
+
}, () => {
|
|
1446
|
+
return t6();
|
|
1447
|
+
});
|
|
1448
|
+
});
|
|
1449
|
+
setInsertionState(n40, null, 2);
|
|
1450
|
+
createIf(() => unref(tooltipVisible), () => {
|
|
1451
|
+
return createComponent(tooltip_default, {
|
|
1452
|
+
id: () => unref(mergedTooltipId),
|
|
1453
|
+
class: "rp-range-slider__tooltip rp-range-slider__tooltip--merged",
|
|
1454
|
+
content: () => unref(mergedTooltipContent),
|
|
1455
|
+
placement: () => unref(tooltipPlacement),
|
|
1456
|
+
color: () => unref(tooltipColor),
|
|
1457
|
+
offset: () => unref(tooltipOffset),
|
|
1458
|
+
open: () => unref(tooltipOpen),
|
|
1459
|
+
"open-delay": () => unref(tooltipOpenDelay),
|
|
1460
|
+
arrow: () => unref(tooltipArrow),
|
|
1461
|
+
decorative: ""
|
|
1462
|
+
}, () => {
|
|
1463
|
+
return t6();
|
|
1464
|
+
});
|
|
1465
|
+
});
|
|
1466
|
+
n42.$evtpointerdown = createInvoker((e) => unref(onTrackPointerDown)(e));
|
|
1467
|
+
on(n42, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1468
|
+
on(n42, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1469
|
+
_setTemplateRef(n43, rangeSliderRef, null, "rangeSliderRef");
|
|
1470
|
+
return n43;
|
|
1471
|
+
}
|
|
1472
|
+
}), [["__scopeId", "data-v-3fdd312a"]]);
|
|
1473
|
+
//#endregion
|
|
1474
|
+
//#region src/components/slider/types.ts
|
|
1475
|
+
var sliderColors = componentColors;
|
|
1476
|
+
var sliderSizes = [
|
|
1477
|
+
"xs",
|
|
1478
|
+
"sm",
|
|
1479
|
+
"md",
|
|
1480
|
+
"lg",
|
|
1481
|
+
"xl"
|
|
1482
|
+
];
|
|
1483
|
+
var sliderOrientations = ["horizontal", "vertical"];
|
|
1484
|
+
//#endregion
|
|
1485
|
+
export { slider_default as a, range_slider_default as i, sliderOrientations as n, sliderSizes as r, sliderColors as t };
|