@starasia/date 5.0.3 → 5.1.1

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/dist/date.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsxs as F, jsx as r, Fragment as _ } from "react/jsx-runtime";
2
- import { useState as z, useRef as P, useEffect as S, forwardRef as G } from "react";
3
- const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
1
+ import { jsxs as $, jsx as a, Fragment as nn } from "react/jsx-runtime";
2
+ import { useState as j, useRef as J, useEffect as I, forwardRef as Z } from "react";
3
+ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
4
4
 
5
5
  * {
6
6
  margin: 0;
@@ -10,7 +10,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
10
10
  /* box-sizing: border-box; */
11
11
  }
12
12
  :root {
13
- --sa-date-radius: var(--sa-radii-md, 0.5rem);
13
+ --sa-date-radius: var(--sa-radii-sm, 0.375rem);
14
14
  --sa-date-radius-lg: var(--sa-radii-lg, 0.75rem);
15
15
  --sa-date-bg: var(--sa-background-primary, #ffffff);
16
16
  --sa-date-border-color: var(--sa-color-gray-alpha-a20, #78867f33);
@@ -147,6 +147,50 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
147
147
  gap: var(--sa-spacing-xs, 4px);
148
148
  }
149
149
 
150
+ .sa-calendar-header-title {
151
+ font-size: 15px;
152
+ font-weight: 600;
153
+ cursor: pointer;
154
+ color: var(--sa-date-text-primary);
155
+ flex: 1;
156
+ line-height: 1.3;
157
+ }
158
+
159
+ .sa-calendar-header-nav {
160
+ display: flex;
161
+ align-items: center;
162
+ gap: 2px;
163
+ flex-shrink: 0;
164
+ }
165
+
166
+ .sa-calendar-nav-btn {
167
+ display: inline-flex;
168
+ align-items: center;
169
+ justify-content: center;
170
+ width: 28px;
171
+ height: 28px;
172
+ border: 0;
173
+ padding: 0;
174
+ background: transparent;
175
+ border-radius: var(--sa-date-radius);
176
+ cursor: pointer;
177
+ color: var(--sa-date-brand);
178
+ transition: background-color 120ms ease;
179
+ }
180
+
181
+ .sa-calendar-nav-btn:hover {
182
+ background: var(--sa-date-brand-subtle);
183
+ }
184
+
185
+ .sa-calendar-nav-btn:active {
186
+ background: var(--sa-date-brand-secondary);
187
+ }
188
+
189
+ .sa-calendar-nav-btn:focus-visible {
190
+ outline: 2px solid var(--sa-date-brand);
191
+ outline-offset: 1px;
192
+ }
193
+
150
194
  .sa-calendar-days-name-preivew {
151
195
  display: flex;
152
196
  gap: var(--sa-spacing-sm, 8px);
@@ -191,8 +235,28 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
191
235
  }
192
236
 
193
237
  .sa-calendar-days-active {
194
- background: var(--sa-date-brand-secondary);
238
+ background: var(--sa-date-brand);
239
+ color: #fff;
240
+ }
241
+
242
+ .sa-calendar-days-today {
243
+ position: relative;
195
244
  color: var(--sa-date-brand);
245
+ font-weight: 700;
246
+ background: transparent;
247
+ }
248
+
249
+ .sa-calendar-days-today::before {
250
+ content: '';
251
+ position: absolute;
252
+ top: 50%;
253
+ left: 50%;
254
+ transform: translate(-50%, -50%);
255
+ width: 32px;
256
+ height: 32px;
257
+ background: var(--sa-date-brand-secondary);
258
+ border-radius: 50%;
259
+ z-index: -1;
196
260
  }
197
261
 
198
262
  /* MONTH STYLING */
@@ -270,13 +334,9 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
270
334
 
271
335
  .sa-calendar-input-outline {
272
336
  border-color: var(--sa-date-border-color);
273
- /* border-color: var(--sa-date-text-muted); */
274
337
  background-color: transparent;
275
338
  border-width: var(--sa-border, 1px);
276
339
  border-style: solid;
277
- /* height: var(--sa-h-10, 40px); */
278
- /* border-radius: var(--sa-date-radius); */
279
- /* padding-inline: var(--sa-spacing-3, 12px); */
280
340
  }
281
341
 
282
342
  .sa-calendar-input-container.sm {
@@ -298,6 +358,40 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
298
358
  padding-inline: var(--sa-spacing-3, 12px);
299
359
  }
300
360
 
361
+ /* filled variant — gray background, no visible border */
362
+ .sa-calendar-input-container.sa-calendar-input-filled {
363
+ background-color: var(--sa-date-accent-subtle, #f0f1f2);
364
+ border-color: transparent;
365
+ border-width: 1px;
366
+ border-style: solid;
367
+ }
368
+ .sa-calendar-input-container.sa-calendar-input-filled:has(input:focus) {
369
+ border-color: var(--sa-date-brand);
370
+ background-color: var(--sa-date-accent-subtle, #f0f1f2);
371
+ box-shadow: 0px 0px 0px 2px var(--sa-date-brand-subtle);
372
+ }
373
+
374
+ /* flushed variant — bottom border only */
375
+ .sa-calendar-input-container.sa-calendar-input-flushed {
376
+ background-color: transparent;
377
+ border-top: none;
378
+ border-left: none;
379
+ border-right: none;
380
+ border-bottom: 1px solid var(--sa-date-border-color);
381
+ border-radius: 0;
382
+ padding-inline: 0;
383
+ }
384
+ .sa-calendar-input-container.sa-calendar-input-flushed:has(input:focus) {
385
+ border-bottom-color: var(--sa-date-brand);
386
+ box-shadow: none;
387
+ }
388
+ .sa-calendar-input-container.sa-calendar-input-flushed.sa-calendar-input-container-error {
389
+ border-bottom-color: var(--sa-date-border-error) !important;
390
+ }
391
+ .sa-calendar-input-container.sa-calendar-input-flushed.sa-calendar-input-container-warning {
392
+ border-bottom-color: var(--sa-date-border-warning) !important;
393
+ }
394
+
301
395
  .sa-calendar-input-preview-container {
302
396
  width: 100%;
303
397
  position: relative;
@@ -358,7 +452,75 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
358
452
  outline: 2px solid var(--sa-date-brand);
359
453
  outline-offset: 1px;
360
454
  }
361
- `, ee = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
455
+
456
+ /* === CALENDAR PANEL SIZE VARIANTS === */
457
+ /* sa-calendar-size-md is the default — no override needed */
458
+
459
+ .sa-calendar.sa-calendar-size-sm {
460
+ padding: 16px 12px;
461
+ gap: 8px;
462
+ }
463
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-days-name-preivew {
464
+ gap: 4px;
465
+ }
466
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-days-name-preivew p {
467
+ font-size: var(--sa-font-size-sm, 12px);
468
+ }
469
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-days-number-preivew {
470
+ gap: 4px;
471
+ }
472
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-days-number-preivew p {
473
+ font-size: var(--sa-font-size-sm, 12px);
474
+ width: 28px;
475
+ height: 26px;
476
+ }
477
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-months-preview p,
478
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-years-preview p {
479
+ font-size: var(--sa-font-size-sm, 12px);
480
+ width: 76px;
481
+ height: 38px;
482
+ }
483
+
484
+ .sa-calendar.sa-calendar-size-lg {
485
+ padding: 28px 20px;
486
+ gap: 16px;
487
+ }
488
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-days-name-preivew {
489
+ gap: 10px;
490
+ }
491
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-days-name-preivew p {
492
+ font-size: 16px;
493
+ }
494
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-days-number-preivew {
495
+ gap: 10px;
496
+ }
497
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-days-number-preivew p {
498
+ font-size: 16px;
499
+ width: 40px;
500
+ height: 36px;
501
+ }
502
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-months-preview p,
503
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-years-preview p {
504
+ font-size: 16px;
505
+ width: 110px;
506
+ height: 54px;
507
+ }
508
+
509
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-header-title {
510
+ font-size: 13px;
511
+ }
512
+ .sa-calendar.sa-calendar-size-sm .sa-calendar-nav-btn {
513
+ width: 24px;
514
+ height: 24px;
515
+ }
516
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-header-title {
517
+ font-size: 16px;
518
+ }
519
+ .sa-calendar.sa-calendar-size-lg .sa-calendar-nav-btn {
520
+ width: 32px;
521
+ height: 32px;
522
+ }
523
+ `, en = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
362
524
  "January",
363
525
  "February",
364
526
  "March",
@@ -371,7 +533,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
371
533
  "October",
372
534
  "November",
373
535
  "December"
374
- ], se = [
536
+ ], on = [
375
537
  "Jan",
376
538
  "Feb",
377
539
  "Mar",
@@ -385,56 +547,56 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
385
547
  "Nov",
386
548
  "Dec"
387
549
  ];
388
- function ne(a) {
389
- const [n, t] = z(a), s = P(null), l = (h) => {
390
- s.current && !s.current.contains(h.target) && t(!1);
550
+ function an(r) {
551
+ const [e, t] = j(r), o = J(null), l = (u) => {
552
+ o.current && !o.current.contains(u.target) && t(!1);
391
553
  };
392
- return S(() => (document.addEventListener("click", l, !0), () => {
554
+ return I(() => (document.addEventListener("click", l, !0), () => {
393
555
  document.removeEventListener("click", l, !0);
394
- }), []), { ref: s, isComponentVisible: n, setIsComponentVisible: t };
556
+ }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: t };
395
557
  }
396
- const K = "sa-calendar-input-styles", oe = (a) => {
558
+ const K = "sa-calendar-input-styles", ln = (r) => {
397
559
  if (!document.getElementById(K)) {
398
- const n = document.createElement("style");
399
- n.id = K, n.textContent = a, document.head.appendChild(n);
560
+ const e = document.createElement("style");
561
+ e.id = K, e.textContent = r, document.head.appendChild(e);
400
562
  }
401
563
  };
402
- oe(J);
403
- const H = (a) => {
404
- if (a === "sm")
564
+ ln(R);
565
+ const H = (r) => {
566
+ if (r === "sm")
405
567
  return 16;
406
- if (a === "md")
568
+ if (r === "md")
407
569
  return 16;
408
- if (a === "lg")
570
+ if (r === "lg")
409
571
  return 20;
410
- }, le = (a) => {
572
+ }, dn = (r) => {
411
573
  const {
412
- size: n = "md",
574
+ size: e = "md",
413
575
  status: t = "default",
414
- variant: s = "outline",
576
+ variant: o = "outline",
415
577
  clearable: l,
416
- onClear: h,
417
- ...i
418
- } = a, g = P(null), f = () => {
419
- g.current && i.onClick && (g.current.focus(), i.onClick(""));
420
- }, e = t === "disable" || i.disabled, p = !!i.value, v = l && p && !e, x = (D) => {
421
- D.stopPropagation(), h == null || h();
578
+ onClear: u,
579
+ ...d
580
+ } = r, p = J(null), g = () => {
581
+ p.current && d.onClick && (p.current.focus(), d.onClick(""));
582
+ }, n = t === "disable" || d.disabled, c = !!d.value, v = l && c && !n, k = (D) => {
583
+ D.stopPropagation(), u == null || u();
422
584
  };
423
- return /* @__PURE__ */ F(
585
+ return /* @__PURE__ */ $(
424
586
  "div",
425
587
  {
426
- className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${n} `,
427
- onClick: f,
588
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
589
+ onClick: g,
428
590
  children: [
429
- /* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ r(
591
+ /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
430
592
  "svg",
431
593
  {
432
594
  xmlns: "http://www.w3.org/2000/svg",
433
- width: H(n),
434
- height: H(n),
595
+ width: H(e),
596
+ height: H(e),
435
597
  viewBox: "0 0 20 20",
436
598
  fill: "none",
437
- children: /* @__PURE__ */ r(
599
+ children: /* @__PURE__ */ a(
438
600
  "path",
439
601
  {
440
602
  d: "M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",
@@ -446,32 +608,32 @@ const H = (a) => {
446
608
  )
447
609
  }
448
610
  ) }),
449
- /* @__PURE__ */ r("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ r(
611
+ /* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
450
612
  "input",
451
613
  {
452
614
  className: "sa-calendar-input",
453
- ...i,
454
- disabled: e,
455
- value: i.value,
456
- ref: g
615
+ ...d,
616
+ disabled: n,
617
+ value: d.value,
618
+ ref: p
457
619
  }
458
620
  ) }),
459
- v ? /* @__PURE__ */ r(
621
+ v ? /* @__PURE__ */ a(
460
622
  "button",
461
623
  {
462
624
  type: "button",
463
625
  "aria-label": "Clear date",
464
626
  className: "sa-calendar-input-clear",
465
- onClick: x,
466
- children: /* @__PURE__ */ r(
627
+ onClick: k,
628
+ children: /* @__PURE__ */ a(
467
629
  "svg",
468
630
  {
469
631
  xmlns: "http://www.w3.org/2000/svg",
470
- width: H(n),
471
- height: H(n),
632
+ width: H(e),
633
+ height: H(e),
472
634
  viewBox: "0 0 20 20",
473
635
  fill: "none",
474
- children: /* @__PURE__ */ r(
636
+ children: /* @__PURE__ */ a(
475
637
  "path",
476
638
  {
477
639
  d: "M5 5L15 15M15 5L5 15",
@@ -484,15 +646,15 @@ const H = (a) => {
484
646
  }
485
647
  )
486
648
  }
487
- ) : /* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ r(
649
+ ) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
488
650
  "svg",
489
651
  {
490
652
  xmlns: "http://www.w3.org/2000/svg",
491
- width: H(n),
492
- height: H(n),
653
+ width: H(e),
654
+ height: H(e),
493
655
  viewBox: "0 0 20 20",
494
656
  fill: "none",
495
- children: /* @__PURE__ */ r(
657
+ children: /* @__PURE__ */ a(
496
658
  "path",
497
659
  {
498
660
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -507,81 +669,82 @@ const H = (a) => {
507
669
  ]
508
670
  }
509
671
  );
510
- }, ie = ({
511
- date: a,
512
- setDate: n,
672
+ }, cn = ({
673
+ date: r,
674
+ setDate: e,
513
675
  dateRange: t,
514
- setDateRange: s,
676
+ setDateRange: o,
515
677
  onChange: l,
516
- minDate: h,
517
- maxDate: i,
518
- input: g
678
+ minDate: u,
679
+ maxDate: d,
680
+ input: p
519
681
  }) => {
520
- var Y, u, y;
521
- const [f, e] = z(null);
522
- let p = new Date(a.getFullYear(), a.getMonth(), 1), v = p.getDay(), x = [];
523
- const D = a.getMonth(), m = !!(t.from && !t.to), o = m && f ? f : null;
524
- for (let d = 0; d < 42; d++) {
525
- d === 0 && v === 0 ? p.setDate(p.getDate() - 7) : d === 0 ? p.setDate(
526
- p.getDate() + (d - v)
527
- ) : p.setDate(p.getDate() + 1);
682
+ var h, m, F;
683
+ const [g, n] = j(null);
684
+ let c = new Date(r.getFullYear(), r.getMonth(), 1), v = c.getDay(), k = [];
685
+ const D = r.getMonth(), b = (/* @__PURE__ */ new Date()).toDateString(), f = !!(t.from && !t.to), s = f && g ? g : null;
686
+ for (let i = 0; i < 42; i++) {
687
+ i === 0 && v === 0 ? c.setDate(c.getDate() - 7) : i === 0 ? c.setDate(
688
+ c.getDate() + (i - v)
689
+ ) : c.setDate(c.getDate() + 1);
528
690
  let w = {
529
- currentMonth: p.getMonth() === D,
530
- date: new Date(p),
531
- month: p.getMonth(),
532
- number: p.getDate(),
533
- selected: p.toDateString() === ((Y = t.from) == null ? void 0 : Y.toDateString()) || p.toDateString() === (((u = t.to) == null ? void 0 : u.toDateString()) || ((y = t.from) == null ? void 0 : y.toDateString())),
534
- year: p.getFullYear(),
535
- isDisabled: h && p < h || i && p > i
691
+ currentMonth: c.getMonth() === D,
692
+ date: new Date(c),
693
+ month: c.getMonth(),
694
+ number: c.getDate(),
695
+ selected: c.toDateString() === ((h = t.from) == null ? void 0 : h.toDateString()) || c.toDateString() === (((m = t.to) == null ? void 0 : m.toDateString()) || ((F = t.from) == null ? void 0 : F.toDateString())),
696
+ isToday: c.toDateString() === b,
697
+ year: c.getFullYear(),
698
+ isDisabled: u && c < u || d && c > d
536
699
  };
537
- x.push(w);
700
+ k.push(w);
538
701
  }
539
- const c = (d) => {
540
- n(d);
541
- }, k = (d) => {
542
- var N;
702
+ const x = (i) => {
703
+ e(i);
704
+ }, N = (i) => {
705
+ var L;
543
706
  let w = { ...t };
544
707
  if (w.from && w.to)
545
- w = { from: d, to: null };
708
+ w = { from: i, to: null };
546
709
  else {
547
- const M = ((N = w.from) == null ? void 0 : N.getTime()) || 0;
548
- d.getTime() > M ? w = { from: w.from, to: d } : w = { from: d, to: w.from };
710
+ const M = ((L = w.from) == null ? void 0 : L.getTime()) || 0;
711
+ i.getTime() > M ? w = { from: w.from, to: i } : w = { from: i, to: w.from };
549
712
  }
550
- s(w), l(w);
713
+ o(w), l(w);
551
714
  };
552
- return /* @__PURE__ */ F(
715
+ return /* @__PURE__ */ $(
553
716
  "div",
554
717
  {
555
718
  className: "sa-calendar-days-preivew",
556
- onMouseLeave: () => e(null),
719
+ onMouseLeave: () => n(null),
557
720
  children: [
558
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((d, w) => /* @__PURE__ */ r("p", { children: d }, w)) }),
559
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: x.map((d, w) => {
560
- const N = t.from && t.to && d.date.getTime() > t.from.getTime() && d.date.getTime() < t.to.getTime(), M = (() => {
561
- if (!o || !t.from)
721
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((i, w) => /* @__PURE__ */ a("p", { children: i }, w)) }),
722
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: k.map((i, w) => {
723
+ const L = t.from && t.to && i.date.getTime() > t.from.getTime() && i.date.getTime() < t.to.getTime(), M = (() => {
724
+ if (!s || !t.from)
562
725
  return !1;
563
- const C = d.date.getTime(), L = t.from.getTime(), j = o.getTime();
564
- return j > L ? C > L && C < j : C < L && C > j;
565
- })(), T = m && f && d.date.toDateString() === f.toDateString(), $ = d.isDisabled, E = () => N || M ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", I = () => $ ? "var(--sa-color-gray-400, #b7b9be)" : N || M ? "var(--sa-color-gray-500, #8c8f97)" : "";
566
- return /* @__PURE__ */ r(
726
+ const C = i.date.getTime(), z = t.from.getTime(), A = s.getTime();
727
+ return A > z ? C > z && C < A : C < z && C > A;
728
+ })(), T = f && g && i.date.toDateString() === g.toDateString(), Y = i.isDisabled, E = () => L || M ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", S = () => Y ? "var(--sa-color-gray-400, #b7b9be)" : L || M ? "var(--sa-color-gray-500, #8c8f97)" : "";
729
+ return /* @__PURE__ */ a(
567
730
  "p",
568
731
  {
569
- className: `${d.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${d.selected || T ? "sa-calendar-days-active" : ""}`,
732
+ className: `${i.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${i.selected || T ? "sa-calendar-days-active" : ""} ${i.isToday && !i.selected ? "sa-calendar-days-today" : ""}`,
570
733
  style: {
571
734
  backgroundColor: E(),
572
- pointerEvents: $ ? "none" : void 0,
573
- cursor: $ ? "not-allowed" : "pointer",
574
- color: I(),
575
- opacity: T && !d.selected ? 0.75 : 1,
576
- ...g ? {} : { width: "100%" }
735
+ pointerEvents: Y ? "none" : void 0,
736
+ cursor: Y ? "not-allowed" : "pointer",
737
+ color: S(),
738
+ opacity: T && !i.selected ? 0.75 : 1,
739
+ ...p ? {} : { width: "100%" }
577
740
  },
578
741
  onClick: () => {
579
- $ || (c(d.date), k(d.date));
742
+ Y || (x(i.date), N(i.date));
580
743
  },
581
744
  onMouseEnter: () => {
582
- $ || e(d.date);
745
+ Y || n(i.date);
583
746
  },
584
- children: d.number
747
+ children: i.number
585
748
  },
586
749
  w
587
750
  );
@@ -589,112 +752,112 @@ const H = (a) => {
589
752
  ]
590
753
  }
591
754
  );
592
- }, de = ({
593
- date: a,
594
- setDate: n,
755
+ }, un = ({
756
+ date: r,
757
+ setDate: e,
595
758
  filter: t,
596
- setViews: s,
759
+ setViews: o,
597
760
  dateRange: l,
598
- setDateRange: h,
599
- onChange: i,
600
- minDate: g,
601
- maxDate: f,
602
- input: e
761
+ setDateRange: u,
762
+ onChange: d,
763
+ minDate: p,
764
+ maxDate: g,
765
+ input: n
603
766
  }) => {
604
- const p = l.from.getFullYear(), v = a.getFullYear(), x = (m) => {
605
- t ? (D(m), n(m)) : (s("days"), n(m));
606
- }, D = (m) => {
607
- var c;
608
- let o = { ...l };
609
- if (o.from && o.to)
610
- o = { from: m, to: null };
767
+ const c = l.from.getFullYear(), v = r.getFullYear(), k = (b) => {
768
+ t ? (D(b), e(b)) : (o("days"), e(b));
769
+ }, D = (b) => {
770
+ var s;
771
+ let f = { ...l };
772
+ if (f.from && f.to)
773
+ f = { from: b, to: null };
611
774
  else {
612
- const k = ((c = o.from) == null ? void 0 : c.getTime()) || 0;
613
- m.getTime() > k ? o = { from: o.from, to: m } : o = { from: m, to: o.from };
775
+ const x = ((s = f.from) == null ? void 0 : s.getTime()) || 0;
776
+ b.getTime() > x ? f = { from: f.from, to: b } : f = { from: b, to: f.from };
614
777
  }
615
- h(o), i(o);
778
+ u(f), d(f);
616
779
  };
617
- return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: W.map((m, o) => {
618
- var Y, u, y;
619
- const c = new Date(v, o).getTime() > l.from.getTime() && new Date(v, o).getTime() < (((Y = l.to) == null ? void 0 : Y.getTime()) || l.from.getTime()), k = g && new Date(v, o) < g || f && new Date(v, o) > f;
620
- return /* @__PURE__ */ r(
780
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((b, f) => {
781
+ var N, h, m;
782
+ const s = new Date(v, f).getTime() > l.from.getTime() && new Date(v, f).getTime() < (((N = l.to) == null ? void 0 : N.getTime()) || l.from.getTime()), x = p && new Date(v, f) < p || g && new Date(v, f) > g;
783
+ return /* @__PURE__ */ a(
621
784
  "p",
622
785
  {
623
- className: p === v && (o === ((u = l.from) == null ? void 0 : u.getMonth()) || o === ((y = l.to) == null ? void 0 : y.getMonth())) ? "sa-calendar-months-active" : "",
786
+ className: c === v && (f === ((h = l.from) == null ? void 0 : h.getMonth()) || f === ((m = l.to) == null ? void 0 : m.getMonth())) ? "sa-calendar-months-active" : "",
624
787
  style: {
625
- backgroundColor: c ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
626
- pointerEvents: k ? "none" : void 0,
627
- cursor: k ? "not-allowed" : "pointer",
628
- color: k ? "var(--sa-color-gray-400, #b7b9be)" : c ? "var(--sa-color-gray-500, #8c8f97)" : "",
629
- ...e ? {} : { width: "100%" }
788
+ backgroundColor: s ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
789
+ pointerEvents: x ? "none" : void 0,
790
+ cursor: x ? "not-allowed" : "pointer",
791
+ color: x ? "var(--sa-color-gray-400, #b7b9be)" : s ? "var(--sa-color-gray-500, #8c8f97)" : "",
792
+ ...n ? {} : { width: "100%" }
630
793
  },
631
794
  onClick: () => {
632
- k || x(new Date(v, o));
795
+ x || k(new Date(v, f));
633
796
  },
634
- children: m.slice(0, 3)
797
+ children: b.slice(0, 3)
635
798
  },
636
- o
799
+ f
637
800
  );
638
801
  }) });
639
- }, U = (a) => {
640
- const n = Math.floor(a / 10) * 10, t = n + 10;
641
- return { start: n, end: t };
642
- }, ce = ({
643
- date: a,
644
- filter: n,
802
+ }, q = (r) => {
803
+ const e = Math.floor(r / 10) * 10, t = e + 10;
804
+ return { start: e, end: t };
805
+ }, hn = ({
806
+ date: r,
807
+ filter: e,
645
808
  setViews: t,
646
- setDate: s,
809
+ setDate: o,
647
810
  dateRange: l,
648
- setDateRange: h,
649
- onChange: i,
650
- minDate: g,
651
- maxDate: f,
652
- input: e
811
+ setDateRange: u,
812
+ onChange: d,
813
+ minDate: p,
814
+ maxDate: g,
815
+ input: n
653
816
  }) => {
654
- var Y;
655
- let p = [];
656
- const v = a.getFullYear(), { start: x, end: D } = U(v), m = l.from.getFullYear(), o = (Y = l.to) == null ? void 0 : Y.getFullYear();
657
- for (let u = x; u < D; u++) {
658
- const y = new Date(u, 0), d = (!g || y >= g) && (!f || y <= f), w = u === m || u === o, N = y > l.from && y < l.to;
659
- p.push({
660
- year: u,
661
- active: w && d,
662
- highlight: N && d,
663
- disabled: !d
817
+ var N;
818
+ let c = [];
819
+ const v = r.getFullYear(), { start: k, end: D } = q(v), b = l.from.getFullYear(), f = (N = l.to) == null ? void 0 : N.getFullYear();
820
+ for (let h = k; h < D; h++) {
821
+ const m = new Date(h, 0), F = (!p || m >= p) && (!g || m <= g), i = h === b || h === f, w = m > l.from && m < l.to;
822
+ c.push({
823
+ year: h,
824
+ active: i && F,
825
+ highlight: w && F,
826
+ disabled: !F
664
827
  });
665
828
  }
666
- const c = (u) => {
667
- n ? (k(u), s(u)) : (s(u), t("months"));
668
- }, k = (u) => {
669
- var d;
670
- let y = { ...l };
671
- if (y.from && y.to)
672
- y = { from: u, to: null };
829
+ const s = (h) => {
830
+ e ? (x(h), o(h)) : (o(h), t("months"));
831
+ }, x = (h) => {
832
+ var F;
833
+ let m = { ...l };
834
+ if (m.from && m.to)
835
+ m = { from: h, to: null };
673
836
  else {
674
- const w = ((d = y.from) == null ? void 0 : d.getTime()) || 0;
675
- u.getTime() > w ? y = { from: y.from, to: u } : y = { from: u, to: y.from };
837
+ const i = ((F = m.from) == null ? void 0 : F.getTime()) || 0;
838
+ h.getTime() > i ? m = { from: m.from, to: h } : m = { from: h, to: m.from };
676
839
  }
677
- h(y), i(y);
840
+ u(m), d(m);
678
841
  };
679
- return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: p.map((u, y) => /* @__PURE__ */ r(
842
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((h, m) => /* @__PURE__ */ a(
680
843
  "p",
681
844
  {
682
- className: `${u.active ? "sa-calendar-months-active" : ""} ${u.highlight ? "sa-calendar-months-highlight" : ""} ${u.disabled ? "sa-calendar-disabled" : ""}`,
845
+ className: `${h.active ? "sa-calendar-months-active" : ""} ${h.highlight ? "sa-calendar-months-highlight" : ""} ${h.disabled ? "sa-calendar-disabled" : ""}`,
683
846
  onClick: () => {
684
- u.disabled || c(new Date(u.year, 0));
847
+ h.disabled || s(new Date(h.year, 0));
685
848
  },
686
849
  style: {
687
- backgroundColor: u.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
688
- color: u.highlight ? "var(--sa-color-gray-500, #8c8f97)" : u.active ? "" : u.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
689
- cursor: u.disabled ? "not-allowed" : "pointer",
690
- pointerEvents: u.disbled ? "none" : "all",
691
- ...e ? {} : { width: "100%" }
850
+ backgroundColor: h.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
851
+ color: h.highlight ? "var(--sa-color-gray-500, #8c8f97)" : h.active ? "" : h.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
852
+ cursor: h.disabled ? "not-allowed" : "pointer",
853
+ pointerEvents: h.disbled ? "none" : "all",
854
+ ...n ? {} : { width: "100%" }
692
855
  },
693
- children: u.year
856
+ children: h.year
694
857
  },
695
- y
858
+ m
696
859
  )) });
697
- }, ae = ({ ...a }) => /* @__PURE__ */ r(
860
+ }, rn = ({ ...r }) => /* @__PURE__ */ a(
698
861
  "svg",
699
862
  {
700
863
  xmlns: "http://www.w3.org/2000/svg",
@@ -702,8 +865,8 @@ const H = (a) => {
702
865
  height: "20",
703
866
  viewBox: "0 0 20 20",
704
867
  fill: "none",
705
- ...a,
706
- children: /* @__PURE__ */ r(
868
+ ...r,
869
+ children: /* @__PURE__ */ a(
707
870
  "path",
708
871
  {
709
872
  d: "M12.5 3.33334L5.83337 10L12.5 16.6667",
@@ -714,7 +877,7 @@ const H = (a) => {
714
877
  }
715
878
  )
716
879
  }
717
- ), re = ({ ...a }) => /* @__PURE__ */ r(
880
+ ), tn = ({ ...r }) => /* @__PURE__ */ a(
718
881
  "svg",
719
882
  {
720
883
  xmlns: "http://www.w3.org/2000/svg",
@@ -722,8 +885,8 @@ const H = (a) => {
722
885
  height: "20",
723
886
  viewBox: "0 0 20 20",
724
887
  fill: "none",
725
- ...a,
726
- children: /* @__PURE__ */ r(
888
+ ...r,
889
+ children: /* @__PURE__ */ a(
727
890
  "path",
728
891
  {
729
892
  d: "M7.5 16.6667L14.1667 10L7.5 3.33334",
@@ -734,254 +897,258 @@ const H = (a) => {
734
897
  }
735
898
  )
736
899
  }
737
- ), ue = ({
738
- setViews: a,
739
- views: n,
900
+ ), pn = ({
901
+ setViews: r,
902
+ views: e,
740
903
  filter: t,
741
- date: s,
904
+ date: o,
742
905
  setDate: l
743
906
  }) => {
744
- const h = () => {
745
- t || a((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
746
- }, i = () => {
747
- if (n === "years") {
748
- l((e) => new Date(e.getFullYear() + 10, 0));
907
+ const u = () => {
908
+ t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
909
+ }, d = () => {
910
+ if (e === "years") {
911
+ l((n) => new Date(n.getFullYear() + 10, 0));
749
912
  return;
750
913
  }
751
- if (n === "months") {
752
- l((e) => new Date(e.getFullYear() + 1, e.getMonth()));
914
+ if (e === "months") {
915
+ l((n) => new Date(n.getFullYear() + 1, n.getMonth()));
753
916
  return;
754
917
  }
755
- l((e) => new Date(e.getFullYear(), e.getMonth() + 1));
756
- }, g = () => {
757
- if (n === "years") {
758
- l((e) => new Date(e.getFullYear() - 10, 0));
918
+ l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
919
+ }, p = () => {
920
+ if (e === "years") {
921
+ l((n) => new Date(n.getFullYear() - 10, 0));
759
922
  return;
760
923
  }
761
- if (n === "months") {
762
- l((e) => new Date(e.getFullYear() - 1, e.getMonth()));
924
+ if (e === "months") {
925
+ l((n) => new Date(n.getFullYear() - 1, n.getMonth()));
763
926
  return;
764
927
  }
765
928
  l(
766
- (e) => new Date(
767
- e.getMonth() === 0 ? e.getFullYear() - 1 : e.getFullYear(),
768
- e.getMonth() === 0 ? 11 : e.getMonth() - 1
929
+ (n) => new Date(
930
+ n.getMonth() === 0 ? n.getFullYear() - 1 : n.getFullYear(),
931
+ n.getMonth() === 0 ? 11 : n.getMonth() - 1
769
932
  )
770
933
  );
771
934
  };
772
- return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
773
- /* @__PURE__ */ r(ae, { onClick: () => g() }),
774
- /* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: h, children: (() => {
775
- if (n === "days")
776
- return `${W[s.getMonth()]} ${s.getFullYear()}`;
777
- if (n === "months")
778
- return `${s.getFullYear()}`;
779
- if (n === "years")
780
- return `${U(s.getFullYear()).start} ~ ${U(s.getFullYear()).end}`;
935
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
936
+ /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
937
+ if (e === "days")
938
+ return `${W[o.getMonth()]} ${o.getFullYear()}`;
939
+ if (e === "months")
940
+ return `${o.getFullYear()}`;
941
+ if (e === "years")
942
+ return `${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`;
781
943
  })() }),
782
- /* @__PURE__ */ r(re, { onClick: () => i() })
944
+ /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
945
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ a(rn, {}) }),
946
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
947
+ ] })
783
948
  ] });
784
949
  };
785
- function A(a) {
786
- const n = new Date(a), t = n.getFullYear(), s = n.getMonth();
787
- return `${n.getDate().toString().padStart(2, "0")} ${se[s]} ${t}`;
950
+ function P(r) {
951
+ const e = new Date(r), t = e.getFullYear(), o = e.getMonth();
952
+ return `${e.getDate().toString().padStart(2, "0")} ${on[o]} ${t}`;
788
953
  }
789
- const te = ({
790
- label: a,
791
- labelPosition: n = "outside-top",
954
+ const sn = ({
955
+ label: r,
956
+ labelPosition: e = "outside-top",
792
957
  required: t,
793
- optional: s,
958
+ optional: o,
794
959
  description: l,
795
- helperText: h,
796
- errorText: i,
797
- fullWidth: g,
798
- children: f
960
+ helperText: u,
961
+ errorText: d,
962
+ fullWidth: p,
963
+ children: g
799
964
  }) => {
800
- const e = [
965
+ const n = [
801
966
  "sa-date-field",
802
- g ? "sa-date-field-fullwidth" : ""
803
- ].filter(Boolean).join(" "), p = a ? /* @__PURE__ */ F("div", { className: "sa-date-field-label-row", children: [
804
- /* @__PURE__ */ r("span", { className: "sa-date-field-label-text", children: a }),
805
- s && /* @__PURE__ */ r("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
806
- t && /* @__PURE__ */ r("span", { className: "sa-date-field-required", children: "*" })
807
- ] }) : null, v = /* @__PURE__ */ F(_, { children: [
808
- h && !i && /* @__PURE__ */ r("p", { className: "sa-date-field-helper", children: h }),
809
- i && /* @__PURE__ */ r("p", { className: "sa-date-field-error-msg", children: i })
967
+ p ? "sa-date-field-fullwidth" : ""
968
+ ].filter(Boolean).join(" "), c = r ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
969
+ /* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: r }),
970
+ o && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
971
+ t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
972
+ ] }) : null, v = /* @__PURE__ */ $(nn, { children: [
973
+ u && !d && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: u }),
974
+ d && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: d })
810
975
  ] });
811
- return a ? n === "outside-left" ? /* @__PURE__ */ F("div", { className: `${e} sa-date-field-left`, children: [
812
- /* @__PURE__ */ F("div", { className: "sa-date-field-left-label", children: [
813
- p,
814
- l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l })
976
+ return r ? e === "outside-left" ? /* @__PURE__ */ $("div", { className: `${n} sa-date-field-left`, children: [
977
+ /* @__PURE__ */ $("div", { className: "sa-date-field-left-label", children: [
978
+ c,
979
+ l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l })
815
980
  ] }),
816
- /* @__PURE__ */ F("div", { className: "sa-date-field-input-wrap", children: [
817
- f,
981
+ /* @__PURE__ */ $("div", { className: "sa-date-field-input-wrap", children: [
982
+ g,
818
983
  v
819
984
  ] })
820
- ] }) : /* @__PURE__ */ F("div", { className: e, children: [
821
- p,
822
- l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
823
- f,
985
+ ] }) : /* @__PURE__ */ $("div", { className: n, children: [
986
+ c,
987
+ l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
988
+ g,
824
989
  v
825
- ] }) : /* @__PURE__ */ F("div", { className: e, children: [
826
- l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
827
- f,
990
+ ] }) : /* @__PURE__ */ $("div", { className: n, children: [
991
+ l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
992
+ g,
828
993
  v
829
994
  ] });
830
- }, Q = "sa-calendar-styles", he = (a) => {
995
+ }, Q = "sa-calendar-styles", gn = (r) => {
831
996
  if (!document.getElementById(Q)) {
832
- const n = document.createElement("style");
833
- n.id = Q, n.textContent = a, document.head.appendChild(n);
997
+ const e = document.createElement("style");
998
+ e.id = Q, e.textContent = r, document.head.appendChild(e);
834
999
  }
835
1000
  };
836
- he(J);
837
- const pe = G(
1001
+ gn(R);
1002
+ const fn = Z(
838
1003
  ({
839
- value: a,
840
- onChange: n,
1004
+ value: r,
1005
+ onChange: e,
841
1006
  filter: t,
842
- input: s = !0,
1007
+ input: o = !0,
843
1008
  disabled: l,
844
- minDate: h,
845
- maxDate: i,
846
- placeholder: g,
847
- size: f,
848
- status: e,
849
- clearable: p,
850
- fullWidth: v = !0,
851
- label: x,
852
- labelPosition: D,
853
- required: m,
854
- optional: o,
855
- description: c,
856
- helperText: k,
857
- errorText: Y
858
- }, u) => {
859
- const y = Y ? "error" : e, { ref: d, isComponentVisible: w, setIsComponentVisible: N } = ne(!1), M = P(null), [T, $] = z("days"), [E, I] = z(/* @__PURE__ */ new Date()), [C, L] = z({
860
- from: (a == null ? void 0 : a.from) || /* @__PURE__ */ new Date(),
861
- to: (a == null ? void 0 : a.to) || /* @__PURE__ */ new Date()
1009
+ minDate: u,
1010
+ maxDate: d,
1011
+ placeholder: p,
1012
+ size: g,
1013
+ variant: n,
1014
+ status: c,
1015
+ clearable: v,
1016
+ fullWidth: k = !0,
1017
+ label: D,
1018
+ labelPosition: b,
1019
+ required: f,
1020
+ optional: s,
1021
+ description: x,
1022
+ helperText: N,
1023
+ errorText: h
1024
+ }, m) => {
1025
+ const F = h ? "error" : c, { ref: i, isComponentVisible: w, setIsComponentVisible: L } = an(!1), M = J(null), [T, Y] = j("days"), [E, S] = j(/* @__PURE__ */ new Date()), [C, z] = j({
1026
+ from: (r == null ? void 0 : r.from) || /* @__PURE__ */ new Date(),
1027
+ to: (r == null ? void 0 : r.to) || /* @__PURE__ */ new Date()
862
1028
  });
863
- S(() => {
864
- a ? (I(a.from), L(a)) : (I(/* @__PURE__ */ new Date()), L({
1029
+ I(() => {
1030
+ r ? (S(r.from), z(r)) : (S(/* @__PURE__ */ new Date()), z({
865
1031
  from: /* @__PURE__ */ new Date(),
866
1032
  to: /* @__PURE__ */ new Date()
867
1033
  }));
868
- }, [a]), S(() => {
869
- t && $(t);
870
- }, [t]), S(() => {
871
- t || $("days");
872
- }, [w]), S(() => {
873
- s || N(!0);
874
- }, [s]);
875
- const j = () => {
876
- var b, B;
877
- if (!a)
1034
+ }, [r]), I(() => {
1035
+ t && Y(t);
1036
+ }, [t]), I(() => {
1037
+ t || Y("days");
1038
+ }, [w]), I(() => {
1039
+ o || L(!0);
1040
+ }, [o]);
1041
+ const A = () => {
1042
+ var y, B;
1043
+ if (!r)
878
1044
  return "";
879
1045
  if (t) {
880
1046
  if (T === "days")
881
- return `${A(C.from)} ~ ${A(C.to || C.from) || "-"}`;
1047
+ return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
882
1048
  if (T === "months")
883
1049
  return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
884
1050
  if (T === "years")
885
- return `${(b = C.from) == null ? void 0 : b.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
1051
+ return `${(y = C.from) == null ? void 0 : y.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
886
1052
  } else
887
- return `${A(C.from)} ~ ${A(C.to || C.from) || "-"}`;
1053
+ return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
888
1054
  }, V = () => {
889
- if (M.current && d.current && s) {
890
- const b = d.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
891
- window.innerWidth < b.left + B.width ? M.current.style.left = `${b.left - B.width + b.width}px` : M.current.style.left = `${b.left}px`, b.top + B.height > window.innerHeight ? M.current.style.top = `${b.y - (b.height + B.height - 28)}px` : M.current.style.top = `${b.y + b.height}px`;
1055
+ if (M.current && i.current && o) {
1056
+ const y = i.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1057
+ window.innerWidth < y.left + B.width ? M.current.style.left = `${y.left - B.width + y.width}px` : M.current.style.left = `${y.left}px`, y.top + B.height > window.innerHeight ? M.current.style.top = `${y.y - (y.height + B.height - 28)}px` : M.current.style.top = `${y.y + y.height}px`;
892
1058
  }
893
1059
  };
894
- S(() => {
895
- M.current && d.current && s && V();
896
- }, [M, d, w]), S(() => {
897
- const b = u == null ? void 0 : u.current;
898
- return b && b.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
899
- b && b.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1060
+ I(() => {
1061
+ M.current && i.current && o && V();
1062
+ }, [M, i, w]), I(() => {
1063
+ const y = m == null ? void 0 : m.current;
1064
+ return y && y.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1065
+ y && y.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
900
1066
  };
901
1067
  }, []);
902
- const R = /* @__PURE__ */ F(
1068
+ const U = /* @__PURE__ */ $(
903
1069
  "div",
904
1070
  {
905
1071
  className: "sa-calendar-wrapper",
906
- style: { height: s ? "auto" : "100%" },
907
- ref: s ? d : null,
1072
+ style: { height: o ? "auto" : "100%" },
1073
+ ref: o ? i : null,
908
1074
  children: [
909
- s ? /* @__PURE__ */ r(
910
- le,
1075
+ o ? /* @__PURE__ */ a(
1076
+ dn,
911
1077
  {
912
- value: j(),
1078
+ value: A(),
913
1079
  inputMode: "none",
914
1080
  onClick: () => {
915
- N(!0);
1081
+ L(!0);
916
1082
  },
917
1083
  onChange: () => {
918
1084
  },
919
1085
  disabled: l,
920
- placeholder: g,
921
- size: f,
922
- status: y,
923
- clearable: p,
924
- onClear: () => n(void 0)
1086
+ placeholder: p,
1087
+ size: g,
1088
+ variant: n,
1089
+ status: F,
1090
+ clearable: v,
1091
+ onClear: () => e(void 0)
925
1092
  }
926
1093
  ) : null,
927
- w ? /* @__PURE__ */ F(
1094
+ w ? /* @__PURE__ */ $(
928
1095
  "div",
929
1096
  {
930
- className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
1097
+ className: `sa-calendar sa-calendar-size-${g || "md"} ${o ? "" : "sa-calendar-no-input"}`,
931
1098
  ref: M,
932
1099
  children: [
933
- /* @__PURE__ */ r(
934
- ue,
1100
+ /* @__PURE__ */ a(
1101
+ pn,
935
1102
  {
936
- setViews: $,
1103
+ setViews: Y,
937
1104
  views: T,
938
1105
  filter: t,
939
1106
  date: E,
940
- setDate: I
1107
+ setDate: S
941
1108
  }
942
1109
  ),
943
- /* @__PURE__ */ r("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ r(
944
- ie,
1110
+ /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ a(
1111
+ cn,
945
1112
  {
946
1113
  date: E,
947
- setDate: I,
948
- setIsComponentVisible: N,
1114
+ setDate: S,
1115
+ setIsComponentVisible: L,
949
1116
  dateRange: C,
950
- setDateRange: L,
951
- input: s,
952
- onChange: n,
953
- minDate: h,
954
- maxDate: i
1117
+ setDateRange: z,
1118
+ input: o,
1119
+ onChange: e,
1120
+ minDate: u,
1121
+ maxDate: d
955
1122
  }
956
- ) : T === "months" ? /* @__PURE__ */ r(
957
- de,
1123
+ ) : T === "months" ? /* @__PURE__ */ a(
1124
+ un,
958
1125
  {
959
1126
  date: E,
960
- setDate: I,
1127
+ setDate: S,
961
1128
  filter: t,
962
- setViews: $,
1129
+ setViews: Y,
963
1130
  dateRange: C,
964
- setDateRange: L,
965
- setIsComponentVisible: N,
966
- input: s,
967
- onChange: n,
968
- minDate: h,
969
- maxDate: i
1131
+ setDateRange: z,
1132
+ setIsComponentVisible: L,
1133
+ input: o,
1134
+ onChange: e,
1135
+ minDate: u,
1136
+ maxDate: d
970
1137
  }
971
- ) : /* @__PURE__ */ r(
972
- ce,
1138
+ ) : /* @__PURE__ */ a(
1139
+ hn,
973
1140
  {
974
1141
  date: E,
975
- setDate: I,
1142
+ setDate: S,
976
1143
  filter: t,
977
- setViews: $,
1144
+ setViews: Y,
978
1145
  dateRange: C,
979
- setDateRange: L,
980
- setIsComponentVisible: N,
981
- input: s,
982
- onChange: n,
983
- minDate: h,
984
- maxDate: i
1146
+ setDateRange: z,
1147
+ setIsComponentVisible: L,
1148
+ input: o,
1149
+ onChange: e,
1150
+ minDate: u,
1151
+ maxDate: d
985
1152
  }
986
1153
  ) })
987
1154
  ]
@@ -990,63 +1157,63 @@ const pe = G(
990
1157
  ]
991
1158
  }
992
1159
  );
993
- return /* @__PURE__ */ r(
994
- te,
1160
+ return /* @__PURE__ */ a(
1161
+ sn,
995
1162
  {
996
- label: x,
997
- labelPosition: D,
998
- required: m,
999
- optional: o,
1000
- description: c,
1001
- helperText: k,
1002
- errorText: Y,
1003
- fullWidth: v,
1004
- children: R
1163
+ label: D,
1164
+ labelPosition: b,
1165
+ required: f,
1166
+ optional: s,
1167
+ description: x,
1168
+ helperText: N,
1169
+ errorText: h,
1170
+ fullWidth: k,
1171
+ children: U
1005
1172
  }
1006
1173
  );
1007
1174
  }
1008
- ), X = "sa-calendar-input-styles", ge = (a) => {
1175
+ ), X = "sa-calendar-input-styles", bn = (r) => {
1009
1176
  if (!document.getElementById(X)) {
1010
- const n = document.createElement("style");
1011
- n.id = X, n.textContent = a, document.head.appendChild(n);
1177
+ const e = document.createElement("style");
1178
+ e.id = X, e.textContent = r, document.head.appendChild(e);
1012
1179
  }
1013
1180
  };
1014
- ge(J);
1015
- const O = (a) => {
1016
- if (a === "sm")
1181
+ bn(R);
1182
+ const O = (r) => {
1183
+ if (r === "sm")
1017
1184
  return 16;
1018
- if (a === "md")
1185
+ if (r === "md")
1019
1186
  return 16;
1020
- if (a === "lg")
1187
+ if (r === "lg")
1021
1188
  return 20;
1022
- }, fe = (a) => {
1189
+ }, mn = (r) => {
1023
1190
  const {
1024
- size: n = "md",
1191
+ size: e = "md",
1025
1192
  status: t = "default",
1026
- variant: s = "outline",
1193
+ variant: o = "outline",
1027
1194
  clearable: l,
1028
- onClear: h,
1029
- ...i
1030
- } = a, g = P(null), f = () => {
1031
- g.current && i.onClick && (g.current.focus(), i.onClick(""));
1032
- }, e = t === "disable" || i.disabled, p = !!i.value, v = l && p && !e, x = (D) => {
1033
- D.stopPropagation(), h == null || h();
1195
+ onClear: u,
1196
+ ...d
1197
+ } = r, p = J(null), g = () => {
1198
+ p.current && d.onClick && (p.current.focus(), d.onClick(""));
1199
+ }, n = t === "disable" || d.disabled, c = !!d.value, v = l && c && !n, k = (D) => {
1200
+ D.stopPropagation(), u == null || u();
1034
1201
  };
1035
- return /* @__PURE__ */ F(
1202
+ return /* @__PURE__ */ $(
1036
1203
  "div",
1037
1204
  {
1038
- className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${n} `,
1039
- onClick: f,
1205
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
1206
+ onClick: g,
1040
1207
  children: [
1041
- /* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ r(
1208
+ /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
1042
1209
  "svg",
1043
1210
  {
1044
1211
  xmlns: "http://www.w3.org/2000/svg",
1045
- width: O(n),
1046
- height: O(n),
1212
+ width: O(e),
1213
+ height: O(e),
1047
1214
  viewBox: "0 0 20 20",
1048
1215
  fill: "none",
1049
- children: /* @__PURE__ */ r(
1216
+ children: /* @__PURE__ */ a(
1050
1217
  "path",
1051
1218
  {
1052
1219
  d: "M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",
@@ -1058,32 +1225,32 @@ const O = (a) => {
1058
1225
  )
1059
1226
  }
1060
1227
  ) }),
1061
- /* @__PURE__ */ r("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ r(
1228
+ /* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
1062
1229
  "input",
1063
1230
  {
1064
1231
  className: "sa-calendar-input",
1065
- ...i,
1066
- disabled: e,
1067
- value: i.value,
1068
- ref: g
1232
+ ...d,
1233
+ disabled: n,
1234
+ value: d.value,
1235
+ ref: p
1069
1236
  }
1070
1237
  ) }),
1071
- v ? /* @__PURE__ */ r(
1238
+ v ? /* @__PURE__ */ a(
1072
1239
  "button",
1073
1240
  {
1074
1241
  type: "button",
1075
1242
  "aria-label": "Clear date",
1076
1243
  className: "sa-calendar-input-clear",
1077
- onClick: x,
1078
- children: /* @__PURE__ */ r(
1244
+ onClick: k,
1245
+ children: /* @__PURE__ */ a(
1079
1246
  "svg",
1080
1247
  {
1081
1248
  xmlns: "http://www.w3.org/2000/svg",
1082
- width: O(n),
1083
- height: O(n),
1249
+ width: O(e),
1250
+ height: O(e),
1084
1251
  viewBox: "0 0 20 20",
1085
1252
  fill: "none",
1086
- children: /* @__PURE__ */ r(
1253
+ children: /* @__PURE__ */ a(
1087
1254
  "path",
1088
1255
  {
1089
1256
  d: "M5 5L15 15M15 5L5 15",
@@ -1096,15 +1263,15 @@ const O = (a) => {
1096
1263
  }
1097
1264
  )
1098
1265
  }
1099
- ) : /* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ r(
1266
+ ) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
1100
1267
  "svg",
1101
1268
  {
1102
1269
  xmlns: "http://www.w3.org/2000/svg",
1103
- width: O(n),
1104
- height: O(n),
1270
+ width: O(e),
1271
+ height: O(e),
1105
1272
  viewBox: "0 0 20 20",
1106
1273
  fill: "none",
1107
- children: /* @__PURE__ */ r(
1274
+ children: /* @__PURE__ */ a(
1108
1275
  "path",
1109
1276
  {
1110
1277
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -1119,324 +1286,329 @@ const O = (a) => {
1119
1286
  ]
1120
1287
  }
1121
1288
  );
1122
- }, me = ({
1123
- date: a,
1124
- setDate: n,
1289
+ }, vn = ({
1290
+ date: r,
1291
+ setDate: e,
1125
1292
  previewDate: t,
1126
- setPreviewDate: s,
1293
+ setPreviewDate: o,
1127
1294
  setIsComponentVisible: l,
1128
- minDate: h,
1129
- maxDate: i,
1130
- input: g,
1131
- onChange: f
1295
+ minDate: u,
1296
+ maxDate: d,
1297
+ input: p,
1298
+ onChange: g
1132
1299
  }) => {
1133
- let e = new Date(
1300
+ let n = new Date(
1134
1301
  t.getFullYear(),
1135
1302
  t.getMonth(),
1136
1303
  1
1137
- ), p = e.getDay(), v = [];
1138
- const x = a.toDateString(), D = t.getMonth();
1139
- for (let o = 0; o < 42; o++) {
1140
- o === 0 && p === 0 ? e.setDate(e.getDate() - 7) : o === 0 ? e.setDate(
1141
- e.getDate() + (o - p)
1142
- ) : e.setDate(e.getDate() + 1);
1143
- let c = {
1144
- currentMonth: e.getMonth() === D,
1145
- date: new Date(e),
1146
- month: e.getMonth(),
1147
- number: e.getDate(),
1148
- selected: e.toDateString() === x,
1149
- year: e.getFullYear(),
1150
- isDisabled: h && e < h || i && e > i
1304
+ ), c = n.getDay(), v = [];
1305
+ const k = r.toDateString(), D = (/* @__PURE__ */ new Date()).toDateString(), b = t.getMonth();
1306
+ for (let s = 0; s < 42; s++) {
1307
+ s === 0 && c === 0 ? n.setDate(n.getDate() - 7) : s === 0 ? n.setDate(
1308
+ n.getDate() + (s - c)
1309
+ ) : n.setDate(n.getDate() + 1);
1310
+ let x = {
1311
+ currentMonth: n.getMonth() === b,
1312
+ date: new Date(n),
1313
+ month: n.getMonth(),
1314
+ number: n.getDate(),
1315
+ selected: n.toDateString() === k,
1316
+ isToday: n.toDateString() === D,
1317
+ year: n.getFullYear(),
1318
+ isDisabled: u && n < u || d && n > d
1151
1319
  };
1152
- v.push(c);
1320
+ v.push(x);
1153
1321
  }
1154
- const m = (o) => {
1155
- (!h || o >= h) && (!i || o <= i) && (n(o), f(o), s(o), g && l(!1));
1322
+ const f = (s) => {
1323
+ (!u || s >= u) && (!d || s <= d) && (e(s), g(s), o(s), p && l(!1));
1156
1324
  };
1157
- return /* @__PURE__ */ F("div", { className: "sa-calendar-days-preivew", children: [
1158
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((o, c) => /* @__PURE__ */ r("p", { children: o }, c)) }),
1159
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: v.map((o, c) => {
1160
- const k = o.isDisabled;
1161
- return /* @__PURE__ */ r(
1325
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
1326
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((s, x) => /* @__PURE__ */ a("p", { children: s }, x)) }),
1327
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: v.map((s, x) => {
1328
+ const N = s.isDisabled;
1329
+ return /* @__PURE__ */ a(
1162
1330
  "p",
1163
1331
  {
1164
- className: `${o.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${o.selected ? "sa-calendar-days-active" : ""}`,
1332
+ className: `${s.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${s.selected ? "sa-calendar-days-active" : ""} ${s.isToday && !s.selected ? "sa-calendar-days-today" : ""}`,
1165
1333
  style: {
1166
- color: k ? "#ccc" : void 0,
1167
- pointerEvents: k ? "none" : void 0,
1168
- cursor: k ? "not-allowed" : "pointer",
1169
- ...g ? {} : { width: "100%" }
1334
+ color: N ? "#ccc" : void 0,
1335
+ pointerEvents: N ? "none" : void 0,
1336
+ cursor: N ? "not-allowed" : "pointer",
1337
+ ...p ? {} : { width: "100%" }
1170
1338
  },
1171
1339
  onClick: () => {
1172
- k || m(o.date);
1340
+ N || f(s.date);
1173
1341
  },
1174
- children: o.number
1342
+ children: s.number
1175
1343
  },
1176
- c
1344
+ x
1177
1345
  );
1178
1346
  }) })
1179
1347
  ] });
1180
- }, ve = ({
1181
- date: a,
1182
- setDate: n,
1348
+ }, yn = ({
1349
+ date: r,
1350
+ setDate: e,
1183
1351
  filter: t,
1184
- setViews: s,
1352
+ setViews: o,
1185
1353
  onChange: l,
1186
- previewDate: h,
1187
- setPreviewDate: i,
1188
- minDate: g,
1189
- maxDate: f,
1190
- input: e
1354
+ previewDate: u,
1355
+ setPreviewDate: d,
1356
+ minDate: p,
1357
+ maxDate: g,
1358
+ input: n
1191
1359
  }) => {
1192
- const p = a.getMonth(), v = a.getFullYear(), x = h.getFullYear(), D = (m) => {
1193
- (!g || m >= g) && (!f || m <= f) && (t ? (l(m), n(m), i(m)) : (s("days"), i(m)));
1360
+ const c = r.getMonth(), v = r.getFullYear(), k = u.getFullYear(), D = (b) => {
1361
+ (!p || b >= p) && (!g || b <= g) && (t ? (l(b), e(b), d(b)) : (o("days"), d(b)));
1194
1362
  };
1195
- return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: W.map((m, o) => {
1196
- const c = g && new Date(x, o, 1) < g || f && new Date(x, o + 1, 0) > f;
1197
- return /* @__PURE__ */ r(
1363
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((b, f) => {
1364
+ const s = p && new Date(k, f, 1) < p || g && new Date(k, f + 1, 0) > g;
1365
+ return /* @__PURE__ */ a(
1198
1366
  "p",
1199
1367
  {
1200
- className: o === p && x === v ? "sa-calendar-months-active" : "",
1368
+ className: f === c && k === v ? "sa-calendar-months-active" : "",
1201
1369
  style: {
1202
- color: c ? "#ccc" : void 0,
1203
- pointerEvents: c ? "none" : void 0,
1204
- cursor: c ? "not-allowed" : "pointer",
1205
- ...e ? {} : { width: "100%" }
1370
+ color: s ? "#ccc" : void 0,
1371
+ pointerEvents: s ? "none" : void 0,
1372
+ cursor: s ? "not-allowed" : "pointer",
1373
+ ...n ? {} : { width: "100%" }
1206
1374
  },
1207
1375
  onClick: () => {
1208
- c || D(new Date(x, o));
1376
+ s || D(new Date(k, f));
1209
1377
  },
1210
- children: m.slice(0, 3)
1378
+ children: b.slice(0, 3)
1211
1379
  },
1212
- o
1380
+ f
1213
1381
  );
1214
1382
  }) });
1215
- }, q = (a) => {
1216
- const n = Math.floor(a / 10) * 10, t = n + 10;
1217
- return { start: n, end: t };
1218
- }, be = ({
1219
- date: a,
1220
- filter: n,
1383
+ }, G = (r) => {
1384
+ const e = Math.floor(r / 10) * 10, t = e + 10;
1385
+ return { start: e, end: t };
1386
+ }, wn = ({
1387
+ date: r,
1388
+ filter: e,
1221
1389
  setViews: t,
1222
- setDate: s,
1390
+ setDate: o,
1223
1391
  onChange: l,
1224
- previewDate: h,
1225
- setPreviewDate: i,
1226
- minDate: g,
1227
- maxDate: f,
1228
- input: e
1392
+ previewDate: u,
1393
+ setPreviewDate: d,
1394
+ minDate: p,
1395
+ maxDate: g,
1396
+ input: n
1229
1397
  }) => {
1230
- let p = [];
1231
- const v = h.getFullYear(), { start: x, end: D } = q(v), m = a.getFullYear();
1232
- for (let c = x; c < D; c++) {
1233
- let k = g && new Date(c, 0, 1) < g || f && new Date(c, 11, 31) > f;
1234
- p.push({ year: c, active: c === m, isDisabled: k });
1398
+ let c = [];
1399
+ const v = u.getFullYear(), { start: k, end: D } = G(v), b = r.getFullYear();
1400
+ for (let s = k; s < D; s++) {
1401
+ let x = p && new Date(s, 0, 1) < p || g && new Date(s, 11, 31) > g;
1402
+ c.push({ year: s, active: s === b, isDisabled: x });
1235
1403
  }
1236
- const o = (c) => {
1237
- (!g || c >= g) && (!f || c <= f) && (n ? (l(c), s(c), i(c)) : (t("months"), i(c)));
1404
+ const f = (s) => {
1405
+ (!p || s >= p) && (!g || s <= g) && (e ? (l(s), o(s), d(s)) : (t("months"), d(s)));
1238
1406
  };
1239
- return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: p.map((c, k) => /* @__PURE__ */ r(
1407
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((s, x) => /* @__PURE__ */ a(
1240
1408
  "p",
1241
1409
  {
1242
- className: c.active ? "sa-calendar-months-active" : "",
1410
+ className: s.active ? "sa-calendar-months-active" : "",
1243
1411
  style: {
1244
- color: c.isDisabled ? "#ccc" : void 0,
1245
- pointerEvents: c.isDisabled ? "none" : void 0,
1246
- cursor: c.isDisabled ? "not-allowed" : "pointer",
1247
- ...e ? {} : { width: "100%" }
1412
+ color: s.isDisabled ? "#ccc" : void 0,
1413
+ pointerEvents: s.isDisabled ? "none" : void 0,
1414
+ cursor: s.isDisabled ? "not-allowed" : "pointer",
1415
+ ...n ? {} : { width: "100%" }
1248
1416
  },
1249
1417
  onClick: () => {
1250
- c.isDisabled || o(new Date(c.year, 0));
1418
+ s.isDisabled || f(new Date(s.year, 0));
1251
1419
  },
1252
- children: c.year
1420
+ children: s.year
1253
1421
  },
1254
- k
1422
+ x
1255
1423
  )) });
1256
- }, ye = ({
1257
- setViews: a,
1258
- views: n,
1424
+ }, xn = ({
1425
+ setViews: r,
1426
+ views: e,
1259
1427
  filter: t,
1260
- previewDate: s,
1428
+ previewDate: o,
1261
1429
  setPreviewDate: l
1262
1430
  }) => {
1263
- const h = () => {
1264
- t || a((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
1265
- }, i = () => {
1266
- if (n === "years") {
1267
- l((e) => new Date(e.getFullYear() + 10, 0));
1431
+ const u = () => {
1432
+ t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
1433
+ }, d = () => {
1434
+ if (e === "years") {
1435
+ l((n) => new Date(n.getFullYear() + 10, 0));
1268
1436
  return;
1269
1437
  }
1270
- if (n === "months") {
1438
+ if (e === "months") {
1271
1439
  l(
1272
- (e) => new Date(e.getFullYear() + 1, e.getMonth())
1440
+ (n) => new Date(n.getFullYear() + 1, n.getMonth())
1273
1441
  );
1274
1442
  return;
1275
1443
  }
1276
- l((e) => new Date(e.getFullYear(), e.getMonth() + 1));
1277
- }, g = () => {
1278
- if (n === "years") {
1279
- l((e) => new Date(e.getFullYear() - 10, 0));
1444
+ l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
1445
+ }, p = () => {
1446
+ if (e === "years") {
1447
+ l((n) => new Date(n.getFullYear() - 10, 0));
1280
1448
  return;
1281
1449
  }
1282
- if (n === "months") {
1450
+ if (e === "months") {
1283
1451
  l(
1284
- (e) => new Date(e.getFullYear() - 1, e.getMonth())
1452
+ (n) => new Date(n.getFullYear() - 1, n.getMonth())
1285
1453
  );
1286
1454
  return;
1287
1455
  }
1288
1456
  l(
1289
- (e) => new Date(
1290
- e.getMonth() === 0 ? e.getFullYear() - 1 : e.getFullYear(),
1291
- e.getMonth() === 0 ? 11 : e.getMonth() - 1
1457
+ (n) => new Date(
1458
+ n.getMonth() === 0 ? n.getFullYear() - 1 : n.getFullYear(),
1459
+ n.getMonth() === 0 ? 11 : n.getMonth() - 1
1292
1460
  )
1293
1461
  );
1294
1462
  };
1295
- return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
1296
- /* @__PURE__ */ r(ae, { onClick: () => g() }),
1297
- /* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: h, children: (() => {
1298
- if (n === "days")
1299
- return `${W[s.getMonth()]} ${s.getFullYear()}`;
1300
- if (n === "months")
1301
- return `${s.getFullYear()}`;
1302
- if (n === "years")
1303
- return `${q(s.getFullYear()).start} ~ ${q(s.getFullYear()).end}`;
1463
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1464
+ /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1465
+ if (e === "days")
1466
+ return `${W[o.getMonth()]} ${o.getFullYear()}`;
1467
+ if (e === "months")
1468
+ return `${o.getFullYear()}`;
1469
+ if (e === "years")
1470
+ return `${G(o.getFullYear()).start} ~ ${G(o.getFullYear()).end}`;
1304
1471
  })() }),
1305
- /* @__PURE__ */ r(re, { onClick: () => i() })
1472
+ /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1473
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ a(rn, {}) }),
1474
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
1475
+ ] })
1306
1476
  ] });
1307
- }, Z = "sa-calendar-styles", we = (a) => {
1308
- if (!document.getElementById(Z)) {
1309
- const n = document.createElement("style");
1310
- n.id = Z, n.textContent = a, document.head.appendChild(n);
1477
+ }, _ = "sa-calendar-styles", kn = (r) => {
1478
+ if (!document.getElementById(_)) {
1479
+ const e = document.createElement("style");
1480
+ e.id = _, e.textContent = r, document.head.appendChild(e);
1311
1481
  }
1312
1482
  };
1313
- we(J);
1314
- const xe = G(
1483
+ kn(R);
1484
+ const Mn = Z(
1315
1485
  ({
1316
- value: a,
1317
- onChange: n,
1486
+ value: r,
1487
+ onChange: e,
1318
1488
  filter: t,
1319
- input: s = !0,
1489
+ input: o = !0,
1320
1490
  disabled: l,
1321
- minDate: h,
1322
- maxDate: i,
1323
- placeholder: g,
1324
- size: f,
1325
- status: e,
1326
- clearable: p,
1327
- fullWidth: v = !0,
1328
- label: x,
1329
- labelPosition: D,
1330
- required: m,
1331
- optional: o,
1332
- description: c,
1333
- helperText: k,
1334
- errorText: Y
1335
- }, u) => {
1336
- const y = Y ? "error" : e, { ref: d, isComponentVisible: w, setIsComponentVisible: N } = ne(!1), M = P(null), [T, $] = z("days"), [E, I] = z(/* @__PURE__ */ new Date()), [C, L] = z(/* @__PURE__ */ new Date());
1337
- S(() => {
1338
- a ? (I(a), L(a)) : (I(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
1339
- }, [a]), S(() => {
1340
- t && $(t);
1341
- }, [t]), S(() => {
1342
- t || $("days");
1343
- }, [w]), S(() => {
1344
- s || N(!0);
1345
- }, [s]);
1346
- const j = () => a ? t === "days" ? A(E) : t === "months" ? `${W[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : A(E) : "", V = () => {
1347
- if (M.current && d.current && s) {
1348
- const b = d.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1349
- window.innerWidth < b.left + B.width ? M.current.style.left = `${b.left - B.width + b.width}px` : M.current.style.left = `${b.left}px`, b.top + B.height > window.innerHeight ? M.current.style.top = `${b.y - (b.height + B.height - 28)}px` : M.current.style.top = `${b.y + b.height}px`;
1491
+ minDate: u,
1492
+ maxDate: d,
1493
+ placeholder: p,
1494
+ size: g,
1495
+ variant: n,
1496
+ status: c,
1497
+ clearable: v,
1498
+ fullWidth: k = !0,
1499
+ label: D,
1500
+ labelPosition: b,
1501
+ required: f,
1502
+ optional: s,
1503
+ description: x,
1504
+ helperText: N,
1505
+ errorText: h
1506
+ }, m) => {
1507
+ const F = h ? "error" : c, { ref: i, isComponentVisible: w, setIsComponentVisible: L } = an(!1), M = J(null), [T, Y] = j("days"), [E, S] = j(/* @__PURE__ */ new Date()), [C, z] = j(/* @__PURE__ */ new Date());
1508
+ I(() => {
1509
+ r ? (S(r), z(r)) : (S(/* @__PURE__ */ new Date()), z(/* @__PURE__ */ new Date()));
1510
+ }, [r]), I(() => {
1511
+ t && Y(t);
1512
+ }, [t]), I(() => {
1513
+ t || Y("days");
1514
+ }, [w]), I(() => {
1515
+ o || L(!0);
1516
+ }, [o]);
1517
+ const A = () => r ? t === "days" ? P(E) : t === "months" ? `${W[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : P(E) : "", V = () => {
1518
+ if (M.current && i.current && o) {
1519
+ const y = i.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1520
+ window.innerWidth < y.left + B.width ? M.current.style.left = `${y.left - B.width + y.width}px` : M.current.style.left = `${y.left}px`, y.top + B.height > window.innerHeight ? M.current.style.top = `${y.y - (y.height + B.height - 28)}px` : M.current.style.top = `${y.y + y.height}px`;
1350
1521
  }
1351
1522
  };
1352
- S(() => {
1353
- M.current && d.current && s && V();
1354
- }, [M, d, w]), S(() => {
1355
- const b = u == null ? void 0 : u.current;
1356
- return b && b.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1357
- b && b.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1523
+ I(() => {
1524
+ M.current && i.current && o && V();
1525
+ }, [M, i, w]), I(() => {
1526
+ const y = m == null ? void 0 : m.current;
1527
+ return y && y.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1528
+ y && y.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1358
1529
  };
1359
1530
  }, []);
1360
- const R = /* @__PURE__ */ F(
1531
+ const U = /* @__PURE__ */ $(
1361
1532
  "div",
1362
1533
  {
1363
1534
  className: "sa-calendar-wrapper",
1364
- style: { height: s ? "auto" : "100%" },
1365
- ref: s ? d : null,
1535
+ style: { height: o ? "auto" : "100%" },
1536
+ ref: o ? i : null,
1366
1537
  children: [
1367
- s ? /* @__PURE__ */ r(
1368
- fe,
1538
+ o ? /* @__PURE__ */ a(
1539
+ mn,
1369
1540
  {
1370
- value: j(),
1371
- onClick: () => N(!0),
1541
+ value: A(),
1542
+ onClick: () => L(!0),
1372
1543
  onChange: () => {
1373
1544
  },
1374
- placeholder: g,
1545
+ placeholder: p,
1375
1546
  disabled: l,
1376
- size: f,
1377
- status: y,
1547
+ size: g,
1548
+ variant: n,
1549
+ status: F,
1378
1550
  inputMode: "none",
1379
- clearable: p,
1380
- onClear: () => n(void 0)
1551
+ clearable: v,
1552
+ onClear: () => e(void 0)
1381
1553
  }
1382
1554
  ) : null,
1383
- w ? /* @__PURE__ */ F(
1555
+ w ? /* @__PURE__ */ $(
1384
1556
  "div",
1385
1557
  {
1386
- className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
1558
+ className: `sa-calendar sa-calendar-size-${g || "md"} ${o ? "" : "sa-calendar-no-input"}`,
1387
1559
  ref: M,
1388
1560
  children: [
1389
- /* @__PURE__ */ r(
1390
- ye,
1561
+ /* @__PURE__ */ a(
1562
+ xn,
1391
1563
  {
1392
- setViews: $,
1564
+ setViews: Y,
1393
1565
  views: T,
1394
1566
  filter: t,
1395
1567
  previewDate: C,
1396
- setPreviewDate: L,
1568
+ setPreviewDate: z,
1397
1569
  isComponentVisible: w
1398
1570
  }
1399
1571
  ),
1400
- /* @__PURE__ */ r("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ r(
1401
- me,
1572
+ /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ a(
1573
+ vn,
1402
1574
  {
1403
1575
  date: E,
1404
- setDate: I,
1576
+ setDate: S,
1405
1577
  previewDate: C,
1406
- setPreviewDate: L,
1407
- setIsComponentVisible: N,
1408
- input: s,
1409
- minDate: h,
1410
- maxDate: i,
1411
- onChange: n
1578
+ setPreviewDate: z,
1579
+ setIsComponentVisible: L,
1580
+ input: o,
1581
+ minDate: u,
1582
+ maxDate: d,
1583
+ onChange: e
1412
1584
  }
1413
- ) : T === "months" ? /* @__PURE__ */ r(
1414
- ve,
1585
+ ) : T === "months" ? /* @__PURE__ */ a(
1586
+ yn,
1415
1587
  {
1416
1588
  date: E,
1417
- setDate: I,
1589
+ setDate: S,
1418
1590
  previewDate: C,
1419
- setPreviewDate: L,
1591
+ setPreviewDate: z,
1420
1592
  filter: t,
1421
- setViews: $,
1422
- onChange: n,
1423
- minDate: h,
1424
- maxDate: i,
1425
- input: s
1593
+ setViews: Y,
1594
+ onChange: e,
1595
+ minDate: u,
1596
+ maxDate: d,
1597
+ input: o
1426
1598
  }
1427
- ) : /* @__PURE__ */ r(
1428
- be,
1599
+ ) : /* @__PURE__ */ a(
1600
+ wn,
1429
1601
  {
1430
1602
  date: E,
1431
- setDate: I,
1603
+ setDate: S,
1432
1604
  previewDate: C,
1433
- setPreviewDate: L,
1605
+ setPreviewDate: z,
1434
1606
  filter: t,
1435
- setViews: $,
1436
- onChange: n,
1437
- minDate: h,
1438
- maxDate: i,
1439
- input: s
1607
+ setViews: Y,
1608
+ onChange: e,
1609
+ minDate: u,
1610
+ maxDate: d,
1611
+ input: o
1440
1612
  }
1441
1613
  ) })
1442
1614
  ]
@@ -1445,68 +1617,70 @@ const xe = G(
1445
1617
  ]
1446
1618
  }
1447
1619
  );
1448
- return /* @__PURE__ */ r(
1449
- te,
1620
+ return /* @__PURE__ */ a(
1621
+ sn,
1450
1622
  {
1451
- label: x,
1452
- labelPosition: D,
1453
- required: m,
1454
- optional: o,
1455
- description: c,
1456
- helperText: k,
1457
- errorText: Y,
1458
- fullWidth: v,
1459
- children: R
1623
+ label: D,
1624
+ labelPosition: b,
1625
+ required: f,
1626
+ optional: s,
1627
+ description: x,
1628
+ helperText: N,
1629
+ errorText: h,
1630
+ fullWidth: k,
1631
+ children: U
1460
1632
  }
1461
1633
  );
1462
1634
  }
1463
- ), Ce = G(
1635
+ ), Nn = Z(
1464
1636
  ({
1465
- value: a,
1466
- onChange: n,
1637
+ value: r,
1638
+ onChange: e,
1467
1639
  filter: t,
1468
- input: s = !0,
1640
+ input: o = !0,
1469
1641
  rangedDate: l,
1470
- disabled: h,
1471
- minDate: i,
1472
- maxDate: g,
1473
- placeholder: f,
1474
- size: e,
1475
- status: p,
1476
- clearable: v,
1477
- fullWidth: x,
1478
- label: D,
1479
- labelPosition: m,
1480
- required: o,
1481
- optional: c,
1482
- description: k,
1483
- helperText: Y,
1484
- errorText: u
1485
- }, y) => {
1486
- const d = {
1487
- onChange: n,
1488
- value: a,
1489
- input: s,
1642
+ disabled: u,
1643
+ minDate: d,
1644
+ maxDate: p,
1645
+ placeholder: g,
1646
+ size: n,
1647
+ variant: c,
1648
+ status: v,
1649
+ clearable: k,
1650
+ fullWidth: D,
1651
+ label: b,
1652
+ labelPosition: f,
1653
+ required: s,
1654
+ optional: x,
1655
+ description: N,
1656
+ helperText: h,
1657
+ errorText: m
1658
+ }, F) => {
1659
+ const i = {
1660
+ onChange: e,
1661
+ value: r,
1662
+ input: o,
1490
1663
  filter: t,
1491
- disabled: h,
1492
- minDate: i,
1493
- maxDate: g,
1494
- placeholder: f,
1495
- size: e,
1496
- status: p,
1497
- clearable: v,
1498
- fullWidth: x,
1499
- label: D,
1500
- labelPosition: m,
1501
- required: o,
1502
- optional: c,
1503
- description: k,
1504
- helperText: Y,
1505
- errorText: u
1664
+ disabled: u,
1665
+ minDate: d,
1666
+ maxDate: p,
1667
+ placeholder: g,
1668
+ size: n,
1669
+ variant: c,
1670
+ status: v,
1671
+ clearable: k,
1672
+ fullWidth: D,
1673
+ label: b,
1674
+ labelPosition: f,
1675
+ required: s,
1676
+ optional: x,
1677
+ description: N,
1678
+ helperText: h,
1679
+ errorText: m
1506
1680
  };
1507
- return /* @__PURE__ */ r(_, { children: l ? /* @__PURE__ */ r(pe, { ...d, ref: y }) : /* @__PURE__ */ r(xe, { ...d, ref: y }) });
1681
+ return /* @__PURE__ */ a(nn, { children: l ? /* @__PURE__ */ a(fn, { ...i, ref: F }) : /* @__PURE__ */ a(Mn, { ...i, ref: F }) });
1508
1682
  }
1509
1683
  );
1510
1684
  export {
1511
- Ce as StarasiaDate
1685
+ Nn as StarasiaDate
1512
1686
  };