hamzus-ui 0.0.9 → 0.0.10

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 CHANGED
@@ -2,9 +2,10 @@
2
2
  import type { SvelteComponentTyped } from "svelte";
3
3
 
4
4
  // button
5
- export class Button extends SvelteComponentTyped<any> {}
6
- export class IconButton extends SvelteComponentTyped<any> {}
5
+ export { default as Button } from "./src/components/hamzus-ui/Button/Button.svelte"
6
+ export { default as IconButton } from "./src/components/hamzus-ui/IconButton/IconButton.svelte"
7
7
  // text
8
+ export class Chips extends SvelteComponentTyped<any> {}
8
9
  export class Tag extends SvelteComponentTyped<any> {}
9
10
  export class InfoCard extends SvelteComponentTyped<any> {}
10
11
  export class AlertCard extends SvelteComponentTyped<any> {}
@@ -16,6 +17,7 @@ export class Dialog extends SvelteComponentTyped<any> {}
16
17
 
17
18
  // form
18
19
  export class Input extends SvelteComponentTyped<any> {}
20
+ export class DatePicker extends SvelteComponentTyped<any> {}
19
21
 
20
22
 
21
23
  export * as DropdownMenu from "./src/components/hamzus-ui/DropdownMenu";
package/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export { default as Button } from "./src/components/hamzus-ui/Button/Button.svelte"
3
3
  export { default as IconButton } from "./src/components/hamzus-ui/IconButton/IconButton.svelte"
4
4
  // text
5
+ export { default as Chips } from "./src/components/hamzus-ui/Chips/Chips.svelte"
5
6
  export { default as Tag } from "./src/components/hamzus-ui/Tag/Tag.svelte"
6
7
  export { default as InfoCard } from "./src/components/hamzus-ui/InfoCard/InfoCard.svelte"
7
8
  export { default as AlertCard } from "./src/components/hamzus-ui/AlertCard/AlertCard.svelte"
@@ -11,6 +12,7 @@ export { default as Kbd } from "./src/components/hamzus-ui/KBD/KBD.svelte"
11
12
  export { default as Dialog } from "./src/components/hamzus-ui/Dialog/Dialog.svelte"
12
13
  // form
13
14
  export { default as Input } from "./src/components/hamzus-ui/Input/Input.svelte"
15
+ export { default as DatePicker } from "./src/components/hamzus-ui/DatePicker/DatePicker.svelte"
14
16
 
15
17
 
16
18
  export * as DropdownMenu from "./src/components/hamzus-ui/DropdownMenu"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamzus-ui",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -0,0 +1,26 @@
1
+ <div class="chips h5">
2
+ <slot/>
3
+ </div>
4
+ <style>
5
+ .chips {
6
+ display: flex;
7
+ width: max-content;
8
+ align-items: center;
9
+ column-gap: var(--pad-m);
10
+ padding: var(--pad-xs) var(--pad-xl);
11
+ border-radius: var(--radius-xxl);
12
+ border: 1px solid var(--stroke);
13
+ background-color: var(--bg-1);
14
+ color: var(--font-2);
15
+ }
16
+ .chips > :global(*) {
17
+ color: var(--font-2);
18
+ }
19
+
20
+ .chips > :global(svg) {
21
+ width: 16px;
22
+ }
23
+ .chips > :global(svg path) {
24
+ fill: var(--font-2);
25
+ }
26
+ </style>
@@ -5,7 +5,9 @@
5
5
  import { onMount } from 'svelte';
6
6
 
7
7
  export let value = ""
8
+ export let label = ""
8
9
  export let name = ""
10
+ export let required = false
9
11
 
10
12
  const monthList = {
11
13
  1: 'janvier',
@@ -23,9 +25,10 @@
23
25
  };
24
26
  const yearList = getYearList();
25
27
 
26
- let monthInput;
28
+ let toggleDisplay;
29
+
30
+ let labelMonth = "selectionner une date";
27
31
 
28
- let currentDay = null
29
32
  let currentYear = new Date().getFullYear();
30
33
  let currentMonth = new Date().getMonth() + 1;
31
34
 
@@ -110,68 +113,22 @@
110
113
  function handleUpdateValue(day) {
111
114
  const formatNumber = (num) => num.toString().padStart(2, '0');
112
115
 
113
- currentDay = day
114
-
115
116
  value = `${currentYear}-${formatNumber(currentMonth)}-${formatNumber(day)}`
116
- }
117
117
 
118
- function handleChangeDayInput(event) {
119
- const onlyNumbers = event.target.value.replace(/\D/g, '');
120
-
121
- if (onlyNumbers.length === 0) {
122
- currentDay = null
123
- return
124
- }
125
-
126
- if (onlyNumbers === "0") {
127
- currentDay = null
128
- return
129
- }
130
-
131
- if (onlyNumbers.length === 1) {
132
- currentDay = "0" + onlyNumbers
133
- return
134
- }
135
-
136
- if (onlyNumbers.length === 3 && onlyNumbers.charAt(0) === "0") {
137
- // prendre les deux dernier chiffre
138
- currentDay = onlyNumbers.charAt(1) + onlyNumbers.charAt(onlyNumbers.length - 1)
139
- monthInput.focus()
140
- return
141
- }
142
-
143
-
144
- if (onlyNumbers.length === 3) {
145
- // prendre le dernier chiffre et mettre un zero
146
- currentDay = "0" + onlyNumbers.charAt(onlyNumbers.length - 1)
147
- return
148
- }
149
- currentDay = onlyNumbers
150
-
151
- console.log(currentDay);
152
-
153
- }
118
+ labelMonth = `${day} ${monthList[currentMonth]} ${currentYear}`
154
119
 
