@cratis/components 1.1.4 → 1.1.6

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.
@@ -6,8 +6,8 @@ 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 = ({ header, visible, width, confirmLabel, cancelLabel, onConfirm, onCancel, onBeforeExecute, children }) => {
10
- const { setCommandValues, setCommandResult, isValid } = commands.useCommandFormContext();
9
+ const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
10
+ const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = commands.useCommandFormContext();
11
11
  const commandInstance = commands.useCommandInstance();
12
12
  const handleConfirm = async () => {
13
13
  if (onBeforeExecute) {
@@ -15,14 +15,19 @@ const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabe
15
15
  setCommandValues(transformedValues);
16
16
  }
17
17
  const result = await commandInstance.execute();
18
- if (result.isSuccess) {
19
- await onConfirm(result);
20
- return true;
21
- }
22
- else {
18
+ if (!result.isSuccess) {
23
19
  setCommandResult(result);
24
20
  return false;
25
21
  }
22
+ if (onConfirm) {
23
+ const closeResult = await onConfirm();
24
+ return closeResult === true;
25
+ }
26
+ if (onClose) {
27
+ const closeResult = await onClose(dialogs.DialogResult.Ok);
28
+ return closeResult !== false;
29
+ }
30
+ return true;
26
31
  };
27
32
  const processChildren = (nodes) => {
28
33
  return React.Children.map(nodes, (child) => {
@@ -42,11 +47,12 @@ const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabe
42
47
  });
43
48
  };
44
49
  const processedChildren = processChildren(children);
45
- return (jsxRuntime.jsx(Dialog.Dialog, { title: header, visible: visible, width: width, onConfirm: handleConfirm, onCancel: onCancel, buttons: dialogs.DialogButtons.OkCancel, okLabel: confirmLabel, cancelLabel: cancelLabel, isValid: isValid, children: jsxRuntime.jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
50
+ const isDialogValid = (isValid !== false) && isCommandFormValid;
51
+ 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, children: jsxRuntime.jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
46
52
  };
47
53
  const CommandDialogComponent = (props) => {
48
- const { visible, header, confirmLabel = 'Confirm', cancelLabel = 'Cancel', onConfirm, onCancel, children, width = '50vw', ...commandFormProps } = props;
49
- return (jsxRuntime.jsx(commands.CommandForm, { ...commandFormProps, children: jsxRuntime.jsx(CommandDialogWrapper, { header: header, visible: visible, width: width, confirmLabel: confirmLabel, cancelLabel: cancelLabel, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
54
+ const { title, visible, width, style, resizable, buttons = dialogs.DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
55
+ 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 }) }));
50
56
  };
51
57
  const CommandDialogColumnWrapper = ({ children }) => (jsxRuntime.jsx(commands.CommandForm.Column, { children: children }));
52
58
  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 } from '@cratis/arc.react/dialogs';\nimport { Dialog } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends Omit<CommandFormProps<TCommand>, 'children'> {\n visible: boolean;\n header: string;\n confirmLabel?: string;\n cancelLabel?: string;\n onConfirm: (result: ICommandResult<TResponse>) => void | Promise<void>;\n onCancel: () => void;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n width?: string;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n header,\n visible,\n width,\n confirmLabel,\n cancelLabel,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n header: string;\n visible: boolean;\n width: string;\n confirmLabel: string;\n cancelLabel: string;\n onConfirm: (result: ICommandResult<unknown>) => void | Promise<void>;\n onCancel: () => void;\n onBeforeExecute?: (values: TCommand) => TCommand;\n children: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n const result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\n if (result.isSuccess) {\n await onConfirm(result);\n return true;\n } else {\n setCommandResult(result);\n return false;\n }\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\n return (\n <Dialog\n title={header}\n visible={visible}\n width={width}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n buttons={DialogButtons.OkCancel}\n okLabel={confirmLabel}\n cancelLabel={cancelLabel}\n isValid={isValid}\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, TResponse = object>(props: CommandDialogProps<TCommand, TResponse>) => {\n const {\n visible,\n header,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n onConfirm,\n onCancel,\n children,\n width = '50vw',\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n header={header}\n visible={visible}\n width={width}\n confirmLabel={confirmLabel}\n cancelLabel={cancelLabel}\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","_jsx","CommandFormFieldWrapper","Dialog","DialogButtons","CommandForm"],"mappings":";;;;;;;;AA4BA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,MAAM,EACN,OAAO,EACP,KAAK,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ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AiC,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;;;;"}
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 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\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n const result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\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 >\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","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,EAkBX,KAAI;AACD,IAAA,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAGA,8BAAqB,EAAY;AAC7G,IAAA,MAAM,eAAe,GAAGC,2BAAkB,EAAY;AAEtD,IAAA,MAAM,aAAa,GAAG,YAAW;QAC7B,IAAI,eAAe,EAAE;AACjB,YAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,eAAe,CAAC;YAC1D,gBAAgB,CAAC,iBAAiB,CAAC;QACvC;AAEA,QAAA,MAAM,MAAM,GAAG,MAAO,eAAkF,CAAC,OAAO,EAAE;AAElH,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACnB,gBAAgB,CAAC,MAAM,CAAC;AACxB,YAAA,OAAO,KAAK;QAChB;QAEA,IAAI,SAAS,EAAE;AACX,YAAA,MAAM,W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,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;;;;"}
@@ -3,7 +3,7 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
 
5
5
  const Page = ({ title, children, panel, ...rest }) => {
6
- return (jsxRuntime.jsxs("div", { className: 'flex flex-col h-full', ...rest, children: [jsxRuntime.jsx("h1", { className: 'text-3xl mt-3 mb-4', children: title }), jsxRuntime.jsx("main", { className: `overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`, children: children })] }));
6
+ return (jsxRuntime.jsxs("div", { className: 'flex flex-col h-full flex-1', ...rest, children: [jsxRuntime.jsx("h1", { className: 'text-3xl mt-3 mb-4', children: title }), jsxRuntime.jsx("main", { className: `overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`, children: children })] }));
7
7
  };
8
8
 
9
9
  exports.Page = Page;
@@ -1 +1 @@
1
- {"version":3,"file":"Page.js","sources":["../../../Common/Page.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { HTMLAttributes, ReactNode } from 'react';\n\nexport interface PageProps extends HTMLAttributes<HTMLDivElement> {\n title: string;\n children?: ReactNode;\n panel?: boolean\n}\n\nexport const Page = ({ title, children, panel, ...rest }: PageProps) => {\n return (\n <div className='flex flex-col h-full' {...rest}>\n <h1 className='text-3xl mt-3 mb-4'>{title}</h1>\n <main className={`overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`}>\n {children}\n </main>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAWO,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAa,KAAI;AACnE,IAAA,QACIA,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sBAAsB,EAAA,GAAK,IAAI,EAAA,QAAA,EAAA,CAC1CC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,GAAM,EAC/CA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,+CAA+C,KAAK,GAAG,OAAO,GAAG,EAAE,EAAE,EAAA,QAAA,EACjF,QAAQ,EAAA,CACN,CAAA,EAAA,CACL;AAEd;;;;"}
1
+ {"version":3,"file":"Page.js","sources":["../../../Common/Page.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { HTMLAttributes, ReactNode } from 'react';\n\nexport interface PageProps extends HTMLAttributes<HTMLDivElement> {\n title: string;\n children?: ReactNode;\n panel?: boolean\n}\n\nexport const Page = ({ title, children, panel, ...rest }: PageProps) => {\n return (\n <div className='flex flex-col h-full flex-1' {...rest}>\n <h1 className='text-3xl mt-3 mb-4'>{title}</h1>\n <main className={`overflow-hidden h-full flex flex-col flex-1 ${panel ? 'panel' : ''}`}>\n {children}\n </main>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAWO,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,EAAa,KAAI;AACnE,IAAA,QACIA,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6BAA6B,EAAA,GAAK,IAAI,EAAA,QAAA,EAAA,CACjDC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,KAAK,GAAM,EAC/CA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,+CAA+C,KAAK,GAAG,OAAO,GAAG,EAAE,EAAE,EAAA,QAAA,EACjF,QAAQ,EAAA,CACN,CAAA,EAAA,CACL;AAEd;;;;"}
@@ -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', resizable = false, isValid, 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, resizable = false, isValid, okLabel = 'Ok', cancelLabel = 'Cancel', yesLabel = 'Yes', noLabel = 'No' }) => {
9
9
  let contextCloseDialog;
10
10
  try {
11
11
  const context = dialogs.useDialogContext();
@@ -17,24 +17,28 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
17
17
  const isDialogValid = isValid !== false;
18
18
  const headerElement = (jsxRuntime.jsx("div", { className: "inline-flex align-items-center justify-content-center gap-2", children: jsxRuntime.jsx("span", { className: "font-bold white-space-nowrap", children: title }) }));
19
19
  const handleClose = async (result) => {
20
- let closeResult = true;
20
+ let shouldCloseThroughContext = true;
21
21
  if (result === dialogs.DialogResult.Ok || result === dialogs.DialogResult.Yes) {
22
22
  if (onConfirm) {
23
- closeResult = await onConfirm();
23
+ const closeResult = await onConfirm();
24
+ shouldCloseThroughContext = closeResult === true;
24
25
  }
25
26
  else if (onClose) {
26
- closeResult = await onClose(result);
27
+ const closeResult = await onClose(result);
28
+ shouldCloseThroughContext = closeResult !== false;
27
29
  }
28
30
  }
29
31
  else {
30
32
  if (onCancel) {
31
- closeResult = await onCancel();
33
+ const closeResult = await onCancel();
34
+ shouldCloseThroughContext = closeResult === true;
32
35
  }
33
36
  else if (onClose) {
34
- closeResult = await onClose(result);
37
+ const closeResult = await onClose(result);
38
+ shouldCloseThroughContext = closeResult !== false;
35
39
  }
36
40
  }
37
- if (closeResult !== false) {
41
+ if (shouldCloseThroughContext) {
38
42
  contextCloseDialog?.(result);
39
43
  }
40
44
  };
@@ -59,7 +63,7 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
59
63
  return (jsxRuntime.jsx(jsxRuntime.Fragment, {}));
60
64
  };
61
65
  const footer = (jsxRuntime.jsx("div", { className: "flex flex-wrap justify-content-start gap-3", children: getFooterInterior() }));
62
- return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer, onHide: typeof buttons === 'number' ? () => handleClose(dialogs.DialogResult.Cancelled) : () => { }, visible: visible, style: { width }, 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 }, resizable: resizable, closable: typeof buttons === 'number', children: children }));
63
67
  };
64
68
 
65
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 { 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 resizable?: boolean;\n isValid?: 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 resizable = false, \n isValid,\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 // Use new onConfirm/onCancel callbacks if provided, otherwise fall back to onClose\n let closeResult: boolean | void | Promise<boolean> | Promise<void> = true;\n \n if (result === DialogResult.Ok || result === DialogResult.Yes) {\n if (onConfirm) {\n closeResult = await onConfirm();\n } else if (onClose) {\n closeResult = await onClose(result);\n }\n } else {\n if (onCancel) {\n closeResult = await onCancel();\n } else if (onClose) {\n closeResult = await onClose(result);\n }\n }\n \n if (closeResult !== false) {\n contextCloseDialog?.(result);\n }\n };\n\n const okFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid} autoFocus />\n </>\n );\n\n const okCancelFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid} autoFocus />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\n </>\n );\n\n const yesNoFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n </>\n );\n\n const yesNoCancelFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\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 }}\n resizable={resizable}\n closable={typeof buttons === 'number'}>\n {children}\n </PrimeDialog>\n );\n};\n"],"names":["DialogButtons","useDialogContext","_jsx","DialogResult","_Fragment","Button","_jsxs","PrimeDialog"],"mappings":";;;;;;;AA6BO,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,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,OAAO,GAAG,IAAI,EACd,WAAW,GAAG,QAAQ,EACtB,QAAQ,G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Q,GAAG,MAAM,WAAW,CAACJ,oBAAY,CAAC,SAAS,CAAC,GAAG,MAAK,EAAE,CAAC,EAC1F,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,EAChB,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 } 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 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 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} autoFocus />\n </>\n );\n\n const okCancelFooter = (\n <>\n <Button label={okLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Ok)} disabled={!isDialogValid} autoFocus />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\n </>\n );\n\n const yesNoFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n </>\n );\n\n const yesNoCancelFooter = (\n <>\n <Button label={yesLabel} icon=\"pi pi-check\" onClick={() => handleClose(DialogResult.Yes)} disabled={!isDialogValid} autoFocus />\n <Button label={noLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.No)} />\n <Button label={cancelLabel} icon=\"pi pi-times\" outlined onClick={() => handleClose(DialogResult.Cancelled)} />\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","_Fragment","Button","_jsxs","PrimeDialog"],"mappings":";;;;;;;AA8BO,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,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,EAA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EAAE,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EAAA,QAAA,EACpC,QAAQ,EAAA,CACC;AAEtB;;;;"}
@@ -1,19 +1,11 @@
1
- import { ICommandResult } from '@cratis/arc/commands';
1
+ import { type DialogProps } from '../Dialogs/Dialog';
2
2
  import React from 'react';
3
3
  import { type CommandFormProps } from '@cratis/arc.react/commands';
4
- export interface CommandDialogProps<TCommand extends object, TResponse = object> extends Omit<CommandFormProps<TCommand>, 'children'> {
5
- visible: boolean;
6
- header: string;
7
- confirmLabel?: string;
8
- cancelLabel?: string;
9
- onConfirm: (result: ICommandResult<TResponse>) => void | Promise<void>;
10
- onCancel: () => void;
4
+ export interface CommandDialogProps<TCommand extends object> extends Omit<CommandFormProps<TCommand>, 'children'>, Omit<DialogProps, 'children'> {
11
5
  children?: React.ReactNode;
12
- style?: React.CSSProperties;
13
- width?: string;
14
6
  }
15
7
  export declare const CommandDialog: {
16
- <TCommand extends object = object, TResponse = object>(props: CommandDialogProps<TCommand, TResponse>): import("react/jsx-runtime").JSX.Element;
8
+ <TCommand extends object = object>(props: CommandDialogProps<TCommand>): import("react/jsx-runtime").JSX.Element;
17
9
  Column: {
18
10
  ({ children }: {
19
11
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,CAC3E,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,M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from 'react/jsx-runtime';
2
- import { DialogButtons } from '@cratis/arc.react/dialogs';
2
+ import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
3
3
  import { Dialog } from '../Dialogs/Dialog.js';
4
4
  import React from 'react';
5
5
  import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
6
6
 
7
- const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabel, onConfirm, onCancel, onBeforeExecute, children }) => {
8
- const { setCommandValues, setCommandResult, isValid } = useCommandFormContext();
7
+ const CommandDialogWrapper = ({ title, visible, width, style, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, children }) => {
8
+ const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext();
9
9
  const commandInstance = useCommandInstance();
10
10
  const handleConfirm = async () => {
11
11
  if (onBeforeExecute) {
@@ -13,14 +13,19 @@ const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabe
13
13
  setCommandValues(transformedValues);
14
14
  }
15
15
  const result = await commandInstance.execute();
16
- if (result.isSuccess) {
17
- await onConfirm(result);
18
- return true;
19
- }
20
- else {
16
+ if (!result.isSuccess) {
21
17
  setCommandResult(result);
22
18
  return false;
23
19
  }
20
+ if (onConfirm) {
21
+ const closeResult = await onConfirm();
22
+ return closeResult === true;
23
+ }
24
+ if (onClose) {
25
+ const closeResult = await onClose(DialogResult.Ok);
26
+ return closeResult !== false;
27
+ }
28
+ return true;
24
29
  };
25
30
  const processChildren = (nodes) => {
26
31
  return React.Children.map(nodes, (child) => {
@@ -40,11 +45,12 @@ const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabe
40
45
  });
41
46
  };
42
47
  const processedChildren = processChildren(children);
43
- return (jsx(Dialog, { title: header, visible: visible, width: width, onConfirm: handleConfirm, onCancel: onCancel, buttons: DialogButtons.OkCancel, okLabel: confirmLabel, cancelLabel: cancelLabel, isValid: isValid, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
48
+ const isDialogValid = (isValid !== false) && isCommandFormValid;
49
+ 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, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
44
50
  };
45
51
  const CommandDialogComponent = (props) => {
46
- const { visible, header, confirmLabel = 'Confirm', cancelLabel = 'Cancel', onConfirm, onCancel, children, width = '50vw', ...commandFormProps } = props;
47
- return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { header: header, visible: visible, width: width, confirmLabel: confirmLabel, cancelLabel: cancelLabel, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: commandFormProps.onBeforeExecute, children: children }) }));
52
+ const { title, visible, width, style, resizable, buttons = DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, children, ...commandFormProps } = props;
53
+ 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 }) }));
48
54
  };
49
55
  const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
50
56
  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 } from '@cratis/arc.react/dialogs';\nimport { Dialog } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps\n} from '@cratis/arc.react/commands';\n\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends Omit<CommandFormProps<TCommand>, 'children'> {\n visible: boolean;\n header: string;\n confirmLabel?: string;\n cancelLabel?: string;\n onConfirm: (result: ICommandResult<TResponse>) => void | Promise<void>;\n onCancel: () => void;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n width?: string;\n}\n\nconst CommandDialogWrapper = <TCommand extends object>({\n header,\n visible,\n width,\n confirmLabel,\n cancelLabel,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n header: string;\n visible: boolean;\n width: string;\n confirmLabel: string;\n cancelLabel: string;\n onConfirm: (result: ICommandResult<unknown>) => void | Promise<void>;\n onCancel: () => void;\n onBeforeExecute?: (values: TCommand) => TCommand;\n children: React.ReactNode;\n}) => {\n const { setCommandValues, setCommandResult, isValid } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n const result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\n if (result.isSuccess) {\n await onConfirm(result);\n return true;\n } else {\n setCommandResult(result);\n return false;\n }\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\n return (\n <Dialog\n title={header}\n visible={visible}\n width={width}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n buttons={DialogButtons.OkCancel}\n okLabel={confirmLabel}\n cancelLabel={cancelLabel}\n isValid={isValid}\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, TResponse = object>(props: CommandDialogProps<TCommand, TResponse>) => {\n const {\n visible,\n header,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n onConfirm,\n onCancel,\n children,\n width = '50vw',\n ...commandFormProps\n } = props;\n\n return (\n <CommandForm<TCommand> {...commandFormProps}>\n <CommandDialogWrapper<TCommand>\n header={header}\n visible={visible}\n width={width}\n confirmLabel={confirmLabel}\n cancelLabel={cancelLabel}\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":";;;;;;AA4BA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,MAAM,EACN,OAAO,EACP,KAAK,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,EAWX,KAAI;IACD,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,qBAAqB,EAAY;AACzF,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AAEtD,IAAA,MAAM,aA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"}
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 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\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n\n const result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\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 >\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,EAkBX,KAAI;AACD,IAAA,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,qBAAqB,EAAY;AAC7G,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AAEtD,IAAA,MAAM,aAAa,GAAG,YAAW;QAC7B,IAAI,eAAe,EAAE;AACjB,YAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,eAAe,CAAC;YAC1D,gBAAgB,CAAC,iBAAiB,CAAC;QACvC;AAEA,QAAA,MAAM,MAAM,GAAG,MAAO,eAAkF,CAAC,OAAO,EAAE;AAElH,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACnB,gBAAgB,CAAC,MAAM,CAAC;AACxB,YAAA,OAAO,KAAK;QAChB;QAEA,IAAI,SAAS,EAAE;AACX,YAAA,MAAM,WAAW,GAAG,MAAM,SAAS,EAAE;YACrC,OAAO,WAAW,KAAK,IAAI;QAC/B;QAEA,IAAI,OAAO,EAAE;YACT,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAClD,OAAO,WAAW,KAAK,KAAK;QAChC;AAEA,QAAA,OAAO,IAAI;AACf,IAAA,CAAC;AAED,IAAA,MAAM,eAAe,GA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AG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandDialog.stories.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,wBAAwB,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAGpC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAsM5C,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAElC,CAAC;AA6DF,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AA+DF,eAAO,MAAM,oBAAoB,EAAE,KAElC,CAAC;AA6BF,eAAO,MAAM,gBAAgB,EAAE,KAE9B,CAAC;AA6BF,eAAO,MAAM,kBAAkB,EAAE,KAEhC,CAAC;AA8BF,eAAO,MAAM,cAAc,EAAE,KAE5B,CAAC;AA8BF,eAAO,MAAM,yBAAyB,EAAE,KAEvC,CAAC;AA8CF,eAAO,MAAM,aAAa,EAAE,KAE3B,CAAC;AA4CF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAsFF,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AAmCF,eAAO,MAAM,aAAa,EAAE,KAE3B,CAAC"}
1
+ {"version":3,"file":"CommandDialog.stories.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,OAAO,wBAAwB,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAGpC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AA2L5C,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAElC,CAAC;AA6DF,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AA+DF,eAAO,MAAM,oBAAoB,EAAE,KAElC,CAAC;AA6BF,eAAO,MAAM,gBAAgB,EAAE,KAE9B,CAAC;AA6BF,eAAO,MAAM,kBAAkB,EAAE,KAEhC,CAAC;AA8BF,eAAO,MAAM,cAAc,EAAE,KAE5B,CAAC;AA8BF,eAAO,MAAM,yBAAyB,EAAE,KAEvC,CAAC;AA4CF,eAAO,MAAM,aAAa,EAAE,KAE3B,CAAC;AA4CF,eAAO,MAAM,SAAS,EAAE,KAEvB,CAAC;AAsFF,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AAmCF,eAAO,MAAM,aAAa,EAAE,KAE3B,CAAC"}
@@ -4,6 +4,7 @@ import { CommandDialog } from './CommandDialog';
4
4
  import { Command, CommandResult, CommandValidator } from '@cratis/arc/commands';
5
5
  import { PropertyDescriptor } from '@cratis/arc/reflection';
6
6
  import { InputTextField, NumberField, TextAreaField } from '../CommandForm/fields';
7
+ import { DialogResult, useDialog, useDialogContext } from '@cratis/arc.react/dialogs';
7
8
  import '@cratis/arc/validation';
8
9
  const meta = {
9
10
  title: 'CommandDialog/CommandDialog',
@@ -67,22 +68,6 @@ class UpdateUserCommandWithServer extends Command {
67
68
  return ['name', 'email', 'age'];
68
69
  }
69
70
  }
70
- const DialogWrapper = () => {
71
- const [visible, setVisible] = useState(true);
72
- const [result, setResult] = useState('');
73
- const [validationErrors, setValidationErrors] = useState([]);
74
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => {
75
- setVisible(true);
76
- setValidationErrors([]);
77
- setResult('');
78
- }, children: "Open Dialog" }), validationErrors.length > 0 && (_jsxs("div", { className: "p-3 mt-3 bg-red-100 border-round", children: [_jsx("strong", { children: "Validation Errors:" }), _jsx("ul", { className: "mt-2 mb-0", children: validationErrors.map((error, index) => (_jsx("li", { children: error }, index))) })] })), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Command executed:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Update User Information (with Validation)", confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async (commandResult) => {
79
- setResult(JSON.stringify(commandResult));
80
- setVisible(false);
81
- }, onCancel: () => setVisible(false), onFieldChange: (command) => {
82
- const errors = command.validation?.validate(command) ?? [];
83
- setValidationErrors(errors.map(v => v.message));
84
- }, children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name (min 2 chars)" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age (18-120)" })] })] }));
85
- };
86
71
  const ServerValidationWrapper = () => {
87
72
  const [visible, setVisible] = useState(true);
88
73
  const [result, setResult] = useState('');
@@ -91,8 +76,8 @@ const ServerValidationWrapper = () => {
91
76
  setVisible(true);
92
77
  setValidationErrors([]);
93
78
  setResult('');
94
- }, children: "Open Dialog" }), validationErrors.length > 0 && (_jsxs("div", { className: "p-3 mt-3 bg-red-100 border-round", children: [_jsx("strong", { children: "Validation Errors:" }), _jsx("ul", { className: "mt-2 mb-0", children: validationErrors.map((error, index) => (_jsx("li", { children: error }, index))) })] })), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Command executed:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommandWithServer, visible: visible, header: "Update User Information (with Server Validation)", confirmLabel: "Save", cancelLabel: "Cancel", onConfirm: async (commandResult) => {
95
- setResult(JSON.stringify(commandResult));
79
+ }, children: "Open Dialog" }), validationErrors.length > 0 && (_jsxs("div", { className: "p-3 mt-3 bg-red-100 border-round", children: [_jsx("strong", { children: "Validation Errors:" }), _jsx("ul", { className: "mt-2 mb-0", children: validationErrors.map((error, index) => (_jsx("li", { children: error }, index))) })] })), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Command executed:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommandWithServer, visible: visible, title: "Update User Information (with Server Validation)", okLabel: "Save", cancelLabel: "Cancel", onConfirm: async () => {
80
+ setResult('Command executed successfully');
96
81
  setVisible(false);
97
82
  }, onCancel: () => setVisible(false), onFieldChange: async (command) => {
98
83
  const validationResult = await command.validate();
@@ -104,8 +89,22 @@ const ServerValidationWrapper = () => {
104
89
  }
105
90
  }, children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name (min 2 chars)" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age (18-120)" })] })] }));
