km-card-layout-core 0.1.5 → 0.1.6

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/utils.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.backgroundChange = backgroundChange;
4
4
  exports.stripLayoutBindings = stripLayoutBindings;
5
5
  exports.applyItemCollectBindings = applyItemCollectBindings;
6
+ exports.getTemplateItems = getTemplateItems;
6
7
  function backgroundChange(bg, layout) {
7
8
  const toNameArray = (name) => {
8
9
  if (Array.isArray(name))
@@ -119,3 +120,7 @@ function applyItemCollectBindings(layouts = [], items = []) {
119
120
  children: (layout.children || []).map(assignBinding),
120
121
  }));
121
122
  }
123
+ function getTemplateItems(ids, items) {
124
+ const idArray = ids.split(',').map(id => id.trim());
125
+ return items.filter(item => idArray.includes(String(item.id)));
126
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "km-card-layout-core",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
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/utils.ts CHANGED
@@ -88,7 +88,7 @@ export function stripLayoutBindings(
88
88
  * 应用元素数据绑定字段
89
89
  * @param layouts 布局
90
90
  * @param items 绑定元素数据
91
- * @returns
91
+ * @returns
92
92
  */
93
93
  export function applyItemCollectBindings(
94
94
  layouts: CardLayoutSchema[] = [],
@@ -103,7 +103,7 @@ export function applyItemCollectBindings(
103
103
  }
104
104
  });
105
105
 
106
- const assignBinding = (el: CardElement): CardElement => {
106
+ const assignBinding = (el: CardElement): CardElement => {
107
107
  const meta = metaMap.get(String(el.id));
108
108
  const binding =
109
109
  meta && meta.bind !== undefined && meta.bind !== null
@@ -134,3 +134,8 @@ export function applyItemCollectBindings(
134
134
  children: (layout.children || []).map(assignBinding),
135
135
  }));
136
136
  }
137
+
138
+ export function getTemplateItems(ids: string, items: ItemCollectMeta[]) {
139
+ const idArray = ids.split(',').map(id => id.trim());
140
+ return items.filter(item => idArray.includes(String(item.id)));
141
+ }