@mekari/pixel3-date-picker 0.0.3-dev.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calendar-panel.d.mts +12 -6
- package/dist/calendar-panel.d.ts +12 -6
- package/dist/calendar-panel.js +163 -85
- package/dist/calendar-panel.mjs +14 -13
- package/dist/{chunk-EYTJIMSM.mjs → chunk-26K3LMTE.mjs} +32 -11
- package/dist/{chunk-5PISTT2K.mjs → chunk-5MFHZK63.mjs} +4 -4
- package/dist/{chunk-XQLKPPRN.mjs → chunk-5VRVDIXN.mjs} +47 -0
- package/dist/{chunk-NU6HYEPT.mjs → chunk-64EO4HV7.mjs} +1 -1
- package/dist/{chunk-ZS4JQRK3.mjs → chunk-7CLF67SP.mjs} +1 -1
- package/dist/{chunk-NIUQXHGQ.mjs → chunk-E5BRVBZ2.mjs} +19 -1
- package/dist/{chunk-KTADGCWP.mjs → chunk-FPRON3EM.mjs} +14 -14
- package/dist/chunk-IRNTTSB7.mjs +144 -0
- package/dist/chunk-KTYQJMW4.mjs +35 -0
- package/dist/chunk-MO5D3TCF.mjs +113 -0
- package/dist/{chunk-HJ4V3PM6.mjs → chunk-O43S64IA.mjs} +4 -4
- package/dist/{chunk-NVULZQVI.mjs → chunk-OMV7LXBW.mjs} +1 -1
- package/dist/chunk-OYJNIILC.mjs +40 -0
- package/dist/{chunk-3RCUXNBN.mjs → chunk-P7JOEQIL.mjs} +9 -6
- package/dist/{chunk-26Y3AVJW.mjs → chunk-U7O52D6B.mjs} +13 -1
- package/dist/{chunk-JZ2KFYWF.mjs → chunk-WK62QUOT.mjs} +1 -1
- package/dist/components/calendar/index.js +83 -51
- package/dist/components/calendar/index.mjs +8 -7
- package/dist/components/calendar/table-date.js +51 -19
- package/dist/components/calendar/table-date.mjs +5 -4
- package/dist/components/calendar/table-month.js +48 -16
- package/dist/components/calendar/table-month.mjs +6 -5
- package/dist/components/calendar/table-year.js +48 -16
- package/dist/components/calendar/table-year.mjs +6 -5
- package/dist/components/parts/index.d.mts +1 -0
- package/dist/components/parts/index.d.ts +1 -0
- package/dist/components/parts/index.js +34 -0
- package/dist/components/parts/index.mjs +7 -3
- package/dist/components/parts/time.d.mts +32 -0
- package/dist/components/parts/time.d.ts +32 -0
- package/dist/components/parts/time.js +59 -0
- package/dist/components/parts/time.mjs +7 -0
- package/dist/composables/useCalendar.d.mts +8 -1
- package/dist/composables/useCalendar.d.ts +8 -1
- package/dist/composables/useCalendar.mjs +2 -2
- package/dist/composables/useCalendarRange.mjs +2 -2
- package/dist/composables/useTime.d.mts +96 -0
- package/dist/composables/useTime.d.ts +96 -0
- package/dist/composables/useTime.js +185 -0
- package/dist/composables/useTime.mjs +9 -0
- package/dist/date-picker.d.mts +91 -3
- package/dist/date-picker.d.ts +91 -3
- package/dist/date-picker.js +487 -118
- package/dist/date-picker.mjs +19 -15
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +487 -118
- package/dist/index.mjs +19 -15
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/date-picker.hooks.js +3 -0
- package/dist/modules/date-picker.hooks.mjs +4 -4
- package/dist/modules/date-picker.locales.mjs +2 -2
- package/dist/modules/date-picker.props.d.mts +83 -4
- package/dist/modules/date-picker.props.d.ts +83 -4
- package/dist/modules/date-picker.props.js +50 -2
- package/dist/modules/date-picker.props.mjs +5 -3
- package/dist/time-panel.d.mts +98 -0
- package/dist/time-panel.d.ts +98 -0
- package/dist/time-panel.js +665 -0
- package/dist/time-panel.mjs +18 -0
- package/dist/utils/base.d.mts +3 -1
- package/dist/utils/base.d.ts +3 -1
- package/dist/utils/base.js +20 -0
- package/dist/utils/base.mjs +5 -1
- package/dist/utils/date.d.mts +2 -1
- package/dist/utils/date.d.ts +2 -1
- package/dist/utils/date.js +13 -0
- package/dist/utils/date.mjs +3 -1
- package/dist/utils/dom.d.mts +18 -0
- package/dist/utils/dom.d.ts +18 -0
- package/dist/utils/dom.js +62 -0
- package/dist/utils/dom.mjs +9 -0
- package/package.json +6 -6
- /package/dist/{chunk-FTR7OMCT.mjs → chunk-MRP3X6QP.mjs} +0 -0
package/dist/index.js
CHANGED
|
@@ -26,19 +26,19 @@ __export(src_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
|
|
28
28
|
// src/date-picker.tsx
|
|
29
|
-
var
|
|
30
|
-
var
|
|
29
|
+
var import_vue25 = require("vue");
|
|
30
|
+
var import_vue26 = require("vue");
|
|
31
31
|
var import_pixel3_input = require("@mekari/pixel3-input");
|
|
32
32
|
var import_pixel3_popover = require("@mekari/pixel3-popover");
|
|
33
33
|
var import_pixel3_icon = require("@mekari/pixel3-icon");
|
|
34
34
|
|
|
35
35
|
// src/calendar-panel.tsx
|
|
36
|
-
var
|
|
37
|
-
var
|
|
36
|
+
var import_vue19 = require("vue");
|
|
37
|
+
var import_vue20 = require("vue");
|
|
38
38
|
|
|
39
39
|
// src/components/calendar/table-date.tsx
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var import_vue11 = require("vue");
|
|
41
|
+
var import_vue12 = require("vue");
|
|
42
42
|
var import_pixel3_button = require("@mekari/pixel3-button");
|
|
43
43
|
|
|
44
44
|
// src/components/parts/date.tsx
|
|
@@ -163,6 +163,38 @@ var YearItem = (0, import_vue8.defineComponent)({
|
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
+
// src/components/parts/time.tsx
|
|
167
|
+
var import_vue9 = require("vue");
|
|
168
|
+
var import_vue10 = require("vue");
|
|
169
|
+
var import_recipes5 = require("@mekari/pixel3-styled-system/recipes");
|
|
170
|
+
var TimeItem = (0, import_vue10.defineComponent)({
|
|
171
|
+
name: "TimeItem",
|
|
172
|
+
props: {
|
|
173
|
+
status: {
|
|
174
|
+
type: String,
|
|
175
|
+
default: "default"
|
|
176
|
+
},
|
|
177
|
+
isDisabled: {
|
|
178
|
+
type: Boolean,
|
|
179
|
+
default: false
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
setup(props, {
|
|
183
|
+
slots
|
|
184
|
+
}) {
|
|
185
|
+
return () => {
|
|
186
|
+
const classes = (0, import_recipes5.timeItemRecipe)({
|
|
187
|
+
status: props.status
|
|
188
|
+
});
|
|
189
|
+
return (0, import_vue9.createVNode)("button", {
|
|
190
|
+
"disabled": props.isDisabled,
|
|
191
|
+
"data-status": props.status,
|
|
192
|
+
"class": classes
|
|
193
|
+
}, [slots.default()]);
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
166
198
|
// src/utils/base.ts
|
|
167
199
|
function chunk(arr, size) {
|
|
168
200
|
if (!Array.isArray(arr)) {
|
|
@@ -199,10 +231,26 @@ var assign = /* @__PURE__ */ __name((initial, override) => {
|
|
|
199
231
|
};
|
|
200
232
|
}, {});
|
|
201
233
|
}, "assign");
|
|
234
|
+
function padNumber(value) {
|
|
235
|
+
value = parseInt(value, 10);
|
|
236
|
+
return value < 10 ? `0${value}` : `${value}`;
|
|
237
|
+
}
|
|
238
|
+
__name(padNumber, "padNumber");
|
|
239
|
+
function generateOptions(length, step) {
|
|
240
|
+
if (step <= 0) {
|
|
241
|
+
step = 1;
|
|
242
|
+
}
|
|
243
|
+
const arr = [];
|
|
244
|
+
for (let i = 0; i < length; i += step) {
|
|
245
|
+
arr.push(i);
|
|
246
|
+
}
|
|
247
|
+
return arr;
|
|
248
|
+
}
|
|
249
|
+
__name(generateOptions, "generateOptions");
|
|
202
250
|
|
|
203
251
|
// src/components/calendar/table-date.tsx
|
|
204
|
-
var
|
|
205
|
-
var TableDate = (0,
|
|
252
|
+
var import_recipes6 = require("@mekari/pixel3-styled-system/recipes");
|
|
253
|
+
var TableDate = (0, import_vue12.defineComponent)({
|
|
206
254
|
name: "TableDate",
|
|
207
255
|
props: {
|
|
208
256
|
days: {
|
|
@@ -247,8 +295,8 @@ var TableDate = (0, import_vue10.defineComponent)({
|
|
|
247
295
|
dateItemRoot,
|
|
248
296
|
dateItemWrapper,
|
|
249
297
|
shortcutLabelWrapper
|
|
250
|
-
} = (0,
|
|
251
|
-
const getDates = (0,
|
|
298
|
+
} = (0, import_recipes6.tableDateSlotRecipe)();
|
|
299
|
+
const getDates = (0, import_vue12.computed)(() => {
|
|
252
300
|
return chunk(props.dates, 7);
|
|
253
301
|
});
|
|
254
302
|
function onNextButton() {
|
|
@@ -292,39 +340,39 @@ var TableDate = (0, import_vue10.defineComponent)({
|
|
|
292
340
|
}
|
|
293
341
|
__name(getDateAttrs, "getDateAttrs");
|
|
294
342
|
return () => {
|
|
295
|
-
return (0,
|
|
343
|
+
return (0, import_vue11.createVNode)("div", null, [(0, import_vue11.createVNode)("div", {
|
|
296
344
|
"data-pixel-parts": "Header",
|
|
297
345
|
"class": headerRoot
|
|
298
|
-
}, [(0,
|
|
346
|
+
}, [(0, import_vue11.createVNode)(import_pixel3_button.MpButton, {
|
|
299
347
|
"left-icon": "chevrons-left",
|
|
300
348
|
"variant": "ghost",
|
|
301
349
|
"size": "sm",
|
|
302
350
|
"onClick": onPreviousButton
|
|
303
|
-
}, null), (0,
|
|
351
|
+
}, null), (0, import_vue11.createVNode)("button", {
|
|
304
352
|
"class": headerLabel,
|
|
305
353
|
"onClick": () => emit("clickHeaderLabel")
|
|
306
|
-
}, [props.headerLabel]), (0,
|
|
354
|
+
}, [props.headerLabel]), (0, import_vue11.createVNode)(import_pixel3_button.MpButton, {
|
|
307
355
|
"right-icon": "chevrons-right",
|
|
308
356
|
"variant": "ghost",
|
|
309
357
|
"size": "sm",
|
|
310
358
|
"onClick": onNextButton
|
|
311
|
-
}, null)]), (0,
|
|
359
|
+
}, null)]), (0, import_vue11.createVNode)("div", {
|
|
312
360
|
"data-pixel-parts": "Content",
|
|
313
361
|
"class": dayWrapper
|
|
314
|
-
}, [props.days.map((day) => (0,
|
|
315
|
-
default: () => [(0,
|
|
316
|
-
}))]), (0,
|
|
362
|
+
}, [props.days.map((day) => (0, import_vue11.createVNode)(Day, null, {
|
|
363
|
+
default: () => [(0, import_vue11.createTextVNode)(" "), day, (0, import_vue11.createTextVNode)(" ")]
|
|
364
|
+
}))]), (0, import_vue11.createVNode)("div", {
|
|
317
365
|
"data-pixel-parts": "Content",
|
|
318
366
|
"class": dateItemRoot
|
|
319
|
-
}, [getDates.value.map((dates, index) => (0,
|
|
367
|
+
}, [getDates.value.map((dates, index) => (0, import_vue11.createVNode)("div", {
|
|
320
368
|
"class": dateItemWrapper,
|
|
321
369
|
"data-row-index": index
|
|
322
|
-
}, [dates.map((date) => (0,
|
|
323
|
-
default: () => [(0,
|
|
324
|
-
}))]))]), props.isShowShortcut && (0,
|
|
370
|
+
}, [dates.map((date) => (0, import_vue11.createVNode)(Date2, getDateAttrs(date), {
|
|
371
|
+
default: () => [(0, import_vue11.createTextVNode)(" "), date.getDate(), (0, import_vue11.createTextVNode)(" ")]
|
|
372
|
+
}))]))]), props.isShowShortcut && (0, import_vue11.createVNode)("div", {
|
|
325
373
|
"data-pixel-parts": "Shortcut",
|
|
326
374
|
"class": shortcutLabelWrapper
|
|
327
|
-
}, [(0,
|
|
375
|
+
}, [(0, import_vue11.createVNode)(import_pixel3_button.MpButton, {
|
|
328
376
|
"variant": "ghost",
|
|
329
377
|
"onClick": onSelectToday
|
|
330
378
|
}, {
|
|
@@ -335,8 +383,8 @@ var TableDate = (0, import_vue10.defineComponent)({
|
|
|
335
383
|
});
|
|
336
384
|
|
|
337
385
|
// src/components/calendar/table-month.tsx
|
|
338
|
-
var
|
|
339
|
-
var
|
|
386
|
+
var import_vue13 = require("vue");
|
|
387
|
+
var import_vue14 = require("vue");
|
|
340
388
|
var import_pixel3_button2 = require("@mekari/pixel3-button");
|
|
341
389
|
|
|
342
390
|
// src/utils/date.ts
|
|
@@ -424,8 +472,8 @@ function isDateBetween(date, min, max) {
|
|
|
424
472
|
__name(isDateBetween, "isDateBetween");
|
|
425
473
|
|
|
426
474
|
// src/components/calendar/table-month.tsx
|
|
427
|
-
var
|
|
428
|
-
var TableMonth = (0,
|
|
475
|
+
var import_recipes7 = require("@mekari/pixel3-styled-system/recipes");
|
|
476
|
+
var TableMonth = (0, import_vue14.defineComponent)({
|
|
429
477
|
name: "TableMonth",
|
|
430
478
|
props: {
|
|
431
479
|
calendar: {
|
|
@@ -463,11 +511,11 @@ var TableMonth = (0, import_vue12.defineComponent)({
|
|
|
463
511
|
monthItemRoot,
|
|
464
512
|
monthItemWrapper,
|
|
465
513
|
shortcutLabelWrapper
|
|
466
|
-
} = (0,
|
|
467
|
-
const getMonths = (0,
|
|
514
|
+
} = (0, import_recipes7.tableMonthSlotRecipe)();
|
|
515
|
+
const getMonths = (0, import_vue14.computed)(() => {
|
|
468
516
|
return chunk(props.months, 3);
|
|
469
517
|
});
|
|
470
|
-
const getCalendarYear = (0,
|
|
518
|
+
const getCalendarYear = (0, import_vue14.computed)(() => props.calendar.getFullYear());
|
|
471
519
|
function onNextButton() {
|
|
472
520
|
emit("next");
|
|
473
521
|
}
|
|
@@ -499,33 +547,33 @@ var TableMonth = (0, import_vue12.defineComponent)({
|
|
|
499
547
|
}
|
|
500
548
|
__name(getMonthAttrs, "getMonthAttrs");
|
|
501
549
|
return () => {
|
|
502
|
-
return (0,
|
|
550
|
+
return (0, import_vue13.createVNode)("div", null, [(0, import_vue13.createVNode)("div", {
|
|
503
551
|
"data-pixel-parts": "Header",
|
|
504
552
|
"class": headerRoot
|
|
505
|
-
}, [(0,
|
|
553
|
+
}, [(0, import_vue13.createVNode)(import_pixel3_button2.MpButton, {
|
|
506
554
|
"left-icon": "chevrons-left",
|
|
507
555
|
"variant": "ghost",
|
|
508
556
|
"size": "sm",
|
|
509
557
|
"onClick": onPreviousButton
|
|
510
|
-
}, null), (0,
|
|
558
|
+
}, null), (0, import_vue13.createVNode)("button", {
|
|
511
559
|
"class": headerLabel,
|
|
512
560
|
"onClick": () => emit("clickHeaderLabel")
|
|
513
|
-
}, [props.headerLabel]), (0,
|
|
561
|
+
}, [props.headerLabel]), (0, import_vue13.createVNode)(import_pixel3_button2.MpButton, {
|
|
514
562
|
"right-icon": "chevrons-right",
|
|
515
563
|
"variant": "ghost",
|
|
516
564
|
"size": "sm",
|
|
517
565
|
"onClick": onNextButton
|
|
518
|
-
}, null)]), (0,
|
|
566
|
+
}, null)]), (0, import_vue13.createVNode)("div", {
|
|
519
567
|
"data-pixel-parts": "Content",
|
|
520
568
|
"class": monthItemRoot
|
|
521
|
-
}, [getMonths.value.map((data) => (0,
|
|
569
|
+
}, [getMonths.value.map((data) => (0, import_vue13.createVNode)("div", {
|
|
522
570
|
"class": monthItemWrapper
|
|
523
|
-
}, [data.map((month) => (0,
|
|
571
|
+
}, [data.map((month) => (0, import_vue13.createVNode)(Month, getMonthAttrs(month.month), {
|
|
524
572
|
default: () => [" ", month.text, " "]
|
|
525
|
-
}))]))]), props.isShowShortcut && (0,
|
|
573
|
+
}))]))]), props.isShowShortcut && (0, import_vue13.createVNode)("div", {
|
|
526
574
|
"data-pixel-parts": "Shortcut",
|
|
527
575
|
"class": shortcutLabelWrapper
|
|
528
|
-
}, [(0,
|
|
576
|
+
}, [(0, import_vue13.createVNode)(import_pixel3_button2.MpButton, {
|
|
529
577
|
"variant": "ghost",
|
|
530
578
|
"onClick": () => onSelectMonth((/* @__PURE__ */ new Date()).getMonth(), getCalendarYear.value)
|
|
531
579
|
}, {
|
|
@@ -536,11 +584,11 @@ var TableMonth = (0, import_vue12.defineComponent)({
|
|
|
536
584
|
});
|
|
537
585
|
|
|
538
586
|
// src/components/calendar/table-year.tsx
|
|
539
|
-
var
|
|
540
|
-
var
|
|
587
|
+
var import_vue15 = require("vue");
|
|
588
|
+
var import_vue16 = require("vue");
|
|
541
589
|
var import_pixel3_button3 = require("@mekari/pixel3-button");
|
|
542
|
-
var
|
|
543
|
-
var TableYear = (0,
|
|
590
|
+
var import_recipes8 = require("@mekari/pixel3-styled-system/recipes");
|
|
591
|
+
var TableYear = (0, import_vue16.defineComponent)({
|
|
544
592
|
name: "TableYear",
|
|
545
593
|
props: {
|
|
546
594
|
years: {
|
|
@@ -574,8 +622,8 @@ var TableYear = (0, import_vue14.defineComponent)({
|
|
|
574
622
|
yearItemRoot,
|
|
575
623
|
yearItemWrapper,
|
|
576
624
|
shortcutLabelWrapper
|
|
577
|
-
} = (0,
|
|
578
|
-
const getYears = (0,
|
|
625
|
+
} = (0, import_recipes8.tableYearSlotRecipe)();
|
|
626
|
+
const getYears = (0, import_vue16.computed)(() => {
|
|
579
627
|
return chunk(props.years, 4);
|
|
580
628
|
});
|
|
581
629
|
function onNextButton() {
|
|
@@ -611,30 +659,30 @@ var TableYear = (0, import_vue14.defineComponent)({
|
|
|
611
659
|
}
|
|
612
660
|
__name(getMonthAttrs, "getMonthAttrs");
|
|
613
661
|
return () => {
|
|
614
|
-
return (0,
|
|
662
|
+
return (0, import_vue15.createVNode)("div", null, [(0, import_vue15.createVNode)("div", {
|
|
615
663
|
"data-pixel-parts": "Header",
|
|
616
664
|
"class": headerRoot
|
|
617
|
-
}, [(0,
|
|
665
|
+
}, [(0, import_vue15.createVNode)(import_pixel3_button3.MpButton, {
|
|
618
666
|
"left-icon": "chevrons-left",
|
|
619
667
|
"variant": "ghost",
|
|
620
668
|
"size": "sm",
|
|
621
669
|
"onClick": onPreviousButton
|
|
622
|
-
}, null), (0,
|
|
670
|
+
}, null), (0, import_vue15.createVNode)("button", {
|
|
623
671
|
"class": headerLabel
|
|
624
|
-
}, [props.headerLabel]), (0,
|
|
672
|
+
}, [props.headerLabel]), (0, import_vue15.createVNode)(import_pixel3_button3.MpButton, {
|
|
625
673
|
"right-icon": "chevrons-right",
|
|
626
674
|
"variant": "ghost",
|
|
627
675
|
"size": "sm",
|
|
628
676
|
"onClick": onNextButton
|
|
629
|
-
}, null)]), (0,
|
|
677
|
+
}, null)]), (0, import_vue15.createVNode)("div", {
|
|
630
678
|
"class": yearItemRoot
|
|
631
|
-
}, [getYears.value.map((data) => (0,
|
|
679
|
+
}, [getYears.value.map((data) => (0, import_vue15.createVNode)("div", {
|
|
632
680
|
"class": yearItemWrapper
|
|
633
|
-
}, [data.map((year) => (0,
|
|
634
|
-
default: () => [(0,
|
|
635
|
-
}))]))]), props.isShowShortcut && (0,
|
|
681
|
+
}, [data.map((year) => (0, import_vue15.createVNode)(YearItem, getMonthAttrs(year), {
|
|
682
|
+
default: () => [(0, import_vue15.createTextVNode)(" "), year, (0, import_vue15.createTextVNode)(" ")]
|
|
683
|
+
}))]))]), props.isShowShortcut && (0, import_vue15.createVNode)("div", {
|
|
636
684
|
"class": shortcutLabelWrapper
|
|
637
|
-
}, [(0,
|
|
685
|
+
}, [(0, import_vue15.createVNode)(import_pixel3_button3.MpButton, {
|
|
638
686
|
"variant": "ghost",
|
|
639
687
|
"onClick": () => onSelectYear((/* @__PURE__ */ new Date()).getFullYear())
|
|
640
688
|
}, {
|
|
@@ -648,11 +696,11 @@ var TableYear = (0, import_vue14.defineComponent)({
|
|
|
648
696
|
var import_date_fns3 = require("date-fns");
|
|
649
697
|
|
|
650
698
|
// src/composables/useCalendar.ts
|
|
651
|
-
var
|
|
699
|
+
var import_vue17 = require("vue");
|
|
652
700
|
var import_date_fns2 = require("date-fns");
|
|
653
701
|
function useCalendar(date, locale2) {
|
|
654
|
-
const currentDate = (0,
|
|
655
|
-
const currentPanel = (0,
|
|
702
|
+
const currentDate = (0, import_vue17.ref)(isValidDate(date) ? date : /* @__PURE__ */ new Date());
|
|
703
|
+
const currentPanel = (0, import_vue17.ref)("date");
|
|
656
704
|
const nextMonth = /* @__PURE__ */ __name(() => {
|
|
657
705
|
currentDate.value = getNextMonth(currentDate.value);
|
|
658
706
|
}, "nextMonth");
|
|
@@ -671,7 +719,7 @@ function useCalendar(date, locale2) {
|
|
|
671
719
|
const changeMonth = /* @__PURE__ */ __name((month) => {
|
|
672
720
|
currentDate.value = (0, import_date_fns2.setMonth)(currentDate.value, month);
|
|
673
721
|
}, "changeMonth");
|
|
674
|
-
const getSplitDates = (0,
|
|
722
|
+
const getSplitDates = (0, import_vue17.computed)(() => {
|
|
675
723
|
return {
|
|
676
724
|
day: currentDate.value.getDay(),
|
|
677
725
|
month: currentDate.value.getMonth(),
|
|
@@ -679,7 +727,7 @@ function useCalendar(date, locale2) {
|
|
|
679
727
|
monthLabel: locale2.value.months[currentDate.value.getMonth()]
|
|
680
728
|
};
|
|
681
729
|
});
|
|
682
|
-
const getDates = (0,
|
|
730
|
+
const getDates = (0, import_vue17.computed)(() => {
|
|
683
731
|
const {
|
|
684
732
|
year,
|
|
685
733
|
month
|
|
@@ -691,7 +739,7 @@ function useCalendar(date, locale2) {
|
|
|
691
739
|
});
|
|
692
740
|
return arr;
|
|
693
741
|
});
|
|
694
|
-
const getMonths = (0,
|
|
742
|
+
const getMonths = (0, import_vue17.computed)(() => {
|
|
695
743
|
const monthsLocale = locale2.value.formatLocale.monthsShort || locale2.value.months;
|
|
696
744
|
const months = monthsLocale.map((text, month) => {
|
|
697
745
|
return {
|
|
@@ -701,7 +749,7 @@ function useCalendar(date, locale2) {
|
|
|
701
749
|
});
|
|
702
750
|
return months;
|
|
703
751
|
});
|
|
704
|
-
const getYears = (0,
|
|
752
|
+
const getYears = (0, import_vue17.computed)(() => {
|
|
705
753
|
const {
|
|
706
754
|
year
|
|
707
755
|
} = getSplitDates.value;
|
|
@@ -712,7 +760,7 @@ function useCalendar(date, locale2) {
|
|
|
712
760
|
}
|
|
713
761
|
return years;
|
|
714
762
|
});
|
|
715
|
-
const getLabel = (0,
|
|
763
|
+
const getLabel = (0, import_vue17.computed)(() => {
|
|
716
764
|
const {
|
|
717
765
|
year,
|
|
718
766
|
monthLabel
|
|
@@ -754,22 +802,22 @@ function useCalendar(date, locale2) {
|
|
|
754
802
|
__name(useCalendar, "useCalendar");
|
|
755
803
|
|
|
756
804
|
// src/composables/useCalendarRange.ts
|
|
757
|
-
var
|
|
805
|
+
var import_vue18 = require("vue");
|
|
758
806
|
function useCalendarRange(props) {
|
|
759
807
|
const leftCalendar = startOfMonth(/* @__PURE__ */ new Date());
|
|
760
808
|
const rightCalendar = startOfMonth(getNextMonth(/* @__PURE__ */ new Date()));
|
|
761
|
-
const startDate = (0,
|
|
762
|
-
const endDate = (0,
|
|
763
|
-
const hoveredDate = (0,
|
|
764
|
-
const calendars = (0,
|
|
765
|
-
const getCurrentDates = (0,
|
|
809
|
+
const startDate = (0, import_vue18.ref)(props.modelValue[0]);
|
|
810
|
+
const endDate = (0, import_vue18.ref)(props.modelValue[1]);
|
|
811
|
+
const hoveredDate = (0, import_vue18.ref)();
|
|
812
|
+
const calendars = (0, import_vue18.ref)([leftCalendar, rightCalendar]);
|
|
813
|
+
const getCurrentDates = (0, import_vue18.computed)(() => {
|
|
766
814
|
if (startDate.value && !endDate.value)
|
|
767
815
|
return [startDate.value];
|
|
768
816
|
if (startDate.value && endDate.value)
|
|
769
817
|
return [startDate.value, endDate.value];
|
|
770
818
|
return [];
|
|
771
819
|
});
|
|
772
|
-
const calendarMinDiff = (0,
|
|
820
|
+
const calendarMinDiff = (0, import_vue18.computed)(() => {
|
|
773
821
|
const map = {
|
|
774
822
|
date: 1,
|
|
775
823
|
// type:date min 1 month
|
|
@@ -780,7 +828,7 @@ function useCalendarRange(props) {
|
|
|
780
828
|
};
|
|
781
829
|
return map[props.type] || map.date;
|
|
782
830
|
});
|
|
783
|
-
const calendarMaxDiff = (0,
|
|
831
|
+
const calendarMaxDiff = (0, import_vue18.computed)(() => Infinity);
|
|
784
832
|
function setStartDate(date) {
|
|
785
833
|
startDate.value = date;
|
|
786
834
|
}
|
|
@@ -870,6 +918,51 @@ function useCalendarRange(props) {
|
|
|
870
918
|
__name(useCalendarRange, "useCalendarRange");
|
|
871
919
|
|
|
872
920
|
// src/modules/date-picker.props.ts
|
|
921
|
+
var timePanelProps = {
|
|
922
|
+
modelValue: {
|
|
923
|
+
type: Date
|
|
924
|
+
},
|
|
925
|
+
defaultDate: {
|
|
926
|
+
type: Date,
|
|
927
|
+
default() {
|
|
928
|
+
const date = /* @__PURE__ */ new Date();
|
|
929
|
+
date.setHours(0, 0, 0, 0);
|
|
930
|
+
return date;
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
isShowHour: {
|
|
934
|
+
type: Boolean,
|
|
935
|
+
default: true
|
|
936
|
+
},
|
|
937
|
+
isShowMinute: {
|
|
938
|
+
type: Boolean,
|
|
939
|
+
default: true
|
|
940
|
+
},
|
|
941
|
+
isShowSecond: {
|
|
942
|
+
type: Boolean,
|
|
943
|
+
default: true
|
|
944
|
+
},
|
|
945
|
+
hourStep: {
|
|
946
|
+
type: Number,
|
|
947
|
+
default: 1
|
|
948
|
+
},
|
|
949
|
+
minuteStep: {
|
|
950
|
+
type: Number,
|
|
951
|
+
default: 1
|
|
952
|
+
},
|
|
953
|
+
secondStep: {
|
|
954
|
+
type: Number,
|
|
955
|
+
default: 1
|
|
956
|
+
},
|
|
957
|
+
isUse12h: {
|
|
958
|
+
type: Boolean,
|
|
959
|
+
default: false
|
|
960
|
+
},
|
|
961
|
+
disabledTime: {
|
|
962
|
+
type: Function,
|
|
963
|
+
default: () => false
|
|
964
|
+
}
|
|
965
|
+
};
|
|
873
966
|
var calendarPanelProps = {
|
|
874
967
|
modelValue: {
|
|
875
968
|
type: Date
|
|
@@ -934,6 +1027,7 @@ var calendarPanelRangeProps = {
|
|
|
934
1027
|
}
|
|
935
1028
|
};
|
|
936
1029
|
var datePickerProps = {
|
|
1030
|
+
...timePanelProps,
|
|
937
1031
|
id: {
|
|
938
1032
|
type: String
|
|
939
1033
|
},
|
|
@@ -1060,8 +1154,8 @@ function getLocale(config) {
|
|
|
1060
1154
|
__name(getLocale, "getLocale");
|
|
1061
1155
|
|
|
1062
1156
|
// src/calendar-panel.tsx
|
|
1063
|
-
var
|
|
1064
|
-
var CalendarPanel = (0,
|
|
1157
|
+
var import_recipes9 = require("@mekari/pixel3-styled-system/recipes");
|
|
1158
|
+
var CalendarPanel = (0, import_vue20.defineComponent)({
|
|
1065
1159
|
name: "CalendarPanel",
|
|
1066
1160
|
props: calendarPanelProps,
|
|
1067
1161
|
emits: ["update:modelValue", "mouseEnter", "mouseLeave", "updateCalendar"],
|
|
@@ -1071,7 +1165,7 @@ var CalendarPanel = (0, import_vue18.defineComponent)({
|
|
|
1071
1165
|
const {
|
|
1072
1166
|
locale: locale2
|
|
1073
1167
|
} = useDatePickerContext();
|
|
1074
|
-
const restValue = (0,
|
|
1168
|
+
const restValue = (0, import_vue20.ref)(props.modelValue);
|
|
1075
1169
|
const {
|
|
1076
1170
|
currentDate: currentPanelDate,
|
|
1077
1171
|
currentPanel,
|
|
@@ -1190,31 +1284,31 @@ var CalendarPanel = (0, import_vue18.defineComponent)({
|
|
|
1190
1284
|
}
|
|
1191
1285
|
}
|
|
1192
1286
|
__name(initCalendar, "initCalendar");
|
|
1193
|
-
(0,
|
|
1287
|
+
(0, import_vue20.watch)(() => props.modelValue, (newValue) => {
|
|
1194
1288
|
if (newValue)
|
|
1195
1289
|
restValue.value = newValue;
|
|
1196
1290
|
}, {
|
|
1197
1291
|
immediate: true
|
|
1198
1292
|
});
|
|
1199
|
-
(0,
|
|
1293
|
+
(0, import_vue20.watch)(() => props.type, (newValue) => {
|
|
1200
1294
|
if (newValue)
|
|
1201
1295
|
currentPanel.value = newValue;
|
|
1202
1296
|
}, {
|
|
1203
1297
|
immediate: true
|
|
1204
1298
|
});
|
|
1205
|
-
(0,
|
|
1299
|
+
(0, import_vue20.watch)(() => currentPanelDate.value, (newValue) => {
|
|
1206
1300
|
if (newValue) {
|
|
1207
1301
|
emit("updateCalendar", newValue);
|
|
1208
1302
|
}
|
|
1209
1303
|
});
|
|
1210
|
-
(0,
|
|
1304
|
+
(0, import_vue20.watch)(() => props.calendar, () => {
|
|
1211
1305
|
initCalendar();
|
|
1212
1306
|
}, {
|
|
1213
1307
|
immediate: true
|
|
1214
1308
|
});
|
|
1215
1309
|
return () => {
|
|
1216
1310
|
if (currentPanel.value === "date") {
|
|
1217
|
-
return (0,
|
|
1311
|
+
return (0, import_vue19.createVNode)(TableDate, {
|
|
1218
1312
|
"days": locale2.value.days,
|
|
1219
1313
|
"dates": getDates.value,
|
|
1220
1314
|
"headerLabel": getLabel.value,
|
|
@@ -1231,7 +1325,7 @@ var CalendarPanel = (0, import_vue18.defineComponent)({
|
|
|
1231
1325
|
}, null);
|
|
1232
1326
|
}
|
|
1233
1327
|
if (currentPanel.value === "month") {
|
|
1234
|
-
return (0,
|
|
1328
|
+
return (0, import_vue19.createVNode)(TableMonth, {
|
|
1235
1329
|
"calendar": currentPanelDate.value,
|
|
1236
1330
|
"months": getMonths.value,
|
|
1237
1331
|
"headerLabel": getLabel.value,
|
|
@@ -1247,7 +1341,7 @@ var CalendarPanel = (0, import_vue18.defineComponent)({
|
|
|
1247
1341
|
}, null);
|
|
1248
1342
|
}
|
|
1249
1343
|
if (currentPanel.value === "year") {
|
|
1250
|
-
return (0,
|
|
1344
|
+
return (0, import_vue19.createVNode)(TableYear, {
|
|
1251
1345
|
"years": getYears.value,
|
|
1252
1346
|
"headerLabel": getLabel.value,
|
|
1253
1347
|
"shortcutLabel": locale2.value.thisYearText,
|
|
@@ -1263,7 +1357,7 @@ var CalendarPanel = (0, import_vue18.defineComponent)({
|
|
|
1263
1357
|
};
|
|
1264
1358
|
}
|
|
1265
1359
|
});
|
|
1266
|
-
var CalendarPanelRange = (0,
|
|
1360
|
+
var CalendarPanelRange = (0, import_vue20.defineComponent)({
|
|
1267
1361
|
name: "CalendarPanelRange",
|
|
1268
1362
|
props: calendarPanelRangeProps,
|
|
1269
1363
|
emits: ["update:modelValue"],
|
|
@@ -1470,7 +1564,7 @@ var CalendarPanelRange = (0, import_vue18.defineComponent)({
|
|
|
1470
1564
|
__name(getYearStatus, "getYearStatus");
|
|
1471
1565
|
return () => {
|
|
1472
1566
|
const isWeekAndBiweek = props.type === "week" || props.type === "biweek";
|
|
1473
|
-
const classes = isWeekAndBiweek ? "" : (0,
|
|
1567
|
+
const classes = isWeekAndBiweek ? "" : (0, import_recipes9.calendarPanelRangeRecipe)();
|
|
1474
1568
|
const calendarPanelAttrs = {
|
|
1475
1569
|
isRange: true,
|
|
1476
1570
|
type: props.type,
|
|
@@ -1483,51 +1577,305 @@ var CalendarPanelRange = (0, import_vue18.defineComponent)({
|
|
|
1483
1577
|
onMouseEnter: (date) => setHoveredDate(date),
|
|
1484
1578
|
onMouseLeave: () => setHoveredDate(void 0)
|
|
1485
1579
|
};
|
|
1486
|
-
const leftNode = (0,
|
|
1580
|
+
const leftNode = (0, import_vue19.createVNode)(CalendarPanel, (0, import_vue19.mergeProps)({
|
|
1487
1581
|
"data-pixel-parts": "CalendarPanelLeft"
|
|
1488
1582
|
}, calendarPanelAttrs, {
|
|
1489
1583
|
"onUpdateCalendar": (value) => updateStartCalendar(value),
|
|
1490
1584
|
"calendar": calendars.value[0]
|
|
1491
1585
|
}), null);
|
|
1492
|
-
const rightNode = props.isInline ? "" : (0,
|
|
1586
|
+
const rightNode = props.isInline ? "" : (0, import_vue19.createVNode)(CalendarPanel, (0, import_vue19.mergeProps)({
|
|
1493
1587
|
"data-pixel-parts": "CalendarPanelRight"
|
|
1494
1588
|
}, calendarPanelAttrs, {
|
|
1495
1589
|
"style": "margin-left: 16px;",
|
|
1496
1590
|
"onUpdateCalendar": (value) => updateEndCalendar(value),
|
|
1497
1591
|
"calendar": calendars.value[1]
|
|
1498
1592
|
}), null);
|
|
1499
|
-
const weekAndBiweekNode = (0,
|
|
1593
|
+
const weekAndBiweekNode = (0, import_vue19.createVNode)(CalendarPanel, (0, import_vue19.mergeProps)({
|
|
1500
1594
|
"data-pixel-parts": "CalendarPanel"
|
|
1501
1595
|
}, calendarPanelAttrs, {
|
|
1502
1596
|
"onUpdateCalendar": (value) => updateStartCalendar(value),
|
|
1503
1597
|
"calendar": props.modelValue[0],
|
|
1504
1598
|
"type": "date"
|
|
1505
1599
|
}), null);
|
|
1506
|
-
return (0,
|
|
1600
|
+
return (0, import_vue19.createVNode)("div", {
|
|
1507
1601
|
"class": classes
|
|
1508
1602
|
}, [isWeekAndBiweek ? weekAndBiweekNode : [leftNode, rightNode]]);
|
|
1509
1603
|
};
|
|
1510
1604
|
}
|
|
1511
1605
|
});
|
|
1512
1606
|
|
|
1607
|
+
// src/time-panel.tsx
|
|
1608
|
+
var import_vue22 = require("vue");
|
|
1609
|
+
var import_vue23 = require("vue");
|
|
1610
|
+
var import_css = require("@mekari/pixel3-styled-system/css");
|
|
1611
|
+
|
|
1612
|
+
// src/composables/useTime.ts
|
|
1613
|
+
var import_vue21 = require("vue");
|
|
1614
|
+
function useTime(props) {
|
|
1615
|
+
const innerValue = (0, import_vue21.ref)(props.modelValue);
|
|
1616
|
+
const innerDateValue = (0, import_vue21.computed)(() => isValidDate(props.modelValue) ? props.modelValue : props.defaultDate);
|
|
1617
|
+
const columns = (0, import_vue21.computed)(() => {
|
|
1618
|
+
const cols = [];
|
|
1619
|
+
if (props.isShowHour)
|
|
1620
|
+
cols.push({
|
|
1621
|
+
type: "hour",
|
|
1622
|
+
list: getHoursList()
|
|
1623
|
+
});
|
|
1624
|
+
if (props.isShowMinute)
|
|
1625
|
+
cols.push({
|
|
1626
|
+
type: "minute",
|
|
1627
|
+
list: getMinutesList()
|
|
1628
|
+
});
|
|
1629
|
+
if (props.isShowSecond)
|
|
1630
|
+
cols.push({
|
|
1631
|
+
type: "second",
|
|
1632
|
+
list: getSecondsList()
|
|
1633
|
+
});
|
|
1634
|
+
if (props.isUse12h)
|
|
1635
|
+
cols.push({
|
|
1636
|
+
type: "ampm",
|
|
1637
|
+
list: getAMPMList()
|
|
1638
|
+
});
|
|
1639
|
+
return cols.filter((v) => v.list.length > 0);
|
|
1640
|
+
});
|
|
1641
|
+
function getHoursList() {
|
|
1642
|
+
return generateOptions(props.isUse12h ? 12 : 24, props.hourStep).map((num) => {
|
|
1643
|
+
const innerDate = new Date(innerDateValue.value);
|
|
1644
|
+
let text = padNumber(num);
|
|
1645
|
+
if (props.isUse12h) {
|
|
1646
|
+
if (num === 0) {
|
|
1647
|
+
text = "12";
|
|
1648
|
+
}
|
|
1649
|
+
if (innerDate.getHours() >= 12) {
|
|
1650
|
+
num += 12;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
const value = innerDate.setHours(num);
|
|
1654
|
+
return {
|
|
1655
|
+
value,
|
|
1656
|
+
text
|
|
1657
|
+
};
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
__name(getHoursList, "getHoursList");
|
|
1661
|
+
function getMinutesList() {
|
|
1662
|
+
return generateOptions(60, props.minuteStep).map((num) => {
|
|
1663
|
+
const value = new Date(innerDateValue.value).setMinutes(num);
|
|
1664
|
+
return {
|
|
1665
|
+
value,
|
|
1666
|
+
text: padNumber(num)
|
|
1667
|
+
};
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
__name(getMinutesList, "getMinutesList");
|
|
1671
|
+
function getSecondsList() {
|
|
1672
|
+
return generateOptions(60, props.secondStep).map((num) => {
|
|
1673
|
+
const value = new Date(innerDateValue.value).setSeconds(num);
|
|
1674
|
+
return {
|
|
1675
|
+
value,
|
|
1676
|
+
text: padNumber(num)
|
|
1677
|
+
};
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
__name(getSecondsList, "getSecondsList");
|
|
1681
|
+
function getAMPMList() {
|
|
1682
|
+
return ["AM", "PM"].map((text, i) => {
|
|
1683
|
+
const innerDate = new Date(innerDateValue.value);
|
|
1684
|
+
const value = innerDate.setHours(innerDate.getHours() % 12 + i * 12);
|
|
1685
|
+
return {
|
|
1686
|
+
text,
|
|
1687
|
+
value
|
|
1688
|
+
};
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
__name(getAMPMList, "getAMPMList");
|
|
1692
|
+
function isDisabledTime(value) {
|
|
1693
|
+
return props.disabledTime(new Date(value));
|
|
1694
|
+
}
|
|
1695
|
+
__name(isDisabledTime, "isDisabledTime");
|
|
1696
|
+
function isDisabledHour(date) {
|
|
1697
|
+
const value = new Date(date);
|
|
1698
|
+
return isDisabledTime(value) && isDisabledTime(value.setMinutes(0, 0, 0)) && isDisabledTime(value.setMinutes(59, 59, 999));
|
|
1699
|
+
}
|
|
1700
|
+
__name(isDisabledHour, "isDisabledHour");
|
|
1701
|
+
function isDisabledMinute(date) {
|
|
1702
|
+
const value = new Date(date);
|
|
1703
|
+
return isDisabledTime(value) && isDisabledTime(value.setSeconds(0, 0)) && isDisabledTime(value.setSeconds(59, 999));
|
|
1704
|
+
}
|
|
1705
|
+
__name(isDisabledMinute, "isDisabledMinute");
|
|
1706
|
+
function isDisabledAMPM(date) {
|
|
1707
|
+
const value = new Date(date);
|
|
1708
|
+
const minHour = value.getHours() < 12 ? 0 : 12;
|
|
1709
|
+
const maxHour = minHour + 11;
|
|
1710
|
+
return isDisabledTime(value) && isDisabledTime(value.setHours(minHour, 0, 0, 0)) && isDisabledTime(value.setHours(maxHour, 59, 59, 999));
|
|
1711
|
+
}
|
|
1712
|
+
__name(isDisabledAMPM, "isDisabledAMPM");
|
|
1713
|
+
function isDisabled(date, type) {
|
|
1714
|
+
if (type === "hour") {
|
|
1715
|
+
return isDisabledHour(date);
|
|
1716
|
+
}
|
|
1717
|
+
if (type === "minute") {
|
|
1718
|
+
return isDisabledMinute(date);
|
|
1719
|
+
}
|
|
1720
|
+
if (type === "ampm") {
|
|
1721
|
+
return isDisabledAMPM(date);
|
|
1722
|
+
}
|
|
1723
|
+
return isDisabledTime(date);
|
|
1724
|
+
}
|
|
1725
|
+
__name(isDisabled, "isDisabled");
|
|
1726
|
+
return {
|
|
1727
|
+
innerValue,
|
|
1728
|
+
columns,
|
|
1729
|
+
getHoursList,
|
|
1730
|
+
getMinutesList,
|
|
1731
|
+
getSecondsList,
|
|
1732
|
+
getAMPMList,
|
|
1733
|
+
isDisabledTime,
|
|
1734
|
+
isDisabledHour,
|
|
1735
|
+
isDisabledMinute,
|
|
1736
|
+
isDisabledAMPM,
|
|
1737
|
+
isDisabled
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
__name(useTime, "useTime");
|
|
1741
|
+
|
|
1742
|
+
// src/utils/dom.ts
|
|
1743
|
+
function getScrollParent(node, until = document.body) {
|
|
1744
|
+
if (!node || node === until) {
|
|
1745
|
+
return null;
|
|
1746
|
+
}
|
|
1747
|
+
const style = /* @__PURE__ */ __name((value, prop) => getComputedStyle(value, null).getPropertyValue(prop), "style");
|
|
1748
|
+
const regex = /(auto|scroll)/;
|
|
1749
|
+
const scroll = regex.test(style(node, "overflow") + style(node, "overflow-y") + style(node, "overflow-x"));
|
|
1750
|
+
return scroll ? node : getScrollParent(node.parentElement, until);
|
|
1751
|
+
}
|
|
1752
|
+
__name(getScrollParent, "getScrollParent");
|
|
1753
|
+
function scrollTo(element, to, duration = 0) {
|
|
1754
|
+
if (duration <= 0) {
|
|
1755
|
+
requestAnimationFrame(() => {
|
|
1756
|
+
element.scrollTop = to;
|
|
1757
|
+
});
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
const difference = to - element.scrollTop;
|
|
1761
|
+
const tick = difference / duration * 10;
|
|
1762
|
+
requestAnimationFrame(() => {
|
|
1763
|
+
const scrollTop = element.scrollTop + tick;
|
|
1764
|
+
if (scrollTop >= to) {
|
|
1765
|
+
element.scrollTop = to;
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
element.scrollTop = scrollTop;
|
|
1769
|
+
scrollTo(element, to, duration - 10);
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
__name(scrollTo, "scrollTo");
|
|
1773
|
+
|
|
1774
|
+
// src/time-panel.tsx
|
|
1775
|
+
var TimePanel = (0, import_vue23.defineComponent)({
|
|
1776
|
+
name: "MpTimePanel",
|
|
1777
|
+
props: timePanelProps,
|
|
1778
|
+
emits: ["update:modelValue"],
|
|
1779
|
+
setup(props, {
|
|
1780
|
+
emit
|
|
1781
|
+
}) {
|
|
1782
|
+
const columnNode = (0, import_vue23.ref)();
|
|
1783
|
+
const {
|
|
1784
|
+
innerValue,
|
|
1785
|
+
columns,
|
|
1786
|
+
isDisabled
|
|
1787
|
+
} = useTime(props);
|
|
1788
|
+
function handleSelectTime(col, item) {
|
|
1789
|
+
const date = new Date(item.value);
|
|
1790
|
+
innerValue.value = date;
|
|
1791
|
+
emit("update:modelValue", date);
|
|
1792
|
+
(0, import_vue23.nextTick)(() => handleScrollToSelected());
|
|
1793
|
+
}
|
|
1794
|
+
__name(handleSelectTime, "handleSelectTime");
|
|
1795
|
+
function getTimeStatus(value, type) {
|
|
1796
|
+
var _a;
|
|
1797
|
+
const cellDate = new Date(value);
|
|
1798
|
+
if (isDisabled(value, type)) {
|
|
1799
|
+
return "disabled";
|
|
1800
|
+
}
|
|
1801
|
+
if (cellDate.getTime() === ((_a = innerValue.value) == null ? void 0 : _a.getTime()) && isValidDate(innerValue.value)) {
|
|
1802
|
+
return "selected";
|
|
1803
|
+
}
|
|
1804
|
+
return "default";
|
|
1805
|
+
}
|
|
1806
|
+
__name(getTimeStatus, "getTimeStatus");
|
|
1807
|
+
function getTimeAttrs(value, type) {
|
|
1808
|
+
const status = getTimeStatus(value, type);
|
|
1809
|
+
return {
|
|
1810
|
+
status,
|
|
1811
|
+
isDisabled: status === "disabled" || void 0,
|
|
1812
|
+
"data-selected": status === "selected" || void 0
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
__name(getTimeAttrs, "getTimeAttrs");
|
|
1816
|
+
function handleScrollToSelected(duration = 0) {
|
|
1817
|
+
var _a;
|
|
1818
|
+
const elements = (_a = columnNode.value) == null ? void 0 : _a.querySelectorAll("[data-selected=true]");
|
|
1819
|
+
elements == null ? void 0 : elements.forEach((element) => {
|
|
1820
|
+
const scrollElement = getScrollParent(element, columnNode.value);
|
|
1821
|
+
if (scrollElement) {
|
|
1822
|
+
const to = element.offsetTop - 10;
|
|
1823
|
+
scrollTo(scrollElement, to, duration);
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
__name(handleScrollToSelected, "handleScrollToSelected");
|
|
1828
|
+
(0, import_vue23.onMounted)(() => {
|
|
1829
|
+
(0, import_vue23.nextTick)(() => handleScrollToSelected(0));
|
|
1830
|
+
});
|
|
1831
|
+
return () => {
|
|
1832
|
+
return (0, import_vue22.createVNode)("div", {
|
|
1833
|
+
"ref": columnNode,
|
|
1834
|
+
"class": (0, import_css.css)({
|
|
1835
|
+
display: "flex",
|
|
1836
|
+
flexDirection: "row",
|
|
1837
|
+
gap: "0.5"
|
|
1838
|
+
})
|
|
1839
|
+
}, [columns.value.map((col, colIndex) => (0, import_vue22.createVNode)("ul", {
|
|
1840
|
+
"data-index": colIndex,
|
|
1841
|
+
"data-type": col.type,
|
|
1842
|
+
"class": (0, import_css.css)({
|
|
1843
|
+
display: "flex",
|
|
1844
|
+
flexDirection: "column",
|
|
1845
|
+
height: "224px",
|
|
1846
|
+
overflowY: "scroll",
|
|
1847
|
+
overflowX: "hidden",
|
|
1848
|
+
py: "10px"
|
|
1849
|
+
})
|
|
1850
|
+
}, [col.list.map((item, itemIndex) => (0, import_vue22.createVNode)("li", {
|
|
1851
|
+
"onClick": () => handleSelectTime(col, item)
|
|
1852
|
+
}, [(0, import_vue22.createVNode)(TimeItem, (0, import_vue22.mergeProps)({
|
|
1853
|
+
"data-index": itemIndex
|
|
1854
|
+
}, getTimeAttrs(item.value, col.type)), {
|
|
1855
|
+
default: () => [item.text]
|
|
1856
|
+
})]))]))]);
|
|
1857
|
+
};
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1860
|
+
|
|
1513
1861
|
// src/modules/date-picker.hooks.ts
|
|
1514
|
-
var
|
|
1862
|
+
var import_vue24 = require("vue");
|
|
1515
1863
|
var import_pixel3_utils2 = require("@mekari/pixel3-utils");
|
|
1516
1864
|
var import_date_format_parse = require("date-format-parse");
|
|
1517
1865
|
function useDatePicker(props, emit) {
|
|
1518
1866
|
const getId = props.id || (0, import_pixel3_utils2.getUniqueId)("", "datepicker").value;
|
|
1519
|
-
const currentLabel = (0,
|
|
1520
|
-
const isOutside = (0,
|
|
1521
|
-
const isPopoverOpen = (0,
|
|
1522
|
-
const isInnerInvalid = (0,
|
|
1523
|
-
const userInput = (0,
|
|
1524
|
-
const innerValueDate = (0,
|
|
1525
|
-
const isUseRange = (0,
|
|
1867
|
+
const currentLabel = (0, import_vue24.ref)("");
|
|
1868
|
+
const isOutside = (0, import_vue24.ref)(true);
|
|
1869
|
+
const isPopoverOpen = (0, import_vue24.ref)(false);
|
|
1870
|
+
const isInnerInvalid = (0, import_vue24.ref)(false);
|
|
1871
|
+
const userInput = (0, import_vue24.ref)(null);
|
|
1872
|
+
const innerValueDate = (0, import_vue24.ref)();
|
|
1873
|
+
const isUseRange = (0, import_vue24.computed)(() => {
|
|
1526
1874
|
if (props.isRange || props.type === "biweek" || props.type === "week")
|
|
1527
1875
|
return true;
|
|
1528
1876
|
return false;
|
|
1529
1877
|
});
|
|
1530
|
-
const innerFormat = (0,
|
|
1878
|
+
const innerFormat = (0, import_vue24.computed)(() => {
|
|
1531
1879
|
const format2 = {
|
|
1532
1880
|
date: "DD-MM-YYYY",
|
|
1533
1881
|
datetime: "DD-MM-YYYY HH:mm:ss",
|
|
@@ -1539,7 +1887,7 @@ function useDatePicker(props, emit) {
|
|
|
1539
1887
|
};
|
|
1540
1888
|
return props.format || format2[props.type] || format2.date;
|
|
1541
1889
|
});
|
|
1542
|
-
const innerValue = (0,
|
|
1890
|
+
const innerValue = (0, import_vue24.computed)(() => {
|
|
1543
1891
|
if (isUseRange.value) {
|
|
1544
1892
|
if (isValidRangeDate(props.modelValue)) {
|
|
1545
1893
|
const startDate = valueToDate(props.modelValue[0]);
|
|
@@ -1550,7 +1898,7 @@ function useDatePicker(props, emit) {
|
|
|
1550
1898
|
}
|
|
1551
1899
|
return valueToDate(props.modelValue);
|
|
1552
1900
|
});
|
|
1553
|
-
const text = (0,
|
|
1901
|
+
const text = (0, import_vue24.computed)(() => {
|
|
1554
1902
|
if (userInput.value !== null)
|
|
1555
1903
|
return userInput.value;
|
|
1556
1904
|
if (!innerValue.value)
|
|
@@ -1567,7 +1915,7 @@ function useDatePicker(props, emit) {
|
|
|
1567
1915
|
}
|
|
1568
1916
|
return formatDate(innerValue.value);
|
|
1569
1917
|
});
|
|
1570
|
-
const locale2 = (0,
|
|
1918
|
+
const locale2 = (0, import_vue24.computed)(() => {
|
|
1571
1919
|
if (isObject(props.lang)) {
|
|
1572
1920
|
return getLocale(props.lang);
|
|
1573
1921
|
}
|
|
@@ -1626,7 +1974,8 @@ function useDatePicker(props, emit) {
|
|
|
1626
1974
|
}
|
|
1627
1975
|
if (isValidValueAndNotDisabled(date)) {
|
|
1628
1976
|
innerValueDate.value = date;
|
|
1629
|
-
(
|
|
1977
|
+
onEmitModelValue(innerValueDate.value);
|
|
1978
|
+
(0, import_vue24.nextTick)(() => {
|
|
1630
1979
|
isOutside.value = true;
|
|
1631
1980
|
isInnerInvalid.value = false;
|
|
1632
1981
|
onBlur();
|
|
@@ -1649,7 +1998,9 @@ function useDatePicker(props, emit) {
|
|
|
1649
1998
|
} else {
|
|
1650
1999
|
emit("update:modelValue", dateToValue(new Date(value)));
|
|
1651
2000
|
}
|
|
1652
|
-
(
|
|
2001
|
+
if (props.type === "time")
|
|
2002
|
+
return;
|
|
2003
|
+
(0, import_vue24.nextTick)(() => {
|
|
1653
2004
|
isOutside.value = true;
|
|
1654
2005
|
onBlur();
|
|
1655
2006
|
});
|
|
@@ -1751,12 +2102,12 @@ function useDatePicker(props, emit) {
|
|
|
1751
2102
|
__name(useDatePicker, "useDatePicker");
|
|
1752
2103
|
|
|
1753
2104
|
// src/date-picker.tsx
|
|
1754
|
-
var
|
|
2105
|
+
var import_recipes10 = require("@mekari/pixel3-styled-system/recipes");
|
|
1755
2106
|
function _isSlot(s) {
|
|
1756
|
-
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0,
|
|
2107
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, import_vue25.isVNode)(s);
|
|
1757
2108
|
}
|
|
1758
2109
|
__name(_isSlot, "_isSlot");
|
|
1759
|
-
var MpDatePicker = (0,
|
|
2110
|
+
var MpDatePicker = (0, import_vue26.defineComponent)({
|
|
1760
2111
|
name: "MpDatePicker",
|
|
1761
2112
|
props: datePickerProps,
|
|
1762
2113
|
emits: ["update:modelValue", "error"],
|
|
@@ -1776,7 +2127,8 @@ var MpDatePicker = (0, import_vue21.defineComponent)({
|
|
|
1776
2127
|
onBlur,
|
|
1777
2128
|
onClear,
|
|
1778
2129
|
onInputChange,
|
|
1779
|
-
onEmitModelValue
|
|
2130
|
+
onEmitModelValue,
|
|
2131
|
+
handleForceFocusToInput
|
|
1780
2132
|
} = useDatePicker(props, emit);
|
|
1781
2133
|
DatePickerProvider({
|
|
1782
2134
|
rootProps: props,
|
|
@@ -1786,9 +2138,11 @@ var MpDatePicker = (0, import_vue21.defineComponent)({
|
|
|
1786
2138
|
const {
|
|
1787
2139
|
root,
|
|
1788
2140
|
popoverContent
|
|
1789
|
-
} = (0,
|
|
1790
|
-
|
|
1791
|
-
|
|
2141
|
+
} = (0, import_recipes10.datePickerSlotRecipe)({
|
|
2142
|
+
variant: props.type === "time" ? "time" : "date"
|
|
2143
|
+
});
|
|
2144
|
+
const inputNode = (0, import_vue25.createVNode)(import_pixel3_input.MpInputGroup, null, {
|
|
2145
|
+
default: () => [(0, import_vue25.createVNode)(import_pixel3_input.MpInput, {
|
|
1792
2146
|
"id": getId,
|
|
1793
2147
|
"placeholder": props.placeholder,
|
|
1794
2148
|
"isClearable": props.isClearable,
|
|
@@ -1807,10 +2161,12 @@ var MpDatePicker = (0, import_vue21.defineComponent)({
|
|
|
1807
2161
|
const target = e.target;
|
|
1808
2162
|
target.focus();
|
|
1809
2163
|
}
|
|
1810
|
-
}, null), (0,
|
|
1811
|
-
default: () => [(0,
|
|
1812
|
-
"
|
|
1813
|
-
},
|
|
2164
|
+
}, null), (0, import_vue25.createVNode)(import_pixel3_input.MpInputRightAddon, null, {
|
|
2165
|
+
default: () => [(0, import_vue25.createVNode)("div", {
|
|
2166
|
+
"onClick": () => handleForceFocusToInput()
|
|
2167
|
+
}, [(0, import_vue25.createVNode)(import_pixel3_icon.MpIcon, {
|
|
2168
|
+
"name": props.type === "time" ? "time" : "calendar"
|
|
2169
|
+
}, null)])]
|
|
1814
2170
|
})]
|
|
1815
2171
|
});
|
|
1816
2172
|
const calendarPanelAttrs = {
|
|
@@ -1821,21 +2177,34 @@ var MpDatePicker = (0, import_vue21.defineComponent)({
|
|
|
1821
2177
|
disabledMonth: props.disabledMonth,
|
|
1822
2178
|
disabledYear: props.disabledYear
|
|
1823
2179
|
};
|
|
1824
|
-
const
|
|
2180
|
+
const datePanelNode = isUseRange.value ? (0, import_vue25.createVNode)(CalendarPanelRange, (0, import_vue25.mergeProps)(calendarPanelAttrs, {
|
|
1825
2181
|
"modelValue": innerValue.value
|
|
1826
|
-
}), null) : (0,
|
|
2182
|
+
}), null) : (0, import_vue25.createVNode)(CalendarPanel, (0, import_vue25.mergeProps)(calendarPanelAttrs, {
|
|
1827
2183
|
"modelValue": innerValue.value
|
|
1828
2184
|
}), null);
|
|
1829
|
-
const
|
|
2185
|
+
const timePanelNode = (0, import_vue25.createVNode)(TimePanel, {
|
|
2186
|
+
"modelValue": innerValue.value,
|
|
2187
|
+
"onUpdate:modelValue": onEmitModelValue,
|
|
2188
|
+
"disabledTime": props.disabledTime,
|
|
2189
|
+
"isShowHour": props.isShowHour,
|
|
2190
|
+
"isShowMinute": props.isShowMinute,
|
|
2191
|
+
"isShowSecond": props.isShowSecond,
|
|
2192
|
+
"hourStep": props.hourStep,
|
|
2193
|
+
"minuteStep": props.minuteStep,
|
|
2194
|
+
"secondStep": props.minuteStep,
|
|
2195
|
+
"isUse12h": props.isUse12h
|
|
2196
|
+
}, null);
|
|
2197
|
+
const panelNode = props.type === "time" ? timePanelNode : datePanelNode;
|
|
2198
|
+
const withPopover = (0, import_vue25.createVNode)(import_pixel3_popover.MpPopover, {
|
|
1830
2199
|
"id": getId,
|
|
1831
2200
|
"isManual": true,
|
|
1832
2201
|
"isOpen": isPopoverOpen.value,
|
|
1833
2202
|
"isKeepAlive": props.isKeepAlive,
|
|
1834
2203
|
"usePortal": props.usePortal
|
|
1835
2204
|
}, {
|
|
1836
|
-
default: () => [(0,
|
|
2205
|
+
default: () => [(0, import_vue25.createVNode)(import_pixel3_popover.MpPopoverTrigger, null, _isSlot(inputNode) ? inputNode : {
|
|
1837
2206
|
default: () => [inputNode]
|
|
1838
|
-
}), (0,
|
|
2207
|
+
}), (0, import_vue25.createVNode)(import_pixel3_popover.MpPopoverContent, {
|
|
1839
2208
|
"class": popoverContent,
|
|
1840
2209
|
"style": {
|
|
1841
2210
|
width: props.isRange ? "590px" : ""
|
|
@@ -1846,7 +2215,7 @@ var MpDatePicker = (0, import_vue21.defineComponent)({
|
|
|
1846
2215
|
default: () => [panelNode]
|
|
1847
2216
|
})]
|
|
1848
2217
|
});
|
|
1849
|
-
return (0,
|
|
2218
|
+
return (0, import_vue25.createVNode)("div", {
|
|
1850
2219
|
"class": root,
|
|
1851
2220
|
"onMouseenter": () => isOutside.value = false,
|
|
1852
2221
|
"onMouseleave": () => isOutside.value = true
|