mountain-ui 1.0.37 → 1.0.38

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.
Files changed (37) hide show
  1. package/index.d.ts +5 -5
  2. package/index.js +5 -5
  3. package/package.json +1 -1
  4. package/src/lib/registry/entityRegistry/components/EntityForm.svelte +1 -0
  5. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Input.svelte +1 -0
  6. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/Input.svelte +17 -1
  7. package/src/lib/registry/viewEntriesProfilRegistery/components/CreateViewEntriesProfilDialog.svelte +17 -0
  8. package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilButton.svelte +51 -0
  9. package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilComponent.svelte +32 -0
  10. package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilDropdown.svelte +60 -0
  11. package/src/lib/registry/viewEntriesProfilRegistery/createViewEntriesProfil.js +15 -0
  12. package/src/lib/registry/viewEntriesProfilRegistery/registerDefaultViewEntriesProfils.js +13 -0
  13. package/src/lib/registry/viewEntriesProfilRegistery/registry.svelte.js +48 -0
  14. package/src/lib/registry/{viewTypeRegistry/components/ViewTypeButton.svelte → viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte} +5 -4
  15. package/src/lib/registry/{viewTypeRegistry/components/ViewTypeComponent.svelte → viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte} +4 -4
  16. package/src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeDropdown.svelte +32 -0
  17. package/src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeIcon.svelte +9 -0
  18. package/src/lib/registry/viewEntriesTypeRegistry/createViewEntriesType.js +17 -0
  19. package/src/lib/registry/viewEntriesTypeRegistry/registerDefaultViewEntriesTypes.js +7 -0
  20. package/src/lib/registry/viewEntriesTypeRegistry/registry.svelte.js +44 -0
  21. package/src/lib/registry/{viewTypeRegistry/viewTypes → viewEntriesTypeRegistry/viewEntriesTypes}/Table/component/StructureTable.svelte +11 -4
  22. package/src/lib/registry/viewEntriesTypeRegistry/viewEntriesTypes/Table/index.js +14 -0
  23. package/src/routes/+layout.svelte +14 -3
  24. package/src/routes/+page.svelte +2 -2
  25. package/src/routes/exemple/+layout.svelte +2 -1
  26. package/src/routes/exemple/[project_normalized_name]/+layout.svelte +3 -1
  27. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+layout.svelte +1 -1
  28. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+page.svelte +182 -1
  29. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/[entry_id]/+page.svelte +25 -0
  30. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/create/+page.svelte +45 -0
  31. package/src/lib/registry/viewTypeRegistry/createViewType.js +0 -17
  32. package/src/lib/registry/viewTypeRegistry/registerDefaultViewTypes.js +0 -7
  33. package/src/lib/registry/viewTypeRegistry/registry.svelte.js +0 -44
  34. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/component/Component copy.svelte +0 -11
  35. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/index.js +0 -14
  36. /package/src/lib/registry/{viewTypeRegistry/viewTypes → viewEntriesTypeRegistry/viewEntriesTypes}/Table/Icon.svelte +0 -0
  37. /package/src/lib/registry/{viewTypeRegistry/viewTypes → viewEntriesTypeRegistry/viewEntriesTypes}/Table/component/Component.svelte +0 -0
package/index.d.ts CHANGED
@@ -45,9 +45,9 @@ export { default as LinkIcon } from './src/lib/registry/entityRegistry/component
45
45
  // View Registry
46
46
  // ============================================
47
47
 
48
- export { viewTypeRegistry } from './src/lib/registry/viewTypeRegistry/registry.svelte.js';
49
- export { createViewType } from './src/lib/registry/viewTypeRegistry/createViewType.js';
50
- export { registerDefaultViewTypes } from './src/lib/registry/viewTypeRegistry/registerDefaultViewTypes.js';
48
+ export { viewTypeRegistry } from './src/lib/registry/viewEntriesTypeRegistry/registry.svelte.js';
49
+ export { createViewType } from './src/lib/registry/viewEntriesTypeRegistry/createViewEntriesType.js';
50
+ export { registerDefaultViewTypes } from './src/lib/registry/viewEntriesTypeRegistry/registerDefaultViewEntriesTypes.js';
51
51
 
52
- export { default as ViewTypeButton } from './src/lib/registry/viewTypeRegistry/components/ViewTypeButton.svelte';
53
- export { default as ViewTypeComponent } from './src/lib/registry/viewTypeRegistry/components/ViewTypeComponent.svelte';
52
+ export { default as ViewTypeButton } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte';
53
+ export { default as ViewTypeComponent } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
package/index.js CHANGED
@@ -45,9 +45,9 @@ export { default as LinkIcon } from './src/lib/registry/entityRegistry/component
45
45
  // View Registry
46
46
  // ============================================
47
47
 
48
- export { viewTypeRegistry } from './src/lib/registry/viewTypeRegistry/registry.svelte.js';
49
- export { createViewType } from './src/lib/registry/viewTypeRegistry/createViewType.js';
50
- export { registerDefaultViewTypes } from './src/lib/registry/viewTypeRegistry/registerDefaultViewTypes.js';
48
+ export { viewTypeRegistry } from './src/lib/registry/viewEntriesTypeRegistry/registry.svelte.js';
49
+ export { createViewType } from './src/lib/registry/viewEntriesTypeRegistry/createViewEntriesType.js';
50
+ export { registerDefaultViewTypes } from './src/lib/registry/viewEntriesTypeRegistry/registerDefaultViewEntriesTypes.js';
51
51
 
