@burdenoff/microfe-botmanor 2026.1120.23 → 2026.1120.25

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 (38) hide show
  1. package/dist/botlit/BotlitRoutes.js +37 -33
  2. package/dist/botlit/BotlitRoutes.js.map +1 -1
  3. package/dist/botlit/components/StoreOwnPackagesCard.d.ts +13 -0
  4. package/dist/botlit/components/StoreOwnPackagesCard.js +101 -0
  5. package/dist/botlit/components/StoreOwnPackagesCard.js.map +1 -0
  6. package/dist/botlit/components/StorePackageDraftCard.d.ts +13 -0
  7. package/dist/botlit/components/StorePackageDraftCard.js +200 -0
  8. package/dist/botlit/components/StorePackageDraftCard.js.map +1 -0
  9. package/dist/botlit/components/StorePolicyBundleCard.d.ts +8 -0
  10. package/dist/botlit/components/StorePolicyBundleCard.js +143 -0
  11. package/dist/botlit/components/StorePolicyBundleCard.js.map +1 -0
  12. package/dist/botlit/components/StorePublishingParts.d.ts +39 -0
  13. package/dist/botlit/components/StorePublishingParts.js +95 -0
  14. package/dist/botlit/components/StorePublishingParts.js.map +1 -0
  15. package/dist/botlit/components/StoreReviewQueueCard.d.ts +13 -0
  16. package/dist/botlit/components/StoreReviewQueueCard.js +131 -0
  17. package/dist/botlit/components/StoreReviewQueueCard.js.map +1 -0
  18. package/dist/botlit/components/StoreSubmissionsCard.d.ts +15 -0
  19. package/dist/botlit/components/StoreSubmissionsCard.js +168 -0
  20. package/dist/botlit/components/StoreSubmissionsCard.js.map +1 -0
  21. package/dist/botlit/hooks/useStorePublishing.d.ts +164 -0
  22. package/dist/botlit/hooks/useStorePublishing.js +234 -0
  23. package/dist/botlit/hooks/useStorePublishing.js.map +1 -0
  24. package/dist/botlit/pages/StorePage.js +89 -82
  25. package/dist/botlit/pages/StorePage.js.map +1 -1
  26. package/dist/botlit/pages/StorePublishingPage.d.ts +3 -0
  27. package/dist/botlit/pages/StorePublishingPage.js +77 -0
  28. package/dist/botlit/pages/StorePublishingPage.js.map +1 -0
  29. package/dist/botlit/pages/index.d.ts +1 -0
  30. package/dist/botlit/utils/storePublishing.d.ts +19 -0
  31. package/dist/botlit/utils/storePublishing.js +65 -0
  32. package/dist/botlit/utils/storePublishing.js.map +1 -0
  33. package/dist/generated/wspace-operations.d.ts +764 -0
  34. package/dist/generated/wspace-operations.js +257 -128
  35. package/dist/generated/wspace-operations.js.map +1 -1
  36. package/dist/generated/wspace-types.d.ts +201 -0
  37. package/dist/generated/wspace-types.js.map +1 -1
  38. package/package.json +1 -1
