element-ps 2.0.32 → 2.0.35
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/index.full.js +74 -406
- package/dist/index.full.min.js +5 -5
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +5 -5
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +74 -406
- package/es/components/alert/index.mjs +2 -2
- package/es/components/alert/src/alert.mjs +33 -83
- package/es/components/alert/src/alert.mjs.map +1 -1
- package/es/components/alert/src/alert2.mjs +83 -33
- package/es/components/alert/src/alert2.mjs.map +1 -1
- package/es/components/backtop/index.mjs +2 -2
- package/es/components/backtop/src/backtop.mjs +59 -18
- package/es/components/backtop/src/backtop.mjs.map +1 -1
- package/es/components/backtop/src/backtop2.mjs +18 -59
- package/es/components/backtop/src/backtop2.mjs.map +1 -1
- package/es/components/breadcrumb/index.mjs +2 -2
- package/es/components/breadcrumb/src/breadcrumb-item.mjs +46 -11
- package/es/components/breadcrumb/src/breadcrumb-item.mjs.map +1 -1
- package/es/components/breadcrumb/src/breadcrumb-item2.mjs +11 -46
- package/es/components/breadcrumb/src/breadcrumb-item2.mjs.map +1 -1
- package/es/components/button/index.mjs +3 -3
- package/es/components/button/src/button-group.mjs +30 -5
- package/es/components/button/src/button-group.mjs.map +1 -1
- package/es/components/button/src/button-group2.mjs +5 -30
- package/es/components/button/src/button-group2.mjs.map +1 -1
- package/es/components/button/src/button.mjs +96 -48
- package/es/components/button/src/button.mjs.map +1 -1
- package/es/components/button/src/button2.mjs +48 -96
- package/es/components/button/src/button2.mjs.map +1 -1
- package/es/components/calendar/index.mjs +2 -2
- package/es/components/calendar/src/calendar.mjs +9 -188
- package/es/components/calendar/src/calendar.mjs.map +1 -1
- package/es/components/calendar/src/calendar2.mjs +188 -9
- package/es/components/calendar/src/calendar2.mjs.map +1 -1
- package/es/components/cascader/src/index.mjs +1 -1
- package/es/components/empty/index.mjs +2 -2
- package/es/components/empty/src/empty.mjs +11 -56
- package/es/components/empty/src/empty.mjs.map +1 -1
- package/es/components/empty/src/empty2.mjs +56 -11
- package/es/components/empty/src/empty2.mjs.map +1 -1
- package/es/components/form/src/form-item2.mjs +2 -8
- package/es/components/form/src/form-item2.mjs.map +1 -1
- package/es/components/image/index.mjs +2 -2
- package/es/components/image/src/image.mjs +50 -127
- package/es/components/image/src/image.mjs.map +1 -1
- package/es/components/image/src/image2.mjs +127 -50
- package/es/components/image/src/image2.mjs.map +1 -1
- package/es/components/image-viewer/index.mjs +2 -2
- package/es/components/image-viewer/src/image-viewer.mjs +210 -31
- package/es/components/image-viewer/src/image-viewer.mjs.map +1 -1
- package/es/components/image-viewer/src/image-viewer2.mjs +31 -210
- package/es/components/image-viewer/src/image-viewer2.mjs.map +1 -1
- package/es/components/index.mjs +24 -24
- package/es/components/input/index.mjs +2 -2
- package/es/components/input/src/input.mjs +295 -85
- package/es/components/input/src/input.mjs.map +1 -1
- package/es/components/input/src/input2.mjs +85 -295
- package/es/components/input/src/input2.mjs.map +1 -1
- package/es/components/link/index.mjs +2 -2
- package/es/components/link/src/link.mjs +19 -43
- package/es/components/link/src/link.mjs.map +1 -1
- package/es/components/link/src/link2.mjs +43 -19
- package/es/components/link/src/link2.mjs.map +1 -1
- package/es/components/menu/index.d.ts +6 -16
- package/es/components/menu/src/menu-item.mjs +8 -35
- package/es/components/menu/src/menu-item.mjs.map +1 -1
- package/es/components/menu/src/menu-item.vue.d.ts +10 -15
- package/es/components/menu/src/menu.mjs +2 -1
- package/es/components/menu/src/menu.mjs.map +1 -1
- package/es/components/popconfirm/index.mjs +2 -2
- package/es/components/popconfirm/src/popconfirm.mjs +20 -53
- package/es/components/popconfirm/src/popconfirm.mjs.map +1 -1
- package/es/components/popconfirm/src/popconfirm2.mjs +53 -20
- package/es/components/popconfirm/src/popconfirm2.mjs.map +1 -1
- package/es/components/popper/index.mjs +2 -2
- package/es/components/popper/src/arrow.mjs +31 -7
- package/es/components/popper/src/arrow.mjs.map +1 -1
- package/es/components/popper/src/arrow2.mjs +7 -31
- package/es/components/popper/src/arrow2.mjs.map +1 -1
- package/es/components/radio/index.mjs +6 -6
- package/es/components/radio/src/radio-button.mjs +9 -80
- package/es/components/radio/src/radio-button.mjs.map +1 -1
- package/es/components/radio/src/radio-button2.mjs +80 -9
- package/es/components/radio/src/radio-button2.mjs.map +1 -1
- package/es/components/radio/src/radio-group.mjs +37 -18
- package/es/components/radio/src/radio-group.mjs.map +1 -1
- package/es/components/radio/src/radio-group2.mjs +18 -37
- package/es/components/radio/src/radio-group2.mjs.map +1 -1
- package/es/components/radio/src/radio.mjs +74 -62
- package/es/components/radio/src/radio.mjs.map +1 -1
- package/es/components/radio/src/radio2.mjs +62 -74
- package/es/components/radio/src/radio2.mjs.map +1 -1
- package/es/components/rate/index.mjs +2 -2
- package/es/components/rate/src/rate.mjs +84 -169
- package/es/components/rate/src/rate.mjs.map +1 -1
- package/es/components/rate/src/rate2.mjs +169 -84
- package/es/components/rate/src/rate2.mjs.map +1 -1
- package/es/components/result/index.mjs +2 -2
- package/es/components/result/src/result.mjs +73 -28
- package/es/components/result/src/result.mjs.map +1 -1
- package/es/components/result/src/result2.mjs +28 -73
- package/es/components/result/src/result2.mjs.map +1 -1
- package/es/components/roving-focus-group/index.mjs +3 -3
- package/es/components/roving-focus-group/src/roving-focus-group-impl.mjs +1 -1
- package/es/components/roving-focus-group/src/roving-focus-group.mjs +27 -29
- package/es/components/roving-focus-group/src/roving-focus-group.mjs.map +1 -1
- package/es/components/roving-focus-group/src/roving-focus-group2.mjs +29 -27
- package/es/components/roving-focus-group/src/roving-focus-group2.mjs.map +1 -1
- package/es/components/roving-focus-group/src/roving-focus-item.mjs +1 -1
- package/es/components/scrollbar/index.mjs +2 -2
- package/es/components/scrollbar/src/bar.mjs +22 -35
- package/es/components/scrollbar/src/bar.mjs.map +1 -1
- package/es/components/scrollbar/src/bar2.mjs +35 -22
- package/es/components/scrollbar/src/bar2.mjs.map +1 -1
- package/es/components/scrollbar/src/scrollbar.mjs +112 -42
- package/es/components/scrollbar/src/scrollbar.mjs.map +1 -1
- package/es/components/scrollbar/src/scrollbar2.mjs +42 -112
- package/es/components/scrollbar/src/scrollbar2.mjs.map +1 -1
- package/es/components/select/src/select.mjs +1 -1
- package/es/components/skeleton/index.mjs +2 -2
- package/es/components/skeleton/src/skeleton.mjs +49 -22
- package/es/components/skeleton/src/skeleton.mjs.map +1 -1
- package/es/components/skeleton/src/skeleton2.mjs +22 -49
- package/es/components/skeleton/src/skeleton2.mjs.map +1 -1
- package/es/components/switch/index.mjs +2 -2
- package/es/components/switch/src/switch.mjs +81 -176
- package/es/components/switch/src/switch.mjs.map +1 -1
- package/es/components/switch/src/switch2.mjs +176 -81
- package/es/components/switch/src/switch2.mjs.map +1 -1
- package/es/components/tabs/index.mjs +2 -2
- package/es/components/tabs/src/tab-pane.mjs +61 -15
- package/es/components/tabs/src/tab-pane.mjs.map +1 -1
- package/es/components/tabs/src/tab-pane2.mjs +15 -61
- package/es/components/tabs/src/tab-pane2.mjs.map +1 -1
- package/es/components/tag/index.mjs +2 -2
- package/es/components/tag/src/tag.mjs +33 -81
- package/es/components/tag/src/tag.mjs.map +1 -1
- package/es/components/tag/src/tag2.mjs +81 -33
- package/es/components/tag/src/tag2.mjs.map +1 -1
- package/es/components/tooltip/src/tooltip2.mjs +1 -1
- package/es/components/tooltip-v2/index.mjs +5 -5
- package/es/components/tooltip-v2/src/content.mjs +113 -50
- package/es/components/tooltip-v2/src/content.mjs.map +1 -1
- package/es/components/tooltip-v2/src/content2.mjs +50 -113
- package/es/components/tooltip-v2/src/content2.mjs.map +1 -1
- package/es/components/tooltip-v2/src/root.mjs +17 -81
- package/es/components/tooltip-v2/src/root.mjs.map +1 -1
- package/es/components/tooltip-v2/src/root2.mjs +81 -17
- package/es/components/tooltip-v2/src/root2.mjs.map +1 -1
- package/es/components/tooltip-v2/src/tooltip.mjs +21 -74
- package/es/components/tooltip-v2/src/tooltip.mjs.map +1 -1
- package/es/components/tooltip-v2/src/tooltip2.mjs +74 -21
- package/es/components/tooltip-v2/src/tooltip2.mjs.map +1 -1
- package/es/components/tooltip-v2/src/trigger.mjs +11 -89
- package/es/components/tooltip-v2/src/trigger.mjs.map +1 -1
- package/es/components/tooltip-v2/src/trigger2.mjs +89 -11
- package/es/components/tooltip-v2/src/trigger2.mjs.map +1 -1
- package/es/components/upload/index.mjs +1 -1
- package/es/components/upload/src/upload-list.mjs +155 -26
- package/es/components/upload/src/upload-list.mjs.map +1 -1
- package/es/components/upload/src/upload-list2.mjs +26 -155
- package/es/components/upload/src/upload-list2.mjs.map +1 -1
- package/es/components/upload/src/upload2.mjs +1 -1
- package/es/index.mjs +24 -24
- package/lib/components/alert/index.js +2 -2
- package/lib/components/alert/src/alert.js +33 -82
- package/lib/components/alert/src/alert.js.map +1 -1
- package/lib/components/alert/src/alert2.js +82 -33
- package/lib/components/alert/src/alert2.js.map +1 -1
- package/lib/components/backtop/index.js +2 -2
- package/lib/components/backtop/src/backtop.js +59 -18
- package/lib/components/backtop/src/backtop.js.map +1 -1
- package/lib/components/backtop/src/backtop2.js +18 -59
- package/lib/components/backtop/src/backtop2.js.map +1 -1
- package/lib/components/breadcrumb/index.js +2 -2
- package/lib/components/breadcrumb/src/breadcrumb-item.js +46 -11
- package/lib/components/breadcrumb/src/breadcrumb-item.js.map +1 -1
- package/lib/components/breadcrumb/src/breadcrumb-item2.js +11 -46
- package/lib/components/breadcrumb/src/breadcrumb-item2.js.map +1 -1
- package/lib/components/button/index.js +3 -3
- package/lib/components/button/src/button-group.js +30 -5
- package/lib/components/button/src/button-group.js.map +1 -1
- package/lib/components/button/src/button-group2.js +5 -30
- package/lib/components/button/src/button-group2.js.map +1 -1
- package/lib/components/button/src/button.js +96 -50
- package/lib/components/button/src/button.js.map +1 -1
- package/lib/components/button/src/button2.js +50 -96
- package/lib/components/button/src/button2.js.map +1 -1
- package/lib/components/calendar/index.js +2 -2
- package/lib/components/calendar/src/calendar.js +9 -192
- package/lib/components/calendar/src/calendar.js.map +1 -1
- package/lib/components/calendar/src/calendar2.js +192 -9
- package/lib/components/calendar/src/calendar2.js.map +1 -1
- package/lib/components/cascader/src/index.js +1 -1
- package/lib/components/empty/index.js +2 -2
- package/lib/components/empty/src/empty.js +11 -56
- package/lib/components/empty/src/empty.js.map +1 -1
- package/lib/components/empty/src/empty2.js +56 -11
- package/lib/components/empty/src/empty2.js.map +1 -1
- package/lib/components/form/src/form-item2.js +1 -7
- package/lib/components/form/src/form-item2.js.map +1 -1
- package/lib/components/image/index.js +2 -2
- package/lib/components/image/src/image.js +50 -127
- package/lib/components/image/src/image.js.map +1 -1
- package/lib/components/image/src/image2.js +127 -50
- package/lib/components/image/src/image2.js.map +1 -1
- package/lib/components/image-viewer/index.js +2 -2
- package/lib/components/image-viewer/src/image-viewer.js +210 -31
- package/lib/components/image-viewer/src/image-viewer.js.map +1 -1
- package/lib/components/image-viewer/src/image-viewer2.js +31 -210
- package/lib/components/image-viewer/src/image-viewer2.js.map +1 -1
- package/lib/components/index.js +24 -24
- package/lib/components/input/index.js +2 -2
- package/lib/components/input/src/input.js +294 -84
- package/lib/components/input/src/input.js.map +1 -1
- package/lib/components/input/src/input2.js +84 -294
- package/lib/components/input/src/input2.js.map +1 -1
- package/lib/components/link/index.js +2 -2
- package/lib/components/link/src/link.js +19 -43
- package/lib/components/link/src/link.js.map +1 -1
- package/lib/components/link/src/link2.js +43 -19
- package/lib/components/link/src/link2.js.map +1 -1
- package/lib/components/menu/index.d.ts +6 -16
- package/lib/components/menu/src/menu-item.js +6 -33
- package/lib/components/menu/src/menu-item.js.map +1 -1
- package/lib/components/menu/src/menu-item.vue.d.ts +10 -15
- package/lib/components/menu/src/menu.js +2 -1
- package/lib/components/menu/src/menu.js.map +1 -1
- package/lib/components/popconfirm/index.js +2 -2
- package/lib/components/popconfirm/src/popconfirm.js +20 -53
- package/lib/components/popconfirm/src/popconfirm.js.map +1 -1
- package/lib/components/popconfirm/src/popconfirm2.js +53 -20
- package/lib/components/popconfirm/src/popconfirm2.js.map +1 -1
- package/lib/components/popper/index.js +2 -2
- package/lib/components/popper/src/arrow.js +31 -7
- package/lib/components/popper/src/arrow.js.map +1 -1
- package/lib/components/popper/src/arrow2.js +7 -31
- package/lib/components/popper/src/arrow2.js.map +1 -1
- package/lib/components/radio/index.js +6 -6
- package/lib/components/radio/src/radio-button.js +9 -80
- package/lib/components/radio/src/radio-button.js.map +1 -1
- package/lib/components/radio/src/radio-button2.js +80 -9
- package/lib/components/radio/src/radio-button2.js.map +1 -1
- package/lib/components/radio/src/radio-group.js +37 -18
- package/lib/components/radio/src/radio-group.js.map +1 -1
- package/lib/components/radio/src/radio-group2.js +18 -37
- package/lib/components/radio/src/radio-group2.js.map +1 -1
- package/lib/components/radio/src/radio.js +73 -64
- package/lib/components/radio/src/radio.js.map +1 -1
- package/lib/components/radio/src/radio2.js +64 -73
- package/lib/components/radio/src/radio2.js.map +1 -1
- package/lib/components/rate/index.js +2 -2
- package/lib/components/rate/src/rate.js +84 -169
- package/lib/components/rate/src/rate.js.map +1 -1
- package/lib/components/rate/src/rate2.js +169 -84
- package/lib/components/rate/src/rate2.js.map +1 -1
- package/lib/components/result/index.js +2 -2
- package/lib/components/result/src/result.js +73 -30
- package/lib/components/result/src/result.js.map +1 -1
- package/lib/components/result/src/result2.js +30 -73
- package/lib/components/result/src/result2.js.map +1 -1
- package/lib/components/roving-focus-group/index.js +2 -2
- package/lib/components/roving-focus-group/src/roving-focus-group-impl.js +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-group.js +27 -33
- package/lib/components/roving-focus-group/src/roving-focus-group.js.map +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-group2.js +33 -27
- package/lib/components/roving-focus-group/src/roving-focus-group2.js.map +1 -1
- package/lib/components/roving-focus-group/src/roving-focus-item.js +1 -1
- package/lib/components/scrollbar/index.js +2 -2
- package/lib/components/scrollbar/src/bar.js +22 -35
- package/lib/components/scrollbar/src/bar.js.map +1 -1
- package/lib/components/scrollbar/src/bar2.js +35 -22
- package/lib/components/scrollbar/src/bar2.js.map +1 -1
- package/lib/components/scrollbar/src/scrollbar.js +112 -42
- package/lib/components/scrollbar/src/scrollbar.js.map +1 -1
- package/lib/components/scrollbar/src/scrollbar2.js +42 -112
- package/lib/components/scrollbar/src/scrollbar2.js.map +1 -1
- package/lib/components/select/src/select.js +1 -1
- package/lib/components/skeleton/index.js +2 -2
- package/lib/components/skeleton/src/skeleton.js +49 -22
- package/lib/components/skeleton/src/skeleton.js.map +1 -1
- package/lib/components/skeleton/src/skeleton2.js +22 -49
- package/lib/components/skeleton/src/skeleton2.js.map +1 -1
- package/lib/components/switch/index.js +2 -2
- package/lib/components/switch/src/switch.js +81 -176
- package/lib/components/switch/src/switch.js.map +1 -1
- package/lib/components/switch/src/switch2.js +176 -81
- package/lib/components/switch/src/switch2.js.map +1 -1
- package/lib/components/tabs/index.js +2 -2
- package/lib/components/tabs/src/tab-pane.js +61 -15
- package/lib/components/tabs/src/tab-pane.js.map +1 -1
- package/lib/components/tabs/src/tab-pane2.js +15 -61
- package/lib/components/tabs/src/tab-pane2.js.map +1 -1
- package/lib/components/tag/index.js +2 -2
- package/lib/components/tag/src/tag.js +34 -81
- package/lib/components/tag/src/tag.js.map +1 -1
- package/lib/components/tag/src/tag2.js +81 -34
- package/lib/components/tag/src/tag2.js.map +1 -1
- package/lib/components/tooltip/src/tooltip2.js +1 -1
- package/lib/components/tooltip-v2/index.js +5 -5
- package/lib/components/tooltip-v2/src/content.js +113 -50
- package/lib/components/tooltip-v2/src/content.js.map +1 -1
- package/lib/components/tooltip-v2/src/content2.js +50 -113
- package/lib/components/tooltip-v2/src/content2.js.map +1 -1
- package/lib/components/tooltip-v2/src/root.js +17 -81
- package/lib/components/tooltip-v2/src/root.js.map +1 -1
- package/lib/components/tooltip-v2/src/root2.js +81 -17
- package/lib/components/tooltip-v2/src/root2.js.map +1 -1
- package/lib/components/tooltip-v2/src/tooltip.js +21 -74
- package/lib/components/tooltip-v2/src/tooltip.js.map +1 -1
- package/lib/components/tooltip-v2/src/tooltip2.js +74 -21
- package/lib/components/tooltip-v2/src/tooltip2.js.map +1 -1
- package/lib/components/tooltip-v2/src/trigger.js +11 -89
- package/lib/components/tooltip-v2/src/trigger.js.map +1 -1
- package/lib/components/tooltip-v2/src/trigger2.js +89 -11
- package/lib/components/tooltip-v2/src/trigger2.js.map +1 -1
- package/lib/components/upload/index.js +1 -1
- package/lib/components/upload/src/upload-list.js +155 -27
- package/lib/components/upload/src/upload-list.js.map +1 -1
- package/lib/components/upload/src/upload-list2.js +27 -155
- package/lib/components/upload/src/upload-list2.js.map +1 -1
- package/lib/components/upload/src/upload2.js +1 -1
- package/lib/index.js +24 -24
- package/package.json +1 -1
- package/web-types.json +1 -1
|
@@ -1,194 +1,15 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, toDisplayString, createVNode, withCtx, createTextVNode, createCommentVNode, createSlots, normalizeProps, guardReactiveProps, Fragment, renderList, createBlock } from 'vue';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { PsButtonGroup, PsButton } from '../../button/index.mjs';
|
|
4
|
-
import '../../../hooks/index.mjs';
|
|
5
1
|
import '../../../utils/index.mjs';
|
|
6
|
-
import
|
|
7
|
-
import { calendarProps } from './calendar2.mjs';
|
|
8
|
-
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
9
|
-
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
10
|
-
import { useLocale } from '../../../hooks/use-locale/index.mjs';
|
|
11
|
-
import { debugWarn } from '../../../utils/error.mjs';
|
|
2
|
+
import { buildProps, definePropType } from '../../../utils/vue/props.mjs';
|
|
12
3
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const props = __props;
|
|
21
|
-
const COMPONENT_NAME = "PsCalendar";
|
|
22
|
-
const ns = useNamespace("calendar");
|
|
23
|
-
const { t, lang } = useLocale();
|
|
24
|
-
const selectedDay = ref();
|
|
25
|
-
const now = dayjs().locale(lang.value);
|
|
26
|
-
const i18nDate = computed(() => {
|
|
27
|
-
const pickedMonth = `el.datepicker.month${date.value.format("M")}`;
|
|
28
|
-
return `${date.value.year()} ${t("el.datepicker.year")} ${t(pickedMonth)}`;
|
|
29
|
-
});
|
|
30
|
-
const realSelectedDay = computed({
|
|
31
|
-
get() {
|
|
32
|
-
if (!props.modelValue)
|
|
33
|
-
return selectedDay.value;
|
|
34
|
-
return date.value;
|
|
35
|
-
},
|
|
36
|
-
set(val) {
|
|
37
|
-
if (!val)
|
|
38
|
-
return;
|
|
39
|
-
selectedDay.value = val;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
const date = computed(() => {
|
|
43
|
-
if (!props.modelValue) {
|
|
44
|
-
if (realSelectedDay.value) {
|
|
45
|
-
return realSelectedDay.value;
|
|
46
|
-
} else if (validatedRange.value.length) {
|
|
47
|
-
return validatedRange.value[0][0];
|
|
48
|
-
}
|
|
49
|
-
return now;
|
|
50
|
-
} else {
|
|
51
|
-
return dayjs(props.modelValue).locale(lang.value);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const calculateValidatedDateRange = (startDayjs, endDayjs) => {
|
|
55
|
-
const firstDay = startDayjs.startOf("week");
|
|
56
|
-
const lastDay = endDayjs.endOf("week");
|
|
57
|
-
const firstMonth = firstDay.get("month");
|
|
58
|
-
const lastMonth = lastDay.get("month");
|
|
59
|
-
if (firstMonth === lastMonth) {
|
|
60
|
-
return [[firstDay, lastDay]];
|
|
61
|
-
} else if (firstMonth + 1 === lastMonth) {
|
|
62
|
-
const firstMonthLastDay = firstDay.endOf("month");
|
|
63
|
-
const lastMonthFirstDay = lastDay.startOf("month");
|
|
64
|
-
const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, "week");
|
|
65
|
-
const lastMonthStartDay = isSameWeek ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
66
|
-
return [
|
|
67
|
-
[firstDay, firstMonthLastDay],
|
|
68
|
-
[lastMonthStartDay.startOf("week"), lastDay]
|
|
69
|
-
];
|
|
70
|
-
} else if (firstMonth + 2 === lastMonth || (firstMonth + 1) % 11 === lastMonth) {
|
|
71
|
-
const firstMonthLastDay = firstDay.endOf("month");
|
|
72
|
-
const secondMonthFirstDay = firstDay.add(1, "month").startOf("month");
|
|
73
|
-
const secondMonthStartDay = firstMonthLastDay.isSame(secondMonthFirstDay, "week") ? secondMonthFirstDay.add(1, "week") : secondMonthFirstDay;
|
|
74
|
-
const secondMonthLastDay = secondMonthStartDay.endOf("month");
|
|
75
|
-
const lastMonthFirstDay = lastDay.startOf("month");
|
|
76
|
-
const lastMonthStartDay = secondMonthLastDay.isSame(lastMonthFirstDay, "week") ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
77
|
-
return [
|
|
78
|
-
[firstDay, firstMonthLastDay],
|
|
79
|
-
[secondMonthStartDay.startOf("week"), secondMonthLastDay],
|
|
80
|
-
[lastMonthStartDay.startOf("week"), lastDay]
|
|
81
|
-
];
|
|
82
|
-
} else {
|
|
83
|
-
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const validatedRange = computed(() => {
|
|
88
|
-
if (!props.range)
|
|
89
|
-
return [];
|
|
90
|
-
const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value));
|
|
91
|
-
const [startDayjs, endDayjs] = rangeArrDayjs;
|
|
92
|
-
if (startDayjs.isAfter(endDayjs)) {
|
|
93
|
-
debugWarn(COMPONENT_NAME, "end time should be greater than start time");
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
if (startDayjs.isSame(endDayjs, "month")) {
|
|
97
|
-
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
98
|
-
} else {
|
|
99
|
-
if (startDayjs.add(1, "month").month() !== endDayjs.month()) {
|
|
100
|
-
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
expose({
|
|
107
|
-
selectedDay: realSelectedDay,
|
|
108
|
-
calculateValidatedDateRange
|
|
109
|
-
});
|
|
110
|
-
return (_ctx, _cache) => {
|
|
111
|
-
return openBlock(), createElementBlock("div", {
|
|
112
|
-
class: normalizeClass(unref(ns).b())
|
|
113
|
-
}, [
|
|
114
|
-
createElementVNode("div", {
|
|
115
|
-
class: normalizeClass(unref(ns).e("header"))
|
|
116
|
-
}, [
|
|
117
|
-
renderSlot(_ctx.$slots, "header", { date: unref(i18nDate) }, () => [
|
|
118
|
-
createElementVNode("div", {
|
|
119
|
-
class: normalizeClass(unref(ns).e("title"))
|
|
120
|
-
}, toDisplayString(unref(i18nDate)), 3),
|
|
121
|
-
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
122
|
-
key: 0,
|
|
123
|
-
class: normalizeClass(unref(ns).e("button-group"))
|
|
124
|
-
}, [
|
|
125
|
-
createVNode(unref(PsButtonGroup), null, {
|
|
126
|
-
default: withCtx(() => [
|
|
127
|
-
createVNode(unref(PsButton), { size: "small" }, {
|
|
128
|
-
default: withCtx(() => [
|
|
129
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.prevMonth")), 1)
|
|
130
|
-
]),
|
|
131
|
-
_: 1
|
|
132
|
-
}),
|
|
133
|
-
createVNode(unref(PsButton), { size: "small" }, {
|
|
134
|
-
default: withCtx(() => [
|
|
135
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.today")), 1)
|
|
136
|
-
]),
|
|
137
|
-
_: 1
|
|
138
|
-
}),
|
|
139
|
-
createVNode(unref(PsButton), { size: "small" }, {
|
|
140
|
-
default: withCtx(() => [
|
|
141
|
-
createTextVNode(toDisplayString(unref(t)("el.datepicker.nextMonth")), 1)
|
|
142
|
-
]),
|
|
143
|
-
_: 1
|
|
144
|
-
})
|
|
145
|
-
]),
|
|
146
|
-
_: 1
|
|
147
|
-
})
|
|
148
|
-
], 2)) : createCommentVNode("v-if", true)
|
|
149
|
-
])
|
|
150
|
-
], 2),
|
|
151
|
-
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
152
|
-
key: 0,
|
|
153
|
-
class: normalizeClass(unref(ns).e("body"))
|
|
154
|
-
}, [
|
|
155
|
-
createVNode(DateTable, {
|
|
156
|
-
date: unref(date),
|
|
157
|
-
"selected-day": unref(realSelectedDay)
|
|
158
|
-
}, createSlots({ _: 2 }, [
|
|
159
|
-
_ctx.$slots.dateCell ? {
|
|
160
|
-
name: "dateCell",
|
|
161
|
-
fn: withCtx((data) => [
|
|
162
|
-
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
163
|
-
])
|
|
164
|
-
} : void 0
|
|
165
|
-
]), 1032, ["date", "selected-day"])
|
|
166
|
-
], 2)) : (openBlock(), createElementBlock("div", {
|
|
167
|
-
key: 1,
|
|
168
|
-
class: normalizeClass(unref(ns).e("body"))
|
|
169
|
-
}, [
|
|
170
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(validatedRange), (range_, index) => {
|
|
171
|
-
return openBlock(), createBlock(DateTable, {
|
|
172
|
-
key: index,
|
|
173
|
-
date: range_[0],
|
|
174
|
-
"selected-day": unref(realSelectedDay),
|
|
175
|
-
range: range_,
|
|
176
|
-
"hide-header": index !== 0
|
|
177
|
-
}, createSlots({ _: 2 }, [
|
|
178
|
-
_ctx.$slots.dateCell ? {
|
|
179
|
-
name: "dateCell",
|
|
180
|
-
fn: withCtx((data) => [
|
|
181
|
-
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
182
|
-
])
|
|
183
|
-
} : void 0
|
|
184
|
-
]), 1032, ["date", "selected-day", "range", "hide-header"]);
|
|
185
|
-
}), 128))
|
|
186
|
-
], 2))
|
|
187
|
-
], 2);
|
|
188
|
-
};
|
|
4
|
+
const calendarProps = buildProps({
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: Date
|
|
7
|
+
},
|
|
8
|
+
range: {
|
|
9
|
+
type: definePropType(Array),
|
|
10
|
+
validator: (range) => Array.isArray(range) && range.length === 2 && range.every((item) => item instanceof Date)
|
|
189
11
|
}
|
|
190
12
|
});
|
|
191
|
-
var Calendar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/calendar/src/calendar.vue"]]);
|
|
192
13
|
|
|
193
|
-
export {
|
|
14
|
+
export { calendarProps };
|
|
194
15
|
//# sourceMappingURL=calendar.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div :class=\"ns.e('header')\">\n <slot name=\"header\" :date=\"i18nDate\">\n <div :class=\"ns.e('title')\">{{ i18nDate }}</div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('button-group')\">\n <ps-button-group>\n <ps-button size=\"small\">\n {{ t('el.datepicker.prevMonth') }}\n </ps-button>\n <ps-button size=\"small\">\n {{ t('el.datepicker.today') }}\n </ps-button>\n <ps-button size=\"small\">\n {{ t('el.datepicker.nextMonth') }}\n </ps-button>\n </ps-button-group>\n </div>\n </slot>\n </div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('body')\">\n <date-table :date=\"date\" :selected-day=\"realSelectedDay\">\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n <div v-else :class=\"ns.e('body')\">\n <date-table\n v-for=\"(range_, index) in validatedRange\"\n :key=\"index\"\n :date=\"range_[0]\"\n :selected-day=\"realSelectedDay\"\n :range=\"range_\"\n :hide-header=\"index !== 0\"\n >\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, ref } from 'vue'\nimport dayjs from 'dayjs'\nimport { PsButton, PsButtonGroup } from '@element-ps/components/button'\nimport { useLocale, useNamespace } from '@element-ps/hooks'\nimport { debugWarn } from '@element-ps/utils'\nimport DateTable from './date-table.vue'\nimport { calendarProps } from './calendar'\n\nimport type { ComputedRef } from 'vue'\nimport type { Dayjs } from 'dayjs'\n\nconst COMPONENT_NAME = 'PsCalendar'\n\ndefineOptions({\n name: 'PsCalendar',\n})\n\nconst props = defineProps(calendarProps)\n\nconst ns = useNamespace('calendar')\n\nconst { t, lang } = useLocale()\nconst selectedDay = ref<Dayjs>()\nconst now = dayjs().locale(lang.value)\n\nconst i18nDate = computed(() => {\n const pickedMonth = `el.datepicker.month${date.value.format('M')}`\n return `${date.value.year()} ${t('el.datepicker.year')} ${t(pickedMonth)}`\n})\n\nconst realSelectedDay = computed<Dayjs | undefined>({\n get() {\n if (!props.modelValue) return selectedDay.value\n return date.value\n },\n set(val) {\n if (!val) return\n selectedDay.value = val\n },\n})\n\nconst date: ComputedRef<Dayjs> = computed(() => {\n if (!props.modelValue) {\n if (realSelectedDay.value) {\n return realSelectedDay.value\n } else if (validatedRange.value.length) {\n return validatedRange.value[0][0]\n }\n return now\n } else {\n return dayjs(props.modelValue).locale(lang.value)\n }\n})\n\n// https://github.com/element-ps/element-ps/issues/3155\n// Calculate the validate date range according to the start and end dates\nconst calculateValidatedDateRange = (\n startDayjs: Dayjs,\n endDayjs: Dayjs\n): [Dayjs, Dayjs][] => {\n const firstDay = startDayjs.startOf('week')\n const lastDay = endDayjs.endOf('week')\n const firstMonth = firstDay.get('month')\n const lastMonth = lastDay.get('month')\n\n // Current mouth\n if (firstMonth === lastMonth) {\n return [[firstDay, lastDay]]\n }\n // Two adjacent months\n else if (firstMonth + 1 === lastMonth) {\n const firstMonthLastDay = firstDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the first month and the first day of the last month is in the same week\n const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, 'week')\n const lastMonthStartDay = isSameWeek\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Three consecutive months (compatible: 2021-01-30 to 2021-02-28)\n else if (\n firstMonth + 2 === lastMonth ||\n (firstMonth + 1) % 11 === lastMonth\n ) {\n const firstMonthLastDay = firstDay.endOf('month')\n const secondMonthFirstDay = firstDay.add(1, 'month').startOf('month')\n\n // Whether the last day of the first month and the second month is in the same week\n const secondMonthStartDay = firstMonthLastDay.isSame(\n secondMonthFirstDay,\n 'week'\n )\n ? secondMonthFirstDay.add(1, 'week')\n : secondMonthFirstDay\n\n const secondMonthLastDay = secondMonthStartDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the second month and the last day of the last month is in the same week\n const lastMonthStartDay = secondMonthLastDay.isSame(\n lastMonthFirstDay,\n 'week'\n )\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [secondMonthStartDay.startOf('week'), secondMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Other cases\n else {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n}\n\n// if range is valid, we get a two-digit array\nconst validatedRange = computed(() => {\n if (!props.range) return []\n const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value))\n const [startDayjs, endDayjs] = rangeArrDayjs\n if (startDayjs.isAfter(endDayjs)) {\n debugWarn(COMPONENT_NAME, 'end time should be greater than start time')\n return []\n }\n if (startDayjs.isSame(endDayjs, 'month')) {\n // same month\n return calculateValidatedDateRange(startDayjs, endDayjs)\n } else {\n // two months\n if (startDayjs.add(1, 'month').month() !== endDayjs.month()) {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n return calculateValidatedDateRange(startDayjs, endDayjs)\n }\n})\n\ndefineExpose({\n /** @description currently selected date */\n selectedDay: realSelectedDay,\n /** @description Calculate the validate date range according to the start and end dates */\n calculateValidatedDateRange,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAwDA,IAAA,MAAA,cAAA,GAAA,YAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAA,aAAA,UAAA,CAAA,CAAA;AAEA,IAAA,MAAA,EAAA,CAAA,EAAA,IAAA,EAAA,GAAA,SAAA,EAAA,CAAA;AACA,IAAA,MAAA,cAAA,GAAA,EAAA,CAAA;AACA,IAAA,MAAA,GAAA,GAAA,KAAA,EAAA,CAAA,MAAA,CAAA,KAAA,KAAA,CAAA,CAAA;AAEA,IAAA,MAAA,QAAA,GAAA,SAAA,MAAA;AACA,MAAA,MAAA,WAAA,GAAA,CAAA,mBAAA,EAAA,IAAA,CAAA,KAAA,CAAA,OAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AACA,MAAA,OAAA,CAAA,EAAA,KAAA,KAAA,CAAA,IAAA,MAAA,CAAA,CAAA,oBAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,CAAA;AAAA,KACA,CAAA,CAAA;AAEA,IAAA,MAAA,kBAAA,QAAA,CAAA;AAAA,MACA,GAAA,GAAA;AACA,QAAA,IAAA,CAAA,KAAA,CAAA,UAAA;AAAA,UAAA,OAAA,WAAA,CAAA,KAAA,CAAA;AACA,QAAA,OAAA,IAAA,CAAA,KAAA,CAAA;AAAA,OACA;AAAA,MACA,IAAA,GAAA,EAAA;AACA,QAAA,IAAA,CA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file":"calendar.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-ps/utils'\nimport { UPDATE_MODEL_EVENT } from '@element-ps/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type Calendar from './calendar.vue'\n\nexport type CalendarDateType =\n | 'prev-month'\n | 'next-month'\n | 'prev-year'\n | 'next-year'\n | 'today'\n\nexport const calendarProps = buildProps({\n modelValue: {\n type: Date,\n },\n range: {\n type: definePropType<[Date, Date]>(Array),\n validator: (range: unknown): range is [Date, Date] =>\n Array.isArray(range) &&\n range.length === 2 &&\n range.every((item) => item instanceof Date),\n },\n} as const)\nexport type CalendarProps = ExtractPropTypes<typeof calendarProps>\n\nexport type CalendarInstance = InstanceType<typeof Calendar>\n"],"names":[],"mappings":";;;AACY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,IAAI;AACd,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,SAAS,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,YAAY,IAAI,CAAC;AACnH,GAAG;AACH,CAAC;;;;"}
|
|
@@ -1,15 +1,194 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, toDisplayString, createVNode, withCtx, createTextVNode, createCommentVNode, createSlots, normalizeProps, guardReactiveProps, Fragment, renderList, createBlock } from 'vue';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { PsButtonGroup, PsButton } from '../../button/index.mjs';
|
|
4
|
+
import '../../../hooks/index.mjs';
|
|
1
5
|
import '../../../utils/index.mjs';
|
|
2
|
-
import
|
|
6
|
+
import DateTable from './date-table.mjs';
|
|
7
|
+
import { calendarProps } from './calendar.mjs';
|
|
8
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
9
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
10
|
+
import { useLocale } from '../../../hooks/use-locale/index.mjs';
|
|
11
|
+
import { debugWarn } from '../../../utils/error.mjs';
|
|
3
12
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const __default__ = {
|
|
14
|
+
name: "PsCalendar"
|
|
15
|
+
};
|
|
16
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17
|
+
...__default__,
|
|
18
|
+
props: calendarProps,
|
|
19
|
+
setup(__props, { expose }) {
|
|
20
|
+
const props = __props;
|
|
21
|
+
const COMPONENT_NAME = "PsCalendar";
|
|
22
|
+
const ns = useNamespace("calendar");
|
|
23
|
+
const { t, lang } = useLocale();
|
|
24
|
+
const selectedDay = ref();
|
|
25
|
+
const now = dayjs().locale(lang.value);
|
|
26
|
+
const i18nDate = computed(() => {
|
|
27
|
+
const pickedMonth = `el.datepicker.month${date.value.format("M")}`;
|
|
28
|
+
return `${date.value.year()} ${t("el.datepicker.year")} ${t(pickedMonth)}`;
|
|
29
|
+
});
|
|
30
|
+
const realSelectedDay = computed({
|
|
31
|
+
get() {
|
|
32
|
+
if (!props.modelValue)
|
|
33
|
+
return selectedDay.value;
|
|
34
|
+
return date.value;
|
|
35
|
+
},
|
|
36
|
+
set(val) {
|
|
37
|
+
if (!val)
|
|
38
|
+
return;
|
|
39
|
+
selectedDay.value = val;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const date = computed(() => {
|
|
43
|
+
if (!props.modelValue) {
|
|
44
|
+
if (realSelectedDay.value) {
|
|
45
|
+
return realSelectedDay.value;
|
|
46
|
+
} else if (validatedRange.value.length) {
|
|
47
|
+
return validatedRange.value[0][0];
|
|
48
|
+
}
|
|
49
|
+
return now;
|
|
50
|
+
} else {
|
|
51
|
+
return dayjs(props.modelValue).locale(lang.value);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const calculateValidatedDateRange = (startDayjs, endDayjs) => {
|
|
55
|
+
const firstDay = startDayjs.startOf("week");
|
|
56
|
+
const lastDay = endDayjs.endOf("week");
|
|
57
|
+
const firstMonth = firstDay.get("month");
|
|
58
|
+
const lastMonth = lastDay.get("month");
|
|
59
|
+
if (firstMonth === lastMonth) {
|
|
60
|
+
return [[firstDay, lastDay]];
|
|
61
|
+
} else if (firstMonth + 1 === lastMonth) {
|
|
62
|
+
const firstMonthLastDay = firstDay.endOf("month");
|
|
63
|
+
const lastMonthFirstDay = lastDay.startOf("month");
|
|
64
|
+
const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, "week");
|
|
65
|
+
const lastMonthStartDay = isSameWeek ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
66
|
+
return [
|
|
67
|
+
[firstDay, firstMonthLastDay],
|
|
68
|
+
[lastMonthStartDay.startOf("week"), lastDay]
|
|
69
|
+
];
|
|
70
|
+
} else if (firstMonth + 2 === lastMonth || (firstMonth + 1) % 11 === lastMonth) {
|
|
71
|
+
const firstMonthLastDay = firstDay.endOf("month");
|
|
72
|
+
const secondMonthFirstDay = firstDay.add(1, "month").startOf("month");
|
|
73
|
+
const secondMonthStartDay = firstMonthLastDay.isSame(secondMonthFirstDay, "week") ? secondMonthFirstDay.add(1, "week") : secondMonthFirstDay;
|
|
74
|
+
const secondMonthLastDay = secondMonthStartDay.endOf("month");
|
|
75
|
+
const lastMonthFirstDay = lastDay.startOf("month");
|
|
76
|
+
const lastMonthStartDay = secondMonthLastDay.isSame(lastMonthFirstDay, "week") ? lastMonthFirstDay.add(1, "week") : lastMonthFirstDay;
|
|
77
|
+
return [
|
|
78
|
+
[firstDay, firstMonthLastDay],
|
|
79
|
+
[secondMonthStartDay.startOf("week"), secondMonthLastDay],
|
|
80
|
+
[lastMonthStartDay.startOf("week"), lastDay]
|
|
81
|
+
];
|
|
82
|
+
} else {
|
|
83
|
+
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const validatedRange = computed(() => {
|
|
88
|
+
if (!props.range)
|
|
89
|
+
return [];
|
|
90
|
+
const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value));
|
|
91
|
+
const [startDayjs, endDayjs] = rangeArrDayjs;
|
|
92
|
+
if (startDayjs.isAfter(endDayjs)) {
|
|
93
|
+
debugWarn(COMPONENT_NAME, "end time should be greater than start time");
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
if (startDayjs.isSame(endDayjs, "month")) {
|
|
97
|
+
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
98
|
+
} else {
|
|
99
|
+
if (startDayjs.add(1, "month").month() !== endDayjs.month()) {
|
|
100
|
+
debugWarn(COMPONENT_NAME, "start time and end time interval must not exceed two months");
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
return calculateValidatedDateRange(startDayjs, endDayjs);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
expose({
|
|
107
|
+
selectedDay: realSelectedDay,
|
|
108
|
+
calculateValidatedDateRange
|
|
109
|
+
});
|
|
110
|
+
return (_ctx, _cache) => {
|
|
111
|
+
return openBlock(), createElementBlock("div", {
|
|
112
|
+
class: normalizeClass(unref(ns).b())
|
|
113
|
+
}, [
|
|
114
|
+
createElementVNode("div", {
|
|
115
|
+
class: normalizeClass(unref(ns).e("header"))
|
|
116
|
+
}, [
|
|
117
|
+
renderSlot(_ctx.$slots, "header", { date: unref(i18nDate) }, () => [
|
|
118
|
+
createElementVNode("div", {
|
|
119
|
+
class: normalizeClass(unref(ns).e("title"))
|
|
120
|
+
}, toDisplayString(unref(i18nDate)), 3),
|
|
121
|
+
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
122
|
+
key: 0,
|
|
123
|
+
class: normalizeClass(unref(ns).e("button-group"))
|
|
124
|
+
}, [
|
|
125
|
+
createVNode(unref(PsButtonGroup), null, {
|
|
126
|
+
default: withCtx(() => [
|
|
127
|
+
createVNode(unref(PsButton), { size: "small" }, {
|
|
128
|
+
default: withCtx(() => [
|
|
129
|
+
createTextVNode(toDisplayString(unref(t)("el.datepicker.prevMonth")), 1)
|
|
130
|
+
]),
|
|
131
|
+
_: 1
|
|
132
|
+
}),
|
|
133
|
+
createVNode(unref(PsButton), { size: "small" }, {
|
|
134
|
+
default: withCtx(() => [
|
|
135
|
+
createTextVNode(toDisplayString(unref(t)("el.datepicker.today")), 1)
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
}),
|
|
139
|
+
createVNode(unref(PsButton), { size: "small" }, {
|
|
140
|
+
default: withCtx(() => [
|
|
141
|
+
createTextVNode(toDisplayString(unref(t)("el.datepicker.nextMonth")), 1)
|
|
142
|
+
]),
|
|
143
|
+
_: 1
|
|
144
|
+
})
|
|
145
|
+
]),
|
|
146
|
+
_: 1
|
|
147
|
+
})
|
|
148
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
149
|
+
])
|
|
150
|
+
], 2),
|
|
151
|
+
unref(validatedRange).length === 0 ? (openBlock(), createElementBlock("div", {
|
|
152
|
+
key: 0,
|
|
153
|
+
class: normalizeClass(unref(ns).e("body"))
|
|
154
|
+
}, [
|
|
155
|
+
createVNode(DateTable, {
|
|
156
|
+
date: unref(date),
|
|
157
|
+
"selected-day": unref(realSelectedDay)
|
|
158
|
+
}, createSlots({ _: 2 }, [
|
|
159
|
+
_ctx.$slots.dateCell ? {
|
|
160
|
+
name: "dateCell",
|
|
161
|
+
fn: withCtx((data) => [
|
|
162
|
+
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
163
|
+
])
|
|
164
|
+
} : void 0
|
|
165
|
+
]), 1032, ["date", "selected-day"])
|
|
166
|
+
], 2)) : (openBlock(), createElementBlock("div", {
|
|
167
|
+
key: 1,
|
|
168
|
+
class: normalizeClass(unref(ns).e("body"))
|
|
169
|
+
}, [
|
|
170
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(validatedRange), (range_, index) => {
|
|
171
|
+
return openBlock(), createBlock(DateTable, {
|
|
172
|
+
key: index,
|
|
173
|
+
date: range_[0],
|
|
174
|
+
"selected-day": unref(realSelectedDay),
|
|
175
|
+
range: range_,
|
|
176
|
+
"hide-header": index !== 0
|
|
177
|
+
}, createSlots({ _: 2 }, [
|
|
178
|
+
_ctx.$slots.dateCell ? {
|
|
179
|
+
name: "dateCell",
|
|
180
|
+
fn: withCtx((data) => [
|
|
181
|
+
renderSlot(_ctx.$slots, "dateCell", normalizeProps(guardReactiveProps(data)))
|
|
182
|
+
])
|
|
183
|
+
} : void 0
|
|
184
|
+
]), 1032, ["date", "selected-day", "range", "hide-header"]);
|
|
185
|
+
}), 128))
|
|
186
|
+
], 2))
|
|
187
|
+
], 2);
|
|
188
|
+
};
|
|
11
189
|
}
|
|
12
190
|
});
|
|
191
|
+
var Calendar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/calendar/src/calendar.vue"]]);
|
|
13
192
|
|
|
14
|
-
export {
|
|
193
|
+
export { Calendar as default };
|
|
15
194
|
//# sourceMappingURL=calendar2.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar2.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-ps/utils'\nimport { UPDATE_MODEL_EVENT } from '@element-ps/constants'\nimport type { ExtractPropTypes } from 'vue'\nimport type Calendar from './calendar.vue'\n\nexport type CalendarDateType =\n | 'prev-month'\n | 'next-month'\n | 'prev-year'\n | 'next-year'\n | 'today'\n\nexport const calendarProps = buildProps({\n modelValue: {\n type: Date,\n },\n range: {\n type: definePropType<[Date, Date]>(Array),\n validator: (range: unknown): range is [Date, Date] =>\n Array.isArray(range) &&\n range.length === 2 &&\n range.every((item) => item instanceof Date),\n },\n} as const)\nexport type CalendarProps = ExtractPropTypes<typeof calendarProps>\n\nexport type CalendarInstance = InstanceType<typeof Calendar>\n"],"names":[],"mappings":";;;AACY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,IAAI;AACd,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;AAC/B,IAAI,SAAS,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,YAAY,IAAI,CAAC;AACnH,GAAG;AACH,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"calendar2.mjs","sources":["../../../../../../packages/components/calendar/src/calendar.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div :class=\"ns.e('header')\">\n <slot name=\"header\" :date=\"i18nDate\">\n <div :class=\"ns.e('title')\">{{ i18nDate }}</div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('button-group')\">\n <ps-button-group>\n <ps-button size=\"small\">\n {{ t('el.datepicker.prevMonth') }}\n </ps-button>\n <ps-button size=\"small\">\n {{ t('el.datepicker.today') }}\n </ps-button>\n <ps-button size=\"small\">\n {{ t('el.datepicker.nextMonth') }}\n </ps-button>\n </ps-button-group>\n </div>\n </slot>\n </div>\n <div v-if=\"validatedRange.length === 0\" :class=\"ns.e('body')\">\n <date-table :date=\"date\" :selected-day=\"realSelectedDay\">\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n <div v-else :class=\"ns.e('body')\">\n <date-table\n v-for=\"(range_, index) in validatedRange\"\n :key=\"index\"\n :date=\"range_[0]\"\n :selected-day=\"realSelectedDay\"\n :range=\"range_\"\n :hide-header=\"index !== 0\"\n >\n <template v-if=\"$slots.dateCell\" #dateCell=\"data\">\n <slot name=\"dateCell\" v-bind=\"data\" />\n </template>\n </date-table>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, ref } from 'vue'\nimport dayjs from 'dayjs'\nimport { PsButton, PsButtonGroup } from '@element-ps/components/button'\nimport { useLocale, useNamespace } from '@element-ps/hooks'\nimport { debugWarn } from '@element-ps/utils'\nimport DateTable from './date-table.vue'\nimport { calendarProps } from './calendar'\n\nimport type { ComputedRef } from 'vue'\nimport type { Dayjs } from 'dayjs'\n\nconst COMPONENT_NAME = 'PsCalendar'\n\ndefineOptions({\n name: 'PsCalendar',\n})\n\nconst props = defineProps(calendarProps)\n\nconst ns = useNamespace('calendar')\n\nconst { t, lang } = useLocale()\nconst selectedDay = ref<Dayjs>()\nconst now = dayjs().locale(lang.value)\n\nconst i18nDate = computed(() => {\n const pickedMonth = `el.datepicker.month${date.value.format('M')}`\n return `${date.value.year()} ${t('el.datepicker.year')} ${t(pickedMonth)}`\n})\n\nconst realSelectedDay = computed<Dayjs | undefined>({\n get() {\n if (!props.modelValue) return selectedDay.value\n return date.value\n },\n set(val) {\n if (!val) return\n selectedDay.value = val\n },\n})\n\nconst date: ComputedRef<Dayjs> = computed(() => {\n if (!props.modelValue) {\n if (realSelectedDay.value) {\n return realSelectedDay.value\n } else if (validatedRange.value.length) {\n return validatedRange.value[0][0]\n }\n return now\n } else {\n return dayjs(props.modelValue).locale(lang.value)\n }\n})\n\n// https://github.com/element-ps/element-ps/issues/3155\n// Calculate the validate date range according to the start and end dates\nconst calculateValidatedDateRange = (\n startDayjs: Dayjs,\n endDayjs: Dayjs\n): [Dayjs, Dayjs][] => {\n const firstDay = startDayjs.startOf('week')\n const lastDay = endDayjs.endOf('week')\n const firstMonth = firstDay.get('month')\n const lastMonth = lastDay.get('month')\n\n // Current mouth\n if (firstMonth === lastMonth) {\n return [[firstDay, lastDay]]\n }\n // Two adjacent months\n else if (firstMonth + 1 === lastMonth) {\n const firstMonthLastDay = firstDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the first month and the first day of the last month is in the same week\n const isSameWeek = firstMonthLastDay.isSame(lastMonthFirstDay, 'week')\n const lastMonthStartDay = isSameWeek\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Three consecutive months (compatible: 2021-01-30 to 2021-02-28)\n else if (\n firstMonth + 2 === lastMonth ||\n (firstMonth + 1) % 11 === lastMonth\n ) {\n const firstMonthLastDay = firstDay.endOf('month')\n const secondMonthFirstDay = firstDay.add(1, 'month').startOf('month')\n\n // Whether the last day of the first month and the second month is in the same week\n const secondMonthStartDay = firstMonthLastDay.isSame(\n secondMonthFirstDay,\n 'week'\n )\n ? secondMonthFirstDay.add(1, 'week')\n : secondMonthFirstDay\n\n const secondMonthLastDay = secondMonthStartDay.endOf('month')\n const lastMonthFirstDay = lastDay.startOf('month')\n\n // Whether the last day of the second month and the last day of the last month is in the same week\n const lastMonthStartDay = secondMonthLastDay.isSame(\n lastMonthFirstDay,\n 'week'\n )\n ? lastMonthFirstDay.add(1, 'week')\n : lastMonthFirstDay\n\n return [\n [firstDay, firstMonthLastDay],\n [secondMonthStartDay.startOf('week'), secondMonthLastDay],\n [lastMonthStartDay.startOf('week'), lastDay],\n ]\n }\n // Other cases\n else {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n}\n\n// if range is valid, we get a two-digit array\nconst validatedRange = computed(() => {\n if (!props.range) return []\n const rangeArrDayjs = props.range.map((_) => dayjs(_).locale(lang.value))\n const [startDayjs, endDayjs] = rangeArrDayjs\n if (startDayjs.isAfter(endDayjs)) {\n debugWarn(COMPONENT_NAME, 'end time should be greater than start time')\n return []\n }\n if (startDayjs.isSame(endDayjs, 'month')) {\n // same month\n return calculateValidatedDateRange(startDayjs, endDayjs)\n } else {\n // two months\n if (startDayjs.add(1, 'month').month() !== endDayjs.month()) {\n debugWarn(\n COMPONENT_NAME,\n 'start time and end time interval must not exceed two months'\n )\n return []\n }\n return calculateValidatedDateRange(startDayjs, endDayjs)\n }\n})\n\ndefineExpose({\n /** @description currently selected date */\n selectedDay: realSelectedDay,\n /** @description Calculate the validate date range according to the start and end dates */\n calculateValidatedDateRange,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAwDA,IAAA,MAAA,cAAA,GAAA,YAAA,CAAA;AAQA,IAAA,MAAA,EAAA,GAAA,aAAA,UAAA,CAAA,CAAA;AAEA,IAAA,MAAA,EAAA,CAAA,EAAA,IAAA,EAAA,GAAA,SAAA,EAAA,CAAA;AACA,IAAA,MAAA,cAAA,GAAA,EAAA,CAAA;AACA,IAAA,MAAA,GAAA,GAAA,KAAA,EAAA,CAAA,MAAA,CAAA,KAAA,KAAA,CAAA,CAAA;AAEA,IAAA,MAAA,QAAA,GAAA,SAAA,MAAA;AACA,MAAA,MAAA,WAAA,GAAA,CAAA,mBAAA,EAAA,IAAA,CAAA,KAAA,CAAA,OAAA,GAAA,CAAA,CAAA,CAAA,CAAA;AACA,MAAA,OAAA,CAAA,EAAA,KAAA,KAAA,CAAA,IAAA,MAAA,CAAA,CAAA,oBAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,CAAA;AAAA,KACA,CAAA,CAAA;AAEA,IAAA,MAAA,kBAAA,QAAA,CAAA;AAAA,MACA,GAAA,GAAA;AACA,QAAA,IAAA,CAAA,KAAA,CAAA,UAAA;AAAA,UAAA,OAAA,WAAA,CAAA,KAAA,CAAA;AACA,QAAA,OAAA,IAAA,CAAA,KAAA,CAAA;AAAA,OACA;AAA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;;;;;;;;;;;;;;;;;"}
|
|
@@ -14,7 +14,7 @@ import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
|
14
14
|
import { CommonProps } from '../../cascader-panel/src/config.mjs';
|
|
15
15
|
import { isValidComponentSize } from '../../../utils/vue/validator.mjs';
|
|
16
16
|
import { useTooltipContentProps } from '../../tooltip/src/tooltip.mjs';
|
|
17
|
-
import { tagProps } from '../../tag/src/
|
|
17
|
+
import { tagProps } from '../../tag/src/tag.mjs';
|
|
18
18
|
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
19
19
|
import { useLocale } from '../../../hooks/use-locale/index.mjs';
|
|
20
20
|
import { formContextKey } from '../../../tokens/form.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../../utils/index.mjs';
|
|
2
|
-
import Empty from './src/
|
|
3
|
-
export { emptyProps } from './src/
|
|
2
|
+
import Empty from './src/empty2.mjs';
|
|
3
|
+
export { emptyProps } from './src/empty.mjs';
|
|
4
4
|
import { withInstall } from '../../utils/vue/install.mjs';
|
|
5
5
|
|
|
6
6
|
const PsEmpty = withInstall(Empty);
|
|
@@ -1,59 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const _hoisted_2 = { key: 1 };
|
|
11
|
-
const __default__ = {
|
|
12
|
-
name: "PsEmpty"
|
|
13
|
-
};
|
|
14
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
-
...__default__,
|
|
16
|
-
props: emptyProps,
|
|
17
|
-
setup(__props) {
|
|
18
|
-
const props = __props;
|
|
19
|
-
const { t } = useLocale();
|
|
20
|
-
const ns = useNamespace("empty");
|
|
21
|
-
const emptyDescription = computed(() => props.description || t("el.table.emptyText"));
|
|
22
|
-
const imageStyle = computed(() => ({
|
|
23
|
-
width: props.imageSize ? `${props.imageSize}px` : ""
|
|
24
|
-
}));
|
|
25
|
-
return (_ctx, _cache) => {
|
|
26
|
-
return openBlock(), createElementBlock("div", {
|
|
27
|
-
class: normalizeClass(unref(ns).b())
|
|
28
|
-
}, [
|
|
29
|
-
createElementVNode("div", {
|
|
30
|
-
class: normalizeClass(unref(ns).e("image")),
|
|
31
|
-
style: normalizeStyle(unref(imageStyle))
|
|
32
|
-
}, [
|
|
33
|
-
_ctx.image ? (openBlock(), createElementBlock("img", {
|
|
34
|
-
key: 0,
|
|
35
|
-
src: _ctx.image,
|
|
36
|
-
ondragstart: "return false"
|
|
37
|
-
}, null, 8, _hoisted_1)) : renderSlot(_ctx.$slots, "image", { key: 1 }, () => [
|
|
38
|
-
createVNode(ImgEmpty)
|
|
39
|
-
])
|
|
40
|
-
], 6),
|
|
41
|
-
createElementVNode("div", {
|
|
42
|
-
class: normalizeClass(unref(ns).e("description"))
|
|
43
|
-
}, [
|
|
44
|
-
_ctx.$slots.description ? renderSlot(_ctx.$slots, "description", { key: 0 }) : (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(unref(emptyDescription)), 1))
|
|
45
|
-
], 2),
|
|
46
|
-
_ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
47
|
-
key: 0,
|
|
48
|
-
class: normalizeClass(unref(ns).e("bottom"))
|
|
49
|
-
}, [
|
|
50
|
-
renderSlot(_ctx.$slots, "default")
|
|
51
|
-
], 2)) : createCommentVNode("v-if", true)
|
|
52
|
-
], 2);
|
|
53
|
-
};
|
|
1
|
+
const emptyProps = {
|
|
2
|
+
image: {
|
|
3
|
+
type: String,
|
|
4
|
+
default: ""
|
|
5
|
+
},
|
|
6
|
+
imageSize: Number,
|
|
7
|
+
description: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: ""
|
|
54
10
|
}
|
|
55
|
-
}
|
|
56
|
-
var Empty = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/empty/src/empty.vue"]]);
|
|
11
|
+
};
|
|
57
12
|
|
|
58
|
-
export {
|
|
13
|
+
export { emptyProps };
|
|
59
14
|
//# sourceMappingURL=empty.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty.mjs","sources":["../../../../../../packages/components/empty/src/empty.
|
|
1
|
+
{"version":3,"file":"empty.mjs","sources":["../../../../../../packages/components/empty/src/empty.ts"],"sourcesContent":["import type { ExtractPropTypes } from 'vue'\nimport type Empty from './empty.vue'\n\nexport const emptyProps = {\n image: {\n type: String,\n default: '',\n },\n imageSize: Number,\n description: {\n type: String,\n default: '',\n },\n} as const\nexport type EmptyProps = ExtractPropTypes<typeof emptyProps>\n\nexport type EmptyInstance = InstanceType<typeof Empty>\n"],"names":[],"mappings":"AAAY,MAAC,UAAU,GAAG;AAC1B,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH;;;;"}
|
|
@@ -1,14 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, normalizeStyle, renderSlot, createVNode, toDisplayString, createCommentVNode } from 'vue';
|
|
2
|
+
import '../../../hooks/index.mjs';
|
|
3
|
+
import ImgEmpty from './img-empty.mjs';
|
|
4
|
+
import { emptyProps } from './empty.mjs';
|
|
5
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
6
|
+
import { useLocale } from '../../../hooks/use-locale/index.mjs';
|
|
7
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
8
|
+
|
|
9
|
+
const _hoisted_1 = ["src"];
|
|
10
|
+
const _hoisted_2 = { key: 1 };
|
|
11
|
+
const __default__ = {
|
|
12
|
+
name: "PsEmpty"
|
|
11
13
|
};
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
...__default__,
|
|
16
|
+
props: emptyProps,
|
|
17
|
+
setup(__props) {
|
|
18
|
+
const props = __props;
|
|
19
|
+
const { t } = useLocale();
|
|
20
|
+
const ns = useNamespace("empty");
|
|
21
|
+
const emptyDescription = computed(() => props.description || t("el.table.emptyText"));
|
|
22
|
+
const imageStyle = computed(() => ({
|
|
23
|
+
width: props.imageSize ? `${props.imageSize}px` : ""
|
|
24
|
+
}));
|
|
25
|
+
return (_ctx, _cache) => {
|
|
26
|
+
return openBlock(), createElementBlock("div", {
|
|
27
|
+
class: normalizeClass(unref(ns).b())
|
|
28
|
+
}, [
|
|
29
|
+
createElementVNode("div", {
|
|
30
|
+
class: normalizeClass(unref(ns).e("image")),
|
|
31
|
+
style: normalizeStyle(unref(imageStyle))
|
|
32
|
+
}, [
|
|
33
|
+
_ctx.image ? (openBlock(), createElementBlock("img", {
|
|
34
|
+
key: 0,
|
|
35
|
+
src: _ctx.image,
|
|
36
|
+
ondragstart: "return false"
|
|
37
|
+
}, null, 8, _hoisted_1)) : renderSlot(_ctx.$slots, "image", { key: 1 }, () => [
|
|
38
|
+
createVNode(ImgEmpty)
|
|
39
|
+
])
|
|
40
|
+
], 6),
|
|
41
|
+
createElementVNode("div", {
|
|
42
|
+
class: normalizeClass(unref(ns).e("description"))
|
|
43
|
+
}, [
|
|
44
|
+
_ctx.$slots.description ? renderSlot(_ctx.$slots, "description", { key: 0 }) : (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(unref(emptyDescription)), 1))
|
|
45
|
+
], 2),
|
|
46
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
47
|
+
key: 0,
|
|
48
|
+
class: normalizeClass(unref(ns).e("bottom"))
|
|
49
|
+
}, [
|
|
50
|
+
renderSlot(_ctx.$slots, "default")
|
|
51
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
52
|
+
], 2);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
var Empty = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/meng/workspace/element-ps/packages/components/empty/src/empty.vue"]]);
|
|
12
57
|
|
|
13
|
-
export {
|
|
58
|
+
export { Empty as default };
|
|
14
59
|
//# sourceMappingURL=empty2.mjs.map
|