@tcn/ui 0.5.0 → 0.7.0

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 (125) hide show
  1. package/dist/confirm.css +1 -1
  2. package/dist/draggable.module-BgelQsuJ.js +5 -0
  3. package/dist/draggable.module-BgelQsuJ.js.map +1 -0
  4. package/dist/form/field/field.js +13 -10
  5. package/dist/form/field/field.js.map +1 -1
  6. package/dist/inputs/color_input/color_picker.js +5 -3
  7. package/dist/inputs/color_input/color_picker.js.map +1 -1
  8. package/dist/inputs/combo_box/combo_box.js +4 -2
  9. package/dist/inputs/combo_box/combo_box.js.map +1 -1
  10. package/dist/inputs/date_picker/date_picker.js +16 -14
  11. package/dist/inputs/date_picker/date_picker.js.map +1 -1
  12. package/dist/inputs/date_picker/date_picker_input.js +10 -8
  13. package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
  14. package/dist/inputs/date_picker/date_picker_year_selector.js +4 -2
  15. package/dist/inputs/date_picker/date_picker_year_selector.js.map +1 -1
  16. package/dist/inputs/mask_input/key_capture_input.js +15 -12
  17. package/dist/inputs/mask_input/key_capture_input.js.map +1 -1
  18. package/dist/inputs/mask_input/mask_input.js +13 -10
  19. package/dist/inputs/mask_input/mask_input.js.map +1 -1
  20. package/dist/inputs/multiselect/multiselect.js +9 -7
  21. package/dist/inputs/multiselect/multiselect.js.map +1 -1
  22. package/dist/inputs/phone_number_input/phone_number_input.d.ts +1 -0
  23. package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
  24. package/dist/inputs/phone_number_input/phone_number_input.js +136 -133
  25. package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
  26. package/dist/inputs/select/select.js +4 -2
  27. package/dist/inputs/select/select.js.map +1 -1
  28. package/dist/inputs/slider/slider.js +7 -5
  29. package/dist/inputs/slider/slider.js.map +1 -1
  30. package/dist/inputs/suggestions/suggestion_list.js +4 -2
  31. package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
  32. package/dist/inputs/switch/switch.js +16 -14
  33. package/dist/inputs/switch/switch.js.map +1 -1
  34. package/dist/inputs/unit_input/unit_input.js +16 -14
  35. package/dist/inputs/unit_input/unit_input.js.map +1 -1
  36. package/dist/navigation/tabs/state/link/tab_link.js +9 -6
  37. package/dist/navigation/tabs/state/link/tab_link.js.map +1 -1
  38. package/dist/navigation/tabs/state/link/use_tab_link.js +8 -8
  39. package/dist/navigation/tabs/state/link/use_tab_link.js.map +1 -1
  40. package/dist/overlay/caret/caret.d.ts +8 -0
  41. package/dist/overlay/caret/caret.d.ts.map +1 -0
  42. package/dist/overlay/caret/caret.js +20 -0
  43. package/dist/overlay/caret/caret.js.map +1 -0
  44. package/dist/overlay/menu/menu.js +34 -32
  45. package/dist/overlay/menu/menu.js.map +1 -1
  46. package/dist/overlay/popper/legacy/popper.js +22 -20
  47. package/dist/overlay/popper/legacy/popper.js.map +1 -1
  48. package/dist/overlay/popper/preview_popper.js +12 -9
  49. package/dist/overlay/popper/preview_popper.js.map +1 -1
  50. package/dist/overlay/tethered/hooks/calculate_origin.d.ts +23 -0
  51. package/dist/overlay/tethered/hooks/calculate_origin.d.ts.map +1 -0
  52. package/dist/overlay/tethered/hooks/calculate_origin.js +41 -0
  53. package/dist/overlay/tethered/hooks/calculate_origin.js.map +1 -0
  54. package/dist/overlay/tethered/hooks/useCaretRefDimensions.d.ts +9 -0
  55. package/dist/overlay/tethered/hooks/useCaretRefDimensions.d.ts.map +1 -0
  56. package/dist/overlay/tethered/hooks/useCaretRefDimensions.js +14 -0
  57. package/dist/overlay/tethered/hooks/useCaretRefDimensions.js.map +1 -0
  58. package/dist/overlay/tethered/hooks/useTether.d.ts +1 -1
  59. package/dist/overlay/tethered/hooks/useTether.d.ts.map +1 -1
  60. package/dist/overlay/tethered/hooks/useTether.js +22 -21
  61. package/dist/overlay/tethered/hooks/useTether.js.map +1 -1
  62. package/dist/overlay/tethered/hooks/useTetherContentRect.d.ts +3 -0
  63. package/dist/overlay/tethered/hooks/useTetherContentRect.d.ts.map +1 -0
  64. package/dist/overlay/tethered/hooks/useTetherContentRect.js +36 -0
  65. package/dist/overlay/tethered/hooks/useTetherContentRect.js.map +1 -0
  66. package/dist/overlay/tethered/hooks/useTetherOrigin.d.ts +14 -0
  67. package/dist/overlay/tethered/hooks/useTetherOrigin.d.ts.map +1 -0
  68. package/dist/overlay/tethered/hooks/useTetherOrigin.js +24 -0
  69. package/dist/overlay/tethered/hooks/useTetherOrigin.js.map +1 -0
  70. package/dist/overlay/tethered/tethered.d.ts +2 -1
  71. package/dist/overlay/tethered/tethered.d.ts.map +1 -1
  72. package/dist/overlay/tethered/tethered.js +71 -38
  73. package/dist/overlay/tethered/tethered.js.map +1 -1
  74. package/dist/stacks/box/box.js +29 -27
  75. package/dist/stacks/box/box.js.map +1 -1
  76. package/dist/stacks/h_collapsible_box.js +14 -12
  77. package/dist/stacks/h_collapsible_box.js.map +1 -1
  78. package/dist/stacks/v_collapsible_box.js +8 -6
  79. package/dist/stacks/v_collapsible_box.js.map +1 -1
  80. package/dist/surfaces/pop_confirm/pop_confirm.d.ts.map +1 -1
  81. package/dist/surfaces/pop_confirm/pop_confirm.js +14 -13
  82. package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
  83. package/dist/surfaces/tooltip/tooltip.d.ts.map +1 -1
  84. package/dist/surfaces/tooltip/tooltip.js +12 -11
  85. package/dist/surfaces/tooltip/tooltip.js.map +1 -1
  86. package/dist/tethered.css +1 -1
  87. package/dist/themes/themes/ergo/ergo_theme.css +1 -1
  88. package/dist/themes/themes/ergo/ergo_theme.js +86 -56
  89. package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
  90. package/dist/themes/themes/windows_98/windows_98.css +1 -1
  91. package/dist/themes/themes/windows_98/windows_98_theme.js +18 -18
  92. package/dist/themes/themes/windows_98/windows_98_theme.js.map +1 -1
  93. package/dist/utils/dnd/draggable/draggable.js +13 -12
  94. package/dist/utils/dnd/draggable/draggable.js.map +1 -1
  95. package/dist/utils/index.d.ts +2 -0
  96. package/dist/utils/index.d.ts.map +1 -1
  97. package/dist/utils/index.js +23 -19
  98. package/dist/utils/index.js.map +1 -1
  99. package/package.json +9 -9
  100. package/src/inputs/phone_number_input/phone_number_input.stories.tsx +24 -0
  101. package/src/inputs/phone_number_input/phone_number_input.tsx +8 -6
  102. package/src/navigation/tabs/state/link/use_tab_link.ts +4 -4
  103. package/src/overlay/{carrot/carrot.stories.tsx → caret/caret.stories.tsx} +14 -14
  104. package/src/overlay/caret/caret.tsx +24 -0
  105. package/src/overlay/tethered/__stories__/shared/base_story_config.ts +8 -0
  106. package/src/overlay/tethered/hooks/calculate_origin.ts +74 -0
  107. package/src/overlay/tethered/hooks/useCaretRefDimensions.ts +22 -0
  108. package/src/overlay/tethered/hooks/useTether.ts +4 -3
  109. package/src/overlay/tethered/hooks/useTetherContentRect.ts +49 -0
  110. package/src/overlay/tethered/hooks/useTetherOrigin.ts +49 -0
  111. package/src/overlay/tethered/tethered.module.css +55 -0
  112. package/src/overlay/tethered/tethered.tsx +44 -6
  113. package/src/surfaces/confirm/confirm.module.css +0 -1
  114. package/src/surfaces/panel/__stories__/panel.stories.tsx +62 -27
  115. package/src/surfaces/panel/__stories__/panel_stories.module.css +14 -1
  116. package/src/surfaces/pop_confirm/pop_confirm.tsx +4 -3
  117. package/src/surfaces/tooltip/tooltip.tsx +1 -0
  118. package/src/themes/themes/ergo/ergo_theme.css +86 -56
  119. package/src/themes/themes/windows_98/windows_98.css +18 -18
  120. package/src/utils/index.ts +3 -0
  121. package/dist/overlay/carrot/base_carrot.d.ts +0 -8
  122. package/dist/overlay/carrot/base_carrot.d.ts.map +0 -1
  123. package/dist/overlay/carrot/base_carrot.js +0 -21
  124. package/dist/overlay/carrot/base_carrot.js.map +0 -1
  125. package/src/overlay/carrot/base_carrot.tsx +0 -24
