@appdirect/sfb-toolkit 5.0.1 → 5.0.3

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.
Files changed (38) hide show
  1. package/coverage/clover.xml +22 -22
  2. package/coverage/coverage-final.json +20 -20
  3. package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
  4. package/coverage/lcov-report/constants/index.html +1 -1
  5. package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
  6. package/coverage/lcov-report/constants/userMock.js.html +1 -1
  7. package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
  8. package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
  9. package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
  10. package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
  11. package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
  12. package/coverage/lcov-report/controllers/index.html +1 -1
  13. package/coverage/lcov-report/controllers/index.js.html +1 -1
  14. package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +1 -1
  15. package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +1 -1
  16. package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
  17. package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +1 -1
  18. package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
  19. package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
  20. package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
  21. package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
  22. package/coverage/lcov-report/front-end-utils/src/components/search.js.html +1 -1
  23. package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
  24. package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
  25. package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
  26. package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
  27. package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
  28. package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
  29. package/coverage/lcov-report/index.html +1 -1
  30. package/coverage/lcov-report/middlewares/config.js.html +1 -1
  31. package/coverage/lcov-report/middlewares/index.html +1 -1
  32. package/coverage/lcov-report/tools/index.html +1 -1
  33. package/coverage/lcov-report/tools/proxy-fetch.js.html +1 -1
  34. package/npm-shrinkwrap.json +9 -9
  35. package/package.json +2 -2
  36. package/readme.md +2 -2
  37. package/src/tools/toolkit-common-vars.js +1 -1
  38. package/src/tools/toolkit-components-copy.js +189 -1
@@ -22,6 +22,33 @@ const PAGE_ORDERABLE_CONTAINER_DIR = 'page-orderable-container'
22
22
  const PAGE_ORDERABLE_CONTAINER_BASE_PATH = `@appdirect/sfb-theme-components/src/components/${PAGE_ORDERABLE_CONTAINER_DIR}`
23
23
  const getPathToCopyTo = (path) => (path.replace('node_modules/@appdirect/sfb-theme-components',
24
24
  `customComponents/sfb_theme_components_${sfbThemeComponentsVersionCustom}`));
25
+ const listingPageComponentsGroup = ['ProductListing', 'ProductListingControls', 'CategorySidebar'];
26
+ const CUSTOM_CSS_AVAILABLE_SINCE_SFB_THEME_VERSION = '0_0_361';
27
+
28
+
29
+ const exceptionPaths = [
30
+ '/src/styles/definitions/_mixins',
31
+ '/src/styles/shared/editions',
32
+ '/src/components/header/atoms/header-home-bar/styles/HeaderHomeBar.scss',
33
+ '/src/components/product-listing-controls/styles/ProductListingControls.scss',
34
+ '/src/components/product-question-form/styles/ProductQuestionForm.scss',
35
+ '/src/components/product-banner/styles/ProductBanner.scss',
36
+ '/src/components/product-review-form/styles/ProductReviewForm.scss',
37
+ '/src/components/product-tabs-menu/styles/TabsMenu.scss',
38
+ '/src/components/product-variants/atoms/variant-cta/styles/VariantCta.scss',
39
+ '/src/components/product-variants/atoms/variant-selection-preview/styles/VariantSelectionPreview.scss',
40
+ '/src/components/product-configurator/styles/ProductConfigurator.scss',
41
+ '/src/components/featured-product/styles/FeaturedProduct.scss',
42
+ '/src/components/comparable-products/atoms/compare-product-reviews/styles/CompareProductReviews.scss',
43
+ '/src/components/comparable-products/styles/ComparableProducts.scss',
44
+ '/src/components/header/atoms/common/header-categories-menu/styles/HeaderCategoriesMenu.scss',
45
+ '/src/components/header/atoms/common/header-navigation/styles/HeaderNavigation.scss',
46
+ '/src/components/header/atoms/header-auxiliary-bar/styles/HeaderAuxiliaryBar.scss',
47
+ '/src/components/product-additional-info/styles/AdditionalInfo.scss',
48
+ '/src/components/product-configurator-v2/styles/ProductConfigurator.scss',
49
+ '/src/components/product-variants/atoms/variant-option-list/styles/VariantOptionList.scss'
50
+
51
+ ];
25
52
 
