@varlet/ui 2.8.3 → 2.8.4-alpha.1677149602351

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 +1 @@
1
- :root { --avatar-group-offset: -10px;}.var-avatar-group { display: inline-flex; flex-wrap: wrap;}.var-avatar-group--row { margin-left: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--row > * { margin-left: var(--avatar-group-offset);}.var-avatar-group--column { flex-direction: column; margin-top: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--column > * { margin-top: var(--avatar-group-offset);}
1
+ :root { --avatar-group-offset: -10px;}.var-avatar-group { display: inline-flex; flex-wrap: wrap;}.var-avatar-group--row { margin-left: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--row .var-avatar { margin-left: var(--avatar-group-offset);}.var-avatar-group--column { flex-direction: column; margin-top: calc(var(--avatar-group-offset) * -1);}.var-avatar-group--column .var-avatar { margin-top: var(--avatar-group-offset);}
@@ -1 +1 @@
1
- .var-button-group { display: inline-flex; border-radius: var(--button-border-radius); max-width: 100%; overflow: auto;}.var-button-group > .var-button:active { box-shadow: none;}.var-button-group--horizontal > .var-button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0;}.var-button-group--horizontal > .var-button:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0;}.var-button-group--horizontal > .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--horizontal.var-button-group--mode-text > .var-button { border-right: thin solid currentColor;}.var-button-group--horizontal.var-button-group--mode-text > .var-button:last-child { border: none;}.var-button-group--horizontal.var-button-group--mode-outline > .var-button:not(:first-child) { border-left: none;}.var-button-group--vertical { flex-direction: column;}.var-button-group--vertical > .var-button:first-child { border-bottom-left-radius: 0; border-bottom-right-radius: 0;}.var-button-group--vertical > .var-button:last-child { border-top-left-radius: 0; border-top-right-radius: 0;}.var-button-group--vertical > .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--vertical.var-button-group--mode-text > .var-button { border-bottom: thin solid currentColor;}.var-button-group--vertical.var-button-group--mode-text > .var-button:last-child { border: none;}.var-button-group--vertical.var-button-group--mode-outline > .var-button:not(:first-child) { border-top: none;}
1
+ .var-button-group { display: inline-flex; border-radius: var(--button-border-radius); max-width: 100%; overflow: auto;}.var-button-group .var-button:active { box-shadow: none;}.var-button-group--horizontal .var-button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0;}.var-button-group--horizontal .var-button:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0;}.var-button-group--horizontal .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--horizontal.var-button-group--mode-text .var-button { border-right: thin solid currentColor;}.var-button-group--horizontal.var-button-group--mode-text .var-button:last-child { border: none;}.var-button-group--horizontal.var-button-group--mode-outline .var-button:not(:first-child) { border-left: none;}.var-button-group--vertical { flex-direction: column;}.var-button-group--vertical .var-button:first-child { border-bottom-left-radius: 0; border-bottom-right-radius: 0;}.var-button-group--vertical .var-button:last-child { border-top-left-radius: 0; border-top-right-radius: 0;}.var-button-group--vertical .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--vertical.var-button-group--mode-text .var-button { border-bottom: thin solid currentColor;}.var-button-group--vertical.var-button-group--mode-text .var-button:last-child { border: none;}.var-button-group--vertical.var-button-group--mode-outline .var-button:not(:first-child) { border-top: none;}
@@ -0,0 +1,154 @@
1
+ import { isFunction, camelize } from '@varlet/shared';
2
+
3
+ function shouldDisabled(arg) {
4
+ if (!arg) {
5
+ return false;
6
+ }
7
+
8
+ var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
9
+
10
+ if (arg === 'desktop' && isMobile) {
11
+ return true;
12
+ }
13
+
14
+ if (arg === 'mobile' && !isMobile) {
15
+ return true;
16
+ }
17
+
18
+ return false;
19
+ }
20
+
21
+ function getStyle(element) {
22
+ var style = element.getAttribute('style');
23
+ if (!style) return {};
24
+ return style.split(';').filter(Boolean).reduce((style, item) => {
25
+ var [key, value] = item.split(':').map(item => item.trim());
26
+ style[camelize(key)] = value;
27
+ return style;
28
+ }, {});
29
+ }
30
+
31
+ function updateRawStyle(element) {
32
+ var {
33
+ value
34
+ } = element._hover;
35
+ var style = getStyle(element);
36
+ Object.keys(value).forEach(key => {
37
+ var camelizedKey = camelize(key);
38
+ var styleValue = value[camelizedKey];
39
+
40
+ if (styleValue != null && style[camelizedKey]) {
41
+ element._hover.rawStyle[camelizedKey] = style[camelizedKey];
42
+ }
43
+ });
44
+ }
45
+
46
+ function updateStyle(element, styleValue) {
47
+ Object.keys(styleValue).forEach(key => {
48
+ var value = styleValue[key];
49
+
50
+ if (value != null) {
51
+ element.style[key] = value;
52
+ }
53
+ });
54
+ }
55
+
56
+ function clearStyle(element) {
57
+ Object.keys(element._hover.value).forEach(key => {
58
+ element.style[key] = '';
59
+ });
60
+ }
61
+
62
+ function restoreStyle(element) {
63
+ clearStyle(element);
64
+ updateStyle(element, element._hover.rawStyle);
65
+ element._hover.rawStyle = {};
66
+ }
67
+
68
+ function createHover() {
69
+ var {
70
+ value
71
+ } = this._hover;
72
+ this._hover.hovering = true;
73
+
74
+ if (isFunction(value)) {
75
+ value(this._hover.hovering);
76
+ return;
77
+ }
78
+
79
+ updateStyle(this, value);
80
+ }
81
+
82
+ function removeHover() {
83
+ this._hover.hovering = false;
84
+
85
+ if (isFunction(this._hover.value)) {
86
+ this._hover.value(this._hover.hovering);
87
+
88
+ return;
89
+ }
90
+
91
+ restoreStyle(this);
92
+ }
93
+
94
+ function mounted(element, binding) {
95
+ var _element$_hover$hover, _element$_hover;
96
+
97
+ var {
98
+ arg,
99
+ value
100
+ } = binding;
101
+
102
+ if (shouldDisabled(arg)) {
103
+ return;
104
+ }
105
+
106
+ element._hover = {
107
+ value,
108
+ hovering: (_element$_hover$hover = (_element$_hover = element._hover) == null ? void 0 : _element$_hover.hovering) != null ? _element$_hover$hover : false,
109
+ rawStyle: {}
110
+ };
111
+ updateRawStyle(element);
112
+ element.addEventListener('mouseenter', createHover);
113
+ element.addEventListener('mouseleave', removeHover);
114
+ }
115
+
116
+ function unmounted(element, binding) {
117
+ if (shouldDisabled(binding.arg)) {
118
+ return;
119
+ }
120
+
121
+ restoreStyle(element);
122
+ element.removeEventListener('mouseenter', createHover);
123
+ element.removeEventListener('mouseleave', removeHover);
124
+ }
125
+
126
+ function beforeUpdate(element, binding) {
127
+ unmounted(element, binding);
128
+ }
129
+
130
+ function shouldUpdateStyle(element, binding) {
131
+ return !isFunction(binding.value) && element._hover.hovering;
132
+ }
133
+
134
+ function updated(element, binding) {
135
+ mounted(element, binding);
136
+
137
+ if (shouldUpdateStyle(element, binding)) {
138
+ updateStyle(element, binding.value);
139
+ }
140
+ }
141
+
142
+ var Hover = {
143
+ mounted,
144
+ unmounted,
145
+ beforeUpdate,
146
+ updated,
147
+
148
+ install(app) {
149
+ app.directive('hover', this);
150
+ }
151
+
152
+ };
153
+ export var _HoverComponent = Hover;
154
+ export default Hover;
File without changes
@@ -27,6 +27,7 @@ import Divider from './divider/index.mjs'
27
27
  import Ellipsis from './ellipsis/index.mjs'