@@ -1,19 +1,19 @@
1
- import { useState as h, useRef as m, useCallback as l, useLayoutEffect as g } from "react";
2
- import { calculateTetheredPosition as y } from "./calculate_position.js";
1
+ import { useState as f, useRef as m, useCallback as g, useLayoutEffect as l } from "react";
2
+ import { calculateTetheredPosition as a } from "./calculate_position.js";
3
3
  function E({
4
- anchor: n,
5
- verticalAnchor: r = "bottom",
6
- verticalOrigin: s = "top",
4
+ anchor: o,
5
+ verticalAnchor: s = "bottom",
6
+ verticalOrigin: r = "top",
7
7
  horizontalAnchor: u = "start",
8
8
  horizontalOrigin: d = "start",
9
9
  verticalOffset: p = 0,
10
- horizontalOffset: w = 0
10
+ horizontalOffset: c = 0
11
11
  }) {
12
- const [o, c] = h({ top: 0, left: 0 }), i = m(null), f = l(() => {
13
- if (!n || !i.current) return;
14
- const t = i.current.getBoundingClientRect(), e = getComputedStyle(i.current);
15
- return y({
16
- anchor: n,
12
+ const [i, h] = f({ top: 0, left: 0 }), n = m(null), w = g(() => {
13
+ if (!o || !n.current) return;
14
+ const t = n.current.getBoundingClientRect(), e = getComputedStyle(n.current);
15
+ return a({
16
+ anchor: o,
17
17
  tether: {
18
18
  dimensions: {
19
19
  width: t.width,
@@ -25,35 +25,36 @@ function E({
25
25
  }
26
26
  },
27
27
  direction: e.direction,
28
- verticalAnchor: r,
29
- verticalOrigin: s,
28
+ verticalAnchor: s,
29
+ verticalOrigin: r,
30
30
  horizontalAnchor: u,
31
31
  horizontalOrigin: d,
32
32
  verticalOffset: p,
33
- horizontalOffset: w,
33
+ horizontalOffset: c,
34
34
  viewport: {
35
35
  width: window.innerWidth,
36
36
  height: window.innerHeight
37
37
  }
38
38
  });
39
39
  }, [
40
- n,
41
- r,
40
+ o,
42
41
  s,
42
+ r,
43
43
  u,
44
44
  d,
45
45
  p,
46
- w
46
+ c
47
47
  ]);
48
- return g(() => {
48
+ return l(() => {
49
49
  const t = () => {
50
- const e = f();
51
- e && (o.top !== e.top || o.left !== e.left) && c(e);
50
+ const e = w();
51
+ if (!e) return;
52
+ (i.top !== e.top || i.left !== e.left) && h(e);
52
53
  };
53
54
  return t(), window.addEventListener("resize", t), () => {
54
55
  window.removeEventListener("resize", t);
55
56
  };
56
- }), { position: o, tetherRef: i };
57
+ }), { position: i, tetherRef: n };
57
58
  }
58
59
  export {
59
60
  E as useTether
@@ -1 +1 @@
1
- {"version":3,"file":"useTether.js","sources":["../../../../src/overlay/tethered/hooks/useTether.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport type { HorizontalTether, VerticalTether } from '../types.js';\nimport { type Rectangle } from '../../../utils/index.js';\nimport { calculateTetheredPosition } from './calculate_position.js';\n\nexport interface UseTetherParams {\n anchor: Rectangle | null;\n verticalAnchor?: VerticalTether;\n verticalOrigin?: VerticalTether;\n horizontalOrigin?: HorizontalTether;\n horizontalAnchor?: HorizontalTether;\n verticalOffset?: number;\n horizontalOffset?: number;\n}\n\nexport function useTether({\n anchor,\n verticalAnchor = 'bottom',\n verticalOrigin = 'top',\n horizontalAnchor = 'start',\n horizontalOrigin = 'start',\n verticalOffset = 0,\n horizontalOffset = 0,\n}: UseTetherParams) {\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const tetherRef = useRef<HTMLDivElement>(null);\n\n const getPosition = useCallback(() => {\n if (!anchor || !tetherRef.current) return;\n\n const tether = tetherRef.current.getBoundingClientRect();\n const computedStyle = getComputedStyle(tetherRef.current);\n\n return calculateTetheredPosition({\n anchor: anchor,\n tether: {\n dimensions: {\n width: tether.width,\n height: tether.height,\n },\n position: {\n x: tether.left,\n y: tether.top,\n },\n },\n direction: computedStyle.direction as 'ltr' | 'rtl',\n verticalAnchor: verticalAnchor,\n verticalOrigin: verticalOrigin,\n horizontalAnchor: horizontalAnchor,\n horizontalOrigin: horizontalOrigin,\n verticalOffset: verticalOffset,\n horizontalOffset: horizontalOffset,\n viewport: {\n width: window.innerWidth,\n height: window.innerHeight,\n },\n });\n }, [\n anchor,\n verticalAnchor,\n verticalOrigin,\n horizontalAnchor,\n horizontalOrigin,\n verticalOffset,\n horizontalOffset,\n ]);\n\n // Update the position when the window is resized\n useLayoutEffect(() => {\n const update = () => {\n const newPosition = getPosition();\n if (!newPosition) return;\n if (position.top !== newPosition.top || position.left !== newPosition.left) {\n setPosition(newPosition);\n }\n };\n update();\n window.addEventListener('resize', update);\n return () => {\n window.removeEventListener('resize', update);\n };\n });\n\n return { position, tetherRef };\n}\n"],"names":["useTether","anchor","verticalAnchor","verticalOrigin","horizontalAnchor","horizontalOrigin","verticalOffset","horizontalOffset","position","setPosition","useState","tetherRef","useRef","getPosition","useCallback","tether","computedStyle","calculateTetheredPosition","useLayoutEffect","update","newPosition"],"mappings":";;AAeO,SAASA,EAAU;AAAA,EACxB,QAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AAAA,EACnB,kBAAAC,IAAmB;AAAA,EACnB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAoB;AAClB,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAE,KAAK,GAAG,MAAM,GAAG,GACtDC,IAAYC,EAAuB,IAAI,GAEvCC,IAAcC,EAAY,MAAM;AACpC,QAAI,CAACb,KAAU,CAACU,EAAU,QAAS;AAEnC,UAAMI,IAASJ,EAAU,QAAQ,sBAAA,GAC3BK,IAAgB,iBAAiBL,EAAU,OAAO;AAExD,WAAOM,EAA0B;AAAA,MAC/B,QAAAhB;AAAA,MACA,QAAQ;AAAA,QACN,YAAY;AAAA,UACV,OAAOc,EAAO;AAAA,UACd,QAAQA,EAAO;AAAA,QAAA;AAAA,QAEjB,UAAU;AAAA,UACR,GAAGA,EAAO;AAAA,UACV,GAAGA,EAAO;AAAA,QAAA;AAAA,MACZ;AAAA,MAEF,WAAWC,EAAc;AAAA,MACzB,gBAAAd;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,UAAU;AAAA,QACR,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,MAAA;AAAA,IACjB,CACD;AAAA,EACH,GAAG;AAAA,IACDN;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD;AAGD,SAAAW,EAAgB,MAAM;AACpB,UAAMC,IAAS,MAAM;AACnB,YAAMC,IAAcP,EAAA;AACpB,MAAKO,MACDZ,EAAS,QAAQY,EAAY,OAAOZ,EAAS,SAASY,EAAY,SACpEX,EAAYW,CAAW;AAAA,IAE3B;AACA,WAAAD,EAAA,GACA,OAAO,iBAAiB,UAAUA,CAAM,GACjC,MAAM;AACX,aAAO,oBAAoB,UAAUA,CAAM;AAAA,IAC7C;AAAA,EACF,CAAC,GAEM,EAAE,UAAAX,GAAU,WAAAG,EAAA;AACrB;"}
1
+ {"version":3,"file":"useTether.js","sources":["../../../../src/overlay/tethered/hooks/useTether.ts"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { type Rectangle } from '../../../utils/index.js';\nimport type { HorizontalTether, VerticalTether } from '../types.js';\nimport { calculateTetheredPosition } from './calculate_position.js';\n\nexport interface UseTetherParams {\n anchor: Rectangle | null;\n verticalAnchor?: VerticalTether;\n verticalOrigin?: VerticalTether;\n horizontalOrigin?: HorizontalTether;\n horizontalAnchor?: HorizontalTether;\n verticalOffset?: number;\n horizontalOffset?: number;\n}\n\nexport function useTether({\n anchor,\n verticalAnchor = 'bottom',\n verticalOrigin = 'top',\n horizontalAnchor = 'start',\n horizontalOrigin = 'start',\n verticalOffset = 0,\n horizontalOffset = 0,\n}: UseTetherParams) {\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const tetherRef = useRef<HTMLDivElement>(null);\n\n const getPosition = useCallback(() => {\n if (!anchor || !tetherRef.current) return;\n\n const tether = tetherRef.current.getBoundingClientRect();\n const computedStyle = getComputedStyle(tetherRef.current);\n\n return calculateTetheredPosition({\n anchor: anchor,\n tether: {\n dimensions: {\n width: tether.width,\n height: tether.height,\n },\n position: {\n x: tether.left,\n y: tether.top,\n },\n },\n direction: computedStyle.direction as 'ltr' | 'rtl',\n verticalAnchor: verticalAnchor,\n verticalOrigin: verticalOrigin,\n horizontalAnchor: horizontalAnchor,\n horizontalOrigin: horizontalOrigin,\n verticalOffset: verticalOffset,\n horizontalOffset: horizontalOffset,\n viewport: {\n width: window.innerWidth,\n height: window.innerHeight,\n },\n });\n }, [\n anchor,\n verticalAnchor,\n verticalOrigin,\n horizontalAnchor,\n horizontalOrigin,\n verticalOffset,\n horizontalOffset,\n ]);\n\n useLayoutEffect(() => {\n const update = () => {\n const newPosition = getPosition();\n if (!newPosition) return;\n const hasChanged =\n position.top !== newPosition.top || position.left !== newPosition.left;\n if (hasChanged) {\n setPosition(newPosition);\n }\n };\n update();\n window.addEventListener('resize', update);\n return () => {\n window.removeEventListener('resize', update);\n };\n });\n\n return { position, tetherRef };\n}\n"],"names":["useTether","anchor","verticalAnchor","verticalOrigin","horizontalAnchor","horizontalOrigin","verticalOffset","horizontalOffset","position","setPosition","useState","tetherRef","useRef","getPosition","useCallback","tether","computedStyle","calculateTetheredPosition","useLayoutEffect","update","newPosition"],"mappings":";;AAeO,SAASA,EAAU;AAAA,EACxB,QAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AAAA,EACnB,kBAAAC,IAAmB;AAAA,EACnB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAoB;AAClB,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAE,KAAK,GAAG,MAAM,GAAG,GACtDC,IAAYC,EAAuB,IAAI,GAEvCC,IAAcC,EAAY,MAAM;AACpC,QAAI,CAACb,KAAU,CAACU,EAAU,QAAS;AAEnC,UAAMI,IAASJ,EAAU,QAAQ,sBAAA,GAC3BK,IAAgB,iBAAiBL,EAAU,OAAO;AAExD,WAAOM,EAA0B;AAAA,MAC/B,QAAAhB;AAAA,MACA,QAAQ;AAAA,QACN,YAAY;AAAA,UACV,OAAOc,EAAO;AAAA,UACd,QAAQA,EAAO;AAAA,QAAA;AAAA,QAEjB,UAAU;AAAA,UACR,GAAGA,EAAO;AAAA,UACV,GAAGA,EAAO;AAAA,QAAA;AAAA,MACZ;AAAA,MAEF,WAAWC,EAAc;AAAA,MACzB,gBAAAd;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,UAAU;AAAA,QACR,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,MAAA;AAAA,IACjB,CACD;AAAA,EACH,GAAG;AAAA,IACDN;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD;AAED,SAAAW,EAAgB,MAAM;AACpB,UAAMC,IAAS,MAAM;AACnB,YAAMC,IAAcP,EAAA;AACpB,UAAI,CAACO,EAAa;AAGlB,OADEZ,EAAS,QAAQY,EAAY,OAAOZ,EAAS,SAASY,EAAY,SAElEX,EAAYW,CAAW;AAAA,IAE3B;AACA,WAAAD,EAAA,GACA,OAAO,iBAAiB,UAAUA,CAAM,GACjC,MAAM;AACX,aAAO,oBAAoB,UAAUA,CAAM;AAAA,IAC7C;AAAA,EACF,CAAC,GAEM,EAAE,UAAAX,GAAU,WAAAG,EAAA;AACrB;"}
@@ -0,0 +1,3 @@
1
+ import { Rectangle } from '../../../utils/index.js';
2
+ export declare function useTetherContentRect(ref: React.RefObject<HTMLElement>): Rectangle;
3
+ //# sourceMappingURL=useTetherContentRect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTetherContentRect.d.ts","sourceRoot":"","sources":["../../../../src/overlay/tethered/hooks/useTetherContentRect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAuBzD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,SAAS,CAwBjF"}
@@ -0,0 +1,36 @@
1
+ import { useState as r, useLayoutEffect as s } from "react";
2
+ function i(t) {
3
+ if (!t)
4
+ return {
5
+ dimensions: { width: 0, height: 0 },
6
+ position: { x: 0, y: 0 }
7
+ };
8
+ const e = t.getBoundingClientRect();
9
+ return {
10
+ dimensions: {
11
+ width: e.width,
12
+ height: e.height
13
+ },
14
+ position: {
15
+ x: e.left,
16
+ y: e.top
17
+ }
18
+ };
19
+ }
20
+ function u(t) {
21
+ const [e, o] = r(
22
+ () => i(t.current)
23
+ );
24
+ return s(() => {
25
+ const n = () => {
26
+ o(i(t.current));
27
+ };
28
+ return n(), window.addEventListener("resize", n), window.addEventListener("scroll", n, !0), () => {
29
+ window.removeEventListener("resize", n), window.removeEventListener("scroll", n, !0);
30
+ };
31
+ }, [t]), e;
32
+ }
33
+ export {
34
+ u as useTetherContentRect
35
+ };
36
+ //# sourceMappingURL=useTetherContentRect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTetherContentRect.js","sources":["../../../../src/overlay/tethered/hooks/useTetherContentRect.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\nimport type { Rectangle } from '../../../utils/index.js';\n\nfunction getTetherContentRect(element: HTMLElement | null): Rectangle {\n if (!element) {\n return {\n dimensions: { width: 0, height: 0 },\n position: { x: 0, y: 0 },\n };\n }\n\n const rect = element.getBoundingClientRect();\n return {\n dimensions: {\n width: rect.width,\n height: rect.height,\n },\n position: {\n x: rect.left,\n y: rect.top,\n },\n };\n}\n\nexport function useTetherContentRect(ref: React.RefObject<HTMLElement>): Rectangle {\n const [contentRect, setContentRect] = useState<Rectangle>(() =>\n getTetherContentRect(ref.current)\n );\n\n useLayoutEffect(() => {\n const update = () => {\n setContentRect(getTetherContentRect(ref.current));\n };\n\n update();\n\n // Track resize events\n window.addEventListener('resize', update);\n // Track scroll events\n window.addEventListener('scroll', update, true);\n\n return () => {\n window.removeEventListener('resize', update);\n window.removeEventListener('scroll', update, true);\n };\n }, [ref]);\n\n return contentRect;\n}\n"],"names":["getTetherContentRect","element","rect","useTetherContentRect","ref","contentRect","setContentRect","useState","useLayoutEffect","update"],"mappings":";AAGA,SAASA,EAAqBC,GAAwC;AACpE,MAAI,CAACA;AACH,WAAO;AAAA,MACL,YAAY,EAAE,OAAO,GAAG,QAAQ,EAAA;AAAA,MAChC,UAAU,EAAE,GAAG,GAAG,GAAG,EAAA;AAAA,IAAE;AAI3B,QAAMC,IAAOD,EAAQ,sBAAA;AACrB,SAAO;AAAA,IACL,YAAY;AAAA,MACV,OAAOC,EAAK;AAAA,MACZ,QAAQA,EAAK;AAAA,IAAA;AAAA,IAEf,UAAU;AAAA,MACR,GAAGA,EAAK;AAAA,MACR,GAAGA,EAAK;AAAA,IAAA;AAAA,EACV;AAEJ;AAEO,SAASC,EAAqBC,GAA8C;AACjF,QAAM,CAACC,GAAaC,CAAc,IAAIC;AAAA,IAAoB,MACxDP,EAAqBI,EAAI,OAAO;AAAA,EAAA;AAGlC,SAAAI,EAAgB,MAAM;AACpB,UAAMC,IAAS,MAAM;AACnB,MAAAH,EAAeN,EAAqBI,EAAI,OAAO,CAAC;AAAA,IAClD;AAEA,WAAAK,EAAA,GAGA,OAAO,iBAAiB,UAAUA,CAAM,GAExC,OAAO,iBAAiB,UAAUA,GAAQ,EAAI,GAEvC,MAAM;AACX,aAAO,oBAAoB,UAAUA,CAAM,GAC3C,OAAO,oBAAoB,UAAUA,GAAQ,EAAI;AAAA,IACnD;AAAA,EACF,GAAG,CAACL,CAAG,CAAC,GAEDC;AACT;"}
@@ -0,0 +1,14 @@
1
+ import { Position } from '../../../utils/index.js';
2
+ import { HorizontalTether, VerticalTether } from '../types.js';
3
+ import { CaretDirection } from './calculate_origin.js';
4
+ export interface UseTetherOriginResult {
5
+ originPosition: Position;
6
+ originOffset: {
7
+ yOffset: number;
8
+ xOffset: number;
9
+ };
10
+ containerRef: React.RefObject<HTMLDivElement>;
11
+ originDirection: CaretDirection;
12
+ }
13
+ export declare function useTetherOrigin(tetherPosition: Position, hOrigin: HorizontalTether, vOrigin: VerticalTether, precision: 'high' | 'low'): UseTetherOriginResult;
14
+ //# sourceMappingURL=useTetherOrigin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTetherOrigin.d.ts","sourceRoot":"","sources":["../../../../src/overlay/tethered/hooks/useTetherOrigin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,QAAQ,CAAC;IACzB,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC9C,eAAe,EAAE,cAAc,CAAC;CACjC;AAED,wBAAgB,eAAe,CAC7B,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,MAAM,GAAG,KAAK,GACxB,qBAAqB,CAyBvB"}
@@ -0,0 +1,24 @@
1
+ import { useRef as g } from "react";
2
+ import { getOriginOffset as u, getOriginPosition as O, getOriginDirection as m } from "./calculate_origin.js";
3
+ import { useTetherContentRect as p } from "./useTetherContentRect.js";
4
+ function P(r, o, t, f) {
5
+ const i = g(null), n = p(i);
6
+ if (f === "low")
7
+ return {
8
+ originPosition: r,
9
+ originOffset: { yOffset: 0, xOffset: 0 },
10
+ containerRef: i,
11
+ originDirection: "none"
12
+ };
13
+ const e = u(n, o, t), s = O(n.position, e), c = m(t, o);
14
+ return {
15
+ originPosition: s,
16
+ originOffset: e,
17
+ containerRef: i,
18
+ originDirection: c
19
+ };
20
+ }
21
+ export {
22
+ P as useTetherOrigin
23
+ };
24
+ //# sourceMappingURL=useTetherOrigin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTetherOrigin.js","sources":["../../../../src/overlay/tethered/hooks/useTetherOrigin.ts"],"sourcesContent":["import { useRef } from 'react';\nimport type { Position } from '../../../utils/index.js';\nimport type { HorizontalTether, VerticalTether } from '../types.js';\nimport {\n getOriginDirection,\n getOriginOffset,\n getOriginPosition,\n type CaretDirection,\n} from './calculate_origin.js';\nimport { useTetherContentRect } from './useTetherContentRect.js';\n\nexport interface UseTetherOriginResult {\n originPosition: Position;\n originOffset: { yOffset: number; xOffset: number };\n containerRef: React.RefObject<HTMLDivElement>;\n originDirection: CaretDirection;\n}\n\nexport function useTetherOrigin(\n tetherPosition: Position,\n hOrigin: HorizontalTether,\n vOrigin: VerticalTether,\n precision: 'high' | 'low'\n): UseTetherOriginResult {\n const containerRef = useRef<HTMLDivElement>(null);\n const containerRect = useTetherContentRect(containerRef);\n\n // If precision is low, return default values\n if (precision === 'low') {\n return {\n originPosition: tetherPosition,\n originOffset: { yOffset: 0, xOffset: 0 },\n containerRef,\n originDirection: 'none',\n };\n }\n\n // Calculate origin values for high precision\n const originOffset = getOriginOffset(containerRect, hOrigin, vOrigin);\n const originPosition = getOriginPosition(containerRect.position, originOffset);\n const originDirection = getOriginDirection(vOrigin, hOrigin);\n\n return {\n originPosition,\n originOffset,\n containerRef,\n originDirection,\n };\n}\n"],"names":["useTetherOrigin","tetherPosition","hOrigin","vOrigin","precision","containerRef","useRef","containerRect","useTetherContentRect","originOffset","getOriginOffset","originPosition","getOriginPosition","originDirection","getOriginDirection"],"mappings":";;;AAkBO,SAASA,EACdC,GACAC,GACAC,GACAC,GACuB;AACvB,QAAMC,IAAeC,EAAuB,IAAI,GAC1CC,IAAgBC,EAAqBH,CAAY;AAGvD,MAAID,MAAc;AAChB,WAAO;AAAA,MACL,gBAAgBH;AAAA,MAChB,cAAc,EAAE,SAAS,GAAG,SAAS,EAAA;AAAA,MACrC,cAAAI;AAAA,MACA,iBAAiB;AAAA,IAAA;AAKrB,QAAMI,IAAeC,EAAgBH,GAAeL,GAASC,CAAO,GAC9DQ,IAAiBC,EAAkBL,EAAc,UAAUE,CAAY,GACvEI,IAAkBC,EAAmBX,GAASD,CAAO;AAE3D,SAAO;AAAA,IACL,gBAAAS;AAAA,IACA,cAAAF;AAAA,IACA,cAAAJ;AAAA,IACA,iBAAAQ;AAAA,EAAA;AAEJ;"}
@@ -1,6 +1,6 @@
1
- import { HorizontalTether, VerticalTether } from './types.js';
2
1
  import { ZStackProps } from '../../stacks/index.js';
3
2
  import { Rectangle } from '../../utils/index.js';
3
+ import { HorizontalTether, VerticalTether } from './types.js';
4
4
  export interface BaseTetheredOwnProps {
5
5
  verticalAnchor?: VerticalTether;
6
6
  verticalOrigin?: VerticalTether;
@@ -11,6 +11,7 @@ export interface BaseTetheredOwnProps {
11
11
  }
12
12
  export interface TetheredOwnProp extends BaseTetheredOwnProps {
13
13
  anchor: Rectangle | null;
14
+ precision?: 'high' | 'low';
14
15
  }
15
16
  export interface TetheredProps extends TetheredOwnProp, ZStackProps {
16
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tethered.d.ts","sourceRoot":"","sources":["../../../src/overlay/tethered/tethered.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQlE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,oBAAoB;IAC3D,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;CAC1B;AACD,MAAM,WAAW,aAAc,SAAQ,eAAe,EAAE,WAAW;CAAG;AAEtE,eAAO,MAAM,QAAQ;;+CA8CpB,CAAC"}
1
+ {"version":3,"file":"tethered.d.ts","sourceRoot":"","sources":["../../../src/overlay/tethered/tethered.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMlE,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKnE,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAgB,SAAQ,oBAAoB;IAC3D,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AACD,MAAM,WAAW,aAAc,SAAQ,eAAe,EAAE,WAAW;CAAG;AAEtE,eAAO,MAAM,QAAQ;;+CAgFpB,CAAC"}
@@ -1,59 +1,92 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { forwardRef as R } from "react";
1
+ import { jsx as p, jsxs as P } from "react/jsx-runtime";
2
+ import { clsx as c } from "clsx";
3
+ import { forwardRef as j } from "react";
3
4
  import "../../stacks/box/box.js";
4
5
  import "../../stacks/h_collapsible_box.js";
5
6
  import "../../stacks/h_stack.js";
6
7
  import "../../stacks/spacer.js";
7
8
  import "../../stacks/v_collapsible_box.js";
8
9
  import "../../stacks/v_stack.js";
9
- import { ZStack as b } from "../../stacks/z_stack.js";
10
+ import { ZStack as D } from "../../stacks/z_stack.js";
10
11
  import "../../utils/click_away_listener.js";
11
12
  import "../../utils/focus_redirect.js";
12
13
  import "../../utils/scroll_away_listener.js";
13
- import { useForkRef as k } from "../../utils/hooks/use_fork_ref.js";
14
+ import { useForkRef as E } from "../../utils/hooks/use_fork_ref.js";
14
15
  import "../../utils/hooks/use_resize_observer.js";
15
- import { useTether as T } from "./hooks/useTether.js";
16
- import { clsx as y } from "clsx";
17
- import { Portal as _ } from "../portal/portal.js";
18
- import '../../tethered.css';const $ = "_tethered_44058d8", j = { tethered: $ }, I = R(
16
+ import "../../utils/dnd/context.js";
17
+ import "../../draggable.module-BgelQsuJ.js";
18
+ import { Caret as N } from "../caret/caret.js";
19
+ import { Portal as S } from "../portal/portal.js";
20
+ import { useCaretRefDimensions as F } from "./hooks/useCaretRefDimensions.js";
21
+ import { useTether as I } from "./hooks/useTether.js";
22
+ import { useTetherOrigin as V } from "./hooks/useTetherOrigin.js";
23
+ import '../../tethered.css';const Z = "_origin-indicator_cbc16ea", q = "_tethered_44058d8", f = { "origin-indicator": Z, tethered: q }, mt = j(
19
24
  function({
20
- anchor: r,
21
- verticalAnchor: e = "bottom",
22
- verticalOrigin: m = "top",
23
- horizontalAnchor: p = "start",
24
- horizontalOrigin: i = "start",
25
- verticalOffset: s = 0,
26
- horizontalOffset: f = 0,
27
- children: c,
28
- style: n,
29
- className: d,
30
- ...a
31
- }, h) {
32
- const { position: t, tetherRef: l } = T({
33
- anchor: r,
34
- verticalAnchor: e,
35
- verticalOrigin: m,
36
- horizontalAnchor: p,
37
- horizontalOrigin: i,
38
- verticalOffset: s,
39
- horizontalOffset: f
40
- }), u = k(h, l), x = {
25
+ anchor: h,
26
+ verticalAnchor: n = "bottom",
27
+ verticalOrigin: r = "top",
28
+ horizontalAnchor: s = "start",
29
+ horizontalOrigin: o = "start",
30
+ verticalOffset: x = 0,
31
+ horizontalOffset: g = 0,
32
+ precision: i = "low",
33
+ children: l,
34
+ style: $,
35
+ className: y,
36
+ ...R
37
+ }, u) {
38
+ const { position: t, tetherRef: w } = I({
39
+ anchor: h,
40
+ verticalAnchor: n,
41
+ verticalOrigin: r,
42
+ horizontalAnchor: s,
43
+ horizontalOrigin: o,
44
+ verticalOffset: x,
45
+ horizontalOffset: g
46
+ }), T = { x: t.left, y: t.top }, { originPosition: m, originOffset: d, containerRef: _, originDirection: e } = V(T, o, r, i), { caretElementRef: b, caretSize: a } = F(
47
+ i,
48
+ e
49
+ ), k = E(u, w, _), C = {
41
50
  "--tethered-top": `${t.top}px`,
42
- "--tethered-left": `${t.left}px`
51
+ "--tethered-left": `${t.left}px`,
52
+ "--tethered-origin-y": `${m.y}px`,
53
+ "--tethered-origin-x": `${m.x}px`,
54
+ "--tethered-origin-delta-y": `${d.yOffset}px`,
55
+ "--tethered-origin-delta-x": `${d.xOffset}px`,
56
+ "--origin-indicator-dimensions-width": `${a.width}px`,
57
+ "--origin-indicator-dimensions-height": `${a.height}px`
43
58
  };
44
- return /* @__PURE__ */ o(_, { children: /* @__PURE__ */ o(
45
- b,
59
+ return /* @__PURE__ */ p(S, { children: /* @__PURE__ */ P(
60
+ D,
46
61
  {
47
- ref: u,
48
- className: y(j.tethered, d),
49
- style: { position: "absolute", ...x, ...n },
50
- ...a,
51
- children: c
62
+ ref: k,
63
+ className: c(f.tethered, "tcn-tethered", y),
64
+ style: { ...C, ...$ },
65
+ "data-v-anchor": n,
66
+ "data-h-anchor": s,
67
+ "data-v-origin": r,
68
+ "data-h-origin": o,
69
+ "data-anchor-direction": e,
70
+ ...R,
71
+ children: [
72
+ l,
73
+ i === "high" && e !== "none" && /* @__PURE__ */ p(
74
+ N,
75
+ {
76
+ ref: b,
77
+ direction: e,
78
+ className: c(
79
+ f["origin-indicator"],
80
+ "tcn-tethered-origin-indicator"
81
+ )
82
+ }
83
+ )
84
+ ]
52
85
  }
53
86
  ) });
54
87
  }
55
88
  );
56
89
  export {
57
- I as Tethered
90
+ mt as Tethered
58
91
  };
59
92
  //# sourceMappingURL=tethered.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tethered.js","sources":["../../../src/overlay/tethered/tethered.tsx"],"sourcesContent":["import { forwardRef, type PropsWithChildren } from 'react';\nimport type { HorizontalTether, VerticalTether } from './types.js';\nimport { ZStack, type ZStackProps } from '../../stacks/index.js';\nimport { useForkRef, type Rectangle } from '../../utils/index.js';\nimport { useTether } from './hooks/useTether.js';\nimport { clsx } from 'clsx';\nimport { Portal } from '../portal/portal.js';\n\n// Styles\nimport styles from './tethered.module.css';\n\nexport interface BaseTetheredOwnProps {\n verticalAnchor?: VerticalTether;\n verticalOrigin?: VerticalTether;\n horizontalOrigin?: HorizontalTether;\n horizontalAnchor?: HorizontalTether;\n verticalOffset?: number;\n horizontalOffset?: number;\n}\n\nexport interface TetheredOwnProp extends BaseTetheredOwnProps {\n anchor: Rectangle | null;\n}\nexport interface TetheredProps extends TetheredOwnProp, ZStackProps {}\n\nexport const Tethered = forwardRef<HTMLElement, PropsWithChildren<TetheredProps>>(\n function Tethered(\n {\n anchor,\n verticalAnchor = 'bottom',\n verticalOrigin = 'top',\n horizontalAnchor = 'start',\n horizontalOrigin = 'start',\n verticalOffset = 0,\n horizontalOffset = 0,\n children,\n style,\n className,\n ...rest\n },\n ref\n ) {\n const { position, tetherRef } = useTether({\n anchor,\n verticalAnchor,\n verticalOrigin,\n horizontalAnchor,\n horizontalOrigin,\n verticalOffset,\n horizontalOffset,\n });\n const forkedRef = useForkRef(ref, tetherRef);\n\n const cssVariables = {\n '--tethered-top': `${position.top}px`,\n '--tethered-left': `${position.left}px`,\n };\n\n return (\n <Portal>\n <ZStack\n ref={forkedRef}\n className={clsx(styles.tethered, className)}\n style={{ position: 'absolute', ...cssVariables, ...style }}\n {...rest}\n >\n {children}\n </ZStack>\n </Portal>\n );\n }\n);\n"],"names":["Tethered","forwardRef","anchor","verticalAnchor","verticalOrigin","horizontalAnchor","horizontalOrigin","verticalOffset","horizontalOffset","children","style","className","rest","ref","position","tetherRef","useTether","forkedRef","useForkRef","cssVariables","Portal","jsx","ZStack","clsx","styles"],"mappings":";;;;;;;;;;;;;;;;;oDAyBaA,IAAWC;AAAA,EACtB,SACE;AAAA,IACE,QAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,gBAAAC,IAAiB;AAAA,IACjB,kBAAAC,IAAmB;AAAA,IACnB,kBAAAC,IAAmB;AAAA,IACnB,gBAAAC,IAAiB;AAAA,IACjB,kBAAAC,IAAmB;AAAA,IACnB,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,GACA;AACA,UAAM,EAAE,UAAAC,GAAU,WAAAC,EAAA,IAAcC,EAAU;AAAA,MACxC,QAAAd;AAAA,MACA,gBAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,IAAA,CACD,GACKS,IAAYC,EAAWL,GAAKE,CAAS,GAErCI,IAAe;AAAA,MACnB,kBAAkB,GAAGL,EAAS,GAAG;AAAA,MACjC,mBAAmB,GAAGA,EAAS,IAAI;AAAA,IAAA;AAGrC,6BACGM,GAAA,EACC,UAAA,gBAAAC;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,KAAKL;AAAA,QACL,WAAWM,EAAKC,EAAO,UAAUb,CAAS;AAAA,QAC1C,OAAO,EAAE,UAAU,YAAY,GAAGQ,GAAc,GAAGT,EAAA;AAAA,QAClD,GAAGE;AAAA,QAEH,UAAAH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;"}
1
+ {"version":3,"file":"tethered.js","sources":["../../../src/overlay/tethered/tethered.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef, type PropsWithChildren } from 'react';\nimport { ZStack, type ZStackProps } from '../../stacks/index.js';\nimport { useForkRef, type Rectangle } from '../../utils/index.js';\nimport { Caret } from '../caret/caret.js';\nimport { Portal } from '../portal/portal.js';\nimport { useCaretRefDimensions } from './hooks/useCaretRefDimensions.js';\nimport { useTether } from './hooks/useTether.js';\nimport { useTetherOrigin } from './hooks/useTetherOrigin.js';\nimport type { HorizontalTether, VerticalTether } from './types.js';\n\n// Styles\nimport styles from './tethered.module.css';\n\nexport interface BaseTetheredOwnProps {\n verticalAnchor?: VerticalTether;\n verticalOrigin?: VerticalTether;\n horizontalOrigin?: HorizontalTether;\n horizontalAnchor?: HorizontalTether;\n verticalOffset?: number;\n horizontalOffset?: number;\n}\n\nexport interface TetheredOwnProp extends BaseTetheredOwnProps {\n anchor: Rectangle | null;\n precision?: 'high' | 'low';\n}\nexport interface TetheredProps extends TetheredOwnProp, ZStackProps {}\n\nexport const Tethered = forwardRef<HTMLElement, PropsWithChildren<TetheredProps>>(\n function Tethered(\n {\n anchor,\n verticalAnchor = 'bottom',\n verticalOrigin = 'top',\n horizontalAnchor = 'start',\n horizontalOrigin = 'start',\n verticalOffset = 0,\n horizontalOffset = 0,\n precision = 'low',\n children,\n style,\n className,\n ...rest\n },\n ref\n ) {\n const { position, tetherRef } = useTether({\n anchor,\n verticalAnchor,\n verticalOrigin,\n horizontalAnchor,\n horizontalOrigin,\n verticalOffset,\n horizontalOffset,\n });\n\n // Convert position from { top, left } to Position type { x, y }\n const tetherPosition = { x: position.left, y: position.top };\n\n const { originPosition, originOffset, containerRef, originDirection } =\n useTetherOrigin(tetherPosition, horizontalOrigin, verticalOrigin, precision);\n\n const { caretElementRef: setCaretElement, caretSize } = useCaretRefDimensions(\n precision,\n originDirection\n );\n\n const forkedRef = useForkRef(ref, tetherRef, containerRef);\n\n const cssVariables = {\n '--tethered-top': `${position.top}px`,\n '--tethered-left': `${position.left}px`,\n '--tethered-origin-y': `${originPosition.y}px`,\n '--tethered-origin-x': `${originPosition.x}px`,\n '--tethered-origin-delta-y': `${originOffset.yOffset}px`,\n '--tethered-origin-delta-x': `${originOffset.xOffset}px`,\n '--origin-indicator-dimensions-width': `${caretSize.width}px`,\n '--origin-indicator-dimensions-height': `${caretSize.height}px`,\n };\n\n return (\n <Portal>\n <ZStack\n ref={forkedRef}\n className={clsx(styles.tethered, 'tcn-tethered', className)}\n style={{ ...cssVariables, ...style }}\n data-v-anchor={verticalAnchor}\n data-h-anchor={horizontalAnchor}\n data-v-origin={verticalOrigin}\n data-h-origin={horizontalOrigin}\n data-anchor-direction={originDirection}\n {...rest}\n >\n {children}\n {precision === 'high' && originDirection !== 'none' && (\n <Caret\n ref={setCaretElement}\n direction={originDirection}\n className={clsx(\n styles['origin-indicator'],\n 'tcn-tethered-origin-indicator'\n )}\n />\n )}\n </ZStack>\n </Portal>\n );\n }\n);\n"],"names":["Tethered","forwardRef","anchor","verticalAnchor","verticalOrigin","horizontalAnchor","horizontalOrigin","verticalOffset","horizontalOffset","precision","children","style","className","rest","ref","position","tetherRef","useTether","tetherPosition","originPosition","originOffset","containerRef","originDirection","useTetherOrigin","setCaretElement","caretSize","useCaretRefDimensions","forkedRef","useForkRef","cssVariables","Portal","jsxs","ZStack","clsx","styles","jsx","Caret"],"mappings":";;;;;;;;;;;;;;;;;;;;;;4GA6BaA,KAAWC;AAAA,EACtB,SACE;AAAA,IACE,QAAAC;AAAA,IACA,gBAAAC,IAAiB;AAAA,IACjB,gBAAAC,IAAiB;AAAA,IACjB,kBAAAC,IAAmB;AAAA,IACnB,kBAAAC,IAAmB;AAAA,IACnB,gBAAAC,IAAiB;AAAA,IACjB,kBAAAC,IAAmB;AAAA,IACnB,WAAAC,IAAY;AAAA,IACZ,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,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c,UAAUa,MAAoB,UAC3C,gBAAAa;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,KAAKZ;AAAA,cACL,WAAWF;AAAA,cACX,WAAWW;AAAA,gBACTC,EAAO,kBAAkB;AAAA,gBACzB;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAAA,GAGN;AAAA,EAEJ;AACF;"}
@@ -5,17 +5,19 @@ import "../../utils/scroll_away_listener.js";
5
5
  import O, { useRef as oo } from "react";
6
6
  import { useForkRef as ro } from "../../utils/hooks/use_fork_ref.js";
7
7
  import "../../utils/hooks/use_resize_observer.js";
8
- import { LeftResizeHandle as to } from "./left_resize_handle.js";
9
- import { RightResizeHandle as ao } from "./right_resize_handle.js";
10
- import { BottomResizeHandle as eo } from "./bottom_resize_handle.js";
11
- import { EndResizeHandle as fo } from "./end_resize_handle.js";
12
- import { StartResizeHandle as so } from "./start_resize_handle.js";
13
- import { TopResizeHandle as lo } from "./top_resize_handle.js";
14
- import { clsx as mo } from "clsx";
8
+ import "../../utils/dnd/context.js";
9
+ import { clsx as to } from "clsx";
10
+ import "../../draggable.module-BgelQsuJ.js";
11
+ import { LeftResizeHandle as ao } from "./left_resize_handle.js";
12
+ import { RightResizeHandle as eo } from "./right_resize_handle.js";
13
+ import { BottomResizeHandle as fo } from "./bottom_resize_handle.js";
14
+ import { EndResizeHandle as so } from "./end_resize_handle.js";
15
+ import { StartResizeHandle as lo } from "./start_resize_handle.js";
16
+ import { TopResizeHandle as mo } from "./top_resize_handle.js";
15
17
  import { isCustomSizeProp as y } from "../utils/isCustomSizeProp.js";
16
18
  import { removeUndefinedProperties as no } from "../utils/remove_undefined_properties.js";
17
19
  import { s as k } from "../../stack.module-CBV1f12Z.js";
18
- const Yo = O.forwardRef(function({
20
+ const Bo = O.forwardRef(function({
19
21
  style: v,
20
22
  className: P,
21
23
  as: _ = "div",
@@ -47,11 +49,11 @@ const Yo = O.forwardRef(function({
47
49
  enableResizeOnLeft: c = !1,
48
50
  enableResizeOnRight: p = !1,
49
51
  onWidthResize: e,
50
- onHeightResize: i,
52
+ onHeightResize: d,
51
53
  onWidthResizeEnd: f,
52
54
  onHeightResizeEnd: u,
53
- horizontalHandleProps: x,
54
- verticalHandleProps: d,
55
+ horizontalHandleProps: i,
56
+ verticalHandleProps: x,
55
57
  ...X
56
58
  }, Z) {
57
59
  const $ = _, o = oo(null), L = ro(Z, o), R = l || n || c || p, T = m || s, z = R, E = T, g = z && r === "flex", S = E && t === "flex", F = !g && !S && (r === "flex" || t === "flex");
@@ -94,7 +96,7 @@ const Yo = O.forwardRef(function({
94
96
  ...no(W),
95
97
  ...v
96
98
  },
97
- className: mo(
99
+ className: to(
98
100
  k.box,
99
101
  P,
100
102
  F && "stack-flex",
@@ -105,57 +107,57 @@ const Yo = O.forwardRef(function({
105
107
  children: [
106
108
  H,
107
109
  s && /* @__PURE__ */ a(
108
- lo,
110
+ mo,
109
111
  {
110
- onHeightResize: i,
112
+ onHeightResize: d,
111
113
  onHeightResizeEnd: u,
112
114
  targetRef: o,
113
- handleProps: x
115
+ handleProps: i
114
116
  }
115
117
  ),
116
118
  m && /* @__PURE__ */ a(
117
- eo,
119
+ fo,
118
120
  {
119
- onHeightResize: i,
121
+ onHeightResize: d,
120
122
  onHeightResizeEnd: u,
121
123
  targetRef: o,
122
- handleProps: d
124
+ handleProps: x
123
125
  }
124
126
  ),
125
127
  n && /* @__PURE__ */ a(
126
- so,
128
+ lo,
127
129
  {
128
130
  onWidthResize: e,
129
131
  onWidthResizeEnd: f,
130
132
  targetRef: o,
131
- handleProps: x
133
+ handleProps: i
132
134
  }
133
135
  ),
134
136
  l && /* @__PURE__ */ a(
135
- fo,
137
+ so,
136
138
  {
137
139
  onWidthResize: e,
138
140
  onWidthResizeEnd: f,
139
141
  targetRef: o,
140
- handleProps: x
142
+ handleProps: i
141
143
  }
142
144
  ),
143
145
  c && /* @__PURE__ */ a(
144
- to,
146
+ ao,
145
147
  {
146
148
  onWidthResize: e,
147
149
  onWidthResizeEnd: f,
148
150
  targetRef: o,
149
- handleProps: d
151
+ handleProps: x
150
152
  }
151
153
  ),
152
154
  p && /* @__PURE__ */ a(
153
- ao,
155
+ eo,
154
156
  {
155
157
  onWidthResize: e,
156
158
  onWidthResizeEnd: f,
157
159
  targetRef: o,
158
- handleProps: d
160
+ handleProps: x
159
161
  }
160
162
  )
161
163
  ]
@@ -163,6 +165,6 @@ const Yo = O.forwardRef(function({
163
165
  );
164
166
  });
165
167
  export {
166
- Yo as Box
168
+ Bo as Box
167
169
  };
168
170
  //# sourceMappingURL=box.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"box.js","sources":["../../../src/stacks/box/box.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport React, { CSSProperties, HTMLAttributes, useRef } from 'react';\nimport { LeftResizeHandle } from './left_resize_handle.js';\nimport { RightResizeHandle } from './right_resize_handle.js';\nimport { BottomResizeHandle } from './bottom_resize_handle.js';\nimport { EndResizeHandle } from './end_resize_handle.js';\nimport { StartResizeHandle } from './start_resize_handle.js';\nimport { TopResizeHandle } from './top_resize_handle.js';\nimport { clsx } from 'clsx';\nimport { isCustomSizeProp } from '../utils/isCustomSizeProp.js';\nimport { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';\nimport styles from '../stack.module.css';\nimport { HandleProps } from './handle_props.js';\n\nexport interface BoxProps extends HTMLAttributes<HTMLElement> {\n as?: string;\n style?: React.CSSProperties;\n className?: string;\n children?: React.ReactNode;\n width?: 'default' | 'flex' | 'auto' | string | number;\n minWidth?: CSSProperties['minWidth'];\n maxWidth?: CSSProperties['maxWidth'];\n height?: 'default' | 'flex' | 'auto' | string | number;\n minHeight?: CSSProperties['minHeight'];\n maxHeight?: CSSProperties['maxHeight'];\n zIndex?: number;\n padding?: CSSProperties['padding'];\n paddingInline?: CSSProperties['paddingInline'];\n paddingBlock?: CSSProperties['paddingBlock'];\n margin?: CSSProperties['margin'];\n marginBlock?: CSSProperties['marginBlock'];\n marginInline?: CSSProperties['marginInline'];\n marginInlineStart?: CSSProperties['marginInlineStart'];\n marginInlineEnd?: CSSProperties['marginInlineEnd'];\n marginTop?: CSSProperties['marginTop'];\n marginBottom?: CSSProperties['marginBottom'];\n overflow?: React.CSSProperties['overflow'];\n overflowX?: React.CSSProperties['overflowX'];\n overflowY?: React.CSSProperties['overflowY'];\n enableResizeOnTop?: boolean;\n enableResizeOnEnd?: boolean;\n enableResizeOnBottom?: boolean;\n enableResizeOnStart?: boolean;\n enableResizeOnLeft?: boolean;\n enableResizeOnRight?: boolean;\n horizontalHandleProps?: HandleProps;\n verticalHandleProps?: HandleProps;\n onWidthResize?: (\n width: number\n // origin: 'left' | 'right'\n ) => void;\n onHeightResize?: (\n height: number\n // origin: 'top' | 'bottom'\n ) => void;\n onWidthResizeEnd?: (width: number) => void;\n onHeightResizeEnd?: (width: number) => void;\n}\n\nexport const Box = React.forwardRef<HTMLElement, BoxProps>(function Box(\n {\n style,\n className,\n as = 'div',\n children,\n width = 'default',\n minWidth,\n maxWidth,\n height = 'default',\n minHeight,\n maxHeight,\n zIndex,\n padding,\n paddingInline,\n paddingBlock,\n margin,\n marginBlock,\n marginInline,\n marginInlineStart,\n marginInlineEnd,\n marginTop,\n marginBottom,\n overflow,\n overflowX,\n overflowY,\n enableResizeOnTop = false,\n enableResizeOnEnd = false,\n enableResizeOnBottom = false,\n enableResizeOnStart = false,\n enableResizeOnLeft = false,\n enableResizeOnRight = false,\n onWidthResize,\n onHeightResize,\n onWidthResizeEnd,\n onHeightResizeEnd,\n horizontalHandleProps,\n verticalHandleProps,\n ...otherProps\n }: BoxProps,\n ref\n) {\n const As = as as React.ElementType;\n const boxRef = useRef<HTMLElement | null>(null);\n const forkedRef = useForkRef(ref, boxRef);\n const hasHorizontalResize =\n enableResizeOnEnd || enableResizeOnStart || enableResizeOnLeft || enableResizeOnRight;\n const hasVerticalResize = enableResizeOnBottom || enableResizeOnTop;\n\n const cannotHorizontalFlex = hasHorizontalResize;\n const cannotVerticalFlex = hasVerticalResize;\n const warnHorizontalFlex = cannotHorizontalFlex && width === 'flex';\n const warnVerticalFlex = cannotVerticalFlex && height === 'flex';\n const isFlexing =\n !warnHorizontalFlex && !warnVerticalFlex && (width === 'flex' || height === 'flex');\n\n if (warnHorizontalFlex) {\n width = '100%';\n // biome-ignore lint/suspicious/noConsole: Need to warn the developer\n console.warn('You cannot have a resizable box and flex simultaneously');\n }\n\n if (warnVerticalFlex) {\n height = 'auto';\n // biome-ignore lint/suspicious/noConsole: Need to warn the developer\n console.warn('You cannot have a resizable box and flex simultaneously');\n }\n\n const propStyles = {\n width: !isCustomSizeProp(width) ? width : undefined,\n minWidth,\n maxWidth,\n height: !isCustomSizeProp(height) ? height : undefined,\n minHeight,\n maxHeight,\n padding,\n paddingInline,\n paddingBlock,\n margin,\n marginBlock,\n marginInline,\n marginInlineStart,\n marginInlineEnd,\n marginTop,\n marginBottom,\n overflow,\n overflowX,\n overflowY,\n zIndex,\n };\n\n return (\n <As\n data-enabled-resize-on-start={String(enableResizeOnStart)}\n data-enabled-resize-on-end={String(enableResizeOnEnd)}\n data-enabled-resize-on-top={String(enableResizeOnTop)}\n data-enabled-resize-on-bottom={String(enableResizeOnBottom)}\n data_enabled-resize-on-left={String(enableResizeOnLeft)}\n data_enabled-resize-on-right={String(enableResizeOnRight)}\n data-height={height}\n data-width={width}\n ref={forkedRef}\n style={{\n ...removeUndefinedProperties(propStyles),\n ...style,\n }}\n className={clsx(\n styles['box'],\n className,\n isFlexing && 'stack-flex',\n isFlexing && styles['stack-flex'],\n 'tcn-box'\n )}\n {...otherProps}\n >\n {children}\n {enableResizeOnTop && (\n <TopResizeHandle\n onHeightResize={onHeightResize}\n onHeightResizeEnd={onHeightResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnBottom && (\n <BottomResizeHandle\n onHeightResize={onHeightResize}\n onHeightResizeEnd={onHeightResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n {enableResizeOnStart && (\n <StartResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnEnd && (\n <EndResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnLeft && (\n <LeftResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n {enableResizeOnRight && (\n <RightResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n </As>\n );\n});\n"],"names":["Box","React","style","className","as","children","width","minWidth","maxWidth","height","minHeight","maxHeight","zIndex","padding","paddingInline","paddingBlock","margin","marginBlock","marginInline","marginInlineStart","marginInlineEnd","marginTop","marginBottom","overflow","overflowX","overflowY","enableResizeOnTop","enableResizeOnEnd","enableResizeOnBottom","enableResizeOnStart","enableResizeOnLeft","enableResizeOnRight","onWidthResize","onHeightResize","onWidthResizeEnd","onHeightResizeEnd","horizontalHandleProps","verticalHandleProps","otherProps","ref","As","boxRef","useRef","forkedRef","useForkRef","hasHorizontalResize","hasVerticalResize","cannotHorizontalFlex","cannotVerticalFlex","warnHorizontalFlex","warnVerticalFlex","isFlexing","propStyles","isCustomSizeProp","jsxs","removeUndefinedProperties","clsx","styles","jsx","TopResizeHandle","BottomResizeHandle","StartResizeHandle","EndResizeHandle","LeftResizeHandle","RightResizeHandle"],"mappings":";;;;;;;;;;;;;;;;;AA2DO,MAAMA,KAAMC,EAAM,WAAkC,SACzD;AAAA,EACE,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,IAAAC,IAAK;AAAA,EACL,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA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A,YACC,eAAA7B;AAAA,YACA,kBAAAE;AAAA,YACA,WAAWO;AAAA,YACX,aAAaL;AAAA,UAAA;AAAA,QAAA;AAAA,QAGhBT,KACC,gBAAA+B;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,eAAA9B;AAAA,YACA,kBAAAE;AAAA,YACA,WAAWO;AAAA,YACX,aAAaL;AAAA,UAAA;AAAA,QAAA;AAAA,QAGhBN,KACC,gBAAA4B;AAAA,UAACK;AAAA,UAAA;AAAA,YACC,eAAA/B;AAAA,YACA,kBAAAE;AAAA,YACA,WAAWO;AAAA,YACX,aAAaJ;AAAA,UAAA;AAAA,QAAA;AAAA,QAGhBN,KACC,gBAAA2B;AAAA,UAACM;AAAA,UAAA;AAAA,YACC,eAAAhC;AAAA,YACA,kBAAAE;AAAA,YACA,WAAWO;AAAA,YACX,aAAaJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
1
+ {"version":3,"file":"box.js","sources":["../../../src/stacks/box/box.tsx"],"sourcesContent":["import { useForkRef } from '../../utils/index.js';\nimport React, { CSSProperties, HTMLAttributes, useRef } from 'react';\nimport { LeftResizeHandle } from './left_resize_handle.js';\nimport { RightResizeHandle } from './right_resize_handle.js';\nimport { BottomResizeHandle } from './bottom_resize_handle.js';\nimport { EndResizeHandle } from './end_resize_handle.js';\nimport { StartResizeHandle } from './start_resize_handle.js';\nimport { TopResizeHandle } from './top_resize_handle.js';\nimport { clsx } from 'clsx';\nimport { isCustomSizeProp } from '../utils/isCustomSizeProp.js';\nimport { removeUndefinedProperties } from '../utils/remove_undefined_properties.js';\nimport styles from '../stack.module.css';\nimport { HandleProps } from './handle_props.js';\n\nexport interface BoxProps extends HTMLAttributes<HTMLElement> {\n as?: string;\n style?: React.CSSProperties;\n className?: string;\n children?: React.ReactNode;\n width?: 'default' | 'flex' | 'auto' | string | number;\n minWidth?: CSSProperties['minWidth'];\n maxWidth?: CSSProperties['maxWidth'];\n height?: 'default' | 'flex' | 'auto' | string | number;\n minHeight?: CSSProperties['minHeight'];\n maxHeight?: CSSProperties['maxHeight'];\n zIndex?: number;\n padding?: CSSProperties['padding'];\n paddingInline?: CSSProperties['paddingInline'];\n paddingBlock?: CSSProperties['paddingBlock'];\n margin?: CSSProperties['margin'];\n marginBlock?: CSSProperties['marginBlock'];\n marginInline?: CSSProperties['marginInline'];\n marginInlineStart?: CSSProperties['marginInlineStart'];\n marginInlineEnd?: CSSProperties['marginInlineEnd'];\n marginTop?: CSSProperties['marginTop'];\n marginBottom?: CSSProperties['marginBottom'];\n overflow?: React.CSSProperties['overflow'];\n overflowX?: React.CSSProperties['overflowX'];\n overflowY?: React.CSSProperties['overflowY'];\n enableResizeOnTop?: boolean;\n enableResizeOnEnd?: boolean;\n enableResizeOnBottom?: boolean;\n enableResizeOnStart?: boolean;\n enableResizeOnLeft?: boolean;\n enableResizeOnRight?: boolean;\n horizontalHandleProps?: HandleProps;\n verticalHandleProps?: HandleProps;\n onWidthResize?: (\n width: number\n // origin: 'left' | 'right'\n ) => void;\n onHeightResize?: (\n height: number\n // origin: 'top' | 'bottom'\n ) => void;\n onWidthResizeEnd?: (width: number) => void;\n onHeightResizeEnd?: (width: number) => void;\n}\n\nexport const Box = React.forwardRef<HTMLElement, BoxProps>(function Box(\n {\n style,\n className,\n as = 'div',\n children,\n width = 'default',\n minWidth,\n maxWidth,\n height = 'default',\n minHeight,\n maxHeight,\n zIndex,\n padding,\n paddingInline,\n paddingBlock,\n margin,\n marginBlock,\n marginInline,\n marginInlineStart,\n marginInlineEnd,\n marginTop,\n marginBottom,\n overflow,\n overflowX,\n overflowY,\n enableResizeOnTop = false,\n enableResizeOnEnd = false,\n enableResizeOnBottom = false,\n enableResizeOnStart = false,\n enableResizeOnLeft = false,\n enableResizeOnRight = false,\n onWidthResize,\n onHeightResize,\n onWidthResizeEnd,\n onHeightResizeEnd,\n horizontalHandleProps,\n verticalHandleProps,\n ...otherProps\n }: BoxProps,\n ref\n) {\n const As = as as React.ElementType;\n const boxRef = useRef<HTMLElement | null>(null);\n const forkedRef = useForkRef(ref, boxRef);\n const hasHorizontalResize =\n enableResizeOnEnd || enableResizeOnStart || enableResizeOnLeft || enableResizeOnRight;\n const hasVerticalResize = enableResizeOnBottom || enableResizeOnTop;\n\n const cannotHorizontalFlex = hasHorizontalResize;\n const cannotVerticalFlex = hasVerticalResize;\n const warnHorizontalFlex = cannotHorizontalFlex && width === 'flex';\n const warnVerticalFlex = cannotVerticalFlex && height === 'flex';\n const isFlexing =\n !warnHorizontalFlex && !warnVerticalFlex && (width === 'flex' || height === 'flex');\n\n if (warnHorizontalFlex) {\n width = '100%';\n // biome-ignore lint/suspicious/noConsole: Need to warn the developer\n console.warn('You cannot have a resizable box and flex simultaneously');\n }\n\n if (warnVerticalFlex) {\n height = 'auto';\n // biome-ignore lint/suspicious/noConsole: Need to warn the developer\n console.warn('You cannot have a resizable box and flex simultaneously');\n }\n\n const propStyles = {\n width: !isCustomSizeProp(width) ? width : undefined,\n minWidth,\n maxWidth,\n height: !isCustomSizeProp(height) ? height : undefined,\n minHeight,\n maxHeight,\n padding,\n paddingInline,\n paddingBlock,\n margin,\n marginBlock,\n marginInline,\n marginInlineStart,\n marginInlineEnd,\n marginTop,\n marginBottom,\n overflow,\n overflowX,\n overflowY,\n zIndex,\n };\n\n return (\n <As\n data-enabled-resize-on-start={String(enableResizeOnStart)}\n data-enabled-resize-on-end={String(enableResizeOnEnd)}\n data-enabled-resize-on-top={String(enableResizeOnTop)}\n data-enabled-resize-on-bottom={String(enableResizeOnBottom)}\n data_enabled-resize-on-left={String(enableResizeOnLeft)}\n data_enabled-resize-on-right={String(enableResizeOnRight)}\n data-height={height}\n data-width={width}\n ref={forkedRef}\n style={{\n ...removeUndefinedProperties(propStyles),\n ...style,\n }}\n className={clsx(\n styles['box'],\n className,\n isFlexing && 'stack-flex',\n isFlexing && styles['stack-flex'],\n 'tcn-box'\n )}\n {...otherProps}\n >\n {children}\n {enableResizeOnTop && (\n <TopResizeHandle\n onHeightResize={onHeightResize}\n onHeightResizeEnd={onHeightResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnBottom && (\n <BottomResizeHandle\n onHeightResize={onHeightResize}\n onHeightResizeEnd={onHeightResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n {enableResizeOnStart && (\n <StartResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnEnd && (\n <EndResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={horizontalHandleProps}\n />\n )}\n {enableResizeOnLeft && (\n <LeftResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n {enableResizeOnRight && (\n <RightResizeHandle\n onWidthResize={onWidthResize}\n onWidthResizeEnd={onWidthResizeEnd}\n targetRef={boxRef}\n handleProps={verticalHandleProps}\n />\n )}\n </As>\n );\n});\n"],"names":["Box","React","style","className","as","children","width","minWidth","maxWidth","height","minHeight","maxHeight","zIndex","padding","paddingInline","paddingBlock","margin","marginBlock","marginInline","marginInlineStart","marginInlineEnd","marginTop","marginBottom","overflow","overflowX","overflowY","enableResizeOnTop","enableResizeOnEnd","enableResizeOnBottom","enableResizeOnStart","enableResizeOnLeft","enableResizeOnRight","onWidthResize","onHeightResize","onWidthResizeEnd","onHeightResizeEnd","horizontalHandleProps","verticalHandleProps","otherProps","ref","As","boxRef","useRef","forkedRef","useForkRef","hasHorizontalResize","hasVerticalResize","cannotHorizontalFlex","cannotVerticalFlex","warnHorizontalFlex","warnVerticalFlex","isFlexing","propStyles","isCustomSizeProp","jsxs","removeUndefinedProperties","clsx","styles","jsx","TopResizeHandle","BottomResizeHandle","StartResizeHand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