ropav 0.1.6 → 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 +6 -0
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +123 -155
- package/dist/alert.css +18 -18
- package/dist/alert.js +10 -11
- 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 +9 -17
- package/dist/badge.css +16 -16
- package/dist/badge.js +5 -5
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +4 -3
- package/dist/button.js +4 -3
- package/dist/button.scss_vue_type_style_index_0_src_true_lang.js +1 -1
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +7 -6
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +14 -13
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +221 -200
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +6 -8
- package/dist/color.js +5 -10
- package/dist/componentColors.js +125 -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 +1 -2
- 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} +1 -5
- 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-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-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +16 -18
- 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/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -17
- 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 +0 -6
- package/dist/components/radio/useRadio.d.ts +1 -2
- 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/useScrollArea.d.ts +70 -53
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -17
- 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/slider/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +0 -1
- package/dist/components/slider/useRangeSlider.d.ts +8 -16
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +7 -13
- 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/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/css.js +12 -0
- package/dist/dialog.js +226 -218
- package/dist/dropdown-menu.js +1458 -1097
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/floating.js +548 -319
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.js +6 -6
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/modal.js +1 -1
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +14 -12
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +65 -63
- package/dist/pointer.js +9 -0
- package/dist/popover.css +34 -34
- package/dist/popover.js +85 -86
- package/dist/progress.js +10 -13
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +30 -36
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +28 -28
- package/dist/scroll-area.js +512 -516
- package/dist/select.css +45 -45
- package/dist/select.js +36 -44
- package/dist/slider.css +191 -191
- package/dist/slider.js +691 -618
- 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 +14 -15
- package/dist/tabs.css +43 -43
- package/dist/tabs.js +29 -56
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +21 -32
- package/dist/toast.css +26 -26
- package/dist/toast.js +141 -118
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +36 -40
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useFloatingPosition.js +140 -10
- package/dist/useOverlayZIndex.js +1 -5
- 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-floating-api.md +6 -5
- package/package.json +13 -12
- 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 -36
- 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 -30
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -38
- /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/slider.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import './slider.css';
|
|
2
2
|
import { t as useControllableValue } from "./useControllableValue.js";
|
|
3
|
-
import {
|
|
3
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
4
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
4
5
|
import { t as bem } from "./bem.js";
|
|
5
6
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
6
|
-
import { n 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;
|
|
@@ -78,7 +78,7 @@ function createSliderMarkItems(marks, min, max, isFilled, properties) {
|
|
|
78
78
|
if (mark.hidden) return [];
|
|
79
79
|
const value = Number(mark.value);
|
|
80
80
|
if (!Number.isFinite(value)) return [];
|
|
81
|
-
const percent =
|
|
81
|
+
const percent = getValuePercent(value, min, max);
|
|
82
82
|
return {
|
|
83
83
|
key: `${value}-${index}`,
|
|
84
84
|
value,
|
|
@@ -112,254 +112,199 @@ function getSliderTooltipAnchor(tooltip) {
|
|
|
112
112
|
return typeof tooltip === "object" && tooltip.anchor === "pointer" ? "pointer" : "thumb";
|
|
113
113
|
}
|
|
114
114
|
//#endregion
|
|
115
|
-
//#region src/components/slider/
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const style = {
|
|
121
|
-
"--_rp-slider-percent": `${valuePercent}%`,
|
|
122
|
-
"--_rp-slider-ratio": `${valuePercent / 100}`,
|
|
123
|
-
"--_rp-slider-tooltip-percent": `${tooltipPercent}%`,
|
|
124
|
-
"--_rp-slider-tooltip-ratio": `${tooltipPercent / 100}`
|
|
125
|
-
};
|
|
126
|
-
setSliderStyleValue(style, "--_rp-slider-color", getSliderColorValue(props.color));
|
|
127
|
-
applySliderThumbStyle(style, getSliderThumbOptions(props.thumb), {
|
|
128
|
-
size: "--rp-slider-thumb-size",
|
|
129
|
-
border: "--_rp-slider-thumb-border-style",
|
|
130
|
-
padding: "--rp-slider-thumb-padding",
|
|
131
|
-
borderColor: "--_rp-slider-thumb-border"
|
|
132
|
-
});
|
|
133
|
-
return style;
|
|
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();
|
|
134
120
|
}
|
|
135
|
-
function
|
|
136
|
-
const control = useControlState(props);
|
|
137
|
-
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
138
|
-
const nativeStep = computed(() => normalizeSliderStep(props.step));
|
|
139
|
-
const normalizedValue = computed(() => normalizeSliderValue(getValue(), bounds.value.min, bounds.value.max, nativeStep.value));
|
|
140
|
-
const valuePercent = computed(() => getSliderValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
141
|
-
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
142
|
-
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
143
|
-
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
144
|
-
position: "--_rp-slider-mark-position",
|
|
145
|
-
decorativeColors: ["--_rp-slider-mark-color", "--_rp-slider-mark-ring-color"],
|
|
146
|
-
foregroundColors: ["--_rp-slider-mark-label-color", "--_rp-slider-mark-filled-label-color"]
|
|
147
|
-
}));
|
|
148
|
-
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
149
|
-
const tooltipAnchor = computed(() => getSliderTooltipAnchor(props.tooltip));
|
|
150
|
-
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
151
|
-
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
152
|
-
const { isOpen: delayedTooltipOpen, open: openDelayedTooltip, closeImmediate: closeDelayedTooltip } = useDelayedOpen({
|
|
153
|
-
openDelay: () => tooltipOpenDelay.value,
|
|
154
|
-
disabled: () => tooltipMode.value !== "hover" || control.disabled
|
|
155
|
-
});
|
|
156
|
-
const trackHovered = ref(false);
|
|
157
|
-
const focusWithin = ref(false);
|
|
121
|
+
function useSliderPointerPreview(options) {
|
|
158
122
|
const dragging = ref(false);
|
|
159
123
|
const previewAvailable = ref(false);
|
|
160
|
-
const previewValue = ref(
|
|
161
|
-
let dismissed = false;
|
|
124
|
+
const previewValue = ref(options.initialValue);
|
|
162
125
|
let dragView = null;
|
|
163
126
|
let dragPointerId;
|
|
164
127
|
let dragTrack = null;
|
|
165
|
-
let previewFrameView = null;
|
|
166
|
-
let previewFrameId;
|
|
167
128
|
let pendingPreview;
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
percent: valuePercent.value,
|
|
174
|
-
min: bounds.value.min,
|
|
175
|
-
max: bounds.value.max,
|
|
176
|
-
orientation: props.orientation,
|
|
177
|
-
getPercent(value) {
|
|
178
|
-
return getSliderValuePercent(value, bounds.value.min, bounds.value.max);
|
|
179
|
-
}
|
|
180
|
-
}));
|
|
181
|
-
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
182
|
-
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
183
|
-
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltipOpen.value && !control.disabled);
|
|
184
|
-
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (props.orientation === "vertical" ? "left" : "top"));
|
|
185
|
-
const tooltipId = computed(() => tooltipOptions.value.id);
|
|
186
|
-
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
187
|
-
const tooltipAutoContrast = computed(() => tooltipOptions.value.autoContrast);
|
|
188
|
-
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
189
|
-
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
190
|
-
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
191
|
-
const tooltipValue = computed(() => tooltipAnchor.value === "pointer" && previewAvailable.value ? previewValue.value : normalizedValue.value);
|
|
192
|
-
const tooltipPercent = computed(() => getSliderValuePercent(tooltipValue.value, bounds.value.min, bounds.value.max));
|
|
193
|
-
const tooltipFormattedValue = computed(() => getFormattedSliderValue(tooltipValue.value, props.formatValue));
|
|
194
|
-
const tooltipContent = computed(() => String(tooltipFormattedValue.value));
|
|
195
|
-
const rootClass = computed(() => bem("rp-slider", {
|
|
196
|
-
[`size-${props.size}`]: Boolean(props.size),
|
|
197
|
-
vertical: props.orientation === "vertical",
|
|
198
|
-
marked: markItems.value.length > 0,
|
|
199
|
-
"marks-with-labels": hasMarkLabels.value,
|
|
200
|
-
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
201
|
-
"thumb-interaction": thumbMode.value === "interaction",
|
|
202
|
-
"thumb-hidden": thumbMode.value === false,
|
|
203
|
-
disabled: control.disabled,
|
|
204
|
-
invalid: control.invalid
|
|
205
|
-
}));
|
|
206
|
-
const trackStyle = computed(() => getSliderTrackStyle(props, valuePercent.value, tooltipPercent.value));
|
|
207
|
-
function onInput(e) {
|
|
208
|
-
if (control.disabled) return;
|
|
209
|
-
const input = e.target;
|
|
210
|
-
emitUpdate(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
211
|
-
}
|
|
212
|
-
function hasTooltipInteraction() {
|
|
213
|
-
if (tooltipAnchor.value === "pointer") return previewAvailable.value && (trackHovered.value || dragging.value);
|
|
214
|
-
return trackHovered.value || focusWithin.value || dragging.value;
|
|
215
|
-
}
|
|
216
|
-
function syncTooltip() {
|
|
217
|
-
if (tooltipMode.value === "hover" && !control.disabled && hasTooltipInteraction() && !dismissed) {
|
|
218
|
-
openDelayedTooltip();
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
closeDelayedTooltip();
|
|
222
|
-
}
|
|
223
|
-
function onTooltipTrackEnter(event) {
|
|
224
|
-
if (control.disabled) return;
|
|
225
|
-
if (tooltipAnchor.value === "pointer") {
|
|
226
|
-
cancelScheduledPreview();
|
|
227
|
-
previewAvailable.value = false;
|
|
228
|
-
const track = event.currentTarget;
|
|
229
|
-
if (track) updatePreviewFromPointer(event, track);
|
|
230
|
-
}
|
|
231
|
-
trackHovered.value = true;
|
|
232
|
-
dismissed = false;
|
|
233
|
-
syncTooltip();
|
|
234
|
-
}
|
|
235
|
-
function onTooltipTrackLeave() {
|
|
236
|
-
trackHovered.value = false;
|
|
237
|
-
if (!dragging.value && tooltipAnchor.value === "pointer") cancelScheduledPreview();
|
|
238
|
-
syncTooltip();
|
|
239
|
-
}
|
|
240
|
-
function onTooltipFocusIn() {
|
|
241
|
-
focusWithin.value = true;
|
|
242
|
-
dismissed = false;
|
|
243
|
-
syncTooltip();
|
|
244
|
-
}
|
|
245
|
-
function onTooltipFocusOut() {
|
|
246
|
-
focusWithin.value = false;
|
|
247
|
-
syncTooltip();
|
|
248
|
-
}
|
|
249
|
-
function removeDragListeners() {
|
|
250
|
-
dragView?.removeEventListener("pointermove", onTooltipWindowPointerMove);
|
|
251
|
-
dragView?.removeEventListener("pointerup", onTooltipPointerEnd);
|
|
252
|
-
dragView?.removeEventListener("pointercancel", onTooltipPointerEnd);
|
|
253
|
-
dragView = null;
|
|
254
|
-
dragPointerId = void 0;
|
|
255
|
-
dragTrack = null;
|
|
256
|
-
}
|
|
257
|
-
function cancelScheduledPreview() {
|
|
258
|
-
if (previewFrameId !== void 0) previewFrameView?.cancelAnimationFrame(previewFrameId);
|
|
259
|
-
previewFrameView = null;
|
|
260
|
-
previewFrameId = void 0;
|
|
261
|
-
pendingPreview = void 0;
|
|
262
|
-
}
|
|
263
|
-
function updatePreviewFromPointer(pointer, track) {
|
|
264
|
-
if (tooltipAnchor.value !== "pointer" || control.disabled) return false;
|
|
265
|
-
const vertical = props.orientation === "vertical";
|
|
266
|
-
const travelRect = track.querySelector(".rp-slider__travel")?.getBoundingClientRect();
|
|
267
|
-
const trackRect = track.getBoundingClientRect();
|
|
268
|
-
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);
|
|
269
134
|
const length = vertical ? rect.height : rect.width;
|
|
270
135
|
if (length <= 0) return false;
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const rawValue = bounds.
|
|
274
|
-
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);
|
|
275
140
|
previewAvailable.value = true;
|
|
276
141
|
return true;
|
|
277
142
|
}
|
|
278
143
|
function applyScheduledPreview() {
|
|
279
144
|
const pending = pendingPreview;
|
|
280
145
|
pendingPreview = void 0;
|
|
281
|
-
if (pending &&
|
|
282
|
-
}
|
|
283
|
-
function onPreviewAnimationFrame() {
|
|
284
|
-
previewFrameView = null;
|
|
285
|
-
previewFrameId = void 0;
|
|
286
|
-
applyScheduledPreview();
|
|
146
|
+
if (pending && updateFromPointer(pending, pending.track)) options.onStateChange();
|
|
287
147
|
}
|
|
288
148
|
function schedulePreview(event, track) {
|
|
289
|
-
if (
|
|
149
|
+
if (!options.enabled() || options.disabled()) return;
|
|
290
150
|
pendingPreview = {
|
|
291
151
|
clientX: event.clientX,
|
|
292
152
|
clientY: event.clientY,
|
|
293
153
|
track
|
|
294
154
|
};
|
|
295
|
-
|
|
296
|
-
if (!view?.requestAnimationFrame) {
|
|
297
|
-
applyScheduledPreview();
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (previewFrameId !== void 0) return;
|
|
301
|
-
previewFrameView = view;
|
|
302
|
-
previewFrameId = view.requestAnimationFrame(onPreviewAnimationFrame);
|
|
155
|
+
previewScheduler.schedule();
|
|
303
156
|
}
|
|
304
|
-
function
|
|
305
|
-
|
|
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;
|
|
168
|
+
}
|
|
169
|
+
function onPointerMove(event) {
|
|
170
|
+
if (dragging.value && !isMatchingPointer(event, dragPointerId)) return;
|
|
306
171
|
const track = event.currentTarget;
|
|
307
172
|
if (track) schedulePreview(event, track);
|
|
308
173
|
}
|
|
309
|
-
function
|
|
310
|
-
if (
|
|
174
|
+
function onWindowPointerMove(event) {
|
|
175
|
+
if (!isMatchingPointer(event, dragPointerId)) return;
|
|
311
176
|
if (dragTrack) schedulePreview(event, dragTrack);
|
|
312
177
|
}
|
|
313
|
-
function
|
|
314
|
-
if (
|
|
178
|
+
function onPointerEnd(event) {
|
|
179
|
+
if (!isMatchingPointer(event, dragPointerId)) return;
|
|
315
180
|
cancelScheduledPreview();
|
|
316
|
-
if (dragTrack)
|
|
181
|
+
if (dragTrack) updateFromPointer(event, dragTrack);
|
|
317
182
|
dragging.value = false;
|
|
318
183
|
removeDragListeners();
|
|
319
|
-
|
|
184
|
+
options.onStateChange();
|
|
320
185
|
}
|
|
321
|
-
function
|
|
322
|
-
if (
|
|
186
|
+
function onPointerDown(event) {
|
|
187
|
+
if (options.disabled() || event.button !== 0 || event.isPrimary === false) return false;
|
|
323
188
|
removeDragListeners();
|
|
324
|
-
dismissed = false;
|
|
325
189
|
dragging.value = true;
|
|
326
|
-
dragPointerId =
|
|
190
|
+
dragPointerId = getPointerId(event);
|
|
327
191
|
dragTrack = event.currentTarget;
|
|
328
|
-
if (dragTrack)
|
|
192
|
+
if (dragTrack) updateFromPointer(event, dragTrack);
|
|
329
193
|
dragView = dragTrack?.ownerDocument.defaultView ?? null;
|
|
330
|
-
dragView?.addEventListener("pointermove",
|
|
331
|
-
dragView?.addEventListener("pointerup",
|
|
332
|
-
dragView?.addEventListener("pointercancel",
|
|
333
|
-
|
|
194
|
+
dragView?.addEventListener("pointermove", onWindowPointerMove);
|
|
195
|
+
dragView?.addEventListener("pointerup", onPointerEnd);
|
|
196
|
+
dragView?.addEventListener("pointercancel", onPointerEnd);
|
|
197
|
+
return true;
|
|
334
198
|
}
|
|
335
|
-
function
|
|
336
|
-
if (
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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();
|
|
340
208
|
}
|
|
341
209
|
onBeforeUnmount(() => {
|
|
342
210
|
removeDragListeners();
|
|
343
211
|
cancelScheduledPreview();
|
|
344
212
|
});
|
|
345
213
|
return {
|
|
346
|
-
control,
|
|
347
|
-
nativeMin: computed(() => bounds.value.min),
|
|
348
|
-
nativeMax: computed(() => bounds.value.max),
|
|
349
|
-
nativeStep,
|
|
350
|
-
rootClass,
|
|
351
|
-
normalizedValue,
|
|
352
|
-
valuePercent,
|
|
353
|
-
formattedValue,
|
|
354
|
-
ariaValueText,
|
|
355
|
-
markItems,
|
|
356
|
-
thumbMode,
|
|
357
|
-
trackSlotProps,
|
|
358
|
-
trackStyle,
|
|
359
|
-
trackHovered,
|
|
360
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,
|
|
361
305
|
tooltipVisible,
|
|
362
306
|
tooltipOpen,
|
|
307
|
+
tooltipAlwaysVisible,
|
|
363
308
|
tooltipAnchor,
|
|
364
309
|
tooltipPlacement,
|
|
365
310
|
tooltipId,
|
|
@@ -373,9 +318,8 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
373
318
|
tooltipPercent,
|
|
374
319
|
tooltipFormattedValue,
|
|
375
320
|
tooltipContent,
|
|
376
|
-
onInput,
|
|
377
321
|
onTooltipPointerDown,
|
|
378
|
-
onTooltipPointerMove,
|
|
322
|
+
onTooltipPointerMove: pointerPreview.onPointerMove,
|
|
379
323
|
onTooltipTrackEnter,
|
|
380
324
|
onTooltipTrackLeave,
|
|
381
325
|
onTooltipFocusIn,
|
|
@@ -384,19 +328,178 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
384
328
|
};
|
|
385
329
|
}
|
|
386
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
|
|
387
491
|
//#region src/components/slider/slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
388
|
-
var t0$2 = template("<span data-v-
|
|
389
|
-
var t1$2 = template("<span data-v-
|
|
390
|
-
var t2$2 = template("<span data-v-
|
|
391
|
-
var t3$2 = template("<span data-v-
|
|
392
|
-
var t4$2 = template("<span data-v-
|
|
393
|
-
var t5$1 = template("<span data-v-
|
|
394
|
-
var t6$1 = template("<span data-v-
|
|
395
|
-
var t7$1 = template("<span data-v-
|
|
396
|
-
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);
|
|
397
501
|
var t9$1 = template(" ");
|
|
398
|
-
var t10 = template("<label data-v-
|
|
399
|
-
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);
|
|
400
503
|
//#endregion
|
|
401
504
|
//#region src/components/slider/slider.vue
|
|
402
505
|
var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -459,36 +562,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
459
562
|
const slots = useSlots();
|
|
460
563
|
const props = __props;
|
|
461
564
|
const emit = __emit;
|
|
462
|
-
const inputRef =
|
|
463
|
-
const controllable = useControllableValue({
|
|
464
|
-
modelValue: () => props.modelValue,
|
|
465
|
-
defaultValue: () => props.defaultValue ?? props.min,
|
|
466
|
-
onChange: (value) => emit("update:modelValue", value)
|
|
467
|
-
});
|
|
468
|
-
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);
|
|
469
|
-
useFormControl({
|
|
470
|
-
elements: () => [inputRef.value],
|
|
471
|
-
isControlled: () => controllable.isControlled.value,
|
|
472
|
-
initializeDefault(element) {
|
|
473
|
-
element.defaultValue = String(normalizeSliderValue(controllable.initialValue, nativeMin.value, nativeMax.value, nativeStep.value));
|
|
474
|
-
},
|
|
475
|
-
validationMessage: () => props.validationMessage,
|
|
476
|
-
readResetValue(elements) {
|
|
477
|
-
controllable.resetValue(elements[0].valueAsNumber);
|
|
478
|
-
},
|
|
479
|
-
syncControlledValue(elements) {
|
|
480
|
-
elements[0].value = String(normalizedValue.value);
|
|
481
|
-
}
|
|
482
|
-
});
|
|
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));
|
|
483
566
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
484
567
|
const rootAttrs = computed(() => getRootAttrs({
|
|
485
568
|
class: [rootClass.value, { "rp-slider--custom-thumb": Boolean(slots.thumb) }],
|
|
486
569
|
style: trackStyle.value,
|
|
487
|
-
"data-disabled":
|
|
488
|
-
"data-invalid":
|
|
570
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
571
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
489
572
|
"data-orientation": props.orientation,
|
|
490
|
-
"data-track-hovered":
|
|
491
|
-
"data-dragging":
|
|
573
|
+
"data-track-hovered": toPresenceAttribute(trackHovered.value),
|
|
574
|
+
"data-dragging": toPresenceAttribute(dragging.value),
|
|
492
575
|
"data-thumb-visibility": thumbMode.value === false ? "hidden" : thumbMode.value
|
|
493
576
|
}));
|
|
494
577
|
const tooltipClassNames = computed(() => ({
|
|
@@ -497,23 +580,18 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
497
580
|
}));
|
|
498
581
|
const tooltipStyles = computed(() => ({ root: props.styles?.tooltip }));
|
|
499
582
|
const nativeInputAttrs = computed(() => {
|
|
500
|
-
const
|
|
583
|
+
const inputAttrs = props.inputAttrs ?? {};
|
|
584
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
501
585
|
return {
|
|
502
|
-
...
|
|
586
|
+
...forwardedAttributes,
|
|
503
587
|
...getPartAttrs("input", {
|
|
504
588
|
class: "rp-slider__native",
|
|
505
589
|
compatibilityClass,
|
|
506
590
|
compatibilityStyle
|
|
507
591
|
}),
|
|
508
|
-
onInput(
|
|
509
|
-
onInput(event);
|
|
510
|
-
compatibilityOnInput?.(event);
|
|
511
|
-
}
|
|
592
|
+
onInput: composeEventHandlers(onInput, inputAttrs.onInput)
|
|
512
593
|
};
|
|
513
594
|
});
|
|
514
|
-
function focus(options) {
|
|
515
|
-
inputRef.value?.focus(options);
|
|
516
|
-
}
|
|
517
595
|
__expose({
|
|
518
596
|
nativeElement: inputRef,
|
|
519
597
|
focus
|
|
@@ -599,8 +677,8 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
599
677
|
"aria-valuetext": unref(ariaValueText),
|
|
600
678
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs["aria-invalid"] : _control.invalid || void 0,
|
|
601
679
|
"aria-required": _props_required_nativeInputAttrs_required,
|
|
602
|
-
"data-disabled": unref(
|
|
603
|
-
"data-invalid": unref(
|
|
680
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
681
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
604
682
|
}]);
|
|
605
683
|
});
|
|
606
684
|
setInsertionState(n45, n47, 6);
|
|
@@ -614,7 +692,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
614
692
|
setDynamicProps(n31, [unref(getPartAttrs)("mark", {
|
|
615
693
|
class: ["rp-slider__mark", { "rp-slider__mark--filled": _mark.filled }],
|
|
616
694
|
style: _mark.style
|
|
617
|
-
}), { "data-filled": unref(
|
|
695
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
618
696
|
});
|
|
619
697
|
setInsertionState(n31, null, 1);
|
|
620
698
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -671,16 +749,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
671
749
|
}
|
|
672
750
|
});
|
|
673
751
|
});
|
|
674
|
-
n45
|
|
752
|
+
on(n45, "pointerdown", (e) => unref(onTooltipPointerDown)(e));
|
|
675
753
|
on(n45, "pointerenter", (e) => unref(onTooltipTrackEnter)(e));
|
|
676
754
|
on(n45, "pointerleave", (e) => unref(onTooltipTrackLeave)(e));
|
|
677
|
-
n45
|
|
678
|
-
n45
|
|
679
|
-
n45
|
|
680
|
-
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));
|
|
681
759
|
return n48;
|
|
682
760
|
}
|
|
683
|
-
}), [["__scopeId", "data-v-
|
|
761
|
+
}), [["__scopeId", "data-v-f21fa11c"]]);
|
|
684
762
|
//#endregion
|
|
685
763
|
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
686
764
|
var TOOLTIP_COLLISION_GAP = 4;
|
|
@@ -745,8 +823,6 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
745
823
|
height: 0
|
|
746
824
|
});
|
|
747
825
|
let resizeObserver;
|
|
748
|
-
let frameWindow;
|
|
749
|
-
let frameId;
|
|
750
826
|
let destroyed = false;
|
|
751
827
|
function setOverlapping(value) {
|
|
752
828
|
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
@@ -784,19 +860,9 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
784
860
|
};
|
|
785
861
|
updateCollision();
|
|
786
862
|
}
|
|
863
|
+
const measureScheduler = createRafScheduler(measureSizes, () => root.value?.ownerDocument.defaultView);
|
|
787
864
|
function scheduleMeasure() {
|
|
788
|
-
if (destroyed
|
|
789
|
-
const view = root.value?.ownerDocument.defaultView;
|
|
790
|
-
if (!view?.requestAnimationFrame) {
|
|
791
|
-
measureSizes();
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
frameWindow = view;
|
|
795
|
-
frameId = view.requestAnimationFrame(() => {
|
|
796
|
-
frameId = void 0;
|
|
797
|
-
frameWindow = void 0;
|
|
798
|
-
measureSizes();
|
|
799
|
-
});
|
|
865
|
+
if (!destroyed) measureScheduler.schedule();
|
|
800
866
|
}
|
|
801
867
|
function refreshObservedElements() {
|
|
802
868
|
if (!resizeObserver) return;
|
|
@@ -862,7 +928,7 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
862
928
|
destroyed = true;
|
|
863
929
|
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
864
930
|
resizeObserver?.disconnect();
|
|
865
|
-
|
|
931
|
+
measureScheduler.cancel();
|
|
866
932
|
});
|
|
867
933
|
return {
|
|
868
934
|
tooltipsOverlapping,
|
|
@@ -872,11 +938,11 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
872
938
|
}
|
|
873
939
|
//#endregion
|
|
874
940
|
//#region src/components/slider/range-slider-tooltip.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
875
|
-
var t0$1 = template("<span data-v-
|
|
876
|
-
var t1$1 = template("<span data-v-
|
|
877
|
-
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);
|
|
878
944
|
var t3$1 = template(" ");
|
|
879
|
-
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);
|
|
880
946
|
//#endregion
|
|
881
947
|
//#region src/components/slider/range-slider-tooltip.vue
|
|
882
948
|
var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -919,6 +985,10 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
919
985
|
},
|
|
920
986
|
emits: ["update:overlapping"],
|
|
921
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
|
+
};
|
|
922
992
|
const props = __props;
|
|
923
993
|
const emit = __emit;
|
|
924
994
|
const generatedId = useId();
|
|
@@ -933,7 +1003,7 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
933
1003
|
open: props.open
|
|
934
1004
|
}));
|
|
935
1005
|
const contentStyle = computed(() => ({
|
|
936
|
-
...
|
|
1006
|
+
...getFloatingOffsetStyle(props.offset, TOOLTIP_OFFSET_PROPERTIES),
|
|
937
1007
|
...resolveTooltipColorStyleWithContrast(props.color, props.autoContrast, props.contrastColor)
|
|
938
1008
|
}));
|
|
939
1009
|
const { tooltipsOverlapping, mergedArrowOffset, mergedMinSize } = useRangeSliderTooltipCollision({
|
|
@@ -1051,20 +1121,128 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
1051
1121
|
_setTemplateRef(n16, tooltipLayerRef, null, "tooltipLayerRef");
|
|
1052
1122
|
return n16;
|
|
1053
1123
|
}
|
|
1054
|
-
}), [["__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
|
+
}
|
|
1055
1240
|
//#endregion
|
|
1056
1241
|
//#region src/components/slider/useRangeSliderPointer.ts
|
|
1057
1242
|
function useRangeSliderPointer(options) {
|
|
1058
1243
|
let session;
|
|
1059
|
-
let frameWindow = null;
|
|
1060
|
-
let frameId;
|
|
1061
1244
|
let pendingPointerEvent;
|
|
1062
1245
|
let geometryDirty = false;
|
|
1063
|
-
function cancelScheduledFrame() {
|
|
1064
|
-
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
1065
|
-
frameWindow = null;
|
|
1066
|
-
frameId = void 0;
|
|
1067
|
-
}
|
|
1068
1246
|
function refreshGeometry() {
|
|
1069
1247
|
const currentSession = session;
|
|
1070
1248
|
if (!currentSession) return false;
|
|
@@ -1081,24 +1259,13 @@ function useRangeSliderPointer(options) {
|
|
|
1081
1259
|
pendingPointerEvent = void 0;
|
|
1082
1260
|
if (event && isCurrentPointer(event)) updateFromPointer(event);
|
|
1083
1261
|
}
|
|
1262
|
+
const updateScheduler = createRafScheduler(applyScheduledUpdate, () => session?.view);
|
|
1084
1263
|
function flushScheduledUpdate() {
|
|
1085
|
-
|
|
1086
|
-
applyScheduledUpdate();
|
|
1087
|
-
}
|
|
1088
|
-
function onAnimationFrame() {
|
|
1089
|
-
frameWindow = null;
|
|
1090
|
-
frameId = void 0;
|
|
1264
|
+
updateScheduler.cancel();
|
|
1091
1265
|
applyScheduledUpdate();
|
|
1092
1266
|
}
|
|
1093
1267
|
function scheduleUpdate() {
|
|
1094
|
-
|
|
1095
|
-
if (!view?.requestAnimationFrame) {
|
|
1096
|
-
flushScheduledUpdate();
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
if (frameId !== void 0) return;
|
|
1100
|
-
frameWindow = view;
|
|
1101
|
-
frameId = view.requestAnimationFrame(onAnimationFrame);
|
|
1268
|
+
if (session) updateScheduler.schedule();
|
|
1102
1269
|
}
|
|
1103
1270
|
function onGeometryChange() {
|
|
1104
1271
|
if (!session) return;
|
|
@@ -1113,7 +1280,7 @@ function useRangeSliderPointer(options) {
|
|
|
1113
1280
|
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
1114
1281
|
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
1115
1282
|
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
1116
|
-
|
|
1283
|
+
updateScheduler.cancel();
|
|
1117
1284
|
pendingPointerEvent = void 0;
|
|
1118
1285
|
geometryDirty = false;
|
|
1119
1286
|
session = void 0;
|
|
@@ -1136,7 +1303,7 @@ function useRangeSliderPointer(options) {
|
|
|
1136
1303
|
switchDraggingThumb(options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
1137
1304
|
}
|
|
1138
1305
|
function isCurrentPointer(event) {
|
|
1139
|
-
return
|
|
1306
|
+
return isMatchingPointer(event, session?.pointerId);
|
|
1140
1307
|
}
|
|
1141
1308
|
function onPointerMove(event) {
|
|
1142
1309
|
if (!isCurrentPointer(event)) return;
|
|
@@ -1168,7 +1335,7 @@ function useRangeSliderPointer(options) {
|
|
|
1168
1335
|
geometry,
|
|
1169
1336
|
thumb,
|
|
1170
1337
|
anchorValue: options.getAnchorValue(thumb),
|
|
1171
|
-
pointerId:
|
|
1338
|
+
pointerId: getPointerId(event)
|
|
1172
1339
|
};
|
|
1173
1340
|
options.startDrag(thumb);
|
|
1174
1341
|
switchDraggingThumb(options.updateThumb(thumb, pointerValue, session.anchorValue));
|
|
@@ -1281,55 +1448,132 @@ function useRangeSliderTooltipState(options) {
|
|
|
1281
1448
|
};
|
|
1282
1449
|
}
|
|
1283
1450
|
//#endregion
|
|
1284
|
-
//#region src/components/slider/
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
const
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
const
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
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
|
+
};
|
|
1332
1574
|
}
|
|
1575
|
+
//#endregion
|
|
1576
|
+
//#region src/components/slider/useRangeSlider.ts
|
|
1333
1577
|
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
1334
1578
|
const [lowerPercent, upperPercent] = valuePercent;
|
|
1335
1579
|
const style = {
|
|
@@ -1348,19 +1592,6 @@ function getRangeSliderTrackStyle(props, valuePercent) {
|
|
|
1348
1592
|
});
|
|
1349
1593
|
return style;
|
|
1350
1594
|
}
|
|
1351
|
-
function getFormattedRangeSliderValue(value, formatter) {
|
|
1352
|
-
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
1353
|
-
}
|
|
1354
|
-
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
1355
|
-
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
1356
|
-
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
1357
|
-
}
|
|
1358
|
-
function getThumbIndex(thumb) {
|
|
1359
|
-
return thumb === "lower" ? 0 : 1;
|
|
1360
|
-
}
|
|
1361
|
-
function getOppositeThumb(thumb) {
|
|
1362
|
-
return thumb === "lower" ? "upper" : "lower";
|
|
1363
|
-
}
|
|
1364
1595
|
function getThumbFromTarget(target) {
|
|
1365
1596
|
const thumb = target?.closest?.("[data-range-slider-thumb]")?.getAttribute("data-range-slider-thumb");
|
|
1366
1597
|
return thumb === "lower" || thumb === "upper" ? thumb : void 0;
|
|
@@ -1371,58 +1602,30 @@ function getThumbInput(track, thumb) {
|
|
|
1371
1602
|
function focusThumb(track, thumb) {
|
|
1372
1603
|
getThumbInput(track, thumb)?.focus({ preventScroll: true });
|
|
1373
1604
|
}
|
|
1374
|
-
function
|
|
1375
|
-
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) {
|
|
1376
1618
|
const activeThumb = ref();
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
const nativeStep = computed(() => {
|
|
1380
|
-
const step = valueStep.value;
|
|
1381
|
-
if (step === "any") return step;
|
|
1382
|
-
return isSliderStepAligned(bounds.value.min, bounds.value.max, step) ? step : "any";
|
|
1383
|
-
});
|
|
1384
|
-
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
1385
|
-
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
1386
|
-
const normalizedValue = computed(() => normalizeRangeSliderValue(getValue(), bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
1387
|
-
const valuePercent = computed(() => [getSliderValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getSliderValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
1388
|
-
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
1389
|
-
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
1390
|
-
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
1391
|
-
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
1392
|
-
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
1393
|
-
const nativeMin = computed(() => {
|
|
1394
|
-
if (normalizedMinRange.value === 0) return [bounds.value.min, bounds.value.min];
|
|
1395
|
-
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;
|
|
1396
1621
|
});
|
|
1397
|
-
const nativeMax = computed(() => {
|
|
1398
|
-
if (normalizedMinRange.value === 0) return [bounds.value.max, bounds.value.max];
|
|
1399
|
-
return [clamp(getStepValueAtOrBelow(normalizedValue.value[1] - normalizedMinRange.value, bounds.value.min, valueStep.value), bounds.value.min, bounds.value.max), bounds.value.max];
|
|
1400
|
-
});
|
|
1401
|
-
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1402
|
-
position: "--_rp-range-slider-mark-position",
|
|
1403
|
-
decorativeColors: ["--_rp-range-slider-mark-color", "--_rp-range-slider-mark-ring-color"],
|
|
1404
|
-
foregroundColors: ["--_rp-range-slider-mark-label-color", "--_rp-range-slider-mark-filled-label-color"]
|
|
1405
|
-
}));
|
|
1406
|
-
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
1407
|
-
const trackSlotProps = computed(() => ({
|
|
1408
|
-
value: normalizedValue.value,
|
|
1409
|
-
formattedValue: formattedValue.value,
|
|
1410
|
-
percent: valuePercent.value,
|
|
1411
|
-
min: bounds.value.min,
|
|
1412
|
-
max: bounds.value.max,
|
|
1413
|
-
orientation: props.orientation,
|
|
1414
|
-
getPercent(value) {
|
|
1415
|
-
return getSliderValuePercent(value, bounds.value.min, bounds.value.max);
|
|
1416
|
-
}
|
|
1417
|
-
}));
|
|
1418
|
-
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valuePercent.value));
|
|
1419
1622
|
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
1420
1623
|
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
1421
1624
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
1422
1625
|
const tooltipState = useRangeSliderTooltipState({
|
|
1423
1626
|
mode: tooltipMode,
|
|
1424
1627
|
openDelay: tooltipOpenDelay,
|
|
1425
|
-
disabled: () => control.disabled,
|
|
1628
|
+
disabled: () => valueState.control.disabled,
|
|
1426
1629
|
setActiveThumb: (thumb) => {
|
|
1427
1630
|
activeThumb.value = thumb;
|
|
1428
1631
|
}
|
|
@@ -1444,7 +1647,7 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1444
1647
|
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
1445
1648
|
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
1446
1649
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
1447
|
-
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])]);
|
|
1448
1651
|
const mergedTooltipContent = computed(() => {
|
|
1449
1652
|
const [lower, upper] = tooltipContent.value;
|
|
1450
1653
|
return lower === upper ? lower : `${lower}–${upper}`;
|
|
@@ -1452,46 +1655,13 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1452
1655
|
const rootClass = computed(() => bem("rp-range-slider", {
|
|
1453
1656
|
[`size-${props.size}`]: Boolean(props.size),
|
|
1454
1657
|
vertical: props.orientation === "vertical",
|
|
1455
|
-
marked: markItems.value.length > 0,
|
|
1456
|
-
"marks-with-labels": hasMarkLabels.value,
|
|
1658
|
+
marked: valueState.markItems.value.length > 0,
|
|
1659
|
+
"marks-with-labels": valueState.hasMarkLabels.value,
|
|
1457
1660
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
1458
|
-
disabled: control.disabled,
|
|
1459
|
-
invalid: control.invalid
|
|
1661
|
+
disabled: valueState.control.disabled,
|
|
1662
|
+
invalid: valueState.control.invalid
|
|
1460
1663
|
}));
|
|
1461
|
-
|
|
1462
|
-
const safeValue = normalizeSliderValue(value, bounds.value.min, bounds.value.max, valueStep.value);
|
|
1463
|
-
if (normalizedMinRange.value > 0) {
|
|
1464
|
-
const nextValue = [...normalizedValue.value];
|
|
1465
|
-
nextValue[getThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax.value[0]) : Math.max(safeValue, nativeMin.value[1]);
|
|
1466
|
-
return {
|
|
1467
|
-
thumb,
|
|
1468
|
-
value: nextValue
|
|
1469
|
-
};
|
|
1470
|
-
}
|
|
1471
|
-
if (safeValue < anchorValue) return {
|
|
1472
|
-
thumb: "lower",
|
|
1473
|
-
value: [safeValue, anchorValue]
|
|
1474
|
-
};
|
|
1475
|
-
if (safeValue > anchorValue) return {
|
|
1476
|
-
thumb: "upper",
|
|
1477
|
-
value: [anchorValue, safeValue]
|
|
1478
|
-
};
|
|
1479
|
-
return {
|
|
1480
|
-
thumb,
|
|
1481
|
-
value: [safeValue, safeValue]
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
|
-
function updateThumb(thumb, value, anchorValue) {
|
|
1485
|
-
if (control.disabled) return thumb;
|
|
1486
|
-
const update = getThumbUpdate(thumb, value, anchorValue);
|
|
1487
|
-
activeThumb.value = update.thumb;
|
|
1488
|
-
emitUpdate(update.value);
|
|
1489
|
-
return update.thumb;
|
|
1490
|
-
}
|
|
1491
|
-
function onInput(thumb, event) {
|
|
1492
|
-
const input = event.target;
|
|
1493
|
-
transferFocusedThumb(input, thumb, updateThumb(thumb, input.valueAsNumber));
|
|
1494
|
-
}
|
|
1664
|
+
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valueState.valuePercent.value));
|
|
1495
1665
|
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
1496
1666
|
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
1497
1667
|
const track = input.closest(".rp-range-slider__track");
|
|
@@ -1501,68 +1671,31 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1501
1671
|
tooltipState.transferInteraction(thumb, nextThumb, "focus");
|
|
1502
1672
|
nextInput.focus({ preventScroll: true });
|
|
1503
1673
|
}
|
|
1674
|
+
function onInput(thumb, event) {
|
|
1675
|
+
const input = event.target;
|
|
1676
|
+
transferFocusedThumb(input, thumb, valueState.updateThumb(thumb, input.valueAsNumber));
|
|
1677
|
+
}
|
|
1504
1678
|
function onTooltipKeydown(thumb, event) {
|
|
1505
1679
|
if (tooltipState.onKeydown(thumb, event)) return;
|
|
1506
|
-
if (!hasManualNativeKeyboard.value || valueStep.value === "any") return;
|
|
1507
|
-
const index =
|
|
1508
|
-
const
|
|
1509
|
-
const pageStep = valueStep.value * 10;
|
|
1510
|
-
let nextValue;
|
|
1511
|
-
switch (event.key) {
|
|
1512
|
-
case "ArrowRight":
|
|
1513
|
-
case "ArrowUp":
|
|
1514
|
-
nextValue = currentValue + valueStep.value;
|
|
1515
|
-
break;
|
|
1516
|
-
case "ArrowLeft":
|
|
1517
|
-
case "ArrowDown":
|
|
1518
|
-
nextValue = currentValue - valueStep.value;
|
|
1519
|
-
break;
|
|
1520
|
-
case "PageUp":
|
|
1521
|
-
nextValue = currentValue + pageStep;
|
|
1522
|
-
break;
|
|
1523
|
-
case "PageDown":
|
|
1524
|
-
nextValue = currentValue - pageStep;
|
|
1525
|
-
break;
|
|
1526
|
-
case "Home":
|
|
1527
|
-
nextValue = nativeMin.value[index];
|
|
1528
|
-
break;
|
|
1529
|
-
case "End":
|
|
1530
|
-
nextValue = nativeMax.value[index];
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
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]);
|
|
1533
1683
|
if (nextValue == null) return;
|
|
1534
1684
|
event.preventDefault();
|
|
1535
|
-
const nextThumb = updateThumb(thumb, nextValue);
|
|
1685
|
+
const nextThumb = valueState.updateThumb(thumb, nextValue);
|
|
1536
1686
|
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
1537
1687
|
}
|
|
1538
|
-
function getPointerGeometry(track) {
|
|
1539
|
-
const vertical = props.orientation === "vertical";
|
|
1540
|
-
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
1541
|
-
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
1542
|
-
const length = vertical ? rect.height : rect.width;
|
|
1543
|
-
if (length <= 0) return void 0;
|
|
1544
|
-
return {
|
|
1545
|
-
length,
|
|
1546
|
-
start: vertical ? rect.bottom : rect.left,
|
|
1547
|
-
vertical
|
|
1548
|
-
};
|
|
1549
|
-
}
|
|
1550
|
-
function getValueFromPointer(event, geometry) {
|
|
1551
|
-
const pointerPosition = geometry.vertical ? event.clientY : event.clientX;
|
|
1552
|
-
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1553
|
-
return bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
1554
|
-
}
|
|
1555
1688
|
const { onTrackPointerDown } = useRangeSliderPointer({
|
|
1556
|
-
disabled: () => control.disabled,
|
|
1557
|
-
getPointerGeometry,
|
|
1558
|
-
getPointerValue:
|
|
1559
|
-
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, normalizedValue.value, activeThumb.value),
|
|
1560
|
-
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))],
|
|
1561
1694
|
setActiveThumb: (thumb) => {
|
|
1562
1695
|
activeThumb.value = thumb;
|
|
1563
1696
|
},
|
|
1564
1697
|
focusThumb,
|
|
1565
|
-
updateThumb,
|
|
1698
|
+
updateThumb: valueState.updateThumb,
|
|
1566
1699
|
transferFocusedThumb: (track, from, to) => {
|
|
1567
1700
|
const input = getThumbInput(track, from);
|
|
1568
1701
|
if (input) transferFocusedThumb(input, from, to);
|
|
@@ -1572,20 +1705,23 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1572
1705
|
transferDrag: (from, to) => tooltipState.transferInteraction(from, to, "drag")
|
|
1573
1706
|
});
|
|
1574
1707
|
return {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
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,
|
|
1581
1717
|
rootClass,
|
|
1582
|
-
normalizedValue,
|
|
1583
|
-
valuePercent,
|
|
1584
|
-
formattedValue,
|
|
1585
|
-
ariaLabels,
|
|
1586
|
-
ariaValueText,
|
|
1587
|
-
markItems,
|
|
1588
|
-
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,
|
|
1589
1725
|
trackStyle,
|
|
1590
1726
|
activeThumb,
|
|
1591
1727
|
tooltipVisible,
|
|
@@ -1612,17 +1748,16 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1612
1748
|
}
|
|
1613
1749
|
//#endregion
|
|
1614
1750
|
//#region src/components/slider/range-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
1615
|
-
var t0 = template("<span data-v-
|
|
1616
|
-
var t1 = template("<span data-v-
|
|
1617
|
-
var t2 = template("<span data-v-
|
|
1618
|
-
var t3 = template("<span data-v-
|
|
1619
|
-
var t4 = template("<input data-v-
|
|
1620
|
-
var t5 = template("<span data-v-
|
|
1621
|
-
var t6 = template("<span data-v-
|
|
1622
|
-
var t7 = template("<span data-v-
|
|
1623
|
-
var t8 = template("<span data-v-
|
|
1624
|
-
var t9 = template("<div data-v-
|
|
1625
|
-
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);
|
|
1626
1761
|
//#endregion
|
|
1627
1762
|
//#region src/components/slider/range-slider.vue
|
|
1628
1763
|
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -1682,47 +1817,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1682
1817
|
const generatedId = useId();
|
|
1683
1818
|
const tooltipsOverlapping = ref(false);
|
|
1684
1819
|
const rangeSliderThumbs = ["lower", "upper"];
|
|
1685
|
-
const lowerInputRef = ref(null);
|
|
1686
|
-
const upperInputRef = ref(null);
|
|
1687
1820
|
const labelId = computed(() => `${props.id ?? generatedId}-label`);
|
|
1688
|
-
const
|
|
1689
|
-
modelValue: () => props.modelValue,
|
|
1690
|
-
defaultValue: () => props.defaultValue ?? [props.min, props.max],
|
|
1691
|
-
onChange: (value) => emit("update:modelValue", value)
|
|
1692
|
-
});
|
|
1693
|
-
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);
|
|
1694
|
-
const validationMessages = computed(() => Array.isArray(props.validationMessage) ? props.validationMessage : [props.validationMessage, props.validationMessage]);
|
|
1695
|
-
function normalizeInitialValue(value = controllable.initialValue) {
|
|
1696
|
-
return normalizeRangeSliderValue(value, props.min, props.max, props.step, props.minRange);
|
|
1697
|
-
}
|
|
1698
|
-
useFormControl({
|
|
1699
|
-
elements: () => [lowerInputRef.value, upperInputRef.value],
|
|
1700
|
-
isControlled: () => controllable.isControlled.value,
|
|
1701
|
-
initializeDefault(element, index) {
|
|
1702
|
-
const initialValue = normalizeInitialValue();
|
|
1703
|
-
element.defaultValue = String(initialValue[index]);
|
|
1704
|
-
},
|
|
1705
|
-
validationMessage: (_element, index) => validationMessages.value[index],
|
|
1706
|
-
readResetValue(elements) {
|
|
1707
|
-
const resetValue = [normalizedValue.value[0], normalizedValue.value[1]];
|
|
1708
|
-
for (const element of elements) {
|
|
1709
|
-
const index = element === upperInputRef.value ? 1 : 0;
|
|
1710
|
-
resetValue[index] = Number(element.defaultValue);
|
|
1711
|
-
}
|
|
1712
|
-
const nextValue = normalizeInitialValue(resetValue);
|
|
1713
|
-
controllable.resetValue(nextValue);
|
|
1714
|
-
nextTick(() => {
|
|
1715
|
-
if (lowerInputRef.value) lowerInputRef.value.value = String(nextValue[0]);
|
|
1716
|
-
if (upperInputRef.value) upperInputRef.value.value = String(nextValue[1]);
|
|
1717
|
-
});
|
|
1718
|
-
},
|
|
1719
|
-
syncControlledValue(elements) {
|
|
1720
|
-
for (const element of elements) {
|
|
1721
|
-
const index = element === upperInputRef.value ? 1 : 0;
|
|
1722
|
-
element.value = String(normalizedValue.value[index]);
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
});
|
|
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));
|
|
1726
1822
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
1727
1823
|
const rootAttrs = computed(() => getRootAttrs({
|
|
1728
1824
|
class: [rootClass.value, {
|
|
@@ -1732,8 +1828,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1732
1828
|
style: trackStyle.value,
|
|
1733
1829
|
role: "group",
|
|
1734
1830
|
"data-active-thumb": activeThumb.value || void 0,
|
|
1735
|
-
"data-disabled":
|
|
1736
|
-
"data-invalid":
|
|
1831
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
1832
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
1737
1833
|
"data-orientation": props.orientation,
|
|
1738
1834
|
"aria-labelledby": groupLabelledby.value,
|
|
1739
1835
|
"aria-describedby": control.ariaDescribedby,
|
|
@@ -1745,44 +1841,21 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1745
1841
|
return [props.inputAttrs, props.inputAttrs];
|
|
1746
1842
|
});
|
|
1747
1843
|
const nativeInputAttrs = computed(() => rangeSliderThumbs.map((thumb, index) => {
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1844
|
+
const inputAttrs = inputAttrsByThumb.value[index] ?? {};
|
|
1845
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
1846
|
+
return Object.assign({}, forwardedAttributes, {
|
|
1750
1847
|
...getPartAttrs("input", {
|
|
1751
1848
|
class: ["rp-range-slider__native", `rp-range-slider__native--${thumb}`],
|
|
1752
1849
|
compatibilityClass,
|
|
1753
1850
|
compatibilityStyle
|
|
1754
1851
|
}),
|
|
1755
|
-
onInput(event)
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
onFocus(event) {
|
|
1760
|
-
onTooltipFocus(thumb);
|
|
1761
|
-
compatibilityOnFocus?.(event);
|
|
1762
|
-
},
|
|
1763
|
-
onBlur(event) {
|
|
1764
|
-
onTooltipBlur(thumb);
|
|
1765
|
-
compatibilityOnBlur?.(event);
|
|
1766
|
-
},
|
|
1767
|
-
onKeydown(event) {
|
|
1768
|
-
onTooltipKeydown(thumb, event);
|
|
1769
|
-
compatibilityOnKeydown?.(event);
|
|
1770
|
-
}
|
|
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)
|
|
1771
1856
|
});
|
|
1772
1857
|
}));
|
|
1773
|
-
const
|
|
1774
|
-
function setInputRef(index, element) {
|
|
1775
|
-
const input = element instanceof HTMLInputElement ? element : null;
|
|
1776
|
-
if (index === 0) lowerInputRef.value = input;
|
|
1777
|
-
else upperInputRef.value = input;
|
|
1778
|
-
}
|
|
1779
|
-
function focus(options) {
|
|
1780
|
-
lowerInputRef.value?.focus(options);
|
|
1781
|
-
}
|
|
1782
|
-
const groupLabelledby = computed(() => {
|
|
1783
|
-
const values = [control.ariaLabelledby, slots.default ? labelId.value : void 0].flatMap((value) => value?.split(/\s+/) ?? []).filter(Boolean);
|
|
1784
|
-
return values.length ? Array.from(new Set(values)).join(" ") : void 0;
|
|
1785
|
-
});
|
|
1858
|
+
const groupLabelledby = computed(() => mergeAriaIdRefs(control.ariaLabelledby, slots.default ? labelId.value : void 0));
|
|
1786
1859
|
__expose({
|
|
1787
1860
|
nativeElements,
|
|
1788
1861
|
focus
|
|
@@ -1865,10 +1938,10 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1865
1938
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs_index?.["aria-invalid"] : _control.invalid || void 0,
|
|
1866
1939
|
"aria-required": _props_required_nativeInputAttrs_index_required,
|
|
1867
1940
|
"data-thumb": _for_item0.value,
|
|
1868
|
-
"data-disabled": unref(
|
|
1869
|
-
"data-invalid": unref(
|
|
1941
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
1942
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
1870
1943
|
}]);
|
|
1871
|
-
_setTemplateRef(n22, (element) => setInputRef(_index, element), true);
|
|
1944
|
+
_setTemplateRef(n22, (element) => unref(setInputRef)(_index, element), true);
|
|
1872
1945
|
});
|
|
1873
1946
|
return n22;
|
|
1874
1947
|
}, (thumb, index) => thumb, 8);
|
|
@@ -1883,7 +1956,7 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1883
1956
|
setDynamicProps(n30, [unref(getPartAttrs)("mark", {
|
|
1884
1957
|
class: ["rp-range-slider__mark", { "rp-range-slider__mark--filled": _mark.filled }],
|
|
1885
1958
|
style: _mark.style
|
|
1886
|
-
}), { "data-filled": unref(
|
|
1959
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
1887
1960
|
});
|
|
1888
1961
|
setInsertionState(n30, null, 1);
|
|
1889
1962
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -1942,12 +2015,12 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1942
2015
|
"onUpdate:overlapping": () => _on_update_overlapping
|
|
1943
2016
|
});
|
|
1944
2017
|
});
|
|
1945
|
-
n42
|
|
2018
|
+
on(n42, "pointerdown", (e) => unref(onTrackPointerDown)(e));
|
|
1946
2019
|
on(n42, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1947
2020
|
on(n42, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1948
2021
|
return n44;
|
|
1949
2022
|
}
|
|
1950
|
-
}), [["__scopeId", "data-v-
|
|
2023
|
+
}), [["__scopeId", "data-v-e27ae1af"]]);
|
|
1951
2024
|
//#endregion
|
|
1952
2025
|
//#region src/components/slider/types.ts
|
|
1953
2026
|
var sliderParts = [
|