@wise/dynamic-flow-client 3.1.0-beta-e9c47a.36 → 3.1.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/build/main.js +335 -247
- package/build/main.min.js +1 -1
- package/build/types/revamp/domain/components/AllOfComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/BoxComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/ColumnsComponent.d.ts +4 -4
- package/build/types/revamp/domain/components/ContainerComponent.d.ts +4 -4
- package/build/types/revamp/domain/components/FormComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/ModalComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/ObjectComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/SelectInputComponent.d.ts +5 -5
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +14 -0
- package/build/types/revamp/domain/components/repeatableComponent/RepeatableComponent.d.ts +5 -5
- package/build/types/revamp/domain/components/utils/component-utils.d.ts +2 -2
- package/build/types/revamp/domain/features/summary/summary-utils.d.ts +2 -2
- package/build/types/revamp/domain/features/validation/validation-functions.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/buttonLayoutToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/layout/formLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapStepToComponent.d.ts +8 -0
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +3 -3
- package/build/types/revamp/domain/types.d.ts +12 -10
- package/build/types/revamp/renderers/LoadingContext.d.ts +9 -0
- package/build/types/revamp/renderers/StepRenderer.d.ts +2 -0
- package/build/types/revamp/renderers/mappers/componentToRendererProps.d.ts +2 -2
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/types.d.ts +8 -1
- package/build/types/revamp/step/Step.d.ts +4 -3
- package/build/types/revamp/step/utils/getRenderFunction.d.ts +2 -2
- package/build/types/revamp/types.d.ts +2 -2
- package/build/types/revamp/utils/component-utils.d.ts +3 -3
- package/build/types/revamp/utils/findComponent.d.ts +2 -2
- package/build/types/revamp/utils/type-utils.d.ts +6 -6
- package/package.json +25 -25
- package/build/types/revamp/domain/mappers/mapStepToComponents.d.ts +0 -6
package/build/main.js
CHANGED
|
@@ -8612,7 +8612,7 @@ var translations = {
|
|
|
8612
8612
|
var i18n_default = translations;
|
|
8613
8613
|
|
|
8614
8614
|
// src/revamp/DynamicFlowWise.tsx
|
|
8615
|
-
var
|
|
8615
|
+
var import_react58 = require("react");
|
|
8616
8616
|
var import_react_intl36 = require("react-intl");
|
|
8617
8617
|
|
|
8618
8618
|
// src/revamp/wise/renderers/AlertRenderer.tsx
|
|
@@ -8818,29 +8818,49 @@ var BoxRenderer_default = BoxRenderer;
|
|
|
8818
8818
|
|
|
8819
8819
|
// src/revamp/wise/renderers/ButtonRenderer.tsx
|
|
8820
8820
|
var import_components42 = require("@transferwise/components");
|
|
8821
|
+
|
|
8822
|
+
// src/revamp/renderers/LoadingContext.tsx
|
|
8823
|
+
var import_react50 = require("react");
|
|
8824
|
+
var LoadingContext = (0, import_react50.createContext)({ loadingState: "idle" });
|
|
8825
|
+
var LoadingContextProvider = LoadingContext.Provider;
|
|
8826
|
+
var useLoadingContext = () => {
|
|
8827
|
+
const { loadingState } = (0, import_react50.useContext)(LoadingContext);
|
|
8828
|
+
return { loadingState, isLoading: loadingState !== "idle" };
|
|
8829
|
+
};
|
|
8830
|
+
|
|
8831
|
+
// src/revamp/wise/renderers/ButtonRenderer.tsx
|
|
8821
8832
|
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
8822
8833
|
var ButtonRenderer = {
|
|
8823
8834
|
canRenderType: "button",
|
|
8824
|
-
render:
|
|
8825
|
-
const className = getMargin2(margin);
|
|
8826
|
-
const priority = mapControl(control);
|
|
8827
|
-
const type = priority === "tertiary" ? void 0 : mapContext(context);
|
|
8828
|
-
return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
8829
|
-
import_components42.Button,
|
|
8830
|
-
{
|
|
8831
|
-
block: true,
|
|
8832
|
-
className,
|
|
8833
|
-
disabled,
|
|
8834
|
-
priority: mapControl(control),
|
|
8835
|
-
size: mapSize(size),
|
|
8836
|
-
type,
|
|
8837
|
-
onClick,
|
|
8838
|
-
children: title
|
|
8839
|
-
}
|
|
8840
|
-
);
|
|
8841
|
-
}
|
|
8835
|
+
render: ButtonRendererComponent
|
|
8842
8836
|
};
|
|
8843
|
-
|
|
8837
|
+
function ButtonRendererComponent({
|
|
8838
|
+
control,
|
|
8839
|
+
context,
|
|
8840
|
+
disabled,
|
|
8841
|
+
margin,
|
|
8842
|
+
title,
|
|
8843
|
+
size,
|
|
8844
|
+
onClick
|
|
8845
|
+
}) {
|
|
8846
|
+
const className = getMargin2(margin);
|
|
8847
|
+
const priority = mapControl(control);
|
|
8848
|
+
const type = priority === "tertiary" ? void 0 : mapContext(context);
|
|
8849
|
+
const { isLoading } = useLoadingContext();
|
|
8850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
8851
|
+
import_components42.Button,
|
|
8852
|
+
{
|
|
8853
|
+
block: true,
|
|
8854
|
+
className,
|
|
8855
|
+
disabled: isLoading || disabled,
|
|
8856
|
+
priority: mapControl(control),
|
|
8857
|
+
size: mapSize(size),
|
|
8858
|
+
type,
|
|
8859
|
+
onClick,
|
|
8860
|
+
children: title
|
|
8861
|
+
}
|
|
8862
|
+
);
|
|
8863
|
+
}
|
|
8844
8864
|
var mapContext = (context) => {
|
|
8845
8865
|
switch (context) {
|
|
8846
8866
|
case "neutral":
|
|
@@ -8875,6 +8895,7 @@ var mapSize = (size) => {
|
|
|
8875
8895
|
return "md";
|
|
8876
8896
|
}
|
|
8877
8897
|
};
|
|
8898
|
+
var ButtonRenderer_default = ButtonRenderer;
|
|
8878
8899
|
|
|
8879
8900
|
// src/revamp/wise/renderers/ColumnsRenderer.tsx
|
|
8880
8901
|
var import_classnames11 = __toESM(require_classnames());
|
|
@@ -9246,21 +9267,25 @@ function NavigationOptionMedia({ icon, image }) {
|
|
|
9246
9267
|
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
9247
9268
|
var DecisionRenderer = {
|
|
9248
9269
|
canRenderType: "decision",
|
|
9249
|
-
render:
|
|
9270
|
+
render: DecisionRendererComponent
|
|
9271
|
+
};
|
|
9272
|
+
var DecisionRenderer_default = DecisionRenderer;
|
|
9273
|
+
function DecisionRendererComponent({ margin, options }) {
|
|
9274
|
+
const { isLoading } = useLoadingContext();
|
|
9275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: getMargin2(margin), children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components45.NavigationOptionsList, { children: options.map(({ description, disabled, icon, image, title, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
9250
9276
|
import_components45.NavigationOption,
|
|
9251
9277
|
{
|
|
9252
9278
|
title,
|
|
9253
9279
|
content: description,
|
|
9254
|
-
disabled,
|
|
9280
|
+
disabled: isLoading || disabled,
|
|
9255
9281
|
media: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(NavigationOptionMedia, { icon, image }),
|
|
9256
9282
|
showMediaCircle: false,
|
|
9257
9283
|
showMediaAtAllSizes: true,
|
|
9258
9284
|
onClick
|
|
9259
9285
|
},
|
|
9260
9286
|
JSON.stringify(title)
|
|
9261
|
-
)) }) })
|
|
9262
|
-
}
|
|
9263
|
-
var DecisionRenderer_default = DecisionRenderer;
|
|
9287
|
+
)) }) });
|
|
9288
|
+
}
|
|
9264
9289
|
|
|
9265
9290
|
// src/revamp/wise/renderers/DividerRenderer.tsx
|
|
9266
9291
|
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
@@ -9345,7 +9370,7 @@ var HeadingRenderer_default = HeadingRenderer;
|
|
|
9345
9370
|
|
|
9346
9371
|
// src/revamp/wise/renderers/ImageRenderer.tsx
|
|
9347
9372
|
var import_components48 = require("@transferwise/components");
|
|
9348
|
-
var
|
|
9373
|
+
var import_react51 = require("react");
|
|
9349
9374
|
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
9350
9375
|
var ImageRenderer = {
|
|
9351
9376
|
canRenderType: "image",
|
|
@@ -9358,9 +9383,9 @@ function ImageRendererComponent({
|
|
|
9358
9383
|
size,
|
|
9359
9384
|
url
|
|
9360
9385
|
}) {
|
|
9361
|
-
const [imageSource, setImageSource] = (0,
|
|
9386
|
+
const [imageSource, setImageSource] = (0, import_react51.useState)("");
|
|
9362
9387
|
const httpClient = useHttpClient();
|
|
9363
|
-
(0,
|
|
9388
|
+
(0, import_react51.useEffect)(() => {
|
|
9364
9389
|
void getImageSource2(httpClient, url).then(setImageSource);
|
|
9365
9390
|
}, [url, httpClient]);
|
|
9366
9391
|
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
@@ -9487,7 +9512,7 @@ var MarkdownRenderer_default = MarkdownRenderer;
|
|
|
9487
9512
|
|
|
9488
9513
|
// src/revamp/wise/renderers/ModalRenderer.tsx
|
|
9489
9514
|
var import_components53 = require("@transferwise/components");
|
|
9490
|
-
var
|
|
9515
|
+
var import_react52 = require("react");
|
|
9491
9516
|
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
9492
9517
|
var ModalRenderer = {
|
|
9493
9518
|
canRenderType: "modal",
|
|
@@ -9495,7 +9520,7 @@ var ModalRenderer = {
|
|
|
9495
9520
|
};
|
|
9496
9521
|
var ModalRenderer_default = ModalRenderer;
|
|
9497
9522
|
function DFModal({ content, margin, trigger }) {
|
|
9498
|
-
const [visible, setVisible] = (0,
|
|
9523
|
+
const [visible, setVisible] = (0, import_react52.useState)(false);
|
|
9499
9524
|
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { className: getMargin2(margin), children: [
|
|
9500
9525
|
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_components53.Button, { priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
|
|
9501
9526
|
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
@@ -9658,9 +9683,9 @@ var import_react_intl32 = require("react-intl");
|
|
|
9658
9683
|
|
|
9659
9684
|
// src/revamp/wise/renderers/hooks/useSnackBarIfAvailable.ts
|
|
9660
9685
|
var import_components57 = require("@transferwise/components");
|
|
9661
|
-
var
|
|
9686
|
+
var import_react53 = require("react");
|
|
9662
9687
|
function useSnackBarIfAvailable2() {
|
|
9663
|
-
const context = (0,
|
|
9688
|
+
const context = (0, import_react53.useContext)(import_components57.SnackbarContext);
|
|
9664
9689
|
return context ? context.createSnackbar : () => {
|
|
9665
9690
|
};
|
|
9666
9691
|
}
|
|
@@ -9709,7 +9734,7 @@ var ParagraphRenderer_default = ParagraphRenderer;
|
|
|
9709
9734
|
|
|
9710
9735
|
// src/revamp/wise/renderers/RepeatableRenderer.tsx
|
|
9711
9736
|
var import_components59 = require("@transferwise/components");
|
|
9712
|
-
var
|
|
9737
|
+
var import_react54 = require("react");
|
|
9713
9738
|
var import_icons3 = require("@transferwise/icons");
|
|
9714
9739
|
var import_react_intl33 = require("react-intl");
|
|
9715
9740
|
var import_classnames14 = __toESM(require_classnames());
|
|
@@ -9733,7 +9758,7 @@ function Repeatable(props) {
|
|
|
9733
9758
|
onRemove
|
|
9734
9759
|
} = props;
|
|
9735
9760
|
const { formatMessage } = (0, import_react_intl33.useIntl)();
|
|
9736
|
-
const [openModalType, setOpenModalType] = (0,
|
|
9761
|
+
const [openModalType, setOpenModalType] = (0, import_react54.useState)(null);
|
|
9737
9762
|
const onAddItem = () => {
|
|
9738
9763
|
onAdd();
|
|
9739
9764
|
setOpenModalType("add");
|
|
@@ -10377,7 +10402,7 @@ var getWiseRenderers = () => [
|
|
|
10377
10402
|
];
|
|
10378
10403
|
|
|
10379
10404
|
// src/revamp/DynamicFlowCore.tsx
|
|
10380
|
-
var
|
|
10405
|
+
var import_react57 = require("react");
|
|
10381
10406
|
var import_react_intl35 = require("react-intl");
|
|
10382
10407
|
|
|
10383
10408
|
// src/revamp/domain/features/events/getAnalyticsEventDispatcher.ts
|
|
@@ -10646,8 +10671,85 @@ var CoreContainerRenderer = {
|
|
|
10646
10671
|
render: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_jsx_runtime117.Fragment, { children })
|
|
10647
10672
|
};
|
|
10648
10673
|
|
|
10674
|
+
// src/revamp/renderers/StepRenderer.tsx
|
|
10675
|
+
var import_react55 = require("react");
|
|
10676
|
+
var import_jsx_runtime118 = require("react/jsx-runtime");
|
|
10677
|
+
var StepRenderer = {
|
|
10678
|
+
canRenderType: "step",
|
|
10679
|
+
render: StepRendererComponent
|
|
10680
|
+
};
|
|
10681
|
+
function StepRendererComponent({ children, loadingState }) {
|
|
10682
|
+
const value = (0, import_react55.useMemo)(() => ({ loadingState }), [loadingState]);
|
|
10683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(LoadingContextProvider, { value, children });
|
|
10684
|
+
}
|
|
10685
|
+
|
|
10649
10686
|
// src/revamp/step/Step.tsx
|
|
10650
|
-
var
|
|
10687
|
+
var import_react56 = require("react");
|
|
10688
|
+
|
|
10689
|
+
// src/revamp/domain/features/validation/validation-functions.ts
|
|
10690
|
+
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
10691
|
+
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
|
|
10692
|
+
|
|
10693
|
+
// src/revamp/domain/features/summary/summary-utils.ts
|
|
10694
|
+
var getSummariser = (schema) => (value) => {
|
|
10695
|
+
const { summary, icon, image } = schema;
|
|
10696
|
+
const stringValueOrNull = isString2(value) ? value : null;
|
|
10697
|
+
return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
|
|
10698
|
+
};
|
|
10699
|
+
var getConstSummary = (schema, model) => {
|
|
10700
|
+
const { summary, icon, image } = schema;
|
|
10701
|
+
const value = isString2(model) ? model : null;
|
|
10702
|
+
return summaryIfProvides(summary, { value, icon, image });
|
|
10703
|
+
};
|
|
10704
|
+
var summariseFromChildren = (components) => components.reduce(
|
|
10705
|
+
(acc, component) => mergeSummaries(acc, component.getSummary()),
|
|
10706
|
+
{}
|
|
10707
|
+
);
|
|
10708
|
+
var mergeSummaries = (summaryA, summaryB) => {
|
|
10709
|
+
var _a, _b, _c, _d;
|
|
10710
|
+
return {
|
|
10711
|
+
title: (_a = summaryA.title) != null ? _a : summaryB.title,
|
|
10712
|
+
description: (_b = summaryA.description) != null ? _b : summaryB.description,
|
|
10713
|
+
icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
|
|
10714
|
+
image: (_d = summaryA.image) != null ? _d : summaryB.image
|
|
10715
|
+
};
|
|
10716
|
+
};
|
|
10717
|
+
var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
10718
|
+
if (!summary) {
|
|
10719
|
+
return {};
|
|
10720
|
+
}
|
|
10721
|
+
return {
|
|
10722
|
+
title: summary.providesTitle && value || void 0,
|
|
10723
|
+
description: summary.providesDescription && value || void 0,
|
|
10724
|
+
icon: summary.providesIcon && icon || void 0,
|
|
10725
|
+
image: summary.providesImage && image || void 0
|
|
10726
|
+
};
|
|
10727
|
+
};
|
|
10728
|
+
|
|
10729
|
+
// src/revamp/domain/components/StepDomainComponent.ts
|
|
10730
|
+
var createStepComponent = (containerProps) => __spreadProps(__spreadValues({}, containerProps), {
|
|
10731
|
+
type: "step",
|
|
10732
|
+
getChildren() {
|
|
10733
|
+
return this.components;
|
|
10734
|
+
},
|
|
10735
|
+
async getSubmittableValue() {
|
|
10736
|
+
return getSubmittableData(this.components);
|
|
10737
|
+
},
|
|
10738
|
+
getSummary() {
|
|
10739
|
+
return summariseFromChildren(this.getChildren());
|
|
10740
|
+
},
|
|
10741
|
+
getLocalValue() {
|
|
10742
|
+
return getLocalValues(this.components);
|
|
10743
|
+
},
|
|
10744
|
+
validate() {
|
|
10745
|
+
return validateComponents(this.getChildren());
|
|
10746
|
+
}
|
|
10747
|
+
});
|
|
10748
|
+
var createEmptyStepComponent = () => createStepComponent({
|
|
10749
|
+
uid: "",
|
|
10750
|
+
loadingState: "idle",
|
|
10751
|
+
components: []
|
|
10752
|
+
});
|
|
10651
10753
|
|
|
10652
10754
|
// src/revamp/domain/components/AlertComponent.ts
|
|
10653
10755
|
var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
|
|
@@ -10741,46 +10843,6 @@ var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md
|
|
|
10741
10843
|
text
|
|
10742
10844
|
});
|
|
10743
10845
|
|
|
10744
|
-
// src/revamp/domain/features/summary/summary-utils.ts
|
|
10745
|
-
var getSummariser = (schema) => (value) => {
|
|
10746
|
-
const { summary, icon, image } = schema;
|
|
10747
|
-
const stringValueOrNull = isString2(value) ? value : null;
|
|
10748
|
-
return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
|
|
10749
|
-
};
|
|
10750
|
-
var getConstSummary = (schema, model) => {
|
|
10751
|
-
const { summary, icon, image } = schema;
|
|
10752
|
-
const value = isString2(model) ? model : null;
|
|
10753
|
-
return summaryIfProvides(summary, { value, icon, image });
|
|
10754
|
-
};
|
|
10755
|
-
var summariseFromChildren = (components) => components.reduce(
|
|
10756
|
-
(acc, component) => mergeSummaries(acc, component.getSummary()),
|
|
10757
|
-
{}
|
|
10758
|
-
);
|
|
10759
|
-
var mergeSummaries = (summaryA, summaryB) => {
|
|
10760
|
-
var _a, _b, _c, _d;
|
|
10761
|
-
return {
|
|
10762
|
-
title: (_a = summaryA.title) != null ? _a : summaryB.title,
|
|
10763
|
-
description: (_b = summaryA.description) != null ? _b : summaryB.description,
|
|
10764
|
-
icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
|
|
10765
|
-
image: (_d = summaryA.image) != null ? _d : summaryB.image
|
|
10766
|
-
};
|
|
10767
|
-
};
|
|
10768
|
-
var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
10769
|
-
if (!summary) {
|
|
10770
|
-
return {};
|
|
10771
|
-
}
|
|
10772
|
-
return {
|
|
10773
|
-
title: summary.providesTitle && value || void 0,
|
|
10774
|
-
description: summary.providesDescription && value || void 0,
|
|
10775
|
-
icon: summary.providesIcon && icon || void 0,
|
|
10776
|
-
image: summary.providesImage && image || void 0
|
|
10777
|
-
};
|
|
10778
|
-
};
|
|
10779
|
-
|
|
10780
|
-
// src/revamp/domain/features/validation/validation-functions.ts
|
|
10781
|
-
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
10782
|
-
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString2);
|
|
10783
|
-
|
|
10784
10846
|
// src/revamp/domain/components/BoxComponent.ts
|
|
10785
10847
|
var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
|
|
10786
10848
|
type: "box",
|
|
@@ -10825,25 +10887,19 @@ var createButtonComponent = (buttonProps) => __spreadProps(__spreadValues({
|
|
|
10825
10887
|
});
|
|
10826
10888
|
|
|
10827
10889
|
// src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
|
|
10828
|
-
var buttonLayoutToComponent = (uid, { action, context, control, disabled, margin = "md", pinOrder, size, title }, { onAction
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
title: getButtonTitle({ title, action: mergedAction }),
|
|
10842
|
-
onClick: () => {
|
|
10843
|
-
void onAction(mergedAction);
|
|
10844
|
-
}
|
|
10845
|
-
});
|
|
10846
|
-
};
|
|
10890
|
+
var buttonLayoutToComponent = (uid, { action, context, control, disabled, margin = "md", pinOrder, size, title }, { onAction }) => createButtonComponent({
|
|
10891
|
+
uid,
|
|
10892
|
+
context: getButtonContext({ context, action }),
|
|
10893
|
+
control: getButtonControl({ control, action }),
|
|
10894
|
+
disabled: getButtonDisabled({ disabled, action }),
|
|
10895
|
+
margin,
|
|
10896
|
+
pinOrder,
|
|
10897
|
+
size,
|
|
10898
|
+
title: getButtonTitle({ title, action }),
|
|
10899
|
+
onClick: () => {
|
|
10900
|
+
void onAction(action);
|
|
10901
|
+
}
|
|
10902
|
+
});
|
|
10847
10903
|
var getButtonTitle = ({ title, action }) => {
|
|
10848
10904
|
var _a;
|
|
10849
10905
|
return (_a = title != null ? title : action == null ? void 0 : action.title) != null ? _a : "";
|
|
@@ -13126,11 +13182,10 @@ var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formPr
|
|
|
13126
13182
|
});
|
|
13127
13183
|
|
|
13128
13184
|
// src/revamp/domain/mappers/layout/formLayoutToComponent.ts
|
|
13129
|
-
var formLayoutToComponent = (uid, { schemaId,
|
|
13185
|
+
var formLayoutToComponent = (uid, { schemaId, control, margin = "md" }, mapperProps) => {
|
|
13130
13186
|
const { step, stepLocalValue } = mapperProps;
|
|
13131
13187
|
const { model, errors, schemas } = step;
|
|
13132
|
-
const
|
|
13133
|
-
const schema = schemas.find((s) => s.$id === id);
|
|
13188
|
+
const schema = schemas.find((s) => s.$id === schemaId);
|
|
13134
13189
|
if (!schema) {
|
|
13135
13190
|
throw new Error("Bad layout schemaId");
|
|
13136
13191
|
}
|
|
@@ -13566,36 +13621,41 @@ var mapLayoutToComponent = (uid, layout, mapperProps) => {
|
|
|
13566
13621
|
}
|
|
13567
13622
|
};
|
|
13568
13623
|
|
|
13569
|
-
// src/revamp/domain/mappers/
|
|
13570
|
-
var
|
|
13624
|
+
// src/revamp/domain/mappers/mapStepToComponent.ts
|
|
13625
|
+
var mapStepToComponent = (_a) => {
|
|
13571
13626
|
var _b = _a, {
|
|
13627
|
+
loadingState,
|
|
13572
13628
|
displayStepTitle
|
|
13573
13629
|
} = _b, mapperProps = __objRest(_b, [
|
|
13630
|
+
"loadingState",
|
|
13574
13631
|
"displayStepTitle"
|
|
13575
13632
|
]);
|
|
13576
13633
|
const { id, key, title, layout = [], errors } = mapperProps.step;
|
|
13577
13634
|
const stepId = id || key;
|
|
13578
13635
|
const uid = stepId != null ? stepId : "step";
|
|
13579
|
-
const heading = title && displayStepTitle
|
|
13580
|
-
// prefix step id or flow id
|
|
13636
|
+
const heading = title && displayStepTitle ? headingLayoutToComponent(`${uid}.title`, {
|
|
13581
13637
|
type: "heading",
|
|
13582
13638
|
text: title,
|
|
13583
13639
|
align: "center",
|
|
13584
13640
|
size: "lg"
|
|
13585
|
-
});
|
|
13586
|
-
const stepError = (errors == null ? void 0 : errors.error)
|
|
13641
|
+
}) : void 0;
|
|
13642
|
+
const stepError = (errors == null ? void 0 : errors.error) ? alertLayoutToComponent(`${uid}.global-error`, {
|
|
13587
13643
|
type: "alert",
|
|
13588
13644
|
markdown: errors.error,
|
|
13589
13645
|
context: "negative"
|
|
13590
|
-
});
|
|
13591
|
-
const
|
|
13646
|
+
}) : void 0;
|
|
13647
|
+
const additionalComponents = [...heading ? [heading] : [], ...stepError ? [stepError] : []];
|
|
13592
13648
|
const layoutComponents = layout.map(
|
|
13593
13649
|
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps)
|
|
13594
13650
|
);
|
|
13595
13651
|
if (stepId === void 0) {
|
|
13596
13652
|
throw new Error("Step must have an id or a key");
|
|
13597
13653
|
}
|
|
13598
|
-
return
|
|
13654
|
+
return createStepComponent({
|
|
13655
|
+
uid,
|
|
13656
|
+
loadingState,
|
|
13657
|
+
components: [...additionalComponents, ...layoutComponents]
|
|
13658
|
+
});
|
|
13599
13659
|
};
|
|
13600
13660
|
|
|
13601
13661
|
// src/revamp/utils/findComponent.ts
|
|
@@ -13618,11 +13678,13 @@ var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
|
13618
13678
|
}, []);
|
|
13619
13679
|
|
|
13620
13680
|
// src/revamp/step/Step.tsx
|
|
13621
|
-
var
|
|
13681
|
+
var import_jsx_runtime119 = require("react/jsx-runtime");
|
|
13682
|
+
var emptyStepComponent = createEmptyStepComponent();
|
|
13622
13683
|
function Step({
|
|
13623
13684
|
localValue: initialLocalValue,
|
|
13624
13685
|
step,
|
|
13625
13686
|
displayStepTitle = true,
|
|
13687
|
+
loadingState,
|
|
13626
13688
|
getErrorMessageFunctions,
|
|
13627
13689
|
render,
|
|
13628
13690
|
httpClient,
|
|
@@ -13632,27 +13694,36 @@ function Step({
|
|
|
13632
13694
|
triggerRefresh
|
|
13633
13695
|
}) {
|
|
13634
13696
|
var _a;
|
|
13635
|
-
const [
|
|
13636
|
-
const
|
|
13637
|
-
const updateComponent = (0,
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13697
|
+
const [stepComponent, setStepComponent] = (0, import_react56.useState)(emptyStepComponent);
|
|
13698
|
+
const stepComponentRef = (0, import_react56.useRef)(emptyStepComponent);
|
|
13699
|
+
const updateComponent = (0, import_react56.useCallback)(
|
|
13700
|
+
(id, update) => {
|
|
13701
|
+
update(findComponent([stepComponentRef.current], id));
|
|
13702
|
+
setStepComponent(() => {
|
|
13703
|
+
const newStepDomainComponent = __spreadValues({}, stepComponentRef.current);
|
|
13704
|
+
stepComponentRef.current = newStepDomainComponent;
|
|
13705
|
+
return newStepDomainComponent;
|
|
13706
|
+
});
|
|
13707
|
+
},
|
|
13708
|
+
[]
|
|
13709
|
+
);
|
|
13710
|
+
(0, import_react56.useEffect)(() => {
|
|
13711
|
+
setStepComponent(() => {
|
|
13712
|
+
const newStepDomainComponent = __spreadProps(__spreadValues({}, stepComponentRef.current), { loadingState });
|
|
13713
|
+
stepComponentRef.current = newStepDomainComponent;
|
|
13714
|
+
return newStepDomainComponent;
|
|
13644
13715
|
});
|
|
13645
|
-
}, []);
|
|
13646
|
-
const onAction = (0,
|
|
13716
|
+
}, [loadingState]);
|
|
13717
|
+
const onAction = (0, import_react56.useCallback)(
|
|
13647
13718
|
async (action) => {
|
|
13648
13719
|
var _a2;
|
|
13649
13720
|
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
13650
|
-
const canSubmit = skipValidation ||
|
|
13721
|
+
const canSubmit = skipValidation || stepComponentRef.current.validate();
|
|
13651
13722
|
if (canSubmit) {
|
|
13652
13723
|
try {
|
|
13653
|
-
const model = await
|
|
13724
|
+
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13654
13725
|
const payload = mergeModels(model, (_a2 = action.data) != null ? _a2 : null);
|
|
13655
|
-
const localValue =
|
|
13726
|
+
const localValue = stepComponentRef.current.getLocalValue();
|
|
13656
13727
|
void triggerSubmission(action, payload, localValue);
|
|
13657
13728
|
} catch (e) {
|
|
13658
13729
|
if (true) {
|
|
@@ -13663,23 +13734,24 @@ function Step({
|
|
|
13663
13734
|
},
|
|
13664
13735
|
[triggerSubmission]
|
|
13665
13736
|
);
|
|
13666
|
-
const onRefresh = (0,
|
|
13737
|
+
const onRefresh = (0, import_react56.useCallback)(
|
|
13667
13738
|
async (schemaId, url) => {
|
|
13668
13739
|
var _a2;
|
|
13669
13740
|
const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
13670
13741
|
if (refreshUrl) {
|
|
13671
|
-
const model = await
|
|
13672
|
-
const localValue =
|
|
13742
|
+
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13743
|
+
const localValue = stepComponentRef.current.getLocalValue();
|
|
13673
13744
|
void triggerRefresh({ refreshUrl, model, localValue, schemaId });
|
|
13674
13745
|
}
|
|
13675
13746
|
},
|
|
13676
13747
|
[step.refreshUrl, step.refreshFormUrl, triggerRefresh]
|
|
13677
13748
|
);
|
|
13678
|
-
(0,
|
|
13679
|
-
const
|
|
13749
|
+
(0, import_react56.useEffect)(() => {
|
|
13750
|
+
const initialComponent = mapStepToComponent({
|
|
13680
13751
|
stepLocalValue: initialLocalValue,
|
|
13681
13752
|
step,
|
|
13682
13753
|
displayStepTitle,
|
|
13754
|
+
loadingState,
|
|
13683
13755
|
updateComponent,
|
|
13684
13756
|
getErrorMessageFunctions,
|
|
13685
13757
|
trackEvent,
|
|
@@ -13688,13 +13760,12 @@ function Step({
|
|
|
13688
13760
|
onAction,
|
|
13689
13761
|
onRefresh
|
|
13690
13762
|
});
|
|
13691
|
-
|
|
13692
|
-
|
|
13763
|
+
setStepComponent(initialComponent);
|
|
13764
|
+
stepComponentRef.current = initialComponent;
|
|
13693
13765
|
if (step.key) {
|
|
13694
13766
|
logEvent("warning", 'Step.key is deprecated, please use "id" instead');
|
|
13695
13767
|
}
|
|
13696
13768
|
}, [
|
|
13697
|
-
initialLocalValue,
|
|
13698
13769
|
step,
|
|
13699
13770
|
displayStepTitle,
|
|
13700
13771
|
updateComponent,
|
|
@@ -13705,13 +13776,20 @@ function Step({
|
|
|
13705
13776
|
logEvent,
|
|
13706
13777
|
onRefresh
|
|
13707
13778
|
]);
|
|
13708
|
-
(0,
|
|
13779
|
+
(0, import_react56.useEffect)(() => {
|
|
13709
13780
|
trackEvent("Step Shown");
|
|
13710
13781
|
}, [(_a = step.id) != null ? _a : step.key]);
|
|
13711
|
-
return /* @__PURE__ */ (0,
|
|
13782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_jsx_runtime119.Fragment, { children: render(stepComponent) });
|
|
13712
13783
|
}
|
|
13713
13784
|
var Step_default = Step;
|
|
13714
13785
|
|
|
13786
|
+
// src/revamp/renderers/stepComponentToProps.ts
|
|
13787
|
+
var stepComponentToProps = ({ loadingState }, children) => ({
|
|
13788
|
+
type: "step",
|
|
13789
|
+
loadingState,
|
|
13790
|
+
children
|
|
13791
|
+
});
|
|
13792
|
+
|
|
13715
13793
|
// src/revamp/renderers/mappers/alertComponentToProps.ts
|
|
13716
13794
|
var alertComponentToProps = ({
|
|
13717
13795
|
context,
|
|
@@ -13848,54 +13926,6 @@ var hiddenComponentToProps = () => ({
|
|
|
13848
13926
|
type: "hidden"
|
|
13849
13927
|
});
|
|
13850
13928
|
|
|
13851
|
-
// src/revamp/renderers/mappers/searchComponentToProps.ts
|
|
13852
|
-
var searchComponentToProps = (component) => {
|
|
13853
|
-
const { uid, control, emptyMessage, error, isLoading, margin, query, results, title } = component;
|
|
13854
|
-
const onChange = component.onChange.bind(component);
|
|
13855
|
-
const onSelect = component.onSelect.bind(component);
|
|
13856
|
-
const state = getSearchState({
|
|
13857
|
-
emptyMessage,
|
|
13858
|
-
error,
|
|
13859
|
-
query,
|
|
13860
|
-
results,
|
|
13861
|
-
onChange,
|
|
13862
|
-
onSelect
|
|
13863
|
-
});
|
|
13864
|
-
return {
|
|
13865
|
-
type: "search",
|
|
13866
|
-
id: uid,
|
|
13867
|
-
control,
|
|
13868
|
-
isLoading,
|
|
13869
|
-
margin,
|
|
13870
|
-
query,
|
|
13871
|
-
state,
|
|
13872
|
-
title,
|
|
13873
|
-
onChange
|
|
13874
|
-
};
|
|
13875
|
-
};
|
|
13876
|
-
var getSearchState = ({
|
|
13877
|
-
emptyMessage,
|
|
13878
|
-
error,
|
|
13879
|
-
query,
|
|
13880
|
-
results,
|
|
13881
|
-
onChange,
|
|
13882
|
-
onSelect
|
|
13883
|
-
}) => {
|
|
13884
|
-
if (!query) {
|
|
13885
|
-
return { type: "pending" };
|
|
13886
|
-
}
|
|
13887
|
-
if (error) {
|
|
13888
|
-
return { type: "error", onRetry: () => onChange(query) };
|
|
13889
|
-
}
|
|
13890
|
-
if (results.length === 0) {
|
|
13891
|
-
return { type: "noResults", message: emptyMessage };
|
|
13892
|
-
}
|
|
13893
|
-
const rendererResults = results.map((result) => __spreadProps(__spreadValues({}, result), {
|
|
13894
|
-
onClick: () => onSelect(result)
|
|
13895
|
-
}));
|
|
13896
|
-
return { type: "results", results: rendererResults };
|
|
13897
|
-
};
|
|
13898
|
-
|
|
13899
13929
|
// src/revamp/renderers/mappers/imageComponentToProps.ts
|
|
13900
13930
|
var imageComponentToProps = ({
|
|
13901
13931
|
accessibilityDescription,
|
|
@@ -13966,6 +13996,34 @@ var modalComponentToProps = ({ control, margin, trigger }, components) => ({
|
|
|
13966
13996
|
trigger
|
|
13967
13997
|
});
|
|
13968
13998
|
|
|
13999
|
+
// src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
|
|
14000
|
+
var multiUploadInputComponentToProps = (component) => {
|
|
14001
|
+
const { accepts, fileMap, maxSize, minItems, maxItems, uploadLabel } = component;
|
|
14002
|
+
const findIdByValue = (file) => Object.keys(fileMap).find((id) => fileMap[id] === file);
|
|
14003
|
+
const fileList = Object.values(fileMap).map((file) => {
|
|
14004
|
+
var _a;
|
|
14005
|
+
return {
|
|
14006
|
+
id: (_a = findIdByValue(file)) != null ? _a : "",
|
|
14007
|
+
file
|
|
14008
|
+
};
|
|
14009
|
+
});
|
|
14010
|
+
return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload-multi")), {
|
|
14011
|
+
accepts,
|
|
14012
|
+
maxSize,
|
|
14013
|
+
minItems,
|
|
14014
|
+
maxItems,
|
|
14015
|
+
uploadLabel,
|
|
14016
|
+
value: fileList,
|
|
14017
|
+
onUpload: component.onUpload.bind(component),
|
|
14018
|
+
onDelete: component.onDelete.bind(component)
|
|
14019
|
+
});
|
|
14020
|
+
};
|
|
14021
|
+
|
|
14022
|
+
// src/revamp/renderers/mappers/numberInputComponentToProps.ts
|
|
14023
|
+
var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
|
|
14024
|
+
onChange: component.onChange.bind(component)
|
|
14025
|
+
});
|
|
14026
|
+
|
|
13969
14027
|
// src/revamp/renderers/mappers/objectComponentToProps.ts
|
|
13970
14028
|
var objectComponentToProps = ({ control, description, help, title }, children) => ({
|
|
13971
14029
|
type: "form-section",
|
|
@@ -13990,34 +14048,6 @@ var paragraphComponentToProps = ({
|
|
|
13990
14048
|
text
|
|
13991
14049
|
});
|
|
13992
14050
|
|
|
13993
|
-
// src/revamp/renderers/mappers/numberInputComponentToProps.ts
|
|
13994
|
-
var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
|
|
13995
|
-
onChange: component.onChange.bind(component)
|
|
13996
|
-
});
|
|
13997
|
-
|
|
13998
|
-
// src/revamp/renderers/mappers/uploadInputComponentToProps.ts
|
|
13999
|
-
var uploadInputComponentToProps = (component) => {
|
|
14000
|
-
const { accepts, maxSize } = component;
|
|
14001
|
-
return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload")), {
|
|
14002
|
-
accepts,
|
|
14003
|
-
maxSize,
|
|
14004
|
-
onUpload: component.onUpload.bind(component)
|
|
14005
|
-
});
|
|
14006
|
-
};
|
|
14007
|
-
|
|
14008
|
-
// src/revamp/renderers/mappers/selectInputComponentToProps.ts
|
|
14009
|
-
var selectInputComponentToProps = (component, children) => {
|
|
14010
|
-
var _b;
|
|
14011
|
-
const { options, selectedIndex, onSelect } = component;
|
|
14012
|
-
const _a = inputComponentToProps(component, "input-select"), { value } = _a, props = __objRest(_a, ["value"]);
|
|
14013
|
-
return __spreadProps(__spreadValues({}, props), {
|
|
14014
|
-
options,
|
|
14015
|
-
selectedIndex,
|
|
14016
|
-
onSelect: onSelect.bind(component),
|
|
14017
|
-
children: (_b = children[selectedIndex != null ? selectedIndex : -1]) != null ? _b : null
|
|
14018
|
-
});
|
|
14019
|
-
};
|
|
14020
|
-
|
|
14021
14051
|
// src/revamp/renderers/mappers/repeatableComponentToProps.ts
|
|
14022
14052
|
var repeatableComponentToProps = (component, children, editableItemChildren) => {
|
|
14023
14053
|
const {
|
|
@@ -14080,6 +14110,67 @@ var reviewComponentToProps = ({
|
|
|
14080
14110
|
title
|
|
14081
14111
|
});
|
|
14082
14112
|
|
|
14113
|
+
// src/revamp/renderers/mappers/searchComponentToProps.ts
|
|
14114
|
+
var searchComponentToProps = (component) => {
|
|
14115
|
+
const { uid, control, emptyMessage, error, isLoading, margin, query, results, title } = component;
|
|
14116
|
+
const onChange = component.onChange.bind(component);
|
|
14117
|
+
const onSelect = component.onSelect.bind(component);
|
|
14118
|
+
const state = getSearchState({
|
|
14119
|
+
emptyMessage,
|
|
14120
|
+
error,
|
|
14121
|
+
query,
|
|
14122
|
+
results,
|
|
14123
|
+
onChange,
|
|
14124
|
+
onSelect
|
|
14125
|
+
});
|
|
14126
|
+
return {
|
|
14127
|
+
type: "search",
|
|
14128
|
+
id: uid,
|
|
14129
|
+
control,
|
|
14130
|
+
isLoading,
|
|
14131
|
+
margin,
|
|
14132
|
+
query,
|
|
14133
|
+
state,
|
|
14134
|
+
title,
|
|
14135
|
+
onChange
|
|
14136
|
+
};
|
|
14137
|
+
};
|
|
14138
|
+
var getSearchState = ({
|
|
14139
|
+
emptyMessage,
|
|
14140
|
+
error,
|
|
14141
|
+
query,
|
|
14142
|
+
results,
|
|
14143
|
+
onChange,
|
|
14144
|
+
onSelect
|
|
14145
|
+
}) => {
|
|
14146
|
+
if (!query) {
|
|
14147
|
+
return { type: "pending" };
|
|
14148
|
+
}
|
|
14149
|
+
if (error) {
|
|
14150
|
+
return { type: "error", onRetry: () => onChange(query) };
|
|
14151
|
+
}
|
|
14152
|
+
if (results.length === 0) {
|
|
14153
|
+
return { type: "noResults", message: emptyMessage };
|
|
14154
|
+
}
|
|
14155
|
+
const rendererResults = results.map((result) => __spreadProps(__spreadValues({}, result), {
|
|
14156
|
+
onClick: () => onSelect(result)
|
|
14157
|
+
}));
|
|
14158
|
+
return { type: "results", results: rendererResults };
|
|
14159
|
+
};
|
|
14160
|
+
|
|
14161
|
+
// src/revamp/renderers/mappers/selectInputComponentToProps.ts
|
|
14162
|
+
var selectInputComponentToProps = (component, children) => {
|
|
14163
|
+
var _b;
|
|
14164
|
+
const { options, selectedIndex, onSelect } = component;
|
|
14165
|
+
const _a = inputComponentToProps(component, "input-select"), { value } = _a, props = __objRest(_a, ["value"]);
|
|
14166
|
+
return __spreadProps(__spreadValues({}, props), {
|
|
14167
|
+
options,
|
|
14168
|
+
selectedIndex,
|
|
14169
|
+
onSelect: onSelect.bind(component),
|
|
14170
|
+
children: (_b = children[selectedIndex != null ? selectedIndex : -1]) != null ? _b : null
|
|
14171
|
+
});
|
|
14172
|
+
};
|
|
14173
|
+
|
|
14083
14174
|
// src/revamp/renderers/mappers/statusListComponentToProps.ts
|
|
14084
14175
|
var statusListComponentToProps = ({
|
|
14085
14176
|
control,
|
|
@@ -14100,26 +14191,13 @@ var textInputComponentToProps = (component) => __spreadProps(__spreadValues({},
|
|
|
14100
14191
|
onChange: component.onChange.bind(component)
|
|
14101
14192
|
});
|
|
14102
14193
|
|
|
14103
|
-
// src/revamp/renderers/mappers/
|
|
14104
|
-
var
|
|
14105
|
-
const { accepts,
|
|
14106
|
-
|
|
14107
|
-
const fileList = Object.values(fileMap).map((file) => {
|
|
14108
|
-
var _a;
|
|
14109
|
-
return {
|
|
14110
|
-
id: (_a = findIdByValue(file)) != null ? _a : "",
|
|
14111
|
-
file
|
|
14112
|
-
};
|
|
14113
|
-
});
|
|
14114
|
-
return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload-multi")), {
|
|
14194
|
+
// src/revamp/renderers/mappers/uploadInputComponentToProps.ts
|
|
14195
|
+
var uploadInputComponentToProps = (component) => {
|
|
14196
|
+
const { accepts, maxSize } = component;
|
|
14197
|
+
return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload")), {
|
|
14115
14198
|
accepts,
|
|
14116
14199
|
maxSize,
|
|
14117
|
-
|
|
14118
|
-
maxItems,
|
|
14119
|
-
uploadLabel,
|
|
14120
|
-
value: fileList,
|
|
14121
|
-
onUpload: component.onUpload.bind(component),
|
|
14122
|
-
onDelete: component.onDelete.bind(component)
|
|
14200
|
+
onUpload: component.onUpload.bind(component)
|
|
14123
14201
|
});
|
|
14124
14202
|
};
|
|
14125
14203
|
|
|
@@ -14130,6 +14208,8 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
14130
14208
|
return hiddenComponentToProps();
|
|
14131
14209
|
}
|
|
14132
14210
|
switch (component.type) {
|
|
14211
|
+
case "step":
|
|
14212
|
+
return stepComponentToProps(component, children);
|
|
14133
14213
|
case "alert":
|
|
14134
14214
|
return alertComponentToProps(component);
|
|
14135
14215
|
case "all-of":
|
|
@@ -14196,7 +14276,7 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
14196
14276
|
};
|
|
14197
14277
|
|
|
14198
14278
|
// src/revamp/step/utils/getRenderFunction.tsx
|
|
14199
|
-
var
|
|
14279
|
+
var import_jsx_runtime120 = require("react/jsx-runtime");
|
|
14200
14280
|
var getRenderFunction = (renderers2) => {
|
|
14201
14281
|
function ComponentRenderer(props) {
|
|
14202
14282
|
const { type } = props;
|
|
@@ -14235,7 +14315,7 @@ var getRenderFunction = (renderers2) => {
|
|
|
14235
14315
|
children: component.getChildren().map(render)
|
|
14236
14316
|
};
|
|
14237
14317
|
};
|
|
14238
|
-
const render = (component) => /* @__PURE__ */ (0,
|
|
14318
|
+
const render = (component) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
14239
14319
|
ComponentRenderer,
|
|
14240
14320
|
__spreadValues({}, componentToRendererProps(component, getNestedContent(component))),
|
|
14241
14321
|
component.uid
|
|
@@ -14330,7 +14410,7 @@ var formatDateOptions = {
|
|
|
14330
14410
|
};
|
|
14331
14411
|
|
|
14332
14412
|
// src/revamp/DynamicFlowCore.tsx
|
|
14333
|
-
var
|
|
14413
|
+
var import_jsx_runtime121 = require("react/jsx-runtime");
|
|
14334
14414
|
function DynamicFlowCore(props) {
|
|
14335
14415
|
var _a;
|
|
14336
14416
|
const {
|
|
@@ -14346,20 +14426,21 @@ function DynamicFlowCore(props) {
|
|
|
14346
14426
|
onLog
|
|
14347
14427
|
} = props;
|
|
14348
14428
|
const { formatMessage, locale } = (0, import_react_intl35.useIntl)();
|
|
14349
|
-
const getErrorMessageFunctions = (0,
|
|
14429
|
+
const getErrorMessageFunctions = (0, import_react57.useMemo)(
|
|
14350
14430
|
() => getSchemaErrorMessageFunction(formatMessage, locale),
|
|
14351
14431
|
[formatMessage, locale]
|
|
14352
14432
|
);
|
|
14353
|
-
(0,
|
|
14433
|
+
(0, import_react57.useEffect)(() => {
|
|
14354
14434
|
var _a2;
|
|
14355
14435
|
if (!initialStep && initialAction) {
|
|
14356
14436
|
void triggerSubmission(initialAction, (_a2 = initialAction.data) != null ? _a2 : {}, null);
|
|
14357
14437
|
}
|
|
14358
14438
|
}, []);
|
|
14359
|
-
const [step, setStep] = (0,
|
|
14360
|
-
const localValueRef = (0,
|
|
14361
|
-
const [etag, setEtag] = (0,
|
|
14362
|
-
const abortControllerRef = (0,
|
|
14439
|
+
const [step, setStep] = (0, import_react57.useState)(initialStep != null ? initialStep : null);
|
|
14440
|
+
const localValueRef = (0, import_react57.useRef)(null);
|
|
14441
|
+
const [etag, setEtag] = (0, import_react57.useState)(null);
|
|
14442
|
+
const abortControllerRef = (0, import_react57.useRef)(new AbortController());
|
|
14443
|
+
const [loadingState, setLoadingState] = (0, import_react57.useState)(initialStep ? "idle" : "loading");
|
|
14363
14444
|
const abortCurrentAndGetNewAbortSignal = () => {
|
|
14364
14445
|
abortControllerRef.current.abort();
|
|
14365
14446
|
abortControllerRef.current = new AbortController();
|
|
@@ -14367,26 +14448,27 @@ function DynamicFlowCore(props) {
|
|
|
14367
14448
|
};
|
|
14368
14449
|
const stepId = (_a = step == null ? void 0 : step.id) != null ? _a : step == null ? void 0 : step.key;
|
|
14369
14450
|
const stepAnalytics = step == null ? void 0 : step.analytics;
|
|
14370
|
-
const trackEvent = (0,
|
|
14451
|
+
const trackEvent = (0, import_react57.useMemo)(
|
|
14371
14452
|
() => getAnalyticsEventDispatcher({ flowId, stepId, analytics: stepAnalytics, onEvent }),
|
|
14372
14453
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14373
14454
|
[flowId, stepId, JSON.stringify(stepAnalytics), onEvent]
|
|
14374
14455
|
);
|
|
14375
|
-
const logEvent = (0,
|
|
14376
|
-
(0,
|
|
14377
|
-
const closeWithError = (0,
|
|
14456
|
+
const logEvent = (0, import_react57.useMemo)(() => getLoggingEventDispatcher(onLog), [onLog]);
|
|
14457
|
+
(0, import_react57.useEffect)(() => trackEvent("Flow Started"), []);
|
|
14458
|
+
const closeWithError = (0, import_react57.useCallback)(
|
|
14378
14459
|
(error, analytics) => {
|
|
14379
14460
|
trackEvent("Flow Failed", __spreadValues({}, analytics));
|
|
14380
14461
|
onError(error);
|
|
14381
14462
|
},
|
|
14382
14463
|
[onError, trackEvent]
|
|
14383
14464
|
);
|
|
14384
|
-
const triggerSubmission = (0,
|
|
14465
|
+
const triggerSubmission = (0, import_react57.useCallback)(
|
|
14385
14466
|
async (action, model, localValue) => {
|
|
14386
14467
|
if (true) {
|
|
14387
14468
|
console.log("\u23EF\uFE0F triggerSubmission", JSON.stringify({ action, model }, null, 2));
|
|
14388
14469
|
}
|
|
14389
14470
|
try {
|
|
14471
|
+
setLoadingState("loading");
|
|
14390
14472
|
const command = await executeSubmission({
|
|
14391
14473
|
action,
|
|
14392
14474
|
model,
|
|
@@ -14403,11 +14485,13 @@ function DynamicFlowCore(props) {
|
|
|
14403
14485
|
}
|
|
14404
14486
|
case "replace-step": {
|
|
14405
14487
|
localValueRef.current = null;
|
|
14488
|
+
setLoadingState("idle");
|
|
14406
14489
|
setStep(command.step);
|
|
14407
14490
|
setEtag(command.etag);
|
|
14408
14491
|
break;
|
|
14409
14492
|
}
|
|
14410
14493
|
case "error": {
|
|
14494
|
+
setLoadingState("idle");
|
|
14411
14495
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
14412
14496
|
const { errors = { error: genericErrorMessage } } = command.body;
|
|
14413
14497
|
if (step) {
|
|
@@ -14431,6 +14515,7 @@ function DynamicFlowCore(props) {
|
|
|
14431
14515
|
});
|
|
14432
14516
|
switch (refreshCommand.type) {
|
|
14433
14517
|
case "refresh-step":
|
|
14518
|
+
setLoadingState("idle");
|
|
14434
14519
|
setStep(__spreadProps(__spreadValues({}, refreshCommand.step), { errors }));
|
|
14435
14520
|
setEtag(refreshCommand.etag);
|
|
14436
14521
|
break;
|
|
@@ -14449,7 +14534,7 @@ function DynamicFlowCore(props) {
|
|
|
14449
14534
|
},
|
|
14450
14535
|
[httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
|
|
14451
14536
|
);
|
|
14452
|
-
const triggerRefresh = (0,
|
|
14537
|
+
const triggerRefresh = (0, import_react57.useCallback)(
|
|
14453
14538
|
async ({
|
|
14454
14539
|
refreshUrl,
|
|
14455
14540
|
model,
|
|
@@ -14461,6 +14546,7 @@ function DynamicFlowCore(props) {
|
|
|
14461
14546
|
}
|
|
14462
14547
|
try {
|
|
14463
14548
|
localValueRef.current = localValue;
|
|
14549
|
+
setLoadingState("loading");
|
|
14464
14550
|
const command = await executeRefresh({
|
|
14465
14551
|
abortSignal: abortCurrentAndGetNewAbortSignal(),
|
|
14466
14552
|
url: refreshUrl,
|
|
@@ -14470,6 +14556,7 @@ function DynamicFlowCore(props) {
|
|
|
14470
14556
|
httpClient,
|
|
14471
14557
|
trackEvent
|
|
14472
14558
|
});
|
|
14559
|
+
setLoadingState("idle");
|
|
14473
14560
|
switch (command.type) {
|
|
14474
14561
|
case "refresh-step":
|
|
14475
14562
|
setStep(command.step);
|
|
@@ -14488,16 +14575,17 @@ function DynamicFlowCore(props) {
|
|
|
14488
14575
|
},
|
|
14489
14576
|
[etag, httpClient, trackEvent, closeWithError]
|
|
14490
14577
|
);
|
|
14491
|
-
const render = (0,
|
|
14492
|
-
() => getRenderFunction([CoreContainerRenderer, ...renderers2]),
|
|
14578
|
+
const render = (0, import_react57.useMemo)(
|
|
14579
|
+
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
14493
14580
|
[renderers2]
|
|
14494
14581
|
);
|
|
14495
|
-
return /* @__PURE__ */ (0,
|
|
14582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ErrorBoundary_default, { onError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
14496
14583
|
Step_default,
|
|
14497
14584
|
{
|
|
14498
14585
|
displayStepTitle,
|
|
14499
14586
|
step,
|
|
14500
14587
|
localValue: localValueRef.current,
|
|
14588
|
+
loadingState,
|
|
14501
14589
|
getErrorMessageFunctions,
|
|
14502
14590
|
render,
|
|
14503
14591
|
httpClient,
|
|
@@ -14510,16 +14598,16 @@ function DynamicFlowCore(props) {
|
|
|
14510
14598
|
}
|
|
14511
14599
|
|
|
14512
14600
|
// src/revamp/DynamicFlowWise.tsx
|
|
14513
|
-
var
|
|
14601
|
+
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
14514
14602
|
var renderers = getWiseRenderers();
|
|
14515
14603
|
function DynamicFlowWise(props) {
|
|
14516
14604
|
const { httpClient } = props;
|
|
14517
14605
|
const { locale } = (0, import_react_intl36.useIntl)();
|
|
14518
|
-
const wiseHttpClient = (0,
|
|
14606
|
+
const wiseHttpClient = (0, import_react58.useMemo)(
|
|
14519
14607
|
() => makeWiseHttpClient(httpClient, locale),
|
|
14520
14608
|
[httpClient, locale]
|
|
14521
14609
|
);
|
|
14522
|
-
return /* @__PURE__ */ (0,
|
|
14610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(HttpClientProvider, { httpClient: wiseHttpClient, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers })) });
|
|
14523
14611
|
}
|
|
14524
14612
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
14525
14613
|
var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
|