@sdata/web-vue 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/sd.css +189 -0
  2. package/dist/sd.min.css +2 -2
  3. package/es/badge/badge.vue.d.ts +2 -0
  4. package/es/badge/badge.vue_vue_type_script_setup_true_lang.js +19 -4
  5. package/es/badge/index.d.ts +3 -0
  6. package/es/bloom-menu/bloom-menu.js +5 -0
  7. package/es/bloom-menu/bloom-menu.vue.d.ts +52 -0
  8. package/es/bloom-menu/bloom-menu.vue_vue_type_script_setup_true_lang.js +380 -0
  9. package/es/bloom-menu/index.d.ts +6 -0
  10. package/es/bloom-menu/index.js +10 -0
  11. package/es/bloom-menu/style/css.js +2 -0
  12. package/es/bloom-menu/style/index.css +135 -0
  13. package/es/bloom-menu/style/index.d.ts +2 -0
  14. package/es/bloom-menu/style/index.js +2 -0
  15. package/es/bloom-menu/style/index.scss +153 -0
  16. package/es/bloom-menu/style/token.scss +24 -0
  17. package/es/bloom-menu/types.d.ts +11 -0
  18. package/es/components.d.ts +3 -0
  19. package/es/index.css +189 -0
  20. package/es/index.d.ts +4 -0
  21. package/es/index.js +5 -1
  22. package/es/index.scss +2 -0
  23. package/es/locale/interface.d.ts +2 -0
  24. package/es/locale/lang/en-us.js +2 -0
  25. package/es/locale/lang/zh-cn.js +2 -0
  26. package/es/number-flow/continuous.d.ts +2 -0
  27. package/es/number-flow/continuous.js +7 -0
  28. package/es/number-flow/formatter.d.ts +15 -0
  29. package/es/number-flow/formatter.js +54 -0
  30. package/es/number-flow/group-key.d.ts +11 -0
  31. package/es/number-flow/group-key.js +4 -0
  32. package/es/number-flow/index.d.ts +63 -0
  33. package/es/number-flow/index.js +15 -0
  34. package/es/number-flow/number-flow-group.js +5 -0
  35. package/es/number-flow/number-flow-group.vue.d.ts +12 -0
  36. package/es/number-flow/number-flow-group.vue_vue_type_script_setup_true_lang.js +58 -0
  37. package/es/number-flow/number-flow.js +5 -0
  38. package/es/number-flow/number-flow.vue.d.ts +20 -0
  39. package/es/number-flow/number-flow.vue_vue_type_script_setup_true_lang.js +284 -0
  40. package/es/number-flow/style/css.js +2 -0
  41. package/es/number-flow/style/index.css +85 -0
  42. package/es/number-flow/style/index.d.ts +2 -0
  43. package/es/number-flow/style/index.js +2 -0
  44. package/es/number-flow/style/index.scss +93 -0
  45. package/es/number-flow/style/token.scss +5 -0
  46. package/es/number-flow/types.d.ts +46 -0
  47. package/es/number-flow/use-can-animate.d.ts +4 -0
  48. package/es/number-flow/use-can-animate.js +30 -0
  49. package/es/rich-text-editor/index.d.ts +3 -3
  50. package/es/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  51. package/es/sd-vue.js +5 -0
  52. package/es/statistic/countdown.vue.d.ts +9 -0
  53. package/es/statistic/countdown.vue_vue_type_script_setup_true_lang.js +29 -2
  54. package/es/statistic/index.d.ts +15 -0
  55. package/es/statistic/statistic.vue.d.ts +3 -3
  56. package/es/statistic/statistic.vue_vue_type_script_setup_true_lang.js +31 -62
  57. package/es/statistic/style/index.css +3 -0
  58. package/es/statistic/style/index.scss +5 -0
  59. package/json/vetur-attributes.json +8 -0
  60. package/json/vetur-tags.json +12 -1
  61. package/json/web-types.json +35 -1
  62. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ @use 'sass:string';
