mountain-ui 1.0.55 → 1.0.57

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 (67) hide show
  1. package/index.d.ts +23 -0
  2. package/index.js +23 -0
  3. package/package.json +1 -1
  4. package/src/lib/components/Nothing.svelte +26 -0
  5. package/src/lib/registry/entityRegistry/components/EntitiesSelector.svelte +41 -0
  6. package/src/lib/registry/entityRegistry/components/EntityCard.svelte +2 -2
  7. package/src/lib/registry/entityRegistry/components/EntityFieldContainer.svelte +13 -0
  8. package/src/lib/registry/entityRegistry/components/EntityForm.svelte +141 -75
  9. package/src/lib/registry/entityRegistry/components/EntityPage.svelte +5 -147
  10. package/src/lib/registry/entityRegistry/components/EntryForm.svelte +102 -0
  11. package/src/lib/registry/entityRegistry/components/EntryPage.svelte +155 -0
  12. package/src/lib/registry/entityRegistry/components/FieldBinding.svelte +90 -0
  13. package/src/lib/registry/entityRegistry/components/FieldRow.svelte +71 -0
  14. package/src/lib/registry/entityRegistry/createEntity.js +6 -0
  15. package/src/lib/registry/entityRegistry/utils.js +15 -0
  16. package/src/lib/registry/entryActionRegistry/components/EntryActionButton.svelte +21 -0
  17. package/src/lib/registry/entryActionRegistry/components/EntryActionsButtons.svelte +18 -0
  18. package/src/lib/registry/entryActionRegistry/createEntryAction.js +17 -0
  19. package/src/lib/registry/entryActionRegistry/registry.svelte.js +48 -0
  20. package/src/lib/registry/entryActionTypeRegistry/components/EntryActionProperties.svelte +42 -0
  21. package/src/lib/registry/entryActionTypeRegistry/components/EntryActionTypeCard.svelte +11 -0
  22. package/src/lib/registry/entryActionTypeRegistry/createEntryActionType.js +24 -0
  23. package/src/lib/registry/entryActionTypeRegistry/entryActionTypes/PrefillNewEntry/Card.svelte +20 -0
  24. package/src/lib/registry/entryActionTypeRegistry/entryActionTypes/PrefillNewEntry/Properties.svelte +147 -0
  25. package/src/lib/registry/entryActionTypeRegistry/entryActionTypes/PrefillNewEntry/component/Binding.svelte +103 -0
  26. package/src/lib/registry/entryActionTypeRegistry/entryActionTypes/PrefillNewEntry/component/BindingClone.svelte +103 -0
  27. package/src/lib/registry/entryActionTypeRegistry/entryActionTypes/PrefillNewEntry/index.js +77 -0
  28. package/src/lib/registry/entryActionTypeRegistry/registerDefaultEntryActionTypes.js +7 -0
  29. package/src/lib/registry/entryActionTypeRegistry/registry.svelte.js +48 -0
  30. package/src/lib/registry/fieldTypeRegistry/createFieldType.js +8 -0
  31. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/index.js +52 -0
  32. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/index.js +3 -0
  33. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/index.js +1 -0
  34. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/index.js +2 -0
  35. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/index.js +2 -0
  36. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/index.js +1 -0
  37. package/src/lib/registry/fieldTypeRegistry/fieldTypes/localisation/LocalisationLand/index.js +2 -0
  38. package/src/lib/registry/fieldTypeRegistry/fieldTypes/money/MoneyCurrency/index.js +2 -0
  39. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/index.js +1 -0
  40. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/index.js +2 -0
  41. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/index.js +1 -0
  42. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/index.js +1 -0
  43. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/index.js +2 -0
  44. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/index.js +2 -0
  45. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/index.js +1 -0
  46. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/index.js +1 -0
  47. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/index.js +1 -0
  48. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/index.js +1 -0
  49. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/index.js +1 -0
  50. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/index.js +1 -0
  51. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/index.js +2 -1
  52. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/index.js +1 -0
  53. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/index.js +1 -0
  54. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/index.js +1 -0
  55. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/index.js +1 -0
  56. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/index.js +1 -0
  57. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/index.js +1 -0
  58. package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilButton.svelte +1 -1
  59. package/src/lib/registry/viewEntriesProfilRegistery/components/ViewEntriesProfilComponent.svelte +1 -1
  60. package/src/routes/exemple/[project_normalized_name]/+layout.svelte +16 -2
  61. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/[entry_id]/+page.svelte +70 -16
  62. package/src/routes/exemple/[project_normalized_name]/[entity_slug]/create/+page.svelte +19 -3
  63. package/src/routes/exemple/[project_normalized_name]/actions/+page.svelte +62 -0
  64. package/src/routes/exemple/[project_normalized_name]/entities/+layout.svelte +5 -0
  65. package/src/routes/exemple/[project_normalized_name]/entities/+page.svelte +70 -0
  66. package/src/routes/exemple/[project_normalized_name]/entities/[entity_id]/+page.svelte +8 -0
  67. package/src/routes/exemple/[project_normalized_name]/entities/create/+page.svelte +6 -0
