km-card-layout-core 0.1.19 → 0.1.22

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.
@@ -136,7 +136,7 @@ exports.updateElementsStyle = updateElementsStyle;
136
136
  const setElementVisible = (layout, key, visible) => {
137
137
  return layout.map(la => ({
138
138
  ...la,
139
- children: la.children.map(el => (el.id === key ? { ...el, visible } : el)),
139
+ children: la.children.map(el => (el.key === key ? { ...el, visible } : el)),
140
140
  }));
141
141
  };
142
142
  exports.setElementVisible = setElementVisible;
@@ -7,9 +7,9 @@ function buildRenderData(layout, items, config) {
7
7
  // 绑定数据
8
8
  let renderLayout = (0, utils_1.applyItemCollectBindings)(layout, items);
9
9
  // 设置显示逻辑
10
- renderLayout = (0, changeBackground_1.setElementVisible)(renderLayout, 'avatar', config.showAvatar);
10
+ renderLayout = (0, changeBackground_1.setElementVisible)(renderLayout, 'image', config.showAvatar);
11
11
  renderLayout = (0, changeBackground_1.setElementVisible)(renderLayout, 'logo', config.showLogo);
12
12
  // 设置背景
13
- renderLayout = renderLayout.map((la, index) => (0, changeBackground_1.backgroundChange)(config.currentBg[index], la));
13
+ renderLayout = renderLayout.map((la, index) => config.currentBg[index] ? (0, changeBackground_1.backgroundChange)(config.currentBg[index], la) : la);
14
14
  return renderLayout;
15
15
  }
@@ -174,6 +174,6 @@ export const setElementVisible = (
174
174
  ): CardLayoutSchema[] => {
175
175
  return layout.map(la => ({
176
176
  ...la,
177
- children: la.children.map(el => (el.id === key ? { ...el, visible } : el)),
177
+ children: la.children.map(el => (el.key === key ? { ...el, visible } : el)),
178
178
  }));
179
179
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "km-card-layout-core",
3
- "version": "0.1.19",
3
+ "version": "0.1.22",
4
4
  "description": "Shared render helpers for CardMaster layout JSON (binding resolution, layout normalization).",
5
5
  "main": "dist/index.js",
6
6
  "types": "types.d.ts",
package/render/tool.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { CardLayoutSchema, TemplateItem } from "../interface";
2
- import { backgroundChange, setElementVisible } from "../ops/changeBackground";
3
- import { Config } from "../types";
4
- import { applyItemCollectBindings } from "../utils";
1
+ import { CardLayoutSchema, TemplateItem } from '../interface';
2
+ import { backgroundChange, setElementVisible } from '../ops/changeBackground';
3
+ import { Config } from '../types';
4
+ import { applyItemCollectBindings } from '../utils';
5
5
 
6
6
  export function buildRenderData(
7
7
  layout: CardLayoutSchema[],
@@ -11,11 +11,11 @@ export function buildRenderData(
11
11
  // 绑定数据
12
12
  let renderLayout = applyItemCollectBindings(layout, items);
13
13
  // 设置显示逻辑
14
- renderLayout = setElementVisible(renderLayout, 'avatar', config.showAvatar);
14
+ renderLayout = setElementVisible(renderLayout, 'image', config.showAvatar);
15
15
  renderLayout = setElementVisible(renderLayout, 'logo', config.showLogo);
16
16
  // 设置背景
17
17
  renderLayout = renderLayout.map((la, index) =>
18
- backgroundChange(config.currentBg[index], la)
18
+ config.currentBg[index] ? backgroundChange(config.currentBg[index], la) : la
19
19
  );
20
20
  return renderLayout;
21
- }
21
+ }