28
28
  import Form from './form/index.mjs'
29
29
  import FormDetails from './form-details/index.mjs'
30
+ import Hover from './hover/index.mjs'
30
31
  import Icon from './icon/index.mjs'
31
32
  import Image from './image/index.mjs'
32
33
  import ImagePreview from './image-preview/index.mjs'
@@ -105,6 +106,7 @@ export * from './divider/index.mjs'
105
106
  export * from './ellipsis/index.mjs'
106
107
  export * from './form/index.mjs'
107
108
  export * from './form-details/index.mjs'
109
+ export * from './hover/index.mjs'
108
110
  export * from './icon/index.mjs'
109
111
  export * from './image/index.mjs'
110
112
  export * from './image-preview/index.mjs'
@@ -183,6 +185,7 @@ import './divider/style/index.mjs'
183
185
  import './ellipsis/style/index.mjs'
184
186
  import './form/style/index.mjs'
185
187
  import './form-details/style/index.mjs'
188
+ import './hover/style/index.mjs'
186
189
  import './icon/style/index.mjs'
187
190
  import './image/style/index.mjs'
188
191
  import './image-preview/style/index.mjs'
@@ -232,7 +235,7 @@ import './time-picker/style/index.mjs'
232
235
  import './tooltip/style/index.mjs'
