@starasia/date 2.0.2 → 3.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,4 +1,4 @@
1
- import { jsxs as $, jsx as l, Fragment as G } from "react/jsx-runtime";
1
+ import { jsxs as $, jsx as i, Fragment as G } from "react/jsx-runtime";
2
2
  import { useState as F, useRef as T, useEffect as D, forwardRef as j } from "react";
3
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");
4
4
 
@@ -27,11 +27,11 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
27
27
  --sa-date-border-error: var(--sa-color-error-500, #ff4d6d);
28
28
  --sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
29
29
  }
30
- .starasia-calendar-wrapper {
30
+ .sa-calendar-wrapper {
31
31
  position: relative;
32
32
  }
33
33
 
34
- .starasia-calendar {
34
+ .sa-calendar {
35
35
  border-radius: var(--sa-date-radius);
36
36
  border: var(--sa-border, 1px) solid var(--sa-date-bg);
37
37
  background: var(--sa-date-bg);
@@ -45,7 +45,7 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
45
45
  z-index: 999;
46
46
  }
47
47
 
48
- .starasia-calendar.starasia-calendar-no-input {
48
+ .sa-calendar.sa-calendar-no-input {
49
49
  position: relative !important;
50
50
  margin-top: 0px;
51
51
 
@@ -59,7 +59,7 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
59
59
  border-radius: 0;
60
60
  }
61
61
 
62
- .starasia-calendar-header {
62
+ .sa-calendar-header {
63
63
  display: flex;
64
64
  flex-direction: row;
65
65
  align-items: center;
@@ -67,25 +67,25 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
67
67
  gap: var(--sa-spacing-xs, 4px);
68
68
  }
69
69
 
70
- .starasia-calendar-days-name-preivew {
70
+ .sa-calendar-days-name-preivew {
71
71
  display: flex;
72
72
  gap: var(--sa-spacing-sm, 8px);
73
73
  }
74
74
 
75
- .starasia-calendar-days-name-preivew p {
75
+ .sa-calendar-days-name-preivew p {
76
76
  color: var(--sa-date-text-subtle);
77
77
  font-size: var(--sa-font-size-md, 14px);
78
78
  flex: 1;
79
79
  display: grid;
80
80
  place-content: center;
81
81
  }
82
- .starasia-calendar-days-number-preivew {
82
+ .sa-calendar-days-number-preivew {
83
83
  display: grid;
84
84
  grid-template-columns: repeat(7, 1fr);
85
85
  gap: var(--sa-spacing-sm, 8px);
86
86
  }
87
87
 
88
- .starasia-calendar-days-number-preivew p {
88
+ .sa-calendar-days-number-preivew p {
89
89
  font-size: var(--sa-font-size-md, 14px);
90
90
  text-align: center;
91
91
  width: 35px;
@@ -98,31 +98,31 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
98
98
  border-radius: var(--sa-date-radius);
99
99
  }
100
100
 
101
- .starasia-calendar-days {
101
+ .sa-calendar-days {
102
102
  color: var(--sa-date-text-muted);
103
103
  }
104
- .starasia-calendar-days-current {
104
+ .sa-calendar-days-current {
105
105
  color: var(--sa-date-text-primary);
106
106
  }
107
107
 
108
- .starasia-calendar-days-number-preivew p:hover {
108
+ .sa-calendar-days-number-preivew p:hover {
109
109
  background: var(--sa-date-brand-subtle);
110
110
  color: var(--sa-date-brand-secondary);
111
111
  }
112
112
 
113
- .starasia-calendar-days-active {
113
+ .sa-calendar-days-active {
114
114
  background: var(--sa-date-brand-secondary);
115
115
  color: var(--sa-date-brand);
116
116
  }
117
117
 
118
118
  /* MONTH STYLING */
119
- .starasia-calendar-months-preview {
119
+ .sa-calendar-months-preview {
120
120
  display: grid;
121
121
  grid-template-columns: repeat(3, 1fr);
122
122
  row-gap: var(--sa-spacing-xs, 4px);
123
123
  }
124
124
 
125
- .starasia-calendar-months-preview p {
125
+ .sa-calendar-months-preview p {
126
126
  width: 98px;
127
127
  height: 48px;
128
128
  display: grid;
@@ -131,23 +131,23 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
131
131
  border-radius: var(--sa-date-radius);
132
132
  }
133
133
 
134
- .starasia-calendar-months-preview p:hover {
134
+ .sa-calendar-months-preview p:hover {
135
135
  background: var(--sa-date-brand-subtle);
136
136
  color: var(--sa-date-brand-secondary);
137
137
  }
138
138
 
139
- .starasia-calendar-months-active {
139
+ .sa-calendar-months-active {
140
140
  background: var(--sa-date-brand-secondary);
141
141
  color: var(--sa-date-brand);
142
142
  }
143
143
  /* Year STYLING */
144
- .starasia-calendar-years-preview {
144
+ .sa-calendar-years-preview {
145
145
  display: grid;
146
146
  grid-template-columns: repeat(3, 1fr);
147
147
  row-gap: var(--sa-spacing-xs, 4px);
148
148
  }
149
149
 
150
- .starasia-calendar-years-preview p {
150
+ .sa-calendar-years-preview p {
151
151
  width: 98px;
152
152
  height: 48px;
153
153
  display: grid;
@@ -156,19 +156,19 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
156
156
  border-radius: var(--sa-date-radius);
157
157
  }
158
158
 
159
- .starasia-calendar-years-preview p:hover {
159
+ .sa-calendar-years-preview p:hover {
160
160
  background: var(--sa-date-brand-subtle);
161
161
  color: var(--sa-date-brand-secondary);
162
162
  }
163
163
 
164
- .starasia-calendar-years-active {
164
+ .sa-calendar-years-active {
165
165
  background: var(--sa-date-brand-secondary);
166
166
  color: var(--sa-date-brand);
167
167
  }
168
168
 
169
169
  /* INPUT */
170
170
 
171
- .starasia-calendar-input-container {
171
+ .sa-calendar-input-container {
172
172
  box-sizing: border-box;
173
173
  overflow: hidden;
174
174
  display: flex;
@@ -177,17 +177,17 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
177
177
  cursor: pointer;
178
178
  }
179
179
 
180
- .starasia-calendar-input-container:has(input:focus) {
180
+ .sa-calendar-input-container:has(input:focus) {
181
181
  border-color: var(--sa-date-brand);
182
182
  box-shadow: 0px 0px 0px 2px var(--sa-date-brand-subtle);
183
183
  }
184
- .starasia-calendar-input-container:has(input:disabled) {
184
+ .sa-calendar-input-container:has(input:disabled) {
185
185
  border-color: var(--sa-date-border-disabled);
186
186
  background-color: var(--sa-date-bg-disabled);
187
187
  pointer-events: none;
188
188
  }
189
189
 
190
- .starasia-calendar-input-outline {
190
+ .sa-calendar-input-outline {
191
191
  border-color: var(--sa-date-border-color);
192
192
  /* border-color: var(--sa-date-text-muted); */
193
193
  background-color: transparent;
@@ -198,31 +198,31 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
198
198
  /* padding-inline: var(--sa-spacing-3, 12px); */
199
199
  }
200
200
 
201
- .starasia-calendar-input-container.sm {
201
+ .sa-calendar-input-container.sm {
202
202
  height: var(--sa-h-8, 32px);
203
203
  border-radius: var(--sa-date-radius);
204
204
  font-size: var(--sa-font-size-sm, 12px);
205
205
  padding-inline: var(--sa-spacing-sm, 8px);
206
206
  }
207
- .starasia-calendar-input-container.md {
207
+ .sa-calendar-input-container.md {
208
208
  height: 38px;
209
209
  border-radius: var(--sa-date-radius);
210
210
  font-size: var(--sa-font-size-md, 14px);
211
211
  padding-inline: var(--sa-spacing-3, 12px);
212
212
  }
213
- .starasia-calendar-input-container.lg {
213
+ .sa-calendar-input-container.lg {
214
214
  height: var(--sa-h-12, 48px);
215
215
  border-radius: var(--sa-date-radius-lg);
216
216
  font-size: var(--sa-font-size-lg, 16px);
217
217
  padding-inline: var(--sa-spacing-3, 12px);
218
218
  }
219
219
 
220
- .starasia-calendar-input-preview-container {
220
+ .sa-calendar-input-preview-container {
221
221
  width: 100%;
222
222
  position: relative;
223
223
  }
224
224
 
225
- .starasia-calendar-input {
225
+ .sa-calendar-input {
226
226
  width: 100%;
227
227
  box-sizing: border-box;
228
228
  height: 100%;
@@ -234,24 +234,24 @@ const S = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
234
234
  cursor: pointer;
235
235
  }
236
236
 
237
- .starasia-calendar-input::placeholder {
237
+ .sa-calendar-input::placeholder {
238
238
  color: var(--sa-date-placeholder);
239
239
  font-weight: var(--sa-font-weight-normal, 300);
240
240
  }
241
241
 
242
242
  /* INPUT ICON */
243
- .starasia-calendar-input-container-icon-left {
243
+ .sa-calendar-input-container-icon-left {
244
244
  display: flex;
245
245
  }
246
- .starasia-calendar-input-container-icon-right {
246
+ .sa-calendar-input-container-icon-right {
247
247
  display: flex;
248
248
  }
249
249
 
250
- .starasia-calendar-input-container-error {
250
+ .sa-calendar-input-container-error {
251
251
  border-color: var(--sa-date-border-error) !important;
252
252
  }
253
253
 
254
- .starasia-calendar-input-container-warning {
254
+ .sa-calendar-input-container-warning {
255
255
  border-color: var(--sa-date-border-warning) !important;
256
256
  }
257
257
  `, J = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], N = [
@@ -289,7 +289,7 @@ function A(a) {
289
289
  document.removeEventListener("click", o, !0);
290
290
  }), []), { ref: s, isComponentVisible: e, setIsComponentVisible: t };
291
291
  }
292
- const z = "starasia-calendar-input-styles", q = (a) => {
292
+ const z = "sa-calendar-input-styles", q = (a) => {
293
293
  if (!document.getElementById(z)) {
294
294
  const e = document.createElement("style");
295
295
  e.id = z, e.textContent = a, document.head.appendChild(e);
@@ -310,10 +310,10 @@ const E = (a) => {
310
310
  return /* @__PURE__ */ $(
311
311
  "div",
312
312
  {
313
- className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${e} `,
313
+ className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
314
314
  onClick: f,
315
315
  children: [
316
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
316
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ i(
317
317
  "svg",
318
318
  {
319
319
  xmlns: "http://www.w3.org/2000/svg",
@@ -321,7 +321,7 @@ const E = (a) => {
321
321
  height: E(e),
322
322
  viewBox: "0 0 20 20",
323
323
  fill: "none",
324
- children: /* @__PURE__ */ l(
324
+ children: /* @__PURE__ */ i(
325
325
  "path",
326
326
  {
327
327
  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,17 +333,17 @@ const E = (a) => {
333
333
  )
334
334
  }
335
335
  ) }),
336
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-preview-container", children: /* @__PURE__ */ l(
336
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ i(
337
337
  "input",
338
338
  {
339
- className: "starasia-calendar-input",
339
+ className: "sa-calendar-input",
340
340
  ...o,
341
341
  disabled: t === "disable" ? !0 : o.disabled,
342
342
  value: o.value,
343
343
  ref: g
344
344
  }
345
345
  ) }),
346
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-right", children: /* @__PURE__ */ l(
346
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ i(
347
347
  "svg",
348
348
  {
349
349
  xmlns: "http://www.w3.org/2000/svg",
@@ -351,7 +351,7 @@ const E = (a) => {
351
351
  height: E(e),
352
352
  viewBox: "0 0 20 20",
353
353
  fill: "none",
354
- children: /* @__PURE__ */ l(
354
+ children: /* @__PURE__ */ i(
355
355
  "path",
356
356
  {
357
357
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -397,30 +397,30 @@ const E = (a) => {
397
397
  const x = (c) => {
398
398
  e(c);
399
399
  }, M = (c) => {
400
- var i;
400
+ var l;
401
401
  let y = { ...t };
402
402
  if (y.from && y.to)
403
403
  y = { from: c, to: null };
404
404
  else {
405
- const p = ((i = y.from) == null ? void 0 : i.getTime()) || 0;
405
+ const p = ((l = y.from) == null ? void 0 : l.getTime()) || 0;
406
406
  c.getTime() > p ? y = { from: y.from, to: c } : y = { from: c, to: y.from };
407
407
  }
408
408
  s(y), o(y);
409
409
  };
410
- return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
411
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: J.map((c, y) => /* @__PURE__ */ l("p", { children: c }, y)) }),
412
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: w.map((c, y) => {
410
+ 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
413
  var C;
414
- const i = 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__ */ l(
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(
416
416
  "p",
417
417
  {
418
- className: `${c.currentMonth ? "starasia-calendar-days-current" : "starasia-calendar-days"} ${c.selected ? "starasia-calendar-days-active" : ""}`,
418
+ className: `${c.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${c.selected ? "sa-calendar-days-active" : ""}`,
419
419
  style: {
420
- backgroundColor: i ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
420
+ backgroundColor: l ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
421
421
  pointerEvents: p ? "none" : void 0,
422
422
  cursor: p ? "not-allowed" : "pointer",
423
- color: p ? "var(--sa-color-gray-400, #b7b9be)" : i ? "var(--sa-color-gray-500, #8c8f97)" : "",
423
+ color: p ? "var(--sa-color-gray-400, #b7b9be)" : l ? "var(--sa-color-gray-500, #8c8f97)" : "",
424
424
  ...b ? {} : { width: "100%" }
425
425
  },
426
426
  onClick: () => {
@@ -457,13 +457,13 @@ const E = (a) => {
457
457
  }
458
458
  g(r), f(r);
459
459
  };
460
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, r) => {
461
- var y, i, p;
460
+ return /* @__PURE__ */ i("div", { className: "sa-calendar-months-preview", children: N.map((u, r) => {
461
+ var y, l, p;
462
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__ */ l(
463
+ return /* @__PURE__ */ i(
464
464
  "p",
465
465
  {
466
- className: w === v && (r === ((i = o.from) == null ? void 0 : i.getMonth()) || r === ((p = o.to) == null ? void 0 : p.getMonth())) ? "starasia-calendar-months-active" : "",
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" : "",
467
467
  style: {
468
468
  backgroundColor: d ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
469
469
  pointerEvents: c ? "none" : void 0,
@@ -497,47 +497,47 @@ const E = (a) => {
497
497
  var y;
498
498
  let w = [];
499
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 i = x; i < M; i++) {
501
- const p = new Date(i, 0), C = (!b || p >= b) && (!h || p <= h), k = i === u || i === r, m = p > o.from && p < o.to;
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
502
  w.push({
503
- year: i,
503
+ year: l,
504
504
  active: k && C,
505
505
  highlight: m && C,
506
506
  disabled: !C
507
507
  });
508
508
  }
509
- const d = (i) => {
510
- e ? (c(i), s(i)) : (s(i), t("months"));
511
- }, c = (i) => {
509
+ const d = (l) => {
510
+ e ? (c(l), s(l)) : (s(l), t("months"));
511
+ }, c = (l) => {
512
512
  var C;
513
513
  let p = { ...o };
514
514
  if (p.from && p.to)
515
- p = { from: i, to: null };
515
+ p = { from: l, to: null };
516
516
  else {
517
517
  const k = ((C = p.from) == null ? void 0 : C.getTime()) || 0;
518
- i.getTime() > k ? p = { from: p.from, to: i } : p = { from: i, to: p.from };
518
+ l.getTime() > k ? p = { from: p.from, to: l } : p = { from: l, to: p.from };
519
519
  }
520
520
  g(p), f(p);
521
521
  };
522
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((i, p) => /* @__PURE__ */ l(
522
+ return /* @__PURE__ */ i("div", { className: "sa-calendar-years-preview", children: w.map((l, p) => /* @__PURE__ */ i(
523
523
  "p",
524
524
  {
525
- className: `${i.active ? "starasia-calendar-months-active" : ""} ${i.highlight ? "starasia-calendar-months-highlight" : ""} ${i.disabled ? "starasia-calendar-disabled" : ""}`,
525
+ className: `${l.active ? "sa-calendar-months-active" : ""} ${l.highlight ? "sa-calendar-months-highlight" : ""} ${l.disabled ? "sa-calendar-disabled" : ""}`,
526
526
  onClick: () => {
527
- i.disabled || d(new Date(i.year, 0));
527
+ l.disabled || d(new Date(l.year, 0));
528
528
  },
529
529
  style: {
530
- backgroundColor: i.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
531
- color: i.highlight ? "var(--sa-color-gray-500, #8c8f97)" : i.active ? "" : i.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
532
- cursor: i.disabled ? "not-allowed" : "pointer",
533
- pointerEvents: i.disbled ? "none" : "all",
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",
534
534
  ...n ? {} : { width: "100%" }
535
535
  },
536
- children: i.year
536
+ children: l.year
537
537
  },
538
538
  p
539
539
  )) });
540
- }, P = ({ ...a }) => /* @__PURE__ */ l(
540
+ }, P = ({ ...a }) => /* @__PURE__ */ i(
541
541
  "svg",
542
542
  {
543
543
  xmlns: "http://www.w3.org/2000/svg",
@@ -546,7 +546,7 @@ const E = (a) => {
546
546
  viewBox: "0 0 20 20",
547
547
  fill: "none",
548
548
  ...a,
549
- children: /* @__PURE__ */ l(
549
+ children: /* @__PURE__ */ i(
550
550
  "path",
551
551
  {
552
552
  d: "M12.5 3.33334L5.83337 10L12.5 16.6667",
@@ -557,7 +557,7 @@ const E = (a) => {
557
557
  }
558
558
  )
559
559
  }
560
- ), R = ({ ...a }) => /* @__PURE__ */ l(
560
+ ), R = ({ ...a }) => /* @__PURE__ */ i(
561
561
  "svg",
562
562
  {
563
563
  xmlns: "http://www.w3.org/2000/svg",
@@ -566,7 +566,7 @@ const E = (a) => {
566
566
  viewBox: "0 0 20 20",
567
567
  fill: "none",
568
568
  ...a,
569
- children: /* @__PURE__ */ l(
569
+ children: /* @__PURE__ */ i(
570
570
  "path",
571
571
  {
572
572
  d: "M7.5 16.6667L14.1667 10L7.5 3.33334",
@@ -612,9 +612,9 @@ const E = (a) => {
612
612
  )
613
613
  );
614
614
  };
615
- return /* @__PURE__ */ $("div", { className: "starasia-calendar-header", children: [
616
- /* @__PURE__ */ l(P, { onClick: () => b() }),
617
- /* @__PURE__ */ l("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
615
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
616
+ /* @__PURE__ */ i(P, { onClick: () => b() }),
617
+ /* @__PURE__ */ i("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
618
618
  if (e === "days")
619
619
  return `${N[s.getMonth()]} ${s.getFullYear()}`;
620
620
  if (e === "months")
@@ -622,14 +622,14 @@ const E = (a) => {
622
622
  if (e === "years")
623
623
  return `${B(s.getFullYear()).start} ~ ${B(s.getFullYear()).end}`;
624
624
  })() }),
625
- /* @__PURE__ */ l(R, { onClick: () => f() })
625
+ /* @__PURE__ */ i(R, { onClick: () => f() })
626
626
  ] });
627
627
  };
628
628
  function L(a) {
629
629
  const e = new Date(a), t = e.getFullYear(), s = e.getMonth();
630
630
  return `${e.getDate().toString().padStart(2, "0")} ${U[s]} ${t}`;
631
631
  }
632
- const W = "starasia-calendar-styles", ee = (a) => {
632
+ const W = "sa-calendar-styles", ee = (a) => {
633
633
  if (!document.getElementById(W)) {
634
634
  const e = document.createElement("style");
635
635
  e.id = W, e.textContent = a, document.head.appendChild(e);
@@ -649,7 +649,7 @@ const ne = j(
649
649
  size: h,
650
650
  status: n
651
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()), [i, p] = F({
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
653
  from: (a == null ? void 0 : a.from) || /* @__PURE__ */ new Date(),
654
654
  to: (a == null ? void 0 : a.to) || /* @__PURE__ */ new Date()
655
655
  });
@@ -671,13 +671,13 @@ const ne = j(
671
671
  return "";
672
672
  if (t) {
673
673
  if (r === "days")
674
- return `${L(i.from)} ~ ${L(i.to || i.from) || "-"}`;
674
+ return `${L(l.from)} ~ ${L(l.to || l.from) || "-"}`;
675
675
  if (r === "months")
676
- return `${N[i.from.getMonth()]} ~ ${i.to ? N[i.to.getMonth()] : "-"}`;
676
+ return `${N[l.from.getMonth()]} ~ ${l.to ? N[l.to.getMonth()] : "-"}`;
677
677
  if (r === "years")
678
- return `${(m = i.from) == null ? void 0 : m.getFullYear()} ~ ${((Y = i.to) == null ? void 0 : Y.getFullYear()) || "-"}`;
678
+ return `${(m = l.from) == null ? void 0 : m.getFullYear()} ~ ${((Y = l.to) == null ? void 0 : Y.getFullYear()) || "-"}`;
679
679
  } else
680
- return `${L(i.from)} ~ ${L(i.to || i.from) || "-"}`;
680
+ return `${L(l.from)} ~ ${L(l.to || l.from) || "-"}`;
681
681
  }, k = () => {
682
682
  if (u.current && v.current && s) {
683
683
  const m = v.current.getBoundingClientRect(), Y = u.current.getBoundingClientRect();
@@ -694,11 +694,11 @@ const ne = j(
694
694
  }, []), /* @__PURE__ */ $(
695
695
  "div",
696
696
  {
697
- className: "starasia-calendar-wrapper",
697
+ className: "sa-calendar-wrapper",
698
698
  style: { height: s ? "auto" : "100%" },
699
699
  ref: s ? v : null,
700
700
  children: [
701
- s ? /* @__PURE__ */ l(
701
+ s ? /* @__PURE__ */ i(
702
702
  K,
703
703
  {
704
704
  value: C(),
@@ -717,10 +717,10 @@ const ne = j(
717
717
  x ? /* @__PURE__ */ $(
718
718
  "div",
719
719
  {
720
- className: `starasia-calendar ${s ? "" : "starasia-calendar-no-input"}`,
720
+ className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
721
721
  ref: u,
722
722
  children: [
723
- /* @__PURE__ */ l(
723
+ /* @__PURE__ */ i(
724
724
  _,
725
725
  {
726
726
  setViews: d,
@@ -730,27 +730,27 @@ const ne = j(
730
730
  setDate: y
731
731
  }
732
732
  ),
733
- /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: r === "days" ? /* @__PURE__ */ l(
733
+ /* @__PURE__ */ i("div", { className: "sa-calendar-body", children: r === "days" ? /* @__PURE__ */ i(
734
734
  Q,
735
735
  {
736
736
  date: c,
737
737
  setDate: y,
738
738
  setIsComponentVisible: M,
739
- dateRange: i,
739
+ dateRange: l,
740
740
  setDateRange: p,
741
741
  input: s,
742
742
  onChange: e,
743
743
  minDate: g,
744
744
  maxDate: f
745
745
  }
746
- ) : r === "months" ? /* @__PURE__ */ l(
746
+ ) : r === "months" ? /* @__PURE__ */ i(
747
747
  X,
748
748
  {
749
749
  date: c,
750
750
  setDate: y,
751
751
  filter: t,
752
752
  setViews: d,
753
- dateRange: i,
753
+ dateRange: l,
754
754
  setDateRange: p,
755
755
  setIsComponentVisible: M,
756
756
  input: s,
@@ -758,14 +758,14 @@ const ne = j(
758
758
  minDate: g,
759
759
  maxDate: f
760
760
  }
761
- ) : /* @__PURE__ */ l(
761
+ ) : /* @__PURE__ */ i(
762
762
  Z,
763
763
  {
764
764
  date: c,
765
765
  setDate: y,
766
766
  filter: t,
767
767
  setViews: d,
768
- dateRange: i,
768
+ dateRange: l,
769
769
  setDateRange: p,
770
770
  setIsComponentVisible: M,
771
771
  input: s,
@@ -781,7 +781,7 @@ const ne = j(
781
781
  }
782
782
  );
783
783
  }
784
- ), O = "starasia-calendar-input-styles", ae = (a) => {
784
+ ), O = "sa-calendar-input-styles", ae = (a) => {
785
785
  if (!document.getElementById(O)) {
786
786
  const e = document.createElement("style");
787
787
  e.id = O, e.textContent = a, document.head.appendChild(e);
@@ -802,10 +802,10 @@ const I = (a) => {
802
802
  return /* @__PURE__ */ $(
803
803
  "div",
804
804
  {
805
- className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${e} `,
805
+ className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
806
806
  onClick: f,
807
807
  children: [
808
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
808
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ i(
809
809
  "svg",
810
810
  {
811
811
  xmlns: "http://www.w3.org/2000/svg",
@@ -813,7 +813,7 @@ const I = (a) => {
813
813
  height: I(e),
814
814
  viewBox: "0 0 20 20",
815
815
  fill: "none",
816
- children: /* @__PURE__ */ l(
816
+ children: /* @__PURE__ */ i(
817
817
  "path",
818
818
  {
819
819
  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,17 +825,17 @@ const I = (a) => {
825
825
  )
826
826
  }
827
827
  ) }),
828
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-preview-container", children: /* @__PURE__ */ l(
828
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ i(
829
829
  "input",
830
830
  {
831
- className: "starasia-calendar-input",
831
+ className: "sa-calendar-input",
832
832
  ...o,
833
833
  disabled: t === "disable" ? !0 : o.disabled,
834
834
  value: o.value,
835
835
  ref: g
836
836
  }
837
837
  ) }),
838
- /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-right", children: /* @__PURE__ */ l(
838
+ /* @__PURE__ */ i("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ i(
839
839
  "svg",
840
840
  {
841
841
  xmlns: "http://www.w3.org/2000/svg",
@@ -843,7 +843,7 @@ const I = (a) => {
843
843
  height: I(e),
844
844
  viewBox: "0 0 20 20",
845
845
  fill: "none",
846
- children: /* @__PURE__ */ l(
846
+ children: /* @__PURE__ */ i(
847
847
  "path",
848
848
  {
849
849
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -893,14 +893,14 @@ const I = (a) => {
893
893
  const u = (r) => {
894
894
  (!g || r >= g) && (!f || r <= f) && (e(r), h(r), s(r), b && o(!1));
895
895
  };
896
- return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
897
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: J.map((r, d) => /* @__PURE__ */ l("p", { children: r }, d)) }),
898
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: v.map((r, d) => {
896
+ 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
899
  const c = r.isDisabled;
900
- return /* @__PURE__ */ l(
900
+ return /* @__PURE__ */ i(
901
901
  "p",
902
902
  {
903
- className: `${r.currentMonth ? "starasia-calendar-days-current" : "starasia-calendar-days"} ${r.selected ? "starasia-calendar-days-active" : ""}`,
903
+ className: `${r.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${r.selected ? "sa-calendar-days-active" : ""}`,
904
904
  style: {
905
905
  color: c ? "#ccc" : void 0,
906
906
  pointerEvents: c ? "none" : void 0,
@@ -931,12 +931,12 @@ const I = (a) => {
931
931
  const w = a.getMonth(), v = a.getFullYear(), x = g.getFullYear(), M = (u) => {
932
932
  (!b || u >= b) && (!h || u <= h) && (t ? (o(u), e(u), f(u)) : (s("days"), f(u)));
933
933
  };
934
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, r) => {
934
+ return /* @__PURE__ */ i("div", { className: "sa-calendar-months-preview", children: N.map((u, r) => {
935
935
  const d = b && new Date(x, r, 1) < b || h && new Date(x, r + 1, 0) > h;
936
- return /* @__PURE__ */ l(
936
+ return /* @__PURE__ */ i(
937
937
  "p",
938
938
  {
939
- className: r === w && x === v ? "starasia-calendar-months-active" : "",
939
+ className: r === w && x === v ? "sa-calendar-months-active" : "",
940
940
  style: {
941
941
  color: d ? "#ccc" : void 0,
942
942
  pointerEvents: d ? "none" : void 0,
@@ -975,10 +975,10 @@ const I = (a) => {
975
975
  const r = (d) => {
976
976
  (!b || d >= b) && (!h || d <= h) && (e ? (o(d), s(d), f(d)) : (t("months"), f(d)));
977
977
  };
978
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((d, c) => /* @__PURE__ */ l(
978
+ return /* @__PURE__ */ i("div", { className: "sa-calendar-years-preview", children: w.map((d, c) => /* @__PURE__ */ i(
979
979
  "p",
980
980
  {
981
- className: d.active ? "starasia-calendar-months-active" : "",
981
+ className: d.active ? "sa-calendar-months-active" : "",
982
982
  style: {
983
983
  color: d.isDisabled ? "#ccc" : void 0,
984
984
  pointerEvents: d.isDisabled ? "none" : void 0,
@@ -992,7 +992,7 @@ const I = (a) => {
992
992
  },
993
993
  c
994
994
  )) });
995
- }, ie = ({
995
+ }, le = ({
996
996
  setViews: a,
997
997
  views: e,
998
998
  filter: t,
@@ -1031,9 +1031,9 @@ const I = (a) => {
1031
1031
  )
1032
1032
  );
1033
1033
  };
1034
- return /* @__PURE__ */ $("div", { className: "starasia-calendar-header", children: [
1035
- /* @__PURE__ */ l(P, { onClick: () => b() }),
1036
- /* @__PURE__ */ l("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
1034
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1035
+ /* @__PURE__ */ i(P, { onClick: () => b() }),
1036
+ /* @__PURE__ */ i("div", { style: { cursor: "pointer" }, onClick: g, children: (() => {
1037
1037
  if (e === "days")
1038
1038
  return `${N[s.getMonth()]} ${s.getFullYear()}`;
1039
1039
  if (e === "months")
@@ -1041,15 +1041,15 @@ const I = (a) => {
1041
1041
  if (e === "years")
1042
1042
  return `${V(s.getFullYear()).start} ~ ${V(s.getFullYear()).end}`;
1043
1043
  })() }),
1044
- /* @__PURE__ */ l(R, { onClick: () => f() })
1044
+ /* @__PURE__ */ i(R, { onClick: () => f() })
1045
1045
  ] });
1046
- }, H = "starasia-calendar-styles", le = (a) => {
1046
+ }, H = "sa-calendar-styles", ie = (a) => {
1047
1047
  if (!document.getElementById(H)) {
1048
1048
  const e = document.createElement("style");
1049
1049
  e.id = H, e.textContent = a, document.head.appendChild(e);
1050
1050
  }
1051
1051
  };
1052
- le(S);
1052
+ ie(S);
1053
1053
  const de = j(
1054
1054
  ({
1055
1055
  value: a,
@@ -1063,7 +1063,7 @@ const de = j(
1063
1063
  size: h,
1064
1064
  status: n
1065
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()), [i, p] = F(/* @__PURE__ */ new Date());
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());
1067
1067
  D(() => {
1068
1068
  a ? (y(a), p(a)) : (y(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1069
1069
  }, [a]), D(() => {
@@ -1089,11 +1089,11 @@ const de = j(
1089
1089
  }, []), /* @__PURE__ */ $(
1090
1090
  "div",
1091
1091
  {
1092
- className: "starasia-calendar-wrapper",
1092
+ className: "sa-calendar-wrapper",
1093
1093
  style: { height: s ? "auto" : "100%" },
1094
1094
  ref: s ? v : null,
1095
1095
  children: [
1096
- s ? /* @__PURE__ */ l(
1096
+ s ? /* @__PURE__ */ i(
1097
1097
  re,
1098
1098
  {
1099
1099
  value: C(),
@@ -1110,26 +1110,26 @@ const de = j(
1110
1110
  x ? /* @__PURE__ */ $(
1111
1111
  "div",
1112
1112
  {
1113
- className: `starasia-calendar ${s ? "" : "starasia-calendar-no-input"}`,
1113
+ className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
1114
1114
  ref: u,
1115
1115
  children: [
1116
- /* @__PURE__ */ l(
1117
- ie,
1116
+ /* @__PURE__ */ i(
1117
+ le,
1118
1118
  {
1119
1119
  setViews: d,
1120
1120
  views: r,
1121
1121
  filter: t,
1122
- previewDate: i,
1122
+ previewDate: l,
1123
1123
  setPreviewDate: p,
1124
1124
  isComponentVisible: x
1125
1125
  }
1126
1126
  ),
1127
- /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: r === "days" ? /* @__PURE__ */ l(
1127
+ /* @__PURE__ */ i("div", { className: "sa-calendar-body", children: r === "days" ? /* @__PURE__ */ i(
1128
1128
  te,
1129
1129
  {
1130
1130
  date: c,
1131
1131
  setDate: y,
1132
- previewDate: i,
1132
+ previewDate: l,
1133
1133
  setPreviewDate: p,
1134
1134
  setIsComponentVisible: M,
1135
1135
  input: s,
@@ -1137,12 +1137,12 @@ const de = j(
1137
1137
  maxDate: f,
1138
1138
  onChange: e
1139
1139
  }
1140
- ) : r === "months" ? /* @__PURE__ */ l(
1140
+ ) : r === "months" ? /* @__PURE__ */ i(
1141
1141
  se,
1142
1142
  {
1143
1143
  date: c,
1144
1144
  setDate: y,
1145
- previewDate: i,
1145
+ previewDate: l,
1146
1146
  setPreviewDate: p,
1147
1147
  filter: t,
1148
1148
  setViews: d,
@@ -1151,12 +1151,12 @@ const de = j(
1151
1151
  maxDate: f,
1152
1152
  input: s
1153
1153
  }
1154
- ) : /* @__PURE__ */ l(
1154
+ ) : /* @__PURE__ */ i(
1155
1155
  oe,
1156
1156
  {
1157
1157
  date: c,
1158
1158
  setDate: y,
1159
- previewDate: i,
1159
+ previewDate: l,
1160
1160
  setPreviewDate: p,
1161
1161
  filter: t,
1162
1162
  setViews: d,
@@ -1186,7 +1186,7 @@ const de = j(
1186
1186
  placeholder: h,
1187
1187
  size: n,
1188
1188
  status: w
1189
- }, v) => /* @__PURE__ */ l(G, { children: o ? /* @__PURE__ */ l(
1189
+ }, v) => /* @__PURE__ */ i(G, { children: o ? /* @__PURE__ */ i(
1190
1190
  ne,
1191
1191
  {
1192
1192
  onChange: e,
@@ -1201,7 +1201,7 @@ const de = j(
1201
1201
  size: n,
1202
1202
  status: w
1203
1203
  }
1204
- ) : /* @__PURE__ */ l(
1204
+ ) : /* @__PURE__ */ i(
1205
1205
  de,
1206
1206
  {
1207
1207
  onChange: e,
package/dist/date.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Y,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(Y=typeof globalThis<"u"?globalThis:Y||self,n(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,n,m){"use strict";const E=`@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
+ (function(Y,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],a):(Y=typeof globalThis<"u"?globalThis:Y||self,a(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,a,m){"use strict";const E=`@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");
2
2
 
3
3
  * {
4
4
  margin: 0;
@@ -25,11 +25,11 @@
25
25
  --sa-date-border-error: var(--sa-color-error-500, #ff4d6d);
26
26
  --sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
27
27
  }
28
- .starasia-calendar-wrapper {
28
+ .sa-calendar-wrapper {
29
29
  position: relative;
30
30
  }
31
31
 
32
- .starasia-calendar {
32
+ .sa-calendar {
33
33
  border-radius: var(--sa-date-radius);
34
34
  border: var(--sa-border, 1px) solid var(--sa-date-bg);
35
35
  background: var(--sa-date-bg);
@@ -43,7 +43,7 @@
43
43
  z-index: 999;
44
44
  }
45
45
 
46
- .starasia-calendar.starasia-calendar-no-input {
46
+ .sa-calendar.sa-calendar-no-input {
47
47
  position: relative !important;
48
48
  margin-top: 0px;
49
49
 
@@ -57,7 +57,7 @@
57
57
  border-radius: 0;
58
58
  }
59
59
 
60
- .starasia-calendar-header {
60
+ .sa-calendar-header {
61
61
  display: flex;
62
62
  flex-direction: row;
63
63
  align-items: center;
@@ -65,25 +65,25 @@
65
65
  gap: var(--sa-spacing-xs, 4px);
66
66
  }
67
67
 
68
- .starasia-calendar-days-name-preivew {
68
+ .sa-calendar-days-name-preivew {
69
69
  display: flex;
70
70
  gap: var(--sa-spacing-sm, 8px);
71
71
  }
72
72
 
73
- .starasia-calendar-days-name-preivew p {
73
+ .sa-calendar-days-name-preivew p {
74
74
  color: var(--sa-date-text-subtle);
75
75
  font-size: var(--sa-font-size-md, 14px);
76
76
  flex: 1;
77
77
  display: grid;
78
78
  place-content: center;
79
79
  }
80
- .starasia-calendar-days-number-preivew {
80
+ .sa-calendar-days-number-preivew {
81
81
  display: grid;
82
82
  grid-template-columns: repeat(7, 1fr);
83
83
  gap: var(--sa-spacing-sm, 8px);
84
84
  }
85
85
 
86
- .starasia-calendar-days-number-preivew p {
86
+ .sa-calendar-days-number-preivew p {
87
87
  font-size: var(--sa-font-size-md, 14px);
88
88
  text-align: center;
89
89
  width: 35px;
@@ -96,31 +96,31 @@
96
96
  border-radius: var(--sa-date-radius);
97
97
  }
98
98
 
99
- .starasia-calendar-days {
99
+ .sa-calendar-days {
100
100
  color: var(--sa-date-text-muted);
101
101
  }
102
- .starasia-calendar-days-current {
102
+ .sa-calendar-days-current {
103
103
  color: var(--sa-date-text-primary);
104
104
  }
105
105
 
106
- .starasia-calendar-days-number-preivew p:hover {
106
+ .sa-calendar-days-number-preivew p:hover {
107
107
  background: var(--sa-date-brand-subtle);
108
108
  color: var(--sa-date-brand-secondary);
109
109
  }
110
110
 
111
- .starasia-calendar-days-active {
111
+ .sa-calendar-days-active {
112
112
  background: var(--sa-date-brand-secondary);
113
113
  color: var(--sa-date-brand);
114
114
  }
115
115
 
116
116
  /* MONTH STYLING */
117
- .starasia-calendar-months-preview {
117
+ .sa-calendar-months-preview {
118
118
  display: grid;
119
119
  grid-template-columns: repeat(3, 1fr);
120
120
  row-gap: var(--sa-spacing-xs, 4px);
121
121
  }
122
122
 
123
- .starasia-calendar-months-preview p {
123
+ .sa-calendar-months-preview p {
124
124
  width: 98px;
125
125
  height: 48px;
126
126
  display: grid;
@@ -129,23 +129,23 @@
129
129
  border-radius: var(--sa-date-radius);
130
130
  }
131
131
 
132
- .starasia-calendar-months-preview p:hover {
132
+ .sa-calendar-months-preview p:hover {
133
133
  background: var(--sa-date-brand-subtle);
134
134
  color: var(--sa-date-brand-secondary);
135
135
  }
136
136
 
137
- .starasia-calendar-months-active {
137
+ .sa-calendar-months-active {
138
138
  background: var(--sa-date-brand-secondary);
139
139
  color: var(--sa-date-brand);
140
140
  }
141
141
  /* Year STYLING */
142
- .starasia-calendar-years-preview {
142
+ .sa-calendar-years-preview {
143
143
  display: grid;
144
144
  grid-template-columns: repeat(3, 1fr);
145
145
  row-gap: var(--sa-spacing-xs, 4px);
146
146
  }
147
147
 
148
- .starasia-calendar-years-preview p {
148
+ .sa-calendar-years-preview p {
149
149
  width: 98px;
150
150
  height: 48px;
151
151
  display: grid;
@@ -154,19 +154,19 @@
154
154
  border-radius: var(--sa-date-radius);
155
155
  }
156
156
 
157
- .starasia-calendar-years-preview p:hover {
157
+ .sa-calendar-years-preview p:hover {
158
158
  background: var(--sa-date-brand-subtle);
159
159
  color: var(--sa-date-brand-secondary);
160
160
  }
161
161
 
162
- .starasia-calendar-years-active {
162
+ .sa-calendar-years-active {
163
163
  background: var(--sa-date-brand-secondary);
164
164
  color: var(--sa-date-brand);
165
165
  }
166
166
 
167
167
  /* INPUT */
168
168
 
169
- .starasia-calendar-input-container {
169
+ .sa-calendar-input-container {
170
170
  box-sizing: border-box;
171
171
  overflow: hidden;
172
172
  display: flex;
@@ -175,17 +175,17 @@
175
175
  cursor: pointer;
176
176
  }
177
177
 
178
- .starasia-calendar-input-container:has(input:focus) {
178
+ .sa-calendar-input-container:has(input:focus) {
179
179
  border-color: var(--sa-date-brand);
180
180
  box-shadow: 0px 0px 0px 2px var(--sa-date-brand-subtle);
181
181
  }
182
- .starasia-calendar-input-container:has(input:disabled) {
182
+ .sa-calendar-input-container:has(input:disabled) {
183
183
  border-color: var(--sa-date-border-disabled);
184
184
  background-color: var(--sa-date-bg-disabled);
185
185
  pointer-events: none;
186
186
  }
187
187
 
188
- .starasia-calendar-input-outline {
188
+ .sa-calendar-input-outline {
189
189
  border-color: var(--sa-date-border-color);
190
190
  /* border-color: var(--sa-date-text-muted); */
191
191
  background-color: transparent;
@@ -196,31 +196,31 @@
196
196
  /* padding-inline: var(--sa-spacing-3, 12px); */
197
197
  }
198
198
 
199
- .starasia-calendar-input-container.sm {
199
+ .sa-calendar-input-container.sm {
200
200
  height: var(--sa-h-8, 32px);
201
201
  border-radius: var(--sa-date-radius);
202
202
  font-size: var(--sa-font-size-sm, 12px);
203
203
  padding-inline: var(--sa-spacing-sm, 8px);
204
204
  }
205
- .starasia-calendar-input-container.md {
205
+ .sa-calendar-input-container.md {
206
206
  height: 38px;
207
207
  border-radius: var(--sa-date-radius);
208
208
  font-size: var(--sa-font-size-md, 14px);
209
209
  padding-inline: var(--sa-spacing-3, 12px);
210
210
  }
211
- .starasia-calendar-input-container.lg {
211
+ .sa-calendar-input-container.lg {
212
212
  height: var(--sa-h-12, 48px);
213
213
  border-radius: var(--sa-date-radius-lg);
214
214
  font-size: var(--sa-font-size-lg, 16px);
215
215
  padding-inline: var(--sa-spacing-3, 12px);
216
216
  }
217
217
 
218
- .starasia-calendar-input-preview-container {
218
+ .sa-calendar-input-preview-container {
219
219
  width: 100%;
220
220
  position: relative;
221
221
  }
222
222
 
223
- .starasia-calendar-input {
223
+ .sa-calendar-input {
224
224
  width: 100%;
225
225
  box-sizing: border-box;
226
226
  height: 100%;
@@ -232,24 +232,24 @@
232
232
  cursor: pointer;
233
233
  }
234
234
 
235
- .starasia-calendar-input::placeholder {
235
+ .sa-calendar-input::placeholder {
236
236
  color: var(--sa-date-placeholder);
237
237
  font-weight: var(--sa-font-weight-normal, 300);
238
238
  }
239
239
 
240
240
  /* INPUT ICON */
241
- .starasia-calendar-input-container-icon-left {
241
+ .sa-calendar-input-container-icon-left {
242
242
  display: flex;
243
243
  }
244
- .starasia-calendar-input-container-icon-right {
244
+ .sa-calendar-input-container-icon-right {
245
245
  display: flex;
246
246
  }
247
247
 
248
- .starasia-calendar-input-container-error {
248
+ .sa-calendar-input-container-error {
249
249
  border-color: var(--sa-date-border-error) !important;
250
250
  }
251
251
 
252
- .starasia-calendar-input-container-warning {
252
+ .sa-calendar-input-container-warning {
253
253
  border-color: var(--sa-date-border-warning) !important;
254
254
  }
255
- `,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(r){const[e,s]=m.useState(r),o=m.useRef(null),l=g=>{o.current&&!o.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(r=>{if(!document.getElementById(V)){const e=document.createElement("style");e.id=V,e.textContent=r,document.head.appendChild(e)}})(E);const S=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},P=r=>{const{size:e="md",status:s="default",variant:o="outline",...l}=r,g=m.useRef(null),p=()=>{g.current&&l.onClick&&(g.current.focus(),l.onClick(""))};return n.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${o} starasia-calendar-input-container-${s} ${e} `,onClick:p,children:[n.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(e),height:S(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"starasia-calendar-input-preview-container",children:n.jsx("input",{className:"starasia-calendar-input",...l,disabled:s==="disable"?!0:l.disabled,value:l.value,ref:g})}),n.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(e),height:S(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},q=({date:r,setDate:e,dateRange:s,setDateRange:o,onChange:l,minDate:g,maxDate:p,input:w})=>{var h,t,d;let u=new Date(r.getFullYear(),r.getMonth(),1),a=u.getDay(),x=[];const b=r.getMonth();for(let c=0;c<42;c++){c===0&&a===0?u.setDate(u.getDate()-7):c===0?u.setDate(u.getDate()+(c-a)):u.setDate(u.getDate()+1);let y={currentMonth:u.getMonth()===b,date:new Date(u),month:u.getMonth(),number:u.getDate(),selected:u.toDateString()===((h=s.from)==null?void 0:h.toDateString())||u.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((d=s.from)==null?void 0:d.toDateString())),year:u.getFullYear(),isDisabled:g&&u<g||p&&u>p};x.push(y)}const M=c=>{e(c)},k=c=>{var i;let y={...s};if(y.from&&y.to)y={from:c,to:null};else{const f=((i=y.from)==null?void 0:i.getTime())||0;c.getTime()>f?y={from:y.from,to:c}:y={from:c,to:y.from}}o(y),l(y)};return n.jsxs("div",{className:"starasia-calendar-days-preivew",children:[n.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((c,y)=>n.jsx("p",{children:c},y))}),n.jsx("div",{className:"starasia-calendar-days-number-preivew",children:x.map((c,y)=>{var D;const i=c.date.getTime()>s.from.getTime()&&c.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),f=c.isDisabled;return n.jsx("p",{className:`${c.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${c.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:i?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:f?"none":void 0,cursor:f?"not-allowed":"pointer",color:f?"var(--sa-color-gray-400, #b7b9be)":i?"var(--sa-color-gray-500, #8c8f97)":"",...w?{}:{width:"100%"}},onClick:()=>{f||(M(c.date),k(c.date))},children:c.number},y)})})]})},G=({date:r,setDate:e,filter:s,setViews:o,dateRange:l,setDateRange:g,onChange:p,minDate:w,maxDate:u,input:a})=>{const x=l.from.getFullYear(),b=r.getFullYear(),M=h=>{s?(k(h),e(h)):(o("days"),e(h))},k=h=>{var d;let t={...l};if(t.from&&t.to)t={from:h,to:null};else{const c=((d=t.from)==null?void 0:d.getTime())||0;h.getTime()>c?t={from:t.from,to:h}:t={from:h,to:t.from}}g(t),p(t)};return n.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((h,t)=>{var y,i,f;const d=new Date(b,t).getTime()>l.from.getTime()&&new Date(b,t).getTime()<(((y=l.to)==null?void 0:y.getTime())||l.from.getTime()),c=w&&new Date(b,t)<w||u&&new Date(b,t)>u;return n.jsx("p",{className:x===b&&(t===((i=l.from)==null?void 0:i.getMonth())||t===((f=l.to)==null?void 0:f.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:d?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",color:c?"var(--sa-color-gray-400, #b7b9be)":d?"var(--sa-color-gray-500, #8c8f97)":"",...a?{}:{width:"100%"}},onClick:()=>{c||M(new Date(b,t))},children:h.slice(0,3)},t)})})},T=r=>{const e=Math.floor(r/10)*10,s=e+10;return{start:e,end:s}},U=({date:r,filter:e,setViews:s,setDate:o,dateRange:l,setDateRange:g,onChange:p,minDate:w,maxDate:u,input:a})=>{var y;let x=[];const b=r.getFullYear(),{start:M,end:k}=T(b),h=l.from.getFullYear(),t=(y=l.to)==null?void 0:y.getFullYear();for(let i=M;i<k;i++){const f=new Date(i,0),D=(!w||f>=w)&&(!u||f<=u),C=i===h||i===t,v=f>l.from&&f<l.to;x.push({year:i,active:C&&D,highlight:v&&D,disabled:!D})}const d=i=>{e?(c(i),o(i)):(o(i),s("months"))},c=i=>{var D;let f={...l};if(f.from&&f.to)f={from:i,to:null};else{const C=((D=f.from)==null?void 0:D.getTime())||0;i.getTime()>C?f={from:f.from,to:i}:f={from:i,to:f.from}}g(f),p(f)};return n.jsx("div",{className:"starasia-calendar-years-preview",children:x.map((i,f)=>n.jsx("p",{className:`${i.active?"starasia-calendar-months-active":""} ${i.highlight?"starasia-calendar-months-highlight":""} ${i.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{i.disabled||d(new Date(i.year,0))},style:{backgroundColor:i.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:i.highlight?"var(--sa-color-gray-500, #8c8f97)":i.active?"":i.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:i.disabled?"not-allowed":"pointer",pointerEvents:i.disbled?"none":"all",...a?{}:{width:"100%"}},children:i.year},f))})},z=({...r})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),O=({...r})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:r,views:e,filter:s,date:o,setDate:l})=>{const g=()=>{s||r(a=>a==="days"?"months":a==="months"?"years":"days")},p=()=>{if(e==="years"){l(a=>new Date(a.getFullYear()+10,0));return}if(e==="months"){l(a=>new Date(a.getFullYear()+1,a.getMonth()));return}l(a=>new Date(a.getFullYear(),a.getMonth()+1))},w=()=>{if(e==="years"){l(a=>new Date(a.getFullYear()-10,0));return}if(e==="months"){l(a=>new Date(a.getFullYear()-1,a.getMonth()));return}l(a=>new Date(a.getMonth()===0?a.getFullYear()-1:a.getFullYear(),a.getMonth()===0?11:a.getMonth()-1))},u=()=>{if(e==="days")return`${F[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${T(o.getFullYear()).start} ~ ${T(o.getFullYear()).end}`};return n.jsxs("div",{className:"starasia-calendar-header",children:[n.jsx(z,{onClick:()=>w()}),n.jsx("div",{style:{cursor:"pointer"},onClick:g,children:u()}),n.jsx(O,{onClick:()=>p()})]})};function N(r){const e=new Date(r),s=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${A[o]} ${s}`}const W="starasia-calendar-styles";(r=>{if(!document.getElementById(W)){const e=document.createElement("style");e.id=W,e.textContent=r,document.head.appendChild(e)}})(E);const Q=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,disabled:l,minDate:g,maxDate:p,placeholder:w,size:u,status:a},x)=>{const{ref:b,isComponentVisible:M,setIsComponentVisible:k}=B(!1),h=m.useRef(null),[t,d]=m.useState("days"),[c,y]=m.useState(new Date),[i,f]=m.useState({from:(r==null?void 0:r.from)||new Date,to:(r==null?void 0:r.to)||new Date});m.useEffect(()=>{r?(y(r.from),f(r)):(y(new Date),f({from:new Date,to:new Date}))},[r]),m.useEffect(()=>{s&&d(s)},[s]),m.useEffect(()=>{s||d("days")},[M]),m.useEffect(()=>{o||k(!0)},[o]);const D=()=>{var v,$;if(!r)return"";if(s){if(t==="days")return`${N(i.from)} ~ ${N(i.to||i.from)||"-"}`;if(t==="months")return`${F[i.from.getMonth()]} ~ ${i.to?F[i.to.getMonth()]:"-"}`;if(t==="years")return`${(v=i.from)==null?void 0:v.getFullYear()} ~ ${(($=i.to)==null?void 0:$.getFullYear())||"-"}`}else return`${N(i.from)} ~ ${N(i.to||i.from)||"-"}`},C=()=>{if(h.current&&b.current&&o){const v=b.current.getBoundingClientRect(),$=h.current.getBoundingClientRect();window.innerWidth<v.left+$.width?h.current.style.left=`${v.left-$.width+v.width}px`:h.current.style.left=`${v.left}px`,v.top+$.height>window.innerHeight?h.current.style.top=`${v.y-(v.height+$.height-28)}px`:h.current.style.top=`${v.y+v.height}px`}};return m.useEffect(()=>{h.current&&b.current&&o&&C()},[h,b,M]),m.useEffect(()=>{const v=x==null?void 0:x.current;return v&&v.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{v&&v.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),n.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?b:null,children:[o?n.jsx(P,{value:D(),inputMode:"none",onClick:()=>{k(!0)},onChange:()=>{},disabled:l,placeholder:w,size:u,status:a}):null,M?n.jsxs("div",{className:`starasia-calendar ${o?"":"starasia-calendar-no-input"}`,ref:h,children:[n.jsx(K,{setViews:d,views:t,filter:s,date:c,setDate:y}),n.jsx("div",{className:"starasia-calendar-body",children:t==="days"?n.jsx(q,{date:c,setDate:y,setIsComponentVisible:k,dateRange:i,setDateRange:f,input:o,onChange:e,minDate:g,maxDate:p}):t==="months"?n.jsx(G,{date:c,setDate:y,filter:s,setViews:d,dateRange:i,setDateRange:f,setIsComponentVisible:k,input:o,onChange:e,minDate:g,maxDate:p}):n.jsx(U,{date:c,setDate:y,filter:s,setViews:d,dateRange:i,setDateRange:f,setIsComponentVisible:k,input:o,onChange:e,minDate:g,maxDate:p})})]}):null]})}),H="starasia-calendar-input-styles";(r=>{if(!document.getElementById(H)){const e=document.createElement("style");e.id=H,e.textContent=r,document.head.appendChild(e)}})(E);const L=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},X=r=>{const{size:e="md",status:s="default",variant:o="outline",...l}=r,g=m.useRef(null),p=()=>{g.current&&l.onClick&&(g.current.focus(),l.onClick(""))};return n.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${o} starasia-calendar-input-container-${s} ${e} `,onClick:p,children:[n.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(e),height:L(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"starasia-calendar-input-preview-container",children:n.jsx("input",{className:"starasia-calendar-input",...l,disabled:s==="disable"?!0:l.disabled,value:l.value,ref:g})}),n.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(e),height:L(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:r,setDate:e,previewDate:s,setPreviewDate:o,setIsComponentVisible:l,minDate:g,maxDate:p,input:w,onChange:u})=>{let a=new Date(s.getFullYear(),s.getMonth(),1),x=a.getDay(),b=[];const M=r.toDateString(),k=s.getMonth();for(let t=0;t<42;t++){t===0&&x===0?a.setDate(a.getDate()-7):t===0?a.setDate(a.getDate()+(t-x)):a.setDate(a.getDate()+1);let d={currentMonth:a.getMonth()===k,date:new Date(a),month:a.getMonth(),number:a.getDate(),selected:a.toDateString()===M,year:a.getFullYear(),isDisabled:g&&a<g||p&&a>p};b.push(d)}const h=t=>{(!g||t>=g)&&(!p||t<=p)&&(e(t),u(t),o(t),w&&l(!1))};return n.jsxs("div",{className:"starasia-calendar-days-preivew",children:[n.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,d)=>n.jsx("p",{children:t},d))}),n.jsx("div",{className:"starasia-calendar-days-number-preivew",children:b.map((t,d)=>{const c=t.isDisabled;return n.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{c||h(t.date)},children:t.number},d)})})]})},_=({date:r,setDate:e,filter:s,setViews:o,onChange:l,previewDate:g,setPreviewDate:p,minDate:w,maxDate:u,input:a})=>{const x=r.getMonth(),b=r.getFullYear(),M=g.getFullYear(),k=h=>{(!w||h>=w)&&(!u||h<=u)&&(s?(l(h),e(h),p(h)):(o("days"),p(h)))};return n.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((h,t)=>{const d=w&&new Date(M,t,1)<w||u&&new Date(M,t+1,0)>u;return n.jsx("p",{className:t===x&&M===b?"starasia-calendar-months-active":"",style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...a?{}:{width:"100%"}},onClick:()=>{d||k(new Date(M,t))},children:h.slice(0,3)},t)})})},I=r=>{const e=Math.floor(r/10)*10,s=e+10;return{start:e,end:s}},R=({date:r,filter:e,setViews:s,setDate:o,onChange:l,previewDate:g,setPreviewDate:p,minDate:w,maxDate:u,input:a})=>{let x=[];const b=g.getFullYear(),{start:M,end:k}=I(b),h=r.getFullYear();for(let d=M;d<k;d++){let c=w&&new Date(d,0,1)<w||u&&new Date(d,11,31)>u;x.push({year:d,active:d===h,isDisabled:c})}const t=d=>{(!w||d>=w)&&(!u||d<=u)&&(e?(l(d),o(d),p(d)):(s("months"),p(d)))};return n.jsx("div",{className:"starasia-calendar-years-preview",children:x.map((d,c)=>n.jsx("p",{className:d.active?"starasia-calendar-months-active":"",style:{color:d.isDisabled?"#ccc":void 0,pointerEvents:d.isDisabled?"none":void 0,cursor:d.isDisabled?"not-allowed":"pointer",...a?{}:{width:"100%"}},onClick:()=>{d.isDisabled||t(new Date(d.year,0))},children:d.year},c))})},ee=({setViews:r,views:e,filter:s,previewDate:o,setPreviewDate:l})=>{const g=()=>{s||r(a=>a==="days"?"months":a==="months"?"years":"days")},p=()=>{if(e==="years"){l(a=>new Date(a.getFullYear()+10,0));return}if(e==="months"){l(a=>new Date(a.getFullYear()+1,a.getMonth()));return}l(a=>new Date(a.getFullYear(),a.getMonth()+1))},w=()=>{if(e==="years"){l(a=>new Date(a.getFullYear()-10,0));return}if(e==="months"){l(a=>new Date(a.getFullYear()-1,a.getMonth()));return}l(a=>new Date(a.getMonth()===0?a.getFullYear()-1:a.getFullYear(),a.getMonth()===0?11:a.getMonth()-1))},u=()=>{if(e==="days")return`${F[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${I(o.getFullYear()).start} ~ ${I(o.getFullYear()).end}`};return n.jsxs("div",{className:"starasia-calendar-header",children:[n.jsx(z,{onClick:()=>w()}),n.jsx("div",{style:{cursor:"pointer"},onClick:g,children:u()}),n.jsx(O,{onClick:()=>p()})]})},J="starasia-calendar-styles";(r=>{if(!document.getElementById(J)){const e=document.createElement("style");e.id=J,e.textContent=r,document.head.appendChild(e)}})(E);const ae=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,disabled:l,minDate:g,maxDate:p,placeholder:w,size:u,status:a},x)=>{const{ref:b,isComponentVisible:M,setIsComponentVisible:k}=B(!1),h=m.useRef(null),[t,d]=m.useState("days"),[c,y]=m.useState(new Date),[i,f]=m.useState(new Date);m.useEffect(()=>{r?(y(r),f(r)):(y(new Date),f(new Date))},[r]),m.useEffect(()=>{s&&d(s)},[s]),m.useEffect(()=>{s||d("days")},[M]),m.useEffect(()=>{o||k(!0)},[o]);const D=()=>r?s==="days"?N(c):s==="months"?`${F[c.getMonth()]} ${c.getFullYear()}`:s==="years"?c.getFullYear():N(c):"",C=()=>{if(h.current&&b.current&&o){const v=b.current.getBoundingClientRect(),$=h.current.getBoundingClientRect();window.innerWidth<v.left+$.width?h.current.style.left=`${v.left-$.width+v.width}px`:h.current.style.left=`${v.left}px`,v.top+$.height>window.innerHeight?h.current.style.top=`${v.y-(v.height+$.height-28)}px`:h.current.style.top=`${v.y+v.height}px`}};return m.useEffect(()=>{h.current&&b.current&&o&&C()},[h,b,M]),m.useEffect(()=>{const v=x==null?void 0:x.current;return v&&v.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{v&&v.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),n.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?b:null,children:[o?n.jsx(X,{value:D(),onClick:()=>k(!0),onChange:()=>{},placeholder:w,disabled:l,size:u,status:a,inputMode:"none"}):null,M?n.jsxs("div",{className:`starasia-calendar ${o?"":"starasia-calendar-no-input"}`,ref:h,children:[n.jsx(ee,{setViews:d,views:t,filter:s,previewDate:i,setPreviewDate:f,isComponentVisible:M}),n.jsx("div",{className:"starasia-calendar-body",children:t==="days"?n.jsx(Z,{date:c,setDate:y,previewDate:i,setPreviewDate:f,setIsComponentVisible:k,input:o,minDate:g,maxDate:p,onChange:e}):t==="months"?n.jsx(_,{date:c,setDate:y,previewDate:i,setPreviewDate:f,filter:s,setViews:d,onChange:e,minDate:g,maxDate:p,input:o}):n.jsx(R,{date:c,setDate:y,previewDate:i,setPreviewDate:f,filter:s,setViews:d,onChange:e,minDate:g,maxDate:p,input:o})})]}):null]})}),ne=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,rangedDate:l,disabled:g,minDate:p,maxDate:w,placeholder:u,size:a,status:x},b)=>n.jsx(n.Fragment,{children:l?n.jsx(Q,{onChange:e,value:r,input:o,filter:s,disabled:g,ref:b,minDate:p,maxDate:w,placeholder:u,size:a,status:x}):n.jsx(ae,{onChange:e,value:r,input:o,filter:s,disabled:g,ref:b,minDate:p,maxDate:w,placeholder:u,size:a,status:x})}));Y.StarasiaDate=ne,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
255
+ `,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(r){const[e,s]=m.useState(r),o=m.useRef(null),l=g=>{o.current&&!o.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:s}}const V="sa-calendar-input-styles";(r=>{if(!document.getElementById(V)){const e=document.createElement("style");e.id=V,e.textContent=r,document.head.appendChild(e)}})(E);const S=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},P=r=>{const{size:e="md",status:s="default",variant:o="outline",...l}=r,g=m.useRef(null),p=()=>{g.current&&l.onClick&&(g.current.focus(),l.onClick(""))};return a.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:p,children:[a.jsx("div",{className:"sa-calendar-input-container-icon-left",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(e),height:S(e),viewBox:"0 0 20 20",fill:"none",children:a.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),a.jsx("div",{className:"sa-calendar-input-preview-container",children:a.jsx("input",{className:"sa-calendar-input",...l,disabled:s==="disable"?!0:l.disabled,value:l.value,ref:g})}),a.jsx("div",{className:"sa-calendar-input-container-icon-right",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(e),height:S(e),viewBox:"0 0 20 20",fill:"none",children:a.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},q=({date:r,setDate:e,dateRange:s,setDateRange:o,onChange:l,minDate:g,maxDate:p,input:w})=>{var h,t,c;let u=new Date(r.getFullYear(),r.getMonth(),1),n=u.getDay(),x=[];const b=r.getMonth();for(let i=0;i<42;i++){i===0&&n===0?u.setDate(u.getDate()-7):i===0?u.setDate(u.getDate()+(i-n)):u.setDate(u.getDate()+1);let y={currentMonth:u.getMonth()===b,date:new Date(u),month:u.getMonth(),number:u.getDate(),selected:u.toDateString()===((h=s.from)==null?void 0:h.toDateString())||u.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:u.getFullYear(),isDisabled:g&&u<g||p&&u>p};x.push(y)}const M=i=>{e(i)},k=i=>{var d;let y={...s};if(y.from&&y.to)y={from:i,to:null};else{const f=((d=y.from)==null?void 0:d.getTime())||0;i.getTime()>f?y={from:y.from,to:i}:y={from:i,to:y.from}}o(y),l(y)};return a.jsxs("div",{className:"sa-calendar-days-preivew",children:[a.jsx("div",{className:"sa-calendar-days-name-preivew",children:j.map((i,y)=>a.jsx("p",{children:i},y))}),a.jsx("div",{className:"sa-calendar-days-number-preivew",children:x.map((i,y)=>{var D;const d=i.date.getTime()>s.from.getTime()&&i.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),f=i.isDisabled;return a.jsx("p",{className:`${i.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${i.selected?"sa-calendar-days-active":""}`,style:{backgroundColor:d?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:f?"none":void 0,cursor:f?"not-allowed":"pointer",color:f?"var(--sa-color-gray-400, #b7b9be)":d?"var(--sa-color-gray-500, #8c8f97)":"",...w?{}:{width:"100%"}},onClick:()=>{f||(M(i.date),k(i.date))},children:i.number},y)})})]})},G=({date:r,setDate:e,filter:s,setViews:o,dateRange:l,setDateRange:g,onChange:p,minDate:w,maxDate:u,input:n})=>{const x=l.from.getFullYear(),b=r.getFullYear(),M=h=>{s?(k(h),e(h)):(o("days"),e(h))},k=h=>{var c;let t={...l};if(t.from&&t.to)t={from:h,to:null};else{const i=((c=t.from)==null?void 0:c.getTime())||0;h.getTime()>i?t={from:t.from,to:h}:t={from:h,to:t.from}}g(t),p(t)};return a.jsx("div",{className:"sa-calendar-months-preview",children:F.map((h,t)=>{var y,d,f;const c=new Date(b,t).getTime()>l.from.getTime()&&new Date(b,t).getTime()<(((y=l.to)==null?void 0:y.getTime())||l.from.getTime()),i=w&&new Date(b,t)<w||u&&new Date(b,t)>u;return a.jsx("p",{className:x===b&&(t===((d=l.from)==null?void 0:d.getMonth())||t===((f=l.to)==null?void 0:f.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:c?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:i?"none":void 0,cursor:i?"not-allowed":"pointer",color:i?"var(--sa-color-gray-400, #b7b9be)":c?"var(--sa-color-gray-500, #8c8f97)":"",...n?{}:{width:"100%"}},onClick:()=>{i||M(new Date(b,t))},children:h.slice(0,3)},t)})})},T=r=>{const e=Math.floor(r/10)*10,s=e+10;return{start:e,end:s}},U=({date:r,filter:e,setViews:s,setDate:o,dateRange:l,setDateRange:g,onChange:p,minDate:w,maxDate:u,input:n})=>{var y;let x=[];const b=r.getFullYear(),{start:M,end:k}=T(b),h=l.from.getFullYear(),t=(y=l.to)==null?void 0:y.getFullYear();for(let d=M;d<k;d++){const f=new Date(d,0),D=(!w||f>=w)&&(!u||f<=u),C=d===h||d===t,v=f>l.from&&f<l.to;x.push({year:d,active:C&&D,highlight:v&&D,disabled:!D})}const c=d=>{e?(i(d),o(d)):(o(d),s("months"))},i=d=>{var D;let f={...l};if(f.from&&f.to)f={from:d,to:null};else{const C=((D=f.from)==null?void 0:D.getTime())||0;d.getTime()>C?f={from:f.from,to:d}:f={from:d,to:f.from}}g(f),p(f)};return a.jsx("div",{className:"sa-calendar-years-preview",children:x.map((d,f)=>a.jsx("p",{className:`${d.active?"sa-calendar-months-active":""} ${d.highlight?"sa-calendar-months-highlight":""} ${d.disabled?"sa-calendar-disabled":""}`,onClick:()=>{d.disabled||c(new Date(d.year,0))},style:{backgroundColor:d.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:d.highlight?"var(--sa-color-gray-500, #8c8f97)":d.active?"":d.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:d.disabled?"not-allowed":"pointer",pointerEvents:d.disbled?"none":"all",...n?{}:{width:"100%"}},children:d.year},f))})},z=({...r})=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,children:a.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),O=({...r})=>a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,children:a.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:r,views:e,filter:s,date:o,setDate:l})=>{const g=()=>{s||r(n=>n==="days"?"months":n==="months"?"years":"days")},p=()=>{if(e==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(e==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},w=()=>{if(e==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(e==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},u=()=>{if(e==="days")return`${F[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${T(o.getFullYear()).start} ~ ${T(o.getFullYear()).end}`};return a.jsxs("div",{className:"sa-calendar-header",children:[a.jsx(z,{onClick:()=>w()}),a.jsx("div",{style:{cursor:"pointer"},onClick:g,children:u()}),a.jsx(O,{onClick:()=>p()})]})};function N(r){const e=new Date(r),s=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${A[o]} ${s}`}const W="sa-calendar-styles";(r=>{if(!document.getElementById(W)){const e=document.createElement("style");e.id=W,e.textContent=r,document.head.appendChild(e)}})(E);const Q=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,disabled:l,minDate:g,maxDate:p,placeholder:w,size:u,status:n},x)=>{const{ref:b,isComponentVisible:M,setIsComponentVisible:k}=B(!1),h=m.useRef(null),[t,c]=m.useState("days"),[i,y]=m.useState(new Date),[d,f]=m.useState({from:(r==null?void 0:r.from)||new Date,to:(r==null?void 0:r.to)||new Date});m.useEffect(()=>{r?(y(r.from),f(r)):(y(new Date),f({from:new Date,to:new Date}))},[r]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{o||k(!0)},[o]);const D=()=>{var v,$;if(!r)return"";if(s){if(t==="days")return`${N(d.from)} ~ ${N(d.to||d.from)||"-"}`;if(t==="months")return`${F[d.from.getMonth()]} ~ ${d.to?F[d.to.getMonth()]:"-"}`;if(t==="years")return`${(v=d.from)==null?void 0:v.getFullYear()} ~ ${(($=d.to)==null?void 0:$.getFullYear())||"-"}`}else return`${N(d.from)} ~ ${N(d.to||d.from)||"-"}`},C=()=>{if(h.current&&b.current&&o){const v=b.current.getBoundingClientRect(),$=h.current.getBoundingClientRect();window.innerWidth<v.left+$.width?h.current.style.left=`${v.left-$.width+v.width}px`:h.current.style.left=`${v.left}px`,v.top+$.height>window.innerHeight?h.current.style.top=`${v.y-(v.height+$.height-28)}px`:h.current.style.top=`${v.y+v.height}px`}};return m.useEffect(()=>{h.current&&b.current&&o&&C()},[h,b,M]),m.useEffect(()=>{const v=x==null?void 0:x.current;return v&&v.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{v&&v.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),a.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?b:null,children:[o?a.jsx(P,{value:D(),inputMode:"none",onClick:()=>{k(!0)},onChange:()=>{},disabled:l,placeholder:w,size:u,status:n}):null,M?a.jsxs("div",{className:`sa-calendar ${o?"":"sa-calendar-no-input"}`,ref:h,children:[a.jsx(K,{setViews:c,views:t,filter:s,date:i,setDate:y}),a.jsx("div",{className:"sa-calendar-body",children:t==="days"?a.jsx(q,{date:i,setDate:y,setIsComponentVisible:k,dateRange:d,setDateRange:f,input:o,onChange:e,minDate:g,maxDate:p}):t==="months"?a.jsx(G,{date:i,setDate:y,filter:s,setViews:c,dateRange:d,setDateRange:f,setIsComponentVisible:k,input:o,onChange:e,minDate:g,maxDate:p}):a.jsx(U,{date:i,setDate:y,filter:s,setViews:c,dateRange:d,setDateRange:f,setIsComponentVisible:k,input:o,onChange:e,minDate:g,maxDate:p})})]}):null]})}),H="sa-calendar-input-styles";(r=>{if(!document.getElementById(H)){const e=document.createElement("style");e.id=H,e.textContent=r,document.head.appendChild(e)}})(E);const L=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},X=r=>{const{size:e="md",status:s="default",variant:o="outline",...l}=r,g=m.useRef(null),p=()=>{g.current&&l.onClick&&(g.current.focus(),l.onClick(""))};return a.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:p,children:[a.jsx("div",{className:"sa-calendar-input-container-icon-left",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(e),height:L(e),viewBox:"0 0 20 20",fill:"none",children:a.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),a.jsx("div",{className:"sa-calendar-input-preview-container",children:a.jsx("input",{className:"sa-calendar-input",...l,disabled:s==="disable"?!0:l.disabled,value:l.value,ref:g})}),a.jsx("div",{className:"sa-calendar-input-container-icon-right",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(e),height:L(e),viewBox:"0 0 20 20",fill:"none",children:a.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:r,setDate:e,previewDate:s,setPreviewDate:o,setIsComponentVisible:l,minDate:g,maxDate:p,input:w,onChange:u})=>{let n=new Date(s.getFullYear(),s.getMonth(),1),x=n.getDay(),b=[];const M=r.toDateString(),k=s.getMonth();for(let t=0;t<42;t++){t===0&&x===0?n.setDate(n.getDate()-7):t===0?n.setDate(n.getDate()+(t-x)):n.setDate(n.getDate()+1);let c={currentMonth:n.getMonth()===k,date:new Date(n),month:n.getMonth(),number:n.getDate(),selected:n.toDateString()===M,year:n.getFullYear(),isDisabled:g&&n<g||p&&n>p};b.push(c)}const h=t=>{(!g||t>=g)&&(!p||t<=p)&&(e(t),u(t),o(t),w&&l(!1))};return a.jsxs("div",{className:"sa-calendar-days-preivew",children:[a.jsx("div",{className:"sa-calendar-days-name-preivew",children:j.map((t,c)=>a.jsx("p",{children:t},c))}),a.jsx("div",{className:"sa-calendar-days-number-preivew",children:b.map((t,c)=>{const i=t.isDisabled;return a.jsx("p",{className:`${t.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${t.selected?"sa-calendar-days-active":""}`,style:{color:i?"#ccc":void 0,pointerEvents:i?"none":void 0,cursor:i?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{i||h(t.date)},children:t.number},c)})})]})},_=({date:r,setDate:e,filter:s,setViews:o,onChange:l,previewDate:g,setPreviewDate:p,minDate:w,maxDate:u,input:n})=>{const x=r.getMonth(),b=r.getFullYear(),M=g.getFullYear(),k=h=>{(!w||h>=w)&&(!u||h<=u)&&(s?(l(h),e(h),p(h)):(o("days"),p(h)))};return a.jsx("div",{className:"sa-calendar-months-preview",children:F.map((h,t)=>{const c=w&&new Date(M,t,1)<w||u&&new Date(M,t+1,0)>u;return a.jsx("p",{className:t===x&&M===b?"sa-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c||k(new Date(M,t))},children:h.slice(0,3)},t)})})},I=r=>{const e=Math.floor(r/10)*10,s=e+10;return{start:e,end:s}},R=({date:r,filter:e,setViews:s,setDate:o,onChange:l,previewDate:g,setPreviewDate:p,minDate:w,maxDate:u,input:n})=>{let x=[];const b=g.getFullYear(),{start:M,end:k}=I(b),h=r.getFullYear();for(let c=M;c<k;c++){let i=w&&new Date(c,0,1)<w||u&&new Date(c,11,31)>u;x.push({year:c,active:c===h,isDisabled:i})}const t=c=>{(!w||c>=w)&&(!u||c<=u)&&(e?(l(c),o(c),p(c)):(s("months"),p(c)))};return a.jsx("div",{className:"sa-calendar-years-preview",children:x.map((c,i)=>a.jsx("p",{className:c.active?"sa-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},i))})},ee=({setViews:r,views:e,filter:s,previewDate:o,setPreviewDate:l})=>{const g=()=>{s||r(n=>n==="days"?"months":n==="months"?"years":"days")},p=()=>{if(e==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(e==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},w=()=>{if(e==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(e==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},u=()=>{if(e==="days")return`${F[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${I(o.getFullYear()).start} ~ ${I(o.getFullYear()).end}`};return a.jsxs("div",{className:"sa-calendar-header",children:[a.jsx(z,{onClick:()=>w()}),a.jsx("div",{style:{cursor:"pointer"},onClick:g,children:u()}),a.jsx(O,{onClick:()=>p()})]})},J="sa-calendar-styles";(r=>{if(!document.getElementById(J)){const e=document.createElement("style");e.id=J,e.textContent=r,document.head.appendChild(e)}})(E);const ne=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,disabled:l,minDate:g,maxDate:p,placeholder:w,size:u,status:n},x)=>{const{ref:b,isComponentVisible:M,setIsComponentVisible:k}=B(!1),h=m.useRef(null),[t,c]=m.useState("days"),[i,y]=m.useState(new Date),[d,f]=m.useState(new Date);m.useEffect(()=>{r?(y(r),f(r)):(y(new Date),f(new Date))},[r]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{o||k(!0)},[o]);const D=()=>r?s==="days"?N(i):s==="months"?`${F[i.getMonth()]} ${i.getFullYear()}`:s==="years"?i.getFullYear():N(i):"",C=()=>{if(h.current&&b.current&&o){const v=b.current.getBoundingClientRect(),$=h.current.getBoundingClientRect();window.innerWidth<v.left+$.width?h.current.style.left=`${v.left-$.width+v.width}px`:h.current.style.left=`${v.left}px`,v.top+$.height>window.innerHeight?h.current.style.top=`${v.y-(v.height+$.height-28)}px`:h.current.style.top=`${v.y+v.height}px`}};return m.useEffect(()=>{h.current&&b.current&&o&&C()},[h,b,M]),m.useEffect(()=>{const v=x==null?void 0:x.current;return v&&v.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{v&&v.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),a.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?b:null,children:[o?a.jsx(X,{value:D(),onClick:()=>k(!0),onChange:()=>{},placeholder:w,disabled:l,size:u,status:n,inputMode:"none"}):null,M?a.jsxs("div",{className:`sa-calendar ${o?"":"sa-calendar-no-input"}`,ref:h,children:[a.jsx(ee,{setViews:c,views:t,filter:s,previewDate:d,setPreviewDate:f,isComponentVisible:M}),a.jsx("div",{className:"sa-calendar-body",children:t==="days"?a.jsx(Z,{date:i,setDate:y,previewDate:d,setPreviewDate:f,setIsComponentVisible:k,input:o,minDate:g,maxDate:p,onChange:e}):t==="months"?a.jsx(_,{date:i,setDate:y,previewDate:d,setPreviewDate:f,filter:s,setViews:c,onChange:e,minDate:g,maxDate:p,input:o}):a.jsx(R,{date:i,setDate:y,previewDate:d,setPreviewDate:f,filter:s,setViews:c,onChange:e,minDate:g,maxDate:p,input:o})})]}):null]})}),ae=m.forwardRef(({value:r,onChange:e,filter:s,input:o=!0,rangedDate:l,disabled:g,minDate:p,maxDate:w,placeholder:u,size:n,status:x},b)=>a.jsx(a.Fragment,{children:l?a.jsx(Q,{onChange:e,value:r,input:o,filter:s,disabled:g,ref:b,minDate:p,maxDate:w,placeholder:u,size:n,status:x}):a.jsx(ne,{onChange:e,value:r,input:o,filter:s,disabled:g,ref:b,minDate:p,maxDate:w,placeholder:u,size:n,status:x})}));Y.StarasiaDate=ae,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",