@plusscommunities/pluss-feature-builder-web-b 1.0.2-beta.4 → 1.0.2-beta.6

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.
@@ -46,7 +46,6 @@ import styles from "./ListingScreen.module.css";
46
46
  import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
47
47
  import { faPen, faTrash } from "@fortawesome/free-solid-svg-icons";
48
48
 
49
-
50
49
  const { Button, Text } = PlussCore.Components;
51
50
 
52
51
  const ListingScreen = (props) => {
@@ -26,7 +26,7 @@ export const selectFormState = (state) => getFeatureBuilderState(state).form;
26
26
  */
27
27
  export const selectFormTitle = (state) => {
28
28
  const formState = selectFormState(state);
29
- return formState && formState.title;
29
+ return formState?.title;
30
30
  };
31
31
 
32
32
  /**
@@ -37,7 +37,7 @@ export const selectFormTitle = (state) => {
37
37
  */
38
38
  export const selectFormIcon = (state) => {
39
39
  const formState = selectFormState(state);
40
- return formState && formState.icon;
40
+ return formState?.icon;
41
41
  };
42
42
 
43
43
  /**
@@ -48,7 +48,7 @@ export const selectFormIcon = (state) => {
48
48
  */
49
49
  export const selectFormDisplayName = (state) => {
50
50
  const formState = selectFormState(state);
51
- return formState && formState.displayName;
51
+ return formState?.displayName;
52
52
  };
53
53
 
54
54
  /**
@@ -59,7 +59,7 @@ export const selectFormDisplayName = (state) => {
59
59
  */
60
60
  export const selectFormLayout = (state) => {
61
61
  const formState = selectFormState(state);
62
- return formState && formState.layout;
62
+ return formState?.layout;
63
63
  };
64
64
 
65
65
  /**
@@ -70,7 +70,7 @@ export const selectFormLayout = (state) => {
70
70
  */
71
71
  export const selectFormFields = (state) => {
72
72
  const formState = selectFormState(state);
73
- return (formState && formState.fields) || [];
73
+ return formState?.fields || [];
74
74
  };
75
75
 
76
76
  export const selectFormField = (fieldId) => (state) =>
@@ -78,21 +78,21 @@ export const selectFormField = (fieldId) => (state) =>
78
78
 
79
79
  export const selectFormIsInitial = (state) => {
80
80
  const formState = selectFormState(state);
81
- return formState && formState._isInitial;
81
+ return formState?._isInitial;
82
82
  };
83
83
  export const selectFormIsSubmitting = (state) => {
84
84
  const formState = selectFormState(state);
85
- return formState && formState._isSubmitting;
85
+ return formState?._isSubmitting;
86
86
  };
87
87
 
88
88
  export const selectFormSubmitError = (state) => {
89
89
  const formState = selectFormState(state);
90
- return formState && formState._submitError;
90
+ return formState?._submitError;
91
91
  };
92
92
 
93
93
  export const selectFormSubmitSuccess = (state) => {
94
94
  const formState = selectFormState(state);
95
- return formState && formState._submitSuccess;
95
+ return formState?._submitSuccess;
96
96
  };
97
97
 
98
98
  // ============ DEFINITION SELECTORS ============
@@ -102,31 +102,44 @@ export const selectDefinitionState = (state) =>
102
102
 
103
103
  export const selectDefinition = (state) => {
104
104
  const definitionState = selectDefinitionState(state);
105
- return definitionState && definitionState.definition;
105
+ return definitionState?.definition;
106
106
  };
107
107
  export const selectDefinitionId = (state) => {
108
108
  const definitionState = selectDefinitionState(state);
109
- return definitionState && definitionState.id;
109
+ return definitionState?.id;
110
110
  };
111
111
  export const selectDefinitionIsLoading = (state) => {
112
112
  const definitionState = selectDefinitionState(state);
113
- return definitionState && definitionState.isLoading;
113
+ return definitionState?.isLoading;
114
114
  };
115
115
  export const selectDefinitionError = (state) => {
116
116
  const definitionState = selectDefinitionState(state);
117
- return definitionState && definitionState.error;
117
+ return definitionState?.error;
118
118
  };
119
119
  export const selectDefinitionIsCreating = (state) => {
120
120
  const definitionState = selectDefinitionState(state);
121
- return definitionState && definitionState.isCreating;
121
+ return definitionState?.isCreating;
122
122
  };
123
123
  export const selectDefinitionIsEditing = (state) => {
124
124
  const definitionState = selectDefinitionState(state);
125
- return definitionState && definitionState.isEditing;
125
+ return definitionState?.isEditing;
126
+ };
127
+ export const selectDefinitionMode = (state) => {
128
+ const definitionState = selectDefinitionState(state);
129
+ return definitionState?.mode;
126
130
  };
127
131
 
128
- // Check if we have a definition loaded
129
- export const selectHasDefinition = (state) => !!selectDefinition(state);
132
+ // Check if we have a definition loaded or if we've determined the mode
133
+ // This is used by hiddenFromFeaturePicker to determine if feature should be shown
134
+ // When mode is "create", definition is null but we've determined the feature doesn't exist
135
+ // When mode is "edit", definition exists and we've determined the feature exists
136
+ export const selectHasDefinition = (state) => {
137
+ const definition = selectDefinition(state);
138
+ const mode = selectDefinitionMode(state);
139
+ // Consider feature "loaded" if definition exists OR mode is set
140
+ // Mode being set means we've successfully fetched and determined the state
141
+ return !!definition || !!mode;
142
+ };
130
143
 
131
144
  // ============ LISTINGS SELECTORS ============
132
145
 
@@ -135,35 +148,35 @@ export const selectListingsState = (state) =>
135
148
 
136
149
  export const selectListings = (state) => {
137
150
  const listingsState = selectListingsState(state);
138
- return (listingsState && listingsState.listings) || [];
151
+ return listingsState?.listings || [];
139
152
  };
140
153
  export const selectListingsIsLoading = (state) => {
141
154
  const listingsState = selectListingsState(state);
142
- return listingsState && listingsState.isLoading;
155
+ return listingsState?.isLoading;
143
156
  };
144
157
  export const selectListingsError = (state) => {
145
158
  const listingsState = selectListingsState(state);
146
- return listingsState && listingsState.error;
159
+ return listingsState?.error;
147
160
  };
148
161
  export const selectListingsIsCreating = (state) => {
149
162
  const listingsState = selectListingsState(state);
150
- return listingsState && listingsState.isCreating;
163
+ return listingsState?.isCreating;
151
164
  };
152
165
  export const selectListingsIsEditing = (state) => {
153
166
  const listingsState = selectListingsState(state);
154
- return listingsState && listingsState.isEditing;
167
+ return listingsState?.isEditing;
155
168
  };
156
169
  export const selectListingsIsDeleting = (state) => {
157
170
  const listingsState = selectListingsState(state);
158
- return listingsState && listingsState.isDeleting;
171
+ return listingsState?.isDeleting;
159
172
  };
160
173
  export const selectListingsIsRestoring = (state) => {
161
174
  const listingsState = selectListingsState(state);
162
- return listingsState && listingsState.isRestoring;
175
+ return listingsState?.isRestoring;
163
176
  };
164
177
  export const selectListingsIsInitiallyLoaded = (state) => {
165
178
  const listingsState = selectListingsState(state);
166
- return listingsState && listingsState.isInitiallyLoaded;
179
+ return listingsState?.isInitiallyLoaded;
167
180
  };
168
181
 
169
182
  // Get a specific listing by ID
@@ -299,7 +312,7 @@ export const selectWizardState = (state) =>
299
312
 
300
313
  export const selectWizardMode = (state) => {
301
314
  const wizardState = selectWizardState(state);
302
- return wizardState && wizardState.mode;
315
+ return wizardState?.mode;
303
316
  };
304
317
 
305
318
  // Mode detection selectors - wizard mode is the SINGLE SOURCE OF TRUTH for create/edit mode
@@ -311,57 +324,57 @@ export const selectIsEditMode = (state) => selectWizardMode(state) === "edit";
311
324
 
312
325
  export const selectNavigationState = (state) => {
313
326
  const wizardState = selectWizardState(state);
314
- return wizardState && wizardState.navigation;
327
+ return wizardState?.navigation;
315
328
  };
316
329
 
317
330
  export const selectCurrentStep = (state) => {
318
331
  const navigationState = selectNavigationState(state);
319
- return navigationState && navigationState.currentStep;
332
+ return navigationState?.currentStep;
320
333
  };
321
334
 
322
335
  export const selectCanGoBack = (state) => {
323
336
  const navigationState = selectNavigationState(state);
324
- return navigationState && navigationState.canGoBack;
337
+ return navigationState?.canGoBack;
325
338
  };
326
339
 
327
340
  export const selectPreviousStep = (state) => {
328
341
  const navigationState = selectNavigationState(state);
329
- return navigationState && navigationState.previousStep;
342
+ return navigationState?.previousStep;
330
343
  };
331
344
 
332
345
  export const selectCanGoForward = (state) => {
333
346
  const navigationState = selectNavigationState(state);
334
- return navigationState && navigationState.canGoForward;
347
+ return navigationState?.canGoForward;
335
348
  };
336
349
 
337
350
  export const selectStepValidation = (state) => {
338
351
  const wizardState = selectWizardState(state);
339
- return wizardState && wizardState.stepValidation;
352
+ return wizardState?.stepValidation;
340
353
  };
341
354
 
342
355
  export const selectStepValidationState = (step) => (state) => {
343
356
  const stepValidation = selectStepValidation(state);
344
- return stepValidation && stepValidation[step];
357
+ return stepValidation?.[step];
345
358
  };
346
359
 
347
360
  export const selectIsStepValid = (step) => (state) => {
348
361
  const stepValidationState = selectStepValidationState(step)(state);
349
- return stepValidationState && stepValidationState.isValid;
362
+ return stepValidationState?.isValid;
350
363
  };
351
364
 
352
365
  export const selectStepErrors = (step) => (state) => {
353
366
  const stepValidationState = selectStepValidationState(step)(state);
354
- return stepValidationState ? stepValidationState.errors : {};
367
+ return stepValidationState?.errors || {};
355
368
  };
356
369
 
357
370
  export const selectStepCompletion = (state) => {
358
371
  const wizardState = selectWizardState(state);
359
- return wizardState && wizardState.stepCompletion;
372
+ return wizardState?.stepCompletion;
360
373
  };
361
374
 
362
375
  export const selectIsStepComplete = (step) => (state) => {
363
376
  const stepCompletion = selectStepCompletion(state);
364
- return stepCompletion && stepCompletion[step];
377
+ return stepCompletion?.[step];
365
378
  };
366
379
 
367
380
  export const selectAllStepsComplete = (state) => {
@@ -418,17 +431,13 @@ export const selectIsStepAccessible = (step) => (state) => {
418
431
  // Get current sort method
419
432
  export const selectSortBy = (state) => {
420
433
  const listingsState = selectListingsState(state);
421
- return listingsState && listingsState.sortBy
422
- ? listingsState.sortBy
423
- : "newest";
434
+ return listingsState?.sortBy ?? "newest";
424
435
  };
425
436
 
426
437
  // Get show deleted toggle state
427
438
  export const selectShowDeleted = (state) => {
428
439
  const listingsState = selectListingsState(state);
429
- return listingsState && listingsState.showDeleted
430
- ? listingsState.showDeleted
431
- : false;
440
+ return listingsState?.showDeleted ?? false;
432
441
  };
433
442
 
434
443
  // Get sorted and filtered listings