@wix/form-public 0.25.0 → 0.27.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 +349 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +250 -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,
|
|
@@ -24698,6 +24836,8 @@ var getGridStyle = (_ref) => {
|
|
|
24698
24836
|
layout
|
|
24699
24837
|
} = _ref;
|
|
24700
24838
|
return {
|
|
24839
|
+
display: "grid",
|
|
24840
|
+
width: "100%",
|
|
24701
24841
|
gridTemplateColumns: `repeat(${layout.columns}, 1fr)`,
|
|
24702
24842
|
gridAutoRows: "minmax(min-content, max-content) 1fr"
|
|
24703
24843
|
};
|
|
@@ -24710,19 +24850,19 @@ var Focusable = (_ref) => {
|
|
|
24710
24850
|
children,
|
|
24711
24851
|
fieldId
|
|
24712
24852
|
} = _ref;
|
|
24713
|
-
const viewRef =
|
|
24853
|
+
const viewRef = React32.useRef(null);
|
|
24714
24854
|
const {
|
|
24715
24855
|
scrollTo
|
|
24716
24856
|
} = useScroll();
|
|
24717
24857
|
const {
|
|
24718
24858
|
focusedFieldId
|
|
24719
24859
|
} = useFocusedField();
|
|
24720
|
-
|
|
24860
|
+
React32.useEffect(() => {
|
|
24721
24861
|
if (viewRef.current && fieldId === focusedFieldId) {
|
|
24722
24862
|
scrollTo(viewRef.current);
|
|
24723
24863
|
}
|
|
24724
24864
|
}, [scrollTo, fieldId, focusedFieldId]);
|
|
24725
|
-
return /* @__PURE__ */
|
|
24865
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24726
24866
|
ref: viewRef
|
|
24727
24867
|
}, children);
|
|
24728
24868
|
};
|
|
@@ -24745,17 +24885,17 @@ var Grid = (_ref) => {
|
|
|
24745
24885
|
enableAnimations
|
|
24746
24886
|
} = useConfig();
|
|
24747
24887
|
const reactElementsByRow = getReactElementsByRow(items);
|
|
24748
|
-
return /* @__PURE__ */
|
|
24888
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24749
24889
|
className: grid_module_default.container,
|
|
24750
24890
|
dir: isRTL ? "rtl" : ""
|
|
24751
24891
|
}, reactElementsByRow.map((elements, index) => {
|
|
24752
24892
|
var _elements$;
|
|
24753
24893
|
const fieldId = (_elements$ = elements[0]) == null || (_elements$ = _elements$.props) == null || (_elements$ = _elements$.field) == null ? void 0 : _elements$.id;
|
|
24754
24894
|
const key = isMobile && fieldId || index;
|
|
24755
|
-
return /* @__PURE__ */
|
|
24895
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(Focusable, {
|
|
24756
24896
|
key: fieldId,
|
|
24757
24897
|
fieldId
|
|
24758
|
-
}, /* @__PURE__ */
|
|
24898
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24759
24899
|
key,
|
|
24760
24900
|
style: getGridStyle({
|
|
24761
24901
|
layout
|
|
@@ -24769,7 +24909,7 @@ var Grid = (_ref) => {
|
|
|
24769
24909
|
function getReactElementsByRow(items) {
|
|
24770
24910
|
const reactElementsByRow = items.reduce((result2, item) => {
|
|
24771
24911
|
const row = item.layout.row;
|
|
24772
|
-
const element = /* @__PURE__ */
|
|
24912
|
+
const element = /* @__PURE__ */ React32__namespace.default.cloneElement(item.component, {
|
|
24773
24913
|
key: item.id
|
|
24774
24914
|
});
|
|
24775
24915
|
if (result2[row]) {
|
|
@@ -24781,14 +24921,14 @@ function getReactElementsByRow(items) {
|
|
|
24781
24921
|
}, []);
|
|
24782
24922
|
return reactElementsByRow;
|
|
24783
24923
|
}
|
|
24784
|
-
var FormViewContext = /* @__PURE__ */
|
|
24924
|
+
var FormViewContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
24785
24925
|
function useFieldView(fieldId) {
|
|
24786
24926
|
const context = useFormView();
|
|
24787
24927
|
const fieldView = context.fields.find((field) => field.id === fieldId);
|
|
24788
24928
|
return fieldView;
|
|
24789
24929
|
}
|
|
24790
24930
|
function useFormView() {
|
|
24791
|
-
const context =
|
|
24931
|
+
const context = React32.useContext(FormViewContext);
|
|
24792
24932
|
if (context === void 0) {
|
|
24793
24933
|
throw new Error("useFormView must be used within a FormViewProvider");
|
|
24794
24934
|
}
|
|
@@ -24796,7 +24936,7 @@ function useFormView() {
|
|
|
24796
24936
|
}
|
|
24797
24937
|
|
|
24798
24938
|
// ../form-fields/dist/esm/field-layout/default-field-layout.js
|
|
24799
|
-
var
|
|
24939
|
+
var import_extends6 = __toESM(require_extends());
|
|
24800
24940
|
|
|
24801
24941
|
// ../form-fields/dist/esm/field-layout/default-field-layout.module.scss
|
|
24802
24942
|
var default_field_layout_module_default = {};
|
|
@@ -24825,7 +24965,7 @@ var DefaultFieldLayout = (_ref) => {
|
|
|
24825
24965
|
const gridColumn = `${layout.column + 1} / span ${layout.width}`;
|
|
24826
24966
|
const [labelRow, inputRow] = rows.map((currentRow) => `${currentRow} / span 1`);
|
|
24827
24967
|
if ("children" in rest) {
|
|
24828
|
-
return /* @__PURE__ */
|
|
24968
|
+
return /* @__PURE__ */ React32__namespace.default.createElement("div", (0, import_extends6.default)({
|
|
24829
24969
|
style: {
|
|
24830
24970
|
gridRow,
|
|
24831
24971
|
gridColumn
|
|
@@ -24837,13 +24977,13 @@ var DefaultFieldLayout = (_ref) => {
|
|
|
24837
24977
|
renderInput,
|
|
24838
24978
|
renderDescription
|
|
24839
24979
|
} = rest;
|
|
24840
|
-
return /* @__PURE__ */
|
|
24980
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(React32__namespace.default.Fragment, null, /* @__PURE__ */ React32__namespace.default.createElement("div", {
|
|
24841
24981
|
style: {
|
|
24842
24982
|
gridRow: labelRow,
|
|
24843
24983
|
gridColumn
|
|
24844
24984
|
},
|
|
24845
24985
|
className: default_field_layout_module_default.label
|
|
24846
|
-
}, renderLabel()), /* @__PURE__ */
|
|
24986
|
+
}, renderLabel()), /* @__PURE__ */ React32__namespace.default.createElement("div", (0, import_extends6.default)({
|
|
24847
24987
|
style: {
|
|
24848
24988
|
gridRow: inputRow,
|
|
24849
24989
|
gridColumn
|
|
@@ -24869,18 +25009,18 @@ var FormRoot = (_ref) => {
|
|
|
24869
25009
|
errors,
|
|
24870
25010
|
FieldLayout: DefaultFieldLayout
|
|
24871
25011
|
});
|
|
24872
|
-
return /* @__PURE__ */
|
|
25012
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(Grid, {
|
|
24873
25013
|
isRTL,
|
|
24874
25014
|
items: formFields,
|
|
24875
25015
|
layout: form.grid
|
|
24876
25016
|
});
|
|
24877
25017
|
};
|
|
24878
25018
|
var Form = (props) => {
|
|
24879
|
-
return /* @__PURE__ */
|
|
25019
|
+
return /* @__PURE__ */ React32__namespace.default.createElement(FormViewContext.Provider, {
|
|
24880
25020
|
value: props.form
|
|
24881
|
-
}, /* @__PURE__ */
|
|
25021
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(UniqueFieldSuffixContextProvider, {
|
|
24882
25022
|
parentId: props.form.parentId
|
|
24883
|
-
}, /* @__PURE__ */
|
|
25023
|
+
}, /* @__PURE__ */ React32__namespace.default.createElement(FormRoot, props)));
|
|
24884
25024
|
};
|
|
24885
25025
|
|
|
24886
25026
|
// ../form-fields/dist/esm/utils/sort-fields.js
|
|
@@ -26862,19 +27002,19 @@ var initialState = {
|
|
|
26862
27002
|
getCountryAddressForm: () => void 0,
|
|
26863
27003
|
addressTemplates: void 0
|
|
26864
27004
|
};
|
|
26865
|
-
var AddressFormsContext = /* @__PURE__ */
|
|
27005
|
+
var AddressFormsContext = /* @__PURE__ */ React32.createContext(initialState);
|
|
26866
27006
|
var getAddressForm = (templates, country) => {
|
|
26867
27007
|
var _templates$find, _templates$find2;
|
|
26868
27008
|
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
27009
|
};
|
|
26870
27010
|
function useAddressForms() {
|
|
26871
|
-
const context =
|
|
27011
|
+
const context = React32.useContext(AddressFormsContext);
|
|
26872
27012
|
if (context === void 0) {
|
|
26873
27013
|
throw new Error("useAddressForms must be used within a AddressFormsContext");
|
|
26874
27014
|
}
|
|
26875
27015
|
return context;
|
|
26876
27016
|
}
|
|
26877
|
-
var FieldInitialDataContext = /* @__PURE__ */
|
|
27017
|
+
var FieldInitialDataContext = /* @__PURE__ */ React32.createContext(void 0);
|
|
26878
27018
|
|
|
26879
27019
|
// ../form-fields/dist/esm/fields/vat-id/vat-id-validation.js
|
|
26880
27020
|
init_esm2();
|
|
@@ -28868,8 +29008,8 @@ function acceptOnlyValidPayments({ field, fieldValue }) {
|
|
|
28868
29008
|
|
|
28869
29009
|
// ../form-viewer/dist/esm/components/form/use-form-values.js
|
|
28870
29010
|
var useFormValues = (form, values, onChange, config) => {
|
|
28871
|
-
const normalizedValues =
|
|
28872
|
-
|
|
29011
|
+
const normalizedValues = React32.useMemo(() => normalizeValues(form, fillEmptyValues(form, values), true, config), [form, values, config]);
|
|
29012
|
+
React32.useEffect(() => {
|
|
28873
29013
|
const hasAnyValueChanged = !deepEqual(normalizedValues, values);
|
|
28874
29014
|
if (hasAnyValueChanged) {
|
|
28875
29015
|
onChange?.(normalizedValues);
|
|
@@ -28881,7 +29021,7 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
28881
29021
|
const { isMobile } = useConfig();
|
|
28882
29022
|
const experiments = useExperiments();
|
|
28883
29023
|
const useFieldsV2 = experiments.isExperimentEnabled(EXPERIMENTS.USE_FIELDS_V2);
|
|
28884
|
-
return
|
|
29024
|
+
return React32.useMemo(() => {
|
|
28885
29025
|
return (form?.steps || []).filter((step) => !stepId || stepId === step.id).map((step) => {
|
|
28886
29026
|
return createFormView({
|
|
28887
29027
|
form,
|
|
@@ -28894,7 +29034,7 @@ var useFormView2 = (form, stepId, breakpoint) => {
|
|
|
28894
29034
|
}, [form, stepId, isMobile, breakpoint, useFieldsV2]);
|
|
28895
29035
|
};
|
|
28896
29036
|
var useReportFieldEdit = (form) => {
|
|
28897
|
-
const lastChangedFields =
|
|
29037
|
+
const lastChangedFields = React32.useRef([]);
|
|
28898
29038
|
const bi = useBi();
|
|
28899
29039
|
return (changedValues) => {
|
|
28900
29040
|
const changedFieldTargets = Object.keys(changedValues);
|
|
@@ -28914,7 +29054,7 @@ var useReportFieldEdit = (form) => {
|
|
|
28914
29054
|
};
|
|
28915
29055
|
var useScrollToFirstError = ({ form, handleStepChange, currentStepId }) => {
|
|
28916
29056
|
const { setFocusedFieldId } = useFocusedField();
|
|
28917
|
-
const scrollToFirstError =
|
|
29057
|
+
const scrollToFirstError = React32.useCallback((errors) => {
|
|
28918
29058
|
const sortedFieldsInStep = getSortedFields(form, {
|
|
28919
29059
|
stepId: currentStepId
|
|
28920
29060
|
});
|
|
@@ -28923,7 +29063,7 @@ var useScrollToFirstError = ({ form, handleStepChange, currentStepId }) => {
|
|
|
28923
29063
|
});
|
|
28924
29064
|
setFocusedFieldId(fieldWithError?.id);
|
|
28925
29065
|
}, [currentStepId, form, setFocusedFieldId]);
|
|
28926
|
-
const handleScrollToFirstError =
|
|
29066
|
+
const handleScrollToFirstError = React32.useCallback((errors) => {
|
|
28927
29067
|
const sortedFields = getSortedFields(form);
|
|
28928
29068
|
const field = sortedFields?.find((_field) => {
|
|
28929
29069
|
return errors.some((error2) => _field.target === error2.errorPath.split("/")[0]);
|
|
@@ -28998,12 +29138,12 @@ var getCheckoutMessage = (text) => {
|
|
|
28998
29138
|
}
|
|
28999
29139
|
};
|
|
29000
29140
|
};
|
|
29001
|
-
var SubmitStatusContext =
|
|
29141
|
+
var SubmitStatusContext = React32.createContext(void 0);
|
|
29002
29142
|
var SubmitStatusProvider = ({ children }) => {
|
|
29003
|
-
const [submitSuccessMessage, setSubmitSuccessMessage] =
|
|
29004
|
-
const [submitFailureCode, setSubmitFailureCode] =
|
|
29005
|
-
const [submitFailureMessage, setSubmitFailureMessage] =
|
|
29006
|
-
const value =
|
|
29143
|
+
const [submitSuccessMessage, setSubmitSuccessMessage] = React32.useState();
|
|
29144
|
+
const [submitFailureCode, setSubmitFailureCode] = React32.useState();
|
|
29145
|
+
const [submitFailureMessage, setSubmitFailureMessage] = React32.useState();
|
|
29146
|
+
const value = React32.useMemo(() => ({
|
|
29007
29147
|
submitSuccessMessage,
|
|
29008
29148
|
submitFailureCode,
|
|
29009
29149
|
submitFailureMessage,
|
|
@@ -29011,10 +29151,10 @@ var SubmitStatusProvider = ({ children }) => {
|
|
|
29011
29151
|
setSubmitFailureCode,
|
|
29012
29152
|
setSubmitFailureMessage
|
|
29013
29153
|
}), [submitSuccessMessage, submitFailureCode, submitFailureMessage]);
|
|
29014
|
-
return
|
|
29154
|
+
return React32__namespace.default.createElement(SubmitStatusContext.Provider, { value }, children);
|
|
29015
29155
|
};
|
|
29016
29156
|
var useSubmitStatus = () => {
|
|
29017
|
-
const context =
|
|
29157
|
+
const context = React32.useContext(SubmitStatusContext);
|
|
29018
29158
|
if (context === void 0) {
|
|
29019
29159
|
throw new Error("useSubmitStatus must be used within a SubmitStatusProvider");
|
|
29020
29160
|
}
|
|
@@ -29041,11 +29181,11 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29041
29181
|
const { report } = useBi();
|
|
29042
29182
|
const fireSubmitSuccess = useSubmitSuccessTrigger();
|
|
29043
29183
|
const panorama = usePanorama();
|
|
29044
|
-
const reportSubmitFormBi =
|
|
29184
|
+
const reportSubmitFormBi = React32.useCallback(({ status, id }) => report(submitFormClick({
|
|
29045
29185
|
submission_status: status,
|
|
29046
29186
|
submission_id: id ?? void 0
|
|
29047
29187
|
})), [report]);
|
|
29048
|
-
const handleSubmitSuccess =
|
|
29188
|
+
const handleSubmitSuccess = React32.useCallback((submission) => {
|
|
29049
29189
|
const action = submitSettings?.submitSuccessAction;
|
|
29050
29190
|
const checkoutId = submission?.orderDetails?.checkoutId;
|
|
29051
29191
|
if (checkoutId && navigateToCheckout) {
|
|
@@ -29075,12 +29215,12 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29075
29215
|
setSubmitFailureCode,
|
|
29076
29216
|
setSubmitFailureMessage
|
|
29077
29217
|
]);
|
|
29078
|
-
const handleSubmitFailure =
|
|
29218
|
+
const handleSubmitFailure = React32.useCallback((error2) => {
|
|
29079
29219
|
const err = getErrorCode(error2);
|
|
29080
29220
|
setSubmitFailureCode(err);
|
|
29081
29221
|
setSubmitSuccessMessage(void 0);
|
|
29082
29222
|
}, [setSubmitFailureCode, setSubmitSuccessMessage]);
|
|
29083
|
-
const handleCustomErrorMessages =
|
|
29223
|
+
const handleCustomErrorMessages = React32.useCallback((error2) => {
|
|
29084
29224
|
const errors = getErrorList(error2);
|
|
29085
29225
|
const formCustomErrorMessage = getFormCustomErrorMessage(errors);
|
|
29086
29226
|
if (formCustomErrorMessage) {
|
|
@@ -29092,7 +29232,7 @@ var useSubmit = ({ validateAndScrollToError, submitAction, onSubmit, onSubmitSuc
|
|
|
29092
29232
|
handleScrollToFirstError?.(fieldCustomErrorMessages);
|
|
29093
29233
|
}
|
|
29094
29234
|
}, [setSubmitFailureMessage, onValidate, handleScrollToFirstError]);
|
|
29095
|
-
const submitForm =
|
|
29235
|
+
const submitForm = React32.useCallback(async () => {
|
|
29096
29236
|
const errors = await validateAndScrollToError(values);
|
|
29097
29237
|
onSubmit?.();
|
|
29098
29238
|
reportSubmitFormBi({ status: BiFormSubmissionStatus.INIT });
|
|
@@ -29168,7 +29308,7 @@ var reportErrorChanges = ({ bi, existingErrors, newErrors, form }) => {
|
|
|
29168
29308
|
var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
29169
29309
|
const { addressTemplates } = useAddressForms();
|
|
29170
29310
|
const externalData = useExternalData();
|
|
29171
|
-
const validateFields2 =
|
|
29311
|
+
const validateFields2 = React32.useCallback(async (newValues) => {
|
|
29172
29312
|
const result2 = await validate(form, newValues, addressTemplates, validationMode);
|
|
29173
29313
|
const _errors = result2?.errors || [];
|
|
29174
29314
|
const additionalErrors = runAdditionalValidation({
|
|
@@ -29180,7 +29320,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
|
29180
29320
|
setErrors(allErrors);
|
|
29181
29321
|
return allErrors;
|
|
29182
29322
|
}, [form, setErrors, addressTemplates, externalData, validationMode]);
|
|
29183
|
-
const handleFieldValidation =
|
|
29323
|
+
const handleFieldValidation = React32.useCallback(async (fieldsToValidate) => {
|
|
29184
29324
|
const fieldErrors = await getFieldErrors(fieldsToValidate, form, addressTemplates, externalData, validationMode);
|
|
29185
29325
|
const otherErrors = (errorsRef.current ?? []).filter((error2) => {
|
|
29186
29326
|
return !findErrorByNormalizedPath(fieldsToValidate, error2.errorPath);
|
|
@@ -29196,7 +29336,7 @@ var useValidation = ({ form, errorsRef, setErrors, validationMode }) => {
|
|
|
29196
29336
|
externalData,
|
|
29197
29337
|
validationMode
|
|
29198
29338
|
]);
|
|
29199
|
-
const validateStep =
|
|
29339
|
+
const validateStep = React32.useCallback(async (stepId, newValues) => {
|
|
29200
29340
|
const items = form?.steps?.find((step) => step.id === stepId)?.layout?.large?.items || [];
|
|
29201
29341
|
const validationErrors = await Promise.all(items.map(async (item) => {
|
|
29202
29342
|
const field = form?.fields?.find((_field) => _field.id === item.fieldId);
|
|
@@ -29232,9 +29372,9 @@ var SubmitThankYouMessage = ({ messageText }) => {
|
|
|
29232
29372
|
if (!messageText) {
|
|
29233
29373
|
return null;
|
|
29234
29374
|
}
|
|
29235
|
-
return
|
|
29375
|
+
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
29376
|
};
|
|
29237
|
-
var Error2 = ({ size, ...props }) => /* @__PURE__ */
|
|
29377
|
+
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
29378
|
Error2.displayName = "Error";
|
|
29239
29379
|
var Error_default = Error2;
|
|
29240
29380
|
|
|
@@ -29247,10 +29387,10 @@ var SubmitErrorMessage = ({ errorMessageCode, errorMessage }) => {
|
|
|
29247
29387
|
}
|
|
29248
29388
|
const errorMessageKeyByCode = `${ERROR_MESSAGE_KEY}.${errorMessageCode}`;
|
|
29249
29389
|
const errorMessageKey = i18n2.exists(`${TRANSLATIONS_NAMESPACE}:${errorMessageKeyByCode}`) ? errorMessageKeyByCode : ERROR_MESSAGE_KEY;
|
|
29250
|
-
return
|
|
29390
|
+
return React32__namespace.default.createElement(
|
|
29251
29391
|
"div",
|
|
29252
29392
|
{ className: submit_status_message_module_default.errorMessage, "data-hook": DATA_HOOKS.SUBMIT_ERROR_MESSAGE },
|
|
29253
|
-
|
|
29393
|
+
React32__namespace.default.createElement(Error_default, { className: submit_status_message_module_default.errorIcon, "aria-hidden": "true" }),
|
|
29254
29394
|
errorMessage || t(errorMessageKey)
|
|
29255
29395
|
);
|
|
29256
29396
|
};
|
|
@@ -29270,8 +29410,8 @@ var transitionStyles = {
|
|
|
29270
29410
|
exited: { opacity: 0 }
|
|
29271
29411
|
};
|
|
29272
29412
|
var FadeOut = ({ visible, children }) => {
|
|
29273
|
-
const nodeRef =
|
|
29274
|
-
return
|
|
29413
|
+
const nodeRef = React32.useRef(null);
|
|
29414
|
+
return React32__namespace.default.createElement(Transition_default, { nodeRef, in: visible, timeout: DURATION }, (state) => React32__namespace.default.createElement("div", { ref: nodeRef, style: {
|
|
29275
29415
|
...defaultStyle,
|
|
29276
29416
|
...transitionStyles[state]
|
|
29277
29417
|
} }, [ENTERING, ENTERED, EXITING].includes(state) ? children : null));
|
|
@@ -29280,15 +29420,15 @@ var FadeOut = ({ visible, children }) => {
|
|
|
29280
29420
|
// ../form-viewer/dist/esm/components/submit-status-message/submit-status-message.js
|
|
29281
29421
|
var SubmitStatusMessage = () => {
|
|
29282
29422
|
const { submitSuccessMessage, submitFailureCode, submitFailureMessage } = useSubmitStatus();
|
|
29283
|
-
return
|
|
29423
|
+
return React32__namespace.default.createElement(
|
|
29284
29424
|
"div",
|
|
29285
29425
|
{ role: "region", "aria-live": "polite" },
|
|
29286
|
-
|
|
29426
|
+
React32__namespace.default.createElement(
|
|
29287
29427
|
FadeOut,
|
|
29288
29428
|
{ visible: !!submitSuccessMessage },
|
|
29289
|
-
|
|
29429
|
+
React32__namespace.default.createElement(SubmitThankYouMessage, { messageText: submitSuccessMessage })
|
|
29290
29430
|
),
|
|
29291
|
-
|
|
29431
|
+
React32__namespace.default.createElement(SubmitErrorMessage, { errorMessageCode: submitFailureCode, errorMessage: submitFailureMessage })
|
|
29292
29432
|
);
|
|
29293
29433
|
};
|
|
29294
29434
|
var StepTitleA11y = ({ index = 0, total = 0 }) => {
|
|
@@ -29297,7 +29437,7 @@ var StepTitleA11y = ({ index = 0, total = 0 }) => {
|
|
|
29297
29437
|
index: index + 1,
|
|
29298
29438
|
total
|
|
29299
29439
|
});
|
|
29300
|
-
return total > 1 ?
|
|
29440
|
+
return total > 1 ? React32__namespace.default.createElement("span", { "aria-label": stepTitleA11y, "aria-live": "polite" }) : null;
|
|
29301
29441
|
};
|
|
29302
29442
|
|
|
29303
29443
|
// ../form-viewer/dist/esm/components/form/form-root.js
|
|
@@ -29324,13 +29464,13 @@ var FormRoot2 = ({
|
|
|
29324
29464
|
onStatusChange,
|
|
29325
29465
|
validationMode
|
|
29326
29466
|
}) => {
|
|
29327
|
-
const formWithOverrides =
|
|
29467
|
+
const formWithOverrides = React32.useMemo(() => applyAllOverrides(unprocessedForm, unprocessedValues, overrides), [unprocessedForm, unprocessedValues, overrides]);
|
|
29328
29468
|
const formId = formWithOverrides.id;
|
|
29329
29469
|
const { setFocusedFieldId } = useFocusedField();
|
|
29330
29470
|
const normalizedValues = useFormValues(formWithOverrides, unprocessedValues, onChange, config);
|
|
29331
|
-
const valuesRef =
|
|
29471
|
+
const valuesRef = React32.useRef(normalizedValues);
|
|
29332
29472
|
valuesRef.current = normalizedValues;
|
|
29333
|
-
const errorsRef =
|
|
29473
|
+
const errorsRef = React32.useRef(errors);
|
|
29334
29474
|
errorsRef.current = errors;
|
|
29335
29475
|
const bi = useBi();
|
|
29336
29476
|
const reportFieldEdit = useReportFieldEdit(formWithOverrides);
|
|
@@ -29359,7 +29499,7 @@ var FormRoot2 = ({
|
|
|
29359
29499
|
});
|
|
29360
29500
|
onValidate(newErrors);
|
|
29361
29501
|
};
|
|
29362
|
-
|
|
29502
|
+
React32.useEffect(() => {
|
|
29363
29503
|
bi.report(formView({ mode: readOnly ? "preview" : "live_site" }));
|
|
29364
29504
|
}, []);
|
|
29365
29505
|
const formViews = useFormView2(formWithOverrides, stepId, breakpoint);
|
|
@@ -29370,7 +29510,7 @@ var FormRoot2 = ({
|
|
|
29370
29510
|
setErrors: _onValidate,
|
|
29371
29511
|
validationMode
|
|
29372
29512
|
});
|
|
29373
|
-
const handleStepChange =
|
|
29513
|
+
const handleStepChange = React32.useCallback((step) => {
|
|
29374
29514
|
const newStepId = formWithOverrides.steps?.[step]?.id;
|
|
29375
29515
|
if (newStepId) {
|
|
29376
29516
|
const firstFieldInStep = getSortedFields(formWithOverrides, {
|
|
@@ -29385,17 +29525,17 @@ var FormRoot2 = ({
|
|
|
29385
29525
|
handleStepChange,
|
|
29386
29526
|
currentStepId: stepId
|
|
29387
29527
|
});
|
|
29388
|
-
const resetFormValues =
|
|
29528
|
+
const resetFormValues = React32.useCallback(() => {
|
|
29389
29529
|
onChange(fillEmptyValues(formWithOverrides, {}));
|
|
29390
29530
|
}, [formWithOverrides, onChange]);
|
|
29391
|
-
const validateAndScrollToError =
|
|
29531
|
+
const validateAndScrollToError = React32.useCallback(async (values) => {
|
|
29392
29532
|
const validationErrors = await validateFields2(values);
|
|
29393
29533
|
if (validationErrors && validationErrors.length) {
|
|
29394
29534
|
handleScrollToFirstError(validationErrors);
|
|
29395
29535
|
}
|
|
29396
29536
|
return validationErrors;
|
|
29397
29537
|
}, [validateFields2, handleScrollToFirstError]);
|
|
29398
|
-
const submitAction =
|
|
29538
|
+
const submitAction = React32.useCallback(async (values) => {
|
|
29399
29539
|
const response = await actions?.submitForm?.(formId, values);
|
|
29400
29540
|
return response?.submission;
|
|
29401
29541
|
}, [actions, formId]);
|
|
@@ -29413,7 +29553,7 @@ var FormRoot2 = ({
|
|
|
29413
29553
|
onValidate: _onValidate,
|
|
29414
29554
|
handleScrollToFirstError
|
|
29415
29555
|
});
|
|
29416
|
-
|
|
29556
|
+
React32.useImperativeHandle(forwardedRef, () => ({
|
|
29417
29557
|
submit: submitForm,
|
|
29418
29558
|
validate: async () => {
|
|
29419
29559
|
const validationErrors = await validateFields2(normalizedValues);
|
|
@@ -29432,9 +29572,9 @@ var FormRoot2 = ({
|
|
|
29432
29572
|
scrollToFirstError
|
|
29433
29573
|
]);
|
|
29434
29574
|
const currentStep = getStepIndex(stepId, formWithOverrides.steps);
|
|
29435
|
-
const setNextStep =
|
|
29436
|
-
const setPreviousStep =
|
|
29437
|
-
const fieldActions =
|
|
29575
|
+
const setNextStep = React32.useCallback(() => handleStepChange(currentStep + 1), [currentStep, handleStepChange]);
|
|
29576
|
+
const setPreviousStep = React32.useCallback(() => handleStepChange(currentStep - 1), [currentStep, handleStepChange]);
|
|
29577
|
+
const fieldActions = React32.useMemo(() => actions ? {
|
|
29438
29578
|
actions: { ...actions, submitForm, setNextStep, setPreviousStep },
|
|
29439
29579
|
formId,
|
|
29440
29580
|
inProgress
|
|
@@ -29442,23 +29582,23 @@ var FormRoot2 = ({
|
|
|
29442
29582
|
if (!formViews?.length || !currentView) {
|
|
29443
29583
|
return null;
|
|
29444
29584
|
}
|
|
29445
|
-
return
|
|
29585
|
+
return React32__namespace.default.createElement(
|
|
29446
29586
|
FieldValidationContext.Provider,
|
|
29447
29587
|
{ value: {
|
|
29448
29588
|
validateFields: handleFieldValidation
|
|
29449
29589
|
} },
|
|
29450
|
-
|
|
29590
|
+
React32__namespace.default.createElement(
|
|
29451
29591
|
FieldActionsContext.Provider,
|
|
29452
29592
|
{ value: fieldActions },
|
|
29453
|
-
|
|
29593
|
+
React32__namespace.default.createElement(
|
|
29454
29594
|
FormStatusProvider,
|
|
29455
29595
|
{ onStatusChange },
|
|
29456
|
-
|
|
29596
|
+
React32__namespace.default.createElement(
|
|
29457
29597
|
"div",
|
|
29458
29598
|
{ "data-hook": DATA_HOOKS.FORM_ROOT },
|
|
29459
|
-
|
|
29460
|
-
|
|
29461
|
-
|
|
29599
|
+
React32__namespace.default.createElement(Form, { form: currentView, values: normalizedValues, onFieldChange, errors, dataHook: DATA_HOOKS.FORM_ROOT }),
|
|
29600
|
+
React32__namespace.default.createElement(StepTitleA11y, { total: formWithOverrides.steps?.length, index: currentStep }),
|
|
29601
|
+
React32__namespace.default.createElement(SubmitStatusMessage, null)
|
|
29462
29602
|
)
|
|
29463
29603
|
)
|
|
29464
29604
|
)
|
|
@@ -29471,8 +29611,8 @@ var dummyBi = {
|
|
|
29471
29611
|
updateDefaults: () => dummyBi
|
|
29472
29612
|
};
|
|
29473
29613
|
var useFormBi = (form, bi, biFormFillSessionId) => {
|
|
29474
|
-
const formEditSessionId =
|
|
29475
|
-
return
|
|
29614
|
+
const formEditSessionId = React32.useMemo(generateUUID, []);
|
|
29615
|
+
return React32.useMemo(() => {
|
|
29476
29616
|
if (!bi) {
|
|
29477
29617
|
return dummyBi;
|
|
29478
29618
|
}
|
|
@@ -29502,12 +29642,12 @@ var useFormBi = (form, bi, biFormFillSessionId) => {
|
|
|
29502
29642
|
|
|
29503
29643
|
// ../form-viewer/dist/esm/components/root/form-viewer-provider.js
|
|
29504
29644
|
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 =
|
|
29645
|
+
const translations = React32.useMemo(() => ({
|
|
29506
29646
|
t: i18n2.getFixedT(locale, translationNamespace),
|
|
29507
29647
|
i18n: i18n2
|
|
29508
29648
|
}), [locale, i18n2, translationNamespace]);
|
|
29509
29649
|
const formBi = useFormBi(form, bi, biFormFillSessionId);
|
|
29510
|
-
const config =
|
|
29650
|
+
const config = React32.useMemo(() => ({
|
|
29511
29651
|
locale,
|
|
29512
29652
|
regionalFormat,
|
|
29513
29653
|
instance,
|
|
@@ -29534,59 +29674,59 @@ var FormViewerProvider = ({ i18n: i18n2, bi, biFormFillSessionId, form, isMobile
|
|
|
29534
29674
|
isRTL,
|
|
29535
29675
|
enableAnimations
|
|
29536
29676
|
]);
|
|
29537
|
-
const forcedViewState =
|
|
29538
|
-
return
|
|
29677
|
+
const forcedViewState = React32.useMemo(() => forcedState ?? [], [forcedState]);
|
|
29678
|
+
return React32__namespace.default.createElement(
|
|
29539
29679
|
FormFieldsContext.Provider,
|
|
29540
29680
|
{ value: fields },
|
|
29541
|
-
|
|
29681
|
+
React32__namespace.default.createElement(
|
|
29542
29682
|
HttpClientContext.Provider,
|
|
29543
29683
|
{ value: { httpClient } },
|
|
29544
|
-
|
|
29684
|
+
React32__namespace.default.createElement(
|
|
29545
29685
|
PanoramaContext.Provider,
|
|
29546
29686
|
{ value: { panorama } },
|
|
29547
|
-
|
|
29687
|
+
React32__namespace.default.createElement(
|
|
29548
29688
|
TranslationContext.Provider,
|
|
29549
29689
|
{ value: translations },
|
|
29550
|
-
|
|
29690
|
+
React32__namespace.default.createElement(
|
|
29551
29691
|
ScrollProvider,
|
|
29552
29692
|
null,
|
|
29553
|
-
|
|
29693
|
+
React32__namespace.default.createElement(
|
|
29554
29694
|
FocusedFieldProvider,
|
|
29555
29695
|
null,
|
|
29556
|
-
|
|
29696
|
+
React32__namespace.default.createElement(
|
|
29557
29697
|
FieldInitialDataContext.Provider,
|
|
29558
29698
|
{ value: fieldInitialData },
|
|
29559
|
-
|
|
29699
|
+
React32__namespace.default.createElement(
|
|
29560
29700
|
BiContext.Provider,
|
|
29561
29701
|
{ value: formBi },
|
|
29562
|
-
|
|
29702
|
+
React32__namespace.default.createElement(
|
|
29563
29703
|
ExternalDataProvider,
|
|
29564
29704
|
{ externalData },
|
|
29565
|
-
|
|
29705
|
+
React32__namespace.default.createElement(
|
|
29566
29706
|
ConfigContext.Provider,
|
|
29567
29707
|
{ value: config },
|
|
29568
|
-
|
|
29708
|
+
React32__namespace.default.createElement(
|
|
29569
29709
|
ForcedStateContext.Provider,
|
|
29570
29710
|
{ value: forcedViewState },
|
|
29571
|
-
|
|
29711
|
+
React32__namespace.default.createElement(
|
|
29572
29712
|
FormContext.Provider,
|
|
29573
29713
|
{ value: form },
|
|
29574
|
-
|
|
29714
|
+
React32__namespace.default.createElement(
|
|
29575
29715
|
AddressFormsContext.Provider,
|
|
29576
29716
|
{ value: {
|
|
29577
29717
|
getCountryAddressForm: (country) => getAddressForm(addressTemplates, country),
|
|
29578
29718
|
addressTemplates
|
|
29579
29719
|
} },
|
|
29580
|
-
|
|
29720
|
+
React32__namespace.default.createElement(
|
|
29581
29721
|
ExperimentsContext.Provider,
|
|
29582
29722
|
{ value: experiments },
|
|
29583
|
-
|
|
29723
|
+
React32__namespace.default.createElement(
|
|
29584
29724
|
EventsProvider,
|
|
29585
29725
|
null,
|
|
29586
|
-
|
|
29726
|
+
React32__namespace.default.createElement(
|
|
29587
29727
|
WixRicosViewerContext.Provider,
|
|
29588
29728
|
{ value: WixRicosViewer },
|
|
29589
|
-
|
|
29729
|
+
React32__namespace.default.createElement(SubmitStatusProvider, null, children)
|
|
29590
29730
|
)
|
|
29591
29731
|
)
|
|
29592
29732
|
)
|
|
@@ -29625,17 +29765,17 @@ var DisabledFormOverlay = ({ content, isEditor }) => {
|
|
|
29625
29765
|
if (isEditor || !content) {
|
|
29626
29766
|
return null;
|
|
29627
29767
|
}
|
|
29628
|
-
return
|
|
29768
|
+
return React32__namespace.default.createElement(ricos_viewer_default, { content, className: disabled_form_overlay_module_default.disabledFormOverlay, customTheme });
|
|
29629
29769
|
};
|
|
29630
29770
|
|
|
29631
29771
|
// ../form-viewer/dist/esm/components/root/form-viewer-static.js
|
|
29632
|
-
var FormViewerStatic =
|
|
29772
|
+
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
29773
|
const { locale = "en", regionalFormat = "en", userData } = config || {};
|
|
29634
|
-
|
|
29774
|
+
React32.useState(() => {
|
|
29635
29775
|
translations && i18n2.addResources(locale, TRANSLATIONS_NAMESPACE, translations);
|
|
29636
29776
|
localeDataset && i18n2.addResources(locale, TRANSLATIONS_NAMESPACE, localeDataset);
|
|
29637
29777
|
});
|
|
29638
|
-
const formWithValidSteps =
|
|
29778
|
+
const formWithValidSteps = React32.useMemo(() => ({
|
|
29639
29779
|
...form,
|
|
29640
29780
|
steps: form?.steps?.filter((step) => step.layout?.large?.items?.length) || []
|
|
29641
29781
|
}), [form]);
|
|
@@ -29643,23 +29783,23 @@ var FormViewerStatic = React31.forwardRef(({ form, i18n: i18n2, isMobile, isRTL,
|
|
|
29643
29783
|
return null;
|
|
29644
29784
|
}
|
|
29645
29785
|
const isDisabled = allowFormDisable && formWithValidSteps.properties?.disabled;
|
|
29646
|
-
return
|
|
29647
|
-
|
|
29786
|
+
return React32__namespace.default.createElement(
|
|
29787
|
+
React32__namespace.default.StrictMode,
|
|
29648
29788
|
null,
|
|
29649
|
-
|
|
29789
|
+
React32__namespace.default.createElement(
|
|
29650
29790
|
FormViewerProvider,
|
|
29651
29791
|
{ 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
|
-
|
|
29792
|
+
React32__namespace.default.createElement(
|
|
29653
29793
|
"form",
|
|
29654
29794
|
{ "aria-label": formWithValidSteps.properties?.name ?? "", id: `form-${formWithValidSteps.id}`, "data-hook": `form-${formWithValidSteps.id}`, className: (0, import_classnames5.default)({
|
|
29655
29795
|
[form_viewer_static_module_default.readOnly]: readOnly,
|
|
29656
29796
|
[form_viewer_static_module_default.disabled]: isDisabled && !config?.isEditor
|
|
29657
29797
|
}), onSubmit: (e) => e.preventDefault() },
|
|
29658
|
-
isDisabled &&
|
|
29659
|
-
|
|
29798
|
+
isDisabled && React32__namespace.default.createElement(DisabledFormOverlay, { content: formWithValidSteps.disabledFormMessage, isEditor: config?.isEditor }),
|
|
29799
|
+
React32__namespace.default.createElement(
|
|
29660
29800
|
"fieldset",
|
|
29661
29801
|
{ className: form_viewer_static_module_default.fieldsetReset, disabled: readOnly || isDisabled },
|
|
29662
|
-
|
|
29802
|
+
React32__namespace.default.createElement(FormRoot2, { form: formWithValidSteps, forwardedRef, config, breakpoint, ...rest })
|
|
29663
29803
|
)
|
|
29664
29804
|
)
|
|
29665
29805
|
)
|
|
@@ -29816,10 +29956,8 @@ var TimeInputMapper = (props) => {
|
|
|
29816
29956
|
};
|
|
29817
29957
|
var TextMapper = (props) => props;
|
|
29818
29958
|
var SubmitButtonMapper = (props) => {
|
|
29819
|
-
const { submitText } = props;
|
|
29820
29959
|
return {
|
|
29821
|
-
...props
|
|
29822
|
-
text: submitText
|
|
29960
|
+
...props
|
|
29823
29961
|
};
|
|
29824
29962
|
};
|
|
29825
29963
|
var ProductListMapper = (props) => {
|
|
@@ -30013,6 +30151,7 @@ function normalizeSchema(obj) {
|
|
|
30013
30151
|
}
|
|
30014
30152
|
return obj;
|
|
30015
30153
|
}
|
|
30154
|
+
var LANGUAGE_CODE = "en";
|
|
30016
30155
|
var mapFieldProps = (fields, mappers) => Object.fromEntries(
|
|
30017
30156
|
Object.entries(fields).map(([fieldType, Component]) => [
|
|
30018
30157
|
fieldType,
|
|
@@ -30031,26 +30170,31 @@ var Form2 = ({
|
|
|
30031
30170
|
values,
|
|
30032
30171
|
onChange,
|
|
30033
30172
|
errors,
|
|
30034
|
-
onValidate
|
|
30173
|
+
onValidate,
|
|
30174
|
+
submitForm
|
|
30035
30175
|
}) => {
|
|
30036
30176
|
const form = normalizeSchema(unformattedForm);
|
|
30037
|
-
const
|
|
30038
|
-
|
|
30039
|
-
|
|
30177
|
+
const i18n2 = initI18n({ locale: LANGUAGE_CODE });
|
|
30178
|
+
const [step, setStep] = React32.useState();
|
|
30179
|
+
const actions = {
|
|
30180
|
+
submitForm,
|
|
30181
|
+
uploadFile: () => {
|
|
30182
|
+
console.log("upload file not implemented");
|
|
30040
30183
|
}
|
|
30041
30184
|
};
|
|
30042
|
-
const
|
|
30043
|
-
const mappedFieldProps = React31.useMemo(
|
|
30185
|
+
const mappedFieldProps = React32.useMemo(
|
|
30044
30186
|
() => mapFieldProps(fields, FIELD_PROP_MAP),
|
|
30045
30187
|
[fields]
|
|
30046
30188
|
);
|
|
30047
|
-
const mappedFieldTypes =
|
|
30189
|
+
const mappedFieldTypes = React32.useMemo(
|
|
30048
30190
|
() => mapFieldTypes(mappedFieldProps, FIELD_TYPE_MAP),
|
|
30049
30191
|
[mappedFieldProps]
|
|
30050
30192
|
);
|
|
30051
30193
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30052
30194
|
FormViewerStatic,
|
|
30053
30195
|
{
|
|
30196
|
+
stepId: step,
|
|
30197
|
+
onStepIdChange: setStep,
|
|
30054
30198
|
form,
|
|
30055
30199
|
values,
|
|
30056
30200
|
onChange,
|
|
@@ -30060,9 +30204,10 @@ var Form2 = ({
|
|
|
30060
30204
|
i18n: i18n2,
|
|
30061
30205
|
WixRicosViewer: () => null,
|
|
30062
30206
|
config: {
|
|
30063
|
-
locale:
|
|
30064
|
-
regionalFormat:
|
|
30065
|
-
}
|
|
30207
|
+
locale: LANGUAGE_CODE,
|
|
30208
|
+
regionalFormat: LANGUAGE_CODE
|
|
30209
|
+
},
|
|
30210
|
+
actions
|
|
30066
30211
|
}
|
|
30067
30212
|
);
|
|
30068
30213
|
};
|