@zengenti/contensis-react-base 3.0.0-beta.6 → 3.0.0-beta.60
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/README.md +4 -4
- package/cjs/{App-3324f784.js → App-36c7bf3a.js} +124 -140
- package/cjs/App-36c7bf3a.js.map +1 -0
- package/cjs/{RouteLoader-c7957b14.js → RouteLoader-ece762dc.js} +31 -23
- package/cjs/RouteLoader-ece762dc.js.map +1 -0
- package/cjs/ToJs-09204afd.js +129 -0
- package/cjs/ToJs-09204afd.js.map +1 -0
- package/cjs/VersionInfo-df35c917.js +181 -0
- package/cjs/VersionInfo-df35c917.js.map +1 -0
- package/cjs/{actions-a24bf46e.js → actions-6b9ef168.js} +5 -4
- package/cjs/actions-6b9ef168.js.map +1 -0
- package/cjs/client.js +16 -21
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +3583 -38
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +4114 -195
- package/cjs/forms.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
- package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
- package/cjs/{login-c810cc4c.js → login-d67b82aa.js} +92 -55
- package/cjs/login-d67b82aa.js.map +1 -0
- package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
- package/cjs/reducers-3a4f8971.js.map +1 -0
- package/cjs/redux.js +6 -5
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +5 -4
- package/cjs/routing.js.map +1 -1
- package/cjs/sagas-8cf21563.js +2038 -0
- package/cjs/sagas-8cf21563.js.map +1 -0
- package/cjs/search.js +280 -1907
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-0ec95076.js → selectors-2c1b1183.js} +7 -3
- package/cjs/selectors-2c1b1183.js.map +1 -0
- package/cjs/user.js +21 -12
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +55 -212
- package/cjs/util.js.map +1 -1
- package/cjs/{version-4f0f5fa6.js → version-ca4173a8.js} +28 -20
- package/cjs/version-ca4173a8.js.map +1 -0
- package/cjs/{version-085d203d.js → version-dcfdafd9.js} +5 -5
- package/cjs/version-dcfdafd9.js.map +1 -0
- package/esm/{App-1b05ab11.js → App-61bf1832.js} +124 -141
- package/esm/App-61bf1832.js.map +1 -0
- package/esm/{RouteLoader-e5f0e8cb.js → RouteLoader-7749ad3f.js} +31 -23
- package/esm/RouteLoader-7749ad3f.js.map +1 -0
- package/esm/ToJs-2627ce21.js +99 -0
- package/esm/ToJs-2627ce21.js.map +1 -0
- package/esm/VersionInfo-add96cdb.js +172 -0
- package/esm/VersionInfo-add96cdb.js.map +1 -0
- package/esm/{actions-927d9698.js → actions-5437f43d.js} +5 -4
- package/esm/actions-5437f43d.js.map +1 -0
- package/esm/client.js +17 -22
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +3581 -37
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +4114 -198
- package/esm/forms.js.map +1 -1
- package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
- package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
- package/esm/{login-f8ba3aeb.js → login-f6dfbe1b.js} +92 -55
- package/esm/login-f6dfbe1b.js.map +1 -0
- package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
- package/esm/reducers-8e5d6232.js.map +1 -0
- package/esm/redux.js +8 -7
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +5 -4
- package/esm/routing.js.map +1 -1
- package/esm/sagas-a22fc54a.js +1952 -0
- package/esm/sagas-a22fc54a.js.map +1 -0
- package/esm/search.js +240 -1848
- package/esm/search.js.map +1 -1
- package/esm/{selectors-b98d5c76.js → selectors-65f0f31c.js} +7 -4
- package/esm/selectors-65f0f31c.js.map +1 -0
- package/esm/user.js +23 -14
- package/esm/user.js.map +1 -1
- package/esm/util.js +54 -209
- package/esm/util.js.map +1 -1
- package/esm/{version-16aa83eb.js → version-1d46bde8.js} +27 -20
- package/esm/version-1d46bde8.js.map +1 -0
- package/esm/version-696796d7.js +15 -0
- package/esm/version-696796d7.js.map +1 -0
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
- package/models/forms/index.d.ts +2 -0
- package/models/index.d.ts +1 -0
- package/models/redux/appstate.d.ts +5 -10
- package/models/redux/selectors/navigation.d.ts +2 -1
- package/models/routing/components/RouteLoader.d.ts +2 -19
- package/models/routing/redux/actions.d.ts +1 -1
- package/models/routing/redux/selectors.d.ts +1 -1
- package/models/routing/routes.d.ts +3 -2
- package/models/routing/util/expressions.d.ts +3 -2
- package/models/routing/util/queries.d.ts +1 -1
- package/models/search/containers/withListing.d.ts +1 -1
- package/models/search/containers/withSearch.d.ts +1 -1
- package/models/search/hooks/useFacets.hook.d.ts +3 -0
- package/models/search/hooks/useListing.hook.d.ts +3 -0
- package/models/search/hooks/useMinilist.hook.d.ts +2 -9
- package/models/search/index.d.ts +4 -1
- package/models/search/models/Queries.d.ts +8 -5
- package/models/search/models/Search.d.ts +60 -28
- package/models/search/models/SearchActions.d.ts +4 -3
- package/models/search/models/SearchProps.d.ts +52 -7
- package/models/search/models/SearchState.d.ts +5 -1
- package/models/search/models/index.d.ts +3 -1
- package/models/search/redux/actions.d.ts +2 -1
- package/models/search/redux/reducers.d.ts +230 -314
- package/models/search/redux/sagas.d.ts +5 -5
- package/models/search/redux/selectors.d.ts +19 -22
- package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
- package/models/search/search/expressions.d.ts +3 -6
- package/models/search/{redux → search}/queries.d.ts +0 -0
- package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
- package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
- package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
- package/models/search/transformations/index.d.ts +3 -0
- package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
- package/models/search/transformations/state-to-searchuri.d.ts +2 -13
- package/models/server/features/linkdepth-api/api.d.ts +12 -0
- package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
- package/models/server/middleware/bundleManipulation.d.ts +2 -1
- package/models/server/util/headers.d.ts +3 -2
- package/models/user/components/Login.d.ts +1 -2
- package/models/user/components/LoginForm.d.ts +1 -2
- package/models/user/hocs/withLogin.d.ts +4 -2
- package/models/user/hocs/withRegistration.d.ts +4 -2
- package/models/user/hooks/useChangePassword.d.ts +5 -5
- package/models/user/hooks/useForgotPassword.d.ts +6 -6
- package/models/user/hooks/useLogin.d.ts +9 -45
- package/models/user/hooks/useRegistration.d.ts +4 -4
- package/models/user/redux/reducers.d.ts +4 -5
- package/models/user/redux/sagas/login.d.ts +11 -8
- package/models/user/redux/selectors.d.ts +33 -71
- package/models/user/util/LoginHelper.class.d.ts +4 -3
- package/models/util/ContensisDeliveryApi.d.ts +1 -3
- package/models/util/json-mapper.d.ts +9 -3
- package/models/util/merge.d.ts +1 -0
- package/package-lock.json +2690 -3400
- package/package.json +60 -55
- package/cjs/App-3324f784.js.map +0 -1
- package/cjs/RouteLoader-c7957b14.js.map +0 -1
- package/cjs/ToJs-a38fa20e.js +0 -230
- package/cjs/ToJs-a38fa20e.js.map +0 -1
- package/cjs/actions-a24bf46e.js.map +0 -1
- package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
- package/cjs/login-c810cc4c.js.map +0 -1
- package/cjs/reducers-fde41d6b.js.map +0 -1
- package/cjs/selectors-0ec95076.js.map +0 -1
- package/cjs/version-085d203d.js.map +0 -1
- package/cjs/version-4f0f5fa6.js.map +0 -1
- package/esm/App-1b05ab11.js.map +0 -1
- package/esm/RouteLoader-e5f0e8cb.js.map +0 -1
- package/esm/ToJs-879a5a85.js +0 -199
- package/esm/ToJs-879a5a85.js.map +0 -1
- package/esm/actions-927d9698.js.map +0 -1
- package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
- package/esm/login-f8ba3aeb.js.map +0 -1
- package/esm/reducers-d6c0edb1.js.map +0 -1
- package/esm/selectors-b98d5c76.js.map +0 -1
- package/esm/version-16aa83eb.js.map +0 -1
- package/esm/version-3833e8b5.js +0 -15
- package/esm/version-3833e8b5.js.map +0 -1
- package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
- package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
- package/models/server/features/caching/cacheHashing.d.ts +0 -1
package/esm/forms.js
CHANGED
|
@@ -1,185 +1,4095 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { produce } from 'immer';
|
|
2
2
|
import { takeEvery, takeLatest, put, call, select, all } from '@redux-saga/core/effects';
|
|
3
3
|
import { createSelector } from 'reselect';
|
|
4
|
+
import { jpath } from 'jsonpath-mapper';
|
|
5
|
+
import queryString__default from 'query-string';
|
|
6
|
+
import 'redux';
|
|
7
|
+
import 'redux-thunk';
|
|
8
|
+
import 'redux-saga';
|
|
9
|
+
import 'redux-injectors';
|
|
10
|
+
import merge from 'deepmerge';
|
|
4
11
|
import React, { createContext, useEffect, useState } from 'react';
|
|
5
12
|
import PropTypes from 'prop-types';
|
|
6
13
|
import { connect } from 'react-redux';
|
|
7
|
-
import styled, { css, ThemeProvider as ThemeProvider$
|
|
8
|
-
|
|
9
|
-
const ACTION_PREFIX = '@FORM2/';
|
|
10
|
-
const SET_FORM_DATA = `${ACTION_PREFIX}SET_FORM_DATA`;
|
|
11
|
-
const SET_FORM_ID = `${ACTION_PREFIX}SET_FORM_ID`;
|
|
12
|
-
const SET_CURRENT_PAGE = `${ACTION_PREFIX}SET_CURRENT_PAGE`;
|
|
13
|
-
const PAGE_BACK = `${ACTION_PREFIX}PAGE_BACK`;
|
|
14
|
-
const PAGE_FORWARD = `${ACTION_PREFIX}PAGE_FORWARD`;
|
|
15
|
-
const SET_FIELD_VALUE = `${ACTION_PREFIX}SET_FIELD_VALUE`;
|
|
16
|
-
const SET_DEFAULT_FIELD_VALUE = `${ACTION_PREFIX}SET_DEFAULT_FIELD_VALUE`;
|
|
17
|
-
const SUBMIT_FORM_FOR_VALIDATION = `${ACTION_PREFIX}SUBMIT_FORM_FOR_VALIDATION`;
|
|
18
|
-
const SUBMIT_FORM = `${ACTION_PREFIX}SUBMIT_FORM`;
|
|
19
|
-
const SUBMIT_FORM_SUCCESS = `${ACTION_PREFIX}SUBMIT_FORM_SUCCESS`;
|
|
20
|
-
const SUBMIT_FORM_ERROR = `${ACTION_PREFIX}SUBMIT_FORM_ERROR`;
|
|
21
|
-
const SET_SUBMITTING_FORM = `${ACTION_PREFIX}SET_SUBMITTING_FORM`;
|
|
22
|
-
const SET_ERROR = `${ACTION_PREFIX}SET_ERROR`;
|
|
23
|
-
const VALIDATE_FIELD = `${ACTION_PREFIX}VALIDATE_FIELD`;
|
|
24
|
-
const SET_FIELD_ERROR = `${ACTION_PREFIX}SET_FIELD_ERROR`;
|
|
25
|
-
const SET_DATE_RANGE_VALUES = `${ACTION_PREFIX}SET_DATE_RANGE_VALUES`;
|
|
26
|
-
const SET_FORM_ENTRIES = `${ACTION_PREFIX}SET_FORM_ENTRIES`;
|
|
27
|
-
const SET_SUCCESS_MESSAGE = `${ACTION_PREFIX}SET_SUCCESS_MESSAGE`;
|
|
28
|
-
const SET_CHECKBOX_VALUE = `${ACTION_PREFIX}SET_CHECKBOX_VALUE`;
|
|
14
|
+
import styled, { css, ThemeProvider as ThemeProvider$2 } from 'styled-components';
|
|
15
|
+
|
|
16
|
+
const ACTION_PREFIX$5 = '@FORM2/';
|
|
17
|
+
const SET_FORM_DATA$1 = `${ACTION_PREFIX$5}SET_FORM_DATA`;
|
|
18
|
+
const SET_FORM_ID$1 = `${ACTION_PREFIX$5}SET_FORM_ID`;
|
|
19
|
+
const SET_CURRENT_PAGE$1 = `${ACTION_PREFIX$5}SET_CURRENT_PAGE`;
|
|
20
|
+
const PAGE_BACK$1 = `${ACTION_PREFIX$5}PAGE_BACK`;
|
|
21
|
+
const PAGE_FORWARD$1 = `${ACTION_PREFIX$5}PAGE_FORWARD`;
|
|
22
|
+
const SET_FIELD_VALUE$1 = `${ACTION_PREFIX$5}SET_FIELD_VALUE`;
|
|
23
|
+
const SET_DEFAULT_FIELD_VALUE$1 = `${ACTION_PREFIX$5}SET_DEFAULT_FIELD_VALUE`;
|
|
24
|
+
const SUBMIT_FORM_FOR_VALIDATION$1 = `${ACTION_PREFIX$5}SUBMIT_FORM_FOR_VALIDATION`;
|
|
25
|
+
const SUBMIT_FORM$1 = `${ACTION_PREFIX$5}SUBMIT_FORM`;
|
|
26
|
+
const SUBMIT_FORM_SUCCESS$1 = `${ACTION_PREFIX$5}SUBMIT_FORM_SUCCESS`;
|
|
27
|
+
const SUBMIT_FORM_ERROR$1 = `${ACTION_PREFIX$5}SUBMIT_FORM_ERROR`;
|
|
28
|
+
const SET_SUBMITTING_FORM$1 = `${ACTION_PREFIX$5}SET_SUBMITTING_FORM`;
|
|
29
|
+
const SET_ERROR$1 = `${ACTION_PREFIX$5}SET_ERROR`;
|
|
30
|
+
const VALIDATE_FIELD$1 = `${ACTION_PREFIX$5}VALIDATE_FIELD`;
|
|
31
|
+
const SET_FIELD_ERROR$1 = `${ACTION_PREFIX$5}SET_FIELD_ERROR`;
|
|
32
|
+
const SET_DATE_RANGE_VALUES$1 = `${ACTION_PREFIX$5}SET_DATE_RANGE_VALUES`;
|
|
33
|
+
const SET_FORM_ENTRIES$1 = `${ACTION_PREFIX$5}SET_FORM_ENTRIES`;
|
|
34
|
+
const SET_SUCCESS_MESSAGE$1 = `${ACTION_PREFIX$5}SET_SUCCESS_MESSAGE`;
|
|
35
|
+
const SET_CHECKBOX_VALUE$1 = `${ACTION_PREFIX$5}SET_CHECKBOX_VALUE`;
|
|
36
|
+
|
|
37
|
+
const MakeFieldType$1 = field => {
|
|
38
|
+
if (!field) return null;
|
|
39
|
+
|
|
40
|
+
if (field.dataType === 'string' && field.editor && field.editor.id === 'multiline') {
|
|
41
|
+
return 'textarea';
|
|
42
|
+
} else if (field.dataType === 'string' && field.editor && field.editor.id === 'list-dropdown') {
|
|
43
|
+
return 'dropdown';
|
|
44
|
+
} else if (field.editor && field.editor.properties && field.editor.properties.readOnly || field.groupId && field.groupId === 'private') {
|
|
45
|
+
return 'hidden';
|
|
46
|
+
} else if (field.dataType === 'stringArray' || field.dataType === 'boolean') {
|
|
47
|
+
return 'checkbox';
|
|
48
|
+
} else if (field.dataType === 'string' && field.validations && field.validations.allowedValues) {
|
|
49
|
+
return 'radio';
|
|
50
|
+
} else if (field.dataType === 'integer') {
|
|
51
|
+
return 'number';
|
|
52
|
+
} else if (field.dataType === 'dateTime') {
|
|
53
|
+
return 'date';
|
|
54
|
+
} else if (field.dataFormat === 'daterange') {
|
|
55
|
+
return 'dateRange';
|
|
56
|
+
} else if (field.dataFormat === 'entry') {
|
|
57
|
+
return 'entryPicker';
|
|
58
|
+
} else {
|
|
59
|
+
return 'textfield';
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const initialSettings$1 = {
|
|
64
|
+
recaptcha: {
|
|
65
|
+
siteKey: null
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const initialStatus$1 = {
|
|
69
|
+
isLoading: false,
|
|
70
|
+
isSubmitting: false,
|
|
71
|
+
hasSuccess: false,
|
|
72
|
+
successMessage: null,
|
|
73
|
+
hasError: false
|
|
74
|
+
};
|
|
75
|
+
const initialPagingInfo$1 = {
|
|
76
|
+
pageIndex: 0,
|
|
77
|
+
pageCount: 0,
|
|
78
|
+
currentPageId: null
|
|
79
|
+
};
|
|
80
|
+
const initialFormData$1 = {
|
|
81
|
+
formId: null,
|
|
82
|
+
data: {},
|
|
83
|
+
fields: [],
|
|
84
|
+
entries: [],
|
|
85
|
+
fieldErrors: [],
|
|
86
|
+
groups: [],
|
|
87
|
+
defaultLanguage: null,
|
|
88
|
+
pagingInfo: initialPagingInfo$1,
|
|
89
|
+
status: initialStatus$1
|
|
90
|
+
};
|
|
91
|
+
let initialState$5 = {
|
|
92
|
+
settings: initialSettings$1
|
|
93
|
+
};
|
|
94
|
+
var reducer$1 = produce((state, action) => {
|
|
95
|
+
switch (action.type) {
|
|
96
|
+
case SET_FORM_ID$1:
|
|
97
|
+
{
|
|
98
|
+
const {
|
|
99
|
+
formId
|
|
100
|
+
} = action || {};
|
|
101
|
+
state[formId] = initialFormData$1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case SET_FORM_DATA$1:
|
|
106
|
+
{
|
|
107
|
+
const {
|
|
108
|
+
fields,
|
|
109
|
+
formId,
|
|
110
|
+
groups,
|
|
111
|
+
defaultLanguage
|
|
112
|
+
} = action || {};
|
|
113
|
+
fields.map(field => {
|
|
114
|
+
field.type = MakeFieldType$1(field);
|
|
115
|
+
});
|
|
116
|
+
state[formId].fields = fields;
|
|
117
|
+
state[formId].formId = formId;
|
|
118
|
+
state[formId].groups = groups;
|
|
119
|
+
state[formId].defaultLanguage = defaultLanguage;
|
|
120
|
+
state[formId].status.isSubmitting = false;
|
|
121
|
+
state[formId].status.hasSuccess = false;
|
|
122
|
+
state[formId].status.hasError = false;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
case SET_CURRENT_PAGE$1:
|
|
127
|
+
{
|
|
128
|
+
const {
|
|
129
|
+
formId,
|
|
130
|
+
pageId,
|
|
131
|
+
pageIndex,
|
|
132
|
+
pageCount
|
|
133
|
+
} = action || {};
|
|
134
|
+
state[formId].pagingInfo.currentPageId = pageId;
|
|
135
|
+
state[formId].pagingInfo.pageIndex = pageIndex;
|
|
136
|
+
state[formId].pagingInfo.pageCount = pageCount;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
case SET_FIELD_VALUE$1:
|
|
141
|
+
{
|
|
142
|
+
const {
|
|
143
|
+
formId,
|
|
144
|
+
id,
|
|
145
|
+
value
|
|
146
|
+
} = action || {};
|
|
147
|
+
state[formId].data[id] = value;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
case SET_DEFAULT_FIELD_VALUE$1:
|
|
152
|
+
{
|
|
153
|
+
const {
|
|
154
|
+
formId,
|
|
155
|
+
value
|
|
156
|
+
} = action || {};
|
|
157
|
+
state[formId].data = value;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
case SET_CHECKBOX_VALUE$1:
|
|
162
|
+
{
|
|
163
|
+
const {
|
|
164
|
+
formId,
|
|
165
|
+
id,
|
|
166
|
+
value,
|
|
167
|
+
isChecked
|
|
168
|
+
} = action || {};
|
|
169
|
+
let values = state[formId].data[id] || [];
|
|
170
|
+
if (isChecked) state[formId].data[id] = { ...values,
|
|
171
|
+
value
|
|
172
|
+
};else state[formId].data[id] = values.filter(v => v !== value);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
case SET_DATE_RANGE_VALUES$1:
|
|
177
|
+
{
|
|
178
|
+
const {
|
|
179
|
+
formId,
|
|
180
|
+
id,
|
|
181
|
+
value,
|
|
182
|
+
dateType
|
|
183
|
+
} = action || {};
|
|
184
|
+
state[formId].data[id][dateType] = value;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
case SET_FIELD_ERROR$1:
|
|
189
|
+
{
|
|
190
|
+
const {
|
|
191
|
+
formId,
|
|
192
|
+
value
|
|
193
|
+
} = action || {};
|
|
194
|
+
state[formId].fieldErrors = value;
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
case SET_SUBMITTING_FORM$1:
|
|
199
|
+
{
|
|
200
|
+
const {
|
|
201
|
+
formId,
|
|
202
|
+
isSubmitting
|
|
203
|
+
} = action || {};
|
|
204
|
+
state[formId].status.isSubmitting = isSubmitting;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
case SUBMIT_FORM_SUCCESS$1:
|
|
209
|
+
{
|
|
210
|
+
const {
|
|
211
|
+
formId
|
|
212
|
+
} = action || {};
|
|
213
|
+
state[formId].status.hasError = false;
|
|
214
|
+
state[formId].status.isSubmitting = false;
|
|
215
|
+
state[formId].status.hasSuccess = true;
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
case SET_SUCCESS_MESSAGE$1:
|
|
220
|
+
{
|
|
221
|
+
const {
|
|
222
|
+
formId,
|
|
223
|
+
message
|
|
224
|
+
} = action || {};
|
|
225
|
+
state[formId].status.successMessage = message;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case SUBMIT_FORM_ERROR$1:
|
|
230
|
+
{
|
|
231
|
+
const {
|
|
232
|
+
formId
|
|
233
|
+
} = action || {};
|
|
234
|
+
state[formId].status.hasError = true;
|
|
235
|
+
state[formId].status.isSubmitting = false;
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
case SET_FORM_ENTRIES$1:
|
|
240
|
+
{
|
|
241
|
+
const {
|
|
242
|
+
formId,
|
|
243
|
+
entries
|
|
244
|
+
} = action || {};
|
|
245
|
+
const entryObject = {};
|
|
246
|
+
entries.map(entry => {
|
|
247
|
+
if (!entry) return null;
|
|
248
|
+
entryObject[entry.id] = entry.entries;
|
|
249
|
+
return entryObject;
|
|
250
|
+
});
|
|
251
|
+
state[formId].entries = entryObject;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
case SET_ERROR$1:
|
|
256
|
+
{
|
|
257
|
+
const {
|
|
258
|
+
formId
|
|
259
|
+
} = action || {};
|
|
260
|
+
state[formId].status.hasError = true;
|
|
261
|
+
state[formId].status.isSubmitting = false;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
default:
|
|
266
|
+
return state;
|
|
267
|
+
}
|
|
268
|
+
}, initialState$5);
|
|
269
|
+
|
|
270
|
+
const action$3 = (type, payload = {}) => ({
|
|
271
|
+
type,
|
|
272
|
+
...payload
|
|
273
|
+
});
|
|
274
|
+
const getImmutableOrJS$1 = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE) => {
|
|
275
|
+
var _globalThis$immutable, _globalThis$immutable2;
|
|
276
|
+
|
|
277
|
+
// Find a fromJS function from global that is dynamically loaded in createStore
|
|
278
|
+
// or replace with a stub function for non-immutable gets
|
|
279
|
+
const fromJS = returnType === 'immutable' ? ((_globalThis$immutable = globalThis.immutable) === null || _globalThis$immutable === void 0 ? void 0 : _globalThis$immutable.fromJSOrdered) || ((_globalThis$immutable2 = globalThis.immutable) === null || _globalThis$immutable2 === void 0 ? void 0 : _globalThis$immutable2.fromJS) : v => v;
|
|
280
|
+
|
|
281
|
+
if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
|
|
282
|
+
if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
|
|
283
|
+
return fromJS(state.get(stateKey, fallbackValue));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (Array.isArray(stateKey) && state && typeof state === 'object') {
|
|
287
|
+
const result = jpath(stateKey.join('.'), state);
|
|
288
|
+
if (typeof result === 'undefined') return fallbackValue;
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const result = state && typeof state === 'object' ? state[stateKey] : undefined;
|
|
293
|
+
if (typeof result === 'undefined') return fallbackValue;
|
|
294
|
+
return result;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
function queryParams$1(search) {
|
|
298
|
+
return queryString__default.parse(typeof window != 'undefined' ? window.location.search : search);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const selectRouteEntry$3 = (state, returnType) => getImmutableOrJS$1(state, ['routing', 'entry'], {}, returnType);
|
|
302
|
+
const selectMappedEntry$1 = (state, returnType) => getImmutableOrJS$1(state, ['routing', 'mappedEntry'], null, returnType);
|
|
303
|
+
const selectSurrogateKeys$1 = state => {
|
|
304
|
+
const keys = getImmutableOrJS$1(state, ['routing', 'surrogateKeys'], [], 'js');
|
|
305
|
+
return keys.join(' ');
|
|
306
|
+
};
|
|
307
|
+
const selectCurrentHostname$1 = state => getImmutableOrJS$1(state, ['routing', 'currentHostname']);
|
|
308
|
+
const selectCurrentTreeID$1 = state => getImmutableOrJS$1(state, ['routing', 'currentHostname']);
|
|
309
|
+
const selectRouteEntryEntryId$3 = state => getImmutableOrJS$1(state, ['routing', 'entry', 'sys', 'id'], null);
|
|
310
|
+
const selectRouteEntryContentTypeId$3 = state => {
|
|
311
|
+
const entry = selectRouteEntry$3(state);
|
|
312
|
+
return getImmutableOrJS$1(entry, ['sys', 'contentTypeId'], null);
|
|
313
|
+
};
|
|
314
|
+
const selectRouteEntryLanguage$1 = state => {
|
|
315
|
+
const entry = selectRouteEntry$3(state);
|
|
316
|
+
return getImmutableOrJS$1(entry, ['sys', 'language'], null);
|
|
317
|
+
};
|
|
318
|
+
const selectRouteEntrySlug$3 = state => {
|
|
319
|
+
const entry = selectRouteEntry$3(state);
|
|
320
|
+
return getImmutableOrJS$1(entry, ['sys', 'slug'], null);
|
|
321
|
+
};
|
|
322
|
+
const selectRouteEntryID$3 = state => getImmutableOrJS$1(state, ['routing', 'entryID']);
|
|
323
|
+
const selectCurrentPath$3 = state => getImmutableOrJS$1(state, ['routing', 'currentPath']);
|
|
324
|
+
const selectCurrentLocation$1 = state => getImmutableOrJS$1(state, ['routing', 'location']);
|
|
325
|
+
const selectCurrentSearch$3 = state => getImmutableOrJS$1(state, ['routing', 'location', 'search']);
|
|
326
|
+
const selectCurrentHash$1 = state => getImmutableOrJS$1(state, ['routing', 'location', 'hash']);
|
|
327
|
+
const selectQueryStringAsObject$3 = state => queryParams$1(selectCurrentSearch$3(state));
|
|
328
|
+
const selectCurrentProject$3 = state => getImmutableOrJS$1(state, ['routing', 'currentProject']);
|
|
329
|
+
const selectIsNotFound$3 = state => getImmutableOrJS$1(state, ['routing', 'notFound']);
|
|
330
|
+
const selectCurrentAncestors$3 = state => getImmutableOrJS$1(state, ['routing', 'currentNodeAncestors'], []);
|
|
331
|
+
const selectCurrentSiblings$1 = state => getImmutableOrJS$1(state, ['routing', 'currentNodeSiblings'], []);
|
|
332
|
+
const selectCurrentNode$1 = (state, returnType) => getImmutableOrJS$1(state, ['routing', 'currentNode'], null, returnType);
|
|
333
|
+
const selectCurrentChildren$1 = state => getImmutableOrJS$1(state, ['routing', 'currentNode', 'children'], []);
|
|
334
|
+
const selectBreadcrumb$1 = state => {
|
|
335
|
+
return selectCurrentAncestors$3(state).push(selectCurrentNode$1(state));
|
|
336
|
+
};
|
|
337
|
+
const selectRouteErrorMessage$1 = state => {
|
|
338
|
+
const error = getImmutableOrJS$1(state, ['routing', 'error']);
|
|
339
|
+
return getImmutableOrJS$1(error, ['data', 'message'], getImmutableOrJS$1(error, 'statusText'));
|
|
340
|
+
};
|
|
341
|
+
const selectRouteIsError$1 = state => getImmutableOrJS$1(state, ['routing', 'isError']);
|
|
342
|
+
const selectRouteLoading$3 = state => getImmutableOrJS$1(state, ['routing', 'isLoading']);
|
|
343
|
+
const selectRouteStatusCode$1 = state => getImmutableOrJS$1(state, ['routing', 'statusCode']);
|
|
344
|
+
const selectStaticRoute$1 = state => getImmutableOrJS$1(state, ['routing', 'staticRoute']);
|
|
345
|
+
|
|
346
|
+
var routing$6 = /*#__PURE__*/Object.freeze({
|
|
347
|
+
__proto__: null,
|
|
348
|
+
selectRouteEntry: selectRouteEntry$3,
|
|
349
|
+
selectMappedEntry: selectMappedEntry$1,
|
|
350
|
+
selectSurrogateKeys: selectSurrogateKeys$1,
|
|
351
|
+
selectCurrentHostname: selectCurrentHostname$1,
|
|
352
|
+
selectCurrentTreeID: selectCurrentTreeID$1,
|
|
353
|
+
selectRouteEntryEntryId: selectRouteEntryEntryId$3,
|
|
354
|
+
selectRouteEntryContentTypeId: selectRouteEntryContentTypeId$3,
|
|
355
|
+
selectRouteEntryLanguage: selectRouteEntryLanguage$1,
|
|
356
|
+
selectRouteEntrySlug: selectRouteEntrySlug$3,
|
|
357
|
+
selectRouteEntryID: selectRouteEntryID$3,
|
|
358
|
+
selectCurrentPath: selectCurrentPath$3,
|
|
359
|
+
selectCurrentLocation: selectCurrentLocation$1,
|
|
360
|
+
selectCurrentSearch: selectCurrentSearch$3,
|
|
361
|
+
selectCurrentHash: selectCurrentHash$1,
|
|
362
|
+
selectQueryStringAsObject: selectQueryStringAsObject$3,
|
|
363
|
+
selectCurrentProject: selectCurrentProject$3,
|
|
364
|
+
selectIsNotFound: selectIsNotFound$3,
|
|
365
|
+
selectCurrentAncestors: selectCurrentAncestors$3,
|
|
366
|
+
selectCurrentSiblings: selectCurrentSiblings$1,
|
|
367
|
+
selectCurrentNode: selectCurrentNode$1,
|
|
368
|
+
selectCurrentChildren: selectCurrentChildren$1,
|
|
369
|
+
selectBreadcrumb: selectBreadcrumb$1,
|
|
370
|
+
selectRouteErrorMessage: selectRouteErrorMessage$1,
|
|
371
|
+
selectRouteIsError: selectRouteIsError$1,
|
|
372
|
+
selectRouteLoading: selectRouteLoading$3,
|
|
373
|
+
selectRouteStatusCode: selectRouteStatusCode$1,
|
|
374
|
+
selectStaticRoute: selectStaticRoute$1
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
const ROUTING_PREFIX$1 = '@ROUTING/';
|
|
378
|
+
const GET_ENTRY$1 = `${ROUTING_PREFIX$1}_GET_ENTRY`;
|
|
379
|
+
const SET_ENTRY$1 = `${ROUTING_PREFIX$1}_SET_ENTRY`;
|
|
380
|
+
const SET_NODE$1 = `${ROUTING_PREFIX$1}_SET_NODE`;
|
|
381
|
+
const SET_ANCESTORS$1 = `${ROUTING_PREFIX$1}_SET_ANCESTORS`;
|
|
382
|
+
const SET_SIBLINGS$1 = `${ROUTING_PREFIX$1}_SET_SIBLINGS`;
|
|
383
|
+
const SET_ENTRY_ID$1 = `${ROUTING_PREFIX$1}_SET_ENTRY_ID`;
|
|
384
|
+
const SET_SURROGATE_KEYS$1 = `${ROUTING_PREFIX$1}_SET_SURROGATE_KEYS`;
|
|
385
|
+
const SET_NAVIGATION_NOT_FOUND$1 = `${ROUTING_PREFIX$1}_SET_NOT_FOUND`;
|
|
386
|
+
const SET_NAVIGATION_PATH$1 = `${ROUTING_PREFIX$1}_SET_NAVIGATION_PATH`;
|
|
387
|
+
const SET_TARGET_PROJECT$1 = `${ROUTING_PREFIX$1}_SET_TARGET_PROJECT`;
|
|
388
|
+
const SET_ROUTE$1 = `${ROUTING_PREFIX$1}_SET_ROUTE`;
|
|
389
|
+
const UPDATE_LOADING_STATE$1 = `${ROUTING_PREFIX$1}_UPDATE_LOADING_STATE`;
|
|
390
|
+
|
|
391
|
+
var routing$1$1 = /*#__PURE__*/Object.freeze({
|
|
392
|
+
__proto__: null,
|
|
393
|
+
GET_ENTRY: GET_ENTRY$1,
|
|
394
|
+
SET_ENTRY: SET_ENTRY$1,
|
|
395
|
+
SET_NODE: SET_NODE$1,
|
|
396
|
+
SET_ANCESTORS: SET_ANCESTORS$1,
|
|
397
|
+
SET_SIBLINGS: SET_SIBLINGS$1,
|
|
398
|
+
SET_ENTRY_ID: SET_ENTRY_ID$1,
|
|
399
|
+
SET_SURROGATE_KEYS: SET_SURROGATE_KEYS$1,
|
|
400
|
+
SET_NAVIGATION_NOT_FOUND: SET_NAVIGATION_NOT_FOUND$1,
|
|
401
|
+
SET_NAVIGATION_PATH: SET_NAVIGATION_PATH$1,
|
|
402
|
+
SET_TARGET_PROJECT: SET_TARGET_PROJECT$1,
|
|
403
|
+
SET_ROUTE: SET_ROUTE$1,
|
|
404
|
+
UPDATE_LOADING_STATE: UPDATE_LOADING_STATE$1
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const setNotFound$1 = notFound => action$3(SET_NAVIGATION_NOT_FOUND$1, {
|
|
408
|
+
notFound
|
|
409
|
+
});
|
|
410
|
+
const setNavigationPath$1 = (path, location, staticRoute, withEvents, statePath, routes) => action$3(SET_NAVIGATION_PATH$1, {
|
|
411
|
+
path,
|
|
412
|
+
location,
|
|
413
|
+
staticRoute,
|
|
414
|
+
withEvents,
|
|
415
|
+
statePath,
|
|
416
|
+
routes
|
|
417
|
+
});
|
|
418
|
+
const setCurrentProject$1 = (project, allowedGroups, hostname) => action$3(SET_TARGET_PROJECT$1, {
|
|
419
|
+
project,
|
|
420
|
+
allowedGroups,
|
|
421
|
+
hostname
|
|
422
|
+
});
|
|
423
|
+
const setRoute$1 = (path, state) => action$3(SET_ROUTE$1, {
|
|
424
|
+
path,
|
|
425
|
+
state
|
|
426
|
+
});
|
|
427
|
+
const setRouteEntry$1 = entry => action$3(SET_ENTRY$1, {
|
|
428
|
+
entry
|
|
429
|
+
});
|
|
430
|
+
const setSurrogateKeys$1 = (keys, url) => action$3(SET_SURROGATE_KEYS$1, {
|
|
431
|
+
keys,
|
|
432
|
+
url
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
var routing$5 = /*#__PURE__*/Object.freeze({
|
|
436
|
+
__proto__: null,
|
|
437
|
+
setNotFound: setNotFound$1,
|
|
438
|
+
setNavigationPath: setNavigationPath$1,
|
|
439
|
+
setCurrentProject: setCurrentProject$1,
|
|
440
|
+
setRoute: setRoute$1,
|
|
441
|
+
setRouteEntry: setRouteEntry$1,
|
|
442
|
+
setSurrogateKeys: setSurrogateKeys$1
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const ACTION_PREFIX$4 = '@USER/';
|
|
446
|
+
const SET_AUTHENTICATION_STATE$1 = `${ACTION_PREFIX$4}SET_AUTHENTICATION_STATE`;
|
|
447
|
+
const LOGIN_USER$1 = `${ACTION_PREFIX$4}LOGIN_USER`;
|
|
448
|
+
const LOGOUT_USER$1 = `${ACTION_PREFIX$4}LOGOUT_USER`;
|
|
449
|
+
const REGISTER_USER$1 = `${ACTION_PREFIX$4}REGISTER_USER`;
|
|
450
|
+
const REGISTER_USER_SUCCESS$1 = `${ACTION_PREFIX$4}REGISTER_USER_SUCCESS`;
|
|
451
|
+
const REGISTER_USER_FAILED$1 = `${ACTION_PREFIX$4}REGISTER_USER_FAILED`;
|
|
452
|
+
const REQUEST_USER_PASSWORD_RESET_SENDING$1 = `${ACTION_PREFIX$4}REQUEST_USER_PASSWORD_RESET_SENDING`;
|
|
453
|
+
const REQUEST_USER_PASSWORD_RESET_SUCCESS$1 = `${ACTION_PREFIX$4}REQUEST_USER_PASSWORD_RESET_SUCCESS`;
|
|
454
|
+
const REQUEST_USER_PASSWORD_RESET_ERROR$1 = `${ACTION_PREFIX$4}REQUEST_USER_PASSWORD_RESET_ERROR`;
|
|
455
|
+
const RESET_USER_PASSWORD_SENDING$1 = `${ACTION_PREFIX$4}RESET_USER_PASSWORD_SENDING`;
|
|
456
|
+
const RESET_USER_PASSWORD_SUCCESS$1 = `${ACTION_PREFIX$4}RESET_USER_PASSWORD_SUCCESS`;
|
|
457
|
+
const RESET_USER_PASSWORD_ERROR$1 = `${ACTION_PREFIX$4}RESET_USER_PASSWORD_ERROR`;
|
|
458
|
+
const CHANGE_USER_PASSWORD_SENDING$1 = `${ACTION_PREFIX$4}CHANGE_USER_PASSWORD_SENDING`;
|
|
459
|
+
const CHANGE_USER_PASSWORD_SUCCESS$1 = `${ACTION_PREFIX$4}CHANGE_USER_PASSWORD_SUCCESS`;
|
|
460
|
+
const CHANGE_USER_PASSWORD_ERROR$1 = `${ACTION_PREFIX$4}CHANGE_USER_PASSWORD_ERROR`;
|
|
461
|
+
|
|
462
|
+
const defaultAuthenticationState$1 = {
|
|
463
|
+
clientCredentials: null,
|
|
464
|
+
errorMessage: null,
|
|
465
|
+
isAuthenticated: false,
|
|
466
|
+
isAuthenticationError: false,
|
|
467
|
+
isError: false,
|
|
468
|
+
isLoading: false
|
|
469
|
+
};
|
|
470
|
+
const defaultPasswordResetRequestValues$1 = {
|
|
471
|
+
isSending: false,
|
|
472
|
+
sent: false,
|
|
473
|
+
error: null
|
|
474
|
+
};
|
|
475
|
+
const defaultResetPasswordValues$1 = {
|
|
476
|
+
isSending: false,
|
|
477
|
+
sent: false,
|
|
478
|
+
error: null
|
|
479
|
+
};
|
|
480
|
+
const defaultChangePasswordValues$1 = {
|
|
481
|
+
isSending: false,
|
|
482
|
+
sent: false,
|
|
483
|
+
error: null
|
|
484
|
+
};
|
|
485
|
+
const defaultRegistrationValues$1 = {
|
|
486
|
+
isLoading: false,
|
|
487
|
+
success: false,
|
|
488
|
+
error: null
|
|
489
|
+
};
|
|
490
|
+
const initialUserState$1 = {
|
|
491
|
+
authenticationState: defaultAuthenticationState$1,
|
|
492
|
+
passwordResetRequest: defaultPasswordResetRequestValues$1,
|
|
493
|
+
resetPassword: defaultResetPasswordValues$1,
|
|
494
|
+
changePassword: defaultChangePasswordValues$1,
|
|
495
|
+
groups: []
|
|
496
|
+
};
|
|
497
|
+
produce((state, action) => {
|
|
498
|
+
switch (action.type) {
|
|
499
|
+
case LOGOUT_USER$1:
|
|
500
|
+
{
|
|
501
|
+
return initialUserState$1;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
case LOGIN_USER$1:
|
|
505
|
+
case SET_AUTHENTICATION_STATE$1:
|
|
506
|
+
{
|
|
507
|
+
var _state, _state$authentication;
|
|
508
|
+
|
|
509
|
+
if (!action.authenticationState) {
|
|
510
|
+
action.authenticationState = defaultAuthenticationState$1;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const {
|
|
514
|
+
authenticationState: {
|
|
515
|
+
clientCredentials = null,
|
|
516
|
+
errorMessage = null,
|
|
517
|
+
isAuthenticated,
|
|
518
|
+
isAuthenticationError = false,
|
|
519
|
+
isError = false,
|
|
520
|
+
isLoading = action.type === LOGIN_USER$1
|
|
521
|
+
},
|
|
522
|
+
user
|
|
523
|
+
} = action;
|
|
524
|
+
|
|
525
|
+
if (user) {
|
|
526
|
+
user.name = `${user.firstName}${user.lastName ? ` ${user.lastName}` : ''}` || null;
|
|
527
|
+
user.isZengentiStaff = user.email.includes('@zengenti.com');
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
state = { ...initialUserState$1,
|
|
531
|
+
...(user || state),
|
|
532
|
+
authenticationState: {
|
|
533
|
+
clientCredentials,
|
|
534
|
+
errorMessage,
|
|
535
|
+
isAuthenticated: isAuthenticated || ((_state = state) === null || _state === void 0 ? void 0 : (_state$authentication = _state.authenticationState) === null || _state$authentication === void 0 ? void 0 : _state$authentication.isAuthenticated),
|
|
536
|
+
isAuthenticationError,
|
|
537
|
+
isError,
|
|
538
|
+
isLoading
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
return state;
|
|
542
|
+
}
|
|
543
|
+
// REGISTER_USER is the trigger to set the user.registration initial state
|
|
544
|
+
// and will set user.registration.isLoading to true
|
|
545
|
+
// REGISTER_USER_FAILED will unset user.registration.isLoading and will set
|
|
546
|
+
// the value in user.registration.error
|
|
547
|
+
// REGISTER_USER_SUCCESS will unset user.registration.isLoading and will
|
|
548
|
+
// set user.registration to the created user from the api response
|
|
549
|
+
|
|
550
|
+
case REGISTER_USER$1:
|
|
551
|
+
case REGISTER_USER_FAILED$1:
|
|
552
|
+
case REGISTER_USER_SUCCESS$1:
|
|
553
|
+
{
|
|
554
|
+
const {
|
|
555
|
+
error,
|
|
556
|
+
user
|
|
557
|
+
} = action; // Set registration object from the supplied action.user
|
|
558
|
+
// so we can call these values back later
|
|
559
|
+
|
|
560
|
+
state.registration = user || state.registration || defaultRegistrationValues$1; // Set registration flags so the UI can track the status
|
|
561
|
+
|
|
562
|
+
state.registration.success = action.type === REGISTER_USER_SUCCESS$1;
|
|
563
|
+
state.registration.error = error || false;
|
|
564
|
+
state.registration.isLoading = action.type === REGISTER_USER$1;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
case REQUEST_USER_PASSWORD_RESET_SENDING$1:
|
|
569
|
+
state.passwordResetRequest = defaultPasswordResetRequestValues$1;
|
|
570
|
+
state.passwordResetRequest.isSending = true;
|
|
571
|
+
return;
|
|
572
|
+
|
|
573
|
+
case REQUEST_USER_PASSWORD_RESET_SUCCESS$1:
|
|
574
|
+
if (state.passwordResetRequest) {
|
|
575
|
+
state.passwordResetRequest.isSending = false;
|
|
576
|
+
state.passwordResetRequest.sent = true;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return;
|
|
580
|
+
|
|
581
|
+
case REQUEST_USER_PASSWORD_RESET_ERROR$1:
|
|
582
|
+
if (state.passwordResetRequest) {
|
|
583
|
+
state.passwordResetRequest.isSending = false;
|
|
584
|
+
state.passwordResetRequest.error = action.error;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
return;
|
|
588
|
+
|
|
589
|
+
case RESET_USER_PASSWORD_SENDING$1:
|
|
590
|
+
if (state.resetPassword) {
|
|
591
|
+
state.resetPassword.isSending = true;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return;
|
|
595
|
+
|
|
596
|
+
case RESET_USER_PASSWORD_SUCCESS$1:
|
|
597
|
+
if (state.resetPassword) {
|
|
598
|
+
state.resetPassword.isSending = false;
|
|
599
|
+
state.resetPassword.sent = true;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return;
|
|
603
|
+
|
|
604
|
+
case RESET_USER_PASSWORD_ERROR$1:
|
|
605
|
+
if (state.resetPassword) {
|
|
606
|
+
state.resetPassword.isSending = false;
|
|
607
|
+
state.resetPassword.error = action.error;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return;
|
|
611
|
+
|
|
612
|
+
case CHANGE_USER_PASSWORD_SENDING$1:
|
|
613
|
+
if (state.changePassword) {
|
|
614
|
+
state.changePassword.isSending = true;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return;
|
|
618
|
+
|
|
619
|
+
case CHANGE_USER_PASSWORD_SUCCESS$1:
|
|
620
|
+
if (state.changePassword) {
|
|
621
|
+
state.changePassword.isSending = false;
|
|
622
|
+
state.changePassword.sent = true;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return;
|
|
626
|
+
|
|
627
|
+
case CHANGE_USER_PASSWORD_ERROR$1:
|
|
628
|
+
if (state.changePassword) {
|
|
629
|
+
state.changePassword.isSending = false;
|
|
630
|
+
state.changePassword.error = action.error;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return;
|
|
634
|
+
|
|
635
|
+
default:
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
}, initialUserState$1);
|
|
639
|
+
|
|
640
|
+
const ACTION_PREFIX$3 = '@NAVIGATION/';
|
|
641
|
+
const GET_NODE_TREE$1 = `${ACTION_PREFIX$3}_GET_NODE_TREE`;
|
|
642
|
+
const SET_NODE_TREE$1 = `${ACTION_PREFIX$3}_SET_NODE_TREE`;
|
|
643
|
+
const GET_NODE_TREE_ERROR$1 = `${ACTION_PREFIX$3}_GET_NODE_TREE_ERROR`;
|
|
644
|
+
|
|
645
|
+
var navigation$1$3 = /*#__PURE__*/Object.freeze({
|
|
646
|
+
__proto__: null,
|
|
647
|
+
GET_NODE_TREE: GET_NODE_TREE$1,
|
|
648
|
+
SET_NODE_TREE: SET_NODE_TREE$1,
|
|
649
|
+
GET_NODE_TREE_ERROR: GET_NODE_TREE_ERROR$1
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
const initialState$2$1 = {
|
|
653
|
+
root: null,
|
|
654
|
+
isError: false,
|
|
655
|
+
isReady: false
|
|
656
|
+
};
|
|
657
|
+
produce((state, action) => {
|
|
658
|
+
switch (action.type) {
|
|
659
|
+
case SET_NODE_TREE$1:
|
|
660
|
+
{
|
|
661
|
+
state.root = action.nodes;
|
|
662
|
+
state.isReady = true;
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
case GET_NODE_TREE_ERROR$1:
|
|
667
|
+
{
|
|
668
|
+
state.isError = true;
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
default:
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
}, initialState$2$1);
|
|
676
|
+
|
|
677
|
+
const combineMerge$1 = (target, source, options) => {
|
|
678
|
+
const destination = target.slice();
|
|
679
|
+
source.forEach((item, index) => {
|
|
680
|
+
if (typeof destination[index] === 'undefined') {
|
|
681
|
+
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
|
682
|
+
} else if (options.isMergeableObject(item)) {
|
|
683
|
+
destination[index] = merge(target[index], item, options);
|
|
684
|
+
} else if (target.indexOf(item) === -1) {
|
|
685
|
+
destination.push(item);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
return destination;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
const initialState$1$1 = {
|
|
692
|
+
currentHostname: null,
|
|
693
|
+
currentPath: '/',
|
|
694
|
+
currentNode: {},
|
|
695
|
+
currentNodeAncestors: [],
|
|
696
|
+
currentProject: 'unknown',
|
|
697
|
+
entryID: null,
|
|
698
|
+
entry: null,
|
|
699
|
+
error: undefined,
|
|
700
|
+
isError: false,
|
|
701
|
+
isLoading: false,
|
|
702
|
+
location: {},
|
|
703
|
+
mappedEntry: null,
|
|
704
|
+
notFound: false,
|
|
705
|
+
staticRoute: null,
|
|
706
|
+
statusCode: 200
|
|
707
|
+
};
|
|
708
|
+
produce((state, action) => {
|
|
709
|
+
switch (action.type) {
|
|
710
|
+
case SET_ANCESTORS$1:
|
|
711
|
+
{
|
|
712
|
+
state.currentNodeAncestors = action.ancestors;
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
case SET_ENTRY$1:
|
|
717
|
+
{
|
|
718
|
+
const {
|
|
719
|
+
entry,
|
|
720
|
+
error,
|
|
721
|
+
mappedEntry,
|
|
722
|
+
node = {},
|
|
723
|
+
isError = false,
|
|
724
|
+
isLoading = false,
|
|
725
|
+
notFound = false,
|
|
726
|
+
statusCode
|
|
727
|
+
} = action;
|
|
728
|
+
let defaultStatus = 200;
|
|
729
|
+
if (notFound === true && isError === false) defaultStatus = 404;else if (isError === true) defaultStatus = statusCode || 500;
|
|
730
|
+
|
|
731
|
+
if (!entry) {
|
|
732
|
+
state.entryID = null;
|
|
733
|
+
state.entry = null;
|
|
734
|
+
state.error = error;
|
|
735
|
+
state.mappedEntry = null;
|
|
736
|
+
state.isError = isError;
|
|
737
|
+
state.isLoading = isLoading;
|
|
738
|
+
state.notFound = notFound;
|
|
739
|
+
state.statusCode = statusCode || defaultStatus;
|
|
740
|
+
} else {
|
|
741
|
+
state.entryID = action.id;
|
|
742
|
+
state.entry = entry;
|
|
743
|
+
state.error = error;
|
|
744
|
+
state.isError = isError;
|
|
745
|
+
state.isLoading = isLoading;
|
|
746
|
+
state.notFound = notFound;
|
|
747
|
+
state.statusCode = statusCode || defaultStatus;
|
|
748
|
+
|
|
749
|
+
if (mappedEntry && Object.keys(mappedEntry).length > 0) {
|
|
750
|
+
state.mappedEntry = mappedEntry;
|
|
751
|
+
state.entry = {
|
|
752
|
+
sys: entry.sys
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (!node) {
|
|
758
|
+
state.currentNode = null;
|
|
759
|
+
} else {
|
|
760
|
+
// On Set Node, we reset all dependants.
|
|
761
|
+
state.currentNode = node; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
762
|
+
|
|
763
|
+
const {
|
|
764
|
+
entry,
|
|
765
|
+
...nodeWithoutEntry
|
|
766
|
+
} = node; // We have the entry stored elsewhere, so lets not keep it twice.
|
|
767
|
+
|
|
768
|
+
state.currentNode = nodeWithoutEntry;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
case UPDATE_LOADING_STATE$1:
|
|
775
|
+
{
|
|
776
|
+
state.isLoading = action.isLoading;
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
case SET_NAVIGATION_PATH$1:
|
|
781
|
+
{
|
|
782
|
+
let staticRoute = {};
|
|
783
|
+
|
|
784
|
+
if (action.staticRoute) {
|
|
785
|
+
staticRoute = { ...action.staticRoute
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (action.path) {
|
|
790
|
+
var _state$entry, _state$entry$sys;
|
|
791
|
+
|
|
792
|
+
// Don't run a path update on initial load as we allready should have it in redux
|
|
793
|
+
const entryUri = state === null || state === void 0 ? void 0 : (_state$entry = state.entry) === null || _state$entry === void 0 ? void 0 : (_state$entry$sys = _state$entry.sys) === null || _state$entry$sys === void 0 ? void 0 : _state$entry$sys.uri;
|
|
794
|
+
|
|
795
|
+
if (entryUri !== action.path) {
|
|
796
|
+
state.currentPath = action.path;
|
|
797
|
+
state.location = action.location;
|
|
798
|
+
state.staticRoute = { ...staticRoute,
|
|
799
|
+
route: { ...staticRoute.route,
|
|
800
|
+
component: null
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
state.isLoading = typeof window !== 'undefined';
|
|
804
|
+
} else {
|
|
805
|
+
state.location = action.location;
|
|
806
|
+
state.staticRoute = { ...staticRoute,
|
|
807
|
+
route: { ...staticRoute.route,
|
|
808
|
+
component: null
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
case SET_ROUTE$1:
|
|
818
|
+
{
|
|
819
|
+
state.nextPath = action.path;
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
case SET_SIBLINGS$1:
|
|
824
|
+
{
|
|
825
|
+
// Can be null in some cases like the homepage.
|
|
826
|
+
let currentNodeSiblingParent = null;
|
|
827
|
+
|
|
828
|
+
if (action.siblings && action.siblings.length > 0) {
|
|
829
|
+
currentNodeSiblingParent = action.siblings[0].parentId;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
state.currentNodeSiblings = action.siblings;
|
|
833
|
+
state.currentNodeSiblingsParent = currentNodeSiblingParent;
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
case SET_SURROGATE_KEYS$1:
|
|
838
|
+
{
|
|
839
|
+
// console.info(`SET_SURROGATE_KEYS: '${action.url}' keys: ${action.keys}`);
|
|
840
|
+
state.surrogateKeys = merge(state.surrogateKeys, (action.keys || '').split(' '), {
|
|
841
|
+
arrayMerge: combineMerge$1
|
|
842
|
+
});
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
case SET_TARGET_PROJECT$1:
|
|
847
|
+
{
|
|
848
|
+
state.currentProject = action.project;
|
|
849
|
+
state.allowedGroups = action.allowedGroups;
|
|
850
|
+
state.currentHostname = action.hostname;
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
default:
|
|
855
|
+
return state;
|
|
856
|
+
}
|
|
857
|
+
}, initialState$1$1);
|
|
858
|
+
|
|
859
|
+
const VERSION_PREFIX$1 = '@VERSION/';
|
|
860
|
+
const SET_VERSION$1 = `${VERSION_PREFIX$1}SET_VERSION`;
|
|
861
|
+
const SET_VERSION_STATUS$1 = `${VERSION_PREFIX$1}SET_VERSION_STATUS`;
|
|
862
|
+
|
|
863
|
+
var version$1$1 = /*#__PURE__*/Object.freeze({
|
|
864
|
+
__proto__: null,
|
|
865
|
+
SET_VERSION: SET_VERSION$1,
|
|
866
|
+
SET_VERSION_STATUS: SET_VERSION_STATUS$1
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
const initialState$4 = {
|
|
870
|
+
commitRef: null,
|
|
871
|
+
buildNo: null,
|
|
872
|
+
contensisVersionStatus: 'published'
|
|
873
|
+
};
|
|
874
|
+
produce((state, action) => {
|
|
875
|
+
switch (action.type) {
|
|
876
|
+
case SET_VERSION_STATUS$1:
|
|
877
|
+
{
|
|
878
|
+
state.contensisVersionStatus = action.status;
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
case SET_VERSION$1:
|
|
883
|
+
{
|
|
884
|
+
state.commitRef = action.commitRef;
|
|
885
|
+
state.buildNo = action.buildNo;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
default:
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
}, initialState$4);
|
|
893
|
+
|
|
894
|
+
const hasNavigationTree$1 = state => getImmutableOrJS$1(state, ['navigation', 'isReady']);
|
|
895
|
+
const selectNavigationRoot$1 = state => getImmutableOrJS$1(state, ['navigation', 'root']);
|
|
896
|
+
const selectNavigationChildren$1 = state => getImmutableOrJS$1(state, ['navigation', 'root', 'children']);
|
|
897
|
+
const selectNavigationDepends$1 = () => [];
|
|
898
|
+
|
|
899
|
+
var navigation$2 = /*#__PURE__*/Object.freeze({
|
|
900
|
+
__proto__: null,
|
|
901
|
+
hasNavigationTree: hasNavigationTree$1,
|
|
902
|
+
selectNavigationRoot: selectNavigationRoot$1,
|
|
903
|
+
selectNavigationChildren: selectNavigationChildren$1,
|
|
904
|
+
selectNavigationDepends: selectNavigationDepends$1
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
const setVersion$1 = (commitRef, buildNo) => action$3(SET_VERSION$1, {
|
|
908
|
+
commitRef,
|
|
909
|
+
buildNo
|
|
910
|
+
});
|
|
911
|
+
const setVersionStatus$1 = status => action$3(SET_VERSION_STATUS$1, {
|
|
912
|
+
status
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
var version$4 = /*#__PURE__*/Object.freeze({
|
|
916
|
+
__proto__: null,
|
|
917
|
+
setVersion: setVersion$1,
|
|
918
|
+
setVersionStatus: setVersionStatus$1
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
const ACTION_PREFIX$2 = '@FORM2/';
|
|
922
|
+
const SET_FORM_DATA = `${ACTION_PREFIX$2}SET_FORM_DATA`;
|
|
923
|
+
const SET_FORM_ID = `${ACTION_PREFIX$2}SET_FORM_ID`;
|
|
924
|
+
const SET_CURRENT_PAGE = `${ACTION_PREFIX$2}SET_CURRENT_PAGE`;
|
|
925
|
+
const PAGE_BACK = `${ACTION_PREFIX$2}PAGE_BACK`;
|
|
926
|
+
const PAGE_FORWARD = `${ACTION_PREFIX$2}PAGE_FORWARD`;
|
|
927
|
+
const SET_FIELD_VALUE = `${ACTION_PREFIX$2}SET_FIELD_VALUE`;
|
|
928
|
+
const SET_DEFAULT_FIELD_VALUE = `${ACTION_PREFIX$2}SET_DEFAULT_FIELD_VALUE`;
|
|
929
|
+
const SUBMIT_FORM_FOR_VALIDATION = `${ACTION_PREFIX$2}SUBMIT_FORM_FOR_VALIDATION`;
|
|
930
|
+
const SUBMIT_FORM = `${ACTION_PREFIX$2}SUBMIT_FORM`;
|
|
931
|
+
const SUBMIT_FORM_SUCCESS = `${ACTION_PREFIX$2}SUBMIT_FORM_SUCCESS`;
|
|
932
|
+
const SUBMIT_FORM_ERROR = `${ACTION_PREFIX$2}SUBMIT_FORM_ERROR`;
|
|
933
|
+
const SET_SUBMITTING_FORM = `${ACTION_PREFIX$2}SET_SUBMITTING_FORM`;
|
|
934
|
+
const SET_ERROR = `${ACTION_PREFIX$2}SET_ERROR`;
|
|
935
|
+
const VALIDATE_FIELD = `${ACTION_PREFIX$2}VALIDATE_FIELD`;
|
|
936
|
+
const VALIDATE_PAGE = `${ACTION_PREFIX$2}VALIDATE_PAGE`;
|
|
937
|
+
const SET_FIELD_ERROR = `${ACTION_PREFIX$2}SET_FIELD_ERROR`;
|
|
938
|
+
const SET_DATE_RANGE_VALUES = `${ACTION_PREFIX$2}SET_DATE_RANGE_VALUES`;
|
|
939
|
+
const SET_FORM_ENTRIES = `${ACTION_PREFIX$2}SET_FORM_ENTRIES`;
|
|
940
|
+
const SET_SUCCESS_MESSAGE = `${ACTION_PREFIX$2}SET_SUCCESS_MESSAGE`;
|
|
941
|
+
const SET_CHECKBOX_VALUE = `${ACTION_PREFIX$2}SET_CHECKBOX_VALUE`;
|
|
942
|
+
|
|
943
|
+
var types$1 = /*#__PURE__*/Object.freeze({
|
|
944
|
+
__proto__: null,
|
|
945
|
+
SET_FORM_DATA: SET_FORM_DATA,
|
|
946
|
+
SET_FORM_ID: SET_FORM_ID,
|
|
947
|
+
SET_CURRENT_PAGE: SET_CURRENT_PAGE,
|
|
948
|
+
PAGE_BACK: PAGE_BACK,
|
|
949
|
+
PAGE_FORWARD: PAGE_FORWARD,
|
|
950
|
+
SET_FIELD_VALUE: SET_FIELD_VALUE,
|
|
951
|
+
SET_DEFAULT_FIELD_VALUE: SET_DEFAULT_FIELD_VALUE,
|
|
952
|
+
SUBMIT_FORM_FOR_VALIDATION: SUBMIT_FORM_FOR_VALIDATION,
|
|
953
|
+
SUBMIT_FORM: SUBMIT_FORM,
|
|
954
|
+
SUBMIT_FORM_SUCCESS: SUBMIT_FORM_SUCCESS,
|
|
955
|
+
SUBMIT_FORM_ERROR: SUBMIT_FORM_ERROR,
|
|
956
|
+
SET_SUBMITTING_FORM: SET_SUBMITTING_FORM,
|
|
957
|
+
SET_ERROR: SET_ERROR,
|
|
958
|
+
VALIDATE_FIELD: VALIDATE_FIELD,
|
|
959
|
+
VALIDATE_PAGE: VALIDATE_PAGE,
|
|
960
|
+
SET_FIELD_ERROR: SET_FIELD_ERROR,
|
|
961
|
+
SET_DATE_RANGE_VALUES: SET_DATE_RANGE_VALUES,
|
|
962
|
+
SET_FORM_ENTRIES: SET_FORM_ENTRIES,
|
|
963
|
+
SET_SUCCESS_MESSAGE: SET_SUCCESS_MESSAGE,
|
|
964
|
+
SET_CHECKBOX_VALUE: SET_CHECKBOX_VALUE
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
const MakeFieldType = field => {
|
|
968
|
+
if (!field) return null;
|
|
969
|
+
|
|
970
|
+
if (field.dataType === 'string' && field.editor && field.editor.id === 'multiline') {
|
|
971
|
+
return 'textarea';
|
|
972
|
+
} else if (field.dataType === 'string' && field.editor && field.editor.id === 'list-dropdown') {
|
|
973
|
+
return 'dropdown';
|
|
974
|
+
} else if (field.editor && field.editor.properties && field.editor.properties.readOnly || field.groupId && field.groupId === 'private') {
|
|
975
|
+
return 'hidden';
|
|
976
|
+
} else if (field.dataType === 'stringArray' || field.dataType === 'boolean') {
|
|
977
|
+
return 'checkbox';
|
|
978
|
+
} else if (field.dataType === 'string' && field.validations && field.validations.allowedValues) {
|
|
979
|
+
return 'radio';
|
|
980
|
+
} else if (field.dataType === 'integer') {
|
|
981
|
+
return 'number';
|
|
982
|
+
} else if (field.dataType === 'dateTime') {
|
|
983
|
+
return 'date';
|
|
984
|
+
} else if (field.dataFormat === 'daterange') {
|
|
985
|
+
return 'dateRange';
|
|
986
|
+
} else if (field.dataFormat === 'entry') {
|
|
987
|
+
return 'entryPicker';
|
|
988
|
+
} else {
|
|
989
|
+
return 'textfield';
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
|
|
993
|
+
const initialSettings = {
|
|
994
|
+
recaptcha: {
|
|
995
|
+
siteKey: null
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
const initialStatus = {
|
|
999
|
+
isLoading: false,
|
|
1000
|
+
isSubmitting: false,
|
|
1001
|
+
hasSuccess: false,
|
|
1002
|
+
successMessage: null,
|
|
1003
|
+
hasError: false
|
|
1004
|
+
};
|
|
1005
|
+
const initialPagingInfo = {
|
|
1006
|
+
pageIndex: 0,
|
|
1007
|
+
pageCount: 0,
|
|
1008
|
+
currentPageId: null
|
|
1009
|
+
};
|
|
1010
|
+
const initialFormData = {
|
|
1011
|
+
formId: null,
|
|
1012
|
+
data: {},
|
|
1013
|
+
fields: [],
|
|
1014
|
+
entries: [],
|
|
1015
|
+
fieldErrors: [],
|
|
1016
|
+
groups: [],
|
|
1017
|
+
defaultLanguage: null,
|
|
1018
|
+
pagingInfo: initialPagingInfo,
|
|
1019
|
+
status: initialStatus
|
|
1020
|
+
};
|
|
1021
|
+
let initialState$3 = {
|
|
1022
|
+
settings: initialSettings
|
|
1023
|
+
};
|
|
1024
|
+
var reducer = produce((state, action) => {
|
|
1025
|
+
switch (action.type) {
|
|
1026
|
+
case SET_FORM_ID:
|
|
1027
|
+
{
|
|
1028
|
+
const {
|
|
1029
|
+
formId
|
|
1030
|
+
} = action || {};
|
|
1031
|
+
state[formId] = initialFormData;
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
case SET_FORM_DATA:
|
|
1036
|
+
{
|
|
1037
|
+
const {
|
|
1038
|
+
fields,
|
|
1039
|
+
formId,
|
|
1040
|
+
groups,
|
|
1041
|
+
defaultLanguage
|
|
1042
|
+
} = action || {};
|
|
1043
|
+
fields.map(field => {
|
|
1044
|
+
field.type = MakeFieldType(field);
|
|
1045
|
+
});
|
|
1046
|
+
state[formId].fields = fields;
|
|
1047
|
+
state[formId].formId = formId;
|
|
1048
|
+
state[formId].groups = groups;
|
|
1049
|
+
state[formId].defaultLanguage = defaultLanguage;
|
|
1050
|
+
state[formId].status.isSubmitting = false;
|
|
1051
|
+
state[formId].status.hasSuccess = false;
|
|
1052
|
+
state[formId].status.hasError = false;
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
case SET_CURRENT_PAGE:
|
|
1057
|
+
{
|
|
1058
|
+
const {
|
|
1059
|
+
formId,
|
|
1060
|
+
pageId,
|
|
1061
|
+
pageIndex,
|
|
1062
|
+
pageCount
|
|
1063
|
+
} = action || {};
|
|
1064
|
+
state[formId].pagingInfo.currentPageId = pageId;
|
|
1065
|
+
state[formId].pagingInfo.pageIndex = pageIndex;
|
|
1066
|
+
state[formId].pagingInfo.pageCount = pageCount;
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
case SET_FIELD_VALUE:
|
|
1071
|
+
{
|
|
1072
|
+
const {
|
|
1073
|
+
formId,
|
|
1074
|
+
id,
|
|
1075
|
+
value
|
|
1076
|
+
} = action || {};
|
|
1077
|
+
state[formId].data[id] = value;
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
case SET_DEFAULT_FIELD_VALUE:
|
|
1082
|
+
{
|
|
1083
|
+
const {
|
|
1084
|
+
formId,
|
|
1085
|
+
value
|
|
1086
|
+
} = action || {};
|
|
1087
|
+
state[formId].data = value;
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
case SET_CHECKBOX_VALUE:
|
|
1092
|
+
{
|
|
1093
|
+
const {
|
|
1094
|
+
formId,
|
|
1095
|
+
id,
|
|
1096
|
+
value,
|
|
1097
|
+
isChecked
|
|
1098
|
+
} = action || {};
|
|
1099
|
+
let values = state[formId].data[id] || [];
|
|
1100
|
+
if (isChecked) state[formId].data[id] = { ...values,
|
|
1101
|
+
value
|
|
1102
|
+
};else state[formId].data[id] = values.filter(v => v !== value);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
case SET_DATE_RANGE_VALUES:
|
|
1107
|
+
{
|
|
1108
|
+
const {
|
|
1109
|
+
formId,
|
|
1110
|
+
id,
|
|
1111
|
+
value,
|
|
1112
|
+
dateType
|
|
1113
|
+
} = action || {};
|
|
1114
|
+
state[formId].data[id][dateType] = value;
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
case SET_FIELD_ERROR:
|
|
1119
|
+
{
|
|
1120
|
+
const {
|
|
1121
|
+
formId,
|
|
1122
|
+
value
|
|
1123
|
+
} = action || {};
|
|
1124
|
+
state[formId].fieldErrors = value;
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
case SET_SUBMITTING_FORM:
|
|
1129
|
+
{
|
|
1130
|
+
const {
|
|
1131
|
+
formId,
|
|
1132
|
+
isSubmitting
|
|
1133
|
+
} = action || {};
|
|
1134
|
+
state[formId].status.isSubmitting = isSubmitting;
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
case SUBMIT_FORM_SUCCESS:
|
|
1139
|
+
{
|
|
1140
|
+
const {
|
|
1141
|
+
formId
|
|
1142
|
+
} = action || {};
|
|
1143
|
+
state[formId].status.hasError = false;
|
|
1144
|
+
state[formId].status.isSubmitting = false;
|
|
1145
|
+
state[formId].status.hasSuccess = true;
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
case SET_SUCCESS_MESSAGE:
|
|
1150
|
+
{
|
|
1151
|
+
const {
|
|
1152
|
+
formId,
|
|
1153
|
+
message
|
|
1154
|
+
} = action || {};
|
|
1155
|
+
state[formId].status.successMessage = message;
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
case SUBMIT_FORM_ERROR:
|
|
1160
|
+
{
|
|
1161
|
+
const {
|
|
1162
|
+
formId
|
|
1163
|
+
} = action || {};
|
|
1164
|
+
state[formId].status.hasError = true;
|
|
1165
|
+
state[formId].status.isSubmitting = false;
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
case SET_FORM_ENTRIES:
|
|
1170
|
+
{
|
|
1171
|
+
const {
|
|
1172
|
+
formId,
|
|
1173
|
+
entries
|
|
1174
|
+
} = action || {};
|
|
1175
|
+
const entryObject = {};
|
|
1176
|
+
entries.map(entry => {
|
|
1177
|
+
if (!entry) return null;
|
|
1178
|
+
entryObject[entry.id] = entry.entries;
|
|
1179
|
+
return entryObject;
|
|
1180
|
+
});
|
|
1181
|
+
state[formId].entries = entryObject;
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
case SET_ERROR:
|
|
1186
|
+
{
|
|
1187
|
+
const {
|
|
1188
|
+
formId
|
|
1189
|
+
} = action || {};
|
|
1190
|
+
state[formId].status.hasError = true;
|
|
1191
|
+
state[formId].status.isSubmitting = false;
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
default:
|
|
1196
|
+
return state;
|
|
1197
|
+
}
|
|
1198
|
+
}, initialState$3);
|
|
1199
|
+
|
|
1200
|
+
const action$1 = (type, payload = {}) => ({
|
|
1201
|
+
type,
|
|
1202
|
+
...payload
|
|
1203
|
+
});
|
|
1204
|
+
const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE) => {
|
|
1205
|
+
var _globalThis$immutable, _globalThis$immutable2;
|
|
1206
|
+
|
|
1207
|
+
// Find a fromJS function from global that is dynamically loaded in createStore
|
|
1208
|
+
// or replace with a stub function for non-immutable gets
|
|
1209
|
+
const fromJS = returnType === 'immutable' ? ((_globalThis$immutable = globalThis.immutable) === null || _globalThis$immutable === void 0 ? void 0 : _globalThis$immutable.fromJSOrdered) || ((_globalThis$immutable2 = globalThis.immutable) === null || _globalThis$immutable2 === void 0 ? void 0 : _globalThis$immutable2.fromJS) : v => v;
|
|
1210
|
+
|
|
1211
|
+
if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
|
|
1212
|
+
if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
|
|
1213
|
+
return fromJS(state.get(stateKey, fallbackValue));
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
if (Array.isArray(stateKey) && state && typeof state === 'object') {
|
|
1217
|
+
const result = jpath(stateKey.join('.'), state);
|
|
1218
|
+
if (typeof result === 'undefined') return fallbackValue;
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
const result = state && typeof state === 'object' ? state[stateKey] : undefined;
|
|
1223
|
+
if (typeof result === 'undefined') return fallbackValue;
|
|
1224
|
+
return result;
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
function queryParams(search) {
|
|
1228
|
+
return queryString__default.parse(typeof window != 'undefined' ? window.location.search : search);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
const selectRouteEntry$1 = (state, returnType) => getImmutableOrJS(state, ['routing', 'entry'], {}, returnType);
|
|
1232
|
+
const selectMappedEntry = (state, returnType) => getImmutableOrJS(state, ['routing', 'mappedEntry'], null, returnType);
|
|
1233
|
+
const selectSurrogateKeys = state => {
|
|
1234
|
+
const keys = getImmutableOrJS(state, ['routing', 'surrogateKeys'], [], 'js');
|
|
1235
|
+
return keys.join(' ');
|
|
1236
|
+
};
|
|
1237
|
+
const selectCurrentHostname = state => getImmutableOrJS(state, ['routing', 'currentHostname']);
|
|
1238
|
+
const selectCurrentTreeID = state => getImmutableOrJS(state, ['routing', 'currentHostname']);
|
|
1239
|
+
const selectRouteEntryEntryId$1 = state => getImmutableOrJS(state, ['routing', 'entry', 'sys', 'id'], null);
|
|
1240
|
+
const selectRouteEntryContentTypeId$1 = state => {
|
|
1241
|
+
const entry = selectRouteEntry$1(state);
|
|
1242
|
+
return getImmutableOrJS(entry, ['sys', 'contentTypeId'], null);
|
|
1243
|
+
};
|
|
1244
|
+
const selectRouteEntryLanguage = state => {
|
|
1245
|
+
const entry = selectRouteEntry$1(state);
|
|
1246
|
+
return getImmutableOrJS(entry, ['sys', 'language'], null);
|
|
1247
|
+
};
|
|
1248
|
+
const selectRouteEntrySlug$1 = state => {
|
|
1249
|
+
const entry = selectRouteEntry$1(state);
|
|
1250
|
+
return getImmutableOrJS(entry, ['sys', 'slug'], null);
|
|
1251
|
+
};
|
|
1252
|
+
const selectRouteEntryID$1 = state => getImmutableOrJS(state, ['routing', 'entryID']);
|
|
1253
|
+
const selectCurrentPath$1 = state => getImmutableOrJS(state, ['routing', 'currentPath']);
|
|
1254
|
+
const selectCurrentLocation = state => getImmutableOrJS(state, ['routing', 'location']);
|
|
1255
|
+
const selectCurrentSearch$1 = state => getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1256
|
+
const selectCurrentHash = state => getImmutableOrJS(state, ['routing', 'location', 'hash']);
|
|
1257
|
+
const selectQueryStringAsObject$1 = state => queryParams(selectCurrentSearch$1(state));
|
|
1258
|
+
const selectCurrentProject$1 = state => getImmutableOrJS(state, ['routing', 'currentProject']);
|
|
1259
|
+
const selectIsNotFound$1 = state => getImmutableOrJS(state, ['routing', 'notFound']);
|
|
1260
|
+
const selectCurrentAncestors$1 = state => getImmutableOrJS(state, ['routing', 'currentNodeAncestors'], []);
|
|
1261
|
+
const selectCurrentSiblings = state => getImmutableOrJS(state, ['routing', 'currentNodeSiblings'], []);
|
|
1262
|
+
const selectCurrentNode = (state, returnType) => getImmutableOrJS(state, ['routing', 'currentNode'], null, returnType);
|
|
1263
|
+
const selectCurrentChildren = state => getImmutableOrJS(state, ['routing', 'currentNode', 'children'], []);
|
|
1264
|
+
const selectBreadcrumb = state => {
|
|
1265
|
+
return selectCurrentAncestors$1(state).push(selectCurrentNode(state));
|
|
1266
|
+
};
|
|
1267
|
+
const selectRouteErrorMessage = state => {
|
|
1268
|
+
const error = getImmutableOrJS(state, ['routing', 'error']);
|
|
1269
|
+
return getImmutableOrJS(error, ['data', 'message'], getImmutableOrJS(error, 'statusText'));
|
|
1270
|
+
};
|
|
1271
|
+
const selectRouteIsError = state => getImmutableOrJS(state, ['routing', 'isError']);
|
|
1272
|
+
const selectRouteLoading$1 = state => getImmutableOrJS(state, ['routing', 'isLoading']);
|
|
1273
|
+
const selectRouteStatusCode = state => getImmutableOrJS(state, ['routing', 'statusCode']);
|
|
1274
|
+
const selectStaticRoute = state => getImmutableOrJS(state, ['routing', 'staticRoute']);
|
|
1275
|
+
|
|
1276
|
+
var routing$3 = /*#__PURE__*/Object.freeze({
|
|
1277
|
+
__proto__: null,
|
|
1278
|
+
selectRouteEntry: selectRouteEntry$1,
|
|
1279
|
+
selectMappedEntry: selectMappedEntry,
|
|
1280
|
+
selectSurrogateKeys: selectSurrogateKeys,
|
|
1281
|
+
selectCurrentHostname: selectCurrentHostname,
|
|
1282
|
+
selectCurrentTreeID: selectCurrentTreeID,
|
|
1283
|
+
selectRouteEntryEntryId: selectRouteEntryEntryId$1,
|
|
1284
|
+
selectRouteEntryContentTypeId: selectRouteEntryContentTypeId$1,
|
|
1285
|
+
selectRouteEntryLanguage: selectRouteEntryLanguage,
|
|
1286
|
+
selectRouteEntrySlug: selectRouteEntrySlug$1,
|
|
1287
|
+
selectRouteEntryID: selectRouteEntryID$1,
|
|
1288
|
+
selectCurrentPath: selectCurrentPath$1,
|
|
1289
|
+
selectCurrentLocation: selectCurrentLocation,
|
|
1290
|
+
selectCurrentSearch: selectCurrentSearch$1,
|
|
1291
|
+
selectCurrentHash: selectCurrentHash,
|
|
1292
|
+
selectQueryStringAsObject: selectQueryStringAsObject$1,
|
|
1293
|
+
selectCurrentProject: selectCurrentProject$1,
|
|
1294
|
+
selectIsNotFound: selectIsNotFound$1,
|
|
1295
|
+
selectCurrentAncestors: selectCurrentAncestors$1,
|
|
1296
|
+
selectCurrentSiblings: selectCurrentSiblings,
|
|
1297
|
+
selectCurrentNode: selectCurrentNode,
|
|
1298
|
+
selectCurrentChildren: selectCurrentChildren,
|
|
1299
|
+
selectBreadcrumb: selectBreadcrumb,
|
|
1300
|
+
selectRouteErrorMessage: selectRouteErrorMessage,
|
|
1301
|
+
selectRouteIsError: selectRouteIsError,
|
|
1302
|
+
selectRouteLoading: selectRouteLoading$1,
|
|
1303
|
+
selectRouteStatusCode: selectRouteStatusCode,
|
|
1304
|
+
selectStaticRoute: selectStaticRoute
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
const ROUTING_PREFIX = '@ROUTING/';
|
|
1308
|
+
const GET_ENTRY = `${ROUTING_PREFIX}_GET_ENTRY`;
|
|
1309
|
+
const SET_ENTRY = `${ROUTING_PREFIX}_SET_ENTRY`;
|
|
1310
|
+
const SET_NODE = `${ROUTING_PREFIX}_SET_NODE`;
|
|
1311
|
+
const SET_ANCESTORS = `${ROUTING_PREFIX}_SET_ANCESTORS`;
|
|
1312
|
+
const SET_SIBLINGS = `${ROUTING_PREFIX}_SET_SIBLINGS`;
|
|
1313
|
+
const SET_ENTRY_ID = `${ROUTING_PREFIX}_SET_ENTRY_ID`;
|
|
1314
|
+
const SET_SURROGATE_KEYS = `${ROUTING_PREFIX}_SET_SURROGATE_KEYS`;
|
|
1315
|
+
const SET_NAVIGATION_NOT_FOUND = `${ROUTING_PREFIX}_SET_NOT_FOUND`;
|
|
1316
|
+
const SET_NAVIGATION_PATH = `${ROUTING_PREFIX}_SET_NAVIGATION_PATH`;
|
|
1317
|
+
const SET_TARGET_PROJECT = `${ROUTING_PREFIX}_SET_TARGET_PROJECT`;
|
|
1318
|
+
const SET_ROUTE = `${ROUTING_PREFIX}_SET_ROUTE`;
|
|
1319
|
+
const UPDATE_LOADING_STATE = `${ROUTING_PREFIX}_UPDATE_LOADING_STATE`;
|
|
1320
|
+
|
|
1321
|
+
var routing$1 = /*#__PURE__*/Object.freeze({
|
|
1322
|
+
__proto__: null,
|
|
1323
|
+
GET_ENTRY: GET_ENTRY,
|
|
1324
|
+
SET_ENTRY: SET_ENTRY,
|
|
1325
|
+
SET_NODE: SET_NODE,
|
|
1326
|
+
SET_ANCESTORS: SET_ANCESTORS,
|
|
1327
|
+
SET_SIBLINGS: SET_SIBLINGS,
|
|
1328
|
+
SET_ENTRY_ID: SET_ENTRY_ID,
|
|
1329
|
+
SET_SURROGATE_KEYS: SET_SURROGATE_KEYS,
|
|
1330
|
+
SET_NAVIGATION_NOT_FOUND: SET_NAVIGATION_NOT_FOUND,
|
|
1331
|
+
SET_NAVIGATION_PATH: SET_NAVIGATION_PATH,
|
|
1332
|
+
SET_TARGET_PROJECT: SET_TARGET_PROJECT,
|
|
1333
|
+
SET_ROUTE: SET_ROUTE,
|
|
1334
|
+
UPDATE_LOADING_STATE: UPDATE_LOADING_STATE
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
const setNotFound = notFound => action$1(SET_NAVIGATION_NOT_FOUND, {
|
|
1338
|
+
notFound
|
|
1339
|
+
});
|
|
1340
|
+
const setNavigationPath = (path, location, staticRoute, withEvents, statePath, routes) => action$1(SET_NAVIGATION_PATH, {
|
|
1341
|
+
path,
|
|
1342
|
+
location,
|
|
1343
|
+
staticRoute,
|
|
1344
|
+
withEvents,
|
|
1345
|
+
statePath,
|
|
1346
|
+
routes
|
|
1347
|
+
});
|
|
1348
|
+
const setCurrentProject = (project, allowedGroups, hostname) => action$1(SET_TARGET_PROJECT, {
|
|
1349
|
+
project,
|
|
1350
|
+
allowedGroups,
|
|
1351
|
+
hostname
|
|
1352
|
+
});
|
|
1353
|
+
const setRoute = (path, state) => action$1(SET_ROUTE, {
|
|
1354
|
+
path,
|
|
1355
|
+
state
|
|
1356
|
+
});
|
|
1357
|
+
const setRouteEntry = entry => action$1(SET_ENTRY, {
|
|
1358
|
+
entry
|
|
1359
|
+
});
|
|
1360
|
+
const setSurrogateKeys = (keys, url) => action$1(SET_SURROGATE_KEYS, {
|
|
1361
|
+
keys,
|
|
1362
|
+
url
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
var routing$2 = /*#__PURE__*/Object.freeze({
|
|
1366
|
+
__proto__: null,
|
|
1367
|
+
setNotFound: setNotFound,
|
|
1368
|
+
setNavigationPath: setNavigationPath,
|
|
1369
|
+
setCurrentProject: setCurrentProject,
|
|
1370
|
+
setRoute: setRoute,
|
|
1371
|
+
setRouteEntry: setRouteEntry,
|
|
1372
|
+
setSurrogateKeys: setSurrogateKeys
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
const ACTION_PREFIX$1 = '@USER/';
|
|
1376
|
+
const SET_AUTHENTICATION_STATE = `${ACTION_PREFIX$1}SET_AUTHENTICATION_STATE`;
|
|
1377
|
+
const LOGIN_USER = `${ACTION_PREFIX$1}LOGIN_USER`;
|
|
1378
|
+
const LOGOUT_USER = `${ACTION_PREFIX$1}LOGOUT_USER`;
|
|
1379
|
+
const REGISTER_USER = `${ACTION_PREFIX$1}REGISTER_USER`;
|
|
1380
|
+
const REGISTER_USER_SUCCESS = `${ACTION_PREFIX$1}REGISTER_USER_SUCCESS`;
|
|
1381
|
+
const REGISTER_USER_FAILED = `${ACTION_PREFIX$1}REGISTER_USER_FAILED`;
|
|
1382
|
+
const REQUEST_USER_PASSWORD_RESET_SENDING = `${ACTION_PREFIX$1}REQUEST_USER_PASSWORD_RESET_SENDING`;
|
|
1383
|
+
const REQUEST_USER_PASSWORD_RESET_SUCCESS = `${ACTION_PREFIX$1}REQUEST_USER_PASSWORD_RESET_SUCCESS`;
|
|
1384
|
+
const REQUEST_USER_PASSWORD_RESET_ERROR = `${ACTION_PREFIX$1}REQUEST_USER_PASSWORD_RESET_ERROR`;
|
|
1385
|
+
const RESET_USER_PASSWORD_SENDING = `${ACTION_PREFIX$1}RESET_USER_PASSWORD_SENDING`;
|
|
1386
|
+
const RESET_USER_PASSWORD_SUCCESS = `${ACTION_PREFIX$1}RESET_USER_PASSWORD_SUCCESS`;
|
|
1387
|
+
const RESET_USER_PASSWORD_ERROR = `${ACTION_PREFIX$1}RESET_USER_PASSWORD_ERROR`;
|
|
1388
|
+
const CHANGE_USER_PASSWORD_SENDING = `${ACTION_PREFIX$1}CHANGE_USER_PASSWORD_SENDING`;
|
|
1389
|
+
const CHANGE_USER_PASSWORD_SUCCESS = `${ACTION_PREFIX$1}CHANGE_USER_PASSWORD_SUCCESS`;
|
|
1390
|
+
const CHANGE_USER_PASSWORD_ERROR = `${ACTION_PREFIX$1}CHANGE_USER_PASSWORD_ERROR`;
|
|
1391
|
+
|
|
1392
|
+
const defaultAuthenticationState = {
|
|
1393
|
+
clientCredentials: null,
|
|
1394
|
+
errorMessage: null,
|
|
1395
|
+
isAuthenticated: false,
|
|
1396
|
+
isAuthenticationError: false,
|
|
1397
|
+
isError: false,
|
|
1398
|
+
isLoading: false
|
|
1399
|
+
};
|
|
1400
|
+
const defaultPasswordResetRequestValues = {
|
|
1401
|
+
isSending: false,
|
|
1402
|
+
sent: false,
|
|
1403
|
+
error: null
|
|
1404
|
+
};
|
|
1405
|
+
const defaultResetPasswordValues = {
|
|
1406
|
+
isSending: false,
|
|
1407
|
+
sent: false,
|
|
1408
|
+
error: null
|
|
1409
|
+
};
|
|
1410
|
+
const defaultChangePasswordValues = {
|
|
1411
|
+
isSending: false,
|
|
1412
|
+
sent: false,
|
|
1413
|
+
error: null
|
|
1414
|
+
};
|
|
1415
|
+
const defaultRegistrationValues = {
|
|
1416
|
+
isLoading: false,
|
|
1417
|
+
success: false,
|
|
1418
|
+
error: null
|
|
1419
|
+
};
|
|
1420
|
+
const initialUserState = {
|
|
1421
|
+
authenticationState: defaultAuthenticationState,
|
|
1422
|
+
passwordResetRequest: defaultPasswordResetRequestValues,
|
|
1423
|
+
resetPassword: defaultResetPasswordValues,
|
|
1424
|
+
changePassword: defaultChangePasswordValues,
|
|
1425
|
+
groups: []
|
|
1426
|
+
};
|
|
1427
|
+
produce((state, action) => {
|
|
1428
|
+
switch (action.type) {
|
|
1429
|
+
case LOGOUT_USER:
|
|
1430
|
+
{
|
|
1431
|
+
return initialUserState;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
case LOGIN_USER:
|
|
1435
|
+
case SET_AUTHENTICATION_STATE:
|
|
1436
|
+
{
|
|
1437
|
+
var _state, _state$authentication;
|
|
1438
|
+
|
|
1439
|
+
if (!action.authenticationState) {
|
|
1440
|
+
action.authenticationState = defaultAuthenticationState;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
const {
|
|
1444
|
+
authenticationState: {
|
|
1445
|
+
clientCredentials = null,
|
|
1446
|
+
errorMessage = null,
|
|
1447
|
+
isAuthenticated,
|
|
1448
|
+
isAuthenticationError = false,
|
|
1449
|
+
isError = false,
|
|
1450
|
+
isLoading = action.type === LOGIN_USER
|
|
1451
|
+
},
|
|
1452
|
+
user
|
|
1453
|
+
} = action;
|
|
1454
|
+
|
|
1455
|
+
if (user) {
|
|
1456
|
+
user.name = `${user.firstName}${user.lastName ? ` ${user.lastName}` : ''}` || null;
|
|
1457
|
+
user.isZengentiStaff = user.email.includes('@zengenti.com');
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
state = { ...initialUserState,
|
|
1461
|
+
...(user || state),
|
|
1462
|
+
authenticationState: {
|
|
1463
|
+
clientCredentials,
|
|
1464
|
+
errorMessage,
|
|
1465
|
+
isAuthenticated: isAuthenticated || ((_state = state) === null || _state === void 0 ? void 0 : (_state$authentication = _state.authenticationState) === null || _state$authentication === void 0 ? void 0 : _state$authentication.isAuthenticated),
|
|
1466
|
+
isAuthenticationError,
|
|
1467
|
+
isError,
|
|
1468
|
+
isLoading
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
return state;
|
|
1472
|
+
}
|
|
1473
|
+
// REGISTER_USER is the trigger to set the user.registration initial state
|
|
1474
|
+
// and will set user.registration.isLoading to true
|
|
1475
|
+
// REGISTER_USER_FAILED will unset user.registration.isLoading and will set
|
|
1476
|
+
// the value in user.registration.error
|
|
1477
|
+
// REGISTER_USER_SUCCESS will unset user.registration.isLoading and will
|
|
1478
|
+
// set user.registration to the created user from the api response
|
|
1479
|
+
|
|
1480
|
+
case REGISTER_USER:
|
|
1481
|
+
case REGISTER_USER_FAILED:
|
|
1482
|
+
case REGISTER_USER_SUCCESS:
|
|
1483
|
+
{
|
|
1484
|
+
const {
|
|
1485
|
+
error,
|
|
1486
|
+
user
|
|
1487
|
+
} = action; // Set registration object from the supplied action.user
|
|
1488
|
+
// so we can call these values back later
|
|
1489
|
+
|
|
1490
|
+
state.registration = user || state.registration || defaultRegistrationValues; // Set registration flags so the UI can track the status
|
|
1491
|
+
|
|
1492
|
+
state.registration.success = action.type === REGISTER_USER_SUCCESS;
|
|
1493
|
+
state.registration.error = error || false;
|
|
1494
|
+
state.registration.isLoading = action.type === REGISTER_USER;
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
case REQUEST_USER_PASSWORD_RESET_SENDING:
|
|
1499
|
+
state.passwordResetRequest = defaultPasswordResetRequestValues;
|
|
1500
|
+
state.passwordResetRequest.isSending = true;
|
|
1501
|
+
return;
|
|
1502
|
+
|
|
1503
|
+
case REQUEST_USER_PASSWORD_RESET_SUCCESS:
|
|
1504
|
+
if (state.passwordResetRequest) {
|
|
1505
|
+
state.passwordResetRequest.isSending = false;
|
|
1506
|
+
state.passwordResetRequest.sent = true;
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
return;
|
|
1510
|
+
|
|
1511
|
+
case REQUEST_USER_PASSWORD_RESET_ERROR:
|
|
1512
|
+
if (state.passwordResetRequest) {
|
|
1513
|
+
state.passwordResetRequest.isSending = false;
|
|
1514
|
+
state.passwordResetRequest.error = action.error;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
return;
|
|
1518
|
+
|
|
1519
|
+
case RESET_USER_PASSWORD_SENDING:
|
|
1520
|
+
if (state.resetPassword) {
|
|
1521
|
+
state.resetPassword.isSending = true;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
return;
|
|
1525
|
+
|
|
1526
|
+
case RESET_USER_PASSWORD_SUCCESS:
|
|
1527
|
+
if (state.resetPassword) {
|
|
1528
|
+
state.resetPassword.isSending = false;
|
|
1529
|
+
state.resetPassword.sent = true;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
return;
|
|
1533
|
+
|
|
1534
|
+
case RESET_USER_PASSWORD_ERROR:
|
|
1535
|
+
if (state.resetPassword) {
|
|
1536
|
+
state.resetPassword.isSending = false;
|
|
1537
|
+
state.resetPassword.error = action.error;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
return;
|
|
1541
|
+
|
|
1542
|
+
case CHANGE_USER_PASSWORD_SENDING:
|
|
1543
|
+
if (state.changePassword) {
|
|
1544
|
+
state.changePassword.isSending = true;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
return;
|
|
1548
|
+
|
|
1549
|
+
case CHANGE_USER_PASSWORD_SUCCESS:
|
|
1550
|
+
if (state.changePassword) {
|
|
1551
|
+
state.changePassword.isSending = false;
|
|
1552
|
+
state.changePassword.sent = true;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
return;
|
|
1556
|
+
|
|
1557
|
+
case CHANGE_USER_PASSWORD_ERROR:
|
|
1558
|
+
if (state.changePassword) {
|
|
1559
|
+
state.changePassword.isSending = false;
|
|
1560
|
+
state.changePassword.error = action.error;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
return;
|
|
1564
|
+
|
|
1565
|
+
default:
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
}, initialUserState);
|
|
1569
|
+
|
|
1570
|
+
const ACTION_PREFIX = '@NAVIGATION/';
|
|
1571
|
+
const GET_NODE_TREE = `${ACTION_PREFIX}_GET_NODE_TREE`;
|
|
1572
|
+
const SET_NODE_TREE = `${ACTION_PREFIX}_SET_NODE_TREE`;
|
|
1573
|
+
const GET_NODE_TREE_ERROR = `${ACTION_PREFIX}_GET_NODE_TREE_ERROR`;
|
|
1574
|
+
|
|
1575
|
+
var navigation$1$1 = /*#__PURE__*/Object.freeze({
|
|
1576
|
+
__proto__: null,
|
|
1577
|
+
GET_NODE_TREE: GET_NODE_TREE,
|
|
1578
|
+
SET_NODE_TREE: SET_NODE_TREE,
|
|
1579
|
+
GET_NODE_TREE_ERROR: GET_NODE_TREE_ERROR
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
const initialState$2 = {
|
|
1583
|
+
root: null,
|
|
1584
|
+
isError: false,
|
|
1585
|
+
isReady: false
|
|
1586
|
+
};
|
|
1587
|
+
produce((state, action) => {
|
|
1588
|
+
switch (action.type) {
|
|
1589
|
+
case SET_NODE_TREE:
|
|
1590
|
+
{
|
|
1591
|
+
state.root = action.nodes;
|
|
1592
|
+
state.isReady = true;
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
case GET_NODE_TREE_ERROR:
|
|
1597
|
+
{
|
|
1598
|
+
state.isError = true;
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
default:
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
}, initialState$2);
|
|
1606
|
+
|
|
1607
|
+
const combineMerge = (target, source, options) => {
|
|
1608
|
+
const destination = target.slice();
|
|
1609
|
+
source.forEach((item, index) => {
|
|
1610
|
+
if (typeof destination[index] === 'undefined') {
|
|
1611
|
+
destination[index] = options.cloneUnlessOtherwiseSpecified(item, options);
|
|
1612
|
+
} else if (options.isMergeableObject(item)) {
|
|
1613
|
+
destination[index] = merge(target[index], item, options);
|
|
1614
|
+
} else if (target.indexOf(item) === -1) {
|
|
1615
|
+
destination.push(item);
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
return destination;
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
const initialState$1 = {
|
|
1622
|
+
currentHostname: null,
|
|
1623
|
+
currentPath: '/',
|
|
1624
|
+
currentNode: {},
|
|
1625
|
+
currentNodeAncestors: [],
|
|
1626
|
+
currentProject: 'unknown',
|
|
1627
|
+
entryID: null,
|
|
1628
|
+
entry: null,
|
|
1629
|
+
error: undefined,
|
|
1630
|
+
isError: false,
|
|
1631
|
+
isLoading: false,
|
|
1632
|
+
location: {},
|
|
1633
|
+
mappedEntry: null,
|
|
1634
|
+
notFound: false,
|
|
1635
|
+
staticRoute: null,
|
|
1636
|
+
statusCode: 200
|
|
1637
|
+
};
|
|
1638
|
+
produce((state, action) => {
|
|
1639
|
+
switch (action.type) {
|
|
1640
|
+
case SET_ANCESTORS:
|
|
1641
|
+
{
|
|
1642
|
+
state.currentNodeAncestors = action.ancestors;
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
case SET_ENTRY:
|
|
1647
|
+
{
|
|
1648
|
+
const {
|
|
1649
|
+
entry,
|
|
1650
|
+
error,
|
|
1651
|
+
mappedEntry,
|
|
1652
|
+
node = {},
|
|
1653
|
+
isError = false,
|
|
1654
|
+
isLoading = false,
|
|
1655
|
+
notFound = false,
|
|
1656
|
+
statusCode
|
|
1657
|
+
} = action;
|
|
1658
|
+
let defaultStatus = 200;
|
|
1659
|
+
if (notFound === true && isError === false) defaultStatus = 404;else if (isError === true) defaultStatus = statusCode || 500;
|
|
1660
|
+
|
|
1661
|
+
if (!entry) {
|
|
1662
|
+
state.entryID = null;
|
|
1663
|
+
state.entry = null;
|
|
1664
|
+
state.error = error;
|
|
1665
|
+
state.mappedEntry = null;
|
|
1666
|
+
state.isError = isError;
|
|
1667
|
+
state.isLoading = isLoading;
|
|
1668
|
+
state.notFound = notFound;
|
|
1669
|
+
state.statusCode = statusCode || defaultStatus;
|
|
1670
|
+
} else {
|
|
1671
|
+
state.entryID = action.id;
|
|
1672
|
+
state.entry = entry;
|
|
1673
|
+
state.error = error;
|
|
1674
|
+
state.isError = isError;
|
|
1675
|
+
state.isLoading = isLoading;
|
|
1676
|
+
state.notFound = notFound;
|
|
1677
|
+
state.statusCode = statusCode || defaultStatus;
|
|
1678
|
+
|
|
1679
|
+
if (mappedEntry && Object.keys(mappedEntry).length > 0) {
|
|
1680
|
+
state.mappedEntry = mappedEntry;
|
|
1681
|
+
state.entry = {
|
|
1682
|
+
sys: entry.sys
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
if (!node) {
|
|
1688
|
+
state.currentNode = null;
|
|
1689
|
+
} else {
|
|
1690
|
+
// On Set Node, we reset all dependants.
|
|
1691
|
+
state.currentNode = node; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1692
|
+
|
|
1693
|
+
const {
|
|
1694
|
+
entry,
|
|
1695
|
+
...nodeWithoutEntry
|
|
1696
|
+
} = node; // We have the entry stored elsewhere, so lets not keep it twice.
|
|
1697
|
+
|
|
1698
|
+
state.currentNode = nodeWithoutEntry;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
return;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
case UPDATE_LOADING_STATE:
|
|
1705
|
+
{
|
|
1706
|
+
state.isLoading = action.isLoading;
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
case SET_NAVIGATION_PATH:
|
|
1711
|
+
{
|
|
1712
|
+
let staticRoute = {};
|
|
1713
|
+
|
|
1714
|
+
if (action.staticRoute) {
|
|
1715
|
+
staticRoute = { ...action.staticRoute
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
if (action.path) {
|
|
1720
|
+
var _state$entry, _state$entry$sys;
|
|
1721
|
+
|
|
1722
|
+
// Don't run a path update on initial load as we allready should have it in redux
|
|
1723
|
+
const entryUri = state === null || state === void 0 ? void 0 : (_state$entry = state.entry) === null || _state$entry === void 0 ? void 0 : (_state$entry$sys = _state$entry.sys) === null || _state$entry$sys === void 0 ? void 0 : _state$entry$sys.uri;
|
|
1724
|
+
|
|
1725
|
+
if (entryUri !== action.path) {
|
|
1726
|
+
state.currentPath = action.path;
|
|
1727
|
+
state.location = action.location;
|
|
1728
|
+
state.staticRoute = { ...staticRoute,
|
|
1729
|
+
route: { ...staticRoute.route,
|
|
1730
|
+
component: null
|
|
1731
|
+
}
|
|
1732
|
+
};
|
|
1733
|
+
state.isLoading = typeof window !== 'undefined';
|
|
1734
|
+
} else {
|
|
1735
|
+
state.location = action.location;
|
|
1736
|
+
state.staticRoute = { ...staticRoute,
|
|
1737
|
+
route: { ...staticRoute.route,
|
|
1738
|
+
component: null
|
|
1739
|
+
}
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
case SET_ROUTE:
|
|
1748
|
+
{
|
|
1749
|
+
state.nextPath = action.path;
|
|
1750
|
+
return;
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
case SET_SIBLINGS:
|
|
1754
|
+
{
|
|
1755
|
+
// Can be null in some cases like the homepage.
|
|
1756
|
+
let currentNodeSiblingParent = null;
|
|
1757
|
+
|
|
1758
|
+
if (action.siblings && action.siblings.length > 0) {
|
|
1759
|
+
currentNodeSiblingParent = action.siblings[0].parentId;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
state.currentNodeSiblings = action.siblings;
|
|
1763
|
+
state.currentNodeSiblingsParent = currentNodeSiblingParent;
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
case SET_SURROGATE_KEYS:
|
|
1768
|
+
{
|
|
1769
|
+
// console.info(`SET_SURROGATE_KEYS: '${action.url}' keys: ${action.keys}`);
|
|
1770
|
+
state.surrogateKeys = merge(state.surrogateKeys, (action.keys || '').split(' '), {
|
|
1771
|
+
arrayMerge: combineMerge
|
|
1772
|
+
});
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
case SET_TARGET_PROJECT:
|
|
1777
|
+
{
|
|
1778
|
+
state.currentProject = action.project;
|
|
1779
|
+
state.allowedGroups = action.allowedGroups;
|
|
1780
|
+
state.currentHostname = action.hostname;
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
default:
|
|
1785
|
+
return state;
|
|
1786
|
+
}
|
|
1787
|
+
}, initialState$1);
|
|
1788
|
+
|
|
1789
|
+
const VERSION_PREFIX = '@VERSION/';
|
|
1790
|
+
const SET_VERSION = `${VERSION_PREFIX}SET_VERSION`;
|
|
1791
|
+
const SET_VERSION_STATUS = `${VERSION_PREFIX}SET_VERSION_STATUS`;
|
|
1792
|
+
|
|
1793
|
+
var version$1 = /*#__PURE__*/Object.freeze({
|
|
1794
|
+
__proto__: null,
|
|
1795
|
+
SET_VERSION: SET_VERSION,
|
|
1796
|
+
SET_VERSION_STATUS: SET_VERSION_STATUS
|
|
1797
|
+
});
|
|
1798
|
+
|
|
1799
|
+
const initialState = {
|
|
1800
|
+
commitRef: null,
|
|
1801
|
+
buildNo: null,
|
|
1802
|
+
contensisVersionStatus: 'published'
|
|
1803
|
+
};
|
|
1804
|
+
produce((state, action) => {
|
|
1805
|
+
switch (action.type) {
|
|
1806
|
+
case SET_VERSION_STATUS:
|
|
1807
|
+
{
|
|
1808
|
+
state.contensisVersionStatus = action.status;
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
case SET_VERSION:
|
|
1813
|
+
{
|
|
1814
|
+
state.commitRef = action.commitRef;
|
|
1815
|
+
state.buildNo = action.buildNo;
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
default:
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
}, initialState);
|
|
1823
|
+
|
|
1824
|
+
const hasNavigationTree = state => getImmutableOrJS(state, ['navigation', 'isReady']);
|
|
1825
|
+
const selectNavigationRoot = state => getImmutableOrJS(state, ['navigation', 'root']);
|
|
1826
|
+
const selectNavigationChildren = state => getImmutableOrJS(state, ['navigation', 'root', 'children']);
|
|
1827
|
+
const selectNavigationDepends = () => [];
|
|
1828
|
+
|
|
1829
|
+
var navigation = /*#__PURE__*/Object.freeze({
|
|
1830
|
+
__proto__: null,
|
|
1831
|
+
hasNavigationTree: hasNavigationTree,
|
|
1832
|
+
selectNavigationRoot: selectNavigationRoot,
|
|
1833
|
+
selectNavigationChildren: selectNavigationChildren,
|
|
1834
|
+
selectNavigationDepends: selectNavigationDepends
|
|
1835
|
+
});
|
|
1836
|
+
|
|
1837
|
+
const setVersion = (commitRef, buildNo) => action$1(SET_VERSION, {
|
|
1838
|
+
commitRef,
|
|
1839
|
+
buildNo
|
|
1840
|
+
});
|
|
1841
|
+
const setVersionStatus = status => action$1(SET_VERSION_STATUS, {
|
|
1842
|
+
status
|
|
1843
|
+
});
|
|
1844
|
+
|
|
1845
|
+
var version$2 = /*#__PURE__*/Object.freeze({
|
|
1846
|
+
__proto__: null,
|
|
1847
|
+
setVersion: setVersion,
|
|
1848
|
+
setVersionStatus: setVersionStatus
|
|
1849
|
+
});
|
|
1850
|
+
|
|
1851
|
+
const selectCommitRef$1 = state => getImmutableOrJS(state, ['version', 'commitRef']);
|
|
1852
|
+
const selectBuildNumber$1 = state => getImmutableOrJS(state, ['version', 'buildNo']);
|
|
1853
|
+
const selectVersionStatus$1 = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
|
|
1854
|
+
|
|
1855
|
+
var version$3 = /*#__PURE__*/Object.freeze({
|
|
1856
|
+
__proto__: null,
|
|
1857
|
+
selectCommitRef: selectCommitRef$1,
|
|
1858
|
+
selectBuildNumber: selectBuildNumber$1,
|
|
1859
|
+
selectVersionStatus: selectVersionStatus$1
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1862
|
+
var types$2 = {
|
|
1863
|
+
navigation: navigation$1$1,
|
|
1864
|
+
routing: routing$1,
|
|
1865
|
+
version: version$1
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
const loadNavigationTree$1 = () => action$1(GET_NODE_TREE);
|
|
1869
|
+
|
|
1870
|
+
var navigation$1$2 = /*#__PURE__*/Object.freeze({
|
|
1871
|
+
__proto__: null,
|
|
1872
|
+
loadNavigationTree: loadNavigationTree$1
|
|
1873
|
+
});
|
|
1874
|
+
|
|
1875
|
+
var actions$1 = {
|
|
1876
|
+
navigation: navigation$1$2,
|
|
1877
|
+
routing: routing$2,
|
|
1878
|
+
version: version$2
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
var selectors$1 = {
|
|
1882
|
+
navigation: navigation,
|
|
1883
|
+
routing: routing$3,
|
|
1884
|
+
version: version$3
|
|
1885
|
+
};
|
|
1886
|
+
const routing$4 = {
|
|
1887
|
+
types: types$2.routing,
|
|
1888
|
+
actions: actions$1.routing,
|
|
1889
|
+
selectors: selectors$1.routing
|
|
1890
|
+
};
|
|
1891
|
+
|
|
1892
|
+
const selectForms$1 = state => getImmutableOrJS(state, ['forms']);
|
|
1893
|
+
const selectFormFieldData = (state, formId, field) => getImmutableOrJS(state, ['forms', formId, 'fields', field]);
|
|
1894
|
+
const selectFieldErrors$1 = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'fieldErrors']);
|
|
1895
|
+
const selectPostData$1 = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'data']);
|
|
1896
|
+
const selectFormGroups$1 = (state, formId) => getImmutableOrJS(state, [('groups')]);
|
|
1897
|
+
const selectPagingInfo$1 = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'pagingInfo']);
|
|
1898
|
+
const selectFormStatus$1 = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'status']);
|
|
1899
|
+
const selectFormMessage = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'status', 'successMessage']);
|
|
1900
|
+
const selectEntries$1 = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'entries']);
|
|
1901
|
+
const makeSelectHasSuccess = (state, formId) => getImmutableOrJS(state, ['forms', formId, 'status', 'hasSuccess']);
|
|
1902
|
+
const selectPagedFields$1 = formId => createSelector([selectForms$1], form => {
|
|
1903
|
+
const pagingInfo = getImmutableOrJS(form, [formId, 'pagingInfo']);
|
|
1904
|
+
const fields = getImmutableOrJS(form, [formId, 'fields']);
|
|
1905
|
+
|
|
1906
|
+
if (fields && fields.length > 0 && pagingInfo && pagingInfo.pageCount > 1) {
|
|
1907
|
+
return fields.filter(f => f.groupId == pagingInfo.currentPageId);
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
return fields;
|
|
1911
|
+
});
|
|
1912
|
+
const makeSelectIsLoading$1 = formId => createSelector(selectForms$1, forms => getImmutableOrJS(forms, [formId, 'status', 'isLoading']));
|
|
1913
|
+
const makeSelectFormFields$1 = formId => createSelector(selectForms$1, forms => getImmutableOrJS(forms, [formId, 'fields']));
|
|
1914
|
+
const makeSelectDefaultLang$1 = formId => createSelector(selectForms$1, forms => getImmutableOrJS(forms, [formId, 'defaultLanguage']));
|
|
1915
|
+
|
|
1916
|
+
var selectors$2 = /*#__PURE__*/Object.freeze({
|
|
1917
|
+
__proto__: null,
|
|
1918
|
+
selectForms: selectForms$1,
|
|
1919
|
+
selectFormFieldData: selectFormFieldData,
|
|
1920
|
+
selectFieldErrors: selectFieldErrors$1,
|
|
1921
|
+
selectPostData: selectPostData$1,
|
|
1922
|
+
selectFormGroups: selectFormGroups$1,
|
|
1923
|
+
selectPagingInfo: selectPagingInfo$1,
|
|
1924
|
+
selectFormStatus: selectFormStatus$1,
|
|
1925
|
+
selectFormMessage: selectFormMessage,
|
|
1926
|
+
selectEntries: selectEntries$1,
|
|
1927
|
+
makeSelectHasSuccess: makeSelectHasSuccess,
|
|
1928
|
+
selectPagedFields: selectPagedFields$1,
|
|
1929
|
+
makeSelectIsLoading: makeSelectIsLoading$1,
|
|
1930
|
+
makeSelectFormFields: makeSelectFormFields$1,
|
|
1931
|
+
makeSelectDefaultLang: makeSelectDefaultLang$1
|
|
1932
|
+
});
|
|
1933
|
+
|
|
1934
|
+
const URI$1 = '/forms';
|
|
1935
|
+
const getFormSchema$1 = async formId => {
|
|
1936
|
+
var options = {
|
|
1937
|
+
method: 'GET',
|
|
1938
|
+
headers: {
|
|
1939
|
+
'Content-Type': 'application/json'
|
|
1940
|
+
}
|
|
1941
|
+
};
|
|
1942
|
+
const getUrl = `${URI$1}/${formId}`;
|
|
1943
|
+
const schema = await request$1(getUrl, options);
|
|
1944
|
+
return schema;
|
|
1945
|
+
};
|
|
1946
|
+
const getEntries$1 = async (formObj, id) => {
|
|
1947
|
+
var options = {
|
|
1948
|
+
method: 'POST',
|
|
1949
|
+
headers: {
|
|
1950
|
+
Accept: '*/*',
|
|
1951
|
+
'Content-Type': 'application/json'
|
|
1952
|
+
},
|
|
1953
|
+
body: JSON.stringify(formObj)
|
|
1954
|
+
};
|
|
1955
|
+
const entriesUrl = `${URI$1}/entries`;
|
|
1956
|
+
const entries = await request$1(entriesUrl, options);
|
|
1957
|
+
return {
|
|
1958
|
+
entries,
|
|
1959
|
+
id
|
|
1960
|
+
};
|
|
1961
|
+
};
|
|
1962
|
+
const postForm$1 = async formObj => {
|
|
1963
|
+
var options = {
|
|
1964
|
+
method: 'POST',
|
|
1965
|
+
headers: {
|
|
1966
|
+
Accept: '*/*',
|
|
1967
|
+
'Content-Type': 'application/json'
|
|
1968
|
+
},
|
|
1969
|
+
body: JSON.stringify(formObj)
|
|
1970
|
+
};
|
|
1971
|
+
const submitted = await request$1(URI$1, options);
|
|
1972
|
+
return submitted;
|
|
1973
|
+
};
|
|
1974
|
+
|
|
1975
|
+
const request$1 = async (url, options) => {
|
|
1976
|
+
return fetch(url, options).then(response => response.json()).then(result => {
|
|
1977
|
+
return result;
|
|
1978
|
+
}) // eslint-disable-next-line no-console
|
|
1979
|
+
.catch(error => console.log('error', error));
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
const validateInput$1 = (field, value) => {
|
|
1983
|
+
const isRequired = field.validations && field.validations.required;
|
|
1984
|
+
const minLength = field.validations && field.validations.minLength;
|
|
1985
|
+
const maxLength = field.validations && field.validations.maxLength;
|
|
1986
|
+
const regex = field.validations && field.validations.regex;
|
|
1987
|
+
const integer = field.dataType === 'integer';
|
|
1988
|
+
const decimal = field.dataType === 'decimal';
|
|
1989
|
+
|
|
1990
|
+
if (isRequired && !value) {
|
|
1991
|
+
const errorMessage = isRequired.message ? isRequired.message['en-GB'] : `${field.id} is required`;
|
|
1992
|
+
return {
|
|
1993
|
+
fieldId: field.id,
|
|
1994
|
+
groupId: field.groupId,
|
|
1995
|
+
message: errorMessage
|
|
1996
|
+
};
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
if (minLength && minLength.value > value.length) {
|
|
2000
|
+
const errorMessage = minLength.message ? minLength.message['en-GB'] : `Minimum characters ${minLength.value}`;
|
|
2001
|
+
return {
|
|
2002
|
+
fieldId: field.id,
|
|
2003
|
+
groupId: field.groupId,
|
|
2004
|
+
message: errorMessage
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
if (maxLength && maxLength.value < value.length) {
|
|
2009
|
+
const errorMessage = maxLength.message && maxLength.message['en-GB'] ? maxLength.message['en-GB'] : `Maximum characters ${maxLength.value}`;
|
|
2010
|
+
return {
|
|
2011
|
+
fieldId: field.id,
|
|
2012
|
+
groupId: field.groupId,
|
|
2013
|
+
message: errorMessage
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
if (regex && value.length > 0) {
|
|
2018
|
+
//Had to make the string raw, as a string ususually is wrapped as '' and Regex couldnt use the regex patter as the string variant
|
|
2019
|
+
const regexPattern = RegExp(regex.pattern.raw);
|
|
2020
|
+
|
|
2021
|
+
if (!regexPattern.test(value)) {
|
|
2022
|
+
const errorMessage = regex.message ? regex.message['en-GB'] : `${field.id} is invalid`;
|
|
2023
|
+
return {
|
|
2024
|
+
fieldId: field.id,
|
|
2025
|
+
groupId: field.groupId,
|
|
2026
|
+
message: errorMessage
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (integer) {
|
|
2032
|
+
const isInteger = value % 1 === 0;
|
|
2033
|
+
|
|
2034
|
+
if (!isInteger) {
|
|
2035
|
+
const errorMessage = `${value} is not an ${field.dataType}`;
|
|
2036
|
+
return {
|
|
2037
|
+
fieldId: field.id,
|
|
2038
|
+
groupId: field.groupId,
|
|
2039
|
+
message: errorMessage
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
if (decimal) {
|
|
2045
|
+
const isDecimal = value % 1 !== 0;
|
|
2046
|
+
|
|
2047
|
+
if (!isDecimal) {
|
|
2048
|
+
const errorMessage = `${value} is not an ${field.dataType}`;
|
|
2049
|
+
return {
|
|
2050
|
+
fieldId: field.id,
|
|
2051
|
+
groupId: field.groupId,
|
|
2052
|
+
message: errorMessage
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
const {
|
|
2059
|
+
selectCurrentAncestors: selectCurrentAncestors$2,
|
|
2060
|
+
selectCurrentPath: selectCurrentPath$2,
|
|
2061
|
+
selectCurrentProject: selectCurrentProject$2,
|
|
2062
|
+
selectCurrentSearch: selectCurrentSearch$2,
|
|
2063
|
+
selectIsNotFound: selectIsNotFound$2,
|
|
2064
|
+
selectQueryStringAsObject: selectQueryStringAsObject$2,
|
|
2065
|
+
selectRouteEntry: selectRouteEntry$2,
|
|
2066
|
+
selectRouteEntryContentTypeId: selectRouteEntryContentTypeId$2,
|
|
2067
|
+
selectRouteEntryDepends: selectRouteEntryDepends$1,
|
|
2068
|
+
selectRouteEntryEntryId: selectRouteEntryEntryId$2,
|
|
2069
|
+
selectRouteEntryID: selectRouteEntryID$2,
|
|
2070
|
+
selectRouteEntrySlug: selectRouteEntrySlug$2,
|
|
2071
|
+
selectRouteLoading: selectRouteLoading$2
|
|
2072
|
+
} = routing$4.selectors;
|
|
2073
|
+
|
|
2074
|
+
const formV2Sagas$1 = [takeEvery(SUBMIT_FORM_SUCCESS, formSuccess$1), takeEvery(SUBMIT_FORM_FOR_VALIDATION, validateForm$1), takeEvery(SUBMIT_FORM, submitForm$1$1), takeEvery(SET_FORM_ID, fetchForm$1), takeLatest(VALIDATE_FIELD, validateField$1$1), takeEvery(PAGE_FORWARD, togglePage$1), takeEvery(PAGE_BACK, togglePage$1), takeEvery(SET_FORM_DATA, getEntryPickerData$1), takeLatest(SET_FORM_DATA, setDefaultValueFields$1)];
|
|
2075
|
+
|
|
2076
|
+
function* validateForm$1(action) {
|
|
2077
|
+
const {
|
|
2078
|
+
formId
|
|
2079
|
+
} = action;
|
|
2080
|
+
yield validateAllfields$1(formId);
|
|
2081
|
+
yield put({
|
|
2082
|
+
type: SUBMIT_FORM,
|
|
2083
|
+
formId
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
function* validateField$1$1(action) {
|
|
2088
|
+
const {
|
|
2089
|
+
formId,
|
|
2090
|
+
id,
|
|
2091
|
+
value
|
|
2092
|
+
} = action;
|
|
2093
|
+
yield call(validateSingleField$1, formId, id, value);
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
function* validateGroupfields$1(formId, groupId) {
|
|
2097
|
+
const state = yield select();
|
|
2098
|
+
const postData = selectPostData$1(state, formId);
|
|
2099
|
+
const selectFormFields = makeSelectFormFields$1(formId);
|
|
2100
|
+
const fields = selectFormFields(state);
|
|
2101
|
+
const groupFields = fields.filter(f => f.groupid == groupId);
|
|
2102
|
+
let newErrors = [];
|
|
2103
|
+
groupFields.forEach(field => {
|
|
2104
|
+
let val = '';
|
|
2105
|
+
|
|
2106
|
+
if (postData[field.id]) {
|
|
2107
|
+
val = postData[field.id];
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
const err = validateInput$1(field, val);
|
|
2111
|
+
if (err) newErrors.push(err);
|
|
2112
|
+
});
|
|
2113
|
+
yield put({
|
|
2114
|
+
type: SET_FIELD_ERROR,
|
|
2115
|
+
formId: formId,
|
|
2116
|
+
value: newErrors
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function* validateAllfields$1(formId) {
|
|
2121
|
+
const state = yield select();
|
|
2122
|
+
const postData = selectPostData$1(state, formId);
|
|
2123
|
+
const selectFormFields = makeSelectFormFields$1(formId);
|
|
2124
|
+
const fields = selectFormFields(state);
|
|
2125
|
+
let newErrors = [];
|
|
2126
|
+
fields.forEach(field => {
|
|
2127
|
+
let val = '';
|
|
2128
|
+
|
|
2129
|
+
if (postData[field.id]) {
|
|
2130
|
+
val = postData[field.id];
|
|
2131
|
+
}
|
|
2132
|
+
|
|
2133
|
+
const err = validateInput$1(field, val);
|
|
2134
|
+
if (err) newErrors.push(err);
|
|
2135
|
+
});
|
|
2136
|
+
yield put({
|
|
2137
|
+
type: SET_FIELD_ERROR,
|
|
2138
|
+
formId: formId,
|
|
2139
|
+
value: newErrors
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
function* validateSingleField$1(formId, fieldId, value) {
|
|
2144
|
+
const state = yield select();
|
|
2145
|
+
const selectFormFields = makeSelectFormFields$1(formId);
|
|
2146
|
+
const fields = selectFormFields(state);
|
|
2147
|
+
const fieldData = fields.find(f => f.id == fieldId);
|
|
2148
|
+
const errors = selectFieldErrors$1(state, formId);
|
|
2149
|
+
const newErrors = []; //loop through current errors to remove any of the item we currently edit
|
|
2150
|
+
|
|
2151
|
+
errors.forEach(error => {
|
|
2152
|
+
if (error.fieldId !== fieldId) {
|
|
2153
|
+
//push any existing errors to new array
|
|
2154
|
+
newErrors.push(error);
|
|
2155
|
+
}
|
|
2156
|
+
});
|
|
2157
|
+
const err = validateInput$1(fieldData, value);
|
|
2158
|
+
if (err) newErrors.push(err);
|
|
2159
|
+
yield put({
|
|
2160
|
+
type: SET_FIELD_ERROR,
|
|
2161
|
+
formId: formId,
|
|
2162
|
+
value: newErrors
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
function* togglePage$1(action) {
|
|
2167
|
+
const {
|
|
2168
|
+
formId,
|
|
2169
|
+
pageIndex
|
|
2170
|
+
} = action;
|
|
2171
|
+
const state = yield select();
|
|
2172
|
+
const formGroups = selectFormGroups$1(state);
|
|
2173
|
+
|
|
2174
|
+
if (action.type === PAGE_FORWARD) {
|
|
2175
|
+
yield validateGroupfields$1(formId, formGroups[pageIndex].id);
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
yield put({
|
|
2179
|
+
type: SET_CURRENT_PAGE,
|
|
2180
|
+
formId: formId,
|
|
2181
|
+
pageId: formGroups[pageIndex].id,
|
|
2182
|
+
pageCount: formGroups.length,
|
|
2183
|
+
pageIndex: pageIndex
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
function* fetchForm$1(action) {
|
|
2188
|
+
const formId = action.formId;
|
|
2189
|
+
const schema = yield getFormSchema$1(formId);
|
|
2190
|
+
const groups = schema && schema.groups && schema.groups.length > 0 && schema.groups.filter(group => group.id !== 'private');
|
|
2191
|
+
|
|
2192
|
+
if (formId && schema) {
|
|
2193
|
+
if (schema.groups && schema.groups.length > 0) {
|
|
2194
|
+
yield put({
|
|
2195
|
+
type: SET_CURRENT_PAGE,
|
|
2196
|
+
formId: formId,
|
|
2197
|
+
pageId: groups[0].id,
|
|
2198
|
+
pageIndex: 0,
|
|
2199
|
+
pageCount: groups.length
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
yield put({
|
|
2204
|
+
type: SET_FORM_DATA,
|
|
2205
|
+
formId: formId,
|
|
2206
|
+
fields: schema.fields,
|
|
2207
|
+
groups: groups,
|
|
2208
|
+
defaultLanguage: schema.defaultLanguage
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
function* formSuccess$1(action) {
|
|
2214
|
+
const state = yield select();
|
|
2215
|
+
const selectFormFields = makeSelectFormFields$1(action.formId);
|
|
2216
|
+
const fields = selectFormFields(state);
|
|
2217
|
+
const redirect = fields.find(f => f.id === 'formSettingsRedirect');
|
|
2218
|
+
const message = fields.find(f => f.id === 'formSettingsMessage');
|
|
2219
|
+
|
|
2220
|
+
if (redirect && redirect.default) {
|
|
2221
|
+
window.location.href = redirect.default['en-GB'];
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
if (message && message.default) {
|
|
2225
|
+
yield put({
|
|
2226
|
+
type: SET_SUCCESS_MESSAGE,
|
|
2227
|
+
message: message.default['en-GB'],
|
|
2228
|
+
formId: action.formId
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
function* submitForm$1$1(action) {
|
|
2234
|
+
const state = yield select();
|
|
2235
|
+
const errors = selectFieldErrors$1(state, action.formId);
|
|
2236
|
+
const canSubmit = errors && errors.length == 0;
|
|
2237
|
+
|
|
2238
|
+
if (canSubmit) {
|
|
2239
|
+
yield put({
|
|
2240
|
+
type: SET_SUBMITTING_FORM,
|
|
2241
|
+
isSubmitting: true,
|
|
2242
|
+
formId: action.formId
|
|
2243
|
+
});
|
|
2244
|
+
const forms = yield select(selectForms$1);
|
|
2245
|
+
const rawData = forms[action.formId];
|
|
2246
|
+
const formObj = {
|
|
2247
|
+
contentType: action.formId,
|
|
2248
|
+
formPost: rawData.data
|
|
2249
|
+
};
|
|
2250
|
+
const formResObj = yield postForm$1(formObj);
|
|
2251
|
+
|
|
2252
|
+
if (formResObj && formResObj.sys && formResObj.sys.id) {
|
|
2253
|
+
yield put({
|
|
2254
|
+
type: SUBMIT_FORM_SUCCESS,
|
|
2255
|
+
formId: action.formId
|
|
2256
|
+
});
|
|
2257
|
+
} else {
|
|
2258
|
+
yield put({
|
|
2259
|
+
type: SUBMIT_FORM_ERROR,
|
|
2260
|
+
formId: action.formId
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
function* setDefaultValueFields$1(action) {
|
|
2267
|
+
const {
|
|
2268
|
+
formId,
|
|
2269
|
+
fields,
|
|
2270
|
+
defaultLanguage
|
|
2271
|
+
} = action;
|
|
2272
|
+
const entryId = yield select(selectRouteEntryEntryId$2);
|
|
2273
|
+
let fieldObj = {};
|
|
2274
|
+
fields.forEach(field => {
|
|
2275
|
+
if (field.dataType == 'string' && field.default) {
|
|
2276
|
+
const val = field.default[defaultLanguage];
|
|
2277
|
+
|
|
2278
|
+
if (val) {
|
|
2279
|
+
fieldObj[field.id] = val;
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
if (field.id == 'sourceEntry') {
|
|
2284
|
+
const val = entryId;
|
|
2285
|
+
|
|
2286
|
+
if (val) {
|
|
2287
|
+
fieldObj[field.id] = val;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
});
|
|
2291
|
+
yield put({
|
|
2292
|
+
type: SET_DEFAULT_FIELD_VALUE,
|
|
2293
|
+
formId: formId,
|
|
2294
|
+
value: fieldObj
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
function* getEntryPickerData$1(action) {
|
|
2299
|
+
const {
|
|
2300
|
+
formId,
|
|
2301
|
+
fields
|
|
2302
|
+
} = action;
|
|
2303
|
+
const entriesToGet = fields.filter(f => f.dataFormat == 'entry');
|
|
2304
|
+
let entriesList = [];
|
|
2305
|
+
|
|
2306
|
+
if (entriesToGet) {
|
|
2307
|
+
entriesList = yield all(entriesToGet.map(entry => {
|
|
2308
|
+
const entriesObj = {
|
|
2309
|
+
contentType: entry.validations.allowedContentTypes.contentTypes,
|
|
2310
|
+
versionStatus: 'published',
|
|
2311
|
+
language: 'en-GB',
|
|
2312
|
+
pageSize: '10'
|
|
2313
|
+
};
|
|
2314
|
+
return call(getEntries$1, entriesObj, entry.id);
|
|
2315
|
+
}));
|
|
2316
|
+
yield put({
|
|
2317
|
+
type: SET_FORM_ENTRIES,
|
|
2318
|
+
formId: formId,
|
|
2319
|
+
entries: entriesList
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
function action$2(type, payload = {}) {
|
|
2325
|
+
return {
|
|
2326
|
+
type,
|
|
2327
|
+
...payload
|
|
2328
|
+
};
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
const submitForm$2 = formId => action$2(SUBMIT_FORM_FOR_VALIDATION, {
|
|
2332
|
+
formId
|
|
2333
|
+
});
|
|
2334
|
+
const setFormId$1 = formId => action$2(SET_FORM_ID, {
|
|
2335
|
+
formId
|
|
2336
|
+
});
|
|
2337
|
+
const setValue$1 = (formId, id, value) => action$2(SET_FIELD_VALUE, {
|
|
2338
|
+
formId,
|
|
2339
|
+
id,
|
|
2340
|
+
value
|
|
2341
|
+
});
|
|
2342
|
+
const setCheckboxValue$1 = (formId, id, value, isChecked) => action$2(SET_CHECKBOX_VALUE, {
|
|
2343
|
+
formId,
|
|
2344
|
+
id,
|
|
2345
|
+
value,
|
|
2346
|
+
isChecked
|
|
2347
|
+
});
|
|
2348
|
+
const setDateRangeValues$1 = (formId, id, dateType, value) => action$2(SET_DATE_RANGE_VALUES, {
|
|
2349
|
+
formId,
|
|
2350
|
+
id,
|
|
2351
|
+
dateType,
|
|
2352
|
+
value
|
|
2353
|
+
});
|
|
2354
|
+
const validateField$2 = (formId, id, value) => action$2(VALIDATE_FIELD, {
|
|
2355
|
+
formId,
|
|
2356
|
+
id,
|
|
2357
|
+
value
|
|
2358
|
+
});
|
|
2359
|
+
const togglePageForward$1 = (formId, pageIndex) => action$2(PAGE_FORWARD, {
|
|
2360
|
+
formId,
|
|
2361
|
+
pageIndex
|
|
2362
|
+
});
|
|
2363
|
+
const togglePageBack$1 = (formId, pageIndex) => action$2(PAGE_BACK, {
|
|
2364
|
+
formId,
|
|
2365
|
+
pageIndex
|
|
2366
|
+
});
|
|
2367
|
+
|
|
2368
|
+
var actions$2 = /*#__PURE__*/Object.freeze({
|
|
2369
|
+
__proto__: null,
|
|
2370
|
+
submitForm: submitForm$2,
|
|
2371
|
+
setFormId: setFormId$1,
|
|
2372
|
+
setValue: setValue$1,
|
|
2373
|
+
setCheckboxValue: setCheckboxValue$1,
|
|
2374
|
+
setDateRangeValues: setDateRangeValues$1,
|
|
2375
|
+
validateField: validateField$2,
|
|
2376
|
+
togglePageForward: togglePageForward$1,
|
|
2377
|
+
togglePageBack: togglePageBack$1
|
|
2378
|
+
});
|
|
2379
|
+
|
|
2380
|
+
//Brand
|
|
2381
|
+
const open_teal$1 = '#37BFA7'; //Brand dark
|
|
2382
|
+
|
|
2383
|
+
const teal_dark$1 = '#00a889'; //Primary
|
|
2384
|
+
|
|
2385
|
+
const accent_blue$1 = '#1853AC';
|
|
2386
|
+
const panel_blue$1 = '#00304D'; //Neutrals
|
|
2387
|
+
|
|
2388
|
+
const base_white$1 = '#FFF';
|
|
2389
|
+
const empress_gray$1 = '#757575';
|
|
2390
|
+
const colors$1 = {
|
|
2391
|
+
brand: open_teal$1,
|
|
2392
|
+
brandDark: teal_dark$1,
|
|
2393
|
+
primary: accent_blue$1,
|
|
2394
|
+
secondary: panel_blue$1,
|
|
2395
|
+
label: '#333',
|
|
2396
|
+
label_optional: '#666',
|
|
2397
|
+
border: '#ccc',
|
|
2398
|
+
message_link: '#333',
|
|
2399
|
+
success: '#118011',
|
|
2400
|
+
warning: '#FFB000',
|
|
2401
|
+
error: '#C63D54',
|
|
2402
|
+
required: '#C63D54',
|
|
2403
|
+
neutrals: {
|
|
2404
|
+
base_white: base_white$1,
|
|
2405
|
+
empress_gray: empress_gray$1
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
const FormStyled$1 = styled.form.withConfig({
|
|
2410
|
+
displayName: "Formstyled__FormStyled",
|
|
2411
|
+
componentId: "sc-1jn1lk9-0"
|
|
2412
|
+
})(["", ";"], ({
|
|
2413
|
+
useDefaultTheme
|
|
2414
|
+
}) => {
|
|
2415
|
+
return css(["", ""], useDefaultTheme && css(["> div:not(:first-child){margin-top:16px;}padding:0 16px;.success-message{font-size:18px;margin:0;}.visuallyHidden{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden;}label{display:inline-block;.isRequired{color:", ";}}input,textarea,select{display:block;font-family:inherit;background-color:", ";border-radius:3px;border:1px solid ", ";height:40px;padding:8px;margin-top:4px;max-width:320px;width:100%;}textarea{height:200px;resize:none;}"], colors$1.error, colors$1.neutrals.base_white, colors$1.border));
|
|
2416
|
+
});
|
|
2417
|
+
|
|
2418
|
+
const Label$1 = ({
|
|
2419
|
+
className,
|
|
2420
|
+
label,
|
|
2421
|
+
id,
|
|
2422
|
+
isRequired,
|
|
2423
|
+
isHidden
|
|
2424
|
+
}) => {
|
|
2425
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
2426
|
+
className: `${className} ${isHidden ? 'visuallyHidden' : ''}`,
|
|
2427
|
+
htmlFor: id
|
|
2428
|
+
}, label, isRequired && /*#__PURE__*/React.createElement("span", {
|
|
2429
|
+
className: "isRequired"
|
|
2430
|
+
}, "*"), isRequired && /*#__PURE__*/React.createElement("span", {
|
|
2431
|
+
className: "visuallyHidden"
|
|
2432
|
+
}, " (required)"));
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2435
|
+
Label$1.propTypes = {
|
|
2436
|
+
className: PropTypes.string,
|
|
2437
|
+
label: PropTypes.string,
|
|
2438
|
+
id: PropTypes.string,
|
|
2439
|
+
isRequired: PropTypes.bool,
|
|
2440
|
+
isHidden: PropTypes.bool
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2443
|
+
const CreateMessage$1 = (type, minLength, maxLength, currentLength, defaultLanguage) => {
|
|
2444
|
+
if (!type) return null;
|
|
2445
|
+
|
|
2446
|
+
switch (type) {
|
|
2447
|
+
case 'min':
|
|
2448
|
+
{
|
|
2449
|
+
if (!minLength) return;
|
|
2450
|
+
const minLengthVal = minLength && minLength.value;
|
|
2451
|
+
const errorMessage = minLength && minLength.message && minLength.message[defaultLanguage];
|
|
2452
|
+
const minText = `Minimum of ${minLengthVal.toString()} characters`;
|
|
2453
|
+
|
|
2454
|
+
if (errorMessage) {
|
|
2455
|
+
return errorMessage;
|
|
2456
|
+
} else {
|
|
2457
|
+
return minText;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
case 'max':
|
|
2462
|
+
{
|
|
2463
|
+
if (!maxLength) return;
|
|
2464
|
+
const maxLengthVal = maxLength && maxLength.value;
|
|
2465
|
+
const errorMessage = maxLength && maxLength.message && maxLength.message[defaultLanguage];
|
|
2466
|
+
const maxText = `Maximum of ${maxLengthVal.toString()} characters`;
|
|
2467
|
+
|
|
2468
|
+
if (errorMessage) {
|
|
2469
|
+
return errorMessage;
|
|
2470
|
+
} else {
|
|
2471
|
+
return maxText;
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
case 'between':
|
|
2476
|
+
{
|
|
2477
|
+
if (!maxLength || !minLength) return;
|
|
2478
|
+
const minLengthVal = minLength && minLength.value;
|
|
2479
|
+
const maxLengthVal = maxLength && maxLength.value;
|
|
2480
|
+
const errorMessage = minLength && minLength.message && minLength.message[defaultLanguage];
|
|
2481
|
+
const rangeText = `Between ${minLengthVal.toString()}-${maxLengthVal.toString()} characters)`;
|
|
2482
|
+
|
|
2483
|
+
if (errorMessage) {
|
|
2484
|
+
return errorMessage;
|
|
2485
|
+
} else if (currentLength < minLengthVal) {
|
|
2486
|
+
return `${(minLengthVal - currentLength).toString()} character${minLengthVal > 1 ? 's' : ''} required ${rangeText}`;
|
|
2487
|
+
} else if (currentLength > maxLengthVal) {
|
|
2488
|
+
return `${(currentLength - maxLengthVal).toString()} character${currentLength - maxLengthVal > 1 ? 's' : ''} over ${rangeText}`;
|
|
2489
|
+
} else if (currentLength) {
|
|
2490
|
+
return `${(maxLengthVal - currentLength).toString()} characters remaining ${rangeText}`;
|
|
2491
|
+
} else {
|
|
2492
|
+
return rangeText;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
default:
|
|
2497
|
+
return null;
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
const CharacterLimitStyled$1 = styled.div.withConfig({
|
|
2502
|
+
displayName: "CharacterLimit__CharacterLimitStyled",
|
|
2503
|
+
componentId: "sc-16zngav-0"
|
|
2504
|
+
})(["", ";"], ({
|
|
2505
|
+
theme,
|
|
2506
|
+
useDefaultTheme
|
|
2507
|
+
}) => {
|
|
2508
|
+
return css(["display:block;", ""], useDefaultTheme && css(["font-size:14px;color:", ";font-weight:400;line-height:24px;text-align:right;max-width:320px;width:100%;"], theme.colors.neutrals.empress_gray));
|
|
2509
|
+
});
|
|
2510
|
+
|
|
2511
|
+
const CharacterLimit$1 = ({
|
|
2512
|
+
className,
|
|
2513
|
+
value,
|
|
2514
|
+
validations,
|
|
2515
|
+
defaultLanguage,
|
|
2516
|
+
useDefaultTheme
|
|
2517
|
+
}) => {
|
|
2518
|
+
if (!validations) return null;
|
|
2519
|
+
let valueAsString = typeof value === 'number' ? value.toString() : value;
|
|
2520
|
+
const currentLength = valueAsString && valueAsString.length ? valueAsString.length : 0;
|
|
2521
|
+
const {
|
|
2522
|
+
minLength,
|
|
2523
|
+
maxLength
|
|
2524
|
+
} = validations;
|
|
2525
|
+
const hasMaxLength = maxLength && !minLength;
|
|
2526
|
+
const hasMinLength = minLength && !maxLength;
|
|
2527
|
+
const hasInBetween = minLength && maxLength;
|
|
2528
|
+
const type = hasMinLength ? 'min' : hasMaxLength ? 'max' : hasInBetween ? 'between' : null;
|
|
2529
|
+
if (!type) return null;
|
|
2530
|
+
return /*#__PURE__*/React.createElement(CharacterLimitStyled$1, {
|
|
2531
|
+
className: className,
|
|
2532
|
+
useDefaultTheme: useDefaultTheme
|
|
2533
|
+
}, CreateMessage$1(type, minLength, maxLength, currentLength, defaultLanguage));
|
|
2534
|
+
};
|
|
2535
|
+
|
|
2536
|
+
CharacterLimit$1.propTypes = {
|
|
2537
|
+
validations: PropTypes.object,
|
|
2538
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
2539
|
+
className: PropTypes.string,
|
|
2540
|
+
defaultLanguage: PropTypes.string,
|
|
2541
|
+
useDefaultTheme: PropTypes.bool
|
|
2542
|
+
};
|
|
2543
|
+
|
|
2544
|
+
const ErrorMessageStyled$1 = styled.div.withConfig({
|
|
2545
|
+
displayName: "ErrorMessage__ErrorMessageStyled",
|
|
2546
|
+
componentId: "sc-1vewdiu-0"
|
|
2547
|
+
})(["", ";"], ({
|
|
2548
|
+
theme,
|
|
2549
|
+
useDefaultTheme
|
|
2550
|
+
}) => {
|
|
2551
|
+
return css(["", ""], useDefaultTheme && css(["display:block;margin-top:8px;color:", ";"], theme.colors.error));
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2554
|
+
const ErrorMessage$1 = ({
|
|
2555
|
+
className,
|
|
2556
|
+
message,
|
|
2557
|
+
useDefaultTheme
|
|
2558
|
+
}) => {
|
|
2559
|
+
return /*#__PURE__*/React.createElement(ErrorMessageStyled$1, {
|
|
2560
|
+
className: className,
|
|
2561
|
+
useDefaultTheme: useDefaultTheme
|
|
2562
|
+
}, message);
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
ErrorMessage$1.propTypes = {
|
|
2566
|
+
className: PropTypes.string,
|
|
2567
|
+
message: PropTypes.string.isRequired,
|
|
2568
|
+
useDefaultTheme: PropTypes.bool
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2571
|
+
const TextfieldStyled$1 = styled.div.withConfig({
|
|
2572
|
+
displayName: "Textfield__TextfieldStyled",
|
|
2573
|
+
componentId: "sc-1a1c03n-0"
|
|
2574
|
+
})(["", ";"], ({
|
|
2575
|
+
isHidden
|
|
2576
|
+
}) => {
|
|
2577
|
+
return css(["display:", ";"], isHidden ? 'none' : 'block');
|
|
2578
|
+
});
|
|
2579
|
+
|
|
2580
|
+
const Textfield$1 = ({
|
|
2581
|
+
className,
|
|
2582
|
+
formId,
|
|
2583
|
+
id,
|
|
2584
|
+
label,
|
|
2585
|
+
type,
|
|
2586
|
+
setValue,
|
|
2587
|
+
validateField,
|
|
2588
|
+
validations,
|
|
2589
|
+
defaultValue,
|
|
2590
|
+
defaultLanguage,
|
|
2591
|
+
placeholder,
|
|
2592
|
+
isHidden,
|
|
2593
|
+
errors,
|
|
2594
|
+
useDefaultTheme
|
|
2595
|
+
}) => {
|
|
2596
|
+
const [showCharLimit, setShowCharLimit] = useState(false);
|
|
2597
|
+
const isRequired = validations && validations.required ? true : false;
|
|
2598
|
+
const placeholderText = placeholder && placeholder.properties && placeholder.properties.placeholderText && placeholder.properties.placeholderText[defaultLanguage];
|
|
2599
|
+
const defaultValueText = defaultValue && defaultValue[defaultLanguage] ? defaultValue[defaultLanguage] : defaultValue;
|
|
2600
|
+
|
|
2601
|
+
const _handleChange = (formId, id, value) => {
|
|
2602
|
+
setValue(formId, id, value);
|
|
2603
|
+
};
|
|
2604
|
+
|
|
2605
|
+
const _handleBlur = (formId, id, value) => {
|
|
2606
|
+
validateField(formId, id, value);
|
|
2607
|
+
setShowCharLimit(false);
|
|
2608
|
+
};
|
|
2609
|
+
|
|
2610
|
+
const _handleFocus = () => {
|
|
2611
|
+
setShowCharLimit(true);
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
return /*#__PURE__*/React.createElement(TextfieldStyled$1, {
|
|
2615
|
+
className: "textfield-container",
|
|
2616
|
+
isHidden: isHidden
|
|
2617
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
2618
|
+
id: id,
|
|
2619
|
+
label: label,
|
|
2620
|
+
isRequired: isRequired,
|
|
2621
|
+
className: "label-textfield"
|
|
2622
|
+
}), showCharLimit && /*#__PURE__*/React.createElement(CharacterLimit$1, {
|
|
2623
|
+
value: defaultValue,
|
|
2624
|
+
validations: validations,
|
|
2625
|
+
defaultLanguage: defaultLanguage,
|
|
2626
|
+
useDefaultTheme: useDefaultTheme
|
|
2627
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
2628
|
+
className: `${className ? className : ''} input-textfield`,
|
|
2629
|
+
type: type,
|
|
2630
|
+
defaultValue: defaultValueText,
|
|
2631
|
+
placeholder: placeholderText,
|
|
2632
|
+
id: id,
|
|
2633
|
+
name: id,
|
|
2634
|
+
onChange: e => _handleChange(formId, id, e.target.value),
|
|
2635
|
+
onBlur: e => _handleBlur(formId, id, e.target.value),
|
|
2636
|
+
onFocus: () => _handleFocus()
|
|
2637
|
+
}), errors && errors.length > 0 && errors.some(x => x.fieldId == id) && /*#__PURE__*/React.createElement(ErrorMessage$1, {
|
|
2638
|
+
message: errors.find(x => x.fieldId == id).message,
|
|
2639
|
+
useDefaultTheme: useDefaultTheme
|
|
2640
|
+
}));
|
|
2641
|
+
};
|
|
2642
|
+
|
|
2643
|
+
Textfield$1.propTypes = {
|
|
2644
|
+
className: PropTypes.string,
|
|
2645
|
+
formId: PropTypes.string,
|
|
2646
|
+
id: PropTypes.string,
|
|
2647
|
+
label: PropTypes.string,
|
|
2648
|
+
type: PropTypes.string,
|
|
2649
|
+
setValue: PropTypes.func,
|
|
2650
|
+
validateField: PropTypes.func,
|
|
2651
|
+
validations: PropTypes.object,
|
|
2652
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
2653
|
+
defaultLanguage: PropTypes.string,
|
|
2654
|
+
placeholder: PropTypes.object,
|
|
2655
|
+
isHidden: PropTypes.bool,
|
|
2656
|
+
errors: PropTypes.array,
|
|
2657
|
+
useDefaultTheme: PropTypes.bool
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
const Textarea$1 = ({
|
|
2661
|
+
className,
|
|
2662
|
+
formId,
|
|
2663
|
+
id,
|
|
2664
|
+
label,
|
|
2665
|
+
type,
|
|
2666
|
+
setValue,
|
|
2667
|
+
validations,
|
|
2668
|
+
defaultValue,
|
|
2669
|
+
defaultLanguage,
|
|
2670
|
+
placeholder,
|
|
2671
|
+
validateField,
|
|
2672
|
+
useDefaultTheme,
|
|
2673
|
+
errors
|
|
2674
|
+
}) => {
|
|
2675
|
+
const [showCharLimit, setShowCharLimit] = useState(false);
|
|
2676
|
+
const isRequired = validations && validations.required ? true : false;
|
|
2677
|
+
const placeholderText = placeholder && placeholder.properties && placeholder.properties.placeholderText && placeholder.properties.placeholderText[defaultLanguage];
|
|
2678
|
+
const defaultValueText = defaultValue ? defaultValue[defaultLanguage] : null;
|
|
2679
|
+
|
|
2680
|
+
const _handleChange = (formId, id, value) => {
|
|
2681
|
+
setValue(formId, id, value);
|
|
2682
|
+
};
|
|
2683
|
+
|
|
2684
|
+
const _handleBlur = (formId, id, value) => {
|
|
2685
|
+
validateField(formId, id, value);
|
|
2686
|
+
setShowCharLimit(false);
|
|
2687
|
+
};
|
|
2688
|
+
|
|
2689
|
+
const _handleFocus = () => {
|
|
2690
|
+
setShowCharLimit(true);
|
|
2691
|
+
};
|
|
2692
|
+
|
|
2693
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2694
|
+
className: "textarea-container"
|
|
2695
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
2696
|
+
id: id,
|
|
2697
|
+
label: label,
|
|
2698
|
+
isRequired: isRequired,
|
|
2699
|
+
className: "label-textarea"
|
|
2700
|
+
}), showCharLimit && /*#__PURE__*/React.createElement(CharacterLimit$1, {
|
|
2701
|
+
value: defaultValue,
|
|
2702
|
+
validations: validations,
|
|
2703
|
+
defaultLanguage: defaultLanguage,
|
|
2704
|
+
useDefaultTheme: useDefaultTheme
|
|
2705
|
+
}), /*#__PURE__*/React.createElement("textarea", {
|
|
2706
|
+
className: `${className ? className : ''} input-textarea`,
|
|
2707
|
+
type: type,
|
|
2708
|
+
id: id,
|
|
2709
|
+
defaultValue: defaultValueText,
|
|
2710
|
+
placeholder: placeholderText,
|
|
2711
|
+
onChange: e => _handleChange(formId, id, e.target.value),
|
|
2712
|
+
onBlur: e => _handleBlur(formId, id, e.target.value),
|
|
2713
|
+
onFocus: () => _handleFocus()
|
|
2714
|
+
}), errors && errors.length > 0 && errors.some(x => x.fieldId == id) && /*#__PURE__*/React.createElement(ErrorMessage$1, {
|
|
2715
|
+
message: errors.find(x => x.fieldId == id).message,
|
|
2716
|
+
useDefaultTheme: useDefaultTheme
|
|
2717
|
+
}));
|
|
2718
|
+
};
|
|
2719
|
+
|
|
2720
|
+
Textarea$1.propTypes = {
|
|
2721
|
+
className: PropTypes.string,
|
|
2722
|
+
formId: PropTypes.string,
|
|
2723
|
+
id: PropTypes.string,
|
|
2724
|
+
label: PropTypes.string,
|
|
2725
|
+
type: PropTypes.string,
|
|
2726
|
+
setValue: PropTypes.func,
|
|
2727
|
+
validations: PropTypes.object,
|
|
2728
|
+
defaultValue: PropTypes.object,
|
|
2729
|
+
defaultLanguage: PropTypes.string,
|
|
2730
|
+
placeholder: PropTypes.object,
|
|
2731
|
+
validateField: PropTypes.func,
|
|
2732
|
+
useDefaultTheme: PropTypes.bool,
|
|
2733
|
+
errors: PropTypes.array
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2736
|
+
const HiddenField$1 = ({
|
|
2737
|
+
className,
|
|
2738
|
+
id,
|
|
2739
|
+
label,
|
|
2740
|
+
type,
|
|
2741
|
+
defaultValue,
|
|
2742
|
+
defaultLanguage,
|
|
2743
|
+
placeholder
|
|
2744
|
+
}) => {
|
|
2745
|
+
return /*#__PURE__*/React.createElement(Textfield$1, {
|
|
2746
|
+
type: type,
|
|
2747
|
+
label: label,
|
|
2748
|
+
id: id,
|
|
2749
|
+
defaultValue: defaultValue,
|
|
2750
|
+
defaultLanguage: defaultLanguage,
|
|
2751
|
+
placeholder: placeholder,
|
|
2752
|
+
className: className,
|
|
2753
|
+
isHidden: true
|
|
2754
|
+
});
|
|
2755
|
+
};
|
|
2756
|
+
|
|
2757
|
+
HiddenField$1.propTypes = {
|
|
2758
|
+
className: PropTypes.string,
|
|
2759
|
+
id: PropTypes.string,
|
|
2760
|
+
label: PropTypes.string,
|
|
2761
|
+
type: PropTypes.string,
|
|
2762
|
+
defaultValue: PropTypes.object,
|
|
2763
|
+
defaultLanguage: PropTypes.string,
|
|
2764
|
+
placeholder: PropTypes.object
|
|
2765
|
+
};
|
|
2766
|
+
|
|
2767
|
+
const Dropdown$1 = ({
|
|
2768
|
+
className,
|
|
2769
|
+
formId,
|
|
2770
|
+
id,
|
|
2771
|
+
validations,
|
|
2772
|
+
defaultValue,
|
|
2773
|
+
defaultLanguage,
|
|
2774
|
+
label,
|
|
2775
|
+
setValue
|
|
2776
|
+
}) => {
|
|
2777
|
+
if (!validations) return null;
|
|
2778
|
+
const isRequired = validations && validations.required ? true : false;
|
|
2779
|
+
const ddValues = validations && validations.allowedValues && validations.allowedValues.values;
|
|
2780
|
+
|
|
2781
|
+
const _handleChange = (formId, id, value) => {
|
|
2782
|
+
setValue(formId, id, value);
|
|
2783
|
+
};
|
|
2784
|
+
|
|
2785
|
+
if (!ddValues || ddValues.length < 1) return null;
|
|
2786
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
2787
|
+
className: "dropdown-container"
|
|
2788
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
2789
|
+
id: id,
|
|
2790
|
+
label: label,
|
|
2791
|
+
isRequired: isRequired,
|
|
2792
|
+
className: "label-dropdown"
|
|
2793
|
+
}), /*#__PURE__*/React.createElement("select", {
|
|
2794
|
+
name: id,
|
|
2795
|
+
id: id,
|
|
2796
|
+
className: `${className ? className : ''} select-dropdown`,
|
|
2797
|
+
defaultValue: defaultValue,
|
|
2798
|
+
onBlur: e => _handleChange(formId, id, e.target.value)
|
|
2799
|
+
}, ddValues.map((val, idx) => {
|
|
2800
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
2801
|
+
key: `${val[defaultLanguage]}-${idx}`,
|
|
2802
|
+
value: val[defaultLanguage],
|
|
2803
|
+
className: "option-dropdown"
|
|
2804
|
+
}, val[defaultLanguage]);
|
|
2805
|
+
})));
|
|
2806
|
+
};
|
|
2807
|
+
|
|
2808
|
+
Dropdown$1.propTypes = {
|
|
2809
|
+
className: PropTypes.string,
|
|
2810
|
+
formId: PropTypes.string,
|
|
2811
|
+
setValue: PropTypes.func,
|
|
2812
|
+
id: PropTypes.string,
|
|
2813
|
+
validations: PropTypes.object,
|
|
2814
|
+
defaultValue: PropTypes.string,
|
|
2815
|
+
label: PropTypes.string,
|
|
2816
|
+
defaultLanguage: PropTypes.string
|
|
2817
|
+
};
|
|
2818
|
+
|
|
2819
|
+
const CheckboxStyled$1 = styled.div.withConfig({
|
|
2820
|
+
displayName: "Checkbox__CheckboxStyled",
|
|
2821
|
+
componentId: "s8ewuf-0"
|
|
2822
|
+
})(["", ";"], ({
|
|
2823
|
+
useDefaultTheme
|
|
2824
|
+
}) => {
|
|
2825
|
+
return css(["", ""], useDefaultTheme && css([".checkbox-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
|
|
2826
|
+
});
|
|
2827
|
+
|
|
2828
|
+
const Checkbox$1 = ({
|
|
2829
|
+
className,
|
|
2830
|
+
formId,
|
|
2831
|
+
setCheckboxValue,
|
|
2832
|
+
id,
|
|
2833
|
+
type,
|
|
2834
|
+
label,
|
|
2835
|
+
validations,
|
|
2836
|
+
defaultValue,
|
|
2837
|
+
name,
|
|
2838
|
+
defaultLanguage,
|
|
2839
|
+
useDefaultTheme
|
|
2840
|
+
}) => {
|
|
2841
|
+
// NF change rules of hooks
|
|
2842
|
+
let isDefaultChecked = defaultValue && defaultValue[defaultLanguage];
|
|
2843
|
+
const [isChecked, setIsChecked] = useState(isDefaultChecked || '');
|
|
2844
|
+
|
|
2845
|
+
switch (type) {
|
|
2846
|
+
case 'multiple':
|
|
2847
|
+
{
|
|
2848
|
+
if (!validations) return null;
|
|
2849
|
+
const isRequired = validations && validations.required ? true : false;
|
|
2850
|
+
const cbValues = validations && validations.allowedValues && validations.allowedValues.values;
|
|
2851
|
+
|
|
2852
|
+
const _handleChange = (value, isChecked) => {
|
|
2853
|
+
setCheckboxValue(formId, id, value, isChecked);
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2856
|
+
if (!cbValues || cbValues.length < 1) return null;
|
|
2857
|
+
return /*#__PURE__*/React.createElement(CheckboxStyled$1, {
|
|
2858
|
+
className: `checkbox-container`,
|
|
2859
|
+
useDefaultTheme: useDefaultTheme
|
|
2860
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
2861
|
+
id: id,
|
|
2862
|
+
label: label,
|
|
2863
|
+
isRequired: isRequired,
|
|
2864
|
+
className: "label-checkbox-container"
|
|
2865
|
+
}), cbValues.map((val, idx) => {
|
|
2866
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
2867
|
+
key: idx,
|
|
2868
|
+
className: "checkbox-wrapper"
|
|
2869
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
2870
|
+
type: "checkbox",
|
|
2871
|
+
id: `checkbox-${idx}`,
|
|
2872
|
+
name: `checkbox-${idx}`,
|
|
2873
|
+
value: val[defaultLanguage],
|
|
2874
|
+
className: `${className ? className : ''} input-checkbox`,
|
|
2875
|
+
onChange: e => _handleChange(e.target.value, e.target.checked)
|
|
2876
|
+
}), /*#__PURE__*/React.createElement(Label$1, {
|
|
2877
|
+
id: `checkbox-${idx}`,
|
|
2878
|
+
label: val[defaultLanguage],
|
|
2879
|
+
className: "label-checkbox"
|
|
2880
|
+
}));
|
|
2881
|
+
}));
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
case 'single':
|
|
2885
|
+
{
|
|
2886
|
+
const _handleChange = isChecked => {
|
|
2887
|
+
setIsChecked(isChecked);
|
|
2888
|
+
setCheckboxValue(formId, id, isChecked);
|
|
2889
|
+
};
|
|
2890
|
+
|
|
2891
|
+
return /*#__PURE__*/React.createElement(CheckboxStyled$1, {
|
|
2892
|
+
className: `checkbox-container`,
|
|
2893
|
+
useDefaultTheme: useDefaultTheme
|
|
2894
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
2895
|
+
className: "checkbox-wrapper"
|
|
2896
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
2897
|
+
type: "checkbox",
|
|
2898
|
+
id: id,
|
|
2899
|
+
name: `checkbox-${id}`,
|
|
2900
|
+
value: name[defaultLanguage],
|
|
2901
|
+
checked: isChecked,
|
|
2902
|
+
className: `${className ? className : ''} input-checkbox`,
|
|
2903
|
+
onChange: e => _handleChange(e.target.checked)
|
|
2904
|
+
}), /*#__PURE__*/React.createElement(Label$1, {
|
|
2905
|
+
id: id,
|
|
2906
|
+
label: label,
|
|
2907
|
+
className: "label-checkbox"
|
|
2908
|
+
})));
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
|
|
2913
|
+
Checkbox$1.propTypes = {
|
|
2914
|
+
className: PropTypes.string,
|
|
2915
|
+
formId: PropTypes.string,
|
|
2916
|
+
id: PropTypes.string,
|
|
2917
|
+
type: PropTypes.string,
|
|
2918
|
+
label: PropTypes.string,
|
|
2919
|
+
setCheckboxValue: PropTypes.func,
|
|
2920
|
+
validations: PropTypes.object,
|
|
2921
|
+
defaultLanguage: PropTypes.string,
|
|
2922
|
+
name: PropTypes.object,
|
|
2923
|
+
default: PropTypes.object
|
|
2924
|
+
};
|
|
2925
|
+
|
|
2926
|
+
const RadioButtonStyled$1 = styled.div.withConfig({
|
|
2927
|
+
displayName: "RadioButton__RadioButtonStyled",
|
|
2928
|
+
componentId: "sc-7y8c21-0"
|
|
2929
|
+
})(["", ";"], ({
|
|
2930
|
+
useDefaultTheme
|
|
2931
|
+
}) => {
|
|
2932
|
+
return css(["", ""], useDefaultTheme && css([".radio-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
|
|
2933
|
+
});
|
|
2934
|
+
|
|
2935
|
+
const RadioButton$1 = ({
|
|
2936
|
+
className,
|
|
2937
|
+
formId,
|
|
2938
|
+
setValue,
|
|
2939
|
+
id,
|
|
2940
|
+
type,
|
|
2941
|
+
label,
|
|
2942
|
+
validations,
|
|
2943
|
+
defaultLanguage,
|
|
2944
|
+
useDefaultTheme
|
|
2945
|
+
}) => {
|
|
2946
|
+
if (!validations) return null;
|
|
2947
|
+
const isRequired = validations && validations.required ? true : false;
|
|
2948
|
+
const cbValues = validations && validations.allowedValues && validations.allowedValues.values;
|
|
2949
|
+
|
|
2950
|
+
const _handleChange = (formId, id, value) => {
|
|
2951
|
+
setValue(formId, id, value);
|
|
2952
|
+
};
|
|
2953
|
+
|
|
2954
|
+
if (!cbValues || cbValues.length < 1) return null;
|
|
2955
|
+
return /*#__PURE__*/React.createElement(RadioButtonStyled$1, {
|
|
2956
|
+
className: "radio-container",
|
|
2957
|
+
useDefaultTheme: useDefaultTheme
|
|
2958
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
2959
|
+
id: id,
|
|
2960
|
+
label: label,
|
|
2961
|
+
isRequired: isRequired,
|
|
2962
|
+
className: "label-radio-container"
|
|
2963
|
+
}), cbValues.map((val, idx) => {
|
|
2964
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
2965
|
+
key: idx,
|
|
2966
|
+
className: "radio-wrapper"
|
|
2967
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
2968
|
+
type: type,
|
|
2969
|
+
id: val[defaultLanguage],
|
|
2970
|
+
name: id,
|
|
2971
|
+
value: val[defaultLanguage],
|
|
2972
|
+
className: `${className ? className : ''} input-radio`,
|
|
2973
|
+
onChange: e => _handleChange(formId, id, e.target.value)
|
|
2974
|
+
}), /*#__PURE__*/React.createElement(Label$1, {
|
|
2975
|
+
id: val[defaultLanguage],
|
|
2976
|
+
label: val[defaultLanguage],
|
|
2977
|
+
className: "label-radio"
|
|
2978
|
+
}));
|
|
2979
|
+
}));
|
|
2980
|
+
};
|
|
2981
|
+
|
|
2982
|
+
RadioButton$1.propTypes = {
|
|
2983
|
+
className: PropTypes.string,
|
|
2984
|
+
formId: PropTypes.string,
|
|
2985
|
+
setValue: PropTypes.func,
|
|
2986
|
+
id: PropTypes.string,
|
|
2987
|
+
type: PropTypes.string,
|
|
2988
|
+
label: PropTypes.string,
|
|
2989
|
+
validations: PropTypes.object,
|
|
2990
|
+
defaultLanguage: PropTypes.string,
|
|
2991
|
+
useDefaultTheme: PropTypes.bool
|
|
2992
|
+
};
|
|
2993
|
+
|
|
2994
|
+
//example date string: 2019-01-02T13:05:00 (expects ISO 8601 Datetime format yyyy-mm-ddThh:mm:ss [this is the format returned from Contensis delivery api])
|
|
2995
|
+
//yyyy > year long, eg. 2019
|
|
2996
|
+
//yy > year short, eg. 19
|
|
2997
|
+
//MMMM > month long, eg. January
|
|
2998
|
+
//MMM > month short, eg. Jan
|
|
2999
|
+
//MM > month with leading 0, eg. 01
|
|
3000
|
+
//M > month, eg. 1
|
|
3001
|
+
//dddd > day long, eg. Monday
|
|
3002
|
+
//ddd > day short, eg. Mon
|
|
3003
|
+
//dd > date with leading 0, eg. 02
|
|
3004
|
+
//d > date, eg. 2
|
|
3005
|
+
//HH > 24 hour clock hour parameter with leading 0, eg. ...T03:05:00 = 03
|
|
3006
|
+
//H > 24 hour clock hour parameter, eg. ...T03:05:00 = 3
|
|
3007
|
+
//hh > 12 hour clock hour parameter with leading 0, eg. ...T16:05:00 = 04
|
|
3008
|
+
//h > 12 hour clock hour parameter, eg. ...T16:05:00 = 4
|
|
3009
|
+
//mm > minutes with leading 0, eg. ...T16:05:00 = 05
|
|
3010
|
+
//m > minutes, eg ...T16:05:00 = 5
|
|
3011
|
+
//t > abbreviated AM / PM, e.g. A or P
|
|
3012
|
+
//tt > AM / PM, e.g. AM or PM
|
|
3013
|
+
const formatDate$1 = (date, format = 'dd MMMM yyyy') => {
|
|
3014
|
+
if (!date) return null;
|
|
3015
|
+
const dateObj = new Date(date);
|
|
3016
|
+
const dateString = date.toString().split('T');
|
|
3017
|
+
const dateArr = dateString[0].split('-');
|
|
3018
|
+
const year = dateArr[0];
|
|
3019
|
+
const month = dateArr[1];
|
|
3020
|
+
const day = dateArr[2];
|
|
3021
|
+
const dayNameInt = dateObj.getDay();
|
|
3022
|
+
const timeArr = dateString[1].split(':');
|
|
3023
|
+
const hour = timeArr[0];
|
|
3024
|
+
const minute = timeArr[1]; //convert to abstract strings to avoid character replacement along the chain, eg. Monday would match 'M' month single parameter
|
|
3025
|
+
|
|
3026
|
+
const YEAR = ['&&', '&'];
|
|
3027
|
+
const MONTH = ['££££', '£££', '££', '£'];
|
|
3028
|
+
const DAY = ['%%%%', '%%%', '%%', '%'];
|
|
3029
|
+
const HOUR24 = ['!!', '!'];
|
|
3030
|
+
const HOUR12 = ['^^', '^'];
|
|
3031
|
+
const MINUTE = ['**', '*'];
|
|
3032
|
+
const TF = ['??', '?'];
|
|
3033
|
+
let formattedDate = format.replace('yyyy', YEAR[0]).replace('yy', YEAR[1]).replace('y', '') //'y' && 'yyy' not valid
|
|
3034
|
+
.replace('MMMM', MONTH[0]).replace('MMM', MONTH[1]).replace('MM', MONTH[2]).replace('M', MONTH[3]).replace('dddd', DAY[0]).replace('ddd', DAY[1]).replace('dd', DAY[2]).replace('d', DAY[3]).replace('HH', HOUR24[0]).replace('H', HOUR24[1]).replace('hh', HOUR12[0]).replace('h', HOUR12[1]).replace('mm', MINUTE[0]).replace('m', MINUTE[1]).replace('tt', TF[0]).replace('t', TF[1]).replace(YEAR[0], year).replace(YEAR[1], year.slice(-2)).replace(MONTH[0], monthsLong$1[parseInt(month, 10)]).replace(MONTH[1], monthsShort$1[parseInt(month, 10)]).replace(MONTH[2], month).replace(MONTH[3], parseInt(month, 10)).replace(DAY[0], daysLong$1[dayNameInt]).replace(DAY[1], daysShort$1[dayNameInt]).replace(DAY[2], day).replace(DAY[3], parseInt(day, 10)).replace(HOUR24[0], hour).replace(HOUR24[1], parseInt(hour, 10)).replace(HOUR12[0], parseHour$1(hour)).replace(HOUR12[1], parseInt(parseHour$1(hour), 10)).replace(MINUTE[0], minute).replace(MINUTE[1], parseInt(minute, 10)).replace(TF[0], parseTF$1(hour)).replace(TF[1], parseTF$1(hour).slice(0, -1));
|
|
3035
|
+
return formattedDate;
|
|
3036
|
+
};
|
|
3037
|
+
|
|
3038
|
+
const monthsShort$1 = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
3039
|
+
const monthsLong$1 = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
3040
|
+
const daysShort$1 = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
3041
|
+
const daysLong$1 = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
3042
|
+
|
|
3043
|
+
const parseHour$1 = hour => {
|
|
3044
|
+
return hour > 12 ? hour - 12 : hour;
|
|
3045
|
+
};
|
|
3046
|
+
|
|
3047
|
+
const parseTF$1 = hour => {
|
|
3048
|
+
return hour > 11 ? 'PM' : 'AM';
|
|
3049
|
+
};
|
|
3050
|
+
|
|
3051
|
+
const SingleDate$1 = ({
|
|
3052
|
+
className,
|
|
3053
|
+
type,
|
|
3054
|
+
id,
|
|
3055
|
+
label,
|
|
3056
|
+
validations,
|
|
3057
|
+
setValue,
|
|
3058
|
+
formId
|
|
3059
|
+
}) => {
|
|
3060
|
+
const isRequired = validations && validations.required ? true : false;
|
|
3061
|
+
const onlyPassedDates = validations && validations.pastDateTime;
|
|
3062
|
+
const d = new Date();
|
|
3063
|
+
const todaysDate = d.toISOString();
|
|
3064
|
+
|
|
3065
|
+
const _handleChange = (formId, id, value) => {
|
|
3066
|
+
const d = new Date(value);
|
|
3067
|
+
const isoDate = d.toISOString();
|
|
3068
|
+
setValue(formId, id, isoDate);
|
|
3069
|
+
};
|
|
3070
|
+
|
|
3071
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3072
|
+
className: "date-container"
|
|
3073
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
3074
|
+
id: id,
|
|
3075
|
+
label: label,
|
|
3076
|
+
isRequired: isRequired,
|
|
3077
|
+
className: "label-date"
|
|
3078
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
3079
|
+
type: type,
|
|
3080
|
+
id: id,
|
|
3081
|
+
name: id,
|
|
3082
|
+
className: `${className ? className : ''} input-date`,
|
|
3083
|
+
max: onlyPassedDates ? formatDate$1(todaysDate, 'yyyy-MM-dd') : '',
|
|
3084
|
+
onChange: e => _handleChange(formId, id, e.target.value)
|
|
3085
|
+
}));
|
|
3086
|
+
};
|
|
3087
|
+
|
|
3088
|
+
SingleDate$1.propTypes = {
|
|
3089
|
+
className: PropTypes.string,
|
|
3090
|
+
formId: PropTypes.string,
|
|
3091
|
+
setValue: PropTypes.func,
|
|
3092
|
+
type: PropTypes.string,
|
|
3093
|
+
id: PropTypes.string,
|
|
3094
|
+
label: PropTypes.string,
|
|
3095
|
+
validations: PropTypes.object
|
|
3096
|
+
};
|
|
3097
|
+
|
|
3098
|
+
const DateRangeStyled$1 = styled.div.withConfig({
|
|
3099
|
+
displayName: "DateRange__DateRangeStyled",
|
|
3100
|
+
componentId: "hnzg32-0"
|
|
3101
|
+
})(["", ";"], ({
|
|
3102
|
+
useDefaultTheme
|
|
3103
|
+
}) => {
|
|
3104
|
+
return css(["", ""], useDefaultTheme && css([".daterange-wrapper{display:flex;flex-direction:column;input{&:first-child{margin:0 0 8px 0;}}}"]));
|
|
3105
|
+
});
|
|
3106
|
+
|
|
3107
|
+
const DateRange$1 = ({
|
|
3108
|
+
className,
|
|
3109
|
+
id,
|
|
3110
|
+
label,
|
|
3111
|
+
validations,
|
|
3112
|
+
setDateRangeValues,
|
|
3113
|
+
formId,
|
|
3114
|
+
useDefaultTheme
|
|
3115
|
+
}) => {
|
|
3116
|
+
const isRequired = validations && validations.required ? true : false;
|
|
3117
|
+
const onlyPassedDates = validations && validations.pastDateTime;
|
|
3118
|
+
const d = new Date();
|
|
3119
|
+
const todaysDate = d.toISOString();
|
|
3120
|
+
const [toDate, setToDate] = useState('');
|
|
3121
|
+
const [fromDate, setFromDate] = useState('');
|
|
3122
|
+
|
|
3123
|
+
const _handleDateChange = (dateType, formId, id, value) => {
|
|
3124
|
+
_updateDateProps(dateType, value);
|
|
3125
|
+
|
|
3126
|
+
const d = new Date(value);
|
|
3127
|
+
const isoDate = d.toISOString();
|
|
3128
|
+
setDateRangeValues(formId, id, dateType, isoDate);
|
|
3129
|
+
};
|
|
3130
|
+
|
|
3131
|
+
const _updateDateProps = (type, date) => {
|
|
3132
|
+
switch (type) {
|
|
3133
|
+
case 'from':
|
|
3134
|
+
{
|
|
3135
|
+
const d = new Date(date);
|
|
3136
|
+
const newDate = d.toISOString();
|
|
3137
|
+
setFromDate(newDate);
|
|
3138
|
+
break;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
case 'to':
|
|
3142
|
+
{
|
|
3143
|
+
const d = new Date(date);
|
|
3144
|
+
const newDate = d.toISOString();
|
|
3145
|
+
setToDate(newDate);
|
|
3146
|
+
break;
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
default:
|
|
3150
|
+
return;
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
|
|
3154
|
+
return /*#__PURE__*/React.createElement(DateRangeStyled$1, {
|
|
3155
|
+
className: `daterange-container`,
|
|
3156
|
+
useDefaultTheme: useDefaultTheme
|
|
3157
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
3158
|
+
id: id,
|
|
3159
|
+
label: label,
|
|
3160
|
+
isRequired: isRequired
|
|
3161
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
3162
|
+
className: "daterange-wrapper"
|
|
3163
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
3164
|
+
id: "date-from",
|
|
3165
|
+
label: "Date from",
|
|
3166
|
+
isHidden: true,
|
|
3167
|
+
className: "label-daterange"
|
|
3168
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
3169
|
+
type: "date",
|
|
3170
|
+
id: "date-from",
|
|
3171
|
+
name: id,
|
|
3172
|
+
max: onlyPassedDates && !toDate ? formatDate$1(todaysDate, 'yyyy-MM-dd') : onlyPassedDates && toDate ? formatDate$1(toDate, 'yyyy-MM-dd') : toDate ? formatDate$1(toDate, 'yyyy-MM-dd') : '',
|
|
3173
|
+
className: `${className ? className : ''} input-daterange`,
|
|
3174
|
+
onChange: e => _handleDateChange('from', formId, id, e.target.value)
|
|
3175
|
+
}), /*#__PURE__*/React.createElement(Label$1, {
|
|
3176
|
+
id: "date-to",
|
|
3177
|
+
label: "Date to",
|
|
3178
|
+
isHidden: true,
|
|
3179
|
+
className: "label-daterange"
|
|
3180
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
3181
|
+
type: "date",
|
|
3182
|
+
id: "date-to",
|
|
3183
|
+
name: id,
|
|
3184
|
+
max: onlyPassedDates ? formatDate$1(todaysDate, 'yyyy-MM-dd') : '',
|
|
3185
|
+
min: formatDate$1(fromDate, 'yyyy-MM-dd'),
|
|
3186
|
+
className: `${className ? className : ''} input-daterange`,
|
|
3187
|
+
onChange: e => _handleDateChange('to', formId, id, e.target.value)
|
|
3188
|
+
})));
|
|
3189
|
+
};
|
|
3190
|
+
|
|
3191
|
+
DateRange$1.propTypes = {
|
|
3192
|
+
className: PropTypes.string,
|
|
3193
|
+
formId: PropTypes.string,
|
|
3194
|
+
setDateRangeValues: PropTypes.func,
|
|
3195
|
+
type: PropTypes.string,
|
|
3196
|
+
id: PropTypes.string,
|
|
3197
|
+
label: PropTypes.string,
|
|
3198
|
+
validations: PropTypes.object,
|
|
3199
|
+
useDefaultTheme: PropTypes.bool
|
|
3200
|
+
};
|
|
3201
|
+
|
|
3202
|
+
const EntryPickerStyled$1 = styled.div.withConfig({
|
|
3203
|
+
displayName: "EntryPicker__EntryPickerStyled",
|
|
3204
|
+
componentId: "svnu18-0"
|
|
3205
|
+
})(["", ";"], ({
|
|
3206
|
+
useDefaultTheme
|
|
3207
|
+
}) => {
|
|
3208
|
+
return css(["", ""], useDefaultTheme && css([".radio-wrapper,.checkbox-wrapper{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;input{height:auto;width:auto;margin:0 4px 0 0;}label{display:inline-block;}}"]));
|
|
3209
|
+
});
|
|
3210
|
+
|
|
3211
|
+
const EntryPicker$1 = ({
|
|
3212
|
+
className,
|
|
3213
|
+
results,
|
|
3214
|
+
id,
|
|
3215
|
+
label,
|
|
3216
|
+
validations,
|
|
3217
|
+
type,
|
|
3218
|
+
useDefaultTheme,
|
|
3219
|
+
setValue,
|
|
3220
|
+
formId
|
|
3221
|
+
}) => {
|
|
3222
|
+
if (!results || results.length > 3) return null;
|
|
3223
|
+
const isRequired = validations && validations.required ? true : false;
|
|
3224
|
+
let valArr = [];
|
|
3225
|
+
|
|
3226
|
+
const _handleChange = (formId, id, value, isChecked) => {
|
|
3227
|
+
if (type === 'checkbox') {
|
|
3228
|
+
if (isChecked) {
|
|
3229
|
+
valArr.push(value);
|
|
3230
|
+
} else if (!isChecked) {
|
|
3231
|
+
valArr = valArr.filter(valItem => valItem !== value);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
setValue(formId, id, valArr);
|
|
3235
|
+
} else {
|
|
3236
|
+
setValue(formId, id, value);
|
|
3237
|
+
}
|
|
3238
|
+
};
|
|
3239
|
+
|
|
3240
|
+
return /*#__PURE__*/React.createElement(EntryPickerStyled$1, {
|
|
3241
|
+
className: `${type}-container`,
|
|
3242
|
+
useDefaultTheme: useDefaultTheme
|
|
3243
|
+
}, /*#__PURE__*/React.createElement(Label$1, {
|
|
3244
|
+
id: id,
|
|
3245
|
+
label: label,
|
|
3246
|
+
isRequired: isRequired,
|
|
3247
|
+
className: `label-${type}-container`
|
|
3248
|
+
}), results.map((res, idx) => {
|
|
3249
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
3250
|
+
key: idx,
|
|
3251
|
+
className: `${type}-wrapper`
|
|
3252
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
3253
|
+
type: type,
|
|
3254
|
+
id: res.entryTitle,
|
|
3255
|
+
value: res.entryTitle,
|
|
3256
|
+
name: id,
|
|
3257
|
+
className: `${className ? className : ''} input-${type}`,
|
|
3258
|
+
onChange: e => _handleChange(formId, id, e.target.value, e.target.checked)
|
|
3259
|
+
}), /*#__PURE__*/React.createElement(Label$1, {
|
|
3260
|
+
id: res.entryTitle,
|
|
3261
|
+
label: res.entryTitle,
|
|
3262
|
+
className: `label-${type}`
|
|
3263
|
+
}));
|
|
3264
|
+
}));
|
|
3265
|
+
};
|
|
3266
|
+
|
|
3267
|
+
EntryPicker$1.propTypes = {
|
|
3268
|
+
className: PropTypes.string,
|
|
3269
|
+
results: PropTypes.array,
|
|
3270
|
+
id: PropTypes.string,
|
|
3271
|
+
label: PropTypes.string,
|
|
3272
|
+
validations: PropTypes.object,
|
|
3273
|
+
type: PropTypes.string,
|
|
3274
|
+
useDefaultTheme: PropTypes.bool,
|
|
3275
|
+
setValue: PropTypes.func,
|
|
3276
|
+
formId: PropTypes.string
|
|
3277
|
+
};
|
|
3278
|
+
|
|
3279
|
+
const FormComposer$1 = ({
|
|
3280
|
+
fields,
|
|
3281
|
+
formData,
|
|
3282
|
+
formId,
|
|
3283
|
+
setValue,
|
|
3284
|
+
setDateRangeValues,
|
|
3285
|
+
validateField,
|
|
3286
|
+
defaultLanguage,
|
|
3287
|
+
errors,
|
|
3288
|
+
useDefaultTheme,
|
|
3289
|
+
entries,
|
|
3290
|
+
setCheckboxValue
|
|
3291
|
+
}) => {
|
|
3292
|
+
if (!fields || fields.length < 1) return null; //const arrayOfFields = Object.entries(fields).map(f => f[1]);
|
|
3293
|
+
|
|
3294
|
+
return fields.map((field, idx) => {
|
|
3295
|
+
if (!field) return null;
|
|
3296
|
+
|
|
3297
|
+
switch (field.type) {
|
|
3298
|
+
case 'number':
|
|
3299
|
+
case 'textfield':
|
|
3300
|
+
{
|
|
3301
|
+
return /*#__PURE__*/React.createElement(Textfield$1, {
|
|
3302
|
+
key: `${field.id}-${idx}`,
|
|
3303
|
+
type: field.type,
|
|
3304
|
+
id: field.id,
|
|
3305
|
+
label: field.name && field.name[defaultLanguage],
|
|
3306
|
+
formId: formId,
|
|
3307
|
+
setValue: setValue,
|
|
3308
|
+
validations: field.validations,
|
|
3309
|
+
validateField: validateField,
|
|
3310
|
+
defaultLanguage: defaultLanguage,
|
|
3311
|
+
defaultValue: formData && formData[field.id] || field.default,
|
|
3312
|
+
placeholder: field.editor,
|
|
3313
|
+
errors: errors,
|
|
3314
|
+
useDefaultTheme: useDefaultTheme
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
case 'textarea':
|
|
3319
|
+
{
|
|
3320
|
+
return /*#__PURE__*/React.createElement(Textarea$1, {
|
|
3321
|
+
key: `${field.id}-${idx}`,
|
|
3322
|
+
type: field.type,
|
|
3323
|
+
id: field.id,
|
|
3324
|
+
label: field.name && field.name[defaultLanguage],
|
|
3325
|
+
formId: formId,
|
|
3326
|
+
setValue: setValue,
|
|
3327
|
+
validations: field.validations,
|
|
3328
|
+
defaultLanguage: defaultLanguage,
|
|
3329
|
+
defaultValue: field.default,
|
|
3330
|
+
placeholder: field.editor,
|
|
3331
|
+
validateField: validateField,
|
|
3332
|
+
useDefaultTheme: useDefaultTheme,
|
|
3333
|
+
errors: errors
|
|
3334
|
+
});
|
|
3335
|
+
}
|
|
3336
|
+
|
|
3337
|
+
case 'dropdown':
|
|
3338
|
+
{
|
|
3339
|
+
return /*#__PURE__*/React.createElement(Dropdown$1, {
|
|
3340
|
+
key: `${field.id}-${idx}`,
|
|
3341
|
+
id: field.id,
|
|
3342
|
+
label: field.name && field.name[defaultLanguage],
|
|
3343
|
+
validations: field.validations,
|
|
3344
|
+
defaultLanguage: defaultLanguage,
|
|
3345
|
+
defaultValue: field.default,
|
|
3346
|
+
formId: formId,
|
|
3347
|
+
setValue: setValue,
|
|
3348
|
+
useDefaultTheme: useDefaultTheme
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
case 'checkbox':
|
|
3353
|
+
{
|
|
3354
|
+
return /*#__PURE__*/React.createElement(Checkbox$1, {
|
|
3355
|
+
key: `${field.id}-${idx}`,
|
|
3356
|
+
id: field.id,
|
|
3357
|
+
name: field.name,
|
|
3358
|
+
label: field.name && field.name[defaultLanguage],
|
|
3359
|
+
validations: field.validations,
|
|
3360
|
+
defaultLanguage: defaultLanguage,
|
|
3361
|
+
setValue: setValue,
|
|
3362
|
+
formId: formId,
|
|
3363
|
+
defaultValue: formData && formData[field.id] || field.default,
|
|
3364
|
+
type: field.dataType === 'boolean' ? 'single' : 'multiple',
|
|
3365
|
+
useDefaultTheme: useDefaultTheme,
|
|
3366
|
+
setCheckboxValue: setCheckboxValue
|
|
3367
|
+
});
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
case 'radio':
|
|
3371
|
+
{
|
|
3372
|
+
return /*#__PURE__*/React.createElement(RadioButton$1, {
|
|
3373
|
+
key: `${field.id}-${idx}`,
|
|
3374
|
+
id: field.id,
|
|
3375
|
+
type: field.type,
|
|
3376
|
+
formId: formId,
|
|
3377
|
+
setValue: setValue,
|
|
3378
|
+
label: field.name && field.name[defaultLanguage],
|
|
3379
|
+
validations: field.validations,
|
|
3380
|
+
defaultLanguage: defaultLanguage,
|
|
3381
|
+
useDefaultTheme: useDefaultTheme
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
case 'entryPicker':
|
|
3386
|
+
{
|
|
3387
|
+
const type = field.dataType === 'objectArray' ? 'checkbox' : 'radio';
|
|
3388
|
+
const results = entries && entries[field.id] && entries[field.id].items;
|
|
3389
|
+
return /*#__PURE__*/React.createElement(EntryPicker$1, {
|
|
3390
|
+
key: `${field.id}-${idx}`,
|
|
3391
|
+
type: type,
|
|
3392
|
+
results: results,
|
|
3393
|
+
id: field.id,
|
|
3394
|
+
label: field.name && field.name[defaultLanguage],
|
|
3395
|
+
useDefaultTheme: useDefaultTheme,
|
|
3396
|
+
setValue: setValue,
|
|
3397
|
+
validateField: validateField,
|
|
3398
|
+
formId: formId
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
|
|
3402
|
+
case 'date':
|
|
3403
|
+
{
|
|
3404
|
+
return /*#__PURE__*/React.createElement(SingleDate$1, {
|
|
3405
|
+
key: `${field.id}-${idx}`,
|
|
3406
|
+
type: field.type,
|
|
3407
|
+
id: field.id,
|
|
3408
|
+
label: field.name && field.name[defaultLanguage],
|
|
3409
|
+
validations: field.validations,
|
|
3410
|
+
formId: formId,
|
|
3411
|
+
setValue: setValue,
|
|
3412
|
+
useDefaultTheme: useDefaultTheme
|
|
3413
|
+
});
|
|
3414
|
+
}
|
|
3415
|
+
|
|
3416
|
+
case 'dateRange':
|
|
3417
|
+
{
|
|
3418
|
+
return /*#__PURE__*/React.createElement(DateRange$1, {
|
|
3419
|
+
key: `${field.id}-${idx}`,
|
|
3420
|
+
id: field.id,
|
|
3421
|
+
label: field.name && field.name[defaultLanguage],
|
|
3422
|
+
validations: field.validations,
|
|
3423
|
+
formId: formId,
|
|
3424
|
+
setDateRangeValues: setDateRangeValues,
|
|
3425
|
+
useDefaultTheme: useDefaultTheme
|
|
3426
|
+
});
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
case 'hidden':
|
|
3430
|
+
{
|
|
3431
|
+
return /*#__PURE__*/React.createElement(HiddenField$1, {
|
|
3432
|
+
key: `${field.id}-${idx}`,
|
|
3433
|
+
type: field.type,
|
|
3434
|
+
id: field.id,
|
|
3435
|
+
label: field.name && field.name[defaultLanguage],
|
|
3436
|
+
defaultLanguage: defaultLanguage,
|
|
3437
|
+
defaultValue: field.default,
|
|
3438
|
+
placeholder: field.editor
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
});
|
|
3443
|
+
};
|
|
3444
|
+
|
|
3445
|
+
FormComposer$1.propTypes = {
|
|
3446
|
+
fields: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3447
|
+
formData: PropTypes.object,
|
|
3448
|
+
entries: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3449
|
+
formId: PropTypes.string,
|
|
3450
|
+
setValue: PropTypes.func,
|
|
3451
|
+
validateField: PropTypes.func,
|
|
3452
|
+
setDateRangeValues: PropTypes.func,
|
|
3453
|
+
defaultLanguage: PropTypes.string,
|
|
3454
|
+
errors: PropTypes.array,
|
|
3455
|
+
useDefaultTheme: PropTypes.bool,
|
|
3456
|
+
setCheckboxValue: PropTypes.func
|
|
3457
|
+
};
|
|
3458
|
+
|
|
3459
|
+
const ButtonStyled$1 = styled.button.withConfig({
|
|
3460
|
+
displayName: "Button__ButtonStyled",
|
|
3461
|
+
componentId: "hr2oup-0"
|
|
3462
|
+
})(["", ";"], ({
|
|
3463
|
+
theme,
|
|
3464
|
+
useDefaultTheme
|
|
3465
|
+
}) => {
|
|
3466
|
+
return css(["", ""], useDefaultTheme && css(["display:inline-block;cursor:pointer;margin:16px 0 0 0;padding:8px 16px;border-radius:3px;border:1px solid ", ";font-family:inherit;transition:opacity 200ms ease;&:hover{opacity:0.7;}"], theme.colors.border));
|
|
3467
|
+
});
|
|
3468
|
+
|
|
3469
|
+
const Button$1 = ({
|
|
3470
|
+
className,
|
|
3471
|
+
type,
|
|
3472
|
+
text,
|
|
3473
|
+
action,
|
|
3474
|
+
useDefaultTheme
|
|
3475
|
+
}) => {
|
|
3476
|
+
return /*#__PURE__*/React.createElement(ButtonStyled$1, {
|
|
3477
|
+
className: `${className ? className : ''} btnSubmit`,
|
|
3478
|
+
type: type,
|
|
3479
|
+
onClick: () => action(),
|
|
3480
|
+
useDefaultTheme: useDefaultTheme
|
|
3481
|
+
}, text);
|
|
3482
|
+
};
|
|
3483
|
+
Button$1.propTypes = {
|
|
3484
|
+
className: PropTypes.string,
|
|
3485
|
+
type: PropTypes.string,
|
|
3486
|
+
text: PropTypes.string,
|
|
3487
|
+
action: PropTypes.func,
|
|
3488
|
+
useDefaultTheme: PropTypes.bool
|
|
3489
|
+
};
|
|
3490
|
+
|
|
3491
|
+
const ThemeContext$1 = createContext();
|
|
3492
|
+
|
|
3493
|
+
const ThemeProvider$1 = ({
|
|
3494
|
+
children,
|
|
3495
|
+
theme
|
|
3496
|
+
}) => {
|
|
3497
|
+
return /*#__PURE__*/React.createElement(ThemeContext$1.Provider, null, /*#__PURE__*/React.createElement(ThemeProvider$2, {
|
|
3498
|
+
theme: theme
|
|
3499
|
+
}, children));
|
|
3500
|
+
};
|
|
3501
|
+
|
|
3502
|
+
ThemeProvider$1.propTypes = {
|
|
3503
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
3504
|
+
theme: PropTypes.object
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
const mediaQueriesNoUnit$1 = {
|
|
3508
|
+
s: 470,
|
|
3509
|
+
ms: 640,
|
|
3510
|
+
m: 768,
|
|
3511
|
+
ml: 880,
|
|
3512
|
+
l: 1024,
|
|
3513
|
+
xl: 1200,
|
|
3514
|
+
xxl: 1366,
|
|
3515
|
+
wide: 1600
|
|
3516
|
+
};
|
|
3517
|
+
const mediaQueries$1 = {
|
|
3518
|
+
small: mediaQueriesNoUnit$1.s + 'px',
|
|
3519
|
+
msmall: mediaQueriesNoUnit$1.ms + 'px',
|
|
3520
|
+
medium: mediaQueriesNoUnit$1.m + 'px',
|
|
3521
|
+
mlarge: mediaQueriesNoUnit$1.ml + 'px',
|
|
3522
|
+
large: mediaQueriesNoUnit$1.l + 'px',
|
|
3523
|
+
xlarge: mediaQueriesNoUnit$1.xl + 'px',
|
|
3524
|
+
xxlarge: mediaQueriesNoUnit$1.xxl + 'px',
|
|
3525
|
+
wide: mediaQueriesNoUnit$1.wide + 'px'
|
|
3526
|
+
};
|
|
3527
|
+
const layout$1 = {
|
|
3528
|
+
mediaQueries: mediaQueries$1
|
|
3529
|
+
};
|
|
3530
|
+
|
|
3531
|
+
const fontFamily$1 = {
|
|
3532
|
+
Poppins: `'Poppins', Arial, sans-serif`
|
|
3533
|
+
}; //use html tag name as object key
|
|
3534
|
+
//use default object key for base styles
|
|
3535
|
+
//use media query key that corresponds with keys set on mediaQueries object from ./layout to map to relevant screen sizes
|
|
3536
|
+
//uses a mobile first approach to rules
|
|
3537
|
+
|
|
3538
|
+
const typography$1 = {
|
|
3539
|
+
default: {
|
|
3540
|
+
color: colors$1.label,
|
|
3541
|
+
font_family: fontFamily$1.Poppins,
|
|
3542
|
+
font_style: 'normal',
|
|
3543
|
+
font_weight: 400,
|
|
3544
|
+
font_size: '18px',
|
|
3545
|
+
line_height: 1.75
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
const defaultStyles$1 = typography$1.default;
|
|
3549
|
+
const typographyStyles$1 = {
|
|
3550
|
+
defaultStyles: defaultStyles$1
|
|
3551
|
+
}; // function generateTypeStyles(obj) {
|
|
3552
|
+
// return Object.keys(obj)
|
|
3553
|
+
// .map(mq => {
|
|
3554
|
+
// const props = generateProps(obj[mq]);
|
|
3555
|
+
// if (mq === 'default') {
|
|
3556
|
+
// return `${props.join(' ')}`;
|
|
3557
|
+
// } else {
|
|
3558
|
+
// return `@media only screen and (min-width:${
|
|
3559
|
+
// mediaQueries[mq]
|
|
3560
|
+
// }){${props.join('')}}`;
|
|
3561
|
+
// }
|
|
3562
|
+
// })
|
|
3563
|
+
// .join('');
|
|
3564
|
+
// }
|
|
3565
|
+
// function generateProps(objMQ) {
|
|
3566
|
+
// let props = [];
|
|
3567
|
+
// Object.keys(objMQ).map(prop => {
|
|
3568
|
+
// props.push(`${prop.split('_').join('-')}: ${objMQ[prop]};`);
|
|
3569
|
+
// });
|
|
3570
|
+
// return props;
|
|
3571
|
+
// }
|
|
3572
|
+
|
|
3573
|
+
const defaultTheme$1 = {
|
|
3574
|
+
layout: layout$1,
|
|
3575
|
+
typographyStyles: typographyStyles$1,
|
|
3576
|
+
typography: typography$1,
|
|
3577
|
+
colors: colors$1
|
|
3578
|
+
};
|
|
3579
|
+
|
|
3580
|
+
const divStyles$1 = {
|
|
3581
|
+
display: 'flex',
|
|
3582
|
+
height: '100vh',
|
|
3583
|
+
alignItems: 'center',
|
|
3584
|
+
justifyContent: 'center',
|
|
3585
|
+
flexDirection: 'Column'
|
|
3586
|
+
};
|
|
3587
|
+
const svgStyles$1 = {
|
|
3588
|
+
width: '80px',
|
|
3589
|
+
height: '80px'
|
|
3590
|
+
};
|
|
3591
|
+
const headingStyles$1 = {
|
|
3592
|
+
margin: '0',
|
|
3593
|
+
fontSize: '16px'
|
|
3594
|
+
};
|
|
3595
|
+
const Loading$1 = () => {
|
|
3596
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
3597
|
+
style: divStyles$1
|
|
3598
|
+
}, /*#__PURE__*/React.createElement("h3", {
|
|
3599
|
+
style: headingStyles$1
|
|
3600
|
+
}, "Loading..."), /*#__PURE__*/React.createElement("svg", {
|
|
3601
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3602
|
+
className: "lds-spinner",
|
|
3603
|
+
preserveAspectRatio: "xMidYMid",
|
|
3604
|
+
viewBox: "0 0 100 100",
|
|
3605
|
+
style: svgStyles$1
|
|
3606
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
3607
|
+
width: "6",
|
|
3608
|
+
height: "12",
|
|
3609
|
+
x: "47",
|
|
3610
|
+
y: "24",
|
|
3611
|
+
fill: "#DE1C8F",
|
|
3612
|
+
rx: "9",
|
|
3613
|
+
ry: "5"
|
|
3614
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3615
|
+
attributeName: "opacity",
|
|
3616
|
+
begin: "-0.9166666666666666s",
|
|
3617
|
+
dur: "1s",
|
|
3618
|
+
keyTimes: "0;1",
|
|
3619
|
+
repeatCount: "indefinite",
|
|
3620
|
+
values: "1;0"
|
|
3621
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3622
|
+
width: "6",
|
|
3623
|
+
height: "12",
|
|
3624
|
+
x: "47",
|
|
3625
|
+
y: "24",
|
|
3626
|
+
fill: "#DE1C8F",
|
|
3627
|
+
rx: "9",
|
|
3628
|
+
ry: "5",
|
|
3629
|
+
transform: "rotate(30 50 50)"
|
|
3630
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3631
|
+
attributeName: "opacity",
|
|
3632
|
+
begin: "-0.8333333333333334s",
|
|
3633
|
+
dur: "1s",
|
|
3634
|
+
keyTimes: "0;1",
|
|
3635
|
+
repeatCount: "indefinite",
|
|
3636
|
+
values: "1;0"
|
|
3637
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3638
|
+
width: "6",
|
|
3639
|
+
height: "12",
|
|
3640
|
+
x: "47",
|
|
3641
|
+
y: "24",
|
|
3642
|
+
fill: "#DE1C8F",
|
|
3643
|
+
rx: "9",
|
|
3644
|
+
ry: "5",
|
|
3645
|
+
transform: "rotate(60 50 50)"
|
|
3646
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3647
|
+
attributeName: "opacity",
|
|
3648
|
+
begin: "-0.75s",
|
|
3649
|
+
dur: "1s",
|
|
3650
|
+
keyTimes: "0;1",
|
|
3651
|
+
repeatCount: "indefinite",
|
|
3652
|
+
values: "1;0"
|
|
3653
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3654
|
+
width: "6",
|
|
3655
|
+
height: "12",
|
|
3656
|
+
x: "47",
|
|
3657
|
+
y: "24",
|
|
3658
|
+
fill: "#DE1C8F",
|
|
3659
|
+
rx: "9",
|
|
3660
|
+
ry: "5",
|
|
3661
|
+
transform: "rotate(90 50 50)"
|
|
3662
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3663
|
+
attributeName: "opacity",
|
|
3664
|
+
begin: "-0.6666666666666666s",
|
|
3665
|
+
dur: "1s",
|
|
3666
|
+
keyTimes: "0;1",
|
|
3667
|
+
repeatCount: "indefinite",
|
|
3668
|
+
values: "1;0"
|
|
3669
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3670
|
+
width: "6",
|
|
3671
|
+
height: "12",
|
|
3672
|
+
x: "47",
|
|
3673
|
+
y: "24",
|
|
3674
|
+
fill: "#DE1C8F",
|
|
3675
|
+
rx: "9",
|
|
3676
|
+
ry: "5",
|
|
3677
|
+
transform: "rotate(120 50 50)"
|
|
3678
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3679
|
+
attributeName: "opacity",
|
|
3680
|
+
begin: "-0.5833333333333334s",
|
|
3681
|
+
dur: "1s",
|
|
3682
|
+
keyTimes: "0;1",
|
|
3683
|
+
repeatCount: "indefinite",
|
|
3684
|
+
values: "1;0"
|
|
3685
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3686
|
+
width: "6",
|
|
3687
|
+
height: "12",
|
|
3688
|
+
x: "47",
|
|
3689
|
+
y: "24",
|
|
3690
|
+
fill: "#DE1C8F",
|
|
3691
|
+
rx: "9",
|
|
3692
|
+
ry: "5",
|
|
3693
|
+
transform: "rotate(150 50 50)"
|
|
3694
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3695
|
+
attributeName: "opacity",
|
|
3696
|
+
begin: "-0.5s",
|
|
3697
|
+
dur: "1s",
|
|
3698
|
+
keyTimes: "0;1",
|
|
3699
|
+
repeatCount: "indefinite",
|
|
3700
|
+
values: "1;0"
|
|
3701
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3702
|
+
width: "6",
|
|
3703
|
+
height: "12",
|
|
3704
|
+
x: "47",
|
|
3705
|
+
y: "24",
|
|
3706
|
+
fill: "#DE1C8F",
|
|
3707
|
+
rx: "9",
|
|
3708
|
+
ry: "5",
|
|
3709
|
+
transform: "rotate(180 50 50)"
|
|
3710
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3711
|
+
attributeName: "opacity",
|
|
3712
|
+
begin: "-0.4166666666666667s",
|
|
3713
|
+
dur: "1s",
|
|
3714
|
+
keyTimes: "0;1",
|
|
3715
|
+
repeatCount: "indefinite",
|
|
3716
|
+
values: "1;0"
|
|
3717
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3718
|
+
width: "6",
|
|
3719
|
+
height: "12",
|
|
3720
|
+
x: "47",
|
|
3721
|
+
y: "24",
|
|
3722
|
+
fill: "#DE1C8F",
|
|
3723
|
+
rx: "9",
|
|
3724
|
+
ry: "5",
|
|
3725
|
+
transform: "rotate(210 50 50)"
|
|
3726
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3727
|
+
attributeName: "opacity",
|
|
3728
|
+
begin: "-0.3333333333333333s",
|
|
3729
|
+
dur: "1s",
|
|
3730
|
+
keyTimes: "0;1",
|
|
3731
|
+
repeatCount: "indefinite",
|
|
3732
|
+
values: "1;0"
|
|
3733
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3734
|
+
width: "6",
|
|
3735
|
+
height: "12",
|
|
3736
|
+
x: "47",
|
|
3737
|
+
y: "24",
|
|
3738
|
+
fill: "#DE1C8F",
|
|
3739
|
+
rx: "9",
|
|
3740
|
+
ry: "5",
|
|
3741
|
+
transform: "rotate(240 50 50)"
|
|
3742
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3743
|
+
attributeName: "opacity",
|
|
3744
|
+
begin: "-0.25s",
|
|
3745
|
+
dur: "1s",
|
|
3746
|
+
keyTimes: "0;1",
|
|
3747
|
+
repeatCount: "indefinite",
|
|
3748
|
+
values: "1;0"
|
|
3749
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3750
|
+
width: "6",
|
|
3751
|
+
height: "12",
|
|
3752
|
+
x: "47",
|
|
3753
|
+
y: "24",
|
|
3754
|
+
fill: "#DE1C8F",
|
|
3755
|
+
rx: "9",
|
|
3756
|
+
ry: "5",
|
|
3757
|
+
transform: "rotate(270 50 50)"
|
|
3758
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3759
|
+
attributeName: "opacity",
|
|
3760
|
+
begin: "-0.16666666666666666s",
|
|
3761
|
+
dur: "1s",
|
|
3762
|
+
keyTimes: "0;1",
|
|
3763
|
+
repeatCount: "indefinite",
|
|
3764
|
+
values: "1;0"
|
|
3765
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3766
|
+
width: "6",
|
|
3767
|
+
height: "12",
|
|
3768
|
+
x: "47",
|
|
3769
|
+
y: "24",
|
|
3770
|
+
fill: "#DE1C8F",
|
|
3771
|
+
rx: "9",
|
|
3772
|
+
ry: "5",
|
|
3773
|
+
transform: "rotate(300 50 50)"
|
|
3774
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3775
|
+
attributeName: "opacity",
|
|
3776
|
+
begin: "-0.08333333333333333s",
|
|
3777
|
+
dur: "1s",
|
|
3778
|
+
keyTimes: "0;1",
|
|
3779
|
+
repeatCount: "indefinite",
|
|
3780
|
+
values: "1;0"
|
|
3781
|
+
})), /*#__PURE__*/React.createElement("rect", {
|
|
3782
|
+
width: "6",
|
|
3783
|
+
height: "12",
|
|
3784
|
+
x: "47",
|
|
3785
|
+
y: "24",
|
|
3786
|
+
fill: "#DE1C8F",
|
|
3787
|
+
rx: "9",
|
|
3788
|
+
ry: "5",
|
|
3789
|
+
transform: "rotate(330 50 50)"
|
|
3790
|
+
}, /*#__PURE__*/React.createElement("animate", {
|
|
3791
|
+
attributeName: "opacity",
|
|
3792
|
+
begin: "0s",
|
|
3793
|
+
dur: "1s",
|
|
3794
|
+
keyTimes: "0;1",
|
|
3795
|
+
repeatCount: "indefinite",
|
|
3796
|
+
values: "1;0"
|
|
3797
|
+
}))));
|
|
3798
|
+
};
|
|
3799
|
+
Loading$1.propTypes = {};
|
|
3800
|
+
|
|
3801
|
+
const Form$1$1 = ({
|
|
3802
|
+
className,
|
|
3803
|
+
formId,
|
|
3804
|
+
fields,
|
|
3805
|
+
formData,
|
|
3806
|
+
setFormId,
|
|
3807
|
+
setValue,
|
|
3808
|
+
validateField,
|
|
3809
|
+
defaultLanguage,
|
|
3810
|
+
errors,
|
|
3811
|
+
pagingInfo,
|
|
3812
|
+
togglePageForward,
|
|
3813
|
+
togglePageBack,
|
|
3814
|
+
submitForm,
|
|
3815
|
+
status,
|
|
3816
|
+
setDateRangeValues,
|
|
3817
|
+
useDefaultTheme,
|
|
3818
|
+
entries,
|
|
3819
|
+
customSubmit,
|
|
3820
|
+
setCheckboxValue
|
|
3821
|
+
}) => {
|
|
3822
|
+
useEffect(() => {
|
|
3823
|
+
setFormId(formId);
|
|
3824
|
+
}, [formId, setFormId]); // NF change rule of hooks
|
|
29
3825
|
|
|
30
|
-
|
|
31
|
-
|
|
3826
|
+
if (!formId) return null;
|
|
3827
|
+
let formRender;
|
|
32
3828
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
3829
|
+
if (pagingInfo && pagingInfo.pageCount > 1) {
|
|
3830
|
+
const isLastPage = pagingInfo.pageCount == pagingInfo.pageIndex + 1;
|
|
3831
|
+
formRender = /*#__PURE__*/React.createElement(FormStyled$1, {
|
|
3832
|
+
className: className,
|
|
3833
|
+
id: formId,
|
|
3834
|
+
useDefaultTheme: useDefaultTheme
|
|
3835
|
+
}, status && status.isLoading || status && status.isSubmitting && /*#__PURE__*/React.createElement(Loading$1, {
|
|
3836
|
+
className: "loading"
|
|
3837
|
+
}), !status || status && !status.isLoading && !status.isSubmitting && !status.hasSuccess && /*#__PURE__*/React.createElement(React.Fragment, null, pagingInfo.pageIndex > 0 && /*#__PURE__*/React.createElement(Button$1, {
|
|
3838
|
+
type: "button",
|
|
3839
|
+
text: "Go Back",
|
|
3840
|
+
action: () => togglePageBack(formId, pagingInfo.pageIndex - 1),
|
|
3841
|
+
useDefaultTheme: useDefaultTheme
|
|
3842
|
+
}), /*#__PURE__*/React.createElement(FormComposer$1, {
|
|
3843
|
+
fields: fields,
|
|
3844
|
+
formData: formData,
|
|
3845
|
+
formId: formId,
|
|
3846
|
+
setValue: setValue,
|
|
3847
|
+
validateField: validateField,
|
|
3848
|
+
defaultLanguage: defaultLanguage,
|
|
3849
|
+
errors: errors,
|
|
3850
|
+
pagingInfo: pagingInfo,
|
|
3851
|
+
useDefaultTheme: useDefaultTheme,
|
|
3852
|
+
entries: entries,
|
|
3853
|
+
setDateRangeValues: setDateRangeValues,
|
|
3854
|
+
setCheckboxValue: setCheckboxValue
|
|
3855
|
+
}), !isLastPage && /*#__PURE__*/React.createElement(Button$1, {
|
|
3856
|
+
type: "button",
|
|
3857
|
+
text: "Next",
|
|
3858
|
+
action: () => togglePageForward(formId, pagingInfo.pageIndex + 1),
|
|
3859
|
+
useDefaultTheme: useDefaultTheme
|
|
3860
|
+
}), isLastPage && /*#__PURE__*/React.createElement(Button$1, {
|
|
3861
|
+
text: "Submit",
|
|
3862
|
+
type: "button",
|
|
3863
|
+
action: () => {
|
|
3864
|
+
submitForm(formId);
|
|
3865
|
+
if (customSubmit) customSubmit();
|
|
3866
|
+
},
|
|
3867
|
+
useDefaultTheme: useDefaultTheme
|
|
3868
|
+
})), status && status.hasSuccess && status.successMessage && /*#__PURE__*/React.createElement("p", {
|
|
3869
|
+
className: "success-message"
|
|
3870
|
+
}, status.successMessage));
|
|
51
3871
|
} else {
|
|
52
|
-
|
|
3872
|
+
formRender = /*#__PURE__*/React.createElement(FormStyled$1, {
|
|
3873
|
+
className: className,
|
|
3874
|
+
id: formId,
|
|
3875
|
+
useDefaultTheme: useDefaultTheme
|
|
3876
|
+
}, status && status.isLoading || status && status.isSubmitting && /*#__PURE__*/React.createElement(Loading$1, {
|
|
3877
|
+
className: "loading"
|
|
3878
|
+
}), !status || status && !status.isLoading && !status.isSubmitting && !status.hasSuccess && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormComposer$1, {
|
|
3879
|
+
fields: fields,
|
|
3880
|
+
formId: formId,
|
|
3881
|
+
setValue: setValue,
|
|
3882
|
+
setDateRangeValues: setDateRangeValues,
|
|
3883
|
+
validateField: validateField,
|
|
3884
|
+
defaultLanguage: defaultLanguage,
|
|
3885
|
+
errors: errors,
|
|
3886
|
+
useDefaultTheme: useDefaultTheme,
|
|
3887
|
+
entries: entries,
|
|
3888
|
+
setCheckboxValue: setCheckboxValue
|
|
3889
|
+
}), /*#__PURE__*/React.createElement(Button$1, {
|
|
3890
|
+
text: "Submit",
|
|
3891
|
+
type: "button",
|
|
3892
|
+
action: () => {
|
|
3893
|
+
submitForm(formId);
|
|
3894
|
+
if (customSubmit) customSubmit();
|
|
3895
|
+
},
|
|
3896
|
+
useDefaultTheme: useDefaultTheme
|
|
3897
|
+
})), status && status.hasSuccess && status.successMessage && /*#__PURE__*/React.createElement("p", {
|
|
3898
|
+
className: "success-message"
|
|
3899
|
+
}, status.successMessage));
|
|
53
3900
|
}
|
|
54
|
-
};
|
|
55
3901
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const initialFormData = {
|
|
62
|
-
formId: null,
|
|
63
|
-
data: {},
|
|
64
|
-
fields: [],
|
|
65
|
-
entries: [],
|
|
66
|
-
fieldErrors: [],
|
|
67
|
-
groups: [],
|
|
68
|
-
defaultLanguage: null,
|
|
69
|
-
pagingInfo: {
|
|
70
|
-
pageIndex: 0,
|
|
71
|
-
pageCount: 0,
|
|
72
|
-
currentPageId: null
|
|
73
|
-
},
|
|
74
|
-
status: {
|
|
75
|
-
isLoading: false,
|
|
76
|
-
isSubmitting: false,
|
|
77
|
-
hasSuccess: false,
|
|
78
|
-
successMessage: null,
|
|
79
|
-
hasError: false
|
|
80
|
-
}
|
|
3902
|
+
return /*#__PURE__*/React.createElement(ThemeProvider$1, {
|
|
3903
|
+
theme: defaultTheme$1
|
|
3904
|
+
}, formRender);
|
|
81
3905
|
};
|
|
82
|
-
let initialState = Map({
|
|
83
|
-
settings: fromJS(initialSettings)
|
|
84
|
-
});
|
|
85
|
-
var reducer = ((state = initialState, action) => {
|
|
86
|
-
switch (action.type) {
|
|
87
|
-
case SET_FORM_ID:
|
|
88
|
-
return state.setIn([action.formId], initialFormData);
|
|
89
|
-
|
|
90
|
-
case SET_FORM_DATA:
|
|
91
|
-
{
|
|
92
|
-
const fields = action.fields; //const fObj = {};
|
|
93
|
-
|
|
94
|
-
fields.map(field => {
|
|
95
|
-
field.type = MakeFieldType(field);
|
|
96
|
-
});
|
|
97
|
-
return state.setIn([fromJS(action.formId), 'fields'], fields).setIn([fromJS(action.formId), 'formId'], action.formId).setIn([fromJS(action.formId), 'groups'], action.groups).setIn([fromJS(action.formId), 'defaultLanguage'], action.defaultLanguage).setIn([fromJS(action.formId), 'status', 'isSubmitting'], false).setIn([fromJS(action.formId), 'status', 'hasSuccess'], false).setIn([fromJS(action.formId), 'status', 'hasError'], false);
|
|
98
|
-
}
|
|
99
3906
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
3907
|
+
Form$1$1.propTypes = {
|
|
3908
|
+
className: PropTypes.string,
|
|
3909
|
+
formId: PropTypes.string,
|
|
3910
|
+
fields: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3911
|
+
formData: PropTypes.object,
|
|
3912
|
+
entries: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3913
|
+
useDefaultTheme: PropTypes.bool,
|
|
3914
|
+
setFormId: PropTypes.func,
|
|
3915
|
+
setValue: PropTypes.func,
|
|
3916
|
+
setDateRangeValues: PropTypes.func,
|
|
3917
|
+
validateField: PropTypes.func,
|
|
3918
|
+
defaultLanguage: PropTypes.string,
|
|
3919
|
+
errors: PropTypes.array,
|
|
3920
|
+
pagingInfo: PropTypes.object,
|
|
3921
|
+
togglePageForward: PropTypes.func,
|
|
3922
|
+
togglePageBack: PropTypes.func,
|
|
3923
|
+
submitForm: PropTypes.func,
|
|
3924
|
+
customSubmit: PropTypes.func,
|
|
3925
|
+
status: PropTypes.object,
|
|
3926
|
+
setCheckboxValue: PropTypes.func
|
|
3927
|
+
};
|
|
113
3928
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
3929
|
+
const FormContainer$1 = ({
|
|
3930
|
+
className,
|
|
3931
|
+
formId,
|
|
3932
|
+
fields,
|
|
3933
|
+
formData,
|
|
3934
|
+
setFormId,
|
|
3935
|
+
setValue,
|
|
3936
|
+
setDateRangeValues,
|
|
3937
|
+
validateField,
|
|
3938
|
+
defaultLanguage,
|
|
3939
|
+
errors,
|
|
3940
|
+
pagingInfo,
|
|
3941
|
+
togglePageForward,
|
|
3942
|
+
togglePageBack,
|
|
3943
|
+
submitForm,
|
|
3944
|
+
status,
|
|
3945
|
+
useDefaultTheme = true,
|
|
3946
|
+
entries,
|
|
3947
|
+
setCheckboxValue,
|
|
3948
|
+
customSubmit
|
|
3949
|
+
}) => {
|
|
3950
|
+
return /*#__PURE__*/React.createElement(Form$1$1, {
|
|
3951
|
+
className: className,
|
|
3952
|
+
formId: formId,
|
|
3953
|
+
fields: fields,
|
|
3954
|
+
setFormId: setFormId,
|
|
3955
|
+
setValue: setValue,
|
|
3956
|
+
setDateRangeValues: setDateRangeValues,
|
|
3957
|
+
validateField: validateField,
|
|
3958
|
+
defaultLanguage: defaultLanguage,
|
|
3959
|
+
errors: errors,
|
|
3960
|
+
pagingInfo: pagingInfo,
|
|
3961
|
+
togglePageForward: togglePageForward,
|
|
3962
|
+
togglePageBack: togglePageBack,
|
|
3963
|
+
submitForm: submitForm,
|
|
3964
|
+
status: status,
|
|
3965
|
+
useDefaultTheme: useDefaultTheme,
|
|
3966
|
+
entries: entries,
|
|
3967
|
+
formData: formData,
|
|
3968
|
+
setCheckboxValue: setCheckboxValue,
|
|
3969
|
+
customSubmit: customSubmit
|
|
3970
|
+
});
|
|
3971
|
+
};
|
|
119
3972
|
|
|
120
|
-
|
|
121
|
-
|
|
3973
|
+
FormContainer$1.propTypes = {
|
|
3974
|
+
className: PropTypes.string,
|
|
3975
|
+
formId: PropTypes.string,
|
|
3976
|
+
fields: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3977
|
+
formData: PropTypes.object,
|
|
3978
|
+
entries: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
3979
|
+
setFormId: PropTypes.func,
|
|
3980
|
+
setDateRangeValues: PropTypes.func,
|
|
3981
|
+
setValue: PropTypes.func,
|
|
3982
|
+
useDefaultTheme: PropTypes.bool,
|
|
3983
|
+
validateField: PropTypes.func,
|
|
3984
|
+
defaultLanguage: PropTypes.string,
|
|
3985
|
+
errors: PropTypes.array,
|
|
3986
|
+
pagingInfo: PropTypes.object,
|
|
3987
|
+
togglePageForward: PropTypes.func,
|
|
3988
|
+
togglePageBack: PropTypes.func,
|
|
3989
|
+
submitForm: PropTypes.func,
|
|
3990
|
+
status: PropTypes.object,
|
|
3991
|
+
setCheckboxValue: PropTypes.func,
|
|
3992
|
+
customSubmit: PropTypes.func
|
|
3993
|
+
};
|
|
122
3994
|
|
|
123
|
-
|
|
124
|
-
|
|
3995
|
+
const mapStateToProps$1 = (state, props) => {
|
|
3996
|
+
const {
|
|
3997
|
+
formId
|
|
3998
|
+
} = props;
|
|
3999
|
+
const selectFormFields = selectPagedFields$1(formId);
|
|
4000
|
+
const selectIsLoading = makeSelectIsLoading$1(formId);
|
|
4001
|
+
const selectDefaultLang = makeSelectDefaultLang$1(formId);
|
|
4002
|
+
return state => ({
|
|
4003
|
+
fields: selectFormFields(state),
|
|
4004
|
+
loading: selectIsLoading(state),
|
|
4005
|
+
defaultLanguage: selectDefaultLang(state),
|
|
4006
|
+
errors: selectFieldErrors$1(state, formId),
|
|
4007
|
+
pagingInfo: selectPagingInfo$1(state, formId),
|
|
4008
|
+
status: selectFormStatus$1(state, formId),
|
|
4009
|
+
entries: selectEntries$1(state, formId),
|
|
4010
|
+
formData: selectPostData$1(state, formId)
|
|
4011
|
+
});
|
|
4012
|
+
};
|
|
125
4013
|
|
|
126
|
-
|
|
127
|
-
|
|
4014
|
+
const mapDispatchToProps$1 = dispatch => {
|
|
4015
|
+
return {
|
|
4016
|
+
setFormId: formId => dispatch(setFormId$1(formId)),
|
|
4017
|
+
setValue: (formId, id, value) => dispatch(setValue$1(formId, id, value)),
|
|
4018
|
+
setCheckboxValue: (formId, id, value, isChecked) => dispatch(setCheckboxValue$1(formId, id, value, isChecked)),
|
|
4019
|
+
setDateRangeValues: (formId, id, dateType, value) => dispatch(setDateRangeValues$1(formId, id, dateType, value)),
|
|
4020
|
+
validateField: (formId, id, value) => dispatch(validateField$2(formId, id, value)),
|
|
4021
|
+
togglePageForward: (formId, pageIndex) => dispatch(togglePageForward$1(formId, pageIndex)),
|
|
4022
|
+
togglePageBack: (formId, pageIndex) => dispatch(togglePageBack$1(formId, pageIndex)),
|
|
4023
|
+
submitForm: formId => dispatch(submitForm$2(formId))
|
|
4024
|
+
};
|
|
4025
|
+
};
|
|
128
4026
|
|
|
129
|
-
|
|
130
|
-
return state.setIn([fromJS(action.formId), 'status', 'isSubmitting'], action.isSubmitting);
|
|
4027
|
+
var Form$2 = connect(mapStateToProps$1, mapDispatchToProps$1)(FormContainer$1);
|
|
131
4028
|
|
|
132
|
-
|
|
133
|
-
|
|
4029
|
+
var forms = /*#__PURE__*/Object.freeze({
|
|
4030
|
+
__proto__: null,
|
|
4031
|
+
'default': Form$2,
|
|
4032
|
+
actions: actions$2,
|
|
4033
|
+
reducer: reducer,
|
|
4034
|
+
sagas: formV2Sagas$1,
|
|
4035
|
+
selectors: selectors$2,
|
|
4036
|
+
types: types$1
|
|
4037
|
+
});
|
|
134
4038
|
|
|
135
|
-
|
|
136
|
-
|
|
4039
|
+
const selectCommitRef = state => getImmutableOrJS$1(state, ['version', 'commitRef']);
|
|
4040
|
+
const selectBuildNumber = state => getImmutableOrJS$1(state, ['version', 'buildNo']);
|
|
4041
|
+
const selectVersionStatus = state => getImmutableOrJS$1(state, ['version', 'contensisVersionStatus']);
|
|
137
4042
|
|
|
138
|
-
|
|
139
|
-
|
|
4043
|
+
var version = /*#__PURE__*/Object.freeze({
|
|
4044
|
+
__proto__: null,
|
|
4045
|
+
selectCommitRef: selectCommitRef,
|
|
4046
|
+
selectBuildNumber: selectBuildNumber,
|
|
4047
|
+
selectVersionStatus: selectVersionStatus
|
|
4048
|
+
});
|
|
140
4049
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
eObj[entry.id] = entry.entries;
|
|
148
|
-
return eObj;
|
|
149
|
-
});
|
|
150
|
-
return state.setIn([action.formId, 'entries'], eObj);
|
|
151
|
-
}
|
|
4050
|
+
var types = {
|
|
4051
|
+
navigation: navigation$1$3,
|
|
4052
|
+
routing: routing$1$1,
|
|
4053
|
+
version: version$1$1,
|
|
4054
|
+
forms: forms
|
|
4055
|
+
};
|
|
152
4056
|
|
|
153
|
-
|
|
154
|
-
return state.setIn([fromJS(action.formId), 'status', 'hasError'], true).setIn([fromJS(action.formId), 'status', 'isSubmitting'], false);
|
|
4057
|
+
const loadNavigationTree = () => action$3(GET_NODE_TREE$1);
|
|
155
4058
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
4059
|
+
var navigation$1 = /*#__PURE__*/Object.freeze({
|
|
4060
|
+
__proto__: null,
|
|
4061
|
+
loadNavigationTree: loadNavigationTree
|
|
159
4062
|
});
|
|
160
4063
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return state.getIn(['forms', formId, 'fieldErrors']);
|
|
167
|
-
};
|
|
168
|
-
const selectPostData = (state, formId) => {
|
|
169
|
-
return state.getIn(['forms', formId, 'data']);
|
|
4064
|
+
var actions = {
|
|
4065
|
+
navigation: navigation$1,
|
|
4066
|
+
routing: routing$5,
|
|
4067
|
+
version: version$4,
|
|
4068
|
+
forms: forms
|
|
170
4069
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
4070
|
+
|
|
4071
|
+
var selectors = {
|
|
4072
|
+
navigation: navigation$2,
|
|
4073
|
+
routing: routing$6,
|
|
4074
|
+
version: version,
|
|
4075
|
+
forms: forms
|
|
176
4076
|
};
|
|
177
|
-
const
|
|
178
|
-
|
|
4077
|
+
const routing = {
|
|
4078
|
+
types: types.routing,
|
|
4079
|
+
actions: actions.routing,
|
|
4080
|
+
selectors: selectors.routing
|
|
179
4081
|
};
|
|
4082
|
+
|
|
4083
|
+
const selectForms = state => getImmutableOrJS$1(state, ['forms']);
|
|
4084
|
+
const selectFieldErrors = (state, formId) => getImmutableOrJS$1(state, ['forms', formId, 'fieldErrors']);
|
|
4085
|
+
const selectPostData = (state, formId) => getImmutableOrJS$1(state, ['forms', formId, 'data']);
|
|
4086
|
+
const selectFormGroups = (state, formId) => getImmutableOrJS$1(state, [('groups')]);
|
|
4087
|
+
const selectPagingInfo = (state, formId) => getImmutableOrJS$1(state, ['forms', formId, 'pagingInfo']);
|
|
4088
|
+
const selectFormStatus = (state, formId) => getImmutableOrJS$1(state, ['forms', formId, 'status']);
|
|
4089
|
+
const selectEntries = (state, formId) => getImmutableOrJS$1(state, ['forms', formId, 'entries']);
|
|
180
4090
|
const selectPagedFields = formId => createSelector([selectForms], form => {
|
|
181
|
-
const pagingInfo = form
|
|
182
|
-
const fields = form
|
|
4091
|
+
const pagingInfo = getImmutableOrJS$1(form, [formId, 'pagingInfo']);
|
|
4092
|
+
const fields = getImmutableOrJS$1(form, [formId, 'fields']);
|
|
183
4093
|
|
|
184
4094
|
if (fields && fields.length > 0 && pagingInfo && pagingInfo.pageCount > 1) {
|
|
185
4095
|
return fields.filter(f => f.groupId == pagingInfo.currentPageId);
|
|
@@ -187,9 +4097,9 @@ const selectPagedFields = formId => createSelector([selectForms], form => {
|
|
|
187
4097
|
|
|
188
4098
|
return fields;
|
|
189
4099
|
});
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
4100
|
+
const makeSelectIsLoading = formId => createSelector(selectForms, forms => getImmutableOrJS$1(forms, [formId, 'status', 'isLoading']));
|
|
4101
|
+
const makeSelectFormFields = formId => createSelector(selectForms, forms => getImmutableOrJS$1(forms, [formId, 'fields']));
|
|
4102
|
+
const makeSelectDefaultLang = formId => createSelector(selectForms, forms => getImmutableOrJS$1(forms, [formId, 'defaultLanguage']));
|
|
193
4103
|
|
|
194
4104
|
const URI = '/forms';
|
|
195
4105
|
const getFormSchema = async formId => {
|
|
@@ -315,7 +4225,23 @@ const validateInput = (field, value) => {
|
|
|
315
4225
|
}
|
|
316
4226
|
};
|
|
317
4227
|
|
|
318
|
-
const
|
|
4228
|
+
const {
|
|
4229
|
+
selectCurrentAncestors,
|
|
4230
|
+
selectCurrentPath,
|
|
4231
|
+
selectCurrentProject,
|
|
4232
|
+
selectCurrentSearch,
|
|
4233
|
+
selectIsNotFound,
|
|
4234
|
+
selectQueryStringAsObject,
|
|
4235
|
+
selectRouteEntry,
|
|
4236
|
+
selectRouteEntryContentTypeId,
|
|
4237
|
+
selectRouteEntryDepends,
|
|
4238
|
+
selectRouteEntryEntryId,
|
|
4239
|
+
selectRouteEntryID,
|
|
4240
|
+
selectRouteEntrySlug,
|
|
4241
|
+
selectRouteLoading
|
|
4242
|
+
} = routing.selectors;
|
|
4243
|
+
|
|
4244
|
+
const formV2Sagas = [takeEvery(SUBMIT_FORM_SUCCESS$1, formSuccess), takeEvery(SUBMIT_FORM_FOR_VALIDATION$1, validateForm), takeEvery(SUBMIT_FORM$1, submitForm$1), takeEvery(SET_FORM_ID$1, fetchForm), takeLatest(VALIDATE_FIELD$1, validateField$1), takeEvery(PAGE_FORWARD$1, togglePage), takeEvery(PAGE_BACK$1, togglePage), takeEvery(SET_FORM_DATA$1, getEntryPickerData), takeLatest(SET_FORM_DATA$1, setDefaultValueFields)];
|
|
319
4245
|
|
|
320
4246
|
function* validateForm(action) {
|
|
321
4247
|
const {
|
|
@@ -323,7 +4249,7 @@ function* validateForm(action) {
|
|
|
323
4249
|
} = action;
|
|
324
4250
|
yield validateAllfields(formId);
|
|
325
4251
|
yield put({
|
|
326
|
-
type: SUBMIT_FORM,
|
|
4252
|
+
type: SUBMIT_FORM$1,
|
|
327
4253
|
formId
|
|
328
4254
|
});
|
|
329
4255
|
}
|
|
@@ -355,7 +4281,7 @@ function* validateGroupfields(formId, groupId) {
|
|
|
355
4281
|
if (err) newErrors.push(err);
|
|
356
4282
|
});
|
|
357
4283
|
yield put({
|
|
358
|
-
type: SET_FIELD_ERROR,
|
|
4284
|
+
type: SET_FIELD_ERROR$1,
|
|
359
4285
|
formId: formId,
|
|
360
4286
|
value: newErrors
|
|
361
4287
|
});
|
|
@@ -378,7 +4304,7 @@ function* validateAllfields(formId) {
|
|
|
378
4304
|
if (err) newErrors.push(err);
|
|
379
4305
|
});
|
|
380
4306
|
yield put({
|
|
381
|
-
type: SET_FIELD_ERROR,
|
|
4307
|
+
type: SET_FIELD_ERROR$1,
|
|
382
4308
|
formId: formId,
|
|
383
4309
|
value: newErrors
|
|
384
4310
|
});
|
|
@@ -401,7 +4327,7 @@ function* validateSingleField(formId, fieldId, value) {
|
|
|
401
4327
|
const err = validateInput(fieldData, value);
|
|
402
4328
|
if (err) newErrors.push(err);
|
|
403
4329
|
yield put({
|
|
404
|
-
type: SET_FIELD_ERROR,
|
|
4330
|
+
type: SET_FIELD_ERROR$1,
|
|
405
4331
|
formId: formId,
|
|
406
4332
|
value: newErrors
|
|
407
4333
|
});
|
|
@@ -413,14 +4339,14 @@ function* togglePage(action) {
|
|
|
413
4339
|
pageIndex
|
|
414
4340
|
} = action;
|
|
415
4341
|
const state = yield select();
|
|
416
|
-
const formGroups = selectFormGroups(state
|
|
4342
|
+
const formGroups = selectFormGroups(state);
|
|
417
4343
|
|
|
418
|
-
if (action.type === PAGE_FORWARD) {
|
|
4344
|
+
if (action.type === PAGE_FORWARD$1) {
|
|
419
4345
|
yield validateGroupfields(formId, formGroups[pageIndex].id);
|
|
420
4346
|
}
|
|
421
4347
|
|
|
422
4348
|
yield put({
|
|
423
|
-
type: SET_CURRENT_PAGE,
|
|
4349
|
+
type: SET_CURRENT_PAGE$1,
|
|
424
4350
|
formId: formId,
|
|
425
4351
|
pageId: formGroups[pageIndex].id,
|
|
426
4352
|
pageCount: formGroups.length,
|
|
@@ -431,12 +4357,12 @@ function* togglePage(action) {
|
|
|
431
4357
|
function* fetchForm(action) {
|
|
432
4358
|
const formId = action.formId;
|
|
433
4359
|
const schema = yield getFormSchema(formId);
|
|
434
|
-
const groups = schema.groups && schema.groups.length > 0 && schema.groups.filter(group => group.id !== 'private');
|
|
4360
|
+
const groups = schema && schema.groups && schema.groups.length > 0 && schema.groups.filter(group => group.id !== 'private');
|
|
435
4361
|
|
|
436
4362
|
if (formId && schema) {
|
|
437
4363
|
if (schema.groups && schema.groups.length > 0) {
|
|
438
4364
|
yield put({
|
|
439
|
-
type: SET_CURRENT_PAGE,
|
|
4365
|
+
type: SET_CURRENT_PAGE$1,
|
|
440
4366
|
formId: formId,
|
|
441
4367
|
pageId: groups[0].id,
|
|
442
4368
|
pageIndex: 0,
|
|
@@ -445,7 +4371,7 @@ function* fetchForm(action) {
|
|
|
445
4371
|
}
|
|
446
4372
|
|
|
447
4373
|
yield put({
|
|
448
|
-
type: SET_FORM_DATA,
|
|
4374
|
+
type: SET_FORM_DATA$1,
|
|
449
4375
|
formId: formId,
|
|
450
4376
|
fields: schema.fields,
|
|
451
4377
|
groups: groups,
|
|
@@ -467,7 +4393,7 @@ function* formSuccess(action) {
|
|
|
467
4393
|
|
|
468
4394
|
if (message && message.default) {
|
|
469
4395
|
yield put({
|
|
470
|
-
type: SET_SUCCESS_MESSAGE,
|
|
4396
|
+
type: SET_SUCCESS_MESSAGE$1,
|
|
471
4397
|
message: message.default['en-GB'],
|
|
472
4398
|
formId: action.formId
|
|
473
4399
|
});
|
|
@@ -481,12 +4407,12 @@ function* submitForm$1(action) {
|
|
|
481
4407
|
|
|
482
4408
|
if (canSubmit) {
|
|
483
4409
|
yield put({
|
|
484
|
-
type: SET_SUBMITTING_FORM,
|
|
4410
|
+
type: SET_SUBMITTING_FORM$1,
|
|
485
4411
|
isSubmitting: true,
|
|
486
4412
|
formId: action.formId
|
|
487
4413
|
});
|
|
488
4414
|
const forms = yield select(selectForms);
|
|
489
|
-
const rawData = forms
|
|
4415
|
+
const rawData = forms[action.formId];
|
|
490
4416
|
const formObj = {
|
|
491
4417
|
contentType: action.formId,
|
|
492
4418
|
formPost: rawData.data
|
|
@@ -495,12 +4421,12 @@ function* submitForm$1(action) {
|
|
|
495
4421
|
|
|
496
4422
|
if (formResObj && formResObj.sys && formResObj.sys.id) {
|
|
497
4423
|
yield put({
|
|
498
|
-
type: SUBMIT_FORM_SUCCESS,
|
|
4424
|
+
type: SUBMIT_FORM_SUCCESS$1,
|
|
499
4425
|
formId: action.formId
|
|
500
4426
|
});
|
|
501
4427
|
} else {
|
|
502
4428
|
yield put({
|
|
503
|
-
type: SUBMIT_FORM_ERROR,
|
|
4429
|
+
type: SUBMIT_FORM_ERROR$1,
|
|
504
4430
|
formId: action.formId
|
|
505
4431
|
});
|
|
506
4432
|
}
|
|
@@ -513,7 +4439,7 @@ function* setDefaultValueFields(action) {
|
|
|
513
4439
|
fields,
|
|
514
4440
|
defaultLanguage
|
|
515
4441
|
} = action;
|
|
516
|
-
const entryId = yield select(
|
|
4442
|
+
const entryId = yield select(selectRouteEntryEntryId);
|
|
517
4443
|
let fieldObj = {};
|
|
518
4444
|
fields.forEach(field => {
|
|
519
4445
|
if (field.dataType == 'string' && field.default) {
|
|
@@ -533,7 +4459,7 @@ function* setDefaultValueFields(action) {
|
|
|
533
4459
|
}
|
|
534
4460
|
});
|
|
535
4461
|
yield put({
|
|
536
|
-
type: SET_DEFAULT_FIELD_VALUE,
|
|
4462
|
+
type: SET_DEFAULT_FIELD_VALUE$1,
|
|
537
4463
|
formId: formId,
|
|
538
4464
|
value: fieldObj
|
|
539
4465
|
});
|
|
@@ -558,23 +4484,13 @@ function* getEntryPickerData(action) {
|
|
|
558
4484
|
return call(getEntries, entriesObj, entry.id);
|
|
559
4485
|
}));
|
|
560
4486
|
yield put({
|
|
561
|
-
type: SET_FORM_ENTRIES,
|
|
4487
|
+
type: SET_FORM_ENTRIES$1,
|
|
562
4488
|
formId: formId,
|
|
563
4489
|
entries: entriesList
|
|
564
4490
|
});
|
|
565
4491
|
}
|
|
566
4492
|
}
|
|
567
4493
|
|
|
568
|
-
const toJS = WrappedComponent => wrappedComponentProps => {
|
|
569
|
-
const KEY = 0;
|
|
570
|
-
const VALUE = 1;
|
|
571
|
-
const propsJS = Object.entries(wrappedComponentProps).reduce((newProps, wrappedComponentProp) => {
|
|
572
|
-
newProps[wrappedComponentProp[KEY]] = Iterable.isIterable(wrappedComponentProp[VALUE]) ? wrappedComponentProp[VALUE].toJS() : wrappedComponentProp[VALUE];
|
|
573
|
-
return newProps;
|
|
574
|
-
}, {});
|
|
575
|
-
return /*#__PURE__*/React.createElement(WrappedComponent, propsJS);
|
|
576
|
-
};
|
|
577
|
-
|
|
578
4494
|
//Brand
|
|
579
4495
|
const open_teal = '#37BFA7'; //Brand dark
|
|
580
4496
|
|
|
@@ -1692,7 +5608,7 @@ const ThemeProvider = ({
|
|
|
1692
5608
|
children,
|
|
1693
5609
|
theme
|
|
1694
5610
|
}) => {
|
|
1695
|
-
return /*#__PURE__*/React.createElement(ThemeContext.Provider, null, /*#__PURE__*/React.createElement(ThemeProvider$
|
|
5611
|
+
return /*#__PURE__*/React.createElement(ThemeContext.Provider, null, /*#__PURE__*/React.createElement(ThemeProvider$2, {
|
|
1696
5612
|
theme: theme
|
|
1697
5613
|
}, children));
|
|
1698
5614
|
};
|
|
@@ -2060,7 +5976,7 @@ const Form$1 = ({
|
|
|
2060
5976
|
type: "button",
|
|
2061
5977
|
action: () => {
|
|
2062
5978
|
submitForm(formId);
|
|
2063
|
-
customSubmit();
|
|
5979
|
+
if (customSubmit) customSubmit();
|
|
2064
5980
|
},
|
|
2065
5981
|
useDefaultTheme: useDefaultTheme
|
|
2066
5982
|
})), status && status.hasSuccess && status.successMessage && /*#__PURE__*/React.createElement("p", {
|
|
@@ -2089,7 +6005,7 @@ const Form$1 = ({
|
|
|
2089
6005
|
type: "button",
|
|
2090
6006
|
action: () => {
|
|
2091
6007
|
submitForm(formId);
|
|
2092
|
-
customSubmit();
|
|
6008
|
+
if (customSubmit) customSubmit();
|
|
2093
6009
|
},
|
|
2094
6010
|
useDefaultTheme: useDefaultTheme
|
|
2095
6011
|
})), status && status.hasSuccess && status.successMessage && /*#__PURE__*/React.createElement("p", {
|
|
@@ -2131,39 +6047,39 @@ function action(type, payload = {}) {
|
|
|
2131
6047
|
};
|
|
2132
6048
|
}
|
|
2133
6049
|
|
|
2134
|
-
const submitForm = formId => action(SUBMIT_FORM_FOR_VALIDATION, {
|
|
6050
|
+
const submitForm = formId => action(SUBMIT_FORM_FOR_VALIDATION$1, {
|
|
2135
6051
|
formId
|
|
2136
6052
|
});
|
|
2137
|
-
const setFormId = formId => action(SET_FORM_ID, {
|
|
6053
|
+
const setFormId = formId => action(SET_FORM_ID$1, {
|
|
2138
6054
|
formId
|
|
2139
6055
|
});
|
|
2140
|
-
const setValue = (formId, id, value) => action(SET_FIELD_VALUE, {
|
|
6056
|
+
const setValue = (formId, id, value) => action(SET_FIELD_VALUE$1, {
|
|
2141
6057
|
formId,
|
|
2142
6058
|
id,
|
|
2143
6059
|
value
|
|
2144
6060
|
});
|
|
2145
|
-
const setCheckboxValue = (formId, id, value, isChecked) => action(SET_CHECKBOX_VALUE, {
|
|
6061
|
+
const setCheckboxValue = (formId, id, value, isChecked) => action(SET_CHECKBOX_VALUE$1, {
|
|
2146
6062
|
formId,
|
|
2147
6063
|
id,
|
|
2148
6064
|
value,
|
|
2149
6065
|
isChecked
|
|
2150
6066
|
});
|
|
2151
|
-
const setDateRangeValues = (formId, id, dateType, value) => action(SET_DATE_RANGE_VALUES, {
|
|
6067
|
+
const setDateRangeValues = (formId, id, dateType, value) => action(SET_DATE_RANGE_VALUES$1, {
|
|
2152
6068
|
formId,
|
|
2153
6069
|
id,
|
|
2154
6070
|
dateType,
|
|
2155
6071
|
value
|
|
2156
6072
|
});
|
|
2157
|
-
const validateField = (formId, id, value) => action(VALIDATE_FIELD, {
|
|
6073
|
+
const validateField = (formId, id, value) => action(VALIDATE_FIELD$1, {
|
|
2158
6074
|
formId,
|
|
2159
6075
|
id,
|
|
2160
6076
|
value
|
|
2161
6077
|
});
|
|
2162
|
-
const togglePageForward = (formId, pageIndex) => action(PAGE_FORWARD, {
|
|
6078
|
+
const togglePageForward = (formId, pageIndex) => action(PAGE_FORWARD$1, {
|
|
2163
6079
|
formId,
|
|
2164
6080
|
pageIndex
|
|
2165
6081
|
});
|
|
2166
|
-
const togglePageBack = (formId, pageIndex) => action(PAGE_BACK, {
|
|
6082
|
+
const togglePageBack = (formId, pageIndex) => action(PAGE_BACK$1, {
|
|
2167
6083
|
formId,
|
|
2168
6084
|
pageIndex
|
|
2169
6085
|
});
|
|
@@ -2266,7 +6182,7 @@ const mapDispatchToProps = dispatch => {
|
|
|
2266
6182
|
};
|
|
2267
6183
|
};
|
|
2268
6184
|
|
|
2269
|
-
connect(mapStateToProps, mapDispatchToProps)(
|
|
6185
|
+
var Form = connect(mapStateToProps, mapDispatchToProps)(FormContainer);
|
|
2270
6186
|
|
|
2271
|
-
export { reducer, formV2Sagas as sagas };
|
|
6187
|
+
export { Form as default, reducer$1 as reducer, formV2Sagas as sagas };
|
|
2272
6188
|
//# sourceMappingURL=forms.js.map
|