@plusscommunities/pluss-feature-builder-web-a 1.0.2-beta.8 → 1.0.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +8 -8
- package/package.json +11 -11
- package/src/actions/formActions.js +148 -148
- package/src/actions/wizardActions.js +166 -166
- package/src/components/listing/ListingFileInput.module.css +1 -1
- package/src/components/listing/ListingGalleryInput.module.css +2 -2
- package/src/images/full.png +0 -0
- package/src/images/fullNoTitle.png +0 -0
- package/src/images/previewWidget.png +0 -0
- package/src/images/widget.png +0 -0
- package/src/reducers/featureBuilderReducer.js +10 -4
- package/src/screens/FormLayoutStep.jsx +421 -420
- package/src/screens/FormOverviewStep.jsx +349 -349
- package/src/values.config.default.js +49 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
selectFormTitle,
|
|
3
|
+
selectFormIcon,
|
|
4
|
+
selectFormDisplayName,
|
|
5
|
+
selectFormLayout,
|
|
6
|
+
selectFormFields,
|
|
7
7
|
} from "../selectors/featureBuilderSelectors";
|
|
8
8
|
|
|
9
|
-
import { clearFormSubmissionState } from "./formActions"
|
|
9
|
+
import { clearFormSubmissionState } from "./formActions";
|
|
10
10
|
|
|
11
11
|
import { values } from "../values.config";
|
|
12
12
|
|
|
@@ -21,208 +21,208 @@ export const VALIDATE_AND_UPDATE_STEP = `${REDUCER_PREFIX}_VALIDATE_AND_UPDATE_S
|
|
|
21
21
|
|
|
22
22
|
// Mode setters
|
|
23
23
|
export const setWizardMode = (mode) => ({
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type: SET_WIZARD_MODE,
|
|
25
|
+
payload: mode,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Navigation actions
|
|
29
29
|
export const setNavigationState = (navigationState) => ({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
type: SET_NAVIGATION_STATE,
|
|
31
|
+
payload: navigationState,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export const setCurrentStep = (step, previousStep = null) => ({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
type: SET_NAVIGATION_STATE,
|
|
36
|
+
payload: {
|
|
37
|
+
currentStep: step,
|
|
38
|
+
previousStep,
|
|
39
|
+
canGoBack: step !== "welcome",
|
|
40
|
+
canGoForward: true,
|
|
41
|
+
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
export const goToStep = (step) => (dispatch, getState) => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const state = getState()[values.reducerKey];
|
|
46
|
+
const currentStep = state?.wizard?.navigation?.currentStep;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Clear form submission state when changing steps
|
|
49
|
+
dispatch(clearFormSubmissionState());
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
dispatch(setCurrentStep(step, currentStep));
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export const updateStepValidation = (step, isValid, errors = {}) => ({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
type: UPDATE_STEP_VALIDATION,
|
|
56
|
+
payload: {
|
|
57
|
+
step,
|
|
58
|
+
isValid,
|
|
59
|
+
errors,
|
|
60
|
+
},
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
export const validateAndUpdateStep = (step) => (dispatch, getState) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
// Use existing selectors to get form data
|
|
65
|
+
const state = getState();
|
|
66
|
+
const title = selectFormTitle(state);
|
|
67
|
+
const icon = selectFormIcon(state);
|
|
68
|
+
const displayName = selectFormDisplayName(state);
|
|
69
|
+
const layout = selectFormLayout(state);
|
|
70
|
+
const fields = selectFormFields(state);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
const form = { title, icon, displayName, layout, fields };
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
const { isValid, errors } = getFormValidation(form, step);
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
// If valid, mark as complete
|
|
79
|
+
if (isValid) {
|
|
80
|
+
dispatch({
|
|
81
|
+
type: MARK_STEP_COMPLETE,
|
|
82
|
+
payload: step,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
return { isValid, errors };
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
// Step completion
|
|
90
90
|
export const markStepComplete = (step) => ({
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
type: MARK_STEP_COMPLETE,
|
|
92
|
+
payload: step,
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
// Reset wizard state
|
|
96
96
|
export const resetWizardState = () => ({
|
|
97
|
-
|
|
97
|
+
type: RESET_WIZARD_STATE,
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
const getFormValidation = (form, step) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
101
|
+
// Return validation results for undefined form (prevent crashes)
|
|
102
|
+
if (!form) {
|
|
103
|
+
switch (step) {
|
|
104
|
+
case "overview":
|
|
105
|
+
return {
|
|
106
|
+
isValid: false,
|
|
107
|
+
errors: {
|
|
108
|
+
title: "Title is required",
|
|
109
|
+
displayName: "Display name is required",
|
|
110
|
+
icon: "Icon is required",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
case "fields":
|
|
114
|
+
return {
|
|
115
|
+
isValid: false,
|
|
116
|
+
errors: {
|
|
117
|
+
missingTitle: "Title field is required",
|
|
118
|
+
missingImage: "Feature image field is required",
|
|
119
|
+
fieldLabels: "Some fields are missing labels",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
case "layout":
|
|
123
|
+
return {
|
|
124
|
+
isValid: false,
|
|
125
|
+
errors: {
|
|
126
|
+
layoutType: "Layout type is required",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
default:
|
|
130
|
+
return { isValid: false, errors: {} };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
switch (step) {
|
|
135
|
+
case "overview": {
|
|
136
|
+
const hasTitle = form.title?.trim().length > 0;
|
|
137
|
+
const hasDisplayName = form.displayName?.trim().length > 0;
|
|
138
|
+
const hasIcon = form.icon?.length > 0;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
isValid: hasTitle && hasDisplayName && hasIcon,
|
|
142
|
+
errors: {
|
|
143
|
+
title: !hasTitle ? "Title is required" : null,
|
|
144
|
+
displayName: !hasDisplayName ? "Display name is required" : null,
|
|
145
|
+
icon: !hasIcon ? "Icon is required" : null,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
case "fields": {
|
|
150
|
+
const hasTitleField = form.fields?.some(
|
|
151
|
+
(field) => field.id === "mandatory-title",
|
|
152
|
+
);
|
|
153
|
+
const hasImageField = form.fields?.some(
|
|
154
|
+
(field) => field.id === "mandatory-feature-image",
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// Check each field for missing labels and create field-specific errors
|
|
158
|
+
const fieldErrors = {};
|
|
159
|
+
let allFieldsHaveLabels = true;
|
|
160
|
+
|
|
161
|
+
if (form.fields) {
|
|
162
|
+
form.fields.forEach((field) => {
|
|
163
|
+
if (
|
|
164
|
+
(field.type === "text" ||
|
|
165
|
+
field.type === "description" ||
|
|
166
|
+
field.type === "title" ||
|
|
167
|
+
field.type === "image" ||
|
|
168
|
+
field.type === "gallery" ||
|
|
169
|
+
field.type === "feature-image" ||
|
|
170
|
+
field.type === "file" ||
|
|
171
|
+
field.type === "cta") &&
|
|
172
|
+
field.values
|
|
173
|
+
) {
|
|
174
|
+
if (!field.values.label || field.values.label.trim().length === 0) {
|
|
175
|
+
fieldErrors[field.id] = "Field label is required";
|
|
176
|
+
allFieldsHaveLabels = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
isValid: hasTitleField && hasImageField && allFieldsHaveLabels,
|
|
184
|
+
errors: {
|
|
185
|
+
missingTitle: !hasTitleField ? "Title field is required" : null,
|
|
186
|
+
missingImage: !hasImageField
|
|
187
|
+
? "Feature image field is required"
|
|
188
|
+
: null,
|
|
189
|
+
...fieldErrors,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "layout": {
|
|
194
|
+
const hasLayoutType = form.layout?.type?.length > 0;
|
|
195
|
+
return {
|
|
196
|
+
isValid: hasLayoutType,
|
|
197
|
+
errors: {
|
|
198
|
+
layoutType: !hasLayoutType ? "Layout type is required" : null,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return { isValid: true, errors: {} };
|
|
204
|
+
}
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
export const setWizardModeAndSave = (mode) => (dispatch) => {
|
|
208
|
-
|
|
208
|
+
dispatch(setWizardMode(mode));
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
export const setCurrentStepAndSave =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
(step, previousStep = null) =>
|
|
213
|
+
(dispatch) => {
|
|
214
|
+
dispatch(setCurrentStep(step, previousStep));
|
|
215
|
+
};
|
|
216
216
|
|
|
217
217
|
export const updateStepValidationAndSave =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
(step, isValid, errors = {}) =>
|
|
219
|
+
(dispatch) => {
|
|
220
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
221
|
+
if (isValid) {
|
|
222
|
+
dispatch(markStepComplete(step));
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
225
|
|
|
226
226
|
export const markStepCompleteAndSave = (step) => (dispatch) => {
|
|
227
|
-
|
|
227
|
+
dispatch(markStepComplete(step));
|
|
228
228
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* Gallery container styles */
|
|
4
4
|
.galleryContainer {
|
|
5
5
|
margin-top: 0.75rem;
|
|
6
|
-
|
|
6
|
+
max-width: 200px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/* Error border wrapper */
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
.imageGrid {
|
|
23
23
|
display: grid;
|
|
24
|
-
|
|
24
|
+
grid-template-columns: repeat(4, 160px);
|
|
25
25
|
gap: 1rem;
|
|
26
26
|
margin-top: 0.5rem;
|
|
27
27
|
}
|
package/src/images/full.png
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/images/widget.png
CHANGED
|
Binary file
|
|
@@ -277,8 +277,11 @@ const formReducer = (state = INITIAL_FORM_STATE, action) => {
|
|
|
277
277
|
switch (type) {
|
|
278
278
|
case formActionTypes.SET_INITIAL_VALUES: {
|
|
279
279
|
// The actual definition data is in payload.featureDefinition.definition
|
|
280
|
-
const definitionWrapper =
|
|
281
|
-
|
|
280
|
+
const definitionWrapper =
|
|
281
|
+
(payload && payload.featureDefinition) || payload;
|
|
282
|
+
const definition =
|
|
283
|
+
(definitionWrapper && definitionWrapper.definition) ||
|
|
284
|
+
definitionWrapper;
|
|
282
285
|
|
|
283
286
|
// Validate and map definition data to form state structure
|
|
284
287
|
const mappedValues = {
|
|
@@ -513,8 +516,11 @@ const definitionReducer = (state = INITIAL_STATE.definition, action) => {
|
|
|
513
516
|
const featureDefinitionWrapper =
|
|
514
517
|
(data && data.featureDefinition) || data;
|
|
515
518
|
definition =
|
|
516
|
-
(featureDefinitionWrapper && featureDefinitionWrapper.definition) ||
|
|
517
|
-
|
|
519
|
+
(featureDefinitionWrapper && featureDefinitionWrapper.definition) ||
|
|
520
|
+
featureDefinitionWrapper;
|
|
521
|
+
definitionId =
|
|
522
|
+
(featureDefinitionWrapper && featureDefinitionWrapper.id) ||
|
|
523
|
+
values.featureId;
|
|
518
524
|
|
|
519
525
|
// Ensure fields array exists and preserves order property
|
|
520
526
|
if (definition?.fields) {
|