@wix/site-ui 1.346.0 → 1.348.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{6706.js → 1093.js} +3 -3
- package/dist/{8724.js → 1219.js} +2 -2
- package/dist/{7373.js → 1288.js} +8 -2
- package/dist/{5299.js → 1381.js} +98 -127
- package/dist/{3056.js → 1607.js} +32 -34
- package/dist/1629.js +2 -0
- package/dist/1669.js +75 -0
- package/dist/1718.js +26 -0
- package/dist/{1477.js → 201.js} +17 -26
- package/dist/2221.js +9 -0
- package/dist/{2445.js → 226.js} +12 -48
- package/dist/2387.js +7 -0
- package/dist/2580.js +6 -0
- package/dist/{1500.js → 2859.js} +10 -34
- package/dist/3014.js +178 -0
- package/dist/{6247.js → 3054.js} +3 -3
- package/dist/{7642.js → 3093.js} +1 -1
- package/dist/3189.js +5 -0
- package/dist/{7564.js → 331.js} +2 -2
- package/dist/3357.js +7 -0
- package/dist/{487.js → 3398.js} +38 -39
- package/dist/3502.js +224 -0
- package/dist/3695.js +50 -0
- package/dist/3829.js +1 -1
- package/dist/{6588.js → 3859.js} +115 -92
- package/dist/{3670.js → 3910.js} +28 -21
- package/dist/392.js +7 -0
- package/dist/{4549.js → 4155.js} +11 -3
- package/dist/4226.js +7 -0
- package/dist/{6329.js → 4229.js} +1 -1
- package/dist/4293.js +3 -0
- package/dist/4346.js +853 -2
- package/dist/{285.js → 4472.js} +3 -3
- package/dist/4605.js +207 -0
- package/dist/{7366.js → 488.js} +60 -7
- package/dist/{8750.js → 497.js} +190 -375
- package/dist/4989.js +35 -0
- package/dist/{6270.js → 510.js} +157 -196
- package/dist/5258.js +26 -0
- package/dist/{5036.js → 5275.js} +0 -3
- package/dist/{8171.js → 5298.js} +90 -102
- package/dist/5473.js +11 -0
- package/dist/{4745.js → 5490.js} +3 -1
- package/dist/{6089.js → 5561.js} +869 -786
- package/dist/{8996.js → 5595.js} +4 -3
- package/dist/5890.js +25 -0
- package/dist/{6046.js → 5969.js} +1 -1
- package/dist/5984.js +38 -0
- package/dist/{8527.js → 6006.js} +3 -3
- package/dist/6040.js +97 -0
- package/dist/{8758.js → 6137.js} +10 -8
- package/dist/{4281.js → 6140.js} +18 -10
- package/dist/{8960.js → 6191.js} +2 -2
- package/dist/6240.js +121 -0
- package/dist/{4490.js → 6373.js} +7 -5
- package/dist/{904.js → 6487.js} +19 -17
- package/dist/{9635.js → 6498.js} +1 -1
- package/dist/6499.js +4 -7
- package/dist/6508.js +7 -0
- package/dist/{8225.js → 6540.js} +1 -0
- package/dist/6551.js +46 -0
- package/dist/{9369.js → 6620.js} +35 -34
- package/dist/{4143.js → 6838.js} +19 -10
- package/dist/6902.js +48 -0
- package/dist/6904.js +51 -0
- package/dist/70.js +24 -0
- package/dist/7024.js +39 -0
- package/dist/{6882.js → 721.js} +737 -362
- package/dist/{951.js → 7270.js} +4 -4
- package/dist/{3485.js → 7323.js} +143 -111
- package/dist/{7541.js → 7488.js} +2 -2
- package/dist/{4863.js → 7542.js} +7 -6
- package/dist/7551.js +28 -0
- package/dist/{7021.js → 7640.js} +1 -1
- package/dist/{353.js → 7692.js} +3 -7
- package/dist/{4707.js → 7930.js} +2 -2
- package/dist/{8052.js → 8.js} +80 -64
- package/dist/{6914.js → 8129.js} +3 -15
- package/dist/{3319.js → 8358.js} +62 -63
- package/dist/{5864.js → 8407.js} +13 -13
- package/dist/8488.js +15 -0
- package/dist/{4768.js → 8495.js} +1 -1
- package/dist/8734.js +171 -0
- package/dist/{1763.js → 9018.js} +205 -331
- package/dist/9053.js +29 -0
- package/dist/9067.js +41 -0
- package/dist/{2861.js → 9120.js} +2 -2
- package/dist/{42.js → 9197.js} +2 -2
- package/dist/{9189.js → 9248.js} +36 -17
- package/dist/{2801.js → 9252.js} +4 -9
- package/dist/9295.js +7 -0
- package/dist/9303.js +8 -0
- package/dist/{167.js → 9374.js} +1 -1
- package/dist/{9352.js → 9540.js} +17 -47
- package/dist/9576.js +51 -0
- package/dist/{8272.js → 9591.js} +36 -46
- package/dist/{6107.js → 9770.js} +2 -2
- package/dist/{5085.js → 9880.js} +6 -3
- package/dist/Accordion/index.d.ts +207 -41
- package/dist/Accordion/index.js +75 -177
- package/dist/AlertDialog/index.d.ts +440 -140
- package/dist/AlertDialog/index.js +3 -13
- package/dist/Autocomplete/index.d.ts +722 -150
- package/dist/Autocomplete/index.js +16 -29
- package/dist/Avatar/index.d.ts +38 -3
- package/dist/Avatar/index.js +82 -28
- package/dist/Breadcrumbs/index.d.ts +63 -91
- package/dist/Breadcrumbs/index.js +1 -1
- package/dist/Button/index.d.ts +11 -0
- package/dist/Button/index.js +2 -2
- package/dist/Checkbox/index.d.ts +206 -36
- package/dist/Checkbox/index.js +293 -8
- package/dist/CheckboxField/index.css +1 -1
- package/dist/CheckboxField/index.d.ts +40 -36
- package/dist/CheckboxGroup/index.d.ts +50 -36
- package/dist/CheckboxGroup/index.js +87 -58
- package/dist/CheckboxGroupField/index.css +1 -1
- package/dist/Collapsible/index.d.ts +128 -36
- package/dist/Collapsible/index.js +21 -25
- package/dist/Combobox/index.d.ts +801 -158
- package/dist/Combobox/index.js +70 -114
- package/dist/ContextMenu/index.d.ts +1162 -195
- package/dist/ContextMenu/index.js +46 -36
- package/dist/Dialog/index.d.ts +425 -133
- package/dist/Dialog/index.js +8 -4
- package/dist/Drawer/index.d.ts +589 -144
- package/dist/Drawer/index.js +482 -562
- package/dist/Field/index.css +1 -1
- package/dist/Field/index.d.ts +341 -42
- package/dist/Field/index.js +123 -273
- package/dist/Fieldset/index.d.ts +11 -0
- package/dist/Fieldset/index.js +10 -17
- package/dist/Form/index.d.ts +43 -39
- package/dist/Form/index.js +58 -50
- package/dist/Input/index.css +1 -1
- package/dist/Input/index.d.ts +94 -42
- package/dist/Input/index.js +1 -1
- package/dist/Menu/index.d.ts +1140 -175
- package/dist/Menu/index.js +51 -67
- package/dist/Menubar/index.d.ts +651 -173
- package/dist/Menubar/index.js +12 -16
- package/dist/Meter/index.js +21 -18
- package/dist/NavigationMenu/index.d.ts +370 -86
- package/dist/NavigationMenu/index.js +144 -178
- package/dist/NumberField/index.css +1 -1
- package/dist/NumberField/index.d.ts +507 -47
- package/dist/NumberField/index.js +434 -718
- package/dist/Popover/index.d.ts +561 -142
- package/dist/Popover/index.js +181 -252
- package/dist/PreviewCard/index.d.ts +507 -143
- package/dist/PreviewCard/index.js +97 -151
- package/dist/Progress/index.d.ts +117 -3
- package/dist/Progress/index.js +37 -36
- package/dist/Radio/index.d.ts +177 -7
- package/dist/Radio/index.js +54 -70
- package/dist/RadioField/index.css +1 -1
- package/dist/RadioField/index.d.ts +23 -7
- package/dist/RadioGroup/index.d.ts +51 -37
- package/dist/RadioGroup/index.js +60 -51
- package/dist/RadioGroupField/index.css +1 -1
- package/dist/RadioGroupField/index.d.ts +40 -37
- package/dist/ScrollArea/index.d.ts +295 -1
- package/dist/ScrollArea/index.js +256 -324
- package/dist/Select/index.d.ts +516 -123
- package/dist/Select/index.js +513 -635
- package/dist/SelectField/index.css +1 -1
- package/dist/SelectField/index.d.ts +109 -134
- package/dist/SelectField/index.js +5 -1
- package/dist/Separator/index.d.ts +12 -0
- package/dist/Separator/index.js +1 -1
- package/dist/Slider/index.d.ts +383 -64
- package/dist/Slider/index.js +298 -374
- package/dist/Switch/index.d.ts +184 -37
- package/dist/Switch/index.js +44 -58
- package/dist/Tabs/index.d.ts +220 -35
- package/dist/Tabs/index.js +199 -193
- package/dist/Toast/index.d.ts +280 -64
- package/dist/Toast/index.js +299 -374
- package/dist/Toggle/index.d.ts +55 -35
- package/dist/Toggle/index.js +19 -13
- package/dist/ToggleGroup/index.d.ts +62 -35
- package/dist/ToggleGroup/index.js +13 -31
- package/dist/Toolbar/index.d.ts +117 -2
- package/dist/Toolbar/index.js +31 -43
- package/dist/Tooltip/index.d.ts +507 -150
- package/dist/Tooltip/index.js +163 -213
- package/dist/index.d.ts +12912 -5382
- package/package.json +3 -3
- package/dist/2205.js +0 -26
- package/dist/2274.js +0 -34
- package/dist/2287.js +0 -17
- package/dist/3020.js +0 -7
- package/dist/3021.js +0 -72
- package/dist/3140.js +0 -4
- package/dist/3248.js +0 -307
- package/dist/4026.js +0 -12
- package/dist/4922.js +0 -15
- package/dist/5659.js +0 -4
- package/dist/5992.js +0 -447
- package/dist/6330.js +0 -30
- package/dist/6535.js +0 -72
- package/dist/6917.js +0 -55
- package/dist/7725.js +0 -10
- package/dist/7871.js +0 -38
- package/dist/8106.js +0 -239
- package/dist/8685.js +0 -102
- package/dist/8935.js +0 -8
- package/dist/8971.js +0 -40
- package/dist/8979.js +0 -10
- package/dist/9048.js +0 -52
- package/dist/9087.js +0 -256
- package/dist/9255.js +0 -136
- /package/dist/{1457.js → 1068.js} +0 -0
- /package/dist/{6003.js → 1234.js} +0 -0
- /package/dist/{4723.js → 1282.js} +0 -0
- /package/dist/{6825.js → 1876.js} +0 -0
- /package/dist/{5778.js → 1885.js} +0 -0
- /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
- /package/dist/{1279.js → 3278.js} +0 -0
- /package/dist/{3296.js → 5568.js} +0 -0
- /package/dist/{8685.css → 6240.css} +0 -0
- /package/dist/{9829.js → 6488.js} +0 -0
- /package/dist/{9863.js → 6534.js} +0 -0
- /package/dist/{4495.js → 7718.js} +0 -0
- /package/dist/{3395.js → 8866.js} +0 -0
- /package/dist/{2418.js → 9837.js} +0 -0
package/dist/Slider/index.js
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../
|
|
4
|
-
import {
|
|
2
|
+
import { utils_formatErrorMessage } from "../5473.js";
|
|
3
|
+
import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../201.js";
|
|
4
|
+
import { focusElementWithVisible, getControlById, useLabel } from "../6838.js";
|
|
5
5
|
import { getWindow, isHTMLElement, isElement } from "../3829.js";
|
|
6
|
-
import {
|
|
7
|
-
import { formatNumber } from "../
|
|
8
|
-
import { clamp } from "../
|
|
9
|
-
import { useDirection } from "../
|
|
10
|
-
import { useStableCallback } from "../
|
|
11
|
-
import { useValueAsRef } from "../
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
6
|
+
import { warn, mergeProps, useMergedRefs, useRenderElement } from "../9591.js";
|
|
7
|
+
import { formatNumber } from "../8129.js";
|
|
8
|
+
import { clamp } from "../5568.js";
|
|
9
|
+
import { useDirection } from "../6534.js";
|
|
10
|
+
import { useStableCallback } from "../7488.js";
|
|
11
|
+
import { useValueAsRef } from "../7930.js";
|
|
12
|
+
import { getTarget, contains, activeElement } from "../4155.js";
|
|
13
|
+
import { createGenericEventDetails, createChangeEventDetails } from "../8495.js";
|
|
14
|
+
import { trackPress, keyboard, inputChange } from "../9837.js";
|
|
15
|
+
import { ownerDocument } from "../6488.js";
|
|
16
|
+
import { useAnimationFrame } from "../5595.js";
|
|
17
|
+
import { addEventListener } from "../1282.js";
|
|
18
|
+
import { isTouchLikePointerType } from "../8734.js";
|
|
19
|
+
import { ARROW_LEFT, ARROW_UP, COMPOSITE_KEYS, PAGE_DOWN, ARROW_RIGHT, ARROW_DOWN } from "../2859.js";
|
|
20
|
+
import { useBaseUiId } from "../5969.js";
|
|
21
|
+
import { useSetFieldFocused } from "../5890.js";
|
|
22
|
+
import { useLabelableId } from "../6551.js";
|
|
23
|
+
import { useCompositeListItem } from "../9576.js";
|
|
24
|
+
import { valueToPercent } from "../8866.js";
|
|
25
|
+
import { useIsHydrating, PrehydrationScript } from "../5984.js";
|
|
26
|
+
import { useIsoLayoutEffect } from "../3357.js";
|
|
27
|
+
import { visuallyHidden } from "../6540.js";
|
|
28
|
+
import { matchesFocusVisible } from "../6137.js";
|
|
29
|
+
import { areArraysEqual } from "../2387.js";
|
|
30
|
+
import { getDefaultLabelId, resolveAriaLabelledBy } from "../1876.js";
|
|
31
|
+
import { useFormContext } from "../9880.js";
|
|
32
|
+
import { useControlled } from "../6006.js";
|
|
33
|
+
import { useRegisterFieldControl } from "../6140.js";
|
|
34
|
+
import { useValueChanged } from "../9252.js";
|
|
35
|
+
import { CompositeList } from "../3014.js";
|
|
34
36
|
import * as __rspack_external_react from "react";
|
|
35
37
|
const SliderRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
36
38
|
if ("production" !== process.env.NODE_ENV) SliderRootContext.displayName = "SliderRootContext";
|
|
37
39
|
function useSliderRootContext() {
|
|
38
40
|
const context = __rspack_external_react.useContext(SliderRootContext);
|
|
39
|
-
if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SliderRootContext is missing. Slider parts must be placed within <Slider.Root>.' :
|
|
41
|
+
if (void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: SliderRootContext is missing. Slider parts must be placed within <Slider.Root>.' : utils_formatErrorMessage(62));
|
|
40
42
|
return context;
|
|
41
43
|
}
|
|
44
|
+
const nullMapping = ()=>null;
|
|
42
45
|
const sliderStateAttributesMapping = {
|
|
43
|
-
activeThumbIndex:
|
|
44
|
-
max:
|
|
45
|
-
min:
|
|
46
|
-
minStepsBetweenValues:
|
|
47
|
-
step:
|
|
48
|
-
values:
|
|
46
|
+
activeThumbIndex: nullMapping,
|
|
47
|
+
max: nullMapping,
|
|
48
|
+
min: nullMapping,
|
|
49
|
+
minStepsBetweenValues: nullMapping,
|
|
50
|
+
step: nullMapping,
|
|
51
|
+
values: nullMapping,
|
|
49
52
|
...fieldValidityMapping
|
|
50
53
|
};
|
|
51
54
|
const SliderLabel_SliderLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
@@ -55,7 +58,7 @@ const SliderLabel_SliderLabel = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
55
58
|
const { state, setLabelId, controlRef, rootLabelId } = useSliderRootContext();
|
|
56
59
|
function focusControl(event, controlId) {
|
|
57
60
|
if (controlId) {
|
|
58
|
-
const controlElement =
|
|
61
|
+
const controlElement = getControlById(event.currentTarget, controlId);
|
|
59
62
|
if (isHTMLElement(controlElement)) return void focusElementWithVisible(controlElement);
|
|
60
63
|
}
|
|
61
64
|
const fallbackInputs = controlRef.current?.querySelectorAll('input[type="range"]');
|
|
@@ -80,20 +83,14 @@ const SliderLabel_SliderLabel = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
80
83
|
if ("production" !== process.env.NODE_ENV) SliderLabel_SliderLabel.displayName = "SliderLabel";
|
|
81
84
|
const SliderValue_SliderValue = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
82
85
|
const { 'aria-live': ariaLive = 'off', render, className, children, style, ...elementProps } = componentProps;
|
|
83
|
-
const { thumbMap, state, values,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const formattedValues = __rspack_external_react.useMemo(()=>{
|
|
88
|
-
const arr = [];
|
|
89
|
-
for(let i = 0; i < values.length; i += 1)arr.push(formatNumber(values[i], locale, formatOptionsRef.current ?? void 0));
|
|
90
|
-
return arr;
|
|
91
|
-
}, [
|
|
92
|
-
formatOptionsRef,
|
|
86
|
+
const { thumbMap, state, values, format, locale } = useSliderRootContext();
|
|
87
|
+
const outputFor = Array.from(thumbMap.values(), ({ inputId })=>inputId).join(' ').trim() || void 0;
|
|
88
|
+
const formattedValues = __rspack_external_react.useMemo(()=>values.map((v)=>formatNumber(v, locale, format)), [
|
|
89
|
+
format,
|
|
93
90
|
locale,
|
|
94
91
|
values
|
|
95
92
|
]);
|
|
96
|
-
const defaultDisplayValue =
|
|
93
|
+
const defaultDisplayValue = formattedValues.join(' – ');
|
|
97
94
|
const element = useRenderElement('output', componentProps, {
|
|
98
95
|
state,
|
|
99
96
|
ref: forwardedRef,
|
|
@@ -110,12 +107,9 @@ const SliderValue_SliderValue = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
110
107
|
return element;
|
|
111
108
|
});
|
|
112
109
|
if ("production" !== process.env.NODE_ENV) SliderValue_SliderValue.displayName = "SliderValue";
|
|
113
|
-
function getMidpoint(element) {
|
|
110
|
+
function getMidpoint(element, vertical) {
|
|
114
111
|
const rect = element.getBoundingClientRect();
|
|
115
|
-
return
|
|
116
|
-
x: (rect.left + rect.right) / 2,
|
|
117
|
-
y: (rect.top + rect.bottom) / 2
|
|
118
|
-
};
|
|
112
|
+
return vertical ? (rect.top + rect.bottom) / 2 : (rect.left + rect.right) / 2;
|
|
119
113
|
}
|
|
120
114
|
function getDecimalPrecision(num) {
|
|
121
115
|
if (0 === num) return 0;
|
|
@@ -133,15 +127,11 @@ function roundValueToStep(value, step, min) {
|
|
|
133
127
|
}
|
|
134
128
|
function validateMinimumDistance(values, step, minStepsBetweenValues) {
|
|
135
129
|
if (!Array.isArray(values)) return true;
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return acc;
|
|
140
|
-
}, []);
|
|
141
|
-
return Math.min(...distances) >= step * minStepsBetweenValues;
|
|
130
|
+
const minDistance = step * minStepsBetweenValues;
|
|
131
|
+
for(let i = 0; i < values.length - 1; i += 1)if (!(Math.abs(values[i] - values[i + 1]) >= minDistance)) return false;
|
|
132
|
+
return true;
|
|
142
133
|
}
|
|
143
|
-
function getPushedThumbValues(
|
|
144
|
-
if (0 === values.length) return [];
|
|
134
|
+
function getPushedThumbValues(values, index, nextValue, min, max, step, minStepsBetweenValues, initialValues) {
|
|
145
135
|
const nextValues = values.slice();
|
|
146
136
|
const minValueDifference = step * minStepsBetweenValues;
|
|
147
137
|
const lastIndex = nextValues.length - 1;
|
|
@@ -152,7 +142,7 @@ function getPushedThumbValues({ values, index, nextValue, min, max, step, minSte
|
|
|
152
142
|
for(let i = index + 1; i <= lastIndex; i += 1){
|
|
153
143
|
const minAllowed = nextValues[i - 1] + minValueDifference;
|
|
154
144
|
const maxAllowed = max - (lastIndex - i) * minValueDifference;
|
|
155
|
-
const initialValue = baseInitialValues[i]
|
|
145
|
+
const initialValue = baseInitialValues[i];
|
|
156
146
|
let candidate = Math.max(nextValues[i], minAllowed);
|
|
157
147
|
if (initialValue < candidate) candidate = Math.max(initialValue, minAllowed);
|
|
158
148
|
nextValues[i] = clamp(candidate, minAllowed, maxAllowed);
|
|
@@ -160,7 +150,7 @@ function getPushedThumbValues({ values, index, nextValue, min, max, step, minSte
|
|
|
160
150
|
for(let i = index - 1; i >= 0; i -= 1){
|
|
161
151
|
const maxAllowed = nextValues[i + 1] - minValueDifference;
|
|
162
152
|
const minAllowed = min + i * minValueDifference;
|
|
163
|
-
const initialValue = baseInitialValues[i]
|
|
153
|
+
const initialValue = baseInitialValues[i];
|
|
164
154
|
let candidate = Math.min(nextValues[i], maxAllowed);
|
|
165
155
|
if (initialValue > candidate) candidate = Math.min(initialValue, maxAllowed);
|
|
166
156
|
nextValues[i] = clamp(candidate, minAllowed, maxAllowed);
|
|
@@ -168,7 +158,7 @@ function getPushedThumbValues({ values, index, nextValue, min, max, step, minSte
|
|
|
168
158
|
for(let i = 0; i <= lastIndex; i += 1)nextValues[i] = Number(nextValues[i].toFixed(12));
|
|
169
159
|
return nextValues;
|
|
170
160
|
}
|
|
171
|
-
function resolveThumbCollision(
|
|
161
|
+
function resolveThumbCollision(behavior, values, currentValues, initialValues, pressedIndex, nextValue, min, max, step, minStepsBetweenValues) {
|
|
172
162
|
const activeValues = currentValues ?? values;
|
|
173
163
|
const baselineValues = initialValues ?? values;
|
|
174
164
|
const range = activeValues.length > 1;
|
|
@@ -178,19 +168,23 @@ function resolveThumbCollision({ behavior, values, currentValues, initialValues,
|
|
|
178
168
|
didSwap: false
|
|
179
169
|
};
|
|
180
170
|
const minValueDifference = step * minStepsBetweenValues;
|
|
171
|
+
if ('push' === behavior) return {
|
|
172
|
+
value: getPushedThumbValues(activeValues, pressedIndex, nextValue, min, max, step, minStepsBetweenValues),
|
|
173
|
+
thumbIndex: pressedIndex,
|
|
174
|
+
didSwap: false
|
|
175
|
+
};
|
|
176
|
+
const candidateValues = activeValues.slice();
|
|
177
|
+
const previousNeighbor = candidateValues[pressedIndex - 1];
|
|
178
|
+
const nextNeighbor = candidateValues[pressedIndex + 1];
|
|
179
|
+
const lowerBound = null != previousNeighbor ? previousNeighbor + minValueDifference : min;
|
|
180
|
+
const upperBound = null != nextNeighbor ? nextNeighbor - minValueDifference : max;
|
|
181
|
+
const pressedValueAfterClamp = Number(clamp(nextValue, lowerBound, upperBound).toFixed(12));
|
|
182
|
+
candidateValues[pressedIndex] = pressedValueAfterClamp;
|
|
181
183
|
switch(behavior){
|
|
182
184
|
case 'swap':
|
|
183
185
|
{
|
|
184
186
|
const pressedInitialValue = activeValues[pressedIndex];
|
|
185
187
|
const epsilon = 1e-7;
|
|
186
|
-
const candidateValues = activeValues.slice();
|
|
187
|
-
const previousNeighbor = candidateValues[pressedIndex - 1];
|
|
188
|
-
const nextNeighbor = candidateValues[pressedIndex + 1];
|
|
189
|
-
const lowerBound = null != previousNeighbor ? previousNeighbor + minValueDifference : min;
|
|
190
|
-
const upperBound = null != nextNeighbor ? nextNeighbor - minValueDifference : max;
|
|
191
|
-
const constrainedValue = clamp(nextValue, lowerBound, upperBound);
|
|
192
|
-
const pressedValueAfterClamp = Number(constrainedValue.toFixed(12));
|
|
193
|
-
candidateValues[pressedIndex] = pressedValueAfterClamp;
|
|
194
188
|
const movingForward = nextValue > pressedInitialValue;
|
|
195
189
|
const movingBackward = nextValue < pressedInitialValue;
|
|
196
190
|
const shouldSwapForward = movingForward && null != nextNeighbor && nextValue >= nextNeighbor - epsilon;
|
|
@@ -209,66 +203,29 @@ function resolveThumbCollision({ behavior, values, currentValues, initialValues,
|
|
|
209
203
|
});
|
|
210
204
|
let nextValueForTarget = nextValue;
|
|
211
205
|
nextValueForTarget = shouldSwapForward ? Math.max(nextValue, candidateValues[targetIndex]) : Math.min(nextValue, candidateValues[targetIndex]);
|
|
212
|
-
const adjustedValues = getPushedThumbValues(
|
|
213
|
-
values: candidateValues,
|
|
214
|
-
index: targetIndex,
|
|
215
|
-
nextValue: nextValueForTarget,
|
|
216
|
-
min,
|
|
217
|
-
max,
|
|
218
|
-
step,
|
|
219
|
-
minStepsBetweenValues,
|
|
220
|
-
initialValues: initialValuesForPush
|
|
221
|
-
});
|
|
206
|
+
const adjustedValues = getPushedThumbValues(candidateValues, targetIndex, nextValueForTarget, min, max, step, minStepsBetweenValues, initialValuesForPush);
|
|
222
207
|
const neighborIndex = shouldSwapForward ? targetIndex - 1 : targetIndex + 1;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
adjustedValues[neighborIndex] = Number(restoredValue.toFixed(12));
|
|
232
|
-
}
|
|
208
|
+
const previousValue = adjustedValues[neighborIndex - 1];
|
|
209
|
+
const nextValueAfter = adjustedValues[neighborIndex + 1];
|
|
210
|
+
let neighborLowerBound = null != previousValue ? previousValue + minValueDifference : min;
|
|
211
|
+
neighborLowerBound = Math.max(neighborLowerBound, min + neighborIndex * minValueDifference);
|
|
212
|
+
let neighborUpperBound = null != nextValueAfter ? nextValueAfter - minValueDifference : max;
|
|
213
|
+
neighborUpperBound = Math.min(neighborUpperBound, max - (adjustedValues.length - 1 - neighborIndex) * minValueDifference);
|
|
214
|
+
const restoredValue = clamp(pressedValueAfterClamp, neighborLowerBound, neighborUpperBound);
|
|
215
|
+
adjustedValues[neighborIndex] = Number(restoredValue.toFixed(12));
|
|
233
216
|
return {
|
|
234
217
|
value: adjustedValues,
|
|
235
218
|
thumbIndex: targetIndex,
|
|
236
219
|
didSwap: true
|
|
237
220
|
};
|
|
238
221
|
}
|
|
239
|
-
case 'push':
|
|
240
|
-
{
|
|
241
|
-
const nextValues = getPushedThumbValues({
|
|
242
|
-
values: activeValues,
|
|
243
|
-
index: pressedIndex,
|
|
244
|
-
nextValue,
|
|
245
|
-
min,
|
|
246
|
-
max,
|
|
247
|
-
step,
|
|
248
|
-
minStepsBetweenValues
|
|
249
|
-
});
|
|
250
|
-
return {
|
|
251
|
-
value: nextValues,
|
|
252
|
-
thumbIndex: pressedIndex,
|
|
253
|
-
didSwap: false
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
222
|
case 'none':
|
|
257
223
|
default:
|
|
258
|
-
{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const upperBound = null != nextNeighbor ? nextNeighbor - minValueDifference : max;
|
|
264
|
-
const constrainedValue = clamp(nextValue, lowerBound, upperBound);
|
|
265
|
-
candidateValues[pressedIndex] = Number(constrainedValue.toFixed(12));
|
|
266
|
-
return {
|
|
267
|
-
value: candidateValues,
|
|
268
|
-
thumbIndex: pressedIndex,
|
|
269
|
-
didSwap: false
|
|
270
|
-
};
|
|
271
|
-
}
|
|
224
|
+
return {
|
|
225
|
+
value: candidateValues,
|
|
226
|
+
thumbIndex: pressedIndex,
|
|
227
|
+
didSwap: false
|
|
228
|
+
};
|
|
272
229
|
}
|
|
273
230
|
}
|
|
274
231
|
const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
|
|
@@ -307,7 +264,7 @@ function getFingerCoords(event, touchIdRef) {
|
|
|
307
264
|
}
|
|
308
265
|
const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
309
266
|
const { render: renderProp, className, style, ...elementProps } = componentProps;
|
|
310
|
-
const { disabled, dragging, inset,
|
|
267
|
+
const { disabled, dragging, inset, isArrayValue, lastChangeReasonRef, max, min, minStepsBetweenValues, onValueCommitted, orientation, pressedThumbCenterOffsetRef, pressedThumbIndexRef, pressedValuesRef, registerFieldControlRef, renderBeforeHydration, setActive, setDragging, setValue, state, step, thumbCollisionBehavior, thumbRefs, values } = useSliderRootContext();
|
|
311
268
|
const direction = useDirection();
|
|
312
269
|
const range = values.length > 1;
|
|
313
270
|
const vertical = 'vertical' === orientation;
|
|
@@ -319,20 +276,34 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
319
276
|
const touchIdRef = __rspack_external_react.useRef(null);
|
|
320
277
|
const moveCountRef = __rspack_external_react.useRef(0);
|
|
321
278
|
const insetThumbOffsetRef = __rspack_external_react.useRef(0);
|
|
279
|
+
const currentInteractionValueRef = __rspack_external_react.useRef(null);
|
|
280
|
+
const pointerGestureRef = __rspack_external_react.useRef(false);
|
|
322
281
|
const latestValuesRef = useValueAsRef(values);
|
|
282
|
+
function getThumbInput(el) {
|
|
283
|
+
return el?.querySelector('input[type="range"]');
|
|
284
|
+
}
|
|
323
285
|
function updatePressedThumb(nextIndex) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
286
|
+
pressedThumbIndexRef.current = nextIndex;
|
|
287
|
+
if (!thumbRefs.current[nextIndex]) pressedThumbCenterOffsetRef.current = null;
|
|
288
|
+
}
|
|
289
|
+
function resetPressedThumb() {
|
|
290
|
+
pressedThumbIndexRef.current = -1;
|
|
291
|
+
pressedThumbCenterOffsetRef.current = null;
|
|
292
|
+
}
|
|
293
|
+
function isTargetDisabledThumb(target) {
|
|
294
|
+
if (!isElement(target)) return false;
|
|
295
|
+
return thumbRefs.current.some((thumbEl)=>{
|
|
296
|
+
if (!isElement(thumbEl) || !contains(thumbEl, target)) return false;
|
|
297
|
+
return getThumbInput(thumbEl)?.disabled === true;
|
|
298
|
+
});
|
|
332
299
|
}
|
|
333
300
|
function getFingerState(fingerCoords) {
|
|
334
301
|
const control = controlRef.current;
|
|
335
|
-
|
|
302
|
+
const thumbIndex = pressedThumbIndexRef.current;
|
|
303
|
+
if (!control || thumbIndex < 0 || thumbIndex >= values.length) {
|
|
304
|
+
if (thumbIndex >= values.length) currentInteractionValueRef.current = null;
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
336
307
|
const { width, height, bottom, left, right } = control.getBoundingClientRect();
|
|
337
308
|
const controlOffset = getControlOffset(stylesRef.current, vertical);
|
|
338
309
|
const insetThumbOffset = insetThumbOffsetRef.current;
|
|
@@ -346,30 +317,17 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
346
317
|
newValue = roundValueToStep(newValue, step, min);
|
|
347
318
|
newValue = clamp(newValue, min, max);
|
|
348
319
|
if (!range) return {
|
|
349
|
-
value:
|
|
350
|
-
|
|
320
|
+
value: isArrayValue ? [
|
|
321
|
+
newValue
|
|
322
|
+
] : newValue,
|
|
323
|
+
thumbIndex,
|
|
351
324
|
didSwap: false
|
|
352
325
|
};
|
|
353
|
-
|
|
354
|
-
if (thumbIndex < 0) return null;
|
|
355
|
-
const collisionResult = resolveThumbCollision({
|
|
356
|
-
behavior: thumbCollisionBehavior,
|
|
357
|
-
values,
|
|
358
|
-
currentValues: latestValuesRef.current ?? values,
|
|
359
|
-
initialValues: pressedValuesRef.current,
|
|
360
|
-
pressedIndex: thumbIndex,
|
|
361
|
-
nextValue: newValue,
|
|
362
|
-
min,
|
|
363
|
-
max,
|
|
364
|
-
step,
|
|
365
|
-
minStepsBetweenValues
|
|
366
|
-
});
|
|
367
|
-
if ('swap' === thumbCollisionBehavior && collisionResult.didSwap) updatePressedThumb(collisionResult.thumbIndex);
|
|
368
|
-
else pressedThumbIndexRef.current = collisionResult.thumbIndex;
|
|
369
|
-
return collisionResult;
|
|
326
|
+
return resolveThumbCollision(thumbCollisionBehavior, values, latestValuesRef.current, pressedValuesRef.current, thumbIndex, newValue, min, max, step, minStepsBetweenValues);
|
|
370
327
|
}
|
|
371
328
|
function startPressing(fingerCoords) {
|
|
372
329
|
pressedValuesRef.current = range ? values.slice() : null;
|
|
330
|
+
currentInteractionValueRef.current = null;
|
|
373
331
|
latestValuesRef.current = values;
|
|
374
332
|
const pressedThumbIndex = pressedThumbIndexRef.current;
|
|
375
333
|
let closestThumbIndex = pressedThumbIndex;
|
|
@@ -385,9 +343,9 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
385
343
|
closestThumbIndex = -1;
|
|
386
344
|
for(let i = 0; i < thumbRefs.current.length; i += 1){
|
|
387
345
|
const thumbEl = thumbRefs.current[i];
|
|
388
|
-
if (isElement(thumbEl)) {
|
|
389
|
-
const midpoint = getMidpoint(thumbEl);
|
|
390
|
-
const distance = Math.abs(fingerCoords[axis] - midpoint
|
|
346
|
+
if (isElement(thumbEl) && !getThumbInput(thumbEl)?.disabled) {
|
|
347
|
+
const midpoint = getMidpoint(thumbEl, vertical);
|
|
348
|
+
const distance = Math.abs(fingerCoords[axis] - midpoint);
|
|
391
349
|
if (void 0 === minDistance || distance <= minDistance) {
|
|
392
350
|
closestThumbIndex = i;
|
|
393
351
|
minDistance = distance;
|
|
@@ -406,13 +364,29 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
406
364
|
}
|
|
407
365
|
}
|
|
408
366
|
function focusThumb(thumbIndex) {
|
|
409
|
-
const input = thumbRefs.current?.[thumbIndex]
|
|
367
|
+
const input = getThumbInput(thumbRefs.current?.[thumbIndex]);
|
|
410
368
|
if (!input) return;
|
|
411
369
|
input.focus({
|
|
412
370
|
preventScroll: true,
|
|
413
371
|
focusVisible: false
|
|
414
372
|
});
|
|
415
373
|
}
|
|
374
|
+
function setValueFromPointer(finger, reason, nativeEvent) {
|
|
375
|
+
const applied = setValue(finger.value, createChangeEventDetails(reason, nativeEvent, void 0, {
|
|
376
|
+
activeThumbIndex: finger.thumbIndex
|
|
377
|
+
}));
|
|
378
|
+
if (applied) {
|
|
379
|
+
currentInteractionValueRef.current = finger.value;
|
|
380
|
+
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
381
|
+
finger.value
|
|
382
|
+
];
|
|
383
|
+
if (finger.didSwap) {
|
|
384
|
+
updatePressedThumb(finger.thumbIndex);
|
|
385
|
+
focusThumb(finger.thumbIndex);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return applied;
|
|
389
|
+
}
|
|
416
390
|
const handleTouchMove = useStableCallback((nativeEvent)=>{
|
|
417
391
|
const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
|
|
418
392
|
if (null == fingerCoords) return;
|
|
@@ -422,51 +396,48 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
422
396
|
if (null == finger) return;
|
|
423
397
|
if (validateMinimumDistance(finger.value, step, minStepsBetweenValues)) {
|
|
424
398
|
if (!dragging && moveCountRef.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) setDragging(true);
|
|
425
|
-
|
|
426
|
-
activeThumbIndex: finger.thumbIndex
|
|
427
|
-
}));
|
|
428
|
-
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
429
|
-
finger.value
|
|
430
|
-
];
|
|
431
|
-
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
399
|
+
setValueFromPointer(finger, "drag", nativeEvent);
|
|
432
400
|
}
|
|
433
401
|
});
|
|
434
|
-
|
|
402
|
+
const handleTouchEnd = useStableCallback((nativeEvent)=>{
|
|
403
|
+
if (null == getFingerCoords(nativeEvent, touchIdRef)) return;
|
|
435
404
|
setActive(-1);
|
|
436
405
|
setDragging(false);
|
|
437
|
-
pressedInputRef.current = null;
|
|
438
406
|
pressedThumbCenterOffsetRef.current = null;
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
if (null !=
|
|
407
|
+
const interactionValue = currentInteractionValueRef.current;
|
|
408
|
+
if (Array.isArray(interactionValue) && interactionValue.length !== values.length) currentInteractionValueRef.current = null;
|
|
409
|
+
if (null != currentInteractionValueRef.current) {
|
|
442
410
|
const commitReason = lastChangeReasonRef.current;
|
|
443
|
-
onValueCommitted(
|
|
411
|
+
onValueCommitted(currentInteractionValueRef.current, createGenericEventDetails(commitReason, nativeEvent));
|
|
444
412
|
}
|
|
445
413
|
if ('pointerType' in nativeEvent && controlRef.current?.hasPointerCapture(nativeEvent.pointerId)) controlRef.current?.releasePointerCapture(nativeEvent.pointerId);
|
|
446
414
|
pressedThumbIndexRef.current = -1;
|
|
447
|
-
touchIdRef.current = null;
|
|
448
|
-
pressedValuesRef.current = null;
|
|
449
415
|
stopListening();
|
|
450
|
-
}
|
|
416
|
+
});
|
|
417
|
+
const handlePointerCancel = useStableCallback((nativeEvent)=>{
|
|
418
|
+
if (null != touchIdRef.current) return;
|
|
419
|
+
handleTouchEnd(nativeEvent);
|
|
420
|
+
});
|
|
451
421
|
const handleTouchStart = useStableCallback((nativeEvent)=>{
|
|
422
|
+
const startedByPointer = pointerGestureRef.current;
|
|
423
|
+
pointerGestureRef.current = false;
|
|
452
424
|
if (disabled) return;
|
|
425
|
+
if (isTargetDisabledThumb(getTarget(nativeEvent))) return void resetPressedThumb();
|
|
453
426
|
const touch = nativeEvent.changedTouches[0];
|
|
454
|
-
if (null
|
|
455
|
-
|
|
456
|
-
if (
|
|
427
|
+
if (null == touch) return;
|
|
428
|
+
touchIdRef.current = touch.identifier;
|
|
429
|
+
if (!startedByPointer) {
|
|
430
|
+
const fingerCoords = {
|
|
431
|
+
x: touch.clientX,
|
|
432
|
+
y: touch.clientY
|
|
433
|
+
};
|
|
457
434
|
startPressing(fingerCoords);
|
|
458
435
|
const finger = getFingerState(fingerCoords);
|
|
459
436
|
if (null == finger) return;
|
|
460
437
|
focusThumb(finger.thumbIndex);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}));
|
|
464
|
-
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
465
|
-
finger.value
|
|
466
|
-
];
|
|
467
|
-
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
438
|
+
setValueFromPointer(finger, trackPress, nativeEvent);
|
|
439
|
+
moveCountRef.current = 0;
|
|
468
440
|
}
|
|
469
|
-
moveCountRef.current = 0;
|
|
470
441
|
const doc = ownerDocument(controlRef.current);
|
|
471
442
|
doc.addEventListener('touchmove', handleTouchMove, {
|
|
472
443
|
passive: true
|
|
@@ -474,14 +445,22 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
474
445
|
doc.addEventListener('touchend', handleTouchEnd, {
|
|
475
446
|
passive: true
|
|
476
447
|
});
|
|
448
|
+
doc.addEventListener('touchcancel', handleTouchEnd, {
|
|
449
|
+
passive: true
|
|
450
|
+
});
|
|
477
451
|
});
|
|
478
452
|
const stopListening = useStableCallback(()=>{
|
|
479
453
|
const doc = ownerDocument(controlRef.current);
|
|
480
454
|
doc.removeEventListener('pointermove', handleTouchMove);
|
|
481
455
|
doc.removeEventListener('pointerup', handleTouchEnd);
|
|
456
|
+
doc.removeEventListener('pointercancel', handlePointerCancel);
|
|
482
457
|
doc.removeEventListener('touchmove', handleTouchMove);
|
|
483
458
|
doc.removeEventListener('touchend', handleTouchEnd);
|
|
459
|
+
doc.removeEventListener('touchcancel', handleTouchEnd);
|
|
460
|
+
touchIdRef.current = null;
|
|
484
461
|
pressedValuesRef.current = null;
|
|
462
|
+
currentInteractionValueRef.current = null;
|
|
463
|
+
pointerGestureRef.current = false;
|
|
485
464
|
});
|
|
486
465
|
const focusFrame = useAnimationFrame();
|
|
487
466
|
__rspack_external_react.useEffect(()=>{
|
|
@@ -519,40 +498,39 @@ const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
519
498
|
{
|
|
520
499
|
['data-base-ui-slider-control']: renderBeforeHydration ? '' : void 0,
|
|
521
500
|
onPointerDown (event) {
|
|
501
|
+
pointerGestureRef.current = false;
|
|
522
502
|
const control = controlRef.current;
|
|
523
503
|
const target = getTarget(event.nativeEvent);
|
|
524
504
|
if (!control || disabled || event.defaultPrevented || !isElement(target) || 0 !== event.button) return;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
542
|
-
finger.value
|
|
543
|
-
];
|
|
544
|
-
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
505
|
+
if (isTargetDisabledThumb(target)) return void resetPressedThumb();
|
|
506
|
+
const fingerCoords = {
|
|
507
|
+
x: event.clientX,
|
|
508
|
+
y: event.clientY
|
|
509
|
+
};
|
|
510
|
+
startPressing(fingerCoords);
|
|
511
|
+
const finger = getFingerState(fingerCoords);
|
|
512
|
+
if (null == finger) return;
|
|
513
|
+
const pressedOnFocusedThumb = contains(thumbRefs.current[finger.thumbIndex], activeElement(ownerDocument(control)));
|
|
514
|
+
if (pressedOnFocusedThumb) event.preventDefault();
|
|
515
|
+
else focusFrame.request(()=>{
|
|
516
|
+
focusThumb(finger.thumbIndex);
|
|
517
|
+
});
|
|
518
|
+
setDragging(true);
|
|
519
|
+
const pressedOnAnyThumb = null != pressedThumbCenterOffsetRef.current;
|
|
520
|
+
if (!pressedOnAnyThumb) setValueFromPointer(finger, trackPress, event.nativeEvent);
|
|
547
521
|
if (event.nativeEvent.pointerId) control.setPointerCapture(event.nativeEvent.pointerId);
|
|
548
522
|
moveCountRef.current = 0;
|
|
549
|
-
|
|
523
|
+
pointerGestureRef.current = isTouchLikePointerType(event.pointerType);
|
|
524
|
+
const doc = ownerDocument(control);
|
|
550
525
|
doc.addEventListener('pointermove', handleTouchMove, {
|
|
551
526
|
passive: true
|
|
552
527
|
});
|
|
553
528
|
doc.addEventListener('pointerup', handleTouchEnd, {
|
|
554
529
|
once: true
|
|
555
530
|
});
|
|
531
|
+
doc.addEventListener('pointercancel', handlePointerCancel, {
|
|
532
|
+
once: true
|
|
533
|
+
});
|
|
556
534
|
}
|
|
557
535
|
},
|
|
558
536
|
elementProps
|
|
@@ -581,33 +559,19 @@ const SliderTrack_SliderTrack = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
581
559
|
return element;
|
|
582
560
|
});
|
|
583
561
|
if ("production" !== process.env.NODE_ENV) SliderTrack_SliderTrack.displayName = "SliderTrack";
|
|
562
|
+
const script = '!function(){const t=document.currentScript?.parentElement;if(!t)return;const e=t.closest("[data-base-ui-slider-control]");if(!e)return;const r=e.querySelector("[data-base-ui-slider-indicator]"),i=e.getBoundingClientRect(),n="vertical"===e.getAttribute("data-orientation")?"height":"width",o=e.querySelectorAll(\'input[type="range"]\'),l=o.length>1,s=o.length-1;let a=null,u=null;for(let t=0;t<o.length;t+=1){const e=o[t],y=parseFloat(e.getAttribute("value")??"");if(Number.isNaN(y))return;const c=e.parentElement;if(!c)return;const p=parseFloat(e.getAttribute("max")??"100"),g=parseFloat(e.getAttribute("min")??"0"),b=c?.getBoundingClientRect(),d=i[n]-b[n],m=100*(y-g)/(p-g),v=(b[n]/2+d*m/100)/i[n]*100;c.style.setProperty("--position",`${v}%`),Number.isFinite(v)&&(c.style.removeProperty("visibility"),r&&(0===t?(a=v,r.style.setProperty("--start-position",`${v}%`),l||r.style.removeProperty("visibility")):t===s&&(u=v-(a??0),r.style.setProperty("--end-position",`${v}%`),r.style.setProperty("--relative-size",`${u}%`),r.style.removeProperty("visibility"))))}}();';
|
|
584
563
|
function asc(a, b) {
|
|
585
564
|
return a - b;
|
|
586
565
|
}
|
|
587
|
-
function replaceArrayItemAtIndex(array, index, newValue) {
|
|
588
|
-
const output = array.slice();
|
|
589
|
-
output[index] = newValue;
|
|
590
|
-
return output.sort(asc);
|
|
591
|
-
}
|
|
592
566
|
function getSliderValue(valueInput, index, min, max, range, values) {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
567
|
+
const clamped = clamp(valueInput, min, max);
|
|
568
|
+
if (!range) return clamped;
|
|
569
|
+
const output = values.slice();
|
|
570
|
+
output[index] = clamp(clamped, values[index - 1] ?? -1 / 0, values[index + 1] ?? 1 / 0);
|
|
571
|
+
return output.sort(asc);
|
|
597
572
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
SliderThumbDataAttributes["dragging"] = "data-dragging";
|
|
601
|
-
SliderThumbDataAttributes["orientation"] = "data-orientation";
|
|
602
|
-
SliderThumbDataAttributes["disabled"] = "data-disabled";
|
|
603
|
-
SliderThumbDataAttributes["valid"] = "data-valid";
|
|
604
|
-
SliderThumbDataAttributes["invalid"] = "data-invalid";
|
|
605
|
-
SliderThumbDataAttributes["touched"] = "data-touched";
|
|
606
|
-
SliderThumbDataAttributes["dirty"] = "data-dirty";
|
|
607
|
-
SliderThumbDataAttributes["focused"] = "data-focused";
|
|
608
|
-
return SliderThumbDataAttributes;
|
|
609
|
-
}({});
|
|
610
|
-
const script = '!function(){const t=document.currentScript?.parentElement;if(!t)return;const e=t.closest("[data-base-ui-slider-control]");if(!e)return;const r=e.querySelector("[data-base-ui-slider-indicator]"),i=e.getBoundingClientRect(),n="vertical"===e.getAttribute("data-orientation")?"height":"width",o=e.querySelectorAll(\'input[type="range"]\'),l=o.length>1,s=o.length-1;let a=null,u=null;for(let t=0;t<o.length;t+=1){const e=o[t],y=parseFloat(e.getAttribute("value")??"");if(Number.isNaN(y))return;const c=e.parentElement;if(!c)return;const p=parseFloat(e.getAttribute("max")??"100"),g=parseFloat(e.getAttribute("min")??"0"),b=c?.getBoundingClientRect(),d=i[n]-b[n],m=100*(y-g)/(p-g),v=(b[n]/2+d*m/100)/i[n]*100;c.style.setProperty("--position",`${v}%`),Number.isFinite(v)&&(c.style.removeProperty("visibility"),r&&(0===t?(a=v,r.style.setProperty("--start-position",`${v}%`),l||r.style.removeProperty("visibility")):t===s&&(u=v-(a??0),r.style.setProperty("--end-position",`${v}%`),r.style.setProperty("--relative-size",`${u}%`),r.style.removeProperty("visibility"))))}}();';
|
|
573
|
+
const SliderThumbDataAttributes_index = 'data-index';
|
|
574
|
+
var _PrehydrationScript;
|
|
611
575
|
const ALL_KEYS = new Set([
|
|
612
576
|
...COMPOSITE_KEYS,
|
|
613
577
|
"PageUp",
|
|
@@ -615,31 +579,36 @@ const ALL_KEYS = new Set([
|
|
|
615
579
|
]);
|
|
616
580
|
function getDefaultAriaValueText(values, index, format, locale) {
|
|
617
581
|
if (index < 0) return;
|
|
618
|
-
if (2 === values.length) {
|
|
619
|
-
if (0 === index) return `${formatNumber(values[index], locale, format)} start range`;
|
|
620
|
-
return `${formatNumber(values[index], locale, format)} end range`;
|
|
621
|
-
}
|
|
582
|
+
if (2 === values.length) return `${formatNumber(values[index], locale, format)} ${0 === index ? 'start' : 'end'} range`;
|
|
622
583
|
return format ? formatNumber(values[index], locale, format) : void 0;
|
|
623
584
|
}
|
|
624
585
|
function getNewValue(thumbValue, increment, direction, min, max) {
|
|
625
|
-
const value =
|
|
586
|
+
const value = thumbValue + increment * direction;
|
|
626
587
|
const roundedValue = Number(value.toFixed(Math.max(getDecimalPrecision(thumbValue), getDecimalPrecision(increment), getDecimalPrecision(min))));
|
|
627
588
|
return clamp(roundedValue, min, max);
|
|
628
589
|
}
|
|
629
590
|
const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
630
|
-
const { render, children: childrenProp, className, 'aria-describedby': ariaDescribedByProp, 'aria-label': ariaLabelProp, 'aria-labelledby': ariaLabelledByProp, disabled: disabledProp = false, getAriaLabel: getAriaLabelProp, getAriaValueText: getAriaValueTextProp, id: idProp, index: indexProp, inputRef: inputRefProp, onBlur: onBlurProp, onFocus: onFocusProp, onKeyDown: onKeyDownProp, tabIndex: tabIndexProp, style, ...elementProps } = componentProps;
|
|
631
|
-
const { nonce } = useCSPContext();
|
|
591
|
+
const { render, children: childrenProp, className, 'aria-describedby': ariaDescribedByProp, 'aria-label': ariaLabelProp, 'aria-labelledby': ariaLabelledByProp, 'aria-valuetext': ariaValueTextProp, disabled: disabledProp = false, getAriaLabel: getAriaLabelProp, getAriaValueText: getAriaValueTextProp, id: idProp, index: indexProp, inputRef: inputRefProp, onBlur: onBlurProp, onFocus: onFocusProp, onKeyDown: onKeyDownProp, tabIndex: tabIndexProp, style, ...elementProps } = componentProps;
|
|
632
592
|
const id = useBaseUiId(idProp);
|
|
633
|
-
const { active: activeIndex, lastUsedThumbIndex, controlRef, disabled: contextDisabled, validation,
|
|
593
|
+
const { active: activeIndex, lastUsedThumbIndex, controlRef, disabled: contextDisabled, validation, format, handleInputChange, inset, isArrayValue, labelId, largeStep, locale, max, min, minStepsBetweenValues, form, name, orientation, pressedThumbCenterOffsetRef, pressedThumbIndexRef, renderBeforeHydration, setActive, setIndicatorPosition, state, step, thumbRefs, values: sliderValues } = useSliderRootContext();
|
|
634
594
|
const direction = useDirection();
|
|
635
595
|
const disabled = disabledProp || contextDisabled;
|
|
636
596
|
const range = sliderValues.length > 1;
|
|
637
597
|
const vertical = 'vertical' === orientation;
|
|
638
598
|
const rtl = 'rtl' === direction;
|
|
639
|
-
const { setTouched,
|
|
599
|
+
const { setTouched, validationMode } = useFieldRootContext();
|
|
640
600
|
const thumbRef = __rspack_external_react.useRef(null);
|
|
641
601
|
const inputRef = __rspack_external_react.useRef(null);
|
|
602
|
+
const setFocused = useSetFieldFocused(disabled, inputRef);
|
|
642
603
|
const restoringFocusVisibleRef = __rspack_external_react.useRef(false);
|
|
604
|
+
const handleFocusProp = useStableCallback((event)=>{
|
|
605
|
+
if (restoringFocusVisibleRef.current) return;
|
|
606
|
+
onFocusProp?.(event);
|
|
607
|
+
});
|
|
608
|
+
const handleBlurProp = useStableCallback((event)=>{
|
|
609
|
+
if (restoringFocusVisibleRef.current) return;
|
|
610
|
+
onBlurProp?.(event);
|
|
611
|
+
});
|
|
643
612
|
const defaultInputId = useBaseUiId();
|
|
644
613
|
const labelableId = useLabelableId();
|
|
645
614
|
const inputId = range ? defaultInputId : labelableId;
|
|
@@ -718,23 +687,19 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
718
687
|
else if (safeLastUsedThumbIndex === index) zIndex = 1;
|
|
719
688
|
} else if (activeIndex === index) zIndex = 1;
|
|
720
689
|
let thumbStyle;
|
|
721
|
-
thumbStyle = inset ? {
|
|
722
|
-
['--position']: `${positionPercent ?? 0}%`,
|
|
723
|
-
visibility: renderBeforeHydration && isHydrating || void 0 === positionPercent ? 'hidden' : void 0,
|
|
690
|
+
thumbStyle = inset || Number.isFinite(thumbValuePercent) ? {
|
|
724
691
|
position: 'absolute',
|
|
725
|
-
[startEdge]: 'var(--position)'
|
|
692
|
+
[startEdge]: inset ? 'var(--position)' : `${thumbValuePercent}%`,
|
|
726
693
|
[crossOffsetProperty]: '50%',
|
|
727
694
|
translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
|
|
728
|
-
zIndex
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
|
|
734
|
-
zIndex
|
|
695
|
+
zIndex,
|
|
696
|
+
...inset && {
|
|
697
|
+
['--position']: `${positionPercent ?? 0}%`,
|
|
698
|
+
visibility: renderBeforeHydration && isHydrating || void 0 === positionPercent ? 'hidden' : void 0
|
|
699
|
+
}
|
|
735
700
|
} : visuallyHidden;
|
|
736
701
|
let cssWritingMode;
|
|
737
|
-
if (
|
|
702
|
+
if (vertical) cssWritingMode = rtl ? 'vertical-rl' : 'vertical-lr';
|
|
738
703
|
const ariaLabel = 'function' == typeof getAriaLabelProp ? getAriaLabelProp(index) : ariaLabelProp;
|
|
739
704
|
const inputProps = mergeProps({
|
|
740
705
|
'aria-label': ariaLabel,
|
|
@@ -742,7 +707,7 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
742
707
|
'aria-describedby': ariaDescribedByProp,
|
|
743
708
|
'aria-orientation': orientation,
|
|
744
709
|
'aria-valuenow': thumbValue,
|
|
745
|
-
'aria-valuetext': 'function' == typeof getAriaValueTextProp ? getAriaValueTextProp(formatNumber(thumbValue, locale,
|
|
710
|
+
'aria-valuetext': 'function' == typeof getAriaValueTextProp ? getAriaValueTextProp(formatNumber(thumbValue, locale, format), thumbValue, index) : ariaValueTextProp ?? getDefaultAriaValueText(sliderValues, index, format, locale),
|
|
746
711
|
disabled,
|
|
747
712
|
form,
|
|
748
713
|
id: inputId,
|
|
@@ -761,47 +726,51 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
761
726
|
},
|
|
762
727
|
onBlur (event) {
|
|
763
728
|
if (restoringFocusVisibleRef.current) return void event.stopPropagation();
|
|
764
|
-
if (!thumbRef.current) return;
|
|
765
729
|
setActive(-1);
|
|
730
|
+
if (thumbRefs.current.some((thumb)=>contains(thumb, event.relatedTarget))) return;
|
|
766
731
|
setTouched(true);
|
|
767
732
|
setFocused(false);
|
|
768
|
-
if ('onBlur' === validationMode) validation.commit(getSliderValue(thumbValue, index, min, max,
|
|
733
|
+
if ('onBlur' === validationMode) validation.commit(getSliderValue(thumbValue, index, min, max, isArrayValue, sliderValues));
|
|
769
734
|
},
|
|
770
735
|
onKeyDown (event) {
|
|
736
|
+
if (event.defaultPrevented) return;
|
|
771
737
|
if (!ALL_KEYS.has(event.key)) return;
|
|
772
738
|
if (COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
|
|
773
739
|
let newValue = null;
|
|
740
|
+
let direction = 0;
|
|
741
|
+
let increment = event.shiftKey ? largeStep : step;
|
|
774
742
|
const roundedValue = roundValueToStep(thumbValue, step, min);
|
|
775
743
|
switch(event.key){
|
|
776
744
|
case ARROW_UP:
|
|
777
|
-
|
|
745
|
+
direction = 1;
|
|
778
746
|
break;
|
|
779
747
|
case ARROW_RIGHT:
|
|
780
|
-
|
|
748
|
+
direction = rtl ? -1 : 1;
|
|
781
749
|
break;
|
|
782
750
|
case ARROW_DOWN:
|
|
783
|
-
|
|
751
|
+
direction = -1;
|
|
784
752
|
break;
|
|
785
753
|
case ARROW_LEFT:
|
|
786
|
-
|
|
754
|
+
direction = rtl ? 1 : -1;
|
|
787
755
|
break;
|
|
788
756
|
case "PageUp":
|
|
789
|
-
|
|
757
|
+
increment = largeStep;
|
|
758
|
+
direction = 1;
|
|
790
759
|
break;
|
|
791
760
|
case PAGE_DOWN:
|
|
792
|
-
|
|
761
|
+
increment = largeStep;
|
|
762
|
+
direction = -1;
|
|
793
763
|
break;
|
|
794
764
|
case "End":
|
|
795
|
-
newValue = max;
|
|
796
|
-
if (range) newValue = Number.isFinite(sliderValues[index + 1]) ? sliderValues[index + 1] - step * minStepsBetweenValues : max;
|
|
765
|
+
newValue = range && Number.isFinite(sliderValues[index + 1]) ? sliderValues[index + 1] - step * minStepsBetweenValues : max;
|
|
797
766
|
break;
|
|
798
767
|
case "Home":
|
|
799
|
-
newValue = min;
|
|
800
|
-
if (range) newValue = Number.isFinite(sliderValues[index - 1]) ? sliderValues[index - 1] + step * minStepsBetweenValues : min;
|
|
768
|
+
newValue = range && Number.isFinite(sliderValues[index - 1]) ? sliderValues[index - 1] + step * minStepsBetweenValues : min;
|
|
801
769
|
break;
|
|
802
770
|
default:
|
|
803
771
|
break;
|
|
804
772
|
}
|
|
773
|
+
if (0 !== direction) newValue = getNewValue(roundedValue, increment, direction, min, max);
|
|
805
774
|
if (null !== newValue) {
|
|
806
775
|
const input = event.currentTarget;
|
|
807
776
|
if (!matchesFocusVisible(input)) {
|
|
@@ -823,10 +792,14 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
823
792
|
height: '100%',
|
|
824
793
|
writingMode: cssWritingMode
|
|
825
794
|
},
|
|
826
|
-
tabIndex: tabIndexProp
|
|
795
|
+
tabIndex: tabIndexProp,
|
|
827
796
|
type: 'range',
|
|
828
797
|
value: thumbValue ?? ''
|
|
829
|
-
}, validation.
|
|
798
|
+
}, (props)=>validation.getValidationProps(disabled, props), {
|
|
799
|
+
onFocus: handleFocusProp,
|
|
800
|
+
onBlur: handleBlurProp,
|
|
801
|
+
onKeyDown: onKeyDownProp
|
|
802
|
+
});
|
|
830
803
|
const mergedInputRef = useMergedRefs(inputRef, validation.inputRef, inputRefProp);
|
|
831
804
|
const element = useRenderElement('div', componentProps, {
|
|
832
805
|
state,
|
|
@@ -837,7 +810,7 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
837
810
|
],
|
|
838
811
|
props: [
|
|
839
812
|
{
|
|
840
|
-
[
|
|
813
|
+
[SliderThumbDataAttributes_index]: index,
|
|
841
814
|
children: /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
842
815
|
children: [
|
|
843
816
|
childrenProp,
|
|
@@ -846,27 +819,17 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
846
819
|
...inputProps,
|
|
847
820
|
suppressHydrationWarning: true
|
|
848
821
|
}),
|
|
849
|
-
inset &&
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
__html: script
|
|
853
|
-
},
|
|
854
|
-
suppressHydrationWarning: true
|
|
855
|
-
})
|
|
822
|
+
inset && last && renderBeforeHydration && (_PrehydrationScript || (_PrehydrationScript = /*#__PURE__*/ jsx(PrehydrationScript, {
|
|
823
|
+
script: script
|
|
824
|
+
})))
|
|
856
825
|
]
|
|
857
826
|
}),
|
|
858
827
|
id,
|
|
859
|
-
onBlur: onBlurProp,
|
|
860
|
-
onFocus: onFocusProp,
|
|
861
828
|
onPointerDown (event) {
|
|
829
|
+
if (disabled) return;
|
|
862
830
|
pressedThumbIndexRef.current = index;
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
const midpoint = getMidpoint(thumbRef.current);
|
|
866
|
-
const offset = ('horizontal' === orientation ? event.clientX : event.clientY) - midpoint[axis];
|
|
867
|
-
pressedThumbCenterOffsetRef.current = offset;
|
|
868
|
-
}
|
|
869
|
-
if (null != inputRef.current && pressedInputRef.current !== inputRef.current) pressedInputRef.current = inputRef.current;
|
|
831
|
+
const midpoint = getMidpoint(event.currentTarget, vertical);
|
|
832
|
+
pressedThumbCenterOffsetRef.current = (vertical ? event.clientY : event.clientX) - midpoint;
|
|
870
833
|
},
|
|
871
834
|
style: thumbStyle,
|
|
872
835
|
suppressHydrationWarning: renderBeforeHydration || void 0
|
|
@@ -878,43 +841,24 @@ const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
878
841
|
return element;
|
|
879
842
|
});
|
|
880
843
|
if ("production" !== process.env.NODE_ENV) SliderThumb_SliderThumb.displayName = "SliderThumb";
|
|
881
|
-
function
|
|
882
|
-
const visibility = void 0 === start || range && void 0 === end ? 'hidden' : void 0;
|
|
883
|
-
const startEdge = vertical ? 'bottom' : 'insetInlineStart';
|
|
884
|
-
const mainSide = vertical ? 'height' : 'width';
|
|
885
|
-
const crossSide = vertical ? 'width' : 'height';
|
|
886
|
-
const styles = {
|
|
887
|
-
visibility: renderBeforeHydration && hydrating ? 'hidden' : visibility,
|
|
888
|
-
position: vertical ? 'absolute' : 'relative',
|
|
889
|
-
[crossSide]: 'inherit'
|
|
890
|
-
};
|
|
891
|
-
styles['--start-position'] = `${start ?? 0}%`;
|
|
892
|
-
if (!range) {
|
|
893
|
-
styles[startEdge] = 0;
|
|
894
|
-
styles[mainSide] = 'var(--start-position)';
|
|
895
|
-
return styles;
|
|
896
|
-
}
|
|
897
|
-
styles['--relative-size'] = `${(end ?? 0) - (start ?? 0)}%`;
|
|
898
|
-
styles[startEdge] = 'var(--start-position)';
|
|
899
|
-
styles[mainSide] = 'var(--relative-size)';
|
|
900
|
-
return styles;
|
|
901
|
-
}
|
|
902
|
-
function getCenteredStyles(vertical, range, start, end) {
|
|
903
|
-
const startEdge = vertical ? 'bottom' : 'insetInlineStart';
|
|
904
|
-
const mainSide = vertical ? 'height' : 'width';
|
|
905
|
-
const crossSide = vertical ? 'width' : 'height';
|
|
844
|
+
function getIndicatorStyles(vertical, range, inset, start, end, forceHidden) {
|
|
906
845
|
const styles = {
|
|
846
|
+
visibility: forceHidden || inset && (void 0 === start || range && void 0 === end) ? 'hidden' : void 0,
|
|
907
847
|
position: vertical ? 'absolute' : 'relative',
|
|
908
|
-
[
|
|
848
|
+
[vertical ? 'width' : 'height']: 'inherit'
|
|
909
849
|
};
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
850
|
+
let startValue = `${start ?? 0}%`;
|
|
851
|
+
let sizeValue = `${(end ?? 0) - (start ?? 0)}%`;
|
|
852
|
+
if (inset) {
|
|
853
|
+
styles['--start-position'] = startValue;
|
|
854
|
+
startValue = 'var(--start-position)';
|
|
855
|
+
if (range) {
|
|
856
|
+
styles['--relative-size'] = sizeValue;
|
|
857
|
+
sizeValue = 'var(--relative-size)';
|
|
858
|
+
}
|
|
914
859
|
}
|
|
915
|
-
|
|
916
|
-
styles[
|
|
917
|
-
styles[mainSide] = `${size}%`;
|
|
860
|
+
styles[vertical ? 'bottom' : 'insetInlineStart'] = range ? startValue : 0;
|
|
861
|
+
styles[vertical ? 'height' : 'width'] = range ? sizeValue : startValue;
|
|
918
862
|
return styles;
|
|
919
863
|
}
|
|
920
864
|
const SliderIndicator_SliderIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
@@ -923,7 +867,7 @@ const SliderIndicator_SliderIndicator = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
923
867
|
const isHydrating = useIsHydrating();
|
|
924
868
|
const vertical = 'vertical' === orientation;
|
|
925
869
|
const range = values.length > 1;
|
|
926
|
-
const style =
|
|
870
|
+
const style = getIndicatorStyles(vertical, range, inset, inset ? indicatorPosition[0] : valueToPercent(values[0], min, max), inset ? indicatorPosition[1] : valueToPercent(values[values.length - 1], min, max), inset && renderBeforeHydration && isHydrating);
|
|
927
871
|
const element = useRenderElement('div', componentProps, {
|
|
928
872
|
state,
|
|
929
873
|
ref: forwardedRef,
|
|
@@ -940,13 +884,8 @@ const SliderIndicator_SliderIndicator = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
940
884
|
return element;
|
|
941
885
|
});
|
|
942
886
|
if ("production" !== process.env.NODE_ENV) SliderIndicator_SliderIndicator.displayName = "SliderIndicator";
|
|
943
|
-
function getSliderChangeEventReason(event) {
|
|
944
|
-
return 'key' in event ? keyboard : inputChange;
|
|
945
|
-
}
|
|
946
887
|
function areValuesEqual(newValue, oldValue) {
|
|
947
|
-
|
|
948
|
-
if (Array.isArray(newValue) && Array.isArray(oldValue)) return areArraysEqual(newValue, oldValue);
|
|
949
|
-
return false;
|
|
888
|
+
return newValue === oldValue || Array.isArray(newValue) && Array.isArray(oldValue) && areArraysEqual(newValue, oldValue);
|
|
950
889
|
}
|
|
951
890
|
const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
952
891
|
const { 'aria-labelledby': ariaLabelledByProp, className, defaultValue, disabled: disabledProp = false, id: idProp, format, largeStep = 10, locale, render, max = 100, min = 0, minStepsBetweenValues = 0, form, name: nameProp, onValueChange: onValueChangeProp, onValueCommitted: onValueCommittedProp, orientation = 'horizontal', step = 1, thumbCollisionBehavior = 'push', thumbAlignment = 'center', value: valueProp, style, ...elementProps } = componentProps;
|
|
@@ -955,7 +894,7 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
955
894
|
const onValueChange = useStableCallback(onValueChangeProp);
|
|
956
895
|
const onValueCommitted = useStableCallback(onValueCommittedProp);
|
|
957
896
|
const { clearErrors } = useFormContext();
|
|
958
|
-
const { state: fieldState, disabled: fieldDisabled, name: fieldName, setTouched, setDirty, validityData,
|
|
897
|
+
const { state: fieldState, disabled: fieldDisabled, name: fieldName, setTouched, setDirty, validityData, validation } = useFieldRootContext();
|
|
959
898
|
const { labelId: fieldLabelId } = useLabelableContext();
|
|
960
899
|
const [labelId, setLabelId] = __rspack_external_react.useState();
|
|
961
900
|
const ariaLabelledby = ariaLabelledByProp ?? resolveAriaLabelledBy(fieldLabelId, labelId);
|
|
@@ -969,13 +908,10 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
969
908
|
const sliderRef = __rspack_external_react.useRef(null);
|
|
970
909
|
const controlRef = __rspack_external_react.useRef(null);
|
|
971
910
|
const thumbRefs = __rspack_external_react.useRef([]);
|
|
972
|
-
const pressedInputRef = __rspack_external_react.useRef(null);
|
|
973
911
|
const pressedThumbCenterOffsetRef = __rspack_external_react.useRef(null);
|
|
974
912
|
const pressedThumbIndexRef = __rspack_external_react.useRef(-1);
|
|
975
913
|
const pressedValuesRef = __rspack_external_react.useRef(null);
|
|
976
|
-
const
|
|
977
|
-
const lastChangeReasonRef = __rspack_external_react.useRef('none');
|
|
978
|
-
const formatOptionsRef = useValueAsRef(format);
|
|
914
|
+
const lastChangeReasonRef = __rspack_external_react.useRef("none");
|
|
979
915
|
const [active, setActiveState] = __rspack_external_react.useState(-1);
|
|
980
916
|
const [lastUsedThumbIndex, setLastUsedThumbIndex] = __rspack_external_react.useState(-1);
|
|
981
917
|
const [dragging, setDragging] = __rspack_external_react.useState(false);
|
|
@@ -988,16 +924,6 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
988
924
|
setActiveState(value);
|
|
989
925
|
if (-1 !== value) setLastUsedThumbIndex(value);
|
|
990
926
|
});
|
|
991
|
-
useRegisterFieldControl(controlRef, id, valueUnwrapped);
|
|
992
|
-
useValueChanged(valueUnwrapped, ()=>{
|
|
993
|
-
clearErrors(name);
|
|
994
|
-
if (shouldValidateOnChange()) validation.commit(valueUnwrapped);
|
|
995
|
-
else validation.commit(valueUnwrapped, true);
|
|
996
|
-
const initialValue = validityData.initialValue;
|
|
997
|
-
let isDirty;
|
|
998
|
-
isDirty = Array.isArray(valueUnwrapped) && Array.isArray(initialValue) ? !areArraysEqual(valueUnwrapped, initialValue) : valueUnwrapped !== initialValue;
|
|
999
|
-
setDirty(isDirty);
|
|
1000
|
-
});
|
|
1001
927
|
const registerFieldControlRef = useStableCallback((element)=>{
|
|
1002
928
|
if (element) controlRef.current = element;
|
|
1003
929
|
});
|
|
@@ -1006,21 +932,27 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1006
932
|
if (!range) return [
|
|
1007
933
|
clamp(valueUnwrapped, min, max)
|
|
1008
934
|
];
|
|
1009
|
-
return valueUnwrapped.
|
|
935
|
+
return valueUnwrapped.map((value)=>clamp(value, min, max)).sort(asc);
|
|
1010
936
|
}, [
|
|
1011
937
|
max,
|
|
1012
938
|
min,
|
|
1013
939
|
range,
|
|
1014
940
|
valueUnwrapped
|
|
1015
941
|
]);
|
|
942
|
+
const fieldValue = range ? values : values[0];
|
|
943
|
+
useRegisterFieldControl(validation.inputRef, id, fieldValue, void 0, !disabled, nameProp);
|
|
944
|
+
useValueChanged(fieldValue, ()=>{
|
|
945
|
+
clearErrors(name);
|
|
946
|
+
validation.change(fieldValue);
|
|
947
|
+
const initialValue = validityData.initialValue;
|
|
948
|
+
let isDirty;
|
|
949
|
+
isDirty = Array.isArray(fieldValue) && Array.isArray(initialValue) ? !areArraysEqual(fieldValue, initialValue) : fieldValue !== initialValue;
|
|
950
|
+
setDirty(isDirty);
|
|
951
|
+
});
|
|
1016
952
|
const setValue = useStableCallback((newValue, details)=>{
|
|
1017
|
-
if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped)) return;
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
});
|
|
1021
|
-
lastChangeReasonRef.current = changeDetails.reason;
|
|
1022
|
-
const nativeEvent = changeDetails.event;
|
|
1023
|
-
const EventConstructor = nativeEvent.constructor ?? Event;
|
|
953
|
+
if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped)) return false;
|
|
954
|
+
const nativeEvent = details.event;
|
|
955
|
+
const EventConstructor = nativeEvent.constructor;
|
|
1024
956
|
const clonedEvent = new EventConstructor(nativeEvent.type, nativeEvent);
|
|
1025
957
|
Object.defineProperty(clonedEvent, 'target', {
|
|
1026
958
|
writable: true,
|
|
@@ -1029,34 +961,37 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1029
961
|
name
|
|
1030
962
|
}
|
|
1031
963
|
});
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
964
|
+
details.event = clonedEvent;
|
|
965
|
+
onValueChange(newValue, details);
|
|
966
|
+
if (details.isCanceled) return false;
|
|
967
|
+
lastChangeReasonRef.current = details.reason;
|
|
1036
968
|
setValueUnwrapped(newValue);
|
|
969
|
+
return true;
|
|
1037
970
|
});
|
|
1038
971
|
const handleInputChange = useStableCallback((valueInput, index, event)=>{
|
|
1039
972
|
const newValue = getSliderValue(valueInput, index, min, max, range, values);
|
|
1040
973
|
if (validateMinimumDistance(newValue, step, minStepsBetweenValues)) {
|
|
1041
|
-
const reason =
|
|
1042
|
-
setValue(newValue, createChangeEventDetails(reason, event.nativeEvent, void 0, {
|
|
974
|
+
const reason = 'key' in event ? keyboard : inputChange;
|
|
975
|
+
const applied = setValue(newValue, createChangeEventDetails(reason, event.nativeEvent, void 0, {
|
|
1043
976
|
activeThumbIndex: index
|
|
1044
977
|
}));
|
|
1045
978
|
setTouched(true);
|
|
1046
|
-
|
|
1047
|
-
onValueCommitted(nextValue, createGenericEventDetails(reason, event.nativeEvent));
|
|
979
|
+
if (applied) onValueCommitted(newValue, createGenericEventDetails(reason, event.nativeEvent));
|
|
1048
980
|
}
|
|
1049
981
|
});
|
|
1050
982
|
if ('production' !== process.env.NODE_ENV) {
|
|
1051
983
|
if (min >= max) warn('Slider `max` must be greater than `min`.');
|
|
1052
984
|
}
|
|
1053
985
|
useIsoLayoutEffect(()=>{
|
|
986
|
+
if (!disabled) return;
|
|
1054
987
|
const activeEl = activeElement(ownerDocument(sliderRef.current));
|
|
1055
|
-
if (
|
|
988
|
+
if (contains(sliderRef.current, activeEl)) activeEl.blur();
|
|
989
|
+
if (-1 !== active) setActive(-1);
|
|
1056
990
|
}, [
|
|
1057
|
-
|
|
991
|
+
active,
|
|
992
|
+
disabled,
|
|
993
|
+
setActive
|
|
1058
994
|
]);
|
|
1059
|
-
if (disabled && -1 !== active) setActive(-1);
|
|
1060
995
|
const state = __rspack_external_react.useMemo(()=>({
|
|
1061
996
|
...fieldState,
|
|
1062
997
|
activeThumbIndex: active,
|
|
@@ -1086,15 +1021,15 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1086
1021
|
disabled,
|
|
1087
1022
|
dragging,
|
|
1088
1023
|
validation,
|
|
1089
|
-
|
|
1024
|
+
format,
|
|
1090
1025
|
handleInputChange,
|
|
1091
1026
|
indicatorPosition,
|
|
1092
1027
|
inset: 'center' !== thumbAlignment,
|
|
1028
|
+
isArrayValue: range,
|
|
1093
1029
|
labelId: ariaLabelledby,
|
|
1094
1030
|
rootLabelId: defaultLabelId,
|
|
1095
1031
|
largeStep,
|
|
1096
1032
|
lastUsedThumbIndex,
|
|
1097
|
-
lastChangedValueRef,
|
|
1098
1033
|
lastChangeReasonRef,
|
|
1099
1034
|
form,
|
|
1100
1035
|
locale,
|
|
@@ -1104,7 +1039,6 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1104
1039
|
name,
|
|
1105
1040
|
onValueCommitted,
|
|
1106
1041
|
orientation,
|
|
1107
|
-
pressedInputRef,
|
|
1108
1042
|
pressedThumbCenterOffsetRef,
|
|
1109
1043
|
pressedThumbIndexRef,
|
|
1110
1044
|
pressedValuesRef,
|
|
@@ -1123,19 +1057,16 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1123
1057
|
values
|
|
1124
1058
|
}), [
|
|
1125
1059
|
active,
|
|
1126
|
-
controlRef,
|
|
1127
1060
|
ariaLabelledby,
|
|
1128
1061
|
defaultLabelId,
|
|
1129
1062
|
disabled,
|
|
1130
1063
|
dragging,
|
|
1131
1064
|
validation,
|
|
1132
|
-
|
|
1065
|
+
format,
|
|
1133
1066
|
handleInputChange,
|
|
1134
1067
|
indicatorPosition,
|
|
1135
1068
|
largeStep,
|
|
1136
1069
|
lastUsedThumbIndex,
|
|
1137
|
-
lastChangedValueRef,
|
|
1138
|
-
lastChangeReasonRef,
|
|
1139
1070
|
form,
|
|
1140
1071
|
locale,
|
|
1141
1072
|
max,
|
|
@@ -1144,22 +1075,15 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1144
1075
|
name,
|
|
1145
1076
|
onValueCommitted,
|
|
1146
1077
|
orientation,
|
|
1147
|
-
|
|
1148
|
-
pressedThumbCenterOffsetRef,
|
|
1149
|
-
pressedThumbIndexRef,
|
|
1150
|
-
pressedValuesRef,
|
|
1078
|
+
range,
|
|
1151
1079
|
registerFieldControlRef,
|
|
1152
1080
|
setActive,
|
|
1153
|
-
setDragging,
|
|
1154
|
-
setIndicatorPosition,
|
|
1155
|
-
setLabelId,
|
|
1156
1081
|
setValue,
|
|
1157
1082
|
state,
|
|
1158
1083
|
step,
|
|
1159
1084
|
thumbCollisionBehavior,
|
|
1160
1085
|
thumbAlignment,
|
|
1161
1086
|
thumbMap,
|
|
1162
|
-
thumbRefs,
|
|
1163
1087
|
values
|
|
1164
1088
|
]);
|
|
1165
1089
|
const element = useRenderElement('div', componentProps, {
|
|
@@ -1174,8 +1098,8 @@ const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(f
|
|
|
1174
1098
|
id,
|
|
1175
1099
|
role: 'group'
|
|
1176
1100
|
},
|
|
1177
|
-
|
|
1178
|
-
|
|
1101
|
+
elementProps,
|
|
1102
|
+
(props)=>validation.getValidationProps(disabled, props)
|
|
1179
1103
|
],
|
|
1180
1104
|
stateAttributesMapping: sliderStateAttributesMapping
|
|
1181
1105
|
});
|