package/index.d.ts CHANGED
@@ -28,6 +28,8 @@ export { default as EntityButton } from './src/lib/registry/entityRegistry/compo
28
28
  export { default as EntityCard } from './src/lib/registry/entityRegistry/components/EntityCard.svelte';
29
29
  export { default as EntityForm } from './src/lib/registry/entityRegistry/components/EntityForm.svelte';
30
30
  export { default as EntityPage } from './src/lib/registry/entityRegistry/components/EntityPage.svelte';
31
+ export { default as EntryForm } from './src/lib/registry/entityRegistry/components/EntryForm.svelte';
32
+ export { default as EntryPage } from './src/lib/registry/entityRegistry/components/EntryPage.svelte';
31
33
  export { default as FieldButton } from './src/lib/registry/entityRegistry/components/FieldButton.svelte';
32
34
  export { default as FieldCard } from './src/lib/registry/entityRegistry/components/FieldCard.svelte';
33
35
  export { default as FieldIcon } from './src/lib/registry/entityRegistry/components/FieldIcon.svelte';
@@ -51,3 +53,24 @@ export { registerDefaultViewEntriesTypes } from './src/lib/registry/viewEntriesT
51
53
 
52
54
  export { default as ViewEntriesTypeButton } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte';
53
55
  export { default as ViewEntriesTypeComponent } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
56
+
57
+ // ============================================
58
+ // EntryActionType Registry
59
+ // ============================================
60
+
61
+ export { entryActionTypeRegistry } from './src/lib/registry/entryActionTypeRegistry/registry.svelte.js';
62
+ export { createEntryActionType } from './src/lib/registry/entryActionTypeRegistry/createEntryActionType.js';
63
+ export { registerDefaultEntryActionTypes } from './src/lib/registry/entryActionTypeRegistry/registerDefaultEntryActionTypes.js';
64
+
65
+ export { default as EntryActionProperties } from './src/lib/registry/entryActionTypeRegistry/components/EntryActionProperties.svelte';
66
+ export { default as EntryActionTypeCard } from './src/lib/registry/entryActionTypeRegistry/components/EntryActionTypeCard.svelte';
67
+
68
+ // ============================================
69
+ // EntryAction Registry
70
+ // ============================================
71
+
72
+ export { entryActionRegistry } from './src/lib/registry/entryActionRegistry/registry.svelte.js';
73
+ export { createEntryAction } from './src/lib/registry/entryActionRegistry/createEntryAction.js';
74
+
75
+ export { default as EntryActionButton } from './src/lib/registry/entryActionRegistry/components/EntryActionButton.svelte';
76
+ export { default as EntryActionsButtons } from './src/lib/registry/entryActionRegistry/components/EntryActionsButtons.svelte';
package/index.js CHANGED
@@ -28,6 +28,8 @@ export { default as EntityButton } from './src/lib/registry/entityRegistry/compo
28
28
  export { default as EntityCard } from './src/lib/registry/entityRegistry/components/EntityCard.svelte';
29
29
  export { default as EntityForm } from './src/lib/registry/entityRegistry/components/EntityForm.svelte';
30
30
  export { default as EntityPage } from './src/lib/registry/entityRegistry/components/EntityPage.svelte';
31
+ export { default as EntryForm } from './src/lib/registry/entityRegistry/components/EntryForm.svelte';
32
+ export { default as EntryPage } from './src/lib/registry/entityRegistry/components/EntryPage.svelte';
31
33
  export { default as FieldButton } from './src/lib/registry/entityRegistry/components/FieldButton.svelte';