@@ -0,0 +1,200 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { BOTMANOR_PERMISSIONS as t } from "../permissions/botmanorPermissions.js";
3
+ import { BotmanorPermissionGate as n } from "../permissions/useBotmanorPermissions.js";
4
+ import { Button as r } from "./Button.js";
5
+ import { Card as i, CardContent as a, CardDescription as o, CardHeader as s, CardTitle as c } from "./Card.js";
6
+ import { FormField as l, Input as u, Textarea as d } from "./Input.js";
7
+ import { packageKindLabels as f } from "./StoreDialogs.js";
8
+ import { ValidationPanel as p } from "./StorePublishingParts.js";
9
+ import { KIND_TEMPLATES as m, SELECT_CLASS as h, emptyDraftForm as g, errorMessage as _ } from "../utils/storePublishing.js";
10
+ import { buildManifest as v, parseContentJson as y, useStorePublishingActions as b } from "../hooks/useStorePublishing.js";
11
+ import "../permissions/index.js";
12
+ import { useMemo as x } from "react";
13
+ import { jsx as S, jsxs as C } from "react/jsx-runtime";
14
+ import { FileCheck2 as w } from "lucide-react";
15
+ import { toast as T } from "sonner";
16
+ // src/botlit/components/StorePackageDraftCard.tsx
17
+ var E = ({ form: E, onFormChange: D, validation: O, onValidationChange: k, onSaved: A }) => {
18
+ let j = e(), { validate: M, run: N, pending: P } = b(), F = x(() => f(j), [j]), I = x(() => y(E.content), [E.content]), L = (e) => (t) => D((n) => ({
19
+ ...n,
20
+ [e]: t
21
+ })), R = () => {
22
+ if (!I.value) throw Error(I.error ?? "Invalid content");
23
+ return {
24
+ kind: E.kind,
25
+ slug: E.slug.trim(),
26
+ version: E.version.trim(),
27
+ manifest: v({
28
+ name: E.name,
29
+ description: E.description,
30
+ content: I.value
31
+ }),
32
+ readme: E.readme.trim() || null
33
+ };
34
+ }, z = async () => {
35
+ try {
36
+ k(await M(R()));
37
+ } catch (e) {
38
+ T.error(_(e, j("botlit.storePublish.toast.validateError", "Validation failed to run")));
39
+ }
40
+ }, B = async () => {
41
+ try {
42
+ let e = R(), t = E.id ? await N({
43
+ kind: "update",
44
+ id: E.id,
45
+ draft: e
46
+ }) : await N({
47
+ kind: "create",
48
+ draft: e
49
+ });
50
+ D((e) => ({
51
+ ...e,
52
+ id: t.id
53
+ })), k(t.validation ?? null), T.success(j("botlit.storePublish.toast.saved", "Draft saved")), await A();
54
+ } catch (e) {
55
+ T.error(_(e, j("botlit.storePublish.toast.saveError", "Could not save the draft")));
56
+ }
57
+ }, V = P === null && I.value !== null && E.name.trim() !== "" && E.slug.trim() !== "" && E.version.trim() !== "";
58
+ return /* @__PURE__ */ C(i, {
59
+ "data-testid": "store-publish-form",
60
+ children: [/* @__PURE__ */ C(s, { children: [/* @__PURE__ */ S(c, { children: E.id ? j("botlit.storePublish.form.editTitle", "Edit draft") : j("botlit.storePublish.form.title", "New package") }), /* @__PURE__ */ S(o, { children: j("botlit.storePublish.form.description", "The content is the kind-specific part of the manifest, as JSON.") })] }), /* @__PURE__ */ C(a, {
61
+ className: "space-y-4",
62
+ children: [
63
+ /* @__PURE__ */ C("div", {
64
+ className: "grid gap-4 md:grid-cols-2",
65
+ children: [
66
+ /* @__PURE__ */ S(l, {
67
+ label: j("botlit.storePublish.form.kind", "Kind"),
68
+ htmlFor: "store-publish-kind",
69
+ required: !0,
70
+ children: /* @__PURE__ */ S("select", {
71
+ id: "store-publish-kind",
72
+ className: h,
73
+ value: E.kind,
74
+ onChange: (e) => {
75
+ let t = e.target.value;
76
+ D((e) => ({
77
+ ...e,
78
+ kind: t,
79
+ content: JSON.stringify(m[t] ?? {}, null, 2)
80
+ }));
81
+ },
82
+ children: Object.keys(m).map((e) => /* @__PURE__ */ S("option", {
83
+ value: e,
84
+ children: F[e] ?? e
85
+ }, e))
86
+ })
87
+ }),
88
+ /* @__PURE__ */ S(l, {
89
+ label: j("botlit.storePublish.form.name", "Name"),
90
+ htmlFor: "store-publish-name",
91
+ required: !0,
92
+ children: /* @__PURE__ */ S(u, {
93
+ id: "store-publish-name",
94
+ value: E.name,
95
+ maxLength: 255,
96
+ onChange: (e) => L("name")(e.target.value)
97
+ })
98
+ }),
99
+ /* @__PURE__ */ S(l, {
100
+ label: j("botlit.storePublish.form.slug", "Slug"),
101
+ htmlFor: "store-publish-slug",
102
+ required: !0,
103
+ description: j("botlit.storePublish.form.slugHelp", "Lowercase, optionally scoped: @acme/support-agent"),
104
+ children: /* @__PURE__ */ S(u, {
105
+ id: "store-publish-slug",
106
+ value: E.slug,
107
+ maxLength: 500,
108
+ onChange: (e) => L("slug")(e.target.value)
109
+ })
110
+ }),
111
+ /* @__PURE__ */ S(l, {
112
+ label: j("botlit.storePublish.form.version", "Version"),
113
+ htmlFor: "store-publish-version",
114
+ required: !0,
115
+ description: j("botlit.storePublish.form.versionHelp", "Semantic version, e.g. 1.0.0"),
116
+ children: /* @__PURE__ */ S(u, {
117
+ id: "store-publish-version",
118
+ value: E.version,
119
+ maxLength: 50,
120
+ onChange: (e) => L("version")(e.target.value)
121
+ })
122
+ })
123
+ ]
124
+ }),
125
+ /* @__PURE__ */ S(l, {
126
+ label: j("botlit.storePublish.form.descriptionField", "Description"),
127
+ htmlFor: "store-publish-description",
128
+ children: /* @__PURE__ */ S(u, {
129
+ id: "store-publish-description",
130
+ value: E.description,
131
+ maxLength: 2e3,
132
+ onChange: (e) => L("description")(e.target.value)
133
+ })
134
+ }),
135
+ /* @__PURE__ */ S(l, {
136
+ label: j("botlit.storePublish.form.content", "Content (JSON)"),
137
+ htmlFor: "store-publish-content",
138
+ required: !0,
139
+ error: I.error ?? void 0,
140
+ children: /* @__PURE__ */ S(d, {
141
+ id: "store-publish-content",
142
+ className: "font-mono text-xs",
143
+ rows: 10,
144
+ value: E.content,
145
+ onChange: (e) => L("content")(e.target.value)
146
+ })
147
+ }),
148
+ /* @__PURE__ */ S(l, {
149
+ label: j("botlit.storePublish.form.readme", "Readme (Markdown)"),
150
+ htmlFor: "store-publish-readme",
151
+ children: /* @__PURE__ */ S(d, {
152
+ id: "store-publish-readme",
153
+ rows: 4,
154
+ value: E.readme,
155
+ onChange: (e) => L("readme")(e.target.value)
156
+ })
157
+ }),
158
+ /* @__PURE__ */ S(p, {
159
+ validation: O,
160
+ testId: "store-publish-validation"
161
+ }),
162
+ /* @__PURE__ */ C("div", {
163
+ className: "flex flex-wrap gap-2",
164
+ children: [
165
+ /* @__PURE__ */ C(r, {
166
+ variant: "outline",
167
+ onClick: () => void z(),
168
+ disabled: P !== null || !I.value,
169
+ "data-testid": "store-publish-validate",
170
+ children: [/* @__PURE__ */ S(w, {
171
+ size: 16,
172
+ className: "mr-2"
173
+ }), j("botlit.storePublish.form.validate", "Validate")]
174
+ }),
175
+ /* @__PURE__ */ S(n, {
176
+ permission: E.id ? t.STORE_UPDATE : t.STORE_CREATE,
177
+ children: /* @__PURE__ */ S(r, {
178
+ variant: "primary",
179
+ onClick: () => void B(),
180
+ disabled: !V,
181
+ "data-testid": "store-publish-save",
182
+ children: E.id ? j("botlit.storePublish.form.update", "Save changes") : j("botlit.storePublish.form.save", "Save draft")
183
+ })
184
+ }),
185
+ E.id && /* @__PURE__ */ S(r, {
186
+ variant: "ghost",
187
+ onClick: () => {
188
+ D(g()), k(null);
189
+ },
190
+ children: j("botlit.storePublish.form.new", "Start a new package")
191
+ })
192
+ ]
193
+ })
194
+ ]
195
+ })]
196
+ });
197
+ };
198
+ export { E as StorePackageDraftCard };
199
+
200
+ //# sourceMappingURL=StorePackageDraftCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorePackageDraftCard.js","names":["StorePackageDraftCard","t","useTr","useStorePublishingActions","kindLabels","useMemo","packageKindLabels","content","parseContentJson","form","setField","onFormChange","current","field","value","draftValues","buildManifest","onValidate","validate","error","errorMessage","onSave","values","saved","run","onValidationChange","toast","onSaved","canSave","pending","Card","CardHeader","CardTitle","CardDescription","CardContent","FormField","SELECT_CLASS","kind","event","KIND_TEMPLATES","Input","Textarea","ValidationPanel","Button","FileCheck2","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","emptyDraftForm"],"sources":["../../../src/botlit/components/StorePackageDraftCard.tsx"],"sourcesContent":["/**\n * Store package draft form (BOFF-15360)\n * @module botlit/components\n *\n * Create or edit a package draft: kind, name, slug, version, description,\n * the kind-specific content as JSON, and a readme. Validate runs the\n * server-side validation without saving; Save stores the draft.\n */\n\nimport { useMemo, type Dispatch, type FC, type SetStateAction } from 'react';\nimport { FileCheck2 } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { Button } from './Button';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { FormField, Input, Textarea } from './Input';\nimport { packageKindLabels } from './StoreDialogs';\nimport { ValidationPanel } from './StorePublishingParts';\nimport {\n KIND_TEMPLATES,\n SELECT_CLASS,\n emptyDraftForm,\n errorMessage,\n type DraftForm,\n} from '../utils/storePublishing';\nimport {\n buildManifest,\n parseContentJson,\n useStorePublishingActions,\n type PackageDraftValues,\n type PackageValidation,\n} from '../hooks/useStorePublishing';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\ninterface StorePackageDraftCardProps {\n form: DraftForm;\n onFormChange: Dispatch<SetStateAction<DraftForm>>;\n validation: PackageValidation | null;\n onValidationChange: (validation: PackageValidation | null) => void;\n /** Called after a save, so the submissions list can refresh. */\n onSaved: () => Promise<void>;\n}\n\nexport const StorePackageDraftCard: FC<StorePackageDraftCardProps> = ({\n form,\n onFormChange,\n validation,\n onValidationChange,\n onSaved,\n}) => {\n const t = useTr();\n const { validate, run, pending } = useStorePublishingActions();\n const kindLabels = useMemo(() => packageKindLabels(t), [t]);\n const content = useMemo(() => parseContentJson(form.content), [form.content]);\n const setField = (field: keyof DraftForm) => (value: string) =>\n onFormChange((current) => ({ ...current, [field]: value }));\n\n const draftValues = (): PackageDraftValues => {\n if (!content.value) throw new Error(content.error ?? 'Invalid content');\n return {\n kind: form.kind,\n slug: form.slug.trim(),\n version: form.version.trim(),\n manifest: buildManifest({\n name: form.name,\n description: form.description,\n content: content.value,\n }),\n readme: form.readme.trim() || null,\n };\n };\n\n const onValidate = async (): Promise<void> => {\n try {\n onValidationChange(await validate(draftValues()));\n } catch (error) {\n toast.error(\n errorMessage(\n error,\n t('botlit.storePublish.toast.validateError', 'Validation failed to run')\n )\n );\n }\n };\n\n const onSave = async (): Promise<void> => {\n try {\n const values = draftValues();\n const saved = form.id\n ? await run({ kind: 'update', id: form.id, draft: values })\n : await run({ kind: 'create', draft: values });\n onFormChange((current) => ({ ...current, id: saved.id }));\n onValidationChange(saved.validation ?? null);\n toast.success(t('botlit.storePublish.toast.saved', 'Draft saved'));\n await onSaved();\n } catch (error) {\n toast.error(\n errorMessage(error, t('botlit.storePublish.toast.saveError', 'Could not save the draft'))\n );\n }\n };\n\n // Name, slug and version are required by the API; content must be a JSON object.\n const canSave =\n pending === null &&\n content.value !== null &&\n form.name.trim() !== '' &&\n form.slug.trim() !== '' &&\n form.version.trim() !== '';\n\n return (\n <Card data-testid=\"store-publish-form\">\n <CardHeader>\n <CardTitle>\n {form.id\n ? t('botlit.storePublish.form.editTitle', 'Edit draft')\n : t('botlit.storePublish.form.title', 'New package')}\n </CardTitle>\n <CardDescription>\n {t(\n 'botlit.storePublish.form.description',\n 'The content is the kind-specific part of the manifest, as JSON.'\n )}\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <div className=\"grid gap-4 md:grid-cols-2\">\n <FormField\n label={t('botlit.storePublish.form.kind', 'Kind')}\n htmlFor=\"store-publish-kind\"\n required\n >\n <select\n id=\"store-publish-kind\"\n className={SELECT_CLASS}\n value={form.kind}\n onChange={(event) => {\n const kind = event.target.value;\n onFormChange((current) => ({\n ...current,\n kind,\n content: JSON.stringify(KIND_TEMPLATES[kind] ?? {}, null, 2),\n }));\n }}\n >\n {Object.keys(KIND_TEMPLATES).map((kind) => (\n <option key={kind} value={kind}>\n {kindLabels[kind] ?? kind}\n </option>\n ))}\n </select>\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.name', 'Name')}\n htmlFor=\"store-publish-name\"\n required\n >\n <Input\n id=\"store-publish-name\"\n value={form.name}\n maxLength={255}\n onChange={(event) => setField('name')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.slug', 'Slug')}\n htmlFor=\"store-publish-slug\"\n required\n description={t(\n 'botlit.storePublish.form.slugHelp',\n 'Lowercase, optionally scoped: @acme/support-agent'\n )}\n >\n <Input\n id=\"store-publish-slug\"\n value={form.slug}\n maxLength={500}\n onChange={(event) => setField('slug')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.version', 'Version')}\n htmlFor=\"store-publish-version\"\n required\n description={t('botlit.storePublish.form.versionHelp', 'Semantic version, e.g. 1.0.0')}\n >\n <Input\n id=\"store-publish-version\"\n value={form.version}\n maxLength={50}\n onChange={(event) => setField('version')(event.target.value)}\n />\n </FormField>\n </div>\n <FormField\n label={t('botlit.storePublish.form.descriptionField', 'Description')}\n htmlFor=\"store-publish-description\"\n >\n <Input\n id=\"store-publish-description\"\n value={form.description}\n maxLength={2000}\n onChange={(event) => setField('description')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.content', 'Content (JSON)')}\n htmlFor=\"store-publish-content\"\n required\n error={content.error ?? undefined}\n >\n <Textarea\n id=\"store-publish-content\"\n className=\"font-mono text-xs\"\n rows={10}\n value={form.content}\n onChange={(event) => setField('content')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.readme', 'Readme (Markdown)')}\n htmlFor=\"store-publish-readme\"\n >\n <Textarea\n id=\"store-publish-readme\"\n rows={4}\n value={form.readme}\n onChange={(event) => setField('readme')(event.target.value)}\n />\n </FormField>\n <ValidationPanel validation={validation} testId=\"store-publish-validation\" />\n <div className=\"flex flex-wrap gap-2\">\n <Button\n variant=\"outline\"\n onClick={() => void onValidate()}\n disabled={pending !== null || !content.value}\n data-testid=\"store-publish-validate\"\n >\n <FileCheck2 size={16} className=\"mr-2\" />\n {t('botlit.storePublish.form.validate', 'Validate')}\n </Button>\n {/* A new draft needs create; saving an existing one is an update (matches the API's RBAC). */}\n <BotmanorPermissionGate\n permission={\n form.id ? BOTMANOR_PERMISSIONS.STORE_UPDATE : BOTMANOR_PERMISSIONS.STORE_CREATE\n }\n >\n <Button\n variant=\"primary\"\n onClick={() => void onSave()}\n disabled={!canSave}\n data-testid=\"store-publish-save\"\n >\n {form.id\n ? t('botlit.storePublish.form.update', 'Save changes')\n : t('botlit.storePublish.form.save', 'Save draft')}\n </Button>\n </BotmanorPermissionGate>\n {form.id && (\n <Button\n variant=\"ghost\"\n onClick={() => {\n onFormChange(emptyDraftForm());\n onValidationChange(null);\n }}\n >\n {t('botlit.storePublish.form.new', 'Start a new package')}\n </Button>\n )}\n </div>\n </CardContent>\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA2CA,IAAaA,KAAyD,EACpE,SACA,iBACA,eACA,uBACA,iBACI;CACJ,IAAMC,IAAIC,EAAM,GACV,EAAE,aAAU,QAAK,eAAYC,EAA0B,GACvDC,IAAaC,QAAcC,EAAkBL,CAAC,GAAG,CAACA,CAAC,CAAC,GACpDM,IAAUF,QAAcG,EAAiBC,EAAK,OAAO,GAAG,CAACA,EAAK,OAAO,CAAC,GACtEC,KAAY,OAA4B,MAC5CC,GAAc,OAAa;EAAE,GAAGC;GAAUC,IAAQC;CAAM,EAAE,GAEtDC,UAAwC;EAC5C,IAAI,CAACR,EAAQ,OAAO,MAAU,MAAMA,EAAQ,SAAS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eAAeA,EAAqB;OAGrE,UAAA,kBAACH,GAAD;QACE,SAAQ;QACR,eAAe,KAAKtB,EAAO;QAC3B,UAAU,CAACO;QACX,eAAY;QAEX,UAAAnB,EAAK,KACFR,EAAE,mCAAmC,cAAc,IACnDA,EAAE,iCAAiC,YAAY;OAC7C,CAAA;MACc,CAAA;MACvBQ,EAAK,MACJ,kBAACkC,GAAD;OACE,SAAQ;OACR,eAAe;QAEb,AADAhC,EAAaoC,EAAe,CAAC,GAC7BtB,EAAmB,IAAI;OACzB;OAEC,UAAAxB,EAAE,gCAAgC,qBAAqB;MAClD,CAAA;KAEP;;GACM;EACT,CAAA,CAAA;;AAEV"}
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { StoreSubmissionRecord } from '../hooks/useStorePublishing';
3
+ interface StorePolicyBundleCardProps {
4
+ /** Called with the new draft, so the page can open it for editing. */
5
+ onCreated: (submission: StoreSubmissionRecord) => Promise<void>;
6
+ }
7
+ export declare const StorePolicyBundleCard: FC<StorePolicyBundleCardProps>;
8
+ export {};
@@ -0,0 +1,143 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { BOTMANOR_PERMISSIONS as t } from "../permissions/botmanorPermissions.js";
3
+ import { BotmanorPermissionGate as n } from "../permissions/useBotmanorPermissions.js";
4
+ import { Badge as r } from "./Badge.js";
5
+ import { Button as i } from "./Button.js";
6
+ import { Card as a, CardContent as o, CardDescription as s, CardHeader as c, CardTitle as l } from "./Card.js";
7
+ import { FormField as u, Input as d } from "./Input.js";
8
+ import { errorMessage as f } from "../utils/storePublishing.js";
9
+ import { usePolicies as p } from "../hooks/usePolicies.js";
10
+ import "../hooks/index.js";
11
+ import { useStorePublishingActions as m } from "../hooks/useStorePublishing.js";
12
+ import "../permissions/index.js";
13
+ import { useState as h } from "react";
14
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
15
+ import { Shield as v } from "lucide-react";
16
+ import { toast as y } from "sonner";
17
+ // src/botlit/components/StorePolicyBundleCard.tsx
18
+ var b = () => ({
19
+ name: "",
20
+ slug: "",
21
+ version: "1.0.0",
22
+ description: ""
23
+ }), x = ({ onCreated: x }) => {
24
+ let S = e(), { data: C } = p(), { run: w, pending: T } = m(), [E, D] = h(b), [O, k] = h(() => /* @__PURE__ */ new Set()), A = (e, t) => k((n) => {
25
+ let r = new Set(n);
26
+ return t ? r.add(e) : r.delete(e), r;
27
+ }), j = (e) => (t) => D((n) => ({
28
+ ...n,
29
+ [e]: t
30
+ })), M = O.size > 0 && E.name.trim() !== "" && E.slug.trim() !== "" && E.version.trim() !== "", N = async () => {
31
+ try {
32
+ let e = await w({
33
+ kind: "bundle",
34
+ bundle: {
35
+ policyIds: [...O],
36
+ name: E.name.trim(),
37
+ slug: E.slug.trim(),
38
+ version: E.version.trim(),
39
+ description: E.description.trim() || void 0
40
+ }
41
+ });
42
+ y.success(S("botlit.storePublish.toast.bundleCreated", "Policy bundle draft created")), k(/* @__PURE__ */ new Set()), D(b()), await x(e);
43
+ } catch (e) {
44
+ y.error(f(e, S("botlit.storePublish.toast.bundleError", "Could not build the bundle")));
45
+ }
46
+ };
47
+ return /* @__PURE__ */ _(a, {
48
+ "data-testid": "store-publish-bundle",
49
+ children: [/* @__PURE__ */ _(c, { children: [/* @__PURE__ */ _(l, {
50
+ className: "flex items-center gap-2",
51
+ children: [/* @__PURE__ */ g(v, { size: 18 }), S("botlit.storePublish.bundle.title", "Policy bundle")]
52
+ }), /* @__PURE__ */ g(s, { children: S("botlit.storePublish.bundle.description", "Package this workspace's policies so other workspaces can install the same guardrails. Installing the bundle creates the policies there; ACTIVE policies install ACTIVE.") })] }), /* @__PURE__ */ _(o, {
53
+ className: "space-y-4",
54
+ children: [
55
+ C.length === 0 ? /* @__PURE__ */ g("p", {
56
+ className: "text-sm text-text-secondary",
57
+ children: S("botlit.storePublish.bundle.noPolicies", "This workspace has no policies yet.")
58
+ }) : /* @__PURE__ */ _("fieldset", {
59
+ className: "max-h-56 space-y-1 overflow-y-auto rounded-md border border-border-subtle p-3",
60
+ children: [/* @__PURE__ */ g("legend", {
61
+ className: "px-1 text-sm font-medium",
62
+ children: S("botlit.storePublish.bundle.policies", "Policies ({{count}} selected)", { count: O.size })
63
+ }), C.map((e) => /* @__PURE__ */ _("label", {
64
+ className: "flex items-center gap-2 text-sm",
65
+ children: [
66
+ /* @__PURE__ */ g("input", {
67
+ type: "checkbox",
68
+ checked: O.has(e.id),
69
+ onChange: (t) => A(e.id, t.target.checked)
70
+ }),
71
+ /* @__PURE__ */ g("span", { children: e.name }),
72
+ /* @__PURE__ */ g(r, {
73
+ variant: "outline",
74
+ children: e.type
75
+ }),
76
+ /* @__PURE__ */ g(r, {
77
+ variant: e.status === "ACTIVE" ? "success" : "secondary",
78
+ children: e.status
79
+ })
80
+ ]
81
+ }, e.id))]
82
+ }),
83
+ /* @__PURE__ */ _("div", {
84
+ className: "grid gap-4 md:grid-cols-3",
85
+ children: [
86
+ /* @__PURE__ */ g(u, {
87
+ label: S("botlit.storePublish.form.name", "Name"),
88
+ htmlFor: "store-bundle-name",
89
+ required: !0,
90
+ children: /* @__PURE__ */ g(d, {
91
+ id: "store-bundle-name",
92
+ value: E.name,
93
+ onChange: (e) => j("name")(e.target.value)
94
+ })
95
+ }),
96
+ /* @__PURE__ */ g(u, {
97
+ label: S("botlit.storePublish.form.slug", "Slug"),
98
+ htmlFor: "store-bundle-slug",
99
+ required: !0,
100
+ children: /* @__PURE__ */ g(d, {
101
+ id: "store-bundle-slug",
102
+ value: E.slug,
103
+ onChange: (e) => j("slug")(e.target.value)
104
+ })
105
+ }),
106
+ /* @__PURE__ */ g(u, {
107
+ label: S("botlit.storePublish.form.version", "Version"),
108
+ htmlFor: "store-bundle-version",
109
+ required: !0,
110
+ children: /* @__PURE__ */ g(d, {
111
+ id: "store-bundle-version",
112
+ value: E.version,
113
+ onChange: (e) => j("version")(e.target.value)
114
+ })
115
+ })
116
+ ]
117
+ }),
118
+ /* @__PURE__ */ g(u, {
119
+ label: S("botlit.storePublish.form.descriptionField", "Description"),
120
+ htmlFor: "store-bundle-description",
121
+ children: /* @__PURE__ */ g(d, {
122
+ id: "store-bundle-description",
123
+ value: E.description,
124
+ onChange: (e) => j("description")(e.target.value)
125
+ })
126
+ }),
127
+ /* @__PURE__ */ g(n, {
128
+ permission: t.STORE_CREATE,
129
+ children: /* @__PURE__ */ g(i, {
130
+ variant: "primary",
131
+ onClick: () => void N(),
132
+ disabled: T !== null || !M,
133
+ "data-testid": "store-bundle-create",
134
+ children: S("botlit.storePublish.bundle.create", "Create bundle draft")
135
+ })
136
+ })
137
+ ]
138
+ })]
139
+ });
140
+ };
141
+ export { x as StorePolicyBundleCard };
142
+
143
+ //# sourceMappingURL=StorePolicyBundleCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorePolicyBundleCard.js","names":["emptyBundle","StorePolicyBundleCard","t","useTr","policies","usePolicies","useStorePublishingActions","bundle","setBundle","useState","selected","setSelected","toggle","next","current","checked","policyId","setField","field","value","ready","onCreate","created","run","toast","onCreated","error","errorMessage","Card","CardHeader","CardTitle","Shield","CardDescription","CardContent","policy","event","Badge","FormField","Input","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Button","pending"],"sources":["../../../src/botlit/components/StorePolicyBundleCard.tsx"],"sourcesContent":["/**\n * Store policy bundle builder (BOFF-15360)\n * @module botlit/components\n *\n * Pick policies of this workspace and package them as a POLICY_BUNDLE draft.\n * Installing the bundle creates the policies in the installing workspace.\n */\n\nimport { useState, type FC } from 'react';\nimport { Shield } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { Badge } from './Badge';\nimport { Button } from './Button';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { FormField, Input } from './Input';\nimport { errorMessage } from '../utils/storePublishing';\nimport { usePolicies } from '../hooks';\nimport { useStorePublishingActions, type StoreSubmissionRecord } from '../hooks/useStorePublishing';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\ninterface BundleFields {\n name: string;\n slug: string;\n version: string;\n description: string;\n}\n\nconst emptyBundle = (): BundleFields => ({ name: '', slug: '', version: '1.0.0', description: '' });\n\ninterface StorePolicyBundleCardProps {\n /** Called with the new draft, so the page can open it for editing. */\n onCreated: (submission: StoreSubmissionRecord) => Promise<void>;\n}\n\nexport const StorePolicyBundleCard: FC<StorePolicyBundleCardProps> = ({ onCreated }) => {\n const t = useTr();\n const { data: policies } = usePolicies();\n const { run, pending } = useStorePublishingActions();\n const [bundle, setBundle] = useState<BundleFields>(emptyBundle);\n const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set());\n\n const toggle = (policyId: string, checked: boolean): void =>\n setSelected((current) => {\n const next = new Set(current);\n if (checked) next.add(policyId);\n else next.delete(policyId);\n return next;\n });\n const setField = (field: keyof BundleFields) => (value: string) =>\n setBundle((current) => ({ ...current, [field]: value }));\n\n const ready =\n selected.size > 0 &&\n bundle.name.trim() !== '' &&\n bundle.slug.trim() !== '' &&\n bundle.version.trim() !== '';\n\n const onCreate = async (): Promise<void> => {\n try {\n const created = await run({\n kind: 'bundle',\n bundle: {\n policyIds: [...selected],\n name: bundle.name.trim(),\n slug: bundle.slug.trim(),\n version: bundle.version.trim(),\n description: bundle.description.trim() || undefined,\n },\n });\n toast.success(t('botlit.storePublish.toast.bundleCreated', 'Policy bundle draft created'));\n setSelected(new Set());\n setBundle(emptyBundle());\n await onCreated(created);\n } catch (error) {\n toast.error(\n errorMessage(\n error,\n t('botlit.storePublish.toast.bundleError', 'Could not build the bundle')\n )\n );\n }\n };\n\n return (\n <Card data-testid=\"store-publish-bundle\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <Shield size={18} />\n {t('botlit.storePublish.bundle.title', 'Policy bundle')}\n </CardTitle>\n <CardDescription>\n {t(\n 'botlit.storePublish.bundle.description',\n \"Package this workspace's policies so other workspaces can install the same guardrails. Installing the bundle creates the policies there; ACTIVE policies install ACTIVE.\"\n )}\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {policies.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.storePublish.bundle.noPolicies', 'This workspace has no policies yet.')}\n </p>\n ) : (\n <fieldset className=\"max-h-56 space-y-1 overflow-y-auto rounded-md border border-border-subtle p-3\">\n <legend className=\"px-1 text-sm font-medium\">\n {t('botlit.storePublish.bundle.policies', 'Policies ({{count}} selected)', {\n count: selected.size,\n })}\n </legend>\n {policies.map((policy) => (\n <label key={policy.id} className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n checked={selected.has(policy.id)}\n onChange={(event) => toggle(policy.id, event.target.checked)}\n />\n <span>{policy.name}</span>\n <Badge variant=\"outline\">{policy.type}</Badge>\n <Badge variant={policy.status === 'ACTIVE' ? 'success' : 'secondary'}>\n {policy.status}\n </Badge>\n </label>\n ))}\n </fieldset>\n )}\n <div className=\"grid gap-4 md:grid-cols-3\">\n <FormField\n label={t('botlit.storePublish.form.name', 'Name')}\n htmlFor=\"store-bundle-name\"\n required\n >\n <Input\n id=\"store-bundle-name\"\n value={bundle.name}\n onChange={(event) => setField('name')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.slug', 'Slug')}\n htmlFor=\"store-bundle-slug\"\n required\n >\n <Input\n id=\"store-bundle-slug\"\n value={bundle.slug}\n onChange={(event) => setField('slug')(event.target.value)}\n />\n </FormField>\n <FormField\n label={t('botlit.storePublish.form.version', 'Version')}\n htmlFor=\"store-bundle-version\"\n required\n >\n <Input\n id=\"store-bundle-version\"\n value={bundle.version}\n onChange={(event) => setField('version')(event.target.value)}\n />\n </FormField>\n </div>\n <FormField\n label={t('botlit.storePublish.form.descriptionField', 'Description')}\n htmlFor=\"store-bundle-description\"\n >\n <Input\n id=\"store-bundle-description\"\n value={bundle.description}\n onChange={(event) => setField('description')(event.target.value)}\n />\n </FormField>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.STORE_CREATE}>\n <Button\n variant=\"primary\"\n onClick={() => void onCreate()}\n disabled={pending !== null || !ready}\n data-testid=\"store-bundle-create\"\n >\n {t('botlit.storePublish.bundle.create', 'Create bundle draft')}\n </Button>\n </BotmanorPermissionGate>\n </CardContent>\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAMA,WAAmC;CAAE,MAAM;CAAI,MAAM;CAAI,SAAS;CAAS,aAAa;AAAG,IAOpFC,KAAyD,EAAE,mBAAgB;CACtF,IAAMC,IAAIC,EAAM,GACV,EAAE,MAAMC,MAAaC,EAAY,GACjC,EAAE,QAAK,eAAYC,EAA0B,GAC7C,CAACC,GAAQC,KAAaC,EAAuBT,CAAW,GACxD,CAACU,GAAUC,KAAeF,wBAAoC,IAAI,IAAI,CAAC,GAEvEG,KAAU,GAAkB,MAChCD,GAAa,MAAY;EACvB,IAAME,IAAO,IAAI,IAAIC,CAAO;EAG5B,OAFIC,IAASF,EAAK,IAAIG,CAAQ,IACzBH,EAAK,OAAOG,CAAQ,GAClBH;CACT,CAAC,GACGI,KAAY,OAA+B,MAC/CT,GAAW,OAAa;EAAE,GAAGM;GAAUI,IAAQC;CAAM,EAAE,GAEnDC,IACJV,EAAS,OAAO,KAChBH,EAAO,KAAK,KAAK,MAAM,MACvBA,EAAO,KAAK,KAAK,MAAM,MACvBA,EAAO,QAAQ,KAAK,MAAM,IAEtBc,IAAW,YAA2B;EAC1C,IAAI;GACF,IAAMC,IAAU,MAAMC,EAAI;IACxB,MAAM;IACN,QAAQ;KACN,WAAW,CAAC,GAAGb,CAAQ;KACvB,MAAMH,EAAO,KAAK,KAAK;KACvB,MAAMA,EAAO,KAAK,KAAK;KACvB,SAASA,EAAO,QAAQ,KAAK;KAC7B,aAAaA,EAAO,YAAY,KAAK,KAAK,KAAA;IAC5C;GACF,CAAC;GAID,AAHAiB,EAAM,QAAQtB,EAAE,2CAA2C,6BAA6B,CAAC,GACzFS,kBAAY,IAAI,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AAA;MACE,kBAACG,GAAD;OACE,OAAOnC,EAAE,iCAAiC,MAAM;OAChD,SAAQ;OACR,UAAA;OAEA,UAAA,kBAACoC,GAAD;QACE,IAAG;QACH,OAAO/B,EAAO;QACd,WAAW,MAAUU,EAAS,MAAM,CAAC,CAACkB,EAAM,OAAO,KAAK;OACzD,CAAA;MACQ,CAAA;MACX,kBAACE,GAAD;OACE,OAAOnC,EAAE,iCAAiC,MAAM;OAChD,SAAQ;OACR,UAAA;OAEA,UAAA,kBAACoC,GAAD;QACE,IAAG;QACH,OAAO/B,EAAO;QACd,WAAW,MAAUU,EAAS,MAAM,CAAC,CAACkB,EAAM,OAAO,KAAK;OACzD,CAAA;MACQ,CAAA;MACX,kBAACE,GAAD;OACE,OAAOnC,EAAE,oCAAoC,SAAS;OACtD,SAAQ;OACR,UAAA;OAEA,UAAA,kBAACoC,GAAD;QACE,IAAG;QACH,OAAO/B,EAAO;QACd,WAAW,MAAUU,EAAS,SAAS,CAAC,CAACkB,EAAM,OAAO,KAAK;OAC5D,CAAA;MACQ,CAAA;KACR;;IACL,kBAACE,GAAD;KACE,OAAOnC,EAAE,6CAA6C,aAAa;KACnE,SAAQ;KAER,UAAA,kBAACoC,GAAD;MACE,IAAG;MACH,OAAO/B,EAAO;MACd,WAAW,MAAUU,EAAS,aAAa,CAAC,CAACkB,EAAM,OAAO,KAAK;KAChE,CAAA;IACQ,CAAA;IACX,kBAACI,GAAD;KAAwB,YAAYC,EAAqB;KACvD,UAAA,kBAACC,GAAD;MACE,SAAQ;MACR,eAAe,KAAKpB,EAAS;MAC7B,UAAUqB,MAAY,QAAQ,CAACtB;MAC/B,eAAY;MAEX,UAAAlB,EAAE,qCAAqC,qBAAqB;KACvD,CAAA;IACc,CAAA;GACb;EACT,CAAA,CAAA;;AAEV"}
@@ -0,0 +1,39 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { PackageValidation } from '../hooks/useStorePublishing';
3
+ /** The result of a validation run: pass/fail, then errors and warnings by field. */
4
+ export declare const ValidationPanel: FC<{
5
+ validation: PackageValidation | null | undefined;
6
+ testId: string;
7
+ }>;
8
+ /**
9
+ * Loading, error and empty states of a list, then the list itself. Loading is
10
+ * shown only before the first rows arrive, so a refetch never blanks the list.
11
+ */
12
+ export declare const ListStatus: FC<{
13
+ loading: boolean;
14
+ error: Error | undefined;
15
+ count: number;
16
+ resource: string;
17
+ onRetry: () => void;
18
+ empty: ReactNode;
19
+ children: ReactNode;
20
+ }>;
21
+ export interface ConfirmDialogCopy {
22
+ title: string;
23
+ description: string;
24
+ confirm: string;
25
+ /** Shows a note field; `required` makes a non-empty note a condition. */
26
+ note?: 'optional' | 'required';
27
+ destructive?: boolean;
28
+ }
29
+ /**
30
+ * A confirmation dialog with an optional note. `copy` null closes it.
31
+ * `onConfirm` receives the trimmed note; the dialog stays open (note kept)
32
+ * until the parent closes it, so a failed action never loses the note.
33
+ */
34
+ export declare const ConfirmDialog: FC<{
35
+ copy: ConfirmDialogCopy | null;
36
+ pending: boolean;
37
+ onConfirm: (note: string) => void;
38
+ onClose: () => void;
39
+ }>;
@@ -0,0 +1,95 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { Button as t } from "./Button.js";
3
+ import { ErrorState as n } from "./ErrorState.js";
4
+ import { Textarea as r } from "./Input.js";
5
+ import { useState as i } from "react";
6
+ import { ResponsiveDialog as a, ResponsiveDialogContent as o, ResponsiveDialogDescription as s, ResponsiveDialogFooter as c, ResponsiveDialogHeader as l, ResponsiveDialogTitle as u } from "@burdenoff/fe-libs/ui";
7
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ import { CheckCircle2 as m, XCircle as h } from "lucide-react";
9
+ // src/botlit/components/StorePublishingParts.tsx
10
+ var g = ({ issues: e, className: t }) => e.length === 0 ? null : /* @__PURE__ */ f("ul", {
11
+ className: `space-y-1 text-sm ${t}`,
12
+ children: e.map((e) => /* @__PURE__ */ p("li", { children: [
13
+ /* @__PURE__ */ f("span", {
14
+ className: "font-mono text-xs",
15
+ children: e.field
16
+ }),
17
+ ": ",
18
+ e.message
19
+ ] }, `${e.field}-${e.code}-${e.message}`))
20
+ }), _ = ({ validation: t, testId: n }) => {
21
+ let r = e();
22
+ return t ? /* @__PURE__ */ p("div", {
23
+ className: "space-y-2 rounded-md border border-border-subtle p-3",
24
+ "data-testid": n,
25
+ children: [
26
+ /* @__PURE__ */ p("div", {
27
+ className: "flex items-center gap-2 text-sm font-medium",
28
+ children: [t.valid ? /* @__PURE__ */ f(m, {
29
+ size: 16,
30
+ className: "text-status-success-text"
31
+ }) : /* @__PURE__ */ f(h, {
32
+ size: 16,
33
+ className: "text-status-error-text"
34
+ }), t.valid ? r("botlit.storePublish.validation.valid", "Validation passed") : r("botlit.storePublish.validation.invalid", "{{count}} problem(s) to fix", { count: t.errors.length })]
35
+ }),
36
+ /* @__PURE__ */ f(g, {
37
+ issues: t.errors,
38
+ className: "text-status-error-text"
39
+ }),
40
+ /* @__PURE__ */ f(g, {
41
+ issues: t.warnings,
42
+ className: "text-status-warning-text"
43
+ })
44
+ ]
45
+ }) : null;
46
+ }, v = ({ loading: t, error: r, count: i, resource: a, onRetry: o, empty: s, children: c }) => {
47
+ let l = e();
48
+ return r ? /* @__PURE__ */ f(n, {
49
+ resource: a,
50
+ error: r,
51
+ onRetry: o
52
+ }) : i === 0 && t ? /* @__PURE__ */ f("p", {
53
+ className: "text-sm text-text-secondary",
54
+ role: "status",
55
+ children: l("botlit.storePublish.loading", "Loading…")
56
+ }) : i === 0 ? /* @__PURE__ */ f(d, { children: s }) : /* @__PURE__ */ f(d, { children: c });
57
+ }, y = ({ copy: e, pending: t, onConfirm: n, onClose: r }) => /* @__PURE__ */ f(a, {
58
+ open: e !== null,
59
+ onOpenChange: (e) => {
60
+ e || r();
61
+ },
62
+ children: /* @__PURE__ */ f(o, { children: e && /* @__PURE__ */ f(b, {
63
+ copy: e,
64
+ pending: t,
65
+ onConfirm: n,
66
+ onClose: r
67
+ }) })
68
+ }), b = ({ copy: n, pending: a, onConfirm: o, onClose: m }) => {
69
+ let h = e(), [g, _] = i(""), v = a || n.note === "required" && !g.trim();
70
+ return /* @__PURE__ */ p(d, { children: [
71
+ /* @__PURE__ */ p(l, { children: [/* @__PURE__ */ f(u, { children: n.title }), /* @__PURE__ */ f(s, { children: n.description })] }),
72
+ n.note && /* @__PURE__ */ f(r, {
73
+ "aria-label": h("botlit.storePublish.dialog.note", "Note"),
74
+ value: g,
75
+ maxLength: 2e3,
76
+ rows: 3,
77
+ placeholder: n.note === "required" ? h("botlit.storePublish.dialog.required", "Reason (required)") : h("botlit.storePublish.dialog.optional", "Note (optional)"),
78
+ onChange: (e) => _(e.target.value)
79
+ }),
80
+ /* @__PURE__ */ p(c, { children: [/* @__PURE__ */ f(t, {
81
+ variant: "ghost",
82
+ onClick: m,
83
+ children: h("botlit.storePublish.dialog.cancel", "Cancel")
84
+ }), /* @__PURE__ */ f(t, {
85
+ variant: n.destructive ? "destructive" : "primary",
86
+ disabled: v,
87
+ onClick: () => o(g.trim()),
88
+ "data-testid": "store-dialog-confirm",
89
+ children: n.confirm
90
+ })] })
91
+ ] });
92
+ };
93
+ export { y as ConfirmDialog, v as ListStatus, _ as ValidationPanel };
94
+
95
+ //# sourceMappingURL=StorePublishingParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorePublishingParts.js","names":["_Fragment","Textarea","Textarea$1","Fragment$1","IssueList","issues","className","issue","ValidationPanel","t","useTr","validation","testId","CheckCircle2","XCircle","ListStatus","error","ErrorState","count","loading","empty","ConfirmDialog","ResponsiveDialog","copy","open","onClose","ResponsiveDialogContent","ConfirmDialogBody","note","setNote","useState","blocked","pending","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","event","ResponsiveDialogFooter","Button","onConfirm"],"sources":["../../../src/botlit/components/StorePublishingParts.tsx"],"sourcesContent":["/**\n * Store publishing building blocks (BOFF-15360)\n * @module botlit/components\n *\n * Shared components of the store publishing page: the validation panel, the\n * list status wrapper and the confirmation dialog. The form model lives in\n * utils/storePublishing.\n */\n\nimport { useState, type FC, type ReactNode } from 'react';\nimport { CheckCircle2, XCircle } from 'lucide-react';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { Button } from './Button';\nimport { ErrorState } from './ErrorState';\nimport { Textarea } from './Input';\nimport type { PackageValidation, ValidationIssue } from '../hooks/useStorePublishing';\n\nconst IssueList: FC<{ issues: ValidationIssue[]; className: string }> = ({ issues, className }) =>\n issues.length === 0 ? null : (\n <ul className={`space-y-1 text-sm ${className}`}>\n {issues.map((issue) => (\n // field + code can repeat across issues; the message tells them apart.\n <li key={`${issue.field}-${issue.code}-${issue.message}`}>\n <span className=\"font-mono text-xs\">{issue.field}</span>: {issue.message}\n </li>\n ))}\n </ul>\n );\n\n/** The result of a validation run: pass/fail, then errors and warnings by field. */\nexport const ValidationPanel: FC<{\n validation: PackageValidation | null | undefined;\n testId: string;\n}> = ({ validation, testId }) => {\n const t = useTr();\n if (!validation) return null;\n return (\n <div className=\"space-y-2 rounded-md border border-border-subtle p-3\" data-testid={testId}>\n <div className=\"flex items-center gap-2 text-sm font-medium\">\n {validation.valid ? (\n <CheckCircle2 size={16} className=\"text-status-success-text\" />\n ) : (\n <XCircle size={16} className=\"text-status-error-text\" />\n )}\n {validation.valid\n ? t('botlit.storePublish.validation.valid', 'Validation passed')\n : t('botlit.storePublish.validation.invalid', '{{count}} problem(s) to fix', {\n count: validation.errors.length,\n })}\n </div>\n <IssueList issues={validation.errors} className=\"text-status-error-text\" />\n <IssueList issues={validation.warnings} className=\"text-status-warning-text\" />\n </div>\n );\n};\n\n/**\n * Loading, error and empty states of a list, then the list itself. Loading is\n * shown only before the first rows arrive, so a refetch never blanks the list.\n */\nexport const ListStatus: FC<{\n loading: boolean;\n error: Error | undefined;\n count: number;\n resource: string;\n onRetry: () => void;\n empty: ReactNode;\n children: ReactNode;\n}> = ({ loading, error, count, resource, onRetry, empty, children }) => {\n const t = useTr();\n if (error) return <ErrorState resource={resource} error={error} onRetry={onRetry} />;\n if (count === 0 && loading) {\n return (\n <p className=\"text-sm text-text-secondary\" role=\"status\">\n {t('botlit.storePublish.loading', 'Loading…')}\n </p>\n );\n }\n if (count === 0) return <>{empty}</>;\n return <>{children}</>;\n};\n\nexport interface ConfirmDialogCopy {\n title: string;\n description: string;\n confirm: string;\n /** Shows a note field; `required` makes a non-empty note a condition. */\n note?: 'optional' | 'required';\n destructive?: boolean;\n}\n\n/**\n * A confirmation dialog with an optional note. `copy` null closes it.\n * `onConfirm` receives the trimmed note; the dialog stays open (note kept)\n * until the parent closes it, so a failed action never loses the note.\n */\nexport const ConfirmDialog: FC<{\n copy: ConfirmDialogCopy | null;\n pending: boolean;\n onConfirm: (note: string) => void;\n onClose: () => void;\n}> = ({ copy, pending, onConfirm, onClose }) => (\n <ResponsiveDialog\n open={copy !== null}\n onOpenChange={(open) => {\n if (!open) onClose();\n }}\n >\n <ResponsiveDialogContent>\n {/* Mounted only while open, so each opening starts with an empty note. */}\n {copy && (\n <ConfirmDialogBody copy={copy} pending={pending} onConfirm={onConfirm} onClose={onClose} />\n )}\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n);\n\nconst ConfirmDialogBody: FC<{\n copy: ConfirmDialogCopy;\n pending: boolean;\n onConfirm: (note: string) => void;\n onClose: () => void;\n}> = ({ copy, pending, onConfirm, onClose }) => {\n const t = useTr();\n const [note, setNote] = useState('');\n const blocked = pending || (copy.note === 'required' && !note.trim());\n return (\n <>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{copy.title}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>{copy.description}</ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n {copy.note && (\n <Textarea\n aria-label={t('botlit.storePublish.dialog.note', 'Note')}\n value={note}\n maxLength={2000}\n rows={3}\n placeholder={\n copy.note === 'required'\n ? t('botlit.storePublish.dialog.required', 'Reason (required)')\n : t('botlit.storePublish.dialog.optional', 'Note (optional)')\n }\n onChange={(event) => setNote(event.target.value)}\n />\n )}\n <ResponsiveDialogFooter>\n <Button variant=\"ghost\" onClick={onClose}>\n {t('botlit.storePublish.dialog.cancel', 'Cancel')}\n </Button>\n <Button\n variant={copy.destructive ? 'destructive' : 'primary'}\n disabled={blocked}\n onClick={() => onConfirm(note.trim())}\n data-testid=\"store-dialog-confirm\"\n >\n {copy.confirm}\n </Button>\n </ResponsiveDialogFooter>\n </>\n );\n};\n"],"mappings":";;;;;;;;;AAyBA,IAAMI,KAAmE,EAAE,WAAQ,mBACjFC,EAAO,WAAW,IAAI,OACpB,kBAAC,MAAD;CAAI,WAAW,qBAAqBC;CACjC,UAAAD,EAAO,KAAK,MAEX,kBAAC,MAAD,EAAA,UAAA;EACE,kBAAC,QAAD;GAAM,WAAU;GAAqB,UAAAE,EAAM;EAAY,CAAA;EAAC;EAAGA,EAAM;CAC/D,EAAA,GAFK,GAAGA,EAAM,MAAM,GAAGA,EAAM,KAAK,GAAGA,EAAM,SAE3C,CACL;AACC,CAAA,GAIKC,KAGP,EAAE,eAAY,gBAAa;CAC/B,IAAMC,IAAIC,EAAM;CAEhB,OADKC,IAEH,kBAAC,OAAD;EAAK,WAAU;EAAuD,eAAaC;EAAnF,UAAA;GACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGD,EAAW,QACV,kBAACE,GAAD;KAAc,MAAM;KAAI,WAAU;IAA4B,CAAA,IAE9D,kBAACC,GAAD;KAAS,MAAM;KAAI,WAAU;IAA0B,CAAA,GAExDH,EAAW,QACRF,EAAE,wCAAwC,mBAAmB,IAC7DA,EAAE,0CAA0C,+BAA+B,EACzE,OAAOE,EAAW,OAAO,OAC3B,CAAC,CACF;;GACL,kBAACP,GAAD;IAAW,QAAQO,EAAW;IAAQ,WAA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AAE,uCAAuC,mBAAmB,IAC5DA,EAAE,uCAAuC,iBAAiB;GAEhE,WAAW,MAAUoB,EAAQO,EAAM,OAAO,KAAK;EAChD,CAAA;EAEH,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD;GAAQ,SAAQ;GAAQ,SAASb;GAC9B,UAAAhB,EAAE,qCAAqC,QAAQ;EAC1C,CAAA,GACR,kBAAC6B,GAAD;GACE,SAASf,EAAK,cAAc,gBAAgB;GAC5C,UAAUQ;GACV,eAAeQ,EAAUX,EAAK,KAAK,CAAC;GACpC,eAAY;GAEX,UAAAL,EAAK;EACA,CAAA,CACc,EAAA,CAAA;CACxB,EAAA,CAAA;AAEN"}
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ import { StoreSubmissionRecord } from '../hooks/useStorePublishing';
3
+ interface StoreReviewQueueCardProps {
4
+ queue: {
5
+ data: StoreSubmissionRecord[];
6
+ loading: boolean;
7
+ error: Error | undefined;
8
+ refetch: () => Promise<void>;
9
+ };
10
+ onChanged: () => Promise<void>;
11
+ }
12
+ export declare const StoreReviewQueueCard: FC<StoreReviewQueueCardProps>;
13
+ export {};