vdesign-ui 0.2.18 → 0.2.20

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.
@@ -313,27 +313,69 @@
313
313
  }
314
314
 
315
315
  &__scroll {
316
- &::before {
317
- content: '';
316
+ overflow-x: auto;
317
+ position: relative;
318
+ height: 100%;
319
+ &--left{
318
320
  position: absolute;
319
- z-index: 1;
320
- top: 0;
321
321
  left: 0;
322
- width: 20px;
323
- height: 48px;
324
- background-color: var(--bg-color-1);
322
+ top: 0;
323
+ height: 100%;
324
+ z-index: 10;
325
+ &::before {
326
+ content: '';
327
+ position: absolute;
328
+ z-index: 1;
329
+ top: 50%;
330
+ transform: translateY(-50%);
331
+ left: 0;
332
+ width: 20px;
333
+ height: 48px;
334
+ background-color: var(--bg-color-1);
335
+ }
336
+ &::after {
337
+ content: '';
338
+ box-shadow: 4px 0 6px rgba(0, 0, 0, 0.05);
339
+ position: absolute;
340
+ top: 50%;
341
+ transform: translateY(-50%);
342
+ left: 0;
343
+ width: 20px;
344
+ height: 30px;
345
+ background-color: transparent;
346
+ }
325
347
  }
326
- &::after {
327
- content: '';
328
- box-shadow: 4px 0 6px rgba(0, 0, 0, 0.05);
348
+ &--right{
329
349
  position: absolute;
330
- top: 50%;
331
- transform: translateY(-50%);
332
- left: 0;
333
- width: 20px;
334
- height: 30px;
335
- background-color: transparent;
336
- }
350
+ right: 0;
351
+ top: 0;
352
+ height: 100%;
353
+ z-index: 10;
354
+ &::before {
355
+ content: '';
356
+ position: absolute;
357
+ z-index: 1;
358
+ top: 50%;
359
+ transform: translateY(-50%);
360
+ right: 0;
361
+ width: 20px;
362
+ height: 48px;
363
+ background-color: var(--bg-color-1);
364
+ }
365
+ &::after {
366
+ content: '';
367
+ box-shadow: -4px 0 6px rgba(0, 0, 0, 0.05);
368
+ position: absolute;
369
+ top: 50%;
370
+ transform: translateY(-50%);
371
+ right: 0;
372
+ width: 20px;
373
+ height: 30px;
374
+ background-color: transparent;
375
+ }
376
+ }
377
+
378
+
337
379
  }
338
380
 
339
381
  &__menu {
@@ -344,22 +386,26 @@
344
386
 
345
387
  &--right {
346
388
  position: relative;
389
+ z-index: 11;
390
+ // margin-inline-start: -12px;
347
391
  display: flex;
348
392
  height: var(--icon-large);
349
393
  padding-inline-end: var(--spacing-tab-primary_icon-margin_right);
350
394
  color: var(--text-color-h1);
351
395
 
352
- &::before {
353
- content: '';
354
- position: absolute;
355
- margin-inline-start: -16px;
356
- width: 16px;
357
- height: 100%;
358
- background-image: linear-gradient(to left, var(--bg-color-1) 0%, rgba(255, 255, 255, 0) 100%);
359
- }
360
-
396
+ // &::before {
397
+ // content: '';
398
+ // position: absolute;
399
+ // margin-inline-start: -16px;
400
+ // width: 16px;
401
+ // height: 100%;
402
+ // background-image: linear-gradient(to left, var(--bg-color-1) 0%, rgba(255, 255, 255, 0) 100%);
403
+ // }
361
404
 
362
405
  }
406
+ &--margin{
407
+ margin-inline-start: -12px;
408
+ }
363
409
  &--btn {
364
410
  cursor: pointer;
365
411
  font-size: var(--icon-large)!important;
@@ -425,18 +471,18 @@
425
471
 
426
472
 
427
473
 
428
- [lang='ar'] {
429
- .@{tabs-prefix-cls}__scroll {
430
- &::before {
431
- right: 0;
432
- left: auto;
433
- }
434
- &::after {
435
- right: 0;
436
- left: auto;
437
- box-shadow: -4px 0 6px rgba(0, 0, 0, 0.05);
438
- }
439
- }
474
+ [lang|='ar'] , [dir='rtl']{
475
+ // .@{tabs-prefix-cls}__scroll {
476
+ // &::before {
477
+ // right: 0;
478
+ // left: auto;
479
+ // }
480
+ // &::after {
481
+ // right: 0;
482
+ // left: auto;
483
+ // box-shadow: -4px 0 6px rgba(0, 0, 0, 0.05);
484
+ // }
485
+ // }
440
486
  .@{tabs-prefix-cls}__menu--right::before {
441
487
  transform: scaleX(-1);
442
488
  }
@@ -450,10 +496,10 @@
450
496
  }
451
497
  }
452
498
 
453
- [theme='dark'][lang='ar']{
454
- .@{tabs-prefix-cls}__scroll {
455
- &::after {
456
- box-shadow: -4px 0 6px rgba(0, 0, 0, 0.35);
457
- }
458
- }
499
+ [theme='dark'][lang|='ar'], [dir='rtl']{
500
+ // .@{tabs-prefix-cls}__scroll {
501
+ // &::after {
502
+ // box-shadow: -4px 0 6px rgba(0, 0, 0, 0.35);
503
+ // }
504
+ // }
459
505
  }
@@ -1,97 +1,139 @@
1
- import Vue from 'vue';
2
- import ToastComponent from './index.vue';
3
- import { inBrowser } from '../utils/env';
1
+ import Vue from "vue";
2
+ import ToastComponent from "./index.vue";
3
+ import { inBrowser } from "../utils/env";
4
4
 
5
- let queueResult = []
6
- let allowMultiple = false
5
+ let queueResult = [];
6
+ let globalAllowMultiple = false;
7
+ let allTimer = null;
7
8
 
8
9
  function getType(value) {
9
- if (value !== value) return 'NaN';
10
+ if (value !== value) return "NaN";
10
11
  return Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
11
12
  }
12
13
 
14
+ function normalizeOptions(raw) {
15
+ let opts = {};
16
+
17
+ if (getType(raw) === 'string' || getType(raw) === 'number') {
18
+ opts.message = String(raw);
19
+ } else if (getType(raw) === 'object') {
20
+ opts = { ...raw };
21
+ } else {
22
+ opts.message = '';
23
+ }
24
+
25
+ // 默认值 & 全局/局部 allowMultiple
26
+ opts.duration = getType(opts.duration) === 'number' ? opts.duration : 1500;
27
+ opts.allowMultiple = 'allowMultiple' in opts ? !!opts.allowMultiple : globalAllowMultiple;
28
+
29
+ return opts;
30
+ }
31
+
13
32
  class VdToast extends Vue.extend(ToastComponent) {
14
33
  constructor(options) {
15
34
  super();
16
35
  this.vm = this.$mount();
17
- this.timer = null
18
- this.allowMultiple = allowMultiple
19
-
20
- // 判断传入的 options 类型,并进行赋值
21
- if (typeof options === 'string' || typeof options === 'number') {
22
- this.message = options;
23
- } else if (getType(options) === 'object') {
24
- this.message = options.message || '';
25
- this.duration = options.duration || 1500;
26
- Object.assign(this, options);
27
- }
36
+ this.timer = null;
37
+ // // 局部优先,回退全局
38
+ // const localAllowMultiple =
39
+ // getType(options) === "object" && "allowMultiple" in options
40
+ // ? options.allowMultiple
41
+ // : globalAllowMultiple;
42
+ // this.allowMultiple = localAllowMultiple;
43
+ // // 判断传入的 options 类型,并进行赋值
44
+ // if (getType(options) === "string" || getType(options) === "number") {
45
+ // this.message = options;
46
+ // } else if (getType(options) === "object") {
47
+ // this.message = options.message || "";
48
+ // this.duration = options.duration || 1500;
49
+ // Object.assign(this, options);
50
+ // }
51
+ Object.assign(this, options);
28
52
 
29
53
  this.init();
30
54
  }
31
-
32
55
  /**
33
56
  * 初始化方法
34
57
  */
35
58
  init() {
36
59
  if (inBrowser) {
37
- document.body.appendChild(this.vm.$el)
38
60
  if (!this.allowMultiple) {
39
- queueResult.forEach(toast => {
40
- toast.clear()
41
- })
61
+ if (allTimer) {
62
+ clearTimeout(allTimer);
63
+ }
64
+ queueResult.forEach((toast) => {
65
+ toast.clear();
66
+ });
42
67
  queueResult = [];
68
+ queueResult.push(this);
69
+ allTimer = setTimeout(() => {
70
+ document.body.appendChild(this.vm.$el);
71
+ }, 50);
72
+ } else {
73
+ queueResult.push(this);
74
+ document.body.appendChild(this.vm.$el);
43
75
  }
44
- this.start()
76
+ this.start();
45
77
  }
46
78
  }
47
-
48
79
  start() {
49
- clearTimeout(this.timer)
80
+ clearTimeout(this.timer);
50
81
  /**
51
82
  * 在挂载真实 DOM 树后显示过渡效果
52
83
  */
53
84
  setTimeout(() => {
54
- this.isShow = true
85
+ this.isShow = true;
55
86
  if (this.duration > 0) {
56
87
  this.end();
57
88
  }
58
- }, 0)
89
+ }, 0);
59
90
  }
60
-
61
91
  end() {
62
92
  /**
63
93
  * 关闭过渡效果之后移除真实 DOM 树节点
64
94
  */
65
95
  this.timer = setTimeout(() => {
66
- this.clear()
67
- }, this.duration)
96
+ this.clear();
97
+ }, this.duration);
68
98
  }
69
-
70
99
  clear() {
71
- this.isShow = false
100
+ this.isShow = false;
72
101
  if (inBrowser && this.vm.$el) {
73
102
  setTimeout(() => {
74
- this.vm.$el.parentNode && this.vm.$el.parentNode.removeChild(this.vm.$el);
75
- }, 500)
103
+ this.vm.$el.parentNode &&
104
+ this.vm.$el.parentNode.removeChild(this.vm.$el);
105
+ }, 500);
76
106
  }
