feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
@@ -0,0 +1,9 @@
import { SFCWithInstall } from "../../utils/vue/typescript.js";
import "../../utils/index.js";
import { StatisticInstance, StatisticProps, StatisticPropsPublic, statisticProps } from "./src/statistic.js";
import { _default } from "./src/statistic.vue.js";
//#region ../../packages/components/statistic/index.d.ts
declare const ElStatistic: SFCWithInstall<typeof _default>;
//#endregion
export { ElStatistic, ElStatistic as default, StatisticInstance, StatisticProps, StatisticPropsPublic, statisticProps };
+10
View File
@@ -0,0 +1,10 @@
import { withInstall } from "../../utils/vue/install.mjs";
import { statisticProps } from "./src/statistic.mjs";
import statistic_default from "./src/statistic2.mjs";
//#region ../../packages/components/statistic/index.ts
const ElStatistic = withInstall(statistic_default);
//#endregion
export { ElStatistic, ElStatistic as default, statisticProps };
//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","names":["Statistic"],"sources":["../../../../../packages/components/statistic/index.ts"],"sourcesContent":["import { withInstall } from '@element-plus/utils'\nimport Statistic from './src/statistic.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElStatistic: SFCWithInstall<typeof Statistic> =\n withInstall(Statistic)\n\nexport default ElStatistic\nexport * from './src/statistic'\n"],"mappings":";;;;;AAKA,MAAa,cACX,YAAYA,kBAAU"}
@@ -0,0 +1,72 @@
import { EpPropFinalized, EpPropMergeType } from "../../../utils/vue/props/types.js";
import "../../../utils/index.js";
import { _default } from "./statistic.vue.js";
import * as vue from "vue";
import { ExtractPublicPropTypes, StyleValue } from "vue";
import { Dayjs } from "dayjs";
//#region ../../packages/components/statistic/src/statistic.d.ts
interface StatisticProps {
/**
* @description Setting the decimal point
*/
decimalSeparator?: string;
/**
* @description Sets the thousandth identifier
*/
groupSeparator?: string;
/**
* @description numerical precision
*/
precision?: number;
/**
* @description Custom numerical presentation
*/
formatter?: (...args: any[]) => string | number;
/**
* @description Numerical content
*/
value?: number | Dayjs;
/**
* @description Sets the prefix of a number
*/
prefix?: string;
/**
* @description Sets the suffix of a number
*/
suffix?: string;
/**
* @description Numeric titles
*/
title?: string;
/**
* @description Styles numeric values
*/
valueStyle?: StyleValue;
}
/**
* @deprecated Removed after 3.0.0, Use `StatisticProps` instead.
*/
declare const statisticProps: {
readonly decimalSeparator: EpPropFinalized<StringConstructor, unknown, unknown, ".", boolean>;
readonly groupSeparator: EpPropFinalized<StringConstructor, unknown, unknown, ",", boolean>;
readonly precision: EpPropFinalized<NumberConstructor, unknown, unknown, 0, boolean>;
readonly formatter: FunctionConstructor;
readonly value: EpPropFinalized<(new (...args: any[]) => number | Dayjs) | (() => number | Dayjs) | (((new (...args: any[]) => number | Dayjs) | (() => number | Dayjs)) | null)[], unknown, unknown, 0, boolean>;
readonly prefix: StringConstructor;
readonly suffix: StringConstructor;
readonly title: StringConstructor;
readonly valueStyle: {
readonly type: vue.PropType<EpPropMergeType<(new (...args: any[]) => string | false | vue.CSSProperties | StyleValue[]) | (() => StyleValue) | (((new (...args: any[]) => string | false | vue.CSSProperties | StyleValue[]) | (() => StyleValue)) | null)[], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
};
/**
* @deprecated Removed after 3.0.0, Use `StatisticProps` instead.
*/
type StatisticPropsPublic = ExtractPublicPropTypes<typeof statisticProps>;
type StatisticInstance = InstanceType<typeof _default> & unknown;
//#endregion
export { StatisticInstance, StatisticProps, StatisticPropsPublic, statisticProps };
@@ -0,0 +1,37 @@
import { buildProps, definePropType } from "../../../utils/vue/props/runtime.mjs";
//#region ../../packages/components/statistic/src/statistic.ts
/**
* @deprecated Removed after 3.0.0, Use `StatisticProps` instead.
*/
const statisticProps = buildProps({
decimalSeparator: {
type: String,
default: "."
},
groupSeparator: {
type: String,
default: ","
},
precision: {
type: Number,
default: 0
},
formatter: Function,
value: {
type: definePropType([Number, Object]),
default: 0
},
prefix: String,
suffix: String,
title: String,
valueStyle: { type: definePropType([
String,
Object,
Array
]) }
});
//#endregion
export { statisticProps };
//# sourceMappingURL=statistic.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"statistic.mjs","names":[],"sources":["../../../../../../packages/components/statistic/src/statistic.ts"],"sourcesContent":["import { buildProps, definePropType } from '@element-plus/utils'\n\nimport type { ExtractPublicPropTypes, StyleValue } from 'vue'\nimport type { Dayjs } from 'dayjs'\nimport type Statistic from './statistic.vue'\n\nexport interface StatisticProps {\n /**\n * @description Setting the decimal point\n */\n decimalSeparator?: string\n /**\n * @description Sets the thousandth identifier\n */\n groupSeparator?: string\n /**\n * @description numerical precision\n */\n precision?: number\n /**\n * @description Custom numerical presentation\n */\n formatter?: (...args: any[]) => string | number\n /**\n * @description Numerical content\n */\n value?: number | Dayjs\n /**\n * @description Sets the prefix of a number\n */\n prefix?: string\n /**\n * @description Sets the suffix of a number\n */\n suffix?: string\n /**\n * @description Numeric titles\n */\n title?: string\n /**\n * @description Styles numeric values\n */\n valueStyle?: StyleValue\n}\n\n/**\n * @deprecated Removed after 3.0.0, Use `StatisticProps` instead.\n */\nexport const statisticProps = buildProps({\n /**\n * @description Setting the decimal point\n */\n decimalSeparator: {\n type: String,\n default: '.',\n },\n /**\n * @description Sets the thousandth identifier\n */\n groupSeparator: {\n type: String,\n default: ',',\n },\n /**\n * @description numerical precision\n */\n precision: {\n type: Number,\n default: 0,\n },\n /**\n * @description Custom numerical presentation\n */\n formatter: Function,\n /**\n * @description Numerical content\n */\n value: {\n type: definePropType<number | Dayjs>([Number, Object]),\n default: 0,\n },\n /**\n * @description Sets the prefix of a number\n */\n prefix: String,\n\n /**\n * @description Sets the suffix of a number\n */\n suffix: String,\n /**\n * @description Numeric titles\n */\n title: String,\n /**\n * @description Styles numeric values\n */\n valueStyle: {\n type: definePropType<StyleValue>([String, Object, Array]),\n },\n} as const)\n\n/**\n * @deprecated Removed after 3.0.0, Use `StatisticProps` instead.\n */\nexport type StatisticPropsPublic = ExtractPublicPropTypes<typeof statisticProps>\n\nexport type StatisticInstance = InstanceType<typeof Statistic> & unknown\n"],"mappings":";;;;;;AAgDA,MAAa,iBAAiB,WAAW;CAIvC,kBAAkB;EAChB,MAAM;EACN,SAAS;EACV;CAID,gBAAgB;EACd,MAAM;EACN,SAAS;EACV;CAID,WAAW;EACT,MAAM;EACN,SAAS;EACV;CAID,WAAW;CAIX,OAAO;EACL,MAAM,eAA+B,CAAC,QAAQ,OAAO,CAAC;EACtD,SAAS;EACV;CAID,QAAQ;CAKR,QAAQ;CAIR,OAAO;CAIP,YAAY,EACV,MAAM,eAA2B;EAAC;EAAQ;EAAQ;EAAM,CAAC,EAC1D;CACF,CAAU"}
@@ -0,0 +1,34 @@
import { StatisticProps } from "./statistic.js";
import * as vue from "vue";
import * as dayjs$1 from "dayjs";
//#region ../../packages/components/statistic/src/statistic.vue.d.ts
declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
type __VLS_Slots = {} & {
title?: (props: typeof __VLS_1) => any;
} & {
prefix?: (props: typeof __VLS_3) => any;
} & {
suffix?: (props: typeof __VLS_5) => any;
};
declare const __VLS_base: vue.DefineComponent<StatisticProps, {
/**
* @description current display value
*/
displayValue: vue.ComputedRef<string | number | dayjs$1.Dayjs>;
}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<StatisticProps> & Readonly<{}>, {
value: number | dayjs$1.Dayjs;
precision: number;
decimalSeparator: string;
groupSeparator: string;
valueStyle: string | false | vue.CSSProperties | vue.StyleValue[] | null;
}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
declare const _default: typeof __VLS_export;
type __VLS_WithSlots<T, S> = T & {
new (): {
$slots: S;
};
};
//#endregion
export { _default };
@@ -0,0 +1,48 @@
import { isFunction, isNumber } from "../../../utils/types.mjs";
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
import { statisticProps } from "./statistic.mjs";
import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, unref } from "vue";
//#region ../../packages/components/statistic/src/statistic.vue?vue&type=script&setup=true&lang.ts
var statistic_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
name: "ElStatistic",
__name: "statistic",
props: statisticProps,
setup(__props, { expose: __expose }) {
const props = __props;
const ns = useNamespace("statistic");
const displayValue = computed(() => {
const { value, formatter, precision, decimalSeparator, groupSeparator } = props;
if (isFunction(formatter)) return formatter(value);
if (!isNumber(value) || Number.isNaN(value)) return value;
let [integer, decimal = ""] = String(value).split(".");
decimal = decimal.padEnd(precision, "0").slice(0, precision > 0 ? precision : 0);
integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
return [integer, decimal].join(decimal ? decimalSeparator : "");
});
__expose({ displayValue });
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", { class: normalizeClass(unref(ns).b()) }, [_ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(unref(ns).e("head"))
}, [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(__props.title), 1)])], 2)) : createCommentVNode("v-if", true), createElementVNode("div", { class: normalizeClass(unref(ns).e("content")) }, [
_ctx.$slots.prefix || __props.prefix ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(unref(ns).e("prefix"))
}, [renderSlot(_ctx.$slots, "prefix", {}, () => [createElementVNode("span", null, toDisplayString(__props.prefix), 1)])], 2)) : createCommentVNode("v-if", true),
createElementVNode("span", {
class: normalizeClass(unref(ns).e("number")),
style: normalizeStyle(__props.valueStyle)
}, toDisplayString(displayValue.value), 7),
_ctx.$slots.suffix || __props.suffix ? (openBlock(), createElementBlock("div", {
key: 1,
class: normalizeClass(unref(ns).e("suffix"))
}, [renderSlot(_ctx.$slots, "suffix", {}, () => [createElementVNode("span", null, toDisplayString(__props.suffix), 1)])], 2)) : createCommentVNode("v-if", true)
], 2)], 2);
};
}
});
//#endregion
export { statistic_vue_vue_type_script_setup_true_lang_default as default };
//# sourceMappingURL=statistic.vue_vue_type_script_setup_true_lang.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"statistic.vue_vue_type_script_setup_true_lang.mjs","names":["$slots"],"sources":["../../../../../../packages/components/statistic/src/statistic.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div v-if=\"$slots.title || title\" :class=\"ns.e('head')\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </div>\n <div :class=\"ns.e('content')\">\n <div v-if=\"$slots.prefix || prefix\" :class=\"ns.e('prefix')\">\n <slot name=\"prefix\">\n <span>{{ prefix }}</span>\n </slot>\n </div>\n <span :class=\"ns.e('number')\" :style=\"valueStyle\">\n {{ displayValue }}\n </span>\n <div v-if=\"$slots.suffix || suffix\" :class=\"ns.e('suffix')\">\n <slot name=\"suffix\">\n <span>{{ suffix }}</span>\n </slot>\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isFunction, isNumber } from '@element-plus/utils'\n\nimport type { StatisticProps } from './statistic'\n\ndefineOptions({\n name: 'ElStatistic',\n})\n\nconst props = withDefaults(defineProps<StatisticProps>(), {\n decimalSeparator: '.',\n groupSeparator: ',',\n precision: 0,\n value: 0,\n valueStyle: undefined,\n})\nconst ns = useNamespace('statistic')\n\nconst displayValue = computed(() => {\n const { value, formatter, precision, decimalSeparator, groupSeparator } =\n props\n\n if (isFunction(formatter)) return formatter(value)\n\n // https://github.com/element-plus/element-plus/issues/17784\n if (!isNumber(value) || Number.isNaN(value)) return value\n\n let [integer, decimal = ''] = String(value).split('.')\n decimal = decimal\n .padEnd(precision, '0')\n .slice(0, precision > 0 ? precision : 0)\n integer = integer.replace(/\\B(?=(\\d{3})+(?!\\d))/g, groupSeparator)\n return [integer, decimal].join(decimal ? decimalSeparator : '')\n})\n\ndefineExpose({\n /**\n * @description current display value\n */\n displayValue,\n})\n</script>\n"],"mappings":";;;;;;;;;;;EAoCA,MAAM,QAAQ;EAOd,MAAM,KAAK,aAAa,YAAW;EAEnC,MAAM,eAAe,eAAe;GAClC,MAAM,EAAE,OAAO,WAAW,WAAW,kBAAkB,mBACrD;AAEF,OAAI,WAAW,UAAU,CAAE,QAAO,UAAU,MAAK;AAGjD,OAAI,CAAC,SAAS,MAAM,IAAI,OAAO,MAAM,MAAM,CAAE,QAAO;GAEpD,IAAI,CAAC,SAAS,UAAU,MAAM,OAAO,MAAM,CAAC,MAAM,IAAG;AACrD,aAAU,QACP,OAAO,WAAW,IAAG,CACrB,MAAM,GAAG,YAAY,IAAI,YAAY,EAAC;AACzC,aAAU,QAAQ,QAAQ,yBAAyB,eAAc;AACjE,UAAO,CAAC,SAAS,QAAQ,CAAC,KAAK,UAAU,mBAAmB,GAAE;IAC/D;AAED,WAAa,EAIX,cACD,CAAA;;uBAlEC,mBAqBM,OAAA,EArBA,OAAK,eAAE,MAAA,GAAE,CAAC,GAAC,CAAA,KACJA,KAAAA,OAAO,SAAS,QAAA,sBAA3B,mBAIM,OAAA;;IAJ6B,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,OAAA,CAAA;OAC5C,WAEO,KAAA,QAAA,SAAA,EAAA,QAAA,iCADF,QAAA,MAAK,EAAA,EAAA,6CAGZ,mBAcM,OAAA,EAdA,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,UAAA,CAAA;IACJA,KAAAA,OAAO,UAAU,QAAA,uBAA5B,mBAIM,OAAA;;KAJ+B,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,SAAA,CAAA;QAC9C,WAEO,KAAA,QAAA,UAAA,EAAA,QAAA,CADL,mBAAyB,QAAA,MAAA,gBAAhB,QAAA,OAAM,EAAA,EAAA;IAGnB,mBAEO,QAAA;KAFA,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,SAAA,CAAA;KAAa,OAAK,eAAE,QAAA,WAAU;uBAC3C,aAAA,MAAY,EAAA,EAAA;IAENA,KAAAA,OAAO,UAAU,QAAA,uBAA5B,mBAIM,OAAA;;KAJ+B,OAAK,eAAE,MAAA,GAAE,CAAC,EAAC,SAAA,CAAA;QAC9C,WAEO,KAAA,QAAA,UAAA,EAAA,QAAA,CADL,mBAAyB,QAAA,MAAA,gBAAhB,QAAA,OAAM,EAAA,EAAA"}
@@ -0,0 +1,8 @@
import statistic_vue_vue_type_script_setup_true_lang_default from "./statistic.vue_vue_type_script_setup_true_lang.mjs";
//#region ../../packages/components/statistic/src/statistic.vue
var statistic_default = statistic_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { statistic_default as default };
//# sourceMappingURL=statistic2.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"statistic2.mjs","names":[],"sources":["../../../../../../packages/components/statistic/src/statistic.vue"],"sourcesContent":["<template>\n <div :class=\"ns.b()\">\n <div v-if=\"$slots.title || title\" :class=\"ns.e('head')\">\n <slot name=\"title\">\n {{ title }}\n </slot>\n </div>\n <div :class=\"ns.e('content')\">\n <div v-if=\"$slots.prefix || prefix\" :class=\"ns.e('prefix')\">\n <slot name=\"prefix\">\n <span>{{ prefix }}</span>\n </slot>\n </div>\n <span :class=\"ns.e('number')\" :style=\"valueStyle\">\n {{ displayValue }}\n </span>\n <div v-if=\"$slots.suffix || suffix\" :class=\"ns.e('suffix')\">\n <slot name=\"suffix\">\n <span>{{ suffix }}</span>\n </slot>\n </div>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { isFunction, isNumber } from '@element-plus/utils'\n\nimport type { StatisticProps } from './statistic'\n\ndefineOptions({\n name: 'ElStatistic',\n})\n\nconst props = withDefaults(defineProps<StatisticProps>(), {\n decimalSeparator: '.',\n groupSeparator: ',',\n precision: 0,\n value: 0,\n valueStyle: undefined,\n})\nconst ns = useNamespace('statistic')\n\nconst displayValue = computed(() => {\n const { value, formatter, precision, decimalSeparator, groupSeparator } =\n props\n\n if (isFunction(formatter)) return formatter(value)\n\n // https://github.com/element-plus/element-plus/issues/17784\n if (!isNumber(value) || Number.isNaN(value)) return value\n\n let [integer, decimal = ''] = String(value).split('.')\n decimal = decimal\n .padEnd(precision, '0')\n .slice(0, precision > 0 ? precision : 0)\n integer = integer.replace(/\\B(?=(\\d{3})+(?!\\d))/g, groupSeparator)\n return [integer, decimal].join(decimal ? decimalSeparator : '')\n})\n\ndefineExpose({\n /**\n * @description current display value\n */\n displayValue,\n})\n</script>\n"],"mappings":""}
@@ -0,0 +1,2 @@
import "../../base/style/css.mjs";
import "element-plus/theme-chalk/el-statistic.css";
@@ -0,0 +1,2 @@
import "../../base/style/index.mjs";
import "element-plus/theme-chalk/src/statistic.scss";