106
91
  };
92
+ const AwaitableWithResultWrapper = () => {
93
+ const [result, setResult] = useState('');
94
+ const UpdateUserDialog = () => {
95
+ const { closeDialog } = useDialogContext();
96
+ return (_jsxs(CommandDialog, { command: UpdateUserCommand, title: "Update User Information (awaitable result)", okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => closeDialog(DialogResult.Ok), onCancel: () => closeDialog(DialogResult.Cancelled), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name (min 2 chars)" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age (18-120)" })] }));
97
+ };
98
+ const [UpdateUserDialogComponent, showUpdateUserDialog] = useDialog(UpdateUserDialog);
99
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: async () => {
100
+ const [dialogResult, commandResult] = await showUpdateUserDialog();
101
+ if (dialogResult === DialogResult.Ok && commandResult) {
102
+ setResult(JSON.stringify(commandResult));
103
+ }
104
+ }, children: "Open Dialog" }), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Command executed:" }), " ", result] })), _jsx(UpdateUserDialogComponent, {})] }));
105
+ };
107
106
  export const Default = {
108
- render: () => _jsx(DialogWrapper, {}),
107
+ render: () => _jsx(AwaitableWithResultWrapper, {}),
109
108
  };
110
109
  export const WithServerValidation = {
111
110
  render: () => _jsx(ServerValidationWrapper, {}),
@@ -123,7 +122,7 @@ const EditUserWrapper = () => {
123
122
  setResult('');
124
123
  setVisible(true);
125
124
  };
126
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("div", { style: { display: 'flex', gap: '0.5rem', marginBottom: '1rem' }, children: users.map(user => (_jsxs("button", { className: "p-button p-component", onClick: () => handleEdit(user), children: ["Edit ", user.name] }, user.email))) }), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Saved:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommand, initialValues: selectedUser, visible: visible, header: `Edit User: ${selectedUser?.name ?? ''}`, confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => {
125
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("div", { style: { display: 'flex', gap: '0.5rem', marginBottom: '1rem' }, children: users.map(user => (_jsxs("button", { className: "p-button p-component", onClick: () => handleEdit(user), children: ["Edit ", user.name] }, user.email))) }), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Saved:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommand, initialValues: selectedUser, visible: visible, title: `Edit User: ${selectedUser?.name ?? ''}`, okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => {
127
126
  setResult(`User "${selectedUser?.name}" updated successfully`);
128
127
  setVisible(false);
129
128
  }, onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age" })] }, selectedUser?.email ?? 'empty')] }));
@@ -137,7 +136,7 @@ const CustomValidationWrapper = () => {
137
136
  return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => {
138
137
  setResult('');
139
138
  setVisible(true);
140
- }, children: "Open Dialog" }), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Saved:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Add User (with Custom Validation)", confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => {
139
+ }, children: "Open Dialog" }), result && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Saved:" }), " ", result] })), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Add User (with Custom Validation)", okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => {
141
140
  setResult('User added successfully');
142
141
  setVisible(false);
143
142
  }, onCancel: () => setVisible(false), onFieldValidate: (_command, fieldName, _oldValue, newValue) => {
@@ -164,28 +163,28 @@ export const WithCustomValidation = {
164
163
  };
165
164
  const ValidationOnBlurWrapper = () => {
166
165
  const [visible, setVisible] = useState(true);
167
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Validation on Blur", confirmLabel: "Save", cancelLabel: "Cancel", validateOn: "blur", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Click away to validate" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Click away to validate", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Click away to validate" })] })] }));
166
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Validation on Blur", okLabel: "Save", cancelLabel: "Cancel", validateOn: "blur", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Click away to validate" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Click away to validate", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Click away to validate" })] })] }));
168
167
  };
