@wix/site-ui 1.30.0 → 1.31.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/1268.js +99 -0
- package/dist/1279.js +7 -0
- package/dist/1457.js +10 -0
- package/dist/1477.js +106 -0
- package/dist/1500.js +111 -0
- package/dist/167.js +6 -0
- package/dist/2274.js +34 -0
- package/dist/2287.js +17 -0
- package/dist/2418.js +31 -0
- package/dist/2801.js +20 -0
- package/dist/285.js +86 -0
- package/dist/2861.js +6 -0
- package/dist/3020.js +7 -0
- package/dist/3021.js +72 -0
- package/dist/3056.js +229 -0
- package/dist/3140.js +4 -0
- package/dist/3248.js +307 -0
- package/dist/3296.js +4 -0
- package/dist/3319.js +400 -0
- package/dist/3395.js +4 -0
- package/dist/3485.js +854 -0
- package/dist/353.js +14 -0
- package/dist/3670.js +418 -0
- package/dist/3829.js +113 -0
- package/dist/4026.js +12 -0
- package/dist/4143.js +46 -0
- package/dist/42.js +32 -0
- package/dist/4281.js +30 -0
- package/dist/4346.js +2 -0
- package/dist/4388.js +418 -0
- package/dist/4490.js +32 -0
- package/dist/4495.js +9 -0
- package/dist/4549.js +24 -0
- package/dist/4586.js +41 -0
- package/dist/4586.js.LICENSE.txt +19 -0
- package/dist/4707.js +19 -0
- package/dist/4723.js +7 -0
- package/dist/4745.js +7 -0
- package/dist/4768.js +35 -0
- package/dist/4922.js +15 -0
- package/dist/5036.js +17 -0
- package/dist/5085.js +20 -0
- package/dist/5299.js +597 -0
- package/dist/5659.js +4 -0
- package/dist/5778.js +10 -0
- package/dist/5864.js +86 -0
- package/dist/5992.js +913 -0
- package/dist/5992.js.LICENSE.txt +19 -0
- package/dist/6003.js +10 -0
- package/dist/6046.js +29 -0
- package/dist/6089.js +2355 -0
- package/dist/6107.js +10 -0
- package/dist/6247.js +20 -0
- package/dist/6270.js +487 -0
- package/dist/6329.js +32 -0
- package/dist/6330.js +30 -0
- package/dist/6499.js +7 -0
- package/dist/6535.js +71 -0
- package/dist/6588.js +382 -0
- package/dist/6706.js +16 -0
- package/dist/6825.js +7 -0
- package/dist/6882.js +1562 -0
- package/dist/6914.js +30 -0
- package/dist/7021.js +13 -0
- package/dist/7366.js +83 -0
- package/dist/7373.js +25 -0
- package/dist/7541.js +25 -0
- package/dist/7564.js +10 -0
- package/dist/7642.js +20 -0
- package/dist/7725.js +10 -0
- package/dist/7871.js +38 -0
- package/dist/8052.js +352 -0
- package/dist/8106.js +238 -0
- package/dist/8171.js +346 -0
- package/dist/8225.js +21 -0
- package/dist/8272.js +333 -0
- package/dist/8527.js +58 -0
- package/dist/8724.js +10 -0
- package/dist/8750.js +1920 -0
- package/dist/8758.js +43 -0
- package/dist/880.js +149 -0
- package/dist/8935.js +8 -0
- package/dist/8960.js +22 -0
- package/dist/8971.js +40 -0
- package/dist/8979.js +10 -0
- package/dist/8996.js +71 -0
- package/dist/904.js +121 -0
- package/dist/9048.js +52 -0
- package/dist/9087.js +256 -0
- package/dist/9189.js +158 -0
- package/dist/9255.js +136 -0
- package/dist/9352.js +148 -0
- package/dist/951.js +22 -0
- package/dist/9635.js +22 -0
- package/dist/9829.js +4 -0
- package/dist/9863.js +8 -0
- package/dist/Accordion/index.d.ts +569 -12
- package/dist/Accordion/index.js +423 -8
- package/dist/AlertDialog/index.d.ts +1417 -18
- package/dist/AlertDialog/index.js +34 -14
- package/dist/Autocomplete/index.d.ts +1861 -38
- package/dist/Autocomplete/index.js +98 -24
- package/dist/Avatar/index.d.ts +129 -7
- package/dist/Avatar/index.js +149 -6
- package/dist/Breadcrumbs/index.d.ts +960 -7
- package/dist/Breadcrumbs/index.js +5 -5
- package/dist/Button/index.d.ts +88 -6
- package/dist/Button/index.js +27 -3
- package/dist/Checkbox/index.d.ts +425 -5
- package/dist/Checkbox/index.js +45 -5
- package/dist/CheckboxGroup/index.d.ts +318 -3
- package/dist/CheckboxGroup/index.js +166 -3
- package/dist/Collapsible/index.d.ts +377 -7
- package/dist/Collapsible/index.js +160 -6
- package/dist/Combobox/index.d.ts +1984 -48
- package/dist/Combobox/index.js +352 -29
- package/dist/ContextMenu/index.d.ts +2340 -36
- package/dist/ContextMenu/index.js +197 -22
- package/dist/Dialog/index.d.ts +1355 -18
- package/dist/Dialog/index.js +16 -14
- package/dist/Drawer/index.d.ts +1653 -18
- package/dist/Drawer/index.js +2797 -20
- package/dist/Field/index.d.ts +655 -15
- package/dist/Field/index.js +677 -10
- package/dist/Fieldset/index.d.ts +94 -5
- package/dist/Fieldset/index.js +68 -5
- package/dist/Form/index.d.ts +331 -2
- package/dist/Form/index.js +106 -3
- package/dist/Input/index.d.ts +692 -3
- package/dist/Input/index.js +10 -3
- package/dist/Menu/index.d.ts +2301 -36
- package/dist/Menu/index.js +365 -26
- package/dist/Menubar/index.d.ts +2301 -3
- package/dist/Menubar/index.js +105 -3
- package/dist/Meter/index.d.ts +175 -11
- package/dist/Meter/index.js +129 -9
- package/dist/NavigationMenu/index.d.ts +978 -28
- package/dist/NavigationMenu/index.js +1034 -17
- package/dist/NumberField/index.d.ts +612 -15
- package/dist/NumberField/index.js +1409 -11
- package/dist/Popover/index.d.ts +1655 -20
- package/dist/Popover/index.js +792 -17
- package/dist/PreviewCard/index.d.ts +1523 -14
- package/dist/PreviewCard/index.js +679 -14
- package/dist/Progress/index.d.ts +183 -11
- package/dist/Progress/index.js +181 -9
- package/dist/Radio/index.d.ts +185 -6
- package/dist/Radio/index.js +253 -6
- package/dist/RadioGroup/index.d.ts +341 -2
- package/dist/RadioGroup/index.js +154 -3
- package/dist/ScrollArea/index.d.ts +265 -13
- package/dist/ScrollArea/index.js +892 -10
- package/dist/Select/index.d.ts +1493 -38
- package/dist/Select/index.js +1824 -23
- package/dist/Separator/index.d.ts +80 -6
- package/dist/Separator/index.js +3 -3
- package/dist/Slider/index.d.ts +678 -16
- package/dist/Slider/index.js +1199 -11
- package/dist/Switch/index.d.ts +393 -5
- package/dist/Switch/index.js +208 -6
- package/dist/Tabs/index.d.ts +523 -12
- package/dist/Tabs/index.js +685 -9
- package/dist/Toggle/index.d.ts +305 -2
- package/dist/Toggle/index.js +76 -3
- package/dist/ToggleGroup/index.d.ts +316 -2
- package/dist/ToggleGroup/index.js +102 -3
- package/dist/Toolbar/index.d.ts +282 -13
- package/dist/Toolbar/index.js +230 -9
- package/dist/Tooltip/index.d.ts +1572 -14
- package/dist/Tooltip/index.js +965 -14
- package/dist/index.d.ts +12749 -652
- package/dist/rslib-runtime.js +18 -0
- package/package.json +3 -3
package/dist/Slider/index.js
CHANGED
|
@@ -1,7 +1,1195 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Slider } from "@base-ui/react/slider";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
2
|
import clsx from "clsx";
|
|
3
|
+
import { warn, mergeProps, useMergedRefs, useRenderElement, esm_formatErrorMessage } from "../8272.js";
|
|
4
|
+
import { useLabelableContext, fieldValidityMapping, useFieldRootContext } from "../1477.js";
|
|
5
|
+
import { ownerDocument } from "../9829.js";
|
|
6
|
+
import { getWindow, isHTMLElement, isElement } from "../3829.js";
|
|
7
|
+
import { focusElementWithVisible, useLabel } from "../4143.js";
|
|
8
|
+
import { formatNumber } from "../6914.js";
|
|
9
|
+
import { clamp } from "../3296.js";
|
|
10
|
+
import { useDirection } from "../9863.js";
|
|
11
|
+
import { useStableCallback } from "../7541.js";
|
|
12
|
+
import { useValueAsRef } from "../4707.js";
|
|
13
|
+
import { createGenericEventDetails, createChangeEventDetails } from "../4768.js";
|
|
14
|
+
import { trackPress, keyboard, inputChange } from "../2418.js";
|
|
15
|
+
import { useAnimationFrame } from "../8996.js";
|
|
16
|
+
import { addEventListener } from "../4723.js";
|
|
17
|
+
import { getTarget, contains, activeElement } from "../4549.js";
|
|
18
|
+
import { ARROW_LEFT, ARROW_UP, COMPOSITE_KEYS, PAGE_DOWN, ARROW_RIGHT, ARROW_DOWN } from "../1500.js";
|
|
19
|
+
import { useCSPContext } from "../6003.js";
|
|
20
|
+
import { useBaseUiId } from "../6046.js";
|
|
21
|
+
import { useLabelableId } from "../9048.js";
|
|
22
|
+
import { useCompositeListItem } from "../3021.js";
|
|
23
|
+
import { valueToPercent } from "../3395.js";
|
|
24
|
+
import { useIsHydrating } from "../2287.js";
|
|
25
|
+
import { useIsoLayoutEffect } from "../6499.js";
|
|
26
|
+
import { visuallyHidden } from "../8225.js";
|
|
27
|
+
import { matchesFocusVisible } from "../8758.js";
|
|
28
|
+
import { areArraysEqual } from "../5659.js";
|
|
29
|
+
import { getDefaultLabelId, resolveAriaLabelledBy } from "../6825.js";
|
|
30
|
+
import { useFormContext } from "../5085.js";
|
|
31
|
+
import { useControlled } from "../8527.js";
|
|
32
|
+
import { useRegisterFieldControl } from "../4281.js";
|
|
33
|
+
import { useValueChanged } from "../2801.js";
|
|
34
|
+
import { CompositeList } from "../9255.js";
|
|
4
35
|
import * as __rspack_external_react from "react";
|
|
36
|
+
const SliderRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
37
|
+
if ("production" !== process.env.NODE_ENV) SliderRootContext.displayName = "SliderRootContext";
|
|
38
|
+
function useSliderRootContext() {
|
|
39
|
+
const context = __rspack_external_react.useContext(SliderRootContext);
|
|
40
|
+
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>.' : esm_formatErrorMessage(62));
|
|
41
|
+
return context;
|
|
42
|
+
}
|
|
43
|
+
const sliderStateAttributesMapping = {
|
|
44
|
+
activeThumbIndex: ()=>null,
|
|
45
|
+
max: ()=>null,
|
|
46
|
+
min: ()=>null,
|
|
47
|
+
minStepsBetweenValues: ()=>null,
|
|
48
|
+
step: ()=>null,
|
|
49
|
+
values: ()=>null,
|
|
50
|
+
...fieldValidityMapping
|
|
51
|
+
};
|
|
52
|
+
const SliderLabel_SliderLabel = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
53
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
54
|
+
const elementPropsWithoutId = elementProps;
|
|
55
|
+
delete elementPropsWithoutId.id;
|
|
56
|
+
const { state, setLabelId, controlRef, rootLabelId } = useSliderRootContext();
|
|
57
|
+
function focusControl(event, controlId) {
|
|
58
|
+
if (controlId) {
|
|
59
|
+
const controlElement = ownerDocument(event.currentTarget).getElementById(controlId);
|
|
60
|
+
if (isHTMLElement(controlElement)) return void focusElementWithVisible(controlElement);
|
|
61
|
+
}
|
|
62
|
+
const fallbackInputs = controlRef.current?.querySelectorAll('input[type="range"]');
|
|
63
|
+
const fallbackInput = fallbackInputs?.length === 1 ? fallbackInputs[0] : null;
|
|
64
|
+
if (isHTMLElement(fallbackInput)) focusElementWithVisible(fallbackInput);
|
|
65
|
+
}
|
|
66
|
+
const labelProps = useLabel({
|
|
67
|
+
id: rootLabelId,
|
|
68
|
+
setLabelId,
|
|
69
|
+
focusControl
|
|
70
|
+
});
|
|
71
|
+
return useRenderElement('div', componentProps, {
|
|
72
|
+
ref: forwardedRef,
|
|
73
|
+
state,
|
|
74
|
+
props: [
|
|
75
|
+
labelProps,
|
|
76
|
+
elementProps
|
|
77
|
+
],
|
|
78
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
if ("production" !== process.env.NODE_ENV) SliderLabel_SliderLabel.displayName = "SliderLabel";
|
|
82
|
+
const SliderValue_SliderValue = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
83
|
+
const { 'aria-live': ariaLive = 'off', render, className, children, style, ...elementProps } = componentProps;
|
|
84
|
+
const { thumbMap, state, values, formatOptionsRef, locale } = useSliderRootContext();
|
|
85
|
+
let htmlFor = '';
|
|
86
|
+
for (const thumbMetadata of thumbMap.values())if (thumbMetadata?.inputId) htmlFor += `${thumbMetadata.inputId} `;
|
|
87
|
+
const outputFor = '' === htmlFor.trim() ? void 0 : htmlFor.trim();
|
|
88
|
+
const formattedValues = __rspack_external_react.useMemo(()=>{
|
|
89
|
+
const arr = [];
|
|
90
|
+
for(let i = 0; i < values.length; i += 1)arr.push(formatNumber(values[i], locale, formatOptionsRef.current ?? void 0));
|
|
91
|
+
return arr;
|
|
92
|
+
}, [
|
|
93
|
+
formatOptionsRef,
|
|
94
|
+
locale,
|
|
95
|
+
values
|
|
96
|
+
]);
|
|
97
|
+
const defaultDisplayValue = values.map((v, i)=>formattedValues[i] || v).join(' – ');
|
|
98
|
+
const element = useRenderElement('output', componentProps, {
|
|
99
|
+
state,
|
|
100
|
+
ref: forwardedRef,
|
|
101
|
+
props: [
|
|
102
|
+
{
|
|
103
|
+
'aria-live': ariaLive,
|
|
104
|
+
children: 'function' == typeof children ? children(formattedValues, values) : defaultDisplayValue,
|
|
105
|
+
htmlFor: outputFor
|
|
106
|
+
},
|
|
107
|
+
elementProps
|
|
108
|
+
],
|
|
109
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
110
|
+
});
|
|
111
|
+
return element;
|
|
112
|
+
});
|
|
113
|
+
if ("production" !== process.env.NODE_ENV) SliderValue_SliderValue.displayName = "SliderValue";
|
|
114
|
+
function getMidpoint(element) {
|
|
115
|
+
const rect = element.getBoundingClientRect();
|
|
116
|
+
return {
|
|
117
|
+
x: (rect.left + rect.right) / 2,
|
|
118
|
+
y: (rect.top + rect.bottom) / 2
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function getDecimalPrecision(num) {
|
|
122
|
+
if (0 === num) return 0;
|
|
123
|
+
if (Math.abs(num) < 1) {
|
|
124
|
+
const parts = num.toExponential().split('e-');
|
|
125
|
+
const matissaDecimalPart = parts[0].split('.')[1];
|
|
126
|
+
return (matissaDecimalPart ? matissaDecimalPart.length : 0) + parseInt(parts[1], 10);
|
|
127
|
+
}
|
|
128
|
+
const decimalPart = num.toString().split('.')[1];
|
|
129
|
+
return decimalPart ? decimalPart.length : 0;
|
|
130
|
+
}
|
|
131
|
+
function roundValueToStep(value, step, min) {
|
|
132
|
+
const nearest = Math.round((value - min) / step) * step + min;
|
|
133
|
+
return Number(nearest.toFixed(Math.max(getDecimalPrecision(step), getDecimalPrecision(min))));
|
|
134
|
+
}
|
|
135
|
+
function validateMinimumDistance(values, step, minStepsBetweenValues) {
|
|
136
|
+
if (!Array.isArray(values)) return true;
|
|
137
|
+
const distances = values.reduce((acc, val, index, vals)=>{
|
|
138
|
+
if (index === vals.length - 1) return acc;
|
|
139
|
+
acc.push(Math.abs(val - vals[index + 1]));
|
|
140
|
+
return acc;
|
|
141
|
+
}, []);
|
|
142
|
+
return Math.min(...distances) >= step * minStepsBetweenValues;
|
|
143
|
+
}
|
|
144
|
+
function getPushedThumbValues({ values, index, nextValue, min, max, step, minStepsBetweenValues, initialValues }) {
|
|
145
|
+
if (0 === values.length) return [];
|
|
146
|
+
const nextValues = values.slice();
|
|
147
|
+
const minValueDifference = step * minStepsBetweenValues;
|
|
148
|
+
const lastIndex = nextValues.length - 1;
|
|
149
|
+
const baseInitialValues = initialValues ?? values;
|
|
150
|
+
const indexMin = min + index * minValueDifference;
|
|
151
|
+
const indexMax = max - (lastIndex - index) * minValueDifference;
|
|
152
|
+
nextValues[index] = clamp(nextValue, indexMin, indexMax);
|
|
153
|
+
for(let i = index + 1; i <= lastIndex; i += 1){
|
|
154
|
+
const minAllowed = nextValues[i - 1] + minValueDifference;
|
|
155
|
+
const maxAllowed = max - (lastIndex - i) * minValueDifference;
|
|
156
|
+
const initialValue = baseInitialValues[i] ?? nextValues[i];
|
|
157
|
+
let candidate = Math.max(nextValues[i], minAllowed);
|
|
158
|
+
if (initialValue < candidate) candidate = Math.max(initialValue, minAllowed);
|
|
159
|
+
nextValues[i] = clamp(candidate, minAllowed, maxAllowed);
|
|
160
|
+
}
|
|
161
|
+
for(let i = index - 1; i >= 0; i -= 1){
|
|
162
|
+
const maxAllowed = nextValues[i + 1] - minValueDifference;
|
|
163
|
+
const minAllowed = min + i * minValueDifference;
|
|
164
|
+
const initialValue = baseInitialValues[i] ?? nextValues[i];
|
|
165
|
+
let candidate = Math.min(nextValues[i], maxAllowed);
|
|
166
|
+
if (initialValue > candidate) candidate = Math.min(initialValue, maxAllowed);
|
|
167
|
+
nextValues[i] = clamp(candidate, minAllowed, maxAllowed);
|
|
168
|
+
}
|
|
169
|
+
for(let i = 0; i <= lastIndex; i += 1)nextValues[i] = Number(nextValues[i].toFixed(12));
|
|
170
|
+
return nextValues;
|
|
171
|
+
}
|
|
172
|
+
function resolveThumbCollision({ behavior, values, currentValues, initialValues, pressedIndex, nextValue, min, max, step, minStepsBetweenValues }) {
|
|
173
|
+
const activeValues = currentValues ?? values;
|
|
174
|
+
const baselineValues = initialValues ?? values;
|
|
175
|
+
const range = activeValues.length > 1;
|
|
176
|
+
if (!range) return {
|
|
177
|
+
value: nextValue,
|
|
178
|
+
thumbIndex: 0,
|
|
179
|
+
didSwap: false
|
|
180
|
+
};
|
|
181
|
+
const minValueDifference = step * minStepsBetweenValues;
|
|
182
|
+
switch(behavior){
|
|
183
|
+
case 'swap':
|
|
184
|
+
{
|
|
185
|
+
const pressedInitialValue = activeValues[pressedIndex];
|
|
186
|
+
const epsilon = 1e-7;
|
|
187
|
+
const candidateValues = activeValues.slice();
|
|
188
|
+
const previousNeighbor = candidateValues[pressedIndex - 1];
|
|
189
|
+
const nextNeighbor = candidateValues[pressedIndex + 1];
|
|
190
|
+
const lowerBound = null != previousNeighbor ? previousNeighbor + minValueDifference : min;
|
|
191
|
+
const upperBound = null != nextNeighbor ? nextNeighbor - minValueDifference : max;
|
|
192
|
+
const constrainedValue = clamp(nextValue, lowerBound, upperBound);
|
|
193
|
+
const pressedValueAfterClamp = Number(constrainedValue.toFixed(12));
|
|
194
|
+
candidateValues[pressedIndex] = pressedValueAfterClamp;
|
|
195
|
+
const movingForward = nextValue > pressedInitialValue;
|
|
196
|
+
const movingBackward = nextValue < pressedInitialValue;
|
|
197
|
+
const shouldSwapForward = movingForward && null != nextNeighbor && nextValue >= nextNeighbor - epsilon;
|
|
198
|
+
const shouldSwapBackward = movingBackward && null != previousNeighbor && nextValue <= previousNeighbor + epsilon;
|
|
199
|
+
if (!shouldSwapForward && !shouldSwapBackward) return {
|
|
200
|
+
value: candidateValues,
|
|
201
|
+
thumbIndex: pressedIndex,
|
|
202
|
+
didSwap: false
|
|
203
|
+
};
|
|
204
|
+
const targetIndex = shouldSwapForward ? pressedIndex + 1 : pressedIndex - 1;
|
|
205
|
+
const initialValuesForPush = candidateValues.map((_, index)=>{
|
|
206
|
+
if (index === pressedIndex) return pressedValueAfterClamp;
|
|
207
|
+
const baseline = baselineValues[index];
|
|
208
|
+
if (null != baseline) return baseline;
|
|
209
|
+
return activeValues[index];
|
|
210
|
+
});
|
|
211
|
+
let nextValueForTarget = nextValue;
|
|
212
|
+
nextValueForTarget = shouldSwapForward ? Math.max(nextValue, candidateValues[targetIndex]) : Math.min(nextValue, candidateValues[targetIndex]);
|
|
213
|
+
const adjustedValues = getPushedThumbValues({
|
|
214
|
+
values: candidateValues,
|
|
215
|
+
index: targetIndex,
|
|
216
|
+
nextValue: nextValueForTarget,
|
|
217
|
+
min,
|
|
218
|
+
max,
|
|
219
|
+
step,
|
|
220
|
+
minStepsBetweenValues,
|
|
221
|
+
initialValues: initialValuesForPush
|
|
222
|
+
});
|
|
223
|
+
const neighborIndex = shouldSwapForward ? targetIndex - 1 : targetIndex + 1;
|
|
224
|
+
if (neighborIndex >= 0 && neighborIndex < adjustedValues.length) {
|
|
225
|
+
const previousValue = adjustedValues[neighborIndex - 1];
|
|
226
|
+
const nextValueAfter = adjustedValues[neighborIndex + 1];
|
|
227
|
+
let neighborLowerBound = null != previousValue ? previousValue + minValueDifference : min;
|
|
228
|
+
neighborLowerBound = Math.max(neighborLowerBound, min + neighborIndex * minValueDifference);
|
|
229
|
+
let neighborUpperBound = null != nextValueAfter ? nextValueAfter - minValueDifference : max;
|
|
230
|
+
neighborUpperBound = Math.min(neighborUpperBound, max - (adjustedValues.length - 1 - neighborIndex) * minValueDifference);
|
|
231
|
+
const restoredValue = clamp(pressedValueAfterClamp, neighborLowerBound, neighborUpperBound);
|
|
232
|
+
adjustedValues[neighborIndex] = Number(restoredValue.toFixed(12));
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
value: adjustedValues,
|
|
236
|
+
thumbIndex: targetIndex,
|
|
237
|
+
didSwap: true
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
case 'push':
|
|
241
|
+
{
|
|
242
|
+
const nextValues = getPushedThumbValues({
|
|
243
|
+
values: activeValues,
|
|
244
|
+
index: pressedIndex,
|
|
245
|
+
nextValue,
|
|
246
|
+
min,
|
|
247
|
+
max,
|
|
248
|
+
step,
|
|
249
|
+
minStepsBetweenValues
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
value: nextValues,
|
|
253
|
+
thumbIndex: pressedIndex,
|
|
254
|
+
didSwap: false
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
case 'none':
|
|
258
|
+
default:
|
|
259
|
+
{
|
|
260
|
+
const candidateValues = activeValues.slice();
|
|
261
|
+
const previousNeighbor = candidateValues[pressedIndex - 1];
|
|
262
|
+
const nextNeighbor = candidateValues[pressedIndex + 1];
|
|
263
|
+
const lowerBound = null != previousNeighbor ? previousNeighbor + minValueDifference : min;
|
|
264
|
+
const upperBound = null != nextNeighbor ? nextNeighbor - minValueDifference : max;
|
|
265
|
+
const constrainedValue = clamp(nextValue, lowerBound, upperBound);
|
|
266
|
+
candidateValues[pressedIndex] = Number(constrainedValue.toFixed(12));
|
|
267
|
+
return {
|
|
268
|
+
value: candidateValues,
|
|
269
|
+
thumbIndex: pressedIndex,
|
|
270
|
+
didSwap: false
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
|
|
276
|
+
function getControlOffset(styles, vertical) {
|
|
277
|
+
if (!styles) return {
|
|
278
|
+
start: 0,
|
|
279
|
+
end: 0
|
|
280
|
+
};
|
|
281
|
+
function parseSize(value) {
|
|
282
|
+
const parsed = null != value ? parseFloat(value) : 0;
|
|
283
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
284
|
+
}
|
|
285
|
+
const start = vertical ? 'Top' : 'InlineStart';
|
|
286
|
+
const end = vertical ? 'Bottom' : 'InlineEnd';
|
|
287
|
+
return {
|
|
288
|
+
start: parseSize(styles[`border${start}Width`]) + parseSize(styles[`padding${start}`]),
|
|
289
|
+
end: parseSize(styles[`border${end}Width`]) + parseSize(styles[`padding${end}`])
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function getFingerCoords(event, touchIdRef) {
|
|
293
|
+
if (null != touchIdRef.current && event.changedTouches) {
|
|
294
|
+
const touchEvent = event;
|
|
295
|
+
for(let i = 0; i < touchEvent.changedTouches.length; i += 1){
|
|
296
|
+
const touch = touchEvent.changedTouches[i];
|
|
297
|
+
if (touch.identifier === touchIdRef.current) return {
|
|
298
|
+
x: touch.clientX,
|
|
299
|
+
y: touch.clientY
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
x: event.clientX,
|
|
306
|
+
y: event.clientY
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const SliderControl_SliderControl = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
310
|
+
const { render: renderProp, className, style, ...elementProps } = componentProps;
|
|
311
|
+
const { disabled, dragging, inset, lastChangedValueRef, lastChangeReasonRef, max, min, minStepsBetweenValues, onValueCommitted, orientation, pressedInputRef, pressedThumbCenterOffsetRef, pressedThumbIndexRef, pressedValuesRef, registerFieldControlRef, renderBeforeHydration, setActive, setDragging, setValue, state, step, thumbCollisionBehavior, thumbRefs, values } = useSliderRootContext();
|
|
312
|
+
const direction = useDirection();
|
|
313
|
+
const range = values.length > 1;
|
|
314
|
+
const vertical = 'vertical' === orientation;
|
|
315
|
+
const controlRef = __rspack_external_react.useRef(null);
|
|
316
|
+
const stylesRef = __rspack_external_react.useRef(null);
|
|
317
|
+
const setStylesRef = useStableCallback((element)=>{
|
|
318
|
+
if (element && null == stylesRef.current) stylesRef.current = getWindow(element).getComputedStyle(element);
|
|
319
|
+
});
|
|
320
|
+
const touchIdRef = __rspack_external_react.useRef(null);
|
|
321
|
+
const moveCountRef = __rspack_external_react.useRef(0);
|
|
322
|
+
const insetThumbOffsetRef = __rspack_external_react.useRef(0);
|
|
323
|
+
const latestValuesRef = useValueAsRef(values);
|
|
324
|
+
function updatePressedThumb(nextIndex) {
|
|
325
|
+
if (pressedThumbIndexRef.current !== nextIndex) pressedThumbIndexRef.current = nextIndex;
|
|
326
|
+
const thumbElement = thumbRefs.current[nextIndex];
|
|
327
|
+
if (!thumbElement) {
|
|
328
|
+
pressedThumbCenterOffsetRef.current = null;
|
|
329
|
+
pressedInputRef.current = null;
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
pressedInputRef.current = thumbElement.querySelector('input[type="range"]');
|
|
333
|
+
}
|
|
334
|
+
function getFingerState(fingerCoords) {
|
|
335
|
+
const control = controlRef.current;
|
|
336
|
+
if (!control) return null;
|
|
337
|
+
const { width, height, bottom, left, right } = control.getBoundingClientRect();
|
|
338
|
+
const controlOffset = getControlOffset(stylesRef.current, vertical);
|
|
339
|
+
const insetThumbOffset = insetThumbOffsetRef.current;
|
|
340
|
+
const controlSize = (vertical ? height : width) - controlOffset.start - controlOffset.end - 2 * insetThumbOffset;
|
|
341
|
+
const thumbCenterOffset = pressedThumbCenterOffsetRef.current ?? 0;
|
|
342
|
+
const fingerX = fingerCoords.x - thumbCenterOffset;
|
|
343
|
+
const fingerY = fingerCoords.y - thumbCenterOffset;
|
|
344
|
+
const valueSize = vertical ? bottom - fingerY - controlOffset.end : ('rtl' === direction ? right - fingerX : fingerX - left) - controlOffset.start;
|
|
345
|
+
const valueRescaled = clamp((valueSize - insetThumbOffset) / controlSize, 0, 1);
|
|
346
|
+
let newValue = (max - min) * valueRescaled + min;
|
|
347
|
+
newValue = roundValueToStep(newValue, step, min);
|
|
348
|
+
newValue = clamp(newValue, min, max);
|
|
349
|
+
if (!range) return {
|
|
350
|
+
value: newValue,
|
|
351
|
+
thumbIndex: 0,
|
|
352
|
+
didSwap: false
|
|
353
|
+
};
|
|
354
|
+
const thumbIndex = pressedThumbIndexRef.current;
|
|
355
|
+
if (thumbIndex < 0) return null;
|
|
356
|
+
const collisionResult = resolveThumbCollision({
|
|
357
|
+
behavior: thumbCollisionBehavior,
|
|
358
|
+
values,
|
|
359
|
+
currentValues: latestValuesRef.current ?? values,
|
|
360
|
+
initialValues: pressedValuesRef.current,
|
|
361
|
+
pressedIndex: thumbIndex,
|
|
362
|
+
nextValue: newValue,
|
|
363
|
+
min,
|
|
364
|
+
max,
|
|
365
|
+
step,
|
|
366
|
+
minStepsBetweenValues
|
|
367
|
+
});
|
|
368
|
+
if ('swap' === thumbCollisionBehavior && collisionResult.didSwap) updatePressedThumb(collisionResult.thumbIndex);
|
|
369
|
+
else pressedThumbIndexRef.current = collisionResult.thumbIndex;
|
|
370
|
+
return collisionResult;
|
|
371
|
+
}
|
|
372
|
+
function startPressing(fingerCoords) {
|
|
373
|
+
pressedValuesRef.current = range ? values.slice() : null;
|
|
374
|
+
latestValuesRef.current = values;
|
|
375
|
+
const pressedThumbIndex = pressedThumbIndexRef.current;
|
|
376
|
+
let closestThumbIndex = pressedThumbIndex;
|
|
377
|
+
if (pressedThumbIndex > -1 && pressedThumbIndex < values.length) {
|
|
378
|
+
if (values[pressedThumbIndex] === max) {
|
|
379
|
+
let candidateIndex = pressedThumbIndex;
|
|
380
|
+
while(candidateIndex > 0 && values[candidateIndex - 1] === max)candidateIndex -= 1;
|
|
381
|
+
closestThumbIndex = candidateIndex;
|
|
382
|
+
}
|
|
383
|
+
} else {
|
|
384
|
+
const axis = vertical ? 'y' : 'x';
|
|
385
|
+
let minDistance;
|
|
386
|
+
closestThumbIndex = -1;
|
|
387
|
+
for(let i = 0; i < thumbRefs.current.length; i += 1){
|
|
388
|
+
const thumbEl = thumbRefs.current[i];
|
|
389
|
+
if (isElement(thumbEl)) {
|
|
390
|
+
const midpoint = getMidpoint(thumbEl);
|
|
391
|
+
const distance = Math.abs(fingerCoords[axis] - midpoint[axis]);
|
|
392
|
+
if (void 0 === minDistance || distance <= minDistance) {
|
|
393
|
+
closestThumbIndex = i;
|
|
394
|
+
minDistance = distance;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (closestThumbIndex > -1 && closestThumbIndex !== pressedThumbIndex) updatePressedThumb(closestThumbIndex);
|
|
400
|
+
if (inset) {
|
|
401
|
+
const thumbEl = thumbRefs.current[closestThumbIndex];
|
|
402
|
+
if (isElement(thumbEl)) {
|
|
403
|
+
const thumbRect = thumbEl.getBoundingClientRect();
|
|
404
|
+
const side = vertical ? 'height' : 'width';
|
|
405
|
+
insetThumbOffsetRef.current = thumbRect[side] / 2;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function focusThumb(thumbIndex) {
|
|
410
|
+
const input = thumbRefs.current?.[thumbIndex]?.querySelector('input[type="range"]');
|
|
411
|
+
if (!input) return;
|
|
412
|
+
input.focus({
|
|
413
|
+
preventScroll: true,
|
|
414
|
+
focusVisible: false
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
const handleTouchMove = useStableCallback((nativeEvent)=>{
|
|
418
|
+
const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
|
|
419
|
+
if (null == fingerCoords) return;
|
|
420
|
+
moveCountRef.current += 1;
|
|
421
|
+
if ('pointermove' === nativeEvent.type && 0 === nativeEvent.buttons) return void handleTouchEnd(nativeEvent);
|
|
422
|
+
const finger = getFingerState(fingerCoords);
|
|
423
|
+
if (null == finger) return;
|
|
424
|
+
if (validateMinimumDistance(finger.value, step, minStepsBetweenValues)) {
|
|
425
|
+
if (!dragging && moveCountRef.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) setDragging(true);
|
|
426
|
+
setValue(finger.value, createChangeEventDetails("drag", nativeEvent, void 0, {
|
|
427
|
+
activeThumbIndex: finger.thumbIndex
|
|
428
|
+
}));
|
|
429
|
+
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
430
|
+
finger.value
|
|
431
|
+
];
|
|
432
|
+
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
function handleTouchEnd(nativeEvent) {
|
|
436
|
+
setActive(-1);
|
|
437
|
+
setDragging(false);
|
|
438
|
+
pressedInputRef.current = null;
|
|
439
|
+
pressedThumbCenterOffsetRef.current = null;
|
|
440
|
+
const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
|
|
441
|
+
const finger = null != fingerCoords ? getFingerState(fingerCoords) : null;
|
|
442
|
+
if (null != finger) {
|
|
443
|
+
const commitReason = lastChangeReasonRef.current;
|
|
444
|
+
onValueCommitted(lastChangedValueRef.current ?? finger.value, createGenericEventDetails(commitReason, nativeEvent));
|
|
445
|
+
}
|
|
446
|
+
if ('pointerType' in nativeEvent && controlRef.current?.hasPointerCapture(nativeEvent.pointerId)) controlRef.current?.releasePointerCapture(nativeEvent.pointerId);
|
|
447
|
+
pressedThumbIndexRef.current = -1;
|
|
448
|
+
touchIdRef.current = null;
|
|
449
|
+
pressedValuesRef.current = null;
|
|
450
|
+
stopListening();
|
|
451
|
+
}
|
|
452
|
+
const handleTouchStart = useStableCallback((nativeEvent)=>{
|
|
453
|
+
if (disabled) return;
|
|
454
|
+
const touch = nativeEvent.changedTouches[0];
|
|
455
|
+
if (null != touch) touchIdRef.current = touch.identifier;
|
|
456
|
+
const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
|
|
457
|
+
if (null != fingerCoords) {
|
|
458
|
+
startPressing(fingerCoords);
|
|
459
|
+
const finger = getFingerState(fingerCoords);
|
|
460
|
+
if (null == finger) return;
|
|
461
|
+
focusThumb(finger.thumbIndex);
|
|
462
|
+
setValue(finger.value, createChangeEventDetails(trackPress, nativeEvent, void 0, {
|
|
463
|
+
activeThumbIndex: finger.thumbIndex
|
|
464
|
+
}));
|
|
465
|
+
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
466
|
+
finger.value
|
|
467
|
+
];
|
|
468
|
+
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
469
|
+
}
|
|
470
|
+
moveCountRef.current = 0;
|
|
471
|
+
const doc = ownerDocument(controlRef.current);
|
|
472
|
+
doc.addEventListener('touchmove', handleTouchMove, {
|
|
473
|
+
passive: true
|
|
474
|
+
});
|
|
475
|
+
doc.addEventListener('touchend', handleTouchEnd, {
|
|
476
|
+
passive: true
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
const stopListening = useStableCallback(()=>{
|
|
480
|
+
const doc = ownerDocument(controlRef.current);
|
|
481
|
+
doc.removeEventListener('pointermove', handleTouchMove);
|
|
482
|
+
doc.removeEventListener('pointerup', handleTouchEnd);
|
|
483
|
+
doc.removeEventListener('touchmove', handleTouchMove);
|
|
484
|
+
doc.removeEventListener('touchend', handleTouchEnd);
|
|
485
|
+
pressedValuesRef.current = null;
|
|
486
|
+
});
|
|
487
|
+
const focusFrame = useAnimationFrame();
|
|
488
|
+
__rspack_external_react.useEffect(()=>{
|
|
489
|
+
const control = controlRef.current;
|
|
490
|
+
if (!control) return ()=>stopListening();
|
|
491
|
+
const unsubscribeTouchStart = addEventListener(control, 'touchstart', handleTouchStart, {
|
|
492
|
+
passive: true
|
|
493
|
+
});
|
|
494
|
+
return ()=>{
|
|
495
|
+
unsubscribeTouchStart();
|
|
496
|
+
focusFrame.cancel();
|
|
497
|
+
stopListening();
|
|
498
|
+
};
|
|
499
|
+
}, [
|
|
500
|
+
stopListening,
|
|
501
|
+
handleTouchStart,
|
|
502
|
+
controlRef,
|
|
503
|
+
focusFrame
|
|
504
|
+
]);
|
|
505
|
+
__rspack_external_react.useEffect(()=>{
|
|
506
|
+
if (disabled) stopListening();
|
|
507
|
+
}, [
|
|
508
|
+
disabled,
|
|
509
|
+
stopListening
|
|
510
|
+
]);
|
|
511
|
+
const element = useRenderElement('div', componentProps, {
|
|
512
|
+
state,
|
|
513
|
+
ref: [
|
|
514
|
+
forwardedRef,
|
|
515
|
+
registerFieldControlRef,
|
|
516
|
+
controlRef,
|
|
517
|
+
setStylesRef
|
|
518
|
+
],
|
|
519
|
+
props: [
|
|
520
|
+
{
|
|
521
|
+
['data-base-ui-slider-control']: renderBeforeHydration ? '' : void 0,
|
|
522
|
+
onPointerDown (event) {
|
|
523
|
+
const control = controlRef.current;
|
|
524
|
+
const target = getTarget(event.nativeEvent);
|
|
525
|
+
if (!control || disabled || event.defaultPrevented || !isElement(target) || 0 !== event.button) return;
|
|
526
|
+
const fingerCoords = getFingerCoords(event, touchIdRef);
|
|
527
|
+
if (null != fingerCoords) {
|
|
528
|
+
startPressing(fingerCoords);
|
|
529
|
+
const finger = getFingerState(fingerCoords);
|
|
530
|
+
if (null == finger) return;
|
|
531
|
+
const pressedOnFocusedThumb = contains(thumbRefs.current[finger.thumbIndex], activeElement(ownerDocument(control)));
|
|
532
|
+
if (pressedOnFocusedThumb) event.preventDefault();
|
|
533
|
+
else focusFrame.request(()=>{
|
|
534
|
+
focusThumb(finger.thumbIndex);
|
|
535
|
+
});
|
|
536
|
+
setDragging(true);
|
|
537
|
+
const pressedOnAnyThumb = null != pressedThumbCenterOffsetRef.current;
|
|
538
|
+
if (!pressedOnAnyThumb) {
|
|
539
|
+
setValue(finger.value, createChangeEventDetails(trackPress, event.nativeEvent, void 0, {
|
|
540
|
+
activeThumbIndex: finger.thumbIndex
|
|
541
|
+
}));
|
|
542
|
+
latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [
|
|
543
|
+
finger.value
|
|
544
|
+
];
|
|
545
|
+
if (finger.didSwap) focusThumb(finger.thumbIndex);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (event.nativeEvent.pointerId) control.setPointerCapture(event.nativeEvent.pointerId);
|
|
549
|
+
moveCountRef.current = 0;
|
|
550
|
+
const doc = ownerDocument(controlRef.current);
|
|
551
|
+
doc.addEventListener('pointermove', handleTouchMove, {
|
|
552
|
+
passive: true
|
|
553
|
+
});
|
|
554
|
+
doc.addEventListener('pointerup', handleTouchEnd, {
|
|
555
|
+
once: true
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
elementProps
|
|
560
|
+
],
|
|
561
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
562
|
+
});
|
|
563
|
+
return element;
|
|
564
|
+
});
|
|
565
|
+
if ("production" !== process.env.NODE_ENV) SliderControl_SliderControl.displayName = "SliderControl";
|
|
566
|
+
const SliderTrack_SliderTrack = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
567
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
568
|
+
const { state } = useSliderRootContext();
|
|
569
|
+
const element = useRenderElement('div', componentProps, {
|
|
570
|
+
state,
|
|
571
|
+
ref: forwardedRef,
|
|
572
|
+
props: [
|
|
573
|
+
{
|
|
574
|
+
style: {
|
|
575
|
+
position: 'relative'
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
elementProps
|
|
579
|
+
],
|
|
580
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
581
|
+
});
|
|
582
|
+
return element;
|
|
583
|
+
});
|
|
584
|
+
if ("production" !== process.env.NODE_ENV) SliderTrack_SliderTrack.displayName = "SliderTrack";
|
|
585
|
+
function asc(a, b) {
|
|
586
|
+
return a - b;
|
|
587
|
+
}
|
|
588
|
+
function replaceArrayItemAtIndex(array, index, newValue) {
|
|
589
|
+
const output = array.slice();
|
|
590
|
+
output[index] = newValue;
|
|
591
|
+
return output.sort(asc);
|
|
592
|
+
}
|
|
593
|
+
function getSliderValue(valueInput, index, min, max, range, values) {
|
|
594
|
+
let newValue = valueInput;
|
|
595
|
+
newValue = clamp(newValue, min, max);
|
|
596
|
+
if (range) newValue = replaceArrayItemAtIndex(values, index, clamp(newValue, values[index - 1] || -1 / 0, values[index + 1] || 1 / 0));
|
|
597
|
+
return newValue;
|
|
598
|
+
}
|
|
599
|
+
let SliderThumbDataAttributes_SliderThumbDataAttributes = /*#__PURE__*/ function(SliderThumbDataAttributes) {
|
|
600
|
+
SliderThumbDataAttributes["index"] = "data-index";
|
|
601
|
+
SliderThumbDataAttributes["dragging"] = "data-dragging";
|
|
602
|
+
SliderThumbDataAttributes["orientation"] = "data-orientation";
|
|
603
|
+
SliderThumbDataAttributes["disabled"] = "data-disabled";
|
|
604
|
+
SliderThumbDataAttributes["valid"] = "data-valid";
|
|
605
|
+
SliderThumbDataAttributes["invalid"] = "data-invalid";
|
|
606
|
+
SliderThumbDataAttributes["touched"] = "data-touched";
|
|
607
|
+
SliderThumbDataAttributes["dirty"] = "data-dirty";
|
|
608
|
+
SliderThumbDataAttributes["focused"] = "data-focused";
|
|
609
|
+
return SliderThumbDataAttributes;
|
|
610
|
+
}({});
|
|
611
|
+
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"))))}}();';
|
|
612
|
+
const ALL_KEYS = new Set([
|
|
613
|
+
...COMPOSITE_KEYS,
|
|
614
|
+
"PageUp",
|
|
615
|
+
PAGE_DOWN
|
|
616
|
+
]);
|
|
617
|
+
function getDefaultAriaValueText(values, index, format, locale) {
|
|
618
|
+
if (index < 0) return;
|
|
619
|
+
if (2 === values.length) {
|
|
620
|
+
if (0 === index) return `${formatNumber(values[index], locale, format)} start range`;
|
|
621
|
+
return `${formatNumber(values[index], locale, format)} end range`;
|
|
622
|
+
}
|
|
623
|
+
return format ? formatNumber(values[index], locale, format) : void 0;
|
|
624
|
+
}
|
|
625
|
+
function getNewValue(thumbValue, increment, direction, min, max) {
|
|
626
|
+
const value = 1 === direction ? thumbValue + increment : thumbValue - increment;
|
|
627
|
+
const roundedValue = Number(value.toFixed(Math.max(getDecimalPrecision(thumbValue), getDecimalPrecision(increment), getDecimalPrecision(min))));
|
|
628
|
+
return clamp(roundedValue, min, max);
|
|
629
|
+
}
|
|
630
|
+
const SliderThumb_SliderThumb = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
631
|
+
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;
|
|
632
|
+
const { nonce } = useCSPContext();
|
|
633
|
+
const id = useBaseUiId(idProp);
|
|
634
|
+
const { active: activeIndex, lastUsedThumbIndex, controlRef, disabled: contextDisabled, validation, formatOptionsRef, handleInputChange, inset, labelId, largeStep, locale, max, min, minStepsBetweenValues, form, name, orientation, pressedInputRef, pressedThumbCenterOffsetRef, pressedThumbIndexRef, renderBeforeHydration, setActive, setIndicatorPosition, state, step, values: sliderValues } = useSliderRootContext();
|
|
635
|
+
const direction = useDirection();
|
|
636
|
+
const disabled = disabledProp || contextDisabled;
|
|
637
|
+
const range = sliderValues.length > 1;
|
|
638
|
+
const vertical = 'vertical' === orientation;
|
|
639
|
+
const rtl = 'rtl' === direction;
|
|
640
|
+
const { setTouched, setFocused, validationMode } = useFieldRootContext();
|
|
641
|
+
const thumbRef = __rspack_external_react.useRef(null);
|
|
642
|
+
const inputRef = __rspack_external_react.useRef(null);
|
|
643
|
+
const restoringFocusVisibleRef = __rspack_external_react.useRef(false);
|
|
644
|
+
const defaultInputId = useBaseUiId();
|
|
645
|
+
const labelableId = useLabelableId();
|
|
646
|
+
const inputId = range ? defaultInputId : labelableId;
|
|
647
|
+
const thumbMetadata = __rspack_external_react.useMemo(()=>({
|
|
648
|
+
inputId
|
|
649
|
+
}), [
|
|
650
|
+
inputId
|
|
651
|
+
]);
|
|
652
|
+
const { ref: listItemRef, index: compositeIndex } = useCompositeListItem({
|
|
653
|
+
metadata: thumbMetadata
|
|
654
|
+
});
|
|
655
|
+
const index = range ? indexProp ?? compositeIndex : 0;
|
|
656
|
+
const last = index === sliderValues.length - 1;
|
|
657
|
+
const thumbValue = sliderValues[index];
|
|
658
|
+
const thumbValuePercent = valueToPercent(thumbValue, min, max);
|
|
659
|
+
const [positionPercent, setPositionPercent] = __rspack_external_react.useState();
|
|
660
|
+
const isHydrating = useIsHydrating();
|
|
661
|
+
const safeLastUsedThumbIndex = lastUsedThumbIndex >= 0 && lastUsedThumbIndex < sliderValues.length ? lastUsedThumbIndex : -1;
|
|
662
|
+
const getInsetPosition = useStableCallback(()=>{
|
|
663
|
+
const control = controlRef.current;
|
|
664
|
+
const thumb = thumbRef.current;
|
|
665
|
+
if (!control || !thumb) return;
|
|
666
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
667
|
+
const controlRect = control.getBoundingClientRect();
|
|
668
|
+
const side = vertical ? 'height' : 'width';
|
|
669
|
+
const controlSize = controlRect[side] - thumbRect[side];
|
|
670
|
+
const thumbOffsetFromControlEdge = thumbRect[side] / 2 + controlSize * thumbValuePercent / 100;
|
|
671
|
+
const nextPositionPercent = thumbOffsetFromControlEdge / controlRect[side] * 100;
|
|
672
|
+
const nextInsetPosition = Number.isFinite(nextPositionPercent) ? nextPositionPercent : void 0;
|
|
673
|
+
setPositionPercent(nextInsetPosition);
|
|
674
|
+
if (0 === index) setIndicatorPosition((prevPosition)=>[
|
|
675
|
+
nextInsetPosition,
|
|
676
|
+
prevPosition[1]
|
|
677
|
+
]);
|
|
678
|
+
else if (last) setIndicatorPosition((prevPosition)=>[
|
|
679
|
+
prevPosition[0],
|
|
680
|
+
nextInsetPosition
|
|
681
|
+
]);
|
|
682
|
+
});
|
|
683
|
+
useIsoLayoutEffect(()=>{
|
|
684
|
+
if (inset) queueMicrotask(getInsetPosition);
|
|
685
|
+
}, [
|
|
686
|
+
getInsetPosition,
|
|
687
|
+
inset
|
|
688
|
+
]);
|
|
689
|
+
useIsoLayoutEffect(()=>{
|
|
690
|
+
if (inset) getInsetPosition();
|
|
691
|
+
}, [
|
|
692
|
+
getInsetPosition,
|
|
693
|
+
inset,
|
|
694
|
+
thumbValuePercent
|
|
695
|
+
]);
|
|
696
|
+
useIsoLayoutEffect(()=>{
|
|
697
|
+
if (!inset) return;
|
|
698
|
+
const control = controlRef.current;
|
|
699
|
+
const thumb = thumbRef.current;
|
|
700
|
+
if (!control || !thumb) return;
|
|
701
|
+
const ResizeObserverCtor = getWindow(control).ResizeObserver;
|
|
702
|
+
if ('function' != typeof ResizeObserverCtor) return;
|
|
703
|
+
const resizeObserver = new ResizeObserverCtor(getInsetPosition);
|
|
704
|
+
resizeObserver.observe(control);
|
|
705
|
+
resizeObserver.observe(thumb);
|
|
706
|
+
return ()=>{
|
|
707
|
+
resizeObserver.disconnect();
|
|
708
|
+
};
|
|
709
|
+
}, [
|
|
710
|
+
controlRef,
|
|
711
|
+
getInsetPosition,
|
|
712
|
+
inset
|
|
713
|
+
]);
|
|
714
|
+
const startEdge = vertical ? 'bottom' : 'insetInlineStart';
|
|
715
|
+
const crossOffsetProperty = vertical ? 'left' : 'top';
|
|
716
|
+
let zIndex;
|
|
717
|
+
if (range) {
|
|
718
|
+
if (activeIndex === index) zIndex = 2;
|
|
719
|
+
else if (safeLastUsedThumbIndex === index) zIndex = 1;
|
|
720
|
+
} else if (activeIndex === index) zIndex = 1;
|
|
721
|
+
let thumbStyle;
|
|
722
|
+
thumbStyle = inset ? {
|
|
723
|
+
['--position']: `${positionPercent ?? 0}%`,
|
|
724
|
+
visibility: renderBeforeHydration && isHydrating || void 0 === positionPercent ? 'hidden' : void 0,
|
|
725
|
+
position: 'absolute',
|
|
726
|
+
[startEdge]: 'var(--position)',
|
|
727
|
+
[crossOffsetProperty]: '50%',
|
|
728
|
+
translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
|
|
729
|
+
zIndex
|
|
730
|
+
} : Number.isFinite(thumbValuePercent) ? {
|
|
731
|
+
position: 'absolute',
|
|
732
|
+
[startEdge]: `${thumbValuePercent}%`,
|
|
733
|
+
[crossOffsetProperty]: '50%',
|
|
734
|
+
translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
|
|
735
|
+
zIndex
|
|
736
|
+
} : visuallyHidden;
|
|
737
|
+
let cssWritingMode;
|
|
738
|
+
if ('vertical' === orientation) cssWritingMode = rtl ? 'vertical-rl' : 'vertical-lr';
|
|
739
|
+
const ariaLabel = 'function' == typeof getAriaLabelProp ? getAriaLabelProp(index) : ariaLabelProp;
|
|
740
|
+
const inputProps = mergeProps({
|
|
741
|
+
'aria-label': ariaLabel,
|
|
742
|
+
'aria-labelledby': ariaLabelledByProp ?? (null == ariaLabel ? labelId : void 0),
|
|
743
|
+
'aria-describedby': ariaDescribedByProp,
|
|
744
|
+
'aria-orientation': orientation,
|
|
745
|
+
'aria-valuenow': thumbValue,
|
|
746
|
+
'aria-valuetext': 'function' == typeof getAriaValueTextProp ? getAriaValueTextProp(formatNumber(thumbValue, locale, formatOptionsRef.current ?? void 0), thumbValue, index) : getDefaultAriaValueText(sliderValues, index, formatOptionsRef.current ?? void 0, locale),
|
|
747
|
+
disabled,
|
|
748
|
+
form,
|
|
749
|
+
id: inputId,
|
|
750
|
+
max,
|
|
751
|
+
min,
|
|
752
|
+
name,
|
|
753
|
+
onChange (event) {
|
|
754
|
+
handleInputChange(event.currentTarget.valueAsNumber, index, event);
|
|
755
|
+
},
|
|
756
|
+
onFocus (event) {
|
|
757
|
+
const isRestoringFocusVisible = restoringFocusVisibleRef.current;
|
|
758
|
+
restoringFocusVisibleRef.current = false;
|
|
759
|
+
setActive(index);
|
|
760
|
+
setFocused(true);
|
|
761
|
+
if (isRestoringFocusVisible) event.stopPropagation();
|
|
762
|
+
},
|
|
763
|
+
onBlur (event) {
|
|
764
|
+
if (restoringFocusVisibleRef.current) return void event.stopPropagation();
|
|
765
|
+
if (!thumbRef.current) return;
|
|
766
|
+
setActive(-1);
|
|
767
|
+
setTouched(true);
|
|
768
|
+
setFocused(false);
|
|
769
|
+
if ('onBlur' === validationMode) validation.commit(getSliderValue(thumbValue, index, min, max, range, sliderValues));
|
|
770
|
+
},
|
|
771
|
+
onKeyDown (event) {
|
|
772
|
+
if (!ALL_KEYS.has(event.key)) return;
|
|
773
|
+
if (COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
|
|
774
|
+
let newValue = null;
|
|
775
|
+
const roundedValue = roundValueToStep(thumbValue, step, min);
|
|
776
|
+
switch(event.key){
|
|
777
|
+
case ARROW_UP:
|
|
778
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, 1, min, max);
|
|
779
|
+
break;
|
|
780
|
+
case ARROW_RIGHT:
|
|
781
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, rtl ? -1 : 1, min, max);
|
|
782
|
+
break;
|
|
783
|
+
case ARROW_DOWN:
|
|
784
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, -1, min, max);
|
|
785
|
+
break;
|
|
786
|
+
case ARROW_LEFT:
|
|
787
|
+
newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, rtl ? 1 : -1, min, max);
|
|
788
|
+
break;
|
|
789
|
+
case "PageUp":
|
|
790
|
+
newValue = getNewValue(roundedValue, largeStep, 1, min, max);
|
|
791
|
+
break;
|
|
792
|
+
case PAGE_DOWN:
|
|
793
|
+
newValue = getNewValue(roundedValue, largeStep, -1, min, max);
|
|
794
|
+
break;
|
|
795
|
+
case "End":
|
|
796
|
+
newValue = max;
|
|
797
|
+
if (range) newValue = Number.isFinite(sliderValues[index + 1]) ? sliderValues[index + 1] - step * minStepsBetweenValues : max;
|
|
798
|
+
break;
|
|
799
|
+
case "Home":
|
|
800
|
+
newValue = min;
|
|
801
|
+
if (range) newValue = Number.isFinite(sliderValues[index - 1]) ? sliderValues[index - 1] + step * minStepsBetweenValues : min;
|
|
802
|
+
break;
|
|
803
|
+
default:
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
if (null !== newValue) {
|
|
807
|
+
const input = event.currentTarget;
|
|
808
|
+
if (!matchesFocusVisible(input)) {
|
|
809
|
+
restoringFocusVisibleRef.current = true;
|
|
810
|
+
input.blur();
|
|
811
|
+
input.focus({
|
|
812
|
+
preventScroll: true,
|
|
813
|
+
focusVisible: true
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
handleInputChange(newValue, index, event);
|
|
817
|
+
event.preventDefault();
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
step,
|
|
821
|
+
style: {
|
|
822
|
+
...visuallyHidden,
|
|
823
|
+
width: '100%',
|
|
824
|
+
height: '100%',
|
|
825
|
+
writingMode: cssWritingMode
|
|
826
|
+
},
|
|
827
|
+
tabIndex: tabIndexProp ?? void 0,
|
|
828
|
+
type: 'range',
|
|
829
|
+
value: thumbValue ?? ''
|
|
830
|
+
}, validation.getInputValidationProps);
|
|
831
|
+
const mergedInputRef = useMergedRefs(inputRef, validation.inputRef, inputRefProp);
|
|
832
|
+
const element = useRenderElement('div', componentProps, {
|
|
833
|
+
state,
|
|
834
|
+
ref: [
|
|
835
|
+
forwardedRef,
|
|
836
|
+
listItemRef,
|
|
837
|
+
thumbRef
|
|
838
|
+
],
|
|
839
|
+
props: [
|
|
840
|
+
{
|
|
841
|
+
[SliderThumbDataAttributes_SliderThumbDataAttributes.index]: index,
|
|
842
|
+
children: /*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
843
|
+
children: [
|
|
844
|
+
childrenProp,
|
|
845
|
+
/*#__PURE__*/ jsx("input", {
|
|
846
|
+
ref: mergedInputRef,
|
|
847
|
+
...inputProps,
|
|
848
|
+
suppressHydrationWarning: true
|
|
849
|
+
}),
|
|
850
|
+
inset && isHydrating && renderBeforeHydration && last && /*#__PURE__*/ jsx("script", {
|
|
851
|
+
nonce: nonce,
|
|
852
|
+
dangerouslySetInnerHTML: {
|
|
853
|
+
__html: script
|
|
854
|
+
},
|
|
855
|
+
suppressHydrationWarning: true
|
|
856
|
+
})
|
|
857
|
+
]
|
|
858
|
+
}),
|
|
859
|
+
id,
|
|
860
|
+
onBlur: onBlurProp,
|
|
861
|
+
onFocus: onFocusProp,
|
|
862
|
+
onPointerDown (event) {
|
|
863
|
+
pressedThumbIndexRef.current = index;
|
|
864
|
+
if (null != thumbRef.current) {
|
|
865
|
+
const axis = 'horizontal' === orientation ? 'x' : 'y';
|
|
866
|
+
const midpoint = getMidpoint(thumbRef.current);
|
|
867
|
+
const offset = ('horizontal' === orientation ? event.clientX : event.clientY) - midpoint[axis];
|
|
868
|
+
pressedThumbCenterOffsetRef.current = offset;
|
|
869
|
+
}
|
|
870
|
+
if (null != inputRef.current && pressedInputRef.current !== inputRef.current) pressedInputRef.current = inputRef.current;
|
|
871
|
+
},
|
|
872
|
+
style: thumbStyle,
|
|
873
|
+
suppressHydrationWarning: renderBeforeHydration || void 0
|
|
874
|
+
},
|
|
875
|
+
elementProps
|
|
876
|
+
],
|
|
877
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
878
|
+
});
|
|
879
|
+
return element;
|
|
880
|
+
});
|
|
881
|
+
if ("production" !== process.env.NODE_ENV) SliderThumb_SliderThumb.displayName = "SliderThumb";
|
|
882
|
+
function getInsetStyles(vertical, range, start, end, renderBeforeHydration, hydrating) {
|
|
883
|
+
const visibility = void 0 === start || range && void 0 === end ? 'hidden' : void 0;
|
|
884
|
+
const startEdge = vertical ? 'bottom' : 'insetInlineStart';
|
|
885
|
+
const mainSide = vertical ? 'height' : 'width';
|
|
886
|
+
const crossSide = vertical ? 'width' : 'height';
|
|
887
|
+
const styles = {
|
|
888
|
+
visibility: renderBeforeHydration && hydrating ? 'hidden' : visibility,
|
|
889
|
+
position: vertical ? 'absolute' : 'relative',
|
|
890
|
+
[crossSide]: 'inherit'
|
|
891
|
+
};
|
|
892
|
+
styles['--start-position'] = `${start ?? 0}%`;
|
|
893
|
+
if (!range) {
|
|
894
|
+
styles[startEdge] = 0;
|
|
895
|
+
styles[mainSide] = 'var(--start-position)';
|
|
896
|
+
return styles;
|
|
897
|
+
}
|
|
898
|
+
styles['--relative-size'] = `${(end ?? 0) - (start ?? 0)}%`;
|
|
899
|
+
styles[startEdge] = 'var(--start-position)';
|
|
900
|
+
styles[mainSide] = 'var(--relative-size)';
|
|
901
|
+
return styles;
|
|
902
|
+
}
|
|
903
|
+
function getCenteredStyles(vertical, range, start, end) {
|
|
904
|
+
const startEdge = vertical ? 'bottom' : 'insetInlineStart';
|
|
905
|
+
const mainSide = vertical ? 'height' : 'width';
|
|
906
|
+
const crossSide = vertical ? 'width' : 'height';
|
|
907
|
+
const styles = {
|
|
908
|
+
position: vertical ? 'absolute' : 'relative',
|
|
909
|
+
[crossSide]: 'inherit'
|
|
910
|
+
};
|
|
911
|
+
if (!range) {
|
|
912
|
+
styles[startEdge] = 0;
|
|
913
|
+
styles[mainSide] = `${start}%`;
|
|
914
|
+
return styles;
|
|
915
|
+
}
|
|
916
|
+
const size = end - start;
|
|
917
|
+
styles[startEdge] = `${start}%`;
|
|
918
|
+
styles[mainSide] = `${size}%`;
|
|
919
|
+
return styles;
|
|
920
|
+
}
|
|
921
|
+
const SliderIndicator_SliderIndicator = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
922
|
+
const { render, className, style: styleProp, ...elementProps } = componentProps;
|
|
923
|
+
const { indicatorPosition, inset, max, min, orientation, renderBeforeHydration, state, values } = useSliderRootContext();
|
|
924
|
+
const isHydrating = useIsHydrating();
|
|
925
|
+
const vertical = 'vertical' === orientation;
|
|
926
|
+
const range = values.length > 1;
|
|
927
|
+
const style = inset ? getInsetStyles(vertical, range, indicatorPosition[0], indicatorPosition[1], renderBeforeHydration, isHydrating) : getCenteredStyles(vertical, range, valueToPercent(values[0], min, max), valueToPercent(values[values.length - 1], min, max));
|
|
928
|
+
const element = useRenderElement('div', componentProps, {
|
|
929
|
+
state,
|
|
930
|
+
ref: forwardedRef,
|
|
931
|
+
props: [
|
|
932
|
+
{
|
|
933
|
+
['data-base-ui-slider-indicator']: renderBeforeHydration ? '' : void 0,
|
|
934
|
+
style,
|
|
935
|
+
suppressHydrationWarning: renderBeforeHydration || void 0
|
|
936
|
+
},
|
|
937
|
+
elementProps
|
|
938
|
+
],
|
|
939
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
940
|
+
});
|
|
941
|
+
return element;
|
|
942
|
+
});
|
|
943
|
+
if ("production" !== process.env.NODE_ENV) SliderIndicator_SliderIndicator.displayName = "SliderIndicator";
|
|
944
|
+
function getSliderChangeEventReason(event) {
|
|
945
|
+
return 'key' in event ? keyboard : inputChange;
|
|
946
|
+
}
|
|
947
|
+
function areValuesEqual(newValue, oldValue) {
|
|
948
|
+
if ('number' == typeof newValue && 'number' == typeof oldValue) return newValue === oldValue;
|
|
949
|
+
if (Array.isArray(newValue) && Array.isArray(oldValue)) return areArraysEqual(newValue, oldValue);
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
const SliderRoot_SliderRoot = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
953
|
+
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;
|
|
954
|
+
const id = useBaseUiId(idProp);
|
|
955
|
+
const defaultLabelId = getDefaultLabelId(id);
|
|
956
|
+
const onValueChange = useStableCallback(onValueChangeProp);
|
|
957
|
+
const onValueCommitted = useStableCallback(onValueCommittedProp);
|
|
958
|
+
const { clearErrors } = useFormContext();
|
|
959
|
+
const { state: fieldState, disabled: fieldDisabled, name: fieldName, setTouched, setDirty, validityData, shouldValidateOnChange, validation } = useFieldRootContext();
|
|
960
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
961
|
+
const [labelId, setLabelId] = __rspack_external_react.useState();
|
|
962
|
+
const ariaLabelledby = ariaLabelledByProp ?? resolveAriaLabelledBy(fieldLabelId, labelId);
|
|
963
|
+
const disabled = fieldDisabled || disabledProp;
|
|
964
|
+
const name = fieldName ?? nameProp;
|
|
965
|
+
const [valueUnwrapped, setValueUnwrapped] = useControlled({
|
|
966
|
+
controlled: valueProp,
|
|
967
|
+
default: defaultValue ?? min,
|
|
968
|
+
name: 'Slider'
|
|
969
|
+
});
|
|
970
|
+
const sliderRef = __rspack_external_react.useRef(null);
|
|
971
|
+
const controlRef = __rspack_external_react.useRef(null);
|
|
972
|
+
const thumbRefs = __rspack_external_react.useRef([]);
|
|
973
|
+
const pressedInputRef = __rspack_external_react.useRef(null);
|
|
974
|
+
const pressedThumbCenterOffsetRef = __rspack_external_react.useRef(null);
|
|
975
|
+
const pressedThumbIndexRef = __rspack_external_react.useRef(-1);
|
|
976
|
+
const pressedValuesRef = __rspack_external_react.useRef(null);
|
|
977
|
+
const lastChangedValueRef = __rspack_external_react.useRef(null);
|
|
978
|
+
const lastChangeReasonRef = __rspack_external_react.useRef('none');
|
|
979
|
+
const formatOptionsRef = useValueAsRef(format);
|
|
980
|
+
const [active, setActiveState] = __rspack_external_react.useState(-1);
|
|
981
|
+
const [lastUsedThumbIndex, setLastUsedThumbIndex] = __rspack_external_react.useState(-1);
|
|
982
|
+
const [dragging, setDragging] = __rspack_external_react.useState(false);
|
|
983
|
+
const [thumbMap, setThumbMap] = __rspack_external_react.useState(()=>new Map());
|
|
984
|
+
const [indicatorPosition, setIndicatorPosition] = __rspack_external_react.useState([
|
|
985
|
+
void 0,
|
|
986
|
+
void 0
|
|
987
|
+
]);
|
|
988
|
+
const setActive = useStableCallback((value)=>{
|
|
989
|
+
setActiveState(value);
|
|
990
|
+
if (-1 !== value) setLastUsedThumbIndex(value);
|
|
991
|
+
});
|
|
992
|
+
useRegisterFieldControl(controlRef, id, valueUnwrapped);
|
|
993
|
+
useValueChanged(valueUnwrapped, ()=>{
|
|
994
|
+
clearErrors(name);
|
|
995
|
+
if (shouldValidateOnChange()) validation.commit(valueUnwrapped);
|
|
996
|
+
else validation.commit(valueUnwrapped, true);
|
|
997
|
+
const initialValue = validityData.initialValue;
|
|
998
|
+
let isDirty;
|
|
999
|
+
isDirty = Array.isArray(valueUnwrapped) && Array.isArray(initialValue) ? !areArraysEqual(valueUnwrapped, initialValue) : valueUnwrapped !== initialValue;
|
|
1000
|
+
setDirty(isDirty);
|
|
1001
|
+
});
|
|
1002
|
+
const registerFieldControlRef = useStableCallback((element)=>{
|
|
1003
|
+
if (element) controlRef.current = element;
|
|
1004
|
+
});
|
|
1005
|
+
const range = Array.isArray(valueUnwrapped);
|
|
1006
|
+
const values = __rspack_external_react.useMemo(()=>{
|
|
1007
|
+
if (!range) return [
|
|
1008
|
+
clamp(valueUnwrapped, min, max)
|
|
1009
|
+
];
|
|
1010
|
+
return valueUnwrapped.slice().sort(asc);
|
|
1011
|
+
}, [
|
|
1012
|
+
max,
|
|
1013
|
+
min,
|
|
1014
|
+
range,
|
|
1015
|
+
valueUnwrapped
|
|
1016
|
+
]);
|
|
1017
|
+
const setValue = useStableCallback((newValue, details)=>{
|
|
1018
|
+
if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped)) return;
|
|
1019
|
+
const changeDetails = details ?? createChangeEventDetails("none", void 0, void 0, {
|
|
1020
|
+
activeThumbIndex: -1
|
|
1021
|
+
});
|
|
1022
|
+
lastChangeReasonRef.current = changeDetails.reason;
|
|
1023
|
+
const nativeEvent = changeDetails.event;
|
|
1024
|
+
const EventConstructor = nativeEvent.constructor ?? Event;
|
|
1025
|
+
const clonedEvent = new EventConstructor(nativeEvent.type, nativeEvent);
|
|
1026
|
+
Object.defineProperty(clonedEvent, 'target', {
|
|
1027
|
+
writable: true,
|
|
1028
|
+
value: {
|
|
1029
|
+
value: newValue,
|
|
1030
|
+
name
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
changeDetails.event = clonedEvent;
|
|
1034
|
+
lastChangedValueRef.current = newValue;
|
|
1035
|
+
onValueChange(newValue, changeDetails);
|
|
1036
|
+
if (changeDetails.isCanceled) return;
|
|
1037
|
+
setValueUnwrapped(newValue);
|
|
1038
|
+
});
|
|
1039
|
+
const handleInputChange = useStableCallback((valueInput, index, event)=>{
|
|
1040
|
+
const newValue = getSliderValue(valueInput, index, min, max, range, values);
|
|
1041
|
+
if (validateMinimumDistance(newValue, step, minStepsBetweenValues)) {
|
|
1042
|
+
const reason = getSliderChangeEventReason(event);
|
|
1043
|
+
setValue(newValue, createChangeEventDetails(reason, event.nativeEvent, void 0, {
|
|
1044
|
+
activeThumbIndex: index
|
|
1045
|
+
}));
|
|
1046
|
+
setTouched(true);
|
|
1047
|
+
const nextValue = lastChangedValueRef.current ?? newValue;
|
|
1048
|
+
onValueCommitted(nextValue, createGenericEventDetails(reason, event.nativeEvent));
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
if ('production' !== process.env.NODE_ENV) {
|
|
1052
|
+
if (min >= max) warn('Slider `max` must be greater than `min`.');
|
|
1053
|
+
}
|
|
1054
|
+
useIsoLayoutEffect(()=>{
|
|
1055
|
+
const activeEl = activeElement(ownerDocument(sliderRef.current));
|
|
1056
|
+
if (disabled && contains(sliderRef.current, activeEl)) activeEl.blur();
|
|
1057
|
+
}, [
|
|
1058
|
+
disabled
|
|
1059
|
+
]);
|
|
1060
|
+
if (disabled && -1 !== active) setActive(-1);
|
|
1061
|
+
const state = __rspack_external_react.useMemo(()=>({
|
|
1062
|
+
...fieldState,
|
|
1063
|
+
activeThumbIndex: active,
|
|
1064
|
+
disabled,
|
|
1065
|
+
dragging,
|
|
1066
|
+
orientation,
|
|
1067
|
+
max,
|
|
1068
|
+
min,
|
|
1069
|
+
minStepsBetweenValues,
|
|
1070
|
+
step,
|
|
1071
|
+
values
|
|
1072
|
+
}), [
|
|
1073
|
+
fieldState,
|
|
1074
|
+
active,
|
|
1075
|
+
disabled,
|
|
1076
|
+
dragging,
|
|
1077
|
+
max,
|
|
1078
|
+
min,
|
|
1079
|
+
minStepsBetweenValues,
|
|
1080
|
+
orientation,
|
|
1081
|
+
step,
|
|
1082
|
+
values
|
|
1083
|
+
]);
|
|
1084
|
+
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1085
|
+
active,
|
|
1086
|
+
controlRef,
|
|
1087
|
+
disabled,
|
|
1088
|
+
dragging,
|
|
1089
|
+
validation,
|
|
1090
|
+
formatOptionsRef,
|
|
1091
|
+
handleInputChange,
|
|
1092
|
+
indicatorPosition,
|
|
1093
|
+
inset: 'center' !== thumbAlignment,
|
|
1094
|
+
labelId: ariaLabelledby,
|
|
1095
|
+
rootLabelId: defaultLabelId,
|
|
1096
|
+
largeStep,
|
|
1097
|
+
lastUsedThumbIndex,
|
|
1098
|
+
lastChangedValueRef,
|
|
1099
|
+
lastChangeReasonRef,
|
|
1100
|
+
form,
|
|
1101
|
+
locale,
|
|
1102
|
+
max,
|
|
1103
|
+
min,
|
|
1104
|
+
minStepsBetweenValues,
|
|
1105
|
+
name,
|
|
1106
|
+
onValueCommitted,
|
|
1107
|
+
orientation,
|
|
1108
|
+
pressedInputRef,
|
|
1109
|
+
pressedThumbCenterOffsetRef,
|
|
1110
|
+
pressedThumbIndexRef,
|
|
1111
|
+
pressedValuesRef,
|
|
1112
|
+
registerFieldControlRef,
|
|
1113
|
+
renderBeforeHydration: 'edge' === thumbAlignment,
|
|
1114
|
+
setActive,
|
|
1115
|
+
setDragging,
|
|
1116
|
+
setIndicatorPosition,
|
|
1117
|
+
setLabelId,
|
|
1118
|
+
setValue,
|
|
1119
|
+
state,
|
|
1120
|
+
step,
|
|
1121
|
+
thumbCollisionBehavior,
|
|
1122
|
+
thumbMap,
|
|
1123
|
+
thumbRefs,
|
|
1124
|
+
values
|
|
1125
|
+
}), [
|
|
1126
|
+
active,
|
|
1127
|
+
controlRef,
|
|
1128
|
+
ariaLabelledby,
|
|
1129
|
+
defaultLabelId,
|
|
1130
|
+
disabled,
|
|
1131
|
+
dragging,
|
|
1132
|
+
validation,
|
|
1133
|
+
formatOptionsRef,
|
|
1134
|
+
handleInputChange,
|
|
1135
|
+
indicatorPosition,
|
|
1136
|
+
largeStep,
|
|
1137
|
+
lastUsedThumbIndex,
|
|
1138
|
+
lastChangedValueRef,
|
|
1139
|
+
lastChangeReasonRef,
|
|
1140
|
+
form,
|
|
1141
|
+
locale,
|
|
1142
|
+
max,
|
|
1143
|
+
min,
|
|
1144
|
+
minStepsBetweenValues,
|
|
1145
|
+
name,
|
|
1146
|
+
onValueCommitted,
|
|
1147
|
+
orientation,
|
|
1148
|
+
pressedInputRef,
|
|
1149
|
+
pressedThumbCenterOffsetRef,
|
|
1150
|
+
pressedThumbIndexRef,
|
|
1151
|
+
pressedValuesRef,
|
|
1152
|
+
registerFieldControlRef,
|
|
1153
|
+
setActive,
|
|
1154
|
+
setDragging,
|
|
1155
|
+
setIndicatorPosition,
|
|
1156
|
+
setLabelId,
|
|
1157
|
+
setValue,
|
|
1158
|
+
state,
|
|
1159
|
+
step,
|
|
1160
|
+
thumbCollisionBehavior,
|
|
1161
|
+
thumbAlignment,
|
|
1162
|
+
thumbMap,
|
|
1163
|
+
thumbRefs,
|
|
1164
|
+
values
|
|
1165
|
+
]);
|
|
1166
|
+
const element = useRenderElement('div', componentProps, {
|
|
1167
|
+
state,
|
|
1168
|
+
ref: [
|
|
1169
|
+
forwardedRef,
|
|
1170
|
+
sliderRef
|
|
1171
|
+
],
|
|
1172
|
+
props: [
|
|
1173
|
+
{
|
|
1174
|
+
'aria-labelledby': ariaLabelledby,
|
|
1175
|
+
id,
|
|
1176
|
+
role: 'group'
|
|
1177
|
+
},
|
|
1178
|
+
validation.getValidationProps,
|
|
1179
|
+
elementProps
|
|
1180
|
+
],
|
|
1181
|
+
stateAttributesMapping: sliderStateAttributesMapping
|
|
1182
|
+
});
|
|
1183
|
+
return /*#__PURE__*/ jsx(SliderRootContext.Provider, {
|
|
1184
|
+
value: contextValue,
|
|
1185
|
+
children: /*#__PURE__*/ jsx(CompositeList, {
|
|
1186
|
+
elementsRef: thumbRefs,
|
|
1187
|
+
onMapChange: setThumbMap,
|
|
1188
|
+
children: element
|
|
1189
|
+
})
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
if ("production" !== process.env.NODE_ENV) SliderRoot_SliderRoot.displayName = "SliderRoot";
|
|
5
1193
|
const Slider_module = {
|
|
6
1194
|
root: "root-uI1zMj",
|
|
7
1195
|
label: "label-MkH3nw",
|
|
@@ -16,38 +1204,38 @@ const SliderSize = {
|
|
|
16
1204
|
medium: 16,
|
|
17
1205
|
large: 20
|
|
18
1206
|
};
|
|
19
|
-
const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1207
|
+
const Label = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderLabel_SliderLabel, {
|
|
20
1208
|
ref: ref,
|
|
21
1209
|
className: clsx(Slider_module.label, className),
|
|
22
1210
|
...props
|
|
23
1211
|
}));
|
|
24
|
-
const Value = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1212
|
+
const Value = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderValue_SliderValue, {
|
|
25
1213
|
ref: ref,
|
|
26
1214
|
className: clsx(Slider_module.value, className),
|
|
27
1215
|
...props
|
|
28
1216
|
}));
|
|
29
|
-
const Control = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1217
|
+
const Control = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderControl_SliderControl, {
|
|
30
1218
|
ref: ref,
|
|
31
1219
|
className: clsx(Slider_module.control, className),
|
|
32
1220
|
...props
|
|
33
1221
|
}));
|
|
34
|
-
const Track = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1222
|
+
const Track = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderTrack_SliderTrack, {
|
|
35
1223
|
ref: ref,
|
|
36
1224
|
className: clsx(Slider_module.track, className),
|
|
37
1225
|
...props
|
|
38
1226
|
}));
|
|
39
|
-
const Thumb = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1227
|
+
const Thumb = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderThumb_SliderThumb, {
|
|
40
1228
|
ref: ref,
|
|
41
1229
|
className: clsx(Slider_module.thumb, className),
|
|
42
1230
|
...props
|
|
43
1231
|
}));
|
|
44
|
-
const Indicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(
|
|
1232
|
+
const Indicator = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(SliderIndicator_SliderIndicator, {
|
|
45
1233
|
ref: ref,
|
|
46
1234
|
className: clsx(Slider_module.indicator, className),
|
|
47
1235
|
...props
|
|
48
1236
|
}));
|
|
49
1237
|
function Root({ className, size = SliderSize.medium, style, ...props }) {
|
|
50
|
-
return /*#__PURE__*/ jsx(
|
|
1238
|
+
return /*#__PURE__*/ jsx(SliderRoot_SliderRoot, {
|
|
51
1239
|
...props,
|
|
52
1240
|
className: clsx(Slider_module.root, className),
|
|
53
1241
|
style: {
|
|
@@ -56,7 +1244,7 @@ function Root({ className, size = SliderSize.medium, style, ...props }) {
|
|
|
56
1244
|
}
|
|
57
1245
|
});
|
|
58
1246
|
}
|
|
59
|
-
const
|
|
1247
|
+
const Slider = {
|
|
60
1248
|
Label: Label,
|
|
61
1249
|
Value: Value,
|
|
62
1250
|
Control: Control,
|
|
@@ -65,4 +1253,4 @@ const Slider_Slider = {
|
|
|
65
1253
|
Indicator: Indicator,
|
|
66
1254
|
Root: Root
|
|
67
1255
|
};
|
|
68
|
-
export {
|
|
1256
|
+
export { Slider, SliderSize };
|