sard-uniapp 1.18.0 → 1.19.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 +19 -0
- package/README.md +5 -0
- package/components/button/button.vue +2 -0
- package/components/button/common.d.ts +1 -0
- package/components/button/index.scss +9 -0
- package/components/cascader/cascader.vue +7 -0
- package/components/cascader-input/cascader-input.vue +1 -1
- package/components/crop-image/crop-image.vue +7 -7
- package/components/dialog-agent/common.d.ts +3 -0
- package/components/dialog-agent/dialog-agent.vue +10 -1
- package/components/dropdown/common.d.ts +3 -0
- package/components/dropdown/index.d.ts +1 -1
- package/components/dropdown-item/dropdown-item.vue +53 -21
- package/components/floating-bubble/floating-bubble.vue +4 -4
- package/components/form/form.vue +4 -1
- package/components/form-item/index.scss +10 -0
- package/components/marquee/marquee.vue +8 -5
- package/components/notice-bar/notice-bar.vue +8 -5
- package/components/notify/notify.vue +10 -7
- package/components/picker-item/index.scss +0 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +15 -9
- package/components/swipe-action/common.d.ts +23 -0
- package/components/swipe-action/common.js +1 -0
- package/components/swipe-action/index.d.ts +1 -0
- package/components/swipe-action/index.js +1 -0
- package/components/swipe-action/index.scss +53 -0
- package/components/swipe-action/swipe-action.d.ts +16 -0
- package/components/swipe-action/swipe-action.vue +275 -0
- package/components/swipe-action/variables.scss +3 -0
- package/components/toast/toast.vue +10 -7
- package/global.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.scss +1 -0
- package/package.json +2 -7
- package/use/index.d.ts +3 -1
- package/use/index.js +3 -1
- package/use/useScrollSpy.js +4 -4
- package/use/useSimulatedClick.js +4 -4
- package/use/useSimulatedPress.js +5 -5
- package/use/useStopMovedClick.d.ts +6 -0
- package/use/useStopMovedClick.js +26 -0
- package/use/useTimeout.d.ts +11 -0
- package/use/useTimeout.js +39 -0
- package/use/useTimeoutLoading.js +9 -7
- package/use/useSetTimeout.d.ts +0 -1
- package/use/useSetTimeout.js +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/sutras/sard-uniapp/compare/v1.18.0...v1.19.0) (2025-06-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 修复 dialog 命令式回调选项参数问题 ([5af4fd8](https://github.com/sutras/sard-uniapp/commit/5af4fd81b6528501f2103b8db1b40a14f6186926))
|
|
7
|
+
* 修复 form fields 错乱删除问题 ([8250da9](https://github.com/sutras/sard-uniapp/commit/8250da9770152a4f6a93e873c70c01e13c91ce56))
|
|
8
|
+
* 修复cascader组件因值不存在时不显示列表的问题 ([4bae371](https://github.com/sutras/sard-uniapp/commit/4bae37167ccd88db3286d3bc233dfa250cfad4f9))
|
|
9
|
+
* 修复picker最后一列在安卓偏移问题 ([a041836](https://github.com/sutras/sard-uniapp/commit/a04183687b4291c04a0c5381dbc8fbf0b0f5afba))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* button 新增 square 属性 ([41db4ac](https://github.com/sutras/sard-uniapp/commit/41db4acd6804f52e02cff5eeb3eaaf005dfc7f5e))
|
|
15
|
+
* dropdown 新增 before-close 属性 ([3407a6b](https://github.com/sutras/sard-uniapp/commit/3407a6b5a9cb4038c7d63de9bfdb81498e6afd76))
|
|
16
|
+
* 新增 swipe-action 组件 ([9a390c6](https://github.com/sutras/sard-uniapp/commit/9a390c61d036a016d2ee8d706130589e3ca4009c))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
1
20
|
# [1.18.0](https://github.com/sutras/sard-uniapp/compare/v1.17.1...v1.18.0) (2025-06-06)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ export default _defineComponent({
|
|
|
79
79
|
theme: { type: String, required: false },
|
|
80
80
|
size: { type: String, required: false },
|
|
81
81
|
round: { type: Boolean, required: false },
|
|
82
|
+
square: { type: Boolean, required: false },
|
|
82
83
|
disabled: { type: Boolean, required: false },
|
|
83
84
|
loading: { type: Boolean, required: false },
|
|
84
85
|
loadingType: { type: String, required: false },
|
|
@@ -162,6 +163,7 @@ export default _defineComponent({
|
|
|
162
163
|
bem.m(props.type),
|
|
163
164
|
bem.m(`${props.type}-${props.theme}`),
|
|
164
165
|
bem.m("round", props.round),
|
|
166
|
+
bem.m("square", props.square),
|
|
165
167
|
bem.m("disabled", isDisabled.value),
|
|
166
168
|
bem.m("loading", props.loading),
|
|
167
169
|
bem.m("block", props.icon || props.inline ? false : props.block),
|
|
@@ -6,6 +6,7 @@ export interface ButtonProps {
|
|
|
6
6
|
theme?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'danger' | 'neutral';
|
|
7
7
|
size?: 'mini' | 'small' | 'medium' | 'large';
|
|
8
8
|
round?: boolean;
|
|
9
|
+
square?: boolean;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
loading?: boolean;
|
|
11
12
|
loadingType?: 'clock' | 'circular';
|
|
@@ -190,6 +190,15 @@
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
// # 方形按钮
|
|
194
|
+
@include m(square) {
|
|
195
|
+
border-radius: 0;
|
|
196
|
+
|
|
197
|
+
&::after {
|
|
198
|
+
border-radius: 0;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
// # active 状态
|
|
194
203
|
@include m(default, pale, mild, outline, text) {
|
|
195
204
|
&:not(#{bem($b: button, $m: disabled)}):not(
|
|
@@ -103,7 +103,7 @@ export default _defineComponent({
|
|
|
103
103
|
function getOutletText(options, value, fieldKeys) {
|
|
104
104
|
const selectedOptions = getSelectedOptionsByValue(options, value, fieldKeys);
|
|
105
105
|
if (!selectedOptions) {
|
|
106
|
-
return "";
|
|
106
|
+
return isNullish(value) ? "" : String(value);
|
|
107
107
|
}
|
|
108
108
|
const labels = selectedOptions.map((option) => option[fieldKeys.label]);
|
|
109
109
|
return labels.join("/");
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
import {
|
|
110
110
|
defaultCropImageProps
|
|
111
111
|
} from "./common";
|
|
112
|
-
import { useDragPinch,
|
|
112
|
+
import { useDragPinch, useTimeout } from "../../use";
|
|
113
113
|
import { useTranslate } from "../locale";
|
|
114
114
|
import SarPopup from "../popup/popup.vue";
|
|
115
115
|
import SarIcon from "../icon/icon.vue";
|
|
@@ -186,23 +186,23 @@ export default _defineComponent({
|
|
|
186
186
|
});
|
|
187
187
|
const rotate = ref(0);
|
|
188
188
|
const actualRotate = ref(0);
|
|
189
|
-
const
|
|
189
|
+
const { start: onRotateEnd } = useTimeout(() => {
|
|
190
190
|
actualRotate.value = rotate.value;
|
|
191
|
-
});
|
|
191
|
+
}, 150 + 100);
|
|
192
192
|
watch(rotate, () => {
|
|
193
|
-
onRotateEnd(
|
|
193
|
+
onRotateEnd();
|
|
194
194
|
});
|
|
195
195
|
const isRotating = computed(() => rotate.value !== actualRotate.value);
|
|
196
196
|
const isStillRotating = ref(false);
|
|
197
|
-
const
|
|
197
|
+
const { start: stopRotateLater, stop: cancelStopRotate } = useTimeout(() => {
|
|
198
198
|
isStillRotating.value = false;
|
|
199
|
-
});
|
|
199
|
+
}, 150);
|
|
200
200
|
watch(isRotating, () => {
|
|
201
201
|
cancelStopRotate();
|
|
202
202
|
if (isRotating.value) {
|
|
203
203
|
isStillRotating.value = true;
|
|
204
204
|
} else {
|
|
205
|
-
stopRotateLater(
|
|
205
|
+
stopRotateLater();
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
const maskStyle = computed(() => {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type DialogProps } from '../dialog/common';
|
|
2
2
|
export interface DialogAgentProps extends DialogProps {
|
|
3
3
|
id?: string;
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
onCancel?: () => void;
|
|
6
|
+
onConfirm?: () => void;
|
|
4
7
|
}
|
|
5
8
|
export declare const defaultDialogAgentProps: () => {
|
|
6
9
|
id: string;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<sar-dialog
|
|
2
|
+
<sar-dialog
|
|
3
|
+
v-bind="innerProps"
|
|
4
|
+
v-model:visible="innerProps.visible"
|
|
5
|
+
@confirm="innerProps.onConfirm"
|
|
6
|
+
@close="innerProps.onClose"
|
|
7
|
+
@cancel="innerProps.onCancel"
|
|
8
|
+
/>
|
|
3
9
|
</template>
|
|
4
10
|
|
|
5
11
|
<script>
|
|
@@ -24,6 +30,9 @@ export default _defineComponent({
|
|
|
24
30
|
__name: "dialog-agent",
|
|
25
31
|
props: _mergeDefaults({
|
|
26
32
|
id: { type: String, required: false },
|
|
33
|
+
onClose: { type: Function, required: false },
|
|
34
|
+
onCancel: { type: Function, required: false },
|
|
35
|
+
onConfirm: { type: Function, required: false },
|
|
27
36
|
rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
28
37
|
rootClass: { type: String, required: false },
|
|
29
38
|
popupStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
|
|
@@ -23,6 +23,8 @@ export interface DropdownOption {
|
|
|
23
23
|
label?: string;
|
|
24
24
|
value?: any;
|
|
25
25
|
}
|
|
26
|
+
export type DropdownCloseType = 'overlay' | 'away' | 'other-button' | 'option' | 'button';
|
|
27
|
+
export type DropdownBeforeClose = (type: DropdownCloseType) => any | Promise<any>;
|
|
26
28
|
export interface DropdownItemProps {
|
|
27
29
|
rootStyle?: StyleValue;
|
|
28
30
|
rootClass?: string;
|
|
@@ -34,6 +36,7 @@ export interface DropdownItemProps {
|
|
|
34
36
|
visible?: boolean;
|
|
35
37
|
separator?: string;
|
|
36
38
|
placeholder?: string;
|
|
39
|
+
beforeClose?: DropdownBeforeClose;
|
|
37
40
|
}
|
|
38
41
|
export declare const defaultDropdownItemProps: {
|
|
39
42
|
options: () => never[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { DropdownProps, DropdownSlots, DropdownItemProps, DropdownItemSlots, DropdownItemEmits, } from './common';
|
|
1
|
+
export type { DropdownProps, DropdownSlots, DropdownItemProps, DropdownItemSlots, DropdownItemEmits, DropdownCloseType, DropdownBeforeClose, } from './common';
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
<slot>
|
|
48
48
|
<sar-list inlaid>
|
|
49
49
|
<sar-list-item
|
|
50
|
-
v-for="(
|
|
50
|
+
v-for="(option, i) in options"
|
|
51
51
|
:key="i"
|
|
52
|
-
:title="
|
|
52
|
+
:title="option.label"
|
|
53
53
|
hover
|
|
54
54
|
:root-class="
|
|
55
55
|
classNames(
|
|
56
56
|
bem.e('option'),
|
|
57
|
-
bem.em('option', 'active',
|
|
57
|
+
bem.em('option', 'active', option.value === innerValue),
|
|
58
58
|
)
|
|
59
59
|
"
|
|
60
|
-
@click="onOptionClick(
|
|
60
|
+
@click="onOptionClick(option)"
|
|
61
61
|
>
|
|
62
62
|
<template #arrow>
|
|
63
63
|
<view :class="bem.e('option-icon')">
|
|
@@ -91,7 +91,10 @@ import {
|
|
|
91
91
|
uniqid,
|
|
92
92
|
getBoundingClientRect,
|
|
93
93
|
getWindowInfo,
|
|
94
|
-
isNullish
|
|
94
|
+
isNullish,
|
|
95
|
+
isFunction,
|
|
96
|
+
isObject,
|
|
97
|
+
noop
|
|
95
98
|
} from "../../utils";
|
|
96
99
|
import SarList from "../list/list.vue";
|
|
97
100
|
import SarListItem from "../list-item/list-item.vue";
|
|
@@ -126,7 +129,8 @@ export default _defineComponent({
|
|
|
126
129
|
modelValue: { type: null, required: false },
|
|
127
130
|
visible: { type: Boolean, required: false },
|
|
128
131
|
separator: { type: String, required: false },
|
|
129
|
-
placeholder: { type: String, required: false }
|
|
132
|
+
placeholder: { type: String, required: false },
|
|
133
|
+
beforeClose: { type: Function, required: false }
|
|
130
134
|
}, defaultDropdownItemProps),
|
|
131
135
|
emits: ["update:model-value", "change", "update:visible", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
|
|
132
136
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -206,34 +210,55 @@ export default _defineComponent({
|
|
|
206
210
|
emit("update:visible", visible);
|
|
207
211
|
}
|
|
208
212
|
};
|
|
213
|
+
let isClosing = false;
|
|
214
|
+
const perhapsClose = (type) => {
|
|
215
|
+
if (isClosing) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (isFunction(props.beforeClose)) {
|
|
219
|
+
const result = props.beforeClose(type);
|
|
220
|
+
if (isObject(result) && isFunction(result.then)) {
|
|
221
|
+
isClosing = true;
|
|
222
|
+
return result.then(() => {
|
|
223
|
+
setInnerVisible(false);
|
|
224
|
+
}).catch(noop);
|
|
225
|
+
} else if (result === false) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
setInnerVisible(false);
|
|
230
|
+
};
|
|
209
231
|
const onItemClick = () => {
|
|
210
232
|
if (!context.disabled && !props.disabled) {
|
|
211
|
-
|
|
233
|
+
if (innerVisible.value) {
|
|
234
|
+
perhapsClose("button");
|
|
235
|
+
} else {
|
|
236
|
+
setInnerVisible(true);
|
|
237
|
+
}
|
|
212
238
|
}
|
|
213
239
|
};
|
|
214
|
-
const onOptionClick = (
|
|
215
|
-
if (
|
|
216
|
-
innerValue.value =
|
|
217
|
-
emit("update:model-value",
|
|
218
|
-
emit("change",
|
|
240
|
+
const onOptionClick = (option) => {
|
|
241
|
+
if (option.value !== innerValue.value) {
|
|
242
|
+
innerValue.value = option.value;
|
|
243
|
+
emit("update:model-value", option.value);
|
|
244
|
+
emit("change", option.value);
|
|
219
245
|
}
|
|
220
|
-
|
|
246
|
+
perhapsClose("option");
|
|
221
247
|
};
|
|
222
248
|
const onOverlayClick = () => {
|
|
223
249
|
if (context.overlayClosable) {
|
|
224
|
-
|
|
250
|
+
perhapsClose("overlay");
|
|
225
251
|
}
|
|
226
252
|
};
|
|
227
253
|
const onAwayClick = () => {
|
|
228
254
|
if (context.awayClosable) {
|
|
229
|
-
|
|
255
|
+
perhapsClose("away");
|
|
230
256
|
}
|
|
231
257
|
};
|
|
232
|
-
const onAfterLeave = () => {
|
|
233
|
-
wholeVisible.value = false;
|
|
234
|
-
};
|
|
235
258
|
const hide = () => {
|
|
236
|
-
|
|
259
|
+
if (innerVisible.value) {
|
|
260
|
+
perhapsClose("other-button");
|
|
261
|
+
}
|
|
237
262
|
};
|
|
238
263
|
onMounted(() => {
|
|
239
264
|
context.register(instance, {
|
|
@@ -252,7 +277,10 @@ export default _defineComponent({
|
|
|
252
277
|
increaseZIndex();
|
|
253
278
|
}
|
|
254
279
|
if (name === "after-leave") {
|
|
255
|
-
|
|
280
|
+
wholeVisible.value = false;
|
|
281
|
+
}
|
|
282
|
+
if (name === "leave-cancelled" || name === "after-leave") {
|
|
283
|
+
isClosing = false;
|
|
256
284
|
}
|
|
257
285
|
emit("visible-hook", name);
|
|
258
286
|
emit(name);
|
|
@@ -298,7 +326,11 @@ export default _defineComponent({
|
|
|
298
326
|
const dropdownItemStyle = computed(() => {
|
|
299
327
|
return stringifyStyle(props.rootStyle);
|
|
300
328
|
});
|
|
301
|
-
const __returned__ = { props, emit, bem, context, itemId, instance, innerValue, innerVisible, wholeVisible, popupVisible, popupInset, awayInset, setPosition, setInnerVisible,
|
|
329
|
+
const __returned__ = { props, emit, bem, context, itemId, instance, innerValue, innerVisible, wholeVisible, popupVisible, popupInset, awayInset, setPosition, setInnerVisible, get isClosing() {
|
|
330
|
+
return isClosing;
|
|
331
|
+
}, set isClosing(v) {
|
|
332
|
+
isClosing = v;
|
|
333
|
+
}, perhapsClose, onItemClick, onOptionClick, onOverlayClick, onAwayClick, hide, zIndex, increaseZIndex, realVisible, transitionClass, onTransitionEnd, popupClass, popupStyle, currentLabel, currentArrow, popupEffect, dropdownItemClass, dropdownItemStyle, get classNames() {
|
|
302
334
|
return classNames;
|
|
303
335
|
}, get isNullish() {
|
|
304
336
|
return isNullish;
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import {
|
|
29
29
|
defaultFloatingBubbleProps
|
|
30
30
|
} from "./common";
|
|
31
|
-
import { useMouseDown,
|
|
31
|
+
import { useMouseDown, useTimeout } from "../../use";
|
|
32
32
|
export default _defineComponent({
|
|
33
33
|
...{
|
|
34
34
|
options: {
|
|
@@ -74,9 +74,9 @@ export default _defineComponent({
|
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
76
|
const animated = ref(false);
|
|
77
|
-
const
|
|
77
|
+
const { start: nonAnimatedLater, stop: cancelNonAnimated } = useTimeout(() => {
|
|
78
78
|
animated.value = false;
|
|
79
|
-
});
|
|
79
|
+
}, 500);
|
|
80
80
|
function getMinX() {
|
|
81
81
|
return props.gapX;
|
|
82
82
|
}
|
|
@@ -154,7 +154,7 @@ export default _defineComponent({
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
animated.value = true;
|
|
157
|
-
nonAnimatedLater(
|
|
157
|
+
nonAnimatedLater();
|
|
158
158
|
bubbleRect = void 0;
|
|
159
159
|
};
|
|
160
160
|
const onMouseDown = useMouseDown(onTouchStart, onTouchMove, onTouchEnd);
|
package/components/form/form.vue
CHANGED
|
@@ -116,7 +116,10 @@ export default _defineComponent({
|
|
|
116
116
|
fields.push(formItemContext);
|
|
117
117
|
};
|
|
118
118
|
const removeField = (formItemContext) => {
|
|
119
|
-
fields.
|
|
119
|
+
const index = fields.indexOf(formItemContext);
|
|
120
|
+
if (index !== -1) {
|
|
121
|
+
fields.splice(index, 1);
|
|
122
|
+
}
|
|
120
123
|
};
|
|
121
124
|
const validator = markRaw(new Validator());
|
|
122
125
|
const { select } = useTranslate("form.defaultValidateMessages");
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
flex-direction: row;
|
|
7
7
|
padding: var(--sar-form-item-padding-y) var(--sar-form-item-padding-x);
|
|
8
8
|
|
|
9
|
+
&:first-child {
|
|
10
|
+
border-top-left-radius: inherit;
|
|
11
|
+
border-top-right-radius: inherit;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:last-child {
|
|
15
|
+
border-bottom-left-radius: inherit;
|
|
16
|
+
border-bottom-right-radius: inherit;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
&:not(:first-child) {
|
|
10
20
|
&::before {
|
|
11
21
|
@include border-top(var(--sar-form-item-border-color));
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
defaultMarqueeProps
|
|
21
21
|
} from "./common";
|
|
22
|
-
import {
|
|
22
|
+
import { useTimeout } from "../../use";
|
|
23
23
|
export default _defineComponent({
|
|
24
24
|
...{
|
|
25
25
|
options: {
|
|
@@ -49,11 +49,14 @@ export default _defineComponent({
|
|
|
49
49
|
const size = props.direction === "vertical" ? height : width;
|
|
50
50
|
duration.value = size / props.speed * 1e3;
|
|
51
51
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const { start: updateLater } = useTimeout(
|
|
53
|
+
() => {
|
|
54
|
+
update();
|
|
55
|
+
},
|
|
56
|
+
() => props.delay
|
|
57
|
+
);
|
|
55
58
|
onMounted(() => {
|
|
56
|
-
updateLater(
|
|
59
|
+
updateLater();
|
|
57
60
|
});
|
|
58
61
|
__expose({
|
|
59
62
|
update
|
|
@@ -44,7 +44,7 @@ import SarIcon from "../icon/icon.vue";
|
|
|
44
44
|
import {
|
|
45
45
|
defaultNoticeBarProps
|
|
46
46
|
} from "./common";
|
|
47
|
-
import {
|
|
47
|
+
import { useTimeout } from "../../use";
|
|
48
48
|
export default _defineComponent({
|
|
49
49
|
components: {
|
|
50
50
|
SarIcon,
|
|
@@ -120,12 +120,15 @@ export default _defineComponent({
|
|
|
120
120
|
emit("close");
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
const { start: updateLater } = useTimeout(
|
|
124
|
+
() => {
|
|
125
|
+
update();
|
|
126
|
+
},
|
|
127
|
+
() => props.delay
|
|
128
|
+
);
|
|
126
129
|
onMounted(() => {
|
|
127
130
|
if (props.scrollable) {
|
|
128
|
-
updateLater(
|
|
131
|
+
updateLater();
|
|
129
132
|
}
|
|
130
133
|
});
|
|
131
134
|
const onClick = (event) => {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
|
|
17
17
|
import { computed, ref, watch, nextTick } from "vue";
|
|
18
18
|
import { classNames, stringifyStyle, createBem } from "../../utils";
|
|
19
|
-
import {
|
|
19
|
+
import { useTimeout } from "../../use";
|
|
20
20
|
import {
|
|
21
21
|
defaultNotifyProps
|
|
22
22
|
} from "./common";
|
|
@@ -59,15 +59,18 @@ export default _defineComponent({
|
|
|
59
59
|
}[props.position];
|
|
60
60
|
});
|
|
61
61
|
const innerVisible = ref(props.visible);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const { start: hideLater, stop: cancelHide } = useTimeout(
|
|
63
|
+
() => {
|
|
64
|
+
innerVisible.value = false;
|
|
65
|
+
emit("update:visible", false);
|
|
66
|
+
},
|
|
67
|
+
() => props.timeout
|
|
68
|
+
);
|
|
66
69
|
const reHideLater = () => {
|
|
67
70
|
cancelHide();
|
|
68
71
|
nextTick(() => {
|
|
69
72
|
if (props.timeout > 0) {
|
|
70
|
-
hideLater(
|
|
73
|
+
hideLater();
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
76
|
};
|
|
@@ -77,7 +80,7 @@ export default _defineComponent({
|
|
|
77
80
|
innerVisible.value = props.visible;
|
|
78
81
|
if (props.visible) {
|
|
79
82
|
if (props.timeout > 0) {
|
|
80
|
-
hideLater(
|
|
83
|
+
hideLater();
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
}
|
|
@@ -79,7 +79,7 @@ import { classNames, stringifyStyle, createBem } from "../../utils";
|
|
|
79
79
|
import {
|
|
80
80
|
defaultPullDownRefreshProps
|
|
81
81
|
} from "./common";
|
|
82
|
-
import { useMouseDown,
|
|
82
|
+
import { useMouseDown, useTimeout } from "../../use";
|
|
83
83
|
import SarLoading from "../loading/loading.vue";
|
|
84
84
|
export default _defineComponent({
|
|
85
85
|
components: {
|
|
@@ -113,12 +113,18 @@ export default _defineComponent({
|
|
|
113
113
|
const progress = computed(() => {
|
|
114
114
|
return Math.min(translateY.value / props.threshold, 1);
|
|
115
115
|
});
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
const { start: toInitialLater, stop: cancelToInitial } = useTimeout(
|
|
117
|
+
() => {
|
|
118
|
+
status.value = "initial";
|
|
119
|
+
},
|
|
120
|
+
() => props.transitionDuration
|
|
121
|
+
);
|
|
122
|
+
const { start: toRecoveringLater, stop: cancelToRecovering } = useTimeout(
|
|
123
|
+
() => {
|
|
124
|
+
toRecovering();
|
|
125
|
+
},
|
|
126
|
+
() => props.doneDuration
|
|
127
|
+
);
|
|
122
128
|
const toLoading = () => {
|
|
123
129
|
cancelToRecovering();
|
|
124
130
|
cancelToInitial();
|
|
@@ -128,11 +134,11 @@ export default _defineComponent({
|
|
|
128
134
|
const toRecovering = () => {
|
|
129
135
|
status.value = "recovering";
|
|
130
136
|
translateY.value = 0;
|
|
131
|
-
toInitialLater(
|
|
137
|
+
toInitialLater();
|
|
132
138
|
};
|
|
133
139
|
const toDone = () => {
|
|
134
140
|
status.value = "done";
|
|
135
|
-
toRecoveringLater(
|
|
141
|
+
toRecoveringLater();
|
|
136
142
|
};
|
|
137
143
|
watch(
|
|
138
144
|
() => props.loading,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type StyleValue } from 'vue';
|
|
2
|
+
export type SwipeActionVisible = 'left' | 'right' | false;
|
|
3
|
+
export interface SwipeActionProps {
|
|
4
|
+
rootStyle?: StyleValue;
|
|
5
|
+
rootClass?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
visible?: SwipeActionVisible;
|
|
8
|
+
}
|
|
9
|
+
export interface SwipeActionSlots {
|
|
10
|
+
default?(props: Record<string, never>): any;
|
|
11
|
+
left?(props: {
|
|
12
|
+
hide: () => void;
|
|
13
|
+
}): any;
|
|
14
|
+
right?(props: {
|
|
15
|
+
hide: () => void;
|
|
16
|
+
}): any;
|
|
17
|
+
}
|
|
18
|
+
export interface SwipeActionEmits {
|
|
19
|
+
(e: 'update:visible', value: SwipeActionVisible): void;
|
|
20
|
+
}
|
|
21
|
+
export interface SwipeActionExpose {
|
|
22
|
+
hide: () => void;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { SwipeActionProps, SwipeActionSlots, SwipeActionEmits, SwipeActionExpose, SwipeActionVisible, } from './common';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@use '../style/base' as *;
|
|
2
|
+
|
|
3
|
+
@include bem(swipe-action) {
|
|
4
|
+
@include b() {
|
|
5
|
+
@include universal;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@include e(content) {
|
|
10
|
+
@include universal;
|
|
11
|
+
cursor: grab;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@include e(actions) {
|
|
15
|
+
@include universal;
|
|
16
|
+
position: absolute;
|
|
17
|
+
left: 0;
|
|
18
|
+
top: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@include e(actions-wrapper) {
|
|
26
|
+
@include universal;
|
|
27
|
+
position: absolute;
|
|
28
|
+
left: 0;
|
|
29
|
+
top: 0;
|
|
30
|
+
right: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@include e(left, right) {
|
|
35
|
+
@include universal;
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 0;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
pointer-events: auto;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@include e(left) {
|
|
45
|
+
left: 0;
|
|
46
|
+
transform: translateX(-100%);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@include e(right) {
|
|
50
|
+
right: 0;
|
|
51
|
+
transform: translateX(100%);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type SwipeActionProps, type SwipeActionSlots, type SwipeActionVisible } from './common';
|
|
2
|
+
declare function __VLS_template(): Readonly<SwipeActionSlots> & SwipeActionSlots;
|
|
3
|
+
declare const __VLS_component: import("vue").DefineComponent<SwipeActionProps, {
|
|
4
|
+
hide: () => void;
|
|
5
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
6
|
+
"update:visible": (value: SwipeActionVisible) => any;
|
|
7
|
+
}, string, import("vue").PublicProps, Readonly<SwipeActionProps> & Readonly<{
|
|
8
|
+
"onUpdate:visible"?: ((value: SwipeActionVisible) => any) | undefined;
|
|
9
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|