@burdenoff/microfe-product 2026.817.1 → 2026.830.2
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.
- package/dist/index.js +2 -1
- package/dist/product/ProductUserRoot.js +27 -21
- package/dist/product/ProductUserRoot.js.map +1 -1
- package/dist/product/pages/ProductCatalogPage.js +96 -94
- package/dist/product/pages/ProductCatalogPage.js.map +1 -1
- package/dist/product-management/shared/components/AuditHistoryTab.js +33 -32
- package/dist/product-management/shared/components/AuditHistoryTab.js.map +1 -1
- package/dist/product-management/shared/components/feedback/ErrorState.js +19 -18
- package/dist/product-management/shared/components/feedback/ErrorState.js.map +1 -1
- package/dist/product-management/shared/components/feedback/LoadingState.js +10 -8
- package/dist/product-management/shared/components/feedback/LoadingState.js.map +1 -1
- package/dist/product-management/shared/components/input/ProductCombobox.js +49 -48
- package/dist/product-management/shared/components/input/ProductCombobox.js.map +1 -1
- package/dist/product-management/shared/components/input/SearchInput.js +17 -15
- package/dist/product-management/shared/components/input/SearchInput.js.map +1 -1
- package/dist/product-management/shared/components/input/TagInput.js +25 -24
- package/dist/product-management/shared/components/input/TagInput.js.map +1 -1
- package/dist/product-management/shared/hooks/useConfirmDialog.js +24 -23
- package/dist/product-management/shared/hooks/useConfirmDialog.js.map +1 -1
- package/dist/product-management/shared/hooks/useTr.js +3 -3
- package/dist/product-management/shared/hooks/useTr.js.map +1 -1
- package/dist/shared/components/MarkdownEditor.js +102 -80
- package/dist/shared/components/MarkdownEditor.js.map +1 -1
- package/dist/shared/hooks/useTr.js +1 -0
- package/dist/translations/en.js +653 -0
- package/dist/translations/en.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ import { useI18n as t } from "@burdenoff/fe-libs/shared/providers/shell/I18nProv
|
|
|
3
3
|
//#region src/product-management/shared/hooks/useTr.ts
|
|
4
4
|
function n() {
|
|
5
5
|
let { t: n } = t();
|
|
6
|
-
return e((e, t) => {
|
|
7
|
-
let
|
|
8
|
-
return r
|
|
6
|
+
return e((e, t, r) => {
|
|
7
|
+
let i = n(e), a = i === e ? t : i;
|
|
8
|
+
return r ? Object.entries(r).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), a) : a;
|
|
9
9
|
}, [n]);
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTr.js","names":[],"sources":["../../../../src/product-management/shared/hooks/useTr.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\n/**\n * useTr — translation hook with fallback semantics.\n *\n * Wraps `useI18n().t()` so that when a key has no translation (i.e. the\n * provider returns the key itself), the caller's English fallback is used\n * instead. This keeps consumer call sites consistent and avoids leaking\n * untranslated keys into the UI.\n *\n *
|
|
1
|
+
{"version":3,"file":"useTr.js","names":[],"sources":["../../../../src/product-management/shared/hooks/useTr.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\n/**\n * useTr — translation hook with fallback semantics.\n *\n * Wraps `useI18n().t()` so that when a key has no translation (i.e. the\n * provider returns the key itself), the caller's English fallback is used\n * instead. This keeps consumer call sites consistent and avoids leaking\n * untranslated keys into the UI.\n *\n * Supports optional interpolation params using `{{key}}` placeholders.\n *\n * @example\n * const tr = useTr();\n * return <h1>{tr('products.title', 'Products')}</h1>;\n * return <p>{tr('products.delete.confirm', 'Delete {{count}} items?', { count: 5 })}</p>;\n */\nexport function useTr(): (\n key: string,\n fallback: string,\n params?: Record<string, string | number>\n) => string {\n const { t } = useI18n();\n return useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>): string => {\n const translated = t(key);\n const raw = translated === key ? fallback : translated;\n if (!params) return raw;\n return Object.entries(params).reduce(\n (str, [k, v]) => str.replace(new RegExp(`\\\\{\\\\{${k}\\\\}\\\\}`, 'g'), String(v)),\n raw\n );\n },\n [t]\n );\n}\n"],"mappings":";;;AAkBA,SAAgB,IAIJ;CACV,IAAM,EAAE,SAAM,GAAS;AACvB,QAAO,GACJ,GAAa,GAAkB,MAAqD;EACnF,IAAM,IAAa,EAAE,EAAI,EACnB,IAAM,MAAe,IAAM,IAAW;AAE5C,SADK,IACE,OAAO,QAAQ,EAAO,CAAC,QAC3B,GAAK,CAAC,GAAG,OAAO,EAAI,QAAY,OAAO,SAAS,EAAE,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC,EAC5E,EACD,GAJmB;IAMtB,CAAC,EAAE,CACJ"}
|
|
@@ -1,161 +1,183 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../product-management/shared/hooks/useTr.js";
|
|
2
|
+
import "../hooks/useTr.js";
|
|
3
|
+
import { useCallback as t, useRef as n, useState as r } from "react";
|
|
4
|
+
import { Bold as i, Code as a, Eye as o, EyeOff as s, Heading as c, Italic as l, Link as u, List as d, ListOrdered as f, Quote as p } from "lucide-react";
|
|
5
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
6
|
+
import { Markdown as g } from "@burdenoff/fe-libs/shared/components";
|
|
5
7
|
//#region src/shared/components/MarkdownEditor.tsx
|
|
6
|
-
var
|
|
8
|
+
var _ = [
|
|
7
9
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
labelKey: "markdownEditor.toolbar.bold",
|
|
11
|
+
labelFallback: "Bold",
|
|
12
|
+
icon: i,
|
|
10
13
|
prefix: "**",
|
|
11
14
|
suffix: "**",
|
|
12
|
-
|
|
15
|
+
placeholderKey: "markdownEditor.placeholder.bold",
|
|
16
|
+
placeholderFallback: "bold text"
|
|
13
17
|
},
|
|
14
18
|
{
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
labelKey: "markdownEditor.toolbar.italic",
|
|
20
|
+
labelFallback: "Italic",
|
|
21
|
+
icon: l,
|
|
17
22
|
prefix: "*",
|
|
18
23
|
suffix: "*",
|
|
19
|
-
|
|
24
|
+
placeholderKey: "markdownEditor.placeholder.italic",
|
|
25
|
+
placeholderFallback: "italic text"
|
|
20
26
|
},
|
|
21
27
|
{
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
labelKey: "markdownEditor.toolbar.heading",
|
|
29
|
+
labelFallback: "Heading",
|
|
30
|
+
icon: c,
|
|
24
31
|
prefix: "## ",
|
|
25
32
|
suffix: "",
|
|
26
|
-
|
|
33
|
+
placeholderKey: "markdownEditor.placeholder.heading",
|
|
34
|
+
placeholderFallback: "Heading",
|
|
27
35
|
block: !0
|
|
28
36
|
},
|
|
29
37
|
{
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
labelKey: "markdownEditor.toolbar.bulletList",
|
|
39
|
+
labelFallback: "Bullet List",
|
|
40
|
+
icon: d,
|
|
32
41
|
prefix: "- ",
|
|
33
42
|
suffix: "",
|
|
34
|
-
|
|
43
|
+
placeholderKey: "markdownEditor.placeholder.listItem",
|
|
44
|
+
placeholderFallback: "list item",
|
|
35
45
|
block: !0
|
|
36
46
|
},
|
|
37
47
|
{
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
labelKey: "markdownEditor.toolbar.numberedList",
|
|
49
|
+
labelFallback: "Numbered List",
|
|
50
|
+
icon: f,
|
|
40
51
|
prefix: "1. ",
|
|
41
52
|
suffix: "",
|
|
42
|
-
|
|
53
|
+
placeholderKey: "markdownEditor.placeholder.listItem",
|
|
54
|
+
placeholderFallback: "list item",
|
|
43
55
|
block: !0
|
|
44
56
|
},
|
|
45
57
|
{
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
labelKey: "markdownEditor.toolbar.link",
|
|
59
|
+
labelFallback: "Link",
|
|
60
|
+
icon: u,
|
|
48
61
|
prefix: "[",
|
|
49
62
|
suffix: "](url)",
|
|
50
|
-
|
|
63
|
+
placeholderKey: "markdownEditor.placeholder.linkText",
|
|
64
|
+
placeholderFallback: "link text"
|
|
51
65
|
},
|
|
52
66
|
{
|
|
53
|
-
|
|
54
|
-
|
|
67
|
+
labelKey: "markdownEditor.toolbar.codeBlock",
|
|
68
|
+
labelFallback: "Code Block",
|
|
69
|
+
icon: a,
|
|
55
70
|
prefix: "```\n",
|
|
56
71
|
suffix: "\n```",
|
|
57
|
-
|
|
72
|
+
placeholderKey: "markdownEditor.placeholder.code",
|
|
73
|
+
placeholderFallback: "code",
|
|
58
74
|
block: !0
|
|
59
75
|
},
|
|
60
76
|
{
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
labelKey: "markdownEditor.toolbar.quote",
|
|
78
|
+
labelFallback: "Quote",
|
|
79
|
+
icon: p,
|
|
63
80
|
prefix: "> ",
|
|
64
81
|
suffix: "",
|
|
65
|
-
|
|
82
|
+
placeholderKey: "markdownEditor.placeholder.quoteText",
|
|
83
|
+
placeholderFallback: "quote text",
|
|
66
84
|
block: !0
|
|
67
85
|
}
|
|
68
86
|
];
|
|
69
|
-
function
|
|
70
|
-
let
|
|
71
|
-
let t =
|
|
87
|
+
function v({ id: i, value: a, onChange: c, label: l, placeholder: u, disabled: d, error: f, rows: p = 6, minHeight: v = 160, className: y = "", showToolbar: b = !0 }) {
|
|
88
|
+
let x = n(null), [S, C] = r(!1), w = e(), T = t((e) => {
|
|
89
|
+
let t = x.current;
|
|
72
90
|
if (!t) return;
|
|
73
|
-
let { selectionStart: n, selectionEnd: r } = t,
|
|
74
|
-
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
let
|
|
91
|
+
let { selectionStart: n, selectionEnd: r } = t, i = a.substring(n, r), o = w(e.placeholderKey, e.placeholderFallback), s = i || o, l;
|
|
92
|
+
l = e.block && n > 0 && a[n - 1] !== "\n" ? `\n${e.prefix}${s}${e.suffix}` : `${e.prefix}${s}${e.suffix}`;
|
|
93
|
+
let u = a.substring(0, n), d = a.substring(r);
|
|
94
|
+
c(u + l + d);
|
|
95
|
+
let f = n + l.indexOf(s), p = f + s.length;
|
|
78
96
|
requestAnimationFrame(() => {
|
|
79
|
-
t.focus(), t.setSelectionRange(
|
|
97
|
+
t.focus(), t.setSelectionRange(f, p);
|
|
80
98
|
});
|
|
81
|
-
}, [
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
}, [
|
|
100
|
+
a,
|
|
101
|
+
c,
|
|
102
|
+
w
|
|
103
|
+
]);
|
|
104
|
+
return /* @__PURE__ */ h("div", {
|
|
105
|
+
className: `space-y-1.5 ${y}`,
|
|
84
106
|
children: [
|
|
85
|
-
|
|
86
|
-
htmlFor:
|
|
107
|
+
l && /* @__PURE__ */ m("label", {
|
|
108
|
+
htmlFor: i,
|
|
87
109
|
className: "block text-sm font-medium text-text-primary",
|
|
88
|
-
children:
|
|
110
|
+
children: l
|
|
89
111
|
}),
|
|
90
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ h("div", {
|
|
91
113
|
className: "border border-default rounded-lg overflow-hidden",
|
|
92
|
-
children: [
|
|
114
|
+
children: [b && /* @__PURE__ */ h("div", {
|
|
93
115
|
className: "flex items-center justify-between bg-bg-sunken px-2 py-1.5 border-b border-border-seam",
|
|
94
|
-
children: [/* @__PURE__ */
|
|
116
|
+
children: [/* @__PURE__ */ m("div", {
|
|
95
117
|
className: "flex items-center gap-0.5",
|
|
96
|
-
children:
|
|
118
|
+
children: _.map((e) => {
|
|
97
119
|
let t = e.icon;
|
|
98
|
-
return /* @__PURE__ */
|
|
120
|
+
return /* @__PURE__ */ m("button", {
|
|
99
121
|
type: "button",
|
|
100
|
-
title: e.
|
|
101
|
-
onClick: () =>
|
|
102
|
-
disabled:
|
|
122
|
+
title: w(e.labelKey, e.labelFallback),
|
|
123
|
+
onClick: () => T(e),
|
|
124
|
+
disabled: d || S,
|
|
103
125
|
className: "\n inline-flex items-center justify-center\n w-8 h-8\n rounded\n text-text-secondary\n hover:bg-bg-sunken hover:text-text-primary\n transition-all duration-150\n disabled:opacity-50 disabled:cursor-not-allowed\n ",
|
|
104
|
-
children: /* @__PURE__ */
|
|
105
|
-
}, e.
|
|
126
|
+
children: /* @__PURE__ */ m(t, { size: 16 })
|
|
127
|
+
}, e.labelKey);
|
|
106
128
|
})
|
|
107
|
-
}), /* @__PURE__ */
|
|
129
|
+
}), /* @__PURE__ */ h("div", {
|
|
108
130
|
className: "flex items-center gap-1",
|
|
109
|
-
children: [/* @__PURE__ */
|
|
131
|
+
children: [/* @__PURE__ */ h("button", {
|
|
110
132
|
type: "button",
|
|
111
|
-
onClick: () =>
|
|
133
|
+
onClick: () => C(!1),
|
|
112
134
|
className: `
|
|
113
135
|
inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium
|
|
114
136
|
transition-all duration-150
|
|
115
|
-
${
|
|
137
|
+
${S ? "text-text-tertiary hover:text-text-secondary" : "bg-surface text-text-primary shadow-sm"}
|
|
116
138
|
`,
|
|
117
|
-
children: [/* @__PURE__ */
|
|
118
|
-
}), /* @__PURE__ */
|
|
139
|
+
children: [/* @__PURE__ */ m(s, { size: 14 }), w("markdownEditor.edit", "Edit")]
|
|
140
|
+
}), /* @__PURE__ */ h("button", {
|
|
119
141
|
type: "button",
|
|
120
|
-
onClick: () =>
|
|
142
|
+
onClick: () => C(!0),
|
|
121
143
|
className: `
|
|
122
144
|
inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium
|
|
123
145
|
transition-all duration-150
|
|
124
|
-
${
|
|
146
|
+
${S ? "bg-surface text-text-primary shadow-sm" : "text-text-tertiary hover:text-text-secondary"}
|
|
125
147
|
`,
|
|
126
|
-
children: [/* @__PURE__ */
|
|
148
|
+
children: [/* @__PURE__ */ m(o, { size: 14 }), w("markdownEditor.preview", "Preview")]
|
|
127
149
|
})]
|
|
128
150
|
})]
|
|
129
|
-
}), /* @__PURE__ */
|
|
151
|
+
}), /* @__PURE__ */ h("div", {
|
|
130
152
|
className: "relative",
|
|
131
|
-
children: [!
|
|
132
|
-
ref:
|
|
133
|
-
id:
|
|
134
|
-
value:
|
|
135
|
-
onChange: (e) =>
|
|
136
|
-
rows:
|
|
137
|
-
disabled:
|
|
138
|
-
placeholder:
|
|
153
|
+
children: [!S && /* @__PURE__ */ m("textarea", {
|
|
154
|
+
ref: x,
|
|
155
|
+
id: i,
|
|
156
|
+
value: a,
|
|
157
|
+
onChange: (e) => c(e.target.value),
|
|
158
|
+
rows: p,
|
|
159
|
+
disabled: d,
|
|
160
|
+
placeholder: u,
|
|
139
161
|
className: "\n w-full px-4 py-3\n bg-surface\n text-text-primary\n placeholder:text-text-tertiary\n focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\n disabled:bg-bg-sunken disabled:cursor-not-allowed\n font-mono text-sm\n resize-y\n transition-all duration-200\n ",
|
|
140
|
-
style: { minHeight:
|
|
141
|
-
}),
|
|
162
|
+
style: { minHeight: v }
|
|
163
|
+
}), S && /* @__PURE__ */ m("div", {
|
|
142
164
|
className: "\n w-full px-4 py-3\n bg-surface\n text-text-primary\n overflow-y-auto\n prose prose-sm max-w-none\n ",
|
|
143
|
-
style: { minHeight:
|
|
144
|
-
children:
|
|
165
|
+
style: { minHeight: v },
|
|
166
|
+
children: a ? /* @__PURE__ */ m(g, { children: a }) : /* @__PURE__ */ m("p", {
|
|
145
167
|
className: "text-text-tertiary italic",
|
|
146
|
-
children: "Nothing to preview yet."
|
|
168
|
+
children: w("markdownEditor.nothingToPreview", "Nothing to preview yet.")
|
|
147
169
|
})
|
|
148
170
|
})]
|
|
149
171
|
})]
|
|
150
172
|
}),
|
|
151
|
-
|
|
173
|
+
f && /* @__PURE__ */ m("p", {
|
|
152
174
|
className: "text-sm text-[var(--color-status-error)] mt-1",
|
|
153
|
-
children:
|
|
175
|
+
children: f
|
|
154
176
|
})
|
|
155
177
|
]
|
|
156
178
|
});
|
|
157
179
|
}
|
|
158
180
|
//#endregion
|
|
159
|
-
export {
|
|
181
|
+
export { v as MarkdownEditor };
|
|
160
182
|
|
|
161
183
|
//# sourceMappingURL=MarkdownEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.js","names":[],"sources":["../../../src/shared/components/MarkdownEditor.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport {\n Bold,\n Italic,\n Link,\n Code,\n List,\n ListOrdered,\n Heading,\n Quote,\n Eye,\n EyeOff,\n} from 'lucide-react';\nimport { Markdown } from '@burdenoff/fe-libs/shared/components';\n\ninterface MarkdownEditorProps {\n id?: string;\n value: string;\n onChange: (value: string) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n error?: string;\n rows?: number;\n minHeight?: number;\n className?: string;\n showToolbar?: boolean;\n}\n\ntype ToolbarAction = {\n label: string;\n icon: React.ComponentType<{ size?: number }>;\n prefix: string;\n suffix: string;\n placeholder: string;\n block?: boolean;\n};\n\nconst TOOLBAR_ACTIONS: ToolbarAction[] = [\n { label: 'Bold', icon: Bold, prefix: '**', suffix: '**', placeholder: 'bold text' },\n { label: 'Italic', icon: Italic, prefix: '*', suffix: '*', placeholder: 'italic text' },\n {\n label: 'Heading',\n icon: Heading,\n prefix: '## ',\n suffix: '',\n placeholder: 'Heading',\n block: true,\n },\n {\n label: 'Bullet List',\n icon: List,\n prefix: '- ',\n suffix: '',\n placeholder: 'list item',\n block: true,\n },\n {\n label: 'Numbered List',\n icon: ListOrdered,\n prefix: '1. ',\n suffix: '',\n placeholder: 'list item',\n block: true,\n },\n {\n label: 'Link',\n icon: Link,\n prefix: '[',\n suffix: '](url)',\n placeholder: 'link text',\n },\n {\n label: 'Code Block',\n icon: Code,\n prefix: '```\\n',\n suffix: '\\n```',\n placeholder: 'code',\n block: true,\n },\n {\n label: 'Quote',\n icon: Quote,\n prefix: '> ',\n suffix: '',\n placeholder: 'quote text',\n block: true,\n },\n];\n\nexport function MarkdownEditor({\n id,\n value,\n onChange,\n label,\n placeholder,\n disabled,\n error,\n rows = 6,\n minHeight = 160,\n className = '',\n showToolbar = true,\n}: MarkdownEditorProps) {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [showPreview, setShowPreview] = useState(false);\n\n const insertMarkdown = useCallback(\n (action: ToolbarAction) => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n\n const { selectionStart, selectionEnd } = textarea;\n const selectedText = value.substring(selectionStart, selectionEnd);\n const textToWrap = selectedText || action.placeholder;\n\n let insertion: string;\n if (action.block && selectionStart > 0 && value[selectionStart - 1] !== '\\n') {\n insertion = `\\n${action.prefix}${textToWrap}${action.suffix}`;\n } else {\n insertion = `${action.prefix}${textToWrap}${action.suffix}`;\n }\n\n const before = value.substring(0, selectionStart);\n const after = value.substring(selectionEnd);\n const newValue = before + insertion + after;\n\n onChange(newValue);\n\n const prefixLen = insertion.indexOf(textToWrap);\n const newCursorStart = selectionStart + prefixLen;\n const newCursorEnd = newCursorStart + textToWrap.length;\n\n requestAnimationFrame(() => {\n textarea.focus();\n textarea.setSelectionRange(newCursorStart, newCursorEnd);\n });\n },\n [value, onChange]\n );\n\n const toolbarButtonClassName = `\n inline-flex items-center justify-center\n w-8 h-8\n rounded\n text-text-secondary\n hover:bg-bg-sunken hover:text-text-primary\n transition-all duration-150\n disabled:opacity-50 disabled:cursor-not-allowed\n `;\n\n return (\n <div className={`space-y-1.5 ${className}`}>\n {label && (\n <label htmlFor={id} className=\"block text-sm font-medium text-text-primary\">\n {label}\n </label>\n )}\n\n <div className=\"border border-default rounded-lg overflow-hidden\">\n {showToolbar && (\n <div className=\"flex items-center justify-between bg-bg-sunken px-2 py-1.5 border-b border-border-seam\">\n <div className=\"flex items-center gap-0.5\">\n {TOOLBAR_ACTIONS.map((action) => {\n const IconComponent = action.icon;\n return (\n <button\n key={action.label}\n type=\"button\"\n title={action.label}\n onClick={() => insertMarkdown(action)}\n disabled={disabled || showPreview}\n className={toolbarButtonClassName}\n >\n <IconComponent size={16} />\n </button>\n );\n })}\n </div>\n\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={() => setShowPreview(false)}\n className={`\n inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium\n transition-all duration-150\n ${\n !showPreview\n ? 'bg-surface text-text-primary shadow-sm'\n : 'text-text-tertiary hover:text-text-secondary'\n }\n `}\n >\n <EyeOff size={14} />\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => setShowPreview(true)}\n className={`\n inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium\n transition-all duration-150\n ${\n showPreview\n ? 'bg-surface text-text-primary shadow-sm'\n : 'text-text-tertiary hover:text-text-secondary'\n }\n `}\n >\n <Eye size={14} />\n Preview\n </button>\n </div>\n </div>\n )}\n\n <div className=\"relative\">\n {!showPreview && (\n <textarea\n ref={textareaRef}\n id={id}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n rows={rows}\n disabled={disabled}\n placeholder={placeholder}\n className=\"\n w-full px-4 py-3\n bg-surface\n text-text-primary\n placeholder:text-text-tertiary\n focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\n disabled:bg-bg-sunken disabled:cursor-not-allowed\n font-mono text-sm\n resize-y\n transition-all duration-200\n \"\n style={{ minHeight }}\n />\n )}\n\n {showPreview && (\n <div\n className=\"\n w-full px-4 py-3\n bg-surface\n text-text-primary\n overflow-y-auto\n prose prose-sm max-w-none\n \"\n style={{ minHeight }}\n >\n {value ? (\n <Markdown>{value}</Markdown>\n ) : (\n <p className=\"text-text-tertiary italic\">Nothing to preview yet.</p>\n )}\n </div>\n )}\n </div>\n </div>\n\n {error && <p className=\"text-sm text-[var(--color-status-error)] mt-1\">{error}</p>}\n </div>\n );\n}\n"],"mappings":";;;;;AAsCA,IAAM,IAAmC;CACvC;EAAE,OAAO;EAAQ,MAAM;EAAM,QAAQ;EAAM,QAAQ;EAAM,aAAa;EAAa;CACnF;EAAE,OAAO;EAAU,MAAM;EAAQ,QAAQ;EAAK,QAAQ;EAAK,aAAa;EAAe;CACvF;EACE,OAAO;EACP,MAAM;EACN,QAAQ;EACR,QAAQ;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{"version":3,"file":"MarkdownEditor.js","names":[],"sources":["../../../src/shared/components/MarkdownEditor.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport {\n Bold,\n Italic,\n Link,\n Code,\n List,\n ListOrdered,\n Heading,\n Quote,\n Eye,\n EyeOff,\n} from 'lucide-react';\nimport { Markdown } from '@burdenoff/fe-libs/shared/components';\nimport { useTr } from '../hooks/useTr';\n\ninterface MarkdownEditorProps {\n id?: string;\n value: string;\n onChange: (value: string) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n error?: string;\n rows?: number;\n minHeight?: number;\n className?: string;\n showToolbar?: boolean;\n}\n\ntype ToolbarAction = {\n labelKey: string;\n labelFallback: string;\n icon: React.ComponentType<{ size?: number }>;\n prefix: string;\n suffix: string;\n placeholderKey: string;\n placeholderFallback: string;\n block?: boolean;\n};\n\nconst TOOLBAR_ACTIONS: ToolbarAction[] = [\n {\n labelKey: 'markdownEditor.toolbar.bold',\n labelFallback: 'Bold',\n icon: Bold,\n prefix: '**',\n suffix: '**',\n placeholderKey: 'markdownEditor.placeholder.bold',\n placeholderFallback: 'bold text',\n },\n {\n labelKey: 'markdownEditor.toolbar.italic',\n labelFallback: 'Italic',\n icon: Italic,\n prefix: '*',\n suffix: '*',\n placeholderKey: 'markdownEditor.placeholder.italic',\n placeholderFallback: 'italic text',\n },\n {\n labelKey: 'markdownEditor.toolbar.heading',\n labelFallback: 'Heading',\n icon: Heading,\n prefix: '## ',\n suffix: '',\n placeholderKey: 'markdownEditor.placeholder.heading',\n placeholderFallback: 'Heading',\n block: true,\n },\n {\n labelKey: 'markdownEditor.toolbar.bulletList',\n labelFallback: 'Bullet List',\n icon: List,\n prefix: '- ',\n suffix: '',\n placeholderKey: 'markdownEditor.placeholder.listItem',\n placeholderFallback: 'list item',\n block: true,\n },\n {\n labelKey: 'markdownEditor.toolbar.numberedList',\n labelFallback: 'Numbered List',\n icon: ListOrdered,\n prefix: '1. ',\n suffix: '',\n placeholderKey: 'markdownEditor.placeholder.listItem',\n placeholderFallback: 'list item',\n block: true,\n },\n {\n labelKey: 'markdownEditor.toolbar.link',\n labelFallback: 'Link',\n icon: Link,\n prefix: '[',\n suffix: '](url)',\n placeholderKey: 'markdownEditor.placeholder.linkText',\n placeholderFallback: 'link text',\n },\n {\n labelKey: 'markdownEditor.toolbar.codeBlock',\n labelFallback: 'Code Block',\n icon: Code,\n prefix: '```\\n',\n suffix: '\\n```',\n placeholderKey: 'markdownEditor.placeholder.code',\n placeholderFallback: 'code',\n block: true,\n },\n {\n labelKey: 'markdownEditor.toolbar.quote',\n labelFallback: 'Quote',\n icon: Quote,\n prefix: '> ',\n suffix: '',\n placeholderKey: 'markdownEditor.placeholder.quoteText',\n placeholderFallback: 'quote text',\n block: true,\n },\n];\n\nexport function MarkdownEditor({\n id,\n value,\n onChange,\n label,\n placeholder,\n disabled,\n error,\n rows = 6,\n minHeight = 160,\n className = '',\n showToolbar = true,\n}: MarkdownEditorProps) {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [showPreview, setShowPreview] = useState(false);\n const tr = useTr();\n\n const insertMarkdown = useCallback(\n (action: ToolbarAction) => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n\n const { selectionStart, selectionEnd } = textarea;\n const selectedText = value.substring(selectionStart, selectionEnd);\n const placeholderText = tr(action.placeholderKey, action.placeholderFallback);\n const textToWrap = selectedText || placeholderText;\n\n let insertion: string;\n if (action.block && selectionStart > 0 && value[selectionStart - 1] !== '\\n') {\n insertion = `\\n${action.prefix}${textToWrap}${action.suffix}`;\n } else {\n insertion = `${action.prefix}${textToWrap}${action.suffix}`;\n }\n\n const before = value.substring(0, selectionStart);\n const after = value.substring(selectionEnd);\n const newValue = before + insertion + after;\n\n onChange(newValue);\n\n const prefixLen = insertion.indexOf(textToWrap);\n const newCursorStart = selectionStart + prefixLen;\n const newCursorEnd = newCursorStart + textToWrap.length;\n\n requestAnimationFrame(() => {\n textarea.focus();\n textarea.setSelectionRange(newCursorStart, newCursorEnd);\n });\n },\n [value, onChange, tr]\n );\n\n const toolbarButtonClassName = `\n inline-flex items-center justify-center\n w-8 h-8\n rounded\n text-text-secondary\n hover:bg-bg-sunken hover:text-text-primary\n transition-all duration-150\n disabled:opacity-50 disabled:cursor-not-allowed\n `;\n\n return (\n <div className={`space-y-1.5 ${className}`}>\n {label && (\n <label htmlFor={id} className=\"block text-sm font-medium text-text-primary\">\n {label}\n </label>\n )}\n\n <div className=\"border border-default rounded-lg overflow-hidden\">\n {showToolbar && (\n <div className=\"flex items-center justify-between bg-bg-sunken px-2 py-1.5 border-b border-border-seam\">\n <div className=\"flex items-center gap-0.5\">\n {TOOLBAR_ACTIONS.map((action) => {\n const IconComponent = action.icon;\n const actionLabel = tr(action.labelKey, action.labelFallback);\n return (\n <button\n key={action.labelKey}\n type=\"button\"\n title={actionLabel}\n onClick={() => insertMarkdown(action)}\n disabled={disabled || showPreview}\n className={toolbarButtonClassName}\n >\n <IconComponent size={16} />\n </button>\n );\n })}\n </div>\n\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={() => setShowPreview(false)}\n className={`\n inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium\n transition-all duration-150\n ${\n !showPreview\n ? 'bg-surface text-text-primary shadow-sm'\n : 'text-text-tertiary hover:text-text-secondary'\n }\n `}\n >\n <EyeOff size={14} />\n {tr('markdownEditor.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n onClick={() => setShowPreview(true)}\n className={`\n inline-flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium\n transition-all duration-150\n ${\n showPreview\n ? 'bg-surface text-text-primary shadow-sm'\n : 'text-text-tertiary hover:text-text-secondary'\n }\n `}\n >\n <Eye size={14} />\n {tr('markdownEditor.preview', 'Preview')}\n </button>\n </div>\n </div>\n )}\n\n <div className=\"relative\">\n {!showPreview && (\n <textarea\n ref={textareaRef}\n id={id}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n rows={rows}\n disabled={disabled}\n placeholder={placeholder}\n className=\"\n w-full px-4 py-3\n bg-surface\n text-text-primary\n placeholder:text-text-tertiary\n focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]\n disabled:bg-bg-sunken disabled:cursor-not-allowed\n font-mono text-sm\n resize-y\n transition-all duration-200\n \"\n style={{ minHeight }}\n />\n )}\n\n {showPreview && (\n <div\n className=\"\n w-full px-4 py-3\n bg-surface\n text-text-primary\n overflow-y-auto\n prose prose-sm max-w-none\n \"\n style={{ minHeight }}\n >\n {value ? (\n <Markdown>{value}</Markdown>\n ) : (\n <p className=\"text-text-tertiary italic\">\n {tr('markdownEditor.nothingToPreview', 'Nothing to preview yet.')}\n </p>\n )}\n </div>\n )}\n </div>\n </div>\n\n {error && <p className=\"text-sm text-[var(--color-status-error)] mt-1\">{error}</p>}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAyCA,IAAM,IAAmC;CACvC;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACtB;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACtB;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACrB,OAAO;EACR;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACrB,OAAO;EACR;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACrB,OAAO;EACR;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,gBAAgB;EAChB,qBAAqB;EACtB;CACD;EACE,UAAU;EACV,eAAe;EACf,MAAM;EACN,QAAQ;EACR,Q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