btxui 1.0.9 → 1.0.11

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.
@@ -1,511 +0,0 @@
1
- import { defineComponent, ref, computed, reactive, onMounted, renderSlot } from "vue";
2
- const prestyles = {
3
- //预置样式-----------------------------------------------------------------------------------
4
- //重置初始字号及行高
5
- "resize": `font-size: 1rem; lineHeight: 1.5;`,
6
- //文字加粗
7
- "bold": `font-weight: bold;`,
8
- //隐藏显示
9
- "show": `display: "block";`,
10
- "hide": `display: "none";`,
11
- //布局
12
- "flex": `display: "flex"; justifyContent: "flex-start"; alignItems: "stretch";`,
13
- "flex-column": `display: "flex"; flexDirection: "column";`,
14
- "flex-1": `display: "flex"; justifyContent: "flex-start"; alignItems: "flex-start";`,
15
- "flex-2": `display: "flex"; justifyContent: "center"; alignItems: "flex-start";`,
16
- "flex-3": `display: "flex"; justifyContent: "flex-end"; alignItems: "flex-start";`,
17
- "flex-4": `display: "flex"; justifyContent: "flex-start"; alignItems: "center"`,
18
- "flex-5": {
19
- display: "flex",
20
- justifyContent: "center",
21
- alignItems: "center"
22
- },
23
- "flex-6": {
24
- display: "flex",
25
- justifyContent: "flex-end",
26
- alignItems: "center"
27
- },
28
- "flex-7": {
29
- display: "flex",
30
- justifyContent: "flex-start",
31
- alignItems: "flex-end"
32
- },
33
- "flex-8": {
34
- display: "flex",
35
- justifyContent: "center",
36
- alignItems: "flex-end"
37
- },
38
- "flex-9": {
39
- display: "flex",
40
- justifyContent: "flex-end",
41
- alignItems: "flex-end"
42
- },
43
- "flex-between": {
44
- display: "flex",
45
- justifyContent: "space-between",
46
- alignItems: "center"
47
- },
48
- "flex-around": {
49
- display: "flex",
50
- justifyContent: "space-around",
51
- alignItems: "center"
52
- },
53
- "grid": {
54
- display: "flex",
55
- flexWrap: "wrap",
56
- alignContent: "flex-start"
57
- },
58
- "max-h": {
59
- height: "100%"
60
- },
61
- "max-w": {
62
- width: "100%"
63
- },
64
- "max": {
65
- height: "100%",
66
- width: "100%"
67
- },
68
- "max-screen": {
69
- height: "100%",
70
- width: "100%",
71
- position: "fixed",
72
- left: 0,
73
- top: 0
74
- },
75
- "item": {
76
- breakInside: "avoid",
77
- mozPageBreakInside: "avoid",
78
- webkitColumnBreakInside: "avoid"
79
- },
80
- "fixed": { position: "fixed" },
81
- "rel": { position: "relative" },
82
- "abs": { position: "absolute" },
83
- "z-1": { zIndex: -1 },
84
- "z0": { zIndex: 0 },
85
- "z1": { zIndex: 1 },
86
- "z2": { zIndex: 2 },
87
- "z3": { zIndex: 3 },
88
- "z4": { zIndex: 4 },
89
- "z5": { zIndex: 5 },
90
- "z6": { zIndex: 6 },
91
- "z7": { zIndex: 7 },
92
- "z8": { zIndex: 8 },
93
- "z9": { zIndex: 9 },
94
- "z10": { zIndex: 10 },
95
- //溢出处理
96
- "no-scroll": { overflow: "hidden" },
97
- "over-show": { overflow: "visible" },
98
- "over-scroll": { overflow: "scroll" },
99
- "over-hide": { overflow: "hidden" },
100
- // 背景
101
- "bg-repeat": { backgroundRepeat: "repeat" },
102
- "bg-repeat-x": { backgroundRepeat: "repeat-x" },
103
- "bg-repeat-y": { backgroundRepeat: "repeat-y" },
104
- // size
105
- "bg-size-cover": `background-size: cover;`,
106
- "bg-size-contain": `background-size: contain;`,
107
- "bg-size-max": `background-size: 100% 100%;`,
108
- "bg-size-max-h": `background-size: auto 100%;`,
109
- "bg-size-max-w": `background-size: 100% auto;`,
110
- "bg-pos-1": { backgroundPosition: "left top" },
111
- "bg-pos-2": { backgroundPosition: "center top" },
112
- "bg-pos-3": { backgroundPosition: "right top" },
113
- "bg-pos-4": { backgroundPosition: "left center" },
114
- "bg-pos-5": { backgroundPosition: "center center" },
115
- "bg-pos-6": { backgroundPosition: "right center" },
116
- "bg-pos-7": { backgroundPosition: "left bottom" },
117
- "bg-pos-8": { backgroundPosition: "center bottom" },
118
- "bg-pos-9": { backgroundPosition: "right bottom" },
119
- //圆角
120
- "round": `border-radius: 50%;`,
121
- "round-lg": `borderRadius: 24px;`,
122
- "round-md": `border-radius: 10px;`,
123
- "round-sm": `borderRadius: 4px;`,
124
- "round-t": `borderBottomRightRadius: 0; borderBottomLeftRadius: 0;`,
125
- "round-b": `borderTopRightRadius: 0; borderTopLeftRadius: 0;`,
126
- "round-l": `borderTopRightRadius: 0; borderBottomRightRadius: 0;`,
127
- "round-r": `borderTopLeftRadius: 0; borderBottomLeftRadius: 0;`,
128
- //描边
129
- "line": `borderStyle: solid;`,
130
- "dashed": `borderStyle: dashed;`,
131
- "line-l": `borderLeftStyle: solid;`,
132
- "line-r": `borderRightStyle: solid;`,
133
- "line-t": `borderTopStyle: solid;`,
134
- "line-b": `borderBottomStyle: solid;`,
135
- "dashed-l": `borderLeftStyle: dashed;`,
136
- "dashed-r": `borderRightStyle: dashed;`,
137
- "dashed-t": `borderTopStyle: dashed;`,
138
- "dashed-b": `borderBottomStyle: dashed;`,
139
- "line-outside": `backgroundClip: padding-box;`,
140
- //文字描边
141
- "text-line": {
142
- textShadow: "1px 0 0 rgba(200, 200, 200, .5), -1px 0 0 rgba(200, 200, 200, .5), 0 1px 0 rgba(200, 200, 200, .5), 0 -1px 0 rgba(200, 200, 200, .5)"
143
- },
144
- //单行省略文本
145
- "ellipsis": {
146
- overflow: "hidden",
147
- textOverflow: "ellipsis",
148
- whiteSpace: "nowrap"
149
- },
150
- //阴影
151
- "shadow": { boxShadow: "0 4px 17px" },
152
- "shadow-sm": { boxShadow: "0 2px 4px" },
153
- "shadow-lg": { boxShadow: "0 14px 40px" },
154
- "shadow-relief": { boxShadow: "1px 1px 0 rgba(0,0,0,.7) inset, 1px 1px 0 rgba(255,255,255,.4)" },
155
- //过渡动画
156
- "trans": { transition: "all .7s" },
157
- "trans-fast": { transition: "all .4s" },
158
- "trans-slow": { transition: "all 1.4s" },
159
- "trans-no": { transition: "none" },
160
- //模糊滤镜
161
- "blur-no": { filter: "blur(0px)" },
162
- "blur-sm": { filter: "blur(2px)" },
163
- "blur-md": { filter: "blur(7px)" },
164
- "blur-lg": { filter: "blur(17px)" },
165
- //明度滤镜
166
- "dark-no": { filter: "brightness(100%)" },
167
- "dark-sm": { filter: "brightness(80%)" },
168
- "dark-md": { filter: "brightness(50%)" },
169
- "dark-lg": { filter: "brightness(20%)" },
170
- // 纯度滤镜
171
- "gray-no": `filter: grayscale(0%);`,
172
- "gray-sm": `filter: grayscale(40%);`,
173
- "gray-md": `filter: grayscale(70%);`,
174
- "gray-lg": `filter: grayscale(100%);`,
175
- // 特殊
176
- "bg-none": `pointerEvents: none;`,
177
- "bg-use": `pointerEvents: auto;`,
178
- "touch-none": `touchAction: none;`,
179
- // 二段赋值-----------------------------------------------------------------------------------
180
- // 文本对齐
181
- "p": {
182
- pro: "text-align"
183
- },
184
- // 文字颜色
185
- "color": {
186
- pro: "color"
187
- },
188
- // 背景色
189
- "bg": {
190
- pro: "background"
191
- },
192
- // 宽度
193
- "w": {
194
- pro: "width",
195
- unit: "rem"
196
- },
197
- // 高度
198
- "h": {
199
- pro: "height",
200
- unit: "rem"
201
- },
202
- // 内边距
203
- "pad": {
204
- pro: "padding",
205
- unit: "rem"
206
- },
207
- // 外边距
208
- "mrg": {
209
- pro: "margin",
210
- unit: "rem"
211
- },
212
- "rule_2": {
213
- //字体
214
- "font": {
215
- pro: "fontFamily"
216
- },
217
- //字号
218
- "fsize": {
219
- pro: "fontSize",
220
- unit: "em"
221
- },
222
- //行高
223
- "lh": {
224
- pro: "lineHeight"
225
- },
226
- //字符间距
227
- "lspace": {
228
- pro: "letterSpacing",
229
- unit: "rem"
230
- },
231
- //不透明度
232
- "alpha": {
233
- pro: "opacity",
234
- extra: {
235
- visibility: "visible"
236
- },
237
- escape: {
238
- "0": {
239
- visibility: "hidden"
240
- }
241
- }
242
- },
243
- //描边颜色
244
- "line": {
245
- pro: "borderColor"
246
- },
247
- //自生长比率
248
- "grow": {
249
- pro: "flexGrow",
250
- extra: {
251
- flexBasis: 0
252
- }
253
- },
254
- //弹性布局项目排序
255
- "order": {
256
- pro: "order"
257
- },
258
- //多列布局容器
259
- "column": {
260
- pro: "columnCount",
261
- extra: {
262
- columnGap: 0
263
- }
264
- },
265
- //最大宽
266
- "rw": {
267
- pro: "maxWidth",
268
- unit: "rem"
269
- },
270
- //最小宽
271
- "lw": {
272
- pro: "minWidth",
273
- unit: "rem"
274
- },
275
- //最大高
276
- "th": {
277
- pro: "maxHeight",
278
- unit: "rem"
279
- },
280
- //最小高
281
- "bh": {
282
- pro: "minHeight",
283
- unit: "rem"
284
- },
285
- //基于容器左侧水平位移
286
- "l": {
287
- pro: "left",
288
- unit: "rem"
289
- },
290
- //基于容器右侧水平位移
291
- "r": {
292
- pro: "right",
293
- unit: "rem"
294
- },
295
- //基于容器上侧垂直位移
296
- "t": {
297
- pro: "top",
298
- unit: "rem"
299
- },
300
- //基于容器下侧垂直位移
301
- "b": {
302
- pro: "bottom",
303
- unit: "rem"
304
- },
305
- //水平位移
306
- "translateX": {
307
- pro: "transform",
308
- tmp: "translateX(%{}%)",
309
- unit: "%"
310
- },
311
- //垂直位移
312
- "translateY": {
313
- pro: "transform",
314
- tmp: "translateY(%{}%)",
315
- unit: "%"
316
- },
317
- //放缩
318
- "scale": {
319
- pro: "transform",
320
- tmp: "scale(%{}%)"
321
- },
322
- //旋转
323
- "rotate": {
324
- pro: "transform",
325
- tmp: "rotate(%{}%)",
326
- unit: "deg"
327
- },
328
- //变形
329
- "transform": {
330
- pro: "transform"
331
- },
332
- //变形中心点
333
- "origin": {
334
- pro: "transformOrigin"
335
- },
336
- //描边粗细
337
- "thick": {
338
- pro: "borderWidth",
339
- unit: "px"
340
- },
341
- //过渡动画延迟
342
- "trans": {
343
- pro: "transition"
344
- }
345
- },
346
- //三段赋值-----------------------------------------------------------------------------------
347
- "rule_3": {
348
- //左侧
349
- "l": {
350
- pro: ["Left"],
351
- unit: "rem"
352
- },
353
- //右侧
354
- "r": {
355
- pro: ["Right"],
356
- unit: "rem"
357
- },
358
- //上侧
359
- "t": {
360
- pro: ["Top"],
361
- unit: "rem"
362
- },
363
- //下侧
364
- "b": {
365
- pro: ["Bottom"],
366
- unit: "rem"
367
- },
368
- //垂直方向
369
- "v": {
370
- pro: ["Top", "Bottom"],
371
- unit: "rem"
372
- },
373
- //水平方向
374
- "h": {
375
- pro: ["Left", "Right"],
376
- unit: "rem"
377
- },
378
- //背景颜色
379
- "gradient": {
380
- pro: ["Image"],
381
- tmp: "-webkit-linear-gradient(%{}%)"
382
- },
383
- //背景颜色
384
- "color": {
385
- pro: ["Color"]
386
- },
387
- //背景尺寸
388
- "size": {
389
- pro: ["Size"]
390
- },
391
- //背景定位
392
- "pos": {
393
- pro: ["Position"]
394
- },
395
- //过渡动画延迟
396
- "delay": {
397
- pro: ["Delay"],
398
- unit: "s"
399
- }
400
- }
401
- };
402
- const theme = {
403
- // 预置主题色
404
- colors: {
405
- none: "transparent",
406
- main: "#051c24",
407
- sub: "#b4967a",
408
- light: "#fff",
409
- lgray: "#eee",
410
- mgray: "#a7a7a7",
411
- dgray: "#373737",
412
- dark: "#111",
413
- blue: "#4085f3",
414
- green: "#02b9a1",
415
- yellow: "#fdba00",
416
- red: "#ec4334",
417
- neutral: "rgba(134,134,134,.17)"
418
- },
419
- // 追加或覆盖主题色
420
- append(colors) {
421
- this.colors = { ...this.colors, ...colors };
422
- }
423
- };
424
- const GLOBAL_STYLE_NAME = "BTXUIGlobal";
425
- const _sfc_main = /* @__PURE__ */ defineComponent({
426
- __name: "index",
427
- props: {
428
- // 样式集
429
- class: {
430
- type: String,
431
- required: false
432
- }
433
- },
434
- setup(__props) {
435
- const props = __props;
436
- const $style = ref();
437
- const styleMap = computed(() => {
438
- const list = [];
439
- for (let item of $style.value.sheet.rules) {
440
- list.push(item.selectorText.substr(1));
441
- }
442
- return list;
443
- });
444
- const initStyle = () => {
445
- let $_style = document.head.querySelector(`#${GLOBAL_STYLE_NAME}`);
446
- if (!$_style) {
447
- $_style = document.createElement("style");
448
- $_style.setAttribute("type", "text/css");
449
- $_style.setAttribute("id", GLOBAL_STYLE_NAME);
450
- document.head.appendChild($_style);
451
- }
452
- $style.value = $_style;
453
- };
454
- const styles = reactive({});
455
- const validValue = (val) => {
456
- if (!isNaN(val * 1))
457
- return val;
458
- if (theme.colors[val])
459
- return theme.colors[val];
460
- return false;
461
- };
462
- const parseStyle = (rule) => {
463
- let style = prestyles[rule];
464
- if (style)
465
- return style;
466
- const rules = rule.split("-");
467
- const dirs = {
468
- l: "left",
469
- t: "top",
470
- r: "right",
471
- b: "bottom"
472
- };
473
- let [r1, r2, r3, r4] = rules;
474
- style = prestyles[r1];
475
- if (style) {
476
- let value = validValue(r2);
477
- if (value)
478
- return `${style.pro}: ${value}${r3 || style.unit || ""}`;
479
- value = validValue(r3);
480
- if (value)
481
- return `${style.pro}-${dirs[r2] || r2}: ${value}${r4 || style.unit || ""}`;
482
- }
483
- };
484
- const parseStyles = () => {
485
- if (!props.class)
486
- return;
487
- props.class.split(" ").forEach((rule) => {
488
- if (!styleMap.value.includes(rule)) {
489
- styleMap.value.push(rule);
490
- styles[rule] = parseStyle(rule);
491
- }
492
- });
493
- };
494
- const setStyle = () => {
495
- Object.keys(styles).forEach((key) => {
496
- $style.value.sheet.addRule(`.${key}`, styles[key]);
497
- });
498
- };
499
- onMounted(() => {
500
- initStyle();
501
- parseStyles();
502
- setStyle();
503
- });
504
- return (_ctx, _cache) => {
505
- return renderSlot(_ctx.$slots, "default");
506
- };
507
- }
508
- });
509
- export {
510
- _sfc_main as _
511
- };