cc1-ui 0.0.1
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/README.md +1 -0
- package/dist/autoimport.d.ts +18 -0
- package/dist/autoimport.js +160 -0
- package/dist/cc1-ui.js +86 -0
- package/dist/components/Button/index.vue.d.ts +292 -0
- package/dist/components/Button/style.css +166 -0
- package/dist/components/Circle/index.vue.d.ts +269 -0
- package/dist/components/Circle/style.css +17 -0
- package/dist/components/Icon/index.vue.d.ts +96 -0
- package/dist/components/Icon/style.css +0 -0
- package/dist/components/Mask/index.vue.d.ts +194 -0
- package/dist/components/Mask/style.css +30 -0
- package/dist/components/SIcon/index.vue.d.ts +135 -0
- package/dist/components/SIcon/style.css +0 -0
- package/dist/components/Scale/index.vue.d.ts +21 -0
- package/dist/components/Scale/style.css +19 -0
- package/dist/components/Select/index.vue.d.ts +49 -0
- package/dist/components/Select/style.css +78 -0
- package/dist/components/Switch/index.vue.d.ts +37 -0
- package/dist/components/Switch/style.css +39 -0
- package/dist/index-BGzY32VF.js +145 -0
- package/dist/index-BlU8Q4GS.js +184 -0
- package/dist/index-BvvdDtUd.js +56 -0
- package/dist/index-CpyM3z5X.js +185 -0
- package/dist/index-l4J1-e0K.js +50 -0
- package/dist/index-lDlR9NjA.js +169 -0
- package/dist/index-ti4E-Nv5.js +172 -0
- package/dist/index-ycYY--mh.js +79 -0
- package/dist/index.css +0 -0
- package/dist/index.d.ts +26 -0
- package/dist/vconf.d.ts +153 -0
- package/package.json +59 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { defineComponent, reactive, watch, onMounted, ref, createElementBlock, openBlock, normalizeStyle } from 'vue';
|
|
2
|
+
|
|
3
|
+
const viewBoxStr = "#{viewBox}";
|
|
4
|
+
const viewBoxDefault = "0 0 1024 1024";
|
|
5
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
|
+
__name: "index",
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* 加载静态资源地址,如https://cdn.xx.xx/vicon或者/static/vicon
|
|
10
|
+
*/
|
|
11
|
+
url: { default: "" },
|
|
12
|
+
/**
|
|
13
|
+
* 使用的图标库名称,默认为'ant'
|
|
14
|
+
*/
|
|
15
|
+
lib: { default: "" },
|
|
16
|
+
/**
|
|
17
|
+
* 使用的图标名称,默认为'up'
|
|
18
|
+
*/
|
|
19
|
+
name: { default: "" },
|
|
20
|
+
/**
|
|
21
|
+
* 使用的图标大小,默认为'20'
|
|
22
|
+
*/
|
|
23
|
+
size: { default: "" },
|
|
24
|
+
/**
|
|
25
|
+
* 使用的图标颜色,默认为'currentColor'
|
|
26
|
+
*/
|
|
27
|
+
color: { default: "" },
|
|
28
|
+
/**
|
|
29
|
+
* 如果为true,使用设计的图标颜色使得color属性无效。默认为false,一般用于多色或固定色图标
|
|
30
|
+
*/
|
|
31
|
+
nofill: { default: false },
|
|
32
|
+
/**
|
|
33
|
+
* 图标宽高显示单位,默认为px
|
|
34
|
+
*/
|
|
35
|
+
unit: { default: "" }
|
|
36
|
+
},
|
|
37
|
+
setup(__props) {
|
|
38
|
+
const props = __props;
|
|
39
|
+
const conf = reactive({
|
|
40
|
+
props: {
|
|
41
|
+
url: "",
|
|
42
|
+
lib: "",
|
|
43
|
+
name: "",
|
|
44
|
+
size: "",
|
|
45
|
+
color: "",
|
|
46
|
+
nofill: "",
|
|
47
|
+
unit: ""
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const viconConf = VConf.vicon;
|
|
51
|
+
const loadProps = () => {
|
|
52
|
+
Object.keys(conf.props).forEach((key) => {
|
|
53
|
+
conf.props[key] = StrUtil.isNull(props[key]) ? viconConf[key] : props[key];
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
watch(
|
|
57
|
+
() => [props.name, props.lib, props.color, props.size, props.nofill],
|
|
58
|
+
() => {
|
|
59
|
+
init();
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
init();
|
|
64
|
+
});
|
|
65
|
+
const iconRef = ref({});
|
|
66
|
+
const str = {
|
|
67
|
+
svg: [
|
|
68
|
+
`<svg style="width: 1em;height: 1em;vertical-align: middle;overflow: hidden;" viewBox="${viewBoxStr}" version="1.1" xmlns="http://www.w3.org/2000/svg">`,
|
|
69
|
+
"</svg>"
|
|
70
|
+
],
|
|
71
|
+
get0: (replacestr) => {
|
|
72
|
+
return str.svg[0].replace(viewBoxStr, replacestr);
|
|
73
|
+
},
|
|
74
|
+
getPath: (param) => {
|
|
75
|
+
return `<path d="${param.d}" fill="${param.fill ?? "currentColor"}" />`;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const init = async () => {
|
|
79
|
+
loadProps();
|
|
80
|
+
const color = ["color:black;", "color:red;"];
|
|
81
|
+
if (StrUtil.isNull(conf.props.name)) return;
|
|
82
|
+
const _url = `${conf.props.url}/${conf.props.lib}/${conf.props.name}.json`;
|
|
83
|
+
const _urlAll = `${conf.props.url}/${conf.props.lib}/_all.json`;
|
|
84
|
+
let filestr;
|
|
85
|
+
let _icon_resource_all = await viconConf.fun.getRes(_urlAll);
|
|
86
|
+
let _icon_resource = await viconConf.fun.getRes(_url);
|
|
87
|
+
if (_icon_resource_all) {
|
|
88
|
+
if (typeof _icon_resource_all === "string") _icon_resource_all = JSON.parse(_icon_resource_all);
|
|
89
|
+
filestr = _icon_resource_all[conf.props.name];
|
|
90
|
+
} else if (_icon_resource) {
|
|
91
|
+
filestr = _icon_resource;
|
|
92
|
+
} else {
|
|
93
|
+
filestr = await viconConf.fun.getResorce(_url, true);
|
|
94
|
+
}
|
|
95
|
+
if (!filestr) {
|
|
96
|
+
console.info(
|
|
97
|
+
`%c icon <%c${conf.props.lib}-${conf.props.name}%c> 不存在`,
|
|
98
|
+
`${color[0]} font-size:12px`,
|
|
99
|
+
color[1],
|
|
100
|
+
color[0]
|
|
101
|
+
);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (typeof filestr === "string") filestr = JSON.parse(filestr);
|
|
105
|
+
let res = "";
|
|
106
|
+
let objt = filestr;
|
|
107
|
+
objt.fill = objt.fill ?? { currentColor: [0] };
|
|
108
|
+
res = str.get0(objt.viewBox ?? viewBoxDefault);
|
|
109
|
+
const getFill = (fill, index) => {
|
|
110
|
+
const fillkeys = Object.keys(fill);
|
|
111
|
+
const colors = conf.props.color;
|
|
112
|
+
for (let i = 0; i < fillkeys.length; i++) {
|
|
113
|
+
const key = fillkeys[i];
|
|
114
|
+
const nums = fill[key];
|
|
115
|
+
if (nums.includes(index)) {
|
|
116
|
+
if (!conf.props.nofill && colors) {
|
|
117
|
+
if (Array.isArray(colors)) return colors[i] ?? colors[colors.length - 1];
|
|
118
|
+
return colors;
|
|
119
|
+
} else {
|
|
120
|
+
return key;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return "currentColor";
|
|
125
|
+
};
|
|
126
|
+
objt.d.forEach((item, index) => {
|
|
127
|
+
res += str.getPath({
|
|
128
|
+
d: item,
|
|
129
|
+
fill: getFill(objt.fill, index)
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
res += str.svg[1];
|
|
133
|
+
if (iconRef.value) iconRef.value.innerHTML = res;
|
|
134
|
+
};
|
|
135
|
+
return (_ctx, _cache) => {
|
|
136
|
+
return openBlock(), createElementBlock("div", {
|
|
137
|
+
ref_key: "iconRef",
|
|
138
|
+
ref: iconRef,
|
|
139
|
+
style: normalizeStyle([{ "display": "inline-flex" }, { fontSize: `${conf.props.size}${conf.props.unit}`, color: conf.props.color }])
|
|
140
|
+
}, null, 4);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { defineComponent, reactive, getCurrentInstance, watch, onMounted, createElementBlock, openBlock, mergeProps } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
__name: "index",
|
|
5
|
+
props: {
|
|
6
|
+
/**
|
|
7
|
+
* 加载静态资源地址,如https://cdn.xx.xx/vsicon或者/static/vsicon
|
|
8
|
+
*/
|
|
9
|
+
url: { default: "" },
|
|
10
|
+
/**
|
|
11
|
+
* 使用的图标库名称,默认为''
|
|
12
|
+
*/
|
|
13
|
+
lib: { default: "" },
|
|
14
|
+
/**
|
|
15
|
+
* 使用的图标名称,默认为'up'
|
|
16
|
+
*/
|
|
17
|
+
name: { default: "" },
|
|
18
|
+
/**
|
|
19
|
+
* 使用的图标大小,默认为'20'
|
|
20
|
+
*/
|
|
21
|
+
size: { default: "" },
|
|
22
|
+
/**
|
|
23
|
+
* 图标大小-宽
|
|
24
|
+
*/
|
|
25
|
+
width: { default: void 0 },
|
|
26
|
+
/**
|
|
27
|
+
* 图标大小-高
|
|
28
|
+
*/
|
|
29
|
+
height: { default: void 0 },
|
|
30
|
+
/**
|
|
31
|
+
* 使用的图标颜色,默认为[]
|
|
32
|
+
*/
|
|
33
|
+
color: { default: [] },
|
|
34
|
+
/**
|
|
35
|
+
* 鼠标悬浮时使用的图标颜色,默认为[]
|
|
36
|
+
*/
|
|
37
|
+
hoverColor: { default: void 0 },
|
|
38
|
+
/**
|
|
39
|
+
* 用于hover时的dom元素id或者class,默认为undefined
|
|
40
|
+
*/
|
|
41
|
+
pid: { default: void 0 },
|
|
42
|
+
/**
|
|
43
|
+
* 图标宽高显示单位,默认为px
|
|
44
|
+
*/
|
|
45
|
+
unit: { default: "" }
|
|
46
|
+
},
|
|
47
|
+
setup(__props) {
|
|
48
|
+
const props = __props;
|
|
49
|
+
const viconConf = VConf.vsicon;
|
|
50
|
+
const svgToUrl = (url) => {
|
|
51
|
+
var encoded = url.replace(/<!--(.*)-->/g, "").replace(/[\r\n]/g, " ").replace(/"/g, `'`).replace(/%/g, "%25").replace(/&/g, "%26").replace(/#/g, "%23").replace(/{/g, "%7B").replace(/}/g, "%7D").replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
52
|
+
let res = `"data:image/svg+xml,${encoded}"`;
|
|
53
|
+
return res;
|
|
54
|
+
};
|
|
55
|
+
const colorTag = ["stop-color", "fill", "stroke"];
|
|
56
|
+
const replaceColor = (str, colorStr, _color) => {
|
|
57
|
+
for (let i = 0; i < colorTag.length; i++) {
|
|
58
|
+
const _tag = colorTag[i];
|
|
59
|
+
str = str.replace(new RegExp(`${_tag}="${colorStr}"`, "g"), `${_tag}="${_color}"`);
|
|
60
|
+
}
|
|
61
|
+
return str;
|
|
62
|
+
};
|
|
63
|
+
const conf = reactive({
|
|
64
|
+
props: {
|
|
65
|
+
url: "",
|
|
66
|
+
lib: "",
|
|
67
|
+
name: "",
|
|
68
|
+
size: "",
|
|
69
|
+
width: void 0,
|
|
70
|
+
height: void 0,
|
|
71
|
+
color: [],
|
|
72
|
+
pid: void 0,
|
|
73
|
+
hoverColor: void 0,
|
|
74
|
+
unit: "px"
|
|
75
|
+
},
|
|
76
|
+
getProps: () => {
|
|
77
|
+
Object.keys(conf.props).forEach((key) => {
|
|
78
|
+
if (!StrUtil.isNull(viconConf[key])) {
|
|
79
|
+
conf.props[key] = viconConf[key];
|
|
80
|
+
}
|
|
81
|
+
if (!StrUtil.isNull(props[key])) {
|
|
82
|
+
conf.props[key] = props[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
dom: null,
|
|
87
|
+
domHover: false,
|
|
88
|
+
domMouseenter: () => {
|
|
89
|
+
conf.domHover = true;
|
|
90
|
+
conf.init();
|
|
91
|
+
},
|
|
92
|
+
domMouseleave: () => {
|
|
93
|
+
conf.domHover = false;
|
|
94
|
+
conf.init();
|
|
95
|
+
},
|
|
96
|
+
setHover: (ischange) => {
|
|
97
|
+
if (ischange) {
|
|
98
|
+
if (conf.dom) {
|
|
99
|
+
conf.dom.removeEventListener("mouseenter", conf.domMouseenter);
|
|
100
|
+
conf.dom.removeEventListener("mouseleave", conf.domMouseleave);
|
|
101
|
+
}
|
|
102
|
+
conf.domHover = false;
|
|
103
|
+
conf.dom = null;
|
|
104
|
+
}
|
|
105
|
+
if (conf.dom || !props.hoverColor) return;
|
|
106
|
+
if (!props.pid) {
|
|
107
|
+
conf.dom = getCurrentInstance()?.proxy?.$el?.parentElement;
|
|
108
|
+
} else {
|
|
109
|
+
conf.dom = document.getElementById(props.pid);
|
|
110
|
+
}
|
|
111
|
+
if (!conf.dom) return;
|
|
112
|
+
conf.dom.addEventListener("mouseenter", conf.domMouseenter);
|
|
113
|
+
conf.dom.addEventListener("mouseleave", conf.domMouseleave);
|
|
114
|
+
},
|
|
115
|
+
content: "",
|
|
116
|
+
colorsObj: {},
|
|
117
|
+
/**
|
|
118
|
+
* 渲染图标
|
|
119
|
+
*/
|
|
120
|
+
init: async () => {
|
|
121
|
+
const sourceColor = Array.isArray(conf.props.color) ? conf.props.color : [conf.props.color];
|
|
122
|
+
const sourceHoverColor = Array.isArray(conf.props.hoverColor) ? conf.props.hoverColor : [conf.props.hoverColor];
|
|
123
|
+
let color = conf.domHover ? sourceHoverColor : sourceColor;
|
|
124
|
+
if (StrUtil.isNull(conf.props.name)) return;
|
|
125
|
+
const _url = `${conf.props.url?.length ? conf.props.url : ""}/${conf.props.lib?.length ? conf.props.lib + "/" : ""}${conf.props.name}.svg`;
|
|
126
|
+
let filestr;
|
|
127
|
+
let _icon_resource = await viconConf.fun.getRes(_url);
|
|
128
|
+
if (_icon_resource) {
|
|
129
|
+
filestr = _icon_resource;
|
|
130
|
+
} else {
|
|
131
|
+
filestr = await viconConf.fun.getResorce(_url, true);
|
|
132
|
+
}
|
|
133
|
+
let colors = [];
|
|
134
|
+
if (conf.colorsObj[conf.props.name]) {
|
|
135
|
+
colors = conf.colorsObj[conf.props.name];
|
|
136
|
+
} else {
|
|
137
|
+
const colorRegex = /(?:stop-color|fill|stroke)="(#?\w+)"/g;
|
|
138
|
+
let match;
|
|
139
|
+
while ((match = colorRegex.exec(filestr)) !== null) {
|
|
140
|
+
colors.push(match[1]);
|
|
141
|
+
}
|
|
142
|
+
colors = colors.filter((v) => v !== "none" && v.length > 0);
|
|
143
|
+
colors = [...new Set(colors)];
|
|
144
|
+
conf.colorsObj[conf.props.name] = colors;
|
|
145
|
+
}
|
|
146
|
+
for (let i = 0; i < colors.length; i++) {
|
|
147
|
+
const colorStr = colors[i];
|
|
148
|
+
const _color = color[i];
|
|
149
|
+
if (_color) {
|
|
150
|
+
filestr = replaceColor(filestr, colorStr, _color);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
conf.content = svgToUrl(filestr);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
watch(
|
|
157
|
+
() => [props.name, props.lib, props.color, props.hoverColor],
|
|
158
|
+
() => {
|
|
159
|
+
if (props.hoverColor !== conf.props.hoverColor) {
|
|
160
|
+
conf.setHover(true);
|
|
161
|
+
}
|
|
162
|
+
conf.getProps();
|
|
163
|
+
conf.init();
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
conf.getProps();
|
|
167
|
+
conf.init();
|
|
168
|
+
onMounted(() => {
|
|
169
|
+
conf.setHover();
|
|
170
|
+
});
|
|
171
|
+
return (_ctx, _cache) => {
|
|
172
|
+
return openBlock(), createElementBlock("div", mergeProps({
|
|
173
|
+
style: [{ "display": "inline-flex" }, {
|
|
174
|
+
"background-image": "url(" + conf.content + ")",
|
|
175
|
+
"background-size": "100% 100%",
|
|
176
|
+
width: (__props.width ? conf.props.width : conf.props.size) + conf.props.unit,
|
|
177
|
+
height: (__props.height ? conf.props.height : conf.props.size) + conf.props.unit
|
|
178
|
+
}]
|
|
179
|
+
}, _ctx.$attrs), null, 16);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineComponent, ref, reactive, onMounted, createElementBlock, openBlock, createElementVNode, normalizeStyle, withDirectives, toDisplayString, vShow } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
__name: "index",
|
|
5
|
+
props: {
|
|
6
|
+
theme: { default: "default" },
|
|
7
|
+
value: { default: false },
|
|
8
|
+
offLabel: { default: "" },
|
|
9
|
+
onLabel: { default: "" }
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:value"],
|
|
12
|
+
setup(__props, { emit: __emit }) {
|
|
13
|
+
const switchRef = ref({});
|
|
14
|
+
const conf = reactive({
|
|
15
|
+
width: 0,
|
|
16
|
+
theme: {
|
|
17
|
+
default: {
|
|
18
|
+
bgColor: ["#FF7C43", "#A57E71"],
|
|
19
|
+
btnColor: ["#FFFFFF", "#FFFFFF"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
conf.width = switchRef.value.clientWidth;
|
|
25
|
+
});
|
|
26
|
+
return (_ctx, _cache) => {
|
|
27
|
+
return openBlock(), createElementBlock("div", {
|
|
28
|
+
class: "v-switch-container",
|
|
29
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:value", !__props.value)),
|
|
30
|
+
ref_key: "switchRef",
|
|
31
|
+
ref: switchRef
|
|
32
|
+
}, [
|
|
33
|
+
createElementVNode("div", {
|
|
34
|
+
class: "v-switch-circle",
|
|
35
|
+
style: normalizeStyle({ background: `${__props.value ? conf.theme[__props.theme].bgColor[0] : conf.theme[__props.theme].bgColor[1]}` })
|
|
36
|
+
}, [
|
|
37
|
+
withDirectives(createElementVNode("span", { style: { "left": "5px" } }, toDisplayString(__props.onLabel), 513), [
|
|
38
|
+
[vShow, __props.value]
|
|
39
|
+
]),
|
|
40
|
+
withDirectives(createElementVNode("span", { style: { "right": "5px" } }, toDisplayString(__props.offLabel), 513), [
|
|
41
|
+
[vShow, !__props.value]
|
|
42
|
+
]),
|
|
43
|
+
createElementVNode("span", {
|
|
44
|
+
class: "v-switch-btn",
|
|
45
|
+
style: normalizeStyle({
|
|
46
|
+
transform: `translateX(${__props.value ? conf.width - 18 - 5 : "3"}px)`,
|
|
47
|
+
background: `${__props.value ? conf.theme[__props.theme].btnColor[0] : conf.theme[__props.theme].btnColor[1]}`
|
|
48
|
+
})
|
|
49
|
+
}, null, 4)
|
|
50
|
+
], 4)
|
|
51
|
+
], 512);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { defineComponent, ref, reactive, watch, onMounted, resolveComponent, createElementBlock, openBlock, createElementVNode, createVNode, withDirectives, vModelText, normalizeStyle, Transition, withCtx, withModifiers, normalizeClass, Fragment, renderList, toDisplayString, vShow } from 'vue';
|
|
2
|
+
import { Scope } from 'tools-vue3';
|
|
3
|
+
|
|
4
|
+
const _hoisted_1 = { style: { "width": "calc(100% - 18px)" } };
|
|
5
|
+
const _hoisted_2 = ["readonly", "autocomplete", "placeholder"];
|
|
6
|
+
const _hoisted_3 = ["onClick"];
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
__name: "index",
|
|
9
|
+
props: {
|
|
10
|
+
list: { default: [] },
|
|
11
|
+
active: { default: "" },
|
|
12
|
+
placeholder: { default: "请选择" },
|
|
13
|
+
/**
|
|
14
|
+
* 可输入进行过滤
|
|
15
|
+
*/
|
|
16
|
+
filterable: { default: null }
|
|
17
|
+
},
|
|
18
|
+
emits: ["update:active", "change"],
|
|
19
|
+
setup(__props, { emit: __emit }) {
|
|
20
|
+
const props = __props;
|
|
21
|
+
const emit = __emit;
|
|
22
|
+
const dialogRef = ref({});
|
|
23
|
+
const inputRef = ref({});
|
|
24
|
+
const timer = Scope.Timer();
|
|
25
|
+
const conf = reactive({
|
|
26
|
+
activeItem: { value: "", label: "" },
|
|
27
|
+
input: {
|
|
28
|
+
/**
|
|
29
|
+
* 初始化选项
|
|
30
|
+
*/
|
|
31
|
+
initValue: () => {
|
|
32
|
+
const _item = props.list.find((item) => item.value === props.active);
|
|
33
|
+
if (_item) {
|
|
34
|
+
if (conf.activeItem.value !== _item.value) {
|
|
35
|
+
conf.activeItem = _item;
|
|
36
|
+
conf.input.setValue(_item);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
label: "",
|
|
41
|
+
setValue: (item) => {
|
|
42
|
+
const bvalue = conf.activeItem.value;
|
|
43
|
+
if (props.filterable === null || item) {
|
|
44
|
+
if (item?.label) {
|
|
45
|
+
conf.activeItem = item;
|
|
46
|
+
const _item = props.list.find((item2) => item2.value === conf.activeItem.value);
|
|
47
|
+
conf.input.label = _item ? _item.label : "";
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
const _item = props.list.find((item2) => item2.value === conf.input.label);
|
|
51
|
+
if (_item) {
|
|
52
|
+
conf.activeItem = _item;
|
|
53
|
+
conf.input.label = _item.label;
|
|
54
|
+
} else {
|
|
55
|
+
conf.input.label = conf.activeItem.label;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
emit("update:active", conf.activeItem.value);
|
|
59
|
+
if (bvalue !== conf.activeItem.value) {
|
|
60
|
+
emit("change", conf.activeItem);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
readonly: props.filterable == null,
|
|
64
|
+
autocomplete: "off"
|
|
65
|
+
},
|
|
66
|
+
dialog: {
|
|
67
|
+
show: false,
|
|
68
|
+
transition: "fade-up",
|
|
69
|
+
position: {
|
|
70
|
+
maxHeight: 274
|
|
71
|
+
},
|
|
72
|
+
click: (item) => {
|
|
73
|
+
conf.dialog.close(item);
|
|
74
|
+
},
|
|
75
|
+
closeFun: () => {
|
|
76
|
+
},
|
|
77
|
+
close: (item) => {
|
|
78
|
+
conf.dialog.show = false;
|
|
79
|
+
conf.dialog.closeFun();
|
|
80
|
+
conf.input.readonly = true;
|
|
81
|
+
conf.input.setValue(item);
|
|
82
|
+
},
|
|
83
|
+
open: () => {
|
|
84
|
+
conf.dialog.closeFun();
|
|
85
|
+
if (conf.dialog.show) {
|
|
86
|
+
conf.dialog.close();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
conf.dialog.show = true;
|
|
90
|
+
conf.input.readonly = props.filterable == null;
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
conf.dialog.closeFun = DomUtil.listener(window, "click", conf.dialog.close).remove;
|
|
93
|
+
}, 10);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
watch(
|
|
98
|
+
() => props.active,
|
|
99
|
+
() => conf.input.initValue()
|
|
100
|
+
);
|
|
101
|
+
onMounted(() => {
|
|
102
|
+
conf.input.initValue();
|
|
103
|
+
timer.on(() => {
|
|
104
|
+
if (!conf.dialog.show) return;
|
|
105
|
+
if (inputRef.value?.getBoundingClientRect) {
|
|
106
|
+
const inputrect = inputRef.value.getBoundingClientRect();
|
|
107
|
+
if (dialogRef.value?.getBoundingClientRect) {
|
|
108
|
+
const rect = dialogRef.value.getBoundingClientRect();
|
|
109
|
+
if (inputrect.top + inputrect.height + rect.height > document.body.clientHeight) {
|
|
110
|
+
dialogRef.value.style.top = "";
|
|
111
|
+
dialogRef.value.style.bottom = inputrect.height + 10 + "px";
|
|
112
|
+
conf.dialog.transition = "fade-down";
|
|
113
|
+
} else {
|
|
114
|
+
dialogRef.value.style.top = inputrect.height + 10 + "px";
|
|
115
|
+
dialogRef.value.style.bottom = "";
|
|
116
|
+
conf.dialog.transition = "fade-up";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, 10);
|
|
121
|
+
});
|
|
122
|
+
return (_ctx, _cache) => {
|
|
123
|
+
const _component_VIcon = resolveComponent("VIcon");
|
|
124
|
+
return openBlock(), createElementBlock("div", {
|
|
125
|
+
class: "v-select",
|
|
126
|
+
onClick: _cache[2] || (_cache[2] = //@ts-ignore
|
|
127
|
+
(...args) => conf.dialog.open && conf.dialog.open(...args)),
|
|
128
|
+
ref_key: "inputRef",
|
|
129
|
+
ref: inputRef
|
|
130
|
+
}, [
|
|
131
|
+
createElementVNode("div", _hoisted_1, [
|
|
132
|
+
withDirectives(createElementVNode("input", {
|
|
133
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => conf.input.label = $event),
|
|
134
|
+
type: "text",
|
|
135
|
+
readonly: conf.input.readonly,
|
|
136
|
+
autocomplete: conf.input.autocomplete,
|
|
137
|
+
placeholder: __props.placeholder
|
|
138
|
+
}, null, 8, _hoisted_2), [
|
|
139
|
+
[vModelText, conf.input.label]
|
|
140
|
+
])
|
|
141
|
+
]),
|
|
142
|
+
createElementVNode("div", {
|
|
143
|
+
style: normalizeStyle([{ "display": "inline-flex", "transition": "all 0.3s" }, { transform: conf.dialog.show ? "rotateZ(90deg)" : "" }])
|
|
144
|
+
}, [
|
|
145
|
+
createVNode(_component_VIcon, {
|
|
146
|
+
type: "right",
|
|
147
|
+
color: "currentColor"
|
|
148
|
+
})
|
|
149
|
+
], 4),
|
|
150
|
+
createVNode(Transition, {
|
|
151
|
+
name: conf.dialog.transition
|
|
152
|
+
}, {
|
|
153
|
+
default: withCtx(() => [
|
|
154
|
+
withDirectives(createElementVNode("div", {
|
|
155
|
+
class: "v-select-dialog",
|
|
156
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
157
|
+
}, ["stop"])),
|
|
158
|
+
ref_key: "dialogRef",
|
|
159
|
+
ref: dialogRef
|
|
160
|
+
}, [
|
|
161
|
+
createElementVNode("div", {
|
|
162
|
+
class: normalizeClass(["v-select-dialog-arrows", [conf.dialog.transition === "fade-up" ? "down" : "up"]])
|
|
163
|
+
}, null, 2),
|
|
164
|
+
createElementVNode("div", {
|
|
165
|
+
style: normalizeStyle([{ maxHeight: conf.dialog.position.maxHeight + "px" }, { "overflow-y": "auto" }])
|
|
166
|
+
}, [
|
|
167
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (item) => {
|
|
168
|
+
return openBlock(), createElementBlock("div", {
|
|
169
|
+
class: normalizeClass(["v-select-dialog-item", [conf.activeItem.value === item.value ? "selected" : ""]]),
|
|
170
|
+
onClick: withModifiers(($event) => conf.dialog.click(item), ["stop"])
|
|
171
|
+
}, toDisplayString(item.label), 11, _hoisted_3);
|
|
172
|
+
}), 256))
|
|
173
|
+
], 4)
|
|
174
|
+
], 512), [
|
|
175
|
+
[vShow, conf.dialog.show]
|
|
176
|
+
])
|
|
177
|
+
]),
|
|
178
|
+
_: 1
|
|
179
|
+
}, 8, ["name"])
|
|
180
|
+
], 512);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineComponent, reactive, onMounted, onUnmounted, createElementBlock, openBlock, createElementVNode, normalizeStyle, renderSlot } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = { class: "v-scale-box" };
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
__name: "index",
|
|
6
|
+
setup(__props) {
|
|
7
|
+
const conf = reactive({
|
|
8
|
+
transform: "scale(1)",
|
|
9
|
+
top: 0,
|
|
10
|
+
left: 0
|
|
11
|
+
});
|
|
12
|
+
const autoSize = () => {
|
|
13
|
+
const w = document.body.scrollWidth;
|
|
14
|
+
const h = document.body.scrollHeight;
|
|
15
|
+
const sw = w / 1920;
|
|
16
|
+
const sh = h / 1080;
|
|
17
|
+
let res = 1;
|
|
18
|
+
res = sw < sh ? sw : sh;
|
|
19
|
+
const resW = 1920 * res;
|
|
20
|
+
const resH = 1080 * res;
|
|
21
|
+
conf.top = (h - resH) / 2;
|
|
22
|
+
conf.left = (w - resW) / 2;
|
|
23
|
+
conf.transform = "scale(" + res.toFixed(4) + ")";
|
|
24
|
+
};
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
autoSize();
|
|
27
|
+
window.addEventListener("resize", autoSize);
|
|
28
|
+
});
|
|
29
|
+
onUnmounted(() => {
|
|
30
|
+
window.removeEventListener("resize", autoSize);
|
|
31
|
+
});
|
|
32
|
+
return (_ctx, _cache) => {
|
|
33
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
34
|
+
createElementVNode("div", {
|
|
35
|
+
class: "v-scale-container",
|
|
36
|
+
style: normalizeStyle({ top: `${conf.top}px`, left: `${conf.left}px` })
|
|
37
|
+
}, [
|
|
38
|
+
createElementVNode("div", {
|
|
39
|
+
class: "v-scale-content",
|
|
40
|
+
style: normalizeStyle({ transform: conf.transform })
|
|
41
|
+
}, [
|
|
42
|
+
renderSlot(_ctx.$slots, "default")
|
|
43
|
+
], 4)
|
|
44
|
+
], 4)
|
|
45
|
+
]);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { _sfc_main as default };
|