@veltra/desktop 1.8.4 → 1.9.0
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/dist/components/alert/alert.js +69 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/style.d.ts +1 -0
- package/dist/components/alert/style.js +1 -0
- package/dist/components/alert/style2.css +76 -0
- package/dist/components/anchor/anchor-item.js +35 -0
- package/dist/components/anchor/anchor-item.js.map +1 -0
- package/dist/components/anchor/anchor.js +61 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/anchor/di.js +6 -0
- package/dist/components/anchor/di.js.map +1 -0
- package/dist/components/anchor/style.d.ts +1 -0
- package/dist/components/anchor/style.js +1 -0
- package/dist/components/anchor/style2.css +45 -0
- package/dist/components/anchor/use-anchor.js +81 -0
- package/dist/components/anchor/use-anchor.js.map +1 -0
- package/dist/components/avatar/avatar-group.js +28 -0
- package/dist/components/avatar/avatar-group.js.map +1 -0
- package/dist/components/avatar/avatar.js +51 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/style.d.ts +1 -0
- package/dist/components/avatar/style.js +1 -0
- package/dist/components/avatar/style2.css +87 -0
- package/dist/components/back-top/back-top.js +82 -0
- package/dist/components/back-top/back-top.js.map +1 -0
- package/dist/components/back-top/style.d.ts +1 -0
- package/dist/components/back-top/style.js +2 -0
- package/dist/components/back-top/style2.css +32 -0
- package/dist/components/carousel/carousel-item.js +27 -0
- package/dist/components/carousel/carousel-item.js.map +1 -0
- package/dist/components/carousel/carousel.js +118 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/carousel/di.js +7 -0
- package/dist/components/carousel/di.js.map +1 -0
- package/dist/components/carousel/style.d.ts +1 -0
- package/dist/components/carousel/style.js +1 -0
- package/dist/components/carousel/style2.css +97 -0
- package/dist/components/carousel/use-carousel.js +68 -0
- package/dist/components/carousel/use-carousel.js.map +1 -0
- package/dist/components/descriptions/descriptions-item.js +16 -0
- package/dist/components/descriptions/descriptions-item.js.map +1 -0
- package/dist/components/descriptions/descriptions.js +67 -0
- package/dist/components/descriptions/descriptions.js.map +1 -0
- package/dist/components/descriptions/style.d.ts +1 -0
- package/dist/components/descriptions/style.js +1 -0
- package/dist/components/descriptions/style2.css +81 -0
- package/dist/components/divider/divider.js +41 -0
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/divider/style.d.ts +1 -0
- package/dist/components/divider/style.js +1 -0
- package/dist/components/divider/style2.css +68 -0
- package/dist/components/expression-editor/components/variable-picker.js +1 -1
- package/dist/components/expression-editor/components/variable-picker.js.map +1 -1
- package/dist/components/file-viewer/previewers/pdf-previewer.js +3 -1
- package/dist/components/file-viewer/previewers/pdf-previewer.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.js +1 -1
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/index.d.ts +48 -30
- package/dist/components/index.js +95 -59
- package/dist/components/index.js.map +1 -1
- package/dist/components/rate/rate.js +130 -0
- package/dist/components/rate/rate.js.map +1 -0
- package/dist/components/rate/style.d.ts +1 -0
- package/dist/components/rate/style.js +1 -0
- package/dist/components/rate/style2.css +58 -0
- package/dist/components/skeleton/skeleton.js +74 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/skeleton/style.d.ts +1 -0
- package/dist/components/skeleton/style.js +1 -0
- package/dist/components/skeleton/style2.css +86 -0
- package/dist/components/space/space.js +47 -0
- package/dist/components/space/space.js.map +1 -0
- package/dist/components/space/style.d.ts +1 -0
- package/dist/components/space/style.js +1 -0
- package/dist/components/space/style2.css +43 -0
- package/dist/components/time-picker/style.d.ts +2 -0
- package/dist/components/time-picker/style.js +3 -0
- package/dist/components/time-picker/style2.css +110 -0
- package/dist/components/time-picker/time-picker.js +196 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/timeline/style.d.ts +1 -0
- package/dist/components/timeline/style.js +1 -0
- package/dist/components/timeline/style2.css +95 -0
- package/dist/components/timeline/timeline-item.js +32 -0
- package/dist/components/timeline/timeline-item.js.map +1 -0
- package/dist/components/timeline/timeline.js +17 -0
- package/dist/components/timeline/timeline.js.map +1 -0
- package/dist/components/transfer/style.d.ts +2 -0
- package/dist/components/transfer/style.js +4 -0
- package/dist/components/transfer/style2.css +172 -0
- package/dist/components/transfer/transfer-list.js +101 -0
- package/dist/components/transfer/transfer-list.js.map +1 -0
- package/dist/components/transfer/transfer.js +138 -0
- package/dist/components/transfer/transfer.js.map +1 -0
- package/dist/index.d.ts +119 -88
- package/dist/index.js +106 -88
- package/dist/types/alert.d.ts +27 -0
- package/dist/types/anchor.d.ts +48 -0
- package/dist/types/avatar.d.ts +28 -0
- package/dist/types/back-top.d.ts +19 -0
- package/dist/types/carousel.d.ts +25 -0
- package/dist/types/descriptions.d.ts +22 -0
- package/dist/types/divider.d.ts +14 -0
- package/dist/types/index.d.ts +14 -1
- package/dist/types/layout.d.ts +2 -1
- package/dist/types/rate.d.ts +26 -0
- package/dist/types/skeleton.d.ts +24 -0
- package/dist/types/space.d.ts +20 -0
- package/dist/types/time-picker.d.ts +38 -0
- package/dist/types/timeline.d.ts +16 -0
- package/dist/types/transfer.d.ts +37 -0
- package/package.json +3 -1
- package/src/components/alert/alert.vue +62 -0
- package/src/components/alert/index.ts +1 -0
- package/src/components/alert/style.scss +67 -0
- package/src/components/alert/style.ts +1 -0
- package/src/components/anchor/anchor-item.vue +35 -0
- package/src/components/anchor/anchor.vue +63 -0
- package/src/components/anchor/di.ts +15 -0
- package/src/components/anchor/index.ts +2 -0
- package/src/components/anchor/style.scss +44 -0
- package/src/components/anchor/style.ts +1 -0
- package/src/components/anchor/use-anchor.ts +120 -0
- package/src/components/avatar/avatar-group.vue +26 -0
- package/src/components/avatar/avatar.vue +52 -0
- package/src/components/avatar/index.ts +2 -0
- package/src/components/avatar/style.scss +79 -0
- package/src/components/avatar/style.ts +1 -0
- package/src/components/back-top/back-top.vue +89 -0
- package/src/components/back-top/index.ts +1 -0
- package/src/components/back-top/style.scss +31 -0
- package/src/components/back-top/style.ts +2 -0
- package/src/components/carousel/carousel-item.vue +27 -0
- package/src/components/carousel/carousel.vue +93 -0
- package/src/components/carousel/di.ts +15 -0
- package/src/components/carousel/index.ts +2 -0
- package/src/components/carousel/style.scss +109 -0
- package/src/components/carousel/style.ts +1 -0
- package/src/components/carousel/use-carousel.ts +77 -0
- package/src/components/descriptions/descriptions-item.vue +12 -0
- package/src/components/descriptions/descriptions.vue +81 -0
- package/src/components/descriptions/index.ts +2 -0
- package/src/components/descriptions/style.scss +73 -0
- package/src/components/descriptions/style.ts +1 -0
- package/src/components/divider/divider.vue +29 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/divider/style.scss +90 -0
- package/src/components/divider/style.ts +1 -0
- package/src/components/expression-editor/components/variable-picker.vue +1 -1
- package/src/components/file-viewer/previewers/pdf-previewer.vue +6 -1
- package/src/components/image-cropper/image-cropper.vue +1 -1
- package/src/components/index.ts +26 -0
- package/src/components/rate/index.ts +1 -0
- package/src/components/rate/rate.vue +127 -0
- package/src/components/rate/style.scss +51 -0
- package/src/components/rate/style.ts +1 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.vue +37 -0
- package/src/components/skeleton/style.scss +94 -0
- package/src/components/skeleton/style.ts +1 -0
- package/src/components/space/index.ts +1 -0
- package/src/components/space/space.vue +45 -0
- package/src/components/space/style.scss +41 -0
- package/src/components/space/style.ts +1 -0
- package/src/components/time-picker/index.ts +1 -0
- package/src/components/time-picker/style.scss +82 -0
- package/src/components/time-picker/style.ts +3 -0
- package/src/components/time-picker/time-picker.vue +183 -0
- package/src/components/timeline/index.ts +2 -0
- package/src/components/timeline/style.scss +107 -0
- package/src/components/timeline/style.ts +1 -0
- package/src/components/timeline/timeline-item.vue +43 -0
- package/src/components/timeline/timeline.vue +17 -0
- package/src/components/transfer/index.ts +1 -0
- package/src/components/transfer/style.scss +135 -0
- package/src/components/transfer/style.ts +4 -0
- package/src/components/transfer/transfer-list.vue +120 -0
- package/src/components/transfer/transfer.vue +134 -0
- package/src/env.d.ts +5 -0
- package/src/types/alert.ts +29 -0
- package/src/types/anchor.ts +50 -0
- package/src/types/avatar.ts +31 -0
- package/src/types/back-top.ts +20 -0
- package/src/types/carousel.ts +29 -0
- package/src/types/descriptions.ts +22 -0
- package/src/types/divider.ts +14 -0
- package/src/types/index.ts +16 -0
- package/src/types/layout.ts +2 -1
- package/src/types/rate.ts +27 -0
- package/src/types/skeleton.ts +29 -0
- package/src/types/space.ts +22 -0
- package/src/types/time-picker.ts +40 -0
- package/src/types/timeline.ts +15 -0
- package/src/types/transfer.ts +45 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icon/icon.js";
|
|
2
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderSlot, resolveDynamicComponent, toDisplayString, unref, withCtx, withModifiers } from "vue";
|
|
3
|
+
import { bem } from "@veltra/utils";
|
|
4
|
+
import { CircleCheckFilled, CircleClose, Close, InfoFilled, WarningFilled } from "@veltra/icons/normal";
|
|
5
|
+
//#region src/components/alert/alert.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
name: "UAlert",
|
|
8
|
+
__name: "alert",
|
|
9
|
+
props: {
|
|
10
|
+
type: { default: "info" },
|
|
11
|
+
title: {},
|
|
12
|
+
description: {},
|
|
13
|
+
showIcon: { type: Boolean },
|
|
14
|
+
closable: { type: Boolean }
|
|
15
|
+
},
|
|
16
|
+
emits: ["close"],
|
|
17
|
+
setup(__props, { emit: __emit }) {
|
|
18
|
+
const emit = __emit;
|
|
19
|
+
const cls = bem("alert");
|
|
20
|
+
const visible = ref(true);
|
|
21
|
+
/** 语义类型对应的图标 */
|
|
22
|
+
const typeIcons = {
|
|
23
|
+
info: InfoFilled,
|
|
24
|
+
success: CircleCheckFilled,
|
|
25
|
+
warning: WarningFilled,
|
|
26
|
+
error: CircleClose
|
|
27
|
+
};
|
|
28
|
+
const className = computed(() => [cls.b, cls.m(__props.type)]);
|
|
29
|
+
/** 点击关闭图标后隐藏自身并发出 close 事件 */
|
|
30
|
+
const handleClose = () => {
|
|
31
|
+
visible.value = false;
|
|
32
|
+
emit("close");
|
|
33
|
+
};
|
|
34
|
+
return (_ctx, _cache) => {
|
|
35
|
+
return visible.value ? (openBlock(), createElementBlock("div", {
|
|
36
|
+
key: 0,
|
|
37
|
+
class: normalizeClass(className.value),
|
|
38
|
+
role: "alert"
|
|
39
|
+
}, [
|
|
40
|
+
__props.showIcon ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
41
|
+
key: 0,
|
|
42
|
+
class: normalizeClass(unref(cls).e("icon"))
|
|
43
|
+
}, {
|
|
44
|
+
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(typeIcons[__props.type])))]),
|
|
45
|
+
_: 1
|
|
46
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true),
|
|
47
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("content")) }, [_ctx.$slots.title || __props.title ? (openBlock(), createElementBlock("div", {
|
|
48
|
+
key: 0,
|
|
49
|
+
class: normalizeClass(unref(cls).e("title"))
|
|
50
|
+
}, [renderSlot(_ctx.$slots, "title", {}, () => [createTextVNode(toDisplayString(__props.title), 1)])], 2)) : createCommentVNode("v-if", true), _ctx.$slots.default || __props.description ? (openBlock(), createElementBlock("div", {
|
|
51
|
+
key: 1,
|
|
52
|
+
class: normalizeClass(unref(cls).e("description"))
|
|
53
|
+
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.description), 1)])], 2)) : createCommentVNode("v-if", true)], 2),
|
|
54
|
+
__props.closable ? (openBlock(), createBlock(unref(_sfc_main$1), {
|
|
55
|
+
key: 1,
|
|
56
|
+
class: normalizeClass(unref(cls).e("close")),
|
|
57
|
+
onClick: withModifiers(handleClose, ["stop"])
|
|
58
|
+
}, {
|
|
59
|
+
default: withCtx(() => [createVNode(unref(Close))]),
|
|
60
|
+
_: 1
|
|
61
|
+
}, 8, ["class"])) : createCommentVNode("v-if", true)
|
|
62
|
+
], 2)) : createCommentVNode("v-if", true);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//#endregion
|
|
67
|
+
export { _sfc_main as default };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=alert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.js","names":["$slots","_openBlock","_createElementBlock","_normalizeClass","_createBlock","_unref","UIcon","_withCtx","_resolveDynamicComponent","_createCommentVNode","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString","_withModifiers","_createVNode"],"sources":["../../../src/components/alert/alert.vue"],"sourcesContent":["<template>\n <div v-if=\"visible\" :class=\"className\" role=\"alert\">\n <u-icon v-if=\"showIcon\" :class=\"cls.e('icon')\">\n <component :is=\"typeIcons[type]\" />\n </u-icon>\n\n <div :class=\"cls.e('content')\">\n <div v-if=\"$slots.title || title\" :class=\"cls.e('title')\">\n <slot name=\"title\">{{ title }}</slot>\n </div>\n\n <div v-if=\"$slots.default || description\" :class=\"cls.e('description')\">\n <slot>{{ description }}</slot>\n </div>\n </div>\n\n <u-icon v-if=\"closable\" :class=\"cls.e('close')\" @click.stop=\"handleClose\">\n <Close />\n </u-icon>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport {\n CircleCheckFilled,\n CircleClose,\n Close,\n InfoFilled,\n WarningFilled\n} from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, ref, type Component } from 'vue'\n\nimport type { AlertEmits, AlertProps, AlertType } from '../../types'\nimport { UIcon } from '../icon'\n\ndefineOptions({ name: 'UAlert' })\n\nconst { type = 'info', closable, showIcon } = defineProps<AlertProps>()\n\nconst emit = defineEmits<AlertEmits>()\n\nconst cls = bem('alert')\n\nconst visible = ref(true)\n\n/** 语义类型对应的图标 */\nconst typeIcons: Record<AlertType, Component> = {\n info: InfoFilled,\n success: CircleCheckFilled,\n warning: WarningFilled,\n error: CircleClose\n}\n\nconst className = computed(() => [cls.b, cls.m(type)])\n\n/** 点击关闭图标后隐藏自身并发出 close 事件 */\nconst handleClose = () => {\n visible.value = false\n emit('close')\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;EAwCA,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,OAAO;EAEvB,MAAM,UAAU,IAAI,IAAI;;EAGxB,MAAM,YAA0C;GAC9C,MAAM;GACN,SAAS;GACT,SAAS;GACT,OAAO;EACT;EAEA,MAAM,YAAY,eAAe,CAAC,IAAI,GAAG,IAAI,EAAE,QAAA,IAAI,CAAC,CAAC;;EAGrD,MAAM,oBAAoB;GACxB,QAAQ,QAAQ;GAChB,KAAK,OAAO;EACd;;GA3Da,OAAA,QAAA,SAAXC,UAAA,GAAAC,mBAkBM,OAAA;;IAlBe,OAAKC,eAAE,UAAA,KAAS;IAAE,MAAK;;IAC5B,QAAA,YAAdF,UAAA,GAAAG,YAESC,MAAAC,WAAA,GAAA;;KAFgB,OAAKH,eAAEE,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA;;KACnC,SAAAE,cAAmC,EAAnCN,UAAA,GAAAG,YAAmCI,wBAAnB,UAAU,QAAA,KAAI,CAAA,EAAA,CAAA;;;IAGhCE,mBAQM,OAAA,EARA,OAAKP,eAAEE,MAAA,GAAA,CAAG,CAAC,EAAC,SAAA,CAAA,EAAA,GACLL,CAAAA,KAAAA,OAAO,SAAS,QAAA,SAA3BC,UAAA,GAAAC,mBAEM,OAAA;;KAF6B,OAAKC,eAAEE,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;IAC7C,GAAA,CAAAM,WAAqC,KAAA,QAAA,SAAA,CAAA,SAAA,CAAfC,gBAAAC,gBAAA,QAAA,KAAK,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAGlBb,KAAAA,mBAAAA,QAAAA,IAAAA,GAAAA,KAAAA,OAAO,WAAW,QAAA,eAA7BC,UAAA,GAAAC,mBAEM,OAAA;;KAFqC,OAAKC,eAAEE,MAAA,GAAA,CAAG,CAAC,EAAC,aAAA,CAAA;IACrD,GAAA,CAAAM,WAA8B,KAAA,QAAA,WAAA,CAAA,SAAA,CAArBC,gBAAAC,gBAAA,QAAA,WAAW,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,QAAA,IAAA,CAAA,GAAA,CAAA;IAIV,QAAA,YAAdZ,UAAA,GAAAG,YAESC,MAAAC,WAAA,GAAA;;KAFgB,OAAKH,eAAEE,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;KAAY,SAAKS,cAAO,aAAW,CAAA,MAAA,CAAA;;KACtE,SAAAP,cAAS,CAATQ,YAASV,MAAA,KAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./style2.css";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
.u-alert {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: flex-start;
|
|
21
|
+
align-items: flex-start;
|
|
22
|
+
flex-wrap: nowrap;
|
|
23
|
+
gap: var(--u-gap-default);
|
|
24
|
+
padding: var(--u-gap-default);
|
|
25
|
+
border-radius: var(--u-radius-default);
|
|
26
|
+
font-size: var(--u-font-size-main-default);
|
|
27
|
+
line-height: 1.6;
|
|
28
|
+
word-break: break-word;
|
|
29
|
+
}
|
|
30
|
+
.u-alert--info {
|
|
31
|
+
color: var(--u-color-info);
|
|
32
|
+
background-color: var(--u-color-info-light-9);
|
|
33
|
+
border: 1px solid var(--u-color-info-light-7);
|
|
34
|
+
}
|
|
35
|
+
.u-alert--success {
|
|
36
|
+
color: var(--u-color-success);
|
|
37
|
+
background-color: var(--u-color-success-light-9);
|
|
38
|
+
border: 1px solid var(--u-color-success-light-7);
|
|
39
|
+
}
|
|
40
|
+
.u-alert--warning {
|
|
41
|
+
color: var(--u-color-warning);
|
|
42
|
+
background-color: var(--u-color-warning-light-9);
|
|
43
|
+
border: 1px solid var(--u-color-warning-light-7);
|
|
44
|
+
}
|
|
45
|
+
.u-alert--error {
|
|
46
|
+
color: var(--u-color-danger);
|
|
47
|
+
background-color: var(--u-color-danger-light-9);
|
|
48
|
+
border: 1px solid var(--u-color-danger-light-7);
|
|
49
|
+
}
|
|
50
|
+
.u-alert__icon {
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
height: calc(var(--u-font-size-main-default) * 1.6);
|
|
53
|
+
font-size: var(--u-font-size-main-large);
|
|
54
|
+
}
|
|
55
|
+
.u-alert__content {
|
|
56
|
+
flex: 1;
|
|
57
|
+
min-width: 0;
|
|
58
|
+
}
|
|
59
|
+
.u-alert__title {
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
}
|
|
62
|
+
.u-alert__description {
|
|
63
|
+
margin-top: var(--u-gap-small);
|
|
64
|
+
color: var(--u-text-color-second);
|
|
65
|
+
font-size: var(--u-font-size-main-small);
|
|
66
|
+
}
|
|
67
|
+
.u-alert__close {
|
|
68
|
+
flex-shrink: 0;
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
align-self: center;
|
|
71
|
+
opacity: 0.6;
|
|
72
|
+
transition: opacity var(--u-transition-fast) var(--u-transition-ease);
|
|
73
|
+
}
|
|
74
|
+
.u-alert__close:hover {
|
|
75
|
+
opacity: 1;
|
|
76
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AnchorDIKey } from "./di.js";
|
|
2
|
+
import { computed, createElementBlock, createTextVNode, defineComponent, inject, normalizeClass, onBeforeUnmount, onMounted, openBlock, renderSlot, toDisplayString, unref } from "vue";
|
|
3
|
+
import { bem } from "@veltra/utils";
|
|
4
|
+
//#region src/components/anchor/anchor-item.vue
|
|
5
|
+
const _hoisted_1 = ["href", "title"];
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
name: "UAnchorItem",
|
|
8
|
+
__name: "anchor-item",
|
|
9
|
+
props: {
|
|
10
|
+
href: {},
|
|
11
|
+
title: {}
|
|
12
|
+
},
|
|
13
|
+
setup(__props) {
|
|
14
|
+
const cls = bem("anchor");
|
|
15
|
+
const context = inject(AnchorDIKey);
|
|
16
|
+
const active = computed(() => context?.current.value === __props.href);
|
|
17
|
+
function handleClick(event) {
|
|
18
|
+
context?.click(__props.href, event);
|
|
19
|
+
}
|
|
20
|
+
onMounted(() => context?.register(__props.href));
|
|
21
|
+
onBeforeUnmount(() => context?.unregister(__props.href));
|
|
22
|
+
return (_ctx, _cache) => {
|
|
23
|
+
return openBlock(), createElementBlock("a", {
|
|
24
|
+
class: normalizeClass([unref(cls).e("item"), unref(bem).is("active", active.value)]),
|
|
25
|
+
href: __props.href,
|
|
26
|
+
title: __props.title,
|
|
27
|
+
onClick: handleClick
|
|
28
|
+
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.title), 1)])], 10, _hoisted_1);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { _sfc_main as default };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=anchor-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor-item.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_renderSlot","_createTextVNode","_toDisplayString"],"sources":["../../../src/components/anchor/anchor-item.vue"],"sourcesContent":["<template>\n <a\n :class=\"[cls.e('item'), bem.is('active', active)]\"\n :href=\"href\"\n :title=\"title\"\n @click=\"handleClick\"\n >\n <slot>{{ title }}</slot>\n </a>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, inject, onBeforeUnmount, onMounted } from 'vue'\n\nimport type { AnchorItemProps } from '../../types'\nimport { AnchorDIKey } from './di'\n\ndefineOptions({ name: 'UAnchorItem' })\n\nconst { href, title } = defineProps<AnchorItemProps>()\n\nconst cls = bem('anchor')\n\nconst context = inject(AnchorDIKey)\n\nconst active = computed(() => context?.current.value === href)\n\nfunction handleClick(event: MouseEvent) {\n context?.click(href, event)\n}\n\nonMounted(() => context?.register(href))\nonBeforeUnmount(() => context?.unregister(href))\n</script>\n"],"mappings":";;;;;;;;;;;;;EAsBA,MAAM,MAAM,IAAI,QAAQ;EAExB,MAAM,UAAU,OAAO,WAAW;EAElC,MAAM,SAAS,eAAe,SAAS,QAAQ,UAAU,QAAA,IAAI;EAE7D,SAAS,YAAY,OAAmB;GACtC,SAAS,MAAM,QAAA,MAAM,KAAK;EAC5B;EAEA,gBAAgB,SAAS,SAAS,QAAA,IAAI,CAAC;EACvC,sBAAsB,SAAS,WAAW,QAAA,IAAI,CAAC;;GAhC7C,OAAAA,UAAA,GAAAC,mBAOI,KAAA;IAND,OAAKC,eAAA,CAAGC,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,GAAUA,MAAA,GAAA,CAAG,CAAC,GAAE,UAAW,OAAA,KAAM,CAAA,CAAA;IAC9C,MAAM,QAAA;IACN,OAAO,QAAA;IACP,SAAO;GAER,GAAA,CAAAC,WAAwB,KAAA,QAAA,WAAA,CAAA,SAAA,CAAfC,gBAAAC,gBAAA,QAAA,KAAK,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,UAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AnchorDIKey } from "./di.js";
|
|
2
|
+
import { useAnchor } from "./use-anchor.js";
|
|
3
|
+
import { computed, createElementBlock, defineComponent, mergeModels, normalizeClass, openBlock, provide, renderSlot, shallowRef, unref, useModel } from "vue";
|
|
4
|
+
import { bem } from "@veltra/utils";
|
|
5
|
+
//#region src/components/anchor/anchor.vue
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
name: "UAnchor",
|
|
8
|
+
__name: "anchor",
|
|
9
|
+
props: /*@__PURE__*/ mergeModels({
|
|
10
|
+
container: {},
|
|
11
|
+
offset: { default: 0 }
|
|
12
|
+
}, {
|
|
13
|
+
"current": {},
|
|
14
|
+
"currentModifiers": {}
|
|
15
|
+
}),
|
|
16
|
+
emits: /*@__PURE__*/ mergeModels(["change", "click-item"], ["update:current"]),
|
|
17
|
+
setup(__props, { emit: __emit }) {
|
|
18
|
+
const emit = __emit;
|
|
19
|
+
/** 受控高亮锚点 */
|
|
20
|
+
const current = useModel(__props, "current");
|
|
21
|
+
const cls = bem("anchor");
|
|
22
|
+
/** 已注册锚点(保持锚点项出现顺序) */
|
|
23
|
+
const hrefs = shallowRef([]);
|
|
24
|
+
function register(href) {
|
|
25
|
+
hrefs.value = [...hrefs.value, href];
|
|
26
|
+
}
|
|
27
|
+
function unregister(href) {
|
|
28
|
+
hrefs.value = hrefs.value.filter((item) => item !== href);
|
|
29
|
+
}
|
|
30
|
+
function handleChange(href) {
|
|
31
|
+
if (current.value === href) return;
|
|
32
|
+
current.value = href;
|
|
33
|
+
emit("change", href);
|
|
34
|
+
}
|
|
35
|
+
const { scrollTo } = useAnchor({
|
|
36
|
+
items: hrefs,
|
|
37
|
+
container: () => __props.container,
|
|
38
|
+
offset: () => __props.offset,
|
|
39
|
+
onChange: handleChange
|
|
40
|
+
});
|
|
41
|
+
function handleClick(href, event) {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
scrollTo(href);
|
|
44
|
+
handleChange(href);
|
|
45
|
+
emit("click-item", href, event);
|
|
46
|
+
}
|
|
47
|
+
provide(AnchorDIKey, {
|
|
48
|
+
current: computed(() => current.value),
|
|
49
|
+
click: handleClick,
|
|
50
|
+
register,
|
|
51
|
+
unregister
|
|
52
|
+
});
|
|
53
|
+
return (_ctx, _cache) => {
|
|
54
|
+
return openBlock(), createElementBlock("nav", { class: normalizeClass(unref(cls).b) }, [renderSlot(_ctx.$slots, "default")], 2);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
export { _sfc_main as default };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchor.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_renderSlot"],"sources":["../../../src/components/anchor/anchor.vue"],"sourcesContent":["<template>\n <nav :class=\"cls.b\">\n <slot></slot>\n </nav>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, provide, shallowRef } from 'vue'\n\nimport type { AnchorEmits, AnchorProps } from '../../types'\nimport { AnchorDIKey } from './di'\nimport { useAnchor } from './use-anchor'\n\ndefineOptions({ name: 'UAnchor' })\n\nconst { container, offset = 0 } = defineProps<AnchorProps>()\n\nconst emit = defineEmits<AnchorEmits>()\n\n/** 受控高亮锚点 */\nconst current = defineModel<string>('current')\n\nconst cls = bem('anchor')\n\n/** 已注册锚点(保持锚点项出现顺序) */\nconst hrefs = shallowRef<string[]>([])\n\nfunction register(href: string) {\n hrefs.value = [...hrefs.value, href]\n}\n\nfunction unregister(href: string) {\n hrefs.value = hrefs.value.filter((item) => item !== href)\n}\n\nfunction handleChange(href: string) {\n if (current.value === href) return\n current.value = href\n emit('change', href)\n}\n\nconst { scrollTo } = useAnchor({\n items: hrefs,\n container: () => container,\n offset: () => offset,\n onChange: handleChange\n})\n\nfunction handleClick(href: string, event: MouseEvent) {\n event.preventDefault()\n scrollTo(href)\n handleChange(href)\n emit('click-item', href, event)\n}\n\nprovide(AnchorDIKey, {\n current: computed(() => current.value),\n click: handleClick,\n register,\n unregister\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;EAkBA,MAAM,OAAO;;EAGb,MAAM,UAAUA,SAAmB,SAAC,SAAS;EAE7C,MAAM,MAAM,IAAI,QAAQ;;EAGxB,MAAM,QAAQ,WAAqB,CAAC,CAAC;EAErC,SAAS,SAAS,MAAc;GAC9B,MAAM,QAAQ,CAAC,GAAG,MAAM,OAAO,IAAI;EACrC;EAEA,SAAS,WAAW,MAAc;GAChC,MAAM,QAAQ,MAAM,MAAM,QAAQ,SAAS,SAAS,IAAI;EAC1D;EAEA,SAAS,aAAa,MAAc;GAClC,IAAI,QAAQ,UAAU,MAAM;GAC5B,QAAQ,QAAQ;GAChB,KAAK,UAAU,IAAI;EACrB;EAEA,MAAM,EAAE,aAAa,UAAU;GAC7B,OAAO;GACP,iBAAiB,QAAA;GACjB,cAAc,QAAA;GACd,UAAU;EACZ,CAAC;EAED,SAAS,YAAY,MAAc,OAAmB;GACpD,MAAM,eAAe;GACrB,SAAS,IAAI;GACb,aAAa,IAAI;GACjB,KAAK,cAAc,MAAM,KAAK;EAChC;EAEA,QAAQ,aAAa;GACnB,SAAS,eAAe,QAAQ,KAAK;GACrC,OAAO;GACP;GACA;EACF,CAAC;;GA5DC,OAAAC,UAAA,GAAAC,mBAEM,OAAA,EAFA,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,CAAC,EAAA,GAChB,CAAAC,WAAa,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"di.js","names":[],"sources":["../../../src/components/anchor/di.ts"],"sourcesContent":["import type { ComputedRef, InjectionKey } from 'vue'\n\n/** 锚点导航父子上下文 */\nexport interface AnchorContext {\n /** 当前高亮锚点 */\n current: ComputedRef<string | undefined>\n /** 点击锚点项(由容器统一滚动定位) */\n click: (href: string, event: MouseEvent) => void\n /** 注册锚点项 */\n register: (href: string) => void\n /** 注销锚点项 */\n unregister: (href: string) => void\n}\n\nexport const AnchorDIKey: InjectionKey<AnchorContext> = Symbol('Anchor')\n"],"mappings":";AAcA,MAAa,cAA2C,OAAO,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./style2.css";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
.u-anchor {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
max-width: 200px;
|
|
22
|
+
}
|
|
23
|
+
.u-anchor__item {
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: var(--u-gap-small) var(--u-gap-default) var(--u-gap-small) calc(var(--u-gap-large) + 2px);
|
|
26
|
+
border-left: 2px solid var(--u-border-color);
|
|
27
|
+
color: var(--u-text-color-second);
|
|
28
|
+
font-size: var(--u-font-size-main);
|
|
29
|
+
line-height: 1.5;
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
transition: color var(--u-transition-fast) var(--u-transition-ease), border-color var(--u-transition-fast) var(--u-transition-ease);
|
|
34
|
+
}
|
|
35
|
+
.u-anchor__item:hover {
|
|
36
|
+
color: var(--u-text-color-main);
|
|
37
|
+
}
|
|
38
|
+
.u-anchor__item:focus-visible {
|
|
39
|
+
outline: none;
|
|
40
|
+
box-shadow: var(--u-focus-ring);
|
|
41
|
+
}
|
|
42
|
+
.u-anchor__item.is-active {
|
|
43
|
+
border-left-color: var(--u-color-primary);
|
|
44
|
+
color: var(--u-color-primary);
|
|
45
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { onMounted, onScopeDispose, toValue, watch } from "vue";
|
|
2
|
+
//#region src/components/anchor/use-anchor.ts
|
|
3
|
+
/**
|
|
4
|
+
* 解析滚动容器。
|
|
5
|
+
* window 滚动统一返回 documentElement,便于复用 scrollTop / scrollHeight。
|
|
6
|
+
*/
|
|
7
|
+
function resolveContainer(target) {
|
|
8
|
+
if (typeof target === "string") return document.querySelector(target) ?? document.documentElement;
|
|
9
|
+
return target ?? document.documentElement;
|
|
10
|
+
}
|
|
11
|
+
/** 锚点滚动联动:点击平滑定位、滚动时计算当前命中锚点 */
|
|
12
|
+
function useAnchor(options) {
|
|
13
|
+
const { items, container, offset, onChange } = options;
|
|
14
|
+
/** 锚点对应的目标元素 */
|
|
15
|
+
function getTarget(href) {
|
|
16
|
+
return document.querySelector(href);
|
|
17
|
+
}
|
|
18
|
+
/** 点击项:平滑滚动到目标锚点 */
|
|
19
|
+
function scrollTo(href) {
|
|
20
|
+
const target = getTarget(href);
|
|
21
|
+
if (!target) return;
|
|
22
|
+
const wrap = resolveContainer(toValue(container));
|
|
23
|
+
const top = wrap === document.documentElement ? window.scrollY + target.getBoundingClientRect().top - toValue(offset) : wrap.scrollTop + target.getBoundingClientRect().top - wrap.getBoundingClientRect().top - toValue(offset);
|
|
24
|
+
wrap.scrollTo({
|
|
25
|
+
top,
|
|
26
|
+
behavior: "smooth"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** 计算当前命中锚点并通知 */
|
|
30
|
+
function update() {
|
|
31
|
+
const hrefs = toValue(items);
|
|
32
|
+
const first = hrefs[0];
|
|
33
|
+
if (!first) return;
|
|
34
|
+
const wrap = resolveContainer(toValue(container));
|
|
35
|
+
const containerTop = wrap === document.documentElement ? 0 : wrap.getBoundingClientRect().top;
|
|
36
|
+
let hit;
|
|
37
|
+
for (const href of hrefs) {
|
|
38
|
+
const target = getTarget(href);
|
|
39
|
+
if (target && target.getBoundingClientRect().top - containerTop - toValue(offset) <= 0) hit = href;
|
|
40
|
+
}
|
|
41
|
+
if (wrap.scrollHeight - wrap.clientHeight > 1 && wrap.scrollTop + wrap.clientHeight >= wrap.scrollHeight - 1) hit = hrefs[hrefs.length - 1] ?? first;
|
|
42
|
+
onChange(hit ?? first);
|
|
43
|
+
}
|
|
44
|
+
let rafId = 0;
|
|
45
|
+
function handleScroll() {
|
|
46
|
+
if (rafId) return;
|
|
47
|
+
rafId = requestAnimationFrame(() => {
|
|
48
|
+
rafId = 0;
|
|
49
|
+
update();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
let bound = document.documentElement;
|
|
53
|
+
function bind() {
|
|
54
|
+
unbind();
|
|
55
|
+
bound = resolveContainer(toValue(container));
|
|
56
|
+
bound.addEventListener("scroll", handleScroll, { passive: true });
|
|
57
|
+
}
|
|
58
|
+
function unbind() {
|
|
59
|
+
bound.removeEventListener("scroll", handleScroll);
|
|
60
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
61
|
+
rafId = 0;
|
|
62
|
+
}
|
|
63
|
+
watch(() => toValue(container), () => {
|
|
64
|
+
bind();
|
|
65
|
+
update();
|
|
66
|
+
});
|
|
67
|
+
watch(items, update);
|
|
68
|
+
onMounted(() => {
|
|
69
|
+
bind();
|
|
70
|
+
update();
|
|
71
|
+
});
|
|
72
|
+
onScopeDispose(unbind);
|
|
73
|
+
return {
|
|
74
|
+
scrollTo,
|
|
75
|
+
update
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
export { useAnchor };
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=use-anchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-anchor.js","names":[],"sources":["../../../src/components/anchor/use-anchor.ts"],"sourcesContent":["import type { MaybeRefOrGetter } from 'vue'\nimport { onMounted, onScopeDispose, toValue, watch } from 'vue'\n\n/** 锚点滚动联动选项 */\nexport interface UseAnchorOptions {\n /** 有序锚点列表(锚点项注册顺序) */\n items: MaybeRefOrGetter<string[]>\n /** 滚动容器:CSS 选择器或元素(含 null,缺省 window) */\n container: MaybeRefOrGetter<string | HTMLElement | null | undefined>\n /** 定位偏移 */\n offset: MaybeRefOrGetter<number>\n /** 命中锚点变化回调 */\n onChange: (href: string) => void\n}\n\n/**\n * 解析滚动容器。\n * window 滚动统一返回 documentElement,便于复用 scrollTop / scrollHeight。\n */\nfunction resolveContainer(target: string | HTMLElement | null | undefined): HTMLElement {\n if (typeof target === 'string') {\n return document.querySelector<HTMLElement>(target) ?? document.documentElement\n }\n return target ?? document.documentElement\n}\n\n/** 锚点滚动联动:点击平滑定位、滚动时计算当前命中锚点 */\nexport function useAnchor(options: UseAnchorOptions) {\n const { items, container, offset, onChange } = options\n\n /** 锚点对应的目标元素 */\n function getTarget(href: string): HTMLElement | null {\n return document.querySelector<HTMLElement>(href)\n }\n\n /** 点击项:平滑滚动到目标锚点 */\n function scrollTo(href: string) {\n const target = getTarget(href)\n if (!target) return\n\n const wrap = resolveContainer(toValue(container))\n const top =\n wrap === document.documentElement\n ? window.scrollY + target.getBoundingClientRect().top - toValue(offset)\n : wrap.scrollTop +\n target.getBoundingClientRect().top -\n wrap.getBoundingClientRect().top -\n toValue(offset)\n\n wrap.scrollTo({ top, behavior: 'smooth' })\n }\n\n /** 计算当前命中锚点并通知 */\n function update() {\n const hrefs = toValue(items)\n const first = hrefs[0]\n if (!first) return\n\n const wrap = resolveContainer(toValue(container))\n const containerTop = wrap === document.documentElement ? 0 : wrap.getBoundingClientRect().top\n\n let hit: string | undefined\n for (const href of hrefs) {\n const target = getTarget(href)\n if (target && target.getBoundingClientRect().top - containerTop - toValue(offset) <= 0) {\n hit = href\n }\n }\n\n // 滚动到底部时直接命中最后一项(容器实际可滚动时才生效,避免内容不足一屏时误命中末项)\n const scrollable = wrap.scrollHeight - wrap.clientHeight > 1\n if (scrollable && wrap.scrollTop + wrap.clientHeight >= wrap.scrollHeight - 1) {\n hit = hrefs[hrefs.length - 1] ?? first\n }\n\n onChange(hit ?? first)\n }\n\n // 滚动监听(rAF 节流)\n let rafId = 0\n function handleScroll() {\n if (rafId) return\n rafId = requestAnimationFrame(() => {\n rafId = 0\n update()\n })\n }\n\n let bound: HTMLElement = document.documentElement\n function bind() {\n unbind()\n bound = resolveContainer(toValue(container))\n bound.addEventListener('scroll', handleScroll, { passive: true })\n }\n\n function unbind() {\n bound.removeEventListener('scroll', handleScroll)\n if (rafId) cancelAnimationFrame(rafId)\n rafId = 0\n }\n\n // 容器变化重绑监听;锚点增删只需重算命中\n watch(\n () => toValue(container),\n () => {\n bind()\n update()\n }\n )\n watch(items, update)\n\n onMounted(() => {\n bind()\n update()\n })\n\n onScopeDispose(unbind)\n\n return { scrollTo, update }\n}\n"],"mappings":";;;;;;AAmBA,SAAS,iBAAiB,QAA8D;CACtF,IAAI,OAAO,WAAW,UACpB,OAAO,SAAS,cAA2B,MAAM,KAAK,SAAS;CAEjE,OAAO,UAAU,SAAS;AAC5B;;AAGA,SAAgB,UAAU,SAA2B;CACnD,MAAM,EAAE,OAAO,WAAW,QAAQ,aAAa;;CAG/C,SAAS,UAAU,MAAkC;EACnD,OAAO,SAAS,cAA2B,IAAI;CACjD;;CAGA,SAAS,SAAS,MAAc;EAC9B,MAAM,SAAS,UAAU,IAAI;EAC7B,IAAI,CAAC,QAAQ;EAEb,MAAM,OAAO,iBAAiB,QAAQ,SAAS,CAAC;EAChD,MAAM,MACJ,SAAS,SAAS,kBACd,OAAO,UAAU,OAAO,sBAAsB,CAAC,CAAC,MAAM,QAAQ,MAAM,IACpE,KAAK,YACL,OAAO,sBAAsB,CAAC,CAAC,MAC/B,KAAK,sBAAsB,CAAC,CAAC,MAC7B,QAAQ,MAAM;EAEpB,KAAK,SAAS;GAAE;GAAK,UAAU;EAAS,CAAC;CAC3C;;CAGA,SAAS,SAAS;EAChB,MAAM,QAAQ,QAAQ,KAAK;EAC3B,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,OAAO;EAEZ,MAAM,OAAO,iBAAiB,QAAQ,SAAS,CAAC;EAChD,MAAM,eAAe,SAAS,SAAS,kBAAkB,IAAI,KAAK,sBAAsB,CAAC,CAAC;EAE1F,IAAI;EACJ,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,SAAS,UAAU,IAAI;GAC7B,IAAI,UAAU,OAAO,sBAAsB,CAAC,CAAC,MAAM,eAAe,QAAQ,MAAM,KAAK,GACnF,MAAM;EAEV;EAIA,IADmB,KAAK,eAAe,KAAK,eAAe,KACzC,KAAK,YAAY,KAAK,gBAAgB,KAAK,eAAe,GAC1E,MAAM,MAAM,MAAM,SAAS,MAAM;EAGnC,SAAS,OAAO,KAAK;CACvB;CAGA,IAAI,QAAQ;CACZ,SAAS,eAAe;EACtB,IAAI,OAAO;EACX,QAAQ,4BAA4B;GAClC,QAAQ;GACR,OAAO;EACT,CAAC;CACH;CAEA,IAAI,QAAqB,SAAS;CAClC,SAAS,OAAO;EACd,OAAO;EACP,QAAQ,iBAAiB,QAAQ,SAAS,CAAC;EAC3C,MAAM,iBAAiB,UAAU,cAAc,EAAE,SAAS,KAAK,CAAC;CAClE;CAEA,SAAS,SAAS;EAChB,MAAM,oBAAoB,UAAU,YAAY;EAChD,IAAI,OAAO,qBAAqB,KAAK;EACrC,QAAQ;CACV;CAGA,YACQ,QAAQ,SAAS,SACjB;EACJ,KAAK;EACL,OAAO;CACT,CACF;CACA,MAAM,OAAO,MAAM;CAEnB,gBAAgB;EACd,KAAK;EACL,OAAO;CACT,CAAC;CAED,eAAe,MAAM;CAErB,OAAO;EAAE;EAAU;CAAO;AAC5B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, defineComponent, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, useSlots } from "vue";
|
|
2
|
+
import { bem } from "@veltra/utils";
|
|
3
|
+
//#region src/components/avatar/avatar-group.vue
|
|
4
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
|
+
name: "UAvatarGroup",
|
|
6
|
+
__name: "avatar-group",
|
|
7
|
+
props: { max: {} },
|
|
8
|
+
setup(__props) {
|
|
9
|
+
const props = __props;
|
|
10
|
+
const cls = bem("avatar-group");
|
|
11
|
+
const slots = useSlots();
|
|
12
|
+
const items = computed(() => slots.default?.() ?? []);
|
|
13
|
+
const shownItems = computed(() => props.max ? items.value.slice(0, props.max) : items.value);
|
|
14
|
+
const restCount = computed(() => props.max ? Math.max(items.value.length - props.max, 0) : 0);
|
|
15
|
+
return (_ctx, _cache) => {
|
|
16
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass(unref(cls).b) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(shownItems.value, (item, index) => {
|
|
17
|
+
return openBlock(), createBlock(resolveDynamicComponent(item), { key: index });
|
|
18
|
+
}), 128)), restCount.value > 0 ? (openBlock(), createElementBlock("span", {
|
|
19
|
+
key: 0,
|
|
20
|
+
class: normalizeClass(unref(cls).e("rest"))
|
|
21
|
+
}, "+" + toDisplayString(restCount.value), 3)) : createCommentVNode("v-if", true)], 2);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { _sfc_main as default };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=avatar-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-group.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_Fragment","_renderList","_createBlock","_resolveDynamicComponent","_toDisplayString","_createCommentVNode"],"sources":["../../../src/components/avatar/avatar-group.vue"],"sourcesContent":["<template>\n <div :class=\"cls.b\">\n <component :is=\"item\" v-for=\"(item, index) of shownItems\" :key=\"index\" />\n <span v-if=\"restCount > 0\" :class=\"cls.e('rest')\">+{{ restCount }}</span>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, useSlots } from 'vue'\n\nimport type { AvatarGroupProps } from '../../types'\n\ndefineOptions({ name: 'UAvatarGroup' })\n\nconst props = defineProps<AvatarGroupProps>()\n\nconst cls = bem('avatar-group')\n\nconst slots = useSlots()\n\n// 插槽 vnode 须在渲染路径读取:插槽内容读取的响应式数据经调用链追踪,内容变化时重新计算\nconst items = computed(() => slots.default?.() ?? [])\nconst shownItems = computed(() => (props.max ? items.value.slice(0, props.max) : items.value))\nconst restCount = computed(() => (props.max ? Math.max(items.value.length - props.max, 0) : 0))\n</script>\n"],"mappings":";;;;;;;;EAeA,MAAM,QAAQ;EAEd,MAAM,MAAM,IAAI,cAAc;EAE9B,MAAM,QAAQ,SAAS;EAGvB,MAAM,QAAQ,eAAe,MAAM,UAAU,KAAK,CAAC,CAAC;EACpD,MAAM,aAAa,eAAgB,MAAM,MAAM,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,IAAI,MAAM,KAAM;EAC7F,MAAM,YAAY,eAAgB,MAAM,MAAM,KAAK,IAAI,MAAM,MAAM,SAAS,MAAM,KAAK,CAAC,IAAI,CAAE;;GAvB5F,OAAAA,UAAA,GAAAC,mBAGM,OAAA,EAHA,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,CAAC,EAAA,GAChB,EAAAH,UAAA,IAAA,GAAAC,mBAAyEG,UAAA,MAAAC,WAA3B,WAAA,QAAhB,MAAM,UAAK;IAAzC,OAAAL,UAAA,GAAAM,YAAyEC,wBAAzD,IAAI,GAAA,EAAuC,KAAK,MAAK,CAAA;GACzD,CAAA,GAAA,GAAA,IAAA,UAAA,QAAS,KAArBP,UAAA,GAAAC,mBAAyE,QAAA;;IAA7C,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA;GAAU,GAAA,MAACK,gBAAG,UAAA,KAAS,GAAA,CAAA,KAAAC,mBAAA,QAAA,IAAA,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { computed, createElementBlock, defineComponent, normalizeClass, openBlock, renderSlot, shallowRef, unref, watch } from "vue";
|
|
2
|
+
import { useFallbackProps } from "@veltra/compositions";
|
|
3
|
+
import { bem } from "@veltra/utils";
|
|
4
|
+
//#region src/components/avatar/avatar.vue
|
|
5
|
+
const _hoisted_1 = ["src", "alt"];
|
|
6
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
|
+
name: "UAvatar",
|
|
8
|
+
__name: "avatar",
|
|
9
|
+
props: {
|
|
10
|
+
src: {},
|
|
11
|
+
alt: {},
|
|
12
|
+
shape: {},
|
|
13
|
+
size: {}
|
|
14
|
+
},
|
|
15
|
+
emits: ["error"],
|
|
16
|
+
setup(__props, { emit: __emit }) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
const emit = __emit;
|
|
19
|
+
const { size } = useFallbackProps([props], { size: "default" });
|
|
20
|
+
const cls = bem("avatar");
|
|
21
|
+
const errored = shallowRef(false);
|
|
22
|
+
watch(() => props.src, () => {
|
|
23
|
+
errored.value = false;
|
|
24
|
+
});
|
|
25
|
+
const classList = computed(() => [
|
|
26
|
+
cls.b,
|
|
27
|
+
cls.m(size.value),
|
|
28
|
+
bem.is("round", props.shape === "round")
|
|
29
|
+
]);
|
|
30
|
+
const handleError = (ev) => {
|
|
31
|
+
errored.value = true;
|
|
32
|
+
emit("error", ev);
|
|
33
|
+
};
|
|
34
|
+
return (_ctx, _cache) => {
|
|
35
|
+
return openBlock(), createElementBlock("span", { class: normalizeClass(classList.value) }, [__props.src && !errored.value ? (openBlock(), createElementBlock("img", {
|
|
36
|
+
key: 0,
|
|
37
|
+
class: normalizeClass(unref(cls).e("image")),
|
|
38
|
+
src: __props.src,
|
|
39
|
+
alt: __props.alt,
|
|
40
|
+
onError: handleError
|
|
41
|
+
}, null, 42, _hoisted_1)) : (openBlock(), createElementBlock("span", {
|
|
42
|
+
key: 1,
|
|
43
|
+
class: normalizeClass(unref(cls).e("fallback"))
|
|
44
|
+
}, [renderSlot(_ctx.$slots, "default")], 2))], 2);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//#endregion
|
|
49
|
+
export { _sfc_main as default };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_renderSlot"],"sources":["../../../src/components/avatar/avatar.vue"],"sourcesContent":["<template>\n <span :class=\"classList\">\n <img\n v-if=\"src && !errored\"\n :class=\"cls.e('image')\"\n :src=\"src\"\n :alt=\"alt\"\n @error=\"handleError\"\n />\n <span v-else :class=\"cls.e('fallback')\">\n <slot />\n </span>\n </span>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport { bem } from '@veltra/utils'\nimport { computed, shallowRef, watch } from 'vue'\n\nimport type { AvatarEmits, AvatarProps, ComponentSize } from '../../types'\n\ndefineOptions({ name: 'UAvatar' })\n\nconst props = defineProps<AvatarProps>()\n\nconst emit = defineEmits<AvatarEmits>()\n\nconst { size } = useFallbackProps([props], { size: 'default' as ComponentSize })\n\nconst cls = bem('avatar')\n\nconst errored = shallowRef(false)\n\nwatch(\n () => props.src,\n () => {\n errored.value = false\n }\n)\n\nconst classList = computed(() => [\n cls.b,\n cls.m(size.value),\n bem.is('round', props.shape === 'round')\n])\n\nconst handleError = (ev: Event) => {\n errored.value = true\n emit('error', ev)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;EAwBA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,EAAE,SAAS,iBAAiB,CAAC,KAAK,GAAG,EAAE,MAAM,UAA2B,CAAC;EAE/E,MAAM,MAAM,IAAI,QAAQ;EAExB,MAAM,UAAU,WAAW,KAAK;EAEhC,YACQ,MAAM,WACN;GACJ,QAAQ,QAAQ;EAClB,CACF;EAEA,MAAM,YAAY,eAAe;GAC/B,IAAI;GACJ,IAAI,EAAE,KAAK,KAAK;GAChB,IAAI,GAAG,SAAS,MAAM,UAAU,OAAO;EACzC,CAAC;EAED,MAAM,eAAe,OAAc;GACjC,QAAQ,QAAQ;GAChB,KAAK,SAAS,EAAE;EAClB;;GAjDE,OAAAA,UAAA,GAAAC,mBAWO,QAAA,EAXA,OAAKC,eAAE,UAAA,KAAS,EAAA,GAEb,CAAA,QAAA,OAAG,CAAK,QAAA,SADhBF,UAAA,GAAAC,mBAME,OAAA;;IAJC,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;IACZ,KAAK,QAAA;IACL,KAAK,QAAA;IACL,SAAO;GAEV,GAAA,MAAA,IAAA,UAAA,MAAAH,UAAA,GAAAC,mBAEO,QAAA;;IAFO,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,UAAA,CAAA;GACxB,GAAA,CAAAC,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,EAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./style2.css";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
.u-avatar {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
flex-shrink: 0;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
border-radius: 50%;
|
|
26
|
+
color: var(--u-text-color-white);
|
|
27
|
+
background-color: var(--u-color-primary);
|
|
28
|
+
user-select: none;
|
|
29
|
+
}
|
|
30
|
+
.u-avatar--small {
|
|
31
|
+
width: var(--u-form-component-height-small);
|
|
32
|
+
height: var(--u-form-component-height-small);
|
|
33
|
+
font-size: var(--u-font-size-main-small);
|
|
34
|
+
}
|
|
35
|
+
.u-avatar--default {
|
|
36
|
+
width: var(--u-form-component-height-default);
|
|
37
|
+
height: var(--u-form-component-height-default);
|
|
38
|
+
font-size: var(--u-font-size-main-default);
|
|
39
|
+
}
|
|
40
|
+
.u-avatar--large {
|
|
41
|
+
width: var(--u-form-component-height-large);
|
|
42
|
+
height: var(--u-form-component-height-large);
|
|
43
|
+
font-size: var(--u-font-size-main-large);
|
|
44
|
+
}
|
|
45
|
+
.u-avatar.is-round {
|
|
46
|
+
border-radius: var(--u-radius-large);
|
|
47
|
+
}
|
|
48
|
+
.u-avatar__image {
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
object-fit: cover;
|
|
52
|
+
}
|
|
53
|
+
.u-avatar__fallback {
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
line-height: 1;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.u-avatar-group {
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
.u-avatar-group .u-avatar {
|
|
66
|
+
border: 2px solid var(--u-bg-color-top);
|
|
67
|
+
}
|
|
68
|
+
.u-avatar-group .u-avatar:not(:first-child) {
|
|
69
|
+
margin-left: calc(var(--u-gap-default) * -1);
|
|
70
|
+
}
|
|
71
|
+
.u-avatar-group__rest {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
width: var(--u-form-component-height-default);
|
|
78
|
+
height: var(--u-form-component-height-default);
|
|
79
|
+
font-size: var(--u-font-size-main-default);
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
border: 2px solid var(--u-bg-color-top);
|
|
82
|
+
color: var(--u-text-color-main);
|
|
83
|
+
background-color: var(--u-color-default);
|
|
84
|
+
}
|
|
85
|
+
.u-avatar-group__rest:not(:first-child) {
|
|
86
|
+
margin-left: calc(var(--u-gap-default) * -1);
|
|
87
|
+
}
|