@varlet/ui 2.8.0-alpha.1676441771603 → 2.8.0-alpha.1676455225773
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/avatar/Avatar.mjs +148 -0
- package/es/avatar/AvatarSfc.css +0 -0
- package/es/avatar/avatar.css +1 -0
- package/es/avatar/index.mjs +9 -0
- package/es/avatar/props.mjs +53 -0
- package/es/avatar/style/index.mjs +3 -0
- package/es/avatar-group/AvatarGroup.mjs +46 -0
- package/es/avatar-group/AvatarGroupSfc.css +0 -0
- package/es/avatar-group/avatarGroup.css +1 -0
- package/es/avatar-group/index.mjs +9 -0
- package/es/avatar-group/props.mjs +9 -0
- package/es/avatar-group/style/index.mjs +3 -0
- package/es/cell/props.mjs +1 -3
- package/es/index.bundle.mjs +13 -1
- package/es/index.mjs +11 -1
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/style.mjs +2 -0
- package/es/themes/dark/avatar.mjs +4 -0
- package/es/themes/dark/index.mjs +2 -2
- package/es/varlet.esm.js +3855 -3626
- package/highlight/web-types.en-US.json +116 -1
- package/highlight/web-types.zh-CN.json +116 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +325 -61
- package/package.json +5 -5
- package/types/avatar.d.ts +29 -0
- package/types/avatarGroup.d.ts +14 -0
- package/types/index.d.ts +4 -0
- package/umd/style.css +1 -1
- package/umd/varlet.js +6 -6
- package/es/themes/dark/paper.mjs +0 -3
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineComponent, ref, onMounted, onUpdated } from 'vue';
|
|
2
|
+
import { props, internalSizeValidator, sizeValidator } from './props.mjs';
|
|
3
|
+
import { toSizeUnit } from '../utils/elements.mjs';
|
|
4
|
+
import { createNamespace, call } from '../utils/components.mjs';
|
|
5
|
+
var {
|
|
6
|
+
n,
|
|
7
|
+
classes
|
|
8
|
+
} = createNamespace('avatar');
|
|
9
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, withDirectives as _withDirectives, openBlock as _openBlock, createElementBlock as _createElementBlock, Fragment as _Fragment, renderSlot as _renderSlot, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
10
|
+
|
|
11
|
+
var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
12
|
+
|
|
13
|
+
var _hoisted_1 = ["src", "lazy-loading", "lazy-error"];
|
|
14
|
+
var _hoisted_2 = ["src"];
|
|
15
|
+
|
|
16
|
+
function __render__(_ctx, _cache) {
|
|
17
|
+
var _directive_lazy = _resolveDirective("lazy");
|
|
18
|
+
|
|
19
|
+
return _openBlock(), _createElementBlock("div", {
|
|
20
|
+
ref: "avatarElement",
|
|
21
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.internalSizeValidator(_ctx.size), _ctx.n("--" + _ctx.size)], [_ctx.round, _ctx.n('--round')], [_ctx.bordered, _ctx.n('--bordered')])),
|
|
22
|
+
style: _normalizeStyle({
|
|
23
|
+
width: !_ctx.internalSizeValidator(_ctx.size) ? _ctx.toSizeUnit(_ctx.size) : undefined,
|
|
24
|
+
height: !_ctx.internalSizeValidator(_ctx.size) ? _ctx.toSizeUnit(_ctx.size) : undefined,
|
|
25
|
+
borderColor: _ctx.borderColor,
|
|
26
|
+
backgroundColor: _ctx.color
|
|
27
|
+
}),
|
|
28
|
+
onClick: _cache[3] || (_cache[3] = function () {
|
|
29
|
+
return _ctx.handleClick && _ctx.handleClick(...arguments);
|
|
30
|
+
})
|
|
31
|
+
}, [_ctx.src ? (_openBlock(), _createElementBlock(_Fragment, {
|
|
32
|
+
key: 0
|
|
33
|
+
}, [_ctx.lazy ? _withDirectives((_openBlock(), _createElementBlock("img", {
|
|
34
|
+
key: 0,
|
|
35
|
+
class: _normalizeClass(_ctx.n('image')),
|
|
36
|
+
src: _ctx.src,
|
|
37
|
+
style: _normalizeStyle({
|
|
38
|
+
objectFit: _ctx.fit
|
|
39
|
+
}),
|
|
40
|
+
"lazy-loading": _ctx.loading,
|
|
41
|
+
"lazy-error": _ctx.error,
|
|
42
|
+
onLoad: _cache[0] || (_cache[0] = function () {
|
|
43
|
+
return _ctx.handleLoad && _ctx.handleLoad(...arguments);
|
|
44
|
+
})
|
|
45
|
+
}, null, 46
|
|
46
|
+
/* CLASS, STYLE, PROPS, HYDRATE_EVENTS */
|
|
47
|
+
, _hoisted_1)), [[_directive_lazy, _ctx.src]]) : (_openBlock(), _createElementBlock("img", {
|
|
48
|
+
key: 1,
|
|
49
|
+
class: _normalizeClass(_ctx.n('image')),
|
|
50
|
+
src: _ctx.src,
|
|
51
|
+
style: _normalizeStyle({
|
|
52
|
+
objectFit: _ctx.fit
|
|
53
|
+
}),
|
|
54
|
+
onLoad: _cache[1] || (_cache[1] = function () {
|
|
55
|
+
return _ctx.handleLoad && _ctx.handleLoad(...arguments);
|
|
56
|
+
}),
|
|
57
|
+
onError: _cache[2] || (_cache[2] = function () {
|
|
58
|
+
return _ctx.handleError && _ctx.handleError(...arguments);
|
|
59
|
+
})
|
|
60
|
+
}, null, 46
|
|
61
|
+
/* CLASS, STYLE, PROPS, HYDRATE_EVENTS */
|
|
62
|
+
, _hoisted_2))], 2112
|
|
63
|
+
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
64
|
+
)) : (_openBlock(), _createElementBlock("div", {
|
|
65
|
+
key: 1,
|
|
66
|
+
ref: "textElement",
|
|
67
|
+
class: _normalizeClass(_ctx.n('text')),
|
|
68
|
+
style: _normalizeStyle({
|
|
69
|
+
scale: _ctx.scale
|
|
70
|
+
})
|
|
71
|
+
}, [_renderSlot(_ctx.$slots, "default")], 6
|
|
72
|
+
/* CLASS, STYLE */
|
|
73
|
+
))], 6
|
|
74
|
+
/* CLASS, STYLE */
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var __sfc__ = defineComponent({
|
|
79
|
+
name: 'VarAvatar',
|
|
80
|
+
components: {},
|
|
81
|
+
props,
|
|
82
|
+
|
|
83
|
+
setup(props) {
|
|
84
|
+
var avatarElement = ref(null);
|
|
85
|
+
var textElement = ref(null);
|
|
86
|
+
var scale = ref(1);
|
|
87
|
+
|
|
88
|
+
var getScale = () => {
|
|
89
|
+
if (!avatarElement.value || !textElement.value) {
|
|
90
|
+
scale.value = 1;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var avatarElementWidth = avatarElement.value.offsetWidth;
|
|
95
|
+
var textElementWidth = textElement.value.offsetWidth;
|
|
96
|
+
|
|
97
|
+
if (avatarElementWidth > textElementWidth) {
|
|
98
|
+
scale.value = 1;
|
|
99
|
+
} else {
|
|
100
|
+
scale.value = avatarElementWidth / textElementWidth;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var handleLoad = e => {
|
|
105
|
+
var el = e.currentTarget;
|
|
106
|
+
var {
|
|
107
|
+
lazy,
|
|
108
|
+
onLoad,
|
|
109
|
+
onError
|
|
110
|
+
} = props;
|
|
111
|
+
|
|
112
|
+
if (lazy) {
|
|
113
|
+
el._lazy.state === 'success' && call(onLoad, e);
|
|
114
|
+
el._lazy.state === 'error' && call(onError, e);
|
|
115
|
+
} else {
|
|
116
|
+
call(onLoad, e);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var handleError = e => {
|
|
121
|
+
call(props.onError, e);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var handleClick = e => {
|
|
125
|
+
call(props.onClick, e);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
onMounted(getScale);
|
|
129
|
+
onUpdated(getScale);
|
|
130
|
+
return {
|
|
131
|
+
internalSizeValidator,
|
|
132
|
+
sizeValidator,
|
|
133
|
+
toSizeUnit,
|
|
134
|
+
n,
|
|
135
|
+
classes,
|
|
136
|
+
avatarElement,
|
|
137
|
+
textElement,
|
|
138
|
+
scale,
|
|
139
|
+
handleLoad,
|
|
140
|
+
handleError,
|
|
141
|
+
handleClick
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
__sfc__.render = __render__;
|
|
148
|
+
export default __sfc__;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root { --avatar-text-color: #f5f5f5; --avatar-border-radius: 4px; --avatar-mini-size: 28px; --avatar-small-size: 36px; --avatar-normal-size: 48px; --avatar-large-size: 64px; --avatar-border: 2px solid #fff; --avatar-background-color: #bebebe;}.var-avatar { display: inline-flex; overflow: hidden; align-items: center; justify-content: center; color: var(--avatar-text-color); border-radius: var(--avatar-border-radius); background-color: var(--avatar-background-color); transition: background-color 0.25s;}.var-avatar img { width: 100%; height: 100%;}.var-avatar--mini { width: var(--avatar-mini-size); height: var(--avatar-mini-size);}.var-avatar--small { width: var(--avatar-small-size); height: var(--avatar-small-size);}.var-avatar--normal { width: var(--avatar-normal-size); height: var(--avatar-normal-size);}.var-avatar--large { width: var(--avatar-large-size); height: var(--avatar-large-size);}.var-avatar--round { border-radius: 50%;}.var-avatar--bordered { border: var(--avatar-border);}.var-avatar__text { padding: 0 4px; white-space: nowrap;}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineListenerProp } from '../utils/components.mjs';
|
|
2
|
+
import { isNumber, isString } from '@varlet/shared';
|
|
3
|
+
|
|
4
|
+
function fitValidator(fit) {
|
|
5
|
+
return ['fill', 'contain', 'cover', 'none', 'scale-down'].includes(fit);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export var internalSizeValidator = size => ['mini', 'small', 'normal', 'large'].includes(size);
|
|
9
|
+
export function sizeValidator(size) {
|
|
10
|
+
return internalSizeValidator(size) || isNumber(size) || isString(size);
|
|
11
|
+
}
|
|
12
|
+
export var props = {
|
|
13
|
+
round: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: true
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
type: [String, Number],
|
|
19
|
+
validator: sizeValidator,
|
|
20
|
+
default: 'normal'
|
|
21
|
+
},
|
|
22
|
+
color: {
|
|
23
|
+
type: String
|
|
24
|
+
},
|
|
25
|
+
src: {
|
|
26
|
+
type: String
|
|
27
|
+
},
|
|
28
|
+
fit: {
|
|
29
|
+
type: String,
|
|
30
|
+
validator: fitValidator,
|
|
31
|
+
default: 'cover'
|
|
32
|
+
},
|
|
33
|
+
bordered: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
},
|
|
37
|
+
borderColor: {
|
|
38
|
+
type: String
|
|
39
|
+
},
|
|
40
|
+
loading: {
|
|
41
|
+
type: String
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
type: String
|
|
45
|
+
},
|
|
46
|
+
lazy: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
onClick: defineListenerProp(),
|
|
51
|
+
onLoad: defineListenerProp(),
|
|
52
|
+
onError: defineListenerProp()
|
|
53
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineComponent, computed } from 'vue';
|
|
2
|
+
import { props } from './props.mjs';
|
|
3
|
+
import { createNamespace } from '../utils/components.mjs';
|
|
4
|
+
import { toSizeUnit } from '../utils/elements.mjs';
|
|
5
|
+
var {
|
|
6
|
+
n,
|
|
7
|
+
classes
|
|
8
|
+
} = createNamespace('avatar-group');
|
|
9
|
+
import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
10
|
+
|
|
11
|
+
function __render__(_ctx, _cache) {
|
|
12
|
+
return _openBlock(), _createElementBlock("div", {
|
|
13
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.vertical, _ctx.n('--column'), _ctx.n('--row')])),
|
|
14
|
+
style: _normalizeStyle(_ctx.rootStyles)
|
|
15
|
+
}, [_renderSlot(_ctx.$slots, "default"), _renderSlot(_ctx.$slots, "rest")], 6
|
|
16
|
+
/* CLASS, STYLE */
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var __sfc__ = defineComponent({
|
|
21
|
+
name: 'VarAvatarGroup',
|
|
22
|
+
components: {},
|
|
23
|
+
props,
|
|
24
|
+
|
|
25
|
+
setup(props) {
|
|
26
|
+
var rootStyles = computed(() => {
|
|
27
|
+
if (props.offset == null) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
'--avatar-group-offset': toSizeUnit(props.offset)
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
n,
|
|
37
|
+
classes,
|
|
38
|
+
toSizeUnit,
|
|
39
|
+
rootStyles
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
__sfc__.render = __render__;
|
|
46
|
+
export default __sfc__;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root { --avatar-group-offset: -10px;}.var-avatar-group { display: flex; flex-wrap: wrap;}.var-avatar-group--row { margin-left: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--row > * { margin-left: var(--avatar-group-offset);}.var-avatar-group--column { flex-direction: column; margin-top: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--column > * { margin-top: var(--avatar-group-offset);}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AvatarGroup from './AvatarGroup.mjs';
|
|
2
|
+
|
|
3
|
+
AvatarGroup.install = function (app) {
|
|
4
|
+
app.component(AvatarGroup.name, AvatarGroup);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { props as avatarGroupProps } from './props.mjs';
|
|
8
|
+
export var _AvatarGroupComponent = AvatarGroup;
|
|
9
|
+
export default AvatarGroup;
|
package/es/cell/props.mjs
CHANGED
package/es/index.bundle.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import ActionSheet from './action-sheet/index.mjs'
|
|
2
2
|
import AppBar from './app-bar/index.mjs'
|
|
3
|
+
import Avatar from './avatar/index.mjs'
|
|
4
|
+
import AvatarGroup from './avatar-group/index.mjs'
|
|
3
5
|
import BackTop from './back-top/index.mjs'
|
|
4
6
|
import Badge from './badge/index.mjs'
|
|
5
7
|
import BottomNavigation from './bottom-navigation/index.mjs'
|
|
@@ -75,6 +77,8 @@ import Uploader from './uploader/index.mjs'
|
|
|
75
77
|
|
|
76
78
|
export * from './action-sheet/index.mjs'
|
|
77
79
|
export * from './app-bar/index.mjs'
|
|
80
|
+
export * from './avatar/index.mjs'
|
|
81
|
+
export * from './avatar-group/index.mjs'
|
|
78
82
|
export * from './back-top/index.mjs'
|
|
79
83
|
export * from './badge/index.mjs'
|
|
80
84
|
export * from './bottom-navigation/index.mjs'
|
|
@@ -150,6 +154,8 @@ export * from './uploader/index.mjs'
|
|
|
150
154
|
|
|
151
155
|
import './action-sheet/style/index.mjs'
|
|
152
156
|
import './app-bar/style/index.mjs'
|
|
157
|
+
import './avatar/style/index.mjs'
|
|
158
|
+
import './avatar-group/style/index.mjs'
|
|
153
159
|
import './back-top/style/index.mjs'
|
|
154
160
|
import './badge/style/index.mjs'
|
|
155
161
|
import './bottom-navigation/style/index.mjs'
|
|
@@ -223,11 +229,13 @@ import './time-picker/style/index.mjs'
|
|
|
223
229
|
import './tooltip/style/index.mjs'
|
|
224
230
|
import './uploader/style/index.mjs'
|
|
225
231
|
|
|
226
|
-
const version = '2.8.0-alpha.
|
|
232
|
+
const version = '2.8.0-alpha.1676455225773'
|
|
227
233
|
|
|
228
234
|
function install(app) {
|
|
229
235
|
ActionSheet.install && app.use(ActionSheet)
|
|
230
236
|
AppBar.install && app.use(AppBar)
|
|
237
|
+
Avatar.install && app.use(Avatar)
|
|
238
|
+
AvatarGroup.install && app.use(AvatarGroup)
|
|
231
239
|
BackTop.install && app.use(BackTop)
|
|
232
240
|
Badge.install && app.use(Badge)
|
|
233
241
|
BottomNavigation.install && app.use(BottomNavigation)
|
|
@@ -307,6 +315,8 @@ export {
|
|
|
307
315
|
install,
|
|
308
316
|
ActionSheet,
|
|
309
317
|
AppBar,
|
|
318
|
+
Avatar,
|
|
319
|
+
AvatarGroup,
|
|
310
320
|
BackTop,
|
|
311
321
|
Badge,
|
|
312
322
|
BottomNavigation,
|
|
@@ -386,6 +396,8 @@ export default {
|
|
|
386
396
|
install,
|
|
387
397
|
ActionSheet,
|
|
388
398
|
AppBar,
|
|
399
|
+
Avatar,
|
|
400
|
+
AvatarGroup,
|
|
389
401
|
BackTop,
|
|
390
402
|
Badge,
|
|
391
403
|
BottomNavigation,
|
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import ActionSheet from './action-sheet/index.mjs'
|
|
2
2
|
import AppBar from './app-bar/index.mjs'
|
|
3
|
+
import Avatar from './avatar/index.mjs'
|
|
4
|
+
import AvatarGroup from './avatar-group/index.mjs'
|
|
3
5
|
import BackTop from './back-top/index.mjs'
|
|
4
6
|
import Badge from './badge/index.mjs'
|
|
5
7
|
import BottomNavigation from './bottom-navigation/index.mjs'
|
|
@@ -75,6 +77,8 @@ import Uploader from './uploader/index.mjs'
|
|
|
75
77
|
|
|
76
78
|
export * from './action-sheet/index.mjs'
|
|
77
79
|
export * from './app-bar/index.mjs'
|
|
80
|
+
export * from './avatar/index.mjs'
|
|
81
|
+
export * from './avatar-group/index.mjs'
|
|
78
82
|
export * from './back-top/index.mjs'
|
|
79
83
|
export * from './badge/index.mjs'
|
|
80
84
|
export * from './bottom-navigation/index.mjs'
|
|
@@ -148,11 +152,13 @@ export * from './time-picker/index.mjs'
|
|
|
148
152
|
export * from './tooltip/index.mjs'
|
|
149
153
|
export * from './uploader/index.mjs'
|
|
150
154
|
|
|
151
|
-
const version = '2.8.0-alpha.
|
|
155
|
+
const version = '2.8.0-alpha.1676455225773'
|
|
152
156
|
|
|
153
157
|
function install(app) {
|
|
154
158
|
ActionSheet.install && app.use(ActionSheet)
|
|
155
159
|
AppBar.install && app.use(AppBar)
|
|
160
|
+
Avatar.install && app.use(Avatar)
|
|
161
|
+
AvatarGroup.install && app.use(AvatarGroup)
|
|
156
162
|
BackTop.install && app.use(BackTop)
|
|
157
163
|
Badge.install && app.use(Badge)
|
|
158
164
|
BottomNavigation.install && app.use(BottomNavigation)
|
|
@@ -232,6 +238,8 @@ export {
|
|
|
232
238
|
install,
|
|
233
239
|
ActionSheet,
|
|
234
240
|
AppBar,
|
|
241
|
+
Avatar,
|
|
242
|
+
AvatarGroup,
|
|
235
243
|
BackTop,
|
|
236
244
|
Badge,
|
|
237
245
|
BottomNavigation,
|
|
@@ -311,6 +319,8 @@ export default {
|
|
|
311
319
|
install,
|
|
312
320
|
ActionSheet,
|
|
313
321
|
AppBar,
|
|
322
|
+
Avatar,
|
|
323
|
+
AvatarGroup,
|
|
314
324
|
BackTop,
|
|
315
325
|
Badge,
|
|
316
326
|
BottomNavigation,
|
|
@@ -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'
|