km-card-layout-core 0.1.22 → 0.1.24

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/bindings.ts CHANGED
@@ -54,6 +54,9 @@ export function applyItemCollectBindings(
54
54
  else delete base.defaultValue;
55
55
  if (key !== undefined) base.key = key;
56
56
  else delete base.key;
57
+ if (el.type === 'text' && meta?.extra?.icon) {
58
+ base.icon = { ...(base.icon || {}), name: meta.extra.icon };
59
+ }
57
60
 
58
61
  if (el.type === 'layout-panel') {
59
62
  return {
package/dist/bindings.js CHANGED
@@ -31,6 +31,7 @@ function applyItemCollectBindings(layouts = [], items = []) {
31
31
  }
32
32
  });
33
33
  const assignBinding = (el) => {
34
+ var _a;
34
35
  const meta = metaMap.get(String(el.id));
35
36
  const binding = meta && meta.bind !== undefined && meta.bind !== null
36
37
  ? meta.bind
@@ -50,6 +51,9 @@ function applyItemCollectBindings(layouts = [], items = []) {
50
51
  base.key = key;
51
52
  else
52
53
  delete base.key;
54
+ if (el.type === 'text' && ((_a = meta === null || meta === void 0 ? void 0 : meta.extra) === null || _a === void 0 ? void 0 : _a.icon)) {
55
+ base.icon = { ...(base.icon || {}), name: meta.extra.icon };
56
+ }
53
57
  if (el.type === 'layout-panel') {
54
58
  return {
55
59
  ...base,
@@ -83,11 +83,11 @@ const buildImageContentStyle = (el, unit) => {
83
83
  const buildTextIcon = (el, unit) => {
84
84
  var _a, _b, _c, _d, _e;
85
85
  const icon = el.icon;
86
- if (!icon || icon.enable === false)
86
+ const enabled = (icon === null || icon === void 0 ? void 0 : icon.enable) === true;
87
+ if (!icon || !enabled)
87
88
  return undefined;
88
89
  const style = icon.style || 'fill';
89
- // el.extra.icon ||
90
- const baseName = el.key || el.binding || el.id;
90
+ const baseName = icon.name || el.key || el.binding || el.id;
91
91
  let name;
92
92
  if (style === 'dot')
93
93
  name = 'round';
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "km-card-layout-core",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
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",
7
7
  "license": "MIT",
8
8
  "scripts": {
9
9
  "build": "tsc -p tsconfig.build.json",
10
+ "watch": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
10
11
  "release": "pnpm run build && npm publish --access public"
11
12
  }
12
13
  }
package/render/builder.ts CHANGED
@@ -125,11 +125,11 @@ const buildTextIcon = (
125
125
  unit: 'px' | 'rpx'
126
126
  ): RenderNode['icon'] | undefined => {
127
127
  const icon = el.icon;
128
- if (!icon || icon.enable === false) return undefined;
129
-
128
+ const enabled = icon?.enable === true;
129
+ if (!icon || !enabled) return undefined;
130
+
130
131
  const style = icon.style || 'fill';
131
- // el.extra.icon ||
132
- const baseName = el.key || el.binding || el.id;
132
+ const baseName = icon.name || el.key || el.binding || el.id;
133
133
  let name: string | undefined;
134
134
  if (style === 'dot') name = 'round';
135
135
  else if (style === 'line') name = baseName ? `${baseName}-line` : undefined;