@toolmain/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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +230 -0
- package/dist/index.js +880 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present - toolmain
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { CSSProperties } from '@toolmain/shared';
|
|
4
|
+
import { DefineComponent } from 'vue';
|
|
5
|
+
import { FixedArray } from '@toolmain/shared';
|
|
6
|
+
import type { MaybeRef } from 'vue';
|
|
7
|
+
import { PublicProps } from 'vue';
|
|
8
|
+
|
|
9
|
+
declare const __VLS_component: DefineComponent<__VLS_Props, {
|
|
10
|
+
update: () => void;
|
|
11
|
+
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
|
|
13
|
+
declare const __VLS_component_2: DefineComponent<ScaleProps, ScaleInstance, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
14
|
+
moving: (pos: MoveParams) => any;
|
|
15
|
+
scaling: (scaleEl: HTMLElement) => any;
|
|
16
|
+
beforeMove: (pos: MoveParams) => any;
|
|
17
|
+
afterMove: (pos: MoveParams) => any;
|
|
18
|
+
afterScale: (scaleEl: HTMLElement) => any;
|
|
19
|
+
maskClick: () => any;
|
|
20
|
+
"update:modelValue": (data: ScaleConfig) => any;
|
|
21
|
+
}, string, PublicProps, Readonly<ScaleProps> & Readonly<{
|
|
22
|
+
onMoving?: ((pos: MoveParams) => any) | undefined;
|
|
23
|
+
onScaling?: ((scaleEl: HTMLElement) => any) | undefined;
|
|
24
|
+
onBeforeMove?: ((pos: MoveParams) => any) | undefined;
|
|
25
|
+
onAfterMove?: ((pos: MoveParams) => any) | undefined;
|
|
26
|
+
onAfterScale?: ((scaleEl: HTMLElement) => any) | undefined;
|
|
27
|
+
onMaskClick?: (() => any) | undefined;
|
|
28
|
+
"onUpdate:modelValue"?: ((data: ScaleConfig) => any) | undefined;
|
|
29
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
30
|
+
|
|
31
|
+
declare type __VLS_Props = {
|
|
32
|
+
/**
|
|
33
|
+
* 选择top时,如果元素滚动到[底部]消失或即将消失,会回到原位置
|
|
34
|
+
*
|
|
35
|
+
* 选择bottom时则是滚动到[顶部]时触发
|
|
36
|
+
*/
|
|
37
|
+
position?: "top" | "bottom";
|
|
38
|
+
target?: string;
|
|
39
|
+
offset?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
declare type __VLS_Slots = {} & {
|
|
43
|
+
default?: (props: typeof __VLS_1) => any;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare type __VLS_Slots_2 = {} & {
|
|
47
|
+
header?: (props: typeof __VLS_1) => any;
|
|
48
|
+
} & {
|
|
49
|
+
default?: (props: typeof __VLS_7) => any;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
declare type __VLS_WithSlots<T, S> = T & {
|
|
53
|
+
new (): {
|
|
54
|
+
$slots: S;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
declare type __VLS_WithSlots_2<T, S> = T & {
|
|
59
|
+
new (): {
|
|
60
|
+
$slots: S;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export declare const Affix: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
65
|
+
|
|
66
|
+
declare type AnimateDir = "left" | "top" | "bottom" | "right" | "self" | "center" | {
|
|
67
|
+
x?: number;
|
|
68
|
+
y?: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
declare type Dir = "horizontal" | "vertical" | "any";
|
|
72
|
+
|
|
73
|
+
declare interface DragAttr {
|
|
74
|
+
/**
|
|
75
|
+
* 元素x轴坐标
|
|
76
|
+
*/
|
|
77
|
+
x: number;
|
|
78
|
+
/**
|
|
79
|
+
* 元素y轴坐标
|
|
80
|
+
*/
|
|
81
|
+
y: number;
|
|
82
|
+
/**
|
|
83
|
+
* 指针x坐标
|
|
84
|
+
*/
|
|
85
|
+
clientX: number;
|
|
86
|
+
/**
|
|
87
|
+
* 指针y坐标
|
|
88
|
+
*/
|
|
89
|
+
clientY: number;
|
|
90
|
+
width: number | InitType;
|
|
91
|
+
height: number | InitType;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare type InitType = "auto" | "inherit" | "initial" | "unset";
|
|
95
|
+
|
|
96
|
+
declare interface MoveHook {
|
|
97
|
+
x?: (oldVal: number, newVal: number, width: number, height: number) => number;
|
|
98
|
+
y?: (oldVal: number, newVal: number, width: number, height: number) => number;
|
|
99
|
+
scale?: (oldVal: FixedArray<number, 2>, newVal: FixedArray<number, 2>) => [FixedArray<number, 2>, FixedArray<number, 2>];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare interface MoveOptions {
|
|
103
|
+
/**
|
|
104
|
+
* 移动方向
|
|
105
|
+
*/
|
|
106
|
+
direction?: Dir;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare type MoveParams = DragAttr & {
|
|
110
|
+
translateX: number;
|
|
111
|
+
translateY: number;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
declare interface ScaleConfig {
|
|
115
|
+
/**
|
|
116
|
+
* 组件可改变尺寸
|
|
117
|
+
*/
|
|
118
|
+
scalable?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 组件可移动
|
|
121
|
+
*/
|
|
122
|
+
movable?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 变成正常元素
|
|
125
|
+
*/
|
|
126
|
+
normal?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 拖动后自动靠边
|
|
129
|
+
*/
|
|
130
|
+
autoStick?: boolean | AnimateDir;
|
|
131
|
+
/**
|
|
132
|
+
* 是否显示
|
|
133
|
+
*/
|
|
134
|
+
visible?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 初始移动位置 `translateX`
|
|
137
|
+
*/
|
|
138
|
+
x?: number;
|
|
139
|
+
/**
|
|
140
|
+
* 初始移动位置 `translateY`
|
|
141
|
+
*/
|
|
142
|
+
y?: number;
|
|
143
|
+
/**
|
|
144
|
+
* 是否拥有头部
|
|
145
|
+
*/
|
|
146
|
+
header?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* 当组件`position`不为`fixed`时
|
|
149
|
+
* 是否相对于window定位,否则相对于父元素定位
|
|
150
|
+
*
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
153
|
+
attachWindow?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* 移动功能的配置项
|
|
156
|
+
*/
|
|
157
|
+
moveConfig?: MoveOptions;
|
|
158
|
+
/**
|
|
159
|
+
* 外壳样式
|
|
160
|
+
*/
|
|
161
|
+
containerStyle?: CSSProperties;
|
|
162
|
+
/**
|
|
163
|
+
* 内容样式,初始宽高应该在这里设置
|
|
164
|
+
*/
|
|
165
|
+
contentStyle?: CSSProperties;
|
|
166
|
+
/**
|
|
167
|
+
* 头部样式
|
|
168
|
+
*/
|
|
169
|
+
headerStyle?: CSSProperties;
|
|
170
|
+
/**
|
|
171
|
+
* 是否显示遮罩层
|
|
172
|
+
*/
|
|
173
|
+
mask?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* 遮罩层样式
|
|
176
|
+
*/
|
|
177
|
+
maskStyle?: CSSProperties;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare interface ScaleInstance {
|
|
181
|
+
/**
|
|
182
|
+
* 智能移动到屏幕边界
|
|
183
|
+
* @param animate - 是否有动画效果 default: true
|
|
184
|
+
*/
|
|
185
|
+
autoStick: (animate: boolean) => Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* 自动隐藏
|
|
188
|
+
* @param animate - 是否有动画效果 default: true
|
|
189
|
+
*/
|
|
190
|
+
autoHide: (animate: boolean) => Promise<void>;
|
|
191
|
+
/**
|
|
192
|
+
* 移动到屏幕边界
|
|
193
|
+
* @param animate - 是否有动画效果 default: true
|
|
194
|
+
*/
|
|
195
|
+
stickTo: (dir: AnimateDir, animate: boolean) => Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* 移动到屏幕 `dir`位置并隐藏
|
|
198
|
+
* @param animate - 是否有动画效果 default: true
|
|
199
|
+
*/
|
|
200
|
+
hideTo: (dir: AnimateDir, animate: boolean) => Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* 显示组件
|
|
203
|
+
*/
|
|
204
|
+
show: (animate: boolean, dir?: AnimateDir) => Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* 当组件`position:fixed`或者`attachWindow:true`时坐标相对于屏幕左上角;否则相对于父元素
|
|
207
|
+
*/
|
|
208
|
+
moveTo: (animate: boolean, dir: AnimateDir, hooks?: MoveHook) => Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* 获取当前状态
|
|
211
|
+
*/
|
|
212
|
+
getStatus: () => Status | undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export declare const ScalePanel: __VLS_WithSlots_2<typeof __VLS_component_2, __VLS_Slots_2>;
|
|
216
|
+
|
|
217
|
+
declare interface ScaleProps {
|
|
218
|
+
modelValue: ScaleConfig;
|
|
219
|
+
/**
|
|
220
|
+
* 按下目标元素并拖动组件,默认按下头部拖动。
|
|
221
|
+
*/
|
|
222
|
+
dragTarget?: MaybeRef<HTMLElement | null | undefined>;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
declare enum Status {
|
|
226
|
+
NORMAL = "NORMAL",
|
|
227
|
+
HIDDEN = "HIDDEN"
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,880 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode('*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}[top~="0"]{top:0}.hidden{display:none}.flex{display:flex}.flex-shrink{flex-shrink:1}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.resize,[resize=""]{resize:both}.px,[px=""]{padding-left:1rem;padding-right:1rem}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.comp-affix .comp-affix-inner[data-v-4c40ccd8]{transition:box-shadow .3s;border-radius:1rem}.comp-affix .comp-affix-inner.fix[data-v-4c40ccd8]{position:fixed;box-shadow:var(--el-box-shadow);background-color:var(--el-card-bg-color)}.p-t[data-v-cb7f9cc6],.p-r[data-v-cb7f9cc6],.p-b[data-v-cb7f9cc6],.p-l[data-v-cb7f9cc6],.p-lt[data-v-cb7f9cc6],.p-rt[data-v-cb7f9cc6],.p-lb[data-v-cb7f9cc6],.p-rb[data-v-cb7f9cc6]{z-index:var(--61c40759);position:absolute}.p-b[data-v-cb7f9cc6],.p-t[data-v-cb7f9cc6],.p-r[data-v-cb7f9cc6],.p-l[data-v-cb7f9cc6]{background-color:transparent;border-radius:4px}.p-b[data-v-cb7f9cc6],.p-t[data-v-cb7f9cc6]{height:4px;left:4px;right:4px}.p-r[data-v-cb7f9cc6],.p-l[data-v-cb7f9cc6]{width:4px;top:4px;bottom:4px}.p-lt[data-v-cb7f9cc6],.p-rt[data-v-cb7f9cc6],.p-lb[data-v-cb7f9cc6],.p-rb[data-v-cb7f9cc6]{width:0;height:0}.p-b[data-v-cb7f9cc6]{bottom:0;cursor:ns-resize}.p-t[data-v-cb7f9cc6]{top:0;cursor:ns-resize}.p-r[data-v-cb7f9cc6]{right:0;cursor:ew-resize}.p-l[data-v-cb7f9cc6]{left:0;cursor:ew-resize}.p-lt[data-v-cb7f9cc6]{left:0;top:0;cursor:nwse-resize;border-top:.4rem solid transparent;border-left:.4rem solid transparent;border-right:.4rem solid transparent;border-bottom:.4rem solid transparent}.p-rt[data-v-cb7f9cc6]{right:0;top:0;cursor:nesw-resize;border-top:.4rem solid transparent;border-left:.4rem solid transparent;border-right:.4rem solid transparent;border-bottom:.4rem solid transparent}.p-lb[data-v-cb7f9cc6]{left:0;bottom:0;cursor:nesw-resize;border-top:.4rem solid transparent;border-left:.4rem solid transparent;border-right:.4rem solid transparent;border-bottom:.4rem solid transparent}.p-rb[data-v-cb7f9cc6]{right:0;bottom:0;cursor:nwse-resize;border-top:.4rem solid transparent;border-left:.4rem solid transparent;border-right:.4rem solid transparent;border-bottom:.4rem solid transparent}.dragContainer[data-v-d123b73c]{display:flex;flex-direction:column;transform-origin:0 0}.dragContainer>.dragHeader[data-v-d123b73c]{flex-shrink:0;display:flex}.dragContainer>.scaleContent[data-v-d123b73c]{flex:1;overflow:hidden;position:relative;display:flex}.dragMask[data-v-d123b73c]{position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:100}')),document.head.appendChild(r)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
|
|
2
|
+
import { defineComponent as be, useTemplateRef as te, shallowRef as ee, computed as $, reactive as Ae, onMounted as De, onBeforeUnmount as Me, createElementBlock as Q, openBlock as j, normalizeStyle as J, normalizeClass as pe, createElementVNode as Oe, renderSlot as we, useCssVars as ze, createCommentVNode as re, Fragment as Be, renderList as $e, withDirectives as Ve, vShow as We, unref as Pe, ref as Te, toValue as ye, watch as q, toRef as oe, createBlock as Ce, Teleport as Ue } from "vue";
|
|
3
|
+
import { px as X, z as je, getStyleValue as Se, isBoolean as ke, isNumber as G, toNumber as w, merge as Ge } from "@toolmain/shared";
|
|
4
|
+
import { useElementBounding as le, useIntersectionObserver as _e, useThrottleFn as Ke, useDebounceFn as qe } from "@vueuse/core";
|
|
5
|
+
import { useEvent as ue, useFlip as Je } from "@toolmain/libs";
|
|
6
|
+
const ae = 2, Qe = /* @__PURE__ */ be({
|
|
7
|
+
__name: "index",
|
|
8
|
+
props: {
|
|
9
|
+
position: { default: "top" },
|
|
10
|
+
target: { default: "" },
|
|
11
|
+
offset: { default: 0 }
|
|
12
|
+
},
|
|
13
|
+
setup(e, { expose: l }) {
|
|
14
|
+
const c = te("affix"), s = te("affixInner"), h = ee(), d = ee(), { width: i, height: R } = le(h), T = $(() => !!d.value), y = ee({}), S = ee({}), a = Ae({
|
|
15
|
+
disableTeleport: !0,
|
|
16
|
+
target: {
|
|
17
|
+
isIntersecting: !1,
|
|
18
|
+
intersectionRatio: 0,
|
|
19
|
+
directions: []
|
|
20
|
+
},
|
|
21
|
+
affix: {
|
|
22
|
+
isIntersecting: !1,
|
|
23
|
+
intersectionRatio: 0,
|
|
24
|
+
needFloat: !1,
|
|
25
|
+
directions: []
|
|
26
|
+
}
|
|
27
|
+
}), {
|
|
28
|
+
x,
|
|
29
|
+
y: n,
|
|
30
|
+
// width: affixWidth,
|
|
31
|
+
height: L,
|
|
32
|
+
update: A
|
|
33
|
+
} = le(c), m = () => {
|
|
34
|
+
if (T.value) {
|
|
35
|
+
if (a.target.isIntersecting && (!a.affix.isIntersecting || a.affix.intersectionRatio < 0.5))
|
|
36
|
+
return !0;
|
|
37
|
+
} else if (!a.affix.isIntersecting || a.affix.intersectionRatio < 0.5)
|
|
38
|
+
return !0;
|
|
39
|
+
return !1;
|
|
40
|
+
}, g = () => {
|
|
41
|
+
if (A(), a.affix.needFloat = !1, a.affix.directions.includes(
|
|
42
|
+
"left"
|
|
43
|
+
/* Left */
|
|
44
|
+
) || a.affix.directions.includes(
|
|
45
|
+
"right"
|
|
46
|
+
/* Right */
|
|
47
|
+
) || a.target.directions.includes(
|
|
48
|
+
"left"
|
|
49
|
+
/* Left */
|
|
50
|
+
) || a.target.directions.includes(
|
|
51
|
+
"right"
|
|
52
|
+
/* Right */
|
|
53
|
+
))
|
|
54
|
+
a.affix.needFloat = !1;
|
|
55
|
+
else if (m()) {
|
|
56
|
+
const C = n.value + L.value / 2 <= window.innerHeight / 2;
|
|
57
|
+
a.affix.needFloat = e.position === "top" ? C : !C;
|
|
58
|
+
}
|
|
59
|
+
a.affix.needFloat ? (y.value = {
|
|
60
|
+
zIndex: 100,
|
|
61
|
+
left: X(x.value),
|
|
62
|
+
[e.position === "bottom" ? "bottom" : "top"]: X(e.offset)
|
|
63
|
+
}, S.value = {
|
|
64
|
+
minWidth: X(i.value),
|
|
65
|
+
height: X(R.value)
|
|
66
|
+
}) : (y.value = {}, S.value = {});
|
|
67
|
+
};
|
|
68
|
+
function P(C, F) {
|
|
69
|
+
const { boundingClientRect: z, intersectionRect: V, rootBounds: Z } = C;
|
|
70
|
+
Z && C.isIntersecting && (F.length = 0, V.y - z.y > ae && F.push(
|
|
71
|
+
"top"
|
|
72
|
+
/* Top */
|
|
73
|
+
), z.y - V.y > ae && F.push(
|
|
74
|
+
"bottom"
|
|
75
|
+
/* Bottom */
|
|
76
|
+
), V.x - z.x > ae && F.push(
|
|
77
|
+
"left"
|
|
78
|
+
/* Left */
|
|
79
|
+
), z.x + z.width - (V.x + V.width) > ae && F.push(
|
|
80
|
+
"right"
|
|
81
|
+
/* Right */
|
|
82
|
+
));
|
|
83
|
+
}
|
|
84
|
+
const N = ([C]) => {
|
|
85
|
+
a.affix.isIntersecting = C.isIntersecting, P(C, a.affix.directions), a.affix.intersectionRatio = C.intersectionRatio, g();
|
|
86
|
+
}, H = ([C]) => {
|
|
87
|
+
a.target.isIntersecting = C.isIntersecting, P(C, a.target.directions), a.target.intersectionRatio = C.intersectionRatio, g();
|
|
88
|
+
}, o = _e(c, N, {
|
|
89
|
+
root: window.document.documentElement,
|
|
90
|
+
threshold: [0, 0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99, 1]
|
|
91
|
+
}), u = _e(d, H, {
|
|
92
|
+
root: window.document.documentElement,
|
|
93
|
+
threshold: [0, 0.01, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99, 1]
|
|
94
|
+
});
|
|
95
|
+
function I() {
|
|
96
|
+
h.value = s.value?.firstElementChild, e.target && (d.value = document.querySelector(e.target)), A();
|
|
97
|
+
}
|
|
98
|
+
const D = Ke(g, 250, !0);
|
|
99
|
+
return De(() => {
|
|
100
|
+
I(), window.addEventListener("resize", D);
|
|
101
|
+
}), Me(() => {
|
|
102
|
+
window.removeEventListener("resize", D), o.stop(), u.stop();
|
|
103
|
+
}), l({
|
|
104
|
+
update: () => {
|
|
105
|
+
m() && g();
|
|
106
|
+
}
|
|
107
|
+
}), (C, F) => (j(), Q("div", {
|
|
108
|
+
class: pe(["comp-affix", { fix: a.affix.needFloat }]),
|
|
109
|
+
style: J(S.value),
|
|
110
|
+
ref: "affix"
|
|
111
|
+
}, [
|
|
112
|
+
Oe("div", {
|
|
113
|
+
ref_key: "affixInner",
|
|
114
|
+
ref: s,
|
|
115
|
+
style: J([y.value, S.value]),
|
|
116
|
+
class: pe(["comp-affix-inner", { fix: a.affix.needFloat }])
|
|
117
|
+
}, [
|
|
118
|
+
we(C.$slots, "default", {}, void 0, !0)
|
|
119
|
+
], 6)
|
|
120
|
+
], 6));
|
|
121
|
+
}
|
|
122
|
+
}), Ee = (e, l) => {
|
|
123
|
+
const c = e.__vccOpts || e;
|
|
124
|
+
for (const [s, h] of l)
|
|
125
|
+
c[s] = h;
|
|
126
|
+
return c;
|
|
127
|
+
}, vt = /* @__PURE__ */ Ee(Qe, [["__scopeId", "data-v-4c40ccd8"]]);
|
|
128
|
+
function Re() {
|
|
129
|
+
return {
|
|
130
|
+
x: 0,
|
|
131
|
+
y: 0,
|
|
132
|
+
clientX: 0,
|
|
133
|
+
clientY: 0,
|
|
134
|
+
width: 0,
|
|
135
|
+
height: 0
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function Le() {
|
|
139
|
+
return {
|
|
140
|
+
x: 0,
|
|
141
|
+
y: 0,
|
|
142
|
+
width: 0,
|
|
143
|
+
height: 0,
|
|
144
|
+
left: 0,
|
|
145
|
+
top: 0,
|
|
146
|
+
right: 0,
|
|
147
|
+
bottom: 0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const Ze = () => {
|
|
151
|
+
let e, l = Le(), c = Re(), s = !1, h = !1;
|
|
152
|
+
const d = ue(), i = {
|
|
153
|
+
emit: (n, ...L) => {
|
|
154
|
+
s || d.emit(n, ...L);
|
|
155
|
+
},
|
|
156
|
+
setTargetAttr: (n) => {
|
|
157
|
+
R(), T({
|
|
158
|
+
x: l.x,
|
|
159
|
+
y: l.y,
|
|
160
|
+
clientX: n.clientX,
|
|
161
|
+
clientY: n.clientY,
|
|
162
|
+
width: l.width,
|
|
163
|
+
height: l.height
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
onSelectStart: (n) => h ? (n.preventDefault(), !1) : !0,
|
|
167
|
+
onDomPointerUp: (n) => {
|
|
168
|
+
if (!s) {
|
|
169
|
+
if (!e) {
|
|
170
|
+
h = !1;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
h && i.emit("aftermove", { ...c }), h = !1;
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
onDomPointerMove: (n) => {
|
|
177
|
+
s || h && (i.setTargetAttr(n), i.emit("moving", { ...c }));
|
|
178
|
+
},
|
|
179
|
+
onElePointerDown: (n) => {
|
|
180
|
+
s || (h = !0, i.setTargetAttr(n), i.emit("beforemove", { ...c }));
|
|
181
|
+
},
|
|
182
|
+
clearEvent: () => {
|
|
183
|
+
document.removeEventListener("selectstart", i.onSelectStart), e?.removeEventListener("pointerdown", i.onElePointerDown), document.removeEventListener("pointerup", i.onDomPointerUp), document.removeEventListener("pointermove", i.onDomPointerMove);
|
|
184
|
+
},
|
|
185
|
+
listenEvent: () => {
|
|
186
|
+
e && (document.addEventListener("selectstart", i.onSelectStart), e.addEventListener("pointerdown", i.onElePointerDown), document.addEventListener("pointerup", i.onDomPointerUp), document.addEventListener("pointermove", i.onDomPointerMove));
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
function R() {
|
|
190
|
+
l = e?.getBoundingClientRect() ?? Le();
|
|
191
|
+
}
|
|
192
|
+
function T(n) {
|
|
193
|
+
c = { ...n };
|
|
194
|
+
}
|
|
195
|
+
function y(n) {
|
|
196
|
+
i.clearEvent(), e = n, d.removeAllListeners(), T(Re()), R(), i.listenEvent();
|
|
197
|
+
}
|
|
198
|
+
function S(n, L) {
|
|
199
|
+
d.on(n, L);
|
|
200
|
+
}
|
|
201
|
+
function a() {
|
|
202
|
+
s = !0;
|
|
203
|
+
}
|
|
204
|
+
function x() {
|
|
205
|
+
s = !1;
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
ele: e,
|
|
209
|
+
rect: l,
|
|
210
|
+
attr: c,
|
|
211
|
+
updateRect: R,
|
|
212
|
+
setAttr: T,
|
|
213
|
+
setTarget: y,
|
|
214
|
+
on: S,
|
|
215
|
+
disable: a,
|
|
216
|
+
enable: x
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
function et() {
|
|
220
|
+
const e = ue();
|
|
221
|
+
let l = !1;
|
|
222
|
+
const c = {
|
|
223
|
+
direction: "any"
|
|
224
|
+
}, s = Ze(), h = (m) => {
|
|
225
|
+
c.direction === "horizontal" ? (m.clientY = 0, m.y = 0) : c.direction === "vertical" && (m.clientX = 0, m.x = 0);
|
|
226
|
+
};
|
|
227
|
+
function d(m) {
|
|
228
|
+
l = !1, s.setTarget(m), s.on("beforemove", (g) => {
|
|
229
|
+
h(g), l = !1, R("beforemove", g);
|
|
230
|
+
}), s.on("moving", (g) => {
|
|
231
|
+
h(g), l = !0, R("moving", g);
|
|
232
|
+
}), s.on("aftermove", (g) => {
|
|
233
|
+
h(g), l = !1, R("aftermove", g);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function i() {
|
|
237
|
+
return s.ele;
|
|
238
|
+
}
|
|
239
|
+
function R(m, g) {
|
|
240
|
+
e.emit(m, g);
|
|
241
|
+
}
|
|
242
|
+
function T(m) {
|
|
243
|
+
c.direction = m;
|
|
244
|
+
}
|
|
245
|
+
function y(m, g) {
|
|
246
|
+
e.on(m, g);
|
|
247
|
+
}
|
|
248
|
+
function S(m, g) {
|
|
249
|
+
e.once(m, g);
|
|
250
|
+
}
|
|
251
|
+
function a(m, g) {
|
|
252
|
+
e.removeAllListeners(m), e.on(m, g);
|
|
253
|
+
}
|
|
254
|
+
function x(m) {
|
|
255
|
+
m && Object.assign(c, m);
|
|
256
|
+
}
|
|
257
|
+
function n() {
|
|
258
|
+
s.enable();
|
|
259
|
+
}
|
|
260
|
+
function L() {
|
|
261
|
+
s.disable();
|
|
262
|
+
}
|
|
263
|
+
function A() {
|
|
264
|
+
return l;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
every: a,
|
|
268
|
+
setTarget: d,
|
|
269
|
+
getTarget: i,
|
|
270
|
+
setDirection: T,
|
|
271
|
+
isMoving: A,
|
|
272
|
+
on: y,
|
|
273
|
+
once: S,
|
|
274
|
+
updateOption: x,
|
|
275
|
+
enable: n,
|
|
276
|
+
disable: L
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const tt = ["onMousedown"], nt = /* @__PURE__ */ be({
|
|
280
|
+
__name: "resize",
|
|
281
|
+
props: {
|
|
282
|
+
config: {},
|
|
283
|
+
scale: {},
|
|
284
|
+
handle: {},
|
|
285
|
+
move: {}
|
|
286
|
+
},
|
|
287
|
+
setup(e) {
|
|
288
|
+
ze((s) => ({
|
|
289
|
+
"61c40759": c.value
|
|
290
|
+
}));
|
|
291
|
+
const l = e, c = $(() => l.config.normal ? void 0 : je.ABSOLUTE);
|
|
292
|
+
return (s, h) => s.scale ? (j(!0), Q(Be, { key: 0 }, $e(s.scale.pointer, (d) => Ve((j(), Q("i", {
|
|
293
|
+
key: d,
|
|
294
|
+
class: pe([`p-${d}`]),
|
|
295
|
+
onMousedown: (i) => s.scale.onMouseDown(i, d)
|
|
296
|
+
}, null, 42, tt)), [
|
|
297
|
+
[We, s.config.scalable]
|
|
298
|
+
])), 128)) : re("", !0);
|
|
299
|
+
}
|
|
300
|
+
}), at = /* @__PURE__ */ Ee(nt, [["__scopeId", "data-v-cb7f9cc6"]]), ie = (e) => {
|
|
301
|
+
if (!e) return {};
|
|
302
|
+
const l = {};
|
|
303
|
+
for (const [c, s] of Object.entries(e))
|
|
304
|
+
l[c] = Se(c, s);
|
|
305
|
+
return l;
|
|
306
|
+
};
|
|
307
|
+
function Xe(e) {
|
|
308
|
+
function l() {
|
|
309
|
+
return {
|
|
310
|
+
scaleX: e.scale[0],
|
|
311
|
+
scaleY: e.scale[1]
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function c() {
|
|
315
|
+
return {
|
|
316
|
+
translateX: e.translateX,
|
|
317
|
+
translateY: e.translateY
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
function s(a, x, n) {
|
|
321
|
+
e.translateX = n ? e.translateX + a : a, e.translateY = n ? e.translateY + x : x;
|
|
322
|
+
}
|
|
323
|
+
function h(a, x) {
|
|
324
|
+
e.prevClientX = a, e.prevClientY = x;
|
|
325
|
+
}
|
|
326
|
+
function d(a, x) {
|
|
327
|
+
e.prevTranslateX = a, e.prevTranslateY = x;
|
|
328
|
+
}
|
|
329
|
+
function i() {
|
|
330
|
+
return {
|
|
331
|
+
clientX: e.prevClientX,
|
|
332
|
+
clientY: e.prevClientY
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function R() {
|
|
336
|
+
return {
|
|
337
|
+
translateX: e.prevTranslateX,
|
|
338
|
+
translateY: e.prevTranslateY
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function T(a, x) {
|
|
342
|
+
e.scale = [a, x];
|
|
343
|
+
}
|
|
344
|
+
function y() {
|
|
345
|
+
e.scale = [1, 1], e.prevClientX = 0, e.prevTranslateX = 0, e.prevClientY = 0, e.prevTranslateY = 0, e.translateX = 0, e.translateY = 0;
|
|
346
|
+
}
|
|
347
|
+
function S(a) {
|
|
348
|
+
Object.assign(e, a);
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
setData: S,
|
|
352
|
+
getTranslate: c,
|
|
353
|
+
setTranslate: s,
|
|
354
|
+
getScale: l,
|
|
355
|
+
setScale: T,
|
|
356
|
+
setNormal: y,
|
|
357
|
+
setPrevClientPos: h,
|
|
358
|
+
getPrevClientPos: i,
|
|
359
|
+
getPrevTranslate: R,
|
|
360
|
+
setPrevTranslate: d
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function Ye(e) {
|
|
364
|
+
function l(h, d) {
|
|
365
|
+
e.value && (e.value[h] = d);
|
|
366
|
+
}
|
|
367
|
+
function c(h) {
|
|
368
|
+
for (const [d, i] of Object.entries(h))
|
|
369
|
+
l(d, i);
|
|
370
|
+
}
|
|
371
|
+
function s(h) {
|
|
372
|
+
if (e.value)
|
|
373
|
+
return e.value[h];
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
get: s,
|
|
377
|
+
set: l,
|
|
378
|
+
sets: c
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function it(e, l, c, s, h, d, i) {
|
|
382
|
+
const { setNormal: R, setTranslate: T, setPrevTranslate: y } = Xe(s), { get: S, set: a } = Ye(h), x = Te(ye(S("position"))), n = qe(
|
|
383
|
+
async () => {
|
|
384
|
+
e.value.autoStick && (typeof e.value.autoStick == "boolean" ? await c.value?.autoStick(!0) : await c.value?.stickTo(e.value.autoStick, !0));
|
|
385
|
+
},
|
|
386
|
+
200,
|
|
387
|
+
{ maxWait: 1e3 }
|
|
388
|
+
);
|
|
389
|
+
function L() {
|
|
390
|
+
l.value && l.value.setTarget(ye(d) ?? i.value ?? null);
|
|
391
|
+
}
|
|
392
|
+
function A() {
|
|
393
|
+
c.value?.setStatus(He.NORMAL), g(e.value.movable), N(e.value.moveConfig), H(e.value.x, e.value.y), P(e.value.normal), ke(e.value.visible) ? m(e.value.visible, !1) : c.value?.hideTo("self", !1);
|
|
394
|
+
}
|
|
395
|
+
function m(o, u) {
|
|
396
|
+
if (!ke(o)) return;
|
|
397
|
+
const I = G(e.value.x) || G(e.value.y);
|
|
398
|
+
o ? c.value?.show(u, I ? { x: e.value.x, y: e.value.y } : "self") : c.value?.hideTo(I ? { x: e.value.x, y: e.value.y } : "self", u);
|
|
399
|
+
}
|
|
400
|
+
function g(o) {
|
|
401
|
+
o ? l.value?.enable() : l.value?.disable();
|
|
402
|
+
}
|
|
403
|
+
function P(o) {
|
|
404
|
+
o ? (l.value?.setTarget(), x.value = S("position"), e.value.movable = !1, e.value.scalable = !1, R(), a("position", "static")) : (L(), a("position", x.value));
|
|
405
|
+
}
|
|
406
|
+
function N(o) {
|
|
407
|
+
o && l.value?.updateOption(o);
|
|
408
|
+
}
|
|
409
|
+
function H(o, u) {
|
|
410
|
+
if (!l.value?.isMoving() && (G(e.value.x) || G(e.value.y))) {
|
|
411
|
+
const I = w(o), D = w(u);
|
|
412
|
+
T(I, D), y(I, D);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return q(() => e.value.movable, g), q(() => e.value.normal, P), q(() => e.value.moveConfig, N, { deep: !0 }), q(
|
|
416
|
+
() => e.value.visible,
|
|
417
|
+
(o) => m(o, !0)
|
|
418
|
+
), q([() => e.value.x, () => e.value.y], ([o, u]) => H(o, u)), q(d, () => {
|
|
419
|
+
e.value.normal || L();
|
|
420
|
+
}), {
|
|
421
|
+
autoStick: n,
|
|
422
|
+
onInit: A,
|
|
423
|
+
onMovableChange: g,
|
|
424
|
+
onNormalChange: P
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
function Ie(e, l) {
|
|
428
|
+
const c = Pe(e);
|
|
429
|
+
return c ? window.getComputedStyle(c).getPropertyValue(l) : Se(l, void 0);
|
|
430
|
+
}
|
|
431
|
+
var He = /* @__PURE__ */ ((e) => (e.NORMAL = "NORMAL", e.HIDDEN = "HIDDEN", e))(He || {}), se = /* @__PURE__ */ ((e) => (e.AFTER_SHOW = "after_show", e.AFTER_HIDE = "after_hide", e.AFTER_STICK = "after_stick", e))(se || {});
|
|
432
|
+
const rt = (e) => {
|
|
433
|
+
const { getTranslate: l, setTranslate: c, setScale: s, setPrevTranslate: h, getScale: d } = Xe(e.dragOffset);
|
|
434
|
+
let i = e.parent;
|
|
435
|
+
const R = Je(), T = ue(), y = Te(
|
|
436
|
+
"NORMAL"
|
|
437
|
+
/* NORMAL */
|
|
438
|
+
), S = {
|
|
439
|
+
stick: 160
|
|
440
|
+
}, a = {
|
|
441
|
+
transX: { old: 0, final: 0 },
|
|
442
|
+
transY: { old: 0, final: 0 }
|
|
443
|
+
}, x = [], n = [];
|
|
444
|
+
function L() {
|
|
445
|
+
const { translateX: t, translateY: f } = l();
|
|
446
|
+
a.transX.old = t, a.transX.final = t, a.transY.old = f, a.transY.final = f;
|
|
447
|
+
}
|
|
448
|
+
const { x: A, y: m, width: g, left: P } = le(e.targetEle);
|
|
449
|
+
function N(t, f) {
|
|
450
|
+
const r = {
|
|
451
|
+
width: window.innerWidth,
|
|
452
|
+
height: window.innerHeight
|
|
453
|
+
};
|
|
454
|
+
if (!e.targetEle.value || t.position === "fixed")
|
|
455
|
+
return r;
|
|
456
|
+
{
|
|
457
|
+
if (f) return r;
|
|
458
|
+
const Y = ne();
|
|
459
|
+
return r.width = Y.offsetWidth, r.height = Y.offsetHeight, r;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function H(t, f, r, v, Y) {
|
|
463
|
+
return () => {
|
|
464
|
+
s(Y[0], Y[1]), c(t, f), h(t, f);
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function o(t, f) {
|
|
468
|
+
const r = { x: 0, y: 0, w: 0, h: 0 };
|
|
469
|
+
if (!e.targetEle.value) return r;
|
|
470
|
+
const v = Ge(
|
|
471
|
+
{
|
|
472
|
+
x: (W, U, Fe, Ne) => U,
|
|
473
|
+
y: (W, U, Fe, Ne) => U,
|
|
474
|
+
scale: (W, U) => [W, U]
|
|
475
|
+
},
|
|
476
|
+
f
|
|
477
|
+
), Y = !!e.config.value.attachWindow, k = window.getComputedStyle(e.targetEle.value), B = N(k, Y);
|
|
478
|
+
let M = 0, O = 0;
|
|
479
|
+
const p = w(k.width), b = w(k.height);
|
|
480
|
+
r.w = p, r.h = b;
|
|
481
|
+
const { translateX: E, translateY: _ } = l();
|
|
482
|
+
if (k.position === "fixed" ? (M = w(k.left), O = w(k.top)) : Y ? (M = w(A.value - E), O = w(m.value - _)) : (M = w(k.left), O = w(k.top)), typeof t == "string")
|
|
483
|
+
switch (t) {
|
|
484
|
+
case "left": {
|
|
485
|
+
r.x = v.x(E, -w(M), p, b), r.y = v.y(_, _, p, b);
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
case "top": {
|
|
489
|
+
r.x = v.x(E, E, p, b), r.y = v.y(_, -w(O), p, b);
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
case "right": {
|
|
493
|
+
r.x = v.x(E, -w(M) + B.width - p, p, b), r.y = v.y(_, _, p, b);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
case "bottom": {
|
|
497
|
+
r.x = v.x(E, E, p, b), r.y = v.y(_, -w(O) + B.height - b, p, b);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case "self": {
|
|
501
|
+
r.x = v.x(E, E, p, b), r.y = v.y(_, _, p, b);
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
case "center":
|
|
505
|
+
default:
|
|
506
|
+
r.x = v.x(E, -w(M) + B.width / 2 - p / 2, p, b), r.y = v.y(_, -w(O) + B.height / 2 - b / 2, p, b);
|
|
507
|
+
}
|
|
508
|
+
else
|
|
509
|
+
G(t.x) ? r.x = v.x(E, -w(M) + (t.x ?? E), p, b) : r.x = v.x(E, E, p, b), G(t.y) ? r.y = v.y(_, -w(O) + (t.y ?? _), p, b) : r.y = v.y(_, _, p, b);
|
|
510
|
+
return r;
|
|
511
|
+
}
|
|
512
|
+
async function u(t, f, r, v) {
|
|
513
|
+
await new Promise((Y) => {
|
|
514
|
+
if (r(), !f) {
|
|
515
|
+
Y();
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
R.animate(
|
|
519
|
+
t,
|
|
520
|
+
v,
|
|
521
|
+
{ duration: S.stick, iterations: 1 },
|
|
522
|
+
{
|
|
523
|
+
finish(k, B) {
|
|
524
|
+
Y();
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
function I() {
|
|
531
|
+
return w(P.value) + w(g.value) / 2 >= window.innerWidth / 2 ? "right" : "left";
|
|
532
|
+
}
|
|
533
|
+
async function D(t = !0, f, r) {
|
|
534
|
+
if (!e.targetEle.value) return;
|
|
535
|
+
const { x: v, y: Y, w: k, h: B } = o(f, r), { scaleX: M, scaleY: O } = d(), p = {
|
|
536
|
+
old: [M, O],
|
|
537
|
+
final: [M, O]
|
|
538
|
+
};
|
|
539
|
+
if (r?.scale) {
|
|
540
|
+
const U = r.scale(p.old, p.final);
|
|
541
|
+
p.old = U[0], p.final = U[1];
|
|
542
|
+
}
|
|
543
|
+
const b = H(v, Y, k, B, p.final), { translateX: E, translateY: _ } = l(), W = [
|
|
544
|
+
{ scale: p.old, translate: [X(E), X(_)] },
|
|
545
|
+
{ scale: p.final, translate: [X(v), X(Y)] }
|
|
546
|
+
];
|
|
547
|
+
await u(e.targetEle.value, t, b, W);
|
|
548
|
+
}
|
|
549
|
+
async function C(t = !0, f) {
|
|
550
|
+
if (y.value !== "HIDDEN" || !e.targetEle.value) return;
|
|
551
|
+
const r = [0, 0], v = [1, 1], Y = [
|
|
552
|
+
{ scale: v, translate: [X(a.transX.final), X(a.transY.final)] },
|
|
553
|
+
{ scale: v, translate: [X(a.transX.old), X(a.transY.old)] }
|
|
554
|
+
], k = () => {
|
|
555
|
+
s(v[0], v[1]), c(a.transX.old, a.transY.old), h(a.transX.old, a.transY.old);
|
|
556
|
+
};
|
|
557
|
+
f ? await D(t, f, {
|
|
558
|
+
scale(B, M) {
|
|
559
|
+
return f === "self" || f === "center" ? [r, v] : [v, v];
|
|
560
|
+
}
|
|
561
|
+
}) : await u(e.targetEle.value, t, k, Y), y.value = "NORMAL", T.emit(
|
|
562
|
+
"after_show"
|
|
563
|
+
/* AFTER_SHOW */
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
async function F(t, f = !0) {
|
|
567
|
+
if (y.value !== "NORMAL" || !e.targetEle.value) return;
|
|
568
|
+
for await (const b of x)
|
|
569
|
+
await b();
|
|
570
|
+
L();
|
|
571
|
+
const { x: r, y: v, w: Y, h: k } = o(t, {
|
|
572
|
+
x: (b, E, _, W) => {
|
|
573
|
+
switch (t) {
|
|
574
|
+
case "left":
|
|
575
|
+
return E -= w(_);
|
|
576
|
+
case "right":
|
|
577
|
+
return E += w(_);
|
|
578
|
+
}
|
|
579
|
+
return E;
|
|
580
|
+
},
|
|
581
|
+
y: (b, E, _, W) => {
|
|
582
|
+
switch (t) {
|
|
583
|
+
case "top":
|
|
584
|
+
return E -= w(W);
|
|
585
|
+
case "bottom":
|
|
586
|
+
return E += w(W);
|
|
587
|
+
}
|
|
588
|
+
return E;
|
|
589
|
+
}
|
|
590
|
+
}), { translateX: B, translateY: M } = l();
|
|
591
|
+
let O = [
|
|
592
|
+
{ scale: [1, 1], translate: [X(B), X(M)] },
|
|
593
|
+
{ scale: [1, 1], translate: [X(r), X(v)] }
|
|
594
|
+
];
|
|
595
|
+
(t === "self" || t === "center") && (O = [
|
|
596
|
+
{ scale: [1, 1], translate: [X(r), X(v)] },
|
|
597
|
+
{ scale: [0, 0], translate: [X(r), X(v)] }
|
|
598
|
+
]), a.transX.final = r, a.transY.final = v;
|
|
599
|
+
const p = H(r, v, Y, k, [0, 0]);
|
|
600
|
+
await u(e.targetEle.value, f, p, O), y.value = "HIDDEN", T.emit(
|
|
601
|
+
"after_hide"
|
|
602
|
+
/* AFTER_HIDE */
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
async function z(t, f = !0) {
|
|
606
|
+
if (y.value === "NORMAL" && e.targetEle.value) {
|
|
607
|
+
for await (const r of n)
|
|
608
|
+
await r();
|
|
609
|
+
await D(f, t), T.emit(
|
|
610
|
+
"after_stick"
|
|
611
|
+
/* AFTER_STICK */
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
async function V(t = !0) {
|
|
616
|
+
y.value === "NORMAL" && await F(I(), t);
|
|
617
|
+
}
|
|
618
|
+
async function Z(t = !0) {
|
|
619
|
+
y.value === "NORMAL" && await z(I(), t);
|
|
620
|
+
}
|
|
621
|
+
function ce(t) {
|
|
622
|
+
y.value = t;
|
|
623
|
+
}
|
|
624
|
+
function K() {
|
|
625
|
+
return y.value;
|
|
626
|
+
}
|
|
627
|
+
function fe() {
|
|
628
|
+
return e.targetEle.value;
|
|
629
|
+
}
|
|
630
|
+
function ve(t, f) {
|
|
631
|
+
T.on(t, f);
|
|
632
|
+
}
|
|
633
|
+
function de(t) {
|
|
634
|
+
x.push(t);
|
|
635
|
+
}
|
|
636
|
+
function he(t) {
|
|
637
|
+
n.push(t);
|
|
638
|
+
}
|
|
639
|
+
function ge(t) {
|
|
640
|
+
t && (i = t);
|
|
641
|
+
}
|
|
642
|
+
function ne() {
|
|
643
|
+
return i ?? e.targetEle.value?.parentElement ?? document.body;
|
|
644
|
+
}
|
|
645
|
+
function me() {
|
|
646
|
+
T.removeAllListeners(), x.length = 0, n.length = 0;
|
|
647
|
+
}
|
|
648
|
+
return {
|
|
649
|
+
getTarget: fe,
|
|
650
|
+
setStatus: ce,
|
|
651
|
+
getStatus: K,
|
|
652
|
+
show: C,
|
|
653
|
+
autoHide: V,
|
|
654
|
+
autoStick: Z,
|
|
655
|
+
stickTo: z,
|
|
656
|
+
hideTo: F,
|
|
657
|
+
moveTo: D,
|
|
658
|
+
dispose: me,
|
|
659
|
+
registerBeforeHideHook: de,
|
|
660
|
+
registerBeforeStickHook: he,
|
|
661
|
+
on: ve,
|
|
662
|
+
setTargetParent: ge,
|
|
663
|
+
getTargetParent: ne
|
|
664
|
+
};
|
|
665
|
+
};
|
|
666
|
+
var xe = /* @__PURE__ */ ((e) => (e.SCALING = "scaling", e.AFTER_SCALE = "after_scale", e))(xe || {});
|
|
667
|
+
const ot = (e) => {
|
|
668
|
+
const l = oe(e.config.value, "containerStyle"), { set: c, sets: s } = Ye(l), h = ue(), d = ["t", "r", "b", "l", "lt", "rt", "lb", "rb"];
|
|
669
|
+
let i = "";
|
|
670
|
+
const { x: R, y: T, width: y, height: S, update: a } = le(e.targetEle), x = {
|
|
671
|
+
t: (o, u) => {
|
|
672
|
+
o.clientY >= n.y + n.height || s({ top: u.t, height: u.h });
|
|
673
|
+
},
|
|
674
|
+
r: (o, u) => {
|
|
675
|
+
c("width", u.w);
|
|
676
|
+
},
|
|
677
|
+
b: (o, u) => {
|
|
678
|
+
c("height", u.h);
|
|
679
|
+
},
|
|
680
|
+
l: (o, u) => {
|
|
681
|
+
o.clientX >= n.x + n.width || s({ left: u.l, width: u.w });
|
|
682
|
+
},
|
|
683
|
+
lt: (o, u) => {
|
|
684
|
+
o.clientX >= n.x + n.width || o.clientY >= n.y + n.height || s({ left: u.l, top: u.t, width: u.w, height: u.h });
|
|
685
|
+
},
|
|
686
|
+
rt: (o, u) => {
|
|
687
|
+
o.clientY >= n.y + n.height || s({ top: u.t, width: u.w, height: u.h });
|
|
688
|
+
},
|
|
689
|
+
lb: (o, u) => {
|
|
690
|
+
o.clientX >= n.x + n.width || s({ left: u.l, width: u.w, height: u.h });
|
|
691
|
+
},
|
|
692
|
+
rb: (o, u) => {
|
|
693
|
+
s({ width: u.w, height: u.h });
|
|
694
|
+
}
|
|
695
|
+
}, n = { x: 0, y: 0, clientX: 0, clientY: 0, left: 0, top: 0, width: 0, height: 0 };
|
|
696
|
+
function L(o) {
|
|
697
|
+
o.preventDefault();
|
|
698
|
+
}
|
|
699
|
+
function A(o) {
|
|
700
|
+
const u = n.top + o.clientY - n.clientY, I = n.left + o.clientX - n.clientX, D = i.startsWith("r") ? o.clientX - n.x : n.width + n.clientX - o.clientX, C = i.endsWith("t") ? n.height + n.clientY - o.clientY : o.clientY - n.y;
|
|
701
|
+
x[i](o, {
|
|
702
|
+
l: I,
|
|
703
|
+
t: u,
|
|
704
|
+
w: D,
|
|
705
|
+
h: C
|
|
706
|
+
}), h.emit(
|
|
707
|
+
"scaling"
|
|
708
|
+
/* SCALING */
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
function m() {
|
|
712
|
+
document.removeEventListener("mouseup", m), document.removeEventListener("mousemove", A), document.removeEventListener("selectstart", L), h.emit(
|
|
713
|
+
"after_scale"
|
|
714
|
+
/* AFTER_SCALE */
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
function g(o, u) {
|
|
718
|
+
document.addEventListener("selectstart", L), i = u, o.stopPropagation(), o.preventDefault(), a(), n.x = R.value, n.y = T.value, n.clientX = o.clientX, n.clientY = o.clientY, n.left = w(e.config.value.containerStyle?.left), n.top = w(e.config.value.containerStyle?.top) || w(e.targetEle.value?.offsetTop), n.width = y.value, n.height = S.value, document.addEventListener("mousemove", A), document.addEventListener("mouseup", m);
|
|
719
|
+
}
|
|
720
|
+
function P(o, u) {
|
|
721
|
+
h.on(o, u);
|
|
722
|
+
}
|
|
723
|
+
function N() {
|
|
724
|
+
h.removeAllListeners();
|
|
725
|
+
}
|
|
726
|
+
function H() {
|
|
727
|
+
return e.targetEle.value;
|
|
728
|
+
}
|
|
729
|
+
return {
|
|
730
|
+
pointer: d,
|
|
731
|
+
getTarget: H,
|
|
732
|
+
onMouseDown: g,
|
|
733
|
+
on: P,
|
|
734
|
+
dispose: N
|
|
735
|
+
};
|
|
736
|
+
}, st = /* @__PURE__ */ be({
|
|
737
|
+
__name: "index",
|
|
738
|
+
props: {
|
|
739
|
+
modelValue: {},
|
|
740
|
+
dragTarget: {}
|
|
741
|
+
},
|
|
742
|
+
emits: ["beforeMove", "moving", "afterMove", "scaling", "afterScale", "maskClick", "update:modelValue"],
|
|
743
|
+
setup(e, { expose: l, emit: c }) {
|
|
744
|
+
const s = c, h = e, d = Te(), i = $({
|
|
745
|
+
get: () => h.modelValue,
|
|
746
|
+
set: (t) => s("update:modelValue", t)
|
|
747
|
+
}), R = te("header"), T = te("scales"), y = te("drag"), S = ee(), a = oe(i.value, "containerStyle"), x = oe(i.value, "contentStyle"), n = oe(i.value, "headerStyle"), { get: L } = Ye(a), A = Ae({
|
|
748
|
+
prevClientX: 0,
|
|
749
|
+
prevClientY: 0,
|
|
750
|
+
prevTranslateX: 0,
|
|
751
|
+
prevTranslateY: 0,
|
|
752
|
+
translateX: 0,
|
|
753
|
+
translateY: 0,
|
|
754
|
+
scale: [0, 0]
|
|
755
|
+
}), { getScale: m, getTranslate: g, setTranslate: P, setPrevClientPos: N, getPrevClientPos: H, setPrevTranslate: o, getPrevTranslate: u } = Xe(A), I = ot({
|
|
756
|
+
config: i,
|
|
757
|
+
targetEle: y
|
|
758
|
+
}), D = $(() => ye(h.dragTarget)), C = $(() => !!i.value.header), F = $(() => ie(x.value)), z = $(() => ie(n.value)), V = $(() => ie(a.value)), Z = $(() => {
|
|
759
|
+
const { scaleX: t, scaleY: f } = m(), { translateX: r, translateY: v } = g(), Y = L("width") ?? Ie(y, "width"), k = L("height") ?? Ie(y, "height");
|
|
760
|
+
return {
|
|
761
|
+
transform: `scale(${t},${f}) translate(${X(r)},${X(v)})`,
|
|
762
|
+
zIndex: i.value.normal ? void 0 : Se("zIndex", L("zIndex")),
|
|
763
|
+
// 计算其transform中心点,用于优化动画效果。元素移动时,其left和top并没有发生变化
|
|
764
|
+
transformOrigin: `${X(parseFloat((r + w(Y) / 2).toFixed(2)))}
|
|
765
|
+
${X(parseFloat((v + w(k) / 2).toFixed(2)))}`
|
|
766
|
+
};
|
|
767
|
+
}), ce = $(() => ie(i.value.maskStyle)), { autoStick: K, onInit: fe, onMovableChange: ve, onNormalChange: de } = it(
|
|
768
|
+
i,
|
|
769
|
+
S,
|
|
770
|
+
d,
|
|
771
|
+
A,
|
|
772
|
+
a,
|
|
773
|
+
D,
|
|
774
|
+
R
|
|
775
|
+
);
|
|
776
|
+
function he() {
|
|
777
|
+
S.value = et(), S.value.every("beforemove", (t) => {
|
|
778
|
+
N(t.clientX, t.clientY), s("beforeMove", Object.assign({}, t, g()));
|
|
779
|
+
}), S.value.every("moving", (t) => {
|
|
780
|
+
const { clientX: f, clientY: r } = H(), { translateX: v, translateY: Y } = u();
|
|
781
|
+
P(v + t.clientX - f, Y + t.clientY - r);
|
|
782
|
+
const k = g();
|
|
783
|
+
(G(i.value.x) || G(i.value.y)) && (i.value.x = k.translateX, i.value.y = k.translateY), s("moving", { ...t, ...k });
|
|
784
|
+
}), S.value.every("aftermove", async (t) => {
|
|
785
|
+
const { translateX: f, translateY: r } = g();
|
|
786
|
+
o(f, r), await K(), s("afterMove", { ...t, ...g() });
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
function ge() {
|
|
790
|
+
I.on(xe.AFTER_SCALE, async () => {
|
|
791
|
+
await K(), T.value && s("afterScale", T.value);
|
|
792
|
+
}), I.on(xe.SCALING, async () => {
|
|
793
|
+
T.value && s("scaling", T.value);
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
function ne() {
|
|
797
|
+
d.value = rt({
|
|
798
|
+
config: i,
|
|
799
|
+
targetEle: y,
|
|
800
|
+
dragOffset: A
|
|
801
|
+
}), d.value.on(se.AFTER_HIDE, () => {
|
|
802
|
+
i.value.visible = !1;
|
|
803
|
+
}), d.value.on(se.AFTER_SHOW, () => {
|
|
804
|
+
i.value.visible = !0;
|
|
805
|
+
}), d.value.on(se.AFTER_STICK, () => {
|
|
806
|
+
const { translateX: t, translateY: f } = g();
|
|
807
|
+
i.value.x = t, i.value.y = f;
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
async function me() {
|
|
811
|
+
ge(), he(), ne(), ve(i.value.movable), de(i.value.normal), fe(), window.addEventListener("resize", K);
|
|
812
|
+
}
|
|
813
|
+
return De(me), Me(() => {
|
|
814
|
+
window.removeEventListener("resize", K), I.dispose(), d.value?.dispose();
|
|
815
|
+
}), l({
|
|
816
|
+
async autoStick(t) {
|
|
817
|
+
return d.value?.autoStick(t);
|
|
818
|
+
},
|
|
819
|
+
async stickTo(t, f) {
|
|
820
|
+
return d.value?.stickTo(t, f);
|
|
821
|
+
},
|
|
822
|
+
async hideTo(t, f) {
|
|
823
|
+
return d.value?.hideTo(t, f);
|
|
824
|
+
},
|
|
825
|
+
async autoHide(t) {
|
|
826
|
+
return d.value?.autoHide(t);
|
|
827
|
+
},
|
|
828
|
+
async show(t, f) {
|
|
829
|
+
return d.value?.show(t, f);
|
|
830
|
+
},
|
|
831
|
+
async moveTo(t, f, r) {
|
|
832
|
+
return d.value?.moveTo(t, f, r);
|
|
833
|
+
},
|
|
834
|
+
getStatus: function() {
|
|
835
|
+
return d.value?.getStatus();
|
|
836
|
+
}
|
|
837
|
+
}), (t, f) => (j(), Q("div", {
|
|
838
|
+
ref: "drag",
|
|
839
|
+
class: "dragContainer",
|
|
840
|
+
style: J([V.value, Z.value])
|
|
841
|
+
}, [
|
|
842
|
+
C.value ? (j(), Q("div", {
|
|
843
|
+
key: 0,
|
|
844
|
+
ref: "header",
|
|
845
|
+
class: "dragHeader",
|
|
846
|
+
style: J(z.value)
|
|
847
|
+
}, [
|
|
848
|
+
we(t.$slots, "header", {}, void 0, !0)
|
|
849
|
+
], 4)) : re("", !0),
|
|
850
|
+
i.value.scalable ? (j(), Ce(at, {
|
|
851
|
+
key: 1,
|
|
852
|
+
config: i.value,
|
|
853
|
+
scale: Pe(I),
|
|
854
|
+
move: S.value
|
|
855
|
+
}, null, 8, ["config", "scale", "move"])) : re("", !0),
|
|
856
|
+
Oe("div", {
|
|
857
|
+
ref: "scales",
|
|
858
|
+
class: "scaleContent",
|
|
859
|
+
style: J(F.value)
|
|
860
|
+
}, [
|
|
861
|
+
we(t.$slots, "default", {}, void 0, !0)
|
|
862
|
+
], 4),
|
|
863
|
+
(j(), Ce(Ue, {
|
|
864
|
+
to: "body",
|
|
865
|
+
disabled: !i.value.mask
|
|
866
|
+
}, [
|
|
867
|
+
i.value.mask ? (j(), Q("div", {
|
|
868
|
+
key: 0,
|
|
869
|
+
class: "dragMask",
|
|
870
|
+
style: J(ce.value),
|
|
871
|
+
onClick: f[0] || (f[0] = (r) => s("maskClick"))
|
|
872
|
+
}, null, 4)) : re("", !0)
|
|
873
|
+
], 8, ["disabled"]))
|
|
874
|
+
], 4));
|
|
875
|
+
}
|
|
876
|
+
}), dt = /* @__PURE__ */ Ee(st, [["__scopeId", "data-v-d123b73c"]]);
|
|
877
|
+
export {
|
|
878
|
+
vt as Affix,
|
|
879
|
+
dt as ScalePanel
|
|
880
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toolmain/components",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "arsh <https://github.com/evilArsh>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/evilArsh/toolmain.git",
|
|
11
|
+
"directory": "packages/components"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vue"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./*": "./dist/*"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/*.js",
|
|
25
|
+
"dist/*.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@vueuse/core": "^13.7.0",
|
|
29
|
+
"unocss": "^66.4.2",
|
|
30
|
+
"vue": "^3.5.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@toolmain/shared": "^1.0.0",
|
|
34
|
+
"@toolmain/libs": "^1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vue-tsc -p tsconfig.json --declaration --emitDeclarationOnly && vite build && api-extractor run"
|
|
38
|
+
}
|
|
39
|
+
}
|