@zengenti/contensis-react-base 3.0.0-beta.64 → 3.0.0-beta.65

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