@seeqdev/qomponents 0.0.111 → 0.0.113

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.
Files changed (201) hide show
  1. package/dist/Accordion/Accordion.js +9 -0
  2. package/dist/Accordion/Accordion.js.map +1 -0
  3. package/dist/Accordion/Accordion.stories.js +115 -0
  4. package/dist/Accordion/Accordion.stories.js.map +1 -0
  5. package/dist/Accordion/Accordion.test.js +55 -0
  6. package/dist/Accordion/Accordion.test.js.map +1 -0
  7. package/dist/Accordion/Accordion.types.js +2 -0
  8. package/dist/Accordion/Accordion.types.js.map +1 -0
  9. package/dist/Accordion/index.js +2 -0
  10. package/dist/Accordion/index.js.map +1 -0
  11. package/dist/Alert/Alert.js +32 -0
  12. package/dist/Alert/Alert.js.map +1 -0
  13. package/dist/Alert/Alert.stories.js +45 -0
  14. package/dist/Alert/Alert.stories.js.map +1 -0
  15. package/dist/Alert/Alert.test.js +51 -0
  16. package/dist/Alert/Alert.test.js.map +1 -0
  17. package/dist/Alert/Alert.types.js +2 -0
  18. package/dist/Alert/Alert.types.js.map +1 -0
  19. package/dist/Alert/index.js +2 -0
  20. package/dist/Alert/index.js.map +1 -0
  21. package/dist/Button/Button.js +92 -0
  22. package/dist/Button/Button.js.map +1 -0
  23. package/dist/Button/Button.stories.js +100 -0
  24. package/dist/Button/Button.stories.js.map +1 -0
  25. package/dist/Button/Button.test.js +49 -0
  26. package/dist/Button/Button.test.js.map +1 -0
  27. package/dist/Button/Button.types.js +5 -0
  28. package/dist/Button/Button.types.js.map +1 -0
  29. package/dist/Button/index.js +2 -0
  30. package/dist/Button/index.js.map +1 -0
  31. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +67 -0
  32. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +1 -0
  33. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +98 -0
  34. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +1 -0
  35. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +85 -0
  36. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +1 -0
  37. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +2 -0
  38. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +1 -0
  39. package/dist/ButtonWithDropdown/index.js +2 -0
  40. package/dist/ButtonWithDropdown/index.js.map +1 -0
  41. package/dist/ButtonWithPopover/ButtonWithPopover.js +53 -0
  42. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +1 -0
  43. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +75 -0
  44. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +1 -0
  45. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +82 -0
  46. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +1 -0
  47. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +2 -0
  48. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +1 -0
  49. package/dist/ButtonWithPopover/index.js +2 -0
  50. package/dist/ButtonWithPopover/index.js.map +1 -0
  51. package/dist/Checkbox/Checkbox.js +26 -0
  52. package/dist/Checkbox/Checkbox.js.map +1 -0
  53. package/dist/Checkbox/Checkbox.stories.js +34 -0
  54. package/dist/Checkbox/Checkbox.stories.js.map +1 -0
  55. package/dist/Checkbox/Checkbox.test.js +94 -0
  56. package/dist/Checkbox/Checkbox.test.js.map +1 -0
  57. package/dist/Checkbox/Checkbox.types.js +2 -0
  58. package/dist/Checkbox/Checkbox.types.js.map +1 -0
  59. package/dist/Checkbox/index.js +2 -0
  60. package/dist/Checkbox/index.js.map +1 -0
  61. package/dist/Icon/Icon.js +55 -0
  62. package/dist/Icon/Icon.js.map +1 -0
  63. package/dist/Icon/Icon.stories.js +45 -0
  64. package/dist/Icon/Icon.stories.js.map +1 -0
  65. package/dist/Icon/Icon.test.js +55 -0
  66. package/dist/Icon/Icon.test.js.map +1 -0
  67. package/dist/Icon/Icon.types.js +16 -0
  68. package/dist/Icon/Icon.types.js.map +1 -0
  69. package/dist/Icon/index.js +2 -0
  70. package/dist/Icon/index.js.map +1 -0
  71. package/dist/InputGroup/InputGroup.js +31 -0
  72. package/dist/InputGroup/InputGroup.js.map +1 -0
  73. package/dist/InputGroup/InputGroup.stories.js +168 -0
  74. package/dist/InputGroup/InputGroup.stories.js.map +1 -0
  75. package/dist/InputGroup/InputGroup.test.js +43 -0
  76. package/dist/InputGroup/InputGroup.test.js.map +1 -0
  77. package/dist/InputGroup/InputGroup.types.d.ts +1 -1
  78. package/dist/InputGroup/InputGroup.types.js +2 -0
  79. package/dist/InputGroup/InputGroup.types.js.map +1 -0
  80. package/dist/InputGroup/index.d.ts +1 -0
  81. package/dist/InputGroup/index.js +2 -0
  82. package/dist/InputGroup/index.js.map +1 -0
  83. package/dist/Modal/Modal.js +100 -0
  84. package/dist/Modal/Modal.js.map +1 -0
  85. package/dist/Modal/Modal.stories.js +127 -0
  86. package/dist/Modal/Modal.stories.js.map +1 -0
  87. package/dist/Modal/Modal.test.js +108 -0
  88. package/dist/Modal/Modal.test.js.map +1 -0
  89. package/dist/Modal/Modal.types.js +2 -0
  90. package/dist/Modal/Modal.types.js.map +1 -0
  91. package/dist/Modal/index.js +2 -0
  92. package/dist/Modal/index.js.map +1 -0
  93. package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
  94. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +48 -0
  95. package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +1 -0
  96. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +80 -0
  97. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +1 -0
  98. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +73 -0
  99. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +1 -0
  100. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +2 -0
  101. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +1 -0
  102. package/dist/SeeqActionDropdown/index.js +2 -0
  103. package/dist/SeeqActionDropdown/index.js.map +1 -0
  104. package/dist/SeeqActionDropdown/variants.js +23 -0
  105. package/dist/SeeqActionDropdown/variants.js.map +1 -0
  106. package/dist/Select/Select.js +174 -0
  107. package/dist/Select/Select.js.map +1 -0
  108. package/dist/Select/Select.stories.js +80 -0
  109. package/dist/Select/Select.stories.js.map +1 -0
  110. package/dist/Select/Select.test.js +182 -0
  111. package/dist/Select/Select.test.js.map +1 -0
  112. package/dist/Select/Select.types.js +2 -0
  113. package/dist/Select/Select.types.js.map +1 -0
  114. package/dist/Select/index.js +3 -0
  115. package/dist/Select/index.js.map +1 -0
  116. package/dist/Slider/Slider.d.ts +6 -6
  117. package/dist/Slider/Slider.js +5 -5
  118. package/dist/Slider/Slider.js.map +1 -1
  119. package/dist/Slider/Slider.stories.d.ts +5 -5
  120. package/dist/Slider/Slider.test.d.ts +1 -1
  121. package/dist/Slider/Slider.test.js +0 -5
  122. package/dist/Slider/Slider.test.js.map +1 -1
  123. package/dist/Slider/Slider.types.d.ts +16 -13
  124. package/dist/Slider/index.d.ts +1 -1
  125. package/dist/Tabs/Tabs.js +22 -0
  126. package/dist/Tabs/Tabs.js.map +1 -0
  127. package/dist/Tabs/Tabs.stories.js +91 -0
  128. package/dist/Tabs/Tabs.stories.js.map +1 -0
  129. package/dist/Tabs/Tabs.test.js +91 -0
  130. package/dist/Tabs/Tabs.test.js.map +1 -0
  131. package/dist/Tabs/Tabs.types.js +2 -0
  132. package/dist/Tabs/Tabs.types.js.map +1 -0
  133. package/dist/Tabs/index.js +2 -0
  134. package/dist/Tabs/index.js.map +1 -0
  135. package/dist/TextArea/TextArea.js +25 -0
  136. package/dist/TextArea/TextArea.js.map +1 -0
  137. package/dist/TextArea/TextArea.stories.js +46 -0
  138. package/dist/TextArea/TextArea.stories.js.map +1 -0
  139. package/dist/TextArea/TextArea.test.js +68 -0
  140. package/dist/TextArea/TextArea.test.js.map +1 -0
  141. package/dist/TextArea/TextArea.types.js +2 -0
  142. package/dist/TextArea/TextArea.types.js.map +1 -0
  143. package/dist/TextArea/index.js +2 -0
  144. package/dist/TextArea/index.js.map +1 -0
  145. package/dist/TextField/TextField.js +79 -0
  146. package/dist/TextField/TextField.js.map +1 -0
  147. package/dist/TextField/TextField.stories.js +70 -0
  148. package/dist/TextField/TextField.stories.js.map +1 -0
  149. package/dist/TextField/TextField.test.js +39 -0
  150. package/dist/TextField/TextField.test.js.map +1 -0
  151. package/dist/TextField/TextField.types.js +2 -0
  152. package/dist/TextField/TextField.types.js.map +1 -0
  153. package/dist/TextField/index.js +2 -0
  154. package/dist/TextField/index.js.map +1 -0
  155. package/dist/ToolbarButton/ToolbarButton.js +75 -0
  156. package/dist/ToolbarButton/ToolbarButton.js.map +1 -0
  157. package/dist/ToolbarButton/ToolbarButton.stories.js +94 -0
  158. package/dist/ToolbarButton/ToolbarButton.stories.js.map +1 -0
  159. package/dist/ToolbarButton/ToolbarButton.test.js +93 -0
  160. package/dist/ToolbarButton/ToolbarButton.test.js.map +1 -0
  161. package/dist/ToolbarButton/ToolbarButton.types.js +2 -0
  162. package/dist/ToolbarButton/ToolbarButton.types.js.map +1 -0
  163. package/dist/ToolbarButton/index.js +2 -0
  164. package/dist/ToolbarButton/index.js.map +1 -0
  165. package/dist/Tooltip/QTip.stories.js +45 -0
  166. package/dist/Tooltip/QTip.stories.js.map +1 -0
  167. package/dist/Tooltip/QTip.types.js +2 -0
  168. package/dist/Tooltip/QTip.types.js.map +1 -0
  169. package/dist/Tooltip/QTipPerformance.stories.js +30 -0
  170. package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
  171. package/dist/Tooltip/Qtip.js +168 -0
  172. package/dist/Tooltip/Qtip.js.map +1 -0
  173. package/dist/Tooltip/Tooltip.js +36 -0
  174. package/dist/Tooltip/Tooltip.js.map +1 -0
  175. package/dist/Tooltip/Tooltip.stories.js +32 -0
  176. package/dist/Tooltip/Tooltip.stories.js.map +1 -0
  177. package/dist/Tooltip/Tooltip.types.js +3 -0
  178. package/dist/Tooltip/Tooltip.types.js.map +1 -0
  179. package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
  180. package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
  181. package/dist/Tooltip/index.js +3 -0
  182. package/dist/Tooltip/index.js.map +1 -0
  183. package/dist/Tooltip/qTip.utilities.js +11 -0
  184. package/dist/Tooltip/qTip.utilities.js.map +1 -0
  185. package/dist/index.d.ts +2 -0
  186. package/dist/index.esm.js +944 -16
  187. package/dist/index.esm.js.map +1 -1
  188. package/dist/index.js +943 -14
  189. package/dist/index.js.map +1 -1
  190. package/dist/styles.css +53 -6
  191. package/dist/types.js +2 -0
  192. package/dist/types.js.map +1 -0
  193. package/dist/utils/browserId.js +29 -0
  194. package/dist/utils/browserId.js.map +1 -0
  195. package/dist/utils/svg.js +20 -0
  196. package/dist/utils/svg.js.map +1 -0
  197. package/dist/utils/validateStyleDimension.js +14 -0
  198. package/dist/utils/validateStyleDimension.js.map +1 -0
  199. package/dist/utils/validateStyleDimension.test.js +20 -0
  200. package/dist/utils/validateStyleDimension.test.js.map +1 -0
  201. package/package.json +2 -1
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
@@ -15922,7 +15922,7 @@ 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
15926
  const errorClasses = 'tw-border-sq-danger-color';
