@dongmingzhixiu/vuexir-compiler 0.4.6 → 0.4.7
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/codegen/swiftui.js +47 -0
- package/package.json +1 -1
package/dist/codegen/swiftui.js
CHANGED
|
@@ -716,6 +716,10 @@ function emitNodeInner(node, ctx) {
|
|
|
716
716
|
const align = isRow ? (ALIGN_MAP[alignRaw] ?? '.top') : (FLEX_START_MAP[alignRaw] ?? '.leading');
|
|
717
717
|
const stack = hasAbsolute ? 'ZStack' : isRow ? 'HStack' : 'VStack';
|
|
718
718
|
const stackAlign = hasAbsolute ? '.topLeading' : align;
|
|
719
|
+
// R132:ZStack 里必须把「非绝对定位」的兄弟包成一个流式子容器,
|
|
720
|
+
// 否则它们会全部叠在左上角互相覆盖(主卡名字与日期重叠就是这个原因)
|
|
721
|
+
const flowChildren = hasAbsolute ? children.filter((c) => c.props?.position !== 'absolute') : [];
|
|
722
|
+
const absChildren = hasAbsolute ? children.filter((c) => c.props?.position === 'absolute') : [];
|
|
719
723
|
const just = props.justifyContent;
|
|
720
724
|
// R-H4:justify-content 的弹性分配仅在「分配方向」有确定空间时有意义。
|
|
721
725
|
// column(主轴=垂直)需要容器高度确定(CSS:auto 高容器无剩余空间);
|
|
@@ -727,6 +731,49 @@ function emitNodeInner(node, ctx) {
|
|
|
727
731
|
}
|
|
728
732
|
// hasAbsolute 时无 flex 语义(ZStack 叠放)
|
|
729
733
|
const justActive = justFlex && (isRow || selfDefinite) && !hasAbsolute;
|
|
734
|
+
// R132:绝对定位容器 → 非绝对子节点先包成一个流式 VStack(保持原有纵向排布),
|
|
735
|
+
// 绝对定位子节点再叠上去;否则全部叠在左上角互相覆盖
|
|
736
|
+
if (hasAbsolute && flowChildren.length > 0) {
|
|
737
|
+
const flowNode = {
|
|
738
|
+
type: 'group',
|
|
739
|
+
props: { ...props, position: undefined, absTop: undefined, absLeft: undefined, absRight: undefined, absBottom: undefined },
|
|
740
|
+
children: flowChildren,
|
|
741
|
+
};
|
|
742
|
+
const flowCode = emitNode(flowNode, {
|
|
743
|
+
parentAxis: dir,
|
|
744
|
+
level: L + 1,
|
|
745
|
+
definiteHeight: selfDefinite,
|
|
746
|
+
warnings: ctx.warnings,
|
|
747
|
+
runtime: ctx.runtime,
|
|
748
|
+
path: `${ctx.path}{flow}`,
|
|
749
|
+
inheritGap: ctx.inheritGap,
|
|
750
|
+
loop: ctx.loop,
|
|
751
|
+
dataProps: ctx.dataProps,
|
|
752
|
+
});
|
|
753
|
+
const absCode = absChildren
|
|
754
|
+
.map((c, i) => emitNode(c, {
|
|
755
|
+
parentAxis: dir,
|
|
756
|
+
level: L + 1,
|
|
757
|
+
definiteHeight: selfDefinite,
|
|
758
|
+
warnings: ctx.warnings,
|
|
759
|
+
runtime: ctx.runtime,
|
|
760
|
+
path: `${ctx.path}{abs${i}}`,
|
|
761
|
+
inheritGap: undefined,
|
|
762
|
+
loop: ctx.loop,
|
|
763
|
+
dataProps: ctx.dataProps,
|
|
764
|
+
}))
|
|
765
|
+
.join('\n');
|
|
766
|
+
const bg = props.background !== undefined ? pad(`Color(${props.background})`) : null;
|
|
767
|
+
return [
|
|
768
|
+
pad('ZStack(alignment: .topLeading) {'),
|
|
769
|
+
bg ? indent(L + 1) + bg.trim() : null,
|
|
770
|
+
flowCode,
|
|
771
|
+
absCode || null,
|
|
772
|
+
pad('}'),
|
|
773
|
+
]
|
|
774
|
+
.filter((x) => x !== null)
|
|
775
|
+
.join('\n');
|
|
776
|
+
}
|
|
730
777
|
// justifyContent:center → 首尾 Spacer;spaceBetween → 子间 Spacer(仅 column 需高度确定)
|
|
731
778
|
const body = [];
|
|
732
779
|
if (just === 'center' && justActive) {
|