@wise/dynamic-flow-client 3.7.0 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.mjs
CHANGED
|
@@ -1193,6 +1193,7 @@ var debounce = (callback, waitMs) => {
|
|
|
1193
1193
|
clearTimer();
|
|
1194
1194
|
}
|
|
1195
1195
|
};
|
|
1196
|
+
debouncedFn.isPending = () => timeoutId !== null;
|
|
1196
1197
|
return debouncedFn;
|
|
1197
1198
|
};
|
|
1198
1199
|
|
|
@@ -3672,7 +3673,8 @@ var _FormControl = class _FormControl extends PureComponent {
|
|
|
3672
3673
|
SelectInputOptionContent2,
|
|
3673
3674
|
{
|
|
3674
3675
|
title: label2,
|
|
3675
|
-
note: note != null ? note : secondary,
|
|
3676
|
+
note: withinTrigger ? note != null ? note : secondary : note,
|
|
3677
|
+
description: withinTrigger ? void 0 : secondary,
|
|
3676
3678
|
icon: withinTrigger && hideIconInTrigger ? void 0 : icon
|
|
3677
3679
|
}
|
|
3678
3680
|
),
|
|
@@ -3807,7 +3809,7 @@ var _FormControl = class _FormControl extends PureComponent {
|
|
|
3807
3809
|
monthFormat,
|
|
3808
3810
|
disabled,
|
|
3809
3811
|
onChange: (date) => {
|
|
3810
|
-
this.handleOnChange(dateToDateString(date));
|
|
3812
|
+
this.handleOnChange(date !== null ? dateToDateString(date) : null);
|
|
3811
3813
|
},
|
|
3812
3814
|
onBlur: this.handleOnBlur,
|
|
3813
3815
|
onFocus: this.handleOnFocus
|
|
@@ -6748,13 +6750,22 @@ function useDebouncedRefresh(fetchRefresh) {
|
|
|
6748
6750
|
map.current.set(key, debouncedFetchRefresh);
|
|
6749
6751
|
return debouncedFetchRefresh;
|
|
6750
6752
|
};
|
|
6751
|
-
|
|
6753
|
+
const debouncedRefresh = (url, data, etag, schema) => {
|
|
6752
6754
|
const debouncedFetchRefresh = retrieveOrCreate(url);
|
|
6753
6755
|
debouncedFetchRefresh(url, data, etag);
|
|
6754
6756
|
if (!schema || !shouldDebounceSchema(schema)) {
|
|
6755
6757
|
debouncedFetchRefresh.flush();
|
|
6756
6758
|
}
|
|
6757
6759
|
};
|
|
6760
|
+
const cancelPendingRefreshes = () => {
|
|
6761
|
+
map.current.forEach((debouncedFetchRefresh) => {
|
|
6762
|
+
debouncedFetchRefresh.cancel();
|
|
6763
|
+
});
|
|
6764
|
+
};
|
|
6765
|
+
const isDebouncing = Array.from(map.current.values()).some(
|
|
6766
|
+
(debouncedFunction) => debouncedFunction.isPending()
|
|
6767
|
+
);
|
|
6768
|
+
return { debouncedRefresh, isDebouncing, cancelPendingRefreshes };
|
|
6758
6769
|
}
|
|
6759
6770
|
var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && schema.type !== "boolean" && schema.format !== "base64url";
|
|
6760
6771
|
|
|
@@ -7113,6 +7124,7 @@ var DynamicFlowComponent = ({
|
|
|
7113
7124
|
[httpClient, locale]
|
|
7114
7125
|
);
|
|
7115
7126
|
const performAction = async (action, data = {}) => {
|
|
7127
|
+
cancelPendingRefreshes();
|
|
7116
7128
|
setLoadingState(!step ? "initial" : "submission");
|
|
7117
7129
|
dispatchEvent("Dynamic Flow - Step Submitted", { actionId: action.id || action.$id });
|
|
7118
7130
|
try {
|
|
@@ -7130,6 +7142,7 @@ var DynamicFlowComponent = ({
|
|
|
7130
7142
|
}
|
|
7131
7143
|
};
|
|
7132
7144
|
const performRefresh = async (url, data, etag2) => {
|
|
7145
|
+
cancelPendingRefreshes();
|
|
7133
7146
|
setLoadingState("refresh");
|
|
7134
7147
|
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "pending" });
|
|
7135
7148
|
try {
|
|
@@ -7143,7 +7156,7 @@ var DynamicFlowComponent = ({
|
|
|
7143
7156
|
const exitResult = await getJsonObjectOrNull(response);
|
|
7144
7157
|
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
7145
7158
|
};
|
|
7146
|
-
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
7159
|
+
const { debouncedRefresh, isDebouncing, cancelPendingRefreshes } = useDebouncedRefresh(performRefresh);
|
|
7147
7160
|
const dispatchEventAndComplete = useCallback9(
|
|
7148
7161
|
(result) => {
|
|
7149
7162
|
dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
|
|
@@ -7251,7 +7264,7 @@ var DynamicFlowComponent = ({
|
|
|
7251
7264
|
}
|
|
7252
7265
|
};
|
|
7253
7266
|
const onAction = async (action) => {
|
|
7254
|
-
if (isLoading || action.disabled) {
|
|
7267
|
+
if (isLoading || isDebouncing || action.disabled) {
|
|
7255
7268
|
return;
|
|
7256
7269
|
}
|
|
7257
7270
|
if (action.exit && !action.url) {
|
|
@@ -7272,7 +7285,7 @@ var DynamicFlowComponent = ({
|
|
|
7272
7285
|
await performAction(action);
|
|
7273
7286
|
}
|
|
7274
7287
|
};
|
|
7275
|
-
return /* @__PURE__ */ jsx72(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ jsx72(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ jsx72(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ jsx72(HttpClientProvider, { httpClient, children: /* @__PURE__ */ jsx72(FeatureContextProvider, { features, children: loader !== null ? loader : /* @__PURE__ */ jsx72(
|
|
7288
|
+
return /* @__PURE__ */ jsx72(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ jsx72(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ jsx72(DynamicFlowProvider, { loading: isLoading || isDebouncing, children: /* @__PURE__ */ jsx72(HttpClientProvider, { httpClient, children: /* @__PURE__ */ jsx72(FeatureContextProvider, { features, children: loader !== null ? loader : /* @__PURE__ */ jsx72(
|
|
7276
7289
|
DynamicFlowStep,
|
|
7277
7290
|
{
|
|
7278
7291
|
step,
|
|
@@ -8510,7 +8523,7 @@ function VariableDateInput({
|
|
|
8510
8523
|
placeholder,
|
|
8511
8524
|
disabled,
|
|
8512
8525
|
onChange: (date) => {
|
|
8513
|
-
onChange(dateToDateString2(date));
|
|
8526
|
+
onChange(date !== null ? dateToDateString2(date) : null);
|
|
8514
8527
|
},
|
|
8515
8528
|
onBlur,
|
|
8516
8529
|
onFocus
|
|
@@ -2,5 +2,6 @@ export interface DebouncedFunc<T extends (...args: Parameters<T>) => ReturnType<
|
|
|
2
2
|
(...args: Parameters<T>): void;
|
|
3
3
|
cancel: () => void;
|
|
4
4
|
flush: () => void;
|
|
5
|
+
isPending: () => boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare const debounce: <T extends (...args: Parameters<T>) => ReturnType<T>>(callback: T, waitMs: number) => DebouncedFunc<T>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Schema } from '@wise/dynamic-flow-types';
|
|
2
2
|
type FetchRefresh = (url: string, data: unknown, etag: string | undefined) => Promise<void | null>;
|
|
3
|
-
export declare function useDebouncedRefresh(fetchRefresh: FetchRefresh):
|
|
3
|
+
export declare function useDebouncedRefresh(fetchRefresh: FetchRefresh): {
|
|
4
|
+
debouncedRefresh: (url: string, data: unknown, etag: string | undefined, schema: Schema) => void;
|
|
5
|
+
isDebouncing: boolean;
|
|
6
|
+
cancelPendingRefreshes: () => void;
|
|
7
|
+
};
|
|
4
8
|
export declare const shouldDebounceSchema: (schema: Schema) => boolean;
|
|
5
9
|
export {};
|