@cratis/components 4.15.1 → 4.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compat-manifest.json +11 -11
- package/dist/esm/Chat/ChatConversation.d.ts +10 -1
- package/dist/esm/Chat/ChatConversation.js +4 -3
- package/dist/esm/Chat/ChatConversation.js.map +1 -1
- package/dist/esm/Chat/ChatSidebar.d.ts +7 -2
- package/dist/esm/Chat/ChatSidebar.js +3 -3
- package/dist/esm/Chat/ChatSidebar.js.map +1 -1
- package/dist/esm/Chat/ChatSidebarForObservableQueries.d.ts +2 -2
- package/dist/esm/Chat/ChatSidebarForObservableQueries.js +60 -12
- package/dist/esm/Chat/ChatSidebarForObservableQueries.js.map +1 -1
- package/dist/esm/Chat/ChatStatus.d.ts +12 -0
- package/dist/esm/Chat/ChatStatus.d.ts.map +1 -0
- package/dist/esm/Chat/ChatStatus.js +10 -0
- package/dist/esm/Chat/ChatStatus.js.map +1 -0
- package/dist/esm/Chat/ChatTopicList.d.ts +10 -1
- package/dist/esm/Chat/ChatTopicList.js +3 -2
- package/dist/esm/Chat/ChatTopicList.js.map +1 -1
- package/dist/esm/Chat/Kit/ChatComposer.d.ts +2 -0
- package/dist/esm/Chat/Kit/ChatComposer.js +14 -7
- package/dist/esm/Chat/Kit/ChatComposer.js.map +1 -1
- package/dist/esm/Chat/index.d.ts +1 -0
- package/dist/esm/Chat/index.js +1 -0
- package/dist/esm/Chat/index.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts +11 -1
- package/dist/esm/CommandDialog/CommandDialog.js +12 -20
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepper.d.ts +8 -1
- package/dist/esm/CommandDialog/CommandStepper.js +11 -19
- package/dist/esm/CommandDialog/CommandStepper.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperContent.d.ts +2 -0
- package/dist/esm/CommandDialog/CommandStepperContent.js +2 -2
- package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.d.ts +8 -1
- package/dist/esm/CommandDialog/StepperCommandDialog.js +12 -19
- package/dist/esm/CommandDialog/StepperCommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/commandValuesUnchanged.d.ts +5 -0
- package/dist/esm/CommandDialog/commandValuesUnchanged.d.ts.map +1 -0
- package/dist/esm/CommandDialog/commandValuesUnchanged.js +22 -0
- package/dist/esm/CommandDialog/commandValuesUnchanged.js.map +1 -0
- package/dist/esm/CommandDialog/confirmBeforeExecute.d.ts +9 -0
- package/dist/esm/CommandDialog/confirmBeforeExecute.d.ts.map +1 -0
- package/dist/esm/CommandDialog/confirmBeforeExecute.js +12 -0
- package/dist/esm/CommandDialog/confirmBeforeExecute.js.map +1 -0
- package/dist/esm/CommandDialog/index.d.ts +1 -0
- package/dist/esm/CommandDialog/useCommandExecution.d.ts +9 -0
- package/dist/esm/CommandDialog/useCommandExecution.js +52 -0
- package/dist/esm/CommandDialog/useCommandExecution.js.map +1 -0
- package/dist/esm/CommandDialog/useSubmissionFlight.d.ts +8 -0
- package/dist/esm/CommandDialog/useSubmissionFlight.d.ts.map +1 -0
- package/dist/esm/CommandDialog/useSubmissionFlight.js +30 -0
- package/dist/esm/CommandDialog/useSubmissionFlight.js.map +1 -0
- package/dist/esm/Common/DatePickerInputImplementation.js +16 -7
- package/dist/esm/Common/DatePickerInputImplementation.js.map +1 -1
- package/dist/esm/Common/Tooltip.d.ts +3 -3
- package/dist/esm/Common/Tooltip.d.ts.map +1 -1
- package/dist/esm/Common/TooltipImplementation.js +1 -1
- package/dist/esm/Common/TooltipImplementation.js.map +1 -1
- package/dist/esm/DataTables/DataTableCore.js +1 -1
- package/dist/esm/DataTables/DataTableCore.js.map +1 -1
- package/dist/esm/DataTables/resolveDataTableStatus.d.ts +1 -0
- package/dist/esm/DataTables/resolveDataTableStatus.js +8 -8
- package/dist/esm/DataTables/resolveDataTableStatus.js.map +1 -1
- package/dist/esm/Filter/CheckboxListFilter.d.ts +5 -1
- package/dist/esm/Filter/CheckboxListFilter.js +16 -4
- package/dist/esm/Filter/CheckboxListFilter.js.map +1 -1
- package/dist/esm/Filter/FilterPanel.d.ts +5 -1
- package/dist/esm/Filter/FilterPanel.js +37 -6
- package/dist/esm/Filter/FilterPanel.js.map +1 -1
- package/dist/esm/Filter/types.d.ts +4 -0
- package/dist/esm/Filter/types.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.d.ts +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +2 -2
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/PivotViewerLabels.d.ts +32 -0
- package/dist/esm/PivotViewer/PivotViewerLabels.d.ts.map +1 -0
- package/dist/esm/PivotViewer/PivotViewerLabels.js +4 -0
- package/dist/esm/PivotViewer/PivotViewerLabels.js.map +1 -0
- package/dist/esm/PivotViewer/components/FilterPanel.d.ts +6 -1
- package/dist/esm/PivotViewer/components/FilterPanel.js +3 -2
- package/dist/esm/PivotViewer/components/FilterPanel.js.map +1 -1
- package/dist/esm/PivotViewer/components/Toolbar.d.ts +3 -1
- package/dist/esm/PivotViewer/components/Toolbar.js +2 -3
- package/dist/esm/PivotViewer/components/Toolbar.js.map +1 -1
- package/dist/esm/PivotViewer/index.d.ts +1 -0
- package/dist/esm/PivotViewer/types.d.ts +4 -1
- package/dist/esm/PivotViewer/types.js.map +1 -1
- package/dist/esm/QueryStatus/QueryStatus.d.ts +8 -0
- package/dist/esm/QueryStatus/QueryStatus.d.ts.map +1 -0
- package/dist/esm/QueryStatus/QueryStatus.js +10 -0
- package/dist/esm/QueryStatus/QueryStatus.js.map +1 -0
- package/dist/esm/QueryStatus/resolveQueryStatus.d.ts +9 -0
- package/dist/esm/QueryStatus/resolveQueryStatus.js +14 -0
- package/dist/esm/QueryStatus/resolveQueryStatus.js.map +1 -0
- package/dist/esm/styles.Canvas.css +10 -3
- package/dist/esm/styles.Chat.css +10 -3
- package/dist/esm/styles.css +10 -3
- package/dist/esm/types/parts.d.ts +2 -2
- package/dist/esm/types/parts.js +2 -2
- package/dist/esm/types/parts.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,12 +8,13 @@ import { matchCandidates } from './Mentions/matchCandidates.js';
|
|
|
8
8
|
import { MentionSuggestions } from './Mentions/MentionSuggestions.js';
|
|
9
9
|
import { ReactionPicker } from './ReactionPicker.js';
|
|
10
10
|
|
|
11
|
-
const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates, onSend, autoFocus = false, buildAvatarUrl, labels, }, handleRef) => {
|
|
11
|
+
const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates, onSend, autoFocus = false, disabled = false, buildAvatarUrl, labels, }, handleRef) => {
|
|
12
12
|
const [draft, setDraft] = useState({ text: '', caret: 0 });
|
|
13
13
|
const [highlightedIndex, setHighlightedIndex] = useState(0);
|
|
14
14
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
15
15
|
const [resolvedCandidates, setResolvedCandidates] = useState([]);
|
|
16
16
|
const inputRef = useRef(null);
|
|
17
|
+
const didAutoFocus = useRef(false);
|
|
17
18
|
const emojiButtonRef = useRef(null);
|
|
18
19
|
const seenCandidatesRef = useRef(new Map());
|
|
19
20
|
const mentionsEnabled = !!mentionCandidates || !!resolveMentionCandidates;
|
|
@@ -62,13 +63,19 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
62
63
|
const suggestions = query && !queryIsCompleteMention
|
|
63
64
|
? matchCandidates(candidatePool, query.text)
|
|
64
65
|
: [];
|
|
65
|
-
const isSuggesting = suggestions.length > 0;
|
|
66
|
+
const isSuggesting = !disabled && suggestions.length > 0;
|
|
66
67
|
const highlighted = Math.min(highlightedIndex, suggestions.length - 1);
|
|
67
68
|
useEffect(() => {
|
|
68
|
-
if (autoFocus) {
|
|
69
|
-
inputRef.current
|
|
69
|
+
if (autoFocus && !disabled && !didAutoFocus.current && inputRef.current) {
|
|
70
|
+
inputRef.current.focus();
|
|
71
|
+
didAutoFocus.current = true;
|
|
72
|
+
}
|
|
73
|
+
}, [autoFocus, disabled]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (disabled) {
|
|
76
|
+
setShowEmojiPicker(false);
|
|
70
77
|
}
|
|
71
|
-
}, [
|
|
78
|
+
}, [disabled]);
|
|
72
79
|
useImperativeHandle(handleRef, () => ({
|
|
73
80
|
prefill: (text) => {
|
|
74
81
|
setDraft({ text, caret: text.length });
|
|
@@ -87,7 +94,7 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
87
94
|
};
|
|
88
95
|
const send = () => {
|
|
89
96
|
const trimmed = draft.text.trim();
|
|
90
|
-
if (!trimmed)
|
|
97
|
+
if (!trimmed || disabled)
|
|
91
98
|
return;
|
|
92
99
|
const known = uniqueById([
|
|
93
100
|
...(mentionCandidates ?? []),
|
|
@@ -144,7 +151,7 @@ const ChatComposer = forwardRef(({ mentionCandidates, resolveMentionCandidates,
|
|
|
144
151
|
send();
|
|
145
152
|
}
|
|
146
153
|
};
|
|
147
|
-
return (jsxs("div", { className: 'chat-composer', children: [isSuggesting && (jsx(MentionSuggestions, { candidates: suggestions, highlightedIndex: highlighted, onSelect: choose, onHighlight: setHighlightedIndex, buildAvatarUrl: buildAvatarUrl })), jsx("textarea", { ref: inputRef, className: 'chat-composer__input', value: draft.text, onChange: (event) => readDraft(event.target), onKeyUp: (event) => readDraft(event.currentTarget), onClick: (event) => readDraft(event.currentTarget), onKeyDown: handleKeyDown, placeholder: labels?.placeholder ?? 'Write a message… (Enter to send)', rows: 2 }), jsx("button", { ref: emojiButtonRef, type: 'button', className: 'chat-composer__emoji-toggle', onMouseDown: (event) => event.preventDefault(), onClick: () => setShowEmojiPicker((previous) => !previous), title: labels?.insertEmoji ?? 'Insert emoji', "aria-label": labels?.insertEmoji ?? 'Insert emoji', "aria-expanded": showEmojiPicker, children: "\u263A" }), jsx("button", { type: 'button', className: 'chat-composer__send', onClick: send, disabled: !draft.text.trim(), title: labels?.send ?? 'Send', "aria-label": labels?.sendMessage ?? 'Send message', children: jsxs("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '22', y1: '2', x2: '11', y2: '13' }), jsx("polygon", { points: '22 2 15 22 11 13 2 9 22 2' })] }) }), jsx(AnchoredOverlay, { anchorRef: emojiButtonRef, open: showEmojiPicker, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { anchorRef: emojiButtonRef, onPick: insertEmoji, onDismiss: () => setShowEmojiPicker(false), labels: labels?.reactionPicker }) })] }));
|
|
154
|
+
return (jsxs("div", { className: 'chat-composer', children: [isSuggesting && (jsx(MentionSuggestions, { candidates: suggestions, highlightedIndex: highlighted, onSelect: choose, onHighlight: setHighlightedIndex, buildAvatarUrl: buildAvatarUrl })), jsx("textarea", { ref: inputRef, className: 'chat-composer__input', value: draft.text, onChange: (event) => readDraft(event.target), onKeyUp: (event) => readDraft(event.currentTarget), onClick: (event) => readDraft(event.currentTarget), onKeyDown: handleKeyDown, placeholder: labels?.placeholder ?? 'Write a message… (Enter to send)', rows: 2, disabled: disabled }), jsx("button", { ref: emojiButtonRef, type: 'button', className: 'chat-composer__emoji-toggle', disabled: disabled, onMouseDown: (event) => event.preventDefault(), onClick: () => setShowEmojiPicker((previous) => !previous), title: labels?.insertEmoji ?? 'Insert emoji', "aria-label": labels?.insertEmoji ?? 'Insert emoji', "aria-expanded": showEmojiPicker, children: "\u263A" }), jsx("button", { type: 'button', className: 'chat-composer__send', onClick: send, disabled: disabled || !draft.text.trim(), title: labels?.send ?? 'Send', "aria-label": labels?.sendMessage ?? 'Send message', children: jsxs("svg", { width: '16', height: '16', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '22', y1: '2', x2: '11', y2: '13' }), jsx("polygon", { points: '22 2 15 22 11 13 2 9 22 2' })] }) }), jsx(AnchoredOverlay, { anchorRef: emojiButtonRef, open: showEmojiPicker && !disabled, side: 'above', align: 'right', gap: 6, children: jsx(ReactionPicker, { anchorRef: emojiButtonRef, onPick: insertEmoji, onDismiss: () => setShowEmojiPicker(false), labels: labels?.reactionPicker }) })] }));
|
|
148
155
|
});
|
|
149
156
|
ChatComposer.displayName = 'ChatComposer';
|
|
150
157
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ChatComposer.js","sources":["../../../../Chat/Kit/ChatComposer.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAoFO,MAAM,YAAY,GAAG,UAAU,CAClC,CACI,EACI,iBAAiB,EACjB,wBAAwB,EACxB,MAAM,EACN,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,cAAc,EACd,MAAM,GACT,EACD,SAAS,KACT;AACA,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CACxD,EAAE,CACL;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC;AAClD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAClC,IAAA,MA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AM,EAAE,WAAW,IAAI,cAAc,EAAA,QAAA,EAEjDD,cACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,aAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,SAAA,EAAA,EAAS,MAAM,EAAC,2BAA2B,EAAA,CAAG,CAAA,EAAA,CAC5C,GACD,EAGTA,GAAA,CAAC,eAAe,EAAA,EACZ,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,eAAe,IAAI,CAAC,QAAQ,EAClC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,CAAC,EAAA,QAAA,EAENA,GAAA,CAAC,cAAc,EAAA,EACX,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAC1C,MAAM,EAAE,MAAM,EAAE,cAAc,GAChC,EAAA,CACY,CAAA,EAAA,CAChB;AAEd,CAAC;AAEL,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
package/dist/esm/Chat/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { ChatIdentifier } from './ChatIdentifier.js';
|
|
|
6
6
|
export type { ChatMention } from './ChatMention.js';
|
|
7
7
|
export type { ChatMessage } from './ChatMessage.js';
|
|
8
8
|
export type { ChatMessageAction } from './ChatMessageAction.js';
|
|
9
|
+
export { ChatStatus } from './ChatStatus.js';
|
|
9
10
|
export { ChatMessageBody } from './ChatMessageBody.js';
|
|
10
11
|
export type { ChatMessageBodyProps } from './ChatMessageBody.js';
|
|
11
12
|
export { ChatSidebar } from './ChatSidebar.js';
|
package/dist/esm/Chat/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ChatConversation } from './ChatConversation.js';
|
|
2
2
|
export { chatIdentifierString, sameChatIdentifier } from './ChatIdentifier.js';
|
|
3
|
+
export { ChatStatus } from './ChatStatus.js';
|
|
3
4
|
export { ChatMessageBody } from './ChatMessageBody.js';
|
|
4
5
|
export { ChatSidebar } from './ChatSidebar.js';
|
|
5
6
|
export { ChatSidebarForObservableQueries } from './ChatSidebarForObservableQueries.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type DialogProps } from '../Dialogs/Dialog.js';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { type CommandFormProps } from '@cratis/arc.react/commands';
|
|
4
|
-
import {
|
|
4
|
+
import type { BeforeExecuteCallback } from './applyBeforeExecute.js';
|
|
5
|
+
import type { ConfirmBeforeExecute } from './confirmBeforeExecute.js';
|
|
5
6
|
/**
|
|
6
7
|
* Props for {@link CommandDialog}. Combines the props of a `CommandForm`
|
|
7
8
|
* (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,
|
|
@@ -27,6 +28,15 @@ export interface CommandDialogProps<TCommand extends object, TResponse = object>
|
|
|
27
28
|
* transforms that do not affect validity (for example a generated id).
|
|
28
29
|
*/
|
|
29
30
|
onBeforeExecute?: BeforeExecuteCallback<TCommand>;
|
|
31
|
+
/**
|
|
32
|
+
* Ask whether to run the command after validation and `onBeforeExecute`.
|
|
33
|
+
* Receives the transformed values. Only `true` executes; all other outcomes
|
|
34
|
+
* keep the dialog open. May return a promise (for example from a confirmation dialog).
|
|
35
|
+
* If command values change while confirmation is pending, execution is skipped
|
|
36
|
+
* and the dialog stays open; confirm the new values again.
|
|
37
|
+
* Unlike `onConfirm`, this runs before execution, not after success.
|
|
38
|
+
*/
|
|
39
|
+
confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;
|
|
30
40
|
/**
|
|
31
41
|
* Form fields and arbitrary content for the dialog body. Children that are
|
|
32
42
|
* `CommandFormField` instances are automatically wrapped so they bind to
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
|
|
3
3
|
import { Dialog } from '../Dialogs/Dialog.js';
|
|
4
|
-
import React
|
|
4
|
+
import React from 'react';
|
|
5
5
|
import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFieldWrapper } from '@cratis/arc.react/commands';
|
|
6
|
-
import {
|
|
6
|
+
import { useCommandExecution } from './useCommandExecution.js';
|
|
7
7
|
import { markAsCommandFormColumn, isCommandFormField } from '../CommandForm/commandFormMarkers.js';
|
|
8
8
|
|
|
9
|
-
const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, children, ...dialogProps }) => {
|
|
9
|
+
const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, children, ...dialogProps }) => {
|
|
10
10
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, } = useCommandFormContext();
|
|
11
11
|
const commandInstance = useCommandInstance();
|
|
12
|
-
const
|
|
12
|
+
const submission = useCommandExecution(commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException);
|
|
13
13
|
const handleConfirm = async () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (onBeforeExecute) {
|
|
18
|
-
const applied = applyBeforeExecute(onBeforeExecute, commandInstance);
|
|
19
|
-
setCommandValues(applied instanceof Promise ? await applied : applied);
|
|
20
|
-
}
|
|
21
|
-
result = await commandInstance.execute();
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
setIsBusy(false);
|
|
25
|
-
}
|
|
14
|
+
const result = await submission.run();
|
|
15
|
+
if (!result)
|
|
16
|
+
return false;
|
|
26
17
|
if (!result.isSuccess) {
|
|
27
18
|
await onFailed?.(result);
|
|
28
19
|
if (result.hasExceptions) {
|
|
@@ -33,7 +24,8 @@ const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValida
|
|
|
33
24
|
if (!result.isValid) {
|
|
34
25
|
await onValidationFailure?.(result.validationResults);
|
|
35
26
|
}
|
|
36
|
-
|
|
27
|
+
if (submission.isMounted())
|
|
28
|
+
setCommandResult(result);
|
|
37
29
|
return false;
|
|
38
30
|
}
|
|
39
31
|
await onSuccess?.(result.response);
|
|
@@ -66,10 +58,10 @@ const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValida
|
|
|
66
58
|
};
|
|
67
59
|
const processedChildren = processChildren(children);
|
|
68
60
|
const isDialogValid = isValid !== false && isCommandFormValid;
|
|
69
|
-
return (jsx(Dialog, { ...dialogProps, onClose: onClose, onConfirm: handleConfirm, isValid: isDialogValid, isBusy:
|
|
61
|
+
return (jsx(Dialog, { ...dialogProps, onClose: onClose, onConfirm: handleConfirm, isValid: isDialogValid, isBusy: submission.isSubmitting, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
|
|
70
62
|
};
|
|
71
63
|
const CommandDialogComponent = (props) => {
|
|
72
|
-
const { title, subtitle, placement, closeIcon, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, dismissable, closeAriaLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
|
|
64
|
+
const { title, subtitle, placement, closeIcon, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, dismissable, closeAriaLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, confirmBeforeExecute, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
|
|
73
65
|
const dialogProps = {
|
|
74
66
|
title,
|
|
75
67
|
subtitle,
|
|
@@ -97,7 +89,7 @@ const CommandDialogComponent = (props) => {
|
|
|
97
89
|
ptOptions,
|
|
98
90
|
unstyled,
|
|
99
91
|
};
|
|
100
|
-
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, children: children }) }));
|
|
92
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, children: children }) }));
|
|
101
93
|
};
|
|
102
94
|
const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
|
|
103
95
|
markAsCommandFormColumn(CommandDialogColumnWrapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;AAwEA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,GAAG,WAAW,EASj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sB,CACtD;AACD,uBAAuB,CAAC,0BAA0B,CAAC;AAEnD,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAcnD,MAAM,aAAa,GAAG;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
|
|
2
2
|
import { type CommandFormProps } from '@cratis/arc.react/commands';
|
|
3
|
-
import {
|
|
3
|
+
import type { BeforeExecuteCallback } from './applyBeforeExecute.js';
|
|
4
|
+
import type { ConfirmBeforeExecute } from './confirmBeforeExecute.js';
|
|
4
5
|
import { type CommandStepperContentProps } from './CommandStepperContent.js';
|
|
5
6
|
/**
|
|
6
7
|
* Event passed to {@link StepperCustomizationProps.onChangeStep} when the user
|
|
@@ -86,6 +87,12 @@ export interface CommandStepperProps<TCommand extends object, TResponse = object
|
|
|
86
87
|
* transforms that do not affect validity (for example a generated id).
|
|
87
88
|
*/
|
|
88
89
|
onBeforeExecute?: BeforeExecuteCallback<TCommand>;
|
|
90
|
+
/**
|
|
91
|
+
* Ask before executing the transformed command values; only `true` executes.
|
|
92
|
+
* Fields are disabled from submit until the guarded submission settles. If command values change
|
|
93
|
+
* during that time, execution is skipped; confirm the new values again.
|
|
94
|
+
*/
|
|
95
|
+
confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;
|
|
89
96
|
/** StepperPanel children defining each wizard step. */
|
|
90
97
|
children?: React.ReactNode;
|
|
91
98
|
}
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { CommandForm, useCommandFormContext, useCommandInstance } from '@cratis/arc.react/commands';
|
|
4
|
-
import {
|
|
4
|
+
import { useCommandExecution } from './useCommandExecution.js';
|
|
5
5
|
import { CommandStepperContent } from './CommandStepperContent.js';
|
|
6
6
|
|
|
7
|
-
const CommandStepperWrapper = ({ children, onStepErrorsChange, showNavigation, showSubmit, nextLabel, previousLabel, okLabel, isBusy, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, }) => {
|
|
7
|
+
const CommandStepperWrapper = ({ children, onStepErrorsChange, showNavigation, showSubmit, nextLabel, previousLabel, okLabel, isBusy, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, }) => {
|
|
8
8
|
const { getFieldError, isValid: isCommandFormValid, setCommandValues, setCommandResult, } = useCommandFormContext();
|
|
9
9
|
const commandInstance = useCommandInstance();
|
|
10
10
|
const [activeStep, setActiveStep] = useState(0);
|
|
11
11
|
const [visitedSteps, setVisitedSteps] = useState(new Set([0]));
|
|
12
|
-
const
|
|
12
|
+
const submission = useCommandExecution(commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException);
|
|
13
13
|
const handleSubmit = async () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (onBeforeExecute) {
|
|
18
|
-
const applied = applyBeforeExecute(onBeforeExecute, commandInstance);
|
|
19
|
-
setCommandValues(applied instanceof Promise ? await applied : applied);
|
|
20
|
-
}
|
|
21
|
-
result = await commandInstance.execute();
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
setIsSubmitting(false);
|
|
25
|
-
}
|
|
14
|
+
const result = await submission.run();
|
|
15
|
+
if (!result)
|
|
16
|
+
return;
|
|
26
17
|
if (!result.isSuccess) {
|
|
27
18
|
await onFailed?.(result);
|
|
28
19
|
if (result.hasExceptions) {
|
|
@@ -33,16 +24,17 @@ const CommandStepperWrapper = ({ children, onStepErrorsChange, showNavigation, s
|
|
|
33
24
|
if (!result.isValid) {
|
|
34
25
|
await onValidationFailure?.(result.validationResults);
|
|
35
26
|
}
|
|
36
|
-
|
|
27
|
+
if (submission.isMounted())
|
|
28
|
+
setCommandResult(result);
|
|
37
29
|
return;
|
|
38
30
|
}
|
|
39
31
|
await onSuccess?.(result.response);
|
|
40
32
|
};
|
|
41
|
-
return (jsx(CommandStepperContent, { activeStep: activeStep, visitedSteps: visitedSteps, onActiveStepChange: setActiveStep, onVisitedStepsChange: setVisitedSteps, onStepErrorsChange: onStepErrorsChange, getFieldError: getFieldError, showNavigation: showNavigation, showSubmit: showSubmit, nextLabel: nextLabel, previousLabel: previousLabel, okLabel: okLabel, isBusy: isBusy, isSubmitting: isSubmitting, isSubmitDisabled: !isCommandFormValid, onSubmit: handleSubmit, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }));
|
|
33
|
+
return (jsx(CommandStepperContent, { activeStep: activeStep, visitedSteps: visitedSteps, onActiveStepChange: setActiveStep, onVisitedStepsChange: setVisitedSteps, onStepErrorsChange: onStepErrorsChange, getFieldError: getFieldError, showNavigation: showNavigation, showSubmit: showSubmit, nextLabel: nextLabel, previousLabel: previousLabel, okLabel: okLabel, isBusy: isBusy, isSubmitting: submission.isSubmitting, disableFieldsWhileSubmitting: confirmBeforeExecute !== undefined, isSubmitDisabled: !isCommandFormValid, onSubmit: handleSubmit, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }));
|
|
42
34
|
};
|
|
43
35
|
const CommandStepper = (props) => {
|
|
44
|
-
const { children, onStepErrorsChange, showNavigation, showSubmit, nextLabel, previousLabel, okLabel, isBusy, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, onBeforeExecute, ...commandFormProps } = props;
|
|
45
|
-
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandStepperWrapper, { onStepErrorsChange: onStepErrorsChange, showNavigation: showNavigation, showSubmit: showSubmit, nextLabel: nextLabel, previousLabel: previousLabel, okLabel: okLabel, isBusy: isBusy, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, children: children }) }));
|
|
36
|
+
const { children, onStepErrorsChange, showNavigation, showSubmit, nextLabel, previousLabel, okLabel, isBusy, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, onBeforeExecute, confirmBeforeExecute, ...commandFormProps } = props;
|
|
37
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandStepperWrapper, { onStepErrorsChange: onStepErrorsChange, showNavigation: showNavigation, showSubmit: showSubmit, nextLabel: nextLabel, previousLabel: previousLabel, okLabel: okLabel, isBusy: isBusy, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, children: children }) }));
|
|
46
38
|
};
|
|
47
39
|
|
|
48
40
|
export { CommandStepper };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandStepper.js","sources":["../../../CommandDialog/CommandStepper.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"CommandStepper.js","sources":["../../../CommandDialog/CommandStepper.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;AA4JA,MAAM,qBAAqB,GAAG,CAA8C,EACxE,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,SAAS,EACT,aAAa,EACb,OAAO,EACP,MAAM,EACN,MAAM,EACN,WAAW,EACX,cAAc,EACd,KAAK,EACL,GAAG,EACH,YAAY,EACZ,EAAE,EACF,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AAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,YAAY,EAC1B,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,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAAA,QAAA,EAEzC,QAAQ,EAAA,CACW,EAAA,CACd;AAEtB;;"}
|
|
@@ -38,6 +38,8 @@ export interface CommandStepperContentProps extends StepperCustomizationProps {
|
|
|
38
38
|
isBusy?: boolean;
|
|
39
39
|
/** Whether submit is currently executing. */
|
|
40
40
|
isSubmitting?: boolean;
|
|
41
|
+
/** Locks form fields during a guarded submission without changing unguarded forms. */
|
|
42
|
+
disableFieldsWhileSubmitting?: boolean;
|
|
41
43
|
/** Disables submit regardless of current step state. */
|
|
42
44
|
isSubmitDisabled?: boolean;
|
|
43
45
|
/** Submit callback invoked on the last step. */
|
|
@@ -55,7 +55,7 @@ const processChildren = (nodes) => {
|
|
|
55
55
|
return child;
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
-
const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveStepChange, onVisitedStepsChange, onStepErrorsChange, getFieldError, showNavigation = true, showSubmit = true, nextLabel, previousLabel, okLabel, isBusy = false, isSubmitting = false, isSubmitDisabled = false, onSubmit, linear = true, orientation = 'horizontal', headerPosition = 'top', start, end, onChangeStep, pt, }) => {
|
|
58
|
+
const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveStepChange, onVisitedStepsChange, onStepErrorsChange, getFieldError, showNavigation = true, showSubmit = true, nextLabel, previousLabel, okLabel, isBusy = false, isSubmitting = false, disableFieldsWhileSubmitting = false, isSubmitDisabled = false, onSubmit, linear = true, orientation = 'horizontal', headerPosition = 'top', start, end, onChangeStep, pt, }) => {
|
|
59
59
|
const { messages } = useCratisComponentsConfig();
|
|
60
60
|
const stepperId = useId();
|
|
61
61
|
const resolvedNextLabel = nextLabel ?? messages?.stepper?.next ?? 'Next';
|
|
@@ -121,7 +121,7 @@ const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveSte
|
|
|
121
121
|
.filter(Boolean)
|
|
122
122
|
.join(' '), "data-cratis-part": 'panels', "data-part": 'panels', "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: panels.map((panel, index) => (jsx("section", { ...pt?.panel, hidden: index !== currentStep, className: ['cratis-command-stepper__panel', pt?.panel?.className]
|
|
123
123
|
.filter(Boolean)
|
|
124
|
-
.join(' '), "data-cratis-part": 'panel', "data-part": 'panel', "data-busy": isStepperBusy || undefined, "data-invalid": stepErrors[index] || undefined, "data-selected": index === currentStep || undefined, "data-visited": visitedSteps.has(index) || undefined, "aria-label": String(panel.props.header ?? `Step ${index + 1}`), "aria-labelledby": pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined), children: processChildren(panel.props.children) }, index))) }));
|
|
124
|
+
.join(' '), "data-cratis-part": 'panel', "data-part": 'panel', "data-busy": isStepperBusy || undefined, "data-invalid": stepErrors[index] || undefined, "data-selected": index === currentStep || undefined, "data-visited": visitedSteps.has(index) || undefined, "aria-label": String(panel.props.header ?? `Step ${index + 1}`), "aria-labelledby": pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined), children: disableFieldsWhileSubmitting ? (jsx("fieldset", { disabled: isSubmitting, inert: isSubmitting, style: { display: 'contents' }, children: processChildren(panel.props.children) })) : processChildren(panel.props.children) }, index))) }));
|
|
125
125
|
return (jsxs("div", { className: `cratis-command-stepper cratis-command-stepper--${orientation}`, "data-orientation": orientation, children: [start, jsx("div", { ...pt?.root, className: ['cratis-command-stepper__root', pt?.root?.className]
|
|
126
126
|
.filter(Boolean)
|
|
127
127
|
.join(' '), "data-cratis-part": 'root', "data-part": 'root', "data-value": currentStep, "data-orientation": orientation, "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: headerPosition === 'bottom' ? (jsxs(Fragment, { children: [stepperPanels, stepperList] })) : (jsxs(Fragment, { children: [stepperList, stepperPanels] })) }), end, showNavigation && (jsxs("div", { style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandStepperContent.js","sources":["../../../CommandDialog/CommandStepperContent.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CommandStepperContent.js","sources":["../../../CommandDialog/CommandStepperContent.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;;;;;;AA4DA,MAAM,eAAe,GAAG,CAAC,QAA+C,KAAY;IAChF,IAAI,OAAO,QAAQ,KAAK,UAAU;AAAE,QAAA,OAAO,EAAE;AAC7C,IAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;IACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,IAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC,CAAC;AAGD,MAAM,yBAAyB,GAAG,CAAC,KAAsB,KAAc;IACnE,MAAM,KAAK,GAAa,EAAE;IAC1B,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,KAAI;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AE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAA,QAAA,EAAA,CAEvB,YAAY,KACTD,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAC,wBAAwB,EAAA,aAAA,EACtB,MAAM,EAAA,CACpB,CACL,EACDA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,eAAe,EAAA,CAAQ,CAAA,EAAA,CACzB,CACZ,CAAA,EAAA,CACC,CACT,CAAA,EAAA,CACC;AAEd;;"}
|
|
@@ -2,7 +2,8 @@ import React, { type CSSProperties } from 'react';
|
|
|
2
2
|
import { type CommandFormProps } from '@cratis/arc.react/commands';
|
|
3
3
|
import { type DialogProps, type CloseDialog, type ConfirmCallback, type CancelCallback } from '../Dialogs/Dialog.js';
|
|
4
4
|
import type { StepperCustomizationProps } from './CommandStepper.js';
|
|
5
|
-
import {
|
|
5
|
+
import type { BeforeExecuteCallback } from './applyBeforeExecute.js';
|
|
6
|
+
import type { ConfirmBeforeExecute } from './confirmBeforeExecute.js';
|
|
6
7
|
/**
|
|
7
8
|
* Props for {@link StepperCommandDialog}. Combines the command-form props,
|
|
8
9
|
* the stepper customization props (`linear`, `pt`, …), and dialog-specific
|
|
@@ -29,6 +30,12 @@ export interface StepperCommandDialogProps<TCommand extends object, TResponse =
|
|
|
29
30
|
* transforms that do not affect validity (for example a generated id).
|
|
30
31
|
*/
|
|
31
32
|
onBeforeExecute?: BeforeExecuteCallback<TCommand>;
|
|
33
|
+
/**
|
|
34
|
+
* Ask before executing the transformed command values; only `true` executes.
|
|
35
|
+
* Fields are disabled from submit until the guarded submission settles. If command values change
|
|
36
|
+
* during that time, execution is skipped; confirm the new values again.
|
|
37
|
+
*/
|
|
38
|
+
confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;
|
|
32
39
|
/** Dialog title text. */
|
|
33
40
|
title: string;
|
|
34
41
|
/** Controls dialog visibility. Defaults to `true`. */
|
|
@@ -11,11 +11,11 @@ import '../renderer/RendererContext.js';
|
|
|
11
11
|
import { CommandForm, useCommandFormContext, useCommandInstance } from '@cratis/arc.react/commands';
|
|
12
12
|
import { Dialog } from '../Dialogs/Dialog.js';
|
|
13
13
|
import { CommandStepperContent } from './CommandStepperContent.js';
|
|
14
|
-
import {
|
|
14
|
+
import { useCommandExecution } from './useCommandExecution.js';
|
|
15
15
|
import { getStepPanels } from './stepChildren.js';
|
|
16
16
|
import { transitionStep } from './transitionStep.js';
|
|
17
17
|
|
|
18
|
-
const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, contentStyle, resizable = false, isValid, onClose, onConfirm, onCancel, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, okLabel, nextLabel, previousLabel, showCancel = false, cancelLabel, linear = true, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, dialogClassName, dialogPt, dialogPtOptions, dialogUnstyled, children, }) => {
|
|
18
|
+
const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', style, contentStyle, resizable = false, isValid, onClose, onConfirm, onCancel, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, okLabel, nextLabel, previousLabel, showCancel = false, cancelLabel, linear = true, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, dialogClassName, dialogPt, dialogPtOptions, dialogUnstyled, children, }) => {
|
|
19
19
|
const { messages } = useCratisComponentsConfig();
|
|
20
20
|
const stepperMessages = messages?.stepper;
|
|
21
21
|
const dialogMessages = messages?.dialog;
|
|
@@ -25,7 +25,8 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
25
25
|
const resolvedCancelLabel = cancelLabel ?? dialogMessages?.cancel ?? 'Cancel';
|
|
26
26
|
const { setCommandValues, setCommandResult, isValid: isCommandFormValid, getFieldError, } = useCommandFormContext();
|
|
27
27
|
const commandInstance = useCommandInstance();
|
|
28
|
-
const
|
|
28
|
+
const submission = useCommandExecution(commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException);
|
|
29
|
+
const isBusy = submission.isSubmitting;
|
|
29
30
|
const [activeStep, setActiveStep] = useState(0);
|
|
30
31
|
const [visitedSteps, setVisitedSteps] = useState(new Set([0]));
|
|
31
32
|
const [stepErrors, setStepErrors] = useState([]);
|
|
@@ -79,18 +80,9 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
82
|
const handleSubmit = async () => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (onBeforeExecute) {
|
|
86
|
-
const applied = applyBeforeExecute(onBeforeExecute, commandInstance);
|
|
87
|
-
setCommandValues(applied instanceof Promise ? await applied : applied);
|
|
88
|
-
}
|
|
89
|
-
result = await commandInstance.execute();
|
|
90
|
-
}
|
|
91
|
-
finally {
|
|
92
|
-
setIsBusy(false);
|
|
93
|
-
}
|
|
83
|
+
const result = await submission.run();
|
|
84
|
+
if (!result)
|
|
85
|
+
return;
|
|
94
86
|
if (!result.isSuccess) {
|
|
95
87
|
await onFailed?.(result);
|
|
96
88
|
if (result.hasExceptions) {
|
|
@@ -101,7 +93,8 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
101
93
|
if (!result.isValid) {
|
|
102
94
|
await onValidationFailure?.(result.validationResults);
|
|
103
95
|
}
|
|
104
|
-
|
|
96
|
+
if (submission.isMounted())
|
|
97
|
+
setCommandResult(result);
|
|
105
98
|
return;
|
|
106
99
|
}
|
|
107
100
|
await onSuccess?.(result.response);
|
|
@@ -113,11 +106,11 @@ const StepperCommandDialogWrapper = ({ title, visible = true, width = '600px', s
|
|
|
113
106
|
width: '100%',
|
|
114
107
|
gap: '0.75rem',
|
|
115
108
|
}, children: [showCancel && (jsx(Button, { variant: 'outline', onClick: () => handleClose(DialogResult.Cancelled), disabled: isBusy, style: { width: 'auto' }, children: jsx("span", { children: resolvedCancelLabel }) })), !isFirstStep && (jsx(Button, { variant: 'outline', onClick: () => changeStep(currentStep - 1), disabled: isBusy, style: { width: 'auto' }, children: jsx("span", { children: resolvedPreviousLabel }) })), jsx("div", { style: { flex: 1 } }), !isLastStep && (jsx(Button, { onClick: () => changeStep(currentStep + 1), disabled: isBusy || isCurrentStepInvalid, style: { width: 'auto' }, children: jsx("span", { children: resolvedNextLabel }) })), isLastStep && isDialogValid && (jsxs(Button, { onClick: handleSubmit, disabled: isBusy, autoFocus: true, style: { width: 'auto' }, children: [isBusy && (jsx("span", { className: 'cratis-dialog__spinner', "aria-hidden": 'true' })), jsx("span", { children: resolvedOkLabel })] }))] }));
|
|
116
|
-
return (jsx(Dialog, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, dismissable: !isBusy, buttons: footer, onCancel: onCancel, onClose: onClose, 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, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
|
|
109
|
+
return (jsx(Dialog, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, dismissable: !isBusy, buttons: footer, onCancel: onCancel, onClose: onClose, 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, isSubmitting: confirmBeforeExecute !== undefined && isBusy, disableFieldsWhileSubmitting: confirmBeforeExecute !== undefined, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, children: children }) }));
|
|
117
110
|
};
|
|
118
111
|
const StepperCommandDialogComponent = (props) => {
|
|
119
|
-
const { title, visible, width, style, contentStyle, resizable, isValid, onClose, onConfirm, onCancel, onBeforeExecute, okLabel, nextLabel, previousLabel, showCancel, cancelLabel, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, dialogClassName, dialogPt, dialogPtOptions, dialogUnstyled, children, ...commandFormProps } = props;
|
|
120
|
-
return (jsx(CommandForm, { ...commandFormProps, children: jsx(StepperCommandDialogWrapper, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, okLabel: okLabel, nextLabel: nextLabel, previousLabel: previousLabel, showCancel: showCancel, cancelLabel: cancelLabel, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, dialogClassName: dialogClassName, dialogPt: dialogPt, dialogPtOptions: dialogPtOptions, dialogUnstyled: dialogUnstyled, children: children }) }));
|
|
112
|
+
const { title, visible, width, style, contentStyle, resizable, isValid, onClose, onConfirm, onCancel, onBeforeExecute, confirmBeforeExecute, okLabel, nextLabel, previousLabel, showCancel, cancelLabel, linear, orientation, headerPosition, start, end, onChangeStep, pt, ptOptions, unstyled, dialogClassName, dialogPt, dialogPtOptions, dialogUnstyled, children, ...commandFormProps } = props;
|
|
113
|
+
return (jsx(CommandForm, { ...commandFormProps, children: jsx(StepperCommandDialogWrapper, { title: title, visible: visible, width: width, style: style, contentStyle: contentStyle, resizable: resizable, isValid: isValid, onClose: onClose, onConfirm: onConfirm, onCancel: onCancel, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, okLabel: okLabel, nextLabel: nextLabel, previousLabel: previousLabel, showCancel: showCancel, cancelLabel: cancelLabel, linear: linear, orientation: orientation, headerPosition: headerPosition, start: start, end: end, onChangeStep: onChangeStep, pt: pt, ptOptions: ptOptions, unstyled: unstyled, dialogClassName: dialogClassName, dialogPt: dialogPt, dialogPtOptions: dialogPtOptions, dialogUnstyled: dialogUnstyled, children: children }) }));
|
|
121
114
|
};
|
|
122
115
|
const StepperCommandDialog = StepperCommandDialogComponent;
|
|
123
116
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StepperCommandDialog.js","sources":["../../../CommandDialog/StepperCommandDialog.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;AAuJA,MAAM,2BAA2B,GAAG,CAA8C,EAC9E,KAAK,EACL,OAAO,GAAG,IAAI,EACd,KAAK,GAAG,OAAO,EACf,KAAK,EACL,YAAY,EACZ,SAAS,GAAG,KAAK,EACjB,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,aAAa,EACb,UAAU,GAAG,KAAK,EAClB,WAAW,EACX,MAAM,GAAG,IAAI,EACb,WAAW,EACX,cAAc,EACd,KAAK,EACL,GAAG,EACH,YAAY,EACZ,EAAE,EACF,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,cAAc,EACd,QAAQ,GAC4C,KAAI;AACxD,IAAA,MAAM,EAAE,QAAQ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
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Capture only the properties Arc will send, before an asynchronous confirmation can change them. */
|
|
2
|
+
export declare const snapshotCommandValues: (command: object) => Record<string, string>;
|
|
3
|
+
/** A changed form value invalidates approval, even if it is nested in a command property. */
|
|
4
|
+
export declare const commandValuesUnchanged: (command: object, snapshot: Record<string, string>) => boolean;
|
|
5
|
+
//# sourceMappingURL=commandValuesUnchanged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandValuesUnchanged.d.ts","sourceRoot":"","sources":["../../../CommandDialog/commandValuesUnchanged.ts"],"names":[],"mappings":"AAQA,sGAAsG;AACtG,eAAO,MAAM,qBAAqB,YAAa,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ5E,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,sBAAsB,YAAa,MAAM,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,OAM1F,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { JsonSerializer } from '@cratis/fundamentals';
|
|
2
|
+
|
|
3
|
+
const serializeProperty = (name, value) => JsonSerializer.serialize({ [name]: value });
|
|
4
|
+
const snapshotCommandValues = (command) => {
|
|
5
|
+
const instance = command;
|
|
6
|
+
const values = command;
|
|
7
|
+
const snapshot = {};
|
|
8
|
+
for (const { name } of instance.propertyDescriptors ?? []) {
|
|
9
|
+
snapshot[name] = serializeProperty(name, values[name]);
|
|
10
|
+
}
|
|
11
|
+
return snapshot;
|
|
12
|
+
};
|
|
13
|
+
const commandValuesUnchanged = (command, snapshot) => {
|
|
14
|
+
const instance = command;
|
|
15
|
+
const values = command;
|
|
16
|
+
const descriptors = instance.propertyDescriptors ?? [];
|
|
17
|
+
return descriptors.length === Object.keys(snapshot).length &&
|
|
18
|
+
descriptors.every(({ name }) => Object.hasOwn(snapshot, name) && snapshot[name] === serializeProperty(name, values[name]));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { commandValuesUnchanged, snapshotCommandValues };
|
|
22
|
+
//# sourceMappingURL=commandValuesUnchanged.js.map
|