169
168
  export const ValidationOnBlur = {
170
169
  render: () => _jsx(ValidationOnBlurWrapper, {}),
171
170
  };
172
171
  const ValidationOnChangeWrapper = () => {
173
172
  const [visible, setVisible] = useState(true);
174
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Validation on Change", confirmLabel: "Save", cancelLabel: "Cancel", validateOn: "change", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Errors appear while typing" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Errors appear while typing", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Errors appear while typing" })] })] }));
173
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Validation on Change", okLabel: "Save", cancelLabel: "Cancel", validateOn: "change", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Errors appear while typing" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Errors appear while typing", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Errors appear while typing" })] })] }));
175
174
  };
176
175
  export const ValidationOnChange = {
177
176
  render: () => _jsx(ValidationOnChangeWrapper, {}),
178
177
  };
179
178
  const ValidateOnInitWrapper = () => {
180
179
  const [visible, setVisible] = useState(true);
181
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Validate on Initialization", confirmLabel: "Save", cancelLabel: "Cancel", validateOnInit: true, autoServerValidate: false, initialValues: { name: 'A', email: 'invalid', age: 10 }, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Errors shown immediately" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Errors shown immediately", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Errors shown immediately" })] })] }));
180
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Validate on Initialization", okLabel: "Save", cancelLabel: "Cancel", validateOnInit: true, autoServerValidate: false, initialValues: { name: 'A', email: 'invalid', age: 10 }, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Errors shown immediately" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Errors shown immediately", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Errors shown immediately" })] })] }));
182
181
  };
