@forgedevstack/bear 1.0.3 → 1.0.4

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 (295) hide show
  1. package/dist/components/Accordion/Accordion.cjs +1 -1
  2. package/dist/components/Accordion/Accordion.const.cjs +1 -0
  3. package/dist/components/Accordion/Accordion.const.d.ts +10 -0
  4. package/dist/components/Accordion/Accordion.const.js +8 -0
  5. package/dist/components/Accordion/Accordion.d.ts +1 -0
  6. package/dist/components/Accordion/Accordion.js +49 -44
  7. package/dist/components/Accordion/Accordion.types.d.ts +2 -0
  8. package/dist/components/Accordion/index.d.ts +3 -2
  9. package/dist/components/ActivityItem/ActivityItem.cjs +1 -0
  10. package/dist/components/ActivityItem/ActivityItem.d.ts +7 -0
  11. package/dist/components/ActivityItem/ActivityItem.js +44 -0
  12. package/dist/components/ActivityItem/ActivityItem.types.d.ts +17 -0
  13. package/dist/components/ActivityItem/index.d.ts +2 -0
  14. package/dist/components/Alert/Alert.cjs +1 -1
  15. package/dist/components/Alert/Alert.const.cjs +1 -0
  16. package/dist/components/Alert/Alert.const.d.ts +14 -0
  17. package/dist/components/Alert/Alert.const.js +27 -0
  18. package/dist/components/Alert/Alert.js +54 -63
  19. package/dist/components/Alert/Alert.types.d.ts +3 -1
  20. package/dist/components/Avatar/Avatar.cjs +1 -1
  21. package/dist/components/Avatar/Avatar.const.cjs +1 -0
  22. package/dist/components/Avatar/Avatar.const.d.ts +28 -0
  23. package/dist/components/Avatar/Avatar.const.js +28 -0
  24. package/dist/components/Avatar/Avatar.js +49 -60
  25. package/dist/components/Avatar/index.d.ts +1 -0
  26. package/dist/components/Badge/Badge.cjs +1 -1
  27. package/dist/components/Badge/Badge.js +24 -22
  28. package/dist/components/BearLogo/EmberLogo.cjs +17 -0
  29. package/dist/components/BearLogo/EmberLogo.js +91 -0
  30. package/dist/components/BearLogo/index.d.ts +2 -0
  31. package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
  32. package/dist/components/Breadcrumbs/Breadcrumbs.const.cjs +1 -0
  33. package/dist/components/Breadcrumbs/Breadcrumbs.const.d.ts +16 -0
  34. package/dist/components/Breadcrumbs/Breadcrumbs.const.js +19 -0
  35. package/dist/components/Breadcrumbs/Breadcrumbs.js +49 -34
  36. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +8 -1
  37. package/dist/components/Button/Button.cjs +1 -1
  38. package/dist/components/Button/Button.constants.cjs +1 -1
  39. package/dist/components/Button/Button.constants.d.ts +2 -2
  40. package/dist/components/Button/Button.constants.js +2 -2
  41. package/dist/components/Button/Button.js +41 -46
  42. package/dist/components/Calendar/Calendar.cjs +1 -1
  43. package/dist/components/Calendar/Calendar.helpers.cjs +1 -0
  44. package/dist/components/Calendar/Calendar.helpers.d.ts +10 -0
  45. package/dist/components/Calendar/Calendar.helpers.js +9 -0
  46. package/dist/components/Calendar/Calendar.js +112 -115
  47. package/dist/components/Card/Card.cjs +1 -1
  48. package/dist/components/Card/Card.const.cjs +1 -0
  49. package/dist/components/Card/Card.const.d.ts +13 -0
  50. package/dist/components/Card/Card.const.js +32 -0
  51. package/dist/components/Card/Card.d.ts +1 -0
  52. package/dist/components/Card/Card.js +101 -105
  53. package/dist/components/Card/index.d.ts +3 -2
  54. package/dist/components/Chart/Chart.cjs +1 -0
  55. package/dist/components/Chart/Chart.const.d.ts +15 -0
  56. package/dist/components/Chart/Chart.d.ts +18 -0
  57. package/dist/components/Chart/Chart.js +225 -0
  58. package/dist/components/Chart/Chart.types.d.ts +51 -0
  59. package/dist/components/Chart/Chart.utils.d.ts +31 -0
  60. package/dist/components/Chart/index.d.ts +2 -0
  61. package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
  62. package/dist/components/CodeBlock/CodeBlock.js +65 -52
  63. package/dist/components/CodeBlock/CodeBlock.types.d.ts +12 -1
  64. package/dist/components/Editable/Editable.cjs +1 -1
  65. package/dist/components/Editable/Editable.js +115 -115
  66. package/dist/components/Gauge/Gauge.cjs +1 -0
  67. package/dist/components/Gauge/Gauge.d.ts +3 -0
  68. package/dist/components/Gauge/Gauge.js +92 -0
  69. package/dist/components/Gauge/Gauge.types.d.ts +27 -0
  70. package/dist/components/Gauge/index.d.ts +2 -0
  71. package/dist/components/Icon/icons/editor.cjs +1 -1
  72. package/dist/components/Icon/icons/editor.d.ts +1 -0
  73. package/dist/components/Icon/icons/editor.js +66 -61
  74. package/dist/components/Icon/icons/misc.cjs +1 -1
  75. package/dist/components/Icon/icons/misc.d.ts +13 -0
  76. package/dist/components/Icon/icons/misc.js +157 -88
  77. package/dist/components/Icon/index.d.ts +22 -0
  78. package/dist/components/Input/Input.cjs +1 -1
  79. package/dist/components/Input/Input.js +36 -35
  80. package/dist/components/Modal/Modal.cjs +1 -1
  81. package/dist/components/Modal/Modal.const.cjs +1 -0
  82. package/dist/components/Modal/Modal.const.d.ts +10 -0
  83. package/dist/components/Modal/Modal.const.js +17 -0
  84. package/dist/components/Modal/Modal.d.ts +11 -0
  85. package/dist/components/Modal/Modal.js +80 -77
  86. package/dist/components/Modal/Modal.types.d.ts +6 -1
  87. package/dist/components/Modal/index.d.ts +3 -2
  88. package/dist/components/Rating/Rating.cjs +1 -1
  89. package/dist/components/Rating/Rating.const.cjs +1 -0
  90. package/dist/components/Rating/Rating.const.d.ts +14 -0
  91. package/dist/components/Rating/Rating.const.js +22 -0
  92. package/dist/components/Rating/Rating.d.ts +5 -10
  93. package/dist/components/Rating/Rating.js +135 -93
  94. package/dist/components/Rating/Rating.types.d.ts +27 -25
  95. package/dist/components/Rating/index.d.ts +2 -2
  96. package/dist/components/RichEditor/RichEditor.cjs +1 -10
  97. package/dist/components/RichEditor/RichEditor.const.cjs +141 -0
  98. package/dist/components/RichEditor/RichEditor.const.d.ts +137 -0
  99. package/dist/components/RichEditor/RichEditor.const.js +279 -0
  100. package/dist/components/RichEditor/RichEditor.d.ts +14 -0
  101. package/dist/components/RichEditor/RichEditor.js +341 -129
  102. package/dist/components/RichEditor/RichEditor.types.d.ts +38 -1
  103. package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -0
  104. package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.d.ts +4 -0
  105. package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +25 -0
  106. package/dist/components/RichEditor/components/ToolbarButton/index.d.ts +1 -0
  107. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -0
  108. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.d.ts +4 -0
  109. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +126 -0
  110. package/dist/components/RichEditor/components/ToolbarColorPicker/index.d.ts +1 -0
  111. package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.cjs +1 -0
  112. package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.d.ts +4 -0
  113. package/dist/components/RichEditor/components/ToolbarDropdown/ToolbarDropdown.js +57 -0
  114. package/dist/components/RichEditor/components/ToolbarDropdown/index.d.ts +1 -0
  115. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -0
  116. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +7 -0
  117. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +45 -0
  118. package/dist/components/RichEditor/components/ToolbarMore/index.d.ts +2 -0
  119. package/dist/components/RichEditor/components/index.d.ts +4 -0
  120. package/dist/components/RichEditor/helpers/formatHelpers.cjs +1 -0
  121. package/dist/components/RichEditor/helpers/formatHelpers.d.ts +57 -0
  122. package/dist/components/RichEditor/helpers/formatHelpers.js +26 -0
  123. package/dist/components/RichEditor/helpers/index.d.ts +1 -0
  124. package/dist/components/RichEditor/index.d.ts +4 -2
  125. package/dist/components/Sidebar/Sidebar.cjs +1 -1
  126. package/dist/components/Sidebar/Sidebar.const.cjs +1 -0
  127. package/dist/components/Sidebar/Sidebar.const.d.ts +16 -0
  128. package/dist/components/Sidebar/Sidebar.const.js +22 -0
  129. package/dist/components/Sidebar/Sidebar.d.ts +14 -2
  130. package/dist/components/Sidebar/Sidebar.js +50 -138
  131. package/dist/components/Sidebar/Sidebar.types.d.ts +7 -3
  132. package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.cjs +1 -0
  133. package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.d.ts +4 -0
  134. package/dist/components/Sidebar/components/SidebarGroup/SidebarGroup.js +45 -0
  135. package/dist/components/Sidebar/components/SidebarGroup/index.d.ts +2 -0
  136. package/dist/components/Sidebar/components/SidebarItem/SidebarItem.cjs +1 -0
  137. package/dist/components/Sidebar/components/SidebarItem/SidebarItem.d.ts +4 -0
  138. package/dist/components/Sidebar/components/SidebarItem/SidebarItem.js +66 -0
  139. package/dist/components/Sidebar/components/SidebarItem/index.d.ts +2 -0
  140. package/dist/components/Sidebar/components/index.d.ts +2 -0
  141. package/dist/components/Sidebar/index.d.ts +5 -2
  142. package/dist/components/SignPad/SignPad.cjs +1 -0
  143. package/dist/components/SignPad/SignPad.const.cjs +1 -0
  144. package/dist/components/SignPad/SignPad.const.d.ts +19 -0
  145. package/dist/components/SignPad/SignPad.const.js +20 -0
  146. package/dist/components/SignPad/SignPad.d.ts +17 -0
  147. package/dist/components/SignPad/SignPad.js +161 -0
  148. package/dist/components/SignPad/SignPad.types.d.ts +37 -0
  149. package/dist/components/SignPad/index.d.ts +3 -0
  150. package/dist/components/Skeleton/Skeleton.cjs +1 -1
  151. package/dist/components/Skeleton/Skeleton.const.cjs +36 -0
  152. package/dist/components/Skeleton/Skeleton.const.d.ts +12 -0
  153. package/dist/components/Skeleton/Skeleton.const.js +58 -0
  154. package/dist/components/Skeleton/Skeleton.d.ts +15 -24
  155. package/dist/components/Skeleton/Skeleton.js +132 -103
  156. package/dist/components/Skeleton/Skeleton.types.d.ts +18 -8
  157. package/dist/components/Skeleton/index.d.ts +2 -2
  158. package/dist/components/Sparkline/Sparkline.cjs +1 -0
  159. package/dist/components/Sparkline/Sparkline.const.cjs +1 -0
  160. package/dist/components/Sparkline/Sparkline.const.d.ts +16 -0
  161. package/dist/components/Sparkline/Sparkline.const.js +16 -0
  162. package/dist/components/Sparkline/Sparkline.d.ts +3 -0
  163. package/dist/components/Sparkline/Sparkline.js +80 -0
  164. package/dist/components/Sparkline/Sparkline.types.d.ts +19 -0
  165. package/dist/components/Sparkline/Sparkline.utils.cjs +1 -0
  166. package/dist/components/Sparkline/Sparkline.utils.d.ts +27 -0
  167. package/dist/components/Sparkline/Sparkline.utils.js +30 -0
  168. package/dist/components/Sparkline/index.d.ts +5 -0
  169. package/dist/components/SpeedDial/SpeedDial.cjs +12 -1
  170. package/dist/components/SpeedDial/SpeedDial.const.cjs +1 -0
  171. package/dist/components/SpeedDial/SpeedDial.const.d.ts +22 -0
  172. package/dist/components/SpeedDial/SpeedDial.const.js +26 -0
  173. package/dist/components/SpeedDial/SpeedDial.d.ts +5 -7
  174. package/dist/components/SpeedDial/SpeedDial.js +154 -144
  175. package/dist/components/SpeedDial/SpeedDial.types.d.ts +26 -29
  176. package/dist/components/SpeedDial/index.d.ts +1 -1
  177. package/dist/components/Spinner/Spinner.cjs +1 -1
  178. package/dist/components/Spinner/Spinner.js +17 -15
  179. package/dist/components/StatCard/StatCard.cjs +1 -0
  180. package/dist/components/StatCard/StatCard.d.ts +7 -0
  181. package/dist/components/StatCard/StatCard.js +36 -0
  182. package/dist/components/StatCard/StatCard.types.d.ts +13 -0
  183. package/dist/components/StatCard/index.d.ts +2 -0
  184. package/dist/components/Stepper/Stepper.cjs +1 -1
  185. package/dist/components/Stepper/Stepper.const.cjs +1 -0
  186. package/dist/components/Stepper/Stepper.const.d.ts +29 -0
  187. package/dist/components/Stepper/Stepper.const.js +46 -0
  188. package/dist/components/Stepper/Stepper.d.ts +10 -3
  189. package/dist/components/Stepper/Stepper.js +143 -92
  190. package/dist/components/Stepper/Stepper.types.d.ts +63 -13
  191. package/dist/components/Stepper/index.d.ts +2 -2
  192. package/dist/components/Switch/Switch.cjs +1 -1
  193. package/dist/components/Switch/Switch.js +74 -47
  194. package/dist/components/Switch/Switch.types.d.ts +11 -1
  195. package/dist/components/Tabs/Tabs.cjs +1 -1
  196. package/dist/components/Tabs/Tabs.js +33 -29
  197. package/dist/components/TimePicker/TimePicker.cjs +1 -1
  198. package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
  199. package/dist/components/TimePicker/TimePicker.constants.d.ts +14 -0
  200. package/dist/components/TimePicker/TimePicker.constants.js +18 -4
  201. package/dist/components/TimePicker/TimePicker.js +92 -91
  202. package/dist/components/Timeline/Timeline.cjs +1 -1
  203. package/dist/components/Timeline/Timeline.const.cjs +1 -0
  204. package/dist/components/Timeline/Timeline.const.d.ts +40 -0
  205. package/dist/components/Timeline/Timeline.const.js +58 -0
  206. package/dist/components/Timeline/Timeline.d.ts +16 -2
  207. package/dist/components/Timeline/Timeline.js +131 -63
  208. package/dist/components/Timeline/Timeline.types.d.ts +30 -11
  209. package/dist/components/Timeline/index.d.ts +1 -1
  210. package/dist/components/Tooltip/Tooltip.cjs +1 -1
  211. package/dist/components/Tooltip/Tooltip.js +37 -35
  212. package/dist/components/Typography/Typography.cjs +1 -1
  213. package/dist/components/Typography/Typography.js +38 -36
  214. package/dist/components/index.cjs +1 -1
  215. package/dist/components/index.d.ts +17 -5
  216. package/dist/components/index.js +216 -195
  217. package/dist/hooks/index.cjs +1 -1
  218. package/dist/hooks/index.d.ts +24 -0
  219. package/dist/hooks/index.js +42 -14
  220. package/dist/hooks/useBounce/index.d.ts +2 -0
  221. package/dist/hooks/useBounce/useBounce.cjs +1 -0
  222. package/dist/hooks/useBounce/useBounce.d.ts +2 -0
  223. package/dist/hooks/useBounce/useBounce.js +36 -0
  224. package/dist/hooks/useBounce/useBounce.types.d.ts +27 -0
  225. package/dist/hooks/useClickOutside/index.d.ts +2 -0
  226. package/dist/hooks/useClickOutside/useClickOutside.d.ts +22 -0
  227. package/dist/hooks/useClickOutside/useClickOutside.types.d.ts +10 -0
  228. package/dist/hooks/useClipboard/index.d.ts +2 -0
  229. package/dist/hooks/useClipboard/useClipboard.cjs +1 -0
  230. package/dist/hooks/useClipboard/useClipboard.d.ts +15 -0
  231. package/dist/hooks/useClipboard/useClipboard.js +22 -0
  232. package/dist/hooks/useClipboard/useClipboard.types.d.ts +20 -0
  233. package/dist/hooks/useDebounce/index.d.ts +2 -0
  234. package/dist/hooks/useDebounce/useDebounce.cjs +1 -0
  235. package/dist/hooks/useDebounce/useDebounce.d.ts +32 -0
  236. package/dist/hooks/useDebounce/useDebounce.js +39 -0
  237. package/dist/hooks/useDebounce/useDebounce.types.d.ts +20 -0
  238. package/dist/hooks/useFloat/index.d.ts +2 -0
  239. package/dist/hooks/useFloat/useFloat.cjs +1 -0
  240. package/dist/hooks/useFloat/useFloat.d.ts +2 -0
  241. package/dist/hooks/useFloat/useFloat.js +37 -0
  242. package/dist/hooks/useFloat/useFloat.types.d.ts +25 -0
  243. package/dist/hooks/useIntersectionObserver/index.d.ts +2 -0
  244. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -0
  245. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.ts +25 -0
  246. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.js +39 -0
  247. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.types.d.ts +22 -0
  248. package/dist/hooks/useKeyPress/index.d.ts +2 -0
  249. package/dist/hooks/useKeyPress/useKeyPress.cjs +1 -0
  250. package/dist/hooks/useKeyPress/useKeyPress.d.ts +22 -0
  251. package/dist/hooks/useKeyPress/useKeyPress.js +39 -0
  252. package/dist/hooks/useKeyPress/useKeyPress.types.d.ts +19 -0
  253. package/dist/hooks/useLocalStorage/index.d.ts +2 -0
  254. package/dist/hooks/useLocalStorage/useLocalStorage.cjs +1 -0
  255. package/dist/hooks/useLocalStorage/useLocalStorage.d.ts +11 -0
  256. package/dist/hooks/useLocalStorage/useLocalStorage.js +47 -0
  257. package/dist/hooks/useLocalStorage/useLocalStorage.types.d.ts +16 -0
  258. package/dist/hooks/useMediaQuery/index.d.ts +3 -0
  259. package/dist/hooks/useMediaQuery/useMediaQuery.d.ts +12 -0
  260. package/dist/hooks/useMediaQuery/useMediaQuery.types.d.ts +21 -0
  261. package/dist/hooks/useParallax/index.d.ts +2 -0
  262. package/dist/hooks/useParallax/useParallax.cjs +1 -0
  263. package/dist/hooks/useParallax/useParallax.d.ts +2 -0
  264. package/dist/hooks/useParallax/useParallax.js +36 -0
  265. package/dist/hooks/useParallax/useParallax.types.d.ts +19 -0
  266. package/dist/hooks/usePulse/index.d.ts +2 -0
  267. package/dist/hooks/usePulse/usePulse.cjs +1 -0
  268. package/dist/hooks/usePulse/usePulse.d.ts +2 -0
  269. package/dist/hooks/usePulse/usePulse.js +38 -0
  270. package/dist/hooks/usePulse/usePulse.types.d.ts +29 -0
  271. package/dist/hooks/useShake/index.d.ts +2 -0
  272. package/dist/hooks/useShake/useShake.cjs +1 -0
  273. package/dist/hooks/useShake/useShake.d.ts +2 -0
  274. package/dist/hooks/useShake/useShake.js +14 -0
  275. package/dist/hooks/useShake/useShake.types.d.ts +19 -0
  276. package/dist/hooks/useSlide/index.d.ts +2 -0
  277. package/dist/hooks/useSlide/useSlide.cjs +1 -0
  278. package/dist/hooks/useSlide/useSlide.d.ts +2 -0
  279. package/dist/hooks/useSlide/useSlide.js +68 -0
  280. package/dist/hooks/useSlide/useSlide.types.d.ts +36 -0
  281. package/dist/hooks/useThrottle/index.d.ts +2 -0
  282. package/dist/hooks/useThrottle/useThrottle.cjs +1 -0
  283. package/dist/hooks/useThrottle/useThrottle.d.ts +26 -0
  284. package/dist/hooks/useThrottle/useThrottle.js +44 -0
  285. package/dist/hooks/useThrottle/useThrottle.types.d.ts +8 -0
  286. package/dist/index.cjs +1 -1
  287. package/dist/index.js +273 -224
  288. package/dist/styles.css +1 -1
  289. package/package.json +14 -21
  290. package/dist/components/RichEditor/RichEditor.icons.cjs +0 -1
  291. package/dist/components/RichEditor/RichEditor.icons.d.ts +0 -16
  292. package/dist/components/RichEditor/RichEditor.icons.js +0 -62
  293. package/dist/components/RichEditor/RichEditor.utils.cjs +0 -1
  294. package/dist/components/RichEditor/RichEditor.utils.d.ts +0 -3
  295. package/dist/components/RichEditor/RichEditor.utils.js +0 -22
