@element-plus/nightly 0.0.20221202 → 0.0.20221204
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.css +1 -1
- package/dist/index.full.js +736 -449
- package/dist/index.full.min.js +17 -17
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +14 -14
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +730 -450
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/az.js +1 -1
- package/dist/locale/az.min.js +1 -1
- package/dist/locale/az.min.mjs +1 -1
- package/dist/locale/az.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mg.js +1 -1
- package/dist/locale/mg.min.js +1 -1
- package/dist/locale/mg.min.mjs +1 -1
- package/dist/locale/mg.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/component.mjs +3 -0
- package/es/component.mjs.map +1 -1
- package/es/components/index.d.ts +1 -0
- package/es/components/index.mjs +3 -0
- package/es/components/index.mjs.map +1 -1
- package/es/components/notification/src/notify.mjs +1 -1
- package/es/components/notification/src/notify.mjs.map +1 -1
- package/es/components/statistic/index.d.ts +164 -0
- package/es/components/statistic/index.mjs +12 -0
- package/es/components/statistic/index.mjs.map +1 -0
- package/es/components/statistic/src/countdown.d.ts +22 -0
- package/es/components/statistic/src/countdown.mjs +63 -0
- package/es/components/statistic/src/countdown.mjs.map +1 -0
- package/es/components/statistic/src/countdown.vue.d.ts +80 -0
- package/es/components/statistic/src/countdown2.mjs +114 -0
- package/es/components/statistic/src/countdown2.mjs.map +1 -0
- package/es/components/statistic/src/statistic.d.ts +21 -0
- package/es/components/statistic/src/statistic.mjs +51 -0
- package/es/components/statistic/src/statistic.mjs.map +1 -0
- package/es/components/statistic/src/statistic.vue.d.ts +83 -0
- package/es/components/statistic/src/statistic2.mjs +81 -0
- package/es/components/statistic/src/statistic2.mjs.map +1 -0
- package/es/components/statistic/style/css.d.ts +2 -0
- package/es/components/statistic/style/css.mjs +3 -0
- package/es/components/statistic/style/css.mjs.map +1 -0
- package/es/components/statistic/style/index.d.ts +2 -0
- package/es/components/statistic/style/index.mjs +3 -0
- package/es/components/statistic/style/index.mjs.map +1 -0
- package/es/components/steps/index.d.ts +16 -16
- package/es/components/steps/src/item.d.ts +1 -1
- package/es/components/steps/src/item.vue.d.ts +4 -4
- package/es/components/steps/src/steps.d.ts +2 -2
- package/es/components/steps/src/steps.vue.d.ts +8 -8
- package/es/index.mjs +3 -0
- package/es/index.mjs.map +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/component.js +165 -162
- package/lib/component.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +23 -13
- package/lib/components/index.js.map +1 -1
- package/lib/components/notification/src/notify.js +1 -1
- package/lib/components/notification/src/notify.js.map +1 -1
- package/lib/components/statistic/index.d.ts +164 -0
- package/lib/components/statistic/index.js +23 -0
- package/lib/components/statistic/index.js.map +1 -0
- package/lib/components/statistic/src/countdown.d.ts +22 -0
- package/lib/components/statistic/src/countdown.js +73 -0
- package/lib/components/statistic/src/countdown.js.map +1 -0
- package/lib/components/statistic/src/countdown.vue.d.ts +80 -0
- package/lib/components/statistic/src/countdown2.js +118 -0
- package/lib/components/statistic/src/countdown2.js.map +1 -0
- package/lib/components/statistic/src/statistic.d.ts +21 -0
- package/lib/components/statistic/src/statistic.js +56 -0
- package/lib/components/statistic/src/statistic.js.map +1 -0
- package/lib/components/statistic/src/statistic.vue.d.ts +83 -0
- package/lib/components/statistic/src/statistic2.js +85 -0
- package/lib/components/statistic/src/statistic2.js.map +1 -0
- package/lib/components/statistic/style/css.d.ts +2 -0
- package/lib/components/statistic/style/css.js +6 -0
- package/lib/components/statistic/style/css.js.map +1 -0
- package/lib/components/statistic/style/index.d.ts +2 -0
- package/lib/components/statistic/style/index.js +6 -0
- package/lib/components/statistic/style/index.js.map +1 -0
- package/lib/components/steps/index.d.ts +16 -16
- package/lib/components/steps/src/item.d.ts +1 -1
- package/lib/components/steps/src/item.vue.d.ts +4 -4
- package/lib/components/steps/src/steps.d.ts +2 -2
- package/lib/components/steps/src/steps.vue.d.ts +8 -8
- package/lib/index.js +112 -102
- package/lib/index.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/tags.json +1 -1
- package/theme-chalk/el-statistic.css +1 -0
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/common/var.scss +14 -1
- package/theme-chalk/src/index.scss +1 -0
- package/theme-chalk/src/statistic.scss +46 -0
- package/web-types.json +1 -1
package/es/components/index.mjs
CHANGED
|
@@ -66,6 +66,7 @@ export { ElTreeSelect } from './tree-select/index.mjs';
|
|
|
66
66
|
export { ElTreeV2 } from './tree-v2/index.mjs';
|
|
67
67
|
export { ElUpload } from './upload/index.mjs';
|
|
68
68
|
import './virtual-list/index.mjs';
|
|
69
|
+
export { ElCountdown, ElStatistic } from './statistic/index.mjs';
|
|
69
70
|
export { ElInfiniteScroll } from './infinite-scroll/index.mjs';
|
|
70
71
|
export { ElLoading } from './loading/index.mjs';
|
|
71
72
|
export { ElMessage } from './message/index.mjs';
|
|
@@ -176,6 +177,8 @@ export { default as DynamicSizeList } from './virtual-list/src/components/dynami
|
|
|
176
177
|
export { default as FixedSizeGrid } from './virtual-list/src/components/fixed-size-grid.mjs';
|
|
177
178
|
export { default as DynamicSizeGrid } from './virtual-list/src/components/dynamic-size-grid.mjs';
|
|
178
179
|
export { virtualizedGridProps, virtualizedListProps, virtualizedProps, virtualizedScrollbarProps } from './virtual-list/src/props.mjs';
|
|
180
|
+
export { regroup, statisticProps } from './statistic/src/statistic.mjs';
|
|
181
|
+
export { countdownEmits, countdownProps, formatTimeStr } from './statistic/src/countdown.mjs';
|
|
179
182
|
export { vLoading as ElLoadingDirective, vLoading } from './loading/src/directive.mjs';
|
|
180
183
|
export { Loading as ElLoadingService } from './loading/src/service.mjs';
|
|
181
184
|
export { messageDefaults, messageEmits, messageProps, messageTypes } from './message/src/message.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -34,8 +34,8 @@ const notify = function(options = {}, context = null) {
|
|
|
34
34
|
const id = `notification_${seed++}`;
|
|
35
35
|
const userOnClose = options.onClose;
|
|
36
36
|
const props = {
|
|
37
|
-
...options,
|
|
38
37
|
zIndex: nextZIndex(),
|
|
38
|
+
...options,
|
|
39
39
|
offset: verticalOffset,
|
|
40
40
|
id,
|
|
41
41
|
onClose: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify.mjs","sources":["../../../../../../packages/components/notification/src/notify.ts"],"sourcesContent":["import { createVNode, render } from 'vue'\nimport { isClient } from '@vueuse/core'\nimport { useZIndex } from '@element-plus/hooks'\nimport { debugWarn, isElement, isString, isVNode } from '@element-plus/utils'\nimport NotificationConstructor from './notification.vue'\nimport { notificationTypes } from './notification'\n\nimport type { AppContext, Ref, VNode } from 'vue'\nimport type {\n NotificationOptions,\n NotificationProps,\n NotificationQueue,\n Notify,\n NotifyFn,\n} from './notification'\n\n// This should be a queue but considering there were `non-autoclosable` notifications.\nconst notifications: Record<\n NotificationOptions['position'],\n NotificationQueue\n> = {\n 'top-left': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-right': [],\n}\n\n// the gap size between each notification\nconst GAP_SIZE = 16\nlet seed = 1\n\nconst notify: NotifyFn & Partial<Notify> & { _context: AppContext | null } =\n function (options = {}, context: AppContext | null = null) {\n if (!isClient) return { close: () => undefined }\n\n if (typeof options === 'string' || isVNode(options)) {\n options = { message: options }\n }\n\n const position = options.position || 'top-right'\n\n let verticalOffset = options.offset || 0\n notifications[position].forEach(({ vm }) => {\n verticalOffset += (vm.el?.offsetHeight || 0) + GAP_SIZE\n })\n verticalOffset += GAP_SIZE\n\n const { nextZIndex } = useZIndex()\n\n const id = `notification_${seed++}`\n const userOnClose = options.onClose\n const props: Partial<NotificationProps> = {\n ...options,\n zIndex: nextZIndex(),\n offset: verticalOffset,\n id,\n onClose: () => {\n close(id, position, userOnClose)\n },\n }\n\n let appendTo: HTMLElement | null = document.body\n if (isElement(options.appendTo)) {\n appendTo = options.appendTo\n } else if (isString(options.appendTo)) {\n appendTo = document.querySelector(options.appendTo)\n }\n\n // should fallback to default value with a warning\n if (!isElement(appendTo)) {\n debugWarn(\n 'ElNotification',\n 'the appendTo option is not an HTMLElement. Falling back to document.body.'\n )\n appendTo = document.body\n }\n\n const container = document.createElement('div')\n\n const vm = createVNode(\n NotificationConstructor,\n props,\n isVNode(props.message)\n ? {\n default: () => props.message,\n }\n : null\n )\n vm.appContext = context ?? notify._context\n\n // clean notification element preventing mem leak\n vm.props!.onDestroy = () => {\n render(null, container)\n }\n\n // instances will remove this item when close function gets called. So we do not need to worry about it.\n render(vm, container)\n notifications[position].push({ vm })\n appendTo.appendChild(container.firstElementChild!)\n\n return {\n // instead of calling the onClose function directly, setting this value so that we can have the full lifecycle\n // for out component, so that all closing steps will not be skipped.\n close: () => {\n ;(vm.component!.exposed as { visible: Ref<boolean> }).visible.value =\n false\n },\n }\n }\nnotificationTypes.forEach((type) => {\n notify[type] = (options = {}) => {\n if (typeof options === 'string' || isVNode(options)) {\n options = {\n message: options,\n }\n }\n return notify({\n ...options,\n type,\n })\n }\n})\n\n/**\n * This function gets called when user click `x` button or press `esc` or the time reached its limitation.\n * Emitted by transition@before-leave event so that we can fetch the current notification.offsetHeight, if this was called\n * by @after-leave the DOM element will be removed from the page thus we can no longer fetch the offsetHeight.\n * @param {String} id notification id to be closed\n * @param {Position} position the positioning strategy\n * @param {Function} userOnClose the callback called when close passed by user\n */\nexport function close(\n id: string,\n position: NotificationOptions['position'],\n userOnClose?: (vm: VNode) => void\n): void {\n // maybe we can store the index when inserting the vm to notification list.\n const orientedNotifications = notifications[position]\n const idx = orientedNotifications.findIndex(\n ({ vm }) => vm.component?.props.id === id\n )\n if (idx === -1) return\n const { vm } = orientedNotifications[idx]\n if (!vm) return\n // calling user's on close function before notification gets removed from DOM.\n userOnClose?.(vm)\n\n // note that this is called @before-leave, that's why we were able to fetch this property.\n const removedHeight = vm.el!.offsetHeight\n const verticalPos = position.split('-')[0]\n orientedNotifications.splice(idx, 1)\n const len = orientedNotifications.length\n if (len < 1) return\n // starting from the removing item.\n for (let i = idx; i < len; i++) {\n // new position equals the current offsetTop minus removed height plus 16px(the gap size between each item)\n const { el, component } = orientedNotifications[i].vm\n const pos =\n Number.parseInt(el!.style[verticalPos], 10) - removedHeight - GAP_SIZE\n component!.props.offset = pos\n }\n}\n\nexport function closeAll(): void {\n // loop through all directions, close them at once.\n for (const orientedNotifications of Object.values(notifications)) {\n orientedNotifications.forEach(({ vm }) => {\n // same as the previous close method, we'd like to make sure lifecycle gets handle properly.\n ;(vm.component!.exposed as { visible: Ref<boolean> }).visible.value =\n false\n })\n }\n}\n\nnotify.closeAll = closeAll\nnotify._context = null\n\nexport default notify as Notify\n"],"names":[],"mappings":";;;;;;;;;;;AAMA,MAAM,aAAa,GAAG;AACtB,EAAE,UAAU,EAAE,EAAE;AAChB,EAAE,WAAW,EAAE,EAAE;AACjB,EAAE,aAAa,EAAE,EAAE;AACnB,EAAE,cAAc,EAAE,EAAE;AACpB,CAAC,CAAC;AACF,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,IAAI,IAAI,GAAG,CAAC,CAAC;AACR,MAAC,MAAM,GAAG,SAAS,OAAO,GAAG,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE;AACtD,EAAE,IAAI,CAAC,QAAQ;AACf,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;AACnC,EAAE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;AACvD,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACnC,GAAG;AACH,EAAE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,WAAW,CAAC;AACnD,EAAE,IAAI,cAAc,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;AAC3C,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK;AACnD,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,YAAY,KAAK,CAAC,IAAI,QAAQ,CAAC;AAC3F,GAAG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SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;AACjC,GAAG;AACH,CAAC;AACM,SAAS,QAAQ,GAAG;AAC3B,EAAE,KAAK,MAAM,qBAAqB,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;AACpE,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK;AAC9C,MAAM,CAAC;AACP,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACjD,KAAK,CAAC,CAAC;AACP,GAAG;AACH,CAAC;AACD,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC3B,MAAM,CAAC,QAAQ,GAAG,IAAI;;;;"}
|
|
1
|
+
{"version":3,"file":"notify.mjs","sources":["../../../../../../packages/components/notification/src/notify.ts"],"sourcesContent":["import { createVNode, render } from 'vue'\nimport { isClient } from '@vueuse/core'\nimport { useZIndex } from '@element-plus/hooks'\nimport { debugWarn, isElement, isString, isVNode } from '@element-plus/utils'\nimport NotificationConstructor from './notification.vue'\nimport { notificationTypes } from './notification'\n\nimport type { AppContext, Ref, VNode } from 'vue'\nimport type {\n NotificationOptions,\n NotificationProps,\n NotificationQueue,\n Notify,\n NotifyFn,\n} from './notification'\n\n// This should be a queue but considering there were `non-autoclosable` notifications.\nconst notifications: Record<\n NotificationOptions['position'],\n NotificationQueue\n> = {\n 'top-left': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-right': [],\n}\n\n// the gap size between each notification\nconst GAP_SIZE = 16\nlet seed = 1\n\nconst notify: NotifyFn & Partial<Notify> & { _context: AppContext | null } =\n function (options = {}, context: AppContext | null = null) {\n if (!isClient) return { close: () => undefined }\n\n if (typeof options === 'string' || isVNode(options)) {\n options = { message: options }\n }\n\n const position = options.position || 'top-right'\n\n let verticalOffset = options.offset || 0\n notifications[position].forEach(({ vm }) => {\n verticalOffset += (vm.el?.offsetHeight || 0) + GAP_SIZE\n })\n verticalOffset += GAP_SIZE\n\n const { nextZIndex } = useZIndex()\n\n const id = `notification_${seed++}`\n const userOnClose = options.onClose\n const props: Partial<NotificationProps> = {\n zIndex: nextZIndex(),\n ...options,\n offset: verticalOffset,\n id,\n onClose: () => {\n close(id, position, userOnClose)\n },\n }\n\n let appendTo: HTMLElement | null = document.body\n if (isElement(options.appendTo)) {\n appendTo = options.appendTo\n } else if (isString(options.appendTo)) {\n appendTo = document.querySelector(options.appendTo)\n }\n\n // should fallback to default value with a warning\n if (!isElement(appendTo)) {\n debugWarn(\n 'ElNotification',\n 'the appendTo option is not an HTMLElement. Falling back to document.body.'\n )\n appendTo = document.body\n }\n\n const container = document.createElement('div')\n\n const vm = createVNode(\n NotificationConstructor,\n props,\n isVNode(props.message)\n ? {\n default: () => props.message,\n }\n : null\n )\n vm.appContext = context ?? notify._context\n\n // clean notification element preventing mem leak\n vm.props!.onDestroy = () => {\n render(null, container)\n }\n\n // instances will remove this item when close function gets called. So we do not need to worry about it.\n render(vm, container)\n notifications[position].push({ vm })\n appendTo.appendChild(container.firstElementChild!)\n\n return {\n // instead of calling the onClose function directly, setting this value so that we can have the full lifecycle\n // for out component, so that all closing steps will not be skipped.\n close: () => {\n ;(vm.component!.exposed as { visible: Ref<boolean> }).visible.value =\n false\n },\n }\n }\nnotificationTypes.forEach((type) => {\n notify[type] = (options = {}) => {\n if (typeof options === 'string' || isVNode(options)) {\n options = {\n message: options,\n }\n }\n return notify({\n ...options,\n type,\n })\n }\n})\n\n/**\n * This function gets called when user click `x` button or press `esc` or the time reached its limitation.\n * Emitted by transition@before-leave event so that we can fetch the current notification.offsetHeight, if this was called\n * by @after-leave the DOM element will be removed from the page thus we can no longer fetch the offsetHeight.\n * @param {String} id notification id to be closed\n * @param {Position} position the positioning strategy\n * @param {Function} userOnClose the callback called when close passed by user\n */\nexport function close(\n id: string,\n position: NotificationOptions['position'],\n userOnClose?: (vm: VNode) => void\n): void {\n // maybe we can store the index when inserting the vm to notification list.\n const orientedNotifications = notifications[position]\n const idx = orientedNotifications.findIndex(\n ({ vm }) => vm.component?.props.id === id\n )\n if (idx === -1) return\n const { vm } = orientedNotifications[idx]\n if (!vm) return\n // calling user's on close function before notification gets removed from DOM.\n userOnClose?.(vm)\n\n // note that this is called @before-leave, that's why we were able to fetch this property.\n const removedHeight = vm.el!.offsetHeight\n const verticalPos = position.split('-')[0]\n orientedNotifications.splice(idx, 1)\n const len = orientedNotifications.length\n if (len < 1) return\n // starting from the removing item.\n for (let i = idx; i < len; i++) {\n // new position equals the current offsetTop minus removed height plus 16px(the gap size between each item)\n const { el, component } = orientedNotifications[i].vm\n const pos =\n Number.parseInt(el!.style[verticalPos], 10) - removedHeight - GAP_SIZE\n component!.props.offset = pos\n }\n}\n\nexport function closeAll(): void {\n // loop through all directions, close them at once.\n for (const orientedNotifications of Object.values(notifications)) {\n orientedNotifications.forEach(({ vm }) => {\n // same as the previous close method, we'd like to make sure lifecycle gets handle properly.\n ;(vm.component!.exposed as { visible: Ref<boolean> }).visible.value =\n false\n })\n }\n}\n\nnotify.closeAll = closeAll\nnotify._context = null\n\nexport default notify as Notify\n"],"names":[],"mappings":";;;;;;;;;;;AAMA,MAAM,aAAa,GAAG;AACtB,EAAE,UAAU,EAAE,EAAE;AAChB,EAAE,WAAW,EAAE,EAAE;AACjB,EAAE,aAAa,EAAE,EAAE;AACnB,EAAE,cAAc,EAAE,EAAE;AACpB,CAAC,CAAC;AACF,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,IAAI,IAAI,GAAG,CAAC,CAAC;AACR,MAAC,MAAM,GAAG,SAAS,OAAO,GAAG,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE;AACtD,EAAE,IAAI,CAAC,QAAQ;AACf,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;AACnC,EAAE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;AACvD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AC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACvC,EAAE,MAAM,GAAG,GAAG,qBAAqB,CAAC,MAAM,CAAC;AAC3C,EAAE,IAAI,GAAG,GAAG,CAAC;AACb,IAAI,OAAO;AACX,EAAE,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;AAClC,IAAI,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,IAAI,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,GAAG,aAAa,GAAG,QAAQ,CAAC;AACtF,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;AACjC,GAAG;AACH,CAAC;AACM,SAAS,QAAQ,GAAG;AAC3B,EAAE,KAAK,MAAM,qBAAqB,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;AACpE,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK;AAC9C,MAAM,CAAC;AACP,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;AACjD,KAAK,CAAC,CAAC;AACP,GAAG;AACH,CAAC;AACD,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC3B,MAAM,CAAC,QAAQ,GAAG,IAAI;;;;"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export * from './src/statistic';
|
|
2
|
+
export * from './src/countdown';
|
|
3
|
+
export declare const ElStatistic: import("element-plus/es/utils").SFCWithInstall<import("vue").DefineComponent<{
|
|
4
|
+
readonly decimalSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ".", boolean>;
|
|
5
|
+
readonly groupSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ",", boolean>;
|
|
6
|
+
readonly precision: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, null, boolean>;
|
|
7
|
+
readonly formatter: {
|
|
8
|
+
readonly type: import("vue").PropType<(val: string | number) => string | number>;
|
|
9
|
+
readonly required: false;
|
|
10
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
11
|
+
__epPropKey: true;
|
|
12
|
+
};
|
|
13
|
+
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, null, boolean>;
|
|
14
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
15
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
16
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
17
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
18
|
+
readonly rate: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 3, boolean>;
|
|
19
|
+
}, {
|
|
20
|
+
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
21
|
+
readonly decimalSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ".", boolean>;
|
|
22
|
+
readonly groupSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ",", boolean>;
|
|
23
|
+
readonly precision: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, null, boolean>;
|
|
24
|
+
readonly formatter: {
|
|
25
|
+
readonly type: import("vue").PropType<(val: string | number) => string | number>;
|
|
26
|
+
readonly required: false;
|
|
27
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
28
|
+
__epPropKey: true;
|
|
29
|
+
};
|
|
30
|
+
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, null, boolean>;
|
|
31
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
32
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
33
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
34
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
35
|
+
readonly rate: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 3, boolean>;
|
|
36
|
+
}>> & {
|
|
37
|
+
[x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
|
|
38
|
+
}>>;
|
|
39
|
+
ns: {
|
|
40
|
+
namespace: import("vue").Ref<string>;
|
|
41
|
+
b: (blockSuffix?: string) => string;
|
|
42
|
+
e: (element?: string | undefined) => string;
|
|
43
|
+
m: (modifier?: string | undefined) => string;
|
|
44
|
+
be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
|
|
45
|
+
em: (element?: string | undefined, modifier?: string | undefined) => string;
|
|
46
|
+
bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
|
|
47
|
+
bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
|
|
48
|
+
is: {
|
|
49
|
+
(name: string, state: boolean | undefined): string;
|
|
50
|
+
(name: string): string;
|
|
51
|
+
};
|
|
52
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
53
|
+
cssVarName: (name: string) => string;
|
|
54
|
+
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
55
|
+
cssVarBlockName: (name: string) => string;
|
|
56
|
+
};
|
|
57
|
+
disposeValue: import("vue").ComputedRef<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
|
|
58
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
|
+
readonly decimalSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ".", boolean>;
|
|
60
|
+
readonly groupSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ",", boolean>;
|
|
61
|
+
readonly precision: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, null, boolean>;
|
|
62
|
+
readonly formatter: {
|
|
63
|
+
readonly type: import("vue").PropType<(val: string | number) => string | number>;
|
|
64
|
+
readonly required: false;
|
|
65
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
66
|
+
__epPropKey: true;
|
|
67
|
+
};
|
|
68
|
+
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, null, boolean>;
|
|
69
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
70
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
71
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
72
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
73
|
+
readonly rate: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 3, boolean>;
|
|
74
|
+
}>>, {
|
|
75
|
+
readonly title: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
|
|
76
|
+
readonly value: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
|
|
77
|
+
readonly prefix: string;
|
|
78
|
+
readonly suffix: string;
|
|
79
|
+
readonly precision: number;
|
|
80
|
+
readonly decimalSeparator: string;
|
|
81
|
+
readonly groupSeparator: string;
|
|
82
|
+
readonly valueStyle: import("vue").StyleValue;
|
|
83
|
+
readonly rate: number;
|
|
84
|
+
}>> & Record<string, any>;
|
|
85
|
+
export declare const ElCountdown: import("element-plus/es/utils").SFCWithInstall<import("vue").DefineComponent<{
|
|
86
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
87
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
88
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
89
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
90
|
+
readonly value: {
|
|
91
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
92
|
+
readonly required: false;
|
|
93
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
94
|
+
__epPropKey: true;
|
|
95
|
+
};
|
|
96
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
97
|
+
}, {
|
|
98
|
+
REFRESH_INTERVAL: number;
|
|
99
|
+
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
100
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
101
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
102
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
103
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
104
|
+
readonly value: {
|
|
105
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
106
|
+
readonly required: false;
|
|
107
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
108
|
+
__epPropKey: true;
|
|
109
|
+
};
|
|
110
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
111
|
+
}>> & {
|
|
112
|
+
onChange?: ((value: number) => any) | undefined;
|
|
113
|
+
onFinish?: (() => any) | undefined;
|
|
114
|
+
}>>;
|
|
115
|
+
emit: ((event: "change", value: number) => void) & ((event: "finish") => void);
|
|
116
|
+
ns: {
|
|
117
|
+
namespace: import("vue").Ref<string>;
|
|
118
|
+
b: (blockSuffix?: string) => string;
|
|
119
|
+
e: (element?: string | undefined) => string;
|
|
120
|
+
m: (modifier?: string | undefined) => string;
|
|
121
|
+
be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
|
|
122
|
+
em: (element?: string | undefined, modifier?: string | undefined) => string;
|
|
123
|
+
bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
|
|
124
|
+
bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
|
|
125
|
+
is: {
|
|
126
|
+
(name: string, state: boolean | undefined): string;
|
|
127
|
+
(name: string): string;
|
|
128
|
+
};
|
|
129
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
130
|
+
cssVarName: (name: string) => string;
|
|
131
|
+
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
132
|
+
cssVarBlockName: (name: string) => string;
|
|
133
|
+
};
|
|
134
|
+
disposeValue: import("vue").Ref<string>;
|
|
135
|
+
timer: number | undefined;
|
|
136
|
+
getTime: (val: number) => number;
|
|
137
|
+
stopTimer: () => void;
|
|
138
|
+
startTimer: () => void;
|
|
139
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
140
|
+
finish: () => boolean;
|
|
141
|
+
change: (value: number) => boolean;
|
|
142
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
143
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
144
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
145
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
146
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
147
|
+
readonly value: {
|
|
148
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
149
|
+
readonly required: false;
|
|
150
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
151
|
+
__epPropKey: true;
|
|
152
|
+
};
|
|
153
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
154
|
+
}>> & {
|
|
155
|
+
onChange?: ((value: number) => any) | undefined;
|
|
156
|
+
onFinish?: (() => any) | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
readonly title: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
|
|
159
|
+
readonly prefix: string;
|
|
160
|
+
readonly suffix: string;
|
|
161
|
+
readonly format: string;
|
|
162
|
+
readonly valueStyle: import("vue").StyleValue;
|
|
163
|
+
}>> & Record<string, any>;
|
|
164
|
+
export default ElStatistic;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '../../utils/index.mjs';
|
|
2
|
+
import Statistic from './src/statistic2.mjs';
|
|
3
|
+
import Countdown from './src/countdown2.mjs';
|
|
4
|
+
export { regroup, statisticProps } from './src/statistic.mjs';
|
|
5
|
+
export { countdownEmits, countdownProps, formatTimeStr } from './src/countdown.mjs';
|
|
6
|
+
import { withInstall } from '../../utils/vue/install.mjs';
|
|
7
|
+
|
|
8
|
+
const ElStatistic = withInstall(Statistic);
|
|
9
|
+
const ElCountdown = withInstall(Countdown);
|
|
10
|
+
|
|
11
|
+
export { ElCountdown, ElStatistic, ElStatistic as default };
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/statistic/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Statistic from './src/statistic.vue'\nimport Countdown from './src/countdown.vue'\n\nexport * from './src/statistic'\nexport * from './src/countdown'\n\nexport const ElStatistic = withInstall(Statistic)\nexport const ElCountdown = withInstall(Countdown)\n\nexport default ElStatistic\n"],"names":[],"mappings":";;;;;;;AAKY,MAAC,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE;AACtC,MAAC,WAAW,GAAG,WAAW,CAAC,SAAS;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import type { StyleValue } from 'vue';
|
|
3
|
+
import type Countdown from './countdown.vue';
|
|
4
|
+
export declare const countdownProps: {
|
|
5
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
6
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
7
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
8
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
9
|
+
readonly value: {
|
|
10
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | dayjs.Dayjs) & {}) | (() => number | dayjs.Dayjs) | ((new (...args: any[]) => (number | dayjs.Dayjs) & {}) | (() => number | dayjs.Dayjs))[], unknown, unknown>>;
|
|
11
|
+
readonly required: false;
|
|
12
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
13
|
+
__epPropKey: true;
|
|
14
|
+
};
|
|
15
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => StyleValue & {}) | (() => StyleValue) | ((new (...args: any[]) => StyleValue & {}) | (() => StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
16
|
+
};
|
|
17
|
+
export declare const countdownEmits: {
|
|
18
|
+
finish: () => boolean;
|
|
19
|
+
change: (value: number) => boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const formatTimeStr: (format: any, time: number, futureTime: any) => string;
|
|
22
|
+
export declare type CountdownInstance = InstanceType<typeof Countdown>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { reduce, floor, divide, multiply, padStart } from 'lodash-unified';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import '../../../utils/index.mjs';
|
|
4
|
+
import { buildProps, definePropType } from '../../../utils/vue/props/runtime.mjs';
|
|
5
|
+
|
|
6
|
+
const countdownProps = buildProps({
|
|
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: null
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
value: {
|
|
24
|
+
type: definePropType([Number, Object])
|
|
25
|
+
},
|
|
26
|
+
valueStyle: {
|
|
27
|
+
type: definePropType([String, Object]),
|
|
28
|
+
default: () => ({})
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const countdownEmits = {
|
|
32
|
+
finish: () => true,
|
|
33
|
+
change: (value) => !!value
|
|
34
|
+
};
|
|
35
|
+
const formatTimeStr = function(format, time, futureTime) {
|
|
36
|
+
const timeUnits = [
|
|
37
|
+
["Y", 1e3 * 60 * 60 * 24 * 365],
|
|
38
|
+
["M", 1e3 * 60 * 60 * 24 * 30],
|
|
39
|
+
["D", 1e3 * 60 * 60 * 24],
|
|
40
|
+
["H", 1e3 * 60 * 60],
|
|
41
|
+
["m", 1e3 * 60],
|
|
42
|
+
["s", 1e3],
|
|
43
|
+
["S", 1]
|
|
44
|
+
];
|
|
45
|
+
return reduce(timeUnits, (con, item) => {
|
|
46
|
+
const name = item[0];
|
|
47
|
+
return con.replace(new RegExp(`${name}+`, "g"), (match) => {
|
|
48
|
+
let sum = 0;
|
|
49
|
+
if (name == "M") {
|
|
50
|
+
sum = Math.abs(dayjs().diff(dayjs(futureTime), name));
|
|
51
|
+
time -= Math.abs(dayjs().diff(dayjs().add(sum, "month").format(), "day") * timeUnits[2][1]);
|
|
52
|
+
} else {
|
|
53
|
+
sum = floor(divide(time, item[1]));
|
|
54
|
+
time -= multiply(sum, item[1]);
|
|
55
|
+
}
|
|
56
|
+
sum = padStart(String(sum), String(match).length, "0");
|
|
57
|
+
return sum;
|
|
58
|
+
});
|
|
59
|
+
}, format);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { countdownEmits, countdownProps, formatTimeStr };
|
|
63
|
+
//# sourceMappingURL=countdown.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countdown.mjs","sources":["../../../../../../packages/components/statistic/src/countdown.ts"],"sourcesContent":["import { divide, floor, multiply, padStart, reduce } from 'lodash-unified'\nimport dayjs from 'dayjs'\nimport { buildProps, definePropType } from '@element-plus/utils'\nimport type { StyleValue } from 'vue'\nimport type { Dayjs } from 'dayjs'\nimport type Countdown from './countdown.vue'\nexport const countdownProps = buildProps({\n format: {\n type: String,\n default: 'HH:mm:ss',\n },\n prefix: {\n type: String,\n default: '',\n },\n suffix: {\n type: String,\n default: null,\n },\n title: {\n type: [String, Number],\n default: '',\n },\n value: {\n type: definePropType<number | Dayjs>([Number, Object]),\n },\n valueStyle: {\n type: definePropType<StyleValue>([String, Object]),\n default: () => ({}),\n },\n} as const)\n\nexport const countdownEmits = {\n finish: () => true,\n change: (value: number) => !!value,\n}\n\nexport const formatTimeStr = function (\n format: any,\n time: number,\n futureTime: any\n) {\n const timeUnits: any = [\n ['Y', 1000 * 60 * 60 * 24 * 365], // years\n ['M', 1000 * 60 * 60 * 24 * 30], // months\n ['D', 1000 * 60 * 60 * 24], // days\n ['H', 1000 * 60 * 60], // hours\n ['m', 1000 * 60], // minutes\n ['s', 1000], // seconds\n ['S', 1], // million seconds\n ]\n return reduce(\n timeUnits,\n (con: string, item: any[]) => {\n const name = item[0]\n return con.replace(new RegExp(`${name}+`, 'g'), (match: any) => {\n let sum: any = 0\n if (name == 'M') {\n //Revision of month\n sum = Math.abs(dayjs().diff(dayjs(futureTime), name))\n time -= Math.abs(\n dayjs().diff(dayjs().add(sum, 'month').format(), 'day') *\n timeUnits[2][1]\n )\n } else {\n sum = floor(divide(time, item[1]))\n time -= multiply(sum, item[1])\n }\n sum = padStart(String(sum), String(match).length, '0') // autoCompletion\n return sum\n })\n },\n format\n )\n}\n\nexport type CountdownInstance = InstanceType<typeof Countdown>\n"],"names":[],"mappings":";;;;;AAGY,MAAC,cAAc,GAAG,UAAU,CAAC;AACzC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,UAAU;AACvB,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,IAAI,EAAE,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1C,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,EAAE;AACvB,QAAQ,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9D,QAAQ,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpG,OAAO,MAAM;AACb,QAAQ,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,QAAQ,IAAI,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,OAAO;AACP,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,CAAC;AACjB,KAAK,CAAC,CAAC;AACP,GAAG,EAAE,MAAM,CAAC,CAAC;AACb;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
3
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
4
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
5
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
6
|
+
readonly value: {
|
|
7
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
8
|
+
readonly required: false;
|
|
9
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
10
|
+
__epPropKey: true;
|
|
11
|
+
};
|
|
12
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
13
|
+
}, {
|
|
14
|
+
REFRESH_INTERVAL: number;
|
|
15
|
+
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
17
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
18
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
19
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
20
|
+
readonly value: {
|
|
21
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
22
|
+
readonly required: false;
|
|
23
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
24
|
+
__epPropKey: true;
|
|
25
|
+
};
|
|
26
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
27
|
+
}>> & {
|
|
28
|
+
onChange?: ((value: number) => any) | undefined;
|
|
29
|
+
onFinish?: (() => any) | undefined;
|
|
30
|
+
}>>;
|
|
31
|
+
emit: ((event: "change", value: number) => void) & ((event: "finish") => void);
|
|
32
|
+
ns: {
|
|
33
|
+
namespace: import("vue").Ref<string>;
|
|
34
|
+
b: (blockSuffix?: string) => string;
|
|
35
|
+
e: (element?: string | undefined) => string;
|
|
36
|
+
m: (modifier?: string | undefined) => string;
|
|
37
|
+
be: (blockSuffix?: string | undefined, element?: string | undefined) => string;
|
|
38
|
+
em: (element?: string | undefined, modifier?: string | undefined) => string;
|
|
39
|
+
bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;
|
|
40
|
+
bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;
|
|
41
|
+
is: {
|
|
42
|
+
(name: string, state: boolean | undefined): string;
|
|
43
|
+
(name: string): string;
|
|
44
|
+
};
|
|
45
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
46
|
+
cssVarName: (name: string) => string;
|
|
47
|
+
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
|
|
48
|
+
cssVarBlockName: (name: string) => string;
|
|
49
|
+
};
|
|
50
|
+
disposeValue: import("vue").Ref<string>;
|
|
51
|
+
timer: number | undefined;
|
|
52
|
+
getTime: (val: number) => number;
|
|
53
|
+
stopTimer: () => void;
|
|
54
|
+
startTimer: () => void;
|
|
55
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
56
|
+
finish: () => boolean;
|
|
57
|
+
change: (value: number) => boolean;
|
|
58
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
|
+
readonly format: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "HH:mm:ss", boolean>;
|
|
60
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
61
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
62
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
63
|
+
readonly value: {
|
|
64
|
+
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs) | ((new (...args: any[]) => (number | import("dayjs").Dayjs) & {}) | (() => number | import("dayjs").Dayjs))[], unknown, unknown>>;
|
|
65
|
+
readonly required: false;
|
|
66
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
67
|
+
__epPropKey: true;
|
|
68
|
+
};
|
|
69
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue) | ((new (...args: any[]) => import("vue").StyleValue & {}) | (() => import("vue").StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
70
|
+
}>> & {
|
|
71
|
+
onChange?: ((value: number) => any) | undefined;
|
|
72
|
+
onFinish?: (() => any) | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
readonly title: import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>;
|
|
75
|
+
readonly prefix: string;
|
|
76
|
+
readonly suffix: string;
|
|
77
|
+
readonly format: string;
|
|
78
|
+
readonly valueStyle: import("vue").StyleValue;
|
|
79
|
+
}>;
|
|
80
|
+
export default _default;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { defineComponent, onBeforeUnmount, ref, watch, openBlock, createElementBlock, normalizeClass, unref, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode, normalizeStyle } from 'vue';
|
|
2
|
+
import { isNil } from 'lodash-unified';
|
|
3
|
+
import '../../../hooks/index.mjs';
|
|
4
|
+
import '../../../utils/index.mjs';
|
|
5
|
+
import { countdownProps, countdownEmits, formatTimeStr } from './countdown.mjs';
|
|
6
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
|
|
7
|
+
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
|
|
8
|
+
import { isNumber } from '@vueuse/core';
|
|
9
|
+
|
|
10
|
+
const REFRESH_INTERVAL = 1e3 / 30;
|
|
11
|
+
const __default__ = defineComponent({
|
|
12
|
+
name: "ElCountdown"
|
|
13
|
+
});
|
|
14
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
15
|
+
...__default__,
|
|
16
|
+
props: countdownProps,
|
|
17
|
+
emits: countdownEmits,
|
|
18
|
+
setup(__props, { expose, emit }) {
|
|
19
|
+
const props = __props;
|
|
20
|
+
onBeforeUnmount(() => {
|
|
21
|
+
stopTimer();
|
|
22
|
+
});
|
|
23
|
+
const ns = useNamespace("statistic");
|
|
24
|
+
const disposeValue = ref("");
|
|
25
|
+
let timer;
|
|
26
|
+
const getTime = (val) => {
|
|
27
|
+
return new Date(val).getTime();
|
|
28
|
+
};
|
|
29
|
+
const stopTimer = () => {
|
|
30
|
+
if (timer) {
|
|
31
|
+
clearInterval(timer);
|
|
32
|
+
timer = void 0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const startTimer = () => {
|
|
36
|
+
const { value, format } = props;
|
|
37
|
+
if (isNil(value)) {
|
|
38
|
+
disposeValue.value = "";
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const timestamp = getTime(isNumber(value) ? value : value.valueOf());
|
|
42
|
+
timer = setInterval(() => {
|
|
43
|
+
const diff = timestamp - Date.now();
|
|
44
|
+
emit("change", diff);
|
|
45
|
+
if (diff < 0) {
|
|
46
|
+
stopTimer();
|
|
47
|
+
emit("finish");
|
|
48
|
+
}
|
|
49
|
+
disposeValue.value = formatTimeStr(format, diff, value);
|
|
50
|
+
}, REFRESH_INTERVAL);
|
|
51
|
+
};
|
|
52
|
+
watch(() => [props.value, props.format], () => {
|
|
53
|
+
stopTimer();
|
|
54
|
+
startTimer();
|
|
55
|
+
}, {
|
|
56
|
+
immediate: true
|
|
57
|
+
});
|
|
58
|
+
expose({
|
|
59
|
+
disposeValue
|
|
60
|
+
});
|
|
61
|
+
return (_ctx, _cache) => {
|
|
62
|
+
return openBlock(), createElementBlock("div", {
|
|
63
|
+
class: normalizeClass(unref(ns).b())
|
|
64
|
+
}, [
|
|
65
|
+
!!_ctx.$slots.title || _ctx.title ? (openBlock(), createElementBlock("div", {
|
|
66
|
+
key: 0,
|
|
67
|
+
ref: "title",
|
|
68
|
+
class: normalizeClass(unref(ns).e("head"))
|
|
69
|
+
}, [
|
|
70
|
+
createElementVNode("span", {
|
|
71
|
+
class: normalizeClass(unref(ns).e("title"))
|
|
72
|
+
}, [
|
|
73
|
+
renderSlot(_ctx.$slots, "title", {}, () => [
|
|
74
|
+
createTextVNode(toDisplayString(_ctx.title), 1)
|
|
75
|
+
])
|
|
76
|
+
], 2)
|
|
77
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
78
|
+
createElementVNode("div", {
|
|
79
|
+
class: normalizeClass(unref(ns).e("content"))
|
|
80
|
+
}, [
|
|
81
|
+
!!_ctx.$slots.title || _ctx.prefix ? (openBlock(), createElementBlock("span", {
|
|
82
|
+
key: 0,
|
|
83
|
+
class: normalizeClass(unref(ns).e("prefix"))
|
|
84
|
+
}, [
|
|
85
|
+
renderSlot(_ctx.$slots, "prefix", {}, () => [
|
|
86
|
+
createTextVNode(toDisplayString(_ctx.prefix), 1)
|
|
87
|
+
])
|
|
88
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
89
|
+
_ctx.value ? (openBlock(), createElementBlock("span", {
|
|
90
|
+
key: 1,
|
|
91
|
+
class: normalizeClass(unref(ns).e("number")),
|
|
92
|
+
style: normalizeStyle(_ctx.valueStyle)
|
|
93
|
+
}, [
|
|
94
|
+
renderSlot(_ctx.$slots, "formatter", {}, () => [
|
|
95
|
+
createTextVNode(toDisplayString(disposeValue.value), 1)
|
|
96
|
+
])
|
|
97
|
+
], 6)) : createCommentVNode("v-if", true),
|
|
98
|
+
!!_ctx.$slots.title || _ctx.suffix ? (openBlock(), createElementBlock("span", {
|
|
99
|
+
key: 2,
|
|
100
|
+
class: normalizeClass(unref(ns).e("suffix"))
|
|
101
|
+
}, [
|
|
102
|
+
renderSlot(_ctx.$slots, "suffix", {}, () => [
|
|
103
|
+
createTextVNode(toDisplayString(_ctx.suffix), 1)
|
|
104
|
+
])
|
|
105
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
106
|
+
], 2)
|
|
107
|
+
], 2);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
var Countdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/statistic/src/countdown.vue"]]);
|
|
112
|
+
|
|
113
|
+
export { Countdown as default };
|
|
114
|
+
//# sourceMappingURL=countdown2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countdown2.mjs","sources":["../../../../../../packages/components/statistic/src/countdown.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div v-if=\"!!$slots.title || title\" ref=\"title\" :class=\"ns.e('head')\">\n <span :class=\"ns.e('title')\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </span>\n </div>\n <div :class=\"ns.e('content')\">\n <span v-if=\"!!$slots.title || prefix\" :class=\"ns.e('prefix')\">\n <slot name=\"prefix\">\n {{ prefix }}\n </slot>\n </span>\n <span v-if=\"value\" :class=\"ns.e('number')\" :style=\"valueStyle\">\n <slot name=\"formatter\"> {{ disposeValue }}</slot>\n </span>\n <span v-if=\"!!$slots.title || suffix\" :class=\"ns.e('suffix')\">\n <slot name=\"suffix\">\n {{ suffix }}\n </slot>\n </span>\n </div>\n </div>\n</template>\n<script lang=\"ts\" setup>\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport { isNil } from 'lodash-unified'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isNumber } from '@element-plus/utils'\nimport { countdownEmits, countdownProps, formatTimeStr } from './countdown'\n\nconst REFRESH_INTERVAL = 1000 / 30\n\ndefineOptions({\n name: 'ElCountdown',\n})\nonBeforeUnmount(() => {\n stopTimer()\n})\nconst props = defineProps(countdownProps)\nconst emit = defineEmits(countdownEmits)\nconst ns = useNamespace('statistic')\nconst disposeValue = ref('')\nlet timer: ReturnType<typeof setInterval> | undefined\n\nconst getTime = (val: number) => {\n return new Date(val).getTime()\n}\n\nconst stopTimer = () => {\n if (timer) {\n clearInterval(timer)\n timer = undefined\n }\n}\n\nconst startTimer = () => {\n const { value, format } = props\n if (isNil(value)) {\n disposeValue.value = ''\n return\n }\n const timestamp = getTime(isNumber(value) ? value : value.valueOf())\n timer = setInterval(() => {\n const diff = timestamp - Date.now()\n emit('change', diff)\n if (diff < 0) {\n stopTimer()\n emit('finish')\n }\n disposeValue.value = formatTimeStr(format, diff, value)\n }, REFRESH_INTERVAL)\n}\n\nwatch(\n () => [props.value, props.format],\n () => {\n stopTimer()\n startTimer()\n },\n {\n immediate: true,\n }\n)\n\ndefineExpose({\n disposeValue,\n})\n</script>\n"],"names":[],"mappings":";;;;;;;;;;mCAmCc,CAAA;AAAA,EACZ,IAAM,EAAA,aAAA;AACR;;;;;;;AACA,IAAA,eAAA,CAAgB,MAAM;AACpB,MAAU,SAAA,EAAA,CAAA;AAAA,KACX,CAAA,CAAA;AAGD,IAAM,MAAA,EAAA,GAAK,aAAa,WAAW,CAAA,CAAA;AACnC,IAAM,MAAA,YAAA,GAAe,IAAI,EAAE,CAAA,CAAA;AAC3B,IAAI,IAAA,KAAA,CAAA;AAEJ,IAAM,MAAA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,KAEf,CAAA,CAAA;AAEA,IAAa,MAAA,CAAA;AAAA,MACX,YAAA;AAAA,KACD,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StyleValue } from 'vue';
|
|
2
|
+
import type Statistic from './statistic.vue';
|
|
3
|
+
export declare const statisticProps: {
|
|
4
|
+
readonly decimalSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ".", boolean>;
|
|
5
|
+
readonly groupSeparator: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, ",", boolean>;
|
|
6
|
+
readonly precision: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, null, boolean>;
|
|
7
|
+
readonly formatter: {
|
|
8
|
+
readonly type: import("vue").PropType<(val: string | number) => string | number>;
|
|
9
|
+
readonly required: false;
|
|
10
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
11
|
+
__epPropKey: true;
|
|
12
|
+
};
|
|
13
|
+
readonly value: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, null, boolean>;
|
|
14
|
+
readonly prefix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
15
|
+
readonly suffix: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, null, boolean>;
|
|
16
|
+
readonly title: import("element-plus/es/utils").EpPropFinalized<readonly [StringConstructor, NumberConstructor], unknown, unknown, "", boolean>;
|
|
17
|
+
readonly valueStyle: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => StyleValue & {}) | (() => StyleValue) | ((new (...args: any[]) => StyleValue & {}) | (() => StyleValue))[], unknown, unknown, () => {}, boolean>;
|
|
18
|
+
readonly rate: import("element-plus/es/utils").EpPropFinalized<NumberConstructor, unknown, unknown, 3, boolean>;
|
|
19
|
+
};
|
|
20
|
+
export declare const regroup: (target: any, _mulriple?: number, _groupSeparator?: string) => string;
|
|
21
|
+
export declare type StatisticInstance = InstanceType<typeof Statistic>;
|