32
34
  export { default as FieldCard } from './src/lib/registry/entityRegistry/components/FieldCard.svelte';
33
35
  export { default as FieldIcon } from './src/lib/registry/entityRegistry/components/FieldIcon.svelte';
@@ -51,3 +53,24 @@ export { registerDefaultViewEntriesTypes } from './src/lib/registry/viewEntriesT
51
53
 
52
54
  export { default as ViewEntriesTypeButton } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeButton.svelte';
53
55
  export { default as ViewEntriesTypeComponent } from './src/lib/registry/viewEntriesTypeRegistry/components/ViewEntriesTypeComponent.svelte';
56
+
57
+ // ============================================
58
+ // EntryActionType Registry
59
+ // ============================================
60
+
61
+ export { entryActionTypeRegistry } from './src/lib/registry/entryActionTypeRegistry/registry.svelte.js';
62
+ export { createEntryActionType } from './src/lib/registry/entryActionTypeRegistry/createEntryActionType.js';
63
+ export { registerDefaultEntryActionTypes } from './src/lib/registry/entryActionTypeRegistry/registerDefaultEntryActionTypes.js';
64
+
65
+ export { default as EntryActionProperties } from './src/lib/registry/entryActionTypeRegistry/components/EntryActionProperties.svelte';
66
+ export { default as EntryActionTypeCard } from './src/lib/registry/entryActionTypeRegistry/components/EntryActionTypeCard.svelte';
67
+
68
+ // ============================================
69
+ // EntryAction Registry
70
+ // ============================================
71
+
72
+ export { entryActionRegistry } from './src/lib/registry/entryActionRegistry/registry.svelte.js';
73
+ export { createEntryAction } from './src/lib/registry/entryActionRegistry/createEntryAction.js';
74
+
75
+ export { default as EntryActionButton } from './src/lib/registry/entryActionRegistry/components/EntryActionButton.svelte';
76
+ export { default as EntryActionsButtons } from './src/lib/registry/entryActionRegistry/components/EntryActionsButtons.svelte';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mountain-ui",
3
3
  "private": false,