2
+ @use '@style/theme/index.scss' as theme;
3
+ @use '@components/number-flow/style/token.scss' as *;
4
+
5
+ $number-flow-prefix-cls: string.unquote('#{theme.$prefix}-number-flow');
6
+
7
+ .#{$number-flow-prefix-cls} {
8
+ display: inline-flex;
9
+ align-items: baseline;
10
+ line-height: 1;
11
+ direction: ltr;
12
+ white-space: nowrap;
13
+ isolation: isolate;
14
+
15
+ &-content,
16
+ &-part,
17
+ &-digit-track,
18
+ &-digit-value,
19
+ &-symbol {
20
+ display: inline-block;
21
+ }
22
+
23
+ &-content {
24
+ margin: calc(-1 * $number-flow-mask-height) calc(-1 * $number-flow-mask-width);
25
+ padding: $number-flow-mask-height $number-flow-mask-width;
26
+ overflow: hidden;
27
+ }
28
+
29
+ &-part {
30
+ position: relative;
31
+ vertical-align: bottom;
32
+ }
33
+
34
+ &-digit {
35
+ height: 1em;
36
+ overflow: hidden;
37
+ }
38
+
39
+ &-digit-track {
40
+ display: flex;
41
+ flex-direction: column;
42
+ height: 1em;
43
+ transform: translateY(calc(1em * var(--sd-number-flow-start)));
44
+ }
45
+
46
+ &-digit-value {
47
+ flex: 0 0 1em;
48
+ height: 1em;
49
+ line-height: 1;
50
+ text-align: center;
51
+ font-variant-numeric: tabular-nums;
52
+ }
53
+
54
+ &-prepared &-digit-track {
55
+ transition: none;
56
+ }
57
+
58
+ &-animating &-digit-track {
59
+ transform: translateY(calc(1em * var(--sd-number-flow-end)));
60
+ transition:
61
+ transform var(--sd-number-flow-spin-duration, var(--sd-number-flow-duration))
62
+ var(--sd-number-flow-spin-easing, var(--sd-number-flow-easing)),
63
+ opacity var(--sd-number-flow-opacity-duration) ease-out;
64
+ }
65
+
66
+ &-symbol {
67
+ white-space: pre;
68
+ }
69
+
70
+ &-will-change :is(&-content, &-part, &-digit-track, &-symbol) {
71
+ will-change: transform;
72
+ }
73
+
74
+ &-custom-prefix {
75
+ margin-right: $number-flow-gap;
76
+ }
77
+
78
+ &-custom-suffix {
79
+ margin-left: $number-flow-gap;
80
+ }
81
+ }
82
+
83
+ .#{$number-flow-prefix-cls}-group {
84
+ display: inline-flex;
85
+ gap: $number-flow-gap;
86
+ align-items: baseline;
87
+ }
88
+
89
+ @media (prefers-reduced-motion: reduce) {
90
+ .#{$number-flow-prefix-cls}-digit-track {
91
+ transition: none;
92
+ }
93
+ }
@@ -0,0 +1,5 @@
1
+ @use '@style/theme/index.scss' as global;
2
+
3
+ $number-flow-gap: global.$spacing-2;
4
+ $number-flow-mask-height: 0.25em;
5
+ $number-flow-mask-width: 0.2em;
@@ -0,0 +1,46 @@
1
+ import type { CSSProperties } from 'vue';
2
+ export type NumberFlowValue = number | string;
3
+ export type NumberFlowFormat = Omit<Intl.NumberFormatOptions, 'notation'> & {
4
+ notation?: Exclude<Intl.NumberFormatOptions['notation'], 'scientific' | 'engineering'>;
5
+ };
6
+ export type NumberFlowTrend = number | ((oldValue: number, value: number) => number);
7
+ export type NumberFlowDigitOptions = {
8
+ max?: number;
9
+ };
10
+ export type NumberFlowDigits = Record<number, NumberFlowDigitOptions>;
11
+ export interface NumberFlowDigitContext {
12
+ position: number;
13
+ length: number;
14
+ trend: number;
15
+ highestChangedPosition?: number;
16
+ }
17
+ export interface NumberFlowPluginContext {
18
+ value: number;
19
+ previousValue: number;
20
+ trend: number;
21
+ }
22
+ export interface NumberFlowPlugin {
23
+ onUpdate?(context: NumberFlowPluginContext): void;
24
+ getDelta?(value: number, previousValue: number, context: NumberFlowDigitContext): number | void;
25
+ }
26
+ export interface NumberFlowProps {
27
+ value: NumberFlowValue;
28
+ locales?: Intl.LocalesArgument;
29
+ format?: NumberFlowFormat;
30
+ prefix?: string;
31
+ suffix?: string;
32
+ trend?: NumberFlowTrend;
33
+ plugins?: NumberFlowPlugin[];
34
+ animated?: boolean;
35
+ transformTiming?: KeyframeAnimationOptions;
36
+ spinTiming?: KeyframeAnimationOptions;
37
+ opacityTiming?: KeyframeAnimationOptions;
38
+ respectMotionPreference?: boolean;
39
+ digits?: NumberFlowDigits;
40
+ willChange?: boolean;
41
+ nonce?: string;
42
+ }
43
+ export interface NumberFlowExposed {
44
+ el: HTMLElement | null;
45
+ }
46
+ export type NumberFlowStyle = CSSProperties & Record<`--${string}`, string | number>;
@@ -0,0 +1,4 @@
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ export declare function useCanAnimate({ respectMotionPreference, }?: {
3
+ respectMotionPreference?: MaybeRefOrGetter<boolean>;
4
+ }): import("vue").ComputedRef<boolean>;
@@ -0,0 +1,30 @@
1
+ import { computed, onMounted, shallowRef, toValue, watchEffect } from "vue";
2
+ //#region components/number-flow/use-can-animate.ts
3
+ /**
4
+ * SSR-safe composable that returns whether number-flow animations can run.
5
+ * Respects `prefers-reduced-motion` and listens for changes.
6
+ */
7
+ function useCanAnimate({ respectMotionPreference = true } = {}) {
8
+ const canAnimate = shallowRef(false);
9
+ const reducedMotion = shallowRef(false);
10
+ const mediaQuery = shallowRef();
11
+ onMounted(() => {
12
+ canAnimate.value = typeof window !== "undefined";
13
+ mediaQuery.value = window.matchMedia("(prefers-reduced-motion: reduce)");
14
+ reducedMotion.value = mediaQuery.value.matches;
15
+ });
16
+ watchEffect((onCleanup) => {
17
+ if (!toValue(respectMotionPreference)) return;
18
+ const onChange = ({ matches }) => {
19
+ reducedMotion.value = matches;
20
+ };
21
+ const query = mediaQuery.value;
22
+ query === null || query === void 0 || query.addEventListener("change", onChange);
23
+ onCleanup(() => {
24
+ query === null || query === void 0 || query.removeEventListener("change", onChange);
25
+ });
26
+ });
27
+ return computed(() => canAnimate.value && (!toValue(respectMotionPreference) || !reducedMotion.value));
28
+ }
29
+ //#endregion
30
+ export { useCanAnimate };
@@ -54,8 +54,8 @@ declare const RichTextEditor: {
54
54
  }, import("vue").PublicProps, {
55
55
  classNames: Partial<Record<import("./types").RichTextEditorSemanticType, string>>;
56
56
  autoSize: boolean | import("./types").RichTextEditorAutoSize;
57
- styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
58
57
  plugins: readonly import("./types").RichTextEditorPlugin[];
58
+ styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
59
59
  transformers: readonly import("@lexical/markdown").Transformer[];
60
60
  history: boolean;
61
61
  historyDelay: number;
@@ -112,8 +112,8 @@ declare const RichTextEditor: {
112
112
  }, {}, {}, {}, {
113
113
  classNames: Partial<Record<import("./types").RichTextEditorSemanticType, string>>;
114
114
  autoSize: boolean | import("./types").RichTextEditorAutoSize;
115
- styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
116
115
  plugins: readonly import("./types").RichTextEditorPlugin[];
116
+ styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
117
117
  transformers: readonly import("@lexical/markdown").Transformer[];
118
118
  history: boolean;
119
119
  historyDelay: number;
@@ -175,8 +175,8 @@ declare const RichTextEditor: {
175
175
  }, string, {
176
176
  classNames: Partial<Record<import("./types").RichTextEditorSemanticType, string>>;
177
177
  autoSize: boolean | import("./types").RichTextEditorAutoSize;
178
- styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
179
178
  plugins: readonly import("./types").RichTextEditorPlugin[];
179
+ styles: Partial<Record<import("./types").RichTextEditorSemanticType, import("vue").CSSProperties>>;
180
180
  transformers: readonly import("@lexical/markdown").Transformer[];
181
181
  history: boolean;
182
182
  historyDelay: number;
@@ -58,8 +58,8 @@ declare const __VLS_base: import("vue").DefineComponent<RichTextEditorProps, {
58
58
  }>, {
59
59
  classNames: Partial<Record<import("./types").RichTextEditorSemanticType, string>>;
60
60
  autoSize: boolean | import("./types").RichTextEditorAutoSize;
61
- styles: Partial<Record<import("./types").RichTextEditorSemanticType, CSSProperties>>;
62
61
  plugins: readonly import("./types").RichTextEditorPlugin[];
62
+ styles: Partial<Record<import("./types").RichTextEditorSemanticType, CSSProperties>>;
63
63
  transformers: readonly import("@lexical/markdown").Transformer[];
64
64
  history: boolean;
65
65
  historyDelay: number;
package/es/sd-vue.js CHANGED
@@ -21,6 +21,7 @@ import Popover from "./popover/index.js";
21
21
  import avatar_group_default from "./avatar/avatar-group.js";
22
22
  import Avatar from "./avatar/index.js";
23
23
  import BackTop from "./back-top/index.js";
24
+ import NumberFlow, { NumberFlowGroup } from "./number-flow/index.js";
24
25
  import Badge from "./badge/index.js";
25
26
  import Ellipsis, { PerformantEllipsis } from "./ellipsis/index.js";
26
27
  import Link from "./link/index.js";
@@ -74,6 +75,7 @@ import JsonForm from "./json-form/index.js";
74
75
  import Toolbar from "./toolbar/index.js";
75
76
  import Modal from "./modal/index.js";
76
77
  import BasicCrudTable from "./basic-crud-table/index.js";
78
+ import BloomMenu from "./bloom-menu/index.js";
77
79
  import BorderBeam from "./border-beam/index.js";
78
80
  import dropdown_button_default from "./dropdown/dropdown-button.js";
79
81
  import dropdown_group_default from "./dropdown/dropdown-group.js";
@@ -218,6 +220,7 @@ var components = {
218
220
  Modal,
219
221
  ModelSelector,
220
222
  Notification,
223
+ NumberFlow,
221
224
  Popconfirm,
222
225
  Progress,
223
226
  QrCode,
@@ -237,6 +240,7 @@ var components = {
237
240
  Anchor,
238
241
  BackTop,
239
242
  BorderBeam,
243
+ BloomMenu,
240
244
  ConfigProvider,
241
245
  ThemeProvider,
242
246
  ResizeBox,
@@ -299,6 +303,7 @@ var SDVue = _objectSpread2(_objectSpread2({}, components), {}, {
299
303
  SkeletonLine: line_default,
300
304
  SkeletonShape: shape_default,
301
305
  Countdown: countdown_default,
306
+ NumberFlowGroup,
302
307
  Step: step_default,
303
308
  Thead: table_thead_default,
304
309
  Td: table_td_default,
@@ -21,6 +21,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
21
21
  type: BooleanConstructor;
22
22
  default: boolean;
23
23
  };
24
+ animation: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
24
28
  valueStyle: {
25
29
  type: PropType<CSSProperties>;
26
30
  };
@@ -44,6 +48,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
44
48
  type: BooleanConstructor;
45
49
  default: boolean;
46
50
  };
51
+ animation: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
47
55
  valueStyle: {
48
56
  type: PropType<CSSProperties>;
49
57
  };
@@ -52,6 +60,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
52
60
  }>, {
53
61
  value: number;
54
62
  start: boolean;
63
+ animation: boolean;
55
64
  format: string;
56
65
  now: number;
57
66
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,7 +1,8 @@
1
1
  import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/objectSpread2.js";
2
2
  import { getPrefixCls } from "../_utils/global-config.js";
3
+ import NumberFlow from "../number-flow/index.js";
3
4
  import { getDateString } from "./utils.js";
4
- import { createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, toDisplayString, toRefs, unref, watch } from "vue";
5
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, toDisplayString, toRefs, unref, watch } from "vue";
5
6
  import originDayjs from "dayjs";
6
7
  //#region components/statistic/countdown.vue?vue&type=script&setup=true&lang.ts
7
8
  var countdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "Countdown" }), {}, {
@@ -45,6 +46,14 @@ var countdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
45
46
  default: true
46
47
  },
47
48
  /**
49
+ * @zh 是否开启数字切换动画
50
+ * @en Whether to enable the number transition animation
51
+ */
52
+ animation: {
53
+ type: Boolean,
54
+ default: true
55
+ },
56
+ /**
48
57
  * @zh 自定义显示值的样式
49
58
  * @en Custom value style
50
59
  * @version 2.32.0
@@ -63,6 +72,10 @@ var countdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
63
72
  const prefixCls = getPrefixCls("statistic");
64
73
  const { start, value, now, format } = toRefs(props);
65
74
  const displayValue = ref(getDateString(Math.max(originDayjs(props.value).diff(originDayjs(props.now), "millisecond"), 0), props.format));
75
+ const displayParts = computed(() => displayValue.value.split(/(\d+)/).flatMap((value) => value ? [{
76
+ type: /^\d+$/.test(value) ? "number" : "text",
77
+ value
78
+ }] : []));
66
79
  watch([
67
80
  value,
68
81
  now,
@@ -105,7 +118,21 @@ var countdown_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
105
118
  }, [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(__props.title), 1)])], 2)) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass(`${unref(prefixCls)}-content`) }, [createElementVNode("div", {
106
119
  class: normalizeClass(`${unref(prefixCls)}-value`),
107
120
  style: normalizeStyle(__props.valueStyle)
108
- }, toDisplayString(displayValue.value), 7)], 2)], 2);
121
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(displayParts.value, (part, index) => {
122
+ return openBlock(), createElementBlock(Fragment, { key: `${part.type}-${index}` }, [part.type === "number" ? (openBlock(), createBlock(unref(NumberFlow), {
123
+ key: 0,
124
+ value: Number(part.value),
125
+ animated: __props.animation,
126
+ format: {
127
+ minimumIntegerDigits: part.value.length,
128
+ useGrouping: false
129
+ }
130
+ }, null, 8, [
131
+ "value",
132
+ "animated",
133
+ "format"
134
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(part.value), 1)], 64))], 64);
135
+ }), 128))], 6)], 2)], 2);
109
136
  };
110
137
  }
111
138
  }));
@@ -191,6 +191,10 @@ declare const Statistic: {
191
191
  type: BooleanConstructor;
192
192
  default: boolean;
193
193
  };
194
+ animation: {
195
+ type: BooleanConstructor;
196
+ default: boolean;
197
+ };
194
198
  valueStyle: {
195
199
  type: import("vue").PropType<import("vue").CSSProperties>;
196
200
  };
@@ -201,6 +205,7 @@ declare const Statistic: {
201
205
  }, import("vue").PublicProps, {
202
206
  value: number;
203
207
  start: boolean;
208
+ animation: boolean;
204
209
  format: string;
205
210
  now: number;
206
211
  }, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
@@ -228,6 +233,10 @@ declare const Statistic: {
228
233
  type: BooleanConstructor;
229
234
  default: boolean;
230
235
  };
236
+ animation: {
237
+ type: BooleanConstructor;
238
+ default: boolean;
239
+ };
231
240
  valueStyle: {
232
241
  type: import("vue").PropType<import("vue").CSSProperties>;
233
242
  };
@@ -236,6 +245,7 @@ declare const Statistic: {
236
245
  }>, {}, {}, {}, {}, {
237
246
  value: number;
238
247
  start: boolean;
248
+ animation: boolean;
239
249
  format: string;
240
250
  now: number;
241
251
  }>;
@@ -260,6 +270,10 @@ declare const Statistic: {
260
270
  type: BooleanConstructor;
261
271
  default: boolean;
262
272
  };
273
+ animation: {
274
+ type: BooleanConstructor;
275
+ default: boolean;
276
+ };
263
277
  valueStyle: {
264
278
  type: import("vue").PropType<import("vue").CSSProperties>;
265
279
  };
@@ -270,6 +284,7 @@ declare const Statistic: {
270
284
  }, string, {
271
285
  value: number;
272
286
  start: boolean;
287
+ animation: boolean;
273
288
  format: string;
274
289
  now: number;
275
290
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
@@ -1,13 +1,13 @@
1
1
  import { CSSProperties, PropType } from 'vue';
2
- declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {}, __VLS_7: {};
2
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_10: {}, __VLS_12: {};
3
3
  type __VLS_Slots = {} & {
4
4
  title?: (props: typeof __VLS_1) => any;
5
5
  } & {
6
6
  prefix?: (props: typeof __VLS_3) => any;
7
7
  } & {
8
- suffix?: (props: typeof __VLS_5) => any;
8
+ suffix?: (props: typeof __VLS_10) => any;
9
9
  } & {
10
- extra?: (props: typeof __VLS_7) => any;
10
+ extra?: (props: typeof __VLS_12) => any;
11
11
  };
12
12
  declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
13
  title: StringConstructor;
@@ -1,9 +1,9 @@
1
1
  import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/objectSpread2.js";
2
2
  import { getPrefixCls } from "../_utils/global-config.js";
3
3
  import { isNumber, isUndefined } from "../_utils/is.js";
4
- import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, openBlock, ref, renderSlot, toDisplayString, toRefs, unref, watch } from "vue";
5
- import BTween from "b-tween";
6
- import NP from "number-precision";
4
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/asyncToGenerator.js";
5
+ import NumberFlow from "../number-flow/index.js";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, onMounted, openBlock, renderSlot, shallowRef, toDisplayString, unref, watch } from "vue";
7
7
  import originDayjs from "dayjs";
8
8
  //#region components/statistic/statistic.vue?vue&type=script&setup=true&lang.ts
9
9
  var _hoisted_1 = { key: 0 };
@@ -68,7 +68,7 @@ var statistic_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
68
68
  */
69
69
  animation: {
70
70
  type: Boolean,
71
- default: false
71
+ default: true
72
72
  },
73
73
  /**
74
74
  * @zh 动画的过度时间
@@ -100,7 +100,6 @@ var statistic_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
100
100
  valueStyle: { type: Object }
101
101
  },
102
102
  setup(__props) {
103
- var _props$valueFrom;
104
103
  const props = __props;
105
104
  /**
106
105
  * @zh 标题
@@ -123,63 +122,25 @@ var statistic_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
123
122
  * @slot suffix
124
123
  */
125
124
  const prefixCls = getPrefixCls("statistic");
126
- const numberValue = computed(() => {
127
- if (isNumber(props.value)) return props.value;
128
- return 0;
129
- });
130
- const innerValue = ref((_props$valueFrom = props.valueFrom) !== null && _props$valueFrom !== void 0 ? _props$valueFrom : props.value);
131
- const tween = ref(null);
132
- const { value } = toRefs(props);
133
125
  const showPlaceholder = computed(() => isUndefined(props.value));
134
- const animation = (from = ((_props$valueFrom2) => (_props$valueFrom2 = props.valueFrom) !== null && _props$valueFrom2 !== void 0 ? _props$valueFrom2 : 0)(), to = numberValue.value) => {
135
- if (from !== to) {
136
- var _tween$value;
137
- tween.value = new BTween({
138
- from: { value: from },
139
- to: { value: to },
140
- duration: props.animationDuration,
141
- easing: "quartOut",
142
- onUpdate: (keys) => {
143
- innerValue.value = keys.value;
144
- },
145
- onFinish: () => {
146
- innerValue.value = to;
147
- }
148
- });
149
- (_tween$value = tween.value) === null || _tween$value === void 0 || _tween$value.start();
150
- }
151
- };
152
- const formatValue = computed(() => {
153
- let _value = innerValue.value;
154
- if (isNumber(_value)) {
155
- if (isNumber(props.precision)) _value = NP.round(_value, props.precision).toFixed(props.precision);
156
- const splitValue = String(_value).split(".");
157
- return {
158
- isNumber: true,
159
- integer: props.showGroupSeparator ? Number(splitValue[0]).toLocaleString("en-US") : splitValue[0],
160
- decimal: splitValue[1]
161
- };
126
+ const displayValue = shallowRef(props.animation && props.valueFrom !== void 0 ? props.valueFrom : props.value);
127
+ const numberFormat = computed(() => ({
128
+ minimumFractionDigits: props.precision,
129
+ maximumFractionDigits: props.precision,
130
+ useGrouping: props.showGroupSeparator
131
+ }));
132
+ const formattedDateValue = computed(() => props.format ? originDayjs(displayValue.value).format(props.format) : displayValue.value);
133
+ onMounted(_asyncToGenerator(function* () {
134
+ if (props.animation && props.start && props.valueFrom !== void 0) {
135
+ yield nextTick();
136
+ displayValue.value = props.value;
162
137
  }
163
- if (props.format) _value = originDayjs(_value).format(props.format);
164
- return {
165
- isNumber: false,
166
- value: _value
167
- };
168
- });
169
- onMounted(() => {
170
- if (props.animation && props.start) animation();
171
- });
138
+ }));
172
139
  watch(() => props.start, (value) => {
173
- if (value && props.animation && !tween.value) animation();
140
+ if (value) displayValue.value = props.value;
174
141
  });
175
- watch(value, (val) => {
176
- if (tween.value) {
177
- var _tween$value$stop, _tween$value2;
178
- (_tween$value$stop = (_tween$value2 = tween.value).stop) === null || _tween$value$stop === void 0 || _tween$value$stop.call(_tween$value2);
179
- tween.value = null;
180
- }
181
- innerValue.value = val;
182
- if (props.animation && props.start) animation();
142
+ watch(() => props.value, (value) => {
143
+ displayValue.value = value;
183
144
  });
184
145
  return (_ctx, _cache) => {
185
146
  return openBlock(), createElementBlock("div", { class: normalizeClass(unref(prefixCls)) }, [__props.title || _ctx.$slots.title ? (openBlock(), createElementBlock("div", {
@@ -193,10 +154,18 @@ var statistic_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
193
154
  key: 0,
194
155
  class: normalizeClass(`${unref(prefixCls)}-prefix`)
195
156
  }, [renderSlot(_ctx.$slots, "prefix")], 2)) : createCommentVNode("", true),
196
- formatValue.value.isNumber ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("span", { class: normalizeClass(`${unref(prefixCls)}-value-integer`) }, toDisplayString(formatValue.value.integer), 3), formatValue.value.decimal ? (openBlock(), createElementBlock("span", {
197
- key: 0,
198
- class: normalizeClass(`${unref(prefixCls)}-value-decimal`)
199
- }, " ." + toDisplayString(formatValue.value.decimal), 3)) : createCommentVNode("", true)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [createTextVNode(toDisplayString(formatValue.value.value), 1)], 64)),
157
+ unref(isNumber)(displayValue.value) ? (openBlock(), createBlock(unref(NumberFlow), {
158
+ key: 1,
159
+ value: displayValue.value,
160
+ animated: __props.animation,
161
+ format: numberFormat.value,
162
+ "transform-timing": { duration: __props.animationDuration }
163
+ }, null, 8, [
164
+ "value",
165
+ "animated",
166
+ "format",
167
+ "transform-timing"
168
+ ])) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [createTextVNode(toDisplayString(formattedDateValue.value), 1)], 64)),
200
169
  _ctx.$slots.suffix ? (openBlock(), createElementBlock("span", {
201
170
  key: 3,
202
171
  class: normalizeClass(`${unref(prefixCls)}-suffix`)
@@ -35,6 +35,9 @@
35
35
  font-size: inherit;
36
36
  white-space: nowrap;
37
37
  }
38
+ .sd-statistic-content .sd-statistic-value .sd-number-flow-fraction {
39
+ font-size: inherit;
40
+ }
38
41
  .sd-statistic-content .sd-statistic-value-decimal {
39
42
  display: inline-block;
40
43
  font-size: inherit;
@@ -3,6 +3,7 @@
3
3
  @use '@components/statistic/style/token.scss' as *;
4
4
 
5
5
  $statistic-prefix-cls: string.unquote('#{theme.$prefix}-statistic');
6
+ $number-flow-prefix-cls: string.unquote('#{theme.$prefix}-number-flow');
6
7
 
7
8
  .#{$statistic-prefix-cls} {
8
9
  display: inline-block;
@@ -27,6 +28,10 @@ $statistic-prefix-cls: string.unquote('#{theme.$prefix}-statistic');
27
28
  white-space: nowrap;
28
29
  }
29
30
 
31
+ .#{$number-flow-prefix-cls}-fraction {
32
+ font-size: $statistic-font-decimal-size;
33
+ }
34
+
30
35
  &-decimal {
31
36
  display: inline-block;
32
37
  font-size: $statistic-font-decimal-size;
@@ -200,6 +200,10 @@
200
200
  "description": "Number to show in badge",
201
201
  "type": "number"
202
202
  },
203
+ "sd-badge/animation": {
204
+ "description": "Whether to enable the number transition animation",
205
+ "type": "boolean"
206
+ },
203
207
  "sd-breadcrumb-item/separator": {
204
208
  "description": "Delimiter text"
205
209
  },
@@ -2507,6 +2511,10 @@
2507
2511
  "description": "Whether to start the countdown",
2508
2512
  "type": "boolean"
2509
2513
  },
2514
+ "sd-countdown/animation": {
2515
+ "description": "Whether to enable the number transition animation",
2516
+ "type": "boolean"
2517
+ },
2510
2518
  "sd-countdown/value-style": {
2511
2519
  "description": "Custom value style"
2512
2520
  },
@@ -88,12 +88,16 @@
88
88
  "offset",
89
89
  "color",
90
90
  "status",
91
- "count"
91
+ "count",
92
+ "animation"
92
93
  ]
93
94
  },
94
95
  "sd-basic-crud-table": {
95
96
  "attributes": []
96
97
  },
98
+ "sd-bloom-menu": {
99
+ "attributes": []
100
+ },
97
101
  "sd-border-beam": {
98
102
  "attributes": []
99
103
  },
@@ -887,6 +891,12 @@
887
891
  "reset-query-on-close"
888
892
  ]
889
893
  },
894
+ "sd-number-flow-group": {
895
+ "attributes": []
896
+ },
897
+ "sd-number-flow": {
898
+ "attributes": []
899
+ },
890
900
  "sd-page-header": {
891
901
  "attributes": [
892
902
  "title",
@@ -1162,6 +1172,7 @@
1162
1172
  "now",
1163
1173
  "format",
1164
1174
  "start",
1175
+ "animation",
1165
1176
  "value-style"
1166
1177
  ]
1167
1178
  },