zartui 3.1.23-beta.1 → 3.1.23-beta.2
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/es/audio/Audio.d.ts +82 -0
- package/es/audio/Audio.mjs +224 -0
- package/es/audio/index.css +1 -0
- package/es/audio/index.d.ts +66 -0
- package/es/audio/index.mjs +10 -0
- package/es/audio/style/index.d.ts +1 -0
- package/es/audio/style/index.mjs +5 -0
- package/es/audio/types.d.ts +3 -0
- package/es/audio/types.mjs +4 -0
- package/es/icon/config.mjs +1 -0
- package/es/icon/index.css +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.mjs +4 -1
- package/es/slider/Slider.d.ts +29 -3
- package/es/slider/Slider.mjs +15 -5
- package/es/slider/index.d.ts +21 -3
- package/es/stepper/Stepper.d.ts +2 -2
- package/es/stepper/index.d.ts +2 -2
- package/es/swipe/Swipe.d.ts +2 -2
- package/es/swipe/index.d.ts +2 -2
- package/es/table/Table.mjs +13 -2
- package/es/utils/format.d.ts +1 -0
- package/es/utils/format.mjs +15 -0
- package/es/video/Video.mjs +4 -25
- package/lib/audio/Audio.d.ts +82 -0
- package/lib/audio/Audio.js +253 -0
- package/lib/audio/index.css +1 -0
- package/lib/audio/index.d.ts +66 -0
- package/lib/audio/index.js +39 -0
- package/lib/audio/style/index.d.ts +1 -0
- package/lib/audio/style/index.js +5 -0
- package/lib/audio/types.d.ts +3 -0
- package/lib/audio/types.js +23 -0
- package/lib/icon/config.js +1 -0
- package/lib/icon/index.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +4 -1
- package/lib/slider/Slider.d.ts +29 -3
- package/lib/slider/Slider.js +14 -4
- package/lib/slider/index.d.ts +21 -3
- package/lib/stepper/Stepper.d.ts +2 -2
- package/lib/stepper/index.d.ts +2 -2
- package/lib/swipe/Swipe.d.ts +2 -2
- package/lib/swipe/index.d.ts +2 -2
- package/lib/table/Table.js +13 -2
- package/lib/utils/format.d.ts +1 -0
- package/lib/utils/format.js +15 -0
- package/lib/video/Video.js +3 -24
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +2349 -2114
- package/lib/zartui.es.js +2350 -2115
- package/lib/zartui.js +11344 -11109
- package/lib/zartui.min.js +1 -1
- package/package.json +81 -81
package/es/slider/Slider.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, createVNode as _createVNode } from "vue";
|
|
2
2
|
import { ref, computed, defineComponent } from "vue";
|
|
3
|
-
import { clamp, addUnit, addNumber, numericProp, isSameValue, getSizeStyle, preventDefault, stopPropagation, createNamespace, makeNumericProp, makeStringProp, truthProp } from "../utils/index.mjs";
|
|
3
|
+
import { clamp, addUnit, addNumber, numericProp, isSameValue, getSizeStyle, preventDefault, stopPropagation, createNamespace, makeNumericProp, makeStringProp, truthProp, makeNumberProp } from "../utils/index.mjs";
|
|
4
4
|
import { useRect, useCustomFieldValue, useEventListener } from "@zartui/use";
|
|
5
5
|
import { useTouch } from "../composables/use-touch.mjs";
|
|
6
6
|
const [name, bem] = createNamespace("slider");
|
|
@@ -24,7 +24,10 @@ const sliderProps = {
|
|
|
24
24
|
title: String,
|
|
25
25
|
// 标题跟进度与主体进度条的排列方式
|
|
26
26
|
direction: makeStringProp("horizontal"),
|
|
27
|
-
showPercent: truthProp
|
|
27
|
+
showPercent: truthProp,
|
|
28
|
+
// 进度条在边缘时,为了防止进度条显示被挤压,对进度条边缘进行扩充,扩充的宽度
|
|
29
|
+
barEdgeOffset: makeNumberProp(4),
|
|
30
|
+
barEdgeOffsetBoundary: makeNumberProp(10)
|
|
28
31
|
};
|
|
29
32
|
var stdin_default = defineComponent({
|
|
30
33
|
name,
|
|
@@ -50,15 +53,21 @@ var stdin_default = defineComponent({
|
|
|
50
53
|
};
|
|
51
54
|
});
|
|
52
55
|
const isRange = (val) => props.range && Array.isArray(val);
|
|
56
|
+
function calcBarWidthInEdge(originWidth) {
|
|
57
|
+
if (originWidth < props.barEdgeOffsetBoundary && originWidth > 0) {
|
|
58
|
+
return props.barEdgeOffset + originWidth;
|
|
59
|
+
}
|
|
60
|
+
return originWidth;
|
|
61
|
+
}
|
|
53
62
|
const calcMainAxis = () => {
|
|
54
63
|
const {
|
|
55
64
|
modelValue,
|
|
56
65
|
min
|
|
57
66
|
} = props;
|
|
58
67
|
if (isRange(modelValue)) {
|
|
59
|
-
return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
|
68
|
+
return `${calcBarWidthInEdge(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
|
60
69
|
}
|
|
61
|
-
return `${(modelValue - Number(min)) * 100 / scope.value}%`;
|
|
70
|
+
return `${calcBarWidthInEdge(modelValue - Number(min)) * 100 / scope.value}%`;
|
|
62
71
|
};
|
|
63
72
|
const calcOffset = () => {
|
|
64
73
|
const {
|
|
@@ -66,7 +75,8 @@ var stdin_default = defineComponent({
|
|
|
66
75
|
min
|
|
67
76
|
} = props;
|
|
68
77
|
if (isRange(modelValue)) {
|
|
69
|
-
|
|
78
|
+
const diff = modelValue[0] - Number(min);
|
|
79
|
+
return `${diff * 100 / scope.value}%`;
|
|
70
80
|
}
|
|
71
81
|
return "0%";
|
|
72
82
|
};
|
package/es/slider/index.d.ts
CHANGED
|
@@ -36,7 +36,15 @@ export declare const Slider: import("../utils").WithInstall<import("vue").Define
|
|
|
36
36
|
type: BooleanConstructor;
|
|
37
37
|
default: true;
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
barEdgeOffset: {
|
|
40
|
+
type: NumberConstructor;
|
|
41
|
+
default: number;
|
|
42
|
+
};
|
|
43
|
+
barEdgeOffsetBoundary: {
|
|
44
|
+
type: NumberConstructor;
|
|
45
|
+
default: number;
|
|
46
|
+
};
|
|
47
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "change" | "dragEnd" | "dragStart")[], "update:modelValue" | "change" | "dragEnd" | "dragStart", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
48
|
min: {
|
|
41
49
|
type: (NumberConstructor | StringConstructor)[];
|
|
42
50
|
default: number;
|
|
@@ -74,11 +82,19 @@ export declare const Slider: import("../utils").WithInstall<import("vue").Define
|
|
|
74
82
|
type: BooleanConstructor;
|
|
75
83
|
default: true;
|
|
76
84
|
};
|
|
85
|
+
barEdgeOffset: {
|
|
86
|
+
type: NumberConstructor;
|
|
87
|
+
default: number;
|
|
88
|
+
};
|
|
89
|
+
barEdgeOffsetBoundary: {
|
|
90
|
+
type: NumberConstructor;
|
|
91
|
+
default: number;
|
|
92
|
+
};
|
|
77
93
|
}>> & {
|
|
78
94
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
79
95
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
80
|
-
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
81
96
|
onDragEnd?: ((...args: any[]) => any) | undefined;
|
|
97
|
+
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
82
98
|
}, {
|
|
83
99
|
reverse: boolean;
|
|
84
100
|
range: boolean;
|
|
@@ -88,9 +104,11 @@ export declare const Slider: import("../utils").WithInstall<import("vue").Define
|
|
|
88
104
|
direction: import("./Slider").SliderDirection;
|
|
89
105
|
modelValue: number | [number, number];
|
|
90
106
|
readonly: boolean;
|
|
91
|
-
step: string | number;
|
|
92
107
|
min: string | number;
|
|
108
|
+
step: string | number;
|
|
93
109
|
showPercent: boolean;
|
|
110
|
+
barEdgeOffset: number;
|
|
111
|
+
barEdgeOffsetBoundary: number;
|
|
94
112
|
}, {}>>;
|
|
95
113
|
export default Slider;
|
|
96
114
|
export { sliderProps } from './Slider';
|
package/es/stepper/Stepper.d.ts
CHANGED
|
@@ -165,9 +165,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
165
165
|
name: string | number;
|
|
166
166
|
max: string | number;
|
|
167
167
|
disabled: boolean;
|
|
168
|
-
longPress: boolean;
|
|
169
|
-
step: string | number;
|
|
170
168
|
min: string | number;
|
|
169
|
+
step: string | number;
|
|
170
|
+
longPress: boolean;
|
|
171
171
|
integer: boolean;
|
|
172
172
|
showPlus: boolean;
|
|
173
173
|
showMinus: boolean;
|
package/es/stepper/index.d.ts
CHANGED
|
@@ -110,9 +110,9 @@ export declare const Stepper: import("../utils").WithInstall<import("vue").Defin
|
|
|
110
110
|
name: string | number;
|
|
111
111
|
max: string | number;
|
|
112
112
|
disabled: boolean;
|
|
113
|
-
longPress: boolean;
|
|
114
|
-
step: string | number;
|
|
115
113
|
min: string | number;
|
|
114
|
+
step: string | number;
|
|
115
|
+
longPress: boolean;
|
|
116
116
|
integer: boolean;
|
|
117
117
|
showPlus: boolean;
|
|
118
118
|
showMinus: boolean;
|
package/es/swipe/Swipe.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
73
73
|
default: true;
|
|
74
74
|
};
|
|
75
75
|
title: ArrayConstructor;
|
|
76
|
-
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "
|
|
76
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "dragEnd" | "dragStart")[], "change" | "dragEnd" | "dragStart", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
77
77
|
loop: {
|
|
78
78
|
type: BooleanConstructor;
|
|
79
79
|
default: true;
|
|
@@ -110,8 +110,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
110
110
|
title: ArrayConstructor;
|
|
111
111
|
}>> & {
|
|
112
112
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
113
|
-
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
114
113
|
onDragEnd?: ((...args: any[]) => any) | undefined;
|
|
114
|
+
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
115
115
|
}, {
|
|
116
116
|
autoplay: string | number;
|
|
117
117
|
loop: boolean;
|
package/es/swipe/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const Swipe: import("../utils").WithInstall<import("vue").DefineC
|
|
|
34
34
|
default: true;
|
|
35
35
|
};
|
|
36
36
|
title: ArrayConstructor;
|
|
37
|
-
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "
|
|
37
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "dragEnd" | "dragStart")[], "change" | "dragEnd" | "dragStart", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
38
38
|
loop: {
|
|
39
39
|
type: BooleanConstructor;
|
|
40
40
|
default: true;
|
|
@@ -71,8 +71,8 @@ export declare const Swipe: import("../utils").WithInstall<import("vue").DefineC
|
|
|
71
71
|
title: ArrayConstructor;
|
|
72
72
|
}>> & {
|
|
73
73
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
74
|
-
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
75
74
|
onDragEnd?: ((...args: any[]) => any) | undefined;
|
|
75
|
+
onDragStart?: ((...args: any[]) => any) | undefined;
|
|
76
76
|
}, {
|
|
77
77
|
autoplay: string | number;
|
|
78
78
|
loop: boolean;
|
package/es/table/Table.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { Icon } from "../icon/index.mjs";
|
|
|
5
5
|
import { SortOrderEnum } from "./types.mjs";
|
|
6
6
|
import TextEllipsis from "../text-ellipsis/index.mjs";
|
|
7
7
|
const [name, bem] = createNamespace("table");
|
|
8
|
+
const BODY_CELL_SLOTS_NAME = "bodyCell";
|
|
8
9
|
const tableProps = {
|
|
9
10
|
headList: makeArrayProp(),
|
|
10
11
|
dataList: makeArrayProp(),
|
|
@@ -151,10 +152,20 @@ var stdin_default = defineComponent({
|
|
|
151
152
|
}, null)]) : ""])]);
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
|
-
const getElement = (rowData, colData) => {
|
|
155
|
+
const getElement = (rowData, colData, rowIndex) => {
|
|
155
156
|
if (rowData[colData.key] && rowData[colData.key].id && slots[`data-${rowData[colData.key].id}`]) {
|
|
156
157
|
return slots[`data-${rowData[colData.key].id}`](rowData[colData.key]);
|
|
157
158
|
}
|
|
159
|
+
const slotProps = {
|
|
160
|
+
column: colData,
|
|
161
|
+
record: rowData,
|
|
162
|
+
text: rowData[colData.key],
|
|
163
|
+
index: rowIndex
|
|
164
|
+
};
|
|
165
|
+
const bodyCellSlots = slots[BODY_CELL_SLOTS_NAME] && slots[BODY_CELL_SLOTS_NAME](slotProps);
|
|
166
|
+
if (bodyCellSlots && bodyCellSlots.length) {
|
|
167
|
+
return bodyCellSlots[0];
|
|
168
|
+
}
|
|
158
169
|
return colData.ellipsis ? _createVNode(TextEllipsis, {
|
|
159
170
|
"content": rowData[colData.key],
|
|
160
171
|
"expandType": "dialog"
|
|
@@ -176,7 +187,7 @@ var stdin_default = defineComponent({
|
|
|
176
187
|
"colspan": (additionalCellProps == null ? void 0 : additionalCellProps.colSpan) !== 1 ? additionalCellProps == null ? void 0 : additionalCellProps.colSpan : null,
|
|
177
188
|
"rowspan": (additionalCellProps == null ? void 0 : additionalCellProps.rowSpan) !== 1 ? additionalCellProps == null ? void 0 : additionalCellProps.rowSpan : null,
|
|
178
189
|
"style": style
|
|
179
|
-
}, [getElement(rowData, colData)]);
|
|
190
|
+
}, [getElement(rowData, colData, rowIndex)]);
|
|
180
191
|
})]);
|
|
181
192
|
const getCol = () => {
|
|
182
193
|
const cols = [];
|
package/es/utils/format.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare function padZero(num: Numeric, targetLength?: number): string;
|
|
|
11
11
|
export declare const clamp: (num: number, min: number, max: number) => number;
|
|
12
12
|
export declare function formatNumber(value: string, allowDot?: boolean, allowMinus?: boolean): string;
|
|
13
13
|
export declare function addNumber(num1: number, num2: number): number;
|
|
14
|
+
export declare function formatSeconds(value?: string | number): string;
|
package/es/utils/format.mjs
CHANGED
|
@@ -106,12 +106,27 @@ function addNumber(num1, num2) {
|
|
|
106
106
|
const cardinal = 10 ** 10;
|
|
107
107
|
return Math.round((num1 + num2) * cardinal) / cardinal;
|
|
108
108
|
}
|
|
109
|
+
function formatSeconds(value = 0) {
|
|
110
|
+
if (!value) {
|
|
111
|
+
return "00:00:00";
|
|
112
|
+
}
|
|
113
|
+
const time = typeof value === "number" ? value : parseInt(value);
|
|
114
|
+
const hours = Math.floor(time / 3600);
|
|
115
|
+
const minutes = Math.floor((time - hours * 3600) / 60);
|
|
116
|
+
const seconds = time - hours * 3600 - minutes * 60;
|
|
117
|
+
let result = "";
|
|
118
|
+
result += ("0" + hours.toString()).slice(-2) + ":";
|
|
119
|
+
result += ("0" + minutes.toString()).slice(-2) + ":";
|
|
120
|
+
result += ("0" + seconds.toString()).slice(-2);
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
109
123
|
export {
|
|
110
124
|
addNumber,
|
|
111
125
|
addUnit,
|
|
112
126
|
camelize,
|
|
113
127
|
clamp,
|
|
114
128
|
formatNumber,
|
|
129
|
+
formatSeconds,
|
|
115
130
|
getSizeStyle,
|
|
116
131
|
getZIndexStyle,
|
|
117
132
|
kebabCase,
|
package/es/video/Video.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import { useExpose } from "../composables/use-expose.mjs";
|
|
|
4
4
|
import { useGlobalZIndex } from "../composables/use-global-z-index.mjs";
|
|
5
5
|
import Icon from "../icon/index.mjs";
|
|
6
6
|
import { throttle } from "../lazyload/vue-lazyload/util.mjs";
|
|
7
|
-
import { createNamespace, makeStringProp } from "../utils/index.mjs";
|
|
7
|
+
import { createNamespace, makeStringProp, formatSeconds } from "../utils/index.mjs";
|
|
8
8
|
const [name, bem] = createNamespace("video");
|
|
9
9
|
const videoProps = {
|
|
10
|
-
src: makeStringProp("
|
|
10
|
+
src: makeStringProp(""),
|
|
11
11
|
// 控制控制器和标题的显示
|
|
12
12
|
showToolBox: Boolean,
|
|
13
13
|
options: {
|
|
@@ -174,27 +174,6 @@ var stdin_default = defineComponent({
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
|
-
const timeFormat = (t = 0) => {
|
|
178
|
-
let h = Math.floor(t / 3600);
|
|
179
|
-
if (+h < 10) {
|
|
180
|
-
h = "0" + h;
|
|
181
|
-
}
|
|
182
|
-
let m = Math.floor(t % 3600 / 60);
|
|
183
|
-
if (+m < 10) {
|
|
184
|
-
m = "0" + m;
|
|
185
|
-
}
|
|
186
|
-
let s = Math.round(t % 3600 % 60);
|
|
187
|
-
if (+s < 10) {
|
|
188
|
-
s = "0" + s;
|
|
189
|
-
}
|
|
190
|
-
let str = "";
|
|
191
|
-
if (h != 0) {
|
|
192
|
-
str = h + ":" + m + ":" + s;
|
|
193
|
-
} else {
|
|
194
|
-
str = m + ":" + s;
|
|
195
|
-
}
|
|
196
|
-
return str;
|
|
197
|
-
};
|
|
198
177
|
const getLoadTime = () => {
|
|
199
178
|
var _a, _b;
|
|
200
179
|
state.videoSet.loaded = (((_a = root.value) == null ? void 0 : _a.buffered.end(0)) || 0) / (((_b = root.value) == null ? void 0 : _b.duration) || 1) * 100;
|
|
@@ -205,8 +184,8 @@ var stdin_default = defineComponent({
|
|
|
205
184
|
const currentTime = Number.isNaN((_c = root.value) == null ? void 0 : _c.currentTime) ? 0 : (_d = root.value) == null ? void 0 : _d.currentTime;
|
|
206
185
|
const percent = (currentTime || 0) / (durationTime || 1);
|
|
207
186
|
state.videoSet.progress.current = Math.round(state.videoSet.progress.width * percent);
|
|
208
|
-
state.videoSet.totalTime =
|
|
209
|
-
state.videoSet.displayTime =
|
|
187
|
+
state.videoSet.totalTime = formatSeconds(durationTime);
|
|
188
|
+
state.videoSet.displayTime = formatSeconds((_e = root.value) == null ? void 0 : _e.currentTime);
|
|
210
189
|
emit("time", currentTime, durationTime, state.videoSet.displayTime, state.videoSet.totalTime);
|
|
211
190
|
};
|
|
212
191
|
const playEnded = () => {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import { AudioType } from './types';
|
|
3
|
+
declare const audioProps: {
|
|
4
|
+
src: {
|
|
5
|
+
type: import("vue").PropType<string>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
muted: BooleanConstructor;
|
|
9
|
+
autoplay: BooleanConstructor;
|
|
10
|
+
loop: BooleanConstructor;
|
|
11
|
+
preload: {
|
|
12
|
+
type: import("vue").PropType<string>;
|
|
13
|
+
default: string;
|
|
14
|
+
};
|
|
15
|
+
second: {
|
|
16
|
+
type: NumberConstructor;
|
|
17
|
+
default: number;
|
|
18
|
+
};
|
|
19
|
+
type: {
|
|
20
|
+
type: import("vue").PropType<AudioType>;
|
|
21
|
+
default: AudioType;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type AudioProps = ExtractPropTypes<typeof audioProps>;
|
|
25
|
+
declare const _default: import("vue").DefineComponent<{
|
|
26
|
+
src: {
|
|
27
|
+
type: import("vue").PropType<string>;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
muted: BooleanConstructor;
|
|
31
|
+
autoplay: BooleanConstructor;
|
|
32
|
+
loop: BooleanConstructor;
|
|
33
|
+
preload: {
|
|
34
|
+
type: import("vue").PropType<string>;
|
|
35
|
+
default: string;
|
|
36
|
+
};
|
|
37
|
+
second: {
|
|
38
|
+
type: NumberConstructor;
|
|
39
|
+
default: number;
|
|
40
|
+
};
|
|
41
|
+
type: {
|
|
42
|
+
type: import("vue").PropType<AudioType>;
|
|
43
|
+
default: AudioType;
|
|
44
|
+
};
|
|
45
|
+
}, () => import("vue/jsx-runtime").JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("ended" | "play" | "forward" | "mute" | "fastBack" | "changeProgress" | "canPlay")[], "ended" | "play" | "forward" | "mute" | "fastBack" | "changeProgress" | "canPlay", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
|
46
|
+
src: {
|
|
47
|
+
type: import("vue").PropType<string>;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
muted: BooleanConstructor;
|
|
51
|
+
autoplay: BooleanConstructor;
|
|
52
|
+
loop: BooleanConstructor;
|
|
53
|
+
preload: {
|
|
54
|
+
type: import("vue").PropType<string>;
|
|
55
|
+
default: string;
|
|
56
|
+
};
|
|
57
|
+
second: {
|
|
58
|
+
type: NumberConstructor;
|
|
59
|
+
default: number;
|
|
60
|
+
};
|
|
61
|
+
type: {
|
|
62
|
+
type: import("vue").PropType<AudioType>;
|
|
63
|
+
default: AudioType;
|
|
64
|
+
};
|
|
65
|
+
}>> & {
|
|
66
|
+
onEnded?: ((...args: any[]) => any) | undefined;
|
|
67
|
+
onPlay?: ((...args: any[]) => any) | undefined;
|
|
68
|
+
onForward?: ((...args: any[]) => any) | undefined;
|
|
69
|
+
onMute?: ((...args: any[]) => any) | undefined;
|
|
70
|
+
onFastBack?: ((...args: any[]) => any) | undefined;
|
|
71
|
+
onChangeProgress?: ((...args: any[]) => any) | undefined;
|
|
72
|
+
onCanPlay?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
type: AudioType;
|
|
75
|
+
autoplay: boolean;
|
|
76
|
+
loop: boolean;
|
|
77
|
+
muted: boolean;
|
|
78
|
+
preload: string;
|
|
79
|
+
src: string;
|
|
80
|
+
second: number;
|
|
81
|
+
}, {}>;
|
|
82
|
+
export default _default;
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name2 in all)
|
|
9
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var stdin_exports = {};
|
|
29
|
+
__export(stdin_exports, {
|
|
30
|
+
default: () => stdin_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
+
var import_vue = require("vue");
|
|
34
|
+
var import_vue2 = require("vue");
|
|
35
|
+
var import_icon = __toESM(require("../icon"));
|
|
36
|
+
var import_slider = __toESM(require("../slider"));
|
|
37
|
+
var import_utils = require("../utils");
|
|
38
|
+
var import_types = require("./types");
|
|
39
|
+
const [name, bem] = (0, import_utils.createNamespace)("audio");
|
|
40
|
+
const audioProps = {
|
|
41
|
+
src: (0, import_utils.makeStringProp)(""),
|
|
42
|
+
muted: Boolean,
|
|
43
|
+
autoplay: Boolean,
|
|
44
|
+
loop: Boolean,
|
|
45
|
+
preload: (0, import_utils.makeStringProp)("auto"),
|
|
46
|
+
second: (0, import_utils.makeNumberProp)(0),
|
|
47
|
+
type: (0, import_utils.makeStringProp)("progress")
|
|
48
|
+
};
|
|
49
|
+
var stdin_default = (0, import_vue2.defineComponent)({
|
|
50
|
+
name,
|
|
51
|
+
props: audioProps,
|
|
52
|
+
emits: ["fastBack", "play", "forward", "ended", "changeProgress", "mute", "canPlay"],
|
|
53
|
+
setup(props, {
|
|
54
|
+
emit,
|
|
55
|
+
slots,
|
|
56
|
+
expose
|
|
57
|
+
}) {
|
|
58
|
+
const audioRef = (0, import_vue2.ref)();
|
|
59
|
+
const audioData = (0, import_vue2.reactive)({
|
|
60
|
+
currentTime: 0,
|
|
61
|
+
currentDuration: "00:00:00",
|
|
62
|
+
percent: 0,
|
|
63
|
+
duration: "00:00:00",
|
|
64
|
+
second: 0,
|
|
65
|
+
hanMuted: props.muted,
|
|
66
|
+
playing: props.autoplay,
|
|
67
|
+
handPlaying: false
|
|
68
|
+
});
|
|
69
|
+
const onCanplay = (e) => {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
if (props.autoplay) {
|
|
72
|
+
if (audioRef.value && audioRef.value.paused) {
|
|
73
|
+
audioRef.value.play();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
audioData.second = ((_a = audioRef.value) == null ? void 0 : _a.duration) || 0;
|
|
77
|
+
audioData.duration = (0, import_utils.formatSeconds)(((_c = (_b = audioRef.value) == null ? void 0 : _b.duration) == null ? void 0 : _c.toString()) || "");
|
|
78
|
+
emit("canPlay", e);
|
|
79
|
+
};
|
|
80
|
+
const onTimeupdate = (e) => {
|
|
81
|
+
audioData.currentTime = parseInt(e.target.currentTime);
|
|
82
|
+
};
|
|
83
|
+
const fastBack = (val) => {
|
|
84
|
+
if (audioData.currentTime > 0) {
|
|
85
|
+
if (val) {
|
|
86
|
+
audioData.currentTime = (0, import_utils.clamp)(audioData.currentTime - val, 0, audioData.second);
|
|
87
|
+
} else {
|
|
88
|
+
audioData.currentTime--;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (audioRef.value) {
|
|
92
|
+
audioRef.value.currentTime = audioData.currentTime;
|
|
93
|
+
}
|
|
94
|
+
emit("fastBack", audioData.currentTime);
|
|
95
|
+
};
|
|
96
|
+
const changeStatus = () => {
|
|
97
|
+
if (audioRef.value) {
|
|
98
|
+
if (audioData.playing) {
|
|
99
|
+
audioRef.value.pause();
|
|
100
|
+
audioData.handPlaying = false;
|
|
101
|
+
} else {
|
|
102
|
+
audioRef.value.play();
|
|
103
|
+
audioData.handPlaying = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
audioData.playing = !audioData.playing;
|
|
107
|
+
emit("play", audioData.playing);
|
|
108
|
+
};
|
|
109
|
+
const forward = (val) => {
|
|
110
|
+
if (val) {
|
|
111
|
+
audioData.currentTime = (0, import_utils.clamp)(audioData.currentTime + val, 0, audioData.second);
|
|
112
|
+
} else {
|
|
113
|
+
audioData.currentTime++;
|
|
114
|
+
}
|
|
115
|
+
if (audioRef.value) {
|
|
116
|
+
audioRef.value.currentTime = audioData.currentTime;
|
|
117
|
+
}
|
|
118
|
+
emit("forward", audioData.currentTime);
|
|
119
|
+
};
|
|
120
|
+
const handle = (val) => {
|
|
121
|
+
audioData.currentDuration = (0, import_utils.formatSeconds)(val);
|
|
122
|
+
audioData.percent = val / audioData.second * 100;
|
|
123
|
+
};
|
|
124
|
+
const audioEnd = () => {
|
|
125
|
+
audioData.playing = false;
|
|
126
|
+
emit("ended");
|
|
127
|
+
};
|
|
128
|
+
const progressChange = (val) => {
|
|
129
|
+
var _a;
|
|
130
|
+
audioData.percent = val;
|
|
131
|
+
if (audioRef.value) {
|
|
132
|
+
audioRef.value.currentTime = audioData.second * val / 100;
|
|
133
|
+
}
|
|
134
|
+
emit("changeProgress", ((_a = audioRef.value) == null ? void 0 : _a.currentTime) || 0);
|
|
135
|
+
};
|
|
136
|
+
const handleMute = () => {
|
|
137
|
+
audioData.hanMuted = !audioData.hanMuted;
|
|
138
|
+
emit("mute", audioData.hanMuted);
|
|
139
|
+
};
|
|
140
|
+
function renderProgress() {
|
|
141
|
+
if (props.type === "progress") {
|
|
142
|
+
return (0, import_vue.createVNode)("div", {
|
|
143
|
+
"class": bem("progress")
|
|
144
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
145
|
+
"class": bem("time")
|
|
146
|
+
}, [audioData.currentDuration]), (0, import_vue.createVNode)("div", {
|
|
147
|
+
"class": bem("bar")
|
|
148
|
+
}, [(0, import_vue.createVNode)(import_slider.default, {
|
|
149
|
+
"modelValue": audioData.percent,
|
|
150
|
+
"showPercent": false,
|
|
151
|
+
"readonly": false,
|
|
152
|
+
"onUpdate:modelValue": progressChange
|
|
153
|
+
}, null)]), (0, import_vue.createVNode)("div", {
|
|
154
|
+
"class": bem("time")
|
|
155
|
+
}, [audioData.duration])]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function renderIcon() {
|
|
159
|
+
if (props.type === "icon") {
|
|
160
|
+
return (0, import_vue.createVNode)("div", {
|
|
161
|
+
"class": bem("icon")
|
|
162
|
+
}, [(0, import_vue.createVNode)("div", {
|
|
163
|
+
"class": bem("icon-box", {
|
|
164
|
+
play: audioData.playing,
|
|
165
|
+
stop: !audioData.playing
|
|
166
|
+
}),
|
|
167
|
+
"onClick": () => changeStatus()
|
|
168
|
+
}, [(0, import_vue.createVNode)(import_icon.default, {
|
|
169
|
+
"name": "audio",
|
|
170
|
+
"class": bem("", {
|
|
171
|
+
rotate: audioData.playing
|
|
172
|
+
})
|
|
173
|
+
}, null)])]);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function renderSlots() {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
if (props.type === "none") {
|
|
179
|
+
return (0, import_vue.createVNode)("div", {
|
|
180
|
+
"onClick": () => changeStatus()
|
|
181
|
+
}, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
182
|
+
} else {
|
|
183
|
+
return (_b = slots.default) == null ? void 0 : _b.call(slots);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
(0, import_vue2.watch)(() => audioData.currentTime, (value) => {
|
|
187
|
+
handle(value);
|
|
188
|
+
});
|
|
189
|
+
(0, import_vue2.onMounted)(() => {
|
|
190
|
+
const arr = ["webkitVisibilityState", "visibilitychange"];
|
|
191
|
+
try {
|
|
192
|
+
for (let i = 0; i < arr.length; i++) {
|
|
193
|
+
document.addEventListener(arr[i], () => {
|
|
194
|
+
var _a;
|
|
195
|
+
if (document.hidden) {
|
|
196
|
+
(_a = audioRef.value) == null ? void 0 : _a.pause();
|
|
197
|
+
} else {
|
|
198
|
+
if (audioData.playing) {
|
|
199
|
+
setTimeout(() => {
|
|
200
|
+
var _a2;
|
|
201
|
+
(_a2 = audioRef.value) == null ? void 0 : _a2.play();
|
|
202
|
+
}, 200);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
} catch (e) {
|
|
208
|
+
console.log(e.message);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
(0, import_vue2.provide)(import_types.ZT_AUDIO_KEY, {
|
|
212
|
+
children: [],
|
|
213
|
+
props,
|
|
214
|
+
audioData,
|
|
215
|
+
handleMute,
|
|
216
|
+
forward,
|
|
217
|
+
fastBack,
|
|
218
|
+
changeStatus
|
|
219
|
+
});
|
|
220
|
+
expose({
|
|
221
|
+
audioData,
|
|
222
|
+
audioRef,
|
|
223
|
+
handleMute,
|
|
224
|
+
forward,
|
|
225
|
+
fastBack,
|
|
226
|
+
changeStatus
|
|
227
|
+
});
|
|
228
|
+
return () => {
|
|
229
|
+
const {
|
|
230
|
+
src,
|
|
231
|
+
type,
|
|
232
|
+
preload,
|
|
233
|
+
autoplay,
|
|
234
|
+
loop
|
|
235
|
+
} = props;
|
|
236
|
+
return (0, import_vue.createVNode)("div", {
|
|
237
|
+
"class": bem()
|
|
238
|
+
}, [renderProgress(), renderIcon(), renderSlots(), (0, import_vue.createVNode)("audio", {
|
|
239
|
+
"ref": audioRef,
|
|
240
|
+
"class": bem("audio-main"),
|
|
241
|
+
"controls": type === "controls",
|
|
242
|
+
"src": src,
|
|
243
|
+
"preload": preload,
|
|
244
|
+
"autoplay": autoplay,
|
|
245
|
+
"loop": loop,
|
|
246
|
+
"muted": audioData.hanMuted,
|
|
247
|
+
"onTimeupdate": onTimeupdate,
|
|
248
|
+
"onCanplay": onCanplay,
|
|
249
|
+
"onEnded": audioEnd
|
|
250
|
+
}, null)]);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--zt-audio-icon-disabled-background: var(--zt-gray-a4);--zt-audio-icon-size: var(--zt-font-size-xl);--zt-audio-icon-box-shadow: 0 0 8px var(--zt-gray-a4);--zt-audio-icon-playing-duration: 2s;--zt-audio-icon-box-size: 30px}.zt-audio{padding:0}.zt-audio .zt-audio__progress{display:flex;align-items:center;width:100%;margin:0 auto;padding:10px 0}.zt-audio .zt-audio__progress .zt-audio__bar{flex:1;margin:0 10px}.zt-audio .zt-audio__progress .zt-audio__time{min-width:50px;font-size:12px;text-align:center}.zt-audio .zt-audio__icon{position:relative;display:inline-block}.zt-audio .zt-audio__icon-box{display:flex;align-items:center;justify-content:center;width:var(--zt-audio-icon-box-size);height:var(--zt-audio-icon-box-size);background:#fff;border-radius:50%;box-shadow:var(--zt-audio-icon-box-shadow)}.zt-audio .zt-audio__icon-box>i{font-size:var(--zt-audio-icon-size)}.zt-audio .zt-audio__icon-box--play>i{animation:rotation var(--zt-audio-icon-playing-duration) linear infinite}.zt-audio .zt-audio__icon-box--stop:after{position:absolute;left:50%;top:50%;content:"";height:2px;width:var(--zt-audio-icon-box-size);background:var(--zt-audio-icon-disabled-background);transform:translate(-50%,-50%) rotate(45deg)}@keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}
|