@alfadocs/ui-kit-debug 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/_chunks/{bishop-score-CMQxsdy4.js → bishop-score-B9tvgoIq.js} +2 -2
  2. package/dist/_chunks/{bishop-score-CMQxsdy4.js.map → bishop-score-B9tvgoIq.js.map} +1 -1
  3. package/dist/_chunks/{bmi-calculator-DuUneHuZ.js → bmi-calculator-DA2NGmVK.js} +2 -2
  4. package/dist/_chunks/{bmi-calculator-DuUneHuZ.js.map → bmi-calculator-DA2NGmVK.js.map} +1 -1
  5. package/dist/_chunks/{calendar-oYWOCrnf.js → calendar-CkuJIg3s.js} +1 -1
  6. package/dist/_chunks/{calendar-oYWOCrnf.js.map → calendar-CkuJIg3s.js.map} +1 -1
  7. package/dist/_chunks/{cycle-calculator-vTtZZAmn.js → cycle-calculator-C_t1Hs8V.js} +2 -2
  8. package/dist/_chunks/{cycle-calculator-vTtZZAmn.js.map → cycle-calculator-C_t1Hs8V.js.map} +1 -1
  9. package/dist/_chunks/date-picker-variants-CXEAx3O_.js.map +1 -1
  10. package/dist/_chunks/{due-date-calculator-CUm5KJbf.js → due-date-calculator-Q8MIwEVV.js} +2 -2
  11. package/dist/_chunks/{due-date-calculator-CUm5KJbf.js.map → due-date-calculator-Q8MIwEVV.js.map} +1 -1
  12. package/dist/_chunks/{fetal-weight-Xf8-ZoDy.js → fetal-weight-D1a6BmM-.js} +2 -2
  13. package/dist/_chunks/{fetal-weight-Xf8-ZoDy.js.map → fetal-weight-D1a6BmM-.js.map} +1 -1
  14. package/dist/_chunks/{gestational-age-calculator-830KJql3.js → gestational-age-calculator-AkNFfZYs.js} +2 -2
  15. package/dist/_chunks/{gestational-age-calculator-830KJql3.js.map → gestational-age-calculator-AkNFfZYs.js.map} +1 -1
  16. package/dist/_chunks/{hcg-doubling-kVOpDfny.js → hcg-doubling-Dg0Hr7ey.js} +2 -2
  17. package/dist/_chunks/{hcg-doubling-kVOpDfny.js.map → hcg-doubling-Dg0Hr7ey.js.map} +1 -1
  18. package/dist/_chunks/{insert-result-njqBthzT.js → insert-result-C1SYdueh.js} +125 -115
  19. package/dist/_chunks/insert-result-C1SYdueh.js.map +1 -0
  20. package/dist/_chunks/{pregnancy-dating-BA37LSkF.js → pregnancy-dating-Dg6dTe1p.js} +2 -2
  21. package/dist/_chunks/{pregnancy-dating-BA37LSkF.js.map → pregnancy-dating-Dg6dTe1p.js.map} +1 -1
  22. package/dist/_chunks/{pregnancy-weight-gain-BMRBeA8V.js → pregnancy-weight-gain-DI7X-0JX.js} +2 -2
  23. package/dist/_chunks/{pregnancy-weight-gain-BMRBeA8V.js.map → pregnancy-weight-gain-DI7X-0JX.js.map} +1 -1
  24. package/dist/_chunks/rich-text-editor-B03qM22-.js +334 -0
  25. package/dist/_chunks/rich-text-editor-B03qM22-.js.map +1 -0
  26. package/dist/_chunks/{unit-converter-BQ6lEYvd.js → unit-converter-3sINXO3m.js} +2 -2
  27. package/dist/_chunks/{unit-converter-BQ6lEYvd.js.map → unit-converter-3sINXO3m.js.map} +1 -1
  28. package/dist/agent-catalog.json +2 -2
  29. package/dist/components/_shared/safe-html.d.ts +1 -1
  30. package/dist/components/bishop-score/index.js +1 -1
  31. package/dist/components/bmi-calculator/index.js +1 -1
  32. package/dist/components/calendar/index.js +1 -1
  33. package/dist/components/cycle-calculator/index.js +1 -1
  34. package/dist/components/due-date-calculator/index.js +1 -1
  35. package/dist/components/fetal-weight/index.js +1 -1
  36. package/dist/components/gestational-age-calculator/index.js +1 -1
  37. package/dist/components/hcg-doubling/index.js +1 -1
  38. package/dist/components/pregnancy-dating/index.js +1 -1
  39. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  40. package/dist/components/rich-text-editor/index.d.ts +2 -2
  41. package/dist/components/rich-text-editor/index.d.ts.map +1 -1
  42. package/dist/components/rich-text-editor/index.js +4 -7
  43. package/dist/components/rich-text-editor/rich-text-editor.agent.d.ts.map +1 -1
  44. package/dist/components/rich-text-editor/rich-text-editor.d.ts +21 -15
  45. package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
  46. package/dist/components/unit-converter/index.js +1 -1
  47. package/dist/hooks/index.d.ts +1 -0
  48. package/dist/hooks/index.d.ts.map +1 -1
  49. package/dist/hooks/index.js +99 -77
  50. package/dist/hooks/index.js.map +1 -1
  51. package/dist/hooks/use-countdown.d.ts +34 -0
  52. package/dist/hooks/use-countdown.d.ts.map +1 -0
  53. package/dist/i18n/locales/ar.d.ts +1 -0
  54. package/dist/i18n/locales/ar.d.ts.map +1 -1
  55. package/dist/i18n/locales/ar.js +1 -0
  56. package/dist/i18n/locales/ar.js.map +1 -1
  57. package/dist/i18n/locales/de.d.ts +1 -0
  58. package/dist/i18n/locales/de.d.ts.map +1 -1
  59. package/dist/i18n/locales/de.js +1 -0
  60. package/dist/i18n/locales/de.js.map +1 -1
  61. package/dist/i18n/locales/el.d.ts +1 -0
  62. package/dist/i18n/locales/el.d.ts.map +1 -1
  63. package/dist/i18n/locales/el.js +1 -0
  64. package/dist/i18n/locales/el.js.map +1 -1
  65. package/dist/i18n/locales/en.d.ts +1 -0
  66. package/dist/i18n/locales/en.d.ts.map +1 -1
  67. package/dist/i18n/locales/en.js +1 -0
  68. package/dist/i18n/locales/en.js.map +1 -1
  69. package/dist/i18n/locales/es.d.ts +1 -0
  70. package/dist/i18n/locales/es.d.ts.map +1 -1
  71. package/dist/i18n/locales/es.js +1 -0
  72. package/dist/i18n/locales/es.js.map +1 -1
  73. package/dist/i18n/locales/fr.d.ts +1 -0
  74. package/dist/i18n/locales/fr.d.ts.map +1 -1
  75. package/dist/i18n/locales/fr.js +1 -0
  76. package/dist/i18n/locales/fr.js.map +1 -1
  77. package/dist/i18n/locales/hi.d.ts +1 -0
  78. package/dist/i18n/locales/hi.d.ts.map +1 -1
  79. package/dist/i18n/locales/hi.js +1 -0
  80. package/dist/i18n/locales/hi.js.map +1 -1
  81. package/dist/i18n/locales/it.d.ts +1 -0
  82. package/dist/i18n/locales/it.d.ts.map +1 -1
  83. package/dist/i18n/locales/it.js +1 -0
  84. package/dist/i18n/locales/it.js.map +1 -1
  85. package/dist/i18n/locales/ja.d.ts +1 -0
  86. package/dist/i18n/locales/ja.d.ts.map +1 -1
  87. package/dist/i18n/locales/ja.js +1 -0
  88. package/dist/i18n/locales/ja.js.map +1 -1
  89. package/dist/i18n/locales/nl.d.ts +1 -0
  90. package/dist/i18n/locales/nl.d.ts.map +1 -1
  91. package/dist/i18n/locales/nl.js +1 -0
  92. package/dist/i18n/locales/nl.js.map +1 -1
  93. package/dist/i18n/locales/pl.d.ts +1 -0
  94. package/dist/i18n/locales/pl.d.ts.map +1 -1
  95. package/dist/i18n/locales/pl.js +1 -0
  96. package/dist/i18n/locales/pl.js.map +1 -1
  97. package/dist/i18n/locales/pt.d.ts +1 -0
  98. package/dist/i18n/locales/pt.d.ts.map +1 -1
  99. package/dist/i18n/locales/pt.js +1 -0
  100. package/dist/i18n/locales/pt.js.map +1 -1
  101. package/dist/i18n/locales/ro.d.ts +1 -0
  102. package/dist/i18n/locales/ro.d.ts.map +1 -1
  103. package/dist/i18n/locales/ro.js +1 -0
  104. package/dist/i18n/locales/ro.js.map +1 -1
  105. package/dist/i18n/locales/ru.d.ts +1 -0
  106. package/dist/i18n/locales/ru.d.ts.map +1 -1
  107. package/dist/i18n/locales/ru.js +1 -0
  108. package/dist/i18n/locales/ru.js.map +1 -1
  109. package/dist/i18n/locales/sq.d.ts +1 -0
  110. package/dist/i18n/locales/sq.d.ts.map +1 -1
  111. package/dist/i18n/locales/sq.js +1 -0
  112. package/dist/i18n/locales/sq.js.map +1 -1
  113. package/dist/i18n/locales/sv.d.ts +1 -0
  114. package/dist/i18n/locales/sv.d.ts.map +1 -1
  115. package/dist/i18n/locales/sv.js +1 -0
  116. package/dist/i18n/locales/sv.js.map +1 -1
  117. package/dist/i18n/locales/tr.d.ts +1 -0
  118. package/dist/i18n/locales/tr.d.ts.map +1 -1
  119. package/dist/i18n/locales/tr.js +1 -0
  120. package/dist/i18n/locales/tr.js.map +1 -1
  121. package/dist/i18n/locales/zh.d.ts +1 -0
  122. package/dist/i18n/locales/zh.d.ts.map +1 -1
  123. package/dist/i18n/locales/zh.js +1 -0
  124. package/dist/i18n/locales/zh.js.map +1 -1
  125. package/dist/index.js +143 -146
  126. package/dist/locales/ar.json +1 -0
  127. package/dist/locales/de.json +1 -0
  128. package/dist/locales/el.json +1 -0
  129. package/dist/locales/en.json +1 -0
  130. package/dist/locales/es.json +1 -0
  131. package/dist/locales/fr.json +1 -0
  132. package/dist/locales/hi.json +1 -0
  133. package/dist/locales/it.json +1 -0
  134. package/dist/locales/ja.json +1 -0
  135. package/dist/locales/nl.json +1 -0
  136. package/dist/locales/pl.json +1 -0
  137. package/dist/locales/pt.json +1 -0
  138. package/dist/locales/ro.json +1 -0
  139. package/dist/locales/ru.json +1 -0
  140. package/dist/locales/sq.json +1 -0
  141. package/dist/locales/sv.json +1 -0
  142. package/dist/locales/tr.json +1 -0
  143. package/dist/locales/zh.json +1 -0
  144. package/dist/safe-html/index.js.map +1 -1
  145. package/dist/tokens.css +23 -25
  146. package/package.json +2 -52
  147. package/dist/_chunks/image-C6RM5hfF.js +0 -16
  148. package/dist/_chunks/image-C6RM5hfF.js.map +0 -1
  149. package/dist/_chunks/insert-result-njqBthzT.js.map +0 -1
  150. package/dist/_chunks/rich-text-editor-DhGIBd4a.js +0 -921
  151. package/dist/_chunks/rich-text-editor-DhGIBd4a.js.map +0 -1
