mountain-ui 1.0.117 → 1.0.118

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mountain-ui",
3
3
  "private": false,
4
- "version": "1.0.117",
4
+ "version": "1.0.118",
5
5
  "description": "A comprehensive UI component library for ERP systems with field types, entities, and registry management built with Svelte",
6
6
  "type": "module",
7
7
  "module": "index.js",
@@ -1,17 +1,23 @@
1
+ import { get } from "svelte/store";
2
+ import { widgetTypeRegistry } from "../widgetTypeRegistry/registry.svelte";
1
3
 
2
4
 
3
5
  export function createWidget(config = {}) {
4
6
  const widget = {
5
7
  id: null,
6
- group_id:null,
7
- position:1,
8
- type:null,
9
- title:"",
10
- props:{},
8
+ group_id: null,
9
+ position: 1,
10
+ type: null,
11
+ title: "",
12
+ props: {},
11
13
  };
12
14
 
13
15
  Object.assign(widget, config);
14
16
 
17
+ widget.getEntityIds = () => {
18
+ const widgetType = widgetTypeRegistry.get(widget.type)
19
+ return widgetType.getEntityIds(widget.props)
20
+ }
15
21
 
16
22
  return widget;
17
23
  }
@@ -41,6 +41,25 @@ function createWidgetGroupRegistry() {
41
41
  getAll() {
42
42
  return all;
43
43
  },
44
+
45
+ getWidgetIdFromEntityId(entityId) {
46
+ const allWidgetGroups = get(this.getAll())
47
+
48
+ let widgetIds = []
49
+
50
+ for (const widgetGroup of allWidgetGroups) {
51
+ for (const widget of widgetGroup.children) {
52
+ const entityIds = widget.getEntityIds()
53
+
54
+ if (!entityIds.includes(entityId)) continue
55
+
56
+ widgetIds.push(widget.id)
57
+ }
58
+ }
59
+
60
+ return widgetIds;
61
+
62
+ },
44
63
  };
45
64
  }
46
65
 
@@ -10,11 +10,11 @@ export function createWidgetType(config = {}) {
10
10
  config:null,
11
11
  preview:null,
12
12
  component:null,
13
- }
13
+ },
14
+ getEntityIds:(widgetProps)=>null
14
15
  };
15
16
 
16
17
  Object.assign(widgetType, config);
17
18
 
18
-
19
19
  return widgetType;
20
20
  }
@@ -9,5 +9,8 @@ export default createWidgetType({
9
9
  components:{
10
10
  config:ConfigBar,
11
11
  component:Bar,
12
+ },
13
+ getEntityIds:(props)=>{
14
+ return [props.entityId]
12
15
  }
13
16
  })
@@ -9,5 +9,8 @@ export default createWidgetType({
9
9
  components: {
10
10
  config: ConfigEvolution,
11
11
  component: Evolution,
12
+ },
13
+ getEntityIds:(props)=>{
14
+ return [props.entityId]
12
15
  }
13
16
  })
@@ -8,5 +8,8 @@ export default createWidgetType({
8
8
  components: {
9
9
  config: ConfigKPI,
10
10
  component: KPI,
11
+ },
12
+ getEntityIds:(props)=>{
13
+ return [props.entityId]
11
14
  }
12
15
  })
@@ -8,5 +8,8 @@ export default createWidgetType({
8
8
  components: {
9
9
  config: ConfigList,
10
10
  component: List,
11
+ },
12
+ getEntityIds:(props)=>{
13
+ return [props.entityId]
11
14
  }
12
15
  })