@wise/dynamic-flow-client 3.1.0-beta-81cefd.37 → 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 +337 -256
- 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/components/utils/isPartialLocalValueMatch.d.ts +0 -1
- 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,24 +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
|
-
onClick: () => {
|
|
10842
|
-
void onAction(mergedAction);
|
|
10843
|
-
}
|
|
10844
|
-
});
|
|
10845
|
-
};
|
|
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
|
+
});
|
|
10846
10903
|
var getButtonTitle = ({ title, action }) => {
|
|
10847
10904
|
var _a;
|
|
10848
10905
|
return (_a = title != null ? title : action == null ? void 0 : action.title) != null ? _a : "";
|
|
@@ -11953,12 +12010,6 @@ var isPartialLocalValueMatch = (partialValue, value) => {
|
|
|
11953
12010
|
}
|
|
11954
12011
|
return partialValue === value;
|
|
11955
12012
|
};
|
|
11956
|
-
var pickIndexOfFirstMatch = (arr) => {
|
|
11957
|
-
if (arr.length > 0 && arr.every((e) => e === arr[0])) {
|
|
11958
|
-
return null;
|
|
11959
|
-
}
|
|
11960
|
-
return arr.findIndex((e) => e);
|
|
11961
|
-
};
|
|
11962
12013
|
|
|
11963
12014
|
// src/revamp/domain/components/SelectInputComponent.ts
|
|
11964
12015
|
var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
@@ -11980,10 +12031,8 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
11980
12031
|
"summariser"
|
|
11981
12032
|
]);
|
|
11982
12033
|
const children = options.map((option) => option.component);
|
|
11983
|
-
const selectedIndex =
|
|
11984
|
-
|
|
11985
|
-
(option) => isPartialLocalValueMatch(selectProps.initialValue, option.component.getLocalValue())
|
|
11986
|
-
)
|
|
12034
|
+
const selectedIndex = options.findIndex(
|
|
12035
|
+
(option) => isPartialLocalValueMatch(selectProps.initialValue, option.component.getLocalValue())
|
|
11987
12036
|
);
|
|
11988
12037
|
const update = getInputUpdateFunction(uid, updateComponent);
|
|
11989
12038
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
@@ -13133,11 +13182,10 @@ var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formPr
|
|
|
13133
13182
|
});
|
|
13134
13183
|
|
|
13135
13184
|
// src/revamp/domain/mappers/layout/formLayoutToComponent.ts
|
|
13136
|
-
var formLayoutToComponent = (uid, { schemaId,
|
|
13185
|
+
var formLayoutToComponent = (uid, { schemaId, control, margin = "md" }, mapperProps) => {
|
|
13137
13186
|
const { step, stepLocalValue } = mapperProps;
|
|
13138
13187
|
const { model, errors, schemas } = step;
|
|
13139
|
-
const
|
|
13140
|
-
const schema = schemas.find((s) => s.$id === id);
|
|
13188
|
+
const schema = schemas.find((s) => s.$id === schemaId);
|
|
13141
13189
|
if (!schema) {
|
|
13142
13190
|
throw new Error("Bad layout schemaId");
|
|
13143
13191
|
}
|
|
@@ -13573,36 +13621,41 @@ var mapLayoutToComponent = (uid, layout, mapperProps) => {
|
|
|
13573
13621
|
}
|
|
13574
13622
|
};
|
|
13575
13623
|
|
|
13576
|
-
// src/revamp/domain/mappers/
|
|
13577
|
-
var
|
|
13624
|
+
// src/revamp/domain/mappers/mapStepToComponent.ts
|
|
13625
|
+
var mapStepToComponent = (_a) => {
|
|
13578
13626
|
var _b = _a, {
|
|
13627
|
+
loadingState,
|
|
13579
13628
|
displayStepTitle
|
|
13580
13629
|
} = _b, mapperProps = __objRest(_b, [
|
|
13630
|
+
"loadingState",
|
|
13581
13631
|
"displayStepTitle"
|
|
13582
13632
|
]);
|
|
13583
13633
|
const { id, key, title, layout = [], errors } = mapperProps.step;
|
|
13584
13634
|
const stepId = id || key;
|
|
13585
13635
|
const uid = stepId != null ? stepId : "step";
|
|
13586
|
-
const heading = title && displayStepTitle
|
|
13587
|
-
// prefix step id or flow id
|
|
13636
|
+
const heading = title && displayStepTitle ? headingLayoutToComponent(`${uid}.title`, {
|
|
13588
13637
|
type: "heading",
|
|
13589
13638
|
text: title,
|
|
13590
13639
|
align: "center",
|
|
13591
13640
|
size: "lg"
|
|
13592
|
-
});
|
|
13593
|
-
const stepError = (errors == null ? void 0 : errors.error)
|
|
13641
|
+
}) : void 0;
|
|
13642
|
+
const stepError = (errors == null ? void 0 : errors.error) ? alertLayoutToComponent(`${uid}.global-error`, {
|
|
13594
13643
|
type: "alert",
|
|
13595
13644
|
markdown: errors.error,
|
|
13596
13645
|
context: "negative"
|
|
13597
|
-
});
|
|
13598
|
-
const
|
|
13646
|
+
}) : void 0;
|
|
13647
|
+
const additionalComponents = [...heading ? [heading] : [], ...stepError ? [stepError] : []];
|
|
13599
13648
|
const layoutComponents = layout.map(
|
|
13600
13649
|
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps)
|
|
13601
13650
|
);
|
|
13602
13651
|
if (stepId === void 0) {
|
|
13603
13652
|
throw new Error("Step must have an id or a key");
|
|
13604
13653
|
}
|
|
13605
|
-
return
|
|
13654
|
+
return createStepComponent({
|
|
13655
|
+
uid,
|
|
13656
|
+
loadingState,
|
|
13657
|
+
components: [...additionalComponents, ...layoutComponents]
|
|
13658
|
+
});
|
|
13606
13659
|
};
|
|
13607
13660
|
|
|
13608
13661
|
// src/revamp/utils/findComponent.ts
|
|
@@ -13625,11 +13678,13 @@ var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
|
13625
13678
|
}, []);
|
|
13626
13679
|
|
|
13627
13680
|
// src/revamp/step/Step.tsx
|
|
13628
|
-
var
|
|
13681
|
+
var import_jsx_runtime119 = require("react/jsx-runtime");
|
|
13682
|
+
var emptyStepComponent = createEmptyStepComponent();
|
|
13629
13683
|
function Step({
|
|
13630
13684
|
localValue: initialLocalValue,
|
|
13631
13685
|
step,
|
|
13632
13686
|
displayStepTitle = true,
|
|
13687
|
+
loadingState,
|
|
13633
13688
|
getErrorMessageFunctions,
|
|
13634
13689
|
render,
|
|
13635
13690
|
httpClient,
|
|
@@ -13639,27 +13694,36 @@ function Step({
|
|
|
13639
13694
|
triggerRefresh
|
|
13640
13695
|
}) {
|
|
13641
13696
|
var _a;
|
|
13642
|
-
const [
|
|
13643
|
-
const
|
|
13644
|
-
const updateComponent = (0,
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
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;
|
|
13651
13715
|
});
|
|
13652
|
-
}, []);
|
|
13653
|
-
const onAction = (0,
|
|
13716
|
+
}, [loadingState]);
|
|
13717
|
+
const onAction = (0, import_react56.useCallback)(
|
|
13654
13718
|
async (action) => {
|
|
13655
13719
|
var _a2;
|
|
13656
13720
|
const skipValidation = action.method === "GET" || Boolean(action.skipValidation);
|
|
13657
|
-
const canSubmit = skipValidation ||
|
|
13721
|
+
const canSubmit = skipValidation || stepComponentRef.current.validate();
|
|
13658
13722
|
if (canSubmit) {
|
|
13659
13723
|
try {
|
|
13660
|
-
const model = await
|
|
13724
|
+
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13661
13725
|
const payload = mergeModels(model, (_a2 = action.data) != null ? _a2 : null);
|
|
13662
|
-
const localValue =
|
|
13726
|
+
const localValue = stepComponentRef.current.getLocalValue();
|
|
13663
13727
|
void triggerSubmission(action, payload, localValue);
|
|
13664
13728
|
} catch (e) {
|
|
13665
13729
|
if (true) {
|
|
@@ -13670,23 +13734,24 @@ function Step({
|
|
|
13670
13734
|
},
|
|
13671
13735
|
[triggerSubmission]
|
|
13672
13736
|
);
|
|
13673
|
-
const onRefresh = (0,
|
|
13737
|
+
const onRefresh = (0, import_react56.useCallback)(
|
|
13674
13738
|
async (schemaId, url) => {
|
|
13675
13739
|
var _a2;
|
|
13676
13740
|
const refreshUrl = (_a2 = url != null ? url : step.refreshUrl) != null ? _a2 : step.refreshFormUrl;
|
|
13677
13741
|
if (refreshUrl) {
|
|
13678
|
-
const model = await
|
|
13679
|
-
const localValue =
|
|
13742
|
+
const model = await stepComponentRef.current.getSubmittableValue();
|
|
13743
|
+
const localValue = stepComponentRef.current.getLocalValue();
|
|
13680
13744
|
void triggerRefresh({ refreshUrl, model, localValue, schemaId });
|
|
13681
13745
|
}
|
|
13682
13746
|
},
|
|
13683
13747
|
[step.refreshUrl, step.refreshFormUrl, triggerRefresh]
|
|
13684
13748
|
);
|
|
13685
|
-
(0,
|
|
13686
|
-
const
|
|
13749
|
+
(0, import_react56.useEffect)(() => {
|
|
13750
|
+
const initialComponent = mapStepToComponent({
|
|
13687
13751
|
stepLocalValue: initialLocalValue,
|
|
13688
13752
|
step,
|
|
13689
13753
|
displayStepTitle,
|
|
13754
|
+
loadingState,
|
|
13690
13755
|
updateComponent,
|
|
13691
13756
|
getErrorMessageFunctions,
|
|
13692
13757
|
trackEvent,
|
|
@@ -13695,13 +13760,12 @@ function Step({
|
|
|
13695
13760
|
onAction,
|
|
13696
13761
|
onRefresh
|
|
13697
13762
|
});
|
|
13698
|
-
|
|
13699
|
-
|
|
13763
|
+
setStepComponent(initialComponent);
|
|
13764
|
+
stepComponentRef.current = initialComponent;
|
|
13700
13765
|
if (step.key) {
|
|
13701
13766
|
logEvent("warning", 'Step.key is deprecated, please use "id" instead');
|
|
13702
13767
|
}
|
|
13703
13768
|
}, [
|
|
13704
|
-
initialLocalValue,
|
|
13705
13769
|
step,
|
|
13706
13770
|
displayStepTitle,
|
|
13707
13771
|
updateComponent,
|
|
@@ -13712,13 +13776,20 @@ function Step({
|
|
|
13712
13776
|
logEvent,
|
|
13713
13777
|
onRefresh
|
|
13714
13778
|
]);
|
|
13715
|
-
(0,
|
|
13779
|
+
(0, import_react56.useEffect)(() => {
|
|
13716
13780
|
trackEvent("Step Shown");
|
|
13717
13781
|
}, [(_a = step.id) != null ? _a : step.key]);
|
|
13718
|
-
return /* @__PURE__ */ (0,
|
|
13782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(import_jsx_runtime119.Fragment, { children: render(stepComponent) });
|
|
13719
13783
|
}
|
|
13720
13784
|
var Step_default = Step;
|
|
13721
13785
|
|
|
13786
|
+
// src/revamp/renderers/stepComponentToProps.ts
|
|
13787
|
+
var stepComponentToProps = ({ loadingState }, children) => ({
|
|
13788
|
+
type: "step",
|
|
13789
|
+
loadingState,
|
|
13790
|
+
children
|
|
13791
|
+
});
|
|
13792
|
+
|
|
13722
13793
|
// src/revamp/renderers/mappers/alertComponentToProps.ts
|
|
13723
13794
|
var alertComponentToProps = ({
|
|
13724
13795
|
context,
|
|
@@ -13855,54 +13926,6 @@ var hiddenComponentToProps = () => ({
|
|
|
13855
13926
|
type: "hidden"
|
|
13856
13927
|
});
|
|
13857
13928
|
|
|
13858
|
-
// src/revamp/renderers/mappers/searchComponentToProps.ts
|
|
13859
|
-
var searchComponentToProps = (component) => {
|
|
13860
|
-
const { uid, control, emptyMessage, error, isLoading, margin, query, results, title } = component;
|
|
13861
|
-
const onChange = component.onChange.bind(component);
|
|
13862
|
-
const onSelect = component.onSelect.bind(component);
|
|
13863
|
-
const state = getSearchState({
|
|
13864
|
-
emptyMessage,
|
|
13865
|
-
error,
|
|
13866
|
-
query,
|
|
13867
|
-
results,
|
|
13868
|
-
onChange,
|
|
13869
|
-
onSelect
|
|
13870
|
-
});
|
|
13871
|
-
return {
|
|
13872
|
-
type: "search",
|
|
13873
|
-
id: uid,
|
|
13874
|
-
control,
|
|
13875
|
-
isLoading,
|
|
13876
|
-
margin,
|
|
13877
|
-
query,
|
|
13878
|
-
state,
|
|
13879
|
-
title,
|
|
13880
|
-
onChange
|
|
13881
|
-
};
|
|
13882
|
-
};
|
|
13883
|
-
var getSearchState = ({
|
|
13884
|
-
emptyMessage,
|
|
13885
|
-
error,
|
|
13886
|
-
query,
|
|
13887
|
-
results,
|
|
13888
|
-
onChange,
|
|
13889
|
-
onSelect
|
|
13890
|
-
}) => {
|
|
13891
|
-
if (!query) {
|
|
13892
|
-
return { type: "pending" };
|
|
13893
|
-
}
|
|
13894
|
-
if (error) {
|
|
13895
|
-
return { type: "error", onRetry: () => onChange(query) };
|
|
13896
|
-
}
|
|
13897
|
-
if (results.length === 0) {
|
|
13898
|
-
return { type: "noResults", message: emptyMessage };
|
|
13899
|
-
}
|
|
13900
|
-
const rendererResults = results.map((result) => __spreadProps(__spreadValues({}, result), {
|
|
13901
|
-
onClick: () => onSelect(result)
|
|
13902
|
-
}));
|
|
13903
|
-
return { type: "results", results: rendererResults };
|
|
13904
|
-
};
|
|
13905
|
-
|
|
13906
13929
|
// src/revamp/renderers/mappers/imageComponentToProps.ts
|
|
13907
13930
|
var imageComponentToProps = ({
|
|
13908
13931
|
accessibilityDescription,
|
|
@@ -13973,6 +13996,34 @@ var modalComponentToProps = ({ control, margin, trigger }, components) => ({
|
|
|
13973
13996
|
trigger
|
|
13974
13997
|
});
|
|
13975
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
|
+
|
|
13976
14027
|
// src/revamp/renderers/mappers/objectComponentToProps.ts
|
|
13977
14028
|
var objectComponentToProps = ({ control, description, help, title }, children) => ({
|
|
13978
14029
|
type: "form-section",
|
|
@@ -13997,34 +14048,6 @@ var paragraphComponentToProps = ({
|
|
|
13997
14048
|
text
|
|
13998
14049
|
});
|
|
13999
14050
|
|
|
14000
|
-
// src/revamp/renderers/mappers/numberInputComponentToProps.ts
|
|
14001
|
-
var numberInputComponentToProps = (component) => __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-number")), {
|
|
14002
|
-
onChange: component.onChange.bind(component)
|
|
14003
|
-
});
|
|
14004
|
-
|
|
14005
|
-
// src/revamp/renderers/mappers/uploadInputComponentToProps.ts
|
|
14006
|
-
var uploadInputComponentToProps = (component) => {
|
|
14007
|
-
const { accepts, maxSize } = component;
|
|
14008
|
-
return __spreadProps(__spreadValues({}, inputComponentToProps(component, "input-upload")), {
|
|
14009
|
-
accepts,
|
|
14010
|
-
maxSize,
|
|
14011
|
-
onUpload: component.onUpload.bind(component)
|
|
14012
|
-
});
|
|
14013
|
-
};
|
|
14014
|
-
|
|
14015
|
-
// src/revamp/renderers/mappers/selectInputComponentToProps.ts
|
|
14016
|
-
var selectInputComponentToProps = (component, children) => {
|
|
14017
|
-
var _b;
|
|
14018
|
-
const { options, selectedIndex, onSelect } = component;
|
|
14019
|
-
const _a = inputComponentToProps(component, "input-select"), { value } = _a, props = __objRest(_a, ["value"]);
|
|
14020
|
-
return __spreadProps(__spreadValues({}, props), {
|
|
14021
|
-
options,
|
|
14022
|
-
selectedIndex,
|
|
14023
|
-
onSelect: onSelect.bind(component),
|
|
14024
|
-
children: (_b = children[selectedIndex != null ? selectedIndex : -1]) != null ? _b : null
|
|
14025
|
-
});
|
|
14026
|
-
};
|
|
14027
|
-
|
|
14028
14051
|
// src/revamp/renderers/mappers/repeatableComponentToProps.ts
|
|
14029
14052
|
var repeatableComponentToProps = (component, children, editableItemChildren) => {
|
|
14030
14053
|
const {
|
|
@@ -14087,6 +14110,67 @@ var reviewComponentToProps = ({
|
|
|
14087
14110
|
title
|
|
14088
14111
|
});
|
|
14089
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
|
+
|
|
14090
14174
|
// src/revamp/renderers/mappers/statusListComponentToProps.ts
|
|
14091
14175
|
var statusListComponentToProps = ({
|
|
14092
14176
|
control,
|
|
@@ -14107,26 +14191,13 @@ var textInputComponentToProps = (component) => __spreadProps(__spreadValues({},
|
|
|
14107
14191
|
onChange: component.onChange.bind(component)
|
|
14108
14192
|
});
|
|
14109
14193
|
|
|
14110
|
-
// src/revamp/renderers/mappers/
|
|
14111
|
-
var
|
|
14112
|
-
const { accepts,
|
|
14113
|
-
|
|
14114
|
-
const fileList = Object.values(fileMap).map((file) => {
|
|
14115
|
-
var _a;
|
|
14116
|
-
return {
|
|
14117
|
-
id: (_a = findIdByValue(file)) != null ? _a : "",
|
|
14118
|
-
file
|
|
14119
|
-
};
|
|
14120
|
-
});
|
|
14121
|
-
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")), {
|
|
14122
14198
|
accepts,
|
|
14123
14199
|
maxSize,
|
|
14124
|
-
|
|
14125
|
-
maxItems,
|
|
14126
|
-
uploadLabel,
|
|
14127
|
-
value: fileList,
|
|
14128
|
-
onUpload: component.onUpload.bind(component),
|
|
14129
|
-
onDelete: component.onDelete.bind(component)
|
|
14200
|
+
onUpload: component.onUpload.bind(component)
|
|
14130
14201
|
});
|
|
14131
14202
|
};
|
|
14132
14203
|
|
|
@@ -14137,6 +14208,8 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
14137
14208
|
return hiddenComponentToProps();
|
|
14138
14209
|
}
|
|
14139
14210
|
switch (component.type) {
|
|
14211
|
+
case "step":
|
|
14212
|
+
return stepComponentToProps(component, children);
|
|
14140
14213
|
case "alert":
|
|
14141
14214
|
return alertComponentToProps(component);
|
|
14142
14215
|
case "all-of":
|
|
@@ -14203,7 +14276,7 @@ var componentToRendererProps = (component, nestedContent) => {
|
|
|
14203
14276
|
};
|
|
14204
14277
|
|
|
14205
14278
|
// src/revamp/step/utils/getRenderFunction.tsx
|
|
14206
|
-
var
|
|
14279
|
+
var import_jsx_runtime120 = require("react/jsx-runtime");
|
|
14207
14280
|
var getRenderFunction = (renderers2) => {
|
|
14208
14281
|
function ComponentRenderer(props) {
|
|
14209
14282
|
const { type } = props;
|
|
@@ -14242,7 +14315,7 @@ var getRenderFunction = (renderers2) => {
|
|
|
14242
14315
|
children: component.getChildren().map(render)
|
|
14243
14316
|
};
|
|
14244
14317
|
};
|
|
14245
|
-
const render = (component) => /* @__PURE__ */ (0,
|
|
14318
|
+
const render = (component) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
14246
14319
|
ComponentRenderer,
|
|
14247
14320
|
__spreadValues({}, componentToRendererProps(component, getNestedContent(component))),
|
|
14248
14321
|
component.uid
|
|
@@ -14337,7 +14410,7 @@ var formatDateOptions = {
|
|
|
14337
14410
|
};
|
|
14338
14411
|
|
|
14339
14412
|
// src/revamp/DynamicFlowCore.tsx
|
|
14340
|
-
var
|
|
14413
|
+
var import_jsx_runtime121 = require("react/jsx-runtime");
|
|
14341
14414
|
function DynamicFlowCore(props) {
|
|
14342
14415
|
var _a;
|
|
14343
14416
|
const {
|
|
@@ -14353,20 +14426,21 @@ function DynamicFlowCore(props) {
|
|
|
14353
14426
|
onLog
|
|
14354
14427
|
} = props;
|
|
14355
14428
|
const { formatMessage, locale } = (0, import_react_intl35.useIntl)();
|
|
14356
|
-
const getErrorMessageFunctions = (0,
|
|
14429
|
+
const getErrorMessageFunctions = (0, import_react57.useMemo)(
|
|
14357
14430
|
() => getSchemaErrorMessageFunction(formatMessage, locale),
|
|
14358
14431
|
[formatMessage, locale]
|
|
14359
14432
|
);
|
|
14360
|
-
(0,
|
|
14433
|
+
(0, import_react57.useEffect)(() => {
|
|
14361
14434
|
var _a2;
|
|
14362
14435
|
if (!initialStep && initialAction) {
|
|
14363
14436
|
void triggerSubmission(initialAction, (_a2 = initialAction.data) != null ? _a2 : {}, null);
|
|
14364
14437
|
}
|
|
14365
14438
|
}, []);
|
|
14366
|
-
const [step, setStep] = (0,
|
|
14367
|
-
const localValueRef = (0,
|
|
14368
|
-
const [etag, setEtag] = (0,
|
|
14369
|
-
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");
|
|
14370
14444
|
const abortCurrentAndGetNewAbortSignal = () => {
|
|
14371
14445
|
abortControllerRef.current.abort();
|
|
14372
14446
|
abortControllerRef.current = new AbortController();
|
|
@@ -14374,26 +14448,27 @@ function DynamicFlowCore(props) {
|
|
|
14374
14448
|
};
|
|
14375
14449
|
const stepId = (_a = step == null ? void 0 : step.id) != null ? _a : step == null ? void 0 : step.key;
|
|
14376
14450
|
const stepAnalytics = step == null ? void 0 : step.analytics;
|
|
14377
|
-
const trackEvent = (0,
|
|
14451
|
+
const trackEvent = (0, import_react57.useMemo)(
|
|
14378
14452
|
() => getAnalyticsEventDispatcher({ flowId, stepId, analytics: stepAnalytics, onEvent }),
|
|
14379
14453
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
14380
14454
|
[flowId, stepId, JSON.stringify(stepAnalytics), onEvent]
|
|
14381
14455
|
);
|
|
14382
|
-
const logEvent = (0,
|
|
14383
|
-
(0,
|
|
14384
|
-
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)(
|
|
14385
14459
|
(error, analytics) => {
|
|
14386
14460
|
trackEvent("Flow Failed", __spreadValues({}, analytics));
|
|
14387
14461
|
onError(error);
|
|
14388
14462
|
},
|
|
14389
14463
|
[onError, trackEvent]
|
|
14390
14464
|
);
|
|
14391
|
-
const triggerSubmission = (0,
|
|
14465
|
+
const triggerSubmission = (0, import_react57.useCallback)(
|
|
14392
14466
|
async (action, model, localValue) => {
|
|
14393
14467
|
if (true) {
|
|
14394
14468
|
console.log("\u23EF\uFE0F triggerSubmission", JSON.stringify({ action, model }, null, 2));
|
|
14395
14469
|
}
|
|
14396
14470
|
try {
|
|
14471
|
+
setLoadingState("loading");
|
|
14397
14472
|
const command = await executeSubmission({
|
|
14398
14473
|
action,
|
|
14399
14474
|
model,
|
|
@@ -14410,11 +14485,13 @@ function DynamicFlowCore(props) {
|
|
|
14410
14485
|
}
|
|
14411
14486
|
case "replace-step": {
|
|
14412
14487
|
localValueRef.current = null;
|
|
14488
|
+
setLoadingState("idle");
|
|
14413
14489
|
setStep(command.step);
|
|
14414
14490
|
setEtag(command.etag);
|
|
14415
14491
|
break;
|
|
14416
14492
|
}
|
|
14417
14493
|
case "error": {
|
|
14494
|
+
setLoadingState("idle");
|
|
14418
14495
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
14419
14496
|
const { errors = { error: genericErrorMessage } } = command.body;
|
|
14420
14497
|
if (step) {
|
|
@@ -14438,6 +14515,7 @@ function DynamicFlowCore(props) {
|
|
|
14438
14515
|
});
|
|
14439
14516
|
switch (refreshCommand.type) {
|
|
14440
14517
|
case "refresh-step":
|
|
14518
|
+
setLoadingState("idle");
|
|
14441
14519
|
setStep(__spreadProps(__spreadValues({}, refreshCommand.step), { errors }));
|
|
14442
14520
|
setEtag(refreshCommand.etag);
|
|
14443
14521
|
break;
|
|
@@ -14456,7 +14534,7 @@ function DynamicFlowCore(props) {
|
|
|
14456
14534
|
},
|
|
14457
14535
|
[httpClient, trackEvent, onCompletion, getErrorMessageFunctions, step, etag, closeWithError]
|
|
14458
14536
|
);
|
|
14459
|
-
const triggerRefresh = (0,
|
|
14537
|
+
const triggerRefresh = (0, import_react57.useCallback)(
|
|
14460
14538
|
async ({
|
|
14461
14539
|
refreshUrl,
|
|
14462
14540
|
model,
|
|
@@ -14468,6 +14546,7 @@ function DynamicFlowCore(props) {
|
|
|
14468
14546
|
}
|
|
14469
14547
|
try {
|
|
14470
14548
|
localValueRef.current = localValue;
|
|
14549
|
+
setLoadingState("loading");
|
|
14471
14550
|
const command = await executeRefresh({
|
|
14472
14551
|
abortSignal: abortCurrentAndGetNewAbortSignal(),
|
|
14473
14552
|
url: refreshUrl,
|
|
@@ -14477,6 +14556,7 @@ function DynamicFlowCore(props) {
|
|
|
14477
14556
|
httpClient,
|
|
14478
14557
|
trackEvent
|
|
14479
14558
|
});
|
|
14559
|
+
setLoadingState("idle");
|
|
14480
14560
|
switch (command.type) {
|
|
14481
14561
|
case "refresh-step":
|
|
14482
14562
|
setStep(command.step);
|
|
@@ -14495,16 +14575,17 @@ function DynamicFlowCore(props) {
|
|
|
14495
14575
|
},
|
|
14496
14576
|
[etag, httpClient, trackEvent, closeWithError]
|
|
14497
14577
|
);
|
|
14498
|
-
const render = (0,
|
|
14499
|
-
() => getRenderFunction([CoreContainerRenderer, ...renderers2]),
|
|
14578
|
+
const render = (0, import_react57.useMemo)(
|
|
14579
|
+
() => getRenderFunction([CoreContainerRenderer, ...renderers2, StepRenderer]),
|
|
14500
14580
|
[renderers2]
|
|
14501
14581
|
);
|
|
14502
|
-
return /* @__PURE__ */ (0,
|
|
14582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ErrorBoundary_default, { onError, children: step ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
14503
14583
|
Step_default,
|
|
14504
14584
|
{
|
|
14505
14585
|
displayStepTitle,
|
|
14506
14586
|
step,
|
|
14507
14587
|
localValue: localValueRef.current,
|
|
14588
|
+
loadingState,
|
|
14508
14589
|
getErrorMessageFunctions,
|
|
14509
14590
|
render,
|
|
14510
14591
|
httpClient,
|
|
@@ -14517,16 +14598,16 @@ function DynamicFlowCore(props) {
|
|
|
14517
14598
|
}
|
|
14518
14599
|
|
|
14519
14600
|
// src/revamp/DynamicFlowWise.tsx
|
|
14520
|
-
var
|
|
14601
|
+
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
14521
14602
|
var renderers = getWiseRenderers();
|
|
14522
14603
|
function DynamicFlowWise(props) {
|
|
14523
14604
|
const { httpClient } = props;
|
|
14524
14605
|
const { locale } = (0, import_react_intl36.useIntl)();
|
|
14525
|
-
const wiseHttpClient = (0,
|
|
14606
|
+
const wiseHttpClient = (0, import_react58.useMemo)(
|
|
14526
14607
|
() => makeWiseHttpClient(httpClient, locale),
|
|
14527
14608
|
[httpClient, locale]
|
|
14528
14609
|
);
|
|
14529
|
-
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 })) });
|
|
14530
14611
|
}
|
|
14531
14612
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
14532
14613
|
var makeWiseHttpClient = (httpClient, locale) => async (input, init) => httpClient(
|