15927
15927
  const borderColorClasses = [
15928
15928
  'tw-border-sq-disabled-gray',
@@ -15932,20 +15932,948 @@ const borderColorClasses = [
15932
15932
  'focus:tw-border-sq-color-dark',
15933
15933
  'active:tw-border-sq-color-dark',
15934
15934
  ].join(' ');
15935
- let borderRadius = 'tw-rounded-sm tw-rounded-r-none';
15935
+ const borderRadius = 'tw-rounded-sm tw-rounded-r-none';
15936
15936
  const fieldClasses = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3' + 'tw-p-1 tw-border-solid tw-border';
15937
15937
  const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
15938
15938
  const lightTheme = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
15939
15939
  /**
15940
15940
  * InputGroup.
15941
15941
  */
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 }) => {
15942
+ const InputGroup = React__default.forwardRef((props, ref) => {
15943
+ const { readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, name, value, placeholder, append = [], extraClassNames = '', id, testId, showError, required, autoComplete, autoFocus, disabled, type, step, min, max, field, maxLength, minLength, ...tooltipProps } = props;
15943
15944
  const tooltipData = getQTipData(tooltipProps);
15944
15945
  const appliedClasses = `${baseClasses} ${extraClassNames}`;
15945
15946
  const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
15946
- return (React__default.createElement("div", { id: id, "data-testid": testId, className: appliedClasses },
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-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)))));
15947
+ return (React__default.createElement("div", { id: id, className: appliedClasses },
15948
+ field ? (React__default.createElement("div", { "data-testid": testId, className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}` }, field)) : (React__default.createElement(TextField, { testId: testId, readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, ref: ref, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, maxLength: maxLength, minLength: minLength, extraClassNames: `tw-flex tw-flex-1 tw-w-full tw-rounded-r-none focus:tw-z-30 ${extraClassNames}`, ...tooltipData })),
15949
+ 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, tooltip: item.buttonProps.tooltip, tooltipOptions: item.buttonProps.tooltipOptions, tooltipTestId: item.buttonProps.tooltipTestId, isHtmlTooltip: item.buttonProps.isHtmlTooltip, type: item.buttonProps.type, iconPosition: item.buttonProps.iconPosition })) : (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)))));
15950
+ });
15951
+
15952
+ // packages/core/number/src/number.ts
15953
+ function clamp(value, [min, max]) {
15954
+ return Math.min(max, Math.max(min, value));
15955
+ }
15956
+
15957
+ // packages/core/primitive/src/primitive.tsx
15958
+ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
15959
+ return function handleEvent(event) {
15960
+ originalEventHandler?.(event);
15961
+ if (checkForDefaultPrevented === false || !event.defaultPrevented) {
15962
+ return ourEventHandler?.(event);
15963
+ }
15964
+ };
15965
+ }
15966
+
15967
+ // packages/react/compose-refs/src/composeRefs.tsx
15968
+ function setRef$1(ref, value) {
15969
+ if (typeof ref === "function") {
15970
+ return ref(value);
15971
+ } else if (ref !== null && ref !== void 0) {
15972
+ ref.current = value;
15973
+ }
15974
+ }
15975
+ function composeRefs$1(...refs) {
15976
+ return (node) => {
15977
+ let hasCleanup = false;
15978
+ const cleanups = refs.map((ref) => {
15979
+ const cleanup = setRef$1(ref, node);
15980
+ if (!hasCleanup && typeof cleanup == "function") {
15981
+ hasCleanup = true;
15982
+ }
15983
+ return cleanup;
15984
+ });
15985
+ if (hasCleanup) {
15986
+ return () => {
15987
+ for (let i = 0; i < cleanups.length; i++) {
15988
+ const cleanup = cleanups[i];
15989
+ if (typeof cleanup == "function") {
15990
+ cleanup();
15991
+ } else {
15992
+ setRef$1(refs[i], null);
15993
+ }
15994
+ }
15995
+ };
15996
+ }
15997
+ };
15998
+ }
15999
+ function useComposedRefs(...refs) {
16000
+ return React.useCallback(composeRefs$1(...refs), refs);
16001
+ }
16002
+
16003
+ // packages/react/context/src/createContext.tsx
16004
+ function createContextScope$1(scopeName, createContextScopeDeps = []) {
16005
+ let defaultContexts = [];
16006
+ function createContext3(rootComponentName, defaultContext) {
16007
+ const BaseContext = React.createContext(defaultContext);
16008
+ const index = defaultContexts.length;
16009
+ defaultContexts = [...defaultContexts, defaultContext];
16010
+ const Provider = (props) => {
16011
+ const { scope, children, ...context } = props;
16012
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
16013
+ const value = React.useMemo(() => context, Object.values(context));
16014
+ return /* @__PURE__ */ jsx$1(Context.Provider, { value, children });
16015
+ };
16016
+ Provider.displayName = rootComponentName + "Provider";
16017
+ function useContext2(consumerName, scope) {
16018
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
16019
+ const context = React.useContext(Context);
16020
+ if (context) return context;
16021
+ if (defaultContext !== void 0) return defaultContext;
16022
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
16023
+ }
16024
+ return [Provider, useContext2];
16025
+ }
16026
+ const createScope = () => {
16027
+ const scopeContexts = defaultContexts.map((defaultContext) => {
16028
+ return React.createContext(defaultContext);
16029
+ });
16030
+ return function useScope(scope) {
16031
+ const contexts = scope?.[scopeName] || scopeContexts;
16032
+ return React.useMemo(
16033
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
16034
+ [scope, contexts]
16035
+ );
16036
+ };
16037
+ };
16038
+ createScope.scopeName = scopeName;
16039
+ return [createContext3, composeContextScopes$1(createScope, ...createContextScopeDeps)];
16040
+ }
16041
+ function composeContextScopes$1(...scopes) {
16042
+ const baseScope = scopes[0];
16043
+ if (scopes.length === 1) return baseScope;
16044
+ const createScope = () => {
16045
+ const scopeHooks = scopes.map((createScope2) => ({
16046
+ useScope: createScope2(),
16047
+ scopeName: createScope2.scopeName
16048
+ }));
16049
+ return function useComposedScopes(overrideScopes) {
16050
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
16051
+ const scopeProps = useScope(overrideScopes);
16052
+ const currentScope = scopeProps[`__scope${scopeName}`];
16053
+ return { ...nextScopes2, ...currentScope };
16054
+ }, {});
16055
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
16056
+ };
16057
+ };
16058
+ createScope.scopeName = baseScope.scopeName;
16059
+ return createScope;
16060
+ }
16061
+
16062
+ // packages/react/use-callback-ref/src/useCallbackRef.tsx
16063
+ function useCallbackRef(callback) {
16064
+ const callbackRef = React.useRef(callback);
16065
+ React.useEffect(() => {
16066
+ callbackRef.current = callback;
16067
+ });
16068
+ return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
16069
+ }
16070
+
16071
+ // packages/react/use-controllable-state/src/useControllableState.tsx
16072
+ function useControllableState({
16073
+ prop,
16074
+ defaultProp,
16075
+ onChange = () => {
16076
+ }
16077
+ }) {
16078
+ const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });
16079
+ const isControlled = prop !== void 0;
16080
+ const value = isControlled ? prop : uncontrolledProp;
16081
+ const handleChange = useCallbackRef(onChange);
16082
+ const setValue = React.useCallback(
16083
+ (nextValue) => {
16084
+ if (isControlled) {
16085
+ const setter = nextValue;
16086
+ const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
16087
+ if (value2 !== prop) handleChange(value2);
16088
+ } else {
16089
+ setUncontrolledProp(nextValue);
16090
+ }
16091
+ },
16092
+ [isControlled, prop, setUncontrolledProp, handleChange]
16093
+ );
16094
+ return [value, setValue];
16095
+ }
16096
+ function useUncontrolledState({
16097
+ defaultProp,
16098
+ onChange
16099
+ }) {
16100
+ const uncontrolledState = React.useState(defaultProp);
16101
+ const [value] = uncontrolledState;
16102
+ const prevValueRef = React.useRef(value);
16103
+ const handleChange = useCallbackRef(onChange);
16104
+ React.useEffect(() => {
16105
+ if (prevValueRef.current !== value) {
16106
+ handleChange(value);
16107
+ prevValueRef.current = value;
16108
+ }
16109
+ }, [value, prevValueRef, handleChange]);
16110
+ return uncontrolledState;
16111
+ }
16112
+
16113
+ // packages/react/direction/src/Direction.tsx
16114
+ var DirectionContext = React.createContext(void 0);
16115
+ function useDirection(localDir) {
16116
+ const globalDir = React.useContext(DirectionContext);
16117
+ return localDir || globalDir || "ltr";
16118
+ }
16119
+
16120
+ // packages/react/use-previous/src/usePrevious.tsx
16121
+ function usePrevious(value) {
16122
+ const ref = React.useRef({ value, previous: value });
16123
+ return React.useMemo(() => {
16124
+ if (ref.current.value !== value) {
16125
+ ref.current.previous = ref.current.value;
16126
+ ref.current.value = value;
16127
+ }
16128
+ return ref.current.previous;
16129
+ }, [value]);
16130
+ }
16131
+
16132
+ // packages/react/use-layout-effect/src/useLayoutEffect.tsx
16133
+ var useLayoutEffect2 = Boolean(globalThis?.document) ? React.useLayoutEffect : () => {
16134
+ };
16135
+
16136
+ // packages/react/use-size/src/useSize.tsx
16137
+ function useSize(element) {
16138
+ const [size, setSize] = React.useState(void 0);
16139
+ useLayoutEffect2(() => {
16140
+ if (element) {
16141
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
16142
+ const resizeObserver = new ResizeObserver((entries) => {
16143
+ if (!Array.isArray(entries)) {
16144
+ return;
16145
+ }
16146
+ if (!entries.length) {
16147
+ return;
16148
+ }
16149
+ const entry = entries[0];
16150
+ let width;
16151
+ let height;
16152
+ if ("borderBoxSize" in entry) {
16153
+ const borderSizeEntry = entry["borderBoxSize"];
16154
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
16155
+ width = borderSize["inlineSize"];
16156
+ height = borderSize["blockSize"];
16157
+ } else {
16158
+ width = element.offsetWidth;
16159
+ height = element.offsetHeight;
16160
+ }
16161
+ setSize({ width, height });
16162
+ });
16163
+ resizeObserver.observe(element, { box: "border-box" });
16164
+ return () => resizeObserver.unobserve(element);
16165
+ } else {
16166
+ setSize(void 0);
16167
+ }
16168
+ }, [element]);
16169
+ return size;
16170
+ }
16171
+
16172
+ // packages/react/slot/src/Slot.tsx
16173
+ var Slot$1 = React.forwardRef((props, forwardedRef) => {
16174
+ const { children, ...slotProps } = props;
16175
+ const childrenArray = React.Children.toArray(children);
16176
+ const slottable = childrenArray.find(isSlottable$1);
16177
+ if (slottable) {
16178
+ const newElement = slottable.props.children;
16179
+ const newChildren = childrenArray.map((child) => {
16180
+ if (child === slottable) {
16181
+ if (React.Children.count(newElement) > 1) return React.Children.only(null);
16182
+ return React.isValidElement(newElement) ? newElement.props.children : null;
16183
+ } else {
16184
+ return child;
16185
+ }
16186
+ });
16187
+ return /* @__PURE__ */ jsx$1(SlotClone$1, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
16188
+ }
16189
+ return /* @__PURE__ */ jsx$1(SlotClone$1, { ...slotProps, ref: forwardedRef, children });
16190
+ });
16191
+ Slot$1.displayName = "Slot";
16192
+ var SlotClone$1 = React.forwardRef((props, forwardedRef) => {
16193
+ const { children, ...slotProps } = props;
16194
+ if (React.isValidElement(children)) {
16195
+ const childrenRef = getElementRef$1(children);
16196
+ return React.cloneElement(children, {
16197
+ ...mergeProps$1(slotProps, children.props),
16198
+ // @ts-ignore
16199
+ ref: forwardedRef ? composeRefs$1(forwardedRef, childrenRef) : childrenRef
16200
+ });
16201
+ }
16202
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
16203
+ });
16204
+ SlotClone$1.displayName = "SlotClone";
16205
+ var Slottable$1 = ({ children }) => {
16206
+ return /* @__PURE__ */ jsx$1(Fragment$1, { children });
16207
+ };
16208
+ function isSlottable$1(child) {
16209
+ return React.isValidElement(child) && child.type === Slottable$1;
16210
+ }
16211
+ function mergeProps$1(slotProps, childProps) {
16212
+ const overrideProps = { ...childProps };
16213
+ for (const propName in childProps) {
16214
+ const slotPropValue = slotProps[propName];
16215
+ const childPropValue = childProps[propName];
16216
+ const isHandler = /^on[A-Z]/.test(propName);
16217
+ if (isHandler) {
16218
+ if (slotPropValue && childPropValue) {
16219
+ overrideProps[propName] = (...args) => {
16220
+ childPropValue(...args);
16221
+ slotPropValue(...args);
16222
+ };
16223
+ } else if (slotPropValue) {
16224
+ overrideProps[propName] = slotPropValue;
16225
+ }
16226
+ } else if (propName === "style") {
16227
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
16228
+ } else if (propName === "className") {
16229
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
16230
+ }
16231
+ }
16232
+ return { ...slotProps, ...overrideProps };
16233
+ }
16234
+ function getElementRef$1(element) {
16235
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
16236
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
16237
+ if (mayWarn) {
16238
+ return element.ref;
16239
+ }
16240
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
16241
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
16242
+ if (mayWarn) {
16243
+ return element.props.ref;
16244
+ }
16245
+ return element.props.ref || element.ref;
16246
+ }
16247
+
16248
+ // packages/react/primitive/src/Primitive.tsx
16249
+ var NODES$1 = [
16250
+ "a",
16251
+ "button",
16252
+ "div",
16253
+ "form",
16254
+ "h2",
16255
+ "h3",
16256
+ "img",
16257
+ "input",
16258
+ "label",
16259
+ "li",
16260
+ "nav",
16261
+ "ol",
16262
+ "p",
16263
+ "span",
16264
+ "svg",
16265
+ "ul"
16266
+ ];
16267
+ var Primitive$1 = NODES$1.reduce((primitive, node) => {
16268
+ const Node = React.forwardRef((props, forwardedRef) => {
16269
+ const { asChild, ...primitiveProps } = props;
16270
+ const Comp = asChild ? Slot$1 : node;
16271
+ if (typeof window !== "undefined") {
16272
+ window[Symbol.for("radix-ui")] = true;
16273
+ }
16274
+ return /* @__PURE__ */ jsx$1(Comp, { ...primitiveProps, ref: forwardedRef });
16275
+ });
16276
+ Node.displayName = `Primitive.${node}`;
16277
+ return { ...primitive, [node]: Node };
16278
+ }, {});
16279
+
16280
+ function createCollection(name) {
16281
+ const PROVIDER_NAME = name + "CollectionProvider";
16282
+ const [createCollectionContext, createCollectionScope] = createContextScope$1(PROVIDER_NAME);
16283
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
16284
+ PROVIDER_NAME,
16285
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
16286
+ );
16287
+ const CollectionProvider = (props) => {
16288
+ const { scope, children } = props;
16289
+ const ref = React__default.useRef(null);
16290
+ const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
16291
+ return /* @__PURE__ */ jsx$1(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
16292
+ };
16293
+ CollectionProvider.displayName = PROVIDER_NAME;
16294
+ const COLLECTION_SLOT_NAME = name + "CollectionSlot";
16295
+ const CollectionSlot = React__default.forwardRef(
16296
+ (props, forwardedRef) => {
16297
+ const { scope, children } = props;
16298
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
16299
+ const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
16300
+ return /* @__PURE__ */ jsx$1(Slot$1, { ref: composedRefs, children });
16301
+ }
16302
+ );
16303
+ CollectionSlot.displayName = COLLECTION_SLOT_NAME;
16304
+ const ITEM_SLOT_NAME = name + "CollectionItemSlot";
16305
+ const ITEM_DATA_ATTR = "data-radix-collection-item";
16306
+ const CollectionItemSlot = React__default.forwardRef(
16307
+ (props, forwardedRef) => {
16308
+ const { scope, children, ...itemData } = props;
16309
+ const ref = React__default.useRef(null);
16310
+ const composedRefs = useComposedRefs(forwardedRef, ref);
16311
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
16312
+ React__default.useEffect(() => {
16313
+ context.itemMap.set(ref, { ref, ...itemData });
16314
+ return () => void context.itemMap.delete(ref);
16315
+ });
16316
+ return /* @__PURE__ */ jsx$1(Slot$1, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
16317
+ }
16318
+ );
16319
+ CollectionItemSlot.displayName = ITEM_SLOT_NAME;
16320
+ function useCollection(scope) {
16321
+ const context = useCollectionContext(name + "CollectionConsumer", scope);
16322
+ const getItems = React__default.useCallback(() => {
16323
+ const collectionNode = context.collectionRef.current;
16324
+ if (!collectionNode) return [];
16325
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
16326
+ const items = Array.from(context.itemMap.values());
16327
+ const orderedItems = items.sort(
16328
+ (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
16329
+ );
16330
+ return orderedItems;
16331
+ }, [context.collectionRef, context.itemMap]);
16332
+ return getItems;
16333
+ }
16334
+ return [
16335
+ { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
16336
+ useCollection,
16337
+ createCollectionScope
16338
+ ];
16339
+ }
16340
+
16341
+ var PAGE_KEYS = ["PageUp", "PageDown"];
16342
+ var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
16343
+ var BACK_KEYS = {
16344
+ "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
16345
+ "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
16346
+ "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
16347
+ "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
16348
+ };
16349
+ var SLIDER_NAME = "Slider";
16350
+ var [Collection, useCollection, createCollectionScope] = createCollection(SLIDER_NAME);
16351
+ var [createSliderContext, createSliderScope] = createContextScope$1(SLIDER_NAME, [
16352
+ createCollectionScope
16353
+ ]);
16354
+ var [SliderProvider, useSliderContext] = createSliderContext(SLIDER_NAME);
16355
+ var Slider$1 = React.forwardRef(
16356
+ (props, forwardedRef) => {
16357
+ const {
16358
+ name,
16359
+ min = 0,
16360
+ max = 100,
16361
+ step = 1,
16362
+ orientation = "horizontal",
16363
+ disabled = false,
16364
+ minStepsBetweenThumbs = 0,
16365
+ defaultValue = [min],
16366
+ value,
16367
+ onValueChange = () => {
16368
+ },
16369
+ onValueCommit = () => {
16370
+ },
16371
+ inverted = false,
16372
+ form,
16373
+ ...sliderProps
16374
+ } = props;
16375
+ const thumbRefs = React.useRef(/* @__PURE__ */ new Set());
16376
+ const valueIndexToChangeRef = React.useRef(0);
16377
+ const isHorizontal = orientation === "horizontal";
16378
+ const SliderOrientation = isHorizontal ? SliderHorizontal : SliderVertical;
16379
+ const [values = [], setValues] = useControllableState({
16380
+ prop: value,
16381
+ defaultProp: defaultValue,
16382
+ onChange: (value2) => {
16383
+ const thumbs = [...thumbRefs.current];
16384
+ thumbs[valueIndexToChangeRef.current]?.focus();
16385
+ onValueChange(value2);
16386
+ }
16387
+ });
16388
+ const valuesBeforeSlideStartRef = React.useRef(values);
16389
+ function handleSlideStart(value2) {
16390
+ const closestIndex = getClosestValueIndex(values, value2);
16391
+ updateValues(value2, closestIndex);
16392
+ }
16393
+ function handleSlideMove(value2) {
16394
+ updateValues(value2, valueIndexToChangeRef.current);
16395
+ }
16396
+ function handleSlideEnd() {
16397
+ const prevValue = valuesBeforeSlideStartRef.current[valueIndexToChangeRef.current];
16398
+ const nextValue = values[valueIndexToChangeRef.current];
16399
+ const hasChanged = nextValue !== prevValue;
16400
+ if (hasChanged) onValueCommit(values);
16401
+ }
16402
+ function updateValues(value2, atIndex, { commit } = { commit: false }) {
16403
+ const decimalCount = getDecimalCount(step);
16404
+ const snapToStep = roundValue(Math.round((value2 - min) / step) * step + min, decimalCount);
16405
+ const nextValue = clamp(snapToStep, [min, max]);
16406
+ setValues((prevValues = []) => {
16407
+ const nextValues = getNextSortedValues(prevValues, nextValue, atIndex);
16408
+ if (hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step)) {
16409
+ valueIndexToChangeRef.current = nextValues.indexOf(nextValue);
16410
+ const hasChanged = String(nextValues) !== String(prevValues);
16411
+ if (hasChanged && commit) onValueCommit(nextValues);
16412
+ return hasChanged ? nextValues : prevValues;
16413
+ } else {
16414
+ return prevValues;
16415
+ }
16416
+ });
16417
+ }
16418
+ return /* @__PURE__ */ jsx$1(
16419
+ SliderProvider,
16420
+ {
16421
+ scope: props.__scopeSlider,
16422
+ name,
16423
+ disabled,
16424
+ min,
16425
+ max,
16426
+ valueIndexToChangeRef,
16427
+ thumbs: thumbRefs.current,
16428
+ values,
16429
+ orientation,
16430
+ form,
16431
+ children: /* @__PURE__ */ jsx$1(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsx$1(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsx$1(
16432
+ SliderOrientation,
16433
+ {
16434
+ "aria-disabled": disabled,
16435
+ "data-disabled": disabled ? "" : void 0,
16436
+ ...sliderProps,
16437
+ ref: forwardedRef,
16438
+ onPointerDown: composeEventHandlers(sliderProps.onPointerDown, () => {
16439
+ if (!disabled) valuesBeforeSlideStartRef.current = values;
16440
+ }),
16441
+ min,
16442
+ max,
16443
+ inverted,
16444
+ onSlideStart: disabled ? void 0 : handleSlideStart,
16445
+ onSlideMove: disabled ? void 0 : handleSlideMove,
16446
+ onSlideEnd: disabled ? void 0 : handleSlideEnd,
16447
+ onHomeKeyDown: () => !disabled && updateValues(min, 0, { commit: true }),
16448
+ onEndKeyDown: () => !disabled && updateValues(max, values.length - 1, { commit: true }),
16449
+ onStepKeyDown: ({ event, direction: stepDirection }) => {
16450
+ if (!disabled) {
16451
+ const isPageKey = PAGE_KEYS.includes(event.key);
16452
+ const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.includes(event.key);
16453
+ const multiplier = isSkipKey ? 10 : 1;
16454
+ const atIndex = valueIndexToChangeRef.current;
16455
+ const value2 = values[atIndex];
16456
+ const stepInDirection = step * multiplier * stepDirection;
16457
+ updateValues(value2 + stepInDirection, atIndex, { commit: true });
16458
+ }
16459
+ }
16460
+ }
16461
+ ) }) })
16462
+ }
16463
+ );
16464
+ }
16465
+ );
16466
+ Slider$1.displayName = SLIDER_NAME;
16467
+ var [SliderOrientationProvider, useSliderOrientationContext] = createSliderContext(SLIDER_NAME, {
16468
+ startEdge: "left",
16469
+ endEdge: "right",
16470
+ size: "width",
16471
+ direction: 1
16472
+ });
16473
+ var SliderHorizontal = React.forwardRef(
16474
+ (props, forwardedRef) => {
16475
+ const {
16476
+ min,
16477
+ max,
16478
+ dir,
16479
+ inverted,
16480
+ onSlideStart,
16481
+ onSlideMove,
16482
+ onSlideEnd,
16483
+ onStepKeyDown,
16484
+ ...sliderProps
16485
+ } = props;
16486
+ const [slider, setSlider] = React.useState(null);
16487
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setSlider(node));
16488
+ const rectRef = React.useRef(void 0);
16489
+ const direction = useDirection(dir);
16490
+ const isDirectionLTR = direction === "ltr";
16491
+ const isSlidingFromLeft = isDirectionLTR && !inverted || !isDirectionLTR && inverted;
16492
+ function getValueFromPointer(pointerPosition) {
16493
+ const rect = rectRef.current || slider.getBoundingClientRect();
16494
+ const input = [0, rect.width];
16495
+ const output = isSlidingFromLeft ? [min, max] : [max, min];
16496
+ const value = linearScale(input, output);
16497
+ rectRef.current = rect;
16498
+ return value(pointerPosition - rect.left);
16499
+ }
16500
+ return /* @__PURE__ */ jsx$1(
16501
+ SliderOrientationProvider,
16502
+ {
16503
+ scope: props.__scopeSlider,
16504
+ startEdge: isSlidingFromLeft ? "left" : "right",
16505
+ endEdge: isSlidingFromLeft ? "right" : "left",
16506
+ direction: isSlidingFromLeft ? 1 : -1,
16507
+ size: "width",
16508
+ children: /* @__PURE__ */ jsx$1(
16509
+ SliderImpl,
16510
+ {
16511
+ dir: direction,
16512
+ "data-orientation": "horizontal",
16513
+ ...sliderProps,
16514
+ ref: composedRefs,
16515
+ style: {
16516
+ ...sliderProps.style,
16517
+ ["--radix-slider-thumb-transform"]: "translateX(-50%)"
16518
+ },
16519
+ onSlideStart: (event) => {
16520
+ const value = getValueFromPointer(event.clientX);
16521
+ onSlideStart?.(value);
16522
+ },
16523
+ onSlideMove: (event) => {
16524
+ const value = getValueFromPointer(event.clientX);
16525
+ onSlideMove?.(value);
16526
+ },
16527
+ onSlideEnd: () => {
16528
+ rectRef.current = void 0;
16529
+ onSlideEnd?.();
16530
+ },
16531
+ onStepKeyDown: (event) => {
16532
+ const slideDirection = isSlidingFromLeft ? "from-left" : "from-right";
16533
+ const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
16534
+ onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 });
16535
+ }
16536
+ }
16537
+ )
16538
+ }
16539
+ );
16540
+ }
16541
+ );
16542
+ var SliderVertical = React.forwardRef(
16543
+ (props, forwardedRef) => {
16544
+ const {
16545
+ min,
16546
+ max,
16547
+ inverted,
16548
+ onSlideStart,
16549
+ onSlideMove,
16550
+ onSlideEnd,
16551
+ onStepKeyDown,
16552
+ ...sliderProps
16553
+ } = props;
16554
+ const sliderRef = React.useRef(null);
16555
+ const ref = useComposedRefs(forwardedRef, sliderRef);
16556
+ const rectRef = React.useRef(void 0);
16557
+ const isSlidingFromBottom = !inverted;
16558
+ function getValueFromPointer(pointerPosition) {
16559
+ const rect = rectRef.current || sliderRef.current.getBoundingClientRect();
16560
+ const input = [0, rect.height];
16561
+ const output = isSlidingFromBottom ? [max, min] : [min, max];
16562
+ const value = linearScale(input, output);
16563
+ rectRef.current = rect;
16564
+ return value(pointerPosition - rect.top);
16565
+ }
16566
+ return /* @__PURE__ */ jsx$1(
16567
+ SliderOrientationProvider,
16568
+ {
16569
+ scope: props.__scopeSlider,
16570
+ startEdge: isSlidingFromBottom ? "bottom" : "top",
16571
+ endEdge: isSlidingFromBottom ? "top" : "bottom",
16572
+ size: "height",
16573
+ direction: isSlidingFromBottom ? 1 : -1,
16574
+ children: /* @__PURE__ */ jsx$1(
16575
+ SliderImpl,
16576
+ {
16577
+ "data-orientation": "vertical",
16578
+ ...sliderProps,
16579
+ ref,
16580
+ style: {
16581
+ ...sliderProps.style,
16582
+ ["--radix-slider-thumb-transform"]: "translateY(50%)"
16583
+ },
16584
+ onSlideStart: (event) => {
16585
+ const value = getValueFromPointer(event.clientY);
16586
+ onSlideStart?.(value);
16587
+ },
16588
+ onSlideMove: (event) => {
16589
+ const value = getValueFromPointer(event.clientY);
16590
+ onSlideMove?.(value);
16591
+ },
16592
+ onSlideEnd: () => {
16593
+ rectRef.current = void 0;
16594
+ onSlideEnd?.();
16595
+ },
16596
+ onStepKeyDown: (event) => {
16597
+ const slideDirection = isSlidingFromBottom ? "from-bottom" : "from-top";
16598
+ const isBackKey = BACK_KEYS[slideDirection].includes(event.key);
16599
+ onStepKeyDown?.({ event, direction: isBackKey ? -1 : 1 });
16600
+ }
16601
+ }
16602
+ )
16603
+ }
16604
+ );
16605
+ }
16606
+ );
16607
+ var SliderImpl = React.forwardRef(
16608
+ (props, forwardedRef) => {
16609
+ const {
16610
+ __scopeSlider,
16611
+ onSlideStart,
16612
+ onSlideMove,
16613
+ onSlideEnd,
16614
+ onHomeKeyDown,
16615
+ onEndKeyDown,
16616
+ onStepKeyDown,
16617
+ ...sliderProps
16618
+ } = props;
16619
+ const context = useSliderContext(SLIDER_NAME, __scopeSlider);
16620
+ return /* @__PURE__ */ jsx$1(
16621
+ Primitive$1.span,
16622
+ {
16623
+ ...sliderProps,
16624
+ ref: forwardedRef,
16625
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
16626
+ if (event.key === "Home") {
16627
+ onHomeKeyDown(event);
16628
+ event.preventDefault();
16629
+ } else if (event.key === "End") {
16630
+ onEndKeyDown(event);
16631
+ event.preventDefault();
16632
+ } else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {
16633
+ onStepKeyDown(event);
16634
+ event.preventDefault();
16635
+ }
16636
+ }),
16637
+ onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
16638
+ const target = event.target;
16639
+ target.setPointerCapture(event.pointerId);
16640
+ event.preventDefault();
16641
+ if (context.thumbs.has(target)) {
16642
+ target.focus();
16643
+ } else {
16644
+ onSlideStart(event);
16645
+ }
16646
+ }),
16647
+ onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
16648
+ const target = event.target;
16649
+ if (target.hasPointerCapture(event.pointerId)) onSlideMove(event);
16650
+ }),
16651
+ onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
16652
+ const target = event.target;
16653
+ if (target.hasPointerCapture(event.pointerId)) {
16654
+ target.releasePointerCapture(event.pointerId);
16655
+ onSlideEnd(event);
16656
+ }
16657
+ })
16658
+ }
16659
+ );
16660
+ }
16661
+ );
16662
+ var TRACK_NAME = "SliderTrack";
16663
+ var SliderTrack = React.forwardRef(
16664
+ (props, forwardedRef) => {
16665
+ const { __scopeSlider, ...trackProps } = props;
16666
+ const context = useSliderContext(TRACK_NAME, __scopeSlider);
16667
+ return /* @__PURE__ */ jsx$1(
16668
+ Primitive$1.span,
16669
+ {
16670
+ "data-disabled": context.disabled ? "" : void 0,
16671
+ "data-orientation": context.orientation,
16672
+ ...trackProps,
16673
+ ref: forwardedRef
16674
+ }
16675
+ );
16676
+ }
16677
+ );
16678
+ SliderTrack.displayName = TRACK_NAME;
16679
+ var RANGE_NAME = "SliderRange";
16680
+ var SliderRange = React.forwardRef(
16681
+ (props, forwardedRef) => {
16682
+ const { __scopeSlider, ...rangeProps } = props;
16683
+ const context = useSliderContext(RANGE_NAME, __scopeSlider);
16684
+ const orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider);
16685
+ const ref = React.useRef(null);
16686
+ const composedRefs = useComposedRefs(forwardedRef, ref);
16687
+ const valuesCount = context.values.length;
16688
+ const percentages = context.values.map(
16689
+ (value) => convertValueToPercentage(value, context.min, context.max)
16690
+ );
16691
+ const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
16692
+ const offsetEnd = 100 - Math.max(...percentages);
16693
+ return /* @__PURE__ */ jsx$1(
16694
+ Primitive$1.span,
16695
+ {
16696
+ "data-orientation": context.orientation,
16697
+ "data-disabled": context.disabled ? "" : void 0,
16698
+ ...rangeProps,
16699
+ ref: composedRefs,
16700
+ style: {
16701
+ ...props.style,
16702
+ [orientation.startEdge]: offsetStart + "%",
16703
+ [orientation.endEdge]: offsetEnd + "%"
16704
+ }
16705
+ }
16706
+ );
16707
+ }
16708
+ );
16709
+ SliderRange.displayName = RANGE_NAME;
16710
+ var THUMB_NAME = "SliderThumb";
16711
+ var SliderThumb = React.forwardRef(
16712
+ (props, forwardedRef) => {
16713
+ const getItems = useCollection(props.__scopeSlider);
16714
+ const [thumb, setThumb] = React.useState(null);
16715
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
16716
+ const index = React.useMemo(
16717
+ () => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
16718
+ [getItems, thumb]
16719
+ );
16720
+ return /* @__PURE__ */ jsx$1(SliderThumbImpl, { ...props, ref: composedRefs, index });
16721
+ }
16722
+ );
16723
+ var SliderThumbImpl = React.forwardRef(
16724
+ (props, forwardedRef) => {
16725
+ const { __scopeSlider, index, name, ...thumbProps } = props;
16726
+ const context = useSliderContext(THUMB_NAME, __scopeSlider);
16727
+ const orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider);
16728
+ const [thumb, setThumb] = React.useState(null);
16729
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setThumb(node));
16730
+ const isFormControl = thumb ? context.form || !!thumb.closest("form") : true;
16731
+ const size = useSize(thumb);
16732
+ const value = context.values[index];
16733
+ const percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max);
16734
+ const label = getLabel(index, context.values.length);
16735
+ const orientationSize = size?.[orientation.size];
16736
+ const thumbInBoundsOffset = orientationSize ? getThumbInBoundsOffset(orientationSize, percent, orientation.direction) : 0;
16737
+ React.useEffect(() => {
16738
+ if (thumb) {
16739
+ context.thumbs.add(thumb);
16740
+ return () => {
16741
+ context.thumbs.delete(thumb);
16742
+ };
16743
+ }
16744
+ }, [thumb, context.thumbs]);
16745
+ return /* @__PURE__ */ jsxs(
16746
+ "span",
16747
+ {
16748
+ style: {
16749
+ transform: "var(--radix-slider-thumb-transform)",
16750
+ position: "absolute",
16751
+ [orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
16752
+ },
16753
+ children: [
16754
+ /* @__PURE__ */ jsx$1(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ jsx$1(
16755
+ Primitive$1.span,
16756
+ {
16757
+ role: "slider",
16758
+ "aria-label": props["aria-label"] || label,
16759
+ "aria-valuemin": context.min,
16760
+ "aria-valuenow": value,
16761
+ "aria-valuemax": context.max,
16762
+ "aria-orientation": context.orientation,
16763
+ "data-orientation": context.orientation,
16764
+ "data-disabled": context.disabled ? "" : void 0,
16765
+ tabIndex: context.disabled ? void 0 : 0,
16766
+ ...thumbProps,
16767
+ ref: composedRefs,
16768
+ style: value === void 0 ? { display: "none" } : props.style,
16769
+ onFocus: composeEventHandlers(props.onFocus, () => {
16770
+ context.valueIndexToChangeRef.current = index;
16771
+ })
16772
+ }
16773
+ ) }),
16774
+ isFormControl && /* @__PURE__ */ jsx$1(
16775
+ BubbleInput,
16776
+ {
16777
+ name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
16778
+ form: context.form,
16779
+ value
16780
+ },
16781
+ index
16782
+ )
16783
+ ]
16784
+ }
16785
+ );
16786
+ }
16787
+ );
16788
+ SliderThumb.displayName = THUMB_NAME;
16789
+ var BubbleInput = (props) => {
16790
+ const { value, ...inputProps } = props;
16791
+ const ref = React.useRef(null);
16792
+ const prevValue = usePrevious(value);
16793
+ React.useEffect(() => {
16794
+ const input = ref.current;
16795
+ const inputProto = window.HTMLInputElement.prototype;
16796
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "value");
16797
+ const setValue = descriptor.set;
16798
+ if (prevValue !== value && setValue) {
16799
+ const event = new Event("input", { bubbles: true });
16800
+ setValue.call(input, value);
16801
+ input.dispatchEvent(event);
16802
+ }
16803
+ }, [prevValue, value]);
16804
+ return /* @__PURE__ */ jsx$1("input", { style: { display: "none" }, ...inputProps, ref, defaultValue: value });
16805
+ };
16806
+ function getNextSortedValues(prevValues = [], nextValue, atIndex) {
16807
+ const nextValues = [...prevValues];
16808
+ nextValues[atIndex] = nextValue;
16809
+ return nextValues.sort((a, b) => a - b);
16810
+ }
16811
+ function convertValueToPercentage(value, min, max) {
16812
+ const maxSteps = max - min;
16813
+ const percentPerStep = 100 / maxSteps;
16814
+ const percentage = percentPerStep * (value - min);
16815
+ return clamp(percentage, [0, 100]);
16816
+ }
16817
+ function getLabel(index, totalValues) {
16818
+ if (totalValues > 2) {
16819
+ return `Value ${index + 1} of ${totalValues}`;
16820
+ } else if (totalValues === 2) {
16821
+ return ["Minimum", "Maximum"][index];
16822
+ } else {
16823
+ return void 0;
16824
+ }
16825
+ }
16826
+ function getClosestValueIndex(values, nextValue) {
16827
+ if (values.length === 1) return 0;
16828
+ const distances = values.map((value) => Math.abs(value - nextValue));
16829
+ const closestDistance = Math.min(...distances);
16830
+ return distances.indexOf(closestDistance);
16831
+ }
16832
+ function getThumbInBoundsOffset(width, left, direction) {
16833
+ const halfWidth = width / 2;
16834
+ const halfPercent = 50;
16835
+ const offset = linearScale([0, halfPercent], [0, halfWidth]);
16836
+ return (halfWidth - offset(left) * direction) * direction;
16837
+ }
16838
+ function getStepsBetweenValues(values) {
16839
+ return values.slice(0, -1).map((value, index) => values[index + 1] - value);
16840
+ }
16841
+ function hasMinStepsBetweenValues(values, minStepsBetweenValues) {
16842
+ if (minStepsBetweenValues > 0) {
16843
+ const stepsBetweenValues = getStepsBetweenValues(values);
16844
+ const actualMinStepsBetweenValues = Math.min(...stepsBetweenValues);
16845
+ return actualMinStepsBetweenValues >= minStepsBetweenValues;
16846
+ }
16847
+ return true;
16848
+ }
16849
+ function linearScale(input, output) {
16850
+ return (value) => {
16851
+ if (input[0] === input[1] || output[0] === output[1]) return output[0];
16852
+ const ratio = (output[1] - output[0]) / (input[1] - input[0]);
16853
+ return output[0] + ratio * (value - input[0]);
16854
+ };
16855
+ }
16856
+ function getDecimalCount(value) {
16857
+ return (String(value).split(".")[1] || "").length;
16858
+ }
16859
+ function roundValue(value, decimalCount) {
16860
+ const rounder = Math.pow(10, decimalCount);
16861
+ return Math.round(value * rounder) / rounder;
16862
+ }
16863
+ var Root$1 = Slider$1;
16864
+ var Track = SliderTrack;
16865
+ var Range = SliderRange;
16866
+ var Thumb = SliderThumb;
16867
+
16868
+ /**
16869
+ * Slider .
16870
+ */
16871
+ const Slider = (props) => {
16872
+ const { onValueChange, onPointerUp, id, value, name, disabled = false, rootExtraClassNames = '', trackExtraClassNames = '', rangeExtraClassNames = '', thumbExtraClassNames = '', step, min, max, } = props;
16873
+ 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 },
16874
+ 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}` },
16875
+ React__default.createElement(Range, { className: `tw-absolute tw-h-full tw-rounded-full ${rangeExtraClassNames}` })),
16876
+ 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 })));
15949
16877
  };
