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