@minto-ai/mini-ui 1.0.1
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.d.ts +12 -0
- package/dist/index.es.js +130 -0
- package/dist/loading/index.d.ts +72 -0
- package/dist/loading/src/loading.d.ts +27 -0
- package/dist/loading/src/loading.vue.d.ts +49 -0
- package/dist/style.css +34 -0
- package/dist/utils/dom/index.d.ts +1 -0
- package/dist/utils/dom/unit.d.ts +5 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/vue/index.d.ts +1 -0
- package/dist/utils/vue/install.d.ts +5 -0
- package/package.json +27 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { MtLoading } from './loading';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
install: (app: App) => void;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
7
|
+
export { MtLoading, };
|
|
8
|
+
declare module 'vue' {
|
|
9
|
+
interface GlobalComponents {
|
|
10
|
+
MtLoading: typeof MtLoading;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { isNumber, isString, isArray, multiply, divide, beParsedAsNumber, checkEmpty } from "@minto-ai/tools";
|
|
2
|
+
import { defineComponent, computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeStyle, normalizeClass, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
3
|
+
const VALID_CSS_KEYWORD_REGEX = /^(?:fit-content|min-content|max-content|auto|inherit|initial|unset)$/;
|
|
4
|
+
const NUMERIC_STRING_REGEX = /^\d+(?:\.\d+)?$/;
|
|
5
|
+
const PIXEL_UNIT_STRING_REGEX = /^\d+(?:\.\d+)?px$/;
|
|
6
|
+
const PERCENTAGE_STRING_REGEX = /^\d+(?:\.\d+)?%$/;
|
|
7
|
+
const VIEWPORT_UNIT_STRING_REGEX = /^\d+(?:\.\d+)?(?:vw|vh)$/;
|
|
8
|
+
const DESIGN_VIEWPORT_WIDTH_PIXELS = 375;
|
|
9
|
+
function convertValueToViewportWidth(value) {
|
|
10
|
+
if (isNumber(value)) {
|
|
11
|
+
return convertSingleValueToViewportWidth(value);
|
|
12
|
+
}
|
|
13
|
+
if (isString(value)) {
|
|
14
|
+
return value.split(/\s+/).map((item) => convertSingleValueToViewportWidth(item)).join(" ");
|
|
15
|
+
}
|
|
16
|
+
if (isArray(value)) {
|
|
17
|
+
return value.map((item) => convertSingleValueToViewportWidth(item)).join(" ");
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Invalid CSS value: ${value}`);
|
|
20
|
+
}
|
|
21
|
+
function convertSingleValueToViewportWidth(value) {
|
|
22
|
+
if (isNumber(value)) {
|
|
23
|
+
return `${multiply(divide(value, DESIGN_VIEWPORT_WIDTH_PIXELS), 100)}vw`;
|
|
24
|
+
}
|
|
25
|
+
if (isString(value)) {
|
|
26
|
+
if (NUMERIC_STRING_REGEX.test(value)) {
|
|
27
|
+
return `${multiply(divide(beParsedAsNumber(value), DESIGN_VIEWPORT_WIDTH_PIXELS), 100)}vw`;
|
|
28
|
+
}
|
|
29
|
+
if (PIXEL_UNIT_STRING_REGEX.test(value)) {
|
|
30
|
+
return `${multiply(divide(beParsedAsNumber(value), DESIGN_VIEWPORT_WIDTH_PIXELS), 100)}vw`;
|
|
31
|
+
}
|
|
32
|
+
if (VALID_CSS_KEYWORD_REGEX.test(value)) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (PERCENTAGE_STRING_REGEX.test(value)) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
if (VIEWPORT_UNIT_STRING_REGEX.test(value)) {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Invalid CSS value: ${value}`);
|
|
43
|
+
}
|
|
44
|
+
function withInstall(component) {
|
|
45
|
+
component.install = (app) => {
|
|
46
|
+
const { name } = component;
|
|
47
|
+
app.component(name, component);
|
|
48
|
+
};
|
|
49
|
+
return component;
|
|
50
|
+
}
|
|
51
|
+
const loadingProps = {
|
|
52
|
+
/**
|
|
53
|
+
* 加载动画的类型
|
|
54
|
+
*/
|
|
55
|
+
type: {
|
|
56
|
+
type: String,
|
|
57
|
+
validator: (value) => {
|
|
58
|
+
return ["spinner"].includes(value);
|
|
59
|
+
},
|
|
60
|
+
default: "spinner"
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* 加载动画的大小
|
|
64
|
+
*/
|
|
65
|
+
size: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 42
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* 加载时显示的文本
|
|
71
|
+
*/
|
|
72
|
+
text: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: ""
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const _hoisted_1 = { class: "mt-loading" };
|
|
78
|
+
const _hoisted_2 = {
|
|
79
|
+
key: 0,
|
|
80
|
+
class: "mt-loading__text"
|
|
81
|
+
};
|
|
82
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
83
|
+
...{
|
|
84
|
+
name: "MtLoading"
|
|
85
|
+
},
|
|
86
|
+
__name: "loading",
|
|
87
|
+
props: loadingProps,
|
|
88
|
+
setup(__props) {
|
|
89
|
+
const props = __props;
|
|
90
|
+
const iconClass = computed(() => {
|
|
91
|
+
const classes = [];
|
|
92
|
+
classes.push(`mt-loading__icon`);
|
|
93
|
+
classes.push(`mt-loading__icon--${props.type}`);
|
|
94
|
+
return classes;
|
|
95
|
+
});
|
|
96
|
+
const iconStyles = computed(() => {
|
|
97
|
+
const styles = {};
|
|
98
|
+
if (!checkEmpty(props.size)) {
|
|
99
|
+
styles["--mt-loading-size"] = convertValueToViewportWidth(props.size);
|
|
100
|
+
}
|
|
101
|
+
return styles;
|
|
102
|
+
});
|
|
103
|
+
return (_ctx, _cache) => {
|
|
104
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
105
|
+
createElementVNode("div", {
|
|
106
|
+
class: normalizeClass(iconClass.value),
|
|
107
|
+
style: normalizeStyle(iconStyles.value)
|
|
108
|
+
}, null, 6),
|
|
109
|
+
props.text || _ctx.$slots.default ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
110
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
111
|
+
createTextVNode(toDisplayString(props.text), 1)
|
|
112
|
+
])
|
|
113
|
+
])) : createCommentVNode("", true)
|
|
114
|
+
]);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const MtLoading = withInstall(_sfc_main);
|
|
119
|
+
const components = [
|
|
120
|
+
MtLoading
|
|
121
|
+
];
|
|
122
|
+
const index = {
|
|
123
|
+
install: (app) => {
|
|
124
|
+
components.forEach((component) => app.use(component));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
MtLoading,
|
|
129
|
+
index as default
|
|
130
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const MtLoading: {
|
|
2
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
|
|
3
|
+
readonly type: {
|
|
4
|
+
readonly type: import('vue').PropType<"spinner">;
|
|
5
|
+
readonly validator: (value: string) => boolean;
|
|
6
|
+
readonly default: "spinner";
|
|
7
|
+
};
|
|
8
|
+
readonly size: {
|
|
9
|
+
readonly type: NumberConstructor;
|
|
10
|
+
readonly default: 42;
|
|
11
|
+
};
|
|
12
|
+
readonly text: {
|
|
13
|
+
readonly type: StringConstructor;
|
|
14
|
+
readonly default: "";
|
|
15
|
+
};
|
|
16
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
|
|
17
|
+
readonly type: "spinner";
|
|
18
|
+
readonly size: number;
|
|
19
|
+
readonly text: string;
|
|
20
|
+
}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
|
21
|
+
P: {};
|
|
22
|
+
B: {};
|
|
23
|
+
D: {};
|
|
24
|
+
C: {};
|
|
25
|
+
M: {};
|
|
26
|
+
Defaults: {};
|
|
27
|
+
}, Readonly<import('vue').ExtractPropTypes<{
|
|
28
|
+
readonly type: {
|
|
29
|
+
readonly type: import('vue').PropType<"spinner">;
|
|
30
|
+
readonly validator: (value: string) => boolean;
|
|
31
|
+
readonly default: "spinner";
|
|
32
|
+
};
|
|
33
|
+
readonly size: {
|
|
34
|
+
readonly type: NumberConstructor;
|
|
35
|
+
readonly default: 42;
|
|
36
|
+
};
|
|
37
|
+
readonly text: {
|
|
38
|
+
readonly type: StringConstructor;
|
|
39
|
+
readonly default: "";
|
|
40
|
+
};
|
|
41
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, {
|
|
42
|
+
readonly type: "spinner";
|
|
43
|
+
readonly size: number;
|
|
44
|
+
readonly text: string;
|
|
45
|
+
}>;
|
|
46
|
+
__isFragment?: never;
|
|
47
|
+
__isTeleport?: never;
|
|
48
|
+
__isSuspense?: never;
|
|
49
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
|
|
50
|
+
readonly type: {
|
|
51
|
+
readonly type: import('vue').PropType<"spinner">;
|
|
52
|
+
readonly validator: (value: string) => boolean;
|
|
53
|
+
readonly default: "spinner";
|
|
54
|
+
};
|
|
55
|
+
readonly size: {
|
|
56
|
+
readonly type: NumberConstructor;
|
|
57
|
+
readonly default: 42;
|
|
58
|
+
};
|
|
59
|
+
readonly text: {
|
|
60
|
+
readonly type: StringConstructor;
|
|
61
|
+
readonly default: "";
|
|
62
|
+
};
|
|
63
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
|
|
64
|
+
readonly type: "spinner";
|
|
65
|
+
readonly size: number;
|
|
66
|
+
readonly text: string;
|
|
67
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
68
|
+
$slots: {
|
|
69
|
+
default?(_: {}): any;
|
|
70
|
+
};
|
|
71
|
+
}) & import('vue').Plugin;
|
|
72
|
+
export default MtLoading;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
declare const loadingProps: {
|
|
3
|
+
/**
|
|
4
|
+
* 加载动画的类型
|
|
5
|
+
*/
|
|
6
|
+
readonly type: {
|
|
7
|
+
readonly type: PropType<"spinner">;
|
|
8
|
+
readonly validator: (value: string) => boolean;
|
|
9
|
+
readonly default: "spinner";
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 加载动画的大小
|
|
13
|
+
*/
|
|
14
|
+
readonly size: {
|
|
15
|
+
readonly type: NumberConstructor;
|
|
16
|
+
readonly default: 42;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 加载时显示的文本
|
|
20
|
+
*/
|
|
21
|
+
readonly text: {
|
|
22
|
+
readonly type: StringConstructor;
|
|
23
|
+
readonly default: "";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type LoadingProps = ExtractPropTypes<typeof loadingProps>;
|
|
27
|
+
export { loadingProps };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
|
+
attrs: Partial<{}>;
|
|
3
|
+
slots: {
|
|
4
|
+
default?(_: {}): any;
|
|
5
|
+
};
|
|
6
|
+
refs: {};
|
|
7
|
+
rootEl: HTMLDivElement;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
11
|
+
readonly type: {
|
|
12
|
+
readonly type: import('vue').PropType<"spinner">;
|
|
13
|
+
readonly validator: (value: string) => boolean;
|
|
14
|
+
readonly default: "spinner";
|
|
15
|
+
};
|
|
16
|
+
readonly size: {
|
|
17
|
+
readonly type: NumberConstructor;
|
|
18
|
+
readonly default: 42;
|
|
19
|
+
};
|
|
20
|
+
readonly text: {
|
|
21
|
+
readonly type: StringConstructor;
|
|
22
|
+
readonly default: "";
|
|
23
|
+
};
|
|
24
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
25
|
+
readonly type: {
|
|
26
|
+
readonly type: import('vue').PropType<"spinner">;
|
|
27
|
+
readonly validator: (value: string) => boolean;
|
|
28
|
+
readonly default: "spinner";
|
|
29
|
+
};
|
|
30
|
+
readonly size: {
|
|
31
|
+
readonly type: NumberConstructor;
|
|
32
|
+
readonly default: 42;
|
|
33
|
+
};
|
|
34
|
+
readonly text: {
|
|
35
|
+
readonly type: StringConstructor;
|
|
36
|
+
readonly default: "";
|
|
37
|
+
};
|
|
38
|
+
}>> & Readonly<{}>, {
|
|
39
|
+
readonly type: "spinner";
|
|
40
|
+
readonly size: number;
|
|
41
|
+
readonly text: string;
|
|
42
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
43
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
44
|
+
export default _default;
|
|
45
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
46
|
+
new (): {
|
|
47
|
+
$slots: S;
|
|
48
|
+
};
|
|
49
|
+
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.mt-loading {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
justify-content: center;
|
|
7
|
+
font-size: inherit;
|
|
8
|
+
}
|
|
9
|
+
.mt-loading__icon--spinner {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
width: var(--mt-loading-size);
|
|
12
|
+
height: var(--mt-loading-size);
|
|
13
|
+
aspect-ratio: 1;
|
|
14
|
+
padding: 0.53vw;
|
|
15
|
+
line-height: var(--mt-loading-size);
|
|
16
|
+
background: #999;
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
mask: conic-gradient(rgba(0, 0, 0, 0) 10%, #000), linear-gradient(#000 0 0) content-box;
|
|
19
|
+
mask-composite: source-out;
|
|
20
|
+
mask-composite: subtract;
|
|
21
|
+
animation: mt-loading-spin 1s infinite linear;
|
|
22
|
+
}
|
|
23
|
+
.mt-loading__text {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
margin-top: 0.53vw;
|
|
26
|
+
font-size: 3.73vw;
|
|
27
|
+
color: #999;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@keyframes mt-loading-spin {
|
|
31
|
+
to {
|
|
32
|
+
transform: rotate(1turn);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './unit';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './install';
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@minto-ai/mini-ui",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"mini-ui",
|
|
12
|
+
"移动端UI组件库",
|
|
13
|
+
"vue3"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.umd.cjs",
|
|
16
|
+
"module": "./dist/index.es.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "vite build"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": "^3.5.13"
|
|
26
|
+
}
|
|
27
|
+
}
|