@varlet/ui 3.8.2 → 3.8.3
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/es/action-sheet/ActionItem.mjs +4 -4
- package/es/action-sheet/ActionSheet.mjs +9 -9
- package/es/action-sheet/index.mjs +2 -2
- package/es/action-sheet/props.mjs +1 -1
- package/es/action-sheet/style/index.mjs +1 -1
- package/es/alert/Alert.mjs +3 -3
- package/es/alert/index.mjs +1 -1
- package/es/app-bar/AppBar.mjs +5 -5
- package/es/app-bar/index.mjs +1 -1
- package/es/auto-complete/AutoComplete.mjs +23 -27
- package/es/auto-complete/index.mjs +1 -1
- package/es/auto-complete/props.mjs +1 -1
- package/es/avatar/Avatar.mjs +5 -5
- package/es/avatar/index.mjs +1 -1
- package/es/avatar-group/AvatarGroup.mjs +2 -2
- package/es/avatar-group/index.mjs +1 -1
- package/es/back-top/BackTop.mjs +7 -7
- package/es/back-top/index.mjs +1 -1
- package/es/badge/Badge.mjs +3 -3
- package/es/badge/index.mjs +1 -1
- package/es/badge/props.mjs +1 -1
- package/es/bottom-navigation/BottomNavigation.mjs +8 -9
- package/es/bottom-navigation/index.mjs +1 -1
- package/es/bottom-navigation-item/BottomNavigationItem.mjs +4 -4
- package/es/bottom-navigation-item/index.mjs +1 -1
- package/es/bottom-navigation-item/provide.mjs +1 -1
- package/es/breadcrumb/Breadcrumb.mjs +3 -3
- package/es/breadcrumb/index.mjs +1 -1
- package/es/breadcrumb/provide.mjs +1 -1
- package/es/breadcrumbs/Breadcrumbs.mjs +2 -2
- package/es/breadcrumbs/index.mjs +1 -1
- package/es/button/Button.mjs +6 -6
- package/es/button/index.mjs +1 -1
- package/es/button-group/ButtonGroup.mjs +1 -1
- package/es/button-group/index.mjs +1 -1
- package/es/card/Card.mjs +39 -39
- package/es/card/index.mjs +1 -1
- package/es/cell/Cell.mjs +3 -3
- package/es/cell/index.mjs +1 -1
- package/es/cell/props.mjs +1 -1
- package/es/checkbox/Checkbox.mjs +7 -7
- package/es/checkbox/index.mjs +1 -1
- package/es/checkbox-group/CheckboxGroup.mjs +5 -5
- package/es/checkbox-group/index.mjs +1 -1
- package/es/chip/Chip.mjs +4 -4
- package/es/chip/index.mjs +1 -1
- package/es/chip/props.mjs +1 -1
- package/es/code/Code.mjs +1 -1
- package/es/code/index.mjs +1 -1
- package/es/col/Col.mjs +4 -4
- package/es/col/index.mjs +1 -1
- package/es/collapse/Collapse.mjs +6 -4
- package/es/collapse/index.mjs +1 -1
- package/es/collapse-item/CollapseItem.mjs +4 -4
- package/es/collapse-item/index.mjs +1 -1
- package/es/collapse-item/provide.mjs +1 -1
- package/es/collapse-transition/CollapseTransition.mjs +2 -2
- package/es/collapse-transition/index.mjs +1 -1
- package/es/collapse-transition/useCollapseTransition.mjs +1 -1
- package/es/context/lock.mjs +1 -1
- package/es/context/stack.mjs +1 -1
- package/es/context/zIndex.mjs +1 -1
- package/es/count-to/CountTo.mjs +4 -4
- package/es/count-to/index.mjs +1 -1
- package/es/countdown/Countdown.mjs +2 -2
- package/es/countdown/index.mjs +1 -1
- package/es/counter/Counter.mjs +8 -8
- package/es/counter/index.mjs +1 -1
- package/es/date-picker/DatePicker.mjs +92 -43
- package/es/date-picker/index.mjs +1 -1
- package/es/date-picker/src/day-picker-panel.mjs +59 -27
- package/es/date-picker/src/month-picker-panel.mjs +57 -23
- package/es/date-picker/src/panel-header.mjs +12 -6
- package/es/date-picker/src/year-picker-panel.mjs +53 -23
- package/es/dialog/Dialog.mjs +5 -5
- package/es/dialog/index.mjs +3 -3
- package/es/dialog/props.mjs +1 -1
- package/es/divider/Divider.mjs +4 -4
- package/es/divider/index.mjs +1 -1
- package/es/drag/Drag.mjs +21 -42
- package/es/drag/index.mjs +1 -1
- package/es/ellipsis/Ellipsis.mjs +2 -2
- package/es/ellipsis/index.mjs +1 -1
- package/es/fab/Fab.mjs +4 -5
- package/es/fab/index.mjs +1 -1
- package/es/fab/props.mjs +1 -1
- package/es/field-decorator/FieldDecorator.mjs +5 -5
- package/es/field-decorator/index.mjs +1 -1
- package/es/floating-panel/FloatingPanel.mjs +6 -6
- package/es/floating-panel/index.mjs +1 -1
- package/es/form/Form.mjs +4 -4
- package/es/form/index.mjs +2 -2
- package/es/form/provide.mjs +1 -1
- package/es/form-details/index.mjs +1 -1
- package/es/highlighter-provider/HighlighterProvider.mjs +2 -2
- package/es/highlighter-provider/index.mjs +1 -1
- package/es/highlighter-provider/provide.mjs +1 -1
- package/es/hover/index.mjs +12 -7
- package/es/hover-overlay/HoverOverlay.mjs +2 -2
- package/es/hover-overlay/index.mjs +2 -2
- package/es/icon/Icon.mjs +3 -3
- package/es/icon/index.mjs +1 -1
- package/es/image/Image.mjs +5 -5
- package/es/image/index.mjs +1 -1
- package/es/image-preview/ImagePreview.mjs +13 -14
- package/es/image-preview/index.mjs +2 -2
- package/es/image-preview/props.mjs +2 -2
- package/es/index-anchor/IndexAnchor.mjs +5 -5
- package/es/index-anchor/index.mjs +1 -1
- package/es/index-anchor/provide.mjs +1 -1
- package/es/index-bar/IndexBar.mjs +17 -13
- package/es/index-bar/index.mjs +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/Input.mjs +12 -12
- package/es/input/index.mjs +1 -1
- package/es/input/props.mjs +1 -1
- package/es/lazy/index.mjs +1 -1
- package/es/link/Link.mjs +2 -2
- package/es/link/index.mjs +1 -1
- package/es/list/List.mjs +10 -10
- package/es/list/index.mjs +1 -1
- package/es/list/provide.mjs +1 -1
- package/es/loading/Loading.mjs +2 -2
- package/es/loading/index.mjs +1 -1
- package/es/loading-bar/LoadingBar.mjs +1 -2
- package/es/loading-bar/index.mjs +1 -1
- package/es/locale/index.mjs +5 -5
- package/es/locale-provider/LocaleProvider.mjs +11 -8
- package/es/locale-provider/index.mjs +1 -1
- package/es/locale-provider/provide.mjs +1 -1
- package/es/menu/Menu.mjs +2 -2
- package/es/menu/index.mjs +1 -1
- package/es/menu/usePopover.mjs +6 -6
- package/es/menu-option/MenuOption.mjs +9 -9
- package/es/menu-option/index.mjs +1 -1
- package/es/menu-option/provide.mjs +1 -1
- package/es/menu-select/MenuChildren.mjs +21 -21
- package/es/menu-select/MenuSelect.mjs +9 -9
- package/es/menu-select/index.mjs +1 -1
- package/es/option/Option.mjs +5 -5
- package/es/option/index.mjs +1 -1
- package/es/option/provide.mjs +1 -1
- package/es/overlay/Overlay.mjs +4 -4
- package/es/overlay/index.mjs +1 -1
- package/es/pagination/Pagination.mjs +26 -18
- package/es/pagination/index.mjs +1 -1
- package/es/paper/Paper.mjs +3 -3
- package/es/paper/index.mjs +1 -1
- package/es/picker/Picker.mjs +9 -9
- package/es/picker/index.mjs +2 -2
- package/es/picker/props.mjs +1 -1
- package/es/popup/Popup.mjs +6 -6
- package/es/popup/index.mjs +1 -1
- package/es/progress/Progress.mjs +4 -4
- package/es/progress/index.mjs +1 -1
- package/es/pull-refresh/PullRefresh.mjs +10 -12
- package/es/pull-refresh/index.mjs +1 -1
- package/es/radio/Radio.mjs +10 -9
- package/es/radio/index.mjs +1 -1
- package/es/radio-group/RadioGroup.mjs +7 -6
- package/es/radio-group/index.mjs +1 -1
- package/es/rate/Rate.mjs +8 -8
- package/es/rate/index.mjs +1 -1
- package/es/rate/props.mjs +1 -1
- package/es/result/Result.mjs +7 -7
- package/es/result/index.mjs +1 -1
- package/es/ripple/index.mjs +1 -1
- package/es/row/Row.mjs +4 -4
- package/es/row/index.mjs +1 -1
- package/es/select/Select.mjs +13 -13
- package/es/select/index.mjs +1 -1
- package/es/select/props.mjs +1 -1
- package/es/skeleton/Skeleton.mjs +3 -3
- package/es/skeleton/index.mjs +1 -1
- package/es/slider/Slider.mjs +9 -9
- package/es/slider/index.mjs +1 -1
- package/es/snackbar/Snackbar.mjs +1 -1
- package/es/snackbar/core.mjs +8 -8
- package/es/snackbar/index.mjs +9 -8
- package/es/snackbar/props.mjs +1 -1
- package/es/space/Space.mjs +2 -2
- package/es/space/index.mjs +1 -1
- package/es/step/Step.mjs +3 -3
- package/es/step/index.mjs +1 -1
- package/es/step/provide.mjs +1 -1
- package/es/steps/Steps.mjs +3 -3
- package/es/steps/index.mjs +1 -1
- package/es/sticky/Sticky.mjs +7 -7
- package/es/sticky/index.mjs +1 -1
- package/es/style-provider/StyleProvider.mjs +2 -2
- package/es/style-provider/index.mjs +2 -2
- package/es/swipe/Swipe.mjs +10 -10
- package/es/swipe/index.mjs +1 -1
- package/es/swipe-item/SwipeItem.mjs +1 -1
- package/es/swipe-item/index.mjs +1 -1
- package/es/swipe-item/provide.mjs +1 -1
- package/es/switch/Switch.mjs +6 -6
- package/es/switch/index.mjs +1 -1
- package/es/tab/Tab.mjs +4 -4
- package/es/tab/index.mjs +1 -1
- package/es/tab/provide.mjs +1 -1
- package/es/tab-item/TabItem.mjs +3 -3
- package/es/tab-item/index.mjs +1 -1
- package/es/tab-item/provide.mjs +1 -1
- package/es/table/Table.mjs +1 -1
- package/es/table/index.mjs +1 -1
- package/es/tabs/Tabs.mjs +9 -7
- package/es/tabs/index.mjs +1 -1
- package/es/tabs/props.mjs +1 -1
- package/es/tabs-items/TabsItems.mjs +4 -4
- package/es/tabs-items/index.mjs +1 -1
- package/es/themes/dark/index.mjs +33 -33
- package/es/themes/index.mjs +1 -1
- package/es/themes/md3-dark/index.mjs +45 -45
- package/es/themes/md3-light/index.mjs +39 -39
- package/es/time-picker/TimePicker.mjs +48 -24
- package/es/time-picker/clock.mjs +41 -19
- package/es/time-picker/index.mjs +1 -1
- package/es/time-picker/utils.mjs +13 -5
- package/es/tooltip/Tooltip.mjs +2 -2
- package/es/tooltip/index.mjs +1 -1
- package/es/uploader/Uploader.mjs +14 -14
- package/es/uploader/index.mjs +1 -1
- package/es/utils/components.mjs +5 -5
- package/es/utils/elements.mjs +9 -9
- package/es/utils/test.mjs +1 -1
- package/es/varlet.esm.js +20946 -20941
- package/es/watermark/Watermark.mjs +15 -17
- package/es/watermark/index.mjs +1 -1
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/varlet.cjs.js +25205 -25003
- package/package.json +34 -34
- package/types/actionSheet.d.ts +2 -2
- package/types/alert.d.ts +1 -1
- package/types/appBar.d.ts +1 -1
- package/types/autoComplete.d.ts +4 -4
- package/types/avatar.d.ts +1 -1
- package/types/avatarGroup.d.ts +1 -1
- package/types/backTop.d.ts +1 -1
- package/types/badge.d.ts +1 -1
- package/types/bottomNavigation.d.ts +2 -2
- package/types/bottomNavigationItem.d.ts +2 -2
- package/types/breadcrumb.d.ts +1 -1
- package/types/breadcrumbs.d.ts +1 -1
- package/types/button.d.ts +5 -5
- package/types/buttonGroup.d.ts +2 -2
- package/types/card.d.ts +1 -1
- package/types/cell.d.ts +1 -1
- package/types/checkbox.d.ts +1 -1
- package/types/checkboxGroup.d.ts +2 -2
- package/types/chip.d.ts +3 -3
- package/types/code.d.ts +1 -1
- package/types/col.d.ts +1 -1
- package/types/collapse.d.ts +1 -1
- package/types/collapseItem.d.ts +1 -1
- package/types/collapseTransition.d.ts +1 -1
- package/types/countTo.d.ts +1 -1
- package/types/countdown.d.ts +1 -1
- package/types/counter.d.ts +1 -1
- package/types/datePicker.d.ts +1 -1
- package/types/dialog.d.ts +1 -1
- package/types/divider.d.ts +1 -1
- package/types/drag.d.ts +1 -1
- package/types/ellipsis.d.ts +1 -1
- package/types/fab.d.ts +2 -2
- package/types/floatingPanel.d.ts +2 -2
- package/types/form.d.ts +1 -1
- package/types/formDetails.d.ts +1 -1
- package/types/highlighterProvider.d.ts +1 -1
- package/types/hover.d.ts +1 -1
- package/types/hoverOverlay.d.ts +1 -1
- package/types/icon.d.ts +1 -1
- package/types/image.d.ts +2 -2
- package/types/imagePreview.d.ts +2 -2
- package/types/indexAnchor.d.ts +1 -1
- package/types/indexBar.d.ts +1 -1
- package/types/input.d.ts +4 -4
- package/types/link.d.ts +1 -1
- package/types/list.d.ts +1 -1
- package/types/loading.d.ts +1 -1
- package/types/localeProvider.d.ts +2 -2
- package/types/menu.d.ts +2 -2
- package/types/menuOption.d.ts +1 -1
- package/types/menuSelect.d.ts +2 -2
- package/types/option.d.ts +1 -1
- package/types/overlay.d.ts +2 -2
- package/types/pagination.d.ts +1 -1
- package/types/paper.d.ts +1 -1
- package/types/picker.d.ts +3 -3
- package/types/popup.d.ts +2 -2
- package/types/progress.d.ts +1 -1
- package/types/pullRefresh.d.ts +1 -1
- package/types/radio.d.ts +1 -1
- package/types/radioGroup.d.ts +3 -3
- package/types/rate.d.ts +1 -1
- package/types/result.d.ts +1 -1
- package/types/row.d.ts +1 -1
- package/types/select.d.ts +3 -3
- package/types/skeleton.d.ts +1 -1
- package/types/slider.d.ts +4 -4
- package/types/snackbar.d.ts +2 -2
- package/types/space.d.ts +1 -1
- package/types/step.d.ts +1 -1
- package/types/steps.d.ts +3 -3
- package/types/sticky.d.ts +1 -1
- package/types/styleProvider.d.ts +2 -2
- package/types/swipe.d.ts +1 -1
- package/types/swipeItem.d.ts +1 -1
- package/types/switch.d.ts +1 -1
- package/types/tab.d.ts +1 -1
- package/types/tabItem.d.ts +1 -1
- package/types/table.d.ts +1 -1
- package/types/tabs.d.ts +3 -3
- package/types/tabsItems.d.ts +2 -2
- package/types/timePicker.d.ts +1 -1
- package/types/tooltip.d.ts +2 -2
- package/types/uploader.d.ts +2 -2
- package/types/watermark.d.ts +1 -1
- package/umd/varlet.js +7 -7
|
@@ -18,21 +18,21 @@ var __async = (__this, __arguments, generator) => {
|
|
|
18
18
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
22
|
+
import { call, doubleRaf, error, isArray, toNumber } from "@varlet/shared";
|
|
21
23
|
import dayjs from "dayjs/esm/index.js";
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
24
|
+
import { t } from "../locale/index.mjs";
|
|
25
|
+
import { injectLocaleProvider } from "../locale-provider/provide.mjs";
|
|
26
|
+
import { createNamespace, formatElevation } from "../utils/components.mjs";
|
|
27
|
+
import { padStart } from "../utils/shared.mjs";
|
|
26
28
|
import {
|
|
27
|
-
props,
|
|
28
29
|
MONTH_LIST,
|
|
30
|
+
props,
|
|
29
31
|
WEEK_HEADER
|
|
30
32
|
} from "./props.mjs";
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import { t } from "../locale/index.mjs";
|
|
35
|
-
import { injectLocaleProvider } from "../locale-provider/provide.mjs";
|
|
33
|
+
import DayPickerPanel from "./src/day-picker-panel.mjs";
|
|
34
|
+
import MonthPickerPanel from "./src/month-picker-panel.mjs";
|
|
35
|
+
import YearPickerPanel from "./src/year-picker-panel.mjs";
|
|
36
36
|
const { name, n, classes } = createNamespace("date-picker");
|
|
37
37
|
import { toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderSlot as _renderSlot, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, normalizeProps as _normalizeProps, mergeProps as _mergeProps, Transition as _Transition, withCtx as _withCtx, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveComponent as _resolveComponent, createBlock as _createBlock } from "vue";
|
|
38
38
|
function __render__(_ctx, _cache) {
|
|
@@ -364,20 +364,32 @@ const __sfc__ = defineComponent({
|
|
|
364
364
|
const formatRangeDays = chooseRangeDay.value.map((date) => dayjs(date).format("YYYY-MM-DD"));
|
|
365
365
|
return formatRangeDays.length ? `${formatRangeDays[0]} ~ ${formatRangeDays[1]}` : "";
|
|
366
366
|
}
|
|
367
|
-
if (multiple)
|
|
368
|
-
|
|
367
|
+
if (multiple) {
|
|
368
|
+
return `${chooseDays.value.length}${(pt || t)("datePickerSelected")}`;
|
|
369
|
+
}
|
|
370
|
+
if (!chooseYear.value || !chooseMonth.value || !chooseDay.value) {
|
|
371
|
+
return "";
|
|
372
|
+
}
|
|
369
373
|
const weekIndex = dayjs(`${chooseYear.value}-${chooseMonth.value}-${chooseDay.value}`).day();
|
|
370
374
|
const week = WEEK_HEADER.find((value) => value === `${weekIndex}`);
|
|
371
375
|
const weekName = (_b = (_a = (pt || t)("datePickerWeekDict")) == null ? void 0 : _a[week].name) != null ? _b : "";
|
|
372
376
|
const monthName = (_d = (_c = (pt || t)("datePickerMonthDict")) == null ? void 0 : _c[chooseMonth.value].name) != null ? _d : "";
|
|
373
377
|
const showDay = padStart(chooseDay.value, 2, "0");
|
|
374
|
-
if ((pt || t)("lang") === "zh-CN")
|
|
378
|
+
if ((pt || t)("lang") === "zh-CN") {
|
|
379
|
+
return `${chooseMonth.value}-${showDay} ${weekName.slice(0, 3)}`;
|
|
380
|
+
}
|
|
375
381
|
return `${weekName.slice(0, 3)}, ${monthName.slice(0, 3)} ${chooseDay.value}`;
|
|
376
382
|
});
|
|
377
383
|
const getPanelType = computed(() => {
|
|
378
|
-
if (props2.type === "year" || isYearPanel.value)
|
|
379
|
-
|
|
380
|
-
|
|
384
|
+
if (props2.type === "year" || isYearPanel.value) {
|
|
385
|
+
return "year";
|
|
386
|
+
}
|
|
387
|
+
if (props2.type === "month" || isMonthPanel.value) {
|
|
388
|
+
return "month";
|
|
389
|
+
}
|
|
390
|
+
if (props2.type === "date") {
|
|
391
|
+
return "date";
|
|
392
|
+
}
|
|
381
393
|
return "";
|
|
382
394
|
});
|
|
383
395
|
const isUntouchable = computed(() => !props2.touchable || !getPanelType.value);
|
|
@@ -404,13 +416,19 @@ const __sfc__ = defineComponent({
|
|
|
404
416
|
watch(
|
|
405
417
|
() => props2.modelValue,
|
|
406
418
|
(value) => {
|
|
407
|
-
if (!checkValue() || invalidFormatDate(value))
|
|
419
|
+
if (!checkValue() || invalidFormatDate(value)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
408
422
|
if (props2.range) {
|
|
409
|
-
if (!isArray(value))
|
|
423
|
+
if (!isArray(value)) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
410
426
|
rangeDone.value = value.length !== 1;
|
|
411
427
|
rangeInit(value, props2.type);
|
|
412
428
|
} else if (props2.multiple) {
|
|
413
|
-
if (!isArray(value))
|
|
429
|
+
if (!isArray(value)) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
414
432
|
multipleInit(value, props2.type);
|
|
415
433
|
} else {
|
|
416
434
|
dateInit(value);
|
|
@@ -420,15 +438,19 @@ const __sfc__ = defineComponent({
|
|
|
420
438
|
);
|
|
421
439
|
watch(getPanelType, resetState);
|
|
422
440
|
function clickEl(type) {
|
|
423
|
-
if (type === "year")
|
|
424
|
-
|
|
425
|
-
else {
|
|
441
|
+
if (type === "year") {
|
|
442
|
+
isYearPanel.value = true;
|
|
443
|
+
} else if (type === "month") {
|
|
444
|
+
isMonthPanel.value = true;
|
|
445
|
+
} else {
|
|
426
446
|
isYearPanel.value = false;
|
|
427
447
|
isMonthPanel.value = false;
|
|
428
448
|
}
|
|
429
449
|
}
|
|
430
450
|
function handleTouchstart(event) {
|
|
431
|
-
if (isUntouchable.value)
|
|
451
|
+
if (isUntouchable.value) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
432
454
|
const { clientX, clientY } = event.touches[0];
|
|
433
455
|
startX = clientX;
|
|
434
456
|
startY = clientY;
|
|
@@ -437,7 +459,9 @@ const __sfc__ = defineComponent({
|
|
|
437
459
|
return x >= y && x > 20 ? "x" : "y";
|
|
438
460
|
}
|
|
439
461
|
function handleTouchmove(event) {
|
|
440
|
-
if (isUntouchable.value)
|
|
462
|
+
if (isUntouchable.value) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
441
465
|
const { clientX, clientY } = event.touches[0];
|
|
442
466
|
const x = clientX - startX;
|
|
443
467
|
const y = clientY - startY;
|
|
@@ -446,7 +470,9 @@ const __sfc__ = defineComponent({
|
|
|
446
470
|
}
|
|
447
471
|
function handleTouchend() {
|
|
448
472
|
return __async(this, null, function* () {
|
|
449
|
-
if (isUntouchable.value || touchDirection !== "x")
|
|
473
|
+
if (isUntouchable.value || touchDirection !== "x") {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
450
476
|
const componentRef = getPanelType.value === "year" ? yearPanelEl : getPanelType.value === "month" ? monthPanelEl : dayPanelEl;
|
|
451
477
|
yield doubleRaf();
|
|
452
478
|
componentRef.value.forwardRef(checkType);
|
|
@@ -469,27 +495,42 @@ const __sfc__ = defineComponent({
|
|
|
469
495
|
const formatType = type === "year" ? "YYYY" : type === "month" ? "YYYY-MM" : "YYYY-MM-DD";
|
|
470
496
|
const formatDates = multipleDates.value.map((date2) => dayjs(date2).format(formatType));
|
|
471
497
|
const index = formatDates.findIndex((choose) => choose === date);
|
|
472
|
-
if (index === -1)
|
|
473
|
-
|
|
498
|
+
if (index === -1) {
|
|
499
|
+
formatDates.push(date);
|
|
500
|
+
} else {
|
|
501
|
+
formatDates.splice(index, 1);
|
|
502
|
+
}
|
|
474
503
|
call(props2["onUpdate:modelValue"], formatDates);
|
|
475
504
|
call(props2.onChange, formatDates);
|
|
476
505
|
}
|
|
477
506
|
function getReverse(dateType, date) {
|
|
478
|
-
if (!chooseYear.value || !chooseMonth.value)
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
if (
|
|
507
|
+
if (!chooseYear.value || !chooseMonth.value) {
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
if (!isSameYear.value) {
|
|
511
|
+
return chooseYear.value > previewYear.value;
|
|
512
|
+
}
|
|
513
|
+
if (dateType === "year") {
|
|
514
|
+
return date < toNumber(chooseYear.value);
|
|
515
|
+
}
|
|
516
|
+
if (dateType === "month") {
|
|
517
|
+
return date < chooseMonth.value;
|
|
518
|
+
}
|
|
482
519
|
return isSameMonth.value ? date < toNumber(chooseDay.value) : chooseMonth.value > previewMonth.value;
|
|
483
520
|
}
|
|
484
521
|
function getChooseDay(day) {
|
|
485
522
|
const { readonly, range, multiple, onChange, "onUpdate:modelValue": updateModelValue } = props2;
|
|
486
|
-
if (day < 0 || readonly)
|
|
523
|
+
if (day < 0 || readonly) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
487
526
|
reverse.value = getReverse("day", day);
|
|
488
527
|
const date = `${previewYear.value}-${previewMonth.value}-${day}`;
|
|
489
528
|
const formatDate = dayjs(date).format("YYYY-MM-DD");
|
|
490
|
-
if (range)
|
|
491
|
-
|
|
492
|
-
else {
|
|
529
|
+
if (range) {
|
|
530
|
+
updateRange(formatDate, "day");
|
|
531
|
+
} else if (multiple) {
|
|
532
|
+
updateMultiple(formatDate, "day");
|
|
533
|
+
} else {
|
|
493
534
|
call(updateModelValue, formatDate);
|
|
494
535
|
call(onChange, formatDate);
|
|
495
536
|
}
|
|
@@ -499,9 +540,11 @@ const __sfc__ = defineComponent({
|
|
|
499
540
|
reverse.value = getReverse("month", month);
|
|
500
541
|
if (type === "month" && !readonly) {
|
|
501
542
|
const date = `${previewYear.value}-${month}`;
|
|
502
|
-
if (range)
|
|
503
|
-
|
|
504
|
-
else {
|
|
543
|
+
if (range) {
|
|
544
|
+
updateRange(date, "month");
|
|
545
|
+
} else if (multiple) {
|
|
546
|
+
updateMultiple(date, "month");
|
|
547
|
+
} else {
|
|
505
548
|
call(updateModelValue, date);
|
|
506
549
|
call(onChange, date);
|
|
507
550
|
}
|
|
@@ -520,9 +563,11 @@ const __sfc__ = defineComponent({
|
|
|
520
563
|
const { type, readonly, range, multiple, onChange, onPreview, "onUpdate:modelValue": updateModelValue } = props2;
|
|
521
564
|
reverse.value = getReverse("year", year);
|
|
522
565
|
if (type === "year" && !readonly) {
|
|
523
|
-
if (range)
|
|
524
|
-
|
|
525
|
-
else {
|
|
566
|
+
if (range) {
|
|
567
|
+
updateRange(`${year}`, "year");
|
|
568
|
+
} else if (multiple) {
|
|
569
|
+
updateMultiple(`${year}`, "year");
|
|
570
|
+
} else {
|
|
526
571
|
call(updateModelValue, `${year}`);
|
|
527
572
|
call(onChange, `${year}`);
|
|
528
573
|
}
|
|
@@ -586,7 +631,9 @@ const __sfc__ = defineComponent({
|
|
|
586
631
|
const formatType = type === "year" ? "YYYY" : type === "month" ? "YYYY-MM" : "YYYY-MM-D";
|
|
587
632
|
const formatDateList = value.map((choose) => dayjs(choose).format(formatType)).slice(0, 2);
|
|
588
633
|
const isValid = rangeDate.value.some((date) => invalidFormatDate(date));
|
|
589
|
-
if (isValid)
|
|
634
|
+
if (isValid) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
590
637
|
rangeDate.value = formatDateList;
|
|
591
638
|
const isChangeOrder = dayjs(rangeDate.value[0]).isAfter(rangeDate.value[1]);
|
|
592
639
|
if (rangeDate.value.length === 2 && isChangeOrder) {
|
|
@@ -602,7 +649,9 @@ const __sfc__ = defineComponent({
|
|
|
602
649
|
function dateInit(value) {
|
|
603
650
|
const handleValue = value ? dayjs(value) : dayjs();
|
|
604
651
|
const formatDate = handleValue.format("YYYY-MM-D");
|
|
605
|
-
if (invalidFormatDate(formatDate))
|
|
652
|
+
if (invalidFormatDate(formatDate)) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
606
655
|
const [yearValue, monthValue, dayValue] = formatDate.split("-");
|
|
607
656
|
const monthDes2 = MONTH_LIST.find((month) => month === monthValue);
|
|
608
657
|
chooseMonth.value = monthDes2;
|
package/es/date-picker/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import DatePicker from "./DatePicker.mjs";
|
|
2
1
|
import { withInstall, withPropsDefaultsSetter } from "../utils/components.mjs";
|
|
2
|
+
import DatePicker from "./DatePicker.mjs";
|
|
3
3
|
import { props as datePickerProps } from "./props.mjs";
|
|
4
4
|
withInstall(DatePicker);
|
|
5
5
|
withPropsDefaultsSetter(DatePicker, datePickerProps);
|
|
@@ -14,24 +14,24 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import dayjs from "dayjs/esm/index.js";
|
|
18
|
-
import isSameOrBefore from "dayjs/esm/plugin/isSameOrBefore/index.js";
|
|
19
|
-
import isSameOrAfter from "dayjs/esm/plugin/isSameOrAfter/index.js";
|
|
20
|
-
import PanelHeader from "./panel-header.mjs";
|
|
21
|
-
import VarButton from "../../button/index.mjs";
|
|
22
17
|
import {
|
|
18
|
+
computed,
|
|
23
19
|
defineComponent,
|
|
20
|
+
reactive,
|
|
24
21
|
ref,
|
|
25
|
-
|
|
26
|
-
watch,
|
|
27
|
-
reactive
|
|
22
|
+
watch
|
|
28
23
|
} from "vue";
|
|
29
|
-
import { WEEK_HEADER } from "../props.mjs";
|
|
30
24
|
import { toNumber } from "@varlet/shared";
|
|
31
|
-
import { createNamespace } from "../../utils/components.mjs";
|
|
32
|
-
import { t } from "../../locale/index.mjs";
|
|
33
25
|
import { onSmartMounted } from "@varlet/use";
|
|
26
|
+
import dayjs from "dayjs/esm/index.js";
|
|
27
|
+
import isSameOrAfter from "dayjs/esm/plugin/isSameOrAfter/index.js";
|
|
28
|
+
import isSameOrBefore from "dayjs/esm/plugin/isSameOrBefore/index.js";
|
|
29
|
+
import VarButton from "../../button/index.mjs";
|
|
30
|
+
import { t } from "../../locale/index.mjs";
|
|
34
31
|
import { injectLocaleProvider } from "../../locale-provider/provide.mjs";
|
|
32
|
+
import { createNamespace } from "../../utils/components.mjs";
|
|
33
|
+
import { WEEK_HEADER } from "../props.mjs";
|
|
34
|
+
import PanelHeader from "./panel-header.mjs";
|
|
35
35
|
dayjs.extend(isSameOrBefore);
|
|
36
36
|
dayjs.extend(isSameOrAfter);
|
|
37
37
|
const { n, classes } = createNamespace("day-picker");
|
|
@@ -233,8 +233,12 @@ const __sfc__ = defineComponent({
|
|
|
233
233
|
let isBeforeMax = true;
|
|
234
234
|
let isAfterMin = true;
|
|
235
235
|
const previewDate = `${previewYear}-${previewMonth}-${day}`;
|
|
236
|
-
if (max)
|
|
237
|
-
|
|
236
|
+
if (max) {
|
|
237
|
+
isBeforeMax = dayjs(previewDate).isSameOrBefore(dayjs(max), "day");
|
|
238
|
+
}
|
|
239
|
+
if (min) {
|
|
240
|
+
isAfterMin = dayjs(previewDate).isSameOrAfter(dayjs(min), "day");
|
|
241
|
+
}
|
|
238
242
|
return isBeforeMax && isAfterMin;
|
|
239
243
|
};
|
|
240
244
|
const shouldChoose = (val) => {
|
|
@@ -243,7 +247,9 @@ const __sfc__ = defineComponent({
|
|
|
243
247
|
componentProps: { range }
|
|
244
248
|
} = props;
|
|
245
249
|
if (range) {
|
|
246
|
-
if (!chooseRangeDay.length)
|
|
250
|
+
if (!chooseRangeDay.length) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
247
253
|
const isBeforeMax = dayjs(val).isSameOrBefore(dayjs(chooseRangeDay[1]), "day");
|
|
248
254
|
const isAfterMin = dayjs(val).isSameOrAfter(dayjs(chooseRangeDay[0]), "day");
|
|
249
255
|
return isBeforeMax && isAfterMin;
|
|
@@ -267,31 +273,55 @@ const __sfc__ = defineComponent({
|
|
|
267
273
|
} = props;
|
|
268
274
|
const val = `${previewYear}-${previewMonth}-${day}`;
|
|
269
275
|
const dayExist = () => {
|
|
270
|
-
if (range || multiple)
|
|
276
|
+
if (range || multiple) {
|
|
277
|
+
return shouldChoose(val);
|
|
278
|
+
}
|
|
271
279
|
return toNumber(chooseDay2) === day && isSame.value;
|
|
272
280
|
};
|
|
273
281
|
const computeDisabled = () => {
|
|
274
|
-
if (!inRange(day))
|
|
275
|
-
|
|
282
|
+
if (!inRange(day)) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
if (!allowedDates) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
276
288
|
return !allowedDates(val);
|
|
277
289
|
};
|
|
278
290
|
const disabled = computeDisabled();
|
|
279
291
|
const computeText = () => {
|
|
280
|
-
if (disabled)
|
|
281
|
-
|
|
292
|
+
if (disabled) {
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
if (range || multiple) {
|
|
296
|
+
return !shouldChoose(val);
|
|
297
|
+
}
|
|
282
298
|
return !isSame.value || toNumber(chooseDay2) !== day;
|
|
283
299
|
};
|
|
284
300
|
const computeOutline = () => {
|
|
285
|
-
if (!(isCurrent.value && toNumber(currentDay) === day && props.componentProps.showCurrent))
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (isSame.value)
|
|
301
|
+
if (!(isCurrent.value && toNumber(currentDay) === day && props.componentProps.showCurrent)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
if ((range || multiple || isSame.value) && disabled) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
if (range || multiple) {
|
|
308
|
+
return !shouldChoose(val);
|
|
309
|
+
}
|
|
310
|
+
if (isSame.value) {
|
|
311
|
+
return chooseDay2 !== currentDay;
|
|
312
|
+
}
|
|
289
313
|
return true;
|
|
290
314
|
};
|
|
291
315
|
const textColorOrCover = () => {
|
|
292
|
-
if (disabled)
|
|
293
|
-
|
|
294
|
-
|
|
316
|
+
if (disabled) {
|
|
317
|
+
return "";
|
|
318
|
+
}
|
|
319
|
+
if (computeOutline()) {
|
|
320
|
+
return color != null ? color : "";
|
|
321
|
+
}
|
|
322
|
+
if (dayExist()) {
|
|
323
|
+
return "";
|
|
324
|
+
}
|
|
295
325
|
return `${nDate()}-color-cover`;
|
|
296
326
|
};
|
|
297
327
|
const isCover = textColorOrCover().startsWith(nDate());
|
|
@@ -311,7 +341,9 @@ const __sfc__ = defineComponent({
|
|
|
311
341
|
};
|
|
312
342
|
const chooseDay = (day, event) => {
|
|
313
343
|
const buttonEl = event.currentTarget;
|
|
314
|
-
if (buttonEl.classList.contains(n("button--disabled")))
|
|
344
|
+
if (buttonEl.classList.contains(n("button--disabled"))) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
315
347
|
emit("choose-day", day);
|
|
316
348
|
};
|
|
317
349
|
const forwardRef = (checkType) => {
|
|
@@ -14,17 +14,17 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
import {
|
|
17
|
+
import { computed, defineComponent, reactive, ref, watch } from "vue";
|
|
18
|
+
import { toNumber } from "@varlet/shared";
|
|
18
19
|
import dayjs from "dayjs/esm/index.js";
|
|
19
|
-
import isSameOrBefore from "dayjs/esm/plugin/isSameOrBefore/index.js";
|
|
20
20
|
import isSameOrAfter from "dayjs/esm/plugin/isSameOrAfter/index.js";
|
|
21
|
-
import
|
|
22
|
-
import PanelHeader from "./panel-header.mjs";
|
|
21
|
+
import isSameOrBefore from "dayjs/esm/plugin/isSameOrBefore/index.js";
|
|
23
22
|
import VarButton from "../../button/index.mjs";
|
|
24
|
-
import { toNumber } from "@varlet/shared";
|
|
25
|
-
import { createNamespace } from "../../utils/components.mjs";
|
|
26
23
|
import { t } from "../../locale/index.mjs";
|
|
27
24
|
import { injectLocaleProvider } from "../../locale-provider/provide.mjs";
|
|
25
|
+
import { createNamespace } from "../../utils/components.mjs";
|
|
26
|
+
import { MONTH_LIST } from "../props.mjs";
|
|
27
|
+
import PanelHeader from "./panel-header.mjs";
|
|
28
28
|
dayjs.extend(isSameOrBefore);
|
|
29
29
|
dayjs.extend(isSameOrAfter);
|
|
30
30
|
const { n, classes } = createNamespace("month-picker");
|
|
@@ -154,8 +154,12 @@ const __sfc__ = defineComponent({
|
|
|
154
154
|
let isBeforeMax = true;
|
|
155
155
|
let isAfterMin = true;
|
|
156
156
|
const previewDate = `${previewYear}-${key}`;
|
|
157
|
-
if (max)
|
|
158
|
-
|
|
157
|
+
if (max) {
|
|
158
|
+
isBeforeMax = dayjs(previewDate).isSameOrBefore(dayjs(max), "month");
|
|
159
|
+
}
|
|
160
|
+
if (min) {
|
|
161
|
+
isAfterMin = dayjs(previewDate).isSameOrAfter(dayjs(min), "month");
|
|
162
|
+
}
|
|
159
163
|
return isBeforeMax && isAfterMin;
|
|
160
164
|
};
|
|
161
165
|
const shouldChoose = (val) => {
|
|
@@ -164,12 +168,16 @@ const __sfc__ = defineComponent({
|
|
|
164
168
|
componentProps: { type, range }
|
|
165
169
|
} = props;
|
|
166
170
|
if (range) {
|
|
167
|
-
if (!chooseRangeMonth.length)
|
|
171
|
+
if (!chooseRangeMonth.length) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
168
174
|
const isBeforeMax = dayjs(val).isSameOrBefore(dayjs(chooseRangeMonth[1]), "month");
|
|
169
175
|
const isAfterMin = dayjs(val).isSameOrAfter(dayjs(chooseRangeMonth[0]), "month");
|
|
170
176
|
return isBeforeMax && isAfterMin;
|
|
171
177
|
}
|
|
172
|
-
if (type === "month")
|
|
178
|
+
if (type === "month") {
|
|
179
|
+
return chooseMonths.includes(val);
|
|
180
|
+
}
|
|
173
181
|
return chooseDays.some((value) => value.includes(val));
|
|
174
182
|
};
|
|
175
183
|
const buttonProps = (key) => {
|
|
@@ -180,31 +188,55 @@ const __sfc__ = defineComponent({
|
|
|
180
188
|
} = props;
|
|
181
189
|
const val = `${previewYear}-${key}`;
|
|
182
190
|
const monthExist = () => {
|
|
183
|
-
if (range || multiple)
|
|
191
|
+
if (range || multiple) {
|
|
192
|
+
return shouldChoose(val);
|
|
193
|
+
}
|
|
184
194
|
return chooseMonth2 === key && isSameYear.value;
|
|
185
195
|
};
|
|
186
196
|
const computeDisabled = () => {
|
|
187
|
-
if (!inRange(key))
|
|
188
|
-
|
|
197
|
+
if (!inRange(key)) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (!allowedDates) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
189
203
|
return !allowedDates(val);
|
|
190
204
|
};
|
|
191
205
|
const disabled = computeDisabled();
|
|
192
206
|
const computeText = () => {
|
|
193
|
-
if (disabled)
|
|
194
|
-
|
|
207
|
+
if (disabled) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
if (range || multiple) {
|
|
211
|
+
return !shouldChoose(val);
|
|
212
|
+
}
|
|
195
213
|
return !isSameYear.value || chooseMonth2 !== key;
|
|
196
214
|
};
|
|
197
215
|
const computeOutline = () => {
|
|
198
|
-
if (!(isCurrentYear.value && currentMonth === key && props.componentProps.showCurrent))
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (isSameYear.value)
|
|
216
|
+
if (!(isCurrentYear.value && currentMonth === key && props.componentProps.showCurrent)) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if ((range || multiple || isSameYear.value) && disabled) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (range || multiple) {
|
|
223
|
+
return !shouldChoose(val);
|
|
224
|
+
}
|
|
225
|
+
if (isSameYear.value) {
|
|
226
|
+
return chooseMonth2 !== currentMonth;
|
|
227
|
+
}
|
|
202
228
|
return true;
|
|
203
229
|
};
|
|
204
230
|
const textColorOrCover = () => {
|
|
205
|
-
if (disabled)
|
|
206
|
-
|
|
207
|
-
|
|
231
|
+
if (disabled) {
|
|
232
|
+
return "";
|
|
233
|
+
}
|
|
234
|
+
if (computeOutline()) {
|
|
235
|
+
return color != null ? color : "";
|
|
236
|
+
}
|
|
237
|
+
if (monthExist()) {
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
208
240
|
return `${nDate()}-color-cover`;
|
|
209
241
|
};
|
|
210
242
|
const isCover = textColorOrCover().startsWith(nDate());
|
|
@@ -220,7 +252,9 @@ const __sfc__ = defineComponent({
|
|
|
220
252
|
};
|
|
221
253
|
const chooseMonth = (month, event) => {
|
|
222
254
|
const buttonEl = event.currentTarget;
|
|
223
|
-
if (buttonEl.classList.contains(n("button--disabled")))
|
|
255
|
+
if (buttonEl.classList.contains(n("button--disabled"))) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
224
258
|
emit("choose-month", month);
|
|
225
259
|
};
|
|
226
260
|
const checkDate = (checkType) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { computed, defineComponent, ref, watch } from "vue";
|
|
2
|
+
import { toNumber } from "@varlet/shared";
|
|
1
3
|
import VarButton from "../../button/index.mjs";
|
|
2
4
|
import VarIcon from "../../icon/index.mjs";
|
|
3
|
-
import { defineComponent, ref, computed, watch } from "vue";
|
|
4
|
-
import { toNumber } from "@varlet/shared";
|
|
5
|
-
import { createNamespace } from "../../utils/components.mjs";
|
|
6
5
|
import { t } from "../../locale/index.mjs";
|
|
7
6
|
import { injectLocaleProvider } from "../../locale-provider/provide.mjs";
|
|
7
|
+
import { createNamespace } from "../../utils/components.mjs";
|
|
8
8
|
const { n } = createNamespace("date-picker-header");
|
|
9
9
|
import { resolveComponent as _resolveComponent, createVNode as _createVNode, normalizeClass as _normalizeClass, withCtx as _withCtx, toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, Transition as _Transition, createElementVNode as _createElementVNode } from "vue";
|
|
10
10
|
function __render__(_ctx, _cache) {
|
|
@@ -104,13 +104,19 @@ const __sfc__ = defineComponent({
|
|
|
104
104
|
var _a;
|
|
105
105
|
const { date, type } = props;
|
|
106
106
|
const { previewMonth, previewYear } = date;
|
|
107
|
-
if (type === "year")
|
|
108
|
-
|
|
107
|
+
if (type === "year") {
|
|
108
|
+
return previewYear;
|
|
109
|
+
}
|
|
110
|
+
if (type === "month") {
|
|
111
|
+
return toNumber(previewYear) + forwardOrBackNum.value;
|
|
112
|
+
}
|
|
109
113
|
const monthName = (_a = (pt || t)("datePickerMonthDict")) == null ? void 0 : _a[previewMonth].name;
|
|
110
114
|
return (pt || t)("lang") === "zh-CN" ? `${previewYear} ${monthName}` : `${monthName} ${previewYear}`;
|
|
111
115
|
});
|
|
112
116
|
const checkDate = (checkType) => {
|
|
113
|
-
if (checkType === "prev" && props.disabled.left || checkType === "next" && props.disabled.right)
|
|
117
|
+
if (checkType === "prev" && props.disabled.left || checkType === "next" && props.disabled.right) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
114
120
|
emit("check-date", checkType);
|
|
115
121
|
reverse.value = checkType === "prev";
|
|
116
122
|
forwardOrBackNum.value += checkType === "prev" ? -1 : 1;
|