183
182
  export const ValidateOnInit = {
184
183
  render: () => _jsx(ValidateOnInitWrapper, {}),
185
184
  };
186
185
  const ValidateAllFieldsWrapper = () => {
187
186
  const [visible, setVisible] = useState(true);
188
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Validate All Fields on Change", confirmLabel: "Save", cancelLabel: "Cancel", validateOn: "blur", validateAllFieldsOnChange: true, autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Blur one field \u2014 all validate" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Blur one field \u2014 all validate", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Blur one field \u2014 all validate" })] })] }));
187
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Validate All Fields on Change", okLabel: "Save", cancelLabel: "Cancel", validateOn: "blur", validateAllFieldsOnChange: true, autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Blur one field \u2014 all validate" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Blur one field \u2014 all validate", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Blur one field \u2014 all validate" })] })] }));
189
188
  };
190
189
  export const ValidateAllFieldsOnChange = {
191
190
  render: () => _jsx(ValidateAllFieldsWrapper, {}),
@@ -193,21 +192,19 @@ export const ValidateAllFieldsOnChange = {
193
192
  const BeforeExecuteWrapper = () => {
194
193
  const [visible, setVisible] = useState(true);
195
194
  const [preprocessedData, setPreprocessedData] = useState('');
196
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => { setVisible(true); setPreprocessedData(''); }, children: "Open Dialog" }), preprocessedData && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Preprocessed before submit:" }), _jsx("pre", { style: { marginTop: '0.5rem', fontSize: '0.875rem' }, children: preprocessedData })] })), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Before Execute Callback", confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, initialValues: { name: '', email: '', age: 18 }, onBeforeExecute: (command) => {
195
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => { setVisible(true); setPreprocessedData(''); }, children: "Open Dialog" }), preprocessedData && (_jsxs("div", { className: "p-3 mt-3 bg-green-100 border-round", children: [_jsx("strong", { children: "Preprocessed before submit:" }), _jsx("pre", { style: { marginTop: '0.5rem', fontSize: '0.875rem' }, children: preprocessedData })] })), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Before Execute Callback", okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, initialValues: { name: '', email: '', age: 18 }, onBeforeExecute: (command) => {
197
196
  command.name = command.name.trim().replace(/\s+/g, ' ');