233
236
  import './uploader/style/index.mjs'
234
237
 
235
- const version = '2.8.3'
238
+ const version = '2.8.4-alpha.1677149602351'
236
239
 
237
240
  function install(app) {
238
241
  ActionSheet.install && app.use(ActionSheet)
@@ -264,6 +267,7 @@ function install(app) {
264
267
  Ellipsis.install && app.use(Ellipsis)
265
268
  Form.install && app.use(Form)
266
269
  FormDetails.install && app.use(FormDetails)
270
+ Hover.install && app.use(Hover)
267
271
  Icon.install && app.use(Icon)
268
272
  Image.install && app.use(Image)
269
273
  ImagePreview.install && app.use(ImagePreview)
@@ -346,6 +350,7 @@ export {
346
350
  Ellipsis,
347
351
  Form,
348
352
  FormDetails,
353
+ Hover,
349
354
  Icon,
350
355
  Image,
351
356
  ImagePreview,
@@ -428,6 +433,7 @@ export default {
428
433
  Ellipsis,
429
434
  Form,
430
435
  FormDetails,
436
+ Hover,
431
437
  Icon,
432
438
  Image,
433
439
  ImagePreview,
package/es/index.mjs CHANGED
@@ -27,6 +27,7 @@ import Divider from './divider/index.mjs'
27
27
  import Ellipsis from './ellipsis/index.mjs'
28
28
  import Form from './form/index.mjs'
29
29
  import FormDetails from './form-details/index.mjs'
30
+ import Hover from './hover/index.mjs'
30
31
  import Icon from './icon/index.mjs'
31
32
  import Image from './image/index.mjs'
32
33
  import ImagePreview from './image-preview/index.mjs'
@@ -105,6 +106,7 @@ export * from './divider/index.mjs'
105
106
  export * from './ellipsis/index.mjs'
106
107
  export * from './form/index.mjs'
107
108
  export * from './form-details/index.mjs'
109
+ export * from './hover/index.mjs'
108
110
  export * from './icon/index.mjs'
109
111
  export * from './image/index.mjs'
110
112
  export * from './image-preview/index.mjs'
@@ -154,7 +156,7 @@ export * from './time-picker/index.mjs'
154
156
  export * from './tooltip/index.mjs'
155
157
  export * from './uploader/index.mjs'
156
158
 
157
- const version = '2.8.3'
159
+ const version = '2.8.4-alpha.1677149602351'
158
160
 
159
161
  function install(app) {
160
162
  ActionSheet.install && app.use(ActionSheet)
@@ -186,6 +188,7 @@ function install(app) {
186
188
  Ellipsis.install && app.use(Ellipsis)
187
189
  Form.install && app.use(Form)
188
190
  FormDetails.install && app.use(FormDetails)
191
+ Hover.install && app.use(Hover)
189
192
  Icon.install && app.use(Icon)
190
193
  Image.install && app.use(Image)
191
194
  ImagePreview.install && app.use(ImagePreview)
@@ -268,6 +271,7 @@ export {
268
271
  Ellipsis,
269
272
  Form,
270
273
  FormDetails,
274
+ Hover,
271
275
  Icon,
272
276
  Image,
273
277
  ImagePreview,
@@ -350,6 +354,7 @@ export default {
350
354
  Ellipsis,
351
355
  Form,
352
356
  FormDetails,
357
+ Hover,
353
358
  Icon,
354
359
  Image,
355
360
  ImagePreview,
@@ -169,6 +169,13 @@ var __sfc__ = defineComponent({
169
169
  var id = ref("var-input-" + getCurrentInstance().uid);
170
170
  var el = ref(null);
171
171
  var isFocus = ref(false);
172
+ var type = computed(() => {
173
+ if (props.type === 'number') {
174
+ return 'text';
175
+ }
176
+
177
+ return props.type;
178
+ });
172
179
  var maxlengthText = computed(() => {
173
180
  var {
174
181
  maxlength,
@@ -240,6 +247,11 @@ var __sfc__ = defineComponent({
240
247
  var {
241
248
  value
242
249
  } = target;
250
+
251
+ if (props.type === 'number') {
252
+ value = formatNumber(value);
253
+ }
254
+
243
255
  value = withMaxlength(withTrim(value));
244
256
  target.value = value;
245
257
  call(props['onUpdate:modelValue'], value);
@@ -252,6 +264,12 @@ var __sfc__ = defineComponent({
252
264
  var {
253
265
  value
254
266
  } = target;
267
+
268
+ if (props.type === 'number') {
269
+ value = toNumber(value).toString();
270
+ call(props['onUpdate:modelValue'], value);
271
+ }
272
+
255
273
  value = withMaxlength(withTrim(value));
256
274
  target.value = value;
257
275
  call(props.onChange, value, e);
@@ -289,6 +307,21 @@ var __sfc__ = defineComponent({
289
307
  validateWithTrigger('onClick');
290
308
  };
291
309
 
310
+ var formatNumber = value => {
311
+ var minusIndex = value.indexOf('-');
312
+ var dotIndex = value.indexOf('.');
313
+
314
+ if (minusIndex > -1) {
315
+ value = minusIndex === 0 ? '-' + value.replace(/-/g, '') : value.replace(/-/g, '');
316
+ }
317
+
318
+ if (dotIndex > -1) {
319
+ value = value.slice(0, dotIndex + 1) + value.slice(dotIndex).replace(/\./g, '');
320
+ }
321
+
322
+ return value.replace(/[^-0-9.]/g, '');
323
+ };
324
+
292
325
  var withTrim = value => props.modelModifiers.trim ? value.trim() : value;
293
326
 
294
327
  var withMaxlength = value => props.maxlength ? value.slice(0, toNumber(props.maxlength)) : value;
@@ -345,6 +378,7 @@ var __sfc__ = defineComponent({
345
378
  id,
346
379
  isFocus,
347
380
  errorMessage,
381
+ type,
348
382
  maxlengthText,
349
383
  formDisabled: form == null ? void 0 : form.disabled,
350
384
  formReadonly: form == null ? void 0 : form.readonly,
@@ -1 +1 @@
1
- :root { --space-size-mini-y: 4px; --space-size-mini-x: 4px; --space-size-small-y: 6px; --space-size-small-x: 6px; --space-size-normal-y: 8px; --space-size-normal-x: 12px; --space-size-large-y: 12px; --space-size-large-x: 20px;}.var-space { display: flex;}.var-space--line { display: inline-flex;}
1
+ :root { --space-size-mini-y: 4px; --space-size-mini-x: 4px; --space-size-small-y: 6px; --space-size-small-x: 6px; --space-size-normal-y: 8px; --space-size-normal-x: 12px; --space-size-large-y: 12px; --space-size-large-x: 20px;}.var-space { display: flex;}.var-space--inline { display: inline-flex;}