@wix/zero-config-implementation 1.104.0 → 1.105.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 +3391 -3381
- package/package.json +2 -2
- package/src/converters/to-editor-component.test.ts +42 -0
- package/src/converters/to-editor-component.ts +14 -3
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"registry": "https://registry.npmjs.org/",
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.105.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": "
|
|
109
|
+
"falconPackageHash": "0c8ba866b638c1cacaeaecfc2e82c36a40e6307f5e3896c922c1dc25"
|
|
110
110
|
}
|
|
@@ -374,6 +374,48 @@ describe('toEditorReactComponent — cssProperties defaultValue', () => {
|
|
|
374
374
|
expect(result.editorElement?.cssProperties?.overflow).toEqual({ defaultValue: 'hidden' })
|
|
375
375
|
})
|
|
376
376
|
|
|
377
|
+
it("excludes margin from the root element but keeps it on inner elements (editor's layout positions the root on stage)", () => {
|
|
378
|
+
const marginProperties = [
|
|
379
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.margin,
|
|
380
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginTop,
|
|
381
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginRight,
|
|
382
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginBottom,
|
|
383
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginLeft,
|
|
384
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginInlineStart,
|
|
385
|
+
CSS_PROPERTIES.CSS_PROPERTY_TYPE.marginInlineEnd,
|
|
386
|
+
]
|
|
387
|
+
const createExtractorData = () => {
|
|
388
|
+
const extractorData = new Map<string, unknown>()
|
|
389
|
+
extractorData.set('css-matcher', matcherDataFromCss(''))
|
|
390
|
+
extractorData.set('css-properties', { relevant: marginProperties })
|
|
391
|
+
return extractorData
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const childElement: ExtractedElement = {
|
|
395
|
+
traceId: 'trace-icon',
|
|
396
|
+
name: 'icon',
|
|
397
|
+
tag: 'div',
|
|
398
|
+
attributes: {},
|
|
399
|
+
extractorData: createExtractorData(),
|
|
400
|
+
children: [],
|
|
401
|
+
}
|
|
402
|
+
const rootElement: ExtractedElement = {
|
|
403
|
+
traceId: 'trace-root',
|
|
404
|
+
name: 'root',
|
|
405
|
+
tag: 'div',
|
|
406
|
+
attributes: {},
|
|
407
|
+
extractorData: createExtractorData(),
|
|
408
|
+
children: [childElement],
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const result = toEditorReactComponent(createComponent(rootElement))
|
|
412
|
+
|
|
413
|
+
for (const property of marginProperties) {
|
|
414
|
+
expect(result.editorElement?.cssProperties?.[property]).toBeUndefined()
|
|
415
|
+
expect(result.editorElement?.elements?.icon?.inlineElement?.cssProperties?.[property]).toEqual({})
|
|
416
|
+
}
|
|
417
|
+
})
|
|
418
|
+
|
|
377
419
|
it('keeps width/height on inner (non-root) elements', () => {
|
|
378
420
|
const rootExtractorData = new Map<string, unknown>()
|
|
379
421
|
rootExtractorData.set('css-matcher', matcherDataFromCss(''))
|
|
@@ -576,9 +576,20 @@ function toDisplayEnumValue(cssValue: string): DisplayEnumValue {
|
|
|
576
576
|
return (CSS_DISPLAY_TO_ENUM[cssValue] ?? cssValue) as DisplayEnumValue
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
//
|
|
580
|
-
//
|
|
581
|
-
|
|
579
|
+
// CSS properties left out of the root element's own `cssProperties`:
|
|
580
|
+
// - `width`/`height`: root sizing is handled separately via layout config.
|
|
581
|
+
// - margins: the editor's layout positions the root on stage.
|
|
582
|
+
const ROOT_EXCLUDED_CSS_PROPERTIES = new Set<string>([
|
|
583
|
+
CSS_PROPERTY_TYPE.width,
|
|
584
|
+
CSS_PROPERTY_TYPE.height,
|
|
585
|
+
CSS_PROPERTY_TYPE.margin,
|
|
586
|
+
CSS_PROPERTY_TYPE.marginTop,
|
|
587
|
+
CSS_PROPERTY_TYPE.marginRight,
|
|
588
|
+
CSS_PROPERTY_TYPE.marginBottom,
|
|
589
|
+
CSS_PROPERTY_TYPE.marginLeft,
|
|
590
|
+
CSS_PROPERTY_TYPE.marginInlineStart,
|
|
591
|
+
CSS_PROPERTY_TYPE.marginInlineEnd,
|
|
592
|
+
])
|
|
582
593
|
|
|
583
594
|
function buildCssProperties(
|
|
584
595
|
element: ExtractedElement | undefined,
|