mountain-ui 1.0.29 → 1.0.30

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 (98) hide show
  1. package/package.json +1 -1
  2. package/src/lib/registry/entityRegistry/components/EntityPage.svelte +158 -0
  3. package/src/lib/registry/entityRegistry/components/FieldTableView.svelte +23 -0
  4. package/src/lib/registry/entityRegistry/components/FieldView.svelte +24 -0
  5. package/src/lib/registry/entityRegistry/createEntity.js +2 -0
  6. package/src/lib/registry/fieldTypeRegistry/components/FieldTypeTableView.svelte +11 -0
  7. package/src/lib/registry/fieldTypeRegistry/components/FieldTypeView.svelte +11 -0
  8. package/src/lib/registry/fieldTypeRegistry/components/LineView.svelte +33 -0
  9. package/src/lib/registry/fieldTypeRegistry/components/ViewText.svelte +5 -0
  10. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/View.svelte +61 -0
  11. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/TableView.svelte +8 -0
  12. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/View.svelte +19 -0
  13. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/index.js +4 -1
  14. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/TableView.svelte +8 -0
  15. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/View.svelte +15 -0
  16. package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/index.js +4 -1
  17. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/TableView.svelte +8 -0
  18. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/View.svelte +52 -0
  19. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/index.js +4 -1
  20. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/TableView.svelte +8 -0
  21. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/View.svelte +52 -0
  22. package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationLine/index.js +6 -2
  23. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/TableView.svelte +28 -0
  24. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/View.svelte +31 -0
  25. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/index.js +4 -1
  26. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/TableView.svelte +13 -0
  27. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/View.svelte +18 -0
  28. package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/index.js +4 -1
  29. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/TableView.svelte +8 -0
  30. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/View.svelte +12 -0
  31. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/index.js +4 -1
  32. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/TableView.svelte +8 -0
  33. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/View.svelte +12 -0
  34. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/index.js +4 -1
  35. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/TableView.svelte +8 -0
  36. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/View.svelte +12 -0
  37. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/index.js +4 -1
  38. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/TableView.svelte +8 -0
  39. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/View.svelte +12 -0
  40. package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/index.js +4 -1
  41. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/TableView.svelte +8 -0
  42. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/View.svelte +12 -0
  43. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/index.js +4 -1
  44. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/TableView.svelte +8 -0
  45. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/View.svelte +12 -0
  46. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/index.js +4 -1
  47. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/TableView.svelte +8 -0
  48. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/View.svelte +13 -0
  49. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/index.js +4 -1
  50. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/TableView.svelte +8 -0
  51. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/View.svelte +12 -0
  52. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/index.js +4 -1
  53. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/TableView.svelte +8 -0
  54. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/View.svelte +13 -0
  55. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/index.js +4 -1
  56. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/TableView.svelte +8 -0
  57. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/View.svelte +24 -0
  58. package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/index.js +4 -1
  59. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/TableView.svelte +9 -0
  60. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/View.svelte +13 -0
  61. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/index.js +4 -1
  62. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/TableView.svelte +9 -0
  63. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/View.svelte +13 -0
  64. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/index.js +4 -1
  65. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/TableView.svelte +9 -0
  66. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/View.svelte +13 -0
  67. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/index.js +4 -1
  68. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/TableView.svelte +8 -0
  69. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/View.svelte +12 -0
  70. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/index.js +4 -1
  71. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/TableView.svelte +8 -0
  72. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/View.svelte +12 -0
  73. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/index.js +4 -1
  74. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/TableView.svelte +8 -0
  75. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/View.svelte +12 -0
  76. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/index.js +4 -1
  77. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/TableView.svelte +8 -0
  78. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/View.svelte +12 -0
  79. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/index.js +4 -1
  80. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/TableView.svelte +9 -0
  81. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/View.svelte +13 -0
  82. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/index.js +4 -1
  83. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/TableView.svelte +8 -0
  84. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/View.svelte +12 -0
  85. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/index.js +4 -1
  86. package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/formatDate.js +155 -0
  87. package/src/lib/registry/viewTypeRegistry/components/ViewTypeButton.svelte +27 -0
  88. package/src/lib/registry/viewTypeRegistry/components/ViewTypeComponent.svelte +30 -0
  89. package/src/lib/registry/viewTypeRegistry/createViewType.js +17 -0
  90. package/src/lib/registry/viewTypeRegistry/registerDefaultViewTypes.js +7 -0
  91. package/src/lib/registry/viewTypeRegistry/registry.svelte.js +44 -0
  92. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/Icon.svelte +16 -0
  93. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/component/Component copy.svelte +11 -0
  94. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/component/Component.svelte +12 -0
  95. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/component/StructureTable.svelte +287 -0
  96. package/src/lib/registry/viewTypeRegistry/viewTypes/Table/index.js +14 -0
  97. package/src/routes/+layout.svelte +13 -1
  98. package/src/routes/+page.svelte +22 -1
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-datetime',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+
4
+ let { value } = $props();
5
+ </script>
6
+
7
+
8
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+
6
+ let { value, compact, unique, secret, label, required } = $props();
7
+ </script>
8
+
9
+ <LineView {compact}>
10
+ <Label {unique} {secret} {label} {required}></Label>
11
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
12
+ </LineView>
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-day',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+
4
+ let { value } = $props();
5
+ </script>
6
+
7
+
8
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+
6
+ let { value, compact, unique, secret, label, required } = $props();
7
+ </script>
8
+
9
+ <LineView {compact}>
10
+ <Label {unique} {secret} {label} {required}></Label>
11
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
12
+ </LineView>
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-hour',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+
4
+ let { value } = $props();
5
+ </script>
6
+
7
+
8
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+
6
+ let { value, compact, unique, secret, label, required } = $props();
7
+ </script>
8
+
9
+ <LineView {compact}>
10
+ <Label {unique} {secret} {label} {required}></Label>
11
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
12
+ </LineView>
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-month',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+
4
+ let { value } = $props();
5
+ </script>
6
+
7
+
8
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+
6
+ let { value, compact, unique, secret, label, required } = $props();
7
+ </script>
8
+
9
+ <LineView {compact}>
10
+ <Label {unique} {secret} {label} {required}></Label>
11
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
12
+ </LineView>
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-month_of_year',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,9 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+ import { formatDateTime } from "../formatDate";
4
+
5
+ let { value } = $props();
6
+ </script>
7
+
8
+
9
+ <ViewText>{value === null ? '-' : formatDateTime(value.flat)}</ViewText>
@@ -0,0 +1,13 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+ import { formatDateTime } from '../formatDate';
6
+
7
+ let { value, compact, unique, secret, label, required } = $props();
8
+ </script>
9
+
10
+ <LineView {compact}>
11
+ <Label {unique} {secret} {label} {required}></Label>
12
+ <ViewText>{value === null ? '-' : formatDateTime(value.flat)}</ViewText>
13
+ </LineView>
@@ -3,6 +3,8 @@ import { createFieldType } from '../../../createFieldType.js';
3
3
  import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