4
- "version": "1.0.55",
4
+ "version": "1.0.57",
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",
@@ -0,0 +1,26 @@
1
+ <script>
2
+
3
+ let {title, description} = $props()
4
+ </script>
5
+
6
+ <div class="nothing">
7
+ <slot name="top"/>
8
+ <h3>{title}</h3>
9
+ <p>{description}</p>
10
+ <slot name="bottom"/>
11
+ </div>
12
+
13
+ <style>
14
+ .nothing {
15
+ display: flex;
16
+ flex-direction: column;
17
+ align-items: center;
18
+ row-gap: var(--pad-m);
19
+ padding: var(--pad-m);
20
+ }
21
+
22
+ .nothing > :global(svg) {
23
+ width: 60px;
24
+ height: auto;
25
+ }
26
+ </style>
@@ -0,0 +1,41 @@
1
+ <script>
2
+ import { Button, DropdownMenu } from 'hamzus-ui';
3
+ import { entityRegistry } from '../registry.svelte';
4
+ import EntityButton from './EntityButton.svelte';
5
+
6
+ let { onChange = (entity) => {}, activeEntityId = $bindable(null) } = $props();
7
+
8
+ const allEntities = entityRegistry.getAll();
9
+
10
+ function handleChange(entity) {
11
+ activeEntityId = entity.id;
12
+
13
+ onChange(entity);
14
+ }
15
+ </script>
16
+
17
+ {#if $allEntities}
18
+ <DropdownMenu.Root direction="bottom">
19
+ <DropdownMenu.Trigger slot="trigger">
20
+ {#if activeEntityId}
21
+ <EntityButton variant="secondary" id={activeEntityId}></EntityButton>
22
+ {:else}
23
+ <Button variant="secondary">
24
+ <h5>selectionner une entité</h5>
25
+ </Button>
26
+ {/if}
27
+ </DropdownMenu.Trigger>
28
+ <DropdownMenu.Content slot="content" width="250px">
29
+ {#each $allEntities as entity}
30
+ <EntityButton
31
+ variant={activeEntityId === entity.id ? 'secondary' : 'ghost'}
32
+ style="width:100%;"
33
+ onClick={() => {
34
+ handleChange(entity);
35
+ }}
36
+ id={entity.id}
37
+ ></EntityButton>
38
+ {/each}
39
+ </DropdownMenu.Content>
40
+ </DropdownMenu.Root>
41
+ {/if}
@@ -4,13 +4,13 @@
4
4
  import FieldIcon from './FieldIcon.svelte';
5
5
  import LinkIcon from './LinkIcon.svelte';
6
6
 
7
- let { id, variant = 'ghost', ...props } = $props();
7
+ let { id, variant = 'ghost', style, ...props } = $props();
8
8
 
9
9
  const entity = $derived(entityRegistry.get(id));
10
10
  </script>
11
11
 
12
12
  {#if entity}
13
- <Button {...props} {variant} style="border-radius:var(--radius-xl);">
13
+ <Button {...props} {variant} style="border-radius:var(--radius-xl);{style}">
14
14
  <div class="card">
15
15
  <div class="top">
16
16
  <h3>{entity.plural_name}</h3>
@@ -0,0 +1,13 @@
1
+ <div class="field-container">
2
+ <slot/>
3
+ </div>
4
+
5
+ <style>
6
+ .field-container {
7
+ display: flex;
8
+ flex-direction: column;
9
+ border: 1px solid var(--stroke);
10
+ border-radius: var(--radius-xl);
11
+ overflow: clip;
12
+ }
13
+ </style>
@@ -1,102 +1,168 @@
1
1
  <script>
2
- import { Button, Form } from 'hamzus-ui';
2
+ import { Accordion, Button, Checkbox, Form, Input } from 'hamzus-ui';
3
3
  import { entityRegistry } from '../registry.svelte';
4
- import FieldInput from './FieldInput.svelte';
5
- import FormCtx from './FormCtx.svelte';
6
-
7
- let { ctx = {}, entityId, onSubmit = () => {}, type = 'create' } = $props();
4
+ import { onMount } from 'svelte';
5
+ import { sanitizePluralNameToNormalizedName, sanitizePluralNameToSlug } from '../utils';
6
+
7
+ let { entityId = null, onSubmit = () => {} } = $props();
8
+
9
+ const entity = $derived(entityId ? entityRegistry.select(entityId) : null);
10
+
11
+ let entityForm = $state({
12
+ pluralName: '',
13
+ singularName: '',
14
+ symbol: '#',
15
+ slug: '',
16
+ normalizedName: '',
17
+ canBeCreated: true,
18
+ canBeEdited: true,
19
+ canBeDeleted: true
20
+ });
21
+
22
+ $effect(() => {
23
+ if ($entity) {
24
+ entityForm = {
25
+ pluralName: $entity.plural_name,
26
+ singularName: $entity.singular_name,
27
+ symbol: $entity.symbol,
28
+ slug: $entity.slug,
29
+ normalizedName: $entity.normalized_name,
30
+ canBeCreated: $entity.can_be_created,
31
+ canBeEdited: $entity.can_be_edited,
32
+ canBeDeleted: $entity.can_be_deleted
33
+ };
34
+ }
35
+ });
8
36
 
9
- let detailsCtx = $state({});
37
+ function updatePluralName(value) {
38
+ entityForm.pluralName = value;
10
39
 
11
- const entity = $derived(entityRegistry.select(entityId));
40
+ entityForm.slug = sanitizePluralNameToSlug(value);
12
41
 
13
- function handleSubmit() {
14
- onSubmit({ ...ctx });
42
+ entityForm.normalizedName = sanitizePluralNameToNormalizedName(value);
15
43
  }
16
44
 
17
- let calculations = $state({});
45
+ function updateSingularName(value) {
46
+ entityForm.singularName = value;
47
+ }
18
48
 
19
- function handleRegisterCalculation(config) {
20
- calculations = {
21
- ...calculations,
22
- [config.id]: config
23
- };
49
+ function updateNormalizedName(value) {
50
+ entityForm.normalizedName = value;
24
51
  }
25
52
 
26
- function handleChange(fieldId, value) {
27
- ctx[fieldId] = value;
53
+ function updateSlug(value) {
54
+ entityForm.slug = value;
55
+ }
28
56
 
29
- recalculate(fieldId);
57
+ function updateSymbol(value) {
58
+ entityForm.symbol = value;
59
+ }
30
60
 
31
- ctx = { ...ctx };
61
+ function updateCanBeCreated(value) {
62
+ entityForm.canBeCreated = value;
32
63
  }
33
- function handleChangeDetails(fieldId, value) {
34
- detailsCtx[fieldId] = value;
35
-
36
- // si c est un type lien alors on parcour ses champs enfant et on reagis
37
- const field = entityRegistry.getField(fieldId, entity.id)
38
- if (field.type === "link") {
39
- const entity = entityRegistry.get(field.props.linkId)
40
- for (const linkedFields of entity.fields) {
41
- recalculate(linkedFields.id)
42
- }
43
- }
44
-
45
- detailsCtx = { ...detailsCtx };
64
+
65
+ function updateCanBeEdited(value) {
66
+ entityForm.canBeEdited = value;
46
67
  }
47
68
 
48
- function recalculate(changedFieldId) {
49
- // on parcour les calcules et on verifie si un depend du champs changé
50
- for (const calc of Object.values(calculations)) {
51
- if (!calc.dependsOn.includes(changedFieldId)) continue;
69
+ function updateCanBeDeleted(value) {
70
+ entityForm.canBeDeleted = value;
71
+ }
52
72
 
53
- calc.calculate(ctx);
54
- }
73
+ function handleAfterSubmit(req) {
74
+ onSubmit(req);
55
75
  }
56
76
  </script>
57
77
 
58
- {#if $entity}
59
- <div class="form">
60
- <FormCtx bind:ctx bind:detailsCtx>
61
- {#each $entity.fields as field}
62
- <FieldInput
63
- {detailsCtx}
64
- {ctx}
65
- onChangeDetails={(value) => {
66
- handleChangeDetails(field.id, value);
67
- }}
68
- onChange={(value) => {
69
- handleChange(field.id, value);
70
- }}
71
- changeCtx={handleChange}
72
- id={field.id}
73
- entityId={$entity.id}
74
- value={ctx?.[field.id] ?? null}
75
- registerCalculation={handleRegisterCalculation}
76
- ></FieldInput>
77
- {/each}
78
- <div class="button">
79
- <Button onClick={handleSubmit}>
80
- <h4>{type === 'create' ? 'créer' : 'éditer'}</h4>
81
- </Button>
82
- </div>
83
- </FormCtx>
84
- </div>
85
- {/if}
78
+ <div class="form">
79
+ <Form style="padding:var(--pad-xxl);width:min(100%, 600px);" path="/{entityId ? "edit" : "create"}-entity" afterSubmit={handleAfterSubmit}>
80
+ <h3>Créer une structure</h3>
81
+
82
+ <Input
83
+ required
84
+ value={entityForm.pluralName}
85
+ onChange={updatePluralName}
86
+ label="Nom pluriel"
87
+ placeholder="Nom de la structure au pluriel"
88
+ />
89
+
90
+ <Input
91
+ required
92
+ value={entityForm.singularName}
93
+ onChange={updateSingularName}
94
+ label="Nom singulier"
95
+ placeholder="Nom de la structure au singulier"
96
+ />
97
+
98
+ <h4>Règles relatives aux éléments créés</h4>
99
+
100
+ <Checkbox
101
+ checked={entityForm.canBeCreated}
102
+ onChange={updateCanBeCreated}
103
+ label="Peut être créé"
104
+ direction="rtl"
105
+ />
106
+
107
+ <Checkbox
108
+ checked={entityForm.canBeEdited}
109
+ onChange={updateCanBeEdited}
110
+ label="Peut être édité"
111
+ direction="rtl"
112
+ />
113
+
114
+ <Checkbox
115
+ checked={entityForm.canBeDeleted}
116
+ onChange={updateCanBeDeleted}
117
+ label="Peut être supprimé"
118
+ direction="rtl"
119
+ />
120
+
121
+ <Accordion.Root let:isOpen>
122
+ <Accordion.Trigger {isOpen}>
123
+ <Accordion.Button {isOpen}>
124
+ <h4>Paramètres avancés</h4>
125
+ </Accordion.Button>
126
+ </Accordion.Trigger>
127
+
128
+ <Accordion.Content {isOpen}>
129
+ <Input
130
+ required
131
+ value={entityForm.normalizedName}
132
+ onChange={updateNormalizedName}
133
+ label="Nom normalisé"
134
+ placeholder="Nom normalisé de la structure"
135
+ />
136
+
137
+ <Input
138
+ required
139
+ value={entityForm.slug}
140
+ onChange={updateSlug}
141
+ label="Slug"
142
+ placeholder="Slug de la structure"
143
+ >
144
+ <h4 slot="startContent">/</h4>
145
+ </Input>
146
+
147
+ <Input
148
+ required
149
+ value={entityForm.symbol}
150
+ onChange={updateSymbol}
151
+ label="Symbole"
152
+ placeholder="Symbole de la structure"
153
+ />
154
+ </Accordion.Content>
155
+ </Accordion.Root>
156
+
157
+ <Button slot="button" type="submit" label={entityId ? "Éditer" : "Créer"} />
158
+ </Form>
159
+ </div>
86
160
 
87
161
  <style>
88
162
  .form {
89
163
  display: flex;
90
164
  flex-direction: column;
91
165
  align-items: center;
92
- width: 100%;
93
- }
94
-
95
- .button {
96
- width: min(100%, 900px);
97
- display: flex;
98
- align-items: center;
99
- justify-content: end;
100
- padding: var(--pad-m);
166
+ width: 100%;
101
167
  }
102
168
  </style>
@@ -2,158 +2,16 @@
2
2
  import { onMount } from 'svelte';
3
3
  import { entityRegistry } from '../registry.svelte';
4
4
  import FieldView from './FieldView.svelte';
5
- import { sendRequest } from 'hamzus-ui';
5
+ import { sendRequest, toast } from 'hamzus-ui';
6
6
 
7
- let { entityId, entryId, children } = $props();
7
+ let { entityId, children } = $props();
8
8
 
9
- let ctx = $state(null);
9
+ const entity = $derived(entityId ? entityRegistry.select(entityId) : null);
10
10
 
11
- let mounted = false;
12
-
13
- const entity = $derived(entityRegistry.select(entityId));
14
-
15
- $effect(() => {
16
- getData(entityId, entryId);
17
- });
18
-
19
- onMount(() => {
20
- getData(entityId, entryId, true);
21
- });
22
-
23
- async function getData(entityId, entryId, isMounting = false) {
24
- if (!isMounting && !mounted) return;
25
-
26
- const request = await sendRequest({
27
- path: '/get-entry',
28
- data: {
29
- entityId: entityId,
30
- entryId: entryId,
31
- idMode: true
32
- }
33
- });
34
-
35
- if (request.statusType === 'error') {
36
- if (request.statusCode === 403) {
37
- ctx = 403;
38
- } else {
39
- ctx = 'error';
40
- }
41
- toast.error({
42
- title: 'Erreur !',
43
- description: request.message
44
- });
45
- return;
46
- }
47
-
48
- ctx = request.data;
49
- console.log(ctx);
50
- console.log($entity);
51
-
52
- mounted = true;
53
- }
54
11
  </script>
55
-
56
- {#if ctx !== null}
57
- {#if ctx === 403}
58
- <div class="error">
59
- <svg
60
- width="24"
61
- height="24"
62
- viewBox="0 0 24 24"
63
- fill="none"
64
- xmlns="http://www.w3.org/2000/svg"
65
- >
66
- <path
67
- opacity="0.4"
68
- d="M10.9608 2.10989L5.46078 4.16989C4.41078 4.56989 3.55078 5.80989 3.55078 6.93989V15.0399C3.55078 15.8499 4.08078 16.9199 4.73078 17.3999L10.2308 21.5099C11.2008 22.2399 12.7908 22.2399 13.7608 21.5099L19.2608 17.3999C19.9108 16.9099 20.4408 15.8499 20.4408 15.0399V6.93989C20.4408 5.81989 19.5808 4.56988 18.5308 4.17988L13.0308 2.11989C12.4708 1.89989 11.5308 1.89989 10.9608 2.10989Z"
69
- fill="#292D32"
70
- />
71
- <path
72
- d="M14.5 10.5C14.5 9.12 13.38 8 12 8C10.62 8 9.5 9.12 9.5 10.5C9.5 11.62 10.24 12.55 11.25 12.87V15.5C11.25 15.91 11.59 16.25 12 16.25C12.41 16.25 12.75 15.91 12.75 15.5V12.87C13.76 12.55 14.5 11.62 14.5 10.5Z"
73
- fill="#292D32"
74
- />
75
- </svg>
76
-
77
- <h3>Vous n'avez pas accès a cet ressource</h3>
78
- <p>Vous ne pouvez pas consulté les element lié a cette entité !</p>
79
- </div>
80
- {:else if ctx === 'error'}
81
- <div class="error">
82
- <svg
83
- width="24"
84
- height="24"
85
- viewBox="0 0 24 24"
86
- fill="none"
87
- xmlns="http://www.w3.org/2000/svg"
88
- >
89
- <path
90
- opacity="0.4"
91
- d="M21.7605 15.92L15.3605 4.4C14.5005 2.85 13.3105 2 12.0005 2C10.6905 2 9.50047 2.85 8.64047 4.4L2.24047 15.92C1.43047 17.39 1.34047 18.8 1.99047 19.91C2.64047 21.02 3.92047 21.63 5.60047 21.63H18.4005C20.0805 21.63 21.3605 21.02 22.0105 19.91C22.6605 18.8 22.5705 17.38 21.7605 15.92Z"
92
- fill="#292D32"
93
- />
94
- <path
95
- d="M12 14.75C11.59 14.75 11.25 14.41 11.25 14V9C11.25 8.59 11.59 8.25 12 8.25C12.41 8.25 12.75 8.59 12.75 9V14C12.75 14.41 12.41 14.75 12 14.75Z"
96
- fill="#292D32"
97
- />
98
- <path
99
- d="M12 18.0001C11.94 18.0001 11.87 17.9901 11.8 17.9801C11.74 17.9701 11.68 17.9501 11.62 17.9201C11.56 17.9001 11.5 17.8701 11.44 17.8301C11.39 17.7901 11.34 17.7501 11.29 17.7101C11.11 17.5201 11 17.2601 11 17.0001C11 16.7401 11.11 16.4801 11.29 16.2901C11.34 16.2501 11.39 16.2101 11.44 16.1701C11.5 16.1301 11.56 16.1001 11.62 16.0801C11.68 16.0501 11.74 16.0301 11.8 16.0201C11.93 15.9901 12.07 15.9901 12.19 16.0201C12.26 16.0301 12.32 16.0501 12.38 16.0801C12.44 16.1001 12.5 16.1301 12.56 16.1701C12.61 16.2101 12.66 16.2501 12.71 16.2901C12.89 16.4801 13 16.7401 13 17.0001C13 17.2601 12.89 17.5201 12.71 17.7101C12.66 17.7501 12.61 17.7901 12.56 17.8301C12.5 17.8701 12.44 17.9001 12.38 17.9201C12.32 17.9501 12.26 17.9701 12.19 17.9801C12.13 17.9901 12.06 18.0001 12 18.0001Z"
100
- fill="#292D32"
101
- />
102
- </svg>
103
-
104
- <h3>Une erreur est survenue !</h3>
105
- <p>Impossible de récuperer l'entrée !</p>
106
- </div>
107
- {:else if $entity}
108
- {@const primaryField = $entity.getPrimaryField()}
109
- <div class="form">
110
- <div class="title">
111
- <h1>{$entity.symbol}{ctx?.[primaryField.id].flat}</h1>
112
- {#if children}
113
- {@render children()}
114
- {/if}
115
- </div>
116
- {#each $entity.fields as field}
117
- <FieldView id={field.id} entityId={$entity.id} value={ctx?.[field.id] ?? null}></FieldView>
118
- {/each}
119
- </div>
120
- {/if}
12
+ {#if $entity}
13
+
121
14
  {/if}
122
15
 
123
16
  <style>
124
- .loader {
125
- display: flex;
126
- align-items: center;
127
- justify-content: center;
128
- padding: 60px var(--pad-m);
129
- }
130
-
131
- .error {
132
- padding: 60px var(--pad-m);
133
- display: flex;
134
- flex-direction: column;
135
- align-items: center;
136
- row-gap: var(--pad-m);
137
- }
138
- .error > svg {
139
- width: 60px;
140
- height: auto;
141
- }
142
- .error > svg path {
143
- fill: var(--red);
144
- }
145
- .title {
146
- display: flex;
147
- align-items: center;
148
- justify-content: space-between;
149
- width: min(100%, 900px);
150
- margin-bottom: 20px;
151
- }
152
-
153
- .form {
154
- display: flex;
155
- flex-direction: column;
156
- align-items: center;
157
- width: 100%;
158
- }
159
17
  </style>