@cratis/components 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cjs/CommandDialog/StepperCommandDialog.css +14 -0
  2. package/dist/cjs/CommandDialog/StepperCommandDialog.js +170 -0
  3. package/dist/cjs/CommandDialog/StepperCommandDialog.js.map +1 -0
  4. package/dist/cjs/CommandDialog/index.js +2 -0
  5. package/dist/cjs/CommandDialog/index.js.map +1 -1
  6. package/dist/cjs/Common/Page.js +2 -2
  7. package/dist/cjs/Common/Page.js.map +1 -1
  8. package/dist/cjs/tailwind-utilities.css +3 -0
  9. package/dist/esm/CommandDialog/StepperCommandDialog.css +14 -0
  10. package/dist/esm/CommandDialog/StepperCommandDialog.d.ts +25 -0
  11. package/dist/esm/CommandDialog/StepperCommandDialog.d.ts.map +1 -0
  12. package/dist/esm/CommandDialog/StepperCommandDialog.js +168 -0
  13. package/dist/esm/CommandDialog/StepperCommandDialog.js.map +1 -0
  14. package/dist/esm/CommandDialog/StepperCommandDialog.stories.d.ts +11 -0
  15. package/dist/esm/CommandDialog/StepperCommandDialog.stories.d.ts.map +1 -0
  16. package/dist/esm/CommandDialog/StepperCommandDialog.stories.js +104 -0
  17. package/dist/esm/CommandDialog/StepperCommandDialog.stories.js.map +1 -0
  18. package/dist/esm/CommandDialog/index.d.ts +1 -0
  19. package/dist/esm/CommandDialog/index.d.ts.map +1 -1
  20. package/dist/esm/CommandDialog/index.js +1 -0
  21. package/dist/esm/CommandDialog/index.js.map +1 -1
  22. package/dist/esm/Common/Page.d.ts +2 -1
  23. package/dist/esm/Common/Page.d.ts.map +1 -1
  24. package/dist/esm/Common/Page.js +2 -2
  25. package/dist/esm/Common/Page.js.map +1 -1
  26. package/dist/esm/Common/Page.stories.d.ts +2 -0
  27. package/dist/esm/Common/Page.stories.d.ts.map +1 -1
  28. package/dist/esm/Common/Page.stories.js +14 -0
  29. package/dist/esm/Common/Page.stories.js.map +1 -1
  30. package/dist/esm/DataPage/DataPage.stories.d.ts +2 -0
  31. package/dist/esm/DataPage/DataPage.stories.d.ts.map +1 -1
  32. package/dist/esm/DataPage/DataPage.stories.js +12 -0
  33. package/dist/esm/DataPage/DataPage.stories.js.map +1 -1
  34. package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.d.ts +2 -0
  35. package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.d.ts.map +1 -1
  36. package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.js +40 -0
  37. package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.js.map +1 -1
  38. package/dist/esm/tailwind-utilities.css +3 -0
  39. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +3 -3
