sard-uniapp 1.25.4 → 1.25.6
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 +25 -0
- package/components/accordion/accordion.vue +1 -1
- package/components/accordion-item/accordion-item.vue +1 -1
- package/components/action-sheet/README.md +106 -12
- package/components/action-sheet/action-sheet.d.ts +2 -1
- package/components/action-sheet/action-sheet.vue +42 -12
- package/components/action-sheet/common.d.ts +51 -12
- package/components/action-sheet-agent/action-sheet-agent.d.ts +35 -0
- package/components/action-sheet-agent/action-sheet-agent.vue +194 -0
- package/components/action-sheet-agent/common.d.ts +613 -0
- package/components/action-sheet-agent/common.js +35 -0
- package/components/action-sheet-agent/index.d.ts +1 -0
- package/components/action-sheet-agent/index.js +1 -0
- package/components/alert/alert.vue +1 -1
- package/components/avatar/avatar.vue +1 -1
- package/components/avatar-group/avatar-group.vue +1 -1
- package/components/back-top/back-top.vue +1 -1
- package/components/badge/badge.vue +1 -1
- package/components/button/button.vue +1 -1
- package/components/calendar/calendar.vue +1 -1
- package/components/calendar-input/calendar-input.vue +2 -2
- package/components/calendar-popout/calendar-popout.vue +2 -2
- package/components/card/card.vue +1 -1
- package/components/cascader/README.md +89 -18
- package/components/cascader/cascader.d.ts +6 -6
- package/components/cascader/cascader.vue +201 -182
- package/components/cascader/common.d.ts +32 -7
- package/components/cascader/common.js +39 -23
- package/components/cascader/index.d.ts +1 -1
- package/components/cascader/index.scss +40 -4
- package/components/cascader/useCascaderTabs.d.ts +12 -0
- package/components/cascader/useCascaderTabs.js +59 -0
- package/components/cascader/useCascaderTree.d.ts +66 -0
- package/components/cascader/useCascaderTree.js +194 -0
- package/components/cascader/variables.scss +9 -2
- package/components/cascader-input/README.md +26 -13
- package/components/cascader-input/cascader-input.d.ts +7 -2
- package/components/cascader-input/cascader-input.vue +70 -16
- package/components/cascader-input/common.d.ts +356 -30
- package/components/cascader-popout/README.md +6 -0
- package/components/cascader-popout/cascader-popout.d.ts +5 -1
- package/components/cascader-popout/cascader-popout.vue +16 -4
- package/components/cascader-popout/common.d.ts +169 -17
- package/components/check-icon/check-icon.vue +1 -1
- package/components/checkbox/checkbox.d.ts +2 -2
- package/components/checkbox/checkbox.vue +1 -1
- package/components/checkbox-group/checkbox-group.vue +1 -1
- package/components/checkbox-input/checkbox-input.vue +2 -2
- package/components/checkbox-popout/checkbox-popout.vue +2 -2
- package/components/col/col.vue +1 -1
- package/components/collapse/collapse.vue +1 -1
- package/components/config/index.d.ts +2 -0
- package/components/config/index.js +7 -1
- package/components/cool-icon/cool-icon.vue +1 -1
- package/components/count-down/count-down.vue +1 -1
- package/components/crop-image/crop-image.vue +1 -1
- package/components/crop-image-agent/crop-image-agent.vue +1 -1
- package/components/datetime-picker/datetime-picker.vue +1 -1
- package/components/datetime-picker-input/datetime-picker-input.vue +2 -2
- package/components/datetime-picker-popout/datetime-picker-popout.vue +2 -2
- package/components/datetime-range-picker/datetime-range-picker.vue +1 -1
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +2 -2
- package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +2 -2
- package/components/dialog/dialog.d.ts +1 -1
- package/components/dialog/dialog.vue +7 -7
- package/components/dialog-agent/dialog-agent.d.ts +11 -11
- package/components/dialog-agent/dialog-agent.vue +2 -2
- package/components/divider/divider.vue +1 -1
- package/components/dnd/dnd.vue +1 -1
- package/components/dnd-handle/dnd-handle.vue +1 -1
- package/components/dnd-item/dnd-item.vue +1 -1
- package/components/dropdown/dropdown.vue +1 -1
- package/components/dropdown-item/dropdown-item.vue +7 -2
- package/components/empty/empty.vue +1 -1
- package/components/fab/fab.vue +1 -1
- package/components/fab-item/fab-item.vue +1 -1
- package/components/floating-bubble/floating-bubble.vue +1 -1
- package/components/floating-panel/floating-panel.vue +1 -1
- package/components/form/form.vue +1 -1
- package/components/form-item/form-item.vue +1 -1
- package/components/form-item-plain/form-item-plain.vue +1 -1
- package/components/form-plain/form-plain.vue +1 -1
- package/components/grid/grid.vue +1 -1
- package/components/grid-item/grid-item.vue +2 -2
- package/components/icon/icon.vue +1 -1
- package/components/icon/sari.scss +17 -17
- package/components/image/image.vue +10 -4
- package/components/indexes/indexes.vue +1 -1
- package/components/indexes-anchor/indexes-anchor.vue +1 -1
- package/components/input/input.vue +1 -1
- package/components/keyboard/keyboard.vue +1 -1
- package/components/list/list.vue +1 -1
- package/components/list-item/list-item.vue +1 -1
- package/components/load-more/load-more.vue +1 -1
- package/components/loading/loading.vue +1 -1
- package/components/locale/lang/ar-SA.d.ts +5 -0
- package/components/locale/lang/ar-SA.js +5 -0
- package/components/locale/lang/en-US.d.ts +5 -0
- package/components/locale/lang/en-US.js +5 -0
- package/components/locale/lang/vi-VN.d.ts +5 -0
- package/components/locale/lang/vi-VN.js +5 -0
- package/components/locale/lang/zh-CN.d.ts +5 -0
- package/components/locale/lang/zh-CN.js +5 -0
- package/components/marquee/marquee.vue +1 -1
- package/components/menu/menu.vue +1 -1
- package/components/navbar/navbar.vue +2 -2
- package/components/navbar-item/navbar-item.vue +1 -1
- package/components/navbar-pit/navbar-pit.vue +1 -1
- package/components/notice-bar/notice-bar.vue +1 -1
- package/components/notify/notify.vue +2 -1
- package/components/notify-agent/notify-agent.d.ts +1 -1
- package/components/notify-agent/notify-agent.vue +1 -1
- package/components/overlay/overlay.vue +1 -1
- package/components/pagination/pagination.vue +1 -1
- package/components/password-input/password-input.vue +1 -1
- package/components/picker/picker.vue +1 -1
- package/components/picker-input/picker-input.vue +2 -2
- package/components/picker-item/picker-item.vue +1 -1
- package/components/picker-popout/picker-popout.vue +2 -2
- package/components/popout/popout.d.ts +1 -1
- package/components/popout/popout.vue +1 -1
- package/components/popout-input/popout-input.vue +1 -1
- package/components/popover/popover.vue +3 -2
- package/components/popover-reference/popover-reference.vue +1 -1
- package/components/popup/README.md +1 -0
- package/components/popup/common.d.ts +28 -0
- package/components/popup/index.scss +4 -2
- package/components/popup/popup.d.ts +1 -0
- package/components/popup/popup.vue +82 -16
- package/components/popup/variables.scss +6 -0
- package/components/progress-bar/progress-bar.vue +1 -1
- package/components/progress-circle/progress-circle.vue +1 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +1 -1
- package/components/qrcode/qrcode.vue +6 -5
- package/components/radio/radio.vue +1 -1
- package/components/radio-group/radio-group.vue +1 -1
- package/components/radio-input/radio-input.vue +2 -2
- package/components/radio-popout/radio-popout.vue +2 -2
- package/components/rate/rate.vue +1 -1
- package/components/read-more/read-more.vue +1 -1
- package/components/resize-sensor/index.scss +7 -0
- package/components/resize-sensor/resize-sensor.vue +10 -3
- package/components/result/result.vue +1 -1
- package/components/row/row.vue +1 -1
- package/components/scroll-list/scroll-list.vue +1 -1
- package/components/scroll-spy/scroll-spy.vue +1 -1
- package/components/scroll-spy-anchor/scroll-spy-anchor.vue +1 -1
- package/components/search/search.vue +1 -1
- package/components/segmented/segmented.vue +1 -1
- package/components/segmented-item/segmented-item.vue +1 -1
- package/components/share-sheet/share-sheet.vue +2 -1
- package/components/sidebar/sidebar.vue +1 -1
- package/components/sidebar-item/sidebar-item.vue +1 -1
- package/components/signature/signature.vue +1 -1
- package/components/skeleton/skeleton.vue +1 -1
- package/components/skeleton-avatar/skeleton-avatar.vue +1 -1
- package/components/skeleton-block/skeleton-block.vue +1 -1
- package/components/skeleton-paragraph/skeleton-paragraph.vue +1 -1
- package/components/skeleton-title/skeleton-title.vue +1 -1
- package/components/slider/slider.vue +1 -1
- package/components/space/space.vue +1 -1
- package/components/status-bar/status-bar.vue +1 -1
- package/components/step/step.vue +1 -1
- package/components/stepper/stepper.vue +1 -1
- package/components/steps/steps.vue +1 -1
- package/components/sticky/sticky.vue +1 -1
- package/components/sticky-box/sticky-box.vue +1 -1
- package/components/swipe-action/swipe-action.vue +1 -1
- package/components/swiper-dot/swiper-dot.vue +1 -1
- package/components/switch/switch.vue +1 -1
- package/components/tab/tab.vue +1 -1
- package/components/tabbar/tabbar.vue +1 -1
- package/components/tabbar-item/tabbar-item.vue +1 -1
- package/components/tabbar-pit/tabbar-pit.vue +1 -1
- package/components/table/table.vue +1 -1
- package/components/table-cell/table-cell.vue +1 -1
- package/components/table-fixation/table-fixation.vue +1 -1
- package/components/table-row/table-row.vue +1 -1
- package/components/tabs/tabs.vue +1 -1
- package/components/tag/tag.vue +1 -1
- package/components/timeline/timeline.vue +1 -1
- package/components/timeline-item/timeline-item.vue +1 -1
- package/components/toast/toast.vue +2 -1
- package/components/toast-agent/toast-agent.vue +1 -1
- package/components/tree/README.md +0 -2
- package/components/tree/tree.d.ts +1 -1
- package/components/tree/tree.vue +36 -81
- package/components/tree-node/tree-node.vue +8 -4
- package/components/upload/upload.vue +1 -1
- package/components/upload-preview/upload-preview.vue +1 -1
- package/components/waterfall/waterfall.vue +1 -1
- package/components/waterfall-item/waterfall-item.vue +1 -1
- package/components/waterfall-load/waterfall-load.vue +1 -1
- package/components/watermark/watermark.vue +6 -8
- package/global.d.ts +2 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -1
- package/use/index.d.ts +1 -0
- package/use/index.js +1 -0
- package/use/useLockScroll.d.ts +8 -0
- package/use/useLockScroll.js +88 -0
- package/utils/file.d.ts +6 -0
- package/utils/file.js +33 -11
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/log.d.ts +1 -0
- package/utils/log.js +4 -0
- package/utils/router.js +2 -1
- package/utils/system.d.ts +2 -0
- package/utils/system.js +6 -1
- package/utils/tree.d.ts +18 -0
- package/utils/tree.js +94 -0
- package/components/tree/utils.d.ts +0 -5
- package/components/tree/utils.js +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
## [1.25.6](https://github.com/sutras/sard-uniapp/compare/v1.25.5...v1.25.6) (2025-12-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **ActionSheet:** 动作面板允许命令式使用 ([d17e03a](https://github.com/sutras/sard-uniapp/commit/d17e03abcb1d9179844a2d6856e4b6d34c0c3a0e))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [1.25.5](https://github.com/sutras/sard-uniapp/compare/v1.25.4...v1.25.5) (2025-11-30)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **image:** 修复image动态展示时无法获取正确尺寸的问题 ([432d8b3](https://github.com/sutras/sard-uniapp/commit/432d8b368a3b49e70f79d8c0b3a7ce65969171e5))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **cascader:** 级联组件新增多选功能 ([7f104c1](https://github.com/sutras/sard-uniapp/commit/7f104c1a393509a6b1c97b2565520f9f8e6f8361))
|
|
21
|
+
* 兼容鸿蒙 ([53924d7](https://github.com/sutras/sard-uniapp/commit/53924d7f9562bb4cbe162083998f1485590c629f))
|
|
22
|
+
* 阻止页面滚动(弹窗中的滚动穿透) ([21b43c0](https://github.com/sutras/sard-uniapp/commit/21b43c0924ba1197b217b6fd1020fbd07d5b04fe))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
1
26
|
## [1.25.4](https://github.com/sutras/sard-uniapp/compare/v1.25.3...v1.25.4) (2025-11-22)
|
|
2
27
|
|
|
3
28
|
|
|
@@ -28,7 +28,7 @@ export default _defineComponent({
|
|
|
28
28
|
},
|
|
29
29
|
__name: "accordion",
|
|
30
30
|
props: {
|
|
31
|
-
rootStyle: { type:
|
|
31
|
+
rootStyle: { type: null, required: false },
|
|
32
32
|
rootClass: { type: String, required: false },
|
|
33
33
|
modelValue: { type: [Array, String, Number], required: false },
|
|
34
34
|
multiple: { type: Boolean, required: false },
|
|
@@ -46,7 +46,7 @@ export default _defineComponent({
|
|
|
46
46
|
},
|
|
47
47
|
__name: "accordion-item",
|
|
48
48
|
props: {
|
|
49
|
-
rootStyle: { type:
|
|
49
|
+
rootStyle: { type: null, required: false },
|
|
50
50
|
rootClass: { type: String, required: false },
|
|
51
51
|
title: { type: String, required: false },
|
|
52
52
|
value: { type: String, required: false },
|
|
@@ -15,6 +15,8 @@ group:
|
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
17
|
import ActionSheet from 'sard-uniapp/components/action-sheet/action-sheet.vue'
|
|
18
|
+
import ActionSheetAgent from 'sard-uniapp/components/action-sheet-agent/action-sheet-agent.vue'
|
|
19
|
+
import { actionSheet } from 'sard-uniapp'
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
## 代码演示
|
|
@@ -27,7 +29,7 @@ import ActionSheet from 'sard-uniapp/components/action-sheet/action-sheet.vue'
|
|
|
27
29
|
|
|
28
30
|
### 取消按钮
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
设置 `show-cancel` 属性展示取消按钮,或者使用 `cancel` 属性在设置取消按钮文本的同时显示取消按钮。
|
|
31
33
|
|
|
32
34
|
@code('${DEMO_PATH}/action-sheet/demo/Cancel.vue')
|
|
33
35
|
|
|
@@ -43,21 +45,64 @@ import ActionSheet from 'sard-uniapp/components/action-sheet/action-sheet.vue'
|
|
|
43
45
|
|
|
44
46
|
@code('${DEMO_PATH}/action-sheet/demo/Status.vue')
|
|
45
47
|
|
|
48
|
+
### 命令式 <sup>1.25.6+</sup>
|
|
49
|
+
|
|
50
|
+
先在页面放置代理组件。
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<sar-action-sheet-agent />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
接着便可以使用 `actionSheet` 方法显示动作面板。
|
|
57
|
+
|
|
58
|
+
@code('${DEMO_PATH}/action-sheet/demo/Imperative.vue')
|
|
59
|
+
|
|
46
60
|
## API
|
|
47
61
|
|
|
48
62
|
### ActionSheetProps
|
|
49
63
|
|
|
50
|
-
| 属性
|
|
51
|
-
|
|
|
52
|
-
| root-class
|
|
53
|
-
| root-style
|
|
54
|
-
| description
|
|
55
|
-
| item-list
|
|
56
|
-
| cancel
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
64
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
65
|
+
| ------------------------------ | -------------------------------------------------------------------- | ---------------------- | ------ |
|
|
66
|
+
| root-class | 组件根元素类名 | string | - |
|
|
67
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
68
|
+
| description | 动作面板描述说明 | string | - |
|
|
69
|
+
| item-list | 面板项列表 | ActionSheetItem[] | [] |
|
|
70
|
+
| show-cancel <sup>1.25.6+</sup> | 是否显示取消按钮 | boolean | false |
|
|
71
|
+
| cancel | 自定义取消按钮文字 | string | - |
|
|
72
|
+
| visible | 是否显示动作面板 | boolean | false |
|
|
73
|
+
| overlay-closable | 点击遮罩后是否关闭 | boolean | true |
|
|
74
|
+
| before-close | 关闭前的回调,返回 `false` 或 `rejected` 状态的 `Promise` 可阻止关闭 | ActionSheetBeforeClose | - |
|
|
75
|
+
| duration | 显隐动画时长,单位 ms | number | 300 |
|
|
76
|
+
|
|
77
|
+
#### ActionSheetBeforeClose
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
type ActionSheetBeforeClose =
|
|
81
|
+
| ((
|
|
82
|
+
type: 'close' | 'cancel',
|
|
83
|
+
loading: {
|
|
84
|
+
readonly cancel: boolean
|
|
85
|
+
readonly select: boolean
|
|
86
|
+
readonly close: boolean
|
|
87
|
+
},
|
|
88
|
+
) => any | Promise<any>)
|
|
89
|
+
| ((
|
|
90
|
+
type: 'select',
|
|
91
|
+
item: ActionSheetItem,
|
|
92
|
+
index: number,
|
|
93
|
+
loading: {
|
|
94
|
+
readonly cancel: boolean
|
|
95
|
+
readonly select: boolean
|
|
96
|
+
readonly close: boolean
|
|
97
|
+
},
|
|
98
|
+
) => any | Promise<any>)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- 当点击动作项时,`type` 为 `select`;
|
|
102
|
+
- 当点击取消按钮时,`type` 为 `cancel`;
|
|
103
|
+
- 当点击遮罩时,`type` 为 `close`。
|
|
104
|
+
|
|
105
|
+
`loading` 表示当前哪个按钮处于异步关闭状态。
|
|
61
106
|
|
|
62
107
|
### ActionSheetItem
|
|
63
108
|
|
|
@@ -87,6 +132,55 @@ import ActionSheet from 'sard-uniapp/components/action-sheet/action-sheet.vue'
|
|
|
87
132
|
| after-leave <sup>1.22.1+</sup> | 退场动画结束时触发 | () => void |
|
|
88
133
|
| leave-cancelled <sup>1.22.1+</sup> | 退场动画取消时触发 | () => void |
|
|
89
134
|
|
|
135
|
+
### ActionSheetAgentProps / ActionSheetOptions <sup>1.25.6+</sup>
|
|
136
|
+
|
|
137
|
+
继承 [`ActionSheetProps`](#ActionSheetProps) 并有以下额外属性。
|
|
138
|
+
|
|
139
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
140
|
+
| ---------------- | --------------------------- | ---------------------------------------------- | ------------- |
|
|
141
|
+
| id | 动作面板组件的 id | string | 'actionSheet' |
|
|
142
|
+
| onClose | 点击遮罩时调用 | () => void |
|
|
143
|
+
| onCancel | 点击取消按钮时调用 | () => void |
|
|
144
|
+
| onSelect | 点击动作项时调用 | (item: ActionSheetItem, index: number) => void |
|
|
145
|
+
| onVisibleHook | 入场/退场动画状态改变时调用 | (name: TransitionHookName) => void |
|
|
146
|
+
| onBeforeEnter | 入场动画开始前调用 | () => void |
|
|
147
|
+
| onEnter | 入场动画开始时调用 | () => void |
|
|
148
|
+
| onAfterEnter | 入场动画结束时调用 | () => void |
|
|
149
|
+
| onEnterCancelled | 入场动画取消时调用 | () => void |
|
|
150
|
+
| onBeforeLeave | 退场动画开始前调用 | () => void |
|
|
151
|
+
| onLeave | 退场动画开始时调用 | () => void |
|
|
152
|
+
| onAfterLeave | 退场动画结束时调用 | () => void |
|
|
153
|
+
| onLeaveCancelled | 退场动画取消时调用 | () => void |
|
|
154
|
+
|
|
155
|
+
### ActionSheetAgentEmits <sup>1.25.6+</sup>
|
|
156
|
+
|
|
157
|
+
继承 [`ActionSheetEmits`](#ActionSheetEmits)。
|
|
158
|
+
|
|
159
|
+
### 命令式方法 <sup>1.25.6+</sup>
|
|
160
|
+
|
|
161
|
+
| 名称 | 描述 | 类型 |
|
|
162
|
+
| ----------- | ------------------------------ | ---------------------------- |
|
|
163
|
+
| actionSheet | 显示动作面板 | ActionSheetFunction |
|
|
164
|
+
| hide | 隐藏指定 `id` 的命令式动作面板 | (id = 'actionSheet') => void |
|
|
165
|
+
| hideAll | 隐藏所有命令式动作面板 | () => void |
|
|
166
|
+
|
|
167
|
+
### ActionSheetFunction <sup>1.25.6+</sup>
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
type ActionSheetFunction = ActionSheetSimpleShowFunction & {
|
|
171
|
+
hide: (id?: string) => void
|
|
172
|
+
hideAll: () => void
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### ActionSheetSimpleShowFunction <sup>1.25.6+</sup>
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
interface ActionSheetSimpleShowFunction {
|
|
180
|
+
(options: ActionSheetOptions): void
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
90
184
|
## 主题定制
|
|
91
185
|
|
|
92
186
|
### CSS 变量
|
|
@@ -14,6 +14,7 @@ declare const _default: import("vue").DefineComponent<ActionSheetProps, {}, {},
|
|
|
14
14
|
duration: number;
|
|
15
15
|
overlayClosable: boolean;
|
|
16
16
|
itemList: ActionSheetItem[];
|
|
17
|
-
|
|
17
|
+
showCancel: boolean;
|
|
18
|
+
beforeClose: import("./common").ActionSheetBeforeClose;
|
|
18
19
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
20
|
export default _default;
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
</view>
|
|
38
38
|
</view>
|
|
39
39
|
</view>
|
|
40
|
-
<template v-if="
|
|
40
|
+
<template v-if="mergedShowCancel">
|
|
41
41
|
<view :class="bem.e('gap')"></view>
|
|
42
42
|
<view :class="bem.e('cancel')" @click="onCancel">
|
|
43
|
-
{{ cancel }}
|
|
43
|
+
{{ cancel || t('cancel') }}
|
|
44
44
|
</view>
|
|
45
45
|
</template>
|
|
46
46
|
</view>
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
<script>
|
|
51
51
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
52
|
-
import { computed, ref, watch } from "vue";
|
|
52
|
+
import { computed, reactive, readonly, ref, watch } from "vue";
|
|
53
53
|
import {
|
|
54
54
|
classNames,
|
|
55
55
|
stringifyStyle,
|
|
@@ -63,15 +63,17 @@ import SarLoading from "../loading/loading.vue";
|
|
|
63
63
|
import {
|
|
64
64
|
defaultActionSheetProps
|
|
65
65
|
} from "./common";
|
|
66
|
+
import { useTranslate } from "../locale";
|
|
66
67
|
/**
|
|
67
68
|
* @property {string} rootClass 组件根元素类名,默认值:-。
|
|
68
69
|
* @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
|
|
69
70
|
* @property {string} description 动作面板描述说明,默认值:-。
|
|
70
71
|
* @property {ActionSheetItem[]} itemList 面板项列表,默认值:[]。
|
|
71
|
-
* @property {
|
|
72
|
+
* @property {boolean} showCancel 是否显示取消按钮,默认值:false。
|
|
73
|
+
* @property {string} cancel 自定义取消按钮文字,默认值:-。
|
|
72
74
|
* @property {boolean} visible 是否显示动作面板,默认值:false。
|
|
73
75
|
* @property {boolean} overlayClosable 点击遮罩后是否关闭,默认值:true。
|
|
74
|
-
* @property {
|
|
76
|
+
* @property {ActionSheetBeforeClose} beforeClose 关闭前的回调,返回 `false` 或 `rejected` 状态的 `Promise` 可阻止关闭,默认值:-。
|
|
75
77
|
* @property {number} duration 显隐动画时长,单位 ms,默认值:300。
|
|
76
78
|
* @event {(visible: boolean) => void} update 动作面板显隐时触发
|
|
77
79
|
* @event {() => void} close 点击遮罩时触发
|
|
@@ -100,11 +102,12 @@ export default _defineComponent({
|
|
|
100
102
|
},
|
|
101
103
|
__name: "action-sheet",
|
|
102
104
|
props: _mergeDefaults({
|
|
103
|
-
rootStyle: { type:
|
|
105
|
+
rootStyle: { type: null, required: false },
|
|
104
106
|
rootClass: { type: String, required: false },
|
|
105
107
|
description: { type: String, required: false },
|
|
106
108
|
itemList: { type: Array, required: false },
|
|
107
109
|
cancel: { type: String, required: false },
|
|
110
|
+
showCancel: { type: Boolean, required: false },
|
|
108
111
|
visible: { type: Boolean, required: false },
|
|
109
112
|
overlayClosable: { type: Boolean, required: false },
|
|
110
113
|
beforeClose: { type: Function, required: false },
|
|
@@ -116,6 +119,7 @@ export default _defineComponent({
|
|
|
116
119
|
const props = __props;
|
|
117
120
|
const emit = __emit;
|
|
118
121
|
const bem = createBem("action-sheet");
|
|
122
|
+
const { t } = useTranslate("actionSheet");
|
|
119
123
|
const innerVisible = ref(props.visible);
|
|
120
124
|
watch(
|
|
121
125
|
() => props.visible,
|
|
@@ -123,9 +127,35 @@ export default _defineComponent({
|
|
|
123
127
|
innerVisible.value = props.visible;
|
|
124
128
|
}
|
|
125
129
|
);
|
|
126
|
-
const
|
|
130
|
+
const mergedShowCancel = computed(() => props.showCancel || props.cancel);
|
|
131
|
+
const loading = reactive({
|
|
132
|
+
cancel: false,
|
|
133
|
+
select: false,
|
|
134
|
+
close: false
|
|
135
|
+
});
|
|
136
|
+
const readonlyLoading = readonly(loading);
|
|
137
|
+
const asyncSet = new Set();
|
|
138
|
+
watch(
|
|
139
|
+
innerVisible,
|
|
140
|
+
() => {
|
|
141
|
+
if (innerVisible.value === false) {
|
|
142
|
+
asyncSet.forEach((obj) => {
|
|
143
|
+
obj.valid = false;
|
|
144
|
+
});
|
|
145
|
+
Object.assign(loading, {
|
|
146
|
+
cancel: false,
|
|
147
|
+
select: false,
|
|
148
|
+
close: false
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
flush: "sync"
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
function perhapsClose(type, item, index) {
|
|
127
157
|
if (isFunction(props.beforeClose)) {
|
|
128
|
-
const result = props.beforeClose(type);
|
|
158
|
+
const result = type === "select" ? props.beforeClose(type, item, index, readonlyLoading) : props.beforeClose(type, readonlyLoading);
|
|
129
159
|
if (isObject(result) && isFunction(result.then)) {
|
|
130
160
|
return result.then(() => {
|
|
131
161
|
innerVisible.value = false;
|
|
@@ -137,17 +167,17 @@ export default _defineComponent({
|
|
|
137
167
|
}
|
|
138
168
|
innerVisible.value = false;
|
|
139
169
|
emit("update:visible", false);
|
|
140
|
-
}
|
|
170
|
+
}
|
|
141
171
|
const onOverlayClick = () => {
|
|
142
|
-
emit("close");
|
|
143
172
|
if (props.overlayClosable) {
|
|
173
|
+
emit("close");
|
|
144
174
|
perhapsClose("close");
|
|
145
175
|
}
|
|
146
176
|
};
|
|
147
177
|
const onSelect = (item, index) => {
|
|
148
178
|
if (!item.disabled && !item.loading) {
|
|
149
179
|
emit("select", item, index);
|
|
150
|
-
perhapsClose("select");
|
|
180
|
+
perhapsClose("select", item, index);
|
|
151
181
|
}
|
|
152
182
|
};
|
|
153
183
|
const onCancel = () => {
|
|
@@ -168,7 +198,7 @@ export default _defineComponent({
|
|
|
168
198
|
const actionSheetStyle = computed(() => {
|
|
169
199
|
return stringifyStyle(props.rootStyle);
|
|
170
200
|
});
|
|
171
|
-
const __returned__ = { props, emit, bem, innerVisible, perhapsClose, onOverlayClick, onSelect, onCancel, onVisibleHook, actionSheetClass, actionSheetStyle, get classNames() {
|
|
201
|
+
const __returned__ = { props, emit, bem, t, innerVisible, mergedShowCancel, loading, readonlyLoading, asyncSet, perhapsClose, onOverlayClick, onSelect, onCancel, onVisibleHook, actionSheetClass, actionSheetStyle, get classNames() {
|
|
172
202
|
return classNames;
|
|
173
203
|
}, get stringifyStyle() {
|
|
174
204
|
return stringifyStyle;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import { type StyleValue } from 'vue';
|
|
2
2
|
import { type TransitionHookEmits } from '../popup/common';
|
|
3
|
+
export type ActionSheetBeforeClose = ((type: 'close' | 'cancel', loading: {
|
|
4
|
+
readonly cancel: boolean;
|
|
5
|
+
readonly select: boolean;
|
|
6
|
+
readonly close: boolean;
|
|
7
|
+
}) => any | Promise<any>) & ((type: 'select', item: ActionSheetItem, index: number, loading: {
|
|
8
|
+
readonly cancel: boolean;
|
|
9
|
+
readonly select: boolean;
|
|
10
|
+
readonly close: boolean;
|
|
11
|
+
}) => any | Promise<any>);
|
|
3
12
|
export interface ActionSheetProps {
|
|
4
13
|
rootStyle?: StyleValue;
|
|
5
14
|
rootClass?: string;
|
|
6
15
|
description?: string;
|
|
7
16
|
itemList?: ActionSheetItem[];
|
|
8
17
|
cancel?: string;
|
|
18
|
+
showCancel?: boolean;
|
|
9
19
|
visible?: boolean;
|
|
10
20
|
overlayClosable?: boolean;
|
|
11
|
-
beforeClose?:
|
|
21
|
+
beforeClose?: ActionSheetBeforeClose;
|
|
12
22
|
duration?: number;
|
|
13
23
|
}
|
|
14
24
|
export declare const defaultActionSheetProps: {
|
|
@@ -18,9 +28,10 @@ export declare const defaultActionSheetProps: {
|
|
|
18
28
|
description: string;
|
|
19
29
|
itemList: ActionSheetItem[];
|
|
20
30
|
cancel: string;
|
|
31
|
+
showCancel: boolean;
|
|
21
32
|
visible: boolean;
|
|
22
33
|
overlayClosable: boolean;
|
|
23
|
-
beforeClose:
|
|
34
|
+
beforeClose: ActionSheetBeforeClose;
|
|
24
35
|
duration: number;
|
|
25
36
|
}) => string | false | import("vue").CSSProperties | StyleValue[]) | null) | undefined;
|
|
26
37
|
rootClass?: (string | ((props: {
|
|
@@ -29,9 +40,10 @@ export declare const defaultActionSheetProps: {
|
|
|
29
40
|
description: string;
|
|
30
41
|
itemList: ActionSheetItem[];
|
|
31
42
|
cancel: string;
|
|
43
|
+
showCancel: boolean;
|
|
32
44
|
visible: boolean;
|
|
33
45
|
overlayClosable: boolean;
|
|
34
|
-
beforeClose:
|
|
46
|
+
beforeClose: ActionSheetBeforeClose;
|
|
35
47
|
duration: number;
|
|
36
48
|
}) => string)) | undefined;
|
|
37
49
|
description?: (string | ((props: {
|
|
@@ -40,9 +52,10 @@ export declare const defaultActionSheetProps: {
|
|
|
40
52
|
description: string;
|
|
41
53
|
itemList: ActionSheetItem[];
|
|
42
54
|
cancel: string;
|
|
55
|
+
showCancel: boolean;
|
|
43
56
|
visible: boolean;
|
|
44
57
|
overlayClosable: boolean;
|
|
45
|
-
beforeClose:
|
|
58
|
+
beforeClose: ActionSheetBeforeClose;
|
|
46
59
|
duration: number;
|
|
47
60
|
}) => string)) | undefined;
|
|
48
61
|
itemList?: ((props: {
|
|
@@ -51,9 +64,10 @@ export declare const defaultActionSheetProps: {
|
|
|
51
64
|
description: string;
|
|
52
65
|
itemList: ActionSheetItem[];
|
|
53
66
|
cancel: string;
|
|
67
|
+
showCancel: boolean;
|
|
54
68
|
visible: boolean;
|
|
55
69
|
overlayClosable: boolean;
|
|
56
|
-
beforeClose:
|
|
70
|
+
beforeClose: ActionSheetBeforeClose;
|
|
57
71
|
duration: number;
|
|
58
72
|
}) => ActionSheetItem[]) | undefined;
|
|
59
73
|
cancel?: (string | ((props: {
|
|
@@ -62,20 +76,34 @@ export declare const defaultActionSheetProps: {
|
|
|
62
76
|
description: string;
|
|
63
77
|
itemList: ActionSheetItem[];
|
|
64
78
|
cancel: string;
|
|
79
|
+
showCancel: boolean;
|
|
65
80
|
visible: boolean;
|
|
66
81
|
overlayClosable: boolean;
|
|
67
|
-
beforeClose:
|
|
82
|
+
beforeClose: ActionSheetBeforeClose;
|
|
68
83
|
duration: number;
|
|
69
84
|
}) => string)) | undefined;
|
|
85
|
+
showCancel?: (boolean | ((props: {
|
|
86
|
+
rootStyle: StyleValue;
|
|
87
|
+
rootClass: string;
|
|
88
|
+
description: string;
|
|
89
|
+
itemList: ActionSheetItem[];
|
|
90
|
+
cancel: string;
|
|
91
|
+
showCancel: boolean;
|
|
92
|
+
visible: boolean;
|
|
93
|
+
overlayClosable: boolean;
|
|
94
|
+
beforeClose: ActionSheetBeforeClose;
|
|
95
|
+
duration: number;
|
|
96
|
+
}) => boolean)) | undefined;
|
|
70
97
|
visible?: (boolean | ((props: {
|
|
71
98
|
rootStyle: StyleValue;
|
|
72
99
|
rootClass: string;
|
|
73
100
|
description: string;
|
|
74
101
|
itemList: ActionSheetItem[];
|
|
75
102
|
cancel: string;
|
|
103
|
+
showCancel: boolean;
|
|
76
104
|
visible: boolean;
|
|
77
105
|
overlayClosable: boolean;
|
|
78
|
-
beforeClose:
|
|
106
|
+
beforeClose: ActionSheetBeforeClose;
|
|
79
107
|
duration: number;
|
|
80
108
|
}) => boolean)) | undefined;
|
|
81
109
|
overlayClosable?: (boolean | ((props: {
|
|
@@ -84,31 +112,42 @@ export declare const defaultActionSheetProps: {
|
|
|
84
112
|
description: string;
|
|
85
113
|
itemList: ActionSheetItem[];
|
|
86
114
|
cancel: string;
|
|
115
|
+
showCancel: boolean;
|
|
87
116
|
visible: boolean;
|
|
88
117
|
overlayClosable: boolean;
|
|
89
|
-
beforeClose:
|
|
118
|
+
beforeClose: ActionSheetBeforeClose;
|
|
90
119
|
duration: number;
|
|
91
120
|
}) => boolean)) | undefined;
|
|
92
|
-
beforeClose?: (
|
|
121
|
+
beforeClose?: (ActionSheetBeforeClose | ((props: {
|
|
93
122
|
rootStyle: StyleValue;
|
|
94
123
|
rootClass: string;
|
|
95
124
|
description: string;
|
|
96
125
|
itemList: ActionSheetItem[];
|
|
97
126
|
cancel: string;
|
|
127
|
+
showCancel: boolean;
|
|
98
128
|
visible: boolean;
|
|
99
129
|
overlayClosable: boolean;
|
|
100
|
-
beforeClose:
|
|
130
|
+
beforeClose: ActionSheetBeforeClose;
|
|
101
131
|
duration: number;
|
|
102
|
-
}) => (type: "close" | "cancel"
|
|
132
|
+
}) => ((type: "close" | "cancel", loading: {
|
|
133
|
+
readonly cancel: boolean;
|
|
134
|
+
readonly select: boolean;
|
|
135
|
+
readonly close: boolean;
|
|
136
|
+
}) => any | Promise<any>) & ((type: "select", item: ActionSheetItem, index: number, loading: {
|
|
137
|
+
readonly cancel: boolean;
|
|
138
|
+
readonly select: boolean;
|
|
139
|
+
readonly close: boolean;
|
|
140
|
+
}) => any | Promise<any>))) | undefined;
|
|
103
141
|
duration?: (number | ((props: {
|
|
104
142
|
rootStyle: StyleValue;
|
|
105
143
|
rootClass: string;
|
|
106
144
|
description: string;
|
|
107
145
|
itemList: ActionSheetItem[];
|
|
108
146
|
cancel: string;
|
|
147
|
+
showCancel: boolean;
|
|
109
148
|
visible: boolean;
|
|
110
149
|
overlayClosable: boolean;
|
|
111
|
-
beforeClose:
|
|
150
|
+
beforeClose: ActionSheetBeforeClose;
|
|
112
151
|
duration: number;
|
|
113
152
|
}) => number)) | undefined;
|
|
114
153
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ActionSheetAgentProps } from './common';
|
|
2
|
+
import { type TransitionHookName } from '../../use';
|
|
3
|
+
import { type ActionSheetItem } from '../action-sheet/common';
|
|
4
|
+
declare const _default: import("vue").DefineComponent<ActionSheetAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
} & {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<ActionSheetAgentProps> & Readonly<{
|
|
9
|
+
[x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
cancel: string;
|
|
12
|
+
rootStyle: string | false | import("vue").CSSProperties | import("vue").StyleValue[] | null;
|
|
13
|
+
rootClass: string;
|
|
14
|
+
onSelect: (item: ActionSheetItem, index: number) => void;
|
|
15
|
+
description: string;
|
|
16
|
+
visible: boolean;
|
|
17
|
+
id: string;
|
|
18
|
+
duration: number;
|
|
19
|
+
overlayClosable: boolean;
|
|
20
|
+
itemList: ActionSheetItem[];
|
|
21
|
+
showCancel: boolean;
|
|
22
|
+
beforeClose: import("../action-sheet/common").ActionSheetBeforeClose;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
onCancel: () => void;
|
|
25
|
+
onVisibleHook: (name: TransitionHookName) => void;
|
|
26
|
+
onBeforeEnter: () => void;
|
|
27
|
+
onEnter: () => void;
|
|
28
|
+
onAfterEnter: () => void;
|
|
29
|
+
onEnterCancelled: () => void;
|
|
30
|
+
onBeforeLeave: () => void;
|
|
31
|
+
onLeave: () => void;
|
|
32
|
+
onAfterLeave: () => void;
|
|
33
|
+
onLeaveCancelled: () => void;
|
|
34
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
35
|
+
export default _default;
|