@forgedevstack/bear 1.0.6 → 1.0.8

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 (230) hide show
  1. package/dist/components/Alert/Alert.cjs +1 -1
  2. package/dist/components/Alert/Alert.const.cjs +1 -1
  3. package/dist/components/Alert/Alert.const.d.ts +4 -0
  4. package/dist/components/Alert/Alert.const.js +9 -15
  5. package/dist/components/Alert/Alert.js +43 -38
  6. package/dist/components/AppBar/AppBar.cjs +1 -1
  7. package/dist/components/AppBar/AppBar.js +20 -16
  8. package/dist/components/BackTop/BackTop.cjs +1 -0
  9. package/dist/components/BackTop/BackTop.const.cjs +1 -0
  10. package/dist/components/BackTop/BackTop.const.d.ts +34 -0
  11. package/dist/components/BackTop/BackTop.const.js +29 -0
  12. package/dist/components/BackTop/BackTop.d.ts +21 -0
  13. package/dist/components/BackTop/BackTop.js +87 -0
  14. package/dist/components/BackTop/BackTop.types.d.ts +28 -0
  15. package/dist/components/BackTop/index.d.ts +3 -0
  16. package/dist/components/Badge/Badge.constants.d.ts +4 -4
  17. package/dist/components/Badge/Badge.types.d.ts +3 -3
  18. package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
  19. package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
  20. package/dist/components/BottomSheet/BottomSheet.js +103 -0
  21. package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
  22. package/dist/components/BottomSheet/index.d.ts +2 -0
  23. package/dist/components/Button/Button.cjs +1 -1
  24. package/dist/components/Button/Button.constants.cjs +38 -48
  25. package/dist/components/Button/Button.constants.d.ts +22 -3
  26. package/dist/components/Button/Button.constants.js +51 -50
  27. package/dist/components/Button/Button.d.ts +14 -7
  28. package/dist/components/Button/Button.js +123 -43
  29. package/dist/components/Button/Button.types.d.ts +26 -4
  30. package/dist/components/Calendar/Calendar.cjs +1 -1
  31. package/dist/components/Calendar/Calendar.js +3 -2
  32. package/dist/components/Card/Card.const.d.ts +2 -2
  33. package/dist/components/Card/Card.types.d.ts +2 -2
  34. package/dist/components/Chat/Chat.cjs +1 -0
  35. package/dist/components/Chat/Chat.const.cjs +1 -0
  36. package/dist/components/Chat/Chat.const.d.ts +26 -0
  37. package/dist/components/Chat/Chat.const.js +29 -0
  38. package/dist/components/Chat/Chat.d.ts +21 -0
  39. package/dist/components/Chat/Chat.js +179 -0
  40. package/dist/components/Chat/Chat.types.d.ts +55 -0
  41. package/dist/components/Chat/index.d.ts +2 -0
  42. package/dist/components/Confetti/Confetti.cjs +1 -0
  43. package/dist/components/Confetti/Confetti.const.cjs +1 -0
  44. package/dist/components/Confetti/Confetti.const.d.ts +16 -0
  45. package/dist/components/Confetti/Confetti.const.js +36 -0
  46. package/dist/components/Confetti/Confetti.d.ts +23 -0
  47. package/dist/components/Confetti/Confetti.js +94 -0
  48. package/dist/components/Confetti/Confetti.types.d.ts +50 -0
  49. package/dist/components/Confetti/index.d.ts +4 -0
  50. package/dist/components/Confetti/useConfetti.cjs +1 -0
  51. package/dist/components/Confetti/useConfetti.d.ts +13 -0
  52. package/dist/components/Confetti/useConfetti.js +12 -0
  53. package/dist/components/DatePicker/DatePicker.cjs +1 -1
  54. package/dist/components/DatePicker/DatePicker.js +3 -2
  55. package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
  56. package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
  57. package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
  58. package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
  59. package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
  60. package/dist/components/DiffViewer/DiffViewer.js +127 -0
  61. package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
  62. package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
  63. package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
  64. package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
  65. package/dist/components/DiffViewer/index.d.ts +2 -0
  66. package/dist/components/Drawer/Drawer.cjs +1 -1
  67. package/dist/components/Drawer/Drawer.js +35 -35
  68. package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
  69. package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
  70. package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
  71. package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
  72. package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
  73. package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
  74. package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
  75. package/dist/components/EmojiPicker/index.d.ts +3 -0
  76. package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
  77. package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
  78. package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
  79. package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
  80. package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
  81. package/dist/components/FloatingChat/FloatingChat.js +144 -0
  82. package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
  83. package/dist/components/FloatingChat/index.d.ts +2 -0
  84. package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
  85. package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
  86. package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
  87. package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
  88. package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
  89. package/dist/components/JsonViewer/JsonViewer.js +195 -0
  90. package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
  91. package/dist/components/JsonViewer/index.d.ts +2 -0
  92. package/dist/components/Kanban/Kanban.cjs +1 -0
  93. package/dist/components/Kanban/Kanban.d.ts +3 -0
  94. package/dist/components/Kanban/Kanban.js +91 -0
  95. package/dist/components/Kanban/Kanban.types.d.ts +21 -0
  96. package/dist/components/Kanban/index.d.ts +2 -0
  97. package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
  98. package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
  99. package/dist/components/MentionsInput/MentionsInput.js +140 -0
  100. package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
  101. package/dist/components/MentionsInput/index.d.ts +2 -0
  102. package/dist/components/QRCode/QRCode.cjs +1 -0
  103. package/dist/components/QRCode/QRCode.const.cjs +1 -0
  104. package/dist/components/QRCode/QRCode.const.d.ts +21 -0
  105. package/dist/components/QRCode/QRCode.const.js +11 -0
  106. package/dist/components/QRCode/QRCode.d.ts +29 -0
  107. package/dist/components/QRCode/QRCode.js +68 -0
  108. package/dist/components/QRCode/QRCode.types.d.ts +32 -0
  109. package/dist/components/QRCode/QRCode.utils.cjs +1 -0
  110. package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
  111. package/dist/components/QRCode/QRCode.utils.js +74 -0
  112. package/dist/components/QRCode/index.d.ts +3 -0
  113. package/dist/components/RichEditor/RichEditor.cjs +1 -1
  114. package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
  115. package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
  116. package/dist/components/RichEditor/RichEditor.const.js +51 -18
  117. package/dist/components/RichEditor/RichEditor.js +106 -105
  118. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
  119. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
  120. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
  121. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
  122. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
  123. package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
  124. package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  125. package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
  126. package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
  127. package/dist/components/SegmentedControl/index.d.ts +2 -0
  128. package/dist/components/SignPad/SignPad.cjs +1 -1
  129. package/dist/components/SignPad/SignPad.js +98 -90
  130. package/dist/components/SliderRange/SliderRange.cjs +1 -0
  131. package/dist/components/SliderRange/SliderRange.d.ts +3 -0
  132. package/dist/components/SliderRange/SliderRange.js +142 -0
  133. package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
  134. package/dist/components/SliderRange/index.d.ts +2 -0
  135. package/dist/components/Spinner/Spinner.types.d.ts +2 -2
  136. package/dist/components/TagsInput/TagsInput.cjs +1 -0
  137. package/dist/components/TagsInput/TagsInput.d.ts +3 -0
  138. package/dist/components/TagsInput/TagsInput.js +100 -0
  139. package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
  140. package/dist/components/TagsInput/index.d.ts +2 -0
  141. package/dist/components/Terminal/Terminal.cjs +1 -0
  142. package/dist/components/Terminal/Terminal.const.cjs +1 -0
  143. package/dist/components/Terminal/Terminal.const.d.ts +32 -0
  144. package/dist/components/Terminal/Terminal.const.js +42 -0
  145. package/dist/components/Terminal/Terminal.d.ts +27 -0
  146. package/dist/components/Terminal/Terminal.js +155 -0
  147. package/dist/components/Terminal/Terminal.types.d.ts +49 -0
  148. package/dist/components/Terminal/index.d.ts +2 -0
  149. package/dist/components/Tour/Tour.cjs +1 -0
  150. package/dist/components/Tour/Tour.const.cjs +1 -0
  151. package/dist/components/Tour/Tour.const.d.ts +25 -0
  152. package/dist/components/Tour/Tour.const.js +38 -0
  153. package/dist/components/Tour/Tour.d.ts +17 -0
  154. package/dist/components/Tour/Tour.js +179 -0
  155. package/dist/components/Tour/Tour.types.d.ts +80 -0
  156. package/dist/components/Tour/index.d.ts +4 -0
  157. package/dist/components/Tour/useTour.cjs +1 -0
  158. package/dist/components/Tour/useTour.d.ts +14 -0
  159. package/dist/components/Tour/useTour.js +27 -0
  160. package/dist/components/Typography/Typography.cjs +1 -1
  161. package/dist/components/Typography/Typography.d.ts +5 -1
  162. package/dist/components/Typography/Typography.js +93 -57
  163. package/dist/components/Typography/Typography.types.d.ts +29 -2
  164. package/dist/components/VirtualList/VirtualList.cjs +1 -0
  165. package/dist/components/VirtualList/VirtualList.d.ts +3 -0
  166. package/dist/components/VirtualList/VirtualList.js +68 -0
  167. package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
  168. package/dist/components/VirtualList/index.d.ts +2 -0
  169. package/dist/components/index.cjs +1 -1
  170. package/dist/components/index.d.ts +35 -1
  171. package/dist/components/index.js +240 -198
  172. package/dist/context/BearProvider.cjs +1 -1
  173. package/dist/context/BearProvider.d.ts +110 -5
  174. package/dist/context/BearProvider.js +198 -53
  175. package/dist/context/defaultTheme.cjs +1 -1
  176. package/dist/context/defaultTheme.js +11 -11
  177. package/dist/hooks/index.cjs +1 -1
  178. package/dist/hooks/index.d.ts +18 -0
  179. package/dist/hooks/index.js +56 -35
  180. package/dist/hooks/useBearComponent/index.d.ts +2 -0
  181. package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
  182. package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
  183. package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
  184. package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
  185. package/dist/hooks/useDragDrop/index.d.ts +2 -0
  186. package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
  187. package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
  188. package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
  189. package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
  190. package/dist/hooks/useIdle/index.d.ts +2 -0
  191. package/dist/hooks/useIdle/useIdle.cjs +1 -0
  192. package/dist/hooks/useIdle/useIdle.d.ts +22 -0
  193. package/dist/hooks/useIdle/useIdle.js +66 -0
  194. package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
  195. package/dist/hooks/useLazyLoad/index.d.ts +2 -0
  196. package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
  197. package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
  198. package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
  199. package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
  200. package/dist/hooks/useLongPress/index.d.ts +2 -0
  201. package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
  202. package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
  203. package/dist/hooks/useLongPress/useLongPress.js +44 -0
  204. package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
  205. package/dist/hooks/useOnline/index.d.ts +2 -0
  206. package/dist/hooks/useOnline/useOnline.cjs +1 -0
  207. package/dist/hooks/useOnline/useOnline.d.ts +16 -0
  208. package/dist/hooks/useOnline/useOnline.js +25 -0
  209. package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
  210. package/dist/hooks/usePageVisibility/index.d.ts +2 -0
  211. package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
  212. package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
  213. package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
  214. package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
  215. package/dist/hooks/useSpotlight/index.d.ts +2 -0
  216. package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
  217. package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
  218. package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
  219. package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
  220. package/dist/hooks/useWebSocket/index.d.ts +2 -0
  221. package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
  222. package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
  223. package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
  224. package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
  225. package/dist/index.cjs +1 -1
  226. package/dist/index.js +327 -264
  227. package/dist/styles.css +1 -1
  228. package/dist/types/component.types.d.ts +125 -42
  229. package/dist/types/theme.types.d.ts +82 -0
  230. package/package.json +1 -1
