@varlet/ui 1.27.7 → 1.27.9-alpha.1653036733481

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.
Files changed (77) hide show
  1. package/es/badge/Badge.js +1 -1
  2. package/es/card/Card.js +213 -12
  3. package/es/card/card.css +1 -1
  4. package/es/card/card.less +109 -7
  5. package/es/card/props.js +18 -0
  6. package/es/col/Col.js +6 -6
  7. package/es/col/col.css +1 -1
  8. package/es/col/col.less +27 -2
  9. package/es/index-bar/IndexBar.js +4 -4
  10. package/es/index-bar/props.js +1 -1
  11. package/es/loading/Loading.js +5 -14
  12. package/es/loading/loading.css +1 -1
  13. package/es/loading/loading.less +20 -0
  14. package/es/picker/Picker.js +10 -7
  15. package/es/picker/props.js +4 -0
  16. package/es/progress/Progress.js +14 -11
  17. package/es/progress/progress.css +1 -1
  18. package/es/progress/progress.less +3 -0
  19. package/es/progress/props.js +1 -1
  20. package/es/rate/Rate.js +4 -2
  21. package/es/rate/props.js +2 -4
  22. package/es/rate/rate.css +1 -1
  23. package/es/rate/rate.less +7 -0
  24. package/es/select/Select.js +3 -1
  25. package/es/slider/Slider.js +10 -9
  26. package/es/snackbar/style/index.js +1 -1
  27. package/es/snackbar/style/less.js +1 -1
  28. package/es/style.css +1 -1
  29. package/es/switch/Switch.js +22 -19
  30. package/es/switch/props.js +1 -2
  31. package/es/switch/switch.css +1 -1
  32. package/es/switch/switch.less +18 -4
  33. package/es/utils/elements.js +13 -0
  34. package/es/utils/jest.js +19 -0
  35. package/es/varlet.esm.js +338 -103
  36. package/highlight/attributes.json +24 -4
  37. package/highlight/tags.json +6 -1
  38. package/highlight/web-types.json +58 -5
  39. package/lib/badge/Badge.js +1 -1
  40. package/lib/card/Card.js +213 -8
  41. package/lib/card/card.css +1 -1
  42. package/lib/card/card.less +109 -7
  43. package/lib/card/props.js +18 -0
  44. package/lib/col/Col.js +6 -6
  45. package/lib/col/col.css +1 -1
  46. package/lib/col/col.less +27 -2
  47. package/lib/index-bar/IndexBar.js +3 -3
  48. package/lib/index-bar/props.js +1 -1
  49. package/lib/loading/Loading.js +6 -15
  50. package/lib/loading/loading.css +1 -1
  51. package/lib/loading/loading.less +20 -0
  52. package/lib/picker/Picker.js +10 -7
  53. package/lib/picker/props.js +4 -0
  54. package/lib/progress/Progress.js +15 -11
  55. package/lib/progress/progress.css +1 -1
  56. package/lib/progress/progress.less +3 -0
  57. package/lib/progress/props.js +1 -1
  58. package/lib/rate/Rate.js +3 -1
  59. package/lib/rate/props.js +2 -4
  60. package/lib/rate/rate.css +1 -1
  61. package/lib/rate/rate.less +7 -0
  62. package/lib/select/Select.js +3 -1
  63. package/lib/slider/Slider.js +9 -8
  64. package/lib/snackbar/style/index.js +1 -1
  65. package/lib/snackbar/style/less.js +1 -1
  66. package/lib/style.css +1 -1
  67. package/lib/switch/Switch.js +22 -19
  68. package/lib/switch/props.js +1 -2
  69. package/lib/switch/switch.css +1 -1
  70. package/lib/switch/switch.less +18 -4
  71. package/lib/utils/elements.js +17 -1
  72. package/lib/utils/jest.js +21 -0
  73. package/package.json +10 -9
  74. package/types/card.d.ts +2 -0
  75. package/types/indexBar.d.ts +1 -1
  76. package/types/picker.d.ts +2 -0
  77. package/umd/varlet.js +4 -4
