duck-vue-components 0.0.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.
- package/README.md +29 -0
- package/dist/MyButton-C1krVCi6.cjs +36 -0
- package/dist/MyButton-C7riFwH6.js +28 -0
- package/dist/_plugin-vue_export-helper-DQXgr64F.cjs +13 -0
- package/dist/_plugin-vue_export-helper-DbXABBKy.js +8 -0
- package/dist/affix-CYU-9qMr.cjs +71 -0
- package/dist/affix-D9EM8_Um.js +66 -0
- package/dist/button-CGv1WHzT.cjs +132 -0
- package/dist/button-tOWSPPxz.js +126 -0
- package/dist/chunk-CZWwpsFl.cjs +43 -0
- package/dist/chunk-pbuEa-1d.js +13 -0
- package/dist/config.cjs +1 -0
- package/dist/config.js +1 -0
- package/dist/constants/json.cjs +4 -0
- package/dist/constants/json.d.cts +2 -0
- package/dist/constants/json.d.ts +2 -0
- package/dist/constants/json.js +2 -0
- package/dist/constants.cjs +14 -0
- package/dist/constants.d.cts +3 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +3 -0
- package/dist/controls/MyButton.cjs +3 -0
- package/dist/controls/MyButton.d.cts +2 -0
- package/dist/controls/MyButton.d.ts +2 -0
- package/dist/controls/MyButton.js +2 -0
- package/dist/controls/affix.cjs +8 -0
- package/dist/controls/affix.d.cts +2 -0
- package/dist/controls/affix.d.ts +2 -0
- package/dist/controls/affix.js +2 -0
- package/dist/controls/button.cjs +8 -0
- package/dist/controls/button.js +2 -0
- package/dist/controls.cjs +18 -0
- package/dist/controls.d.cts +10 -0
- package/dist/controls.d.ts +10 -0
- package/dist/controls.js +5 -0
- package/dist/dom-CllENWMY.js +346 -0
- package/dist/dom-DS4YqkjW.cjs +580 -0
- package/dist/index-1ELDRrC5.d.ts +1397 -0
- package/dist/index-5JdIJn1m.d.cts +74 -0
- package/dist/index-6KzLtJFy.d.cts +157 -0
- package/dist/index-BGkTN1DD.d.cts +15 -0
- package/dist/index-BHq-BMCP.d.ts +74 -0
- package/dist/index-BI-hrf4t.d.ts +332 -0
- package/dist/index-BtOBjeH7.d.ts +10 -0
- package/dist/index-C-uY4885.d.cts +23 -0
- package/dist/index-C5SJLWEN.d.ts +23 -0
- package/dist/index-CSvc8L11.d.cts +51 -0
- package/dist/index-CeemHBNT.d.ts +51 -0
- package/dist/index-CfkAYIKD.d.cts +80 -0
- package/dist/index-CiJC-ieW.d.ts +157 -0
- package/dist/index-DamAmum6.d.ts +15 -0
- package/dist/index-DhOoJCHW.d.cts +1397 -0
- package/dist/index-PhthUD7x.d.cts +10 -0
- package/dist/index-oDsyZ3t2.d.cts +332 -0
- package/dist/index-x9xs2cbA.d.ts +80 -0
- package/dist/json-BkkaM20u.cjs +31034 -0
- package/dist/json-D-_zTSK6.js +31023 -0
- package/dist/locale-DhlAaV1Q.js +597 -0
- package/dist/locale-WzzxOobw.cjs +658 -0
- package/dist/locale.cjs +12 -0
- package/dist/locale.js +2 -0
- package/dist/objects-CLXPNOUW.js +134 -0
- package/dist/objects-o7u5s_lI.cjs +272 -0
- package/dist/packages/config.cjs +10 -0
- package/dist/packages/config.d.cts +2 -0
- package/dist/packages/config.d.ts +2 -0
- package/dist/packages/config.js +5 -0
- package/dist/packages/constants/json.cjs +4 -0
- package/dist/packages/constants/json.js +2 -0
- package/dist/packages/constants.cjs +78 -0
- package/dist/packages/constants.js +67 -0
- package/dist/packages/controls/MyButton.cjs +3 -0
- package/dist/packages/controls/MyButton.js +2 -0
- package/dist/packages/controls/affix.cjs +8 -0
- package/dist/packages/controls/affix.js +2 -0
- package/dist/packages/controls/button.cjs +8 -0
- package/dist/packages/controls/button.d.cts +2 -0
- package/dist/packages/controls/button.d.ts +2 -0
- package/dist/packages/controls/button.js +2 -0
- package/dist/packages/controls.cjs +31 -0
- package/dist/packages/controls.js +12 -0
- package/dist/packages/locale.cjs +12 -0
- package/dist/packages/locale.d.cts +39 -0
- package/dist/packages/locale.d.ts +39 -0
- package/dist/packages/locale.js +2 -0
- package/dist/packages/stores.cjs +337 -0
- package/dist/packages/stores.js +320 -0
- package/dist/packages/utils/dom.cjs +32 -0
- package/dist/packages/utils/dom.d.cts +2 -0
- package/dist/packages/utils/dom.d.ts +2 -0
- package/dist/packages/utils/dom.js +2 -0
- package/dist/packages/utils/vue/props.cjs +63 -0
- package/dist/packages/utils/vue/props.d.cts +2 -0
- package/dist/packages/utils/vue/props.d.ts +2 -0
- package/dist/packages/utils/vue/props.js +56 -0
- package/dist/packages/utils/vue.cjs +32 -0
- package/dist/packages/utils/vue.d.cts +3 -0
- package/dist/packages/utils/vue.d.ts +3 -0
- package/dist/packages/utils/vue.js +24 -0
- package/dist/packages/utils.cjs +190 -0
- package/dist/packages/utils.js +6 -0
- package/dist/packages.cjs +15 -0
- package/dist/packages.d.cts +3 -0
- package/dist/packages.d.ts +3 -0
- package/dist/packages.js +3 -0
- package/dist/stores.cjs +17 -0
- package/dist/stores.d.cts +805 -0
- package/dist/stores.d.ts +805 -0
- package/dist/stores.js +4 -0
- package/dist/style.css +15 -0
- package/dist/utils/dom.cjs +32 -0
- package/dist/utils/dom.js +2 -0
- package/dist/utils/vue/props.cjs +7 -0
- package/dist/utils/vue/props.js +2 -0
- package/dist/utils/vue.cjs +11 -0
- package/dist/utils/vue.js +3 -0
- package/dist/utils-DlBKdS0t.js +696 -0
- package/dist/utils-egS_3P4w.cjs +850 -0
- package/dist/utils.cjs +190 -0
- package/dist/utils.d.cts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +6 -0
- package/package.json +184 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as baseT } from "./index-5JdIJn1m.cjs";
|
|
2
|
+
import { o as SFCWithInstall } from "./index-BGkTN1DD.cjs";
|
|
3
|
+
import * as _$vue from "vue";
|
|
4
|
+
import { AffixEmits, AffixProps } from "element-plus";
|
|
5
|
+
|
|
6
|
+
//#region src/packages/controls/affix/affix.vue.d.ts
|
|
7
|
+
type __VLS_Props = {
|
|
8
|
+
control: Partial<OptionT>;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: _$vue.DefineComponent<__VLS_Props, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
declare namespace affix_d_exports {
|
|
13
|
+
export { OptionT, Template, init };
|
|
14
|
+
}
|
|
15
|
+
declare const Template: SFCWithInstall<typeof _default>;
|
|
16
|
+
type OptionT = AffixProps & AffixEmits & baseT & {
|
|
17
|
+
default: any;
|
|
18
|
+
moduleName: string;
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
declare function init(moduleName: string, name: string, options?: Partial<OptionT>): Partial<OptionT>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { affix_d_exports as t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as baseT } from "./index-BHq-BMCP.js";
|
|
2
|
+
import { o as SFCWithInstall } from "./index-DamAmum6.js";
|
|
3
|
+
import * as _$vue from "vue";
|
|
4
|
+
import { AffixEmits, AffixProps } from "element-plus";
|
|
5
|
+
|
|
6
|
+
//#region src/packages/controls/affix/affix.vue.d.ts
|
|
7
|
+
type __VLS_Props = {
|
|
8
|
+
control: Partial<OptionT>;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: _$vue.DefineComponent<__VLS_Props, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
declare namespace affix_d_exports {
|
|
13
|
+
export { OptionT, Template, init };
|
|
14
|
+
}
|
|
15
|
+
declare const Template: SFCWithInstall<typeof _default>;
|
|
16
|
+
type OptionT = AffixProps & AffixEmits & baseT & {
|
|
17
|
+
default: any;
|
|
18
|
+
moduleName: string;
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
declare function init(moduleName: string, name: string, options?: Partial<OptionT>): Partial<OptionT>;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { affix_d_exports as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as baseT } from "./index-5JdIJn1m.cjs";
|
|
2
|
+
import { o as SFCWithInstall } from "./index-BGkTN1DD.cjs";
|
|
3
|
+
import { O as Mutable } from "./index-oDsyZ3t2.cjs";
|
|
4
|
+
import * as _$vue from "vue";
|
|
5
|
+
import { Component } from "vue";
|
|
6
|
+
import { ButtonProps } from "element-plus";
|
|
7
|
+
|
|
8
|
+
//#region src/packages/controls/button/button.vue.d.ts
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
control: Partial<OptionT>;
|
|
11
|
+
};
|
|
12
|
+
declare var __VLS_11: {}, __VLS_35: {}, __VLS_43: {};
|
|
13
|
+
type __VLS_Slots = {} & {
|
|
14
|
+
default?: (props: typeof __VLS_11) => any;
|
|
15
|
+
} & {
|
|
16
|
+
loading?: (props: typeof __VLS_35) => any;
|
|
17
|
+
} & {
|
|
18
|
+
icon?: (props: typeof __VLS_43) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: _$vue.DefineComponent<__VLS_Props, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
|
|
21
|
+
click: (...args: any[]) => void;
|
|
22
|
+
}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default_1: typeof __VLS_export;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
declare namespace button_d_exports {
|
|
33
|
+
export { OptionT, Template, init };
|
|
34
|
+
}
|
|
35
|
+
declare const Template: SFCWithInstall<typeof _default_1>;
|
|
36
|
+
type OptionT = Mutable<ButtonProps> & baseT & {
|
|
37
|
+
default: any;
|
|
38
|
+
loadingSlot: any;
|
|
39
|
+
iconSlot: any;
|
|
40
|
+
moduleName: string;
|
|
41
|
+
name: string;
|
|
42
|
+
customized: boolean;
|
|
43
|
+
suffixIcon: any | string | Component;
|
|
44
|
+
tag: any;
|
|
45
|
+
separator: boolean;
|
|
46
|
+
click: (e: any) => any | Promise<any>;
|
|
47
|
+
refreshButton?: (options: any, data?: any) => Partial<OptionT>;
|
|
48
|
+
};
|
|
49
|
+
declare function init(moduleName: string, name: string, options?: Partial<OptionT>): Partial<OptionT>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { button_d_exports as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { t as baseT } from "./index-BHq-BMCP.js";
|
|
2
|
+
import { o as SFCWithInstall } from "./index-DamAmum6.js";
|
|
3
|
+
import { O as Mutable } from "./index-BI-hrf4t.js";
|
|
4
|
+
import * as _$vue from "vue";
|
|
5
|
+
import { Component } from "vue";
|
|
6
|
+
import { ButtonProps } from "element-plus";
|
|
7
|
+
|
|
8
|
+
//#region src/packages/controls/button/button.vue.d.ts
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
control: Partial<OptionT>;
|
|
11
|
+
};
|
|
12
|
+
declare var __VLS_11: {}, __VLS_35: {}, __VLS_43: {};
|
|
13
|
+
type __VLS_Slots = {} & {
|
|
14
|
+
default?: (props: typeof __VLS_11) => any;
|
|
15
|
+
} & {
|
|
16
|
+
loading?: (props: typeof __VLS_35) => any;
|
|
17
|
+
} & {
|
|
18
|
+
icon?: (props: typeof __VLS_43) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: _$vue.DefineComponent<__VLS_Props, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {
|
|
21
|
+
click: (...args: any[]) => void;
|
|
22
|
+
}, string, _$vue.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
|
+
onClick?: ((...args: any[]) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default_1: typeof __VLS_export;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
declare namespace button_d_exports {
|
|
33
|
+
export { OptionT, Template, init };
|
|
34
|
+
}
|
|
35
|
+
declare const Template: SFCWithInstall<typeof _default_1>;
|
|
36
|
+
type OptionT = Mutable<ButtonProps> & baseT & {
|
|
37
|
+
default: any;
|
|
38
|
+
loadingSlot: any;
|
|
39
|
+
iconSlot: any;
|
|
40
|
+
moduleName: string;
|
|
41
|
+
name: string;
|
|
42
|
+
customized: boolean;
|
|
43
|
+
suffixIcon: any | string | Component;
|
|
44
|
+
tag: any;
|
|
45
|
+
separator: boolean;
|
|
46
|
+
click: (e: any) => any | Promise<any>;
|
|
47
|
+
refreshButton?: (options: any, data?: any) => Partial<OptionT>;
|
|
48
|
+
};
|
|
49
|
+
declare function init(moduleName: string, name: string, options?: Partial<OptionT>): Partial<OptionT>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { button_d_exports as t };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CSSProperties } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/packages/utils/dom/aria.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Determine if the testing element is visible on screen no matter if its on the viewport or not
|
|
6
|
+
*/
|
|
7
|
+
declare const isVisible: (element: HTMLElement) => boolean;
|
|
8
|
+
declare const obtainAllFocusableElements: (element: HTMLElement) => HTMLElement[];
|
|
9
|
+
/**
|
|
10
|
+
* @desc Determine if target element is focusable
|
|
11
|
+
* @param element {HTMLElement}
|
|
12
|
+
* @returns {Boolean} true if it is focusable
|
|
13
|
+
*/
|
|
14
|
+
declare const isFocusable: (element: HTMLElement) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @desc Set Attempt to set focus on the current node.
|
|
17
|
+
* @param element
|
|
18
|
+
* The node to attempt to focus on.
|
|
19
|
+
* @returns
|
|
20
|
+
* true if element is focused.
|
|
21
|
+
*/
|
|
22
|
+
declare const attemptFocus: (element: HTMLElement) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Trigger an event
|
|
25
|
+
* mouseenter, mouseleave, mouseover, keyup, change, click, etc.
|
|
26
|
+
* @param {HTMLElement} elm
|
|
27
|
+
* @param {String} name
|
|
28
|
+
* @param {*} opts
|
|
29
|
+
*/
|
|
30
|
+
declare const triggerEvent: (elm: HTMLElement, name: string, ...opts: Array<boolean>) => HTMLElement;
|
|
31
|
+
declare const isLeaf: (el: HTMLElement) => boolean;
|
|
32
|
+
declare const getSibling: (el: HTMLElement, distance: number, elClass: string) => Element | null;
|
|
33
|
+
declare const focusNode: (el: HTMLElement) => void;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/packages/utils/dom/event.d.ts
|
|
36
|
+
declare const composeEventHandlers: <E>(theirsHandler?: (event: E) => boolean | void, oursHandler?: (event: E) => void, {
|
|
37
|
+
checkForDefaultPrevented
|
|
38
|
+
}?: {
|
|
39
|
+
checkForDefaultPrevented?: boolean | undefined;
|
|
40
|
+
}) => (event: E) => void;
|
|
41
|
+
type WhenMouseHandler = (e: PointerEvent) => any;
|
|
42
|
+
declare const whenMouse: (handler: WhenMouseHandler) => WhenMouseHandler;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/packages/utils/dom/position.d.ts
|
|
45
|
+
declare const isInContainer: (el?: Element, container?: Element | Window) => boolean;
|
|
46
|
+
declare const getOffsetTop: (el: HTMLElement) => number;
|
|
47
|
+
declare const getOffsetTopDistance: (el: HTMLElement, containerEl: HTMLElement) => number;
|
|
48
|
+
declare const getClientXY: (event: MouseEvent | TouchEvent) => {
|
|
49
|
+
clientX: number;
|
|
50
|
+
clientY: number;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/packages/utils/dom/scroll.d.ts
|
|
54
|
+
declare const isScroll: (el: HTMLElement, isVertical?: boolean) => boolean;
|
|
55
|
+
declare const getScrollContainer: (el: HTMLElement, isVertical?: boolean) => Window | HTMLElement | undefined;
|
|
56
|
+
declare const getScrollBarWidth: (namespace: string) => number;
|
|
57
|
+
/**
|
|
58
|
+
* Scroll with in the container element, positioning the **selected** element at the top
|
|
59
|
+
* of the container
|
|
60
|
+
*/
|
|
61
|
+
declare function scrollIntoView(container: HTMLElement, selected: HTMLElement): void;
|
|
62
|
+
declare function animateScrollTo(container: HTMLElement | Window, from: number, to: number, duration: number, callback?: unknown): () => void;
|
|
63
|
+
declare const getScrollElement: (target: HTMLElement, container: HTMLElement | Window) => HTMLElement;
|
|
64
|
+
declare const getScrollTop: (container: HTMLElement | Window) => number;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/packages/utils/dom/style.d.ts
|
|
67
|
+
declare const classNameToArray: (cls?: string) => string[];
|
|
68
|
+
declare const hasClass: (el: Element, cls: string) => boolean;
|
|
69
|
+
declare const addClass: (el: Element, cls: string) => void;
|
|
70
|
+
declare const removeClass: (el: Element, cls: string) => void;
|
|
71
|
+
declare const getStyle: (element: HTMLElement, styleName: keyof CSSProperties) => string;
|
|
72
|
+
declare const setStyle: (element: HTMLElement, styleName: CSSProperties | keyof CSSProperties, value?: string | number) => void;
|
|
73
|
+
declare const removeStyle: (element: HTMLElement, style: CSSProperties | keyof CSSProperties) => void;
|
|
74
|
+
declare function addUnit(value?: string | number, defaultUnit?: string): string | undefined;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/packages/utils/dom/element.d.ts
|
|
77
|
+
type GetElement = <T extends string | HTMLElement | Window | null | undefined>(target: T) => T extends string ? HTMLElement | null : T;
|
|
78
|
+
declare const getElement: GetElement;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { triggerEvent as A, attemptFocus as C, isLeaf as D, isFocusable as E, isVisible as O, whenMouse as S, getSibling as T, getClientXY as _, getStyle as a, isInContainer as b, removeStyle as c, getScrollBarWidth as d, getScrollContainer as f, scrollIntoView as g, isScroll as h, classNameToArray as i, obtainAllFocusableElements as k, setStyle as l, getScrollTop as m, addClass as n, hasClass as o, getScrollElement as p, addUnit as r, removeClass as s, getElement as t, animateScrollTo as u, getOffsetTop as v, focusNode as w, composeEventHandlers as x, getOffsetTopDistance as y };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ExtractPropTypes, PropType } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/packages/utils/vue/props/util.d.ts
|
|
4
|
+
type Writable<T> = { -readonly [P in keyof T]: T[P] };
|
|
5
|
+
type WritableArray<T> = T extends readonly any[] ? Writable<T> : T;
|
|
6
|
+
type IfNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
|
|
7
|
+
type IfUnknown<T, Y, N> = [unknown] extends [T] ? Y : N;
|
|
8
|
+
type UnknownToNever<T> = IfUnknown<T, never, T>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/packages/utils/vue/props/runtime.d.ts
|
|
11
|
+
declare const epPropKey = "__epPropKey";
|
|
12
|
+
declare const definePropType: <T>(val: any) => PropType<T>;
|
|
13
|
+
declare const isEpProp: (val: unknown) => val is EpProp<any, any, any>;
|
|
14
|
+
/**
|
|
15
|
+
* @description Build prop. It can better optimize prop types
|
|
16
|
+
* @description 生成 prop,能更好地优化类型
|
|
17
|
+
* @example
|
|
18
|
+
// limited options
|
|
19
|
+
// the type will be PropType<'light' | 'dark'>
|
|
20
|
+
buildProp({
|
|
21
|
+
type: String,
|
|
22
|
+
values: ['light', 'dark'],
|
|
23
|
+
} as const)
|
|
24
|
+
* @example
|
|
25
|
+
// limited options and other types
|
|
26
|
+
// the type will be PropType<'small' | 'large' | number>
|
|
27
|
+
buildProp({
|
|
28
|
+
type: [String, Number],
|
|
29
|
+
values: ['small', 'large'],
|
|
30
|
+
validator: (val: unknown): val is number => typeof val === 'number',
|
|
31
|
+
} as const)
|
|
32
|
+
@link see more: https://github.com/element-plus/element-plus/pull/3341
|
|
33
|
+
*/
|
|
34
|
+
declare const buildProp: <Type = never, Value = never, Validator = never, Default extends EpPropMergeType<Type, Value, Validator> = never, Required extends boolean = false>(prop: EpPropInput<Type, Value, Validator, Default, Required>, key?: string) => EpPropFinalized<Type, Value, Validator, Default, Required>;
|
|
35
|
+
declare const buildProps: <Props extends Record<string, {
|
|
36
|
+
[epPropKey]: true;
|
|
37
|
+
} | NativePropType | EpPropInput<any, any, any, any, any>>>(props: Props) => { [K in keyof Props]: IfEpProp<Props[K], Props[K], IfNativePropType<Props[K], Props[K], EpPropConvert<Props[K]>>> };
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/packages/utils/vue/props/types.d.ts
|
|
40
|
+
type Value<T> = T[keyof T];
|
|
41
|
+
/**
|
|
42
|
+
* Extract the type of a single prop
|
|
43
|
+
*
|
|
44
|
+
* 提取单个 prop 的参数类型
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ExtractPropType<{ type: StringConstructor }> => string | undefined
|
|
48
|
+
* ExtractPropType<{ type: StringConstructor, required: true }> => string
|
|
49
|
+
* ExtractPropType<{ type: BooleanConstructor }> => boolean
|
|
50
|
+
*/
|
|
51
|
+
type ExtractPropType<T extends object> = Value<ExtractPropTypes<{
|
|
52
|
+
key: T;
|
|
53
|
+
}>>;
|
|
54
|
+
/**
|
|
55
|
+
* Extracts types via `ExtractPropTypes`, accepting `PropType<T>`, `XXXConstructor`, `never`...
|
|
56
|
+
*
|
|
57
|
+
* 通过 `ExtractPropTypes` 提取类型,接受 `PropType<T>`、`XXXConstructor`、`never`...
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ResolvePropType<BooleanConstructor> => boolean
|
|
61
|
+
* ResolvePropType<PropType<T>> => T
|
|
62
|
+
**/
|
|
63
|
+
type ResolvePropType<T> = IfNever<T, never, ExtractPropType<{
|
|
64
|
+
type: WritableArray<T>;
|
|
65
|
+
required: true;
|
|
66
|
+
}>>;
|
|
67
|
+
/**
|
|
68
|
+
* Merge Type, Value, Validator types
|
|
69
|
+
* 合并 Type、Value、Validator 的类型
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* EpPropMergeType<StringConstructor, '1', 1> => 1 | "1" // ignores StringConstructor
|
|
73
|
+
* EpPropMergeType<StringConstructor, never, number> => string | number
|
|
74
|
+
*/
|
|
75
|
+
type EpPropMergeType<Type, Value, Validator> = IfNever<UnknownToNever<Value>, ResolvePropType<Type>, never> | UnknownToNever<Value> | UnknownToNever<Validator>;
|
|
76
|
+
/**
|
|
77
|
+
* Handling default values for input (constraints)
|
|
78
|
+
*
|
|
79
|
+
* 处理输入参数的默认值(约束)
|
|
80
|
+
*/
|
|
81
|
+
type EpPropInputDefault<Required extends boolean, Default> = Required extends true ? never : Default extends Record<string, unknown> | Array<any> ? () => Default : (() => Default) | Default;
|
|
82
|
+
/**
|
|
83
|
+
* Native prop types, e.g: `BooleanConstructor`, `StringConstructor`, `null`, `undefined`, etc.
|
|
84
|
+
*
|
|
85
|
+
* 原生 prop `类型,BooleanConstructor`、`StringConstructor`、`null`、`undefined` 等
|
|
86
|
+
*/
|
|
87
|
+
type NativePropType = ((...args: any) => any) | {
|
|
88
|
+
new (...args: any): any;
|
|
89
|
+
} | undefined | null;
|
|
90
|
+
type IfNativePropType<T, Y, N> = [T] extends [NativePropType] ? Y : N;
|
|
91
|
+
/**
|
|
92
|
+
* input prop `buildProp` or `buildProps` (constraints)
|
|
93
|
+
*
|
|
94
|
+
* prop 输入参数(约束)
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* EpPropInput<StringConstructor, 'a', never, never, true>
|
|
98
|
+
* ⬇️
|
|
99
|
+
* {
|
|
100
|
+
type?: StringConstructor | undefined;
|
|
101
|
+
required?: true | undefined;
|
|
102
|
+
values?: readonly "a"[] | undefined;
|
|
103
|
+
validator?: ((val: any) => boolean) | ((val: any) => val is never) | undefined;
|
|
104
|
+
default?: undefined;
|
|
105
|
+
}
|
|
106
|
+
*/
|
|
107
|
+
type EpPropInput<Type, Value, Validator, Default extends EpPropMergeType<Type, Value, Validator>, Required extends boolean> = {
|
|
108
|
+
type?: Type;
|
|
109
|
+
required?: Required;
|
|
110
|
+
values?: readonly Value[];
|
|
111
|
+
validator?: ((val: any) => val is Validator) | ((val: any) => boolean);
|
|
112
|
+
default?: EpPropInputDefault<Required, Default>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* output prop `buildProp` or `buildProps`.
|
|
116
|
+
*
|
|
117
|
+
* prop 输出参数。
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* EpProp<'a', 'b', true>
|
|
121
|
+
* ⬇️
|
|
122
|
+
* {
|
|
123
|
+
readonly type: PropType<"a">;
|
|
124
|
+
readonly required: true;
|
|
125
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
126
|
+
readonly default: "b";
|
|
127
|
+
__epPropKey: true;
|
|
128
|
+
}
|
|
129
|
+
*/
|
|
130
|
+
type EpProp<Type, Default, Required> = {
|
|
131
|
+
readonly type: PropType<Type>;
|
|
132
|
+
readonly required: [Required] extends [true] ? true : false;
|
|
133
|
+
readonly validator: ((val: unknown) => boolean) | undefined;
|
|
134
|
+
[epPropKey]: true;
|
|
135
|
+
} & IfNever<Default, unknown, {
|
|
136
|
+
readonly default: Default;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Determine if it is `EpProp`
|
|
140
|
+
*/
|
|
141
|
+
type IfEpProp<T, Y, N> = T extends {
|
|
142
|
+
[epPropKey]: true;
|
|
143
|
+
} ? Y : N;
|
|
144
|
+
/**
|
|
145
|
+
* Converting input to output.
|
|
146
|
+
*
|
|
147
|
+
* 将输入转换为输出
|
|
148
|
+
*/
|
|
149
|
+
type EpPropConvert<Input> = Input extends EpPropInput<infer Type, infer Value, infer Validator, any, infer Required> ? EpPropFinalized<Type, Value, Validator, Input['default'], Required> : never;
|
|
150
|
+
/**
|
|
151
|
+
* Finalized conversion output
|
|
152
|
+
*
|
|
153
|
+
* 最终转换 EpProp
|
|
154
|
+
*/
|
|
155
|
+
type EpPropFinalized<Type, Value, Validator, Default, Required> = EpProp<EpPropMergeType<Type, Value, Validator>, UnknownToNever<Default>, Required>;
|
|
156
|
+
//#endregion
|
|
157
|
+
export { IfNever as _, EpPropInputDefault as a, Writable as b, IfEpProp as c, ResolvePropType as d, buildProp as f, isEpProp as g, epPropKey as h, EpPropInput as i, IfNativePropType as l, definePropType as m, EpPropConvert as n, EpPropMergeType as o, buildProps as p, EpPropFinalized as r, ExtractPropType as s, EpProp as t, NativePropType as u, IfUnknown as v, WritableArray as x, UnknownToNever as y };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppContext, Directive, EmitsOptions, Plugin, SetupContext } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/packages/utils/vue/typescript.d.ts
|
|
4
|
+
type SFCWithInstall<T> = T & Plugin;
|
|
5
|
+
type SFCInstallWithContext<T> = SFCWithInstall<T> & {
|
|
6
|
+
_context: AppContext | null;
|
|
7
|
+
};
|
|
8
|
+
type EmitFn<E extends EmitsOptions> = SetupContext<E>['emit'];
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/packages/utils/vue/install.d.ts
|
|
11
|
+
declare const withInstall: <T, E extends Record<string, any>>(main: T, extra?: E) => SFCWithInstall<T> & E;
|
|
12
|
+
declare const withInstallFunction: <T>(fn: T, name: string) => SFCInstallWithContext<T>;
|
|
13
|
+
declare const withInstallDirective: <T extends Directive>(directive: T, name: string) => SFCWithInstall<T>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SFCInstallWithContext as a, EmitFn as i, withInstallDirective as n, SFCWithInstall as o, withInstallFunction as r, withInstall as t };
|