@apple-pie/slice 0.0.1 → 0.0.3

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 (225) hide show
  1. package/dist/cjs/chunks/Avatar-8-wPWe0V.js +68 -0
  2. package/dist/cjs/chunks/AvatarGroup-CVKmgBbD.js +39 -0
  3. package/dist/cjs/chunks/Badge-CMapJCij.js +41 -0
  4. package/dist/cjs/chunks/CheckBox-7AACxrdZ.js +76 -0
  5. package/dist/cjs/chunks/DivInput-BKKJTFeV.js +204 -0
  6. package/dist/cjs/chunks/DocIcons-BRWOzK96.js +41 -0
  7. package/dist/cjs/chunks/Dot-Dnr9M9na.js +80 -0
  8. package/dist/cjs/chunks/DrggablePanel-C6TPsDB-.js +302 -0
  9. package/dist/cjs/chunks/DropDown-D9sf_m2I.js +154 -0
  10. package/dist/cjs/chunks/EditorButtonBar-CUNDgRQd.js +244 -0
  11. package/dist/cjs/chunks/ErrorSummary-Dv44onsV.js +42 -0
  12. package/dist/cjs/chunks/FlexDiv-DZBpswHV.js +103 -0
  13. package/dist/cjs/chunks/Grouper-_kd2nU78.js +50 -0
  14. package/dist/cjs/chunks/IconButton-BfsPlKTb.js +84 -0
  15. package/dist/cjs/chunks/Logos-DSlAUz8l.js +119 -0
  16. package/dist/cjs/chunks/MessageInput-CiHFo2j8.js +399 -0
  17. package/dist/cjs/chunks/Overlay-DwCPvGB5.js +45 -0
  18. package/dist/cjs/chunks/Pager-CFtZ0IIW.js +42 -0
  19. package/dist/cjs/chunks/ProgressIndicator-C5oB7Mky.js +121 -0
  20. package/dist/cjs/chunks/RadioButton-e_y2qiPE.js +65 -0
  21. package/dist/cjs/chunks/RadioButtonList-I81UwHmM.js +116 -0
  22. package/dist/cjs/chunks/Slider-C-gn7Sby.js +285 -0
  23. package/dist/cjs/chunks/Spacer-BEY2-_PB.js +16 -0
  24. package/dist/cjs/chunks/Switch-CtkFtogd.js +43 -0
  25. package/dist/cjs/chunks/TabBar-D3bj4pjj.js +176 -0
  26. package/dist/cjs/chunks/TextArea-B1oKK3_b.js +153 -0
  27. package/dist/cjs/chunks/TextField-CiQdPP5E.js +248 -0
  28. package/dist/cjs/chunks/Tip-C2pzExut.js +91 -0
  29. package/dist/cjs/chunks/Toast-DrijUwoL.js +141 -0
  30. package/dist/cjs/chunks/UIButton-CH4p-8yq.js +317 -0
  31. package/dist/cjs/chunks/UIButtonBar-0fHPB0ww.js +58 -0
  32. package/dist/cjs/chunks/UICard-DBDSyT7E.js +36 -0
  33. package/dist/cjs/chunks/UIChip-kjhvRrOV.js +93 -0
  34. package/dist/cjs/chunks/UIFileIcon-ZrbDIeYz.js +54 -0
  35. package/dist/cjs/chunks/UILabel-DkBE2AIt.js +116 -0
  36. package/dist/cjs/chunks/_types-CoWzQFsT.js +714 -0
  37. package/dist/cjs/chunks/sharedTypes-BvTjh6M5.js +9 -0
  38. package/dist/cjs/chunks/style-inject.es-XZHJH68X.js +30 -0
  39. package/dist/cjs/chunks/tipStore-C9oV9SIh.js +23 -0
  40. package/dist/cjs/chunks/toastStore-C-ETP9H6.js +23 -0
  41. package/dist/cjs/chunks/tslib.es6-4H29ixHs.js +48 -0
  42. package/dist/cjs/chunks/utils-CbayehuI.js +126 -0
  43. package/dist/cjs/hooks/useDoubleClick.js +26 -0
  44. package/dist/cjs/hooks/useKeyboardShortcuts.js +42 -0
  45. package/dist/cjs/hooks/useLastUpdated.js +53 -0
  46. package/dist/cjs/hooks/useLocalStore.js +52 -0
  47. package/dist/cjs/hooks/useObserveResize.js +56 -0
  48. package/dist/cjs/hooks/useObserveTheme.js +37 -0
  49. package/dist/cjs/hooks/useTheme.js +86 -0
  50. package/dist/cjs/hooks/useToolTip.js +36 -0
  51. package/dist/cjs/hooks/useTrackRenders.js +38 -0
  52. package/dist/cjs/hooks/useWindow.js +64 -0
  53. package/dist/cjs/hooks.js +33 -0
  54. package/dist/cjs/index.js +124 -0
  55. package/dist/cjs/providers/ThemeProvider.js +55 -0
  56. package/dist/cjs/providers.js +14 -0
  57. package/dist/cjs/stores/tip.js +12 -0
  58. package/dist/cjs/stores/toast.js +12 -0
  59. package/dist/cjs/stores.js +18 -0
  60. package/dist/cjs/theme/colors.js +383 -0
  61. package/dist/cjs/theme/corners.js +14 -0
  62. package/dist/cjs/theme/elevations.js +17 -0
  63. package/dist/cjs/theme/themes.js +26 -0
  64. package/dist/cjs/theme/type.js +316 -0
  65. package/dist/cjs/theme.js +16 -0
  66. package/dist/cjs/uikit/Avatar.js +11 -0
  67. package/dist/cjs/uikit/AvatarGroup.js +12 -0
  68. package/dist/cjs/uikit/Badge.js +11 -0
  69. package/dist/cjs/uikit/CheckBox.js +22 -0
  70. package/dist/cjs/uikit/DivInput.js +13 -0
  71. package/dist/cjs/uikit/DocIcon.js +18 -0
  72. package/dist/cjs/uikit/Dot.js +12 -0
  73. package/dist/cjs/uikit/DraggablePanel.js +21 -0
  74. package/dist/cjs/uikit/DropDown.js +21 -0
  75. package/dist/cjs/uikit/EditorButtonBar.js +28 -0
  76. package/dist/cjs/uikit/ErrorSummary.js +12 -0
  77. package/dist/cjs/uikit/FlexDiv.js +12 -0
  78. package/dist/cjs/uikit/Grouper.js +23 -0
  79. package/dist/cjs/uikit/Icon.js +23 -0
  80. package/dist/cjs/uikit/IconButton.js +25 -0
  81. package/dist/cjs/uikit/Logos.js +18 -0
  82. package/dist/cjs/uikit/MessageInput.js +30 -0
  83. package/dist/cjs/uikit/Overlay.js +12 -0
  84. package/dist/cjs/uikit/Pager.js +12 -0
  85. package/dist/cjs/uikit/Progress.js +21 -0
  86. package/dist/cjs/uikit/RadioButton.js +26 -0
  87. package/dist/cjs/uikit/RadioButtonList.js +27 -0
  88. package/dist/cjs/uikit/Slider.js +13 -0
  89. package/dist/cjs/uikit/Spacer.js +10 -0
  90. package/dist/cjs/uikit/Switch.js +12 -0
  91. package/dist/cjs/uikit/TabBar.js +26 -0
  92. package/dist/cjs/uikit/TextArea.js +27 -0
  93. package/dist/cjs/uikit/Textfield.js +28 -0
  94. package/dist/cjs/uikit/Tip.js +13 -0
  95. package/dist/cjs/uikit/Toast.js +26 -0
  96. package/dist/cjs/uikit/UIButton.js +26 -0
  97. package/dist/cjs/uikit/UIButtonBar.js +26 -0
  98. package/dist/cjs/uikit/UICard.js +21 -0
  99. package/dist/cjs/uikit/UIChip.js +22 -0
  100. package/dist/cjs/uikit/UIFileIcon.js +18 -0
  101. package/dist/cjs/uikit/UILabel.js +19 -0
  102. package/dist/esm/chunks/Avatar-D_muqPrW.js +66 -0
  103. package/dist/esm/chunks/AvatarGroup-D8Xmrn52.js +37 -0
  104. package/dist/esm/chunks/Badge-PPf5Uvw3.js +39 -0
  105. package/dist/esm/chunks/CheckBox-CswFI0Xc.js +74 -0
  106. package/dist/esm/chunks/DivInput-iKFkeU2F.js +202 -0
  107. package/dist/esm/chunks/DocIcons-CbOX4n8Y.js +39 -0
  108. package/dist/esm/chunks/Dot-B84UVs2e.js +78 -0
  109. package/dist/esm/chunks/DrggablePanel-CYYwTmFd.js +300 -0
  110. package/dist/esm/chunks/DropDown-D4t6EhKL.js +152 -0
  111. package/dist/esm/chunks/EditorButtonBar-FnMa8Zv2.js +242 -0
  112. package/dist/esm/chunks/ErrorSummary-DhU5SKPt.js +40 -0
  113. package/dist/esm/chunks/FlexDiv-CmMpORgn.js +101 -0
  114. package/dist/esm/chunks/Grouper-BbreOXI9.js +48 -0
  115. package/dist/esm/chunks/IconButton-CguHGkBM.js +82 -0
  116. package/dist/esm/chunks/Logos-DwZP-TR2.js +117 -0
  117. package/dist/esm/chunks/MessageInput-DMHzCwjO.js +397 -0
  118. package/dist/esm/chunks/Overlay-CCBy7n7H.js +43 -0
  119. package/dist/esm/chunks/Pager-BsSti93V.js +40 -0
  120. package/dist/esm/chunks/ProgressIndicator-BVukxMU6.js +118 -0
  121. package/dist/esm/chunks/RadioButton-B5BxQI0R.js +63 -0
  122. package/dist/esm/chunks/RadioButtonList-C2z8McAD.js +114 -0
  123. package/dist/esm/chunks/Slider-C-PcWqTz.js +283 -0
  124. package/dist/esm/chunks/Spacer-DbZSG5x3.js +14 -0
  125. package/dist/esm/chunks/Switch-DjfrSiQz.js +41 -0
  126. package/dist/esm/chunks/TabBar-BSBcgTbd.js +174 -0
  127. package/dist/esm/chunks/TextArea-COM0UPo2.js +151 -0
  128. package/dist/esm/chunks/TextField-Bh24bRWs.js +246 -0
  129. package/dist/esm/chunks/Tip-Ct19Ljul.js +89 -0
  130. package/dist/esm/chunks/Toast-BR0oMX6z.js +139 -0
  131. package/dist/esm/chunks/UIButton-DKx-_O8h.js +315 -0
  132. package/dist/esm/chunks/UIButtonBar-BNdA5eVq.js +56 -0
  133. package/dist/esm/chunks/UICard-Dn5f3wg8.js +34 -0
  134. package/dist/esm/chunks/UIChip-DqnGeVyR.js +91 -0
  135. package/dist/esm/chunks/UIFileIcon-qGxIPsJJ.js +52 -0
  136. package/dist/esm/chunks/UILabel-RnbodPCS.js +114 -0
  137. package/dist/esm/chunks/_types-BaYeLEWK.js +712 -0
  138. package/dist/esm/chunks/sharedTypes-BfZzG1KX.js +9 -0
  139. package/dist/esm/chunks/style-inject.es-tgCJW-Cu.js +28 -0
  140. package/dist/esm/chunks/tipStore-nBYJ6tmE.js +17 -0
  141. package/dist/esm/chunks/toastStore-r3pvNa28.js +17 -0
  142. package/dist/esm/chunks/tslib.es6-0pkUdtrF.js +45 -0
  143. package/dist/esm/chunks/utils-BRZK2Drn.js +119 -0
  144. package/dist/esm/hooks/useDoubleClick.js +24 -0
  145. package/dist/esm/hooks/useKeyboardShortcuts.js +40 -0
  146. package/dist/esm/hooks/useLastUpdated.js +51 -0
  147. package/dist/esm/hooks/useLocalStore.js +50 -0
  148. package/dist/esm/hooks/useObserveResize.js +54 -0
  149. package/dist/esm/hooks/useObserveTheme.js +35 -0
  150. package/dist/esm/hooks/useTheme.js +84 -0
  151. package/dist/esm/hooks/useToolTip.js +34 -0
  152. package/dist/esm/hooks/useTrackRenders.js +36 -0
  153. package/dist/esm/hooks/useWindow.js +62 -0
  154. package/dist/esm/hooks.js +15 -0
  155. package/dist/esm/index.js +58 -0
  156. package/dist/esm/providers/ThemeProvider.js +53 -0
  157. package/dist/esm/providers.js +8 -0
  158. package/dist/esm/stores/tip.js +2 -0
  159. package/dist/esm/stores/toast.js +2 -0
  160. package/dist/esm/stores.js +3 -0
  161. package/dist/esm/theme/colors.js +377 -0
  162. package/dist/esm/theme/corners.js +12 -0
  163. package/dist/esm/theme/elevations.js +15 -0
  164. package/dist/esm/theme/themes.js +23 -0
  165. package/dist/esm/theme/type.js +312 -0
  166. package/dist/esm/theme.js +5 -0
  167. package/dist/esm/uikit/Avatar.js +5 -0
  168. package/dist/esm/uikit/AvatarGroup.js +6 -0
  169. package/dist/esm/uikit/Badge.js +5 -0
  170. package/dist/esm/uikit/CheckBox.js +16 -0
  171. package/dist/esm/uikit/DivInput.js +7 -0
  172. package/dist/esm/uikit/DocIcon.js +12 -0
  173. package/dist/esm/uikit/Dot.js +6 -0
  174. package/dist/esm/uikit/DraggablePanel.js +15 -0
  175. package/dist/esm/uikit/DropDown.js +15 -0
  176. package/dist/esm/uikit/EditorButtonBar.js +22 -0
  177. package/dist/esm/uikit/ErrorSummary.js +6 -0
  178. package/dist/esm/uikit/FlexDiv.js +6 -0
  179. package/dist/esm/uikit/Grouper.js +17 -0
  180. package/dist/esm/uikit/Icon.js +13 -0
  181. package/dist/esm/uikit/IconButton.js +19 -0
  182. package/dist/esm/uikit/Logos.js +12 -0
  183. package/dist/esm/uikit/MessageInput.js +24 -0
  184. package/dist/esm/uikit/Overlay.js +6 -0
  185. package/dist/esm/uikit/Pager.js +6 -0
  186. package/dist/esm/uikit/Progress.js +14 -0
  187. package/dist/esm/uikit/RadioButton.js +20 -0
  188. package/dist/esm/uikit/RadioButtonList.js +21 -0
  189. package/dist/esm/uikit/Slider.js +7 -0
  190. package/dist/esm/uikit/Spacer.js +4 -0
  191. package/dist/esm/uikit/Switch.js +6 -0
  192. package/dist/esm/uikit/TabBar.js +20 -0
  193. package/dist/esm/uikit/TextArea.js +21 -0
  194. package/dist/esm/uikit/Textfield.js +22 -0
  195. package/dist/esm/uikit/Tip.js +7 -0
  196. package/dist/esm/uikit/Toast.js +16 -0
  197. package/dist/esm/uikit/UIButton.js +20 -0
  198. package/dist/esm/uikit/UIButtonBar.js +20 -0
  199. package/dist/esm/uikit/UICard.js +15 -0
  200. package/dist/esm/uikit/UIChip.js +16 -0
  201. package/dist/esm/uikit/UIFileIcon.js +12 -0
  202. package/dist/esm/uikit/UILabel.js +13 -0
  203. package/dist/types/index.d.ts +3 -3
  204. package/dist/types/providers/ThemeProvider.d.ts +1 -0
  205. package/dist/types/stores/index.d.ts +2 -0
  206. package/dist/types/stores/tip/_types.d.ts +8 -0
  207. package/dist/types/stores/tip/index.d.ts +2 -0
  208. package/dist/types/stores/tip/tipStore.d.ts +12 -0
  209. package/dist/types/stores/toast/_types.d.ts +14 -0
  210. package/dist/types/stores/toast/index.d.ts +2 -0
  211. package/dist/types/stores/toast/toastStore.d.ts +12 -0
  212. package/dist/types/theme/elevations/_types.d.ts +10 -0
  213. package/dist/types/theme/elevations/elevations.d.ts +5 -0
  214. package/dist/types/theme/index.d.ts +2 -0
  215. package/dist/types/theme/themes.d.ts +2 -0
  216. package/dist/types/uikit/FlexDiv/FlexDiv.d.ts +2 -0
  217. package/dist/types/uikit/FlexDiv/_types.d.ts +1 -0
  218. package/dist/types/uikit/Toast/Toast.d.ts +1 -1
  219. package/dist/types/uikit/Toast/_types.d.ts +7 -1
  220. package/dist/types/uikit/Toast/index.d.ts +1 -1
  221. package/package.json +84 -5
  222. package/dist/index.esm.js +0 -5859
  223. package/dist/index.esm.js.map +0 -1
  224. package/dist/index.js +0 -5911
  225. package/dist/index.js.map +0 -1
