toggle-components-library 1.22.8 → 1.22.9

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": "toggle-components-library",
3
- "version": "1.22.8",
3
+ "version": "1.22.9",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "main": "dist/toggle-components-library.common.js",
14
14
  "module": "dist/toggle-components-library.esm.js",
15
- "unpkg": "dist/toggle-components-library.min.js",
15
+ "unpkg": "dist/toggle-components-library.umd.min.js",
16
16
  "browser": {
17
17
  "./sfc": "src/toggle-components-library.vue"
18
18
  },
@@ -24,25 +24,27 @@
24
24
  "*.js"
25
25
  ],
26
26
  "dependencies": {
27
- "core-js": "^3.6.4",
27
+ "apexcharts": "^3.35.5",
28
+ "core-js": "^3.25.0",
28
29
  "countries-list": "^2.6.1",
29
30
  "date-fns": "^1.30.1",
30
31
  "storybook-vue-router": "^1.0.7",
31
- "vue": "^2.6.11",
32
+ "vue": "^2.7.10",
32
33
  "vue-airbnb-style-datepicker": "^2.7.1",
34
+ "vue-apexcharts": "^1.6.2",
33
35
  "vue-color": "^2.7.1",
34
36
  "vue-moment": "^4.1.0",
35
37
  "vue-multiselect": "^2.0.8",
36
- "vue-router": "^3.4.3",
38
+ "vue-router": "^3.6.4",
37
39
  "vue2-dropzone": "^3.6.0",
38
40
  "vuedraggable": "^2.24.3",
39
41
  "webfontloader": "^1.6.28"
40
42
  },
41
43
  "devDependencies": {
42
- "@babel/core": "^7.11.1",
43
- "@storybook/addon-actions": "^6.0.6",
44
- "@storybook/addon-docs": "^6.0.6",
45
- "@storybook/vue": "^6.0.6",
44
+ "@babel/core": "^7.18.13",
45
+ "@storybook/addon-actions": "^6.5.10",
46
+ "@storybook/addon-docs": "^6.5.10",
47
+ "@storybook/vue": "^6.5.10",
46
48
  "@vue/cli-plugin-babel": "^4.5.3",
47
49
  "@vue/cli-plugin-eslint": "^4.5.3",
48
50
  "@vue/cli-service": "^4.5.3",
@@ -53,9 +55,9 @@
53
55
  "eslint-plugin-vue": "^6.2.2",
54
56
  "react": "^16.13.1",
55
57
  "react-is": "^16.13.1",
56
- "sass": "^1.26.8",
58
+ "sass": "^1.54.5",
57
59
  "sass-loader": "^8.0.2",
58
- "vue-template-compiler": "^2.6.11"
60
+ "vue-template-compiler": "^2.7.10"
59
61
  },
