ropav 0.0.8 → 0.0.10
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 -2
- 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 -16
- package/dist/base.css +609 -180
- 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 -9
- package/dist/card.css +12 -12
- package/dist/check.js +12 -0
- package/dist/checkbox.css +16 -57
- package/dist/checkbox.js +14 -31
- package/dist/collapse.css +2 -2
- package/dist/collapse.js +1 -1
- package/dist/color-input.css +108 -0
- package/dist/color-input.js +349 -0
- package/dist/color-picker.css +304 -0
- package/dist/color-picker.js +797 -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 -13
- package/dist/components/accordion/accordion-item.d.ts +4 -4
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/index.d.ts +4 -4
- package/dist/components/accordion/types.d.ts +1 -1
- package/dist/components/accordion/useAccordion.d.ts +1 -1
- 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/badge.d.ts +1 -1
- package/dist/components/badge/index.d.ts +3 -3
- package/dist/components/badge/types.d.ts +3 -2
- package/dist/components/badge/useBadgeColor.d.ts +3 -8
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/types.d.ts +2 -1
- package/dist/components/button/useButtonColor.d.ts +3 -13
- package/dist/components/button-group/button-group.d.ts +1 -1
- package/dist/components/button-group/index.d.ts +2 -2
- 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 +1 -1
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/types.d.ts +2 -1
- package/dist/components/checkbox/useCheckbox.d.ts +4 -6
- package/dist/components/collapse/collapse.d.ts +2 -2
- package/dist/components/collapse/index.d.ts +3 -3
- package/dist/components/collapse/useCollapse.d.ts +1 -1
- 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 +35 -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 +16 -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-items.d.ts +15 -6
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +3 -3
- package/dist/components/dropdown-menu/index.d.ts +3 -3
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -10
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +3 -3
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +12 -4
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +3 -3
- package/dist/components/field/field.d.ts +2 -2
- package/dist/components/field/index.d.ts +2 -2
- package/dist/components/field/types.d.ts +0 -2
- package/dist/components/field/useField.d.ts +1 -3
- package/dist/components/icon-button/icon-button.d.ts +1 -1
- package/dist/components/icon-button/index.d.ts +2 -2
- package/dist/components/icon-button/types.d.ts +2 -1
- package/dist/components/input/index.d.ts +2 -2
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/types.d.ts +3 -0
- package/dist/components/input/useInput.d.ts +2 -2
- package/dist/components/modal/index.d.ts +2 -2
- package/dist/components/modal/modal.d.ts +1 -1
- package/dist/components/modal/types.d.ts +1 -1
- package/dist/components/modal/useModal.d.ts +1 -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/overlay/index.d.ts +2 -2
- package/dist/components/overlay/overlay.d.ts +1 -1
- package/dist/components/overlay/useOverlay.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -2
- package/dist/components/popover/index.js +2 -1
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/types.d.ts +3 -1
- package/dist/components/popover/usePopover.d.ts +2 -1
- package/dist/components/progress/index.d.ts +3 -3
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/progress/types.d.ts +2 -2
- package/dist/components/progress/useProgress.d.ts +2 -2
- package/dist/components/radio/index.d.ts +3 -3
- package/dist/components/radio/radio-group.d.ts +1 -1
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/types.d.ts +4 -1
- package/dist/components/radio/useRadio.d.ts +4 -6
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/types.d.ts +3 -0
- package/dist/components/select/useSelect.d.ts +2 -2
- package/dist/components/slider/index.d.ts +4 -3
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/range-slider-tooltip.d.ts +34 -0
- package/dist/components/slider/range-slider.d.ts +37 -0
- package/dist/components/slider/slider.d.ts +1 -1
- package/dist/components/slider/sliderCore.d.ts +35 -0
- package/dist/components/slider/types.d.ts +15 -6
- package/dist/components/slider/useRangeSlider.d.ts +57 -0
- package/dist/components/slider/useRangeSliderPointer.d.ts +19 -0
- package/dist/components/slider/useRangeSliderTooltipCollision.d.ts +36 -0
- package/dist/components/slider/useRangeSliderTooltipState.d.ts +23 -0
- package/dist/components/slider/useSlider.d.ts +11 -15
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/types.d.ts +1 -1
- package/dist/components/switch/useSwitch.d.ts +4 -5
- package/dist/components/tabs/index.d.ts +6 -6
- package/dist/components/tabs/tabs-content.d.ts +2 -2
- package/dist/components/tabs/tabs-list.d.ts +4 -4
- package/dist/components/tabs/tabs-trigger.d.ts +5 -5
- package/dist/components/tabs/tabs.d.ts +5 -5
- package/dist/components/tabs/useTabs.d.ts +1 -1
- package/dist/components/textarea/index.d.ts +2 -2
- package/dist/components/textarea/textarea.d.ts +1 -1
- package/dist/components/textarea/useTextarea.d.ts +2 -2
- package/dist/components/toast/defaults.d.ts +7 -0
- package/dist/components/toast/index.d.ts +7 -0
- package/dist/components/toast/index.js +2 -0
- package/dist/components/toast/toast-provider.d.ts +21 -0
- package/dist/components/toast/toast-viewport.d.ts +34 -0
- package/dist/components/toast/toast.d.ts +31 -0
- package/dist/components/toast/types.d.ts +106 -0
- package/dist/components/toast/useToast.d.ts +4 -0
- package/dist/components/toast/useToastColor.d.ts +3 -0
- package/dist/components/toast/useToastState.d.ts +2 -0
- package/dist/components/tooltip/index.d.ts +2 -2
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/types.d.ts +2 -1
- package/dist/components/tooltip/useTooltip.d.ts +3 -1
- package/dist/dropdown-menu.css +17 -17
- package/dist/dropdown-menu.js +160 -39
- package/dist/field.css +15 -18
- package/dist/field.js +17 -35
- package/dist/icon-button.css +57 -236
- package/dist/icon-button.js +5 -6
- package/dist/index.d.ts +31 -22
- package/dist/index.js +17 -4
- package/dist/input.css +40 -46
- package/dist/input.js +39 -21
- package/dist/minus.js +12 -0
- package/dist/modal.css +9 -9
- package/dist/modal.js +1 -1
- 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 -3
- package/dist/popover.css +62 -29
- package/dist/popover.js +33 -19
- package/dist/popover2.js +17 -0
- package/dist/progress.css +9 -30
- package/dist/progress.js +3 -6
- package/dist/radio.css +34 -62
- package/dist/radio.js +28 -16
- package/dist/rafScheduler.js +34 -0
- package/dist/select.css +105 -61
- package/dist/select.js +12 -8
- package/dist/slider.css +719 -125
- package/dist/slider.js +1251 -149
- package/dist/switch.css +19 -44
- package/dist/switch.js +4 -5
- package/dist/tabs.css +36 -36
- package/dist/tabs.js +1 -1
- package/dist/textarea.css +33 -25
- package/dist/textarea.js +8 -2
- package/dist/toast.css +232 -0
- package/dist/toast.js +679 -0
- package/dist/tooltip.css +7 -35
- package/dist/tooltip.js +30 -18
- package/dist/useButtonColor.js +16 -14
- package/dist/utils/componentColors.d.ts +60 -0
- package/package.json +55 -15
- package/src/styles/_mixins.scss +25 -41
- package/src/styles/_tokens.scss +615 -182
- package/src/styles/_variables.scss +177 -49
package/dist/slider.js
CHANGED
|
@@ -1,46 +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
|
-
import {
|
|
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/
|
|
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
|
|
26
|
-
//#region src/components/slider/useSlider.ts
|
|
27
|
-
var sliderColorNames = new Set(sliderColors);
|
|
28
|
-
var sliderMarkColorProperties = [
|
|
29
|
-
"--_rp-slider-mark-color",
|
|
30
|
-
"--_rp-slider-mark-label-color",
|
|
31
|
-
"--_rp-slider-mark-filled-label-color",
|
|
32
|
-
"--_rp-slider-mark-ring-color"
|
|
33
|
-
];
|
|
34
|
-
function normalizeSliderValue(value, min, max, step) {
|
|
35
|
-
const bounds = normalizeSliderBounds(min, max);
|
|
36
|
-
const safeStep = normalizeSliderStep(step);
|
|
37
|
-
const safeValue = Number.isFinite(value) ? value : bounds.min;
|
|
38
|
-
const clamped = Math.min(bounds.max, Math.max(bounds.min, safeValue));
|
|
39
|
-
if (safeStep === "any") return clamped;
|
|
40
|
-
const steps = Math.round((clamped - bounds.min) / safeStep);
|
|
41
|
-
const snapped = bounds.min + steps * safeStep;
|
|
42
|
-
return Math.min(bounds.max, Math.max(bounds.min, Number(snapped.toFixed(10))));
|
|
43
|
-
}
|
|
6
|
+
import { i as useDelayedOpen, n as resolveTooltipColorStyleWithContrast, r as resolveTooltipOffsetStyle, t as tooltip_default } from "./tooltip.js";
|
|
7
|
+
import { applyVShow, child, computed, createComponent, createFor, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, next, on, onBeforeUnmount, onMounted, ref, renderEffect, setAttr, setClass, setClassName, setInsertionState, setProp, setStyle, setText, setValue, template, toDisplayString, toRef, txt, unref, useId, useSlots, watch } from "vue";
|
|
8
|
+
//#region src/components/slider/sliderCore.ts
|
|
44
9
|
function normalizeSliderBounds(min, max) {
|
|
45
10
|
const safeMin = Number.isFinite(min) ? min : 0;
|
|
46
11
|
const safeMax = Number.isFinite(max) ? max : safeMin;
|
|
@@ -55,37 +20,48 @@ function normalizeSliderBounds(min, max) {
|
|
|
55
20
|
function normalizeSliderStep(step) {
|
|
56
21
|
return step === "any" || Number.isFinite(step) && step > 0 ? step : "any";
|
|
57
22
|
}
|
|
23
|
+
function normalizeSliderValue(value, min, max, step) {
|
|
24
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
25
|
+
const safeStep = normalizeSliderStep(step);
|
|
26
|
+
const safeValue = Number.isFinite(value) ? value : bounds.min;
|
|
27
|
+
const clamped = Math.min(bounds.max, Math.max(bounds.min, safeValue));
|
|
28
|
+
if (safeStep === "any") return clamped;
|
|
29
|
+
const steps = Math.round((clamped - bounds.min) / safeStep);
|
|
30
|
+
const snapped = bounds.min + steps * safeStep;
|
|
31
|
+
return Math.min(bounds.max, Math.max(bounds.min, Number(snapped.toFixed(10))));
|
|
32
|
+
}
|
|
58
33
|
function getSliderValuePercent(value, min, max) {
|
|
59
34
|
if (max <= min) return 0;
|
|
60
35
|
const percent = (value - min) / (max - min) * 100;
|
|
61
36
|
return Math.min(100, Math.max(0, percent));
|
|
62
37
|
}
|
|
63
|
-
function
|
|
64
|
-
if (
|
|
65
|
-
return sliderColorNames.has(color) ? `var(--rp-color-${color})` : color;
|
|
38
|
+
function setSliderStyleValue(style, property, value) {
|
|
39
|
+
if (value) style[property] = value;
|
|
66
40
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
41
|
+
function getSliderLengthValue(value) {
|
|
42
|
+
if (value == null || value === "") return void 0;
|
|
43
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
44
|
+
return value;
|
|
69
45
|
}
|
|
70
|
-
function
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
46
|
+
function getSliderBorderValue(value, borderColorProperty) {
|
|
47
|
+
if (value == null || value === "") return void 0;
|
|
48
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px solid var(${borderColorProperty})` : void 0;
|
|
49
|
+
return value;
|
|
73
50
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
51
|
+
function applySliderThumbStyle(style, thumbStyle, properties) {
|
|
52
|
+
setSliderStyleValue(style, properties.size, getSliderLengthValue(thumbStyle?.size));
|
|
53
|
+
setSliderStyleValue(style, properties.border, getSliderBorderValue(thumbStyle?.border, properties.borderColor));
|
|
54
|
+
setSliderStyleValue(style, properties.padding, getSliderLengthValue(thumbStyle?.padding));
|
|
76
55
|
}
|
|
77
|
-
function getSliderMarkStyle(percent, color) {
|
|
78
|
-
const style = {
|
|
79
|
-
const colorValue =
|
|
80
|
-
for (const property of
|
|
56
|
+
function getSliderMarkStyle(percent, color, properties) {
|
|
57
|
+
const style = { [properties.position]: `${percent}%` };
|
|
58
|
+
const colorValue = getComponentColorValue(color);
|
|
59
|
+
for (const property of properties.colors) setSliderStyleValue(style, property, colorValue);
|
|
81
60
|
return style;
|
|
82
61
|
}
|
|
83
|
-
function
|
|
84
|
-
return typeof mark === "number" ? { value: mark } : mark;
|
|
85
|
-
}
|
|
86
|
-
function normalizeSliderMarks(marks, min, max, valuePercent) {
|
|
62
|
+
function createSliderMarkItems(marks, min, max, isFilled, properties) {
|
|
87
63
|
return (marks ?? []).flatMap((markInput, index) => {
|
|
88
|
-
const mark =
|
|
64
|
+
const mark = typeof markInput === "number" ? { value: markInput } : markInput;
|
|
89
65
|
if (mark.hidden) return [];
|
|
90
66
|
const value = Number(mark.value);
|
|
91
67
|
if (!Number.isFinite(value)) return [];
|
|
@@ -95,47 +71,11 @@ function normalizeSliderMarks(marks, min, max, valuePercent) {
|
|
|
95
71
|
value,
|
|
96
72
|
label: mark.label,
|
|
97
73
|
hasLabel: mark.label != null,
|
|
98
|
-
filled: percent
|
|
99
|
-
style: getSliderMarkStyle(percent, mark.color)
|
|
74
|
+
filled: isFilled(value, percent),
|
|
75
|
+
style: getSliderMarkStyle(percent, mark.color, properties)
|
|
100
76
|
};
|
|
101
77
|
});
|
|
102
78
|
}
|
|
103
|
-
function getSliderLengthValue(value) {
|
|
104
|
-
if (value == null || value === "") return void 0;
|
|
105
|
-
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
function getSliderBorderValue(value) {
|
|
109
|
-
if (value == null || value === "") return void 0;
|
|
110
|
-
if (typeof value === "number") return Number.isFinite(value) ? `${value}px solid var(--_rp-slider-thumb-border)` : void 0;
|
|
111
|
-
return value;
|
|
112
|
-
}
|
|
113
|
-
var sliderThumbStyleProps = [
|
|
114
|
-
[
|
|
115
|
-
"--_rp-slider-thumb-size",
|
|
116
|
-
"size",
|
|
117
|
-
getSliderLengthValue
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
"--_rp-slider-thumb-border-style",
|
|
121
|
-
"border",
|
|
122
|
-
getSliderBorderValue
|
|
123
|
-
],
|
|
124
|
-
[
|
|
125
|
-
"--_rp-slider-thumb-padding",
|
|
126
|
-
"padding",
|
|
127
|
-
getSliderLengthValue
|
|
128
|
-
]
|
|
129
|
-
];
|
|
130
|
-
function getSliderTrackStyle(props, valuePercent) {
|
|
131
|
-
const style = {
|
|
132
|
-
"--_rp-slider-percent": `${valuePercent}%`,
|
|
133
|
-
"--_rp-slider-ratio": `${valuePercent / 100}`
|
|
134
|
-
};
|
|
135
|
-
setSliderStyleValue(style, "--_rp-slider-custom-color", getSliderCustomColorValue(props.color));
|
|
136
|
-
for (const [property, propName, getValue] of sliderThumbStyleProps) setSliderStyleValue(style, property, getValue(props.thumbStyle?.[propName]));
|
|
137
|
-
return style;
|
|
138
|
-
}
|
|
139
79
|
function getFormattedSliderValue(value, formatter) {
|
|
140
80
|
return formatter ? formatter(value) : value;
|
|
141
81
|
}
|
|
@@ -152,6 +92,25 @@ function getSliderTooltipMode(tooltip) {
|
|
|
152
92
|
if (typeof tooltip === "object") return tooltip.mode ?? "hover";
|
|
153
93
|
return tooltip;
|
|
154
94
|
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/components/slider/useSlider.ts
|
|
97
|
+
function getSliderColorValue(color) {
|
|
98
|
+
return getComponentColorValue(color);
|
|
99
|
+
}
|
|
100
|
+
function getSliderTrackStyle(props, valuePercent) {
|
|
101
|
+
const style = {
|
|
102
|
+
"--_rp-slider-percent": `${valuePercent}%`,
|
|
103
|
+
"--_rp-slider-ratio": `${valuePercent / 100}`
|
|
104
|
+
};
|
|
105
|
+
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
106
|
+
applySliderThumbStyle(style, props.thumbStyle, {
|
|
107
|
+
size: "--_rp-slider-thumb-size",
|
|
108
|
+
border: "--_rp-slider-thumb-border-style",
|
|
109
|
+
padding: "--_rp-slider-thumb-padding",
|
|
110
|
+
borderColor: "--_rp-slider-thumb-border"
|
|
111
|
+
});
|
|
112
|
+
return style;
|
|
113
|
+
}
|
|
155
114
|
function useSlider(props, emitUpdate) {
|
|
156
115
|
const control = useControlState(props);
|
|
157
116
|
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
@@ -160,7 +119,15 @@ function useSlider(props, emitUpdate) {
|
|
|
160
119
|
const valuePercent = computed(() => getSliderValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
161
120
|
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
162
121
|
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
163
|
-
const markItems = computed(() =>
|
|
122
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
123
|
+
position: "--_rp-slider-mark-position",
|
|
124
|
+
colors: [
|
|
125
|
+
"--_rp-slider-mark-color",
|
|
126
|
+
"--_rp-slider-mark-label-color",
|
|
127
|
+
"--_rp-slider-mark-filled-label-color",
|
|
128
|
+
"--_rp-slider-mark-ring-color"
|
|
129
|
+
]
|
|
130
|
+
}));
|
|
164
131
|
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
165
132
|
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
166
133
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
@@ -168,6 +135,12 @@ function useSlider(props, emitUpdate) {
|
|
|
168
135
|
openDelay: () => tooltipOpenDelay.value,
|
|
169
136
|
disabled: () => tooltipMode.value !== "hover" || control.disabled
|
|
170
137
|
});
|
|
138
|
+
const trackHovered = ref(false);
|
|
139
|
+
const focusWithin = ref(false);
|
|
140
|
+
const dragging = ref(false);
|
|
141
|
+
let dismissed = false;
|
|
142
|
+
let dragView = null;
|
|
143
|
+
let dragPointerId;
|
|
171
144
|
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
172
145
|
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
173
146
|
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
@@ -179,15 +152,12 @@ function useSlider(props, emitUpdate) {
|
|
|
179
152
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
180
153
|
const tooltipContent = computed(() => String(formattedValue.value));
|
|
181
154
|
const rootClass = computed(() => bem("rp-slider", {
|
|
182
|
-
[`color-${props.color}`]: isSliderPresetColor(props.color),
|
|
183
155
|
[`size-${props.size}`]: Boolean(props.size),
|
|
184
156
|
vertical: props.orientation === "vertical",
|
|
185
157
|
marked: markItems.value.length > 0,
|
|
186
158
|
"marks-with-labels": hasMarkLabels.value,
|
|
187
159
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
188
|
-
disabled: control.disabled
|
|
189
|
-
invalid: control.invalid,
|
|
190
|
-
valid: control.valid && !control.invalid
|
|
160
|
+
disabled: control.disabled
|
|
191
161
|
}));
|
|
192
162
|
const trackStyle = computed(() => getSliderTrackStyle(props, valuePercent.value));
|
|
193
163
|
function onInput(e) {
|
|
@@ -195,15 +165,64 @@ function useSlider(props, emitUpdate) {
|
|
|
195
165
|
const input = e.target;
|
|
196
166
|
emitUpdate(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
197
167
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
168
|
+
function hasTooltipInteraction() {
|
|
169
|
+
return trackHovered.value || focusWithin.value || dragging.value;
|
|
200
170
|
}
|
|
201
|
-
function
|
|
171
|
+
function syncTooltip() {
|
|
172
|
+
if (tooltipMode.value === "hover" && !control.disabled && hasTooltipInteraction() && !dismissed) {
|
|
173
|
+
openDelayedTooltip();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
202
176
|
closeDelayedTooltip();
|
|
203
177
|
}
|
|
178
|
+
function onTooltipMouseEnter() {
|
|
179
|
+
trackHovered.value = true;
|
|
180
|
+
dismissed = false;
|
|
181
|
+
syncTooltip();
|
|
182
|
+
}
|
|
183
|
+
function onTooltipMouseLeave() {
|
|
184
|
+
trackHovered.value = false;
|
|
185
|
+
syncTooltip();
|
|
186
|
+
}
|
|
187
|
+
function onTooltipFocusIn() {
|
|
188
|
+
focusWithin.value = true;
|
|
189
|
+
dismissed = false;
|
|
190
|
+
syncTooltip();
|
|
191
|
+
}
|
|
192
|
+
function onTooltipFocusOut() {
|
|
193
|
+
focusWithin.value = false;
|
|
194
|
+
syncTooltip();
|
|
195
|
+
}
|
|
196
|
+
function removeDragListeners() {
|
|
197
|
+
dragView?.removeEventListener("pointerup", onTooltipPointerEnd);
|
|
198
|
+
dragView?.removeEventListener("pointercancel", onTooltipPointerEnd);
|
|
199
|
+
dragView = null;
|
|
200
|
+
dragPointerId = void 0;
|
|
201
|
+
}
|
|
202
|
+
function onTooltipPointerEnd(event) {
|
|
203
|
+
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
204
|
+
dragging.value = false;
|
|
205
|
+
removeDragListeners();
|
|
206
|
+
syncTooltip();
|
|
207
|
+
}
|
|
208
|
+
function onTooltipPointerDown(event) {
|
|
209
|
+
if (control.disabled || event.button !== 0 || event.isPrimary === false) return;
|
|
210
|
+
removeDragListeners();
|
|
211
|
+
dismissed = false;
|
|
212
|
+
dragging.value = true;
|
|
213
|
+
dragPointerId = Number.isFinite(event.pointerId) ? event.pointerId : void 0;
|
|
214
|
+
dragView = event.currentTarget?.ownerDocument.defaultView ?? null;
|
|
215
|
+
dragView?.addEventListener("pointerup", onTooltipPointerEnd);
|
|
216
|
+
dragView?.addEventListener("pointercancel", onTooltipPointerEnd);
|
|
217
|
+
syncTooltip();
|
|
218
|
+
}
|
|
204
219
|
function onTooltipKeydown(event) {
|
|
205
|
-
if (event.key === "Escape")
|
|
220
|
+
if (event.key === "Escape") {
|
|
221
|
+
dismissed = true;
|
|
222
|
+
closeDelayedTooltip();
|
|
223
|
+
}
|
|
206
224
|
}
|
|
225
|
+
onBeforeUnmount(removeDragListeners);
|
|
207
226
|
return {
|
|
208
227
|
control,
|
|
209
228
|
nativeMin: computed(() => bounds.value.min),
|
|
@@ -226,23 +245,26 @@ function useSlider(props, emitUpdate) {
|
|
|
226
245
|
tooltipArrow,
|
|
227
246
|
tooltipContent,
|
|
228
247
|
onInput,
|
|
229
|
-
|
|
230
|
-
|
|
248
|
+
onTooltipPointerDown,
|
|
249
|
+
onTooltipMouseEnter,
|
|
250
|
+
onTooltipMouseLeave,
|
|
251
|
+
onTooltipFocusIn,
|
|
252
|
+
onTooltipFocusOut,
|
|
231
253
|
onTooltipKeydown
|
|
232
254
|
};
|
|
233
255
|
}
|
|
234
256
|
//#endregion
|
|
235
257
|
//#region src/components/slider/slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
236
|
-
var t0 = template("<span data-v-
|
|
237
|
-
var t1 = template("<span data-v-
|
|
238
|
-
var t2 = template("<span data-v-
|
|
239
|
-
var t3 = template("<span data-v-
|
|
240
|
-
var t4 = template("<span data-v-
|
|
241
|
-
var t5 = template("<span data-v-
|
|
242
|
-
var t6 = template("<span data-v-
|
|
243
|
-
var t7 = template("<span data-v-
|
|
244
|
-
var t8 = template("<label data-v-
|
|
245
|
-
delegateEvents("input", "focusin", "focusout", "keydown");
|
|
258
|
+
var t0$2 = template("<span data-v-b852f835 class=rp-slider__label>");
|
|
259
|
+
var t1$2 = template("<span data-v-b852f835 class=rp-slider__value aria-hidden=true>");
|
|
260
|
+
var t2$2 = template("<span data-v-b852f835 class=rp-slider__header>");
|
|
261
|
+
var t3$2 = template("<span data-v-b852f835 class=rp-slider__mark-label> ");
|
|
262
|
+
var t4$2 = template("<span data-v-b852f835><span data-v-b852f835 class=rp-slider__mark-dot></span>");
|
|
263
|
+
var t5$1 = template("<span data-v-b852f835 class=rp-slider__marks aria-hidden=true>");
|
|
264
|
+
var t6$1 = template("<span data-v-b852f835 class=rp-slider__thumb aria-hidden=true><span data-v-b852f835 class=rp-slider__thumb-content>");
|
|
265
|
+
var t7$1 = template("<span data-v-b852f835 class=rp-slider__tooltip-anchor aria-hidden=true>", 2);
|
|
266
|
+
var t8$1 = template("<label data-v-b852f835><span data-v-b852f835 class=rp-slider__track><span data-v-b852f835 class=rp-slider__bar aria-hidden=true></span><input data-v-b852f835 class=rp-slider__native type=range>", 1);
|
|
267
|
+
delegateEvents("input", "pointerdown", "focusin", "focusout", "keydown");
|
|
246
268
|
//#endregion
|
|
247
269
|
//#region src/components/slider/slider.vue
|
|
248
270
|
var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -273,18 +295,6 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
273
295
|
type: Boolean,
|
|
274
296
|
default: void 0
|
|
275
297
|
},
|
|
276
|
-
required: {
|
|
277
|
-
type: Boolean,
|
|
278
|
-
default: void 0
|
|
279
|
-
},
|
|
280
|
-
invalid: {
|
|
281
|
-
type: Boolean,
|
|
282
|
-
default: void 0
|
|
283
|
-
},
|
|
284
|
-
valid: {
|
|
285
|
-
type: Boolean,
|
|
286
|
-
default: void 0
|
|
287
|
-
},
|
|
288
298
|
ariaLabel: {},
|
|
289
299
|
ariaValueText: {},
|
|
290
300
|
describedby: {},
|
|
@@ -294,10 +304,10 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
294
304
|
setup(__props, { emit: __emit, slots: $slots }) {
|
|
295
305
|
const props = __props;
|
|
296
306
|
const emit = __emit;
|
|
297
|
-
const { control, nativeMin, nativeMax, nativeStep, rootClass, normalizedValue, valuePercent, formattedValue, ariaValueText, markItems, trackStyle, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipId, tooltipColor, tooltipOffset, tooltipOpenDelay, tooltipArrow, tooltipContent, onInput,
|
|
307
|
+
const { control, nativeMin, nativeMax, nativeStep, rootClass, normalizedValue, valuePercent, formattedValue, ariaValueText, markItems, trackStyle, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipId, tooltipColor, tooltipOffset, tooltipOpenDelay, tooltipArrow, tooltipContent, onInput, onTooltipPointerDown, onTooltipMouseEnter, onTooltipMouseLeave, onTooltipFocusIn, onTooltipFocusOut, onTooltipKeydown } = useSlider(props, (value) => {
|
|
298
308
|
emit("update:modelValue", value);
|
|
299
309
|
});
|
|
300
|
-
const n31 = t8();
|
|
310
|
+
const n31 = t8$1();
|
|
301
311
|
const n30 = child(n31, 1);
|
|
302
312
|
const n11 = next(child(n30), 1);
|
|
303
313
|
renderEffect(() => {
|
|
@@ -307,17 +317,17 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
307
317
|
});
|
|
308
318
|
setInsertionState(n31, 0, 0);
|
|
309
319
|
createIf(() => $slots.default || $slots.value, () => {
|
|
310
|
-
const n10 = t2();
|
|
320
|
+
const n10 = t2$2();
|
|
311
321
|
setInsertionState(n10, null, 0);
|
|
312
322
|
createIf(() => $slots.default, () => {
|
|
313
|
-
const n5 = t0();
|
|
323
|
+
const n5 = t0$2();
|
|
314
324
|
setInsertionState(n5, null, 0);
|
|
315
325
|
createSlot("default", null, null, 1);
|
|
316
326
|
return n5;
|
|
317
327
|
});
|
|
318
328
|
setInsertionState(n10, null, 1);
|
|
319
329
|
createIf(() => $slots.value, () => {
|
|
320
|
-
const n9 = t1();
|
|
330
|
+
const n9 = t1$2();
|
|
321
331
|
setInsertionState(n9, null, 0);
|
|
322
332
|
createSlot("value", {
|
|
323
333
|
value: () => unref(normalizedValue),
|
|
@@ -331,7 +341,6 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
331
341
|
n11.$evtinput = createInvoker((e) => unref(onInput)(e));
|
|
332
342
|
renderEffect(() => {
|
|
333
343
|
const _control = unref(control);
|
|
334
|
-
const _control_required = _control.required;
|
|
335
344
|
setProp(n11, "id", _control.id);
|
|
336
345
|
setProp(n11, "name", __props.name);
|
|
337
346
|
setValue(n11, unref(normalizedValue));
|
|
@@ -340,21 +349,18 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
340
349
|
setProp(n11, "step", unref(nativeStep));
|
|
341
350
|
setProp(n11, "orient", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
342
351
|
setProp(n11, "disabled", _control.disabled || void 0);
|
|
343
|
-
setProp(n11, "required", _control_required || void 0);
|
|
344
352
|
setAttr(n11, "aria-label", __props.ariaLabel || void 0);
|
|
345
353
|
setAttr(n11, "aria-labelledby", _control.ariaLabelledby);
|
|
346
354
|
setAttr(n11, "aria-describedby", _control.ariaDescribedby);
|
|
347
355
|
setAttr(n11, "aria-orientation", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
348
|
-
setAttr(n11, "aria-invalid", _control.invalid || void 0);
|
|
349
|
-
setAttr(n11, "aria-required", _control_required || void 0);
|
|
350
356
|
setAttr(n11, "aria-valuetext", unref(ariaValueText));
|
|
351
357
|
});
|
|
352
358
|
setInsertionState(n30, null, 2);
|
|
353
359
|
createIf(() => unref(markItems).length, () => {
|
|
354
|
-
const n20 = t5();
|
|
360
|
+
const n20 = t5$1();
|
|
355
361
|
setInsertionState(n20, null, 0);
|
|
356
362
|
createFor(() => unref(markItems), (_for_item0) => {
|
|
357
|
-
const n19 = t4();
|
|
363
|
+
const n19 = t4$2();
|
|
358
364
|
renderEffect(() => {
|
|
359
365
|
const _mark = _for_item0.value;
|
|
360
366
|
setClassName(n19, _mark.filled ? 1 : 0, " rp-slider__mark--filled", "rp-slider__mark");
|
|
@@ -362,7 +368,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
362
368
|
});
|
|
363
369
|
setInsertionState(n19, null, 1);
|
|
364
370
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
365
|
-
const n18 = t3();
|
|
371
|
+
const n18 = t3$2();
|
|
366
372
|
const x18 = txt(n18);
|
|
367
373
|
renderEffect(() => setText(x18, toDisplayString(_for_item0.value.label)));
|
|
368
374
|
return n18;
|
|
@@ -373,7 +379,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
373
379
|
});
|
|
374
380
|
setInsertionState(n30, null, 3);
|
|
375
381
|
createIf(() => $slots.thumb, () => {
|
|
376
|
-
const n25 = t6();
|
|
382
|
+
const n25 = t6$1();
|
|
377
383
|
setInsertionState(child(n25), null, 0);
|
|
378
384
|
createSlot("thumb", {
|
|
379
385
|
value: () => unref(normalizedValue),
|
|
@@ -396,16 +402,1112 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
396
402
|
arrow: () => unref(tooltipArrow),
|
|
397
403
|
decorative: ""
|
|
398
404
|
}, () => {
|
|
399
|
-
return t7();
|
|
405
|
+
return t7$1();
|
|
400
406
|
});
|
|
401
407
|
});
|
|
402
|
-
|
|
403
|
-
on(n30, "
|
|
404
|
-
n30
|
|
405
|
-
n30.$
|
|
408
|
+
n30.$evtpointerdown = createInvoker((e) => unref(onTooltipPointerDown)(e));
|
|
409
|
+
on(n30, "mouseenter", (e) => unref(onTooltipMouseEnter)(e));
|
|
410
|
+
on(n30, "mouseleave", (e) => unref(onTooltipMouseLeave)(e));
|
|
411
|
+
n30.$evtfocusin = createInvoker((e) => unref(onTooltipFocusIn)(e));
|
|
412
|
+
n30.$evtfocusout = createInvoker((e) => unref(onTooltipFocusOut)(e));
|
|
406
413
|
n30.$evtkeydown = createInvoker((e) => unref(onTooltipKeydown)(e));
|
|
407
414
|
return n31;
|
|
408
415
|
}
|
|
409
|
-
}), [["__scopeId", "data-v-
|
|
416
|
+
}), [["__scopeId", "data-v-b852f835"]]);
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
419
|
+
var TOOLTIP_COLLISION_GAP = 4;
|
|
420
|
+
function getAxisSize(size, orientation) {
|
|
421
|
+
return orientation === "horizontal" ? size.width : size.height;
|
|
422
|
+
}
|
|
423
|
+
function getTooltipInterval(anchor, size, orientation, placement) {
|
|
424
|
+
const axisSize = getAxisSize(size, orientation);
|
|
425
|
+
if (orientation === "horizontal" ? placement === "top" || placement === "bottom" : placement === "left" || placement === "right") return {
|
|
426
|
+
start: anchor - axisSize / 2,
|
|
427
|
+
end: anchor + axisSize / 2
|
|
428
|
+
};
|
|
429
|
+
return (orientation === "horizontal" ? placement === "left" : placement === "top") ? {
|
|
430
|
+
start: anchor - axisSize,
|
|
431
|
+
end: anchor
|
|
432
|
+
} : {
|
|
433
|
+
start: anchor,
|
|
434
|
+
end: anchor + axisSize
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function areTooltipIntervalsOverlapping(lower, upper, gap) {
|
|
438
|
+
return lower.start < upper.end + gap && lower.end + gap > upper.start;
|
|
439
|
+
}
|
|
440
|
+
function areRangeSliderTooltipLayoutsOverlapping({ gap = TOOLTIP_COLLISION_GAP, lowerPercent, lowerSize, orientation, placement, trackLength, upperPercent, upperSize }) {
|
|
441
|
+
if (trackLength <= 0 || lowerSize.width <= 0 || lowerSize.height <= 0 || upperSize.width <= 0 || upperSize.height <= 0) return false;
|
|
442
|
+
const getAnchor = (percent) => {
|
|
443
|
+
const ratio = percent / 100;
|
|
444
|
+
return orientation === "vertical" ? trackLength * (1 - ratio) : trackLength * ratio;
|
|
445
|
+
};
|
|
446
|
+
return areTooltipIntervalsOverlapping(getTooltipInterval(getAnchor(lowerPercent), lowerSize, orientation, placement), getTooltipInterval(getAnchor(upperPercent), upperSize, orientation, placement), gap);
|
|
447
|
+
}
|
|
448
|
+
function getObservedSize(entry) {
|
|
449
|
+
const borderBoxSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize;
|
|
450
|
+
if (borderBoxSize) return {
|
|
451
|
+
width: borderBoxSize.inlineSize,
|
|
452
|
+
height: borderBoxSize.blockSize
|
|
453
|
+
};
|
|
454
|
+
return {
|
|
455
|
+
width: entry.contentRect.width,
|
|
456
|
+
height: entry.contentRect.height
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function getElementSize(element) {
|
|
460
|
+
const rect = element.getBoundingClientRect();
|
|
461
|
+
return {
|
|
462
|
+
width: rect.width,
|
|
463
|
+
height: rect.height
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement, root, sizeDependencies = [], upper, valuePercent }) {
|
|
467
|
+
const tooltipsOverlapping = ref(false);
|
|
468
|
+
const rootSize = ref({
|
|
469
|
+
width: 0,
|
|
470
|
+
height: 0
|
|
471
|
+
});
|
|
472
|
+
const lowerSize = ref({
|
|
473
|
+
width: 0,
|
|
474
|
+
height: 0
|
|
475
|
+
});
|
|
476
|
+
const upperSize = ref({
|
|
477
|
+
width: 0,
|
|
478
|
+
height: 0
|
|
479
|
+
});
|
|
480
|
+
let resizeObserver;
|
|
481
|
+
let frameWindow;
|
|
482
|
+
let frameId;
|
|
483
|
+
let destroyed = false;
|
|
484
|
+
function setOverlapping(value) {
|
|
485
|
+
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
486
|
+
}
|
|
487
|
+
function updateCollision() {
|
|
488
|
+
if (!enabled.value) {
|
|
489
|
+
setOverlapping(false);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const trackLength = orientation.value === "horizontal" ? rootSize.value.width : rootSize.value.height;
|
|
493
|
+
setOverlapping(areRangeSliderTooltipLayoutsOverlapping({
|
|
494
|
+
gap: TOOLTIP_COLLISION_GAP,
|
|
495
|
+
lowerPercent: valuePercent.value[0],
|
|
496
|
+
lowerSize: lowerSize.value,
|
|
497
|
+
orientation: orientation.value,
|
|
498
|
+
placement: placement.value,
|
|
499
|
+
trackLength,
|
|
500
|
+
upperPercent: valuePercent.value[1],
|
|
501
|
+
upperSize: upperSize.value
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
504
|
+
function measureSizes() {
|
|
505
|
+
if (destroyed) return;
|
|
506
|
+
rootSize.value = root.value ? getElementSize(root.value) : {
|
|
507
|
+
width: 0,
|
|
508
|
+
height: 0
|
|
509
|
+
};
|
|
510
|
+
lowerSize.value = lower.value ? getElementSize(lower.value) : {
|
|
511
|
+
width: 0,
|
|
512
|
+
height: 0
|
|
513
|
+
};
|
|
514
|
+
upperSize.value = upper.value ? getElementSize(upper.value) : {
|
|
515
|
+
width: 0,
|
|
516
|
+
height: 0
|
|
517
|
+
};
|
|
518
|
+
updateCollision();
|
|
519
|
+
}
|
|
520
|
+
function scheduleMeasure() {
|
|
521
|
+
if (destroyed || frameId != null) return;
|
|
522
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
523
|
+
if (!view?.requestAnimationFrame) {
|
|
524
|
+
measureSizes();
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
frameWindow = view;
|
|
528
|
+
frameId = view.requestAnimationFrame(() => {
|
|
529
|
+
frameId = void 0;
|
|
530
|
+
frameWindow = void 0;
|
|
531
|
+
measureSizes();
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function refreshObservedElements() {
|
|
535
|
+
if (!resizeObserver) return;
|
|
536
|
+
resizeObserver.disconnect();
|
|
537
|
+
for (const element of [
|
|
538
|
+
root.value,
|
|
539
|
+
lower.value,
|
|
540
|
+
upper.value
|
|
541
|
+
]) if (element) resizeObserver.observe(element);
|
|
542
|
+
}
|
|
543
|
+
function onResize(entries) {
|
|
544
|
+
for (const entry of entries) {
|
|
545
|
+
const size = getObservedSize(entry);
|
|
546
|
+
if (entry.target === root.value) rootSize.value = size;
|
|
547
|
+
else if (entry.target === lower.value) lowerSize.value = size;
|
|
548
|
+
else if (entry.target === upper.value) upperSize.value = size;
|
|
549
|
+
}
|
|
550
|
+
updateCollision();
|
|
551
|
+
}
|
|
552
|
+
function onWindowResize() {
|
|
553
|
+
scheduleMeasure();
|
|
554
|
+
}
|
|
555
|
+
onMounted(() => {
|
|
556
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
557
|
+
if (view?.ResizeObserver) resizeObserver = new view.ResizeObserver(onResize);
|
|
558
|
+
view?.addEventListener("resize", onWindowResize);
|
|
559
|
+
refreshObservedElements();
|
|
560
|
+
if (!resizeObserver) scheduleMeasure();
|
|
561
|
+
});
|
|
562
|
+
watch([
|
|
563
|
+
root,
|
|
564
|
+
lower,
|
|
565
|
+
upper
|
|
566
|
+
], () => {
|
|
567
|
+
refreshObservedElements();
|
|
568
|
+
if (!resizeObserver) scheduleMeasure();
|
|
569
|
+
}, { flush: "post" });
|
|
570
|
+
watch([
|
|
571
|
+
valuePercent,
|
|
572
|
+
orientation,
|
|
573
|
+
placement,
|
|
574
|
+
enabled
|
|
575
|
+
], updateCollision, { flush: "sync" });
|
|
576
|
+
watch(sizeDependencies, () => {
|
|
577
|
+
if (!resizeObserver) scheduleMeasure();
|
|
578
|
+
}, { flush: "post" });
|
|
579
|
+
const arrowAlongTrackAxis = computed(() => orientation.value === "horizontal" ? placement.value === "top" || placement.value === "bottom" : placement.value === "left" || placement.value === "right");
|
|
580
|
+
const trackAxisLength = computed(() => orientation.value === "horizontal" ? rootSize.value.width : rootSize.value.height);
|
|
581
|
+
const thumbDistance = computed(() => {
|
|
582
|
+
const [lowerPercent, upperPercent] = valuePercent.value;
|
|
583
|
+
return Math.abs(upperPercent - lowerPercent) / 100 * trackAxisLength.value;
|
|
584
|
+
});
|
|
585
|
+
const mergedArrowOffset = computed(() => {
|
|
586
|
+
if (trackAxisLength.value <= 0 || !arrowAlongTrackAxis.value) return 0;
|
|
587
|
+
return thumbDistance.value * .5;
|
|
588
|
+
});
|
|
589
|
+
const mergedMinSize = computed(() => {
|
|
590
|
+
if (!tooltipsOverlapping.value || trackAxisLength.value <= 0 || !arrowAlongTrackAxis.value) return 0;
|
|
591
|
+
const maxEndpoint = Math.max(getAxisSize(lowerSize.value, orientation.value), getAxisSize(upperSize.value, orientation.value));
|
|
592
|
+
return thumbDistance.value + maxEndpoint;
|
|
593
|
+
});
|
|
594
|
+
onBeforeUnmount(() => {
|
|
595
|
+
destroyed = true;
|
|
596
|
+
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
597
|
+
resizeObserver?.disconnect();
|
|
598
|
+
if (frameId != null) frameWindow?.cancelAnimationFrame(frameId);
|
|
599
|
+
});
|
|
600
|
+
return {
|
|
601
|
+
tooltipsOverlapping,
|
|
602
|
+
mergedArrowOffset,
|
|
603
|
+
mergedMinSize
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/components/slider/range-slider-tooltip.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
608
|
+
var t0$1 = template("<span data-v-d17966e5 class=rp-range-slider__tooltip-merged-value> </span>");
|
|
609
|
+
var t1$1 = template("<span data-v-d17966e5 class=rp-range-slider__tooltip-merged-value> ");
|
|
610
|
+
var t2$1 = template("<span data-v-d17966e5 class=rp-range-slider__tooltip-merged-separator>–</span>", 2);
|
|
611
|
+
var t3$1 = template(" ");
|
|
612
|
+
var t4$1 = template("<span data-v-d17966e5 aria-hidden=true><span data-v-d17966e5><span data-v-d17966e5 class=rp-range-slider__tooltip-anchor></span><span data-v-d17966e5 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-d17966e5><span data-v-d17966e5 class=rp-range-slider__tooltip-anchor></span><span data-v-d17966e5 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-d17966e5><span data-v-d17966e5 class=rp-range-slider__tooltip-anchor></span><span data-v-d17966e5 class=rp-tooltip__content aria-hidden=true>", 1);
|
|
613
|
+
//#endregion
|
|
614
|
+
//#region src/components/slider/range-slider-tooltip.vue
|
|
615
|
+
var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
616
|
+
name: "RpRangeSliderTooltip",
|
|
617
|
+
__name: "range-slider-tooltip",
|
|
618
|
+
props: {
|
|
619
|
+
arrow: {
|
|
620
|
+
type: Boolean,
|
|
621
|
+
default: false
|
|
622
|
+
},
|
|
623
|
+
color: { default: void 0 },
|
|
624
|
+
content: {},
|
|
625
|
+
ids: {},
|
|
626
|
+
mergedContent: {},
|
|
627
|
+
mergedId: { default: void 0 },
|
|
628
|
+
offset: { default: void 0 },
|
|
629
|
+
open: { type: Boolean },
|
|
630
|
+
orientation: {},
|
|
631
|
+
placement: {},
|
|
632
|
+
valuePercent: {}
|
|
633
|
+
},
|
|
634
|
+
emits: ["update:overlapping"],
|
|
635
|
+
setup(__props, { emit: __emit }) {
|
|
636
|
+
const props = __props;
|
|
637
|
+
const emit = __emit;
|
|
638
|
+
const generatedId = useId();
|
|
639
|
+
const tooltipLayerRef = ref(null);
|
|
640
|
+
const lowerContentRef = ref(null);
|
|
641
|
+
const upperContentRef = ref(null);
|
|
642
|
+
const resolvedIds = computed(() => [props.ids[0] ?? `${generatedId}-lower-tooltip`, props.ids[1] ?? `${generatedId}-upper-tooltip`]);
|
|
643
|
+
const resolvedMergedId = computed(() => props.mergedId ?? `${generatedId}-merged-tooltip`);
|
|
644
|
+
const tooltipRootClass = computed(() => bem("rp-tooltip", {
|
|
645
|
+
[`placement-${props.placement}`]: true,
|
|
646
|
+
arrow: props.arrow,
|
|
647
|
+
open: props.open
|
|
648
|
+
}));
|
|
649
|
+
const contentStyle = computed(() => ({
|
|
650
|
+
...resolveTooltipOffsetStyle(props.offset),
|
|
651
|
+
...resolveTooltipColorStyleWithContrast(props.color, void 0)
|
|
652
|
+
}));
|
|
653
|
+
const { tooltipsOverlapping, mergedArrowOffset, mergedMinSize } = useRangeSliderTooltipCollision({
|
|
654
|
+
enabled: toRef(props, "open"),
|
|
655
|
+
lower: lowerContentRef,
|
|
656
|
+
orientation: toRef(props, "orientation"),
|
|
657
|
+
placement: toRef(props, "placement"),
|
|
658
|
+
root: tooltipLayerRef,
|
|
659
|
+
sizeDependencies: [() => props.content],
|
|
660
|
+
upper: upperContentRef,
|
|
661
|
+
valuePercent: toRef(props, "valuePercent")
|
|
662
|
+
});
|
|
663
|
+
const layerStyle = computed(() => ({
|
|
664
|
+
"--_rp-range-slider-tooltip-merged-arrow-offset": `${mergedArrowOffset.value}px`,
|
|
665
|
+
"--_rp-range-slider-tooltip-merged-min-size": `${mergedMinSize.value}px`
|
|
666
|
+
}));
|
|
667
|
+
watch(tooltipsOverlapping, (overlapping) => {
|
|
668
|
+
emit("update:overlapping", overlapping);
|
|
669
|
+
}, { immediate: true });
|
|
670
|
+
onBeforeUnmount(() => {
|
|
671
|
+
emit("update:overlapping", false);
|
|
672
|
+
});
|
|
673
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
674
|
+
const n16 = t4$1();
|
|
675
|
+
const n1 = child(n16);
|
|
676
|
+
const n0 = next(child(n1), 1);
|
|
677
|
+
const n3 = next(n1, 1);
|
|
678
|
+
const n2 = next(child(n3), 1);
|
|
679
|
+
const n15 = next(n3, 2);
|
|
680
|
+
const n14 = next(child(n15), 1);
|
|
681
|
+
const x0 = txt(n0);
|
|
682
|
+
applyVShow(n0, () => __props.open);
|
|
683
|
+
_setTemplateRef(n0, lowerContentRef, null, "lowerContentRef");
|
|
684
|
+
const x2 = txt(n2);
|
|
685
|
+
applyVShow(n2, () => __props.open);
|
|
686
|
+
_setTemplateRef(n2, upperContentRef, null, "upperContentRef");
|
|
687
|
+
renderEffect(() => {
|
|
688
|
+
const _tooltipRootClass = tooltipRootClass.value;
|
|
689
|
+
const _resolvedIds = resolvedIds.value;
|
|
690
|
+
const _contentStyle = contentStyle.value;
|
|
691
|
+
const _content = __props.content;
|
|
692
|
+
setClass(n16, [
|
|
693
|
+
"rp-range-slider__tooltips",
|
|
694
|
+
`rp-range-slider__tooltips--placement-${__props.placement}`,
|
|
695
|
+
{
|
|
696
|
+
"rp-range-slider__tooltips--overlapping": unref(tooltipsOverlapping),
|
|
697
|
+
"rp-range-slider__tooltips--vertical": __props.orientation === "vertical"
|
|
698
|
+
}
|
|
699
|
+
]);
|
|
700
|
+
setStyle(n16, layerStyle.value);
|
|
701
|
+
setClass(n1, [
|
|
702
|
+
_tooltipRootClass,
|
|
703
|
+
"rp-range-slider__tooltip",
|
|
704
|
+
"rp-range-slider__tooltip--lower"
|
|
705
|
+
]);
|
|
706
|
+
setProp(n0, "id", _resolvedIds[0]);
|
|
707
|
+
setStyle(n0, _contentStyle);
|
|
708
|
+
setText(x0, toDisplayString(_content[0]));
|
|
709
|
+
setClass(n3, [
|
|
710
|
+
_tooltipRootClass,
|
|
711
|
+
"rp-range-slider__tooltip",
|
|
712
|
+
"rp-range-slider__tooltip--upper"
|
|
713
|
+
]);
|
|
714
|
+
setProp(n2, "id", _resolvedIds[1]);
|
|
715
|
+
setStyle(n2, _contentStyle);
|
|
716
|
+
setText(x2, toDisplayString(_content[1]));
|
|
717
|
+
setClass(n15, [
|
|
718
|
+
_tooltipRootClass,
|
|
719
|
+
"rp-range-slider__tooltip",
|
|
720
|
+
"rp-range-slider__tooltip--merged"
|
|
721
|
+
]);
|
|
722
|
+
setProp(n14, "id", resolvedMergedId.value);
|
|
723
|
+
setStyle(n14, _contentStyle);
|
|
724
|
+
});
|
|
725
|
+
setInsertionState(n14, null, 0);
|
|
726
|
+
createIf(() => __props.orientation === "vertical" && __props.content[0] !== __props.content[1], () => {
|
|
727
|
+
const n6 = t0$1();
|
|
728
|
+
const n7 = t1$1();
|
|
729
|
+
const x6 = txt(n6);
|
|
730
|
+
const x7 = txt(n7);
|
|
731
|
+
renderEffect(() => {
|
|
732
|
+
const _content = __props.content;
|
|
733
|
+
setText(x6, toDisplayString(_content[1]));
|
|
734
|
+
setText(x7, toDisplayString(_content[0]));
|
|
735
|
+
});
|
|
736
|
+
return [n6, n7];
|
|
737
|
+
}, () => createIf(() => __props.content[0] !== __props.content[1], () => {
|
|
738
|
+
const n9 = t0$1();
|
|
739
|
+
const n10 = t2$1();
|
|
740
|
+
const n11 = t1$1();
|
|
741
|
+
const x9 = txt(n9);
|
|
742
|
+
const x11 = txt(n11);
|
|
743
|
+
renderEffect(() => {
|
|
744
|
+
const _content = __props.content;
|
|
745
|
+
setText(x9, toDisplayString(_content[0]));
|
|
746
|
+
setText(x11, toDisplayString(_content[1]));
|
|
747
|
+
});
|
|
748
|
+
return [
|
|
749
|
+
n9,
|
|
750
|
+
n10,
|
|
751
|
+
n11
|
|
752
|
+
];
|
|
753
|
+
}, () => {
|
|
754
|
+
const n13 = t3$1();
|
|
755
|
+
renderEffect(() => setText(n13, toDisplayString(__props.mergedContent)));
|
|
756
|
+
return n13;
|
|
757
|
+
}, 518), 262);
|
|
758
|
+
applyVShow(n14, () => __props.open);
|
|
759
|
+
_setTemplateRef(n16, tooltipLayerRef, null, "tooltipLayerRef");
|
|
760
|
+
return n16;
|
|
761
|
+
}
|
|
762
|
+
}), [["__scopeId", "data-v-d17966e5"]]);
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/components/slider/useRangeSliderPointer.ts
|
|
765
|
+
function useRangeSliderPointer(options) {
|
|
766
|
+
let session;
|
|
767
|
+
let frameWindow = null;
|
|
768
|
+
let frameId;
|
|
769
|
+
let pendingPointerEvent;
|
|
770
|
+
let geometryDirty = false;
|
|
771
|
+
function cancelScheduledFrame() {
|
|
772
|
+
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
773
|
+
frameWindow = null;
|
|
774
|
+
frameId = void 0;
|
|
775
|
+
}
|
|
776
|
+
function refreshGeometry() {
|
|
777
|
+
const currentSession = session;
|
|
778
|
+
if (!currentSession) return false;
|
|
779
|
+
if (!geometryDirty) return true;
|
|
780
|
+
const geometry = options.getPointerGeometry(currentSession.track);
|
|
781
|
+
if (geometry === void 0) return false;
|
|
782
|
+
geometryDirty = false;
|
|
783
|
+
currentSession.geometry = geometry;
|
|
784
|
+
return true;
|
|
785
|
+
}
|
|
786
|
+
function applyScheduledUpdate() {
|
|
787
|
+
if (!refreshGeometry()) return;
|
|
788
|
+
const event = pendingPointerEvent;
|
|
789
|
+
pendingPointerEvent = void 0;
|
|
790
|
+
if (event && isCurrentPointer(event)) updateFromPointer(event);
|
|
791
|
+
}
|
|
792
|
+
function flushScheduledUpdate() {
|
|
793
|
+
cancelScheduledFrame();
|
|
794
|
+
applyScheduledUpdate();
|
|
795
|
+
}
|
|
796
|
+
function onAnimationFrame() {
|
|
797
|
+
frameWindow = null;
|
|
798
|
+
frameId = void 0;
|
|
799
|
+
applyScheduledUpdate();
|
|
800
|
+
}
|
|
801
|
+
function scheduleUpdate() {
|
|
802
|
+
const view = session?.view;
|
|
803
|
+
if (!view?.requestAnimationFrame) {
|
|
804
|
+
flushScheduledUpdate();
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if (frameId !== void 0) return;
|
|
808
|
+
frameWindow = view;
|
|
809
|
+
frameId = view.requestAnimationFrame(onAnimationFrame);
|
|
810
|
+
}
|
|
811
|
+
function onGeometryChange() {
|
|
812
|
+
if (!session) return;
|
|
813
|
+
geometryDirty = true;
|
|
814
|
+
scheduleUpdate();
|
|
815
|
+
}
|
|
816
|
+
function stopDragging() {
|
|
817
|
+
const stoppedSession = session;
|
|
818
|
+
if (!stoppedSession) return;
|
|
819
|
+
stoppedSession.view?.removeEventListener("pointermove", onPointerMove);
|
|
820
|
+
stoppedSession.view?.removeEventListener("pointerup", onPointerEnd);
|
|
821
|
+
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
822
|
+
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
823
|
+
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
824
|
+
cancelScheduledFrame();
|
|
825
|
+
pendingPointerEvent = void 0;
|
|
826
|
+
geometryDirty = false;
|
|
827
|
+
session = void 0;
|
|
828
|
+
options.endDrag(stoppedSession.thumb);
|
|
829
|
+
}
|
|
830
|
+
function switchDraggingThumb(nextThumb) {
|
|
831
|
+
const currentSession = session;
|
|
832
|
+
if (!currentSession || currentSession.thumb === nextThumb) return;
|
|
833
|
+
const previousThumb = currentSession.thumb;
|
|
834
|
+
currentSession.thumb = nextThumb;
|
|
835
|
+
options.transferDrag(previousThumb, nextThumb);
|
|
836
|
+
options.setActiveThumb(nextThumb);
|
|
837
|
+
options.transferFocusedThumb(currentSession.track, previousThumb, nextThumb);
|
|
838
|
+
}
|
|
839
|
+
function updateFromPointer(event) {
|
|
840
|
+
const currentSession = session;
|
|
841
|
+
if (!currentSession) return;
|
|
842
|
+
const value = options.getPointerValue(event, currentSession.geometry);
|
|
843
|
+
if (value == null) return;
|
|
844
|
+
switchDraggingThumb(options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
845
|
+
}
|
|
846
|
+
function isCurrentPointer(event) {
|
|
847
|
+
return session?.pointerId === void 0 || event.pointerId === session.pointerId;
|
|
848
|
+
}
|
|
849
|
+
function onPointerMove(event) {
|
|
850
|
+
if (!isCurrentPointer(event)) return;
|
|
851
|
+
if (!session) return;
|
|
852
|
+
pendingPointerEvent = event;
|
|
853
|
+
scheduleUpdate();
|
|
854
|
+
}
|
|
855
|
+
function onPointerEnd(event) {
|
|
856
|
+
if (!isCurrentPointer(event)) return;
|
|
857
|
+
if (event.type === "pointerup") flushScheduledUpdate();
|
|
858
|
+
stopDragging();
|
|
859
|
+
}
|
|
860
|
+
function onTrackPointerDown(event) {
|
|
861
|
+
if (options.disabled() || event.button !== 0 || event.isPrimary === false) return;
|
|
862
|
+
const track = event.currentTarget;
|
|
863
|
+
if (!track) return;
|
|
864
|
+
const geometry = options.getPointerGeometry(track);
|
|
865
|
+
if (geometry === void 0) return;
|
|
866
|
+
const pointerValue = options.getPointerValue(event, geometry);
|
|
867
|
+
if (pointerValue == null) return;
|
|
868
|
+
const thumb = options.getThumb(event, pointerValue);
|
|
869
|
+
event.preventDefault();
|
|
870
|
+
stopDragging();
|
|
871
|
+
options.setActiveThumb(thumb);
|
|
872
|
+
options.focusThumb(track, thumb);
|
|
873
|
+
session = {
|
|
874
|
+
view: track.ownerDocument.defaultView,
|
|
875
|
+
track,
|
|
876
|
+
geometry,
|
|
877
|
+
thumb,
|
|
878
|
+
anchorValue: options.getAnchorValue(thumb),
|
|
879
|
+
pointerId: Number.isFinite(event.pointerId) ? event.pointerId : void 0
|
|
880
|
+
};
|
|
881
|
+
options.startDrag(thumb);
|
|
882
|
+
switchDraggingThumb(options.updateThumb(thumb, pointerValue, session.anchorValue));
|
|
883
|
+
const view = session?.view;
|
|
884
|
+
view?.addEventListener("pointermove", onPointerMove);
|
|
885
|
+
view?.addEventListener("pointerup", onPointerEnd);
|
|
886
|
+
view?.addEventListener("pointercancel", onPointerEnd);
|
|
887
|
+
view?.addEventListener("resize", onGeometryChange);
|
|
888
|
+
view?.addEventListener("scroll", onGeometryChange, true);
|
|
889
|
+
}
|
|
890
|
+
onBeforeUnmount(stopDragging);
|
|
891
|
+
return { onTrackPointerDown };
|
|
892
|
+
}
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/components/slider/useRangeSliderTooltipState.ts
|
|
895
|
+
function useRangeSliderTooltipState(options) {
|
|
896
|
+
const delayedTooltip = useDelayedOpen({
|
|
897
|
+
openDelay: () => options.openDelay.value,
|
|
898
|
+
disabled: () => options.mode.value !== "hover" || options.disabled()
|
|
899
|
+
});
|
|
900
|
+
const interactionReasons = ref({
|
|
901
|
+
lower: {
|
|
902
|
+
focus: false,
|
|
903
|
+
drag: false
|
|
904
|
+
},
|
|
905
|
+
upper: {
|
|
906
|
+
focus: false,
|
|
907
|
+
drag: false
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
const trackHovered = ref(false);
|
|
911
|
+
const dismissed = ref(false);
|
|
912
|
+
function hasThumbInteraction(thumb) {
|
|
913
|
+
const reasons = interactionReasons.value[thumb];
|
|
914
|
+
return reasons.focus || reasons.drag;
|
|
915
|
+
}
|
|
916
|
+
function hasAnyInteraction() {
|
|
917
|
+
return trackHovered.value || hasThumbInteraction("lower") || hasThumbInteraction("upper");
|
|
918
|
+
}
|
|
919
|
+
function sync() {
|
|
920
|
+
if (options.mode.value === "hover" && !options.disabled() && hasAnyInteraction() && !dismissed.value) {
|
|
921
|
+
delayedTooltip.open();
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
delayedTooltip.closeImmediate();
|
|
925
|
+
}
|
|
926
|
+
function startInteraction(thumb, reason) {
|
|
927
|
+
options.setActiveThumb(thumb);
|
|
928
|
+
const wasActive = hasAnyInteraction();
|
|
929
|
+
const wasDismissed = dismissed.value;
|
|
930
|
+
interactionReasons.value[thumb][reason] = true;
|
|
931
|
+
dismissed.value = false;
|
|
932
|
+
if (!wasActive || wasDismissed) sync();
|
|
933
|
+
}
|
|
934
|
+
function endInteraction(thumb, reason) {
|
|
935
|
+
interactionReasons.value[thumb][reason] = false;
|
|
936
|
+
if (!hasAnyInteraction()) sync();
|
|
937
|
+
}
|
|
938
|
+
function transferInteraction(from, to, reason) {
|
|
939
|
+
if (!interactionReasons.value[from][reason]) return;
|
|
940
|
+
interactionReasons.value[from][reason] = false;
|
|
941
|
+
interactionReasons.value[to][reason] = true;
|
|
942
|
+
}
|
|
943
|
+
function onFocus(thumb) {
|
|
944
|
+
startInteraction(thumb, "focus");
|
|
945
|
+
}
|
|
946
|
+
function onBlur(thumb) {
|
|
947
|
+
endInteraction(thumb, "focus");
|
|
948
|
+
}
|
|
949
|
+
function onTrackMouseEnter() {
|
|
950
|
+
const wasActive = hasAnyInteraction();
|
|
951
|
+
const wasDismissed = dismissed.value;
|
|
952
|
+
trackHovered.value = true;
|
|
953
|
+
dismissed.value = false;
|
|
954
|
+
if (!wasActive || wasDismissed) sync();
|
|
955
|
+
}
|
|
956
|
+
function onTrackMouseLeave() {
|
|
957
|
+
trackHovered.value = false;
|
|
958
|
+
if (!hasAnyInteraction()) sync();
|
|
959
|
+
}
|
|
960
|
+
function onKeydown(thumb, event) {
|
|
961
|
+
options.setActiveThumb(thumb);
|
|
962
|
+
if (event.key === "Escape") {
|
|
963
|
+
dismissed.value = true;
|
|
964
|
+
delayedTooltip.closeImmediate();
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
if (dismissed.value) {
|
|
968
|
+
dismissed.value = false;
|
|
969
|
+
sync();
|
|
970
|
+
}
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
const visible = computed(() => options.mode.value !== false);
|
|
974
|
+
const alwaysVisible = computed(() => options.mode.value === "always");
|
|
975
|
+
const open = computed(() => alwaysVisible.value || options.mode.value === "hover" && delayedTooltip.isOpen.value && hasAnyInteraction() && !dismissed.value && !options.disabled());
|
|
976
|
+
watch([options.mode, options.disabled], sync);
|
|
977
|
+
return {
|
|
978
|
+
visible,
|
|
979
|
+
alwaysVisible,
|
|
980
|
+
open,
|
|
981
|
+
startInteraction,
|
|
982
|
+
endInteraction,
|
|
983
|
+
transferInteraction,
|
|
984
|
+
onFocus,
|
|
985
|
+
onBlur,
|
|
986
|
+
onTrackMouseEnter,
|
|
987
|
+
onTrackMouseLeave,
|
|
988
|
+
onKeydown
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
//#endregion
|
|
992
|
+
//#region src/components/slider/useRangeSlider.ts
|
|
993
|
+
function roundSliderNumber(value) {
|
|
994
|
+
return Number(value.toFixed(10));
|
|
995
|
+
}
|
|
996
|
+
function clamp(value, min, max) {
|
|
997
|
+
return Math.min(max, Math.max(min, value));
|
|
998
|
+
}
|
|
999
|
+
function getStepValueAtOrAbove(value, min, step) {
|
|
1000
|
+
if (step === "any") return value;
|
|
1001
|
+
return roundSliderNumber(min + Math.ceil((value - min) / step - 1e-10) * step);
|
|
1002
|
+
}
|
|
1003
|
+
function getStepValueAtOrBelow(value, min, step) {
|
|
1004
|
+
if (step === "any") return value;
|
|
1005
|
+
return roundSliderNumber(min + Math.floor((value - min) / step + 1e-10) * step);
|
|
1006
|
+
}
|
|
1007
|
+
function isSliderStepAligned(min, max, step) {
|
|
1008
|
+
const stepCount = (max - min) / step;
|
|
1009
|
+
return Math.abs(stepCount - Math.round(stepCount)) <= 1e-10;
|
|
1010
|
+
}
|
|
1011
|
+
function normalizeRangeSliderMinRange(minRange, min, max) {
|
|
1012
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1013
|
+
const domain = bounds.max - bounds.min;
|
|
1014
|
+
return Math.min(domain, Number.isFinite(minRange) && minRange > 0 ? minRange : 0);
|
|
1015
|
+
}
|
|
1016
|
+
function normalizeRangeSliderValue(value, min, max, step, minRange = 0) {
|
|
1017
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1018
|
+
const safeStep = normalizeSliderStep(step);
|
|
1019
|
+
const safeMinRange = normalizeRangeSliderMinRange(minRange, bounds.min, bounds.max);
|
|
1020
|
+
const first = normalizeSliderValue(Array.isArray(value) ? Number(value[0]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1021
|
+
const second = normalizeSliderValue(Array.isArray(value) ? Number(value[1]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1022
|
+
const lower = Math.min(first, second);
|
|
1023
|
+
const upper = Math.max(first, second);
|
|
1024
|
+
if (upper - lower >= safeMinRange) return [lower, upper];
|
|
1025
|
+
if (safeMinRange >= bounds.max - bounds.min) return [bounds.min, bounds.max];
|
|
1026
|
+
const expandedUpper = getStepValueAtOrAbove(lower + safeMinRange, bounds.min, safeStep);
|
|
1027
|
+
if (expandedUpper <= bounds.max) return [lower, expandedUpper];
|
|
1028
|
+
const expandedLower = getStepValueAtOrBelow(bounds.max - safeMinRange, bounds.min, safeStep);
|
|
1029
|
+
return [Math.max(bounds.min, expandedLower), bounds.max];
|
|
1030
|
+
}
|
|
1031
|
+
function getClosestRangeSliderThumb(value, range, activeThumb) {
|
|
1032
|
+
const [lower, upper] = range;
|
|
1033
|
+
if (value < lower) return "lower";
|
|
1034
|
+
if (value > upper) return "upper";
|
|
1035
|
+
const lowerDistance = Math.abs(value - lower);
|
|
1036
|
+
const upperDistance = Math.abs(value - upper);
|
|
1037
|
+
if (lowerDistance < upperDistance) return "lower";
|
|
1038
|
+
if (upperDistance < lowerDistance) return "upper";
|
|
1039
|
+
return activeThumb ?? "upper";
|
|
1040
|
+
}
|
|
1041
|
+
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
1042
|
+
const [lowerPercent, upperPercent] = valuePercent;
|
|
1043
|
+
const style = {
|
|
1044
|
+
"--_rp-range-slider-lower-percent": `${lowerPercent}%`,
|
|
1045
|
+
"--_rp-range-slider-upper-percent": `${upperPercent}%`,
|
|
1046
|
+
"--_rp-range-slider-lower-ratio": `${lowerPercent / 100}`,
|
|
1047
|
+
"--_rp-range-slider-upper-ratio": `${upperPercent / 100}`,
|
|
1048
|
+
"--_rp-range-slider-tooltip-merged-percent": `${(lowerPercent + upperPercent) / 2}%`
|
|
1049
|
+
};
|
|
1050
|
+
setSliderStyleValue(style, "--_rp-range-slider-color", getComponentColorValue(props.color));
|
|
1051
|
+
applySliderThumbStyle(style, props.thumbStyle, {
|
|
1052
|
+
size: "--_rp-range-slider-thumb-size",
|
|
1053
|
+
border: "--_rp-range-slider-thumb-border-style",
|
|
1054
|
+
padding: "--_rp-range-slider-thumb-padding",
|
|
1055
|
+
borderColor: "--_rp-range-slider-thumb-border"
|
|
1056
|
+
});
|
|
1057
|
+
return style;
|
|
1058
|
+
}
|
|
1059
|
+
function getFormattedRangeSliderValue(value, formatter) {
|
|
1060
|
+
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
1061
|
+
}
|
|
1062
|
+
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
1063
|
+
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
1064
|
+
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
1065
|
+
}
|
|
1066
|
+
function getThumbIndex(thumb) {
|
|
1067
|
+
return thumb === "lower" ? 0 : 1;
|
|
1068
|
+
}
|
|
1069
|
+
function getOppositeThumb(thumb) {
|
|
1070
|
+
return thumb === "lower" ? "upper" : "lower";
|
|
1071
|
+
}
|
|
1072
|
+
function getThumbFromTarget(target) {
|
|
1073
|
+
const thumb = target?.closest?.("[data-range-slider-thumb]")?.getAttribute("data-range-slider-thumb");
|
|
1074
|
+
return thumb === "lower" || thumb === "upper" ? thumb : void 0;
|
|
1075
|
+
}
|
|
1076
|
+
function getThumbInput(track, thumb) {
|
|
1077
|
+
return track.querySelector(`.rp-range-slider__native--${thumb}, input[data-range-slider-thumb="${thumb}"]`);
|
|
1078
|
+
}
|
|
1079
|
+
function focusThumb(track, thumb) {
|
|
1080
|
+
getThumbInput(track, thumb)?.focus({ preventScroll: true });
|
|
1081
|
+
}
|
|
1082
|
+
function useRangeSlider(props, emitUpdate) {
|
|
1083
|
+
const control = useControlState(props);
|
|
1084
|
+
const activeThumb = ref();
|
|
1085
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
1086
|
+
const valueStep = computed(() => normalizeSliderStep(props.step));
|
|
1087
|
+
const nativeStep = computed(() => {
|
|
1088
|
+
const step = valueStep.value;
|
|
1089
|
+
if (step === "any") return step;
|
|
1090
|
+
return isSliderStepAligned(bounds.value.min, bounds.value.max, step) ? step : "any";
|
|
1091
|
+
});
|
|
1092
|
+
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
1093
|
+
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
1094
|
+
const normalizedValue = computed(() => normalizeRangeSliderValue(props.modelValue, bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
1095
|
+
const valuePercent = computed(() => [getSliderValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getSliderValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
1096
|
+
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
1097
|
+
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
1098
|
+
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
1099
|
+
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
1100
|
+
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
1101
|
+
const nativeMin = computed(() => {
|
|
1102
|
+
if (normalizedMinRange.value === 0) return [bounds.value.min, bounds.value.min];
|
|
1103
|
+
return [bounds.value.min, clamp(getStepValueAtOrAbove(normalizedValue.value[0] + normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max)];
|
|
1104
|
+
});
|
|
1105
|
+
const nativeMax = computed(() => {
|
|
1106
|
+
if (normalizedMinRange.value === 0) return [bounds.value.max, bounds.value.max];
|
|
1107
|
+
return [clamp(getStepValueAtOrBelow(normalizedValue.value[1] - normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max), bounds.value.max];
|
|
1108
|
+
});
|
|
1109
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1110
|
+
position: "--_rp-range-slider-mark-position",
|
|
1111
|
+
colors: [
|
|
1112
|
+
"--_rp-range-slider-mark-color",
|
|
1113
|
+
"--_rp-range-slider-mark-label-color",
|
|
1114
|
+
"--_rp-range-slider-mark-filled-label-color",
|
|
1115
|
+
"--_rp-range-slider-mark-ring-color"
|
|
1116
|
+
]
|
|
1117
|
+
}));
|
|
1118
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
1119
|
+
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valuePercent.value));
|
|
1120
|
+
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
1121
|
+
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
1122
|
+
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
1123
|
+
const tooltipState = useRangeSliderTooltipState({
|
|
1124
|
+
mode: tooltipMode,
|
|
1125
|
+
openDelay: tooltipOpenDelay,
|
|
1126
|
+
disabled: () => control.disabled,
|
|
1127
|
+
setActiveThumb: (thumb) => {
|
|
1128
|
+
activeThumb.value = thumb;
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
const tooltipVisible = tooltipState.visible;
|
|
1132
|
+
const tooltipAlwaysVisible = tooltipState.alwaysVisible;
|
|
1133
|
+
const tooltipOpen = tooltipState.open;
|
|
1134
|
+
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (props.orientation === "vertical" ? "left" : "top"));
|
|
1135
|
+
const tooltipIds = computed(() => {
|
|
1136
|
+
const baseId = tooltipOptions.value.id;
|
|
1137
|
+
return baseId ? [`${baseId}-lower`, `${baseId}-upper`] : [void 0, void 0];
|
|
1138
|
+
});
|
|
1139
|
+
const mergedTooltipId = computed(() => {
|
|
1140
|
+
const baseId = tooltipOptions.value.id;
|
|
1141
|
+
return baseId ? `${baseId}-merged` : void 0;
|
|
1142
|
+
});
|
|
1143
|
+
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
1144
|
+
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
1145
|
+
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
1146
|
+
const tooltipContent = computed(() => [String(formattedValue.value[0]), String(formattedValue.value[1])]);
|
|
1147
|
+
const mergedTooltipContent = computed(() => {
|
|
1148
|
+
const [lower, upper] = tooltipContent.value;
|
|
1149
|
+
return lower === upper ? lower : `${lower}–${upper}`;
|
|
1150
|
+
});
|
|
1151
|
+
const rootClass = computed(() => bem("rp-range-slider", {
|
|
1152
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
1153
|
+
vertical: props.orientation === "vertical",
|
|
1154
|
+
marked: markItems.value.length > 0,
|
|
1155
|
+
"marks-with-labels": hasMarkLabels.value,
|
|
1156
|
+
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
1157
|
+
disabled: control.disabled
|
|
1158
|
+
}));
|
|
1159
|
+
function getThumbUpdate(thumb, value, anchorValue = normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))]) {
|
|
1160
|
+
const safeValue = normalizeSliderValue(value, bounds.value.min, bounds.value.max, valueStep.value);
|
|
1161
|
+
if (normalizedMinRange.value > 0) {
|
|
1162
|
+
const nextValue = [...normalizedValue.value];
|
|
1163
|
+
nextValue[getThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax.value[0]) : Math.max(safeValue, nativeMin.value[1]);
|
|
1164
|
+
return {
|
|
1165
|
+
thumb,
|
|
1166
|
+
value: nextValue
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
if (safeValue < anchorValue) return {
|
|
1170
|
+
thumb: "lower",
|
|
1171
|
+
value: [safeValue, anchorValue]
|
|
1172
|
+
};
|
|
1173
|
+
if (safeValue > anchorValue) return {
|
|
1174
|
+
thumb: "upper",
|
|
1175
|
+
value: [anchorValue, safeValue]
|
|
1176
|
+
};
|
|
1177
|
+
return {
|
|
1178
|
+
thumb,
|
|
1179
|
+
value: [safeValue, safeValue]
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function updateThumb(thumb, value, anchorValue) {
|
|
1183
|
+
if (control.disabled) return thumb;
|
|
1184
|
+
const update = getThumbUpdate(thumb, value, anchorValue);
|
|
1185
|
+
activeThumb.value = update.thumb;
|
|
1186
|
+
emitUpdate(update.value);
|
|
1187
|
+
return update.thumb;
|
|
1188
|
+
}
|
|
1189
|
+
function onInput(thumb, event) {
|
|
1190
|
+
const input = event.target;
|
|
1191
|
+
transferFocusedThumb(input, thumb, updateThumb(thumb, input.valueAsNumber));
|
|
1192
|
+
}
|
|
1193
|
+
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
1194
|
+
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
1195
|
+
const track = input.closest(".rp-range-slider__track");
|
|
1196
|
+
if (!track) return;
|
|
1197
|
+
const nextInput = getThumbInput(track, nextThumb);
|
|
1198
|
+
if (!nextInput) return;
|
|
1199
|
+
tooltipState.transferInteraction(thumb, nextThumb, "focus");
|
|
1200
|
+
nextInput.focus({ preventScroll: true });
|
|
1201
|
+
}
|
|
1202
|
+
function onTooltipKeydown(thumb, event) {
|
|
1203
|
+
if (tooltipState.onKeydown(thumb, event)) return;
|
|
1204
|
+
if (!hasManualNativeKeyboard.value || valueStep.value === "any") return;
|
|
1205
|
+
const index = getThumbIndex(thumb);
|
|
1206
|
+
const currentValue = normalizedValue.value[index];
|
|
1207
|
+
const pageStep = valueStep.value * 10;
|
|
1208
|
+
let nextValue;
|
|
1209
|
+
switch (event.key) {
|
|
1210
|
+
case "ArrowRight":
|
|
1211
|
+
case "ArrowUp":
|
|
1212
|
+
nextValue = currentValue + valueStep.value;
|
|
1213
|
+
break;
|
|
1214
|
+
case "ArrowLeft":
|
|
1215
|
+
case "ArrowDown":
|
|
1216
|
+
nextValue = currentValue - valueStep.value;
|
|
1217
|
+
break;
|
|
1218
|
+
case "PageUp":
|
|
1219
|
+
nextValue = currentValue + pageStep;
|
|
1220
|
+
break;
|
|
1221
|
+
case "PageDown":
|
|
1222
|
+
nextValue = currentValue - pageStep;
|
|
1223
|
+
break;
|
|
1224
|
+
case "Home":
|
|
1225
|
+
nextValue = nativeMin.value[index];
|
|
1226
|
+
break;
|
|
1227
|
+
case "End":
|
|
1228
|
+
nextValue = nativeMax.value[index];
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
if (nextValue == null) return;
|
|
1232
|
+
event.preventDefault();
|
|
1233
|
+
const nextThumb = updateThumb(thumb, nextValue);
|
|
1234
|
+
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
1235
|
+
}
|
|
1236
|
+
function getPointerGeometry(track) {
|
|
1237
|
+
const vertical = props.orientation === "vertical";
|
|
1238
|
+
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
1239
|
+
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
1240
|
+
const length = vertical ? rect.height : rect.width;
|
|
1241
|
+
if (length <= 0) return void 0;
|
|
1242
|
+
return {
|
|
1243
|
+
length,
|
|
1244
|
+
start: vertical ? rect.bottom : rect.left,
|
|
1245
|
+
vertical
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
function getValueFromPointer(event, geometry) {
|
|
1249
|
+
const pointerPosition = geometry.vertical ? event.clientY : event.clientX;
|
|
1250
|
+
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1251
|
+
return bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
1252
|
+
}
|
|
1253
|
+
const { onTrackPointerDown } = useRangeSliderPointer({
|
|
1254
|
+
disabled: () => control.disabled,
|
|
1255
|
+
getPointerGeometry,
|
|
1256
|
+
getPointerValue: getValueFromPointer,
|
|
1257
|
+
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, normalizedValue.value, activeThumb.value),
|
|
1258
|
+
getAnchorValue: (thumb) => normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))],
|
|
1259
|
+
setActiveThumb: (thumb) => {
|
|
1260
|
+
activeThumb.value = thumb;
|
|
1261
|
+
},
|
|
1262
|
+
focusThumb,
|
|
1263
|
+
updateThumb,
|
|
1264
|
+
transferFocusedThumb: (track, from, to) => {
|
|
1265
|
+
const input = getThumbInput(track, from);
|
|
1266
|
+
if (input) transferFocusedThumb(input, from, to);
|
|
1267
|
+
},
|
|
1268
|
+
startDrag: (thumb) => tooltipState.startInteraction(thumb, "drag"),
|
|
1269
|
+
endDrag: (thumb) => tooltipState.endInteraction(thumb, "drag"),
|
|
1270
|
+
transferDrag: (from, to) => tooltipState.transferInteraction(from, to, "drag")
|
|
1271
|
+
});
|
|
1272
|
+
return {
|
|
1273
|
+
control,
|
|
1274
|
+
nativeMin,
|
|
1275
|
+
nativeMax,
|
|
1276
|
+
nativeStep,
|
|
1277
|
+
nativeNames,
|
|
1278
|
+
nativeIds,
|
|
1279
|
+
rootClass,
|
|
1280
|
+
normalizedValue,
|
|
1281
|
+
valuePercent,
|
|
1282
|
+
formattedValue,
|
|
1283
|
+
ariaLabels,
|
|
1284
|
+
ariaValueText,
|
|
1285
|
+
markItems,
|
|
1286
|
+
trackStyle,
|
|
1287
|
+
activeThumb,
|
|
1288
|
+
tooltipVisible,
|
|
1289
|
+
tooltipOpen,
|
|
1290
|
+
tooltipPlacement,
|
|
1291
|
+
tooltipIds,
|
|
1292
|
+
mergedTooltipId,
|
|
1293
|
+
tooltipColor,
|
|
1294
|
+
tooltipOffset,
|
|
1295
|
+
tooltipOpenDelay,
|
|
1296
|
+
tooltipArrow,
|
|
1297
|
+
tooltipContent,
|
|
1298
|
+
mergedTooltipContent,
|
|
1299
|
+
onInput,
|
|
1300
|
+
onTrackPointerDown,
|
|
1301
|
+
onTooltipFocus: tooltipState.onFocus,
|
|
1302
|
+
onTooltipBlur: tooltipState.onBlur,
|
|
1303
|
+
onTooltipTrackMouseEnter: tooltipState.onTrackMouseEnter,
|
|
1304
|
+
onTooltipTrackMouseLeave: tooltipState.onTrackMouseLeave,
|
|
1305
|
+
onTooltipKeydown
|
|
1306
|
+
};
|
|
1307
|
+
}
|
|
1308
|
+
//#endregion
|
|
1309
|
+
//#region src/components/slider/range-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1310
|
+
var t0 = template("<span data-v-8dd81f55 class=rp-range-slider__label>");
|
|
1311
|
+
var t1 = template("<span data-v-8dd81f55 class=rp-range-slider__value aria-hidden=true>");
|
|
1312
|
+
var t2 = template("<span data-v-8dd81f55 class=rp-range-slider__header>");
|
|
1313
|
+
var t3 = template("<input data-v-8dd81f55 type=range>");
|
|
1314
|
+
var t4 = template("<span data-v-8dd81f55 class=rp-range-slider__mark-label> ");
|
|
1315
|
+
var t5 = template("<span data-v-8dd81f55><span data-v-8dd81f55 class=rp-range-slider__mark-dot></span>");
|
|
1316
|
+
var t6 = template("<span data-v-8dd81f55 class=rp-range-slider__marks aria-hidden=true>");
|
|
1317
|
+
var t7 = template("<span data-v-8dd81f55><span data-v-8dd81f55 class=rp-range-slider__thumb-content>");
|
|
1318
|
+
var t8 = template("<div data-v-8dd81f55 role=group><span data-v-8dd81f55 class=rp-range-slider__track><span data-v-8dd81f55 class=rp-range-slider__bar aria-hidden=true></span><!><span data-v-8dd81f55 class=rp-range-slider__thumbs aria-hidden=true>", 1);
|
|
1319
|
+
delegateEvents("input", "keydown", "pointerdown");
|
|
1320
|
+
//#endregion
|
|
1321
|
+
//#region src/components/slider/range-slider.vue
|
|
1322
|
+
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
1323
|
+
name: "RpRangeSlider",
|
|
1324
|
+
__name: "range-slider",
|
|
1325
|
+
props: {
|
|
1326
|
+
modelValue: {},
|
|
1327
|
+
minRange: { default: 0 },
|
|
1328
|
+
name: {},
|
|
1329
|
+
ariaLabel: { default: () => ["Minimum", "Maximum"] },
|
|
1330
|
+
ariaValueText: {},
|
|
1331
|
+
id: {},
|
|
1332
|
+
min: { default: 0 },
|
|
1333
|
+
max: { default: 100 },
|
|
1334
|
+
step: { default: 1 },
|
|
1335
|
+
marks: { default: () => [] },
|
|
1336
|
+
thumbStyle: {},
|
|
1337
|
+
tooltip: {
|
|
1338
|
+
type: [
|
|
1339
|
+
Boolean,
|
|
1340
|
+
String,
|
|
1341
|
+
Object
|
|
1342
|
+
],
|
|
1343
|
+
default: "hover"
|
|
1344
|
+
},
|
|
1345
|
+
formatValue: {},
|
|
1346
|
+
color: {},
|
|
1347
|
+
size: {},
|
|
1348
|
+
orientation: { default: "horizontal" },
|
|
1349
|
+
disabled: {
|
|
1350
|
+
type: Boolean,
|
|
1351
|
+
default: void 0
|
|
1352
|
+
},
|
|
1353
|
+
describedby: {},
|
|
1354
|
+
labelledby: {}
|
|
1355
|
+
},
|
|
1356
|
+
emits: ["update:modelValue"],
|
|
1357
|
+
setup(__props, { emit: __emit, slots: $slots }) {
|
|
1358
|
+
const props = __props;
|
|
1359
|
+
const emit = __emit;
|
|
1360
|
+
const slots = useSlots();
|
|
1361
|
+
const generatedId = useId();
|
|
1362
|
+
const tooltipsOverlapping = ref(false);
|
|
1363
|
+
const rangeSliderThumbs = ["lower", "upper"];
|
|
1364
|
+
const labelId = computed(() => `${props.id ?? generatedId}-label`);
|
|
1365
|
+
const { control, nativeMin, nativeMax, nativeStep, nativeNames, nativeIds, rootClass, normalizedValue, valuePercent, formattedValue, ariaLabels, ariaValueText, markItems, trackStyle, activeThumb, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipIds, mergedTooltipId, tooltipColor, tooltipOffset, tooltipArrow, tooltipContent, mergedTooltipContent, onInput, onTrackPointerDown, onTooltipFocus, onTooltipBlur, onTooltipTrackMouseEnter, onTooltipTrackMouseLeave, onTooltipKeydown } = useRangeSlider(props, (value) => {
|
|
1366
|
+
emit("update:modelValue", value);
|
|
1367
|
+
});
|
|
1368
|
+
const groupLabelledby = computed(() => {
|
|
1369
|
+
const values = [control.ariaLabelledby, slots.default ? labelId.value : void 0].flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
1370
|
+
return values.length ? Array.from(new Set(values)).join(" ") : void 0;
|
|
1371
|
+
});
|
|
1372
|
+
const n34 = t8();
|
|
1373
|
+
const n33 = child(n34, 1);
|
|
1374
|
+
const n32 = next(child(n33), 1);
|
|
1375
|
+
const n31 = next(n32, 3);
|
|
1376
|
+
renderEffect(() => {
|
|
1377
|
+
const _control = unref(control);
|
|
1378
|
+
setClass(n34, [unref(rootClass), {
|
|
1379
|
+
"rp-range-slider--custom-thumb": $slots.thumb,
|
|
1380
|
+
"rp-range-slider--tooltips-overlapping": tooltipsOverlapping.value
|
|
1381
|
+
}]);
|
|
1382
|
+
setAttr(n34, "data-active-thumb", unref(activeThumb));
|
|
1383
|
+
setAttr(n34, "data-disabled", _control.disabled || void 0);
|
|
1384
|
+
setStyle(n34, unref(trackStyle));
|
|
1385
|
+
setAttr(n34, "aria-labelledby", groupLabelledby.value);
|
|
1386
|
+
setAttr(n34, "aria-describedby", _control.ariaDescribedby);
|
|
1387
|
+
});
|
|
1388
|
+
setInsertionState(n34, 0, 0);
|
|
1389
|
+
createIf(() => $slots.default || $slots.value, () => {
|
|
1390
|
+
const n10 = t2();
|
|
1391
|
+
setInsertionState(n10, null, 0);
|
|
1392
|
+
createIf(() => $slots.default, () => {
|
|
1393
|
+
const n5 = t0();
|
|
1394
|
+
renderEffect(() => setProp(n5, "id", labelId.value));
|
|
1395
|
+
setInsertionState(n5, null, 0);
|
|
1396
|
+
createSlot("default", null, null, 1);
|
|
1397
|
+
return n5;
|
|
1398
|
+
});
|
|
1399
|
+
setInsertionState(n10, null, 1);
|
|
1400
|
+
createIf(() => $slots.value, () => {
|
|
1401
|
+
const n9 = t1();
|
|
1402
|
+
setInsertionState(n9, null, 0);
|
|
1403
|
+
createSlot("value", {
|
|
1404
|
+
value: () => unref(normalizedValue),
|
|
1405
|
+
formattedValue: () => unref(formattedValue),
|
|
1406
|
+
percent: () => unref(valuePercent)
|
|
1407
|
+
}, null, 1);
|
|
1408
|
+
return n9;
|
|
1409
|
+
});
|
|
1410
|
+
return n10;
|
|
1411
|
+
});
|
|
1412
|
+
setInsertionState(n33, n32, 1);
|
|
1413
|
+
createFor(() => rangeSliderThumbs, (_for_item0, _for_key0) => {
|
|
1414
|
+
const n13 = t3();
|
|
1415
|
+
n13.$evtinput = createInvoker(($event) => unref(onInput)(_for_item0.value, $event));
|
|
1416
|
+
on(n13, "focus", () => unref(onTooltipFocus)(_for_item0.value));
|
|
1417
|
+
on(n13, "blur", () => unref(onTooltipBlur)(_for_item0.value));
|
|
1418
|
+
n13.$evtkeydown = createInvoker(($event) => unref(onTooltipKeydown)(_for_item0.value, $event));
|
|
1419
|
+
let _index, _control;
|
|
1420
|
+
renderEffect(() => {
|
|
1421
|
+
_index = _for_key0.value;
|
|
1422
|
+
_control = unref(control);
|
|
1423
|
+
setProp(n13, "id", unref(nativeIds)[_index]);
|
|
1424
|
+
setProp(n13, "name", unref(nativeNames)[_index]);
|
|
1425
|
+
setValue(n13, unref(normalizedValue)[_index]);
|
|
1426
|
+
setProp(n13, "min", unref(nativeMin)[_index]);
|
|
1427
|
+
setProp(n13, "max", unref(nativeMax)[_index]);
|
|
1428
|
+
setProp(n13, "step", unref(nativeStep));
|
|
1429
|
+
setProp(n13, "orient", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1430
|
+
setProp(n13, "disabled", _control.disabled || void 0);
|
|
1431
|
+
setAttr(n13, "aria-label", unref(ariaLabels)[_index]);
|
|
1432
|
+
setAttr(n13, "aria-describedby", _control.ariaDescribedby);
|
|
1433
|
+
setAttr(n13, "aria-orientation", __props.orientation === "vertical" ? "vertical" : void 0);
|
|
1434
|
+
setAttr(n13, "aria-valuetext", unref(ariaValueText)[_index]);
|
|
1435
|
+
});
|
|
1436
|
+
setClass(n13, ["rp-range-slider__native", `rp-range-slider__native--${_for_item0.value}`]);
|
|
1437
|
+
return n13;
|
|
1438
|
+
}, (thumb, index) => thumb, 8);
|
|
1439
|
+
setInsertionState(n33, n32, 2);
|
|
1440
|
+
createIf(() => unref(markItems).length, () => {
|
|
1441
|
+
const n22 = t6();
|
|
1442
|
+
setInsertionState(n22, null, 0);
|
|
1443
|
+
createFor(() => unref(markItems), (_for_item0) => {
|
|
1444
|
+
const n21 = t5();
|
|
1445
|
+
renderEffect(() => {
|
|
1446
|
+
const _mark = _for_item0.value;
|
|
1447
|
+
setClassName(n21, _mark.filled ? 1 : 0, " rp-range-slider__mark--filled", "rp-range-slider__mark");
|
|
1448
|
+
setStyle(n21, _mark.style);
|
|
1449
|
+
});
|
|
1450
|
+
setInsertionState(n21, null, 1);
|
|
1451
|
+
createIf(() => _for_item0.value.hasLabel, () => {
|
|
1452
|
+
const n20 = t4();
|
|
1453
|
+
const x20 = txt(n20);
|
|
1454
|
+
renderEffect(() => setText(x20, toDisplayString(_for_item0.value.label)));
|
|
1455
|
+
return n20;
|
|
1456
|
+
});
|
|
1457
|
+
return n21;
|
|
1458
|
+
}, (mark) => mark.key, 9);
|
|
1459
|
+
return n22;
|
|
1460
|
+
});
|
|
1461
|
+
setInsertionState(n31, null, 0);
|
|
1462
|
+
createFor(() => rangeSliderThumbs, (_for_item0, _for_key0) => {
|
|
1463
|
+
const n27 = t7();
|
|
1464
|
+
const n26 = child(n27);
|
|
1465
|
+
renderEffect(() => setAttr(n27, "data-range-slider-thumb", _for_item0.value));
|
|
1466
|
+
setInsertionState(n26, null, 0);
|
|
1467
|
+
createSlot("thumb", {
|
|
1468
|
+
thumb: () => _for_item0.value,
|
|
1469
|
+
index: () => _for_key0.value,
|
|
1470
|
+
value: () => unref(normalizedValue)[_for_key0.value],
|
|
1471
|
+
formattedValue: () => unref(formattedValue)[_for_key0.value],
|
|
1472
|
+
percent: () => unref(valuePercent)[_for_key0.value]
|
|
1473
|
+
}, null, 1);
|
|
1474
|
+
setClass(n27, ["rp-range-slider__thumb", `rp-range-slider__thumb--${_for_item0.value}`]);
|
|
1475
|
+
return n27;
|
|
1476
|
+
}, (thumb, index) => thumb, 8);
|
|
1477
|
+
setInsertionState(n31, null, 1);
|
|
1478
|
+
createIf(() => unref(tooltipVisible), () => {
|
|
1479
|
+
const _on_update_overlapping = ($event) => tooltipsOverlapping.value = $event;
|
|
1480
|
+
return createComponent(range_slider_tooltip_default, {
|
|
1481
|
+
arrow: () => unref(tooltipArrow),
|
|
1482
|
+
color: () => unref(tooltipColor),
|
|
1483
|
+
content: () => unref(tooltipContent),
|
|
1484
|
+
ids: () => unref(tooltipIds),
|
|
1485
|
+
"merged-content": () => unref(mergedTooltipContent),
|
|
1486
|
+
"merged-id": () => unref(mergedTooltipId),
|
|
1487
|
+
offset: () => unref(tooltipOffset),
|
|
1488
|
+
open: () => unref(tooltipOpen),
|
|
1489
|
+
orientation: () => __props.orientation,
|
|
1490
|
+
placement: () => unref(tooltipPlacement),
|
|
1491
|
+
"value-percent": () => unref(valuePercent),
|
|
1492
|
+
"onUpdate:overlapping": () => _on_update_overlapping
|
|
1493
|
+
});
|
|
1494
|
+
});
|
|
1495
|
+
n33.$evtpointerdown = createInvoker((e) => unref(onTrackPointerDown)(e));
|
|
1496
|
+
on(n33, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1497
|
+
on(n33, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1498
|
+
return n34;
|
|
1499
|
+
}
|
|
1500
|
+
}), [["__scopeId", "data-v-8dd81f55"]]);
|
|
1501
|
+
//#endregion
|
|
1502
|
+
//#region src/components/slider/types.ts
|
|
1503
|
+
var sliderColors = componentColors;
|
|
1504
|
+
var sliderSizes = [
|
|
1505
|
+
"xs",
|
|
1506
|
+
"sm",
|
|
1507
|
+
"md",
|
|
1508
|
+
"lg",
|
|
1509
|
+
"xl"
|
|
1510
|
+
];
|
|
1511
|
+
var sliderOrientations = ["horizontal", "vertical"];
|
|
410
1512
|
//#endregion
|
|
411
|
-
export {
|
|
1513
|
+
export { slider_default as a, range_slider_default as i, sliderOrientations as n, sliderSizes as r, sliderColors as t };
|