26
53
  const formattedComponentStatus = ({ data, statusMessage, statusType, path = '', maxStringLength = 30 }) => {
27
54
  const formattingOffset = (maxStringLength + 20) <= 50 ? 50 : maxStringLength + 20;
@@ -127,6 +154,153 @@ const addDefaultExport = (data, indexFileData, indexExportStrategy) => {
127
154
  return indexFileData;
128
155
  }
129
156
 
157
+ const isAtomPath = (atomPath) => {
158
+ return !!atomPath.match(/sfb-theme-components\/src\/atoms/)?.index;
159
+ }
160
+
161
+ const isExceptionPath = (path) => {
162
+ return exceptionPaths.some((exception) => path.includes(exception));
163
+ }
164
+
165
+ const lowerCaseFirstCharacter = (str) => {
166
+ return str ? str.charAt(0).toLowerCase() + str.slice(1): '';
167
+ }
168
+
169
+ const addUniqueCssClass = (fileData, isScssFile, isException) => {
170
+ let updatedFileData = fileData;
171
+ if(isException) {
172
+ updatedFileData = updatedFileData.replaceAll(/\.buttonIcon_(icon|text)/g, `.buttonIcon_${sfbThemeComponentsVersionCustom}_${"$1"}`);
173
+ updatedFileData = updatedFileData.replaceAll(/\.buttonIcon(?!\w+)/g, `.buttonIcon_${sfbThemeComponentsVersionCustom}`);
174
+ updatedFileData = updatedFileData.replaceAll(/\.button_(item|icon|text)/g, `.button_${sfbThemeComponentsVersionCustom}_${"$1"}`);
175
+ updatedFileData = updatedFileData.replaceAll(/\.button(?!\w+)/g, `.button_${sfbThemeComponentsVersionCustom}`);
176
+ updatedFileData = updatedFileData.replaceAll(/(?<=-namespace.+)(\.[a-zA-Z]+)/g, `${"$1"}_${sfbThemeComponentsVersionCustom}`);
177
+ updatedFileData = updatedFileData.replaceAll(/(?<!-namespace.+)\.(menuDropdown|link|select|sideBar|rating|pricing|productCard|contentDropdown)/g, `.${"$1"}_${sfbThemeComponentsVersionCustom}`);
178
+
179
+ return updatedFileData;
180
+ };
181
+
182
+ if(isScssFile) {
183
+ const cssClassList = updatedFileData.matchAll(/(\.[a-zA-Z0-9]+)\s*\{|\$?namespace.*"(\.[a-zA-Z]+)"/g);
184
+ if(!cssClassList) {
185
+ return updatedFileData;
186
+ } else {
187
+ const matchedCssClassList = [...cssClassList];
188
+ matchedCssClassList.forEach(cssClass => {
189
+ let namespaceClass;
190
+ if(cssClass?.[1]) {
191
+ namespaceClass = cssClass?.[1];
192
+ const cssClassPattern = new RegExp(`(?<!&)\\${namespaceClass}\\s*{`, 'g');
193
+ updatedFileData = updatedFileData.replace(cssClassPattern, `${namespaceClass}_${sfbThemeComponentsVersionCustom} {`);
194
+ }
195
+
196
+ if(cssClass?.[2]) {
197
+ namespaceClass = cssClass?.[2];
198
+ const cssNamespacePattern = new RegExp(`["|']\\${namespaceClass}['|"]`, 'g');
199
+ updatedFileData = updatedFileData.replace(cssNamespacePattern, `"${namespaceClass}_${sfbThemeComponentsVersionCustom}"`);
200
+ }
201
+
202
+ switch(namespaceClass) {
203
+ case '.languageSwitcher':
204
+ updatedFileData = updatedFileData.replace('.select', `.select_${sfbThemeComponentsVersionCustom}`);
205
+ break;
206
+ case '.buttonsList':
207
+ updatedFileData = updatedFileData.replace(/\.button(?![a-zA-Z]+)/g, `.button_${sfbThemeComponentsVersionCustom}`);
208
+ break;
209
+ case '.selectionPreview':
210
+ updatedFileData = updatedFileData.replace(/(?<=\s+)\.([a-zA-Z]+)/g, `.${"$1"}_${sfbThemeComponentsVersionCustom}`);
211
+ break;
212
+ case '.productListingCard':
213
+ updatedFileData = updatedFileData.replace('.rating', `.rating_${sfbThemeComponentsVersionCustom}`);
214
+ updatedFileData = updatedFileData.replace(/\.checkbox_(group)/g, `.checkbox_${sfbThemeComponentsVersionCustom}_${"$1"}`);
215
+ break;
216
+ case '.button':
217
+ updatedFileData = updatedFileData.replaceAll(/\.button_(item|text)/g, `.button_${sfbThemeComponentsVersionCustom}_${"$1"}`);
218
+ break;
219
+ case '.checkbox':
220
+ updatedFileData = updatedFileData.replace(/\.checkbox_(text)/g, `.checkbox_${sfbThemeComponentsVersionCustom}_${"$1"}`);
221
+ break;
222
+ case '.checkboxUncontrolled':
223
+ updatedFileData = updatedFileData.replace(/\.checkboxUncontrolled_(text)/g, `.checkboxUncontrolled_${sfbThemeComponentsVersionCustom}_${"$1"}`);
224
+ break;
225
+ case '.radioGroup':
226
+ updatedFileData = updatedFileData.replace(/\.radioGroup_(text)/g, `.radioGroup_${sfbThemeComponentsVersionCustom}_${"$1"}`);
227
+ break;
228
+ case '.slider':
229
+ updatedFileData = updatedFileData.replaceAll('.button', `.button_${sfbThemeComponentsVersionCustom}`);
230
+ default:
231
+ break;
232
+ }
233
+ })
234
+
235
+ return updatedFileData;
236
+ }
237
+ } else {
238
+ const namespace = updatedFileData.match(/createNamespace\((.*)\)/);
239
+ if(!namespace) {
240
+ return updatedFileData;
241
+ }
242
+ const namespaceString = namespace?.[1]?.match(/['|"](\w+)['|"]/);
243
+ if(namespaceString) {
244
+ const lowerCaseNamespace = namespaceString?.[1]?.toLowerCase();
245
+ updatedFileData = updatedFileData.replace(
246
+ /createNamespace\('.*'\)/,
247
+ `createNamespace('${namespaceString?.[1]}_${sfbThemeComponentsVersionCustom}')`
248
+ );
249
+
250
+ switch(lowerCaseNamespace) {
251
+ case 'select':
252
+ updatedFileData = updatedFileData.replace(
253
+ /'select'/g,
254
+ `'${lowerCaseFirstCharacter(namespaceString?.[1])}_${sfbThemeComponentsVersionCustom}'`
255
+ )
256
+ break;
257
+ case 'slider':
258
+ updatedFileData = updatedFileData.replace(
259
+ /'button_text'/g,
260
+ `'button_${sfbThemeComponentsVersionCustom}_text'`
261
+ )
262
+ break;
263
+ case 'volumepricingmodal':
264
+ updatedFileData = updatedFileData.replace(
265
+ /'volumePricingModalBodyScrollDisable'/g,
266
+ `'volumePricingModalBodyScrollDisable_${sfbThemeComponentsVersionCustom}'`
267
+ )
268
+ break;
269
+ case 'volumepricing':
270
+ updatedFileData = updatedFileData.replace(
271
+ /"(volumePricing[a-zA-Z]+)"/g,
272
+ `"${"$1"}_${sfbThemeComponentsVersionCustom}"`
273
+ )
274
+ break;
275
+ case 'volumepricingcard':
276
+ updatedFileData = updatedFileData.replace(
277
+ "volumePricingCardIcon",
278
+ `volumePricingCardIcon_${sfbThemeComponentsVersionCustom}`
279
+ )
280
+ break;
281
+ default:
282
+ break;
283
+ }
284
+
285
+ return updatedFileData;
286
+ } else {
287
+ // namespace is defined as a variable
288
+ const namespaceVariablePattern = new RegExp(`${namespace?.[1]}\\s*=\\s*['|"](\\w+)['|"]`);
289
+ const namespaceVariable = updatedFileData.match(namespaceVariablePattern);
290
+ const namespaceStringPattern = new RegExp(`${namespace?.[1]}\\s*=\\s*['|"]${namespaceVariable?.[1]}['|"]`);
291
+
292
+ if(namespaceVariable) {
293
+ updatedFileData = updatedFileData.replace(
294
+ namespaceStringPattern,
295
+ `${namespace?.[1]} = '${namespaceVariable?.[1]}_${sfbThemeComponentsVersionCustom}'`
296
+ )
297
+ }
298
+
299
+ return updatedFileData;
300
+ }
301
+ }
302
+ }
303
+
130
304
  const sfbThemeComponentsDeepCopy = (
131
305
  pathsToFileList,
132
306
  maxComponentStringLength,
@@ -176,7 +350,13 @@ const sfbThemeComponentsDeepCopy = (
176
350
  const folderPath = pathToCopyTo.slice(0, pathToCopyTo.lastIndexOf('/'));
177
351
  fs.mkdirSync(folderPath, { recursive: true });
178
352
 
179
- fileData = replacePageOrderableContainerImports(fileData)
353
+ fileData = replacePageOrderableContainerImports(fileData);
354
+
355
+ const isException = isExceptionPath(path);
356
+ if(sfbThemeComponentsVersionCustom >= CUSTOM_CSS_AVAILABLE_SINCE_SFB_THEME_VERSION
357
+ && isAtomPath(path) || isExceptionPath(path)){
358
+ fileData = addUniqueCssClass(fileData, isScssFile, isException);
359
+ }
180
360
 
181
361
  fs.writeFileSync(pathToCopyTo, fileData);
182
362
  if(componentsToCopy[path]) {
@@ -331,6 +511,14 @@ const sfbThemeComponentsDeepCopy = (
331
511
  return;
332
512
  }
333
513
 
514
+ if (sfbThemeComponentsVersionCustom >= CUSTOM_CSS_AVAILABLE_SINCE_SFB_THEME_VERSION) {
515
+ const listingPageComponentsSelected = listingPageComponentsGroup.some(comp =>
516
+ selectedComponentsList.includes(comp));
517
+ if(listingPageComponentsSelected) {
518
+ selectedComponentsList = [ ...selectedComponentsList, ...listingPageComponentsGroup];
519
+ }
520
+ }
521
+
334
522
  selectedComponentsList.forEach(component => {
335
523
  const hasComponent = componentMap[component.toLowerCase()];
336
524
  if(hasComponent) {