ropav 0.1.6 → 0.1.8
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 +7 -1
- 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/ancestry.js +136 -0
- 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/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/chevron-left.js +12 -0
- 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 +247 -276
- 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/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- 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/calendar/calendar.d.ts +30 -0
- package/dist/components/calendar/calendarBehavior.d.ts +49 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/types.d.ts +53 -0
- package/dist/components/calendar/useCalendar.d.ts +24 -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/useColorPickerDrag.d.ts +1 -1
- 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/combobox/combobox.d.ts +29 -0
- package/dist/components/combobox/comboboxModel.d.ts +4 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/types.d.ts +43 -0
- package/dist/components/combobox/useCombobox.d.ts +45 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/datePickerModel.d.ts +10 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/types.d.ts +57 -0
- package/dist/components/date-picker/useDatePicker.d.ts +29 -0
- package/dist/components/date-picker/useDatePickerValueState.d.ts +21 -0
- 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-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -30
- 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 +114 -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 +35 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +24 -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 +28 -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/dropzone/dropzone.d.ts +31 -0
- package/dist/components/dropzone/dropzoneModel.d.ts +16 -0
- package/dist/components/dropzone/index.d.ts +3 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/types.d.ts +56 -0
- package/dist/components/dropzone/useDropzone.d.ts +25 -0
- package/dist/components/file-input/file-input.d.ts +29 -0
- package/dist/components/file-input/index.d.ts +3 -0
- package/dist/components/file-input/index.js +2 -0
- package/dist/components/file-input/types.d.ts +37 -0
- package/dist/components/file-input/useFileInput.d.ts +15 -0
- package/dist/components/floating/index.js +2 -2
- package/dist/components/floating/useFloatingPosition.d.ts +1 -14
- package/dist/components/floating/useFloatingTargetLifecycle.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +10 -0
- package/dist/components/hover-card/hover-card.d.ts +25 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +2 -0
- package/dist/components/hover-card/types.d.ts +45 -0
- package/dist/components/hover-card/useHoverCard.d.ts +22 -0
- package/dist/components/hover-card/useHoverCardDisclosure.d.ts +19 -0
- package/dist/components/multi-select/index.d.ts +3 -0
- package/dist/components/multi-select/index.js +2 -0
- package/dist/components/multi-select/multi-select.d.ts +30 -0
- package/dist/components/multi-select/multiSelectModel.d.ts +3 -0
- package/dist/components/multi-select/types.d.ts +49 -0
- package/dist/components/multi-select/useMultiSelect.d.ts +46 -0
- package/dist/components/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -19
- 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 +13 -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 +11 -9
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +26 -0
- package/dist/components/segmented-control/types.d.ts +47 -0
- package/dist/components/segmented-control/useSegmentedControl.d.ts +15 -0
- package/dist/components/select/useSelect.d.ts +31 -19
- 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 +9 -17
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- 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/tags-input/index.d.ts +3 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags-input.d.ts +27 -0
- package/dist/components/tags-input/tagsInputModel.d.ts +12 -0
- package/dist/components/tags-input/types.d.ts +37 -0
- package/dist/components/tags-input/useTagsInput.d.ts +23 -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/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/css.js +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +215 -218
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +1626 -1185
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +2 -2
- package/dist/multi-select.css +316 -0
- package/dist/multi-select.js +481 -0
- package/dist/nativeChoice.js +169 -0
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +44 -44
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +66 -73
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +55 -37
- package/dist/popover.js +75 -101
- 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 +540 -554
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +131 -289
- package/dist/slider.css +191 -191
- package/dist/slider.js +720 -706
- 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/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- 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 +64 -63
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +14 -40
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/useHoverDisclosure.js +561 -0
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -19
- 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/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +8 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +24 -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/optionFilter.d.ts +5 -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 +13 -9
- package/docs/public-styles-api.md +25 -12
- package/package.json +51 -14
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- 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/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/floating.js +0 -415
- /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 { t as createRafScheduler } from "./rafScheduler.js";
|
|
15
|
+
import { t as createPointerSession } from "./pointerSession.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,129 +112,150 @@ 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
|
-
|
|
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();
|
|
118
120
|
}
|
|
119
|
-
function
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
function useSliderPointerPreview(options) {
|
|
122
|
+
const dragging = ref(false);
|
|
123
|
+
const previewAvailable = ref(false);
|
|
124
|
+
const previewValue = ref(options.initialValue);
|
|
125
|
+
let disposing = false;
|
|
126
|
+
let pendingPreview;
|
|
127
|
+
const previewScheduler = createRafScheduler(applyScheduledPreview, () => pendingPreview?.track.ownerDocument.defaultView);
|
|
128
|
+
function updateFromPointer(pointer, track) {
|
|
129
|
+
if (!options.enabled() || options.disabled()) return false;
|
|
130
|
+
const vertical = options.orientation() === "vertical";
|
|
131
|
+
const rect = getPreviewRect(track, vertical);
|
|
132
|
+
const length = vertical ? rect.height : rect.width;
|
|
133
|
+
if (length <= 0) return false;
|
|
134
|
+
const ratio = clamp((vertical ? rect.bottom - pointer.clientY : pointer.clientX - rect.left) / length, 0, 1);
|
|
135
|
+
const bounds = options.bounds.value;
|
|
136
|
+
const rawValue = bounds.min + ratio * (bounds.max - bounds.min);
|
|
137
|
+
previewValue.value = normalizeSliderValue(rawValue, bounds.min, bounds.max, options.step.value);
|
|
138
|
+
previewAvailable.value = true;
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
function applyScheduledPreview() {
|
|
142
|
+
const pending = pendingPreview;
|
|
143
|
+
pendingPreview = void 0;
|
|
144
|
+
if (pending && updateFromPointer(pending, pending.track)) options.onStateChange();
|
|
145
|
+
}
|
|
146
|
+
function schedulePreview(event, track) {
|
|
147
|
+
if (!options.enabled() || options.disabled()) return;
|
|
148
|
+
pendingPreview = {
|
|
149
|
+
clientX: event.clientX,
|
|
150
|
+
clientY: event.clientY,
|
|
151
|
+
track
|
|
152
|
+
};
|
|
153
|
+
previewScheduler.schedule();
|
|
154
|
+
}
|
|
155
|
+
function cancelScheduledPreview() {
|
|
156
|
+
previewScheduler.cancel();
|
|
157
|
+
pendingPreview = void 0;
|
|
158
|
+
}
|
|
159
|
+
const pointerSession = createPointerSession({
|
|
160
|
+
endUpdate: "event",
|
|
161
|
+
onStart(event, track) {
|
|
162
|
+
cancelScheduledPreview();
|
|
163
|
+
dragging.value = true;
|
|
164
|
+
updateFromPointer(event, track);
|
|
165
|
+
},
|
|
166
|
+
onStop() {
|
|
167
|
+
dragging.value = false;
|
|
168
|
+
if (!disposing) options.onStateChange();
|
|
169
|
+
},
|
|
170
|
+
onUpdate(event, track) {
|
|
171
|
+
if (updateFromPointer(event, track) && event.type === "pointermove") options.onStateChange();
|
|
172
|
+
}
|
|
132
173
|
});
|
|
133
|
-
|
|
174
|
+
function onPointerMove(event) {
|
|
175
|
+
if (dragging.value) return;
|
|
176
|
+
const track = event.currentTarget;
|
|
177
|
+
if (track) schedulePreview(event, track);
|
|
178
|
+
}
|
|
179
|
+
function onPointerDown(event) {
|
|
180
|
+
return pointerSession.start(event, () => {
|
|
181
|
+
if (options.disabled()) return;
|
|
182
|
+
const track = event.currentTarget;
|
|
183
|
+
if (!track) return;
|
|
184
|
+
return {
|
|
185
|
+
state: track,
|
|
186
|
+
target: track
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function onTrackEnter(event) {
|
|
191
|
+
if (!options.enabled()) return;
|
|
192
|
+
cancelScheduledPreview();
|
|
193
|
+
previewAvailable.value = false;
|
|
194
|
+
const track = event.currentTarget;
|
|
195
|
+
if (track) updateFromPointer(event, track);
|
|
196
|
+
}
|
|
197
|
+
function onTrackLeave() {
|
|
198
|
+
if (!dragging.value && options.enabled()) cancelScheduledPreview();
|
|
199
|
+
}
|
|
200
|
+
onBeforeUnmount(() => {
|
|
201
|
+
disposing = true;
|
|
202
|
+
pointerSession.stop();
|
|
203
|
+
cancelScheduledPreview();
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
dragging,
|
|
207
|
+
previewAvailable,
|
|
208
|
+
previewValue,
|
|
209
|
+
onPointerDown,
|
|
210
|
+
onPointerMove,
|
|
211
|
+
onTrackEnter,
|
|
212
|
+
onTrackLeave
|
|
213
|
+
};
|
|
134
214
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
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));
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/components/slider/useSliderTooltipState.ts
|
|
217
|
+
function useSliderTooltipState(options) {
|
|
218
|
+
const tooltipOptions = computed(() => getSliderTooltipOptions(options.tooltip()));
|
|
219
|
+
const tooltipAnchor = computed(() => getSliderTooltipAnchor(options.tooltip()));
|
|
220
|
+
const tooltipMode = computed(() => getSliderTooltipMode(options.tooltip()));
|
|
151
221
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
152
|
-
const
|
|
222
|
+
const delayedTooltip = useDelayedOpen({
|
|
153
223
|
openDelay: () => tooltipOpenDelay.value,
|
|
154
|
-
disabled: () => tooltipMode.value !== "hover" ||
|
|
224
|
+
disabled: () => tooltipMode.value !== "hover" || options.disabled()
|
|
155
225
|
});
|
|
156
226
|
const trackHovered = ref(false);
|
|
157
227
|
const focusWithin = ref(false);
|
|
158
|
-
const dragging = ref(false);
|
|
159
|
-
const previewAvailable = ref(false);
|
|
160
|
-
const previewValue = ref(normalizedValue.value);
|
|
161
228
|
let dismissed = false;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
value: normalizedValue.value,
|
|
172
|
-
formattedValue: formattedValue.value,
|
|
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
|
-
}
|
|
229
|
+
const pointerPreview = useSliderPointerPreview({
|
|
230
|
+
enabled: () => tooltipAnchor.value === "pointer",
|
|
231
|
+
disabled: options.disabled,
|
|
232
|
+
orientation: options.orientation,
|
|
233
|
+
bounds: options.bounds,
|
|
234
|
+
step: options.step,
|
|
235
|
+
initialValue: options.value.value,
|
|
236
|
+
onStateChange: syncTooltip
|
|
237
|
+
});
|
|
212
238
|
function hasTooltipInteraction() {
|
|
213
|
-
if (tooltipAnchor.value === "pointer") return previewAvailable.value && (trackHovered.value || dragging.value);
|
|
214
|
-
return trackHovered.value || focusWithin.value || dragging.value;
|
|
239
|
+
if (tooltipAnchor.value === "pointer") return pointerPreview.previewAvailable.value && (trackHovered.value || pointerPreview.dragging.value);
|
|
240
|
+
return trackHovered.value || focusWithin.value || pointerPreview.dragging.value;
|
|
215
241
|
}
|
|
216
242
|
function syncTooltip() {
|
|
217
|
-
if (tooltipMode.value === "hover" && !
|
|
218
|
-
|
|
243
|
+
if (tooltipMode.value === "hover" && !options.disabled() && hasTooltipInteraction() && !dismissed) {
|
|
244
|
+
delayedTooltip.open();
|
|
219
245
|
return;
|
|
220
246
|
}
|
|
221
|
-
|
|
247
|
+
delayedTooltip.closeImmediate();
|
|
222
248
|
}
|
|
223
249
|
function onTooltipTrackEnter(event) {
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
cancelScheduledPreview();
|
|
227
|
-
previewAvailable.value = false;
|
|
228
|
-
const track = event.currentTarget;
|
|
229
|
-
if (track) updatePreviewFromPointer(event, track);
|
|
230
|
-
}
|
|
250
|
+
if (options.disabled()) return;
|
|
251
|
+
pointerPreview.onTrackEnter(event);
|
|
231
252
|
trackHovered.value = true;
|
|
232
253
|
dismissed = false;
|
|
233
254
|
syncTooltip();
|
|
234
255
|
}
|
|
235
256
|
function onTooltipTrackLeave() {
|
|
236
257
|
trackHovered.value = false;
|
|
237
|
-
|
|
258
|
+
pointerPreview.onTrackLeave();
|
|
238
259
|
syncTooltip();
|
|
239
260
|
}
|
|
240
261
|
function onTooltipFocusIn() {
|
|
@@ -246,120 +267,36 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
246
267
|
focusWithin.value = false;
|
|
247
268
|
syncTooltip();
|
|
248
269
|
}
|
|
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;
|
|
269
|
-
const length = vertical ? rect.height : rect.width;
|
|
270
|
-
if (length <= 0) return false;
|
|
271
|
-
const offset = vertical ? rect.bottom - pointer.clientY : pointer.clientX - rect.left;
|
|
272
|
-
const ratio = Math.min(1, Math.max(0, offset / length));
|
|
273
|
-
const rawValue = bounds.value.min + ratio * (bounds.value.max - bounds.value.min);
|
|
274
|
-
previewValue.value = normalizeSliderValue(rawValue, bounds.value.min, bounds.value.max, nativeStep.value);
|
|
275
|
-
previewAvailable.value = true;
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
function applyScheduledPreview() {
|
|
279
|
-
const pending = pendingPreview;
|
|
280
|
-
pendingPreview = void 0;
|
|
281
|
-
if (pending && updatePreviewFromPointer(pending, pending.track)) syncTooltip();
|
|
282
|
-
}
|
|
283
|
-
function onPreviewAnimationFrame() {
|
|
284
|
-
previewFrameView = null;
|
|
285
|
-
previewFrameId = void 0;
|
|
286
|
-
applyScheduledPreview();
|
|
287
|
-
}
|
|
288
|
-
function schedulePreview(event, track) {
|
|
289
|
-
if (tooltipAnchor.value !== "pointer" || control.disabled) return;
|
|
290
|
-
pendingPreview = {
|
|
291
|
-
clientX: event.clientX,
|
|
292
|
-
clientY: event.clientY,
|
|
293
|
-
track
|
|
294
|
-
};
|
|
295
|
-
const view = track.ownerDocument.defaultView;
|
|
296
|
-
if (!view?.requestAnimationFrame) {
|
|
297
|
-
applyScheduledPreview();
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (previewFrameId !== void 0) return;
|
|
301
|
-
previewFrameView = view;
|
|
302
|
-
previewFrameId = view.requestAnimationFrame(onPreviewAnimationFrame);
|
|
303
|
-
}
|
|
304
|
-
function onTooltipPointerMove(event) {
|
|
305
|
-
if (dragPointerId !== void 0 && dragging.value && event.pointerId !== dragPointerId) return;
|
|
306
|
-
const track = event.currentTarget;
|
|
307
|
-
if (track) schedulePreview(event, track);
|
|
308
|
-
}
|
|
309
|
-
function onTooltipWindowPointerMove(event) {
|
|
310
|
-
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
311
|
-
if (dragTrack) schedulePreview(event, dragTrack);
|
|
312
|
-
}
|
|
313
|
-
function onTooltipPointerEnd(event) {
|
|
314
|
-
if (dragPointerId !== void 0 && event.pointerId !== dragPointerId) return;
|
|
315
|
-
cancelScheduledPreview();
|
|
316
|
-
if (dragTrack) updatePreviewFromPointer(event, dragTrack);
|
|
317
|
-
dragging.value = false;
|
|
318
|
-
removeDragListeners();
|
|
319
|
-
syncTooltip();
|
|
320
|
-
}
|
|
321
270
|
function onTooltipPointerDown(event) {
|
|
322
|
-
if (
|
|
323
|
-
removeDragListeners();
|
|
271
|
+
if (!pointerPreview.onPointerDown(event)) return;
|
|
324
272
|
dismissed = false;
|
|
325
|
-
dragging.value = true;
|
|
326
|
-
dragPointerId = Number.isFinite(event.pointerId) ? event.pointerId : void 0;
|
|
327
|
-
dragTrack = event.currentTarget;
|
|
328
|
-
if (dragTrack) updatePreviewFromPointer(event, dragTrack);
|
|
329
|
-
dragView = dragTrack?.ownerDocument.defaultView ?? null;
|
|
330
|
-
dragView?.addEventListener("pointermove", onTooltipWindowPointerMove);
|
|
331
|
-
dragView?.addEventListener("pointerup", onTooltipPointerEnd);
|
|
332
|
-
dragView?.addEventListener("pointercancel", onTooltipPointerEnd);
|
|
333
273
|
syncTooltip();
|
|
334
274
|
}
|
|
335
275
|
function onTooltipKeydown(event) {
|
|
336
|
-
if (event.key
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
276
|
+
if (event.key !== "Escape") return;
|
|
277
|
+
dismissed = true;
|
|
278
|
+
delayedTooltip.closeImmediate();
|
|
340
279
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
280
|
+
const tooltipVisible = computed(() => tooltipMode.value !== false);
|
|
281
|
+
const tooltipAlwaysVisible = computed(() => tooltipMode.value === "always");
|
|
282
|
+
const tooltipOpen = computed(() => tooltipAlwaysVisible.value || tooltipMode.value === "hover" && delayedTooltip.isOpen.value && !options.disabled());
|
|
283
|
+
const tooltipPlacement = computed(() => tooltipOptions.value.placement ?? (options.orientation() === "vertical" ? "left" : "top"));
|
|
284
|
+
const tooltipId = computed(() => tooltipOptions.value.id);
|
|
285
|
+
const tooltipColor = computed(() => tooltipOptions.value.color);
|
|
286
|
+
const tooltipAutoContrast = computed(() => tooltipOptions.value.autoContrast);
|
|
287
|
+
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
288
|
+
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
289
|
+
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
290
|
+
const tooltipValue = computed(() => tooltipAnchor.value === "pointer" && pointerPreview.previewAvailable.value ? pointerPreview.previewValue.value : options.value.value);
|
|
291
|
+
const tooltipPercent = computed(() => getValuePercent(tooltipValue.value, options.bounds.value.min, options.bounds.value.max));
|
|
292
|
+
const tooltipFormattedValue = computed(() => getFormattedSliderValue(tooltipValue.value, options.formatValue()));
|
|
293
|
+
const tooltipContent = computed(() => String(tooltipFormattedValue.value));
|
|
345
294
|
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
295
|
trackHovered,
|
|
360
|
-
dragging,
|
|
296
|
+
dragging: pointerPreview.dragging,
|
|
361
297
|
tooltipVisible,
|
|
362
298
|
tooltipOpen,
|
|
299
|
+
tooltipAlwaysVisible,
|
|
363
300
|
tooltipAnchor,
|
|
364
301
|
tooltipPlacement,
|
|
365
302
|
tooltipId,
|
|
@@ -373,9 +310,8 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
373
310
|
tooltipPercent,
|
|
374
311
|
tooltipFormattedValue,
|
|
375
312
|
tooltipContent,
|
|
376
|
-
onInput,
|
|
377
313
|
onTooltipPointerDown,
|
|
378
|
-
onTooltipPointerMove,
|
|
314
|
+
onTooltipPointerMove: pointerPreview.onPointerMove,
|
|
379
315
|
onTooltipTrackEnter,
|
|
380
316
|
onTooltipTrackLeave,
|
|
381
317
|
onTooltipFocusIn,
|
|
@@ -384,19 +320,178 @@ function useSlider(props, emitUpdate, getValue = () => props.modelValue ?? props
|
|
|
384
320
|
};
|
|
385
321
|
}
|
|
386
322
|
//#endregion
|
|
323
|
+
//#region src/components/slider/useSliderValueState.ts
|
|
324
|
+
function useSliderValueState(props, onChange) {
|
|
325
|
+
const inputRef = ref(null);
|
|
326
|
+
const controllable = useControllableValue({
|
|
327
|
+
modelValue: () => props.modelValue,
|
|
328
|
+
defaultValue: () => props.defaultValue ?? props.min,
|
|
329
|
+
onChange
|
|
330
|
+
});
|
|
331
|
+
const control = useControlState(props);
|
|
332
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
333
|
+
const nativeMin = computed(() => bounds.value.min);
|
|
334
|
+
const nativeMax = computed(() => bounds.value.max);
|
|
335
|
+
const nativeStep = computed(() => normalizeSliderStep(props.step));
|
|
336
|
+
const normalizedValue = computed(() => normalizeSliderValue(controllable.value.value, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
337
|
+
const valuePercent = computed(() => getValuePercent(normalizedValue.value, bounds.value.min, bounds.value.max));
|
|
338
|
+
const formattedValue = computed(() => getFormattedSliderValue(normalizedValue.value, props.formatValue));
|
|
339
|
+
const ariaValueText = computed(() => getSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
340
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (_value, percent) => percent <= valuePercent.value, {
|
|
341
|
+
position: "--_rp-slider-mark-position",
|
|
342
|
+
decorativeColors: ["--_rp-slider-mark-color", "--_rp-slider-mark-ring-color"],
|
|
343
|
+
foregroundColors: ["--_rp-slider-mark-label-color", "--_rp-slider-mark-filled-label-color"]
|
|
344
|
+
}));
|
|
345
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
346
|
+
const trackSlotProps = computed(() => ({
|
|
347
|
+
value: normalizedValue.value,
|
|
348
|
+
formattedValue: formattedValue.value,
|
|
349
|
+
percent: valuePercent.value,
|
|
350
|
+
min: bounds.value.min,
|
|
351
|
+
max: bounds.value.max,
|
|
352
|
+
orientation: props.orientation,
|
|
353
|
+
getPercent(value) {
|
|
354
|
+
return getValuePercent(value, bounds.value.min, bounds.value.max);
|
|
355
|
+
}
|
|
356
|
+
}));
|
|
357
|
+
function onInput(event) {
|
|
358
|
+
if (control.disabled) return;
|
|
359
|
+
const input = event.target;
|
|
360
|
+
controllable.setValue(normalizeSliderValue(input.valueAsNumber, bounds.value.min, bounds.value.max, nativeStep.value));
|
|
361
|
+
}
|
|
362
|
+
useFormControl({
|
|
363
|
+
elements: () => [inputRef.value],
|
|
364
|
+
isControlled: () => controllable.isControlled.value,
|
|
365
|
+
initializeDefault(element) {
|
|
366
|
+
element.defaultValue = String(normalizeSliderValue(controllable.initialValue, nativeMin.value, nativeMax.value, nativeStep.value));
|
|
367
|
+
},
|
|
368
|
+
validationMessage: () => props.validationMessage,
|
|
369
|
+
readResetValue(elements) {
|
|
370
|
+
controllable.resetValue(elements[0].valueAsNumber);
|
|
371
|
+
},
|
|
372
|
+
syncControlledValue(elements) {
|
|
373
|
+
elements[0].value = String(normalizedValue.value);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
function focus(options) {
|
|
377
|
+
inputRef.value?.focus(options);
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
inputRef,
|
|
381
|
+
focus,
|
|
382
|
+
control,
|
|
383
|
+
bounds,
|
|
384
|
+
nativeMin,
|
|
385
|
+
nativeMax,
|
|
386
|
+
nativeStep,
|
|
387
|
+
normalizedValue,
|
|
388
|
+
valuePercent,
|
|
389
|
+
formattedValue,
|
|
390
|
+
ariaValueText,
|
|
391
|
+
markItems,
|
|
392
|
+
hasMarkLabels,
|
|
393
|
+
trackSlotProps,
|
|
394
|
+
onInput
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/components/slider/useSlider.ts
|
|
399
|
+
function getSliderTrackStyle(props, valuePercent, tooltipPercent) {
|
|
400
|
+
const style = {
|
|
401
|
+
"--_rp-slider-percent": `${valuePercent}%`,
|
|
402
|
+
"--_rp-slider-ratio": `${valuePercent / 100}`,
|
|
403
|
+
"--_rp-slider-tooltip-percent": `${tooltipPercent}%`,
|
|
404
|
+
"--_rp-slider-tooltip-ratio": `${tooltipPercent / 100}`
|
|
405
|
+
};
|
|
406
|
+
setSliderStyleValue(style, "--_rp-slider-color", getComponentColorValue(props.color));
|
|
407
|
+
applySliderThumbStyle(style, getSliderThumbOptions(props.thumb), {
|
|
408
|
+
size: "--rp-slider-thumb-size",
|
|
409
|
+
border: "--_rp-slider-thumb-border-style",
|
|
410
|
+
padding: "--rp-slider-thumb-padding",
|
|
411
|
+
borderColor: "--_rp-slider-thumb-border"
|
|
412
|
+
});
|
|
413
|
+
return style;
|
|
414
|
+
}
|
|
415
|
+
function useSlider(props, onChange) {
|
|
416
|
+
const valueState = useSliderValueState(props, onChange);
|
|
417
|
+
const tooltipState = useSliderTooltipState({
|
|
418
|
+
tooltip: () => props.tooltip,
|
|
419
|
+
orientation: () => props.orientation,
|
|
420
|
+
disabled: () => valueState.control.disabled,
|
|
421
|
+
value: valueState.normalizedValue,
|
|
422
|
+
bounds: valueState.bounds,
|
|
423
|
+
step: valueState.nativeStep,
|
|
424
|
+
formatValue: () => props.formatValue
|
|
425
|
+
});
|
|
426
|
+
const thumbMode = computed(() => getSliderThumbMode(props.thumb));
|
|
427
|
+
const rootClass = computed(() => bem("rp-slider", {
|
|
428
|
+
[`size-${props.size}`]: Boolean(props.size),
|
|
429
|
+
vertical: props.orientation === "vertical",
|
|
430
|
+
marked: valueState.markItems.value.length > 0,
|
|
431
|
+
"marks-with-labels": valueState.hasMarkLabels.value,
|
|
432
|
+
"tooltip-always-visible": tooltipState.tooltipAlwaysVisible.value,
|
|
433
|
+
"thumb-interaction": thumbMode.value === "interaction",
|
|
434
|
+
"thumb-hidden": thumbMode.value === false,
|
|
435
|
+
disabled: valueState.control.disabled,
|
|
436
|
+
invalid: valueState.control.invalid
|
|
437
|
+
}));
|
|
438
|
+
const trackStyle = computed(() => getSliderTrackStyle(props, valueState.valuePercent.value, tooltipState.tooltipPercent.value));
|
|
439
|
+
return {
|
|
440
|
+
inputRef: valueState.inputRef,
|
|
441
|
+
focus: valueState.focus,
|
|
442
|
+
control: valueState.control,
|
|
443
|
+
nativeMin: valueState.nativeMin,
|
|
444
|
+
nativeMax: valueState.nativeMax,
|
|
445
|
+
nativeStep: valueState.nativeStep,
|
|
446
|
+
rootClass,
|
|
447
|
+
normalizedValue: valueState.normalizedValue,
|
|
448
|
+
valuePercent: valueState.valuePercent,
|
|
449
|
+
formattedValue: valueState.formattedValue,
|
|
450
|
+
ariaValueText: valueState.ariaValueText,
|
|
451
|
+
markItems: valueState.markItems,
|
|
452
|
+
thumbMode,
|
|
453
|
+
trackSlotProps: valueState.trackSlotProps,
|
|
454
|
+
trackStyle,
|
|
455
|
+
trackHovered: tooltipState.trackHovered,
|
|
456
|
+
dragging: tooltipState.dragging,
|
|
457
|
+
tooltipVisible: tooltipState.tooltipVisible,
|
|
458
|
+
tooltipOpen: tooltipState.tooltipOpen,
|
|
459
|
+
tooltipAnchor: tooltipState.tooltipAnchor,
|
|
460
|
+
tooltipPlacement: tooltipState.tooltipPlacement,
|
|
461
|
+
tooltipId: tooltipState.tooltipId,
|
|
462
|
+
tooltipColor: tooltipState.tooltipColor,
|
|
463
|
+
tooltipAutoContrast: tooltipState.tooltipAutoContrast,
|
|
464
|
+
tooltipContrastColor: tooltipState.tooltipContrastColor,
|
|
465
|
+
tooltipOffset: tooltipState.tooltipOffset,
|
|
466
|
+
tooltipOpenDelay: tooltipState.tooltipOpenDelay,
|
|
467
|
+
tooltipArrow: tooltipState.tooltipArrow,
|
|
468
|
+
tooltipValue: tooltipState.tooltipValue,
|
|
469
|
+
tooltipPercent: tooltipState.tooltipPercent,
|
|
470
|
+
tooltipFormattedValue: tooltipState.tooltipFormattedValue,
|
|
471
|
+
tooltipContent: tooltipState.tooltipContent,
|
|
472
|
+
onInput: valueState.onInput,
|
|
473
|
+
onTooltipPointerDown: tooltipState.onTooltipPointerDown,
|
|
474
|
+
onTooltipPointerMove: tooltipState.onTooltipPointerMove,
|
|
475
|
+
onTooltipTrackEnter: tooltipState.onTooltipTrackEnter,
|
|
476
|
+
onTooltipTrackLeave: tooltipState.onTooltipTrackLeave,
|
|
477
|
+
onTooltipFocusIn: tooltipState.onTooltipFocusIn,
|
|
478
|
+
onTooltipFocusOut: tooltipState.onTooltipFocusOut,
|
|
479
|
+
onTooltipKeydown: tooltipState.onTooltipKeydown
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
//#endregion
|
|
387
483
|
//#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-
|
|
484
|
+
var t0$2 = template("<span data-v-f21fa11c>");
|
|
485
|
+
var t1$2 = template("<span data-v-f21fa11c class=rp-slider__header>");
|
|
486
|
+
var t2$2 = template("<span data-v-f21fa11c class=\"rp-slider__track-layer rp-slider__track-underlay\"aria-hidden=true>");
|
|
487
|
+
var t3$2 = template("<span data-v-f21fa11c class=\"rp-slider__track-layer rp-slider__track-overlay\"aria-hidden=true>");
|
|
488
|
+
var t4$2 = template("<span data-v-f21fa11c class=rp-slider__travel aria-hidden=true>", 2);
|
|
489
|
+
var t5$1 = template("<span data-v-f21fa11c> ");
|
|
490
|
+
var t6$1 = template("<span data-v-f21fa11c><span data-v-f21fa11c class=rp-slider__mark-dot></span>");
|
|
491
|
+
var t7$1 = template("<span data-v-f21fa11c class=rp-slider__marks aria-hidden=true>");
|
|
492
|
+
var t8$1 = template("<span data-v-f21fa11c class=rp-slider__tooltip-anchor aria-hidden=true></span>", 2);
|
|
397
493
|
var t9$1 = template(" ");
|
|
398
|
-
var t10 = template("<label data-v-
|
|
399
|
-
delegateEvents("pointerdown", "pointermove", "focusin", "focusout", "keydown");
|
|
494
|
+
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
495
|
//#endregion
|
|
401
496
|
//#region src/components/slider/slider.vue
|
|
402
497
|
var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -459,36 +554,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
459
554
|
const slots = useSlots();
|
|
460
555
|
const props = __props;
|
|
461
556
|
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
|
-
});
|
|
557
|
+
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
558
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
484
559
|
const rootAttrs = computed(() => getRootAttrs({
|
|
485
560
|
class: [rootClass.value, { "rp-slider--custom-thumb": Boolean(slots.thumb) }],
|
|
486
561
|
style: trackStyle.value,
|
|
487
|
-
"data-disabled":
|
|
488
|
-
"data-invalid":
|
|
562
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
563
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
489
564
|
"data-orientation": props.orientation,
|
|
490
|
-
"data-track-hovered":
|
|
491
|
-
"data-dragging":
|
|
565
|
+
"data-track-hovered": toPresenceAttribute(trackHovered.value),
|
|
566
|
+
"data-dragging": toPresenceAttribute(dragging.value),
|
|
492
567
|
"data-thumb-visibility": thumbMode.value === false ? "hidden" : thumbMode.value
|
|
493
568
|
}));
|
|
494
569
|
const tooltipClassNames = computed(() => ({
|
|
@@ -497,23 +572,18 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
497
572
|
}));
|
|
498
573
|
const tooltipStyles = computed(() => ({ root: props.styles?.tooltip }));
|
|
499
574
|
const nativeInputAttrs = computed(() => {
|
|
500
|
-
const
|
|
575
|
+
const inputAttrs = props.inputAttrs ?? {};
|
|
576
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
501
577
|
return {
|
|
502
|
-
...
|
|
578
|
+
...forwardedAttributes,
|
|
503
579
|
...getPartAttrs("input", {
|
|
504
580
|
class: "rp-slider__native",
|
|
505
581
|
compatibilityClass,
|
|
506
582
|
compatibilityStyle
|
|
507
583
|
}),
|
|
508
|
-
onInput(
|
|
509
|
-
onInput(event);
|
|
510
|
-
compatibilityOnInput?.(event);
|
|
511
|
-
}
|
|
584
|
+
onInput: composeEventHandlers(onInput, inputAttrs.onInput)
|
|
512
585
|
};
|
|
513
586
|
});
|
|
514
|
-
function focus(options) {
|
|
515
|
-
inputRef.value?.focus(options);
|
|
516
|
-
}
|
|
517
587
|
__expose({
|
|
518
588
|
nativeElement: inputRef,
|
|
519
589
|
focus
|
|
@@ -599,8 +669,8 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
599
669
|
"aria-valuetext": unref(ariaValueText),
|
|
600
670
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs["aria-invalid"] : _control.invalid || void 0,
|
|
601
671
|
"aria-required": _props_required_nativeInputAttrs_required,
|
|
602
|
-
"data-disabled": unref(
|
|
603
|
-
"data-invalid": unref(
|
|
672
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
673
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
604
674
|
}]);
|
|
605
675
|
});
|
|
606
676
|
setInsertionState(n45, n47, 6);
|
|
@@ -614,7 +684,7 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
614
684
|
setDynamicProps(n31, [unref(getPartAttrs)("mark", {
|
|
615
685
|
class: ["rp-slider__mark", { "rp-slider__mark--filled": _mark.filled }],
|
|
616
686
|
style: _mark.style
|
|
617
|
-
}), { "data-filled": unref(
|
|
687
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
618
688
|
});
|
|
619
689
|
setInsertionState(n31, null, 1);
|
|
620
690
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -671,16 +741,16 @@ var slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE_
|
|
|
671
741
|
}
|
|
672
742
|
});
|
|
673
743
|
});
|
|
674
|
-
n45
|
|
744
|
+
on(n45, "pointerdown", (e) => unref(onTooltipPointerDown)(e));
|
|
675
745
|
on(n45, "pointerenter", (e) => unref(onTooltipTrackEnter)(e));
|
|
676
746
|
on(n45, "pointerleave", (e) => unref(onTooltipTrackLeave)(e));
|
|
677
|
-
n45
|
|
678
|
-
n45
|
|
679
|
-
n45
|
|
680
|
-
n45
|
|
747
|
+
on(n45, "pointermove", (e) => unref(onTooltipPointerMove)(e));
|
|
748
|
+
on(n45, "focusin", (e) => unref(onTooltipFocusIn)(e));
|
|
749
|
+
on(n45, "focusout", (e) => unref(onTooltipFocusOut)(e));
|
|
750
|
+
on(n45, "keydown", (e) => unref(onTooltipKeydown)(e));
|
|
681
751
|
return n48;
|
|
682
752
|
}
|
|
683
|
-
}), [["__scopeId", "data-v-
|
|
753
|
+
}), [["__scopeId", "data-v-f21fa11c"]]);
|
|
684
754
|
//#endregion
|
|
685
755
|
//#region src/components/slider/useRangeSliderTooltipCollision.ts
|
|
686
756
|
var TOOLTIP_COLLISION_GAP = 4;
|
|
@@ -745,8 +815,6 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
745
815
|
height: 0
|
|
746
816
|
});
|
|
747
817
|
let resizeObserver;
|
|
748
|
-
let frameWindow;
|
|
749
|
-
let frameId;
|
|
750
818
|
let destroyed = false;
|
|
751
819
|
function setOverlapping(value) {
|
|
752
820
|
if (tooltipsOverlapping.value !== value) tooltipsOverlapping.value = value;
|
|
@@ -784,19 +852,9 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
784
852
|
};
|
|
785
853
|
updateCollision();
|
|
786
854
|
}
|
|
855
|
+
const measureScheduler = createRafScheduler(measureSizes, () => root.value?.ownerDocument.defaultView);
|
|
787
856
|
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
|
-
});
|
|
857
|
+
if (!destroyed) measureScheduler.schedule();
|
|
800
858
|
}
|
|
801
859
|
function refreshObservedElements() {
|
|
802
860
|
if (!resizeObserver) return;
|
|
@@ -862,7 +920,7 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
862
920
|
destroyed = true;
|
|
863
921
|
(root.value?.ownerDocument.defaultView)?.removeEventListener("resize", onWindowResize);
|
|
864
922
|
resizeObserver?.disconnect();
|
|
865
|
-
|
|
923
|
+
measureScheduler.cancel();
|
|
866
924
|
});
|
|
867
925
|
return {
|
|
868
926
|
tooltipsOverlapping,
|
|
@@ -872,11 +930,11 @@ function useRangeSliderTooltipCollision({ enabled, lower, orientation, placement
|
|
|
872
930
|
}
|
|
873
931
|
//#endregion
|
|
874
932
|
//#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-
|
|
933
|
+
var t0$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-value> </span>");
|
|
934
|
+
var t1$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-value> ");
|
|
935
|
+
var t2$1 = template("<span data-v-da6906b9 class=rp-range-slider__tooltip-merged-separator>–</span>", 2);
|
|
878
936
|
var t3$1 = template(" ");
|
|
879
|
-
var t4$1 = template("<span data-v-
|
|
937
|
+
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
938
|
//#endregion
|
|
881
939
|
//#region src/components/slider/range-slider-tooltip.vue
|
|
882
940
|
var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -919,6 +977,10 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
919
977
|
},
|
|
920
978
|
emits: ["update:overlapping"],
|
|
921
979
|
setup(__props, { emit: __emit }) {
|
|
980
|
+
const TOOLTIP_OFFSET_PROPERTIES = {
|
|
981
|
+
mainAxis: "--_rp-tooltip-main-axis-offset",
|
|
982
|
+
crossAxis: "--_rp-tooltip-cross-axis-offset"
|
|
983
|
+
};
|
|
922
984
|
const props = __props;
|
|
923
985
|
const emit = __emit;
|
|
924
986
|
const generatedId = useId();
|
|
@@ -933,7 +995,7 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
933
995
|
open: props.open
|
|
934
996
|
}));
|
|
935
997
|
const contentStyle = computed(() => ({
|
|
936
|
-
...
|
|
998
|
+
...getFloatingOffsetStyle(props.offset, TOOLTIP_OFFSET_PROPERTIES),
|
|
937
999
|
...resolveTooltipColorStyleWithContrast(props.color, props.autoContrast, props.contrastColor)
|
|
938
1000
|
}));
|
|
939
1001
|
const { tooltipsOverlapping, mergedArrowOffset, mergedMinSize } = useRangeSliderTooltipCollision({
|
|
@@ -1051,135 +1113,181 @@ var range_slider_tooltip_default = /*#__PURE__*/ _plugin_vue_export_helper_defau
|
|
|
1051
1113
|
_setTemplateRef(n16, tooltipLayerRef, null, "tooltipLayerRef");
|
|
1052
1114
|
return n16;
|
|
1053
1115
|
}
|
|
1054
|
-
}), [["__scopeId", "data-v-
|
|
1116
|
+
}), [["__scopeId", "data-v-da6906b9"]]);
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/components/slider/rangeSliderModel.ts
|
|
1119
|
+
function roundSliderNumber(value) {
|
|
1120
|
+
return Number(value.toFixed(10));
|
|
1121
|
+
}
|
|
1122
|
+
function getStepValueAtOrAbove(value, min, step) {
|
|
1123
|
+
if (step === "any") return value;
|
|
1124
|
+
return roundSliderNumber(min + Math.ceil((value - min) / step - 1e-10) * step);
|
|
1125
|
+
}
|
|
1126
|
+
function getStepValueAtOrBelow(value, min, step) {
|
|
1127
|
+
if (step === "any") return value;
|
|
1128
|
+
return roundSliderNumber(min + Math.floor((value - min) / step + 1e-10) * step);
|
|
1129
|
+
}
|
|
1130
|
+
function isSliderStepAligned(min, max, step) {
|
|
1131
|
+
const stepCount = (max - min) / step;
|
|
1132
|
+
return Math.abs(stepCount - Math.round(stepCount)) <= 1e-10;
|
|
1133
|
+
}
|
|
1134
|
+
function normalizeRangeSliderMinRange(minRange, min, max) {
|
|
1135
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1136
|
+
const domain = bounds.max - bounds.min;
|
|
1137
|
+
return Math.min(domain, Number.isFinite(minRange) && minRange > 0 ? minRange : 0);
|
|
1138
|
+
}
|
|
1139
|
+
function normalizeRangeSliderValue(value, min, max, step, minRange = 0) {
|
|
1140
|
+
const bounds = normalizeSliderBounds(min, max);
|
|
1141
|
+
const safeStep = normalizeSliderStep(step);
|
|
1142
|
+
const safeMinRange = normalizeRangeSliderMinRange(minRange, bounds.min, bounds.max);
|
|
1143
|
+
const first = normalizeSliderValue(Array.isArray(value) ? Number(value[0]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1144
|
+
const second = normalizeSliderValue(Array.isArray(value) ? Number(value[1]) : NaN, bounds.min, bounds.max, safeStep);
|
|
1145
|
+
const lower = Math.min(first, second);
|
|
1146
|
+
const upper = Math.max(first, second);
|
|
1147
|
+
if (upper - lower >= safeMinRange) return [lower, upper];
|
|
1148
|
+
if (safeMinRange >= bounds.max - bounds.min) return [bounds.min, bounds.max];
|
|
1149
|
+
const expandedUpper = getStepValueAtOrAbove(lower + safeMinRange, bounds.min, safeStep);
|
|
1150
|
+
if (expandedUpper <= bounds.max) return [lower, expandedUpper];
|
|
1151
|
+
const expandedLower = getStepValueAtOrBelow(bounds.max - safeMinRange, bounds.min, safeStep);
|
|
1152
|
+
return [Math.max(bounds.min, expandedLower), bounds.max];
|
|
1153
|
+
}
|
|
1154
|
+
function getClosestRangeSliderThumb(value, range, activeThumb) {
|
|
1155
|
+
const [lower, upper] = range;
|
|
1156
|
+
if (value < lower) return "lower";
|
|
1157
|
+
if (value > upper) return "upper";
|
|
1158
|
+
const lowerDistance = Math.abs(value - lower);
|
|
1159
|
+
const upperDistance = Math.abs(value - upper);
|
|
1160
|
+
if (lowerDistance < upperDistance) return "lower";
|
|
1161
|
+
if (upperDistance < lowerDistance) return "upper";
|
|
1162
|
+
return activeThumb ?? "upper";
|
|
1163
|
+
}
|
|
1164
|
+
function getRangeSliderNativeStep(bounds, step) {
|
|
1165
|
+
if (step === "any") return step;
|
|
1166
|
+
return isSliderStepAligned(bounds.min, bounds.max, step) ? step : "any";
|
|
1167
|
+
}
|
|
1168
|
+
function getRangeSliderNativeLimits(value, bounds, step, minRange) {
|
|
1169
|
+
if (minRange === 0) return {
|
|
1170
|
+
min: [bounds.min, bounds.min],
|
|
1171
|
+
max: [bounds.max, bounds.max]
|
|
1172
|
+
};
|
|
1173
|
+
return {
|
|
1174
|
+
min: [bounds.min, clamp(getStepValueAtOrAbove(value[0] + minRange, bounds.min, step), bounds.min, bounds.max)],
|
|
1175
|
+
max: [clamp(getStepValueAtOrBelow(value[1] - minRange, bounds.min, step), bounds.min, bounds.max), bounds.max]
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function getRangeSliderThumbUpdate({ thumb, value, currentValue, bounds, step, minRange, nativeMin, nativeMax, anchorValue = currentValue[getRangeSliderThumbIndex(getOppositeRangeSliderThumb(thumb))] }) {
|
|
1179
|
+
const safeValue = normalizeSliderValue(value, bounds.min, bounds.max, step);
|
|
1180
|
+
if (minRange > 0) {
|
|
1181
|
+
const nextValue = [...currentValue];
|
|
1182
|
+
nextValue[getRangeSliderThumbIndex(thumb)] = thumb === "lower" ? Math.min(safeValue, nativeMax[0]) : Math.max(safeValue, nativeMin[1]);
|
|
1183
|
+
return {
|
|
1184
|
+
thumb,
|
|
1185
|
+
value: nextValue
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
if (safeValue < anchorValue) return {
|
|
1189
|
+
thumb: "lower",
|
|
1190
|
+
value: [safeValue, anchorValue]
|
|
1191
|
+
};
|
|
1192
|
+
if (safeValue > anchorValue) return {
|
|
1193
|
+
thumb: "upper",
|
|
1194
|
+
value: [anchorValue, safeValue]
|
|
1195
|
+
};
|
|
1196
|
+
return {
|
|
1197
|
+
thumb,
|
|
1198
|
+
value: [safeValue, safeValue]
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
function getFormattedRangeSliderValue(value, formatter) {
|
|
1202
|
+
return [getFormattedSliderValue(value[0], formatter), getFormattedSliderValue(value[1], formatter)];
|
|
1203
|
+
}
|
|
1204
|
+
function getRangeSliderAriaValueText(value, ariaValueText, formatter) {
|
|
1205
|
+
const endpointValues = Array.isArray(ariaValueText) ? ariaValueText : [ariaValueText, ariaValueText];
|
|
1206
|
+
return [getSliderAriaValueText(value[0], endpointValues[0], formatter), getSliderAriaValueText(value[1], endpointValues[1], formatter)];
|
|
1207
|
+
}
|
|
1208
|
+
function getRangeSliderThumbIndex(thumb) {
|
|
1209
|
+
return thumb === "lower" ? 0 : 1;
|
|
1210
|
+
}
|
|
1211
|
+
function getOppositeRangeSliderThumb(thumb) {
|
|
1212
|
+
return thumb === "lower" ? "upper" : "lower";
|
|
1213
|
+
}
|
|
1214
|
+
function getRangeSliderKeyboardValue(key, currentValue, step, min, max) {
|
|
1215
|
+
switch (key) {
|
|
1216
|
+
case "ArrowRight":
|
|
1217
|
+
case "ArrowUp": return currentValue + step;
|
|
1218
|
+
case "ArrowLeft":
|
|
1219
|
+
case "ArrowDown": return currentValue - step;
|
|
1220
|
+
case "PageUp": return currentValue + step * 10;
|
|
1221
|
+
case "PageDown": return currentValue - step * 10;
|
|
1222
|
+
case "Home": return min;
|
|
1223
|
+
case "End": return max;
|
|
1224
|
+
default: return;
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
function getRangeSliderPointerValue(pointer, geometry, bounds) {
|
|
1228
|
+
const pointerPosition = geometry.vertical ? pointer.clientY : pointer.clientX;
|
|
1229
|
+
const ratio = clamp((geometry.vertical ? geometry.start - pointerPosition : pointerPosition - geometry.start) / geometry.length, 0, 1);
|
|
1230
|
+
return bounds.min + ratio * (bounds.max - bounds.min);
|
|
1231
|
+
}
|
|
1055
1232
|
//#endregion
|
|
1056
1233
|
//#region src/components/slider/useRangeSliderPointer.ts
|
|
1057
1234
|
function useRangeSliderPointer(options) {
|
|
1058
|
-
|
|
1059
|
-
let frameWindow = null;
|
|
1060
|
-
let frameId;
|
|
1061
|
-
let pendingPointerEvent;
|
|
1062
|
-
let geometryDirty = false;
|
|
1063
|
-
function cancelScheduledFrame() {
|
|
1064
|
-
if (frameId !== void 0) frameWindow?.cancelAnimationFrame(frameId);
|
|
1065
|
-
frameWindow = null;
|
|
1066
|
-
frameId = void 0;
|
|
1067
|
-
}
|
|
1068
|
-
function refreshGeometry() {
|
|
1069
|
-
const currentSession = session;
|
|
1070
|
-
if (!currentSession) return false;
|
|
1071
|
-
if (!geometryDirty) return true;
|
|
1235
|
+
function refreshGeometry(currentSession) {
|
|
1072
1236
|
const geometry = options.getPointerGeometry(currentSession.track);
|
|
1073
1237
|
if (geometry === void 0) return false;
|
|
1074
|
-
geometryDirty = false;
|
|
1075
1238
|
currentSession.geometry = geometry;
|
|
1076
1239
|
return true;
|
|
1077
1240
|
}
|
|
1078
|
-
function
|
|
1079
|
-
if (
|
|
1080
|
-
const event = pendingPointerEvent;
|
|
1081
|
-
pendingPointerEvent = void 0;
|
|
1082
|
-
if (event && isCurrentPointer(event)) updateFromPointer(event);
|
|
1083
|
-
}
|
|
1084
|
-
function flushScheduledUpdate() {
|
|
1085
|
-
cancelScheduledFrame();
|
|
1086
|
-
applyScheduledUpdate();
|
|
1087
|
-
}
|
|
1088
|
-
function onAnimationFrame() {
|
|
1089
|
-
frameWindow = null;
|
|
1090
|
-
frameId = void 0;
|
|
1091
|
-
applyScheduledUpdate();
|
|
1092
|
-
}
|
|
1093
|
-
function scheduleUpdate() {
|
|
1094
|
-
const view = session?.view;
|
|
1095
|
-
if (!view?.requestAnimationFrame) {
|
|
1096
|
-
flushScheduledUpdate();
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
if (frameId !== void 0) return;
|
|
1100
|
-
frameWindow = view;
|
|
1101
|
-
frameId = view.requestAnimationFrame(onAnimationFrame);
|
|
1102
|
-
}
|
|
1103
|
-
function onGeometryChange() {
|
|
1104
|
-
if (!session) return;
|
|
1105
|
-
geometryDirty = true;
|
|
1106
|
-
scheduleUpdate();
|
|
1107
|
-
}
|
|
1108
|
-
function stopDragging() {
|
|
1109
|
-
const stoppedSession = session;
|
|
1110
|
-
if (!stoppedSession) return;
|
|
1111
|
-
stoppedSession.view?.removeEventListener("pointermove", onPointerMove);
|
|
1112
|
-
stoppedSession.view?.removeEventListener("pointerup", onPointerEnd);
|
|
1113
|
-
stoppedSession.view?.removeEventListener("pointercancel", onPointerEnd);
|
|
1114
|
-
stoppedSession.view?.removeEventListener("resize", onGeometryChange);
|
|
1115
|
-
stoppedSession.view?.removeEventListener("scroll", onGeometryChange, true);
|
|
1116
|
-
cancelScheduledFrame();
|
|
1117
|
-
pendingPointerEvent = void 0;
|
|
1118
|
-
geometryDirty = false;
|
|
1119
|
-
session = void 0;
|
|
1120
|
-
options.endDrag(stoppedSession.thumb);
|
|
1121
|
-
}
|
|
1122
|
-
function switchDraggingThumb(nextThumb) {
|
|
1123
|
-
const currentSession = session;
|
|
1124
|
-
if (!currentSession || currentSession.thumb === nextThumb) return;
|
|
1241
|
+
function switchDraggingThumb(currentSession, nextThumb) {
|
|
1242
|
+
if (currentSession.thumb === nextThumb) return;
|
|
1125
1243
|
const previousThumb = currentSession.thumb;
|
|
1126
1244
|
currentSession.thumb = nextThumb;
|
|
1127
1245
|
options.transferDrag(previousThumb, nextThumb);
|
|
1128
1246
|
options.setActiveThumb(nextThumb);
|
|
1129
1247
|
options.transferFocusedThumb(currentSession.track, previousThumb, nextThumb);
|
|
1130
1248
|
}
|
|
1131
|
-
function updateFromPointer(event) {
|
|
1132
|
-
const currentSession = session;
|
|
1133
|
-
if (!currentSession) return;
|
|
1249
|
+
function updateFromPointer(event, currentSession) {
|
|
1134
1250
|
const value = options.getPointerValue(event, currentSession.geometry);
|
|
1135
1251
|
if (value == null) return;
|
|
1136
|
-
switchDraggingThumb(options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
1137
|
-
}
|
|
1138
|
-
function isCurrentPointer(event) {
|
|
1139
|
-
return session?.pointerId === void 0 || event.pointerId === session.pointerId;
|
|
1140
|
-
}
|
|
1141
|
-
function onPointerMove(event) {
|
|
1142
|
-
if (!isCurrentPointer(event)) return;
|
|
1143
|
-
if (!session) return;
|
|
1144
|
-
pendingPointerEvent = event;
|
|
1145
|
-
scheduleUpdate();
|
|
1146
|
-
}
|
|
1147
|
-
function onPointerEnd(event) {
|
|
1148
|
-
if (!isCurrentPointer(event)) return;
|
|
1149
|
-
if (event.type === "pointerup") flushScheduledUpdate();
|
|
1150
|
-
stopDragging();
|
|
1252
|
+
switchDraggingThumb(currentSession, options.updateThumb(currentSession.thumb, value, currentSession.anchorValue));
|
|
1151
1253
|
}
|
|
1254
|
+
const pointerSession = createPointerSession({
|
|
1255
|
+
onStart(event, currentSession) {
|
|
1256
|
+
event.preventDefault();
|
|
1257
|
+
options.setActiveThumb(currentSession.thumb);
|
|
1258
|
+
options.focusThumb(currentSession.track, currentSession.thumb);
|
|
1259
|
+
options.startDrag(currentSession.thumb);
|
|
1260
|
+
switchDraggingThumb(currentSession, options.updateThumb(currentSession.thumb, currentSession.initialValue, currentSession.anchorValue));
|
|
1261
|
+
},
|
|
1262
|
+
onStop(currentSession) {
|
|
1263
|
+
options.endDrag(currentSession.thumb);
|
|
1264
|
+
},
|
|
1265
|
+
onUpdate: updateFromPointer,
|
|
1266
|
+
refreshGeometry
|
|
1267
|
+
});
|
|
1152
1268
|
function onTrackPointerDown(event) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
};
|
|
1173
|
-
options.startDrag(thumb);
|
|
1174
|
-
switchDraggingThumb(options.updateThumb(thumb, pointerValue, session.anchorValue));
|
|
1175
|
-
const view = session?.view;
|
|
1176
|
-
view?.addEventListener("pointermove", onPointerMove);
|
|
1177
|
-
view?.addEventListener("pointerup", onPointerEnd);
|
|
1178
|
-
view?.addEventListener("pointercancel", onPointerEnd);
|
|
1179
|
-
view?.addEventListener("resize", onGeometryChange);
|
|
1180
|
-
view?.addEventListener("scroll", onGeometryChange, true);
|
|
1269
|
+
return pointerSession.start(event, () => {
|
|
1270
|
+
if (options.disabled()) return;
|
|
1271
|
+
const track = event.currentTarget;
|
|
1272
|
+
if (!track) return;
|
|
1273
|
+
const geometry = options.getPointerGeometry(track);
|
|
1274
|
+
if (geometry === void 0) return;
|
|
1275
|
+
const initialValue = options.getPointerValue(event, geometry);
|
|
1276
|
+
if (initialValue == null) return;
|
|
1277
|
+
const thumb = options.getThumb(event, initialValue);
|
|
1278
|
+
return {
|
|
1279
|
+
state: {
|
|
1280
|
+
anchorValue: options.getAnchorValue(thumb),
|
|
1281
|
+
geometry,
|
|
1282
|
+
initialValue,
|
|
1283
|
+
thumb,
|
|
1284
|
+
track
|
|
1285
|
+
},
|
|
1286
|
+
target: track
|
|
1287
|
+
};
|
|
1288
|
+
});
|
|
1181
1289
|
}
|
|
1182
|
-
onBeforeUnmount(
|
|
1290
|
+
onBeforeUnmount(pointerSession.stop);
|
|
1183
1291
|
return { onTrackPointerDown };
|
|
1184
1292
|
}
|
|
1185
1293
|
//#endregion
|
|
@@ -1281,55 +1389,132 @@ function useRangeSliderTooltipState(options) {
|
|
|
1281
1389
|
};
|
|
1282
1390
|
}
|
|
1283
1391
|
//#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
|
-
|
|
1392
|
+
//#region src/components/slider/useRangeSliderValueState.ts
|
|
1393
|
+
function useRangeSliderValueState(props, onChange, setActiveThumb) {
|
|
1394
|
+
const lowerInputRef = ref(null);
|
|
1395
|
+
const upperInputRef = ref(null);
|
|
1396
|
+
const controllable = useControllableValue({
|
|
1397
|
+
modelValue: () => props.modelValue,
|
|
1398
|
+
defaultValue: () => props.defaultValue ?? [props.min, props.max],
|
|
1399
|
+
onChange
|
|
1400
|
+
});
|
|
1401
|
+
const control = useControlState(props);
|
|
1402
|
+
const bounds = computed(() => normalizeSliderBounds(props.min, props.max));
|
|
1403
|
+
const valueStep = computed(() => normalizeSliderStep(props.step));
|
|
1404
|
+
const nativeStep = computed(() => getRangeSliderNativeStep(bounds.value, valueStep.value));
|
|
1405
|
+
const hasManualNativeKeyboard = computed(() => valueStep.value !== "any" && nativeStep.value === "any");
|
|
1406
|
+
const normalizedMinRange = computed(() => normalizeRangeSliderMinRange(props.minRange, bounds.value.min, bounds.value.max));
|
|
1407
|
+
const normalizedValue = computed(() => normalizeRangeSliderValue(controllable.value.value, bounds.value.min, bounds.value.max, valueStep.value, normalizedMinRange.value));
|
|
1408
|
+
const nativeLimits = computed(() => getRangeSliderNativeLimits(normalizedValue.value, bounds.value, valueStep.value, normalizedMinRange.value));
|
|
1409
|
+
const nativeMin = computed(() => nativeLimits.value.min);
|
|
1410
|
+
const nativeMax = computed(() => nativeLimits.value.max);
|
|
1411
|
+
const valuePercent = computed(() => [getValuePercent(normalizedValue.value[0], bounds.value.min, bounds.value.max), getValuePercent(normalizedValue.value[1], bounds.value.min, bounds.value.max)]);
|
|
1412
|
+
const formattedValue = computed(() => getFormattedRangeSliderValue(normalizedValue.value, props.formatValue));
|
|
1413
|
+
const ariaLabels = computed(() => props.ariaLabel ?? ["Minimum", "Maximum"]);
|
|
1414
|
+
const ariaValueText = computed(() => getRangeSliderAriaValueText(normalizedValue.value, props.ariaValueText, props.formatValue));
|
|
1415
|
+
const nativeNames = computed(() => Array.isArray(props.name) ? props.name : [props.name, props.name]);
|
|
1416
|
+
const nativeIds = computed(() => [control.id, control.id ? `${control.id}-upper` : void 0]);
|
|
1417
|
+
const validationMessages = computed(() => Array.isArray(props.validationMessage) ? props.validationMessage : [props.validationMessage, props.validationMessage]);
|
|
1418
|
+
const markItems = computed(() => createSliderMarkItems(props.marks, bounds.value.min, bounds.value.max, (value) => value >= normalizedValue.value[0] && value <= normalizedValue.value[1], {
|
|
1419
|
+
position: "--_rp-range-slider-mark-position",
|
|
1420
|
+
decorativeColors: ["--_rp-range-slider-mark-color", "--_rp-range-slider-mark-ring-color"],
|
|
1421
|
+
foregroundColors: ["--_rp-range-slider-mark-label-color", "--_rp-range-slider-mark-filled-label-color"]
|
|
1422
|
+
}));
|
|
1423
|
+
const hasMarkLabels = computed(() => markItems.value.some((mark) => mark.hasLabel));
|
|
1424
|
+
const trackSlotProps = computed(() => ({
|
|
1425
|
+
value: normalizedValue.value,
|
|
1426
|
+
formattedValue: formattedValue.value,
|
|
1427
|
+
percent: valuePercent.value,
|
|
1428
|
+
min: bounds.value.min,
|
|
1429
|
+
max: bounds.value.max,
|
|
1430
|
+
orientation: props.orientation,
|
|
1431
|
+
getPercent(value) {
|
|
1432
|
+
return getValuePercent(value, bounds.value.min, bounds.value.max);
|
|
1433
|
+
}
|
|
1434
|
+
}));
|
|
1435
|
+
function normalizeInitialValue(value = controllable.initialValue) {
|
|
1436
|
+
return normalizeRangeSliderValue(value, props.min, props.max, props.step, props.minRange);
|
|
1437
|
+
}
|
|
1438
|
+
useFormControl({
|
|
1439
|
+
elements: () => [lowerInputRef.value, upperInputRef.value],
|
|
1440
|
+
isControlled: () => controllable.isControlled.value,
|
|
1441
|
+
initializeDefault(element, index) {
|
|
1442
|
+
const initialValue = normalizeInitialValue();
|
|
1443
|
+
element.defaultValue = String(initialValue[index]);
|
|
1444
|
+
},
|
|
1445
|
+
validationMessage: (_element, index) => validationMessages.value[index],
|
|
1446
|
+
readResetValue(elements) {
|
|
1447
|
+
const resetValue = [normalizedValue.value[0], normalizedValue.value[1]];
|
|
1448
|
+
for (const element of elements) {
|
|
1449
|
+
const index = element === upperInputRef.value ? 1 : 0;
|
|
1450
|
+
resetValue[index] = Number(element.defaultValue);
|
|
1451
|
+
}
|
|
1452
|
+
const nextValue = normalizeInitialValue(resetValue);
|
|
1453
|
+
controllable.resetValue(nextValue);
|
|
1454
|
+
nextTick(() => {
|
|
1455
|
+
if (lowerInputRef.value) lowerInputRef.value.value = String(nextValue[0]);
|
|
1456
|
+
if (upperInputRef.value) upperInputRef.value.value = String(nextValue[1]);
|
|
1457
|
+
});
|
|
1458
|
+
},
|
|
1459
|
+
syncControlledValue(elements) {
|
|
1460
|
+
for (const element of elements) {
|
|
1461
|
+
const index = element === upperInputRef.value ? 1 : 0;
|
|
1462
|
+
element.value = String(normalizedValue.value[index]);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
function updateThumb(thumb, value, anchorValue) {
|
|
1467
|
+
if (control.disabled) return thumb;
|
|
1468
|
+
const update = getRangeSliderThumbUpdate({
|
|
1469
|
+
thumb,
|
|
1470
|
+
value,
|
|
1471
|
+
currentValue: normalizedValue.value,
|
|
1472
|
+
bounds: bounds.value,
|
|
1473
|
+
step: valueStep.value,
|
|
1474
|
+
minRange: normalizedMinRange.value,
|
|
1475
|
+
nativeMin: nativeMin.value,
|
|
1476
|
+
nativeMax: nativeMax.value,
|
|
1477
|
+
anchorValue
|
|
1478
|
+
});
|
|
1479
|
+
setActiveThumb(update.thumb);
|
|
1480
|
+
controllable.setValue(update.value);
|
|
1481
|
+
return update.thumb;
|
|
1482
|
+
}
|
|
1483
|
+
const nativeElements = computed(() => [lowerInputRef.value, upperInputRef.value]);
|
|
1484
|
+
function setInputRef(index, element) {
|
|
1485
|
+
const input = element instanceof HTMLInputElement ? element : null;
|
|
1486
|
+
if (index === 0) lowerInputRef.value = input;
|
|
1487
|
+
else upperInputRef.value = input;
|
|
1488
|
+
}
|
|
1489
|
+
function focus(options) {
|
|
1490
|
+
lowerInputRef.value?.focus(options);
|
|
1491
|
+
}
|
|
1492
|
+
return {
|
|
1493
|
+
nativeElements,
|
|
1494
|
+
setInputRef,
|
|
1495
|
+
focus,
|
|
1496
|
+
control,
|
|
1497
|
+
bounds,
|
|
1498
|
+
valueStep,
|
|
1499
|
+
hasManualNativeKeyboard,
|
|
1500
|
+
nativeMin,
|
|
1501
|
+
nativeMax,
|
|
1502
|
+
nativeStep,
|
|
1503
|
+
nativeNames,
|
|
1504
|
+
nativeIds,
|
|
1505
|
+
normalizedValue,
|
|
1506
|
+
valuePercent,
|
|
1507
|
+
formattedValue,
|
|
1508
|
+
ariaLabels,
|
|
1509
|
+
ariaValueText,
|
|
1510
|
+
markItems,
|
|
1511
|
+
hasMarkLabels,
|
|
1512
|
+
trackSlotProps,
|
|
1513
|
+
updateThumb
|
|
1514
|
+
};
|
|
1332
1515
|
}
|
|
1516
|
+
//#endregion
|
|
1517
|
+
//#region src/components/slider/useRangeSlider.ts
|
|
1333
1518
|
function getRangeSliderTrackStyle(props, valuePercent) {
|
|
1334
1519
|
const [lowerPercent, upperPercent] = valuePercent;
|
|
1335
1520
|
const style = {
|
|
@@ -1348,19 +1533,6 @@ function getRangeSliderTrackStyle(props, valuePercent) {
|
|
|
1348
1533
|
});
|
|
1349
1534
|
return style;
|
|
1350
1535
|
}
|
|
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
1536
|
function getThumbFromTarget(target) {
|
|
1365
1537
|
const thumb = target?.closest?.("[data-range-slider-thumb]")?.getAttribute("data-range-slider-thumb");
|
|
1366
1538
|
return thumb === "lower" || thumb === "upper" ? thumb : void 0;
|
|
@@ -1371,58 +1543,30 @@ function getThumbInput(track, thumb) {
|
|
|
1371
1543
|
function focusThumb(track, thumb) {
|
|
1372
1544
|
getThumbInput(track, thumb)?.focus({ preventScroll: true });
|
|
1373
1545
|
}
|
|
1374
|
-
function
|
|
1375
|
-
const
|
|
1546
|
+
function readRangeSliderPointerGeometry(track, orientation) {
|
|
1547
|
+
const vertical = orientation === "vertical";
|
|
1548
|
+
const thumbsRect = track.querySelector(".rp-range-slider__thumbs")?.getBoundingClientRect();
|
|
1549
|
+
const rect = thumbsRect && (vertical ? thumbsRect.height > 0 : thumbsRect.width > 0) ? thumbsRect : track.getBoundingClientRect();
|
|
1550
|
+
const length = vertical ? rect.height : rect.width;
|
|
1551
|
+
if (length <= 0) return void 0;
|
|
1552
|
+
return {
|
|
1553
|
+
length,
|
|
1554
|
+
start: vertical ? rect.bottom : rect.left,
|
|
1555
|
+
vertical
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
function useRangeSlider(props, onChange) {
|
|
1376
1559
|
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";
|
|
1560
|
+
const valueState = useRangeSliderValueState(props, onChange, (thumb) => {
|
|
1561
|
+
activeThumb.value = thumb;
|
|
1383
1562
|
});
|
|
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)];
|
|
1396
|
-
});
|
|
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
1563
|
const tooltipOptions = computed(() => getSliderTooltipOptions(props.tooltip));
|
|
1420
1564
|
const tooltipMode = computed(() => getSliderTooltipMode(props.tooltip));
|
|
1421
1565
|
const tooltipOpenDelay = computed(() => tooltipOptions.value.openDelay ?? 0);
|
|
1422
1566
|
const tooltipState = useRangeSliderTooltipState({
|
|
1423
1567
|
mode: tooltipMode,
|
|
1424
1568
|
openDelay: tooltipOpenDelay,
|
|
1425
|
-
disabled: () => control.disabled,
|
|
1569
|
+
disabled: () => valueState.control.disabled,
|
|
1426
1570
|
setActiveThumb: (thumb) => {
|
|
1427
1571
|
activeThumb.value = thumb;
|
|
1428
1572
|
}
|
|
@@ -1444,7 +1588,7 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1444
1588
|
const tooltipContrastColor = computed(() => tooltipOptions.value.contrastColor);
|
|
1445
1589
|
const tooltipOffset = computed(() => tooltipOptions.value.offset);
|
|
1446
1590
|
const tooltipArrow = computed(() => tooltipOptions.value.arrow ?? false);
|
|
1447
|
-
const tooltipContent = computed(() => [String(formattedValue.value[0]), String(formattedValue.value[1])]);
|
|
1591
|
+
const tooltipContent = computed(() => [String(valueState.formattedValue.value[0]), String(valueState.formattedValue.value[1])]);
|
|
1448
1592
|
const mergedTooltipContent = computed(() => {
|
|
1449
1593
|
const [lower, upper] = tooltipContent.value;
|
|
1450
1594
|
return lower === upper ? lower : `${lower}–${upper}`;
|
|
@@ -1452,46 +1596,13 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1452
1596
|
const rootClass = computed(() => bem("rp-range-slider", {
|
|
1453
1597
|
[`size-${props.size}`]: Boolean(props.size),
|
|
1454
1598
|
vertical: props.orientation === "vertical",
|
|
1455
|
-
marked: markItems.value.length > 0,
|
|
1456
|
-
"marks-with-labels": hasMarkLabels.value,
|
|
1599
|
+
marked: valueState.markItems.value.length > 0,
|
|
1600
|
+
"marks-with-labels": valueState.hasMarkLabels.value,
|
|
1457
1601
|
"tooltip-always-visible": tooltipAlwaysVisible.value,
|
|
1458
|
-
disabled: control.disabled,
|
|
1459
|
-
invalid: control.invalid
|
|
1602
|
+
disabled: valueState.control.disabled,
|
|
1603
|
+
invalid: valueState.control.invalid
|
|
1460
1604
|
}));
|
|
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
|
-
}
|
|
1605
|
+
const trackStyle = computed(() => getRangeSliderTrackStyle(props, valueState.valuePercent.value));
|
|
1495
1606
|
function transferFocusedThumb(input, thumb, nextThumb) {
|
|
1496
1607
|
if (thumb === nextThumb || input.ownerDocument.activeElement !== input) return;
|
|
1497
1608
|
const track = input.closest(".rp-range-slider__track");
|
|
@@ -1501,68 +1612,31 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1501
1612
|
tooltipState.transferInteraction(thumb, nextThumb, "focus");
|
|
1502
1613
|
nextInput.focus({ preventScroll: true });
|
|
1503
1614
|
}
|
|
1615
|
+
function onInput(thumb, event) {
|
|
1616
|
+
const input = event.target;
|
|
1617
|
+
transferFocusedThumb(input, thumb, valueState.updateThumb(thumb, input.valueAsNumber));
|
|
1618
|
+
}
|
|
1504
1619
|
function onTooltipKeydown(thumb, event) {
|
|
1505
1620
|
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
|
-
}
|
|
1621
|
+
if (!valueState.hasManualNativeKeyboard.value || valueState.valueStep.value === "any") return;
|
|
1622
|
+
const index = getRangeSliderThumbIndex(thumb);
|
|
1623
|
+
const nextValue = getRangeSliderKeyboardValue(event.key, valueState.normalizedValue.value[index], valueState.valueStep.value, valueState.nativeMin.value[index], valueState.nativeMax.value[index]);
|
|
1533
1624
|
if (nextValue == null) return;
|
|
1534
1625
|
event.preventDefault();
|
|
1535
|
-
const nextThumb = updateThumb(thumb, nextValue);
|
|
1626
|
+
const nextThumb = valueState.updateThumb(thumb, nextValue);
|
|
1536
1627
|
transferFocusedThumb(event.target, thumb, nextThumb);
|
|
1537
1628
|
}
|
|
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
1629
|
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[
|
|
1630
|
+
disabled: () => valueState.control.disabled,
|
|
1631
|
+
getPointerGeometry: (track) => readRangeSliderPointerGeometry(track, props.orientation),
|
|
1632
|
+
getPointerValue: (event, geometry) => getRangeSliderPointerValue(event, geometry, valueState.bounds.value),
|
|
1633
|
+
getThumb: (event, value) => getThumbFromTarget(event.target) ?? getClosestRangeSliderThumb(value, valueState.normalizedValue.value, activeThumb.value),
|
|
1634
|
+
getAnchorValue: (thumb) => valueState.normalizedValue.value[getRangeSliderThumbIndex(getOppositeRangeSliderThumb(thumb))],
|
|
1561
1635
|
setActiveThumb: (thumb) => {
|
|
1562
1636
|
activeThumb.value = thumb;
|
|
1563
1637
|
},
|
|
1564
1638
|
focusThumb,
|
|
1565
|
-
updateThumb,
|
|
1639
|
+
updateThumb: valueState.updateThumb,
|
|
1566
1640
|
transferFocusedThumb: (track, from, to) => {
|
|
1567
1641
|
const input = getThumbInput(track, from);
|
|
1568
1642
|
if (input) transferFocusedThumb(input, from, to);
|
|
@@ -1572,20 +1646,23 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1572
1646
|
transferDrag: (from, to) => tooltipState.transferInteraction(from, to, "drag")
|
|
1573
1647
|
});
|
|
1574
1648
|
return {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1649
|
+
nativeElements: valueState.nativeElements,
|
|
1650
|
+
setInputRef: valueState.setInputRef,
|
|
1651
|
+
focus: valueState.focus,
|
|
1652
|
+
control: valueState.control,
|
|
1653
|
+
nativeMin: valueState.nativeMin,
|
|
1654
|
+
nativeMax: valueState.nativeMax,
|
|
1655
|
+
nativeStep: valueState.nativeStep,
|
|
1656
|
+
nativeNames: valueState.nativeNames,
|
|
1657
|
+
nativeIds: valueState.nativeIds,
|
|
1581
1658
|
rootClass,
|
|
1582
|
-
normalizedValue,
|
|
1583
|
-
valuePercent,
|
|
1584
|
-
formattedValue,
|
|
1585
|
-
ariaLabels,
|
|
1586
|
-
ariaValueText,
|
|
1587
|
-
markItems,
|
|
1588
|
-
trackSlotProps,
|
|
1659
|
+
normalizedValue: valueState.normalizedValue,
|
|
1660
|
+
valuePercent: valueState.valuePercent,
|
|
1661
|
+
formattedValue: valueState.formattedValue,
|
|
1662
|
+
ariaLabels: valueState.ariaLabels,
|
|
1663
|
+
ariaValueText: valueState.ariaValueText,
|
|
1664
|
+
markItems: valueState.markItems,
|
|
1665
|
+
trackSlotProps: valueState.trackSlotProps,
|
|
1589
1666
|
trackStyle,
|
|
1590
1667
|
activeThumb,
|
|
1591
1668
|
tooltipVisible,
|
|
@@ -1612,17 +1689,16 @@ function useRangeSlider(props, emitUpdate, getValue = () => props.modelValue ??
|
|
|
1612
1689
|
}
|
|
1613
1690
|
//#endregion
|
|
1614
1691
|
//#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");
|
|
1692
|
+
var t0 = template("<span data-v-e27ae1af>");
|
|
1693
|
+
var t1 = template("<span data-v-e27ae1af class=rp-range-slider__header>");
|
|
1694
|
+
var t2 = template("<span data-v-e27ae1af class=\"rp-range-slider__track-layer rp-range-slider__track-underlay\"aria-hidden=true>");
|
|
1695
|
+
var t3 = template("<span data-v-e27ae1af class=\"rp-range-slider__track-layer rp-range-slider__track-overlay\"aria-hidden=true>");
|
|
1696
|
+
var t4 = template("<input data-v-e27ae1af>");
|
|
1697
|
+
var t5 = template("<span data-v-e27ae1af> ");
|
|
1698
|
+
var t6 = template("<span data-v-e27ae1af><span data-v-e27ae1af class=rp-range-slider__mark-dot></span>");
|
|
1699
|
+
var t7 = template("<span data-v-e27ae1af class=rp-range-slider__marks aria-hidden=true>");
|
|
1700
|
+
var t8 = template("<span data-v-e27ae1af><span data-v-e27ae1af class=rp-range-slider__thumb-content>");
|
|
1701
|
+
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
1702
|
//#endregion
|
|
1627
1703
|
//#region src/components/slider/range-slider.vue
|
|
1628
1704
|
var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -1682,47 +1758,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1682
1758
|
const generatedId = useId();
|
|
1683
1759
|
const tooltipsOverlapping = ref(false);
|
|
1684
1760
|
const rangeSliderThumbs = ["lower", "upper"];
|
|
1685
|
-
const lowerInputRef = ref(null);
|
|
1686
|
-
const upperInputRef = ref(null);
|
|
1687
1761
|
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
|
-
});
|
|
1762
|
+
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
1763
|
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
1727
1764
|
const rootAttrs = computed(() => getRootAttrs({
|
|
1728
1765
|
class: [rootClass.value, {
|
|
@@ -1732,8 +1769,8 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1732
1769
|
style: trackStyle.value,
|
|
1733
1770
|
role: "group",
|
|
1734
1771
|
"data-active-thumb": activeThumb.value || void 0,
|
|
1735
|
-
"data-disabled":
|
|
1736
|
-
"data-invalid":
|
|
1772
|
+
"data-disabled": toPresenceAttribute(control.disabled),
|
|
1773
|
+
"data-invalid": toPresenceAttribute(control.invalid),
|
|
1737
1774
|
"data-orientation": props.orientation,
|
|
1738
1775
|
"aria-labelledby": groupLabelledby.value,
|
|
1739
1776
|
"aria-describedby": control.ariaDescribedby,
|
|
@@ -1745,44 +1782,21 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1745
1782
|
return [props.inputAttrs, props.inputAttrs];
|
|
1746
1783
|
});
|
|
1747
1784
|
const nativeInputAttrs = computed(() => rangeSliderThumbs.map((thumb, index) => {
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1785
|
+
const inputAttrs = inputAttrsByThumb.value[index] ?? {};
|
|
1786
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(inputAttrs);
|
|
1787
|
+
return Object.assign({}, forwardedAttributes, {
|
|
1750
1788
|
...getPartAttrs("input", {
|
|
1751
1789
|
class: ["rp-range-slider__native", `rp-range-slider__native--${thumb}`],
|
|
1752
1790
|
compatibilityClass,
|
|
1753
1791
|
compatibilityStyle
|
|
1754
1792
|
}),
|
|
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
|
-
}
|
|
1793
|
+
onInput: composeEventHandlers((event) => onInput(thumb, event), inputAttrs.onInput),
|
|
1794
|
+
onFocus: composeEventHandlers(() => onTooltipFocus(thumb), inputAttrs.onFocus),
|
|
1795
|
+
onBlur: composeEventHandlers(() => onTooltipBlur(thumb), inputAttrs.onBlur),
|
|
1796
|
+
onKeydown: composeEventHandlers((event) => onTooltipKeydown(thumb, event), inputAttrs.onKeydown)
|
|
1771
1797
|
});
|
|
1772
1798
|
}));
|
|
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
|
-
});
|
|
1799
|
+
const groupLabelledby = computed(() => mergeAriaIdRefs(control.ariaLabelledby, slots.default ? labelId.value : void 0));
|
|
1786
1800
|
__expose({
|
|
1787
1801
|
nativeElements,
|
|
1788
1802
|
focus
|
|
@@ -1865,10 +1879,10 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1865
1879
|
"aria-invalid": _props.invalid === void 0 ? _nativeInputAttrs_index?.["aria-invalid"] : _control.invalid || void 0,
|
|
1866
1880
|
"aria-required": _props_required_nativeInputAttrs_index_required,
|
|
1867
1881
|
"data-thumb": _for_item0.value,
|
|
1868
|
-
"data-disabled": unref(
|
|
1869
|
-
"data-invalid": unref(
|
|
1882
|
+
"data-disabled": unref(toPresenceAttribute)(_control.disabled),
|
|
1883
|
+
"data-invalid": unref(toPresenceAttribute)(_control.invalid)
|
|
1870
1884
|
}]);
|
|
1871
|
-
_setTemplateRef(n22, (element) => setInputRef(_index, element), true);
|
|
1885
|
+
_setTemplateRef(n22, (element) => unref(setInputRef)(_index, element), true);
|
|
1872
1886
|
});
|
|
1873
1887
|
return n22;
|
|
1874
1888
|
}, (thumb, index) => thumb, 8);
|
|
@@ -1883,7 +1897,7 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1883
1897
|
setDynamicProps(n30, [unref(getPartAttrs)("mark", {
|
|
1884
1898
|
class: ["rp-range-slider__mark", { "rp-range-slider__mark--filled": _mark.filled }],
|
|
1885
1899
|
style: _mark.style
|
|
1886
|
-
}), { "data-filled": unref(
|
|
1900
|
+
}), { "data-filled": unref(toPresenceAttribute)(_mark.filled) }]);
|
|
1887
1901
|
});
|
|
1888
1902
|
setInsertionState(n30, null, 1);
|
|
1889
1903
|
createIf(() => _for_item0.value.hasLabel, () => {
|
|
@@ -1942,12 +1956,12 @@ var range_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @_
|
|
|
1942
1956
|
"onUpdate:overlapping": () => _on_update_overlapping
|
|
1943
1957
|
});
|
|
1944
1958
|
});
|
|
1945
|
-
n42
|
|
1959
|
+
on(n42, "pointerdown", (e) => unref(onTrackPointerDown)(e));
|
|
1946
1960
|
on(n42, "mouseenter", (e) => unref(onTooltipTrackMouseEnter)(e));
|
|
1947
1961
|
on(n42, "mouseleave", (e) => unref(onTooltipTrackMouseLeave)(e));
|
|
1948
1962
|
return n44;
|
|
1949
1963
|
}
|
|
1950
|
-
}), [["__scopeId", "data-v-
|
|
1964
|
+
}), [["__scopeId", "data-v-e27ae1af"]]);
|
|
1951
1965
|
//#endregion
|
|
1952
1966
|
//#region src/components/slider/types.ts
|
|
1953
1967
|
var sliderParts = [
|