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