@mekari/pixel3-date-picker 0.0.1-dev.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.
Files changed (103) hide show
  1. package/dist/calendar-panel.d.mts +231 -0
  2. package/dist/calendar-panel.d.ts +231 -0
  3. package/dist/calendar-panel.js +1498 -0
  4. package/dist/calendar-panel.mjs +25 -0
  5. package/dist/chunk-26Y3AVJW.mjs +115 -0
  6. package/dist/chunk-3VROFGJH.mjs +34 -0
  7. package/dist/chunk-3YYRUEIF.mjs +257 -0
  8. package/dist/chunk-5PISTT2K.mjs +131 -0
  9. package/dist/chunk-AGAA7XTC.mjs +20 -0
  10. package/dist/chunk-EJCSF5VR.mjs +492 -0
  11. package/dist/chunk-EQWT6VDG.mjs +34 -0
  12. package/dist/chunk-FTR7OMCT.mjs +0 -0
  13. package/dist/chunk-HJ4V3PM6.mjs +125 -0
  14. package/dist/chunk-J5BK7Z2U.mjs +46 -0
  15. package/dist/chunk-JZ2KFYWF.mjs +127 -0
  16. package/dist/chunk-LVCRFE25.mjs +153 -0
  17. package/dist/chunk-NIUQXHGQ.mjs +56 -0
  18. package/dist/chunk-NVULZQVI.mjs +119 -0
  19. package/dist/chunk-OY5PVQH5.mjs +31 -0
  20. package/dist/chunk-Q3Z5ZITX.mjs +155 -0
  21. package/dist/chunk-QZ7VFGWC.mjs +6 -0
  22. package/dist/chunk-V36XV4LV.mjs +129 -0
  23. package/dist/chunk-V6D6W7RO.mjs +0 -0
  24. package/dist/chunk-VACMCDOZ.mjs +8 -0
  25. package/dist/components/calendar/index.d.mts +11 -0
  26. package/dist/components/calendar/index.d.ts +11 -0
  27. package/dist/components/calendar/index.js +548 -0
  28. package/dist/components/calendar/index.mjs +23 -0
  29. package/dist/components/calendar/table-date.d.mts +97 -0
  30. package/dist/components/calendar/table-date.d.ts +97 -0
  31. package/dist/components/calendar/table-date.js +305 -0
  32. package/dist/components/calendar/table-date.mjs +13 -0
  33. package/dist/components/calendar/table-month.d.mts +90 -0
  34. package/dist/components/calendar/table-month.d.ts +90 -0
  35. package/dist/components/calendar/table-month.js +294 -0
  36. package/dist/components/calendar/table-month.mjs +14 -0
  37. package/dist/components/calendar/table-year.d.mts +71 -0
  38. package/dist/components/calendar/table-year.d.ts +71 -0
  39. package/dist/components/calendar/table-year.js +288 -0
  40. package/dist/components/calendar/table-year.mjs +14 -0
  41. package/dist/components/parts/date.d.mts +38 -0
  42. package/dist/components/parts/date.d.ts +38 -0
  43. package/dist/components/parts/date.js +70 -0
  44. package/dist/components/parts/date.mjs +7 -0
  45. package/dist/components/parts/day.d.mts +6 -0
  46. package/dist/components/parts/day.d.ts +6 -0
  47. package/dist/components/parts/day.js +44 -0
  48. package/dist/components/parts/day.mjs +7 -0
  49. package/dist/components/parts/index.d.mts +9 -0
  50. package/dist/components/parts/index.d.ts +9 -0
  51. package/dist/components/parts/index.js +157 -0
  52. package/dist/components/parts/index.mjs +20 -0
  53. package/dist/components/parts/month.d.mts +29 -0
  54. package/dist/components/parts/month.d.ts +29 -0
  55. package/dist/components/parts/month.js +58 -0
  56. package/dist/components/parts/month.mjs +7 -0
  57. package/dist/components/parts/year.d.mts +29 -0
  58. package/dist/components/parts/year.d.ts +29 -0
  59. package/dist/components/parts/year.js +58 -0
  60. package/dist/components/parts/year.mjs +7 -0
  61. package/dist/composables/useCalendar.d.mts +90 -0
  62. package/dist/composables/useCalendar.d.ts +90 -0
  63. package/dist/composables/useCalendar.js +184 -0
  64. package/dist/composables/useCalendar.mjs +8 -0
  65. package/dist/composables/useCalendarRange.d.mts +277 -0
  66. package/dist/composables/useCalendarRange.d.ts +277 -0
  67. package/dist/composables/useCalendarRange.js +160 -0
  68. package/dist/composables/useCalendarRange.mjs +8 -0
  69. package/dist/date-picker.d.mts +237 -0
  70. package/dist/date-picker.d.ts +237 -0
  71. package/dist/date-picker.js +1851 -0
  72. package/dist/date-picker.mjs +25 -0
  73. package/dist/index.d.mts +3 -0
  74. package/dist/index.d.ts +3 -0
  75. package/dist/index.js +1853 -0
  76. package/dist/index.mjs +25 -0
  77. package/dist/metafile-cjs.json +1 -0
  78. package/dist/metafile-esm.json +1 -0
  79. package/dist/modules/date-picker.context.d.mts +20 -0
  80. package/dist/modules/date-picker.context.d.ts +20 -0
  81. package/dist/modules/date-picker.context.js +33 -0
  82. package/dist/modules/date-picker.context.mjs +9 -0
  83. package/dist/modules/date-picker.hooks.d.mts +53 -0
  84. package/dist/modules/date-picker.hooks.d.ts +53 -0
  85. package/dist/modules/date-picker.hooks.js +337 -0
  86. package/dist/modules/date-picker.hooks.mjs +10 -0
  87. package/dist/modules/date-picker.locales.d.mts +27 -0
  88. package/dist/modules/date-picker.locales.d.ts +27 -0
  89. package/dist/modules/date-picker.locales.js +84 -0
  90. package/dist/modules/date-picker.locales.mjs +8 -0
  91. package/dist/modules/date-picker.props.d.mts +217 -0
  92. package/dist/modules/date-picker.props.d.ts +217 -0
  93. package/dist/modules/date-picker.props.js +181 -0
  94. package/dist/modules/date-picker.props.mjs +11 -0
  95. package/dist/utils/base.d.mts +20 -0
  96. package/dist/utils/base.d.ts +20 -0
  97. package/dist/utils/base.js +80 -0
  98. package/dist/utils/base.mjs +13 -0
  99. package/dist/utils/date.d.mts +19 -0
  100. package/dist/utils/date.d.ts +19 -0
  101. package/dist/utils/date.js +147 -0
  102. package/dist/utils/date.mjs +29 -0
  103. package/package.json +49 -0
