@eightshift/ui-components 1.6.1 → 1.7.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/Button-VbCAu4hd.js +185 -0
- package/dist/{intlStrings-BxJIrC6b.js → Color-BpLubxWI.js} +2394 -2394
- package/dist/{ColorSwatch-BNX2quma.js → ColorSwatch-CinC14s3.js} +4 -4
- package/dist/{Dialog-BdtBguys.js → Dialog-BN5EE7UH.js} +9 -9
- package/dist/{FieldError-ClB3-XvF.js → FieldError-BttM1Nxd.js} +2 -2
- package/dist/{FocusScope-B5L3qI3N.js → FocusScope-CtCX0OGo.js} +2 -2
- package/dist/{Group-ubPTwji_.js → Group-XzWUooix.js} +3 -3
- package/dist/{Heading-DGnF6JDc.js → Heading-DZelepHV.js} +1 -1
- package/dist/{Hidden-CupIZhlF.js → Hidden-CcFqOzrp.js} +1 -1
- package/dist/{Input-BoNEjaXM.js → Input-CV1qVS6t.js} +8 -8
- package/dist/{Label-BqW0M3HN.js → Label-BwqMVkuV.js} +2 -2
- package/dist/{ListBox-civ86c_v.js → ListBox-DuZPdnkk.js} +16 -12
- package/dist/{SelectionManager-Ctbzoj1E.js → SelectionManager-x27KqnAT.js} +67 -34
- package/dist/{Separator-CDhAddZc.js → Separator-BM58t3PP.js} +24 -26
- package/dist/{Slider-Dkj8Slw3.js → Slider-D9Cs6yKr.js} +162 -162
- package/dist/{Text-CdwRBXol.js → Text-BVIXT8qq.js} +1 -1
- package/dist/{VisuallyHidden-DsMLX-RC.js → VisuallyHidden-WhC7vZaL.js} +2 -2
- package/dist/assets/style.css +1 -1
- package/dist/components/animated-visibility/animated-visibility.js +92 -129
- package/dist/components/base-control/base-control.js +1 -1
- package/dist/components/button/button.js +6 -6
- package/dist/components/checkbox/checkbox.js +7 -7
- package/dist/components/color-pickers/color-picker.js +2 -2
- package/dist/components/color-pickers/color-swatch.js +3 -3
- package/dist/components/color-pickers/gradient-editor.js +2 -2
- package/dist/components/color-pickers/solid-color-picker.js +64 -64
- package/dist/components/component-toggle/component-toggle.js +1 -1
- package/dist/components/draggable/draggable-handle.js +2 -2
- package/dist/components/draggable/draggable.js +7 -4
- package/dist/components/draggable-list/draggable-list-item.js +2 -2
- package/dist/components/draggable-list/draggable-list.js +6 -3
- package/dist/components/expandable/expandable.js +3 -3
- package/dist/components/index.js +3 -1
- package/dist/components/input-field/input-field.js +7 -7
- package/dist/components/item-collection/item-collection.js +6 -1
- package/dist/components/link-input/link-input.js +40 -36
- package/dist/components/list-box/list-box.js +2 -2
- package/dist/components/matrix-align/matrix-align.js +2 -2
- package/dist/components/menu/menu.js +15 -15
- package/dist/components/modal/modal.js +6 -6
- package/dist/components/number-picker/number-picker.js +10 -10
- package/dist/components/option-select/option-select.js +1 -1
- package/dist/components/options-panel/options-panel.js +1 -1
- package/dist/components/placeholders/file-placeholder.js +1 -1
- package/dist/components/placeholders/media-placeholder.js +6 -5
- package/dist/components/popover/popover.js +2 -2
- package/dist/components/radio/radio.js +13 -13
- package/dist/components/repeater/repeater-item.js +1 -1
- package/dist/components/repeater/repeater.js +6 -3
- package/dist/components/responsive/mini-responsive.js +495 -0
- package/dist/components/responsive/responsive-legacy.js +2 -2
- package/dist/components/responsive/responsive.js +7 -3
- package/dist/components/responsive-preview/responsive-preview.js +1 -1
- package/dist/components/select/async-multi-select.js +1 -0
- package/dist/components/select/async-single-select.js +1 -0
- package/dist/components/select/multi-select.js +1 -0
- package/dist/components/select/single-select.js +1 -0
- package/dist/components/select/styles.js +1 -1
- package/dist/components/slider/column-config-slider.js +3 -3
- package/dist/components/slider/slider.js +3 -3
- package/dist/components/slider/utils.js +1 -1
- package/dist/components/spacer/spacer.js +3 -4
- package/dist/components/tabs/tabs.js +22 -17
- package/dist/components/toggle/switch.js +6 -6
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle-button/toggle-button.js +6 -6
- package/dist/components/tooltip/tooltip.js +3 -3
- package/dist/{context-kCEA3M_y.js → context-Cs-ZD1nu.js} +1 -1
- package/dist/{default-i18n-BqWys-1G.js → default-i18n-DRnM8y4w.js} +45 -21
- package/dist/{focusSafely-xMzk3syC.js → focusSafely-CgFLw4FA.js} +1 -1
- package/dist/icons/jsx-svg.js +1 -1
- package/dist/index.js +3 -1
- package/dist/{number-CHmNj-oR.js → number-GajL10e1.js} +2 -2
- package/dist/{react-jsx-parser.min-sPC96O_U.js → react-jsx-parser.min-B5HVwW_W.js} +103 -53
- package/dist/{textSelection-D5Bit8i8.js → textSelection-CvK0YHTZ.js} +1 -1
- package/dist/{tooltip-srrt1p-b.js → tooltip-eKaARDoV.js} +5 -5
- package/dist/{useButton-6H5k2W5N.js → useButton-Cy9eEev7.js} +3 -3
- package/dist/{useEvent-BY-3vfxa.js → useEvent-LZebwyrb.js} +1 -1
- package/dist/{useFocusRing-rz8eyzby.js → useFocusRing-BMOTWmOx.js} +1 -1
- package/dist/{useFocusable-Bu2Ovohk.js → useFocusable-ByyKSVQv.js} +2 -2
- package/dist/{useFormReset-fUHUaaR6.js → useFormReset-B8m1uz1J.js} +1 -1
- package/dist/{useFormValidationState-DAan_XbC.js → useFormValidationState-BjMhz_VI.js} +2 -2
- package/dist/{useLabel-Bk7iP__W.js → useLabel-B6uO0wVK.js} +2 -2
- package/dist/{useLabels-DmsOywGg.js → useLabels-5dFkeiXx.js} +1 -1
- package/dist/{useListState-GXSJsAgz.js → useListState-eKxv7HPC.js} +28 -16
- package/dist/{useLocalizedStringFormatter-m03yY3xi.js → useLocalizedStringFormatter-BaKmjFNp.js} +1 -1
- package/dist/{useMenuTrigger-CT2-BFLo.js → useMenuTrigger-4fwEmto8.js} +4 -4
- package/dist/{useNumberFieldState-CpmU88xz.js → useNumberField-DMMUTZ-h.js} +169 -169
- package/dist/{useNumberFormatter-B-20GQ2u.js → useNumberFormatter-Cyx5Dxkf.js} +1 -1
- package/dist/{usePress-Cs8K7gKw.js → usePress-D8nPoIQm.js} +22 -10
- package/dist/{useSingleSelectListState-C1ddMCq3.js → useSingleSelectListState-CABciySJ.js} +3 -2
- package/dist/{useToggle-Cn2nQUNS.js → useToggle-BmltE9Zr.js} +4 -4
- package/dist/{useToggleState-Dj0JhD9W.js → useToggleState-DZXLEnA_.js} +1 -1
- package/dist/{utils-Du2x3YVu.js → utils-BCJajCwh.js} +15 -7
- package/package.json +18 -18
- package/dist/Button-CYX0D6At.js +0 -55
- package/dist/LiveAnnouncer-D8h-3GrG.js +0 -63
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52, c as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, g as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "./utils-
|
|
2
|
-
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "./Label-
|
|
1
|
+
import { f as $8ae05eaa5c114e9c$export$7f54fc3180508a52, c as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, g as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a, $ as $64fa3d84918910a7$export$fabf2dc03a41866e } from "./utils-BCJajCwh.js";
|
|
2
|
+
import { a as $01b77f81d0f07f68$export$75b6ee27786ba447 } from "./Label-BwqMVkuV.js";
|
|
3
3
|
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "./filterDOMProps-EDDcM64A.js";
|
|
4
|
-
import React__default, { useRef, useMemo, useCallback,
|
|
5
|
-
import { $ as $a916eb452884faea$export$b7a616150fdb9f44 } from "./useNumberFormatter-
|
|
6
|
-
import {
|
|
7
|
-
import { $ as $9446cca9a3875146$export$
|
|
8
|
-
import { $ as $03deb23ff14920c4$export$4eaf04e54aa8eed6, a as $14c0b72509d70225$export$b0d6fa1ab32e3295, b as $14c0b72509d70225$export$16a4697467175487 } from "./textSelection-
|
|
9
|
-
import { $ as $d191a55c9702f145$export$8467354a121f1b9f } from "./useLabel-
|
|
10
|
-
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-
|
|
11
|
-
import { $ as $99facab73266f662$export$5add1d006293d136 } from "./useFormReset-
|
|
12
|
-
import { a as $46d819fcbaf35654$export$8f71654801c2f7cd, $ as $e6afbd83fe6ebbd2$export$4c014de7c8940b4c } from "./useFocusable-
|
|
13
|
-
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "./useFocusRing-
|
|
14
|
-
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "./VisuallyHidden-
|
|
4
|
+
import React__default, { useRef, useMemo, useCallback, useState, useEffect, createContext, forwardRef, useContext } from "react";
|
|
5
|
+
import { $ as $a916eb452884faea$export$b7a616150fdb9f44 } from "./useNumberFormatter-Cyx5Dxkf.js";
|
|
6
|
+
import { e as $458b0a5536c1a7cf$export$40bfa8c7b0832715, i as $507fabe10e71c6fb$export$8397ddfc504fdb9a, m as $7215afc6de606d6b$export$de79e2c695e052f3, $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "./focusSafely-CgFLw4FA.js";
|
|
7
|
+
import { $ as $9446cca9a3875146$export$cb6e0bb50bc19463, a as $9446cca9a3875146$export$7d15b64cf5a3a4c4 } from "./number-GajL10e1.js";
|
|
8
|
+
import { $ as $03deb23ff14920c4$export$4eaf04e54aa8eed6, a as $14c0b72509d70225$export$b0d6fa1ab32e3295, b as $14c0b72509d70225$export$16a4697467175487 } from "./textSelection-CvK0YHTZ.js";
|
|
9
|
+
import { $ as $d191a55c9702f145$export$8467354a121f1b9f } from "./useLabel-B6uO0wVK.js";
|
|
10
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "./context-Cs-ZD1nu.js";
|
|
11
|
+
import { $ as $99facab73266f662$export$5add1d006293d136 } from "./useFormReset-B8m1uz1J.js";
|
|
12
|
+
import { a as $46d819fcbaf35654$export$8f71654801c2f7cd, $ as $e6afbd83fe6ebbd2$export$4c014de7c8940b4c } from "./useFocusable-ByyKSVQv.js";
|
|
13
|
+
import { $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "./useFocusRing-BMOTWmOx.js";
|
|
14
|
+
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "./VisuallyHidden-WhC7vZaL.js";
|
|
15
15
|
function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
16
16
|
let { onMoveStart, onMove, onMoveEnd } = props;
|
|
17
17
|
let state = useRef({
|
|
@@ -219,6 +219,155 @@ function $e8a7022cf87cba2a$export$36da96379f79f245(props) {
|
|
|
219
219
|
moveProps
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
|
+
const $28f99e3e86e6ec45$var$DEFAULT_MIN_VALUE = 0;
|
|
223
|
+
const $28f99e3e86e6ec45$var$DEFAULT_MAX_VALUE = 100;
|
|
224
|
+
const $28f99e3e86e6ec45$var$DEFAULT_STEP_VALUE = 1;
|
|
225
|
+
function $28f99e3e86e6ec45$export$e5fda3247f5d67f9(props) {
|
|
226
|
+
const { isDisabled = false, minValue = $28f99e3e86e6ec45$var$DEFAULT_MIN_VALUE, maxValue = $28f99e3e86e6ec45$var$DEFAULT_MAX_VALUE, numberFormatter: formatter, step = $28f99e3e86e6ec45$var$DEFAULT_STEP_VALUE, orientation = "horizontal" } = props;
|
|
227
|
+
let pageSize = useMemo(() => {
|
|
228
|
+
let calcPageSize = (maxValue - minValue) / 10;
|
|
229
|
+
calcPageSize = $9446cca9a3875146$export$cb6e0bb50bc19463(calcPageSize, 0, calcPageSize + step, step);
|
|
230
|
+
return Math.max(calcPageSize, step);
|
|
231
|
+
}, [
|
|
232
|
+
step,
|
|
233
|
+
maxValue,
|
|
234
|
+
minValue
|
|
235
|
+
]);
|
|
236
|
+
let restrictValues = useCallback((values2) => values2 === null || values2 === void 0 ? void 0 : values2.map((val, idx) => {
|
|
237
|
+
let min = idx === 0 ? minValue : val[idx - 1];
|
|
238
|
+
let max = idx === values2.length - 1 ? maxValue : val[idx + 1];
|
|
239
|
+
return $9446cca9a3875146$export$cb6e0bb50bc19463(val, min, max, step);
|
|
240
|
+
}), [
|
|
241
|
+
minValue,
|
|
242
|
+
maxValue,
|
|
243
|
+
step
|
|
244
|
+
]);
|
|
245
|
+
let value = useMemo(() => restrictValues($28f99e3e86e6ec45$var$convertValue(props.value)), [
|
|
246
|
+
props.value
|
|
247
|
+
]);
|
|
248
|
+
let defaultValue = useMemo(() => {
|
|
249
|
+
var _convertValue;
|
|
250
|
+
return restrictValues((_convertValue = $28f99e3e86e6ec45$var$convertValue(props.defaultValue)) !== null && _convertValue !== void 0 ? _convertValue : [
|
|
251
|
+
minValue
|
|
252
|
+
]);
|
|
253
|
+
}, [
|
|
254
|
+
props.defaultValue,
|
|
255
|
+
minValue
|
|
256
|
+
]);
|
|
257
|
+
let onChange = $28f99e3e86e6ec45$var$createOnChange(props.value, props.defaultValue, props.onChange);
|
|
258
|
+
let onChangeEnd = $28f99e3e86e6ec45$var$createOnChange(props.value, props.defaultValue, props.onChangeEnd);
|
|
259
|
+
const [values, setValuesState] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange);
|
|
260
|
+
const [isDraggings, setDraggingsState] = useState(new Array(values.length).fill(false));
|
|
261
|
+
const isEditablesRef = useRef(new Array(values.length).fill(true));
|
|
262
|
+
const [focusedIndex, setFocusedIndex] = useState(void 0);
|
|
263
|
+
const valuesRef = useRef(values);
|
|
264
|
+
const isDraggingsRef = useRef(isDraggings);
|
|
265
|
+
let setValues = (values2) => {
|
|
266
|
+
valuesRef.current = values2;
|
|
267
|
+
setValuesState(values2);
|
|
268
|
+
};
|
|
269
|
+
let setDraggings = (draggings) => {
|
|
270
|
+
isDraggingsRef.current = draggings;
|
|
271
|
+
setDraggingsState(draggings);
|
|
272
|
+
};
|
|
273
|
+
function getValuePercent(value2) {
|
|
274
|
+
return (value2 - minValue) / (maxValue - minValue);
|
|
275
|
+
}
|
|
276
|
+
function getThumbMinValue(index) {
|
|
277
|
+
return index === 0 ? minValue : values[index - 1];
|
|
278
|
+
}
|
|
279
|
+
function getThumbMaxValue(index) {
|
|
280
|
+
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
281
|
+
}
|
|
282
|
+
function isThumbEditable(index) {
|
|
283
|
+
return isEditablesRef.current[index];
|
|
284
|
+
}
|
|
285
|
+
function setThumbEditable(index, editable) {
|
|
286
|
+
isEditablesRef.current[index] = editable;
|
|
287
|
+
}
|
|
288
|
+
function updateValue(index, value2) {
|
|
289
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
290
|
+
const thisMin = getThumbMinValue(index);
|
|
291
|
+
const thisMax = getThumbMaxValue(index);
|
|
292
|
+
value2 = $9446cca9a3875146$export$cb6e0bb50bc19463(value2, thisMin, thisMax, step);
|
|
293
|
+
let newValues = $28f99e3e86e6ec45$var$replaceIndex(valuesRef.current, index, value2);
|
|
294
|
+
setValues(newValues);
|
|
295
|
+
}
|
|
296
|
+
function updateDragging(index, dragging) {
|
|
297
|
+
if (isDisabled || !isThumbEditable(index)) return;
|
|
298
|
+
if (dragging) valuesRef.current = values;
|
|
299
|
+
const wasDragging = isDraggingsRef.current[index];
|
|
300
|
+
isDraggingsRef.current = $28f99e3e86e6ec45$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
301
|
+
setDraggings(isDraggingsRef.current);
|
|
302
|
+
if (onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) onChangeEnd(valuesRef.current);
|
|
303
|
+
}
|
|
304
|
+
function getFormattedValue(value2) {
|
|
305
|
+
return formatter.format(value2);
|
|
306
|
+
}
|
|
307
|
+
function setThumbPercent(index, percent) {
|
|
308
|
+
updateValue(index, getPercentValue(percent));
|
|
309
|
+
}
|
|
310
|
+
function getRoundedValue(value2) {
|
|
311
|
+
return Math.round((value2 - minValue) / step) * step + minValue;
|
|
312
|
+
}
|
|
313
|
+
function getPercentValue(percent) {
|
|
314
|
+
const val = percent * (maxValue - minValue) + minValue;
|
|
315
|
+
return $9446cca9a3875146$export$7d15b64cf5a3a4c4(getRoundedValue(val), minValue, maxValue);
|
|
316
|
+
}
|
|
317
|
+
function incrementThumb(index, stepSize = 1) {
|
|
318
|
+
let s = Math.max(stepSize, step);
|
|
319
|
+
updateValue(index, $9446cca9a3875146$export$cb6e0bb50bc19463(values[index] + s, minValue, maxValue, step));
|
|
320
|
+
}
|
|
321
|
+
function decrementThumb(index, stepSize = 1) {
|
|
322
|
+
let s = Math.max(stepSize, step);
|
|
323
|
+
updateValue(index, $9446cca9a3875146$export$cb6e0bb50bc19463(values[index] - s, minValue, maxValue, step));
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
values,
|
|
327
|
+
getThumbValue: (index) => values[index],
|
|
328
|
+
setThumbValue: updateValue,
|
|
329
|
+
setThumbPercent,
|
|
330
|
+
isThumbDragging: (index) => isDraggings[index],
|
|
331
|
+
setThumbDragging: updateDragging,
|
|
332
|
+
focusedThumb: focusedIndex,
|
|
333
|
+
setFocusedThumb: setFocusedIndex,
|
|
334
|
+
getThumbPercent: (index) => getValuePercent(values[index]),
|
|
335
|
+
getValuePercent,
|
|
336
|
+
getThumbValueLabel: (index) => getFormattedValue(values[index]),
|
|
337
|
+
getFormattedValue,
|
|
338
|
+
getThumbMinValue,
|
|
339
|
+
getThumbMaxValue,
|
|
340
|
+
getPercentValue,
|
|
341
|
+
isThumbEditable,
|
|
342
|
+
setThumbEditable,
|
|
343
|
+
incrementThumb,
|
|
344
|
+
decrementThumb,
|
|
345
|
+
step,
|
|
346
|
+
pageSize,
|
|
347
|
+
orientation,
|
|
348
|
+
isDisabled
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
function $28f99e3e86e6ec45$var$replaceIndex(array, index, value) {
|
|
352
|
+
if (array[index] === value) return array;
|
|
353
|
+
return [
|
|
354
|
+
...array.slice(0, index),
|
|
355
|
+
value,
|
|
356
|
+
...array.slice(index + 1)
|
|
357
|
+
];
|
|
358
|
+
}
|
|
359
|
+
function $28f99e3e86e6ec45$var$convertValue(value) {
|
|
360
|
+
if (value == null) return void 0;
|
|
361
|
+
return Array.isArray(value) ? value : [
|
|
362
|
+
value
|
|
363
|
+
];
|
|
364
|
+
}
|
|
365
|
+
function $28f99e3e86e6ec45$var$createOnChange(value, defaultValue, onChange) {
|
|
366
|
+
return (newValue) => {
|
|
367
|
+
if (typeof value === "number" || typeof defaultValue === "number") onChange === null || onChange === void 0 ? void 0 : onChange(newValue[0]);
|
|
368
|
+
else onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
222
371
|
const $aa519ee6cf463259$export$d6c8d9636a3dc49c = /* @__PURE__ */ new WeakMap();
|
|
223
372
|
function $aa519ee6cf463259$export$68e648cbec363a18(state, index) {
|
|
224
373
|
let data = $aa519ee6cf463259$export$d6c8d9636a3dc49c.get(state);
|
|
@@ -514,155 +663,6 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
514
663
|
isFocused
|
|
515
664
|
};
|
|
516
665
|
}
|
|
517
|
-
const $28f99e3e86e6ec45$var$DEFAULT_MIN_VALUE = 0;
|
|
518
|
-
const $28f99e3e86e6ec45$var$DEFAULT_MAX_VALUE = 100;
|
|
519
|
-
const $28f99e3e86e6ec45$var$DEFAULT_STEP_VALUE = 1;
|
|
520
|
-
function $28f99e3e86e6ec45$export$e5fda3247f5d67f9(props) {
|
|
521
|
-
const { isDisabled = false, minValue = $28f99e3e86e6ec45$var$DEFAULT_MIN_VALUE, maxValue = $28f99e3e86e6ec45$var$DEFAULT_MAX_VALUE, numberFormatter: formatter, step = $28f99e3e86e6ec45$var$DEFAULT_STEP_VALUE, orientation = "horizontal" } = props;
|
|
522
|
-
let pageSize = useMemo(() => {
|
|
523
|
-
let calcPageSize = (maxValue - minValue) / 10;
|
|
524
|
-
calcPageSize = $9446cca9a3875146$export$cb6e0bb50bc19463(calcPageSize, 0, calcPageSize + step, step);
|
|
525
|
-
return Math.max(calcPageSize, step);
|
|
526
|
-
}, [
|
|
527
|
-
step,
|
|
528
|
-
maxValue,
|
|
529
|
-
minValue
|
|
530
|
-
]);
|
|
531
|
-
let restrictValues = useCallback((values2) => values2 === null || values2 === void 0 ? void 0 : values2.map((val, idx) => {
|
|
532
|
-
let min = idx === 0 ? minValue : val[idx - 1];
|
|
533
|
-
let max = idx === values2.length - 1 ? maxValue : val[idx + 1];
|
|
534
|
-
return $9446cca9a3875146$export$cb6e0bb50bc19463(val, min, max, step);
|
|
535
|
-
}), [
|
|
536
|
-
minValue,
|
|
537
|
-
maxValue,
|
|
538
|
-
step
|
|
539
|
-
]);
|
|
540
|
-
let value = useMemo(() => restrictValues($28f99e3e86e6ec45$var$convertValue(props.value)), [
|
|
541
|
-
props.value
|
|
542
|
-
]);
|
|
543
|
-
let defaultValue = useMemo(() => {
|
|
544
|
-
var _convertValue;
|
|
545
|
-
return restrictValues((_convertValue = $28f99e3e86e6ec45$var$convertValue(props.defaultValue)) !== null && _convertValue !== void 0 ? _convertValue : [
|
|
546
|
-
minValue
|
|
547
|
-
]);
|
|
548
|
-
}, [
|
|
549
|
-
props.defaultValue,
|
|
550
|
-
minValue
|
|
551
|
-
]);
|
|
552
|
-
let onChange = $28f99e3e86e6ec45$var$createOnChange(props.value, props.defaultValue, props.onChange);
|
|
553
|
-
let onChangeEnd = $28f99e3e86e6ec45$var$createOnChange(props.value, props.defaultValue, props.onChangeEnd);
|
|
554
|
-
const [values, setValuesState] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange);
|
|
555
|
-
const [isDraggings, setDraggingsState] = useState(new Array(values.length).fill(false));
|
|
556
|
-
const isEditablesRef = useRef(new Array(values.length).fill(true));
|
|
557
|
-
const [focusedIndex, setFocusedIndex] = useState(void 0);
|
|
558
|
-
const valuesRef = useRef(values);
|
|
559
|
-
const isDraggingsRef = useRef(isDraggings);
|
|
560
|
-
let setValues = (values2) => {
|
|
561
|
-
valuesRef.current = values2;
|
|
562
|
-
setValuesState(values2);
|
|
563
|
-
};
|
|
564
|
-
let setDraggings = (draggings) => {
|
|
565
|
-
isDraggingsRef.current = draggings;
|
|
566
|
-
setDraggingsState(draggings);
|
|
567
|
-
};
|
|
568
|
-
function getValuePercent(value2) {
|
|
569
|
-
return (value2 - minValue) / (maxValue - minValue);
|
|
570
|
-
}
|
|
571
|
-
function getThumbMinValue(index) {
|
|
572
|
-
return index === 0 ? minValue : values[index - 1];
|
|
573
|
-
}
|
|
574
|
-
function getThumbMaxValue(index) {
|
|
575
|
-
return index === values.length - 1 ? maxValue : values[index + 1];
|
|
576
|
-
}
|
|
577
|
-
function isThumbEditable(index) {
|
|
578
|
-
return isEditablesRef.current[index];
|
|
579
|
-
}
|
|
580
|
-
function setThumbEditable(index, editable) {
|
|
581
|
-
isEditablesRef.current[index] = editable;
|
|
582
|
-
}
|
|
583
|
-
function updateValue(index, value2) {
|
|
584
|
-
if (isDisabled || !isThumbEditable(index)) return;
|
|
585
|
-
const thisMin = getThumbMinValue(index);
|
|
586
|
-
const thisMax = getThumbMaxValue(index);
|
|
587
|
-
value2 = $9446cca9a3875146$export$cb6e0bb50bc19463(value2, thisMin, thisMax, step);
|
|
588
|
-
let newValues = $28f99e3e86e6ec45$var$replaceIndex(valuesRef.current, index, value2);
|
|
589
|
-
setValues(newValues);
|
|
590
|
-
}
|
|
591
|
-
function updateDragging(index, dragging) {
|
|
592
|
-
if (isDisabled || !isThumbEditable(index)) return;
|
|
593
|
-
if (dragging) valuesRef.current = values;
|
|
594
|
-
const wasDragging = isDraggingsRef.current[index];
|
|
595
|
-
isDraggingsRef.current = $28f99e3e86e6ec45$var$replaceIndex(isDraggingsRef.current, index, dragging);
|
|
596
|
-
setDraggings(isDraggingsRef.current);
|
|
597
|
-
if (onChangeEnd && wasDragging && !isDraggingsRef.current.some(Boolean)) onChangeEnd(valuesRef.current);
|
|
598
|
-
}
|
|
599
|
-
function getFormattedValue(value2) {
|
|
600
|
-
return formatter.format(value2);
|
|
601
|
-
}
|
|
602
|
-
function setThumbPercent(index, percent) {
|
|
603
|
-
updateValue(index, getPercentValue(percent));
|
|
604
|
-
}
|
|
605
|
-
function getRoundedValue(value2) {
|
|
606
|
-
return Math.round((value2 - minValue) / step) * step + minValue;
|
|
607
|
-
}
|
|
608
|
-
function getPercentValue(percent) {
|
|
609
|
-
const val = percent * (maxValue - minValue) + minValue;
|
|
610
|
-
return $9446cca9a3875146$export$7d15b64cf5a3a4c4(getRoundedValue(val), minValue, maxValue);
|
|
611
|
-
}
|
|
612
|
-
function incrementThumb(index, stepSize = 1) {
|
|
613
|
-
let s = Math.max(stepSize, step);
|
|
614
|
-
updateValue(index, $9446cca9a3875146$export$cb6e0bb50bc19463(values[index] + s, minValue, maxValue, step));
|
|
615
|
-
}
|
|
616
|
-
function decrementThumb(index, stepSize = 1) {
|
|
617
|
-
let s = Math.max(stepSize, step);
|
|
618
|
-
updateValue(index, $9446cca9a3875146$export$cb6e0bb50bc19463(values[index] - s, minValue, maxValue, step));
|
|
619
|
-
}
|
|
620
|
-
return {
|
|
621
|
-
values,
|
|
622
|
-
getThumbValue: (index) => values[index],
|
|
623
|
-
setThumbValue: updateValue,
|
|
624
|
-
setThumbPercent,
|
|
625
|
-
isThumbDragging: (index) => isDraggings[index],
|
|
626
|
-
setThumbDragging: updateDragging,
|
|
627
|
-
focusedThumb: focusedIndex,
|
|
628
|
-
setFocusedThumb: setFocusedIndex,
|
|
629
|
-
getThumbPercent: (index) => getValuePercent(values[index]),
|
|
630
|
-
getValuePercent,
|
|
631
|
-
getThumbValueLabel: (index) => getFormattedValue(values[index]),
|
|
632
|
-
getFormattedValue,
|
|
633
|
-
getThumbMinValue,
|
|
634
|
-
getThumbMaxValue,
|
|
635
|
-
getPercentValue,
|
|
636
|
-
isThumbEditable,
|
|
637
|
-
setThumbEditable,
|
|
638
|
-
incrementThumb,
|
|
639
|
-
decrementThumb,
|
|
640
|
-
step,
|
|
641
|
-
pageSize,
|
|
642
|
-
orientation,
|
|
643
|
-
isDisabled
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
function $28f99e3e86e6ec45$var$replaceIndex(array, index, value) {
|
|
647
|
-
if (array[index] === value) return array;
|
|
648
|
-
return [
|
|
649
|
-
...array.slice(0, index),
|
|
650
|
-
value,
|
|
651
|
-
...array.slice(index + 1)
|
|
652
|
-
];
|
|
653
|
-
}
|
|
654
|
-
function $28f99e3e86e6ec45$var$convertValue(value) {
|
|
655
|
-
if (value == null) return void 0;
|
|
656
|
-
return Array.isArray(value) ? value : [
|
|
657
|
-
value
|
|
658
|
-
];
|
|
659
|
-
}
|
|
660
|
-
function $28f99e3e86e6ec45$var$createOnChange(value, defaultValue, onChange) {
|
|
661
|
-
return (newValue) => {
|
|
662
|
-
if (typeof value === "number" || typeof defaultValue === "number") onChange === null || onChange === void 0 ? void 0 : onChange(newValue[0]);
|
|
663
|
-
else onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
666
|
const $6f909507e6374d18$export$e99164f0030f3bff = /* @__PURE__ */ createContext(null);
|
|
667
667
|
const $6f909507e6374d18$export$1e7083018727fa60 = /* @__PURE__ */ createContext(null);
|
|
668
668
|
const $6f909507e6374d18$export$f1fce0420cc6d8ee = /* @__PURE__ */ createContext(null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415 } from "./utils-
|
|
1
|
+
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415 } from "./utils-BCJajCwh.js";
|
|
2
2
|
import React__default, { forwardRef, createContext } from "react";
|
|
3
3
|
const $514c0188e459b4c0$export$9afb8bc826b033ea = /* @__PURE__ */ createContext({});
|
|
4
4
|
function $514c0188e459b4c0$var$Text(props, ref) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./utils-
|
|
1
|
+
import { c as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "./utils-BCJajCwh.js";
|
|
2
2
|
import React__default, { useState, useMemo } from "react";
|
|
3
|
-
import { d as $9ab94262bd0047c7$export$420e68273165f4ec } from "./focusSafely-
|
|
3
|
+
import { d as $9ab94262bd0047c7$export$420e68273165f4ec } from "./focusSafely-CgFLw4FA.js";
|
|
4
4
|
const $5c3e21d68f1c4674$var$styles = {
|
|
5
5
|
border: 0,
|
|
6
6
|
clip: "rect(0 0 0 0)",
|