sprintify-ui 0.0.142 → 0.0.144

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.
@@ -1,10 +1,7 @@
1
1
  <template>
2
- <div
3
- class="base-date-picker relative"
4
- :class="{ 'base-date-picker--inline': inline }"
5
- >
2
+ <div class="base-date-picker relative">
6
3
  <div
7
- class="pointer-events-none absolute top-0 left-0 flex h-10 items-center justify-center pl-2.5"
4
+ class="pointer-events-none absolute top-0 left-0 flex h-[42px] items-center justify-center pl-2.5"
8
5
  >
9
6
  <BaseIcon
10
7
  class="relative -top-px h-5 w-5 text-slate-400"
@@ -22,11 +19,11 @@
22
19
  />
23
20
  <div
24
21
  v-if="modelValueFormatted && !disabled"
25
- class="absolute right-0 top-0.5 flex h-full justify-center p-1"
22
+ class="absolute right-0 top-0 flex h-[42px] items-center justify-center p-1"
26
23
  >
27
24
  <button
28
25
  type="button"
29
- class="flex h-8 items-center rounded p-1 hover:bg-slate-200"
26
+ class="flex items-center rounded p-1.5 hover:bg-slate-100"
30
27
  @click="clear()"
31
28
  >
32
29
  <BaseIcon class="h-5 w-5 text-slate-600" icon="heroicons:x-mark" />
@@ -131,17 +128,39 @@ const modelValueFormatted = computed((): string | string[] | null => {
131
128
  const listModelValue = [] as string[];
132
129
 
133
130
  props.modelValue.forEach(function (date) {
134
- listModelValue.push(DateTime.fromISO(date, { zone: 'utc' }).toISODate());
131
+ listModelValue.push(parseDate(date));
135
132
  });
136
133
 
137
134
  return listModelValue;
138
135
  }
139
136
 
140
- return (
141
- DateTime.fromISO(props.modelValue, { zone: 'utc' }).toISODate() ?? null
142
- );
137
+ return parseDate(props.modelValue);
143
138
  });
144
139
 
140
+ function dateJsToLuxon(date: Date): DateTime {
141
+ return DateTime.fromJSDate(date);
142
+ }
143
+
144
+ function stringToLuxon(date: string): DateTime {
145
+ if (date.includes('Z') && date.includes('T')) {
146
+ return DateTime.fromISO(date);
147
+ }
148
+
149
+ return DateTime.fromSQL(date);
150
+ }
151
+
152
+ function luxonToString(date: DateTime): string {
153
+ if (props.enableTime) {
154
+ return date.toFormat('yyyy-MM-dd HH:mm:ss');
155
+ }
156
+
157
+ return date.toFormat('yyyy-MM-dd');
158
+ }
159
+
160
+ function parseDate(date: string): string {
161
+ return luxonToString(stringToLuxon(date));
162
+ }
163
+
145
164
  const locale = computed(() => {
146
165
  if (props.locale === 'fr') {
147
166
  return French;
@@ -165,6 +184,8 @@ const flatpickrConfig = computed(() => {
165
184
  noCalendar: props.noCalendar,
166
185
  disable: props.disableDates,
167
186
  inline: props.inline,
187
+ animate: false,
188
+ time_24hr: true,
168
189
  };
169
190
  });
170
191
 
@@ -246,11 +267,7 @@ function init() {
246
267
  const listDate = [] as string[];
247
268
 
248
269
  dates.forEach(function (date) {
249
- if (props.enableTime) {
250
- listDate.push(DateTime.fromJSDate(date, { zone: 'utc' }).toISO());
251
- } else {
252
- listDate.push(DateTime.fromJSDate(date, { zone: 'utc' }).toISODate());
253
- }
270
+ listDate.push(luxonToString(dateJsToLuxon(date)));
254
271
  });
255
272
 
256
273
  if (listDate.length == 0) {
@@ -273,28 +290,99 @@ function clear() {
273
290
  }
274
291
  </script>
275
292
  <style lang="postcss">
276
- .base-date-picker--inline {
277
- .flatpickr-calendar.inline {
293
+ body .flatpickr-calendar {
294
+ width: 280px;
295
+ box-shadow: 1px 0 0 #cbd5e1, -1px 0 0 #cbd5e1, 0 1px 0 #cbd5e1,
296
+ 0 -1px 0 #cbd5e1, 0 3px 13px rgb(0 0 0 / 10%);
297
+
298
+ &.inline {
299
+ width: 260px;
278
300
  box-shadow: none;
279
301
  border: none;
280
302
  padding: 0;
281
- margin-top: 6px;
303
+
304
+ .flatpickr-months {
305
+ width: 260px;
306
+ }
307
+
308
+ .flatpickr-innerContainer {
309
+ padding: 0;
310
+ width: 260px;
311
+ }
312
+ }
313
+
314
+ .dayContainer {
315
+ width: 260px;
316
+ max-width: 260px;
317
+ min-width: 260px;
318
+ }
319
+
320
+ .flatpickr-day {
321
+ height: 36px;
322
+ line-height: 36px;
323
+ }
324
+
325
+ .flatpickr-months {
326
+ width: 280px;
327
+ padding-top: 10px;
328
+
329
+ .flatpickr-prev-month,
330
+ .flatpickr-next-month {
331
+ top: 5px;
332
+ }
333
+
334
+ .flatpickr-prev-month {
335
+ left: 2px;
336
+ }
337
+
338
+ .flatpickr-next-month {
339
+ right: 2px;
340
+ }
341
+
342
+ .flatpickr-prev-month:hover svg,
343
+ .flatpickr-next-month:hover svg {
344
+ fill: #888;
345
+ }
346
+ }
347
+
348
+ .flatpickr-current-month {
349
+ padding-top: 1px;
350
+
351
+ .flatpickr-monthDropdown-months {
352
+ font-weight: 400;
353
+ height: 25px;
354
+ &:focus {
355
+ box-shadow: none;
356
+ }
357
+ }
358
+
359
+ input.cur-year {
360
+ font-weight: 400;
361
+ height: 25px;
362
+ &:focus {
363
+ box-shadow: none;
364
+ }
365
+ }
366
+ }
367
+
368
+ .flatpickr-innerContainer {
369
+ padding: 10px;
370
+ padding-top: 0;
371
+ width: 280px;
372
+ }
373
+
374
+ .flatpickr-rContainer {
375
+ width: 260px;
376
+ }
377
+
378
+ .numInput {
379
+ &:focus {
380
+ box-shadow: none;
381
+ }
282
382
  }
283
383
  }
284
- .flatpickr-calendar .flatpickr-current-month .flatpickr-monthDropdown-months {
285
- font-weight: 400;
286
- }
287
- .flatpickr-calendar .flatpickr-current-month input.cur-year {
288
- font-weight: 400;
289
- }
290
- .flatpickr-months .flatpickr-prev-month:hover svg,
291
- .flatpickr-months .flatpickr-next-month:hover svg {
292
- fill: #888;
293
- }
384
+
294
385
  .flatpickr-calendar span.flatpickr-weekday {
295
386
  @apply font-medium text-slate-400;
296
387
  }
297
- .flatpickr-calendar .flatpickr-current-month {
298
- padding-top: 5px;
299
- }
300
388
  </style>