hamzus-ui 0.0.34 → 0.0.36

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamzus-ui",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -5,6 +5,7 @@
5
5
  import { onMount } from 'svelte';
6
6
 
7
7
  export let value = ""
8
+ export let onChange = undefined
8
9
  export let label = ""
9
10
  export let name = ""
10
11
  export let required = false
@@ -27,7 +28,7 @@
27
28
 
28
29
  let toggleDisplay;
29
30
 
30
- let labelMonth = "selectionner une date";
31
+ $: labelMonth = formatValue(value);
31
32
 
32
33
  let currentYear = new Date().getFullYear();
33
34
  let currentMonth = new Date().getMonth() + 1;
@@ -42,7 +43,20 @@
42
43
  return Array.from({ length: currentYear - startYear + 1 }, (_, i) => currentYear + 100 - i);
43
44
  }
44
45
 
45
- onMount(() => {});
46
+ function formatValue(value) {
47
+ if (value === "") {
48
+ return "selectionner une date"
49
+ }
50
+
51
+ const dateData = value.split("-")
52
+
53
+ const day = parseInt(dateData[2])
54
+ const month = parseInt(dateData[1])
55
+ const year = dateData[0]
56
+
57
+ return `${day} ${monthList[month]} ${currentYear}`
58
+
59
+ }
46
60
 
47
61
  function generateCalendarMatrix(year, month) {
48
62
  const firstDay = new Date(year, month, 1);
@@ -115,7 +129,9 @@
115
129
 
116
130
  value = `${currentYear}-${formatNumber(currentMonth)}-${formatNumber(day)}`
117
131
 
118
- labelMonth = `${day} ${monthList[currentMonth]} ${currentYear}`
132
+ if (onChange !== undefined) {
133
+ onChange(value)
134
+ }
119
135
 
120
136
  toggleDisplay()
121
137
  }