@@ -0,0 +1,302 @@
1
+ 'use strict';
2
+
3
+ var tslib_es6 = require('./tslib.es6-4H29ixHs.js');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var hooks_useTheme = require('../hooks/useTheme.js');
7
+ require('../theme/colors.js');
8
+ require('../hooks/useWindow.js');
9
+ var hooks_useObserveResize = require('../hooks/useObserveResize.js');
10
+ var utils = require('./utils-CbayehuI.js');
11
+ var styleInject_es = require('./style-inject.es-XZHJH68X.js');
12
+
13
+ var css_248z = ".flexBox-module_row__PWxbe {\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowBetween__27lKK {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowStart__nJZnW {\n\tdisplay: flex;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowEnd__dHcOU {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_column__MP2Xd {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStart__Kg8cV {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: flex-start;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStartCenter__zcmtk {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnBetween__157yI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnEnd__u2nwI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-end;\n\talign-items: flex-end;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}\n\n.DraggablePanel-module_panel__r-Dm- {\n\tposition: relative;\n\tbackground-color: var(--panel-bg);\n}\n\n.DraggablePanel-module_content__K1gRd {\n\twidth: 100%;\n\theight: 100%;\n\toverflow: hidden;\n}\n\n.DraggablePanel-module_handle__yVrgS {\n\twidth: var(--drag-handle-width);\n\theight: var(--drag-handle-height);\n\tmin-width: var(--drag-handle-width);\n\tmin-height: var(--drag-handle-height);\n\tborder-radius: var(--drag-handle-radius);\n\tborder: var(--drag-handle-border) solid var(--drag-handle-border-color);\n\tbackground: var(--drag-handle-bg);\n\tposition: absolute;\n\ttop: 50%;\n\tleft: 50%;\n\ttransform: translateX(-50%) translateY(-50%);\n\tz-index: 15000;\n}\n";
14
+ var css = {"panel":"DraggablePanel-module_panel__r-Dm- flexBox-module_columnStart__Kg8cV","content":"DraggablePanel-module_content__K1gRd flexBox-module_columnStart__Kg8cV","handle":"DraggablePanel-module_handle__yVrgS"};
15
+ styleInject_es.styleInject(css_248z);
16
+
17
+ const MIN_SIZE = 50;
18
+ const DraggablePanel = React.memo((props) => {
19
+ const theme = hooks_useTheme.useTheme();
20
+ const { children, sizeConstraints = { initial: 250, min: 250, max: 500 }, dragsRight = true, isClosed = true, resizeHandle = {
21
+ width: 10,
22
+ color: 'transparent',
23
+ offsetX: true,
24
+ }, borderRight = '1px solid var(--core-outline-primary)', borderLeft = null, bgColor = 'transparent', drags = true, isTouchDevice = false, disableOnContext = true, dragHandle = true, dragHandleStyle, containerRef, onResize = () => null, onResizeStart = () => null, onResizeEnd = () => null } = props, divAttributes = tslib_es6.__rest(props, ["children", "sizeConstraints", "dragsRight", "isClosed", "resizeHandle", "borderRight", "borderLeft", "bgColor", "drags", "isTouchDevice", "disableOnContext", "dragHandle", "dragHandleStyle", "containerRef", "onResize", "onResizeStart", "onResizeEnd"]);
25
+ const { id: divId, className, style } = divAttributes, rest = tslib_es6.__rest(divAttributes, ["id", "className", "style"]);
26
+ const divStyle = style !== null && style !== void 0 ? style : {};
27
+ const divClass = className ? ` ${className}` : '';
28
+ const handle = React.useRef(null);
29
+ const div = React.useRef(null);
30
+ const [isDragging, setIsDragging] = React.useState(false);
31
+ const isOver = React.useRef(false);
32
+ const gripper = Object.assign({}, resizeHandle);
33
+ const containerSize = hooks_useObserveResize.useObserveResize(containerRef);
34
+ const [handleHighlight, setHandleHighlight] = React.useState(false);
35
+ const [lastWidth, setLastWidth] = React.useState(null);
36
+ const [panelClosed, setPanelClosed] = React.useState(isClosed);
37
+ const [constraints, setConstraints] = React.useState(sizeConstraints);
38
+ const [contWidth, setContWidth] = React.useState(undefined);
39
+ const timer = React.useRef(null);
40
+ const startX = React.useRef(0);
41
+ const startWidth = React.useRef(0);
42
+ const divWidth = React.useRef(0);
43
+ const divHeight = React.useRef(0);
44
+ const deltaWidth = React.useRef(0);
45
+ // handle window resize call back - use the window object only if containerRef is undefined
46
+ const handleWindowResize = React.useCallback(() => {
47
+ if (!(containerRef === null || containerRef === void 0 ? void 0 : containerRef.current))
48
+ setContWidth(window.innerWidth);
49
+ }, [containerRef]);
50
+ const handleMouseOver = React.useCallback(() => {
51
+ isOver.current = true;
52
+ setHighlight(true);
53
+ }, []);
54
+ const handleMouseOut = React.useCallback(() => {
55
+ isOver.current = false;
56
+ if (!isDragging)
57
+ setHighlight(false);
58
+ }, [isDragging]);
59
+ const handleFocus = React.useCallback(() => {
60
+ isOver.current = true;
61
+ setHighlight(true);
62
+ }, []);
63
+ const handleBlur = React.useCallback(() => {
64
+ isOver.current = false;
65
+ if (!isDragging)
66
+ setHighlight(false);
67
+ }, [isDragging]);
68
+ const handleTouchStart = React.useCallback(() => {
69
+ isOver.current = true;
70
+ setHighlight(true);
71
+ }, []);
72
+ const handleTouchEnd = React.useCallback(() => {
73
+ isOver.current = false;
74
+ if (!isDragging)
75
+ setHighlight(false);
76
+ }, [isDragging]);
77
+ // handle container resize - if continerRef and width more than 0 use this to set container size
78
+ React.useEffect(() => {
79
+ if (!containerRef)
80
+ return;
81
+ if (containerSize.width > 0)
82
+ setContWidth(containerSize.width);
83
+ }, [containerSize, containerRef]);
84
+ // listen to then window resize event
85
+ // biome-ignore lint/correctness/useExhaustiveDependencies: on mount only
86
+ React.useEffect(() => {
87
+ if (!contWidth)
88
+ setContWidth(window.innerWidth);
89
+ globalThis.addEventListener('resize', handleWindowResize);
90
+ return () => globalThis.removeEventListener('resize', handleWindowResize);
91
+ }, []);
92
+ // close/open on prop change
93
+ React.useEffect(() => setPanelClosed(isClosed), [isClosed]);
94
+ // on constraints update, check and adjust div width to not exceed max
95
+ const adjustCurrentWidth = React.useCallback((relConst) => {
96
+ if ((div === null || div === void 0 ? void 0 : div.current) && relConst.max) {
97
+ const currentWidth = div.current.offsetWidth;
98
+ if (currentWidth > relConst.max) {
99
+ div.current.style.width = `${relConst.max}px`;
100
+ divWidth.current = relConst.max;
101
+ setLastWidth(relConst.max);
102
+ }
103
+ }
104
+ }, []);
105
+ // reset constraints on prop changes
106
+ React.useEffect(() => {
107
+ if (!contWidth)
108
+ return;
109
+ const { min, max, initial } = sizeConstraints;
110
+ const relativeConstraints = { min, max, initial };
111
+ for (const [key, value] of Object.entries(sizeConstraints)) {
112
+ let calc = value;
113
+ if (calc <= 1 && calc >= 0)
114
+ calc = contWidth * value; // handle "percent" values
115
+ if (calc > 1 && calc < MIN_SIZE)
116
+ calc = MIN_SIZE; // ensure values no smaller than MIN_SIZE
117
+ relativeConstraints[key] = calc;
118
+ }
119
+ if (relativeConstraints.min < relativeConstraints.initial) {
120
+ relativeConstraints.initial = relativeConstraints.min; // ensure "initial" is not smaller than "min"
121
+ }
122
+ setConstraints(relativeConstraints);
123
+ adjustCurrentWidth(relativeConstraints);
124
+ }, [sizeConstraints, contWidth, adjustCurrentWidth]);
125
+ // callback for hilight when hovering over the resize handle
126
+ const setHighlight = React.useCallback((state) => {
127
+ if (timer.current)
128
+ clearTimeout(timer.current);
129
+ if (state) {
130
+ timer.current = setTimeout(() => {
131
+ setHandleHighlight(state);
132
+ }, isTouchDevice ? 0 : 350);
133
+ }
134
+ else
135
+ setHandleHighlight(false);
136
+ }, [isTouchDevice]);
137
+ // get the current mouse X position using touch or mouse event
138
+ const getClientX = React.useCallback((e) => {
139
+ return utils.pointerPosition(e);
140
+ }, []);
141
+ // calculate the drag amount based on starting point and new client x point
142
+ const getNewWidth = React.useCallback((clientX) => {
143
+ return dragsRight
144
+ ? startWidth.current + clientX - startX.current
145
+ : startWidth.current - clientX + startX.current;
146
+ }, [dragsRight]);
147
+ // check constraints to prevent over dragging
148
+ const canDrag = React.useCallback((newWidth, clientX) => {
149
+ if (constraints === null || constraints === void 0 ? void 0 : constraints.min) {
150
+ if (newWidth <= constraints.min)
151
+ return false;
152
+ if (newWidth < constraints.min)
153
+ return false;
154
+ }
155
+ if (constraints === null || constraints === void 0 ? void 0 : constraints.max) {
156
+ if (newWidth >= constraints.max) {
157
+ if (clientX - startX.current > 0)
158
+ return false;
159
+ }
160
+ }
161
+ return true;
162
+ }, [constraints]);
163
+ // process drag
164
+ const doDrag = React.useCallback((e) => {
165
+ if (div === null || div === void 0 ? void 0 : div.current) {
166
+ e.stopPropagation();
167
+ e.preventDefault();
168
+ const el = div.current;
169
+ const clientX = getClientX(e);
170
+ const newWidth = getNewWidth(clientX);
171
+ if (!canDrag(newWidth, clientX))
172
+ return;
173
+ el.style.width = `${newWidth}px`;
174
+ divWidth.current = newWidth;
175
+ deltaWidth.current = clientX - startX.current;
176
+ onResize({
177
+ div,
178
+ divWidth: divWidth.current,
179
+ divHeight: divHeight.current,
180
+ deltaWidth: deltaWidth.current,
181
+ });
182
+ }
183
+ return false;
184
+ }, [onResize, canDrag, getNewWidth, getClientX]);
185
+ // handle stopping drag
186
+ const stopDrag = React.useCallback(() => {
187
+ setIsDragging(false);
188
+ document.documentElement.removeEventListener('mousemove', doDrag, false);
189
+ document.documentElement.removeEventListener('mouseup', stopDrag, false);
190
+ document.documentElement.removeEventListener('touchmove', doDrag, false);
191
+ document.documentElement.removeEventListener('touchend', stopDrag, false);
192
+ document.documentElement.style.userSelect = 'auto';
193
+ // noinspection JSDeprecatedSymbols
194
+ document.documentElement.style.webkitUserSelect = 'auto'; // reuqired for safari / iOS
195
+ if (div === null || div === void 0 ? void 0 : div.current) {
196
+ divWidth.current = div.current.offsetWidth;
197
+ divHeight.current = div.current.offsetHeight;
198
+ deltaWidth.current = 0;
199
+ const update = {
200
+ div,
201
+ divWidth: divWidth.current,
202
+ divHeight: divHeight.current,
203
+ deltaWidth: deltaWidth.current,
204
+ };
205
+ onResize(update);
206
+ onResizeEnd(update);
207
+ }
208
+ setLastWidth(divWidth.current);
209
+ if (!isOver.current)
210
+ setHighlight(false);
211
+ }, [doDrag, onResizeEnd, onResize, setHighlight]);
212
+ // handle starting drag
213
+ const initDrag = React.useCallback((e) => {
214
+ if ((div === null || div === void 0 ? void 0 : div.current) && document.defaultView) {
215
+ setIsDragging(true);
216
+ const el = div.current;
217
+ divWidth.current = div.current.offsetWidth;
218
+ divHeight.current = div.current.offsetHeight;
219
+ deltaWidth.current = 0;
220
+ startX.current = utils.pointerPosition(e);
221
+ startWidth.current = Number.parseInt(document.defaultView.getComputedStyle(el).width, 10);
222
+ document.documentElement.addEventListener('mousemove', doDrag, false);
223
+ document.documentElement.addEventListener('mouseup', stopDrag, false);
224
+ document.documentElement.addEventListener('touchmove', doDrag, false);
225
+ document.documentElement.addEventListener('touchend', stopDrag, false);
226
+ document.documentElement.style.userSelect = 'none';
227
+ // noinspection JSDeprecatedSymbols
228
+ document.documentElement.style.webkitUserSelect = 'none'; // reuqired for safari / iOS
229
+ const update = {
230
+ div,
231
+ divWidth: divWidth.current,
232
+ divHeight: divHeight.current,
233
+ deltaWidth: deltaWidth.current,
234
+ };
235
+ onResize(update);
236
+ onResizeStart(update);
237
+ }
238
+ }, [doDrag, stopDrag, onResize, onResizeStart]);
239
+ React.useEffect(() => {
240
+ const hl = handle === null || handle === void 0 ? void 0 : handle.current;
241
+ if (hl && drags) {
242
+ hl.addEventListener('mousedown', initDrag, false);
243
+ hl.addEventListener('touchstart', initDrag, { passive: true });
244
+ }
245
+ return () => {
246
+ if (hl) {
247
+ hl.removeEventListener('mousedown', initDrag, false);
248
+ hl.removeEventListener('touchstart', initDrag);
249
+ }
250
+ };
251
+ }, [drags, initDrag]);
252
+ const leftRightStyle = React.useMemo(() => {
253
+ if (dragsRight) {
254
+ return { right: isTouchDevice ? -22 : -((gripper.width || 10) / 2) };
255
+ }
256
+ return { left: isTouchDevice ? -22 : -((gripper.width || 10) / 2) };
257
+ }, [dragsRight, isTouchDevice, gripper.width]);
258
+ const width = React.useMemo(() => {
259
+ if (!drags)
260
+ return '100%';
261
+ if (panelClosed)
262
+ return 0;
263
+ if (lastWidth)
264
+ return lastWidth;
265
+ return constraints.initial;
266
+ }, [drags, panelClosed, lastWidth, constraints.initial]);
267
+ const cssVars = React.useMemo(() => {
268
+ return {
269
+ '--panel-bg': bgColor !== null && bgColor !== void 0 ? bgColor : 'transparent',
270
+ };
271
+ }, [bgColor]);
272
+ return (jsxRuntime.jsxs("div", Object.assign({ id: divId, className: `${css.panel}${divClass}`, ref: div, onContextMenu: (e) => {
273
+ if (disableOnContext)
274
+ e.preventDefault();
275
+ return true;
276
+ }, style: Object.assign(Object.assign(Object.assign({}, divStyle), cssVars), { overflow: 'visible', width: width, height: '100%', maxWidth: drags ? constraints.max : 'unset', transition: isDragging ? '' : 'width 0.2s ease', borderRight: panelClosed || !borderRight || !drags ? 'none' : borderRight, borderLeft: panelClosed || !borderLeft || !drags ? 'none' : borderLeft }) }, rest, { children: [jsxRuntime.jsxs("div", { ref: handle, style: Object.assign(Object.assign({ position: 'absolute', boxSizing: 'border-box', display: panelClosed || !drags ? 'none' : 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 1, top: 0 }, leftRightStyle), { bottom: 0, width: isTouchDevice ? 44 : gripper.width, backgroundColor: resizeHandle.color, cursor: 'col-resize', overflow: 'visible' }), onMouseOver: handleMouseOver, onMouseOut: handleMouseOut, onFocus: handleFocus, onBlur: handleBlur, onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, children: [dragHandle && !panelClosed && (jsxRuntime.jsx(DragHandle, Object.assign({}, (dragHandleStyle !== null && dragHandleStyle !== void 0 ? dragHandleStyle : {})))), jsxRuntime.jsx("div", { style: {
277
+ backgroundColor: handleHighlight
278
+ ? theme.current.colors['core-outline-primary']
279
+ : 'transparent',
280
+ flex: 1,
281
+ maxWidth: 3,
282
+ height: '100%',
283
+ pointerEvents: 'none',
284
+ transition: 'background-color 0.2s ease',
285
+ } })] }), jsxRuntime.jsx("div", { className: css.content, children: children })] })));
286
+ });
287
+ const DragHandle = React.memo((props) => {
288
+ const { width = 6, height = 6, radius = 100, stroke = 1, color = 'var(--core-surface-primary)', strokeColor = 'var(--core-outline-primary)', } = props;
289
+ const cssVars = React.useMemo(() => {
290
+ return {
291
+ '--drag-handle-width': `${width}px`,
292
+ '--drag-handle-height': `${height}px`,
293
+ '--drag-handle-radius': `${radius}px`,
294
+ '--drag-handle-border': `${stroke}px`,
295
+ '--drag-handle-border-color': `${strokeColor}`,
296
+ '--drag-handle-bg': `${color}`,
297
+ };
298
+ }, [width, height, radius, stroke, color, strokeColor]);
299
+ return jsxRuntime.jsx("div", { className: css.handle, style: cssVars });
300
+ });
301
+
302
+ exports.DraggablePanel = DraggablePanel;
@@ -0,0 +1,154 @@
1
+ 'use strict';
2
+
3
+ var tslib_es6 = require('./tslib.es6-4H29ixHs.js');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var hooks_useTheme = require('../hooks/useTheme.js');
7
+ require('../theme/colors.js');
8
+ require('../hooks/useWindow.js');
9
+ var _types = require('./_types-CoWzQFsT.js');
10
+ var styleInject_es = require('./style-inject.es-XZHJH68X.js');
11
+
12
+ var css_248z = ".flexBox-module_row__PWxbe {\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowBetween__27lKK {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowStart__nJZnW {\n\tdisplay: flex;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowEnd__dHcOU {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_column__MP2Xd {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStart__Kg8cV {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: flex-start;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStartCenter__zcmtk {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnBetween__157yI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnEnd__u2nwI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-end;\n\talign-items: flex-end;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.type-module_body-xs-regular__QWEzl {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-medium__FxEAv {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-bold__rf7AV {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.25px;\n}.type-module_body-s-regular__8-FO- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-medium__qyYq- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-bold__7GQ5Z {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-m-regular__Qtp5G {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-medium__Ieh9K {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-bold__0lZ3I {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-l-regular__Ar4d3 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-medium__6tV1n {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-bold__I8Q1v {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_heading-s-bold__QFgN8 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-s-medium__jGIb2 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-bold__tdBSi {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-medium__-7Uyu {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-medium__8hGYF {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-bold__Cryjg {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}\n\n.DropDown-module_wrapper__56asG {\n\tposition: relative;\n\tgap: var(--dd-gap);\n\tmin-width: var(--dd-width);\n\twidth: var(--dd-width);\n\tborder-radius: var(--dd-border-radius);\n\tbackground-color: var(--dd-bg-color);\n\tbox-shadow: 0 0 0 var(--dd-box-shadow-size) var(--dd-border-color);\n\tpadding: var(--dd-padding-tops) var(--dd-padding-left) var(--dd-padding-tops)\n\t\tvar(--dd-padding-right) !important;\n\ttransition: all 0.2s ease-in-out 0s;\n}\n\n.DropDown-module_face__kF56R {\n\tflex: 1;\n\toverflow: hidden;\n\tdisplay: -webkit-box;\n\t-webkit-line-clamp: 1;\n\t-webkit-box-orient: vertical;\n\ttext-overflow: ellipsis;\n\tword-break: break-all;\n\tcolor: var(--dd-color);\n}\n\n.DropDown-module_small__QYoM4 {\n}\n\n.DropDown-module_medium__FrKVH {\n}\n\n.DropDown-module_large__O1hDm {\n}\n\n.DropDown-module_chevron__upYr7 {\n\tmin-height: var(--dd-icon-size);\n\tmax-height: var(--dd-icon-size);\n\tmin-width: var(--dd-icon-size);\n\tmax-width: var(--dd-icon-size);\n}\n\n.DropDown-module_select__1rQRA {\n\tposition: absolute;\n\topacity: 0;\n\twidth: 100%;\n\theight: 100%;\n\tfont-size: 14px;\n\tbackground-color: #1f99cd;\n\tbackground-position: right 10px center;\n\tbackground-repeat: no-repeat;\n\tbackground-size: auto 50%;\n\tborder: none;\n\toutline: none;\n\t-moz-appearance: none;\n\t-webkit-appearance: none;\n\tappearance: none;\n\t&::-ms-expand {\n\t\tdisplay: none;\n\t}\n}\n";
13
+ var css = {"wrapper":"DropDown-module_wrapper__56asG flexBox-module_rowStart__nJZnW","face":"DropDown-module_face__kF56R flexBox-module_rowStart__nJZnW","small":"DropDown-module_small__QYoM4 type-module_body-s-regular__8-FO-","medium":"DropDown-module_medium__FrKVH type-module_body-m-regular__Qtp5G","large":"DropDown-module_large__O1hDm type-module_body-l-regular__Ar4d3","chevron":"DropDown-module_chevron__upYr7 flexBox-module_rowStart__nJZnW","select":"DropDown-module_select__1rQRA"};
14
+ styleInject_es.styleInject(css_248z);
15
+
16
+ const DropDown = React.memo((props) => {
17
+ const theme = hooks_useTheme.useTheme();
18
+ const { name = 'Select', width = '100%', height = 'auto', selectedIndex = 0, selectedValue = '', options = [], placeholder = true, validate = true, borderRadius = 4, bgColor = 'transparent', iconColor = theme.current.colors['core-icon-primary'], paddingLeft = '8px', paddingRight = '12px', paddingTops = '8px', iconSize = 20, disabled = false, unframed = false, focused = false, gap = 0, size = 'medium', onChange = () => null, onValidate = () => null, onFocus = () => null, onBlur = () => null } = props, divAttributes = tslib_es6.__rest(props, ["name", "width", "height", "selectedIndex", "selectedValue", "options", "placeholder", "validate", "borderRadius", "bgColor", "iconColor", "paddingLeft", "paddingRight", "paddingTops", "iconSize", "disabled", "unframed", "focused", "gap", "size", "onChange", "onValidate", "onFocus", "onBlur"]);
19
+ const { id: divId, className, style } = divAttributes, rest = tslib_es6.__rest(divAttributes, ["id", "className", "style"]);
20
+ const divStyle = style !== null && style !== void 0 ? style : {};
21
+ const divClass = className ? ` ${className}` : '';
22
+ const [index, setIndex] = React.useState(selectedIndex);
23
+ const [selectedText, setSelectedText] = React.useState('Select an option');
24
+ const [initiated, setInitiated] = React.useState(false);
25
+ const [color, setColor] = React.useState(iconColor);
26
+ const ref = React.useRef(null);
27
+ React.useEffect(() => setColor(theme.current.colors['core-icon-primary']), [theme]);
28
+ // validate selection and if there's a placeholder
29
+ // with a validate flag, set error state and event error
30
+ React.useEffect(() => {
31
+ let valid = true;
32
+ if (validate && placeholder && index === 0)
33
+ valid = false;
34
+ if (!initiated)
35
+ valid = true;
36
+ onValidate(valid);
37
+ }, [index, validate, placeholder, initiated, onValidate]);
38
+ // set focus
39
+ React.useEffect(() => {
40
+ if (focused && (ref === null || ref === void 0 ? void 0 : ref.current)) {
41
+ setInitiated(true);
42
+ ref.current.click();
43
+ }
44
+ }, [focused]);
45
+ // set selected by index
46
+ React.useEffect(() => {
47
+ if (ref === null || ref === void 0 ? void 0 : ref.current) {
48
+ if (!(options === null || options === void 0 ? void 0 : options[selectedIndex]))
49
+ return;
50
+ const label = options[selectedIndex].label || 'Select an option';
51
+ setIndex(selectedIndex);
52
+ setSelectedText(label);
53
+ ref.current.selectedIndex = selectedIndex;
54
+ }
55
+ }, [selectedIndex, options]);
56
+ // set selected by value - FIXED: potential infinite loop
57
+ React.useEffect(() => {
58
+ if (!options || options.length === 0 || selectedValue === '')
59
+ return;
60
+ const foundIndex = options.findIndex((option) => {
61
+ var _a, _b, _c;
62
+ return ((_a = option === null || option === void 0 ? void 0 : option.value) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
63
+ selectedValue.toString().toLowerCase() ||
64
+ ((_b = option === null || option === void 0 ? void 0 : option.label) === null || _b === void 0 ? void 0 : _b.toLowerCase()) ===
65
+ selectedValue.toString().toLowerCase() ||
66
+ ((_c = option === null || option === void 0 ? void 0 : option.alt) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === selectedValue.toString().toLowerCase();
67
+ });
68
+ if (foundIndex !== -1) {
69
+ const label = options[foundIndex].label || 'Select an option';
70
+ setSelectedText(label);
71
+ setIndex(foundIndex);
72
+ if (ref.current)
73
+ ref.current.selectedIndex = foundIndex;
74
+ }
75
+ }, [selectedValue, options]);
76
+ // memo on change
77
+ const handleChange = React.useCallback((i) => {
78
+ if (!options)
79
+ return;
80
+ const label = options[i].label || 'Select an option';
81
+ setIndex(i);
82
+ setSelectedText(label);
83
+ if (index !== i)
84
+ onChange(i, options[i]);
85
+ onBlur(options[i].label || '');
86
+ }, [options, index, onChange, onBlur]);
87
+ // memo focus
88
+ const handleFocus = React.useCallback(() => {
89
+ setInitiated(true);
90
+ onFocus();
91
+ }, [onFocus]);
92
+ // Memoize renderOptions
93
+ const renderedOptions = React.useMemo(() => {
94
+ if (!options)
95
+ return null;
96
+ return options.map((option, i) => (jsxRuntime.jsx("option", { value: option === null || option === void 0 ? void 0 : option.value, onMouseUp: () => handleChange(i), children: option === null || option === void 0 ? void 0 : option.label }, `${option === null || option === void 0 ? void 0 : option.value}_${i}`)));
97
+ }, [options, handleChange]);
98
+ // Memoize displayed text
99
+ const displayText = React.useMemo(() => selectedText.replace('-- ', ''), [selectedText]);
100
+ // Memoize handleMouseDown
101
+ const handleMouseDown = React.useCallback((e) => {
102
+ if (disabled)
103
+ e.preventDefault();
104
+ handleFocus();
105
+ }, [disabled, handleFocus]);
106
+ // Memoize onChange handler
107
+ const handleSelectChange = React.useCallback((e) => {
108
+ handleChange(e.target.selectedIndex);
109
+ }, [handleChange]);
110
+ const getSize = React.useCallback((value) => {
111
+ if (typeof value === 'string')
112
+ return value;
113
+ return `${value}px`;
114
+ }, []);
115
+ const cssVars = React.useMemo(() => {
116
+ return {
117
+ '--dd-gap': `${gap}px`,
118
+ '--dd-height': `${getSize(height)}`,
119
+ '--dd-width': `${getSize(width)}`,
120
+ '--dd-margin': '8px',
121
+ '--dd-border-radius': borderRadius ? `${borderRadius}px` : '4px',
122
+ '--dd-box-shadow-size': unframed ? '0' : '1px',
123
+ '--dd-border-color': unframed
124
+ ? 'transparent'
125
+ : 'var(--core-outline-primary)',
126
+ '--dd-bg-color': bgColor !== null && bgColor !== void 0 ? bgColor : 'transparent',
127
+ '--dd-padding-left': unframed ? '0' : `${getSize(paddingLeft)}`,
128
+ '--dd-padding-right': unframed ? '0' : `${getSize(paddingRight)}`,
129
+ '--dd-padding-tops': unframed ? '0' : `${getSize(paddingTops)}`,
130
+ '--dd-icon-size': `${iconSize}px`,
131
+ '--dd-color': placeholder && index === 0
132
+ ? 'var(--core-text-tertiary)'
133
+ : 'var(--core-text-primary)',
134
+ };
135
+ }, [
136
+ gap,
137
+ height,
138
+ width,
139
+ borderRadius,
140
+ bgColor,
141
+ paddingLeft,
142
+ paddingRight,
143
+ paddingTops,
144
+ unframed,
145
+ placeholder,
146
+ iconSize,
147
+ index,
148
+ getSize,
149
+ ]);
150
+ return (jsxRuntime.jsxs("div", Object.assign({ id: divId, className: `${css.wrapper}${divClass}`, style: Object.assign(Object.assign({}, divStyle), cssVars) }, rest, { children: [jsxRuntime.jsx("div", { className: `${css.face} ${css[size]}`, children: displayText }), jsxRuntime.jsx("div", { className: css.chevron, children: jsxRuntime.jsx(_types.Icon, { name: "chevron down", size: iconSize, strokeColor: color }) }), jsxRuntime.jsx("select", { className: css.select, defaultValue: index, ref: ref, onFocus: handleFocus, onMouseDown: handleMouseDown, onChange: handleSelectChange, "aria-label": name, children: renderedOptions })] })));
151
+ });
152
+ DropDown.displayName = 'DropDown';
153
+
154
+ exports.DropDown = DropDown;