198
197
  command.email = command.email.toLowerCase().trim();
198
+ setPreprocessedData(JSON.stringify(command, null, 2));
199
199
  return command;
200
- }, onConfirm: async (result) => {
201
- setPreprocessedData(JSON.stringify(result, null, 2));
202
- setVisible(false);
203
- }, onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: 'Try " Extra Spaces "' }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Try UPPERCASE@EMAIL.COM", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age (18-120)" })] })] }));
200
+ }, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: 'Try " Extra Spaces "' }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Try UPPERCASE@EMAIL.COM", type: "email" }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age (18-120)" })] })] }));
204
201
  };
205
202
  export const BeforeExecute = {
206
203
  render: () => _jsx(BeforeExecuteWrapper, {}),
207
204
  };
208
205
  const WithIconsWrapper = () => {
209
206
  const [visible, setVisible] = useState(true);
210
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, header: "Fields with Icons", confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83D\uDC64" }) }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83D\uDCE7" }) }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83C\uDF82" }) })] })] }));
207
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateUserCommand, visible: visible, title: "Fields with Icons", okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx(InputTextField, { value: (c) => c.name, title: "Name", placeholder: "Enter name", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83D\uDC64" }) }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83D\uDCE7" }) }), _jsx(NumberField, { value: (c) => c.age, title: "Age", placeholder: "Enter age", icon: _jsx("span", { style: { fontSize: '1.25rem' }, children: "\uD83C\uDF82" }) })] })] }));
211
208
  };
