@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,172 @@
|
|
|
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-transfer {
|
|
19
|
+
width: 100%;
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: flex-start;
|
|
22
|
+
align-items: center;
|
|
23
|
+
flex-wrap: nowrap;
|
|
24
|
+
}
|
|
25
|
+
.u-transfer__buttons {
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: calc(var(--u-gap-default) / 2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.u-transfer-list {
|
|
33
|
+
flex: 1;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
background-color: var(--u-bg-color-top);
|
|
38
|
+
border: var(--u-border);
|
|
39
|
+
border-radius: var(--u-radius-default);
|
|
40
|
+
box-shadow: var(--u-shadow-emboss);
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
}
|
|
43
|
+
.u-transfer-list__header {
|
|
44
|
+
flex-shrink: 0;
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: flex-start;
|
|
47
|
+
align-items: center;
|
|
48
|
+
flex-wrap: nowrap;
|
|
49
|
+
}
|
|
50
|
+
.u-transfer-list__title {
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
}
|
|
55
|
+
.u-transfer-list__count {
|
|
56
|
+
flex-shrink: 0;
|
|
57
|
+
margin-left: auto;
|
|
58
|
+
color: var(--u-text-color-second);
|
|
59
|
+
}
|
|
60
|
+
.u-transfer-list__filter {
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
border-bottom: var(--u-border);
|
|
63
|
+
}
|
|
64
|
+
.u-transfer-list__filter-input {
|
|
65
|
+
width: 100%;
|
|
66
|
+
padding: 0;
|
|
67
|
+
margin: 0;
|
|
68
|
+
border: none;
|
|
69
|
+
outline: none;
|
|
70
|
+
background: transparent;
|
|
71
|
+
font: inherit;
|
|
72
|
+
color: var(--u-text-color-main);
|
|
73
|
+
cursor: text;
|
|
74
|
+
}
|
|
75
|
+
.u-transfer-list__filter-input::placeholder {
|
|
76
|
+
color: var(--u-text-color-placeholder);
|
|
77
|
+
}
|
|
78
|
+
.u-transfer-list__filter-input:disabled {
|
|
79
|
+
cursor: not-allowed;
|
|
80
|
+
}
|
|
81
|
+
.u-transfer-list__body {
|
|
82
|
+
flex: 1;
|
|
83
|
+
height: 240px;
|
|
84
|
+
margin: 0;
|
|
85
|
+
padding: 0;
|
|
86
|
+
list-style: none;
|
|
87
|
+
overflow-y: auto;
|
|
88
|
+
}
|
|
89
|
+
.u-transfer-list__item {
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
user-select: none;
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: flex-start;
|
|
94
|
+
align-items: center;
|
|
95
|
+
flex-wrap: nowrap;
|
|
96
|
+
}
|
|
97
|
+
.u-transfer-list__item:hover {
|
|
98
|
+
background-color: var(--u-bg-color-hover);
|
|
99
|
+
}
|
|
100
|
+
.u-transfer-list__item.is-disabled {
|
|
101
|
+
cursor: not-allowed;
|
|
102
|
+
color: var(--u-text-color-disabled);
|
|
103
|
+
}
|
|
104
|
+
.u-transfer-list__item.is-disabled:hover {
|
|
105
|
+
background-color: transparent;
|
|
106
|
+
}
|
|
107
|
+
.u-transfer-list__item-label {
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
text-overflow: ellipsis;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
}
|
|
112
|
+
.u-transfer-list__empty {
|
|
113
|
+
height: 240px;
|
|
114
|
+
display: flex;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
align-items: center;
|
|
117
|
+
flex-wrap: nowrap;
|
|
118
|
+
}
|
|
119
|
+
.u-transfer-list--small .u-transfer-list__header {
|
|
120
|
+
height: var(--u-form-component-height-small);
|
|
121
|
+
padding: 0 var(--u-gap-small);
|
|
122
|
+
border-bottom: var(--u-border);
|
|
123
|
+
}
|
|
124
|
+
.u-transfer-list--small .u-transfer-list__filter {
|
|
125
|
+
height: var(--u-form-component-height-small);
|
|
126
|
+
padding: 0 var(--u-gap-small);
|
|
127
|
+
}
|
|
128
|
+
.u-transfer-list--small .u-transfer-list__count {
|
|
129
|
+
font-size: var(--u-font-size-main-small);
|
|
130
|
+
}
|
|
131
|
+
.u-transfer-list--small .u-transfer-list__item {
|
|
132
|
+
height: var(--u-form-component-height-small);
|
|
133
|
+
padding: 0 var(--u-gap-small);
|
|
134
|
+
border-radius: var(--u-radius-small);
|
|
135
|
+
font-size: var(--u-font-size-main-small);
|
|
136
|
+
}
|
|
137
|
+
.u-transfer-list--default .u-transfer-list__header {
|
|
138
|
+
height: var(--u-form-component-height-default);
|
|
139
|
+
padding: 0 var(--u-gap-default);
|
|
140
|
+
border-bottom: var(--u-border);
|
|
141
|
+
}
|
|
142
|
+
.u-transfer-list--default .u-transfer-list__filter {
|
|
143
|
+
height: var(--u-form-component-height-default);
|
|
144
|
+
padding: 0 var(--u-gap-default);
|
|
145
|
+
}
|
|
146
|
+
.u-transfer-list--default .u-transfer-list__count {
|
|
147
|
+
font-size: var(--u-font-size-main-default);
|
|
148
|
+
}
|
|
149
|
+
.u-transfer-list--default .u-transfer-list__item {
|
|
150
|
+
height: var(--u-form-component-height-default);
|
|
151
|
+
padding: 0 var(--u-gap-default);
|
|
152
|
+
border-radius: var(--u-radius-default);
|
|
153
|
+
font-size: var(--u-font-size-main-default);
|
|
154
|
+
}
|
|
155
|
+
.u-transfer-list--large .u-transfer-list__header {
|
|
156
|
+
height: var(--u-form-component-height-large);
|
|
157
|
+
padding: 0 var(--u-gap-large);
|
|
158
|
+
border-bottom: var(--u-border);
|
|
159
|
+
}
|
|
160
|
+
.u-transfer-list--large .u-transfer-list__filter {
|
|
161
|
+
height: var(--u-form-component-height-large);
|
|
162
|
+
padding: 0 var(--u-gap-large);
|
|
163
|
+
}
|
|
164
|
+
.u-transfer-list--large .u-transfer-list__count {
|
|
165
|
+
font-size: var(--u-font-size-main-large);
|
|
166
|
+
}
|
|
167
|
+
.u-transfer-list--large .u-transfer-list__item {
|
|
168
|
+
height: var(--u-form-component-height-large);
|
|
169
|
+
padding: 0 var(--u-gap-large);
|
|
170
|
+
border-radius: var(--u-radius-large);
|
|
171
|
+
font-size: var(--u-font-size-main-large);
|
|
172
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import _sfc_main$1 from "../empty/empty.js";
|
|
2
|
+
import _sfc_main$2 from "../checkbox/checkbox.js";
|
|
3
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderList, toDisplayString, unref, vModelText, withDirectives, withModifiers } from "vue";
|
|
4
|
+
import { bem } from "@veltra/utils";
|
|
5
|
+
//#region src/components/transfer/transfer-list.vue
|
|
6
|
+
const _hoisted_1 = ["placeholder", "disabled"];
|
|
7
|
+
const _hoisted_2 = ["onClick"];
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
name: "UTransferList",
|
|
10
|
+
__name: "transfer-list",
|
|
11
|
+
props: {
|
|
12
|
+
title: { default: "" },
|
|
13
|
+
options: { default: () => [] },
|
|
14
|
+
checkedKeys: {},
|
|
15
|
+
filterable: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
placeholder: { default: "" },
|
|
20
|
+
disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
size: { default: "default" }
|
|
25
|
+
},
|
|
26
|
+
emits: ["check", "check-all"],
|
|
27
|
+
setup(__props, { emit: __emit }) {
|
|
28
|
+
const emit = __emit;
|
|
29
|
+
const cls = bem("transfer-list");
|
|
30
|
+
const query = ref("");
|
|
31
|
+
/** 搜索只作用于本栏,按 label 匹配 */
|
|
32
|
+
const filtered = computed(() => __props.options.filter((o) => o.label.includes(query.value)));
|
|
33
|
+
const selectable = computed(() => filtered.value.filter((o) => !o.disabled));
|
|
34
|
+
const allChecked = computed(() => selectable.value.length > 0 && selectable.value.every((o) => __props.checkedKeys.has(o.key)));
|
|
35
|
+
const indeterminate = computed(() => {
|
|
36
|
+
return selectable.value.filter((o) => __props.checkedKeys.has(o.key)).length > 0 && !allChecked.value;
|
|
37
|
+
});
|
|
38
|
+
const checkedCount = computed(() => __props.options.filter((o) => __props.checkedKeys.has(o.key)).length);
|
|
39
|
+
function handleCheckAll(checked) {
|
|
40
|
+
const keys = checked ? selectable.value.map((o) => o.key) : filtered.value.filter((o) => __props.checkedKeys.has(o.key)).map((o) => o.key);
|
|
41
|
+
emit("check-all", keys, checked);
|
|
42
|
+
}
|
|
43
|
+
function handleItemClick(option) {
|
|
44
|
+
if (__props.disabled || option.disabled) return;
|
|
45
|
+
emit("check", option.key, !__props.checkedKeys.has(option.key));
|
|
46
|
+
}
|
|
47
|
+
return (_ctx, _cache) => {
|
|
48
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass([unref(cls).b, unref(cls).m(__props.size)]) }, [
|
|
49
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("header")) }, [
|
|
50
|
+
createVNode(unref(_sfc_main$2), {
|
|
51
|
+
"model-value": allChecked.value,
|
|
52
|
+
indeterminate: indeterminate.value,
|
|
53
|
+
disabled: __props.disabled || !selectable.value.length,
|
|
54
|
+
"onUpdate:modelValue": handleCheckAll
|
|
55
|
+
}, null, 8, [
|
|
56
|
+
"model-value",
|
|
57
|
+
"indeterminate",
|
|
58
|
+
"disabled"
|
|
59
|
+
]),
|
|
60
|
+
createElementVNode("span", { class: normalizeClass(unref(cls).e("title")) }, toDisplayString(__props.title), 3),
|
|
61
|
+
createElementVNode("span", { class: normalizeClass(unref(cls).e("count")) }, toDisplayString(checkedCount.value) + "/" + toDisplayString(__props.options.length), 3)
|
|
62
|
+
], 2),
|
|
63
|
+
__props.filterable ? (openBlock(), createElementBlock("div", {
|
|
64
|
+
key: 0,
|
|
65
|
+
class: normalizeClass(unref(cls).e("filter"))
|
|
66
|
+
}, [withDirectives(createElementVNode("input", {
|
|
67
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => query.value = $event),
|
|
68
|
+
class: normalizeClass(unref(cls).e("filter-input")),
|
|
69
|
+
placeholder: __props.placeholder,
|
|
70
|
+
disabled: __props.disabled
|
|
71
|
+
}, null, 10, _hoisted_1), [[vModelText, query.value]])], 2)) : createCommentVNode("v-if", true),
|
|
72
|
+
filtered.value.length ? (openBlock(), createElementBlock("ul", {
|
|
73
|
+
key: 1,
|
|
74
|
+
class: normalizeClass(unref(cls).e("body"))
|
|
75
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(filtered.value, (option) => {
|
|
76
|
+
return openBlock(), createElementBlock("li", {
|
|
77
|
+
key: option.key,
|
|
78
|
+
class: normalizeClass([unref(cls).e("item"), unref(bem).is("disabled", __props.disabled || option.disabled)]),
|
|
79
|
+
onClick: ($event) => handleItemClick(option)
|
|
80
|
+
}, [createVNode(unref(_sfc_main$2), {
|
|
81
|
+
"model-value": __props.checkedKeys.has(option.key),
|
|
82
|
+
disabled: __props.disabled || option.disabled,
|
|
83
|
+
"onUpdate:modelValue": ($event) => emit("check", option.key, $event),
|
|
84
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"]))
|
|
85
|
+
}, null, 8, [
|
|
86
|
+
"model-value",
|
|
87
|
+
"disabled",
|
|
88
|
+
"onUpdate:modelValue"
|
|
89
|
+
]), createElementVNode("span", { class: normalizeClass(unref(cls).e("item-label")) }, toDisplayString(option.label), 3)], 10, _hoisted_2);
|
|
90
|
+
}), 128))], 2)) : (openBlock(), createElementBlock("div", {
|
|
91
|
+
key: 2,
|
|
92
|
+
class: normalizeClass(unref(cls).e("empty"))
|
|
93
|
+
}, [createVNode(unref(_sfc_main$1))], 2))
|
|
94
|
+
], 2);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
//#endregion
|
|
99
|
+
export { _sfc_main as default };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=transfer-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-list.js","names":["_openBlock","_createElementBlock","_normalizeClass","_unref","_createElementVNode","_createVNode","UCheckbox","_toDisplayString","_withDirectives","_vModelText","_createCommentVNode","_Fragment","_renderList","_withModifiers","UEmpty"],"sources":["../../../src/components/transfer/transfer-list.vue"],"sourcesContent":["<template>\n <div :class=\"[cls.b, cls.m(size)]\">\n <div :class=\"cls.e('header')\">\n <u-checkbox\n :model-value=\"allChecked\"\n :indeterminate=\"indeterminate\"\n :disabled=\"disabled || !selectable.length\"\n @update:model-value=\"handleCheckAll\"\n />\n\n <span :class=\"cls.e('title')\">{{ title }}</span>\n\n <span :class=\"cls.e('count')\">{{ checkedCount }}/{{ options.length }}</span>\n </div>\n\n <div v-if=\"filterable\" :class=\"cls.e('filter')\">\n <input\n v-model=\"query\"\n :class=\"cls.e('filter-input')\"\n :placeholder=\"placeholder\"\n :disabled=\"disabled\"\n />\n </div>\n\n <ul v-if=\"filtered.length\" :class=\"cls.e('body')\">\n <li\n v-for=\"option of filtered\"\n :key=\"option.key\"\n :class=\"[cls.e('item'), bem.is('disabled', disabled || option.disabled)]\"\n @click=\"handleItemClick(option)\"\n >\n <u-checkbox\n :model-value=\"checkedKeys.has(option.key)\"\n :disabled=\"disabled || option.disabled\"\n @update:model-value=\"emit('check', option.key, $event)\"\n @click.stop\n />\n\n <span :class=\"cls.e('item-label')\">{{ option.label }}</span>\n </li>\n </ul>\n\n <div v-else :class=\"cls.e('empty')\">\n <u-empty />\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport type { ComponentSize } from '@veltra/utils'\nimport { bem } from '@veltra/utils'\nimport { computed, ref } from 'vue'\n\nimport type { TransferOption } from '../../types'\nimport { UCheckbox } from '../checkbox'\nimport { UEmpty } from '../empty'\n\ndefineOptions({ name: 'UTransferList' })\n\nconst {\n title = '',\n options = [],\n checkedKeys,\n filterable = false,\n placeholder = '',\n disabled = false,\n size = 'default'\n} = defineProps<{\n /** 栏标题 */\n title?: string\n /** 本栏选项 */\n options?: TransferOption[]\n /** 两栏共用的勾选 key 集合 */\n checkedKeys: Set<string | number>\n /** 是否显示搜索框 */\n filterable?: boolean\n /** 搜索框占位符 */\n placeholder?: string\n /** 是否禁用整栏 */\n disabled?: boolean\n /** 组件尺寸 */\n size?: ComponentSize\n}>()\n\nconst emit = defineEmits<{\n (e: 'check', key: string | number, checked: boolean): void\n (e: 'check-all', keys: Array<string | number>, checked: boolean): void\n}>()\n\nconst cls = bem('transfer-list')\n\nconst query = ref('')\n\n/** 搜索只作用于本栏,按 label 匹配 */\nconst filtered = computed(() => options.filter((o) => o.label.includes(query.value)))\nconst selectable = computed(() => filtered.value.filter((o) => !o.disabled))\n\nconst allChecked = computed(\n () => selectable.value.length > 0 && selectable.value.every((o) => checkedKeys.has(o.key))\n)\n\nconst indeterminate = computed(() => {\n const count = selectable.value.filter((o) => checkedKeys.has(o.key)).length\n return count > 0 && !allChecked.value\n})\n\nconst checkedCount = computed(() => options.filter((o) => checkedKeys.has(o.key)).length)\n\nfunction handleCheckAll(checked: boolean) {\n const keys = checked\n ? selectable.value.map((o) => o.key)\n : filtered.value.filter((o) => checkedKeys.has(o.key)).map((o) => o.key)\n emit('check-all', keys, checked)\n}\n\nfunction handleItemClick(option: TransferOption) {\n if (disabled || option.disabled) return\n emit('check', option.key, !checkedKeys.has(option.key))\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAoFA,MAAM,OAAO;EAKb,MAAM,MAAM,IAAI,eAAe;EAE/B,MAAM,QAAQ,IAAI,EAAE;;EAGpB,MAAM,WAAW,eAAe,QAAA,QAAQ,QAAQ,MAAM,EAAE,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC;EACpF,MAAM,aAAa,eAAe,SAAS,MAAM,QAAQ,MAAM,CAAC,EAAE,QAAQ,CAAC;EAE3E,MAAM,aAAa,eACX,WAAW,MAAM,SAAS,KAAK,WAAW,MAAM,OAAO,MAAM,QAAA,YAAY,IAAI,EAAE,GAAG,CAAC,CAC3F;EAEA,MAAM,gBAAgB,eAAe;GAEnC,OADc,WAAW,MAAM,QAAQ,MAAM,QAAA,YAAY,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,SACtD,KAAK,CAAC,WAAW;EAClC,CAAC;EAED,MAAM,eAAe,eAAe,QAAA,QAAQ,QAAQ,MAAM,QAAA,YAAY,IAA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,OAAKC,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;IACvB,GAAA,CAAAE,YAAWF,MAAAW,WAAA,CAAA,CAAA,GAAA,CAAA"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _sfc_main$1 from "../button/button.js";
|
|
2
|
+
import _sfc_main$2 from "./transfer-list.js";
|
|
3
|
+
import { computed, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, normalizeClass, openBlock, shallowReactive, unref, useModel, watch } from "vue";
|
|
4
|
+
import { useFormFallbackProps } from "@veltra/compositions";
|
|
5
|
+
import { bem, injectFormContext } from "@veltra/utils";
|
|
6
|
+
import { ArrowLeft, ArrowRight } from "@veltra/icons/normal";
|
|
7
|
+
//#region src/components/transfer/transfer.vue
|
|
8
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
9
|
+
name: "UTransfer",
|
|
10
|
+
__name: "transfer",
|
|
11
|
+
props: /*@__PURE__*/ mergeModels({
|
|
12
|
+
modelValue: {},
|
|
13
|
+
dataSource: {},
|
|
14
|
+
titles: {},
|
|
15
|
+
filterable: { type: Boolean },
|
|
16
|
+
filterPlaceholder: {},
|
|
17
|
+
tips: {},
|
|
18
|
+
span: {},
|
|
19
|
+
label: {},
|
|
20
|
+
field: {},
|
|
21
|
+
disabled: { type: Boolean },
|
|
22
|
+
readonly: { type: Boolean },
|
|
23
|
+
rules: {},
|
|
24
|
+
size: {}
|
|
25
|
+
}, {
|
|
26
|
+
"modelValue": { default: () => [] },
|
|
27
|
+
"modelModifiers": {}
|
|
28
|
+
}),
|
|
29
|
+
emits: /*@__PURE__*/ mergeModels(["update:modelValue", "change"], ["update:modelValue"]),
|
|
30
|
+
setup(__props, { emit: __emit }) {
|
|
31
|
+
const props = __props;
|
|
32
|
+
const emit = __emit;
|
|
33
|
+
const cls = bem("transfer");
|
|
34
|
+
const { formProps } = injectFormContext();
|
|
35
|
+
const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {
|
|
36
|
+
size: "default",
|
|
37
|
+
disabled: false,
|
|
38
|
+
readonly: false
|
|
39
|
+
});
|
|
40
|
+
const model = useModel(__props, "modelValue");
|
|
41
|
+
/** 数据源,两栏共用;未传时按空列表处理 */
|
|
42
|
+
const dataSource = computed(() => props.dataSource ?? []);
|
|
43
|
+
/** 栏标题,未传时用默认文案 */
|
|
44
|
+
const titles = computed(() => props.titles ?? ["源列表", "目标列表"]);
|
|
45
|
+
/** 搜索框占位符,未传时用默认文案 */
|
|
46
|
+
const filterPlaceholder = computed(() => props.filterPlaceholder ?? ["请输入搜索内容", "请输入搜索内容"]);
|
|
47
|
+
/** 两栏共用的勾选 key 集合,移动后清空 */
|
|
48
|
+
const checkedSet = shallowReactive(/* @__PURE__ */ new Set());
|
|
49
|
+
const targetKeySet = computed(() => new Set(model.value));
|
|
50
|
+
/** 两栏按 data-source 出现顺序各取一半 */
|
|
51
|
+
const sourceOptions = computed(() => dataSource.value.filter((o) => !targetKeySet.value.has(o.key)));
|
|
52
|
+
const targetOptions = computed(() => dataSource.value.filter((o) => targetKeySet.value.has(o.key)));
|
|
53
|
+
const checkedSourceKeys = computed(() => Array.from(checkedSet).filter((key) => !targetKeySet.value.has(key)));
|
|
54
|
+
const checkedTargetKeys = computed(() => Array.from(checkedSet).filter((key) => targetKeySet.value.has(key)));
|
|
55
|
+
/** 数据源或绑定值外部变化后,清掉已不在数据源里的残留勾选 */
|
|
56
|
+
watch([dataSource, model], () => {
|
|
57
|
+
const keys = new Set(dataSource.value.map((o) => o.key));
|
|
58
|
+
for (const key of checkedSet) if (!keys.has(key)) checkedSet.delete(key);
|
|
59
|
+
});
|
|
60
|
+
const handleCheck = (key, checked) => {
|
|
61
|
+
if (checked) checkedSet.add(key);
|
|
62
|
+
else checkedSet.delete(key);
|
|
63
|
+
};
|
|
64
|
+
const handleCheckAll = (keys, checked) => {
|
|
65
|
+
keys.forEach((key) => checked ? checkedSet.add(key) : checkedSet.delete(key));
|
|
66
|
+
};
|
|
67
|
+
const moveTo = (direction) => {
|
|
68
|
+
const movedKeys = direction === "right" ? checkedSourceKeys.value : checkedTargetKeys.value;
|
|
69
|
+
if (!movedKeys.length) return;
|
|
70
|
+
const movedSet = new Set(movedKeys);
|
|
71
|
+
const targetKeys = direction === "right" ? [...model.value, ...movedKeys] : model.value.filter((key) => !movedSet.has(key));
|
|
72
|
+
model.value = targetKeys;
|
|
73
|
+
checkedSet.clear();
|
|
74
|
+
emit("change", targetKeys, direction, movedKeys);
|
|
75
|
+
};
|
|
76
|
+
return (_ctx, _cache) => {
|
|
77
|
+
return openBlock(), createElementBlock("div", { class: normalizeClass([
|
|
78
|
+
unref(cls).b,
|
|
79
|
+
unref(cls).m(unref(size)),
|
|
80
|
+
unref(bem).is("disabled", unref(disabled) || unref(readonly))
|
|
81
|
+
]) }, [
|
|
82
|
+
createVNode(_sfc_main$2, {
|
|
83
|
+
title: titles.value[0],
|
|
84
|
+
options: sourceOptions.value,
|
|
85
|
+
"checked-keys": unref(checkedSet),
|
|
86
|
+
filterable: __props.filterable,
|
|
87
|
+
placeholder: filterPlaceholder.value[0],
|
|
88
|
+
disabled: unref(disabled) || unref(readonly),
|
|
89
|
+
size: unref(size),
|
|
90
|
+
onCheck: handleCheck,
|
|
91
|
+
onCheckAll: handleCheckAll
|
|
92
|
+
}, null, 8, [
|
|
93
|
+
"title",
|
|
94
|
+
"options",
|
|
95
|
+
"checked-keys",
|
|
96
|
+
"filterable",
|
|
97
|
+
"placeholder",
|
|
98
|
+
"disabled",
|
|
99
|
+
"size"
|
|
100
|
+
]),
|
|
101
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("buttons")) }, [createVNode(unref(_sfc_main$1), {
|
|
102
|
+
icon: unref(ArrowRight),
|
|
103
|
+
circle: "",
|
|
104
|
+
disabled: unref(disabled) || unref(readonly) || !checkedSourceKeys.value.length,
|
|
105
|
+
onClick: _cache[0] || (_cache[0] = ($event) => moveTo("right"))
|
|
106
|
+
}, null, 8, ["icon", "disabled"]), createVNode(unref(_sfc_main$1), {
|
|
107
|
+
icon: unref(ArrowLeft),
|
|
108
|
+
circle: "",
|
|
109
|
+
disabled: unref(disabled) || unref(readonly) || !checkedTargetKeys.value.length,
|
|
110
|
+
onClick: _cache[1] || (_cache[1] = ($event) => moveTo("left"))
|
|
111
|
+
}, null, 8, ["icon", "disabled"])], 2),
|
|
112
|
+
createVNode(_sfc_main$2, {
|
|
113
|
+
title: titles.value[1],
|
|
114
|
+
options: targetOptions.value,
|
|
115
|
+
"checked-keys": unref(checkedSet),
|
|
116
|
+
filterable: __props.filterable,
|
|
117
|
+
placeholder: filterPlaceholder.value[1],
|
|
118
|
+
disabled: unref(disabled) || unref(readonly),
|
|
119
|
+
size: unref(size),
|
|
120
|
+
onCheck: handleCheck,
|
|
121
|
+
onCheckAll: handleCheckAll
|
|
122
|
+
}, null, 8, [
|
|
123
|
+
"title",
|
|
124
|
+
"options",
|
|
125
|
+
"checked-keys",
|
|
126
|
+
"filterable",
|
|
127
|
+
"placeholder",
|
|
128
|
+
"disabled",
|
|
129
|
+
"size"
|
|
130
|
+
])
|
|
131
|
+
], 2);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
//#endregion
|
|
136
|
+
export { _sfc_main as default };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_unref","_createVNode","UTransferList","_createElementVNode","UButton"],"sources":["../../../src/components/transfer/transfer.vue"],"sourcesContent":["<template>\n <div :class=\"[cls.b, cls.m(size), bem.is('disabled', disabled || readonly)]\">\n <u-transfer-list\n :title=\"titles[0]\"\n :options=\"sourceOptions\"\n :checked-keys=\"checkedSet\"\n :filterable=\"filterable\"\n :placeholder=\"filterPlaceholder[0]\"\n :disabled=\"disabled || readonly\"\n :size=\"size\"\n @check=\"handleCheck\"\n @check-all=\"handleCheckAll\"\n />\n\n <div :class=\"cls.e('buttons')\">\n <u-button\n :icon=\"ArrowRight\"\n circle\n :disabled=\"disabled || readonly || !checkedSourceKeys.length\"\n @click=\"moveTo('right')\"\n />\n\n <u-button\n :icon=\"ArrowLeft\"\n circle\n :disabled=\"disabled || readonly || !checkedTargetKeys.length\"\n @click=\"moveTo('left')\"\n />\n </div>\n\n <u-transfer-list\n :title=\"titles[1]\"\n :options=\"targetOptions\"\n :checked-keys=\"checkedSet\"\n :filterable=\"filterable\"\n :placeholder=\"filterPlaceholder[1]\"\n :disabled=\"disabled || readonly\"\n :size=\"size\"\n @check=\"handleCheck\"\n @check-all=\"handleCheckAll\"\n />\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFormFallbackProps } from '@veltra/compositions'\nimport { ArrowLeft, ArrowRight } from '@veltra/icons/normal'\nimport { bem, injectFormContext } from '@veltra/utils'\nimport { computed, shallowReactive, watch } from 'vue'\n\nimport type { TransferDirection, TransferEmits, TransferProps } from '../../types'\nimport { UButton } from '../button'\nimport UTransferList from './transfer-list.vue'\n\ndefineOptions({ name: 'UTransfer' })\n\nconst props = defineProps<TransferProps>()\n\nconst emit = defineEmits<TransferEmits>()\n\nconst cls = bem('transfer')\n\nconst { formProps } = injectFormContext()\n\nconst { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {\n size: 'default',\n disabled: false,\n readonly: false\n})\n\nconst model = defineModel<Array<string | number>>({ default: () => [] })\n\n/** 数据源,两栏共用;未传时按空列表处理 */\nconst dataSource = computed(() => props.dataSource ?? [])\n\n/** 栏标题,未传时用默认文案 */\nconst titles = computed<[string, string]>(() => props.titles ?? ['源列表', '目标列表'])\n\n/** 搜索框占位符,未传时用默认文案 */\nconst filterPlaceholder = computed<[string, string]>(\n () => props.filterPlaceholder ?? ['请输入搜索内容', '请输入搜索内容']\n)\n\n/** 两栏共用的勾选 key 集合,移动后清空 */\nconst checkedSet = shallowReactive<Set<string | number>>(new Set())\n\nconst targetKeySet = computed(() => new Set(model.value))\n\n/** 两栏按 data-source 出现顺序各取一半 */\nconst sourceOptions = computed(() => dataSource.value.filter((o) => !targetKeySet.value.has(o.key)))\nconst targetOptions = computed(() => dataSource.value.filter((o) => targetKeySet.value.has(o.key)))\n\nconst checkedSourceKeys = computed(() =>\n Array.from(checkedSet).filter((key) => !targetKeySet.value.has(key))\n)\nconst checkedTargetKeys = computed(() =>\n Array.from(checkedSet).filter((key) => targetKeySet.value.has(key))\n)\n\n/** 数据源或绑定值外部变化后,清掉已不在数据源里的残留勾选 */\nwatch([dataSource, model], () => {\n const keys = new Set(dataSource.value.map((o) => o.key))\n for (const key of checkedSet) {\n if (!keys.has(key)) checkedSet.delete(key)\n }\n})\n\nconst handleCheck = (key: string | number, checked: boolean) => {\n if (checked) {\n checkedSet.add(key)\n } else {\n checkedSet.delete(key)\n }\n}\n\nconst handleCheckAll = (keys: Array<string | number>, checked: boolean) => {\n keys.forEach((key) => (checked ? checkedSet.add(key) : checkedSet.delete(key)))\n}\n\nconst moveTo = (direction: TransferDirection) => {\n const movedKeys = direction === 'right' ? checkedSourceKeys.value : checkedTargetKeys.value\n if (!movedKeys.length) return\n\n const movedSet = new Set(movedKeys)\n const targetKeys =\n direction === 'right'\n ? [...model.value, ...movedKeys]\n : model.value.filter((key) => !movedSet.has(key))\n\n model.value = targetKeys\n checkedSet.clear()\n emit('change', targetKeys, direction, movedKeys)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,UAAU;EAE1B,MAAM,EAAE,cAAc,kBAAkB;EAExC,MAAM,EAAE,MAAM,UAAU,aAAa,qBAAqB,CAAC,aAAa,CAAC,GAAG,KAAK,GAAG;GAClF,MAAM;GACN,UAAU;GACV,UAAU;EACZ,CAAC;EAED,MAAM,QAAQA,SAAmC,SAAA,YAAsB;;EAGvE,MAAM,aAAa,eAAe,MAAM,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