ropav 0.1.5 → 0.1.7
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 +10 -0
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +125 -154
- package/dist/alert.css +18 -18
- package/dist/alert.js +20 -20
- package/dist/aria.js +14 -0
- package/dist/aspect-ratio.js +1 -1
- package/dist/attributes.js +9 -0
- package/dist/attributes2.js +29 -0
- package/dist/avatar.css +19 -19
- package/dist/avatar.js +10 -18
- package/dist/badge.css +16 -16
- package/dist/badge.js +6 -6
- package/dist/base.css +18 -13
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +13 -14
- package/dist/button.css +32 -27
- package/dist/button.js +13 -14
- package/dist/{useButtonColor.js → button.scss_vue_type_style_index_0_src_true_lang.js} +3 -2
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +23 -29
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +8 -7
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +15 -14
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +222 -202
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +7 -9
- package/dist/color.js +5 -10
- package/dist/componentColors.js +165 -84
- package/dist/componentRef.js +26 -0
- package/dist/components/accordion/accordionContext.d.ts +3 -0
- package/dist/components/accordion/accordionModel.d.ts +14 -0
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/types.d.ts +1 -2
- package/dist/components/accordion/useAccordion.d.ts +2 -2
- package/dist/components/accordion/useAccordionItem.d.ts +2 -0
- package/dist/components/checkbox/useCheckbox.d.ts +2 -3
- package/dist/components/color-input/color-input.d.ts +2 -2
- package/dist/components/color-input/useColorInput.d.ts +1 -1
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +2 -2
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +22 -0
- package/dist/components/color-picker/useColorPickerSlider.d.ts +20 -0
- package/dist/components/color-picker/useColorPickerValue.d.ts +1 -1
- package/dist/components/dialog/{dialog-core.d.ts → dialogContext.d.ts} +2 -6
- package/dist/components/dialog/useDialogContentInteractions.d.ts +18 -0
- package/dist/components/dialog/useDialogRootState.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +3 -3
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -19
- package/dist/components/dropdown-menu/dropdownMenuDataModel.d.ts +20 -0
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionNavigation.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionRegistry.d.ts +42 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +85 -0
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -11
- package/dist/components/dropdown-menu/useDropdownMenuContextTrigger.d.ts +9 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +34 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +22 -0
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +6 -5
- package/dist/components/dropdown-menu/useDropdownMenuInteractionDismissal.d.ts +17 -0
- package/dist/components/dropdown-menu/useDropdownMenuInteractionKeyboard.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +0 -1
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +29 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +19 -0
- package/dist/components/floating/hoverDisclosureInteractionModel.d.ts +42 -0
- package/dist/components/floating/index.js +1 -1
- package/dist/components/floating/useFloatingPosition.d.ts +0 -1
- package/dist/components/floating/useHoverDisclosureInteractions.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosureOpenState.d.ts +25 -0
- package/dist/components/floating/useHoverDisclosureTargetBinding.d.ts +27 -0
- package/dist/components/input/useInput.d.ts +1 -1
- package/dist/components/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +4 -18
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/paginationModel.d.ts +4 -0
- package/dist/components/pagination/types.d.ts +15 -0
- package/dist/components/pagination/usePagination.d.ts +3 -19
- package/dist/components/popover/usePopoverBindings.d.ts +16 -0
- package/dist/components/progress/progressModel.d.ts +8 -0
- package/dist/components/progress/useProgress.d.ts +1 -7
- package/dist/components/radio/useRadio.d.ts +3 -4
- package/dist/components/scroll-area/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area/scrollAreaModel.d.ts +64 -0
- package/dist/components/scroll-area/types.d.ts +4 -0
- package/dist/components/scroll-area/useScrollArea.d.ts +70 -52
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -14
- package/dist/components/scroll-area/useScrollAreaDerivedState.d.ts +8 -0
- package/dist/components/scroll-area/useScrollAreaMeasurement.d.ts +35 -0
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +10 -8
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- package/dist/components/select/useSelect.d.ts +2 -1
- package/dist/components/select/useSelectNativeValue.d.ts +1 -7
- package/dist/components/slider/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +2 -2
- package/dist/components/slider/useRangeSlider.d.ts +9 -17
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +8 -14
- package/dist/components/slider/useSliderPointerPreview.d.ts +22 -0
- package/dist/components/slider/useSliderTooltipState.d.ts +40 -0
- package/dist/components/slider/useSliderValueState.d.ts +33 -0
- package/dist/components/switch/useSwitch.d.ts +1 -1
- package/dist/components/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/textarea/useTextarea.d.ts +1 -1
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/index.js +2 -0
- package/dist/composables/useControllableValue.d.ts +14 -0
- package/dist/css.js +12 -0
- package/dist/dialog.js +227 -216
- package/dist/dropdown-menu.js +1493 -1118
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/floating.js +553 -312
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/icon-button.css +12 -173
- package/dist/icon-button.js +8 -7
- package/dist/index.d.ts +5 -4
- package/dist/index.js +13 -11
- package/dist/input.css +24 -24
- package/dist/input.js +20 -32
- package/dist/interactive.js +18 -0
- package/dist/modal.js +11 -7
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +15 -13
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +67 -65
- package/dist/pointer.js +9 -0
- package/dist/popover.css +34 -34
- package/dist/popover.js +93 -91
- package/dist/progress.css +29 -21
- package/dist/progress.js +25 -21
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +31 -37
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +35 -26
- package/dist/scroll-area.js +553 -500
- package/dist/select.css +45 -45
- package/dist/select.js +70 -56
- package/dist/slider.css +191 -191
- package/dist/slider.js +695 -628
- package/dist/styles-api.d.ts +0 -1
- package/dist/styles-api.js +1 -4
- package/dist/switch.css +17 -17
- package/dist/switch.js +15 -16
- package/dist/tabs.css +46 -46
- package/dist/tabs.js +51 -68
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +22 -33
- package/dist/toast.css +26 -26
- package/dist/toast.js +157 -129
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +46 -47
- package/dist/useCollapse.js +19 -17
- package/dist/useControlState.js +4 -7
- package/dist/useControllableValue.js +8 -2
- package/dist/useFloatingPosition.js +122 -1128
- package/dist/useFormControl.js +3 -2
- package/dist/useOverlayZIndex.js +2 -6
- package/dist/useRequiredInject.js +1 -1
- package/dist/useTeleportTarget.js +3 -14
- package/dist/useTypeahead.js +94 -0
- package/dist/utils/aria.d.ts +3 -0
- package/dist/utils/attributes.d.ts +2 -0
- package/dist/utils/bem.d.ts +3 -0
- package/dist/utils/collectionNavigation.d.ts +2 -0
- package/dist/utils/color.d.ts +7 -0
- package/dist/{components/color-picker/color-picker-utils.d.ts → utils/colorPicker.d.ts} +5 -4
- package/dist/utils/componentColors.d.ts +7 -0
- package/dist/utils/css.d.ts +3 -0
- package/dist/utils/dom/ancestry.d.ts +7 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/pointer.d.ts +2 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +23 -0
- package/dist/utils/floatingOffset.d.ts +10 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/indexPath.d.ts +6 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/rafScheduler.d.ts +4 -0
- package/dist/utils/text.d.ts +2 -0
- package/docs/code-architecture.md +118 -0
- package/docs/public-composables-api.md +52 -0
- package/docs/public-floating-api.md +6 -5
- package/package.json +54 -46
- package/src/styles/_mixins.scss +4 -0
- package/src/styles/_tokens.scss +12 -12
- package/src/styles/_variables.scss +1 -1
- package/dist/button-link.css +0 -167
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +0 -3
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -21
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +0 -37
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +0 -29
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +0 -52
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +0 -17
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +0 -18
- package/dist/components/scroll-area/scrollAreaCore.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -35
- /package/dist/components/alert/{useAlertColor.d.ts → alertColor.d.ts} +0 -0
- /package/dist/components/avatar/{useAvatarColor.d.ts → avatarColor.d.ts} +0 -0
- /package/dist/components/badge/{useBadgeColor.d.ts → badgeColor.d.ts} +0 -0
- /package/dist/components/button/{useButtonColor.d.ts → buttonColor.d.ts} +0 -0
- /package/dist/components/color-swatch/{useColorSwatchColor.d.ts → colorSwatchColor.d.ts} +0 -0
- /package/dist/components/toast/{useToastColor.d.ts → toastColor.d.ts} +0 -0
- /package/dist/{composables → internal/composables}/useOverlayLayer.d.ts +0 -0
package/dist/slider.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import './slider.css';
|
|
2
|
+
import { t as useControllableValue } from "./useControllableValue.js";
|
|
3
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
4
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
2
5
|
import { t as bem } from "./bem.js";
|
|
3
|
-
import { n as useStylesApi, t as presence } from "./styles-api.js";
|
|
4
|
-
import { n as getComponentColorValue, t as componentColors } from "./componentColors.js";
|
|
5
6
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
6
|
-
import { t as
|
|
7
|
+
import { n as getValuePercent, t as clamp } from "./number.js";
|
|
8
|
+
import { i as getComponentColorValue, r as getComponentColorRoles, t as componentColors } from "./componentColors.js";
|
|
7
9
|
import { i as useFormControl } from "./useFormControl.js";
|
|
10
|
+
import { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
11
|
+
import { n as mergeAriaIdRefs } from "./aria.js";
|
|
8
12
|
import { t as useControlState } from "./useControlState.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
13
|
+
import { t as toCssLength } from "./css.js";
|
|
14
|
+
import { n as isMatchingPointer, t as getPointerId } from "./pointer.js";
|
|
15
|
+
import { t as createRafScheduler } from "./rafScheduler.js";
|
|
16
|
+
import { t as getFloatingOffsetStyle } from "./floatingOffset.js";
|
|
17
|
+
import { n as resolveTooltipColorStyleWithContrast, r as useDelayedOpen, t as tooltip_default } from "./tooltip.js";
|
|
18
|
+
import { applyVShow, child, computed, createComponent, createFor, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, extend, next, nextTick, on, onBeforeUnmount, onMounted, ref, renderEffect, setClass, setDynamicProps, setInsertionState, setProp, setStyle, setText, template, toDisplayString, toRef, txt, unref, useId, useSlots, watch } from "vue";
|
|
19
|
+
//#region src/components/slider/sliderModel.ts
|
|
12
20
|
function normalizeSliderBounds(min, max) {
|
|
13
21
|
const safeMin = Number.isFinite(min) ? min : 0;
|
|
14
22
|
const safeMax = Number.isFinite(max) ? max : safeMin;
|
|
@@ -26,25 +34,17 @@ function normalizeSliderStep(step) {
|
|
|
26
34
|
function normalizeSliderValue(value, min, max, step) {
|
|
27
35
|
const bounds = normalizeSliderBounds(min, max);
|
|
28
36
|
const safeStep = normalizeSliderStep(step);
|
|
29
|
-
const
|
|
30
|
-
const clamped = Math.min(bounds.max, Math.max(bounds.min, safeValue));
|
|
37
|
+
const clamped = clamp(Number.isFinite(value) ? value : bounds.min, bounds.min, bounds.max);
|
|
31
38
|
if (safeStep === "any") return clamped;
|
|
32
39
|
const steps = Math.round((clamped - bounds.min) / safeStep);
|
|
33
40
|
const snapped = bounds.min + steps * safeStep;
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
function getSliderValuePercent(value, min, max) {
|
|
37
|
-
if (!Number.isFinite(value) || max <= min) return 0;
|
|
38
|
-
const percent = (value - min) / (max - min) * 100;
|
|
39
|
-
return Math.min(100, Math.max(0, percent));
|
|
41
|
+
return clamp(Number(snapped.toFixed(10)), bounds.min, bounds.max);
|
|
40
42
|
}
|
|
41
43
|
function setSliderStyleValue(style, property, value) {
|
|
42
44
|
if (value) style[property] = value;
|
|
43
45
|
}
|
|
44
46
|
function getSliderLengthValue(value) {
|
|
45
|
-
|
|
46
|
-
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
47
|
-
return value;
|
|
47
|
+
return toCssLength(value);
|
|
48
48
|
}
|
|
49
49
|
function getSliderBorderValue(value, borderColorProperty) {
|
|
50
50
|
if (value == null || value === "") return void 0;
|
|
@@ -67,7 +67,9 @@ function getSliderThumbMode(thumb) {
|
|
|
67
67
|
function getSliderMarkStyle(percent, color, properties) {
|
|
68
68
|
const style = { [properties.position]: `${percent}%` };
|
|
69
69
|
const colorValue = getComponentColorValue(color);
|
|
70
|
-
|
|
70
|
+
const foreground = getComponentColorRoles(color)?.foreground;
|
|
71
|
+
for (const property of properties.decorativeColors) setSliderStyleValue(style, property, colorValue);
|
|
72
|
+
for (const property of properties.foregroundColors) setSliderStyleValue(style, property, foreground);
|
|
71
73
|
return style;
|
|
72
74
|
}
|
|
73
75
|
function createSliderMarkItems(marks, min, max, isFilled, properties) {
|
|
@@ -76,7 +78,7 @@ function createSliderMarkItems(marks, min, max, isFilled, properties) {
|
|
|
76
78
|
if (mark.hidden) return [];
|
|
77
79
|
const value = Number(mark.value);
|
|
78
80
|
if (!Number.isFinite(value)) return [];
|
|
79
|
-
const percent =
|
|
81
|
+
const percent = getValuePercent(value, min, max);
|
|
80
82
|
return {
|
|
81
83
|
key: `${value}-${index}`,
|
|
82
84
|
value,
|
|
@@ -110,258 +112,199 @@ function getSliderTooltipAnchor(tooltip) {
|
|
|
110
112
|
return typeof tooltip === "object" && tooltip.anchor === "pointer" ? "pointer" : "thumb";
|
|
111
113
|
}
|
|
112
114
|
//#endregion
|
|
113
|
-
//#region src/components/slider/
|
|
114
|
-
function
|
|
115
|
-
|
|
115
|
+
//#region src/components/slider/useSliderPointerPreview.ts
|
|
116
|
+
function getPreviewRect(track, vertical) {
|
|
117
|
+
const travelRect = track.querySelector(".rp-slider__travel")?.getBoundingClientRect();
|
|
118
|
+
if (travelRect && (vertical ? travelRect.height > 0 : travelRect.width > 0)) return travelRect;
|
|
119
|
+
return track.getBoundingClientRect();
|
|
116
120
|
}
|
|
117
|
-
function
|
|
118
|
-
const style = {
|
|
119
|
-
"--_rp-slider-percent": `${valuePercent}%`,
|
|
120
|
-
"--_rp-slider-ratio": `${valuePercent / 100}`,
|
|
121
|
-
"--_rp-slider-tooltip-percent": `${tooltipPercent}%`,
|
|
122
|
-
"--_rp-slider-tooltip-ratio": `${tooltipPercent / 100}`
|
|
123
|
-
};
|
|
124
|
-
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
125
|
-
applySliderThumbStyle(style, getSliderThumbOptions(props.thumb), {
|
|
126
|
-
size: "--rp-slider-thumb-size",
|
|
127
|
-
border: "--_rp-slider-thumb-border-style",
|
|
128
|
-
padding: "--rp-slider-thumb-padding",
|
|
129
|
-
borderColor: "--_rp-slider-thumb-border"
|
|
130
|
-
});
|
|
131
|
-
return style;
|
|
132
|
-
}
|
|
133
|
-
function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props.min) {
|
|
134
|
-
const control = useControlState(props);
|
|
135
|
-
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
136
|
-
const nativeStep = computed(() => normalizeSliderStep(props.step));
|
|
137
|
-
const normalizedValue = computed(() => normalizeSliderValue(getValue(), bounds.value.min, bounds.value.max, nativeStep.value));
|
|
138
|
-
const valuePercent = computed(() => getSliderValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
139
|
-
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
140
|
-
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
141
|
-
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
142
|
-
position: "--_rp-slider-mark-position",
|
|
143
|
-
colors: [
|
|
144
|
-
"--_rp-slider-mark-color",
|
|
145
|
-
"--_rp-slider-mark-label-color",
|
|
146
|
-
"--_rp-slider-mark-filled-label-color",
|
|
147
|
-
"--_rp-slider-mark-ring-color"
|
|
148
|
-
]
|
|
149
|
-
}));
|
|
150
|
-
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
151
|
-
const tooltipAnchor = computed(() => getSliderTooltipAnchor(props.tooltip));
|
|
152
|
-
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
153
|
-
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
154
|
-
const { isOpen: delayedTooltipOpen, open: openDelayedTooltip, closeImmediate: closeDelayedTooltip } = useDelayedOpen({
|
|
155
|
-
openDelay: () => tooltipOpenDelay.value,
|
|
156
|
-
disabled: () => tooltipMode.value !== "hover" || control.disabled
|
|
157
|
-
});
|
|
158
|
-
const trackHovered = ref(false);
|
|
159
|
-
const focusWithin = ref(false);
|
|
121
|
+
function useSliderPointerPreview(options) {
|
|
160
122
|
const dragging = ref(false);
|
|
161
123
|
const previewAvailable = ref(false);
|
|
162
|
-
const previewValue = ref(
|
|
163
|
-
let dismissed = false;
|
|
124
|
+
const previewValue = ref(options.initialValue);
|
|
164
125
|
let dragView = null;
|
|
165
126
|
let dragPointerId;
|
|
166
127
|
let dragTrack = null;
|
|
167
|
-
let previewFrameView = null;
|
|
168
|
-
let previewFrameId;
|
|
169
128
|
let pendingPreview;
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
percent: valuePercent.value,
|
|
176
|
-
min: bounds.value.min,
|
|
177
|
-
max: bounds.value.max,
|
|
178
|
-
orientation: props.orientation,
|
|
179
|
-
getPercent(value) {
|
|
180
|
-
return getSliderValuePercent(value, bounds.value.min, bounds.value.max);
|
|
181
|
-
}
|
|
182
|
-
}));
|
|
183
|
-
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
184
|
-
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
185
|
-
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltipOpen.value && !control.disabled);
|
|
186
|
-
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (props.orientation === "vertical" ? "left" : "top"));
|
|
187
|
-
const tooltipId = computed(() => tooltipOptions.value.id);
|
|
188
|
-
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
189
|
-
const tooltipAutoContrast = computed(() => tooltipOptions.value.autoContrast);
|
|
190
|
-
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
191
|
-
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
192
|
-
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
193
|
-
const tooltipValue = computed(() => tooltipAnchor.value === "pointer" && previewAvailable.value ? previewValue.value : normalizedValue.value);
|
|
194
|
-
const tooltipPercent = computed(() => getSliderValuePercent(tooltipValue.value, bounds.value.min, bounds.value.max));
|
|
195
|
-
const tooltipFormattedValue = computed(() => getFormattedSliderValue(tooltipValue.value, props.formatValue));
|
|
196
|
-
const tooltipContent = computed(() => String(tooltipFormattedValue.value));
|
|
197
|
-
const rootClass = computed(() => bem("rp-slider", {
|
|
198
|
-
[`size-${props.size}`]: Boolean(props.size),
|
|
199
|
-
vertical: props.orientation === "vertical",
|
|
200
|
-
marked: markItems.value.length > 0,
|
|
201
|
-
"marks-with-labels": hasMarkLabels.value,
|
|
202
|
-
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
203
|
-
"thumb-interaction": thumbMode.value === "interaction",
|
|
204
|
-
"thumb-hidden": thumbMode.value === false,
|
|
205
|
-
disabled: control.disabled,
|
|
206
|
-
invalid: control.invalid
|
|
207
|
-
}));
|
|
208
|
-
const trackStyle = computed(() => getSliderTrackStyle(props, valuePercent.value, tooltipPercent.value));
|
|
209
|
-
function onInput(e) {
|
|
210
|
-
if (control.disabled) return;
|
|
211
|
-
const input = e.target;
|
|
212
|
-
emitUpdate(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
213
|
-
}
|
|
214
|
-
function hasTooltipInteraction() {
|
|
215
|
-
if (tooltipAnchor.value === "pointer") return previewAvailable.value && (trackHovered.value || dragging.value);
|
|
216
|
-
return trackHovered.value || focusWithin.value || dragging.value;
|
|
217
|
-
}
|
|
218
|
-
function syncTooltip() {
|
|
219
|
-
if (tooltipMode.value === "hover" && !control.disabled && hasTooltipInteraction() && !dismissed) {
|
|
220
|
-
openDelayedTooltip();
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
closeDelayedTooltip();
|
|
224
|
-
}
|
|
225
|
-
function onTooltipTrackEnter(event) {
|
|
226
|
-
if (control.disabled) return;
|
|
227
|
-
if (tooltipAnchor.value === "pointer") {
|
|
228
|
-
cancelScheduledPreview();
|
|
229
|
-
previewAvailable.value = false;
|
|
230
|
-
const track = event.currentTarget;
|
|
231
|
-
if (track) updatePreviewFromPointer(event, track);
|
|
232
|
-
}
|
|
233
|
-
trackHovered.value = true;
|
|
234
|
-
dismissed = false;
|
|
235
|
-
syncTooltip();
|
|
236
|
-
}
|
|
237
|
-
function onTooltipTrackLeave() {
|
|
238
|
-
trackHovered.value = false;
|
|
239
|
-
if (!dragging.value && tooltipAnchor.value === "pointer") cancelScheduledPreview();
|
|
240
|
-
syncTooltip();
|
|
241
|
-
}
|
|
242
|
-
function onTooltipFocusIn() {
|
|
243
|
-
focusWithin.value = true;
|
|
244
|
-
dismissed = false;
|
|
245
|
-
syncTooltip();
|
|
246
|
-
}
|
|
247
|
-
function onTooltipFocusOut() {
|
|
248
|
-
focusWithin.value = false;
|
|
249
|
-
syncTooltip();
|
|
250
|
-
}
|
|
251
|
-
function removeDragListeners() {
|
|
252
|
-
dragView?.removeEventListener("pointermove", onTooltipWindowPointerMove);
|
|
253
|
-
dragView?.removeEventListener("pointerup", onTooltipPointerEnd);
|
|
254
|
-
dragView?.removeEventListener("pointercancel", onTooltipPointerEnd);
|
|
255
|
-
dragView = null;
|
|
256
|
-
dragPointerId = void 0;
|
|
257
|
-
dragTrack = null;
|
|
258
|
-
}
|
|
259
|
-
function cancelScheduledPreview() {
|
|
260
|
-
if (previewFrameId !== void 0) previewFrameView?.cancelAnimationFrame(previewFrameId);
|
|
261
|
-
previewFrameView = null;
|
|
262
|
-
previewFrameId = void 0;
|
|
263
|
-
pendingPreview = void 0;
|
|
264
|
-
}
|
|
265
|
-
function updatePreviewFromPointer(pointer, track) {
|
|
266
|
-
if (tooltipAnchor.value !== "pointer" || control.disabled) return false;
|
|
267
|
-
const vertical = props.orientation === "vertical";
|
|
268
|
-
const travelRect = track.querySelector(".rp-slider__travel")?.getBoundingClientRect();
|
|
269
|
-
const trackRect = track.getBoundingClientRect();
|
|
270
|
-
const rect = travelRect && (vertical ? travelRect.height > 0 : travelRect.width > 0) ? travelRect : trackRect;
|
|
129
|
+
const previewScheduler = createRafScheduler(applyScheduledPreview, () => pendingPreview?.track.ownerDocument.defaultView);
|
|
130
|
+
function updateFromPointer(pointer, track) {
|
|
131
|
+
if (!options.enabled() || options.disabled()) return false;
|
|
132
|
+
const vertical = options.orientation() === "vertical";
|
|
133
|
+
const rect = getPreviewRect(track, vertical);
|
|
271
134
|
const length = vertical ? rect.height : rect.width;
|
|
272
135
|
if (length <= 0) return false;
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const rawValue = bounds.
|
|
276
|
-
previewValue.value = normalizeSliderValue(rawValue, bounds.
|
|
136
|
+
const ratio = clamp((vertical ? rect.bottom - pointer.clientY : pointer.clientX - rect.left) / length, 0, 1);
|
|
137
|
+
const bounds = options.bounds.value;
|
|
138
|
+
const rawValue = bounds.min + ratio * (bounds.max - bounds.min);
|
|
139
|
+
previewValue.value = normalizeSliderValue(rawValue, bounds.min, bounds.max, options.step.value);
|
|
277
140
|
previewAvailable.value = true;
|
|
278
141
|
return true;
|
|
279
142
|
}
|
|
280
143
|
function applyScheduledPreview() {
|
|
281
144
|
const pending = pendingPreview;
|
|
282
145
|
pendingPreview = void 0;
|
|
283
|
-
if (pending &&
|
|
284
|
-
}
|
|
285
|
-
function onPreviewAnimationFrame() {
|
|
286
|
-
previewFrameView = null;
|
|
287
|
-
previewFrameId = void 0;
|
|
288
|
-
applyScheduledPreview();
|
|
146
|
+
if (pending && updateFromPointer(pending, pending.track)) options.onStateChange();
|
|
289
147
|
}
|
|
290
148
|
function schedulePreview(event, track) {
|
|
291
|
-
if (
|
|
149
|
+
if (!options.enabled() || options.disabled()) return;
|
|
292
150
|
pendingPreview = {
|
|
293
151
|
clientX: event.clientX,
|
|
294
152
|
clientY: event.clientY,
|
|
295
153
|
track
|
|
296
154
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
155
|
+
previewScheduler.schedule();
|
|
156
|
+
}
|
|
157
|
+
function cancelScheduledPreview() {
|
|
158
|
+
previewScheduler.cancel();
|
|
159
|
+
pendingPreview = void 0;
|
|
160
|
+
}
|
|
161
|
+
function removeDragListeners() {
|
|
162
|
+
dragView?.removeEventListener("pointermove", onWindowPointerMove);
|
|
163
|
+
dragView?.removeEventListener("pointerup", onPointerEnd);
|
|
164
|
+
dragView?.removeEventListener("pointercancel", onPointerEnd);
|
|
165
|
+
dragView = null;
|
|
166
|
+
dragPointerId = void 0;
|
|
167
|
+
dragTrack = null;
|
|
305
168
|
}
|
|
306
|
-
function
|
|
307
|
-
if (
|
|
169
|
+
function onPointerMove(event) {
|
|
170
|
+
if (dragging.value && !isMatchingPointer(event, dragPointerId)) return;
|
|
308
171
|
const track = event.currentTarget;
|
|
309
172
|
if (track) schedulePreview(event, track);
|
|
310
173
|
}
|
|
311
|
-
function
|
|
312
|
-
if (
|
|
174
|
+
function onWindowPointerMove(event) {
|
|
175
|
+
if (!isMatchingPointer(event, dragPointerId)) return;
|
|
313
176
|
if (dragTrack) schedulePreview(event, dragTrack);
|
|
314
177
|
}
|
|
315
|
-
function
|
|
316
|
-
if (
|
|
178
|
+
function onPointerEnd(event) {
|
|
179
|
+
if (!isMatchingPointer(event, dragPointerId)) return;
|
|
317
180
|
cancelScheduledPreview();
|
|
318
|
-
if (dragTrack)
|
|
181
|
+
if (dragTrack) updateFromPointer(event, dragTrack);
|
|
319
182
|
dragging.value = false;
|
|
320
183
|
removeDragListeners();
|
|
321
|
-
|
|
184
|
+
options.onStateChange();
|
|
322
185
|
}
|
|
323
|
-
function
|
|
324
|
-
if (
|
|
186
|
+
function onPointerDown(event) {
|
|
187
|
+
if (options.disabled() || event.button !== 0 || event.isPrimary === false) return false;
|
|
325
188
|
removeDragListeners();
|
|
326
|
-
dismissed = false;
|
|
327
189
|
dragging.value = true;
|
|
328
|
-
dragPointerId =
|
|
190
|
+
dragPointerId = getPointerId(event);
|
|
329
191
|
dragTrack = event.currentTarget;
|
|
330
|
-
if (dragTrack)
|
|
192
|
+
if (dragTrack) updateFromPointer(event, dragTrack);
|
|
331
193
|
dragView = dragTrack?.ownerDocument.defaultView ?? null;
|
|
332
|
-
dragView?.addEventListener("pointermove",
|
|
333
|
-
dragView?.addEventListener("pointerup",
|
|
334
|
-
dragView?.addEventListener("pointercancel",
|
|
335
|
-
|
|
194
|
+
dragView?.addEventListener("pointermove", onWindowPointerMove);
|
|
195
|
+
dragView?.addEventListener("pointerup", onPointerEnd);
|
|
196
|
+
dragView?.addEventListener("pointercancel", onPointerEnd);
|
|
197
|
+
return true;
|
|
336
198
|
}
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
199
|
+
function onTrackEnter(event) {
|
|
200
|
+
if (!options.enabled()) return;
|
|
201
|
+
cancelScheduledPreview();
|
|
202
|
+
previewAvailable.value = false;
|
|
203
|
+
const track = event.currentTarget;
|
|
204
|
+
if (track) updateFromPointer(event, track);
|
|
205
|
+
}
|
|
206
|
+
function onTrackLeave() {
|
|
207
|
+
if (!dragging.value && options.enabled()) cancelScheduledPreview();
|
|
342
208
|
}
|
|
343
209
|
onBeforeUnmount(() => {
|
|
344
210
|
removeDragListeners();
|
|
345
211
|
cancelScheduledPreview();
|
|
346
212
|
});
|
|
347
213
|
return {
|
|
348
|
-
control,
|
|
349
|
-
nativeMin: computed(() => bounds.value.min),
|
|
350
|
-
nativeMax: computed(() => bounds.value.max),
|
|
351
|
-
nativeStep,
|
|
352
|
-
rootClass,
|
|
353
|
-
normalizedValue,
|
|
354
|
-
valuePercent,
|
|
355
|
-
formattedValue,
|
|
356
|
-
ariaValueText,
|
|
357
|
-
markItems,
|
|
358
|
-
thumbMode,
|
|
359
|
-
trackSlotProps,
|
|
360
|
-
trackStyle,
|
|
361
|
-
trackHovered,
|
|
362
214
|
dragging,
|
|
215
|
+
previewAvailable,
|
|
216
|
+
previewValue,
|
|
217
|
+
onPointerDown,
|
|
218
|
+
onPointerMove,
|
|
219
|
+
onTrackEnter,
|
|
220
|
+
onTrackLeave
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/components/slider/useSliderTooltipState.ts
|
|
225
|
+
function useSliderTooltipState(options) {
|
|
226
|
+
const tooltipOptions = computed(() => getSliderTooltipOptions(options.tooltip()));
|
|
227
|
+
const tooltipAnchor = computed(() => getSliderTooltipAnchor(options.tooltip()));
|
|
228
|
+
const tooltipMode = computed(() => getSliderTooltipMode(options.tooltip()));
|
|
229
|
+
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
230
|
+
const delayedTooltip = useDelayedOpen({
|
|
231
|
+
openDelay: () => tooltipOpenDelay.value,
|
|
232
|
+
disabled: () => tooltipMode.value !== "hover" || options.disabled()
|
|
233
|
+
});
|
|
234
|
+
const trackHovered = ref(false);
|
|
235
|
+
const focusWithin = ref(false);
|
|
236
|
+
let dismissed = false;
|
|
237
|
+
const pointerPreview = useSliderPointerPreview({
|
|
238
|
+
enabled: () => tooltipAnchor.value === "pointer",
|
|
239
|
+
disabled: options.disabled,
|
|
240
|
+
orientation: options.orientation,
|
|
241
|
+
bounds: options.bounds,
|
|
242
|
+
step: options.step,
|
|
243
|
+
initialValue: options.value.value,
|
|
244
|
+
onStateChange: syncTooltip
|
|
245
|
+
});
|
|
246
|
+
function hasTooltipInteraction() {
|
|
247
|
+
if (tooltipAnchor.value === "pointer") return pointerPreview.previewAvailable.value && (trackHovered.value || pointerPreview.dragging.value);
|
|
248
|
+
return trackHovered.value || focusWithin.value || pointerPreview.dragging.value;
|
|
249
|
+
}
|
|
250
|
+
function syncTooltip() {
|
|
251
|
+
if (tooltipMode.value === "hover" && !options.disabled() && hasTooltipInteraction() && !dismissed) {
|
|
252
|
+
delayedTooltip.open();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
delayedTooltip.closeImmediate();
|
|
256
|
+
}
|
|
257
|
+
function onTooltipTrackEnter(event) {
|
|
258
|
+
if (options.disabled()) return;
|
|
259
|
+
pointerPreview.onTrackEnter(event);
|
|
260
|
+
trackHovered.value = true;
|
|
261
|
+
dismissed = false;
|
|
262
|
+
syncTooltip();
|
|
263
|
+
}
|
|
264
|
+
function onTooltipTrackLeave() {
|
|
265
|
+
trackHovered.value = false;
|
|
266
|
+
pointerPreview.onTrackLeave();
|
|
267
|
+
syncTooltip();
|
|
268
|
+
}
|
|
269
|
+
function onTooltipFocusIn() {
|
|
270
|
+
focusWithin.value = true;
|
|
271
|
+
dismissed = false;
|
|
272
|
+
syncTooltip();
|
|
273
|
+
}
|
|
274
|
+
function onTooltipFocusOut() {
|
|
275
|
+
focusWithin.value = false;
|
|
276
|
+
syncTooltip();
|
|
277
|
+
}
|
|
278
|
+
function onTooltipPointerDown(event) {
|
|
279
|
+
if (!pointerPreview.onPointerDown(event)) return;
|
|
280
|
+
dismissed = false;
|
|
281
|
+
syncTooltip();
|
|
282
|
+
}
|
|
283
|
+
function onTooltipKeydown(event) {
|
|
284
|
+
if (event.key !== "Escape") return;
|
|
285
|
+
dismissed = true;
|
|
286
|
+
delayedTooltip.closeImmediate();
|
|
287
|
+
}
|
|
288
|
+
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
289
|
+
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
290
|
+
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltip.isOpen.value && !options.disabled());
|
|
291
|
+
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (options.orientation() === "vertical" ? "left" : "top"));
|
|
292
|
+
const tooltipId = computed(() => tooltipOptions.value.id);
|
|
293
|
+
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
294
|
+
const tooltipAutoContrast = computed(() => tooltipOptions.value.autoContrast);
|
|
295
|
+
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
296
|
+
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
297
|
+
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
298
|
+
const tooltipValue = computed(() => tooltipAnchor.value === "pointer" && pointerPreview.previewAvailable.value ? pointerPreview.previewValue.value : options.value.value);
|
|
299
|
+
const tooltipPercent = computed(() => getValuePercent(tooltipValue.value, options.bounds.value.min, options.bounds.value.max));
|
|
300
|
+
const tooltipFormattedValue = computed(() => getFormattedSliderValue(tooltipValue.value, options.formatValue()));
|
|
301
|
+
const tooltipContent = computed(() => String(tooltipFormattedValue.value));
|
|
302
|
+
return {
|
|
303
|
+
trackHovered,
|
|
304
|
+
dragging: pointerPreview.dragging,
|
|
363
305
|
tooltipVisible,
|
|
364
306
|
tooltipOpen,
|
|
307
|
+
tooltipAlwaysVisible,
|
|
365
308
|
tooltipAnchor,
|
|
366
309
|
tooltipPlacement,
|
|
367
310
|
tooltipId,
|
|
@@ -375,9 +318,8 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
375
318
|
tooltipPercent,
|
|
376
319
|
tooltipFormattedValue,
|
|
377
320
|
tooltipContent,
|
|
378
|
-
onInput,
|
|
379
321
|
onTooltipPointerDown,
|
|
380
|
-
onTooltipPointerMove,
|
|
322
|
+
onTooltipPointerMove: pointerPreview.onPointerMove,
|
|
381
323
|
onTooltipTrackEnter,
|
|
382
324
|
onTooltipTrackLeave,
|
|
383
325
|
onTooltipFocusIn,
|
|
@@ -386,19 +328,178 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
386
328
|
};
|
|
387
329
|
}
|
|
388
330
|
//#endregion
|
|
331
|
+
//#region src/components/slider/useSliderValueState.ts
|
|
332
|
+
function useSliderValueState(props, onChange) {
|
|
333
|
+
const inputRef = ref(null);
|
|
334
|
+
const controllable = useControllableValue({
|
|
335
|
+
modelValue: () => props.modelValue,
|
|
336
|
+
defaultValue: () => props.defaultValue ?? props.min,
|
|
337
|
+
onChange
|
|
338
|
+
});
|
|
339
|
+
const control = useControlState(props);
|
|
340
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
341
|
+
const nativeMin = computed(() => bounds.value.min);
|
|
342
|
+
const nativeMax = computed(() => bounds.value.max);
|
|
343
|
+
const nativeStep = computed(() => normalizeSliderStep(props.step));
|
|
344
|
+
const normalizedValue = computed(() => normalizeSliderValue(controllable.value.value, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
345
|
+
const valuePercent = computed(() => getValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
346
|
+
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
347
|
+
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
348
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
349
|
+
position: "--_rp-slider-mark-position",
|
|
350
|
+
decorativeColors: ["--_rp-slider-mark-color", "--_rp-slider-mark-ring-color"],
|
|
351
|
+
foregroundColors: ["--_rp-slider-mark-label-color", "--_rp-slider-mark-filled-label-color"]
|
|
352
|
+
}));
|
|
353
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
354
|
+
const trackSlotProps = computed(() => ({
|
|
355
|
+
value: normalizedValue.value,
|
|
356
|
+
formattedValue: formattedValue.value,
|
|
357
|
+
percent: valuePercent.value,
|
|
358
|
+
min: bounds.value.min,
|
|
359
|
+
max: bounds.value.max,
|
|
360
|
+
orientation: props.orientation,
|
|
361
|
+
getPercent(value) {
|
|
362
|
+
return getValuePercent(value, bounds.value.min, bounds.value.max);
|
|
363
|
+
}
|
|
364
|
+
}));
|
|
365
|
+
function onInput(event) {
|
|
366
|
+
if (control.disabled) return;
|
|
367
|
+
const input = event.target;
|
|
368
|
+
controllable.setValue(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
369
|
+
}
|
|
370
|
+
useFormControl({
|
|
371
|
+
elements: () => [inputRef.value],
|
|
372
|
+
isControlled: () => controllable.isControlled.value,
|
|
373
|
+
initializeDefault(element) {
|
|
374
|
+
element.defaultValue = String(normalizeSliderValue(controllable.initialValue, nativeMin.value, nativeMax.value, nativeStep.value));
|
|
375
|
+
},
|
|
376
|
+
validationMessage: () => props.validationMessage,
|
|
377
|
+
readResetValue(elements) {
|
|
378
|
+
controllable.resetValue(elements[0].valueAsNumber);
|
|
379
|
+
},
|
|
380
|
+
syncControlledValue(elements) {
|
|
381
|
+
elements[0].value = String(normalizedValue.value);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
function focus(options) {
|
|
385
|
+
inputRef.value?.focus(options);
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
inputRef,
|
|
389
|
+
focus,
|
|
390
|
+
control,
|
|
391
|
+
bounds,
|
|
392
|
+
nativeMin,
|
|
393
|
+
nativeMax,
|
|
394
|
+
nativeStep,
|
|
395
|
+
normalizedValue,
|
|
396
|
+
valuePercent,
|
|
397
|
+
formattedValue,
|
|
398
|
+
ariaValueText,
|
|
399
|
+
markItems,
|
|
400
|
+
hasMarkLabels,
|
|
401
|
+
trackSlotProps,
|
|
402
|
+
onInput
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/components/slider/useSlider.ts
|
|
407
|
+
function getSliderTrackStyle(props, valuePercent, tooltipPercent) {
|
|
408
|
+
const style = {
|
|
409
|
+
"--_rp-slider-percent": `${valuePercent}%`,
|
|
410
|
+
"--_rp-slider-ratio": `${valuePercent / 100}`,
|
|
411
|
+
"--_rp-slider-tooltip-percent": `${tooltipPercent}%`,
|
|
412
|
+
"--_rp-slider-tooltip-ratio": `${tooltipPercent / 100}`
|
|
413
|
+
};
|
|
414
|
+
setSliderStyleValue(style, "--_rp-slider-color", getComponentColorValue(props.color));
|
|
415
|
+
applySliderThumbStyle(style, getSliderThumbOptions(props.thumb), {
|
|
416
|
+
size: "--rp-slider-thumb-size",
|
|
417
|
+
border: "--_rp-slider-thumb-border-style",
|
|
418
|
+
padding: "--rp-slider-thumb-padding",
|
|
419
|
+
borderColor: "--_rp-slider-thumb-border"
|
|
420
|
+
});
|
|
421
|
+
return style;
|
|
422
|
+
}
|
|
423
|
+
function useSlider(props, onChange) {
|
|
424
|
+
const valueState = useSliderValueState(props, onChange);
|
|
425
|
+
const tooltipState = useSliderTooltipState({
|
|
426
|
+
tooltip: () => props.tooltip,
|
|
427
|
+
orientation: () => props.orientation,
|
|
428
|
+
disabled: () => valueState.control.disabled,
|
|
429
|
+
value: valueState.normalizedValue,
|
|
430
|
+
bounds: valueState.bounds,
|
|
431
|
+
step: valueState.nativeStep,
|
|
432
|
+
formatValue: () => props.formatValue
|
|
433
|
+
});
|
|
434
|
+
const thumbMode = computed(() => getSliderThumbMode(props.thumb));
|
|
435
|
+
const rootClass = computed(() => bem("rp-slider", {
|
|
436
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
437
|
+
vertical: props.orientation === "vertical",
|
|
438
|
+
marked: valueState.markItems.value.length > 0,
|
|
439
|
+
"marks-with-labels": valueState.hasMarkLabels.value,
|
|
440
|
+
"tooltip-always-visible": tooltipState.tooltipAlwaysVisible.value,
|
|
441
|
+
"thumb-interaction": thumbMode.value === "interaction",
|
|
442
|
+
"thumb-hidden": thumbMode.value === false,
|
|
443
|
+
disabled: valueState.control.disabled,
|
|
444
|
+
invalid: valueState.control.invalid
|
|
445
|
+
}));
|
|
446
|
+
const trackStyle = computed(() => getSliderTrackStyle(props, valueState.valuePercent.value, tooltipState.tooltipPercent.value));
|
|
447
|
+
return {
|
|
448
|
+
inputRef: valueState.inputRef,
|
|
449
|
+
focus: valueState.focus,
|
|
450
|
+
control: valueState.control,
|
|
451
|
+
nativeMin: valueState.nativeMin,
|
|
452
|
+
nativeMax: valueState.nativeMax,
|
|
453
|
+
nativeStep: valueState.nativeStep,
|
|
454
|
+
rootClass,
|
|
455
|
+
normalizedValue: valueState.normalizedValue,
|
|
456
|
+
valuePercent: valueState.valuePercent,
|
|
457
|
+
formattedValue: valueState.formattedValue,
|
|
458
|
+
ariaValueText: valueState.ariaValueText,
|
|
459
|
+
markItems: valueState.markItems,
|
|
460
|
+
thumbMode,
|
|
461
|
+
trackSlotProps: valueState.trackSlotProps,
|
|
462
|
+
trackStyle,
|
|
463
|
+
trackHovered: tooltipState.trackHovered,
|
|
464
|
+
dragging: tooltipState.dragging,
|
|
465
|
+
tooltipVisible: tooltipState.tooltipVisible,
|
|
466
|
+
tooltipOpen: tooltipState.tooltipOpen,
|
|
467
|
+
tooltipAnchor: tooltipState.tooltipAnchor,
|
|
468
|
+
tooltipPlacement: tooltipState.tooltipPlacement,
|
|
469
|
+
tooltipId: tooltipState.tooltipId,
|
|
470
|
+
tooltipColor: tooltipState.tooltipColor,
|
|
471
|
+
tooltipAutoContrast: tooltipState.tooltipAutoContrast,
|
|
472
|
+
tooltipContrastColor: tooltipState.tooltipContrastColor,
|
|
473
|
+
tooltipOffset: tooltipState.tooltipOffset,
|
|
474
|
+
tooltipOpenDelay: tooltipState.tooltipOpenDelay,
|
|
475
|
+
tooltipArrow: tooltipState.tooltipArrow,
|
|
476
|
+
tooltipValue: tooltipState.tooltipValue,
|
|
477
|
+
tooltipPercent: tooltipState.tooltipPercent,
|
|
478
|
+
tooltipFormattedValue: tooltipState.tooltipFormattedValue,
|
|
479
|
+
tooltipContent: tooltipState.tooltipContent,
|
|
480
|
+
onInput: valueState.onInput,
|
|
481
|
+
onTooltipPointerDown: tooltipState.onTooltipPointerDown,
|
|
482
|
+
onTooltipPointerMove: tooltipState.onTooltipPointerMove,
|
|
483
|
+
onTooltipTrackEnter: tooltipState.onTooltipTrackEnter,
|
|
484
|
+
onTooltipTrackLeave: tooltipState.onTooltipTrackLeave,
|
|
485
|
+
onTooltipFocusIn: tooltipState.onTooltipFocusIn,
|
|
486
|
+
onTooltipFocusOut: tooltipState.onTooltipFocusOut,
|
|
487
|
+
onTooltipKeydown: tooltipState.onTooltipKeydown
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
389
491
|
//#region src/components/slider/slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
390
|
-
var t0$2 = template("<span data-v-
|
|
391
|
-
var t1$2 = template("<span data-v-
|
|
392
|
-
var t2$2 = template("<span data-v-
|
|
393
|
-
var t3$2 = template("<span data-v-
|
|
394
|
-
var t4$2 = template("<span data-v-
|
|
395
|
-
var t5$1 = template("<span data-v-
|
|
396
|
-
var t6$1 = template("<span data-v-
|
|
397
|
-
var t7$1 = template("<span data-v-
|
|
398
|
-
var t8$1 = template("<span data-v-
|
|
492
|
+
var t0$2 = template("<span data-v-f21fa11c>");
|
|
493
|
+
var t1$2 = template("<span data-v-f21fa11c class=rp-slider__header>");
|
|
494
|
+
var t2$2 = template("<span data-v-f21fa11c class=\"rp-slider__track-layer rp-slider__track-underlay\"aria-hidden=true>");
|
|
495
|
+
var t3$2 = template("<span data-v-f21fa11c class=\"rp-slider__track-layer rp-slider__track-overlay\"aria-hidden=true>");
|
|
496
|
+
var t4$2 = template("<span data-v-f21fa11c class=rp-slider__travel aria-hidden=true>", 2);
|
|
497
|
+
var t5$1 = template("<span data-v-f21fa11c> ");
|
|
498
|
+
var t6$1 = template("<span data-v-f21fa11c><span data-v-f21fa11c class=rp-slider__mark-dot></span>");
|
|
499
|
+
var t7$1 = template("<span data-v-f21fa11c class=rp-slider__marks aria-hidden=true>");
|
|
500
|
+
var t8$1 = template("<span data-v-f21fa11c class=rp-slider__tooltip-anchor aria-hidden=true></span>", 2);
|
|
399
501
|
var t9$1 = template(" ");
|
|
400
|
-
var t10 = template("<label data-v-
|
|
401
|
-
delegateEvents("pointerdown", "pointermove", "focusin", "focusout", "keydown");
|
|
502
|
+
var t10 = template("<label data-v-f21fa11c><span data-v-f21fa11c><span data-v-f21fa11c class=rp-slider__rail aria-hidden=true></span><!><span data-v-f21fa11c></span><!><input data-v-f21fa11c><!><span data-v-f21fa11c><span data-v-f21fa11c class=rp-slider__thumb-content>", 1);
|
|
402
503
|
//#endregion
|
|
403
504
|
//#region src/components/slider/slider.vue
|
|
404
505
|
var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -461,36 +562,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
461
562
|
const slots = useSlots();
|
|
462
563
|
const props = __props;
|
|
463
564
|
const emit = __emit;
|
|
464
|
-
const inputRef =
|
|
465
|
-
const controllable = useControllableValue({
|
|
466
|
-
modelValue: () => props.modelValue,
|
|
467
|
-
defaultValue: () => props.defaultValue ?? props.min,
|
|
468
|
-
onChange: (value) => emit("update:modelValue", value)
|
|
469
|
-
});
|
|
470
|
-
const { control, nativeMin, nativeMax, nativeStep, rootClass, normalizedValue, valuePercent, formattedValue, ariaValueText, markItems, thumbMode, trackSlotProps, trackStyle, trackHovered, dragging, tooltipVisible, tooltipOpen, tooltipAnchor, tooltipPlacement, tooltipId, tooltipColor, tooltipAutoContrast, tooltipContrastColor, tooltipOffset, tooltipOpenDelay, tooltipArrow, tooltipValue, tooltipPercent, tooltipFormattedValue, tooltipContent, onInput, onTooltipPointerDown, onTooltipPointerMove, onTooltipTrackEnter, onTooltipTrackLeave, onTooltipFocusIn, onTooltipFocusOut, onTooltipKeydown } = useSlider(props, (value) => controllable.setValue(value), () => controllable.value.value);
|
|
471
|
-
useFormControl({
|
|
472
|
-
elements: () => [inputRef.value],
|
|
473
|
-
isControlled: () => controllable.isControlled.value,
|
|
474
|
-
initializeDefault(element) {
|
|
475
|
-
element.defaultValue = String(normalizeSliderValue(controllable.initialValue, nativeMin.value, nativeMax.value, nativeStep.value));
|
|
476
|
-
},
|
|
477
|
-
validationMessage: () => props.validationMessage,
|
|
478
|
-
readResetValue(elements) {
|
|
479
|
-
controllable.resetValue(elements[0].valueAsNumber);
|
|
480
|
-
},
|
|
481
|
-
syncControlledValue(elements) {
|
|
482
|
-
elements[0].value = String(normalizedValue.value);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
565
|
+
const { inputRef, focus, control, nativeMin, nativeMax, nativeStep, rootClass, normalizedValue, valuePercent, formattedValue, ariaValueText, markItems, thumbMode, trackSlotProps, trackStyle, trackHovered, dragging, tooltipVisible, tooltipOpen, tooltipAnchor, tooltipPlacement, tooltipId, tooltipColor, tooltipAutoContrast, tooltipContrastColor, tooltipOffset, tooltipOpenDelay, tooltipArrow, tooltipValue, tooltipPercent, tooltipFormattedValue, tooltipContent, onInput, onTooltipPointerDown, onTooltipPointerMove, onTooltipTrackEnter, onTooltipTrackLeave, onTooltipFocusIn, onTooltipFocusOut, onTooltipKeydown } = useSlider(props, (value) => emit("update:modelValue", value));
|
|
485
566
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
486
567
|
const rootAttrs = computed(() => getRootAttrs({
|
|
487
568
|
class: [rootClass.value, { "rp-slider--custom-thumb": Boolean(slots.thumb) }],
|
|
488
569
|
style: trackStyle.value,
|
|
489
|
-
"data-disabled":
|
|
490
|
-
"data-invalid":
|
|
570
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
571
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
491
572
|
"data-orientation": props.orientation,
|
|
492
|
-
"data-track-hovered":
|
|
493
|
-
"data-dragging":
|
|
573
|
+
"data-track-hovered": toPresenceAttribute(trackHovered.value),
|
|
574
|
+
"data-dragging": toPresenceAttribute(dragging.value),
|
|
494
575
|
"data-thumb-visibility": thumbMode.value === false ? "hidden" : thumbMode.value
|
|
495
576
|
}));
|
|
496
577
|
const tooltipClassNames = computed(() => ({
|
|
@@ -499,23 +580,18 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
499
580
|
}));
|
|
500
581
|
const tooltipStyles = computed(() => ({ root: props.styles?.tooltip }));
|
|
501
582
|
const nativeInputAttrs = computed(() => {
|
|
502
|
-
const
|
|
583
|
+
const inputAttrs = props.inputAttrs ?? {};
|
|
584
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
503
585
|
return {
|
|
504
|
-
...
|
|
586
|
+
...forwardedAttributes,
|
|
505
587
|
...getPartAttrs("input", {
|
|
506
588
|
class: "rp-slider__native",
|
|
507
589
|
compatibilityClass,
|
|
508
590
|
compatibilityStyle
|
|
509
591
|
}),
|
|
510
|
-
onInput(
|
|
511
|
-
onInput(event);
|
|
512
|
-
compatibilityOnInput?.(event);
|
|
513
|
-
}
|
|
592
|
+
onInput: composeEventHandlers(onInput, inputAttrs.onInput)
|
|
514
593
|
};
|
|
515
594
|
});
|
|
516
|
-
function focus(options) {
|
|
517
|
-
inputRef.value?.focus(options);
|
|
518
|
-
}
|
|
519
595
|
__expose({
|
|
520
596
|
nativeElement: inputRef,
|
|
521
597
|
focus
|
|
@@ -601,8 +677,8 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
601
677
|
"aria-valuetext": unref(ariaValueText),
|
|
602
678
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs["aria-invalid"] : _control.invalid || void 0,
|
|
603
679
|
"aria-required": _props_required_nativeInputAttrs_required,
|
|
604
|
-
"data-disabled": unref(
|
|
605
|
-
"data-invalid": unref(
|
|
680
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
681
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
606
682
|
}]);
|
|
607
683
|
});
|
|
608
684
|
setInsertionState(n45, n47, 6);
|
|
@@ -616,7 +692,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
616
692
|
setDynamicProps(n31, [unref(getPartAttrs)("mark", {
|
|
617
693
|
class: ["rp-slider__mark", { "rp-slider__mark--filled": _mark.filled }],
|
|
618
694
|
style: _mark.style
|
|
619
|
-
}), { "data-filled": unref(
|
|
695
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
620
696
|
});
|
|
621
697
|
setInsertionState(n31, null, 1);
|
|
622
698
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -673,16 +749,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
673
749
|
}
|
|
674
750
|
});
|
|
675
751
|
});
|
|
676
|
-
n45
|
|
752
|
+
on(n45, "pointerdown", (e) => unref(onTooltipPointerDown)(e));
|
|
677
753
|
on(n45, "pointerenter", (e) => unref(onTooltipTrackEnter)(e));
|
|
678
754
|
on(n45, "pointerleave", (e) => unref(onTooltipTrackLeave)(e));
|
|
679
|
-
n45
|
|
680
|
-
n45
|
|
681
|
-
n45
|
|
682
|
-
n45
|
|
755
|
+
on(n45, "pointermove", (e) => unref(onTooltipPointerMove)(e));
|
|
756
|
+
on(n45, "focusin", (e) => unref(onTooltipFocusIn)(e));
|
|
757
|
+
on(n45, "focusout", (e) => unref(onTooltipFocusOut)(e));
|
|
758
|
+
on(n45, "keydown", (e) => unref(onTooltipKeydown)(e));
|
|
683
759
|
return n48;
|
|
684
760
|
}
|
|
685
|
-
}), [["__scopeId", "data-v-
|
|
761
|
+
}), [["__scopeId", "data-v-f21fa11c"]]);
|
|
686
762
|
//#endregion
|
|
687
763
|
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
688
764
|
var TOOLTIP_COLLISION_GAP = 4;
|
|
@@ -747,8 +823,6 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
747
823
|
height: 0
|
|
748
824
|
});
|
|
749
825
|
let resizeObserver;
|
|
750
|
-
let frameWindow;
|
|
751
|
-
let frameId;
|
|
752
826
|
let destroyed = false;
|
|
753
827
|
function setOverlapping(value) {
|
|
754
828
|
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
@@ -786,19 +860,9 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
786
860
|
};
|
|
787
861
|
updateCollision();
|
|
788
862
|
}
|
|
863
|
+
const measureScheduler = createRafScheduler(measureSizes, () => root.value?.ownerDocument.defaultView);
|
|
789
864
|
function scheduleMeasure() {
|
|
790
|
-
if (destroyed
|
|
791
|
-
const view = root.value?.ownerDocument.defaultView;
|
|
792
|
-
if (!view?.requestAnimationFrame) {
|
|
793
|
-
measureSizes();
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
frameWindow = view;
|
|
797
|
-
frameId = view.requestAnimationFrame(() => {
|
|
798
|
-
frameId = void 0;
|
|
799
|
-
frameWindow = void 0;
|
|
800
|
-
measureSizes();
|
|
801
|
-
});
|
|
865
|
+
if (!destroyed) measureScheduler.schedule();
|
|
802
866
|
}
|
|
803
867
|
function refreshObservedElements() {
|
|
804
868
|
if (!resizeObserver) return;
|
|
@@ -864,7 +928,7 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
864
928
|
destroyed = true;
|
|
865
929
|
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
866
930
|
resizeObserver?.disconnect();
|
|
867
|
-
|
|
931
|
+
measureScheduler.cancel();
|
|
868
932
|
});
|
|
869
933
|
return {
|
|
870
934
|
tooltipsOverlapping,
|
|
@@ -874,11 +938,11 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
874
938
|
}
|
|
875
939
|
//#endregion
|
|
876
940
|
//#region src/components/slider/range-slider-tooltip.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
877
|
-
var t0$1 = template("<span data-v-
|
|
878
|
-
var t1$1 = template("<span data-v-
|
|
879
|
-
var t2$1 = template("<span data-v-
|
|
941
|
+
var t0$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-value> </span>");
|
|
942
|
+
var t1$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-value> ");
|
|
943
|
+
var t2$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-separator>–</span>", 2);
|
|
880
944
|
var t3$1 = template(" ");
|
|
881
|
-
var t4$1 = template("<span data-v-
|
|
945
|
+
var t4$1 = template("<span data-v-da6906b9 aria-hidden=true><span data-v-da6906b9 data-thumb=lower><span data-v-da6906b9 class=rp-range-slider__tooltip-anchor></span><span data-v-da6906b9 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-da6906b9 data-thumb=upper><span data-v-da6906b9 class=rp-range-slider__tooltip-anchor></span><span data-v-da6906b9 class=rp-tooltip__content aria-hidden=true> </span></span><span data-v-da6906b9 data-thumb=merged><span data-v-da6906b9 class=rp-range-slider__tooltip-anchor></span><span data-v-da6906b9 class=rp-tooltip__content aria-hidden=true>", 1);
|
|
882
946
|
//#endregion
|
|
883
947
|
//#region src/components/slider/range-slider-tooltip.vue
|
|
884
948
|
var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -921,6 +985,10 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
921
985
|
},
|
|
922
986
|
emits: ["update:overlapping"],
|
|
923
987
|
setup(__props, { emit: __emit }) {
|
|
988
|
+
const TOOLTIP_OFFSET_PROPERTIES = {
|
|
989
|
+
mainAxis: "--_rp-tooltip-main-axis-offset",
|
|
990
|
+
crossAxis: "--_rp-tooltip-cross-axis-offset"
|
|
991
|
+
};
|
|
924
992
|
const props = __props;
|
|
925
993
|
const emit = __emit;
|
|
926
994
|
const generatedId = useId();
|
|
@@ -935,7 +1003,7 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
935
1003
|
open: props.open
|
|
936
1004
|
}));
|
|
937
1005
|
const contentStyle = computed(() => ({
|
|
938
|
-
...
|
|
1006
|
+
...getFloatingOffsetStyle(props.offset, TOOLTIP_OFFSET_PROPERTIES),
|
|
939
1007
|
...resolveTooltipColorStyleWithContrast(props.color, props.autoContrast, props.contrastColor)
|
|
940
1008
|
}));
|
|
941
1009
|
const { tooltipsOverlapping, mergedArrowOffset, mergedMinSize } = useRangeSliderTooltipCollision({
|
|
@@ -1053,20 +1121,128 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
1053
1121
|
_setTemplateRef(n16, tooltipLayerRef, null, "tooltipLayerRef");
|
|
1054
1122
|
return n16;
|
|
1055
1123
|
}
|
|
1056
|
-
}), [["__scopeId", "data-v-
|
|
1124
|
+
}), [["__scopeId", "data-v-da6906b9"]]);
|
|
1125
|
+
//#endregion
|
|
1126
|
+
//#region src/components/slider/rangeSliderModel.ts
|
|
1127
|
+
function roundSliderNumber(value) {
|
|
1128
|
+
return Number(value.toFixed(10));
|
|
1129
|
+
}
|
|
1130
|
+
function getStepValueAtOrAbove(value, min, step) {
|
|
1131
|
+
if (step === "any") return value;
|
|
1132
|
+
return roundSliderNumber(min + Math.ceil((value - min) / step - 1e-10) * step);
|
|
1133
|
+
}
|
|
1134
|
+
function getStepValueAtOrBelow(value, min, step) {
|
|
1135
|
+
if (step === "any") return value;
|
|
1136
|
+
return roundSliderNumber(min + Math.floor((value - min) / step + 1e-10) * step);
|
|
1137
|
+
}
|
|
1138
|
+
function isSliderStepAligned(min, max, step) {
|
|
1139
|
+
const stepCount = (max - min) / step;
|
|
1140
|
+
return Math.abs(stepCount - Math.round(stepCount)) <= 1e-10;
|
|
1141
|
+
}
|
|
1142
|
+
function normalizeRangeSliderMinRange(minRange, min, max) {
|
|
1143
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1144
|
+
const domain = bounds.max - bounds.min;
|
|
1145
|
+
return Math.min(domain, Number.isFinite(minRange) && minRange > 0 ? minRange : 0);
|
|
1146
|
+
}
|
|
1147
|
+
function normalizeRangeSliderValue(value, min, max, step, minRange = 0) {
|
|
1148
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1149
|
+
const safeStep = normalizeSliderStep(step);
|
|
1150
|
+
const safeMinRange = normalizeRangeSliderMinRange(minRange, bounds.min, bounds.max);
|
|
1151
|
+
const first = normalizeSliderValue(Array.isArray(value) ? Number(value[0]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1152
|
+
const second = normalizeSliderValue(Array.isArray(value) ? Number(value[1]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1153
|
+
const lower = Math.min(first, second);
|
|
1154
|
+
const upper = Math.max(first, second);
|
|
1155
|
+
if (upper - lower >= safeMinRange) return [lower, upper];
|
|
1156
|
+
if (safeMinRange >= bounds.max - bounds.min) return [bounds.min, bounds.max];
|
|
1157
|
+
const expandedUpper = getStepValueAtOrAbove(lower + safeMinRange, bounds.min, safeStep);
|
|
1158
|
+
if (expandedUpper <= bounds.max) return [lower, expandedUpper];
|
|
1159
|
+
const expandedLower = getStepValueAtOrBelow(bounds.max - safeMinRange, bounds.min, safeStep);
|
|
1160
|
+
return [Math.max(bounds.min, expandedLower), bounds.max];
|
|
1161
|
+
}
|
|
1162
|
+
function getClosestRangeSliderThumb(value, range, activeThumb) {
|
|
1163
|
+
const [lower, upper] = range;
|
|
1164
|
+
if (value < lower) return "lower";
|
|
1165
|
+
if (value > upper) return "upper";
|
|
1166
|
+
const lowerDistance = Math.abs(value - lower);
|
|
1167
|
+
const upperDistance = Math.abs(value - upper);
|
|
1168
|
+
if (lowerDistance < upperDistance) return "lower";
|
|
1169
|
+
if (upperDistance < lowerDistance) return "upper";
|
|
1170
|
+
return activeThumb ?? "upper";
|
|
1171
|
+
}
|
|
1172
|
+
function getRangeSliderNativeStep(bounds, step) {
|
|
1173
|
+
if (step === "any") return step;
|
|
1174
|
+
return isSliderStepAligned(bounds.min, bounds.max, step) ? step : "any";
|
|
1175
|
+
}
|
|
1176
|
+
function getRangeSliderNativeLimits(value, bounds, step, minRange) {
|
|
1177
|
+
if (minRange === 0) return {
|
|
1178
|
+
min: [bounds.min, bounds.min],
|
|
1179
|
+
max: [bounds.max, bounds.max]
|
|
1180
|
+
};
|
|
1181
|
+
return {
|
|
1182
|
+
min: [bounds.min, clamp(getStepValueAtOrAbove(value[0] + minRange, bounds.min, step), bounds.min, bounds.max)],
|
|
1183
|
+
max: [clamp(getStepValueAtOrBelow(value[1] - minRange, bounds.min, step), bounds.min, bounds.max), bounds.max]
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
function getRangeSliderThumbUpdate({ thumb, value, currentValue, bounds, step, minRange, nativeMin, nativeMax, anchorValue = currentValue[getRangeSliderThumbIndex(getOppositeRangeSliderThumb(thumb))] }) {
|
|
1187
|
+
const safeValue = normalizeSliderValue(value, bounds.min, bounds.max, step);
|
|
1188
|
+
if (minRange > 0) {
|
|
1189
|
+
const nextValue = [...currentValue];
|
|
1190
|
+
nextValue[getRangeSliderThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax[0]) : Math.max(safeValue, nativeMin[1]);
|
|
1191
|
+
return {
|
|
1192
|
+
thumb,
|
|
1193
|
+
value: nextValue
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
if (safeValue < anchorValue) return {
|
|
1197
|
+
thumb: "lower",
|
|
1198
|
+
value: [safeValue, anchorValue]
|
|
1199
|
+
};
|
|
1200
|
+
if (safeValue > anchorValue) return {
|
|
1201
|
+
thumb: "upper",
|
|
1202
|
+
value: [anchorValue, safeValue]
|
|
1203
|
+
};
|
|
1204
|
+
return {
|
|
1205
|
+
thumb,
|
|
1206
|
+
value: [safeValue, safeValue]
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
function getFormattedRangeSliderValue(value, formatter) {
|
|
1210
|
+
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
1211
|
+
}
|
|
1212
|
+
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
1213
|
+
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
1214
|
+
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
1215
|
+
}
|
|
1216
|
+
function getRangeSliderThumbIndex(thumb) {
|
|
1217
|
+
return thumb === "lower" ? 0 : 1;
|
|
1218
|
+
}
|
|
1219
|
+
function getOppositeRangeSliderThumb(thumb) {
|
|
1220
|
+
return thumb === "lower" ? "upper" : "lower";
|
|
1221
|
+
}
|
|
1222
|
+
function getRangeSliderKeyboardValue(key, currentValue, step, min, max) {
|
|
1223
|
+
switch (key) {
|
|
1224
|
+
case "ArrowRight":
|
|
1225
|
+
case "ArrowUp": return currentValue + step;
|
|
1226
|
+
case "ArrowLeft":
|
|
1227
|
+
case "ArrowDown": return currentValue - step;
|
|
1228
|
+
case "PageUp": return currentValue + step * 10;
|
|
1229
|
+
case "PageDown": return currentValue - step * 10;
|
|
1230
|
+
case "Home": return min;
|
|
1231
|
+
case "End": return max;
|
|
1232
|
+
default: return;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
function getRangeSliderPointerValue(pointer, geometry, bounds) {
|
|
1236
|
+
const pointerPosition = geometry.vertical ? pointer.clientY : pointer.clientX;
|
|
1237
|
+
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1238
|
+
return bounds.min + ratio * (bounds.max - bounds.min);
|
|
1239
|
+
}
|
|
1057
1240
|
//#endregion
|
|
1058
1241
|
//#region src/components/slider/useRangeSliderPointer.ts
|
|
1059
1242
|
function useRangeSliderPointer(options) {
|
|
1060
1243
|
let session;
|
|
1061
|
-
let frameWindow = null;
|
|
1062
|
-
let frameId;
|
|
1063
1244
|
let pendingPointerEvent;
|
|
1064
1245
|
let geometryDirty = false;
|
|
1065
|
-
function cancelScheduledFrame() {
|
|
1066
|
-
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
1067
|
-
frameWindow = null;
|
|
1068
|
-
frameId = void 0;
|
|
1069
|
-
}
|
|
1070
1246
|
function refreshGeometry() {
|
|
1071
1247
|
const currentSession = session;
|
|
1072
1248
|
if (!currentSession) return false;
|
|
@@ -1083,24 +1259,13 @@ function useRangeSliderPointer(options) {
|
|
|
1083
1259
|
pendingPointerEvent = void 0;
|
|
1084
1260
|
if (event && isCurrentPointer(event)) updateFromPointer(event);
|
|
1085
1261
|
}
|
|
1262
|
+
const updateScheduler = createRafScheduler(applyScheduledUpdate, () => session?.view);
|
|
1086
1263
|
function flushScheduledUpdate() {
|
|
1087
|
-
|
|
1088
|
-
applyScheduledUpdate();
|
|
1089
|
-
}
|
|
1090
|
-
function onAnimationFrame() {
|
|
1091
|
-
frameWindow = null;
|
|
1092
|
-
frameId = void 0;
|
|
1264
|
+
updateScheduler.cancel();
|
|
1093
1265
|
applyScheduledUpdate();
|
|
1094
1266
|
}
|
|
1095
1267
|
function scheduleUpdate() {
|
|
1096
|
-
|
|
1097
|
-
if (!view?.requestAnimationFrame) {
|
|
1098
|
-
flushScheduledUpdate();
|
|
1099
|
-
return;
|
|
1100
|
-
}
|
|
1101
|
-
if (frameId !== void 0) return;
|
|
1102
|
-
frameWindow = view;
|
|
1103
|
-
frameId = view.requestAnimationFrame(onAnimationFrame);
|
|
1268
|
+
if (session) updateScheduler.schedule();
|
|
1104
1269
|
}
|
|
1105
1270
|
function onGeometryChange() {
|
|
1106
1271
|
if (!session) return;
|
|
@@ -1115,7 +1280,7 @@ function useRangeSliderPointer(options) {
|
|
|
1115
1280
|
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
1116
1281
|
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
1117
1282
|
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
1118
|
-
|
|
1283
|
+
updateScheduler.cancel();
|
|
1119
1284
|
pendingPointerEvent = void 0;
|
|
1120
1285
|
geometryDirty = false;
|
|
1121
1286
|
session = void 0;
|
|
@@ -1138,7 +1303,7 @@ function useRangeSliderPointer(options) {
|
|
|
1138
1303
|
switchDraggingThumb(options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
1139
1304
|
}
|
|
1140
1305
|
function isCurrentPointer(event) {
|
|
1141
|
-
return
|
|
1306
|
+
return isMatchingPointer(event, session?.pointerId);
|
|
1142
1307
|
}
|
|
1143
1308
|
function onPointerMove(event) {
|
|
1144
1309
|
if (!isCurrentPointer(event)) return;
|
|
@@ -1170,7 +1335,7 @@ function useRangeSliderPointer(options) {
|
|
|
1170
1335
|
geometry,
|
|
1171
1336
|
thumb,
|
|
1172
1337
|
anchorValue: options.getAnchorValue(thumb),
|
|
1173
|
-
pointerId:
|
|
1338
|
+
pointerId: getPointerId(event)
|
|
1174
1339
|
};
|
|
1175
1340
|
options.startDrag(thumb);
|
|
1176
1341
|
switchDraggingThumb(options.updateThumb(thumb, pointerValue, session.anchorValue));
|
|
@@ -1283,55 +1448,132 @@ function useRangeSliderTooltipState(options) {
|
|
|
1283
1448
|
};
|
|
1284
1449
|
}
|
|
1285
1450
|
//#endregion
|
|
1286
|
-
//#region src/components/slider/
|
|
1287
|
-
function
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
const
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1451
|
+
//#region src/components/slider/useRangeSliderValueState.ts
|
|
1452
|
+
function useRangeSliderValueState(props, onChange, setActiveThumb) {
|
|
1453
|
+
const lowerInputRef = ref(null);
|
|
1454
|
+
const upperInputRef = ref(null);
|
|
1455
|
+
const controllable = useControllableValue({
|
|
1456
|
+
modelValue: () => props.modelValue,
|
|
1457
|
+
defaultValue: () => props.defaultValue ?? [props.min, props.max],
|
|
1458
|
+
onChange
|
|
1459
|
+
});
|
|
1460
|
+
const control = useControlState(props);
|
|
1461
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
1462
|
+
const valueStep = computed(() => normalizeSliderStep(props.step));
|
|
1463
|
+
const nativeStep = computed(() => getRangeSliderNativeStep(bounds.value, valueStep.value));
|
|
1464
|
+
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
1465
|
+
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
1466
|
+
const normalizedValue = computed(() => normalizeRangeSliderValue(controllable.value.value, bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
1467
|
+
const nativeLimits = computed(() => getRangeSliderNativeLimits(normalizedValue.value, bounds.value, valueStep.value, normalizedMinRange.value));
|
|
1468
|
+
const nativeMin = computed(() => nativeLimits.value.min);
|
|
1469
|
+
const nativeMax = computed(() => nativeLimits.value.max);
|
|
1470
|
+
const valuePercent = computed(() => [getValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
1471
|
+
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
1472
|
+
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
1473
|
+
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
1474
|
+
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
1475
|
+
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
1476
|
+
const validationMessages = computed(() => Array.isArray(props.validationMessage) ? props.validationMessage : [props.validationMessage, props.validationMessage]);
|
|
1477
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1478
|
+
position: "--_rp-range-slider-mark-position",
|
|
1479
|
+
decorativeColors: ["--_rp-range-slider-mark-color", "--_rp-range-slider-mark-ring-color"],
|
|
1480
|
+
foregroundColors: ["--_rp-range-slider-mark-label-color", "--_rp-range-slider-mark-filled-label-color"]
|
|
1481
|
+
}));
|
|
1482
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
1483
|
+
const trackSlotProps = computed(() => ({
|
|
1484
|
+
value: normalizedValue.value,
|
|
1485
|
+
formattedValue: formattedValue.value,
|
|
1486
|
+
percent: valuePercent.value,
|
|
1487
|
+
min: bounds.value.min,
|
|
1488
|
+
max: bounds.value.max,
|
|
1489
|
+
orientation: props.orientation,
|
|
1490
|
+
getPercent(value) {
|
|
1491
|
+
return getValuePercent(value, bounds.value.min, bounds.value.max);
|
|
1492
|
+
}
|
|
1493
|
+
}));
|
|
1494
|
+
function normalizeInitialValue(value = controllable.initialValue) {
|
|
1495
|
+
return normalizeRangeSliderValue(value, props.min, props.max, props.step, props.minRange);
|
|
1496
|
+
}
|
|
1497
|
+
useFormControl({
|
|
1498
|
+
elements: () => [lowerInputRef.value, upperInputRef.value],
|
|
1499
|
+
isControlled: () => controllable.isControlled.value,
|
|
1500
|
+
initializeDefault(element, index) {
|
|
1501
|
+
const initialValue = normalizeInitialValue();
|
|
1502
|
+
element.defaultValue = String(initialValue[index]);
|
|
1503
|
+
},
|
|
1504
|
+
validationMessage: (_element, index) => validationMessages.value[index],
|
|
1505
|
+
readResetValue(elements) {
|
|
1506
|
+
const resetValue = [normalizedValue.value[0], normalizedValue.value[1]];
|
|
1507
|
+
for (const element of elements) {
|
|
1508
|
+
const index = element === upperInputRef.value ? 1 : 0;
|
|
1509
|
+
resetValue[index] = Number(element.defaultValue);
|
|
1510
|
+
}
|
|
1511
|
+
const nextValue = normalizeInitialValue(resetValue);
|
|
1512
|
+
controllable.resetValue(nextValue);
|
|
1513
|
+
nextTick(() => {
|
|
1514
|
+
if (lowerInputRef.value) lowerInputRef.value.value = String(nextValue[0]);
|
|
1515
|
+
if (upperInputRef.value) upperInputRef.value.value = String(nextValue[1]);
|
|
1516
|
+
});
|
|
1517
|
+
},
|
|
1518
|
+
syncControlledValue(elements) {
|
|
1519
|
+
for (const element of elements) {
|
|
1520
|
+
const index = element === upperInputRef.value ? 1 : 0;
|
|
1521
|
+
element.value = String(normalizedValue.value[index]);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
function updateThumb(thumb, value, anchorValue) {
|
|
1526
|
+
if (control.disabled) return thumb;
|
|
1527
|
+
const update = getRangeSliderThumbUpdate({
|
|
1528
|
+
thumb,
|
|
1529
|
+
value,
|
|
1530
|
+
currentValue: normalizedValue.value,
|
|
1531
|
+
bounds: bounds.value,
|
|
1532
|
+
step: valueStep.value,
|
|
1533
|
+
minRange: normalizedMinRange.value,
|
|
1534
|
+
nativeMin: nativeMin.value,
|
|
1535
|
+
nativeMax: nativeMax.value,
|
|
1536
|
+
anchorValue
|
|
1537
|
+
});
|
|
1538
|
+
setActiveThumb(update.thumb);
|
|
1539
|
+
controllable.setValue(update.value);
|
|
1540
|
+
return update.thumb;
|
|
1541
|
+
}
|
|
1542
|
+
const nativeElements = computed(() => [lowerInputRef.value, upperInputRef.value]);
|
|
1543
|
+
function setInputRef(index, element) {
|
|
1544
|
+
const input = element instanceof HTMLInputElement ? element : null;
|
|
1545
|
+
if (index === 0) lowerInputRef.value = input;
|
|
1546
|
+
else upperInputRef.value = input;
|
|
1547
|
+
}
|
|
1548
|
+
function focus(options) {
|
|
1549
|
+
lowerInputRef.value?.focus(options);
|
|
1550
|
+
}
|
|
1551
|
+
return {
|
|
1552
|
+
nativeElements,
|
|
1553
|
+
setInputRef,
|
|
1554
|
+
focus,
|
|
1555
|
+
control,
|
|
1556
|
+
bounds,
|
|
1557
|
+
valueStep,
|
|
1558
|
+
hasManualNativeKeyboard,
|
|
1559
|
+
nativeMin,
|
|
1560
|
+
nativeMax,
|
|
1561
|
+
nativeStep,
|
|
1562
|
+
nativeNames,
|
|
1563
|
+
nativeIds,
|
|
1564
|
+
normalizedValue,
|
|
1565
|
+
valuePercent,
|
|
1566
|
+
formattedValue,
|
|
1567
|
+
ariaLabels,
|
|
1568
|
+
ariaValueText,
|
|
1569
|
+
markItems,
|
|
1570
|
+
hasMarkLabels,
|
|
1571
|
+
trackSlotProps,
|
|
1572
|
+
updateThumb
|
|
1573
|
+
};
|
|
1334
1574
|
}
|
|
1575
|
+
//#endregion
|
|
1576
|
+
//#region src/components/slider/useRangeSlider.ts
|
|
1335
1577
|
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
1336
1578
|
const [lowerPercent, upperPercent] = valuePercent;
|
|
1337
1579
|
const style = {
|
|
@@ -1350,19 +1592,6 @@ function getRangeSliderTrackStyle(props, valuePercent) {
|
|
|
1350
1592
|
});
|
|
1351
1593
|
return style;
|
|
1352
1594
|
}
|
|
1353
|
-
function getFormattedRangeSliderValue(value, formatter) {
|
|
1354
|
-
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
1355
|
-
}
|
|
1356
|
-
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
1357
|
-
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
1358
|
-
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
1359
|
-
}
|
|
1360
|
-
function getThumbIndex(thumb) {
|
|
1361
|
-
return thumb === "lower" ? 0 : 1;
|
|
1362
|
-
}
|
|
1363
|
-
function getOppositeThumb(thumb) {
|
|
1364
|
-
return thumb === "lower" ? "upper" : "lower";
|
|
1365
|
-
}
|
|
1366
1595
|
function getThumbFromTarget(target) {
|
|
1367
1596
|
const thumb = target?.closest?.("[data-range-slider-thumb]")?.getAttribute("data-range-slider-thumb");
|
|
1368
1597
|
return thumb === "lower" || thumb === "upper" ? thumb : void 0;
|
|
@@ -1373,62 +1602,30 @@ function getThumbInput(track, thumb) {
|
|
|
1373
1602
|
function focusThumb(track, thumb) {
|
|
1374
1603
|
getThumbInput(track, thumb)?.focus({ preventScroll: true });
|
|
1375
1604
|
}
|
|
1376
|
-
function
|
|
1377
|
-
const
|
|
1605
|
+
function readRangeSliderPointerGeometry(track, orientation) {
|
|
1606
|
+
const vertical = orientation === "vertical";
|
|
1607
|
+
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
1608
|
+
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
1609
|
+
const length = vertical ? rect.height : rect.width;
|
|
1610
|
+
if (length <= 0) return void 0;
|
|
1611
|
+
return {
|
|
1612
|
+
length,
|
|
1613
|
+
start: vertical ? rect.bottom : rect.left,
|
|
1614
|
+
vertical
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
function useRangeSlider(props, onChange) {
|
|
1378
1618
|
const activeThumb = ref();
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
const nativeStep = computed(() => {
|
|
1382
|
-
const step = valueStep.value;
|
|
1383
|
-
if (step === "any") return step;
|
|
1384
|
-
return isSliderStepAligned(bounds.value.min, bounds.value.max, step) ? step : "any";
|
|
1385
|
-
});
|
|
1386
|
-
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
1387
|
-
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
1388
|
-
const normalizedValue = computed(() => normalizeRangeSliderValue(getValue(), bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
1389
|
-
const valuePercent = computed(() => [getSliderValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getSliderValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
1390
|
-
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
1391
|
-
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
1392
|
-
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
1393
|
-
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
1394
|
-
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
1395
|
-
const nativeMin = computed(() => {
|
|
1396
|
-
if (normalizedMinRange.value === 0) return [bounds.value.min, bounds.value.min];
|
|
1397
|
-
return [bounds.value.min, clamp(getStepValueAtOrAbove(normalizedValue.value[0] + normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max)];
|
|
1619
|
+
const valueState = useRangeSliderValueState(props, onChange, (thumb) => {
|
|
1620
|
+
activeThumb.value = thumb;
|
|
1398
1621
|
});
|
|
1399
|
-
const nativeMax = computed(() => {
|
|
1400
|
-
if (normalizedMinRange.value === 0) return [bounds.value.max, bounds.value.max];
|
|
1401
|
-
return [clamp(getStepValueAtOrBelow(normalizedValue.value[1] - normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max), bounds.value.max];
|
|
1402
|
-
});
|
|
1403
|
-
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1404
|
-
position: "--_rp-range-slider-mark-position",
|
|
1405
|
-
colors: [
|
|
1406
|
-
"--_rp-range-slider-mark-color",
|
|
1407
|
-
"--_rp-range-slider-mark-label-color",
|
|
1408
|
-
"--_rp-range-slider-mark-filled-label-color",
|
|
1409
|
-
"--_rp-range-slider-mark-ring-color"
|
|
1410
|
-
]
|
|
1411
|
-
}));
|
|
1412
|
-
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
1413
|
-
const trackSlotProps = computed(() => ({
|
|
1414
|
-
value: normalizedValue.value,
|
|
1415
|
-
formattedValue: formattedValue.value,
|
|
1416
|
-
percent: valuePercent.value,
|
|
1417
|
-
min: bounds.value.min,
|
|
1418
|
-
max: bounds.value.max,
|
|
1419
|
-
orientation: props.orientation,
|
|
1420
|
-
getPercent(value) {
|
|
1421
|
-
return getSliderValuePercent(value, bounds.value.min, bounds.value.max);
|
|
1422
|
-
}
|
|
1423
|
-
}));
|
|
1424
|
-
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valuePercent.value));
|
|
1425
1622
|
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
1426
1623
|
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
1427
1624
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
1428
1625
|
const tooltipState = useRangeSliderTooltipState({
|
|
1429
1626
|
mode: tooltipMode,
|
|
1430
1627
|
openDelay: tooltipOpenDelay,
|
|
1431
|
-
disabled: () => control.disabled,
|
|
1628
|
+
disabled: () => valueState.control.disabled,
|
|
1432
1629
|
setActiveThumb: (thumb) => {
|
|
1433
1630
|
activeThumb.value = thumb;
|
|
1434
1631
|
}
|
|
@@ -1450,7 +1647,7 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1450
1647
|
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
1451
1648
|
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
1452
1649
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
1453
|
-
const tooltipContent = computed(() => [String(formattedValue.value[0]), String(formattedValue.value[1])]);
|
|
1650
|
+
const tooltipContent = computed(() => [String(valueState.formattedValue.value[0]), String(valueState.formattedValue.value[1])]);
|
|
1454
1651
|
const mergedTooltipContent = computed(() => {
|
|
1455
1652
|
const [lower, upper] = tooltipContent.value;
|
|
1456
1653
|
return lower === upper ? lower : `${lower}–${upper}`;
|
|
@@ -1458,46 +1655,13 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1458
1655
|
const rootClass = computed(() => bem("rp-range-slider", {
|
|
1459
1656
|
[`size-${props.size}`]: Boolean(props.size),
|
|
1460
1657
|
vertical: props.orientation === "vertical",
|
|
1461
|
-
marked: markItems.value.length > 0,
|
|
1462
|
-
"marks-with-labels": hasMarkLabels.value,
|
|
1658
|
+
marked: valueState.markItems.value.length > 0,
|
|
1659
|
+
"marks-with-labels": valueState.hasMarkLabels.value,
|
|
1463
1660
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
1464
|
-
disabled: control.disabled,
|
|
1465
|
-
invalid: control.invalid
|
|
1661
|
+
disabled: valueState.control.disabled,
|
|
1662
|
+
invalid: valueState.control.invalid
|
|
1466
1663
|
}));
|
|
1467
|
-
|
|
1468
|
-
const safeValue = normalizeSliderValue(value, bounds.value.min, bounds.value.max, valueStep.value);
|
|
1469
|
-
if (normalizedMinRange.value > 0) {
|
|
1470
|
-
const nextValue = [...normalizedValue.value];
|
|
1471
|
-
nextValue[getThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax.value[0]) : Math.max(safeValue, nativeMin.value[1]);
|
|
1472
|
-
return {
|
|
1473
|
-
thumb,
|
|
1474
|
-
value: nextValue
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
if (safeValue < anchorValue) return {
|
|
1478
|
-
thumb: "lower",
|
|
1479
|
-
value: [safeValue, anchorValue]
|
|
1480
|
-
};
|
|
1481
|
-
if (safeValue > anchorValue) return {
|
|
1482
|
-
thumb: "upper",
|
|
1483
|
-
value: [anchorValue, safeValue]
|
|
1484
|
-
};
|
|
1485
|
-
return {
|
|
1486
|
-
thumb,
|
|
1487
|
-
value: [safeValue, safeValue]
|
|
1488
|
-
};
|
|
1489
|
-
}
|
|
1490
|
-
function updateThumb(thumb, value, anchorValue) {
|
|
1491
|
-
if (control.disabled) return thumb;
|
|
1492
|
-
const update = getThumbUpdate(thumb, value, anchorValue);
|
|
1493
|
-
activeThumb.value = update.thumb;
|
|
1494
|
-
emitUpdate(update.value);
|
|
1495
|
-
return update.thumb;
|
|
1496
|
-
}
|
|
1497
|
-
function onInput(thumb, event) {
|
|
1498
|
-
const input = event.target;
|
|
1499
|
-
transferFocusedThumb(input, thumb, updateThumb(thumb, input.valueAsNumber));
|
|
1500
|
-
}
|
|
1664
|
+
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valueState.valuePercent.value));
|
|
1501
1665
|
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
1502
1666
|
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
1503
1667
|
const track = input.closest(".rp-range-slider__track");
|
|
@@ -1507,68 +1671,31 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1507
1671
|
tooltipState.transferInteraction(thumb, nextThumb, "focus");
|
|
1508
1672
|
nextInput.focus({ preventScroll: true });
|
|
1509
1673
|
}
|
|
1674
|
+
function onInput(thumb, event) {
|
|
1675
|
+
const input = event.target;
|
|
1676
|
+
transferFocusedThumb(input, thumb, valueState.updateThumb(thumb, input.valueAsNumber));
|
|
1677
|
+
}
|
|
1510
1678
|
function onTooltipKeydown(thumb, event) {
|
|
1511
1679
|
if (tooltipState.onKeydown(thumb, event)) return;
|
|
1512
|
-
if (!hasManualNativeKeyboard.value || valueStep.value === "any") return;
|
|
1513
|
-
const index =
|
|
1514
|
-
const
|
|
1515
|
-
const pageStep = valueStep.value * 10;
|
|
1516
|
-
let nextValue;
|
|
1517
|
-
switch (event.key) {
|
|
1518
|
-
case "ArrowRight":
|
|
1519
|
-
case "ArrowUp":
|
|
1520
|
-
nextValue = currentValue + valueStep.value;
|
|
1521
|
-
break;
|
|
1522
|
-
case "ArrowLeft":
|
|
1523
|
-
case "ArrowDown":
|
|
1524
|
-
nextValue = currentValue - valueStep.value;
|
|
1525
|
-
break;
|
|
1526
|
-
case "PageUp":
|
|
1527
|
-
nextValue = currentValue + pageStep;
|
|
1528
|
-
break;
|
|
1529
|
-
case "PageDown":
|
|
1530
|
-
nextValue = currentValue - pageStep;
|
|
1531
|
-
break;
|
|
1532
|
-
case "Home":
|
|
1533
|
-
nextValue = nativeMin.value[index];
|
|
1534
|
-
break;
|
|
1535
|
-
case "End":
|
|
1536
|
-
nextValue = nativeMax.value[index];
|
|
1537
|
-
break;
|
|
1538
|
-
}
|
|
1680
|
+
if (!valueState.hasManualNativeKeyboard.value || valueState.valueStep.value === "any") return;
|
|
1681
|
+
const index = getRangeSliderThumbIndex(thumb);
|
|
1682
|
+
const nextValue = getRangeSliderKeyboardValue(event.key, valueState.normalizedValue.value[index], valueState.valueStep.value, valueState.nativeMin.value[index], valueState.nativeMax.value[index]);
|
|
1539
1683
|
if (nextValue == null) return;
|
|
1540
1684
|
event.preventDefault();
|
|
1541
|
-
const nextThumb = updateThumb(thumb, nextValue);
|
|
1685
|
+
const nextThumb = valueState.updateThumb(thumb, nextValue);
|
|
1542
1686
|
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
1543
1687
|
}
|
|
1544
|
-
function getPointerGeometry(track) {
|
|
1545
|
-
const vertical = props.orientation === "vertical";
|
|
1546
|
-
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
1547
|
-
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
1548
|
-
const length = vertical ? rect.height : rect.width;
|
|
1549
|
-
if (length <= 0) return void 0;
|
|
1550
|
-
return {
|
|
1551
|
-
length,
|
|
1552
|
-
start: vertical ? rect.bottom : rect.left,
|
|
1553
|
-
vertical
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
function getValueFromPointer(event, geometry) {
|
|
1557
|
-
const pointerPosition = geometry.vertical ? event.clientY : event.clientX;
|
|
1558
|
-
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1559
|
-
return bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
1560
|
-
}
|
|
1561
1688
|
const { onTrackPointerDown } = useRangeSliderPointer({
|
|
1562
|
-
disabled: () => control.disabled,
|
|
1563
|
-
getPointerGeometry,
|
|
1564
|
-
getPointerValue:
|
|
1565
|
-
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, normalizedValue.value, activeThumb.value),
|
|
1566
|
-
getAnchorValue: (thumb) => normalizedValue.value[
|
|
1689
|
+
disabled: () => valueState.control.disabled,
|
|
1690
|
+
getPointerGeometry: (track) => readRangeSliderPointerGeometry(track, props.orientation),
|
|
1691
|
+
getPointerValue: (event, geometry) => getRangeSliderPointerValue(event, geometry, valueState.bounds.value),
|
|
1692
|
+
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, valueState.normalizedValue.value, activeThumb.value),
|
|
1693
|
+
getAnchorValue: (thumb) => valueState.normalizedValue.value[getRangeSliderThumbIndex(getOppositeRangeSliderThumb(thumb))],
|
|
1567
1694
|
setActiveThumb: (thumb) => {
|
|
1568
1695
|
activeThumb.value = thumb;
|
|
1569
1696
|
},
|
|
1570
1697
|
focusThumb,
|
|
1571
|
-
updateThumb,
|
|
1698
|
+
updateThumb: valueState.updateThumb,
|
|
1572
1699
|
transferFocusedThumb: (track, from, to) => {
|
|
1573
1700
|
const input = getThumbInput(track, from);
|
|
1574
1701
|
if (input) transferFocusedThumb(input, from, to);
|
|
@@ -1578,20 +1705,23 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1578
1705
|
transferDrag: (from, to) => tooltipState.transferInteraction(from, to, "drag")
|
|
1579
1706
|
});
|
|
1580
1707
|
return {
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1708
|
+
nativeElements: valueState.nativeElements,
|
|
1709
|
+
setInputRef: valueState.setInputRef,
|
|
1710
|
+
focus: valueState.focus,
|
|
1711
|
+
control: valueState.control,
|
|
1712
|
+
nativeMin: valueState.nativeMin,
|
|
1713
|
+
nativeMax: valueState.nativeMax,
|
|
1714
|
+
nativeStep: valueState.nativeStep,
|
|
1715
|
+
nativeNames: valueState.nativeNames,
|
|
1716
|
+
nativeIds: valueState.nativeIds,
|
|
1587
1717
|
rootClass,
|
|
1588
|
-
normalizedValue,
|
|
1589
|
-
valuePercent,
|
|
1590
|
-
formattedValue,
|
|
1591
|
-
ariaLabels,
|
|
1592
|
-
ariaValueText,
|
|
1593
|
-
markItems,
|
|
1594
|
-
trackSlotProps,
|
|
1718
|
+
normalizedValue: valueState.normalizedValue,
|
|
1719
|
+
valuePercent: valueState.valuePercent,
|
|
1720
|
+
formattedValue: valueState.formattedValue,
|
|
1721
|
+
ariaLabels: valueState.ariaLabels,
|
|
1722
|
+
ariaValueText: valueState.ariaValueText,
|
|
1723
|
+
markItems: valueState.markItems,
|
|
1724
|
+
trackSlotProps: valueState.trackSlotProps,
|
|
1595
1725
|
trackStyle,
|
|
1596
1726
|
activeThumb,
|
|
1597
1727
|
tooltipVisible,
|
|
@@ -1618,17 +1748,16 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1618
1748
|
}
|
|
1619
1749
|
//#endregion
|
|
1620
1750
|
//#region src/components/slider/range-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1621
|
-
var t0 = template("<span data-v-
|
|
1622
|
-
var t1 = template("<span data-v-
|
|
1623
|
-
var t2 = template("<span data-v-
|
|
1624
|
-
var t3 = template("<span data-v-
|
|
1625
|
-
var t4 = template("<input data-v-
|
|
1626
|
-
var t5 = template("<span data-v-
|
|
1627
|
-
var t6 = template("<span data-v-
|
|
1628
|
-
var t7 = template("<span data-v-
|
|
1629
|
-
var t8 = template("<span data-v-
|
|
1630
|
-
var t9 = template("<div data-v-
|
|
1631
|
-
delegateEvents("pointerdown");
|
|
1751
|
+
var t0 = template("<span data-v-e27ae1af>");
|
|
1752
|
+
var t1 = template("<span data-v-e27ae1af class=rp-range-slider__header>");
|
|
1753
|
+
var t2 = template("<span data-v-e27ae1af class=\"rp-range-slider__track-layer rp-range-slider__track-underlay\"aria-hidden=true>");
|
|
1754
|
+
var t3 = template("<span data-v-e27ae1af class=\"rp-range-slider__track-layer rp-range-slider__track-overlay\"aria-hidden=true>");
|
|
1755
|
+
var t4 = template("<input data-v-e27ae1af>");
|
|
1756
|
+
var t5 = template("<span data-v-e27ae1af> ");
|
|
1757
|
+
var t6 = template("<span data-v-e27ae1af><span data-v-e27ae1af class=rp-range-slider__mark-dot></span>");
|
|
1758
|
+
var t7 = template("<span data-v-e27ae1af class=rp-range-slider__marks aria-hidden=true>");
|
|
1759
|
+
var t8 = template("<span data-v-e27ae1af><span data-v-e27ae1af class=rp-range-slider__thumb-content>");
|
|
1760
|
+
var t9 = template("<div data-v-e27ae1af><span data-v-e27ae1af><span data-v-e27ae1af class=rp-range-slider__rail aria-hidden=true></span><!><span data-v-e27ae1af></span><!><span data-v-e27ae1af class=rp-range-slider__thumbs aria-hidden=true>", 1);
|
|
1632
1761
|
//#endregion
|
|
1633
1762
|
//#region src/components/slider/range-slider.vue
|
|
1634
1763
|
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -1688,47 +1817,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1688
1817
|
const generatedId = useId();
|
|
1689
1818
|
const tooltipsOverlapping = ref(false);
|
|
1690
1819
|
const rangeSliderThumbs = ["lower", "upper"];
|
|
1691
|
-
const lowerInputRef = ref(null);
|
|
1692
|
-
const upperInputRef = ref(null);
|
|
1693
1820
|
const labelId = computed(() => `${props.id ?? generatedId}-label`);
|
|
1694
|
-
const
|
|
1695
|
-
modelValue: () => props.modelValue,
|
|
1696
|
-
defaultValue: () => props.defaultValue ?? [props.min, props.max],
|
|
1697
|
-
onChange: (value) => emit("update:modelValue", value)
|
|
1698
|
-
});
|
|
1699
|
-
const { control, nativeMin, nativeMax, nativeStep, nativeNames, nativeIds, rootClass, normalizedValue, valuePercent, formattedValue, ariaLabels, ariaValueText, markItems, trackSlotProps, trackStyle, activeThumb, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipIds, mergedTooltipId, tooltipColor, tooltipAutoContrast, tooltipContrastColor, tooltipOffset, tooltipArrow, tooltipContent, mergedTooltipContent, onInput, onTrackPointerDown, onTooltipFocus, onTooltipBlur, onTooltipTrackMouseEnter, onTooltipTrackMouseLeave, onTooltipKeydown } = useRangeSlider(props, (value) => controllable.setValue(value), () => controllable.value.value);
|
|
1700
|
-
const validationMessages = computed(() => Array.isArray(props.validationMessage) ? props.validationMessage : [props.validationMessage, props.validationMessage]);
|
|
1701
|
-
function normalizeInitialValue(value = controllable.initialValue) {
|
|
1702
|
-
return normalizeRangeSliderValue(value, props.min, props.max, props.step, props.minRange);
|
|
1703
|
-
}
|
|
1704
|
-
useFormControl({
|
|
1705
|
-
elements: () => [lowerInputRef.value, upperInputRef.value],
|
|
1706
|
-
isControlled: () => controllable.isControlled.value,
|
|
1707
|
-
initializeDefault(element, index) {
|
|
1708
|
-
const initialValue = normalizeInitialValue();
|
|
1709
|
-
element.defaultValue = String(initialValue[index]);
|
|
1710
|
-
},
|
|
1711
|
-
validationMessage: (_element, index) => validationMessages.value[index],
|
|
1712
|
-
readResetValue(elements) {
|
|
1713
|
-
const resetValue = [normalizedValue.value[0], normalizedValue.value[1]];
|
|
1714
|
-
for (const element of elements) {
|
|
1715
|
-
const index = element === upperInputRef.value ? 1 : 0;
|
|
1716
|
-
resetValue[index] = Number(element.defaultValue);
|
|
1717
|
-
}
|
|
1718
|
-
const nextValue = normalizeInitialValue(resetValue);
|
|
1719
|
-
controllable.resetValue(nextValue);
|
|
1720
|
-
nextTick(() => {
|
|
1721
|
-
if (lowerInputRef.value) lowerInputRef.value.value = String(nextValue[0]);
|
|
1722
|
-
if (upperInputRef.value) upperInputRef.value.value = String(nextValue[1]);
|
|
1723
|
-
});
|
|
1724
|
-
},
|
|
1725
|
-
syncControlledValue(elements) {
|
|
1726
|
-
for (const element of elements) {
|
|
1727
|
-
const index = element === upperInputRef.value ? 1 : 0;
|
|
1728
|
-
element.value = String(normalizedValue.value[index]);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1821
|
+
const { nativeElements, setInputRef, focus, control, nativeMin, nativeMax, nativeStep, nativeNames, nativeIds, rootClass, normalizedValue, valuePercent, formattedValue, ariaLabels, ariaValueText, markItems, trackSlotProps, trackStyle, activeThumb, tooltipVisible, tooltipOpen, tooltipPlacement, tooltipIds, mergedTooltipId, tooltipColor, tooltipAutoContrast, tooltipContrastColor, tooltipOffset, tooltipArrow, tooltipContent, mergedTooltipContent, onInput, onTrackPointerDown, onTooltipFocus, onTooltipBlur, onTooltipTrackMouseEnter, onTooltipTrackMouseLeave, onTooltipKeydown } = useRangeSlider(props, (value) => emit("update:modelValue", value));
|
|
1732
1822
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
1733
1823
|
const rootAttrs = computed(() => getRootAttrs({
|
|
1734
1824
|
class: [rootClass.value, {
|
|
@@ -1738,8 +1828,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1738
1828
|
style: trackStyle.value,
|
|
1739
1829
|
role: "group",
|
|
1740
1830
|
"data-active-thumb": activeThumb.value || void 0,
|
|
1741
|
-
"data-disabled":
|
|
1742
|
-
"data-invalid":
|
|
1831
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
1832
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
1743
1833
|
"data-orientation": props.orientation,
|
|
1744
1834
|
"aria-labelledby": groupLabelledby.value,
|
|
1745
1835
|
"aria-describedby": control.ariaDescribedby,
|
|
@@ -1751,44 +1841,21 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1751
1841
|
return [props.inputAttrs, props.inputAttrs];
|
|
1752
1842
|
});
|
|
1753
1843
|
const nativeInputAttrs = computed(() => rangeSliderThumbs.map((thumb, index) => {
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1844
|
+
const inputAttrs = inputAttrsByThumb.value[index] ?? {};
|
|
1845
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
1846
|
+
return Object.assign({}, forwardedAttributes, {
|
|
1756
1847
|
...getPartAttrs("input", {
|
|
1757
1848
|
class: ["rp-range-slider__native", `rp-range-slider__native--${thumb}`],
|
|
1758
1849
|
compatibilityClass,
|
|
1759
1850
|
compatibilityStyle
|
|
1760
1851
|
}),
|
|
1761
|
-
onInput(event)
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
onFocus(event) {
|
|
1766
|
-
onTooltipFocus(thumb);
|
|
1767
|
-
compatibilityOnFocus?.(event);
|
|
1768
|
-
},
|
|
1769
|
-
onBlur(event) {
|
|
1770
|
-
onTooltipBlur(thumb);
|
|
1771
|
-
compatibilityOnBlur?.(event);
|
|
1772
|
-
},
|
|
1773
|
-
onKeydown(event) {
|
|
1774
|
-
onTooltipKeydown(thumb, event);
|
|
1775
|
-
compatibilityOnKeydown?.(event);
|
|
1776
|
-
}
|
|
1852
|
+
onInput: composeEventHandlers((event) => onInput(thumb, event), inputAttrs.onInput),
|
|
1853
|
+
onFocus: composeEventHandlers(() => onTooltipFocus(thumb), inputAttrs.onFocus),
|
|
1854
|
+
onBlur: composeEventHandlers(() => onTooltipBlur(thumb), inputAttrs.onBlur),
|
|
1855
|
+
onKeydown: composeEventHandlers((event) => onTooltipKeydown(thumb, event), inputAttrs.onKeydown)
|
|
1777
1856
|
});
|
|
1778
1857
|
}));
|
|
1779
|
-
const
|
|
1780
|
-
function setInputRef(index, element) {
|
|
1781
|
-
const input = element instanceof HTMLInputElement ? element : null;
|
|
1782
|
-
if (index === 0) lowerInputRef.value = input;
|
|
1783
|
-
else upperInputRef.value = input;
|
|
1784
|
-
}
|
|
1785
|
-
function focus(options) {
|
|
1786
|
-
lowerInputRef.value?.focus(options);
|
|
1787
|
-
}
|
|
1788
|
-
const groupLabelledby = computed(() => {
|
|
1789
|
-
const values = [control.ariaLabelledby, slots.default ? labelId.value : void 0].flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
1790
|
-
return values.length ? Array.from(new Set(values)).join(" ") : void 0;
|
|
1791
|
-
});
|
|
1858
|
+
const groupLabelledby = computed(() => mergeAriaIdRefs(control.ariaLabelledby, slots.default ? labelId.value : void 0));
|
|
1792
1859
|
__expose({
|
|
1793
1860
|
nativeElements,
|
|
1794
1861
|
focus
|
|
@@ -1871,10 +1938,10 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1871
1938
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs_index?.["aria-invalid"] : _control.invalid || void 0,
|
|
1872
1939
|
"aria-required": _props_required_nativeInputAttrs_index_required,
|
|
1873
1940
|
"data-thumb": _for_item0.value,
|
|
1874
|
-
"data-disabled": unref(
|
|
1875
|
-
"data-invalid": unref(
|
|
1941
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
1942
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
1876
1943
|
}]);
|
|
1877
|
-
_setTemplateRef(n22, (element) => setInputRef(_index, element), true);
|
|
1944
|
+
_setTemplateRef(n22, (element) => unref(setInputRef)(_index, element), true);
|
|
1878
1945
|
});
|
|
1879
1946
|
return n22;
|
|
1880
1947
|
}, (thumb, index) => thumb, 8);
|
|
@@ -1889,7 +1956,7 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1889
1956
|
setDynamicProps(n30, [unref(getPartAttrs)("mark", {
|
|
1890
1957
|
class: ["rp-range-slider__mark", { "rp-range-slider__mark--filled": _mark.filled }],
|
|
1891
1958
|
style: _mark.style
|
|
1892
|
-
}), { "data-filled": unref(
|
|
1959
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
1893
1960
|
});
|
|
1894
1961
|
setInsertionState(n30, null, 1);
|
|
1895
1962
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -1948,12 +2015,12 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1948
2015
|
"onUpdate:overlapping": () => _on_update_overlapping
|
|
1949
2016
|
});
|
|
1950
2017
|
});
|
|
1951
|
-
n42
|
|
2018
|
+
on(n42, "pointerdown", (e) => unref(onTrackPointerDown)(e));
|
|
1952
2019
|
on(n42, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1953
2020
|
on(n42, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1954
2021
|
return n44;
|
|
1955
2022
|
}
|
|
1956
|
-
}), [["__scopeId", "data-v-
|
|
2023
|
+
}), [["__scopeId", "data-v-e27ae1af"]]);
|
|
1957
2024
|
//#endregion
|
|
1958
2025
|
//#region src/components/slider/types.ts
|
|
1959
2026
|
var sliderParts = [
|