@aplus-frontend/ui 0.4.8 → 0.4.10

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.
Files changed (57) hide show
  1. package/es/index.mjs +21 -19
  2. package/es/src/ap-table/components/dynamic-component/index.vue2.mjs +4 -3
  3. package/es/src/index.d.ts +1 -0
  4. package/es/src/index.mjs +209 -206
  5. package/es/src/path-map.mjs +1 -0
  6. package/es/src/scroll-bar/interface.d.ts +1 -1
  7. package/es/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
  8. package/es/src/scroll-view/hooks/use-scroll-back.mjs +37 -0
  9. package/es/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
  10. package/es/src/scroll-view/hooks/use-scroll-smooth.mjs +50 -0
  11. package/es/src/scroll-view/hooks/use-scroll-wrapper.d.ts +19 -0
  12. package/es/src/scroll-view/hooks/use-scroll-wrapper.mjs +54 -0
  13. package/es/src/scroll-view/index.d.ts +3 -0
  14. package/es/src/scroll-view/index.mjs +2 -0
  15. package/es/src/scroll-view/index.vue.d.ts +214 -0
  16. package/es/src/scroll-view/index.vue.mjs +253 -0
  17. package/es/src/scroll-view/index.vue2.mjs +4 -0
  18. package/es/src/scroll-view/interface.d.ts +92 -0
  19. package/es/src/scroll-view/interface.mjs +1 -0
  20. package/es/src/scroll-view/style/css.d.ts +0 -0
  21. package/es/src/scroll-view/style/css.js +2 -0
  22. package/es/src/scroll-view/style/index.d.ts +0 -0
  23. package/es/src/scroll-view/style/index.js +2 -0
  24. package/es/src/scroll-view/utils/index.d.ts +11 -0
  25. package/es/src/scroll-view/utils/index.mjs +18 -0
  26. package/lib/index.js +1 -1
  27. package/lib/src/ap-table/components/dynamic-component/index.vue2.js +1 -1
  28. package/lib/src/index.d.ts +1 -0
  29. package/lib/src/index.js +1 -1
  30. package/lib/src/path-map.js +1 -1
  31. package/lib/src/scroll-bar/interface.d.ts +1 -1
  32. package/lib/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
  33. package/lib/src/scroll-view/hooks/use-scroll-back.js +1 -0
  34. package/lib/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
  35. package/lib/src/scroll-view/hooks/use-scroll-smooth.js +1 -0
  36. package/lib/src/scroll-view/hooks/use-scroll-wrapper.d.ts +19 -0
  37. package/lib/src/scroll-view/hooks/use-scroll-wrapper.js +1 -0
  38. package/lib/src/scroll-view/index.d.ts +3 -0
  39. package/lib/src/scroll-view/index.js +1 -0
  40. package/lib/src/scroll-view/index.vue.d.ts +214 -0
  41. package/lib/src/scroll-view/index.vue.js +1 -0
  42. package/lib/src/scroll-view/index.vue2.js +1 -0
  43. package/lib/src/scroll-view/interface.d.ts +92 -0
  44. package/lib/src/scroll-view/interface.js +1 -0
  45. package/lib/src/scroll-view/style/css.cjs +2 -0
  46. package/lib/src/scroll-view/style/css.d.ts +0 -0
  47. package/lib/src/scroll-view/style/index.cjs +2 -0
  48. package/lib/src/scroll-view/style/index.d.ts +0 -0
  49. package/lib/src/scroll-view/utils/index.d.ts +11 -0
  50. package/lib/src/scroll-view/utils/index.js +1 -0
  51. package/package.json +6 -5
  52. package/theme/index.css +21 -1
  53. package/theme/index.less +1 -0
  54. package/theme/scroll-bar/index.css +1 -1
  55. package/theme/scroll-bar/index.less +1 -1
  56. package/theme/scroll-view/index.css +20 -0
  57. package/theme/scroll-view/index.less +23 -0
