sard-uniapp 1.30.1 → 1.30.3
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 +13 -0
- package/components/accordion/accordion.vue +1 -1
- package/components/accordion-item/accordion-item.vue +1 -1
- package/components/action-sheet/README.md +84 -45
- package/components/action-sheet/action-sheet.d.ts +15 -4
- package/components/action-sheet/action-sheet.vue +53 -45
- package/components/action-sheet/common.d.ts +14 -9
- package/components/action-sheet/context.d.ts +16 -0
- package/components/action-sheet/context.js +55 -0
- package/components/action-sheet/index.d.ts +2 -1
- package/components/action-sheet-agent/action-sheet-agent.d.ts +17 -6
- package/components/action-sheet-agent/action-sheet-agent.vue +25 -7
- package/components/action-sheet-agent/common.d.ts +4 -2
- package/components/action-sheet-item/action-sheet-item.d.ts +17 -0
- package/components/action-sheet-item/action-sheet-item.vue +85 -0
- package/components/action-sheet-item/common.d.ts +18 -0
- package/components/action-sheet-item/common.js +1 -0
- package/components/action-sheet-item/index.d.ts +1 -0
- package/components/action-sheet-item/index.js +1 -0
- package/components/alert/alert.d.ts +1 -1
- 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/barcode/barcode.vue +1 -1
- package/components/button/button.d.ts +4 -3
- package/components/button/button.vue +13 -3
- package/components/button/common.d.ts +3 -0
- package/components/calendar/calendar.vue +1 -1
- package/components/calendar-input/calendar-input.d.ts +2 -2
- 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/cascader.vue +1 -1
- package/components/cascader/useCascaderTree.d.ts +1 -1
- package/components/cascader-input/cascader-input.d.ts +2 -2
- package/components/cascader-input/cascader-input.vue +2 -2
- package/components/cascader-popout/cascader-popout.vue +2 -2
- 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.d.ts +1 -1
- package/components/checkbox-group/checkbox-group.vue +1 -1
- package/components/checkbox-input/checkbox-input.d.ts +2 -2
- package/components/checkbox-input/checkbox-input.vue +2 -2
- package/components/checkbox-popout/checkbox-popout.d.ts +1 -1
- 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/color-picker/color-picker.d.ts +1 -1
- package/components/color-picker/color-picker.vue +1 -1
- package/components/color-picker-input/color-picker-input.d.ts +2 -2
- package/components/color-picker-input/color-picker-input.vue +2 -2
- package/components/color-picker-popout/color-picker-popout.d.ts +1 -1
- package/components/color-picker-popout/color-picker-popout.vue +2 -2
- package/components/compact/compact.vue +1 -1
- package/components/config/index.d.ts +4 -0
- 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/date-strip/date-strip.vue +1 -1
- package/components/datetime-picker/datetime-picker.vue +1 -1
- package/components/datetime-picker-input/datetime-picker-input.d.ts +2 -2
- 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.d.ts +2 -2
- 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/README.md +33 -40
- package/components/dialog/common.d.ts +1 -0
- package/components/dialog/common.js +1 -0
- package/components/dialog/dialog.d.ts +1 -0
- package/components/dialog/dialog.vue +6 -4
- package/components/dialog-agent/common.d.ts +3 -1
- package/components/dialog-agent/dialog-agent.d.ts +10 -2
- package/components/dialog-agent/dialog-agent.vue +8 -3
- 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 +1 -1
- package/components/ellipsis/ellipsis.vue +1 -1
- package/components/empty/empty.vue +1 -1
- package/components/fab/fab.d.ts +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/README.md +20 -19
- package/components/form/common.js +4 -2
- package/components/form/form.vue +2 -2
- package/components/form-item/form-item.d.ts +2 -2
- package/components/form-item/form-item.vue +12 -11
- package/components/form-item/useFormItem.js +11 -4
- package/components/form-item-plain/form-item-plain.d.ts +2 -2
- package/components/form-item-plain/form-item-plain.vue +12 -11
- package/components/form-plain/form-plain.vue +2 -2
- package/components/grid/common.d.ts +1 -1
- package/components/grid/common.js +1 -1
- package/components/grid/grid.vue +3 -3
- package/components/grid-item/grid-item.vue +4 -4
- package/components/icon/icon.d.ts +1 -1
- package/components/icon/icon.vue +1 -1
- package/components/image/image.vue +1 -1
- package/components/indexes/indexes.vue +1 -1
- package/components/indexes-anchor/indexes-anchor.vue +1 -1
- package/components/input/input.d.ts +1 -1
- package/components/input/input.vue +1 -1
- package/components/input-base/input-base.d.ts +1 -1
- package/components/input-base/input-base.vue +1 -1
- package/components/keyboard/keyboard.vue +1 -1
- package/components/keyboard-popout/keyboard-popout.vue +2 -2
- 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.d.ts +1 -1
- package/components/loading/loading.vue +1 -1
- package/components/locale/lang/ar-SA.d.ts +3 -0
- package/components/locale/lang/ar-SA.js +3 -0
- package/components/locale/lang/en-US.d.ts +3 -0
- package/components/locale/lang/en-US.js +3 -0
- package/components/locale/lang/vi-VN.d.ts +3 -0
- package/components/locale/lang/vi-VN.js +3 -0
- package/components/locale/lang/zh-CN.d.ts +3 -0
- package/components/locale/lang/zh-CN.js +3 -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.d.ts +1 -1
- package/components/notice-bar/notice-bar.vue +1 -1
- package/components/notify/README.md +4 -0
- package/components/notify/common.d.ts +1 -0
- package/components/notify/notify.d.ts +2 -1
- package/components/notify/notify.vue +12 -6
- package/components/notify-agent/common.d.ts +3 -1
- package/components/notify-agent/index.d.ts +1 -1
- package/components/notify-agent/notify-agent.d.ts +11 -3
- package/components/notify-agent/notify-agent.vue +6 -2
- package/components/overlay/overlay.vue +1 -1
- package/components/pagination/pagination.vue +1 -1
- package/components/password-input/password-input.d.ts +1 -1
- package/components/password-input/password-input.vue +1 -1
- package/components/picker/picker.vue +1 -1
- package/components/picker-input/common.d.ts +29 -29
- package/components/picker-input/picker-input.d.ts +2 -2
- 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.vue +1 -1
- package/components/popout-input/popout-input.d.ts +1 -1
- package/components/popout-input/popout-input.vue +1 -1
- package/components/popover/popover.vue +1 -1
- package/components/popover-reference/popover-reference.vue +1 -1
- package/components/popup/README.md +66 -2
- package/components/popup/popup.vue +1 -1
- package/components/popup-agent/common.d.ts +28 -0
- package/components/popup-agent/common.js +36 -0
- package/components/popup-agent/index.d.ts +1 -0
- package/components/popup-agent/index.js +1 -0
- package/components/popup-agent/popup-agent.d.ts +44 -0
- package/components/popup-agent/popup-agent.vue +160 -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.d.ts +1 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +1 -1
- package/components/puzzle-verify/puzzle-verify.d.ts +1 -1
- package/components/puzzle-verify/puzzle-verify.vue +1 -1
- package/components/qrcode/qrcode.d.ts +1 -1
- package/components/qrcode/qrcode.vue +1 -1
- package/components/radio/radio.vue +1 -1
- package/components/radio-group/radio-group.d.ts +1 -1
- package/components/radio-group/radio-group.vue +1 -1
- package/components/radio-input/radio-input.d.ts +2 -2
- package/components/radio-input/radio-input.vue +2 -2
- package/components/radio-popout/radio-popout.d.ts +1 -1
- 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/resize-sensor.vue +1 -1
- package/components/result/result.vue +1 -1
- package/components/rotate-verify/rotate-verify.d.ts +1 -1
- package/components/rotate-verify/rotate-verify.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.d.ts +1 -1
- package/components/search/search.vue +1 -1
- package/components/segmented/segmented.d.ts +1 -1
- package/components/segmented/segmented.vue +1 -1
- package/components/segmented-item/segmented-item.vue +1 -1
- package/components/select/select.d.ts +1 -1
- package/components/select/select.vue +1 -1
- package/components/select-input/select-input.d.ts +3 -3
- package/components/select-input/select-input.vue +2 -2
- package/components/select-option/select-option.vue +1 -1
- package/components/select-option-group/select-option-group.vue +1 -1
- package/components/select-popout/select-popout.d.ts +1 -1
- package/components/select-popout/select-popout.vue +5 -5
- package/components/share-sheet/README.md +128 -28
- package/components/share-sheet/common.d.ts +15 -10
- package/components/share-sheet/context.d.ts +17 -0
- package/components/share-sheet/context.js +58 -0
- package/components/share-sheet/index.d.ts +2 -1
- package/components/share-sheet/index.scss +0 -18
- package/components/share-sheet/share-sheet.d.ts +18 -4
- package/components/share-sheet/share-sheet.vue +73 -72
- package/components/share-sheet-agent/common.d.ts +31 -0
- package/components/share-sheet-agent/common.js +36 -0
- package/components/share-sheet-agent/index.d.ts +1 -0
- package/components/share-sheet-agent/index.js +1 -0
- package/components/share-sheet-agent/share-sheet-agent.d.ts +53 -0
- package/components/share-sheet-agent/share-sheet-agent.vue +181 -0
- package/components/share-sheet-item/common.d.ts +21 -0
- package/components/share-sheet-item/common.js +1 -0
- package/components/share-sheet-item/index.d.ts +1 -0
- package/components/share-sheet-item/index.js +1 -0
- package/components/share-sheet-item/share-sheet-item.d.ts +16 -0
- package/components/share-sheet-item/share-sheet-item.vue +92 -0
- package/components/share-sheet-row/common.d.ts +14 -0
- package/components/share-sheet-row/common.js +1 -0
- package/components/share-sheet-row/index.d.ts +1 -0
- package/components/share-sheet-row/index.js +1 -0
- package/components/share-sheet-row/index.scss +21 -0
- package/components/share-sheet-row/share-sheet-row.d.ts +13 -0
- package/components/share-sheet-row/share-sheet-row.vue +48 -0
- package/components/sidebar/sidebar.vue +1 -1
- package/components/sidebar-item/sidebar-item.vue +1 -1
- package/components/signature/signature.d.ts +1 -1
- package/components/signature/signature.vue +1 -1
- package/components/skeleton/skeleton.d.ts +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/slide-verify/slide-verify.vue +1 -1
- package/components/slider/slider.d.ts +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.d.ts +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/swipe-action-group/swipe-action-group.vue +1 -1
- package/components/swiper/swiper.vue +3 -3
- package/components/swiper-dot/swiper-dot.vue +1 -1
- package/components/switch/switch.d.ts +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.d.ts +1 -1
- package/components/tag/tag.vue +1 -1
- package/components/textarea-base/textarea-base.d.ts +1 -1
- package/components/textarea-base/textarea-base.vue +1 -1
- package/components/timeline/timeline.vue +1 -1
- package/components/timeline-item/timeline-item.vue +1 -1
- package/components/toast/README.md +43 -18
- package/components/toast/common.d.ts +8 -0
- package/components/toast/toast.d.ts +12 -3
- package/components/toast/toast.vue +37 -10
- package/components/toast-agent/common.d.ts +3 -1
- package/components/toast-agent/toast-agent.d.ts +13 -2
- package/components/toast-agent/toast-agent.vue +17 -2
- package/components/tree/tree.vue +1 -1
- package/components/upload/upload.vue +1 -1
- package/components/upload-preview/upload-preview.d.ts +2 -2
- 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 +1 -1
- package/global.d.ts +5 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/package.json +1 -1
- package/use/index.d.ts +1 -0
- package/use/index.js +1 -0
- package/use/reactiveComputed.d.ts +3 -0
- package/use/reactiveComputed.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## <small>1.30.3 (2026-05-23)</small>
|
|
3
|
+
|
|
4
|
+
* Code Refactoring: 优化代理组件代码 ([1e2c4ce](https://github.com/sutras/sard-uniapp/commit/1e2c4ce))
|
|
5
|
+
* Bug Fixes: 新增back-press属性,允许自定义用户的返回操作 ([5bf1425](https://github.com/sutras/sard-uniapp/commit/5bf1425))
|
|
6
|
+
* Features: 新增scope属性和getAuthorize事件支持 ([a863c8f](https://github.com/sutras/sard-uniapp/commit/a863c8f))
|
|
7
|
+
* Features: 新增小程序关注生活号和授权相关事件支持 ([5f2329a](https://github.com/sutras/sard-uniapp/commit/5f2329a))
|
|
8
|
+
* Features: 新增弹窗、动作面板、分享面板等组件的插槽与命令式调用能力,优化Toast组件 ([68e87fb](https://github.com/sutras/sard-uniapp/commit/68e87fb))
|
|
9
|
+
|
|
10
|
+
## <small>1.30.2 (2026-05-14)</small>
|
|
11
|
+
|
|
12
|
+
* Bug Fixes: 修复表单项布尔类型属性的覆盖问题 ([903a2c4](https://github.com/sutras/sard-uniapp/commit/903a2c4))
|
|
13
|
+
|
|
2
14
|
## <small>1.30.1 (2026-05-10)</small>
|
|
3
15
|
|
|
16
|
+
* Bug Fixes: 修复小程序端字数限制问题 ([a0c6923](https://github.com/sutras/sard-uniapp/commit/a0c6923))
|
|
4
17
|
* Bug Fixes: 修复弹窗中使用时滚动位置不正确问题 ([30fb9d9](https://github.com/sutras/sard-uniapp/commit/30fb9d9))
|
|
5
18
|
* Bug Fixes: 透传常用属性 ([cc21393](https://github.com/sutras/sard-uniapp/commit/cc21393))
|
|
6
19
|
|
|
@@ -29,7 +29,7 @@ export default _defineComponent({
|
|
|
29
29
|
},
|
|
30
30
|
__name: "accordion",
|
|
31
31
|
props: _mergeDefaults({
|
|
32
|
-
rootStyle: { type: null, required: false },
|
|
32
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
33
33
|
rootClass: { type: String, required: false },
|
|
34
34
|
modelValue: { type: [Array, String, Number], required: false },
|
|
35
35
|
multiple: { type: Boolean, required: false },
|
|
@@ -53,7 +53,7 @@ export default _defineComponent({
|
|
|
53
53
|
},
|
|
54
54
|
__name: "accordion-item",
|
|
55
55
|
props: {
|
|
56
|
-
rootStyle: { type: null, required: false },
|
|
56
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
57
57
|
rootClass: { type: String, required: false },
|
|
58
58
|
title: { type: String, required: false },
|
|
59
59
|
value: { type: String, required: false },
|
|
@@ -54,8 +54,19 @@ import { actionSheet } from 'sard-uniapp'
|
|
|
54
54
|
|
|
55
55
|
接着便可以使用 `actionSheet` 方法显示动作面板。
|
|
56
56
|
|
|
57
|
+
如果需要显示多个命令式动作面板,可以给代理组件设置 `id`,在调用 `actionSheet` 方法时传入相同的 `id` 来使用对应的代理组件。
|
|
58
|
+
|
|
57
59
|
<<< @demo/action-sheet/demo/Imperative.vue
|
|
58
60
|
|
|
61
|
+
### 插槽 <sup>1.30.3+</sup>
|
|
62
|
+
|
|
63
|
+
可以使用插槽自定义内容,包括描述、取消按钮等。
|
|
64
|
+
也可以使用默认插槽自定义动作项,此时需要使用 `action-sheet-item` 组件来构建动作项的布局。
|
|
65
|
+
|
|
66
|
+
可使用 `action-sheet` 或者 `action-sheet-agent` 组件的插槽自定义内容。
|
|
67
|
+
|
|
68
|
+
<<< @demo/action-sheet/demo/Slot.vue
|
|
69
|
+
|
|
59
70
|
## API
|
|
60
71
|
|
|
61
72
|
### ActionSheetProps
|
|
@@ -65,7 +76,7 @@ import { actionSheet } from 'sard-uniapp'
|
|
|
65
76
|
| root-class | 组件根元素类名 | string | - |
|
|
66
77
|
| root-style | 组件根元素样式 | StyleValue | - |
|
|
67
78
|
| description | 动作面板描述说明 | string | - |
|
|
68
|
-
| item-list | 面板项列表 |
|
|
79
|
+
| item-list | 面板项列表 | ActionSheetItemProps[] | [] |
|
|
69
80
|
| show-cancel <sup>1.25.6+</sup> | 是否显示取消按钮 | boolean | false |
|
|
70
81
|
| cancel | 自定义取消按钮文字 | string | - |
|
|
71
82
|
| visible | 是否显示动作面板 | boolean | false |
|
|
@@ -87,7 +98,7 @@ type ActionSheetBeforeClose =
|
|
|
87
98
|
) => any | Promise<any>)
|
|
88
99
|
| ((
|
|
89
100
|
type: 'select',
|
|
90
|
-
item:
|
|
101
|
+
item: ActionSheetItemProps,
|
|
91
102
|
index: number,
|
|
92
103
|
loading: {
|
|
93
104
|
readonly cancel: boolean
|
|
@@ -103,53 +114,81 @@ type ActionSheetBeforeClose =
|
|
|
103
114
|
|
|
104
115
|
`loading` 表示当前哪个按钮处于异步关闭状态。
|
|
105
116
|
|
|
106
|
-
###
|
|
117
|
+
### ActionSheetSlots <sup>1.30.3+</sup>
|
|
107
118
|
|
|
108
|
-
|
|
|
109
|
-
| ----------- | -------------- |
|
|
110
|
-
|
|
|
111
|
-
| description |
|
|
112
|
-
|
|
|
113
|
-
| disabled | 禁用状态 | boolean | false |
|
|
114
|
-
| loading | 加载状态 | boolean | false |
|
|
119
|
+
| 插槽 | 描述 | 属性 |
|
|
120
|
+
| ----------- | -------------- | ---- |
|
|
121
|
+
| default | 自定义默认内容 | - |
|
|
122
|
+
| description | 自定义描述 | - |
|
|
123
|
+
| cancel | 自定义取消按钮 | - |
|
|
115
124
|
|
|
116
125
|
### ActionSheetEmits
|
|
117
126
|
|
|
118
|
-
| 事件 | 描述 | 类型
|
|
119
|
-
| ---------------------------------- | --------------------------- |
|
|
120
|
-
| update:visible | 动作面板显隐时触发 | `(visible: boolean) => void`
|
|
121
|
-
| close | 点击遮罩时触发 | `() => void`
|
|
122
|
-
| cancel | 点击取消按钮时触发 | `() => void`
|
|
123
|
-
| select | 点击动作按钮时触发 | `(item:
|
|
124
|
-
| visible-hook <sup>1.22.1+</sup> | 入场/退场动画状态改变时触发 | `(name: TransitionHookName) => void`
|
|
125
|
-
| before-enter <sup>1.22.1+</sup> | 入场动画开始前触发 | `() => void`
|
|
126
|
-
| enter <sup>1.22.1+</sup> | 入场动画开始时触发 | `() => void`
|
|
127
|
-
| after-enter <sup>1.22.1+</sup> | 入场动画结束时触发 | `() => void`
|
|
128
|
-
| enter-cancelled <sup>1.22.1+</sup> | 入场动画取消时触发 | `() => void`
|
|
129
|
-
| before-leave <sup>1.22.1+</sup> | 退场动画开始前触发 | `() => void`
|
|
130
|
-
| leave <sup>1.22.1+</sup> | 退场动画开始时触发 | `() => void`
|
|
131
|
-
| after-leave <sup>1.22.1+</sup> | 退场动画结束时触发 | `() => void`
|
|
132
|
-
| leave-cancelled <sup>1.22.1+</sup> | 退场动画取消时触发 | `() => void`
|
|
127
|
+
| 事件 | 描述 | 类型 |
|
|
128
|
+
| ---------------------------------- | --------------------------- | ----------------------------------------------------- |
|
|
129
|
+
| update:visible | 动作面板显隐时触发 | `(visible: boolean) => void` |
|
|
130
|
+
| close | 点击遮罩时触发 | `() => void` |
|
|
131
|
+
| cancel | 点击取消按钮时触发 | `() => void` |
|
|
132
|
+
| select | 点击动作按钮时触发 | `(item: ActionSheetItemProps, index: number) => void` |
|
|
133
|
+
| visible-hook <sup>1.22.1+</sup> | 入场/退场动画状态改变时触发 | `(name: TransitionHookName) => void` |
|
|
134
|
+
| before-enter <sup>1.22.1+</sup> | 入场动画开始前触发 | `() => void` |
|
|
135
|
+
| enter <sup>1.22.1+</sup> | 入场动画开始时触发 | `() => void` |
|
|
136
|
+
| after-enter <sup>1.22.1+</sup> | 入场动画结束时触发 | `() => void` |
|
|
137
|
+
| enter-cancelled <sup>1.22.1+</sup> | 入场动画取消时触发 | `() => void` |
|
|
138
|
+
| before-leave <sup>1.22.1+</sup> | 退场动画开始前触发 | `() => void` |
|
|
139
|
+
| leave <sup>1.22.1+</sup> | 退场动画开始时触发 | `() => void` |
|
|
140
|
+
| after-leave <sup>1.22.1+</sup> | 退场动画结束时触发 | `() => void` |
|
|
141
|
+
| leave-cancelled <sup>1.22.1+</sup> | 退场动画取消时触发 | `() => void` |
|
|
142
|
+
|
|
143
|
+
### ActionSheetItemProps <sup>1.30.3+</sup>
|
|
144
|
+
|
|
145
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
146
|
+
| ------------------------ | -------------------------------------- | ------- | ------ |
|
|
147
|
+
| name | 动作标签,同 `label`,建议使用 `label` | string | - |
|
|
148
|
+
| label <sup>1.30.3+</sup> | 动作标签 | string | - |
|
|
149
|
+
| value | 动作的值 | any | - |
|
|
150
|
+
| description | 动作的描述说明 | string | - |
|
|
151
|
+
| color | 字体颜色 | string | - |
|
|
152
|
+
| disabled | 禁用状态 | boolean | false |
|
|
153
|
+
| loading | 加载状态 | boolean | false |
|
|
154
|
+
|
|
155
|
+
### ActionSheetItemSlots <sup>1.30.3+</sup>
|
|
156
|
+
|
|
157
|
+
| 插槽 | 描述 | 属性 |
|
|
158
|
+
| ----------- | -------------- | ---- |
|
|
159
|
+
| default | 自定义默认内容 | - |
|
|
160
|
+
| label | 自定义标签 | - |
|
|
161
|
+
| description | 自定义描述 | - |
|
|
162
|
+
|
|
163
|
+
### ActionSheetItemEmits <sup>1.30.3+</sup>
|
|
164
|
+
|
|
165
|
+
| 事件 | 描述 | 类型 |
|
|
166
|
+
| ----- | ---------------- | ------------ |
|
|
167
|
+
| click | 点击动作项时触发 | `() => void` |
|
|
133
168
|
|
|
134
169
|
### ActionSheetAgentProps / ActionSheetOptions <sup>1.25.6+</sup>
|
|
135
170
|
|
|
136
171
|
继承 [`ActionSheetProps`](#ActionSheetProps) 并有以下额外属性。
|
|
137
172
|
|
|
138
|
-
| 属性 | 描述 | 类型
|
|
139
|
-
| ---------------- | --------------------------- |
|
|
140
|
-
| id | 动作面板组件的 id | string
|
|
141
|
-
| onClose | 点击遮罩时调用 | `() => void`
|
|
142
|
-
| onCancel | 点击取消按钮时调用 | `() => void`
|
|
143
|
-
| onSelect | 点击动作项时调用 | `(item:
|
|
144
|
-
| onVisibleHook | 入场/退场动画状态改变时调用 | `(name: TransitionHookName) => void`
|
|
145
|
-
| onBeforeEnter | 入场动画开始前调用 | `() => void`
|
|
146
|
-
| onEnter | 入场动画开始时调用 | `() => void`
|
|
147
|
-
| onAfterEnter | 入场动画结束时调用 | `() => void`
|
|
148
|
-
| onEnterCancelled | 入场动画取消时调用 | `() => void`
|
|
149
|
-
| onBeforeLeave | 退场动画开始前调用 | `() => void`
|
|
150
|
-
| onLeave | 退场动画开始时调用 | `() => void`
|
|
151
|
-
| onAfterLeave | 退场动画结束时调用 | `() => void`
|
|
152
|
-
| onLeaveCancelled | 退场动画取消时调用 | `() => void`
|
|
173
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
174
|
+
| ---------------- | --------------------------- | ----------------------------------------------------- | ------------- |
|
|
175
|
+
| id | 动作面板组件的 id | string | 'actionSheet' |
|
|
176
|
+
| onClose | 点击遮罩时调用 | `() => void` |
|
|
177
|
+
| onCancel | 点击取消按钮时调用 | `() => void` |
|
|
178
|
+
| onSelect | 点击动作项时调用 | `(item: ActionSheetItemProps, index: number) => void` |
|
|
179
|
+
| onVisibleHook | 入场/退场动画状态改变时调用 | `(name: TransitionHookName) => void` |
|
|
180
|
+
| onBeforeEnter | 入场动画开始前调用 | `() => void` |
|
|
181
|
+
| onEnter | 入场动画开始时调用 | `() => void` |
|
|
182
|
+
| onAfterEnter | 入场动画结束时调用 | `() => void` |
|
|
183
|
+
| onEnterCancelled | 入场动画取消时调用 | `() => void` |
|
|
184
|
+
| onBeforeLeave | 退场动画开始前调用 | `() => void` |
|
|
185
|
+
| onLeave | 退场动画开始时调用 | `() => void` |
|
|
186
|
+
| onAfterLeave | 退场动画结束时调用 | `() => void` |
|
|
187
|
+
| onLeaveCancelled | 退场动画取消时调用 | `() => void` |
|
|
188
|
+
|
|
189
|
+
### ActionSheetAgentSlots <sup>1.30.3+</sup>
|
|
190
|
+
|
|
191
|
+
继承 [`ActionSheetSlots`](#ActionSheetSlots)。
|
|
153
192
|
|
|
154
193
|
### ActionSheetAgentEmits <sup>1.25.6+</sup>
|
|
155
194
|
|
|
@@ -157,11 +196,11 @@ type ActionSheetBeforeClose =
|
|
|
157
196
|
|
|
158
197
|
### 命令式方法 <sup>1.25.6+</sup>
|
|
159
198
|
|
|
160
|
-
| 名称
|
|
161
|
-
|
|
|
162
|
-
| actionSheet
|
|
163
|
-
| hide
|
|
164
|
-
| hideAll
|
|
199
|
+
| 名称 | 描述 | 类型 |
|
|
200
|
+
| ------------------- | ------------------------------ | ------------------------------ |
|
|
201
|
+
| actionSheet | 显示动作面板 | ActionSheetFunction |
|
|
202
|
+
| actionSheet.hide | 隐藏指定 `id` 的命令式动作面板 | `(id = 'actionSheet') => void` |
|
|
203
|
+
| actionSheet.hideAll | 隐藏所有命令式动作面板 | `() => void` |
|
|
165
204
|
|
|
166
205
|
### ActionSheetFunction <sup>1.25.6+</sup>
|
|
167
206
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
declare
|
|
1
|
+
import { type ActionSheetItemProps, type ActionSheetProps, type ActionSheetSlots } from './common';
|
|
2
|
+
declare function __VLS_template(): Readonly<ActionSheetSlots> & ActionSheetSlots;
|
|
3
|
+
declare const __VLS_component: import("vue").DefineComponent<ActionSheetProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
4
|
[x: string]: any;
|
|
4
5
|
} & {
|
|
5
6
|
[x: string]: any;
|
|
@@ -11,10 +12,20 @@ declare const _default: import("vue").DefineComponent<ActionSheetProps, {}, {},
|
|
|
11
12
|
visible: boolean;
|
|
12
13
|
duration: number;
|
|
13
14
|
overlayClosable: boolean;
|
|
14
|
-
cancel: string;
|
|
15
15
|
description: string;
|
|
16
|
-
|
|
16
|
+
cancel: string;
|
|
17
|
+
itemList: ActionSheetItemProps[];
|
|
17
18
|
showCancel: boolean;
|
|
18
19
|
beforeClose: import("./common").ActionSheetBeforeClose;
|
|
20
|
+
internalDefault: number;
|
|
21
|
+
internalDescription: number;
|
|
22
|
+
internalCancel: number;
|
|
23
|
+
internalContext: import("./context").UseActionSheetReturn;
|
|
19
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
20
26
|
export default _default;
|
|
27
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -9,40 +9,31 @@
|
|
|
9
9
|
@back-press="onBackPress"
|
|
10
10
|
>
|
|
11
11
|
<view :class="actionSheetClass" :style="actionSheetStyle">
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<view
|
|
17
|
-
v-for="(item, i) in itemList"
|
|
18
|
-
:key="i"
|
|
19
|
-
:class="
|
|
20
|
-
classNames(
|
|
21
|
-
bem.e('item'),
|
|
22
|
-
bem.em('item', 'disabled', item.disabled),
|
|
23
|
-
bem.em('item', 'loading', item.loading),
|
|
24
|
-
)
|
|
25
|
-
"
|
|
26
|
-
:style="stringifyStyle({ color: item.color })"
|
|
27
|
-
@click="onSelect(item, i)"
|
|
28
|
-
>
|
|
29
|
-
<template v-if="!item.loading">
|
|
30
|
-
<view :class="bem.e('item-name')">
|
|
31
|
-
{{ item.name }}
|
|
32
|
-
</view>
|
|
33
|
-
<view v-if="item.description" :class="bem.e('item-description')">
|
|
34
|
-
{{ item.description }}
|
|
35
|
-
</view>
|
|
36
|
-
</template>
|
|
37
|
-
<view v-else :class="bem.e('loading')">
|
|
38
|
-
<sar-loading />
|
|
39
|
-
</view>
|
|
12
|
+
<template v-if="showDescription">
|
|
13
|
+
<view :class="bem.e('description')">
|
|
14
|
+
<slot v-if="hasDescriptionSlot" name="description"></slot>
|
|
15
|
+
<template v-else>{{ description }}</template>
|
|
40
16
|
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<view :class="bem.e('content')">
|
|
20
|
+
<template v-if="itemList && itemList.length > 0">
|
|
21
|
+
<sar-action-sheet-item
|
|
22
|
+
v-for="(item, i) in itemList"
|
|
23
|
+
:key="i"
|
|
24
|
+
v-bind="item"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
<slot></slot>
|
|
41
28
|
</view>
|
|
29
|
+
|
|
42
30
|
<template v-if="mergedShowCancel">
|
|
43
31
|
<view :class="bem.e('gap')"></view>
|
|
44
32
|
<view :class="bem.e('cancel')" @click="onCancel">
|
|
45
|
-
|
|
33
|
+
<slot v-if="hasCancelSlot" name="cancel"></slot>
|
|
34
|
+
<template v-else>
|
|
35
|
+
{{ cancel || t('cancel') }}
|
|
36
|
+
</template>
|
|
46
37
|
</view>
|
|
47
38
|
</template>
|
|
48
39
|
</view>
|
|
@@ -50,27 +41,29 @@
|
|
|
50
41
|
</template>
|
|
51
42
|
|
|
52
43
|
<script>
|
|
53
|
-
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
54
|
-
import {
|
|
44
|
+
import { useSlots as _useSlots, mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
45
|
+
import { reactive, readonly, ref, watch, computed } from "vue";
|
|
55
46
|
import {
|
|
56
47
|
classNames,
|
|
57
48
|
stringifyStyle,
|
|
58
49
|
createBem,
|
|
59
50
|
noop,
|
|
60
51
|
isFunction,
|
|
61
|
-
isObject
|
|
52
|
+
isObject,
|
|
53
|
+
isNumber
|
|
62
54
|
} from "../../utils";
|
|
63
55
|
import SarPopup from "../popup/popup.vue";
|
|
64
|
-
import
|
|
56
|
+
import SarActionSheetItem from "../action-sheet-item/action-sheet-item.vue";
|
|
65
57
|
import {
|
|
66
58
|
defaultActionSheetProps
|
|
67
59
|
} from "./common";
|
|
68
60
|
import { useTranslate } from "../locale";
|
|
61
|
+
import { useActionSheet } from "./context";
|
|
69
62
|
/**
|
|
70
63
|
* @property {string} rootClass 组件根元素类名,默认值:-。
|
|
71
64
|
* @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
|
|
72
65
|
* @property {string} description 动作面板描述说明,默认值:-。
|
|
73
|
-
* @property {
|
|
66
|
+
* @property {ActionSheetItemProps[]} itemList 面板项列表,默认值:[]。
|
|
74
67
|
* @property {boolean} showCancel 是否显示取消按钮,默认值:false。
|
|
75
68
|
* @property {string} cancel 自定义取消按钮文字,默认值:-。
|
|
76
69
|
* @property {boolean} visible 是否显示动作面板,默认值:false。
|
|
@@ -80,7 +73,7 @@ import { useTranslate } from "../locale";
|
|
|
80
73
|
* @event {`(visible: boolean) => void`} update 动作面板显隐时触发
|
|
81
74
|
* @event {`() => void`} close 点击遮罩时触发
|
|
82
75
|
* @event {`() => void`} cancel 点击取消按钮时触发
|
|
83
|
-
* @event {`(item:
|
|
76
|
+
* @event {`(item: ActionSheetItemProps, index: number) => void`} select 点击动作按钮时触发
|
|
84
77
|
* @event {`(name: TransitionHookName) => void`} visible-hook 入场/退场动画状态改变时触发
|
|
85
78
|
* @event {`() => void`} before-enter 入场动画开始前触发
|
|
86
79
|
* @event {`() => void`} enter 入场动画开始时触发
|
|
@@ -94,7 +87,7 @@ import { useTranslate } from "../locale";
|
|
|
94
87
|
export default _defineComponent({
|
|
95
88
|
components: {
|
|
96
89
|
SarPopup,
|
|
97
|
-
|
|
90
|
+
SarActionSheetItem,
|
|
98
91
|
},
|
|
99
92
|
...{
|
|
100
93
|
options: {
|
|
@@ -104,7 +97,7 @@ export default _defineComponent({
|
|
|
104
97
|
},
|
|
105
98
|
__name: "action-sheet",
|
|
106
99
|
props: _mergeDefaults({
|
|
107
|
-
rootStyle: { type: null, required: false },
|
|
100
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
108
101
|
rootClass: { type: String, required: false },
|
|
109
102
|
description: { type: String, required: false },
|
|
110
103
|
itemList: { type: Array, required: false },
|
|
@@ -113,15 +106,32 @@ export default _defineComponent({
|
|
|
113
106
|
visible: { type: Boolean, required: false },
|
|
114
107
|
overlayClosable: { type: Boolean, required: false },
|
|
115
108
|
beforeClose: { type: Function, required: false },
|
|
116
|
-
duration: { type: Number, required: false }
|
|
109
|
+
duration: { type: Number, required: false },
|
|
110
|
+
internalDefault: { type: Number, required: false },
|
|
111
|
+
internalDescription: { type: Number, required: false },
|
|
112
|
+
internalCancel: { type: Number, required: false },
|
|
113
|
+
internalContext: { type: Object, required: false }
|
|
117
114
|
}, defaultActionSheetProps()),
|
|
118
115
|
emits: ["update:visible", "close", "cancel", "select", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
|
|
119
116
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
120
117
|
__expose();
|
|
121
118
|
const props = __props;
|
|
119
|
+
const slots = _useSlots();
|
|
122
120
|
const emit = __emit;
|
|
123
121
|
const bem = createBem("action-sheet");
|
|
124
122
|
const { t } = useTranslate("actionSheet");
|
|
123
|
+
const hasCancelSlot = computed(
|
|
124
|
+
() => !!(isNumber(props.internalCancel) ? props.internalCancel : slots.cancel)
|
|
125
|
+
);
|
|
126
|
+
const mergedShowCancel = computed(() => {
|
|
127
|
+
return !!(props.showCancel || props.cancel || hasCancelSlot.value);
|
|
128
|
+
});
|
|
129
|
+
const hasDescriptionSlot = computed(
|
|
130
|
+
() => !!(isNumber(props.internalDescription) ? props.internalDescription : slots.description)
|
|
131
|
+
);
|
|
132
|
+
const showDescription = computed(() => {
|
|
133
|
+
return !!(props.description || hasDescriptionSlot.value);
|
|
134
|
+
});
|
|
125
135
|
const innerVisible = ref(props.visible);
|
|
126
136
|
watch(
|
|
127
137
|
() => props.visible,
|
|
@@ -129,7 +139,6 @@ export default _defineComponent({
|
|
|
129
139
|
innerVisible.value = props.visible;
|
|
130
140
|
}
|
|
131
141
|
);
|
|
132
|
-
const mergedShowCancel = computed(() => props.showCancel || props.cancel);
|
|
133
142
|
const loading = reactive({
|
|
134
143
|
cancel: false,
|
|
135
144
|
select: false,
|
|
@@ -178,6 +187,7 @@ export default _defineComponent({
|
|
|
178
187
|
};
|
|
179
188
|
const onSelect = (item, index) => {
|
|
180
189
|
if (!item.disabled && !item.loading) {
|
|
190
|
+
item = { ...item };
|
|
181
191
|
emit("select", item, index);
|
|
182
192
|
perhapsClose("select", item, index);
|
|
183
193
|
}
|
|
@@ -194,21 +204,19 @@ export default _defineComponent({
|
|
|
194
204
|
innerVisible.value = false;
|
|
195
205
|
emit("update:visible", false);
|
|
196
206
|
};
|
|
207
|
+
const context = props.internalContext || useActionSheet();
|
|
208
|
+
context.setSelectCallback(onSelect);
|
|
197
209
|
const actionSheetClass = computed(() => {
|
|
198
210
|
return classNames(
|
|
199
211
|
bem.b(),
|
|
200
|
-
bem.m("headless", !
|
|
212
|
+
bem.m("headless", !showDescription.value),
|
|
201
213
|
props.rootClass
|
|
202
214
|
);
|
|
203
215
|
});
|
|
204
216
|
const actionSheetStyle = computed(() => {
|
|
205
217
|
return stringifyStyle(props.rootStyle);
|
|
206
218
|
});
|
|
207
|
-
const __returned__ = { props, emit, bem, t,
|
|
208
|
-
return classNames;
|
|
209
|
-
}, get stringifyStyle() {
|
|
210
|
-
return stringifyStyle;
|
|
211
|
-
}, SarPopup, SarLoading };
|
|
219
|
+
const __returned__ = { props, slots, emit, bem, t, hasCancelSlot, mergedShowCancel, hasDescriptionSlot, showDescription, innerVisible, loading, readonlyLoading, asyncSet, perhapsClose, onOverlayClick, onSelect, onCancel, onVisibleHook, onBackPress, context, actionSheetClass, actionSheetStyle, SarPopup, SarActionSheetItem };
|
|
212
220
|
return __returned__;
|
|
213
221
|
}
|
|
214
222
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type StyleValue } from 'vue';
|
|
2
2
|
import { type DefaultProps } from '../config';
|
|
3
3
|
import { type TransitionHookEmits } from '../popup/common';
|
|
4
|
+
import { type ActionSheetItemProps } from '../action-sheet-item';
|
|
5
|
+
import { type UseActionSheetReturn } from './context';
|
|
4
6
|
export type ActionSheetBeforeClose = ((type: 'close' | 'cancel', loading: {
|
|
5
7
|
readonly cancel: boolean;
|
|
6
8
|
readonly select: boolean;
|
|
7
9
|
readonly close: boolean;
|
|
8
|
-
}) => any | Promise<any>) & ((type: 'select', item:
|
|
10
|
+
}) => any | Promise<any>) & ((type: 'select', item: ActionSheetItemProps, index: number, loading: {
|
|
9
11
|
readonly cancel: boolean;
|
|
10
12
|
readonly select: boolean;
|
|
11
13
|
readonly close: boolean;
|
|
@@ -14,25 +16,28 @@ export interface ActionSheetProps {
|
|
|
14
16
|
rootStyle?: StyleValue;
|
|
15
17
|
rootClass?: string;
|
|
16
18
|
description?: string;
|
|
17
|
-
itemList?:
|
|
19
|
+
itemList?: ActionSheetItemProps[];
|
|
18
20
|
cancel?: string;
|
|
19
21
|
showCancel?: boolean;
|
|
20
22
|
visible?: boolean;
|
|
21
23
|
overlayClosable?: boolean;
|
|
22
24
|
beforeClose?: ActionSheetBeforeClose;
|
|
23
25
|
duration?: number;
|
|
26
|
+
internalDefault?: number;
|
|
27
|
+
internalDescription?: number;
|
|
28
|
+
internalCancel?: number;
|
|
29
|
+
internalContext?: UseActionSheetReturn;
|
|
24
30
|
}
|
|
25
31
|
export declare const defaultActionSheetProps: () => DefaultProps<ActionSheetProps>;
|
|
26
32
|
export interface ActionSheetEmits extends TransitionHookEmits {
|
|
27
33
|
(e: 'update:visible', visible: boolean): void;
|
|
28
34
|
(e: 'close'): void;
|
|
29
35
|
(e: 'cancel'): void;
|
|
30
|
-
(e: 'select', item:
|
|
36
|
+
(e: 'select', item: ActionSheetItemProps, index: number): void;
|
|
31
37
|
}
|
|
32
|
-
export interface
|
|
33
|
-
|
|
34
|
-
description?:
|
|
35
|
-
|
|
36
|
-
loading?: boolean;
|
|
37
|
-
disabled?: boolean;
|
|
38
|
+
export interface ActionSheetSlots {
|
|
39
|
+
default?(props?: any): any;
|
|
40
|
+
description?(props?: any): any;
|
|
41
|
+
cancel?(props?: any): any;
|
|
38
42
|
}
|
|
43
|
+
export type { ActionSheetItemProps, ActionSheetItemEmits, ActionSheetItemSlots, } from '../action-sheet-item/common';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type InjectionKey, type Ref } from 'vue';
|
|
2
|
+
import { type ActionSheetItemProps } from '../action-sheet-item/common';
|
|
3
|
+
export interface ActionSheetContext {
|
|
4
|
+
select: (item: ActionSheetItemProps) => void;
|
|
5
|
+
addItem: (item: ActionSheetItemProps) => void;
|
|
6
|
+
removeItem: (item: ActionSheetItemProps) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const actionSheetContextKey: InjectionKey<ActionSheetContext>;
|
|
9
|
+
export interface UseActionSheetReturn {
|
|
10
|
+
items: Ref<ActionSheetItemProps[]>;
|
|
11
|
+
setSelectCallback: (callback: (item: ActionSheetItemProps, index: number) => void) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useActionSheet(): UseActionSheetReturn;
|
|
14
|
+
export declare function useActionSheetItem(item: ActionSheetItemProps): {
|
|
15
|
+
select: () => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { provide, inject, onMounted, onUnmounted, useAttrs, ref, } from 'vue';
|
|
2
|
+
import { reactiveComputed } from '../../use';
|
|
3
|
+
export const actionSheetContextKey = Symbol('ActionSheetContext');
|
|
4
|
+
export function useActionSheet() {
|
|
5
|
+
const items = ref([]);
|
|
6
|
+
let selectCallback = null;
|
|
7
|
+
const setSelectCallback = (callback) => {
|
|
8
|
+
selectCallback = callback;
|
|
9
|
+
};
|
|
10
|
+
provide(actionSheetContextKey, {
|
|
11
|
+
select: (item) => {
|
|
12
|
+
const index = items.value.indexOf(item);
|
|
13
|
+
selectCallback?.(item, index);
|
|
14
|
+
},
|
|
15
|
+
addItem: (item) => {
|
|
16
|
+
if (!items.value.includes(item)) {
|
|
17
|
+
items.value.push(item);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
removeItem: (item) => {
|
|
21
|
+
const index = items.value.indexOf(item);
|
|
22
|
+
if (index > -1) {
|
|
23
|
+
items.value.splice(index, 1);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
items,
|
|
29
|
+
setSelectCallback,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function useActionSheetItem(item) {
|
|
33
|
+
const context = inject(actionSheetContextKey);
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error('ActionSheetItem must be included in ActionSheet.');
|
|
36
|
+
}
|
|
37
|
+
const attrs = useAttrs();
|
|
38
|
+
const mergedItem = reactiveComputed(() => {
|
|
39
|
+
return {
|
|
40
|
+
...item,
|
|
41
|
+
...attrs,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
context.addItem(mergedItem);
|
|
46
|
+
});
|
|
47
|
+
onUnmounted(() => {
|
|
48
|
+
context.removeItem(mergedItem);
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
select: () => {
|
|
52
|
+
context.select(mergedItem);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type { ActionSheetProps, ActionSheetEmits,
|
|
1
|
+
export type { ActionSheetProps, ActionSheetEmits, ActionSheetSlots, ActionSheetItemProps, ActionSheetItemEmits, ActionSheetItemSlots, } from './common';
|
|
2
|
+
export type { ActionSheetContext } from './context';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type ActionSheetAgentProps } from './common';
|
|
1
|
+
import { type ActionSheetAgentProps, type ActionSheetAgentSlots } from './common';
|
|
2
2
|
import { type TransitionHookName } from '../../use';
|
|
3
|
-
import { type
|
|
4
|
-
declare
|
|
3
|
+
import { type ActionSheetItemProps } from '../action-sheet/common';
|
|
4
|
+
declare function __VLS_template(): Readonly<ActionSheetAgentSlots> & ActionSheetAgentSlots;
|
|
5
|
+
declare const __VLS_component: import("vue").DefineComponent<ActionSheetAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
5
6
|
[x: string]: any;
|
|
6
7
|
} & {
|
|
7
8
|
[x: string]: any;
|
|
@@ -13,15 +14,19 @@ declare const _default: import("vue").DefineComponent<ActionSheetAgentProps, {},
|
|
|
13
14
|
visible: boolean;
|
|
14
15
|
duration: number;
|
|
15
16
|
overlayClosable: boolean;
|
|
16
|
-
cancel: string;
|
|
17
17
|
description: string;
|
|
18
|
-
|
|
18
|
+
cancel: string;
|
|
19
|
+
itemList: ActionSheetItemProps[];
|
|
19
20
|
showCancel: boolean;
|
|
20
21
|
beforeClose: import("../action-sheet/common").ActionSheetBeforeClose;
|
|
22
|
+
internalDefault: number;
|
|
23
|
+
internalDescription: number;
|
|
24
|
+
internalCancel: number;
|
|
25
|
+
internalContext: import("../action-sheet/context").UseActionSheetReturn;
|
|
21
26
|
id: string;
|
|
22
27
|
onClose: () => void;
|
|
23
28
|
onCancel: () => void;
|
|
24
|
-
onSelect: (item:
|
|
29
|
+
onSelect: (item: ActionSheetItemProps, index: number) => void;
|
|
25
30
|
onVisibleHook: (name: TransitionHookName) => void;
|
|
26
31
|
onBeforeEnter: () => void;
|
|
27
32
|
onEnter: () => void;
|
|
@@ -32,4 +37,10 @@ declare const _default: import("vue").DefineComponent<ActionSheetAgentProps, {},
|
|
|
32
37
|
onAfterLeave: () => void;
|
|
33
38
|
onLeaveCancelled: () => void;
|
|
34
39
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
35
41
|
export default _default;
|
|
42
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
43
|
+
new (): {
|
|
44
|
+
$slots: S;
|
|
45
|
+
};
|
|
46
|
+
};
|