mountain-ui 1.0.72 → 1.0.74

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.72",
4
+ "version": "1.0.74",
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",
@@ -8,6 +8,7 @@
8
8
  const allEntities = entityRegistry.getAll();
9
9
 
10
10
  function handleChange(entity) {
11
+
11
12
  activeEntityId = entity.id;
12
13
 
13
14
  onChange(entity);
@@ -27,18 +27,37 @@
27
27
  }
28
28
  </script>
29
29
 
30
- {#if entryActionId}
31
- {#if $entryAction && name && props}
32
- <EntryActionProperties entryActionType={$entryAction.type} bind:name bind:props {...restProps}
30
+ <div class="form">
31
+ {#if entryActionId}
32
+ {#if $entryAction && name && props}
33
+ <EntryActionProperties entryActionType={$entryAction.type} bind:name bind:props {...restProps}
34
+ ></EntryActionProperties>
35
+ <div class="btn-zone">
36
+ <Button onClick={handleSubmit}>
37
+ <h5>éditer</h5>
38
+ </Button>
39
+ </div>
40
+ {/if}
41
+ {:else}
42
+ <EntryActionProperties {entryActionType} bind:name bind:props {...restProps}
33
43
  ></EntryActionProperties>
34
- <Button onClick={handleSubmit}>
35
- <h5>éditer</h5>
36
- </Button>
44
+ <div class="btn-zone">
45
+ <Button onClick={handleSubmit}>
46
+ <h5>créée</h5>
47
+ </Button>
48
+ </div>
37
49
  {/if}
38
- {:else}
39
- <EntryActionProperties {entryActionType} bind:name bind:props {...restProps}
40
- ></EntryActionProperties>
41
- <Button onClick={handleSubmit}>
42
- <h5>créée</h5>
43
- </Button>
44
- {/if}
50
+ </div>
51
+
52
+ <style>
53
+ .form {
54
+ display: flex;
55
+ flex-direction: column;
56
+ width: 100%;
57
+ }
58
+
59
+ .btn-zone {
60
+ width: 100%;
61
+ display: flex;
62
+ }
63
+ </style>
@@ -13,7 +13,7 @@
13
13
  props = $bindable({
14
14
  fromEntityId: null,
15
15
  toEntityId: null,
16
- bindings: null //[
16
+ bindings: [] //[
17
17
  // {
18
18
  // fromFieldId:null,
19
19
  // toFieldId:null,
@@ -35,6 +35,7 @@
35
35
  onChange = (props) => {}
36
36
  } = $props();
37
37
 
38
+
38
39
  let fromEntityId = $derived(props.fromEntityId);
39
40
  let toEntityId = $derived(props.toEntityId);
40
41
 
@@ -43,29 +44,13 @@
43
44
 
44
45
  let isMounted = $state(false);
45
46
 
46
- onMount(()=>{
47
- isMounted = true
48
- })
49
-
50
- $effect(() => {
51
- const newProps = getProps(fromEntityId, toEntityId);
52
-
53
- if (newProps === null) return
54
-
55
- props = {...newProps}
56
- });
57
-
58
- function getProps() {
59
- if (!isMounted && props.bindings !== null) {
60
- return props
61
- }
62
-
47
+ function updateBindings() {
63
48
  let newProps = {
64
49
  fromEntityId: fromEntityId,
65
50
  toEntityId: toEntityId
66
51
  };
67
52
  if (!fromEntity) {
68
- return {
53
+ props = {
69
54
  ...newProps,
70
55
  bindings: []
71
56
  };
@@ -81,7 +66,7 @@
81
66
  });
82
67
  }
83
68
 
84
- return {
69
+ props = {
85
70
  ...newProps,
86
71
  bindings: [...newBindings]
87
72
  };
@@ -90,11 +75,29 @@
90
75
  function getBinding(fieldId) {
91
76
  return props.bindings?.find((binding) => binding?.fromFieldId === fieldId);
92
77
  }
78
+
79
+ function handleChangeFromEntityId(entity) {
80
+ props = {
81
+ ...props,
82
+ fromEntityId: entity.id
83
+ };
84
+
85
+ updateBindings();
86
+ }
87
+ function handleChangeToEntityId(entity) {
88
+ props = {
89
+ ...props,
90
+ toEntityId: entity.id
91
+ };
92
+
93
+ updateBindings();
94
+ }
93
95
  </script>
94
96
 
95
97
  <div class="props">
96
98
  <div class="transfer">
97
- <EntitiesSelector bind:activeEntityId={fromEntityId}></EntitiesSelector>
99
+ <EntitiesSelector activeEntityId={fromEntityId} onChange={handleChangeFromEntityId}
100
+ ></EntitiesSelector>
98
101
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
99
102
  <path
100
103
  d="M14.4291 18.8201C14.2391 18.8201 14.0491 18.7501 13.8991 18.6001C13.6091 18.3101 13.6091 17.8301 13.8991 17.5401L19.4391 12.0001L13.8991 6.46012C13.6091 6.17012 13.6091 5.69012 13.8991 5.40012C14.1891 5.11012 14.6691 5.11012 14.9591 5.40012L21.0291 11.4701C21.3191 11.7601 21.3191 12.2401 21.0291 12.5301L14.9591 18.6001C14.8091 18.7501 14.6191 18.8201 14.4291 18.8201Z"
@@ -106,7 +109,8 @@
106
109
  />
107
110
  </svg>
108
111
 
109
- <EntitiesSelector bind:activeEntityId={toEntityId}></EntitiesSelector>
112
+ <EntitiesSelector activeEntityId={toEntityId} onChange={handleChangeToEntityId}
113
+ ></EntitiesSelector>
110
114
  </div>
111
115
 
112
116
  {#if fromEntity && toEntity}