@bildvitta/quasar-ui-asteroid 2.15.0 → 2.17.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
- "version": "2.15.0",
3
+ "version": "2.17.1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -35,6 +35,10 @@ export default {
35
35
  description: 'CSS classes for each result value.'
36
36
  },
37
37
 
38
+ emptyResultText: {
39
+ description: 'Message for fields with empty values.'
40
+ },
41
+
38
42
  fields: {
39
43
  description: 'Define header value for each `field`.'
40
44
  },
@@ -38,6 +38,11 @@ export default {
38
38
  type: Boolean
39
39
  },
40
40
 
41
+ emptyResultText: {
42
+ default: '-',
43
+ type: String
44
+ },
45
+
41
46
  result: {
42
47
  default: () => ({}),
43
48
  type: Object
@@ -76,16 +81,14 @@ export default {
76
81
  resultsByFields () {
77
82
  const formattedResult = {}
78
83
  const result = extend(true, {}, this.result)
79
-
80
84
  for (const key in result) {
81
85
  if (this.formattedFields[key]?.type) {
82
- formattedResult[key] = humanize(this.formattedFields[key], result[key])
86
+ formattedResult[key] = humanize(this.formattedFields[key], result[key]) || this.emptyResultText
83
87
  // TODO: Rever.
84
88
  // eslint-disable-next-line vue/no-side-effects-in-computed-properties
85
89
  this.slotValue[key] = { ...this.formattedFields[key], formattedResult: formattedResult[key] }
86
90
  }
87
91
  }
88
-
89
92
  return formattedResult
90
93
  }
91
94
  }
@@ -22,6 +22,10 @@ export default {
22
22
  description: 'Table columns and order.'
23
23
  },
24
24
 
25
+ emptyResultText: {
26
+ description: 'Message for fields with empty values.'
27
+ },
28
+
25
29
  fields: {
26
30
  description: 'Contain fields data, as `name`, `label` and `type`.',
27
31
  table: {
@@ -43,6 +43,11 @@ export default {
43
43
  rowKey: {
44
44
  default: 'name',
45
45
  type: String
46
+ },
47
+
48
+ emptyResultText: {
49
+ default: '-',
50
+ type: String
46
51
  }
47
52
  },
48
53
 
@@ -114,7 +119,7 @@ export default {
114
119
  return results.map((result, index) => {
115
120
  for (const key in result) {
116
121
  result.default = this.results[index]
117
- result[key] = humanize(this.fields[key], result[key])
122
+ result[key] = humanize(this.fields[key], result[key]) || this.emptyResultText
118
123
  }
119
124
 
120
125
  return result
@@ -54,6 +54,11 @@ function percent (value = 0, places = 2) {
54
54
  return value ? (value / 100).toLocaleString('pt-BR', { style: 'percent', minimumFractionDigits: places }) : ''
55
55
  }
56
56
 
57
+ function formatPercent (value = 0, places = 2) {
58
+ value = Number(value)
59
+ return value ? value.toLocaleString('pt-BR', { style: 'percent', minimumFractionDigits: places }) : ''
60
+ }
61
+
57
62
  function squareArea (value = 0, suffix = 'm²') {
58
63
  value = decimal(value)
59
64
  return value ? `${value} ${suffix}` : ''
@@ -96,8 +101,7 @@ function handleMasks (value) {
96
101
 
97
102
  // Labels
98
103
  function humanize (field = {}, value) {
99
- if (!value) return value
100
-
104
+ if (field.mask && !value) return value
101
105
  const mappedMasks = handleMasks(value)
102
106
 
103
107
  if (mappedMasks[field.mask]) {
@@ -111,6 +115,7 @@ function humanize (field = {}, value) {
111
115
  case 'datetime': return dateTime(value)
112
116
  case 'time': return time(value)
113
117
  case 'radio': return selectLabel(field.options, value)
118
+ case 'percent': return formatPercent(value)
114
119
  default: return value
115
120
  }
116
121
  }
@@ -143,6 +148,7 @@ export {
143
148
  decimal,
144
149
  formatCompanyDocument,
145
150
  formatDocument,
151
+ formatPercent,
146
152
  formatPersonalDocument,
147
153
  formatPhone,
148
154
  formatPostalCode,
@@ -13,6 +13,7 @@ import {
13
13
  decimal,
14
14
  formatCompanyDocument,
15
15
  formatDocument,
16
+ formatPercent,
16
17
  formatPersonalDocument,
17
18
  formatPhone,
18
19
  formatPostalCode,
@@ -36,6 +37,7 @@ export {
36
37
  decimal,
37
38
  formatCompanyDocument,
38
39
  formatDocument,
40
+ formatPercent,
39
41
  formatPersonalDocument,
40
42
  formatPhone,
41
43
  formatPostalCode,