60
62
  "eslintConfig": {
61
63
  "root": true,
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1070.503" height="166.653" viewBox="0 0 1070.503 166.653">
2
+ <defs>
3
+ <linearGradient id="linear-gradient" x1="0.993" y1="0.5" x2="0" y2="0.5" gradientUnits="objectBoundingBox">
4
+ <stop offset="0" stop-color="#f7f7f7"/>
5
+ <stop offset="1" stop-color="#dce9f7"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <g id="Group_222" data-name="Group 222" transform="translate(-182.585 -931.326)">
9
+ <path id="Union_1" data-name="Union 1" d="M0,166.653V0H84.287C169.914,0,342.83,37.691,448.053,37.691H625.967c132,0,148.131,20.785,269.689,20.785s174.859-.288,174.846,0c-.027.233-.012,16.421,0,22.1h0s0,.359,0,.993c0,.607,0,.952,0,.952h0c-.01,5.848-.025,22.889,0,23.137.014.3-53.289,0-174.846,0S757.971,127.34,625.967,127.34H448.053c-105.223,0-278.139,39.313-363.766,39.313Zm0,0ZM0,0Z" transform="translate(182.586 931.326)" fill="url(#linear-gradient)"/>
10
+ </g>
11
+ </svg>
@@ -0,0 +1,135 @@
1
+ <template>
2
+ <div>
3
+ <h3 class="toggle-metric metric-label">{{label}}</h3>
4
+ {{checkWindowSize}}
5
+ <apexchart type="bar" :height="height" :options="chartOptions" :series="values"></apexchart>
6
+ </div>
7
+
8
+ </template>
9
+
10
+ <script>
11
+ import {charts} from "../mixins/mixins";
12
+
13
+ export default {
14
+
15
+ mixins:[charts],
16
+
17
+ props: {
18
+ /**
19
+ * Used to overwrite the default colors
20
+ */
21
+ colors: {
22
+ type: [Array]
23
+ },
24
+ /*
25
+ * Component's height
26
+ */
27
+ height: {
28
+ type: String,
29
+ default: "100%"
30
+ },
31
+ /*
32
+ * Component's values
33
+ */
34
+ values: {
35
+ type: [Array],
36
+ required: true
37
+ },
38
+ /*
39
+ * Component's labels
40
+ */
41
+ label: {
42
+ type: String,
43
+ required: true
44
+ },
45
+ /*
46
+ * Component's categories
47
+ */
48
+ categories: {
49
+ type: [Array],
50
+ required: true
51
+ }
52
+ },
53
+
54
+ computed: {
55
+ /**
56
+ * define the pie chart options
57
+ * @return Object
58
+ */
59
+ chartOptions() {
60
+ return {
61
+ tooltip: {
62
+ y: {
63
+ formatter: function(value, opts) {
64
+ let percent = opts.w.globals.seriesPercent[opts.seriesIndex][opts.dataPointIndex];
65
+ return percent.toFixed(0) + '%'
66
+ }
67
+ }
68
+ },
69
+ plotOptions: {
70
+ bar: {
71
+ borderRadius: 5,
72
+ columnWidth: '60%',
73
+ }
74
+
75
+ },
76
+ chart: {
77
+ toolbar: {
78
+ show: false
79
+ },
80
+ },
81
+ grid: {
82
+ show: false
83
+ },
84
+ dataLabels: {
85
+ enabled: false,
86
+ },
87
+ xaxis: {
88
+ categories: this.categories,
89
+ labels: {
90
+ style: {
91
+ padding: '20px',
92
+ fontSize: '1rem',
93
+ }
94
+ },
95
+
96
+ },
97
+ yaxis: {
98
+
99
+ show: true,
100
+ labels: {
101
+ show: false
102
+ },
103
+ axisBorder: {
104
+ show: true,
105
+ color: this.getColor('gray'),
106
+ width: 3
107
+ },
108
+ axisTicks: {
109
+ show: false
110
+ }
111
+ },
112
+
113
+ colors: this.colors ? this.colors : this.getDefaultColors(),
114
+ legend: {
115
+ horizontalAlign: 'left',
116
+ offsetX: -12,
117
+ showForSingleSeries: true,
118
+ markers: {
119
+ width: 50,
120
+ radius: 5,
121
+ offsetY: 3
122
+ },
123
+
124
+ itemMargin: {
125
+ horizontal: 5,
126
+ vertical: 0
127
+ },
128
+
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ };
135
+ </script>
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <div class="toggle-metric-funnel-container">
3
+
4
+ <div class="funnel-grid-svg"></div>
5
+
6
+ <div class="funnel-spark-line funnel-grid-1">
7
+ <slot name="sparkLine1"></slot>
8
+ </div>
9
+ <div class="funnel-spark-line funnel-grid-2">
10
+ <slot name="sparkLine2"></slot>
11
+ </div>
12
+ <div class="funnel-spark-line funnel-grid-3">
13
+ <slot name="sparkLine3"></slot>
14
+ </div>
15
+ <div class="funnel-spark-line funnel-grid-4">
16
+ <slot name="sparkLine4"></slot>
17
+ </div>
18
+
19
+ <div class="funnel-single-metric funnel-grid-5">
20
+ <div class="funnel-single-metric-container">
21
+ <slot name="funnel1" class="funnel-single-metric"></slot>
22
+ </div>
23
+ </div>
24
+
25
+ <div class="funnel-single-metric funnel-grid-6">
26
+ <div class="funnel-single-metric-container">
27
+ <slot name="funnel2" class="funnel-single-metric"></slot>
28
+ </div>
29
+ </div>
30
+
31
+ <div class="funnel-single-metric funnel-grid-7">
32
+ <div class="funnel-single-metric-container">
33
+ <slot name="funnel3" class="funnel-single-metric"></slot>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="funnel-single-metric funnel-grid-8">
38
+ <div class="funnel-single-metric-container">
39
+ <slot name="funnel4" class="funnel-single-metric"></slot>
40
+ </div>
41
+ </div>
42
+
43
+ </div>
44
+ </template>
45
+
46
+ <script>
47
+
48
+ import { mixins } from '../mixins/mixins'
49
+
50
+ export default {
51
+ mixins:[mixins],
52
+ props: {
53
+ /*
54
+ * Component's name
55
+ */
56
+ name: {
57
+ type: String,
58
+ default: "ToggleMetricFunnelChart"
59
+ }
60
+ }
61
+ }
62
+
63
+ </script>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <div>
3
+ <h3 class="toggle-metric metric-label">{{label}}</h3>
4
+ <apexchart type="pie" :options="chartOptions" :series="values"></apexchart>
5
+ </div>
6
+
7
+ </template>
8
+
9
+ <script>
10
+
11
+ import {charts} from "../mixins/mixins";
12
+
13
+ export default {
14
+ mixins:[charts],
15
+
16
+ props: {
17
+ /**
18
+ * Used to overwrite the default colors
19
+ */
20
+ colors: {
21
+ type: [String]
22
+ },
23
+ /**
24
+ * Component's values
25
+ */
26
+ values: {
27
+ type: Array,
28
+ required: true
29
+ },
30
+ /**
31
+ * Component's main label
32
+ */
33
+ label: {
34
+ type: String,
35
+ required: true
36
+ },
37
+ /**
38
+ * Component's label for each value
39
+ */
40
+ labels: {
41
+ type: Array,
42
+ required: true
43
+ }
44
+ },
45
+ computed: {
46
+ /**
47
+ * define the pie chart options
48
+ * @return Object
49
+ */
50
+ chartOptions() {
51
+ return {
52
+ labels: this.labels,
53
+ plotOptions: {
54
+ pie: {
55
+ customScale: 1,
56
+ dataLabels: {
57
+ offset: -50
58
+ }
59
+
60
+ }
61
+ },
62
+ colors: this.colors ? this.colors : this.getDefaultColors(),
63
+ dataLabels: {
64
+ enabledOnSeries: true,
65
+ formatter: function (val, {seriesIndex, w}) {
66
+ return `${w.globals.labels[seriesIndex]} ${val}%`
67
+ },
68
+ style: {
69
+ colors: [this.getColor('black')],
70
+ fontSize: '1rem',
71
+ fontWeight: 300
72
+ },
73
+ background: {
74
+ enabled: false,
75
+ },
76
+ dropShadow: {
77
+ enabled: false,
78
+ }
79
+ },
80
+
81
+ legend: {
82
+ show: false,
83
+ },
84
+ tooltip: {
85
+ enabled: false
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ };
92
+ </script>
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div>
3
+ <h3 class="toggle-metric metric-label">{{label}}</h3>
4
+ <h1 class="toggle-metric metric-value">{{metricValue}}</h1>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+
10
+ import { mixins } from '../mixins/mixins'
11
+
12
+
13
+ export default {
14
+ mixins:[mixins],
15
+ props: {
16
+ /**
17
+ * Component's name
18
+ */
19
+ name: {
20
+ type: String,
21
+ default: "ToggleMetricSingleMetric"
22
+ },
23
+ /**
24
+ * Type of the value, this will affect on the format shown
25
+ */
26
+ type : {
27
+ type: String,
28
+ validator: function (value) {
29
+ return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
30
+ }
31
+ },
32
+ /**
33
+ * Component's value
34
+ */
35
+ value: {
36
+ type: [String, Number],
37
+ required: true
38
+ },
39
+ /**
40
+ * Component's label
41
+ */
42
+ label: {
43
+ type: String,
44
+ default: ""
45
+ },
46
+ /**
47
+ * Currency Code
48
+ */
49
+ currencyCode:{
50
+ type:String,
51
+ required:false,
52
+ default:'GBP'
53
+ },
54
+ /**
55
+ * Currency locale
56
+ */
57
+ currencyLocale:{
58
+ type:String,
59
+ required:false,
60
+ default:'en-GB'
61
+ },
62
+ /**
63
+ * Currency denomination
64
+ */
65
+ currencyDenomination: {
66
+ type: Number,
67
+ default: 100
68
+ }
69
+ },
70
+ computed: {
71
+ /**
72
+ * Formats the value to be shown
73
+ * @return String
74
+ */
75
+ metricValue() {
76
+ if (this.value == 0) {
77
+ return "-";
78
+ }
79
+
80
+ switch (this.type) {
81
+ case 'currency':
82
+ return (this.value/this.currencyDenomination).toLocaleString(this.currencyLocale, {style: 'currency', currency: this.currencyCode});
83
+ case'percentage':
84
+ return `${this.value} %`
85
+ default:
86
+ return this.value.toLocaleString();
87
+
88
+ }
89
+ }
90
+
91
+
92
+ }
93
+ }
94
+
95
+
96
+ </script>
@@ -0,0 +1,241 @@
1
+ <template>
2
+ <div>
3
+ <ToggleBadge style="margin-bottom: 10px"
4
+ :badgeStyle="trendImpactClass"
5
+ >
6
+ {{trendImpactLabel}}
7
+ </ToggleBadge>
8
+
9
+ <ToggleMetricSingleMetric :value="singleMetricVal" :label="label" :type="type" :currencyCode="currencyCode" :currencyLocale="currencyLocale" :currencyDenomination="currencyDenomination"/>
10
+
11
+ <apexchart type="line" :height="height" :width="width" :options="chartOptions" :series="sparkLineVal" ref="sparkLineRef">
12
+ </apexchart>
13
+ </div>
14
+ </template>
15
+
16
+ <script>
17
+
18
+ import Vue from "vue";
19
+ import {charts} from "../mixins/mixins";
20
+ import ToggleMetricSingleMetric from './ToggleMetricSingleMetric.vue';
21
+ import ToggleBadge from '../badges/ToggleBadge.vue';
22
+ import VueApexCharts from 'vue-apexcharts'
23
+
24
+ Vue.use(VueApexCharts);
25
+ Vue.component('apexchart', VueApexCharts);
26
+
27
+ export default {
28
+ mixins:[charts],
29
+ props: {
30
+ /**
31
+ * Component's name
32
+ */
33
+ name: {
34
+ type: String,
35
+ default: "ToggleMetricSingleMetric"
36
+ },
37
+ /**
38
+ * The line chart height
39
+ */
40
+ height : {
41
+ type: String,
42
+ default: "25%"
43
+ },
44
+ /**
45
+ * The line chart width
46
+ */
47
+ width : {
48
+ type: String,
49
+ default: "25%"
50
+ },
51
+ /**
52
+ * Type of the value, this will affect on the format shown for the single value
53
+ */
54
+ type : {
55
+ type: String,
56
+ validator: function (value) {
57
+ return ['text', 'number', 'percentage', 'currency'].indexOf(value) !== -1
58
+ }
59
+ },
60
+ /**
61
+ * single metric component value
62
+ */
63
+ singleMetricVal: {
64
+ type: [String, Number],
65
+ required: true
66
+ },
67
+ /**
68
+ * spark line component value
69
+ */
70
+ sparkLineVal: {
71
+ type: Array,
72
+ required: true
73
+ },
74
+ /**
75
+ * Component's label
76
+ */
77
+ label: {
78
+ type: String,
79
+ required: true
80
+ },
81
+ /**
82
+ * Currency Code
83
+ */
84
+ currencyCode:{
85
+ type:String,
86
+ required:false,
87
+ default:'GBP'
88
+ },
89
+ /**
90
+ * Currency locale
91
+ */
92
+ currencyLocale:{
93
+ type:String,
94
+ required:false,
95
+ default:'en-GB'
96
+ },
97
+ /**
98
+ * Currency denomination
99
+ */
100
+ currencyDenomination: {
101
+ type: Number,
102
+ default: 100
103
+ },
104
+ /**
105
+ * Percentage base used to calculate the trend impact
106
+ */
107
+ trend_impact_percentage :{
108
+ type: Number,
109
+ default: 5
110
+ },
111
+ /**
112
+ * This prop will inverse the trend impact
113
+ */
114
+ inverse_trend_impact: {
115
+ type: Boolean,
116
+ default: false
117
+ }
118
+ },
119
+
120
+ components: {
121
+ ToggleMetricSingleMetric,
122
+ ToggleBadge
123
+ },
124
+
125
+ data : function(){
126
+ return {
127
+ trendImpact: 0,
128
+ chartOptions: {
129
+ chart: {
130
+ sparkline: {
131
+ enabled: true,
132
+ },
133
+ defaultLocale: 'en',
134
+ redrawOnParentResize: true,
135
+ redrawOnWindowResize: true,
136
+ },
137
+ stroke: {
138
+ width: 5,
139
+ },
140
+ grid: {
141
+ padding: {
142
+ top: 5,
143
+ bottom: 5,
144
+ }
145
+ },
146
+ noData: {
147
+ text: "No data found",
148
+ align: 'left',
149
+ verticalAlign: 'top',
150
+ offsetX: 0,
151
+ offsetY: 0
152
+ },
153
+
154
+ }
155
+ };
156
+ },
157
+ mounted() {
158
+ this.updateTrend();
159
+ },
160
+ updated() {
161
+ this.updateTrend();
162
+ },
163
+ computed: {
164
+ /**
165
+ * Defines the badge class from the trending impact
166
+ * @return String
167
+ */
168
+ trendImpactClass() {
169
+ return this.getTrendImpact() === 1 ? 'confirm'
170
+ : this.getTrendImpact() === -1 ? 'abort'
171
+ : this.getTrendImpact() === 0 ? 'warning'
172
+ : 'empty';
173
+ },
174
+ /**
175
+ * Defines the badge title from the trending impact
176
+ * @return String
177
+ */
178
+ trendImpactLabel() {
179
+ return this.getTrendImpact() === 1 ? 'Trending up'
180
+ : this.getTrendImpact() === -1 ? 'Going down'
181
+ : this.getTrendImpact() === 0 ? 'Keeping steady'
182
+ : 'No data';
183
+ }
184
+ },
185
+ methods: {
186
+ /**
187
+ * Gets the trend impact from mixing method
188
+ * @return Integer
189
+ */
190
+ getTrendImpact() {
191
+
192
+ if (this.sparkLineVal[0].data.length > 0) {
193
+ // if the value is an object, map to array
194
+
195
+ const trendImpactVals = this.sparkLineVal[0].data[0].y ? this.sparkLineVal[0].data.map(data => data.y) : this.sparkLineVal[0].data;
196
+
197
+ let result = this.calcTrendImpact(trendImpactVals, this.trend_impact_percentage);
198
+ if (this.inverse_trend_impact === true && result != false)
199
+ return result *-1;
200
+ else
201
+ return result;
202
+
203
+ } else {
204
+ return false;
205
+ }
206
+ },
207
+
208
+ /**
209
+ * Gets trend impact and udpates the chart with respective color
210
+ * @return Void
211
+ */
212
+ updateTrend() {
213
+ this.trendImpact = this.getTrendImpact();
214
+
215
+ switch (this.trendImpact) {
216
+ case 1:
217
+ this.updateChart([this.getColor('green')]);
218
+ break;
219
+ case 0:
220
+ this.updateChart([this.getColor('amber')]);
221
+ break;
222
+ case -1:
223
+ this.updateChart([this.getColor('red')]);
224
+ break;
225
+ case false:
226
+ this.updateChart([this.getColor('gray')]);
227
+ break;
228
+ }
229
+ },
230
+
231
+ /**
232
+ * Updates the spark line chart component colors
233
+ * @return Void
234
+ */
235
+ updateChart(colors) {
236
+ this.$refs.sparkLineRef.updateOptions({ colors: colors });
237
+ }
238
+ }
239
+ }
240
+
241
+ </script>