@havue/components 1.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.
@@ -0,0 +1,8 @@
1
+ export declare function useOperateEvent(): {
2
+ colorAreaRef: import("vue").Ref<HTMLDivElement | undefined, HTMLDivElement | undefined>;
3
+ circlePickerCoordinate: {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ setCirclePickerCoordinate: (x: number, y: number, width: number, height: number) => void;
8
+ };
@@ -0,0 +1,4 @@
1
+ import type { SFCWithInstall } from '@havue/utils';
2
+ import ColorPicker from './ColorPicker.vue';
3
+ export declare const HvColorPicker: SFCWithInstall<typeof ColorPicker>;
4
+ export default HvColorPicker;
@@ -0,0 +1,47 @@
1
+ import type ColorConstruct from 'color';
2
+ export type RgbColorType = {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ };
7
+ export type HsvColorType = {
8
+ h: number;
9
+ s: number;
10
+ v: number;
11
+ };
12
+ export declare function hexToColor(hex: string): ColorConstruct;
13
+ /**
14
+ * 输入rgb,返回16进制颜色
15
+ * @param {ColorConstruct} color
16
+ * @returns {string}
17
+ */
18
+ export declare function colorToHex(color: ColorConstruct): string;
19
+ /**
20
+ * 根据颜色值,计算得到hsv深度100的颜色和当前深度值
21
+ * @param { ColorConstruct } color
22
+ * @returns {
23
+ * color: ColorConstruct
24
+ * value: number [0-100]
25
+ * }
26
+ *
27
+ */
28
+ export declare function getLightColorAndDepth(color: ColorConstruct): {
29
+ color: ColorConstruct;
30
+ value: number;
31
+ };
32
+ /**
33
+ * 根据高亮区域的颜色和缩放比例,计算得到原始rgb颜色值
34
+ * @param { ColorConstruct } color
35
+ * @param { number } value 深度 [0-100]
36
+ * @returns ColorConstruct
37
+ *
38
+ */
39
+ export declare function getOriginColorByLightAndDepth(color: ColorConstruct, value: number): ColorConstruct;
40
+ /**
41
+ * 根据canvas高亮区域的颜色和深度值,计算得到原始hex颜色值
42
+ * @param { ColorConstruct } color
43
+ * @param { number } value 深度 [0-100]
44
+ * @returns string
45
+ *
46
+ */
47
+ export declare function getOriginHexByLightAndDepth(color: ColorConstruct, value: number): string;
@@ -0,0 +1 @@
1
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, time?: number): (this: any, ...args: Parameters<T>) => void;
@@ -0,0 +1,47 @@
1
+ import type { DragAndDropDragType } from './manager';
2
+ declare const ImmediateEnumType: {
3
+ readonly LEFT: "left";
4
+ readonly RIGHT: "right";
5
+ readonly TOP: "top";
6
+ readonly BOTTOM: "bottom";
7
+ readonly ALL: "all";
8
+ };
9
+ type ImmediateType = (typeof ImmediateEnumType)[keyof typeof ImmediateEnumType];
10
+ type __VLS_Props = {
11
+ type: DragAndDropDragType;
12
+ immediate?: ImmediateType | Array<ImmediateType> | undefined;
13
+ disabled?: boolean;
14
+ data?: any;
15
+ };
16
+ declare const dragItemRef: import("vue").Ref<HTMLElement | undefined, HTMLElement | undefined>;
17
+ /** 是否开始拖动 */
18
+ declare const isDragThis: import("vue").Ref<boolean, boolean>;
19
+ declare const cloneNodeStyle: import("vue").ComputedRef<{
20
+ transform: string;
21
+ }>;
22
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
23
+ declare var __VLS_1: {}, __VLS_3: {}, __VLS_5: {};
24
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
25
+ default?: (props: typeof __VLS_1) => any;
26
+ } & {
27
+ 'drag-item'?: (props: typeof __VLS_3) => any;
28
+ } & {
29
+ default?: (props: typeof __VLS_5) => any;
30
+ }>;
31
+ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
32
+ dragItemRef: typeof dragItemRef;
33
+ isDragThis: typeof isDragThis;
34
+ cloneNodeStyle: typeof cloneNodeStyle;
35
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
36
+ disabled: boolean;
37
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
39
+ disabled: boolean;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
41
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
42
+ export default _default;
43
+ type __VLS_WithSlots<T, S> = T & {
44
+ new (): {
45
+ $slots: S;
46
+ };
47
+ };
@@ -0,0 +1,41 @@
1
+ import type { DragAndDropDragType, DragAndDropPoint } from './manager';
2
+ type __VLS_Props = {
3
+ acceptDragType: DragAndDropDragType | Array<DragAndDropDragType>;
4
+ };
5
+ declare const dropAreaRef: import("vue").Ref<HTMLElement | undefined, HTMLElement | undefined>;
6
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
7
+ declare var __VLS_1: {};
8
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
9
+ default?: (props: typeof __VLS_1) => any;
10
+ }>;
11
+ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
12
+ dropAreaRef: typeof dropAreaRef;
13
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
14
+ drop: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
15
+ move: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
16
+ enter: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
17
+ leave: (type: DragAndDropDragType, data: any) => any;
18
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
+ onDrop?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
20
+ onMove?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
21
+ onEnter?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
22
+ onLeave?: ((type: DragAndDropDragType, data: any) => any) | undefined;
23
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
25
+ drop: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
26
+ move: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
27
+ enter: (type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any;
28
+ leave: (type: DragAndDropDragType, data: any) => any;
29
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
30
+ onDrop?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
31
+ onMove?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
32
+ onEnter?: ((type: DragAndDropDragType, point: DragAndDropPoint, data: any) => any) | undefined;
33
+ onLeave?: ((type: DragAndDropDragType, data: any) => any) | undefined;
34
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
36
+ export default _default;
37
+ type __VLS_WithSlots<T, S> = T & {
38
+ new (): {
39
+ $slots: S;
40
+ };
41
+ };
@@ -0,0 +1,6 @@
1
+ import type { SFCWithInstall } from '@havue/utils';
2
+ import Draggable from './Draggable.vue';
3
+ import Droppable from './Droppable.vue';
4
+ export declare const HvDraggable: SFCWithInstall<typeof Draggable>;
5
+ export declare const HvDroppable: SFCWithInstall<typeof Droppable>;
6
+ export type { DragAndDropPoint, DragAndDropDragType, DnDManager } from './manager';
@@ -0,0 +1,81 @@
1
+ import { EventBus } from '@havue/shared';
2
+ export type DragAndDropPoint = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export type DragAndDropDragType = string | number | symbol;
7
+ type Events = {
8
+ down: (p: DragAndDropPoint) => void;
9
+ 'first-move': (p: DragAndDropPoint, e: MouseEvent | TouchEvent) => void;
10
+ start: (p: DragAndDropPoint) => void;
11
+ move: (params: {
12
+ type: DragAndDropDragType;
13
+ data: any;
14
+ point: DragAndDropPoint;
15
+ }) => void;
16
+ end: (params: {
17
+ type: DragAndDropDragType;
18
+ data: any;
19
+ point: DragAndDropPoint;
20
+ }) => void;
21
+ };
22
+ export declare class DnDManager extends EventBus<Events> {
23
+ /** 是否开始拖动 */
24
+ isDragStart: boolean;
25
+ /** 拖动元素类型 */
26
+ dragType: DragAndDropDragType | undefined;
27
+ /** Draggable传递的数据,
28
+ * 供Droppable使用
29
+ */
30
+ dragData: any;
31
+ private isSendFirstMovePos;
32
+ /** 移动端长按一定时间才触发 onStart */
33
+ private touchStartPressTime;
34
+ /** touchstart事件触发的时的时间 */
35
+ private touchStartTime;
36
+ /** touchstart时间触发的位置 */
37
+ private touchStartPosition;
38
+ /** onMove最后位置 */
39
+ private lastMovePoint;
40
+ private emitTouchStartTimer;
41
+ private destroy;
42
+ constructor();
43
+ updateDargInfo(type: Exclude<DragAndDropDragType, undefined>, data: any): void;
44
+ /**
45
+ * 通知 Draggable 开始点击
46
+ * @param point
47
+ */
48
+ private onDown;
49
+ /**
50
+ * 通知 Draggable 拖拽开始
51
+ * @param point
52
+ */
53
+ private onFirstMove;
54
+ /**
55
+ * 通知 Draggable 拖拽开始
56
+ * @param point
57
+ */
58
+ private onStart;
59
+ /**
60
+ * 通知 Draggable 移动
61
+ * @param point
62
+ * @returns
63
+ */
64
+ private onMove;
65
+ /**
66
+ * 结束拖拽
67
+ * @returns
68
+ */
69
+ private onEnd;
70
+ private onMouseDown;
71
+ private onMouseMove;
72
+ private onMouseUp;
73
+ private onTouchStart;
74
+ private onTouchMove;
75
+ private onTouchEnd;
76
+ private bindEventListener;
77
+ private removeEventListener;
78
+ destroyed(): void;
79
+ }
80
+ export declare const DnDManagerInstance: DnDManager;
81
+ export {};
@@ -0,0 +1,29 @@
1
+ export type { DragAndScaleChangeResultType } from './hooks/useDragAndScale';
2
+ import type { DragAndScaleChangeResultType, DragAndScaleOptions } from './hooks/useDragAndScale';
3
+ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
4
+ container: DragAndScaleOptions["container"];
5
+ containerRealSize?: DragAndScaleOptions["containerRealSize"];
6
+ keepRatio?: DragAndScaleOptions["keepRatio"];
7
+ limit?: DragAndScaleOptions["limit"];
8
+ disabled?: DragAndScaleOptions["disabled"];
9
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
10
+ change: (params: DragAndScaleChangeResultType) => any;
11
+ finish: () => any;
12
+ }, string, import("vue").PublicProps, Readonly<{
13
+ container: DragAndScaleOptions["container"];
14
+ containerRealSize?: DragAndScaleOptions["containerRealSize"];
15
+ keepRatio?: DragAndScaleOptions["keepRatio"];
16
+ limit?: DragAndScaleOptions["limit"];
17
+ disabled?: DragAndScaleOptions["disabled"];
18
+ }> & Readonly<{
19
+ onChange?: ((params: DragAndScaleChangeResultType) => any) | undefined;
20
+ onFinish?: (() => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
+ default?: ((props: {}) => any) | undefined;
23
+ }>;
24
+ export default _default;
25
+ type __VLS_WithSlots<T, S> = T & {
26
+ new (): {
27
+ $slots: S;
28
+ };
29
+ };
@@ -0,0 +1,45 @@
1
+ import type { MaybeRef } from 'vue';
2
+ export type DragAndScaleOptions = {
3
+ container: HTMLElement | undefined | null;
4
+ containerRealSize?: {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ scaleAreaWidth?: number;
9
+ keepRatio?: boolean | Partial<KeepRatioType>;
10
+ limit?: {
11
+ inContainer?: boolean;
12
+ minWidth?: number;
13
+ minHeight?: number;
14
+ maxWidth?: number;
15
+ maxHeight?: number;
16
+ };
17
+ disabled?: boolean;
18
+ onChange?: (p: DragAndScaleChangeResultType) => void;
19
+ onFinish?: () => void;
20
+ };
21
+ type KeepRatioType = {
22
+ enable: boolean;
23
+ scaleCase: 'min' | 'max';
24
+ };
25
+ export type DragAndScalePoint = {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ type TargetAreaType = {
30
+ elX: number;
31
+ elY: number;
32
+ elWidth: number;
33
+ elHeight: number;
34
+ };
35
+ export type DragAndScaleChangeResultType = TargetAreaType & {
36
+ type: 'move' | 'scale';
37
+ deltaX: number;
38
+ deltaY: number;
39
+ realX: number;
40
+ realY: number;
41
+ realWidth: number;
42
+ realHeight: number;
43
+ };
44
+ export declare function useDragAndScale(target: MaybeRef<HTMLElement>, operateTarget: MaybeRef<HTMLElement>, options: MaybeRef<DragAndScaleOptions>): void;
45
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { SFCWithInstall } from '@havue/utils';
2
+ import DragAndScale from './DragAndScale.vue';
3
+ export declare const HvDragAndScale: SFCWithInstall<typeof DragAndScale>;
4
+ export default HvDragAndScale;
5
+ export type { DragAndScaleOptions, DragAndScalePoint, DragAndScaleChangeResultType, useDragAndScale } from './hooks/useDragAndScale';
@@ -0,0 +1,3 @@
1
+ export * from '@havue/color-picker';
2
+ export * from '@havue/drag-and-drop';
3
+ export * from '@havue/drag-and-scale';
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@havue/components",
3
+ "version": "1.0.0",
4
+ "description": "Some components for Vue3",
5
+ "keywords": [
6
+ "havue",
7
+ "components",
8
+ "vue3"
9
+ ],
10
+ "license": "MIT",
11
+ "homepage": "https://happypedestrian.github.io/havue/guide/",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/HappyPedestrian/havue.git"
15
+ },
16
+ "dependencies": {
17
+ "@havue/shared": "^1.0.0",
18
+ "@havue/drag-and-drop": "^1.0.0",
19
+ "@havue/color-picker": "^1.0.0",
20
+ "@havue/drag-and-scale": "^1.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "vue": "^3.3.0"
24
+ },
25
+ "peerDependencies": {
26
+ "vue": "^3.3.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org/"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "main": "./dist/components.umd.js",
36
+ "module": "./dist/components.mjs",
37
+ "types": "./dist/types/src/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "require": "./dist/components.umd.js",
41
+ "import": "./dist/components.mjs",
42
+ "types": "./dist/types/src/index.d.ts"
43
+ }
44
+ },
45
+ "scripts": {
46
+ "build:package": "vite build --mode package",
47
+ "build:full": "vite build --mode full",
48
+ "build:full-min": "vite build --mode full-min",
49
+ "build": "pnpm run build:package && pnpm run build:full && pnpm run build:full-min"
50
+ }
51
+ }