@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
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../hooks/useTr.js";
|
|
2
|
+
import { isPermissionDeniedError as t } from "../../utils/permission-error.js";
|
|
3
|
+
import { AlertCircle as n, Lock as r } from "lucide-react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
5
|
//#region src/product-management/shared/components/feedback/ErrorState.tsx
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
return /* @__PURE__ */
|
|
6
|
+
function o({ title: o, message: s, error: c, action: l, deniedTitle: u, deniedMessage: d }) {
|
|
7
|
+
let f = e(), p = o ?? f("errorState.title", "Something went wrong"), m = u ?? f("errorState.deniedTitle", "You don't have access"), h = d ?? f("errorState.deniedMessage", "This area is restricted to platform administrators."), g = t(c, s);
|
|
8
|
+
return /* @__PURE__ */ a("div", {
|
|
8
9
|
className: "flex flex-col items-center justify-center py-12 text-center animate-in fade-in duration-200",
|
|
9
10
|
children: [
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
className: `size-16 rounded-full flex items-center justify-center mb-4 ${
|
|
12
|
-
children:
|
|
11
|
+
/* @__PURE__ */ i("div", {
|
|
12
|
+
className: `size-16 rounded-full flex items-center justify-center mb-4 ${g ? "bg-[var(--color-bg-subtle)]" : "bg-[var(--color-status-error-subtle)]"}`,
|
|
13
|
+
children: g ? /* @__PURE__ */ i(r, {
|
|
13
14
|
size: 32,
|
|
14
15
|
className: "text-text-tertiary"
|
|
15
|
-
}) : /* @__PURE__ */
|
|
16
|
+
}) : /* @__PURE__ */ i(n, {
|
|
16
17
|
size: 32,
|
|
17
18
|
className: "text-[var(--color-status-error)]"
|
|
18
19
|
})
|
|
19
20
|
}),
|
|
20
|
-
/* @__PURE__ */
|
|
21
|
+
/* @__PURE__ */ i("h3", {
|
|
21
22
|
className: "text-lg font-semibold text-text-primary mb-2",
|
|
22
|
-
children:
|
|
23
|
+
children: g ? m : p
|
|
23
24
|
}),
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ i("p", {
|
|
25
26
|
className: "text-sm text-text-tertiary mb-6 max-w-md",
|
|
26
|
-
children:
|
|
27
|
+
children: g ? h : s
|
|
27
28
|
}),
|
|
28
|
-
|
|
29
|
+
l && !g && /* @__PURE__ */ i("button", {
|
|
29
30
|
type: "button",
|
|
30
|
-
onClick:
|
|
31
|
+
onClick: l.onClick,
|
|
31
32
|
className: "\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90\n transition-all duration-200\n font-medium\n ",
|
|
32
|
-
children:
|
|
33
|
+
children: l.label
|
|
33
34
|
})
|
|
34
35
|
]
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
//#endregion
|
|
38
|
-
export {
|
|
39
|
+
export { o as ErrorState };
|
|
39
40
|
|
|
40
41
|
//# sourceMappingURL=ErrorState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorState.js","names":[],"sources":["../../../../../src/product-management/shared/components/feedback/ErrorState.tsx"],"sourcesContent":["import { AlertCircle, Lock } from 'lucide-react';\n\nimport { isPermissionDeniedError } from '../../utils/permission-error';\n\ninterface ErrorStateProps {\n title?: string;\n message: string;\n /**\n * The raw error, when the caller has it. Lets this component tell a denial\n * apart from a genuine failure via the GraphQL `extensions.code` rather than\n * guessing from the message.\n */\n error?: unknown;\n action?: {\n label: string;\n onClick: () => void;\n };\n /** Copy for the access-denied variant; English defaults, translate at the call site. */\n deniedTitle?: string;\n deniedMessage?: string;\n}\n\n/**\n * ErrorState — generic error display.\n *\n *
|
|
1
|
+
{"version":3,"file":"ErrorState.js","names":[],"sources":["../../../../../src/product-management/shared/components/feedback/ErrorState.tsx"],"sourcesContent":["import { AlertCircle, Lock } from 'lucide-react';\n\nimport { isPermissionDeniedError } from '../../utils/permission-error';\nimport { useTr } from '../../hooks/useTr';\n\ninterface ErrorStateProps {\n title?: string;\n message: string;\n /**\n * The raw error, when the caller has it. Lets this component tell a denial\n * apart from a genuine failure via the GraphQL `extensions.code` rather than\n * guessing from the message.\n */\n error?: unknown;\n action?: {\n label: string;\n onClick: () => void;\n };\n /** Copy for the access-denied variant; English defaults, translate at the call site. */\n deniedTitle?: string;\n deniedMessage?: string;\n}\n\n/**\n * ErrorState — generic error display.\n *\n * Defaults are translated through the i18n provider. Callers can pass\n * explicit `title`, `deniedTitle`, and `deniedMessage` props when they need\n * a context-specific string from another namespace.\n *\n * A permission denial renders as its own state: these screens read the platform\n * product catalog, which is restricted to super admins, so a normal user who\n * lands here is not looking at a broken page. Showing \"Something went wrong\"\n * over a Retry button that can never succeed invites them to sit there\n * retrying, so the denial says what it is and drops the action.\n */\nexport function ErrorState({\n title,\n message,\n error,\n action,\n deniedTitle,\n deniedMessage,\n}: ErrorStateProps) {\n const tr = useTr();\n const resolvedTitle = title ?? tr('errorState.title', 'Something went wrong');\n const resolvedDeniedTitle = deniedTitle ?? tr('errorState.deniedTitle', \"You don't have access\");\n const resolvedDeniedMessage =\n deniedMessage ??\n tr('errorState.deniedMessage', 'This area is restricted to platform administrators.');\n\n const denied = isPermissionDeniedError(error, message);\n\n return (\n <div className=\"flex flex-col items-center justify-center py-12 text-center animate-in fade-in duration-200\">\n <div\n className={`size-16 rounded-full flex items-center justify-center mb-4 ${\n denied ? 'bg-[var(--color-bg-subtle)]' : 'bg-[var(--color-status-error-subtle)]'\n }`}\n >\n {denied ? (\n <Lock size={32} className=\"text-text-tertiary\" />\n ) : (\n <AlertCircle size={32} className=\"text-[var(--color-status-error)]\" />\n )}\n </div>\n <h3 className=\"text-lg font-semibold text-text-primary mb-2\">\n {denied ? resolvedDeniedTitle : resolvedTitle}\n </h3>\n <p className=\"text-sm text-text-tertiary mb-6 max-w-md\">\n {denied ? resolvedDeniedMessage : message}\n </p>\n {action && !denied && (\n <button\n type=\"button\"\n onClick={action.onClick}\n className=\"\n inline-flex items-center gap-2 px-4 py-2\n bg-[var(--color-action-primary-bg)]\n text-[var(--color-action-primary-text)]\n rounded-lg\n hover:opacity-90\n transition-all duration-200\n font-medium\n \"\n >\n {action.label}\n </button>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAoCA,SAAgB,EAAW,EACzB,UACA,YACA,UACA,WACA,gBACA,oBACkB;CAClB,IAAM,IAAK,GAAO,EACZ,IAAgB,KAAS,EAAG,oBAAoB,uBAAuB,EACvE,IAAsB,KAAe,EAAG,0BAA0B,wBAAwB,EAC1F,IACJ,KACA,EAAG,4BAA4B,sDAAsD,EAEjF,IAAS,EAAwB,GAAO,EAAQ;AAEtD,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IACE,WAAW,8DACT,IAAS,gCAAgC;cAG1C,IACC,kBAAC,GAAD;KAAM,MAAM;KAAI,WAAU;KAAuB,CAAA,GAEjD,kBAAC,GAAD;KAAa,MAAM;KAAI,WAAU;KAAqC,CAAA;IAEpE,CAAA;GACN,kBAAC,MAAD;IAAI,WAAU;cACX,IAAS,IAAsB;IAC7B,CAAA;GACL,kBAAC,KAAD;IAAG,WAAU;cACV,IAAS,IAAwB;IAChC,CAAA;GACH,KAAU,CAAC,KACV,kBAAC,UAAD;IACE,MAAK;IACL,SAAS,EAAO;IAChB,WAAU;cAUT,EAAO;IACD,CAAA;GAEP"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../hooks/useTr.js";
|
|
2
|
+
import { Loader2 as t } from "lucide-react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
4
|
//#region src/product-management/shared/components/feedback/LoadingState.tsx
|
|
4
|
-
function
|
|
5
|
-
|
|
5
|
+
function i({ message: i }) {
|
|
6
|
+
let a = e(), o = i ?? a("loadingState.message", "Loading...");
|
|
7
|
+
return /* @__PURE__ */ r("div", {
|
|
6
8
|
className: "flex flex-col items-center justify-center py-12 animate-in fade-in duration-200",
|
|
7
|
-
children: [/* @__PURE__ */ t
|
|
9
|
+
children: [/* @__PURE__ */ n(t, {
|
|
8
10
|
size: 48,
|
|
9
11
|
className: "text-[var(--color-status-info)] animate-spin mb-4"
|
|
10
|
-
}), /* @__PURE__ */
|
|
12
|
+
}), /* @__PURE__ */ n("p", {
|
|
11
13
|
className: "text-sm text-text-tertiary",
|
|
12
|
-
children:
|
|
14
|
+
children: o
|
|
13
15
|
})]
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
//#endregion
|
|
17
|
-
export {
|
|
19
|
+
export { i as LoadingState };
|
|
18
20
|
|
|
19
21
|
//# sourceMappingURL=LoadingState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingState.js","names":[],"sources":["../../../../../src/product-management/shared/components/feedback/LoadingState.tsx"],"sourcesContent":["import { Loader2 } from 'lucide-react';\n\ninterface LoadingStateProps {\n message?: string;\n}\n\n/**\n * LoadingState — generic loading indicator.\n *\n *
|
|
1
|
+
{"version":3,"file":"LoadingState.js","names":[],"sources":["../../../../../src/product-management/shared/components/feedback/LoadingState.tsx"],"sourcesContent":["import { Loader2 } from 'lucide-react';\nimport { useTr } from '../../hooks/useTr';\n\ninterface LoadingStateProps {\n message?: string;\n}\n\n/**\n * LoadingState — generic loading indicator.\n *\n * Default message is translated through the i18n provider. Callers can pass\n * an explicit `message` prop when they need a context-specific string from\n * another namespace.\n */\nexport function LoadingState({ message }: LoadingStateProps) {\n const tr = useTr();\n const resolvedMessage = message ?? tr('loadingState.message', 'Loading...');\n return (\n <div className=\"flex flex-col items-center justify-center py-12 animate-in fade-in duration-200\">\n <Loader2 size={48} className=\"text-[var(--color-status-info)] animate-spin mb-4\" />\n <p className=\"text-sm text-text-tertiary\">{resolvedMessage}</p>\n </div>\n );\n}\n"],"mappings":";;;;AAcA,SAAgB,EAAa,EAAE,cAA8B;CAC3D,IAAM,IAAK,GAAO,EACZ,IAAkB,KAAW,EAAG,wBAAwB,aAAa;AAC3E,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,GAAD;GAAS,MAAM;GAAI,WAAU;GAAsD,CAAA,EACnF,kBAAC,KAAD;GAAG,WAAU;aAA8B;GAAoB,CAAA,CAC3D"}
|
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../hooks/useTr.js";
|
|
2
|
+
import { useProduct as t, useProducts as n } from "../../../modules/products/hooks/useProducts.js";
|
|
3
|
+
import { cn as r } from "../../utils/cn.js";
|
|
4
|
+
import { useEffect as i, useState as a } from "react";
|
|
5
|
+
import { Check as o, ChevronsUpDown as s } from "lucide-react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Command as u, CommandEmpty as d, CommandInput as f, CommandItem as p, CommandList as m, Popover as h, PopoverContent as g, PopoverTrigger as _ } from "@burdenoff/fe-libs/ui";
|
|
7
8
|
//#region src/product-management/shared/components/input/ProductCombobox.tsx
|
|
8
|
-
function
|
|
9
|
-
let [n,
|
|
10
|
-
return
|
|
11
|
-
let n = setTimeout(() =>
|
|
9
|
+
function v(e, t) {
|
|
10
|
+
let [n, r] = a(e);
|
|
11
|
+
return i(() => {
|
|
12
|
+
let n = setTimeout(() => r(e), t);
|
|
12
13
|
return () => clearTimeout(n);
|
|
13
14
|
}, [e, t]), n;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
-
let [
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
open:
|
|
16
|
+
function y({ value: i, onChange: y, disabled: b = !1, required: x = !1, placeholder: S = "Select a product…", id: C, error: w }) {
|
|
17
|
+
let [T, E] = a(!1), [D, O] = a(""), k = v(D.trim(), 200), A = e(), { products: j, loading: M } = n(k ? { search: k } : void 0, { limit: 100 }), { product: N, loading: P } = t(i), F = N ? `${N.name} (${N.slug})` : i ? P ? A("productCombobox.loading", "Loading…") : i : S, I = r("w-full flex items-center justify-between gap-2 px-3 py-2", "bg-surface", "border border-default", "rounded-lg", "text-left text-sm text-text-primary", "focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]", "disabled:bg-bg-sunken disabled:cursor-not-allowed", "transition-all duration-200", w && "border-[var(--color-status-error)]", !N && "text-text-tertiary");
|
|
18
|
+
return /* @__PURE__ */ l(h, {
|
|
19
|
+
open: T,
|
|
19
20
|
onOpenChange: (e) => {
|
|
20
|
-
|
|
21
|
+
E(e), e || O("");
|
|
21
22
|
},
|
|
22
|
-
children: [/* @__PURE__ */
|
|
23
|
+
children: [/* @__PURE__ */ c(_, {
|
|
23
24
|
asChild: !0,
|
|
24
|
-
children: /* @__PURE__ */
|
|
25
|
+
children: /* @__PURE__ */ l("button", {
|
|
25
26
|
type: "button",
|
|
26
|
-
id:
|
|
27
|
+
id: C,
|
|
27
28
|
role: "combobox",
|
|
28
|
-
"aria-expanded":
|
|
29
|
-
"aria-required":
|
|
30
|
-
"aria-invalid":
|
|
31
|
-
disabled:
|
|
32
|
-
className:
|
|
33
|
-
children: [/* @__PURE__ */
|
|
29
|
+
"aria-expanded": T,
|
|
30
|
+
"aria-required": x,
|
|
31
|
+
"aria-invalid": w ? !0 : void 0,
|
|
32
|
+
disabled: b,
|
|
33
|
+
className: I,
|
|
34
|
+
children: [/* @__PURE__ */ c("span", {
|
|
34
35
|
className: "truncate",
|
|
35
|
-
children:
|
|
36
|
-
}), /* @__PURE__ */ s
|
|
36
|
+
children: F
|
|
37
|
+
}), /* @__PURE__ */ c(s, {
|
|
37
38
|
size: 16,
|
|
38
39
|
className: "shrink-0 text-text-tertiary",
|
|
39
40
|
"aria-hidden": "true"
|
|
40
41
|
})]
|
|
41
42
|
})
|
|
42
|
-
}), /* @__PURE__ */
|
|
43
|
+
}), /* @__PURE__ */ c(g, {
|
|
43
44
|
align: "start",
|
|
44
45
|
className: "w-[var(--radix-popover-trigger-width)] p-0 border border-default bg-surface",
|
|
45
|
-
children: /* @__PURE__ */
|
|
46
|
+
children: /* @__PURE__ */ l(u, {
|
|
46
47
|
shouldFilter: !1,
|
|
47
48
|
className: "bg-surface text-text-primary",
|
|
48
|
-
children: [/* @__PURE__ */
|
|
49
|
-
value:
|
|
50
|
-
onValueChange:
|
|
51
|
-
placeholder: "Search products…",
|
|
49
|
+
children: [/* @__PURE__ */ c(f, {
|
|
50
|
+
value: D,
|
|
51
|
+
onValueChange: O,
|
|
52
|
+
placeholder: A("productCombobox.searchPlaceholder", "Search products…"),
|
|
52
53
|
className: "text-text-primary placeholder:text-text-tertiary"
|
|
53
|
-
}), /* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
54
|
+
}), /* @__PURE__ */ l(m, { children: [
|
|
55
|
+
/* @__PURE__ */ c(d, {
|
|
55
56
|
className: "text-text-tertiary",
|
|
56
|
-
children:
|
|
57
|
+
children: M ? A("productCombobox.searching", "Searching…") : A("productCombobox.noProductsFound", "No products found.")
|
|
57
58
|
}),
|
|
58
|
-
!
|
|
59
|
+
!x && /* @__PURE__ */ l(p, {
|
|
59
60
|
value: "__none__",
|
|
60
61
|
onSelect: () => {
|
|
61
|
-
|
|
62
|
+
y(""), E(!1);
|
|
62
63
|
},
|
|
63
64
|
className: "text-text-tertiary",
|
|
64
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ c(o, {
|
|
65
66
|
size: 16,
|
|
66
|
-
className:
|
|
67
|
+
className: r("shrink-0", i === "" ? "opacity-100" : "opacity-0"),
|
|
67
68
|
"aria-hidden": "true"
|
|
68
|
-
}), /* @__PURE__ */
|
|
69
|
+
}), /* @__PURE__ */ c("span", {
|
|
69
70
|
className: "truncate italic",
|
|
70
|
-
children: "None"
|
|
71
|
+
children: A("productCombobox.none", "None")
|
|
71
72
|
})]
|
|
72
73
|
}),
|
|
73
|
-
|
|
74
|
+
j.map((e) => /* @__PURE__ */ l(p, {
|
|
74
75
|
value: e.id,
|
|
75
76
|
onSelect: () => {
|
|
76
|
-
|
|
77
|
+
y(e.id), E(!1);
|
|
77
78
|
},
|
|
78
79
|
className: "text-text-primary",
|
|
79
|
-
children: [/* @__PURE__ */
|
|
80
|
+
children: [/* @__PURE__ */ c(o, {
|
|
80
81
|
size: 16,
|
|
81
|
-
className:
|
|
82
|
+
className: r("shrink-0", e.id === i ? "opacity-100" : "opacity-0"),
|
|
82
83
|
"aria-hidden": "true"
|
|
83
|
-
}), /* @__PURE__ */
|
|
84
|
+
}), /* @__PURE__ */ l("span", {
|
|
84
85
|
className: "truncate",
|
|
85
86
|
children: [
|
|
86
87
|
e.name,
|
|
87
88
|
" ",
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ l("span", {
|
|
89
90
|
className: "text-text-tertiary",
|
|
90
91
|
children: [
|
|
91
92
|
"(",
|
|
@@ -102,6 +103,6 @@ function v({ value: r, onChange: v, disabled: y = !1, required: b = !1, placehol
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
//#endregion
|
|
105
|
-
export {
|
|
106
|
+
export { y as ProductCombobox };
|
|
106
107
|
|
|
107
108
|
//# sourceMappingURL=ProductCombobox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductCombobox.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/ProductCombobox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { Check, ChevronsUpDown } from 'lucide-react';\nimport {\n Command,\n CommandEmpty,\n CommandInput,\n CommandItem,\n CommandList,\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@burdenoff/fe-libs/ui';\n\nimport { cn } from '../../utils/cn';\nimport { useProduct, useProducts } from '../../../modules/products/hooks/useProducts';\n\ninterface ProductComboboxProps {\n /** Selected product id (controlled). Empty string = nothing selected. */\n value: string;\n /** Called with the selected product id ('' when cleared). */\n onChange: (id: string) => void;\n disabled?: boolean;\n required?: boolean;\n placeholder?: string;\n /** Id for the trigger button — pairs with an external <label htmlFor>. */\n id?: string;\n /** Optional error message — toggles the invalid border + aria-invalid. */\n error?: string;\n}\n\n/** Debounce a value so each keystroke doesn't fire a query. */\nfunction useDebounced<T>(value: T, ms: number): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n const t = setTimeout(() => setDebounced(value), ms);\n return () => clearTimeout(t);\n }, [value, ms]);\n return debounced;\n}\n\n/**\n * ProductCombobox — searchable single-select for platform products.\n *\n * A button trigger shows the selected product as `name (slug)` (or a\n * placeholder) and opens a Popover with a cmdk Command. Built entirely on the\n * existing fe-libs `ui` primitives (Command + Popover) — no new dependencies.\n *\n * Search is performed **server-side** (`useProducts({ search })`) so any\n * product is reachable, not just the first page — important now that the\n * free-text product-id input was replaced by this control. The current\n * selection's label is resolved independently via `useProduct(value)`, so it\n * renders correctly even while the list is filtered to a different search.\n */\nexport function ProductCombobox({\n value,\n onChange,\n disabled = false,\n required = false,\n placeholder = 'Select a product…',\n id,\n error,\n}: ProductComboboxProps) {\n const [open, setOpen] = useState(false);\n const [search, setSearch] = useState('');\n const debouncedSearch = useDebounced(search.trim(), 200);\n\n // Options: server-side search, so any product is reachable (no client-only cap).\n const { products, loading } = useProducts(\n debouncedSearch ? { search: debouncedSearch } : undefined,\n { limit: 100 }\n );\n\n // Resolve the selected product's label independently of the (searchable) list,\n // so a current selection still shows even when the list is filtered elsewhere.\n const { product: selectedProduct, loading: selectedLoading } = useProduct(value);\n\n // Resolved → name (slug). Still fetching → \"Loading…\". Set but unresolved\n // (e.g. a deleted/stale product id) → show the raw id, not a permanent spinner.\n // Empty → placeholder.\n const triggerLabel = selectedProduct\n ? `${selectedProduct.name} (${selectedProduct.slug})`\n : value\n ? selectedLoading\n ? 'Loading…'\n : value\n : placeholder;\n\n const triggerClassName = cn(\n 'w-full flex items-center justify-between gap-2 px-3 py-2',\n 'bg-surface',\n 'border border-default',\n 'rounded-lg',\n 'text-left text-sm text-text-primary',\n 'focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]',\n 'disabled:bg-bg-sunken disabled:cursor-not-allowed',\n 'transition-all duration-200',\n error && 'border-[var(--color-status-error)]',\n !selectedProduct && 'text-text-tertiary'\n );\n\n return (\n <Popover\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n // Reset the query on close so reopening starts fresh, not pre-filtered.\n if (!next) setSearch('');\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n id={id}\n role=\"combobox\"\n aria-expanded={open}\n aria-required={required}\n aria-invalid={error ? true : undefined}\n disabled={disabled}\n className={triggerClassName}\n >\n <span className=\"truncate\">{triggerLabel}</span>\n <ChevronsUpDown size={16} className=\"shrink-0 text-text-tertiary\" aria-hidden=\"true\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"w-[var(--radix-popover-trigger-width)] p-0 border border-default bg-surface\"\n >\n {/* Search is server-side → disable cmdk's client filter so we render\n exactly what the query returned. */}\n <Command shouldFilter={false} className=\"bg-surface text-text-primary\">\n <CommandInput\n value={search}\n onValueChange={setSearch}\n placeholder
|
|
1
|
+
{"version":3,"file":"ProductCombobox.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/ProductCombobox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { Check, ChevronsUpDown } from 'lucide-react';\nimport {\n Command,\n CommandEmpty,\n CommandInput,\n CommandItem,\n CommandList,\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from '@burdenoff/fe-libs/ui';\n\nimport { cn } from '../../utils/cn';\nimport { useProduct, useProducts } from '../../../modules/products/hooks/useProducts';\nimport { useTr } from '../../hooks/useTr';\n\ninterface ProductComboboxProps {\n /** Selected product id (controlled). Empty string = nothing selected. */\n value: string;\n /** Called with the selected product id ('' when cleared). */\n onChange: (id: string) => void;\n disabled?: boolean;\n required?: boolean;\n placeholder?: string;\n /** Id for the trigger button — pairs with an external <label htmlFor>. */\n id?: string;\n /** Optional error message — toggles the invalid border + aria-invalid. */\n error?: string;\n}\n\n/** Debounce a value so each keystroke doesn't fire a query. */\nfunction useDebounced<T>(value: T, ms: number): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n const t = setTimeout(() => setDebounced(value), ms);\n return () => clearTimeout(t);\n }, [value, ms]);\n return debounced;\n}\n\n/**\n * ProductCombobox — searchable single-select for platform products.\n *\n * A button trigger shows the selected product as `name (slug)` (or a\n * placeholder) and opens a Popover with a cmdk Command. Built entirely on the\n * existing fe-libs `ui` primitives (Command + Popover) — no new dependencies.\n *\n * Search is performed **server-side** (`useProducts({ search })`) so any\n * product is reachable, not just the first page — important now that the\n * free-text product-id input was replaced by this control. The current\n * selection's label is resolved independently via `useProduct(value)`, so it\n * renders correctly even while the list is filtered to a different search.\n */\nexport function ProductCombobox({\n value,\n onChange,\n disabled = false,\n required = false,\n placeholder = 'Select a product…',\n id,\n error,\n}: ProductComboboxProps) {\n const [open, setOpen] = useState(false);\n const [search, setSearch] = useState('');\n const debouncedSearch = useDebounced(search.trim(), 200);\n const tr = useTr();\n\n // Options: server-side search, so any product is reachable (no client-only cap).\n const { products, loading } = useProducts(\n debouncedSearch ? { search: debouncedSearch } : undefined,\n { limit: 100 }\n );\n\n // Resolve the selected product's label independently of the (searchable) list,\n // so a current selection still shows even when the list is filtered elsewhere.\n const { product: selectedProduct, loading: selectedLoading } = useProduct(value);\n\n // Resolved → name (slug). Still fetching → localized \"Loading…\". Set but unresolved\n // (e.g. a deleted/stale product id) → show the raw id, not a permanent spinner.\n // Empty → placeholder.\n const triggerLabel = selectedProduct\n ? `${selectedProduct.name} (${selectedProduct.slug})`\n : value\n ? selectedLoading\n ? tr('productCombobox.loading', 'Loading…')\n : value\n : placeholder;\n\n const triggerClassName = cn(\n 'w-full flex items-center justify-between gap-2 px-3 py-2',\n 'bg-surface',\n 'border border-default',\n 'rounded-lg',\n 'text-left text-sm text-text-primary',\n 'focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]',\n 'disabled:bg-bg-sunken disabled:cursor-not-allowed',\n 'transition-all duration-200',\n error && 'border-[var(--color-status-error)]',\n !selectedProduct && 'text-text-tertiary'\n );\n\n return (\n <Popover\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n // Reset the query on close so reopening starts fresh, not pre-filtered.\n if (!next) setSearch('');\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n id={id}\n role=\"combobox\"\n aria-expanded={open}\n aria-required={required}\n aria-invalid={error ? true : undefined}\n disabled={disabled}\n className={triggerClassName}\n >\n <span className=\"truncate\">{triggerLabel}</span>\n <ChevronsUpDown size={16} className=\"shrink-0 text-text-tertiary\" aria-hidden=\"true\" />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"w-[var(--radix-popover-trigger-width)] p-0 border border-default bg-surface\"\n >\n {/* Search is server-side → disable cmdk's client filter so we render\n exactly what the query returned. */}\n <Command shouldFilter={false} className=\"bg-surface text-text-primary\">\n <CommandInput\n value={search}\n onValueChange={setSearch}\n placeholder={tr('productCombobox.searchPlaceholder', 'Search products…')}\n className=\"text-text-primary placeholder:text-text-tertiary\"\n />\n <CommandList>\n <CommandEmpty className=\"text-text-tertiary\">\n {loading\n ? tr('productCombobox.searching', 'Searching…')\n : tr('productCombobox.noProductsFound', 'No products found.')}\n </CommandEmpty>\n {/* Optional fields need a way back to \"no product\" — emit '' so\n callers like ContentPageForm (productId || undefined) can clear\n an existing association. Hidden when the field is required. */}\n {!required && (\n <CommandItem\n value=\"__none__\"\n onSelect={() => {\n onChange('');\n setOpen(false);\n }}\n className=\"text-text-tertiary\"\n >\n <Check\n size={16}\n className={cn('shrink-0', value === '' ? 'opacity-100' : 'opacity-0')}\n aria-hidden=\"true\"\n />\n <span className=\"truncate italic\">{tr('productCombobox.none', 'None')}</span>\n </CommandItem>\n )}\n {products.map((product) => (\n <CommandItem\n key={product.id}\n value={product.id}\n onSelect={() => {\n onChange(product.id);\n setOpen(false);\n }}\n className=\"text-text-primary\"\n >\n <Check\n size={16}\n className={cn('shrink-0', product.id === value ? 'opacity-100' : 'opacity-0')}\n aria-hidden=\"true\"\n />\n <span className=\"truncate\">\n {product.name} <span className=\"text-text-tertiary\">({product.slug})</span>\n </span>\n </Comm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} from "lucide-react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
3
4
|
//#region src/product-management/shared/components/input/SearchInput.tsx
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function a({ value: a, onChange: o, placeholder: s, clearAriaLabel: c, className: l = "" }) {
|
|
6
|
+
let u = e(), d = s ?? u("searchInput.placeholder", "Search..."), f = c ?? u("searchInput.clearAriaLabel", "Clear search");
|
|
7
|
+
return /* @__PURE__ */ i("div", {
|
|
8
|
+
className: `relative ${l}`,
|
|
7
9
|
children: [
|
|
8
|
-
/* @__PURE__ */
|
|
10
|
+
/* @__PURE__ */ r(t, {
|
|
9
11
|
size: 18,
|
|
10
12
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-text-tertiary"
|
|
11
13
|
}),
|
|
12
|
-
/* @__PURE__ */
|
|
14
|
+
/* @__PURE__ */ r("input", {
|
|
13
15
|
type: "text",
|
|
14
|
-
value:
|
|
15
|
-
onChange: (e) =>
|
|
16
|
-
placeholder:
|
|
16
|
+
value: a,
|
|
17
|
+
onChange: (e) => o(e.target.value),
|
|
18
|
+
placeholder: d,
|
|
17
19
|
className: "\n w-full pl-[3.25rem] pr-10 py-2\n bg-surface\n border border-default\n rounded-lg\n text-text-primary\n placeholder:text-text-tertiary\n focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]\n transition-all duration-200\n "
|
|
18
20
|
}),
|
|
19
|
-
|
|
21
|
+
a && /* @__PURE__ */ r("button", {
|
|
20
22
|
type: "button",
|
|
21
|
-
onClick: () =>
|
|
23
|
+
onClick: () => o(""),
|
|
22
24
|
className: "\n absolute right-3 top-1/2 -translate-y-1/2\n p-1 rounded-md\n text-text-tertiary\n hover:text-text-primary\n hover:bg-bg-sunken\n transition-all duration-200\n ",
|
|
23
|
-
"aria-label":
|
|
24
|
-
children: /* @__PURE__ */ n
|
|
25
|
+
"aria-label": f,
|
|
26
|
+
children: /* @__PURE__ */ r(n, { size: 16 })
|
|
25
27
|
})
|
|
26
28
|
]
|
|
27
29
|
});
|
|
28
30
|
}
|
|
29
31
|
//#endregion
|
|
30
|
-
export {
|
|
32
|
+
export { a as SearchInput };
|
|
31
33
|
|
|
32
34
|
//# sourceMappingURL=SearchInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/SearchInput.tsx"],"sourcesContent":["import { Search, X } from 'lucide-react';\n\ninterface SearchInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n clearAriaLabel?: string;\n className?: string;\n}\n\n/**\n * SearchInput — reusable search input with clear button.\n *\n *
|
|
1
|
+
{"version":3,"file":"SearchInput.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/SearchInput.tsx"],"sourcesContent":["import { Search, X } from 'lucide-react';\nimport { useTr } from '../../hooks/useTr';\n\ninterface SearchInputProps {\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n clearAriaLabel?: string;\n className?: string;\n}\n\n/**\n * SearchInput — reusable search input with clear button.\n *\n * Defaults are translated through the i18n provider. Callers can still pass\n * explicit `placeholder` / `clearAriaLabel` props when they need a\n * context-specific string from another namespace.\n */\nexport function SearchInput({\n value,\n onChange,\n placeholder,\n clearAriaLabel,\n className = '',\n}: SearchInputProps) {\n const tr = useTr();\n const resolvedPlaceholder = placeholder ?? tr('searchInput.placeholder', 'Search...');\n const resolvedClearAriaLabel = clearAriaLabel ?? tr('searchInput.clearAriaLabel', 'Clear search');\n return (\n <div className={`relative ${className}`}>\n <Search size={18} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-text-tertiary\" />\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={resolvedPlaceholder}\n className=\"\n w-full pl-[3.25rem] pr-10 py-2\n bg-surface\n border border-default\n rounded-lg\n text-text-primary\n placeholder:text-text-tertiary\n focus:outline-none focus:ring-2 focus:ring-[var(--color-border-focus)]\n transition-all duration-200\n \"\n />\n {value && (\n <button\n type=\"button\"\n onClick={() => onChange('')}\n className=\"\n absolute right-3 top-1/2 -translate-y-1/2\n p-1 rounded-md\n text-text-tertiary\n hover:text-text-primary\n hover:bg-bg-sunken\n transition-all duration-200\n \"\n aria-label={resolvedClearAriaLabel}\n >\n <X size={16} />\n </button>\n )}\n </div>\n );\n}\n"],"mappings":";;;;AAkBA,SAAgB,EAAY,EAC1B,UACA,aACA,gBACA,mBACA,eAAY,MACO;CACnB,IAAM,IAAK,GAAO,EACZ,IAAsB,KAAe,EAAG,2BAA2B,YAAY,EAC/E,IAAyB,KAAkB,EAAG,8BAA8B,eAAe;AACjG,QACE,kBAAC,OAAD;EAAK,WAAW,YAAY;YAA5B;GACE,kBAAC,GAAD;IAAQ,MAAM;IAAI,WAAU;IAAgE,CAAA;GAC5F,kBAAC,SAAD;IACE,MAAK;IACE;IACP,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM;IACzC,aAAa;IACb,WAAU;IAUV,CAAA;GACD,KACC,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,EAAS,GAAG;IAC3B,WAAU;IAQV,cAAY;cAEZ,kBAAC,GAAD,EAAG,MAAM,IAAM,CAAA;IACR,CAAA;GAEP"}
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../hooks/useTr.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { Tag as n, X as r } from "lucide-react";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
5
|
//#region src/product-management/shared/components/input/TagInput.tsx
|
|
5
|
-
function
|
|
6
|
-
let [
|
|
6
|
+
function o({ value: o, onChange: s, placeholder: c, className: l = "", disabled: u = !1 }) {
|
|
7
|
+
let d = e(), f = c ?? d("tagInput.placeholder", "Add a tag…"), [p, m] = t(""), h = (e) => {
|
|
7
8
|
let t = e.trim().toLowerCase().replace(/\s+/g, "-");
|
|
8
|
-
!t ||
|
|
9
|
-
},
|
|
10
|
-
o
|
|
9
|
+
!t || o.includes(t) || (s([...o, t]), m(""));
|
|
10
|
+
}, g = (e) => {
|
|
11
|
+
s(o.filter((t) => t !== e));
|
|
11
12
|
};
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
+
return /* @__PURE__ */ a("div", {
|
|
13
14
|
className: `
|
|
14
15
|
flex flex-wrap gap-2 items-center
|
|
15
16
|
min-h-[42px] px-3 py-2
|
|
16
17
|
bg-surface border border-default rounded-lg
|
|
17
18
|
focus-within:ring-2 focus-within:ring-[var(--color-border-focus)]
|
|
18
19
|
transition-all duration-200
|
|
19
|
-
${
|
|
20
|
-
${
|
|
20
|
+
${u ? "opacity-50 cursor-not-allowed" : ""}
|
|
21
|
+
${l}
|
|
21
22
|
`,
|
|
22
23
|
children: [
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ i(n, {
|
|
24
25
|
size: 14,
|
|
25
26
|
className: "text-text-tertiary shrink-0"
|
|
26
27
|
}),
|
|
27
|
-
|
|
28
|
+
o.map((e) => /* @__PURE__ */ a("span", {
|
|
28
29
|
className: "\n inline-flex items-center gap-1 px-2 py-0.5\n bg-[var(--color-status-info-subtle)]\n text-[var(--color-status-info)]\n text-xs font-medium rounded-full\n ",
|
|
29
|
-
children: [e, !
|
|
30
|
+
children: [e, !u && /* @__PURE__ */ i("button", {
|
|
30
31
|
type: "button",
|
|
31
|
-
onClick: () =>
|
|
32
|
+
onClick: () => g(e),
|
|
32
33
|
className: "hover:text-[var(--color-status-error)] transition-colors",
|
|
33
|
-
"aria-label":
|
|
34
|
-
children: /* @__PURE__ */ r
|
|
34
|
+
"aria-label": d("tagInput.removeTagAriaLabel", "Remove tag {{tag}}", { tag: e }),
|
|
35
|
+
children: /* @__PURE__ */ i(r, { size: 10 })
|
|
35
36
|
})]
|
|
36
37
|
}, e)),
|
|
37
|
-
!
|
|
38
|
+
!u && /* @__PURE__ */ i("input", {
|
|
38
39
|
type: "text",
|
|
39
|
-
value:
|
|
40
|
-
onChange: (e) =>
|
|
40
|
+
value: p,
|
|
41
|
+
onChange: (e) => m(e.target.value),
|
|
41
42
|
onKeyDown: (e) => {
|
|
42
|
-
e.key === "Enter" || e.key === "," ? (e.preventDefault(),
|
|
43
|
+
e.key === "Enter" || e.key === "," ? (e.preventDefault(), h(p)) : e.key === "Backspace" && !p && o.length > 0 && g(o[o.length - 1]);
|
|
43
44
|
},
|
|
44
|
-
onBlur: () =>
|
|
45
|
-
placeholder:
|
|
45
|
+
onBlur: () => h(p),
|
|
46
|
+
placeholder: o.length === 0 ? f : "",
|
|
46
47
|
className: "\n flex-1 min-w-[100px] bg-transparent\n text-sm text-text-primary placeholder:text-text-tertiary\n outline-none\n "
|
|
47
48
|
})
|
|
48
49
|
]
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
//#endregion
|
|
52
|
-
export {
|
|
53
|
+
export { o as TagInput };
|
|
53
54
|
|
|
54
55
|
//# sourceMappingURL=TagInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagInput.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/TagInput.tsx"],"sourcesContent":["import { useState, type KeyboardEvent } from 'react';\nimport { X, Tag } from 'lucide-react';\n\ninterface TagInputProps {\n value: string[];\n onChange: (tags: string[]) => void;\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nexport function TagInput({\n value,\n onChange,\n placeholder
|
|
1
|
+
{"version":3,"file":"TagInput.js","names":[],"sources":["../../../../../src/product-management/shared/components/input/TagInput.tsx"],"sourcesContent":["import { useState, type KeyboardEvent } from 'react';\nimport { X, Tag } from 'lucide-react';\nimport { useTr } from '../../hooks/useTr';\n\ninterface TagInputProps {\n value: string[];\n onChange: (tags: string[]) => void;\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nexport function TagInput({\n value,\n onChange,\n placeholder,\n className = '',\n disabled = false,\n}: TagInputProps) {\n const tr = useTr();\n const resolvedPlaceholder = placeholder ?? tr('tagInput.placeholder', 'Add a tag…');\n const [input, setInput] = useState('');\n\n const addTag = (raw: string) => {\n const tag = raw.trim().toLowerCase().replace(/\\s+/g, '-');\n if (!tag || value.includes(tag)) return;\n onChange([...value, tag]);\n setInput('');\n };\n\n const removeTag = (tag: string) => {\n onChange(value.filter((t) => t !== tag));\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter' || e.key === ',') {\n e.preventDefault();\n addTag(input);\n } else if (e.key === 'Backspace' && !input && value.length > 0) {\n removeTag(value[value.length - 1]);\n }\n };\n\n return (\n <div\n className={`\n flex flex-wrap gap-2 items-center\n min-h-[42px] px-3 py-2\n bg-surface border border-default rounded-lg\n focus-within:ring-2 focus-within:ring-[var(--color-border-focus)]\n transition-all duration-200\n ${disabled ? 'opacity-50 cursor-not-allowed' : ''}\n ${className}\n `}\n >\n <Tag size={14} className=\"text-text-tertiary shrink-0\" />\n {value.map((tag) => (\n <span\n key={tag}\n className=\"\n inline-flex items-center gap-1 px-2 py-0.5\n bg-[var(--color-status-info-subtle)]\n text-[var(--color-status-info)]\n text-xs font-medium rounded-full\n \"\n >\n {tag}\n {!disabled && (\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n className=\"hover:text-[var(--color-status-error)] transition-colors\"\n aria-label={tr('tagInput.removeTagAriaLabel', 'Remove tag {{tag}}', { tag })}\n >\n <X size={10} />\n </button>\n )}\n </span>\n ))}\n {!disabled && (\n <input\n type=\"text\"\n value={input}\n onChange={(e) => setInput(e.target.value)}\n onKeyDown={handleKeyDown}\n onBlur={() => addTag(input)}\n placeholder={value.length === 0 ? resolvedPlaceholder : ''}\n className=\"\n flex-1 min-w-[100px] bg-transparent\n text-sm text-text-primary placeholder:text-text-tertiary\n outline-none\n \"\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAYA,SAAgB,EAAS,EACvB,UACA,aACA,gB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
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useTr as e } from "./useTr.js";
|
|
2
|
+
import { useCallback as t, useRef as n, useState as r } from "react";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import { AlertDialog as o, AlertDialogAction as s, AlertDialogCancel as c, AlertDialogContent as l, AlertDialogDescription as u, AlertDialogFooter as d, AlertDialogHeader as f, AlertDialogTitle as p } from "@burdenoff/fe-libs/ui";
|
|
4
5
|
//#region src/product-management/shared/hooks/useConfirmDialog.tsx
|
|
5
|
-
function
|
|
6
|
-
let [
|
|
6
|
+
function m() {
|
|
7
|
+
let m = e(), [h, g] = r({
|
|
7
8
|
open: !1,
|
|
8
9
|
title: "",
|
|
9
10
|
message: ""
|
|
10
|
-
}),
|
|
11
|
+
}), _ = n(null), v = t((e) => (g({
|
|
11
12
|
...e,
|
|
12
13
|
open: !0
|
|
13
14
|
}), new Promise((e) => {
|
|
14
|
-
|
|
15
|
-
})), []),
|
|
16
|
-
|
|
15
|
+
_.current = e;
|
|
16
|
+
})), []), y = t((e) => {
|
|
17
|
+
g((e) => ({
|
|
17
18
|
...e,
|
|
18
19
|
open: !1
|
|
19
20
|
}));
|
|
20
|
-
let t =
|
|
21
|
-
|
|
21
|
+
let t = _.current;
|
|
22
|
+
_.current = null, t?.(e);
|
|
22
23
|
}, []);
|
|
23
24
|
return {
|
|
24
|
-
confirm:
|
|
25
|
-
ConfirmDialog: /* @__PURE__ */
|
|
26
|
-
open:
|
|
25
|
+
confirm: v,
|
|
26
|
+
ConfirmDialog: /* @__PURE__ */ i(o, {
|
|
27
|
+
open: h.open,
|
|
27
28
|
onOpenChange: (e) => {
|
|
28
|
-
e ||
|
|
29
|
+
e || y(!1);
|
|
29
30
|
},
|
|
30
|
-
children: /* @__PURE__ */
|
|
31
|
-
onClick: () =>
|
|
32
|
-
children:
|
|
33
|
-
}), /* @__PURE__ */
|
|
34
|
-
onClick: () =>
|
|
35
|
-
className:
|
|
36
|
-
children:
|
|
31
|
+
children: /* @__PURE__ */ a(l, { children: [/* @__PURE__ */ a(f, { children: [/* @__PURE__ */ i(p, { children: h.title }), /* @__PURE__ */ i(u, { children: h.message })] }), /* @__PURE__ */ a(d, { children: [/* @__PURE__ */ i(c, {
|
|
32
|
+
onClick: () => y(!1),
|
|
33
|
+
children: h.cancelButtonTitle ?? m("confirmDialog.cancel", "Cancel")
|
|
34
|
+
}), /* @__PURE__ */ i(s, {
|
|
35
|
+
onClick: () => y(!0),
|
|
36
|
+
className: h.destructive ? "bg-[var(--color-action-danger-bg)] text-[var(--color-action-danger-text)] hover:bg-[var(--color-action-danger-bg-hover)]" : void 0,
|
|
37
|
+
children: h.okButtonTitle ?? m("confirmDialog.ok", "OK")
|
|
37
38
|
})] })] })
|
|
38
39
|
})
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
//#endregion
|
|
42
|
-
export {
|
|
43
|
+
export { m as useConfirmDialog };
|
|
43
44
|
|
|
44
45
|
//# sourceMappingURL=useConfirmDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConfirmDialog.js","names":[],"sources":["../../../../src/product-management/shared/hooks/useConfirmDialog.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '@burdenoff/fe-libs/ui';\n\nexport interface ConfirmDialogOptions {\n title: string;\n message: string;\n okButtonTitle?: string;\n cancelButtonTitle?: string;\n /** Destructive intent styles the confirm action with the danger token. */\n destructive?: boolean;\n}\n\ninterface ConfirmDialogState extends ConfirmDialogOptions {\n open: boolean;\n}\n\n/**\n * Promise-based confirmation backed by fe-libs `AlertDialog`.\n *\n * Drop-in replacement for the web `window.confirm()` fallback used alongside\n * the native bridge: `confirm()` resolves to `true`/`false` exactly like\n * `window.confirm`, so existing `const ok = native === null ? await confirm(...) : native`\n * gates keep their semantics. Render the returned `ConfirmDialog` element once\n * in the component tree.\n */\nexport function useConfirmDialog() {\n const [state, setState] = useState<ConfirmDialogState>({\n open: false,\n title: '',\n message: '',\n });\n const resolverRef = useRef<((value: boolean) => void) | null>(null);\n\n const confirm = useCallback((options: ConfirmDialogOptions): Promise<boolean> => {\n setState({ ...options, open: true });\n return new Promise<boolean>((resolve) => {\n resolverRef.current = resolve;\n });\n }, []);\n\n const settle = useCallback((value: boolean) => {\n setState((prev) => ({ ...prev, open: false }));\n const resolver = resolverRef.current;\n resolverRef.current = null;\n resolver?.(value);\n }, []);\n\n const ConfirmDialog = (\n <AlertDialog\n open={state.open}\n onOpenChange={(next) => {\n if (!next) settle(false);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>{state.title}</AlertDialogTitle>\n <AlertDialogDescription>{state.message}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel onClick={() => settle(false)}>\n {state.cancelButtonTitle ?? 'Cancel'}\n </AlertDialogCancel>\n <AlertDialogAction\n onClick={() => settle(true)}\n className={\n state.destructive\n ? 'bg-[var(--color-action-danger-bg)] text-[var(--color-action-danger-text)] hover:bg-[var(--color-action-danger-bg-hover)]'\n : undefined\n }\n >\n {state.okButtonTitle ?? 'OK'}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n\n return { confirm, ConfirmDialog };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useConfirmDialog.js","names":[],"sources":["../../../../src/product-management/shared/hooks/useConfirmDialog.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from './useTr';\n\nexport interface ConfirmDialogOptions {\n title: string;\n message: string;\n okButtonTitle?: string;\n cancelButtonTitle?: string;\n /** Destructive intent styles the confirm action with the danger token. */\n destructive?: boolean;\n}\n\ninterface ConfirmDialogState extends ConfirmDialogOptions {\n open: boolean;\n}\n\n/**\n * Promise-based confirmation backed by fe-libs `AlertDialog`.\n *\n * Drop-in replacement for the web `window.confirm()` fallback used alongside\n * the native bridge: `confirm()` resolves to `true`/`false` exactly like\n * `window.confirm`, so existing `const ok = native === null ? await confirm(...) : native`\n * gates keep their semantics. Render the returned `ConfirmDialog` element once\n * in the component tree.\n */\nexport function useConfirmDialog() {\n const tr = useTr();\n const [state, setState] = useState<ConfirmDialogState>({\n open: false,\n title: '',\n message: '',\n });\n const resolverRef = useRef<((value: boolean) => void) | null>(null);\n\n const confirm = useCallback((options: ConfirmDialogOptions): Promise<boolean> => {\n setState({ ...options, open: true });\n return new Promise<boolean>((resolve) => {\n resolverRef.current = resolve;\n });\n }, []);\n\n const settle = useCallback((value: boolean) => {\n setState((prev) => ({ ...prev, open: false }));\n const resolver = resolverRef.current;\n resolverRef.current = null;\n resolver?.(value);\n }, []);\n\n const ConfirmDialog = (\n <AlertDialog\n open={state.open}\n onOpenChange={(next) => {\n if (!next) settle(false);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>{state.title}</AlertDialogTitle>\n <AlertDialogDescription>{state.message}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel onClick={() => settle(false)}>\n {state.cancelButtonTitle ?? tr('confirmDialog.cancel', 'Cancel')}\n </AlertDialogCancel>\n <AlertDialogAction\n onClick={() => settle(true)}\n className={\n state.destructive\n ? 'bg-[var(--color-action-danger-bg)] text-[var(--color-action-danger-text)] hover:bg-[var(--color-action-danger-bg-hover)]'\n : undefined\n }\n >\n {state.okButtonTitle ?? tr('confirmDialog.ok', 'OK')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n\n return { confirm, ConfirmDialog };\n}\n"],"mappings":";;;;;AAmCA,SAAgB,IAAmB;CACjC,IAAM,IAAK,GAAO,EACZ,CAAC,GAAO,KAAY,EAA6B;EACrD,MAAM;EACN,OAAO;EACP,SAAS;EACV,CAAC,EACI,IAAc,EAA0C,KAAK,EAE7D,IAAU,GAAa,OAC3B,EAAS;EAAE,GAAG;EAAS,MAAM;EAAM,CAAC,EAC7B,IAAI,SAAkB,MAAY;AACvC,IAAY,UAAU;GACtB,GACD,EAAE,CAAC,EAEA,IAAS,GAAa,MAAmB;AAC7C,KAAU,OAAU;GAAE,GAAG;GAAM,MAAM;GAAO,EAAE;EAC9C,IAAM,IAAW,EAAY;AAE7B,EADA,EAAY,UAAU,MACtB,IAAW,EAAM;IAChB,EAAE,CAAC;AAiCN,QAAO;EAAE;EAAS,eA9BhB,kBAAC,GAAD;GACE,MAAM,EAAM;GACZ,eAAe,MAAS;AACtB,IAAK,KAAM,EAAO,GAAM;;aAG1B,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD,EAAA,UAAmB,EAAM,OAAyB,CAAA,EAClD,kBAAC,GAAD,EAAA,UAAyB,EAAM,SAAiC,CAAA,CAC9C,EAAA,CAAA,EACpB,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;IAAmB,eAAe,EAAO,GAAM;cAC5C,EAAM,qBAAqB,EAAG,wBAAwB,SAAS;IAC9C,CAAA,EACpB,kBAAC,GAAD;IACE,eAAe,EAAO,GAAK;IAC3B,WACE,EAAM,cACF,6HACA,KAAA;cAGL,EAAM,iBAAiB,EAAG,oBAAoB,KAAK;IAClC,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAGE;EAAe"}
|