@varlet/ui 2.4.1 → 2.4.3-alpha.1671108240429

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/es/input/Input.js CHANGED
@@ -2,7 +2,7 @@ import VarFormDetails from '../form-details';
2
2
  import VarIcon from '../icon';
3
3
  import { defineComponent, getCurrentInstance, ref, computed, nextTick, onMounted } from 'vue';
4
4
  import { props } from './props';
5
- import { isEmpty } from '@varlet/shared';
5
+ import { isEmpty, toNumber } from '@varlet/shared';
6
6
  import { useValidation, createNamespace, call } from '../utils/components';
7
7
  import { useForm } from '../form/provide';
8
8
  var {
@@ -235,20 +235,25 @@ export default defineComponent({
235
235
  };
236
236
 
237
237
  var handleInput = e => {
238
+ var target = e.target;
238
239
  var {
239
240
  value
240
- } = e.target;
241
- value = withTrim(value);
241
+ } = target;
242
+ value = withMaxlength(withTrim(value));
243
+ target.value = value;
242
244
  call(props['onUpdate:modelValue'], value);
243
245
  call(props.onInput, value, e);
244
246
  validateWithTrigger('onInput');
245
247
  };
246
248
 
247
249
  var handleChange = e => {
250
+ var target = e.target;
248
251
  var {
249
252
  value
250
- } = e.target;
251
- call(props.onChange, withTrim(value), e);
253
+ } = target;
254
+ value = withMaxlength(withTrim(value));
255
+ target.value = value;
256
+ call(props.onChange, value, e);
252
257
  validateWithTrigger('onChange');
253
258
  };
254
259
 
@@ -285,6 +290,8 @@ export default defineComponent({
285
290
 
286
291
  var withTrim = value => props.modelModifiers.trim ? value.trim() : value;
287
292
 
293
+ var withMaxlength = value => props.maxlength ? value.slice(0, toNumber(props.maxlength)) : value;
294
+
288
295
  var handleTouchstart = e => {
289
296
  var {
290
297
  disabled,
package/es/space/Space.js CHANGED
@@ -6,16 +6,11 @@ import { isArray } from '@varlet/shared';
6
6
 
7
7
 
8
8
  import { call, createNamespace } from '../utils/components';
9
+ import { spacePluginOptions } from './context';
9
10
  var {
10
11
  n,
11
12
  classes
12
13
  } = createNamespace('space');
13
- var internalSizes = {
14
- mini: [4, 4],
15
- small: [6, 6],
16
- normal: [8, 12],
17
- large: [12, 20]
18
- };
19
14
  export default defineComponent({
20
15
  name: 'VarSpace',
21
16
  props,
@@ -24,6 +19,11 @@ export default defineComponent({
24
19
  var {
25
20
  slots
26
21
  } = _ref;
22
+ var internalSizes = {};
23
+ Object.keys(spacePluginOptions).forEach(key => {
24
+ var size = spacePluginOptions[key];
25
+ internalSizes[key] = isArray(size) ? size.map(toPxNum) : [toPxNum(size), toPxNum(size)];
26
+ });
27
27
 
28
28
  var getSize = (size, isInternalSize) => {
29
29
  return isInternalSize ? internalSizes[size] : isArray(size) ? size.map(toPxNum) : [toPxNum(size), toPxNum(size)];
@@ -0,0 +1,9 @@
1
+ export var spacePluginOptions = {
2
+ mini: [4, 4],
3
+ small: [6, 6],
4
+ normal: [8, 12],
5
+ large: [12, 20]
6
+ };
7
+ export var mergeSpacePluginOptions = options => {
8
+ Object.assign(spacePluginOptions, options);
9
+ };
package/es/space/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import Space from './Space';
2
+ import { mergeSpacePluginOptions } from './context';
2
3
 
3
- Space.install = function (app) {
4
+ Space.install = function (app, spacePluginOptions) {
5
+ mergeSpacePluginOptions(spacePluginOptions);
4
6
  app.component(Space.name, Space);
5
7
  };
6
8