@@ -0,0 +1,1498 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/calendar-panel.tsx
32
+ var calendar_panel_exports = {};
33
+ __export(calendar_panel_exports, {
34
+ CalendarPanel: () => CalendarPanel,
35
+ CalendarPanelRange: () => CalendarPanelRange
36
+ });
37
+ module.exports = __toCommonJS(calendar_panel_exports);
38
+ var import_vue17 = require("vue");
39
+ var import_vue18 = require("vue");
40
+
41
+ // src/components/calendar/table-date.tsx
42
+ var import_vue9 = require("vue");
43
+ var import_vue10 = require("vue");
44
+ var import_pixel3_button = require("@mekari/pixel3-button");
45
+
46
+ // src/components/parts/date.tsx
47
+ var import_vue = require("vue");
48
+ var import_vue2 = require("vue");
49
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
50
+ var Date2 = (0, import_vue2.defineComponent)({
51
+ name: "Date",
52
+ props: {
53
+ status: {
54
+ type: String
55
+ },
56
+ isDisabled: {
57
+ type: Boolean,
58
+ default: false
59
+ },
60
+ isShowPinbar: {
61
+ type: Boolean,
62
+ default: false
63
+ }
64
+ },
65
+ setup(props, {
66
+ slots
67
+ }) {
68
+ return () => {
69
+ const dateItemClasses = (0, import_recipes.dateItemRecipe)({
70
+ status: props.status
71
+ });
72
+ const {
73
+ root,
74
+ pinbar
75
+ } = (0, import_recipes.pinbarSlotRecipe)();
76
+ return (0, import_vue.createVNode)("button", {
77
+ "disabled": props.isDisabled,
78
+ "data-status": props.status,
79
+ "class": dateItemClasses
80
+ }, [slots.default(), props.isShowPinbar && (0, import_vue.createVNode)("div", {
81
+ "class": root
82
+ }, [(0, import_vue.createVNode)("div", {
83
+ "class": pinbar
84
+ }, null)])]);
85
+ };
86
+ }
87
+ });
88
+
89
+ // src/components/parts/day.tsx
90
+ var import_vue3 = require("vue");
91
+ var import_vue4 = require("vue");
92
+ var import_recipes2 = require("@mekari/pixel3-styled-system/recipes");
93
+ var Day = (0, import_vue4.defineComponent)({
94
+ name: "Day",
95
+ setup(props, {
96
+ slots
97
+ }) {
98
+ return () => {
99
+ return (0, import_vue3.createVNode)("div", {
100
+ "class": (0, import_recipes2.dayItemRecipe)()
101
+ }, [slots.default()]);
102
+ };
103
+ }
104
+ });
105
+
106
+ // src/components/parts/month.tsx
107
+ var import_vue5 = require("vue");
108
+ var import_vue6 = require("vue");
109
+ var import_recipes3 = require("@mekari/pixel3-styled-system/recipes");
110
+ var Month = (0, import_vue6.defineComponent)({
111
+ name: "Month",
112
+ props: {
113
+ status: {
114
+ type: String
115
+ },
116
+ isDisabled: {
117
+ type: Boolean,
118
+ default: false
119
+ }
120
+ },
121
+ setup(props, {
122
+ slots
123
+ }) {
124
+ return () => {
125
+ const classes = (0, import_recipes3.monthItemRecipe)({
126
+ status: props.status
127
+ });
128
+ return (0, import_vue5.createVNode)("button", {
129
+ "disabled": props.isDisabled,
130
+ "data-status": props.status,
131
+ "class": classes
132
+ }, [slots.default()]);
133
+ };
134
+ }
135
+ });
136
+
137
+ // src/components/parts/year.tsx
138
+ var import_vue7 = require("vue");
139
+ var import_vue8 = require("vue");
140
+ var import_recipes4 = require("@mekari/pixel3-styled-system/recipes");
141
+ var YearItem = (0, import_vue8.defineComponent)({
142
+ name: "YearItem",
143
+ props: {
144
+ status: {
145
+ type: String
146
+ },
147
+ isDisabled: {
148
+ type: Boolean,
149
+ default: false
150
+ }
151
+ },
152
+ setup(props, {
153
+ slots
154
+ }) {
155
+ return () => {
156
+ const classes = (0, import_recipes4.yearItemRecipe)({
157
+ status: props.status
158
+ });
159
+ return (0, import_vue7.createVNode)("button", {
160
+ "disabled": props.isDisabled,
161
+ "data-status": props.status,
162
+ "class": classes
163
+ }, [slots.default()]);
164
+ };
165
+ }
166
+ });
167
+
168
+ // src/utils/base.ts
169
+ function chunk(arr, size) {
170
+ if (!Array.isArray(arr)) {
171
+ return [];
172
+ }
173
+ const result = [];
174
+ const len = arr.length;
175
+ let i = 0;
176
+ size = size || len;
177
+ while (i < len) {
178
+ result.push(arr.slice(i, i += size));
179
+ }
180
+ return result;
181
+ }
182
+ __name(chunk, "chunk");
183
+ var isObject = /* @__PURE__ */ __name((value) => {
184
+ return !!value && value.constructor === Object;
185
+ }, "isObject");
186
+ var assign = /* @__PURE__ */ __name((initial, override) => {
187
+ var _a;
188
+ if (!initial || !override)
189
+ return (_a = initial != null ? initial : override) != null ? _a : {};
190
+ return Object.entries({
191
+ ...initial,
192
+ ...override
193
+ }).reduce((acc, [key, value]) => {
194
+ return {
195
+ ...acc,
196
+ [key]: (() => {
197
+ if (isObject(initial[key]))
198
+ return assign(initial[key], value);
199
+ return value;
200
+ })()
201
+ };
202
+ }, {});
203
+ }, "assign");
204
+
205
+ // src/components/calendar/table-date.tsx
206
+ var import_recipes5 = require("@mekari/pixel3-styled-system/recipes");
207
+ var TableDate = (0, import_vue10.defineComponent)({
208
+ name: "TableDate",
209
+ props: {
210
+ days: {
211
+ type: Array,
212
+ default: () => []
213
+ },
214
+ dates: {
215
+ type: Array,
216
+ default: () => []
217
+ },
218
+ headerLabel: {
219
+ type: String,
220
+ default: ""
221
+ },
222
+ shortcutLabel: {
223
+ type: String,
224
+ default: ""
225
+ },
226
+ getDateStatus: {
227
+ type: Function,
228
+ default: () => {
229
+ }
230
+ },
231
+ isShowShortcut: {
232
+ type: Boolean
233
+ },
234
+ isRange: {
235
+ type: Boolean
236
+ },
237
+ isHideNotThisMonthDate: {
238
+ type: Boolean
239
+ }
240
+ },
241
+ emits: ["next", "previous", "changePanel", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
242
+ setup(props, {
243
+ emit
244
+ }) {
245
+ const {
246
+ headerRoot,
247
+ headerLabel,
248
+ dayWrapper,
249
+ dateItemRoot,
250
+ dateItemWrapper,
251
+ shortcutLabelWrapper
252
+ } = (0, import_recipes5.tableDateSlotRecipe)();
253
+ const getDates = (0, import_vue10.computed)(() => {
254
+ return chunk(props.dates, 7);
255
+ });
256
+ function onNextButton() {
257
+ emit("next");
258
+ }
259
+ __name(onNextButton, "onNextButton");
260
+ function onPreviousButton() {
261
+ emit("previous");
262
+ }
263
+ __name(onPreviousButton, "onPreviousButton");
264
+ function onSelectDate(date) {
265
+ emit("select", date);
266
+ }
267
+ __name(onSelectDate, "onSelectDate");
268
+ function onSelectToday() {
269
+ const today = /* @__PURE__ */ new Date();
270
+ onSelectDate(today);
271
+ }
272
+ __name(onSelectToday, "onSelectToday");
273
+ function getDateAttrs(date) {
274
+ const {
275
+ status,
276
+ isDisabled,
277
+ isShowPinbar
278
+ } = props.getDateStatus(date);
279
+ return {
280
+ status: isDisabled ? "disabled" : status,
281
+ isDisabled,
282
+ isShowPinbar,
283
+ onClick: () => onSelectDate(date),
284
+ onMouseenter: () => {
285
+ emit("mouseEnter", date);
286
+ },
287
+ onMouseleave: () => {
288
+ emit("mouseLeave");
289
+ },
290
+ style: {
291
+ visibility: props.isHideNotThisMonthDate && status === "notThisMonth" ? "hidden" : ""
292
+ }
293
+ };
294
+ }
295
+ __name(getDateAttrs, "getDateAttrs");
296
+ return () => {
297
+ return (0, import_vue9.createVNode)("div", null, [(0, import_vue9.createVNode)("div", {
298
+ "data-pixel-parts": "Header",
299
+ "class": headerRoot
300
+ }, [(0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
301
+ "left-icon": "chevrons-left",
302
+ "variant": "ghost",
303
+ "size": "sm",
304
+ "onClick": onPreviousButton
305
+ }, null), (0, import_vue9.createVNode)("button", {
306
+ "class": headerLabel,
307
+ "onClick": () => emit("clickHeaderLabel")
308
+ }, [props.headerLabel]), (0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
309
+ "right-icon": "chevrons-right",
310
+ "variant": "ghost",
311
+ "size": "sm",
312
+ "onClick": onNextButton
313
+ }, null)]), (0, import_vue9.createVNode)("div", {
314
+ "data-pixel-parts": "Content",
315
+ "class": dayWrapper
316
+ }, [props.days.map((day) => (0, import_vue9.createVNode)(Day, null, {
317
+ default: () => [(0, import_vue9.createTextVNode)(" "), day, (0, import_vue9.createTextVNode)(" ")]
318
+ }))]), (0, import_vue9.createVNode)("div", {
319
+ "data-pixel-parts": "Content",
320
+ "class": dateItemRoot
321
+ }, [getDates.value.map((dates, index) => (0, import_vue9.createVNode)("div", {
322
+ "class": dateItemWrapper,
323
+ "data-row-index": index
324
+ }, [dates.map((date) => (0, import_vue9.createVNode)(Date2, getDateAttrs(date), {
325
+ default: () => [(0, import_vue9.createTextVNode)(" "), date.getDate(), (0, import_vue9.createTextVNode)(" ")]
326
+ }))]))]), props.isShowShortcut && (0, import_vue9.createVNode)("div", {
327
+ "data-pixel-parts": "Shortcut",
328
+ "class": shortcutLabelWrapper
329
+ }, [(0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
330
+ "variant": "ghost",
331
+ "onClick": onSelectToday
332
+ }, {
333
+ default: () => [props.shortcutLabel]
334
+ })])]);
335
+ };
336
+ }
337
+ });
338
+
339
+ // src/components/calendar/table-month.tsx
340
+ var import_vue11 = require("vue");
341
+ var import_vue12 = require("vue");
342
+ var import_pixel3_button2 = require("@mekari/pixel3-button");
343
+
344
+ // src/utils/date.ts
345
+ var import_date_fns = require("date-fns");
346
+ function createDate(y, M = 0, d = 1, h = 0, m = 0, s = 0, ms = 0) {
347
+ const date = new Date(y, M, d, h, m, s, ms);
348
+ if (y < 100 && y >= 0) {
349
+ date.setFullYear(y);
350
+ }
351
+ return date;
352
+ }
353
+ __name(createDate, "createDate");
354
+ function isValidDate(date) {
355
+ return date instanceof Date && !isNaN(date);
356
+ }
357
+ __name(isValidDate, "isValidDate");
358
+ function startOfMonth(value) {
359
+ const date = new Date(value);
360
+ date.setDate(1);
361
+ date.setHours(0, 0, 0, 0);
362
+ return date;
363
+ }
364
+ __name(startOfMonth, "startOfMonth");
365
+ function startOfWeek(value, firstDayOfWeek = 0) {
366
+ if (!(firstDayOfWeek >= 0 && firstDayOfWeek <= 6)) {
367
+ throw new RangeError("weekStartsOn must be between 0 and 6");
368
+ }
369
+ const date = new Date(value);
370
+ const day = date.getDay();
371
+ const diff = (day + 7 - firstDayOfWeek) % 7;
372
+ date.setDate(date.getDate() - diff);
373
+ date.setHours(0, 0, 0, 0);
374
+ return date;
375
+ }
376
+ __name(startOfWeek, "startOfWeek");
377
+ function getCalendar({
378
+ firstDayOfWeek,
379
+ year,
380
+ month
381
+ }) {
382
+ const arr = [];
383
+ const calendar = createDate(year, month, 0);
384
+ const lastDayInLastMonth = calendar.getDate();
385
+ const firstDayInLastMonth = lastDayInLastMonth - (calendar.getDay() + 7 - firstDayOfWeek) % 7;
386
+ for (let i = firstDayInLastMonth; i <= lastDayInLastMonth; i++) {
387
+ arr.push(createDate(year, month, i - lastDayInLastMonth));
388
+ }
389
+ calendar.setMonth(month + 1, 0);
390
+ const lastDayInCurrentMonth = calendar.getDate();
391
+ for (let i = 1; i <= lastDayInCurrentMonth; i++) {
392
+ arr.push(createDate(year, month, i));
393
+ }
394
+ const lastMonthLength = lastDayInLastMonth - firstDayInLastMonth + 1;
395
+ const nextMonthLength = 6 * 7 - lastMonthLength - lastDayInCurrentMonth;
396
+ for (let i = 1; i <= nextMonthLength; i++) {
397
+ arr.push(createDate(year, month, lastDayInCurrentMonth + i));
398
+ }
399
+ return arr;
400
+ }
401
+ __name(getCalendar, "getCalendar");
402
+ function getNextMonth(date) {
403
+ return (0, import_date_fns.addMonths)(date, 1);
404
+ }
405
+ __name(getNextMonth, "getNextMonth");
406
+ function getPreviousMonth(date) {
407
+ return (0, import_date_fns.addMonths)(date, -1);
408
+ }
409
+ __name(getPreviousMonth, "getPreviousMonth");
410
+ function addDays(value, days) {
411
+ const date = new Date(value);
412
+ date.setDate(date.getDate() + days);
413
+ return date;
414
+ }
415
+ __name(addDays, "addDays");
416
+ function isDateBetween(date, min, max) {
417
+ const _date = new Date(date);
418
+ const _min = new Date(min);
419
+ const _max = new Date(max);
420
+ return _date.getTime() >= _min.getTime() && _date.getTime() <= _max.getTime();
421
+ }
422
+ __name(isDateBetween, "isDateBetween");
423
+
424
+ // src/components/calendar/table-month.tsx
425
+ var import_recipes6 = require("@mekari/pixel3-styled-system/recipes");
426
+ var TableMonth = (0, import_vue12.defineComponent)({
427
+ name: "TableMonth",
428
+ props: {
429
+ calendar: {
430
+ type: Date,
431
+ default: () => /* @__PURE__ */ new Date()
432
+ },
433
+ months: {
434
+ type: Array,
435
+ default: () => []
436
+ },
437
+ headerLabel: {
438
+ type: String,
439
+ default: ""
440
+ },
441
+ shortcutLabel: {
442
+ type: String,
443
+ default: ""
444
+ },
445
+ getMonthStatus: {
446
+ type: Function,
447
+ default: () => {
448
+ }
449
+ },
450
+ isShowShortcut: {
451
+ type: Boolean
452
+ }
453
+ },
454
+ emits: ["next", "previous", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
455
+ setup(props, {
456
+ emit
457
+ }) {
458
+ const {
459
+ headerRoot,
460
+ headerLabel,
461
+ monthItemRoot,
462
+ monthItemWrapper,
463
+ shortcutLabelWrapper
464
+ } = (0, import_recipes6.tableMonthSlotRecipe)();
465
+ const getMonths = (0, import_vue12.computed)(() => {
466
+ return chunk(props.months, 3);
467
+ });
468
+ const getCalendarYear = (0, import_vue12.computed)(() => props.calendar.getFullYear());
469
+ function onNextButton() {
470
+ emit("next");
471
+ }
472
+ __name(onNextButton, "onNextButton");
473
+ function onPreviousButton() {
474
+ emit("previous", "previousMonth");
475
+ }
476
+ __name(onPreviousButton, "onPreviousButton");
477
+ function onSelectMonth(month, year) {
478
+ emit("select", month, year);
479
+ }
480
+ __name(onSelectMonth, "onSelectMonth");
481
+ function getMonthAttrs(month) {
482
+ const {
483
+ status,
484
+ isDisabled
485
+ } = props.getMonthStatus(month, getCalendarYear.value);
486
+ return {
487
+ status: isDisabled ? "disabled" : status,
488
+ isDisabled,
489
+ onClick: () => onSelectMonth(month, getCalendarYear.value),
490
+ onMouseenter: () => {
491
+ emit("mouseEnter", createDate(getCalendarYear.value, month));
492
+ },
493
+ onMouseleave: () => {
494
+ emit("mouseLeave");
495
+ }
496
+ };
497
+ }
498
+ __name(getMonthAttrs, "getMonthAttrs");
499
+ return () => {
500
+ return (0, import_vue11.createVNode)("div", null, [(0, import_vue11.createVNode)("div", {
501
+ "data-pixel-parts": "Header",
502
+ "class": headerRoot
503
+ }, [(0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
504
+ "left-icon": "chevrons-left",
505
+ "variant": "ghost",
506
+ "size": "sm",
507
+ "onClick": onPreviousButton
508
+ }, null), (0, import_vue11.createVNode)("button", {
509
+ "class": headerLabel,
510
+ "onClick": () => emit("clickHeaderLabel")
511
+ }, [props.headerLabel]), (0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
512
+ "right-icon": "chevrons-right",
513
+ "variant": "ghost",
514
+ "size": "sm",
515
+ "onClick": onNextButton
516
+ }, null)]), (0, import_vue11.createVNode)("div", {
517
+ "data-pixel-parts": "Content",
518
+ "class": monthItemRoot
519
+ }, [getMonths.value.map((data) => (0, import_vue11.createVNode)("div", {
520
+ "class": monthItemWrapper
521
+ }, [data.map((month) => (0, import_vue11.createVNode)(Month, getMonthAttrs(month.month), {
522
+ default: () => [" ", month.text, " "]
523
+ }))]))]), props.isShowShortcut && (0, import_vue11.createVNode)("div", {
524
+ "data-pixel-parts": "Shortcut",
525
+ "class": shortcutLabelWrapper
526
+ }, [(0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
527
+ "variant": "ghost",
528
+ "onClick": () => onSelectMonth((/* @__PURE__ */ new Date()).getMonth(), getCalendarYear.value)
529
+ }, {
530
+ default: () => [props.shortcutLabel]
531
+ })])]);
532
+ };
533
+ }
534
+ });
535
+
536
+ // src/components/calendar/table-year.tsx
537
+ var import_vue13 = require("vue");
538
+ var import_vue14 = require("vue");
539
+ var import_pixel3_button3 = require("@mekari/pixel3-button");
540
+ var import_recipes7 = require("@mekari/pixel3-styled-system/recipes");
541
+ var TableYear = (0, import_vue14.defineComponent)({
542
+ name: "TableYear",
543
+ props: {
544
+ years: {
545
+ type: Array,
546
+ default: () => []
547
+ },
548
+ headerLabel: {
549
+ type: String,
550
+ default: ""
551
+ },
552
+ shortcutLabel: {
553
+ type: String,
554
+ default: ""
555
+ },
556
+ getYearStatus: {
557
+ type: Function,
558
+ default: () => {
559
+ }
560
+ },
561
+ isShowShortcut: {
562
+ type: Boolean
563
+ }
564
+ },
565
+ emits: ["next", "previous", "select", "mouseEnter", "mouseLeave"],
566
+ setup(props, {
567
+ emit
568
+ }) {
569
+ const {
570
+ headerRoot,
571
+ headerLabel,
572
+ yearItemRoot,
573
+ yearItemWrapper,
574
+ shortcutLabelWrapper
575
+ } = (0, import_recipes7.tableYearSlotRecipe)();
576
+ const getYears = (0, import_vue14.computed)(() => {
577
+ return chunk(props.years, 4);
578
+ });
579
+ function onNextButton() {
580
+ const lastYear = props.years[props.years.length - 1];
581
+ emit("next", lastYear + 1);
582
+ }
583
+ __name(onNextButton, "onNextButton");
584
+ function onPreviousButton() {
585
+ const firstYear = props.years[0];
586
+ emit("previous", firstYear - 1);
587
+ }
588
+ __name(onPreviousButton, "onPreviousButton");
589
+ function onSelectYear(year) {
590
+ emit("select", year);
591
+ }
592
+ __name(onSelectYear, "onSelectYear");
593
+ function getMonthAttrs(year) {
594
+ const {
595
+ status,
596
+ isDisabled
597
+ } = props.getYearStatus(year);
598
+ return {
599
+ status: isDisabled ? "disabled" : status,
600
+ isDisabled,
601
+ onClick: () => onSelectYear(year),
602
+ onMouseenter: () => {
603
+ emit("mouseEnter", createDate(year));
604
+ },
605
+ onMouseleave: () => {
606
+ emit("mouseLeave");
607
+ }
608
+ };
609
+ }
610
+ __name(getMonthAttrs, "getMonthAttrs");
611
+ return () => {
612
+ return (0, import_vue13.createVNode)("div", null, [(0, import_vue13.createVNode)("div", {
613
+ "data-pixel-parts": "Header",
614
+ "class": headerRoot
615
+ }, [(0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
616
+ "left-icon": "chevrons-left",
617
+ "variant": "ghost",
618
+ "size": "sm",
619
+ "onClick": onPreviousButton
620
+ }, null), (0, import_vue13.createVNode)("button", {
621
+ "class": headerLabel
622
+ }, [props.headerLabel]), (0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
623
+ "right-icon": "chevrons-right",
624
+ "variant": "ghost",
625
+ "size": "sm",
626
+ "onClick": onNextButton
627
+ }, null)]), (0, import_vue13.createVNode)("div", {
628
+ "class": yearItemRoot
629
+ }, [getYears.value.map((data) => (0, import_vue13.createVNode)("div", {
630
+ "class": yearItemWrapper
631
+ }, [data.map((year) => (0, import_vue13.createVNode)(YearItem, getMonthAttrs(year), {
632
+ default: () => [(0, import_vue13.createTextVNode)(" "), year, (0, import_vue13.createTextVNode)(" ")]
633
+ }))]))]), props.isShowShortcut && (0, import_vue13.createVNode)("div", {
634
+ "class": shortcutLabelWrapper
635
+ }, [(0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
636
+ "variant": "ghost",
637
+ "onClick": () => onSelectYear((/* @__PURE__ */ new Date()).getFullYear())
638
+ }, {
639
+ default: () => [props.shortcutLabel]
640
+ })])]);
641
+ };
642
+ }
643
+ });
644
+
645
+ // src/calendar-panel.tsx
646
+ var import_date_fns3 = require("date-fns");
647
+
648
+ // src/composables/useCalendar.ts
649
+ var import_vue15 = require("vue");
650
+ var import_date_fns2 = require("date-fns");
651
+ function useCalendar(date, locale) {
652
+ const currentDate = (0, import_vue15.ref)(isValidDate(date) ? date : /* @__PURE__ */ new Date());
653
+ const currentPanel = (0, import_vue15.ref)("date");
654
+ const nextMonth = /* @__PURE__ */ __name(() => {
655
+ currentDate.value = getNextMonth(currentDate.value);
656
+ }, "nextMonth");
657
+ const previousMonth = /* @__PURE__ */ __name(() => {
658
+ currentDate.value = getPreviousMonth(currentDate.value);
659
+ }, "previousMonth");
660
+ const nextYear = /* @__PURE__ */ __name(() => {
661
+ currentDate.value = (0, import_date_fns2.addYears)(currentDate.value, 1);
662
+ }, "nextYear");
663
+ const previousYear = /* @__PURE__ */ __name(() => {
664
+ currentDate.value = (0, import_date_fns2.addYears)(currentDate.value, -1);
665
+ }, "previousYear");
666
+ const changeYear = /* @__PURE__ */ __name((year) => {
667
+ currentDate.value = (0, import_date_fns2.setYear)(currentDate.value, year);
668
+ }, "changeYear");
669
+ const changeMonth = /* @__PURE__ */ __name((month) => {
670
+ currentDate.value = (0, import_date_fns2.setMonth)(currentDate.value, month);
671
+ }, "changeMonth");
672
+ const getSplitDates = (0, import_vue15.computed)(() => {
673
+ return {
674
+ day: currentDate.value.getDay(),
675
+ month: currentDate.value.getMonth(),
676
+ year: currentDate.value.getFullYear(),
677
+ monthLabel: locale.value.months[currentDate.value.getMonth()]
678
+ };
679
+ });
680
+ const getDates = (0, import_vue15.computed)(() => {
681
+ const {
682
+ year,
683
+ month
684
+ } = getSplitDates.value;
685
+ const arr = getCalendar({
686
+ firstDayOfWeek: locale.value.formatLocale.firstDayOfWeek || 0,
687
+ year,
688
+ month
689
+ });
690
+ return arr;
691
+ });
692
+ const getMonths = (0, import_vue15.computed)(() => {
693
+ const monthsLocale = locale.value.formatLocale.monthsShort || locale.value.months;
694
+ const months = monthsLocale.map((text, month) => {
695
+ return {
696
+ text,
697
+ month
698
+ };
699
+ });
700
+ return months;
701
+ });
702
+ const getYears = (0, import_vue15.computed)(() => {
703
+ const {
704
+ year
705
+ } = getSplitDates.value;
706
+ const firstYear = Math.floor(year / 10) * 10;
707
+ const years = [];
708
+ for (let i = 0; i < 10; i++) {
709
+ years.push(firstYear + i);
710
+ }
711
+ return years;
712
+ });
713
+ const getLabel = (0, import_vue15.computed)(() => {
714
+ const {
715
+ year,
716
+ monthLabel
717
+ } = getSplitDates.value;
718
+ if (currentPanel.value === "date")
719
+ return `${monthLabel} ${year}`;
720
+ if (currentPanel.value === "month")
721
+ return `${year}`;
722
+ if (currentPanel.value === "year")
723
+ return `${getYears.value[0]} - ${getYears.value[9]}`;
724
+ return "";
725
+ });
726
+ function changePanel(value) {
727
+ currentPanel.value = value;
728
+ }
729
+ __name(changePanel, "changePanel");
730
+ function setPanelDate(date2) {
731
+ currentDate.value = date2;
732
+ }
733
+ __name(setPanelDate, "setPanelDate");
734
+ return {
735
+ currentDate,
736
+ currentPanel,
737
+ nextMonth,
738
+ previousMonth,
739
+ nextYear,
740
+ previousYear,
741
+ changeYear,
742
+ changeMonth,
743
+ getDates,
744
+ getMonths,
745
+ getYears,
746
+ getLabel,
747
+ getSplitDates,
748
+ changePanel,
749
+ setPanelDate
750
+ };
751
+ }
752
+ __name(useCalendar, "useCalendar");
753
+
754
+ // src/composables/useCalendarRange.ts
755
+ var import_vue16 = require("vue");
756
+ function useCalendarRange(props) {
757
+ const leftCalendar = startOfMonth(/* @__PURE__ */ new Date());
758
+ const rightCalendar = startOfMonth(getNextMonth(/* @__PURE__ */ new Date()));
759
+ const startDate = (0, import_vue16.ref)(props.modelValue[0]);
760
+ const endDate = (0, import_vue16.ref)(props.modelValue[1]);
761
+ const hoveredDate = (0, import_vue16.ref)();
762
+ const calendars = (0, import_vue16.ref)([leftCalendar, rightCalendar]);
763
+ const getCurrentDates = (0, import_vue16.computed)(() => {
764
+ if (startDate.value && !endDate.value)
765
+ return [startDate.value];
766
+ if (startDate.value && endDate.value)
767
+ return [startDate.value, endDate.value];
768
+ return [];
769
+ });
770
+ const calendarMinDiff = (0, import_vue16.computed)(() => {
771
+ const map = {
772
+ date: 1,
773
+ // type:date min 1 month
774
+ month: 1 * 12,
775
+ // type:month min 1 year
776
+ year: 10 * 12
777
+ // type:year min 10 year
778
+ };
779
+ return map[props.type] || map.date;
780
+ });
781
+ const calendarMaxDiff = (0, import_vue16.computed)(() => Infinity);
782
+ function setStartDate(date) {
783
+ startDate.value = date;
784
+ }
785
+ __name(setStartDate, "setStartDate");
786
+ function setEndDate(date) {
787
+ endDate.value = date;
788
+ }
789
+ __name(setEndDate, "setEndDate");
790
+ function setHoveredDate(date) {
791
+ hoveredDate.value = date;
792
+ }
793
+ __name(setHoveredDate, "setHoveredDate");
794
+ function getDateRangeStatus(cellDate) {
795
+ const status = {
796
+ inRange: false,
797
+ hoverInRange: false,
798
+ activeDragRange: false
799
+ };
800
+ const isInRange = /* @__PURE__ */ __name((data, range, fn = (v) => v.getTime()) => {
801
+ const value = fn(data);
802
+ let [min, max] = range.map(fn);
803
+ if (min > max) {
804
+ [min, max] = [max, min];
805
+ }
806
+ return value > min && value < max;
807
+ }, "isInRange");
808
+ if (getCurrentDates.value.length === 2 && isInRange(cellDate, getCurrentDates.value)) {
809
+ status.inRange = true;
810
+ }
811
+ if (getCurrentDates.value.length === 1 && hoveredDate.value && isInRange(cellDate, [getCurrentDates.value[0], hoveredDate.value])) {
812
+ status.hoverInRange = true;
813
+ }
814
+ if (getCurrentDates.value[0]) {
815
+ status.activeDragRange = true;
816
+ }
817
+ return status;
818
+ }
819
+ __name(getDateRangeStatus, "getDateRangeStatus");
820
+ function updateStartCalendar(value) {
821
+ updateCalendars([value, calendars.value[1]], 1);
822
+ }
823
+ __name(updateStartCalendar, "updateStartCalendar");
824
+ function updateEndCalendar(value) {
825
+ updateCalendars([calendars.value[0], value], 0);
826
+ }
827
+ __name(updateEndCalendar, "updateEndCalendar");
828
+ function updateCalendars(value, adjustIndex = 1) {
829
+ const gap = getCalendarGap(value);
830
+ if (gap) {
831
+ const calendar = new Date(value[adjustIndex]);
832
+ calendar.setMonth(calendar.getMonth() + (adjustIndex === 0 ? -gap : gap));
833
+ value[adjustIndex] = calendar;
834
+ }
835
+ calendars.value = value;
836
+ }
837
+ __name(updateCalendars, "updateCalendars");
838
+ function getCalendarGap(calendars2) {
839
+ const [calendarLeft, calendarRight] = calendars2;
840
+ const yearDiff = calendarRight.getFullYear() - calendarLeft.getFullYear();
841
+ const monthDiff = calendarRight.getMonth() - calendarLeft.getMonth();
842
+ const diff = yearDiff * 12 + monthDiff;
843
+ const min = calendarMinDiff.value;
844
+ const max = calendarMaxDiff.value;
845
+ if (diff < min) {
846
+ return min - diff;
847
+ }
848
+ if (diff > max) {
849
+ return max - diff;
850
+ }
851
+ return 0;
852
+ }
853
+ __name(getCalendarGap, "getCalendarGap");
854
+ return {
855
+ startDate,
856
+ endDate,
857
+ hoveredDate,
858
+ calendars,
859
+ getCurrentDates,
860
+ setStartDate,
861
+ setEndDate,
862
+ setHoveredDate,
863
+ getDateRangeStatus,
864
+ updateStartCalendar,
865
+ updateEndCalendar
866
+ };
867
+ }
868
+ __name(useCalendarRange, "useCalendarRange");
869
+
870
+ // src/modules/date-picker.props.ts
871
+ var calendarPanelProps = {
872
+ modelValue: {
873
+ type: Date
874
+ },
875
+ defaultValue: {
876
+ type: Date
877
+ },
878
+ type: {
879
+ type: String,
880
+ default: "date"
881
+ },
882
+ calendar: {
883
+ type: Date
884
+ },
885
+ isRange: {
886
+ type: Boolean,
887
+ default: false
888
+ },
889
+ isShowShortcut: {
890
+ type: Boolean,
891
+ default: true
892
+ },
893
+ disabledDate: {
894
+ type: Function,
895
+ default: () => {
896
+ }
897
+ },
898
+ disabledMonth: {
899
+ type: Function,
900
+ default: () => {
901
+ }
902
+ },
903
+ disabledYear: {
904
+ type: Function,
905
+ default: () => {
906
+ }
907
+ },
908
+ getDateStatus: {
909
+ type: Function,
910
+ default: void 0
911
+ },
912
+ getMonthStatus: {
913
+ type: Function,
914
+ default: void 0
915
+ },
916
+ getYearStatus: {
917
+ type: Function,
918
+ default: void 0
919
+ },
920
+ isHideNotThisMonthDate: {
921
+ type: Boolean
922
+ }
923
+ };
924
+ var calendarPanelRangeProps = {
925
+ ...calendarPanelProps,
926
+ modelValue: {
927
+ type: Array
928
+ }
929
+ };
930
+ var datePickerProps = {
931
+ id: {
932
+ type: String
933
+ },
934
+ modelValue: {
935
+ type: [String, Number, Date, Array]
936
+ },
937
+ type: calendarPanelProps.type,
938
+ valueType: {
939
+ type: String,
940
+ default: "date"
941
+ },
942
+ format: {
943
+ type: String
944
+ },
945
+ rangeSeparator: {
946
+ type: String,
947
+ default: " - "
948
+ },
949
+ placeholder: {
950
+ type: String,
951
+ default: ""
952
+ },
953
+ errorMessage: {
954
+ type: String,
955
+ default: "Format tanggal/waktu salah"
956
+ },
957
+ disabledMessage: {
958
+ type: String,
959
+ default: ""
960
+ },
961
+ lang: {
962
+ type: Object,
963
+ default: () => {
964
+ }
965
+ },
966
+ inputAttr: {
967
+ type: Object,
968
+ default: () => ({})
969
+ },
970
+ contentAttr: {
971
+ type: Object,
972
+ default: () => ({})
973
+ },
974
+ isRange: calendarPanelProps.isRange,
975
+ isReadOnly: {
976
+ type: Boolean,
977
+ default: false
978
+ },
979
+ isDisabled: {
980
+ type: Boolean,
981
+ default: false
982
+ },
983
+ isClearable: {
984
+ type: Boolean,
985
+ default: true
986
+ },
987
+ isInvalid: {
988
+ type: Boolean,
989
+ default: false
990
+ },
991
+ usePortal: {
992
+ type: Boolean,
993
+ default: false
994
+ },
995
+ isKeepAlive: {
996
+ type: Boolean,
997
+ default: false
998
+ },
999
+ isInline: {
1000
+ type: Boolean,
1001
+ default: false
1002
+ },
1003
+ isNotClickable: {
1004
+ type: Boolean,
1005
+ default: false
1006
+ },
1007
+ isDisableHeader: {
1008
+ type: Boolean,
1009
+ default: false
1010
+ },
1011
+ isShowShortcut: {
1012
+ type: Boolean,
1013
+ default: false
1014
+ },
1015
+ disabledDate: calendarPanelProps.disabledDate,
1016
+ disabledMonth: calendarPanelProps.disabledMonth,
1017
+ disabledYear: calendarPanelProps.disabledYear
1018
+ };
1019
+
1020
+ // src/modules/date-picker.context.ts
1021
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
1022
+ var [DatePickerProvider, useDatePickerContext] = (0, import_pixel3_utils.usePixelCreateContext)("DatePickerContext");
1023
+
1024
+ // src/modules/date-picker.locales.ts
1025
+ var import_en = __toESM(require("date-format-parse/lib/locale/en"));
1026
+ var locales = {
1027
+ formatLocale: import_en.default,
1028
+ days: import_en.default.weekdaysMin,
1029
+ months: import_en.default.monthsShort,
1030
+ yearFormat: "YYYY",
1031
+ monthFormat: "MMM",
1032
+ monthBeforeYear: true,
1033
+ todayText: "Today",
1034
+ thisMonthText: "This Month",
1035
+ thisYearText: "This Year"
1036
+ };
1037
+ function getLocale(config) {
1038
+ if (!config) {
1039
+ return locales;
1040
+ }
1041
+ return assign(locales, config);
1042
+ }
1043
+ __name(getLocale, "getLocale");
1044
+
1045
+ // src/calendar-panel.tsx
1046
+ var import_recipes8 = require("@mekari/pixel3-styled-system/recipes");
1047
+ var CalendarPanel = (0, import_vue18.defineComponent)({
1048
+ name: "CalendarPanel",
1049
+ props: calendarPanelProps,
1050
+ emits: ["update:modelValue", "mouseEnter", "mouseLeave", "updateCalendar"],
1051
+ setup(props, {
1052
+ emit
1053
+ }) {
1054
+ const {
1055
+ locale
1056
+ } = useDatePickerContext();
1057
+ const restValue = (0, import_vue18.ref)(props.modelValue);
1058
+ const {
1059
+ currentDate: currentPanelDate,
1060
+ currentPanel,
1061
+ changePanel,
1062
+ getDates,
1063
+ getMonths,
1064
+ getYears,
1065
+ nextMonth,
1066
+ previousMonth,
1067
+ nextYear,
1068
+ previousYear,
1069
+ getLabel,
1070
+ changeMonth,
1071
+ changeYear
1072
+ } = useCalendar(props.modelValue || props.defaultValue, locale);
1073
+ function onSelectDate(date) {
1074
+ currentPanelDate.value = date;
1075
+ restValue.value = date;
1076
+ emit("update:modelValue", restValue.value);
1077
+ }
1078
+ __name(onSelectDate, "onSelectDate");
1079
+ function onSelectMonth(value, year) {
1080
+ if (props.type === "month") {
1081
+ const day = 1;
1082
+ const month = value;
1083
+ const date = new Date(year, month, day);
1084
+ restValue.value = date;
1085
+ emit("update:modelValue", restValue.value);
1086
+ return;
1087
+ }
1088
+ changeMonth(value);
1089
+ changePanel("date");
1090
+ }
1091
+ __name(onSelectMonth, "onSelectMonth");
1092
+ function onSelectYear(value) {
1093
+ if (props.type === "year") {
1094
+ const day = 1;
1095
+ const month = currentPanelDate.value.getMonth();
1096
+ const year = value;
1097
+ const date = new Date(year, month, day);
1098
+ restValue.value = date;
1099
+ emit("update:modelValue", restValue.value);
1100
+ return;
1101
+ }
1102
+ changeYear(value);
1103
+ changePanel("month");
1104
+ }
1105
+ __name(onSelectYear, "onSelectYear");
1106
+ function getDateStatus(date) {
1107
+ let status = "default";
1108
+ if ((0, import_date_fns3.isToday)(date))
1109
+ status = "today";
1110
+ if ((0, import_date_fns3.isEqual)(props.modelValue, date)) {
1111
+ status = "selected";
1112
+ }
1113
+ const isCurrentMonth = currentPanelDate.value.getMonth() === date.getMonth();
1114
+ if (!isCurrentMonth)
1115
+ status = "notThisMonth";
1116
+ if (props.getDateStatus && props.getDateStatus(date)) {
1117
+ status = props.getDateStatus(date);
1118
+ if (props.isHideNotThisMonthDate && !isCurrentMonth) {
1119
+ status = "notThisMonth";
1120
+ }
1121
+ }
1122
+ return {
1123
+ status,
1124
+ isDisabled: props.disabledDate ? props.disabledDate(date) : false,
1125
+ // TODO : Handle show pin bar
1126
+ isShowPinbar: false
1127
+ };
1128
+ }
1129
+ __name(getDateStatus, "getDateStatus");
1130
+ function getMonthStatus(month, year) {
1131
+ let status = "default";
1132
+ const isCurrentMonth = currentPanelDate.value.getMonth() === month && year === (/* @__PURE__ */ new Date()).getFullYear();
1133
+ if (isCurrentMonth)
1134
+ status = "today";
1135
+ if (props.type === "month" && props.modelValue) {
1136
+ const isMonthEqual = props.modelValue.getMonth() === month;
1137
+ const isYearEqual = props.modelValue.getFullYear() === currentPanelDate.value.getFullYear();
1138
+ const isSelected = isMonthEqual && isYearEqual;
1139
+ if (isSelected)
1140
+ status = "selected";
1141
+ }
1142
+ if (props.getMonthStatus && props.getMonthStatus(month, year)) {
1143
+ status = props.getMonthStatus(month, year);
1144
+ }
1145
+ return {
1146
+ status,
1147
+ isDisabled: props.disabledMonth(month, year) || false
1148
+ };
1149
+ }
1150
+ __name(getMonthStatus, "getMonthStatus");
1151
+ function getYearStatus(year) {
1152
+ var _a;
1153
+ let status = "default";
1154
+ const isCurrentYear = (/* @__PURE__ */ new Date()).getFullYear() === year;
1155
+ if (isCurrentYear)
1156
+ status = "today";
1157
+ const isSelected = ((_a = props.modelValue) == null ? void 0 : _a.getFullYear()) === year;
1158
+ if (isSelected)
1159
+ status = "selected";
1160
+ if (props.getYearStatus && props.getYearStatus(year)) {
1161
+ status = props.getYearStatus(year);
1162
+ }
1163
+ return {
1164
+ status,
1165
+ isDisabled: props.disabledYear(year) || false
1166
+ };
1167
+ }
1168
+ __name(getYearStatus, "getYearStatus");
1169
+ function initCalendar() {
1170
+ if (props.calendar) {
1171
+ const calendarDate = props.calendar;
1172
+ currentPanelDate.value = calendarDate;
1173
+ }
1174
+ }
1175
+ __name(initCalendar, "initCalendar");
1176
+ (0, import_vue18.watch)(() => props.modelValue, (newValue) => {
1177
+ if (newValue)
1178
+ restValue.value = newValue;
1179
+ }, {
1180
+ immediate: true
1181
+ });
1182
+ (0, import_vue18.watch)(() => props.type, (newValue) => {
1183
+ if (newValue)
1184
+ currentPanel.value = newValue;
1185
+ }, {
1186
+ immediate: true
1187
+ });
1188
+ (0, import_vue18.watch)(() => currentPanelDate.value, (newValue) => {
1189
+ if (newValue) {
1190
+ emit("updateCalendar", newValue);
1191
+ }
1192
+ });
1193
+ (0, import_vue18.watch)(() => props.calendar, () => {
1194
+ initCalendar();
1195
+ }, {
1196
+ immediate: true
1197
+ });
1198
+ return () => {
1199
+ if (currentPanel.value === "date") {
1200
+ return (0, import_vue17.createVNode)(TableDate, {
1201
+ "days": locale.value.days,
1202
+ "dates": getDates.value,
1203
+ "headerLabel": getLabel.value,
1204
+ "shortcutLabel": locale.value.todayText,
1205
+ "onNext": nextMonth,
1206
+ "onPrevious": previousMonth,
1207
+ "onClickHeaderLabel": () => changePanel("year"),
1208
+ "onSelect": onSelectDate,
1209
+ "getDateStatus": getDateStatus,
1210
+ "isShowShortcut": props.isShowShortcut,
1211
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1212
+ "onMouseLeave": () => emit("mouseLeave"),
1213
+ "isHideNotThisMonthDate": props.isHideNotThisMonthDate
1214
+ }, null);
1215
+ }
1216
+ if (currentPanel.value === "month") {
1217
+ return (0, import_vue17.createVNode)(TableMonth, {
1218
+ "calendar": currentPanelDate.value,
1219
+ "months": getMonths.value,
1220
+ "headerLabel": getLabel.value,
1221
+ "shortcutLabel": locale.value.thisMonthText,
1222
+ "onNext": nextYear,
1223
+ "onPrevious": previousYear,
1224
+ "onClickHeaderLabel": () => changePanel("year"),
1225
+ "onSelect": onSelectMonth,
1226
+ "getMonthStatus": getMonthStatus,
1227
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1228
+ "onMouseLeave": () => emit("mouseLeave"),
1229
+ "isShowShortcut": props.isShowShortcut
1230
+ }, null);
1231
+ }
1232
+ if (currentPanel.value === "year") {
1233
+ return (0, import_vue17.createVNode)(TableYear, {
1234
+ "years": getYears.value,
1235
+ "headerLabel": getLabel.value,
1236
+ "shortcutLabel": locale.value.thisYearText,
1237
+ "onNext": (year) => changeYear(year),
1238
+ "onPrevious": (year) => changeYear(year),
1239
+ "onSelect": onSelectYear,
1240
+ "getYearStatus": getYearStatus,
1241
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1242
+ "onMouseLeave": () => emit("mouseLeave"),
1243
+ "isShowShortcut": props.isShowShortcut
1244
+ }, null);
1245
+ }
1246
+ };
1247
+ }
1248
+ });
1249
+ var CalendarPanelRange = (0, import_vue18.defineComponent)({
1250
+ name: "CalendarPanelRange",
1251
+ props: calendarPanelRangeProps,
1252
+ emits: ["update:modelValue"],
1253
+ setup(props, {
1254
+ emit
1255
+ }) {
1256
+ var _a;
1257
+ const {
1258
+ startDate,
1259
+ endDate,
1260
+ hoveredDate,
1261
+ calendars,
1262
+ setStartDate,
1263
+ setEndDate,
1264
+ setHoveredDate,
1265
+ getDateRangeStatus,
1266
+ getCurrentDates,
1267
+ updateStartCalendar,
1268
+ updateEndCalendar
1269
+ } = useCalendarRange(props);
1270
+ if ((_a = props.modelValue) == null ? void 0 : _a.length) {
1271
+ updateStartCalendar(props.modelValue[0]);
1272
+ updateEndCalendar(props.modelValue[1]);
1273
+ }
1274
+ function onSelectDate(date) {
1275
+ if (props.type === "week" || props.type === "biweek") {
1276
+ const gap = {
1277
+ week: 6,
1278
+ biweek: 13
1279
+ };
1280
+ const startDate2 = startOfWeek(date, getLocale().formatLocale.firstDayOfWeek);
1281
+ const endDate2 = addDays(startDate2, gap[props.type]);
1282
+ setStartDate(startDate2);
1283
+ setEndDate(endDate2);
1284
+ emit("update:modelValue", getCurrentDates.value);
1285
+ return;
1286
+ }
1287
+ if (startDate.value && endDate.value) {
1288
+ setStartDate(void 0);
1289
+ setEndDate(void 0);
1290
+ setStartDate(date);
1291
+ return;
1292
+ }
1293
+ if (startDate.value && !endDate.value) {
1294
+ setEndDate(date);
1295
+ if (startDate.value && endDate.value) {
1296
+ emit("update:modelValue", getCurrentDates.value);
1297
+ }
1298
+ return;
1299
+ }
1300
+ if (!startDate.value && !endDate.value) {
1301
+ setStartDate(date);
1302
+ if (startDate.value && endDate.value) {
1303
+ emit("update:modelValue", getCurrentDates.value);
1304
+ }
1305
+ return;
1306
+ }
1307
+ }
1308
+ __name(onSelectDate, "onSelectDate");
1309
+ function getDateStatus(date) {
1310
+ var _a2, _b;
1311
+ let status = "default";
1312
+ if ((0, import_date_fns3.isToday)(date))
1313
+ status = "today";
1314
+ const {
1315
+ inRange,
1316
+ hoverInRange
1317
+ } = getDateRangeStatus(date);
1318
+ if (inRange || hoverInRange) {
1319
+ status = "range";
1320
+ }
1321
+ if (startDate.value && !endDate.value && (0, import_date_fns3.isEqual)(hoveredDate.value, date)) {
1322
+ status = "selected";
1323
+ }
1324
+ if ((0, import_date_fns3.isEqual)(startDate.value, date)) {
1325
+ status = "selected";
1326
+ }
1327
+ if ((0, import_date_fns3.isEqual)(endDate.value, date)) {
1328
+ status = "selected";
1329
+ }
1330
+ if (props.type === "week") {
1331
+ if ((_a2 = props.modelValue) == null ? void 0 : _a2.length) {
1332
+ const startDate2 = startOfWeek(props.modelValue[0], getLocale().formatLocale.firstDayOfWeek);
1333
+ const endDate2 = addDays(startDate2, 6);
1334
+ if (isDateBetween(date, startDate2, endDate2)) {
1335
+ status = "weekSelectedMiddle";
1336
+ if ((0, import_date_fns3.isEqual)(startDate2, date))
1337
+ status = "weekSelectedStart";
1338
+ if ((0, import_date_fns3.isEqual)(endDate2, date))
1339
+ status = "weekSelectedEnd";
1340
+ }
1341
+ }
1342
+ if (hoveredDate.value) {
1343
+ const startDate2 = startOfWeek(hoveredDate.value, getLocale().formatLocale.firstDayOfWeek);
1344
+ const endDate2 = addDays(startDate2, 6);
1345
+ if (isDateBetween(date, startDate2, endDate2)) {
1346
+ status = "weekHoveredMiddle";
1347
+ if ((0, import_date_fns3.isEqual)(startDate2, date))
1348
+ status = "weekHoveredStart";
1349
+ if ((0, import_date_fns3.isEqual)(endDate2, date))
1350
+ status = "weekHoveredEnd";
1351
+ }
1352
+ }
1353
+ }
1354
+ if (props.type === "biweek") {
1355
+ const getBiweekDates = /* @__PURE__ */ __name((date2) => {
1356
+ const firstWeekStartDate = startOfWeek(date2, getLocale().formatLocale.firstDayOfWeek);
1357
+ const firstWeekEndDate = addDays(firstWeekStartDate, 6);
1358
+ const secondWeekStartDate = startOfWeek(addDays(firstWeekStartDate, 7), getLocale().formatLocale.firstDayOfWeek);
1359
+ const secondWeekEndDate = addDays(secondWeekStartDate, 6);
1360
+ return {
1361
+ firstWeekStartDate,
1362
+ firstWeekEndDate,
1363
+ secondWeekStartDate,
1364
+ secondWeekEndDate
1365
+ };
1366
+ }, "getBiweekDates");
1367
+ if ((_b = props.modelValue) == null ? void 0 : _b.length) {
1368
+ const {
1369
+ firstWeekStartDate,
1370
+ firstWeekEndDate,
1371
+ secondWeekStartDate,
1372
+ secondWeekEndDate
1373
+ } = getBiweekDates(props.modelValue[0]);
1374
+ if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
1375
+ status = "weekSelectedMiddle";
1376
+ if ((0, import_date_fns3.isEqual)(firstWeekStartDate, date))
1377
+ status = "weekSelectedStart";
1378
+ if ((0, import_date_fns3.isEqual)(firstWeekEndDate, date))
1379
+ status = "weekSelectedEnd";
1380
+ if ((0, import_date_fns3.isEqual)(secondWeekStartDate, date))
1381
+ status = "weekSelectedStart";
1382
+ if ((0, import_date_fns3.isEqual)(secondWeekEndDate, date))
1383
+ status = "weekSelectedEnd";
1384
+ }
1385
+ }
1386
+ if (hoveredDate.value) {
1387
+ const {
1388
+ firstWeekStartDate,
1389
+ firstWeekEndDate,
1390
+ secondWeekStartDate,
1391
+ secondWeekEndDate
1392
+ } = getBiweekDates(hoveredDate.value);
1393
+ if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
1394
+ status = "weekHoveredMiddle";
1395
+ if ((0, import_date_fns3.isEqual)(firstWeekStartDate, date))
1396
+ status = "weekHoveredStart";
1397
+ if ((0, import_date_fns3.isEqual)(firstWeekEndDate, date))
1398
+ status = "weekHoveredEnd";
1399
+ if ((0, import_date_fns3.isEqual)(secondWeekStartDate, date))
1400
+ status = "weekHoveredStart";
1401
+ if ((0, import_date_fns3.isEqual)(secondWeekEndDate, date))
1402
+ status = "weekHoveredEnd";
1403
+ }
1404
+ }
1405
+ }
1406
+ return status;
1407
+ }
1408
+ __name(getDateStatus, "getDateStatus");
1409
+ function getMonthStatus(month, year) {
1410
+ let status = "default";
1411
+ const parseToDate = createDate(year, month);
1412
+ const {
1413
+ inRange,
1414
+ hoverInRange
1415
+ } = getDateRangeStatus(parseToDate);
1416
+ if (inRange || hoverInRange) {
1417
+ status = "range";
1418
+ }
1419
+ if (startDate.value && !endDate.value && (0, import_date_fns3.isEqual)(hoveredDate.value, parseToDate)) {
1420
+ status = "selected";
1421
+ }
1422
+ if ((0, import_date_fns3.isEqual)(startDate.value, parseToDate)) {
1423
+ status = "selected";
1424
+ }
1425
+ if ((0, import_date_fns3.isEqual)(endDate.value, parseToDate)) {
1426
+ status = "selected";
1427
+ }
1428
+ return status;
1429
+ }
1430
+ __name(getMonthStatus, "getMonthStatus");
1431
+ function getYearStatus(year) {
1432
+ var _a2, _b, _c;
1433
+ let status = "default";
1434
+ const parseToDate = createDate(year);
1435
+ const {
1436
+ inRange,
1437
+ hoverInRange
1438
+ } = getDateRangeStatus(parseToDate);
1439
+ if (inRange || hoverInRange) {
1440
+ status = "range";
1441
+ }
1442
+ if (startDate.value && !endDate.value && ((_a2 = hoveredDate.value) == null ? void 0 : _a2.getFullYear()) === parseToDate.getFullYear()) {
1443
+ status = "selected";
1444
+ }
1445
+ if (((_b = startDate.value) == null ? void 0 : _b.getFullYear()) === parseToDate.getFullYear()) {
1446
+ status = "selected";
1447
+ }
1448
+ if (((_c = endDate.value) == null ? void 0 : _c.getFullYear()) === parseToDate.getFullYear()) {
1449
+ status = "selected";
1450
+ }
1451
+ return status;
1452
+ }
1453
+ __name(getYearStatus, "getYearStatus");
1454
+ return () => {
1455
+ const isWeekAndBiweek = props.type === "week" || props.type === "biweek";
1456
+ const classes = isWeekAndBiweek ? "" : (0, import_recipes8.calendarPanelRangeRecipe)();
1457
+ const calendarPanelAttrs = {
1458
+ isRange: true,
1459
+ type: props.type,
1460
+ isHideNotThisMonthDate: props.type === "week" || props.type === "biweek" ? false : true,
1461
+ isShowShortcut: false,
1462
+ getDateStatus,
1463
+ getMonthStatus,
1464
+ getYearStatus,
1465
+ "onUpdate:modelValue": (date) => onSelectDate(date),
1466
+ onMouseEnter: (date) => setHoveredDate(date),
1467
+ onMouseLeave: () => setHoveredDate(void 0)
1468
+ };
1469
+ const leftNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1470
+ "data-pixel-parts": "CalendarPanelLeft"
1471
+ }, calendarPanelAttrs, {
1472
+ "onUpdateCalendar": (value) => updateStartCalendar(value),
1473
+ "calendar": calendars.value[0]
1474
+ }), null);
1475
+ const rightNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1476
+ "data-pixel-parts": "CalendarPanelRight"
1477
+ }, calendarPanelAttrs, {
1478
+ "onUpdateCalendar": (value) => updateEndCalendar(value),
1479
+ "calendar": calendars.value[1]
1480
+ }), null);
1481
+ const weekAndBiweekNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1482
+ "data-pixel-parts": "CalendarPanel"
1483
+ }, calendarPanelAttrs, {
1484
+ "onUpdateCalendar": (value) => updateStartCalendar(value),
1485
+ "calendar": props.modelValue[0],
1486
+ "type": "date"
1487
+ }), null);
1488
+ return (0, import_vue17.createVNode)("div", {
1489
+ "class": classes
1490
+ }, [isWeekAndBiweek ? weekAndBiweekNode : [leftNode, rightNode]]);
1491
+ };
1492
+ }
1493
+ });
1494
+ // Annotate the CommonJS export names for ESM import in node:
1495
+ 0 && (module.exports = {
1496
+ CalendarPanel,
1497
+ CalendarPanelRange
1498
+ });