sard-uniapp 1.19.4 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +1 -1
- package/components/calendar/README.md +20 -20
- package/components/calendar/calendar.vue +1 -1
- package/components/calendar-input/README.md +10 -10
- package/components/calendar-input/calendar-input.vue +2 -2
- package/components/calendar-month/calendar-month.vue +17 -21
- package/components/calendar-popout/calendar-popout.vue +1 -1
- package/components/card/README.md +16 -8
- package/components/card/card.vue +7 -1
- package/components/card/common.d.ts +2 -0
- package/components/card/index.scss +30 -2
- package/components/card/variables.scss +16 -1
- package/components/checkbox/common.d.ts +1 -0
- package/components/checkbox/common.js +1 -0
- package/components/checkbox-input/checkbox-input.vue +9 -0
- package/components/checkbox-popout/README.md +27 -6
- package/components/checkbox-popout/checkbox-popout.vue +113 -47
- package/components/checkbox-popout/common.d.ts +3 -0
- package/components/checkbox-popout/index.scss +16 -0
- package/components/config/index.d.ts +6 -0
- package/components/config/index.js +6 -0
- package/components/datetime-picker/README.md +1 -71
- package/components/datetime-picker/common.d.ts +1 -0
- package/components/datetime-picker/common.js +21 -8
- package/components/datetime-picker/datetime-picker.vue +3 -3
- package/components/datetime-picker-input/README.md +10 -10
- package/components/datetime-picker-input/datetime-picker-input.vue +2 -2
- package/components/datetime-picker-popout/datetime-picker-popout.vue +1 -1
- package/components/datetime-range-picker/datetime-range-picker.vue +12 -10
- package/components/datetime-range-picker-input/README.md +10 -10
- package/components/datetime-range-picker-input/datetime-range-picker-input.vue +2 -2
- package/components/datetime-range-picker-popout/README.md +0 -6
- package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +11 -8
- package/components/floating-bubble/floating-bubble.vue +3 -3
- package/components/form/README.md +19 -19
- package/components/form/form.vue +2 -4
- package/components/form-item/form-item.vue +12 -0
- package/components/icon/icon.d.ts +1 -1
- package/components/indexes/README.md +4 -0
- package/components/indexes-nav/indexes-nav.vue +2 -2
- package/components/keyboard/common.d.ts +1 -2
- package/components/keyboard/common.js +2 -11
- package/components/keyboard/keyboard.d.ts +2 -2
- package/components/list-item/index.scss +4 -0
- package/components/locale/index.d.ts +4 -0
- package/components/locale/index.js +14 -1
- package/components/locale/lang/en-US.d.ts +4 -0
- package/components/locale/lang/en-US.js +4 -0
- package/components/locale/lang/zh-CN.d.ts +4 -0
- package/components/locale/lang/zh-CN.js +4 -0
- package/components/marquee/README.md +8 -2
- package/components/marquee/marquee.vue +9 -1
- package/components/notice-bar/README.md +8 -2
- package/components/notice-bar/notice-bar.vue +14 -8
- package/components/notify/notify.d.ts +1 -1
- package/components/notify-agent/notify-agent.d.ts +1 -1
- package/components/pagination/pagination.vue +2 -2
- package/components/popover/utils.js +4 -4
- package/components/pull-down-refresh/common.d.ts +1 -1
- package/components/radio/common.d.ts +1 -0
- package/components/radio/common.js +1 -0
- package/components/radio-input/radio-input.vue +6 -0
- package/components/radio-popout/README.md +20 -6
- package/components/radio-popout/common.d.ts +2 -0
- package/components/radio-popout/index.scss +4 -0
- package/components/radio-popout/radio-popout.vue +91 -45
- package/components/read-more/README.md +82 -0
- package/components/read-more/common.d.ts +24 -0
- package/components/read-more/common.js +2 -0
- package/components/read-more/index.d.ts +1 -0
- package/components/read-more/index.js +1 -0
- package/components/read-more/index.scss +41 -0
- package/components/read-more/read-more.d.ts +20 -0
- package/components/read-more/read-more.vue +168 -0
- package/components/read-more/variables.scss +12 -0
- package/components/resize-sensor/README.md +55 -0
- package/components/resize-sensor/common.d.ts +19 -0
- package/components/resize-sensor/common.js +2 -0
- package/components/resize-sensor/index.d.ts +1 -0
- package/components/resize-sensor/index.js +1 -0
- package/components/resize-sensor/index.scss +33 -0
- package/components/resize-sensor/resize-sensor.d.ts +16 -0
- package/components/resize-sensor/resize-sensor.vue +152 -0
- package/components/scroll-list/README.md +79 -0
- package/components/scroll-list/common.d.ts +23 -0
- package/components/scroll-list/common.js +1 -0
- package/components/scroll-list/index.d.ts +1 -0
- package/components/scroll-list/index.js +1 -0
- package/components/scroll-list/index.scss +35 -0
- package/components/scroll-list/scroll-list.d.ts +20 -0
- package/components/scroll-list/scroll-list.vue +158 -0
- package/components/scroll-list/variables.scss +11 -0
- package/components/sidebar/README.md +8 -8
- package/components/sidebar/sidebar.vue +1 -1
- package/components/slider/slider.vue +4 -4
- package/components/stepper/stepper.vue +2 -2
- package/components/sticky/README.md +92 -0
- package/components/sticky/common.d.ts +15 -0
- package/components/sticky/common.js +1 -0
- package/components/sticky/index.d.ts +1 -0
- package/components/sticky/index.js +1 -0
- package/components/sticky/index.scss +18 -0
- package/components/sticky/sticky.d.ts +10 -0
- package/components/sticky/sticky.vue +190 -0
- package/components/sticky-box/common.d.ts +19 -0
- package/components/sticky-box/common.js +1 -0
- package/components/sticky-box/index.d.ts +1 -0
- package/components/sticky-box/index.js +1 -0
- package/components/sticky-box/index.scss +19 -0
- package/components/sticky-box/sticky-box.d.ts +10 -0
- package/components/sticky-box/sticky-box.vue +82 -0
- package/components/style/mixins/border.scss +101 -38
- package/components/style/variables-dark.scss +4 -0
- package/components/style/variables.scss +8 -0
- package/components/table/table.vue +2 -1
- package/components/table-fixation/table-fixation.vue +2 -1
- package/components/toast/toast.d.ts +1 -1
- package/components/toast-agent/toast-agent.d.ts +1 -1
- package/components/tree/tree.d.ts +1 -1
- package/components/tree-node/tree-node.vue +2 -2
- package/components/upload/README.md +23 -15
- package/components/upload/common.d.ts +6 -4
- package/components/upload/upload.d.ts +2 -0
- package/components/upload/upload.vue +51 -13
- package/components/upload/utils.d.ts +1 -0
- package/components/upload/utils.js +2 -0
- package/components/upload-preview/index.scss +1 -0
- package/components/upload-preview/upload-preview.d.ts +6 -4
- package/components/upload-preview/upload-preview.vue +17 -24
- package/global.d.ts +5 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/index.scss +2 -0
- package/package.json +4 -2
- package/use/index.d.ts +4 -0
- package/use/index.js +4 -0
- package/use/useIndeterminate.d.ts +10 -0
- package/use/useIndeterminate.js +27 -0
- package/use/useIntersectionObserver.d.ts +16 -0
- package/use/useIntersectionObserver.js +52 -0
- package/use/useSimulatedClick.js +2 -2
- package/use/useSimulatedPress.js +2 -2
- package/use/useSingleTask.d.ts +6 -0
- package/use/useSingleTask.js +40 -0
- package/use/useWindowResize.d.ts +4 -0
- package/use/useWindowResize.js +15 -0
- package/utils/array.d.ts +28 -0
- package/utils/array.js +90 -0
- package/utils/common.d.ts +3 -0
- package/utils/common.js +1 -0
- package/utils/date.d.ts +84 -11
- package/utils/date.js +120 -63
- package/utils/dom.js +2 -0
- package/utils/geometry.d.ts +56 -38
- package/utils/geometry.js +56 -30
- package/utils/index.d.ts +8 -1
- package/utils/index.js +8 -1
- package/utils/is.d.ts +12 -0
- package/utils/is.js +16 -0
- package/utils/number.d.ts +24 -0
- package/utils/number.js +37 -0
- package/utils/object.d.ts +29 -0
- package/utils/object.js +139 -0
- package/utils/persist.d.ts +15 -0
- package/utils/persist.js +89 -0
- package/utils/physics.d.ts +34 -0
- package/utils/physics.js +66 -0
- package/utils/request.d.ts +227 -0
- package/utils/request.js +249 -0
- package/utils/router.d.ts +47 -0
- package/utils/router.js +115 -0
- package/utils/string.d.ts +46 -0
- package/utils/string.js +134 -0
- package/utils/url-query.d.ts +19 -0
- package/utils/url-query.js +95 -0
- package/utils/utils.d.ts +0 -166
- package/utils/utils.js +0 -441
- package/utils/case.d.ts +0 -4
- package/utils/case.js +0 -26
|
@@ -24,18 +24,32 @@ import RadioPopout from 'sard-uniapp/components/radio-popout/radio-popout.vue'
|
|
|
24
24
|
|
|
25
25
|
@code('${DEMO_PATH}/radio-popout/demo/Basic.vue')
|
|
26
26
|
|
|
27
|
+
### 禁用选项 <sup>1.20+</sup>
|
|
28
|
+
|
|
29
|
+
设置了 `disabled` 的选项可禁止选择。
|
|
30
|
+
|
|
31
|
+
@code('${DEMO_PATH}/radio-popout/demo/Disabled.vue')
|
|
32
|
+
|
|
33
|
+
### 可搜索的 <sup>1.20+</sup>
|
|
34
|
+
|
|
35
|
+
使用 `searchable` 显示搜索框,可用于过滤选项列表。
|
|
36
|
+
|
|
37
|
+
@code('${DEMO_PATH}/radio-popout/demo/Search.vue')
|
|
38
|
+
|
|
27
39
|
## API
|
|
28
40
|
|
|
29
41
|
### RadioPopoutProps
|
|
30
42
|
|
|
31
43
|
继承 [`RadioGroupProps`](./radio#RadioGroupProps) 并有以下额外属性:
|
|
32
44
|
|
|
33
|
-
| 属性
|
|
34
|
-
|
|
|
35
|
-
| popout-class
|
|
36
|
-
| popout-style
|
|
37
|
-
| visible (v-model)
|
|
38
|
-
| title
|
|
45
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
46
|
+
| ----------------------------------- | -------------------- | ---------- | ------ |
|
|
47
|
+
| popout-class | 弹窗框根元素类名 | string | - |
|
|
48
|
+
| popout-style | 弹窗框根元素样式 | StyleValue | - |
|
|
49
|
+
| visible (v-model) | 是否显示弹出框 | boolean | - |
|
|
50
|
+
| title | 弹出框标题 | string | - |
|
|
51
|
+
| searchable <sup>1.20+</sup> | 是否可搜索 | boolean | false |
|
|
52
|
+
| filter-placeholder <sup>1.20+</sup> | 搜索输入框占位符内容 | string | - |
|
|
39
53
|
|
|
40
54
|
### RadioPopoutEmits
|
|
41
55
|
|
|
@@ -5,6 +5,8 @@ export interface RadioPopoutProps extends RadioGroupProps {
|
|
|
5
5
|
title?: string;
|
|
6
6
|
popoutClass?: string;
|
|
7
7
|
popoutStyle?: StyleValue;
|
|
8
|
+
searchable?: boolean;
|
|
9
|
+
filterPlaceholder?: string;
|
|
8
10
|
}
|
|
9
11
|
export declare const defaultRadioPopoutProps: () => {
|
|
10
12
|
options: () => never[];
|
|
@@ -7,49 +7,61 @@
|
|
|
7
7
|
@confirm="onConfirm"
|
|
8
8
|
>
|
|
9
9
|
<template #visible="{ already }">
|
|
10
|
-
<view v-if="already"
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:lower-threshold="0"
|
|
17
|
-
:throttle="false"
|
|
18
|
-
@scroll="onScroll"
|
|
19
|
-
@scrolltoupper="onScrolltoupper"
|
|
20
|
-
@scrolltolower="onScrolltolower"
|
|
21
|
-
>
|
|
22
|
-
<sar-radio-group
|
|
23
|
-
:size="size"
|
|
24
|
-
:type="type"
|
|
25
|
-
:checkedColor="checkedColor"
|
|
26
|
-
:direction="direction"
|
|
27
|
-
:validate-event="false"
|
|
28
|
-
:model-value="popoutValue"
|
|
29
|
-
@change="onChange"
|
|
10
|
+
<view v-if="already">
|
|
11
|
+
<sar-list-item v-if="searchable">
|
|
12
|
+
<sar-input
|
|
13
|
+
v-model="searchValue"
|
|
14
|
+
:placeholder="filterPlaceholder"
|
|
15
|
+
clearable
|
|
30
16
|
>
|
|
31
|
-
<template #
|
|
32
|
-
<sar-
|
|
33
|
-
<sar-list-item
|
|
34
|
-
v-for="option in options"
|
|
35
|
-
:key="getMayPrimitiveOption(option, fieldKeys.value)"
|
|
36
|
-
:title="getMayPrimitiveOption(option, fieldKeys.label)"
|
|
37
|
-
hover
|
|
38
|
-
@click="
|
|
39
|
-
toggle(getMayPrimitiveOption(option, fieldKeys.value))
|
|
40
|
-
"
|
|
41
|
-
>
|
|
42
|
-
<template #value>
|
|
43
|
-
<sar-radio
|
|
44
|
-
readonly
|
|
45
|
-
:value="getMayPrimitiveOption(option, fieldKeys.value)"
|
|
46
|
-
/>
|
|
47
|
-
</template>
|
|
48
|
-
</sar-list-item>
|
|
49
|
-
</sar-list>
|
|
17
|
+
<template #prepend>
|
|
18
|
+
<sar-icon family="sari" name="search" />
|
|
50
19
|
</template>
|
|
51
|
-
</sar-
|
|
52
|
-
</
|
|
20
|
+
</sar-input>
|
|
21
|
+
</sar-list-item>
|
|
22
|
+
<view :class="containerClass">
|
|
23
|
+
<scroll-view
|
|
24
|
+
:class="scrollClass"
|
|
25
|
+
scroll-y
|
|
26
|
+
trap-scroll
|
|
27
|
+
:upper-threshold="0"
|
|
28
|
+
:lower-threshold="0"
|
|
29
|
+
:throttle="false"
|
|
30
|
+
@scroll="onScroll"
|
|
31
|
+
@scrolltoupper="onScrolltoupper"
|
|
32
|
+
@scrolltolower="onScrolltolower"
|
|
33
|
+
>
|
|
34
|
+
<sar-radio-group
|
|
35
|
+
:size="size"
|
|
36
|
+
:type="type"
|
|
37
|
+
:checkedColor="checkedColor"
|
|
38
|
+
:direction="direction"
|
|
39
|
+
:validate-event="false"
|
|
40
|
+
:model-value="popoutValue"
|
|
41
|
+
@change="onChange"
|
|
42
|
+
>
|
|
43
|
+
<template #custom="{ toggle }">
|
|
44
|
+
<sar-list inlaid>
|
|
45
|
+
<sar-list-item
|
|
46
|
+
v-for="option in filteredOptions"
|
|
47
|
+
:key="option.value"
|
|
48
|
+
:title="option.label"
|
|
49
|
+
:hover="!option.disabled"
|
|
50
|
+
@click="select(option, toggle)"
|
|
51
|
+
>
|
|
52
|
+
<template #icon>
|
|
53
|
+
<sar-radio
|
|
54
|
+
readonly
|
|
55
|
+
:disabled="option.disabled"
|
|
56
|
+
:value="option.value"
|
|
57
|
+
/>
|
|
58
|
+
</template>
|
|
59
|
+
</sar-list-item>
|
|
60
|
+
</sar-list>
|
|
61
|
+
</template>
|
|
62
|
+
</sar-radio-group>
|
|
63
|
+
</scroll-view>
|
|
64
|
+
</view>
|
|
53
65
|
</view>
|
|
54
66
|
</template>
|
|
55
67
|
</sar-popout>
|
|
@@ -57,12 +69,14 @@
|
|
|
57
69
|
|
|
58
70
|
<script>
|
|
59
71
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
60
|
-
import { computed } from "vue";
|
|
72
|
+
import { computed, ref } from "vue";
|
|
61
73
|
import SarPopout from "../popout/popout.vue";
|
|
62
74
|
import SarRadioGroup from "../radio-group/radio-group.vue";
|
|
63
75
|
import SarRadio from "../radio/radio.vue";
|
|
64
76
|
import SarList from "../list/list.vue";
|
|
65
77
|
import SarListItem from "../list-item/list-item.vue";
|
|
78
|
+
import SarIcon from "../icon/icon.vue";
|
|
79
|
+
import SarInput from "../input/input.vue";
|
|
66
80
|
import { classNames, createBem, getMayPrimitiveOption } from "../../utils";
|
|
67
81
|
import {
|
|
68
82
|
defaultRadioPopoutProps
|
|
@@ -86,6 +100,8 @@ import { useScrollSide, useFormPopout } from "../../use";
|
|
|
86
100
|
* @property {StyleValue} popoutStyle 弹窗框根元素样式,默认值:-。
|
|
87
101
|
* @property {boolean} visible 是否显示弹出框,默认值:-。
|
|
88
102
|
* @property {string} title 弹出框标题,默认值:-。
|
|
103
|
+
* @property {boolean} searchable 是否可搜索,默认值:false。
|
|
104
|
+
* @property {string} filterPlaceholder 搜索输入框占位符内容,默认值:-。
|
|
89
105
|
* @event {(visible: boolean) => void} update 弹出框显隐时触发
|
|
90
106
|
* @event {(value: any | undefined) => void} change 单选输入组件值改变时触发
|
|
91
107
|
*/
|
|
@@ -96,6 +112,8 @@ export default _defineComponent({
|
|
|
96
112
|
SarRadio,
|
|
97
113
|
SarList,
|
|
98
114
|
SarListItem,
|
|
115
|
+
SarIcon,
|
|
116
|
+
SarInput,
|
|
99
117
|
},
|
|
100
118
|
...{
|
|
101
119
|
options: {
|
|
@@ -109,6 +127,8 @@ export default _defineComponent({
|
|
|
109
127
|
title: { type: String, required: false },
|
|
110
128
|
popoutClass: { type: String, required: false },
|
|
111
129
|
popoutStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
130
|
+
searchable: { type: Boolean, required: false },
|
|
131
|
+
filterPlaceholder: { type: String, required: false },
|
|
112
132
|
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
113
133
|
rootClass: { type: String, required: false },
|
|
114
134
|
modelValue: { type: null, required: false },
|
|
@@ -135,6 +155,28 @@ export default _defineComponent({
|
|
|
135
155
|
const fieldKeys = computed(() => {
|
|
136
156
|
return Object.assign({}, defaultOptionKeys, props.optionKeys);
|
|
137
157
|
});
|
|
158
|
+
const objectOptions = computed(() => {
|
|
159
|
+
return props.options.map((option) => {
|
|
160
|
+
return {
|
|
161
|
+
label: getMayPrimitiveOption(option, fieldKeys.value.label),
|
|
162
|
+
value: getMayPrimitiveOption(option, fieldKeys.value.value),
|
|
163
|
+
disabled: getMayPrimitiveOption(option, fieldKeys.value.disabled) === true
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
const select = (option, toggle) => {
|
|
168
|
+
if (!option.disabled) {
|
|
169
|
+
toggle(option.value);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const searchValue = ref("");
|
|
173
|
+
const filteredOptions = computed(() => {
|
|
174
|
+
const searchString = searchValue.value;
|
|
175
|
+
if (!searchString) return objectOptions.value;
|
|
176
|
+
return objectOptions.value.filter((option) => {
|
|
177
|
+
return option.label.includes(searchString);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
138
180
|
const { scrollSide, onScroll, onScrolltoupper, onScrolltolower } = useScrollSide();
|
|
139
181
|
const containerClass = computed(() => {
|
|
140
182
|
return classNames(
|
|
@@ -142,9 +184,13 @@ export default _defineComponent({
|
|
|
142
184
|
bem.em("container", scrollSide.value, scrollSide.value)
|
|
143
185
|
);
|
|
144
186
|
});
|
|
145
|
-
const
|
|
146
|
-
return
|
|
147
|
-
|
|
187
|
+
const scrollClass = computed(() => {
|
|
188
|
+
return classNames(
|
|
189
|
+
bem.e("scroll"),
|
|
190
|
+
bem.em("scroll", "searchable", props.searchable)
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
const __returned__ = { props, emit, bem, innerVisible, popoutValue, onChange, onConfirm, fieldKeys, objectOptions, select, searchValue, filteredOptions, scrollSide, onScroll, onScrolltoupper, onScrolltolower, containerClass, scrollClass, SarPopout, SarRadioGroup, SarRadio, SarList, SarListItem, SarIcon, SarInput };
|
|
148
194
|
return __returned__;
|
|
149
195
|
}
|
|
150
196
|
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 组件
|
|
3
|
+
title: ReadMore
|
|
4
|
+
subtitle: 阅读更多
|
|
5
|
+
group: 数据展示
|
|
6
|
+
version: 1.20+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 介绍
|
|
10
|
+
|
|
11
|
+
该组件一般用于内容较长,预先收起一部分,点击再展开全部内容的场景。
|
|
12
|
+
|
|
13
|
+
## 引入
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import ReadMore from 'sard-uniapp/components/read-more/read-more.vue'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 代码演示
|
|
20
|
+
|
|
21
|
+
### 基础使用
|
|
22
|
+
|
|
23
|
+
在默认插槽放置任意内容,默认会收起来,点击展开按钮时全部显示。
|
|
24
|
+
|
|
25
|
+
为了避免滚动到一定位置再收起来的位置跳跃,可以使用 `keep-location` 属性保持收起后,按钮下面的内容依然在屏幕中原来的位置。
|
|
26
|
+
|
|
27
|
+
只可用在页面滚动中,如果在 `scroll-view` 中,需要在 `close` 事件回调中自行实现。
|
|
28
|
+
|
|
29
|
+
@code('${DEMO_PATH}/read-more/demo/Basic.vue')
|
|
30
|
+
|
|
31
|
+
### 收起时最大高度
|
|
32
|
+
|
|
33
|
+
可以使用 `max-height` 设置收起时的最大高度。
|
|
34
|
+
|
|
35
|
+
@code('${DEMO_PATH}/read-more/demo/MaxHeight.vue')
|
|
36
|
+
|
|
37
|
+
### 按钮文案
|
|
38
|
+
|
|
39
|
+
使用 `open-text` 和 `close-text` 设置展开状态和收起状态时的按钮文案。
|
|
40
|
+
|
|
41
|
+
@code('${DEMO_PATH}/read-more/demo/Text.vue')
|
|
42
|
+
|
|
43
|
+
### 隐藏收起按钮
|
|
44
|
+
|
|
45
|
+
设置 `hide-close` 后,在展开时不会再显示收起按钮。
|
|
46
|
+
|
|
47
|
+
@code('${DEMO_PATH}/read-more/demo/HideClose.vue')
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### ReadMoreProps
|
|
52
|
+
|
|
53
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
54
|
+
| ----------------- | -------------------------------------------------------------- | ---------- | ------ |
|
|
55
|
+
| root-class | 组件根元素类名 | string | - |
|
|
56
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
57
|
+
| max-height | 收起时最大展示高度 | number | 200 |
|
|
58
|
+
| hide-close | 是否隐藏收起按钮,打开后就不能手动收起来了 | boolean | false |
|
|
59
|
+
| open-text | 展开状态按钮文案 | string | '收起' |
|
|
60
|
+
| close-text | 收起状态按钮文案 | string | '展开' |
|
|
61
|
+
| visible (v-model) | 控制展开和收起 | boolean | false |
|
|
62
|
+
| keep-location | 收起时保持按钮下面的内容在屏幕中原来的位置,只可用在页面滚动中 | boolean | false |
|
|
63
|
+
|
|
64
|
+
### ReadMoreSlots
|
|
65
|
+
|
|
66
|
+
| 插槽 | 描述 | 属性 |
|
|
67
|
+
| ------- | -------------- | ---- |
|
|
68
|
+
| default | 自定义默认内容 | - |
|
|
69
|
+
|
|
70
|
+
### ReadMoreEmits
|
|
71
|
+
|
|
72
|
+
| 事件 | 描述 | 类型 |
|
|
73
|
+
| -------------- | --------------- | ------------------------- |
|
|
74
|
+
| update:visible | 展开/收起时触发 | (visible: boolean)=> void |
|
|
75
|
+
| open | 展开时触发 | () => void |
|
|
76
|
+
| close | 收起时触发 | () => void |
|
|
77
|
+
|
|
78
|
+
## 主题定制
|
|
79
|
+
|
|
80
|
+
### CSS 变量
|
|
81
|
+
|
|
82
|
+
@code('./variables.scss#variables')
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
export interface ReadMoreProps {
|
|
3
|
+
rootStyle?: StyleValue;
|
|
4
|
+
rootClass?: string;
|
|
5
|
+
maxHeight?: number;
|
|
6
|
+
hideClose?: boolean;
|
|
7
|
+
openText?: string;
|
|
8
|
+
closeText?: string;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
keepLocation?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const defaultReadMoreProps: {
|
|
13
|
+
maxHeight: number;
|
|
14
|
+
};
|
|
15
|
+
export interface ReadMoreSlots {
|
|
16
|
+
default?(props: Record<string, never>): any;
|
|
17
|
+
}
|
|
18
|
+
export interface ReadMoreEmits {
|
|
19
|
+
(e: 'update:visible', visible: boolean): void;
|
|
20
|
+
(e: 'open'): void;
|
|
21
|
+
(e: 'close'): void;
|
|
22
|
+
}
|
|
23
|
+
export interface ReadMoreExpose {
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ReadMoreProps, ReadMoreSlots, ReadMoreEmits, ReadMoreExpose, } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@use '../style/base' as *;
|
|
2
|
+
|
|
3
|
+
@include bem(read-more) {
|
|
4
|
+
@include b() {
|
|
5
|
+
@include universal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@include e(content) {
|
|
9
|
+
position: relative;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@include e(shadow) {
|
|
13
|
+
@include universal;
|
|
14
|
+
position: absolute;
|
|
15
|
+
left: 0;
|
|
16
|
+
right: 0;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
max-height: var(--sar-read-more-shadow-max-height);
|
|
19
|
+
height: var(--sar-read-more-shadow-height);
|
|
20
|
+
background-image: var(--sar-read-more-shadow-bg-image);
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@include e(toggle) {
|
|
25
|
+
@include universal;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-left: auto;
|
|
29
|
+
margin-right: auto;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include m(close) {
|
|
33
|
+
@include e(content) {
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@include e(shadow) {
|
|
38
|
+
display: flex;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReadMoreProps, type ReadMoreSlots } from './common';
|
|
2
|
+
declare function __VLS_template(): Readonly<ReadMoreSlots> & ReadMoreSlots;
|
|
3
|
+
declare const __VLS_component: import("vue").DefineComponent<ReadMoreProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
4
|
+
close: () => any;
|
|
5
|
+
"update:visible": (visible: boolean) => any;
|
|
6
|
+
open: () => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<ReadMoreProps> & Readonly<{
|
|
8
|
+
onClose?: (() => any) | undefined;
|
|
9
|
+
"onUpdate:visible"?: ((visible: boolean) => any) | undefined;
|
|
10
|
+
onOpen?: (() => any) | undefined;
|
|
11
|
+
}>, {
|
|
12
|
+
maxHeight: number;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="readMoreClass" :style="readMoreStyle">
|
|
3
|
+
<view :id="contentId" :class="bem.e('content')" :style="contentStyle">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
<view :class="bem.e('shadow')"></view>
|
|
6
|
+
</view>
|
|
7
|
+
<view
|
|
8
|
+
v-if="!hideToggle"
|
|
9
|
+
:id="toggleId"
|
|
10
|
+
:class="bem.e('toggle')"
|
|
11
|
+
@touchstart="onTouchStart"
|
|
12
|
+
@mousedown="onMouseDown"
|
|
13
|
+
>
|
|
14
|
+
<sar-button type="pale-text" @click="onButtonClick">
|
|
15
|
+
<text>{{ toggleText }}</text>
|
|
16
|
+
<sar-icon family="sari" :name="toggleIcon" />
|
|
17
|
+
</sar-button>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
24
|
+
import { computed, getCurrentInstance, ref, watch } from "vue";
|
|
25
|
+
import {
|
|
26
|
+
classNames,
|
|
27
|
+
stringifyStyle,
|
|
28
|
+
createBem,
|
|
29
|
+
uniqid,
|
|
30
|
+
getBoundingClientRect
|
|
31
|
+
} from "../../utils";
|
|
32
|
+
import {
|
|
33
|
+
defaultReadMoreProps
|
|
34
|
+
} from "./common";
|
|
35
|
+
import SarButton from "../button/button.vue";
|
|
36
|
+
import SarIcon from "../icon/icon.vue";
|
|
37
|
+
import { useTranslate } from "../locale";
|
|
38
|
+
import { useMouseDown, useSingleTask } from "../../use";
|
|
39
|
+
/**
|
|
40
|
+
* @property {string} rootClass 组件根元素类名,默认值:-。
|
|
41
|
+
* @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
|
|
42
|
+
* @property {number} maxHeight 收起时最大展示高度,默认值:200。
|
|
43
|
+
* @property {boolean} hideClose 是否隐藏收起按钮,打开后就不能手动收起来了,默认值:false。
|
|
44
|
+
* @property {string} openText 展开状态按钮文案,默认值:'收起'。
|
|
45
|
+
* @property {string} closeText 收起状态按钮文案,默认值:'展开'。
|
|
46
|
+
* @property {boolean} visible 控制展开和收起,默认值:false。
|
|
47
|
+
* @property {boolean} keepLocation 收起时保持按钮下面的内容在屏幕中原来的位置,只可用在页面滚动中,默认值:false。
|
|
48
|
+
* @event {(visible: boolean)=> void} update 展开/收起时触发
|
|
49
|
+
* @event {() => void} open 展开时触发
|
|
50
|
+
* @event {() => void} close 收起时触发
|
|
51
|
+
*/
|
|
52
|
+
export default _defineComponent({
|
|
53
|
+
components: {
|
|
54
|
+
SarButton,
|
|
55
|
+
SarIcon,
|
|
56
|
+
},
|
|
57
|
+
...{
|
|
58
|
+
options: {
|
|
59
|
+
virtualHost: true,
|
|
60
|
+
styleIsolation: "shared"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
__name: "read-more",
|
|
64
|
+
props: _mergeDefaults({
|
|
65
|
+
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
66
|
+
rootClass: { type: String, required: false },
|
|
67
|
+
maxHeight: { type: Number, required: false },
|
|
68
|
+
hideClose: { type: Boolean, required: false },
|
|
69
|
+
openText: { type: String, required: false },
|
|
70
|
+
closeText: { type: String, required: false },
|
|
71
|
+
visible: { type: Boolean, required: false },
|
|
72
|
+
keepLocation: { type: Boolean, required: false }
|
|
73
|
+
}, defaultReadMoreProps),
|
|
74
|
+
emits: ["update:visible", "open", "close"],
|
|
75
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
76
|
+
const props = __props;
|
|
77
|
+
const emit = __emit;
|
|
78
|
+
const bem = createBem("read-more");
|
|
79
|
+
const { t } = useTranslate("readMore");
|
|
80
|
+
const innerVisible = ref(props.visible);
|
|
81
|
+
const { startTask, onFinishTask } = useSingleTask();
|
|
82
|
+
watch(
|
|
83
|
+
() => props.visible,
|
|
84
|
+
() => {
|
|
85
|
+
onFinishTask(() => {
|
|
86
|
+
innerVisible.value = props.visible;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
const handleClick = () => {
|
|
91
|
+
innerVisible.value = !innerVisible.value;
|
|
92
|
+
emit("update:visible", innerVisible.value);
|
|
93
|
+
if (innerVisible.value) {
|
|
94
|
+
emit("open");
|
|
95
|
+
} else {
|
|
96
|
+
onClose();
|
|
97
|
+
emit("close");
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const onButtonClick = () => {
|
|
101
|
+
onFinishTask(handleClick);
|
|
102
|
+
};
|
|
103
|
+
const toggleText = computed(() => {
|
|
104
|
+
return innerVisible.value ? props.openText || t("fold") : props.closeText || t("unfold");
|
|
105
|
+
});
|
|
106
|
+
const toggleIcon = computed(() => {
|
|
107
|
+
return innerVisible.value ? "up" : "down";
|
|
108
|
+
});
|
|
109
|
+
const hideToggle = computed(() => {
|
|
110
|
+
return innerVisible.value && props.hideClose;
|
|
111
|
+
});
|
|
112
|
+
const contentId = uniqid();
|
|
113
|
+
const toggleId = uniqid();
|
|
114
|
+
const instance = getCurrentInstance();
|
|
115
|
+
let scrollTop = 0;
|
|
116
|
+
const onTouchStart = (event) => {
|
|
117
|
+
if (props.keepLocation && innerVisible.value) {
|
|
118
|
+
startTask(async () => {
|
|
119
|
+
const { clientY, pageY } = event.touches[0];
|
|
120
|
+
const contentRect = await getBoundingClientRect(`#${contentId}`, instance);
|
|
121
|
+
const toggleRect = await getBoundingClientRect(`#${toggleId}`, instance);
|
|
122
|
+
const closeContentHeight = Math.min(props.maxHeight, contentRect.height);
|
|
123
|
+
const openContentHeight = contentRect.height;
|
|
124
|
+
const offsetTop = clientY - toggleRect.top;
|
|
125
|
+
const openContentPageY = pageY - offsetTop - openContentHeight;
|
|
126
|
+
const closeContentClientY = toggleRect.top - closeContentHeight;
|
|
127
|
+
scrollTop = openContentPageY - closeContentClientY;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const onMouseDown = useMouseDown(onTouchStart);
|
|
132
|
+
const onClose = () => {
|
|
133
|
+
if (props.keepLocation) {
|
|
134
|
+
uni.pageScrollTo({
|
|
135
|
+
scrollTop,
|
|
136
|
+
duration: 0
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
__expose({});
|
|
141
|
+
const readMoreClass = computed(() => {
|
|
142
|
+
return classNames(
|
|
143
|
+
bem.b(),
|
|
144
|
+
bem.m("close", !innerVisible.value),
|
|
145
|
+
props.rootClass
|
|
146
|
+
);
|
|
147
|
+
});
|
|
148
|
+
const readMoreStyle = computed(() => {
|
|
149
|
+
return stringifyStyle(props.rootStyle);
|
|
150
|
+
});
|
|
151
|
+
const contentStyle = computed(() => {
|
|
152
|
+
return {
|
|
153
|
+
maxHeight: innerVisible.value ? "none" : props.maxHeight + "px"
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
const __returned__ = { props, emit, bem, t, innerVisible, startTask, onFinishTask, handleClick, onButtonClick, toggleText, toggleIcon, hideToggle, contentId, toggleId, instance, get scrollTop() {
|
|
157
|
+
return scrollTop;
|
|
158
|
+
}, set scrollTop(v) {
|
|
159
|
+
scrollTop = v;
|
|
160
|
+
}, onTouchStart, onMouseDown, onClose, readMoreClass, readMoreStyle, contentStyle, SarButton, SarIcon };
|
|
161
|
+
return __returned__;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
</script>
|
|
165
|
+
|
|
166
|
+
<style lang="scss">
|
|
167
|
+
@import './index.scss';
|
|
168
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// #variables
|
|
2
|
+
page,
|
|
3
|
+
.sar-portal {
|
|
4
|
+
--sar-read-more-shadow-max-height: 80%;
|
|
5
|
+
--sar-read-more-shadow-height: 200rpx;
|
|
6
|
+
--sar-read-more-shadow-bg-image: linear-gradient(
|
|
7
|
+
to bottom,
|
|
8
|
+
rgba(var(--sar-emphasis-bg-rgb), 0),
|
|
9
|
+
rgba(var(--sar-emphasis-bg-rgb), 1) 95%
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
// #endvariables
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 组件
|
|
3
|
+
title: ResizeSensor
|
|
4
|
+
subtitle: 尺寸传感器
|
|
5
|
+
group: 反馈组件
|
|
6
|
+
version: 1.20+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 介绍
|
|
10
|
+
|
|
11
|
+
可感知元素尺寸的变化,在元素宽度或高度变化时触发事件。
|
|
12
|
+
|
|
13
|
+
## 引入
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import ResizeSensor from 'sard-uniapp/components/resize-sensor/resize-sensor.vue'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 代码演示
|
|
20
|
+
|
|
21
|
+
### 基础使用
|
|
22
|
+
|
|
23
|
+
将 `ResizeSensor` 组件放置在要监听尺寸变化的元素里面,此元素需要设置相对、绝对或固定定位;监听 `resize` 事件,此事件会在被监听元素尺寸发生变化时触发。
|
|
24
|
+
|
|
25
|
+
@code('${DEMO_PATH}/resize-sensor/demo/Basic.vue')
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
### ResizeSensorProps
|
|
30
|
+
|
|
31
|
+
| 属性 | 描述 | 类型 | 默认值 |
|
|
32
|
+
| ---------- | ---------------------------------- | ---------- | ------ |
|
|
33
|
+
| root-class | 组件根元素类名 | string | - |
|
|
34
|
+
| root-style | 组件根元素样式 | StyleValue | - |
|
|
35
|
+
| initial | 是否在初始化时触发 `resize` 事件 | boolean | false |
|
|
36
|
+
| threshold | 触发 `resize` 事件的阈值,单位毫秒 | number | 150 |
|
|
37
|
+
|
|
38
|
+
### ResizeSensorEmits
|
|
39
|
+
|
|
40
|
+
| 事件 | 描述 | 类型 |
|
|
41
|
+
| ------ | -------------------------- | ------------------------- |
|
|
42
|
+
| resize | 在元素宽或高发生变化时触发 | (value: NodeRect) => void |
|
|
43
|
+
|
|
44
|
+
#### NodeRect
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
interface NodeRect {
|
|
48
|
+
top: number
|
|
49
|
+
right: number
|
|
50
|
+
bottom: number
|
|
51
|
+
left: number
|
|
52
|
+
height: number
|
|
53
|
+
width: number
|
|
54
|
+
}
|
|
55
|
+
```
|