orion-design 0.1.0 → 0.1.2
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/components/Flex/Col.d.ts +25 -0
- package/dist/components/Flex/Item.d.ts +25 -0
- package/dist/components/Flex/Row.d.ts +25 -0
- package/dist/components/Flex/index.d.ts +10 -0
- package/dist/components/Flex/index.js +151 -0
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Space/index.d.ts +76 -0
- package/dist/components/_util/classNames.d.ts +2 -0
- package/dist/components/_util/classNames.js +31 -0
- package/dist/components/_util/isValid.d.ts +2 -0
- package/dist/components/_util/isValid.js +5 -0
- package/dist/components/_util/props-util/index.d.ts +6 -0
- package/dist/components/_util/props-util/index.js +53 -0
- package/dist/components/_util/props-util/initDefaultProps.d.ts +6 -0
- package/dist/components/_util/props-util/initDefaultProps.js +25 -0
- package/dist/components/_util/type.d.ts +62 -0
- package/dist/components/_util/type.js +66 -0
- package/dist/components/_util/util.d.ts +18 -0
- package/dist/components/_util/util.js +83 -0
- package/dist/components/_util/vue-types/index.d.ts +12 -0
- package/dist/components/_util/vue-types/index.js +473 -0
- package/dist/components/components.d.ts +4 -0
- package/dist/components/components.js +10 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +23 -0
- package/dist/components-O4L3qYfM.js +61 -0
- package/dist/error/OrionError.js +9 -7
- package/dist/index.css +44 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +12 -3
- package/dist/print/LodopFuncs.js +109 -140
- package/dist/print/index.js +204 -199
- package/dist/request/ErrorHandlerChain.js +13 -13
- package/dist/request/RequestFilterChain.js +13 -13
- package/dist/request/ResponseParserChain.js +13 -13
- package/dist/request/disivion/DateSerializer.js +44 -53
- package/dist/request/disivion/DivisionErrorHandler.js +42 -42
- package/dist/request/disivion/DivisionResponseParser.js +22 -18
- package/dist/request/disivion/index.d.ts +21 -1
- package/dist/request/disivion/index.js +493 -24
- package/dist/request/error/BizExceptionResponseError.js +10 -10
- package/dist/request/error/ExceptionResponseError.js +10 -10
- package/dist/request/error/ResponseError.js +11 -9
- package/dist/request/error/SessionExceptionResponseError.js +10 -10
- package/dist/request/index.d.ts +3 -0
- package/dist/request/index.js +9 -20
- package/dist/style/index.d.ts +3 -0
- package/dist/style/index.js +1 -0
- package/dist/utils/DateUtil.js +47 -52
- package/dist/utils/NumberUtil.js +5 -5
- package/dist/utils/cloneDeep.js +1 -2255
- package/dist/utils/delay.js +1 -1
- package/dist/utils/index.js +3 -4
- package/dist/utils/md5.js +218 -272
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.js +6 -0
- package/dist/version/version.d.ts +2 -0
- package/dist/version/version.js +3 -0
- package/global.d.ts +9 -0
- package/package.json +28 -10
- package/dist/_commonjsHelpers-BFTU3MAI.js +0 -7
- package/dist/bignumber-upqAL281.js +0 -2907
- package/dist/dayjs.min-CYqA_arp.js +0 -12
- package/dist/request/disivion/request.d.ts +0 -21
- package/dist/request/disivion/request.js +0 -19345
- package/dist/request/postByOpenNewWindow.d.ts +0 -1
- package/dist/request/postByOpenNewWindow.js +0 -41
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { PropType, ExtractPropTypes } from 'vue';
|
2
|
+
export declare const colProps: () => {
|
3
|
+
gutter: {
|
4
|
+
default: string | boolean;
|
5
|
+
type: PropType<string | boolean>;
|
6
|
+
};
|
7
|
+
height: StringConstructor;
|
8
|
+
};
|
9
|
+
export type ColProps = Partial<ExtractPropTypes<ReturnType<typeof colProps>>>;
|
10
|
+
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
11
|
+
gutter: {
|
12
|
+
default: string | boolean;
|
13
|
+
type: PropType<string | boolean>;
|
14
|
+
};
|
15
|
+
height: StringConstructor;
|
16
|
+
}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
17
|
+
gutter: {
|
18
|
+
default: string | boolean;
|
19
|
+
type: PropType<string | boolean>;
|
20
|
+
};
|
21
|
+
height: StringConstructor;
|
22
|
+
}>> & Readonly<{}>, {
|
23
|
+
gutter: string | boolean;
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
25
|
+
export default _default;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
2
|
+
export declare const itemProps: () => {
|
3
|
+
flexBasic: StringConstructor;
|
4
|
+
hidden: {
|
5
|
+
type: BooleanConstructor;
|
6
|
+
default: boolean;
|
7
|
+
};
|
8
|
+
};
|
9
|
+
export type ItemProps = Partial<ExtractPropTypes<ReturnType<typeof itemProps>>>;
|
10
|
+
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
11
|
+
flexBasic: StringConstructor;
|
12
|
+
hidden: {
|
13
|
+
type: BooleanConstructor;
|
14
|
+
default: boolean;
|
15
|
+
};
|
16
|
+
}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
17
|
+
flexBasic: StringConstructor;
|
18
|
+
hidden: {
|
19
|
+
type: BooleanConstructor;
|
20
|
+
default: boolean;
|
21
|
+
};
|
22
|
+
}>> & Readonly<{}>, {
|
23
|
+
hidden: boolean;
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
25
|
+
export default _default;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { PropType, ExtractPropTypes } from 'vue';
|
2
|
+
export declare const rowProps: () => {
|
3
|
+
gutter: {
|
4
|
+
default: string | boolean;
|
5
|
+
type: PropType<string | boolean>;
|
6
|
+
};
|
7
|
+
height: StringConstructor;
|
8
|
+
};
|
9
|
+
export type RowProps = Partial<ExtractPropTypes<ReturnType<typeof rowProps>>>;
|
10
|
+
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
11
|
+
gutter: {
|
12
|
+
default: string | boolean;
|
13
|
+
type: PropType<string | boolean>;
|
14
|
+
};
|
15
|
+
height: StringConstructor;
|
16
|
+
}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
17
|
+
gutter: {
|
18
|
+
default: string | boolean;
|
19
|
+
type: PropType<string | boolean>;
|
20
|
+
};
|
21
|
+
height: StringConstructor;
|
22
|
+
}>> & Readonly<{}>, {
|
23
|
+
gutter: string | boolean;
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
25
|
+
export default _default;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Plugin } from 'vue';
|
2
|
+
import Row from './Row';
|
3
|
+
import Col from './Col';
|
4
|
+
import Item from './Item';
|
5
|
+
export declare const Rowflex: typeof Row & Plugin;
|
6
|
+
export declare const Colflex: typeof Col & Plugin;
|
7
|
+
export declare const Flexitem: typeof Item & Plugin;
|
8
|
+
export type { RowProps as RowflexProps } from './Row';
|
9
|
+
export type { ColProps as ColflexProps } from './Col';
|
10
|
+
export type { ItemProps as FlexitemProps } from './Item';
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import { defineComponent, computed, createVNode } from 'vue';
|
2
|
+
import classNames from '../_util/classNames.js';
|
3
|
+
import OrionError from '../../error/OrionError.js';
|
4
|
+
import { anyType, booleanType } from '../_util/type.js';
|
5
|
+
import '../_util/util.js';
|
6
|
+
|
7
|
+
const rowProps = () => ({
|
8
|
+
gutter: anyType(),
|
9
|
+
height: String
|
10
|
+
});
|
11
|
+
var Row = defineComponent({
|
12
|
+
name: 'ORowflex',
|
13
|
+
inheritAttrs: false,
|
14
|
+
props: rowProps(),
|
15
|
+
setup(props, {
|
16
|
+
slots,
|
17
|
+
attrs,
|
18
|
+
emit,
|
19
|
+
expose
|
20
|
+
}) {
|
21
|
+
const style = computed(() => {
|
22
|
+
const rowStyle = {};
|
23
|
+
rowStyle.gap = props.gutter === true || props.gutter === '' ? `var(--orion-flex-gutter)` : props.gutter ? props.gutter : undefined;
|
24
|
+
if (props.height) {
|
25
|
+
if (props.height == 'fill') {
|
26
|
+
throw new OrionError(`ORowflex的height无法配置为['fill'],可以设置的值如['need', '100%', '200px'],请检查!`);
|
27
|
+
} else if (props.height == 'need') ; else {
|
28
|
+
rowStyle.height = props.height;
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
rowStyle.height = '100%';
|
32
|
+
}
|
33
|
+
return rowStyle;
|
34
|
+
});
|
35
|
+
return () => {
|
36
|
+
const children = slots.default?.();
|
37
|
+
const cn = classNames('orion-flex', 'orion-flex-row', 'orion-flex-justify-start');
|
38
|
+
return createVNode("div", {
|
39
|
+
"class": [cn, attrs.class],
|
40
|
+
"style": [style.value, attrs.style]
|
41
|
+
}, [children]);
|
42
|
+
};
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
const colProps = () => ({
|
47
|
+
gutter: anyType(),
|
48
|
+
height: String
|
49
|
+
});
|
50
|
+
var Col = defineComponent({
|
51
|
+
name: 'OColflex',
|
52
|
+
inheritAttrs: false,
|
53
|
+
props: colProps(),
|
54
|
+
setup(props, {
|
55
|
+
slots,
|
56
|
+
attrs,
|
57
|
+
emit,
|
58
|
+
expose
|
59
|
+
}) {
|
60
|
+
const style = computed(() => {
|
61
|
+
const rowStyle = {};
|
62
|
+
rowStyle.gap = props.gutter === true || props.gutter === '' ? `var(--orion-flex-gutter)` : props.gutter ? props.gutter : undefined;
|
63
|
+
if (props.height) {
|
64
|
+
if (props.height == 'fill') {
|
65
|
+
throw new OrionError(`OColflex的height无法配置为['fill'],可以设置的值如['need', '100%', '200px'],请检查!`);
|
66
|
+
} else if (props.height == 'need') ; else {
|
67
|
+
rowStyle.height = props.height;
|
68
|
+
}
|
69
|
+
} else {
|
70
|
+
rowStyle.height = '100%';
|
71
|
+
}
|
72
|
+
return rowStyle;
|
73
|
+
});
|
74
|
+
return () => {
|
75
|
+
const children = slots.default?.();
|
76
|
+
const cn = classNames('orion-flex', 'orion-flex-column');
|
77
|
+
return createVNode("div", {
|
78
|
+
"class": [cn, attrs.class],
|
79
|
+
"style": [style.value, attrs.style]
|
80
|
+
}, [children]);
|
81
|
+
};
|
82
|
+
}
|
83
|
+
});
|
84
|
+
|
85
|
+
const itemProps = () => ({
|
86
|
+
flexBasic: String,
|
87
|
+
hidden: booleanType(false)
|
88
|
+
});
|
89
|
+
var Item = defineComponent({
|
90
|
+
name: 'OFlexitem',
|
91
|
+
inheritAttrs: false,
|
92
|
+
props: itemProps(),
|
93
|
+
setup(props, {
|
94
|
+
slots,
|
95
|
+
attrs,
|
96
|
+
emit,
|
97
|
+
expose
|
98
|
+
}) {
|
99
|
+
const style = computed(() => {
|
100
|
+
const itemStyle = {};
|
101
|
+
if (props.flexBasic !== 'need' && props.flexBasic !== 'fill') {
|
102
|
+
itemStyle['flex'] = `0 0 ${props.flexBasic}`;
|
103
|
+
}
|
104
|
+
return itemStyle;
|
105
|
+
});
|
106
|
+
const classes = computed(() => {
|
107
|
+
const {
|
108
|
+
hidden
|
109
|
+
} = props;
|
110
|
+
let flexClass = 'orion-flexitem-fill';
|
111
|
+
if (props.flexBasic) {
|
112
|
+
if (props.flexBasic == 'need') {
|
113
|
+
flexClass = 'orion-flexitem-auto';
|
114
|
+
} else if (props.flexBasic !== 'need' && props.flexBasic !== 'fill') {
|
115
|
+
flexClass = 'orion-flexitem-fixed';
|
116
|
+
}
|
117
|
+
}
|
118
|
+
return ['orion-flexitem', flexClass, {
|
119
|
+
[`orion-hidden`]: hidden
|
120
|
+
}];
|
121
|
+
});
|
122
|
+
return () => {
|
123
|
+
const children = slots.default?.();
|
124
|
+
return createVNode("div", {
|
125
|
+
"class": [classes.value, attrs.class],
|
126
|
+
"style": [style.value, attrs.style]
|
127
|
+
}, [children]);
|
128
|
+
};
|
129
|
+
}
|
130
|
+
});
|
131
|
+
|
132
|
+
Row.install = function (app) {
|
133
|
+
// @ts-ignore
|
134
|
+
app.component(Row.name, Row);
|
135
|
+
return app;
|
136
|
+
};
|
137
|
+
Col.install = function (app) {
|
138
|
+
// @ts-ignore
|
139
|
+
app.component(Col.name, Col);
|
140
|
+
return app;
|
141
|
+
};
|
142
|
+
Item.install = function (app) {
|
143
|
+
// @ts-ignore
|
144
|
+
app.component(Item.name, Item);
|
145
|
+
return app;
|
146
|
+
};
|
147
|
+
const Rowflex = Row;
|
148
|
+
const Colflex = Col;
|
149
|
+
const Flexitem = Item;
|
150
|
+
|
151
|
+
export { Colflex, Flexitem, Rowflex };
|
@@ -0,0 +1,2 @@
|
|
1
|
+
declare const OModal: import("vue").DefineComponent<{}, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
2
|
+
export default OModal;
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import type { PropType, ExtractPropTypes, Plugin } from 'vue';
|
2
|
+
import type { CustomSlotsType } from '../_util/type';
|
3
|
+
export declare const spaceProps: () => {
|
4
|
+
gutter: {
|
5
|
+
default: string | boolean;
|
6
|
+
type: PropType<string | boolean>;
|
7
|
+
};
|
8
|
+
vertical: {
|
9
|
+
default: string | boolean;
|
10
|
+
type: PropType<string | boolean>;
|
11
|
+
};
|
12
|
+
};
|
13
|
+
export type SpaceProps = Partial<ExtractPropTypes<ReturnType<typeof spaceProps>>>;
|
14
|
+
declare const _default: {
|
15
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<ExtractPropTypes<{
|
16
|
+
gutter: {
|
17
|
+
default: string | boolean;
|
18
|
+
type: PropType<string | boolean>;
|
19
|
+
};
|
20
|
+
vertical: {
|
21
|
+
default: string | boolean;
|
22
|
+
type: PropType<string | boolean>;
|
23
|
+
};
|
24
|
+
}>> & Readonly<{}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Readonly<ExtractPropTypes<{
|
25
|
+
gutter: {
|
26
|
+
default: string | boolean;
|
27
|
+
type: PropType<string | boolean>;
|
28
|
+
};
|
29
|
+
vertical: {
|
30
|
+
default: string | boolean;
|
31
|
+
type: PropType<string | boolean>;
|
32
|
+
};
|
33
|
+
}>> & Readonly<{}>, {
|
34
|
+
gutter: string | boolean;
|
35
|
+
vertical: string | boolean;
|
36
|
+
}, true, {}, CustomSlotsType<{
|
37
|
+
default?: any;
|
38
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
39
|
+
P: {};
|
40
|
+
B: {};
|
41
|
+
D: {};
|
42
|
+
C: {};
|
43
|
+
M: {};
|
44
|
+
Defaults: {};
|
45
|
+
}, Readonly<ExtractPropTypes<{
|
46
|
+
gutter: {
|
47
|
+
default: string | boolean;
|
48
|
+
type: PropType<string | boolean>;
|
49
|
+
};
|
50
|
+
vertical: {
|
51
|
+
default: string | boolean;
|
52
|
+
type: PropType<string | boolean>;
|
53
|
+
};
|
54
|
+
}>> & Readonly<{}>, () => any, {}, {}, {}, {
|
55
|
+
gutter: string | boolean;
|
56
|
+
vertical: string | boolean;
|
57
|
+
}>;
|
58
|
+
__isFragment?: never;
|
59
|
+
__isTeleport?: never;
|
60
|
+
__isSuspense?: never;
|
61
|
+
} & import("vue").ComponentOptionsBase<Readonly<ExtractPropTypes<{
|
62
|
+
gutter: {
|
63
|
+
default: string | boolean;
|
64
|
+
type: PropType<string | boolean>;
|
65
|
+
};
|
66
|
+
vertical: {
|
67
|
+
default: string | boolean;
|
68
|
+
type: PropType<string | boolean>;
|
69
|
+
};
|
70
|
+
}>> & Readonly<{}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
71
|
+
gutter: string | boolean;
|
72
|
+
vertical: string | boolean;
|
73
|
+
}, {}, string, CustomSlotsType<{
|
74
|
+
default?: any;
|
75
|
+
}>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & Plugin;
|
76
|
+
export default _default;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { isString, isArray, isObject } from './util.js';
|
2
|
+
|
3
|
+
function classNames(...args) {
|
4
|
+
const classes = [];
|
5
|
+
for (let i = 0; i < args.length; i++) {
|
6
|
+
const value = args[i];
|
7
|
+
if (!value) continue;
|
8
|
+
if (isString(value)) {
|
9
|
+
// @ts-ignore
|
10
|
+
classes.push(value);
|
11
|
+
} else if (isArray(value)) {
|
12
|
+
for (let i = 0; i < value.length; i++) {
|
13
|
+
const inner = classNames(value[i]);
|
14
|
+
if (inner) {
|
15
|
+
// @ts-ignore
|
16
|
+
classes.push(inner);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
} else if (isObject(value)) {
|
20
|
+
for (const name in value) {
|
21
|
+
if (value[name]) {
|
22
|
+
// @ts-ignore
|
23
|
+
classes.push(name);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
return classes.join(' ');
|
29
|
+
}
|
30
|
+
|
31
|
+
export { classNames as default };
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import initDefaultProps from './initDefaultProps';
|
2
|
+
export declare const skipFlattenKey: unique symbol;
|
3
|
+
export declare const flattenChildren: (children?: any[], filterEmpty?: boolean) => any[];
|
4
|
+
export declare function filterEmpty(children?: any[]): any[];
|
5
|
+
export declare function isEmptyElement(c: any): boolean;
|
6
|
+
export { initDefaultProps };
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Fragment, isVNode, Comment, Text } from 'vue';
|
2
|
+
import isValid from '../isValid.js';
|
3
|
+
export { default as initDefaultProps } from './initDefaultProps.js';
|
4
|
+
|
5
|
+
const skipFlattenKey = Symbol('skipFlatten');
|
6
|
+
const flattenChildren = (children = [], filterEmpty = true) => {
|
7
|
+
const temp = Array.isArray(children) ? children : [children];
|
8
|
+
const res = [];
|
9
|
+
temp.forEach(child => {
|
10
|
+
if (Array.isArray(child)) {
|
11
|
+
res.push(...flattenChildren(child, filterEmpty));
|
12
|
+
// @ts-ignore
|
13
|
+
} else if (child && child.type === Fragment) {
|
14
|
+
// @ts-ignore
|
15
|
+
if (child.key === skipFlattenKey) {
|
16
|
+
res.push(child);
|
17
|
+
} else {
|
18
|
+
// @ts-ignore
|
19
|
+
res.push(...flattenChildren(child.children, filterEmpty));
|
20
|
+
}
|
21
|
+
} else if (child && isVNode(child)) {
|
22
|
+
if (filterEmpty && !isEmptyElement(child)) {
|
23
|
+
res.push(child);
|
24
|
+
} else if (!filterEmpty) {
|
25
|
+
res.push(child);
|
26
|
+
}
|
27
|
+
} else if (isValid(child)) {
|
28
|
+
res.push(child);
|
29
|
+
}
|
30
|
+
});
|
31
|
+
return res;
|
32
|
+
};
|
33
|
+
function filterEmpty(children = []) {
|
34
|
+
const res = [];
|
35
|
+
children.forEach(child => {
|
36
|
+
if (Array.isArray(child)) {
|
37
|
+
// @ts-ignore
|
38
|
+
res.push(...child);
|
39
|
+
// @ts-ignore
|
40
|
+
} else if (child?.type === Fragment) {
|
41
|
+
// @ts-ignore
|
42
|
+
res.push(...filterEmpty(child.children));
|
43
|
+
} else {
|
44
|
+
res.push(child);
|
45
|
+
}
|
46
|
+
});
|
47
|
+
return res.filter(c => !isEmptyElement(c));
|
48
|
+
}
|
49
|
+
function isEmptyElement(c) {
|
50
|
+
return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === '');
|
51
|
+
}
|
52
|
+
|
53
|
+
export { filterEmpty, flattenChildren, isEmptyElement, skipFlattenKey };
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { PropType } from 'vue';
|
2
|
+
import type { VueTypeValidableDef, VueTypeDef } from 'vue-types';
|
3
|
+
declare const initDefaultProps: <T>(types: T, defaultProps: { [K in keyof T]?: T[K] extends VueTypeValidableDef<infer U> ? U : T[K] extends VueTypeDef<infer U> ? U : T[K] extends {
|
4
|
+
type: PropType<infer U>;
|
5
|
+
} ? U : any; }) => T;
|
6
|
+
export default initDefaultProps;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
const initDefaultProps = (types, defaultProps) => {
|
2
|
+
const propTypes = {
|
3
|
+
...types
|
4
|
+
};
|
5
|
+
Object.keys(defaultProps).forEach(k => {
|
6
|
+
const prop = propTypes[k];
|
7
|
+
if (prop) {
|
8
|
+
if (prop.type || prop.default) {
|
9
|
+
prop.default = defaultProps[k];
|
10
|
+
} else if (prop.def) {
|
11
|
+
prop.def(defaultProps[k]);
|
12
|
+
} else {
|
13
|
+
propTypes[k] = {
|
14
|
+
type: prop,
|
15
|
+
default: defaultProps[k]
|
16
|
+
};
|
17
|
+
}
|
18
|
+
} else {
|
19
|
+
throw new Error(`not have ${k} prop`);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
return propTypes;
|
23
|
+
};
|
24
|
+
|
25
|
+
export { initDefaultProps as default };
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import type { PropType, Plugin, Ref, VNode, SlotsType } from 'vue';
|
2
|
+
export declare const tuple: <T extends string[]>(...args: T) => T;
|
3
|
+
export declare const tupleNum: <T extends number[]>(...args: T) => T;
|
4
|
+
/**
|
5
|
+
* https://stackoverflow.com/a/59187769
|
6
|
+
* Extract the type of an element of an array/tuple without performing indexing
|
7
|
+
*/
|
8
|
+
export type ElementOf<T> = T extends (infer E)[] ? E : T extends readonly (infer F)[] ? F : never;
|
9
|
+
/**
|
10
|
+
* https://github.com/Microsoft/TypeScript/issues/29729
|
11
|
+
*/
|
12
|
+
export type LiteralUnion<T extends string> = T | (string & {});
|
13
|
+
export type Data = Record<string, unknown>;
|
14
|
+
export type Key = string | number;
|
15
|
+
type DefaultFactory<T> = (props: Data) => T | null | undefined;
|
16
|
+
export interface PropOptions<T = any, D = T> {
|
17
|
+
type?: PropType<T> | true | null;
|
18
|
+
required?: boolean;
|
19
|
+
default?: D | DefaultFactory<D> | null | undefined | object;
|
20
|
+
validator?(value: unknown): boolean;
|
21
|
+
}
|
22
|
+
declare type VNodeChildAtom = VNode | string | number | boolean | null | undefined | void;
|
23
|
+
export type VueNode = VNodeChildAtom | VNodeChildAtom[] | VNode;
|
24
|
+
export declare const withInstall: <T>(comp: T) => T & Plugin;
|
25
|
+
export type MaybeRef<T> = T | Ref<T>;
|
26
|
+
export declare function eventType<T>(): {
|
27
|
+
type: PropType<T | T[]>;
|
28
|
+
};
|
29
|
+
export declare function objectType<T = {}>(defaultVal?: T): {
|
30
|
+
type: PropType<T>;
|
31
|
+
default: T;
|
32
|
+
};
|
33
|
+
export declare function booleanType(defaultVal?: boolean): {
|
34
|
+
type: BooleanConstructor;
|
35
|
+
default: boolean;
|
36
|
+
};
|
37
|
+
export declare function functionType<T = () => {}>(defaultVal?: T): {
|
38
|
+
type: PropType<T>;
|
39
|
+
default: T;
|
40
|
+
};
|
41
|
+
export declare function anyType<T = any>(defaultVal?: T, required?: boolean): {
|
42
|
+
default: T;
|
43
|
+
type: PropType<T>;
|
44
|
+
};
|
45
|
+
export declare function vNodeType<T = VueNode>(): {
|
46
|
+
type: PropType<T>;
|
47
|
+
};
|
48
|
+
export declare function arrayType<T extends any[]>(defaultVal?: T): {
|
49
|
+
type: PropType<T>;
|
50
|
+
default: T;
|
51
|
+
};
|
52
|
+
export declare function stringType<T extends string = string>(defaultVal?: T): {
|
53
|
+
type: PropType<T>;
|
54
|
+
default: T;
|
55
|
+
};
|
56
|
+
export declare function someType<T>(types?: any[], defaultVal?: T): {
|
57
|
+
type: PropType<T>;
|
58
|
+
default: T;
|
59
|
+
};
|
60
|
+
export type CustomSlotsType<T> = SlotsType<T>;
|
61
|
+
export type AnyObject = Record<PropertyKey, any>;
|
62
|
+
export {};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
|
2
|
+
const tuple = (...args) => args;
|
3
|
+
const tupleNum = (...args) => args;
|
4
|
+
const withInstall = comp => {
|
5
|
+
const c = comp;
|
6
|
+
c.install = function (app) {
|
7
|
+
// @ts-ignore
|
8
|
+
app.component(c.displayName || c.name, comp);
|
9
|
+
};
|
10
|
+
return comp;
|
11
|
+
};
|
12
|
+
function eventType() {
|
13
|
+
return {
|
14
|
+
type: [Function, Array]
|
15
|
+
};
|
16
|
+
}
|
17
|
+
function objectType(defaultVal) {
|
18
|
+
return {
|
19
|
+
type: Object,
|
20
|
+
default: defaultVal
|
21
|
+
};
|
22
|
+
}
|
23
|
+
function booleanType(defaultVal) {
|
24
|
+
return {
|
25
|
+
type: Boolean,
|
26
|
+
default: defaultVal
|
27
|
+
};
|
28
|
+
}
|
29
|
+
function functionType(defaultVal) {
|
30
|
+
return {
|
31
|
+
type: Function,
|
32
|
+
default: defaultVal
|
33
|
+
};
|
34
|
+
}
|
35
|
+
function anyType(defaultVal, required) {
|
36
|
+
const type = {
|
37
|
+
validator: () => true,
|
38
|
+
default: defaultVal
|
39
|
+
};
|
40
|
+
return required ? type : type;
|
41
|
+
}
|
42
|
+
function vNodeType() {
|
43
|
+
return {
|
44
|
+
validator: () => true
|
45
|
+
};
|
46
|
+
}
|
47
|
+
function arrayType(defaultVal) {
|
48
|
+
return {
|
49
|
+
type: Array,
|
50
|
+
default: defaultVal
|
51
|
+
};
|
52
|
+
}
|
53
|
+
function stringType(defaultVal) {
|
54
|
+
return {
|
55
|
+
type: String,
|
56
|
+
default: defaultVal
|
57
|
+
};
|
58
|
+
}
|
59
|
+
function someType(types, defaultVal) {
|
60
|
+
return types ? {
|
61
|
+
type: types,
|
62
|
+
default: defaultVal
|
63
|
+
} : anyType(defaultVal);
|
64
|
+
}
|
65
|
+
|
66
|
+
export { anyType, arrayType, booleanType, eventType, functionType, objectType, someType, stringType, tuple, tupleNum, vNodeType, withInstall };
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { VueNode } from './type';
|
2
|
+
export declare const isFunction: (val: any) => boolean;
|
3
|
+
export declare const controlDefaultValue: any;
|
4
|
+
export declare const isArray: (arg: any) => arg is any[];
|
5
|
+
export declare const isString: (val: any) => val is string;
|
6
|
+
export declare const isSymbol: (val: any) => val is symbol;
|
7
|
+
export declare const isObject: (val: any) => boolean;
|
8
|
+
declare const isOn: (key: any) => boolean;
|
9
|
+
declare const cacheStringFunction: (fn: any) => (str: any) => any;
|
10
|
+
declare const camelize: (str: any) => any;
|
11
|
+
declare const hyphenate: (str: any) => any;
|
12
|
+
declare const capitalize: (str: any) => any;
|
13
|
+
declare function resolvePropValue(options: any, props: any, key: any, value: any): any;
|
14
|
+
export declare function getDataAndAriaProps(props: any): {};
|
15
|
+
export declare function toPx(val: any): any;
|
16
|
+
export declare function renderHelper<T = Record<string, any>>(v: VueNode | ((arg0: T) => VueNode), props?: T, defaultV?: any): any;
|
17
|
+
export declare function wrapPromiseFn(openFn: (resolve: VoidFunction) => VoidFunction): any;
|
18
|
+
export { isOn, cacheStringFunction, camelize, hyphenate, capitalize, resolvePropValue };
|