52
- export { default as ViewTypeButton } from './src/lib/registry/viewTypeRegistry/components/ViewTypeButton.svelte';
53
- export { default as ViewTypeComponent } from './src/lib/registry/viewTypeRegistry/components/ViewTypeComponent.svelte';
52
+ export { default as ViewTypeButton } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte';
53
+ export { default as ViewTypeComponent } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mountain-ui",
3
3
  "private": false,
4
- "version": "1.0.37",
4
+ "version": "1.0.38",
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",
@@ -68,6 +68,7 @@
68
68
  onChange={(value) => {
69
69
  handleChange(field.id, value);
70
70
  }}
71
+ changeCtx={handleChange}
71
72
  id={field.id}
72
73
  entityId={$entity.id}
73
74
  value={ctx?.[field.id] ?? null}
@@ -155,6 +155,7 @@
155
155
  onChange={(value) => {
156
156
  handleChange(lineIndex, row.fieldId, value);
157
157
  }}
158
+ changeCtx={handleChange}
158
159
  id={row.fieldId}
159
160
  value={table[lineIndex].ctx?.[row.fieldId] ?? null}
160
161
  registerCalculation={(config)=>{
@@ -17,10 +17,17 @@
17
17
  linkId = null,
18
18
  multiple = false,
19
19
  display = false,
20
+ bindings = [
21
+ // {
22
+ // elementFieldId: 0,
23
+ // ctxFieldId:0
24
+ // }
25
+ ],
20
26
  name = null,
21
27
  value = null,
22
28
  onChangeDetails = () => {},
23
29
  onChange = () => {},
30
+ changeCtx = (fieldId, value) => {},
24
31
  field
25
32
  } = $props();
26
33
 
@@ -28,7 +35,7 @@
28
35
 
29
36
  let limit = 20;
30
37
 
31
- let structure = entityRegistry.get(linkId);
38
+ let structure = $derived(entityRegistry.get(linkId));
32
39
 
33
40
  let lastRequest = null;
34
41
 
@@ -86,6 +93,15 @@
86
93
 
87
94
  onChangeDetails(value?.element ?? null);
88
95
  onChange(value?.element.id.flat ?? null);
96
+
97
+ // changer le ctx
98
+ for (const bind of bindings) {
99
+ const elementField = entityRegistry.getField(bind.elementFieldId,structure.id)
100
+ if (!elementField) continue
101
+ const value = lastRequest.data[elementField.normalized_name]?.flat ?? null
102
+ // update la valeur dans le ctx
103
+ changeCtx(bind.ctxFieldId, value)
104
+ }
89
105
  }
90
106
  </script>
