@jini-ai/admin 0.6.19 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/consent/react/ConsentFields.d.ts +1 -1
  3. package/dist/consent/react/ConsentFields.js +2 -3
  4. package/dist/consent/react/ConsentSettingsPanel.d.ts +1 -1
  5. package/dist/consent/react/settings-panel.hooks.d.ts +0 -1
  6. package/dist/consent/react/settings-panel.hooks.js +0 -1
  7. package/dist/core/ports/forms.d.ts +26 -1
  8. package/dist/forms/adapters/http.js +3 -0
  9. package/dist/forms/adapters/memory.d.ts +3 -1
  10. package/dist/forms/adapters/memory.js +6 -2
  11. package/dist/forms/controllers/form-editor.controller.d.ts +8 -1
  12. package/dist/forms/controllers/form-editor.controller.js +8 -3
  13. package/dist/forms/form-editor-dirty.d.ts +5 -0
  14. package/dist/forms/form-editor-dirty.js +4 -2
  15. package/dist/forms/html-rules.d.ts +2 -1
  16. package/dist/forms/html-rules.js +6 -3
  17. package/dist/forms/models.d.ts +2 -1
  18. package/dist/forms/react/components/FormEditorFieldsBody.d.ts +9 -0
  19. package/dist/forms/react/components/FormEditorFieldsBody.js +5 -1
  20. package/dist/forms/react/components/FormProviderSettings.d.ts +5 -0
  21. package/dist/forms/react/components/FormProviderSettings.js +23 -0
  22. package/dist/forms/react/components/FormSubmissionDetail.js +9 -2
  23. package/dist/forms/react/hooks/forms-view.hooks.d.ts +15 -1
  24. package/dist/forms/react/hooks/use-form-editor.hooks.d.ts +9 -1
  25. package/dist/forms/react/hooks/use-form-editor.hooks.js +17 -5
  26. package/dist/forms/react/pages/FormEditor.js +2 -2
  27. package/dist/react/components/DataTable.d.ts +6 -1
  28. package/dist/react/components/DataTable.js +5 -1
  29. package/dist/react/components/RowMenu/RowMenu.hooks.js +5 -3
  30. package/dist/react/entities/EntityField.d.ts +2 -1
  31. package/dist/react/entities/EntityField.js +9 -4
  32. package/package.json +13 -13
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [fedca02]
8
+ - Updated dependencies [11ce174]
9
+ - Updated dependencies [3a9fcc6]
10
+ - Updated dependencies [8fe045b]
11
+ - Updated dependencies [c393010]
12
+ - Updated dependencies [ce9e9dc]
13
+ - Updated dependencies [1838089]
14
+ - Updated dependencies [df2698c]
15
+ - Updated dependencies [4044fe3]
16
+ - Updated dependencies [0ccd93c]
17
+ - Updated dependencies [a6e4a75]
18
+ - Updated dependencies [42cfff7]
19
+ - Updated dependencies [41ff2ff]
20
+ - Updated dependencies [a266ba8]
21
+ - Updated dependencies [39cf677]
22
+ - Updated dependencies [66bf2d2]
23
+ - Updated dependencies [291a220]
24
+ - Updated dependencies [27063ef]
25
+ - Updated dependencies [6ab1d81]
26
+ - Updated dependencies [699b478]
27
+ - Updated dependencies [1cf0306]
28
+ - Updated dependencies [39cf677]
29
+ - @jini-ai/agent-plugins@0.7.0
30
+ - @jini-ai/cms@0.7.0
31
+ - @jini-ai/core@0.7.0
32
+ - @jini-ai/ui@0.7.0
33
+ - @jini-ai/agentic@0.7.0
34
+ - @jini-ai/ui-kit@0.7.0
35
+
36
+ ## 0.6.22
37
+
38
+ - Form submission detail shows a failed email notification and the field errors of an imported submission that did not pass the form checks. `FormSubmission` gains optional `notificationDelivery` and `validation`.
39
+
3
40
  ## 0.6.17
4
41
 
5
42
  ### Patch Changes
@@ -26,7 +26,7 @@ export interface ConsentFieldsProps {
26
26
  export declare function ConsentBannerFields({ value, onChange, disabled, problems, dictionary, limits, bannerModes }: ConsentFieldsProps & {
27
27
  bannerModes?: readonly NonNullable<ConsentSettingsView['bannerMode']>[] | undefined;
28
28
  }): import("react").JSX.Element;
29
- /** On/off, script policy, region behavior and the version that re-asks visitors when it changes. */
29
+ /** On/off, region behavior and the version that re-asks visitors when it changes. */
30
30
  export declare function ConsentRulesFields({ value, onChange, disabled, problems, dictionary, limits, regionModes }: ConsentFieldsProps & {
31
31
  regionModes?: readonly ConsentSettingsView['regionMode'][];
32
32
  }): import("react").JSX.Element;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from 'react';
3
3
  import { defaultAdminTheme } from '@jini-ai/ui/theme';
4
- import { InfoTip } from '@jini-ai/ui/admin-widgets';
5
4
  import { pixelInputValue, problemsFor, useConsentSettingsPanel, usePolicyVersionInput } from './settings-panel.hooks.js';
6
5
  const BANNER_FIELDS = [
7
6
  { key: 'title', label: 'Banner title' }, { key: 'message', label: 'Banner message', multiline: true },
@@ -58,13 +57,13 @@ export function ConsentBannerFields({ value, onChange, disabled = false, problem
58
57
  ? _jsx("textarea", { className: "jini-input", value: value[key] ?? '', maxLength: limits[key] ?? 2000, rows: 3, onChange: handlers.text(key), ...aria })
59
58
  : _jsx("input", { className: "jini-input", type: "text", value: value[key] ?? '', maxLength: limits[key] ?? 2000, onChange: handlers.text(key), ...aria }) }, key)), _jsx("p", { className: "jini-hint", children: t('Link a published privacy page, such as /privacy. The second link is optional.') })] });
60
59
  }
61
- /** On/off, script policy, region behavior and the version that re-asks visitors when it changes. */
60
+ /** On/off, region behavior and the version that re-asks visitors when it changes. */
62
61
  export function ConsentRulesFields({ value, onChange, disabled = false, problems, dictionary, limits = {}, regionModes = ['auto', 'opt-in', 'opt-out'] }) {
63
62
  const id = useId();
64
63
  const t = translator(dictionary);
65
64
  const handlers = useConsentSettingsPanel({ value, onChange });
66
65
  const modes = regionModes.includes(value.regionMode) ? regionModes : [value.regionMode, ...regionModes];
67
- return _jsxs("fieldset", { disabled: disabled, className: "jini-consent-settings-fields", children: [_jsx("legend", { children: t('Rules') }), _jsxs("button", { type: "button", className: value.enabled ? 'jini-toggle-row on' : 'jini-toggle-row', role: "switch", "aria-checked": value.enabled, "aria-labelledby": `${id}-enabled`, "aria-describedby": `${id}-hint`, onClick: handlers.toggle, children: [_jsxs("span", { className: "jini-toggle-row-text", children: [_jsx("span", { id: `${id}-enabled`, className: "jini-toggle-row-label", children: t('Enable cookie consent on this site') }), _jsx("span", { id: `${id}-hint`, className: "jini-toggle-row-hint", children: t('Applies to published site pages.') })] }), _jsx("span", { className: "jini-toggle-row-switch", "aria-hidden": "true" })] }), value.enabled && _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsxs("button", { type: "button", className: value.allowUnsafeEval === true ? 'jini-toggle-row on' : 'jini-toggle-row', role: "switch", "aria-checked": value.allowUnsafeEval === true, "aria-labelledby": `${id}-eval`, "aria-describedby": `${id}-eval-hint`, onClick: handlers.toggleUnsafeEval, children: [_jsx("span", { className: "jini-toggle-row-text", children: _jsx("span", { id: `${id}-eval`, className: "jini-toggle-row-label", children: t('Allow dynamic code (unsafe-eval)') }) }), _jsx("span", { className: "jini-toggle-row-switch", "aria-hidden": "true" })] }), _jsx(InfoTip, { triggerLabel: t('About dynamic code'), descriptionId: `${id}-eval-hint`, label: t("Some themes need this. It weakens the site's script protection. Optional scripts still wait for consent.") })] }), _jsx(Field, { label: t('Region mode'), field: "regionMode", problems: problems, children: aria => _jsx("select", { className: "jini-input", value: value.regionMode, onChange: handlers.region, ...aria, children: modes.map(mode => _jsx("option", { value: mode, children: t(REGION_LABELS[mode]) }, mode)) }) }), _jsx("p", { className: "jini-hint", children: t('California permits optional categories until opt-out. Global Privacy Control always disables analytics and marketing.') }), _jsx(Field, { label: t('Policy version'), field: "policyVersion", problems: problems, children: aria => _jsx(PolicyVersionInput, { value: value.policyVersion, onChange: onChange, maxLength: limits.policyVersion ?? 128, aria: aria }) }), _jsx("p", { className: "jini-hint", children: t('Change the policy version to ask visitors to choose again.') })] });
66
+ return _jsxs("fieldset", { disabled: disabled, className: "jini-consent-settings-fields", children: [_jsx("legend", { children: t('Rules') }), _jsxs("button", { type: "button", className: value.enabled ? 'jini-toggle-row on' : 'jini-toggle-row', role: "switch", "aria-checked": value.enabled, "aria-labelledby": `${id}-enabled`, "aria-describedby": `${id}-hint`, onClick: handlers.toggle, children: [_jsxs("span", { className: "jini-toggle-row-text", children: [_jsx("span", { id: `${id}-enabled`, className: "jini-toggle-row-label", children: t('Enable cookie consent on this site') }), _jsx("span", { id: `${id}-hint`, className: "jini-toggle-row-hint", children: t('Applies to published site pages.') })] }), _jsx("span", { className: "jini-toggle-row-switch", "aria-hidden": "true" })] }), _jsx(Field, { label: t('Region mode'), field: "regionMode", problems: problems, children: aria => _jsx("select", { className: "jini-input", value: value.regionMode, onChange: handlers.region, ...aria, children: modes.map(mode => _jsx("option", { value: mode, children: t(REGION_LABELS[mode]) }, mode)) }) }), _jsx("p", { className: "jini-hint", children: t('California permits optional categories until opt-out. Global Privacy Control always disables analytics and marketing.') }), _jsx(Field, { label: t('Policy version'), field: "policyVersion", problems: problems, children: aria => _jsx(PolicyVersionInput, { value: value.policyVersion, onChange: onChange, maxLength: limits.policyVersion ?? 128, aria: aria }) }), _jsx("p", { className: "jini-hint", children: t('Change the policy version to ask visitors to choose again.') })] });
68
67
  }
