mod-build 4.0.76-beta.7 → 4.0.78-beta.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.78
4
+
5
+ - Updating `mergeDefaultFormFieldConfig` to be recursive and merge to nested fields (so we can wrap multiple fields in a `fieldset`).
6
+
3
7
  ## 4.0.76
4
8
 
5
9
  - Discarded usage of qs_gtm_container_id and has-qs-params function, which is no longer necessary and we will only rely on gtm_container_id that is set in site config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "4.0.76-beta.7",
3
+ "version": "4.0.78-beta.1",
4
4
  "description": "Share components for S3 sites.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -18,7 +18,9 @@ responseInterceptor(tcpaAxiosInstance);
18
18
  responseInterceptor(consentCaptureAxiosInstance);
19
19
 
20
20
  async function mergeDefaultFormFieldConfigOnSteps(defaultConfig, data, parentConfig) {
21
- if (!data || typeof data !== 'object') return;
21
+ if (!data || typeof data !== 'object') {
22
+ return;
23
+ }
22
24
 
23
25
  if (data.steps && typeof data.steps === 'object') {
24
26
  data.steps = await mergeDefaultFormFieldConfig(defaultConfig, data, parentConfig);
@@ -42,31 +44,35 @@ function mergeDefaultFormFieldConfig(defaultConfig, config, parentConfig) {
42
44
  return steps;
43
45
  }
44
46
 
45
- if (parentConfig.useAccessibleConfig) {
46
- steps.items.forEach(item => {
47
- if (item.stepContent.fields) {
48
- item.stepContent.fields = item.stepContent.fields.map(field => {
49
- if (field.attributes && field.attributes.name && defaultConfig[field.attributes.name]) {
50
- field = merge(cloneDeep(defaultConfig[field.attributes.name]), field);
51
- }
52
- return field;
53
- });
54
- }
55
- });
56
- } else {
57
- steps.items.forEach(item => {
58
- if (item.fields) {
59
- item.fields = item.fields.map(field => {
60
- if (field.name && defaultConfig[field.name]) {
61
- field = Object.assign(cloneDeep(defaultConfig[field.name]), field);
62
- }
63
- return field;
64
- });
47
+ steps.items.forEach(item => {
48
+ processFieldsInObject(defaultConfig, item);
49
+ });
50
+
51
+ return steps;
52
+ }
53
+
54
+ function processFieldsInObject(defaultConfig, obj) {
55
+ if (!obj || typeof obj !== 'object') {
56
+ return;
57
+ }
58
+
59
+ if (obj.fields && Array.isArray(obj.fields)) {
60
+ obj.fields = obj.fields.map(field => {
61
+ if (field.attributes && field.attributes.name && defaultConfig[field.attributes.name]) {
62
+ field = merge(cloneDeep(defaultConfig[field.attributes.name]), field);
65
63
  }
64
+ return field;
66
65
  });
67
66
  }
68
67
 
69
- return steps;
68
+ for (const key in obj) {
69
+ if (obj.hasOwnProperty(key)) {
70
+ const value = obj[key];
71
+ if (typeof value === 'object' && value !== null) {
72
+ processFieldsInObject(defaultConfig, value);
73
+ }
74
+ }
75
+ }
70
76
  }
71
77
 
72
78
  const getDefaultFormFieldConfig = async (config, folder = 'accessible-components') => {
@@ -283,11 +289,7 @@ export default async function(config) {
283
289
 
284
290
  if (Object.keys(config).length > 0) {
285
291
  if (!config.doNotUseDefaultFieldConfig && !tempConfigCreated) {
286
- if (config.useAccessibleConfig) {
287
- await getDefaultFormFieldConfig(config, 'accessible-components');
288
- } else {
289
- await getDefaultFormFieldConfig(config, 'shared-components');
290
- }
292
+ await getDefaultFormFieldConfig(config, 'accessible-components');
291
293
  }
292
294
  if (!config.tcpaText && config.primary_trade && !tempConfigCreated) {
293
295
  await fetchTcpaFromSitegenie(config, tempConfig, pathSubdirectory);