@wix/form-public 0.25.0 → 0.26.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/dist/_tsup-dts-rollup.d.cts +34 -6
- package/dist/_tsup-dts-rollup.d.ts +34 -6
- package/dist/index.cjs +347 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +248 -105
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React32 = require('react');
|
|
4
4
|
var ReactDOM = require('react-dom');
|
|
5
5
|
var camelCase = require('lodash.camelcase');
|
|
6
6
|
var mapKeys = require('lodash.mapkeys');
|
|
@@ -26,7 +26,7 @@ function _interopNamespace(e) {
|
|
|
26
26
|
return Object.freeze(n);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var React32__namespace = /*#__PURE__*/_interopNamespace(React32);
|
|
30
30
|
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
31
31
|
var camelCase__default = /*#__PURE__*/_interopDefault(camelCase);
|
|
32
32
|
var mapKeys__default = /*#__PURE__*/_interopDefault(mapKeys);
|
|
@@ -4287,7 +4287,7 @@ var require_classnames = __commonJS({
|
|
|
4287
4287
|
var RicosViewerContext;
|
|
4288
4288
|
var init_ViewerContext = __esm({
|
|
4289
4289
|
"../../node_modules/@wix/ricos/dist/es/ricos-context/viewer/ViewerContext.js"() {
|
|
4290
|
-
RicosViewerContext =
|
|
4290
|
+
RicosViewerContext = React32__namespace.default.createContext(null);
|
|
4291
4291
|
}
|
|
4292
4292
|
});
|
|
4293
4293
|
|
|
@@ -5236,16 +5236,16 @@ var require_prop_types = __commonJS({
|
|
|
5236
5236
|
// ../../node_modules/@babel/runtime/helpers/extends.js
|
|
5237
5237
|
var require_extends = __commonJS({
|
|
5238
5238
|
"../../node_modules/@babel/runtime/helpers/extends.js"(exports, module) {
|
|
5239
|
-
function
|
|
5240
|
-
return module.exports =
|
|
5239
|
+
function _extends7() {
|
|
5240
|
+
return module.exports = _extends7 = Object.assign ? Object.assign.bind() : function(n) {
|
|
5241
5241
|
for (var e = 1; e < arguments.length; e++) {
|
|
5242
5242
|
var t = arguments[e];
|
|
5243
5243
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
5244
5244
|
}
|
|
5245
5245
|
return n;
|
|
5246
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports,
|
|
5246
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _extends7.apply(null, arguments);
|
|
5247
5247
|
}
|
|
5248
|
-
module.exports =
|
|
5248
|
+
module.exports = _extends7, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5249
5249
|
}
|
|
5250
5250
|
});
|
|
5251
5251
|
|
|
@@ -5311,7 +5311,7 @@ var init_PropTypes = __esm({
|
|
|
5311
5311
|
var TransitionGroupContext_default;
|
|
5312
5312
|
var init_TransitionGroupContext = __esm({
|
|
5313
5313
|
"../../node_modules/react-transition-group/esm/TransitionGroupContext.js"() {
|
|
5314
|
-
TransitionGroupContext_default =
|
|
5314
|
+
TransitionGroupContext_default = React32__namespace.default.createContext(null);
|
|
5315
5315
|
}
|
|
5316
5316
|
});
|
|
5317
5317
|
|
|
@@ -5543,13 +5543,13 @@ var init_Transition = __esm({
|
|
|
5543
5543
|
var _this$props = this.props, children = _this$props.children; _this$props.in; _this$props.mountOnEnter; _this$props.unmountOnExit; _this$props.appear; _this$props.enter; _this$props.exit; _this$props.timeout; _this$props.addEndListener; _this$props.onEnter; _this$props.onEntering; _this$props.onEntered; _this$props.onExit; _this$props.onExiting; _this$props.onExited; _this$props.nodeRef; var childProps = _objectWithoutPropertiesLoose(_this$props, ["children", "in", "mountOnEnter", "unmountOnExit", "appear", "enter", "exit", "timeout", "addEndListener", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "nodeRef"]);
|
|
5544
5544
|
return (
|
|
5545
5545
|
// allows for nested Transitions
|
|
5546
|
-
/* @__PURE__ */
|
|
5546
|
+
/* @__PURE__ */ React32__namespace.default.createElement(TransitionGroupContext_default.Provider, {
|
|
5547
5547
|
value: null
|
|
5548
|
-
}, typeof children === "function" ? children(status, childProps) :
|
|
5548
|
+
}, typeof children === "function" ? children(status, childProps) : React32__namespace.default.cloneElement(React32__namespace.default.Children.only(children), childProps))
|
|
5549
5549
|
);
|
|
5550
5550
|
};
|
|
5551
5551
|
return Transition2;
|
|
5552
|
-
})(
|
|
5552
|
+
})(React32__namespace.default.Component);
|
|
5553
5553
|
Transition.contextType = TransitionGroupContext_default;
|
|
5554
5554
|
Transition.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
5555
5555
|
/**
|
|
@@ -20519,7 +20519,6 @@ var INPUT_FIELD_TYPES = {
|
|
|
20519
20519
|
var READONLY_FIELD_TYPES = {
|
|
20520
20520
|
HEADER: "HEADER",
|
|
20521
20521
|
RICH_TEXT: "RICH_TEXT",
|
|
20522
|
-
SUBMIT_BUTTON: "SUBMIT_BUTTON",
|
|
20523
20522
|
ECOM_CONTACT_DETAILS: "ECOM_CONTACT_DETAILS",
|
|
20524
20523
|
ECOM_SHIPPING_DETAILS: "ECOM_SHIPPING_DETAILS",
|
|
20525
20524
|
BOOKINGS_HEADER: "BOOKINGS_HEADER",
|
|
@@ -20530,8 +20529,7 @@ var READONLY_FIELD_TYPES = {
|
|
|
20530
20529
|
// ../form-fields/dist/esm/constants/field-types.js
|
|
20531
20530
|
var FIELD_TYPES = {
|
|
20532
20531
|
...INPUT_FIELD_TYPES,
|
|
20533
|
-
...READONLY_FIELD_TYPES
|
|
20534
|
-
};
|
|
20532
|
+
...READONLY_FIELD_TYPES};
|
|
20535
20533
|
|
|
20536
20534
|
// ../form-fields/dist/esm/constants/empty-values.js
|
|
20537
20535
|
var EMPTY_VALUE = null;
|
|
@@ -20547,49 +20545,56 @@ var Breakpoint = /* @__PURE__ */ (function(Breakpoint2) {
|
|
|
20547
20545
|
return Breakpoint2;
|
|
20548
20546
|
})({});
|
|
20549
20547
|
var DEFAULT_BREAKPOINT = Breakpoint.LARGE;
|
|
20550
|
-
var FieldValidationContext = /* @__PURE__ */
|
|
20551
|
-
var useFieldValidation = () =>
|
|
20548
|
+
var FieldValidationContext = /* @__PURE__ */ React32.createContext(null);
|
|
20549
|
+
var useFieldValidation = () => React32.useContext(FieldValidationContext) || {};
|
|
20552
20550
|
var FORM_STATUS = {
|
|
20553
20551
|
BUSY: "BUSY",
|
|
20554
20552
|
READY: "READY"
|
|
20555
20553
|
};
|
|
20556
|
-
var FormStatusContext = /* @__PURE__ */
|
|
20554
|
+
var FormStatusContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20557
20555
|
var FormStatusProvider = (_ref) => {
|
|
20558
20556
|
let {
|
|
20559
20557
|
children,
|
|
20560
20558
|
onStatusChange
|
|
20561
20559
|
} = _ref;
|
|
20562
|
-
const previousFormStatus =
|
|
20563
|
-
const [fieldStatusByTarget, setFieldStatusByTarget] =
|
|
20564
|
-
const setFormStatus =
|
|
20560
|
+
const previousFormStatus = React32.useRef(FORM_STATUS.READY);
|
|
20561
|
+
const [fieldStatusByTarget, setFieldStatusByTarget] = React32.useState({});
|
|
20562
|
+
const setFormStatus = React32.useCallback((target, status) => {
|
|
20565
20563
|
setFieldStatusByTarget((previous) => ({
|
|
20566
20564
|
...previous,
|
|
20567
20565
|
[target]: status
|
|
20568
20566
|
}));
|
|
20569
20567
|
}, []);
|
|
20570
|
-
const currentFormStatus =
|
|
20568
|
+
const currentFormStatus = React32.useMemo(() => {
|
|
20571
20569
|
const isFormBusy = Object.values(fieldStatusByTarget).some((status) => status === FORM_STATUS.BUSY);
|
|
20572
20570
|
return isFormBusy ? FORM_STATUS.BUSY : FORM_STATUS.READY;
|
|
20573
20571
|
}, [fieldStatusByTarget]);
|
|
20574
|
-
|
|
20572
|
+
React32.useEffect(() => {
|
|
20575
20573
|
if (previousFormStatus.current !== currentFormStatus) {
|
|
20576
20574
|
previousFormStatus.current = currentFormStatus;
|
|
20577
20575
|
onStatusChange == null || onStatusChange(currentFormStatus);
|
|
20578
20576
|
}
|
|
20579
20577
|
}, [currentFormStatus, onStatusChange]);
|
|
20580
|
-
const contextValue =
|
|
20578
|
+
const contextValue = React32.useMemo(() => {
|
|
20581
20579
|
return {
|
|
20582
20580
|
formStatus: currentFormStatus,
|
|
20583
20581
|
setFormStatus
|
|
20584
20582
|
};
|
|
20585
20583
|
}, [currentFormStatus, setFormStatus]);
|
|
20586
|
-
return /* @__PURE__ */
|
|
20584
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FormStatusContext.Provider, {
|
|
20587
20585
|
value: contextValue
|
|
20588
20586
|
}, children);
|
|
20589
20587
|
};
|
|
20590
|
-
|
|
20588
|
+
function useFormStatus() {
|
|
20589
|
+
const context = React32.useContext(FormStatusContext);
|
|
20590
|
+
if (context === void 0) {
|
|
20591
|
+
throw new Error("useFormStatus must be used within a Form Status provider");
|
|
20592
|
+
}
|
|
20593
|
+
return context;
|
|
20594
|
+
}
|
|
20595
|
+
var WixRicosViewerContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20591
20596
|
function useWixRicosViewer() {
|
|
20592
|
-
const context =
|
|
20597
|
+
const context = React32.useContext(WixRicosViewerContext);
|
|
20593
20598
|
if (context === void 0) {
|
|
20594
20599
|
throw new Error("useWixRicosViewer must be used within a WixRicosViewerContext.Provider");
|
|
20595
20600
|
}
|
|
@@ -20651,7 +20656,7 @@ var link_viewer_default = {
|
|
|
20651
20656
|
// ../../node_modules/@wix/ricos/dist/es/plugin-link/nodeViewDecorators/anchor.js
|
|
20652
20657
|
var decorator = (anchorDecoration, element) => {
|
|
20653
20658
|
const { anchor } = anchorDecoration.anchorData;
|
|
20654
|
-
return /* @__PURE__ */
|
|
20659
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(
|
|
20655
20660
|
"a",
|
|
20656
20661
|
{
|
|
20657
20662
|
key: `anchor-${element?.key}`,
|
|
@@ -20694,7 +20699,7 @@ var LINK_TYPE = "LINK";
|
|
|
20694
20699
|
|
|
20695
20700
|
// ../../node_modules/@wix/ricos/dist/es/plugin-link/nodeViewDecorators/link.js
|
|
20696
20701
|
var decorator2 = (element, linkDecoration, contextualData, node) => {
|
|
20697
|
-
const { baseUrl } =
|
|
20702
|
+
const { baseUrl } = React32.useContext(RicosViewerContext);
|
|
20698
20703
|
const link = linkDecoration.linkData?.link;
|
|
20699
20704
|
const target = link?.target || contextualData.anchorTarget;
|
|
20700
20705
|
const rel = link?.rel || {};
|
|
@@ -20709,7 +20714,7 @@ var decorator2 = (element, linkDecoration, contextualData, node) => {
|
|
|
20709
20714
|
type: Node_Type.TEXT,
|
|
20710
20715
|
textData: node.textData
|
|
20711
20716
|
});
|
|
20712
|
-
return /* @__PURE__ */
|
|
20717
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(
|
|
20713
20718
|
"a",
|
|
20714
20719
|
{
|
|
20715
20720
|
key: `link=${element.key}`,
|
|
@@ -20752,9 +20757,9 @@ var pluginLink = (config) => {
|
|
|
20752
20757
|
|
|
20753
20758
|
// ../form-fields/dist/esm/ui/ricos-viewer/ricos-viewer.js
|
|
20754
20759
|
var import_classnames3 = __toESM(require_classnames());
|
|
20755
|
-
var ConfigContext = /* @__PURE__ */
|
|
20760
|
+
var ConfigContext = /* @__PURE__ */ React32.createContext(null);
|
|
20756
20761
|
function useConfig() {
|
|
20757
|
-
const context =
|
|
20762
|
+
const context = React32.useContext(ConfigContext);
|
|
20758
20763
|
if (context === void 0) {
|
|
20759
20764
|
throw new Error("useConfig must be used within a ConfigContext.Provider");
|
|
20760
20765
|
}
|
|
@@ -20768,7 +20773,7 @@ var htmlAttributesPlugin = (_23) => ({
|
|
|
20768
20773
|
type: "",
|
|
20769
20774
|
nodeViewDecorators: [htmlAttributesDecorator],
|
|
20770
20775
|
nodeViewRenderers: {
|
|
20771
|
-
[Node_Type.EXTERNAL]: (__) => /* @__PURE__ */
|
|
20776
|
+
[Node_Type.EXTERNAL]: (__) => /* @__PURE__ */ React32__namespace.default.createElement(React32__namespace.default.Fragment, null)
|
|
20772
20777
|
}
|
|
20773
20778
|
});
|
|
20774
20779
|
var htmlAttributesDecorator = {
|
|
@@ -20779,13 +20784,13 @@ var htmlAttributesDecorator = {
|
|
|
20779
20784
|
node
|
|
20780
20785
|
} = _ref;
|
|
20781
20786
|
if (((_node$textData = node.textData) == null ? void 0 : _node$textData.text) == null) {
|
|
20782
|
-
return /* @__PURE__ */
|
|
20787
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(React32__namespace.default.Fragment, null);
|
|
20783
20788
|
}
|
|
20784
20789
|
const props = Object.fromEntries(Object.entries(((_node$externalData = node.externalData) == null ? void 0 : _node$externalData.fields) ?? []).map((_ref2) => {
|
|
20785
20790
|
let [k, v] = _ref2;
|
|
20786
20791
|
return [k, v.stringValue];
|
|
20787
20792
|
}));
|
|
20788
|
-
return /* @__PURE__ */
|
|
20793
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("span", props, (_node$textData2 = node.textData) == null ? void 0 : _node$textData2.text);
|
|
20789
20794
|
}
|
|
20790
20795
|
};
|
|
20791
20796
|
|
|
@@ -20804,10 +20809,10 @@ var RicosViewer = (_ref) => {
|
|
|
20804
20809
|
if (!content) {
|
|
20805
20810
|
return null;
|
|
20806
20811
|
}
|
|
20807
|
-
return /* @__PURE__ */
|
|
20812
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
20808
20813
|
className: (0, import_classnames3.default)(ricos_viewer_module_default.container, className),
|
|
20809
20814
|
"data-hook": dataHook
|
|
20810
|
-
}, /* @__PURE__ */
|
|
20815
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(WixRicosViewer, {
|
|
20811
20816
|
biSettings: {
|
|
20812
20817
|
consumer: "Forms",
|
|
20813
20818
|
platform: "Livesite",
|
|
@@ -20821,9 +20826,9 @@ var RicosViewer = (_ref) => {
|
|
|
20821
20826
|
locale
|
|
20822
20827
|
}));
|
|
20823
20828
|
};
|
|
20824
|
-
var ricos_viewer_default = /* @__PURE__ */
|
|
20829
|
+
var ricos_viewer_default = /* @__PURE__ */ React32__namespace.default.memo(RicosViewer);
|
|
20825
20830
|
function useRicosTheme(customTheme) {
|
|
20826
|
-
return
|
|
20831
|
+
return React32.useMemo(() => ({
|
|
20827
20832
|
palette: {
|
|
20828
20833
|
type: "rgb",
|
|
20829
20834
|
bgColor: "var(--wix-forms-formInputBackgroundColor)",
|
|
@@ -20833,7 +20838,7 @@ function useRicosTheme(customTheme) {
|
|
|
20833
20838
|
...customTheme
|
|
20834
20839
|
}), [customTheme]);
|
|
20835
20840
|
}
|
|
20836
|
-
var UniqueFieldSuffixContext = /* @__PURE__ */
|
|
20841
|
+
var UniqueFieldSuffixContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20837
20842
|
var UniqueFieldSuffixContextProvider = (_ref) => {
|
|
20838
20843
|
let {
|
|
20839
20844
|
parentId = "id",
|
|
@@ -20843,28 +20848,28 @@ var UniqueFieldSuffixContextProvider = (_ref) => {
|
|
|
20843
20848
|
compId = "comp"
|
|
20844
20849
|
} = useConfig();
|
|
20845
20850
|
const uniqueId = `${compId}-${parentId.split("-").at(0)}`;
|
|
20846
|
-
return /* @__PURE__ */
|
|
20851
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(UniqueFieldSuffixContext.Provider, {
|
|
20847
20852
|
value: uniqueId
|
|
20848
20853
|
}, children);
|
|
20849
20854
|
};
|
|
20850
|
-
var FocusedFieldContext = /* @__PURE__ */
|
|
20855
|
+
var FocusedFieldContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20851
20856
|
var FocusedFieldProvider = (_ref) => {
|
|
20852
20857
|
let {
|
|
20853
20858
|
children
|
|
20854
20859
|
} = _ref;
|
|
20855
|
-
const [focusedFieldId, setFocusedFieldId] =
|
|
20856
|
-
const contextValue =
|
|
20860
|
+
const [focusedFieldId, setFocusedFieldId] = React32__namespace.default.useState(void 0);
|
|
20861
|
+
const contextValue = React32.useMemo(() => {
|
|
20857
20862
|
return {
|
|
20858
20863
|
focusedFieldId,
|
|
20859
20864
|
setFocusedFieldId
|
|
20860
20865
|
};
|
|
20861
20866
|
}, [focusedFieldId, setFocusedFieldId]);
|
|
20862
|
-
return /* @__PURE__ */
|
|
20867
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FocusedFieldContext.Provider, {
|
|
20863
20868
|
value: contextValue
|
|
20864
20869
|
}, children);
|
|
20865
20870
|
};
|
|
20866
20871
|
function useFocusedField() {
|
|
20867
|
-
const context =
|
|
20872
|
+
const context = React32.useContext(FocusedFieldContext);
|
|
20868
20873
|
if (context === void 0) {
|
|
20869
20874
|
throw new Error("useFocusedField must be used within a FocusedFieldProvider");
|
|
20870
20875
|
}
|
|
@@ -20872,14 +20877,14 @@ function useFocusedField() {
|
|
|
20872
20877
|
}
|
|
20873
20878
|
|
|
20874
20879
|
// ../form-fields/dist/esm/contexts/events-context.js
|
|
20875
|
-
var EventsContext = /* @__PURE__ */
|
|
20880
|
+
var EventsContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20876
20881
|
var EventsProvider = (_ref) => {
|
|
20877
20882
|
let {
|
|
20878
20883
|
children
|
|
20879
20884
|
} = _ref;
|
|
20880
|
-
const [submitSuccessCounter, setSubmitSuccessCounter] =
|
|
20881
|
-
const [submittedValues, setSubmittedValues] =
|
|
20882
|
-
const value =
|
|
20885
|
+
const [submitSuccessCounter, setSubmitSuccessCounter] = React32.useState(0);
|
|
20886
|
+
const [submittedValues, setSubmittedValues] = React32.useState({});
|
|
20887
|
+
const value = React32.useMemo(() => ({
|
|
20883
20888
|
submitSuccessCounter,
|
|
20884
20889
|
submittedValues,
|
|
20885
20890
|
fireSubmitSuccess: (values) => {
|
|
@@ -20887,12 +20892,12 @@ var EventsProvider = (_ref) => {
|
|
|
20887
20892
|
setSubmittedValues(values || {});
|
|
20888
20893
|
}
|
|
20889
20894
|
}), [submitSuccessCounter, submittedValues]);
|
|
20890
|
-
return /* @__PURE__ */
|
|
20895
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(EventsContext.Provider, {
|
|
20891
20896
|
value
|
|
20892
20897
|
}, children);
|
|
20893
20898
|
};
|
|
20894
20899
|
var useEvents = () => {
|
|
20895
|
-
const context =
|
|
20900
|
+
const context = React32.useContext(EventsContext);
|
|
20896
20901
|
if (context === void 0) {
|
|
20897
20902
|
throw new Error("useEvents must be used within a EventsProvider");
|
|
20898
20903
|
}
|
|
@@ -20904,13 +20909,13 @@ var useSubmitSuccessTrigger = () => {
|
|
|
20904
20909
|
} = useEvents();
|
|
20905
20910
|
return fireSubmitSuccess;
|
|
20906
20911
|
};
|
|
20907
|
-
var ScrollContext = /* @__PURE__ */
|
|
20912
|
+
var ScrollContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
20908
20913
|
var ScrollProvider = (_ref) => {
|
|
20909
20914
|
let {
|
|
20910
20915
|
children
|
|
20911
20916
|
} = _ref;
|
|
20912
|
-
const scrollViewRef =
|
|
20913
|
-
const value =
|
|
20917
|
+
const scrollViewRef = React32.useRef(null);
|
|
20918
|
+
const value = React32.useMemo(() => ({
|
|
20914
20919
|
scrollTo: (element) => {
|
|
20915
20920
|
if (element && scrollViewRef.current) {
|
|
20916
20921
|
const {
|
|
@@ -20928,14 +20933,14 @@ var ScrollProvider = (_ref) => {
|
|
|
20928
20933
|
}
|
|
20929
20934
|
}
|
|
20930
20935
|
}), []);
|
|
20931
|
-
return /* @__PURE__ */
|
|
20936
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
20932
20937
|
ref: scrollViewRef
|
|
20933
|
-
}, /* @__PURE__ */
|
|
20938
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(ScrollContext.Provider, {
|
|
20934
20939
|
value
|
|
20935
20940
|
}, children));
|
|
20936
20941
|
};
|
|
20937
20942
|
function useScroll() {
|
|
20938
|
-
const context =
|
|
20943
|
+
const context = React32.useContext(ScrollContext);
|
|
20939
20944
|
if (context === void 0) {
|
|
20940
20945
|
throw new Error("useScroll must be used within a ScrollProvider");
|
|
20941
20946
|
}
|
|
@@ -24351,9 +24356,9 @@ function initI18n({ icuOptions = {}, ...options }) {
|
|
|
24351
24356
|
}
|
|
24352
24357
|
|
|
24353
24358
|
// ../form-fields/dist/esm/contexts/translation-context.js
|
|
24354
|
-
var TranslationContext = /* @__PURE__ */
|
|
24359
|
+
var TranslationContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24355
24360
|
function useTranslation() {
|
|
24356
|
-
const context =
|
|
24361
|
+
const context = React32.useContext(TranslationContext);
|
|
24357
24362
|
if (context === void 0) {
|
|
24358
24363
|
throw new Error("useTranslation must be used within a TranslationProvider");
|
|
24359
24364
|
}
|
|
@@ -24375,18 +24380,18 @@ function generateUUID() {
|
|
|
24375
24380
|
}
|
|
24376
24381
|
return uuid;
|
|
24377
24382
|
}
|
|
24378
|
-
var ExperimentsContext = /* @__PURE__ */
|
|
24383
|
+
var ExperimentsContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24379
24384
|
var useExperiments = () => {
|
|
24380
|
-
const experiments =
|
|
24385
|
+
const experiments = React32.useContext(ExperimentsContext) || {};
|
|
24381
24386
|
return {
|
|
24382
24387
|
experiments,
|
|
24383
24388
|
isExperimentEnabled: (spec) => experiments[spec] === true || experiments[spec] === "true" || false
|
|
24384
24389
|
};
|
|
24385
24390
|
};
|
|
24386
|
-
var HttpClientContext = /* @__PURE__ */
|
|
24387
|
-
var FormContext = /* @__PURE__ */
|
|
24391
|
+
var HttpClientContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24392
|
+
var FormContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24388
24393
|
function useForm() {
|
|
24389
|
-
const context =
|
|
24394
|
+
const context = React32.useContext(FormContext);
|
|
24390
24395
|
if (context === void 0) {
|
|
24391
24396
|
throw new Error("useForm must be used within a FormProvider");
|
|
24392
24397
|
}
|
|
@@ -24394,9 +24399,9 @@ function useForm() {
|
|
|
24394
24399
|
}
|
|
24395
24400
|
|
|
24396
24401
|
// ../form-fields/dist/esm/contexts/panorama-context.js
|
|
24397
|
-
var PanoramaContext = /* @__PURE__ */
|
|
24402
|
+
var PanoramaContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24398
24403
|
function usePanorama() {
|
|
24399
|
-
const context =
|
|
24404
|
+
const context = React32.useContext(PanoramaContext);
|
|
24400
24405
|
if (context === void 0) {
|
|
24401
24406
|
throw new Error("usePanorama must be used within a PanoramaProvider");
|
|
24402
24407
|
}
|
|
@@ -24415,37 +24420,40 @@ function usePanorama() {
|
|
|
24415
24420
|
})
|
|
24416
24421
|
};
|
|
24417
24422
|
}
|
|
24418
|
-
var BiContext = /* @__PURE__ */
|
|
24423
|
+
var BiContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24419
24424
|
function useBi() {
|
|
24420
|
-
const context =
|
|
24425
|
+
const context = React32.useContext(BiContext);
|
|
24421
24426
|
if (context === void 0) {
|
|
24422
24427
|
throw new Error("useBi must be used within a BiProvider");
|
|
24423
24428
|
}
|
|
24424
24429
|
return context;
|
|
24425
24430
|
}
|
|
24426
|
-
var ForcedStateContext = /* @__PURE__ */
|
|
24431
|
+
var ForcedStateContext = /* @__PURE__ */ React32.createContext([]);
|
|
24427
24432
|
var FALLBACK = {};
|
|
24428
|
-
var ExternalDataContext = /* @__PURE__ */
|
|
24433
|
+
var ExternalDataContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24429
24434
|
var ExternalDataProvider = (_ref) => {
|
|
24430
24435
|
let {
|
|
24431
24436
|
children,
|
|
24432
24437
|
externalData
|
|
24433
24438
|
} = _ref;
|
|
24434
|
-
return /* @__PURE__ */
|
|
24439
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(ExternalDataContext.Provider, {
|
|
24435
24440
|
value: externalData ?? FALLBACK
|
|
24436
24441
|
}, children);
|
|
24437
24442
|
};
|
|
24438
24443
|
function useExternalData() {
|
|
24439
|
-
const context =
|
|
24444
|
+
const context = React32.useContext(ExternalDataContext);
|
|
24440
24445
|
if (context === void 0) {
|
|
24441
24446
|
throw new Error("useExternalData must be used within a ExternalDataProvider");
|
|
24442
24447
|
}
|
|
24443
24448
|
return context;
|
|
24444
24449
|
}
|
|
24445
|
-
var FieldActionsContext = /* @__PURE__ */
|
|
24446
|
-
|
|
24450
|
+
var FieldActionsContext = /* @__PURE__ */ React32.createContext({});
|
|
24451
|
+
function useFieldActions() {
|
|
24452
|
+
return React32.useContext(FieldActionsContext);
|
|
24453
|
+
}
|
|
24454
|
+
var FormFieldsContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24447
24455
|
function useFormFields() {
|
|
24448
|
-
const context =
|
|
24456
|
+
const context = React32.useContext(FormFieldsContext);
|
|
24449
24457
|
if (context === void 0) {
|
|
24450
24458
|
throw new Error("useFormFields must be used within a FormFieldsProvider");
|
|
24451
24459
|
}
|
|
@@ -24453,7 +24461,7 @@ function useFormFields() {
|
|
|
24453
24461
|
}
|
|
24454
24462
|
|
|
24455
24463
|
// ../form-fields/dist/esm/ui/form/components/form/form-field.js
|
|
24456
|
-
var
|
|
24464
|
+
var import_extends5 = __toESM(require_extends());
|
|
24457
24465
|
|
|
24458
24466
|
// ../form-fields/dist/esm/ui/form/types/form-view.js
|
|
24459
24467
|
function isInputField2(field) {
|
|
@@ -24497,7 +24505,7 @@ var InputField = (_ref) => {
|
|
|
24497
24505
|
} = useFieldValidation();
|
|
24498
24506
|
const form = useForm();
|
|
24499
24507
|
const fieldValue = values[field.target];
|
|
24500
|
-
const errorsByTarget =
|
|
24508
|
+
const errorsByTarget = React32.useMemo(() => groupErrorsByTarget(errors), [errors]);
|
|
24501
24509
|
const fieldErrors = errorsByTarget == null ? void 0 : errorsByTarget[field.target];
|
|
24502
24510
|
const fieldError = fieldErrors == null ? void 0 : fieldErrors[0];
|
|
24503
24511
|
const {
|
|
@@ -24524,7 +24532,7 @@ var InputField = (_ref) => {
|
|
|
24524
24532
|
field_target: field == null ? void 0 : field.target
|
|
24525
24533
|
}));
|
|
24526
24534
|
};
|
|
24527
|
-
const handleChange =
|
|
24535
|
+
const handleChange = React32.useCallback((value) => {
|
|
24528
24536
|
if (fieldError) {
|
|
24529
24537
|
validateFields2([{
|
|
24530
24538
|
value,
|
|
@@ -24540,7 +24548,7 @@ var InputField = (_ref) => {
|
|
|
24540
24548
|
if (!FieldComponent) {
|
|
24541
24549
|
return null;
|
|
24542
24550
|
}
|
|
24543
|
-
return /* @__PURE__ */
|
|
24551
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FieldComponent, (0, import_extends.default)({}, field.properties, {
|
|
24544
24552
|
onChange: handleChange,
|
|
24545
24553
|
onBlur: _onBlur,
|
|
24546
24554
|
onFocus: _onFocus,
|
|
@@ -24576,7 +24584,7 @@ var ReadOnlyField = (_ref) => {
|
|
|
24576
24584
|
if (!FieldComponent) {
|
|
24577
24585
|
return null;
|
|
24578
24586
|
}
|
|
24579
|
-
return /* @__PURE__ */
|
|
24587
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FieldComponent, (0, import_extends2.default)({}, field.properties, {
|
|
24580
24588
|
id: field.id,
|
|
24581
24589
|
externalData,
|
|
24582
24590
|
fieldType: field.fieldType,
|
|
@@ -24601,14 +24609,14 @@ var NestedFormField = (_ref) => {
|
|
|
24601
24609
|
const externalData = useExternalData();
|
|
24602
24610
|
const form = useForm();
|
|
24603
24611
|
const fieldValue = values[field.target];
|
|
24604
|
-
const errorsByTarget =
|
|
24612
|
+
const errorsByTarget = React32.useMemo(() => groupErrorsByTarget(errors), [errors]);
|
|
24605
24613
|
const fieldErrors = errorsByTarget == null ? void 0 : errorsByTarget[field.target];
|
|
24606
24614
|
const fieldError = fieldErrors == null ? void 0 : fieldErrors[0];
|
|
24607
24615
|
const {
|
|
24608
24616
|
requiredIndicator,
|
|
24609
24617
|
requiredIndicatorPlacement
|
|
24610
24618
|
} = form.requiredIndicatorProperties || {};
|
|
24611
|
-
const handleChange =
|
|
24619
|
+
const handleChange = React32.useCallback((value) => {
|
|
24612
24620
|
if (!value) {
|
|
24613
24621
|
value = null;
|
|
24614
24622
|
}
|
|
@@ -24618,7 +24626,7 @@ var NestedFormField = (_ref) => {
|
|
|
24618
24626
|
if (!FieldComponent) {
|
|
24619
24627
|
return null;
|
|
24620
24628
|
}
|
|
24621
|
-
return /* @__PURE__ */
|
|
24629
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FieldComponent, (0, import_extends3.default)({}, field.properties, {
|
|
24622
24630
|
onChange: handleChange,
|
|
24623
24631
|
error: fieldError,
|
|
24624
24632
|
errors: fieldErrors,
|
|
@@ -24634,6 +24642,130 @@ var NestedFormField = (_ref) => {
|
|
|
24634
24642
|
}));
|
|
24635
24643
|
};
|
|
24636
24644
|
|
|
24645
|
+
// ../form-fields/dist/esm/ui/form/components/form/submit-button-field.js
|
|
24646
|
+
var import_extends4 = __toESM(require_extends());
|
|
24647
|
+
|
|
24648
|
+
// ../form-fields/dist/esm/fields/submit-button/submit-button/utils.js
|
|
24649
|
+
var getCurrentStep = (form, fieldId) => {
|
|
24650
|
+
var _form$steps;
|
|
24651
|
+
const stepCount = form != null && form.steps ? form.steps.length - 1 : 0;
|
|
24652
|
+
const hasSteps = stepCount > 0;
|
|
24653
|
+
const stepNumber = hasSteps && (form == null || (_form$steps = form.steps) == null ? void 0 : _form$steps.findIndex((step) => {
|
|
24654
|
+
var _step$layout;
|
|
24655
|
+
return (_step$layout = step.layout) == null || (_step$layout = _step$layout.large) == null || (_step$layout = _step$layout.items) == null ? void 0 : _step$layout.find((item) => item.fieldId === fieldId);
|
|
24656
|
+
}));
|
|
24657
|
+
const isLastStep = stepNumber === stepCount;
|
|
24658
|
+
return {
|
|
24659
|
+
hasSteps,
|
|
24660
|
+
stepNumber,
|
|
24661
|
+
isLastStep
|
|
24662
|
+
};
|
|
24663
|
+
};
|
|
24664
|
+
|
|
24665
|
+
// ../form-fields/dist/esm/fields/submit-button/submit-button/use-submit-button.js
|
|
24666
|
+
var useSubmitButton = (_ref) => {
|
|
24667
|
+
let {
|
|
24668
|
+
form,
|
|
24669
|
+
id
|
|
24670
|
+
} = _ref;
|
|
24671
|
+
const {
|
|
24672
|
+
hasSteps,
|
|
24673
|
+
stepNumber,
|
|
24674
|
+
isLastStep
|
|
24675
|
+
} = getCurrentStep(form, id);
|
|
24676
|
+
const {
|
|
24677
|
+
inProgress,
|
|
24678
|
+
actions
|
|
24679
|
+
} = useFieldActions();
|
|
24680
|
+
const [submitInProgress, setSubmitInProgress] = React32.useState(false);
|
|
24681
|
+
const {
|
|
24682
|
+
formStatus
|
|
24683
|
+
} = useFormStatus();
|
|
24684
|
+
const isDisabled = submitInProgress;
|
|
24685
|
+
const isInProgress = inProgress || formStatus === FORM_STATUS.BUSY;
|
|
24686
|
+
const showPreviousButton = hasSteps && stepNumber !== 0;
|
|
24687
|
+
const showNextButton = hasSteps && !isLastStep;
|
|
24688
|
+
const showSubmitButton = !hasSteps || hasSteps && isLastStep;
|
|
24689
|
+
const handleSubmitClick = React32.useCallback(async () => {
|
|
24690
|
+
if (isInProgress) {
|
|
24691
|
+
return;
|
|
24692
|
+
}
|
|
24693
|
+
setSubmitInProgress(true);
|
|
24694
|
+
try {
|
|
24695
|
+
await (actions == null ? void 0 : actions.submitForm());
|
|
24696
|
+
} catch (error2) {
|
|
24697
|
+
console.error(error2);
|
|
24698
|
+
}
|
|
24699
|
+
setSubmitInProgress(false);
|
|
24700
|
+
}, [actions, isInProgress]);
|
|
24701
|
+
return {
|
|
24702
|
+
handleSubmitClick,
|
|
24703
|
+
isDisabled,
|
|
24704
|
+
isInProgress,
|
|
24705
|
+
showPreviousButton,
|
|
24706
|
+
showNextButton,
|
|
24707
|
+
showSubmitButton,
|
|
24708
|
+
hasSteps
|
|
24709
|
+
};
|
|
24710
|
+
};
|
|
24711
|
+
|
|
24712
|
+
// ../form-fields/dist/esm/ui/form/components/form/submit-button-field.js
|
|
24713
|
+
var SubmitButtonField = (_ref) => {
|
|
24714
|
+
let {
|
|
24715
|
+
field,
|
|
24716
|
+
FieldLayout
|
|
24717
|
+
} = _ref;
|
|
24718
|
+
const {
|
|
24719
|
+
submitText,
|
|
24720
|
+
nextText,
|
|
24721
|
+
previousText,
|
|
24722
|
+
text
|
|
24723
|
+
} = field.properties;
|
|
24724
|
+
const componentsById = useFormFields();
|
|
24725
|
+
const externalData = useExternalData();
|
|
24726
|
+
const form = useForm();
|
|
24727
|
+
const {
|
|
24728
|
+
actions
|
|
24729
|
+
} = useFieldActions();
|
|
24730
|
+
const {
|
|
24731
|
+
handleSubmitClick,
|
|
24732
|
+
isDisabled,
|
|
24733
|
+
isInProgress,
|
|
24734
|
+
showPreviousButton,
|
|
24735
|
+
showNextButton,
|
|
24736
|
+
showSubmitButton,
|
|
24737
|
+
hasSteps
|
|
24738
|
+
} = useSubmitButton({
|
|
24739
|
+
form,
|
|
24740
|
+
id: field.id
|
|
24741
|
+
});
|
|
24742
|
+
const submitButtonText = submitText || text || "";
|
|
24743
|
+
const previousButtonText = previousText || "";
|
|
24744
|
+
const nextButtonText = nextText || "";
|
|
24745
|
+
const FieldComponent = componentsById[field.fieldType];
|
|
24746
|
+
if (!FieldComponent) {
|
|
24747
|
+
return null;
|
|
24748
|
+
}
|
|
24749
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FieldComponent, (0, import_extends4.default)({}, field.properties, {
|
|
24750
|
+
id: field.id,
|
|
24751
|
+
externalData,
|
|
24752
|
+
fieldType: field.fieldType,
|
|
24753
|
+
FieldLayout,
|
|
24754
|
+
hasSteps,
|
|
24755
|
+
isDisabled,
|
|
24756
|
+
isInProgress,
|
|
24757
|
+
showPreviousButton,
|
|
24758
|
+
showNextButton,
|
|
24759
|
+
showSubmitButton,
|
|
24760
|
+
submitText: submitButtonText,
|
|
24761
|
+
previousText: previousButtonText,
|
|
24762
|
+
nextText: nextButtonText,
|
|
24763
|
+
onSubmitClick: handleSubmitClick,
|
|
24764
|
+
onPreviousClick: () => actions == null ? void 0 : actions.setPreviousStep(),
|
|
24765
|
+
onNextClick: () => actions == null ? void 0 : actions.setNextStep()
|
|
24766
|
+
}));
|
|
24767
|
+
};
|
|
24768
|
+
|
|
24637
24769
|
// ../form-fields/dist/esm/services/multiline-address.js
|
|
24638
24770
|
var isMultilineAddressField = (field) => {
|
|
24639
24771
|
var _field$view3, _field$view4;
|
|
@@ -24648,18 +24780,24 @@ var FormField = (_ref) => {
|
|
|
24648
24780
|
...rest
|
|
24649
24781
|
} = _ref;
|
|
24650
24782
|
if (!isMultilineAddressField(field) && isNestedFormField(field)) {
|
|
24651
|
-
return /* @__PURE__ */
|
|
24783
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(NestedFormField, (0, import_extends5.default)({}, rest, {
|
|
24652
24784
|
field,
|
|
24653
24785
|
FieldLayout
|
|
24654
24786
|
}));
|
|
24655
24787
|
}
|
|
24656
24788
|
if (isInputField2(field)) {
|
|
24657
|
-
return /* @__PURE__ */
|
|
24789
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(InputField, (0, import_extends5.default)({}, rest, {
|
|
24790
|
+
field,
|
|
24791
|
+
FieldLayout
|
|
24792
|
+
}));
|
|
24793
|
+
}
|
|
24794
|
+
if (field.fieldType === "SUBMIT_BUTTON") {
|
|
24795
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(SubmitButtonField, (0, import_extends5.default)({}, rest, {
|
|
24658
24796
|
field,
|
|
24659
24797
|
FieldLayout
|
|
24660
24798
|
}));
|
|
24661
24799
|
}
|
|
24662
|
-
return /* @__PURE__ */
|
|
24800
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(ReadOnlyField, (0, import_extends5.default)({}, rest, {
|
|
24663
24801
|
field,
|
|
24664
24802
|
FieldLayout
|
|
24665
24803
|
}));
|
|
@@ -24675,7 +24813,7 @@ var createFormFields = (_ref) => {
|
|
|
24675
24813
|
FieldLayout
|
|
24676
24814
|
} = _ref;
|
|
24677
24815
|
return form.fields.map((formField) => {
|
|
24678
|
-
const component = /* @__PURE__ */
|
|
24816
|
+
const component = /* @__PURE__ */ React32__namespace.default.createElement(FormField, {
|
|
24679
24817
|
key: formField.id,
|
|
24680
24818
|
field: formField,
|
|
24681
24819
|
values,
|
|
@@ -24710,19 +24848,19 @@ var Focusable = (_ref) => {
|
|
|
24710
24848
|
children,
|
|
24711
24849
|
fieldId
|
|
24712
24850
|
} = _ref;
|
|
24713
|
-
const viewRef =
|
|
24851
|
+
const viewRef = React32.useRef(null);
|
|
24714
24852
|
const {
|
|
24715
24853
|
scrollTo
|
|
24716
24854
|
} = useScroll();
|
|
24717
24855
|
const {
|
|
24718
24856
|
focusedFieldId
|
|
24719
24857
|
} = useFocusedField();
|
|
24720
|
-
|
|
24858
|
+
React32.useEffect(() => {
|
|
24721
24859
|
if (viewRef.current && fieldId === focusedFieldId) {
|
|
24722
24860
|
scrollTo(viewRef.current);
|
|
24723
24861
|
}
|
|
24724
24862
|
}, [scrollTo, fieldId, focusedFieldId]);
|
|
24725
|
-
return /* @__PURE__ */
|
|
24863
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24726
24864
|
ref: viewRef
|
|
24727
24865
|
}, children);
|
|
24728
24866
|
};
|
|
@@ -24745,17 +24883,17 @@ var Grid = (_ref) => {
|
|
|
24745
24883
|
enableAnimations
|
|
24746
24884
|
} = useConfig();
|
|
24747
24885
|
const reactElementsByRow = getReactElementsByRow(items);
|
|
24748
|
-
return /* @__PURE__ */
|
|
24886
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24749
24887
|
className: grid_module_default.container,
|
|
24750
24888
|
dir: isRTL ? "rtl" : ""
|
|
24751
24889
|
}, reactElementsByRow.map((elements, index) => {
|
|
24752
24890
|
var _elements$;
|
|
24753
24891
|
const fieldId = (_elements$ = elements[0]) == null || (_elements$ = _elements$.props) == null || (_elements$ = _elements$.field) == null ? void 0 : _elements$.id;
|
|
24754
24892
|
const key = isMobile && fieldId || index;
|
|
24755
|
-
return /* @__PURE__ */
|
|
24893
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(Focusable, {
|
|
24756
24894
|
key: fieldId,
|
|
24757
24895
|
fieldId
|
|
24758
|
-
}, /* @__PURE__ */
|
|
24896
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24759
24897
|
key,
|
|
24760
24898
|
style: getGridStyle({
|
|
24761
24899
|
layout
|
|
@@ -24769,7 +24907,7 @@ var Grid = (_ref) => {
|
|
|
24769
24907
|
function getReactElementsByRow(items) {
|
|
24770
24908
|
const reactElementsByRow = items.reduce((result2, item) => {
|
|
24771
24909
|
const row = item.layout.row;
|
|
24772
|
-
const element = /* @__PURE__ */
|
|
24910
|
+
const element = /* @__PURE__ */ React32__namespace.default.cloneElement(item.component, {
|
|
24773
24911
|
key: item.id
|
|
24774
24912
|
});
|
|
24775
24913
|
if (result2[row]) {
|
|
@@ -24781,14 +24919,14 @@ function getReactElementsByRow(items) {
|
|
|
24781
24919
|
}, []);
|
|
24782
24920
|
return reactElementsByRow;
|
|
24783
24921
|
}
|
|
24784
|
-
var FormViewContext = /* @__PURE__ */
|
|
24922
|
+
var FormViewContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24785
24923
|
function useFieldView(fieldId) {
|
|
24786
24924
|
const context = useFormView();
|
|
24787
24925
|
const fieldView = context.fields.find((field) => field.id === fieldId);
|
|
24788
24926
|
return fieldView;
|
|
24789
24927
|
}
|
|
24790
24928
|
function useFormView() {
|
|
24791
|
-
const context =
|
|
24929
|
+
const context = React32.useContext(FormViewContext);
|
|
24792
24930
|
if (context === void 0) {
|
|
24793
24931
|
throw new Error("useFormView must be used within a FormViewProvider");
|
|
24794
24932
|
}
|
|
@@ -24796,7 +24934,7 @@ function useFormView() {
|
|
|
24796
24934
|
}
|
|
24797
24935
|
|
|
24798
24936
|
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
24799
|
-
var
|
|
24937
|
+
var import_extends6 = __toESM(require_extends());
|
|
24800
24938
|
|
|
24801
24939
|
// ../form-fields/dist/esm/field-layout/default-field-layout.module.scss
|
|
24802
24940
|
var default_field_layout_module_default = {};
|
|
@@ -24825,7 +24963,7 @@ var DefaultFieldLayout = (_ref) => {
|
|
|
24825
24963
|
const gridColumn = `${layout.column + 1} / span ${layout.width}`;
|
|
24826
24964
|
const [labelRow, inputRow] = rows.map((currentRow) => `${currentRow} / span 1`);
|
|
24827
24965
|
if ("children" in rest) {
|
|
24828
|
-
return /* @__PURE__ */
|
|
24966
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", (0, import_extends6.default)({
|
|
24829
24967
|
style: {
|
|
24830
24968
|
gridRow,
|
|
24831
24969
|
gridColumn
|
|
@@ -24837,13 +24975,13 @@ var DefaultFieldLayout = (_ref) => {
|
|
|
24837
24975
|
renderInput,
|
|
24838
24976
|
renderDescription
|
|
24839
24977
|
} = rest;
|
|
24840
|
-
return /* @__PURE__ */
|
|
24978
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(React32__namespace.default.Fragment, null, /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24841
24979
|
style: {
|
|
24842
24980
|
gridRow: labelRow,
|
|
24843
24981
|
gridColumn
|
|
24844
24982
|
},
|
|
24845
24983
|
className: default_field_layout_module_default.label
|
|
24846
|
-
}, renderLabel()), /* @__PURE__ */
|
|
24984
|
+
}, renderLabel()), /* @__PURE__ */ React32__namespace.default.createElement("div", (0, import_extends6.default)({
|
|
24847
24985
|
style: {
|
|
24848
24986
|
gridRow: inputRow,
|
|
24849
24987
|
gridColumn
|
|
@@ -24869,18 +25007,18 @@ var FormRoot = (_ref) => {
|
|
|
24869
25007
|
errors,
|
|
24870
25008
|
FieldLayout: DefaultFieldLayout
|
|
24871
25009
|
});
|
|
24872
|
-
return /* @__PURE__ */
|
|
25010
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
|
|
24873
25011
|
isRTL,
|
|
24874
25012
|
items: formFields,
|
|
24875
25013
|
layout: form.grid
|
|
24876
25014
|
});
|
|
24877
25015
|
};
|
|
24878
25016
|
var Form = (props) => {
|
|
24879
|
-
return /* @__PURE__ */
|
|
25017
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FormViewContext.Provider, {
|
|
24880
25018
|
value: props.form
|
|
24881
|
-
}, /* @__PURE__ */
|
|
25019
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(UniqueFieldSuffixContextProvider, {
|
|
24882
25020
|
parentId: props.form.parentId
|
|
24883
|
-
}, /* @__PURE__ */
|
|
25021
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FormRoot, props)));
|
|
24884
25022
|
};
|
|
24885
25023
|
|
|
24886
25024
|
// ../form-fields/dist/esm/utils/sort-fields.js
|
|
@@ -26862,19 +27000,19 @@ var initialState = {
|
|
|
26862
27000
|
getCountryAddressForm: () => void 0,
|
|
26863
27001
|
addressTemplates: void 0
|
|
26864
27002
|
};
|
|
26865
|
-
var AddressFormsContext = /* @__PURE__ */
|
|
27003
|
+
var AddressFormsContext = /* @__PURE__ */ React32.createContext(initialState);
|
|
26866
27004
|
var getAddressForm = (templates, country) => {
|
|
26867
27005
|
var _templates$find, _templates$find2;
|
|
26868
27006
|
return (templates == null || (_templates$find = templates.find((template) => template.country === country)) == null ? void 0 : _templates$find.template) || (templates == null || (_templates$find2 = templates.find((template) => template.country === "COMMON")) == null ? void 0 : _templates$find2.template);
|
|
26869
27007
|
};
|
|
26870
27008
|
function useAddressForms() {
|
|
26871
|
-
const context =
|
|
27009
|
+
const context = React32.useContext(AddressFormsContext);
|
|
26872
27010
|
if (context === void 0) {
|
|
26873
27011
|
throw new Error("useAddressForms must be used within a AddressFormsContext");
|
|
26874
27012
|
}
|
|
26875
27013
|
return context;
|
|
26876
27014
|
}
|
|
26877
|
-
var FieldInitialDataContext = /* @__PURE__ */
|
|
27015
|
+
var FieldInitialDataContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
26878
27016
|
|
|
26879
27017
|
// ../form-fields/dist/esm/fields/vat-id/vat-id-validation.js
|
|
26880
27018
|
init_esm2();
|
|
@@ -28868,8 +29006,8 @@ function acceptOnlyValidPayments({ field, fieldValue }) {
|
|
|
28868
29006
|
|
|
28869
29007
|
// ../form-viewer/dist/esm/components/form/use-form-values.js
|
|
28870
29008
|
var useFormValues = (form, values, onChange, config) => {
|
|
28871
|
-
const normalizedValues =
|
|
28872
|
-
|
|
29009
|
+
const normalizedValues = React32.useMemo(() => normalizeValues(form, fillEmptyValues(form, values), true, config), [form, values, config]);
|
|
29010
|
+
React32.useEffect(() => {
|
|
28873
29011
|
const hasAnyValueChanged = !deepEqual(normalizedValues, values);
|
|
28874
29012
|
if (hasAnyValueChanged) {
|
|
28875
29013
|
onChange?.(normalizedValues);
|
|
@@ -28881,7 +29019,7 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
28881
29019
|
const { isMobile } = useConfig();
|
|
28882
29020
|
const experiments = useExperiments();
|
|
28883
29021
|
const useFieldsV2 = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2);
|
|
28884
|
-
return
|
|
29022
|
+
return React32.useMemo(() => {
|
|
28885
29023
|
return (form?.steps || []).filter((step) => !stepId || stepId === step.id).map((step) => {
|
|
28886
29024
|
return createFormView({
|
|
28887
29025
|
form,
|
|
@@ -28894,7 +29032,7 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
28894
29032
|
}, [form, stepId, isMobile, breakpoint, useFieldsV2]);
|
|
28895
29033
|
};
|
|
28896
29034
|
var useReportFieldEdit = (form) => {
|
|
28897
|
-
const lastChangedFields =
|
|
29035
|
+
const lastChangedFields = React32.useRef([]);
|
|
28898
29036
|
const bi = useBi();
|
|
28899
29037
|
return (changedValues) => {
|
|
28900
29038
|
const changedFieldTargets = Object.keys(changedValues);
|
|
@@ -28914,7 +29052,7 @@ var useReportFieldEdit = (form) => {
|
|
|
28914
29052
|
};
|
|
28915
29053
|
var useScrollToFirstError = ({ form, handleStepChange, currentStepId }) => {
|
|
28916
29054
|
const { setFocusedFieldId } = useFocusedField();
|
|
28917
|
-
const scrollToFirstError =
|
|
29055
|
+
const scrollToFirstError = React32.useCallback((errors) => {
|
|
28918
29056
|
const sortedFieldsInStep = getSortedFields(form, {
|
|
28919
29057
|
stepId: currentStepId
|
|
28920
29058
|
});
|
|
@@ -28923,7 +29061,7 @@ var useScrollToFirstError = ({ form, handleStepChange, currentStepId }) => {
|
|
|
28923
29061
|
});
|
|
28924
29062
|
setFocusedFieldId(fieldWithError?.id);
|
|
28925
29063
|
}, [currentStepId, form, setFocusedFieldId]);
|
|
28926
|
-
const handleScrollToFirstError =
|
|
29064
|
+
const handleScrollToFirstError = React32.useCallback((errors) => {
|
|
28927
29065
|
const sortedFields = getSortedFields(form);
|
|
28928
29066
|
const field = sortedFields?.find((_field) => {
|
|
28929
29067
|
return errors.some((error2) => _field.target === error2.errorPath.split("/")[0]);
|
|
@@ -28998,12 +29136,12 @@ var getCheckoutMessage = (text) => {
|
|
|
28998
29136
|
}
|
|
28999
29137
|
};
|
|
29000
29138
|
};
|
|
29001
|
-
var SubmitStatusContext =
|
|
29139
|
+
var SubmitStatusContext = React32.createContext(void 0);
|
|
29002
29140
|
var SubmitStatusProvider = ({ children }) => {
|
|
29003
|
-
const [submitSuccessMessage, setSubmitSuccessMessage] =
|
|
29004
|
-
const [submitFailureCode, setSubmitFailureCode] =
|
|
29005
|
-
const [submitFailureMessage, setSubmitFailureMessage] =
|
|
29006
|
-
const value =
|
|
29141
|
+
const [submitSuccessMessage, setSubmitSuccessMessage] = React32.useState();
|
|
29142
|
+
const [submitFailureCode, setSubmitFailureCode] = React32.useState();
|
|
29143
|
+
const [submitFailureMessage, setSubmitFailureMessage] = React32.useState();
|
|
29144
|
+
const value = React32.useMemo(() => ({
|
|
29007
29145
|
submitSuccessMessage,
|
|
29008
29146
|
submitFailureCode,
|
|
29009
29147
|
submitFailureMessage,
|
|
@@ -29011,10 +29149,10 @@ var SubmitStatusProvider = ({ children }) => {
|
|
|
29011
29149
|
setSubmitFailureCode,
|
|
29012
29150
|
setSubmitFailureMessage
|
|
29013
29151
|
}), [submitSuccessMessage, submitFailureCode, submitFailureMessage]);
|
|
29014
|
-
return
|
|
29152
|
+
return React32__namespace.default.createElement(SubmitStatusContext.Provider, { value }, children);
|
|
29015
29153
|
};
|
|
29016
29154
|
var useSubmitStatus = () => {
|
|
29017
|
-
const context =
|
|
29155
|
+
const context = React32.useContext(SubmitStatusContext);
|
|
29018
29156
|
if (context === void 0) {
|
|
29019
29157
|
throw new Error("useSubmitStatus must be used within a SubmitStatusProvider");
|
|
29020
29158
|
}
|
|
@@ -29041,11 +29179,11 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29041
29179
|
const { report } = useBi();
|
|
29042
29180
|
const fireSubmitSuccess = useSubmitSuccessTrigger();
|
|
29043
29181
|
const panorama = usePanorama();
|
|
29044
|
-
const reportSubmitFormBi =
|
|
29182
|
+
const reportSubmitFormBi = React32.useCallback(({ status, id }) => report(submitFormClick({
|
|
29045
29183
|
submission_status: status,
|
|
29046
29184
|
submission_id: id ?? void 0
|
|
29047
29185
|
})), [report]);
|
|
29048
|
-
const handleSubmitSuccess =
|
|
29186
|
+
const handleSubmitSuccess = React32.useCallback((submission) => {
|
|
29049
29187
|
const action = submitSettings?.submitSuccessAction;
|
|
29050
29188
|
const checkoutId = submission?.orderDetails?.checkoutId;
|
|
29051
29189
|
if (checkoutId && navigateToCheckout) {
|
|
@@ -29075,12 +29213,12 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29075
29213
|
setSubmitFailureCode,
|
|
29076
29214
|
setSubmitFailureMessage
|
|
29077
29215
|
]);
|
|
29078
|
-
const handleSubmitFailure =
|
|
29216
|
+
const handleSubmitFailure = React32.useCallback((error2) => {
|
|
29079
29217
|
const err = getErrorCode(error2);
|
|
29080
29218
|
setSubmitFailureCode(err);
|
|
29081
29219
|
setSubmitSuccessMessage(void 0);
|
|
29082
29220
|
}, [setSubmitFailureCode, setSubmitSuccessMessage]);
|
|
29083
|
-
const handleCustomErrorMessages =
|
|
29221
|
+
const handleCustomErrorMessages = React32.useCallback((error2) => {
|
|
29084
29222
|
const errors = getErrorList(error2);
|
|
29085
29223
|
const formCustomErrorMessage = getFormCustomErrorMessage(errors);
|
|
29086
29224
|
if (formCustomErrorMessage) {
|
|
@@ -29092,7 +29230,7 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29092
29230
|
handleScrollToFirstError?.(fieldCustomErrorMessages);
|
|
29093
29231
|
}
|
|
29094
29232
|
}, [setSubmitFailureMessage, onValidate, handleScrollToFirstError]);
|
|
29095
|
-
const submitForm =
|
|
29233
|
+
const submitForm = React32.useCallback(async () => {
|
|
29096
29234
|
const errors = await validateAndScrollToError(values);
|
|
29097
29235
|
onSubmit?.();
|
|
29098
29236
|
reportSubmitFormBi({ status: BiFormSubmissionStatus.INIT });
|
|
@@ -29168,7 +29306,7 @@ var reportErrorChanges = ({ bi, existingErrors, newErrors, form }) => {
|
|
|
29168
29306
|
var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
29169
29307
|
const { addressTemplates } = useAddressForms();
|
|
29170
29308
|
const externalData = useExternalData();
|
|
29171
|
-
const validateFields2 =
|
|
29309
|
+
const validateFields2 = React32.useCallback(async (newValues) => {
|
|
29172
29310
|
const result2 = await validate(form, newValues, addressTemplates, validationMode);
|
|
29173
29311
|
const _errors = result2?.errors || [];
|
|
29174
29312
|
const additionalErrors = runAdditionalValidation({
|
|
@@ -29180,7 +29318,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
|
29180
29318
|
setErrors(allErrors);
|
|
29181
29319
|
return allErrors;
|
|
29182
29320
|
}, [form, setErrors, addressTemplates, externalData, validationMode]);
|
|
29183
|
-
const handleFieldValidation =
|
|
29321
|
+
const handleFieldValidation = React32.useCallback(async (fieldsToValidate) => {
|
|
29184
29322
|
const fieldErrors = await getFieldErrors(fieldsToValidate, form, addressTemplates, externalData, validationMode);
|
|
29185
29323
|
const otherErrors = (errorsRef.current ?? []).filter((error2) => {
|
|
29186
29324
|
return !findErrorByNormalizedPath(fieldsToValidate, error2.errorPath);
|
|
@@ -29196,7 +29334,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
|
29196
29334
|
externalData,
|
|
29197
29335
|
validationMode
|
|
29198
29336
|
]);
|
|
29199
|
-
const validateStep =
|
|
29337
|
+
const validateStep = React32.useCallback(async (stepId, newValues) => {
|
|
29200
29338
|
const items = form?.steps?.find((step) => step.id === stepId)?.layout?.large?.items || [];
|
|
29201
29339
|
const validationErrors = await Promise.all(items.map(async (item) => {
|
|
29202
29340
|
const field = form?.fields?.find((_field) => _field.id === item.fieldId);
|
|
@@ -29232,9 +29370,9 @@ var SubmitThankYouMessage = ({ messageText }) => {
|
|
|
29232
29370
|
if (!messageText) {
|
|
29233
29371
|
return null;
|
|
29234
29372
|
}
|
|
29235
|
-
return
|
|
29373
|
+
return React32__namespace.default.createElement(ricos_viewer_default, { dataHook: DATA_HOOKS.SUBMIT_THANK_YOU_MESSAGE, content: messageText, customTheme, className: submit_status_message_module_default.thankYouMessage });
|
|
29236
29374
|
};
|
|
29237
|
-
var Error2 = ({ size, ...props }) => /* @__PURE__ */
|
|
29375
|
+
var Error2 = ({ size, ...props }) => /* @__PURE__ */ React32__namespace.createElement("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: size || "24", height: size || "24", ...props }, /* @__PURE__ */ React32__namespace.createElement("path", { fillRule: "evenodd", d: "M11.5,3 C16.187,3 20,6.813 20,11.5 C20,16.187 16.187,20 11.5,20 C6.813,20 3,16.187 3,11.5 C3,6.813 6.813,3 11.5,3 Z M11.5,4 C7.364,4 4,7.364 4,11.5 C4,15.636 7.364,19 11.5,19 C15.636,19 19,15.636 19,11.5 C19,7.364 15.636,4 11.5,4 Z M12,14 L12,15 L11,15 L11,14 L12,14 Z M12,8 L12,13 L11,13 L11,8 L12,8 Z" }));
|
|
29238
29376
|
Error2.displayName = "Error";
|
|
29239
29377
|
var Error_default = Error2;
|
|
29240
29378
|
|
|
@@ -29247,10 +29385,10 @@ var SubmitErrorMessage = ({ errorMessageCode, errorMessage }) => {
|
|
|
29247
29385
|
}
|
|
29248
29386
|
const errorMessageKeyByCode = `${ERROR_MESSAGE_KEY}.${errorMessageCode}`;
|
|
29249
29387
|
const errorMessageKey = i18n2.exists(`${TRANSLATIONS_NAMESPACE}:${errorMessageKeyByCode}`) ? errorMessageKeyByCode : ERROR_MESSAGE_KEY;
|
|
29250
|
-
return
|
|
29388
|
+
return React32__namespace.default.createElement(
|
|
29251
29389
|
"div",
|
|
29252
29390
|
{ className: submit_status_message_module_default.errorMessage, "data-hook": DATA_HOOKS.SUBMIT_ERROR_MESSAGE },
|
|
29253
|
-
|
|
29391
|
+
React32__namespace.default.createElement(Error_default, { className: submit_status_message_module_default.errorIcon, "aria-hidden": "true" }),
|
|
29254
29392
|
errorMessage || t(errorMessageKey)
|
|
29255
29393
|
);
|
|
29256
29394
|
};
|
|
@@ -29270,8 +29408,8 @@ var transitionStyles = {
|
|
|
29270
29408
|
exited: { opacity: 0 }
|
|
29271
29409
|
};
|
|
29272
29410
|
var FadeOut = ({ visible, children }) => {
|
|
29273
|
-
const nodeRef =
|
|
29274
|
-
return
|
|
29411
|
+
const nodeRef = React32.useRef(null);
|
|
29412
|
+
return React32__namespace.default.createElement(Transition_default, { nodeRef, in: visible, timeout: DURATION }, (state) => React32__namespace.default.createElement("div", { ref: nodeRef, style: {
|
|
29275
29413
|
...defaultStyle,
|
|
29276
29414
|
...transitionStyles[state]
|
|
29277
29415
|
} }, [ENTERING, ENTERED, EXITING].includes(state) ? children : null));
|
|
@@ -29280,15 +29418,15 @@ var FadeOut = ({ visible, children }) => {
|
|
|
29280
29418
|
// ../form-viewer/dist/esm/components/submit-status-message/submit-status-message.js
|
|
29281
29419
|
var SubmitStatusMessage = () => {
|
|
29282
29420
|
const { submitSuccessMessage, submitFailureCode, submitFailureMessage } = useSubmitStatus();
|
|
29283
|
-
return
|
|
29421
|
+
return React32__namespace.default.createElement(
|
|
29284
29422
|
"div",
|
|
29285
29423
|
{ role: "region", "aria-live": "polite" },
|
|
29286
|
-
|
|
29424
|
+
React32__namespace.default.createElement(
|
|
29287
29425
|
FadeOut,
|
|
29288
29426
|
{ visible: !!submitSuccessMessage },
|
|
29289
|
-
|
|
29427
|
+
React32__namespace.default.createElement(SubmitThankYouMessage, { messageText: submitSuccessMessage })
|
|
29290
29428
|
),
|
|
29291
|
-
|
|
29429
|
+
React32__namespace.default.createElement(SubmitErrorMessage, { errorMessageCode: submitFailureCode, errorMessage: submitFailureMessage })
|
|
29292
29430
|
);
|
|
29293
29431
|
};
|
|
29294
29432
|
var StepTitleA11y = ({ index = 0, total = 0 }) => {
|
|
@@ -29297,7 +29435,7 @@ var StepTitleA11y = ({ index = 0, total = 0 }) => {
|
|
|
29297
29435
|
index: index + 1,
|
|
29298
29436
|
total
|
|
29299
29437
|
});
|
|
29300
|
-
return total > 1 ?
|
|
29438
|
+
return total > 1 ? React32__namespace.default.createElement("span", { "aria-label": stepTitleA11y, "aria-live": "polite" }) : null;
|
|
29301
29439
|
};
|
|
29302
29440
|
|
|
29303
29441
|
// ../form-viewer/dist/esm/components/form/form-root.js
|
|
@@ -29324,13 +29462,13 @@ var FormRoot2 = ({
|
|
|
29324
29462
|
onStatusChange,
|
|
29325
29463
|
validationMode
|
|
29326
29464
|
}) => {
|
|
29327
|
-
const formWithOverrides =
|
|
29465
|
+
const formWithOverrides = React32.useMemo(() => applyAllOverrides(unprocessedForm, unprocessedValues, overrides), [unprocessedForm, unprocessedValues, overrides]);
|
|
29328
29466
|
const formId = formWithOverrides.id;
|
|
29329
29467
|
const { setFocusedFieldId } = useFocusedField();
|
|
29330
29468
|
const normalizedValues = useFormValues(formWithOverrides, unprocessedValues, onChange, config);
|
|
29331
|
-
const valuesRef =
|
|
29469
|
+
const valuesRef = React32.useRef(normalizedValues);
|
|
29332
29470
|
valuesRef.current = normalizedValues;
|
|
29333
|
-
const errorsRef =
|
|
29471
|
+
const errorsRef = React32.useRef(errors);
|
|
29334
29472
|
errorsRef.current = errors;
|
|
29335
29473
|
const bi = useBi();
|
|
29336
29474
|
const reportFieldEdit = useReportFieldEdit(formWithOverrides);
|
|
@@ -29359,7 +29497,7 @@ var FormRoot2 = ({
|
|
|
29359
29497
|
});
|
|
29360
29498
|
onValidate(newErrors);
|
|
29361
29499
|
};
|
|
29362
|
-
|
|
29500
|
+
React32.useEffect(() => {
|
|
29363
29501
|
bi.report(formView({ mode: readOnly ? "preview" : "live_site" }));
|
|
29364
29502
|
}, []);
|
|
29365
29503
|
const formViews = useFormView2(formWithOverrides, stepId, breakpoint);
|
|
@@ -29370,7 +29508,7 @@ var FormRoot2 = ({
|
|
|
29370
29508
|
setErrors: _onValidate,
|
|
29371
29509
|
validationMode
|
|
29372
29510
|
});
|
|
29373
|
-
const handleStepChange =
|
|
29511
|
+
const handleStepChange = React32.useCallback((step) => {
|
|
29374
29512
|
const newStepId = formWithOverrides.steps?.[step]?.id;
|
|
29375
29513
|
if (newStepId) {
|
|
29376
29514
|
const firstFieldInStep = getSortedFields(formWithOverrides, {
|
|
@@ -29385,17 +29523,17 @@ var FormRoot2 = ({
|
|
|
29385
29523
|
handleStepChange,
|
|
29386
29524
|
currentStepId: stepId
|
|
29387
29525
|
});
|
|
29388
|
-
const resetFormValues =
|
|
29526
|
+
const resetFormValues = React32.useCallback(() => {
|
|
29389
29527
|
onChange(fillEmptyValues(formWithOverrides, {}));
|
|
29390
29528
|
}, [formWithOverrides, onChange]);
|
|
29391
|
-
const validateAndScrollToError =
|
|
29529
|
+
const validateAndScrollToError = React32.useCallback(async (values) => {
|
|
29392
29530
|
const validationErrors = await validateFields2(values);
|
|
29393
29531
|
if (validationErrors && validationErrors.length) {
|
|
29394
29532
|
handleScrollToFirstError(validationErrors);
|
|
29395
29533
|
}
|
|
29396
29534
|
return validationErrors;
|
|
29397
29535
|
}, [validateFields2, handleScrollToFirstError]);
|
|
29398
|
-
const submitAction =
|
|
29536
|
+
const submitAction = React32.useCallback(async (values) => {
|
|
29399
29537
|
const response = await actions?.submitForm?.(formId, values);
|
|
29400
29538
|
return response?.submission;
|
|
29401
29539
|
}, [actions, formId]);
|
|
@@ -29413,7 +29551,7 @@ var FormRoot2 = ({
|
|
|
29413
29551
|
onValidate: _onValidate,
|
|
29414
29552
|
handleScrollToFirstError
|
|
29415
29553
|
});
|
|
29416
|
-
|
|
29554
|
+
React32.useImperativeHandle(forwardedRef, () => ({
|
|
29417
29555
|
submit: submitForm,
|
|
29418
29556
|
validate: async () => {
|
|
29419
29557
|
const validationErrors = await validateFields2(normalizedValues);
|
|
@@ -29432,9 +29570,9 @@ var FormRoot2 = ({
|
|
|
29432
29570
|
scrollToFirstError
|
|
29433
29571
|
]);
|
|
29434
29572
|
const currentStep = getStepIndex(stepId, formWithOverrides.steps);
|
|
29435
|
-
const setNextStep =
|
|
29436
|
-
const setPreviousStep =
|
|
29437
|
-
const fieldActions =
|
|
29573
|
+
const setNextStep = React32.useCallback(() => handleStepChange(currentStep + 1), [currentStep, handleStepChange]);
|
|
29574
|
+
const setPreviousStep = React32.useCallback(() => handleStepChange(currentStep - 1), [currentStep, handleStepChange]);
|
|
29575
|
+
const fieldActions = React32.useMemo(() => actions ? {
|
|
29438
29576
|
actions: { ...actions, submitForm, setNextStep, setPreviousStep },
|
|
29439
29577
|
formId,
|
|
29440
29578
|
inProgress
|
|
@@ -29442,23 +29580,23 @@ var FormRoot2 = ({
|
|
|
29442
29580
|
if (!formViews?.length || !currentView) {
|
|
29443
29581
|
return null;
|
|
29444
29582
|
}
|
|
29445
|
-
return
|
|
29583
|
+
return React32__namespace.default.createElement(
|
|
29446
29584
|
FieldValidationContext.Provider,
|
|
29447
29585
|
{ value: {
|
|
29448
29586
|
validateFields: handleFieldValidation
|
|
29449
29587
|
} },
|
|
29450
|
-
|
|
29588
|
+
React32__namespace.default.createElement(
|
|
29451
29589
|
FieldActionsContext.Provider,
|
|
29452
29590
|
{ value: fieldActions },
|
|
29453
|
-
|
|
29591
|
+
React32__namespace.default.createElement(
|
|
29454
29592
|
FormStatusProvider,
|
|
29455
29593
|
{ onStatusChange },
|
|
29456
|
-
|
|
29594
|
+
React32__namespace.default.createElement(
|
|
29457
29595
|
"div",
|
|
29458
29596
|
{ "data-hook": DATA_HOOKS.FORM_ROOT },
|
|
29459
|
-
|
|
29460
|
-
|
|
29461
|
-
|
|
29597
|
+
React32__namespace.default.createElement(Form, { form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
|
|
29598
|
+
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29599
|
+
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29462
29600
|
)
|
|
29463
29601
|
)
|
|
29464
29602
|
)
|
|
@@ -29471,8 +29609,8 @@ var dummyBi = {
|
|
|
29471
29609
|
updateDefaults: () => dummyBi
|
|
29472
29610
|
};
|
|
29473
29611
|
var useFormBi = (form, bi, biFormFillSessionId) => {
|
|
29474
|
-
const formEditSessionId =
|
|
29475
|
-
return
|
|
29612
|
+
const formEditSessionId = React32.useMemo(generateUUID, []);
|
|
29613
|
+
return React32.useMemo(() => {
|
|
29476
29614
|
if (!bi) {
|
|
29477
29615
|
return dummyBi;
|
|
29478
29616
|
}
|
|
@@ -29502,12 +29640,12 @@ var useFormBi = (form, bi, biFormFillSessionId) => {
|
|
|
29502
29640
|
|
|
29503
29641
|
// ../form-viewer/dist/esm/components/root/form-viewer-provider.js
|
|
29504
29642
|
var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile, isEditor, isComposer, isRTL, compId, locale, regionalFormat, externalData, fields, forcedState, instance, children, httpClient, panorama, experiments, translationNamespace, currency, userData, WixRicosViewer, addressTemplates, atlasBaseUrl, fieldInitialData, enableAnimations }) => {
|
|
29505
|
-
const translations =
|
|
29643
|
+
const translations = React32.useMemo(() => ({
|
|
29506
29644
|
t: i18n2.getFixedT(locale, translationNamespace),
|
|
29507
29645
|
i18n: i18n2
|
|
29508
29646
|
}), [locale, i18n2, translationNamespace]);
|
|
29509
29647
|
const formBi = useFormBi(form, bi, biFormFillSessionId);
|
|
29510
|
-
const config =
|
|
29648
|
+
const config = React32.useMemo(() => ({
|
|
29511
29649
|
locale,
|
|
29512
29650
|
regionalFormat,
|
|
29513
29651
|
instance,
|
|
@@ -29534,59 +29672,59 @@ var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile
|
|
|
29534
29672
|
isRTL,
|
|
29535
29673
|
enableAnimations
|
|
29536
29674
|
]);
|
|
29537
|
-
const forcedViewState =
|
|
29538
|
-
return
|
|
29675
|
+
const forcedViewState = React32.useMemo(() => forcedState ?? [], [forcedState]);
|
|
29676
|
+
return React32__namespace.default.createElement(
|
|
29539
29677
|
FormFieldsContext.Provider,
|
|
29540
29678
|
{ value: fields },
|
|
29541
|
-
|
|
29679
|
+
React32__namespace.default.createElement(
|
|
29542
29680
|
HttpClientContext.Provider,
|
|
29543
29681
|
{ value: { httpClient } },
|
|
29544
|
-
|
|
29682
|
+
React32__namespace.default.createElement(
|
|
29545
29683
|
PanoramaContext.Provider,
|
|
29546
29684
|
{ value: { panorama } },
|
|
29547
|
-
|
|
29685
|
+
React32__namespace.default.createElement(
|
|
29548
29686
|
TranslationContext.Provider,
|
|
29549
29687
|
{ value: translations },
|
|
29550
|
-
|
|
29688
|
+
React32__namespace.default.createElement(
|
|
29551
29689
|
ScrollProvider,
|
|
29552
29690
|
null,
|
|
29553
|
-
|
|
29691
|
+
React32__namespace.default.createElement(
|
|
29554
29692
|
FocusedFieldProvider,
|
|
29555
29693
|
null,
|
|
29556
|
-
|
|
29694
|
+
React32__namespace.default.createElement(
|
|
29557
29695
|
FieldInitialDataContext.Provider,
|
|
29558
29696
|
{ value: fieldInitialData },
|
|
29559
|
-
|
|
29697
|
+
React32__namespace.default.createElement(
|
|
29560
29698
|
BiContext.Provider,
|
|
29561
29699
|
{ value: formBi },
|
|
29562
|
-
|
|
29700
|
+
React32__namespace.default.createElement(
|
|
29563
29701
|
ExternalDataProvider,
|
|
29564
29702
|
{ externalData },
|
|
29565
|
-
|
|
29703
|
+
React32__namespace.default.createElement(
|
|
29566
29704
|
ConfigContext.Provider,
|
|
29567
29705
|
{ value: config },
|
|
29568
|
-
|
|
29706
|
+
React32__namespace.default.createElement(
|
|
29569
29707
|
ForcedStateContext.Provider,
|
|
29570
29708
|
{ value: forcedViewState },
|
|
29571
|
-
|
|
29709
|
+
React32__namespace.default.createElement(
|
|
29572
29710
|
FormContext.Provider,
|
|
29573
29711
|
{ value: form },
|
|
29574
|
-
|
|
29712
|
+
React32__namespace.default.createElement(
|
|
29575
29713
|
AddressFormsContext.Provider,
|
|
29576
29714
|
{ value: {
|
|
29577
29715
|
getCountryAddressForm: (country) => getAddressForm(addressTemplates, country),
|
|
29578
29716
|
addressTemplates
|
|
29579
29717
|
} },
|
|
29580
|
-
|
|
29718
|
+
React32__namespace.default.createElement(
|
|
29581
29719
|
ExperimentsContext.Provider,
|
|
29582
29720
|
{ value: experiments },
|
|
29583
|
-
|
|
29721
|
+
React32__namespace.default.createElement(
|
|
29584
29722
|
EventsProvider,
|
|
29585
29723
|
null,
|
|
29586
|
-
|
|
29724
|
+
React32__namespace.default.createElement(
|
|
29587
29725
|
WixRicosViewerContext.Provider,
|
|
29588
29726
|
{ value: WixRicosViewer },
|
|
29589
|
-
|
|
29727
|
+
React32__namespace.default.createElement(SubmitStatusProvider, null, children)
|
|
29590
29728
|
)
|
|
29591
29729
|
)
|
|
29592
29730
|
)
|
|
@@ -29625,17 +29763,17 @@ var DisabledFormOverlay = ({ content, isEditor }) => {
|
|
|
29625
29763
|
if (isEditor || !content) {
|
|
29626
29764
|
return null;
|
|
29627
29765
|
}
|
|
29628
|
-
return
|
|
29766
|
+
return React32__namespace.default.createElement(ricos_viewer_default, { content, className: disabled_form_overlay_module_default.disabledFormOverlay, customTheme });
|
|
29629
29767
|
};
|
|
29630
29768
|
|
|
29631
29769
|
// ../form-viewer/dist/esm/components/root/form-viewer-static.js
|
|
29632
|
-
var FormViewerStatic =
|
|
29770
|
+
var FormViewerStatic = React32.forwardRef(({ form, i18n: i18n2, isMobile, isRTL, config = null, readOnly = false, externalData, bi, biFormFillSessionId, translations, localeDataset, forcedState, httpClient, panorama, experiments, currency, fields, WixRicosViewer, breakpoint = Breakpoint.LARGE, allowFormDisable = true, fieldInitialData, enableAnimations, ...rest }, forwardedRef) => {
|
|
29633
29771
|
const { locale = "en", regionalFormat = "en", userData } = config || {};
|
|
29634
|
-
|
|
29772
|
+
React32.useState(() => {
|
|
29635
29773
|
translations && i18n2.addResources(locale, TRANSLATIONS_NAMESPACE, translations);
|
|
29636
29774
|
localeDataset && i18n2.addResources(locale, TRANSLATIONS_NAMESPACE, localeDataset);
|
|
29637
29775
|
});
|
|
29638
|
-
const formWithValidSteps =
|
|
29776
|
+
const formWithValidSteps = React32.useMemo(() => ({
|
|
29639
29777
|
...form,
|
|
29640
29778
|
steps: form?.steps?.filter((step) => step.layout?.large?.items?.length) || []
|
|
29641
29779
|
}), [form]);
|
|
@@ -29643,23 +29781,23 @@ var FormViewerStatic = React31.forwardRef(({ form, i18n: i18n2, isMobile, isRTL,
|
|
|
29643
29781
|
return null;
|
|
29644
29782
|
}
|
|
29645
29783
|
const isDisabled = allowFormDisable && formWithValidSteps.properties?.disabled;
|
|
29646
|
-
return
|
|
29647
|
-
|
|
29784
|
+
return React32__namespace.default.createElement(
|
|
29785
|
+
React32__namespace.default.StrictMode,
|
|
29648
29786
|
null,
|
|
29649
|
-
|
|
29787
|
+
React32__namespace.default.createElement(
|
|
29650
29788
|
FormViewerProvider,
|
|
29651
29789
|
{ httpClient, i18n: i18n2, bi, panorama, biFormFillSessionId, form: formWithValidSteps, locale, regionalFormat, isRTL, isMobile, isEditor: config?.isEditor, isComposer: config?.isComposer, externalData, fields, forcedState, instance: config?.instance, experiments, translationNamespace: TRANSLATIONS_NAMESPACE, currency, userData, WixRicosViewer, addressTemplates: config?.addressTemplates, atlasBaseUrl: config?.atlasBaseUrl, fieldInitialData, compId: config?.compId, enableAnimations },
|
|
29652
|
-
|
|
29790
|
+
React32__namespace.default.createElement(
|
|
29653
29791
|
"form",
|
|
29654
29792
|
{ "aria-label": formWithValidSteps.properties?.name ?? "", id: `form-${formWithValidSteps.id}`, "data-hook": `form-${formWithValidSteps.id}`, className: (0, import_classnames5.default)({
|
|
29655
29793
|
[form_viewer_static_module_default.readOnly]: readOnly,
|
|
29656
29794
|
[form_viewer_static_module_default.disabled]: isDisabled && !config?.isEditor
|
|
29657
29795
|
}), onSubmit: (e) => e.preventDefault() },
|
|
29658
|
-
isDisabled &&
|
|
29659
|
-
|
|
29796
|
+
isDisabled && React32__namespace.default.createElement(DisabledFormOverlay, { content: formWithValidSteps.disabledFormMessage, isEditor: config?.isEditor }),
|
|
29797
|
+
React32__namespace.default.createElement(
|
|
29660
29798
|
"fieldset",
|
|
29661
29799
|
{ className: form_viewer_static_module_default.fieldsetReset, disabled: readOnly || isDisabled },
|
|
29662
|
-
|
|
29800
|
+
React32__namespace.default.createElement(FormRoot2, { form: formWithValidSteps, forwardedRef, config, breakpoint, ...rest })
|
|
29663
29801
|
)
|
|
29664
29802
|
)
|
|
29665
29803
|
)
|
|
@@ -29816,10 +29954,8 @@ var TimeInputMapper = (props) => {
|
|
|
29816
29954
|
};
|
|
29817
29955
|
var TextMapper = (props) => props;
|
|
29818
29956
|
var SubmitButtonMapper = (props) => {
|
|
29819
|
-
const { submitText } = props;
|
|
29820
29957
|
return {
|
|
29821
|
-
...props
|
|
29822
|
-
text: submitText
|
|
29958
|
+
...props
|
|
29823
29959
|
};
|
|
29824
29960
|
};
|
|
29825
29961
|
var ProductListMapper = (props) => {
|
|
@@ -30013,6 +30149,7 @@ function normalizeSchema(obj) {
|
|
|
30013
30149
|
}
|
|
30014
30150
|
return obj;
|
|
30015
30151
|
}
|
|
30152
|
+
var LANGUAGE_CODE = "en";
|
|
30016
30153
|
var mapFieldProps = (fields, mappers) => Object.fromEntries(
|
|
30017
30154
|
Object.entries(fields).map(([fieldType, Component]) => [
|
|
30018
30155
|
fieldType,
|
|
@@ -30031,26 +30168,31 @@ var Form2 = ({
|
|
|
30031
30168
|
values,
|
|
30032
30169
|
onChange,
|
|
30033
30170
|
errors,
|
|
30034
|
-
onValidate
|
|
30171
|
+
onValidate,
|
|
30172
|
+
submitForm
|
|
30035
30173
|
}) => {
|
|
30036
30174
|
const form = normalizeSchema(unformattedForm);
|
|
30037
|
-
const
|
|
30038
|
-
|
|
30039
|
-
|
|
30175
|
+
const i18n2 = initI18n({ locale: LANGUAGE_CODE });
|
|
30176
|
+
const [step, setStep] = React32.useState();
|
|
30177
|
+
const actions = {
|
|
30178
|
+
submitForm,
|
|
30179
|
+
uploadFile: () => {
|
|
30180
|
+
console.log("upload file not implemented");
|
|
30040
30181
|
}
|
|
30041
30182
|
};
|
|
30042
|
-
const
|
|
30043
|
-
const mappedFieldProps = React31.useMemo(
|
|
30183
|
+
const mappedFieldProps = React32.useMemo(
|
|
30044
30184
|
() => mapFieldProps(fields, FIELD_PROP_MAP),
|
|
30045
30185
|
[fields]
|
|
30046
30186
|
);
|
|
30047
|
-
const mappedFieldTypes =
|
|
30187
|
+
const mappedFieldTypes = React32.useMemo(
|
|
30048
30188
|
() => mapFieldTypes(mappedFieldProps, FIELD_TYPE_MAP),
|
|
30049
30189
|
[mappedFieldProps]
|
|
30050
30190
|
);
|
|
30051
30191
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30052
30192
|
FormViewerStatic,
|
|
30053
30193
|
{
|
|
30194
|
+
stepId: step,
|
|
30195
|
+
onStepIdChange: setStep,
|
|
30054
30196
|
form,
|
|
30055
30197
|
values,
|
|
30056
30198
|
onChange,
|
|
@@ -30060,9 +30202,10 @@ var Form2 = ({
|
|
|
30060
30202
|
i18n: i18n2,
|
|
30061
30203
|
WixRicosViewer: () => null,
|
|
30062
30204
|
config: {
|
|
30063
|
-
locale:
|
|
30064
|
-
regionalFormat:
|
|
30065
|
-
}
|
|
30205
|
+
locale: LANGUAGE_CODE,
|
|
30206
|
+
regionalFormat: LANGUAGE_CODE
|
|
30207
|
+
},
|
|
30208
|
+
actions
|
|
30066
30209
|
}
|
|
30067
30210
|
);
|
|
30068
30211
|
};
|