@@ -0,0 +1,14 @@
1
+ /* Copyright (c) Cratis. All rights reserved. */
2
+ /* Licensed under the MIT license. See LICENSE file in the project root for full license information. */
3
+
4
+ /* ── Step validation colors ─────────────────────────────────────────────── */
5
+ /* The circle background colour for error/valid states is applied via inline
6
+ style on the number span through PrimeReact's passthrough API, so no CSS
7
+ class rules are needed here for those states.
8
+
9
+ Non-active steps are dimmed using PrimeReact's own data-p-active attribute
10
+ so no extra passthrough class injection is required. */
11
+
12
+ .p-stepper [data-pc-section="header"][data-p-active="false"] {
13
+ opacity: 0.5;
14
+ }
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var dialogs = require('@cratis/arc.react/dialogs');
5
+ var dialog = require('primereact/dialog');
6
+ var stepper = require('primereact/stepper');
7
+ var button = require('primereact/button');
8
+ var React = require('react');
9
+ var commands = require('@cratis/arc.react/commands');
10
+ require('./StepperCommandDialog.css');
11
+
12
+ const getPropertyName = (accessor) => {
13
+ if (typeof accessor !== 'function')
14
+ return '';
15
+ const fnStr = accessor.toString();
16
+ const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
17
+ return match ? match[1] : '';
18
+ };
19
+ const extractFieldNamesFromNode = (nodes) => {
20
+ const names = [];
21
+ React.Children.forEach(nodes, (child) => {
22
+ if (!React.isValidElement(child))
23
+ return;
24
+ const component = child.type;
25
+ if (component.displayName === 'CommandFormField') {
26
+ const fieldProps = child.props;
27
+ const name = getPropertyName(fieldProps.value);
28
+ if (name)
29
+ names.push(name);
30
+ }
31
+ const childProps = child.props;
32
+ if (childProps.children != null) {
33
+ names.push(...extractFieldNamesFromNode(childProps.children));
34
+ }
35
+ });
36
+ return names;
37
+ };
38
+ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, resizable = false, isValid, onClose, onConfirm, onCancel, onBeforeExecute, okLabel = 'Submit', nextLabel = 'Next', previousLabel = 'Previous', orientation = 'horizontal', headerPosition, linear = true, onChangeStep, start, end, pt, ptOptions, unstyled, children }) => {
39
+ const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = commands.useCommandFormContext();
40
+ const commandInstance = commands.useCommandInstance();
41
+ const [isBusy, setIsBusy] = React.useState(false);
42
+ const [activeStep, setActiveStep] = React.useState(0);
43
+ const [visitedSteps, setVisitedSteps] = React.useState(new Set([0]));
44
+ let contextCloseDialog;
45
+ try {
46
+ const context = dialogs.useDialogContext();
47
+ contextCloseDialog = context?.closeDialog;
48
+ }
49
+ catch {
50
+ contextCloseDialog = undefined;
51
+ }
52
+ const stepCount = React.Children.count(children);
53
+ const isLastStep = activeStep === stepCount - 1;
54
+ const isFirstStep = activeStep === 0;
55
+ const isDialogValid = isValid !== false && isCommandFormValid;
56
+ const stepFieldNames = React.useMemo(() => React.Children.toArray(children).map((step) => {
57
+ if (!React.isValidElement(step))
58
+ return [];
59
+ const stepProps = step.props;
60
+ return extractFieldNamesFromNode(stepProps.children);
61
+ }), [children]);
62
+ const stepHasError = (stepIndex) => stepFieldNames[stepIndex]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;
63
+ const handleClose = async (result) => {
64
+ let shouldCloseThroughContext = true;
65
+ if (result === dialogs.DialogResult.Ok || result === dialogs.DialogResult.Yes) {
66
+ if (onConfirm) {
67
+ const closeResult = await onConfirm();
68
+ shouldCloseThroughContext = closeResult === true;
69
+ }
70
+ else if (onClose) {
71
+ const closeResult = await onClose(result);
72
+ shouldCloseThroughContext = closeResult !== false;
73
+ }
74
+ }
75
+ else {
76
+ if (onCancel) {
77
+ const closeResult = await onCancel();
78
+ shouldCloseThroughContext = closeResult === true;
79
+ }
80
+ else if (onClose) {
81
+ const closeResult = await onClose(result);
82
+ shouldCloseThroughContext = closeResult !== false;
83
+ }
84
+ }
85
+ if (shouldCloseThroughContext) {
86
+ contextCloseDialog?.(result);
87
+ }
88
+ };
89
+ const handleSubmit = async () => {
90
+ if (onBeforeExecute) {
91
+ const transformedValues = onBeforeExecute(commandInstance);
92
+ setCommandValues(transformedValues);
93
+ }
94
+ setIsBusy(true);
95
+ let result;
96
+ try {
97
+ result = await commandInstance.execute();
98
+ }
99
+ finally {
100
+ setIsBusy(false);
101
+ }
102
+ if (!result.isSuccess) {
103
+ setCommandResult(result);
104
+ return;
105
+ }
106
+ await handleClose(dialogs.DialogResult.Ok);
107
+ };
108
+ const processChildren = (nodes) => {
109
+ return React.Children.map(nodes, (child) => {
110
+ if (!React.isValidElement(child))
111
+ return child;
112
+ const component = child.type;
113
+ if (component.displayName === 'CommandFormField') {
114
+ return jsxRuntime.jsx(commands.CommandFormFieldWrapper, { field: child });
115
+ }
116
+ const childProps = child.props;
117
+ if (childProps.children != null) {
118
+ return React.cloneElement(child, {
119
+ children: processChildren(childProps.children)
120
+ });
121
+ }
122
+ return child;
123
+ });
124
+ };
125
+ const stepperPt = React.useMemo(() => {
126
+ const userPt = pt;
127
+ const userStepperPanelPt = userPt?.stepperpanel;
128
+ const userNumberPt = userStepperPanelPt?.number;
129
+ return {
130
+ ...userPt,
131
+ stepperpanel: {
132
+ ...userStepperPanelPt,
133
+ number: (opts) => {
134
+ const existing = typeof userNumberPt === 'function'
135
+ ? userNumberPt(opts)
136
+ : userNumberPt ?? {};
137
+ const idx = opts.context.index;
138
+ const hasError = stepFieldNames[idx]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;
139
+ const isVisited = visitedSteps.has(idx);
140
+ const bgColor = hasError
141
+ ? 'var(--red-500, #ef4444)'
142
+ : isVisited
143
+ ? 'var(--green-500, #22c55e)'
144
+ : null;
145
+ if (!bgColor)
146
+ return existing;
147
+ const existingStyle = existing.style;
148
+ return {
149
+ ...existing,
150
+ style: { ...existingStyle, backgroundColor: bgColor, color: '#fff' }
151
+ };
152
+ }
153
+ }
154
+ };
155
+ }, [pt, stepFieldNames, getFieldError, visitedSteps]);
156
+ const headerElement = (jsxRuntime.jsx("div", { className: "inline-flex align-items-center justify-content-center gap-2", children: jsxRuntime.jsx("span", { className: "font-bold white-space-nowrap", children: title }) }));
157
+ const footer = (jsxRuntime.jsxs("div", { className: "flex align-items-center w-full gap-3", children: [!isFirstStep && (jsxRuntime.jsx(button.Button, { label: previousLabel, icon: "pi pi-arrow-left", onClick: () => setActiveStep(s => s - 1), disabled: isBusy, outlined: true })), jsxRuntime.jsx("div", { className: "flex-1" }), !isLastStep && (jsxRuntime.jsx(button.Button, { label: nextLabel, icon: "pi pi-arrow-right", iconPos: "right", onClick: () => {
158
+ setVisitedSteps(prev => new Set(prev).add(activeStep));
159
+ setActiveStep(s => s + 1);
160
+ }, disabled: isBusy || stepHasError(activeStep) })), isLastStep && isDialogValid && (jsxRuntime.jsx(button.Button, { label: okLabel, icon: "pi pi-check", onClick: handleSubmit, loading: isBusy, disabled: isBusy, autoFocus: true }))] }));
161
+ return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(dialogs.DialogResult.Cancelled), visible: visible, style: { width, ...style }, resizable: resizable, closable: true, children: jsxRuntime.jsx(stepper.Stepper, { activeStep: activeStep, linear: linear, orientation: orientation, headerPosition: headerPosition, onChangeStep: onChangeStep, start: start, end: end, pt: stepperPt, ptOptions: ptOptions, unstyled: unstyled, children: processChildren(children) }) }));
162
+ };
163
+ const StepperCommandDialogComponent = (props) => {
164
+ const { title, visible, width, style, resizable, isValid, onClose, onConfirm, onCancel, okLabel, nextLabel, previousLabel, orientation, headerPosition, linear, onChangeStep, start, end, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
165
+ return (jsxRuntime.jsx(commands.CommandForm, { ...commandFormProps, children: jsxRuntime.jsx(StepperCommandDialogWrapper, { title: title, visible: visible, width: width, style: style, resizable: resizable, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, okLabel: okLabel, nextLabel: nextLabel, previousLabel: previousLabel, orientation: orientation, headerPosition: headerPosition, linear: linear, onChangeStep: onChangeStep, start: start, end: end, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
166
+ };
167
+ const StepperCommandDialog = StepperCommandDialogComponent;
168
+
169
+ exports.StepperCommandDialog = StepperCommandDialog;
170
+ //# sourceMappingURL=StepperCommandDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogResult, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { Dialog as PrimeDialog } from 'primereact/dialog';\nimport { Stepper as PrimeStepper, type StepperProps } from 'primereact/stepper';\nimport { Button } from 'primereact/button';\nimport React, { useMemo, useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\nimport type { CloseDialog, ConfirmCallback, CancelCallback } from '../Dialogs/Dialog';\nimport { CSSProperties } from 'react';\nimport './StepperCommandDialog.css';\n\n/** Extracts the property name from an accessor function like `c => c.name`. */\nconst getPropertyName = (accessor: ((obj: unknown) => unknown) | unknown): string => {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n};\n\n/** Recursively collects all CommandFormField property names from a React node tree. */\nconst extractFieldNamesFromNode = (nodes: React.ReactNode): string[] => {\n const names: string[] = [];\n React.Children.forEach(nodes, (child) => {\n if (!React.isValidElement(child)) return;\n const component = child.type as React.ComponentType<unknown>;\n if ((component as { displayName?: string }).displayName === 'CommandFormField') {\n const fieldProps = child.props as { value?: (obj: unknown) => unknown };\n const name = getPropertyName(fieldProps.value);\n if (name) names.push(name);\n }\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n names.push(...extractFieldNamesFromNode(childProps.children as React.ReactNode));\n }\n });\n return names;\n};\n\n/**\n * Stepper-specific customization props forwarded directly to PrimeReact Stepper.\n * `activeStep` and `children` are managed internally and are excluded.\n */\ntype StepperCustomizationProps = Pick<StepperProps,\n 'orientation' | 'headerPosition' | 'linear' | 'onChangeStep' | 'start' | 'end' | 'pt' | 'ptOptions' | 'unstyled'\n>;\n\nexport interface StepperCommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n StepperCustomizationProps {\n /** Dialog title text. */\n title: string;\n /** Controls dialog visibility. Defaults to `true`. */\n visible?: boolean;\n /** Dialog width. */\n width?: string;\n /** Custom CSS styles applied to the dialog. */\n style?: CSSProperties;\n /** Whether the dialog can be resized. Defaults to `false`. */\n resizable?: boolean;\n /** Additional validity gate combined with command form validity. */\n isValid?: boolean;\n /** Fallback close callback. */\n onClose?: CloseDialog;\n /** Confirm callback — called only after successful command execution. */\n onConfirm?: ConfirmCallback;\n /** Cancel callback — invoked when the dialog X button is clicked. */\n onCancel?: CancelCallback;\n /** Label for the submit button shown on the last step when valid. Defaults to `'Submit'`. */\n okLabel?: string;\n /** Label for the next step button. Defaults to `'Next'`. */\n nextLabel?: string;\n /** Label for the previous step button. Defaults to `'Previous'`. */\n previousLabel?: string;\n /** StepperPanel children defining each wizard step. */\n children?: React.ReactNode;\n}\n\nconst StepperCommandDialogWrapper = <TCommand extends object>({\n title,\n visible = true,\n width = '600px',\n style,\n resizable = false,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n okLabel = 'Submit',\n nextLabel = 'Next',\n previousLabel = 'Previous',\n orientation = 'horizontal',\n headerPosition,\n linear = true,\n onChangeStep,\n start,\n end,\n pt,\n ptOptions,\n unstyled,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: CSSProperties;\n resizable?: boolean;\n isValid?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n onBeforeExecute?: (values: TCommand) => TCommand;\n okLabel?: string;\n nextLabel?: string;\n previousLabel?: string;\n children?: React.ReactNode;\n} & StepperCustomizationProps) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n const [activeStep, setActiveStep] = useState(0);\n const [visitedSteps, setVisitedSteps] = useState<Set<number>>(new Set([0]));\n\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n contextCloseDialog = undefined;\n }\n\n const stepCount = React.Children.count(children);\n const isLastStep = activeStep === stepCount - 1;\n const isFirstStep = activeStep === 0;\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n // Pre-compute the command property names for each StepperPanel step.\n // Used to determine whether a step has validation errors for the indicator badge.\n const stepFieldNames = useMemo(\n () => React.Children.toArray(children).map((step) => {\n if (!React.isValidElement(step)) return [] as string[];\n const stepProps = step.props as Record<string, unknown>;\n return extractFieldNamesFromNode(stepProps.children as React.ReactNode);\n }),\n [children]\n );\n\n const stepHasError = (stepIndex: number): boolean =>\n stepFieldNames[stepIndex]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;\n\n const handleClose = async (result: DialogResult) => {\n let shouldCloseThroughContext = true;\n\n if (result === DialogResult.Ok || result === DialogResult.Yes) {\n if (onConfirm) {\n const closeResult = await onConfirm();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n } else {\n if (onCancel) {\n const closeResult = await onCancel();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n }\n\n if (shouldCloseThroughContext) {\n contextCloseDialog?.(result);\n }\n };\n\n const handleSubmit = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\n\n try {\n result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\n } finally {\n setIsBusy(false);\n }\n\n if (!result.isSuccess) {\n setCommandResult(result);\n return;\n }\n\n await handleClose(DialogResult.Ok);\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 (component.displayName === 'CommandFormField') {\n type FieldElement = Parameters<typeof CommandFormFieldWrapper>[0]['field'];\n return <CommandFormFieldWrapper field={child as unknown as FieldElement} />;\n }\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n return React.cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n children: processChildren(childProps.children as React.ReactNode)\n });\n }\n\n return child;\n });\n };\n\n /**\n * Builds the passthrough `pt` object for PrimeStepper, injecting an inline\n * style onto the step *number* span to colour it red (errors) or green (visited\n * and valid). Targeting the number span — rather than the header `<li>` — means\n * PrimeReact's default `p-stepper-header` class and all its layout/separator\n * CSS are never disturbed.\n * Merges with any user-supplied `pt` prop.\n */\n const stepperPt = useMemo(() => {\n type StepContext = { context: { index: number } };\n type NumberPtFn = (opts: StepContext) => Record<string, unknown>;\n\n const userPt = pt as Record<string, unknown> | undefined;\n const userStepperPanelPt = userPt?.stepperpanel as Record<string, unknown> | undefined;\n const userNumberPt = userStepperPanelPt?.number;\n\n return {\n ...userPt,\n stepperpanel: {\n ...userStepperPanelPt,\n number: (opts: StepContext) => {\n const existing: Record<string, unknown> =\n typeof userNumberPt === 'function'\n ? (userNumberPt as NumberPtFn)(opts)\n : (userNumberPt as Record<string, unknown> | undefined) ?? {};\n const idx = opts.context.index;\n const hasError = stepFieldNames[idx]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;\n const isVisited = visitedSteps.has(idx);\n\n const bgColor = hasError\n ? 'var(--red-500, #ef4444)'\n : isVisited\n ? 'var(--green-500, #22c55e)'\n : null;\n\n if (!bgColor) return existing;\n const existingStyle = existing.style as Record<string, unknown> | undefined;\n return {\n ...existing,\n style: { ...existingStyle, backgroundColor: bgColor, color: '#fff' }\n };\n }\n }\n };\n }, [pt, stepFieldNames, getFieldError, visitedSteps]);\n\n const headerElement = (\n <div className=\"inline-flex align-items-center justify-content-center gap-2\">\n <span className=\"font-bold white-space-nowrap\">{title}</span>\n </div>\n );\n\n const footer = (\n <div className=\"flex align-items-center w-full gap-3\">\n {!isFirstStep && (\n <Button\n label={previousLabel}\n icon=\"pi pi-arrow-left\"\n onClick={() => setActiveStep(s => s - 1)}\n disabled={isBusy}\n outlined\n />\n )}\n <div className=\"flex-1\" />\n {!isLastStep && (\n <Button\n label={nextLabel}\n icon=\"pi pi-arrow-right\"\n iconPos=\"right\"\n onClick={() => {\n setVisitedSteps(prev => new Set(prev).add(activeStep));\n setActiveStep(s => s + 1);\n }}\n disabled={isBusy || stepHasError(activeStep)}\n />\n )}\n {isLastStep && isDialogValid && (\n <Button\n label={okLabel}\n icon=\"pi pi-check\"\n onClick={handleSubmit}\n loading={isBusy}\n disabled={isBusy}\n autoFocus\n />\n )}\n </div>\n );\n\n return (\n <PrimeDialog\n header={headerElement}\n modal\n footer={footer}\n onHide={() => handleClose(DialogResult.Cancelled)}\n visible={visible}\n style={{ width, ...style }}\n resizable={resizable}\n closable\n >\n <PrimeStepper\n activeStep={activeStep}\n linear={linear}\n orientation={orientation}\n headerPosition={headerPosition}\n onChangeStep={onChangeStep}\n start={start}\n end={end}\n pt={stepperPt as StepperProps['pt']}\n ptOptions={ptOptions}\n unstyled={unstyled}\n >\n {processChildren(children)}\n </PrimeStepper>\n </PrimeDialog>\n );\n};\n\nconst StepperCommandDialogComponent = <TCommand extends object = object>(\n props: StepperCommandDialogProps<TCommand>\n) => {\n const {\n title,\n visible,\n width,\n style,\n resizable,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n okLabel,\n nextLabel,\n previousLabel,\n orientation,\n headerPosition,\n linear,\n onChangeStep,\n start,\n end,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <StepperCommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n okLabel={okLabel}\n nextLabel={nextLabel}\n previousLabel={previousLabel}\n orientation={orientation}\n headerPosition={headerPosition}\n linear={linear}\n onChangeStep={onChangeStep}\n start={start}\n end={end}\n pt={pt}\n ptOptions={ptOptions}\n unstyled={unstyled}\n >\n {children}\n </StepperCommandDialogWrapper>\n </CommandForm>\n );\n};\n\nexport const StepperCommandDialog = StepperCommandDialogComponent;\n"],"names":["useCommandFormContext","useCommandInstance","useState","useDialogContext","useMemo","DialogResult","_jsx","CommandFormFieldWrapper","_jsxs","Button","PrimeDialog","PrimeStepper","CommandForm"],"mappings":";;;;;;;;;;;AAqBA,MAAM,eAAe,GAAG,CAAC,QAA+C,KAAY;IAChF,IAAI,OAAO,QAAQ,KAAK,UAAU;AAA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EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,EAAA,CACiB,EAAA,CACpB;AAEtB,CAAC;AAEM,MAAM,oBAAoB,GAAG;;;;"}
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var CommandDialog = require('./CommandDialog.js');
4
+ var StepperCommandDialog = require('./StepperCommandDialog.js');
4
5
 
5
6
 
6
7
 
7
8
  exports.CommandDialog = CommandDialog.CommandDialog;
9
+ exports.StepperCommandDialog = StepperCommandDialog.StepperCommandDialog;
8
10
  //# 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":";;;;;;;;"}
@@ -2,8 +2,8 @@
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
 
5
- const Page = ({ title, children, panel, ...rest }) => {
6
- return (jsxRuntime.jsxs("div", { className: 'flex flex-col h-full flex-1', ...rest, children: [jsxRuntime.jsx("h1", { className: 'text-3xl mt-3 mb-4', children: title }), jsxRuntime.jsx("main", { className: `overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`, children: children })] }));
5
+ const Page = ({ title, showTitle = false, children, panel, ...rest }) => {
6
+ return (jsxRuntime.jsxs("div", { className: 'flex flex-col h-full flex-1', ...rest, children: [showTitle && jsxRuntime.jsx("h1", { className: 'text-3xl mt-3 mb-4', children: title }), jsxRuntime.jsx("main", { className: `overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`, children: children })] }));
7
7
  };
8
8
 
9
9
  exports.Page = Page;
@@ -1 +1 @@
1
- {"version":3,"file":"Page.js","sources":["../../../Common/Page.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 { HTMLAttributes, ReactNode } from 'react';\n\nexport interface PageProps extends HTMLAttributes<HTMLDivElement> {\n title: string;\n children?: ReactNode;\n panel?: boolean\n}\n\nexport const Page = ({ title, children, panel, ...rest }: PageProps) => {\n return (\n <div className='flex flex-col h-full flex-1' {...rest}>\n <h1 className='text-3xl mt-3 mb-4'>{title}</h1>\n <main className={`overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`}>\n {children}\n </main>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAWO,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAa,KAAI;AACnE,IAAA,QACIA,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6BAA6B,EAAA,GAAK,IAAI,EAAA,QAAA,EAAA,CACjDC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,GAAM,EAC/CA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,+CAA+C,KAAK,GAAG,OAAO,GAAG,EAAE,EAAE,EAAA,QAAA,EACjF,QAAQ,EAAA,CACN,CAAA,EAAA,CACL;AAEd;;;;"}
1
+ {"version":3,"file":"Page.js","sources":["../../../Common/Page.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 { HTMLAttributes, ReactNode } from 'react';\n\nexport interface PageProps extends HTMLAttributes<HTMLDivElement> {\n title: string;\n showTitle?: boolean;\n children?: ReactNode;\n panel?: boolean\n}\n\nexport const Page = ({ title, showTitle = false, children, panel, ...rest }: PageProps) => {\n return (\n <div className='flex flex-col h-full flex-1' {...rest}>\n {showTitle && <h1 className='text-3xl mt-3 mb-4'>{title}</h1>}\n <main className={`overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`}>\n {children}\n </main>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;MAYa,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAa,KAAI;AACtF,IAAA,QACIA,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6BAA6B,KAAK,IAAI,EAAA,QAAA,EAAA,CAChD,SAAS,IAAIC,uBAAI,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,EAAA,CAAM,EAC7DA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,CAAA,4CAAA,EAA+C,KAAK,GAAG,OAAO,GAAG,EAAE,CAAA,CAAE,EAAA,QAAA,EACjF,QAAQ,EAAA,CACN,CAAA,EAAA,CACL;AAEd;;;;"}
@@ -328,6 +328,9 @@
328
328
  .ml-2 {
329
329
  margin-left: calc(var(--spacing) * 2);
330
330
  }
331
+ .ml-3 {
332
+ margin-left: calc(var(--spacing) * 3);
333
+ }
331
334
  .block {
332
335
  display: block;
333
336
  }
@@ -0,0 +1,14 @@
1
+ /* Copyright (c) Cratis. All rights reserved. */
2
+ /* Licensed under the MIT license. See LICENSE file in the project root for full license information. */
3
+
4
+ /* ── Step validation colors ─────────────────────────────────────────────── */
5
+ /* The circle background colour for error/valid states is applied via inline
6
+ style on the number span through PrimeReact's passthrough API, so no CSS
7
+ class rules are needed here for those states.
8
+
9
+ Non-active steps are dimmed using PrimeReact's own data-p-active attribute
10
+ so no extra passthrough class injection is required. */
11
+
12
+ .p-stepper [data-pc-section="header"][data-p-active="false"] {
13
+ opacity: 0.5;
14
+ }
@@ -0,0 +1,25 @@
1
+ import { type StepperProps } from 'primereact/stepper';
2
+ import React from 'react';
3
+ import { type CommandFormProps } from '@cratis/arc.react/commands';
4
+ import type { CloseDialog, ConfirmCallback, CancelCallback } from '../Dialogs/Dialog';
5
+ import { CSSProperties } from 'react';
6
+ import './StepperCommandDialog.css';
7
+ type StepperCustomizationProps = Pick<StepperProps, 'orientation' | 'headerPosition' | 'linear' | 'onChangeStep' | 'start' | 'end' | 'pt' | 'ptOptions' | 'unstyled'>;
8
+ export interface StepperCommandDialogProps<TCommand extends object> extends Omit<CommandFormProps<TCommand>, 'children'>, StepperCustomizationProps {
9
+ title: string;
10
+ visible?: boolean;
11
+ width?: string;
12
+ style?: CSSProperties;
13
+ resizable?: boolean;
14
+ isValid?: boolean;
15
+ onClose?: CloseDialog;
16
+ onConfirm?: ConfirmCallback;
17
+ onCancel?: CancelCallback;
18
+ okLabel?: string;
19
+ nextLabel?: string;
20
+ previousLabel?: string;
21
+ children?: React.ReactNode;
22
+ }
23
+ export declare const StepperCommandDialog: <TCommand extends object = object>(props: StepperCommandDialogProps<TCommand>) => import("react/jsx-runtime").JSX.Element;
24
+ export {};
25
+ //# sourceMappingURL=StepperCommandDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperCommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"names":[],"mappings":"AAMA,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhF,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,4BAA4B,CAAC;AAiCpC,KAAK,yBAAyB,GAAG,IAAI,CAAC,YAAY,EAC9C,aAAa,GAAG,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,GAAG,UAAU,CACnH,CAAC;AAEF,MAAM,WAAW,yBAAyB,CAAC,QAAQ,SAAS,MAAM,CAC9D,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAChD,yBAAyB;IAE7B,KAAK,EAAE,MAAM,CAAC;IAEd,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,WAAW,CAAC;IAEtB,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAoUD,eAAO,MAAM,oBAAoB,GA7DM,QAAQ,SAAS,MAAM,kBACnD,yBAAyB,CAAC,QAAQ,CAAC,4CA4DmB,CAAC"}
@@ -0,0 +1,168 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useDialogContext, DialogResult } from '@cratis/arc.react/dialogs';
3
+ import { Dialog } from 'primereact/dialog';
4
+ import { Stepper } from 'primereact/stepper';
5
+ import { Button } from 'primereact/button';
6
+ import React, { useState, useMemo } from 'react';
7
+ import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
8
+ import './StepperCommandDialog.css';
9
+
10
+ const getPropertyName = (accessor) => {
11
+ if (typeof accessor !== 'function')
12
+ return '';
13
+ const fnStr = accessor.toString();
14
+ const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
15
+ return match ? match[1] : '';
16
+ };
17
+ const extractFieldNamesFromNode = (nodes) => {
18
+ const names = [];
19
+ React.Children.forEach(nodes, (child) => {
20
+ if (!React.isValidElement(child))
21
+ return;
22
+ const component = child.type;
23
+ if (component.displayName === 'CommandFormField') {
24
+ const fieldProps = child.props;
25
+ const name = getPropertyName(fieldProps.value);
26
+ if (name)
27
+ names.push(name);
28
+ }
29
+ const childProps = child.props;
30
+ if (childProps.children != null) {
31
+ names.push(...extractFieldNamesFromNode(childProps.children));
32
+ }
33
+ });
34
+ return names;
35
+ };
36
+ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, resizable = false, isValid, onClose, onConfirm, onCancel, onBeforeExecute, okLabel = 'Submit', nextLabel = 'Next', previousLabel = 'Previous', orientation = 'horizontal', headerPosition, linear = true, onChangeStep, start, end, pt, ptOptions, unstyled, children }) => {
37
+ const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = useCommandFormContext();
38
+ const commandInstance = useCommandInstance();
39
+ const [isBusy, setIsBusy] = useState(false);
40
+ const [activeStep, setActiveStep] = useState(0);
41
+ const [visitedSteps, setVisitedSteps] = useState(new Set([0]));
42
+ let contextCloseDialog;
43
+ try {
44
+ const context = useDialogContext();
45
+ contextCloseDialog = context?.closeDialog;
46
+ }
47
+ catch {
48
+ contextCloseDialog = undefined;
49
+ }
50
+ const stepCount = React.Children.count(children);
51
+ const isLastStep = activeStep === stepCount - 1;
52
+ const isFirstStep = activeStep === 0;
53
+ const isDialogValid = isValid !== false && isCommandFormValid;
54
+ const stepFieldNames = useMemo(() => React.Children.toArray(children).map((step) => {
55
+ if (!React.isValidElement(step))
56
+ return [];
57
+ const stepProps = step.props;
58
+ return extractFieldNamesFromNode(stepProps.children);
59
+ }), [children]);
60
+ const stepHasError = (stepIndex) => stepFieldNames[stepIndex]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;
61
+ const handleClose = async (result) => {
62
+ let shouldCloseThroughContext = true;
63
+ if (result === DialogResult.Ok || result === DialogResult.Yes) {
64
+ if (onConfirm) {
65
+ const closeResult = await onConfirm();
66
+ shouldCloseThroughContext = closeResult === true;
67
+ }
68
+ else if (onClose) {
69
+ const closeResult = await onClose(result);
70
+ shouldCloseThroughContext = closeResult !== false;
71
+ }
72
+ }
73
+ else {
74
+ if (onCancel) {
75
+ const closeResult = await onCancel();
76
+ shouldCloseThroughContext = closeResult === true;
77
+ }
78
+ else if (onClose) {
79
+ const closeResult = await onClose(result);
80
+ shouldCloseThroughContext = closeResult !== false;
81
+ }
82
+ }
83
+ if (shouldCloseThroughContext) {
84
+ contextCloseDialog?.(result);
85
+ }
86
+ };
87
+ const handleSubmit = async () => {
88
+ if (onBeforeExecute) {
89
+ const transformedValues = onBeforeExecute(commandInstance);
90
+ setCommandValues(transformedValues);
91
+ }
92
+ setIsBusy(true);
93
+ let result;
94
+ try {
95
+ result = await commandInstance.execute();
96
+ }
97
+ finally {
98
+ setIsBusy(false);
99
+ }
100
+ if (!result.isSuccess) {
101
+ setCommandResult(result);
102
+ return;
103
+ }
104
+ await handleClose(DialogResult.Ok);
105
+ };
106
+ const processChildren = (nodes) => {
107
+ return React.Children.map(nodes, (child) => {
108
+ if (!React.isValidElement(child))
109
+ return child;
110
+ const component = child.type;
111
+ if (component.displayName === 'CommandFormField') {
112
+ return jsx(CommandFormFieldWrapper, { field: child });
113
+ }
114
+ const childProps = child.props;
115
+ if (childProps.children != null) {
116
+ return React.cloneElement(child, {
117
+ children: processChildren(childProps.children)
118
+ });
119
+ }
120
+ return child;
121
+ });
122
+ };
123
+ const stepperPt = useMemo(() => {
124
+ const userPt = pt;
125
+ const userStepperPanelPt = userPt?.stepperpanel;
126
+ const userNumberPt = userStepperPanelPt?.number;
127
+ return {
128
+ ...userPt,
129
+ stepperpanel: {
130
+ ...userStepperPanelPt,
131
+ number: (opts) => {
132
+ const existing = typeof userNumberPt === 'function'
133
+ ? userNumberPt(opts)
134
+ : userNumberPt ?? {};
135
+ const idx = opts.context.index;
136
+ const hasError = stepFieldNames[idx]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;
137
+ const isVisited = visitedSteps.has(idx);
138
+ const bgColor = hasError
139
+ ? 'var(--red-500, #ef4444)'
140
+ : isVisited
141
+ ? 'var(--green-500, #22c55e)'
142
+ : null;
143
+ if (!bgColor)
144
+ return existing;
145
+ const existingStyle = existing.style;
146
+ return {
147
+ ...existing,
148
+ style: { ...existingStyle, backgroundColor: bgColor, color: '#fff' }
149
+ };
150
+ }
151
+ }
152
+ };
153
+ }, [pt, stepFieldNames, getFieldError, visitedSteps]);
154
+ const headerElement = (jsx("div", { className: "inline-flex align-items-center justify-content-center gap-2", children: jsx("span", { className: "font-bold white-space-nowrap", children: title }) }));
155
+ const footer = (jsxs("div", { className: "flex align-items-center w-full gap-3", children: [!isFirstStep && (jsx(Button, { label: previousLabel, icon: "pi pi-arrow-left", onClick: () => setActiveStep(s => s - 1), disabled: isBusy, outlined: true })), jsx("div", { className: "flex-1" }), !isLastStep && (jsx(Button, { label: nextLabel, icon: "pi pi-arrow-right", iconPos: "right", onClick: () => {
156
+ setVisitedSteps(prev => new Set(prev).add(activeStep));
157
+ setActiveStep(s => s + 1);
158
+ }, disabled: isBusy || stepHasError(activeStep) })), isLastStep && isDialogValid && (jsx(Button, { label: okLabel, icon: "pi pi-check", onClick: handleSubmit, loading: isBusy, disabled: isBusy, autoFocus: true }))] }));
159
+ return (jsx(Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(DialogResult.Cancelled), visible: visible, style: { width, ...style }, resizable: resizable, closable: true, children: jsx(Stepper, { activeStep: activeStep, linear: linear, orientation: orientation, headerPosition: headerPosition, onChangeStep: onChangeStep, start: start, end: end, pt: stepperPt, ptOptions: ptOptions, unstyled: unstyled, children: processChildren(children) }) }));
160
+ };
161
+ const StepperCommandDialogComponent = (props) => {
162
+ const { title, visible, width, style, resizable, isValid, onClose, onConfirm, onCancel, okLabel, nextLabel, previousLabel, orientation, headerPosition, linear, onChangeStep, start, end, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
163
+ return (jsx(CommandForm, { ...commandFormProps, children: jsx(StepperCommandDialogWrapper, { title: title, visible: visible, width: width, style: style, resizable: resizable, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, okLabel: okLabel, nextLabel: nextLabel, previousLabel: previousLabel, orientation: orientation, headerPosition: headerPosition, linear: linear, onChangeStep: onChangeStep, start: start, end: end, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
164
+ };
165
+ const StepperCommandDialog = StepperCommandDialogComponent;
166
+
167
+ export { StepperCommandDialog };
168
+ //# sourceMappingURL=StepperCommandDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogResult, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { Dialog as PrimeDialog } from 'primereact/dialog';\nimport { Stepper as PrimeStepper, type StepperProps } from 'primereact/stepper';\nimport { Button } from 'primereact/button';\nimport React, { useMemo, useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\nimport type { CloseDialog, ConfirmCallback, CancelCallback } from '../Dialogs/Dialog';\nimport { CSSProperties } from 'react';\nimport './StepperCommandDialog.css';\n\n/** Extracts the property name from an accessor function like `c => c.name`. */\nconst getPropertyName = (accessor: ((obj: unknown) => unknown) | unknown): string => {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n};\n\n/** Recursively collects all CommandFormField property names from a React node tree. */\nconst extractFieldNamesFromNode = (nodes: React.ReactNode): string[] => {\n const names: string[] = [];\n React.Children.forEach(nodes, (child) => {\n if (!React.isValidElement(child)) return;\n const component = child.type as React.ComponentType<unknown>;\n if ((component as { displayName?: string }).displayName === 'CommandFormField') {\n const fieldProps = child.props as { value?: (obj: unknown) => unknown };\n const name = getPropertyName(fieldProps.value);\n if (name) names.push(name);\n }\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n names.push(...extractFieldNamesFromNode(childProps.children as React.ReactNode));\n }\n });\n return names;\n};\n\n/**\n * Stepper-specific customization props forwarded directly to PrimeReact Stepper.\n * `activeStep` and `children` are managed internally and are excluded.\n */\ntype StepperCustomizationProps = Pick<StepperProps,\n 'orientation' | 'headerPosition' | 'linear' | 'onChangeStep' | 'start' | 'end' | 'pt' | 'ptOptions' | 'unstyled'\n>;\n\nexport interface StepperCommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n StepperCustomizationProps {\n /** Dialog title text. */\n title: string;\n /** Controls dialog visibility. Defaults to `true`. */\n visible?: boolean;\n /** Dialog width. */\n width?: string;\n /** Custom CSS styles applied to the dialog. */\n style?: CSSProperties;\n /** Whether the dialog can be resized. Defaults to `false`. */\n resizable?: boolean;\n /** Additional validity gate combined with command form validity. */\n isValid?: boolean;\n /** Fallback close callback. */\n onClose?: CloseDialog;\n /** Confirm callback — called only after successful command execution. */\n onConfirm?: ConfirmCallback;\n /** Cancel callback — invoked when the dialog X button is clicked. */\n onCancel?: CancelCallback;\n /** Label for the submit button shown on the last step when valid. Defaults to `'Submit'`. */\n okLabel?: string;\n /** Label for the next step button. Defaults to `'Next'`. */\n nextLabel?: string;\n /** Label for the previous step button. Defaults to `'Previous'`. */\n previousLabel?: string;\n /** StepperPanel children defining each wizard step. */\n children?: React.ReactNode;\n}\n\nconst StepperCommandDialogWrapper = <TCommand extends object>({\n title,\n visible = true,\n width = '600px',\n style,\n resizable = false,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n okLabel = 'Submit',\n nextLabel = 'Next',\n previousLabel = 'Previous',\n orientation = 'horizontal',\n headerPosition,\n linear = true,\n onChangeStep,\n start,\n end,\n pt,\n ptOptions,\n unstyled,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: CSSProperties;\n resizable?: boolean;\n isValid?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n onBeforeExecute?: (values: TCommand) => TCommand;\n okLabel?: string;\n nextLabel?: string;\n previousLabel?: string;\n children?: React.ReactNode;\n} & StepperCustomizationProps) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n const [activeStep, setActiveStep] = useState(0);\n const [visitedSteps, setVisitedSteps] = useState<Set<number>>(new Set([0]));\n\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n contextCloseDialog = undefined;\n }\n\n const stepCount = React.Children.count(children);\n const isLastStep = activeStep === stepCount - 1;\n const isFirstStep = activeStep === 0;\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n // Pre-compute the command property names for each StepperPanel step.\n // Used to determine whether a step has validation errors for the indicator badge.\n const stepFieldNames = useMemo(\n () => React.Children.toArray(children).map((step) => {\n if (!React.isValidElement(step)) return [] as string[];\n const stepProps = step.props as Record<string, unknown>;\n return extractFieldNamesFromNode(stepProps.children as React.ReactNode);\n }),\n [children]\n );\n\n const stepHasError = (stepIndex: number): boolean =>\n stepFieldNames[stepIndex]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;\n\n const handleClose = async (result: DialogResult) => {\n let shouldCloseThroughContext = true;\n\n if (result === DialogResult.Ok || result === DialogResult.Yes) {\n if (onConfirm) {\n const closeResult = await onConfirm();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n } else {\n if (onCancel) {\n const closeResult = await onCancel();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n }\n\n if (shouldCloseThroughContext) {\n contextCloseDialog?.(result);\n }\n };\n\n const handleSubmit = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\n\n try {\n result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\n } finally {\n setIsBusy(false);\n }\n\n if (!result.isSuccess) {\n setCommandResult(result);\n return;\n }\n\n await handleClose(DialogResult.Ok);\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 (component.displayName === 'CommandFormField') {\n type FieldElement = Parameters<typeof CommandFormFieldWrapper>[0]['field'];\n return <CommandFormFieldWrapper field={child as unknown as FieldElement} />;\n }\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n return React.cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n children: processChildren(childProps.children as React.ReactNode)\n });\n }\n\n return child;\n });\n };\n\n /**\n * Builds the passthrough `pt` object for PrimeStepper, injecting an inline\n * style onto the step *number* span to colour it red (errors) or green (visited\n * and valid). Targeting the number span — rather than the header `<li>` — means\n * PrimeReact's default `p-stepper-header` class and all its layout/separator\n * CSS are never disturbed.\n * Merges with any user-supplied `pt` prop.\n */\n const stepperPt = useMemo(() => {\n type StepContext = { context: { index: number } };\n type NumberPtFn = (opts: StepContext) => Record<string, unknown>;\n\n const userPt = pt as Record<string, unknown> | undefined;\n const userStepperPanelPt = userPt?.stepperpanel as Record<string, unknown> | undefined;\n const userNumberPt = userStepperPanelPt?.number;\n\n return {\n ...userPt,\n stepperpanel: {\n ...userStepperPanelPt,\n number: (opts: StepContext) => {\n const existing: Record<string, unknown> =\n typeof userNumberPt === 'function'\n ? (userNumberPt as NumberPtFn)(opts)\n : (userNumberPt as Record<string, unknown> | undefined) ?? {};\n const idx = opts.context.index;\n const hasError = stepFieldNames[idx]?.some(fieldName => !!(getFieldError?.(fieldName))) ?? false;\n const isVisited = visitedSteps.has(idx);\n\n const bgColor = hasError\n ? 'var(--red-500, #ef4444)'\n : isVisited\n ? 'var(--green-500, #22c55e)'\n : null;\n\n if (!bgColor) return existing;\n const existingStyle = existing.style as Record<string, unknown> | undefined;\n return {\n ...existing,\n style: { ...existingStyle, backgroundColor: bgColor, color: '#fff' }\n };\n }\n }\n };\n }, [pt, stepFieldNames, getFieldError, visitedSteps]);\n\n const headerElement = (\n <div className=\"inline-flex align-items-center justify-content-center gap-2\">\n <span className=\"font-bold white-space-nowrap\">{title}</span>\n </div>\n );\n\n const footer = (\n <div className=\"flex align-items-center w-full gap-3\">\n {!isFirstStep && (\n <Button\n label={previousLabel}\n icon=\"pi pi-arrow-left\"\n onClick={() => setActiveStep(s => s - 1)}\n disabled={isBusy}\n outlined\n />\n )}\n <div className=\"flex-1\" />\n {!isLastStep && (\n <Button\n label={nextLabel}\n icon=\"pi pi-arrow-right\"\n iconPos=\"right\"\n onClick={() => {\n setVisitedSteps(prev => new Set(prev).add(activeStep));\n setActiveStep(s => s + 1);\n }}\n disabled={isBusy || stepHasError(activeStep)}\n />\n )}\n {isLastStep && isDialogValid && (\n <Button\n label={okLabel}\n icon=\"pi pi-check\"\n onClick={handleSubmit}\n loading={isBusy}\n disabled={isBusy}\n autoFocus\n />\n )}\n </div>\n );\n\n return (\n <PrimeDialog\n header={headerElement}\n modal\n footer={footer}\n onHide={() => handleClose(DialogResult.Cancelled)}\n visible={visible}\n style={{ width, ...style }}\n resizable={resizable}\n closable\n >\n <PrimeStepper\n activeStep={activeStep}\n linear={linear}\n orientation={orientation}\n headerPosition={headerPosition}\n onChangeStep={onChangeStep}\n start={start}\n end={end}\n pt={stepperPt as StepperProps['pt']}\n ptOptions={ptOptions}\n unstyled={unstyled}\n >\n {processChildren(children)}\n </PrimeStepper>\n </PrimeDialog>\n );\n};\n\nconst StepperCommandDialogComponent = <TCommand extends object = object>(\n props: StepperCommandDialogProps<TCommand>\n) => {\n const {\n title,\n visible,\n width,\n style,\n resizable,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n okLabel,\n nextLabel,\n previousLabel,\n orientation,\n headerPosition,\n linear,\n onChangeStep,\n start,\n end,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <StepperCommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n okLabel={okLabel}\n nextLabel={nextLabel}\n previousLabel={previousLabel}\n orientation={orientation}\n headerPosition={headerPosition}\n linear={linear}\n onChangeStep={onChangeStep}\n start={start}\n end={end}\n pt={pt}\n ptOptions={ptOptions}\n unstyled={unstyled}\n >\n {children}\n </StepperCommandDialogWrapper>\n </CommandForm>\n );\n};\n\nexport const StepperCommandDialog = StepperCommandDialogComponent;\n"],"names":["_jsx","_jsxs","PrimeDialog","PrimeStepper"],"mappings":";;;;;;;;;AAqBA,MAAM,eAAe,GAAG,CAAC,QAA+C,KAAY;IAChF,IAAI,OAAO,QAAQ,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AAC7C,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC,CAAC;AAGD,MAAM,yBAAyB,GAAG,CAAC,KAAsB,KAAc;IACnE,MAAM,KAAK,GAAa,EAAE;IAC1B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,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tB,CAAC;AAED,MAAM,6BAA6B,GAAG,CAClC,KAA0C,KAC1C;IACA,MAAM,EACF,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,MAAM,EACN,YAAY,EACZ,KAAK,EACL,GAAG,EACH,EAAE,EACF,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,gBAAgB,EACtB,GAAG,KAAK;IAET,QACIH,IAAC,WAAW,EAAA,EAAA,GAAe,gBAAgB,EAAA,QAAA,EACvCA,GAAA,CAAC,2BAA2B,EAAA,EACxB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,gBAAgB,CAAC,eAAe,EACjD,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,YAEjB,QAAQ,EAAA,CACiB,EAAA,CACpB;AAEtB,CAAC;AAEM,MAAM,oBAAoB,GAAG;;;;"}
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { StepperCommandDialog } from './StepperCommandDialog';
3
+ import '@cratis/arc/validation';
4
+ declare const meta: Meta<typeof StepperCommandDialog>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof StepperCommandDialog>;
7
+ export declare const Default: Story;
8
+ export declare const ThreeSteps: Story;
9
+ export declare const WithValidationIndicators: Story;
10
+ export declare const WithBusyState: Story;
11
+ //# sourceMappingURL=StepperCommandDialog.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepperCommandDialog.stories.d.ts","sourceRoot":"","sources":["../../../CommandDialog/StepperCommandDialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAM9D,OAAO,wBAAwB,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,oBAAoB,CAG3C,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAwDnD,eAAO,MAAM,OAAO,EAAE,KA0ErB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAmExB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,KAyDtC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAuD3B,CAAC"}