@tekkare/auriga 0.2.58 → 0.2.60

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/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.2.58"
7
+ "version": "0.2.60"
8
8
  }
@@ -12,7 +12,13 @@
12
12
  />
13
13
  </div>
14
14
  <div class="kpi_text">
15
- <p class="kpi_value">{{ kpi.value }}</p>
15
+ <p class="kpi_value">
16
+ {{
17
+ typeof kpi.value === "number"
18
+ ? Intl.NumberFormat("fr-FR").format(kpi.value).replace(",", ".")
19
+ : kpi.value
20
+ }}
21
+ </p>
16
22
  <p class="kpi_legend">{{ kpi.legend }}</p>
17
23
  </div>
18
24
  </div>
@@ -1,10 +1,15 @@
1
+ interface kpi {
2
+ value: any;
3
+ legend: string;
4
+ icon: string;
5
+ }
1
6
  declare const _default: import("vue").DefineComponent<{
2
7
  kpis: {
3
8
  type: {
4
- (arrayLength: number): Object[];
5
- (...items: Object[]): Object[];
6
- new (arrayLength: number): Object[];
7
- new (...items: Object[]): Object[];
9
+ (arrayLength: number): kpi[];
10
+ (...items: kpi[]): kpi[];
11
+ new (arrayLength: number): kpi[];
12
+ new (...items: kpi[]): kpi[];
8
13
  isArray(arg: any): arg is any[];
9
14
  readonly prototype: any[];
10
15
  from<T>(arrayLike: ArrayLike<T>): T[];
@@ -19,10 +24,10 @@ declare const _default: import("vue").DefineComponent<{
19
24
  }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
25
  kpis: {
21
26
  type: {
22
- (arrayLength: number): Object[];
23
- (...items: Object[]): Object[];
24
- new (arrayLength: number): Object[];
25
- new (...items: Object[]): Object[];
27
+ (arrayLength: number): kpi[];
28
+ (...items: kpi[]): kpi[];
29
+ new (arrayLength: number): kpi[];
30
+ new (...items: kpi[]): kpi[];
26
31
  isArray(arg: any): arg is any[];
27
32
  readonly prototype: any[];
28
33
  from<T>(arrayLike: ArrayLike<T>): T[];
@@ -97,6 +97,10 @@ export default defineComponent({
97
97
  return [null, "percentage", "price"].includes(value);
98
98
  }
99
99
  },
100
+ hasPercentages: {
101
+ type: Boolean,
102
+ default: false
103
+ },
100
104
  currency: {
101
105
  type: String,
102
106
  default: null
@@ -248,9 +252,32 @@ export default defineComponent({
248
252
  borderRadius: 2
249
253
  },
250
254
  formatter: function(value, opt) {
251
- const numValue = Math.round(value * 10) / 10;
252
- const returnValue = new Intl.NumberFormat("fr-FR").format(numValue).replace(",", ".");
253
- return value === null ? "" : `${returnValue}${props.dataType === "price" ? ` ${props.currency}` : props.dataType === "percentage" ? " %" : ""}`;
255
+ const seriesData = props.series;
256
+ if (props.hasPercentages && value !== null) {
257
+ const formatValue = new Intl.NumberFormat("fr-FR", {
258
+ maximumFractionDigits: 1
259
+ }).format(value).replace(",", ".");
260
+ let returnValue = props.dataType === "price" ? `${formatValue} ${props.currency}` : formatValue;
261
+ if (opt.dataPointIndex > 0 && seriesData[opt.seriesIndex].data[opt.dataPointIndex - 1] !== null && seriesData[opt.seriesIndex].data[opt.dataPointIndex] !== null) {
262
+ const previousVal = seriesData[opt.seriesIndex].data[opt.dataPointIndex - 1];
263
+ const plainPercent = (value - previousVal) / previousVal * 100;
264
+ const formatPercent = new Intl.NumberFormat("fr-FR", {
265
+ maximumFractionDigits: 1
266
+ }).format((value - previousVal) / previousVal * 100).replace(",", ".");
267
+ if (previousVal === 0) {
268
+ returnValue = "-";
269
+ } else if (Number(plainPercent) > 0) {
270
+ returnValue = `${returnValue} (+${formatPercent}%)`;
271
+ } else {
272
+ returnValue = returnValue + " (" + formatPercent + "%)";
273
+ }
274
+ }
275
+ return returnValue;
276
+ } else {
277
+ const numValue = Math.round(value * 10) / 10;
278
+ const returnValue = new Intl.NumberFormat("fr-FR").format(numValue).replace(",", ".");
279
+ return value === null ? "" : `${returnValue}${props.dataType === "price" ? ` ${props.currency}` : props.dataType === "percentage" ? " %" : ""}`;
280
+ }
254
281
  }
255
282
  };
256
283
  options.value["xaxis"] = {
@@ -46,6 +46,10 @@ declare const _default: import("vue").DefineComponent<{
46
46
  default: null;
47
47
  validator: (value: string | null) => boolean;
48
48
  };
49
+ hasPercentages: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
49
53
  currency: {
50
54
  type: StringConstructor;
51
55
  default: null;
@@ -104,6 +108,10 @@ declare const _default: import("vue").DefineComponent<{
104
108
  default: null;
105
109
  validator: (value: string | null) => boolean;
106
110
  };
111
+ hasPercentages: {
112
+ type: BooleanConstructor;
113
+ default: boolean;
114
+ };
107
115
  currency: {
108
116
  type: StringConstructor;
109
117
  default: null;
@@ -118,6 +126,7 @@ declare const _default: import("vue").DefineComponent<{
118
126
  tooltipOptions: Record<string, any>;
119
127
  formatDate: boolean;
120
128
  dataType: string;
129
+ hasPercentages: boolean;
121
130
  currency: string;
122
131
  }, {}>;
123
132
  export default _default;
@@ -36,7 +36,7 @@ export default defineComponent({
36
36
  name: "tableRowCrop",
37
37
  /* components: { argIcon, argStyle }, */
38
38
  props: {
39
- value: { type: [String, Number, Array, Object], default: "" },
39
+ value: { default: "" },
40
40
  custom: { type: Boolean, default: false }
41
41
  },
42
42
  setup(props, { emit }) {
@@ -1,6 +1,5 @@
1
1
  declare const _default: import("vue").DefineComponent<{
2
2
  value: {
3
- type: (ObjectConstructor | StringConstructor | ArrayConstructor | NumberConstructor)[];
4
3
  default: string;
5
4
  };
6
5
  custom: {
@@ -15,7 +14,6 @@ declare const _default: import("vue").DefineComponent<{
15
14
  showReadMore: import("vue").Ref<boolean>;
16
15
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
17
16
  value: {
18
- type: (ObjectConstructor | StringConstructor | ArrayConstructor | NumberConstructor)[];
19
17
  default: string;
20
18
  };
21
19
  custom: {
@@ -23,7 +21,7 @@ declare const _default: import("vue").DefineComponent<{
23
21
  default: boolean;
24
22
  };
25
23
  }>>, {
26
- value: string | number | Record<string, any> | unknown[];
24
+ value: string;
27
25
  custom: boolean;
28
26
  }, {}>;
29
27
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/auriga",
3
- "version": "0.2.58",
3
+ "version": "0.2.60",
4
4
  "description": "Aurgia is a UI kit developped by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",