@starasia/date 3.1.2 → 4.0.0

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 $, jsx as t, Fragment as G } from "react/jsx-runtime";
2
- import { useState as N, useRef as S, useEffect as D, forwardRef as W } from "react";
3
- const B = `@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 F, jsx as t, Fragment as q } from "react/jsx-runtime";
2
+ import { useState as N, useRef as B, useEffect as D, forwardRef as W } from "react";
3
+ const V = `@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;
@@ -29,6 +29,9 @@ const B = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
29
29
  }
30
30
  .sa-calendar-wrapper {
31
31
  position: relative;
32
+ width: max-content;
33
+ }
34
+ .sa-calendar-wrapper-fullwidth {
32
35
  width: 100%;
33
36
  }
34
37
 
@@ -279,7 +282,7 @@ const B = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
279
282
  outline: 2px solid var(--sa-date-brand);
280
283
  outline-offset: 1px;
281
284
  }
282
- `, J = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], L = [
285
+ `, P = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], L = [
283
286
  "January",
284
287
  "February",
285
288
  "March",
@@ -292,7 +295,7 @@ const B = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
292
295
  "October",
293
296
  "November",
294
297
  "December"
295
- ], q = [
298
+ ], K = [
296
299
  "Jan",
297
300
  "Feb",
298
301
  "Mar",
@@ -306,53 +309,53 @@ const B = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
306
309
  "Nov",
307
310
  "Dec"
308
311
  ];
309
- function P(r) {
310
- const [e, s] = N(r), o = S(null), c = (p) => {
311
- o.current && !o.current.contains(p.target) && s(!1);
312
+ function R(a) {
313
+ const [e, o] = N(a), l = B(null), c = (g) => {
314
+ l.current && !l.current.contains(g.target) && o(!1);
312
315
  };
313
316
  return D(() => (document.addEventListener("click", c, !0), () => {
314
317
  document.removeEventListener("click", c, !0);
315
- }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: s };
318
+ }), []), { ref: l, isComponentVisible: e, setIsComponentVisible: o };
316
319
  }