212
209
  export const WithIcons = {
213
210
  render: () => _jsx(WithIconsWrapper, {}),
@@ -256,14 +253,14 @@ class UpdateProfileCommand extends Command {
256
253
  }
257
254
  const MultiColumnWrapper = () => {
258
255
  const [visible, setVisible] = useState(true);
259
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateProfileCommand, visible: visible, header: "Edit Profile", confirmLabel: "Save", cancelLabel: "Cancel", width: "70vw", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsxs("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1.5rem' }, children: [_jsxs(CommandDialog.Column, { children: [_jsx(InputTextField, { value: (c) => c.firstName, title: "First Name", placeholder: "Enter first name" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" })] }), _jsxs(CommandDialog.Column, { children: [_jsx(InputTextField, { value: (c) => c.lastName, title: "Last Name", placeholder: "Enter last name" }), _jsx(InputTextField, { value: (c) => c.phone, title: "Phone", placeholder: "Enter phone number" })] })] }), _jsx(TextAreaField, { value: (c) => c.bio, title: "Bio", placeholder: "Tell us about yourself", rows: 3 })] })] }));
256
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateProfileCommand, visible: visible, title: "Edit Profile", okLabel: "Save", cancelLabel: "Cancel", width: "70vw", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsxs("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '1.5rem' }, children: [_jsxs(CommandDialog.Column, { children: [_jsx(InputTextField, { value: (c) => c.firstName, title: "First Name", placeholder: "Enter first name" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" })] }), _jsxs(CommandDialog.Column, { children: [_jsx(InputTextField, { value: (c) => c.lastName, title: "Last Name", placeholder: "Enter last name" }), _jsx(InputTextField, { value: (c) => c.phone, title: "Phone", placeholder: "Enter phone number" })] })] }), _jsx(TextAreaField, { value: (c) => c.bio, title: "Bio", placeholder: "Tell us about yourself", rows: 3 })] })] }));
260
257
  };
