@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.js CHANGED
@@ -1214,6 +1214,7 @@ var debounce = (callback, waitMs) => {
1214
1214
  clearTimer();
1215
1215
  }
1216
1216
  };
1217
+ debouncedFn.isPending = () => timeoutId !== null;
1217
1218
  return debouncedFn;
1218
1219
  };
1219
1220
 
@@ -3678,7 +3679,8 @@ var _FormControl = class _FormControl extends import_react18.PureComponent {
3678
3679
  import_components15.SelectInputOptionContent,
3679
3680
  {
3680
3681
  title: label2,
3681
- note: note != null ? note : secondary,
3682
+ note: withinTrigger ? note != null ? note : secondary : note,
3683
+ description: withinTrigger ? void 0 : secondary,
3682
3684
  icon: withinTrigger && hideIconInTrigger ? void 0 : icon
3683
3685
  }
3684
3686
  ),
@@ -3813,7 +3815,7 @@ var _FormControl = class _FormControl extends import_react18.PureComponent {
3813
3815
  monthFormat,
3814
3816
  disabled,
3815
3817
  onChange: (date) => {
3816
- this.handleOnChange(dateToDateString(date));
3818
+ this.handleOnChange(date !== null ? dateToDateString(date) : null);
3817
3819
  },
3818
3820
  onBlur: this.handleOnBlur,
3819
3821
  onFocus: this.handleOnFocus
@@ -6754,13 +6756,22 @@ function useDebouncedRefresh(fetchRefresh) {
6754
6756
  map.current.set(key, debouncedFetchRefresh);
6755
6757
  return debouncedFetchRefresh;
6756
6758
  };
6757
- return function(url, data, etag, schema) {
6759
+ const debouncedRefresh = (url, data, etag, schema) => {
6758
6760
  const debouncedFetchRefresh = retrieveOrCreate(url);
6759
6761
  debouncedFetchRefresh(url, data, etag);
6760
6762
  if (!schema || !shouldDebounceSchema(schema)) {
6761
6763
  debouncedFetchRefresh.flush();
6762
6764
  }
6763
6765
  };
6766
+ const cancelPendingRefreshes = () => {
6767
+ map.current.forEach((debouncedFetchRefresh) => {
6768
+ debouncedFetchRefresh.cancel();
6769
+ });
6770
+ };
6771
+ const isDebouncing = Array.from(map.current.values()).some(
6772
+ (debouncedFunction) => debouncedFunction.isPending()
6773
+ );
6774
+ return { debouncedRefresh, isDebouncing, cancelPendingRefreshes };
6764
6775
  }
6765
6776
  var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && schema.type !== "boolean" && schema.format !== "base64url";
6766
6777
 
@@ -7119,6 +7130,7 @@ var DynamicFlowComponent = ({
7119
7130
  [httpClient, locale]
7120
7131
  );
7121
7132
  const performAction = async (action, data = {}) => {
7133
+ cancelPendingRefreshes();
7122
7134
  setLoadingState(!step ? "initial" : "submission");
7123
7135
  dispatchEvent("Dynamic Flow - Step Submitted", { actionId: action.id || action.$id });
7124
7136
  try {
@@ -7136,6 +7148,7 @@ var DynamicFlowComponent = ({
7136
7148
  }
7137
7149
  };
7138
7150
  const performRefresh = async (url, data, etag2) => {
7151
+ cancelPendingRefreshes();
7139
7152
  setLoadingState("refresh");
7140
7153
  dispatchEvent("Dynamic Flow - Step Refreshed", { status: "pending" });
7141
7154
  try {
@@ -7149,7 +7162,7 @@ var DynamicFlowComponent = ({
7149
7162
  const exitResult = await getJsonObjectOrNull(response);
7150
7163
  dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
7151
7164
  };
7152
- const debouncedRefresh = useDebouncedRefresh(performRefresh);
7165
+ const { debouncedRefresh, isDebouncing, cancelPendingRefreshes } = useDebouncedRefresh(performRefresh);
7153
7166
  const dispatchEventAndComplete = (0, import_react47.useCallback)(
7154
7167
  (result) => {
7155
7168
  dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
@@ -7257,7 +7270,7 @@ var DynamicFlowComponent = ({
7257
7270
  }
7258
7271
  };
7259
7272
  const onAction = async (action) => {
7260
- if (isLoading || action.disabled) {
7273
+ if (isLoading || isDebouncing || action.disabled) {
7261
7274
  return;
7262
7275
  }
7263
7276
  if (action.exit && !action.url) {
@@ -7278,7 +7291,7 @@ var DynamicFlowComponent = ({
7278
7291
  await performAction(action);
7279
7292
  }
7280
7293
  };
7281
- return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(HttpClientProvider, { httpClient, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(FeatureContextProvider, { features, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
7294
+ return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DynamicFlowProvider, { loading: isLoading || isDebouncing, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(HttpClientProvider, { httpClient, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(FeatureContextProvider, { features, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
7282
7295
  DynamicFlowStep,
7283
7296
  {
7284
7297
  step,
@@ -8516,7 +8529,7 @@ function VariableDateInput({
8516
8529
  placeholder,
8517
8530
  disabled,
8518
8531
  onChange: (date) => {
8519
- onChange(dateToDateString2(date));
8532
+ onChange(date !== null ? dateToDateString2(date) : null);
8520
8533
  },
8521
8534
  onBlur,
8522
8535
  onFocus