@hellboy/ds 0.1.3 → 0.2.7

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 (298) hide show
  1. package/README.md +512 -162
  2. package/{src/style/components/badge → dist/components}/badge.css +9 -25
  3. package/dist/components/badge.d.mts +12 -0
  4. package/dist/components/badge.d.ts +12 -0
  5. package/dist/components/badge.js +42 -0
  6. package/dist/components/badge.mjs +15 -0
  7. package/dist/components/banner.css +280 -0
  8. package/dist/components/banner.d.mts +12 -0
  9. package/dist/components/banner.d.ts +12 -0
  10. package/dist/components/banner.js +184 -0
  11. package/dist/components/banner.mjs +147 -0
  12. package/dist/components/button-group.css +289 -0
  13. package/dist/components/button-group.d.mts +81 -0
  14. package/dist/components/button-group.d.ts +81 -0
  15. package/dist/components/button-group.js +180 -0
  16. package/dist/components/button-group.mjs +143 -0
  17. package/{src/style/components/button → dist/components}/button.css +59 -62
  18. package/dist/components/button.d.mts +57 -0
  19. package/dist/components/button.d.ts +57 -0
  20. package/dist/components/button.js +129 -0
  21. package/dist/components/button.mjs +92 -0
  22. package/{src/style/components/card → dist/components}/card.css +9 -30
  23. package/dist/components/card.d.mts +31 -0
  24. package/dist/components/card.d.ts +31 -0
  25. package/dist/components/card.js +59 -0
  26. package/dist/components/card.mjs +32 -0
  27. package/{src/style → dist}/components/checkbox.css +51 -43
  28. package/dist/components/checkbox.d.mts +31 -0
  29. package/dist/components/checkbox.d.ts +31 -0
  30. package/dist/components/checkbox.js +130 -0
  31. package/dist/components/checkbox.mjs +93 -0
  32. package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
  33. package/dist/components/code-block.d.mts +24 -0
  34. package/dist/components/code-block.d.ts +24 -0
  35. package/dist/components/code-block.js +43 -0
  36. package/dist/components/code-block.mjs +16 -0
  37. package/dist/components/color-control.css +285 -0
  38. package/dist/components/color-control.d.mts +5 -0
  39. package/dist/components/color-control.d.ts +5 -0
  40. package/dist/components/color-control.js +534 -0
  41. package/dist/components/color-control.mjs +497 -0
  42. package/dist/components/dialog.css +930 -0
  43. package/dist/components/dialog.d.mts +32 -0
  44. package/dist/components/dialog.d.ts +32 -0
  45. package/dist/components/dialog.js +1111 -0
  46. package/dist/components/dialog.mjs +1074 -0
  47. package/dist/components/divider.css +356 -0
  48. package/dist/components/divider.d.mts +32 -0
  49. package/dist/components/divider.d.ts +32 -0
  50. package/dist/components/divider.js +344 -0
  51. package/dist/components/divider.mjs +307 -0
  52. package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
  53. package/dist/components/drag-handle.d.mts +11 -0
  54. package/dist/components/drag-handle.d.ts +11 -0
  55. package/dist/components/drag-handle.js +103 -0
  56. package/dist/components/drag-handle.mjs +66 -0
  57. package/dist/components/drawer.css +1027 -0
  58. package/dist/components/drawer.d.mts +14 -0
  59. package/dist/components/drawer.d.ts +14 -0
  60. package/dist/components/drawer.js +1072 -0
  61. package/dist/components/drawer.mjs +1035 -0
  62. package/dist/components/floating-bar.css +17 -0
  63. package/dist/components/floating-bar.d.mts +25 -0
  64. package/dist/components/floating-bar.d.ts +25 -0
  65. package/dist/components/floating-bar.js +52 -0
  66. package/dist/components/floating-bar.mjs +25 -0
  67. package/dist/components/footer.css +40 -0
  68. package/dist/components/footer.d.mts +8 -0
  69. package/dist/components/footer.d.ts +8 -0
  70. package/dist/components/footer.js +44 -0
  71. package/dist/components/footer.mjs +17 -0
  72. package/dist/components/grid.css +47 -0
  73. package/dist/components/grid.d.mts +27 -0
  74. package/dist/components/grid.d.ts +27 -0
  75. package/dist/components/grid.js +52 -0
  76. package/dist/components/grid.mjs +25 -0
  77. package/dist/components/header.css +1075 -0
  78. package/dist/components/header.d.mts +35 -0
  79. package/dist/components/header.d.ts +35 -0
  80. package/dist/components/header.js +1402 -0
  81. package/dist/components/header.mjs +1365 -0
  82. package/dist/components/hero.css +121 -0
  83. package/dist/components/hero.d.mts +111 -0
  84. package/dist/components/hero.d.ts +111 -0
  85. package/dist/components/hero.js +285 -0
  86. package/dist/components/hero.mjs +248 -0
  87. package/{src/style/components/icons → dist/components}/icons.css +14 -15
  88. package/dist/components/icons.d.mts +104 -0
  89. package/dist/components/icons.d.ts +104 -0
  90. package/dist/components/icons.js +239 -0
  91. package/dist/components/icons.mjs +203 -0
  92. package/{src/style/components/input → dist/components}/input.css +189 -102
  93. package/dist/components/input.d.mts +114 -0
  94. package/dist/components/input.d.ts +114 -0
  95. package/dist/components/input.js +926 -0
  96. package/dist/components/input.mjs +879 -0
  97. package/dist/components/layout.css +551 -0
  98. package/dist/components/layout.d.mts +16 -0
  99. package/dist/components/layout.d.ts +16 -0
  100. package/dist/components/layout.js +387 -0
  101. package/dist/components/layout.mjs +352 -0
  102. package/{src/style/components/list → dist/components}/list.css +47 -41
  103. package/dist/components/list.d.mts +46 -0
  104. package/dist/components/list.d.ts +46 -0
  105. package/dist/components/list.js +124 -0
  106. package/dist/components/list.mjs +96 -0
  107. package/dist/components/navbar.css +706 -0
  108. package/dist/components/navbar.d.mts +56 -0
  109. package/dist/components/navbar.d.ts +56 -0
  110. package/dist/components/navbar.js +994 -0
  111. package/dist/components/navbar.mjs +952 -0
  112. package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
  113. package/dist/components/page-index.d.mts +25 -0
  114. package/dist/components/page-index.d.ts +25 -0
  115. package/dist/components/page-index.js +239 -0
  116. package/dist/components/page-index.mjs +202 -0
  117. package/{src/style/components/page → dist/components}/page.css +4 -15
  118. package/dist/components/page.d.mts +30 -0
  119. package/dist/components/page.d.ts +30 -0
  120. package/dist/components/page.js +40 -0
  121. package/dist/components/page.mjs +13 -0
  122. package/dist/components/popover.css +87 -0
  123. package/dist/components/popover.d.mts +22 -0
  124. package/dist/components/popover.d.ts +22 -0
  125. package/dist/components/popover.js +243 -0
  126. package/dist/components/popover.mjs +206 -0
  127. package/{src/style → dist}/components/radio.css +8 -51
  128. package/dist/components/radio.d.mts +59 -0
  129. package/dist/components/radio.d.ts +59 -0
  130. package/dist/components/radio.js +133 -0
  131. package/dist/components/radio.mjs +95 -0
  132. package/dist/components/section.css +993 -0
  133. package/dist/components/section.d.mts +33 -0
  134. package/dist/components/section.d.ts +33 -0
  135. package/dist/components/section.js +1401 -0
  136. package/dist/components/section.mjs +1364 -0
  137. package/dist/components/select.css +391 -0
  138. package/dist/components/select.d.mts +63 -0
  139. package/dist/components/select.d.ts +63 -0
  140. package/dist/components/select.js +452 -0
  141. package/dist/components/select.mjs +415 -0
  142. package/{src/style/components/slider → dist/components}/slider.css +55 -33
  143. package/dist/components/slider.d.mts +69 -0
  144. package/dist/components/slider.d.ts +69 -0
  145. package/dist/components/slider.js +254 -0
  146. package/dist/components/slider.mjs +217 -0
  147. package/dist/components/switch.css +1081 -0
  148. package/dist/components/switch.d.mts +33 -0
  149. package/dist/components/switch.d.ts +33 -0
  150. package/dist/components/switch.js +1092 -0
  151. package/dist/components/switch.mjs +1055 -0
  152. package/{src/style/components/table → dist/components}/table.css +3 -28
  153. package/dist/components/table.d.mts +42 -0
  154. package/dist/components/table.d.ts +42 -0
  155. package/dist/components/table.js +108 -0
  156. package/dist/components/table.mjs +76 -0
  157. package/dist/components/tag.css +97 -0
  158. package/dist/components/tag.d.mts +12 -0
  159. package/dist/components/tag.d.ts +12 -0
  160. package/dist/components/tag.js +42 -0
  161. package/dist/components/tag.mjs +15 -0
  162. package/dist/components/textarea.css +1359 -0
  163. package/dist/components/textarea.d.mts +84 -0
  164. package/dist/components/textarea.d.ts +84 -0
  165. package/dist/components/textarea.js +1962 -0
  166. package/dist/components/textarea.mjs +1924 -0
  167. package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
  168. package/dist/components/theme-control.d.mts +9 -0
  169. package/dist/components/theme-control.d.ts +9 -0
  170. package/dist/components/theme-control.js +235 -0
  171. package/dist/components/theme-control.mjs +200 -0
  172. package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
  173. package/dist/components/tooltip.d.mts +12 -0
  174. package/dist/components/tooltip.d.ts +12 -0
  175. package/dist/components/tooltip.js +200 -0
  176. package/dist/components/tooltip.mjs +163 -0
  177. package/dist/icons-Czahnf-r.d.mts +15 -0
  178. package/dist/icons-Czahnf-r.d.ts +15 -0
  179. package/dist/index.css +2914 -2067
  180. package/dist/index.d.mts +144 -721
  181. package/dist/index.d.ts +144 -721
  182. package/dist/index.js +4076 -2282
  183. package/dist/index.mjs +4132 -2366
  184. package/dist/theme.css +34 -34
  185. package/package.json +27 -8
  186. package/dist/index.css.map +0 -1
  187. package/dist/index.js.map +0 -1
  188. package/dist/index.mjs.map +0 -1
  189. package/hellboy-ds-0.1.2.tgz +0 -0
  190. package/src/components/badge/Badge.tsx +0 -29
  191. package/src/components/badge/index.ts +0 -1
  192. package/src/components/banner/Banner.tsx +0 -48
  193. package/src/components/banner/banner.css +0 -44
  194. package/src/components/banner/index.ts +0 -1
  195. package/src/components/button/button.tsx +0 -127
  196. package/src/components/button/index.ts +0 -1
  197. package/src/components/card/card.tsx +0 -57
  198. package/src/components/card/index.ts +0 -1
  199. package/src/components/checkbox/Checkbox.tsx +0 -98
  200. package/src/components/checkbox/index.ts +0 -1
  201. package/src/components/code-block/code-block.tsx +0 -44
  202. package/src/components/code-block/index.ts +0 -1
  203. package/src/components/color-control/color-control.tsx +0 -322
  204. package/src/components/color-control/index.ts +0 -1
  205. package/src/components/drag-handle/DragHandle.tsx +0 -78
  206. package/src/components/drag-handle/index.ts +0 -1
  207. package/src/components/drawer/drawer.tsx +0 -82
  208. package/src/components/drawer/index.ts +0 -1
  209. package/src/components/floating-bar/floating-bar.tsx +0 -52
  210. package/src/components/floating-bar/index.ts +0 -2
  211. package/src/components/footer/footer.tsx +0 -28
  212. package/src/components/footer/index.ts +0 -1
  213. package/src/components/grid/Grid.tsx +0 -53
  214. package/src/components/grid/index.ts +0 -1
  215. package/src/components/header/header.tsx +0 -57
  216. package/src/components/header/index.ts +0 -1
  217. package/src/components/icons/icons.tsx +0 -44
  218. package/src/components/icons/index.ts +0 -1
  219. package/src/components/index.ts +0 -29
  220. package/src/components/input/DatePicker.tsx +0 -133
  221. package/src/components/input/Input.tsx +0 -220
  222. package/src/components/input/InputDate.tsx +0 -10
  223. package/src/components/input/InputDateTime.tsx +0 -10
  224. package/src/components/input/InputEmail.tsx +0 -10
  225. package/src/components/input/InputField.tsx +0 -137
  226. package/src/components/input/InputNumber.tsx +0 -10
  227. package/src/components/input/InputPassword.tsx +0 -10
  228. package/src/components/input/InputSearch.tsx +0 -10
  229. package/src/components/input/InputTel.tsx +0 -10
  230. package/src/components/input/InputText.tsx +0 -10
  231. package/src/components/input/InputTime.tsx +0 -10
  232. package/src/components/input/InputUrl.tsx +0 -10
  233. package/src/components/input/TimePicker.tsx +0 -151
  234. package/src/components/input/index.ts +0 -11
  235. package/src/components/layout/Layout.tsx +0 -244
  236. package/src/components/layout/index.ts +0 -1
  237. package/src/components/list/List.tsx +0 -159
  238. package/src/components/list/index.ts +0 -1
  239. package/src/components/navbar/MenuCategory.tsx +0 -20
  240. package/src/components/navbar/MenuGroup.tsx +0 -288
  241. package/src/components/navbar/MenuItem.tsx +0 -65
  242. package/src/components/navbar/Navbar.tsx +0 -23
  243. package/src/components/navbar/index.ts +0 -4
  244. package/src/components/page/index.ts +0 -1
  245. package/src/components/page/page.tsx +0 -46
  246. package/src/components/page-index/PageIndex.tsx +0 -275
  247. package/src/components/page-index/index.ts +0 -1
  248. package/src/components/popover/index.ts +0 -1
  249. package/src/components/popover/popover.tsx +0 -199
  250. package/src/components/radio/Radio.tsx +0 -176
  251. package/src/components/radio/index.ts +0 -1
  252. package/src/components/section/index.ts +0 -1
  253. package/src/components/section/section.tsx +0 -66
  254. package/src/components/select/Select.tsx +0 -212
  255. package/src/components/select/index.ts +0 -1
  256. package/src/components/slider/Slider.tsx +0 -267
  257. package/src/components/slider/index.ts +0 -1
  258. package/src/components/switch/index.ts +0 -1
  259. package/src/components/switch/switch.tsx +0 -99
  260. package/src/components/table/Table.tsx +0 -147
  261. package/src/components/table/index.ts +0 -1
  262. package/src/components/theme-control/index.ts +0 -1
  263. package/src/components/theme-control/theme-control.tsx +0 -78
  264. package/src/components/tooltip/index.ts +0 -1
  265. package/src/components/tooltip/tooltip.tsx +0 -207
  266. package/src/contexts/NavbarTooltipContext.tsx +0 -48
  267. package/src/contexts/index.ts +0 -1
  268. package/src/foundations/motion.md +0 -136
  269. package/src/index.ts +0 -40
  270. package/src/style/_shared/field.css +0 -69
  271. package/src/style/components/color-control/color-control.css +0 -126
  272. package/src/style/components/drawer/drawer.css +0 -210
  273. package/src/style/components/floating-bar/floating-bar.css +0 -39
  274. package/src/style/components/footer/footer.css +0 -108
  275. package/src/style/components/grid/grid.css +0 -33
  276. package/src/style/components/header/header.css +0 -44
  277. package/src/style/components/layout/layout.css +0 -205
  278. package/src/style/components/navbar/navbar.css +0 -342
  279. package/src/style/components/popover/popover.css +0 -44
  280. package/src/style/components/section/section.css +0 -67
  281. package/src/style/components/select/select.css +0 -143
  282. package/src/style/components/switch/switch.css +0 -267
  283. package/src/style/foundations/global.css +0 -316
  284. package/src/style/foundations/motion.css +0 -164
  285. package/src/style/foundations/spacing.css +0 -51
  286. package/src/style/foundations/typography.css +0 -39
  287. package/src/style/foundations/z-index.css +0 -81
  288. package/src/style/modes/dark.css +0 -146
  289. package/src/style/modes/light.css +0 -147
  290. package/src/style/semantic.css +0 -52
  291. package/src/style/styles.css +0 -51
  292. package/src/style/themes/theme.json +0 -37
  293. package/src/utils/README.md +0 -305
  294. package/src/utils/USER_PREFERENCES.md +0 -558
  295. package/src/utils/theme.ts +0 -127
  296. package/src/utils/user-preferences.ts +0 -577
  297. package/tsconfig.json +0 -25
  298. package/tsup.config.ts +0 -52