77
107
  }
78
108
  }
79
109
 
80
- const Toast = (options) => {
81
- const NewOption = new VdToast(options)
82
- queueResult.push(NewOption)
83
- return NewOption
84
- }
110
+ // const Toast = (options) => {
111
+ // const localAllowMultiple =
112
+ // getType(options) === "object" && "allowMultiple" in options
113
+ // ? options.allowMultiple
114
+ // : globalAllowMultiple;
115
+
116
+ // if(getType(options) === "object") {
117
+ // options.allowMultiple = localAllowMultiple;
118
+ // }
119
+ // return new VdToast(options);
120
+ // };
121
+
122
+ const Toast = (rawOptions) => {
123
+ const opts = normalizeOptions(rawOptions);
124
+ return new VdToast(opts);
125
+ };
126
+
85
127
 
86
128
  Toast.clear = () => {
87
- queueResult.forEach(toast => {
88
- toast.clear()
89
- })
129
+ queueResult.forEach((toast) => {
130
+ toast.clear();
131
+ });
90
132
  queueResult = [];
91
- }
133
+ };
92
134
 
93
- Toast.allowMultiple = () => {
94
- allowMultiple = true
95
- }
135
+ Toast.allowMultiple = (value = true) => {
136
+ globalAllowMultiple = value;
137
+ };
96
138
 
97
- export default Toast
139
+ export default Toast;
@@ -18,7 +18,8 @@ export default {
18
18
  bgColor: '', // 背景颜色
19
19
  icon: '', // 图标
20
20
  duration: 1500, // 延迟时间
21
- position: 'middle' // default:middle, value: top, bottom
21
+ position: 'middle', // default:middle, value: top, bottom
22
+ allowMultiple: false
22
23
  }
23
24
  },
24
25
  computed: {
@@ -50,6 +50,7 @@
50
50
  }
51
51
 
52
52
  &__bottom {
53
+ top: initial;
53
54
  bottom: 50px;
54
55
  left: 50%;
55
56
  transform: translate(-50%, 0);
@@ -134,7 +134,7 @@
134
134
  }
135
135
  }
136
136
 
137
- [lang='ar'] {
137
+ [lang|='ar'] , [dir='rtl']{
138
138
  .@{upload-prefix-cls}{
139
139
  &__preview{
140
140
  &-delete{