@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,1851 @@
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/date-picker.tsx
32
+ var date_picker_exports = {};
33
+ __export(date_picker_exports, {
34
+ MpDatePicker: () => MpDatePicker
35
+ });
36
+ module.exports = __toCommonJS(date_picker_exports);
37
+ var import_vue20 = require("vue");
38
+ var import_vue21 = require("vue");
39
+ var import_pixel3_input = require("@mekari/pixel3-input");
40
+ var import_pixel3_popover = require("@mekari/pixel3-popover");
41
+ var import_pixel3_icon = require("@mekari/pixel3-icon");
42
+
43
+ // src/calendar-panel.tsx
44
+ var import_vue17 = require("vue");
45
+ var import_vue18 = require("vue");
46
+
47
+ // src/components/calendar/table-date.tsx
48
+ var import_vue9 = require("vue");
49
+ var import_vue10 = require("vue");
50
+ var import_pixel3_button = require("@mekari/pixel3-button");
51
+
52
+ // src/components/parts/date.tsx
53
+ var import_vue = require("vue");
54
+ var import_vue2 = require("vue");
55
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
56
+ var Date2 = (0, import_vue2.defineComponent)({
57
+ name: "Date",
58
+ props: {
59
+ status: {
60
+ type: String
61
+ },
62
+ isDisabled: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ isShowPinbar: {
67
+ type: Boolean,
68
+ default: false
69
+ }
70
+ },
71
+ setup(props, {
72
+ slots
73
+ }) {
74
+ return () => {
75
+ const dateItemClasses = (0, import_recipes.dateItemRecipe)({
76
+ status: props.status
77
+ });
78
+ const {
79
+ root,
80
+ pinbar
81
+ } = (0, import_recipes.pinbarSlotRecipe)();
82
+ return (0, import_vue.createVNode)("button", {
83
+ "disabled": props.isDisabled,
84
+ "data-status": props.status,
85
+ "class": dateItemClasses
86
+ }, [slots.default(), props.isShowPinbar && (0, import_vue.createVNode)("div", {
87
+ "class": root
88
+ }, [(0, import_vue.createVNode)("div", {
89
+ "class": pinbar
90
+ }, null)])]);
91
+ };
92
+ }
93
+ });
94
+
95
+ // src/components/parts/day.tsx
96
+ var import_vue3 = require("vue");
97
+ var import_vue4 = require("vue");
98
+ var import_recipes2 = require("@mekari/pixel3-styled-system/recipes");
99
+ var Day = (0, import_vue4.defineComponent)({
100
+ name: "Day",
101
+ setup(props, {
102
+ slots
103
+ }) {
104
+ return () => {
105
+ return (0, import_vue3.createVNode)("div", {
106
+ "class": (0, import_recipes2.dayItemRecipe)()
107
+ }, [slots.default()]);
108
+ };
109
+ }
110
+ });
111
+
112
+ // src/components/parts/month.tsx
113
+ var import_vue5 = require("vue");
114
+ var import_vue6 = require("vue");
115
+ var import_recipes3 = require("@mekari/pixel3-styled-system/recipes");
116
+ var Month = (0, import_vue6.defineComponent)({
117
+ name: "Month",
118
+ props: {
119
+ status: {
120
+ type: String
121
+ },
122
+ isDisabled: {
123
+ type: Boolean,
124
+ default: false
125
+ }
126
+ },
127
+ setup(props, {
128
+ slots
129
+ }) {
130
+ return () => {
131
+ const classes = (0, import_recipes3.monthItemRecipe)({
132
+ status: props.status
133
+ });
134
+ return (0, import_vue5.createVNode)("button", {
135
+ "disabled": props.isDisabled,
136
+ "data-status": props.status,
137
+ "class": classes
138
+ }, [slots.default()]);
139
+ };
140
+ }
141
+ });
142
+
143
+ // src/components/parts/year.tsx
144
+ var import_vue7 = require("vue");
145
+ var import_vue8 = require("vue");
146
+ var import_recipes4 = require("@mekari/pixel3-styled-system/recipes");
147
+ var YearItem = (0, import_vue8.defineComponent)({
148
+ name: "YearItem",
149
+ props: {
150
+ status: {
151
+ type: String
152
+ },
153
+ isDisabled: {
154
+ type: Boolean,
155
+ default: false
156
+ }
157
+ },
158
+ setup(props, {
159
+ slots
160
+ }) {
161
+ return () => {
162
+ const classes = (0, import_recipes4.yearItemRecipe)({
163
+ status: props.status
164
+ });
165
+ return (0, import_vue7.createVNode)("button", {
166
+ "disabled": props.isDisabled,
167
+ "data-status": props.status,
168
+ "class": classes
169
+ }, [slots.default()]);
170
+ };
171
+ }
172
+ });
173
+
174
+ // src/utils/base.ts
175
+ function chunk(arr, size) {
176
+ if (!Array.isArray(arr)) {
177
+ return [];
178
+ }
179
+ const result = [];
180
+ const len = arr.length;
181
+ let i = 0;
182
+ size = size || len;
183
+ while (i < len) {
184
+ result.push(arr.slice(i, i += size));
185
+ }
186
+ return result;
187
+ }
188
+ __name(chunk, "chunk");
189
+ var isObject = /* @__PURE__ */ __name((value) => {
190
+ return !!value && value.constructor === Object;
191
+ }, "isObject");
192
+ var assign = /* @__PURE__ */ __name((initial, override) => {
193
+ var _a;
194
+ if (!initial || !override)
195
+ return (_a = initial != null ? initial : override) != null ? _a : {};
196
+ return Object.entries({
197
+ ...initial,
198
+ ...override
199
+ }).reduce((acc, [key, value]) => {
200
+ return {
201
+ ...acc,
202
+ [key]: (() => {
203
+ if (isObject(initial[key]))
204
+ return assign(initial[key], value);
205
+ return value;
206
+ })()
207
+ };
208
+ }, {});
209
+ }, "assign");
210
+
211
+ // src/components/calendar/table-date.tsx
212
+ var import_recipes5 = require("@mekari/pixel3-styled-system/recipes");
213
+ var TableDate = (0, import_vue10.defineComponent)({
214
+ name: "TableDate",
215
+ props: {
216
+ days: {
217
+ type: Array,
218
+ default: () => []
219
+ },
220
+ dates: {
221
+ type: Array,
222
+ default: () => []
223
+ },
224
+ headerLabel: {
225
+ type: String,
226
+ default: ""
227
+ },
228
+ shortcutLabel: {
229
+ type: String,
230
+ default: ""
231
+ },
232
+ getDateStatus: {
233
+ type: Function,
234
+ default: () => {
235
+ }
236
+ },
237
+ isShowShortcut: {
238
+ type: Boolean
239
+ },
240
+ isRange: {
241
+ type: Boolean
242
+ },
243
+ isHideNotThisMonthDate: {
244
+ type: Boolean
245
+ }
246
+ },
247
+ emits: ["next", "previous", "changePanel", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
248
+ setup(props, {
249
+ emit
250
+ }) {
251
+ const {
252
+ headerRoot,
253
+ headerLabel,
254
+ dayWrapper,
255
+ dateItemRoot,
256
+ dateItemWrapper,
257
+ shortcutLabelWrapper
258
+ } = (0, import_recipes5.tableDateSlotRecipe)();
259
+ const getDates = (0, import_vue10.computed)(() => {
260
+ return chunk(props.dates, 7);
261
+ });
262
+ function onNextButton() {
263
+ emit("next");
264
+ }
265
+ __name(onNextButton, "onNextButton");
266
+ function onPreviousButton() {
267
+ emit("previous");
268
+ }
269
+ __name(onPreviousButton, "onPreviousButton");
270
+ function onSelectDate(date) {
271
+ emit("select", date);
272
+ }
273
+ __name(onSelectDate, "onSelectDate");
274
+ function onSelectToday() {
275
+ const today = /* @__PURE__ */ new Date();
276
+ onSelectDate(today);
277
+ }
278
+ __name(onSelectToday, "onSelectToday");
279
+ function getDateAttrs(date) {
280
+ const {
281
+ status,
282
+ isDisabled,
283
+ isShowPinbar
284
+ } = props.getDateStatus(date);
285
+ return {
286
+ status: isDisabled ? "disabled" : status,
287
+ isDisabled,
288
+ isShowPinbar,
289
+ onClick: () => onSelectDate(date),
290
+ onMouseenter: () => {
291
+ emit("mouseEnter", date);
292
+ },
293
+ onMouseleave: () => {
294
+ emit("mouseLeave");
295
+ },
296
+ style: {
297
+ visibility: props.isHideNotThisMonthDate && status === "notThisMonth" ? "hidden" : ""
298
+ }
299
+ };
300
+ }
301
+ __name(getDateAttrs, "getDateAttrs");
302
+ return () => {
303
+ return (0, import_vue9.createVNode)("div", null, [(0, import_vue9.createVNode)("div", {
304
+ "data-pixel-parts": "Header",
305
+ "class": headerRoot
306
+ }, [(0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
307
+ "left-icon": "chevrons-left",
308
+ "variant": "ghost",
309
+ "size": "sm",
310
+ "onClick": onPreviousButton
311
+ }, null), (0, import_vue9.createVNode)("button", {
312
+ "class": headerLabel,
313
+ "onClick": () => emit("clickHeaderLabel")
314
+ }, [props.headerLabel]), (0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
315
+ "right-icon": "chevrons-right",
316
+ "variant": "ghost",
317
+ "size": "sm",
318
+ "onClick": onNextButton
319
+ }, null)]), (0, import_vue9.createVNode)("div", {
320
+ "data-pixel-parts": "Content",
321
+ "class": dayWrapper
322
+ }, [props.days.map((day) => (0, import_vue9.createVNode)(Day, null, {
323
+ default: () => [(0, import_vue9.createTextVNode)(" "), day, (0, import_vue9.createTextVNode)(" ")]
324
+ }))]), (0, import_vue9.createVNode)("div", {
325
+ "data-pixel-parts": "Content",
326
+ "class": dateItemRoot
327
+ }, [getDates.value.map((dates, index) => (0, import_vue9.createVNode)("div", {
328
+ "class": dateItemWrapper,
329
+ "data-row-index": index
330
+ }, [dates.map((date) => (0, import_vue9.createVNode)(Date2, getDateAttrs(date), {
331
+ default: () => [(0, import_vue9.createTextVNode)(" "), date.getDate(), (0, import_vue9.createTextVNode)(" ")]
332
+ }))]))]), props.isShowShortcut && (0, import_vue9.createVNode)("div", {
333
+ "data-pixel-parts": "Shortcut",
334
+ "class": shortcutLabelWrapper
335
+ }, [(0, import_vue9.createVNode)(import_pixel3_button.MpButton, {
336
+ "variant": "ghost",
337
+ "onClick": onSelectToday
338
+ }, {
339
+ default: () => [props.shortcutLabel]
340
+ })])]);
341
+ };
342
+ }
343
+ });
344
+
345
+ // src/components/calendar/table-month.tsx
346
+ var import_vue11 = require("vue");
347
+ var import_vue12 = require("vue");
348
+ var import_pixel3_button2 = require("@mekari/pixel3-button");
349
+
350
+ // src/utils/date.ts
351
+ var import_date_fns = require("date-fns");
352
+ function createDate(y, M = 0, d = 1, h = 0, m = 0, s = 0, ms = 0) {
353
+ const date = new Date(y, M, d, h, m, s, ms);
354
+ if (y < 100 && y >= 0) {
355
+ date.setFullYear(y);
356
+ }
357
+ return date;
358
+ }
359
+ __name(createDate, "createDate");
360
+ function isValidDate(date) {
361
+ return date instanceof Date && !isNaN(date);
362
+ }
363
+ __name(isValidDate, "isValidDate");
364
+ function isValidRangeDate(date) {
365
+ return Array.isArray(date) && date.length === 2 && date.every(isValidDate) && date[0] <= date[1];
366
+ }
367
+ __name(isValidRangeDate, "isValidRangeDate");
368
+ function startOfMonth(value) {
369
+ const date = new Date(value);
370
+ date.setDate(1);
371
+ date.setHours(0, 0, 0, 0);
372
+ return date;
373
+ }
374
+ __name(startOfMonth, "startOfMonth");
375
+ function startOfWeek(value, firstDayOfWeek = 0) {
376
+ if (!(firstDayOfWeek >= 0 && firstDayOfWeek <= 6)) {
377
+ throw new RangeError("weekStartsOn must be between 0 and 6");
378
+ }
379
+ const date = new Date(value);
380
+ const day = date.getDay();
381
+ const diff = (day + 7 - firstDayOfWeek) % 7;
382
+ date.setDate(date.getDate() - diff);
383
+ date.setHours(0, 0, 0, 0);
384
+ return date;
385
+ }
386
+ __name(startOfWeek, "startOfWeek");
387
+ function getCalendar({
388
+ firstDayOfWeek,
389
+ year,
390
+ month
391
+ }) {
392
+ const arr = [];
393
+ const calendar = createDate(year, month, 0);
394
+ const lastDayInLastMonth = calendar.getDate();
395
+ const firstDayInLastMonth = lastDayInLastMonth - (calendar.getDay() + 7 - firstDayOfWeek) % 7;
396
+ for (let i = firstDayInLastMonth; i <= lastDayInLastMonth; i++) {
397
+ arr.push(createDate(year, month, i - lastDayInLastMonth));
398
+ }
399
+ calendar.setMonth(month + 1, 0);
400
+ const lastDayInCurrentMonth = calendar.getDate();
401
+ for (let i = 1; i <= lastDayInCurrentMonth; i++) {
402
+ arr.push(createDate(year, month, i));
403
+ }
404
+ const lastMonthLength = lastDayInLastMonth - firstDayInLastMonth + 1;
405
+ const nextMonthLength = 6 * 7 - lastMonthLength - lastDayInCurrentMonth;
406
+ for (let i = 1; i <= nextMonthLength; i++) {
407
+ arr.push(createDate(year, month, lastDayInCurrentMonth + i));
408
+ }
409
+ return arr;
410
+ }
411
+ __name(getCalendar, "getCalendar");
412
+ function getNextMonth(date) {
413
+ return (0, import_date_fns.addMonths)(date, 1);
414
+ }
415
+ __name(getNextMonth, "getNextMonth");
416
+ function getPreviousMonth(date) {
417
+ return (0, import_date_fns.addMonths)(date, -1);
418
+ }
419
+ __name(getPreviousMonth, "getPreviousMonth");
420
+ function addDays(value, days) {
421
+ const date = new Date(value);
422
+ date.setDate(date.getDate() + days);
423
+ return date;
424
+ }
425
+ __name(addDays, "addDays");
426
+ function isDateBetween(date, min, max) {
427
+ const _date = new Date(date);
428
+ const _min = new Date(min);
429
+ const _max = new Date(max);
430
+ return _date.getTime() >= _min.getTime() && _date.getTime() <= _max.getTime();
431
+ }
432
+ __name(isDateBetween, "isDateBetween");
433
+
434
+ // src/components/calendar/table-month.tsx
435
+ var import_recipes6 = require("@mekari/pixel3-styled-system/recipes");
436
+ var TableMonth = (0, import_vue12.defineComponent)({
437
+ name: "TableMonth",
438
+ props: {
439
+ calendar: {
440
+ type: Date,
441
+ default: () => /* @__PURE__ */ new Date()
442
+ },
443
+ months: {
444
+ type: Array,
445
+ default: () => []
446
+ },
447
+ headerLabel: {
448
+ type: String,
449
+ default: ""
450
+ },
451
+ shortcutLabel: {
452
+ type: String,
453
+ default: ""
454
+ },
455
+ getMonthStatus: {
456
+ type: Function,
457
+ default: () => {
458
+ }
459
+ },
460
+ isShowShortcut: {
461
+ type: Boolean
462
+ }
463
+ },
464
+ emits: ["next", "previous", "select", "clickHeaderLabel", "mouseEnter", "mouseLeave"],
465
+ setup(props, {
466
+ emit
467
+ }) {
468
+ const {
469
+ headerRoot,
470
+ headerLabel,
471
+ monthItemRoot,
472
+ monthItemWrapper,
473
+ shortcutLabelWrapper
474
+ } = (0, import_recipes6.tableMonthSlotRecipe)();
475
+ const getMonths = (0, import_vue12.computed)(() => {
476
+ return chunk(props.months, 3);
477
+ });
478
+ const getCalendarYear = (0, import_vue12.computed)(() => props.calendar.getFullYear());
479
+ function onNextButton() {
480
+ emit("next");
481
+ }
482
+ __name(onNextButton, "onNextButton");
483
+ function onPreviousButton() {
484
+ emit("previous", "previousMonth");
485
+ }
486
+ __name(onPreviousButton, "onPreviousButton");
487
+ function onSelectMonth(month, year) {
488
+ emit("select", month, year);
489
+ }
490
+ __name(onSelectMonth, "onSelectMonth");
491
+ function getMonthAttrs(month) {
492
+ const {
493
+ status,
494
+ isDisabled
495
+ } = props.getMonthStatus(month, getCalendarYear.value);
496
+ return {
497
+ status: isDisabled ? "disabled" : status,
498
+ isDisabled,
499
+ onClick: () => onSelectMonth(month, getCalendarYear.value),
500
+ onMouseenter: () => {
501
+ emit("mouseEnter", createDate(getCalendarYear.value, month));
502
+ },
503
+ onMouseleave: () => {
504
+ emit("mouseLeave");
505
+ }
506
+ };
507
+ }
508
+ __name(getMonthAttrs, "getMonthAttrs");
509
+ return () => {
510
+ return (0, import_vue11.createVNode)("div", null, [(0, import_vue11.createVNode)("div", {
511
+ "data-pixel-parts": "Header",
512
+ "class": headerRoot
513
+ }, [(0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
514
+ "left-icon": "chevrons-left",
515
+ "variant": "ghost",
516
+ "size": "sm",
517
+ "onClick": onPreviousButton
518
+ }, null), (0, import_vue11.createVNode)("button", {
519
+ "class": headerLabel,
520
+ "onClick": () => emit("clickHeaderLabel")
521
+ }, [props.headerLabel]), (0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
522
+ "right-icon": "chevrons-right",
523
+ "variant": "ghost",
524
+ "size": "sm",
525
+ "onClick": onNextButton
526
+ }, null)]), (0, import_vue11.createVNode)("div", {
527
+ "data-pixel-parts": "Content",
528
+ "class": monthItemRoot
529
+ }, [getMonths.value.map((data) => (0, import_vue11.createVNode)("div", {
530
+ "class": monthItemWrapper
531
+ }, [data.map((month) => (0, import_vue11.createVNode)(Month, getMonthAttrs(month.month), {
532
+ default: () => [" ", month.text, " "]
533
+ }))]))]), props.isShowShortcut && (0, import_vue11.createVNode)("div", {
534
+ "data-pixel-parts": "Shortcut",
535
+ "class": shortcutLabelWrapper
536
+ }, [(0, import_vue11.createVNode)(import_pixel3_button2.MpButton, {
537
+ "variant": "ghost",
538
+ "onClick": () => onSelectMonth((/* @__PURE__ */ new Date()).getMonth(), getCalendarYear.value)
539
+ }, {
540
+ default: () => [props.shortcutLabel]
541
+ })])]);
542
+ };
543
+ }
544
+ });
545
+
546
+ // src/components/calendar/table-year.tsx
547
+ var import_vue13 = require("vue");
548
+ var import_vue14 = require("vue");
549
+ var import_pixel3_button3 = require("@mekari/pixel3-button");
550
+ var import_recipes7 = require("@mekari/pixel3-styled-system/recipes");
551
+ var TableYear = (0, import_vue14.defineComponent)({
552
+ name: "TableYear",
553
+ props: {
554
+ years: {
555
+ type: Array,
556
+ default: () => []
557
+ },
558
+ headerLabel: {
559
+ type: String,
560
+ default: ""
561
+ },
562
+ shortcutLabel: {
563
+ type: String,
564
+ default: ""
565
+ },
566
+ getYearStatus: {
567
+ type: Function,
568
+ default: () => {
569
+ }
570
+ },
571
+ isShowShortcut: {
572
+ type: Boolean
573
+ }
574
+ },
575
+ emits: ["next", "previous", "select", "mouseEnter", "mouseLeave"],
576
+ setup(props, {
577
+ emit
578
+ }) {
579
+ const {
580
+ headerRoot,
581
+ headerLabel,
582
+ yearItemRoot,
583
+ yearItemWrapper,
584
+ shortcutLabelWrapper
585
+ } = (0, import_recipes7.tableYearSlotRecipe)();
586
+ const getYears = (0, import_vue14.computed)(() => {
587
+ return chunk(props.years, 4);
588
+ });
589
+ function onNextButton() {
590
+ const lastYear = props.years[props.years.length - 1];
591
+ emit("next", lastYear + 1);
592
+ }
593
+ __name(onNextButton, "onNextButton");
594
+ function onPreviousButton() {
595
+ const firstYear = props.years[0];
596
+ emit("previous", firstYear - 1);
597
+ }
598
+ __name(onPreviousButton, "onPreviousButton");
599
+ function onSelectYear(year) {
600
+ emit("select", year);
601
+ }
602
+ __name(onSelectYear, "onSelectYear");
603
+ function getMonthAttrs(year) {
604
+ const {
605
+ status,
606
+ isDisabled
607
+ } = props.getYearStatus(year);
608
+ return {
609
+ status: isDisabled ? "disabled" : status,
610
+ isDisabled,
611
+ onClick: () => onSelectYear(year),
612
+ onMouseenter: () => {
613
+ emit("mouseEnter", createDate(year));
614
+ },
615
+ onMouseleave: () => {
616
+ emit("mouseLeave");
617
+ }
618
+ };
619
+ }
620
+ __name(getMonthAttrs, "getMonthAttrs");
621
+ return () => {
622
+ return (0, import_vue13.createVNode)("div", null, [(0, import_vue13.createVNode)("div", {
623
+ "data-pixel-parts": "Header",
624
+ "class": headerRoot
625
+ }, [(0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
626
+ "left-icon": "chevrons-left",
627
+ "variant": "ghost",
628
+ "size": "sm",
629
+ "onClick": onPreviousButton
630
+ }, null), (0, import_vue13.createVNode)("button", {
631
+ "class": headerLabel
632
+ }, [props.headerLabel]), (0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
633
+ "right-icon": "chevrons-right",
634
+ "variant": "ghost",
635
+ "size": "sm",
636
+ "onClick": onNextButton
637
+ }, null)]), (0, import_vue13.createVNode)("div", {
638
+ "class": yearItemRoot
639
+ }, [getYears.value.map((data) => (0, import_vue13.createVNode)("div", {
640
+ "class": yearItemWrapper
641
+ }, [data.map((year) => (0, import_vue13.createVNode)(YearItem, getMonthAttrs(year), {
642
+ default: () => [(0, import_vue13.createTextVNode)(" "), year, (0, import_vue13.createTextVNode)(" ")]
643
+ }))]))]), props.isShowShortcut && (0, import_vue13.createVNode)("div", {
644
+ "class": shortcutLabelWrapper
645
+ }, [(0, import_vue13.createVNode)(import_pixel3_button3.MpButton, {
646
+ "variant": "ghost",
647
+ "onClick": () => onSelectYear((/* @__PURE__ */ new Date()).getFullYear())
648
+ }, {
649
+ default: () => [props.shortcutLabel]
650
+ })])]);
651
+ };
652
+ }
653
+ });
654
+
655
+ // src/calendar-panel.tsx
656
+ var import_date_fns3 = require("date-fns");
657
+
658
+ // src/composables/useCalendar.ts
659
+ var import_vue15 = require("vue");
660
+ var import_date_fns2 = require("date-fns");
661
+ function useCalendar(date, locale) {
662
+ const currentDate = (0, import_vue15.ref)(isValidDate(date) ? date : /* @__PURE__ */ new Date());
663
+ const currentPanel = (0, import_vue15.ref)("date");
664
+ const nextMonth = /* @__PURE__ */ __name(() => {
665
+ currentDate.value = getNextMonth(currentDate.value);
666
+ }, "nextMonth");
667
+ const previousMonth = /* @__PURE__ */ __name(() => {
668
+ currentDate.value = getPreviousMonth(currentDate.value);
669
+ }, "previousMonth");
670
+ const nextYear = /* @__PURE__ */ __name(() => {
671
+ currentDate.value = (0, import_date_fns2.addYears)(currentDate.value, 1);
672
+ }, "nextYear");
673
+ const previousYear = /* @__PURE__ */ __name(() => {
674
+ currentDate.value = (0, import_date_fns2.addYears)(currentDate.value, -1);
675
+ }, "previousYear");
676
+ const changeYear = /* @__PURE__ */ __name((year) => {
677
+ currentDate.value = (0, import_date_fns2.setYear)(currentDate.value, year);
678
+ }, "changeYear");
679
+ const changeMonth = /* @__PURE__ */ __name((month) => {
680
+ currentDate.value = (0, import_date_fns2.setMonth)(currentDate.value, month);
681
+ }, "changeMonth");
682
+ const getSplitDates = (0, import_vue15.computed)(() => {
683
+ return {
684
+ day: currentDate.value.getDay(),
685
+ month: currentDate.value.getMonth(),
686
+ year: currentDate.value.getFullYear(),
687
+ monthLabel: locale.value.months[currentDate.value.getMonth()]
688
+ };
689
+ });
690
+ const getDates = (0, import_vue15.computed)(() => {
691
+ const {
692
+ year,
693
+ month
694
+ } = getSplitDates.value;
695
+ const arr = getCalendar({
696
+ firstDayOfWeek: locale.value.formatLocale.firstDayOfWeek || 0,
697
+ year,
698
+ month
699
+ });
700
+ return arr;
701
+ });
702
+ const getMonths = (0, import_vue15.computed)(() => {
703
+ const monthsLocale = locale.value.formatLocale.monthsShort || locale.value.months;
704
+ const months = monthsLocale.map((text, month) => {
705
+ return {
706
+ text,
707
+ month
708
+ };
709
+ });
710
+ return months;
711
+ });
712
+ const getYears = (0, import_vue15.computed)(() => {
713
+ const {
714
+ year
715
+ } = getSplitDates.value;
716
+ const firstYear = Math.floor(year / 10) * 10;
717
+ const years = [];
718
+ for (let i = 0; i < 10; i++) {
719
+ years.push(firstYear + i);
720
+ }
721
+ return years;
722
+ });
723
+ const getLabel = (0, import_vue15.computed)(() => {
724
+ const {
725
+ year,
726
+ monthLabel
727
+ } = getSplitDates.value;
728
+ if (currentPanel.value === "date")
729
+ return `${monthLabel} ${year}`;
730
+ if (currentPanel.value === "month")
731
+ return `${year}`;
732
+ if (currentPanel.value === "year")
733
+ return `${getYears.value[0]} - ${getYears.value[9]}`;
734
+ return "";
735
+ });
736
+ function changePanel(value) {
737
+ currentPanel.value = value;
738
+ }
739
+ __name(changePanel, "changePanel");
740
+ function setPanelDate(date2) {
741
+ currentDate.value = date2;
742
+ }
743
+ __name(setPanelDate, "setPanelDate");
744
+ return {
745
+ currentDate,
746
+ currentPanel,
747
+ nextMonth,
748
+ previousMonth,
749
+ nextYear,
750
+ previousYear,
751
+ changeYear,
752
+ changeMonth,
753
+ getDates,
754
+ getMonths,
755
+ getYears,
756
+ getLabel,
757
+ getSplitDates,
758
+ changePanel,
759
+ setPanelDate
760
+ };
761
+ }
762
+ __name(useCalendar, "useCalendar");
763
+
764
+ // src/composables/useCalendarRange.ts
765
+ var import_vue16 = require("vue");
766
+ function useCalendarRange(props) {
767
+ const leftCalendar = startOfMonth(/* @__PURE__ */ new Date());
768
+ const rightCalendar = startOfMonth(getNextMonth(/* @__PURE__ */ new Date()));
769
+ const startDate = (0, import_vue16.ref)(props.modelValue[0]);
770
+ const endDate = (0, import_vue16.ref)(props.modelValue[1]);
771
+ const hoveredDate = (0, import_vue16.ref)();
772
+ const calendars = (0, import_vue16.ref)([leftCalendar, rightCalendar]);
773
+ const getCurrentDates = (0, import_vue16.computed)(() => {
774
+ if (startDate.value && !endDate.value)
775
+ return [startDate.value];
776
+ if (startDate.value && endDate.value)
777
+ return [startDate.value, endDate.value];
778
+ return [];
779
+ });
780
+ const calendarMinDiff = (0, import_vue16.computed)(() => {
781
+ const map = {
782
+ date: 1,
783
+ // type:date min 1 month
784
+ month: 1 * 12,
785
+ // type:month min 1 year
786
+ year: 10 * 12
787
+ // type:year min 10 year
788
+ };
789
+ return map[props.type] || map.date;
790
+ });
791
+ const calendarMaxDiff = (0, import_vue16.computed)(() => Infinity);
792
+ function setStartDate(date) {
793
+ startDate.value = date;
794
+ }
795
+ __name(setStartDate, "setStartDate");
796
+ function setEndDate(date) {
797
+ endDate.value = date;
798
+ }
799
+ __name(setEndDate, "setEndDate");
800
+ function setHoveredDate(date) {
801
+ hoveredDate.value = date;
802
+ }
803
+ __name(setHoveredDate, "setHoveredDate");
804
+ function getDateRangeStatus(cellDate) {
805
+ const status = {
806
+ inRange: false,
807
+ hoverInRange: false,
808
+ activeDragRange: false
809
+ };
810
+ const isInRange = /* @__PURE__ */ __name((data, range, fn = (v) => v.getTime()) => {
811
+ const value = fn(data);
812
+ let [min, max] = range.map(fn);
813
+ if (min > max) {
814
+ [min, max] = [max, min];
815
+ }
816
+ return value > min && value < max;
817
+ }, "isInRange");
818
+ if (getCurrentDates.value.length === 2 && isInRange(cellDate, getCurrentDates.value)) {
819
+ status.inRange = true;
820
+ }
821
+ if (getCurrentDates.value.length === 1 && hoveredDate.value && isInRange(cellDate, [getCurrentDates.value[0], hoveredDate.value])) {
822
+ status.hoverInRange = true;
823
+ }
824
+ if (getCurrentDates.value[0]) {
825
+ status.activeDragRange = true;
826
+ }
827
+ return status;
828
+ }
829
+ __name(getDateRangeStatus, "getDateRangeStatus");
830
+ function updateStartCalendar(value) {
831
+ updateCalendars([value, calendars.value[1]], 1);
832
+ }
833
+ __name(updateStartCalendar, "updateStartCalendar");
834
+ function updateEndCalendar(value) {
835
+ updateCalendars([calendars.value[0], value], 0);
836
+ }
837
+ __name(updateEndCalendar, "updateEndCalendar");
838
+ function updateCalendars(value, adjustIndex = 1) {
839
+ const gap = getCalendarGap(value);
840
+ if (gap) {
841
+ const calendar = new Date(value[adjustIndex]);
842
+ calendar.setMonth(calendar.getMonth() + (adjustIndex === 0 ? -gap : gap));
843
+ value[adjustIndex] = calendar;
844
+ }
845
+ calendars.value = value;
846
+ }
847
+ __name(updateCalendars, "updateCalendars");
848
+ function getCalendarGap(calendars2) {
849
+ const [calendarLeft, calendarRight] = calendars2;
850
+ const yearDiff = calendarRight.getFullYear() - calendarLeft.getFullYear();
851
+ const monthDiff = calendarRight.getMonth() - calendarLeft.getMonth();
852
+ const diff = yearDiff * 12 + monthDiff;
853
+ const min = calendarMinDiff.value;
854
+ const max = calendarMaxDiff.value;
855
+ if (diff < min) {
856
+ return min - diff;
857
+ }
858
+ if (diff > max) {
859
+ return max - diff;
860
+ }
861
+ return 0;
862
+ }
863
+ __name(getCalendarGap, "getCalendarGap");
864
+ return {
865
+ startDate,
866
+ endDate,
867
+ hoveredDate,
868
+ calendars,
869
+ getCurrentDates,
870
+ setStartDate,
871
+ setEndDate,
872
+ setHoveredDate,
873
+ getDateRangeStatus,
874
+ updateStartCalendar,
875
+ updateEndCalendar
876
+ };
877
+ }
878
+ __name(useCalendarRange, "useCalendarRange");
879
+
880
+ // src/modules/date-picker.props.ts
881
+ var calendarPanelProps = {
882
+ modelValue: {
883
+ type: Date
884
+ },
885
+ defaultValue: {
886
+ type: Date
887
+ },
888
+ type: {
889
+ type: String,
890
+ default: "date"
891
+ },
892
+ calendar: {
893
+ type: Date
894
+ },
895
+ isRange: {
896
+ type: Boolean,
897
+ default: false
898
+ },
899
+ isShowShortcut: {
900
+ type: Boolean,
901
+ default: true
902
+ },
903
+ disabledDate: {
904
+ type: Function,
905
+ default: () => {
906
+ }
907
+ },
908
+ disabledMonth: {
909
+ type: Function,
910
+ default: () => {
911
+ }
912
+ },
913
+ disabledYear: {
914
+ type: Function,
915
+ default: () => {
916
+ }
917
+ },
918
+ getDateStatus: {
919
+ type: Function,
920
+ default: void 0
921
+ },
922
+ getMonthStatus: {
923
+ type: Function,
924
+ default: void 0
925
+ },
926
+ getYearStatus: {
927
+ type: Function,
928
+ default: void 0
929
+ },
930
+ isHideNotThisMonthDate: {
931
+ type: Boolean
932
+ }
933
+ };
934
+ var calendarPanelRangeProps = {
935
+ ...calendarPanelProps,
936
+ modelValue: {
937
+ type: Array
938
+ }
939
+ };
940
+ var datePickerProps = {
941
+ id: {
942
+ type: String
943
+ },
944
+ modelValue: {
945
+ type: [String, Number, Date, Array]
946
+ },
947
+ type: calendarPanelProps.type,
948
+ valueType: {
949
+ type: String,
950
+ default: "date"
951
+ },
952
+ format: {
953
+ type: String
954
+ },
955
+ rangeSeparator: {
956
+ type: String,
957
+ default: " - "
958
+ },
959
+ placeholder: {
960
+ type: String,
961
+ default: ""
962
+ },
963
+ errorMessage: {
964
+ type: String,
965
+ default: "Format tanggal/waktu salah"
966
+ },
967
+ disabledMessage: {
968
+ type: String,
969
+ default: ""
970
+ },
971
+ lang: {
972
+ type: Object,
973
+ default: () => {
974
+ }
975
+ },
976
+ inputAttr: {
977
+ type: Object,
978
+ default: () => ({})
979
+ },
980
+ contentAttr: {
981
+ type: Object,
982
+ default: () => ({})
983
+ },
984
+ isRange: calendarPanelProps.isRange,
985
+ isReadOnly: {
986
+ type: Boolean,
987
+ default: false
988
+ },
989
+ isDisabled: {
990
+ type: Boolean,
991
+ default: false
992
+ },
993
+ isClearable: {
994
+ type: Boolean,
995
+ default: true
996
+ },
997
+ isInvalid: {
998
+ type: Boolean,
999
+ default: false
1000
+ },
1001
+ usePortal: {
1002
+ type: Boolean,
1003
+ default: false
1004
+ },
1005
+ isKeepAlive: {
1006
+ type: Boolean,
1007
+ default: false
1008
+ },
1009
+ isInline: {
1010
+ type: Boolean,
1011
+ default: false
1012
+ },
1013
+ isNotClickable: {
1014
+ type: Boolean,
1015
+ default: false
1016
+ },
1017
+ isDisableHeader: {
1018
+ type: Boolean,
1019
+ default: false
1020
+ },
1021
+ isShowShortcut: {
1022
+ type: Boolean,
1023
+ default: false
1024
+ },
1025
+ disabledDate: calendarPanelProps.disabledDate,
1026
+ disabledMonth: calendarPanelProps.disabledMonth,
1027
+ disabledYear: calendarPanelProps.disabledYear
1028
+ };
1029
+
1030
+ // src/modules/date-picker.context.ts
1031
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
1032
+ var [DatePickerProvider, useDatePickerContext] = (0, import_pixel3_utils.usePixelCreateContext)("DatePickerContext");
1033
+
1034
+ // src/modules/date-picker.locales.ts
1035
+ var import_en = __toESM(require("date-format-parse/lib/locale/en"));
1036
+ var locales = {
1037
+ formatLocale: import_en.default,
1038
+ days: import_en.default.weekdaysMin,
1039
+ months: import_en.default.monthsShort,
1040
+ yearFormat: "YYYY",
1041
+ monthFormat: "MMM",
1042
+ monthBeforeYear: true,
1043
+ todayText: "Today",
1044
+ thisMonthText: "This Month",
1045
+ thisYearText: "This Year"
1046
+ };
1047
+ function getLocale(config) {
1048
+ if (!config) {
1049
+ return locales;
1050
+ }
1051
+ return assign(locales, config);
1052
+ }
1053
+ __name(getLocale, "getLocale");
1054
+
1055
+ // src/calendar-panel.tsx
1056
+ var import_recipes8 = require("@mekari/pixel3-styled-system/recipes");
1057
+ var CalendarPanel = (0, import_vue18.defineComponent)({
1058
+ name: "CalendarPanel",
1059
+ props: calendarPanelProps,
1060
+ emits: ["update:modelValue", "mouseEnter", "mouseLeave", "updateCalendar"],
1061
+ setup(props, {
1062
+ emit
1063
+ }) {
1064
+ const {
1065
+ locale
1066
+ } = useDatePickerContext();
1067
+ const restValue = (0, import_vue18.ref)(props.modelValue);
1068
+ const {
1069
+ currentDate: currentPanelDate,
1070
+ currentPanel,
1071
+ changePanel,
1072
+ getDates,
1073
+ getMonths,
1074
+ getYears,
1075
+ nextMonth,
1076
+ previousMonth,
1077
+ nextYear,
1078
+ previousYear,
1079
+ getLabel,
1080
+ changeMonth,
1081
+ changeYear
1082
+ } = useCalendar(props.modelValue || props.defaultValue, locale);
1083
+ function onSelectDate(date) {
1084
+ currentPanelDate.value = date;
1085
+ restValue.value = date;
1086
+ emit("update:modelValue", restValue.value);
1087
+ }
1088
+ __name(onSelectDate, "onSelectDate");
1089
+ function onSelectMonth(value, year) {
1090
+ if (props.type === "month") {
1091
+ const day = 1;
1092
+ const month = value;
1093
+ const date = new Date(year, month, day);
1094
+ restValue.value = date;
1095
+ emit("update:modelValue", restValue.value);
1096
+ return;
1097
+ }
1098
+ changeMonth(value);
1099
+ changePanel("date");
1100
+ }
1101
+ __name(onSelectMonth, "onSelectMonth");
1102
+ function onSelectYear(value) {
1103
+ if (props.type === "year") {
1104
+ const day = 1;
1105
+ const month = currentPanelDate.value.getMonth();
1106
+ const year = value;
1107
+ const date = new Date(year, month, day);
1108
+ restValue.value = date;
1109
+ emit("update:modelValue", restValue.value);
1110
+ return;
1111
+ }
1112
+ changeYear(value);
1113
+ changePanel("month");
1114
+ }
1115
+ __name(onSelectYear, "onSelectYear");
1116
+ function getDateStatus(date) {
1117
+ let status = "default";
1118
+ if ((0, import_date_fns3.isToday)(date))
1119
+ status = "today";
1120
+ if ((0, import_date_fns3.isEqual)(props.modelValue, date)) {
1121
+ status = "selected";
1122
+ }
1123
+ const isCurrentMonth = currentPanelDate.value.getMonth() === date.getMonth();
1124
+ if (!isCurrentMonth)
1125
+ status = "notThisMonth";
1126
+ if (props.getDateStatus && props.getDateStatus(date)) {
1127
+ status = props.getDateStatus(date);
1128
+ if (props.isHideNotThisMonthDate && !isCurrentMonth) {
1129
+ status = "notThisMonth";
1130
+ }
1131
+ }
1132
+ return {
1133
+ status,
1134
+ isDisabled: props.disabledDate ? props.disabledDate(date) : false,
1135
+ // TODO : Handle show pin bar
1136
+ isShowPinbar: false
1137
+ };
1138
+ }
1139
+ __name(getDateStatus, "getDateStatus");
1140
+ function getMonthStatus(month, year) {
1141
+ let status = "default";
1142
+ const isCurrentMonth = currentPanelDate.value.getMonth() === month && year === (/* @__PURE__ */ new Date()).getFullYear();
1143
+ if (isCurrentMonth)
1144
+ status = "today";
1145
+ if (props.type === "month" && props.modelValue) {
1146
+ const isMonthEqual = props.modelValue.getMonth() === month;
1147
+ const isYearEqual = props.modelValue.getFullYear() === currentPanelDate.value.getFullYear();
1148
+ const isSelected = isMonthEqual && isYearEqual;
1149
+ if (isSelected)
1150
+ status = "selected";
1151
+ }
1152
+ if (props.getMonthStatus && props.getMonthStatus(month, year)) {
1153
+ status = props.getMonthStatus(month, year);
1154
+ }
1155
+ return {
1156
+ status,
1157
+ isDisabled: props.disabledMonth(month, year) || false
1158
+ };
1159
+ }
1160
+ __name(getMonthStatus, "getMonthStatus");
1161
+ function getYearStatus(year) {
1162
+ var _a;
1163
+ let status = "default";
1164
+ const isCurrentYear = (/* @__PURE__ */ new Date()).getFullYear() === year;
1165
+ if (isCurrentYear)
1166
+ status = "today";
1167
+ const isSelected = ((_a = props.modelValue) == null ? void 0 : _a.getFullYear()) === year;
1168
+ if (isSelected)
1169
+ status = "selected";
1170
+ if (props.getYearStatus && props.getYearStatus(year)) {
1171
+ status = props.getYearStatus(year);
1172
+ }
1173
+ return {
1174
+ status,
1175
+ isDisabled: props.disabledYear(year) || false
1176
+ };
1177
+ }
1178
+ __name(getYearStatus, "getYearStatus");
1179
+ function initCalendar() {
1180
+ if (props.calendar) {
1181
+ const calendarDate = props.calendar;
1182
+ currentPanelDate.value = calendarDate;
1183
+ }
1184
+ }
1185
+ __name(initCalendar, "initCalendar");
1186
+ (0, import_vue18.watch)(() => props.modelValue, (newValue) => {
1187
+ if (newValue)
1188
+ restValue.value = newValue;
1189
+ }, {
1190
+ immediate: true
1191
+ });
1192
+ (0, import_vue18.watch)(() => props.type, (newValue) => {
1193
+ if (newValue)
1194
+ currentPanel.value = newValue;
1195
+ }, {
1196
+ immediate: true
1197
+ });
1198
+ (0, import_vue18.watch)(() => currentPanelDate.value, (newValue) => {
1199
+ if (newValue) {
1200
+ emit("updateCalendar", newValue);
1201
+ }
1202
+ });
1203
+ (0, import_vue18.watch)(() => props.calendar, () => {
1204
+ initCalendar();
1205
+ }, {
1206
+ immediate: true
1207
+ });
1208
+ return () => {
1209
+ if (currentPanel.value === "date") {
1210
+ return (0, import_vue17.createVNode)(TableDate, {
1211
+ "days": locale.value.days,
1212
+ "dates": getDates.value,
1213
+ "headerLabel": getLabel.value,
1214
+ "shortcutLabel": locale.value.todayText,
1215
+ "onNext": nextMonth,
1216
+ "onPrevious": previousMonth,
1217
+ "onClickHeaderLabel": () => changePanel("year"),
1218
+ "onSelect": onSelectDate,
1219
+ "getDateStatus": getDateStatus,
1220
+ "isShowShortcut": props.isShowShortcut,
1221
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1222
+ "onMouseLeave": () => emit("mouseLeave"),
1223
+ "isHideNotThisMonthDate": props.isHideNotThisMonthDate
1224
+ }, null);
1225
+ }
1226
+ if (currentPanel.value === "month") {
1227
+ return (0, import_vue17.createVNode)(TableMonth, {
1228
+ "calendar": currentPanelDate.value,
1229
+ "months": getMonths.value,
1230
+ "headerLabel": getLabel.value,
1231
+ "shortcutLabel": locale.value.thisMonthText,
1232
+ "onNext": nextYear,
1233
+ "onPrevious": previousYear,
1234
+ "onClickHeaderLabel": () => changePanel("year"),
1235
+ "onSelect": onSelectMonth,
1236
+ "getMonthStatus": getMonthStatus,
1237
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1238
+ "onMouseLeave": () => emit("mouseLeave"),
1239
+ "isShowShortcut": props.isShowShortcut
1240
+ }, null);
1241
+ }
1242
+ if (currentPanel.value === "year") {
1243
+ return (0, import_vue17.createVNode)(TableYear, {
1244
+ "years": getYears.value,
1245
+ "headerLabel": getLabel.value,
1246
+ "shortcutLabel": locale.value.thisYearText,
1247
+ "onNext": (year) => changeYear(year),
1248
+ "onPrevious": (year) => changeYear(year),
1249
+ "onSelect": onSelectYear,
1250
+ "getYearStatus": getYearStatus,
1251
+ "onMouseEnter": (value) => emit("mouseEnter", value),
1252
+ "onMouseLeave": () => emit("mouseLeave"),
1253
+ "isShowShortcut": props.isShowShortcut
1254
+ }, null);
1255
+ }
1256
+ };
1257
+ }
1258
+ });
1259
+ var CalendarPanelRange = (0, import_vue18.defineComponent)({
1260
+ name: "CalendarPanelRange",
1261
+ props: calendarPanelRangeProps,
1262
+ emits: ["update:modelValue"],
1263
+ setup(props, {
1264
+ emit
1265
+ }) {
1266
+ var _a;
1267
+ const {
1268
+ startDate,
1269
+ endDate,
1270
+ hoveredDate,
1271
+ calendars,
1272
+ setStartDate,
1273
+ setEndDate,
1274
+ setHoveredDate,
1275
+ getDateRangeStatus,
1276
+ getCurrentDates,
1277
+ updateStartCalendar,
1278
+ updateEndCalendar
1279
+ } = useCalendarRange(props);
1280
+ if ((_a = props.modelValue) == null ? void 0 : _a.length) {
1281
+ updateStartCalendar(props.modelValue[0]);
1282
+ updateEndCalendar(props.modelValue[1]);
1283
+ }
1284
+ function onSelectDate(date) {
1285
+ if (props.type === "week" || props.type === "biweek") {
1286
+ const gap = {
1287
+ week: 6,
1288
+ biweek: 13
1289
+ };
1290
+ const startDate2 = startOfWeek(date, getLocale().formatLocale.firstDayOfWeek);
1291
+ const endDate2 = addDays(startDate2, gap[props.type]);
1292
+ setStartDate(startDate2);
1293
+ setEndDate(endDate2);
1294
+ emit("update:modelValue", getCurrentDates.value);
1295
+ return;
1296
+ }
1297
+ if (startDate.value && endDate.value) {
1298
+ setStartDate(void 0);
1299
+ setEndDate(void 0);
1300
+ setStartDate(date);
1301
+ return;
1302
+ }
1303
+ if (startDate.value && !endDate.value) {
1304
+ setEndDate(date);
1305
+ if (startDate.value && endDate.value) {
1306
+ emit("update:modelValue", getCurrentDates.value);
1307
+ }
1308
+ return;
1309
+ }
1310
+ if (!startDate.value && !endDate.value) {
1311
+ setStartDate(date);
1312
+ if (startDate.value && endDate.value) {
1313
+ emit("update:modelValue", getCurrentDates.value);
1314
+ }
1315
+ return;
1316
+ }
1317
+ }
1318
+ __name(onSelectDate, "onSelectDate");
1319
+ function getDateStatus(date) {
1320
+ var _a2, _b;
1321
+ let status = "default";
1322
+ if ((0, import_date_fns3.isToday)(date))
1323
+ status = "today";
1324
+ const {
1325
+ inRange,
1326
+ hoverInRange
1327
+ } = getDateRangeStatus(date);
1328
+ if (inRange || hoverInRange) {
1329
+ status = "range";
1330
+ }
1331
+ if (startDate.value && !endDate.value && (0, import_date_fns3.isEqual)(hoveredDate.value, date)) {
1332
+ status = "selected";
1333
+ }
1334
+ if ((0, import_date_fns3.isEqual)(startDate.value, date)) {
1335
+ status = "selected";
1336
+ }
1337
+ if ((0, import_date_fns3.isEqual)(endDate.value, date)) {
1338
+ status = "selected";
1339
+ }
1340
+ if (props.type === "week") {
1341
+ if ((_a2 = props.modelValue) == null ? void 0 : _a2.length) {
1342
+ const startDate2 = startOfWeek(props.modelValue[0], getLocale().formatLocale.firstDayOfWeek);
1343
+ const endDate2 = addDays(startDate2, 6);
1344
+ if (isDateBetween(date, startDate2, endDate2)) {
1345
+ status = "weekSelectedMiddle";
1346
+ if ((0, import_date_fns3.isEqual)(startDate2, date))
1347
+ status = "weekSelectedStart";
1348
+ if ((0, import_date_fns3.isEqual)(endDate2, date))
1349
+ status = "weekSelectedEnd";
1350
+ }
1351
+ }
1352
+ if (hoveredDate.value) {
1353
+ const startDate2 = startOfWeek(hoveredDate.value, getLocale().formatLocale.firstDayOfWeek);
1354
+ const endDate2 = addDays(startDate2, 6);
1355
+ if (isDateBetween(date, startDate2, endDate2)) {
1356
+ status = "weekHoveredMiddle";
1357
+ if ((0, import_date_fns3.isEqual)(startDate2, date))
1358
+ status = "weekHoveredStart";
1359
+ if ((0, import_date_fns3.isEqual)(endDate2, date))
1360
+ status = "weekHoveredEnd";
1361
+ }
1362
+ }
1363
+ }
1364
+ if (props.type === "biweek") {
1365
+ const getBiweekDates = /* @__PURE__ */ __name((date2) => {
1366
+ const firstWeekStartDate = startOfWeek(date2, getLocale().formatLocale.firstDayOfWeek);
1367
+ const firstWeekEndDate = addDays(firstWeekStartDate, 6);
1368
+ const secondWeekStartDate = startOfWeek(addDays(firstWeekStartDate, 7), getLocale().formatLocale.firstDayOfWeek);
1369
+ const secondWeekEndDate = addDays(secondWeekStartDate, 6);
1370
+ return {
1371
+ firstWeekStartDate,
1372
+ firstWeekEndDate,
1373
+ secondWeekStartDate,
1374
+ secondWeekEndDate
1375
+ };
1376
+ }, "getBiweekDates");
1377
+ if ((_b = props.modelValue) == null ? void 0 : _b.length) {
1378
+ const {
1379
+ firstWeekStartDate,
1380
+ firstWeekEndDate,
1381
+ secondWeekStartDate,
1382
+ secondWeekEndDate
1383
+ } = getBiweekDates(props.modelValue[0]);
1384
+ if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
1385
+ status = "weekSelectedMiddle";
1386
+ if ((0, import_date_fns3.isEqual)(firstWeekStartDate, date))
1387
+ status = "weekSelectedStart";
1388
+ if ((0, import_date_fns3.isEqual)(firstWeekEndDate, date))
1389
+ status = "weekSelectedEnd";
1390
+ if ((0, import_date_fns3.isEqual)(secondWeekStartDate, date))
1391
+ status = "weekSelectedStart";
1392
+ if ((0, import_date_fns3.isEqual)(secondWeekEndDate, date))
1393
+ status = "weekSelectedEnd";
1394
+ }
1395
+ }
1396
+ if (hoveredDate.value) {
1397
+ const {
1398
+ firstWeekStartDate,
1399
+ firstWeekEndDate,
1400
+ secondWeekStartDate,
1401
+ secondWeekEndDate
1402
+ } = getBiweekDates(hoveredDate.value);
1403
+ if (isDateBetween(date, firstWeekStartDate, secondWeekEndDate)) {
1404
+ status = "weekHoveredMiddle";
1405
+ if ((0, import_date_fns3.isEqual)(firstWeekStartDate, date))
1406
+ status = "weekHoveredStart";
1407
+ if ((0, import_date_fns3.isEqual)(firstWeekEndDate, date))
1408
+ status = "weekHoveredEnd";
1409
+ if ((0, import_date_fns3.isEqual)(secondWeekStartDate, date))
1410
+ status = "weekHoveredStart";
1411
+ if ((0, import_date_fns3.isEqual)(secondWeekEndDate, date))
1412
+ status = "weekHoveredEnd";
1413
+ }
1414
+ }
1415
+ }
1416
+ return status;
1417
+ }
1418
+ __name(getDateStatus, "getDateStatus");
1419
+ function getMonthStatus(month, year) {
1420
+ let status = "default";
1421
+ const parseToDate = createDate(year, month);
1422
+ const {
1423
+ inRange,
1424
+ hoverInRange
1425
+ } = getDateRangeStatus(parseToDate);
1426
+ if (inRange || hoverInRange) {
1427
+ status = "range";
1428
+ }
1429
+ if (startDate.value && !endDate.value && (0, import_date_fns3.isEqual)(hoveredDate.value, parseToDate)) {
1430
+ status = "selected";
1431
+ }
1432
+ if ((0, import_date_fns3.isEqual)(startDate.value, parseToDate)) {
1433
+ status = "selected";
1434
+ }
1435
+ if ((0, import_date_fns3.isEqual)(endDate.value, parseToDate)) {
1436
+ status = "selected";
1437
+ }
1438
+ return status;
1439
+ }
1440
+ __name(getMonthStatus, "getMonthStatus");
1441
+ function getYearStatus(year) {
1442
+ var _a2, _b, _c;
1443
+ let status = "default";
1444
+ const parseToDate = createDate(year);
1445
+ const {
1446
+ inRange,
1447
+ hoverInRange
1448
+ } = getDateRangeStatus(parseToDate);
1449
+ if (inRange || hoverInRange) {
1450
+ status = "range";
1451
+ }
1452
+ if (startDate.value && !endDate.value && ((_a2 = hoveredDate.value) == null ? void 0 : _a2.getFullYear()) === parseToDate.getFullYear()) {
1453
+ status = "selected";
1454
+ }
1455
+ if (((_b = startDate.value) == null ? void 0 : _b.getFullYear()) === parseToDate.getFullYear()) {
1456
+ status = "selected";
1457
+ }
1458
+ if (((_c = endDate.value) == null ? void 0 : _c.getFullYear()) === parseToDate.getFullYear()) {
1459
+ status = "selected";
1460
+ }
1461
+ return status;
1462
+ }
1463
+ __name(getYearStatus, "getYearStatus");
1464
+ return () => {
1465
+ const isWeekAndBiweek = props.type === "week" || props.type === "biweek";
1466
+ const classes = isWeekAndBiweek ? "" : (0, import_recipes8.calendarPanelRangeRecipe)();
1467
+ const calendarPanelAttrs = {
1468
+ isRange: true,
1469
+ type: props.type,
1470
+ isHideNotThisMonthDate: props.type === "week" || props.type === "biweek" ? false : true,
1471
+ isShowShortcut: false,
1472
+ getDateStatus,
1473
+ getMonthStatus,
1474
+ getYearStatus,
1475
+ "onUpdate:modelValue": (date) => onSelectDate(date),
1476
+ onMouseEnter: (date) => setHoveredDate(date),
1477
+ onMouseLeave: () => setHoveredDate(void 0)
1478
+ };
1479
+ const leftNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1480
+ "data-pixel-parts": "CalendarPanelLeft"
1481
+ }, calendarPanelAttrs, {
1482
+ "onUpdateCalendar": (value) => updateStartCalendar(value),
1483
+ "calendar": calendars.value[0]
1484
+ }), null);
1485
+ const rightNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1486
+ "data-pixel-parts": "CalendarPanelRight"
1487
+ }, calendarPanelAttrs, {
1488
+ "onUpdateCalendar": (value) => updateEndCalendar(value),
1489
+ "calendar": calendars.value[1]
1490
+ }), null);
1491
+ const weekAndBiweekNode = (0, import_vue17.createVNode)(CalendarPanel, (0, import_vue17.mergeProps)({
1492
+ "data-pixel-parts": "CalendarPanel"
1493
+ }, calendarPanelAttrs, {
1494
+ "onUpdateCalendar": (value) => updateStartCalendar(value),
1495
+ "calendar": props.modelValue[0],
1496
+ "type": "date"
1497
+ }), null);
1498
+ return (0, import_vue17.createVNode)("div", {
1499
+ "class": classes
1500
+ }, [isWeekAndBiweek ? weekAndBiweekNode : [leftNode, rightNode]]);
1501
+ };
1502
+ }
1503
+ });
1504
+
1505
+ // src/modules/date-picker.hooks.ts
1506
+ var import_vue19 = require("vue");
1507
+ var import_pixel3_utils2 = require("@mekari/pixel3-utils");
1508
+ var import_date_format_parse = require("date-format-parse");
1509
+ function useDatePicker(props, emit) {
1510
+ const getId = props.id || (0, import_pixel3_utils2.getUniqueId)("", "datepicker").value;
1511
+ const currentLabel = (0, import_vue19.ref)("");
1512
+ const isOutside = (0, import_vue19.ref)(true);
1513
+ const isPopoverOpen = (0, import_vue19.ref)(false);
1514
+ const isInnerInvalid = (0, import_vue19.ref)(false);
1515
+ const userInput = (0, import_vue19.ref)(null);
1516
+ const innerValueDate = (0, import_vue19.ref)();
1517
+ const isUseRange = (0, import_vue19.computed)(() => {
1518
+ if (props.isRange || props.type === "biweek" || props.type === "week")
1519
+ return true;
1520
+ return false;
1521
+ });
1522
+ const innerFormat = (0, import_vue19.computed)(() => {
1523
+ const format2 = {
1524
+ date: "DD-MM-YYYY",
1525
+ datetime: "DD-MM-YYYY HH:mm:ss",
1526
+ year: "YYYY",
1527
+ month: "YYYY-MM",
1528
+ time: "HH:mm:ss",
1529
+ week: "DD-MM-YYYY",
1530
+ biweek: "DD-MM-YYYY"
1531
+ };
1532
+ return props.format || format2[props.type] || format2.date;
1533
+ });
1534
+ const innerValue = (0, import_vue19.computed)(() => {
1535
+ if (isUseRange.value) {
1536
+ if (isValidRangeDate(props.modelValue)) {
1537
+ const startDate = valueToDate(props.modelValue[0]);
1538
+ const endDate = valueToDate(props.modelValue[1]);
1539
+ return [startDate, endDate];
1540
+ }
1541
+ return [];
1542
+ }
1543
+ return valueToDate(props.modelValue);
1544
+ });
1545
+ const text = (0, import_vue19.computed)(() => {
1546
+ if (userInput.value !== null)
1547
+ return userInput.value;
1548
+ if (!innerValue.value)
1549
+ return "";
1550
+ if (isUseRange.value) {
1551
+ if (!isValidRangeDate(innerValue.value))
1552
+ return "";
1553
+ } else {
1554
+ if (!isValidDate(innerValue.value))
1555
+ return "";
1556
+ }
1557
+ if (Array.isArray(innerValue.value)) {
1558
+ return innerValue.value.map((v) => formatDate(v)).join(props.rangeSeparator);
1559
+ }
1560
+ return formatDate(innerValue.value);
1561
+ });
1562
+ const locale = (0, import_vue19.computed)(() => {
1563
+ if (isObject(props.lang)) {
1564
+ return getLocale(props.lang);
1565
+ }
1566
+ return getLocale();
1567
+ });
1568
+ function onOpenPopover() {
1569
+ if (props.isReadOnly)
1570
+ return;
1571
+ isPopoverOpen.value = true;
1572
+ }
1573
+ __name(onOpenPopover, "onOpenPopover");
1574
+ function onClosePopover() {
1575
+ isPopoverOpen.value = false;
1576
+ }
1577
+ __name(onClosePopover, "onClosePopover");
1578
+ function onBlur() {
1579
+ onClosePopover();
1580
+ const inputEl = document.getElementById(`${getId}-control`);
1581
+ inputEl == null ? void 0 : inputEl.blur();
1582
+ }
1583
+ __name(onBlur, "onBlur");
1584
+ function handleForceFocusToInput() {
1585
+ const inputEl = document.getElementById(`${getId}-control`);
1586
+ inputEl == null ? void 0 : inputEl.focus();
1587
+ }
1588
+ __name(handleForceFocusToInput, "handleForceFocusToInput");
1589
+ function onClear() {
1590
+ isOutside.value = true;
1591
+ userInput.value = null;
1592
+ emit("update:modelValue", "");
1593
+ onBlur();
1594
+ }
1595
+ __name(onClear, "onClear");
1596
+ function onInputChange(e) {
1597
+ var _a;
1598
+ if (e) {
1599
+ const target = e.target;
1600
+ userInput.value = typeof e === "string" ? e : target.value;
1601
+ if (userInput.value === null)
1602
+ return;
1603
+ const text2 = ((_a = userInput.value) == null ? void 0 : _a.trim()) || "";
1604
+ if (text2 === "") {
1605
+ onClear();
1606
+ isInnerInvalid.value = false;
1607
+ return;
1608
+ }
1609
+ let date;
1610
+ if (isUseRange.value) {
1611
+ let arr = text2.split(props.rangeSeparator);
1612
+ if (arr.length !== 2) {
1613
+ arr = text2.split(props.rangeSeparator.trim());
1614
+ }
1615
+ date = arr.map((v) => parseDate(v.trim()));
1616
+ } else {
1617
+ date = parseDate(text2);
1618
+ }
1619
+ if (isValidValueAndNotDisabled(date)) {
1620
+ innerValueDate.value = date;
1621
+ (0, import_vue19.nextTick)(() => {
1622
+ isOutside.value = true;
1623
+ isInnerInvalid.value = false;
1624
+ onBlur();
1625
+ });
1626
+ } else {
1627
+ isInnerInvalid.value = true;
1628
+ emit("error", text2);
1629
+ }
1630
+ }
1631
+ }
1632
+ __name(onInputChange, "onInputChange");
1633
+ function onEmitModelValue(value) {
1634
+ userInput.value = null;
1635
+ innerValueDate.value = value;
1636
+ if (isUseRange.value) {
1637
+ const dates = value;
1638
+ const startDate = dateToValue(new Date(dates[0]));
1639
+ const endDate = dateToValue(new Date(dates[1]));
1640
+ emit("update:modelValue", [startDate, endDate]);
1641
+ } else {
1642
+ emit("update:modelValue", dateToValue(new Date(value)));
1643
+ }
1644
+ (0, import_vue19.nextTick)(() => {
1645
+ isOutside.value = true;
1646
+ onBlur();
1647
+ });
1648
+ }
1649
+ __name(onEmitModelValue, "onEmitModelValue");
1650
+ function parseDate(value) {
1651
+ const backupDate = /* @__PURE__ */ new Date();
1652
+ return (0, import_date_format_parse.parse)(value, innerFormat.value, {
1653
+ locale: locale.value.formatLocale,
1654
+ backupDate
1655
+ });
1656
+ }
1657
+ __name(parseDate, "parseDate");
1658
+ function formatDate(date) {
1659
+ return (0, import_date_format_parse.format)(date, innerFormat.value, {
1660
+ locale: locale.value.formatLocale
1661
+ });
1662
+ }
1663
+ __name(formatDate, "formatDate");
1664
+ function valueToDate(value) {
1665
+ switch (props.valueType) {
1666
+ case "date":
1667
+ return value instanceof Date ? new Date(value.getTime()) : /* @__PURE__ */ new Date(NaN);
1668
+ case "timestamp":
1669
+ return typeof value === "number" ? new Date(value) : /* @__PURE__ */ new Date(NaN);
1670
+ case "string":
1671
+ return typeof value === "string" ? parseDate(value) : /* @__PURE__ */ new Date(NaN);
1672
+ default:
1673
+ return typeof value === "string" ? parseDate(value) : /* @__PURE__ */ new Date(NaN);
1674
+ }
1675
+ }
1676
+ __name(valueToDate, "valueToDate");
1677
+ function dateToValue(date) {
1678
+ if (!isValidDate(date))
1679
+ return null;
1680
+ switch (props.valueType) {
1681
+ case "date":
1682
+ return date;
1683
+ case "timestamp":
1684
+ return date.getTime();
1685
+ case "string":
1686
+ return formatDate(date);
1687
+ default:
1688
+ return formatDate(date);
1689
+ }
1690
+ }
1691
+ __name(dateToValue, "dateToValue");
1692
+ function isValidValue(value) {
1693
+ if (isUseRange.value)
1694
+ return isValidRangeDate(value);
1695
+ return isValidDate(value);
1696
+ }
1697
+ __name(isValidValue, "isValidValue");
1698
+ function isValidValueAndNotDisabled(value) {
1699
+ if (!isValidValue(value))
1700
+ return false;
1701
+ const disabledDate = typeof props.disabledDate === "function" ? props.disabledDate : () => false;
1702
+ if (!Array.isArray(value)) {
1703
+ value = [value];
1704
+ }
1705
+ return value.every((v) => !disabledDate(v));
1706
+ }
1707
+ __name(isValidValueAndNotDisabled, "isValidValueAndNotDisabled");
1708
+ const rootAttrs = {
1709
+ style: {
1710
+ width: "100%",
1711
+ position: "relative"
1712
+ },
1713
+ onMouseenter: () => {
1714
+ isOutside.value = false;
1715
+ },
1716
+ onMouseleave: () => {
1717
+ isOutside.value = true;
1718
+ }
1719
+ };
1720
+ return {
1721
+ rootAttrs,
1722
+ isOutside,
1723
+ isPopoverOpen,
1724
+ currentLabel,
1725
+ userInput,
1726
+ innerFormat,
1727
+ innerValueDate,
1728
+ innerValue,
1729
+ isUseRange,
1730
+ onOpenPopover,
1731
+ onClosePopover,
1732
+ onClear,
1733
+ onInputChange,
1734
+ getId,
1735
+ onBlur,
1736
+ handleForceFocusToInput,
1737
+ text,
1738
+ locale,
1739
+ isInnerInvalid,
1740
+ onEmitModelValue
1741
+ };
1742
+ }
1743
+ __name(useDatePicker, "useDatePicker");
1744
+
1745
+ // src/date-picker.tsx
1746
+ var import_recipes9 = require("@mekari/pixel3-styled-system/recipes");
1747
+ function _isSlot(s) {
1748
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, import_vue20.isVNode)(s);
1749
+ }
1750
+ __name(_isSlot, "_isSlot");
1751
+ var MpDatePicker = (0, import_vue21.defineComponent)({
1752
+ name: "MpDatePicker",
1753
+ props: datePickerProps,
1754
+ emits: ["update:modelValue", "error"],
1755
+ setup(props, {
1756
+ emit
1757
+ }) {
1758
+ const {
1759
+ text,
1760
+ getId,
1761
+ innerValue,
1762
+ locale,
1763
+ isOutside,
1764
+ isPopoverOpen,
1765
+ isInnerInvalid,
1766
+ isUseRange,
1767
+ onOpenPopover,
1768
+ onBlur,
1769
+ onClear,
1770
+ onInputChange,
1771
+ onEmitModelValue
1772
+ } = useDatePicker(props, emit);
1773
+ DatePickerProvider({
1774
+ rootProps: props,
1775
+ locale
1776
+ });
1777
+ return () => {
1778
+ const {
1779
+ root,
1780
+ popoverContent
1781
+ } = (0, import_recipes9.datePickerSlotRecipe)();
1782
+ const inputNode = (0, import_vue20.createVNode)(import_pixel3_input.MpInputGroup, null, {
1783
+ default: () => [(0, import_vue20.createVNode)(import_pixel3_input.MpInput, {
1784
+ "id": getId,
1785
+ "placeholder": props.placeholder,
1786
+ "isClearable": props.isClearable,
1787
+ "isDisabled": props.isDisabled,
1788
+ "isInvalid": props.isInvalid || isInnerInvalid.value,
1789
+ "isReadOnly": props.isReadOnly,
1790
+ "modelValue": text.value,
1791
+ "onInput": onInputChange,
1792
+ "onClear": onClear,
1793
+ "onFocus": () => onOpenPopover(),
1794
+ "onBlur": (e) => {
1795
+ if (isOutside.value) {
1796
+ onBlur();
1797
+ return;
1798
+ }
1799
+ const target = e.target;
1800
+ target.focus();
1801
+ }
1802
+ }, null), (0, import_vue20.createVNode)(import_pixel3_input.MpInputRightAddon, null, {
1803
+ default: () => [(0, import_vue20.createVNode)(import_pixel3_icon.MpIcon, {
1804
+ "name": "calendar"
1805
+ }, null)]
1806
+ })]
1807
+ });
1808
+ const calendarPanelAttrs = {
1809
+ type: props.type,
1810
+ "onUpdate:modelValue": onEmitModelValue,
1811
+ disabledDate: props.disabledDate,
1812
+ disabledMonth: props.disabledMonth,
1813
+ disabledYear: props.disabledYear
1814
+ };
1815
+ const panelNode = isUseRange.value ? (0, import_vue20.createVNode)(CalendarPanelRange, (0, import_vue20.mergeProps)(calendarPanelAttrs, {
1816
+ "modelValue": innerValue.value
1817
+ }), null) : (0, import_vue20.createVNode)(CalendarPanel, (0, import_vue20.mergeProps)(calendarPanelAttrs, {
1818
+ "modelValue": innerValue.value
1819
+ }), null);
1820
+ const withPopover = (0, import_vue20.createVNode)(import_pixel3_popover.MpPopover, {
1821
+ "id": getId,
1822
+ "isManual": true,
1823
+ "isOpen": isPopoverOpen.value,
1824
+ "isKeepAlive": props.isKeepAlive,
1825
+ "usePortal": props.usePortal
1826
+ }, {
1827
+ default: () => [(0, import_vue20.createVNode)(import_pixel3_popover.MpPopoverTrigger, null, _isSlot(inputNode) ? inputNode : {
1828
+ default: () => [inputNode]
1829
+ }), (0, import_vue20.createVNode)(import_pixel3_popover.MpPopoverContent, {
1830
+ "class": popoverContent,
1831
+ "style": {
1832
+ width: props.isRange ? "590px" : ""
1833
+ },
1834
+ "onMouseenter": () => isOutside.value = false,
1835
+ "onMouseleave": () => isOutside.value = true
1836
+ }, _isSlot(panelNode) ? panelNode : {
1837
+ default: () => [panelNode]
1838
+ })]
1839
+ });
1840
+ return (0, import_vue20.createVNode)("div", {
1841
+ "class": root,
1842
+ "onMouseenter": () => isOutside.value = false,
1843
+ "onMouseleave": () => isOutside.value = true
1844
+ }, [props.isInline ? panelNode : withPopover]);
1845
+ };
1846
+ }
1847
+ });
1848
+ // Annotate the CommonJS export names for ESM import in node:
1849
+ 0 && (module.exports = {
1850
+ MpDatePicker
1851
+ });