@cratis/components 4.15.1 → 4.17.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/Canvas/Canvas.d.ts +9 -2
- package/dist/esm/Canvas/Canvas.js +2 -2
- package/dist/esm/Canvas/Canvas.js.map +1 -1
- package/dist/esm/Canvas/CanvasControls.d.ts +22 -0
- package/dist/esm/Canvas/CanvasControls.js +10 -6
- package/dist/esm/Canvas/CanvasControls.js.map +1 -1
- package/dist/esm/Canvas/index.d.ts +1 -1
- 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
|
@@ -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,SAAS,EACT,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,GAC0B,KAAI;AAClD,IAAA,MAAM,EACF,aAAa,EACb,OAAO,EAAE,kBAAkB,EAC3B,gBAAgB,EAChB,gBAAgB,GACnB,GAAG,qBAAqB,EAAY;AACrC,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC/C,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAc,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAClC,eAAe,EAAE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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;AACpC,QAAA,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;YAAE;AAClC,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,QAAA,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE;AAC/B,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,EAAE;YAC7B,KAAK,CAAC,IAAI,CACN,GAAG,yBAAyB,CAAC,U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E,MAAM,EAChB,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAExBA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,qBAAqB,EAAA,CAAQ,EAAA,CAC/B,CACZ,EACDA,aAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAA,CAAI,EAC1B,CAAC,UAAU,KACRA,GAAA,CAAC,MAAM,EAAA,EACH,OAAO,EAAE,MAAM,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,EAC1C,QAAQ,EAAE,MAAM,IAAI,YAAY,IAAI,oBAAoB,EACxD,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAExBA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,iBAAiB,EAAA,CAAQ,EAAA,CAC3B,CACZ,EACA,UAAU,IAAI,UAAU,KACrBC,IAAA,CAAC,MAAM,IACH,OAAO,EAAE,MAAM,KAAK,QAAQ,IAAI,EAChC,QAAQ,EACJ,MAAM;4BACN,YAAY;4BACZ,gBAAgB;AAChB,4BAAA,gBAAgB,EAEpB,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,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,EAAE,GAAG,yBAAyB,EAAE;AAChD,IAAA,MAAM,eAAe,GAAG,QAAQ,EAAE,OAAO;AACzC,IAAA,MAAM,cAAc,GAAG,QAAQ,EAAE,MAAM;IACvC,MAAM,eAAe,GAAG,OAAO,IAAI,eAAe,EAAE,MAAM,IAAI,QAAQ;IACtE,MAAM,iBAAiB,GAAG,SAAS,IAAI,eAAe,EAAE,IAAI,IAAI,MAAM;IACtE,MAAM,qBAAqB,GACvB,aAAa,IAAI,eAAe,EAAE,QAAQ,IAAI,UAAU;IAC5D,MAAM,mBAAmB,GAAG,WAAW,IAAI,cAAc,EAAE,MAAM,IAAI,QAAQ;AAC7E,IAAA,MAAM,EACF,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EAAE,kBAAkB,EAC3B,aAAa,GAChB,GAAG,qBAAqB,EAAY;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AAC,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,EAC1C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,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,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAA,QAAA,EAE7B,QAAQ,EAAA,CACiB,EAAA,CACpB;AAEtB,CAAC;AAgBM,MAAM,oBAAoB,GAAG;;"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandValuesUnchanged.js","sources":["../../../CommandDialog/commandValuesUnchanged.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAMA,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,KAAc,KAAa,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;AAGxG,MAAM,qBAAqB,GAAG,CAAC,OAAe,KAA4B;IAC7E,MAAM,QAAQ,GAAG,OAAsD;IACvE,MAAM,MAAM,GAAG,OAAkC;IACjD,MAAM,QAAQ,GAA2B,EAAE;IAC3C,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC,mBAAmB,IAAI,EAAE,EAAE;AACvD,QAAA,QAAQ,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1D;AACA,IAAA,OAAO,QAAQ;AACnB;MAGa,sBAAsB,GAAG,CAAC,OAAe,EAAE,QAAgC,KAAa;IACjG,MAAM,QAAQ,GAAG,OAAsD;IACvE,MAAM,MAAM,GAAG,OAAkC;AACjD,IAAA,MAAM,WAAW,GAAG,QAAQ,CAAC,mBAAmB,IAAI,EAAE;IACtD,OAAO,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM;AACtD,QAAA,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAClI;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Receives values after onBeforeExecute; only `true` approves execution.
|
|
3
|
+
* If command property values change while confirmation is pending, approval is
|
|
4
|
+
* discarded without executing or reporting a result. Confirm the new values again.
|
|
5
|
+
*/
|
|
6
|
+
export type ConfirmBeforeExecute<TCommand> = (values: TCommand) => boolean | Promise<boolean>;
|
|
7
|
+
/** Report a rejected guard through the same exception callback used for command failures. */
|
|
8
|
+
export declare const reportConfirmationError: (error: unknown, onException?: (messages: string[], stackTrace: string) => void | Promise<void>) => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=confirmBeforeExecute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmBeforeExecute.d.ts","sourceRoot":"","sources":["../../../CommandDialog/confirmBeforeExecute.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,QAAQ,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9F,6FAA6F;AAC7F,eAAO,MAAM,uBAAuB,UACzB,OAAO,gBACA,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,kBAQjF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const reportConfirmationError = async (error, onException) => {
|
|
2
|
+
const exception = error instanceof Error ? error : new Error(String(error));
|
|
3
|
+
if (onException) {
|
|
4
|
+
await onException([exception.message], exception.stack ?? '');
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
console.error(exception);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { reportConfirmationError };
|
|
12
|
+
//# sourceMappingURL=confirmBeforeExecute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmBeforeExecute.js","sources":["../../../CommandDialog/confirmBeforeExecute.ts"],"sourcesContent":[null],"names":[],"mappings":"AAWO,MAAM,uBAAuB,GAAG,OACnC,KAAc,EACd,WAA8E,KAC9E;IACA,MAAM,SAAS,GAAG,KAAK,YAAY,KAAK,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3E,IAAI,WAAW,EAAE;AACb,QAAA,MAAM,WAAW,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC;IACjE;SAAO;AACH,QAAA,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;IAC5B;AACJ;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ICommandResult } from '@cratis/arc/commands';
|
|
2
|
+
import { type BeforeExecuteCallback } from './applyBeforeExecute.js';
|
|
3
|
+
import { type ConfirmBeforeExecute } from './confirmBeforeExecute.js';
|
|
4
|
+
/** Owns one submission from transform through execution, releasing busy before result callbacks. */
|
|
5
|
+
export declare const useCommandExecution: <TCommand extends object, TResponse>(commandInstance: TCommand, setCommandValues: (values: TCommand) => void, onBeforeExecute?: BeforeExecuteCallback<TCommand>, confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>, onException?: (messages: string[], stackTrace: string) => void | Promise<void>) => {
|
|
6
|
+
run: () => Promise<ICommandResult<TResponse> | undefined>;
|
|
7
|
+
isSubmitting: boolean;
|
|
8
|
+
isMounted: () => boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { applyBeforeExecute } from './applyBeforeExecute.js';
|
|
2
|
+
import { reportConfirmationError } from './confirmBeforeExecute.js';
|
|
3
|
+
import { snapshotCommandValues, commandValuesUnchanged } from './commandValuesUnchanged.js';
|
|
4
|
+
import { useSubmissionFlight } from './useSubmissionFlight.js';
|
|
5
|
+
|
|
6
|
+
const useCommandExecution = (commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException) => {
|
|
7
|
+
const submission = useSubmissionFlight();
|
|
8
|
+
const run = async () => {
|
|
9
|
+
if (!submission.begin(confirmBeforeExecute !== undefined))
|
|
10
|
+
return undefined;
|
|
11
|
+
let confirmationError;
|
|
12
|
+
let result;
|
|
13
|
+
try {
|
|
14
|
+
let values = commandInstance;
|
|
15
|
+
if (onBeforeExecute) {
|
|
16
|
+
const applied = applyBeforeExecute(onBeforeExecute, commandInstance);
|
|
17
|
+
values = applied instanceof Promise ? await applied : applied;
|
|
18
|
+
setCommandValues(values);
|
|
19
|
+
}
|
|
20
|
+
if (confirmBeforeExecute) {
|
|
21
|
+
let approved = false;
|
|
22
|
+
let valuesUnchanged = false;
|
|
23
|
+
try {
|
|
24
|
+
const approvedValues = snapshotCommandValues(commandInstance);
|
|
25
|
+
approved = await confirmBeforeExecute(values);
|
|
26
|
+
if (submission.isMounted() && approved === true) {
|
|
27
|
+
valuesUnchanged = commandValuesUnchanged(commandInstance, approvedValues);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
confirmationError = { error };
|
|
32
|
+
}
|
|
33
|
+
if (confirmationError === undefined &&
|
|
34
|
+
(!submission.isMounted() || approved !== true || !valuesUnchanged))
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (confirmationError === undefined) {
|
|
38
|
+
result = await commandInstance.execute();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
submission.finish();
|
|
43
|
+
}
|
|
44
|
+
if (confirmationError)
|
|
45
|
+
await reportConfirmationError(confirmationError.error, onException);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
return { run, isSubmitting: submission.isSubmitting, isMounted: submission.isMounted };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { useCommandExecution };
|
|
52
|
+
//# sourceMappingURL=useCommandExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommandExecution.js","sources":["../../../CommandDialog/useCommandExecution.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUO,MAAM,mBAAmB,GAAG,CAC/B,eAAyB,EACzB,gBAA4C,EAC5C,eAAiD,EACjD,oBAAqD,EACrD,WAA8E,KAC9E;AACA,IAAA,MAAM,UAAU,GAAG,mBAAmB,EAAE;AAExC,IAAA,MAAM,GAAG,GAAG,YAA2D;QACnE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,CAAC;AAAE,YAAA,OAAO,SAAS;AAC3E,QAAA,IAAI,iBAAiD;AACrD,QAAA,IAAI,MAA6C;AACjD,QAAA,IAAI;YACA,IAAI,MAAM,GAAG,eAAe;YAC5B,IAAI,eAAe,EAAE;gBACjB,MAAM,OAAO,GAAG,kBAAkB,CAAC,eAAe,EAAE,eAAe,CAAC;AACpE,gBA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|
|
3
|
+
isSubmitting: boolean;
|
|
4
|
+
begin: (exclusive: boolean) => boolean;
|
|
5
|
+
finish: () => void;
|
|
6
|
+
isMounted: () => boolean;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useSubmissionFlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubmissionFlight.d.ts","sourceRoot":"","sources":["../../../CommandDialog/useSubmissionFlight.ts"],"names":[],"mappings":"AAMA,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB;;uBAUF,OAAO;;;CAepC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { flushSync } from 'react-dom';
|
|
3
|
+
|
|
4
|
+
const useSubmissionFlight = () => {
|
|
5
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
|
+
const inFlight = useRef(false);
|
|
7
|
+
const mounted = useRef(true);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
mounted.current = true;
|
|
10
|
+
return () => { mounted.current = false; };
|
|
11
|
+
}, []);
|
|
12
|
+
const begin = (exclusive) => {
|
|
13
|
+
if (exclusive && (!mounted.current || inFlight.current))
|
|
14
|
+
return false;
|
|
15
|
+
if (exclusive)
|
|
16
|
+
inFlight.current = true;
|
|
17
|
+
if (mounted.current)
|
|
18
|
+
setIsSubmitting(true);
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
const finish = () => {
|
|
22
|
+
inFlight.current = false;
|
|
23
|
+
if (mounted.current)
|
|
24
|
+
flushSync(() => setIsSubmitting(false));
|
|
25
|
+
};
|
|
26
|
+
return { isSubmitting, begin, finish, isMounted: () => mounted.current };
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { useSubmissionFlight };
|
|
30
|
+
//# sourceMappingURL=useSubmissionFlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubmissionFlight.js","sources":["../../../CommandDialog/useSubmissionFlight.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAOO,MAAM,mBAAmB,GAAG,MAAK;IACpC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACvD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9B,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;IAE5B,SAAS,CAAC,MAAK;AACX,QAAA,OAAO,CAAC,OAAO,GAAG,IAAI;QACtB,OAAO,MAAK,EAAG,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,KAAK,GAAG,CAAC,SAAkB,KAAI;QACjC,IAAI,SAAS,KAAK,CAAC,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC;AAAE,YAAA,OAAO,KAAK;AACrE,QAAA,IAAI,SAAS;AAAE,YAAA,QAAQ,CAAC,OAAO,GAAG,IAAI;QACtC,IAAI,OAAO,CAAC,OAAO;YAAE,eAAe,CAAC,IAAI,CAAC;AAC1C,QAAA,OAAO,IAAI;AACf,IAAA,CAAC;IAED,MAAM,MAAM,GAAG,MAAK;AAChB,QAAA,QAAQ,CAAC,OAAO,GAAG,KAAK;QAGxB,IAAI,OAAO,CAAC,OAAO;YAAE,SAAS,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,CAAC;AAChE,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE;AAC5E;;"}
|
|
@@ -48,6 +48,8 @@ const DatePickerInputImplementation = ({ value, onChange, onBlur, invalid, disab
|
|
|
48
48
|
const effectiveDisabled = disabled ?? pt?.input?.disabled ?? false;
|
|
49
49
|
const effectiveReadOnly = readOnly ?? pt?.input?.readOnly ?? false;
|
|
50
50
|
const effectiveInvalid = invalid ?? pt?.input?.['aria-invalid'] ?? false;
|
|
51
|
+
const actionsDisabled = effectiveDisabled || effectiveReadOnly;
|
|
52
|
+
const clearDisabled = actionsDisabled || pt?.clear?.disabled || false;
|
|
51
53
|
const effectivePlaceholder = placeholder ?? pt?.input?.placeholder;
|
|
52
54
|
const effectiveAriaLabel = ariaLabel ??
|
|
53
55
|
pt?.input?.['aria-label'] ??
|
|
@@ -69,7 +71,10 @@ const DatePickerInputImplementation = ({ value, onChange, onBlur, invalid, disab
|
|
|
69
71
|
'aria-describedby': undefined,
|
|
70
72
|
'aria-invalid': undefined,
|
|
71
73
|
};
|
|
72
|
-
return (jsx("div", { ...pt?.root, className: rootClassName, style: { ...pt?.root?.style, ...style }, "data-cratis-part": 'root', "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled || undefined, "data-readonly": effectiveReadOnly || undefined, "data-open": isPickerOpen || undefined, "data-selected": value !== null || undefined, onBlur: onBlur, children: jsx(UNSAFE_PortalProvider, { getContainer: overlayEnvironment.getContainer, children: jsx(DatePicker, { value: asDateValue(value, showTime), onChange: (next) => onChange(asDate(next), { source: 'user' }), isDisabled: effectiveDisabled, isReadOnly: effectiveReadOnly, isInvalid: effectiveInvalid,
|
|
74
|
+
return (jsx("div", { ...pt?.root, className: rootClassName, style: { ...pt?.root?.style, ...style }, "data-cratis-part": 'root', "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled || undefined, "data-readonly": effectiveReadOnly || undefined, "data-open": isPickerOpen || undefined, "data-selected": value !== null || undefined, onBlur: onBlur, children: jsx(UNSAFE_PortalProvider, { getContainer: overlayEnvironment.getContainer, children: jsx(DatePicker, { value: asDateValue(value, showTime), onChange: (next) => onChange(asDate(next), { source: 'user' }), isDisabled: effectiveDisabled, isReadOnly: effectiveReadOnly, isInvalid: effectiveInvalid, isOpen: isPickerOpen, onOpenChange: (nextIsOpen) => {
|
|
75
|
+
if (!nextIsOpen || !effectiveReadOnly)
|
|
76
|
+
setIsPickerOpen(nextIsOpen);
|
|
77
|
+
}, minValue: minValue, maxValue: maxValue, granularity: showTime ? 'minute' : 'day', hourCycle: hourFormat === '12' ? 12 : hourFormat === '24' ? 24 : undefined, "aria-label": effectiveAriaLabel, "aria-labelledby": effectiveAriaLabelledby, "aria-describedby": effectiveAriaDescribedby, className: 'cratis-date-picker__picker', children: ({ isOpen }) => (jsxs(Fragment, { children: [jsxs(Group, { ...pt?.group, id: inputId, "aria-invalid": effectiveInvalid || undefined, className: classNames('cratis-date-picker__group', pt?.group?.className), "data-cratis-part": 'group', "data-empty": value === null || undefined, render: (groupProps) => (jsx("div", { ...groupProps, "data-open": isOpen || undefined, "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled || undefined, "data-readonly": effectiveReadOnly || undefined, "data-selected": value !== null || undefined })), children: [jsx(DateInput, { ...inputPartAttributes, className: classNames('cratis-date-picker__input', pt?.input?.className), style: pt?.input?.style, "data-cratis-part": 'input', "data-placeholder": effectivePlaceholder, render: (inputProps) => (jsx("div", { ...inputProps, "data-open": isOpen || undefined, "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled || undefined, "data-readonly": effectiveReadOnly || undefined, "data-selected": value !== null || undefined })), children: (segment) => (jsx(DateSegment, { ...pt?.segment, segment: segment, className: classNames('cratis-date-picker__segment', pt?.segment?.className), "data-cratis-part": 'segment', render: (segmentProps) => (jsx("span", { ...segmentProps, "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled || undefined, "data-readonly": effectiveReadOnly || undefined })) })) }), value === null && effectivePlaceholder && (jsx("span", { ...pt?.placeholder, className: classNames('cratis-date-picker__placeholder', pt?.placeholder?.className), "data-cratis-part": 'placeholder', "aria-hidden": 'true', children: effectivePlaceholder })), showIcon && (jsx(Button, { ...asReactAriaButtonProps(pt?.trigger), isDisabled: effectiveDisabled || effectiveReadOnly, className: classNames('cratis-date-picker__trigger', pt?.trigger?.className), "data-cratis-part": 'trigger', render: (triggerProps) => (jsx("button", { ...triggerProps, "data-open": isOpen || undefined, "data-invalid": effectiveInvalid || undefined, "data-disabled": effectiveDisabled ||
|
|
73
78
|
effectiveReadOnly ||
|
|
74
79
|
undefined, "data-readonly": effectiveReadOnly || undefined, "data-selected": value !== null || undefined })), "aria-label": pt?.trigger?.['aria-label'] ??
|
|
75
80
|
datePickerMessages?.openCalendar ??
|
|
@@ -80,17 +85,21 @@ const DatePickerInputImplementation = ({ value, onChange, onBlur, invalid, disab
|
|
|
80
85
|
datePickerMessages?.previousMonth ??
|
|
81
86
|
'Previous month', children: jsx("span", { "aria-hidden": 'true', children: icon('previous', '‹') }) }), jsx(Heading, { ...pt?.heading, className: classNames('cratis-date-picker__heading', pt?.heading?.className), "data-cratis-part": 'heading' }), jsx(Button, { ...asReactAriaButtonProps(pt?.next), slot: 'next', className: classNames('cratis-date-picker__nav', pt?.next?.className), "data-cratis-part": 'next', "aria-label": pt?.next?.['aria-label'] ??
|
|
82
87
|
datePickerMessages?.nextMonth ??
|
|
83
|
-
'Next month', children: jsx("span", { "aria-hidden": 'true', children: icon('next', '›') }) })] }), jsxs(CalendarGrid, { ...pt?.grid, className: classNames('cratis-date-picker__grid', pt?.grid?.className), "data-cratis-part": 'grid', children: [jsx(CalendarGridHeader, { children: (day) => (jsx(CalendarHeaderCell, { children: day })) }), jsx(CalendarGridBody, { children: (date) => (jsx(CalendarCell, { ...pt?.cell, date: date, className: classNames('cratis-date-picker__cell', pt?.cell?.className), "data-cratis-part": 'cell' })) })] })] }), showButtonBar && (jsxs("div", { ...pt?.buttonBar, className: classNames('cratis-date-picker__button-bar', pt?.buttonBar?.className), "data-cratis-part": 'button-bar', children: [jsx("button", { ...pt?.today, type: 'button', className: classNames('cratis-date-picker__action', pt?.today?.className), "data-cratis-part": 'today', "data-disabled": isTodayOutOfBounds || undefined, disabled: isTodayOutOfBounds, "aria-disabled": isTodayOutOfBounds || undefined, onClick: (event) => {
|
|
84
|
-
if (isTodayOutOfBounds)
|
|
88
|
+
'Next month', children: jsx("span", { "aria-hidden": 'true', children: icon('next', '›') }) })] }), jsxs(CalendarGrid, { ...pt?.grid, className: classNames('cratis-date-picker__grid', pt?.grid?.className), "data-cratis-part": 'grid', children: [jsx(CalendarGridHeader, { children: (day) => (jsx(CalendarHeaderCell, { children: day })) }), jsx(CalendarGridBody, { children: (date) => (jsx(CalendarCell, { ...pt?.cell, date: date, className: classNames('cratis-date-picker__cell', pt?.cell?.className), "data-cratis-part": 'cell' })) })] })] }), showButtonBar && (jsxs("div", { ...pt?.buttonBar, className: classNames('cratis-date-picker__button-bar', pt?.buttonBar?.className), "data-cratis-part": 'button-bar', children: [jsx("button", { ...pt?.today, type: 'button', className: classNames('cratis-date-picker__action', pt?.today?.className), "data-cratis-part": 'today', "data-disabled": actionsDisabled || isTodayOutOfBounds || undefined, disabled: actionsDisabled || isTodayOutOfBounds, "aria-disabled": actionsDisabled || isTodayOutOfBounds || undefined, onClick: (event) => {
|
|
89
|
+
if (actionsDisabled || isTodayOutOfBounds)
|
|
85
90
|
return;
|
|
86
91
|
onChange(todayDate, {
|
|
87
92
|
source: 'user',
|
|
88
93
|
nativeEvent: event.nativeEvent,
|
|
89
94
|
});
|
|
90
|
-
}, children: resolvedTodayLabel }), jsx("button", { ...pt?.clear, type: 'button', className: classNames('cratis-date-picker__action', pt?.clear?.className), "data-cratis-part": 'clear', onClick: (event) =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
}, children: resolvedTodayLabel }), jsx("button", { ...pt?.clear, type: 'button', className: classNames('cratis-date-picker__action', pt?.clear?.className), "data-cratis-part": 'clear', "data-disabled": clearDisabled || undefined, disabled: clearDisabled, "aria-disabled": clearDisabled || pt?.clear?.['aria-disabled'] || undefined, onClick: (event) => {
|
|
96
|
+
if (clearDisabled)
|
|
97
|
+
return;
|
|
98
|
+
onChange(null, {
|
|
99
|
+
source: 'user',
|
|
100
|
+
nativeEvent: event.nativeEvent,
|
|
101
|
+
});
|
|
102
|
+
}, children: resolvedClearLabel })] }))] }) })] })) }) }) }));
|
|
94
103
|
};
|
|
95
104
|
|
|
96
105
|
export { DatePickerInputImplementation };
|