@cratis/components 4.44.4 → 4.46.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.
- package/compat-manifest.json +13 -13
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +2 -1
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandForm/AutoCommandFields.d.ts +32 -0
- package/dist/esm/CommandForm/AutoCommandFields.d.ts.map +1 -0
- package/dist/esm/CommandForm/AutoCommandFields.js +26 -0
- package/dist/esm/CommandForm/AutoCommandFields.js.map +1 -0
- package/dist/esm/CommandForm/AutoCommandForm.d.ts.map +1 -1
- package/dist/esm/CommandForm/AutoCommandForm.js +5 -32
- package/dist/esm/CommandForm/AutoCommandForm.js.map +1 -1
- package/dist/esm/CommandForm/commandOverlayContext.d.ts +6 -0
- package/dist/esm/CommandForm/commandOverlayContext.d.ts.map +1 -0
- package/dist/esm/CommandForm/commandOverlayContext.js +6 -0
- package/dist/esm/CommandForm/commandOverlayContext.js.map +1 -0
- package/dist/esm/CommandForm/generatedFields.d.ts +15 -0
- package/dist/esm/CommandForm/generatedFields.d.ts.map +1 -0
- package/dist/esm/CommandForm/generatedFields.js +44 -0
- package/dist/esm/CommandForm/generatedFields.js.map +1 -0
- package/dist/esm/CommandForm/index.d.ts +1 -0
- package/dist/esm/CommandForm/index.d.ts.map +1 -1
- package/dist/esm/CommandForm/index.js +1 -0
- package/dist/esm/CommandForm/index.js.map +1 -1
- package/dist/esm/renderer/presentation.d.ts +20 -1
- package/dist/esm/renderer/presentation.d.ts.map +1 -1
- package/dist/esm/renderer/presentation.js +6 -1
- package/dist/esm/renderer/presentation.js.map +1 -1
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
{
|
|
71
71
|
"name": "@cratis/components",
|
|
72
72
|
"role": "core",
|
|
73
|
-
"version": "4.
|
|
73
|
+
"version": "4.46.0",
|
|
74
74
|
"releaseMajorRange": ">=4 <5",
|
|
75
75
|
"independentRelease": false,
|
|
76
76
|
"private": false,
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
{
|
|
95
95
|
"name": "@cratis/eslint-plugin-components",
|
|
96
96
|
"role": "eslint",
|
|
97
|
-
"version": "4.
|
|
97
|
+
"version": "4.46.0",
|
|
98
98
|
"releaseMajorRange": ">=4 <5",
|
|
99
99
|
"independentRelease": false,
|
|
100
100
|
"private": false,
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
{
|
|
108
108
|
"name": "@cratis/components.migrator",
|
|
109
109
|
"role": "migrator",
|
|
110
|
-
"version": "4.
|
|
110
|
+
"version": "4.46.0",
|
|
111
111
|
"releaseMajorRange": ">=4 <5",
|
|
112
112
|
"independentRelease": false,
|
|
113
113
|
"private": false,
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
{
|
|
119
119
|
"name": "@cratis/components.conformance",
|
|
120
120
|
"role": "conformance",
|
|
121
|
-
"version": "4.
|
|
121
|
+
"version": "4.46.0",
|
|
122
122
|
"releaseMajorRange": ">=4 <5",
|
|
123
123
|
"independentRelease": false,
|
|
124
124
|
"private": false,
|
|
125
125
|
"packageAccess": "public",
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@cratis/components": "4.
|
|
127
|
+
"@cratis/components": "4.46.0",
|
|
128
128
|
"react": "^19.0.0",
|
|
129
129
|
"react-dom": "^19.0.0"
|
|
130
130
|
},
|
|
@@ -134,13 +134,13 @@
|
|
|
134
134
|
{
|
|
135
135
|
"name": "@cratis/components.mui",
|
|
136
136
|
"role": "renderer-adapter",
|
|
137
|
-
"version": "4.
|
|
137
|
+
"version": "4.46.0",
|
|
138
138
|
"releaseMajorRange": ">=4 <5",
|
|
139
139
|
"independentRelease": false,
|
|
140
140
|
"private": false,
|
|
141
141
|
"packageAccess": "public",
|
|
142
142
|
"peerDependencies": {
|
|
143
|
-
"@cratis/components": "4.
|
|
143
|
+
"@cratis/components": "4.46.0",
|
|
144
144
|
"@emotion/react": ">=11.5 <12",
|
|
145
145
|
"@emotion/styled": ">=11.11 <12",
|
|
146
146
|
"@mui/material": ">=9 <10",
|
|
@@ -190,13 +190,13 @@
|
|
|
190
190
|
{
|
|
191
191
|
"name": "@cratis/components.primereact",
|
|
192
192
|
"role": "renderer-adapter",
|
|
193
|
-
"version": "4.
|
|
193
|
+
"version": "4.46.0",
|
|
194
194
|
"releaseMajorRange": ">=4 <5",
|
|
195
195
|
"independentRelease": false,
|
|
196
196
|
"private": false,
|
|
197
197
|
"packageAccess": "public",
|
|
198
198
|
"peerDependencies": {
|
|
199
|
-
"@cratis/components": "4.
|
|
199
|
+
"@cratis/components": "4.46.0",
|
|
200
200
|
"@primereact/core": ">=11 <12",
|
|
201
201
|
"@primereact/ui": ">=11 <12",
|
|
202
202
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -258,13 +258,13 @@
|
|
|
258
258
|
{
|
|
259
259
|
"name": "@cratis/components.primereact10",
|
|
260
260
|
"role": "renderer-adapter",
|
|
261
|
-
"version": "4.
|
|
261
|
+
"version": "4.46.0",
|
|
262
262
|
"releaseMajorRange": ">=4 <5",
|
|
263
263
|
"independentRelease": false,
|
|
264
264
|
"private": false,
|
|
265
265
|
"packageAccess": "public",
|
|
266
266
|
"peerDependencies": {
|
|
267
|
-
"@cratis/components": "4.
|
|
267
|
+
"@cratis/components": "4.46.0",
|
|
268
268
|
"primereact": ">=10.9.9 <11",
|
|
269
269
|
"react": "^19.0.0",
|
|
270
270
|
"react-dom": "^19.0.0"
|
|
@@ -306,13 +306,13 @@
|
|
|
306
306
|
{
|
|
307
307
|
"name": "@cratis/components.designsystemet",
|
|
308
308
|
"role": "renderer-adapter",
|
|
309
|
-
"version": "4.
|
|
309
|
+
"version": "4.46.0",
|
|
310
310
|
"releaseMajorRange": ">=4 <5",
|
|
311
311
|
"independentRelease": false,
|
|
312
312
|
"private": false,
|
|
313
313
|
"packageAccess": "public",
|
|
314
314
|
"peerDependencies": {
|
|
315
|
-
"@cratis/components": "4.
|
|
315
|
+
"@cratis/components": "4.46.0",
|
|
316
316
|
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
317
317
|
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
318
318
|
"react": "^19.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAmB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAmB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AAQnE;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,CAC3E,SACI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC3E,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC;IAChE;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAElD;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAEtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAqHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AACH,QAAA,MAAM,sBAAsB;KAAI,QAAQ,SAAS,MAAM,WAAW,SAAS,kBAChE,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC;;CA4FjD,CAAC;AAEF,QAAA,MAAM,0BAA0B,iBAAkB;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAE9E,CAAC;AAKF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,+BAAyB,CAAC"}
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
6
6
|
import { useCommandExecution } from './useCommandExecution.js';
|
|
7
7
|
import { markAsCommandFormColumn, isCommandFormField } from '../CommandForm/commandFormMarkers.js';
|
|
8
|
+
import { CommandOverlayContext } from '../CommandForm/commandOverlayContext.js';
|
|
8
9
|
|
|
9
10
|
const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, children, ...dialogProps }) => {
|
|
10
11
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, } = useCommandFormContext();
|
|
@@ -95,7 +96,7 @@ const CommandDialogComponent = (props) => {
|
|
|
95
96
|
ptOptions,
|
|
96
97
|
unstyled,
|
|
97
98
|
};
|
|
98
|
-
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, children: children }) }));
|
|
99
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandOverlayContext.Provider, { value: commandFormProps.currentValues, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, children: children }) }) }));
|
|
99
100
|
};
|
|
100
101
|
const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
|
|
101
102
|
markAsCommandFormColumn(CommandDialogColumnWrapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps,\n} from '@cratis/arc.react/commands';\nimport type { BeforeExecuteCallback } from './applyBeforeExecute';\nimport type { ConfirmBeforeExecute } from './confirmBeforeExecute';\nimport { useCommandExecution } from './useCommandExecution';\nimport {\n isCommandFormField,\n markAsCommandFormColumn,\n} from '../CommandForm/commandFormMarkers';\n\n/**\n * Props for {@link CommandDialog}. Combines the props of a `CommandForm`\n * (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,\n * `onBeforeExecute`, etc.) with the props of a {@link Dialog} (`title`,\n * `buttons`, `width`, `pt`, `unstyled`, …). Dialog presentation props\n * such as `subtitle`, `placement`, and `closeIcon` are forwarded to the dialog.\n *\n * @typeParam TCommand - The command record type (must extend `object`).\n * @typeParam TResponse - The response payload type returned by a successful command. Defaults to `object`.\n */\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends\n Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>,\n Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> {\n /**\n * A transformer invoked with the current command values immediately before\n * the command executes on confirm. It **must return** the values to run with\n * (mutated or not) — a callback that returns nothing does not execute the\n * command with `undefined`; the current values are kept and a warning is\n * logged. May be async.\n *\n * ⚠️ It runs **only on submit**, after the form has already been validated,\n * so a value produced here can never satisfy required-field validation — the\n * submit button stays disabled if a required value is only seeded here. Seed\n * required values through `initialValues`; reserve `onBeforeExecute` for\n * transforms that do not affect validity (for example a generated id).\n */\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n\n /**\n * Ask whether to run the command after validation and `onBeforeExecute`.\n * Receives the transformed values. Only `true` executes; all other outcomes\n * keep the dialog open. May return a promise (for example from a confirmation dialog).\n * If command values change while confirmation is pending, execution is skipped\n * and the dialog stays open; confirm the new values again.\n * Unlike `onConfirm`, this runs before execution, not after success.\n */\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n\n /**\n * Form fields and arbitrary content for the dialog body. Children that are\n * `CommandFormField` instances are automatically wrapped so they bind to\n * the command instance.\n */\n children?: React.ReactNode;\n}\n\n// Requiring each key here makes a newly added Dialog prop fail compilation until it is routed.\ntype ForwardedDialogProps = Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> &\n Record<keyof Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'>, unknown>;\n\nconst CommandDialogWrapper = <TCommand extends object, TResponse = object>({\n isValid,\n onClose,\n onConfirm,\n onSuccess,\n onValidationFailure,\n onFailed,\n onException,\n onUnauthorized,\n onBeforeExecute,\n confirmBeforeExecute,\n children,\n ...dialogProps\n}: Omit<DialogProps, 'isBusy'> & {\n onSuccess?: CommandFormProps<TCommand, TResponse>['onSuccess'];\n onValidationFailure?: CommandFormProps<TCommand, TResponse>['onValidationFailure'];\n onFailed?: CommandFormProps<TCommand, TResponse>['onFailed'];\n onException?: CommandFormProps<TCommand, TResponse>['onException'];\n onUnauthorized?: CommandFormProps<TCommand, TResponse>['onUnauthorized'];\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n}) => {\n const {\n setCommandValues,\n setCommandResult,\n isValid: isCommandFormValid,\n } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const submission = useCommandExecution<TCommand, TResponse>(\n commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException,\n );\n\n const handleConfirm = async () => {\n const result = await submission.run();\n if (!result) return false;\n\n if (!result.isSuccess) {\n await onFailed?.(result);\n if (result.hasExceptions) {\n await onException?.(result.exceptionMessages, result.exceptionStackTrace);\n }\n if (!result.isAuthorized) await onUnauthorized?.();\n if (!result.isValid) {\n await onValidationFailure?.(result.validationResults);\n }\n if (submission.isMounted()) setCommandResult(result);\n return false;\n }\n\n await onSuccess?.(result.response as TResponse);\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\n return true;\n };\n\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<\n typeof CommandFormFieldWrapper\n >[0]['field'];\n // SAFETY: isCommandFormField guards that child.type is a command form field component.\n return (\n <CommandFormFieldWrapper field={child as unknown as FieldElement} />\n );\n }\n\n const childProps = child.props as Record<string, unknown>;\n // A function child is a render prop, not a node: mapping it would replace the\n // function with its mapped result and break the component that calls it.\n if (childProps.children != null && typeof childProps.children !== 'function') {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n };\n\n const processedChildren = processChildren(children);\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n return (\n <Dialog\n {...dialogProps}\n onClose={onClose}\n onConfirm={handleConfirm}\n isValid={isDialogValid}\n isBusy={submission.isSubmitting}\n isCommandDialog\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * ## Where `TCommand` comes from\n *\n * `TCommand` is an auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# `[Command]` record. `dotnet build` writes a `.ts` file\n * per command with the right property types and a typed `execute()` method;\n * importing the class is all the connection-to-the-backend you need. The\n * class also exposes a `.use()` hook for direct (non-dialog) usage and a\n * `useWithChangeTracking()` variant.\n *\n * ## What happens on confirm\n *\n * 1. If `onBeforeExecute` is supplied, it transforms the command values.\n * Used for generated IDs (`Guid.create()`) that the user did not type in.\n * 2. The command's `execute()` runs through Arc's command pipeline. The\n * backend handler returns either a typed response (mapped to `TResponse`)\n * or a `ValidationResult[]`.\n * 3. On `IsSuccess: true`, `onSuccess(response)` fires and the dialog closes\n * through the dialog host context.\n * 4. On a validation failure, `onValidationFailure(errors)` fires and the\n * form's per-field error display is updated. The dialog stays open.\n * 5. On a domain or transport failure, `onFailed(result)` fires. The dialog\n * stays open and the `CommandResult` is set on the form context so the\n * UI can surface the error to the user.\n *\n * Throughout, the dialog is in the `isBusy` state — the confirm button keeps\n * focus but is `aria-disabled` and ignores activation, the other action\n * buttons are disabled, and the confirm button shows a spinner.\n *\n * ## Destructive commands and initial focus\n *\n * The confirm button is focused when the dialog opens, and a focused native\n * button fires `click` from the `keydown` of `Enter`. A command whose form\n * has required fields is protected from a held or double-tapped `Enter` for\n * free, because `isCommandFormValid` keeps confirm disabled until something\n * is filled in. A command that takes **no** input — the typical \"delete\n * this, permanently\" command — has no such gate, so its confirm button is\n * armed the instant the dialog appears.\n *\n * Pass `initialFocus` (forwarded straight to {@link Dialog}) for those:\n *\n * ```tsx\n * <CommandDialog<DeletePerson>\n * command={DeletePerson}\n * title=\"Delete personal data?\"\n * okLabel=\"Delete\"\n * initialFocus={DialogInitialFocus.Cancel}\n * onSuccess={() => closeDialog(DialogResult.Ok)}>\n * This cannot be undone.\n * </CommandDialog>\n * ```\n *\n * Everything else — the footer, the close (X), `Escape`, and the confirm\n * wiring that runs the command — is untouched.\n *\n * ## Field binding\n *\n * Children that are `CommandFormField` instances (`InputTextField`,\n * `NumberField`, `DropdownField`, every `@cratis/components/CommandForm/fields`\n * widget) bind to a property on the command via the `value` accessor:\n *\n * ```tsx\n * <InputTextField value={c => c.name} title=\"Name\" />\n * ```\n *\n * The accessor's argument is the command instance — TypeScript infers\n * `c.name` is a string and the field type-checks against that. Arbitrary\n * non-field children (custom layout, additional text, decorative elements)\n * are rendered as plain content.\n *\n * ## Typed dialog host usage\n *\n * Combine with `useDialog<CommandResult<TResponse>>()` from\n * `@cratis/arc.react/dialogs` to get a fully-typed result at the call site:\n *\n * ```tsx\n * import { useDialog, DialogResult } from '@cratis/arc.react/dialogs';\n * import { CommandDialog } from '@cratis/components/CommandDialog';\n * import { RegisterAuthor } from './RegisterAuthor'; // proxy from C#\n *\n * type RegisterAuthorResponse = { authorId: string };\n *\n * const RegisterAuthorDialog = () => {\n * const { closeDialog } = useDialogContext<CommandResult<RegisterAuthorResponse>>();\n * return (\n * <CommandDialog<RegisterAuthor, RegisterAuthorResponse>\n * command={RegisterAuthor}\n * title=\"Register author\"\n * okLabel=\"Register\"\n * onSuccess={(response) => closeDialog(DialogResult.Ok)}\n * onCancel={() => closeDialog(DialogResult.Cancelled)}>\n * <InputTextField value={c => c.name} title=\"Name\" />\n * <InputTextField value={c => c.email} title=\"Email\" />\n * </CommandDialog>\n * );\n * };\n * ```\n *\n * ## What's special vs. raw Dialog + CommandForm\n *\n * - Confirm wiring (`onConfirm` → `commandInstance.execute()`) is handled\n * internally; you only supply `onSuccess` / `onValidationFailure` / `onFailed`.\n * - The dialog's `isBusy` state tracks the in-flight command without manual\n * `useState`.\n * - Field error propagation from `CommandResult.validationResults` to the\n * form context is automatic.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n * @param props - {@link CommandDialogProps}.\n */\nconst CommandDialogComponent = <TCommand extends object = object, TResponse = object>(\n props: CommandDialogProps<TCommand, TResponse>,\n) => {\n const {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n confirmBeforeExecute,\n className,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n const dialogProps = {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n className,\n pt,\n ptOptions,\n unstyled,\n } satisfies ForwardedDialogProps;\n\n return (\n <CommandForm<TCommand, TResponse> {...commandFormProps}>\n <CommandDialogWrapper<TCommand, TResponse>\n {...dialogProps}\n onSuccess={props.onSuccess}\n onValidationFailure={props.onValidationFailure}\n onFailed={props.onFailed}\n onException={props.onException}\n onUnauthorized={props.onUnauthorized}\n onBeforeExecute={onBeforeExecute}\n confirmBeforeExecute={confirmBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nmarkAsCommandFormColumn(CommandDialogColumnWrapper);\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * See {@link CommandDialogComponent} for full documentation.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n */\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;;;AAwEA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,GAAG,WAAW,EASjB,KAAI;AACD,IAAA,MAAM,EACF,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EAAE,kBAAkB,GAC9B,GAAG,qBAAqB,EAAY;AACrC,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AACtD,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAClC,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,WAAW,CACxF;AAED,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0BAA0B;AAcnD,MAAM,aAAa,GAAG;;"}
|
|
1
|
+
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps,\n} from '@cratis/arc.react/commands';\nimport type { BeforeExecuteCallback } from './applyBeforeExecute';\nimport type { ConfirmBeforeExecute } from './confirmBeforeExecute';\nimport { useCommandExecution } from './useCommandExecution';\nimport {\n isCommandFormField,\n markAsCommandFormColumn,\n} from '../CommandForm/commandFormMarkers';\nimport { CommandOverlayContext } from '../CommandForm/commandOverlayContext';\n\n/**\n * Props for {@link CommandDialog}. Combines the props of a `CommandForm`\n * (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,\n * `onBeforeExecute`, etc.) with the props of a {@link Dialog} (`title`,\n * `buttons`, `width`, `pt`, `unstyled`, …). Dialog presentation props\n * such as `subtitle`, `placement`, and `closeIcon` are forwarded to the dialog.\n *\n * @typeParam TCommand - The command record type (must extend `object`).\n * @typeParam TResponse - The response payload type returned by a successful command. Defaults to `object`.\n */\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends\n Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>,\n Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> {\n /**\n * A transformer invoked with the current command values immediately before\n * the command executes on confirm. It **must return** the values to run with\n * (mutated or not) — a callback that returns nothing does not execute the\n * command with `undefined`; the current values are kept and a warning is\n * logged. May be async.\n *\n * ⚠️ It runs **only on submit**, after the form has already been validated,\n * so a value produced here can never satisfy required-field validation — the\n * submit button stays disabled if a required value is only seeded here. Seed\n * required values through `initialValues`; reserve `onBeforeExecute` for\n * transforms that do not affect validity (for example a generated id).\n */\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n\n /**\n * Ask whether to run the command after validation and `onBeforeExecute`.\n * Receives the transformed values. Only `true` executes; all other outcomes\n * keep the dialog open. May return a promise (for example from a confirmation dialog).\n * If command values change while confirmation is pending, execution is skipped\n * and the dialog stays open; confirm the new values again.\n * Unlike `onConfirm`, this runs before execution, not after success.\n */\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n\n /**\n * Form fields and arbitrary content for the dialog body. Children that are\n * `CommandFormField` instances are automatically wrapped so they bind to\n * the command instance.\n */\n children?: React.ReactNode;\n}\n\n// Requiring each key here makes a newly added Dialog prop fail compilation until it is routed.\ntype ForwardedDialogProps = Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> &\n Record<keyof Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'>, unknown>;\n\nconst CommandDialogWrapper = <TCommand extends object, TResponse = object>({\n isValid,\n onClose,\n onConfirm,\n onSuccess,\n onValidationFailure,\n onFailed,\n onException,\n onUnauthorized,\n onBeforeExecute,\n confirmBeforeExecute,\n children,\n ...dialogProps\n}: Omit<DialogProps, 'isBusy'> & {\n onSuccess?: CommandFormProps<TCommand, TResponse>['onSuccess'];\n onValidationFailure?: CommandFormProps<TCommand, TResponse>['onValidationFailure'];\n onFailed?: CommandFormProps<TCommand, TResponse>['onFailed'];\n onException?: CommandFormProps<TCommand, TResponse>['onException'];\n onUnauthorized?: CommandFormProps<TCommand, TResponse>['onUnauthorized'];\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n}) => {\n const {\n setCommandValues,\n setCommandResult,\n isValid: isCommandFormValid,\n } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const submission = useCommandExecution<TCommand, TResponse>(\n commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException,\n );\n\n const handleConfirm = async () => {\n const result = await submission.run();\n if (!result) return false;\n\n if (!result.isSuccess) {\n await onFailed?.(result);\n if (result.hasExceptions) {\n await onException?.(result.exceptionMessages, result.exceptionStackTrace);\n }\n if (!result.isAuthorized) await onUnauthorized?.();\n if (!result.isValid) {\n await onValidationFailure?.(result.validationResults);\n }\n if (submission.isMounted()) setCommandResult(result);\n return false;\n }\n\n await onSuccess?.(result.response as TResponse);\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\n return true;\n };\n\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<\n typeof CommandFormFieldWrapper\n >[0]['field'];\n // SAFETY: isCommandFormField guards that child.type is a command form field component.\n return (\n <CommandFormFieldWrapper field={child as unknown as FieldElement} />\n );\n }\n\n const childProps = child.props as Record<string, unknown>;\n // A function child is a render prop, not a node: mapping it would replace the\n // function with its mapped result and break the component that calls it.\n if (childProps.children != null && typeof childProps.children !== 'function') {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n };\n\n const processedChildren = processChildren(children);\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n return (\n <Dialog\n {...dialogProps}\n onClose={onClose}\n onConfirm={handleConfirm}\n isValid={isDialogValid}\n isBusy={submission.isSubmitting}\n isCommandDialog\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * ## Where `TCommand` comes from\n *\n * `TCommand` is an auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# `[Command]` record. `dotnet build` writes a `.ts` file\n * per command with the right property types and a typed `execute()` method;\n * importing the class is all the connection-to-the-backend you need. The\n * class also exposes a `.use()` hook for direct (non-dialog) usage and a\n * `useWithChangeTracking()` variant.\n *\n * ## What happens on confirm\n *\n * 1. If `onBeforeExecute` is supplied, it transforms the command values.\n * Used for generated IDs (`Guid.create()`) that the user did not type in.\n * 2. The command's `execute()` runs through Arc's command pipeline. The\n * backend handler returns either a typed response (mapped to `TResponse`)\n * or a `ValidationResult[]`.\n * 3. On `IsSuccess: true`, `onSuccess(response)` fires and the dialog closes\n * through the dialog host context.\n * 4. On a validation failure, `onValidationFailure(errors)` fires and the\n * form's per-field error display is updated. The dialog stays open.\n * 5. On a domain or transport failure, `onFailed(result)` fires. The dialog\n * stays open and the `CommandResult` is set on the form context so the\n * UI can surface the error to the user.\n *\n * Throughout, the dialog is in the `isBusy` state — the confirm button keeps\n * focus but is `aria-disabled` and ignores activation, the other action\n * buttons are disabled, and the confirm button shows a spinner.\n *\n * ## Destructive commands and initial focus\n *\n * The confirm button is focused when the dialog opens, and a focused native\n * button fires `click` from the `keydown` of `Enter`. A command whose form\n * has required fields is protected from a held or double-tapped `Enter` for\n * free, because `isCommandFormValid` keeps confirm disabled until something\n * is filled in. A command that takes **no** input — the typical \"delete\n * this, permanently\" command — has no such gate, so its confirm button is\n * armed the instant the dialog appears.\n *\n * Pass `initialFocus` (forwarded straight to {@link Dialog}) for those:\n *\n * ```tsx\n * <CommandDialog<DeletePerson>\n * command={DeletePerson}\n * title=\"Delete personal data?\"\n * okLabel=\"Delete\"\n * initialFocus={DialogInitialFocus.Cancel}\n * onSuccess={() => closeDialog(DialogResult.Ok)}>\n * This cannot be undone.\n * </CommandDialog>\n * ```\n *\n * Everything else — the footer, the close (X), `Escape`, and the confirm\n * wiring that runs the command — is untouched.\n *\n * ## Field binding\n *\n * Children that are `CommandFormField` instances (`InputTextField`,\n * `NumberField`, `DropdownField`, every `@cratis/components/CommandForm/fields`\n * widget) bind to a property on the command via the `value` accessor:\n *\n * ```tsx\n * <InputTextField value={c => c.name} title=\"Name\" />\n * ```\n *\n * The accessor's argument is the command instance — TypeScript infers\n * `c.name` is a string and the field type-checks against that. Arbitrary\n * non-field children (custom layout, additional text, decorative elements)\n * are rendered as plain content.\n *\n * ## Typed dialog host usage\n *\n * Combine with `useDialog<CommandResult<TResponse>>()` from\n * `@cratis/arc.react/dialogs` to get a fully-typed result at the call site:\n *\n * ```tsx\n * import { useDialog, DialogResult } from '@cratis/arc.react/dialogs';\n * import { CommandDialog } from '@cratis/components/CommandDialog';\n * import { RegisterAuthor } from './RegisterAuthor'; // proxy from C#\n *\n * type RegisterAuthorResponse = { authorId: string };\n *\n * const RegisterAuthorDialog = () => {\n * const { closeDialog } = useDialogContext<CommandResult<RegisterAuthorResponse>>();\n * return (\n * <CommandDialog<RegisterAuthor, RegisterAuthorResponse>\n * command={RegisterAuthor}\n * title=\"Register author\"\n * okLabel=\"Register\"\n * onSuccess={(response) => closeDialog(DialogResult.Ok)}\n * onCancel={() => closeDialog(DialogResult.Cancelled)}>\n * <InputTextField value={c => c.name} title=\"Name\" />\n * <InputTextField value={c => c.email} title=\"Email\" />\n * </CommandDialog>\n * );\n * };\n * ```\n *\n * ## What's special vs. raw Dialog + CommandForm\n *\n * - Confirm wiring (`onConfirm` → `commandInstance.execute()`) is handled\n * internally; you only supply `onSuccess` / `onValidationFailure` / `onFailed`.\n * - The dialog's `isBusy` state tracks the in-flight command without manual\n * `useState`.\n * - Field error propagation from `CommandResult.validationResults` to the\n * form context is automatic.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n * @param props - {@link CommandDialogProps}.\n */\nconst CommandDialogComponent = <TCommand extends object = object, TResponse = object>(\n props: CommandDialogProps<TCommand, TResponse>,\n) => {\n const {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n confirmBeforeExecute,\n className,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n const dialogProps = {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n className,\n pt,\n ptOptions,\n unstyled,\n } satisfies ForwardedDialogProps;\n\n return (\n <CommandForm<TCommand, TResponse> {...commandFormProps}>\n <CommandOverlayContext.Provider value={commandFormProps.currentValues}>\n <CommandDialogWrapper<TCommand, TResponse>\n {...dialogProps}\n onSuccess={props.onSuccess}\n onValidationFailure={props.onValidationFailure}\n onFailed={props.onFailed}\n onException={props.onException}\n onUnauthorized={props.onUnauthorized}\n onBeforeExecute={onBeforeExecute}\n confirmBeforeExecute={confirmBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandOverlayContext.Provider>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nmarkAsCommandFormColumn(CommandDialogColumnWrapper);\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * See {@link CommandDialogComponent} for full documentation.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n */\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAyEA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,GAAG,WAAW,EASjB,KAAI;AACD,IAAA,MAAM,EACF,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EAAE,kBAAkB,GAC9B,GAAG,qBAAqB,EAAY;AACrC,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AACtD,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAClC,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,WAAW,CACxF;AAED,IAAA,MAAM,aAAa,GAAG,YAAW;AAC7B,QAAA,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE;AACrC,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;AAEzB,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;AACnB,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC;AACxB,YAAA,IAAI,MAAM,CAAC,aAAa,EAAE;gBACtB,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;YAC7E;YACA,IAAI,CAAC,MAAM,CAAC,YAAY;gBAAE,MAAM,cAAc,IAAI;AAClD,YAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AAC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ACP,WAAW;QACX,qBAAqB;QACrB,aAAa;QACb,eAAe;QACf,cAAc;QACd,OAAO;QACP,OAAO;QACP,SAAS;QACT,QAAQ;QACR,SAAS;QACT,EAAE;QACF,SAAS;QACT,QAAQ;KACoB;AAEhC,IAAA,QACIA,GAAA,CAAC,WAAW,EAAA,EAAA,GAA0B,gBAAgB,EAAA,QAAA,EAClDA,GAAA,CAAC,qBAAqB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,gBAAgB,CAAC,aAAa,EAAA,QAAA,EACjEA,GAAA,CAAC,oBAAoB,EAAA,EAAA,GACb,WAAW,EACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAAA,QAAA,EAEzC,QAAQ,EAAA,CACU,EAAA,CACM,EAAA,CACvB;AAEtB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAE,QAAQ,EAAiC,MAC3EA,GAAA,CAAC,WAAW,CAAC,MAAM,cAAE,QAAQ,EAAA,CAAsB,CACtD;AACD,uBAAuB,CAAC,0BAA0B,CAAC;AAEnD,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAcnD,MAAM,aAAa,GAAG;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link AutoCommandFields}.
|
|
4
|
+
*/
|
|
5
|
+
export interface AutoCommandFieldsProps<TCommand extends object> {
|
|
6
|
+
/**
|
|
7
|
+
* Property names to leave out of the generated field list.
|
|
8
|
+
*/
|
|
9
|
+
exclude?: (keyof TCommand)[];
|
|
10
|
+
/**
|
|
11
|
+
* A read-only reset hint: the same `currentValues` overlay passed to the host form. A change to a
|
|
12
|
+
* property's value discards a generated `GuidField`'s unfinished draft, as in `AutoCommandForm`. It
|
|
13
|
+
* never writes values; the host stays authoritative. Inside `CommandDialog` it defaults to the
|
|
14
|
+
* dialog's own `currentValues`; pass it explicitly for a plain `CommandForm`.
|
|
15
|
+
*/
|
|
16
|
+
currentValues?: Partial<TCommand>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates fields from the host command's own properties, using the same type providers, titles,
|
|
20
|
+
* `exclude` and omission rules as {@link AutoCommandForm}, inside an existing `CommandForm` or
|
|
21
|
+
* `CommandDialog`. It renders no form of its own; values, validation and execution belong to the host.
|
|
22
|
+
* Each field binds itself to the host's command context. Steppers and column layouts are not supported.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <CommandDialog command={RenameProject} title='Rename project'>
|
|
27
|
+
* <AutoCommandFields<RenameProject> exclude={['projectId']} />
|
|
28
|
+
* </CommandDialog>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function AutoCommandFields<TCommand extends object = object>(props: AutoCommandFieldsProps<TCommand>): React.ReactElement;
|
|
32
|
+
//# sourceMappingURL=AutoCommandFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoCommandFields.d.ts","sourceRoot":"","sources":["../../../CommandForm/AutoCommandFields.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,QAAQ,SAAS,MAAM;IAC3D;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACrC;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAC9D,KAAK,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GACxC,KAAK,CAAC,YAAY,CAmBpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { CommandFormFieldWrapper, useCommandFormContext } from '@cratis/arc.react/commands';
|
|
4
|
+
import { CommandOverlayContext } from './commandOverlayContext.js';
|
|
5
|
+
import { useCommandPropertyDescriptors, useExcludedProperties, generateFields } from './generatedFields.js';
|
|
6
|
+
|
|
7
|
+
function useHostCommand() {
|
|
8
|
+
try {
|
|
9
|
+
return useCommandFormContext().command;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
throw new Error('AutoCommandFields must be rendered inside a CommandForm or CommandDialog.');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function AutoCommandFields(props) {
|
|
16
|
+
const command = useHostCommand();
|
|
17
|
+
const dialogOverlay = useContext(CommandOverlayContext);
|
|
18
|
+
const propertyDescriptors = useCommandPropertyDescriptors(command);
|
|
19
|
+
const excluded = useExcludedProperties(props.exclude);
|
|
20
|
+
const overlay = props.currentValues ?? dialogOverlay;
|
|
21
|
+
const fields = useMemo(() => generateFields(propertyDescriptors, excluded, overlay), [propertyDescriptors, excluded, overlay]);
|
|
22
|
+
return (jsx(Fragment, { children: fields.map((field) => (jsx(CommandFormFieldWrapper, { field: field }, field.key))) }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { AutoCommandFields };
|
|
26
|
+
//# sourceMappingURL=AutoCommandFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoCommandFields.js","sources":["../../../CommandForm/AutoCommandFields.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { useContext, useMemo } from 'react';\nimport { CommandFormFieldWrapper, useCommandFormContext } from '@cratis/arc.react/commands';\nimport { CommandOverlayContext } from './commandOverlayContext';\nimport { generateFields, useCommandPropertyDescriptors, useExcludedProperties } from './generatedFields';\n\n/**\n * Props for {@link AutoCommandFields}.\n */\nexport interface AutoCommandFieldsProps<TCommand extends object> {\n /**\n * Property names to leave out of the generated field list.\n */\n exclude?: (keyof TCommand)[];\n\n /**\n * A read-only reset hint: the same `currentValues` overlay passed to the host form. A change to a\n * property's value discards a generated `GuidField`'s unfinished draft, as in `AutoCommandForm`. It\n * never writes values; the host stays authoritative. Inside `CommandDialog` it defaults to the\n * dialog's own `currentValues`; pass it explicitly for a plain `CommandForm`.\n */\n currentValues?: Partial<TCommand>;\n}\n\ntype FieldElement = Parameters<typeof CommandFormFieldWrapper>[0]['field'];\n\nfunction useHostCommand<TCommand extends object>() {\n try {\n return useCommandFormContext<TCommand>().command;\n } catch {\n throw new Error('AutoCommandFields must be rendered inside a CommandForm or CommandDialog.');\n }\n}\n\n/**\n * Generates fields from the host command's own properties, using the same type providers, titles,\n * `exclude` and omission rules as {@link AutoCommandForm}, inside an existing `CommandForm` or\n * `CommandDialog`. It renders no form of its own; values, validation and execution belong to the host.\n * Each field binds itself to the host's command context. Steppers and column layouts are not supported.\n *\n * @example\n * ```tsx\n * <CommandDialog command={RenameProject} title='Rename project'>\n * <AutoCommandFields<RenameProject> exclude={['projectId']} />\n * </CommandDialog>\n * ```\n */\nexport function AutoCommandFields<TCommand extends object = object>(\n props: AutoCommandFieldsProps<TCommand>,\n): React.ReactElement {\n const command = useHostCommand<TCommand>();\n const dialogOverlay = useContext(CommandOverlayContext) as Partial<TCommand> | undefined;\n const propertyDescriptors = useCommandPropertyDescriptors(command as new () => object);\n const excluded = useExcludedProperties<TCommand>(props.exclude);\n const overlay = props.currentValues ?? dialogOverlay;\n const fields = useMemo(\n () => generateFields<TCommand>(propertyDescriptors, excluded, overlay),\n [propertyDescriptors, excluded, overlay],\n );\n\n return (\n <>\n {fields.map((field) => (\n // SAFETY: generated elements are command form field components with fieldName and value props.\n <CommandFormFieldWrapper key={field.key} field={field as unknown as FieldElement} />\n ))}\n </>\n );\n}\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;AA4BA,SAAS,cAAc,GAAA;AACnB,IAAA,IAAI;AACA,QAAA,OAAO,qBAAqB,EAAY,CAAC,OAAO;IACpD;AAAE,IAAA,MAAM;AACJ,QAAA,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC;IAChG;AACJ;AAeM,SAAU,iBAAiB,CAC7B,KAAuC,EAAA;AAEvC,IAAA,MAAM,OAAO,GAAG,cAAc,EAAY;AAC1C,IAAA,MAAM,aAAa,GAAG,UAAU,CAAC,qBAAqB,CAAkC;AACxF,IAAA,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,OAA2B,CAAC;IACtF,MAAM,QAAQ,GAAG,qBAAqB,CAAW,KAAK,CAAC,OAAO,CAAC;AAC/D,IAAA,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,IAAI,aAAa;IACpD,MAAM,MAAM,GAAG,OAAO,CAClB,MAAM,cAAc,CAAW,mBAAmB,EAAE,QAAQ,EAAE,OAAO,CAAC,EACtE,CAAC,mBAAmB,EAAE,QAAQ,EAAE,OAAO,CAAC,CAC3C;IAED,QACIA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EACK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,MAEdD,GAAA,CAAC,uBAAuB,EAAA,EAAiB,KAAK,EAAE,KAAgC,EAAA,EAAlD,KAAK,CAAC,GAAG,CAA6C,CACvF,CAAC,EAAA,CACH;AAEX;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCommandForm.d.ts","sourceRoot":"","sources":["../../../CommandForm/AutoCommandForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoCommandForm.d.ts","sourceRoot":"","sources":["../../../CommandForm/AutoCommandForm.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAMhF;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CACjC,QAAQ,SAAS,MAAM,EACvB,SAAS,GAAG,MAAM,CACpB,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC;IAC7D;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,CAAC;IAE7B;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM,EAChF,KAAK,EAAE,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,GACjD,KAAK,CAAC,YAAY,CAYpB"}
|
|
@@ -1,41 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
3
2
|
import { CommandForm } from '@cratis/arc.react/commands';
|
|
4
|
-
import { Guid } from '@cratis/fundamentals';
|
|
5
|
-
import { GuidField } from './fields/GuidField.js';
|
|
6
3
|
import { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders.js';
|
|
7
|
-
import {
|
|
4
|
+
import { useCommandPropertyDescriptors, useExcludedProperties, generateFields } from './generatedFields.js';
|
|
8
5
|
|
|
9
6
|
registerDefaultFieldTypeProviders();
|
|
10
|
-
function formatTitle(propertyName) {
|
|
11
|
-
return propertyName
|
|
12
|
-
.replace(/([A-Z])/g, ' $1')
|
|
13
|
-
.replace(/^./, (character) => character.toUpperCase())
|
|
14
|
-
.trim();
|
|
15
|
-
}
|
|
16
|
-
function guidFieldResetProps(field, overlayValue) {
|
|
17
|
-
if (field !== GuidField) {
|
|
18
|
-
return {};
|
|
19
|
-
}
|
|
20
|
-
return { resetKey: overlayValue instanceof Guid ? overlayValue.toString() : overlayValue };
|
|
21
|
-
}
|
|
22
7
|
function AutoCommandForm(props) {
|
|
23
8
|
const { exclude, footer, ...commandFormProps } = props;
|
|
24
|
-
const propertyDescriptors =
|
|
25
|
-
const excluded =
|
|
26
|
-
const fields = propertyDescriptors
|
|
27
|
-
.filter((descriptor) => !excluded.has(descriptor.name))
|
|
28
|
-
.map((descriptor) => {
|
|
29
|
-
const provider = resolveFieldTypeProvider(descriptor);
|
|
30
|
-
if (!provider) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const Field = provider.component;
|
|
34
|
-
return (jsx(Field, { ...guidFieldResetProps(Field, props.currentValues?.[descriptor.name]), fieldName: descriptor.name, value: (instance) => {
|
|
35
|
-
return instance[descriptor.name];
|
|
36
|
-
}, title: formatTitle(descriptor.name) }, descriptor.name));
|
|
37
|
-
})
|
|
38
|
-
.filter((field) => field !== null);
|
|
9
|
+
const propertyDescriptors = useCommandPropertyDescriptors(props.command);
|
|
10
|
+
const excluded = useExcludedProperties(exclude);
|
|
11
|
+
const fields = generateFields(propertyDescriptors, excluded, props.currentValues);
|
|
39
12
|
return (jsxs(CommandForm, { ...commandFormProps, children: [fields, footer] }));
|
|
40
13
|
}
|
|
41
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCommandForm.js","sources":["../../../CommandForm/AutoCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"AutoCommandForm.js","sources":["../../../CommandForm/AutoCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport { CommandForm, type CommandFormProps } from '@cratis/arc.react/commands';\nimport { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders';\nimport { generateFields, useCommandPropertyDescriptors, useExcludedProperties } from './generatedFields';\n\nregisterDefaultFieldTypeProviders();\n\n/**\n * Props for {@link AutoCommandForm} - every {@link CommandFormProps} except `children`, which is\n * generated from the command's own properties instead of being written out by hand.\n */\nexport interface AutoCommandFormProps<\n TCommand extends object,\n TResponse = object,\n> extends Omit<CommandFormProps<TCommand, TResponse>, 'children'> {\n /**\n * Property names to leave out of the generated field list - for a property that should not\n * be user-editable, or one a custom field placed elsewhere on the page already covers.\n */\n exclude?: (keyof TCommand)[];\n\n /**\n * Optional content rendered after the generated fields, inside the native Arc form and\n * command context. Supply a submit control here when needed; no action is added by default.\n */\n footer?: React.ReactNode;\n}\n\n/**\n * A `CommandForm` that generates its field list from the command's own properties, choosing each\n * field's component by the property's type through the {@link FieldTypeProvider} registry -\n * `registerFieldTypeProvider` for a type the built-in defaults (`string`, `number`, `boolean`,\n * `Date`) don't cover, or to override one of them. `GuidField` is not a default; register it for\n * Fundamentals `Guid` properties to edit them.\n *\n * A property whose type no registered provider handles is left out of the generated list -\n * `exclude` it explicitly for clarity, or add a `CommandForm` child by hand alongside this\n * component for that one property.\n *\n * @example\n * ```tsx\n * <AutoCommandForm command={RegisterInvoice} exclude={['invoiceId']} />\n * ```\n */\nexport function AutoCommandForm<TCommand extends object = object, TResponse = object>(\n props: AutoCommandFormProps<TCommand, TResponse>,\n): React.ReactElement {\n const { exclude, footer, ...commandFormProps } = props;\n const propertyDescriptors = useCommandPropertyDescriptors(props.command);\n const excluded = useExcludedProperties<TCommand>(exclude);\n const fields = generateFields<TCommand>(propertyDescriptors, excluded, props.currentValues);\n\n return (\n <CommandForm {...commandFormProps}>\n {fields}\n {footer}\n </CommandForm>\n );\n}\n"],"names":["_jsxs"],"mappings":";;;;;AAQA,iCAAiC,EAAE;AAuC7B,SAAU,eAAe,CAC3B,KAAgD,EAAA;IAEhD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,GAAG,KAAK;IACtD,MAAM,mBAAmB,GAAG,6BAA6B,CAAC,KAAK,CAAC,OAAO,CAAC;AACxE,IAAA,MAAM,QAAQ,GAAG,qBAAqB,CAAW,OAAO,CAAC;AACzD,IAAA,MAAM,MAAM,GAAG,cAAc,CAAW,mBAAmB,EAAE,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;IAE3F,QACIA,IAAA,CAAC,WAAW,EAAA,EAAA,GAAK,gBAAgB,EAAA,QAAA,EAAA,CAC5B,MAAM,EACN,MAAM,CAAA,EAAA,CACG;AAEtB;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal: carries a host's `currentValues` overlay to generated fields that sit inside it, so they can
|
|
3
|
+
* derive the reset hint without the caller repeating the prop. Not part of the public API.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CommandOverlayContext: import("react").Context<object | undefined>;
|
|
6
|
+
//# sourceMappingURL=commandOverlayContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandOverlayContext.d.ts","sourceRoot":"","sources":["../../../CommandForm/commandOverlayContext.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,6CAA+C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandOverlayContext.js","sources":["../../../CommandForm/commandOverlayContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { createContext } from 'react';\n\n/**\n * Internal: carries a host's `currentValues` overlay to generated fields that sit inside it, so they can\n * derive the reset hint without the caller repeating the prop. Not part of the public API.\n */\nexport const CommandOverlayContext = createContext<object | undefined>(undefined);\n"],"names":[],"mappings":";;MASa,qBAAqB,GAAG,aAAa,CAAqB,SAAS;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the property descriptors of a command constructor. Metadata only: the instance is never executed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useCommandPropertyDescriptors(command: new () => object): PropertyDescriptor[];
|
|
7
|
+
/**
|
|
8
|
+
* Memoises the set of excluded property names.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useExcludedProperties<TCommand extends object>(exclude: (keyof TCommand)[] | undefined): Set<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Generates one keyed field element per descriptor that is not excluded and has a registered provider.
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateFields<TCommand extends object>(propertyDescriptors: PropertyDescriptor[], excluded: Set<string>, currentValues: Partial<TCommand> | undefined): React.ReactElement[];
|
|
15
|
+
//# sourceMappingURL=generatedFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedFields.d.ts","sourceRoot":"","sources":["../../../CommandForm/generatedFields.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAyBjE;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,UAAU,MAAM,GAAG,kBAAkB,EAAE,CAG7F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,QAAQ,CAAC,EAAE,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAEnH;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAS,MAAM,EAClD,mBAAmB,EAAE,kBAAkB,EAAE,EACzC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,EACrB,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS,GAC7C,KAAK,CAAC,YAAY,EAAE,CA4BtB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Guid } from '@cratis/fundamentals';
|
|
4
|
+
import { GuidField } from './fields/GuidField.js';
|
|
5
|
+
import { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders.js';
|
|
6
|
+
import { resolveFieldTypeProvider } from './fieldTypeProviderRegistry.js';
|
|
7
|
+
|
|
8
|
+
registerDefaultFieldTypeProviders();
|
|
9
|
+
function formatTitle(propertyName) {
|
|
10
|
+
return propertyName
|
|
11
|
+
.replace(/([A-Z])/g, ' $1')
|
|
12
|
+
.replace(/^./, (character) => character.toUpperCase())
|
|
13
|
+
.trim();
|
|
14
|
+
}
|
|
15
|
+
function guidFieldResetProps(field, overlayValue) {
|
|
16
|
+
if (field !== GuidField) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
return { resetKey: overlayValue instanceof Guid ? overlayValue.toString() : overlayValue };
|
|
20
|
+
}
|
|
21
|
+
function useCommandPropertyDescriptors(command) {
|
|
22
|
+
return useMemo(() => new command().propertyDescriptors, [command]);
|
|
23
|
+
}
|
|
24
|
+
function useExcludedProperties(exclude) {
|
|
25
|
+
return useMemo(() => new Set((exclude ?? [])), [exclude]);
|
|
26
|
+
}
|
|
27
|
+
function generateFields(propertyDescriptors, excluded, currentValues) {
|
|
28
|
+
return propertyDescriptors
|
|
29
|
+
.filter((descriptor) => !excluded.has(descriptor.name))
|
|
30
|
+
.map((descriptor) => {
|
|
31
|
+
const provider = resolveFieldTypeProvider(descriptor);
|
|
32
|
+
if (!provider) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const Field = provider.component;
|
|
36
|
+
return (jsx(Field, { ...guidFieldResetProps(Field, currentValues?.[descriptor.name]), fieldName: descriptor.name, value: (instance) => {
|
|
37
|
+
return instance[descriptor.name];
|
|
38
|
+
}, title: formatTitle(descriptor.name) }, descriptor.name));
|
|
39
|
+
})
|
|
40
|
+
.filter((field) => field !== null);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { generateFields, useCommandPropertyDescriptors, useExcludedProperties };
|
|
44
|
+
//# sourceMappingURL=generatedFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedFields.js","sources":["../../../CommandForm/generatedFields.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type React from 'react';\nimport { useMemo } from 'react';\nimport type { Command } from '@cratis/arc/commands';\nimport type { PropertyDescriptor } from '@cratis/arc/reflection';\nimport { Guid } from '@cratis/fundamentals';\nimport { GuidField } from './fields/GuidField';\nimport { registerDefaultFieldTypeProviders } from './defaultFieldTypeProviders';\nimport { resolveFieldTypeProvider } from './fieldTypeProviderRegistry';\n\nregisterDefaultFieldTypeProviders();\n\nfunction formatTitle(propertyName: string): string {\n return propertyName\n .replace(/([A-Z])/g, ' $1')\n .replace(/^./, (character) => character.toUpperCase())\n .trim();\n}\n\n// An invalid GuidField draft leaves the command value empty, so a changed currentValues overlay must\n// discard the draft even when the native value does not change. Only the registered GuidField itself\n// receives the key: no other provider sees an extra prop.\nfunction guidFieldResetProps(field: unknown, overlayValue: unknown): { resetKey?: unknown } {\n if (field !== GuidField) {\n return {};\n }\n return { resetKey: overlayValue instanceof Guid ? overlayValue.toString() : overlayValue };\n}\n\n/**\n * Reads the property descriptors of a command constructor. Metadata only: the instance is never executed.\n */\nexport function useCommandPropertyDescriptors(command: new () => object): PropertyDescriptor[] {\n // SAFETY: Arc command constructors expose the Command property-descriptor contract at runtime.\n return useMemo(() => (new command() as unknown as Command).propertyDescriptors, [command]);\n}\n\n/**\n * Memoises the set of excluded property names.\n */\nexport function useExcludedProperties<TCommand extends object>(exclude: (keyof TCommand)[] | undefined): Set<string> {\n return useMemo(() => new Set<string>((exclude ?? []) as string[]), [exclude]);\n}\n\n/**\n * Generates one keyed field element per descriptor that is not excluded and has a registered provider.\n */\nexport function generateFields<TCommand extends object>(\n propertyDescriptors: PropertyDescriptor[],\n excluded: Set<string>,\n currentValues: Partial<TCommand> | undefined,\n): React.ReactElement[] {\n return propertyDescriptors\n .filter((descriptor) => !excluded.has(descriptor.name))\n .map((descriptor) => {\n const provider = resolveFieldTypeProvider(descriptor);\n if (!provider) {\n return null;\n }\n\n const Field = provider.component;\n return (\n <Field\n key={descriptor.name}\n {...guidFieldResetProps(Field, currentValues?.[descriptor.name as keyof TCommand])}\n // The accessor reads the property dynamically, so CommandForm cannot infer the\n // property name from its source text; fieldName states it explicitly.\n fieldName={descriptor.name}\n value={(instance: TCommand) => {\n // SAFETY: Arc descriptors name runtime properties on the same command instance.\n return (instance as unknown as Record<string, unknown>)[\n descriptor.name\n ];\n }}\n title={formatTitle(descriptor.name)}\n />\n );\n })\n .filter((field): field is React.ReactElement => field !== null);\n}\n"],"names":["_jsx"],"mappings":";;;;;;;AAYA,iCAAiC,EAAE;AAEnC,SAAS,WAAW,CAAC,YAAoB,EAAA;AACrC,IAAA,OAAO;AACF,SAAA,OAAO,CAAC,UAAU,EAAE,KAAK;AACzB,SAAA,OAAO,CAAC,IAAI,EAAE,CAAC,SAAS,KAAK,SAAS,CAAC,WAAW,EAAE;AACpD,SAAA,IAAI,EAAE;AACf;AAKA,SAAS,mBAAmB,CAAC,KAAc,EAAE,YAAqB,EAAA;AAC9D,IAAA,IAAI,KAAK,KAAK,SAAS,EAAE;AACrB,QAAA,OAAO,EAAE;IACb;AACA,IAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,YAAY,IAAI,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,YAAY,EAAE;AAC9F;AAKM,SAAU,6BAA6B,CAAC,OAAyB,EAAA;AAEnE,IAAA,OAAO,OAAO,CAAC,MAAO,IAAI,OAAO,EAAyB,CAAC,mBAAmB,EAAE,CAAC,OAAO,CAAC,CAAC;AAC9F;AAKM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
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../CommandForm/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAsB,CAAC;AACrC,cAAc,mBAAU,CAAC;AACzB,cAAc,wBAAqB,CAAC;AACpC,cAAc,gCAA6B,CAAC;AAC5C,cAAc,sBAAmB,CAAC;AAClC,cAAc,wBAAqB,CAAC"}
|
|
@@ -18,4 +18,5 @@ export { ToggleSwitchField } from './fields/ToggleSwitchField.js';
|
|
|
18
18
|
export { RatingField } from './fields/RatingField.js';
|
|
19
19
|
export { clearFieldTypeProviders, registerFieldTypeProvider, resolveFieldTypeProvider } from './fieldTypeProviderRegistry.js';
|
|
20
20
|
export { AutoCommandForm } from './AutoCommandForm.js';
|
|
21
|
+
export { AutoCommandFields } from './AutoCommandFields.js';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import type { ButtonProps } from '../Common/Button.js';
|
|
3
3
|
import type { CheckboxProps } from '../Common/Checkbox.js';
|
|
4
|
+
import type { DatePickerInputProps } from '../Common/DatePickerInput.js';
|
|
4
5
|
import type { IconButtonProps } from '../Common/IconButton.js';
|
|
5
6
|
import type { RadioProps } from '../Common/Radio.js';
|
|
6
7
|
import type { SurfaceProps } from '../Common/Surface.js';
|
|
7
8
|
import type { SwitchProps } from '../Common/Switch.js';
|
|
8
9
|
import type { TextAreaProps } from '../Common/TextArea.js';
|
|
9
10
|
import type { TextInputProps } from '../Common/TextInput.js';
|
|
11
|
+
import type { TooltipProps } from '../Common/Tooltip.js';
|
|
10
12
|
import type { TablePaginatorProps } from '../DataTables/TablePaginator.js';
|
|
13
|
+
import type { DropdownProps } from '../Dropdown/Dropdown.js';
|
|
11
14
|
import type { ProgressBarProps } from '../Display/ProgressBar.js';
|
|
12
15
|
import type { CratisPresentationUiLibraryProviderProps } from './manifest.js';
|
|
13
16
|
/** Stable renderer profile implemented by certified presentation adapters. */
|
|
@@ -57,7 +60,7 @@ export type CratisPresentationSlotMap = {
|
|
|
57
60
|
* implement any of them through {@link CratisPresentationUiLibrary.atomicSlots}; new ids are only
|
|
58
61
|
* ever appended.
|
|
59
62
|
*/
|
|
60
|
-
export declare const cratisAtomicSlotIds: readonly ["datatables.paginator"];
|
|
63
|
+
export declare const cratisAtomicSlotIds: readonly ["datatables.paginator", "common.tooltip", "dropdown.select", "display.datePicker"];
|
|
61
64
|
/** Identifier of one stable atomic slot. */
|
|
62
65
|
export type CratisAtomicSlotId = (typeof cratisAtomicSlotIds)[number];
|
|
63
66
|
/** Exact public component prop contracts covered by the stable atomic slots. */
|
|
@@ -67,6 +70,22 @@ export interface CratisAtomicSlots {
|
|
|
67
70
|
* `TablePaginatorParts` parts and no ref.
|
|
68
71
|
*/
|
|
69
72
|
readonly 'datatables.paginator': TablePaginatorProps;
|
|
73
|
+
/**
|
|
74
|
+
* Tooltip contract: non-interactive `content`, `position`, `disabled`, `className` and exactly
|
|
75
|
+
* one focusable trigger child. The adapter keeps the trigger's `data-cratis-part` and renders
|
|
76
|
+
* the popup as the `popup` part; there is no ref.
|
|
77
|
+
*/
|
|
78
|
+
readonly 'common.tooltip': TooltipProps;
|
|
79
|
+
/**
|
|
80
|
+
* Select contract: the public `DropdownProps` with an untyped value, the `DropdownParts` parts
|
|
81
|
+
* and no ref. The adapter owns the trigger, filter, listbox, keyboard and selection callbacks.
|
|
82
|
+
*/
|
|
83
|
+
readonly 'dropdown.select': DropdownProps<unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Date picker contract: the public `DatePickerInputProps` with `Date | null` values, the
|
|
86
|
+
* `DatePickerInputPassThrough` parts and no ref. Calendar library values stay inside the adapter.
|
|
87
|
+
*/
|
|
88
|
+
readonly 'display.datePicker': DatePickerInputProps;
|
|
70
89
|
}
|
|
71
90
|
/** One stable, adapter-owned atomic slot declaration. */
|
|
72
91
|
export interface CratisAtomicSlotDeclaration<SlotId extends CratisAtomicSlotId> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../renderer/presentation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,wCAAwC,EAAE,MAAM,eAAY,CAAC;AAG3E,8EAA8E;AAC9E,eAAO,MAAM,2BAA2B,EAAG,wBAAiC,CAAC;AAE7E,8DAA8D;AAC9D,eAAO,MAAM,+BAA+B,EAAG,CAAU,CAAC;AAE1D,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,iLAU3B,CAAC;AAEZ,kDAAkD;AAClD,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CA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E,OAAO,2BAA2B,CAAC;IACrD,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,OAAO,yBAAyB,CAAC;IACxD,uFAAuF;IACvF,QAAQ,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACtD,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,yBAAyB,CAAC;IAC1C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,wCAAwC,CAAC,CAAC;IAC5E;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC;CAC9C;AAuQD;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,YAC3B,2BAA2B,KACrC,2BAqBF,CAAC;AAOF,iFAAiF;AACjF,MAAM,WAAW,uBAAuB;IACpC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -11,7 +11,12 @@ const cratisPresentationSlotIds = Object.freeze([
|
|
|
11
11
|
'common.progress',
|
|
12
12
|
'common.surface',
|
|
13
13
|
]);
|
|
14
|
-
const cratisAtomicSlotIds = Object.freeze([
|
|
14
|
+
const cratisAtomicSlotIds = Object.freeze([
|
|
15
|
+
'datatables.paginator',
|
|
16
|
+
'common.tooltip',
|
|
17
|
+
'dropdown.select',
|
|
18
|
+
'display.datePicker',
|
|
19
|
+
]);
|
|
15
20
|
const requiredCapabilityIds = [
|
|
16
21
|
'slot.render',
|
|
17
22
|
'parts.passthrough',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.js","sources":["../../../renderer/presentation.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType } from 'react';\nimport type { ButtonProps } from '../Common/Button';\nimport type { CheckboxProps } from '../Common/Checkbox';\nimport type { IconButtonProps } from '../Common/IconButton';\nimport type { RadioProps } from '../Common/Radio';\nimport type { SurfaceProps } from '../Common/Surface';\nimport type { SwitchProps } from '../Common/Switch';\nimport type { TextAreaProps } from '../Common/TextArea';\nimport type { TextInputProps } from '../Common/TextInput';\nimport type { TablePaginatorProps } from '../DataTables/TablePaginator';\nimport type { ProgressBarProps } from '../Display/ProgressBar';\nimport type { CratisPresentationUiLibraryProviderProps } from './manifest';\nimport type { unstable_SlotMap } from './slots';\n\n/** Stable renderer profile implemented by certified presentation adapters. */\nexport const CRATIS_PRESENTATION_PROFILE = 'stable-presentation/v1' as const;\n\n/** Renderer ABI major for the stable presentation profile. */\nexport const CRATIS_PRESENTATION_ABI_VERSION = 1 as const;\n\n/** Immutable, canonical slot order for the stable presentation profile. */\nexport const cratisPresentationSlotIds = Object.freeze([\n 'common.button',\n 'common.iconButton',\n 'common.textInput',\n 'common.textArea',\n 'common.checkbox',\n 'common.radio',\n 'common.switch',\n 'common.progress',\n 'common.surface',\n] as const);\n\n/** Identifier of one stable presentation slot. */\nexport type CratisPresentationSlotId = (typeof cratisPresentationSlotIds)[number];\n\n/** Exact public component prop and ref contracts covered by the stable presentation profile. */\nexport interface CratisPresentationSlots {\n /** Cratis button presentation contract, including native button refs and form behavior. */\n readonly 'common.button': ButtonProps;\n /** Accessible icon-only button contract with native button ownership. */\n readonly 'common.iconButton': IconButtonProps;\n /** Native text-input contract with semantic value-first change events. */\n readonly 'common.textInput': TextInputProps;\n /** Native multiline text-input contract with semantic value-first change events. */\n readonly 'common.textArea': TextAreaProps;\n /** Native checkbox contract with checked state, form participation, and input refs. */\n readonly 'common.checkbox': CheckboxProps;\n /** Native radio-option contract with selection state, form participation, and input refs. */\n readonly 'common.radio': RadioProps;\n /** Boolean switch contract preserving switch semantics and input ownership. */\n readonly 'common.switch': SwitchProps;\n /** Determinate or indeterminate progress presentation contract. */\n readonly 'common.progress': ProgressBarProps;\n /** Non-interactive semantic surface and native-element presentation contract. */\n readonly 'common.surface': SurfaceProps;\n}\n\n/** One stable, presentation-owned renderer slot declaration. */\nexport interface CratisPresentationSlotDeclaration<\n SlotId extends CratisPresentationSlotId,\n> {\n /** Stable presentation slots always preserve Components behavior ownership. */\n readonly mode: 'presentation';\n /** Unsupported declarations cannot claim the stable profile. */\n readonly fidelity: 'native' | 'emulated';\n /** Component implementing the slot's exact public props and ref contract. */\n readonly render: ComponentType<CratisPresentationSlots[SlotId]>;\n}\n\n/** Complete implementation table required by the stable presentation profile. */\nexport type CratisPresentationSlotMap = {\n readonly [\n SlotId in CratisPresentationSlotId\n ]: CratisPresentationSlotDeclaration<SlotId>;\n};\n\n/**\n * Immutable list of the atomic slots whose contracts are stable. A stable presentation library may\n * implement any of them through {@link CratisPresentationUiLibrary.atomicSlots}; new ids are only\n * ever appended.\n */\nexport const cratisAtomicSlotIds = Object.freeze(['datatables.paginator'] as const);\n\n/** Identifier of one stable atomic slot. */\nexport type CratisAtomicSlotId = (typeof cratisAtomicSlotIds)[number];\n\n/** Exact public component prop contracts covered by the stable atomic slots. */\nexport interface CratisAtomicSlots {\n /**\n * Table paginator contract: zero-based `page`, `pageCount`, zero-based `onPageChange`, the\n * `TablePaginatorParts` parts and no ref.\n */\n readonly 'datatables.paginator': TablePaginatorProps;\n}\n\n/** One stable, adapter-owned atomic slot declaration. */\nexport interface CratisAtomicSlotDeclaration<SlotId extends CratisAtomicSlotId> {\n /** Stable atomic slots give the adapter ownership of the complete interaction. */\n readonly mode: 'atomic';\n /** Unsupported declarations are expressed by omitting the slot. */\n readonly fidelity: 'native' | 'emulated';\n /** Component implementing the slot's exact public props contract. */\n readonly render: ComponentType<CratisAtomicSlots[SlotId]>;\n}\n\n/** Optional atomic implementations. An omitted slot keeps the built-in Components implementation. */\nexport type CratisAtomicSlotMap = {\n readonly [SlotId in CratisAtomicSlotId]?: CratisAtomicSlotDeclaration<SlotId>;\n};\n\n/** Capabilities whose meaning is stable for the bounded presentation profile. */\nexport type CratisPresentationCapabilityId =\n | 'slot.render'\n | 'parts.passthrough'\n | 'ssr.staticRender'\n | 'rtl'\n | 'forcedColors'\n | 'motion.reduced';\n\ntype CratisPresentationOptionalCapabilityId = Exclude<\n CratisPresentationCapabilityId,\n 'slot.render' | 'parts.passthrough' | 'ssr.staticRender'\n>;\n\n/** Required presentation capabilities followed by optional stable evidence capabilities. */\nexport type CratisPresentationCapabilities = readonly [\n 'slot.render',\n 'parts.passthrough',\n 'ssr.staticRender',\n ...CratisPresentationOptionalCapabilityId[],\n];\n\n/** Immutable manifest for one implementation of the stable presentation profile. */\nexport interface CratisPresentationUiLibrary {\n /** Stable, package-local renderer identity used for diagnostics and telemetry. */\n readonly id: string;\n /** Human-readable renderer name. */\n readonly displayName: string;\n /** Stable presentation renderer ABI major. */\n readonly abi: typeof CRATIS_PRESENTATION_ABI_VERSION;\n /** The bounded profile is a primitive presentation adapter. */\n readonly level: 'primitive';\n /** Exact stable presentation profile identifier. */\n readonly profile: typeof CRATIS_PRESENTATION_PROFILE;\n /** Canonical immutable list of all nine stable slots. */\n readonly profileSlots: typeof cratisPresentationSlotIds;\n /** Required presentation capabilities followed by any optional stable capabilities. */\n readonly capabilities: CratisPresentationCapabilities;\n /** Complete nine-slot presentation implementation. */\n readonly slots: CratisPresentationSlotMap;\n /** Optional provider mounted once around the selected renderer scope. */\n readonly Provider?: ComponentType<CratisPresentationUiLibraryProviderProps>;\n /**\n * Optional adapter-owned implementations of stable atomic slots. Omitted slots resolve to the\n * built-in Components implementation.\n */\n readonly atomicSlots?: CratisAtomicSlotMap;\n}\n\nconst requiredCapabilityIds = [\n 'slot.render',\n 'parts.passthrough',\n 'ssr.staticRender',\n] as const;\n\nconst stableCapabilityIds = new Set<CratisPresentationCapabilityId>([\n ...requiredCapabilityIds,\n 'rtl',\n 'forcedColors',\n 'motion.reduced',\n]);\n\nconst invalidPresentationLibrary: (reason: string) => never = (reason) => {\n throw new TypeError(`Invalid stable presentation UI library: ${reason}.`);\n};\n\nconst hasCanonicalProfileSlots = (profileSlots: readonly unknown[]): boolean =>\n profileSlots.length === cratisPresentationSlotIds.length &&\n profileSlots.every((slotId, index) => slotId === cratisPresentationSlotIds[index]);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst isRendererIdentity = (id: unknown): boolean =>\n typeof id === 'string' &&\n id.length <= 128 &&\n /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(id);\n\nconst isDisplayName = (displayName: unknown): boolean =>\n typeof displayName === 'string' &&\n displayName.trim().length > 0 &&\n displayName.length <= 128;\n\nconst isComponent = (render: unknown): boolean =>\n render !== null && (typeof render === 'function' || typeof render === 'object');\n\nconst isStableFidelity = (fidelity: unknown): boolean =>\n fidelity === 'native' || fidelity === 'emulated';\n\nconst validateIdentity = (library: CratisPresentationUiLibrary) => {\n if (library === null || typeof library !== 'object') {\n invalidPresentationLibrary('manifest must be an object');\n }\n if (!isRendererIdentity(library.id)) {\n invalidPresentationLibrary('id must be a valid package-local renderer identity');\n }\n if (!isDisplayName(library.displayName)) {\n invalidPresentationLibrary(\n 'displayName must contain between 1 and 128 characters',\n );\n }\n if (library.Provider !== undefined && typeof library.Provider !== 'function') {\n invalidPresentationLibrary('Provider must be a React component when supplied');\n }\n};\n\nconst validateProfile = (library: CratisPresentationUiLibrary) => {\n if (library.profile !== CRATIS_PRESENTATION_PROFILE) {\n invalidPresentationLibrary(`profile must be '${CRATIS_PRESENTATION_PROFILE}'`);\n }\n if (library.abi !== CRATIS_PRESENTATION_ABI_VERSION) {\n invalidPresentationLibrary(`ABI must be ${CRATIS_PRESENTATION_ABI_VERSION}`);\n }\n if (library.level !== 'primitive') {\n invalidPresentationLibrary(\"level must be 'primitive'\");\n }\n if (\n !Array.isArray(library.profileSlots) ||\n !hasCanonicalProfileSlots(library.profileSlots)\n ) {\n invalidPresentationLibrary(\n 'profileSlots must be the canonical nine-slot profile',\n );\n }\n};\n\nconst declarationProblem = (\n declaration: Record<string, unknown>,\n label: string,\n mode: 'presentation' | 'atomic',\n): string | undefined => {\n if (declaration.mode !== mode) return `${label} must use ${mode} mode`;\n if (!isStableFidelity(declaration.fidelity)) {\n return `${label} must use native or emulated fidelity`;\n }\n if (!isComponent(declaration.render)) return `${label} must provide a component`;\n return undefined;\n};\n\nconst validateDeclaration = (\n declaration: Record<string, unknown>,\n label: string,\n mode: 'presentation' | 'atomic',\n) => {\n const problem = declarationProblem(declaration, label, mode);\n if (problem) invalidPresentationLibrary(problem);\n};\n\nconst validateSlots = (library: CratisPresentationUiLibrary) => {\n if (!library.slots || typeof library.slots !== 'object') {\n invalidPresentationLibrary('slots must be an object');\n }\n\n const slotIds = Object.keys(library.slots);\n if (\n slotIds.length !== cratisPresentationSlotIds.length ||\n cratisPresentationSlotIds.some((slotId) => !slotIds.includes(slotId))\n ) {\n invalidPresentationLibrary(\n 'slots must contain exactly the nine stable presentation slots',\n );\n }\n\n for (const slotId of cratisPresentationSlotIds) {\n // SAFETY: the canonical slot list indexes the complete stable map; the wider record view\n // exists only so runtime JavaScript callers can be checked before their value is frozen.\n const declaration = library.slots[slotId] as unknown as\n Record<string, unknown> | undefined;\n if (!declaration) {\n invalidPresentationLibrary(`slot '${slotId}' must provide a declaration`);\n }\n validateDeclaration(declaration, `slot '${slotId}'`, 'presentation');\n }\n};\n\nconst validateCapabilities = (library: CratisPresentationUiLibrary) => {\n if (\n !Array.isArray(library.capabilities) ||\n library.capabilities.some((capability) => !stableCapabilityIds.has(capability))\n ) {\n invalidPresentationLibrary(\n 'capabilities must stay within the stable presentation subset',\n );\n }\n if (\n requiredCapabilityIds.some(\n (capability, index) => library.capabilities[index] !== capability,\n )\n ) {\n invalidPresentationLibrary(\n 'capabilities must begin with slot.render, parts.passthrough, and ssr.staticRender',\n );\n }\n if (new Set(library.capabilities).size !== library.capabilities.length) {\n invalidPresentationLibrary('capabilities must not contain duplicates');\n }\n};\n\nconst isStableAtomicSlotId = (slotId: string): slotId is CratisAtomicSlotId =>\n (cratisAtomicSlotIds as readonly string[]).includes(slotId);\n\n/** One atomic slot entry inspected from a single own-enumerable snapshot of `atomicSlots`. */\ninterface AtomicSlotEntry {\n readonly slotId: string;\n /** Declaration read exactly once, or undefined for an explicitly omitted slot. */\n readonly declaration?: Readonly<Record<string, unknown>>;\n /** Why the entry cannot be used; undefined when it is valid. */\n readonly problem?: string;\n}\n\n/** Inspection of a library's `atomicSlots`: one problem for the map, or one result per own key. */\ninterface AtomicSlotInspection {\n readonly problem?: string;\n readonly entries: readonly AtomicSlotEntry[];\n}\n\nconst snapshotDeclaration = (declaration: Record<string, unknown>) => ({\n mode: declaration.mode,\n fidelity: declaration.fidelity,\n render: declaration.render,\n});\n\nconst inspectAtomicSlot = (slotId: string, value: unknown): AtomicSlotEntry => {\n const label = `atomic slot '${slotId}'`;\n if (!isStableAtomicSlotId(slotId)) {\n return { slotId, problem: `${label} is not a stable atomic slot` };\n }\n if (value === undefined) return { slotId };\n if (!isRecord(value)) return { slotId, problem: `${label} must provide a declaration` };\n\n const declaration = snapshotDeclaration(value);\n return { slotId, declaration, problem: declarationProblem(declaration, label, 'atomic') };\n};\n\nconst isPlainPrototype = (prototype: unknown): boolean =>\n prototype === null || prototype === Object.prototype;\n\n/**\n * Inspects `atomicSlots` through ONE snapshot of its own enumerable keys, reading each value\n * once. Inherited and non-enumerable declarations never take part in validation or resolution.\n */\nconst inspectAtomicSlots = (atomicSlots: unknown): AtomicSlotInspection => {\n if (atomicSlots === undefined) return { entries: [] };\n if (!isRecord(atomicSlots)) {\n return { problem: 'atomicSlots must be an object when supplied', entries: [] };\n }\n if (!isPlainPrototype(Object.getPrototypeOf(atomicSlots))) {\n return {\n problem: 'atomicSlots must be a plain object; inherited declarations are not allowed',\n entries: [],\n };\n }\n return {\n entries: Object.keys(atomicSlots).map((slotId) =>\n inspectAtomicSlot(slotId, atomicSlots[slotId]),\n ),\n };\n};\n\nconst isUsableAtomicSlot = (\n entry: AtomicSlotEntry,\n): entry is AtomicSlotEntry & { readonly declaration: Readonly<Record<string, unknown>> } =>\n entry.problem === undefined && entry.declaration !== undefined;\n\n/** Builds a frozen slot-id keyed map of the usable entries; keys are own data properties. */\nconst usableAtomicSlots = (entries: readonly AtomicSlotEntry[]): Readonly<Record<string, object>> =>\n Object.freeze(\n Object.fromEntries(\n entries\n .filter(isUsableAtomicSlot)\n .map(({ slotId, declaration }) => [slotId, Object.freeze(declaration)]),\n ),\n );\n\nconst frozenValidAtomicSlots = (atomicSlots: unknown): CratisAtomicSlotMap | undefined => {\n if (atomicSlots === undefined) return undefined;\n const inspection = inspectAtomicSlots(atomicSlots);\n const problem =\n inspection.problem ?? inspection.entries.find((entry) => entry.problem)?.problem;\n if (problem) invalidPresentationLibrary(problem);\n return usableAtomicSlots(inspection.entries) as CratisAtomicSlotMap;\n};\n\nconst freezeDeclaration = <\n Declaration extends {\n readonly mode: string;\n readonly fidelity: string;\n readonly render: unknown;\n },\n>(\n declaration: Declaration,\n): Declaration =>\n Object.freeze({\n mode: declaration.mode,\n fidelity: declaration.fidelity,\n render: declaration.render,\n }) as Declaration;\n\nconst freezePresentationSlots = (\n slots: CratisPresentationSlotMap,\n): CratisPresentationSlotMap =>\n Object.freeze(\n Object.fromEntries(\n cratisPresentationSlotIds.map((slotId) => [\n slotId,\n freezeDeclaration(slots[slotId]),\n ]),\n ),\n ) as CratisPresentationSlotMap;\n\n/**\n * Defines and freezes a complete implementation of the stable nine-slot presentation profile,\n * plus any optional stable atomic slots. Runtime validation protects JavaScript callers from\n * claiming a profile they do not implement.\n *\n * @param library Stable presentation library declaration.\n * @returns A defensive, deeply frozen manifest copy.\n */\nexport const definePresentationUiLibrary = (\n library: CratisPresentationUiLibrary,\n): CratisPresentationUiLibrary => {\n validateIdentity(library);\n validateProfile(library);\n validateSlots(library);\n validateCapabilities(library);\n const atomicSlots = frozenValidAtomicSlots(library.atomicSlots);\n\n return Object.freeze({\n id: library.id,\n displayName: library.displayName,\n abi: library.abi,\n level: library.level,\n profile: library.profile,\n profileSlots: cratisPresentationSlotIds,\n capabilities: Object.freeze([\n ...library.capabilities,\n ]) as CratisPresentationCapabilities,\n slots: freezePresentationSlots(library.slots),\n Provider: library.Provider,\n ...(atomicSlots === undefined ? {} : { atomicSlots }),\n });\n};\n\nconst atomicSlotsInspectionOf = (library: { readonly profile: string }) =>\n library.profile === CRATIS_PRESENTATION_PROFILE\n ? inspectAtomicSlots((library as { readonly atomicSlots?: unknown }).atomicSlots)\n : { entries: [] };\n\n/** One reason a stable presentation library's atomic slot cannot be resolved. */\nexport interface StableAtomicSlotProblem {\n /** Offending slot id, when the problem concerns a single entry. */\n readonly slotId?: string;\n /** Human-readable reason. */\n readonly message: string;\n}\n\n/**\n * Lists why a stable presentation library's atomic slots cannot all be resolved. Libraries built\n * with the generic definer or as raw manifests can claim the stable profile without passing\n * {@link definePresentationUiLibrary}; resolution skips their invalid entries and this reports them.\n *\n * @param library Renderer library being validated.\n * @returns Problems in key order; empty for valid or absent atomic slots and for other profiles.\n * @internal Resolution helper; not part of the public package surface.\n */\nexport const stableAtomicSlotProblemsOf = (library: {\n readonly profile: string;\n}): readonly StableAtomicSlotProblem[] => {\n const inspection: AtomicSlotInspection = atomicSlotsInspectionOf(library);\n if (inspection.problem) return [{ message: inspection.problem }];\n return inspection.entries.flatMap(({ slotId, problem }) =>\n problem ? [{ slotId, message: problem }] : [],\n );\n};\n\n/**\n * Returns the stable atomic slot declarations a stable presentation library adds to resolution.\n * Only own enumerable, fully valid declarations take part; invalid ones fail closed to the\n * built-in implementation and are reported by {@link stableAtomicSlotProblemsOf}. Libraries of any\n * other profile, and libraries without `atomicSlots`, contribute nothing, so their slot tables\n * resolve exactly as before.\n *\n * @param library Renderer library being resolved.\n * @returns The library's stable atomic declarations keyed by slot id; empty when it has none.\n * @internal Resolution helper; not part of the public package surface.\n */\nexport const stableAtomicSlotsOf = (library: {\n readonly profile: string;\n}): unstable_SlotMap =>\n usableAtomicSlots(atomicSlotsInspectionOf(library).entries) as unstable_SlotMap;\n"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OAAO;QAAE,OAAO,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;AAChE,IAAA,OAAO,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAClD,OAAO,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CAChD;AACL;AAaO,MAAM,mBAAmB,GAAG,CAAC,OAEnC,KACG,iBAAiB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,OAAO;;"}
|
|
1
|
+
{"version":3,"file":"presentation.js","sources":["../../../renderer/presentation.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType } from 'react';\nimport type { ButtonProps } from '../Common/Button';\nimport type { CheckboxProps } from '../Common/Checkbox';\nimport type { DatePickerInputProps } from '../Common/DatePickerInput';\nimport type { IconButtonProps } from '../Common/IconButton';\nimport type { RadioProps } from '../Common/Radio';\nimport type { SurfaceProps } from '../Common/Surface';\nimport type { SwitchProps } from '../Common/Switch';\nimport type { TextAreaProps } from '../Common/TextArea';\nimport type { TextInputProps } from '../Common/TextInput';\nimport type { TooltipProps } from '../Common/Tooltip';\nimport type { TablePaginatorProps } from '../DataTables/TablePaginator';\nimport type { DropdownProps } from '../Dropdown/Dropdown';\nimport type { ProgressBarProps } from '../Display/ProgressBar';\nimport type { CratisPresentationUiLibraryProviderProps } from './manifest';\nimport type { unstable_SlotMap } from './slots';\n\n/** Stable renderer profile implemented by certified presentation adapters. */\nexport const CRATIS_PRESENTATION_PROFILE = 'stable-presentation/v1' as const;\n\n/** Renderer ABI major for the stable presentation profile. */\nexport const CRATIS_PRESENTATION_ABI_VERSION = 1 as const;\n\n/** Immutable, canonical slot order for the stable presentation profile. */\nexport const cratisPresentationSlotIds = Object.freeze([\n 'common.button',\n 'common.iconButton',\n 'common.textInput',\n 'common.textArea',\n 'common.checkbox',\n 'common.radio',\n 'common.switch',\n 'common.progress',\n 'common.surface',\n] as const);\n\n/** Identifier of one stable presentation slot. */\nexport type CratisPresentationSlotId = (typeof cratisPresentationSlotIds)[number];\n\n/** Exact public component prop and ref contracts covered by the stable presentation profile. */\nexport interface CratisPresentationSlots {\n /** Cratis button presentation contract, including native button refs and form behavior. */\n readonly 'common.button': ButtonProps;\n /** Accessible icon-only button contract with native button ownership. */\n readonly 'common.iconButton': IconButtonProps;\n /** Native text-input contract with semantic value-first change events. */\n readonly 'common.textInput': TextInputProps;\n /** Native multiline text-input contract with semantic value-first change events. */\n readonly 'common.textArea': TextAreaProps;\n /** Native checkbox contract with checked state, form participation, and input refs. */\n readonly 'common.checkbox': CheckboxProps;\n /** Native radio-option contract with selection state, form participation, and input refs. */\n readonly 'common.radio': RadioProps;\n /** Boolean switch contract preserving switch semantics and input ownership. */\n readonly 'common.switch': SwitchProps;\n /** Determinate or indeterminate progress presentation contract. */\n readonly 'common.progress': ProgressBarProps;\n /** Non-interactive semantic surface and native-element presentation contract. */\n readonly 'common.surface': SurfaceProps;\n}\n\n/** One stable, presentation-owned renderer slot declaration. */\nexport interface CratisPresentationSlotDeclaration<\n SlotId extends CratisPresentationSlotId,\n> {\n /** Stable presentation slots always preserve Components behavior ownership. */\n readonly mode: 'presentation';\n /** Unsupported declarations cannot claim the stable profile. */\n readonly fidelity: 'native' | 'emulated';\n /** Component implementing the slot's exact public props and ref contract. */\n readonly render: ComponentType<CratisPresentationSlots[SlotId]>;\n}\n\n/** Complete implementation table required by the stable presentation profile. */\nexport type CratisPresentationSlotMap = {\n readonly [\n SlotId in CratisPresentationSlotId\n ]: CratisPresentationSlotDeclaration<SlotId>;\n};\n\n/**\n * Immutable list of the atomic slots whose contracts are stable. A stable presentation library may\n * implement any of them through {@link CratisPresentationUiLibrary.atomicSlots}; new ids are only\n * ever appended.\n */\nexport const cratisAtomicSlotIds = Object.freeze([\n 'datatables.paginator',\n 'common.tooltip',\n 'dropdown.select',\n 'display.datePicker',\n] as const);\n\n/** Identifier of one stable atomic slot. */\nexport type CratisAtomicSlotId = (typeof cratisAtomicSlotIds)[number];\n\n/** Exact public component prop contracts covered by the stable atomic slots. */\nexport interface CratisAtomicSlots {\n /**\n * Table paginator contract: zero-based `page`, `pageCount`, zero-based `onPageChange`, the\n * `TablePaginatorParts` parts and no ref.\n */\n readonly 'datatables.paginator': TablePaginatorProps;\n /**\n * Tooltip contract: non-interactive `content`, `position`, `disabled`, `className` and exactly\n * one focusable trigger child. The adapter keeps the trigger's `data-cratis-part` and renders\n * the popup as the `popup` part; there is no ref.\n */\n readonly 'common.tooltip': TooltipProps;\n /**\n * Select contract: the public `DropdownProps` with an untyped value, the `DropdownParts` parts\n * and no ref. The adapter owns the trigger, filter, listbox, keyboard and selection callbacks.\n */\n readonly 'dropdown.select': DropdownProps<unknown>;\n /**\n * Date picker contract: the public `DatePickerInputProps` with `Date | null` values, the\n * `DatePickerInputPassThrough` parts and no ref. Calendar library values stay inside the adapter.\n */\n readonly 'display.datePicker': DatePickerInputProps;\n}\n\n/** One stable, adapter-owned atomic slot declaration. */\nexport interface CratisAtomicSlotDeclaration<SlotId extends CratisAtomicSlotId> {\n /** Stable atomic slots give the adapter ownership of the complete interaction. */\n readonly mode: 'atomic';\n /** Unsupported declarations are expressed by omitting the slot. */\n readonly fidelity: 'native' | 'emulated';\n /** Component implementing the slot's exact public props contract. */\n readonly render: ComponentType<CratisAtomicSlots[SlotId]>;\n}\n\n/** Optional atomic implementations. An omitted slot keeps the built-in Components implementation. */\nexport type CratisAtomicSlotMap = {\n readonly [SlotId in CratisAtomicSlotId]?: CratisAtomicSlotDeclaration<SlotId>;\n};\n\n/** Capabilities whose meaning is stable for the bounded presentation profile. */\nexport type CratisPresentationCapabilityId =\n | 'slot.render'\n | 'parts.passthrough'\n | 'ssr.staticRender'\n | 'rtl'\n | 'forcedColors'\n | 'motion.reduced';\n\ntype CratisPresentationOptionalCapabilityId = Exclude<\n CratisPresentationCapabilityId,\n 'slot.render' | 'parts.passthrough' | 'ssr.staticRender'\n>;\n\n/** Required presentation capabilities followed by optional stable evidence capabilities. */\nexport type CratisPresentationCapabilities = readonly [\n 'slot.render',\n 'parts.passthrough',\n 'ssr.staticRender',\n ...CratisPresentationOptionalCapabilityId[],\n];\n\n/** Immutable manifest for one implementation of the stable presentation profile. */\nexport interface CratisPresentationUiLibrary {\n /** Stable, package-local renderer identity used for diagnostics and telemetry. */\n readonly id: string;\n /** Human-readable renderer name. */\n readonly displayName: string;\n /** Stable presentation renderer ABI major. */\n readonly abi: typeof CRATIS_PRESENTATION_ABI_VERSION;\n /** The bounded profile is a primitive presentation adapter. */\n readonly level: 'primitive';\n /** Exact stable presentation profile identifier. */\n readonly profile: typeof CRATIS_PRESENTATION_PROFILE;\n /** Canonical immutable list of all nine stable slots. */\n readonly profileSlots: typeof cratisPresentationSlotIds;\n /** Required presentation capabilities followed by any optional stable capabilities. */\n readonly capabilities: CratisPresentationCapabilities;\n /** Complete nine-slot presentation implementation. */\n readonly slots: CratisPresentationSlotMap;\n /** Optional provider mounted once around the selected renderer scope. */\n readonly Provider?: ComponentType<CratisPresentationUiLibraryProviderProps>;\n /**\n * Optional adapter-owned implementations of stable atomic slots. Omitted slots resolve to the\n * built-in Components implementation.\n */\n readonly atomicSlots?: CratisAtomicSlotMap;\n}\n\nconst requiredCapabilityIds = [\n 'slot.render',\n 'parts.passthrough',\n 'ssr.staticRender',\n] as const;\n\nconst stableCapabilityIds = new Set<CratisPresentationCapabilityId>([\n ...requiredCapabilityIds,\n 'rtl',\n 'forcedColors',\n 'motion.reduced',\n]);\n\nconst invalidPresentationLibrary: (reason: string) => never = (reason) => {\n throw new TypeError(`Invalid stable presentation UI library: ${reason}.`);\n};\n\nconst hasCanonicalProfileSlots = (profileSlots: readonly unknown[]): boolean =>\n profileSlots.length === cratisPresentationSlotIds.length &&\n profileSlots.every((slotId, index) => slotId === cratisPresentationSlotIds[index]);\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst isRendererIdentity = (id: unknown): boolean =>\n typeof id === 'string' &&\n id.length <= 128 &&\n /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(id);\n\nconst isDisplayName = (displayName: unknown): boolean =>\n typeof displayName === 'string' &&\n displayName.trim().length > 0 &&\n displayName.length <= 128;\n\nconst isComponent = (render: unknown): boolean =>\n render !== null && (typeof render === 'function' || typeof render === 'object');\n\nconst isStableFidelity = (fidelity: unknown): boolean =>\n fidelity === 'native' || fidelity === 'emulated';\n\nconst validateIdentity = (library: CratisPresentationUiLibrary) => {\n if (library === null || typeof library !== 'object') {\n invalidPresentationLibrary('manifest must be an object');\n }\n if (!isRendererIdentity(library.id)) {\n invalidPresentationLibrary('id must be a valid package-local renderer identity');\n }\n if (!isDisplayName(library.displayName)) {\n invalidPresentationLibrary(\n 'displayName must contain between 1 and 128 characters',\n );\n }\n if (library.Provider !== undefined && typeof library.Provider !== 'function') {\n invalidPresentationLibrary('Provider must be a React component when supplied');\n }\n};\n\nconst validateProfile = (library: CratisPresentationUiLibrary) => {\n if (library.profile !== CRATIS_PRESENTATION_PROFILE) {\n invalidPresentationLibrary(`profile must be '${CRATIS_PRESENTATION_PROFILE}'`);\n }\n if (library.abi !== CRATIS_PRESENTATION_ABI_VERSION) {\n invalidPresentationLibrary(`ABI must be ${CRATIS_PRESENTATION_ABI_VERSION}`);\n }\n if (library.level !== 'primitive') {\n invalidPresentationLibrary(\"level must be 'primitive'\");\n }\n if (\n !Array.isArray(library.profileSlots) ||\n !hasCanonicalProfileSlots(library.profileSlots)\n ) {\n invalidPresentationLibrary(\n 'profileSlots must be the canonical nine-slot profile',\n );\n }\n};\n\nconst declarationProblem = (\n declaration: Record<string, unknown>,\n label: string,\n mode: 'presentation' | 'atomic',\n): string | undefined => {\n if (declaration.mode !== mode) return `${label} must use ${mode} mode`;\n if (!isStableFidelity(declaration.fidelity)) {\n return `${label} must use native or emulated fidelity`;\n }\n if (!isComponent(declaration.render)) return `${label} must provide a component`;\n return undefined;\n};\n\nconst validateDeclaration = (\n declaration: Record<string, unknown>,\n label: string,\n mode: 'presentation' | 'atomic',\n) => {\n const problem = declarationProblem(declaration, label, mode);\n if (problem) invalidPresentationLibrary(problem);\n};\n\nconst validateSlots = (library: CratisPresentationUiLibrary) => {\n if (!library.slots || typeof library.slots !== 'object') {\n invalidPresentationLibrary('slots must be an object');\n }\n\n const slotIds = Object.keys(library.slots);\n if (\n slotIds.length !== cratisPresentationSlotIds.length ||\n cratisPresentationSlotIds.some((slotId) => !slotIds.includes(slotId))\n ) {\n invalidPresentationLibrary(\n 'slots must contain exactly the nine stable presentation slots',\n );\n }\n\n for (const slotId of cratisPresentationSlotIds) {\n // SAFETY: the canonical slot list indexes the complete stable map; the wider record view\n // exists only so runtime JavaScript callers can be checked before their value is frozen.\n const declaration = library.slots[slotId] as unknown as\n Record<string, unknown> | undefined;\n if (!declaration) {\n invalidPresentationLibrary(`slot '${slotId}' must provide a declaration`);\n }\n validateDeclaration(declaration, `slot '${slotId}'`, 'presentation');\n }\n};\n\nconst validateCapabilities = (library: CratisPresentationUiLibrary) => {\n if (\n !Array.isArray(library.capabilities) ||\n library.capabilities.some((capability) => !stableCapabilityIds.has(capability))\n ) {\n invalidPresentationLibrary(\n 'capabilities must stay within the stable presentation subset',\n );\n }\n if (\n requiredCapabilityIds.some(\n (capability, index) => library.capabilities[index] !== capability,\n )\n ) {\n invalidPresentationLibrary(\n 'capabilities must begin with slot.render, parts.passthrough, and ssr.staticRender',\n );\n }\n if (new Set(library.capabilities).size !== library.capabilities.length) {\n invalidPresentationLibrary('capabilities must not contain duplicates');\n }\n};\n\nconst isStableAtomicSlotId = (slotId: string): slotId is CratisAtomicSlotId =>\n (cratisAtomicSlotIds as readonly string[]).includes(slotId);\n\n/** One atomic slot entry inspected from a single own-enumerable snapshot of `atomicSlots`. */\ninterface AtomicSlotEntry {\n readonly slotId: string;\n /** Declaration read exactly once, or undefined for an explicitly omitted slot. */\n readonly declaration?: Readonly<Record<string, unknown>>;\n /** Why the entry cannot be used; undefined when it is valid. */\n readonly problem?: string;\n}\n\n/** Inspection of a library's `atomicSlots`: one problem for the map, or one result per own key. */\ninterface AtomicSlotInspection {\n readonly problem?: string;\n readonly entries: readonly AtomicSlotEntry[];\n}\n\nconst snapshotDeclaration = (declaration: Record<string, unknown>) => ({\n mode: declaration.mode,\n fidelity: declaration.fidelity,\n render: declaration.render,\n});\n\nconst inspectAtomicSlot = (slotId: string, value: unknown): AtomicSlotEntry => {\n const label = `atomic slot '${slotId}'`;\n if (!isStableAtomicSlotId(slotId)) {\n return { slotId, problem: `${label} is not a stable atomic slot` };\n }\n if (value === undefined) return { slotId };\n if (!isRecord(value)) return { slotId, problem: `${label} must provide a declaration` };\n\n const declaration = snapshotDeclaration(value);\n return { slotId, declaration, problem: declarationProblem(declaration, label, 'atomic') };\n};\n\nconst isPlainPrototype = (prototype: unknown): boolean =>\n prototype === null || prototype === Object.prototype;\n\n/**\n * Inspects `atomicSlots` through ONE snapshot of its own enumerable keys, reading each value\n * once. Inherited and non-enumerable declarations never take part in validation or resolution.\n */\nconst inspectAtomicSlots = (atomicSlots: unknown): AtomicSlotInspection => {\n if (atomicSlots === undefined) return { entries: [] };\n if (!isRecord(atomicSlots)) {\n return { problem: 'atomicSlots must be an object when supplied', entries: [] };\n }\n if (!isPlainPrototype(Object.getPrototypeOf(atomicSlots))) {\n return {\n problem: 'atomicSlots must be a plain object; inherited declarations are not allowed',\n entries: [],\n };\n }\n return {\n entries: Object.keys(atomicSlots).map((slotId) =>\n inspectAtomicSlot(slotId, atomicSlots[slotId]),\n ),\n };\n};\n\nconst isUsableAtomicSlot = (\n entry: AtomicSlotEntry,\n): entry is AtomicSlotEntry & { readonly declaration: Readonly<Record<string, unknown>> } =>\n entry.problem === undefined && entry.declaration !== undefined;\n\n/** Builds a frozen slot-id keyed map of the usable entries; keys are own data properties. */\nconst usableAtomicSlots = (entries: readonly AtomicSlotEntry[]): Readonly<Record<string, object>> =>\n Object.freeze(\n Object.fromEntries(\n entries\n .filter(isUsableAtomicSlot)\n .map(({ slotId, declaration }) => [slotId, Object.freeze(declaration)]),\n ),\n );\n\nconst frozenValidAtomicSlots = (atomicSlots: unknown): CratisAtomicSlotMap | undefined => {\n if (atomicSlots === undefined) return undefined;\n const inspection = inspectAtomicSlots(atomicSlots);\n const problem =\n inspection.problem ?? inspection.entries.find((entry) => entry.problem)?.problem;\n if (problem) invalidPresentationLibrary(problem);\n return usableAtomicSlots(inspection.entries) as CratisAtomicSlotMap;\n};\n\nconst freezeDeclaration = <\n Declaration extends {\n readonly mode: string;\n readonly fidelity: string;\n readonly render: unknown;\n },\n>(\n declaration: Declaration,\n): Declaration =>\n Object.freeze({\n mode: declaration.mode,\n fidelity: declaration.fidelity,\n render: declaration.render,\n }) as Declaration;\n\nconst freezePresentationSlots = (\n slots: CratisPresentationSlotMap,\n): CratisPresentationSlotMap =>\n Object.freeze(\n Object.fromEntries(\n cratisPresentationSlotIds.map((slotId) => [\n slotId,\n freezeDeclaration(slots[slotId]),\n ]),\n ),\n ) as CratisPresentationSlotMap;\n\n/**\n * Defines and freezes a complete implementation of the stable nine-slot presentation profile,\n * plus any optional stable atomic slots. Runtime validation protects JavaScript callers from\n * claiming a profile they do not implement.\n *\n * @param library Stable presentation library declaration.\n * @returns A defensive, deeply frozen manifest copy.\n */\nexport const definePresentationUiLibrary = (\n library: CratisPresentationUiLibrary,\n): CratisPresentationUiLibrary => {\n validateIdentity(library);\n validateProfile(library);\n validateSlots(library);\n validateCapabilities(library);\n const atomicSlots = frozenValidAtomicSlots(library.atomicSlots);\n\n return Object.freeze({\n id: library.id,\n displayName: library.displayName,\n abi: library.abi,\n level: library.level,\n profile: library.profile,\n profileSlots: cratisPresentationSlotIds,\n capabilities: Object.freeze([\n ...library.capabilities,\n ]) as CratisPresentationCapabilities,\n slots: freezePresentationSlots(library.slots),\n Provider: library.Provider,\n ...(atomicSlots === undefined ? {} : { atomicSlots }),\n });\n};\n\nconst atomicSlotsInspectionOf = (library: { readonly profile: string }) =>\n library.profile === CRATIS_PRESENTATION_PROFILE\n ? inspectAtomicSlots((library as { readonly atomicSlots?: unknown }).atomicSlots)\n : { entries: [] };\n\n/** One reason a stable presentation library's atomic slot cannot be resolved. */\nexport interface StableAtomicSlotProblem {\n /** Offending slot id, when the problem concerns a single entry. */\n readonly slotId?: string;\n /** Human-readable reason. */\n readonly message: string;\n}\n\n/**\n * Lists why a stable presentation library's atomic slots cannot all be resolved. Libraries built\n * with the generic definer or as raw manifests can claim the stable profile without passing\n * {@link definePresentationUiLibrary}; resolution skips their invalid entries and this reports them.\n *\n * @param library Renderer library being validated.\n * @returns Problems in key order; empty for valid or absent atomic slots and for other profiles.\n * @internal Resolution helper; not part of the public package surface.\n */\nexport const stableAtomicSlotProblemsOf = (library: {\n readonly profile: string;\n}): readonly StableAtomicSlotProblem[] => {\n const inspection: AtomicSlotInspection = atomicSlotsInspectionOf(library);\n if (inspection.problem) return [{ message: inspection.problem }];\n return inspection.entries.flatMap(({ slotId, problem }) =>\n problem ? [{ slotId, message: problem }] : [],\n );\n};\n\n/**\n * Returns the stable atomic slot declarations a stable presentation library adds to resolution.\n * Only own enumerable, fully valid declarations take part; invalid ones fail closed to the\n * built-in implementation and are reported by {@link stableAtomicSlotProblemsOf}. Libraries of any\n * other profile, and libraries without `atomicSlots`, contribute nothing, so their slot tables\n * resolve exactly as before.\n *\n * @param library Renderer library being resolved.\n * @returns The library's stable atomic declarations keyed by slot id; empty when it has none.\n * @internal Resolution helper; not part of the public package surface.\n */\nexport const stableAtomicSlotsOf = (library: {\n readonly profile: string;\n}): unstable_SlotMap =>\n usableAtomicSlots(atomicSlotsInspectionOf(library).entries) as unstable_SlotMap;\n"],"names":[],"mappings":"AAqBO,MAAM,2BAA2B,GAAG;AAGpC,MAAM,+BAA+B,GAAG;AAGxC,MAAM,yBAAyB,GAAG,MAAM,CAAC,M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