twcpt 0.0.36 → 0.0.37

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,42 @@
1
+ /**
2
+ * 下拉弹层(position: fixed)定位工具
3
+ * 兼容 html/body 上设置 zoom 的场景:getBoundingClientRect 返回缩放后的坐标,
4
+ * 而写回 fixed 元素的 left/top 会再次被缩放,因此需要换算回布局坐标。
5
+ */
6
+ export type DropdownAlign = 'center' | 'left' | 'right';
7
+ export interface LayoutRect {
8
+ bottom: number;
9
+ height: number;
10
+ left: number;
11
+ right: number;
12
+ top: number;
13
+ width: number;
14
+ }
15
+ export interface DropdownPositionOptions {
16
+ /** 水平对齐方式,默认 left */
17
+ align?: DropdownAlign;
18
+ /** 弹层与触发元素的间距,默认 8 */
19
+ gap?: number;
20
+ /** 弹层元素,用于读取高度判断是否需要向上展开 */
21
+ menu?: HTMLElement | null;
22
+ /** 弹层宽度,center/right 对齐时需要;不传则读取 menu 宽度 */
23
+ menuWidth?: number;
24
+ /** 触发元素 */
25
+ trigger: HTMLElement;
26
+ }
27
+ export declare const DROPDOWN_GAP = 8;
28
+ /**
29
+ * 获取元素当前的缩放比例(视觉尺寸 / 布局尺寸)
30
+ */
31
+ export declare function getElementScale(el: HTMLElement, rect?: DOMRect): number;
32
+ /**
33
+ * 获取元素在 fixed 布局坐标系下的位置
34
+ */
35
+ export declare function getLayoutRect(el: HTMLElement, scale?: number): LayoutRect;
36
+ /**
37
+ * 计算下拉弹层位置:默认在触发元素下方,空间不足时向上展开
38
+ */
39
+ export declare function getDropdownPosition(options: DropdownPositionOptions): {
40
+ left: number;
41
+ top: number;
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "twcpt",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "description": "A Vue 3 component library built with Vite and TypeScript, featuring components integrated with Element-plus.",
5
5
  "main": "dist/twcpt.umd.js",
6
6
  "module": "dist/twcpt.es.js",