@@ -1,144 +1,356 @@
1
- import { jsxs as S, jsx as r } from "react/jsx-runtime";
2
- import { useRef as U, useState as $, useEffect as L, useCallback as m } from "react";
3
- import { queryCommandState as d, execCommand as t, DEFAULT_TOOLBAR as N } from "./RichEditor.utils.js";
4
- import { LinkIcon as q, CodeIcon as E, BlockquoteIcon as F, OrderedListIcon as M, BulletListIcon as R, Heading2Icon as A, Heading1Icon as C, StrikethroughIcon as H, UnderlineIcon as j, ItalicIcon as O, BoldIcon as D } from "./RichEditor.icons.js";
5
- const K = ({ icon: n, title: u, active: s, onClick: k, disabled: i }) => /* @__PURE__ */ r(
6
- "button",
7
- {
8
- type: "button",
9
- title: u,
10
- onClick: k,
11
- disabled: i,
12
- className: `
13
- p-1.5 rounded transition-colors
14
- ${s ? "bg-pink-500 text-white" : "text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"}
15
- ${i ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
16
- `,
17
- children: n
18
- }
19
- ), G = ({
20
- value: n,
21
- defaultValue: u = "",
22
- onChange: s,
23
- placeholder: k = "Start typing...",
24
- disabled: i = !1,
25
- readOnly: b = !1,
26
- minHeight: f = 150,
27
- maxHeight: l,
28
- toolbar: y = N,
29
- className: I = "",
30
- ...v
31
- }) => {
32
- const o = U(null), [x, w] = $(/* @__PURE__ */ new Set());
33
- L(() => {
34
- o.current && n !== void 0 && o.current.innerHTML !== n && (o.current.innerHTML = n);
35
- }, [n]), L(() => {
36
- o.current && u && !n && (o.current.innerHTML = u);
1
+ import { jsxs as me, jsx as t } from "react/jsx-runtime";
2
+ import { useRef as pe, useState as C, useEffect as _, useCallback as d } from "react";
3
+ import { cn as b } from "../../utils/cn.js";
4
+ import { getActiveFormats as be, queryCommandValue as Re, execCommand as u, insertLink as Te, setTextColor as x, setHighlightColor as S, fileToDataUrl as v, insertImage as A } from "./helpers/formatHelpers.js";
5
+ import { RICH_EDITOR_MIN_HEIGHT as ye, RICH_EDITOR_DEFAULT_TOOLBAR as _e, RICH_EDITOR_CONTENT_STYLES as Ee, RICH_EDITOR_BUTTON_CONFIG as O, RICH_EDITOR_TOOLBAR_CLASSES as Le, RICH_EDITOR_CONTENT_CLASSES as ze, RICH_EDITOR_ROOT_CLASSES as He, RICH_EDITOR_DIVIDER_CLASSES as ke, RICH_EDITOR_HEADING_OPTIONS as xe } from "./RichEditor.const.js";
6
+ import { ToolbarButton as f } from "./components/ToolbarButton/ToolbarButton.js";
7
+ import { ToolbarDropdown as Se } from "./components/ToolbarDropdown/ToolbarDropdown.js";
8
+ import { ToolbarColorPicker as D } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
9
+ import { ToolbarMore as ve } from "./components/ToolbarMore/ToolbarMore.js";
10
+ import { TextIcon as Ae, InsertLinkIcon as B, InsertPhotoIcon as F, AlignLeftIcon as N, AlignCenterIcon as w, AlignRightIcon as U, AlignJustifyIcon as M, IndentIncreaseIcon as V, IndentDecreaseIcon as j, FormatClearIcon as J, TableIcon as Oe, CodeIcon as De, QuoteIcon as Be, ListNumberedIcon as Fe, ListBulletIcon as Ne, Heading3Icon as we, Heading2Icon as Ue, Heading1Icon as Me, StrikethroughIcon as Ve, UnderlineIcon as je, ItalicIcon as Je, BoldIcon as Pe } from "../Icon/icons/editor.js";
11
+ const qe = 6, nt = (P) => {
12
+ const {
13
+ value: I,
14
+ defaultValue: E = "",
15
+ onChange: R,
16
+ placeholder: q = "Start typing...",
17
+ disabled: i = !1,
18
+ readOnly: o = !1,
19
+ minHeight: T = ye,
20
+ maxHeight: m,
21
+ toolbar: L = _e,
22
+ className: G = "",
23
+ testId: $,
24
+ id: Y,
25
+ allowImagePaste: z = !0,
26
+ ...K
27
+ } = P, a = pe(null), [Q, W] = C(/* @__PURE__ */ new Set()), [X, H] = C("p"), [Z, ee] = C("#000000"), [te, ne] = C("#fef08a"), [ie, oe] = C([]), [re, le] = C([]);
28
+ _(() => {
29
+ const e = "bear-rich-editor-styles";
30
+ if (!document.getElementById(e)) {
31
+ const n = document.createElement("style");
32
+ n.id = e, n.textContent = Ee, document.head.appendChild(n);
33
+ }
34
+ }, []), _(() => {
35
+ a.current && I !== void 0 && a.current.innerHTML !== I && (a.current.innerHTML = I);
36
+ }, [I]), _(() => {
37
+ a.current && E && !I && (a.current.innerHTML = E);
37
38
  }, []);
38
- const c = m(() => {
39
- const e = /* @__PURE__ */ new Set();
40
- d("bold") && e.add("bold"), d("italic") && e.add("italic"), d("underline") && e.add("underline"), d("strikeThrough") && e.add("strikethrough"), d("insertUnorderedList") && e.add("bulletList"), d("insertOrderedList") && e.add("orderedList"), w(e);
41
- }, []), g = m(() => {
42
- o.current && s && s(o.current.innerHTML), c();
43
- }, [s, c]), B = m((e) => {
44
- var a;
45
- if (!(i || b)) {
46
- switch ((a = o.current) == null || a.focus(), e) {
47
- case "bold":
48
- t("bold");
49
- break;
50
- case "italic":
51
- t("italic");
52
- break;
53
- case "underline":
54
- t("underline");
55
- break;
56
- case "strikethrough":
57
- t("strikeThrough");
58
- break;
59
- case "heading1":
60
- t("formatBlock", "<h1>");
61
- break;
62
- case "heading2":
63
- t("formatBlock", "<h2>");
64
- break;
65
- case "heading3":
66
- t("formatBlock", "<h3>");
67
- break;
68
- case "bulletList":
69
- t("insertUnorderedList");
70
- break;
71
- case "orderedList":
72
- t("insertOrderedList");
73
- break;
74
- case "blockquote":
75
- t("formatBlock", "<blockquote>");
76
- break;
77
- case "code":
78
- t("formatBlock", "<pre>");
79
- break;
80
- case "link":
81
- const p = prompt("Enter URL:");
82
- p && t("createLink", p);
83
- break;
39
+ const h = d(() => {
40
+ W(be());
41
+ const e = Re("formatBlock");
42
+ e && H(e.toLowerCase().replace(/[<>]/g, ""));
43
+ }, []), l = d(() => {
44
+ a.current && R && R(a.current.innerHTML), h();
45
+ }, [R, h]), ae = d((e) => {
46
+ var s;
47
+ if (i || o) return;
48
+ (s = a.current) == null || s.focus();
49
+ const n = O[e];
50
+ if (!n) return;
51
+ const c = "value" in n ? n.value : void 0;
52
+ c ? u(n.command, c) : u(n.command), h(), l();
53
+ }, [i, o, h, l]), se = d((e) => {
54
+ var n;
55
+ i || o || ((n = a.current) == null || n.focus(), u("formatBlock", e), H(e), l());
56
+ }, [i, o, l]), ce = d(() => {
57
+ var s;
58
+ if (i || o) return;
59
+ const e = window.getSelection(), n = e && e.toString().length > 0, c = prompt("Enter URL:", n ? "" : "https://");
60
+ c && ((s = a.current) == null || s.focus(), Te(c), l());
61
+ }, [i, o, l]), p = d((e, n) => {
62
+ if (!e) return;
63
+ (n === "text" ? oe : le)((s) => {
64
+ const r = s.filter((g) => g !== e);
65
+ return [e, ...r].slice(0, qe);
66
+ });
67
+ }, []), de = d((e) => {
68
+ var n;
69
+ i || o || ((n = a.current) == null || n.focus(), x(e), ee(e), p(e, "text"), l());
70
+ }, [i, o, l, p]), ue = d((e) => {
71
+ var n;
72
+ i || o || ((n = a.current) == null || n.focus(), S(e), ne(e), p(e, "highlight"), l());
73
+ }, [i, o, l, p]), fe = d((e) => {
74
+ var n;
75
+ i || o || ((n = a.current) == null || n.focus(), x(e), l());
76
+ }, [i, o, l]), ge = d((e) => {
77
+ var n;
78
+ i || o || ((n = a.current) == null || n.focus(), S(e), l());
79
+ }, [i, o, l]), he = d(async (e) => {
80
+ var c;
81
+ if (!z) return;
82
+ const n = (c = e.clipboardData) == null ? void 0 : c.items;
83
+ if (n)
84
+ for (let s = 0; s < n.length; s++) {
85
+ const r = n[s];
86
+ if (r.type.startsWith("image/")) {
87
+ e.preventDefault();
88
+ const g = r.getAsFile();
89
+ if (g) {
90
+ const y = await v(g);
91
+ A(y), l();
92
+ }
93
+ return;
94
+ }
84
95
  }
85
- c(), g();
86
- }
87
- }, [i, b, c, g]), T = (e, a) => {
96
+ }, [z, l]), Ce = d(() => {
97
+ if (i || o) return;
98
+ const e = document.createElement("input");
99
+ e.type = "file", e.accept = "image/*", e.onchange = async (n) => {
100
+ var s, r;
101
+ const c = (s = n.target.files) == null ? void 0 : s[0];
102
+ if (c) {
103
+ const g = await v(c);
104
+ (r = a.current) == null || r.focus(), A(g), l();
105
+ }
106
+ }, e.click();
107
+ }, [i, o, l]), Ie = {
108
+ bold: /* @__PURE__ */ t(Pe, { size: 16 }),
109
+ italic: /* @__PURE__ */ t(Je, { size: 16 }),
110
+ underline: /* @__PURE__ */ t(je, { size: 16 }),
111
+ strikethrough: /* @__PURE__ */ t(Ve, { size: 16 }),
112
+ heading1: /* @__PURE__ */ t(Me, { size: 16 }),
113
+ heading2: /* @__PURE__ */ t(Ue, { size: 16 }),
114
+ heading3: /* @__PURE__ */ t(we, { size: 16 }),
115
+ bulletList: /* @__PURE__ */ t(Ne, { size: 16 }),
116
+ orderedList: /* @__PURE__ */ t(Fe, { size: 16 }),
117
+ blockquote: /* @__PURE__ */ t(Be, { size: 16 }),
118
+ code: /* @__PURE__ */ t(De, { size: 16 }),
119
+ link: /* @__PURE__ */ t(B, { size: 16 }),
120
+ alignLeft: /* @__PURE__ */ t(N, { size: 16 }),
121
+ alignCenter: /* @__PURE__ */ t(w, { size: 16 }),
122
+ alignRight: /* @__PURE__ */ t(U, { size: 16 }),
123
+ alignJustify: /* @__PURE__ */ t(M, { size: 16 }),
124
+ image: /* @__PURE__ */ t(F, { size: 16 }),
125
+ indent: /* @__PURE__ */ t(V, { size: 16 }),
126
+ outdent: /* @__PURE__ */ t(j, { size: 16 }),
127
+ clearFormat: /* @__PURE__ */ t(J, { size: 16 }),
128
+ table: /* @__PURE__ */ t(Oe, { size: 16 })
129
+ }, k = (e, n) => {
88
130
  if (e === "divider")
89
- return /* @__PURE__ */ r("div", { className: "w-px h-5 bg-gray-300 dark:bg-gray-600 mx-1" }, `divider-${a}`);
90
- const h = {
91
- bold: { icon: /* @__PURE__ */ r(D, {}), title: "Bold" },
92
- italic: { icon: /* @__PURE__ */ r(O, {}), title: "Italic" },
93
- underline: { icon: /* @__PURE__ */ r(j, {}), title: "Underline" },
94
- strikethrough: { icon: /* @__PURE__ */ r(H, {}), title: "Strikethrough" },
95
- heading1: { icon: /* @__PURE__ */ r(C, {}), title: "Heading 1" },
96
- heading2: { icon: /* @__PURE__ */ r(A, {}), title: "Heading 2" },
97
- bulletList: { icon: /* @__PURE__ */ r(R, {}), title: "Bullet List" },
98
- orderedList: { icon: /* @__PURE__ */ r(M, {}), title: "Numbered List" },
99
- blockquote: { icon: /* @__PURE__ */ r(F, {}), title: "Quote" },
100
- code: { icon: /* @__PURE__ */ r(E, {}), title: "Code Block" },
101
- link: { icon: /* @__PURE__ */ r(q, {}), title: "Insert Link" }
102
- }[e];
103
- return h ? /* @__PURE__ */ r(
104
- K,
131
+ return /* @__PURE__ */ t("div", { className: b("Bear-RichEditor__divider", ke) }, `divider-${n}`);
132
+ if (e === "headingDropdown")
133
+ return /* @__PURE__ */ t(
134
+ Se,
135
+ {
136
+ options: xe,
137
+ value: X,
138
+ onChange: se,
139
+ title: "Text Style",
140
+ disabled: i || o,
141
+ icon: /* @__PURE__ */ t(Ae, { size: 16 })
142
+ },
143
+ "heading-dropdown"
144
+ );
145
+ if (e === "textColor")
146
+ return /* @__PURE__ */ t(
147
+ D,
148
+ {
149
+ value: Z,
150
+ onChange: de,
151
+ title: "Text Color",
152
+ disabled: i || o,
153
+ type: "text",
154
+ recentColors: ie,
155
+ onApplyLast: fe
156
+ },
157
+ "text-color"
158
+ );
159
+ if (e === "highlightColor")
160
+ return /* @__PURE__ */ t(
161
+ D,
162
+ {
163
+ value: te,
164
+ onChange: ue,
165
+ title: "Highlight Color",
166
+ disabled: i || o,
167
+ type: "highlight",
168
+ recentColors: re,
169
+ onApplyLast: ge
170
+ },
171
+ "highlight-color"
172
+ );
173
+ if (e === "link")
174
+ return /* @__PURE__ */ t(
175
+ f,
176
+ {
177
+ icon: /* @__PURE__ */ t(B, { size: 16 }),
178
+ title: "Insert Link",
179
+ onClick: ce,
180
+ disabled: i || o
181
+ },
182
+ "link"
183
+ );
184
+ if (e === "image")
185
+ return /* @__PURE__ */ t(
186
+ f,
187
+ {
188
+ icon: /* @__PURE__ */ t(F, { size: 16 }),
189
+ title: "Insert Image",
190
+ onClick: Ce,
191
+ disabled: i || o
192
+ },
193
+ "image"
194
+ );
195
+ if (e === "alignLeft")
196
+ return /* @__PURE__ */ t(
197
+ f,
198
+ {
199
+ icon: /* @__PURE__ */ t(N, { size: 16 }),
200
+ title: "Align Left",
201
+ onClick: () => {
202
+ var r;
203
+ (r = a.current) == null || r.focus(), u("justifyLeft"), l();
204
+ },
205
+ disabled: i || o
206
+ },
207
+ "alignLeft"
208
+ );
209
+ if (e === "alignCenter")
210
+ return /* @__PURE__ */ t(
211
+ f,
212
+ {
213
+ icon: /* @__PURE__ */ t(w, { size: 16 }),
214
+ title: "Align Center",
215
+ onClick: () => {
216
+ var r;
217
+ (r = a.current) == null || r.focus(), u("justifyCenter"), l();
218
+ },
219
+ disabled: i || o
220
+ },
221
+ "alignCenter"
222
+ );
223
+ if (e === "alignRight")
224
+ return /* @__PURE__ */ t(
225
+ f,
226
+ {
227
+ icon: /* @__PURE__ */ t(U, { size: 16 }),
228
+ title: "Align Right",
229
+ onClick: () => {
230
+ var r;
231
+ (r = a.current) == null || r.focus(), u("justifyRight"), l();
232
+ },
233
+ disabled: i || o
234
+ },
235
+ "alignRight"
236
+ );
237
+ if (e === "alignJustify")
238
+ return /* @__PURE__ */ t(
239
+ f,
240
+ {
241
+ icon: /* @__PURE__ */ t(M, { size: 16 }),
242
+ title: "Justify",
243
+ onClick: () => {
244
+ var r;
245
+ (r = a.current) == null || r.focus(), u("justifyFull"), l();
246
+ },
247
+ disabled: i || o
248
+ },
249
+ "alignJustify"
250
+ );
251
+ if (e === "indent")
252
+ return /* @__PURE__ */ t(
253
+ f,
254
+ {
255
+ icon: /* @__PURE__ */ t(V, { size: 16 }),
256
+ title: "Increase Indent",
257
+ onClick: () => {
258
+ var r;
259
+ (r = a.current) == null || r.focus(), u("indent"), l();
260
+ },
261
+ disabled: i || o
262
+ },
263
+ "indent"
264
+ );
265
+ if (e === "outdent")
266
+ return /* @__PURE__ */ t(
267
+ f,
268
+ {
269
+ icon: /* @__PURE__ */ t(j, { size: 16 }),
270
+ title: "Decrease Indent",
271
+ onClick: () => {
272
+ var r;
273
+ (r = a.current) == null || r.focus(), u("outdent"), l();
274
+ },
275
+ disabled: i || o
276
+ },
277
+ "outdent"
278
+ );
279
+ if (e === "clearFormat")
280
+ return /* @__PURE__ */ t(
281
+ f,
282
+ {
283
+ icon: /* @__PURE__ */ t(J, { size: 16 }),
284
+ title: "Clear Formatting",
285
+ onClick: () => {
286
+ var r;
287
+ (r = a.current) == null || r.focus(), u("removeFormat"), l();
288
+ },
289
+ disabled: i || o
290
+ },
291
+ "clearFormat"
292
+ );
293
+ if (e === "more")
294
+ return /* @__PURE__ */ t(ve, { disabled: i || o, children: [
295
+ "alignLeft",
296
+ "alignCenter",
297
+ "alignRight",
298
+ "alignJustify",
299
+ "indent",
300
+ "outdent",
301
+ "blockquote",
302
+ "code",
303
+ "clearFormat"
304
+ ].map((g, y) => k(g, y + 1e3)) }, "more");
305
+ const c = O[e], s = Ie[e];
306
+ return !c || !s ? null : /* @__PURE__ */ t(
307
+ f,
105
308
  {
106
- icon: h.icon,
107
- title: h.title,
108
- active: x.has(e),
109
- onClick: () => B(e),
110
- disabled: i || b
309
+ icon: s,
310
+ title: c.title,
311
+ active: Q.has(e),
312
+ onClick: () => ae(e),
313
+ disabled: i || o
111
314
  },
112
315
  e
113
- ) : null;
316
+ );
114
317
  };
115
- return /* @__PURE__ */ S(
318
+ return /* @__PURE__ */ me(
116
319
  "div",
117
320
  {
118
- className: `bear-rich-editor rounded-lg border border-gray-300 dark:border-gray-600 overflow-hidden bg-white dark:bg-gray-900 ${I}`,
119
- ...v,
321
+ id: Y,
322
+ "data-testid": $,
323
+ className: b(
324
+ "Bear-RichEditor",
325
+ He,
326
+ i && "Bear-RichEditor--disabled",
327
+ o && "Bear-RichEditor--readonly",
328
+ G
329
+ ),
330
+ ...K,
120
331
  children: [
121
- y.length > 0 && /* @__PURE__ */ r("div", { className: "bear-rich-editor-toolbar flex flex-wrap items-center gap-0.5 p-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800", children: y.map((e, a) => T(e, a)) }),
122
- /* @__PURE__ */ r(
332
+ L.length > 0 && /* @__PURE__ */ t("div", { className: b("Bear-RichEditor__toolbar", Le), children: L.map((e, n) => k(e, n)) }),
333
+ /* @__PURE__ */ t(
123
334
  "div",
124
335
  {
125
- ref: o,
126
- contentEditable: !i && !b,
127
- onInput: g,
128
- onSelect: c,
129
- onKeyUp: c,
130
- onMouseUp: c,
131
- "data-placeholder": k,
132
- className: `
133
- bear-rich-editor-content p-3 outline-none prose prose-sm dark:prose-invert max-w-none
134
- text-gray-900 dark:text-white
135
- [&:empty]:before:content-[attr(data-placeholder)] [&:empty]:before:text-gray-400 [&:empty]:before:pointer-events-none
136
- ${i ? "opacity-50 cursor-not-allowed" : ""}
137
- `,
336
+ ref: a,
337
+ contentEditable: !i && !o,
338
+ onInput: l,
339
+ onSelect: h,
340
+ onKeyUp: h,
341
+ onMouseUp: h,
342
+ onPaste: he,
343
+ "data-placeholder": q,
344
+ className: b(
345
+ "Bear-RichEditor__content",
346
+ ze,
347
+ "[&:empty]:before:bear-content-[attr(data-placeholder)] [&:empty]:before:bear-text-gray-400 [&:empty]:before:bear-pointer-events-none",
348
+ i && "Bear-RichEditor__content--disabled bear-opacity-50 bear-cursor-not-allowed"
349
+ ),
138
350
  style: {
139
- minHeight: typeof f == "number" ? `${f}px` : f,
140
- maxHeight: l ? typeof l == "number" ? `${l}px` : l : void 0,
141
- overflowY: l ? "auto" : void 0
351
+ minHeight: typeof T == "number" ? `${T}px` : T,
352
+ maxHeight: m ? typeof m == "number" ? `${m}px` : m : void 0,
353
+ overflowY: m ? "auto" : void 0
142
354
  }
143
355
  }
144
356
  )
@@ -147,5 +359,5 @@ const K = ({ icon: n, title: u, active: s, onClick: k, disabled: i }) => /* @__P
147
359
  );
148
360
  };
149
361
  export {
150
- G as RichEditor
362
+ nt as RichEditor
151
363
  };
@@ -1,16 +1,31 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
2
  export interface RichEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
3
+ /** Controlled HTML content */
3
4
  value?: string;
5
+ /** Initial HTML content (uncontrolled) */
4
6
  defaultValue?: string;
7
+ /** Called when content changes */
5
8
  onChange?: (value: string) => void;
9
+ /** Placeholder text when empty */
6
10
  placeholder?: string;
11
+ /** Completely disables the editor */
7
12
  disabled?: boolean;
13
+ /** Allows viewing but not editing */
8
14
  readOnly?: boolean;
15
+ /** Minimum editor height in pixels */
9
16
  minHeight?: string | number;
17
+ /** Maximum height (enables scroll) */
10
18
  maxHeight?: string | number;
19
+ /** Toolbar buttons to display */
11
20
  toolbar?: ToolbarOption[];
21
+ /** Test ID for testing purposes */
22
+ testId?: string;
23
+ /** Unique ID for accessibility */
24
+ id?: string;
25
+ /** Enable image paste support */
26
+ allowImagePaste?: boolean;
12
27
  }
13
- export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'divider';
28
+ export type ToolbarOption = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'paragraph' | 'headingDropdown' | 'bulletList' | 'orderedList' | 'blockquote' | 'code' | 'link' | 'image' | 'textColor' | 'highlightColor' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'indent' | 'outdent' | 'clearFormat' | 'table' | 'divider' | 'more';
14
29
  export interface ToolbarButtonProps {
15
30
  icon: ReactNode;
16
31
  title: string;
@@ -18,3 +33,25 @@ export interface ToolbarButtonProps {
18
33
  onClick: () => void;
19
34
  disabled?: boolean;
20
35
  }
36
+ export interface DropdownOption {
37
+ value: string;
38
+ label: string;
39
+ preview?: ReactNode;
40
+ }
41
+ export interface ToolbarDropdownProps {
42
+ options: DropdownOption[];
43
+ value: string;
44
+ onChange: (value: string) => void;
45
+ title: string;
46
+ disabled?: boolean;
47
+ icon?: ReactNode;
48
+ }
49
+ export interface ToolbarColorPickerProps {
50
+ value: string;
51
+ onChange: (color: string) => void;
52
+ title: string;
53
+ disabled?: boolean;
54
+ type?: 'text' | 'highlight';
55
+ recentColors?: string[];
56
+ onApplyLast?: (color: string) => void;
57
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),T=require("../../../../utils/cn.cjs"),t=require("../../RichEditor.const.cjs"),E=e=>{const{icon:i,title:_,active:n,onClick:r,disabled:o}=e;return c.jsx("button",{type:"button",title:_,onClick:r,disabled:o,className:T.cn("Bear-RichEditor__button",t.RICH_EDITOR_BUTTON_BASE_CLASSES,n?`Bear-RichEditor__button--active ${t.RICH_EDITOR_BUTTON_ACTIVE_CLASSES}`:t.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,o&&`Bear-RichEditor__button--disabled ${t.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:i})};exports.ToolbarButton=E;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ToolbarButtonProps } from '../../RichEditor.types';
3
+ export declare const ToolbarButton: FC<ToolbarButtonProps>;
4
+ export default ToolbarButton;
@@ -0,0 +1,25 @@
1
+ import { jsx as T } from "react/jsx-runtime";
2
+ import { cn as S } from "../../../../utils/cn.js";
3
+ import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as e, RICH_EDITOR_BUTTON_ACTIVE_CLASSES as n, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as c, RICH_EDITOR_BUTTON_BASE_CLASSES as I } from "../../RichEditor.const.js";
4
+ const B = (o) => {
5
+ const { icon: _, title: i, active: r, onClick: E, disabled: t } = o;
6
+ return /* @__PURE__ */ T(
7
+ "button",
8
+ {
9
+ type: "button",
10
+ title: i,
11
+ onClick: E,
12
+ disabled: t,
13
+ className: S(
14
+ "Bear-RichEditor__button",
15
+ I,
16
+ r ? `Bear-RichEditor__button--active ${n}` : c,
17
+ t && `Bear-RichEditor__button--disabled ${e}`
18
+ ),
19
+ children: _
20
+ }
21
+ );
22
+ };
23
+ export {
24
+ B as ToolbarButton
25
+ };
@@ -0,0 +1 @@
1
+ export { ToolbarButton, default } from './ToolbarButton';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),g=require("react"),s=require("../../../../utils/cn.cjs"),i=require("../../RichEditor.const.cjs"),m=require("../../../Icon/icons/editor.cjs"),_=require("../../../Icon/icons/status.cjs"),C=p=>{const{value:r,onChange:f,title:y,disabled:o,type:n="text",recentColors:a=[],onApplyLast:h}=p,[b,c]=g.useState(!1),l=g.useRef(null);g.useEffect(()=>{const e=u=>{l.current&&!l.current.contains(u.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const d=e=>{f(e),c(!1)},k=n==="text"?m.FormatColorTextIcon:m.HighlightIcon,x=a[0]||r;return t.jsxs("div",{ref:l,className:"Bear-RichEditor__color-picker relative flex items-center",children:[t.jsxs("button",{type:"button",title:y,disabled:o,onClick:()=>c(!b),className:s.cn("Bear-RichEditor__color-trigger",i.RICH_EDITOR_BUTTON_BASE_CLASSES,i.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center gap-0.5",o&&`Bear-RichEditor__color-trigger--disabled ${i.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:[t.jsx(k,{size:16}),t.jsx("span",{className:"w-3 h-1 rounded-sm mt-0.5",style:{backgroundColor:r||(n==="text"?"#000000":"#fef08a")}})]}),x&&h&&t.jsx("button",{type:"button",title:`Apply ${n==="text"?"text":"highlight"} color`,disabled:o,onClick:()=>h(x),className:s.cn("Bear-RichEditor__color-apply","p-0.5 rounded transition-colors","text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-zinc-700",o&&"opacity-50 cursor-not-allowed"),children:t.jsx(_.CheckIcon,{size:12})}),b&&t.jsxs("div",{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]",style:{zIndex:9999},children:[a.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:"Recent"}),t.jsx("div",{className:"flex gap-1",children:a.slice(0,6).map((e,u)=>t.jsx("button",{type:"button",onClick:()=>d(e),className:s.cn("w-6 h-6 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",r===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},`recent-${u}`))})]}),t.jsx("div",{className:"grid grid-cols-8 gap-1",children:i.RICH_EDITOR_COLORS.map(e=>t.jsx("button",{type:"button",onClick:()=>d(e),className:s.cn("Bear-RichEditor__color-swatch","w-5 h-5 rounded-full border border-gray-300 dark:border-zinc-600 transition-transform hover:scale-110",r===e&&"ring-2 ring-pink-500 ring-offset-1 dark:ring-offset-zinc-800"),style:{backgroundColor:e},title:e},e))}),t.jsxs("button",{type:"button",onClick:()=>d(""),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",children:["Remove ",n==="text"?"color":"highlight"]})]})]})};exports.ToolbarColorPicker=C;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ToolbarColorPickerProps } from '../../RichEditor.types';
3
+ export declare const ToolbarColorPicker: FC<ToolbarColorPickerProps>;
4
+ export default ToolbarColorPicker;