@seeqdev/qomponents 0.0.110 → 0.0.112
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/InputGroup/InputGroup.types.d.ts +19 -4
- package/dist/Slider/Slider.d.ts +6 -6
- package/dist/Slider/Slider.stories.d.ts +5 -5
- package/dist/Slider/Slider.test.d.ts +1 -1
- package/dist/Slider/Slider.types.d.ts +16 -13
- package/dist/Slider/index.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +975 -43
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +974 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +75 -10
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1097,7 +1097,7 @@ const oppositeAlignmentMap = {
|
|
|
1097
1097
|
start: 'end',
|
|
1098
1098
|
end: 'start'
|
|
1099
1099
|
};
|
|
1100
|
-
function clamp(start, value, end) {
|
|
1100
|
+
function clamp$1(start, value, end) {
|
|
1101
1101
|
return max$1(start, min$1(value, end));
|
|
1102
1102
|
}
|
|
1103
1103
|
function evaluate(value, param) {
|
|
@@ -1470,7 +1470,7 @@ const arrow$1 = options => ({
|
|
|
1470
1470
|
const min$1$1 = minPadding;
|
|
1471
1471
|
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1472
1472
|
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1473
|
-
const offset = clamp(min$1$1, center, max);
|
|
1473
|
+
const offset = clamp$1(min$1$1, center, max);
|
|
1474
1474
|
|
|
1475
1475
|
// If the reference is small enough that the arrow's padding causes it to
|
|
1476
1476
|
// to point to nothing for an aligned placement, adjust the offset of the
|
|
@@ -1810,14 +1810,14 @@ const shift = function (options) {
|
|
|
1810
1810
|
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1811
1811
|
const min = mainAxisCoord + overflow[minSide];
|
|
1812
1812
|
const max = mainAxisCoord - overflow[maxSide];
|
|
1813
|
-
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
1813
|
+
mainAxisCoord = clamp$1(min, mainAxisCoord, max);
|
|
1814
1814
|
}
|
|
1815
1815
|
if (checkCrossAxis) {
|
|
1816
1816
|
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1817
1817
|
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1818
1818
|
const min = crossAxisCoord + overflow[minSide];
|
|
1819
1819
|
const max = crossAxisCoord - overflow[maxSide];
|
|
1820
|
-
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
1820
|
+
crossAxisCoord = clamp$1(min, crossAxisCoord, max);
|
|
1821
1821
|
}
|
|
1822
1822
|
const limitedCoords = limiter.fn({
|
|
1823
1823
|
...state,
|
|
@@ -3708,7 +3708,7 @@ function assignRef(ref, value) {
|
|
|
3708
3708
|
* @see https://github.com/theKashey/use-callback-ref#usecallbackref---to-replace-reactuseref
|
|
3709
3709
|
* @returns {MutableRefObject}
|
|
3710
3710
|
*/
|
|
3711
|
-
function useCallbackRef(initialValue, callback) {
|
|
3711
|
+
function useCallbackRef$1(initialValue, callback) {
|
|
3712
3712
|
var ref = React.useState(function () { return ({
|
|
3713
3713
|
// value
|
|
3714
3714
|
value: initialValue,
|
|
@@ -3749,7 +3749,7 @@ var currentValues = new WeakMap();
|
|
|
3749
3749
|
* }
|
|
3750
3750
|
*/
|
|
3751
3751
|
function useMergeRefs(refs, defaultValue) {
|
|
3752
|
-
var callbackRef = useCallbackRef(defaultValue || null, function (newValue) {
|
|
3752
|
+
var callbackRef = useCallbackRef$1(defaultValue || null, function (newValue) {
|
|
3753
3753
|
return refs.forEach(function (ref) { return assignRef(ref, newValue); });
|
|
3754
3754
|
});
|
|
3755
3755
|
// handle refs changes - added or removed
|
|
@@ -4643,8 +4643,8 @@ const setValidInputDimension = (width, height) => {
|
|
|
4643
4643
|
return inputStyle;
|
|
4644
4644
|
};
|
|
4645
4645
|
|
|
4646
|
-
const errorClasses$
|
|
4647
|
-
const borderColorClasses$
|
|
4646
|
+
const errorClasses$4 = 'tw-border-sq-danger-color';
|
|
4647
|
+
const borderColorClasses$4 = [
|
|
4648
4648
|
'tw-border-sq-disabled-gray',
|
|
4649
4649
|
'dark:tw-border-sq-dark-disabled-gray',
|
|
4650
4650
|
'dark:focus:tw-border-sq-color-dark-dark',
|
|
@@ -4656,8 +4656,8 @@ const baseClasses$5 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-
|
|
|
4656
4656
|
' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
|
|
4657
4657
|
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
|
|
4658
4658
|
' dark:tw-placeholder-sq-dark-text-lighter specTextField';
|
|
4659
|
-
const darkTheme$
|
|
4660
|
-
const lightTheme$
|
|
4659
|
+
const darkTheme$3 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
|
|
4660
|
+
const lightTheme$3 = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
|
|
4661
4661
|
const sizeClasses = {
|
|
4662
4662
|
sm: 'tw-text-sm',
|
|
4663
4663
|
lg: 'tw-text-xl',
|
|
@@ -4702,7 +4702,7 @@ const TextField = React.forwardRef((props, ref) => {
|
|
|
4702
4702
|
else if (inputGroup === 'right') {
|
|
4703
4703
|
borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
|
|
4704
4704
|
}
|
|
4705
|
-
const appliedClasses = `${baseClasses$5} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$
|
|
4705
|
+
const appliedClasses = `${baseClasses$5} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$3} ${darkTheme$3} ${borderRadius} ${showError ? errorClasses$4 : borderColorClasses$4} `;
|
|
4706
4706
|
const inputProp = setValidInputDimension(inputWidth, inputHeight)
|
|
4707
4707
|
? {
|
|
4708
4708
|
style: setValidInputDimension(inputWidth, inputHeight),
|
|
@@ -4744,11 +4744,11 @@ const Checkbox = (props) => {
|
|
|
4744
4744
|
const baseClasses$3 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm tw-w-full' +
|
|
4745
4745
|
' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
|
|
4746
4746
|
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
|
|
4747
|
-
const darkTheme$
|
|
4747
|
+
const darkTheme$2 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
|
|
4748
4748
|
'dark:tw-placeholder-sq-dark-text-lighter disabled:dark:tw-text-sq-dark-text-lighter';
|
|
4749
|
-
const lightTheme$
|
|
4750
|
-
const errorClasses$
|
|
4751
|
-
const borderColorClasses$
|
|
4749
|
+
const lightTheme$2 = 'tw-text-sq-text-color tw-placeholder-gray-400 disabled:tw-text-sq-darkish-gray';
|
|
4750
|
+
const errorClasses$3 = 'tw-border-sq-danger-color';
|
|
4751
|
+
const borderColorClasses$3 = [
|
|
4752
4752
|
'tw-border-sq-disabled-gray',
|
|
4753
4753
|
'dark:tw-border-sq-dark-disabled-gray',
|
|
4754
4754
|
'dark:focus:tw-border-sq-color-dark-dark',
|
|
@@ -4760,7 +4760,7 @@ const borderColorClasses$2 = [
|
|
|
4760
4760
|
* TextArea.
|
|
4761
4761
|
*/
|
|
4762
4762
|
const TextArea = ({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
|
|
4763
|
-
const appliedClasses = `${baseClasses$3} ${extraClassNames} ${lightTheme$
|
|
4763
|
+
const appliedClasses = `${baseClasses$3} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${showError ? errorClasses$3 : borderColorClasses$3}`;
|
|
4764
4764
|
return (React.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
|
|
4765
4765
|
};
|
|
4766
4766
|
|
|
@@ -11593,7 +11593,7 @@ var colors = {
|
|
|
11593
11593
|
neutral80: 'hsl(0, 0%, 20%)',
|
|
11594
11594
|
neutral90: 'hsl(0, 0%, 10%)'
|
|
11595
11595
|
};
|
|
11596
|
-
var borderRadius = 4;
|
|
11596
|
+
var borderRadius$1 = 4;
|
|
11597
11597
|
// Used to calculate consistent margin/padding on elements
|
|
11598
11598
|
var baseUnit = 4;
|
|
11599
11599
|
// The minimum height of the control
|
|
@@ -11606,7 +11606,7 @@ var spacing = {
|
|
|
11606
11606
|
menuGutter: menuGutter
|
|
11607
11607
|
};
|
|
11608
11608
|
var defaultTheme = {
|
|
11609
|
-
borderRadius: borderRadius,
|
|
11609
|
+
borderRadius: borderRadius$1,
|
|
11610
11610
|
colors: colors,
|
|
11611
11611
|
spacing: spacing
|
|
11612
11612
|
};
|
|
@@ -13339,8 +13339,8 @@ var CreatableSelect$1 = CreatableSelect;
|
|
|
13339
13339
|
|
|
13340
13340
|
const baseClasses$2 = ['focus:tw-ring-0', 'disabled:tw-cursor-not-allowed'].join(' ');
|
|
13341
13341
|
const containerStyles = ['tw-bg-white', 'dark:tw-bg-sq-dark-background'].join(' ');
|
|
13342
|
-
const errorClasses$
|
|
13343
|
-
const borderColorClasses$
|
|
13342
|
+
const errorClasses$2 = 'tw-border-sq-danger-color';
|
|
13343
|
+
const borderColorClasses$2 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
|
|
13344
13344
|
const borderStyles$3 = [
|
|
13345
13345
|
'tw-border-solid',
|
|
13346
13346
|
'tw-border',
|
|
@@ -13478,7 +13478,7 @@ const Select = ({ options, value, placeholder = 'select', noOptionsMessage = 'no
|
|
|
13478
13478
|
else if (inputGroup === 'right') {
|
|
13479
13479
|
border = menuIsOpen ? 'tw-rounded-tr-sm' : 'tw-rounded-r-sm';
|
|
13480
13480
|
}
|
|
13481
|
-
const appliedClasses = `${borderStyles$3} ${border} ${showError ? errorClasses$
|
|
13481
|
+
const appliedClasses = `${borderStyles$3} ${border} ${showError ? errorClasses$2 : borderColorClasses$2} ${small ? 'reactSelectMinHeightSmall' : 'reactSelectMinHeight'} `;
|
|
13482
13482
|
return `${appliedClasses} ${baseClasses$2} specSelectControl ${isDisabled ? disabledClasses$3 : ''} ${small ? 'tw-pl-2 tw-pr-1' : 'tw-pl-2.5 tw-pr-1.5'}`;
|
|
13483
13483
|
},
|
|
13484
13484
|
placeholder: () => placeholderStyles,
|
|
@@ -15851,22 +15851,22 @@ const ButtonWithDropdown = ({ dropdownItems, triggerIcon, id, extraClassNames, c
|
|
|
15851
15851
|
|
|
15852
15852
|
const baseClasses$1 = 'tw-mx-auto tw-p-4 tw-leading-normal tw-outline-none tw-py-2 tw-px-3 tw-rounded-sm tw-w-full' +
|
|
15853
15853
|
' tw-border-solid tw-border tw-text-sm tw-flex tw-flex-col tw-justify-center tw-items-center';
|
|
15854
|
-
const darkTheme = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
|
|
15855
|
-
const lightTheme = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
|
|
15856
|
-
const errorClasses = 'tw-border-sq-danger-color';
|
|
15857
|
-
const borderColorClasses = 'tw-border-sq-color-dark';
|
|
15854
|
+
const darkTheme$1 = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
|
|
15855
|
+
const lightTheme$1 = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
|
|
15856
|
+
const errorClasses$1 = 'tw-border-sq-danger-color';
|
|
15857
|
+
const borderColorClasses$1 = 'tw-border-sq-color-dark';
|
|
15858
15858
|
/**
|
|
15859
15859
|
* Alert.
|
|
15860
15860
|
*/
|
|
15861
15861
|
const Alert = ({ children, dismissible = true, onClose, show = true, variant, testId, id, extraClassNames, }) => {
|
|
15862
15862
|
const appliedTheme = {
|
|
15863
|
-
theme: `${lightTheme} ${darkTheme}`,
|
|
15863
|
+
theme: `${lightTheme$1} ${darkTheme$1}`,
|
|
15864
15864
|
danger: 'tw-text-sq-text-color tw-bg-sq-danger-color',
|
|
15865
15865
|
warning: 'tw-bg-sq-bg-warning-color tw-text-sq-text-color',
|
|
15866
15866
|
};
|
|
15867
15867
|
const appliedBorderTheme = {
|
|
15868
|
-
theme: borderColorClasses,
|
|
15869
|
-
danger: errorClasses,
|
|
15868
|
+
theme: borderColorClasses$1,
|
|
15869
|
+
danger: errorClasses$1,
|
|
15870
15870
|
warning: 'tw-border-none',
|
|
15871
15871
|
};
|
|
15872
15872
|
const appliedClasses = `${baseClasses$1} ${appliedTheme[variant]} ${extraClassNames} ${appliedBorderTheme[variant]}`;
|
|
@@ -15942,25 +15942,957 @@ const SeeqActionDropdown = ({ seeqActionDropdownItems, trigger, id, extraClassNa
|
|
|
15942
15942
|
})))));
|
|
15943
15943
|
};
|
|
15944
15944
|
|
|
15945
|
-
const baseClasses = 'tw-flex tw-outline-none tw-rounded-sm tw-w-full tw-relative tw-flex-wrap
|
|
15945
|
+
const baseClasses = 'tw-flex tw-outline-none tw-rounded-sm tw-w-full tw-relative tw-flex-wrap';
|
|
15946
|
+
const errorClasses = 'tw-border-sq-danger-color';
|
|
15947
|
+
const borderColorClasses = [
|
|
15948
|
+
'tw-border-sq-disabled-gray',
|
|
15949
|
+
'dark:tw-border-sq-dark-disabled-gray',
|
|
15950
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
15951
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
15952
|
+
'focus:tw-border-sq-color-dark',
|
|
15953
|
+
'active:tw-border-sq-color-dark',
|
|
15954
|
+
].join(' ');
|
|
15955
|
+
let borderRadius = 'tw-rounded-sm tw-rounded-r-none';
|
|
15956
|
+
const fieldClasses = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3' + 'tw-p-1 tw-border-solid tw-border';
|
|
15957
|
+
const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
|
|
15958
|
+
const lightTheme = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
|
|
15946
15959
|
/**
|
|
15947
15960
|
* InputGroup.
|
|
15948
15961
|
*/
|
|
15949
|
-
const InputGroup = ({ readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown,
|
|
15962
|
+
const InputGroup = ({ readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, name, value, placeholder, append = [], extraClassNames = '', id, testId, showError, required, autoComplete, autoFocus, disabled, type, step, min, max, field, ...tooltipProps }) => {
|
|
15950
15963
|
const tooltipData = getQTipData(tooltipProps);
|
|
15951
15964
|
const appliedClasses = `${baseClasses} ${extraClassNames}`;
|
|
15952
|
-
const
|
|
15953
|
-
'tw-border-sq-disabled-gray',
|
|
15954
|
-
'dark:tw-border-sq-dark-disabled-gray',
|
|
15955
|
-
'dark:focus:tw-border-sq-color-dark-dark',
|
|
15956
|
-
'dark:active:tw-border-sq-color-dark-dark',
|
|
15957
|
-
'focus:tw-border-sq-color-dark',
|
|
15958
|
-
'active:tw-border-sq-color-dark',
|
|
15959
|
-
].join(' ');
|
|
15960
|
-
const textfield = (React.createElement(TextField, { readonly: onClick ? true : readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, extraClassNames: `tw-flex tw-flex-1 tw-rounded-r-none focus:tw-z-30 ${onClick ? 'tw-cursor-pointer' : ''} ${extraClassNames}`, ...tooltipData }));
|
|
15965
|
+
const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
|
|
15961
15966
|
return (React.createElement("div", { id: id, "data-testid": testId, className: appliedClasses },
|
|
15962
|
-
|
|
15963
|
-
append.filter(Boolean).map((item, index) => item.variant === 'button' ? (React.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", onClick: item.buttonProps.onClick, variant: item.buttonProps.variant, icon: item.buttonProps.icon, iconColor: item.buttonProps.iconColor, testId: item.buttonProps.testId, disabled: item.buttonProps.disabled, label: item.buttonProps.label, iconStyle: item.buttonProps.iconStyle })) : (React.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-
|
|
15967
|
+
field ? (React.createElement("div", { className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}` }, field)) : (React.createElement(TextField, { readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, extraClassNames: `tw-flex tw-flex-1 tw-w-full tw-rounded-r-none focus:tw-z-30 ${extraClassNames}`, ...tooltipData })),
|
|
15968
|
+
append.filter(Boolean).map((item, index) => item.variant === 'button' ? (React.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", onClick: item.buttonProps.onClick, variant: item.buttonProps.variant, icon: item.buttonProps.icon, iconColor: item.buttonProps.iconColor, testId: item.buttonProps.testId, disabled: item.buttonProps.disabled, label: item.buttonProps.label, iconStyle: item.buttonProps.iconStyle })) : (React.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-justify-center tw-rounded-none tw-ml-[-1px] active:tw-z-30 active:tw-border tw-border last:tw-rounded-r-sm` }, item.element)))));
|
|
15969
|
+
};
|
|
15970
|
+
|
|
15971
|
+
// packages/core/number/src/number.ts
|
|
15972
|
+
function clamp(value, [min, max]) {
|
|
15973
|
+
return Math.min(max, Math.max(min, value));
|
|
15974
|
+
}
|
|
15975
|
+
|
|
15976
|
+
// packages/core/primitive/src/primitive.tsx
|
|
15977
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
15978
|
+
return function handleEvent(event) {
|
|
15979
|
+
originalEventHandler?.(event);
|
|
15980
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
15981
|
+
return ourEventHandler?.(event);
|
|
15982
|
+
}
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
|
|
15986
|
+
// packages/react/compose-refs/src/composeRefs.tsx
|
|
15987
|
+
function setRef$1(ref, value) {
|
|
15988
|
+
if (typeof ref === "function") {
|
|
15989
|
+
return ref(value);
|
|
15990
|
+
} else if (ref !== null && ref !== void 0) {
|
|
15991
|
+
ref.current = value;
|
|
15992
|
+
}
|
|
15993
|
+
}
|
|
15994
|
+
function composeRefs$1(...refs) {
|
|
15995
|
+
return (node) => {
|
|
15996
|
+
let hasCleanup = false;
|
|
15997
|
+
const cleanups = refs.map((ref) => {
|
|
15998
|
+
const cleanup = setRef$1(ref, node);
|
|
15999
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
16000
|
+
hasCleanup = true;
|
|
16001
|
+
}
|
|
16002
|
+
return cleanup;
|
|
16003
|
+
});
|
|
16004
|
+
if (hasCleanup) {
|
|
16005
|
+
return () => {
|
|
16006
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
16007
|
+
const cleanup = cleanups[i];
|
|
16008
|
+
if (typeof cleanup == "function") {
|
|
16009
|
+
cleanup();
|
|
16010
|
+
} else {
|
|
16011
|
+
setRef$1(refs[i], null);
|
|
16012
|
+
}
|
|
16013
|
+
}
|
|
16014
|
+
};
|
|
16015
|
+
}
|
|
16016
|
+
};
|
|
16017
|
+
}
|
|
16018
|
+
function useComposedRefs(...refs) {
|
|
16019
|
+
return React__namespace.useCallback(composeRefs$1(...refs), refs);
|
|
16020
|
+
}
|
|
16021
|
+
|
|
16022
|
+
// packages/react/context/src/createContext.tsx
|
|
16023
|
+
function createContextScope$1(scopeName, createContextScopeDeps = []) {
|
|
16024
|
+
let defaultContexts = [];
|
|
16025
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
16026
|
+
const BaseContext = React__namespace.createContext(defaultContext);
|
|
16027
|
+
const index = defaultContexts.length;
|
|
16028
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
16029
|
+
const Provider = (props) => {
|
|
16030
|
+
const { scope, children, ...context } = props;
|
|
16031
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
16032
|
+
const value = React__namespace.useMemo(() => context, Object.values(context));
|
|
16033
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value, children });
|
|
16034
|
+
};
|
|
16035
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
16036
|
+
function useContext2(consumerName, scope) {
|
|
16037
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
16038
|
+
const context = React__namespace.useContext(Context);
|
|
16039
|
+
if (context) return context;
|
|
16040
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
16041
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
16042
|
+
}
|
|
16043
|
+
return [Provider, useContext2];
|
|
16044
|
+
}
|
|
16045
|
+
const createScope = () => {
|
|
16046
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
16047
|
+
return React__namespace.createContext(defaultContext);
|
|
16048
|
+
});
|
|
16049
|
+
return function useScope(scope) {
|
|
16050
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
16051
|
+
return React__namespace.useMemo(
|
|
16052
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
16053
|
+
[scope, contexts]
|
|
16054
|
+
);
|
|
16055
|
+
};
|
|
16056
|
+
};
|
|
16057
|
+
createScope.scopeName = scopeName;
|
|
16058
|
+
return [createContext3, composeContextScopes$1(createScope, ...createContextScopeDeps)];
|
|
16059
|
+
}
|
|
16060
|
+
function composeContextScopes$1(...scopes) {
|
|
16061
|
+
const baseScope = scopes[0];
|
|
16062
|
+
if (scopes.length === 1) return baseScope;
|
|
16063
|
+
const createScope = () => {
|
|
16064
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
16065
|
+
useScope: createScope2(),
|
|
16066
|
+
scopeName: createScope2.scopeName
|
|
16067
|
+
}));
|
|
16068
|
+
return function useComposedScopes(overrideScopes) {
|
|
16069
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
16070
|
+
const scopeProps = useScope(overrideScopes);
|
|
16071
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
16072
|
+
return { ...nextScopes2, ...currentScope };
|
|
16073
|
+
}, {});
|
|
16074
|
+
return React__namespace.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
16075
|
+
};
|
|
16076
|
+
};
|
|
16077
|
+
createScope.scopeName = baseScope.scopeName;
|
|
16078
|
+
return createScope;
|
|
16079
|
+
}
|
|
16080
|
+
|
|
16081
|
+
// packages/react/use-callback-ref/src/useCallbackRef.tsx
|
|
16082
|
+
function useCallbackRef(callback) {
|
|
16083
|
+
const callbackRef = React__namespace.useRef(callback);
|
|
16084
|
+
React__namespace.useEffect(() => {
|
|
16085
|
+
callbackRef.current = callback;
|
|
16086
|
+
});
|
|
16087
|
+
return React__namespace.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
16088
|
+
}
|
|
16089
|
+
|
|
16090
|
+
// packages/react/use-controllable-state/src/useControllableState.tsx
|
|
16091
|
+
function useControllableState({
|
|
16092
|
+
prop,
|
|
16093
|
+
defaultProp,
|
|
16094
|
+
onChange = () => {
|
|
16095
|
+
}
|
|
16096
|
+
}) {
|
|
16097
|
+
const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });
|
|
16098
|
+
const isControlled = prop !== void 0;
|
|
16099
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
16100
|
+
const handleChange = useCallbackRef(onChange);
|
|
16101
|
+
const setValue = React__namespace.useCallback(
|
|
16102
|
+
(nextValue) => {
|
|
16103
|
+
if (isControlled) {
|
|
16104
|
+
const setter = nextValue;
|
|
16105
|
+
const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
|
|
16106
|
+
if (value2 !== prop) handleChange(value2);
|
|
16107
|
+
} else {
|
|
16108
|
+
setUncontrolledProp(nextValue);
|
|
16109
|
+
}
|
|
16110
|
+
},
|
|
16111
|
+
[isControlled, prop, setUncontrolledProp, handleChange]
|
|
16112
|
+
);
|
|
16113
|
+
return [value, setValue];
|
|
16114
|
+
}
|
|
16115
|
+
function useUncontrolledState({
|
|
16116
|
+
defaultProp,
|
|
16117
|
+
onChange
|
|
16118
|
+
}) {
|
|
16119
|
+
const uncontrolledState = React__namespace.useState(defaultProp);
|
|
16120
|
+
const [value] = uncontrolledState;
|
|
16121
|
+
const prevValueRef = React__namespace.useRef(value);
|
|
16122
|
+
const handleChange = useCallbackRef(onChange);
|
|
16123
|
+
React__namespace.useEffect(() => {
|
|
16124
|
+
if (prevValueRef.current !== value) {
|
|
16125
|
+
handleChange(value);
|
|
16126
|
+
prevValueRef.current = value;
|
|
16127
|
+
}
|
|
16128
|
+
}, [value, prevValueRef, handleChange]);
|
|
16129
|
+
return uncontrolledState;
|
|
16130
|
+
}
|
|
16131
|
+
|
|
16132
|
+
// packages/react/direction/src/Direction.tsx
|
|
16133
|
+
var DirectionContext = React__namespace.createContext(void 0);
|
|
16134
|
+
function useDirection(localDir) {
|
|
16135
|
+
const globalDir = React__namespace.useContext(DirectionContext);
|
|
16136
|
+
return localDir || globalDir || "ltr";
|
|
16137
|
+
}
|
|
16138
|
+
|
|
16139
|
+
// packages/react/use-previous/src/usePrevious.tsx
|
|
16140
|
+
function usePrevious(value) {
|
|
16141
|
+
const ref = React__namespace.useRef({ value, previous: value });
|
|
16142
|
+
return React__namespace.useMemo(() => {
|
|
16143
|
+
if (ref.current.value !== value) {
|
|
16144
|
+
ref.current.previous = ref.current.value;
|
|
16145
|
+
ref.current.value = value;
|
|
16146
|
+
}
|
|
16147
|
+
return ref.current.previous;
|
|
16148
|
+
}, [value]);
|
|
16149
|
+
}
|
|
16150
|
+
|
|
16151
|
+
// packages/react/use-layout-effect/src/useLayoutEffect.tsx
|
|
16152
|
+
var useLayoutEffect2 = Boolean(globalThis?.document) ? React__namespace.useLayoutEffect : () => {
|
|
16153
|
+
};
|
|
16154
|
+
|
|
16155
|
+
// packages/react/use-size/src/useSize.tsx
|
|
16156
|
+
function useSize(element) {
|
|
16157
|
+
const [size, setSize] = React__namespace.useState(void 0);
|
|
16158
|
+
useLayoutEffect2(() => {
|
|
16159
|
+
if (element) {
|
|
16160
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
16161
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
16162
|
+
if (!Array.isArray(entries)) {
|
|
16163
|
+
return;
|
|
16164
|
+
}
|
|
16165
|
+
if (!entries.length) {
|
|
16166
|
+
return;
|
|
16167
|
+
}
|
|
16168
|
+
const entry = entries[0];
|
|
16169
|
+
let width;
|
|
16170
|
+
let height;
|
|
16171
|
+
if ("borderBoxSize" in entry) {
|
|
16172
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
16173
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
16174
|
+
width = borderSize["inlineSize"];
|
|
16175
|
+
height = borderSize["blockSize"];
|
|
16176
|
+
} else {
|
|
16177
|
+
width = element.offsetWidth;
|
|
16178
|
+
height = element.offsetHeight;
|
|
16179
|
+
}
|
|
16180
|
+
setSize({ width, height });
|
|
16181
|
+
});
|
|
16182
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
16183
|
+
return () => resizeObserver.unobserve(element);
|
|
16184
|
+
} else {
|
|
16185
|
+
setSize(void 0);
|
|
16186
|
+
}
|
|
16187
|
+
}, [element]);
|
|
16188
|
+
return size;
|
|
16189
|
+
}
|
|
16190
|
+
|
|
16191
|
+
// packages/react/slot/src/Slot.tsx
|
|
16192
|
+
var Slot$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
16193
|
+
const { children, ...slotProps } = props;
|
|
16194
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
16195
|
+
const slottable = childrenArray.find(isSlottable$1);
|
|
16196
|
+
if (slottable) {
|
|
16197
|
+
const newElement = slottable.props.children;
|
|
16198
|
+
const newChildren = childrenArray.map((child) => {
|
|
16199
|
+
if (child === slottable) {
|
|
16200
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
16201
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
16202
|
+
} else {
|
|
16203
|
+
return child;
|
|
16204
|
+
}
|
|
16205
|
+
});
|
|
16206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone$1, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
16207
|
+
}
|
|
16208
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SlotClone$1, { ...slotProps, ref: forwardedRef, children });
|
|
16209
|
+
});
|
|
16210
|
+
Slot$1.displayName = "Slot";
|
|
16211
|
+
var SlotClone$1 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
16212
|
+
const { children, ...slotProps } = props;
|
|
16213
|
+
if (React__namespace.isValidElement(children)) {
|
|
16214
|
+
const childrenRef = getElementRef$1(children);
|
|
16215
|
+
return React__namespace.cloneElement(children, {
|
|
16216
|
+
...mergeProps$1(slotProps, children.props),
|
|
16217
|
+
// @ts-ignore
|
|
16218
|
+
ref: forwardedRef ? composeRefs$1(forwardedRef, childrenRef) : childrenRef
|
|
16219
|
+
});
|
|
16220
|
+
}
|
|
16221
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
16222
|
+
});
|
|
16223
|
+
SlotClone$1.displayName = "SlotClone";
|
|
16224
|
+
var Slottable$1 = ({ children }) => {
|
|
16225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
16226
|
+
};
|
|
16227
|
+
function isSlottable$1(child) {
|
|
16228
|
+
return React__namespace.isValidElement(child) && child.type === Slottable$1;
|
|
16229
|
+
}
|
|
16230
|
+
function mergeProps$1(slotProps, childProps) {
|
|
16231
|
+
const overrideProps = { ...childProps };
|
|
16232
|
+
for (const propName in childProps) {
|
|
16233
|
+
const slotPropValue = slotProps[propName];
|
|
16234
|
+
const childPropValue = childProps[propName];
|
|
16235
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
16236
|
+
if (isHandler) {
|
|
16237
|
+
if (slotPropValue && childPropValue) {
|
|
16238
|
+
overrideProps[propName] = (...args) => {
|
|
16239
|
+
childPropValue(...args);
|
|
16240
|
+
slotPropValue(...args);
|
|
16241
|
+
};
|
|
16242
|
+
} else if (slotPropValue) {
|
|
16243
|
+
overrideProps[propName] = slotPropValue;
|
|
16244
|
+
}
|
|
16245
|
+
} else if (propName === "style") {
|
|
16246
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
16247
|
+
} else if (propName === "className") {
|
|
16248
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
16249
|
+
}
|
|
16250
|
+
}
|
|
16251
|
+
return { ...slotProps, ...overrideProps };
|
|
16252
|
+
}
|
|
16253
|
+
function getElementRef$1(element) {
|
|
16254
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
16255
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
16256
|
+
if (mayWarn) {
|
|
16257
|
+
return element.ref;
|
|
16258
|
+
}
|
|
16259
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
16260
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
16261
|
+
if (mayWarn) {
|
|
16262
|
+
return element.props.ref;
|
|
16263
|
+
}
|
|
16264
|
+
return element.props.ref || element.ref;
|
|
16265
|
+
}
|
|
16266
|
+
|
|
16267
|
+
// packages/react/primitive/src/Primitive.tsx
|
|
16268
|
+
var NODES$1 = [
|
|
16269
|
+
"a",
|
|
16270
|
+
"button",
|
|
16271
|
+
"div",
|
|
16272
|
+
"form",
|
|
16273
|
+
"h2",
|
|
16274
|
+
"h3",
|
|
16275
|
+
"img",
|
|
16276
|
+
"input",
|
|
16277
|
+
"label",
|
|
16278
|
+
"li",
|
|
16279
|
+
"nav",
|
|
16280
|
+
"ol",
|
|
16281
|
+
"p",
|
|
16282
|
+
"span",
|
|
16283
|
+
"svg",
|
|
16284
|
+
"ul"
|
|
16285
|
+
];
|
|
16286
|
+
var Primitive$1 = NODES$1.reduce((primitive, node) => {
|
|
16287
|
+
const Node = React__namespace.forwardRef((props, forwardedRef) => {
|
|
16288
|
+
const { asChild, ...primitiveProps } = props;
|
|
16289
|
+
const Comp = asChild ? Slot$1 : node;
|
|
16290
|
+
if (typeof window !== "undefined") {
|
|
16291
|
+
window[Symbol.for("radix-ui")] = true;
|
|
16292
|
+
}
|
|
16293
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
16294
|
+
});
|
|
16295
|
+
Node.displayName = `Primitive.${node}`;
|
|
16296
|
+
return { ...primitive, [node]: Node };
|
|
16297
|
+
}, {});
|
|
16298
|
+
|
|
16299
|
+
function createCollection(name) {
|
|
16300
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
16301
|
+
const [createCollectionContext, createCollectionScope] = createContextScope$1(PROVIDER_NAME);
|
|
16302
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
|
16303
|
+
PROVIDER_NAME,
|
|
16304
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
16305
|
+
);
|
|
16306
|
+
const CollectionProvider = (props) => {
|
|
16307
|
+
const { scope, children } = props;
|
|
16308
|
+
const ref = React.useRef(null);
|
|
16309
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
16310
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
16311
|
+
};
|
|
16312
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
16313
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
16314
|
+
const CollectionSlot = React.forwardRef(
|
|
16315
|
+
(props, forwardedRef) => {
|
|
16316
|
+
const { scope, children } = props;
|
|
16317
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
16318
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
16319
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Slot$1, { ref: composedRefs, children });
|
|
16320
|
+
}
|
|
16321
|
+
);
|
|
16322
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
16323
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
16324
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
16325
|
+
const CollectionItemSlot = React.forwardRef(
|
|
16326
|
+
(props, forwardedRef) => {
|
|
16327
|
+
const { scope, children, ...itemData } = props;
|
|
16328
|
+
const ref = React.useRef(null);
|
|
16329
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
16330
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
16331
|
+
React.useEffect(() => {
|
|
16332
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
|
16333
|
+
return () => void context.itemMap.delete(ref);
|
|
16334
|
+
});
|
|
16335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Slot$1, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
16336
|
+
}
|
|
16337
|
+
);
|
|
16338
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
16339
|
+
function useCollection(scope) {
|
|
16340
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
16341
|
+
const getItems = React.useCallback(() => {
|
|
16342
|
+
const collectionNode = context.collectionRef.current;
|
|
16343
|
+
if (!collectionNode) return [];
|
|
16344
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
16345
|
+
const items = Array.from(context.itemMap.values());
|
|
16346
|
+
const orderedItems = items.sort(
|
|
16347
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
16348
|
+
);
|
|
16349
|
+
return orderedItems;
|
|
16350
|
+
}, [context.collectionRef, context.itemMap]);
|
|
16351
|
+
return getItems;
|
|
16352
|
+
}
|
|
16353
|
+
return [
|
|
16354
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
16355
|
+
useCollection,
|
|
16356
|
+
createCollectionScope
|
|
16357
|
+
];
|
|
16358
|
+
}
|
|
16359
|
+
|
|
16360
|
+
var PAGE_KEYS = ["PageUp", "PageDown"];
|
|
16361
|
+
var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
16362
|
+
var BACK_KEYS = {
|
|
16363
|
+
"from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
|
|
16364
|
+
"from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
|
|
16365
|
+
"from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
|
|
16366
|
+
"from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
|
|
16367
|
+
};
|
|
16368
|
+
var SLIDER_NAME = "Slider";
|
|
16369
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(SLIDER_NAME);
|
|
16370
|
+
var [createSliderContext, createSliderScope] = createContextScope$1(SLIDER_NAME, [
|
|
16371
|
+
createCollectionScope
|
|
16372
|
+
]);
|
|
16373
|
+
var [SliderProvider, useSliderContext] = createSliderContext(SLIDER_NAME);
|
|
16374
|
+
var Slider$1 = React__namespace.forwardRef(
|
|
16375
|
+
(props, forwardedRef) => {
|
|
16376
|
+
const {
|
|
16377
|
+
name,
|
|
16378
|
+
min = 0,
|
|
16379
|
+
max = 100,
|
|
16380
|
+
step = 1,
|
|
16381
|
+
orientation = "horizontal",
|
|
16382
|
+
disabled = false,
|
|
16383
|
+
minStepsBetweenThumbs = 0,
|
|
16384
|
+
defaultValue = [min],
|
|
16385
|
+
value,
|
|
16386
|
+
onValueChange = () => {
|
|
16387
|
+
},
|
|
16388
|
+
onValueCommit = () => {
|
|
16389
|
+
},
|
|
16390
|
+
inverted = false,
|
|
16391
|
+
form,
|
|
16392
|
+
...sliderProps
|
|
16393
|
+
} = props;
|
|
16394
|
+
const thumbRefs = React__namespace.useRef(/* @__PURE__ */ new Set());
|
|
16395
|
+
const valueIndexToChangeRef = React__namespace.useRef(0);
|
|
16396
|
+
const isHorizontal = orientation === "horizontal";
|
|
16397
|
+
const SliderOrientation = isHorizontal ? SliderHorizontal : SliderVertical;
|
|
16398
|
+
const [values = [], setValues] = useControllableState({
|
|
16399
|
+
prop: value,
|
|
16400
|
+
defaultProp: defaultValue,
|
|
16401
|
+
onChange: (value2) => {
|
|
16402
|
+
const thumbs = [...thumbRefs.current];
|
|
16403
|
+
thumbs[valueIndexToChangeRef.current]?.focus();
|
|
16404
|
+
onValueChange(value2);
|
|
16405
|
+
}
|
|
16406
|
+
});
|
|
16407
|
+
const valuesBeforeSlideStartRef = React__namespace.useRef(values);
|
|
16408
|
+
function handleSlideStart(value2) {
|
|
16409
|
+
const closestIndex = getClosestValueIndex(values, value2);
|
|
16410
|
+
updateValues(value2, closestIndex);
|
|
16411
|
+
}
|
|
16412
|
+
function handleSlideMove(value2) {
|
|
16413
|
+
updateValues(value2, valueIndexToChangeRef.current);
|
|
16414
|
+
}
|
|
16415
|
+
function handleSlideEnd() {
|
|
16416
|
+
const prevValue = valuesBeforeSlideStartRef.current[valueIndexToChangeRef.current];
|
|
16417
|
+
const nextValue = values[valueIndexToChangeRef.current];
|
|
16418
|
+
const hasChanged = nextValue !== prevValue;
|
|
16419
|
+
if (hasChanged) onValueCommit(values);
|
|
16420
|
+
}
|
|
16421
|
+
function updateValues(value2, atIndex, { commit } = { commit: false }) {
|
|
16422
|
+
const decimalCount = getDecimalCount(step);
|
|
16423
|
+
const snapToStep = roundValue(Math.round((value2 - min) / step) * step + min, decimalCount);
|
|
16424
|
+
const nextValue = clamp(snapToStep, [min, max]);
|
|
16425
|
+
setValues((prevValues = []) => {
|
|
16426
|
+
const nextValues = getNextSortedValues(prevValues, nextValue, atIndex);
|
|
16427
|
+
if (hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) {
|
|
16428
|
+
valueIndexToChangeRef.current = nextValues.indexOf(nextValue);
|
|
16429
|
+
const hasChanged = String(nextValues) !== String(prevValues);
|
|
16430
|
+
if (hasChanged && commit) onValueCommit(nextValues);
|
|
16431
|
+
return hasChanged ? nextValues : prevValues;
|
|
16432
|
+
} else {
|
|
16433
|
+
return prevValues;
|
|
16434
|
+
}
|
|
16435
|
+
});
|
|
16436
|
+
}
|
|
16437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16438
|
+
SliderProvider,
|
|
16439
|
+
{
|
|
16440
|
+
scope: props.__scopeSlider,
|
|
16441
|
+
name,
|
|
16442
|
+
disabled,
|
|
16443
|
+
min,
|
|
16444
|
+
max,
|
|
16445
|
+
valueIndexToChangeRef,
|
|
16446
|
+
thumbs: thumbRefs.current,
|
|
16447
|
+
values,
|
|
16448
|
+
orientation,
|
|
16449
|
+
form,
|
|
16450
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsxRuntime.jsx(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16451
|
+
SliderOrientation,
|
|
16452
|
+
{
|
|
16453
|
+
"aria-disabled": disabled,
|
|
16454
|
+
"data-disabled": disabled ? "" : void 0,
|
|
16455
|
+
...sliderProps,
|
|
16456
|
+
ref: forwardedRef,
|
|
16457
|
+
onPointerDown: composeEventHandlers(sliderProps.onPointerDown, () => {
|
|
16458
|
+
if (!disabled) valuesBeforeSlideStartRef.current = values;
|
|
16459
|
+
}),
|
|
16460
|
+
min,
|
|
16461
|
+
max,
|
|
16462
|
+
inverted,
|
|
16463
|
+
onSlideStart: disabled ? void 0 : handleSlideStart,
|
|
16464
|
+
onSlideMove: disabled ? void 0 : handleSlideMove,
|
|
16465
|
+
onSlideEnd: disabled ? void 0 : handleSlideEnd,
|
|
16466
|
+
onHomeKeyDown: () => !disabled && updateValues(min, 0, { commit: true }),
|
|
16467
|
+
onEndKeyDown: () => !disabled && updateValues(max, values.length - 1, { commit: true }),
|
|
16468
|
+
onStepKeyDown: ({ event, direction: stepDirection }) => {
|
|
16469
|
+
if (!disabled) {
|
|
16470
|
+
const isPageKey = PAGE_KEYS.includes(event.key);
|
|
16471
|
+
const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.includes(event.key);
|
|
16472
|
+
const multiplier = isSkipKey ? 10 : 1;
|
|
16473
|
+
const atIndex = valueIndexToChangeRef.current;
|
|
16474
|
+
const value2 = values[atIndex];
|
|
16475
|
+
const stepInDirection = step * multiplier * stepDirection;
|
|
16476
|
+
updateValues(value2 + stepInDirection, atIndex, { commit: true });
|
|
16477
|
+
}
|
|
16478
|
+
}
|
|
16479
|
+
}
|
|
16480
|
+
) }) })
|
|
16481
|
+
}
|
|
16482
|
+
);
|
|
16483
|
+
}
|
|
16484
|
+
);
|
|
16485
|
+
Slider$1.displayName = SLIDER_NAME;
|
|
16486
|
+
var [SliderOrientationProvider, useSliderOrientationContext] = createSliderContext(SLIDER_NAME, {
|
|
16487
|
+
startEdge: "left",
|
|
16488
|
+
endEdge: "right",
|
|
16489
|
+
size: "width",
|
|
16490
|
+
direction: 1
|
|
16491
|
+
});
|
|
16492
|
+
var SliderHorizontal = React__namespace.forwardRef(
|
|
16493
|
+
(props, forwardedRef) => {
|
|
16494
|
+
const {
|
|
16495
|
+
min,
|
|
16496
|
+
max,
|
|
16497
|
+
dir,
|
|
16498
|
+
inverted,
|
|
16499
|
+
onSlideStart,
|
|
16500
|
+
onSlideMove,
|
|
16501
|
+
onSlideEnd,
|
|
16502
|
+
onStepKeyDown,
|
|
16503
|
+
...sliderProps
|
|
16504
|
+
} = props;
|
|
16505
|
+
const [slider, setSlider] = React__namespace.useState(null);
|
|
16506
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setSlider(node));
|
|
16507
|
+
const rectRef = React__namespace.useRef(void 0);
|
|
16508
|
+
const direction = useDirection(dir);
|
|
16509
|
+
const isDirectionLTR = direction === "ltr";
|
|
16510
|
+
const isSlidingFromLeft = isDirectionLTR && !inverted || !isDirectionLTR && inverted;
|
|
16511
|
+
function getValueFromPointer(pointerPosition) {
|
|
16512
|
+
const rect = rectRef.current || slider.getBoundingClientRect();
|
|
16513
|
+
const input = [0, rect.width];
|
|
16514
|
+
const output = isSlidingFromLeft ? [min, max] : [max, min];
|
|
16515
|
+
const value = linearScale(input, output);
|
|
16516
|
+
rectRef.current = rect;
|
|
16517
|
+
return value(pointerPosition - rect.left);
|
|
16518
|
+
}
|
|
16519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16520
|
+
SliderOrientationProvider,
|
|
16521
|
+
{
|
|
16522
|
+
scope: props.__scopeSlider,
|
|
16523
|
+
startEdge: isSlidingFromLeft ? "left" : "right",
|
|
16524
|
+
endEdge: isSlidingFromLeft ? "right" : "left",
|
|
16525
|
+
direction: isSlidingFromLeft ? 1 : -1,
|
|
16526
|
+
size: "width",
|
|
16527
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16528
|
+
SliderImpl,
|
|
16529
|
+
{
|
|
16530
|
+
dir: direction,
|
|
16531
|
+
"data-orientation": "horizontal",
|
|
16532
|
+
...sliderProps,
|
|
16533
|
+
ref: composedRefs,
|
|
16534
|
+
style: {
|
|
16535
|
+
...sliderProps.style,
|
|
16536
|
+
["--radix-slider-thumb-transform"]: "translateX(-50%)"
|
|
16537
|
+
},
|
|
16538
|
+
onSlideStart: (event) => {
|
|
16539
|
+
const value = getValueFromPointer(event.clientX);
|
|
16540
|
+
onSlideStart?.(value);
|
|
16541
|
+
},
|
|
16542
|
+
onSlideMove: (event) => {
|
|
16543
|
+
const value = getValueFromPointer(event.clientX);
|
|
16544
|
+
onSlideMove?.(value);
|
|
16545
|
+
},
|
|
16546
|
+
onSlideEnd: () => {
|
|
16547
|
+
rectRef.current = void 0;
|
|
16548
|
+
onSlideEnd?.();
|
|
16549
|
+
},
|
|
16550
|
+
onStepKeyDown: (event) => {
|
|
16551
|
+
const slideDirection = isSlidingFromLeft ? "from-left" : "from-right";
|
|
16552
|
+
const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
|
|
16553
|
+
onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 });
|
|
16554
|
+
}
|
|
16555
|
+
}
|
|
16556
|
+
)
|
|
16557
|
+
}
|
|
16558
|
+
);
|
|
16559
|
+
}
|
|
16560
|
+
);
|
|
16561
|
+
var SliderVertical = React__namespace.forwardRef(
|
|
16562
|
+
(props, forwardedRef) => {
|
|
16563
|
+
const {
|
|
16564
|
+
min,
|
|
16565
|
+
max,
|
|
16566
|
+
inverted,
|
|
16567
|
+
onSlideStart,
|
|
16568
|
+
onSlideMove,
|
|
16569
|
+
onSlideEnd,
|
|
16570
|
+
onStepKeyDown,
|
|
16571
|
+
...sliderProps
|
|
16572
|
+
} = props;
|
|
16573
|
+
const sliderRef = React__namespace.useRef(null);
|
|
16574
|
+
const ref = useComposedRefs(forwardedRef, sliderRef);
|
|
16575
|
+
const rectRef = React__namespace.useRef(void 0);
|
|
16576
|
+
const isSlidingFromBottom = !inverted;
|
|
16577
|
+
function getValueFromPointer(pointerPosition) {
|
|
16578
|
+
const rect = rectRef.current || sliderRef.current.getBoundingClientRect();
|
|
16579
|
+
const input = [0, rect.height];
|
|
16580
|
+
const output = isSlidingFromBottom ? [max, min] : [min, max];
|
|
16581
|
+
const value = linearScale(input, output);
|
|
16582
|
+
rectRef.current = rect;
|
|
16583
|
+
return value(pointerPosition - rect.top);
|
|
16584
|
+
}
|
|
16585
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16586
|
+
SliderOrientationProvider,
|
|
16587
|
+
{
|
|
16588
|
+
scope: props.__scopeSlider,
|
|
16589
|
+
startEdge: isSlidingFromBottom ? "bottom" : "top",
|
|
16590
|
+
endEdge: isSlidingFromBottom ? "top" : "bottom",
|
|
16591
|
+
size: "height",
|
|
16592
|
+
direction: isSlidingFromBottom ? 1 : -1,
|
|
16593
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16594
|
+
SliderImpl,
|
|
16595
|
+
{
|
|
16596
|
+
"data-orientation": "vertical",
|
|
16597
|
+
...sliderProps,
|
|
16598
|
+
ref,
|
|
16599
|
+
style: {
|
|
16600
|
+
...sliderProps.style,
|
|
16601
|
+
["--radix-slider-thumb-transform"]: "translateY(50%)"
|
|
16602
|
+
},
|
|
16603
|
+
onSlideStart: (event) => {
|
|
16604
|
+
const value = getValueFromPointer(event.clientY);
|
|
16605
|
+
onSlideStart?.(value);
|
|
16606
|
+
},
|
|
16607
|
+
onSlideMove: (event) => {
|
|
16608
|
+
const value = getValueFromPointer(event.clientY);
|
|
16609
|
+
onSlideMove?.(value);
|
|
16610
|
+
},
|
|
16611
|
+
onSlideEnd: () => {
|
|
16612
|
+
rectRef.current = void 0;
|
|
16613
|
+
onSlideEnd?.();
|
|
16614
|
+
},
|
|
16615
|
+
onStepKeyDown: (event) => {
|
|
16616
|
+
const slideDirection = isSlidingFromBottom ? "from-bottom" : "from-top";
|
|
16617
|
+
const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
|
|
16618
|
+
onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 });
|
|
16619
|
+
}
|
|
16620
|
+
}
|
|
16621
|
+
)
|
|
16622
|
+
}
|
|
16623
|
+
);
|
|
16624
|
+
}
|
|
16625
|
+
);
|
|
16626
|
+
var SliderImpl = React__namespace.forwardRef(
|
|
16627
|
+
(props, forwardedRef) => {
|
|
16628
|
+
const {
|
|
16629
|
+
__scopeSlider,
|
|
16630
|
+
onSlideStart,
|
|
16631
|
+
onSlideMove,
|
|
16632
|
+
onSlideEnd,
|
|
16633
|
+
onHomeKeyDown,
|
|
16634
|
+
onEndKeyDown,
|
|
16635
|
+
onStepKeyDown,
|
|
16636
|
+
...sliderProps
|
|
16637
|
+
} = props;
|
|
16638
|
+
const context = useSliderContext(SLIDER_NAME, __scopeSlider);
|
|
16639
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16640
|
+
Primitive$1.span,
|
|
16641
|
+
{
|
|
16642
|
+
...sliderProps,
|
|
16643
|
+
ref: forwardedRef,
|
|
16644
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
16645
|
+
if (event.key === "Home") {
|
|
16646
|
+
onHomeKeyDown(event);
|
|
16647
|
+
event.preventDefault();
|
|
16648
|
+
} else if (event.key === "End") {
|
|
16649
|
+
onEndKeyDown(event);
|
|
16650
|
+
event.preventDefault();
|
|
16651
|
+
} else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {
|
|
16652
|
+
onStepKeyDown(event);
|
|
16653
|
+
event.preventDefault();
|
|
16654
|
+
}
|
|
16655
|
+
}),
|
|
16656
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
16657
|
+
const target = event.target;
|
|
16658
|
+
target.setPointerCapture(event.pointerId);
|
|
16659
|
+
event.preventDefault();
|
|
16660
|
+
if (context.thumbs.has(target)) {
|
|
16661
|
+
target.focus();
|
|
16662
|
+
} else {
|
|
16663
|
+
onSlideStart(event);
|
|
16664
|
+
}
|
|
16665
|
+
}),
|
|
16666
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
16667
|
+
const target = event.target;
|
|
16668
|
+
if (target.hasPointerCapture(event.pointerId)) onSlideMove(event);
|
|
16669
|
+
}),
|
|
16670
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
16671
|
+
const target = event.target;
|
|
16672
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
16673
|
+
target.releasePointerCapture(event.pointerId);
|
|
16674
|
+
onSlideEnd(event);
|
|
16675
|
+
}
|
|
16676
|
+
})
|
|
16677
|
+
}
|
|
16678
|
+
);
|
|
16679
|
+
}
|
|
16680
|
+
);
|
|
16681
|
+
var TRACK_NAME = "SliderTrack";
|
|
16682
|
+
var SliderTrack = React__namespace.forwardRef(
|
|
16683
|
+
(props, forwardedRef) => {
|
|
16684
|
+
const { __scopeSlider, ...trackProps } = props;
|
|
16685
|
+
const context = useSliderContext(TRACK_NAME, __scopeSlider);
|
|
16686
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16687
|
+
Primitive$1.span,
|
|
16688
|
+
{
|
|
16689
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
16690
|
+
"data-orientation": context.orientation,
|
|
16691
|
+
...trackProps,
|
|
16692
|
+
ref: forwardedRef
|
|
16693
|
+
}
|
|
16694
|
+
);
|
|
16695
|
+
}
|
|
16696
|
+
);
|
|
16697
|
+
SliderTrack.displayName = TRACK_NAME;
|
|
16698
|
+
var RANGE_NAME = "SliderRange";
|
|
16699
|
+
var SliderRange = React__namespace.forwardRef(
|
|
16700
|
+
(props, forwardedRef) => {
|
|
16701
|
+
const { __scopeSlider, ...rangeProps } = props;
|
|
16702
|
+
const context = useSliderContext(RANGE_NAME, __scopeSlider);
|
|
16703
|
+
const orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider);
|
|
16704
|
+
const ref = React__namespace.useRef(null);
|
|
16705
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
16706
|
+
const valuesCount = context.values.length;
|
|
16707
|
+
const percentages = context.values.map(
|
|
16708
|
+
(value) => convertValueToPercentage(value, context.min, context.max)
|
|
16709
|
+
);
|
|
16710
|
+
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
|
|
16711
|
+
const offsetEnd = 100 - Math.max(...percentages);
|
|
16712
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16713
|
+
Primitive$1.span,
|
|
16714
|
+
{
|
|
16715
|
+
"data-orientation": context.orientation,
|
|
16716
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
16717
|
+
...rangeProps,
|
|
16718
|
+
ref: composedRefs,
|
|
16719
|
+
style: {
|
|
16720
|
+
...props.style,
|
|
16721
|
+
[orientation.startEdge]: offsetStart + "%",
|
|
16722
|
+
[orientation.endEdge]: offsetEnd + "%"
|
|
16723
|
+
}
|
|
16724
|
+
}
|
|
16725
|
+
);
|
|
16726
|
+
}
|
|
16727
|
+
);
|
|
16728
|
+
SliderRange.displayName = RANGE_NAME;
|
|
16729
|
+
var THUMB_NAME = "SliderThumb";
|
|
16730
|
+
var SliderThumb = React__namespace.forwardRef(
|
|
16731
|
+
(props, forwardedRef) => {
|
|
16732
|
+
const getItems = useCollection(props.__scopeSlider);
|
|
16733
|
+
const [thumb, setThumb] = React__namespace.useState(null);
|
|
16734
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
|
|
16735
|
+
const index = React__namespace.useMemo(
|
|
16736
|
+
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
|
|
16737
|
+
[getItems, thumb]
|
|
16738
|
+
);
|
|
16739
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SliderThumbImpl, { ...props, ref: composedRefs, index });
|
|
16740
|
+
}
|
|
16741
|
+
);
|
|
16742
|
+
var SliderThumbImpl = React__namespace.forwardRef(
|
|
16743
|
+
(props, forwardedRef) => {
|
|
16744
|
+
const { __scopeSlider, index, name, ...thumbProps } = props;
|
|
16745
|
+
const context = useSliderContext(THUMB_NAME, __scopeSlider);
|
|
16746
|
+
const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider);
|
|
16747
|
+
const [thumb, setThumb] = React__namespace.useState(null);
|
|
16748
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
|
|
16749
|
+
const isFormControl = thumb ? context.form || !!thumb.closest("form") : true;
|
|
16750
|
+
const size = useSize(thumb);
|
|
16751
|
+
const value = context.values[index];
|
|
16752
|
+
const percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max);
|
|
16753
|
+
const label = getLabel(index, context.values.length);
|
|
16754
|
+
const orientationSize = size?.[orientation.size];
|
|
16755
|
+
const thumbInBoundsOffset = orientationSize ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0;
|
|
16756
|
+
React__namespace.useEffect(() => {
|
|
16757
|
+
if (thumb) {
|
|
16758
|
+
context.thumbs.add(thumb);
|
|
16759
|
+
return () => {
|
|
16760
|
+
context.thumbs.delete(thumb);
|
|
16761
|
+
};
|
|
16762
|
+
}
|
|
16763
|
+
}, [thumb, context.thumbs]);
|
|
16764
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
16765
|
+
"span",
|
|
16766
|
+
{
|
|
16767
|
+
style: {
|
|
16768
|
+
transform: "var(--radix-slider-thumb-transform)",
|
|
16769
|
+
position: "absolute",
|
|
16770
|
+
[orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
|
|
16771
|
+
},
|
|
16772
|
+
children: [
|
|
16773
|
+
/* @__PURE__ */ jsxRuntime.jsx(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16774
|
+
Primitive$1.span,
|
|
16775
|
+
{
|
|
16776
|
+
role: "slider",
|
|
16777
|
+
"aria-label": props["aria-label"] || label,
|
|
16778
|
+
"aria-valuemin": context.min,
|
|
16779
|
+
"aria-valuenow": value,
|
|
16780
|
+
"aria-valuemax": context.max,
|
|
16781
|
+
"aria-orientation": context.orientation,
|
|
16782
|
+
"data-orientation": context.orientation,
|
|
16783
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
16784
|
+
tabIndex: context.disabled ? void 0 : 0,
|
|
16785
|
+
...thumbProps,
|
|
16786
|
+
ref: composedRefs,
|
|
16787
|
+
style: value === void 0 ? { display: "none" } : props.style,
|
|
16788
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
16789
|
+
context.valueIndexToChangeRef.current = index;
|
|
16790
|
+
})
|
|
16791
|
+
}
|
|
16792
|
+
) }),
|
|
16793
|
+
isFormControl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
16794
|
+
BubbleInput,
|
|
16795
|
+
{
|
|
16796
|
+
name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
|
|
16797
|
+
form: context.form,
|
|
16798
|
+
value
|
|
16799
|
+
},
|
|
16800
|
+
index
|
|
16801
|
+
)
|
|
16802
|
+
]
|
|
16803
|
+
}
|
|
16804
|
+
);
|
|
16805
|
+
}
|
|
16806
|
+
);
|
|
16807
|
+
SliderThumb.displayName = THUMB_NAME;
|
|
16808
|
+
var BubbleInput = (props) => {
|
|
16809
|
+
const { value, ...inputProps } = props;
|
|
16810
|
+
const ref = React__namespace.useRef(null);
|
|
16811
|
+
const prevValue = usePrevious(value);
|
|
16812
|
+
React__namespace.useEffect(() => {
|
|
16813
|
+
const input = ref.current;
|
|
16814
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
16815
|
+
const descriptor = Object.getOwnPropertyDescriptor(inputProto, "value");
|
|
16816
|
+
const setValue = descriptor.set;
|
|
16817
|
+
if (prevValue !== value && setValue) {
|
|
16818
|
+
const event = new Event("input", { bubbles: true });
|
|
16819
|
+
setValue.call(input, value);
|
|
16820
|
+
input.dispatchEvent(event);
|
|
16821
|
+
}
|
|
16822
|
+
}, [prevValue, value]);
|
|
16823
|
+
return /* @__PURE__ */ jsxRuntime.jsx("input", { style: { display: "none" }, ...inputProps, ref, defaultValue: value });
|
|
16824
|
+
};
|
|
16825
|
+
function getNextSortedValues(prevValues = [], nextValue, atIndex) {
|
|
16826
|
+
const nextValues = [...prevValues];
|
|
16827
|
+
nextValues[atIndex] = nextValue;
|
|
16828
|
+
return nextValues.sort((a, b) => a - b);
|
|
16829
|
+
}
|
|
16830
|
+
function convertValueToPercentage(value, min, max) {
|
|
16831
|
+
const maxSteps = max - min;
|
|
16832
|
+
const percentPerStep = 100 / maxSteps;
|
|
16833
|
+
const percentage = percentPerStep * (value - min);
|
|
16834
|
+
return clamp(percentage, [0, 100]);
|
|
16835
|
+
}
|
|
16836
|
+
function getLabel(index, totalValues) {
|
|
16837
|
+
if (totalValues > 2) {
|
|
16838
|
+
return `Value ${index + 1} of ${totalValues}`;
|
|
16839
|
+
} else if (totalValues === 2) {
|
|
16840
|
+
return ["Minimum", "Maximum"][index];
|
|
16841
|
+
} else {
|
|
16842
|
+
return void 0;
|
|
16843
|
+
}
|
|
16844
|
+
}
|
|
16845
|
+
function getClosestValueIndex(values, nextValue) {
|
|
16846
|
+
if (values.length === 1) return 0;
|
|
16847
|
+
const distances = values.map((value) => Math.abs(value - nextValue));
|
|
16848
|
+
const closestDistance = Math.min(...distances);
|
|
16849
|
+
return distances.indexOf(closestDistance);
|
|
16850
|
+
}
|
|
16851
|
+
function getThumbInBoundsOffset(width, left, direction) {
|
|
16852
|
+
const halfWidth = width / 2;
|
|
16853
|
+
const halfPercent = 50;
|
|
16854
|
+
const offset = linearScale([0, halfPercent], [0, halfWidth]);
|
|
16855
|
+
return (halfWidth - offset(left) * direction) * direction;
|
|
16856
|
+
}
|
|
16857
|
+
function getStepsBetweenValues(values) {
|
|
16858
|
+
return values.slice(0, -1).map((value, index) => values[index + 1] - value);
|
|
16859
|
+
}
|
|
16860
|
+
function hasMinStepsBetweenValues(values, minStepsBetweenValues) {
|
|
16861
|
+
if (minStepsBetweenValues > 0) {
|
|
16862
|
+
const stepsBetweenValues = getStepsBetweenValues(values);
|
|
16863
|
+
const actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);
|
|
16864
|
+
return actualMinStepsBetweenValues >= minStepsBetweenValues;
|
|
16865
|
+
}
|
|
16866
|
+
return true;
|
|
16867
|
+
}
|
|
16868
|
+
function linearScale(input, output) {
|
|
16869
|
+
return (value) => {
|
|
16870
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
16871
|
+
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
16872
|
+
return output[0] + ratio * (value - input[0]);
|
|
16873
|
+
};
|
|
16874
|
+
}
|
|
16875
|
+
function getDecimalCount(value) {
|
|
16876
|
+
return (String(value).split(".")[1] || "").length;
|
|
16877
|
+
}
|
|
16878
|
+
function roundValue(value, decimalCount) {
|
|
16879
|
+
const rounder = Math.pow(10, decimalCount);
|
|
16880
|
+
return Math.round(value * rounder) / rounder;
|
|
16881
|
+
}
|
|
16882
|
+
var Root$1 = Slider$1;
|
|
16883
|
+
var Track = SliderTrack;
|
|
16884
|
+
var Range = SliderRange;
|
|
16885
|
+
var Thumb = SliderThumb;
|
|
16886
|
+
|
|
16887
|
+
/**
|
|
16888
|
+
* Slider .
|
|
16889
|
+
*/
|
|
16890
|
+
const Slider = (props) => {
|
|
16891
|
+
const { onValueChange, onPointerUp, id, value, name, disabled = false, rootExtraClassNames = '', trackExtraClassNames = '', rangeExtraClassNames = '', thumbExtraClassNames = '', step, min, max, } = props;
|
|
16892
|
+
return (React.createElement(Root$1, { className: `tw-relative tw-flex tw-h-5 tw-w-full tw-touch-none tw-select-none tw-items-center ${rootExtraClassNames}`, defaultValue: [value], value: [value], onValueChange: (value) => onValueChange && onValueChange(value), onPointerUp: (e) => onPointerUp && onPointerUp(e), name: name, id: id, max: max, min: min, disabled: disabled, step: step },
|
|
16893
|
+
React.createElement(Track, { className: `tw-relative tw-h-[5px] tw-grow tw-rounded-[4px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray ${trackExtraClassNames}` },
|
|
16894
|
+
React.createElement(Range, { className: `tw-absolute tw-h-full tw-rounded-full ${rangeExtraClassNames}` })),
|
|
16895
|
+
React.createElement(Thumb, { className: `tw-block tw-h-[15px] tw-w-[15px] tw-rounded-full tw-bg-sq-color-dark active:tw-bg-sq-color-dark-dark focus:outline-none focus-visible:tw-outline-none aria-disabled:tw-bg-sq-dark-gray dark:aria-disabled:tw-bg-sq-dark-disabled-gray tw-transition tw-ease-in-out ${thumbExtraClassNames}`, "aria-disabled": disabled })));
|
|
15964
16896
|
};
|
|
15965
16897
|
|
|
15966
16898
|
// packages/react/context/src/createContext.tsx
|
|
@@ -16276,6 +17208,7 @@ exports.QTip = QTip;
|
|
|
16276
17208
|
exports.SeeqActionDropdown = SeeqActionDropdown;
|
|
16277
17209
|
exports.Select = Select;
|
|
16278
17210
|
exports.SelectCompoents = components;
|
|
17211
|
+
exports.Slider = Slider;
|
|
16279
17212
|
exports.Tabs = Tabs;
|
|
16280
17213
|
exports.TextArea = TextArea;
|
|
16281
17214
|
exports.TextField = TextField;
|