vue-devui 1.0.0-alpha.5 → 1.0.0-beta.11
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/README.md +31 -36
- package/accordion/index.d.ts +7 -0
- package/accordion/index.es.js +508 -1
- package/accordion/index.umd.js +1 -1
- package/accordion/style.css +1 -1
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +175 -1
- package/alert/index.umd.js +1 -1
- package/alert/style.css +1 -1
- package/anchor/index.d.ts +7 -0
- package/anchor/index.es.js +263 -1
- package/anchor/index.umd.js +1 -1
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +301 -1
- package/avatar/index.umd.js +1 -1
- package/back-top/index.d.ts +7 -0
- package/back-top/index.es.js +128 -0
- package/back-top/index.umd.js +1 -0
- package/back-top/package.json +7 -0
- package/back-top/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +95 -1
- package/badge/index.umd.js +1 -1
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/index.es.js +127 -1
- package/breadcrumb/index.umd.js +1 -1
- package/button/index.d.ts +7 -0
- package/button/index.es.js +392 -1
- package/button/index.umd.js +1 -1
- package/button/style.css +1 -1
- package/card/index.d.ts +7 -0
- package/card/index.es.js +61 -1
- package/card/index.umd.js +1 -1
- package/carousel/index.d.ts +7 -0
- package/carousel/index.es.js +329 -1
- package/carousel/index.umd.js +1 -1
- package/cascader/index.d.ts +7 -0
- package/cascader/index.es.js +1343 -1
- package/cascader/index.umd.js +1 -1
- package/cascader/style.css +1 -1
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +377 -1
- package/checkbox/index.umd.js +1 -1
- package/comment/index.d.ts +7 -0
- package/comment/index.es.js +85 -0
- package/comment/index.umd.js +1 -0
- package/comment/package.json +7 -0
- package/comment/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +176 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker/index.d.ts +7 -0
- package/date-picker/index.es.js +1172 -1
- package/date-picker/index.umd.js +1 -1
- package/date-picker/style.css +1 -1
- package/dragdrop/index.d.ts +7 -0
- package/dragdrop/index.es.js +32 -0
- package/dragdrop/index.umd.js +1 -0
- package/dragdrop/package.json +7 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +287 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +527 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +5857 -1
- package/editable-select/index.umd.js +27 -1
- package/editable-select/style.css +1 -1
- package/form/index.d.ts +7 -0
- package/form/index.es.js +2244 -0
- package/form/index.umd.js +1 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +163 -1
- package/fullscreen/index.umd.js +1 -1
- package/gantt/index.d.ts +7 -0
- package/gantt/index.es.js +535 -0
- package/gantt/index.umd.js +1 -0
- package/gantt/package.json +7 -0
- package/gantt/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +269 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +75 -1
- package/icon/index.umd.js +1 -1
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +480 -1
- package/image-preview/index.umd.js +1 -1
- package/image-preview/style.css +1 -1
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +190 -1
- package/input/index.umd.js +1 -1
- package/input-icon/index.d.ts +7 -0
- package/input-icon/index.es.js +332 -0
- package/input-icon/index.umd.js +1 -0
- package/input-icon/package.json +7 -0
- package/input-icon/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +240 -1
- package/input-number/index.umd.js +1 -1
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +100 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +256 -1
- package/loading/index.umd.js +1 -1
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +1225 -1
- package/modal/index.umd.js +1 -1
- package/modal/style.css +1 -1
- package/nav-sprite/index.d.ts +7 -0
- package/nav-sprite/index.es.js +742 -0
- package/nav-sprite/index.umd.js +1 -0
- package/nav-sprite/package.json +7 -0
- package/nuxt/components/Accordion.js +3 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Anchor.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/BackTop.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Breadcrumb.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Carousel.js +3 -0
- package/nuxt/components/Cascader.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Comment.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DatePicker.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormControl.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormLabel.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Gantt.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/Icon.js +2 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputIcon.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/NavSprite.js +2 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/QuadrantDiagram.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/ReadTip.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/StepsGuide.js +3 -0
- package/nuxt/components/StickSlider.js +3 -0
- package/nuxt/components/Sticky.js +2 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/TagInput.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimeAxis.js +3 -0
- package/nuxt/components/TimeAxisItem.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/Toast.js +3 -0
- package/nuxt/components/ToastService.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Transfer.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/TreeSelect.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +368 -1
- package/overlay/index.umd.js +1 -1
- package/overlay/style.css +1 -1
- package/package.json +8 -34
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +642 -1
- package/pagination/index.umd.js +1 -1
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +205 -1
- package/panel/index.umd.js +1 -1
- package/panel/style.css +1 -1
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +236 -1
- package/popover/index.umd.js +1 -1
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +153 -1
- package/progress/index.umd.js +3 -1
- package/quadrant-diagram/index.d.ts +7 -0
- package/quadrant-diagram/index.es.js +489 -1
- package/quadrant-diagram/index.umd.js +1 -1
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +225 -1
- package/radio/index.umd.js +1 -1
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +220 -1
- package/rate/index.umd.js +1 -1
- package/read-tip/index.d.ts +7 -0
- package/read-tip/index.es.js +258 -0
- package/read-tip/index.umd.js +1 -0
- package/read-tip/package.json +7 -0
- package/read-tip/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +119 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +181 -1
- package/ripple/index.umd.js +1 -1
- package/search/index.d.ts +7 -0
- package/search/index.es.js +543 -1
- package/search/index.umd.js +1 -1
- package/select/index.d.ts +7 -0
- package/select/index.es.js +706 -1
- package/select/index.umd.js +1 -1
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +297 -1
- package/skeleton/index.umd.js +1 -1
- package/skeleton/style.css +1 -1
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +199 -1
- package/slider/index.umd.js +1 -1
- package/slider/style.css +1 -1
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +636 -1
- package/splitter/index.umd.js +1 -1
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +280 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +42 -1
- package/status/index.umd.js +1 -1
- package/steps-guide/index.d.ts +7 -0
- package/steps-guide/index.es.js +239 -1
- package/steps-guide/index.umd.js +1 -1
- package/steps-guide/style.css +1 -1
- package/sticky/index.d.ts +7 -0
- package/sticky/index.es.js +197 -1
- package/sticky/index.umd.js +1 -1
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +100 -1
- package/switch/index.umd.js +1 -1
- package/switch/style.css +1 -1
- package/table/index.d.ts +7 -0
- package/table/index.es.js +1828 -1
- package/table/index.umd.js +1 -1
- package/table/style.css +1 -1
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +195 -1
- package/tabs/index.umd.js +1 -1
- package/tabs/style.css +1 -1
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +131 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/tag-input/index.d.ts +7 -0
- package/tag-input/index.es.js +329 -1
- package/tag-input/index.umd.js +1 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +132 -0
- package/textarea/index.umd.js +1 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/time-axis/index.d.ts +7 -0
- package/time-axis/index.es.js +299 -0
- package/time-axis/index.umd.js +1 -0
- package/time-axis/package.json +7 -0
- package/time-axis/style.css +1 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +1255 -1
- package/time-picker/index.umd.js +1 -1
- package/time-picker/style.css +1 -1
- package/toast/index.d.ts +7 -0
- package/toast/index.es.js +2060 -1
- package/toast/index.umd.js +1 -1
- package/toast/style.css +1 -1
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +171 -1
- package/tooltip/index.umd.js +1 -1
- package/transfer/index.d.ts +7 -0
- package/transfer/index.es.js +1725 -1
- package/transfer/index.umd.js +1 -1
- package/transfer/style.css +1 -1
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +907 -1
- package/tree/index.umd.js +1 -1
- package/tree/style.css +1 -1
- package/tree-select/index.d.ts +7 -0
- package/tree-select/index.es.js +528 -0
- package/tree-select/index.umd.js +1 -0
- package/tree-select/package.json +7 -0
- package/tree-select/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +2834 -1
- package/upload/index.umd.js +1 -1
- package/upload/style.css +1 -1
- package/vue-devui.es.js +27743 -1
- package/vue-devui.umd.js +29 -1
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { defineComponent, ref, onMounted, onUnmounted, createVNode } from "vue";
|
|
2
|
+
const countdownProps = {
|
|
3
|
+
value: {
|
|
4
|
+
type: Number,
|
|
5
|
+
required: true
|
|
6
|
+
},
|
|
7
|
+
format: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: "HH:mm:ss"
|
|
10
|
+
},
|
|
11
|
+
prefix: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: ""
|
|
14
|
+
},
|
|
15
|
+
suffix: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
},
|
|
19
|
+
valueStyle: {
|
|
20
|
+
type: Object,
|
|
21
|
+
default: () => {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var countdown = "";
|
|
27
|
+
const getFormatTime = (leftTime) => {
|
|
28
|
+
const timeformat = new Map([["Y", 0], ["M", 0], ["D", 0], ["H", 0], ["m", 0], ["s", 0], ["S", 0]]);
|
|
29
|
+
const year = Math.floor(leftTime / (365 * 24 * 60 * 60 * 1e3));
|
|
30
|
+
const month = Math.floor(leftTime / (30 * 24 * 60 * 60 * 1e3) % 12);
|
|
31
|
+
const day = Math.floor(leftTime / (24 * 60 * 60 * 1e3) % 30);
|
|
32
|
+
const hour = Math.floor(leftTime / (60 * 60 * 1e3) % 24);
|
|
33
|
+
const minute = Math.floor(leftTime / (60 * 1e3) % 60);
|
|
34
|
+
const second = Math.floor(leftTime / 1e3 % 60);
|
|
35
|
+
const millsecond = leftTime % 1e3;
|
|
36
|
+
timeformat.set("Y", year);
|
|
37
|
+
timeformat.set("M", month);
|
|
38
|
+
timeformat.set("D", day);
|
|
39
|
+
timeformat.set("H", hour);
|
|
40
|
+
timeformat.set("m", minute);
|
|
41
|
+
timeformat.set("s", second);
|
|
42
|
+
timeformat.set("S", millsecond);
|
|
43
|
+
return timeformat;
|
|
44
|
+
};
|
|
45
|
+
const getLegalTime = (s, timeformat) => {
|
|
46
|
+
const dateValue = new Map([["Y", 0], ["M", 0], ["D", 0], ["H", 0], ["m", 0], ["s", 0], ["S", 0]]);
|
|
47
|
+
const m = new Map([["Y", 12], ["M", 30], ["D", 24], ["H", 60], ["m", 60], ["s", 1e3], ["S", 1]]);
|
|
48
|
+
let storage = 0;
|
|
49
|
+
for (const k of dateValue.keys()) {
|
|
50
|
+
if (s.has(k)) {
|
|
51
|
+
dateValue.set(k, timeformat.get(k) + storage);
|
|
52
|
+
storage = 0;
|
|
53
|
+
} else {
|
|
54
|
+
storage += timeformat.get(k) * m.get(k);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!s.has("S") && timeformat.get("S") > 500) {
|
|
58
|
+
dateValue.set("s", dateValue.get("s") + 1);
|
|
59
|
+
}
|
|
60
|
+
return dateValue;
|
|
61
|
+
};
|
|
62
|
+
const getTimeSplit = (format) => {
|
|
63
|
+
const fomatMap = new Set(["Y", "M", "D", "H", "m", "s", "S"]);
|
|
64
|
+
const m = [];
|
|
65
|
+
for (let i = 0; i < format.length; i++) {
|
|
66
|
+
const k = format[i];
|
|
67
|
+
if (m.length === 0 || m[m.length - 1].k !== k || !fomatMap.has(k)) {
|
|
68
|
+
m.push({ k, n: 1 });
|
|
69
|
+
} else {
|
|
70
|
+
m[m.length - 1].n++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return m;
|
|
74
|
+
};
|
|
75
|
+
const getDeduplication = (format) => {
|
|
76
|
+
const fomatMap = new Set(["Y", "M", "D", "H", "m", "s", "S"]);
|
|
77
|
+
const s = new Set();
|
|
78
|
+
for (let i = 0; i < format.length; i++) {
|
|
79
|
+
const k = format[i];
|
|
80
|
+
if (fomatMap.has(k)) {
|
|
81
|
+
s.add(k);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return s;
|
|
85
|
+
};
|
|
86
|
+
const numFormat = (n, len) => {
|
|
87
|
+
const maxNum = 10 ** len - 1;
|
|
88
|
+
if (n >= maxNum) {
|
|
89
|
+
return n;
|
|
90
|
+
} else {
|
|
91
|
+
const carryLen = len - n.toString().length;
|
|
92
|
+
let str = "";
|
|
93
|
+
for (let i = 0; i < carryLen; i++) {
|
|
94
|
+
str += "0";
|
|
95
|
+
}
|
|
96
|
+
return str + n;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var Countdown = defineComponent({
|
|
100
|
+
name: "DCountdown",
|
|
101
|
+
props: countdownProps,
|
|
102
|
+
emits: ["onChange", "onFinish"],
|
|
103
|
+
setup(props, ctx) {
|
|
104
|
+
const countdown2 = ref();
|
|
105
|
+
const s = getDeduplication(props.format);
|
|
106
|
+
const timeFormat = getTimeSplit(props.format);
|
|
107
|
+
const timeStr = ref("");
|
|
108
|
+
const getTimeStr = (legalTime) => {
|
|
109
|
+
const fomatMap = new Set(["Y", "M", "D", "H", "m", "s", "S"]);
|
|
110
|
+
const t = timeFormat.reduce((pre, cur) => {
|
|
111
|
+
if (fomatMap.has(cur.k)) {
|
|
112
|
+
return pre + numFormat(legalTime.get(cur.k), cur.n);
|
|
113
|
+
}
|
|
114
|
+
return pre + cur.k;
|
|
115
|
+
}, "");
|
|
116
|
+
timeStr.value = t;
|
|
117
|
+
};
|
|
118
|
+
const getTime = () => {
|
|
119
|
+
const value = new Date(props.value).getTime();
|
|
120
|
+
const leftTime = value > new Date().getTime() ? value - new Date().getTime() : 0;
|
|
121
|
+
const formatTime = getFormatTime(leftTime);
|
|
122
|
+
const legalTime = getLegalTime(s, formatTime);
|
|
123
|
+
!ctx.slots.default && getTimeStr(legalTime);
|
|
124
|
+
ctx.emit("onChange", {
|
|
125
|
+
leftTime,
|
|
126
|
+
formatTime,
|
|
127
|
+
legalTime
|
|
128
|
+
});
|
|
129
|
+
return leftTime;
|
|
130
|
+
};
|
|
131
|
+
const startTime = () => {
|
|
132
|
+
getTime();
|
|
133
|
+
if (countdown2.value)
|
|
134
|
+
return;
|
|
135
|
+
countdown2.value = setInterval(() => {
|
|
136
|
+
const t = getTime();
|
|
137
|
+
if (t === 0) {
|
|
138
|
+
ctx.emit("onFinish");
|
|
139
|
+
clearInterval(countdown2.value);
|
|
140
|
+
}
|
|
141
|
+
}, s.has("S") ? 100 : 1e3);
|
|
142
|
+
};
|
|
143
|
+
onMounted(() => {
|
|
144
|
+
startTime();
|
|
145
|
+
});
|
|
146
|
+
onUnmounted(() => {
|
|
147
|
+
clearInterval(countdown2.value);
|
|
148
|
+
});
|
|
149
|
+
return () => {
|
|
150
|
+
return createVNode("div", {
|
|
151
|
+
"class": "devui-countdown"
|
|
152
|
+
}, [ctx.slots.default ? ctx.slots.default() : createVNode("div", {
|
|
153
|
+
"class": "countdown-content",
|
|
154
|
+
"style": props.valueStyle
|
|
155
|
+
}, [createVNode("span", {
|
|
156
|
+
"class": "countdown-prefix"
|
|
157
|
+
}, [props.prefix]), createVNode("span", {
|
|
158
|
+
"class": "countdown-value"
|
|
159
|
+
}, [timeStr.value]), createVNode("span", {
|
|
160
|
+
"class": "countdown-suffix"
|
|
161
|
+
}, [props.suffix])])]);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
Countdown.install = function(app) {
|
|
166
|
+
app.component(Countdown.name, Countdown);
|
|
167
|
+
};
|
|
168
|
+
var index = {
|
|
169
|
+
title: "Countdown \u5012\u8BA1\u65F6",
|
|
170
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
171
|
+
status: "100%",
|
|
172
|
+
install(app) {
|
|
173
|
+
app.use(Countdown);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
export { Countdown, index as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(r,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(r=typeof globalThis!="undefined"?globalThis:r||self,a(r.index={},r.Vue))})(this,function(r,a){"use strict";const w={value:{type:Number,required:!0},format:{type:String,default:"HH:mm:ss"},prefix:{type:String,default:""},suffix:{type:String,default:""},valueStyle:{type:Object,default:()=>({})}};var T="";const M=e=>{const t=new Map([["Y",0],["M",0],["D",0],["H",0],["m",0],["s",0],["S",0]]),n=Math.floor(e/(365*24*60*60*1e3)),s=Math.floor(e/(30*24*60*60*1e3)%12),o=Math.floor(e/(24*60*60*1e3)%30),u=Math.floor(e/(60*60*1e3)%24),h=Math.floor(e/(60*1e3)%60),f=Math.floor(e/1e3%60),S=e%1e3;return t.set("Y",n),t.set("M",s),t.set("D",o),t.set("H",u),t.set("m",h),t.set("s",f),t.set("S",S),t},p=(e,t)=>{const n=new Map([["Y",0],["M",0],["D",0],["H",0],["m",0],["s",0],["S",0]]),s=new Map([["Y",12],["M",30],["D",24],["H",60],["m",60],["s",1e3],["S",1]]);let o=0;for(const u of n.keys())e.has(u)?(n.set(u,t.get(u)+o),o=0):o+=t.get(u)*s.get(u);return!e.has("S")&&t.get("S")>500&&n.set("s",n.get("s")+1),n},y=e=>{const t=new Set(["Y","M","D","H","m","s","S"]),n=[];for(let s=0;s<e.length;s++){const o=e[s];n.length===0||n[n.length-1].k!==o||!t.has(o)?n.push({k:o,n:1}):n[n.length-1].n++}return n},v=e=>{const t=new Set(["Y","M","D","H","m","s","S"]),n=new Set;for(let s=0;s<e.length;s++){const o=e[s];t.has(o)&&n.add(o)}return n},D=(e,t)=>{const n=10**t-1;if(e>=n)return e;{const s=t-e.toString().length;let o="";for(let u=0;u<s;u++)o+="0";return o+e}};var l=a.defineComponent({name:"DCountdown",props:w,emits:["onChange","onFinish"],setup(e,t){const n=a.ref(),s=v(e.format),o=y(e.format),u=a.ref(""),h=c=>{const i=new Set(["Y","M","D","H","m","s","S"]),m=o.reduce((d,g)=>i.has(g.k)?d+D(c.get(g.k),g.n):d+g.k,"");u.value=m},f=()=>{const c=new Date(e.value).getTime(),i=c>new Date().getTime()?c-new Date().getTime():0,m=M(i),d=p(s,m);return!t.slots.default&&h(d),t.emit("onChange",{leftTime:i,formatTime:m,legalTime:d}),i},S=()=>{f(),!n.value&&(n.value=setInterval(()=>{f()===0&&(t.emit("onFinish"),clearInterval(n.value))},s.has("S")?100:1e3))};return a.onMounted(()=>{S()}),a.onUnmounted(()=>{clearInterval(n.value)}),()=>a.createVNode("div",{class:"devui-countdown"},[t.slots.default?t.slots.default():a.createVNode("div",{class:"countdown-content",style:e.valueStyle},[a.createVNode("span",{class:"countdown-prefix"},[e.prefix]),a.createVNode("span",{class:"countdown-value"},[u.value]),a.createVNode("span",{class:"countdown-suffix"},[e.suffix])])])}});l.install=function(e){e.component(l.name,l)};var H={title:"Countdown \u5012\u8BA1\u65F6",category:"\u6570\u636E\u5C55\u793A",status:"100%",install(e){e.use(l)}};r.Countdown=l,r.default=H,Object.defineProperty(r,"__esModule",{value:!0}),r[Symbol.toStringTag]="Module"});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.devui-countdown .countdown-content{font-size:24px;color:var(--devui-text, #252b3a)}.devui-countdown .countdown-content span{display:inline-block}.devui-countdown .countdown-content .countdown-prefix{margin-right:4px}.devui-countdown .countdown-content .countdown-suffix{margin-left:4px}
|