aloha-vue 1.0.174 → 1.0.176

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.
@@ -7,7 +7,9 @@ export default {
7
7
  },
8
8
  data() {
9
9
  return {
10
- model: undefined,
10
+ model: {
11
+ alohadate: "2023-01-10",
12
+ },
11
13
  selectData: [
12
14
  {
13
15
  label: "Aloha 1",
@@ -77,6 +79,13 @@ export default {
77
79
  step: 0.01,
78
80
  required: true,
79
81
  },
82
+ {
83
+ type: "date",
84
+ label: "Aloha date",
85
+ id: "alohadate",
86
+ classColumn: "a_column_8",
87
+ required: true,
88
+ },
80
89
  {
81
90
  type: "file",
82
91
  label: "Aloha File",
@@ -27,11 +27,11 @@ export default {
27
27
  },
28
28
  {
29
29
  label: "Alohafreidsfdsfdsfsdfdsfdsfdsfsd",
30
- id: "aloha1",
31
- keyLabel: "aloha",
32
- sortId: "aloha",
30
+ id: "number",
31
+ keyLabel: "number",
32
+ sortId: "number",
33
33
  grow: 0,
34
- footerKeyLabel: "aloha",
34
+ footerKeyLabel: "number",
35
35
  class: "a_justify_content_end",
36
36
  },
37
37
  {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.174",
4
+ "version": "1.0.176",
5
5
  "author": "Ilia Brykin",
6
6
  "scripts": {
7
7
  "build-icons": "node scriptsNode/iconsSvgToJs.js bootstrap3 && node scriptsNode/iconsSvgToJs.js bootstrap-1-9-1"
@@ -1,10 +1,22 @@
1
1
  import DOMPurify from "dompurify";
2
2
 
3
+ import {
4
+ isNumber,
5
+ toString,
6
+ } from "lodash-es";
7
+
3
8
  export default {
4
9
  beforeMount(el, binding) {
5
- el.innerHTML = DOMPurify.sanitize(binding.value);
10
+ el.innerHTML = DOMPurify.sanitize(toCorrectFormat(binding.value));
6
11
  },
7
12
  updated(el, binding) {
8
- el.innerHTML = DOMPurify.sanitize(binding.value);
13
+ el.innerHTML = DOMPurify.sanitize(toCorrectFormat(binding.value));
9
14
  },
10
15
  };
16
+
17
+ function toCorrectFormat(value) {
18
+ if (isNumber(value)) {
19
+ return toString(value);
20
+ }
21
+ return value;
22
+ }
@@ -46,7 +46,7 @@ export default {
46
46
  default: undefined,
47
47
  },
48
48
  valueType: {
49
- default: "date",
49
+ default: "format",
50
50
  validator: function(value) {
51
51
  return ["timestamp", "format", "date"].indexOf(value) !== -1 || isPlainObject(value);
52
52
  },
@@ -143,6 +143,11 @@ export default {
143
143
  required: false,
144
144
  default: false,
145
145
  },
146
+ formatSave: {
147
+ type: String,
148
+ required: false,
149
+ default: "YYYY-MM-DD",
150
+ },
146
151
  },
147
152
  emits: [
148
153
  "blur",
@@ -259,8 +264,8 @@ export default {
259
264
  value2date,
260
265
  } = this.transform;
261
266
  if (!this.range) {
262
- return this.isValidValue(this.modelValue)
263
- ? this.stringify(value2date(this.modelValue))
267
+ return this.isValidValueText(this.modelValue)
268
+ ? this.stringify(this.value2dateText(this.modelValue))
264
269
  : "";
265
270
  }
266
271
  return this.isValidRangeValue(this.modelValue)
@@ -446,7 +451,7 @@ export default {
446
451
  parse(value) {
447
452
  return (isPlainObject(this.format) && typeof this.format.parse === "function")
448
453
  ? this.format.parse(value)
449
- : parseDate(value, this.format);
454
+ : parseDate(value, this.format, this.formatSave);
450
455
  },
451
456
 
452
457
  isValidValue(value) {
@@ -516,7 +521,7 @@ export default {
516
521
  const { date2value } = this.transform;
517
522
  const value = this.range
518
523
  ? this.currentValue.map(date2value)
519
- : date2value(this.currentValue);
524
+ : formatDate(this.currentValue, this.formatSave);
520
525
  this.changeModel({
521
526
  model: value,
522
527
  });
@@ -705,6 +710,23 @@ export default {
705
710
  setCloseFocus() {
706
711
  this.$refs.focusByClose && this.$refs.focusByClose.focus();
707
712
  },
713
+
714
+ isValidValueText(value) {
715
+ return !!parseDate(value, this.format, this.formatSave);
716
+ },
717
+
718
+ value2dateText(value) {
719
+ let dateValue = null;
720
+ try {
721
+ dateValue = moment(value, this.formatSave) || null;
722
+ } catch (e) {
723
+
724
+ }
725
+ if (dateValue && dateValue.isValid && !dateValue.isValid()) {
726
+ dateValue = null;
727
+ }
728
+ return dateValue;
729
+ },
708
730
  },
709
731
  render() {
710
732
  return this.isRender && h("div", {
@@ -1,4 +1,5 @@
1
- import fecha from "fecha";
1
+ // import fecha from "fecha";
2
+ import moment from "moment";
2
3
 
3
4
  export function isPlainObject(obj) {
4
5
  return Object.prototype.toString.call(obj) === "[object Object]";
@@ -59,15 +60,16 @@ export function formatDate(date, format) {
59
60
  return "";
60
61
  }
61
62
  try {
62
- return fecha.format(new Date(date), format);
63
+ return moment(date).format(format);
64
+ // return fecha.format(new Date(date), format);
63
65
  } catch (e) {
64
66
  return "";
65
67
  }
66
68
  }
67
69
 
68
- export function parseDate(value, format) {
70
+ export function parseDate(value, format, formatSave) {
69
71
  try {
70
- return fecha.parse(value, format) || null;
72
+ return moment(value, formatSave).format(format) || null;
71
73
  } catch (e) {
72
74
  return null;
73
75
  }