155
- function handleChangeMonthInput(event) {
156
-
120
+ toggleDisplay()
157
121
  }
158
122
  </script>
159
123
 
160
- <input type="hidden" {name} {value}>
161
- <h4>{value}</h4>
162
-
163
- <div class="group">
164
-
165
- <input type="text" bind:value={currentDay} placeholder="dd" on:input={handleChangeDayInput} class="cell p">
166
- <p>/</p>
167
- <input type="text" placeholder="mm" on:input={handleChangeMonthInput} bind:this={monthInput} class="cell p">
168
-
169
- </div>
170
-
171
-
172
- <DropdownMenu.Root>
124
+ <div class="date-picker">
125
+ {#if label}
126
+ <h5>{label}</h5>
127
+ {/if}
128
+ <DropdownMenu.Root triggerFullWidth bind:toggleDisplay>
173
129
  <DropdownMenu.Trigger slot="trigger">
174
- <IconButton variant="ghost">
130
+ <Button variant="outline" style="width:100%">
131
+ <input class="date-input" {required} type="date" {name} {value}>
175
132
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
176
133
  <path d="M8 5.75C7.59 5.75 7.25 5.41 7.25 5V2C7.25 1.59 7.59 1.25 8 1.25C8.41 1.25 8.75 1.59 8.75 2V5C8.75 5.41 8.41 5.75 8 5.75Z" fill="white" />
177
134
  <path d="M16 5.75C15.59 5.75 15.25 5.41 15.25 5V2C15.25 1.59 15.59 1.25 16 1.25C16.41 1.25 16.75 1.59 16.75 2V5C16.75 5.41 16.41 5.75 16 5.75Z" fill="white" />
@@ -184,7 +141,8 @@
184
141
  <path d="M20.5 9.83984H3.5C3.09 9.83984 2.75 9.49984 2.75 9.08984C2.75 8.67984 3.09 8.33984 3.5 8.33984H20.5C20.91 8.33984 21.25 8.67984 21.25 9.08984C21.25 9.49984 20.91 9.83984 20.5 9.83984Z" fill="white" />
185
142
  <path d="M16 22.75H8C4.35 22.75 2.25 20.65 2.25 17V8.5C2.25 4.85 4.35 2.75 8 2.75H16C19.65 2.75 21.75 4.85 21.75 8.5V17C21.75 20.65 19.65 22.75 16 22.75ZM8 4.25C5.14 4.25 3.75 5.64 3.75 8.5V17C3.75 19.86 5.14 21.25 8 21.25H16C18.86 21.25 20.25 19.86 20.25 17V8.5C20.25 5.64 18.86 4.25 16 4.25H8Z" fill="white" />
186
143
  </svg>
187
- </IconButton>
144
+ {labelMonth}
145
+ </Button>
188
146
  </DropdownMenu.Trigger>
189
147
  <DropdownMenu.Content
190
148
  slot="content"
@@ -254,25 +212,9 @@
254
212
  </DropdownMenu.Content>
255
213
  </DropdownMenu.Root>
256
214
 
215
+ </div>
257
216
  <style>
258
217
 
259
- .group {
260
- display: flex;
261
- align-items: center;
262
- column-gap: var(--pad-s);
263
- }
264
-
265
- .cell {
266
- padding: var(--pad-xs);
267
- border-radius: var(--radius-s);
268
- width: 30px;
269
- }
270
- .cell:hover {
271
- background-color: var(--bg-3);
272
- }
273
- .cell:focus{
274
- background-color: var(--bg-1);
275
- }
276
218
 
277
219
  .month-selector {
278
220
  display: flex;
@@ -289,7 +231,6 @@
289
231
  background-color: var(--bg-2);
290
232
  }
291
233
 
292
- .calendar th > div,
293
234
  .calendar td > div {
294
235
  display: flex;
295
236
  align-items: center;
@@ -323,4 +264,12 @@
323
264
  border-bottom-left-radius: var(--radius-l);
324
265
  border-bottom-right-radius: var(--radius-l);
325
266
  }
267
+
268
+ .date-input {
269
+ display: none;
270
+ }
271
+ :global(button:has(.date-input:user-invalid)) {
272
+ border: 1px solid var(--red);
273
+ background-color: var(--red-b);
274
+ }
326
275
  </style>
@@ -45,7 +45,7 @@ import { onDestroy, onMount } from 'svelte';
45
45
  }
46
46
  }
47
47
 
48
- function toggleDisplay() {
48
+ export let toggleDisplay = () => {
49
49
  if (display) {
50
50
  // appliquer une animation
51
51
  exit = true;
@@ -23,7 +23,7 @@
23
23
  export let isLoading = false;
24
24
  export let isVisible = false;
25
25
  export let padding = '3px 10px';
26
- export let borderRadius = '12px';
26
+ export let borderRadius = 'var(--radius-m)';
27
27
  export let defaultBg = '--bg-2';
28
28
  export let formatPattern = [];
29
29
  import { onMount } from 'svelte';