@@ -0,0 +1,1924 @@
1
+ // src/components/textarea/RichTextarea.tsx
2
+ import * as React22 from "react";
3
+ import DOMPurify from "dompurify";
4
+
5
+ // src/components/floating-bar/floating-bar.tsx
6
+ import { jsx } from "react/jsx-runtime";
7
+ var FloatingBar = ({
8
+ position = "bottom",
9
+ children,
10
+ className = "",
11
+ ...props
12
+ }) => {
13
+ const classes = [
14
+ "floating-bar",
15
+ `floating-bar--${position}`,
16
+ className
17
+ ].filter(Boolean).join(" ");
18
+ return /* @__PURE__ */ jsx(
19
+ "div",
20
+ {
21
+ className: classes,
22
+ ...props,
23
+ children: /* @__PURE__ */ jsx("div", { className: "floating-bar__content", children })
24
+ }
25
+ );
26
+ };
27
+
28
+ // src/components/select/Select.tsx
29
+ import * as React2 from "react";
30
+
31
+ // src/components/icons/icons.tsx
32
+ import { Icon as IconifyIcon } from "@iconify/react";
33
+ import { jsx as jsx2 } from "react/jsx-runtime";
34
+ var Icon = ({ name, size = 24, className, loading = false, ...rest }) => {
35
+ const iconName = name.includes(":") ? name : `heroicons:${name}`;
36
+ const classes = ["icon", className].filter(Boolean).join(" ");
37
+ if (loading) {
38
+ const style = { width: size, height: size };
39
+ return /* @__PURE__ */ jsx2(
40
+ "span",
41
+ {
42
+ className: `${classes} icon--skeleton`,
43
+ style,
44
+ "aria-hidden": rest["aria-label"] ? "false" : "true",
45
+ ...rest["aria-label"] ? { "aria-label": rest["aria-label"] } : {}
46
+ }
47
+ );
48
+ }
49
+ return /* @__PURE__ */ jsx2(
50
+ IconifyIcon,
51
+ {
52
+ icon: iconName,
53
+ width: size,
54
+ height: size,
55
+ className: classes,
56
+ ...rest
57
+ }
58
+ );
59
+ };
60
+
61
+ // src/components/popover/popover.tsx
62
+ import * as React from "react";
63
+ import * as ReactDOM from "react-dom";
64
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
65
+ var Popover = ({
66
+ trigger,
67
+ children,
68
+ isOpen,
69
+ onToggle,
70
+ placement = "bottom",
71
+ align = "start",
72
+ offset = 8,
73
+ flip = true,
74
+ closeOnEscape = true,
75
+ closeOnClickOutside = true
76
+ }) => {
77
+ const [internalOpen, setInternalOpen] = React.useState(false);
78
+ const triggerRef = React.useRef(null);
79
+ const popoverRef = React.useRef(null);
80
+ const [popoverStyle, setPopoverStyle] = React.useState({});
81
+ const [resolvedPlacement, setResolvedPlacement] = React.useState(placement);
82
+ const isControlled = isOpen !== void 0;
83
+ const open = isControlled ? isOpen : internalOpen;
84
+ const toggle = React.useCallback(() => {
85
+ if (isControlled) {
86
+ onToggle?.();
87
+ } else {
88
+ setInternalOpen((prev) => !prev);
89
+ }
90
+ }, [isControlled, onToggle]);
91
+ React.useEffect(() => {
92
+ const handleClickOutside = (event) => {
93
+ if (closeOnClickOutside && triggerRef.current && !triggerRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
94
+ toggle();
95
+ }
96
+ };
97
+ if (open) {
98
+ document.addEventListener("mousedown", handleClickOutside);
99
+ }
100
+ return () => {
101
+ document.removeEventListener("mousedown", handleClickOutside);
102
+ };
103
+ }, [open, toggle, closeOnClickOutside]);
104
+ React.useEffect(() => {
105
+ const handleEscapeKey = (event) => {
106
+ if (closeOnEscape && event.key === "Escape" && open) {
107
+ toggle();
108
+ }
109
+ };
110
+ if (open) {
111
+ document.addEventListener("keydown", handleEscapeKey);
112
+ }
113
+ return () => {
114
+ document.removeEventListener("keydown", handleEscapeKey);
115
+ };
116
+ }, [open, toggle, closeOnEscape]);
117
+ React.useEffect(() => {
118
+ if (!open || !triggerRef.current || !popoverRef.current) {
119
+ return;
120
+ }
121
+ const updatePosition = () => {
122
+ if (!triggerRef.current || !popoverRef.current) {
123
+ return;
124
+ }
125
+ const triggerRect = triggerRef.current.getBoundingClientRect();
126
+ const popoverRect = popoverRef.current.getBoundingClientRect();
127
+ const viewportWidth = window.innerWidth;
128
+ const viewportHeight = window.innerHeight;
129
+ const spaceTop = triggerRect.top;
130
+ const spaceBottom = viewportHeight - triggerRect.bottom;
131
+ const spaceLeft = triggerRect.left;
132
+ const spaceRight = viewportWidth - triggerRect.right;
133
+ let finalPlacement = placement;
134
+ if (flip) {
135
+ if (placement === "right" && spaceRight < popoverRect.width + offset) {
136
+ finalPlacement = spaceLeft >= popoverRect.width + offset ? "left" : "bottom";
137
+ } else if (placement === "left" && spaceLeft < popoverRect.width + offset) {
138
+ finalPlacement = spaceRight >= popoverRect.width + offset ? "right" : "bottom";
139
+ } else if (placement === "bottom" && spaceBottom < popoverRect.height + offset) {
140
+ finalPlacement = spaceTop >= popoverRect.height + offset ? "top" : "bottom";
141
+ } else if (placement === "top" && spaceTop < popoverRect.height + offset) {
142
+ finalPlacement = spaceBottom >= popoverRect.height + offset ? "bottom" : "top";
143
+ }
144
+ }
145
+ setResolvedPlacement(finalPlacement);
146
+ const newStyle = {
147
+ position: "fixed",
148
+ zIndex: "var(--z-popover)",
149
+ opacity: 1,
150
+ visibility: "visible",
151
+ pointerEvents: "auto"
152
+ };
153
+ const getAlignmentOffset = () => {
154
+ let alignmentOffset = 0;
155
+ if (finalPlacement === "left" || finalPlacement === "right") {
156
+ switch (align) {
157
+ case "center":
158
+ alignmentOffset = (triggerRect.height - popoverRect.height) / 2;
159
+ break;
160
+ case "end":
161
+ alignmentOffset = triggerRect.height - popoverRect.height;
162
+ break;
163
+ case "start":
164
+ default:
165
+ alignmentOffset = 0;
166
+ }
167
+ } else {
168
+ switch (align) {
169
+ case "center":
170
+ alignmentOffset = (triggerRect.width - popoverRect.width) / 2;
171
+ break;
172
+ case "end":
173
+ alignmentOffset = triggerRect.width - popoverRect.width;
174
+ break;
175
+ case "start":
176
+ default:
177
+ alignmentOffset = 0;
178
+ }
179
+ }
180
+ return alignmentOffset;
181
+ };
182
+ switch (finalPlacement) {
183
+ case "right":
184
+ newStyle.top = triggerRect.top + getAlignmentOffset();
185
+ newStyle.left = triggerRect.right + offset;
186
+ break;
187
+ case "left":
188
+ newStyle.top = triggerRect.top + getAlignmentOffset();
189
+ newStyle.left = triggerRect.left - popoverRect.width - offset;
190
+ break;
191
+ case "top":
192
+ newStyle.top = triggerRect.top - popoverRect.height - offset;
193
+ newStyle.left = triggerRect.left + getAlignmentOffset();
194
+ break;
195
+ case "bottom":
196
+ default:
197
+ newStyle.top = triggerRect.bottom + offset;
198
+ newStyle.left = triggerRect.left + getAlignmentOffset();
199
+ }
200
+ if (typeof newStyle.left === "number") {
201
+ if (newStyle.left + popoverRect.width > viewportWidth - offset) {
202
+ newStyle.left = viewportWidth - popoverRect.width - offset;
203
+ }
204
+ if (newStyle.left < offset) {
205
+ newStyle.left = offset;
206
+ }
207
+ }
208
+ if (typeof newStyle.top === "number") {
209
+ if (newStyle.top + popoverRect.height > viewportHeight - offset) {
210
+ newStyle.top = viewportHeight - popoverRect.height - offset;
211
+ }
212
+ if (newStyle.top < offset) {
213
+ newStyle.top = offset;
214
+ }
215
+ }
216
+ setPopoverStyle(newStyle);
217
+ };
218
+ requestAnimationFrame(updatePosition);
219
+ window.addEventListener("resize", updatePosition);
220
+ window.addEventListener("scroll", updatePosition, true);
221
+ return () => {
222
+ window.removeEventListener("resize", updatePosition);
223
+ window.removeEventListener("scroll", updatePosition, true);
224
+ };
225
+ }, [open, placement, align, offset, flip]);
226
+ const handleTriggerClick = React.useCallback(() => {
227
+ toggle();
228
+ }, [toggle]);
229
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
230
+ /* @__PURE__ */ jsx3(
231
+ "div",
232
+ {
233
+ ref: triggerRef,
234
+ onClick: handleTriggerClick,
235
+ style: { display: "inline-block", position: "relative" },
236
+ children: React.isValidElement(trigger) ? React.cloneElement(trigger, {
237
+ onClick: (e) => {
238
+ e.stopPropagation();
239
+ handleTriggerClick();
240
+ trigger.props?.onClick?.(e);
241
+ }
242
+ }) : trigger
243
+ }
244
+ ),
245
+ open && ReactDOM.createPortal(
246
+ /* @__PURE__ */ jsx3(
247
+ "div",
248
+ {
249
+ ref: popoverRef,
250
+ className: `popover popover--${resolvedPlacement}`,
251
+ style: {
252
+ ...popoverStyle,
253
+ // Start with opacity 0 and visibility hidden to prevent initial flash
254
+ opacity: popoverStyle.top !== void 0 ? 1 : 0,
255
+ visibility: popoverStyle.top !== void 0 ? "visible" : "hidden"
256
+ },
257
+ children: /* @__PURE__ */ jsx3("div", { className: "popover__content", children })
258
+ }
259
+ ),
260
+ document.body
261
+ )
262
+ ] });
263
+ };
264
+
265
+ // src/components/icons/iconConstants.ts
266
+ var INPUT_TYPE_ICONS = {
267
+ // Standard HTML input types
268
+ email: "envelope-solid",
269
+ password: "lock-closed-solid",
270
+ search: "magnifying-glass-solid",
271
+ date: "calendar-days-solid",
272
+ time: "clock-solid",
273
+ "datetime-local": "calendar-days-solid",
274
+ tel: "phone-solid",
275
+ url: "link-solid",
276
+ number: "hashtag-solid",
277
+ // Additional semantic types
278
+ username: "user-solid",
279
+ name: "user-solid",
280
+ firstname: "user-solid",
281
+ lastname: "user-solid",
282
+ address: "map-pin-solid",
283
+ city: "building-solid",
284
+ state: "map-solid",
285
+ zip: "map-pin-solid",
286
+ "zip-code": "map-pin-solid",
287
+ country: "globe-americas-solid",
288
+ creditcard: "credit-card-solid",
289
+ card: "credit-card-solid",
290
+ cvv: "lock-closed-solid",
291
+ expiry: "calendar-days-solid",
292
+ "expiration-date": "calendar-days-solid",
293
+ // File and media types
294
+ file: "document-solid",
295
+ image: "photo-solid",
296
+ video: "video-camera-solid",
297
+ audio: "microphone-solid",
298
+ // Communication
299
+ message: "chat-bubble-left-solid",
300
+ comment: "chat-bubble-left-solid",
301
+ feedback: "chat-bubble-left-solid",
302
+ // Actions and states
303
+ submit: "paper-airplane-solid",
304
+ send: "paper-airplane-solid",
305
+ save: "floppy-disk-solid",
306
+ edit: "pencil-solid",
307
+ delete: "trash-solid",
308
+ remove: "x-mark-solid",
309
+ add: "plus-solid",
310
+ create: "plus-solid",
311
+ upload: "arrow-up-tray-solid",
312
+ download: "arrow-down-tray-solid",
313
+ refresh: "arrow-path-solid",
314
+ reload: "arrow-path-solid",
315
+ settings: "cog-solid",
316
+ config: "cog-solid",
317
+ filter: "funnel-solid",
318
+ sort: "bars-arrow-up-solid"
319
+ };
320
+ var ACTION_ICONS = {
321
+ close: "x-mark-solid",
322
+ back: "arrow-left-solid",
323
+ forward: "arrow-right-solid",
324
+ up: "arrow-up-solid",
325
+ down: "arrow-down-solid",
326
+ expand: "chevron-down-solid",
327
+ collapse: "chevron-up-solid",
328
+ menu: "bars-3-solid",
329
+ more: "ellipsis-horizontal-solid",
330
+ check: "check-solid",
331
+ cross: "x-mark-solid",
332
+ plus: "plus-solid",
333
+ minus: "minus-solid",
334
+ search: "magnifying-glass-solid",
335
+ clear: "x-mark-solid",
336
+ loading: "arrow-path-solid",
337
+ error: "exclamation-triangle-solid",
338
+ warning: "exclamation-triangle-solid",
339
+ info: "information-circle-solid",
340
+ success: "check-circle-solid"
341
+ };
342
+ var LIST_ICONS = {
343
+ selected: "check-solid",
344
+ unselected: "circle-solid"
345
+ };
346
+
347
+ // src/components/list/List.tsx
348
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
349
+ var ListItem = ({
350
+ children,
351
+ icon,
352
+ selected = false,
353
+ disabled = false,
354
+ onClick,
355
+ category,
356
+ className = "",
357
+ ...props
358
+ }) => {
359
+ const classes = [
360
+ "list-item",
361
+ selected && "list-item--selected",
362
+ disabled && "list-item--disabled",
363
+ onClick && !disabled && "list-item--interactive",
364
+ className
365
+ ].filter(Boolean).join(" ");
366
+ const handleClick = () => {
367
+ if (!disabled && onClick) {
368
+ onClick();
369
+ }
370
+ };
371
+ const handleKeyDown = (e) => {
372
+ if (!disabled && onClick && (e.key === "Enter" || e.key === " ")) {
373
+ e.preventDefault();
374
+ onClick();
375
+ }
376
+ };
377
+ return /* @__PURE__ */ jsxs2(
378
+ "div",
379
+ {
380
+ className: classes,
381
+ onClick: handleClick,
382
+ onKeyDown: handleKeyDown,
383
+ role: onClick ? "button" : void 0,
384
+ tabIndex: onClick && !disabled ? 0 : void 0,
385
+ "aria-selected": selected,
386
+ "aria-disabled": disabled,
387
+ ...props,
388
+ children: [
389
+ icon && /* @__PURE__ */ jsx4("div", { className: "list-item__icon", children: /* @__PURE__ */ jsx4(Icon, { name: icon, size: 20 }) }),
390
+ /* @__PURE__ */ jsxs2("div", { className: "list-item__content", children: [
391
+ category && /* @__PURE__ */ jsx4("div", { className: "list-item__category", children: category }),
392
+ /* @__PURE__ */ jsx4("div", { children })
393
+ ] }),
394
+ selected && /* @__PURE__ */ jsx4("div", { className: "list-item__indicator", children: /* @__PURE__ */ jsx4(Icon, { name: LIST_ICONS.selected, size: 16 }) })
395
+ ]
396
+ }
397
+ );
398
+ };
399
+ var List = ({ children, className = "", ...props }) => {
400
+ const classes = ["list", className].filter(Boolean).join(" ");
401
+ return /* @__PURE__ */ jsx4("div", { className: classes, role: "list", ...props, children });
402
+ };
403
+
404
+ // src/components/select/Select.tsx
405
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
406
+ var Select = ({
407
+ options,
408
+ value,
409
+ onChange,
410
+ label,
411
+ placeholder = "Select an option",
412
+ helperText,
413
+ error,
414
+ disabled = false,
415
+ fullWidth = false,
416
+ size = "md",
417
+ className = "",
418
+ id
419
+ }) => {
420
+ const [isOpen, setIsOpen] = React2.useState(false);
421
+ const selectId = id || `select-${React2.useId()}`;
422
+ const selectedOption = options.find((opt) => opt.value === value);
423
+ const handleSelect = (optionValue) => {
424
+ onChange?.(optionValue);
425
+ setIsOpen(false);
426
+ };
427
+ const handleKeyDown = (e) => {
428
+ if (disabled) return;
429
+ if (e.key === "Enter" || e.key === " ") {
430
+ e.preventDefault();
431
+ setIsOpen(!isOpen);
432
+ } else if (e.key === "Escape") {
433
+ setIsOpen(false);
434
+ } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
435
+ e.preventDefault();
436
+ if (!isOpen) {
437
+ setIsOpen(true);
438
+ }
439
+ }
440
+ };
441
+ const containerClasses = [
442
+ "select-container",
443
+ fullWidth && "select-container--full-width",
444
+ className
445
+ ].filter(Boolean).join(" ");
446
+ const triggerClasses = [
447
+ "select__trigger",
448
+ `select__trigger--${size}`,
449
+ error && "select__trigger--error",
450
+ disabled && "select__trigger--disabled",
451
+ isOpen && "select__trigger--open"
452
+ ].filter(Boolean).join(" ");
453
+ return /* @__PURE__ */ jsxs3("div", { className: containerClasses, children: [
454
+ label && /* @__PURE__ */ jsx5("label", { htmlFor: selectId, className: "select__label", children: label }),
455
+ /* @__PURE__ */ jsx5(
456
+ Popover,
457
+ {
458
+ trigger: /* @__PURE__ */ jsxs3(
459
+ "button",
460
+ {
461
+ id: selectId,
462
+ type: "button",
463
+ className: triggerClasses,
464
+ onClick: () => !disabled && setIsOpen(!isOpen),
465
+ onKeyDown: handleKeyDown,
466
+ disabled,
467
+ "aria-haspopup": "listbox",
468
+ "aria-expanded": isOpen,
469
+ "aria-labelledby": label ? `${selectId}-label` : void 0,
470
+ "aria-describedby": error ? `${selectId}-error` : helperText ? `${selectId}-helper` : void 0,
471
+ "aria-invalid": error ? "true" : "false",
472
+ children: [
473
+ /* @__PURE__ */ jsxs3("span", { className: "select__trigger-content", children: [
474
+ selectedOption?.icon && /* @__PURE__ */ jsx5(
475
+ Icon,
476
+ {
477
+ name: selectedOption.icon,
478
+ size: size === "sm" ? 16 : size === "lg" ? 24 : 20
479
+ }
480
+ ),
481
+ /* @__PURE__ */ jsx5("span", { className: "select__trigger-text", children: selectedOption ? selectedOption.label : placeholder })
482
+ ] }),
483
+ /* @__PURE__ */ jsx5(
484
+ Icon,
485
+ {
486
+ name: "flowbite:chevron-down-outline",
487
+ size: size === "sm" ? 16 : size === "lg" ? 24 : 20,
488
+ className: "select__trigger-icon"
489
+ }
490
+ )
491
+ ]
492
+ }
493
+ ),
494
+ isOpen,
495
+ onToggle: () => !disabled && setIsOpen(!isOpen),
496
+ placement: "bottom",
497
+ children: /* @__PURE__ */ jsx5("div", { className: "select__dropdown scrollable", role: "listbox", children: /* @__PURE__ */ jsx5(List, { children: options.map((option) => /* @__PURE__ */ jsx5(
498
+ ListItem,
499
+ {
500
+ icon: option.icon,
501
+ selected: option.value === value,
502
+ disabled: option.disabled,
503
+ onClick: () => !option.disabled && handleSelect(option.value),
504
+ role: "option",
505
+ "aria-selected": option.value === value,
506
+ children: option.label
507
+ },
508
+ option.value
509
+ )) }) })
510
+ }
511
+ ),
512
+ error && /* @__PURE__ */ jsx5("p", { id: `${selectId}-error`, className: "select__message select__message--error", children: error }),
513
+ helperText && !error && /* @__PURE__ */ jsx5("p", { id: `${selectId}-helper`, className: "select__message", children: helperText })
514
+ ] });
515
+ };
516
+
517
+ // src/components/button/button.tsx
518
+ import React3 from "react";
519
+ import { Button as AriakitButton } from "@ariakit/react";
520
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
521
+ var Button = React3.forwardRef(
522
+ ({
523
+ variant = "primary",
524
+ size = "md",
525
+ children,
526
+ isLoading = false,
527
+ disabled = false,
528
+ fullWidth = false,
529
+ startIcon,
530
+ endIcon,
531
+ iconOnly = false,
532
+ href,
533
+ active = false,
534
+ className,
535
+ onClick,
536
+ ...props
537
+ }, ref) => {
538
+ const buttonClasses = [
539
+ "btn",
540
+ `btn--${variant}`,
541
+ `btn--${size}`,
542
+ fullWidth && "btn--full-width",
543
+ iconOnly && "btn--icon-only",
544
+ active && "btn--active",
545
+ className
546
+ ].filter(Boolean).join(" ");
547
+ const iconSize = size === "xs" ? 14 : size === "sm" ? 16 : size === "lg" ? 24 : 20;
548
+ const buttonContent = /* @__PURE__ */ jsxs4(Fragment2, { children: [
549
+ isLoading && /* @__PURE__ */ jsx6("span", { className: "btn__spinner" }),
550
+ startIcon && (isLoading ? /* @__PURE__ */ jsx6("span", { className: "btn__icon-placeholder", style: { width: iconSize, height: iconSize } }) : /* @__PURE__ */ jsx6(Icon, { name: startIcon, size: iconSize, className: "btn__icon" })),
551
+ !iconOnly && children,
552
+ endIcon && /* @__PURE__ */ jsx6(Icon, { name: endIcon, size: iconSize, className: "btn__icon" })
553
+ ] });
554
+ const handleClick = (e) => {
555
+ if (href && !isLoading && !disabled) {
556
+ window.location.href = href;
557
+ }
558
+ onClick?.(e);
559
+ };
560
+ return /* @__PURE__ */ jsx6(
561
+ AriakitButton,
562
+ {
563
+ ref,
564
+ disabled: disabled || isLoading,
565
+ className: buttonClasses,
566
+ onClick: handleClick,
567
+ ...props,
568
+ children: buttonContent
569
+ }
570
+ );
571
+ }
572
+ );
573
+ Button.displayName = "Button";
574
+
575
+ // src/components/dialog/Dialog.tsx
576
+ import * as React21 from "react";
577
+ import { createPortal as createPortal3 } from "react-dom";
578
+
579
+ // src/components/_shared/Backdrop.tsx
580
+ import * as React4 from "react";
581
+ import { jsx as jsx7 } from "react/jsx-runtime";
582
+ var Backdrop = React4.forwardRef(
583
+ ({ className = "", blur = true, style, ...props }, ref) => {
584
+ return /* @__PURE__ */ jsx7(
585
+ "div",
586
+ {
587
+ ref,
588
+ className: `backdrop ${blur ? "backdrop--blur" : ""} ${className}`,
589
+ style,
590
+ "aria-hidden": "true",
591
+ ...props
592
+ }
593
+ );
594
+ }
595
+ );
596
+ Backdrop.displayName = "Backdrop";
597
+
598
+ // src/components/_shared/Thumb.tsx
599
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
600
+
601
+ // src/components/_shared/HeadingAnchor.tsx
602
+ import { useState as useState7, useMemo } from "react";
603
+
604
+ // src/components/input/InputText.tsx
605
+ import React9 from "react";
606
+
607
+ // src/components/input/Input.tsx
608
+ import * as React8 from "react";
609
+
610
+ // src/components/input/InputField.tsx
611
+ import * as React5 from "react";
612
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
613
+ var InputField = React5.forwardRef(
614
+ ({
615
+ type = "text",
616
+ label,
617
+ helperText,
618
+ error,
619
+ icon,
620
+ iconRight,
621
+ fullWidth = false,
622
+ size = "md",
623
+ className = "",
624
+ disabled,
625
+ id,
626
+ onRightIconClick,
627
+ ...props
628
+ }, ref) => {
629
+ const inputId = id || `input-${React5.useId()}`;
630
+ const containerClasses = [
631
+ "input-container",
632
+ fullWidth && "input-container--full-width",
633
+ className
634
+ ].filter(Boolean).join(" ");
635
+ const inputClasses = [
636
+ "input",
637
+ `input--${size}`,
638
+ error && "input--error",
639
+ disabled && "input--disabled",
640
+ icon && "input--has-icon-left",
641
+ iconRight && "input--has-icon-right"
642
+ ].filter(Boolean).join(" ");
643
+ return /* @__PURE__ */ jsxs6("div", { className: containerClasses, children: [
644
+ label && /* @__PURE__ */ jsx9("label", { htmlFor: inputId, className: "input__label", children: label }),
645
+ /* @__PURE__ */ jsxs6("div", { className: "input__wrapper", children: [
646
+ icon && /* @__PURE__ */ jsx9("span", { className: "input__icon input__icon--left", "aria-hidden": "true", children: /* @__PURE__ */ jsx9(Icon, { name: icon, size: 16 }) }),
647
+ /* @__PURE__ */ jsx9(
648
+ "input",
649
+ {
650
+ ref,
651
+ type,
652
+ id: inputId,
653
+ className: inputClasses,
654
+ disabled,
655
+ ...props
656
+ }
657
+ ),
658
+ iconRight && /* @__PURE__ */ jsx9(
659
+ "button",
660
+ {
661
+ type: "button",
662
+ className: "input__icon input__icon--right",
663
+ onClick: onRightIconClick,
664
+ tabIndex: -1,
665
+ "aria-label": "Icon action",
666
+ children: /* @__PURE__ */ jsx9(Icon, { name: iconRight, size: 16 })
667
+ }
668
+ )
669
+ ] }),
670
+ error && /* @__PURE__ */ jsx9("p", { className: "input__message input__message--error", children: error }),
671
+ helperText && !error && /* @__PURE__ */ jsx9("p", { className: "input__message", children: helperText })
672
+ ] });
673
+ }
674
+ );
675
+
676
+ // src/components/input/DatePicker.tsx
677
+ import * as React6 from "react";
678
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
679
+ var MONTHS = [
680
+ "January",
681
+ "February",
682
+ "March",
683
+ "April",
684
+ "May",
685
+ "June",
686
+ "July",
687
+ "August",
688
+ "September",
689
+ "October",
690
+ "November",
691
+ "December"
692
+ ];
693
+ var DAYS_OF_WEEK = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
694
+ var DatePicker = ({ value, onChange, disabled }) => {
695
+ const parseDate = (dateStr) => {
696
+ if (!dateStr) {
697
+ const today = /* @__PURE__ */ new Date();
698
+ return { year: today.getFullYear(), month: today.getMonth(), day: today.getDate() };
699
+ }
700
+ const [year, month, day] = dateStr.split("-").map(Number);
701
+ return { year, month: month - 1, day };
702
+ };
703
+ const { year: initialYear, month: initialMonth, day: selectedDay } = parseDate(value);
704
+ const [currentYear, setCurrentYear] = React6.useState(initialYear);
705
+ const [currentMonth, setCurrentMonth] = React6.useState(initialMonth);
706
+ const getDaysInMonth = (year, month) => {
707
+ return new Date(year, month + 1, 0).getDate();
708
+ };
709
+ const getFirstDayOfMonth = (year, month) => {
710
+ return new Date(year, month, 1).getDay();
711
+ };
712
+ const handleDateSelect = (day) => {
713
+ if (disabled) return;
714
+ const formattedDate = `${currentYear}-${String(currentMonth + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
715
+ onChange(formattedDate);
716
+ };
717
+ const handlePrevMonth = () => {
718
+ if (currentMonth === 0) {
719
+ setCurrentMonth(11);
720
+ setCurrentYear(currentYear - 1);
721
+ } else {
722
+ setCurrentMonth(currentMonth - 1);
723
+ }
724
+ };
725
+ const handleNextMonth = () => {
726
+ if (currentMonth === 11) {
727
+ setCurrentMonth(0);
728
+ setCurrentYear(currentYear + 1);
729
+ } else {
730
+ setCurrentMonth(currentMonth + 1);
731
+ }
732
+ };
733
+ const daysInMonth = getDaysInMonth(currentYear, currentMonth);
734
+ const firstDay = getFirstDayOfMonth(currentYear, currentMonth);
735
+ const days = [
736
+ ...Array(firstDay).fill(null),
737
+ ...Array.from({ length: daysInMonth }, (_, i) => i + 1)
738
+ ];
739
+ return /* @__PURE__ */ jsxs7("div", { className: "date-picker", children: [
740
+ /* @__PURE__ */ jsxs7("div", { className: "date-picker__header", children: [
741
+ /* @__PURE__ */ jsx10(
742
+ "button",
743
+ {
744
+ type: "button",
745
+ className: "date-picker__nav",
746
+ onClick: handlePrevMonth,
747
+ disabled,
748
+ "aria-label": "Previous month",
749
+ children: "\u2039"
750
+ }
751
+ ),
752
+ /* @__PURE__ */ jsxs7("div", { className: "date-picker__title", children: [
753
+ /* @__PURE__ */ jsx10(
754
+ "select",
755
+ {
756
+ className: "date-picker__select",
757
+ value: currentMonth,
758
+ onChange: (e) => setCurrentMonth(Number(e.target.value)),
759
+ disabled,
760
+ children: MONTHS.map((month, idx) => /* @__PURE__ */ jsx10("option", { value: idx, children: month }, month))
761
+ }
762
+ ),
763
+ /* @__PURE__ */ jsx10(
764
+ "select",
765
+ {
766
+ className: "date-picker__select",
767
+ value: currentYear,
768
+ onChange: (e) => setCurrentYear(Number(e.target.value)),
769
+ disabled,
770
+ children: Array.from({ length: 100 }, (_, i) => currentYear - 50 + i).map((year) => /* @__PURE__ */ jsx10("option", { value: year, children: year }, year))
771
+ }
772
+ )
773
+ ] }),
774
+ /* @__PURE__ */ jsx10(
775
+ "button",
776
+ {
777
+ type: "button",
778
+ className: "date-picker__nav",
779
+ onClick: handleNextMonth,
780
+ disabled,
781
+ "aria-label": "Next month",
782
+ children: "\u203A"
783
+ }
784
+ )
785
+ ] }),
786
+ /* @__PURE__ */ jsx10("div", { className: "date-picker__weekdays", children: DAYS_OF_WEEK.map((day) => /* @__PURE__ */ jsx10("div", { className: "date-picker__weekday", children: day }, day)) }),
787
+ /* @__PURE__ */ jsx10("div", { className: "date-picker__days", children: days.map((day, idx) => /* @__PURE__ */ jsx10(
788
+ "button",
789
+ {
790
+ type: "button",
791
+ className: `date-picker__day ${day === selectedDay ? "date-picker__day--selected" : ""} ${!day ? "date-picker__day--empty" : ""}`,
792
+ onClick: () => day && handleDateSelect(day),
793
+ disabled: !day || disabled,
794
+ children: day || ""
795
+ },
796
+ idx
797
+ )) })
798
+ ] });
799
+ };
800
+
801
+ // src/components/input/TimePicker.tsx
802
+ import * as React7 from "react";
803
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
804
+ var parseTime = (timeStr) => {
805
+ if (!timeStr) return { hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
806
+ const parts = timeStr.split(":");
807
+ const hours = parseInt(parts[0] || "0", 10);
808
+ const minutes = parseInt(parts[1] || "0", 10);
809
+ const secondsParts = (parts[2] || "0").split(".");
810
+ const seconds = parseInt(secondsParts[0] || "0", 10);
811
+ const milliseconds = parseInt(secondsParts[1] || "0", 10);
812
+ return { hours, minutes, seconds, milliseconds };
813
+ };
814
+ var TimeColumn = ({
815
+ label,
816
+ value,
817
+ max,
818
+ field,
819
+ step,
820
+ disabled,
821
+ onChange
822
+ }) => {
823
+ const items = Array.from({ length: Math.floor(max / step) + 1 }, (_, i) => i * step);
824
+ const columnRef = React7.useRef(null);
825
+ React7.useEffect(() => {
826
+ if (columnRef.current) {
827
+ const selected = columnRef.current.querySelector(".time-picker__item--selected");
828
+ if (selected) {
829
+ selected.scrollIntoView({ block: "center", behavior: "smooth" });
830
+ }
831
+ }
832
+ }, [value]);
833
+ return /* @__PURE__ */ jsxs8("div", { className: "time-picker__column", children: [
834
+ /* @__PURE__ */ jsx11("div", { className: "time-picker__label", children: label }),
835
+ /* @__PURE__ */ jsx11("div", { className: "time-picker__scroll scrollable", ref: columnRef, children: items.map((item) => /* @__PURE__ */ jsx11(
836
+ "button",
837
+ {
838
+ type: "button",
839
+ className: `time-picker__item ${item === value ? "time-picker__item--selected" : ""}`,
840
+ onClick: () => onChange(field, item),
841
+ disabled,
842
+ children: String(item).padStart(field === "milliseconds" ? 3 : 2, "0")
843
+ },
844
+ item
845
+ )) })
846
+ ] });
847
+ };
848
+ var TimePicker = ({
849
+ value,
850
+ onChange,
851
+ disabled,
852
+ showMilliseconds = false,
853
+ minuteStep = 1
854
+ }) => {
855
+ const [internalTime, setInternalTime] = React7.useState(value);
856
+ React7.useEffect(() => {
857
+ setInternalTime(value);
858
+ }, [value]);
859
+ const { hours, minutes, seconds, milliseconds } = parseTime(internalTime);
860
+ const handleChange = (field, newValue) => {
861
+ if (disabled) return;
862
+ const currentParsed = parseTime(internalTime);
863
+ const updated = { ...currentParsed, [field]: newValue };
864
+ let formattedTime = `${String(updated.hours).padStart(2, "0")}:${String(updated.minutes).padStart(2, "0")}:${String(updated.seconds).padStart(2, "0")}`;
865
+ if (showMilliseconds && updated.milliseconds > 0) {
866
+ formattedTime += `.${String(updated.milliseconds).padStart(3, "0")}`;
867
+ }
868
+ setInternalTime(formattedTime);
869
+ onChange(formattedTime);
870
+ };
871
+ return /* @__PURE__ */ jsxs8("div", { className: "time-picker", children: [
872
+ /* @__PURE__ */ jsx11(
873
+ TimeColumn,
874
+ {
875
+ label: "Hours",
876
+ value: hours,
877
+ max: 23,
878
+ field: "hours",
879
+ step: 1,
880
+ disabled,
881
+ onChange: handleChange
882
+ }
883
+ ),
884
+ /* @__PURE__ */ jsx11(
885
+ TimeColumn,
886
+ {
887
+ label: "Minutes",
888
+ value: minutes,
889
+ max: 59,
890
+ field: "minutes",
891
+ step: minuteStep,
892
+ disabled,
893
+ onChange: handleChange
894
+ }
895
+ ),
896
+ /* @__PURE__ */ jsx11(
897
+ TimeColumn,
898
+ {
899
+ label: "Seconds",
900
+ value: seconds,
901
+ max: 59,
902
+ field: "seconds",
903
+ step: 1,
904
+ disabled,
905
+ onChange: handleChange
906
+ }
907
+ ),
908
+ showMilliseconds && /* @__PURE__ */ jsx11(
909
+ TimeColumn,
910
+ {
911
+ label: "ms",
912
+ value: milliseconds,
913
+ max: 999,
914
+ field: "milliseconds",
915
+ step: 1,
916
+ disabled,
917
+ onChange: handleChange
918
+ }
919
+ )
920
+ ] });
921
+ };
922
+
923
+ // src/components/input/Input.tsx
924
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
925
+ var TYPE_ICON_MAP = INPUT_TYPE_ICONS;
926
+ var formatDisplayValue = (val, inputType) => {
927
+ if (!val) return "";
928
+ if (inputType === "date") {
929
+ const [year, month, day] = val.split("-");
930
+ return `${day}/${month}/${year}`;
931
+ }
932
+ if (inputType === "time") {
933
+ return val;
934
+ }
935
+ if (inputType === "datetime-local") {
936
+ const [datePart, timePart] = val.split("T");
937
+ if (datePart && timePart) {
938
+ const [year, month, day] = datePart.split("-");
939
+ return `${day}/${month}/${year} ${timePart}`;
940
+ }
941
+ return val;
942
+ }
943
+ return val;
944
+ };
945
+ var Input = React8.forwardRef(
946
+ ({
947
+ type = "text",
948
+ label,
949
+ helperText,
950
+ error,
951
+ icon,
952
+ fullWidth = false,
953
+ size = "md",
954
+ className = "",
955
+ disabled,
956
+ id,
957
+ showMilliseconds = false,
958
+ minuteStep = 1,
959
+ showClear = true,
960
+ ...props
961
+ }, ref) => {
962
+ const [showPassword, setShowPassword] = React8.useState(false);
963
+ const [showDateTimePicker, setShowDateTimePicker] = React8.useState(false);
964
+ const inputRef = React8.useRef(null);
965
+ const leftIcon = icon || TYPE_ICON_MAP[type];
966
+ const isPasswordType = type === "password";
967
+ const actualType = isPasswordType && showPassword ? "text" : type !== "date" && type !== "time" && type !== "datetime-local" ? type : "text";
968
+ const isDateTimeType = type === "date" || type === "time" || type === "datetime-local";
969
+ const isSearchType = type === "search";
970
+ const hasValue = props.value && String(props.value).length > 0;
971
+ const rightIconName = isPasswordType ? showPassword ? "heroicons:eye-slash-solid" : "heroicons:eye-solid" : isDateTimeType ? "heroicons:chevron-down-solid" : isSearchType && hasValue && showClear ? ACTION_ICONS.clear : void 0;
972
+ const handleRightIconClick = () => {
973
+ if (isPasswordType) {
974
+ setShowPassword(!showPassword);
975
+ } else if (isDateTimeType) {
976
+ setShowDateTimePicker(!showDateTimePicker);
977
+ } else if (isSearchType && hasValue && showClear) {
978
+ if (props.onChange) {
979
+ props.onChange({ target: { value: "" } });
980
+ }
981
+ }
982
+ };
983
+ const handleDateTimeChange = (newValue) => {
984
+ if (props.onChange) {
985
+ props.onChange({ target: { value: newValue } });
986
+ }
987
+ };
988
+ if (!isDateTimeType) {
989
+ return /* @__PURE__ */ jsx12(
990
+ InputField,
991
+ {
992
+ ref: ref || inputRef,
993
+ type: actualType,
994
+ label,
995
+ helperText,
996
+ error,
997
+ icon: leftIcon,
998
+ iconRight: rightIconName,
999
+ onRightIconClick: handleRightIconClick,
1000
+ fullWidth,
1001
+ size,
1002
+ className,
1003
+ disabled,
1004
+ id,
1005
+ ...props
1006
+ }
1007
+ );
1008
+ }
1009
+ return /* @__PURE__ */ jsxs9("div", { className: `input-container ${fullWidth ? "input-container--full-width" : ""} ${className}`.trim(), children: [
1010
+ label && /* @__PURE__ */ jsx12("label", { htmlFor: id, className: "input__label", children: label }),
1011
+ /* @__PURE__ */ jsx12(
1012
+ Popover,
1013
+ {
1014
+ trigger: /* @__PURE__ */ jsx12(
1015
+ InputField,
1016
+ {
1017
+ ref: ref || inputRef,
1018
+ type: "text",
1019
+ icon: leftIcon,
1020
+ iconRight: rightIconName,
1021
+ onRightIconClick: () => setShowDateTimePicker(!showDateTimePicker),
1022
+ fullWidth,
1023
+ size,
1024
+ disabled,
1025
+ id,
1026
+ value: formatDisplayValue(String(props.value || ""), type),
1027
+ placeholder: props.placeholder,
1028
+ readOnly: true
1029
+ }
1030
+ ),
1031
+ isOpen: showDateTimePicker,
1032
+ onToggle: () => setShowDateTimePicker(!showDateTimePicker),
1033
+ placement: "bottom",
1034
+ children: /* @__PURE__ */ jsxs9("div", { style: { padding: "1rem" }, children: [
1035
+ (type === "date" || type === "datetime-local") && /* @__PURE__ */ jsx12(
1036
+ DatePicker,
1037
+ {
1038
+ value: String(props.value || "").split("T")[0],
1039
+ onChange: (newDate) => {
1040
+ if (type === "datetime-local") {
1041
+ const time = String(props.value || "").split("T")[1] || "00:00:00";
1042
+ handleDateTimeChange(`${newDate}T${time}`);
1043
+ } else {
1044
+ handleDateTimeChange(newDate);
1045
+ setShowDateTimePicker(false);
1046
+ }
1047
+ },
1048
+ disabled
1049
+ }
1050
+ ),
1051
+ (type === "time" || type === "datetime-local") && /* @__PURE__ */ jsx12(
1052
+ TimePicker,
1053
+ {
1054
+ value: String(props.value || "").split("T")[1] || "00:00:00",
1055
+ onChange: (newTime) => {
1056
+ if (type === "datetime-local") {
1057
+ const date = String(props.value || "").split("T")[0] || (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1058
+ handleDateTimeChange(`${date}T${newTime}`);
1059
+ } else {
1060
+ handleDateTimeChange(newTime);
1061
+ }
1062
+ },
1063
+ disabled,
1064
+ showMilliseconds,
1065
+ minuteStep
1066
+ }
1067
+ )
1068
+ ] })
1069
+ }
1070
+ ),
1071
+ error && /* @__PURE__ */ jsx12("p", { className: "input__message input__message--error", children: error }),
1072
+ helperText && !error && /* @__PURE__ */ jsx12("p", { className: "input__message", children: helperText })
1073
+ ] });
1074
+ }
1075
+ );
1076
+ Input.displayName = "Input";
1077
+
1078
+ // src/components/input/InputText.tsx
1079
+ import { jsx as jsx13 } from "react/jsx-runtime";
1080
+ var InputText = React9.forwardRef((props, ref) => {
1081
+ return /* @__PURE__ */ jsx13(Input, { ref, ...props, type: "text" });
1082
+ });
1083
+ InputText.displayName = "InputText";
1084
+
1085
+ // src/components/input/InputEmail.tsx
1086
+ import React10 from "react";
1087
+ import { jsx as jsx14 } from "react/jsx-runtime";
1088
+ var InputEmail = React10.forwardRef((props, ref) => {
1089
+ return /* @__PURE__ */ jsx14(Input, { ref, ...props, type: "email" });
1090
+ });
1091
+ InputEmail.displayName = "InputEmail";
1092
+
1093
+ // src/components/input/InputPassword.tsx
1094
+ import React11 from "react";
1095
+ import { jsx as jsx15 } from "react/jsx-runtime";
1096
+ var InputPassword = React11.forwardRef((props, ref) => {
1097
+ return /* @__PURE__ */ jsx15(Input, { ref, ...props, type: "password" });
1098
+ });
1099
+ InputPassword.displayName = "InputPassword";
1100
+
1101
+ // src/components/input/InputSearch.tsx
1102
+ import React12 from "react";
1103
+ import { jsx as jsx16 } from "react/jsx-runtime";
1104
+ var InputSearch = React12.forwardRef((props, ref) => {
1105
+ return /* @__PURE__ */ jsx16(Input, { ref, ...props, type: "search" });
1106
+ });
1107
+ InputSearch.displayName = "InputSearch";
1108
+
1109
+ // src/components/input/InputTel.tsx
1110
+ import React13 from "react";
1111
+ import { jsx as jsx17 } from "react/jsx-runtime";
1112
+ var InputTel = React13.forwardRef((props, ref) => {
1113
+ return /* @__PURE__ */ jsx17(Input, { ref, ...props, type: "tel" });
1114
+ });
1115
+ InputTel.displayName = "InputTel";
1116
+
1117
+ // src/components/input/InputUrl.tsx
1118
+ import React14 from "react";
1119
+ import { jsx as jsx18 } from "react/jsx-runtime";
1120
+ var InputUrl = React14.forwardRef((props, ref) => {
1121
+ return /* @__PURE__ */ jsx18(Input, { ref, ...props, type: "url" });
1122
+ });
1123
+ InputUrl.displayName = "InputUrl";
1124
+
1125
+ // src/components/input/InputNumber.tsx
1126
+ import React15 from "react";
1127
+ import { jsx as jsx19 } from "react/jsx-runtime";
1128
+ var InputNumber = React15.forwardRef((props, ref) => {
1129
+ return /* @__PURE__ */ jsx19(Input, { ref, ...props, type: "number" });
1130
+ });
1131
+ InputNumber.displayName = "InputNumber";
1132
+
1133
+ // src/components/input/InputDate.tsx
1134
+ import React16 from "react";
1135
+ import { jsx as jsx20 } from "react/jsx-runtime";
1136
+ var InputDate = React16.forwardRef((props, ref) => {
1137
+ return /* @__PURE__ */ jsx20(Input, { ref, ...props, type: "date" });
1138
+ });
1139
+ InputDate.displayName = "InputDate";
1140
+
1141
+ // src/components/input/InputTime.tsx
1142
+ import React17 from "react";
1143
+ import { jsx as jsx21 } from "react/jsx-runtime";
1144
+ var InputTime = React17.forwardRef((props, ref) => {
1145
+ return /* @__PURE__ */ jsx21(Input, { ref, ...props, type: "time" });
1146
+ });
1147
+ InputTime.displayName = "InputTime";
1148
+
1149
+ // src/components/input/InputDateTime.tsx
1150
+ import React18 from "react";
1151
+ import { jsx as jsx22 } from "react/jsx-runtime";
1152
+ var InputDateTime = React18.forwardRef((props, ref) => {
1153
+ return /* @__PURE__ */ jsx22(Input, { ref, ...props, type: "datetime-local" });
1154
+ });
1155
+ InputDateTime.displayName = "InputDateTime";
1156
+
1157
+ // src/components/tooltip/tooltip.tsx
1158
+ import * as React19 from "react";
1159
+ import * as ReactDOM2 from "react-dom";
1160
+ import { Fragment as Fragment3, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
1161
+
1162
+ // src/components/_shared/HeadingAnchor.tsx
1163
+ import { Fragment as Fragment4, jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
1164
+
1165
+ // src/components/dialog/Dialog.tsx
1166
+ import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
1167
+ var Dialog = ({
1168
+ open,
1169
+ onClose,
1170
+ title,
1171
+ children,
1172
+ size = "md",
1173
+ footer,
1174
+ showCloseButton = true,
1175
+ closeOnBackdropClick = true,
1176
+ closeOnEscape = true,
1177
+ className = "",
1178
+ ariaLabel,
1179
+ ariaDescribedBy
1180
+ }) => {
1181
+ const dialogRef = React21.useRef(null);
1182
+ React21.useEffect(() => {
1183
+ if (!open || !closeOnEscape) return;
1184
+ const handleEscape = (e) => {
1185
+ if (e.key === "Escape") {
1186
+ onClose();
1187
+ }
1188
+ };
1189
+ document.addEventListener("keydown", handleEscape);
1190
+ return () => document.removeEventListener("keydown", handleEscape);
1191
+ }, [open, closeOnEscape, onClose]);
1192
+ React21.useEffect(() => {
1193
+ if (open) {
1194
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
1195
+ document.body.style.overflow = "hidden";
1196
+ document.body.style.paddingRight = `${scrollbarWidth}px`;
1197
+ } else {
1198
+ document.body.style.overflow = "";
1199
+ document.body.style.paddingRight = "";
1200
+ }
1201
+ return () => {
1202
+ document.body.style.overflow = "";
1203
+ document.body.style.paddingRight = "";
1204
+ };
1205
+ }, [open]);
1206
+ React21.useEffect(() => {
1207
+ if (!open || !dialogRef.current) return;
1208
+ const dialog = dialogRef.current;
1209
+ const focusableElements = dialog.querySelectorAll(
1210
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
1211
+ );
1212
+ const firstElement = focusableElements[0];
1213
+ const lastElement = focusableElements[focusableElements.length - 1];
1214
+ const handleTab = (e) => {
1215
+ if (e.key !== "Tab") return;
1216
+ if (e.shiftKey) {
1217
+ if (document.activeElement === firstElement) {
1218
+ e.preventDefault();
1219
+ lastElement?.focus();
1220
+ }
1221
+ } else {
1222
+ if (document.activeElement === lastElement) {
1223
+ e.preventDefault();
1224
+ firstElement?.focus();
1225
+ }
1226
+ }
1227
+ };
1228
+ dialog.addEventListener("keydown", handleTab);
1229
+ firstElement?.focus();
1230
+ return () => {
1231
+ dialog.removeEventListener("keydown", handleTab);
1232
+ };
1233
+ }, [open]);
1234
+ const handleBackdropClick = (e) => {
1235
+ if (closeOnBackdropClick && e.target === e.currentTarget) {
1236
+ onClose();
1237
+ }
1238
+ };
1239
+ if (!open) return null;
1240
+ const dialogContent = /* @__PURE__ */ jsxs12("div", { className: "dialog__portal", children: [
1241
+ /* @__PURE__ */ jsx25(Backdrop, { onClick: handleBackdropClick, "data-enter": "" }),
1242
+ /* @__PURE__ */ jsxs12(
1243
+ "div",
1244
+ {
1245
+ ref: dialogRef,
1246
+ className: `dialog dialog--${size} ${className}`,
1247
+ role: "dialog",
1248
+ "aria-modal": "true",
1249
+ "aria-label": ariaLabel || title,
1250
+ "aria-describedby": ariaDescribedBy,
1251
+ children: [
1252
+ (title || showCloseButton) && /* @__PURE__ */ jsxs12("div", { className: "dialog__header", children: [
1253
+ title && /* @__PURE__ */ jsx25("h2", { className: "dialog__title", children: title }),
1254
+ showCloseButton && /* @__PURE__ */ jsx25(
1255
+ Button,
1256
+ {
1257
+ variant: "ghost",
1258
+ className: "dialog__close",
1259
+ startIcon: ACTION_ICONS.close,
1260
+ iconOnly: true,
1261
+ onClick: onClose,
1262
+ "aria-label": "Close dialog"
1263
+ }
1264
+ )
1265
+ ] }),
1266
+ /* @__PURE__ */ jsx25("div", { className: "dialog__content scrollable", children }),
1267
+ footer && /* @__PURE__ */ jsx25("div", { className: "dialog__footer", children: footer })
1268
+ ]
1269
+ }
1270
+ )
1271
+ ] });
1272
+ return createPortal3(dialogContent, document.body);
1273
+ };
1274
+
1275
+ // src/components/textarea/RichTextarea.tsx
1276
+ import { Fragment as Fragment5, jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
1277
+ var defaultToolbarOptions = [
1278
+ "bold",
1279
+ "italic",
1280
+ "underline",
1281
+ "link",
1282
+ "unorderedList",
1283
+ "orderedList"
1284
+ ];
1285
+ var iconMap = {
1286
+ bold: "bold",
1287
+ italic: "italic",
1288
+ underline: "underline",
1289
+ strikethrough: "strikethrough",
1290
+ link: "link",
1291
+ unlink: "link-slash",
1292
+ orderedList: "numbered-list",
1293
+ unorderedList: "list-bullet",
1294
+ code: "code-bracket",
1295
+ blockquote: "quote",
1296
+ h1: "h1",
1297
+ h2: "h2",
1298
+ h3: "h3"
1299
+ };
1300
+ var headingOptions = [
1301
+ { value: "p", label: "Normal" },
1302
+ { value: "h1", label: "Heading 1" },
1303
+ { value: "h2", label: "Heading 2" },
1304
+ { value: "h3", label: "Heading 3" }
1305
+ ];
1306
+ var defaultSanitizer = (html) => {
1307
+ return DOMPurify.sanitize(html, {
1308
+ ALLOWED_TAGS: [
1309
+ "b",
1310
+ "i",
1311
+ "u",
1312
+ "s",
1313
+ "strong",
1314
+ "em",
1315
+ "a",
1316
+ "ul",
1317
+ "ol",
1318
+ "li",
1319
+ "p",
1320
+ "br",
1321
+ "code",
1322
+ "pre",
1323
+ "blockquote",
1324
+ "h1",
1325
+ "h2",
1326
+ "h3"
1327
+ ],
1328
+ ALLOWED_ATTR: ["href", "target", "rel"]
1329
+ });
1330
+ };
1331
+ var RichTextarea = React22.forwardRef(
1332
+ ({
1333
+ value,
1334
+ defaultValue,
1335
+ onChange,
1336
+ onSelectionChange,
1337
+ placeholder = "Enter text...",
1338
+ toolbarOptions = defaultToolbarOptions,
1339
+ showTopToolbar = false,
1340
+ readOnly = false,
1341
+ disabled = false,
1342
+ sanitizeHTML = defaultSanitizer,
1343
+ onPaste,
1344
+ ariaLabel,
1345
+ ariaDescribedBy,
1346
+ maxLines,
1347
+ className = "",
1348
+ style,
1349
+ onBlur,
1350
+ onFocus
1351
+ }, ref) => {
1352
+ const editorRef = React22.useRef(null);
1353
+ const [internalHTML, setInternalHTML] = React22.useState(
1354
+ sanitizeHTML(defaultValue || "")
1355
+ );
1356
+ const [showToolbar, setShowToolbar] = React22.useState(false);
1357
+ const [toolbarPosition, setToolbarPosition] = React22.useState({
1358
+ top: 0,
1359
+ left: 0
1360
+ });
1361
+ const [activeFormats, setActiveFormats] = React22.useState(/* @__PURE__ */ new Set());
1362
+ const [currentHeading, setCurrentHeading] = React22.useState("p");
1363
+ const [showLinkDialog, setShowLinkDialog] = React22.useState(false);
1364
+ const [linkUrl, setLinkUrl] = React22.useState("");
1365
+ const [savedRange, setSavedRange] = React22.useState(null);
1366
+ const [showLinkTooltip, setShowLinkTooltip] = React22.useState(false);
1367
+ const [tooltipPosition, setTooltipPosition] = React22.useState({ x: 0, y: 0 });
1368
+ const [isHoldingCtrl, setIsHoldingCtrl] = React22.useState(false);
1369
+ const [shouldScroll, setShouldScroll] = React22.useState(false);
1370
+ const isControlled = value !== void 0;
1371
+ const currentHTML = isControlled ? value : internalHTML;
1372
+ React22.useImperativeHandle(ref, () => editorRef.current);
1373
+ React22.useEffect(() => {
1374
+ if (isControlled && editorRef.current) {
1375
+ const sanitized = sanitizeHTML(value || "");
1376
+ if (editorRef.current.innerHTML !== sanitized) {
1377
+ editorRef.current.innerHTML = sanitized;
1378
+ }
1379
+ }
1380
+ }, [value, isControlled, sanitizeHTML]);
1381
+ React22.useEffect(() => {
1382
+ if (!isControlled && editorRef.current && defaultValue) {
1383
+ editorRef.current.innerHTML = sanitizeHTML(defaultValue);
1384
+ }
1385
+ }, []);
1386
+ React22.useEffect(() => {
1387
+ const handleGlobalKeyDown = (event) => {
1388
+ const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
1389
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
1390
+ if (modKey && !isHoldingCtrl) {
1391
+ setIsHoldingCtrl(true);
1392
+ }
1393
+ };
1394
+ const handleGlobalKeyUp = (event) => {
1395
+ const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
1396
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
1397
+ if (!modKey && isHoldingCtrl) {
1398
+ setIsHoldingCtrl(false);
1399
+ }
1400
+ };
1401
+ document.addEventListener("keydown", handleGlobalKeyDown);
1402
+ document.addEventListener("keyup", handleGlobalKeyUp);
1403
+ return () => {
1404
+ document.removeEventListener("keydown", handleGlobalKeyDown);
1405
+ document.removeEventListener("keyup", handleGlobalKeyUp);
1406
+ };
1407
+ }, [isHoldingCtrl]);
1408
+ React22.useEffect(() => {
1409
+ if (!maxLines || !editorRef.current) return;
1410
+ const calculateHeight = () => {
1411
+ const editor = editorRef.current;
1412
+ if (!editor) return;
1413
+ const computedStyle = window.getComputedStyle(editor);
1414
+ const lineHeight = parseFloat(computedStyle.lineHeight) || 1.2 * parseFloat(computedStyle.fontSize);
1415
+ const maxHeight = maxLines * lineHeight;
1416
+ const contentHeight = editor.scrollHeight;
1417
+ setShouldScroll(contentHeight > maxHeight);
1418
+ if (maxLines) {
1419
+ editor.style.maxHeight = `${maxHeight}px`;
1420
+ }
1421
+ };
1422
+ calculateHeight();
1423
+ const handleResize = () => calculateHeight();
1424
+ window.addEventListener("resize", handleResize);
1425
+ return () => window.removeEventListener("resize", handleResize);
1426
+ }, [maxLines, currentHTML]);
1427
+ const execCommand = (command, value2 = null) => {
1428
+ document.execCommand(command, false, value2 || void 0);
1429
+ editorRef.current?.focus();
1430
+ updateActiveFormats();
1431
+ handleContentChange();
1432
+ };
1433
+ const applyHeading = (headingTag) => {
1434
+ if (headingTag === "p") {
1435
+ execCommand("formatBlock", "<p>");
1436
+ } else {
1437
+ execCommand("formatBlock", `<${headingTag}>`);
1438
+ }
1439
+ setCurrentHeading(headingTag);
1440
+ };
1441
+ const handleInput = () => {
1442
+ handleContentChange();
1443
+ };
1444
+ const handleContentChange = () => {
1445
+ if (!editorRef.current) return;
1446
+ const html = editorRef.current.innerHTML;
1447
+ const sanitized = sanitizeHTML(html);
1448
+ if (isControlled) {
1449
+ onChange?.(sanitized);
1450
+ } else {
1451
+ setInternalHTML(sanitized);
1452
+ onChange?.(sanitized);
1453
+ }
1454
+ };
1455
+ const handlePaste = (event) => {
1456
+ if (onPaste && onPaste(event)) {
1457
+ return;
1458
+ }
1459
+ event.preventDefault();
1460
+ const text = event.clipboardData.getData("text/html") || event.clipboardData.getData("text/plain");
1461
+ const sanitized = sanitizeHTML(text);
1462
+ document.execCommand("insertHTML", false, sanitized);
1463
+ handleContentChange();
1464
+ };
1465
+ const handleKeyDown = (event) => {
1466
+ const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
1467
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
1468
+ if (modKey) {
1469
+ switch (event.key.toLowerCase()) {
1470
+ case "b":
1471
+ event.preventDefault();
1472
+ execCommand("bold");
1473
+ break;
1474
+ case "i":
1475
+ event.preventDefault();
1476
+ execCommand("italic");
1477
+ break;
1478
+ case "u":
1479
+ event.preventDefault();
1480
+ execCommand("underline");
1481
+ break;
1482
+ case "k":
1483
+ event.preventDefault();
1484
+ handleLinkCommand();
1485
+ break;
1486
+ default:
1487
+ break;
1488
+ }
1489
+ }
1490
+ if (event.key === "Escape") {
1491
+ setShowToolbar(false);
1492
+ }
1493
+ };
1494
+ const handleLinkCommand = () => {
1495
+ const selection = window.getSelection();
1496
+ if (selection && selection.rangeCount > 0) {
1497
+ setSavedRange(selection.getRangeAt(0).cloneRange());
1498
+ } else {
1499
+ setSavedRange(null);
1500
+ }
1501
+ setShowLinkDialog(true);
1502
+ };
1503
+ const handleLinkSubmit = () => {
1504
+ if (linkUrl) {
1505
+ const selection = window.getSelection();
1506
+ if (selection && savedRange) {
1507
+ try {
1508
+ selection.removeAllRanges();
1509
+ selection.addRange(savedRange);
1510
+ } catch (e) {
1511
+ }
1512
+ }
1513
+ const currentSelection = window.getSelection();
1514
+ if (currentSelection && !currentSelection.isCollapsed) {
1515
+ execCommand("createLink", linkUrl);
1516
+ } else {
1517
+ execCommand("insertHTML", `<a href="${linkUrl.replace(/"/g, "&quot;")}" target="_blank" rel="noopener noreferrer">${linkUrl}</a>`);
1518
+ }
1519
+ setLinkUrl("");
1520
+ setSavedRange(null);
1521
+ }
1522
+ setShowLinkDialog(false);
1523
+ };
1524
+ const handleLinkCancel = () => {
1525
+ setLinkUrl("");
1526
+ setSavedRange(null);
1527
+ setShowLinkDialog(false);
1528
+ };
1529
+ const handleSelectionChange = () => {
1530
+ const selection = window.getSelection();
1531
+ onSelectionChange?.(selection);
1532
+ if (!selection || selection.isCollapsed) {
1533
+ setShowToolbar(false);
1534
+ return;
1535
+ }
1536
+ const range = selection.getRangeAt(0);
1537
+ if (!editorRef.current?.contains(range.commonAncestorContainer)) {
1538
+ setShowToolbar(false);
1539
+ return;
1540
+ }
1541
+ updateActiveFormats();
1542
+ updateToolbarPosition(range);
1543
+ setShowToolbar(true);
1544
+ };
1545
+ const updateToolbarPosition = (range) => {
1546
+ const rect = range.getBoundingClientRect();
1547
+ const editorRect = editorRef.current?.getBoundingClientRect();
1548
+ if (!editorRect) return;
1549
+ setToolbarPosition({
1550
+ top: rect.top - editorRect.top - 48,
1551
+ // 48px above selection
1552
+ left: rect.left - editorRect.left + rect.width / 2
1553
+ });
1554
+ };
1555
+ const updateActiveFormats = () => {
1556
+ const formats = /* @__PURE__ */ new Set();
1557
+ if (document.queryCommandState("bold")) formats.add("bold");
1558
+ if (document.queryCommandState("italic")) formats.add("italic");
1559
+ if (document.queryCommandState("underline")) formats.add("underline");
1560
+ if (document.queryCommandState("strikeThrough"))
1561
+ formats.add("strikethrough");
1562
+ if (document.queryCommandState("insertOrderedList"))
1563
+ formats.add("orderedList");
1564
+ if (document.queryCommandState("insertUnorderedList"))
1565
+ formats.add("unorderedList");
1566
+ setActiveFormats(formats);
1567
+ };
1568
+ const handleEditorFocus = (event) => {
1569
+ onFocus?.(event);
1570
+ document.addEventListener("selectionchange", handleSelectionChange);
1571
+ };
1572
+ const handleEditorBlur = (event) => {
1573
+ setTimeout(() => {
1574
+ const activeElement = document.activeElement;
1575
+ const isToolbarClick = activeElement?.closest(".rich-textarea__toolbar");
1576
+ if (!isToolbarClick) {
1577
+ setShowToolbar(false);
1578
+ document.removeEventListener(
1579
+ "selectionchange",
1580
+ handleSelectionChange
1581
+ );
1582
+ }
1583
+ }, 150);
1584
+ onBlur?.(event);
1585
+ };
1586
+ const handleEditorClick = (event) => {
1587
+ const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0;
1588
+ const modKey = isMac ? event.metaKey : event.ctrlKey;
1589
+ if (modKey) {
1590
+ const target = event.target;
1591
+ let linkElement = null;
1592
+ if (target.tagName === "A") {
1593
+ linkElement = target;
1594
+ } else {
1595
+ linkElement = target.closest("a");
1596
+ }
1597
+ if (linkElement && linkElement.href) {
1598
+ event.preventDefault();
1599
+ window.open(linkElement.href, "_blank", "noopener,noreferrer");
1600
+ }
1601
+ }
1602
+ };
1603
+ const handleEditorMouseMove = (event) => {
1604
+ const target = event.target;
1605
+ let linkElement = null;
1606
+ if (target.tagName === "A") {
1607
+ linkElement = target;
1608
+ } else {
1609
+ linkElement = target.closest("a");
1610
+ }
1611
+ if (linkElement && linkElement.href) {
1612
+ const rect = linkElement.getBoundingClientRect();
1613
+ const editorRect = editorRef.current?.getBoundingClientRect();
1614
+ if (editorRect) {
1615
+ setTooltipPosition({
1616
+ x: rect.left - editorRect.left,
1617
+ y: rect.top - editorRect.top + 32
1618
+ });
1619
+ setShowLinkTooltip(true);
1620
+ }
1621
+ } else {
1622
+ setShowLinkTooltip(false);
1623
+ }
1624
+ };
1625
+ const handleEditorMouseLeave = () => {
1626
+ setShowLinkTooltip(false);
1627
+ };
1628
+ const renderToolbarButton = (option) => {
1629
+ const isActive = activeFormats.has(option);
1630
+ const handleClick = () => {
1631
+ switch (option) {
1632
+ case "bold":
1633
+ execCommand("bold");
1634
+ break;
1635
+ case "italic":
1636
+ execCommand("italic");
1637
+ break;
1638
+ case "underline":
1639
+ execCommand("underline");
1640
+ break;
1641
+ case "strikethrough":
1642
+ execCommand("strikeThrough");
1643
+ break;
1644
+ case "link":
1645
+ handleLinkCommand();
1646
+ break;
1647
+ case "unlink":
1648
+ execCommand("unlink");
1649
+ break;
1650
+ case "orderedList":
1651
+ execCommand("insertOrderedList");
1652
+ break;
1653
+ case "unorderedList":
1654
+ execCommand("insertUnorderedList");
1655
+ break;
1656
+ case "code":
1657
+ execCommand("formatBlock", "<pre>");
1658
+ break;
1659
+ case "blockquote":
1660
+ execCommand("formatBlock", "<blockquote>");
1661
+ break;
1662
+ case "h1":
1663
+ execCommand("formatBlock", "<h1>");
1664
+ break;
1665
+ case "h2":
1666
+ execCommand("formatBlock", "<h2>");
1667
+ break;
1668
+ case "h3":
1669
+ execCommand("formatBlock", "<h3>");
1670
+ break;
1671
+ default:
1672
+ break;
1673
+ }
1674
+ };
1675
+ return /* @__PURE__ */ jsx26(
1676
+ "button",
1677
+ {
1678
+ type: "button",
1679
+ className: `rich-textarea__toolbar-button ${isActive ? "rich-textarea__toolbar-button--active" : ""}`,
1680
+ onClick: handleClick,
1681
+ onMouseDown: (e) => e.preventDefault(),
1682
+ "aria-label": option,
1683
+ "aria-pressed": isActive,
1684
+ children: /* @__PURE__ */ jsx26(Icon, { name: `${iconMap[option]}`, size: 16 })
1685
+ },
1686
+ option
1687
+ );
1688
+ };
1689
+ const editorClasses = [
1690
+ "rich-textarea",
1691
+ shouldScroll && "scrollable",
1692
+ disabled && "rich-textarea--disabled",
1693
+ readOnly && "rich-textarea--readonly",
1694
+ className
1695
+ ].filter(Boolean).join(" ");
1696
+ const isEmpty = !currentHTML || currentHTML === "<br>";
1697
+ return /* @__PURE__ */ jsxs13("div", { className: `rich-textarea-container ${showTopToolbar ? "rich-textarea-container--with-top-toolbar" : ""} ${isHoldingCtrl ? "rich-textarea-container--holding-ctrl" : ""}`, style, children: [
1698
+ showTopToolbar && !readOnly && !disabled && /* @__PURE__ */ jsx26(FloatingBar, { position: "top", className: "rich-textarea__top-toolbar", children: /* @__PURE__ */ jsxs13("div", { className: "rich-textarea__top-toolbar-content", children: [
1699
+ /* @__PURE__ */ jsx26(
1700
+ Select,
1701
+ {
1702
+ options: headingOptions,
1703
+ value: currentHeading,
1704
+ onChange: (value2) => applyHeading(value2),
1705
+ placeholder: "Format",
1706
+ className: "rich-textarea__heading-select"
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ jsx26("div", { className: "rich-textarea__top-toolbar-buttons", children: toolbarOptions.map((option) => {
1710
+ const isActive = activeFormats.has(option);
1711
+ return /* @__PURE__ */ jsx26(
1712
+ Button,
1713
+ {
1714
+ variant: isActive ? "primary" : "ghost",
1715
+ size: "sm",
1716
+ onClick: () => {
1717
+ switch (option) {
1718
+ case "bold":
1719
+ execCommand("bold");
1720
+ break;
1721
+ case "italic":
1722
+ execCommand("italic");
1723
+ break;
1724
+ case "underline":
1725
+ execCommand("underline");
1726
+ break;
1727
+ case "strikethrough":
1728
+ execCommand("strikeThrough");
1729
+ break;
1730
+ case "link":
1731
+ handleLinkCommand();
1732
+ break;
1733
+ case "unlink":
1734
+ execCommand("unlink");
1735
+ break;
1736
+ case "orderedList":
1737
+ execCommand("insertOrderedList");
1738
+ break;
1739
+ case "unorderedList":
1740
+ execCommand("insertUnorderedList");
1741
+ break;
1742
+ case "code":
1743
+ execCommand("formatBlock", "<pre>");
1744
+ break;
1745
+ case "blockquote":
1746
+ execCommand("formatBlock", "<blockquote>");
1747
+ break;
1748
+ case "h1":
1749
+ applyHeading("h1");
1750
+ break;
1751
+ case "h2":
1752
+ applyHeading("h2");
1753
+ break;
1754
+ case "h3":
1755
+ applyHeading("h3");
1756
+ break;
1757
+ default:
1758
+ break;
1759
+ }
1760
+ },
1761
+ onMouseDown: (e) => e.preventDefault(),
1762
+ "aria-label": option,
1763
+ "aria-pressed": isActive,
1764
+ children: /* @__PURE__ */ jsx26(Icon, { name: `${iconMap[option]}`, size: 16 })
1765
+ },
1766
+ option
1767
+ );
1768
+ }) })
1769
+ ] }) }),
1770
+ /* @__PURE__ */ jsx26(
1771
+ "div",
1772
+ {
1773
+ ref: editorRef,
1774
+ className: editorClasses,
1775
+ contentEditable: !disabled && !readOnly,
1776
+ role: "textbox",
1777
+ "aria-label": ariaLabel,
1778
+ "aria-describedby": ariaDescribedBy,
1779
+ "aria-multiline": "true",
1780
+ "aria-readonly": readOnly,
1781
+ "aria-disabled": disabled,
1782
+ onInput: handleInput,
1783
+ onPaste: handlePaste,
1784
+ onKeyDown: handleKeyDown,
1785
+ onClick: handleEditorClick,
1786
+ onMouseMove: handleEditorMouseMove,
1787
+ onMouseLeave: handleEditorMouseLeave,
1788
+ onFocus: handleEditorFocus,
1789
+ onBlur: handleEditorBlur,
1790
+ "data-placeholder": isEmpty ? placeholder : void 0,
1791
+ suppressContentEditableWarning: true
1792
+ }
1793
+ ),
1794
+ showToolbar && !readOnly && !disabled && /* @__PURE__ */ jsx26(
1795
+ "div",
1796
+ {
1797
+ className: "rich-textarea__toolbar",
1798
+ style: {
1799
+ top: `${toolbarPosition.top}px`,
1800
+ left: `${toolbarPosition.left}px`
1801
+ },
1802
+ role: "toolbar",
1803
+ "aria-label": "Text formatting",
1804
+ children: toolbarOptions.map(renderToolbarButton)
1805
+ }
1806
+ ),
1807
+ /* @__PURE__ */ jsx26(
1808
+ Dialog,
1809
+ {
1810
+ open: showLinkDialog,
1811
+ onClose: handleLinkCancel,
1812
+ title: "Insert Link",
1813
+ size: "sm",
1814
+ footer: /* @__PURE__ */ jsxs13(Fragment5, { children: [
1815
+ /* @__PURE__ */ jsx26(Button, { variant: "ghost", onClick: handleLinkCancel, children: "Cancel" }),
1816
+ /* @__PURE__ */ jsx26(Button, { variant: "primary", onClick: handleLinkSubmit, children: "Insert" })
1817
+ ] }),
1818
+ children: /* @__PURE__ */ jsx26(
1819
+ InputText,
1820
+ {
1821
+ label: "URL",
1822
+ value: linkUrl,
1823
+ onChange: (e) => setLinkUrl(e.target.value),
1824
+ placeholder: "https://example.com",
1825
+ autoFocus: true,
1826
+ onKeyDown: (e) => {
1827
+ if (e.key === "Enter") {
1828
+ e.preventDefault();
1829
+ handleLinkSubmit();
1830
+ }
1831
+ }
1832
+ }
1833
+ )
1834
+ }
1835
+ ),
1836
+ showLinkTooltip && /* @__PURE__ */ jsxs13(
1837
+ "div",
1838
+ {
1839
+ className: "rich-textarea__link-tooltip",
1840
+ style: {
1841
+ position: "absolute",
1842
+ top: `${tooltipPosition.y}px`,
1843
+ left: `${tooltipPosition.x}px`,
1844
+ backgroundColor: "var(--color-bg-1)",
1845
+ color: "var(--color-foreground-1)",
1846
+ padding: "4px 8px",
1847
+ borderRadius: "4px",
1848
+ fontSize: "12px",
1849
+ whiteSpace: "nowrap",
1850
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
1851
+ zIndex: 1e3,
1852
+ pointerEvents: "none",
1853
+ border: "1px solid var(--color-border-1)"
1854
+ },
1855
+ children: [
1856
+ navigator.platform.toUpperCase().indexOf("MAC") >= 0 ? "CMD" : "CTRL",
1857
+ " + Click to access URL"
1858
+ ]
1859
+ }
1860
+ )
1861
+ ] });
1862
+ }
1863
+ );
1864
+ RichTextarea.displayName = "RichTextarea";
1865
+
1866
+ // src/components/textarea/Textarea.tsx
1867
+ import * as React23 from "react";
1868
+ import { jsx as jsx27, jsxs as jsxs14 } from "react/jsx-runtime";
1869
+ var Textarea = React23.forwardRef(
1870
+ ({
1871
+ label,
1872
+ helperText,
1873
+ error,
1874
+ fullWidth = false,
1875
+ size = "md",
1876
+ className = "",
1877
+ rows = 3,
1878
+ resize = "vertical",
1879
+ style,
1880
+ ...props
1881
+ }, ref) => {
1882
+ const textareaId = React23.useId();
1883
+ const errorId = React23.useId();
1884
+ const helperId = React23.useId();
1885
+ const textareaClasses = [
1886
+ "input-field",
1887
+ "input-field--textarea",
1888
+ `input-field--${size}`,
1889
+ fullWidth && "input-field--full-width",
1890
+ error && "input-field--error",
1891
+ className
1892
+ ].filter(Boolean).join(" ");
1893
+ const containerClasses = [
1894
+ "input-container",
1895
+ fullWidth && "input-container--full-width"
1896
+ ].filter(Boolean).join(" ");
1897
+ return /* @__PURE__ */ jsxs14("div", { className: containerClasses, children: [
1898
+ label && /* @__PURE__ */ jsx27("label", { htmlFor: textareaId, className: "input-label", children: label }),
1899
+ /* @__PURE__ */ jsx27("div", { className: "input-field-wrapper", children: /* @__PURE__ */ jsx27(
1900
+ "textarea",
1901
+ {
1902
+ ...props,
1903
+ ref,
1904
+ id: textareaId,
1905
+ rows,
1906
+ className: textareaClasses,
1907
+ style: {
1908
+ resize,
1909
+ ...style
1910
+ },
1911
+ "aria-invalid": !!error,
1912
+ "aria-describedby": [error && errorId, helperText && helperId].filter(Boolean).join(" ") || void 0
1913
+ }
1914
+ ) }),
1915
+ error && /* @__PURE__ */ jsx27("div", { id: errorId, className: "input-error", role: "alert", children: error }),
1916
+ helperText && !error && /* @__PURE__ */ jsx27("div", { id: helperId, className: "input-helper", children: helperText })
1917
+ ] });
1918
+ }
1919
+ );
1920
+ Textarea.displayName = "Textarea";
1921
+ export {
1922
+ RichTextarea,
1923
+ Textarea
1924
+ };