69
68
  /** Placement, bounded appearance tokens and allowlisted custom CSS. The engine checks contrast and
70
69
  * CSS safety; its problems arrive on the `appearance` field and show under the custom CSS. */
@@ -12,7 +12,7 @@ export interface ConsentAppearanceView {
12
12
  /** The host's consent configuration. The look fields are optional so older hosts stay valid. */
13
13
  export interface ConsentSettingsView {
14
14
  enabled: boolean;
15
- /** Optional for older hosts; omitted means the dynamic code exception is off. */
15
+ /** @deprecated Retained for saved-settings compatibility; declared-script consent does not use it. */
16
16
  allowUnsafeEval?: boolean;
17
17
  /** Optional for older hosts; omitted uses the Jini banner when consent is enabled. */
18
18
  bannerMode?: 'jini' | 'headless' | 'off';
@@ -3,7 +3,6 @@ import type { ConsentAppearanceView, ConsentFieldProblem, ConsentSettingsPanelPr
3
3
  /** Keep value conversions and toggle behavior out of the view. React owns event signatures. */
4
4
  export declare function useConsentSettingsPanel({ value, onChange }: Pick<ConsentSettingsPanelProps, 'value' | 'onChange'>, _options?: {}): {
5
5
  toggle: () => void;
6
- toggleUnsafeEval: () => void;
7
6
  bannerMode: ({ mode }: {
8
7
  mode: NonNullable<ConsentSettingsView["bannerMode"]>;
9
8
  }, _optional?: {}) => () => void;
@@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
3
3
  export function useConsentSettingsPanel({ value, onChange }, _options = {}) {
4
4
  return {
5
5
  toggle: () => onChange({ patch: { enabled: !value.enabled } }),
6
- toggleUnsafeEval: () => onChange({ patch: { allowUnsafeEval: value.allowUnsafeEval !== true } }),
7
6
  bannerMode: ({ mode }, _optional = {}) => () => onChange({ patch: { bannerMode: mode } }),
8
7
  region: (event) => onChange({ patch: { regionMode: event.target.value } }),
9
8
  placement: (event) => onChange({ patch: { placement: event.target.value } }),
@@ -58,6 +58,7 @@
58
58
  * (`@jini-ai/cms/forms` `FIELD_TYPE_REGISTRY`) now owns the full vocabulary, and a host offering a
59
59
  * richer form builder needs room to add its own without this contract standing in the way.
60
60
  */
61
+ import type { FormAnswer } from "@jini-ai/cms/forms";
61
62
  /** A form field's input kind — open, see file header. */
62
63
  export type FormFieldType = "text" | "email" | "textarea" | "checkbox" | (string & {});
63
64
  /** Lifecycle of a form definition — open, see file header. There is no "deleted" state; see the
@@ -93,6 +94,11 @@ export interface AdminFormNotifyConfig {
93
94
  readonly enabled: boolean;
94
95
  readonly recipients: readonly string[];
95
96
  }
97
+ /** Public collection choice; omitted means built-in collection. No secrets belong in this object. */
98
+ export interface AdminFormProviderSelection {
99
+ readonly id: string;
100
+ readonly config: Readonly<Record<string, string>>;
101
+ }
96
102
  export interface AdminFormDefinition {
97
103
  readonly id: string;
98
104
  readonly name: string;
@@ -105,12 +111,27 @@ export interface AdminFormDefinition {
105
111
  /** HTML authoring is explicit; absent mode means the existing Builder contract. */
106
112
  readonly mode?: AdminFormMode | undefined;
107
113
  readonly html?: string | undefined;
114
+ readonly provider?: AdminFormProviderSelection | undefined;
108
115
  }
109
116
  export interface AdminFormSubmission {
117
+ readonly evidence?: import("@jini-ai/cms/forms").FormSubmissionEvidence;
118
+ readonly schemaHash?: string;
119
+ /** Optional host notification summary, with no recipient/provider details. */
120
+ readonly notificationDelivery?: {
121
+ readonly failed: number;
122
+ readonly pending: number;
123
+ };
124
+ readonly validation?: {
125
+ readonly status: "invalid";
126
+ readonly fieldErrors: readonly {
127
+ readonly field: string;
128
+ readonly reason: string;
129
+ }[];
130
+ };
110
131
  readonly id: string;
111
132
  readonly formDefinitionId: string;
112
133
  /** Keyed by the definition's field ids at submission time. */
113
- readonly data: Readonly<Record<string, string | boolean>>;
134
+ readonly data: Readonly<Record<string, FormAnswer>>;
114
135
  readonly sourceIp: string;
115
136
  readonly submittedAt: string;
116
137
  /** Missing means active for older wire records. Trash preserves the original submission data. */
@@ -127,6 +148,7 @@ export interface AdminFormCreateInput {
127
148
  readonly fields: readonly AdminFormField[];
128
149
  readonly mode?: AdminFormMode | undefined;
129
150
  readonly html?: string | undefined;
151
+ readonly provider?: AdminFormProviderSelection | undefined;
130
152
  readonly notify?: AdminFormNotifyConfig;
131
153
  }
132
154
  /** No `slug` — see file header. */
@@ -135,12 +157,15 @@ export interface AdminFormUpdatePatch {
135
157
  /** A mode/body patch uses the authoring route; an ordinary patch keeps the CRUD route. */
136
158
  readonly mode?: AdminFormMode | undefined;
137
159
  readonly html?: string | undefined;
160
+ readonly provider?: AdminFormProviderSelection | undefined;
138
161
  /** Whole-array replace with an add/edit-only constraint — see file header. */
139
162
  readonly fields?: readonly AdminFormField[];
140
163
  readonly notify?: AdminFormNotifyConfig;
141
164
  readonly status?: FormDefinitionStatus;
142
165
  }
143
166
  export interface AdminFormsPort {
167
+ /** Current public collection settings. Older hosts may omit discovery; editors preserve their stored selection. */
168
+ listFormProviders?(requiredArgs: Record<string, never>, optionalArgs?: Record<string, never>): Promise<readonly import("@jini-ai/cms/forms").FormProviderDescription[]>;
144
169
  listFormDefinitions(requiredArgs: Record<string, never>): Promise<readonly AdminFormDefinition[]>;
145
170
  getFormDefinition(requiredArgs: {
146
171
  id: string;
@@ -10,6 +10,9 @@ export function createHttpFormsApi({ transport, basePath }, { mediaBasePath } =
10
10
  ...(mediaBase === undefined ? {} : {
11
11
  submissionFileUrl: ({ mediaId }, _optional = {}) => transport.url({ path: `${mediaBase}/${encodeURIComponent(mediaId)}/original` }),
12
12
  }),
13
+ async listFormProviders(_required, _optional = {}) {
14
+ return (await transport.request({ path: `${base}/_providers`, method: 'GET' })).data;
15
+ },
13
16
  async listFormDefinitions(_required, _optional = {}) {
14
17
  return (await transport.request({ path: base, method: 'GET' })).data;
15
18
  },
@@ -1,9 +1,11 @@
1
+ import type { FormProviderDescription } from '@jini-ai/cms/forms';
1
2
  import type { AdminFormsPort, AdminFormDefinition, AdminFormSubmission } from '../../core/ports/forms.js';
2
3
  import type { FormsTrashPort } from '../ports.js';
3
4
  /** A scoped, deterministic in-memory API with the core contract's add/edit-only invariant. */
4
- export declare function createMemoryFormsApi(_required?: Record<string, never>, { forms, submissions, now, nextId }?: {
5
+ export declare function createMemoryFormsApi(_required?: Record<string, never>, { forms, submissions, providers, now, nextId }?: {
5
6
  forms?: readonly AdminFormDefinition[];
6
7
  submissions?: readonly AdminFormSubmission[];
8
+ providers?: readonly FormProviderDescription[];
7
9
  now?: () => string;
8
10
  nextId?: () => string;
9
11
  }): AdminFormsPort & {
@@ -1,6 +1,8 @@
1
1
  import { AdminApiError } from '../../core/transport/errors.js';
2
+ // Keep this disposable browser fixture independent of the CMS runtime.
3
+ const DEFAULT_PROVIDERS = [{ id: 'builtin', label: 'Built-in', fields: [], answers: 'Answers are stored in the built-in inbox.', validation: 'The built-in receiver validates the declared form fields.', frameOrigins: [], available: true }];
2
4
  // The contract excludes slug; runtime callers cannot smuggle it through a cast either.
3
- const PATCHABLE_KEYS = ['name', 'fields', 'notify', 'status', 'mode', 'html'];
5
+ const PATCHABLE_KEYS = ['name', 'fields', 'notify', 'status', 'mode', 'html', 'provider'];
4
6
  /** The allowlisted patch keys the caller actually supplied (an explicit `undefined` is not a value). */
5
7
  function suppliedPatch(patch) {
6
8
  return Object.fromEntries(PATCHABLE_KEYS.filter(key => patch[key] !== undefined).map(key => [key, patch[key]]));
@@ -15,7 +17,8 @@ function assertNoFieldRemoved({ current, patch }) {
15
17
  }
16
18
  }
17
19
  /** A scoped, deterministic in-memory API with the core contract's add/edit-only invariant. */
18
- export function createMemoryFormsApi(_required = {}, { forms = [], submissions = [], now = () => new Date(0).toISOString(), nextId } = {}) {
20
+ export function createMemoryFormsApi(_required = {}, { forms = [], submissions = [], providers = DEFAULT_PROVIDERS, now = () => new Date(0).toISOString(), nextId } = {}) {
21
+ const descriptions = structuredClone([...providers]);
19
22
  const definitions = structuredClone([...forms]);
20
23
  const answers = structuredClone([...submissions]);
21
24
  let sequence = definitions.length;
@@ -43,6 +46,7 @@ export function createMemoryFormsApi(_required = {}, { forms = [], submissions =
43
46
  };
44
47
  return {
45
48
  forms: definitions, submissions: answers,
49
+ async listFormProviders(_required, _optional = {}) { return structuredClone(descriptions); },
46
50
  async listFormDefinitions(_required, _optional = {}) { return structuredClone(definitions); },
47
51
  async getFormDefinition({ id }, _optional = {}) { return structuredClone(find(id)); },
48
52
  async createFormDefinition(input, options = {}) {
@@ -1,6 +1,8 @@
1
+ import type { AdminFormProviderSelection } from "../../core/ports/forms.js";
1
2
  import type { AdminFormDefinition, AdminFormField, AdminFormNotify } from "../models.js";
2
3
  export interface FormEditorState {
3
4
  form: AdminFormDefinition | null;
5
+ provider: AdminFormProviderSelection;
4
6
  mode: "builder" | "html";
5
7
  html: string;
6
8
  copyFeedback: string | null;
@@ -9,8 +11,13 @@ export interface FormEditorState {
9
11
  fields: AdminFormField[];
10
12
  notify: AdminFormNotify;
11
13
  }
14
+ /** New forms start with the existing built-in collection policy.
15
+ * @complexity O(1) time/space; no I/O.
16
+ * @overallScore 98 — Recommended: defaults remain explicit rather than derived from installed plugins. */
12
17
  export declare function initialFormEditorState(_required: Record<string, never>, _optional?: {}): FormEditorState;
13
- /** A headless section store. React owns subscriptions/effects, never this state. */
18
+ /** A headless section store. React owns subscriptions/effects, never this state.
19
+ * @complexity O(1) construction; HTML starter generation is O(fields + generated bytes), no I/O.
20
+ * @overallScore 97 — Recommended: callers replace provider configuration rather than mutate its readonly record. */
14
21
  export declare function createFormEditorController(_required: Record<string, never>, _optional?: {}): {
15
22
  seed({ form }: {
16
23
  form: AdminFormDefinition;
@@ -1,16 +1,21 @@
1
1
  import { createFormsDraftStore } from "./draft-store.js";
2
2
  import { blankField } from "../rules.js";
3
3
  import { formHtmlStarter } from "../html-rules.js";
4
+ /** New forms start with the existing built-in collection policy.
5
+ * @complexity O(1) time/space; no I/O.
6
+ * @overallScore 98 — Recommended: defaults remain explicit rather than derived from installed plugins. */
4
7
  export function initialFormEditorState(_required, _optional = {}) {
5
- return { form: null, mode: "builder", html: "", copyFeedback: null, name: "", slug: "", fields: [blankField()], notify: { enabled: false, recipients: [] } };
8
+ return { form: null, provider: { id: "builtin", config: {} }, mode: "builder", html: "", copyFeedback: null, name: "", slug: "", fields: [blankField()], notify: { enabled: false, recipients: [] } };
6
9
  }
7
- /** A headless section store. React owns subscriptions/effects, never this state. */
10
+ /** A headless section store. React owns subscriptions/effects, never this state.
11
+ * @complexity O(1) construction; HTML starter generation is O(fields + generated bytes), no I/O.
12
+ * @overallScore 97 — Recommended: callers replace provider configuration rather than mutate its readonly record. */
8
13
  export function createFormEditorController(_required, _optional = {}) {
9
14
  const store = createFormsDraftStore({ initial: initialFormEditorState({}) });
10
15
  return {
11
16
  ...store,
12
17
  seed({ form }, _options = {}) {
13
- store.patch({ patch: { form, name: form.name, slug: form.slug, fields: form.fields, mode: form.mode ?? 'builder', html: form.html ?? '', notify: form.notify } });
18
+ store.patch({ patch: { form, provider: form.provider ?? { id: "builtin", config: {} }, name: form.name, slug: form.slug, fields: form.fields, mode: form.mode ?? 'builder', html: form.html ?? '', notify: form.notify } });
14
19
  },
15
20
  changeMode({ mode }, { submitLabel = 'Send' } = {}) {
16
21
  const state = store.getSnapshot();
@@ -1,3 +1,4 @@
1
+ import type { AdminFormProviderSelection } from "../core/ports/forms.js";
1
2
  import type { AdminFormDefinition, AdminFormField } from "./models.js";
2
3
  /**
3
4
  * @file What "unsaved" means on the form editor, so Back can warn before it discards edits.
@@ -8,6 +9,7 @@ import type { AdminFormDefinition, AdminFormField } from "./models.js";
8
9
  */
9
10
  /** The parts of the editor a Save writes. `notify` has no UI here, so it is never a pending edit. */
10
11
  export interface FormEditorDraft {
12
+ provider?: AdminFormProviderSelection;
11
13
  name: string;
12
14
  slug: string;
13
15
  fields: AdminFormField[];
@@ -20,6 +22,7 @@ export interface FormEditorDraft {
20
22
  * @param input The live editor values.
21
23
  * @returns The comparable draft.
22
24
  * @complexity O(1).
25
+ * @overallScore 97 — Recommended: an absent provider and explicit built-in provider are intentionally equivalent.
23
26
  */
24
27
  export declare function formEditorDraft(input: {
25
28
  name: string;
@@ -27,6 +30,7 @@ export declare function formEditorDraft(input: {
27
30
  fields: AdminFormField[];
28
31
  mode: "builder" | "html";
29
32
  html: string;
33
+ provider?: AdminFormProviderSelection;
30
34
  }): FormEditorDraft;
31
35
  /**
32
36
  * The draft the editor started from: the loaded form, or the blank new-form state.
@@ -34,6 +38,7 @@ export declare function formEditorDraft(input: {
34
38
  * @param input.isNew Whether this is the "new form" screen.
35
39
  * @returns `null` while an existing form is still loading — nothing to lose yet, so never dirty.
36
40
  * @complexity O(1).
41
+ * @overallScore 97 — Recommended: the loading baseline remains null until the repository value arrives.
37
42
  */
38
43
  export declare function formEditorBaseline(input: {
39
44
  form: AdminFormDefinition | null;
@@ -3,9 +3,10 @@ import { blankField } from "./rules.js";
3
3
  * @param input The live editor values.
4
4
  * @returns The comparable draft.
5
5
  * @complexity O(1).
6
+ * @overallScore 97 — Recommended: an absent provider and explicit built-in provider are intentionally equivalent.
6
7
  */
7
8
  export function formEditorDraft(input) {
8
- return { name: input.name, slug: input.slug, fields: input.fields, mode: input.mode, html: input.mode === "html" ? input.html : "" };
9
+ return { ...(input.provider && input.provider.id !== "builtin" ? { provider: input.provider } : {}), name: input.name, slug: input.slug, fields: input.fields, mode: input.mode, html: input.mode === "html" ? input.html : "" };
9
10
  }
10
11
  /**
11
12
  * The draft the editor started from: the loaded form, or the blank new-form state.
@@ -13,6 +14,7 @@ export function formEditorDraft(input) {
13
14
  * @param input.isNew Whether this is the "new form" screen.
14
15
  * @returns `null` while an existing form is still loading — nothing to lose yet, so never dirty.
15
16
  * @complexity O(1).
17
+ * @overallScore 97 — Recommended: the loading baseline remains null until the repository value arrives.
16
18
  */
17
19
  export function formEditorBaseline(input) {
18
20
  if (input.isNew)
@@ -20,6 +22,6 @@ export function formEditorBaseline(input) {
20
22
  if (!input.form)
21
23
  return null;
22
24
  const mode = input.form.mode ?? "builder";
23
- return formEditorDraft({ name: input.form.name, slug: input.form.slug, fields: input.form.fields, mode, html: input.form.html ?? "" });
25
+ return formEditorDraft({ name: input.form.name, slug: input.form.slug, fields: input.form.fields, mode, html: input.form.html ?? "", ...(input.form.provider ? { provider: input.form.provider } : {}) });
24
26
  }
25
27
  //# sourceMappingURL=form-editor-dirty.js.map
@@ -43,9 +43,10 @@ export declare function formatFormAnswer({ value, options, type }: {
43
43
  * A file answer also carries its reference so the view can link the download.
44
44
  * @complexity O(c + a) time and space for c columns and a submitted answers; no I/O.
45
45
  */
46
- export declare function formSubmissionRows({ data, answerColumns }: {
46
+ export declare function formSubmissionRows({ data, answerColumns, evidence }: {
47
47
  data: AdminFormSubmission['data'];
48
48
  answerColumns: readonly FormAnswerColumn[];
49
+ evidence?: AdminFormSubmission['evidence'];
49
50
  }, { unknownFieldLabel }?: {
50
51
  unknownFieldLabel?: string;
51
52
  }): Array<{
@@ -3,7 +3,10 @@ import { FIELD_TYPE_REGISTRY, escapeFormHtml } from "@jini-ai/cms/forms";
3
3
  export function formAnswerColumns({ fields }, display = {}) {
4
4
  return fields.map((field) => {
5
5
  const format = (value) => formatFormAnswer({ value, options: field.options, type: field.type }, display);
6
- return { key: `answer:${field.id}`, header: field.label, cell: (submission) => format(submission.data[field.id]), format };
6
+ return { key: `answer:${field.id}`, header: field.label, cell: (submission) => {
7
+ const captured = submission.evidence?.fields.find(original => original.id === field.id);
8
+ return captured ? formatFormAnswer({ value: submission.data[field.id], options: captured.options, type: captured.type }, display) : format(submission.data[field.id]);
9
+ }, format };
7
10
  });
8
11
  }
9
12
  /** Narrows a stored answer to an uploaded-file reference.
@@ -77,8 +80,8 @@ function formatByteSize({ bytes }) {
77
80
  * A file answer also carries its reference so the view can link the download.
78
81
  * @complexity O(c + a) time and space for c columns and a submitted answers; no I/O.
79
82
  */
80
- export function formSubmissionRows({ data, answerColumns }, { unknownFieldLabel = "Unknown field" } = {}) {
81
- const columns = new Map(answerColumns.map(column => [column.key, column]));
83
+ export function formSubmissionRows({ data, answerColumns, evidence }, { unknownFieldLabel = "Unknown field" } = {}) {
84
+ const columns = new Map((evidence ? formAnswerColumns({ fields: evidence.fields }) : answerColumns).map(column => [column.key, column]));
82
85
  return Object.entries(data).map(([key, value]) => {
83
86
  const column = columns.get(`answer:${key}`);
84
87
  const formatted = column?.format ? column.format(value) : formatFormAnswer({ value });
@@ -1,4 +1,5 @@
1
1
  import type { AdminFormDefinition as Definition, AdminFormField as Field, AdminFormSubmission as Submission } from '../core/ports/forms.js';
2
+ import type { FormAnswer } from '@jini-ai/cms/forms';
2
3
  /** Mutable editor drafts project the core contract; they never define another API. */
3
4
  export type AdminFormField = {
4
5
  -readonly [K in keyof Field]: Field[K];
@@ -16,7 +17,7 @@ export type AdminFormDefinition = Omit<Definition, 'fields' | 'notify'> & {
16
17
  };
17
18
  export type AdminFormSubmission = Omit<Submission, 'data'> & {
18
19
  workspaceId?: string;
19
- data: Record<string, string | boolean>;
20
+ data: Record<string, FormAnswer>;
20
21
  };
21
22
  export type FormsTranslator = (key: string, vars?: Record<string, string | number>) => string;
22
23
  /** Copy drafts at the API boundary so editing cannot mutate a repository/cache snapshot. */
@@ -1,5 +1,11 @@
1
+ import type { FormProviderDescription } from "@jini-ai/cms/forms";
2
+ import type { AdminFormProviderSelection } from "../../../core/ports/forms.js";
1
3
  import type { AdminFormDefinition, AdminFormField } from '../../models.js';
2
4
  export interface FormEditorFieldsBodyProps {
5
+ providers?: readonly FormProviderDescription[] | undefined;
6
+ providersError?: string | null | undefined;
7
+ provider?: AdminFormProviderSelection;
8
+ onProviderChange?: (value: AdminFormProviderSelection) => void;
3
9
  name: string;
4
10
  onNameChange: (value: string) => void;
5
11
  slug: string;
@@ -21,6 +27,9 @@ export interface FormEditorFieldsBodyProps {
21
27
  onCopyEmbed: () => void;
22
28
  copyFeedback: string | null;
23
29
  }
30
+ /** Edit the existing form body and explicit collection destination without crossing their state boundaries.
31
+ * @complexity O(f) render time/space for fields; event callbacks perform no direct I/O.
32
+ * Provider settings come from the shared runtime description; no vendor choices live in this view. */
24
33
  export declare function FormEditorFieldsBody(props: FormEditorFieldsBodyProps): import("react").JSX.Element;
25
34
  /** The page-header title/description text — split out because `FormEditor`'s isNew-dependent copy
26
35
  * (two ternaries, one with a `||` fallback) is otherwise indistinguishable, in the complexity
@@ -1,13 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { FormProviderSettings } from "./FormProviderSettings.js";
2
3
  import { useFormFieldsBodyView } from "../hooks/forms-view.hooks.js";
3
4
  import { agentHandle } from '@jini-ai/agentic';
4
5
  import { FormEditorActions, FormEditorModeSwitch } from "./FormEditorFieldsBodyParts.js";
6
+ /** Edit the existing form body and explicit collection destination without crossing their state boundaries.
7
+ * @complexity O(f) render time/space for fields; event callbacks perform no direct I/O.
8
+ * Provider settings come from the shared runtime description; no vendor choices live in this view. */
5
9
  export function FormEditorFieldsBody(props) {
6
10
  const handlers = useFormFieldsBodyView(props);
7
11
  const { name, slug, isNew, t } = props;
8
12
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: "field-group", children: _jsxs("div", { className: "field-row", children: [_jsxs("div", { className: "field", children: [_jsx("label", { className: "field-label", htmlFor: "form-name", children: t("Name") }), _jsx("input", { id: "form-name", value: name, onChange: handlers.onName, ...agentHandle({ handle: "form-editor-name" }, { role: "field", label: "This form's display name" }) })] }), _jsxs("div", { className: "field", children: [_jsx("label", { className: "field-label", htmlFor: "form-slug", children: t("Slug") }), _jsx("input", { id: "form-slug", value: slug, disabled: !isNew, onChange: handlers.onSlug, ...agentHandle({ handle: "form-editor-slug" }, {
9
13
  role: "field",
10
14
  label: "This form's URL slug — only editable while creating a new form",
11
- }) })] })] }) }), _jsx("div", { className: "field-group", children: _jsx(FormEditorModeSwitch, { props: props, handlers: handlers }) }), _jsxs("div", { className: "field-group", children: [_jsx("p", { children: _jsx("strong", { children: t("Basic spam protection is on.") }) }), _jsx("p", { className: "muted", children: t("Hidden-field checks, submission timing when available, duplicate suppression, and rate limits.") }), _jsx("p", { className: "muted", children: t("Live server defaults: wait 1 second; up to 5 submissions per minute per IP address and form.") }), _jsx("p", { className: "muted", children: t("Exported forms use their destination's protection; timing and duplicate suppression may be unavailable. Custom embeds need the generated hidden controls for hidden-field checks.") })] }), _jsx(FormEditorActions, { props: props })] }));
15
+ }) })] })] }) }), _jsx(FormProviderSettings, { ...props }), _jsx("div", { className: "field-group", children: _jsx(FormEditorModeSwitch, { props: props, handlers: handlers }) }), (!props.provider || props.provider.id === "builtin") ? _jsxs("div", { className: "field-group", children: [_jsx("p", { children: _jsx("strong", { children: t("Basic spam protection is on.") }) }), _jsx("p", { className: "muted", children: t("Hidden-field checks, submission timing when available, duplicate suppression, and rate limits.") }), _jsx("p", { className: "muted", children: t("Live server defaults: wait 1 second; up to 5 submissions per minute per IP address and form.") }), _jsx("p", { className: "muted", children: t("Exported forms use their destination's protection; timing and duplicate suppression may be unavailable. Custom embeds need the generated hidden controls for hidden-field checks.") })] }) : null, _jsx(FormEditorActions, { props: props })] }));
12
16
  }
13
17
  //# sourceMappingURL=FormEditorFieldsBody.js.map
@@ -0,0 +1,5 @@
1
+ import type { FormEditorFieldsBodyProps } from './FormEditorFieldsBody.js';
2
+ /** Runtime metadata owns choices and public fields. Missing discovery never rewrites the saved draft.
3
+ * @complexity O(p + f) render time/space for provider and configuration field counts; no I/O. */
4
+ export declare function FormProviderSettings({ provider, providers, providersError, onProviderChange, t }: FormEditorFieldsBodyProps): import("react").JSX.Element;
5
+ //# sourceMappingURL=FormProviderSettings.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /** Runtime metadata owns choices and public fields. Missing discovery never rewrites the saved draft.
3
+ * @complexity O(p + f) render time/space for provider and configuration field counts; no I/O. */
4
+ export function FormProviderSettings({ provider = { id: 'builtin', config: {} }, providers, providersError, onProviderChange, t }) {
5
+ if (providers === undefined && !providersError)
6
+ return _jsx("div", { className: "field-group", children: _jsx("p", { role: "status", children: t('Loading form providers…') }) });
7
+ const choices = providers ?? [];
8
+ const selected = choices.find(item => item.id === provider.id);
9
+ const unavailable = unavailableSettings({ selected, providersError, t });
10
+ return _jsxs("div", { className: "field-group", children: [_jsx("label", { htmlFor: "form-provider", children: t('Where answers go') }), _jsxs("select", { id: "form-provider", value: provider.id, disabled: choices.length === 0, onChange: event => onProviderChange?.({ id: event.target.value, config: {} }), children: [choices.map(item => _jsx("option", { value: item.id, disabled: !item.available, children: t(item.label) }, item.id)), !selected ? _jsx("option", { value: provider.id, children: provider.id }) : null] }), unavailable ? _jsx("p", { children: unavailable }) : _jsxs(_Fragment, { children: [selected.fields.map(field => _jsxs("div", { className: "field", children: [_jsx("label", { htmlFor: `form-provider-${field.key}`, children: t(field.label) }), _jsx("input", { id: `form-provider-${field.key}`, type: field.type, value: provider.config[field.key] ?? '', onChange: event => onProviderChange?.({ id: provider.id, config: { ...provider.config, [field.key]: event.target.value } }) }), field.helpText ? _jsx("p", { children: t(field.helpText) }) : null] }, field.key)), _jsx("p", { children: t(selected.answers) }), _jsx("p", { children: t(selected.validation) }), selected.helpText ? _jsx("p", { children: t(selected.helpText) }) : null] }), _jsx("p", { children: t('Switching providers preserves your existing definitions and submission history. Republish every static page containing this form after switching providers.') })] });
11
+ }
12
+ /** Keep discovery failure separate from editable configuration without replacing either value. */
13
+ function unavailableSettings({ selected, providersError, t }) {
14
+ if (providersError)
15
+ return providersError;
16
+ const storedProviderOff = t("This form can't collect answers because its form provider is off or failing. Enable its plugin in Plugins, or choose another form provider. Your saved selection is kept, and other changes still save.");
17
+ if (!selected)
18
+ return storedProviderOff;
19
+ if (selected.available)
20
+ return null;
21
+ return selected.message ?? storedProviderOff;
22
+ }
23
+ //# sourceMappingURL=FormProviderSettings.js.map
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { ConfirmDialog } from '../../../react/components/ConfirmDialog/ConfirmDialog.js';
3
3
  import { agentHandle } from '@jini-ai/agentic';
4
4
  import { useWiredFormSubmissionDetail } from '../hooks/use-form-submission-detail.hooks.js';
@@ -22,7 +22,7 @@ export function FormSubmissionDetail({ formId, submissionId, onBack, onDeleted,
22
22
  // button sat right on top of the table and Delete sat right underneath it. Same
23
23
  // flex-column-plus-gap idiom `.field-group` already uses elsewhere for vertical rhythm,
24
24
  // rather than one-off margins on each button.
25
- _jsxs("div", { className: "form-submission-detail", children: [_jsxs("button", { type: "button", className: "btn-secondary", onClick: onBack, "aria-label": t("Back to submissions"), ...agentHandle({ handle: "form-submission-back" }, { role: "link", label: "Back to this form's list of submissions" }), children: ["\u2190 ", t("Back")] }), error ? _jsx("div", { className: "notice error", children: error }) : null, _jsx("div", { className: "table-scroll", children: _jsx("table", { className: "list-table", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("th", { children: t("Submitted at") }), _jsx("td", { children: _jsx(FormSubmissionDate, { date: formatDate({ iso: submission.submittedAt }) }) })] }), _jsxs("tr", { children: [_jsx("th", { children: t("Source IP") }), _jsx("td", { children: submission.sourceIp })] }), formSubmissionRows({ data: submission.data, answerColumns }, { unknownFieldLabel: t("Unknown field") }).map(({ key, label, value, file }) => {
25
+ _jsxs("div", { className: "form-submission-detail", children: [_jsxs("button", { type: "button", className: "btn-secondary", onClick: onBack, "aria-label": t("Back to submissions"), ...agentHandle({ handle: "form-submission-back" }, { role: "link", label: "Back to this form's list of submissions" }), children: ["\u2190 ", t("Back")] }), _jsx(SubmissionStatusNotices, { submission: submission, error: error, t: t }), _jsx("div", { className: "table-scroll", children: _jsx("table", { className: "list-table", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("th", { children: t("Submitted at") }), _jsx("td", { children: _jsx(FormSubmissionDate, { date: formatDate({ iso: submission.submittedAt }) }) })] }), _jsxs("tr", { children: [_jsx("th", { children: t("Source IP") }), _jsx("td", { children: submission.sourceIp })] }), formSubmissionRows({ data: submission.data, answerColumns, evidence: submission.evidence }, { unknownFieldLabel: t("Unknown field") }).map(({ key, label, value, file }) => {
26
26
  const href = file ? fileUrl(file) : null;
27
27
  return (_jsxs("tr", { children: [_jsx("th", { className: "jini-submission-field-label", children: label }), _jsx("td", { children: href && file ? _jsx("a", { href: href, download: file.filename, ...agentHandle({ handle: `form-submission-file-${key}` }, { role: "link", label: `Download the uploaded file ${file.filename}` }), children: value }) : value })] }, key));
28
28
  })] }) }) }), _jsx("button", { type: "button", className: "btn-danger", disabled: deleting, onClick: requestDelete, ...agentHandle({ handle: "form-submission-delete" }, {
@@ -30,4 +30,11 @@ export function FormSubmissionDetail({ formId, submissionId, onBack, onDeleted,
30
30
  label: "Move this submission to the trash. Opens a confirmation dialog first.",
31
31
  }), children: t("Delete submission") }), _jsx(ConfirmDialog, { open: confirmOpen, agentHandle: "form-submission-delete-confirm", title: t("Move to trash?"), body: _jsx("p", { children: t("It will disappear from this list. You can restore it from the Trash.") }), confirmLabel: t("Move to trash"), destructive: true, pending: deleting, onConfirm: confirmDelete, onCancel: cancelDelete })] }));
32
32
  }
33
+ /** Historical context is displayed as plain text; authored HTML is never executed here. */
34
+ function SubmissionEvidenceNotice({ submission, t }) {
35
+ return !submission.evidence ? _jsxs("div", { className: "notice", children: [t("original schema/consent unavailable"), !submission.validation ? _jsx("p", { children: t("validation unknown") }) : null] }) : _jsxs("div", { className: "notice", children: [_jsxs("p", { children: [t("Schema hash"), ": ", _jsx("code", { children: submission.evidence.schemaHash })] }), submission.evidence.consent.map(consent => _jsxs("p", { children: [consent.wording, consent.helpText ? ` — ${consent.helpText}` : ""] }, consent.fieldId))] });
36
+ }
37
+ function SubmissionStatusNotices({ submission, error, t }) {
38
+ return _jsxs(_Fragment, { children: [error ? _jsx("div", { className: "notice error", children: error }) : null, submission.notificationDelivery && submission.notificationDelivery.failed > 0 ? _jsxs("div", { className: "notice error", role: "alert", children: [t("Email notification failed. The submission is saved here. Check the email provider settings before sending a new notification."), _jsxs("p", { children: [t("Details: FORM_NOTIFICATION_FAILED"), " (", submission.notificationDelivery.failed, ")"] })] }) : null, _jsx(SubmissionEvidenceNotice, { submission: submission, t: t }), submission.validation?.status === "invalid" ? _jsxs("div", { className: "notice error", role: "alert", children: [_jsx("p", { children: t("Imported for review: this submission did not pass the form checks.") }), _jsx("ul", { children: submission.validation.fieldErrors.map(({ field, reason }, index) => _jsxs("li", { children: [field, ": ", reason] }, `${field}-${index}`)) })] }) : null] });
39
+ }
33
40
  //# sourceMappingURL=FormSubmissionDetail.js.map
@@ -27,6 +27,7 @@ export declare function useFormsListView({ forms, t, formatFormDates, toggleStat
27
27
  updatedAt: string;
28
28
  name: string;
29
29
  mode?: import("../../../core/ports/forms.js").AdminFormMode | undefined;
30
+ provider?: import("../../../core/ports/forms.js").AdminFormProviderSelection | undefined;
30
31
  workspaceId?: string;
31
32
  fields: AdminFormField[];
32
33
  notify: import("../../models.js").AdminFormNotify;
@@ -156,11 +157,24 @@ export declare function useSubmissionsView({ controller }: {
156
157
  view: () => void;
157
158
  status?: "active" | "trash";
158
159
  id: string;
160
+ evidence?: import("@jini-ai/cms/forms").FormSubmissionEvidence;
161
+ schemaHash?: string;
162
+ notificationDelivery?: {
163
+ readonly failed: number;
164
+ readonly pending: number;
165
+ };
166
+ validation?: {
167
+ readonly status: "invalid";
168
+ readonly fieldErrors: readonly {
169
+ readonly field: string;
170
+ readonly reason: string;
171
+ }[];
172
+ };
159
173
  formDefinitionId: string;
160
174
  sourceIp: string;
161
175
  submittedAt: string;
162
176
  workspaceId?: string;
163
- data: Record<string, string | boolean>;
177
+ data: Record<string, import("@jini-ai/cms/forms").FormAnswer>;
164
178
  }[];
165
179
  };
166
180
  export declare function useFormFieldsBodyView(props: FormEditorFieldsBodyProps, _optional?: {}): {
@@ -1,4 +1,5 @@
1
- import type { AdminFormsPort } from "../../../core/ports/forms.js";
1
+ import type { FormProviderDescription } from "@jini-ai/cms/forms";
2
+ import type { AdminFormProviderSelection, AdminFormsPort } from "../../../core/ports/forms.js";
2
3
  import { type FormAnswerColumn } from "../../html-rules.js";
3
4
  import type { AdminFormDefinition, AdminFormField } from "../../models.js";
4
5
  /**
@@ -61,6 +62,10 @@ export interface FormEditorController {
61
62
  /** `null` until the initial load settles (or always, for `isNew`) — the caller renders a loading
62
63
  * state or the empty create form accordingly. */
63
64
  form: AdminFormDefinition | null;
65
+ providers?: readonly FormProviderDescription[] | undefined;
66
+ providersError?: string | null;
67
+ provider: AdminFormProviderSelection;
68
+ setProvider: (value: AdminFormProviderSelection) => void;
64
69
  name: string;
65
70
  setName: (value: string) => void;
66
71
  slug: string;
@@ -111,6 +116,9 @@ export interface FormEditorController {
111
116
  * `FormEditor.tsx` calling `useAdminLocale()`/`FORMS_DICT` directly. */
112
117
  t: (key: string) => string;
113
118
  }
119
+ /** Load and save the editor through its injected port, preserving authoring and collection metadata.
120
+ * @complexity O(f + b) draft state for fields/HTML bytes; one definition request per save, no provider I/O.
121
+ * @overallScore 95 — Low: the existing screen lifecycle remains one hook with independently tested callbacks. */
114
122
  export declare function useFormEditor(props: {
115
123
  formId: string;
116
124
  tab: "fields" | "submissions";
@@ -1,4 +1,5 @@
1
1
  import { formView } from "../../models.js";
2
+ import { describeApiError } from "../../../core/transport/errors.js";
2
3
  import { useFormsPorts, useFormsOptions } from "./FormsPorts.hooks.js";
3
4
  import { useController } from "../../../core/react/use-controller.js";
4
5
  import { createFormEditorController, initialFormEditorState } from "../../controllers/form-editor.controller.js";
@@ -14,13 +15,17 @@ function authoringPatch({ mode, html, savedMode }) {
14
15
  return { mode, html };
15
16
  return savedMode === "html" ? { mode } : {};
16
17
  }
18
+ /** Load and save the editor through its injected port, preserving authoring and collection metadata.
19
+ * @complexity O(f + b) draft state for fields/HTML bytes; one definition request per save, no provider I/O.
20
+ * @overallScore 95 — Low: the existing screen lifecycle remains one hook with independently tested callbacks. */
17
21
  export function useFormEditor(props, { clipboard } = {}) {
18
22
  const { port, navigate, t } = props;
19
23
  const { tab } = props;
20
24
  const isNew = props.formId === "new";
21
25
  const { controller: stateController, snapshot: stateSnapshot } = useController({ create: () => createFormEditorController({}), dependencies: [] });
22
26
  const state = stateSnapshot ?? initialFormEditorState({});
23
- const { form, mode, html, copyFeedback, name, slug, fields, notify } = state;
27
+ const { form, mode, html, copyFeedback, name, slug, fields, notify, provider } = state;
28
+ const setProvider = (value) => stateController?.update({ key: "provider", value });
24
29
  const setForm = (value) => stateController?.update({ key: "form", value });
25
30
  const setHtml = (value) => stateController?.update({ key: "html", value });
26
31
  const setCopyFeedback = (value) => stateController?.update({ key: "copyFeedback", value });
@@ -36,6 +41,11 @@ export function useFormEditor(props, { clipboard } = {}) {
36
41
  // Roving-tabindex focus targets for the tab strip below, indexed the same as `FORM_TABS` — see
37
42
  // `nextTabIndex`'s doc comment for why the index math itself lives outside the component.
38
43
  const tabRefs = useRef([]);
44
+ const discovery = useFetchQuery({ key: ["forms", "providers"], fetch: async () => {
45
+ if (!port.listFormProviders)
46
+ throw new Error("Form provider settings are unavailable.");
47
+ return { data: await port.listFormProviders({}) };
48
+ } });
39
49
  const list = useFetchQuery({ key: KEYS.form(props.formId), fetch: () => port.getFormDefinition({ id: props.formId }).then(form => ({ data: formView({ form }) })) }, { enabled: !isNew });
40
50
  // Seeds `form`/`name`/`slug`/`fields`/`notify` from `list.data` exactly once per `formId` — see
41
51
  // this file's own header for the regression this guards against (a background refetch of the SAME
@@ -80,7 +90,7 @@ export function useFormEditor(props, { clipboard } = {}) {
80
90
  invalidates: [KEYS.list],
81
91
  });
82
92
  const createMutation = useFetchMutation({
83
- run: ({ input }) => port.createFormDefinition({ name: input.name, slug: input.slug, fields: input.fields, ...(input.mode ? { mode: input.mode, html: input.html } : {}) }, { notify: input.notify }),
93
+ run: ({ input }) => port.createFormDefinition({ name: input.name, slug: input.slug, fields: input.fields, ...(input.provider ? { provider: input.provider } : {}), ...(input.mode ? { mode: input.mode, html: input.html } : {}) }, { notify: input.notify }),
84
94
  }, {
85
95
  invalidates: [KEYS.list],
86
96
  });
@@ -105,7 +115,7 @@ export function useFormEditor(props, { clipboard } = {}) {
105
115
  }
106
116
  async function handleSave() {
107
117
  // Ordinary Builder saves keep their existing endpoint/permissions. A mode change is explicit.
108
- const authoring = authoringPatch({ mode, html, savedMode: form?.mode });
118
+ const authoring = { ...authoringPatch({ mode, html, savedMode: form?.mode }), ...(provider.id !== "builtin" || form?.provider ? { provider } : {}) };
109
119
  try {
110
120
  if (isNew) {
111
121
  // `notify` here is always this hook's own blank default — a new form has no earlier value
@@ -148,7 +158,7 @@ export function useFormEditor(props, { clipboard } = {}) {
148
158
  }
149
159
  // Same guard as the post and widget editors (reload/close prompt included); the in-app Back
150
160
  // gets the admin's confirm modal rather than `confirmLeave`'s `window.confirm`.
151
- const { isDirty } = useDirtyGuard({ current: formEditorDraft({ name, slug, fields, mode, html }), original: formEditorBaseline({ form, isNew }) });
161
+ const { isDirty } = useDirtyGuard({ current: formEditorDraft({ name, slug, fields, mode, html, provider }), original: formEditorBaseline({ form, isNew }) });
152
162
  const [leaveConfirmOpen, setLeaveConfirmOpen] = useState(false);
153
163
  const leave = {
154
164
  confirmOpen: leaveConfirmOpen,
@@ -194,7 +204,9 @@ export function useFormEditor(props, { clipboard } = {}) {
194
204
  }
195
205
  return {
196
206
  isNew,
197
- form,
207
+ form, provider, setProvider,
208
+ providers: discovery.data?.data,
209
+ providersError: discovery.error ? `${t("Could not load form providers")}: ${describeApiError({ e: discovery.error, fallback: t("The settings service did not respond. Try opening this editor again.") })}` : null,
198
210
  mode, onModeChange, html, setHtml, copyEmbed, copyFeedback,
199
211
  answerColumns: formAnswerColumns({ fields: form?.fields ?? [] }, { yes: t("Yes"), no: t("No") }),
200
212
  name,
@@ -13,7 +13,7 @@ import { FormEditorMainPanel } from "../components/FormEditorMainPanel.js";
13
13
  * `const`, because a `const` assigned inside `FormEditor` still executes in that function's own
14
14
  * scope — every branch inside it would still count toward `FormEditor`'s own complexity score. */
15
15
  export function FormEditor({ formId, tab, useFormEditorHook = useWiredFormEditor }, _optional = {}) {
16
- const { answerColumns, mode, onModeChange, html, setHtml, copyEmbed, copyFeedback, isNew, form, name, setName, slug, setSlug, fields, setFields, tab: activeTab, onTabChange, error, saving, existingFieldIds, showTabs, tabRefs, onTabsKeyDown, handleSave, handleStatusToggle, leave, t, } = useFormEditorHook({ formId, tab });
16
+ const { answerColumns, provider, setProvider, providers, providersError, mode, onModeChange, html, setHtml, copyEmbed, copyFeedback, isNew, form, name, setName, slug, setSlug, fields, setFields, tab: activeTab, onTabChange, error, saving, existingFieldIds, showTabs, tabRefs, onTabsKeyDown, handleSave, handleStatusToggle, leave, t, } = useFormEditorHook({ formId, tab });
17
17
  if (!isNew && !form && !error)
18
18
  return _jsx("div", { className: "notice", children: t("Loading form…") });
19
19
  // Previously this was the ONLY guard, and it only covers the pre-error case — once the load
@@ -31,7 +31,7 @@ export function FormEditor({ formId, tab, useFormEditorHook = useWiredFormEditor
31
31
  return _jsx("div", { className: "notice error", children: error });
32
32
  // Shared between the "new form" (no tabs, always visible) and "existing form, Fields tab"
33
33
  // views — kept as one JSX value instead of two copies so the two paths can't drift.
34
- const fieldsBody = (_jsx(FormEditorFieldsBody, { mode: mode, onModeChange: onModeChange, html: html, onHtmlChange: setHtml, onCopyEmbed: copyEmbed, copyFeedback: copyFeedback, name: name, onNameChange: setName, slug: slug, onSlugChange: setSlug, isNew: isNew, fields: fields, existingFieldIds: existingFieldIds, onFieldsChange: setFields, form: form, saving: saving, onStatusToggle: handleStatusToggle, onSave: handleSave, t: t }));
34
+ const fieldsBody = (_jsx(FormEditorFieldsBody, { mode: mode, onModeChange: onModeChange, html: html, onHtmlChange: setHtml, onCopyEmbed: copyEmbed, copyFeedback: copyFeedback, provider: provider, onProviderChange: setProvider, providers: providers, providersError: providersError, name: name, onNameChange: setName, slug: slug, onSlugChange: setSlug, isNew: isNew, fields: fields, existingFieldIds: existingFieldIds, onFieldsChange: setFields, form: form, saving: saving, onStatusToggle: handleStatusToggle, onSave: handleSave, t: t }));
35
35
  return (_jsxs("div", { className: "page", children: [_jsxs("div", { className: "page-header page-header-split", ...agentHandle({ handle: "form-editor-header" }, {
36
36
  role: "region",
37
37
  label: "Form editor header — title and the Back to forms link",
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  import type { DataTableSortDirection, DataTableSortState } from '../../core/data-table/types.js';
3
3
  /**
4
4
  * @file The admin list table.
@@ -125,6 +125,11 @@ export interface DataTableProps<Row> {
125
125
  loadingContent?: ReactNode;
126
126
  /** `<tfoot>` content. Rendered as-is: supply your own `<tr>`/`<td>`. */
127
127
  footer?: ReactNode;
128
+ /**
129
+ * Full-width content on its own row (`tr.list-table-detail`) under a row, for what no narrow
130
+ * column can hold. `null` renders no extra row.
131
+ */
132
+ rowDetail?: (row: Row, index: number) => ReactNode;
128
133
  /** Accessible name for the table itself. Worth setting when a screen has more than one. */
129
134
  label?: string;
130
135
  /** `<caption>`. Visible unless the host's CSS hides it; prefer {@link label} for a name that
@@ -1,4 +1,5 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
2
3
  function resolveCellClassName(column, row, index) {
3
4
  return typeof column.cellClassName === 'function'
4
5
  ? column.cellClassName(row, index)
@@ -71,6 +72,9 @@ export function DataTable(props) {
71
72
  }
72
73
  const direction = props.sort?.column === column.key ? props.sort.direction : null;
73
74
  return (_jsx("th", { scope: "col", className: column.headerClassName, "aria-sort": ariaSortValue(direction), children: _jsxs("button", { type: "button", className: "sortable-column-header", onClick: () => props.onSortChange?.(nextSortState(props.sort, column)), "aria-label": column.sort.label(direction), children: [column.header, _jsx("span", { "aria-hidden": "true", children: sortCaretGlyph(direction) })] }) }, column.key));
74
- }) }) }), _jsx("tbody", { children: rows.map((row, index) => (_jsx("tr", { className: props.rowClassName?.(row, index), children: props.columns.map((column) => (_jsx("td", { className: resolveCellClassName(column, row, index), children: column.cell(row, index) }, column.key))) }, props.rowKey(row, index)))) }), props.footer === undefined ? null : _jsx("tfoot", { children: props.footer })] }) }));
75
+ }) }) }), _jsx("tbody", { children: rows.map((row, index) => {
76
+ const detail = props.rowDetail?.(row, index) ?? null;
77
+ return (_jsxs(Fragment, { children: [_jsx("tr", { className: props.rowClassName?.(row, index), children: props.columns.map((column) => (_jsx("td", { className: resolveCellClassName(column, row, index), children: column.cell(row, index) }, column.key))) }), detail === null ? null : (_jsx("tr", { className: "list-table-detail", children: _jsx("td", { colSpan: props.columns.length, children: detail }) }))] }, props.rowKey(row, index)));
78
+ }) }), props.footer === undefined ? null : _jsx("tfoot", { children: props.footer })] }) }));
75
79
  }
76
80
  //# sourceMappingURL=DataTable.js.map
@@ -108,12 +108,14 @@ export function useRowMenu({ itemCount, window, document }) {
108
108
  }, [anchor, window, document]);
109
109
  // Keeps real DOM focus on the active item (roving focus via `tabIndex={-1}` on every item except
110
110
  // the active one) rather than only tracking `activeIndex` in state — arrow-key navigation needs
111
- // to move the browser's actual focus for a screen reader to announce it.
111
+ // to move the browser's actual focus for a screen reader to announce it. Waits for the first
112
+ // position: until then the menu is `visibility: hidden`, and a browser ignores focus on that.
113
+ const visible = open && position !== null;
112
114
  useEffect(() => {
113
- if (!open)
115
+ if (!visible)
114
116
  return;
115
117
  itemRefs.current[activeIndex]?.focus();
116
- }, [open, activeIndex]);
118
+ }, [visible, activeIndex]);
117
119
  function onTriggerClick() {
118
120
  if (open)
119
121
  close(false);
@@ -3,6 +3,7 @@ import type { AdminEntityField } from '../../core/ports/entities.js';
3
3
  import { type EntityTranslate } from './types.js';
4
4
  import { type RelationIndex } from './rules.js';
5
5
  interface EntityFieldProps {
6
+ readonly agentHandle?: string | false | undefined;
6
7
  readonly inputId: string;
7
8
  readonly field: AdminEntityField;
8
9
  readonly value: unknown;
@@ -18,6 +19,6 @@ interface EntityFieldProps {
18
19
  readonly text: string;
19
20
  }) => void;
20
21
  }
21
- export declare function EntityField(props: EntityFieldProps): ReactNode;
22
+ export declare function EntityField(required: EntityFieldProps): ReactNode;
22
23
  export {};
23
24
  //# sourceMappingURL=EntityField.d.ts.map
@@ -1,16 +1,19 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { agentHandleProps } from '@jini-ai/agentic';
3
+ import { useAgentHandle } from '@jini-ai/ui';
2
4
  import { Select } from '@jini-ai/ui/admin-widgets';
3
5
  import { selectTranslate } from './types.js';
4
6
  import { fromDatetimeLocalValue, toDatetimeLocalValue } from './rules.js';
5
7
  const fieldLabel = ({ field, translate }) => translate({ key: field.label ?? field.name });
6
8
  const blankToUndefined = (raw) => (raw === '' ? undefined : raw);
7
- const commonProps = ({ inputId, disabled, invalid }) => ({ id: inputId, disabled, 'aria-invalid': invalid });
9
+ const commonProps = (props) => ({ id: props.inputId, disabled: props.disabled, 'aria-invalid': props.invalid,
10
+ ...agentHandleProps({}, { base: props.agentHandle || undefined, role: 'field', label: fieldLabel(props) }) });
8
11
  function RelationInput(props) {
9
12
  const { inputId, field, value, translate, disabled, onChange } = props;
10
13
  const options = props.relations[field.target]?.options ?? [];
11
14
  const selectedId = typeof value === 'string' ? value : '';
12
15
  const missing = selectedId !== '' && !options.some((option) => option.id === selectedId);
13
- return _jsx(Select, { id: inputId, disabled: disabled, value: selectedId, translate: selectTranslate({ translate }), "aria-label": fieldLabel(props), options: [
16
+ return _jsx(Select, { id: inputId, agentHandle: props.agentHandle, disabled: disabled, value: selectedId, translate: selectTranslate({ translate }), "aria-label": fieldLabel(props), options: [
14
17
  { value: '', label: translate({ key: 'No value' }) },
15
18
  ...(missing ? [{ value: selectedId, label: `${selectedId} (${translate({ key: 'Unresolved' })})` }] : []),
16
19
  ...options.map((option) => ({ value: option.id, label: option.title })),
@@ -25,7 +28,7 @@ function BooleanInput(props) {
25
28
  const { inputId, field, value, translate, disabled, onChange } = props;
26
29
  if (field.required)
27
30
  return _jsx("input", { ...commonProps(props), type: "checkbox", checked: value === true, onChange: (e) => onChange({ value: e.target.checked }) });
28
- return _jsx(Select, { id: inputId, disabled: disabled, value: booleanSelectValue(value), translate: selectTranslate({ translate }), "aria-label": fieldLabel(props), options: [
31
+ return _jsx(Select, { id: inputId, agentHandle: props.agentHandle, disabled: disabled, value: booleanSelectValue(value), translate: selectTranslate({ translate }), "aria-label": fieldLabel(props), options: [
29
32
  { value: '', label: translate({ key: 'No value' }) }, { value: 'true', label: translate({ key: 'Yes' }) }, { value: 'false', label: translate({ key: 'No' }) },
30
33
  ], onChange: (selected) => onChange({ value: selected === '' ? undefined : selected === 'true' }) });
31
34
  }
@@ -33,7 +36,9 @@ function NumberInput(props) {
33
36
  const { field, value, onChange } = props;
34
37
  return _jsx("input", { ...commonProps(props), type: "number", step: field.kind === 'integer' ? '1' : 'any', value: typeof value === 'number' ? value : '', onChange: (e) => onChange({ value: e.target.value === '' ? undefined : Number(e.target.value) }) });
35
38
  }
36
- export function EntityField(props) {
39
+ export function EntityField(required) {
40
+ const base = useAgentHandle({ agentHandle: required.agentHandle });
41
+ const props = { ...required, agentHandle: base ?? false };
37
42
  const { field, value, onChange } = props;
38
43
  switch (field.kind) {
39
44
  case 'json': return _jsx("textarea", { ...commonProps(props), value: props.text, onChange: (e) => props.onTextChange({ text: e.target.value }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/admin",
3
- "version": "0.6.19",
3
+ "version": "0.7.0",
4
4
  "description": "Composable admin surface for Jini-hosted products: framework-free contracts, panel registry, and route model in `/core`; React shell and panels in `/react`. Import only the layers you need.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -458,12 +458,12 @@
458
458
  "peerDependencies": {
459
459
  "react": "^18.3.0 || ^19.0.0",
460
460
  "react-dom": "^18.3.0 || ^19.0.0",
461
- "@jini-ai/agentic": "^0.6.10",
462
- "@jini-ai/ui": "^0.6.10",
463
- "@jini-ai/ui-kit": "^0.6.10",
464
- "@jini-ai/agent-plugins": "^0.6.10",
465
- "@jini-ai/cms": "^0.6.10",
466
- "@jini-ai/core": "^0.6.10"
461
+ "@jini-ai/agentic": "^0.7.0",
462
+ "@jini-ai/ui": "^0.7.0",
463
+ "@jini-ai/ui-kit": "^0.7.0",
464
+ "@jini-ai/agent-plugins": "^0.7.0",
465
+ "@jini-ai/cms": "^0.7.0",
466
+ "@jini-ai/core": "^0.7.0"
467
467
  },
468
468
  "devDependencies": {
469
469
  "@testing-library/jest-dom": "^6.6.3",
@@ -475,12 +475,12 @@
475
475
  "react": "^19.2.0",
476
476
  "react-dom": "^19.2.0",
477
477
  "@testing-library/user-event": "^14.6.1",
478
- "@jini-ai/ui": "^0.6.19",
479
- "@jini-ai/ui-kit": "^0.6.19",
480
- "@jini-ai/cms": "^0.6.19",
481
- "@jini-ai/agent-plugins": "^0.6.19",
482
- "@jini-ai/core": "^0.6.19",
483
- "@jini-ai/agentic": "^0.6.19"
478
+ "@jini-ai/agentic": "^0.7.0",
479
+ "@jini-ai/ui": "^0.7.0",
480
+ "@jini-ai/ui-kit": "^0.7.0",
481
+ "@jini-ai/agent-plugins": "^0.7.0",
482
+ "@jini-ai/cms": "^0.7.0",
483
+ "@jini-ai/core": "^0.7.0"
484
484
  },
485
485
  "typesVersions": {
486
486
  "*": {