@cratis/components 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/CommandDialog/CommandDialog.js +4 -4
- package/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/CommandDialog/StepperCommandDialog.js +4 -4
- package/dist/cjs/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/cjs/Dialogs/Dialog.js +2 -2
- package/dist/cjs/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +4 -4
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts +3 -2
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.js +4 -4
- package/dist/esm/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.d.ts +5 -3
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js +2 -2
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ var Dialog = require('../Dialogs/Dialog.js');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var commands = require('@cratis/arc.react/commands');
|
|
8
8
|
|
|
9
|
-
const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
|
|
9
|
+
const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
|
|
10
10
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = commands.useCommandFormContext();
|
|
11
11
|
const commandInstance = commands.useCommandInstance();
|
|
12
12
|
const [isBusy, setIsBusy] = React.useState(false);
|
|
@@ -56,11 +56,11 @@ const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons
|
|
|
56
56
|
};
|
|
57
57
|
const processedChildren = processChildren(children);
|
|
58
58
|
const isDialogValid = (isValid !== false) && isCommandFormValid;
|
|
59
|
-
return (jsxRuntime.jsx(Dialog.Dialog, { title: title, visible: visible, width: width, style: style, resizable: resizable, buttons: buttons, onClose: onClose, onConfirm: handleConfirm, onCancel: onCancel, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isDialogValid, isBusy: isBusy, children: jsxRuntime.jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
59
|
+
return (jsxRuntime.jsx(Dialog.Dialog, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, onClose: onClose, onConfirm: handleConfirm, onCancel: onCancel, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isDialogValid, isBusy: isBusy, children: jsxRuntime.jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
60
60
|
};
|
|
61
61
|
const CommandDialogComponent = (props) => {
|
|
62
|
-
const { title, visible, width, style, resizable, buttons = dialogs.DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
|
|
63
|
-
return (jsxRuntime.jsx(commands.CommandForm, { ...commandFormProps, children: jsxRuntime.jsx(CommandDialogWrapper, { title: title, visible: visible, width: width, style: style, resizable: resizable, buttons: buttons, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
|
|
62
|
+
const { title, visible, width, style, contentStyle, resizable, buttons = dialogs.DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
|
|
63
|
+
return (jsxRuntime.jsx(commands.CommandForm, { ...commandFormProps, children: jsxRuntime.jsx(CommandDialogWrapper, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
|
|
64
64
|
};
|
|
65
65
|
const CommandDialogColumnWrapper = ({ children }) => (jsxRuntime.jsx(commands.CommandForm.Column, { children: children }));
|
|
66
66
|
CommandDialogColumnWrapper.displayName = 'CommandFormColumn';
|
|
@@ -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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React, { useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n Omit<DialogProps, 'children'> {\n children?: React.ReactNode;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n title,\n visible,\n width,\n style,\n resizable,\n buttons,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: DialogProps['style'];\n resizable?: boolean;\n buttons?: DialogProps['buttons'];\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n isValid?: boolean;\n onClose?: DialogProps['onClose'];\n onConfirm?: DialogProps['onConfirm'];\n onCancel?: DialogProps['onCancel'];\n onBeforeExecute?: (values: TCommand) => TCommand;\n children?: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\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 false;\n }\n\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\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 (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 const processedChildren = processChildren(children);\n const isDialogValid = (isValid !== false) && isCommandFormValid;\n\n return (\n <Dialog\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n buttons={buttons}\n onClose={onClose}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isDialogValid}\n isBusy={isBusy}\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\nconst CommandDialogComponent = <TCommand extends object = object>(props: CommandDialogProps<TCommand>) => {\n const {\n title,\n visible,\n width,\n style,\n resizable,\n buttons = DialogButtons.OkCancel,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n buttons={buttons}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nCommandDialogColumnWrapper.displayName = 'CommandFormColumn';\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["useCommandFormContext","useCommandInstance","useState","DialogResult","_jsx","CommandFormFieldWrapper","Dialog","DialogButtons","CommandForm"],"mappings":";;;;;;;;AAqBA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,
|
|
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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React, { useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n Omit<DialogProps, 'children'> {\n children?: React.ReactNode;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n title,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: DialogProps['style'];\n contentStyle?: DialogProps['contentStyle'];\n resizable?: boolean;\n buttons?: DialogProps['buttons'];\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n isValid?: boolean;\n onClose?: DialogProps['onClose'];\n onConfirm?: DialogProps['onConfirm'];\n onCancel?: DialogProps['onCancel'];\n onBeforeExecute?: (values: TCommand) => TCommand;\n children?: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\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 false;\n }\n\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\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 (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 const processedChildren = processChildren(children);\n const isDialogValid = (isValid !== false) && isCommandFormValid;\n\n return (\n <Dialog\n title={title}\n visible={visible}\n width={width}\n style={style}\n contentStyle={contentStyle}\n resizable={resizable}\n buttons={buttons}\n onClose={onClose}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isDialogValid}\n isBusy={isBusy}\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\nconst CommandDialogComponent = <TCommand extends object = object>(props: CommandDialogProps<TCommand>) => {\n const {\n title,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n contentStyle={contentStyle}\n resizable={resizable}\n buttons={buttons}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nCommandDialogColumnWrapper.displayName = 'CommandFormColumn';\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["useCommandFormContext","useCommandInstance","useState","DialogResult","_jsx","CommandFormFieldWrapper","Dialog","DialogButtons","CommandForm"],"mappings":";;;;;;;;AAqBA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,EAmBX,KAAI;AACD,IAAA,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAGA,8BAAqB,EAAY;AAC7G,IAAA,MAAM,eAAe,GAAGC,2BAAkB,EAAY;IACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,aAAa,GAAG,YAAW;QAC7B,IAAI,eAAe,EAAE;AACjB,YAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,eAAe,CAAC;YAC1D,gBAAgB,CAAC,iBAAiB,CAAC;QACvC;QAEA,SAAS,CAAC,IAAI,CAAC;AACf,QAAA,IAAI,MAA+B;AACnC,QAAA,IAAI;AACA,YAAA,MAAM,GAAG,MAAO,eAAkF,CAAC,OAAO,EAAE;QAChH;gBAAU;YACN,SAAS,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,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,gBAAgB,CAAC,eAAe,EAAA,QAAA,EAEhD,QAAQ,EAAA,CACU,EAAA,CACb;AAEtB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAE,QAAQ,EAAiC,MAC3EA,cAAA,CAACI,oBAAW,CAAC,MAAM,cAAE,QAAQ,EAAA,CAAsB,CACtD;AACD,0BAA0B,CAAC,WAAW,GAAG,mBAAmB;AAE5D,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAEnD,MAAM,aAAa,GAAG;;;;"}
|
|
@@ -35,7 +35,7 @@ const extractFieldNamesFromNode = (nodes) => {
|
|
|
35
35
|
});
|
|
36
36
|
return names;
|
|
37
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 }) => {
|
|
38
|
+
const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, contentStyle, 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
39
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = commands.useCommandFormContext();
|
|
40
40
|
const commandInstance = commands.useCommandInstance();
|
|
41
41
|
const [isBusy, setIsBusy] = React.useState(false);
|
|
@@ -158,11 +158,11 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
158
158
|
setVisitedSteps(prev => new Set(prev).add(activeStep));
|
|
159
159
|
setActiveStep(s => s + 1);
|
|
160
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) }) }));
|
|
161
|
+
return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(dialogs.DialogResult.Cancelled), visible: visible, style: { width, ...style }, contentStyle: contentStyle, 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
162
|
};
|
|
163
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 }) }));
|
|
164
|
+
const { title, visible, width, style, contentStyle, 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, contentStyle: contentStyle, 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
166
|
};
|
|
167
167
|
const StepperCommandDialog = StepperCommandDialogComponent;
|
|
168
168
|
|
|
@@ -1 +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,IAA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B,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;;;;"}
|
|
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, type DialogProps as PrimeDialogProps } 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 './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?: PrimeDialogProps['style'];\n /** Custom CSS styles applied to the dialog content area. */\n contentStyle?: PrimeDialogProps['contentStyle'];\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 contentStyle,\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?: PrimeDialogProps['style'];\n contentStyle?: PrimeDialogProps['contentStyle'];\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 contentStyle={contentStyle}\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 contentStyle,\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 contentStyle={contentStyle}\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":";;;;;;;;;;;AAoBA,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,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iB,EAAA,CACpB;AAEtB,CAAC;AAEM,MAAM,oBAAoB,GAAG;;;;"}
|
|
@@ -5,7 +5,7 @@ var dialog = require('primereact/dialog');
|
|
|
5
5
|
var button = require('primereact/button');
|
|
6
6
|
var dialogs = require('@cratis/arc.react/dialogs');
|
|
7
7
|
|
|
8
|
-
const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons = dialogs.DialogButtons.OkCancel, children, width = '450px', style, resizable = false, isValid, isBusy = false, okLabel = 'Ok', cancelLabel = 'Cancel', yesLabel = 'Yes', noLabel = 'No' }) => {
|
|
8
|
+
const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons = dialogs.DialogButtons.OkCancel, children, width = '450px', style, contentStyle, resizable = false, isValid, isBusy = false, okLabel = 'Ok', cancelLabel = 'Cancel', yesLabel = 'Yes', noLabel = 'No' }) => {
|
|
9
9
|
let contextCloseDialog;
|
|
10
10
|
try {
|
|
11
11
|
const context = dialogs.useDialogContext();
|
|
@@ -63,7 +63,7 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
|
|
|
63
63
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, {}));
|
|
64
64
|
};
|
|
65
65
|
const footer = (jsxRuntime.jsx("div", { className: "flex flex-wrap justify-content-start gap-3", children: getFooterInterior() }));
|
|
66
|
-
return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer, onHide: typeof buttons === 'number' ? () => handleClose(dialogs.DialogResult.Cancelled) : () => { }, visible: visible, style: { width, ...style }, resizable: resizable, closable: typeof buttons === 'number', children: children }));
|
|
66
|
+
return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer, onHide: typeof buttons === 'number' ? () => handleClose(dialogs.DialogResult.Cancelled) : () => { }, visible: visible, style: { width, ...style }, contentStyle: contentStyle, resizable: resizable, closable: typeof buttons === 'number', children: children }));
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
exports.Dialog = Dialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.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 { Dialog as PrimeDialog } from 'primereact/dialog';\nimport { Button } from 'primereact/button';\nimport { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { CSSProperties, ReactNode } from 'react';\n\nexport type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\nexport interface DialogProps {\n title: string;\n visible?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n buttons?: DialogButtons | ReactNode;\n children: ReactNode;\n width?: string;\n style?: CSSProperties;\n resizable?: boolean;\n isValid?: boolean;\n isBusy?: boolean;\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n}\n\nexport const Dialog = ({ \n title, \n visible = true, \n onClose, \n onConfirm,\n onCancel,\n buttons = DialogButtons.OkCancel, \n children, \n width = '450px', \n style,\n resizable = false, \n isValid,\n isBusy = false,\n okLabel = 'Ok',\n cancelLabel = 'Cancel',\n yesLabel = 'Yes',\n noLabel = 'No'\n}: DialogProps) => {\n // Try to get dialog context, but allow it to be undefined for standalone usage\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n // No context available - dialog is being used standalone\n contextCloseDialog = undefined;\n }\n \n const isDialogValid = isValid !== false;\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 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 okFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n </>\n );\n\n const okCancelFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} disabled={isBusy} />\n </>\n );\n\n const yesNoFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} disabled={isBusy} />\n </>\n );\n\n const yesNoCancelFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} disabled={isBusy} />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} disabled={isBusy} />\n </>\n );\n\n const getFooterInterior = () => {\n // If buttons is a ReactNode (custom buttons), use it directly\n if (typeof buttons !== 'number') {\n return buttons;\n }\n\n // Otherwise, use predefined buttons based on DialogButtons enum\n switch (buttons) {\n case DialogButtons.Ok:\n return okFooter;\n case DialogButtons.OkCancel:\n return okCancelFooter;\n case DialogButtons.YesNo:\n return yesNoFooter;\n case DialogButtons.YesNoCancel:\n return yesNoCancelFooter;\n }\n\n return (<></>);\n };\n\n const footer = (\n <div className=\"flex flex-wrap justify-content-start gap-3\">\n {getFooterInterior()}\n </div>\n );\n\n return (\n <PrimeDialog\n header={headerElement}\n modal\n footer={footer}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onHide={typeof buttons === 'number' ? () => handleClose(DialogResult.Cancelled) : () => {}}\n visible={visible}\n style={{ width, ...style }}\n resizable={resizable}\n closable={typeof buttons === 'number'}>\n {children}\n </PrimeDialog>\n );\n};\n"],"names":["DialogButtons","useDialogContext","_jsx","DialogResult","Button","_jsxs","_Fragment","PrimeDialog"],"mappings":";;;;;;;AA+BO,MAAM,MAAM,GAAG,CAAC,EACnB,KAAK,EACL,OAAO,GAAG,IAAI,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,GAAGA,qBAAa,CAAC,QAAQ,EAChC,QAAQ,EACR,KAAK,GAAG,OAAO,EACf,KAAK,EACL,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,IAAI,EACd,WAAW,GAAG,QAAQ,EACtB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,IAAI,EACJ,KAAI;AAEd,IAAA,IAAI,kBAAgE;AACpE,IAAA,IAAI;AACA,QAAA,MAAM,OAAO,GAAGC,wBAAgB,EAAE;AAClC,QAAA,kBAAkB,GAAG,OAAO,EAAE,WAAW;IAC7C;AAAE,IAAA,MAAM;QAEJ,kBAAkB,GAAG,SAAS;IAClC;AAEA,IAAA,MAAM,aAAa,GAAG,OAAO,KAAK,KAAK;AACvC,IAAA,MAAM,aAAa,IACfC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6DAA6D,EAAA,QAAA,EACxEA,cAAA,CAAA,MAAA,EAAA,EAAM,SAA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,QAAQ,GAAG,MAAM,WAAW,CAACJ,oBAAY,CAAC,SAAS,CAAC,GAAG,MAAK,EAAE,CAAC,EAC1F,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EAAA,QAAA,EACpC,QAAQ,EAAA,CACC;AAEtB;;;;"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.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 { Dialog as PrimeDialog, type DialogProps as PrimeDialogProps } from 'primereact/dialog';\nimport { Button } from 'primereact/button';\nimport { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { ReactNode } from 'react';\n\nexport type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\nexport interface DialogProps {\n title: string;\n visible?: boolean;\n onClose?: CloseDialog;\n onConfirm?: ConfirmCallback;\n onCancel?: CancelCallback;\n buttons?: DialogButtons | ReactNode;\n children: ReactNode;\n width?: string;\n style?: PrimeDialogProps['style'];\n contentStyle?: PrimeDialogProps['contentStyle'];\n resizable?: boolean;\n isValid?: boolean;\n isBusy?: boolean;\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n}\n\nexport const Dialog = ({ \n title, \n visible = true, \n onClose, \n onConfirm,\n onCancel,\n buttons = DialogButtons.OkCancel, \n children, \n width = '450px', \n style,\n contentStyle,\n resizable = false, \n isValid,\n isBusy = false,\n okLabel = 'Ok',\n cancelLabel = 'Cancel',\n yesLabel = 'Yes',\n noLabel = 'No'\n}: DialogProps) => {\n // Try to get dialog context, but allow it to be undefined for standalone usage\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n // No context available - dialog is being used standalone\n contextCloseDialog = undefined;\n }\n \n const isDialogValid = isValid !== false;\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 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 okFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n </>\n );\n\n const okCancelFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} disabled={isBusy} />\n </>\n );\n\n const yesNoFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} disabled={isBusy} />\n </>\n );\n\n const yesNoCancelFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid || isBusy} loading={isBusy} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} disabled={isBusy} />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} disabled={isBusy} />\n </>\n );\n\n const getFooterInterior = () => {\n // If buttons is a ReactNode (custom buttons), use it directly\n if (typeof buttons !== 'number') {\n return buttons;\n }\n\n // Otherwise, use predefined buttons based on DialogButtons enum\n switch (buttons) {\n case DialogButtons.Ok:\n return okFooter;\n case DialogButtons.OkCancel:\n return okCancelFooter;\n case DialogButtons.YesNo:\n return yesNoFooter;\n case DialogButtons.YesNoCancel:\n return yesNoCancelFooter;\n }\n\n return (<></>);\n };\n\n const footer = (\n <div className=\"flex flex-wrap justify-content-start gap-3\">\n {getFooterInterior()}\n </div>\n );\n\n return (\n <PrimeDialog\n header={headerElement}\n modal\n footer={footer}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onHide={typeof buttons === 'number' ? () => handleClose(DialogResult.Cancelled) : () => {}}\n visible={visible}\n style={{ width, ...style }}\n contentStyle={contentStyle}\n resizable={resizable}\n closable={typeof buttons === 'number'}>\n {children}\n </PrimeDialog>\n );\n};\n"],"names":["DialogButtons","useDialogContext","_jsx","DialogResult","Button","_jsxs","_Fragment","PrimeDialog"],"mappings":";;;;;;;AAgCO,MAAM,MAAM,GAAG,CAAC,EACnB,KAAK,EACL,OAAO,GAAG,IAAI,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,GAAGA,qBAAa,CAAC,QAAQ,EAChC,QAAQ,EACR,KAAK,GAAG,OAAO,EACf,KAAK,EACL,YAAY,EACZ,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,IAAI,EACd,WAAW,GAAG,QAAQ,EACtB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,IAAI,EACJ,KAAI;AAEd,IAAA,IAAI,kBAAg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B;;QAGhC,QAAQE,cAAA,CAAAI,mBAAA,EAAA,EAAA,CAAK;AACjB,IAAA,CAAC;AAED,IAAA,MAAM,MAAM,IACRJ,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4CAA4C,EAAA,QAAA,EACtD,iBAAiB,EAAE,EAAA,CAClB,CACT;AAED,IAAA,QACIA,cAAA,CAACK,aAAW,EAAA,EACR,MAAM,EAAE,aAAa,EACrB,KAAK,EAAA,IAAA,EACL,MAAM,EAAE,MAAM,EAEd,MAAM,EAAE,OAAO,OAAO,KAAK,QAAQ,GAAG,MAAM,WAAW,CAACJ,oBAAY,CAAC,SAAS,CAAC,GAAG,MAAK,EAAE,CAAC,EAC1F,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAC1B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EAAA,QAAA,EACpC,QAAQ,EAAA,CACC;AAEtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,CACvD,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAChD,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;
|
|
1
|
+
{"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,CACvD,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,EAChD,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAmLD,eAAO,MAAM,aAAa;KAtDM,QAAQ,SAAS,MAAM,kBAAkB,kBAAkB,CAAC,QAAQ,CAAC;;uBA+CnD;YAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE;;;CAO5B,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { Dialog } from '../Dialogs/Dialog.js';
|
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
5
|
import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
6
6
|
|
|
7
|
-
const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
|
|
7
|
+
const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
|
|
8
8
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext();
|
|
9
9
|
const commandInstance = useCommandInstance();
|
|
10
10
|
const [isBusy, setIsBusy] = useState(false);
|
|
@@ -54,11 +54,11 @@ const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons
|
|
|
54
54
|
};
|
|
55
55
|
const processedChildren = processChildren(children);
|
|
56
56
|
const isDialogValid = (isValid !== false) && isCommandFormValid;
|
|
57
|
-
return (jsx(Dialog, { title: title, visible: visible, width: width, style: style, resizable: resizable, buttons: buttons, onClose: onClose, onConfirm: handleConfirm, onCancel: onCancel, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isDialogValid, isBusy: isBusy, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
57
|
+
return (jsx(Dialog, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, onClose: onClose, onConfirm: handleConfirm, onCancel: onCancel, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isDialogValid, isBusy: isBusy, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
58
58
|
};
|
|
59
59
|
const CommandDialogComponent = (props) => {
|
|
60
|
-
const { title, visible, width, style, resizable, buttons = DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
|
|
61
|
-
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { title: title, visible: visible, width: width, style: style, resizable: resizable, buttons: buttons, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
|
|
60
|
+
const { title, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
|
|
61
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
|
|
62
62
|
};
|
|
63
63
|
const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
|
|
64
64
|
CommandDialogColumnWrapper.displayName = 'CommandFormColumn';
|
|
@@ -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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React, { useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n Omit<DialogProps, 'children'> {\n children?: React.ReactNode;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n title,\n visible,\n width,\n style,\n resizable,\n buttons,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: DialogProps['style'];\n resizable?: boolean;\n buttons?: DialogProps['buttons'];\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n isValid?: boolean;\n onClose?: DialogProps['onClose'];\n onConfirm?: DialogProps['onConfirm'];\n onCancel?: DialogProps['onCancel'];\n onBeforeExecute?: (values: TCommand) => TCommand;\n children?: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\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 false;\n }\n\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\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 (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 const processedChildren = processChildren(children);\n const isDialogValid = (isValid !== false) && isCommandFormValid;\n\n return (\n <Dialog\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n buttons={buttons}\n onClose={onClose}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isDialogValid}\n isBusy={isBusy}\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\nconst CommandDialogComponent = <TCommand extends object = object>(props: CommandDialogProps<TCommand>) => {\n const {\n title,\n visible,\n width,\n style,\n resizable,\n buttons = DialogButtons.OkCancel,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n resizable={resizable}\n buttons={buttons}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nCommandDialogColumnWrapper.displayName = 'CommandFormColumn';\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;AAqBA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,
|
|
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 { ICommandResult } from '@cratis/arc/commands';\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React, { useState } from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object>\n extends Omit<CommandFormProps<TCommand>, 'children'>,\n Omit<DialogProps, 'children'> {\n children?: React.ReactNode;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n title,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n title: string;\n visible?: boolean;\n width?: string;\n style?: DialogProps['style'];\n contentStyle?: DialogProps['contentStyle'];\n resizable?: boolean;\n buttons?: DialogProps['buttons'];\n okLabel?: string;\n cancelLabel?: string;\n yesLabel?: string;\n noLabel?: string;\n isValid?: boolean;\n onClose?: DialogProps['onClose'];\n onConfirm?: DialogProps['onConfirm'];\n onCancel?: DialogProps['onCancel'];\n onBeforeExecute?: (values: TCommand) => TCommand;\n children?: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const [isBusy, setIsBusy] = useState(false);\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n setIsBusy(true);\n let result: ICommandResult<unknown>;\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 false;\n }\n\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\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 (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 const processedChildren = processChildren(children);\n const isDialogValid = (isValid !== false) && isCommandFormValid;\n\n return (\n <Dialog\n title={title}\n visible={visible}\n width={width}\n style={style}\n contentStyle={contentStyle}\n resizable={resizable}\n buttons={buttons}\n onClose={onClose}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isDialogValid}\n isBusy={isBusy}\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\nconst CommandDialogComponent = <TCommand extends object = object>(props: CommandDialogProps<TCommand>) => {\n const {\n title,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n children,\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n title={title}\n visible={visible}\n width={width}\n style={style}\n contentStyle={contentStyle}\n resizable={resizable}\n buttons={buttons}\n okLabel={okLabel}\n cancelLabel={cancelLabel}\n yesLabel={yesLabel}\n noLabel={noLabel}\n isValid={isValid}\n onClose={onClose}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={commandFormProps.onBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nCommandDialogColumnWrapper.displayName = 'CommandFormColumn';\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;AAqBA,MAAM,oBAAoB,GA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AAG;;;;"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { type DialogProps as PrimeDialogProps } from 'primereact/dialog';
|
|
1
2
|
import { type StepperProps } from 'primereact/stepper';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { type CommandFormProps } from '@cratis/arc.react/commands';
|
|
4
5
|
import type { CloseDialog, ConfirmCallback, CancelCallback } from '../Dialogs/Dialog';
|
|
5
|
-
import { CSSProperties } from 'react';
|
|
6
6
|
import './StepperCommandDialog.css';
|
|
7
7
|
type StepperCustomizationProps = Pick<StepperProps, 'orientation' | 'headerPosition' | 'linear' | 'onChangeStep' | 'start' | 'end' | 'pt' | 'ptOptions' | 'unstyled'>;
|
|
8
8
|
export interface StepperCommandDialogProps<TCommand extends object> extends Omit<CommandFormProps<TCommand>, 'children'>, StepperCustomizationProps {
|
|
9
9
|
title: string;
|
|
10
10
|
visible?: boolean;
|
|
11
11
|
width?: string;
|
|
12
|
-
style?:
|
|
12
|
+
style?: PrimeDialogProps['style'];
|
|
13
|
+
contentStyle?: PrimeDialogProps['contentStyle'];
|
|
13
14
|
resizable?: boolean;
|
|
14
15
|
isValid?: boolean;
|
|
15
16
|
onClose?: CloseDialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepperCommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StepperCommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAyB,KAAK,WAAW,IAAI,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChG,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,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,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAElC,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAEhD,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;AAyUD,eAAO,MAAM,oBAAoB,GA/DM,QAAQ,SAAS,MAAM,kBACnD,yBAAyB,CAAC,QAAQ,CAAC,4CA8DmB,CAAC"}
|
|
@@ -33,7 +33,7 @@ const extractFieldNamesFromNode = (nodes) => {
|
|
|
33
33
|
});
|
|
34
34
|
return names;
|
|
35
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 }) => {
|
|
36
|
+
const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, contentStyle, 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
37
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = useCommandFormContext();
|
|
38
38
|
const commandInstance = useCommandInstance();
|
|
39
39
|
const [isBusy, setIsBusy] = useState(false);
|
|
@@ -156,11 +156,11 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
156
156
|
setVisitedSteps(prev => new Set(prev).add(activeStep));
|
|
157
157
|
setActiveStep(s => s + 1);
|
|
158
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) }) }));
|
|
159
|
+
return (jsx(Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(DialogResult.Cancelled), visible: visible, style: { width, ...style }, contentStyle: contentStyle, 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
160
|
};
|
|
161
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 }) }));
|
|
162
|
+
const { title, visible, width, style, contentStyle, 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, contentStyle: contentStyle, 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
164
|
};
|
|
165
165
|
const StepperCommandDialog = StepperCommandDialogComponent;
|
|
166
166
|
|
|
@@ -1 +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,KAAK,KAAI;AACpC,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE;AAClC,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,QAAA,IAAK,SAAsC,CAAC,WAAW,KAAK,kBAAkB,EAAE;AAC5E,YAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAA8C;YACvE,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC;AAC9C,YAAA,IAAI,IAAI;AAAE,gBAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9B;AACA,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAgC;AACzD,QAAA,IAAI,UAAU,CAAC,QAAQ,IAAI,IAAI,EAAE;YAC7B,KAAK,CAA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K,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;;;;"}
|
|
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, type DialogProps as PrimeDialogProps } 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 './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?: PrimeDialogProps['style'];\n /** Custom CSS styles applied to the dialog content area. */\n contentStyle?: PrimeDialogProps['contentStyle'];\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 contentStyle,\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?: PrimeDialogProps['style'];\n contentStyle?: PrimeDialogProps['contentStyle'];\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 contentStyle={contentStyle}\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 contentStyle,\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 contentStyle={contentStyle}\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":";;;;;;;;;AAoBA,MAAM,eAAe,GAAG,CAAC,QAA+C,KAAY;IAChF,IAAI,OAAO,QA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AAW,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;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type DialogProps as PrimeDialogProps } from 'primereact/dialog';
|
|
1
2
|
import { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';
|
|
2
|
-
import {
|
|
3
|
+
import { ReactNode } from 'react';
|
|
3
4
|
export type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;
|
|
4
5
|
export type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;
|
|
5
6
|
export type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;
|
|
@@ -12,7 +13,8 @@ export interface DialogProps {
|
|
|
12
13
|
buttons?: DialogButtons | ReactNode;
|
|
13
14
|
children: ReactNode;
|
|
14
15
|
width?: string;
|
|
15
|
-
style?:
|
|
16
|
+
style?: PrimeDialogProps['style'];
|
|
17
|
+
contentStyle?: PrimeDialogProps['contentStyle'];
|
|
16
18
|
resizable?: boolean;
|
|
17
19
|
isValid?: boolean;
|
|
18
20
|
isBusy?: boolean;
|
|
@@ -21,5 +23,5 @@ export interface DialogProps {
|
|
|
21
23
|
yesLabel?: string;
|
|
22
24
|
noLabel?: string;
|
|
23
25
|
}
|
|
24
|
-
export declare const Dialog: ({ title, visible, onClose, onConfirm, onCancel, buttons, children, width, style, resizable, isValid, isBusy, okLabel, cancelLabel, yesLabel, noLabel }: DialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const Dialog: ({ title, visible, onClose, onConfirm, onCancel, buttons, children, width, style, contentStyle, resizable, isValid, isBusy, okLabel, cancelLabel, yesLabel, noLabel }: DialogProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
27
|
//# sourceMappingURL=Dialog.d.ts.map
|