91
107
 
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import { Button, Dialog, Input } from "hamzus-ui";
3
+
4
+ let {isOpen= $bindable(false), onCreate = (name)=>{}} = $props()
5
+
6
+ let name = $derived(isOpen ? "" : "")
7
+
8
+
9
+ </script>
10
+ <Dialog bind:isOpen>
11
+ <div style="display:flex;row-gap:var(--pad-m);flex-direction:column;">
12
+ <h3>Créer une nouvelle vue</h3>
13
+ <p>Créer sur base des paramètre actuel une nouvelle vue ?</p>
14
+ <Input bind:value={name} label="nom"/>
15
+ <Button desabled={name === ""} onClick={()=>{onCreate(name)}}>confirmer</Button>
16
+ </div>
17
+ </Dialog>
@@ -0,0 +1,51 @@
1
+ <script>
2
+ import { Button } from 'hamzus-ui';
3
+ import { viewEntriesProfilRegistry } from '../registry.svelte';
4
+ import ViewEntriesTypeIcon from '$lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeIcon.svelte';
5
+
6
+ let { id, variant = 'ghost', ...props } = $props();
7
+
8
+ const viewProfil = $derived(viewEntriesProfilRegistry.get(id));
9
+ </script>
10
+
11
+ {#if viewProfil}
12
+ <Button {...props} {variant} style="padding:var(--pad-s) var(--pad-l) var(--pad-s) var(--pad-m);width:100%;">
13
+ <div class="ico">
14
+ <ViewEntriesTypeIcon type={viewProfil.type}></ViewEntriesTypeIcon>
15
+ </div>
16
+ <h5>{viewProfil.name}</h5>
17
+ {#if viewProfil.is_default}
18
+ <div class="ico-end">
19
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
20
+ <path d="M6.44922 22C6.03922 22 5.69922 21.66 5.69922 21.25V2.75C5.69922 2.34 6.03922 2 6.44922 2C6.85922 2 7.19922 2.34 7.19922 2.75V21.25C7.19922 21.66 6.85922 22 6.44922 22Z" fill="#292D32"/>
21
+ <path opacity="0.4" d="M15.2001 7.16004L7.10008 3.66004C6.98008 3.60004 6.85008 3.62004 6.74008 3.69004C6.64008 3.76004 6.58008 3.87004 6.58008 4.00004V17C6.58008 17.13 6.65008 17.25 6.76008 17.32C6.82008 17.36 6.89008 17.38 6.96008 17.38C7.02008 17.38 7.07008 17.37 7.13008 17.34L15.4301 13.24C15.4301 13.24 15.4301 13.24 15.4401 13.24C17.1001 12.38 17.9901 11.27 17.9401 10.1C17.8801 8.92004 16.9101 7.88004 15.2001 7.16004Z" fill="#292D32"/>
22
+ </svg>
23
+
24
+
25
+
26
+ </div>
27
+ {/if}
28
+ </Button>
29
+ {/if}
30
+
31
+ <style>
32
+ .ico {
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ width: 16px;
37
+ height: 16px;
38
+ }
39
+ .ico-end {
40
+ display: flex;
41
+ align-items: center;
42
+ justify-content: center;
43
+ width: 16px;
44
+ height: 16px;
45
+ margin-left: auto;
46
+ }
47
+
48
+ .ico path {
49
+ fill: var(--font-2);
50
+ }
51
+ </style>
@@ -0,0 +1,32 @@
1
+ <script>
2
+ import { Button, RotativeLoader } from 'hamzus-ui';
3
+ import { viewEntriesProfilRegistry } from '../registry.svelte';
4
+ import ViewEntriesTypeComponent from '$lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
5
+
6
+ let { id, ...props } = $props();
7
+
8
+ const viewProfil = $derived(viewEntriesProfilRegistry.select(id));
9
+
10
+ $effect(()=>{
11
+ console.log($viewProfil.props);
12
+
13
+ })
14
+ </script>
15
+ {#if $viewProfil}
16
+ {#key id}
17
+ <ViewEntriesTypeComponent type={$viewProfil.type} {...$viewProfil.props} {...props}><slot name="actions" slot="actions"/></ViewEntriesTypeComponent>
18
+ {/key}
19
+ {:else}
20
+ <div class="loader">
21
+ <RotativeLoader></RotativeLoader>
22
+ </div>
23
+ {/if}
24
+
25
+ <style>
26
+ .loader {
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ padding: 60px var(--pad-m);
31
+ }
32
+ </style>
@@ -0,0 +1,60 @@
1
+ <script>
2
+ import { Button, DropdownMenu } from 'hamzus-ui';
3
+ import { viewEntriesProfilRegistry } from '../registry.svelte';
4
+ import ViewProfilButton from './ViewEntriesProfilButton.svelte';
5
+ import CreateViewEntriesProfilDialog from './CreateViewEntriesProfilDialog.svelte';
6
+
7
+ let { onChange = (id) => {}, id = null, onCreate = (name)=>{}, onDelete = (id)=>{},onDesableAsDefault = ()=>{}, onSetAsDefault = (id)=>{}, props = $bindable({}) } = $props();
8
+
9
+ let createViewIsOpen = $state(false)
10
+
11
+ const targetViewProfil = $derived(viewEntriesProfilRegistry.select(id))
12
+
13
+ const viewProfils = viewEntriesProfilRegistry.getAll();
14
+ </script>
15
+
16
+ <CreateViewEntriesProfilDialog bind:isOpen={createViewIsOpen} {onCreate}></CreateViewEntriesProfilDialog>
17
+
18
+ <DropdownMenu.Root direction="bottom">
19
+ <DropdownMenu.Trigger slot="trigger">
20
+ {#if id !== null}
21
+ <ViewProfilButton variant="secondary" {id}></ViewProfilButton>
22
+ {:else}
23
+ <Button variant="secondary" style="width:100%">
24
+ <h5>selectionner un profil de vue</h5>
25
+ </Button>
26
+ {/if}
27
+ </DropdownMenu.Trigger>
28
+ <DropdownMenu.Content slot="content" width="250px">
29
+ {#each $viewProfils as viewProfil}
30
+ <ViewProfilButton
31
+ variant={viewProfil.id === id ? 'secondary' : 'ghost'}
32
+ onClick={() => {
33
+ onChange(viewProfil.id);
34
+ }}
35
+ id={viewProfil.id}
36
+ ></ViewProfilButton>
37
+ {/each}
38
+ <DropdownMenu.Separator></DropdownMenu.Separator>
39
+
40
+ <Button variant="ghost" style="width:100%;" onClick={()=>{createViewIsOpen = true}}>
41
+ <h5>Créer</h5>
42
+ </Button>
43
+ {#if !($targetViewProfil?.is_default ?? false)}
44
+ <Button variant="ghost" style="width:100%;" onClick={()=>{
45
+ if (id === 0) {
46
+ onDesableAsDefault(id)
47
+ } else {
48
+ onSetAsDefault(id)
49
+ }
50
+ }}>
51
+ <h5>Définir par défaut</h5>
52
+ </Button>
53
+ {/if}
54
+ {#if id !== 0}
55
+ <Button variant="destructive" style="width:100%;" onClick={()=>{onDelete(id)}}>
56
+ <h5>Supprimer</h5>
57
+ </Button>
58
+ {/if}
59
+ </DropdownMenu.Content>
60
+ </DropdownMenu.Root>
@@ -0,0 +1,15 @@
1
+ export function createViewEntriesProfil(config = {}) {
2
+ const viewEntriesProfil = {
3
+ id:0,
4
+ name:"",
5
+ type:"",
6
+ is_default:"",
7
+ props:{},
8
+ };
9
+
10
+ Object.assign(viewEntriesProfil, config);
11
+
12
+ // viewEntriesProfil.get = () => "test";
13
+
14
+ return viewEntriesProfil;
15
+ }
@@ -0,0 +1,13 @@
1
+ import { createViewEntriesProfil } from './createViewEntriesProfil';
2
+ import { viewEntriesProfilRegistry } from './registry.svelte';
3
+
4
+
5
+ export function registerDefaultViewProfil() {
6
+ viewEntriesProfilRegistry.register(createViewEntriesProfil({
7
+ id:0,
8
+ name:"vue par défaut",
9
+ is_default:false,
10
+ type:"table",
11
+ props:{}
12
+ }))
13
+ }
@@ -0,0 +1,48 @@
1
+ import { writable, derived, get } from 'svelte/store';
2
+
3
+ function createViewEntriesProfilRegistry() {
4
+ const store = writable({});
5
+
6
+ const all = derived(store, ($viewEntriesProfils) => Object.values($viewEntriesProfils));
7
+
8
+ return {
9
+ subscribe: store.subscribe,
10
+
11
+ register(viewEntriesProfil) {
12
+ store.update((viewEntriesProfils) => ({
13
+ ...viewEntriesProfils,
14
+ [viewEntriesProfil.id]: viewEntriesProfil
15
+ }));
16
+ },
17
+
18
+ unregisterAll(viewEntriesProfil) {
19
+ store.update((viewEntriesProfils) => ({}));
20
+ },
21
+
22
+ unregister(id) {
23
+ store.update((viewEntriesProfils) => {
24
+ const copy = { ...viewEntriesProfils };
25
+
26
+ delete copy[id];
27
+
28
+ return copy;
29
+ });
30
+ },
31
+
32
+ get(id) {
33
+ return get(store)[id];
34
+ },
35
+
36
+ select(id) {
37
+ return derived(store, ($viewEntriesProfils) => $viewEntriesProfils[id]);
38
+ },
39
+
40
+
41
+
42
+ getAll() {
43
+ return all;
44
+ }
45
+ };
46
+ }
47
+
48
+ export const viewEntriesProfilRegistry = createViewEntriesProfilRegistry();
@@ -1,16 +1,17 @@
1
1
  <script>
2
2
  import { Button } from 'hamzus-ui';
3
- import { viewTypeRegistry } from '../registry.svelte';
3
+ import { viewEntriesTypeRegistry } from '../registry.svelte';
4
+ import ViewEntriesTypeIcon from './ViewEntriesTypeIcon.svelte';
4
5
 
5
6
  let { type, variant = 'ghost', ...props } = $props();
6
7
 
7
- const viewType = viewTypeRegistry.get(type);
8
+ const viewType = viewEntriesTypeRegistry.get(type);
8
9
  </script>
9
10
 
10
11
  {#if viewType}
11
- <Button {...props} {variant} style="padding:var(--pad-s) var(--pad-l) var(--pad-s) var(--pad-s);width:100%;">
12
+ <Button {...props} {variant} style="padding:var(--pad-s) var(--pad-l) var(--pad-s) var(--pad-m);width:100%;">
12
13
  <div class="ico">
13
- <svelte:component this={viewType.components.icon}></svelte:component>
14
+ <ViewEntriesTypeIcon {type}></ViewEntriesTypeIcon>
14
15
  </div>
15
16
  <h5>{viewType.name}</h5>
16
17
  </Button>
@@ -1,17 +1,17 @@
1
1
  <script>
2
2
  import { Button, RotativeLoader } from 'hamzus-ui';
3
- import { viewTypeRegistry } from '../registry.svelte';
3
+ import { viewEntriesTypeRegistry } from '../registry.svelte';
4
4
 
5
5
  let { type, ...props } = $props();
6
6
 
7
- const viewType = viewTypeRegistry.get(type);
7
+ const viewType = $derived(viewEntriesTypeRegistry.get(type));
8
8
 
9
- console.log(viewType);
9
+ const ViewTypeComponent = $derived(viewType?.components?.component ?? null)
10
10
 
11
11
  </script>
12
12
 
13
13
  {#if viewType}
14
- <svelte:component this={viewType.components.component} {...props}></svelte:component>
14
+ <ViewTypeComponent {...props}><slot name="actions" slot="actions"/></ViewTypeComponent>
15
15
  {:else}
16
16
  <div class="loader">
17
17
  <RotativeLoader></RotativeLoader>
@@ -0,0 +1,32 @@
1
+ <script>
2
+ import { Button, DropdownMenu } from 'hamzus-ui';
3
+ import { viewEntriesTypeRegistry } from '../registry.svelte';
4
+ import ViewTypeButton from './ViewEntriesTypeButton.svelte';
5
+
6
+ let { onChange = (type) => {}, type = null } = $props();
7
+
8
+ const viewTypes = viewEntriesTypeRegistry.getAll();
9
+ </script>
10
+
11
+ <DropdownMenu.Root direction="bottom">
12
+ <DropdownMenu.Trigger slot="trigger">
13
+ {#if type !== null}
14
+ <ViewTypeButton variant="secondary" {type}></ViewTypeButton>
15
+ {:else}
16
+ <Button variant="secondary" style="width:100%">
17
+ <h5>selectionner un type de vue</h5>
18
+ </Button>
19
+ {/if}
20
+ </DropdownMenu.Trigger>
21
+ <DropdownMenu.Content slot="content" width="250px">
22
+ {#each $viewTypes as viewType}
23
+ <ViewTypeButton
24
+ variant={viewType.type === type ? 'secondary' : 'ghost'}
25
+ onClick={() => {
26
+ onChange(viewType.type);
27
+ }}
28
+ type={viewType.type}
29
+ ></ViewTypeButton>
30
+ {/each}
31
+ </DropdownMenu.Content>
32
+ </DropdownMenu.Root>
@@ -0,0 +1,9 @@
1
+ <script>
2
+ import { viewEntriesTypeRegistry } from "../registry.svelte";
3
+
4
+ let { type } = $props();
5
+
6
+ const viewType = viewEntriesTypeRegistry.get(type);
7
+ </script>
8
+
9
+ <svelte:component this={viewType.components.icon}></svelte:component>
@@ -0,0 +1,17 @@
1
+ export function createViewEntriesType(config = {}) {
2
+ const viewEntriesType = {
3
+ type:"",
4
+ name:"",
5
+ description:"",
6
+ components : {
7
+ component:null,
8
+ icon:null,
9
+ }
10
+ };
11
+
12
+ Object.assign(viewEntriesType, config);
13
+
14
+ // viewEntriesType.get = () => "test";
15
+
16
+ return viewEntriesType;
17
+ }
@@ -0,0 +1,7 @@
1
+ import { viewEntriesTypeRegistry } from './registry.svelte';
2
+ import Table from './viewEntriesTypes/Table';
3
+
4
+
5
+ export function registerDefaultViewEntriesTypes() {
6
+ viewEntriesTypeRegistry.register(Table)
7
+ }
@@ -0,0 +1,44 @@
1
+ import { writable, derived, get } from 'svelte/store';
2
+
3
+ function createViewEntriesTypeRegistry() {
4
+ const store = writable({});
5
+
6
+ const all = derived(store, ($viewEntriesTypes) => Object.values($viewEntriesTypes));
7
+
8
+ return {
9
+ subscribe: store.subscribe,
10
+
11
+ register(viewEntriesType) {
12
+ store.update((viewEntriesTypes) => ({
13
+ ...viewEntriesTypes,
14
+ [viewEntriesType.type]: viewEntriesType
15
+ }));
16
+ },
17
+
18
+ unregister(type) {
19
+ store.update((viewEntriesTypes) => {
20
+ const copy = { ...viewEntriesTypes };
21
+
22
+ delete copy[type];
23
+
24
+ return copy;
25
+ });
26
+ },
27
+
28
+ get(type) {
29
+ return get(store)[type];
30
+ },
31
+
32
+ select(type) {
33
+ return derived(store, ($viewEntriesTypes) => $viewEntriesTypes[type]);
34
+ },
35
+
36
+
37
+
38
+ getAll() {
39
+ return all;
40
+ }
41
+ };
42
+ }
43
+
44
+ export const viewEntriesTypeRegistry = createViewEntriesTypeRegistry();
@@ -11,16 +11,19 @@
11
11
  entityId = null,
12
12
  path = '/get-all-entries',
13
13
  data = {},
14
+ onClick = (rowData)=>{},
14
15
  slug = null,
15
16
  onChange = () => {},
17
+ onChangeProps = (newProps) => {},
16
18
  invisibleFilters = {},
17
19
  structureColumns = [],
20
+ defaultFilters = {},
18
21
  defaultColumns = {},
19
22
  defaultProps = {},
20
23
  ...props
21
24
  } = $props();
22
25
 
23
- const entity = entityRegistry.select(entityId);
26
+ const entity = $derived(entityRegistry.select(entityId))
24
27
 
25
28
  let error = $state(null);
26
29
 
@@ -33,6 +36,8 @@
33
36
  });
34
37
 
35
38
  onMount(() => {
39
+ console.log();
40
+
36
41
  mounted = true;
37
42
  getColumnsFromStructureColumns($entity);
38
43
  });
@@ -203,11 +208,13 @@
203
208
  defaultFilters: defaultFilters,
204
209
  defaultColumns: defaultColumns
205
210
  };
211
+
212
+ onChangeProps(defaultProps)
206
213
  }
207
214
 
208
- function onClick(rowData) {
215
+ function handleClick(rowData) {
209
216
  // rediriger vers
210
- goto(`/${$page.params.projet_slug}/${$page.params.origin}/${slug ?? $page.params.structure_slug}/${rowData.id}`);
217
+ onClick(rowData)
211
218
  }
212
219
  </script>
213
220
 
@@ -250,7 +257,7 @@
250
257
  <p>Impossible de récuperer l'entrée !</p>
251
258
  </div>
252
259
  {:else if columns.length > 0}
253
- <TableV2.Root {getRows} onChange={handleChange} {onClick} {columns} {...props}>
260
+ <TableV2.Root {getRows} onChange={handleChange} onClick={handleClick} {columns} {...props} filters={defaultFilters}>
254
261
  <TableV2.ActionsBar slot="actions-bar"
255
262
  ><slot name="actions" slot="actions" /></TableV2.ActionsBar
256
263
  >
@@ -0,0 +1,14 @@
1
+ import { createViewEntriesType } from '../../createViewEntriesType';
2
+
3
+ import Icon from './Icon.svelte'
4
+ import Component from './component/Component.svelte'
5
+
6
+ export default createViewEntriesType({
7
+ type: "table",
8
+ name: "Tableau",
9
+ description: "",
10
+ components: {
11
+ component: Component,
12
+ icon: Icon,
13
+ },
14
+ });
@@ -6,9 +6,11 @@
6
6
  import { entityRegistry } from '$lib/registry/entityRegistry/registry.svelte';
7
7
  import { createEntity } from '$lib/registry/entityRegistry/createEntity';
8
8
  import { init, sendRequest } from 'hamzus-ui';
9
- import { registerDefaultViewTypes } from '$lib/registry/viewTypeRegistry/registerDefaultViewTypes';
9
+ import { registerDefaultViewEntriesTypes } from '$lib/registry/viewEntriesTypeRegistry/registerDefaultViewEntriesTypes';
10
10
  import { projectRegistry } from '$lib/registry/projectRegistry/registry.svelte';
11
11
  import { createProject } from '$lib/registry/projectRegistry/createProject';
12
+ import { page } from '$app/stores';
13
+ import { registerDefaultViewProfil } from '$lib/registry/viewEntriesProfilRegistery/registerDefaultViewEntriesProfils';
12
14
 
13
15
  let { children } = $props();
14
16
 
@@ -24,8 +26,11 @@
24
26
  if (!response || response.statusType === 'error') {
25
27
  // si il est pas encore dans la page de login on redirige
26
28
  const path = '/login';
29
+
30
+ if ($page.url.pathname === path) return
31
+ window.location.href = defaultUnlogged;
32
+
27
33
 
28
- window.location.href = defaultUnlogged;
29
34
  }
30
35
  },
31
36
  replayAfter401: true,
@@ -37,20 +42,26 @@
37
42
  });
38
43
 
39
44
  onMount(async () => {
45
+
40
46
  registerDefaultFieldTypes();
47
+ registerDefaultViewEntriesTypes();
41
48
 
42
49
  // récuperer les projets
43
50
  const projectStructures = await sendRequest({
44
51
  path: '/get-all-projects'
45
52
  });
46
53
 
54
+ if (!projectStructures || projectStructures.statusType === "error") {
55
+ isMount = true
56
+ return
57
+ }
58
+
47
59
  for (const project of projectStructures.data) {
48
60
  projectRegistry.register(createProject(project));
49
61
  }
50
62
 
51
63
 
52
64
 
53
- registerDefaultViewTypes();
54
65
 
55
66
  // enregistrer des entité
56
67
  // entityRegistry.register(
@@ -15,8 +15,8 @@
15
15
  import FieldTypeTableView from '$lib/registry/fieldTypeRegistry/components/FieldTypeTableView.svelte';
16
16
  import FieldTypeView from '$lib/registry/fieldTypeRegistry/components/FieldTypeView.svelte';
17
17
  import { fieldTypeRegistry } from '$lib/registry/fieldTypeRegistry/registry.svelte';
18
- import ViewTypeComponent from '$lib/registry/viewTypeRegistry/components/ViewTypeComponent.svelte';
19
- import { viewTypeRegistry } from '$lib/registry/viewTypeRegistry/registry.svelte';
18
+ import ViewTypeComponent from '$lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
19
+ import { viewTypeRegistry } from '$lib/registry/viewEntriesTypeRegistry/registry.svelte';
20
20
  import { onMount } from 'svelte';
21
21
 
22
22
  const entities = entityRegistry.getAll();
@@ -20,7 +20,7 @@
20
20
  <nav class="top-bar">
21
21
  <h3>Mountain UI</h3>
22
22
  <div class="project-selector">
23
- <ProjectDropdown projectId={projectRegistry.getFromNormalizedName($page.params.project_normalized_name).id} hubHref="/exemple" {getHref} {isActive}></ProjectDropdown>
23
+ <ProjectDropdown projectId={projectRegistry.getFromNormalizedName($page.params.project_normalized_name)?.id ?? null} hubHref="/exemple" {getHref} {isActive}></ProjectDropdown>
24
24
  </div>
25
25
 
26
26
  </nav>
@@ -34,6 +34,7 @@
34
34
  display: flex;
35
35
  align-items: center;
36
36
  justify-content: space-between;
37
+ flex-shrink: 0;
37
38
  padding: var(--pad-s);
38
39
  border-bottom: 1px solid var(--stroke);
39
40
  }
@@ -87,12 +87,14 @@
87
87
  width: 100%;
88
88
  height: 40px;
89
89
  position: sticky;
90
- top: 0px;
90
+ top: 43px;
91
91
  display: flex;
92
92
  align-items: center;
93
93
  column-gap: var(--pad-m);
94
94
  padding: var(--pad-s);
95
95
  border-bottom: 1px solid var(--stroke);
96
96
  overflow-x: auto;
97
+ flex-shrink: 0;
98
+ background-color: var(--bg-1);
97
99
  }
98
100
  </style>
@@ -40,5 +40,5 @@
40
40
  <p>L'entité n'a pas peu être trouvé !</p>
41
41
  </div>
42
42
  {:else}
43
- {@render children()}
43
+ {@render children()}
44
44
  {/if}
@@ -1 +1,182 @@
1
- <h3>entity</h3>
1
+ <script>
2
+ import { beforeNavigate, goto } from '$app/navigation';
3
+ import { page } from '$app/stores';
4
+ import { entityRegistry } from '$lib/registry/entityRegistry/registry.svelte';
5
+ import ViewEntriesProfilComponent from '$lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilComponent.svelte';
6
+ import ViewEntriesProfilDropdown from '$lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilDropdown.svelte';
7
+ import { createViewEntriesProfil } from '$lib/registry/viewEntriesProfilRegistery/createViewEntriesProfil';
8
+ import { registerDefaultViewProfil } from '$lib/registry/viewEntriesProfilRegistery/registerDefaultViewEntriesProfils';
9
+ import { viewEntriesProfilRegistry } from '$lib/registry/viewEntriesProfilRegistery/registry.svelte';
10
+ import ViewEntriesTypeDropdown from '$lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeDropdown.svelte';
11
+ import { Button, DropdownMenu, IconButton, sendRequest } from 'hamzus-ui';
12
+ import { onMount } from 'svelte';
13
+
14
+ const targetEntity = $derived(entityRegistry.getFromSlug($page.params.entity_slug));
15
+
16
+ let targetViewId = $state(null);
17
+
18
+ let viewProps = $state({});
19
+
20
+ beforeNavigate(() => {
21
+ targetViewId = null;
22
+ });
23
+
24
+ onMount(loadAllViewEntriesProfil);
25
+
26
+ async function loadAllViewEntriesProfil() {
27
+ viewEntriesProfilRegistry.unregisterAll();
28
+
29
+ registerDefaultViewProfil();
30
+
31
+ const request = await sendRequest({
32
+ path: '/get-all-views-from-entity-id',
33
+ data: {
34
+ entityId: targetEntity.id
35
+ }
36
+ });
37
+
38
+ let defaultView = 0;
39
+
40
+ for (const viewProfil of request.data) {
41
+ console.log(viewProfil);
42
+
43
+ if (viewProfil.is_default) {
44
+ defaultView = viewProfil.id;
45
+ }
46
+
47
+ viewEntriesProfilRegistry.register(
48
+ createViewEntriesProfil({
49
+ id: viewProfil.id,
50
+ is_default: viewProfil.is_default,
51
+ name: viewProfil.name,
52
+ type: 'table',
53
+ props: viewProfil.props
54
+ })
55
+ );
56
+ }
57
+
58
+ targetViewId = defaultView;
59
+ }
60
+
61
+ function onChange(id) {
62
+ targetViewId = id;
63
+ }
64
+
65
+ function handleClick(data) {
66
+ console.log();
67
+ goto(
68
+ `/exemple/${$page.params.project_normalized_name}/${$page.params.entity_slug}/${data.id.props.value.flat}`
69
+ );
70
+ }
71
+
72
+ function onChangeProps(props) {
73
+ viewProps = props;
74
+ }
75
+
76
+ async function handleCreateViewProfil(name) {
77
+ console.log(viewProps);
78
+
79
+ const request = await sendRequest({
80
+ path: '/create-view',
81
+ data: {
82
+ entityId: targetEntity.id,
83
+ defaultProps: JSON.stringify(viewProps),
84
+ name
85
+ }
86
+ });
87
+ }
88
+ async function handleDesableDefault() {
89
+ const request = await sendRequest({
90
+ path: '/desable-default-view',
91
+ data: {
92
+ entityId: targetEntity.id
93
+ }
94
+ });
95
+
96
+ loadAllViewEntriesProfil();
97
+ }
98
+ async function handleDeleteViewProfil(id) {
99
+ const request = await sendRequest({
100
+ path: '/delete-view',
101
+ data: {
102
+ viewId: id
103
+ }
104
+ });
105
+
106
+ loadAllViewEntriesProfil();
107
+ }
108
+
109
+ async function handleSetAsDefaultViewProfil(id) {
110
+ const request = await sendRequest({
111
+ path: '/set-as-default-view',
112
+ data: {
113
+ viewId: id
114
+ }
115
+ });
116
+
117
+ loadAllViewEntriesProfil();
118
+ }
119
+ </script>
120
+
121
+ <div class="top-bar">
122
+ <h4>{targetEntity.plural_name}</h4>
123
+ <div class="view-profil-selector">
124
+ <ViewEntriesProfilDropdown
125
+ {onChange}
126
+ id={targetViewId}
127
+ onCreate={handleCreateViewProfil}
128
+ onDesableAsDefault={handleDesableDefault}
129
+ onSetAsDefault={handleSetAsDefaultViewProfil}
130
+ onDelete={handleDeleteViewProfil}
131
+ ></ViewEntriesProfilDropdown>
132
+ </div>
133
+ </div>
134
+ {#if targetViewId !== null && targetEntity}
135
+ <ViewEntriesProfilComponent
136
+ id={targetViewId}
137
+ entityId={targetEntity.id}
138
+ onClick={handleClick}
139
+ {onChangeProps}
140
+ >
141
+ <div slot="actions">
142
+ <DropdownMenu.Root direction="bottom">
143
+ <DropdownMenu.Trigger slot="trigger">
144
+ <IconButton size="26px" variant="outline"
145
+ ><svg
146
+ width="24"
147
+ height="24"
148
+ viewBox="0 0 24 24"
149
+ fill="none"
150
+ xmlns="http://www.w3.org/2000/svg"
151
+ >
152
+ <path
153
+ d="M11.9995 16.8001C11.2995 16.8001 10.5995 16.5301 10.0695 16.0001L3.54953 9.48014C3.25953 9.19014 3.25953 8.71014 3.54953 8.42014C3.83953 8.13014 4.31953 8.13014 4.60953 8.42014L11.1295 14.9401C11.6095 15.4201 12.3895 15.4201 12.8695 14.9401L19.3895 8.42014C19.6795 8.13014 20.1595 8.13014 20.4495 8.42014C20.7395 8.71014 20.7395 9.19014 20.4495 9.48014L13.9295 16.0001C13.3995 16.5301 12.6995 16.8001 11.9995 16.8001Z"
154
+ fill="#292D32"
155
+ />
156
+ </svg>
157
+ </IconButton>
158
+ </DropdownMenu.Trigger>
159
+ <DropdownMenu.Content slot="content" width="250px">
160
+ <Button href="/exemple/{$page.params.project_normalized_name}/{$page.params.entity_slug}/create" variant="ghost" style="width:100%;">
161
+ <h5>créer</h5>
162
+ </Button>
163
+ <Button variant="ghost" style="width:100%;">
164
+ <h5>importer</h5>
165
+ </Button>
166
+ </DropdownMenu.Content>
167
+ </DropdownMenu.Root>
168
+ </div>
169
+ </ViewEntriesProfilComponent>
170
+ {/if}
171
+
172
+ <style>
173
+ .top-bar {
174
+ position: sticky;
175
+ top: 0px;
176
+ display: flex;
177
+ align-items: center;
178
+ justify-content: space-between;
179
+ padding: var(--pad-s);
180
+ border-bottom: 1px solid var(--stroke);
181
+ }
182
+ </style>
@@ -0,0 +1,25 @@
1
+ <script>
2
+ import { page } from "$app/stores";
3
+ import EntityPage from "$lib/registry/entityRegistry/components/EntityPage.svelte";
4
+ import { entityRegistry } from "$lib/registry/entityRegistry/registry.svelte";
5
+
6
+
7
+ const entity = $derived(entityRegistry.getFromSlug($page.params.entity_slug))
8
+ </script>
9
+
10
+ {#if entity}
11
+ <div class="page">
12
+ <EntityPage entityId={entity.id} entryId={$page.params.entry_id}></EntityPage>
13
+ </div>
14
+ {/if}
15
+
16
+ <style>
17
+
18
+ .page {
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: center;
22
+ width: 100%;
23
+ padding: 60px var(--pad-m);
24
+ }
25
+ </style>
@@ -0,0 +1,45 @@
1
+ <script>
2
+ import { page } from "$app/stores";
3
+ import EntityForm from "$lib/registry/entityRegistry/components/EntityForm.svelte";
4
+ import { entityRegistry } from "$lib/registry/entityRegistry/registry.svelte";
5
+ import { sendRequest, toast } from "hamzus-ui";
6
+ import path from "path";
7
+
8
+
9
+ const entity = $derived(entityRegistry.getFromSlug($page.params.entity_slug))
10
+
11
+ async function handleSubmit(ctx) {
12
+ const request = await sendRequest({
13
+ path:"/create-entry",
14
+ data:{
15
+ ...ctx,
16
+ entity_id:entity.id
17
+ }
18
+ })
19
+
20
+ if (request.statusType === "error") {
21
+ toast.error({
22
+ title:"Erreur !",
23
+ description:request.message
24
+ })
25
+ return
26
+ }
27
+ }
28
+ </script>
29
+
30
+ {#if entity}
31
+ <div class="page">
32
+ <EntityForm onSubmit={handleSubmit} entityId={entity.id}></EntityForm>
33
+ </div>
34
+ {/if}
35
+
36
+ <style>
37
+
38
+ .page {
39
+ display: flex;
40
+ flex-direction: column;
41
+ align-items: center;
42
+ width: 100%;
43
+ padding: 60px var(--pad-m);
44
+ }
45
+ </style>
@@ -1,17 +0,0 @@
1
- export function createViewType(config = {}) {
2
- const viewType = {
3
- type:"",
4
- name:"",
5
- description:"",
6
- components : {
7
- component:null,
8
- icon:null,
9
- }
10
- };
11
-
12
- Object.assign(viewType, config);
13
-
14
- // viewType.get = () => "test";
15
-
16
- return viewType;
17
- }
@@ -1,7 +0,0 @@
1
- import { viewTypeRegistry } from './registry.svelte';
2
- import Table from './viewTypes/Table';
3
-
4
-
5
- export function registerDefaultViewTypes() {
6
- viewTypeRegistry.register(Table)
7
- }
@@ -1,44 +0,0 @@
1
- import { writable, derived, get } from 'svelte/store';
2
-
3
- function createViewTypeRegistry() {
4
- const store = writable({});
5
-
6
- const all = derived(store, ($viewTypes) => Object.values($viewTypes));
7
-
8
- return {
9
- subscribe: store.subscribe,
10
-
11
- register(viewType) {
12
- store.update((viewTypes) => ({
13
- ...viewTypes,
14
- [viewType.type]: viewType
15
- }));
16
- },
17
-
18
- unregister(type) {
19
- store.update((viewTypes) => {
20
- const copy = { ...viewTypes };
21
-
22
- delete copy[type];
23
-
24
- return copy;
25
- });
26
- },
27
-
28
- get(type) {
29
- return get(store)[type];
30
- },
31
-
32
- select(type) {
33
- return derived(store, ($viewTypes) => $viewTypes[type]);
34
- },
35
-
36
-
37
-
38
- getAll() {
39
- return all;
40
- }
41
- };
42
- }
43
-
44
- export const viewTypeRegistry = createViewTypeRegistry();
@@ -1,11 +0,0 @@
1
- <script>
2
- import { page } from '$app/stores';
3
- import { Button, DropdownMenu, IconButton } from 'hamzus-ui';
4
- import StructureTable from './StructureTable.svelte';
5
-
6
- let { structureId = 0, columns = [], defaultProps = null, ...props } = $props();
7
- </script>
8
-
9
- <StructureTable bind:defaultProps structureColumns={columns} {structureId} {...props}>
10
- <slot slot="actions" name="actions"></slot>
11
- </StructureTable>
@@ -1,14 +0,0 @@
1
- import { createViewType } from '../../createViewType';
2
-
3
- import Icon from '../Table/Icon.svelte';
4
- import Component from '../Table/component/Component.svelte';
5
-
6
- export default createViewType({
7
- type: "table",
8
- name: "Tableau",
9
- description: "",
10
- components: {
11
- component: Component,
12
- icon: Icon,
13
- },
14
- });