+ import TableView from './TableView.svelte';
7
+ import View from './View.svelte';
6
8
 
7
9
  export default createFieldType({
8
10
  type: 'time-updated_at',
@@ -24,7 +26,8 @@ export default createFieldType({
24
26
  button: Button,
25
27
  card: Card,
26
28
  input: null,
27
- cell: null,
29
+ tableView: TableView,
30
+ view: View,
28
31
  filter: null,
29
32
  properties: null
30
33
  },
@@ -0,0 +1,8 @@
1
+ <script>
2
+ import ViewText from "../../../components/ViewText.svelte";
3
+
4
+ let { value } = $props();
5
+ </script>
6
+
7
+
8
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ import Label from '../../../components/Label.svelte';
3
+ import LineView from '../../../components/LineView.svelte';
4
+ import ViewText from '../../../components/ViewText.svelte';
5
+
6
+ let { value, compact, unique, secret, label, required } = $props();
7
+ </script>
8
+
9
+ <LineView {compact}>
10
+ <Label {unique} {secret} {label} {required}></Label>
11
+ <ViewText>{value === null ? '-' : value.flat}</ViewText>
12
+ </LineView>
@@ -4,6 +4,8 @@ import Icon from './Icon.svelte';
4
4
  import Button from './Button.svelte';
5
5
  import Card from './Card.svelte';
6
6
  import Input from './Input.svelte';
7
+ import TableView from './TableView.svelte';
8
+ import View from './View.svelte';
7
9
 
8
10
  export default createFieldType({
9
11
  type: 'time-year',
@@ -25,7 +27,8 @@ export default createFieldType({
25
27
  button: Button,
26
28
  card: Card,
27
29
  input: Input,
28
- cell: null,
30
+ tableView: TableView,
31
+ view: View,
29
32
  filter: null,
30
33
  properties: null
31
34
  },
@@ -0,0 +1,155 @@
1
+
2
+ export function formatDateFromTimestamp(timestamp) {
3
+ // Créer une instance Date à partir du timestamp
4
+ const date = new Date(timestamp);
5
+
6
+ // Utiliser Intl.DateTimeFormat pour formater la date
7
+ const formatter = new Intl.DateTimeFormat('fr-FR', {
8
+ year: 'numeric',
9
+ month: '2-digit',
10
+ day: '2-digit',
11
+ hour: '2-digit',
12
+ minute: '2-digit',
13
+ second: '2-digit',
14
+ hour12: false // Utiliser l'heure au format 24 heures
15
+ });
16
+
17
+ // Formatage de la date avec Intl.DateTimeFormat
18
+ const parts = formatter.formatToParts(date);
19
+
20
+ // Extraire les différentes parties de la date
21
+ const year = parts.find(part => part.type === 'year').value;
22
+ const month = parts.find(part => part.type === 'month').value;
23
+ const day = parts.find(part => part.type === 'day').value;
24
+ const hour = parts.find(part => part.type === 'hour').value;
25
+ const minute = parts.find(part => part.type === 'minute').value;
26
+ const second = parts.find(part => part.type === 'second').value;
27
+
28
+ // Formater la date selon le format souhaité
29
+ return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
30
+ }
31
+
32
+ export function formatDate(dateOrigine) {
33
+ dateOrigine = new Date(dateOrigine);
34
+
35
+ // Extraction des composants de la date
36
+ let annee = dateOrigine.getFullYear();
37
+ let mois = dateOrigine.getMonth() + 1; // Les mois commencent à 0, donc ajoutez 1
38
+ let jour = dateOrigine.getDate();
39
+
40
+ // Formatage des composants de la date
41
+ let dateFormatee = (jour < 10 ? '0' : '') + jour + '/' +
42
+ (mois < 10 ? '0' : '') + mois + '/' +
43
+ annee
44
+ return dateFormatee;
45
+ }
46
+
47
+ export function formatDateTime(dateOrigine) {
48
+ dateOrigine = new Date(convertToLocalDateTime(dateOrigine));
49
+
50
+ // Extraction des composants de la date
51
+ let annee = dateOrigine.getFullYear();
52
+ let mois = dateOrigine.getMonth() + 1; // Les mois commencent à 0, donc ajoutez 1
53
+ let jour = dateOrigine.getDate();
54
+ let heures = dateOrigine.getHours();
55
+ let minutes = dateOrigine.getMinutes();
56
+ let secondes = dateOrigine.getSeconds();
57
+
58
+ // Formatage des composants de la date
59
+ let dateFormatee = (jour < 10 ? '0' : '') + jour + '/' +
60
+ (mois < 10 ? '0' : '') + mois + '/' +
61
+ annee + ' à ' +
62
+ (heures < 10 ? '0' : '') + heures + ':' +
63
+ (minutes < 10 ? '0' : '') + minutes + ":" +
64
+ (secondes < 10 ? '0' : '') + secondes;
65
+ return dateFormatee;
66
+ }
67
+ export function formatTime(dateOrigine) {
68
+ dateOrigine = new Date(convertToLocalDateTime(dateOrigine));
69
+
70
+ let heures = dateOrigine.getHours();
71
+ let minutes = dateOrigine.getMinutes();
72
+
73
+ // Formatage des composants de la date
74
+ let dateFormatee = (heures < 10 ? '0' : '') + heures + 'h' +
75
+ (minutes < 10 ? '0' : '') + minutes;
76
+ return dateFormatee;
77
+ }
78
+ export function convertirSec(secondes) {
79
+ const heures = Math.floor(secondes / 3600);
80
+ let minutes = Math.floor((secondes % 3600) / 60);
81
+ if (heures !== 0) {
82
+ minutes = minutes.toString().length == 1 ? '0' + minutes : minutes
83
+
84
+ return `${heures}h${minutes}`;
85
+ }else{
86
+ return `${minutes}min`;
87
+ }
88
+ }
89
+
90
+ export function formatMonth(dateString) {
91
+ const date = new Date(dateString);
92
+
93
+ // Formatage en "mois année" (par exemple, "octobre 2024" en français)
94
+ const options = { year: 'numeric', month: 'long' };
95
+ return new Intl.DateTimeFormat('fr-FR', options).format(date);
96
+ }
97
+ export function timeSince(date) {
98
+ const now = new Date();
99
+ const past = new Date(convertToLocalDateTime(date));
100
+ const diffMs = now - past; // en millisecondes
101
+
102
+ const seconds = Math.floor(diffMs / 1000);
103
+ const minutes = Math.floor(diffMs / (1000 * 60));
104
+ const hours = Math.floor(diffMs / (1000 * 60 * 60));
105
+ const days = Math.floor(diffMs / (1000 * 60 * 60 * 24));
106
+
107
+ if (seconds < 60) {
108
+ return `il y a ${seconds} sec`;
109
+ } else if (minutes < 60) {
110
+ return `il y a ${minutes} min`;
111
+ } else if (hours < 24) {
112
+ return `il y a ${hours} h`;
113
+ } else {
114
+ return `il y a ${days} j`;
115
+ }
116
+ }
117
+
118
+ export function convertToLocalDateTime(Datetime) {
119
+ // Convertir la chaîne en objet Date UTC
120
+ const utcDate = new Date(Datetime.replace(' ', 'T') + 'Z');
121
+
122
+ // Extraire les composants de la date locale
123
+ const year = utcDate.getFullYear();
124
+ const month = String(utcDate.getMonth() + 1).padStart(2, '0'); // Mois de 0 à 11, on ajoute donc 1
125
+ const day = String(utcDate.getDate()).padStart(2, '0');
126
+
127
+ // Extraire les composants de l'heure locale
128
+ const hours = String(utcDate.getHours()).padStart(2, '0');
129
+ const minutes = String(utcDate.getMinutes()).padStart(2, '0');
130
+ const seconds = String(utcDate.getSeconds()).padStart(2, '0');
131
+
132
+ // Formater la date et l'heure en YYYY-MM-DD HH:mm:SS
133
+ const localDateTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
134
+
135
+ return localDateTime;
136
+ }
137
+ export function convertToLocalDateTimeForDateTime(Datetime) {
138
+ // Convertir la chaîne en objet Date UTC
139
+ const utcDate = new Date(Datetime.replace(' ', 'T') + 'Z');
140
+
141
+ // Extraire les composants de la date locale
142
+ const year = utcDate.getFullYear();
143
+ const month = String(utcDate.getMonth() + 1).padStart(2, '0'); // Mois de 0 à 11, on ajoute donc 1
144
+ const day = String(utcDate.getDate()).padStart(2, '0');
145
+
146
+ // Extraire les composants de l'heure locale
147
+ const hours = String(utcDate.getHours()).padStart(2, '0');
148
+ const minutes = String(utcDate.getMinutes()).padStart(2, '0');
149
+
150
+ // Formater la date et l'heure en YYYY-MM-DD HH:mm:SS
151
+ const localDateTime = `${year}-${month}-${day} ${hours}:${minutes}`;
152
+
153
+ return localDateTime;
154
+ }
155
+
@@ -0,0 +1,27 @@
1
+ <script>
2
+ import { Button } from 'hamzus-ui';
3
+ import { viewTypeRegistry } from '../registry.svelte';
4
+
5
+ let { type, variant = 'ghost', ...props } = $props();
6
+
7
+ const viewType = viewTypeRegistry.get(type);
8
+ </script>
9
+
10
+ {#if viewType}
11
+ <Button {...props} {variant} style="padding:var(--pad-s) var(--pad-l) var(--pad-s) var(--pad-s);width:100%;">
12
+ <div class="ico">
13
+ <svelte:component this={viewType.components.icon}></svelte:component>
14
+ </div>
15
+ <h5>{viewType.name}</h5>
16
+ </Button>
17
+ {/if}
18
+
19
+ <style>
20
+ .ico {
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ width: 16px;
25
+ height: 16px;
26
+ }
27
+ </style>
@@ -0,0 +1,30 @@
1
+ <script>
2
+ import { Button, RotativeLoader } from 'hamzus-ui';
3
+ import { viewTypeRegistry } from '../registry.svelte';
4
+
5
+ let { type, ...props } = $props();
6
+
7
+ const viewType = viewTypeRegistry.get(type);
8
+
9
+ console.log(viewType);
10
+
11
+ </script>
12
+
13
+ {#if viewType}
14
+ <svelte:component this={viewType.components.component} {...props}></svelte:component>
15
+ {:else}
16
+ <div class="loader">
17
+ <RotativeLoader></RotativeLoader>
18
+ </div>
19
+ {/if}
20
+
21
+ <style>
22
+
23
+ .loader {
24
+ display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ padding: 60px var(--pad-m);
28
+ }
29
+ </style>
30
+
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,7 @@
1
+ import { viewTypeRegistry } from './registry.svelte';
2
+ import Table from './viewTypes/Table';
3
+
4
+
5
+ export function registerDefaultViewTypes() {
6
+ viewTypeRegistry.register(Table)
7
+ }
@@ -0,0 +1,44 @@
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();
@@ -0,0 +1,16 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ d="M4.1 11L19.9 11C21.4 11 22 10.36 22 8.77L22 4.73C22 3.14 21.4 2.5 19.9 2.5L4.1 2.5C2.6 2.5 2 3.14 2 4.73L2 8.77C2 10.36 2.6 11 4.1 11Z"
4
+ fill="#00C0E8"
5
+ />
6
+ <path
7
+ opacity="0.4"
8
+ d="M13.1 21.5L19.9 21.5C21.4 21.5 22 20.86 22 19.27L22 15.23C22 13.64 21.4 13 19.9 13L13.1 13C11.6 13 11 13.64 11 15.23L11 19.27C11 20.86 11.6 21.5 13.1 21.5Z"
9
+ fill="#00C0E8"
10
+ />
11
+ <path
12
+ opacity="0.4"
13
+ d="M4.1 21.5L6.9 21.5C8.4 21.5 9 20.86 9 19.27L9 15.23C9 13.64 8.4 13 6.9 13L4.1 13C2.6 13 2 13.64 2 15.23L2 19.27C2 20.86 2.6 21.5 4.1 21.5Z"
14
+ fill="#00C0E8"
15
+ />
16
+ </svg>
@@ -0,0 +1,11 @@
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>
@@ -0,0 +1,12 @@
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 { entityId, ...props } = $props();
7
+
8
+ </script>
9
+
10
+ <StructureTable {entityId} {...props}>
11
+ <slot slot="actions" name="actions"></slot>
12
+ </StructureTable>