317
- const z = "sa-calendar-input-styles", K = (r) => {
318
- if (!document.getElementById(z)) {
320
+ const O = "sa-calendar-input-styles", Q = (a) => {
321
+ if (!document.getElementById(O)) {
319
322
  const e = document.createElement("style");
320
- e.id = z, e.textContent = r, document.head.appendChild(e);
323
+ e.id = O, e.textContent = a, document.head.appendChild(e);
321
324
  }
322
325
  };
323
- K(B);
324
- const T = (r) => {
325
- if (r === "sm")
326
+ Q(V);
327
+ const E = (a) => {
328
+ if (a === "sm")
326
329
  return 16;
327
- if (r === "md")
330
+ if (a === "md")
328
331
  return 16;
329
- if (r === "lg")
332
+ if (a === "lg")
330
333
  return 20;
331
- }, Q = (r) => {
334
+ }, X = (a) => {
332
335
  const {
333
336
  size: e = "md",
334
- status: s = "default",
335
- variant: o = "outline",
337
+ status: o = "default",
338
+ variant: l = "outline",
336
339
  clearable: c,
337
- onClear: p,
338
- ...g
339
- } = r, f = S(null), u = () => {
340
- f.current && g.onClick && (f.current.focus(), g.onClick(""));
341
- }, n = s === "disable" || g.disabled, x = !!g.value, b = c && x && !n, v = (k) => {
342
- k.stopPropagation(), p == null || p();
340
+ onClear: g,
341
+ ...h
342
+ } = a, f = B(null), u = () => {
343
+ f.current && h.onClick && (f.current.focus(), h.onClick(""));
344
+ }, n = o === "disable" || h.disabled, M = !!h.value, k = c && M && !n, x = (b) => {
345
+ b.stopPropagation(), g == null || g();
343
346
  };
344
- return /* @__PURE__ */ $(
347
+ return /* @__PURE__ */ F(
345
348
  "div",
346
349
  {
347
- className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,
350
+ className: `sa-calendar-input-container sa-calendar-input-${l} sa-calendar-input-container-${o} ${e} `,
348
351
  onClick: u,
349
352
  children: [
350
353
  /* @__PURE__ */ t("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ t(
351
354
  "svg",
352
355
  {
353
356
  xmlns: "http://www.w3.org/2000/svg",
354
- width: T(e),
355
- height: T(e),
357
+ width: E(e),
358
+ height: E(e),
356
359
  viewBox: "0 0 20 20",
357
360
  fill: "none",
358
361
  children: /* @__PURE__ */ t(
@@ -371,25 +374,25 @@ const T = (r) => {
371
374
  "input",
372
375
  {
373
376
  className: "sa-calendar-input",
374
- ...g,
377
+ ...h,
375
378
  disabled: n,
376
- value: g.value,
379
+ value: h.value,
377
380
  ref: f
378
381
  }
379
382
  ) }),
380
- b ? /* @__PURE__ */ t(
383
+ k ? /* @__PURE__ */ t(
381
384
  "button",
382
385
  {
383
386
  type: "button",
384
387
  "aria-label": "Clear date",
385
388
  className: "sa-calendar-input-clear",
386
- onClick: v,
389
+ onClick: x,
387
390
  children: /* @__PURE__ */ t(
388
391
  "svg",
389
392
  {
390
393
  xmlns: "http://www.w3.org/2000/svg",
391
- width: T(e),
392
- height: T(e),
394
+ width: E(e),
395
+ height: E(e),
393
396
  viewBox: "0 0 20 20",
394
397
  fill: "none",
395
398
  children: /* @__PURE__ */ t(
@@ -409,8 +412,8 @@ const T = (r) => {
409
412
  "svg",
410
413
  {
411
414
  xmlns: "http://www.w3.org/2000/svg",
412
- width: T(e),
413
- height: T(e),
415
+ width: E(e),
416
+ height: E(e),
414
417
  viewBox: "0 0 20 20",
415
418
  fill: "none",
416
419
  children: /* @__PURE__ */ t(
@@ -428,65 +431,65 @@ const T = (r) => {
428
431
  ]
429
432
  }
430
433
  );
431
- }, X = ({
432
- date: r,
434
+ }, Z = ({
435
+ date: a,
433
436
  setDate: e,
434
- dateRange: s,
435
- setDateRange: o,
437
+ dateRange: o,
438
+ setDateRange: l,
436
439
  onChange: c,
437
- minDate: p,
438
- maxDate: g,
440
+ minDate: g,
441
+ maxDate: h,
439
442
  input: f
440
443
  }) => {
441
- var y, a, l;
442
- let u = new Date(r.getFullYear(), r.getMonth(), 1), n = u.getDay(), x = [];
443
- const b = r.getMonth();
444
+ var y, s, r;
445
+ let u = new Date(a.getFullYear(), a.getMonth(), 1), n = u.getDay(), M = [];
446
+ const k = a.getMonth();
444
447
  for (let i = 0; i < 42; i++) {
445
448
  i === 0 && n === 0 ? u.setDate(u.getDate() - 7) : i === 0 ? u.setDate(
446
449
  u.getDate() + (i - n)
447
450
  ) : u.setDate(u.getDate() + 1);
448
451
  let m = {
449
- currentMonth: u.getMonth() === b,
452
+ currentMonth: u.getMonth() === k,
450
453
  date: new Date(u),
451
454
  month: u.getMonth(),
452
455
  number: u.getDate(),
453
- selected: u.toDateString() === ((y = s.from) == null ? void 0 : y.toDateString()) || u.toDateString() === (((a = s.to) == null ? void 0 : a.toDateString()) || ((l = s.from) == null ? void 0 : l.toDateString())),
456
+ selected: u.toDateString() === ((y = o.from) == null ? void 0 : y.toDateString()) || u.toDateString() === (((s = o.to) == null ? void 0 : s.toDateString()) || ((r = o.from) == null ? void 0 : r.toDateString())),
454
457
  year: u.getFullYear(),
455
- isDisabled: p && u < p || g && u > g
458
+ isDisabled: g && u < g || h && u > h
456
459
  };
457
- x.push(m);
460
+ M.push(m);
458
461
  }
459
- const v = (i) => {
462
+ const x = (i) => {
460
463
  e(i);
461
- }, k = (i) => {
464
+ }, b = (i) => {
462
465
  var d;
463
- let m = { ...s };
466
+ let m = { ...o };
464
467
  if (m.from && m.to)
465
468
  m = { from: i, to: null };
466
469
  else {
467
- const h = ((d = m.from) == null ? void 0 : d.getTime()) || 0;
468
- i.getTime() > h ? m = { from: m.from, to: i } : m = { from: i, to: m.from };
470
+ const p = ((d = m.from) == null ? void 0 : d.getTime()) || 0;
471
+ i.getTime() > p ? m = { from: m.from, to: i } : m = { from: i, to: m.from };
469
472
  }
470
- o(m), c(m);
473
+ l(m), c(m);
471
474
  };
472
- return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
473
- /* @__PURE__ */ t("div", { className: "sa-calendar-days-name-preivew", children: J.map((i, m) => /* @__PURE__ */ t("p", { children: i }, m)) }),
474
- /* @__PURE__ */ t("div", { className: "sa-calendar-days-number-preivew", children: x.map((i, m) => {
475
- var M;
476
- const d = i.date.getTime() > s.from.getTime() && i.date.getTime() < (((M = s.to) == null ? void 0 : M.getTime()) || s.from.getTime()), h = i.isDisabled;
475
+ return /* @__PURE__ */ F("div", { className: "sa-calendar-days-preivew", children: [
476
+ /* @__PURE__ */ t("div", { className: "sa-calendar-days-name-preivew", children: P.map((i, m) => /* @__PURE__ */ t("p", { children: i }, m)) }),
477
+ /* @__PURE__ */ t("div", { className: "sa-calendar-days-number-preivew", children: M.map((i, m) => {
478
+ var w;
479
+ const d = i.date.getTime() > o.from.getTime() && i.date.getTime() < (((w = o.to) == null ? void 0 : w.getTime()) || o.from.getTime()), p = i.isDisabled;
477
480
  return /* @__PURE__ */ t(
478
481
  "p",
479
482
  {
480
483
  className: `${i.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${i.selected ? "sa-calendar-days-active" : ""}`,
481
484
  style: {
482
485
  backgroundColor: d ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
483
- pointerEvents: h ? "none" : void 0,
484
- cursor: h ? "not-allowed" : "pointer",
485
- color: h ? "var(--sa-color-gray-400, #b7b9be)" : d ? "var(--sa-color-gray-500, #8c8f97)" : "",
486
+ pointerEvents: p ? "none" : void 0,
487
+ cursor: p ? "not-allowed" : "pointer",
488
+ color: p ? "var(--sa-color-gray-400, #b7b9be)" : d ? "var(--sa-color-gray-500, #8c8f97)" : "",
486
489
  ...f ? {} : { width: "100%" }
487
490
  },
488
491
  onClick: () => {
489
- h || (v(i.date), k(i.date));
492
+ p || (x(i.date), b(i.date));
490
493
  },
491
494
  children: i.number
492
495
  },
@@ -494,99 +497,99 @@ const T = (r) => {
494
497
  );
495
498
  }) })
496
499
  ] });
497
- }, Z = ({
498
- date: r,
500
+ }, _ = ({
501
+ date: a,
499
502
  setDate: e,
500
- filter: s,
501
- setViews: o,
503
+ filter: o,
504
+ setViews: l,
502
505
  dateRange: c,
503
- setDateRange: p,
504
- onChange: g,
506
+ setDateRange: g,
507
+ onChange: h,
505
508
  minDate: f,
506
509
  maxDate: u,
507
510
  input: n
508
511
  }) => {
509
- const x = c.from.getFullYear(), b = r.getFullYear(), v = (y) => {
510
- s ? (k(y), e(y)) : (o("days"), e(y));
511
- }, k = (y) => {
512
- var l;
513
- let a = { ...c };
514
- if (a.from && a.to)
515
- a = { from: y, to: null };
512
+ const M = c.from.getFullYear(), k = a.getFullYear(), x = (y) => {
513
+ o ? (b(y), e(y)) : (l("days"), e(y));
514
+ }, b = (y) => {
515
+ var r;
516
+ let s = { ...c };
517
+ if (s.from && s.to)
518
+ s = { from: y, to: null };
516
519
  else {
517
- const i = ((l = a.from) == null ? void 0 : l.getTime()) || 0;
518
- y.getTime() > i ? a = { from: a.from, to: y } : a = { from: y, to: a.from };
520
+ const i = ((r = s.from) == null ? void 0 : r.getTime()) || 0;
521
+ y.getTime() > i ? s = { from: s.from, to: y } : s = { from: y, to: s.from };
519
522
  }
520
- p(a), g(a);
523
+ g(s), h(s);
521
524
  };
522
- return /* @__PURE__ */ t("div", { className: "sa-calendar-months-preview", children: L.map((y, a) => {
523
- var m, d, h;
524
- const l = new Date(b, a).getTime() > c.from.getTime() && new Date(b, a).getTime() < (((m = c.to) == null ? void 0 : m.getTime()) || c.from.getTime()), i = f && new Date(b, a) < f || u && new Date(b, a) > u;
525
+ return /* @__PURE__ */ t("div", { className: "sa-calendar-months-preview", children: L.map((y, s) => {
526
+ var m, d, p;
527
+ const r = new Date(k, s).getTime() > c.from.getTime() && new Date(k, s).getTime() < (((m = c.to) == null ? void 0 : m.getTime()) || c.from.getTime()), i = f && new Date(k, s) < f || u && new Date(k, s) > u;
525
528
  return /* @__PURE__ */ t(
526
529
  "p",
527
530
  {
528
- className: x === b && (a === ((d = c.from) == null ? void 0 : d.getMonth()) || a === ((h = c.to) == null ? void 0 : h.getMonth())) ? "sa-calendar-months-active" : "",
531
+ className: M === k && (s === ((d = c.from) == null ? void 0 : d.getMonth()) || s === ((p = c.to) == null ? void 0 : p.getMonth())) ? "sa-calendar-months-active" : "",
529
532
  style: {
530
- backgroundColor: l ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
533
+ backgroundColor: r ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
531
534
  pointerEvents: i ? "none" : void 0,
532
535
  cursor: i ? "not-allowed" : "pointer",
533
- color: i ? "var(--sa-color-gray-400, #b7b9be)" : l ? "var(--sa-color-gray-500, #8c8f97)" : "",
536
+ color: i ? "var(--sa-color-gray-400, #b7b9be)" : r ? "var(--sa-color-gray-500, #8c8f97)" : "",
534
537
  ...n ? {} : { width: "100%" }
535
538
  },
536
539
  onClick: () => {
537
- i || v(new Date(b, a));
540
+ i || x(new Date(k, s));
538
541
  },
539
542
  children: y.slice(0, 3)
540
543
  },
541
- a
544
+ s
542
545
  );
543
546
  }) });
544
- }, V = (r) => {
545
- const e = Math.floor(r / 10) * 10, s = e + 10;
546
- return { start: e, end: s };
547
- }, _ = ({
548
- date: r,
547
+ }, j = (a) => {
548
+ const e = Math.floor(a / 10) * 10, o = e + 10;
549
+ return { start: e, end: o };
550
+ }, ee = ({
551
+ date: a,
549
552
  filter: e,
550
- setViews: s,
551
- setDate: o,
553
+ setViews: o,
554
+ setDate: l,
552
555
  dateRange: c,
553
- setDateRange: p,
554
- onChange: g,
556
+ setDateRange: g,
557
+ onChange: h,
555
558
  minDate: f,
556
559
  maxDate: u,
557
560
  input: n
558
561
  }) => {
559
562
  var m;
560
- let x = [];
561
- const b = r.getFullYear(), { start: v, end: k } = V(b), y = c.from.getFullYear(), a = (m = c.to) == null ? void 0 : m.getFullYear();
562
- for (let d = v; d < k; d++) {
563
- const h = new Date(d, 0), M = (!f || h >= f) && (!u || h <= u), F = d === y || d === a, C = h > c.from && h < c.to;
564
- x.push({
563
+ let M = [];
564
+ const k = a.getFullYear(), { start: x, end: b } = j(k), y = c.from.getFullYear(), s = (m = c.to) == null ? void 0 : m.getFullYear();
565
+ for (let d = x; d < b; d++) {
566
+ const p = new Date(d, 0), w = (!f || p >= f) && (!u || p <= u), C = d === y || d === s, T = p > c.from && p < c.to;
567
+ M.push({
565
568
  year: d,
566
- active: F && M,
567
- highlight: C && M,
568
- disabled: !M
569
+ active: C && w,
570
+ highlight: T && w,
571
+ disabled: !w
569
572
  });
570
573
  }
571
- const l = (d) => {
572
- e ? (i(d), o(d)) : (o(d), s("months"));
574
+ const r = (d) => {
575
+ e ? (i(d), l(d)) : (l(d), o("months"));
573
576
  }, i = (d) => {
574
- var M;
575
- let h = { ...c };
576
- if (h.from && h.to)
577
- h = { from: d, to: null };
577
+ var w;
578
+ let p = { ...c };
579
+ if (p.from && p.to)
580
+ p = { from: d, to: null };
578
581
  else {
579
- const F = ((M = h.from) == null ? void 0 : M.getTime()) || 0;
580
- d.getTime() > F ? h = { from: h.from, to: d } : h = { from: d, to: h.from };
582
+ const C = ((w = p.from) == null ? void 0 : w.getTime()) || 0;
583
+ d.getTime() > C ? p = { from: p.from, to: d } : p = { from: d, to: p.from };
581
584
  }
582
- p(h), g(h);
585
+ g(p), h(p);
583
586
  };
584
- return /* @__PURE__ */ t("div", { className: "sa-calendar-years-preview", children: x.map((d, h) => /* @__PURE__ */ t(
587
+ return /* @__PURE__ */ t("div", { className: "sa-calendar-years-preview", children: M.map((d, p) => /* @__PURE__ */ t(
585
588
  "p",
586
589
  {
587
590
  className: `${d.active ? "sa-calendar-months-active" : ""} ${d.highlight ? "sa-calendar-months-highlight" : ""} ${d.disabled ? "sa-calendar-disabled" : ""}`,
588
591
  onClick: () => {
589
- d.disabled || l(new Date(d.year, 0));
592
+ d.disabled || r(new Date(d.year, 0));
590
593
  },
591
594
  style: {
592
595
  backgroundColor: d.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
@@ -597,9 +600,9 @@ const T = (r) => {
597
600
  },
598
601
  children: d.year
599
602
  },
600
- h
603
+ p
601
604
  )) });
602
- }, R = ({ ...r }) => /* @__PURE__ */ t(
605
+ }, U = ({ ...a }) => /* @__PURE__ */ t(
603
606
  "svg",
604
607
  {
605
608
  xmlns: "http://www.w3.org/2000/svg",
@@ -607,7 +610,7 @@ const T = (r) => {
607
610
  height: "20",
608
611
  viewBox: "0 0 20 20",
609
612
  fill: "none",
610
- ...r,
613
+ ...a,
611
614
  children: /* @__PURE__ */ t(
612
615
  "path",
613
616
  {
@@ -619,7 +622,7 @@ const T = (r) => {
619
622
  }
620
623
  )
621
624
  }
622
- ), U = ({ ...r }) => /* @__PURE__ */ t(
625
+ ), G = ({ ...a }) => /* @__PURE__ */ t(
623
626
  "svg",
624
627
  {
625
628
  xmlns: "http://www.w3.org/2000/svg",
@@ -627,7 +630,7 @@ const T = (r) => {
627
630
  height: "20",
628
631
  viewBox: "0 0 20 20",
629
632
  fill: "none",
630
- ...r,
633
+ ...a,
631
634
  children: /* @__PURE__ */ t(
632
635
  "path",
633
636
  {
@@ -639,16 +642,16 @@ const T = (r) => {
639
642
  }
640
643
  )
641
644
  }
642
- ), ee = ({
643
- setViews: r,
645
+ ), ne = ({
646
+ setViews: a,
644
647
  views: e,
645
- filter: s,
646
- date: o,
648
+ filter: o,
649
+ date: l,
647
650
  setDate: c
648
651
  }) => {
649
- const p = () => {
650
- s || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
651
- }, g = () => {
652
+ const g = () => {
653
+ o || a((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
654
+ }, h = () => {
652
655
  if (e === "years") {
653
656
  c((n) => new Date(n.getFullYear() + 10, 0));
654
657
  return;
@@ -674,100 +677,101 @@ const T = (r) => {
674
677
  )
675
678
  );
676
679
  };
677
- return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
678
- /* @__PURE__ */ t(R, { onClick: () => f() }),
679
- /* @__PURE__ */ t("div", { style: { cursor: "pointer" }, onClick: p, children: (() => {
680
+ return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
681
+ /* @__PURE__ */ t(U, { onClick: () => f() }),
682
+ /* @__PURE__ */ t("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
680
683
  if (e === "days")
681
- return `${L[o.getMonth()]} ${o.getFullYear()}`;
684
+ return `${L[l.getMonth()]} ${l.getFullYear()}`;
682
685
  if (e === "months")
683
- return `${o.getFullYear()}`;
686
+ return `${l.getFullYear()}`;
684
687
  if (e === "years")
685
- return `${V(o.getFullYear()).start} ~ ${V(o.getFullYear()).end}`;
688
+ return `${j(l.getFullYear()).start} ~ ${j(l.getFullYear()).end}`;
686
689
  })() }),
687
- /* @__PURE__ */ t(U, { onClick: () => g() })
690
+ /* @__PURE__ */ t(G, { onClick: () => h() })
688
691
  ] });
689
692
  };
690
- function I(r) {
691
- const e = new Date(r), s = e.getFullYear(), o = e.getMonth();
692
- return `${e.getDate().toString().padStart(2, "0")} ${q[o]} ${s}`;
693
+ function S(a) {
694
+ const e = new Date(a), o = e.getFullYear(), l = e.getMonth();
695
+ return `${e.getDate().toString().padStart(2, "0")} ${K[l]} ${o}`;
693
696
  }
694
- const O = "sa-calendar-styles", ne = (r) => {
695
- if (!document.getElementById(O)) {
697
+ const H = "sa-calendar-styles", ae = (a) => {
698
+ if (!document.getElementById(H)) {
696
699
  const e = document.createElement("style");
697
- e.id = O, e.textContent = r, document.head.appendChild(e);
700
+ e.id = H, e.textContent = a, document.head.appendChild(e);
698
701
  }
699
702
  };
700
- ne(B);
701
- const ae = W(
703
+ ae(V);
704
+ const re = W(
702
705
  ({
703
- value: r,
706
+ value: a,
704
707
  onChange: e,
705
- filter: s,
706
- input: o = !0,
708
+ filter: o,
709
+ input: l = !0,
707
710
  disabled: c,
708
- minDate: p,
709
- maxDate: g,
711
+ minDate: g,
712
+ maxDate: h,
710
713
  placeholder: f,
711
714
  size: u,
712
715
  status: n,
713
- clearable: x
714
- }, b) => {
715
- const { ref: v, isComponentVisible: k, setIsComponentVisible: y } = P(!1), a = S(null), [l, i] = N("days"), [m, d] = N(/* @__PURE__ */ new Date()), [h, M] = N({
716
- from: (r == null ? void 0 : r.from) || /* @__PURE__ */ new Date(),
717
- to: (r == null ? void 0 : r.to) || /* @__PURE__ */ new Date()
716
+ clearable: M,
717
+ fullWidth: k = !1
718
+ }, x) => {
719
+ const { ref: b, isComponentVisible: y, setIsComponentVisible: s } = R(!1), r = B(null), [i, m] = N("days"), [d, p] = N(/* @__PURE__ */ new Date()), [w, C] = N({
720
+ from: (a == null ? void 0 : a.from) || /* @__PURE__ */ new Date(),
721
+ to: (a == null ? void 0 : a.to) || /* @__PURE__ */ new Date()
718
722
  });
719
723
  D(() => {
720
- r ? (d(r.from), M(r)) : (d(/* @__PURE__ */ new Date()), M({
724
+ a ? (p(a.from), C(a)) : (p(/* @__PURE__ */ new Date()), C({
721
725
  from: /* @__PURE__ */ new Date(),
722
726
  to: /* @__PURE__ */ new Date()
723
727
  }));
724
- }, [r]), D(() => {
725
- s && i(s);
726
- }, [s]), D(() => {
727
- s || i("days");
728
- }, [k]), D(() => {
729
- o || y(!0);
730
- }, [o]);
731
- const F = () => {
732
- var w, Y;
733
- if (!r)
728
+ }, [a]), D(() => {
729
+ o && m(o);
730
+ }, [o]), D(() => {
731
+ o || m("days");
732
+ }, [y]), D(() => {
733
+ l || s(!0);
734
+ }, [l]);
735
+ const T = () => {
736
+ var v, $;
737
+ if (!a)
734
738
  return "";
735
- if (s) {
736
- if (l === "days")
737
- return `${I(h.from)} ~ ${I(h.to || h.from) || "-"}`;
738
- if (l === "months")
739
- return `${L[h.from.getMonth()]} ~ ${h.to ? L[h.to.getMonth()] : "-"}`;
740
- if (l === "years")
741
- return `${(w = h.from) == null ? void 0 : w.getFullYear()} ~ ${((Y = h.to) == null ? void 0 : Y.getFullYear()) || "-"}`;
739
+ if (o) {
740
+ if (i === "days")
741
+ return `${S(w.from)} ~ ${S(w.to || w.from) || "-"}`;
742
+ if (i === "months")
743
+ return `${L[w.from.getMonth()]} ~ ${w.to ? L[w.to.getMonth()] : "-"}`;
744
+ if (i === "years")
745
+ return `${(v = w.from) == null ? void 0 : v.getFullYear()} ~ ${(($ = w.to) == null ? void 0 : $.getFullYear()) || "-"}`;
742
746
  } else
743
- return `${I(h.from)} ~ ${I(h.to || h.from) || "-"}`;
744
- }, C = () => {
745
- if (a.current && v.current && o) {
746
- const w = v.current.getBoundingClientRect(), Y = a.current.getBoundingClientRect();
747
- window.innerWidth < w.left + Y.width ? a.current.style.left = `${w.left - Y.width + w.width}px` : a.current.style.left = `${w.left}px`, w.top + Y.height > window.innerHeight ? a.current.style.top = `${w.y - (w.height + Y.height - 28)}px` : a.current.style.top = `${w.y + w.height}px`;
747
+ return `${S(w.from)} ~ ${S(w.to || w.from) || "-"}`;
748
+ }, Y = () => {
749
+ if (r.current && b.current && l) {
750
+ const v = b.current.getBoundingClientRect(), $ = r.current.getBoundingClientRect();
751
+ window.innerWidth < v.left + $.width ? r.current.style.left = `${v.left - $.width + v.width}px` : r.current.style.left = `${v.left}px`, v.top + $.height > window.innerHeight ? r.current.style.top = `${v.y - (v.height + $.height - 28)}px` : r.current.style.top = `${v.y + v.height}px`;
748
752
  }
749
753
  };
750
754
  return D(() => {
751
- a.current && v.current && o && C();
752
- }, [a, v, k]), D(() => {
753
- const w = b == null ? void 0 : b.current;
754
- return w && w.addEventListener("scroll", C), window.addEventListener("scroll", C), () => {
755
- w && w.removeEventListener("scroll", C), window.removeEventListener("scroll", C);
755
+ r.current && b.current && l && Y();
756
+ }, [r, b, y]), D(() => {
757
+ const v = x == null ? void 0 : x.current;
758
+ return v && v.addEventListener("scroll", Y), window.addEventListener("scroll", Y), () => {
759
+ v && v.removeEventListener("scroll", Y), window.removeEventListener("scroll", Y);
756
760
  };
757
- }, []), /* @__PURE__ */ $(
761
+ }, []), /* @__PURE__ */ F(
758
762
  "div",
759
763
  {
760
- className: "sa-calendar-wrapper",
761
- style: { height: o ? "auto" : "100%" },
762
- ref: o ? v : null,
764
+ className: `sa-calendar-wrapper${k ? " sa-calendar-wrapper-fullwidth" : ""}`,
765
+ style: { height: l ? "auto" : "100%" },
766
+ ref: l ? b : null,
763
767
  children: [
764
- o ? /* @__PURE__ */ t(
765
- Q,
768
+ l ? /* @__PURE__ */ t(
769
+ X,
766
770
  {
767
- value: F(),
771
+ value: T(),
768
772
  inputMode: "none",
769
773
  onClick: () => {
770
- y(!0);
774
+ s(!0);
771
775
  },
772
776
  onChange: () => {
773
777
  },
@@ -775,68 +779,68 @@ const ae = W(
775
779
  placeholder: f,
776
780
  size: u,
777
781
  status: n,
778
- clearable: x,
782
+ clearable: M,
779
783
  onClear: () => e(void 0)
780
784
  }
781
785
  ) : null,
782
- k ? /* @__PURE__ */ $(
786
+ y ? /* @__PURE__ */ F(
783
787
  "div",
784
788
  {
785
- className: `sa-calendar ${o ? "" : "sa-calendar-no-input"}`,
786
- ref: a,
789
+ className: `sa-calendar ${l ? "" : "sa-calendar-no-input"}`,
790
+ ref: r,
787
791
  children: [
788
792
  /* @__PURE__ */ t(
789
- ee,
793
+ ne,
790
794
  {
791
- setViews: i,
792
- views: l,
793
- filter: s,
794
- date: m,
795
- setDate: d
795
+ setViews: m,
796
+ views: i,
797
+ filter: o,
798
+ date: d,
799
+ setDate: p
796
800
  }
797
801
  ),
798
- /* @__PURE__ */ t("div", { className: "sa-calendar-body", children: l === "days" ? /* @__PURE__ */ t(
799
- X,
802
+ /* @__PURE__ */ t("div", { className: "sa-calendar-body", children: i === "days" ? /* @__PURE__ */ t(
803
+ Z,
800
804
  {
801
- date: m,
802
- setDate: d,
803
- setIsComponentVisible: y,
804
- dateRange: h,
805
- setDateRange: M,
806
- input: o,
805
+ date: d,
806
+ setDate: p,
807
+ setIsComponentVisible: s,
808
+ dateRange: w,
809
+ setDateRange: C,
810
+ input: l,
807
811
  onChange: e,
808
- minDate: p,
809
- maxDate: g
812
+ minDate: g,
813
+ maxDate: h
810
814
  }
811
- ) : l === "months" ? /* @__PURE__ */ t(
812
- Z,
815
+ ) : i === "months" ? /* @__PURE__ */ t(
816
+ _,
813
817
  {
814
- date: m,
815
- setDate: d,
816
- filter: s,
817
- setViews: i,
818
- dateRange: h,
819
- setDateRange: M,
820
- setIsComponentVisible: y,
821
- input: o,
818
+ date: d,
819
+ setDate: p,
820
+ filter: o,
821
+ setViews: m,
822
+ dateRange: w,
823
+ setDateRange: C,
824
+ setIsComponentVisible: s,
825
+ input: l,
822
826
  onChange: e,
823
- minDate: p,
824
- maxDate: g
827
+ minDate: g,
828
+ maxDate: h
825
829
  }
826
830
  ) : /* @__PURE__ */ t(
827
- _,
831
+ ee,
828
832
  {
829
- date: m,
830
- setDate: d,
831
- filter: s,
832
- setViews: i,
833
- dateRange: h,
834
- setDateRange: M,
835
- setIsComponentVisible: y,
836
- input: o,
833
+ date: d,
834
+ setDate: p,
835
+ filter: o,
836
+ setViews: m,
837
+ dateRange: w,
838
+ setDateRange: C,
839
+ setIsComponentVisible: s,
840
+ input: l,
837
841
  onChange: e,
838
- minDate: p,
839
- maxDate: g
842
+ minDate: g,
843
+ maxDate: h
840
844
  }
841
845
  ) })
842
846
  ]
@@ -846,45 +850,45 @@ const ae = W(
846
850
  }
847
851
  );
848
852
  }
849
- ), H = "sa-calendar-input-styles", re = (r) => {
850
- if (!document.getElementById(H)) {
853
+ ), A = "sa-calendar-input-styles", te = (a) => {
854
+ if (!document.getElementById(A)) {
851
855
  const e = document.createElement("style");
852
- e.id = H, e.textContent = r, document.head.appendChild(e);
856
+ e.id = A, e.textContent = a, document.head.appendChild(e);
853
857
  }
854
858
  };
855
- re(B);
856
- const E = (r) => {
857
- if (r === "sm")
859
+ te(V);
860
+ const I = (a) => {
861
+ if (a === "sm")
858
862
  return 16;
859
- if (r === "md")
863
+ if (a === "md")
860
864
  return 16;
861
- if (r === "lg")
865
+ if (a === "lg")
862
866
  return 20;
863
- }, te = (r) => {
867
+ }, se = (a) => {
864
868
  const {
865
869
  size: e = "md",
866
- status: s = "default",
867
- variant: o = "outline",
870
+ status: o = "default",
871
+ variant: l = "outline",
868
872
  clearable: c,
869
- onClear: p,
870
- ...g
871
- } = r, f = S(null), u = () => {
872
- f.current && g.onClick && (f.current.focus(), g.onClick(""));
873
- }, n = s === "disable" || g.disabled, x = !!g.value, b = c && x && !n, v = (k) => {
874
- k.stopPropagation(), p == null || p();
873
+ onClear: g,
874
+ ...h
875
+ } = a, f = B(null), u = () => {
876
+ f.current && h.onClick && (f.current.focus(), h.onClick(""));
877
+ }, n = o === "disable" || h.disabled, M = !!h.value, k = c && M && !n, x = (b) => {
878
+ b.stopPropagation(), g == null || g();
875
879
  };
876
- return /* @__PURE__ */ $(
880
+ return /* @__PURE__ */ F(
877
881
  "div",
878
882
  {
879
- className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,
883
+ className: `sa-calendar-input-container sa-calendar-input-${l} sa-calendar-input-container-${o} ${e} `,
880
884
  onClick: u,
881
885
  children: [
882
886
  /* @__PURE__ */ t("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ t(
883
887
  "svg",
884
888
  {
885
889
  xmlns: "http://www.w3.org/2000/svg",
886
- width: E(e),
887
- height: E(e),
890
+ width: I(e),
891
+ height: I(e),
888
892
  viewBox: "0 0 20 20",
889
893
  fill: "none",
890
894
  children: /* @__PURE__ */ t(
@@ -903,25 +907,25 @@ const E = (r) => {
903
907
  "input",
904
908
  {
905
909
  className: "sa-calendar-input",
906
- ...g,
910
+ ...h,
907
911
  disabled: n,
908
- value: g.value,
912
+ value: h.value,
909
913
  ref: f
910
914
  }
911
915
  ) }),
912
- b ? /* @__PURE__ */ t(
916
+ k ? /* @__PURE__ */ t(
913
917
  "button",
914
918
  {
915
919
  type: "button",
916
920
  "aria-label": "Clear date",
917
921
  className: "sa-calendar-input-clear",
918
- onClick: v,
922
+ onClick: x,
919
923
  children: /* @__PURE__ */ t(
920
924
  "svg",
921
925
  {
922
926
  xmlns: "http://www.w3.org/2000/svg",
923
- width: E(e),
924
- height: E(e),
927
+ width: I(e),
928
+ height: I(e),
925
929
  viewBox: "0 0 20 20",
926
930
  fill: "none",
927
931
  children: /* @__PURE__ */ t(
@@ -941,8 +945,8 @@ const E = (r) => {
941
945
  "svg",
942
946
  {
943
947
  xmlns: "http://www.w3.org/2000/svg",
944
- width: E(e),
945
- height: E(e),
948
+ width: I(e),
949
+ height: I(e),
946
950
  viewBox: "0 0 20 20",
947
951
  fill: "none",
948
952
  children: /* @__PURE__ */ t(
@@ -960,49 +964,49 @@ const E = (r) => {
960
964
  ]
961
965
  }
962
966
  );
963
- }, se = ({
964
- date: r,
967
+ }, oe = ({
968
+ date: a,
965
969
  setDate: e,
966
- previewDate: s,
967
- setPreviewDate: o,
970
+ previewDate: o,
971
+ setPreviewDate: l,
968
972
  setIsComponentVisible: c,
969
- minDate: p,
970
- maxDate: g,
973
+ minDate: g,
974
+ maxDate: h,
971
975
  input: f,
972
976
  onChange: u
973
977
  }) => {
974
978
  let n = new Date(
975
- s.getFullYear(),
976
- s.getMonth(),
979
+ o.getFullYear(),
980
+ o.getMonth(),
977
981
  1
978
- ), x = n.getDay(), b = [];
979
- const v = r.toDateString(), k = s.getMonth();
980
- for (let a = 0; a < 42; a++) {
981
- a === 0 && x === 0 ? n.setDate(n.getDate() - 7) : a === 0 ? n.setDate(
982
- n.getDate() + (a - x)
982
+ ), M = n.getDay(), k = [];
983
+ const x = a.toDateString(), b = o.getMonth();
984
+ for (let s = 0; s < 42; s++) {
985
+ s === 0 && M === 0 ? n.setDate(n.getDate() - 7) : s === 0 ? n.setDate(
986
+ n.getDate() + (s - M)
983
987
  ) : n.setDate(n.getDate() + 1);
984
- let l = {
985
- currentMonth: n.getMonth() === k,
988
+ let r = {
989
+ currentMonth: n.getMonth() === b,
986
990
  date: new Date(n),
987
991
  month: n.getMonth(),
988
992
  number: n.getDate(),
989
- selected: n.toDateString() === v,
993
+ selected: n.toDateString() === x,
990
994
  year: n.getFullYear(),
991
- isDisabled: p && n < p || g && n > g
995
+ isDisabled: g && n < g || h && n > h
992
996
  };
993
- b.push(l);
997
+ k.push(r);
994
998
  }
995
- const y = (a) => {
996
- (!p || a >= p) && (!g || a <= g) && (e(a), u(a), o(a), f && c(!1));
999
+ const y = (s) => {
1000
+ (!g || s >= g) && (!h || s <= h) && (e(s), u(s), l(s), f && c(!1));
997
1001
  };
998
- return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
999
- /* @__PURE__ */ t("div", { className: "sa-calendar-days-name-preivew", children: J.map((a, l) => /* @__PURE__ */ t("p", { children: a }, l)) }),
1000
- /* @__PURE__ */ t("div", { className: "sa-calendar-days-number-preivew", children: b.map((a, l) => {
1001
- const i = a.isDisabled;
1002
+ return /* @__PURE__ */ F("div", { className: "sa-calendar-days-preivew", children: [
1003
+ /* @__PURE__ */ t("div", { className: "sa-calendar-days-name-preivew", children: P.map((s, r) => /* @__PURE__ */ t("p", { children: s }, r)) }),
1004
+ /* @__PURE__ */ t("div", { className: "sa-calendar-days-number-preivew", children: k.map((s, r) => {
1005
+ const i = s.isDisabled;
1002
1006
  return /* @__PURE__ */ t(
1003
1007
  "p",
1004
1008
  {
1005
- className: `${a.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${a.selected ? "sa-calendar-days-active" : ""}`,
1009
+ className: `${s.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${s.selected ? "sa-calendar-days-active" : ""}`,
1006
1010
  style: {
1007
1011
  color: i ? "#ccc" : void 0,
1008
1012
  pointerEvents: i ? "none" : void 0,
@@ -1010,100 +1014,100 @@ const E = (r) => {
1010
1014
  ...f ? {} : { width: "100%" }
1011
1015
  },
1012
1016
  onClick: () => {
1013
- i || y(a.date);
1017
+ i || y(s.date);
1014
1018
  },
1015
- children: a.number
1019
+ children: s.number
1016
1020
  },
1017
- l
1021
+ r
1018
1022
  );
1019
1023
  }) })
1020
1024
  ] });
1021
- }, oe = ({
1022
- date: r,
1025
+ }, le = ({
1026
+ date: a,
1023
1027
  setDate: e,
1024
- filter: s,
1025
- setViews: o,
1028
+ filter: o,
1029
+ setViews: l,
1026
1030
  onChange: c,
1027
- previewDate: p,
1028
- setPreviewDate: g,
1031
+ previewDate: g,
1032
+ setPreviewDate: h,
1029
1033
  minDate: f,
1030
1034
  maxDate: u,
1031
1035
  input: n
1032
1036
  }) => {
1033
- const x = r.getMonth(), b = r.getFullYear(), v = p.getFullYear(), k = (y) => {
1034
- (!f || y >= f) && (!u || y <= u) && (s ? (c(y), e(y), g(y)) : (o("days"), g(y)));
1037
+ const M = a.getMonth(), k = a.getFullYear(), x = g.getFullYear(), b = (y) => {
1038
+ (!f || y >= f) && (!u || y <= u) && (o ? (c(y), e(y), h(y)) : (l("days"), h(y)));
1035
1039
  };
1036
- return /* @__PURE__ */ t("div", { className: "sa-calendar-months-preview", children: L.map((y, a) => {
1037
- const l = f && new Date(v, a, 1) < f || u && new Date(v, a + 1, 0) > u;
1040
+ return /* @__PURE__ */ t("div", { className: "sa-calendar-months-preview", children: L.map((y, s) => {
1041
+ const r = f && new Date(x, s, 1) < f || u && new Date(x, s + 1, 0) > u;
1038
1042
  return /* @__PURE__ */ t(
1039
1043
  "p",
1040
1044
  {
1041
- className: a === x && v === b ? "sa-calendar-months-active" : "",
1045
+ className: s === M && x === k ? "sa-calendar-months-active" : "",
1042
1046
  style: {
1043
- color: l ? "#ccc" : void 0,
1044
- pointerEvents: l ? "none" : void 0,
1045
- cursor: l ? "not-allowed" : "pointer",
1047
+ color: r ? "#ccc" : void 0,
1048
+ pointerEvents: r ? "none" : void 0,
1049
+ cursor: r ? "not-allowed" : "pointer",
1046
1050
  ...n ? {} : { width: "100%" }
1047
1051
  },
1048
1052
  onClick: () => {
1049
- l || k(new Date(v, a));
1053
+ r || b(new Date(x, s));
1050
1054
  },
1051
1055
  children: y.slice(0, 3)
1052
1056
  },
1053
- a
1057
+ s
1054
1058
  );
1055
1059
  }) });
1056
- }, j = (r) => {
1057
- const e = Math.floor(r / 10) * 10, s = e + 10;
1058
- return { start: e, end: s };
1059
- }, le = ({
1060
- date: r,
1060
+ }, z = (a) => {
1061
+ const e = Math.floor(a / 10) * 10, o = e + 10;
1062
+ return { start: e, end: o };
1063
+ }, ie = ({
1064
+ date: a,
1061
1065
  filter: e,
1062
- setViews: s,
1063
- setDate: o,
1066
+ setViews: o,
1067
+ setDate: l,
1064
1068
  onChange: c,
1065
- previewDate: p,
1066
- setPreviewDate: g,
1069
+ previewDate: g,
1070
+ setPreviewDate: h,
1067
1071
  minDate: f,
1068
1072
  maxDate: u,
1069
1073
  input: n
1070
1074
  }) => {
1071
- let x = [];
1072
- const b = p.getFullYear(), { start: v, end: k } = j(b), y = r.getFullYear();
1073
- for (let l = v; l < k; l++) {
1074
- let i = f && new Date(l, 0, 1) < f || u && new Date(l, 11, 31) > u;
1075
- x.push({ year: l, active: l === y, isDisabled: i });
1075
+ let M = [];
1076
+ const k = g.getFullYear(), { start: x, end: b } = z(k), y = a.getFullYear();
1077
+ for (let r = x; r < b; r++) {
1078
+ let i = f && new Date(r, 0, 1) < f || u && new Date(r, 11, 31) > u;
1079
+ M.push({ year: r, active: r === y, isDisabled: i });
1076
1080
  }
1077
- const a = (l) => {
1078
- (!f || l >= f) && (!u || l <= u) && (e ? (c(l), o(l), g(l)) : (s("months"), g(l)));
1081
+ const s = (r) => {
1082
+ (!f || r >= f) && (!u || r <= u) && (e ? (c(r), l(r), h(r)) : (o("months"), h(r)));
1079
1083
  };
1080
- return /* @__PURE__ */ t("div", { className: "sa-calendar-years-preview", children: x.map((l, i) => /* @__PURE__ */ t(
1084
+ return /* @__PURE__ */ t("div", { className: "sa-calendar-years-preview", children: M.map((r, i) => /* @__PURE__ */ t(
1081
1085
  "p",
1082
1086
  {
1083
- className: l.active ? "sa-calendar-months-active" : "",
1087
+ className: r.active ? "sa-calendar-months-active" : "",
1084
1088
  style: {
1085
- color: l.isDisabled ? "#ccc" : void 0,
1086
- pointerEvents: l.isDisabled ? "none" : void 0,
1087
- cursor: l.isDisabled ? "not-allowed" : "pointer",
1089
+ color: r.isDisabled ? "#ccc" : void 0,
1090
+ pointerEvents: r.isDisabled ? "none" : void 0,
1091
+ cursor: r.isDisabled ? "not-allowed" : "pointer",
1088
1092
  ...n ? {} : { width: "100%" }
1089
1093
  },
1090
1094
  onClick: () => {
1091
- l.isDisabled || a(new Date(l.year, 0));
1095
+ r.isDisabled || s(new Date(r.year, 0));
1092
1096
  },
1093
- children: l.year
1097
+ children: r.year
1094
1098
  },
1095
1099
  i
1096
1100
  )) });
1097
- }, ie = ({
1098
- setViews: r,
1101
+ }, de = ({
1102
+ setViews: a,
1099
1103
  views: e,
1100
- filter: s,
1101
- previewDate: o,
1104
+ filter: o,
1105
+ previewDate: l,
1102
1106
  setPreviewDate: c
1103
1107
  }) => {
1104
- const p = () => {
1105
- s || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
1106
- }, g = () => {
1108
+ const g = () => {
1109
+ o || a((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
1110
+ }, h = () => {
1107
1111
  if (e === "years") {
1108
1112
  c((n) => new Date(n.getFullYear() + 10, 0));
1109
1113
  return;
@@ -1133,74 +1137,75 @@ const E = (r) => {
1133
1137
  )
1134
1138
  );
1135
1139
  };
1136
- return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1137
- /* @__PURE__ */ t(R, { onClick: () => f() }),
1138
- /* @__PURE__ */ t("div", { style: { cursor: "pointer" }, onClick: p, children: (() => {
1140
+ return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
1141
+ /* @__PURE__ */ t(U, { onClick: () => f() }),
1142
+ /* @__PURE__ */ t("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
1139
1143
  if (e === "days")
1140
- return `${L[o.getMonth()]} ${o.getFullYear()}`;
1144
+ return `${L[l.getMonth()]} ${l.getFullYear()}`;
1141
1145
  if (e === "months")
1142
- return `${o.getFullYear()}`;
1146
+ return `${l.getFullYear()}`;
1143
1147
  if (e === "years")
1144
- return `${j(o.getFullYear()).start} ~ ${j(o.getFullYear()).end}`;
1148
+ return `${z(l.getFullYear()).start} ~ ${z(l.getFullYear()).end}`;
1145
1149
  })() }),
1146
- /* @__PURE__ */ t(U, { onClick: () => g() })
1150
+ /* @__PURE__ */ t(G, { onClick: () => h() })
1147
1151
  ] });
1148
- }, A = "sa-calendar-styles", de = (r) => {
1149
- if (!document.getElementById(A)) {
1152
+ }, J = "sa-calendar-styles", ce = (a) => {
1153
+ if (!document.getElementById(J)) {
1150
1154
  const e = document.createElement("style");
1151
- e.id = A, e.textContent = r, document.head.appendChild(e);
1155
+ e.id = J, e.textContent = a, document.head.appendChild(e);
1152
1156
  }
1153
1157
  };
1154
- de(B);
1155
- const ce = W(
1158
+ ce(V);
1159
+ const ue = W(
1156
1160
  ({
1157
- value: r,
1161
+ value: a,
1158
1162
  onChange: e,
1159
- filter: s,
1160
- input: o = !0,
1163
+ filter: o,
1164
+ input: l = !0,
1161
1165
  disabled: c,
1162
- minDate: p,
1163
- maxDate: g,
1166
+ minDate: g,
1167
+ maxDate: h,
1164
1168
  placeholder: f,
1165
1169
  size: u,
1166
1170
  status: n,
1167
- clearable: x
1168
- }, b) => {
1169
- const { ref: v, isComponentVisible: k, setIsComponentVisible: y } = P(!1), a = S(null), [l, i] = N("days"), [m, d] = N(/* @__PURE__ */ new Date()), [h, M] = N(/* @__PURE__ */ new Date());
1171
+ clearable: M,
1172
+ fullWidth: k = !1
1173
+ }, x) => {
1174
+ const { ref: b, isComponentVisible: y, setIsComponentVisible: s } = R(!1), r = B(null), [i, m] = N("days"), [d, p] = N(/* @__PURE__ */ new Date()), [w, C] = N(/* @__PURE__ */ new Date());
1170
1175
  D(() => {
1171
- r ? (d(r), M(r)) : (d(/* @__PURE__ */ new Date()), M(/* @__PURE__ */ new Date()));
1172
- }, [r]), D(() => {
1173
- s && i(s);
1174
- }, [s]), D(() => {
1175
- s || i("days");
1176
- }, [k]), D(() => {
1177
- o || y(!0);
1178
- }, [o]);
1179
- const F = () => r ? s === "days" ? I(m) : s === "months" ? `${L[m.getMonth()]} ${m.getFullYear()}` : s === "years" ? m.getFullYear() : I(m) : "", C = () => {
1180
- if (a.current && v.current && o) {
1181
- const w = v.current.getBoundingClientRect(), Y = a.current.getBoundingClientRect();
1182
- window.innerWidth < w.left + Y.width ? a.current.style.left = `${w.left - Y.width + w.width}px` : a.current.style.left = `${w.left}px`, w.top + Y.height > window.innerHeight ? a.current.style.top = `${w.y - (w.height + Y.height - 28)}px` : a.current.style.top = `${w.y + w.height}px`;
1176
+ a ? (p(a), C(a)) : (p(/* @__PURE__ */ new Date()), C(/* @__PURE__ */ new Date()));
1177
+ }, [a]), D(() => {
1178
+ o && m(o);
1179
+ }, [o]), D(() => {
1180
+ o || m("days");
1181
+ }, [y]), D(() => {
1182
+ l || s(!0);
1183
+ }, [l]);
1184
+ const T = () => a ? o === "days" ? S(d) : o === "months" ? `${L[d.getMonth()]} ${d.getFullYear()}` : o === "years" ? d.getFullYear() : S(d) : "", Y = () => {
1185
+ if (r.current && b.current && l) {
1186
+ const v = b.current.getBoundingClientRect(), $ = r.current.getBoundingClientRect();
1187
+ window.innerWidth < v.left + $.width ? r.current.style.left = `${v.left - $.width + v.width}px` : r.current.style.left = `${v.left}px`, v.top + $.height > window.innerHeight ? r.current.style.top = `${v.y - (v.height + $.height - 28)}px` : r.current.style.top = `${v.y + v.height}px`;
1183
1188
  }
1184
1189
  };
1185
1190
  return D(() => {
1186
- a.current && v.current && o && C();
1187
- }, [a, v, k]), D(() => {
1188
- const w = b == null ? void 0 : b.current;
1189
- return w && w.addEventListener("scroll", C), window.addEventListener("scroll", C), () => {
1190
- w && w.removeEventListener("scroll", C), window.removeEventListener("scroll", C);
1191
+ r.current && b.current && l && Y();
1192
+ }, [r, b, y]), D(() => {
1193
+ const v = x == null ? void 0 : x.current;
1194
+ return v && v.addEventListener("scroll", Y), window.addEventListener("scroll", Y), () => {
1195
+ v && v.removeEventListener("scroll", Y), window.removeEventListener("scroll", Y);
1191
1196
  };
1192
- }, []), /* @__PURE__ */ $(
1197
+ }, []), /* @__PURE__ */ F(
1193
1198
  "div",
1194
1199
  {
1195
- className: "sa-calendar-wrapper",
1196
- style: { height: o ? "auto" : "100%" },
1197
- ref: o ? v : null,
1200
+ className: `sa-calendar-wrapper${k ? " sa-calendar-wrapper-fullwidth" : ""}`,
1201
+ style: { height: l ? "auto" : "100%" },
1202
+ ref: l ? b : null,
1198
1203
  children: [
1199
- o ? /* @__PURE__ */ t(
1200
- te,
1204
+ l ? /* @__PURE__ */ t(
1205
+ se,
1201
1206
  {
1202
- value: F(),
1203
- onClick: () => y(!0),
1207
+ value: T(),
1208
+ onClick: () => s(!0),
1204
1209
  onChange: () => {
1205
1210
  },
1206
1211
  placeholder: f,
@@ -1208,67 +1213,67 @@ const ce = W(
1208
1213
  size: u,
1209
1214
  status: n,
1210
1215
  inputMode: "none",
1211
- clearable: x,
1216
+ clearable: M,
1212
1217
  onClear: () => e(void 0)
1213
1218
  }
1214
1219
  ) : null,
1215
- k ? /* @__PURE__ */ $(
1220
+ y ? /* @__PURE__ */ F(
1216
1221
  "div",
1217
1222
  {
1218
- className: `sa-calendar ${o ? "" : "sa-calendar-no-input"}`,
1219
- ref: a,
1223
+ className: `sa-calendar ${l ? "" : "sa-calendar-no-input"}`,
1224
+ ref: r,
1220
1225
  children: [
1221
1226
  /* @__PURE__ */ t(
1222
- ie,
1227
+ de,
1223
1228
  {
1224
- setViews: i,
1225
- views: l,
1226
- filter: s,
1227
- previewDate: h,
1228
- setPreviewDate: M,
1229
- isComponentVisible: k
1229
+ setViews: m,
1230
+ views: i,
1231
+ filter: o,
1232
+ previewDate: w,
1233
+ setPreviewDate: C,
1234
+ isComponentVisible: y
1230
1235
  }
1231
1236
  ),
1232
- /* @__PURE__ */ t("div", { className: "sa-calendar-body", children: l === "days" ? /* @__PURE__ */ t(
1233
- se,
1237
+ /* @__PURE__ */ t("div", { className: "sa-calendar-body", children: i === "days" ? /* @__PURE__ */ t(
1238
+ oe,
1234
1239
  {
1235
- date: m,
1236
- setDate: d,
1237
- previewDate: h,
1238
- setPreviewDate: M,
1239
- setIsComponentVisible: y,
1240
- input: o,
1241
- minDate: p,
1242
- maxDate: g,
1240
+ date: d,
1241
+ setDate: p,
1242
+ previewDate: w,
1243
+ setPreviewDate: C,
1244
+ setIsComponentVisible: s,
1245
+ input: l,
1246
+ minDate: g,
1247
+ maxDate: h,
1243
1248
  onChange: e
1244
1249
  }
1245
- ) : l === "months" ? /* @__PURE__ */ t(
1246
- oe,
1250
+ ) : i === "months" ? /* @__PURE__ */ t(
1251
+ le,
1247
1252
  {
1248
- date: m,
1249
- setDate: d,
1250
- previewDate: h,
1251
- setPreviewDate: M,
1252
- filter: s,
1253
- setViews: i,
1253
+ date: d,
1254
+ setDate: p,
1255
+ previewDate: w,
1256
+ setPreviewDate: C,
1257
+ filter: o,
1258
+ setViews: m,
1254
1259
  onChange: e,
1255
- minDate: p,
1256
- maxDate: g,
1257
- input: o
1260
+ minDate: g,
1261
+ maxDate: h,
1262
+ input: l
1258
1263
  }
1259
1264
  ) : /* @__PURE__ */ t(
1260
- le,
1265
+ ie,
1261
1266
  {
1262
- date: m,
1263
- setDate: d,
1264
- previewDate: h,
1265
- setPreviewDate: M,
1266
- filter: s,
1267
- setViews: i,
1267
+ date: d,
1268
+ setDate: p,
1269
+ previewDate: w,
1270
+ setPreviewDate: C,
1271
+ filter: o,
1272
+ setViews: m,
1268
1273
  onChange: e,
1269
- minDate: p,
1270
- maxDate: g,
1271
- input: o
1274
+ minDate: g,
1275
+ maxDate: h,
1276
+ input: l
1272
1277
  }
1273
1278
  ) })
1274
1279
  ]
@@ -1278,54 +1283,57 @@ const ce = W(
1278
1283
  }
1279
1284
  );
1280
1285
  }
1281
- ), ge = W(
1286
+ ), pe = W(
1282
1287
  ({
1283
- value: r,
1288
+ value: a,
1284
1289
  onChange: e,
1285
- filter: s,
1286
- input: o = !0,
1290
+ filter: o,
1291
+ input: l = !0,
1287
1292
  rangedDate: c,
1288
- disabled: p,
1289
- minDate: g,
1293
+ disabled: g,
1294
+ minDate: h,
1290
1295
  maxDate: f,
1291
1296
  placeholder: u,
1292
1297
  size: n,
1293
- status: x,
1294
- clearable: b
1295
- }, v) => /* @__PURE__ */ t(G, { children: c ? /* @__PURE__ */ t(
1296
- ae,
1298
+ status: M,
1299
+ clearable: k,
1300
+ fullWidth: x
1301
+ }, b) => /* @__PURE__ */ t(q, { children: c ? /* @__PURE__ */ t(
1302
+ re,
1297
1303
  {
1298
1304
  onChange: e,
1299
- value: r,
1300
- input: o,
1301
- filter: s,
1302
- disabled: p,
1303
- ref: v,
1304
- minDate: g,
1305
+ value: a,
1306
+ input: l,
1307
+ filter: o,
1308
+ disabled: g,
1309
+ ref: b,
1310
+ minDate: h,
1305
1311
  maxDate: f,
1306
1312
  placeholder: u,
1307
1313
  size: n,
1308
- status: x,
1309
- clearable: b
1314
+ status: M,
1315
+ clearable: k,
1316
+ fullWidth: x
1310
1317
  }
1311
1318
  ) : /* @__PURE__ */ t(
1312
- ce,
1319
+ ue,
1313
1320
  {
1314
1321
  onChange: e,
1315
- value: r,
1316
- input: o,
1317
- filter: s,
1318
- disabled: p,
1319
- ref: v,
1320
- minDate: g,
1322
+ value: a,
1323
+ input: l,
1324
+ filter: o,
1325
+ disabled: g,
1326
+ ref: b,
1327
+ minDate: h,
1321
1328
  maxDate: f,
1322
1329
  placeholder: u,
1323
1330
  size: n,
1324
- status: x,
1325
- clearable: b
1331
+ status: M,
1332
+ clearable: k,
1333
+ fullWidth: x
1326
1334
  }
1327
1335
  ) })
1328
1336
  );
1329
1337
  export {
1330
- ge as StarasiaDate
1338
+ pe as StarasiaDate
1331
1339
  };