@kizmann/nano-ui 0.8.30 → 0.8.32

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/nano-ui",
3
- "version": "0.8.30",
3
+ "version": "0.8.32",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -294,18 +294,18 @@ export default {
294
294
  }
295
295
 
296
296
  let render = () => Arr.each(setup.content, (value, key) => {
297
- return this.ctor('renderSetup')(value, key)
297
+ return this.ctor('renderSetup')(value, key);
298
298
  });
299
299
 
300
300
  if ( Any.isFunction(setup.content) ) {
301
- render = setup.content.apply(this.scope);
301
+ render = () => setup.content.apply(this.scope);
302
302
  }
303
303
 
304
304
  if ( Any.isString(setup.content) ) {
305
- render = setup.content;
305
+ render = () => setup.content;
306
306
  }
307
307
 
308
- return h(component, props, render);
308
+ return h(component, props, { default: render });
309
309
  },
310
310
 
311
311
  render()
@@ -118,7 +118,7 @@ export default {
118
118
  modelValue(value)
119
119
  {
120
120
  if ( value !== this.tempValue ) {
121
- this.tempValue = Num.float(value);
121
+ this.tempValue = this.getValue(value);
122
122
  }
123
123
  }
124
124
 
@@ -127,7 +127,7 @@ export default {
127
127
  data()
128
128
  {
129
129
  return {
130
- focus: false, tempValue: Num.float(this.modelValue),
130
+ focus: false, tempValue: this.getValue(),
131
131
  }
132
132
  },
133
133
 
@@ -135,12 +135,26 @@ export default {
135
135
 
136
136
  clear()
137
137
  {
138
- this.$emit('update:modelValue', this.clearValue);
138
+ this.$emit('update:modelValue', this.tempValue = this.clearValue);
139
+ },
140
+
141
+ getValue(value = null)
142
+ {
143
+ if ( Any.isNull(value) ) {
144
+ value = this.modelValue;
145
+ }
146
+
147
+ if ( Any.isEmpty(value) ) {
148
+ return this.min;
149
+ }
150
+
151
+ return Num.float(value);
139
152
  },
140
153
 
141
154
  getDisplayValue()
142
155
  {
143
- if ( Any.isNull(this.modelValue) ) {
156
+
157
+ if ( Any.isEmpty(this.modelValue) ) {
144
158
  return null;
145
159
  }
146
160
 
@@ -251,6 +265,10 @@ export default {
251
265
  {
252
266
  let value = event.target.value;
253
267
 
268
+ if ( value.match(/^[0-9]+((.|,)[0-9]+)?$/) ) {
269
+ value = this.format.replace(':count', value);
270
+ }
271
+
254
272
  let format = this.format.replace(':count',
255
273
  `([0-9\\,\\.\\-\\s]+)`);
256
274
 
@@ -258,7 +276,7 @@ export default {
258
276
 
259
277
  let match = value.match(regex);
260
278
 
261
- if ( ! match ) {
279
+ if ( !match ) {
262
280
  return event.target.value = this.getDisplayValue();
263
281
  }
264
282
 
@@ -289,12 +307,12 @@ export default {
289
307
  this.tempValue <= this.min;
290
308
 
291
309
  let props = {
292
- type: 'input-number',
293
- size: this.size,
294
- icon: 'fa fa-minus',
295
- square: true,
296
- disabled: disabled,
297
- onMousedown: this.onPrevDown,
310
+ type: 'input-number',
311
+ size: this.size,
312
+ icon: 'fa fa-minus',
313
+ square: true,
314
+ disabled: disabled,
315
+ onMousedown: this.onPrevDown,
298
316
  };
299
317
 
300
318
  return (<NButton {...props} />);
@@ -306,12 +324,12 @@ export default {
306
324
  this.tempValue >= this.max;
307
325
 
308
326
  let props = {
309
- type: 'input-number',
310
- size: this.size,
311
- icon: 'fa fa-plus',
312
- square: true,
313
- disabled: disabled,
314
- onMousedown: this.onNextDown,
327
+ type: 'input-number',
328
+ size: this.size,
329
+ icon: 'fa fa-plus',
330
+ square: true,
331
+ disabled: disabled,
332
+ onMousedown: this.onNextDown,
315
333
  };
316
334
 
317
335
  return (<NButton {...props} />);
@@ -323,29 +341,26 @@ export default {
323
341
  ['class', 'style']);
324
342
 
325
343
  Obj.assign(props, {
326
- disabled: this.disabled,
327
- placeholder: this.placeholder,
328
- onKeydown: this.onKeydown,
329
- onFocus: this.onFocus,
330
- onBlur: this.onBlur,
344
+ value: this.getDisplayValue(),
345
+ disabled: this.disabled,
346
+ placeholder: this.placeholder,
347
+ onKeydown: this.onKeydown,
348
+ onFocus: this.onFocus,
349
+ onBlur: this.onBlur,
331
350
  });
332
351
 
333
- if ( this.modelValue !== null ) {
334
- props.value = this.getDisplayValue();
335
- }
336
-
337
352
  return h('input', props);
338
353
  },
339
354
 
340
355
  renderClear()
341
356
  {
342
- if ( ! this.clearable || Any.isEmpty(this.tempValue) ) {
357
+ if ( !this.clearable || Any.isEmpty(this.tempValue) ) {
343
358
  return null;
344
359
  }
345
360
 
346
361
  let props = {};
347
362
 
348
- if ( ! this.disabled ) {
363
+ if ( !this.disabled ) {
349
364
  props.onMousedown = this.clear;
350
365
  }
351
366
 
@@ -382,10 +397,10 @@ export default {
382
397
 
383
398
  return (
384
399
  <div class={classList}>
385
- { this.ctor('renderPrev')() }
386
- { this.ctor('renderInput')() }
387
- { this.ctor('renderClear')() }
388
- { this.ctor('renderNext')() }
400
+ {this.ctor('renderPrev')()}
401
+ {this.ctor('renderInput')()}
402
+ {this.ctor('renderClear')()}
403
+ {this.ctor('renderNext')()}
389
404
  </div>
390
405
  );
391
406
  }
@@ -90,11 +90,12 @@ export default {
90
90
  data()
91
91
  {
92
92
  return {
93
- tempPage: this.page,
94
- tempLimit: this.limit,
95
- }
93
+ tempPage: this.page, tempLimit: this.limit,
94
+ };
96
95
  },
97
96
 
97
+
98
+
98
99
  methods: {
99
100
 
100
101
  forcePage(page)
@@ -142,12 +143,12 @@ export default {
142
143
 
143
144
  onLimitInput(value)
144
145
  {
145
- this.$emit('update:limit', this.tempLimit = value);
146
-
147
- if ( this.pages < this.tempPage ) {
146
+ if ( this.tempLimit !== value ) {
148
147
  this.$emit('update:page', this.tempPage = 1);
149
148
  }
150
149
 
150
+ this.$emit('update:limit', this.tempLimit = value);
151
+
151
152
  this.updatePaginate();
152
153
  },
153
154