@cratis/components 2.6.2 → 2.7.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 +30 -4
- package/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/CommandDialog/CommandStepper.js +23 -15
- package/dist/cjs/CommandDialog/CommandStepper.js.map +1 -1
- package/dist/cjs/CommandDialog/StepperCommandDialog.js +17 -8
- package/dist/cjs/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/cjs/CommandDialog/stepChildren.js +31 -0
- package/dist/cjs/CommandDialog/stepChildren.js.map +1 -0
- package/dist/cjs/DataPage/DataPage.js +54 -10
- package/dist/cjs/DataPage/DataPage.js.map +1 -1
- package/dist/cjs/DataPage/DataPageLayout.js +34 -0
- package/dist/cjs/DataPage/DataPageLayout.js.map +1 -0
- package/dist/cjs/Dialogs/BusyIndicatorDialog.js +6 -2
- package/dist/cjs/Dialogs/BusyIndicatorDialog.js.map +1 -1
- package/dist/cjs/Dialogs/Dialog.js +61 -7
- package/dist/cjs/Dialogs/Dialog.js.map +1 -1
- package/dist/cjs/Dialogs/DialogInitialFocus.js +49 -0
- package/dist/cjs/Dialogs/DialogInitialFocus.js.map +1 -0
- package/dist/cjs/Dialogs/index.js +5 -0
- package/dist/cjs/Dialogs/index.js.map +1 -1
- package/dist/cjs/tailwind-utilities.css +3 -0
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +30 -4
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepper.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandStepper.js +23 -15
- package/dist/esm/CommandDialog/CommandStepper.js.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.js +18 -9
- package/dist/esm/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/stepChildren.d.ts +3 -0
- package/dist/esm/CommandDialog/stepChildren.d.ts.map +1 -0
- package/dist/esm/CommandDialog/stepChildren.js +29 -0
- package/dist/esm/CommandDialog/stepChildren.js.map +1 -0
- package/dist/esm/DataPage/DataPage.d.ts +1 -0
- package/dist/esm/DataPage/DataPage.d.ts.map +1 -1
- package/dist/esm/DataPage/DataPage.js +54 -10
- package/dist/esm/DataPage/DataPage.js.map +1 -1
- package/dist/esm/DataPage/DataPageLayout.d.ts +6 -0
- package/dist/esm/DataPage/DataPageLayout.d.ts.map +1 -0
- package/dist/esm/DataPage/DataPageLayout.js +32 -0
- package/dist/esm/DataPage/DataPageLayout.js.map +1 -0
- package/dist/esm/Dialogs/BusyIndicatorDialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/BusyIndicatorDialog.js +6 -2
- package/dist/esm/Dialogs/BusyIndicatorDialog.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.d.ts +3 -1
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js +62 -8
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/Dialogs/DialogInitialFocus.d.ts +6 -0
- package/dist/esm/Dialogs/DialogInitialFocus.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogInitialFocus.js +49 -0
- package/dist/esm/Dialogs/DialogInitialFocus.js.map +1 -0
- package/dist/esm/Dialogs/index.d.ts +1 -0
- package/dist/esm/Dialogs/index.d.ts.map +1 -1
- package/dist/esm/Dialogs/index.js +1 -0
- package/dist/esm/Dialogs/index.js.map +1 -1
- package/dist/esm/tailwind-utilities.css +3 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/vite.config.d.ts.map +1 -1
- package/dist/esm/vite.config.js +1 -0
- package/dist/esm/vite.config.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var dialog = require('primereact/dialog');
|
|
5
5
|
var button = require('primereact/button');
|
|
6
6
|
var dialogs = require('@cratis/arc.react/dialogs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var DialogInitialFocus = require('./DialogInitialFocus.js');
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Cratis wrapper around PrimeReact's `Dialog` that adds the surface every Arc
|
|
@@ -25,6 +27,36 @@ var dialogs = require('@cratis/arc.react/dialogs');
|
|
|
25
27
|
* - **Validity gate** (`isValid`) that disables the confirm button without
|
|
26
28
|
* disabling the cancel button. Used by command-executing wrappers to
|
|
27
29
|
* block submission while form validation fails.
|
|
30
|
+
* - **Initial focus** (`initialFocus`) choosing which element inside the
|
|
31
|
+
* dialog the keyboard lands on when it opens.
|
|
32
|
+
*
|
|
33
|
+
* ## Initial focus
|
|
34
|
+
*
|
|
35
|
+
* By default the confirm button is focused when the dialog opens, so the
|
|
36
|
+
* common "read it, press Enter" flow costs one keystroke. That default also
|
|
37
|
+
* *arms* the confirm button: browsers fire `click` from the `keydown` of
|
|
38
|
+
* `Enter`, so the key still held down from opening the dialog — or the very
|
|
39
|
+
* ordinary habit of pressing `Enter` twice — confirms it immediately.
|
|
40
|
+
*
|
|
41
|
+
* A dialog whose confirm action is destructive **and** needs no input to
|
|
42
|
+
* become valid gets no protection from `isValid`, because there is nothing
|
|
43
|
+
* to fill in. Give those dialogs an explicit
|
|
44
|
+
* {@link DialogInitialFocus} instead:
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <Dialog title="Delete personal data?"
|
|
48
|
+
* buttons={DialogButtons.YesNo}
|
|
49
|
+
* initialFocus={DialogInitialFocus.Cancel}
|
|
50
|
+
* onConfirm={...} onCancel={...}>
|
|
51
|
+
* This permanently removes the person and every record about them.
|
|
52
|
+
* </Dialog>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* `Cancel` focuses the dismissing button (`Cancel`, or `No` when the set has
|
|
56
|
+
* no `Cancel`); `Content` focuses the dialog's title so nothing at all is
|
|
57
|
+
* armed and screen readers announce the dialog from the top. Both keep the
|
|
58
|
+
* footer, the close (X), `Escape`, and every callback intact — unlike
|
|
59
|
+
* replacing `buttons` with a custom node.
|
|
28
60
|
*
|
|
29
61
|
* ## Arc dialog host integration
|
|
30
62
|
*
|
|
@@ -77,7 +109,7 @@ var dialogs = require('@cratis/arc.react/dialogs');
|
|
|
77
109
|
*
|
|
78
110
|
* @param props - {@link DialogProps}.
|
|
79
111
|
*/
|
|
80
|
-
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', className, pt, ptOptions, unstyled }) => {
|
|
112
|
+
const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons = dialogs.DialogButtons.OkCancel, initialFocus = DialogInitialFocus.DialogInitialFocus.Confirm, children, width = '450px', style, contentStyle, resizable = false, isValid, isBusy = false, okLabel = 'Ok', cancelLabel = 'Cancel', yesLabel = 'Yes', noLabel = 'No', className, pt, ptOptions, unstyled }) => {
|
|
81
113
|
// useDialogContext() is called unconditionally on every render — the try/catch only suppresses
|
|
82
114
|
// the exception when Dialog is used standalone (outside a provider). React's Rules of Hooks
|
|
83
115
|
// are not violated because the hook is always called; the try/catch never skips the call.
|
|
@@ -90,7 +122,29 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
|
|
|
90
122
|
contextCloseDialog = undefined;
|
|
91
123
|
}
|
|
92
124
|
const isDialogValid = isValid !== false;
|
|
93
|
-
|
|
125
|
+
// A dismissing button only exists for the predefined sets that have one — Cancel for
|
|
126
|
+
// OkCancel / YesNoCancel, No for YesNo. Asking for Cancel focus without one (DialogButtons.Ok,
|
|
127
|
+
// a custom footer node, or no footer) degrades to focusing the title rather than silently
|
|
128
|
+
// leaving focus on document.body outside the modal.
|
|
129
|
+
const hasDismissingButton = typeof buttons === 'number' && buttons !== dialogs.DialogButtons.Ok;
|
|
130
|
+
const resolvedInitialFocus = (initialFocus === DialogInitialFocus.DialogInitialFocus.Cancel && !hasDismissingButton)
|
|
131
|
+
? DialogInitialFocus.DialogInitialFocus.Content
|
|
132
|
+
: initialFocus;
|
|
133
|
+
const focusesConfirmButton = resolvedInitialFocus === DialogInitialFocus.DialogInitialFocus.Confirm;
|
|
134
|
+
const focusesDismissingButton = resolvedInitialFocus === DialogInitialFocus.DialogInitialFocus.Cancel;
|
|
135
|
+
const focusesTitle = resolvedInitialFocus === DialogInitialFocus.DialogInitialFocus.Content;
|
|
136
|
+
// PrimeReact's focus trap parks focus on the first focusable element inside the dialog while
|
|
137
|
+
// it transitions in, and its own onShow focus only fires when nothing in the dialog has focus.
|
|
138
|
+
// Moving focus to the title from onShow therefore runs last and wins, without having to fight
|
|
139
|
+
// the trap or turn focusOnShow off (which would leave focus outside the modal for the duration
|
|
140
|
+
// of the transition).
|
|
141
|
+
const titleRef = React.useRef(null);
|
|
142
|
+
const handleShow = () => {
|
|
143
|
+
if (focusesTitle) {
|
|
144
|
+
titleRef.current?.focus({ preventScroll: true });
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const headerElement = (jsxRuntime.jsx("div", { className: "inline-flex items-center justify-center gap-2", children: jsxRuntime.jsx("span", { ref: titleRef, tabIndex: focusesTitle ? -1 : undefined, className: "font-bold whitespace-nowrap", children: title }) }));
|
|
94
148
|
const handleClose = async (result) => {
|
|
95
149
|
let shouldCloseThroughContext = true;
|
|
96
150
|
if (result === dialogs.DialogResult.Ok || result === dialogs.DialogResult.Yes) {
|
|
@@ -117,10 +171,10 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
|
|
|
117
171
|
contextCloseDialog?.(result);
|
|
118
172
|
}
|
|
119
173
|
};
|
|
120
|
-
const okFooter = (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(button.Button, { label: okLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Ok), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus:
|
|
121
|
-
const okCancelFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: okLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Ok), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus:
|
|
122
|
-
const yesNoFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: yesLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Yes), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus:
|
|
123
|
-
const yesNoCancelFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: yesLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Yes), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus:
|
|
174
|
+
const okFooter = (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(button.Button, { label: okLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Ok), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus: focusesConfirmButton }) }));
|
|
175
|
+
const okCancelFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: okLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Ok), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus: focusesConfirmButton }), jsxRuntime.jsx(button.Button, { label: cancelLabel, icon: "pi pi-times", outlined: true, onClick: () => handleClose(dialogs.DialogResult.Cancelled), disabled: isBusy, autoFocus: focusesDismissingButton })] }));
|
|
176
|
+
const yesNoFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: yesLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Yes), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus: focusesConfirmButton }), jsxRuntime.jsx(button.Button, { label: noLabel, icon: "pi pi-times", outlined: true, onClick: () => handleClose(dialogs.DialogResult.No), disabled: isBusy, autoFocus: focusesDismissingButton })] }));
|
|
177
|
+
const yesNoCancelFooter = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(button.Button, { label: yesLabel, icon: "pi pi-check", onClick: () => handleClose(dialogs.DialogResult.Yes), disabled: !isDialogValid || isBusy, loading: isBusy, autoFocus: focusesConfirmButton }), jsxRuntime.jsx(button.Button, { label: noLabel, icon: "pi pi-times", outlined: true, onClick: () => handleClose(dialogs.DialogResult.No), disabled: isBusy }), jsxRuntime.jsx(button.Button, { label: cancelLabel, icon: "pi pi-times", outlined: true, onClick: () => handleClose(dialogs.DialogResult.Cancelled), disabled: isBusy, autoFocus: focusesDismissingButton })] }));
|
|
124
178
|
const getFooterInterior = () => {
|
|
125
179
|
// If buttons is a ReactNode (custom buttons), use it directly
|
|
126
180
|
if (typeof buttons !== 'number') {
|
|
@@ -142,7 +196,7 @@ const Dialog = ({ title, visible = true, onClose, onConfirm, onCancel, buttons =
|
|
|
142
196
|
const footer = (jsxRuntime.jsx("div", { className: "flex flex-wrap justify-start gap-3", children: getFooterInterior() }));
|
|
143
197
|
return (jsxRuntime.jsx(dialog.Dialog, { header: headerElement, modal: true, footer: footer,
|
|
144
198
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
145
|
-
onHide: typeof buttons === 'number' ? () => handleClose(dialogs.DialogResult.Cancelled) : () => { }, visible: visible, style: { width, ...style }, contentStyle: contentStyle, resizable: resizable, closable: typeof buttons === 'number', className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }));
|
|
199
|
+
onHide: typeof buttons === 'number' ? () => handleClose(dialogs.DialogResult.Cancelled) : () => { }, onShow: handleShow, visible: visible, style: { width, ...style }, contentStyle: contentStyle, resizable: resizable, closable: typeof buttons === 'number', className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }));
|
|
146
200
|
};
|
|
147
201
|
|
|
148
202
|
exports.Dialog = Dialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":[null],"names":["DialogButtons","useDialogContext","_jsx","DialogResult","
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":[null],"names":["DialogButtons","DialogInitialFocus","useDialogContext","useRef","_jsx","DialogResult","_Fragment","Button","_jsxs","PrimeDialog"],"mappings":";;;;;;;;;AAwJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGG;AACI,MAAM,MAAM,GAAG,CAAC,EACnB,KAAK,EACL,OAAO,GAAG,IAAI,EACd,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,GAAGA,qBAAa,CAAC,QAAQ,EAChC,YAAY,GAAGC,qCAAkB,CAAC,OAAO,EACzC,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,EACd,SAAS,EACT,EAAE,EACF,SAAS,EACT,QAAQ,EACE,KAAI;;;;AAId,IAAA,IAAI,kBAAgE;AACpE,IAAA,IAAI;AACA,QAAA,MAAM,OAAO,GAAGC,wBAAgB,EAAE;AAClC,QAAA,kBAAkB,GAAG,OAAO,EAAE,WAAW;IAC7C;AAAE,IAAA,MAAM;QACJ,kBAAkB,GAAG,SAAS;IAClC;AAEA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AY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,OAAO,OAAO,KAAK,QAAQ,EACrC,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAAA,QAAA,EACjB,QAAQ,EAAA,CACC;AAEtB;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/**
|
|
6
|
+
* Defines where keyboard focus lands when a dialog becomes visible.
|
|
7
|
+
*
|
|
8
|
+
* A modal must move focus into itself when it opens — leaving focus on
|
|
9
|
+
* `document.body` strands keyboard and screen-reader users outside the
|
|
10
|
+
* content they were just interrupted with. Every member of this enum
|
|
11
|
+
* therefore names a real element inside the dialog; there is deliberately
|
|
12
|
+
* no "focus nothing" member.
|
|
13
|
+
*/
|
|
14
|
+
exports.DialogInitialFocus = void 0;
|
|
15
|
+
(function (DialogInitialFocus) {
|
|
16
|
+
/**
|
|
17
|
+
* Focus the confirming button (`Ok` / `Yes`). This is the default and
|
|
18
|
+
* the fastest path for a dialog whose expected answer is "go ahead".
|
|
19
|
+
*
|
|
20
|
+
* ⚠️ It also *arms* that button: a browser fires `click` on a native
|
|
21
|
+
* button from the `keydown` of `Enter` or `Space`, so a held key or a
|
|
22
|
+
* second press of the key that opened the dialog confirms it. For a
|
|
23
|
+
* destructive action that needs no input to become valid, prefer
|
|
24
|
+
* {@link DialogInitialFocus.Cancel} or {@link DialogInitialFocus.Content}.
|
|
25
|
+
*/
|
|
26
|
+
DialogInitialFocus[DialogInitialFocus["Confirm"] = 1] = "Confirm";
|
|
27
|
+
/**
|
|
28
|
+
* Focus the dismissing button — `Cancel` when the button set has one,
|
|
29
|
+
* otherwise `No`. This is the least destructive action, which is what
|
|
30
|
+
* the WAI-ARIA authoring practices recommend focusing for a dialog that
|
|
31
|
+
* confirms something irreversible.
|
|
32
|
+
*
|
|
33
|
+
* Falls back to {@link DialogInitialFocus.Content} when the button set
|
|
34
|
+
* has no dismissing button (`DialogButtons.Ok`), when the footer is a
|
|
35
|
+
* custom `ReactNode`, or when there is no footer at all.
|
|
36
|
+
*/
|
|
37
|
+
DialogInitialFocus[DialogInitialFocus["Cancel"] = 2] = "Cancel";
|
|
38
|
+
/**
|
|
39
|
+
* Focus the dialog's own title instead of any button, so nothing is
|
|
40
|
+
* armed. Screen readers announce the dialog and its title, and the
|
|
41
|
+
* first `Tab` walks the content from the top.
|
|
42
|
+
*
|
|
43
|
+
* This is the right choice for a dialog that should be *read* before it
|
|
44
|
+
* is answered, and the only sensible choice for a dialog with no footer
|
|
45
|
+
* buttons at all.
|
|
46
|
+
*/
|
|
47
|
+
DialogInitialFocus[DialogInitialFocus["Content"] = 3] = "Content";
|
|
48
|
+
})(exports.DialogInitialFocus || (exports.DialogInitialFocus = {}));
|
|
49
|
+
//# sourceMappingURL=DialogInitialFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogInitialFocus.js","sources":["../../../Dialogs/DialogInitialFocus.ts"],"sourcesContent":[null],"names":["DialogInitialFocus"],"mappings":";;AAAA;AACA;AAEA;;;;;;;;AAQG;AACSA;AAAZ,CAAA,UAAY,kBAAkB,EAAA;AAE1B;;;;;;;;;AASG;AACH,IAAA,kBAAA,CAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AAEX;;;;;;;;;AASG;AACH,IAAA,kBAAA,CAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAU;AAEV;;;;;;;;AAQG;AACH,IAAA,kBAAA,CAAA,kBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACf,CAAC,EApCWA,0BAAkB,KAAlBA,0BAAkB,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var BusyIndicatorDialog = require('./BusyIndicatorDialog.js');
|
|
4
4
|
var ConfirmationDialog = require('./ConfirmationDialog.js');
|
|
5
5
|
var Dialog = require('./Dialog.js');
|
|
6
|
+
var DialogInitialFocus = require('./DialogInitialFocus.js');
|
|
6
7
|
|
|
7
8
|
// Copyright (c) Cratis. All rights reserved.
|
|
8
9
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -10,4 +11,8 @@ var Dialog = require('./Dialog.js');
|
|
|
10
11
|
exports.BusyIndicatorDialog = BusyIndicatorDialog.BusyIndicatorDialog;
|
|
11
12
|
exports.ConfirmationDialog = ConfirmationDialog.ConfirmationDialog;
|
|
12
13
|
exports.Dialog = Dialog.Dialog;
|
|
14
|
+
Object.defineProperty(exports, "DialogInitialFocus", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return DialogInitialFocus.DialogInitialFocus; }
|
|
17
|
+
});
|
|
13
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../Dialogs/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../Dialogs/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;AACA;;;;;;;;;;"}
|
|
@@ -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;AACpC,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAWtF,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,CAC3E,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC/E,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IAcjC,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAOlD,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;AACpC,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAWtF,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,CAC3E,SAAQ,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC/E,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC;IAcjC,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAOlD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAiVD,eAAO,MAAM,aAAa;KApEM,QAAQ,SAAS,MAAM,WAAW,SAAS,kBAAkB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC;;uBA6DlF;YAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;SAAE;;;CAO5B,CAAC"}
|
|
@@ -5,7 +5,7 @@ import React, { useState } from 'react';
|
|
|
5
5
|
import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
6
6
|
import { applyBeforeExecute } from './applyBeforeExecute.js';
|
|
7
7
|
|
|
8
|
-
const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resizable, buttons, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onSuccess, onValidationFailure, onFailed, onBeforeExecute, className, pt, ptOptions, unstyled, children }) => {
|
|
8
|
+
const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resizable, buttons, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onSuccess, onValidationFailure, onFailed, onBeforeExecute, className, pt, ptOptions, unstyled, children }) => {
|
|
9
9
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid } = useCommandFormContext();
|
|
10
10
|
const commandInstance = useCommandInstance();
|
|
11
11
|
const [isBusy, setIsBusy] = useState(false);
|
|
@@ -62,7 +62,7 @@ const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resi
|
|
|
62
62
|
};
|
|
63
63
|
const processedChildren = processChildren(children);
|
|
64
64
|
const isDialogValid = (isValid !== false) && isCommandFormValid;
|
|
65
|
-
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, className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
65
|
+
return (jsx(Dialog, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, initialFocus: initialFocus, onClose: onClose, onConfirm: handleConfirm, onCancel: onCancel, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isDialogValid, isBusy: isBusy, className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound
|
|
@@ -98,6 +98,32 @@ const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resi
|
|
|
98
98
|
* Throughout, the dialog is in the `isBusy` state — every action button is
|
|
99
99
|
* disabled and the confirm button shows a spinner.
|
|
100
100
|
*
|
|
101
|
+
* ## Destructive commands and initial focus
|
|
102
|
+
*
|
|
103
|
+
* The confirm button is focused when the dialog opens, and a focused native
|
|
104
|
+
* button fires `click` from the `keydown` of `Enter`. A command whose form
|
|
105
|
+
* has required fields is protected from a held or double-tapped `Enter` for
|
|
106
|
+
* free, because `isCommandFormValid` keeps confirm disabled until something
|
|
107
|
+
* is filled in. A command that takes **no** input — the typical "delete
|
|
108
|
+
* this, permanently" command — has no such gate, so its confirm button is
|
|
109
|
+
* armed the instant the dialog appears.
|
|
110
|
+
*
|
|
111
|
+
* Pass `initialFocus` (forwarded straight to {@link Dialog}) for those:
|
|
112
|
+
*
|
|
113
|
+
* ```tsx
|
|
114
|
+
* <CommandDialog<DeletePerson>
|
|
115
|
+
* command={DeletePerson}
|
|
116
|
+
* title="Delete personal data?"
|
|
117
|
+
* okLabel="Delete"
|
|
118
|
+
* initialFocus={DialogInitialFocus.Cancel}
|
|
119
|
+
* onSuccess={() => closeDialog(DialogResult.Ok)}>
|
|
120
|
+
* This cannot be undone.
|
|
121
|
+
* </CommandDialog>
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* Everything else — the footer, the close (X), `Escape`, and the confirm
|
|
125
|
+
* wiring that runs the command — is untouched.
|
|
126
|
+
*
|
|
101
127
|
* ## Field binding
|
|
102
128
|
*
|
|
103
129
|
* Children that are `CommandFormField` instances (`InputTextField`,
|
|
@@ -155,8 +181,8 @@ const CommandDialogWrapper = ({ title, visible, width, style, contentStyle, resi
|
|
|
155
181
|
* @param props - {@link CommandDialogProps}.
|
|
156
182
|
*/
|
|
157
183
|
const CommandDialogComponent = (props) => {
|
|
158
|
-
const { title, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
|
|
159
|
-
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, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onBeforeExecute: onBeforeExecute, className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
|
|
184
|
+
const { title, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
|
|
185
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, buttons: buttons, initialFocus: initialFocus, okLabel: okLabel, cancelLabel: cancelLabel, yesLabel: yesLabel, noLabel: noLabel, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onBeforeExecute: onBeforeExecute, className: className, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
|
|
160
186
|
};
|
|
161
187
|
const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
|
|
162
188
|
CommandDialogColumnWrapper.displayName = 'CommandFormColumn';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAmDA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,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,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,eAAe,EACf,SAAS,EACT,EAAE,EACF,SAAS,EACT,QAAQ,EACR,QAAQ,
|
|
1
|
+
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;AAmDA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,YAAY,EACZ,SAAS,EACT,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,eAAe,EACf,SAAS,EACT,EAAE,EACF,SAAS,EACT,QAAQ,EACR,QAAQ,EA2BX,KAAI;AACD,IAAA,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,qBAAqB,EAAY;AAC7G,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;IACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAE3C,IAAA,MAAM,aAAa,GAAG,YAAW;QAC7B,IAAI,eAAe,EAAE;YACjB,MAAM,OAAO,GAAG,kBAAkB,CAAC,eAAe,EAAE,eAAe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,QAAQ,EAAA,QAAA,EAEjB,QAAQ,EAAA,CACU,EAAA,CACb;AAEtB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAE,QAAQ,EAAiC,MAC3EA,GAAA,CAAC,WAAW,CAAC,MAAM,cAAE,QAAQ,EAAA,CAAsB,CACtD;AACD,0BAA0B,CAAC,WAAW,GAAG,mBAAmB;AAE5D,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAEnD,MAAM,aAAa,GAAG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandStepper.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepper.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"CommandStepper.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepper.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,sBAAsB,CAAC;AAM9B,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,YAAY,EACrD,aAAa,GAAG,gBAAgB,GAAG,QAAQ,GAAG,cAAc,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,GAAG,UAAU,CACnH,CAAC;AAEF,MAAM,WAAW,0BAA2B,SAAQ,yBAAyB;IAEzE,UAAU,EAAE,MAAM,CAAC;IAEn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I,+TA0BnC,0BAA0B,sBA8J5B,CAAC;AAmKF,eAAO,MAAM,cAAc,GAAI,QAAQ,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM,EAC/E,OAAO,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,sBAoDlD,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { Stepper } from 'primereact/stepper';
|
|
|
4
4
|
import { Button } from 'primereact/button';
|
|
5
5
|
import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
6
6
|
import { applyBeforeExecute } from './applyBeforeExecute.js';
|
|
7
|
+
import { getStepPanels } from './stepChildren.js';
|
|
7
8
|
import './CommandStepper.css';
|
|
8
9
|
|
|
9
10
|
/** Extracts the property name from an accessor function like `c => c.name`. */
|
|
@@ -52,20 +53,27 @@ const processChildren = (nodes) => {
|
|
|
52
53
|
});
|
|
53
54
|
};
|
|
54
55
|
const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveStepChange, onVisitedStepsChange, onStepErrorsChange, getFieldError, showNavigation = true, showSubmit = true, nextLabel = 'Next', previousLabel = 'Previous', okLabel = 'Submit', isBusy = false, isSubmitting = false, isSubmitDisabled = false, onSubmit, orientation = 'horizontal', headerPosition, linear = true, onChangeStep, start, end, pt, ptOptions, unstyled, }) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
// The steps that actually render. Conditional steps (`{condition && <StepperPanel/>}`)
|
|
57
|
+
// leave falsy children behind, so the count, the per-step validation state and what the
|
|
58
|
+
// Stepper renders are all derived from this one list — they cannot drift apart.
|
|
59
|
+
const steps = useMemo(() => getStepPanels(children), [children]);
|
|
60
|
+
const stepCount = steps.length;
|
|
61
|
+
// A conditional step can vanish after the user has advanced past it, which leaves the
|
|
62
|
+
// incoming index pointing at a step that is no longer rendered. Clamp it into the set that
|
|
63
|
+
// is, so the panel shown, the validation state read and the buttons offered all belong to a
|
|
64
|
+
// step that exists.
|
|
65
|
+
const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));
|
|
66
|
+
const isLastStep = currentStep >= stepCount - 1;
|
|
67
|
+
const isFirstStep = currentStep <= 0;
|
|
68
|
+
const stepFieldNames = useMemo(() => steps.map((step) => {
|
|
61
69
|
const stepProps = step.props;
|
|
62
70
|
return extractFieldNamesFromNode(stepProps.children);
|
|
63
|
-
}), [
|
|
71
|
+
}), [steps]);
|
|
64
72
|
const stepErrors = useMemo(() => stepFieldNames.map(fields => fields.some(fieldName => !!getFieldError?.(fieldName))), [stepFieldNames, getFieldError]);
|
|
65
73
|
useEffect(() => {
|
|
66
74
|
onStepErrorsChange?.(stepErrors);
|
|
67
75
|
}, [onStepErrorsChange, stepErrors]);
|
|
68
|
-
const isCurrentStepInvalid = stepErrors[
|
|
76
|
+
const isCurrentStepInvalid = stepErrors[currentStep] ?? false;
|
|
69
77
|
const hasAnyStepErrors = stepErrors.some(hasError => hasError);
|
|
70
78
|
const stepperPt = useMemo(() => {
|
|
71
79
|
const userPt = pt;
|
|
@@ -104,26 +112,26 @@ const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveSte
|
|
|
104
112
|
onChangeStep?.(event);
|
|
105
113
|
const index = event.index;
|
|
106
114
|
if (typeof index === 'number') {
|
|
107
|
-
if (index >
|
|
115
|
+
if (index > currentStep && isCurrentStepInvalid) {
|
|
108
116
|
return;
|
|
109
117
|
}
|
|
110
|
-
if (index >
|
|
111
|
-
onVisitedStepsChange?.(new Set(visitedSteps).add(
|
|
118
|
+
if (index > currentStep) {
|
|
119
|
+
onVisitedStepsChange?.(new Set(visitedSteps).add(currentStep));
|
|
112
120
|
}
|
|
113
121
|
onActiveStepChange?.(index);
|
|
114
122
|
}
|
|
115
123
|
};
|
|
116
124
|
const handlePrevious = () => {
|
|
117
|
-
onActiveStepChange?.(Math.max(0,
|
|
125
|
+
onActiveStepChange?.(Math.max(0, currentStep - 1));
|
|
118
126
|
};
|
|
119
127
|
const handleNext = () => {
|
|
120
128
|
if (isCurrentStepInvalid) {
|
|
121
129
|
return;
|
|
122
130
|
}
|
|
123
|
-
onVisitedStepsChange?.(new Set(visitedSteps).add(
|
|
124
|
-
onActiveStepChange?.(Math.min(stepCount - 1,
|
|
131
|
+
onVisitedStepsChange?.(new Set(visitedSteps).add(currentStep));
|
|
132
|
+
onActiveStepChange?.(Math.min(stepCount - 1, currentStep + 1));
|
|
125
133
|
};
|
|
126
|
-
return (jsxs("div", { className: "cratis-command-stepper", children: [jsx(Stepper, { activeStep:
|
|
134
|
+
return (jsxs("div", { className: "cratis-command-stepper", children: [jsx(Stepper, { activeStep: currentStep, linear: linear, orientation: orientation, headerPosition: headerPosition, onChangeStep: handleChangeStep, start: start, end: end, pt: stepperPt, ptOptions: ptOptions, unstyled: unstyled, children: processChildren(steps) }), showNavigation && (jsxs("div", { style: { display: 'flex', alignItems: 'center', width: '100%', gap: '0.75rem' }, children: [!isFirstStep && (jsx(Button, { label: previousLabel, icon: "pi pi-arrow-left", onClick: handlePrevious, disabled: isBusy, outlined: true, style: { width: 'auto' } })), jsx("div", { style: { flex: 1 } }), !isLastStep && (jsx(Button, { label: nextLabel, icon: "pi pi-arrow-right", iconPos: "right", onClick: handleNext, disabled: isBusy || isSubmitting || isCurrentStepInvalid, style: { width: 'auto' } })), isLastStep && showSubmit && (jsx(Button, { label: okLabel, icon: "pi pi-check", onClick: () => void onSubmit?.(), loading: isSubmitting, disabled: isBusy || isSubmitting || isSubmitDisabled || hasAnyStepErrors, autoFocus: true, style: { width: 'auto' } }))] }))] }));
|
|
127
135
|
};
|
|
128
136
|
const CommandStepperWrapper = ({ children, onStepErrorsChange, showNavigation, showSubmit, nextLabel, previousLabel, okLabel, isBusy, orientation, headerPosition, linear, onChangeStep, start, end, pt, ptOptions, unstyled, onSuccess, onValidationFailure, onFailed, onBeforeExecute, }) => {
|
|
129
137
|
const { getFieldError, isValid: isCommandFormValid, setCommandValues, setCommandResult } = useCommandFormContext();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandStepper.js","sources":["../../../CommandDialog/CommandStepper.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","PrimeStepper"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommandStepper.js","sources":["../../../CommandDialog/CommandStepper.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","PrimeStepper"],"mappings":";;;;;;;;;AAiFA;AACA,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;AAED;AACA,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;AAEA,QAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAgC;AACzD,QAAA,IAAI,UAAU,CAAC,QAAQ,IAAI,IAAI,EAA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AS,EACpB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,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,EAClB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,eAAe,EAAE,eAAe,YAE/B,QAAQ,EAAA,CACW,EAAA,CACd;AAEtB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
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;AAEhG,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAIH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAyB,KAAK,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
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;AAEhG,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAIH,KAAK,gBAAgB,EACxB,M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uYD,eAAO,MAAM,oBAAoB,GA3EM,QAAQ,SAAS,MAAM,WAAW,SAAS,kBACvE,yBAAyB,CAAC,QAAQ,EAAE,SAAS,CAAC,sBA0EQ,CAAC"}
|
|
@@ -2,10 +2,11 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useDialogContext, DialogResult } from '@cratis/arc.react/dialogs';
|
|
3
3
|
import { Dialog } from 'primereact/dialog';
|
|
4
4
|
import { Button } from 'primereact/button';
|
|
5
|
-
import
|
|
5
|
+
import { useState } from 'react';
|
|
6
6
|
import { CommandForm, useCommandFormContext, useCommandInstance } from '@cratis/arc.react/commands';
|
|
7
7
|
import { CommandStepperContent } from './CommandStepper.js';
|
|
8
8
|
import { applyBeforeExecute } from './applyBeforeExecute.js';
|
|
9
|
+
import { getStepPanels } from './stepChildren.js';
|
|
9
10
|
|
|
10
11
|
const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, contentStyle, resizable = false, isValid, onClose, onConfirm, onCancel, onSuccess, onValidationFailure, onFailed, onBeforeExecute, okLabel = 'Submit', nextLabel = 'Next', previousLabel = 'Previous', orientation = 'horizontal', headerPosition, linear = true, onChangeStep, start, end, pt, ptOptions, unstyled, dialogClassName, dialogPt, dialogPtOptions, dialogUnstyled, children }) => {
|
|
11
12
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError } = useCommandFormContext();
|
|
@@ -25,11 +26,19 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
25
26
|
catch {
|
|
26
27
|
contextCloseDialog = undefined;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
// Only the steps that actually render count. That count is not fixed: a conditional step
|
|
30
|
+
// (`{condition && <StepperPanel/>}`) can disappear after the user has already advanced past
|
|
31
|
+
// it — a late-resolving query or a `currentValues` overlay flipping the condition is enough.
|
|
32
|
+
// The step the wizard is on is therefore clamped into the set that still renders, and the
|
|
33
|
+
// last/first tests are inequalities, so an index left stranded above the end still resolves
|
|
34
|
+
// to the last surviving step instead of a step that is neither last nor navigable. Same
|
|
35
|
+
// shape as CommandStepperContent, which this dialog's body is.
|
|
36
|
+
const stepCount = getStepPanels(children).length;
|
|
37
|
+
const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));
|
|
38
|
+
const isLastStep = currentStep >= stepCount - 1;
|
|
39
|
+
const isFirstStep = currentStep <= 0;
|
|
31
40
|
const isDialogValid = isValid !== false && isCommandFormValid;
|
|
32
|
-
const isCurrentStepInvalid = stepErrors[
|
|
41
|
+
const isCurrentStepInvalid = stepErrors[currentStep] ?? false;
|
|
33
42
|
const handleClose = async (result) => {
|
|
34
43
|
let shouldCloseThroughContext = true;
|
|
35
44
|
if (result === DialogResult.Ok || result === DialogResult.Yes) {
|
|
@@ -83,11 +92,11 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
83
92
|
await handleClose(DialogResult.Ok);
|
|
84
93
|
};
|
|
85
94
|
const headerElement = (jsx("div", { className: "inline-flex items-center justify-center gap-2", children: jsx("span", { className: "font-bold whitespace-nowrap", children: title }) }));
|
|
86
|
-
const footer = (jsxs("div", { className: "flex items-center w-full gap-3", children: [!isFirstStep && (jsx(Button, { label: previousLabel, icon: "pi pi-arrow-left", onClick: () => setActiveStep(
|
|
87
|
-
setVisitedSteps(prev => new Set(prev).add(
|
|
88
|
-
setActiveStep(
|
|
95
|
+
const footer = (jsxs("div", { className: "flex items-center w-full gap-3", children: [!isFirstStep && (jsx(Button, { label: previousLabel, icon: "pi pi-arrow-left", onClick: () => setActiveStep(Math.max(0, currentStep - 1)), disabled: isBusy, outlined: true })), jsx("div", { className: "flex-1" }), !isLastStep && (jsx(Button, { label: nextLabel, icon: "pi pi-arrow-right", iconPos: "right", onClick: () => {
|
|
96
|
+
setVisitedSteps(prev => new Set(prev).add(currentStep));
|
|
97
|
+
setActiveStep(Math.min(stepCount - 1, currentStep + 1));
|
|
89
98
|
}, disabled: isBusy || isCurrentStepInvalid })), isLastStep && isDialogValid && (jsx(Button, { label: okLabel, icon: "pi pi-check", onClick: handleSubmit, loading: isBusy, disabled: isBusy, autoFocus: true }))] }));
|
|
90
|
-
return (jsx(Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(DialogResult.Cancelled), visible: visible, style: { width, ...style }, contentStyle: contentStyle, resizable: resizable, closable: true, className: dialogClassName, pt: dialogPt, ptOptions: dialogPtOptions, unstyled: dialogUnstyled, children: jsx(CommandStepperContent, { activeStep:
|
|
99
|
+
return (jsx(Dialog, { header: headerElement, modal: true, footer: footer, onHide: () => handleClose(DialogResult.Cancelled), visible: visible, style: { width, ...style }, contentStyle: contentStyle, resizable: resizable, closable: true, className: dialogClassName, pt: dialogPt, ptOptions: dialogPtOptions, unstyled: dialogUnstyled, children: jsx(CommandStepperContent, { activeStep: currentStep, visitedSteps: visitedSteps, getFieldError: getFieldError, onActiveStepChange: setActiveStep, onVisitedStepsChange: setVisitedSteps, onStepErrorsChange: setStepErrors, showNavigation: false, showSubmit: false, linear: linear, orientation: orientation, headerPosition: headerPosition, onChangeStep: onChangeStep, start: start, end: end, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
|
|
91
100
|
};
|
|
92
101
|
/**
|
|
93
102
|
* A multi-step wizard dialog backed by a single Cratis Arc command. Wraps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","PrimeDialog"],"mappings":"
|
|
1
|
+
{"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","PrimeDialog"],"mappings":";;;;;;;;;;AAwFA,MAAM,2BAA2B,GAAG,CAA8C,EAC9E,KAAK,EACL,OAAO,GAAG,IAAI,EACd,KAAK,GAAG,OAAO,EACf,KAA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