@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,15 @@
1
+ import type { NumberFlowValue } from './types';
2
+ export type NumberFlowPartType = Exclude<Intl.NumberFormatPartTypes, 'minusSign' | 'plusSign'> | 'sign' | 'prefix' | 'suffix';
3
+ export interface NumberFlowPart {
4
+ key: string;
5
+ type: NumberFlowPartType;
6
+ value: string;
7
+ digit?: number;
8
+ position?: number;
9
+ }
10
+ export interface NumberFlowData {
11
+ parts: NumberFlowPart[];
12
+ value: number;
13
+ valueAsString: string;
14
+ }
15
+ export declare function formatNumberFlow(value: NumberFlowValue, formatter: Intl.NumberFormat, prefix?: string, suffix?: string): NumberFlowData;
@@ -0,0 +1,54 @@
1
+ //#region components/number-flow/formatter.ts
2
+ function formatNumberFlow(value, formatter, prefix, suffix) {
3
+ const numericValue = typeof value === "string" ? Number.parseFloat(value) : value;
4
+ const rawParts = formatter.formatToParts(numericValue);
5
+ const integerDigits = rawParts.filter((part) => part.type === "integer").reduce((count, part) => count + part.value.length, 0);
6
+ const counts = /* @__PURE__ */ new Map();
7
+ let integerPosition = integerDigits - 1;
8
+ let fractionPosition = -1;
9
+ const nextKey = (type) => {
10
+ var _counts$get;
11
+ const index = (_counts$get = counts.get(type)) !== null && _counts$get !== void 0 ? _counts$get : 0;
12
+ counts.set(type, index + 1);
13
+ return `${type}:${index}`;
14
+ };
15
+ const parts = [];
16
+ if (prefix) parts.push({
17
+ key: nextKey("prefix"),
18
+ type: "prefix",
19
+ value: prefix
20
+ });
21
+ for (const part of rawParts) {
22
+ const type = part.type === "minusSign" || part.type === "plusSign" ? "sign" : part.type;
23
+ if (type === "integer" || type === "fraction") {
24
+ for (const character of part.value) {
25
+ const position = type === "integer" ? integerPosition-- : fractionPosition--;
26
+ parts.push({
27
+ key: `${type}:${position}`,
28
+ type,
29
+ value: character,
30
+ digit: Number(character),
31
+ position
32
+ });
33
+ }
34
+ continue;
35
+ }
36
+ parts.push({
37
+ key: nextKey(type),
38
+ type,
39
+ value: part.value
40
+ });
41
+ }
42
+ if (suffix) parts.push({
43
+ key: nextKey("suffix"),
44
+ type: "suffix",
45
+ value: suffix
46
+ });
47
+ return {
48
+ parts,
49
+ value: numericValue,
50
+ valueAsString: `${prefix !== null && prefix !== void 0 ? prefix : ""}${formatter.format(numericValue)}${suffix !== null && suffix !== void 0 ? suffix : ""}`
51
+ };
52
+ }
53
+ //#endregion
54
+ export { formatNumberFlow };
@@ -0,0 +1,11 @@
1
+ import type { ComputedRef, InjectionKey } from 'vue';
2
+ import type { NumberFlowValue } from './types';
3
+ export interface GroupChild {
4
+ value: ComputedRef<NumberFlowValue>;
5
+ prepare: () => number | undefined;
6
+ commit: (version: number) => boolean;
7
+ start: (version: number) => void;
8
+ }
9
+ export declare const GROUP_KEY: InjectionKey<{
10
+ register: (child: GroupChild) => () => void;
11
+ }>;
@@ -0,0 +1,4 @@
1
+ //#region components/number-flow/group-key.ts
2
+ var GROUP_KEY = Symbol("NumberFlowGroup");
3
+ //#endregion
4
+ export { GROUP_KEY };
@@ -0,0 +1,63 @@
1
+ import type { App } from 'vue';
2
+ import type { SDOptions } from '../_utils/types';
3
+ import { continuous } from './continuous';
4
+ import _NumberFlowGroup from './number-flow-group.vue';
5
+ import _NumberFlow from './number-flow.vue';
6
+ export { useCanAnimate } from './use-can-animate';
7
+ declare const NumberFlow: {
8
+ new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./types").NumberFlowProps> & Readonly<{
9
+ onAnimationsstart?: (() => any) | undefined;
10
+ onAnimationsfinish?: (() => any) | undefined;
11
+ }>, import("./types").NumberFlowExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
+ animationsstart: () => any;
13
+ animationsfinish: () => any;
14
+ }, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
15
+ P: {};
16
+ B: {};
17
+ D: {};
18
+ C: {};
19
+ M: {};
20
+ Defaults: {};
21
+ }, Readonly<import("./types").NumberFlowProps> & Readonly<{
22
+ onAnimationsstart?: (() => any) | undefined;
23
+ onAnimationsfinish?: (() => any) | undefined;
24
+ }>, import("./types").NumberFlowExposed, {}, {}, {}, {}>;
25
+ __isFragment?: never;
26
+ __isTeleport?: never;
27
+ __isSuspense?: never;
28
+ } & import("vue").ComponentOptionsBase<Readonly<import("./types").NumberFlowProps> & Readonly<{
29
+ onAnimationsstart?: (() => any) | undefined;
30
+ onAnimationsfinish?: (() => any) | undefined;
31
+ }>, import("./types").NumberFlowExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
+ animationsstart: () => any;
33
+ animationsfinish: () => any;
34
+ }, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
35
+ $slots: {
36
+ prefix(): unknown;
37
+ suffix(): unknown;
38
+ };
39
+ }) & {
40
+ install: (app: App, options?: SDOptions) => void;
41
+ };
42
+ declare const NumberFlowGroup: {
43
+ new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
44
+ P: {};
45
+ B: {};
46
+ D: {};
47
+ C: {};
48
+ M: {};
49
+ Defaults: {};
50
+ }, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, {}>;
51
+ __isFragment?: never;
52
+ __isTeleport?: never;
53
+ __isSuspense?: never;
54
+ } & import("vue").ComponentOptionsBase<Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
55
+ $slots: {
56
+ default(): unknown;
57
+ };
58
+ });
59
+ export { NumberFlowGroup, continuous };
60
+ export type NumberFlowInstance = InstanceType<typeof _NumberFlow>;
61
+ export type NumberFlowGroupInstance = InstanceType<typeof _NumberFlowGroup>;
62
+ export type { NumberFlowDigitContext, NumberFlowDigitOptions, NumberFlowDigits, NumberFlowExposed, NumberFlowFormat, NumberFlowPlugin, NumberFlowPluginContext, NumberFlowProps, NumberFlowStyle, NumberFlowTrend, NumberFlowValue, } from './types';
63
+ export default NumberFlow;
@@ -0,0 +1,15 @@
1
+ import { getComponentPrefix, setGlobalConfig } from "../_utils/global-config.js";
2
+ import { continuous } from "./continuous.js";
3
+ import number_flow_group_default from "./number-flow-group.js";
4
+ import { useCanAnimate } from "./use-can-animate.js";
5
+ import number_flow_default from "./number-flow.js";
6
+ //#region components/number-flow/index.ts
7
+ var NumberFlow = Object.assign(number_flow_default, { install: (app, options) => {
8
+ setGlobalConfig(app, options);
9
+ const componentPrefix = getComponentPrefix(options);
10
+ app.component(componentPrefix + number_flow_default.name, number_flow_default);
11
+ app.component(componentPrefix + number_flow_group_default.name, number_flow_group_default);
12
+ } });
13
+ var NumberFlowGroup = number_flow_group_default;
14
+ //#endregion
15
+ export { NumberFlowGroup, continuous, NumberFlow as default, useCanAnimate };
@@ -0,0 +1,5 @@
1
+ import number_flow_group_vue_vue_type_script_setup_true_lang_default from "./number-flow-group.vue_vue_type_script_setup_true_lang.js";
2
+ //#region components/number-flow/number-flow-group.vue
3
+ var number_flow_group_default = number_flow_group_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { number_flow_group_default as default };
@@ -0,0 +1,12 @@
1
+ type __VLS_Slots = {
2
+ default(): unknown;
3
+ };
4
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
8
+ type __VLS_WithSlots<T, S> = T & {
9
+ new (): {
10
+ $slots: S;
11
+ };
12
+ };
@@ -0,0 +1,58 @@
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/objectSpread2.js";
2
+ import { getPrefixCls } from "../_utils/global-config.js";
3
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/asyncToGenerator.js";
4
+ import { GROUP_KEY } from "./group-key.js";
5
+ import { createElementBlock, defineComponent, nextTick, normalizeClass, openBlock, provide, renderSlot, unref, watch } from "vue";
6
+ //#region components/number-flow/number-flow-group.vue?vue&type=script&setup=true&lang.ts
7
+ var number_flow_group_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "NumberFlowGroup" }), {}, {
8
+ __name: "number-flow-group",
9
+ setup(__props) {
10
+ const children = /* @__PURE__ */ new Set();
11
+ let updating = false;
12
+ let pending = false;
13
+ function animateChildren() {
14
+ return _animateChildren.apply(this, arguments);
15
+ }
16
+ function _animateChildren() {
17
+ _animateChildren = _asyncToGenerator(function* () {
18
+ if (updating) {
19
+ pending = true;
20
+ return;
21
+ }
22
+ updating = true;
23
+ try {
24
+ do {
25
+ pending = false;
26
+ const preparedChildren = [...children].flatMap((child) => {
27
+ const version = child.prepare();
28
+ return version === void 0 ? [] : [{
29
+ child,
30
+ version
31
+ }];
32
+ });
33
+ if (preparedChildren.length === 0) continue;
34
+ yield nextTick();
35
+ preparedChildren.filter(({ child, version }) => child.commit(version)).forEach(({ child, version }) => child.start(version));
36
+ } while (pending);
37
+ } finally {
38
+ updating = false;
39
+ }
40
+ });
41
+ return _animateChildren.apply(this, arguments);
42
+ }
43
+ provide(GROUP_KEY, { register(child) {
44
+ children.add(child);
45
+ const stopWatch = watch(child.value, animateChildren, { flush: "pre" });
46
+ return () => {
47
+ stopWatch();
48
+ children.delete(child);
49
+ };
50
+ } });
51
+ const prefixCls = getPrefixCls("number-flow-group");
52
+ return (_ctx, _cache) => {
53
+ return openBlock(), createElementBlock("span", { class: normalizeClass(unref(prefixCls)) }, [renderSlot(_ctx.$slots, "default")], 2);
54
+ };
55
+ }
56
+ }));
57
+ //#endregion
58
+ export { number_flow_group_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,5 @@
1
+ import number_flow_vue_vue_type_script_setup_true_lang_default from "./number-flow.vue_vue_type_script_setup_true_lang.js";
2
+ //#region components/number-flow/number-flow.vue
3
+ var number_flow_default = number_flow_vue_vue_type_script_setup_true_lang_default;
4
+ //#endregion
5
+ export { number_flow_default as default };
@@ -0,0 +1,20 @@
1
+ import type { NumberFlowExposed, NumberFlowProps } from './types';
2
+ type __VLS_Slots = {
3
+ prefix(): unknown;
4
+ suffix(): unknown;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<NumberFlowProps, NumberFlowExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ animationsstart: () => any;
8
+ animationsfinish: () => any;
9
+ }, string, import("vue").PublicProps, Readonly<NumberFlowProps> & Readonly<{
10
+ onAnimationsstart?: (() => any) | undefined;
11
+ onAnimationsfinish?: (() => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
16
+ type __VLS_WithSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,284 @@
1
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/objectSpread2.js";
2
+ import { getPrefixCls } from "../_utils/global-config.js";
3
+ import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.142.0/helpers/esm/asyncToGenerator.js";
4
+ import { GROUP_KEY } from "./group-key.js";
5
+ import { formatNumberFlow } from "./formatter.js";
6
+ import { useCanAnimate } from "./use-can-animate.js";
7
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, inject, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, unref, useSlots, useTemplateRef, watch, withCtx } from "vue";
8
+ //#region components/number-flow/number-flow.vue?vue&type=script&setup=true&lang.ts
9
+ var _hoisted_1 = ["data-number-flow-id", "aria-label"];
10
+ var _hoisted_2 = ["data-number-flow-part"];
11
+ var number_flow_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent(_objectSpread2(_objectSpread2({}, { name: "NumberFlow" }), {}, {
12
+ __name: "number-flow",
13
+ props: {
14
+ value: {},
15
+ locales: {},
16
+ format: {},
17
+ prefix: {},
18
+ suffix: {},
19
+ trend: {
20
+ type: [Number, Function],
21
+ default: (oldValue, newValue) => Math.sign(newValue - oldValue)
22
+ },
23
+ plugins: {},
24
+ animated: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ transformTiming: { default: () => (() => ({
29
+ duration: 900,
30
+ easing: "cubic-bezier(0.16, 1, 0.3, 1)"
31
+ })) },
32
+ spinTiming: {},
33
+ opacityTiming: { default: () => (() => ({
34
+ duration: 450,
35
+ easing: "ease-out"
36
+ })) },
37
+ respectMotionPreference: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ digits: {},
42
+ willChange: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ nonce: {}
47
+ },
48
+ emits: ["animationsstart", "animationsfinish"],
49
+ setup(__props, { expose: __expose, emit: __emit }) {
50
+ const emit = __emit;
51
+ const prefixCls = getPrefixCls("number-flow");
52
+ const slots = useSlots();
53
+ const rootRef = useTemplateRef("rootRef");
54
+ const styleScope = shallowRef();
55
+ onMounted(() => {
56
+ styleScope.value = `sd-number-flow-${crypto.randomUUID()}`;
57
+ });
58
+ const numberFormatter = computed(() => new Intl.NumberFormat(__props.locales, __props.format));
59
+ function formatData(val) {
60
+ return formatNumberFlow(val, numberFormatter.value, slots.prefix ? void 0 : __props.prefix, slots.suffix ? void 0 : __props.suffix);
61
+ }
62
+ const previousData = shallowRef(formatData(__props.value));
63
+ const currentValue = computed(() => __props.value);
64
+ const currentData = computed(() => formatData(__props.value));
65
+ const animationPhase = shallowRef("idle");
66
+ const isAnimating = computed(() => animationPhase.value === "animating");
67
+ let animationVersion = 0;
68
+ let finishTimer;
69
+ const resolvedTransformTiming = computed(() => typeof __props.transformTiming === "function" ? __props.transformTiming() : __props.transformTiming);
70
+ const resolvedOpacityTiming = computed(() => typeof __props.opacityTiming === "function" ? __props.opacityTiming() : __props.opacityTiming);
71
+ const transformDuration = computed(() => typeof resolvedTransformTiming.value.duration === "number" ? resolvedTransformTiming.value.duration : 900);
72
+ const transformEasing = computed(() => {
73
+ var _resolvedTransformTim, _resolvedTransformTim2;
74
+ return (_resolvedTransformTim = (_resolvedTransformTim2 = resolvedTransformTiming.value.easing) === null || _resolvedTransformTim2 === void 0 ? void 0 : _resolvedTransformTim2.toString()) !== null && _resolvedTransformTim !== void 0 ? _resolvedTransformTim : "cubic-bezier(0.16, 1, 0.3, 1)";
75
+ });
76
+ const spinDuration = computed(() => {
77
+ if (__props.spinTiming && typeof __props.spinTiming.duration === "number") return __props.spinTiming.duration;
78
+ return transformDuration.value;
79
+ });
80
+ const spinEasing = computed(() => {
81
+ var _props$spinTiming;
82
+ if ((_props$spinTiming = __props.spinTiming) === null || _props$spinTiming === void 0 ? void 0 : _props$spinTiming.easing) return __props.spinTiming.easing.toString();
83
+ return transformEasing.value;
84
+ });
85
+ const opacityDuration = computed(() => typeof resolvedOpacityTiming.value.duration === "number" ? resolvedOpacityTiming.value.duration : 450);
86
+ const motionCanAnimate = useCanAnimate({ respectMotionPreference: () => __props.respectMotionPreference });
87
+ const canAnimate = computed(() => __props.animated && motionCanAnimate.value);
88
+ const computedTrend = computed(() => typeof __props.trend === "function" ? __props.trend(previousData.value.value, currentData.value.value) : __props.trend);
89
+ const classes = computed(() => [prefixCls, {
90
+ [`${prefixCls}-animated`]: canAnimate.value,
91
+ [`${prefixCls}-prepared`]: animationPhase.value === "prepared",
92
+ [`${prefixCls}-animating`]: isAnimating.value,
93
+ [`${prefixCls}-will-change`]: __props.willChange
94
+ }]);
95
+ function sanitizeDuration(duration) {
96
+ return Number.isFinite(duration) && duration >= 0 ? duration : 0;
97
+ }
98
+ function sanitizeEasing(easing) {
99
+ return /^[a-zA-Z0-9(),.\s+-]+$/.test(easing) ? easing : "linear";
100
+ }
101
+ const dynamicStyles = computed(() => {
102
+ if (!styleScope.value) return "";
103
+ const rootSelector = `[data-number-flow-id="${styleScope.value}"]`;
104
+ const rules = [`${rootSelector}{--sd-number-flow-duration:${sanitizeDuration(transformDuration.value)}ms;--sd-number-flow-easing:${sanitizeEasing(transformEasing.value)};--sd-number-flow-spin-duration:${sanitizeDuration(spinDuration.value)}ms;--sd-number-flow-spin-easing:${sanitizeEasing(spinEasing.value)};--sd-number-flow-opacity-duration:${sanitizeDuration(opacityDuration.value)}ms}`];
105
+ currentData.value.parts.forEach((part, index) => {
106
+ if (part.digit === void 0) return;
107
+ const delta = getDigitDelta(part);
108
+ const distance = Math.abs(delta);
109
+ rules.push(`${rootSelector} [data-number-flow-part="${index}"]{--sd-number-flow-start:${delta < 0 ? -distance : 0};--sd-number-flow-end:${delta > 0 ? -distance : 0}}`);
110
+ });
111
+ return rules.join("");
112
+ });
113
+ function getPreviousDigit(part) {
114
+ var _previousData$value$p, _previousData$value$p2;
115
+ return (_previousData$value$p = (_previousData$value$p2 = previousData.value.parts.find((candidate) => candidate.key === part.key)) === null || _previousData$value$p2 === void 0 ? void 0 : _previousData$value$p2.digit) !== null && _previousData$value$p !== void 0 ? _previousData$value$p : part.digit;
116
+ }
117
+ const highestChangedPosition = computed(() => {
118
+ const previousDigits = new Map(previousData.value.parts.filter((part) => part.digit !== void 0).map((part) => [part.key, part]));
119
+ const changedPositions = currentData.value.parts.flatMap((part) => {
120
+ var _part$position;
121
+ if (part.digit === void 0) return [];
122
+ const previous = previousDigits.get(part.key);
123
+ return (previous === null || previous === void 0 ? void 0 : previous.digit) === part.digit ? [] : [(_part$position = part.position) !== null && _part$position !== void 0 ? _part$position : 0];
124
+ });
125
+ return changedPositions.length === 0 ? void 0 : Math.max(...changedPositions);
126
+ });
127
+ function getDigitDelta(part) {
128
+ var _props$digits$max, _props$digits, _part$position2, _part$position3, _props$plugins;
129
+ const current = part.digit;
130
+ const previous = getPreviousDigit(part);
131
+ const length = ((_props$digits$max = (_props$digits = __props.digits) === null || _props$digits === void 0 || (_props$digits = _props$digits[(_part$position2 = part.position) !== null && _part$position2 !== void 0 ? _part$position2 : 0]) === null || _props$digits === void 0 ? void 0 : _props$digits.max) !== null && _props$digits$max !== void 0 ? _props$digits$max : 9) + 1;
132
+ const context = {
133
+ position: (_part$position3 = part.position) !== null && _part$position3 !== void 0 ? _part$position3 : 0,
134
+ length,
135
+ trend: computedTrend.value,
136
+ highestChangedPosition: highestChangedPosition.value
137
+ };
138
+ for (const plugin of (_props$plugins = __props.plugins) !== null && _props$plugins !== void 0 ? _props$plugins : []) {
139
+ var _plugin$getDelta;
140
+ const delta = (_plugin$getDelta = plugin.getDelta) === null || _plugin$getDelta === void 0 ? void 0 : _plugin$getDelta.call(plugin, current, previous, context);
141
+ if (delta !== void 0) return delta;
142
+ }
143
+ const difference = current - previous;
144
+ if (computedTrend.value < 0 && current > previous) return current - length - previous;
145
+ if (computedTrend.value > 0 && current < previous) return length - previous + current;
146
+ return difference;
147
+ }
148
+ function getDigitSequence(part) {
149
+ var _props$digits$max2, _props$digits2, _part$position4;
150
+ const current = part.digit;
151
+ const previous = getPreviousDigit(part);
152
+ const delta = getDigitDelta(part);
153
+ if (animationPhase.value === "idle" || delta === 0) return [{
154
+ key: `current-${current}`,
155
+ value: current
156
+ }];
157
+ const length = ((_props$digits$max2 = (_props$digits2 = __props.digits) === null || _props$digits2 === void 0 || (_props$digits2 = _props$digits2[(_part$position4 = part.position) !== null && _part$position4 !== void 0 ? _part$position4 : 0]) === null || _props$digits2 === void 0 ? void 0 : _props$digits2.max) !== null && _props$digits$max2 !== void 0 ? _props$digits$max2 : 9) + 1;
158
+ const start = delta > 0 ? previous : current;
159
+ return Array.from({ length: Math.abs(delta) + 1 }, (_, index) => ({
160
+ key: `step-${index}`,
161
+ value: (start + index) % length
162
+ }));
163
+ }
164
+ function finishAnimation(version = animationVersion) {
165
+ if (version !== animationVersion || animationPhase.value === "idle") return;
166
+ clearTimeout(finishTimer);
167
+ finishTimer = void 0;
168
+ previousData.value = currentData.value;
169
+ animationPhase.value = "idle";
170
+ emit("animationsfinish");
171
+ }
172
+ const group = inject(GROUP_KEY, void 0);
173
+ function prepareAnimation(oldData, data, force = false) {
174
+ var _props$plugins2;
175
+ const version = ++animationVersion;
176
+ clearTimeout(finishTimer);
177
+ finishTimer = void 0;
178
+ previousData.value = oldData;
179
+ (_props$plugins2 = __props.plugins) === null || _props$plugins2 === void 0 || _props$plugins2.forEach((plugin) => {
180
+ var _plugin$onUpdate;
181
+ return (_plugin$onUpdate = plugin.onUpdate) === null || _plugin$onUpdate === void 0 ? void 0 : _plugin$onUpdate.call(plugin, {
182
+ value: data.value,
183
+ previousValue: oldData.value,
184
+ trend: computedTrend.value
185
+ });
186
+ });
187
+ if (!canAnimate.value || !force && data.value === oldData.value) {
188
+ previousData.value = data;
189
+ animationPhase.value = "idle";
190
+ return;
191
+ }
192
+ animationPhase.value = "prepared";
193
+ return version;
194
+ }
195
+ function commitAnimationStart(version) {
196
+ var _rootRef$value;
197
+ if (version !== animationVersion || animationPhase.value !== "prepared") return false;
198
+ (_rootRef$value = rootRef.value) === null || _rootRef$value === void 0 || _rootRef$value.getBoundingClientRect();
199
+ return true;
200
+ }
201
+ function startAnimation(version) {
202
+ if (version !== animationVersion || animationPhase.value !== "prepared") return;
203
+ animationPhase.value = "animating";
204
+ emit("animationsstart");
205
+ finishTimer = setTimeout(() => finishAnimation(version), spinDuration.value + 50);
206
+ }
207
+ if (group) {
208
+ const unregister = group.register({
209
+ value: currentValue,
210
+ prepare: () => prepareAnimation(previousData.value, currentData.value, true),
211
+ commit: commitAnimationStart,
212
+ start: startAnimation
213
+ });
214
+ onBeforeUnmount(unregister);
215
+ } else watch(currentValue, function() {
216
+ var _ref = _asyncToGenerator(function* (data, oldData) {
217
+ const version = prepareAnimation(formatData(oldData), formatData(data));
218
+ if (version === void 0) return;
219
+ yield nextTick();
220
+ if (!commitAnimationStart(version)) return;
221
+ startAnimation(version);
222
+ });
223
+ return function(_x, _x2) {
224
+ return _ref.apply(this, arguments);
225
+ };
226
+ }(), { flush: "pre" });
227
+ onBeforeUnmount(() => clearTimeout(finishTimer));
228
+ __expose({ get el() {
229
+ return rootRef.value;
230
+ } });
231
+ return (_ctx, _cache) => {
232
+ return openBlock(), createElementBlock("span", {
233
+ ref_key: "rootRef",
234
+ ref: rootRef,
235
+ class: normalizeClass(classes.value),
236
+ "data-number-flow-id": styleScope.value,
237
+ role: "img",
238
+ "aria-label": currentData.value.valueAsString
239
+ }, [
240
+ (openBlock(), createBlock(resolveDynamicComponent("style"), { nonce: __props.nonce }, {
241
+ default: withCtx(() => [createTextVNode(toDisplayString(dynamicStyles.value), 1)]),
242
+ _: 1
243
+ }, 8, ["nonce"])),
244
+ _ctx.$slots.prefix ? (openBlock(), createElementBlock("span", {
245
+ key: 0,
246
+ class: normalizeClass(`${unref(prefixCls)}-custom-prefix`),
247
+ "aria-hidden": "true"
248
+ }, [renderSlot(_ctx.$slots, "prefix")], 2)) : createCommentVNode("", true),
249
+ createElementVNode("span", {
250
+ class: normalizeClass(`${unref(prefixCls)}-content`),
251
+ "aria-hidden": "true"
252
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(currentData.value.parts, (part, partIndex) => {
253
+ return openBlock(), createElementBlock("span", {
254
+ key: part.key,
255
+ "data-number-flow-part": partIndex,
256
+ class: normalizeClass([
257
+ `${unref(prefixCls)}-part`,
258
+ `${unref(prefixCls)}-${part.type}`,
259
+ { [`${unref(prefixCls)}-digit`]: part.digit !== void 0 }
260
+ ])
261
+ }, [part.digit !== void 0 ? (openBlock(), createElementBlock("span", {
262
+ key: 0,
263
+ class: normalizeClass(`${unref(prefixCls)}-digit-track`)
264
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList(getDigitSequence(part), (digit) => {
265
+ return openBlock(), createElementBlock("span", {
266
+ key: digit.key,
267
+ class: normalizeClass(`${unref(prefixCls)}-digit-value`)
268
+ }, toDisplayString(digit.value), 3);
269
+ }), 128))], 2)) : (openBlock(), createElementBlock("span", {
270
+ key: 1,
271
+ class: normalizeClass(`${unref(prefixCls)}-symbol`)
272
+ }, toDisplayString(part.value), 3))], 10, _hoisted_2);
273
+ }), 128))], 2),
274
+ _ctx.$slots.suffix ? (openBlock(), createElementBlock("span", {
275
+ key: 1,
276
+ class: normalizeClass(`${unref(prefixCls)}-custom-suffix`),
277
+ "aria-hidden": "true"
278
+ }, [renderSlot(_ctx.$slots, "suffix")], 2)) : createCommentVNode("", true)
279
+ ], 10, _hoisted_1);
280
+ };
281
+ }
282
+ }));
283
+ //#endregion
284
+ export { number_flow_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,2 @@
1
+ import "../../style/index.css";
2
+ import "./index.css";
@@ -0,0 +1,85 @@
1
+ /******** borderSize *******/
2
+ /******** borderStyle *******/
3
+ /******** radius *******/
4
+ /******** shadow distance *******/
5
+ /******** size *******/
6
+ /******** spacing *******/
7
+ /******** shadow *******/
8
+ /******** opacity *******/
9
+ /******** fontSize *******/
10
+ /******** fontWeight ********/
11
+ /******** Primary *******/
12
+ /******** success *******/
13
+ /******** warning *******/
14
+ /******** danger *******/
15
+ /******** link *******/
16
+ /******** radius *******/
17
+ /********* icon hover *********/
18
+ .sd-number-flow {
19
+ display: inline-flex;
20
+ align-items: baseline;
21
+ line-height: 1;
22
+ direction: ltr;
23
+ white-space: nowrap;
24
+ isolation: isolate;
25
+ }
26
+ .sd-number-flow-content, .sd-number-flow-part, .sd-number-flow-digit-track, .sd-number-flow-digit-value, .sd-number-flow-symbol {
27
+ display: inline-block;
28
+ }
29
+ .sd-number-flow-content {
30
+ margin: -0.25em -0.2em;
31
+ padding: 0.25em 0.2em;
32
+ overflow: hidden;
33
+ }
34
+ .sd-number-flow-part {
35
+ position: relative;
36
+ vertical-align: bottom;
37
+ }
38
+ .sd-number-flow-digit {
39
+ height: 1em;
40
+ overflow: hidden;
41
+ }
42
+ .sd-number-flow-digit-track {
43
+ display: flex;
44
+ flex-direction: column;
45
+ height: 1em;
46
+ transform: translateY(calc(1em * var(--sd-number-flow-start)));
47
+ }
48
+ .sd-number-flow-digit-value {
49
+ flex: 0 0 1em;
50
+ height: 1em;
51
+ line-height: 1;
52
+ text-align: center;
53
+ font-variant-numeric: tabular-nums;
54
+ }
55
+ .sd-number-flow-prepared .sd-number-flow-digit-track {
56
+ transition: none;
57
+ }
58
+ .sd-number-flow-animating .sd-number-flow-digit-track {
59
+ transform: translateY(calc(1em * var(--sd-number-flow-end)));
60
+ transition: transform var(--sd-number-flow-spin-duration, var(--sd-number-flow-duration)) var(--sd-number-flow-spin-easing, var(--sd-number-flow-easing)), opacity var(--sd-number-flow-opacity-duration) ease-out;
61
+ }
62
+ .sd-number-flow-symbol {
63
+ white-space: pre;
64
+ }
65
+ .sd-number-flow-will-change :is(.sd-number-flow-content, .sd-number-flow-part, .sd-number-flow-digit-track, .sd-number-flow-symbol) {
66
+ will-change: transform;
67
+ }
68
+ .sd-number-flow-custom-prefix {
69
+ margin-right: 4px;
70
+ }
71
+ .sd-number-flow-custom-suffix {
72
+ margin-left: 4px;
73
+ }
74
+
75
+ .sd-number-flow-group {
76
+ display: inline-flex;
77
+ gap: 4px;
78
+ align-items: baseline;
79
+ }
80
+
81
+ @media (prefers-reduced-motion: reduce) {
82
+ .sd-number-flow-digit-track {
83
+ transition: none;
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ import '../../style/index.scss';
2
+ import './index.scss';
@@ -0,0 +1,2 @@
1
+ import "../../style/index.scss";
2
+ import "./index.scss";