mountain-ui 1.0.36 → 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.
- package/index.d.ts +5 -5
- package/index.js +5 -5
- package/package.json +1 -1
- package/src/lib/registry/entityRegistry/components/EntityForm.svelte +1 -0
- package/src/lib/registry/entityRegistry/registry.svelte.js +17 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Input.svelte +1 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/Input.svelte +17 -1
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/View.svelte +1 -1
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/View.svelte +1 -1
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/View.svelte +1 -1
- package/src/lib/registry/projectRegistry/components/ProjectButton.svelte +14 -0
- package/src/lib/registry/projectRegistry/components/ProjectCard.svelte +43 -0
- package/src/lib/registry/projectRegistry/components/ProjectDropdown.svelte +117 -0
- package/src/lib/registry/projectRegistry/createProject.js +17 -0
- package/src/lib/registry/projectRegistry/registry.svelte.js +50 -0
- package/src/lib/registry/viewEntriesProfilRegistery/components/CreateViewEntriesProfilDialog.svelte +17 -0
- package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilButton.svelte +51 -0
- package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilComponent.svelte +32 -0
- package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilDropdown.svelte +60 -0
- package/src/lib/registry/viewEntriesProfilRegistery/createViewEntriesProfil.js +15 -0
- package/src/lib/registry/viewEntriesProfilRegistery/registerDefaultViewEntriesProfils.js +13 -0
- package/src/lib/registry/viewEntriesProfilRegistery/registry.svelte.js +48 -0
- package/src/lib/registry/{viewTypeRegistry/components/ViewTypeButton.svelte → viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte} +5 -4
- package/src/lib/registry/{viewTypeRegistry/components/ViewTypeComponent.svelte → viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte} +4 -4
- package/src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeDropdown.svelte +32 -0
- package/src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeIcon.svelte +9 -0
- package/src/lib/registry/viewEntriesTypeRegistry/createViewEntriesType.js +17 -0
- package/src/lib/registry/viewEntriesTypeRegistry/registerDefaultViewEntriesTypes.js +7 -0
- package/src/lib/registry/viewEntriesTypeRegistry/registry.svelte.js +44 -0
- package/src/lib/registry/{viewTypeRegistry/viewTypes → viewEntriesTypeRegistry/viewEntriesTypes}/Table/component/StructureTable.svelte +11 -4
- package/src/lib/registry/viewEntriesTypeRegistry/viewEntriesTypes/Table/index.js +14 -0
- package/src/routes/+layout.svelte +613 -598
- package/src/routes/+page.svelte +3 -3
- package/src/routes/exemple/+layout.svelte +44 -0
- package/src/routes/exemple/+page.svelte +0 -0
- package/src/routes/exemple/[project_normalized_name]/+layout.svelte +100 -0
- package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+layout.svelte +44 -0
- package/src/routes/exemple/[project_normalized_name]/[entity_slug]/+page.svelte +182 -0
- package/src/routes/exemple/[project_normalized_name]/[entity_slug]/[entry_id]/+page.svelte +25 -0
- package/src/routes/exemple/[project_normalized_name]/[entity_slug]/create/+page.svelte +45 -0
- package/src/routes/exemple/[project_normalized_name]/home/+page.svelte +1 -0
- package/src/lib/registry/viewTypeRegistry/createViewType.js +0 -17
- package/src/lib/registry/viewTypeRegistry/registerDefaultViewTypes.js +0 -7
- package/src/lib/registry/viewTypeRegistry/registry.svelte.js +0 -44
- package/src/lib/registry/viewTypeRegistry/viewTypes/Table/component/Component copy.svelte +0 -11
- package/src/lib/registry/viewTypeRegistry/viewTypes/Table/index.js +0 -14
- /package/src/lib/registry/{viewTypeRegistry/viewTypes → viewEntriesTypeRegistry/viewEntriesTypes}/Table/Icon.svelte +0 -0
- /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/
|
|
49
|
-
export { createViewType } from './src/lib/registry/
|
|
50
|
-
export { registerDefaultViewTypes } from './src/lib/registry/
|
|
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/
|
|
53
|
-
export { default as ViewTypeComponent } from './src/lib/registry/
|
|
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/
|
|
49
|
-
export { createViewType } from './src/lib/registry/
|
|
50
|
-
export { registerDefaultViewTypes } from './src/lib/registry/
|
|
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/
|
|
53
|
-
export { default as ViewTypeComponent } from './src/lib/registry/
|
|
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.
|
|
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",
|
|
@@ -25,9 +25,26 @@ function createEntityRegistry() {
|
|
|
25
25
|
});
|
|
26
26
|
},
|
|
27
27
|
|
|
28
|
+
unregisterAll(id) {
|
|
29
|
+
store.update((entities) => {
|
|
30
|
+
return {};
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
|
|
28
34
|
get(id) {
|
|
29
35
|
return get(store)[id];
|
|
30
36
|
},
|
|
37
|
+
getFromSlug(slug) {
|
|
38
|
+
const entities = get(store);
|
|
39
|
+
|
|
40
|
+
for (const entity of Object.values(entities)) {
|
|
41
|
+
if (entity.slug !== slug) continue
|
|
42
|
+
|
|
43
|
+
return entity
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
},
|
|
31
48
|
|
|
32
49
|
select(id) {
|
|
33
50
|
return derived(store, ($entities) => $entities[id]);
|
|
@@ -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,14 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button } from 'hamzus-ui';
|
|
3
|
+
import { projectRegistry } from '../registry.svelte';
|
|
4
|
+
|
|
5
|
+
let { id, variant = 'ghost', ...props } = $props();
|
|
6
|
+
|
|
7
|
+
const project = projectRegistry.get(id);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if project}
|
|
11
|
+
<Button {...props} {variant}>
|
|
12
|
+
<h5>{project.name}</h5>
|
|
13
|
+
</Button>
|
|
14
|
+
{/if}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button } from 'hamzus-ui';
|
|
3
|
+
import { projectRegistry } from '../registry.svelte';
|
|
4
|
+
let { id, variant = 'ghost', ...props } = $props();
|
|
5
|
+
|
|
6
|
+
const project = projectRegistry.get(id);
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if project}
|
|
10
|
+
<Button {...props} {variant} style="border-radius:var(--radius-xl);">
|
|
11
|
+
<div class="card">
|
|
12
|
+
<div class="top">
|
|
13
|
+
<h3>{project.name}</h3>
|
|
14
|
+
</div>
|
|
15
|
+
<h6>/{project.normalized_name}</h6>
|
|
16
|
+
</div>
|
|
17
|
+
</Button>
|
|
18
|
+
{/if}
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.card {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: baseline;
|
|
25
|
+
padding: var(--pad-m);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.card .top {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
column-gap: var(--pad-xxl);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
.card h3 {
|
|
36
|
+
text-transform: capitalize;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
.card > h6 {
|
|
41
|
+
color: var(--font-2);
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button, DropdownMenu } from 'hamzus-ui';
|
|
3
|
+
import { projectRegistry } from '../registry.svelte';
|
|
4
|
+
|
|
5
|
+
let { projectId = $bindable(null), hubHref = "/", isActive = ()=>{}, getHref = (project)=>{} } = $props();
|
|
6
|
+
|
|
7
|
+
const project = $derived(projectRegistry.get(projectId));
|
|
8
|
+
|
|
9
|
+
const projects = projectRegistry.getAll();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<DropdownMenu.Root direction="bottom" triggerFullWidth>
|
|
13
|
+
<DropdownMenu.Trigger slot="trigger">
|
|
14
|
+
<Button variant="outline" style="width:100%;justify-content:space-between;">
|
|
15
|
+
<div class="project-btn">
|
|
16
|
+
<h4>{project?.name ?? 'selectionné un projet'}</h4>
|
|
17
|
+
</div>
|
|
18
|
+
<svg
|
|
19
|
+
width="24"
|
|
20
|
+
height="24"
|
|
21
|
+
viewBox="0 0 24 24"
|
|
22
|
+
fill="none"
|
|
23
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
+
>
|
|
25
|
+
<path
|
|
26
|
+
d="M9.00945 21.2502C8.81945 21.2502 8.62945 21.1802 8.47945 21.0302L3.46945 16.0202C3.17945 15.7302 3.17945 15.2502 3.46945 14.9602C3.75945 14.6702 4.23945 14.6702 4.52945 14.9602L9.53945 19.9702C9.82945 20.2602 9.82945 20.7402 9.53945 21.0302C9.38945 21.1702 9.19945 21.2502 9.00945 21.2502Z"
|
|
27
|
+
fill="#292D32"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
d="M9.00977 21.25C8.59977 21.25 8.25977 20.91 8.25977 20.5V3.5C8.25977 3.09 8.59977 2.75 9.00977 2.75C9.41977 2.75 9.75977 3.09 9.75977 3.5V20.5C9.75977 20.91 9.41977 21.25 9.00977 21.25Z"
|
|
31
|
+
fill="#292D32"
|
|
32
|
+
/>
|
|
33
|
+
<path
|
|
34
|
+
d="M20.0095 9.25994C19.8195 9.25994 19.6295 9.18994 19.4795 9.03994L14.4695 4.02994C14.1795 3.73994 14.1795 3.25994 14.4695 2.96994C14.7595 2.67994 15.2395 2.67994 15.5295 2.96994L20.5395 7.97994C20.8295 8.26994 20.8295 8.74994 20.5395 9.03994C20.3895 9.18994 20.1995 9.25994 20.0095 9.25994Z"
|
|
35
|
+
fill="#292D32"
|
|
36
|
+
/>
|
|
37
|
+
<path
|
|
38
|
+
d="M14.9902 21.25C14.5802 21.25 14.2402 20.91 14.2402 20.5V3.5C14.2402 3.09 14.5802 2.75 14.9902 2.75C15.4002 2.75 15.7402 3.09 15.7402 3.5V20.5C15.7402 20.91 15.4102 21.25 14.9902 21.25Z"
|
|
39
|
+
fill="#292D32"
|
|
40
|
+
/>
|
|
41
|
+
</svg>
|
|
42
|
+
</Button>
|
|
43
|
+
</DropdownMenu.Trigger>
|
|
44
|
+
<DropdownMenu.Content slot="content" width="var(--hamzus-tigger-width)">
|
|
45
|
+
{#if $projects.length > 1}
|
|
46
|
+
{#each $projects as project}
|
|
47
|
+
<Button
|
|
48
|
+
href={getHref(project)}
|
|
49
|
+
variant="{isActive(project) ? "secondary" : "ghost"}"
|
|
50
|
+
style="width:100%;"
|
|
51
|
+
>
|
|
52
|
+
<div class="project-btn">
|
|
53
|
+
<h4>{project.name}</h4>
|
|
54
|
+
<h6>{project.active_subscription?.name ?? ''}</h6>
|
|
55
|
+
</div>
|
|
56
|
+
</Button>
|
|
57
|
+
{/each}
|
|
58
|
+
{:else}
|
|
59
|
+
<div class="no-other-project">
|
|
60
|
+
<h4>Aucun autre projet</h4>
|
|
61
|
+
<p>Créée d'autre projets erp et navigué entre eux facilement.</p>
|
|
62
|
+
</div>
|
|
63
|
+
{/if}
|
|
64
|
+
<DropdownMenu.Separator></DropdownMenu.Separator>
|
|
65
|
+
<Button href={hubHref} variant="ghost" style="width:100%;column-gap:var(--pad-m);">
|
|
66
|
+
<svg
|
|
67
|
+
width="24"
|
|
68
|
+
height="24"
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
fill="none"
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
>
|
|
73
|
+
<path
|
|
74
|
+
d="M12 22.75C6.07 22.75 1.25 17.93 1.25 12C1.25 6.07 6.07 1.25 12 1.25C17.93 1.25 22.75 6.07 22.75 12C22.75 17.93 17.93 22.75 12 22.75ZM12 2.75C6.9 2.75 2.75 6.9 2.75 12C2.75 17.1 6.9 21.25 12 21.25C17.1 21.25 21.25 17.1 21.25 12C21.25 6.9 17.1 2.75 12 2.75Z"
|
|
75
|
+
fill="#292D32"
|
|
76
|
+
/>
|
|
77
|
+
<path
|
|
78
|
+
d="M9.00023 21.75H8.00023C7.59023 21.75 7.25023 21.41 7.25023 21C7.25023 20.59 7.57023 20.26 7.98023 20.25C6.41023 14.89 6.41023 9.11 7.98023 3.75C7.57023 3.74 7.25023 3.41 7.25023 3C7.25023 2.59 7.59023 2.25 8.00023 2.25H9.00023C9.24023 2.25 9.47023 2.37 9.61023 2.56C9.75023 2.76 9.79023 3.01 9.71023 3.24C7.83023 8.89 7.83023 15.11 9.71023 20.77C9.79023 21 9.75023 21.25 9.61023 21.45C9.47023 21.63 9.24023 21.75 9.00023 21.75Z"
|
|
79
|
+
fill="#292D32"
|
|
80
|
+
/>
|
|
81
|
+
<path
|
|
82
|
+
d="M15.0004 21.7502C14.9204 21.7502 14.8404 21.7402 14.7604 21.7102C14.3704 21.5802 14.1504 21.1502 14.2904 20.7602C16.1704 15.1102 16.1704 8.89018 14.2904 3.23018C14.1604 2.84018 14.3704 2.41018 14.7604 2.28018C15.1604 2.15018 15.5804 2.36018 15.7104 2.75018C17.7004 8.71018 17.7004 15.2702 15.7104 21.2202C15.6104 21.5502 15.3104 21.7502 15.0004 21.7502Z"
|
|
83
|
+
fill="#292D32"
|
|
84
|
+
/>
|
|
85
|
+
<path
|
|
86
|
+
d="M12 17.1998C9.21 17.1998 6.43 16.8098 3.75 16.0198C3.74 16.4198 3.41 16.7498 3 16.7498C2.59 16.7498 2.25 16.4098 2.25 15.9998V14.9998C2.25 14.7598 2.37 14.5298 2.56 14.3898C2.76 14.2498 3.01 14.2098 3.24 14.2898C8.89 16.1698 15.12 16.1698 20.77 14.2898C21 14.2098 21.25 14.2498 21.45 14.3898C21.65 14.5298 21.76 14.7598 21.76 14.9998V15.9998C21.76 16.4098 21.42 16.7498 21.01 16.7498C20.6 16.7498 20.27 16.4298 20.26 16.0198C17.57 16.8098 14.79 17.1998 12 17.1998Z"
|
|
87
|
+
fill="#292D32"
|
|
88
|
+
/>
|
|
89
|
+
<path
|
|
90
|
+
d="M20.9998 9.74986C20.9198 9.74986 20.8398 9.73986 20.7598 9.70986C15.1098 7.82986 8.87978 7.82986 3.22978 9.70986C2.82978 9.83986 2.40978 9.62986 2.27978 9.23986C2.15978 8.83986 2.36978 8.41986 2.75978 8.28986C8.71978 6.29986 15.2798 6.29986 21.2298 8.28986C21.6198 8.41986 21.8398 8.84986 21.6998 9.23986C21.6098 9.54986 21.3098 9.74986 20.9998 9.74986Z"
|
|
91
|
+
fill="#292D32"
|
|
92
|
+
/>
|
|
93
|
+
</svg>
|
|
94
|
+
|
|
95
|
+
<h5>retourner au hub</h5>
|
|
96
|
+
</Button>
|
|
97
|
+
</DropdownMenu.Content>
|
|
98
|
+
</DropdownMenu.Root>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
<style>
|
|
102
|
+
.project-btn {
|
|
103
|
+
display: flex;
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
align-items: baseline;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.project-btn > h6 {
|
|
109
|
+
color: var(--font-3);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.no-other-project {
|
|
113
|
+
padding: var(--pad-m);
|
|
114
|
+
border-radius: var(--radius-m);
|
|
115
|
+
background-color: var(--bg-blur);
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function createProject(config = {}) {
|
|
2
|
+
const project = {
|
|
3
|
+
id: null,
|
|
4
|
+
name: "",
|
|
5
|
+
normalized_name: "",
|
|
6
|
+
description: '',
|
|
7
|
+
active_subscription:{
|
|
8
|
+
name:""
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
Object.assign(project, config);
|
|
13
|
+
|
|
14
|
+
// project.get = (id) => project.fields.find((field) => field.id === id);
|
|
15
|
+
|
|
16
|
+
return project;
|
|
17
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { writable, derived, get } from 'svelte/store';
|
|
2
|
+
|
|
3
|
+
function createProjectRegistry() {
|
|
4
|
+
const store = writable({});
|
|
5
|
+
|
|
6
|
+
const all = derived(store, ($projects) => Object.values($projects));
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
subscribe: store.subscribe,
|
|
10
|
+
|
|
11
|
+
register(project) {
|
|
12
|
+
store.update((projects) => ({
|
|
13
|
+
...projects,
|
|
14
|
+
[project.id]: project
|
|
15
|
+
}));
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
unregister(id) {
|
|
19
|
+
store.update((projects) => {
|
|
20
|
+
const copy = { ...projects };
|
|
21
|
+
|
|
22
|
+
delete copy[id];
|
|
23
|
+
|
|
24
|
+
return copy;
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
get(id) {
|
|
29
|
+
return get(store)[id];
|
|
30
|
+
},
|
|
31
|
+
getFromNormalizedName(normalized_name) {
|
|
32
|
+
const projects = Object.values(get(store));
|
|
33
|
+
|
|
34
|
+
return projects.find(p=>p.normalized_name === normalized_name) ?? null
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
select(id) {
|
|
39
|
+
return derived(store, ($projects) => $projects[id]);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
getAll() {
|
|
45
|
+
return all;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const projectRegistry = createProjectRegistry();
|
package/src/lib/registry/viewEntriesProfilRegistery/components/CreateViewEntriesProfilDialog.svelte
ADDED
|
@@ -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>
|
package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilComponent.svelte
ADDED
|
@@ -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>
|
package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilDropdown.svelte
ADDED
|
@@ -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 {
|
|
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 =
|
|
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-
|
|
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
|
-
<
|
|
14
|
+
<ViewEntriesTypeIcon {type}></ViewEntriesTypeIcon>
|
|
14
15
|
</div>
|
|
15
16
|
<h5>{viewType.name}</h5>
|
|
16
17
|
</Button>
|