@@ -1,126 +1,136 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { useState as k, useRef as y, useEffect as _ } from "react";
3
- import { cn as a } from "../../../../utils/cn.js";
4
- import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as C, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as E, RICH_EDITOR_BUTTON_BASE_CLASSES as R, RICH_EDITOR_COLORS as v } from "../../RichEditor.const.js";
5
- import { FormatColorTextIcon as I, HighlightIcon as N } from "../../../Icon/icons/editor.js";
6
- import { CheckIcon as S } from "../../../Icon/icons/status.js";
7
- const L = (p) => {
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import { useState as C, useRef as _, useEffect as w } from "react";
3
+ import { createPortal as N } from "react-dom";
4
+ import { cn as i } from "../../../../utils/cn.js";
5
+ import { RICH_EDITOR_COLORS as S, RICH_EDITOR_BUTTON_DISABLED_CLASSES as B, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as T, RICH_EDITOR_BUTTON_BASE_CLASSES as O } from "../../RichEditor.const.js";
6
+ import { useMediaQuery as z } from "../../../../hooks/useMediaQuery.js";
7
+ import { FormatColorTextIcon as A, HighlightIcon as L } from "../../../Icon/icons/editor.js";
8
+ import { CheckIcon as M } from "../../../Icon/icons/status.js";
9
+ const Q = (R) => {
8
10
  const {
9
- value: o,
10
- onChange: b,
11
- title: f,
12
- disabled: n,
13
- type: i = "text",
14
- recentColors: l = [],
15
- onApplyLast: m
16
- } = p, [h, s] = k(!1), c = y(null);
17
- _(() => {
18
- const e = (g) => {
19
- c.current && !c.current.contains(g.target) && s(!1);
11
+ value: a,
12
+ onChange: v,
13
+ title: E,
14
+ disabled: l,
15
+ type: c = "text",
16
+ recentColors: d = [],
17
+ onApplyLast: g
18
+ } = R, [s, m] = C(!1), [h, b] = C({ top: 0, left: 0 }), u = _(null), p = _(null), o = z("(max-width: 640px)");
19
+ w(() => {
20
+ if (s && o && p.current && typeof document < "u") {
21
+ const t = p.current.getBoundingClientRect(), r = t.top, k = window.innerHeight - t.bottom;
22
+ k >= 240 || k >= r ? b({ top: t.bottom + 4, left: Math.max(8, Math.min(t.left, window.innerWidth - 220)) }) : b({ top: t.top - 244, left: Math.max(8, Math.min(t.left, window.innerWidth - 220)) });
23
+ }
24
+ }, [s, o]), w(() => {
25
+ const t = (r) => {
26
+ u.current && !u.current.contains(r.target) && m(!1);
20
27
  };
21
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
28
+ return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
22
29
  }, []);
23
- const d = (e) => {
24
- b(e), s(!1);
25
- }, x = i === "text" ? I : N, u = l[0] || o;
26
- return /* @__PURE__ */ r("div", { ref: c, className: "Bear-RichEditor__color-picker relative flex items-center", children: [
27
- /* @__PURE__ */ r(
30
+ const f = (t) => {
31
+ v(t), m(!1);
32
+ }, I = c === "text" ? A : L, x = d[0] || a, y = /* @__PURE__ */ n(
33
+ "div",
34
+ {
35
+ className: i(
36
+ "Bear-RichEditor__color-menu p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,240px)]",
37
+ o ? "fixed z-[9999]" : "absolute bottom-full left-0 mb-1"
38
+ ),
39
+ style: o ? { top: h.top, left: h.left } : void 0,
40
+ children: [
41
+ d.length > 0 && /* @__PURE__ */ n("div", { className: "mb-3", children: [
42
+ /* @__PURE__ */ e("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1.5", children: "Recent" }),
43
+ /* @__PURE__ */ e("div", { className: "flex gap-1 flex-wrap", children: d.slice(0, 6).map((t, r) => /* @__PURE__ */ e(
44
+ "button",
45
+ {
46
+ type: "button",
47
+ onClick: () => f(t),
48
+ className: i(
49
+ "w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",
50
+ a === t && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
51
+ ),
52
+ style: { backgroundColor: t },
53
+ title: t
54
+ },
55
+ `recent-${r}`
56
+ )) })
57
+ ] }),
58
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-8 gap-1", children: S.map((t) => /* @__PURE__ */ e(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ onClick: () => f(t),
63
+ className: i(
64
+ "Bear-RichEditor__color-swatch w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110 touch-manipulation",
65
+ a === t && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
66
+ ),
67
+ style: { backgroundColor: t },
68
+ title: t
69
+ },
70
+ t
71
+ )) }),
72
+ /* @__PURE__ */ n(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ onClick: () => f(""),
77
+ className: "w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors touch-manipulation",
78
+ children: [
79
+ "Remove ",
80
+ c === "text" ? "color" : "highlight"
81
+ ]
82
+ }
83
+ )
84
+ ]
85
+ }
86
+ );
87
+ return /* @__PURE__ */ n("div", { ref: u, className: "Bear-RichEditor__color-picker relative flex items-center", children: [
88
+ /* @__PURE__ */ n(
28
89
  "button",
29
90
  {
91
+ ref: p,
30
92
  type: "button",
31
- title: f,
32
- disabled: n,
33
- onClick: () => s(!h),
34
- className: a(
93
+ title: E,
94
+ disabled: l,
95
+ onClick: () => m(!s),
96
+ className: i(
35
97
  "Bear-RichEditor__color-trigger",
36
- R,
37
- E,
98
+ O,
99
+ T,
38
100
  "flex items-center gap-0.5",
39
- n && `Bear-RichEditor__color-trigger--disabled ${C}`
101
+ l && `Bear-RichEditor__color-trigger--disabled ${B}`
40
102
  ),
41
103
  children: [
42
- /* @__PURE__ */ t(x, { size: 16 }),
43
- /* @__PURE__ */ t(
104
+ /* @__PURE__ */ e(I, { size: 16 }),
105
+ /* @__PURE__ */ e(
44
106
  "span",
45
107
  {
46
108
  className: "w-3 h-1 rounded-sm mt-0.5",
47
- style: { backgroundColor: o || (i === "text" ? "#000000" : "#fef08a") }
109
+ style: { backgroundColor: a || (c === "text" ? "#000000" : "#fef08a") }
48
110
  }
49
111
  )
50
112
  ]
51
113
  }
52
114
  ),
53
- u && m && /* @__PURE__ */ t(
115
+ x && g && /* @__PURE__ */ e(
54
116
  "button",
55
117
  {
56
118
  type: "button",
57
- title: `Apply ${i === "text" ? "text" : "highlight"} color`,
58
- disabled: n,
59
- onClick: () => m(u),
60
- className: a(
119
+ title: `Apply ${c === "text" ? "text" : "highlight"} color`,
120
+ disabled: l,
121
+ onClick: () => g(x),
122
+ className: i(
61
123
  "Bear-RichEditor__color-apply",
62
124
  "p-0.5 rounded transition-colors",
63
125
  "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700",
64
- n && "opacity-50 cursor-not-allowed"
126
+ l && "opacity-50 cursor-not-allowed"
65
127
  ),
66
- children: /* @__PURE__ */ t(S, { size: 12 })
128
+ children: /* @__PURE__ */ e(M, { size: 12 })
67
129
  }
68
130
  ),
69
- h && /* @__PURE__ */ r(
70
- "div",
71
- {
72
- className: "Bear-RichEditor__color-menu absolute bottom-full left-0 mb-1 p-3 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px]",
73
- style: { zIndex: 9999 },
74
- children: [
75
- l.length > 0 && /* @__PURE__ */ r("div", { className: "mb-3", children: [
76
- /* @__PURE__ */ t("p", { className: "text-xs text-gray-500 dark:text-gray-400 mb-1.5", children: "Recent" }),
77
- /* @__PURE__ */ t("div", { className: "flex gap-1", children: l.slice(0, 6).map((e, g) => /* @__PURE__ */ t(
78
- "button",
79
- {
80
- type: "button",
81
- onClick: () => d(e),
82
- className: a(
83
- "w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",
84
- o === e && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
85
- ),
86
- style: { backgroundColor: e },
87
- title: e
88
- },
89
- `recent-${g}`
90
- )) })
91
- ] }),
92
- /* @__PURE__ */ t("div", { className: "grid grid-cols-8 gap-1", children: v.map((e) => /* @__PURE__ */ t(
93
- "button",
94
- {
95
- type: "button",
96
- onClick: () => d(e),
97
- className: a(
98
- "Bear-RichEditor__color-swatch",
99
- "w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",
100
- o === e && "ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"
101
- ),
102
- style: { backgroundColor: e },
103
- title: e
104
- },
105
- e
106
- )) }),
107
- /* @__PURE__ */ r(
108
- "button",
109
- {
110
- type: "button",
111
- onClick: () => d(""),
112
- className: "w-full mt-2 px-2 py-1.5 text-xs text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors",
113
- children: [
114
- "Remove ",
115
- i === "text" ? "color" : "highlight"
116
- ]
117
- }
118
- )
119
- ]
120
- }
121
- )
131
+ s && (o && typeof document < "u" ? N(y, document.body) : y)
122
132
  ] });
123
133
  };
124
134
  export {
125
- L as ToolbarColorPicker
135
+ Q as ToolbarColorPicker
126
136
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),d=require("../../../../utils/cn.cjs"),o=require("../../RichEditor.const.cjs"),u=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),_=({children:l,disabled:i})=>{const[r,s]=n.useState(!1),t=n.useRef(null);return n.useEffect(()=>{const c=a=>{t.current&&!t.current.contains(a.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),e.jsxs("div",{ref:t,className:"Bear-RichEditor__more relative",children:[e.jsx("button",{type:"button",title:"More options",disabled:i,onClick:()=>s(!r),className:d.cn("Bear-RichEditor__more-trigger",o.RICH_EDITOR_BUTTON_BASE_CLASSES,o.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center justify-center",r&&"bg-pink-500 text-white",i&&`Bear-RichEditor__more-trigger--disabled ${o.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:e.jsx(u,{})}),r&&e.jsx("div",{className:"Bear-RichEditor__more-menu absolute top-full right-0 mt-1 p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl z-50 min-w-[200px]",children:e.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:l})})]})};exports.ToolbarMore=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),E=require("react-dom"),h=require("../../../../utils/cn.cjs"),l=require("../../RichEditor.const.cjs"),p=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"}),e.jsx("circle",{cx:"6",cy:"12",r:"1.5",fill:"currentColor"}),e.jsx("circle",{cx:"18",cy:"12",r:"1.5",fill:"currentColor"})]}),R=({children:_,disabled:u,isMobile:r})=>{const[o,d]=t.useState(!1),c=t.useRef(null),i=t.useRef(null),[a,g]=t.useState({top:0,left:0});t.useEffect(()=>{const n=m=>{var x;if(c.current&&!c.current.contains(m.target)){const s=m.target;(x=s.closest)!=null&&x.call(s,".Bear-RichEditor__more-menu")||d(!1)}};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.useEffect(()=>{if(o&&r&&i.current&&typeof document<"u"){const n=i.current.getBoundingClientRect();g({top:n.bottom+4,left:Math.max(8,n.right-220)})}},[o,r]);const f=e.jsx("div",{className:h.cn("Bear-RichEditor__more-menu p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,280px)] max-h-[70vh] overflow-y-auto",r?"fixed z-[9999]":"absolute top-full right-0 mt-1 z-50"),style:r?{top:a.top,left:a.left}:void 0,children:e.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:_})});return e.jsxs("div",{ref:c,className:"Bear-RichEditor__more relative",children:[e.jsx("button",{ref:i,type:"button",title:"More options",disabled:u,onClick:()=>d(!o),className:h.cn("Bear-RichEditor__more-trigger",l.RICH_EDITOR_BUTTON_BASE_CLASSES,l.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center justify-center",o&&"bg-pink-500 text-white",u&&`Bear-RichEditor__more-trigger--disabled ${l.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:e.jsx(p,{})}),o&&(r&&typeof document<"u"?E.createPortal(f,document.body):f)]})};exports.ToolbarMore=R;
@@ -2,6 +2,8 @@ import { FC, ReactNode } from 'react';
2
2
  export interface ToolbarMoreProps {
3
3
  children: ReactNode;
4
4
  disabled?: boolean;
5
+ /** When true, render menu via portal for mobile (avoids clipping) */
6
+ isMobile?: boolean;
5
7
  }
6
8
  export declare const ToolbarMore: FC<ToolbarMoreProps>;
7
9
  export default ToolbarMore;
@@ -1,45 +1,63 @@
1
- import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import { useState as a, useRef as d, useEffect as m } from "react";
3
- import { cn as u } from "../../../../utils/cn.js";
4
- import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as _, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as f, RICH_EDITOR_BUTTON_BASE_CLASSES as h } from "../../RichEditor.const.js";
5
- const E = () => /* @__PURE__ */ s("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6
- /* @__PURE__ */ e("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
7
- /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
8
- ] }), S = ({ children: c, disabled: o }) => {
9
- const [r, i] = a(!1), t = d(null);
10
- return m(() => {
11
- const n = (l) => {
12
- t.current && !t.current.contains(l.target) && i(!1);
1
+ import { jsx as e, jsxs as g } from "react/jsx-runtime";
2
+ import { useState as f, useRef as p, useEffect as h } from "react";
3
+ import { createPortal as C } from "react-dom";
4
+ import { cn as _ } from "../../../../utils/cn.js";
5
+ import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as R, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as v, RICH_EDITOR_BUTTON_BASE_CLASSES as w } from "../../RichEditor.const.js";
6
+ const B = () => /* @__PURE__ */ g("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
7
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "1.5", fill: "currentColor" }),
8
+ /* @__PURE__ */ e("circle", { cx: "6", cy: "12", r: "1.5", fill: "currentColor" }),
9
+ /* @__PURE__ */ e("circle", { cx: "18", cy: "12", r: "1.5", fill: "currentColor" })
10
+ ] }), b = ({ children: x, disabled: l, isMobile: t }) => {
11
+ const [r, s] = f(!1), n = p(null), i = p(null), [d, E] = f({ top: 0, left: 0 });
12
+ h(() => {
13
+ const o = (u) => {
14
+ var a;
15
+ if (n.current && !n.current.contains(u.target)) {
16
+ const c = u.target;
17
+ (a = c.closest) != null && a.call(c, ".Bear-RichEditor__more-menu") || s(!1);
18
+ }
13
19
  };
14
- return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
15
- }, []), /* @__PURE__ */ s("div", { ref: t, className: "Bear-RichEditor__more relative", children: [
20
+ return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
21
+ }, []), h(() => {
22
+ if (r && t && i.current && typeof document < "u") {
23
+ const o = i.current.getBoundingClientRect();
24
+ E({ top: o.bottom + 4, left: Math.max(8, o.right - 220) });
25
+ }
26
+ }, [r, t]);
27
+ const m = /* @__PURE__ */ e(
28
+ "div",
29
+ {
30
+ className: _(
31
+ "Bear-RichEditor__more-menu p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,280px)] max-h-[70vh] overflow-y-auto",
32
+ t ? "fixed z-[9999]" : "absolute top-full right-0 mt-1 z-50"
33
+ ),
34
+ style: t ? { top: d.top, left: d.left } : void 0,
35
+ children: /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-0.5", children: x })
36
+ }
37
+ );
38
+ return /* @__PURE__ */ g("div", { ref: n, className: "Bear-RichEditor__more relative", children: [
16
39
  /* @__PURE__ */ e(
17
40
  "button",
18
41
  {
42
+ ref: i,
19
43
  type: "button",
20
44
  title: "More options",
21
- disabled: o,
22
- onClick: () => i(!r),
23
- className: u(
45
+ disabled: l,
46
+ onClick: () => s(!r),
47
+ className: _(
24
48
  "Bear-RichEditor__more-trigger",
25
- h,
26
- f,
49
+ w,
50
+ v,
27
51
  "flex items-center justify-center",
28
52
  r && "bg-pink-500 text-white",
29
- o && `Bear-RichEditor__more-trigger--disabled ${_}`
53
+ l && `Bear-RichEditor__more-trigger--disabled ${R}`
30
54
  ),
31
- children: /* @__PURE__ */ e(E, {})
55
+ children: /* @__PURE__ */ e(B, {})
32
56
  }
33
57
  ),
34
- r && /* @__PURE__ */ e(
35
- "div",
36
- {
37
- className: "Bear-RichEditor__more-menu absolute top-full right-0 mt-1 p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl z-50 min-w-[200px]",
38
- children: /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-0.5", children: c })
39
- }
40
- )
58
+ r && (t && typeof document < "u" ? C(m, document.body) : m)
41
59
  ] });
42
60
  };
43
61
  export {
44
- S as ToolbarMore
62
+ b as ToolbarMore
45
63
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),i=require("../../utils/cn.cjs"),y={sm:"bear-h-8 bear-text-sm",md:"bear-h-10 bear-text-base",lg:"bear-h-12 bear-text-lg"},p=({items:t,value:b,defaultValue:d,onChange:a,size:c="md",fullWidth:l=!1,disabled:r=!1,className:u})=>{var o;const[x,g]=f.useState(d??((o=t[0])==null?void 0:o.value)??""),n=b??x,v=(e,m)=>{m||r||(b===void 0&&g(e),a==null||a(e))};return s.jsx("div",{role:"group","aria-label":"Segmented control",className:i.cn("Bear-SegmentedControl bear-relative bear-inline-flex bear-rounded-lg bear-bg-gray-200 dark:bear-bg-zinc-800 bear-p-1",l&&"bear-w-full",r&&"bear-opacity-50 bear-pointer-events-none",u),children:t.map(e=>s.jsx("button",{type:"button",role:"tab","aria-selected":e.value===n,"aria-disabled":e.disabled||r,disabled:e.disabled||r,onClick:()=>v(e.value,e.disabled),className:i.cn("Bear-SegmentedControl__item bear-relative bear-flex-1 bear-flex bear-items-center bear-justify-center bear-rounded-md bear-font-medium bear-transition-all bear-duration-200 bear-text-gray-600 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-zinc-200",e.value===n&&"bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-900 dark:bear-text-white bear-shadow-sm",(e.disabled||r)&&"bear-cursor-not-allowed bear-opacity-50",y[c],l?"bear-min-w-0":"bear-px-4"),children:e.label},e.value))})};exports.SegmentedControl=p;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { SegmentedControlProps } from './SegmentedControl.types';
3
+ export declare const SegmentedControl: FC<SegmentedControlProps>;
@@ -0,0 +1,58 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useState as g } from "react";
3
+ import { cn as d } from "../../utils/cn.js";
4
+ const p = {
5
+ sm: "bear-h-8 bear-text-sm",
6
+ md: "bear-h-10 bear-text-base",
7
+ lg: "bear-h-12 bear-text-lg"
8
+ }, w = ({
9
+ items: t,
10
+ value: b,
11
+ defaultValue: i,
12
+ onChange: r,
13
+ size: c = "md",
14
+ fullWidth: l = !1,
15
+ disabled: a = !1,
16
+ className: u
17
+ }) => {
18
+ var o;
19
+ const [m, x] = g(i ?? ((o = t[0]) == null ? void 0 : o.value) ?? ""), n = b ?? m, v = (e, f) => {
20
+ f || a || (b === void 0 && x(e), r == null || r(e));
21
+ };
22
+ return /* @__PURE__ */ s(
23
+ "div",
24
+ {
25
+ role: "group",
26
+ "aria-label": "Segmented control",
27
+ className: d(
28
+ "Bear-SegmentedControl bear-relative bear-inline-flex bear-rounded-lg bear-bg-gray-200 dark:bear-bg-zinc-800 bear-p-1",
29
+ l && "bear-w-full",
30
+ a && "bear-opacity-50 bear-pointer-events-none",
31
+ u
32
+ ),
33
+ children: t.map((e) => /* @__PURE__ */ s(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ role: "tab",
38
+ "aria-selected": e.value === n,
39
+ "aria-disabled": e.disabled || a,
40
+ disabled: e.disabled || a,
41
+ onClick: () => v(e.value, e.disabled),
42
+ className: d(
43
+ "Bear-SegmentedControl__item bear-relative bear-flex-1 bear-flex bear-items-center bear-justify-center bear-rounded-md bear-font-medium bear-transition-all bear-duration-200 bear-text-gray-600 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-zinc-200",
44
+ e.value === n && "bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-900 dark:bear-text-white bear-shadow-sm",
45
+ (e.disabled || a) && "bear-cursor-not-allowed bear-opacity-50",
46
+ p[c],
47
+ l ? "bear-min-w-0" : "bear-px-4"
48
+ ),
49
+ children: e.label
50
+ },
51
+ e.value
52
+ ))
53
+ }
54
+ );
55
+ };
56
+ export {
57
+ w as SegmentedControl
58
+ };
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SegmentedControlItem {
3
+ value: string;
4
+ label: ReactNode;
5
+ disabled?: boolean;
6
+ }
7
+ export interface SegmentedControlProps {
8
+ items: SegmentedControlItem[];
9
+ value?: string;
10
+ defaultValue?: string;
11
+ onChange?: (value: string) => void;
12
+ size?: 'sm' | 'md' | 'lg';
13
+ fullWidth?: boolean;
14
+ disabled?: boolean;
15
+ className?: string;
16
+ }
@@ -0,0 +1,2 @@
1
+ export { SegmentedControl } from './SegmentedControl';
2
+ export type { SegmentedControlProps, SegmentedControlItem } from './SegmentedControl.types';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),s=require("react"),_=require("../../utils/cn.cjs"),p=require("../Button/Button.cjs"),a=require("./SignPad.const.cjs"),V=y=>{const{onChange:r,width:P=a.SIGN_PAD_DEFAULT_WIDTH,height:A=a.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:B,strokeWidth:N=a.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:O,placeholder:U=a.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:o=!1,readOnly:l=!1,showClear:I=!0,showSave:v=!1,clearText:M="Clear",saveText:j="Save",outputFormat:h=a.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:D=a.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:F,testId:H,id:K,...W}=y,i=s.useRef(null),[f,x]=s.useState(!1),[u,m]=s.useState(!1),[g,C]=s.useState(null),[E,q]=s.useState(!1);s.useEffect(()=>{const e=()=>{const n=document.documentElement.classList.contains("dark");q(n)};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const k=B||(E?a.SIGN_PAD_STROKE_DARK:a.SIGN_PAD_STROKE_LIGHT),S=O||(E?a.SIGN_PAD_BG_DARK:a.SIGN_PAD_BG_LIGHT);s.useEffect(()=>{const e=i.current;if(!e)return;const t=e.getContext("2d");t&&(e.width=P,e.height=A,t.fillStyle=S,t.fillRect(0,0,P,A))},[P,A,S,E]);const b=s.useCallback(e=>{const t=i.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),d=t.width/n.width,w=t.height/n.height;if("touches"in e){const G=e.touches[0];return{x:(G.clientX-n.left)*d,y:(G.clientY-n.top)*w}}return{x:(e.clientX-n.left)*d,y:(e.clientY-n.top)*w}},[]),L=s.useCallback(e=>{if(o||l)return;const t=b(e);x(!0),C(t)},[o,l,b]),R=s.useCallback(e=>{if(!f||o||l)return;const t=i.current,n=t==null?void 0:t.getContext("2d");if(!t||!n||!g)return;const d=b(e);n.beginPath(),n.moveTo(g.x,g.y),n.lineTo(d.x,d.y),n.strokeStyle=k,n.lineWidth=N,n.lineCap="round",n.lineJoin="round",n.stroke(),C(d),m(!0)},[f,o,l,g,k,N,b]),T=s.useCallback(()=>{if(f&&u){const e=i.current;if(e&&r){const t=e.toDataURL(h,D);r(t)}}x(!1),C(null)},[f,u,r,h,D]),X=s.useCallback(()=>{const e=i.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=S==="transparent"?"rgba(0,0,0,0)":S,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),m(!1),r==null||r(null))},[S,r]),Y=s.useCallback(()=>{const e=i.current;if(!e||!u)return;const t=e.toDataURL(h,D);r==null||r(t)},[u,r,h,D]);return c.jsxs("div",{id:K,"data-testid":H,className:_.cn("Bear-SignPad bear-max-w-full bear-w-full",a.SIGN_PAD_ROOT_CLASSES,o&&"Bear-SignPad--disabled bear-opacity-50",l&&"Bear-SignPad--readonly",F),...W,children:[c.jsxs("div",{className:_.cn("Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",a.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!o&&!l&&a.SIGN_PAD_CANVAS_WRAPPER_HOVER,o&&"bear-cursor-not-allowed",!o&&!l&&"bear-cursor-crosshair"),children:[c.jsx("canvas",{ref:i,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",style:{width:P,height:A},onMouseDown:L,onMouseMove:R,onMouseUp:T,onMouseLeave:T,onTouchStart:L,onTouchMove:R,onTouchEnd:T}),!u&&c.jsx("div",{className:_.cn("Bear-SignPad__placeholder",a.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),c.jsx("div",{className:_.cn("Bear-SignPad__line",a.SIGN_PAD_LINE_CLASSES)}),c.jsx("span",{className:_.cn("Bear-SignPad__x-mark",a.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(I||v)&&c.jsxs("div",{className:_.cn("Bear-SignPad__actions",a.SIGN_PAD_ACTIONS_CLASSES),children:[I&&c.jsx(p.Button,{size:"sm",variant:"ghost",onClick:X,disabled:o||!u,children:M}),v&&c.jsx(p.Button,{size:"sm",variant:"primary",onClick:Y,disabled:o||!u,children:j})]})]})};exports.SignPad=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),_=require("../../utils/cn.cjs"),G=require("../Button/Button.cjs"),s=require("./SignPad.const.cjs"),V=y=>{const{onChange:o,width:h=s.SIGN_PAD_DEFAULT_WIDTH,height:f=s.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:B,strokeWidth:m=s.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:O,placeholder:U=s.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:r=!1,readOnly:c=!1,showClear:C=!0,showSave:L=!1,clearText:M="Clear",saveText:j="Save",outputFormat:A=s.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:P=s.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:F,testId:H,id:K,...W}=y,l=a.useRef(null),[D,N]=a.useState(!1),[u,I]=a.useState(!1),[v,E]=a.useState(null),[b,q]=a.useState(!1);a.useEffect(()=>{const e=()=>{const n=document.documentElement.classList.contains("dark");q(n)};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const x=B||(b?s.SIGN_PAD_STROKE_DARK:s.SIGN_PAD_STROKE_LIGHT),S=O||(b?s.SIGN_PAD_BG_DARK:s.SIGN_PAD_BG_LIGHT);a.useEffect(()=>{const e=l.current;if(!e)return;const t=e.getContext("2d");t&&(e.width=h,e.height=f,t.fillStyle=S,t.fillRect(0,0,h,f))},[h,f,S,b]),a.useEffect(()=>{const e=l.current;if(!e||r||c)return;const t=n=>n.preventDefault();return e.addEventListener("touchstart",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchmove",t)}},[r,c]);const g=a.useCallback(e=>{const t=l.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),d=t.width/n.width,p=t.height/n.height;if("touches"in e){const w=e.touches[0];return{x:(w.clientX-n.left)*d,y:(w.clientY-n.top)*p}}return{x:(e.clientX-n.left)*d,y:(e.clientY-n.top)*p}},[]),k=a.useCallback(e=>{if(r||c)return;const t=g(e);N(!0),E(t)},[r,c,g]),R=a.useCallback(e=>{if(!D||r||c)return;const t=l.current,n=t==null?void 0:t.getContext("2d");if(!t||!n||!v)return;const d=g(e);n.beginPath(),n.moveTo(v.x,v.y),n.lineTo(d.x,d.y),n.strokeStyle=x,n.lineWidth=m,n.lineCap="round",n.lineJoin="round",n.stroke(),E(d),I(!0)},[D,r,c,v,x,m,g]),T=a.useCallback(()=>{if(D&&u){const e=l.current;if(e&&o){const t=e.toDataURL(A,P);o(t)}}N(!1),E(null)},[D,u,o,A,P]),X=a.useCallback(()=>{const e=l.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=S==="transparent"?"rgba(0,0,0,0)":S,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),I(!1),o==null||o(null))},[S,o]),Y=a.useCallback(()=>{const e=l.current;if(!e||!u)return;const t=e.toDataURL(A,P);o==null||o(t)},[u,o,A,P]);return i.jsxs("div",{id:K,"data-testid":H,className:_.cn("Bear-SignPad bear-max-w-full bear-w-full",s.SIGN_PAD_ROOT_CLASSES,r&&"Bear-SignPad--disabled bear-opacity-50",c&&"Bear-SignPad--readonly",F),...W,children:[i.jsxs("div",{className:_.cn("Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden","touch-none",s.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!r&&!c&&s.SIGN_PAD_CANVAS_WRAPPER_HOVER,r&&"bear-cursor-not-allowed",!r&&!c&&"bear-cursor-crosshair"),children:[i.jsx("canvas",{ref:l,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full touch-none",style:{width:h,height:f,touchAction:"none"},onMouseDown:k,onMouseMove:R,onMouseUp:T,onMouseLeave:T,onTouchStart:k,onTouchMove:R,onTouchEnd:T}),!u&&i.jsx("div",{className:_.cn("Bear-SignPad__placeholder",s.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),i.jsx("div",{className:_.cn("Bear-SignPad__line",s.SIGN_PAD_LINE_CLASSES)}),i.jsx("span",{className:_.cn("Bear-SignPad__x-mark",s.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(C||L)&&i.jsxs("div",{className:_.cn("Bear-SignPad__actions",s.SIGN_PAD_ACTIONS_CLASSES),children:[C&&i.jsx(G.Button,{size:"sm",variant:"ghost",onClick:X,disabled:r||!u,children:M}),L&&i.jsx(G.Button,{size:"sm",variant:"primary",onClick:Y,disabled:r||!u,children:j})]})]})};exports.SignPad=V;