@seeqdev/qomponents 0.0.41 → 0.0.42

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 (117) hide show
  1. package/README.md +135 -135
  2. package/dist/Tabs/Tabs.d.ts +4 -0
  3. package/dist/Tabs/Tabs.stories.d.ts +5 -0
  4. package/dist/Tabs/Tabs.test.d.ts +1 -0
  5. package/dist/Tabs/Tabs.types.d.ts +18 -0
  6. package/dist/Tabs/index.d.ts +1 -0
  7. package/dist/example/.eslintrc.cjs +14 -14
  8. package/dist/example/README.md +33 -33
  9. package/dist/example/index.html +13 -13
  10. package/dist/example/package.json +30 -30
  11. package/dist/example/src/ComplexSelectExample.tsx +81 -81
  12. package/dist/example/src/Example.tsx +167 -167
  13. package/dist/example/src/index.css +102 -102
  14. package/dist/example/src/main.tsx +10 -10
  15. package/dist/example/src/vite-env.d.ts +1 -1
  16. package/dist/example/tsconfig.json +33 -33
  17. package/dist/example/tsconfig.node.json +12 -12
  18. package/dist/example/vite.config.ts +12 -12
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.esm.js +486 -7
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.js +486 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/styles.css +2726 -2644
  25. package/package.json +80 -79
  26. package/dist/Button/Button.js +0 -87
  27. package/dist/Button/Button.js.map +0 -1
  28. package/dist/Button/Button.stories.js +0 -77
  29. package/dist/Button/Button.stories.js.map +0 -1
  30. package/dist/Button/Button.test.js +0 -49
  31. package/dist/Button/Button.test.js.map +0 -1
  32. package/dist/Button/Button.types.js +0 -4
  33. package/dist/Button/Button.types.js.map +0 -1
  34. package/dist/Button/index.js +0 -2
  35. package/dist/Button/index.js.map +0 -1
  36. package/dist/Checkbox/Checkbox.js +0 -24
  37. package/dist/Checkbox/Checkbox.js.map +0 -1
  38. package/dist/Checkbox/Checkbox.stories.js +0 -32
  39. package/dist/Checkbox/Checkbox.stories.js.map +0 -1
  40. package/dist/Checkbox/Checkbox.test.js +0 -94
  41. package/dist/Checkbox/Checkbox.test.js.map +0 -1
  42. package/dist/Checkbox/Checkbox.types.js +0 -2
  43. package/dist/Checkbox/Checkbox.types.js.map +0 -1
  44. package/dist/Checkbox/index.js +0 -2
  45. package/dist/Checkbox/index.js.map +0 -1
  46. package/dist/Icon/Icon.js +0 -63
  47. package/dist/Icon/Icon.js.map +0 -1
  48. package/dist/Icon/Icon.stories.js +0 -40
  49. package/dist/Icon/Icon.stories.js.map +0 -1
  50. package/dist/Icon/Icon.test.js +0 -55
  51. package/dist/Icon/Icon.test.js.map +0 -1
  52. package/dist/Icon/Icon.types.js +0 -16
  53. package/dist/Icon/Icon.types.js.map +0 -1
  54. package/dist/Icon/index.js +0 -2
  55. package/dist/Icon/index.js.map +0 -1
  56. package/dist/Select/Select.js +0 -168
  57. package/dist/Select/Select.js.map +0 -1
  58. package/dist/Select/Select.stories.js +0 -72
  59. package/dist/Select/Select.stories.js.map +0 -1
  60. package/dist/Select/Select.test.js +0 -161
  61. package/dist/Select/Select.test.js.map +0 -1
  62. package/dist/Select/Select.types.js +0 -2
  63. package/dist/Select/Select.types.js.map +0 -1
  64. package/dist/Select/index.js +0 -2
  65. package/dist/Select/index.js.map +0 -1
  66. package/dist/TextArea/TextArea.js +0 -23
  67. package/dist/TextArea/TextArea.js.map +0 -1
  68. package/dist/TextArea/TextArea.stories.js +0 -39
  69. package/dist/TextArea/TextArea.stories.js.map +0 -1
  70. package/dist/TextArea/TextArea.test.js +0 -68
  71. package/dist/TextArea/TextArea.test.js.map +0 -1
  72. package/dist/TextArea/TextArea.types.js +0 -2
  73. package/dist/TextArea/TextArea.types.js.map +0 -1
  74. package/dist/TextArea/index.js +0 -2
  75. package/dist/TextArea/index.js.map +0 -1
  76. package/dist/TextField/TextField.js +0 -64
  77. package/dist/TextField/TextField.js.map +0 -1
  78. package/dist/TextField/TextField.stories.js +0 -41
  79. package/dist/TextField/TextField.stories.js.map +0 -1
  80. package/dist/TextField/TextField.test.js +0 -35
  81. package/dist/TextField/TextField.test.js.map +0 -1
  82. package/dist/TextField/TextField.types.js +0 -2
  83. package/dist/TextField/TextField.types.js.map +0 -1
  84. package/dist/TextField/index.js +0 -2
  85. package/dist/TextField/index.js.map +0 -1
  86. package/dist/ToolbarButton/ToolbarButton.js +0 -74
  87. package/dist/ToolbarButton/ToolbarButton.js.map +0 -1
  88. package/dist/ToolbarButton/ToolbarButton.stories.js +0 -79
  89. package/dist/ToolbarButton/ToolbarButton.stories.js.map +0 -1
  90. package/dist/ToolbarButton/ToolbarButton.test.js +0 -93
  91. package/dist/ToolbarButton/ToolbarButton.test.js.map +0 -1
  92. package/dist/ToolbarButton/ToolbarButton.types.js +0 -2
  93. package/dist/ToolbarButton/ToolbarButton.types.js.map +0 -1
  94. package/dist/ToolbarButton/index.js +0 -2
  95. package/dist/ToolbarButton/index.js.map +0 -1
  96. package/dist/Tooltip/QTip.stories.js +0 -40
  97. package/dist/Tooltip/QTip.stories.js.map +0 -1
  98. package/dist/Tooltip/QTip.types.js +0 -2
  99. package/dist/Tooltip/QTip.types.js.map +0 -1
  100. package/dist/Tooltip/QTipPerformance.stories.js +0 -30
  101. package/dist/Tooltip/QTipPerformance.stories.js.map +0 -1
  102. package/dist/Tooltip/Qtip.js +0 -148
  103. package/dist/Tooltip/Qtip.js.map +0 -1
  104. package/dist/Tooltip/Tooltip.js +0 -36
  105. package/dist/Tooltip/Tooltip.js.map +0 -1
  106. package/dist/Tooltip/Tooltip.stories.js +0 -32
  107. package/dist/Tooltip/Tooltip.stories.js.map +0 -1
  108. package/dist/Tooltip/Tooltip.types.js +0 -3
  109. package/dist/Tooltip/Tooltip.types.js.map +0 -1
  110. package/dist/Tooltip/TooltipPerformance.stories.js +0 -30
  111. package/dist/Tooltip/TooltipPerformance.stories.js.map +0 -1
  112. package/dist/Tooltip/index.js +0 -3
  113. package/dist/Tooltip/index.js.map +0 -1
  114. package/dist/types.js +0 -2
  115. package/dist/types.js.map +0 -1
  116. package/dist/utils/browserId.js +0 -29
  117. package/dist/utils/browserId.js.map +0 -1
