@wix/zero-config-implementation 1.97.0 → 1.98.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
@@ -20772,7 +20772,7 @@ function KQ(t, e) {
20772
20772
  t.innerElementProps,
20773
20773
  t.propUsages
20774
20774
  ),
20775
- cssProperties: iD(r),
20775
+ cssProperties: iD(r, !0),
20776
20776
  cssCustomProperties: i,
20777
20777
  ...u && { states: u },
20778
20778
  ...l && { displayGroups: l },
@@ -20828,7 +20828,7 @@ function eD(t, e, r, n, i, s, a) {
20828
20828
  };
20829
20829
  continue;
20830
20830
  }
20831
- const h = XA(u), m = l && s ? Z3(l.props, s) : void 0, g = iD(u), p = e.get(u.traceId) ?? {}, A = Q3(
20831
+ const h = XA(u), m = l && s ? Z3(l.props, s) : void 0, g = iD(u, !1), p = e.get(u.traceId) ?? {}, A = Q3(
20832
20832
  h ? J3(u, h, r.focus) : void 0,
20833
20833
  j3({ element: u, propTriggers: [], classTriggers: r.custom })
20834
20834
  );
@@ -20998,22 +20998,22 @@ const { CSS_PROPERTY_TYPE: tX, DISPLAY_VALUE: Un } = $n, rX = {
20998
20998
  function nX(t) {
20999
20999
  return rX[t] ?? t;
21000
21000
  }
21001
- function iD(t) {
21002
- const e = {}, n = t?.extractorData.get("css-properties")?.relevant;
21003
- if (!n || n.length === 0)
21004
- return e;
21005
- const i = t ? eX(t) : /* @__PURE__ */ new Map();
21006
- for (const s of n) {
21007
- if (s === tX.display && t) {
21008
- e[s] = iX(t);
21001
+ function iD(t, e) {
21002
+ const r = {}, i = t?.extractorData.get("css-properties")?.relevant;
21003
+ if (!i || i.length === 0)
21004
+ return r;
21005
+ const s = t ? eX(t) : /* @__PURE__ */ new Map();
21006
+ for (const a of i) {
21007
+ if (a === tX.display && t) {
21008
+ e || (r[a] = iX(t));
21009
21009
  continue;
21010
21010
  }
21011
- const a = TQ(s, i), o = a !== void 0 ? a7(a) : void 0;
21012
- e[s] = {
21013
- ...o !== void 0 && { defaultValue: o }
21011
+ const o = TQ(a, s), u = o !== void 0 ? a7(o) : void 0;
21012
+ r[a] = {
21013
+ ...u !== void 0 && { defaultValue: u }
21014
21014
  };
21015
21015
  }
21016
- return e;
21016
+ return r;
21017
21017
  }
21018
21018
  function iX(t) {
21019
21019
  const e = t.extractorData.get("css-matcher"), r = e ? qA(e) : void 0;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.97.0",
7
+ "version": "1.98.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",
@@ -106,5 +106,5 @@
106
106
  ]
107
107
  }
108
108
  },
109
- "falconPackageHash": "0b3ebaeffed6f192d5ccd84f8598e0e524b0edb36eb3ca0961bab4c7"
109
+ "falconPackageHash": "741408430f509ba8b4ac3b6f2ff22c4fae1bf06d9f8b98e2a9e8e079"
110
110
  }
@@ -43,11 +43,22 @@ function createElementWithDisplayMatcher(tag: string, matcherData: MatchedCssDat
43
43
  }
44
44
  }
45
45
 
46
- function createComponent(rootElement: ExtractedElement): ComponentInfoWithCss {
46
+ function createComponent(rootElement: ExtractedElement, renderDisplayElementAsChild = false): ComponentInfoWithCss {
47
+ const componentRoot = renderDisplayElementAsChild
48
+ ? {
49
+ traceId: 'trace-container',
50
+ name: 'container',
51
+ tag: 'div',
52
+ attributes: {},
53
+ extractorData: new Map<string, unknown>(),
54
+ children: [{ ...rootElement, traceId: 'trace-display', name: 'display' }],
55
+ }
56
+ : rootElement
57
+
47
58
  return {
48
59
  componentName: 'DisplayComponent',
49
60
  props: {},
50
- elements: [rootElement],
61
+ elements: [componentRoot],
51
62
  propUsages: new Map(),
52
63
  css: [],
53
64
  varUsedByTraceId: new Map(),
@@ -71,6 +82,10 @@ function createComponentWithA11yUsages(propPaths: string[]): ComponentInfoWithCs
71
82
  }
72
83
  }
73
84
 
85
+ function getDisplayProperty(result: ReturnType<typeof toEditorReactComponent>) {
86
+ return result.editorElement?.elements?.display?.inlineElement?.cssProperties?.display
87
+ }
88
+
74
89
  describe('toEditorReactComponent accessibility conversion', () => {
75
90
  it('omits the a11y item when the component reads only component-owned fields', () => {
76
91
  const component = createComponentWithA11yUsages(['props.a11y.role', 'props.a11y.tabIndex'])
@@ -115,6 +130,14 @@ function createSemanticElement({
115
130
  }
116
131
 
117
132
  describe('toEditorReactComponent display conversion', () => {
133
+ it('omits display from the root editor element', () => {
134
+ const rootElement = createElementWithDisplayMatcher('div', matcherDataFromCss('display: flex'))
135
+
136
+ const result = toEditorReactComponent(createComponent(rootElement))
137
+
138
+ expect(result.editorElement?.cssProperties?.display).toBeUndefined()
139
+ })
140
+
118
141
  it('resolves local display fallback chains before emitting the manifest display value', () => {
119
142
  const rootElement = createElementWithDisplayMatcher(
120
143
  'span',
@@ -123,10 +146,10 @@ describe('toEditorReactComponent display conversion', () => {
123
146
  ),
124
147
  )
125
148
 
126
- const result = toEditorReactComponent(createComponent(rootElement))
149
+ const result = toEditorReactComponent(createComponent(rootElement, true))
127
150
  expect(result.editorElement).toBeDefined()
128
151
 
129
- expect(result.editorElement?.cssProperties?.display).toEqual({
152
+ expect(getDisplayProperty(result)).toEqual({
130
153
  display: {
131
154
  displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, 'inlineFlex'],
132
155
  },
@@ -136,10 +159,10 @@ describe('toEditorReactComponent display conversion', () => {
136
159
  it('keeps using the tag default when no display declaration exists', () => {
137
160
  const rootElement = createElementWithDisplayMatcher('span', matcherDataFromCss(''))
138
161
 
139
- const result = toEditorReactComponent(createComponent(rootElement))
162
+ const result = toEditorReactComponent(createComponent(rootElement, true))
140
163
  expect(result.editorElement).toBeDefined()
141
164
 
142
- expect(result.editorElement?.cssProperties?.display).toEqual({
165
+ expect(getDisplayProperty(result)).toEqual({
143
166
  display: {
144
167
  displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, 'inline'],
145
168
  },
@@ -166,9 +189,9 @@ describe('toEditorReactComponent display conversion', () => {
166
189
  it.each(tagDefaults)('maps a <%s> tag default (%s) onto its enum name', (tag, _cssDisplay, expectedEnumValue) => {
167
190
  const rootElement = createElementWithDisplayMatcher(tag, matcherDataFromCss(''))
168
191
 
169
- const result = toEditorReactComponent(createComponent(rootElement))
192
+ const result = toEditorReactComponent(createComponent(rootElement, true))
170
193
 
171
- expect(result.editorElement?.cssProperties?.display).toEqual({
194
+ expect(getDisplayProperty(result)).toEqual({
172
195
  display: {
173
196
  displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, expectedEnumValue],
174
197
  },
@@ -177,14 +200,14 @@ describe('toEditorReactComponent display conversion', () => {
177
200
 
178
201
  it('treats an explicit `display: table-cell` declaration the same as the tag default', () => {
179
202
  const fromTag = toEditorReactComponent(
180
- createComponent(createElementWithDisplayMatcher('td', matcherDataFromCss(''))),
203
+ createComponent(createElementWithDisplayMatcher('td', matcherDataFromCss('')), true),
181
204
  )
182
205
  const fromCss = toEditorReactComponent(
183
- createComponent(createElementWithDisplayMatcher('div', matcherDataFromCss('display: table-cell'))),
206
+ createComponent(createElementWithDisplayMatcher('div', matcherDataFromCss('display: table-cell')), true),
184
207
  )
185
208
 
186
- expect(fromCss.editorElement?.cssProperties?.display).toEqual(fromTag.editorElement?.cssProperties?.display)
187
- expect(fromCss.editorElement?.cssProperties?.display).toEqual({
209
+ expect(getDisplayProperty(fromCss)).toEqual(getDisplayProperty(fromTag))
210
+ expect(getDisplayProperty(fromCss)).toEqual({
188
211
  display: {
189
212
  displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, CSS_PROPERTIES.DISPLAY_VALUE.tableCell],
190
213
  },
@@ -194,9 +217,9 @@ describe('toEditorReactComponent display conversion', () => {
194
217
  it('still maps kebab-case values that do have an enum representation', () => {
195
218
  const rootElement = createElementWithDisplayMatcher('div', matcherDataFromCss('display: inline-block'))
196
219
 
197
- const result = toEditorReactComponent(createComponent(rootElement))
220
+ const result = toEditorReactComponent(createComponent(rootElement, true))
198
221
 
199
- expect(result.editorElement?.cssProperties?.display).toEqual({
222
+ expect(getDisplayProperty(result)).toEqual({
200
223
  display: {
201
224
  displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, CSS_PROPERTIES.DISPLAY_VALUE.inlineBlock],
202
225
  },
@@ -208,8 +231,8 @@ describe('toEditorReactComponent display conversion', () => {
208
231
 
209
232
  for (const [tag] of tagDefaults) {
210
233
  const rootElement = createElementWithDisplayMatcher(tag, matcherDataFromCss(''))
211
- const result = toEditorReactComponent(createComponent(rootElement))
212
- const emittedValues = result.editorElement?.cssProperties?.display?.display?.displayValues ?? []
234
+ const result = toEditorReactComponent(createComponent(rootElement, true))
235
+ const emittedValues = getDisplayProperty(result)?.display?.displayValues ?? []
213
236
 
214
237
  expect(emittedValues.filter((displayValue) => !allowedValues.has(displayValue))).toEqual([])
215
238
  }
@@ -234,9 +257,9 @@ describe('toEditorReactComponent display conversion', () => {
234
257
  'div',
235
258
  matcherDataFromCss(`display: ${toCssSpelling(enumValue)}`),
236
259
  )
237
- const result = toEditorReactComponent(createComponent(rootElement))
260
+ const result = toEditorReactComponent(createComponent(rootElement, true))
238
261
 
239
- return result.editorElement?.cssProperties?.display?.display?.displayValues?.[1] !== enumValue
262
+ return getDisplayProperty(result)?.display?.displayValues?.[1] !== enumValue
240
263
  })
241
264
 
242
265
  expect(unreachable).toEqual([])
@@ -127,7 +127,7 @@ function buildEditorElement(
127
127
  component.innerElementProps,
128
128
  component.propUsages,
129
129
  ),
130
- cssProperties: buildCssProperties(rootElement),
130
+ cssProperties: buildCssProperties(rootElement, true),
131
131
  cssCustomProperties: rootCustomProps,
132
132
  ...(rootStates && { states: rootStates }),
133
133
  ...(displayGroups && { displayGroups }),
@@ -224,7 +224,7 @@ function buildElements(
224
224
  const semanticClass = getSemanticBlockName(element)
225
225
 
226
226
  const data = innerEntry && propUsages ? buildData(innerEntry.props, propUsages) : undefined
227
- const cssProps = buildCssProperties(element)
227
+ const cssProps = buildCssProperties(element, false)
228
228
  const cssCustomProps = nearestCommonAncestorCustomProps.get(element.traceId) ?? {}
229
229
 
230
230
  // Inner-element custom states come from custom-class triggers only; prop
@@ -563,7 +563,10 @@ function toDisplayEnumValue(cssValue: string): DisplayEnumValue {
563
563
  return (CSS_DISPLAY_TO_ENUM[cssValue] ?? cssValue) as DisplayEnumValue
564
564
  }
565
565
 
566
- function buildCssProperties(element: ExtractedElement | undefined): Record<string, CssPropertyItem> {
566
+ function buildCssProperties(
567
+ element: ExtractedElement | undefined,
568
+ isRootElement: boolean,
569
+ ): Record<string, CssPropertyItem> {
567
570
  const result: Record<string, CssPropertyItem> = {}
568
571
 
569
572
  const cssData = element?.extractorData.get('css-properties') as CssPropertiesData | undefined
@@ -574,7 +577,9 @@ function buildCssProperties(element: ExtractedElement | undefined): Record<strin
574
577
  const cssPropertyValues = element ? getMatchedPropertyValues(element) : new Map<string, string>()
575
578
  for (const propName of decidedProperties) {
576
579
  if (propName === CSS_PROPERTY_TYPE.display && element) {
577
- result[propName] = buildDisplayProperty(element)
580
+ if (!isRootElement) {
581
+ result[propName] = buildDisplayProperty(element)
582
+ }
578
583
  continue
579
584
  }
580
585
  const resolvedValue = resolveLonghand(propName, cssPropertyValues)