@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.
- package/es/index.mjs +21 -19
- package/es/src/ap-table/components/dynamic-component/index.vue2.mjs +4 -3
- package/es/src/index.d.ts +1 -0
- package/es/src/index.mjs +209 -206
- package/es/src/path-map.mjs +1 -0
- package/es/src/scroll-bar/interface.d.ts +1 -1
- package/es/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
- package/es/src/scroll-view/hooks/use-scroll-back.mjs +37 -0
- package/es/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
- package/es/src/scroll-view/hooks/use-scroll-smooth.mjs +50 -0
- package/es/src/scroll-view/hooks/use-scroll-wrapper.d.ts +19 -0
- package/es/src/scroll-view/hooks/use-scroll-wrapper.mjs +54 -0
- package/es/src/scroll-view/index.d.ts +3 -0
- package/es/src/scroll-view/index.mjs +2 -0
- package/es/src/scroll-view/index.vue.d.ts +214 -0
- package/es/src/scroll-view/index.vue.mjs +253 -0
- package/es/src/scroll-view/index.vue2.mjs +4 -0
- package/es/src/scroll-view/interface.d.ts +92 -0
- package/es/src/scroll-view/interface.mjs +1 -0
- package/es/src/scroll-view/style/css.d.ts +0 -0
- package/es/src/scroll-view/style/css.js +2 -0
- package/es/src/scroll-view/style/index.d.ts +0 -0
- package/es/src/scroll-view/style/index.js +2 -0
- package/es/src/scroll-view/utils/index.d.ts +11 -0
- package/es/src/scroll-view/utils/index.mjs +18 -0
- package/lib/index.js +1 -1
- package/lib/src/ap-table/components/dynamic-component/index.vue2.js +1 -1
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -1
- package/lib/src/path-map.js +1 -1
- package/lib/src/scroll-bar/interface.d.ts +1 -1
- package/lib/src/scroll-view/hooks/use-scroll-back.d.ts +26 -0
- package/lib/src/scroll-view/hooks/use-scroll-back.js +1 -0
- package/lib/src/scroll-view/hooks/use-scroll-smooth.d.ts +26 -0
- package/lib/src/scroll-view/hooks/use-scroll-smooth.js +1 -0
- package/lib/src/scroll-view/hooks/use-scroll-wrapper.d.ts +19 -0
- package/lib/src/scroll-view/hooks/use-scroll-wrapper.js +1 -0
- package/lib/src/scroll-view/index.d.ts +3 -0
- package/lib/src/scroll-view/index.js +1 -0
- package/lib/src/scroll-view/index.vue.d.ts +214 -0
- package/lib/src/scroll-view/index.vue.js +1 -0
- package/lib/src/scroll-view/index.vue2.js +1 -0
- package/lib/src/scroll-view/interface.d.ts +92 -0
- package/lib/src/scroll-view/interface.js +1 -0
- package/lib/src/scroll-view/style/css.cjs +2 -0
- package/lib/src/scroll-view/style/css.d.ts +0 -0
- package/lib/src/scroll-view/style/index.cjs +2 -0
- package/lib/src/scroll-view/style/index.d.ts +0 -0
- package/lib/src/scroll-view/utils/index.d.ts +11 -0
- package/lib/src/scroll-view/utils/index.js +1 -0
- package/package.json +6 -5
- package/theme/index.css +21 -1
- package/theme/index.less +1 -0
- package/theme/scroll-bar/index.css +1 -1
- package/theme/scroll-bar/index.less +1 -1
- package/theme/scroll-view/index.css +20 -0
- package/theme/scroll-view/index.less +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");require("../scroll-bar/index.js");const c=require("../utils/index.js"),o=require("../scroll-bar/utils/index.js"),Z=require("./hooks/use-scroll-wrapper.js"),W=require("lodash-unified"),w=require("@vueuse/core"),b=require("@aplus-frontend/utils"),ee=require("./hooks/use-scroll-back.js"),te=require("./hooks/use-scroll-smooth.js"),re=require("./utils/index.js"),ae=require("../config-provider/hooks/use-namespace.js"),D=require("../scroll-bar/internal.vue.js"),ne=e.defineComponent({name:"ScrollView",__name:"index",props:{width:{},heigth:{},showXBar:{type:Boolean,default:!0},showYBar:{type:Boolean,default:!0},autoPlay:{type:[Boolean,Object]},xBarProps:{default:()=>({})},yBarProps:{default:()=>({})},onWheel:{}},setup($,{expose:C}){const n=$,M={direction:"vertical",rate:1,repeat:!0},{b:X,e:g,em:z}=ae.useNamespace("scroll-view"),f=e.ref(),u=e.reactive({x:30,y:30});let m=!1;const{scrollOffset:a,maxScrollDistance:i,xBarRef:Y,yBarRef:O,containerRef:s,scrollYBar:h,scrollXBar:d,updateMaxScrollDistance:A}=Z.default(),{width:L,height:T}=w.useElementSize(f),{width:j,height:F}=w.useElementSize(s),{start:P}=ee.useScrollBack({scrollOffset:a,maxScrollDistance:i,onScroll:r=>{r==="horizontal"?d():h()},async onScrollEnd(){await b.wait(200),S()}}),{start:R}=te.useScrollSmooth({scrollOffset:a,maxScrollDistance:i,onScroll(r,t){V.value&&(y(),m=!0),r&&d(),t&&h()},async onScrollEnd(){m&&(await b.wait(200),S(),m=!1)}}),{resume:S,pause:y,isActive:V}=w.useRafFn(()=>{if(!n.autoPlay){y();return}const r=n.autoPlay===!0?{}:n.autoPlay,t={...M,...r};if(t.direction==="horizontal"){if(a.x===i.x){y(),t.repeat&&P("horizontal");return}a.x=o.ensureRangeValue(a.x+t.rate,0,i.x),d()}else{if(a.y===i.y){y(),t.repeat&&P("vertical");return}a.y=o.ensureRangeValue(a.y+t.rate,0,i.y),h()}},{immediate:!0}),p=e.computed(()=>n.showXBar&&u.x!==100),x=e.computed(()=>n.showYBar&&u.y!==100),H=e.computed(()=>({width:c.isDef(n.width)?W.isString(n.width)?n.width:Number.isNaN(n.width)?void 0:`${n.width}px`:void 0,height:c.isDef(n.heigth)?W.isString(n.heigth)?n.heigth:Number.isNaN(n.heigth)?void 0:`${n.heigth}px`:void 0,padding:`${n.xBarProps.trackWidth||10}px ${n.yBarProps.trackWidth||10}px`}));async function B(){V.value&&(y(),await b.wait(500),S())}async function I(r){var t;if(e.unref(x))r.preventDefault(),r.stopPropagation();else return;a.y=o.ensureRangeValue(a.y+r.deltaY,0,i.y),h(),(t=n.onWheel)==null||t.call(n,"vertical",a.y),B()}function U(r){var t;if(e.unref(p))r.preventDefault(),r.stopPropagation();else return;a.x=o.ensureRangeValue(a.x+r.deltaX,0,i.x),d(),(t=n.onWheel)==null||t.call(n,"horizontal",a.x),B()}function k(){if(n.showYBar){const{visibleSize:r,totalSize:t}=o.getScrollable(s.value,"vertical");u.y=o.ensureRangeValue(Math.min(r/(t||1)*100))}if(n.showXBar){const{visibleSize:r,totalSize:t}=o.getScrollable(s.value,"horizontal");u.x=o.ensureRangeValue(Math.min(r/(t||1)*100))}}function q(r,t){const l=e.unref(s),v=e.unref(f);if(!l||!v)return;const{visibleSize:N,totalSize:_}=o.getScrollable(l,t);if(_<=N)return;const E=(_-N)*r/100,Q=t==="vertical";if(B(),Q){a.y=E;return}a.x=E}e.watchEffect(()=>{e.unref(s.value)&&k()},{flush:"post"}),e.watch(()=>[L.value,T.value,j.value,F.value],()=>{k(),A()}),e.watchEffect(()=>{f.value&&(f.value.style.transform=`translate3d(-${a.x}px, -${a.y}px, 0px)`)});function G(r,t){c.isDef(r)&&p.value&&(a.x=o.ensureRangeValue(r,0,i.x),d()),c.isDef(t)&&x.value&&(a.y=o.ensureRangeValue(t,0,i.y),h())}function J({smooth:r,left:t,top:l}){r?R({x:t,y:l}):(c.isDef(t)&&(a.x=t),c.isDef(l)&&(a.y=l))}function K(r,t="start"){const l=re.getElementScrollOffset(s.value,r,t),v={};p.value&&(v.x=o.ensureRangeValue(a.x+l.x,0,i.x)),x.value&&(v.y=o.ensureRangeValue(a.y+l.y,0,i.y)),R(v)}return C({scrollTop:e.computed(()=>a.y),scrollLeft:e.computed(()=>a.x),scroll:G,scrollTo:J,scrollIntoView:K}),(r,t)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:s,class:e.normalizeClass(e.unref(X)()),style:e.normalizeStyle(H.value),onWheel:[e.withModifiers(I,["exact"]),e.withModifiers(U,["shift"])]},[e.createElementVNode("div",{ref_key:"contentRef",ref:f,class:e.normalizeClass(e.unref(g)("content"))},[e.renderSlot(r.$slots,"default")],2),e.createElementVNode("div",{class:e.normalizeClass([e.unref(g)("bar-wrapper"),e.unref(z)("bar-wrapper","vertical")]),style:e.normalizeStyle(`height: calc(100% - ${p.value?r.xBarProps.trackWidth||10:0}px)`)},[x.value?(e.openBlock(),e.createBlock(e.unref(D.default),e.mergeProps({key:0,ref_key:"yBarRef",ref:O},r.yBarProps,{"bar-length":u.y,onScroll:t[0]||(t[0]=l=>q(l,"vertical"))}),null,16,["bar-length"])):e.createCommentVNode("",!0)],6),e.createElementVNode("div",{class:e.normalizeClass([e.unref(g)("bar-wrapper"),e.unref(z)("bar-wrapper","horizontal")])},[p.value?(e.openBlock(),e.createBlock(e.unref(D.default),e.mergeProps({key:0,ref_key:"xBarRef",ref:Y},r.xBarProps,{direction:"horizontal","bar-length":u.x,onScroll:t[1]||(t[1]=l=>q(l,"horizontal"))}),null,16,["bar-length"])):e.createCommentVNode("",!0)],2)],38))}});exports.default=ne;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index.vue.js");exports.default=e.default;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { InternalScrollBarProps, ScrollBarDirection } from '../scroll-bar';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
type BarExtraProps = Omit<InternalScrollBarProps, 'direction' | 'scroll' | 'barLength'>;
|
|
4
|
+
export type ScrollOffsetType = {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
export type AutoPlayConfig = {
|
|
9
|
+
/**
|
|
10
|
+
* 自动滚动的方向
|
|
11
|
+
*/
|
|
12
|
+
direction?: ScrollBarDirection;
|
|
13
|
+
/**
|
|
14
|
+
* 自动滚动的速率,每一帧滚动的长度
|
|
15
|
+
*/
|
|
16
|
+
rate?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 是否开启重复滚动
|
|
19
|
+
*/
|
|
20
|
+
repeat?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export interface ScrollViewProps {
|
|
23
|
+
/**
|
|
24
|
+
* 外部容器的宽度,当需要横向滚动条时必需设置
|
|
25
|
+
*/
|
|
26
|
+
width?: number | string;
|
|
27
|
+
/**
|
|
28
|
+
* 外部容器的高度,当需要竖向滚动时必须设置
|
|
29
|
+
*/
|
|
30
|
+
heigth?: number | string;
|
|
31
|
+
/**
|
|
32
|
+
* 是否显示横向滚动条(前提是可以横向滚动)
|
|
33
|
+
*/
|
|
34
|
+
showXBar?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* 是否显示竖向滚动条(前提是可以竖向滚动)
|
|
37
|
+
*/
|
|
38
|
+
showYBar?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 设置自动滚动
|
|
41
|
+
*/
|
|
42
|
+
autoPlay?: true | AutoPlayConfig;
|
|
43
|
+
/**
|
|
44
|
+
* 横向滚动条额外可配置的属性
|
|
45
|
+
*/
|
|
46
|
+
xBarProps?: BarExtraProps;
|
|
47
|
+
/**
|
|
48
|
+
* 竖向滚动条额外可配置属性
|
|
49
|
+
*/
|
|
50
|
+
yBarProps?: BarExtraProps;
|
|
51
|
+
/**
|
|
52
|
+
* 滚轮滚动事件
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
onWheel?: (direction: ScrollBarDirection, offset: number) => void;
|
|
56
|
+
}
|
|
57
|
+
export type ScrollOptions = {
|
|
58
|
+
top?: number;
|
|
59
|
+
left?: number;
|
|
60
|
+
smooth?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ScrollViewExpose = {
|
|
63
|
+
/**
|
|
64
|
+
* 当前滚动距离顶部的位置
|
|
65
|
+
*/
|
|
66
|
+
scrollTop: Ref<number>;
|
|
67
|
+
/**
|
|
68
|
+
* 当前滚动距离左侧的位置
|
|
69
|
+
*/
|
|
70
|
+
scrollLeft: Ref<number>;
|
|
71
|
+
/**
|
|
72
|
+
* 滚动到指定位置
|
|
73
|
+
* @param x
|
|
74
|
+
* @param y
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
scroll: (x?: number, y?: number) => void;
|
|
78
|
+
/**
|
|
79
|
+
* 滚动到指定位置(支持指定平滑滚动)
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
scrollTo: (options: ScrollOptions) => void;
|
|
84
|
+
/**
|
|
85
|
+
* 将子元素滚动到可视区域
|
|
86
|
+
* @param element
|
|
87
|
+
* @param position
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
scrollIntoView: (element: Element, position?: 'start' | 'center' | 'end') => void;
|
|
91
|
+
};
|
|
92
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取某个元素相对滚动容器可见应该滚动的偏移量(绝对值)
|
|
3
|
+
* @param container
|
|
4
|
+
* @param element
|
|
5
|
+
* @param position
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function getElementScrollOffset(container: HTMLElement, element: HTMLElement, position: 'start' | 'center' | 'end'): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(o,c,t){const e=o.getBoundingClientRect(),n=c.getBoundingClientRect(),s=t==="x"?"left":"top",f=t==="x"?"right":"bottom",l=t==="x"?"width":"height";return{start:n[s]-e[s],end:n[f]-e[f],center:n[f]-e[f]+(e[l]-n[l])/2}}function r(o,c,t){const e=g(o,c,"x"),n=g(o,c,"y");return{x:e[t],y:n[t]}}exports.getElementScrollOffset=r;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aplus-frontend/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -65,22 +65,23 @@
|
|
|
65
65
|
"sortablejs": "^1.15.2",
|
|
66
66
|
"vue-virtual-scroller": "2.0.0-beta.8",
|
|
67
67
|
"vuedraggable": "^4.1.0",
|
|
68
|
-
"@aplus-frontend/
|
|
69
|
-
"@aplus-frontend/
|
|
68
|
+
"@aplus-frontend/utils": "1.0.48",
|
|
69
|
+
"@aplus-frontend/hooks": "1.0.7"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@aplus-frontend/antdv": "^1.0.
|
|
72
|
+
"@aplus-frontend/antdv": "^1.0.11",
|
|
73
73
|
"@aplus-frontend/icon": "^1.2.1",
|
|
74
74
|
"@aplus-frontend/oss": "^1.1.2",
|
|
75
75
|
"vue": "^3.5.13"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@aplus-frontend/antdv": "^1.0.
|
|
78
|
+
"@aplus-frontend/antdv": "^1.0.11",
|
|
79
79
|
"@aplus-frontend/icon": "^1.2.1",
|
|
80
80
|
"@aplus-frontend/oss": "^1.1.2",
|
|
81
81
|
"@types/sortablejs": "^1.15.8",
|
|
82
82
|
"@vue/test-utils": "^2.4.6",
|
|
83
83
|
"axios": "^1.7.2",
|
|
84
|
+
"csstype": "^3.1.3",
|
|
84
85
|
"jsdom": "^25.0.0",
|
|
85
86
|
"vue": "^3.5.13",
|
|
86
87
|
"vue-types": "3.0.2",
|
package/theme/index.css
CHANGED
|
@@ -1769,7 +1769,7 @@ div.aplus-ap-info-layout-admin__header-shadow.aplus-ap-info-layout-admin__sticky
|
|
|
1769
1769
|
}
|
|
1770
1770
|
.aplus-scroll-bar__bar--horizontal {
|
|
1771
1771
|
height: var(--aplus-scroll-bar-bar-width, 8px);
|
|
1772
|
-
top: calc(var(--aplus-scroll-bar-track-width, 10px) - var(--aplus-scroll-bar-bar-width, 8px));
|
|
1772
|
+
top: calc(var(--aplus-scroll-bar-track-width, 10px) / 2 - var(--aplus-scroll-bar-bar-width, 8px) / 2);
|
|
1773
1773
|
}
|
|
1774
1774
|
.aplus-scroll-bar__bar--vertical {
|
|
1775
1775
|
width: var(--aplus-scroll-bar-bar-width, 8px);
|
|
@@ -2093,3 +2093,23 @@ div.aplus-ap-info-layout-admin__header-shadow.aplus-ap-info-layout-admin__sticky
|
|
|
2093
2093
|
.aplus-batch-input-group-popover-input__popover--content textarea {
|
|
2094
2094
|
padding: 0;
|
|
2095
2095
|
}
|
|
2096
|
+
.aplus-scroll-view {
|
|
2097
|
+
position: relative;
|
|
2098
|
+
overflow: hidden;
|
|
2099
|
+
}
|
|
2100
|
+
.aplus-scroll-view__content {
|
|
2101
|
+
display: inline-block;
|
|
2102
|
+
}
|
|
2103
|
+
.aplus-scroll-view__bar-wrapper {
|
|
2104
|
+
position: absolute;
|
|
2105
|
+
}
|
|
2106
|
+
.aplus-scroll-view__bar-wrapper--horizontal {
|
|
2107
|
+
left: 0;
|
|
2108
|
+
bottom: 0;
|
|
2109
|
+
width: 100%;
|
|
2110
|
+
}
|
|
2111
|
+
.aplus-scroll-view__bar-wrapper--vertical {
|
|
2112
|
+
top: 0;
|
|
2113
|
+
right: 0;
|
|
2114
|
+
height: 100%;
|
|
2115
|
+
}
|
package/theme/index.less
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
.aplus-scroll-bar__bar--horizontal {
|
|
40
40
|
height: var(--aplus-scroll-bar-bar-width, 8px);
|
|
41
|
-
top: calc(var(--aplus-scroll-bar-track-width, 10px) - var(--aplus-scroll-bar-bar-width, 8px));
|
|
41
|
+
top: calc(var(--aplus-scroll-bar-track-width, 10px) / 2 - var(--aplus-scroll-bar-bar-width, 8px) / 2);
|
|
42
42
|
}
|
|
43
43
|
.aplus-scroll-bar__bar--vertical {
|
|
44
44
|
width: var(--aplus-scroll-bar-bar-width, 8px);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.aplus-scroll-view {
|
|
2
|
+
position: relative;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
}
|
|
5
|
+
.aplus-scroll-view__content {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
}
|
|
8
|
+
.aplus-scroll-view__bar-wrapper {
|
|
9
|
+
position: absolute;
|
|
10
|
+
}
|
|
11
|
+
.aplus-scroll-view__bar-wrapper--horizontal {
|
|
12
|
+
left: 0;
|
|
13
|
+
bottom: 0;
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
.aplus-scroll-view__bar-wrapper--vertical {
|
|
17
|
+
top: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '../mixins/mixins.less';
|
|
2
|
+
@import '../mixins/config.less';
|
|
3
|
+
|
|
4
|
+
.b(scroll-view, {
|
|
5
|
+
position: relative;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
&__content {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
10
|
+
&__bar-wrapper {
|
|
11
|
+
position: absolute;
|
|
12
|
+
&--horizontal {
|
|
13
|
+
left: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
&--vertical {
|
|
18
|
+
top: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
height: 100%
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|