@@ -8,7 +8,7 @@ var _vue = require("vue");
8
8
 
9
9
  var _components = require("../utils/components");
10
10
 
11
- var _shared = require("../utils/shared");
11
+ var _elements = require("../utils/elements");
12
12
 
13
13
  var _provide = require("../form/provide");
14
14
 
@@ -44,18 +44,18 @@ function render(_ctx, _cache) {
44
44
  style: (0, _vue.normalizeStyle)(_ctx.styleComputed.switch)
45
45
  }, [(0, _vue.createElementVNode)("div", {
46
46
  style: (0, _vue.normalizeStyle)(_ctx.styleComputed.track),
47
- class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track-active')], [_ctx.errorMessage, _ctx.n('track-error')]))
47
+ class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track--active')], [_ctx.errorMessage, _ctx.n('track--error')]))
48
48
  }, null, 6
49
49
  /* CLASS, STYLE */
50
50
  ), (0, _vue.withDirectives)(((0, _vue.openBlock)(), (0, _vue.createElementBlock)("div", {
51
- class: (0, _vue.normalizeClass)(_ctx.n('ripple')),
51
+ class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('ripple'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('ripple--active')])),
52
52
  style: (0, _vue.normalizeStyle)(_ctx.styleComputed.ripple)
53
53
  }, [(0, _vue.createElementVNode)("div", {
54
54
  style: (0, _vue.normalizeStyle)(_ctx.styleComputed.handle),
55
- class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle-active')], [_ctx.errorMessage, _ctx.n('handle-error')]))
55
+ class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle--active')], [_ctx.errorMessage, _ctx.n('handle--error')]))
56
56
  }, [_ctx.loading ? ((0, _vue.openBlock)(), (0, _vue.createBlock)(_component_var_loading, {
57
57
  key: 0,
58
- radius: _ctx.toNumber(_ctx.size) / 2 - 2
58
+ radius: _ctx.radius
59
59
  }, null, 8
60
60
  /* PROPS */
61
61
  , ["radius"])) : (0, _vue.createCommentVNode)("v-if", true)], 6
@@ -112,35 +112,38 @@ var _default = (0, _vue.defineComponent)({
112
112
  loadingColor,
113
113
  activeValue
114
114
  } = props;
115
- var sizeNum = (0, _shared.toNumber)(size);
116
- var switchWidth = sizeNum * 2;
117
- var switchHeight = sizeNum * 1.2;
118
115
  return {
119
116
  handle: {
120
- width: size + "px",
121
- height: size + "px",
117
+ width: (0, _elements.multiplySizeUnit)(size),
118
+ height: (0, _elements.multiplySizeUnit)(size),
122
119
  backgroundColor: modelValue === activeValue ? color || '' : closeColor || '',
123
120
  color: loadingColor && loadingColor
124
121
  },
125
122
  ripple: {
126
- left: modelValue === activeValue ? sizeNum / 2 + "px" : "-" + sizeNum / 2 + "px",
123
+ left: modelValue === activeValue ? (0, _elements.multiplySizeUnit)(size, 0.5) : "-" + (0, _elements.multiplySizeUnit)(size, 0.5),
127
124
  color: modelValue === activeValue ? color || '' : closeColor || '#999',
128
- width: sizeNum * 2 + "px",
129
- height: sizeNum * 2 + "px"
125
+ width: (0, _elements.multiplySizeUnit)(size, 2),
126
+ height: (0, _elements.multiplySizeUnit)(size, 2)
130
127
  },
131
128
  track: {
132
- height: switchHeight * 0.6 + "px",
133
- width: switchWidth - 2 + "px",
134
- borderRadius: switchWidth / 3 + "px",
129
+ height: (0, _elements.multiplySizeUnit)(size, 0.72),
130
+ width: (0, _elements.multiplySizeUnit)(size, 1.9),
131
+ borderRadius: (0, _elements.multiplySizeUnit)(size, 2 / 3),
135
132
  filter: modelValue === activeValue || errorMessage != null && errorMessage.value ? 'opacity(.6)' : 'brightness(.6)',
136
133
  backgroundColor: modelValue === activeValue ? color || '' : closeColor || ''
137
134
  },
138
135
  switch: {
139
- height: switchHeight + "px",
140
- width: switchWidth + "px"
136
+ height: (0, _elements.multiplySizeUnit)(size, 1.2),
137
+ width: (0, _elements.multiplySizeUnit)(size, 2)
141
138
  }
142
139
  };
143
140
  });
141
+ var radius = (0, _vue.computed)(() => {
142
+ var {
143
+ size = '5.333vw'
144
+ } = props;
145
+ return (0, _elements.multiplySizeUnit)(size, 0.4);
146
+ });
144
147
 
145
148
  var switchActive = event => {
146
149
  var {
@@ -177,7 +180,7 @@ var _default = (0, _vue.defineComponent)({
177
180
  n,
178
181
  classes,
179
182
  switchActive,
180
- toNumber: _shared.toNumber,
183
+ radius,
181
184
  styleComputed,
182
185
  errorMessage,
183
186
  formDisabled: form == null ? void 0 : form.disabled,
@@ -34,8 +34,7 @@ var props = {
34
34
  type: String
35
35
  },
36
36
  size: {
37
- type: [String, Number],
38
- default: 20
37
+ type: [String, Number]
39
38
  },
40
39
  rules: {
41
40
  type: Array
@@ -1 +1 @@
1
- :root { --switch-track-background: #fff; --switch-track-active-background: var(--color-primary); --switch-track-error-background: var(--color-danger); --switch-ripple-color: var(--color-primary); --switch-handle-background: #fff; --switch-handle-color: #fff; --switch-handle-active-background: var(--color-primary); --switch-handle-error-background: var(--color-danger);}.var-switch { display: inline-block;}.var-switch__block { position: relative; display: flex; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center;}.var-switch--disable { filter: opacity(0.6); cursor: not-allowed;}.var-switch__track { background: var(--switch-track-background); transition: background-color 0.25s; filter: opacity(0.6);}.var-switch__track-active { background-color: var(--switch-track-active-background);}.var-switch__track-error { background-color: var(--switch-track-error-background) !important;}.var-switch__ripple { position: absolute; display: flex; align-items: center; justify-content: center; color: var(--switch-ripple-color); border-radius: 50%; overflow: hidden; transition: 0.3s var(--cubic-bezier);}.var-switch__handle { border-radius: 50%; background-color: var(--switch-handle-background); display: flex; align-items: center; justify-content: center; color: var(--switch-handle-color); transition: background-color 0.25s;}.var-switch__handle-active { background-color: var(--switch-handle-active-background);}.var-switch__handle-error { background-color: var(--switch-handle-error-background) !important;}
1
+ :root { --switch-track-background: #fff; --switch-track-active-background: var(--color-primary); --switch-track-error-background: var(--color-danger); --switch-ripple-color: var(--color-primary); --switch-handle-background: #fff; --switch-handle-color: #fff; --switch-handle-active-background: var(--color-primary); --switch-handle-error-background: var(--color-danger);}.var-switch { display: inline-block;}.var-switch__block { position: relative; display: flex; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center; height: 24px; width: 40px;}.var-switch--disable { filter: opacity(0.6); cursor: not-allowed;}.var-switch__track { background: var(--switch-track-background); transition: background-color 0.25s; filter: opacity(0.6); height: 14.4px; width: 38px; border-radius: calc(20px * 2 / 3);}.var-switch__track--active { background-color: var(--switch-track-active-background);}.var-switch__track--error { background-color: var(--switch-track-error-background) !important;}.var-switch__ripple { position: absolute; display: flex; align-items: center; justify-content: center; color: var(--switch-ripple-color); border-radius: 50%; overflow: hidden; transition: 0.3s var(--cubic-bezier); width: 40px; height: 40px; left: -10px;}.var-switch__ripple--active { left: 10px;}.var-switch__handle { border-radius: 50%; background-color: var(--switch-handle-background); display: flex; align-items: center; justify-content: center; color: var(--switch-handle-color); transition: background-color 0.25s; width: 20px; height: 20px;}.var-switch__handle--active { background-color: var(--switch-handle-active-background);}.var-switch__handle--error { background-color: var(--switch-handle-error-background) !important;}
@@ -28,6 +28,8 @@
28
28
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
29
29
  align-items: center;
30
30
  justify-content: center;
31
+ height: 24px;
32
+ width: 40px;
31
33
  }
32
34
 
33
35
  &--disable {
@@ -39,12 +41,15 @@
39
41
  background: var(--switch-track-background);
40
42
  transition: background-color 0.25s;
41
43
  filter: opacity(0.6);
44
+ height: 14.4px;
45
+ width: 38px;
46
+ border-radius: calc(20px * 2 / 3);
42
47
 
43
- &-active {
48
+ &--active {
44
49
  background-color: var(--switch-track-active-background);
45
50
  }
46
51
 
47
- &-error {
52
+ &--error {
48
53
  background-color: var(--switch-track-error-background) !important;
49
54
  }
50
55
  }
@@ -58,6 +63,13 @@
58
63
  border-radius: 50%;
59
64
  overflow: hidden;
60
65
  transition: 0.3s var(--cubic-bezier);
66
+ width: 40px;
67
+ height: 40px;
68
+ left: -10px;
69
+
70
+ &--active {
71
+ left: 10px;
72
+ }
61
73
  }
62
74
 
63
75
  &__handle {
@@ -68,12 +80,14 @@
68
80
  justify-content: center;
69
81
  color: var(--switch-handle-color);
70
82
  transition: background-color 0.25s;
83
+ width: 20px;
84
+ height: 20px;
71
85
 
72
- &-active {
86
+ &--active {
73
87
  background-color: var(--switch-handle-active-background);
74
88
  }
75
89
 
76
- &-error {
90
+ &--error {
77
91
  background-color: var(--switch-handle-error-background) !important;
78
92
  }
79
93
  }
@@ -12,7 +12,7 @@ exports.getScrollTop = getScrollTop;
12
12
  exports.getTop = getTop;
13
13
  exports.getTranslate = getTranslate;
14
14
  exports.inViewport = inViewport;
15
- exports.isVw = exports.isVh = exports.isRem = exports.isPx = exports.isPercent = void 0;
15
+ exports.multiplySizeUnit = exports.isVw = exports.isVh = exports.isRem = exports.isPx = exports.isPercent = void 0;
16
16
  exports.nextTickFrame = nextTickFrame;
17
17
  exports.requestAnimationFrame = requestAnimationFrame;
18
18
  exports.scrollTo = scrollTo;
@@ -195,6 +195,22 @@ var toSizeUnit = value => {
195
195
 
196
196
  exports.toSizeUnit = toSizeUnit;
197
197
 
198
+ var multiplySizeUnit = function (value, quantity) {
199
+ if (quantity === void 0) {
200
+ quantity = 1;
201
+ }
202
+
203
+ if (value == null) {
204
+ return undefined;
205
+ }
206
+
207
+ var legalSize = toSizeUnit(value);
208
+ var unit = legalSize.match(/(vh|%|rem|px|vw)$/)[0];
209
+ return "" + parseFloat(legalSize) * quantity + unit;
210
+ };
211
+
212
+ exports.multiplySizeUnit = multiplySizeUnit;
213
+
198
214
  function requestAnimationFrame(fn) {
199
215
  return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
200
216
  }
package/lib/utils/jest.js CHANGED
@@ -7,6 +7,7 @@ exports.mockConsole = mockConsole;
7
7
  exports.mockDoubleRaf = mockDoubleRaf;
8
8
  exports.mockFileReader = mockFileReader;
9
9
  exports.mockImageNaturalSize = mockImageNaturalSize;
10
+ exports.mockIndexBarOwnTop = mockIndexBarOwnTop;
10
11
  exports.mockOffset = mockOffset;
11
12
  exports.mockScrollTo = mockScrollTo;
12
13
  exports.mockStubs = mockStubs;
@@ -281,4 +282,24 @@ function mockScrollTo(Element) {
281
282
  this.scrollTop = y;
282
283
  }
283
284
  };
285
+ }
286
+
287
+ function mockIndexBarOwnTop() {
288
+ var originForEach = Array.prototype.forEach; // eslint-disable-next-line no-extend-native
289
+
290
+ Array.prototype.forEach = function (fn, thisArg) {
291
+ var changedArr = this.map((value, index) => {
292
+ if (value.ownTop && !value.ownTop.value) value.ownTop.value = (index + 1) * 50;
293
+ return value;
294
+ });
295
+ originForEach.call(changedArr, fn, thisArg);
296
+ };
297
+
298
+ return {
299
+ mockRestore() {
300
+ // eslint-disable-next-line no-extend-native
301
+ Array.prototype.forEach = originForEach;
302
+ }
303
+
304
+ };
284
305
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "1.27.7",
3
+ "version": "1.27.9-alpha.1653036733481",
4
4
  "description": "A material like components library",
5
5
  "module": "es/index.js",
6
6
  "main": "lib/index.js",
@@ -39,21 +39,22 @@
39
39
  },
40
40
  "gitHead": "ee9c3866bedad96c86365b0f9888a3a6bb781b1f",
41
41
  "dependencies": {
42
- "@varlet/icons": "1.27.7",
42
+ "@varlet/icons": "1.27.9-alpha.1653036733481",
43
43
  "dayjs": "^1.10.4",
44
44
  "decimal.js": "^10.2.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@varlet/cli": "1.27.7",
48
- "@varlet/touch-emulator": "1.27.7",
49
- "@vue/test-utils": "2.0.0-rc.6",
47
+ "@varlet/cli": "1.27.9-alpha.1653036733481",
48
+ "@varlet/touch-emulator": "1.27.9-alpha.1653036733481",
50
49
  "@vue/runtime-core": "3.2.25",
51
- "typescript": "^4.4.4",
52
- "lodash-es": "^4.17.21",
50
+ "@vue/test-utils": "2.0.0-rc.6",
53
51
  "clipboard": "^2.0.6",
52
+ "live-server": "^1.2.1",
53
+ "lodash-es": "^4.17.21",
54
+ "postcss-px-to-viewport": "^1.1.1",
55
+ "typescript": "^4.4.4",
54
56
  "vue": "3.2.25",
55
- "vue-router": "4.0.12",
56
- "live-server": "^1.2.1"
57
+ "vue-router": "4.0.12"
57
58
  },
58
59
  "browserslist": [
59
60
  "Chrome >= 51",
package/types/card.d.ts CHANGED
@@ -4,6 +4,8 @@ export interface CardProps {
4
4
  src?: string
5
5
  fit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down'
6
6
  height?: string | number
7
+ width?: string | number
8
+ direction?: 'row' | 'column'
7
9
  alt?: string
8
10
  title?: string
9
11
  subtitle?: string
@@ -2,7 +2,7 @@ import { VarComponent } from './varComponent'
2
2
 
3
3
  export interface IndexBarProps {
4
4
  sticky?: boolean
5
- stickyOffsetTop?: number
5
+ stickyOffsetTop?: number | string
6
6
  hideList?: boolean
7
7
  cssMode?: boolean
8
8
  zIndex?: number | string
package/types/picker.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface PickerProps {
20
20
  toolbar?: boolean
21
21
  cascade?: boolean
22
22
  cascadeInitialIndexes: number[]
23
+ textFormatter?: (text: any, columnIndex: number) => any
23
24
  optionHeight?: string | number
24
25
  optionCount?: string | number
25
26
  confirmButtonText?: string
@@ -60,6 +61,7 @@ export interface PickerOptions {
60
61
  cancelButtonText?: string
61
62
  confirmButtonTextColor?: string
62
63
  cancelButtonTextColor?: string
64
+ textFormatter?: (text: any, columnIndex: number) => any
63
65
  onOpen?: () => void
64
66
  onOpened?: () => void
65
67
  onClose?: () => void