@@ -1,921 +0,0 @@
1
- import { jsxs as k, jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as se, useId as re, useMemo as I, useState as H, useEffect as w, useRef as B, useImperativeHandle as ie, useCallback as R } from "react";
3
- import { useEditor as oe, EditorContent as ne } from "@tiptap/react";
4
- import ae from "@tiptap/starter-kit";
5
- import de from "@tiptap/extension-link";
6
- import ce from "@tiptap/extension-image";
7
- import { Table as le } from "@tiptap/extension-table";
8
- import ue from "@tiptap/extension-table-row";
9
- import me from "@tiptap/extension-table-cell";
10
- import fe from "@tiptap/extension-table-header";
11
- import { Markdown as he } from "tiptap-markdown";
12
- import pe from "./purify.es-Cm3utOpm.js";
13
- import { c as S } from "./index-D2ZczOXr.js";
14
- import { useTranslation as U } from "react-i18next";
15
- import * as z from "@radix-ui/react-dialog";
16
- import { u as be } from "./registry-nPAVE19X.js";
17
- import { s as ve } from "./safe-image-src-DstKgCo7.js";
18
- import { X as ge } from "./x-CCcI3eJp.js";
19
- import { C as ke } from "./chevron-down-BX_NP2Yh.js";
20
- import { c as m } from "./createLucideIcon-CrFbzy84.js";
21
- import { I as ye } from "./image-C6RM5hfF.js";
22
- /**
23
- * @license lucide-react v1.8.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */
28
- const xe = [
29
- [
30
- "path",
31
- { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
32
- ]
33
- ], ze = m("bold", xe);
34
- /**
35
- * @license lucide-react v1.8.0 - ISC
36
- *
37
- * This source code is licensed under the ISC license.
38
- * See the LICENSE file in the root directory of this source tree.
39
- */
40
- const we = [
41
- ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
42
- ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
43
- ], Me = m("code", we);
44
- /**
45
- * @license lucide-react v1.8.0 - ISC
46
- *
47
- * This source code is licensed under the ISC license.
48
- * See the LICENSE file in the root directory of this source tree.
49
- */
50
- const Ne = [
51
- ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
52
- ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
53
- ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
54
- ], Ae = m("italic", Ne);
55
- /**
56
- * @license lucide-react v1.8.0 - ISC
57
- *
58
- * This source code is licensed under the ISC license.
59
- * See the LICENSE file in the root directory of this source tree.
60
- */
61
- const Ce = [
62
- ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
63
- ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
64
- ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
65
- ], Le = m("link-2", Ce);
66
- /**
67
- * @license lucide-react v1.8.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */
72
- const Te = [
73
- ["path", { d: "M11 5h10", key: "1cz7ny" }],
74
- ["path", { d: "M11 12h10", key: "1438ji" }],
75
- ["path", { d: "M11 19h10", key: "11t30w" }],
76
- ["path", { d: "M4 4h1v5", key: "10yrso" }],
77
- ["path", { d: "M4 9h2", key: "r1h2o0" }],
78
- ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
79
- ], Re = m("list-ordered", Te);
80
- /**
81
- * @license lucide-react v1.8.0 - ISC
82
- *
83
- * This source code is licensed under the ISC license.
84
- * See the LICENSE file in the root directory of this source tree.
85
- */
86
- const _e = [
87
- ["path", { d: "M3 5h.01", key: "18ugdj" }],
88
- ["path", { d: "M3 12h.01", key: "nlz23k" }],
89
- ["path", { d: "M3 19h.01", key: "noohij" }],
90
- ["path", { d: "M8 5h13", key: "1pao27" }],
91
- ["path", { d: "M8 12h13", key: "1za7za" }],
92
- ["path", { d: "M8 19h13", key: "m83p4d" }]
93
- ], Ie = m("list", _e);
94
- /**
95
- * @license lucide-react v1.8.0 - ISC
96
- *
97
- * This source code is licensed under the ISC license.
98
- * See the LICENSE file in the root directory of this source tree.
99
- */
100
- const je = [["path", { d: "M5 12h14", key: "1ays0h" }]], He = m("minus", je);
101
- /**
102
- * @license lucide-react v1.8.0 - ISC
103
- *
104
- * This source code is licensed under the ISC license.
105
- * See the LICENSE file in the root directory of this source tree.
106
- */
107
- const Be = [
108
- [
109
- "path",
110
- {
111
- d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
112
- key: "rib7q0"
113
- }
114
- ],
115
- [
116
- "path",
117
- {
118
- d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
119
- key: "1ymkrd"
120
- }
121
- ]
122
- ], Se = m("quote", Be);
123
- /**
124
- * @license lucide-react v1.8.0 - ISC
125
- *
126
- * This source code is licensed under the ISC license.
127
- * See the LICENSE file in the root directory of this source tree.
128
- */
129
- const De = [
130
- ["path", { d: "M21 7v6h-6", key: "3ptur4" }],
131
- ["path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7", key: "1kgawr" }]
132
- ], $e = m("redo", De);
133
- /**
134
- * @license lucide-react v1.8.0 - ISC
135
- *
136
- * This source code is licensed under the ISC license.
137
- * See the LICENSE file in the root directory of this source tree.
138
- */
139
- const Ee = [
140
- ["path", { d: "M12 3v18", key: "108xh3" }],
141
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
142
- ["path", { d: "M3 9h18", key: "1pudct" }],
143
- ["path", { d: "M3 15h18", key: "5xshup" }]
144
- ], Ke = m("table", Ee);
145
- /**
146
- * @license lucide-react v1.8.0 - ISC
147
- *
148
- * This source code is licensed under the ISC license.
149
- * See the LICENSE file in the root directory of this source tree.
150
- */
151
- const qe = [
152
- ["path", { d: "M3 7v6h6", key: "1v2h90" }],
153
- ["path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13", key: "1r6uu6" }]
154
- ], Fe = m("undo", qe), Ve = {
155
- id: "rich-text-editor",
156
- capabilities: ["edit_inline"],
157
- state: {
158
- html: {
159
- type: "string",
160
- description: "Sanitised HTML representation of the editor content.",
161
- read: (a) => a.getHTML()
162
- },
163
- markdown: {
164
- type: "string",
165
- description: "Markdown representation of the editor content.",
166
- read: (a) => a.getMarkdown()
167
- }
168
- },
169
- actions: {
170
- set_content: {
171
- safety: "destructive",
172
- argsType: "{ html: string }",
173
- description: "Replace the editor content. Loses unsaved input.",
174
- invoke: (a, v) => {
175
- a.setContent(v.html);
176
- }
177
- },
178
- clear: {
179
- safety: "destructive",
180
- description: "Empty the editor. Loses unsaved input.",
181
- invoke: (a) => {
182
- a.clear();
183
- }
184
- },
185
- focus: {
186
- safety: "read",
187
- description: "Move keyboard focus to the editor surface.",
188
- invoke: (a) => {
189
- a.focus();
190
- }
191
- }
192
- },
193
- domHooks: {
194
- root: { attr: "data-component", value: "rich-text-editor" },
195
- instanceId: {
196
- attr: "data-component-id",
197
- sourceProp: "id",
198
- description: "Sourced from the id prop."
199
- }
200
- }
201
- }, Pe = {
202
- FORBID_TAGS: [
203
- "script",
204
- "style",
205
- "iframe",
206
- "object",
207
- "embed",
208
- "form",
209
- "base",
210
- "meta"
211
- ],
212
- FORBID_ATTR: [
213
- "onerror",
214
- "onclick",
215
- "onload",
216
- "onmouseover",
217
- "onfocus",
218
- "onblur"
219
- ]
220
- };
221
- function j(a) {
222
- return pe.sanitize(a, Pe);
223
- }
224
- const Ze = S(
225
- "tiptap-theme-alfadocs ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]"
226
- ), Ue = S(
227
- [
228
- "ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
229
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
230
- "ds:bg-[var(--background)] ds:p-[var(--spacing-xs)]"
231
- ].join(" "),
232
- {
233
- variants: {
234
- direction: {
235
- ltr: "",
236
- rtl: "ds:flex-row-reverse"
237
- }
238
- },
239
- defaultVariants: { direction: "ltr" }
240
- }
241
- ), G = S(
242
- [
243
- "ds:inline-flex ds:items-center ds:justify-center",
244
- "ds:[min-block-size:var(--min-target-size)]",
245
- "ds:[min-inline-size:var(--min-target-size)]",
246
- "ds:gap-[var(--spacing-xs)]",
247
- "ds:rounded-[var(--radius-sm)] ds:bg-transparent ds:text-[var(--foreground)]",
248
- "ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
249
- "ds:hover:bg-[var(--muted)]",
250
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
251
- "ds:focus-visible:outline-solid",
252
- "ds:focus-visible:outline-[var(--ring)]",
253
- "ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
254
- "ds:forced-colors:focus-visible:outline-[CanvasText]",
255
- "ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]"
256
- ].join(" "),
257
- {
258
- variants: {
259
- pressed: {
260
- true: "ds:bg-[var(--muted)] ds:text-[var(--primary)]",
261
- false: ""
262
- },
263
- disabled: {
264
- true: "ds:opacity-[var(--opacity-50)] ds:cursor-not-allowed",
265
- false: ""
266
- }
267
- },
268
- defaultVariants: { pressed: !1, disabled: !1 }
269
- }
270
- ), Ge = S(
271
- [
272
- "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
273
- "ds:bg-[var(--background)] ds:text-[var(--foreground)]"
274
- ].join(" ")
275
- ), Qe = {
276
- minimal: ["bold", "italic", "link"],
277
- standard: [
278
- "bold",
279
- "italic",
280
- "link",
281
- "heading",
282
- "bulletList",
283
- "orderedList",
284
- "quote"
285
- ],
286
- full: [
287
- "bold",
288
- "italic",
289
- "link",
290
- "heading",
291
- "bulletList",
292
- "orderedList",
293
- "quote",
294
- "image",
295
- "table",
296
- "codeBlock",
297
- "horizontalRule",
298
- "undo",
299
- "redo"
300
- ]
301
- };
302
- function Xe({
303
- editor: a,
304
- registerRef: v,
305
- tabIndex: l,
306
- onFocus: h,
307
- onKeyDown: _,
308
- label: M,
309
- disabled: i,
310
- pressed: D
311
- }) {
312
- const [y, N] = H(!1), A = B(null);
313
- w(() => {
314
- if (!y) return;
315
- function c($) {
316
- const g = $.target;
317
- A.current && g && !A.current.contains(g) && N(!1);
318
- }
319
- return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
320
- }, [y]);
321
- function o(c) {
322
- a.chain().focus().toggleHeading({ level: c }).run(), N(!1);
323
- }
324
- return /* @__PURE__ */ k("div", { ref: A, className: "ds:relative ds:inline-flex", children: [
325
- /* @__PURE__ */ k(
326
- "button",
327
- {
328
- type: "button",
329
- ref: v,
330
- tabIndex: l,
331
- onFocus: h,
332
- onKeyDown: _,
333
- onClick: () => {
334
- i || N((c) => !c);
335
- },
336
- "aria-haspopup": "listbox",
337
- "aria-expanded": y,
338
- "aria-disabled": i || void 0,
339
- "aria-label": M,
340
- title: M,
341
- className: G({ pressed: D, disabled: i }),
342
- children: [
343
- /* @__PURE__ */ r(
344
- "span",
345
- {
346
- "aria-hidden": "true",
347
- className: "ds:text-[length:var(--font-size-sm)] ds:font-semibold",
348
- children: "H"
349
- }
350
- ),
351
- /* @__PURE__ */ r(
352
- ke,
353
- {
354
- "aria-hidden": "true",
355
- className: "ds:block-size-4 ds:inline-size-4"
356
- }
357
- )
358
- ]
359
- }
360
- ),
361
- y && !i ? /* @__PURE__ */ r(
362
- "ul",
363
- {
364
- role: "listbox",
365
- "aria-label": M,
366
- className: [
367
- "ds:absolute ds:top-full ds:mt-[var(--spacing-xs)] ds:start-0 ds:z-[var(--z-dropdown)]",
368
- "ds:[min-inline-size:8rem] ds:rounded-[var(--radius-md)]",
369
- "ds:border ds:border-[color:var(--border)] ds:bg-[var(--background)]",
370
- "ds:shadow-[var(--shadow-lg)] ds:p-[var(--spacing-xs)]"
371
- ].join(" "),
372
- children: [1, 2, 3].map((c) => /* @__PURE__ */ r("li", { role: "none", children: /* @__PURE__ */ r(
373
- "button",
374
- {
375
- type: "button",
376
- role: "option",
377
- "aria-selected": a.isActive("heading", { level: c }) || void 0,
378
- onClick: () => o(c),
379
- className: [
380
- "ds:flex ds:w-full ds:items-center",
381
- "ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
382
- "ds:[min-block-size:var(--min-target-size)]",
383
- "ds:rounded-[var(--radius-sm)] ds:text-start",
384
- "ds:hover:bg-[var(--muted)]",
385
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
386
- "ds:focus-visible:outline-solid",
387
- "ds:focus-visible:outline-[var(--ring)]",
388
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
389
- ].join(" "),
390
- children: `H${c}`
391
- }
392
- ) }, c))
393
- }
394
- ) : null
395
- ] });
396
- }
397
- function Ye({
398
- open: a,
399
- onOpenChange: v
400
- }) {
401
- const { t: l } = U();
402
- return /* @__PURE__ */ r(z.Root, { open: a, onOpenChange: v, children: /* @__PURE__ */ k(z.Portal, { children: [
403
- /* @__PURE__ */ r(
404
- z.Overlay,
405
- {
406
- className: [
407
- "ds:fixed ds:inset-0 ds:z-[var(--z-modal-backdrop)]",
408
- "ds:bg-[var(--background)]/[var(--opacity-70)]",
409
- "ds:backdrop-blur-sm"
410
- ].join(" ")
411
- }
412
- ),
413
- /* @__PURE__ */ k(
414
- z.Content,
415
- {
416
- className: [
417
- "ds:fixed ds:z-[var(--z-modal)]",
418
- "ds:start-1/2 ds:top-1/2 ds:-translate-x-1/2 ds:-translate-y-1/2",
419
- "ds:w-[calc(100%-var(--spacing-lg)*2)] ds:max-w-[var(--dialog-width-md)]",
420
- "ds:rounded-[var(--radius-lg)]",
421
- "ds:bg-[var(--popover)] ds:text-[var(--popover-foreground)]",
422
- "ds:shadow-[var(--shadow-xl)] ds:p-[var(--spacing-lg)]",
423
- "ds:focus-visible:outline-none"
424
- ].join(" "),
425
- children: [
426
- /* @__PURE__ */ k("div", { className: "ds:flex ds:items-start ds:justify-between ds:gap-[var(--spacing-md)]", children: [
427
- /* @__PURE__ */ r(z.Title, { className: "type-title-card ds:leading-snug", children: l("editor.shortcuts.title") }),
428
- /* @__PURE__ */ r(z.Close, { asChild: !0, children: /* @__PURE__ */ r(
429
- "button",
430
- {
431
- type: "button",
432
- "aria-label": l("editor.shortcuts.close"),
433
- className: [
434
- "ds:inline-flex ds:items-center ds:justify-center",
435
- "ds:[min-block-size:var(--min-target-size)]",
436
- "ds:[min-inline-size:var(--min-target-size)]",
437
- "ds:rounded-[var(--radius-sm)]",
438
- "ds:hover:bg-[var(--muted)]",
439
- "ds:focus-visible:outline-[length:var(--focus-ring-width)]",
440
- "ds:focus-visible:outline-solid",
441
- "ds:focus-visible:outline-[var(--ring)]",
442
- "ds:forced-colors:focus-visible:outline-[CanvasText]"
443
- ].join(" "),
444
- children: /* @__PURE__ */ r(
445
- ge,
446
- {
447
- "aria-hidden": "true",
448
- className: "ds:block-size-4 ds:inline-size-4"
449
- }
450
- )
451
- }
452
- ) })
453
- ] }),
454
- /* @__PURE__ */ r("ul", { className: "ds:mt-[var(--spacing-md)] ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]", children: [
455
- { key: "editor.shortcuts.bold", combo: "⌘/Ctrl + B" },
456
- { key: "editor.shortcuts.italic", combo: "⌘/Ctrl + I" },
457
- { key: "editor.shortcuts.link", combo: "⌘/Ctrl + K" },
458
- { key: "editor.shortcuts.undo", combo: "⌘/Ctrl + Z" },
459
- { key: "editor.shortcuts.redo", combo: "⌘/Ctrl + Shift + Z" },
460
- { key: "editor.shortcuts.open", combo: "⌘/Ctrl + /" }
461
- ].map((h) => /* @__PURE__ */ k(
462
- "li",
463
- {
464
- className: "ds:flex ds:items-center ds:justify-between ds:gap-[var(--spacing-md)]",
465
- children: [
466
- /* @__PURE__ */ r("span", { className: "ds:text-[length:var(--font-size-sm)]", children: l(h.key) }),
467
- /* @__PURE__ */ r(
468
- "kbd",
469
- {
470
- className: [
471
- "ds:font-[var(--font-mono)] ds:text-[length:var(--font-size-xs)]",
472
- "ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)]",
473
- "ds:rounded-[var(--radius-sm)] ds:bg-[var(--muted)]"
474
- ].join(" "),
475
- children: h.combo
476
- }
477
- )
478
- ]
479
- },
480
- h.key
481
- )) })
482
- ]
483
- }
484
- )
485
- ] }) });
486
- }
487
- const Je = se(
488
- ({
489
- id: a,
490
- defaultValue: v,
491
- value: l,
492
- onChange: h,
493
- toolbar: _ = "standard",
494
- placeholder: M,
495
- readOnly: i = !1,
496
- ariaLabel: D,
497
- minHeight: y,
498
- className: N
499
- }, A) => {
500
- const { t: o } = U(), c = re(), $ = I(
501
- () => `rte-${c.replace(/[^a-zA-Z0-9-_]/g, "")}`,
502
- [c]
503
- ), [g, Q] = H(!1);
504
- w(() => {
505
- typeof document > "u" || Q(document.documentElement.dir === "rtl");
506
- }, []);
507
- const [X, F] = H(!1), C = B(null), L = B(h);
508
- w(() => {
509
- L.current = h;
510
- }, [h]);
511
- const Y = I(() => {
512
- const s = l ?? v ?? "";
513
- return s ? j(s) : "";
514
- }, [v, l]), e = oe({
515
- extensions: [
516
- ae.configure({
517
- heading: { levels: [1, 2, 3] }
518
- }),
519
- de.configure({
520
- protocols: ["http", "https", "mailto", "tel"],
521
- HTMLAttributes: {
522
- rel: "noopener noreferrer",
523
- target: "_blank"
524
- },
525
- validate: (s) => /^(https?:|mailto:|tel:)/i.test(s)
526
- }),
527
- ce,
528
- le.configure({ resizable: !1 }),
529
- ue,
530
- me,
531
- fe,
532
- he.configure({
533
- html: !1,
534
- transformPastedText: !0
535
- })
536
- ],
537
- content: Y,
538
- editable: !i,
539
- immediatelyRender: !1,
540
- shouldRerenderOnTransaction: !0,
541
- editorProps: {
542
- attributes: {
543
- role: "textbox",
544
- "aria-multiline": "true",
545
- "aria-label": D ?? o("editor.placeholder"),
546
- "data-placeholder": M ?? o("editor.placeholder")
547
- },
548
- transformPastedHTML(s) {
549
- return j(s);
550
- },
551
- handleKeyDown(s, t) {
552
- return (t.metaKey || t.ctrlKey) && t.key === "/" ? (t.preventDefault(), F(!0), !0) : !1;
553
- }
554
- },
555
- onUpdate({ editor: s }) {
556
- L.current && (C.current && clearTimeout(C.current), C.current = setTimeout(() => {
557
- var d, p, b;
558
- const t = s.getHTML(), f = ((p = (d = s.storage.markdown) == null ? void 0 : d.getMarkdown) == null ? void 0 : p.call(d)) ?? "";
559
- (b = L.current) == null || b.call(L, { html: t, markdown: f });
560
- }, 100));
561
- }
562
- });
563
- w(() => () => {
564
- C.current && clearTimeout(C.current);
565
- }, []), w(() => {
566
- e && e.setEditable(!i);
567
- }, [e, i]), w(() => {
568
- if (!e || l === void 0 || e.getHTML() === l) return;
569
- const t = j(l);
570
- e.commands.setContent(t, { emitUpdate: !1 });
571
- }, [e, l]);
572
- const E = I(
573
- () => ({
574
- getHTML() {
575
- return (e == null ? void 0 : e.getHTML()) ?? "";
576
- },
577
- getMarkdown() {
578
- var t, u;
579
- return e ? ((u = (t = e.storage.markdown) == null ? void 0 : t.getMarkdown) == null ? void 0 : u.call(t)) ?? "" : "";
580
- },
581
- setContent(s) {
582
- if (!e) return;
583
- const t = j(s);
584
- e.commands.setContent(t);
585
- },
586
- focus() {
587
- e == null || e.commands.focus();
588
- },
589
- clear() {
590
- e == null || e.commands.clearContent();
591
- }
592
- }),
593
- [e]
594
- );
595
- ie(A, () => E, [E]), be(Ve, E, a);
596
- const V = B([]), [T, K] = H(0), q = I(() => Qe[_], [_]), J = R(
597
- (s) => (t) => {
598
- V.current[s] = t;
599
- },
600
- []
601
- ), P = R((s) => {
602
- const t = V.current[s];
603
- t && t.focus();
604
- }, []), Z = R(
605
- (s) => {
606
- const t = q.length;
607
- if (t === 0) return;
608
- const u = g ? "ArrowLeft" : "ArrowRight", f = g ? "ArrowRight" : "ArrowLeft";
609
- let d = null;
610
- s.key === u ? d = (T + 1) % t : s.key === f ? d = (T - 1 + t) % t : s.key === "Home" ? d = 0 : s.key === "End" && (d = t - 1), d !== null && (s.preventDefault(), K(d), P(d));
611
- },
612
- [T, P, g, q.length]
613
- ), W = R(
614
- (s) => {
615
- if (s.preventDefault(), !e) return;
616
- const t = e.getAttributes("link").href, u = window.prompt(o("editor.link.insert"), t ?? "");
617
- if (u === null) return;
618
- const f = u.trim();
619
- if (f === "") {
620
- e.chain().focus().unsetLink().run();
621
- return;
622
- }
623
- /^(https?:|mailto:|tel:)/i.test(f) && e.chain().focus().extendMarkRange("link").setLink({ href: f }).run();
624
- },
625
- [e, o]
626
- ), O = R(() => {
627
- if (!e) return;
628
- const s = window.prompt(o("editor.image.insert"), "");
629
- if (s === null) return;
630
- const t = ve(s);
631
- t && e.chain().focus().setImage({ src: t }).run();
632
- }, [e, o]);
633
- function ee(s, t) {
634
- if (!e) return null;
635
- const u = J(t), f = {
636
- tabIndex: t === T ? 0 : -1,
637
- onFocus: () => K(t),
638
- onKeyDown: Z
639
- }, d = (n, x) => G({ pressed: n, disabled: x });
640
- function p(n) {
641
- return /* @__PURE__ */ r(
642
- "button",
643
- {
644
- type: "button",
645
- ref: u,
646
- ...f,
647
- "aria-label": n.label,
648
- "aria-pressed": n.pressed,
649
- "aria-disabled": n.disabled || void 0,
650
- "aria-keyshortcuts": n.shortcut,
651
- title: n.label,
652
- onClick: (x) => {
653
- x.preventDefault(), n.disabled || n.onActivate();
654
- },
655
- className: d(n.pressed, n.disabled),
656
- children: n.icon
657
- }
658
- );
659
- }
660
- function b(n) {
661
- return /* @__PURE__ */ r(
662
- "button",
663
- {
664
- type: "button",
665
- ref: u,
666
- ...f,
667
- "aria-label": n.label,
668
- "aria-disabled": n.disabled || void 0,
669
- "aria-keyshortcuts": n.shortcut,
670
- title: n.label,
671
- onClick: (x) => {
672
- if (n.disabled) {
673
- x.preventDefault();
674
- return;
675
- }
676
- n.onActivate(x);
677
- },
678
- className: d(!1, n.disabled),
679
- children: n.icon
680
- }
681
- );
682
- }
683
- switch (s) {
684
- case "bold":
685
- return p({
686
- label: o("editor.bold"),
687
- pressed: e.isActive("bold"),
688
- disabled: i,
689
- shortcut: "Control+B Meta+B",
690
- onActivate: () => e.chain().focus().toggleBold().run(),
691
- icon: /* @__PURE__ */ r(
692
- ze,
693
- {
694
- "aria-hidden": "true",
695
- className: "ds:block-size-4 ds:inline-size-4"
696
- }
697
- )
698
- });
699
- case "italic":
700
- return p({
701
- label: o("editor.italic"),
702
- pressed: e.isActive("italic"),
703
- disabled: i,
704
- shortcut: "Control+I Meta+I",
705
- onActivate: () => e.chain().focus().toggleItalic().run(),
706
- icon: /* @__PURE__ */ r(
707
- Ae,
708
- {
709
- "aria-hidden": "true",
710
- className: "ds:block-size-4 ds:inline-size-4"
711
- }
712
- )
713
- });
714
- case "link":
715
- return b({
716
- label: o("editor.link.insert"),
717
- disabled: i,
718
- shortcut: "Control+K Meta+K",
719
- onActivate: W,
720
- icon: /* @__PURE__ */ r(
721
- Le,
722
- {
723
- "aria-hidden": "true",
724
- className: "ds:block-size-4 ds:inline-size-4"
725
- }
726
- )
727
- });
728
- case "heading":
729
- return /* @__PURE__ */ r(
730
- Xe,
731
- {
732
- editor: e,
733
- registerRef: u,
734
- tabIndex: t === T ? 0 : -1,
735
- onFocus: () => K(t),
736
- onKeyDown: Z,
737
- label: o("editor.heading"),
738
- disabled: i,
739
- pressed: e.isActive("heading", { level: 1 }) || e.isActive("heading", { level: 2 }) || e.isActive("heading", { level: 3 })
740
- }
741
- );
742
- case "bulletList":
743
- return p({
744
- label: o("editor.list.bullet"),
745
- pressed: e.isActive("bulletList"),
746
- disabled: i,
747
- onActivate: () => e.chain().focus().toggleBulletList().run(),
748
- icon: /* @__PURE__ */ r(
749
- Ie,
750
- {
751
- "aria-hidden": "true",
752
- className: "ds:block-size-4 ds:inline-size-4"
753
- }
754
- )
755
- });
756
- case "orderedList":
757
- return p({
758
- label: o("editor.list.ordered"),
759
- pressed: e.isActive("orderedList"),
760
- disabled: i,
761
- onActivate: () => e.chain().focus().toggleOrderedList().run(),
762
- icon: /* @__PURE__ */ r(
763
- Re,
764
- {
765
- "aria-hidden": "true",
766
- className: "ds:block-size-4 ds:inline-size-4"
767
- }
768
- )
769
- });
770
- case "quote":
771
- return p({
772
- label: o("editor.quote"),
773
- pressed: e.isActive("blockquote"),
774
- disabled: i,
775
- onActivate: () => e.chain().focus().toggleBlockquote().run(),
776
- icon: /* @__PURE__ */ r(
777
- Se,
778
- {
779
- "aria-hidden": "true",
780
- className: "ds:block-size-4 ds:inline-size-4"
781
- }
782
- )
783
- });
784
- case "image":
785
- return b({
786
- label: o("editor.image.insert"),
787
- disabled: i,
788
- onActivate: O,
789
- icon: /* @__PURE__ */ r(
790
- ye,
791
- {
792
- "aria-hidden": "true",
793
- className: "ds:block-size-4 ds:inline-size-4"
794
- }
795
- )
796
- });
797
- case "table":
798
- return b({
799
- label: o("editor.table.insert"),
800
- disabled: i,
801
- onActivate: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run(),
802
- icon: /* @__PURE__ */ r(
803
- Ke,
804
- {
805
- "aria-hidden": "true",
806
- className: "ds:block-size-4 ds:inline-size-4"
807
- }
808
- )
809
- });
810
- case "codeBlock":
811
- return p({
812
- label: o("editor.codeBlock"),
813
- pressed: e.isActive("codeBlock"),
814
- disabled: i,
815
- onActivate: () => e.chain().focus().toggleCodeBlock().run(),
816
- icon: /* @__PURE__ */ r(
817
- Me,
818
- {
819
- "aria-hidden": "true",
820
- className: "ds:block-size-4 ds:inline-size-4"
821
- }
822
- )
823
- });
824
- case "horizontalRule":
825
- return b({
826
- label: o("editor.horizontalRule"),
827
- disabled: i,
828
- onActivate: () => e.chain().focus().setHorizontalRule().run(),
829
- icon: /* @__PURE__ */ r(
830
- He,
831
- {
832
- "aria-hidden": "true",
833
- className: "ds:block-size-4 ds:inline-size-4"
834
- }
835
- )
836
- });
837
- case "undo":
838
- return b({
839
- label: o("editor.undo"),
840
- disabled: i || !e.can().undo(),
841
- shortcut: "Control+Z Meta+Z",
842
- onActivate: () => e.chain().focus().undo().run(),
843
- icon: /* @__PURE__ */ r(
844
- Fe,
845
- {
846
- "aria-hidden": "true",
847
- className: "ds:block-size-4 ds:inline-size-4"
848
- }
849
- )
850
- });
851
- case "redo":
852
- return b({
853
- label: o("editor.redo"),
854
- disabled: i || !e.can().redo(),
855
- shortcut: "Control+Shift+Z Meta+Shift+Z",
856
- onActivate: () => e.chain().focus().redo().run(),
857
- icon: /* @__PURE__ */ r(
858
- $e,
859
- {
860
- "aria-hidden": "true",
861
- className: "ds:block-size-4 ds:inline-size-4"
862
- }
863
- )
864
- });
865
- default:
866
- return null;
867
- }
868
- }
869
- const te = (() => {
870
- switch (y) {
871
- case "sm":
872
- return "ds:[min-block-size:8rem]";
873
- case "md":
874
- return "ds:[min-block-size:16rem]";
875
- case "lg":
876
- return "ds:[min-block-size:24rem]";
877
- default:
878
- return;
879
- }
880
- })();
881
- return /* @__PURE__ */ k(
882
- "div",
883
- {
884
- id: $,
885
- className: [Ze(), N].filter(Boolean).join(" "),
886
- dir: g ? "rtl" : void 0,
887
- "data-component": "rich-text-editor",
888
- "data-component-id": a,
889
- children: [
890
- i ? null : /* @__PURE__ */ r(
891
- "div",
892
- {
893
- role: "toolbar",
894
- "aria-label": o("editor.toolbarLabel"),
895
- className: Ue({ direction: g ? "rtl" : "ltr" }),
896
- children: q.map((s, t) => /* @__PURE__ */ r("span", { className: "ds:contents", children: ee(s, t) }, s))
897
- }
898
- ),
899
- /* @__PURE__ */ r(
900
- "div",
901
- {
902
- className: [Ge(), te].filter(Boolean).join(" "),
903
- children: /* @__PURE__ */ r(ne, { editor: e })
904
- }
905
- ),
906
- /* @__PURE__ */ r(Ye, { open: X, onOpenChange: F })
907
- ]
908
- }
909
- );
910
- }
911
- );
912
- Je.displayName = "RichTextEditor";
913
- export {
914
- Je as R,
915
- Ue as a,
916
- Ge as e,
917
- Ve as r,
918
- G as t,
919
- Ze as w
920
- };
921
- //# sourceMappingURL=rich-text-editor-DhGIBd4a.js.map