mountain-ui 1.0.35 → 1.0.37
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 +1 -1
- package/src/lib/registry/entityRegistry/registry.svelte.js +17 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/View.svelte +6 -3
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/View.svelte +2 -2
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/View.svelte +2 -2
- 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/routes/+layout.svelte +600 -596
- package/src/routes/+page.svelte +2 -2
- package/src/routes/exemple/+layout.svelte +43 -0
- package/src/routes/exemple/+page.svelte +0 -0
- package/src/routes/exemple/[project_normalized_name]/+layout.svelte +98 -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 +1 -0
- package/src/routes/exemple/[project_normalized_name]/home/+page.svelte +1 -0
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.37",
|
|
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]);
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
let { value, unique, secret, label, required, columns = [] } = $props();
|
|
10
10
|
|
|
11
|
-
let entries =
|
|
11
|
+
let entries = $state([]);
|
|
12
12
|
|
|
13
13
|
$effect(() => {
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
entries = value?.formated?.entries ?? {};
|
|
15
16
|
});
|
|
16
17
|
</script>
|
|
17
18
|
|
|
@@ -35,10 +36,12 @@
|
|
|
35
36
|
{#each columns as column, columnIndex}
|
|
36
37
|
<ResponsiveTable.Cell {ctx}>
|
|
37
38
|
{#each column.rows as row, rowIndex}
|
|
39
|
+
{@const field = entityRegistry.getField(row.fieldId)}
|
|
38
40
|
<FieldView
|
|
39
41
|
compact
|
|
40
42
|
id={row.fieldId}
|
|
41
|
-
|
|
43
|
+
entityId={field.entity_id}
|
|
44
|
+
value={line[field.normalized_name] ?? "null"}
|
|
42
45
|
></FieldView>
|
|
43
46
|
{/each}
|
|
44
47
|
</ResponsiveTable.Cell>
|
package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/View.svelte
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let {
|
|
2
|
+
let { label, value } = $props();
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<div class="total-container">
|
|
6
6
|
<div class="total">
|
|
7
7
|
<div class="total-content">
|
|
8
|
-
<h4>{
|
|
8
|
+
<h4>{label}</h4>
|
|
9
9
|
<h4>{value === null ? '-' : value.flat}</h4>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/View.svelte
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let {
|
|
2
|
+
let { label, value } = $props();
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<div class="total-container">
|
|
6
6
|
<div class="total">
|
|
7
7
|
<div class="total-content">
|
|
8
|
-
<h4>{
|
|
8
|
+
<h4>{label}</h4>
|
|
9
9
|
<h4>{value === null ? '-' : value.flat}</h4>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
@@ -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();
|