ropav 0.0.9 → 0.0.11
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/README.md +6 -0
- package/dist/accordion.css +115 -111
- package/dist/accordion.js +60 -16
- package/dist/alert.css +110 -108
- package/dist/alert.js +48 -26
- package/dist/aspect-ratio.css +17 -15
- package/dist/aspect-ratio.js +20 -6
- package/dist/avatar.css +98 -96
- package/dist/avatar.js +27 -16
- package/dist/badge.css +95 -93
- package/dist/badge.js +29 -16
- package/dist/base.css +672 -671
- package/dist/button-group.css +39 -37
- package/dist/button-group.js +23 -12
- package/dist/button-link.css +160 -158
- package/dist/button-link.js +43 -24
- package/dist/button.css +160 -158
- package/dist/button.js +37 -19
- package/dist/card.css +109 -107
- package/dist/card.js +42 -17
- package/dist/checkbox.css +139 -137
- package/dist/checkbox.js +79 -28
- package/dist/collapse.css +29 -27
- package/dist/collapse.js +44 -10
- package/dist/color-input.css +137 -107
- package/dist/color-input.js +91 -17
- package/dist/color-picker.css +309 -303
- package/dist/color-picker.js +250 -77
- package/dist/color-picker2.js +9 -1
- package/dist/color-swatch.css +48 -46
- package/dist/color-swatch.js +15 -11
- package/dist/color-swatch2.js +4 -0
- package/dist/components/accordion/accordion-item.d.ts +16 -4
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/index.d.ts +5 -4
- package/dist/components/accordion/index.js +2 -2
- package/dist/components/accordion/types.d.ts +10 -5
- package/dist/components/accordion/useAccordion.d.ts +1 -1
- package/dist/components/alert/alert.d.ts +3 -3
- package/dist/components/alert/index.d.ts +3 -3
- package/dist/components/alert/index.js +2 -2
- package/dist/components/alert/types.d.ts +5 -2
- package/dist/components/alert/useAlertColor.d.ts +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +1 -1
- package/dist/components/aspect-ratio/index.d.ts +3 -2
- package/dist/components/aspect-ratio/index.js +2 -2
- package/dist/components/aspect-ratio/types.d.ts +4 -1
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/avatar/index.d.ts +3 -3
- package/dist/components/avatar/index.js +2 -2
- package/dist/components/avatar/types.d.ts +5 -2
- package/dist/components/avatar/useAvatarColor.d.ts +1 -1
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/index.d.ts +3 -3
- package/dist/components/badge/index.js +2 -2
- package/dist/components/badge/types.d.ts +5 -2
- package/dist/components/badge/useBadgeColor.d.ts +1 -1
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/index.d.ts +3 -2
- package/dist/components/button/index.js +2 -2
- package/dist/components/button/types.d.ts +5 -2
- package/dist/components/button/useButtonColor.d.ts +1 -1
- package/dist/components/button-group/button-group.d.ts +1 -1
- package/dist/components/button-group/index.d.ts +3 -2
- package/dist/components/button-group/index.js +2 -2
- package/dist/components/button-group/types.d.ts +4 -1
- package/dist/components/button-link/button-link.d.ts +1 -1
- package/dist/components/button-link/index.d.ts +3 -2
- package/dist/components/button-link/index.js +2 -2
- package/dist/components/button-link/types.d.ts +5 -2
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/index.d.ts +3 -2
- package/dist/components/card/index.js +2 -2
- package/dist/components/card/types.d.ts +5 -1
- package/dist/components/checkbox/checkbox.d.ts +5 -2
- package/dist/components/checkbox/index.d.ts +3 -2
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/checkbox/types.d.ts +7 -2
- package/dist/components/checkbox/useCheckbox.d.ts +4 -2
- package/dist/components/collapse/collapse.d.ts +2 -2
- package/dist/components/collapse/index.d.ts +4 -3
- package/dist/components/collapse/index.js +2 -2
- package/dist/components/collapse/types.d.ts +9 -2
- package/dist/components/collapse/useCollapse.d.ts +1 -1
- package/dist/components/color-input/color-input.d.ts +1 -1
- package/dist/components/color-input/index.d.ts +3 -2
- package/dist/components/color-input/index.js +2 -2
- package/dist/components/color-input/types.d.ts +8 -4
- package/dist/components/color-input/useColorInput.d.ts +5 -5
- package/dist/components/color-input/useColorInputEyeDropper.d.ts +1 -1
- package/dist/components/color-input/useColorInputPopover.d.ts +2 -2
- package/dist/components/color-input/useColorInputValue.d.ts +1 -1
- package/dist/components/color-picker/color-picker-saturation.d.ts +1 -1
- package/dist/components/color-picker/color-picker-slider.d.ts +1 -1
- package/dist/components/color-picker/color-picker-utils.d.ts +1 -1
- package/dist/components/color-picker/color-picker.d.ts +1 -1
- package/dist/components/color-picker/index.d.ts +3 -3
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +13 -1
- package/dist/components/color-picker/useColorPickerDrag.d.ts +7 -2
- package/dist/components/color-picker/useColorPickerSwatches.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerValue.d.ts +2 -2
- package/dist/components/color-swatch/color-swatch.d.ts +1 -1
- package/dist/components/color-swatch/index.d.ts +3 -2
- package/dist/components/color-swatch/index.js +2 -1
- package/dist/components/color-swatch/types.d.ts +4 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +15 -6
- package/dist/components/dropdown-menu/dropdown-menu-primitives.d.ts +724 -0
- 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 +55 -3
- package/dist/components/dropdown-menu/index.js +2 -2
- package/dist/components/dropdown-menu/types.d.ts +142 -6
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +21 -12
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +6 -4
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +4 -3
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +5 -5
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +3 -3
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +25 -5
- 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 +3 -2
- package/dist/components/field/index.js +2 -2
- package/dist/components/field/types.d.ts +4 -1
- package/dist/components/field/useField.d.ts +1 -1
- package/dist/components/floating/index.d.ts +1 -0
- package/dist/components/floating/index.js +0 -0
- package/dist/components/floating/types.d.ts +31 -0
- package/dist/components/floating/useFloatingPosition.d.ts +38 -0
- package/dist/components/focus-trap/focus-trap.d.ts +31 -0
- package/dist/components/focus-trap/index.d.ts +4 -0
- package/dist/components/focus-trap/index.js +3 -0
- package/dist/components/focus-trap/types.d.ts +41 -0
- package/dist/components/focus-trap/useFocusTrap.d.ts +2 -0
- package/dist/components/icon-button/icon-button.d.ts +1 -1
- package/dist/components/icon-button/index.d.ts +3 -2
- package/dist/components/icon-button/index.js +2 -1
- package/dist/components/icon-button/types.d.ts +5 -2
- package/dist/components/input/index.d.ts +3 -2
- package/dist/components/input/index.js +2 -1
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/types.d.ts +4 -1
- package/dist/components/input/useInput.d.ts +2 -2
- package/dist/components/modal/index.d.ts +3 -2
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal/modal.d.ts +1 -1
- package/dist/components/modal/types.d.ts +9 -2
- package/dist/components/modal/useModal.d.ts +1 -1
- package/dist/components/number-input/index.d.ts +3 -2
- package/dist/components/number-input/index.js +2 -2
- package/dist/components/number-input/number-input.d.ts +1 -1
- package/dist/components/number-input/types.d.ts +5 -2
- package/dist/components/number-input/useNumberInput.d.ts +2 -2
- package/dist/components/overlay/index.d.ts +3 -2
- package/dist/components/overlay/index.js +2 -1
- package/dist/components/overlay/overlay.d.ts +1 -1
- package/dist/components/overlay/types.d.ts +4 -1
- package/dist/components/overlay/useOverlay.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -3
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/types.d.ts +21 -11
- package/dist/components/popover/usePopover.d.ts +11 -2
- package/dist/components/progress/index.d.ts +3 -3
- package/dist/components/progress/index.js +2 -2
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/progress/types.d.ts +5 -2
- package/dist/components/progress/useProgress.d.ts +2 -2
- package/dist/components/radio/index.d.ts +4 -3
- package/dist/components/radio/index.js +2 -2
- package/dist/components/radio/radio-group.d.ts +1 -1
- package/dist/components/radio/radio.d.ts +9 -4
- package/dist/components/radio/types.d.ts +21 -4
- package/dist/components/radio/useRadio.d.ts +10 -5
- package/dist/components/select/index.d.ts +3 -2
- package/dist/components/select/index.js +2 -2
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/types.d.ts +4 -1
- package/dist/components/select/useSelect.d.ts +4 -3
- package/dist/components/slider/index.d.ts +4 -4
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/range-slider-tooltip.d.ts +37 -0
- package/dist/components/slider/range-slider.d.ts +8 -13
- package/dist/components/slider/slider.d.ts +5 -2
- package/dist/components/slider/sliderCore.d.ts +35 -0
- package/dist/components/slider/types.d.ts +14 -7
- package/dist/components/slider/useRangeSlider.d.ts +5 -7
- package/dist/components/slider/useRangeSliderPointer.d.ts +19 -0
- package/dist/components/slider/useRangeSliderTooltipCollision.d.ts +31 -2
- 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 +3 -2
- package/dist/components/switch/index.js +2 -2
- package/dist/components/switch/switch.d.ts +5 -2
- package/dist/components/switch/types.d.ts +7 -2
- package/dist/components/switch/useSwitch.d.ts +4 -2
- package/dist/components/tabs/index.d.ts +7 -6
- package/dist/components/tabs/index.js +2 -2
- 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/types.d.ts +13 -4
- package/dist/components/tabs/useTabs.d.ts +1 -1
- package/dist/components/teleport-provider/index.d.ts +2 -0
- package/dist/components/teleport-provider/index.js +2 -0
- package/dist/components/teleport-provider/teleport-provider.d.ts +21 -0
- package/dist/components/teleport-provider/types.d.ts +4 -0
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +5 -0
- package/dist/components/textarea/index.d.ts +3 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/textarea/textarea.d.ts +5 -2
- package/dist/components/textarea/types.d.ts +6 -1
- package/dist/components/textarea/useTextarea.d.ts +3 -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 +110 -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 +3 -2
- package/dist/components/tooltip/index.js +2 -1
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/types.d.ts +14 -13
- package/dist/components/tooltip/useTooltip.d.ts +15 -3
- package/dist/dropdown-menu.css +191 -107
- package/dist/dropdown-menu.js +1729 -107
- package/dist/field.css +41 -39
- package/dist/field.js +40 -16
- package/dist/focus-trap.js +80 -0
- package/dist/icon-button.css +193 -189
- package/dist/icon-button.js +23 -18
- package/dist/icon-button2.js +8 -0
- package/dist/index.d.ts +35 -30
- package/dist/index.js +36 -31
- package/dist/input.css +122 -120
- package/dist/input.js +47 -34
- package/dist/input2.js +9 -0
- package/dist/legacy-unlayered.css +5461 -0
- package/dist/modal.css +129 -127
- package/dist/modal.js +160 -200
- package/dist/number-input.css +87 -85
- package/dist/number-input.js +61 -17
- package/dist/overlay.css +26 -24
- package/dist/overlay.js +17 -9
- package/dist/overlay2.js +4 -0
- package/dist/popover.css +140 -107
- package/dist/popover.js +295 -189
- package/dist/popover2.js +6 -1
- package/dist/progress.css +101 -99
- package/dist/progress.js +50 -28
- package/dist/radio.css +114 -105
- package/dist/radio.js +154 -56
- package/dist/select.css +244 -242
- package/dist/select.js +92 -47
- package/dist/slider.css +1109 -904
- package/dist/slider.js +1118 -923
- package/dist/styles-api.d.ts +22 -0
- package/dist/styles-api.js +49 -0
- package/dist/switch.css +120 -108
- package/dist/switch.js +89 -33
- package/dist/tabs.css +286 -278
- package/dist/tabs.js +60 -21
- package/dist/teleport-provider.js +15 -0
- package/dist/textarea.css +132 -130
- package/dist/textarea.js +77 -29
- package/dist/toast.css +236 -0
- package/dist/toast.js +739 -0
- package/dist/tooltip.css +137 -107
- package/dist/tooltip.js +182 -223
- package/dist/tooltip2.js +8 -0
- package/dist/useClickOutside.js +1 -1
- package/dist/useFloatingPosition.js +1284 -0
- package/dist/useFocusTrap.js +130 -0
- package/dist/useTeleportTarget.js +29 -0
- package/dist/utils/componentColors.d.ts +60 -0
- package/docs/public-styles-api.md +133 -0
- package/docs/public-tokens.md +545 -0
- package/package.json +44 -12
- package/src/styles/_tokens.scss +33 -28
- package/src/styles/_utilities.scss +11 -9
- package/src/styles/styles-manifest.json +4125 -0
- package/dist/components/slider/useRangeSliderTooltipTransition.d.ts +0 -4
package/dist/slider.js
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
import './slider.css';
|
|
2
2
|
import { t as bem } from "./bem.js";
|
|
3
|
+
import { n as useStylesApi, t as presence } from "./styles-api.js";
|
|
3
4
|
import { n as getComponentColorValue, t as componentColors } from "./componentColors.js";
|
|
4
5
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
5
6
|
import { t as useControlState } from "./useControlState.js";
|
|
6
|
-
import {
|
|
7
|
-
import { child, computed, createComponent, createFor, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, next,
|
|
8
|
-
//#region src/components/slider/
|
|
9
|
-
var sliderMarkColorProperties = [
|
|
10
|
-
"--_rp-slider-mark-color",
|
|
11
|
-
"--_rp-slider-mark-label-color",
|
|
12
|
-
"--_rp-slider-mark-filled-label-color",
|
|
13
|
-
"--_rp-slider-mark-ring-color"
|
|
14
|
-
];
|
|
15
|
-
function normalizeSliderValue(value, min, max, step) {
|
|
16
|
-
const bounds = normalizeSliderBounds(min, max);
|
|
17
|
-
const safeStep = normalizeSliderStep(step);
|
|
18
|
-
const safeValue = Number.isFinite(value) ? value : bounds.min;
|
|
19
|
-
const clamped = Math.min(bounds.max, Math.max(bounds.min, safeValue));
|
|
20
|
-
if (safeStep === "any") return clamped;
|
|
21
|
-
const steps = Math.round((clamped - bounds.min) / safeStep);
|
|
22
|
-
const snapped = bounds.min + steps * safeStep;
|
|
23
|
-
return Math.min(bounds.max, Math.max(bounds.min, Number(snapped.toFixed(10))));
|
|
24
|
-
}
|
|
7
|
+
import { i as useDelayedOpen, n as resolveTooltipColorStyleWithContrast, r as resolveTooltipOffsetStyle, t as tooltip_default } from "./tooltip.js";
|
|
8
|
+
import { applyVShow, child, computed, createComponent, createFor, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, next, on, onBeforeUnmount, onMounted, ref, renderEffect, setClass, setDynamicProps, setInsertionState, setProp, setStyle, setText, template, toDisplayString, toRef, txt, unref, useId, useSlots, watch } from "vue";
|
|
9
|
+
//#region src/components/slider/sliderCore.ts
|
|
25
10
|
function normalizeSliderBounds(min, max) {
|
|
26
11
|
const safeMin = Number.isFinite(min) ? min : 0;
|
|
27
12
|
const safeMax = Number.isFinite(max) ? max : safeMin;
|
|
@@ -36,32 +21,48 @@ function normalizeSliderBounds(min, max) {
|
|
|
36
21
|
function normalizeSliderStep(step) {
|
|
37
22
|
return step === "any" || Number.isFinite(step) && step > 0 ? step : "any";
|
|
38
23
|
}
|
|
24
|
+
function normalizeSliderValue(value, min, max, step) {
|
|
25
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
26
|
+
const safeStep = normalizeSliderStep(step);
|
|
27
|
+
const safeValue = Number.isFinite(value) ? value : bounds.min;
|
|
28
|
+
const clamped = Math.min(bounds.max, Math.max(bounds.min, safeValue));
|
|
29
|
+
if (safeStep === "any") return clamped;
|
|
30
|
+
const steps = Math.round((clamped - bounds.min) / safeStep);
|
|
31
|
+
const snapped = bounds.min + steps * safeStep;
|
|
32
|
+
return Math.min(bounds.max, Math.max(bounds.min, Number(snapped.toFixed(10))));
|
|
33
|
+
}
|
|
39
34
|
function getSliderValuePercent(value, min, max) {
|
|
40
35
|
if (max <= min) return 0;
|
|
41
36
|
const percent = (value - min) / (max - min) * 100;
|
|
42
37
|
return Math.min(100, Math.max(0, percent));
|
|
43
38
|
}
|
|
44
|
-
function getSliderMarkColorValue(color) {
|
|
45
|
-
return getComponentColorValue(color);
|
|
46
|
-
}
|
|
47
|
-
function getSliderColorValue(color) {
|
|
48
|
-
return getComponentColorValue(color);
|
|
49
|
-
}
|
|
50
39
|
function setSliderStyleValue(style, property, value) {
|
|
51
40
|
if (value) style[property] = value;
|
|
52
41
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
function getSliderLengthValue(value) {
|
|
43
|
+
if (value == null || value === "") return void 0;
|
|
44
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function getSliderBorderValue(value, borderColorProperty) {
|
|
48
|
+
if (value == null || value === "") return void 0;
|
|
49
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px solid var(${borderColorProperty})` : void 0;
|
|
50
|
+
return value;
|
|
58
51
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
52
|
+
function applySliderThumbStyle(style, thumbStyle, properties) {
|
|
53
|
+
setSliderStyleValue(style, properties.size, getSliderLengthValue(thumbStyle?.size));
|
|
54
|
+
setSliderStyleValue(style, properties.border, getSliderBorderValue(thumbStyle?.border, properties.borderColor));
|
|
55
|
+
setSliderStyleValue(style, properties.padding, getSliderLengthValue(thumbStyle?.padding));
|
|
61
56
|
}
|
|
62
|
-
function
|
|
57
|
+
function getSliderMarkStyle(percent, color, properties) {
|
|
58
|
+
const style = { [properties.position]: `${percent}%` };
|
|
59
|
+
const colorValue = getComponentColorValue(color);
|
|
60
|
+
for (const property of properties.colors) setSliderStyleValue(style, property, colorValue);
|
|
61
|
+
return style;
|
|
62
|
+
}
|
|
63
|
+
function createSliderMarkItems(marks, min, max, isFilled, properties) {
|
|
63
64
|
return (marks ?? []).flatMap((markInput, index) => {
|
|
64
|
-
const mark =
|
|
65
|
+
const mark = typeof markInput === "number" ? { value: markInput } : markInput;
|
|
65
66
|
if (mark.hidden) return [];
|
|
66
67
|
const value = Number(mark.value);
|
|
67
68
|
if (!Number.isFinite(value)) return [];
|
|
@@ -71,47 +72,11 @@ function normalizeSliderMarks(marks, min, max, valuePercent) {
|
|
|
71
72
|
value,
|
|
72
73
|
label: mark.label,
|
|
73
74
|
hasLabel: mark.label != null,
|
|
74
|
-
filled: percent
|
|
75
|
-
style: getSliderMarkStyle(percent, mark.color)
|
|
75
|
+
filled: isFilled(value, percent),
|
|
76
|
+
style: getSliderMarkStyle(percent, mark.color, properties)
|
|
76
77
|
};
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
|
-
function getSliderLengthValue(value) {
|
|
80
|
-
if (value == null || value === "") return void 0;
|
|
81
|
-
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
function getSliderBorderValue(value) {
|
|
85
|
-
if (value == null || value === "") return void 0;
|
|
86
|
-
if (typeof value === "number") return Number.isFinite(value) ? `${value}px solid var(--_rp-slider-thumb-border)` : void 0;
|
|
87
|
-
return value;
|
|
88
|
-
}
|
|
89
|
-
var sliderThumbStyleProps = [
|
|
90
|
-
[
|
|
91
|
-
"--_rp-slider-thumb-size",
|
|
92
|
-
"size",
|
|
93
|
-
getSliderLengthValue
|
|
94
|
-
],
|
|
95
|
-
[
|
|
96
|
-
"--_rp-slider-thumb-border-style",
|
|
97
|
-
"border",
|
|
98
|
-
getSliderBorderValue
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
"--_rp-slider-thumb-padding",
|
|
102
|
-
"padding",
|
|
103
|
-
getSliderLengthValue
|
|
104
|
-
]
|
|
105
|
-
];
|
|
106
|
-
function getSliderTrackStyle(props, valuePercent) {
|
|
107
|
-
const style = {
|
|
108
|
-
"--_rp-slider-percent": `${valuePercent}%`,
|
|
109
|
-
"--_rp-slider-ratio": `${valuePercent / 100}`
|
|
110
|
-
};
|
|
111
|
-
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
112
|
-
for (const [property, propName, getValue] of sliderThumbStyleProps) setSliderStyleValue(style, property, getValue(props.thumbStyle?.[propName]));
|
|
113
|
-
return style;
|
|
114
|
-
}
|
|
115
80
|
function getFormattedSliderValue(value, formatter) {
|
|
116
81
|
return formatter ? formatter(value) : value;
|
|
117
82
|
}
|
|
@@ -128,6 +93,25 @@ function getSliderTooltipMode(tooltip) {
|
|
|
128
93
|
if (typeof tooltip === "object") return tooltip.mode ?? "hover";
|
|
129
94
|
return tooltip;
|
|
130
95
|
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/components/slider/useSlider.ts
|
|
98
|
+
function getSliderColorValue(color) {
|
|
99
|
+
return getComponentColorValue(color);
|
|
100
|
+
}
|
|
101
|
+
function getSliderTrackStyle(props, valuePercent) {
|
|
102
|
+
const style = {
|
|
103
|
+
"--_rp-slider-percent": `${valuePercent}%`,
|
|
104
|
+
"--_rp-slider-ratio": `${valuePercent / 100}`
|
|
105
|
+
};
|
|
106
|
+
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
107
|
+
applySliderThumbStyle(style, props.thumbStyle, {
|
|
108
|
+
size: "--rp-slider-thumb-size",
|
|
109
|
+
border: "--_rp-slider-thumb-border-style",
|
|
110
|
+
padding: "--rp-slider-thumb-padding",
|
|
111
|
+
borderColor: "--_rp-slider-thumb-border"
|
|
112
|
+
});
|
|
113
|
+
return style;
|
|
114
|
+
}
|
|
131
115
|
function useSlider(props, emitUpdate) {
|
|
132
116
|
const control = useControlState(props);
|
|
133
117
|
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
@@ -136,7 +120,15 @@ function useSlider(props, emitUpdate) {
|
|
|
136
120
|
const valuePercent = computed(() => getSliderValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
137
121
|
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
138
122
|
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
139
|
-
const markItems = computed(() =>
|
|
123
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
124
|
+
position: "--_rp-slider-mark-position",
|
|
125
|
+
colors: [
|
|
126
|
+
"--_rp-slider-mark-color",
|
|
127
|
+
"--_rp-slider-mark-label-color",
|
|
128
|
+
"--_rp-slider-mark-filled-label-color",
|
|
129
|
+
"--_rp-slider-mark-ring-color"
|
|
130
|
+
]
|
|
131
|
+
}));
|
|
140
132
|
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
141
133
|
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
142
134
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
@@ -144,6 +136,12 @@ function useSlider(props, emitUpdate) {
|
|
|
144
136
|
openDelay: () => tooltipOpenDelay.value,
|
|
145
137
|
disabled: () => tooltipMode.value !== "hover" || control.disabled
|
|
146
138
|
});
|
|
139
|
+
const trackHovered = ref(false);
|
|
140
|
+
const focusWithin = ref(false);
|
|
141
|
+
const dragging = ref(false);
|
|
142
|
+
let dismissed = false;
|
|
143
|
+
let dragView = null;
|
|
144
|
+
let dragPointerId;
|
|
147
145
|
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
148
146
|
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
149
147
|
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
@@ -160,9 +158,7 @@ function useSlider(props, emitUpdate) {
|
|
|
160
158
|
marked: markItems.value.length > 0,
|
|
161
159
|
"marks-with-labels": hasMarkLabels.value,
|
|
162
160
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
163
|
-
disabled: control.disabled
|
|
164
|
-
invalid: control.invalid,
|
|
165
|
-
valid: control.valid && !control.invalid
|
|
161
|
+
disabled: control.disabled
|
|
166
162
|
}));
|
|
167
163
|
const trackStyle = computed(() => getSliderTrackStyle(props, valuePercent.value));
|
|
168
164
|
function onInput(e) {
|
|
@@ -170,15 +166,64 @@ function useSlider(props, emitUpdate) {
|
|
|
170
166
|
const input = e.target;
|
|
171
167
|
emitUpdate(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
172
168
|
}
|
|
173
|
-
function
|
|
174
|
-
|
|
169
|
+
function hasTooltipInteraction() {
|
|
170
|
+
return trackHovered.value || focusWithin.value || dragging.value;
|
|
175
171
|
}
|
|
176
|
-
function
|
|
172
|
+
function syncTooltip() {
|
|
173
|
+
if (tooltipMode.value === "hover" && !control.disabled && hasTooltipInteraction() && !dismissed) {
|
|
174
|
+
openDelayedTooltip();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
177
|
closeDelayedTooltip();
|
|
178
178
|
}
|
|
179
|
+
function onTooltipMouseEnter() {
|
|
180
|
+
trackHovered.value = true;
|
|
181
|
+
dismissed = false;
|
|
182
|
+
syncTooltip();
|
|
183
|
+
}
|
|
184
|
+
function onTooltipMouseLeave() {
|
|
185
|
+
trackHovered.value = false;
|
|
186
|
+
syncTooltip();
|
|
187
|
+
}
|
|
188
|
+
function onTooltipFocusIn() {
|
|
189
|
+
focusWithin.value = true;
|
|
190
|
+
dismissed = false;
|
|
191
|
+
syncTooltip();
|
|
192
|
+
}
|
|
193
|
+
function onTooltipFocusOut() {
|
|
194
|
+
focusWithin.value = false;
|
|
195
|
+
syncTooltip();
|
|
196
|
+
}
|
|
197
|
+
function removeDragListeners() {
|
|
198
|
+
dragView?.removeEventListener("pointerup", onTooltipPointerEnd);
|
|
199
|
+
dragView?.removeEventListener("pointercancel", onTooltipPointerEnd);
|
|
200
|
+
dragView = null;
|
|
201
|
+
dragPointerId = void 0;
|
|
202
|
+
}
|
|
203
|
+
function onTooltipPointerEnd(event) {
|
|
204
|
+
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
205
|
+
dragging.value = false;
|
|
206
|
+
removeDragListeners();
|
|
207
|
+
syncTooltip();
|
|
208
|
+
}
|
|
209
|
+
function onTooltipPointerDown(event) {
|
|
210
|
+
if (control.disabled || event.button !== 0 || event.isPrimary === false) return;
|
|
211
|
+
removeDragListeners();
|
|
212
|
+
dismissed = false;
|
|
213
|
+
dragging.value = true;
|
|
214
|
+
dragPointerId = Number.isFinite(event.pointerId) ? event.pointerId : void 0;
|
|
215
|
+
dragView = event.currentTarget?.ownerDocument.defaultView ?? null;
|
|
216
|
+
dragView?.addEventListener("pointerup", onTooltipPointerEnd);
|
|
217
|
+
dragView?.addEventListener("pointercancel", onTooltipPointerEnd);
|
|
218
|
+
syncTooltip();
|
|
219
|
+
}
|
|
179
220
|
function onTooltipKeydown(event) {
|
|
180
|
-
if (event.key === "Escape")
|
|
221
|
+
if (event.key === "Escape") {
|
|
222
|
+
dismissed = true;
|
|
223
|
+
closeDelayedTooltip();
|
|
224
|
+
}
|
|
181
225
|
}
|
|
226
|
+
onBeforeUnmount(removeDragListeners);
|
|
182
227
|
return {
|
|
183
228
|
control,
|
|
184
229
|
nativeMin: computed(() => bounds.value.min),
|
|
@@ -201,27 +246,30 @@ function useSlider(props, emitUpdate) {
|
|
|
201
246
|
tooltipArrow,
|
|
202
247
|
tooltipContent,
|
|
203
248
|
onInput,
|
|
204
|
-
|
|
205
|
-
|
|
249
|
+
onTooltipPointerDown,
|
|
250
|
+
onTooltipMouseEnter,
|
|
251
|
+
onTooltipMouseLeave,
|
|
252
|
+
onTooltipFocusIn,
|
|
253
|
+
onTooltipFocusOut,
|
|
206
254
|
onTooltipKeydown
|
|
207
255
|
};
|
|
208
256
|
}
|
|
209
257
|
//#endregion
|
|
210
258
|
//#region src/components/slider/slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
211
|
-
var t0$
|
|
212
|
-
var t1$
|
|
213
|
-
var t2$
|
|
214
|
-
var t3$
|
|
215
|
-
var t4$
|
|
216
|
-
var t5$1 = template("<span data-v-
|
|
217
|
-
var t6$1 = template("<span data-v-
|
|
218
|
-
var t7$1 = template("<span data-v-
|
|
219
|
-
|
|
220
|
-
delegateEvents("input", "focusin", "focusout", "keydown");
|
|
259
|
+
var t0$2 = template("<span data-v-cf8192a8>");
|
|
260
|
+
var t1$2 = template("<span data-v-cf8192a8 class=rp-slider__header>");
|
|
261
|
+
var t2$2 = template("<span data-v-cf8192a8> ");
|
|
262
|
+
var t3$2 = template("<span data-v-cf8192a8><span data-v-cf8192a8 class=rp-slider__mark-dot></span>");
|
|
263
|
+
var t4$2 = template("<span data-v-cf8192a8 class=rp-slider__marks aria-hidden=true>");
|
|
264
|
+
var t5$1 = template("<span data-v-cf8192a8><span data-v-cf8192a8 class=rp-slider__thumb-content>");
|
|
265
|
+
var t6$1 = template("<span data-v-cf8192a8 class=rp-slider__tooltip-anchor aria-hidden=true>", 2);
|
|
266
|
+
var t7$1 = template("<label data-v-cf8192a8><span data-v-cf8192a8><span data-v-cf8192a8></span><input data-v-cf8192a8>", 1);
|
|
267
|
+
delegateEvents("pointerdown", "focusin", "focusout", "keydown");
|
|
221
268
|
//#endregion
|
|
222
269
|
//#region src/components/slider/slider.vue
|
|
223
270
|
var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
224
271
|
name: "RpSlider",
|
|
272
|
+
inheritAttrs: false,
|
|
225
273
|
__name: "slider",
|
|
226
274
|
props: {
|
|
227
275
|
id: {},
|
|
@@ -248,51 +296,75 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
248
296
|
type: Boolean,
|
|
249
297
|
default: void 0
|
|
250
298
|
},
|
|
251
|
-
required: {
|
|
252
|
-
type: Boolean,
|
|
253
|
-
default: void 0
|
|
254
|
-
},
|
|
255
|
-
invalid: {
|
|
256
|
-
type: Boolean,
|
|
257
|
-
default: void 0
|
|
258
|
-
},
|
|
259
|
-
valid: {
|
|
260
|
-
type: Boolean,
|
|
261
|
-
default: void 0
|
|
262
|
-
},
|
|
263
299
|
ariaLabel: {},
|
|
264
300
|
ariaValueText: {},
|
|
265
301
|
describedby: {},
|
|
266
|
-
labelledby: {}
|
|
302
|
+
labelledby: {},
|
|
303
|
+
inputAttrs: {},
|
|
304
|
+
classNames: {},
|
|
305
|
+
styles: {}
|
|
267
306
|
},
|
|
268
307
|
emits: ["update:modelValue"],
|
|
269
|
-
setup(__props, { emit: __emit, slots: $slots }) {
|
|
308
|
+
setup(__props, { expose: __expose, emit: __emit, slots: $slots }) {
|
|
270
309
|
const props = __props;
|
|
271
310
|
const emit = __emit;
|
|
272
|
-
const
|
|
311
|
+
const inputRef = ref(null);
|
|
312
|
+
const slots = useSlots();
|
|
313
|
+
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) => {
|
|
273
314
|
emit("update:modelValue", value);
|
|
274
315
|
});
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
316
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
317
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
318
|
+
class: [rootClass.value, { "rp-slider--custom-thumb": Boolean(slots.thumb) }],
|
|
319
|
+
style: trackStyle.value,
|
|
320
|
+
"data-disabled": presence(control.disabled),
|
|
321
|
+
"data-orientation": props.orientation
|
|
322
|
+
}));
|
|
323
|
+
const tooltipClassNames = computed(() => ({ root: ["rp-slider__tooltip", props.classNames?.tooltip] }));
|
|
324
|
+
const tooltipStyles = computed(() => ({ root: props.styles?.tooltip }));
|
|
325
|
+
const nativeInputAttrs = computed(() => {
|
|
326
|
+
const { class: compatibilityClass, style: compatibilityStyle, onInput: compatibilityOnInput, ...attrs } = props.inputAttrs ?? {};
|
|
327
|
+
return {
|
|
328
|
+
...attrs,
|
|
329
|
+
...getPartAttrs("input", {
|
|
330
|
+
class: "rp-slider__native",
|
|
331
|
+
compatibilityClass,
|
|
332
|
+
compatibilityStyle
|
|
333
|
+
}),
|
|
334
|
+
onInput(event) {
|
|
335
|
+
onInput(event);
|
|
336
|
+
compatibilityOnInput?.(event);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
282
339
|
});
|
|
283
|
-
|
|
340
|
+
function focus(options) {
|
|
341
|
+
inputRef.value?.focus(options);
|
|
342
|
+
}
|
|
343
|
+
__expose({
|
|
344
|
+
nativeElement: inputRef,
|
|
345
|
+
focus
|
|
346
|
+
});
|
|
347
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
348
|
+
const n32 = t7$1();
|
|
349
|
+
const n31 = child(n32, 1);
|
|
350
|
+
const n11 = child(n31);
|
|
351
|
+
const n12 = next(n11, 1);
|
|
352
|
+
renderEffect(() => setDynamicProps(n32, [rootAttrs.value]));
|
|
353
|
+
setInsertionState(n32, 0, 0);
|
|
284
354
|
createIf(() => $slots.default || $slots.value, () => {
|
|
285
|
-
const n10 =
|
|
355
|
+
const n10 = t1$2();
|
|
286
356
|
setInsertionState(n10, null, 0);
|
|
287
357
|
createIf(() => $slots.default, () => {
|
|
288
|
-
const n5 = t0$
|
|
358
|
+
const n5 = t0$2();
|
|
359
|
+
renderEffect(() => setDynamicProps(n5, [unref(getPartAttrs)("label", { class: "rp-slider__label" })]));
|
|
289
360
|
setInsertionState(n5, null, 0);
|
|
290
361
|
createSlot("default", null, null, 1);
|
|
291
362
|
return n5;
|
|
292
363
|
});
|
|
293
364
|
setInsertionState(n10, null, 1);
|
|
294
365
|
createIf(() => $slots.value, () => {
|
|
295
|
-
const n9 =
|
|
366
|
+
const n9 = t0$2();
|
|
367
|
+
renderEffect(() => setDynamicProps(n9, [unref(getPartAttrs)("value", { class: "rp-slider__value" }), { "aria-hidden": "true" }]));
|
|
296
368
|
setInsertionState(n9, null, 0);
|
|
297
369
|
createSlot("value", {
|
|
298
370
|
value: () => unref(normalizedValue),
|
|
@@ -303,65 +375,76 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
303
375
|
});
|
|
304
376
|
return n10;
|
|
305
377
|
});
|
|
306
|
-
|
|
378
|
+
_setTemplateRef(n12, inputRef, null, "inputRef");
|
|
307
379
|
renderEffect(() => {
|
|
380
|
+
const _getPartAttrs = unref(getPartAttrs);
|
|
308
381
|
const _control = unref(control);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
382
|
+
setDynamicProps(n31, [_getPartAttrs("track", { class: "rp-slider__track" })]);
|
|
383
|
+
setDynamicProps(n11, [_getPartAttrs("range", { class: "rp-slider__bar" }), { "aria-hidden": "true" }]);
|
|
384
|
+
setDynamicProps(n12, [nativeInputAttrs.value, {
|
|
385
|
+
id: _control.id,
|
|
386
|
+
name: __props.name,
|
|
387
|
+
type: "range",
|
|
388
|
+
value: unref(normalizedValue),
|
|
389
|
+
min: unref(nativeMin),
|
|
390
|
+
max: unref(nativeMax),
|
|
391
|
+
step: unref(nativeStep),
|
|
392
|
+
orient: __props.orientation === "vertical" ? "vertical" : void 0,
|
|
393
|
+
disabled: _control.disabled || void 0,
|
|
394
|
+
"aria-label": __props.ariaLabel || void 0,
|
|
395
|
+
"aria-labelledby": _control.ariaLabelledby,
|
|
396
|
+
"aria-describedby": _control.ariaDescribedby,
|
|
397
|
+
"aria-orientation": __props.orientation === "vertical" ? "vertical" : void 0,
|
|
398
|
+
"aria-valuetext": unref(ariaValueText),
|
|
399
|
+
"data-disabled": unref(presence)(_control.disabled)
|
|
400
|
+
}]);
|
|
326
401
|
});
|
|
327
|
-
setInsertionState(
|
|
402
|
+
setInsertionState(n31, null, 2);
|
|
328
403
|
createIf(() => unref(markItems).length, () => {
|
|
329
|
-
const
|
|
330
|
-
setInsertionState(
|
|
404
|
+
const n21 = t4$2();
|
|
405
|
+
setInsertionState(n21, null, 0);
|
|
331
406
|
createFor(() => unref(markItems), (_for_item0) => {
|
|
332
|
-
const
|
|
407
|
+
const n20 = t3$2();
|
|
333
408
|
renderEffect(() => {
|
|
334
409
|
const _mark = _for_item0.value;
|
|
335
|
-
|
|
336
|
-
|
|
410
|
+
setDynamicProps(n20, [unref(getPartAttrs)("mark", {
|
|
411
|
+
class: ["rp-slider__mark", { "rp-slider__mark--filled": _mark.filled }],
|
|
412
|
+
style: _mark.style
|
|
413
|
+
}), { "data-filled": unref(presence)(_mark.filled) }]);
|
|
337
414
|
});
|
|
338
|
-
setInsertionState(
|
|
415
|
+
setInsertionState(n20, null, 1);
|
|
339
416
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
renderEffect(() =>
|
|
343
|
-
|
|
417
|
+
const n19 = t2$2();
|
|
418
|
+
const x19 = txt(n19);
|
|
419
|
+
renderEffect(() => {
|
|
420
|
+
setDynamicProps(n19, [unref(getPartAttrs)("markLabel", { class: "rp-slider__mark-label" })]);
|
|
421
|
+
setText(x19, toDisplayString(_for_item0.value.label));
|
|
422
|
+
});
|
|
423
|
+
return n19;
|
|
344
424
|
});
|
|
345
|
-
return
|
|
425
|
+
return n20;
|
|
346
426
|
}, (mark) => mark.key, 9);
|
|
347
|
-
return
|
|
427
|
+
return n21;
|
|
348
428
|
});
|
|
349
|
-
setInsertionState(
|
|
429
|
+
setInsertionState(n31, null, 3);
|
|
350
430
|
createIf(() => $slots.thumb, () => {
|
|
351
|
-
const
|
|
352
|
-
|
|
431
|
+
const n26 = t5$1();
|
|
432
|
+
const n25 = child(n26);
|
|
433
|
+
renderEffect(() => setDynamicProps(n26, [unref(getPartAttrs)("thumb", { class: "rp-slider__thumb" }), { "aria-hidden": "true" }]));
|
|
434
|
+
setInsertionState(n25, null, 0);
|
|
353
435
|
createSlot("thumb", {
|
|
354
436
|
value: () => unref(normalizedValue),
|
|
355
437
|
formattedValue: () => unref(formattedValue),
|
|
356
438
|
percent: () => unref(valuePercent)
|
|
357
439
|
}, null, 1);
|
|
358
|
-
return
|
|
440
|
+
return n26;
|
|
359
441
|
});
|
|
360
|
-
setInsertionState(
|
|
442
|
+
setInsertionState(n31, null, 4);
|
|
361
443
|
createIf(() => unref(tooltipVisible), () => {
|
|
362
444
|
return createComponent(tooltip_default, {
|
|
363
445
|
id: () => unref(tooltipId),
|
|
364
|
-
class:
|
|
446
|
+
"class-names": () => tooltipClassNames.value,
|
|
447
|
+
styles: () => tooltipStyles.value,
|
|
365
448
|
content: () => unref(tooltipContent),
|
|
366
449
|
placement: () => unref(tooltipPlacement),
|
|
367
450
|
color: () => unref(tooltipColor),
|
|
@@ -371,25 +454,614 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
371
454
|
arrow: () => unref(tooltipArrow),
|
|
372
455
|
decorative: ""
|
|
373
456
|
}, () => {
|
|
374
|
-
return
|
|
457
|
+
return t6$1();
|
|
375
458
|
});
|
|
376
459
|
});
|
|
377
|
-
|
|
378
|
-
on(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
460
|
+
n31.$evtpointerdown = createInvoker((e) => unref(onTooltipPointerDown)(e));
|
|
461
|
+
on(n31, "mouseenter", (e) => unref(onTooltipMouseEnter)(e));
|
|
462
|
+
on(n31, "mouseleave", (e) => unref(onTooltipMouseLeave)(e));
|
|
463
|
+
n31.$evtfocusin = createInvoker((e) => unref(onTooltipFocusIn)(e));
|
|
464
|
+
n31.$evtfocusout = createInvoker((e) => unref(onTooltipFocusOut)(e));
|
|
465
|
+
n31.$evtkeydown = createInvoker((e) => unref(onTooltipKeydown)(e));
|
|
466
|
+
return n32;
|
|
383
467
|
}
|
|
384
|
-
}), [["__scopeId", "data-v-
|
|
468
|
+
}), [["__scopeId", "data-v-cf8192a8"]]);
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
471
|
+
var TOOLTIP_COLLISION_GAP = 4;
|
|
472
|
+
function getAxisSize(size, orientation) {
|
|
473
|
+
return orientation === "horizontal" ? size.width : size.height;
|
|
474
|
+
}
|
|
475
|
+
function getTooltipInterval(anchor, size, orientation, placement) {
|
|
476
|
+
const axisSize = getAxisSize(size, orientation);
|
|
477
|
+
if (orientation === "horizontal" ? placement === "top" || placement === "bottom" : placement === "left" || placement === "right") return {
|
|
478
|
+
start: anchor - axisSize / 2,
|
|
479
|
+
end: anchor + axisSize / 2
|
|
480
|
+
};
|
|
481
|
+
return (orientation === "horizontal" ? placement === "left" : placement === "top") ? {
|
|
482
|
+
start: anchor - axisSize,
|
|
483
|
+
end: anchor
|
|
484
|
+
} : {
|
|
485
|
+
start: anchor,
|
|
486
|
+
end: anchor + axisSize
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function areTooltipIntervalsOverlapping(lower, upper, gap) {
|
|
490
|
+
return lower.start < upper.end + gap && lower.end + gap > upper.start;
|
|
491
|
+
}
|
|
492
|
+
function areRangeSliderTooltipLayoutsOverlapping({ gap = TOOLTIP_COLLISION_GAP, lowerPercent, lowerSize, orientation, placement, trackLength, upperPercent, upperSize }) {
|
|
493
|
+
if (trackLength <= 0 || lowerSize.width <= 0 || lowerSize.height <= 0 || upperSize.width <= 0 || upperSize.height <= 0) return false;
|
|
494
|
+
const getAnchor = (percent) => {
|
|
495
|
+
const ratio = percent / 100;
|
|
496
|
+
return orientation === "vertical" ? trackLength * (1 - ratio) : trackLength * ratio;
|
|
497
|
+
};
|
|
498
|
+
return areTooltipIntervalsOverlapping(getTooltipInterval(getAnchor(lowerPercent), lowerSize, orientation, placement), getTooltipInterval(getAnchor(upperPercent), upperSize, orientation, placement), gap);
|
|
499
|
+
}
|
|
500
|
+
function getObservedSize(entry) {
|
|
501
|
+
const borderBoxSize = Array.isArray(entry.borderBoxSize) ? entry.borderBoxSize[0] : entry.borderBoxSize;
|
|
502
|
+
if (borderBoxSize) return {
|
|
503
|
+
width: borderBoxSize.inlineSize,
|
|
504
|
+
height: borderBoxSize.blockSize
|
|
505
|
+
};
|
|
506
|
+
return {
|
|
507
|
+
width: entry.contentRect.width,
|
|
508
|
+
height: entry.contentRect.height
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function getElementSize(element) {
|
|
512
|
+
const rect = element.getBoundingClientRect();
|
|
513
|
+
return {
|
|
514
|
+
width: rect.width,
|
|
515
|
+
height: rect.height
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement, root, sizeDependencies = [], upper, valuePercent }) {
|
|
519
|
+
const tooltipsOverlapping = ref(false);
|
|
520
|
+
const rootSize = ref({
|
|
521
|
+
width: 0,
|
|
522
|
+
height: 0
|
|
523
|
+
});
|
|
524
|
+
const lowerSize = ref({
|
|
525
|
+
width: 0,
|
|
526
|
+
height: 0
|
|
527
|
+
});
|
|
528
|
+
const upperSize = ref({
|
|
529
|
+
width: 0,
|
|
530
|
+
height: 0
|
|
531
|
+
});
|
|
532
|
+
let resizeObserver;
|
|
533
|
+
let frameWindow;
|
|
534
|
+
let frameId;
|
|
535
|
+
let destroyed = false;
|
|
536
|
+
function setOverlapping(value) {
|
|
537
|
+
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
538
|
+
}
|
|
539
|
+
function updateCollision() {
|
|
540
|
+
if (!enabled.value) {
|
|
541
|
+
setOverlapping(false);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
const trackLength = orientation.value === "horizontal" ? rootSize.value.width : rootSize.value.height;
|
|
545
|
+
setOverlapping(areRangeSliderTooltipLayoutsOverlapping({
|
|
546
|
+
gap: TOOLTIP_COLLISION_GAP,
|
|
547
|
+
lowerPercent: valuePercent.value[0],
|
|
548
|
+
lowerSize: lowerSize.value,
|
|
549
|
+
orientation: orientation.value,
|
|
550
|
+
placement: placement.value,
|
|
551
|
+
trackLength,
|
|
552
|
+
upperPercent: valuePercent.value[1],
|
|
553
|
+
upperSize: upperSize.value
|
|
554
|
+
}));
|
|
555
|
+
}
|
|
556
|
+
function measureSizes() {
|
|
557
|
+
if (destroyed) return;
|
|
558
|
+
rootSize.value = root.value ? getElementSize(root.value) : {
|
|
559
|
+
width: 0,
|
|
560
|
+
height: 0
|
|
561
|
+
};
|
|
562
|
+
lowerSize.value = lower.value ? getElementSize(lower.value) : {
|
|
563
|
+
width: 0,
|
|
564
|
+
height: 0
|
|
565
|
+
};
|
|
566
|
+
upperSize.value = upper.value ? getElementSize(upper.value) : {
|
|
567
|
+
width: 0,
|
|
568
|
+
height: 0
|
|
569
|
+
};
|
|
570
|
+
updateCollision();
|
|
571
|
+
}
|
|
572
|
+
function scheduleMeasure() {
|
|
573
|
+
if (destroyed || frameId != null) return;
|
|
574
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
575
|
+
if (!view?.requestAnimationFrame) {
|
|
576
|
+
measureSizes();
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
frameWindow = view;
|
|
580
|
+
frameId = view.requestAnimationFrame(() => {
|
|
581
|
+
frameId = void 0;
|
|
582
|
+
frameWindow = void 0;
|
|
583
|
+
measureSizes();
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
function refreshObservedElements() {
|
|
587
|
+
if (!resizeObserver) return;
|
|
588
|
+
resizeObserver.disconnect();
|
|
589
|
+
for (const element of [
|
|
590
|
+
root.value,
|
|
591
|
+
lower.value,
|
|
592
|
+
upper.value
|
|
593
|
+
]) if (element) resizeObserver.observe(element);
|
|
594
|
+
}
|
|
595
|
+
function onResize(entries) {
|
|
596
|
+
for (const entry of entries) {
|
|
597
|
+
const size = getObservedSize(entry);
|
|
598
|
+
if (entry.target === root.value) rootSize.value = size;
|
|
599
|
+
else if (entry.target === lower.value) lowerSize.value = size;
|
|
600
|
+
else if (entry.target === upper.value) upperSize.value = size;
|
|
601
|
+
}
|
|
602
|
+
updateCollision();
|
|
603
|
+
}
|
|
604
|
+
function onWindowResize() {
|
|
605
|
+
scheduleMeasure();
|
|
606
|
+
}
|
|
607
|
+
onMounted(() => {
|
|
608
|
+
const view = root.value?.ownerDocument.defaultView;
|
|
609
|
+
if (view?.ResizeObserver) resizeObserver = new view.ResizeObserver(onResize);
|
|
610
|
+
view?.addEventListener("resize", onWindowResize);
|
|
611
|
+
refreshObservedElements();
|
|
612
|
+
if (!resizeObserver) scheduleMeasure();
|
|
613
|
+
});
|
|
614
|
+
watch([
|
|
615
|
+
root,
|
|
616
|
+
lower,
|
|
617
|
+
upper
|
|
618
|
+
], () => {
|
|
619
|
+
refreshObservedElements();
|
|
620
|
+
if (!resizeObserver) scheduleMeasure();
|
|
621
|
+
}, { flush: "post" });
|
|
622
|
+
watch([
|
|
623
|
+
valuePercent,
|
|
624
|
+
orientation,
|
|
625
|
+
placement,
|
|
626
|
+
enabled
|
|
627
|
+
], updateCollision, { flush: "sync" });
|
|
628
|
+
watch(sizeDependencies, () => {
|
|
629
|
+
if (!resizeObserver) scheduleMeasure();
|
|
630
|
+
}, { flush: "post" });
|
|
631
|
+
const arrowAlongTrackAxis = computed(() => orientation.value === "horizontal" ? placement.value === "top" || placement.value === "bottom" : placement.value === "left" || placement.value === "right");
|
|
632
|
+
const trackAxisLength = computed(() => orientation.value === "horizontal" ? rootSize.value.width : rootSize.value.height);
|
|
633
|
+
const thumbDistance = computed(() => {
|
|
634
|
+
const [lowerPercent, upperPercent] = valuePercent.value;
|
|
635
|
+
return Math.abs(upperPercent - lowerPercent) / 100 * trackAxisLength.value;
|
|
636
|
+
});
|
|
637
|
+
const mergedArrowOffset = computed(() => {
|
|
638
|
+
if (trackAxisLength.value <= 0 || !arrowAlongTrackAxis.value) return 0;
|
|
639
|
+
return thumbDistance.value * .5;
|
|
640
|
+
});
|
|
641
|
+
const mergedMinSize = computed(() => {
|
|
642
|
+
if (!tooltipsOverlapping.value || trackAxisLength.value <= 0 || !arrowAlongTrackAxis.value) return 0;
|
|
643
|
+
const maxEndpoint = Math.max(getAxisSize(lowerSize.value, orientation.value), getAxisSize(upperSize.value, orientation.value));
|
|
644
|
+
return thumbDistance.value + maxEndpoint;
|
|
645
|
+
});
|
|
646
|
+
onBeforeUnmount(() => {
|
|
647
|
+
destroyed = true;
|
|
648
|
+
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
649
|
+
resizeObserver?.disconnect();
|
|
650
|
+
if (frameId != null) frameWindow?.cancelAnimationFrame(frameId);
|
|
651
|
+
});
|
|
652
|
+
return {
|
|
653
|
+
tooltipsOverlapping,
|
|
654
|
+
mergedArrowOffset,
|
|
655
|
+
mergedMinSize
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/components/slider/range-slider-tooltip.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
660
|
+
var t0$1 = template("<span data-v-ce70c540 class=rp-range-slider__tooltip-merged-value> </span>");
|
|
661
|
+
var t1$1 = template("<span data-v-ce70c540 class=rp-range-slider__tooltip-merged-value> ");
|
|
662
|
+
var t2$1 = template("<span data-v-ce70c540 class=rp-range-slider__tooltip-merged-separator>–</span>", 2);
|
|
663
|
+
var t3$1 = template(" ");
|
|
664
|
+
var t4$1 = template("<span data-v-ce70c540 aria-hidden=true><span data-v-ce70c540 data-thumb=lower><span data-v-ce70c540 class=rp-range-slider__tooltip-anchor></span><span data-v-ce70c540 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-ce70c540 data-thumb=upper><span data-v-ce70c540 class=rp-range-slider__tooltip-anchor></span><span data-v-ce70c540 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-ce70c540 data-thumb=merged><span data-v-ce70c540 class=rp-range-slider__tooltip-anchor></span><span data-v-ce70c540 class=rp-tooltip__content aria-hidden=true>", 1);
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/components/slider/range-slider-tooltip.vue
|
|
667
|
+
var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
668
|
+
name: "RpRangeSliderTooltip",
|
|
669
|
+
__name: "range-slider-tooltip",
|
|
670
|
+
props: {
|
|
671
|
+
arrow: {
|
|
672
|
+
type: Boolean,
|
|
673
|
+
default: false
|
|
674
|
+
},
|
|
675
|
+
color: { default: void 0 },
|
|
676
|
+
content: {},
|
|
677
|
+
ids: {},
|
|
678
|
+
mergedContent: {},
|
|
679
|
+
mergedId: { default: void 0 },
|
|
680
|
+
offset: { default: void 0 },
|
|
681
|
+
open: { type: Boolean },
|
|
682
|
+
orientation: {},
|
|
683
|
+
placement: {},
|
|
684
|
+
valuePercent: {},
|
|
685
|
+
tooltipClass: { type: [
|
|
686
|
+
Boolean,
|
|
687
|
+
null,
|
|
688
|
+
String,
|
|
689
|
+
Object,
|
|
690
|
+
Array
|
|
691
|
+
] },
|
|
692
|
+
tooltipStyle: { type: [
|
|
693
|
+
Boolean,
|
|
694
|
+
null,
|
|
695
|
+
String,
|
|
696
|
+
Object,
|
|
697
|
+
Array
|
|
698
|
+
] }
|
|
699
|
+
},
|
|
700
|
+
emits: ["update:overlapping"],
|
|
701
|
+
setup(__props, { emit: __emit }) {
|
|
702
|
+
const props = __props;
|
|
703
|
+
const emit = __emit;
|
|
704
|
+
const generatedId = useId();
|
|
705
|
+
const tooltipLayerRef = ref(null);
|
|
706
|
+
const lowerContentRef = ref(null);
|
|
707
|
+
const upperContentRef = ref(null);
|
|
708
|
+
const resolvedIds = computed(() => [props.ids[0] ?? `${generatedId}-lower-tooltip`, props.ids[1] ?? `${generatedId}-upper-tooltip`]);
|
|
709
|
+
const resolvedMergedId = computed(() => props.mergedId ?? `${generatedId}-merged-tooltip`);
|
|
710
|
+
const tooltipRootClass = computed(() => bem("rp-tooltip", {
|
|
711
|
+
[`placement-${props.placement}`]: true,
|
|
712
|
+
arrow: props.arrow,
|
|
713
|
+
open: props.open
|
|
714
|
+
}));
|
|
715
|
+
const contentStyle = computed(() => ({
|
|
716
|
+
...resolveTooltipOffsetStyle(props.offset),
|
|
717
|
+
...resolveTooltipColorStyleWithContrast(props.color, void 0)
|
|
718
|
+
}));
|
|
719
|
+
const { tooltipsOverlapping, mergedArrowOffset, mergedMinSize } = useRangeSliderTooltipCollision({
|
|
720
|
+
enabled: toRef(props, "open"),
|
|
721
|
+
lower: lowerContentRef,
|
|
722
|
+
orientation: toRef(props, "orientation"),
|
|
723
|
+
placement: toRef(props, "placement"),
|
|
724
|
+
root: tooltipLayerRef,
|
|
725
|
+
sizeDependencies: [() => props.content],
|
|
726
|
+
upper: upperContentRef,
|
|
727
|
+
valuePercent: toRef(props, "valuePercent")
|
|
728
|
+
});
|
|
729
|
+
const layerStyle = computed(() => ({
|
|
730
|
+
"--_rp-range-slider-tooltip-merged-arrow-offset": `${mergedArrowOffset.value}px`,
|
|
731
|
+
"--_rp-range-slider-tooltip-merged-min-size": `${mergedMinSize.value}px`
|
|
732
|
+
}));
|
|
733
|
+
watch(tooltipsOverlapping, (overlapping) => {
|
|
734
|
+
emit("update:overlapping", overlapping);
|
|
735
|
+
}, { immediate: true });
|
|
736
|
+
onBeforeUnmount(() => {
|
|
737
|
+
emit("update:overlapping", false);
|
|
738
|
+
});
|
|
739
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
740
|
+
const n16 = t4$1();
|
|
741
|
+
const n1 = child(n16);
|
|
742
|
+
const n0 = next(child(n1), 1);
|
|
743
|
+
const n3 = next(n1, 1);
|
|
744
|
+
const n2 = next(child(n3), 1);
|
|
745
|
+
const n15 = next(n3, 2);
|
|
746
|
+
const n14 = next(child(n15), 1);
|
|
747
|
+
const x0 = txt(n0);
|
|
748
|
+
applyVShow(n0, () => __props.open);
|
|
749
|
+
_setTemplateRef(n0, lowerContentRef, null, "lowerContentRef");
|
|
750
|
+
const x2 = txt(n2);
|
|
751
|
+
applyVShow(n2, () => __props.open);
|
|
752
|
+
_setTemplateRef(n2, upperContentRef, null, "upperContentRef");
|
|
753
|
+
renderEffect(() => {
|
|
754
|
+
const _tooltipStyle = __props.tooltipStyle;
|
|
755
|
+
const _resolvedIds = resolvedIds.value;
|
|
756
|
+
const _contentStyle = contentStyle.value;
|
|
757
|
+
const _content = __props.content;
|
|
758
|
+
setClass(n16, [
|
|
759
|
+
"rp-range-slider__tooltips",
|
|
760
|
+
`rp-range-slider__tooltips--placement-${__props.placement}`,
|
|
761
|
+
{
|
|
762
|
+
"rp-range-slider__tooltips--overlapping": unref(tooltipsOverlapping),
|
|
763
|
+
"rp-range-slider__tooltips--vertical": __props.orientation === "vertical"
|
|
764
|
+
}
|
|
765
|
+
]);
|
|
766
|
+
setStyle(n16, layerStyle.value);
|
|
767
|
+
setClass(n1, [
|
|
768
|
+
tooltipRootClass.value,
|
|
769
|
+
"rp-range-slider__tooltip",
|
|
770
|
+
"rp-range-slider__tooltip--lower",
|
|
771
|
+
__props.tooltipClass
|
|
772
|
+
]);
|
|
773
|
+
setStyle(n1, _tooltipStyle);
|
|
774
|
+
setProp(n0, "id", _resolvedIds[0]);
|
|
775
|
+
setStyle(n0, _contentStyle);
|
|
776
|
+
setText(x0, toDisplayString(_content[0]));
|
|
777
|
+
setClass(n3, [
|
|
778
|
+
tooltipRootClass.value,
|
|
779
|
+
"rp-range-slider__tooltip",
|
|
780
|
+
"rp-range-slider__tooltip--upper",
|
|
781
|
+
__props.tooltipClass
|
|
782
|
+
]);
|
|
783
|
+
setStyle(n3, _tooltipStyle);
|
|
784
|
+
setProp(n2, "id", _resolvedIds[1]);
|
|
785
|
+
setStyle(n2, _contentStyle);
|
|
786
|
+
setText(x2, toDisplayString(_content[1]));
|
|
787
|
+
setClass(n15, [
|
|
788
|
+
tooltipRootClass.value,
|
|
789
|
+
"rp-range-slider__tooltip",
|
|
790
|
+
"rp-range-slider__tooltip--merged",
|
|
791
|
+
__props.tooltipClass
|
|
792
|
+
]);
|
|
793
|
+
setStyle(n15, _tooltipStyle);
|
|
794
|
+
setProp(n14, "id", resolvedMergedId.value);
|
|
795
|
+
setStyle(n14, _contentStyle);
|
|
796
|
+
});
|
|
797
|
+
setInsertionState(n14, null, 0);
|
|
798
|
+
createIf(() => __props.orientation === "vertical" && __props.content[0] !== __props.content[1], () => {
|
|
799
|
+
const n6 = t0$1();
|
|
800
|
+
const n7 = t1$1();
|
|
801
|
+
const x6 = txt(n6);
|
|
802
|
+
const x7 = txt(n7);
|
|
803
|
+
renderEffect(() => {
|
|
804
|
+
const _content = __props.content;
|
|
805
|
+
setText(x6, toDisplayString(_content[1]));
|
|
806
|
+
setText(x7, toDisplayString(_content[0]));
|
|
807
|
+
});
|
|
808
|
+
return [n6, n7];
|
|
809
|
+
}, () => createIf(() => __props.content[0] !== __props.content[1], () => {
|
|
810
|
+
const n9 = t0$1();
|
|
811
|
+
const n10 = t2$1();
|
|
812
|
+
const n11 = t1$1();
|
|
813
|
+
const x9 = txt(n9);
|
|
814
|
+
const x11 = txt(n11);
|
|
815
|
+
renderEffect(() => {
|
|
816
|
+
const _content = __props.content;
|
|
817
|
+
setText(x9, toDisplayString(_content[0]));
|
|
818
|
+
setText(x11, toDisplayString(_content[1]));
|
|
819
|
+
});
|
|
820
|
+
return [
|
|
821
|
+
n9,
|
|
822
|
+
n10,
|
|
823
|
+
n11
|
|
824
|
+
];
|
|
825
|
+
}, () => {
|
|
826
|
+
const n13 = t3$1();
|
|
827
|
+
renderEffect(() => setText(n13, toDisplayString(__props.mergedContent)));
|
|
828
|
+
return n13;
|
|
829
|
+
}, 518), 262);
|
|
830
|
+
applyVShow(n14, () => __props.open);
|
|
831
|
+
_setTemplateRef(n16, tooltipLayerRef, null, "tooltipLayerRef");
|
|
832
|
+
return n16;
|
|
833
|
+
}
|
|
834
|
+
}), [["__scopeId", "data-v-ce70c540"]]);
|
|
835
|
+
//#endregion
|
|
836
|
+
//#region src/components/slider/useRangeSliderPointer.ts
|
|
837
|
+
function useRangeSliderPointer(options) {
|
|
838
|
+
let session;
|
|
839
|
+
let frameWindow = null;
|
|
840
|
+
let frameId;
|
|
841
|
+
let pendingPointerEvent;
|
|
842
|
+
let geometryDirty = false;
|
|
843
|
+
function cancelScheduledFrame() {
|
|
844
|
+
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
845
|
+
frameWindow = null;
|
|
846
|
+
frameId = void 0;
|
|
847
|
+
}
|
|
848
|
+
function refreshGeometry() {
|
|
849
|
+
const currentSession = session;
|
|
850
|
+
if (!currentSession) return false;
|
|
851
|
+
if (!geometryDirty) return true;
|
|
852
|
+
const geometry = options.getPointerGeometry(currentSession.track);
|
|
853
|
+
if (geometry === void 0) return false;
|
|
854
|
+
geometryDirty = false;
|
|
855
|
+
currentSession.geometry = geometry;
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
function applyScheduledUpdate() {
|
|
859
|
+
if (!refreshGeometry()) return;
|
|
860
|
+
const event = pendingPointerEvent;
|
|
861
|
+
pendingPointerEvent = void 0;
|
|
862
|
+
if (event && isCurrentPointer(event)) updateFromPointer(event);
|
|
863
|
+
}
|
|
864
|
+
function flushScheduledUpdate() {
|
|
865
|
+
cancelScheduledFrame();
|
|
866
|
+
applyScheduledUpdate();
|
|
867
|
+
}
|
|
868
|
+
function onAnimationFrame() {
|
|
869
|
+
frameWindow = null;
|
|
870
|
+
frameId = void 0;
|
|
871
|
+
applyScheduledUpdate();
|
|
872
|
+
}
|
|
873
|
+
function scheduleUpdate() {
|
|
874
|
+
const view = session?.view;
|
|
875
|
+
if (!view?.requestAnimationFrame) {
|
|
876
|
+
flushScheduledUpdate();
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (frameId !== void 0) return;
|
|
880
|
+
frameWindow = view;
|
|
881
|
+
frameId = view.requestAnimationFrame(onAnimationFrame);
|
|
882
|
+
}
|
|
883
|
+
function onGeometryChange() {
|
|
884
|
+
if (!session) return;
|
|
885
|
+
geometryDirty = true;
|
|
886
|
+
scheduleUpdate();
|
|
887
|
+
}
|
|
888
|
+
function stopDragging() {
|
|
889
|
+
const stoppedSession = session;
|
|
890
|
+
if (!stoppedSession) return;
|
|
891
|
+
stoppedSession.view?.removeEventListener("pointermove", onPointerMove);
|
|
892
|
+
stoppedSession.view?.removeEventListener("pointerup", onPointerEnd);
|
|
893
|
+
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
894
|
+
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
895
|
+
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
896
|
+
cancelScheduledFrame();
|
|
897
|
+
pendingPointerEvent = void 0;
|
|
898
|
+
geometryDirty = false;
|
|
899
|
+
session = void 0;
|
|
900
|
+
options.endDrag(stoppedSession.thumb);
|
|
901
|
+
}
|
|
902
|
+
function switchDraggingThumb(nextThumb) {
|
|
903
|
+
const currentSession = session;
|
|
904
|
+
if (!currentSession || currentSession.thumb === nextThumb) return;
|
|
905
|
+
const previousThumb = currentSession.thumb;
|
|
906
|
+
currentSession.thumb = nextThumb;
|
|
907
|
+
options.transferDrag(previousThumb, nextThumb);
|
|
908
|
+
options.setActiveThumb(nextThumb);
|
|
909
|
+
options.transferFocusedThumb(currentSession.track, previousThumb, nextThumb);
|
|
910
|
+
}
|
|
911
|
+
function updateFromPointer(event) {
|
|
912
|
+
const currentSession = session;
|
|
913
|
+
if (!currentSession) return;
|
|
914
|
+
const value = options.getPointerValue(event, currentSession.geometry);
|
|
915
|
+
if (value == null) return;
|
|
916
|
+
switchDraggingThumb(options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
917
|
+
}
|
|
918
|
+
function isCurrentPointer(event) {
|
|
919
|
+
return session?.pointerId === void 0 || event.pointerId === session.pointerId;
|
|
920
|
+
}
|
|
921
|
+
function onPointerMove(event) {
|
|
922
|
+
if (!isCurrentPointer(event)) return;
|
|
923
|
+
if (!session) return;
|
|
924
|
+
pendingPointerEvent = event;
|
|
925
|
+
scheduleUpdate();
|
|
926
|
+
}
|
|
927
|
+
function onPointerEnd(event) {
|
|
928
|
+
if (!isCurrentPointer(event)) return;
|
|
929
|
+
if (event.type === "pointerup") flushScheduledUpdate();
|
|
930
|
+
stopDragging();
|
|
931
|
+
}
|
|
932
|
+
function onTrackPointerDown(event) {
|
|
933
|
+
if (options.disabled() || event.button !== 0 || event.isPrimary === false) return;
|
|
934
|
+
const track = event.currentTarget;
|
|
935
|
+
if (!track) return;
|
|
936
|
+
const geometry = options.getPointerGeometry(track);
|
|
937
|
+
if (geometry === void 0) return;
|
|
938
|
+
const pointerValue = options.getPointerValue(event, geometry);
|
|
939
|
+
if (pointerValue == null) return;
|
|
940
|
+
const thumb = options.getThumb(event, pointerValue);
|
|
941
|
+
event.preventDefault();
|
|
942
|
+
stopDragging();
|
|
943
|
+
options.setActiveThumb(thumb);
|
|
944
|
+
options.focusThumb(track, thumb);
|
|
945
|
+
session = {
|
|
946
|
+
view: track.ownerDocument.defaultView,
|
|
947
|
+
track,
|
|
948
|
+
geometry,
|
|
949
|
+
thumb,
|
|
950
|
+
anchorValue: options.getAnchorValue(thumb),
|
|
951
|
+
pointerId: Number.isFinite(event.pointerId) ? event.pointerId : void 0
|
|
952
|
+
};
|
|
953
|
+
options.startDrag(thumb);
|
|
954
|
+
switchDraggingThumb(options.updateThumb(thumb, pointerValue, session.anchorValue));
|
|
955
|
+
const view = session?.view;
|
|
956
|
+
view?.addEventListener("pointermove", onPointerMove);
|
|
957
|
+
view?.addEventListener("pointerup", onPointerEnd);
|
|
958
|
+
view?.addEventListener("pointercancel", onPointerEnd);
|
|
959
|
+
view?.addEventListener("resize", onGeometryChange);
|
|
960
|
+
view?.addEventListener("scroll", onGeometryChange, true);
|
|
961
|
+
}
|
|
962
|
+
onBeforeUnmount(stopDragging);
|
|
963
|
+
return { onTrackPointerDown };
|
|
964
|
+
}
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region src/components/slider/useRangeSliderTooltipState.ts
|
|
967
|
+
function useRangeSliderTooltipState(options) {
|
|
968
|
+
const delayedTooltip = useDelayedOpen({
|
|
969
|
+
openDelay: () => options.openDelay.value,
|
|
970
|
+
disabled: () => options.mode.value !== "hover" || options.disabled()
|
|
971
|
+
});
|
|
972
|
+
const interactionReasons = ref({
|
|
973
|
+
lower: {
|
|
974
|
+
focus: false,
|
|
975
|
+
drag: false
|
|
976
|
+
},
|
|
977
|
+
upper: {
|
|
978
|
+
focus: false,
|
|
979
|
+
drag: false
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
const trackHovered = ref(false);
|
|
983
|
+
const dismissed = ref(false);
|
|
984
|
+
function hasThumbInteraction(thumb) {
|
|
985
|
+
const reasons = interactionReasons.value[thumb];
|
|
986
|
+
return reasons.focus || reasons.drag;
|
|
987
|
+
}
|
|
988
|
+
function hasAnyInteraction() {
|
|
989
|
+
return trackHovered.value || hasThumbInteraction("lower") || hasThumbInteraction("upper");
|
|
990
|
+
}
|
|
991
|
+
function sync() {
|
|
992
|
+
if (options.mode.value === "hover" && !options.disabled() && hasAnyInteraction() && !dismissed.value) {
|
|
993
|
+
delayedTooltip.open();
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
delayedTooltip.closeImmediate();
|
|
997
|
+
}
|
|
998
|
+
function startInteraction(thumb, reason) {
|
|
999
|
+
options.setActiveThumb(thumb);
|
|
1000
|
+
const wasActive = hasAnyInteraction();
|
|
1001
|
+
const wasDismissed = dismissed.value;
|
|
1002
|
+
interactionReasons.value[thumb][reason] = true;
|
|
1003
|
+
dismissed.value = false;
|
|
1004
|
+
if (!wasActive || wasDismissed) sync();
|
|
1005
|
+
}
|
|
1006
|
+
function endInteraction(thumb, reason) {
|
|
1007
|
+
interactionReasons.value[thumb][reason] = false;
|
|
1008
|
+
if (!hasAnyInteraction()) sync();
|
|
1009
|
+
}
|
|
1010
|
+
function transferInteraction(from, to, reason) {
|
|
1011
|
+
if (!interactionReasons.value[from][reason]) return;
|
|
1012
|
+
interactionReasons.value[from][reason] = false;
|
|
1013
|
+
interactionReasons.value[to][reason] = true;
|
|
1014
|
+
}
|
|
1015
|
+
function onFocus(thumb) {
|
|
1016
|
+
startInteraction(thumb, "focus");
|
|
1017
|
+
}
|
|
1018
|
+
function onBlur(thumb) {
|
|
1019
|
+
endInteraction(thumb, "focus");
|
|
1020
|
+
}
|
|
1021
|
+
function onTrackMouseEnter() {
|
|
1022
|
+
const wasActive = hasAnyInteraction();
|
|
1023
|
+
const wasDismissed = dismissed.value;
|
|
1024
|
+
trackHovered.value = true;
|
|
1025
|
+
dismissed.value = false;
|
|
1026
|
+
if (!wasActive || wasDismissed) sync();
|
|
1027
|
+
}
|
|
1028
|
+
function onTrackMouseLeave() {
|
|
1029
|
+
trackHovered.value = false;
|
|
1030
|
+
if (!hasAnyInteraction()) sync();
|
|
1031
|
+
}
|
|
1032
|
+
function onKeydown(thumb, event) {
|
|
1033
|
+
options.setActiveThumb(thumb);
|
|
1034
|
+
if (event.key === "Escape") {
|
|
1035
|
+
dismissed.value = true;
|
|
1036
|
+
delayedTooltip.closeImmediate();
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
if (dismissed.value) {
|
|
1040
|
+
dismissed.value = false;
|
|
1041
|
+
sync();
|
|
1042
|
+
}
|
|
1043
|
+
return false;
|
|
1044
|
+
}
|
|
1045
|
+
const visible = computed(() => options.mode.value !== false);
|
|
1046
|
+
const alwaysVisible = computed(() => options.mode.value === "always");
|
|
1047
|
+
const open = computed(() => alwaysVisible.value || options.mode.value === "hover" && delayedTooltip.isOpen.value && hasAnyInteraction() && !dismissed.value && !options.disabled());
|
|
1048
|
+
watch([options.mode, options.disabled], sync);
|
|
1049
|
+
return {
|
|
1050
|
+
visible,
|
|
1051
|
+
alwaysVisible,
|
|
1052
|
+
open,
|
|
1053
|
+
startInteraction,
|
|
1054
|
+
endInteraction,
|
|
1055
|
+
transferInteraction,
|
|
1056
|
+
onFocus,
|
|
1057
|
+
onBlur,
|
|
1058
|
+
onTrackMouseEnter,
|
|
1059
|
+
onTrackMouseLeave,
|
|
1060
|
+
onKeydown
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
385
1063
|
//#endregion
|
|
386
1064
|
//#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
1065
|
function roundSliderNumber(value) {
|
|
394
1066
|
return Number(value.toFixed(10));
|
|
395
1067
|
}
|
|
@@ -438,94 +1110,30 @@ function getClosestRangeSliderThumb(value, range, activeThumb) {
|
|
|
438
1110
|
if (upperDistance < lowerDistance) return "upper";
|
|
439
1111
|
return activeThumb ?? "upper";
|
|
440
1112
|
}
|
|
441
|
-
function
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
-
};
|
|
1113
|
+
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
1114
|
+
const [lowerPercent, upperPercent] = valuePercent;
|
|
1115
|
+
const style = {
|
|
1116
|
+
"--_rp-range-slider-lower-percent": `${lowerPercent}%`,
|
|
1117
|
+
"--_rp-range-slider-upper-percent": `${upperPercent}%`,
|
|
1118
|
+
"--_rp-range-slider-lower-ratio": `${lowerPercent / 100}`,
|
|
1119
|
+
"--_rp-range-slider-upper-ratio": `${upperPercent / 100}`,
|
|
1120
|
+
"--_rp-range-slider-tooltip-merged-percent": `${(lowerPercent + upperPercent) / 2}%`
|
|
1121
|
+
};
|
|
1122
|
+
setSliderStyleValue(style, "--_rp-range-slider-color", getComponentColorValue(props.color));
|
|
1123
|
+
applySliderThumbStyle(style, props.thumbStyle, {
|
|
1124
|
+
size: "--rp-slider-thumb-size",
|
|
1125
|
+
border: "--_rp-range-slider-thumb-border-style",
|
|
1126
|
+
padding: "--rp-slider-thumb-padding",
|
|
1127
|
+
borderColor: "--_rp-range-slider-thumb-border"
|
|
508
1128
|
});
|
|
1129
|
+
return style;
|
|
509
1130
|
}
|
|
510
1131
|
function getFormattedRangeSliderValue(value, formatter) {
|
|
511
|
-
return
|
|
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));
|
|
1132
|
+
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
517
1133
|
}
|
|
518
1134
|
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
519
1135
|
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
520
|
-
return [
|
|
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;
|
|
1136
|
+
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
529
1137
|
}
|
|
530
1138
|
function getThumbIndex(thumb) {
|
|
531
1139
|
return thumb === "lower" ? 0 : 1;
|
|
@@ -570,31 +1178,31 @@ function useRangeSlider(props, emitUpdate) {
|
|
|
570
1178
|
if (normalizedMinRange.value === 0) return [bounds.value.max, bounds.value.max];
|
|
571
1179
|
return [clamp(getStepValueAtOrBelow(normalizedValue.value[1] - normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max), bounds.value.max];
|
|
572
1180
|
});
|
|
573
|
-
const markItems = computed(() =>
|
|
1181
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1182
|
+
position: "--_rp-range-slider-mark-position",
|
|
1183
|
+
colors: [
|
|
1184
|
+
"--_rp-range-slider-mark-color",
|
|
1185
|
+
"--_rp-range-slider-mark-label-color",
|
|
1186
|
+
"--_rp-range-slider-mark-filled-label-color",
|
|
1187
|
+
"--_rp-range-slider-mark-ring-color"
|
|
1188
|
+
]
|
|
1189
|
+
}));
|
|
574
1190
|
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
575
1191
|
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valuePercent.value));
|
|
576
|
-
const tooltipOptions = computed(() =>
|
|
577
|
-
const tooltipMode = computed(() =>
|
|
1192
|
+
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
1193
|
+
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
578
1194
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
focus: false,
|
|
586
|
-
drag: false
|
|
587
|
-
},
|
|
588
|
-
upper: {
|
|
589
|
-
focus: false,
|
|
590
|
-
drag: false
|
|
1195
|
+
const tooltipState = useRangeSliderTooltipState({
|
|
1196
|
+
mode: tooltipMode,
|
|
1197
|
+
openDelay: tooltipOpenDelay,
|
|
1198
|
+
disabled: () => control.disabled,
|
|
1199
|
+
setActiveThumb: (thumb) => {
|
|
1200
|
+
activeThumb.value = thumb;
|
|
591
1201
|
}
|
|
592
1202
|
});
|
|
593
|
-
const
|
|
594
|
-
const
|
|
595
|
-
const
|
|
596
|
-
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
597
|
-
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltip.isOpen.value && hasAnyTooltipInteractionReason() && !tooltipDismissed.value && !control.disabled);
|
|
1203
|
+
const tooltipVisible = tooltipState.visible;
|
|
1204
|
+
const tooltipAlwaysVisible = tooltipState.alwaysVisible;
|
|
1205
|
+
const tooltipOpen = tooltipState.open;
|
|
598
1206
|
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (props.orientation === "vertical" ? "left" : "top"));
|
|
599
1207
|
const tooltipIds = computed(() => {
|
|
600
1208
|
const baseId = tooltipOptions.value.id;
|
|
@@ -608,16 +1216,17 @@ function useRangeSlider(props, emitUpdate) {
|
|
|
608
1216
|
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
609
1217
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
610
1218
|
const tooltipContent = computed(() => [String(formattedValue.value[0]), String(formattedValue.value[1])]);
|
|
611
|
-
const mergedTooltipContent = computed(() =>
|
|
1219
|
+
const mergedTooltipContent = computed(() => {
|
|
1220
|
+
const [lower, upper] = tooltipContent.value;
|
|
1221
|
+
return lower === upper ? lower : `${lower}–${upper}`;
|
|
1222
|
+
});
|
|
612
1223
|
const rootClass = computed(() => bem("rp-range-slider", {
|
|
613
1224
|
[`size-${props.size}`]: Boolean(props.size),
|
|
614
1225
|
vertical: props.orientation === "vertical",
|
|
615
1226
|
marked: markItems.value.length > 0,
|
|
616
1227
|
"marks-with-labels": hasMarkLabels.value,
|
|
617
1228
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
618
|
-
disabled: control.disabled
|
|
619
|
-
invalid: control.invalid,
|
|
620
|
-
valid: control.valid && !control.invalid
|
|
1229
|
+
disabled: control.disabled
|
|
621
1230
|
}));
|
|
622
1231
|
function getThumbUpdate(thumb, value, anchorValue = normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))]) {
|
|
623
1232
|
const safeValue = normalizeSliderValue(value, bounds.value.min, bounds.value.max, valueStep.value);
|
|
@@ -653,101 +1262,17 @@ function useRangeSlider(props, emitUpdate) {
|
|
|
653
1262
|
const input = event.target;
|
|
654
1263
|
transferFocusedThumb(input, thumb, updateThumb(thumb, input.valueAsNumber));
|
|
655
1264
|
}
|
|
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
1265
|
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
683
1266
|
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
684
1267
|
const track = input.closest(".rp-range-slider__track");
|
|
685
1268
|
if (!track) return;
|
|
686
1269
|
const nextInput = getThumbInput(track, nextThumb);
|
|
687
1270
|
if (!nextInput) return;
|
|
688
|
-
|
|
689
|
-
if (currentReasons.focus) {
|
|
690
|
-
currentReasons.focus = false;
|
|
691
|
-
tooltipInteractionReasons.value[nextThumb].focus = true;
|
|
692
|
-
}
|
|
1271
|
+
tooltipState.transferInteraction(thumb, nextThumb, "focus");
|
|
693
1272
|
nextInput.focus({ preventScroll: true });
|
|
694
1273
|
}
|
|
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
1274
|
function onTooltipKeydown(thumb, event) {
|
|
745
|
-
|
|
746
|
-
if (event.key === "Escape") {
|
|
747
|
-
dismissTooltip();
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
resumeDismissedTooltip(thumb);
|
|
1275
|
+
if (tooltipState.onKeydown(thumb, event)) return;
|
|
751
1276
|
if (!hasManualNativeKeyboard.value || valueStep.value === "any") return;
|
|
752
1277
|
const index = getThumbIndex(thumb);
|
|
753
1278
|
const currentValue = normalizedValue.value[index];
|
|
@@ -780,88 +1305,42 @@ function useRangeSlider(props, emitUpdate) {
|
|
|
780
1305
|
const nextThumb = updateThumb(thumb, nextValue);
|
|
781
1306
|
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
782
1307
|
}
|
|
783
|
-
function
|
|
1308
|
+
function getPointerGeometry(track) {
|
|
784
1309
|
const vertical = props.orientation === "vertical";
|
|
785
|
-
const trackRect = track.getBoundingClientRect();
|
|
786
1310
|
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
787
|
-
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect :
|
|
1311
|
+
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
788
1312
|
const length = vertical ? rect.height : rect.width;
|
|
789
1313
|
if (length <= 0) return void 0;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
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();
|
|
1314
|
+
return {
|
|
1315
|
+
length,
|
|
1316
|
+
start: vertical ? rect.bottom : rect.left,
|
|
1317
|
+
vertical
|
|
1318
|
+
};
|
|
838
1319
|
}
|
|
839
|
-
function
|
|
840
|
-
|
|
841
|
-
const
|
|
842
|
-
|
|
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);
|
|
1320
|
+
function getValueFromPointer(event, geometry) {
|
|
1321
|
+
const pointerPosition = geometry.vertical ? event.clientY : event.clientX;
|
|
1322
|
+
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1323
|
+
return bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
860
1324
|
}
|
|
861
|
-
|
|
862
|
-
|
|
1325
|
+
const { onTrackPointerDown } = useRangeSliderPointer({
|
|
1326
|
+
disabled: () => control.disabled,
|
|
1327
|
+
getPointerGeometry,
|
|
1328
|
+
getPointerValue: getValueFromPointer,
|
|
1329
|
+
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, normalizedValue.value, activeThumb.value),
|
|
1330
|
+
getAnchorValue: (thumb) => normalizedValue.value[getThumbIndex(getOppositeThumb(thumb))],
|
|
1331
|
+
setActiveThumb: (thumb) => {
|
|
1332
|
+
activeThumb.value = thumb;
|
|
1333
|
+
},
|
|
1334
|
+
focusThumb,
|
|
1335
|
+
updateThumb,
|
|
1336
|
+
transferFocusedThumb: (track, from, to) => {
|
|
1337
|
+
const input = getThumbInput(track, from);
|
|
1338
|
+
if (input) transferFocusedThumb(input, from, to);
|
|
1339
|
+
},
|
|
1340
|
+
startDrag: (thumb) => tooltipState.startInteraction(thumb, "drag"),
|
|
1341
|
+
endDrag: (thumb) => tooltipState.endInteraction(thumb, "drag"),
|
|
1342
|
+
transferDrag: (from, to) => tooltipState.transferInteraction(from, to, "drag")
|
|
863
1343
|
});
|
|
864
|
-
onBeforeUnmount(stopDragging);
|
|
865
1344
|
return {
|
|
866
1345
|
control,
|
|
867
1346
|
nativeMin,
|
|
@@ -891,326 +1370,29 @@ function useRangeSlider(props, emitUpdate) {
|
|
|
891
1370
|
mergedTooltipContent,
|
|
892
1371
|
onInput,
|
|
893
1372
|
onTrackPointerDown,
|
|
894
|
-
onTooltipFocus,
|
|
895
|
-
onTooltipBlur,
|
|
896
|
-
onTooltipTrackMouseEnter,
|
|
897
|
-
onTooltipTrackMouseLeave,
|
|
898
|
-
openTooltip,
|
|
899
|
-
closeTooltip,
|
|
1373
|
+
onTooltipFocus: tooltipState.onFocus,
|
|
1374
|
+
onTooltipBlur: tooltipState.onBlur,
|
|
1375
|
+
onTooltipTrackMouseEnter: tooltipState.onTrackMouseEnter,
|
|
1376
|
+
onTooltipTrackMouseLeave: tooltipState.onTrackMouseLeave,
|
|
900
1377
|
onTooltipKeydown
|
|
901
1378
|
};
|
|
902
1379
|
}
|
|
903
1380
|
//#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
1381
|
//#region src/components/slider/range-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1201
|
-
var t0 = template("<span data-v-
|
|
1202
|
-
var t1 = template("<span data-v-
|
|
1203
|
-
var t2 = template("<
|
|
1204
|
-
var t3 = template("<span data-v-
|
|
1205
|
-
var t4 = template("<span data-v-
|
|
1206
|
-
var t5 = template("<span data-v-
|
|
1207
|
-
var t6 = template("<span data-v-
|
|
1208
|
-
var t7 = template("<div data-v-
|
|
1209
|
-
delegateEvents("
|
|
1382
|
+
var t0 = template("<span data-v-c82ae6e8>");
|
|
1383
|
+
var t1 = template("<span data-v-c82ae6e8 class=rp-range-slider__header>");
|
|
1384
|
+
var t2 = template("<input data-v-c82ae6e8>");
|
|
1385
|
+
var t3 = template("<span data-v-c82ae6e8> ");
|
|
1386
|
+
var t4 = template("<span data-v-c82ae6e8><span data-v-c82ae6e8 class=rp-range-slider__mark-dot></span>");
|
|
1387
|
+
var t5 = template("<span data-v-c82ae6e8 class=rp-range-slider__marks aria-hidden=true>");
|
|
1388
|
+
var t6 = template("<span data-v-c82ae6e8><span data-v-c82ae6e8 class=rp-range-slider__thumb-content>");
|
|
1389
|
+
var t7 = template("<div data-v-c82ae6e8><span data-v-c82ae6e8><span data-v-c82ae6e8></span><!><span data-v-c82ae6e8 class=rp-range-slider__thumbs aria-hidden=true>", 1);
|
|
1390
|
+
delegateEvents("pointerdown");
|
|
1210
1391
|
//#endregion
|
|
1211
1392
|
//#region src/components/slider/range-slider.vue
|
|
1212
1393
|
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
1213
1394
|
name: "RpRangeSlider",
|
|
1395
|
+
inheritAttrs: false,
|
|
1214
1396
|
__name: "range-slider",
|
|
1215
1397
|
props: {
|
|
1216
1398
|
modelValue: {},
|
|
@@ -1218,6 +1400,7 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1218
1400
|
name: {},
|
|
1219
1401
|
ariaLabel: { default: () => ["Minimum", "Maximum"] },
|
|
1220
1402
|
ariaValueText: {},
|
|
1403
|
+
inputAttrs: {},
|
|
1221
1404
|
id: {},
|
|
1222
1405
|
min: { default: 0 },
|
|
1223
1406
|
max: { default: 100 },
|
|
@@ -1240,77 +1423,108 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1240
1423
|
type: Boolean,
|
|
1241
1424
|
default: void 0
|
|
1242
1425
|
},
|
|
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
1426
|
describedby: {},
|
|
1256
|
-
labelledby: {}
|
|
1427
|
+
labelledby: {},
|
|
1428
|
+
classNames: {},
|
|
1429
|
+
styles: {}
|
|
1257
1430
|
},
|
|
1258
1431
|
emits: ["update:modelValue"],
|
|
1259
|
-
setup(__props, { emit: __emit, slots: $slots }) {
|
|
1432
|
+
setup(__props, { expose: __expose, emit: __emit, slots: $slots }) {
|
|
1260
1433
|
const props = __props;
|
|
1261
1434
|
const emit = __emit;
|
|
1262
1435
|
const slots = useSlots();
|
|
1263
1436
|
const generatedId = useId();
|
|
1264
|
-
const
|
|
1437
|
+
const tooltipsOverlapping = ref(false);
|
|
1438
|
+
const rangeSliderThumbs = ["lower", "upper"];
|
|
1439
|
+
const lowerInputRef = ref(null);
|
|
1440
|
+
const upperInputRef = ref(null);
|
|
1265
1441
|
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,
|
|
1442
|
+
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) => {
|
|
1267
1443
|
emit("update:modelValue", value);
|
|
1268
1444
|
});
|
|
1269
|
-
const {
|
|
1270
|
-
|
|
1445
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
1446
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
1447
|
+
class: [rootClass.value, {
|
|
1448
|
+
"rp-range-slider--custom-thumb": Boolean(slots.thumb),
|
|
1449
|
+
"rp-range-slider--tooltips-overlapping": tooltipsOverlapping.value
|
|
1450
|
+
}],
|
|
1451
|
+
style: trackStyle.value,
|
|
1452
|
+
role: "group",
|
|
1453
|
+
"data-active-thumb": activeThumb.value || void 0,
|
|
1454
|
+
"data-disabled": presence(control.disabled),
|
|
1455
|
+
"data-orientation": props.orientation,
|
|
1456
|
+
"aria-labelledby": groupLabelledby.value,
|
|
1457
|
+
"aria-describedby": control.ariaDescribedby
|
|
1458
|
+
}));
|
|
1459
|
+
const inputAttrsByThumb = computed(() => {
|
|
1460
|
+
if (Array.isArray(props.inputAttrs)) return props.inputAttrs;
|
|
1461
|
+
return [props.inputAttrs, props.inputAttrs];
|
|
1462
|
+
});
|
|
1463
|
+
const nativeInputAttrs = computed(() => rangeSliderThumbs.map((thumb, index) => {
|
|
1464
|
+
const { class: compatibilityClass, style: compatibilityStyle, onInput: compatibilityOnInput, onFocus: compatibilityOnFocus, onBlur: compatibilityOnBlur, onKeydown: compatibilityOnKeydown, ...attrs } = inputAttrsByThumb.value[index] ?? {};
|
|
1465
|
+
return Object.assign({}, attrs, {
|
|
1466
|
+
...getPartAttrs("input", {
|
|
1467
|
+
class: ["rp-range-slider__native", `rp-range-slider__native--${thumb}`],
|
|
1468
|
+
compatibilityClass,
|
|
1469
|
+
compatibilityStyle
|
|
1470
|
+
}),
|
|
1471
|
+
onInput(event) {
|
|
1472
|
+
onInput(thumb, event);
|
|
1473
|
+
compatibilityOnInput?.(event);
|
|
1474
|
+
},
|
|
1475
|
+
onFocus(event) {
|
|
1476
|
+
onTooltipFocus(thumb);
|
|
1477
|
+
compatibilityOnFocus?.(event);
|
|
1478
|
+
},
|
|
1479
|
+
onBlur(event) {
|
|
1480
|
+
onTooltipBlur(thumb);
|
|
1481
|
+
compatibilityOnBlur?.(event);
|
|
1482
|
+
},
|
|
1483
|
+
onKeydown(event) {
|
|
1484
|
+
onTooltipKeydown(thumb, event);
|
|
1485
|
+
compatibilityOnKeydown?.(event);
|
|
1486
|
+
}
|
|
1487
|
+
});
|
|
1488
|
+
}));
|
|
1489
|
+
const nativeElements = computed(() => [lowerInputRef.value, upperInputRef.value]);
|
|
1490
|
+
function setInputRef(index, element) {
|
|
1491
|
+
const input = element instanceof HTMLInputElement ? element : null;
|
|
1492
|
+
if (index === 0) lowerInputRef.value = input;
|
|
1493
|
+
else upperInputRef.value = input;
|
|
1494
|
+
}
|
|
1495
|
+
function focus(options) {
|
|
1496
|
+
lowerInputRef.value?.focus(options);
|
|
1497
|
+
}
|
|
1271
1498
|
const groupLabelledby = computed(() => {
|
|
1272
1499
|
const values = [control.ariaLabelledby, slots.default ? labelId.value : void 0].flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
1273
1500
|
return values.length ? Array.from(new Set(values)).join(" ") : void 0;
|
|
1274
1501
|
});
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
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);
|
|
1502
|
+
__expose({
|
|
1503
|
+
nativeElements,
|
|
1504
|
+
focus
|
|
1299
1505
|
});
|
|
1300
|
-
|
|
1506
|
+
const _setTemplateRef = createTemplateRefSetter();
|
|
1507
|
+
const n35 = t7();
|
|
1508
|
+
const n34 = child(n35, 1);
|
|
1509
|
+
const n11 = child(n34);
|
|
1510
|
+
const n33 = next(n11, 1);
|
|
1511
|
+
const n32 = next(n33, 3);
|
|
1512
|
+
renderEffect(() => setDynamicProps(n35, [rootAttrs.value]));
|
|
1513
|
+
setInsertionState(n35, 0, 0);
|
|
1301
1514
|
createIf(() => $slots.default || $slots.value, () => {
|
|
1302
|
-
const n10 =
|
|
1515
|
+
const n10 = t1();
|
|
1303
1516
|
setInsertionState(n10, null, 0);
|
|
1304
1517
|
createIf(() => $slots.default, () => {
|
|
1305
1518
|
const n5 = t0();
|
|
1306
|
-
renderEffect(() =>
|
|
1519
|
+
renderEffect(() => setDynamicProps(n5, [{ id: labelId.value }, unref(getPartAttrs)("label", { class: "rp-range-slider__label" })]));
|
|
1307
1520
|
setInsertionState(n5, null, 0);
|
|
1308
1521
|
createSlot("default", null, null, 1);
|
|
1309
1522
|
return n5;
|
|
1310
1523
|
});
|
|
1311
1524
|
setInsertionState(n10, null, 1);
|
|
1312
1525
|
createIf(() => $slots.value, () => {
|
|
1313
|
-
const n9 =
|
|
1526
|
+
const n9 = t0();
|
|
1527
|
+
renderEffect(() => setDynamicProps(n9, [unref(getPartAttrs)("value", { class: "rp-range-slider__value" }), { "aria-hidden": "true" }]));
|
|
1314
1528
|
setInsertionState(n9, null, 0);
|
|
1315
1529
|
createSlot("value", {
|
|
1316
1530
|
value: () => unref(normalizedValue),
|
|
@@ -1321,157 +1535,138 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1321
1535
|
});
|
|
1322
1536
|
return n10;
|
|
1323
1537
|
});
|
|
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
1538
|
renderEffect(() => {
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
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]);
|
|
1539
|
+
const _getPartAttrs = unref(getPartAttrs);
|
|
1540
|
+
setDynamicProps(n34, [_getPartAttrs("track", { class: "rp-range-slider__track" })]);
|
|
1541
|
+
setDynamicProps(n11, [_getPartAttrs("range", { class: "rp-range-slider__bar" }), { "aria-hidden": "true" }]);
|
|
1376
1542
|
});
|
|
1377
|
-
setInsertionState(
|
|
1543
|
+
setInsertionState(n34, n33, 1);
|
|
1544
|
+
createFor(() => rangeSliderThumbs, (_for_item0, _for_key0) => {
|
|
1545
|
+
const n14 = t2();
|
|
1546
|
+
renderEffect(() => {
|
|
1547
|
+
const _index = _for_key0.value;
|
|
1548
|
+
const _control = unref(control);
|
|
1549
|
+
setDynamicProps(n14, [nativeInputAttrs.value[_index], {
|
|
1550
|
+
id: unref(nativeIds)[_index],
|
|
1551
|
+
name: unref(nativeNames)[_index],
|
|
1552
|
+
type: "range",
|
|
1553
|
+
value: unref(normalizedValue)[_index],
|
|
1554
|
+
min: unref(nativeMin)[_index],
|
|
1555
|
+
max: unref(nativeMax)[_index],
|
|
1556
|
+
step: unref(nativeStep),
|
|
1557
|
+
orient: __props.orientation === "vertical" ? "vertical" : void 0,
|
|
1558
|
+
disabled: _control.disabled || void 0,
|
|
1559
|
+
"aria-label": unref(ariaLabels)[_index],
|
|
1560
|
+
"aria-describedby": _control.ariaDescribedby,
|
|
1561
|
+
"aria-orientation": __props.orientation === "vertical" ? "vertical" : void 0,
|
|
1562
|
+
"aria-valuetext": unref(ariaValueText)[_index],
|
|
1563
|
+
"data-thumb": _for_item0.value,
|
|
1564
|
+
"data-disabled": unref(presence)(_control.disabled)
|
|
1565
|
+
}]);
|
|
1566
|
+
_setTemplateRef(n14, (element) => setInputRef(_index, element), true);
|
|
1567
|
+
});
|
|
1568
|
+
return n14;
|
|
1569
|
+
}, (thumb, index) => thumb, 8);
|
|
1570
|
+
setInsertionState(n34, n33, 2);
|
|
1378
1571
|
createIf(() => unref(markItems).length, () => {
|
|
1379
|
-
const
|
|
1380
|
-
setInsertionState(
|
|
1572
|
+
const n23 = t5();
|
|
1573
|
+
setInsertionState(n23, null, 0);
|
|
1381
1574
|
createFor(() => unref(markItems), (_for_item0) => {
|
|
1382
|
-
const
|
|
1575
|
+
const n22 = t4();
|
|
1383
1576
|
renderEffect(() => {
|
|
1384
1577
|
const _mark = _for_item0.value;
|
|
1385
|
-
|
|
1386
|
-
|
|
1578
|
+
setDynamicProps(n22, [unref(getPartAttrs)("mark", {
|
|
1579
|
+
class: ["rp-range-slider__mark", { "rp-range-slider__mark--filled": _mark.filled }],
|
|
1580
|
+
style: _mark.style
|
|
1581
|
+
}), { "data-filled": unref(presence)(_mark.filled) }]);
|
|
1387
1582
|
});
|
|
1388
|
-
setInsertionState(
|
|
1583
|
+
setInsertionState(n22, null, 1);
|
|
1389
1584
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
1390
|
-
const
|
|
1391
|
-
const
|
|
1392
|
-
renderEffect(() =>
|
|
1393
|
-
|
|
1585
|
+
const n21 = t3();
|
|
1586
|
+
const x21 = txt(n21);
|
|
1587
|
+
renderEffect(() => {
|
|
1588
|
+
setDynamicProps(n21, [unref(getPartAttrs)("markLabel", { class: "rp-range-slider__mark-label" })]);
|
|
1589
|
+
setText(x21, toDisplayString(_for_item0.value.label));
|
|
1590
|
+
});
|
|
1591
|
+
return n21;
|
|
1394
1592
|
});
|
|
1395
|
-
return
|
|
1593
|
+
return n22;
|
|
1396
1594
|
}, (mark) => mark.key, 9);
|
|
1397
|
-
return
|
|
1595
|
+
return n23;
|
|
1398
1596
|
});
|
|
1399
|
-
setInsertionState(
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
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();
|
|
1597
|
+
setInsertionState(n32, null, 0);
|
|
1598
|
+
createFor(() => rangeSliderThumbs, (_for_item0, _for_key0) => {
|
|
1599
|
+
const n28 = t6();
|
|
1600
|
+
const n27 = child(n28);
|
|
1601
|
+
renderEffect(() => {
|
|
1602
|
+
const _thumb = _for_item0.value;
|
|
1603
|
+
setDynamicProps(n28, [unref(getPartAttrs)("thumb", { class: ["rp-range-slider__thumb", `rp-range-slider__thumb--${_thumb}`] }), {
|
|
1604
|
+
"data-range-slider-thumb": _thumb,
|
|
1605
|
+
"data-thumb": _thumb
|
|
1606
|
+
}]);
|
|
1422
1607
|
});
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1608
|
+
setInsertionState(n27, null, 0);
|
|
1609
|
+
createSlot("thumb", {
|
|
1610
|
+
thumb: () => _for_item0.value,
|
|
1611
|
+
index: () => _for_key0.value,
|
|
1612
|
+
value: () => unref(normalizedValue)[_for_key0.value],
|
|
1613
|
+
formattedValue: () => unref(formattedValue)[_for_key0.value],
|
|
1614
|
+
percent: () => unref(valuePercent)[_for_key0.value]
|
|
1615
|
+
}, null, 1);
|
|
1616
|
+
return n28;
|
|
1617
|
+
}, (thumb, index) => thumb, 8);
|
|
1618
|
+
setInsertionState(n32, null, 1);
|
|
1433
1619
|
createIf(() => unref(tooltipVisible), () => {
|
|
1434
|
-
|
|
1435
|
-
|
|
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),
|
|
1620
|
+
const _on_update_overlapping = ($event) => tooltipsOverlapping.value = $event;
|
|
1621
|
+
return createComponent(range_slider_tooltip_default, {
|
|
1443
1622
|
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
1623
|
color: () => unref(tooltipColor),
|
|
1624
|
+
content: () => unref(tooltipContent),
|
|
1625
|
+
ids: () => unref(tooltipIds),
|
|
1626
|
+
"merged-content": () => unref(mergedTooltipContent),
|
|
1627
|
+
"merged-id": () => unref(mergedTooltipId),
|
|
1457
1628
|
offset: () => unref(tooltipOffset),
|
|
1458
1629
|
open: () => unref(tooltipOpen),
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1630
|
+
orientation: () => __props.orientation,
|
|
1631
|
+
placement: () => unref(tooltipPlacement),
|
|
1632
|
+
"value-percent": () => unref(valuePercent),
|
|
1633
|
+
"tooltip-class": () => __props.classNames?.tooltip,
|
|
1634
|
+
"tooltip-style": () => __props.styles?.tooltip,
|
|
1635
|
+
"onUpdate:overlapping": () => _on_update_overlapping
|
|
1464
1636
|
});
|
|
1465
1637
|
});
|
|
1466
|
-
|
|
1467
|
-
on(
|
|
1468
|
-
on(
|
|
1469
|
-
|
|
1470
|
-
return n43;
|
|
1638
|
+
n34.$evtpointerdown = createInvoker((e) => unref(onTrackPointerDown)(e));
|
|
1639
|
+
on(n34, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1640
|
+
on(n34, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1641
|
+
return n35;
|
|
1471
1642
|
}
|
|
1472
|
-
}), [["__scopeId", "data-v-
|
|
1643
|
+
}), [["__scopeId", "data-v-c82ae6e8"]]);
|
|
1473
1644
|
//#endregion
|
|
1474
1645
|
//#region src/components/slider/types.ts
|
|
1646
|
+
var sliderParts = [
|
|
1647
|
+
"root",
|
|
1648
|
+
"label",
|
|
1649
|
+
"value",
|
|
1650
|
+
"track",
|
|
1651
|
+
"range",
|
|
1652
|
+
"input",
|
|
1653
|
+
"thumb",
|
|
1654
|
+
"mark",
|
|
1655
|
+
"markLabel",
|
|
1656
|
+
"tooltip"
|
|
1657
|
+
];
|
|
1658
|
+
var rangeSliderParts = [
|
|
1659
|
+
"root",
|
|
1660
|
+
"label",
|
|
1661
|
+
"value",
|
|
1662
|
+
"track",
|
|
1663
|
+
"range",
|
|
1664
|
+
"input",
|
|
1665
|
+
"thumb",
|
|
1666
|
+
"mark",
|
|
1667
|
+
"markLabel",
|
|
1668
|
+
"tooltip"
|
|
1669
|
+
];
|
|
1475
1670
|
var sliderColors = componentColors;
|
|
1476
1671
|
var sliderSizes = [
|
|
1477
1672
|
"xs",
|
|
@@ -1482,4 +1677,4 @@ var sliderSizes = [
|
|
|
1482
1677
|
];
|
|
1483
1678
|
var sliderOrientations = ["horizontal", "vertical"];
|
|
1484
1679
|
//#endregion
|
|
1485
|
-
export {
|
|
1680
|
+
export { sliderSizes as a, sliderParts as i, sliderColors as n, range_slider_default as o, sliderOrientations as r, slider_default as s, rangeSliderParts as t };
|