261
258
  export const MultiColumnLayout = {
262
259
  render: () => _jsx(MultiColumnWrapper, {}),
263
260
  };
264
261
  const MixedChildrenWrapper = () => {
265
262
  const [visible, setVisible] = useState(true);
266
- return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateProfileCommand, visible: visible, header: "Edit Profile (Mixed Children)", confirmLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx("h3", { style: { marginTop: 0, marginBottom: '0.75rem' }, children: "Personal Information" }), _jsx(InputTextField, { value: (c) => c.firstName, title: "First Name", placeholder: "Enter first name" }), _jsx(InputTextField, { value: (c) => c.lastName, title: "Last Name", placeholder: "Enter last name" }), _jsx("h3", { style: { marginTop: '1rem', marginBottom: '0.75rem' }, children: "Contact Details" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(InputTextField, { value: (c) => c.phone, title: "Phone", placeholder: "Enter phone number" }), _jsx("h3", { style: { marginTop: '1rem', marginBottom: '0.75rem' }, children: "About You" }), _jsx(TextAreaField, { value: (c) => c.bio, title: "Bio", placeholder: "Tell us about yourself (min 10 chars)", rows: 3 })] })] }));
263
+ return (_jsxs("div", { className: "storybook-wrapper", children: [_jsx("button", { className: "p-button p-component mb-3", onClick: () => setVisible(true), children: "Open Dialog" }), _jsxs(CommandDialog, { command: UpdateProfileCommand, visible: visible, title: "Edit Profile (Mixed Children)", okLabel: "Save", cancelLabel: "Cancel", autoServerValidate: false, onConfirm: async () => setVisible(false), onCancel: () => setVisible(false), children: [_jsx("h3", { style: { marginTop: 0, marginBottom: '0.75rem' }, children: "Personal Information" }), _jsx(InputTextField, { value: (c) => c.firstName, title: "First Name", placeholder: "Enter first name" }), _jsx(InputTextField, { value: (c) => c.lastName, title: "Last Name", placeholder: "Enter last name" }), _jsx("h3", { style: { marginTop: '1rem', marginBottom: '0.75rem' }, children: "Contact Details" }), _jsx(InputTextField, { value: (c) => c.email, title: "Email", placeholder: "Enter email", type: "email" }), _jsx(InputTextField, { value: (c) => c.phone, title: "Phone", placeholder: "Enter phone number" }), _jsx("h3", { style: { marginTop: '1rem', marginBottom: '0.75rem' }, children: "About You" }), _jsx(TextAreaField, { value: (c) => c.bio, title: "Bio", placeholder: "Tell us about yourself (min 10 chars)", rows: 3 })] })] }));
267
264
  };
268
265
  export const MixedChildren = {
269
266
  render: () => _jsx(MixedChildrenWrapper, {}),