@@ -0,0 +1,26 @@
1
+ import { ScrollBarDirection } from '../../scroll-bar';
2
+ import { Ref } from 'vue';
3
+ type ScrollBackOptions = {
4
+ scrollOffset: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ maxScrollDistance: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ timer?: number;
13
+ onScroll?: (direction: ScrollBarDirection) => void;
14
+ onScrollEnd?: (direction: ScrollBarDirection) => void;
15
+ };
16
+ /**
17
+ * 在特定的时间内滚动到0
18
+ * @param options
19
+ * @returns
20
+ */
21
+ declare const useScrollBack: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
22
+ start: (direction: ScrollBarDirection) => void;
23
+ stop: () => void;
24
+ isActive: Readonly< Ref<boolean, boolean>>;
25
+ };
26
+ export { useScrollBack };
@@ -0,0 +1,37 @@
1
+ import "../../scroll-bar/index.mjs";
2
+ import { useRafFn as x } from "@vueuse/core";
3
+ import { ensureRangeValue as u } from "../../scroll-bar/utils/index.mjs";
4
+ const m = {
5
+ horizontal: "x",
6
+ vertical: "y"
7
+ }, p = () => {
8
+ }, M = (e) => 1 - Math.pow(1 - e, 3), y = ({
9
+ scrollOffset: e,
10
+ maxScrollDistance: d,
11
+ timer: l = 500,
12
+ onScroll: n = p,
13
+ onScrollEnd: f = p
14
+ }) => {
15
+ let a, t, i;
16
+ const { pause: r, resume: g, isActive: h } = x(
17
+ () => {
18
+ const o = Date.now(), s = m[t], T = o - a, c = u(T / l, 0, 1), v = M(c);
19
+ c === 1 ? (e[s] = 0, r(), n(t), f(t)) : (e[s] = u(
20
+ i * (1 - v),
21
+ 0,
22
+ d[s]
23
+ ), n(t));
24
+ },
25
+ { immediate: !1 }
26
+ );
27
+ function w(o) {
28
+ t = o, a = Date.now(), i = e[m[o]], g();
29
+ }
30
+ function D() {
31
+ r();
32
+ }
33
+ return { start: w, stop: D, isActive: h };
34
+ };
35
+ export {
36
+ y as useScrollBack
37
+ };
@@ -0,0 +1,26 @@
1
+ import { ScrollOffsetType } from '../interface';
2
+ import { Ref } from 'vue';
3
+ type ScrollBackOptions = {
4
+ scrollOffset: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ maxScrollDistance: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ timer?: number;
13
+ onScroll?: (x: boolean, y: boolean) => void;
14
+ onScrollEnd?: (x: boolean, y: boolean) => void;
15
+ };
16
+ /**
17
+ * 在特定的时间内滚动到0
18
+ * @param options
19
+ * @returns
20
+ */
21
+ declare const useScrollSmooth: ({ scrollOffset, maxScrollDistance, timer, onScroll, onScrollEnd }: ScrollBackOptions) => {
22
+ start: (target: Partial<ScrollOffsetType>) => void;
23
+ stop: () => void;
24
+ isActive: Readonly< Ref<boolean, boolean>>;
25
+ };
26
+ export { useScrollSmooth };
@@ -0,0 +1,50 @@
1
+ import "../../scroll-bar/index.mjs";
2
+ import { useRafFn as R } from "@vueuse/core";
3
+ import { isDef as f } from "../../utils/index.mjs";
4
+ import { ensureRangeValue as s } from "../../scroll-bar/utils/index.mjs";
5
+ const g = () => {
6
+ }, b = (i) => 1 - Math.pow(1 - i, 3), V = ({
7
+ scrollOffset: i,
8
+ maxScrollDistance: r,
9
+ timer: l = 500,
10
+ onScroll: u = g,
11
+ onScrollEnd: T = g
12
+ }) => {
13
+ let m, e, t, o, n;
14
+ const { pause: a, resume: w, isActive: p } = R(
15
+ () => {
16
+ const v = Date.now() - m, c = s(v / l, 0, 1), y = b(c);
17
+ c === 1 ? (o && (i.x = t.x), n && (i.y = t.y), a(), u(o, n), T(o, n)) : (o && (t.x > e.x ? i.x = s(
18
+ e.x + (t.x - e.x) * y,
19
+ e.x,
20
+ r.x
21
+ ) : i.x = s(
22
+ t.x + (e.x - t.x) * (1 - y),
23
+ 0,
24
+ e.x
25
+ )), n && (t.y > e.y ? i.y = s(
26
+ e.y + (t.y - e.y) * y,
27
+ e.y,
28
+ r.y
29
+ ) : i.y = s(
30
+ t.y + (e.y - t.y) * (1 - y),
31
+ 0,
32
+ e.y
33
+ )), u(o, n));
34
+ },
35
+ { immediate: !1 }
36
+ );
37
+ function d(x) {
38
+ p.value && a(), m = Date.now(), e = {
39
+ x: i.x,
40
+ y: i.y
41
+ }, t = x, o = f(x.x), n = f(x.y), w();
42
+ }
43
+ function h() {
44
+ a();
45
+ }
46
+ return { start: d, stop: h, isActive: p };
47
+ };
48
+ export {
49
+ V as useScrollSmooth
50
+ };
@@ -0,0 +1,19 @@
1
+ import { InternalScrollBarExpose } from '../../scroll-bar';
2
+ import { Ref } from 'vue';
3
+ declare const useScrollWrapper: () => {
4
+ maxScrollDistance: {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ scrollOffset: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ xBarRef: Ref<InternalScrollBarExpose | undefined, InternalScrollBarExpose | undefined>;
13
+ yBarRef: Ref<InternalScrollBarExpose | undefined, InternalScrollBarExpose | undefined>;
14
+ scrollYBar: () => void;
15
+ scrollXBar: () => void;
16
+ containerRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
17
+ updateMaxScrollDistance: () => void;
18
+ };
19
+ export default useScrollWrapper;
@@ -0,0 +1,54 @@
1
+ import { getScrollable as c } from "../../scroll-bar/utils/index.mjs";
2
+ import { ref as i, reactive as v, watch as p, unref as b } from "vue";
3
+ const B = () => {
4
+ const t = i(), n = v({ x: 0, y: 0 }), a = v({ x: 0, y: 0 }), s = i(), u = i();
5
+ p(
6
+ () => t.value,
7
+ () => {
8
+ f();
9
+ }
10
+ );
11
+ function f() {
12
+ const e = b(t);
13
+ if (!e)
14
+ return;
15
+ const { visibleSize: l, totalSize: r } = c(
16
+ e,
17
+ "horizontal"
18
+ ), { visibleSize: o, totalSize: x } = c(e, "vertical");
19
+ n.x = r - l, n.y = x - o;
20
+ }
21
+ function S() {
22
+ var o;
23
+ if (!t.value)
24
+ return;
25
+ const { totalSize: e, visibleSize: l } = c(
26
+ t.value,
27
+ "vertical"
28
+ ), r = a.y / (e - l || 1) * 100;
29
+ (o = u.value) == null || o.scroll(r);
30
+ }
31
+ function z() {
32
+ var o;
33
+ if (!t.value)
34
+ return;
35
+ const { totalSize: e, visibleSize: l } = c(
36
+ t.value,
37
+ "horizontal"
38
+ ), r = a.x / (e - l || 1) * 100;
39
+ (o = s.value) == null || o.scroll(r);
40
+ }
41
+ return {
42
+ maxScrollDistance: n,
43
+ scrollOffset: a,
44
+ xBarRef: s,
45
+ yBarRef: u,
46
+ scrollYBar: S,
47
+ scrollXBar: z,
48
+ containerRef: t,
49
+ updateMaxScrollDistance: f
50
+ };
51
+ };
52
+ export {
53
+ B as default
54
+ };
@@ -0,0 +1,3 @@
1
+ import { default as ScrollView } from './index.vue';
2
+ export { ScrollView };
3
+ export * from './interface';
@@ -0,0 +1,2 @@
1
+ import "./index.vue2.mjs";
2
+ import "./interface.mjs";
@@ -0,0 +1,214 @@
1
+ import { ScrollOptions, ScrollViewProps } from './interface';
2
+ import { ScrollBarDirection, InternalScrollBarProps } from '../scroll-bar';
3
+ import { CreateComponentPublicInstanceWithMixins, Ref, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent, ComputedRef } from 'vue';
4
+ declare function scroll(x?: number, y?: number): void;
5
+ declare function scrollTo({ smooth, left, top }: ScrollOptions): void;
6
+ declare function scrollIntoView(element: HTMLElement, position?: 'start' | 'center' | 'end'): void;
7
+ declare function __VLS_template(): {
8
+ attrs: Partial<{}>;
9
+ slots: {
10
+ default?(_: {}): any;
11
+ };
12
+ refs: {
13
+ containerRef: HTMLDivElement;
14
+ contentRef: HTMLDivElement;
15
+ yBarRef: CreateComponentPublicInstanceWithMixins<Readonly< InternalScrollBarProps> & Readonly<{}>, {
16
+ currentScroll: Ref<number, number>;
17
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
18
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
19
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
20
+ scroll: (percent: number) => void;
21
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
22
+ scroll: number;
23
+ disabled: boolean;
24
+ direction: ScrollBarDirection;
25
+ trackSpeed: number;
26
+ barLength: number;
27
+ showTrack: boolean;
28
+ }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
29
+ container: HTMLDivElement;
30
+ track: HTMLDivElement;
31
+ bar: HTMLDivElement;
32
+ }, HTMLDivElement, ComponentProvideOptions, {
33
+ P: {};
34
+ B: {};
35
+ D: {};
36
+ C: {};
37
+ M: {};
38
+ Defaults: {};
39
+ }, Readonly< InternalScrollBarProps> & Readonly<{}>, {
40
+ currentScroll: Ref<number, number>;
41
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
42
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
43
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
44
+ scroll: (percent: number) => void;
45
+ }, {}, {}, {}, {
46
+ scroll: number;
47
+ disabled: boolean;
48
+ direction: ScrollBarDirection;
49
+ trackSpeed: number;
50
+ barLength: number;
51
+ showTrack: boolean;
52
+ }> | null;
53
+ xBarRef: CreateComponentPublicInstanceWithMixins<Readonly< InternalScrollBarProps> & Readonly<{}>, {
54
+ currentScroll: Ref<number, number>;
55
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
56
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
57
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
58
+ scroll: (percent: number) => void;
59
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
60
+ scroll: number;
61
+ disabled: boolean;
62
+ direction: ScrollBarDirection;
63
+ trackSpeed: number;
64
+ barLength: number;
65
+ showTrack: boolean;
66
+ }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
67
+ container: HTMLDivElement;
68
+ track: HTMLDivElement;
69
+ bar: HTMLDivElement;
70
+ }, HTMLDivElement, ComponentProvideOptions, {
71
+ P: {};
72
+ B: {};
73
+ D: {};
74
+ C: {};
75
+ M: {};
76
+ Defaults: {};
77
+ }, Readonly< InternalScrollBarProps> & Readonly<{}>, {
78
+ currentScroll: Ref<number, number>;
79
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
80
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
81
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
82
+ scroll: (percent: number) => void;
83
+ }, {}, {}, {}, {
84
+ scroll: number;
85
+ disabled: boolean;
86
+ direction: ScrollBarDirection;
87
+ trackSpeed: number;
88
+ barLength: number;
89
+ showTrack: boolean;
90
+ }> | null;
91
+ };
92
+ rootEl: HTMLDivElement;
93
+ };
94
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
95
+ declare const __VLS_component: DefineComponent<ScrollViewProps, {
96
+ scrollTop: ComputedRef<number>;
97
+ scrollLeft: ComputedRef<number>;
98
+ scroll: typeof scroll;
99
+ scrollTo: typeof scrollTo;
100
+ scrollIntoView: typeof scrollIntoView;
101
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ScrollViewProps> & Readonly<{}>, {
102
+ showXBar: boolean;
103
+ showYBar: boolean;
104
+ xBarProps: {
105
+ width?: number | undefined;
106
+ onScroll?: ((percent: number) => void) | undefined;
107
+ disabled?: boolean | undefined;
108
+ trackSpeed?: number | undefined;
109
+ barColor?: import("csstype").Property.BackgroundColor | undefined;
110
+ trackColor?: import("csstype").Property.BackgroundColor | undefined;
111
+ trackWidth?: number | undefined;
112
+ showTrack?: boolean | undefined;
113
+ onScrollStart?: ((percent: number) => void) | undefined;
114
+ onScrollEnd?: ((percent: number) => void) | undefined;
115
+ };
116
+ yBarProps: {
117
+ width?: number | undefined;
118
+ onScroll?: ((percent: number) => void) | undefined;
119
+ disabled?: boolean | undefined;
120
+ trackSpeed?: number | undefined;
121
+ barColor?: import("csstype").Property.BackgroundColor | undefined;
122
+ trackColor?: import("csstype").Property.BackgroundColor | undefined;
123
+ trackWidth?: number | undefined;
124
+ showTrack?: boolean | undefined;
125
+ onScrollStart?: ((percent: number) => void) | undefined;
126
+ onScrollEnd?: ((percent: number) => void) | undefined;
127
+ };
128
+ }, {}, {}, {}, string, ComponentProvideOptions, false, {
129
+ containerRef: HTMLDivElement;
130
+ contentRef: HTMLDivElement;
131
+ yBarRef: CreateComponentPublicInstanceWithMixins<Readonly< InternalScrollBarProps> & Readonly<{}>, {
132
+ currentScroll: Ref<number, number>;
133
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
134
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
135
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
136
+ scroll: (percent: number) => void;
137
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
138
+ scroll: number;
139
+ disabled: boolean;
140
+ direction: ScrollBarDirection;
141
+ trackSpeed: number;
142
+ barLength: number;
143
+ showTrack: boolean;
144
+ }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
145
+ container: HTMLDivElement;
146
+ track: HTMLDivElement;
147
+ bar: HTMLDivElement;
148
+ }, HTMLDivElement, ComponentProvideOptions, {
149
+ P: {};
150
+ B: {};
151
+ D: {};
152
+ C: {};
153
+ M: {};
154
+ Defaults: {};
155
+ }, Readonly< InternalScrollBarProps> & Readonly<{}>, {
156
+ currentScroll: Ref<number, number>;
157
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
158
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
159
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
160
+ scroll: (percent: number) => void;
161
+ }, {}, {}, {}, {
162
+ scroll: number;
163
+ disabled: boolean;
164
+ direction: ScrollBarDirection;
165
+ trackSpeed: number;
166
+ barLength: number;
167
+ showTrack: boolean;
168
+ }> | null;
169
+ xBarRef: CreateComponentPublicInstanceWithMixins<Readonly< InternalScrollBarProps> & Readonly<{}>, {
170
+ currentScroll: Ref<number, number>;
171
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
172
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
173
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
174
+ scroll: (percent: number) => void;
175
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
176
+ scroll: number;
177
+ disabled: boolean;
178
+ direction: ScrollBarDirection;
179
+ trackSpeed: number;
180
+ barLength: number;
181
+ showTrack: boolean;
182
+ }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
183
+ container: HTMLDivElement;
184
+ track: HTMLDivElement;
185
+ bar: HTMLDivElement;
186
+ }, HTMLDivElement, ComponentProvideOptions, {
187
+ P: {};
188
+ B: {};
189
+ D: {};
190
+ C: {};
191
+ M: {};
192
+ Defaults: {};
193
+ }, Readonly< InternalScrollBarProps> & Readonly<{}>, {
194
+ currentScroll: Ref<number, number>;
195
+ container: Ref<HTMLElement | undefined, HTMLElement | undefined>;
196
+ bar: Ref<HTMLElement | undefined, HTMLElement | undefined>;
197
+ track: Ref<HTMLElement | undefined, HTMLElement | undefined>;
198
+ scroll: (percent: number) => void;
199
+ }, {}, {}, {}, {
200
+ scroll: number;
201
+ disabled: boolean;
202
+ direction: ScrollBarDirection;
203
+ trackSpeed: number;
204
+ barLength: number;
205
+ showTrack: boolean;
206
+ }> | null;
207
+ }, HTMLDivElement>;
208
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
209
+ export default _default;
210
+ type __VLS_WithTemplateSlots<T, S> = T & {
211
+ new (): {
212
+ $slots: S;
213
+ };
214
+ };
@@ -0,0 +1,253 @@
1
+ import { defineComponent as fe, ref as ue, reactive as he, computed as v, unref as l, watchEffect as _, watch as pe, openBlock as P, createElementBlock as ye, normalizeClass as B, normalizeStyle as M, withModifiers as A, createElementVNode as z, renderSlot as me, createBlock as L, mergeProps as O, createCommentVNode as T } from "vue";
2
+ import "../config-provider/index.mjs";
3
+ import "../scroll-bar/index.mjs";
4
+ import { isDef as f } from "../utils/index.mjs";
5
+ import { ensureRangeValue as n, getScrollable as k } from "../scroll-bar/utils/index.mjs";
6
+ import de from "./hooks/use-scroll-wrapper.mjs";
7
+ import { isString as j } from "lodash-unified";
8
+ import { useElementSize as F, useRafFn as ve } from "@vueuse/core";
9
+ import { wait as R } from "@aplus-frontend/utils";
10
+ import { useScrollBack as xe } from "./hooks/use-scroll-back.mjs";
11
+ import { useScrollSmooth as Be } from "./hooks/use-scroll-smooth.mjs";
12
+ import { getElementScrollOffset as we } from "./utils/index.mjs";
13
+ import { useNamespace as ge } from "../config-provider/hooks/use-namespace.mjs";
14
+ import H from "../scroll-bar/internal.vue.mjs";
15
+ const Ye = /* @__PURE__ */ fe({
16
+ name: "ScrollView",
17
+ __name: "index",
18
+ props: {
19
+ width: {},
20
+ heigth: {},
21
+ showXBar: { type: Boolean, default: !0 },
22
+ showYBar: { type: Boolean, default: !0 },
23
+ autoPlay: { type: [Boolean, Object] },
24
+ xBarProps: { default: () => ({}) },
25
+ yBarProps: { default: () => ({}) },
26
+ onWheel: {}
27
+ },
28
+ setup(I, { expose: q }) {
29
+ const o = I, G = {
30
+ direction: "vertical",
31
+ rate: 1,
32
+ repeat: !0
33
+ }, { b: J, e: w, em: W } = ge("scroll-view"), u = ue(), c = he({ x: 30, y: 30 });
34
+ let g = !1;
35
+ const {
36
+ scrollOffset: r,
37
+ maxScrollDistance: i,
38
+ xBarRef: K,
39
+ yBarRef: Q,
40
+ containerRef: s,
41
+ scrollYBar: h,
42
+ scrollXBar: p,
43
+ updateMaxScrollDistance: U
44
+ } = de(), { width: Z, height: ee } = F(u), { width: te, height: re } = F(s), { start: N } = xe({
45
+ scrollOffset: r,
46
+ maxScrollDistance: i,
47
+ onScroll: (t) => {
48
+ t === "horizontal" ? p() : h();
49
+ },
50
+ async onScrollEnd() {
51
+ await R(200), S();
52
+ }
53
+ }), { start: $ } = Be({
54
+ scrollOffset: r,
55
+ maxScrollDistance: i,
56
+ onScroll(t, e) {
57
+ V.value && (y(), g = !0), t && p(), e && h();
58
+ },
59
+ async onScrollEnd() {
60
+ g && (await R(200), S(), g = !1);
61
+ }
62
+ }), { resume: S, pause: y, isActive: V } = ve(
63
+ () => {
64
+ if (!o.autoPlay) {
65
+ y();
66
+ return;
67
+ }
68
+ const t = o.autoPlay === !0 ? {} : o.autoPlay, e = {
69
+ ...G,
70
+ ...t
71
+ };
72
+ if (e.direction === "horizontal") {
73
+ if (r.x === i.x) {
74
+ y(), e.repeat && N("horizontal");
75
+ return;
76
+ }
77
+ r.x = n(
78
+ r.x + e.rate,
79
+ 0,
80
+ i.x
81
+ ), p();
82
+ } else {
83
+ if (r.y === i.y) {
84
+ y(), e.repeat && N("vertical");
85
+ return;
86
+ }
87
+ r.y = n(
88
+ r.y + e.rate,
89
+ 0,
90
+ i.y
91
+ ), h();
92
+ }
93
+ },
94
+ { immediate: !0 }
95
+ ), m = v(() => o.showXBar && c.x !== 100), x = v(() => o.showYBar && c.y !== 100), oe = v(() => ({
96
+ width: f(o.width) ? j(o.width) ? o.width : Number.isNaN(o.width) ? void 0 : `${o.width}px` : void 0,
97
+ height: f(o.heigth) ? j(o.heigth) ? o.heigth : Number.isNaN(o.heigth) ? void 0 : `${o.heigth}px` : void 0,
98
+ padding: `${o.xBarProps.trackWidth || 10}px ${o.yBarProps.trackWidth || 10}px`
99
+ }));
100
+ async function b() {
101
+ V.value && (y(), await R(500), S());
102
+ }
103
+ async function ae(t) {
104
+ var e;
105
+ if (l(x))
106
+ t.preventDefault(), t.stopPropagation();
107
+ else
108
+ return;
109
+ r.y = n(
110
+ r.y + t.deltaY,
111
+ 0,
112
+ i.y
113
+ ), h(), (e = o.onWheel) == null || e.call(o, "vertical", r.y), b();
114
+ }
115
+ function le(t) {
116
+ var e;
117
+ if (l(m))
118
+ t.preventDefault(), t.stopPropagation();
119
+ else
120
+ return;
121
+ r.x = n(
122
+ r.x + t.deltaX,
123
+ 0,
124
+ i.x
125
+ ), p(), (e = o.onWheel) == null || e.call(o, "horizontal", r.x), b();
126
+ }
127
+ function E() {
128
+ if (o.showYBar) {
129
+ const { visibleSize: t, totalSize: e } = k(
130
+ s.value,
131
+ "vertical"
132
+ );
133
+ c.y = n(
134
+ Math.min(t / (e || 1) * 100)
135
+ );
136
+ }
137
+ if (o.showXBar) {
138
+ const { visibleSize: t, totalSize: e } = k(
139
+ s.value,
140
+ "horizontal"
141
+ );
142
+ c.x = n(
143
+ Math.min(t / (e || 1) * 100)
144
+ );
145
+ }
146
+ }
147
+ function X(t, e) {
148
+ const a = l(s), d = l(u);
149
+ if (!a || !d) return;
150
+ const { visibleSize: C, totalSize: D } = k(a, e);
151
+ if (D <= C) return;
152
+ const Y = (D - C) * t / 100, ce = e === "vertical";
153
+ if (b(), ce) {
154
+ r.y = Y;
155
+ return;
156
+ }
157
+ r.x = Y;
158
+ }
159
+ _(
160
+ () => {
161
+ l(s.value) && E();
162
+ },
163
+ { flush: "post" }
164
+ ), pe(
165
+ () => [
166
+ Z.value,
167
+ ee.value,
168
+ te.value,
169
+ re.value
170
+ ],
171
+ () => {
172
+ E(), U();
173
+ }
174
+ ), _(() => {
175
+ u.value && (u.value.style.transform = `translate3d(-${r.x}px, -${r.y}px, 0px)`);
176
+ });
177
+ function ie(t, e) {
178
+ f(t) && m.value && (r.x = n(t, 0, i.x), p()), f(e) && x.value && (r.y = n(e, 0, i.y), h());
179
+ }
180
+ function ne({ smooth: t, left: e, top: a }) {
181
+ t ? $({ x: e, y: a }) : (f(e) && (r.x = e), f(a) && (r.y = a));
182
+ }
183
+ function se(t, e = "start") {
184
+ const a = we(
185
+ s.value,
186
+ t,
187
+ e
188
+ ), d = {};
189
+ m.value && (d.x = n(
190
+ r.x + a.x,
191
+ 0,
192
+ i.x
193
+ )), x.value && (d.y = n(
194
+ r.y + a.y,
195
+ 0,
196
+ i.y
197
+ )), $(d);
198
+ }
199
+ return q({
200
+ scrollTop: v(() => r.y),
201
+ scrollLeft: v(() => r.x),
202
+ scroll: ie,
203
+ scrollTo: ne,
204
+ scrollIntoView: se
205
+ }), (t, e) => (P(), ye("div", {
206
+ ref_key: "containerRef",
207
+ ref: s,
208
+ class: B(l(J)()),
209
+ style: M(oe.value),
210
+ onWheel: [
211
+ A(ae, ["exact"]),
212
+ A(le, ["shift"])
213
+ ]
214
+ }, [
215
+ z("div", {
216
+ ref_key: "contentRef",
217
+ ref: u,
218
+ class: B(l(w)("content"))
219
+ }, [
220
+ me(t.$slots, "default")
221
+ ], 2),
222
+ z("div", {
223
+ class: B([l(w)("bar-wrapper"), l(W)("bar-wrapper", "vertical")]),
224
+ style: M(`height: calc(100% - ${m.value ? t.xBarProps.trackWidth || 10 : 0}px)`)
225
+ }, [
226
+ x.value ? (P(), L(l(H), O({
227
+ key: 0,
228
+ ref_key: "yBarRef",
229
+ ref: Q
230
+ }, t.yBarProps, {
231
+ "bar-length": c.y,
232
+ onScroll: e[0] || (e[0] = (a) => X(a, "vertical"))
233
+ }), null, 16, ["bar-length"])) : T("", !0)
234
+ ], 6),
235
+ z("div", {
236
+ class: B([l(w)("bar-wrapper"), l(W)("bar-wrapper", "horizontal")])
237
+ }, [
238
+ m.value ? (P(), L(l(H), O({
239
+ key: 0,
240
+ ref_key: "xBarRef",
241
+ ref: K
242
+ }, t.xBarProps, {
243
+ direction: "horizontal",
244
+ "bar-length": c.x,
245
+ onScroll: e[1] || (e[1] = (a) => X(a, "horizontal"))
246
+ }), null, 16, ["bar-length"])) : T("", !0)
247
+ ], 2)
248
+ ], 38));
249
+ }
250
+ });
251
+ export {
252
+ Ye as default
253
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./index.vue.mjs";
2
+ export {
3
+ f as default
4
+ };