package/dist/index.js CHANGED
@@ -98,7 +98,7 @@ const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClas
98
98
  const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
99
99
  const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
100
100
  const style = type === 'color' && color ? { color } : {};
101
- const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
101
+ const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
102
102
  ${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
103
103
  const tooltipData = tooltip
104
104
  ? {
@@ -4673,13 +4673,13 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
4673
4673
  const arrowBaseClasses = 'before:tw-content-[\'\'] before:tw-absolute before:tw-border-8';
4674
4674
  const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
4675
4675
  const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
4676
- const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
4676
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
4677
4677
  before:tw-border-l-transparent before:tw-border-r-black`;
4678
- const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
4678
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
4679
4679
  before:tw-border-l-black before:tw-border-r-transparent`;
4680
- const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
4680
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
4681
4681
  before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
4682
- const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
4682
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
4683
4683
  before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
4684
4684
  const placements = {
4685
4685
  top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
@@ -4689,7 +4689,7 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
4689
4689
  };
4690
4690
  return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
4691
4691
  children,
4692
- React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
4692
+ React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
4693
4693
  tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
4694
4694
  };
4695
4695
 
@@ -13689,11 +13689,491 @@ const Select = ({ options, value, placeholder = 'select', noOptionsMessage = 'no
13689
13689
  return creatable ? React.createElement(CreatableSelect$1, { ...props }) : React.createElement(StateManagedSelect$1, { ...props });
13690
13690
  };
13691
13691
 
13692
+ // We have resorted to returning slots directly rather than exposing primitives that can then
13693
+ // be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.
13694
+ // This is because we encountered issues with generic types that cannot be statically analysed
13695
+ // due to creating them dynamically via createCollection.
13696
+ function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
13697
+ /* -----------------------------------------------------------------------------------------------
13698
+ * CollectionProvider
13699
+ * ---------------------------------------------------------------------------------------------*/ const PROVIDER_NAME = name + 'CollectionProvider';
13700
+ const [createCollectionContext, createCollectionScope] = $c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
13701
+ const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
13702
+ collectionRef: {
13703
+ current: null
13704
+ },
13705
+ itemMap: new Map()
13706
+ });
13707
+ const CollectionProvider = (props)=>{
13708
+ const { scope: scope , children: children } = props;
13709
+ const ref = React.useRef(null);
13710
+ const itemMap = React.useRef(new Map()).current;
13711
+ return /*#__PURE__*/ React.createElement(CollectionProviderImpl, {
13712
+ scope: scope,
13713
+ itemMap: itemMap,
13714
+ collectionRef: ref
13715
+ }, children);
13716
+ };
13717
+ /* -----------------------------------------------------------------------------------------------
13718
+ * CollectionSlot
13719
+ * ---------------------------------------------------------------------------------------------*/ const COLLECTION_SLOT_NAME = name + 'CollectionSlot';
13720
+ const CollectionSlot = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
13721
+ const { scope: scope , children: children } = props;
13722
+ const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
13723
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, context.collectionRef);
13724
+ return /*#__PURE__*/ React.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
13725
+ ref: composedRefs
13726
+ }, children);
13727
+ });
13728
+ /* -----------------------------------------------------------------------------------------------
13729
+ * CollectionItem
13730
+ * ---------------------------------------------------------------------------------------------*/ const ITEM_SLOT_NAME = name + 'CollectionItemSlot';
13731
+ const ITEM_DATA_ATTR = 'data-radix-collection-item';
13732
+ const CollectionItemSlot = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
13733
+ const { scope: scope , children: children , ...itemData } = props;
13734
+ const ref = React.useRef(null);
13735
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
13736
+ const context = useCollectionContext(ITEM_SLOT_NAME, scope);
13737
+ React.useEffect(()=>{
13738
+ context.itemMap.set(ref, {
13739
+ ref: ref,
13740
+ ...itemData
13741
+ });
13742
+ return ()=>void context.itemMap.delete(ref)
13743
+ ;
13744
+ });
13745
+ return /*#__PURE__*/ React.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, {
13746
+ [ITEM_DATA_ATTR]: '',
13747
+ ref: composedRefs
13748
+ }, children);
13749
+ });
13750
+ /* -----------------------------------------------------------------------------------------------
13751
+ * useCollection
13752
+ * ---------------------------------------------------------------------------------------------*/ function useCollection(scope) {
13753
+ const context = useCollectionContext(name + 'CollectionConsumer', scope);
13754
+ const getItems = React.useCallback(()=>{
13755
+ const collectionNode = context.collectionRef.current;
13756
+ if (!collectionNode) return [];
13757
+ const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
13758
+ const items = Array.from(context.itemMap.values());
13759
+ const orderedItems = items.sort((a, b)=>orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
13760
+ );
13761
+ return orderedItems;
13762
+ }, [
13763
+ context.collectionRef,
13764
+ context.itemMap
13765
+ ]);
13766
+ return getItems;
13767
+ }
13768
+ return [
13769
+ {
13770
+ Provider: CollectionProvider,
13771
+ Slot: CollectionSlot,
13772
+ ItemSlot: CollectionItemSlot
13773
+ },
13774
+ useCollection,
13775
+ createCollectionScope
13776
+ ];
13777
+ }
13778
+
13779
+ const $f631663db3294ace$var$DirectionContext = /*#__PURE__*/ React.createContext(undefined);
13780
+ /* -----------------------------------------------------------------------------------------------*/ function $f631663db3294ace$export$b39126d51d94e6f3(localDir) {
13781
+ const globalDir = React.useContext($f631663db3294ace$var$DirectionContext);
13782
+ return localDir || globalDir || 'ltr';
13783
+ }
13784
+
13785
+ const $d7bdfb9eb0fdf311$var$ENTRY_FOCUS = 'rovingFocusGroup.onEntryFocus';
13786
+ const $d7bdfb9eb0fdf311$var$EVENT_OPTIONS = {
13787
+ bubbles: false,
13788
+ cancelable: true
13789
+ };
13790
+ /* -------------------------------------------------------------------------------------------------
13791
+ * RovingFocusGroup
13792
+ * -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$GROUP_NAME = 'RovingFocusGroup';
13793
+ const [$d7bdfb9eb0fdf311$var$Collection, $d7bdfb9eb0fdf311$var$useCollection, $d7bdfb9eb0fdf311$var$createCollectionScope] = $e02a7d9cb1dc128c$export$c74125a8e3af6bb2($d7bdfb9eb0fdf311$var$GROUP_NAME);
13794
+ const [$d7bdfb9eb0fdf311$var$createRovingFocusGroupContext, $d7bdfb9eb0fdf311$export$c7109489551a4f4] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($d7bdfb9eb0fdf311$var$GROUP_NAME, [
13795
+ $d7bdfb9eb0fdf311$var$createCollectionScope
13796
+ ]);
13797
+ const [$d7bdfb9eb0fdf311$var$RovingFocusProvider, $d7bdfb9eb0fdf311$var$useRovingFocusContext] = $d7bdfb9eb0fdf311$var$createRovingFocusGroupContext($d7bdfb9eb0fdf311$var$GROUP_NAME);
13798
+ const $d7bdfb9eb0fdf311$export$8699f7c8af148338 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
13799
+ return /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$var$Collection.Provider, {
13800
+ scope: props.__scopeRovingFocusGroup
13801
+ }, /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$var$Collection.Slot, {
13802
+ scope: props.__scopeRovingFocusGroup
13803
+ }, /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$var$RovingFocusGroupImpl, _extends({}, props, {
13804
+ ref: forwardedRef
13805
+ }))));
13806
+ });
13807
+ /* -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$RovingFocusGroupImpl = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
13808
+ const { __scopeRovingFocusGroup: __scopeRovingFocusGroup , orientation: orientation , loop: loop = false , dir: dir , currentTabStopId: currentTabStopIdProp , defaultCurrentTabStopId: defaultCurrentTabStopId , onCurrentTabStopIdChange: onCurrentTabStopIdChange , onEntryFocus: onEntryFocus , ...groupProps } = props;
13809
+ const ref = React.useRef(null);
13810
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(forwardedRef, ref);
13811
+ const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
13812
+ const [currentTabStopId = null, setCurrentTabStopId] = $71cd76cc60e0454e$export$6f32135080cb4c3({
13813
+ prop: currentTabStopIdProp,
13814
+ defaultProp: defaultCurrentTabStopId,
13815
+ onChange: onCurrentTabStopIdChange
13816
+ });
13817
+ const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
13818
+ const handleEntryFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEntryFocus);
13819
+ const getItems = $d7bdfb9eb0fdf311$var$useCollection(__scopeRovingFocusGroup);
13820
+ const isClickFocusRef = React.useRef(false);
13821
+ const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
13822
+ React.useEffect(()=>{
13823
+ const node = ref.current;
13824
+ if (node) {
13825
+ node.addEventListener($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, handleEntryFocus);
13826
+ return ()=>node.removeEventListener($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, handleEntryFocus)
13827
+ ;
13828
+ }
13829
+ }, [
13830
+ handleEntryFocus
13831
+ ]);
13832
+ return /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$var$RovingFocusProvider, {
13833
+ scope: __scopeRovingFocusGroup,
13834
+ orientation: orientation,
13835
+ dir: direction,
13836
+ loop: loop,
13837
+ currentTabStopId: currentTabStopId,
13838
+ onItemFocus: React.useCallback((tabStopId)=>setCurrentTabStopId(tabStopId)
13839
+ , [
13840
+ setCurrentTabStopId
13841
+ ]),
13842
+ onItemShiftTab: React.useCallback(()=>setIsTabbingBackOut(true)
13843
+ , []),
13844
+ onFocusableItemAdd: React.useCallback(()=>setFocusableItemsCount((prevCount)=>prevCount + 1
13845
+ )
13846
+ , []),
13847
+ onFocusableItemRemove: React.useCallback(()=>setFocusableItemsCount((prevCount)=>prevCount - 1
13848
+ )
13849
+ , [])
13850
+ }, /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
13851
+ tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
13852
+ "data-orientation": orientation
13853
+ }, groupProps, {
13854
+ ref: composedRefs,
13855
+ style: {
13856
+ outline: 'none',
13857
+ ...props.style
13858
+ },
13859
+ onMouseDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, ()=>{
13860
+ isClickFocusRef.current = true;
13861
+ }),
13862
+ onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, (event)=>{
13863
+ // We normally wouldn't need this check, because we already check
13864
+ // that the focus is on the current target and not bubbling to it.
13865
+ // We do this because Safari doesn't focus buttons when clicked, and
13866
+ // instead, the wrapper will get focused and not through a bubbling event.
13867
+ const isKeyboardFocus = !isClickFocusRef.current;
13868
+ if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
13869
+ const entryFocusEvent = new CustomEvent($d7bdfb9eb0fdf311$var$ENTRY_FOCUS, $d7bdfb9eb0fdf311$var$EVENT_OPTIONS);
13870
+ event.currentTarget.dispatchEvent(entryFocusEvent);
13871
+ if (!entryFocusEvent.defaultPrevented) {
13872
+ const items = getItems().filter((item)=>item.focusable
13873
+ );
13874
+ const activeItem = items.find((item)=>item.active
13875
+ );
13876
+ const currentItem = items.find((item)=>item.id === currentTabStopId
13877
+ );
13878
+ const candidateItems = [
13879
+ activeItem,
13880
+ currentItem,
13881
+ ...items
13882
+ ].filter(Boolean);
13883
+ const candidateNodes = candidateItems.map((item)=>item.ref.current
13884
+ );
13885
+ $d7bdfb9eb0fdf311$var$focusFirst(candidateNodes);
13886
+ }
13887
+ }
13888
+ isClickFocusRef.current = false;
13889
+ }),
13890
+ onBlur: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlur, ()=>setIsTabbingBackOut(false)
13891
+ )
13892
+ })));
13893
+ });
13894
+ /* -------------------------------------------------------------------------------------------------
13895
+ * RovingFocusGroupItem
13896
+ * -----------------------------------------------------------------------------------------------*/ const $d7bdfb9eb0fdf311$var$ITEM_NAME = 'RovingFocusGroupItem';
13897
+ const $d7bdfb9eb0fdf311$export$ab9df7c53fe8454 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
13898
+ const { __scopeRovingFocusGroup: __scopeRovingFocusGroup , focusable: focusable = true , active: active = false , tabStopId: tabStopId , ...itemProps } = props;
13899
+ const autoId = $1746a345f3d73bb7$export$f680877a34711e37();
13900
+ const id = tabStopId || autoId;
13901
+ const context = $d7bdfb9eb0fdf311$var$useRovingFocusContext($d7bdfb9eb0fdf311$var$ITEM_NAME, __scopeRovingFocusGroup);
13902
+ const isCurrentTabStop = context.currentTabStopId === id;
13903
+ const getItems = $d7bdfb9eb0fdf311$var$useCollection(__scopeRovingFocusGroup);
13904
+ const { onFocusableItemAdd: onFocusableItemAdd , onFocusableItemRemove: onFocusableItemRemove } = context;
13905
+ React.useEffect(()=>{
13906
+ if (focusable) {
13907
+ onFocusableItemAdd();
13908
+ return ()=>onFocusableItemRemove()
13909
+ ;
13910
+ }
13911
+ }, [
13912
+ focusable,
13913
+ onFocusableItemAdd,
13914
+ onFocusableItemRemove
13915
+ ]);
13916
+ return /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$var$Collection.ItemSlot, {
13917
+ scope: __scopeRovingFocusGroup,
13918
+ id: id,
13919
+ focusable: focusable,
13920
+ active: active
13921
+ }, /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
13922
+ tabIndex: isCurrentTabStop ? 0 : -1,
13923
+ "data-orientation": context.orientation
13924
+ }, itemProps, {
13925
+ ref: forwardedRef,
13926
+ onMouseDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, (event)=>{
13927
+ // We prevent focusing non-focusable items on `mousedown`.
13928
+ // Even though the item has tabIndex={-1}, that only means take it out of the tab order.
13929
+ if (!focusable) event.preventDefault(); // Safari doesn't focus a button when clicked so we run our logic on mousedown also
13930
+ else context.onItemFocus(id);
13931
+ }),
13932
+ onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, ()=>context.onItemFocus(id)
13933
+ ),
13934
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event)=>{
13935
+ if (event.key === 'Tab' && event.shiftKey) {
13936
+ context.onItemShiftTab();
13937
+ return;
13938
+ }
13939
+ if (event.target !== event.currentTarget) return;
13940
+ const focusIntent = $d7bdfb9eb0fdf311$var$getFocusIntent(event, context.orientation, context.dir);
13941
+ if (focusIntent !== undefined) {
13942
+ event.preventDefault();
13943
+ const items = getItems().filter((item)=>item.focusable
13944
+ );
13945
+ let candidateNodes = items.map((item)=>item.ref.current
13946
+ );
13947
+ if (focusIntent === 'last') candidateNodes.reverse();
13948
+ else if (focusIntent === 'prev' || focusIntent === 'next') {
13949
+ if (focusIntent === 'prev') candidateNodes.reverse();
13950
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
13951
+ candidateNodes = context.loop ? $d7bdfb9eb0fdf311$var$wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
13952
+ }
13953
+ /**
13954
+ * Imperative focus during keydown is risky so we prevent React's batching updates
13955
+ * to avoid potential bugs. See: https://github.com/facebook/react/issues/20332
13956
+ */ setTimeout(()=>$d7bdfb9eb0fdf311$var$focusFirst(candidateNodes)
13957
+ );
13958
+ }
13959
+ })
13960
+ })));
13961
+ });
13962
+ /* -----------------------------------------------------------------------------------------------*/ // prettier-ignore
13963
+ const $d7bdfb9eb0fdf311$var$MAP_KEY_TO_FOCUS_INTENT = {
13964
+ ArrowLeft: 'prev',
13965
+ ArrowUp: 'prev',
13966
+ ArrowRight: 'next',
13967
+ ArrowDown: 'next',
13968
+ PageUp: 'first',
13969
+ Home: 'first',
13970
+ PageDown: 'last',
13971
+ End: 'last'
13972
+ };
13973
+ function $d7bdfb9eb0fdf311$var$getDirectionAwareKey(key, dir) {
13974
+ if (dir !== 'rtl') return key;
13975
+ return key === 'ArrowLeft' ? 'ArrowRight' : key === 'ArrowRight' ? 'ArrowLeft' : key;
13976
+ }
13977
+ function $d7bdfb9eb0fdf311$var$getFocusIntent(event, orientation, dir) {
13978
+ const key = $d7bdfb9eb0fdf311$var$getDirectionAwareKey(event.key, dir);
13979
+ if (orientation === 'vertical' && [
13980
+ 'ArrowLeft',
13981
+ 'ArrowRight'
13982
+ ].includes(key)) return undefined;
13983
+ if (orientation === 'horizontal' && [
13984
+ 'ArrowUp',
13985
+ 'ArrowDown'
13986
+ ].includes(key)) return undefined;
13987
+ return $d7bdfb9eb0fdf311$var$MAP_KEY_TO_FOCUS_INTENT[key];
13988
+ }
13989
+ function $d7bdfb9eb0fdf311$var$focusFirst(candidates) {
13990
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
13991
+ for (const candidate of candidates){
13992
+ // if focus is already where we want to go, we don't want to keep going through the candidates
13993
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
13994
+ candidate.focus();
13995
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
13996
+ }
13997
+ }
13998
+ /**
13999
+ * Wraps an array around itself at a given start index
14000
+ * Example: `wrapArray(['a', 'b', 'c', 'd'], 2) === ['c', 'd', 'a', 'b']`
14001
+ */ function $d7bdfb9eb0fdf311$var$wrapArray(array, startIndex) {
14002
+ return array.map((_, index)=>array[(startIndex + index) % array.length]
14003
+ );
14004
+ }
14005
+ const $d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9 = $d7bdfb9eb0fdf311$export$8699f7c8af148338;
14006
+ const $d7bdfb9eb0fdf311$export$6d08773d2e66f8f2 = $d7bdfb9eb0fdf311$export$ab9df7c53fe8454;
14007
+
14008
+ /* -------------------------------------------------------------------------------------------------
14009
+ * Tabs
14010
+ * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TABS_NAME = 'Tabs';
14011
+ const [$69cb30bb0017df05$var$createTabsContext, $69cb30bb0017df05$export$355f5bd209d7b13a] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($69cb30bb0017df05$var$TABS_NAME, [
14012
+ $d7bdfb9eb0fdf311$export$c7109489551a4f4
14013
+ ]);
14014
+ const $69cb30bb0017df05$var$useRovingFocusGroupScope = $d7bdfb9eb0fdf311$export$c7109489551a4f4();
14015
+ const [$69cb30bb0017df05$var$TabsProvider, $69cb30bb0017df05$var$useTabsContext] = $69cb30bb0017df05$var$createTabsContext($69cb30bb0017df05$var$TABS_NAME);
14016
+ const $69cb30bb0017df05$export$b2539bed5023c21c = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
14017
+ const { __scopeTabs: __scopeTabs , value: valueProp , onValueChange: onValueChange , defaultValue: defaultValue , orientation: orientation = 'horizontal' , dir: dir , activationMode: activationMode = 'automatic' , ...tabsProps } = props;
14018
+ const direction = $f631663db3294ace$export$b39126d51d94e6f3(dir);
14019
+ const [value, setValue] = $71cd76cc60e0454e$export$6f32135080cb4c3({
14020
+ prop: valueProp,
14021
+ onChange: onValueChange,
14022
+ defaultProp: defaultValue
14023
+ });
14024
+ return /*#__PURE__*/ React.createElement($69cb30bb0017df05$var$TabsProvider, {
14025
+ scope: __scopeTabs,
14026
+ baseId: $1746a345f3d73bb7$export$f680877a34711e37(),
14027
+ value: value,
14028
+ onValueChange: setValue,
14029
+ orientation: orientation,
14030
+ dir: direction,
14031
+ activationMode: activationMode
14032
+ }, /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
14033
+ dir: direction,
14034
+ "data-orientation": orientation
14035
+ }, tabsProps, {
14036
+ ref: forwardedRef
14037
+ })));
14038
+ });
14039
+ /* -------------------------------------------------------------------------------------------------
14040
+ * TabsList
14041
+ * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TAB_LIST_NAME = 'TabsList';
14042
+ const $69cb30bb0017df05$export$9712d22edc0d78c1 = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
14043
+ const { __scopeTabs: __scopeTabs , loop: loop = true , ...listProps } = props;
14044
+ const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TAB_LIST_NAME, __scopeTabs);
14045
+ const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
14046
+ return /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, _extends({
14047
+ asChild: true
14048
+ }, rovingFocusGroupScope, {
14049
+ orientation: context.orientation,
14050
+ dir: context.dir,
14051
+ loop: loop
14052
+ }), /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
14053
+ role: "tablist",
14054
+ "aria-orientation": context.orientation
14055
+ }, listProps, {
14056
+ ref: forwardedRef
14057
+ })));
14058
+ });
14059
+ /* -------------------------------------------------------------------------------------------------
14060
+ * TabsTrigger
14061
+ * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$TRIGGER_NAME = 'TabsTrigger';
14062
+ const $69cb30bb0017df05$export$8114b9fdfdf9f3ba = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
14063
+ const { __scopeTabs: __scopeTabs , value: value , disabled: disabled = false , ...triggerProps } = props;
14064
+ const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TRIGGER_NAME, __scopeTabs);
14065
+ const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
14066
+ const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
14067
+ const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
14068
+ const isSelected = value === context.value;
14069
+ return /*#__PURE__*/ React.createElement($d7bdfb9eb0fdf311$export$6d08773d2e66f8f2, _extends({
14070
+ asChild: true
14071
+ }, rovingFocusGroupScope, {
14072
+ focusable: !disabled,
14073
+ active: isSelected
14074
+ }), /*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
14075
+ type: "button",
14076
+ role: "tab",
14077
+ "aria-selected": isSelected,
14078
+ "aria-controls": contentId,
14079
+ "data-state": isSelected ? 'active' : 'inactive',
14080
+ "data-disabled": disabled ? '' : undefined,
14081
+ disabled: disabled,
14082
+ id: triggerId
14083
+ }, triggerProps, {
14084
+ ref: forwardedRef,
14085
+ onMouseDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onMouseDown, (event)=>{
14086
+ // only call handler if it's the left button (mousedown gets triggered by all mouse buttons)
14087
+ // but not when the control key is pressed (avoiding MacOS right click)
14088
+ if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
14089
+ else // prevent focus to avoid accidental activation
14090
+ event.preventDefault();
14091
+ }),
14092
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event)=>{
14093
+ if ([
14094
+ ' ',
14095
+ 'Enter'
14096
+ ].includes(event.key)) context.onValueChange(value);
14097
+ }),
14098
+ onFocus: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocus, ()=>{
14099
+ // handle "automatic" activation if necessary
14100
+ // ie. activate tab following focus
14101
+ const isAutomaticActivation = context.activationMode !== 'manual';
14102
+ if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
14103
+ })
14104
+ })));
14105
+ });
14106
+ /* -------------------------------------------------------------------------------------------------
14107
+ * TabsContent
14108
+ * -----------------------------------------------------------------------------------------------*/ const $69cb30bb0017df05$var$CONTENT_NAME = 'TabsContent';
14109
+ const $69cb30bb0017df05$export$bd905d70e8fd2ebb = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
14110
+ const { __scopeTabs: __scopeTabs , value: value , forceMount: forceMount , children: children , ...contentProps } = props;
14111
+ const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$CONTENT_NAME, __scopeTabs);
14112
+ const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
14113
+ const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
14114
+ const isSelected = value === context.value;
14115
+ const isMountAnimationPreventedRef = React.useRef(isSelected);
14116
+ React.useEffect(()=>{
14117
+ const rAF = requestAnimationFrame(()=>isMountAnimationPreventedRef.current = false
14118
+ );
14119
+ return ()=>cancelAnimationFrame(rAF)
14120
+ ;
14121
+ }, []);
14122
+ return /*#__PURE__*/ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
14123
+ present: forceMount || isSelected
14124
+ }, ({ present: present })=>/*#__PURE__*/ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
14125
+ "data-state": isSelected ? 'active' : 'inactive',
14126
+ "data-orientation": context.orientation,
14127
+ role: "tabpanel",
14128
+ "aria-labelledby": triggerId,
14129
+ hidden: !present,
14130
+ id: contentId,
14131
+ tabIndex: 0
14132
+ }, contentProps, {
14133
+ ref: forwardedRef,
14134
+ style: {
14135
+ ...props.style,
14136
+ animationDuration: isMountAnimationPreventedRef.current ? '0s' : undefined
14137
+ }
14138
+ }), present && children)
14139
+ );
14140
+ });
14141
+ /* ---------------------------------------------------------------------------------------------- */ function $69cb30bb0017df05$var$makeTriggerId(baseId, value) {
14142
+ return `${baseId}-trigger-${value}`;
14143
+ }
14144
+ function $69cb30bb0017df05$var$makeContentId(baseId, value) {
14145
+ return `${baseId}-content-${value}`;
14146
+ }
14147
+ const $69cb30bb0017df05$export$be92b6f5f03c0fe9 = $69cb30bb0017df05$export$b2539bed5023c21c;
14148
+ const $69cb30bb0017df05$export$54c2e3dc7acea9f5 = $69cb30bb0017df05$export$9712d22edc0d78c1;
14149
+ const $69cb30bb0017df05$export$41fb9f06171c75f4 = $69cb30bb0017df05$export$8114b9fdfdf9f3ba;
14150
+ const $69cb30bb0017df05$export$7c6e2c02157bb7d2 = $69cb30bb0017df05$export$bd905d70e8fd2ebb;
14151
+
14152
+ const Tabs = ({ tabs, defaultActiveTab, activeTab, onTabSelect, extraClassNames, testId, id, }) => {
14153
+ const handleTabSelect = (tabId) => {
14154
+ if (activeTab === tabId)
14155
+ return;
14156
+ onTabSelect && onTabSelect(tabId);
14157
+ };
14158
+ return (React.createElement($69cb30bb0017df05$export$be92b6f5f03c0fe9, { className: `tw-flex tw-flex-col tw-min-w-[300px] ${extraClassNames || ''}`, defaultValue: defaultActiveTab, "data-testid": testId, id: id, value: activeTab, onValueChange: handleTabSelect },
14159
+ React.createElement($69cb30bb0017df05$export$54c2e3dc7acea9f5, { className: `tw-bg-sq-light-gray dark:tw-bg-gray-700 tw-flex tw-flex-row tw-gap-[2px]` }, tabs.map(({ id, icon, label, tabExtraClassNames, testId: tabsTestId, disabled }, index) => (React.createElement($69cb30bb0017df05$export$41fb9f06171c75f4, { className: `tw-bg-sq-white dark:tw-bg-sq-dark-background tw-h-[45px] tw-border-solid dark:tw-border-gray-700 tw-flex tw-flex-1 tw-justify-center tw-items-center ${tabExtraClassNames || ''} ${activeTab === id
14160
+ ? 'tw-border-b-sq-color-dark dark:tw-border-b-sq-color-dark tw-border-b-[3px]'
14161
+ : 'hover:tw-bg-sq-light-gray tw-border-b-[1px] hover:dark:tw-bg-gray-700'}`, "data-testid": tabsTestId, disabled: disabled, key: `${label}-${id}-${index}`, value: id },
14162
+ React.createElement("span", null,
14163
+ icon && React.createElement(Icon, { icon: icon, testId: `${id}_tab-icon`, extraClassNames: "tw-text-[15px] tw-mr-[7px]" }),
14164
+ React.createElement("span", { className: `tw-text-[14px] tw-font-medium ${activeTab === id
14165
+ ? 'dark:tw-text-sq-dark-text tw-text-gray-500'
14166
+ : 'dark:tw-text-sq-color-dark-dark tw-text-sq-color-dark'}` }, label)))))),
14167
+ tabs.map((tab, index) => (React.createElement($69cb30bb0017df05$export$7c6e2c02157bb7d2, { key: `${tab.label}_${index}_content`, value: tab.id },
14168
+ React.createElement("div", { className: "tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-4" }, tab.content))))));
14169
+ };
14170
+
13692
14171
  exports.Button = Button;
13693
14172
  exports.Checkbox = Checkbox;
13694
14173
  exports.Icon = Icon;
13695
14174
  exports.QTip = QTip;
13696
14175
  exports.Select = Select;
14176
+ exports.Tabs = Tabs;
13697
14177
  exports.TextArea = TextArea;
13698
14178
  exports.TextField = TextField;
13699
14179
  exports.ToolbarButton = ToolbarButton;