@wix/zero-config-implementation 1.73.0 → 1.74.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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as t, D as e, E as o, I as n, N as c, P as l, R as i, a as p, V as E, b as m, c as x, d as f, e as d, f as u, h as C, i as I, j as k, k as y, l as A, m as D, n as P, o as R, p as h, q as B, r as M, s as T, t as b, w } from "./index-K3lIO4FC.js";
1
+ import { B as t, D as e, E as o, I as n, N as c, P as l, R as i, a as p, V as E, b as m, c as x, d as f, e as d, f as u, h as C, i as I, j as k, k as y, l as A, m as D, n as P, o as R, p as h, q as B, r as M, s as T, t as b, w } from "./index-FEhWzHzO.js";
2
2
  import "react";
3
3
  export {
4
4
  t as BaseError,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.73.0",
7
+ "version": "1.74.0",
8
8
  "description": "Core library for extracting component manifests from JS and CSS files",
9
9
  "type": "module",
10
10
  "main": "dist/index.js",
@@ -82,5 +82,5 @@
82
82
  ]
83
83
  }
84
84
  },
85
- "falconPackageHash": "398dcee4762e04fdaa11211df36bfb4ac7e2ea328d412a68f2e363f8"
85
+ "falconPackageHash": "9af6c0faf11670fde2ed8a2ae3c7eac531b2a4a90069d9192b84da4d"
86
86
  }
@@ -188,11 +188,25 @@ describe('getCssPropertiesForTag', () => {
188
188
  expect(relevantProperties).not.toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
189
189
  })
190
190
 
191
- it('composes text and box properties for semantic text with box-generating default display', () => {
191
+ it('keeps paragraph tags text-only by default', () => {
192
192
  const relevantProperties = getCssPropertiesForTag('p')
193
193
 
194
194
  expect(relevantProperties).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
195
- expect(relevantProperties).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
195
+ expect(relevantProperties).not.toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
196
+ })
197
+
198
+ it('keeps heading tags text-only by default', () => {
199
+ const relevantProperties = getCssPropertiesForTag('h2')
200
+
201
+ expect(relevantProperties).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
202
+ expect(relevantProperties).not.toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
203
+ })
204
+
205
+ it('keeps role-based heading text-only by default', () => {
206
+ const relevantProperties = getCssPropertiesForTag('div', 'heading')
207
+
208
+ expect(relevantProperties).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
209
+ expect(relevantProperties).not.toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
196
210
  })
197
211
 
198
212
  it('falls back to box properties for unknown non-media tags', () => {
@@ -265,6 +279,26 @@ describe('enrichContainerProperties', () => {
265
279
  expect(cssData.relevant).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
266
280
  })
267
281
 
282
+ it('does not add box properties to p when it relies on its default block display', () => {
283
+ const elements = [createElementWithCssProperties('p', '')]
284
+
285
+ const [enrichedElement] = enrichContainerProperties(elements)
286
+ const cssData = enrichedElement.extractorData.get('css-properties') as { relevant: string[] }
287
+
288
+ expect(cssData.relevant).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
289
+ expect(cssData.relevant).not.toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
290
+ })
291
+
292
+ it('adds box properties to p when display is explicitly overridden to block', () => {
293
+ const elements = [createElementWithCssProperties('p', 'display: block')]
294
+
295
+ const [enrichedElement] = enrichContainerProperties(elements)
296
+ const cssData = enrichedElement.extractorData.get('css-properties') as { relevant: string[] }
297
+
298
+ expect(cssData.relevant).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.font)
299
+ expect(cssData.relevant).toContain(CSS_PROPERTIES.CSS_PROPERTY_TYPE.paddingTop)
300
+ })
301
+
268
302
  it('adds box properties to strong when display becomes inline-flex', () => {
269
303
  const elements = [createElementWithCssProperties('strong', 'display: inline-flex')]
270
304
 
@@ -44,6 +44,8 @@ const TEXT_TAGS = new Set([
44
44
  'i',
45
45
  ])
46
46
 
47
+ const DEFAULT_NON_BOX_TEXT_TAGS = new Set(['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
48
+
47
49
  /**
48
50
  * Media & Visuals - elements requiring aspect ratio control (excluding svg)
49
51
  */
@@ -137,7 +139,7 @@ export function getCssPropertiesForTag(tag: string, role?: string): string[] {
137
139
  const properties: string[] = []
138
140
  const hasTextProperties = hasTextSemantics(tag, role)
139
141
  const hasMediaProperties = hasMediaSemantics(tag, role)
140
- const hasBoxProperties = hasContainerLikeDefaultDisplay(tag) && !hasMediaProperties
142
+ const hasBoxProperties = hasDefaultBoxProperties(tag, role) && !hasMediaProperties
141
143
 
142
144
  if (hasTextProperties) {
143
145
  properties.push(...TEXT_CSS_PROPERTIES)
@@ -406,12 +408,30 @@ function hasContainerLikeDefaultDisplay(tag: string): boolean {
406
408
  return displayCreatesContainerBox(getDefaultDisplayForTag(tag))
407
409
  }
408
410
 
409
- function hasEffectiveContainerDisplay(tag: string, matcherData?: MatchedCssData): boolean {
411
+ function suppressesDefaultBoxProperties(tag: string, role?: string): boolean {
412
+ const normalizedTag = tag.toLowerCase()
413
+ if (DEFAULT_NON_BOX_TEXT_TAGS.has(normalizedTag)) {
414
+ return true
415
+ }
416
+
417
+ const normalizedRole = role?.toLowerCase()
418
+ return normalizedRole === 'heading' || normalizedRole === 'paragraph'
419
+ }
420
+
421
+ function hasDefaultBoxProperties(tag: string, role?: string): boolean {
422
+ if (suppressesDefaultBoxProperties(tag, role)) {
423
+ return false
424
+ }
425
+
426
+ return hasContainerLikeDefaultDisplay(tag)
427
+ }
428
+
429
+ function hasEffectiveContainerDisplay(tag: string, role?: string, matcherData?: MatchedCssData): boolean {
410
430
  if (matcherData && hasDisplayDeclaration(matcherData)) {
411
431
  return hasContainerLikeDisplay(matcherData)
412
432
  }
413
433
 
414
- return hasContainerLikeDefaultDisplay(tag)
434
+ return hasDefaultBoxProperties(tag, role)
415
435
  }
416
436
 
417
437
  /**
@@ -450,7 +470,7 @@ export function enrichContainerProperties(elements: ExtractedElement[]): Extract
450
470
  const matcherData = element.extractorData.get('css-matcher') as MatchedCssData | undefined
451
471
  const cssData = element.extractorData.get('css-properties') as CssPropertiesData | undefined
452
472
 
453
- if (cssData && hasEffectiveContainerDisplay(element.tag, matcherData)) {
473
+ if (cssData && hasEffectiveContainerDisplay(element.tag, role, matcherData)) {
454
474
  element.extractorData.set('css-properties', {
455
475
  relevant: addBoxProperties(cssData.relevant),
456
476
  })