sard-uniapp 1.24.2 → 1.24.4
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/CHANGELOG.md +28 -0
- package/components/cascader-input/cascader-input.vue +1 -0
- package/components/cascader-popout/cascader-popout.vue +1 -0
- package/components/config/index.d.ts +1 -0
- package/components/config/index.js +1 -0
- package/components/datetime-picker/datetime-picker.vue +2 -2
- package/components/fab/README.md +82 -35
- package/components/fab/common.d.ts +19 -0
- package/components/fab/common.js +1 -0
- package/components/fab/fab.d.ts +9 -2
- package/components/fab/fab.vue +58 -53
- package/components/fab/index.d.ts +1 -1
- package/components/fab/index.scss +1 -54
- package/components/fab-item/common.d.ts +23 -0
- package/components/fab-item/common.js +1 -0
- package/components/fab-item/fab-item.d.ts +14 -0
- package/components/fab-item/fab-item.vue +93 -0
- package/components/fab-item/index.d.ts +1 -0
- package/components/fab-item/index.js +1 -0
- package/components/fab-item/index.scss +44 -0
- package/components/floating-bubble/README.md +12 -10
- package/components/floating-bubble/common.d.ts +2 -0
- package/components/floating-bubble/floating-bubble.vue +9 -3
- package/components/floating-bubble/useFloatingBubble.d.ts +3 -0
- package/components/floating-bubble/useFloatingBubble.js +10 -3
- package/components/form-item/useFormItem.js +3 -2
- package/components/input/input.vue +0 -3
- package/components/popout/README.md +17 -16
- package/components/popout/popout.vue +1 -0
- package/components/popup/README.md +12 -11
- package/components/popup/popup.vue +1 -0
- package/components/share-sheet/share-sheet.vue +1 -0
- package/components/toast/common.d.ts +1 -0
- package/components/toast/index.scss +0 -16
- package/components/toast/toast.d.ts +1 -0
- package/components/toast/toast.vue +2 -5
- package/components/toast-agent/common.d.ts +1 -0
- package/components/toast-agent/toast-agent.d.ts +1 -0
- package/global.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/utils/dom.d.ts +1 -1
- package/utils/dom.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.24.4](https://github.com/sutras/sard-uniapp/compare/v1.24.3...v1.24.4) (2025-09-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **form-item:** 修复滚动报错问题 ([046fc16](https://github.com/sutras/sard-uniapp/commit/046fc16abc03e260172eb9a6f763b241d58ebd05))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [1.24.3](https://github.com/sutras/sard-uniapp/compare/v1.24.2...v1.24.3) (2025-09-13)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **cascader:** 修复allLevels属性透传问题 ([ab36e14](https://github.com/sutras/sard-uniapp/commit/ab36e14f4dee3c5162fa37514667e8362b084744))
|
|
16
|
+
* **datetime-picker:** 修复农历转公历错误的问题 ([9906925](https://github.com/sutras/sard-uniapp/commit/9906925e43b4ca0f5845d932e54db0fccc4e1841))
|
|
17
|
+
* **fab, floating-bubble:** 修复定位不准确的问题 ([de86205](https://github.com/sutras/sard-uniapp/commit/de862051a02c9ba9b4bda963937d07330171dbfd))
|
|
18
|
+
* **input,textarea:** 修复有些机型在输入合成时被最大输入长度阻碍的问题 ([057e800](https://github.com/sutras/sard-uniapp/commit/057e8004fa06849a2e6423d56bf3c4fc85318a8a))
|
|
19
|
+
* 修复web pc端展示默认导航时虚拟触摸事件clientY偏差问题 ([224c052](https://github.com/sutras/sard-uniapp/commit/224c0525e1f1171b05ed212bf4906e09e9c9374e))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **fab:** 允许自定义按钮 ([312b425](https://github.com/sutras/sard-uniapp/commit/312b4252497b3ab2d030e10057cc73ef6a7c116b))
|
|
25
|
+
* **toast:** 添加transparent属性的全局配置 ([ba14176](https://github.com/sutras/sard-uniapp/commit/ba14176e73d88413a864e35e787233b164028427))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
1
29
|
## [1.24.2](https://github.com/sutras/sard-uniapp/compare/v1.24.1...v1.24.2) (2025-09-06)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -148,7 +148,7 @@ export default _defineComponent({
|
|
|
148
148
|
} else {
|
|
149
149
|
const lunarDate = solarToLunar(
|
|
150
150
|
innerValue.value.getFullYear(),
|
|
151
|
-
innerValue.value.getMonth(),
|
|
151
|
+
innerValue.value.getMonth() + 1,
|
|
152
152
|
innerValue.value.getDate()
|
|
153
153
|
);
|
|
154
154
|
const yearIndex = innerType.value.indexOf("y");
|
|
@@ -246,7 +246,7 @@ export default _defineComponent({
|
|
|
246
246
|
} else {
|
|
247
247
|
const lunarDate = solarToLunar(
|
|
248
248
|
innerValue.value.getFullYear(),
|
|
249
|
-
innerValue.value.getMonth(),
|
|
249
|
+
innerValue.value.getMonth() + 1,
|
|
250
250
|
innerValue.value.getDate()
|
|
251
251
|
);
|
|
252
252
|
return innerType.value.map((letter) => {
|
package/components/fab/README.md
CHANGED
|
@@ -14,6 +14,7 @@ version: 1.5+
|
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import Fab from 'sard-uniapp/components/fab/fab.vue'
|
|
17
|
+
import FabItem from 'sard-uniapp/components/fab-item/fab-item.vue'
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
## 代码演示
|
|
@@ -24,7 +25,7 @@ import Fab from 'sard-uniapp/components/fab/fab.vue'
|
|
|
24
25
|
|
|
25
26
|
@code('${DEMO_PATH}/fab/demo/Basic.vue')
|
|
26
27
|
|
|
27
|
-
###
|
|
28
|
+
### 自定义颜色
|
|
28
29
|
|
|
29
30
|
设置 `background` 属性以及按钮项的 `background` 自定义背景色。
|
|
30
31
|
|
|
@@ -54,50 +55,72 @@ import Fab from 'sard-uniapp/components/fab/fab.vue'
|
|
|
54
55
|
|
|
55
56
|
@code('${DEMO_PATH}/fab/demo/BottomLeft.vue')
|
|
56
57
|
|
|
57
|
-
### 无扩展按钮显示
|
|
58
|
-
|
|
59
|
-
当不设置 `item-list` 属性,或其数组长度为 0,则不显示扩展按钮。
|
|
60
|
-
|
|
61
|
-
@code('${DEMO_PATH}/fab/demo/NonItemList.vue')
|
|
62
|
-
|
|
63
58
|
### 自定义图标
|
|
64
59
|
|
|
65
60
|
使用 `icon` 和 `icon-family` 可自定义悬浮按钮图标。
|
|
66
61
|
|
|
67
62
|
@code('${DEMO_PATH}/fab/demo/Icon.vue')
|
|
68
63
|
|
|
64
|
+
### 自定义插槽内容 <sup>1.24.3+</sup>
|
|
65
|
+
|
|
66
|
+
使用 `default` 插槽自定义入口按钮内容,使用 `list` 插槽自定义扩展按钮内容,需要自行循环 `FabItem` 组件。
|
|
67
|
+
|
|
68
|
+
@code('${DEMO_PATH}/fab/demo/Slots.vue')
|
|
69
|
+
|
|
70
|
+
### 可拖拽的 <sup>1.24.2+</sup>
|
|
71
|
+
|
|
72
|
+
设置 `draggable` 属性,悬浮按钮展示在右下角,允许在 y 轴方向上下拖拽。
|
|
73
|
+
|
|
74
|
+
@code('${DEMO_PATH}/fab/demo/Draggable.vue')
|
|
75
|
+
|
|
76
|
+
### 自由拖拽和磁吸 <sup>1.24.2+</sup>
|
|
77
|
+
|
|
78
|
+
`axis` 属性设置允许在 x 或 y 轴方向拖拽,`magnet` 属性设置松开手指后吸附到指定轴方向的最近一边。
|
|
79
|
+
|
|
80
|
+
@code('${DEMO_PATH}/fab/demo/Magnet.vue')
|
|
81
|
+
|
|
82
|
+
### 双向绑定 <sup>1.24.2+</sup>
|
|
83
|
+
|
|
84
|
+
使用 `v-model:offset` 控制悬浮按钮的位置。
|
|
85
|
+
|
|
86
|
+
@code('${DEMO_PATH}/fab/demo/Offset.vue')
|
|
87
|
+
|
|
69
88
|
## API
|
|
70
89
|
|
|
71
90
|
### FabProps
|
|
72
91
|
|
|
73
|
-
| 属性 | 描述
|
|
74
|
-
| ----------------------------------- |
|
|
75
|
-
| root-class | 组件根元素类名
|
|
76
|
-
| root-style | 组件根元素样式
|
|
77
|
-
| top | 设置距离窗口顶部的距离,优先级比 `bottom` 高
|
|
78
|
-
| right | 设置距离窗口右边的距离
|
|
79
|
-
| bottom | 设置距离窗口底部的距离
|
|
80
|
-
| left | 设置距离窗口左边的距离,优先级比 `right` 高
|
|
81
|
-
| color | 设置按钮图标的颜色
|
|
82
|
-
| background | 设置按钮的背景色
|
|
83
|
-
| icon | 设置入口按钮的图标
|
|
84
|
-
| icon
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
| gap-
|
|
94
|
-
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
92
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
93
|
+
| ----------------------------------- | --------------------------------------------------------- | ------------------------------ | ------ |
|
|
94
|
+
| root-class | 组件根元素类名 | string | - |
|
|
95
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
96
|
+
| top | 设置距离窗口顶部的距离,优先级比 `bottom` 高 | string | - |
|
|
97
|
+
| right | 设置距离窗口右边的距离 | string | - |
|
|
98
|
+
| bottom | 设置距离窗口底部的距离 | string | - |
|
|
99
|
+
| left | 设置距离窗口左边的距离,优先级比 `right` 高 | string | - |
|
|
100
|
+
| color | 设置按钮图标的颜色 | string | - |
|
|
101
|
+
| background | 设置按钮的背景色 | string | - |
|
|
102
|
+
| icon | 设置入口按钮的图标 | string | - |
|
|
103
|
+
| visible-icon <sup>1.24.3+</sup> | 设置弹出扩展按钮时的入口按钮的图标 | string | - |
|
|
104
|
+
| icon-family | 设置入口按钮的图标族 | string | - |
|
|
105
|
+
| item-list | 设置扩展按钮 | FabItem[] | [] |
|
|
106
|
+
| hide-name | 是否隐藏按钮名称 | boolean | false |
|
|
107
|
+
| overlay-closable | 点击遮罩是否隐藏扩展按钮 | boolean | false |
|
|
108
|
+
| duration | 扩展按钮显隐动画时长,单位 ms | number | 150 |
|
|
109
|
+
| draggable <sup>1.24.2+</sup> | 是否可拖拽 | boolean | false |
|
|
110
|
+
| axis <sup>1.24.2+</sup> | 允许拖拽的方向轴 | 'x' \| 'y' \| 'both' \| 'none' | 'y' |
|
|
111
|
+
| magnet <sup>1.24.2+</sup> | 吸附到指定轴最近的一边,在拖拽时使用 | 'x' \| 'y' | - |
|
|
112
|
+
| gap-x <sup>1.24.2+</sup> | 悬浮按钮与窗口左右两边的最小间距,单位为 px,在拖拽时使用 | number | 24 |
|
|
113
|
+
| gap-y <sup>1.24.2+</sup> | 悬浮按钮与窗口上下两边的最小间距,单位为 px,在拖拽时使用 | number | 24 |
|
|
114
|
+
| offset (v-model) <sup>1.24.2+</sup> | 控制悬浮按钮的位置,在拖拽时使用 | { x: number; y: number } | - |
|
|
115
|
+
| navbar-height <sup>1.24.3+</sup> | 自定义顶部导航栏的高度,在拖拽时使用 | number | 0 |
|
|
116
|
+
| tabbar-height <sup>1.24.3+</sup> | 自定义底部标签栏的高度,在拖拽时使用 | number | 0 |
|
|
117
|
+
|
|
118
|
+
### FabSlots <sup>1.24.3+</sup>
|
|
119
|
+
|
|
120
|
+
| 插槽 | 描述 | 属性 |
|
|
121
|
+
| ------- | ------------------ | ------------------------------------------------------- |
|
|
122
|
+
| default | 自定义入口按钮内容 | { visible: boolean } |
|
|
123
|
+
| list | 自定义扩展按钮内容 | { onItemClick: (item: FabItem, index: number) => void } |
|
|
101
124
|
|
|
102
125
|
### FabEmits
|
|
103
126
|
|
|
@@ -117,6 +140,30 @@ import Fab from 'sard-uniapp/components/fab/fab.vue'
|
|
|
117
140
|
| icon | 按钮图标 | string | - |
|
|
118
141
|
| icon-family | 按钮图标族 | string | - |
|
|
119
142
|
|
|
143
|
+
### FabItemProps <sup>1.24.3+</sup>
|
|
144
|
+
|
|
145
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
146
|
+
| ----------- | -------------- | ---------- | ------ |
|
|
147
|
+
| root-class | 组件根元素类名 | string | - |
|
|
148
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
149
|
+
| name | 按钮名称 | string | - |
|
|
150
|
+
| color | 按钮图标颜色 | string | - |
|
|
151
|
+
| background | 按钮背景色 | string | - |
|
|
152
|
+
| icon | 按钮图标 | string | - |
|
|
153
|
+
| icon-family | 按钮图标族 | string | - |
|
|
154
|
+
|
|
155
|
+
### FabItemSlots <sup>1.24.3+</sup>
|
|
156
|
+
|
|
157
|
+
| 插槽 | 描述 | 属性 |
|
|
158
|
+
| ------- | -------------- | ---- |
|
|
159
|
+
| default | 自定义按钮内容 | - |
|
|
160
|
+
|
|
161
|
+
### FabItemEmits <sup>1.24.3+</sup>
|
|
162
|
+
|
|
163
|
+
| 事件 | 描述 | 类型 |
|
|
164
|
+
| ----- | -------------- | -------------------- |
|
|
165
|
+
| click | 点击按钮时触发 | (event: any) => void |
|
|
166
|
+
|
|
120
167
|
## 主题定制
|
|
121
168
|
|
|
122
169
|
### CSS 变量
|
|
@@ -9,6 +9,7 @@ export interface FabProps {
|
|
|
9
9
|
color?: string;
|
|
10
10
|
background?: string;
|
|
11
11
|
icon?: string;
|
|
12
|
+
visibleIcon?: string;
|
|
12
13
|
iconFamily?: string;
|
|
13
14
|
itemList?: FabItem[];
|
|
14
15
|
hideName?: boolean;
|
|
@@ -23,6 +24,8 @@ export interface FabProps {
|
|
|
23
24
|
x: number;
|
|
24
25
|
y: number;
|
|
25
26
|
};
|
|
27
|
+
navbarHeight?: number;
|
|
28
|
+
tabbarHeight?: number;
|
|
26
29
|
}
|
|
27
30
|
export declare const defaultFabProps: () => {
|
|
28
31
|
itemList: () => never[];
|
|
@@ -34,6 +37,14 @@ export declare const defaultFabProps: () => {
|
|
|
34
37
|
gapX: number;
|
|
35
38
|
gapY: number;
|
|
36
39
|
};
|
|
40
|
+
export interface FabSlots {
|
|
41
|
+
default?(props: {
|
|
42
|
+
visible: boolean;
|
|
43
|
+
}): any;
|
|
44
|
+
list?(props: {
|
|
45
|
+
onItemClick: (item: FabItem, index: number) => void;
|
|
46
|
+
}): any;
|
|
47
|
+
}
|
|
37
48
|
export interface FabEmits {
|
|
38
49
|
(e: 'click', event: any): void;
|
|
39
50
|
(e: 'select', item: FabItem, index: number): void;
|
|
@@ -48,4 +59,12 @@ export interface FabItem {
|
|
|
48
59
|
background?: string;
|
|
49
60
|
icon?: string;
|
|
50
61
|
iconFamily?: string;
|
|
62
|
+
[key: PropertyKey]: any;
|
|
63
|
+
}
|
|
64
|
+
export interface FabContext {
|
|
65
|
+
hideName?: boolean;
|
|
66
|
+
visible?: boolean;
|
|
67
|
+
isLeft?: boolean;
|
|
68
|
+
onItemClick: (item: FabItem, index: number) => void;
|
|
51
69
|
}
|
|
70
|
+
export declare const fabContextSymbol: unique symbol;
|
package/components/fab/common.js
CHANGED
package/components/fab/fab.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type FabProps, FabItem } from './common';
|
|
2
|
-
declare
|
|
1
|
+
import { type FabProps, type FabSlots, type FabItem } from './common';
|
|
2
|
+
declare function __VLS_template(): Readonly<FabSlots> & FabSlots;
|
|
3
|
+
declare const __VLS_component: import("vue").DefineComponent<FabProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
3
4
|
click: (event: any) => any;
|
|
4
5
|
select: (item: FabItem, index: number) => any;
|
|
5
6
|
"update:offset": (offset: {
|
|
@@ -23,4 +24,10 @@ declare const _default: import("vue").DefineComponent<FabProps, {}, {}, {}, {},
|
|
|
23
24
|
gapX: number;
|
|
24
25
|
gapY: number;
|
|
25
26
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
26
28
|
export default _default;
|
|
29
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
30
|
+
new (): {
|
|
31
|
+
$slots: S;
|
|
32
|
+
};
|
|
33
|
+
};
|
package/components/fab/fab.vue
CHANGED
|
@@ -15,50 +15,52 @@
|
|
|
15
15
|
@touchcancel="onTouchEnd"
|
|
16
16
|
@mousedown="onMouseDown"
|
|
17
17
|
>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
<sar-fab-item
|
|
19
|
+
is-entry
|
|
20
|
+
:color="color"
|
|
21
|
+
:background="background"
|
|
22
|
+
@click="onItemEntryClick"
|
|
23
|
+
>
|
|
24
|
+
<slot :visible="visible">
|
|
25
|
+
<sar-icon :family="iconFamily || 'sari'" :name="entryIcon" />
|
|
26
|
+
</slot>
|
|
27
|
+
</sar-fab-item>
|
|
23
28
|
|
|
24
29
|
<view
|
|
25
30
|
:class="contentClass"
|
|
26
31
|
:style="contentStyle"
|
|
27
32
|
@transitionend="onTransitionEnd"
|
|
28
33
|
>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
>
|
|
44
|
-
<sar-icon :family="item.iconFamily" :name="item.icon" />
|
|
45
|
-
</view>
|
|
46
|
-
</view>
|
|
34
|
+
<slot name="list" :on-item-click="onItemClick">
|
|
35
|
+
<sar-fab-item
|
|
36
|
+
v-for="(item, index) in itemList"
|
|
37
|
+
:key="index"
|
|
38
|
+
:index="index"
|
|
39
|
+
:name="item.name"
|
|
40
|
+
:color="item.color"
|
|
41
|
+
:background="item.background"
|
|
42
|
+
:icon="item.icon"
|
|
43
|
+
:icon-family="item.iconFamily"
|
|
44
|
+
:item="item"
|
|
45
|
+
/>
|
|
46
|
+
</slot>
|
|
47
47
|
</view>
|
|
48
48
|
</view>
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script>
|
|
52
52
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
53
|
-
import { computed, reactive, ref, toRef } from "vue";
|
|
53
|
+
import { computed, provide, reactive, ref, toRef } from "vue";
|
|
54
54
|
import { classNames, stringifyStyle, createBem, isNullish } from "../../utils";
|
|
55
55
|
import {
|
|
56
|
-
defaultFabProps
|
|
56
|
+
defaultFabProps,
|
|
57
|
+
fabContextSymbol
|
|
57
58
|
} from "./common";
|
|
58
59
|
import { useTransition, useZIndex } from "../../use";
|
|
59
60
|
import SarIcon from "../icon/icon.vue";
|
|
60
61
|
import SarOverlay from "../overlay/overlay.vue";
|
|
61
62
|
import { useFloatingBubble } from "../floating-bubble/useFloatingBubble";
|
|
63
|
+
import SarFabItem from "../fab-item/fab-item.vue";
|
|
62
64
|
/**
|
|
63
65
|
* @property {string} rootClass 组件根元素类名,默认值:-。
|
|
64
66
|
* @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
|
|
@@ -69,6 +71,7 @@ import { useFloatingBubble } from "../floating-bubble/useFloatingBubble";
|
|
|
69
71
|
* @property {string} color 设置按钮图标的颜色,默认值:-。
|
|
70
72
|
* @property {string} background 设置按钮的背景色,默认值:-。
|
|
71
73
|
* @property {string} icon 设置入口按钮的图标,默认值:-。
|
|
74
|
+
* @property {string} visibleIcon 设置弹出扩展按钮时的入口按钮的图标,默认值:-。
|
|
72
75
|
* @property {string} iconFamily 设置入口按钮的图标族,默认值:-。
|
|
73
76
|
* @property {FabItem[]} itemList 设置扩展按钮,默认值:[]。
|
|
74
77
|
* @property {boolean} hideName 是否隐藏按钮名称,默认值:false。
|
|
@@ -76,10 +79,12 @@ import { useFloatingBubble } from "../floating-bubble/useFloatingBubble";
|
|
|
76
79
|
* @property {number} duration 扩展按钮显隐动画时长,单位 ms,默认值:150。
|
|
77
80
|
* @property {boolean} draggable 是否可拖拽,默认值:false。
|
|
78
81
|
* @property {'x' | 'y' | 'both' | 'none'} axis 允许拖拽的方向轴,默认值:'y'。
|
|
79
|
-
* @property {'x' | 'y'} magnet
|
|
80
|
-
* @property {number} gapX 悬浮按钮与窗口左右两边的最小间距,单位为 px
|
|
81
|
-
* @property {number} gapY 悬浮按钮与窗口上下两边的最小间距,单位为 px
|
|
82
|
-
* @property {{ x: number; y: number }} offset
|
|
82
|
+
* @property {'x' | 'y'} magnet 吸附到指定轴最近的一边,在拖拽时使用,默认值:-。
|
|
83
|
+
* @property {number} gapX 悬浮按钮与窗口左右两边的最小间距,单位为 px,在拖拽时使用,默认值:24。
|
|
84
|
+
* @property {number} gapY 悬浮按钮与窗口上下两边的最小间距,单位为 px,在拖拽时使用,默认值:24。
|
|
85
|
+
* @property {{ x: number; y: number }} offset 控制悬浮按钮的位置,在拖拽时使用,默认值:-。
|
|
86
|
+
* @property {number} navbarHeight 自定义顶部导航栏的高度,在拖拽时使用,默认值:0。
|
|
87
|
+
* @property {number} tabbarHeight 自定义底部标签栏的高度,在拖拽时使用,默认值:0。
|
|
83
88
|
* @event {(event: any) => void} click 点击入口按钮时触发
|
|
84
89
|
* @event {(item: FabItem, index: number) => void} select 点击扩展按钮时触发
|
|
85
90
|
* @event {(offset: { x: number; y: number }) => void} update 因用户拖拽导致位置改变时触发
|
|
@@ -88,6 +93,7 @@ export default _defineComponent({
|
|
|
88
93
|
components: {
|
|
89
94
|
SarIcon,
|
|
90
95
|
SarOverlay,
|
|
96
|
+
SarFabItem,
|
|
91
97
|
},
|
|
92
98
|
...{
|
|
93
99
|
options: {
|
|
@@ -106,6 +112,7 @@ export default _defineComponent({
|
|
|
106
112
|
color: { type: String, required: false },
|
|
107
113
|
background: { type: String, required: false },
|
|
108
114
|
icon: { type: String, required: false },
|
|
115
|
+
visibleIcon: { type: String, required: false },
|
|
109
116
|
iconFamily: { type: String, required: false },
|
|
110
117
|
itemList: { type: Array, required: false },
|
|
111
118
|
hideName: { type: Boolean, required: false },
|
|
@@ -116,7 +123,9 @@ export default _defineComponent({
|
|
|
116
123
|
magnet: { type: String, required: false },
|
|
117
124
|
gapX: { type: Number, required: false },
|
|
118
125
|
gapY: { type: Number, required: false },
|
|
119
|
-
offset: { type: Object, required: false }
|
|
126
|
+
offset: { type: Object, required: false },
|
|
127
|
+
navbarHeight: { type: Number, required: false },
|
|
128
|
+
tabbarHeight: { type: Number, required: false }
|
|
120
129
|
}, defaultFabProps()),
|
|
121
130
|
emits: ["click", "select", "update:offset"],
|
|
122
131
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -133,18 +142,18 @@ export default _defineComponent({
|
|
|
133
142
|
prefix: bem.m("zoom-")
|
|
134
143
|
})
|
|
135
144
|
);
|
|
145
|
+
const entryIcon = computed(() => {
|
|
146
|
+
return visible.value ? props.visibleIcon || "close" : props.icon || "plus";
|
|
147
|
+
});
|
|
136
148
|
const onItemEntryClick = (event) => {
|
|
137
149
|
if (stopBubbling.value) return;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
increaseZIndex();
|
|
142
|
-
}
|
|
150
|
+
visible.value = !visible.value;
|
|
151
|
+
if (visible.value) {
|
|
152
|
+
increaseZIndex();
|
|
143
153
|
}
|
|
144
154
|
emit("click", event);
|
|
145
155
|
};
|
|
146
156
|
const onItemClick = (item, index) => {
|
|
147
|
-
if (stopBubbling.value) return;
|
|
148
157
|
visible.value = false;
|
|
149
158
|
emit("select", item, index);
|
|
150
159
|
};
|
|
@@ -164,7 +173,8 @@ export default _defineComponent({
|
|
|
164
173
|
bubbleId,
|
|
165
174
|
stopBubbling,
|
|
166
175
|
windowWidth,
|
|
167
|
-
windowHeight
|
|
176
|
+
windowHeight,
|
|
177
|
+
windowTop
|
|
168
178
|
} = useFloatingBubble(props, emit, {
|
|
169
179
|
disabled: visible
|
|
170
180
|
});
|
|
@@ -174,12 +184,20 @@ export default _defineComponent({
|
|
|
174
184
|
const isLeft = computed(() => {
|
|
175
185
|
return props.draggable ? position.value.x > windowWidth / 2 ? false : true : !isNullish(props.left);
|
|
176
186
|
});
|
|
187
|
+
provide(
|
|
188
|
+
fabContextSymbol,
|
|
189
|
+
reactive({
|
|
190
|
+
hideName: toRef(() => props.hideName),
|
|
191
|
+
isLeft,
|
|
192
|
+
visible,
|
|
193
|
+
onItemClick
|
|
194
|
+
})
|
|
195
|
+
);
|
|
177
196
|
const fabClass = computed(() => {
|
|
178
197
|
return classNames(
|
|
179
198
|
bem.b(),
|
|
180
199
|
bem.m(isTop.value ? "top" : "bottom"),
|
|
181
200
|
bem.m(isLeft.value ? "left" : "right"),
|
|
182
|
-
bem.m("visible", visible.value),
|
|
183
201
|
bem.m("animated", animated.value),
|
|
184
202
|
bem.m("initialized", initialized.value),
|
|
185
203
|
bem.m("draggable", props.draggable),
|
|
@@ -191,6 +209,7 @@ export default _defineComponent({
|
|
|
191
209
|
return stringifyStyle(props.rootStyle, {
|
|
192
210
|
zIndex: visible.value ? zIndex.value : null,
|
|
193
211
|
...props.draggable ? {
|
|
212
|
+
top: `${windowTop}px`,
|
|
194
213
|
transform: `translate3d(${position.value.x}px, ${position.value.y}px, 0)`
|
|
195
214
|
} : {
|
|
196
215
|
top: props.top,
|
|
@@ -200,15 +219,6 @@ export default _defineComponent({
|
|
|
200
219
|
}
|
|
201
220
|
});
|
|
202
221
|
});
|
|
203
|
-
const itemEntryClass = computed(() => {
|
|
204
|
-
return classNames(bem.e("item"), bem.em("item", "entry"));
|
|
205
|
-
});
|
|
206
|
-
const itemEntryBtnStyle = computed(() => {
|
|
207
|
-
return stringifyStyle({
|
|
208
|
-
color: props.color,
|
|
209
|
-
background: props.background
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
222
|
const contentClass = computed(() => {
|
|
213
223
|
return classNames(bem.e("content"), transitionClass.value);
|
|
214
224
|
});
|
|
@@ -219,12 +229,7 @@ export default _defineComponent({
|
|
|
219
229
|
transformOrigin: `${isTop.value ? "top" : "bottom"} ${isLeft.value ? "left" : "right"}`
|
|
220
230
|
});
|
|
221
231
|
});
|
|
222
|
-
const
|
|
223
|
-
return classNames(bem.e("item"));
|
|
224
|
-
});
|
|
225
|
-
const __returned__ = { props, emit, bem, visible, zIndex, increaseZIndex, realVisible, transitionClass, onTransitionEnd, onItemEntryClick, onItemClick, onOverlayClick, onTouchStart, onTouchMove, onTouchEnd, onMouseDown, position, initialized, animated, bubbleId, stopBubbling, windowWidth, windowHeight, isTop, isLeft, fabClass, fabStyle, itemEntryClass, itemEntryBtnStyle, contentClass, contentStyle, itemClass, get stringifyStyle() {
|
|
226
|
-
return stringifyStyle;
|
|
227
|
-
}, SarIcon, SarOverlay };
|
|
232
|
+
const __returned__ = { props, emit, bem, visible, zIndex, increaseZIndex, realVisible, transitionClass, onTransitionEnd, entryIcon, onItemEntryClick, onItemClick, onOverlayClick, onTouchStart, onTouchMove, onTouchEnd, onMouseDown, position, initialized, animated, bubbleId, stopBubbling, windowWidth, windowHeight, windowTop, isTop, isLeft, fabClass, fabStyle, contentClass, contentStyle, SarIcon, SarOverlay, SarFabItem };
|
|
228
233
|
return __returned__;
|
|
229
234
|
}
|
|
230
235
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { FabProps, FabEmits, FabItem } from './common';
|
|
1
|
+
export type { FabProps, FabSlots, FabEmits, FabItem } from './common';
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
right: var(--sar-fab-right);
|
|
8
8
|
bottom: var(--sar-fab-bottom);
|
|
9
9
|
z-index: var(--sar-fab-z-index);
|
|
10
|
+
opacity: 0;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
@include e(content) {
|
|
13
14
|
@include universal;
|
|
14
15
|
position: absolute;
|
|
15
|
-
gap: var(--sar-fab-item-gap);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@include m(draggable) {
|
|
@@ -38,45 +38,6 @@
|
|
|
38
38
|
opacity var(--sar-fab-duration) ease-out;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
@include e(item) {
|
|
42
|
-
@include universal;
|
|
43
|
-
flex-direction: row;
|
|
44
|
-
align-items: center;
|
|
45
|
-
gap: var(--sar-fab-item-name-gap);
|
|
46
|
-
cursor: pointer;
|
|
47
|
-
|
|
48
|
-
&:active {
|
|
49
|
-
opacity: var(--sar-fab-item-active-opacity);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@include m(entry) {
|
|
53
|
-
@include e(item-btn) {
|
|
54
|
-
transition: transform var(--sar-fab-duration);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@include e(item-name) {
|
|
60
|
-
@include universal;
|
|
61
|
-
font-size: var(--sar-fab-item-name-font-size);
|
|
62
|
-
color: var(--sar-fab-item-name-color);
|
|
63
|
-
white-space: nowrap;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@include e(item-btn) {
|
|
67
|
-
@include universal;
|
|
68
|
-
flex: none;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
align-items: center;
|
|
71
|
-
width: var(--sar-fab-item-btn-size);
|
|
72
|
-
height: var(--sar-fab-item-btn-size);
|
|
73
|
-
border-radius: var(--sar-rounded-full);
|
|
74
|
-
font-size: var(--sar-fab-item-btn-font-size);
|
|
75
|
-
color: var(--sar-fab-item-btn-color);
|
|
76
|
-
background-color: var(--sar-fab-item-btn-bg);
|
|
77
|
-
box-shadow: var(--sar-fab-item-btn-box-shadow);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
41
|
@include m(top) {
|
|
81
42
|
@include e(content) {
|
|
82
43
|
top: calc(100% + var(--sar-fab-item-gap));
|
|
@@ -93,10 +54,6 @@
|
|
|
93
54
|
@include e(content) {
|
|
94
55
|
left: 0;
|
|
95
56
|
}
|
|
96
|
-
|
|
97
|
-
@include e(item) {
|
|
98
|
-
flex-direction: row-reverse;
|
|
99
|
-
}
|
|
100
57
|
}
|
|
101
58
|
|
|
102
59
|
@include m(right) {
|
|
@@ -105,16 +62,6 @@
|
|
|
105
62
|
}
|
|
106
63
|
}
|
|
107
64
|
|
|
108
|
-
@include m(visible) {
|
|
109
|
-
@include e(item) {
|
|
110
|
-
@include m(entry) {
|
|
111
|
-
@include e(item-btn) {
|
|
112
|
-
transform: rotate(45deg);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
65
|
@include m(initialized) {
|
|
119
66
|
opacity: 1;
|
|
120
67
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
import { type FabItem } from '../fab/common';
|
|
3
|
+
export interface FabItemProps {
|
|
4
|
+
rootStyle?: StyleValue;
|
|
5
|
+
rootClass?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
background?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
iconFamily?: string;
|
|
11
|
+
isEntry?: boolean;
|
|
12
|
+
index?: number;
|
|
13
|
+
item?: FabItem;
|
|
14
|
+
}
|
|
15
|
+
export declare const defaultFabItemProps: {};
|
|
16
|
+
export interface FabItemSlots {
|
|
17
|
+
default?(props: Record<string, never>): any;
|
|
18
|
+
}
|
|
19
|
+
export interface FabItemEmits {
|
|
20
|
+
(e: 'click', event: any): void;
|
|
21
|
+
}
|
|
22
|
+
export interface FabItemExpose {
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultFabItemProps = {};
|