15950
16878
 
15951
16879
  // packages/react/context/src/createContext.tsx
@@ -16235,17 +17163,17 @@ Defaulting to \`null\`.`;
16235
17163
  var Root = Progress;
16236
17164
  var Indicator = ProgressIndicator;
16237
17165
 
16238
- const ProgressBar = ({ value, max = 100, label, extraClasses }) => {
17166
+ const ProgressBar = ({ value, max = 100, label, extraClasses, testId }) => {
16239
17167
  const tooltipData = getQTipData({ tooltip: label });
16240
17168
  const [progress, setProgress] = React__default.useState(0);
16241
17169
  React__default.useEffect(() => {
16242
17170
  const timer = setTimeout(() => setProgress(value), 500);
16243
17171
  return () => clearTimeout(timer);
16244
17172
  }, []);
16245
- return (React__default.createElement("span", { ...tooltipData },
17173
+ return (React__default.createElement("span", { "data-testid": testId, ...tooltipData },
16246
17174
  React__default.createElement(Root, { className: "tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray", max: max, value: value },
16247
17175
  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}%)` } }))));
16248
17176
  };
16249
17177
 
16250
- export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Icon, InputGroup, Modal, ProgressBar, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
17178
+ export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Icon, InputGroup, Modal, ProgressBar, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Slider, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
16251
17179
  //# sourceMappingURL=index.esm.js.map