@varlet/ui 1.20.1-alpha.1 → 1.20.1-alpha.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-anchor/IndexAnchor.js +13 -2
- package/es/index-bar/IndexBar.js +11 -1
- package/es/index-bar/props.js +4 -0
- package/es/snackbar/style/index.js +1 -1
- package/es/snackbar/style/less.js +1 -1
- package/es/sticky/Sticky.js +27 -20
- package/es/sticky/props.js +4 -0
- package/es/sticky/sticky.css +1 -1
- package/es/sticky/sticky.less +2 -0
- package/highlight/attributes.json +8 -0
- package/highlight/tags.json +3 -1
- package/highlight/web-types.json +18 -0
- package/package.json +3 -3
- package/types/indexBar.d.ts +1 -0
- package/types/sticky.d.ts +2 -0
- package/umd/varlet.js +1 -1
|
@@ -10,6 +10,8 @@ export var render = /*#__PURE__*/_withId((_ctx, _cache) => {
|
|
|
10
10
|
return _openBlock(), _createBlock(_resolveDynamicComponent(_ctx.sticky ? 'var-sticky' : _ctx.Transition), {
|
|
11
11
|
"offset-top": _ctx.sticky ? _ctx.stickyOffsetTop : null,
|
|
12
12
|
"z-index": _ctx.sticky ? _ctx.zIndex : null,
|
|
13
|
+
disabled: _ctx.disabled && !_ctx.cssMode,
|
|
14
|
+
"css-mode": _ctx.cssMode,
|
|
13
15
|
ref: "anchorEl"
|
|
14
16
|
}, {
|
|
15
17
|
default: _withId(() => [_createVNode("div", _mergeProps({
|
|
@@ -24,7 +26,7 @@ export var render = /*#__PURE__*/_withId((_ctx, _cache) => {
|
|
|
24
26
|
|
|
25
27
|
}, 8
|
|
26
28
|
/* PROPS */
|
|
27
|
-
, ["offset-top", "z-index"]);
|
|
29
|
+
, ["offset-top", "z-index", "disabled", "css-mode"]);
|
|
28
30
|
});
|
|
29
31
|
export default defineComponent({
|
|
30
32
|
render,
|
|
@@ -42,6 +44,7 @@ export default defineComponent({
|
|
|
42
44
|
bindIndexBar
|
|
43
45
|
} = useIndexBar();
|
|
44
46
|
var ownTop = ref(0);
|
|
47
|
+
var disabled = ref(false);
|
|
45
48
|
var name = computed(() => props.index);
|
|
46
49
|
var anchorEl = ref(null);
|
|
47
50
|
|
|
@@ -53,6 +56,7 @@ export default defineComponent({
|
|
|
53
56
|
var {
|
|
54
57
|
active,
|
|
55
58
|
sticky,
|
|
59
|
+
cssMode,
|
|
56
60
|
stickyOffsetTop,
|
|
57
61
|
zIndex
|
|
58
62
|
} = indexBar;
|
|
@@ -62,11 +66,16 @@ export default defineComponent({
|
|
|
62
66
|
ownTop.value = anchorEl.value.$el ? anchorEl.value.$el.offsetTop : anchorEl.value.offsetTop;
|
|
63
67
|
};
|
|
64
68
|
|
|
69
|
+
var setDisabled = value => {
|
|
70
|
+
disabled.value = value;
|
|
71
|
+
};
|
|
72
|
+
|
|
65
73
|
var indexAnchorProvider = {
|
|
66
74
|
index,
|
|
67
75
|
name,
|
|
68
76
|
ownTop,
|
|
69
|
-
setOwnTop
|
|
77
|
+
setOwnTop,
|
|
78
|
+
setDisabled
|
|
70
79
|
};
|
|
71
80
|
bindIndexBar(indexAnchorProvider);
|
|
72
81
|
return {
|
|
@@ -75,6 +84,8 @@ export default defineComponent({
|
|
|
75
84
|
active,
|
|
76
85
|
sticky,
|
|
77
86
|
zIndex,
|
|
87
|
+
disabled,
|
|
88
|
+
cssMode,
|
|
78
89
|
stickyOffsetTop,
|
|
79
90
|
Transition
|
|
80
91
|
};
|
package/es/index-bar/IndexBar.js
CHANGED
|
@@ -66,11 +66,13 @@ export default defineComponent({
|
|
|
66
66
|
var anchorNameList = ref([]);
|
|
67
67
|
var active = ref();
|
|
68
68
|
var sticky = computed(() => props.sticky);
|
|
69
|
+
var cssMode = computed(() => props.cssMode);
|
|
69
70
|
var stickyOffsetTop = computed(() => props.stickyOffsetTop);
|
|
70
71
|
var zIndex = computed(() => props.zIndex);
|
|
71
72
|
var indexBarProvider = {
|
|
72
73
|
active,
|
|
73
74
|
sticky,
|
|
75
|
+
cssMode,
|
|
74
76
|
stickyOffsetTop,
|
|
75
77
|
zIndex
|
|
76
78
|
};
|
|
@@ -88,12 +90,20 @@ export default defineComponent({
|
|
|
88
90
|
scrollTop,
|
|
89
91
|
scrollHeight
|
|
90
92
|
} = scrollEl.value;
|
|
93
|
+
var {
|
|
94
|
+
offsetTop
|
|
95
|
+
} = barEl.value;
|
|
91
96
|
indexAnchors.forEach((anchor, index) => {
|
|
92
97
|
var anchorTop = anchor.ownTop.value;
|
|
93
|
-
var top = scrollTop - anchorTop + stickyOffsetTop.value;
|
|
98
|
+
var top = scrollTop - anchorTop + stickyOffsetTop.value - offsetTop;
|
|
94
99
|
var distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].ownTop.value - anchor.ownTop.value;
|
|
95
100
|
|
|
96
101
|
if (top >= 0 && top < distance && !clickedName.value) {
|
|
102
|
+
if (index && !props.cssMode) {
|
|
103
|
+
indexAnchors[index - 1].setDisabled(true);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
anchor.setDisabled(false);
|
|
97
107
|
emitEvent(anchor);
|
|
98
108
|
}
|
|
99
109
|
});
|
package/es/index-bar/props.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.css'
|
|
2
|
+
import '../SnackbarSfc.css'
|
|
2
3
|
import '../../styles/elevation.css'
|
|
3
4
|
import '../../loading/loading.css'
|
|
4
5
|
import '../../button/button.css'
|
|
5
6
|
import '../../icon/icon.css'
|
|
6
7
|
import '../snackbar.css'
|
|
7
8
|
import '../coreSfc.css'
|
|
8
|
-
import '../SnackbarSfc.css'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.less'
|
|
2
|
+
import '../SnackbarSfc.less'
|
|
2
3
|
import '../../styles/elevation.less'
|
|
3
4
|
import '../../loading/loading.less'
|
|
4
5
|
import '../../button/button.less'
|
|
5
6
|
import '../../icon/icon.less'
|
|
6
7
|
import '../snackbar.less'
|
|
7
8
|
import '../coreSfc.less'
|
|
8
|
-
import '../SnackbarSfc.less'
|
package/es/sticky/Sticky.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref, onMounted, onUnmounted, onActivated, onDeactivated, computed } from 'vue';
|
|
1
|
+
import { defineComponent, ref, onMounted, onUnmounted, onActivated, onDeactivated, computed, watch } from 'vue';
|
|
2
2
|
import { props } from './props';
|
|
3
3
|
import { getParentScroller, toPxNum } from '../utils/elements';
|
|
4
4
|
import { toNumber } from '../utils/shared';
|
|
@@ -8,24 +8,24 @@ var _withId = /*#__PURE__*/_withScopeId("");
|
|
|
8
8
|
|
|
9
9
|
export var render = /*#__PURE__*/_withId((_ctx, _cache) => {
|
|
10
10
|
return _openBlock(), _createBlock("div", {
|
|
11
|
-
class: ["var-sticky", [_ctx.
|
|
11
|
+
class: ["var-sticky", [_ctx.enableCSSMode ? 'var-sticky--css-mode' : null]],
|
|
12
12
|
ref: "stickyEl",
|
|
13
13
|
style: {
|
|
14
14
|
zIndex: _ctx.toNumber(_ctx.zIndex),
|
|
15
|
-
top:
|
|
16
|
-
width: _ctx.
|
|
17
|
-
height: _ctx.
|
|
15
|
+
top: _ctx.enableCSSMode ? _ctx.offsetTop + "px" : null,
|
|
16
|
+
width: _ctx.enableFixedMode ? _ctx.fixedWidth : null,
|
|
17
|
+
height: _ctx.enableFixedMode ? _ctx.fixedHeight : null
|
|
18
18
|
}
|
|
19
19
|
}, [_createVNode("div", {
|
|
20
20
|
class: "var-sticky__wrapper",
|
|
21
21
|
ref: "wrapperEl",
|
|
22
22
|
style: {
|
|
23
23
|
zIndex: _ctx.toNumber(_ctx.zIndex),
|
|
24
|
-
position: _ctx.
|
|
25
|
-
width: _ctx.
|
|
26
|
-
height: _ctx.
|
|
27
|
-
left: _ctx.
|
|
28
|
-
top: _ctx.
|
|
24
|
+
position: _ctx.enableFixedMode ? 'fixed' : null,
|
|
25
|
+
width: _ctx.enableFixedMode ? _ctx.fixedWrapperWidth : null,
|
|
26
|
+
height: _ctx.enableFixedMode ? _ctx.fixedWrapperHeight : null,
|
|
27
|
+
left: _ctx.enableFixedMode ? _ctx.fixedLeft : null,
|
|
28
|
+
top: _ctx.enableFixedMode ? _ctx.fixedTop : null
|
|
29
29
|
}
|
|
30
30
|
}, [_renderSlot(_ctx.$slots, "default")], 4
|
|
31
31
|
/* STYLE */
|
|
@@ -41,7 +41,6 @@ export default defineComponent({
|
|
|
41
41
|
setup(props) {
|
|
42
42
|
var stickyEl = ref(null);
|
|
43
43
|
var wrapperEl = ref(null);
|
|
44
|
-
var isSupportCSSSticky;
|
|
45
44
|
var isFixed = ref(false);
|
|
46
45
|
var fixedTop = ref('0px');
|
|
47
46
|
var fixedLeft = ref('0px');
|
|
@@ -49,10 +48,22 @@ export default defineComponent({
|
|
|
49
48
|
var fixedHeight = ref('auto');
|
|
50
49
|
var fixedWrapperWidth = ref('auto');
|
|
51
50
|
var fixedWrapperHeight = ref('auto');
|
|
51
|
+
var enableCSSMode = computed(() => !props.disabled && props.cssMode);
|
|
52
|
+
var enableFixedMode = computed(() => !props.disabled && isFixed.value);
|
|
52
53
|
var offsetTop = computed(() => toPxNum(props.offsetTop));
|
|
53
54
|
var scroller = window;
|
|
54
55
|
|
|
55
56
|
var handleScroll = () => {
|
|
57
|
+
var {
|
|
58
|
+
onScroll,
|
|
59
|
+
cssMode,
|
|
60
|
+
disabled
|
|
61
|
+
} = props;
|
|
62
|
+
|
|
63
|
+
if (disabled) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
var scrollerTop = 0;
|
|
57
68
|
|
|
58
69
|
if (scroller !== window) {
|
|
@@ -69,13 +80,9 @@ export default defineComponent({
|
|
|
69
80
|
left: stickyLeft
|
|
70
81
|
} = sticky.getBoundingClientRect();
|
|
71
82
|
var currentOffsetTop = stickyTop - scrollerTop;
|
|
72
|
-
var {
|
|
73
|
-
onScroll,
|
|
74
|
-
cssMode
|
|
75
|
-
} = props;
|
|
76
83
|
|
|
77
84
|
if (currentOffsetTop <= offsetTop.value) {
|
|
78
|
-
if (!
|
|
85
|
+
if (!cssMode) {
|
|
79
86
|
fixedWidth.value = sticky.offsetWidth + "px";
|
|
80
87
|
fixedHeight.value = sticky.offsetHeight + "px";
|
|
81
88
|
fixedTop.value = scrollerTop + offsetTop.value + "px";
|
|
@@ -104,12 +111,10 @@ export default defineComponent({
|
|
|
104
111
|
window.removeEventListener('scroll', handleScroll);
|
|
105
112
|
};
|
|
106
113
|
|
|
114
|
+
watch(() => props.disabled, handleScroll);
|
|
107
115
|
onActivated(addScrollListener);
|
|
108
116
|
onDeactivated(removeScrollListener);
|
|
109
|
-
onMounted(
|
|
110
|
-
isSupportCSSSticky = ['sticky', '-webkit-sticky'].includes(window.getComputedStyle(stickyEl.value).position);
|
|
111
|
-
addScrollListener();
|
|
112
|
-
});
|
|
117
|
+
onMounted(addScrollListener);
|
|
113
118
|
onUnmounted(removeScrollListener);
|
|
114
119
|
return {
|
|
115
120
|
stickyEl,
|
|
@@ -122,6 +127,8 @@ export default defineComponent({
|
|
|
122
127
|
fixedHeight,
|
|
123
128
|
fixedWrapperWidth,
|
|
124
129
|
fixedWrapperHeight,
|
|
130
|
+
enableCSSMode,
|
|
131
|
+
enableFixedMode,
|
|
125
132
|
toNumber
|
|
126
133
|
};
|
|
127
134
|
}
|
package/es/sticky/props.js
CHANGED
package/es/sticky/sticky.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.var-sticky--css-mode { position: sticky; position: -webkit-sticky;}
|
|
1
|
+
.var-sticky { position: relative;}.var-sticky--css-mode { position: sticky; position: -webkit-sticky;}
|
package/es/sticky/sticky.less
CHANGED
|
@@ -711,6 +711,10 @@
|
|
|
711
711
|
"type": "boolean",
|
|
712
712
|
"description": "是否隐藏锚点列表 默认值:false"
|
|
713
713
|
},
|
|
714
|
+
"var-index-bar/css-mode": {
|
|
715
|
+
"type": "boolean",
|
|
716
|
+
"description": "开启原生`css sticky`模式 默认值:false"
|
|
717
|
+
},
|
|
714
718
|
"var-index-bar/z-index": {
|
|
715
719
|
"type": "number | string",
|
|
716
720
|
"description": "z-index 层级 默认值:1"
|
|
@@ -1363,6 +1367,10 @@
|
|
|
1363
1367
|
"type": "boolean",
|
|
1364
1368
|
"description": "开启原生`css sticky`模式 默认值:false"
|
|
1365
1369
|
},
|
|
1370
|
+
"var-sticky/disabled": {
|
|
1371
|
+
"type": "boolean",
|
|
1372
|
+
"description": "禁用吸顶, 设置为`true`时, 元素会回到文档流中 默认值:false"
|
|
1373
|
+
},
|
|
1366
1374
|
"var-style-provider/style-vars": {
|
|
1367
1375
|
"type": "Record<string, string>",
|
|
1368
1376
|
"description": "css变量 默认值:{}"
|
package/highlight/tags.json
CHANGED
|
@@ -274,6 +274,7 @@
|
|
|
274
274
|
"sticky",
|
|
275
275
|
"sticky-offset-top",
|
|
276
276
|
"hide-list",
|
|
277
|
+
"css-mode",
|
|
277
278
|
"z-index",
|
|
278
279
|
"highlight-color",
|
|
279
280
|
"duration"
|
|
@@ -525,7 +526,8 @@
|
|
|
525
526
|
"attributes": [
|
|
526
527
|
"offset-top",
|
|
527
528
|
"z-index",
|
|
528
|
-
"css-mode"
|
|
529
|
+
"css-mode",
|
|
530
|
+
"disabled"
|
|
529
531
|
]
|
|
530
532
|
},
|
|
531
533
|
"var-style-provider": {
|
package/highlight/web-types.json
CHANGED
|
@@ -2150,6 +2150,15 @@
|
|
|
2150
2150
|
"kind": "expression"
|
|
2151
2151
|
}
|
|
2152
2152
|
},
|
|
2153
|
+
{
|
|
2154
|
+
"name": "css-mode",
|
|
2155
|
+
"description": "开启原生`css sticky`模式",
|
|
2156
|
+
"default": "false",
|
|
2157
|
+
"value": {
|
|
2158
|
+
"type": "boolean",
|
|
2159
|
+
"kind": "expression"
|
|
2160
|
+
}
|
|
2161
|
+
},
|
|
2153
2162
|
{
|
|
2154
2163
|
"name": "z-index",
|
|
2155
2164
|
"description": "z-index 层级",
|
|
@@ -4087,6 +4096,15 @@
|
|
|
4087
4096
|
"type": "boolean",
|
|
4088
4097
|
"kind": "expression"
|
|
4089
4098
|
}
|
|
4099
|
+
},
|
|
4100
|
+
{
|
|
4101
|
+
"name": "disabled",
|
|
4102
|
+
"description": "禁用吸顶, 设置为`true`时, 元素会回到文档流中",
|
|
4103
|
+
"default": "false",
|
|
4104
|
+
"value": {
|
|
4105
|
+
"type": "boolean",
|
|
4106
|
+
"kind": "expression"
|
|
4107
|
+
}
|
|
4090
4108
|
}
|
|
4091
4109
|
],
|
|
4092
4110
|
"events": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/ui",
|
|
3
|
-
"version": "1.20.1-alpha.
|
|
3
|
+
"version": "1.20.1-alpha.10+89c77d4c",
|
|
4
4
|
"description": "A material like components library",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"vue": "^3.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "89c77d4cb34cca2a4734796192dbd8403cca288d",
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@varlet/cli": "^1.20.1-alpha.
|
|
50
|
+
"@varlet/cli": "^1.20.1-alpha.10+89c77d4c"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"dayjs": "^1.10.4",
|
package/types/indexBar.d.ts
CHANGED
package/types/sticky.d.ts
CHANGED