@iamproperty/components 5.7.1-beta5 → 6.0.0
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/assets/css/components/barchart.component.css +1 -1
- package/assets/css/components/barchart.component.css.map +1 -1
- package/assets/css/components/card.css +1 -1
- package/assets/css/components/card.css.map +1 -1
- package/assets/css/components/card.global.css +1 -1
- package/assets/css/components/card.global.css.map +1 -1
- package/assets/css/components/charts.config.css +1 -1
- package/assets/css/components/charts.config.css.map +1 -1
- package/assets/css/components/charts.module.css +1 -1
- package/assets/css/components/charts.module.css.map +1 -1
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/components/_global.js +32 -0
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
- package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/barchart/barchart.component.js +11 -10
- package/assets/js/components/barchart/barchart.component.min.js +4 -6
- package/assets/js/components/barchart/barchart.component.min.js.map +1 -1
- package/assets/js/components/card/card.component.js +29 -4
- package/assets/js/components/card/card.component.min.js +15 -8
- package/assets/js/components/card/card.component.min.js.map +1 -1
- package/assets/js/components/carousel/carousel.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
- package/assets/js/components/nav/nav.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/search/search.component.min.js +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/table/table.component.min.js +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +1 -1
- package/assets/js/dynamic.min.js +1 -1
- package/assets/js/modules/chart.module.js +68 -88
- package/assets/js/scripts.bundle.js +22 -15
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/js/tests/chart.spec.js +57 -0
- package/assets/sass/components/barchart.component.scss +47 -3
- package/assets/sass/components/card.global.scss +7 -1
- package/assets/sass/components/card.scss +114 -45
- package/assets/sass/components/charts.config.scss +15 -10
- package/assets/sass/components/charts.module.scss +19 -4
- package/assets/sass/elements/badge-tag.scss +6 -0
- package/assets/sass/elements/dialog.scss +6 -2
- package/assets/ts/components/_global.ts +40 -0
- package/assets/ts/components/barchart/barchart.component.ts +13 -19
- package/assets/ts/components/card/card.component.ts +35 -4
- package/assets/ts/modules/chart.module.ts +89 -108
- package/assets/ts/tests/chart.spec.ts +77 -0
- package/dist/components.es.js +11 -11
- package/dist/components.umd.js +54 -47
- package/package.json +1 -1
- package/src/components/BarChart/BarChart.vue +1 -1
|
@@ -14,7 +14,7 @@ class iamCard extends HTMLElement {
|
|
|
14
14
|
super();
|
|
15
15
|
this.attachShadow({ mode: 'open'});
|
|
16
16
|
|
|
17
|
-
if(this.querySelector('*:not(.badge):not(small):not(.btn) > [class*="fa-"]:not(.btn)'))
|
|
17
|
+
if(this.querySelector('*:not(.badge):not(small):not(.btn):not(button) > [class*="fa-"]:not(.btn)'))
|
|
18
18
|
this.classList.add('card--has-icon');
|
|
19
19
|
|
|
20
20
|
let classList = this.classList.toString();
|
|
@@ -45,7 +45,8 @@ class iamCard extends HTMLElement {
|
|
|
45
45
|
|
|
46
46
|
const createCardConent () {
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
// TODO split this out a bit
|
|
49
|
+
return `${this.hasAttribute('data-image') || this.hasAttribute('data-record') ? `<div class="card__head" part="head">${this.hasAttribute('data-image') ? `<img src="${this.getAttribute('data-image')}" alt="" loading="lazy" />` : ``} <div class="card__badges"><slot name="badges"></slot></div></div>` : ''}
|
|
49
50
|
<div class="card__body" part="body">
|
|
50
51
|
${!this.hasAttribute('data-image') && this.querySelector('[slot="badges"]') && this.querySelector('[slot="checkbox"]') ? `<div class="card__badges card__badges--inline"><slot name="badges"></slot></div>` : ''}
|
|
51
52
|
${!this.hasAttribute('data-image') && !this.hasAttribute('data-record') && this.querySelector('[slot="badges"]') ? `<div class="card__badges"><slot name="badges"></slot></div>` : ''}
|
|
@@ -55,6 +56,13 @@ class iamCard extends HTMLElement {
|
|
|
55
56
|
</div>
|
|
56
57
|
${this.hasAttribute('data-add-link') ? `<button class="btn btn-compact btn-secondary fa-plus">Add property</button>` : ''}
|
|
57
58
|
<slot name="checkbox"></slot>
|
|
59
|
+
<slot name="primary-action"></slot>
|
|
60
|
+
<div class="dialog__wrapper d-none">
|
|
61
|
+
<button class="btn btn-secondary btn-compact fa-ellipsis-vertical" popovertarget="actions" title="${this.hasAttribute('data-menu-title') ? this.getAttribute('data-menu-title') : 'Further actions'}">Lorum ipsum</button>
|
|
62
|
+
<dialog class="dialog--fix dialog--list" id="actions" popover>
|
|
63
|
+
<slot name="actions"></slot>
|
|
64
|
+
</dialog>
|
|
65
|
+
</div>
|
|
58
66
|
<div class="card__footer" part="footer">
|
|
59
67
|
<slot name="footer"></slot>
|
|
60
68
|
<slot name="btns"></slot>
|
|
@@ -66,11 +74,34 @@ class iamCard extends HTMLElement {
|
|
|
66
74
|
this.classList.add('loaded');
|
|
67
75
|
|
|
68
76
|
// Mimic clicking the parent node so the focus and target events can be on the card
|
|
69
|
-
const
|
|
77
|
+
const component = this;
|
|
78
|
+
const parentNode = component.parentNode.closest('a, button, label, router-link');
|
|
70
79
|
const card = this.shadowRoot.querySelector('.card')
|
|
71
80
|
const btnCompact = this.shadowRoot.querySelector('.btn-compact');
|
|
72
81
|
const recordType = this.hasAttribute('data-record') ? this.getAttribute('data-record') : '';
|
|
73
82
|
|
|
83
|
+
|
|
84
|
+
// Add the actions slot to the buttons and links to move them into a dialog warpper
|
|
85
|
+
const actionsWrapper = this.shadowRoot.querySelector('.dialog__wrapper');
|
|
86
|
+
let buttons = component.querySelectorAll('button[slot="actions"],a[slot="actions"]');
|
|
87
|
+
if(buttons.length){
|
|
88
|
+
|
|
89
|
+
const actionsWrapper = this.shadowRoot.querySelector('.dialog__wrapper');
|
|
90
|
+
const actionsDialog = this.shadowRoot.querySelector('.dialog__wrapper dialog');
|
|
91
|
+
const actionsBtn = actionsWrapper.querySelector('button');
|
|
92
|
+
|
|
93
|
+
actionsWrapper.classList.remove('d-none');
|
|
94
|
+
|
|
95
|
+
Array.from(buttons).forEach((button,index)=>{
|
|
96
|
+
|
|
97
|
+
button.classList.add('btn');
|
|
98
|
+
button.classList.add('btn-action');
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
actionsWrapper.remove();
|
|
103
|
+
}
|
|
104
|
+
|
|
74
105
|
/*
|
|
75
106
|
If the parentNode is actually just a div,
|
|
76
107
|
we don't want to look for anything or add events
|
|
@@ -209,7 +240,7 @@ class iamCard extends HTMLElement {
|
|
|
209
240
|
if(oldVal != newVal){
|
|
210
241
|
let classList = this.classList.toString();
|
|
211
242
|
|
|
212
|
-
if(this.querySelector('*:not(.badge):not(small):not(.btn) > [class*="fa-"]:not(.btn)'))
|
|
243
|
+
if(this.querySelector('*:not(.badge):not(small):not(.btn):not(button) > [class*="fa-"]:not(.btn)'))
|
|
213
244
|
classList += ' card--has-icon';
|
|
214
245
|
|
|
215
246
|
this.shadowRoot.querySelector('.card').setAttribute('class',`card ${classList}`);
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { numberOfDays } from './helpers'
|
|
2
1
|
|
|
3
2
|
// #region Functions that setup and trigger other functions
|
|
4
3
|
|
|
5
|
-
export const addClasses = (chartElement:any) => {
|
|
4
|
+
export const addClasses = (chartElement:any, chartOuter:any) => {
|
|
6
5
|
|
|
7
6
|
// add colour classes
|
|
8
7
|
for (let i = 1; i <= 10; i++) {
|
|
9
8
|
if(chartElement.hasAttribute(`data-colour-${i}`)){
|
|
10
9
|
|
|
11
10
|
let colour = chartElement.getAttribute(`data-colour-${i}`);
|
|
12
|
-
|
|
13
11
|
chartElement.style.setProperty(`--chart-colour-${i}`, `var(--chart-colour-${colour})`);
|
|
14
12
|
chartElement.style.setProperty(`--chart-colour-${i}-hover`, `var(--chart-colour-${colour}-hover)`);
|
|
15
13
|
}
|
|
14
|
+
|
|
15
|
+
Array.from(chartOuter.querySelectorAll(`[data-colour-${i}]`)).forEach((element:HTMLElement) => {
|
|
16
|
+
|
|
17
|
+
let colour = element.getAttribute(`data-colour-${i}`);
|
|
18
|
+
element.style.setProperty(`--chart-colour-${i}-set`, `var(--chart-colour-${colour})`);
|
|
19
|
+
element.style.setProperty(`--chart-colour-${i}-hover`, `var(--chart-colour-${colour}-hover)`);
|
|
20
|
+
});
|
|
21
|
+
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
return true;
|
|
@@ -34,26 +40,24 @@ export const setupChart = (chartElement:any,chartOuter:any,tableElement:any) =>
|
|
|
34
40
|
Array.from(chartOuter.querySelectorAll(':scope > input[type="checkbox"],:scope > input[type="radio"]')).map((element: any) => { element.remove(); })
|
|
35
41
|
// #endregion
|
|
36
42
|
|
|
37
|
-
let {xaxis} = getChartData(chartElement
|
|
43
|
+
let {xaxis} = getChartData(chartElement);
|
|
38
44
|
|
|
39
|
-
setCellData(chartElement,
|
|
45
|
+
setCellData(chartElement,tableElement);
|
|
40
46
|
|
|
41
47
|
createChartKey(chartOuter,tableElement,chartKey);
|
|
42
|
-
createChartGuidelines(chartElement,
|
|
43
|
-
createChartYaxis(chartElement,
|
|
48
|
+
createChartGuidelines(chartElement,chartGuidelines);
|
|
49
|
+
createChartYaxis(chartElement,chartYaxis);
|
|
44
50
|
|
|
45
51
|
if(xaxis){
|
|
46
|
-
createXaxis(
|
|
52
|
+
createXaxis(chartOuter);
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
55
|
return true;
|
|
52
56
|
};
|
|
53
57
|
// #endregion
|
|
54
58
|
|
|
55
59
|
// #region Event handlers and observers
|
|
56
|
-
export const setEventListener = function(chartOuter:any) {
|
|
60
|
+
export const setEventListener = function(chartElement:any, chartOuter:any) {
|
|
57
61
|
|
|
58
62
|
let chart = chartOuter.querySelector('.chart');
|
|
59
63
|
chart.addEventListener('mousemove', (event:any) => {
|
|
@@ -81,15 +85,35 @@ export const setEventListener = function(chartOuter:any) {
|
|
|
81
85
|
label.setAttribute('part','key-unchecked');
|
|
82
86
|
});
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
|
|
89
|
+
let table = chartElement.querySelector('table');
|
|
90
|
+
let shadowTable = chartOuter.querySelector('table');
|
|
91
|
+
|
|
92
|
+
chartOuter.addEventListener('change', function(event:any){
|
|
93
|
+
|
|
94
|
+
let eventTarget = event.target;
|
|
95
|
+
|
|
96
|
+
const customEvent = new CustomEvent("view-change", { detail: {
|
|
97
|
+
'data-dataset': eventTarget.getAttribute('data-dataset'),
|
|
98
|
+
'label': eventTarget.getAttribute('data-label'),
|
|
99
|
+
'checked': eventTarget.checked
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
chartElement.dispatchEvent(customEvent);
|
|
85
104
|
|
|
86
105
|
Array.from(labels).forEach((label:HTMLElement) => {
|
|
87
106
|
|
|
88
|
-
if(chartOuter.querySelector(`input#${label.getAttribute('for')}`)
|
|
107
|
+
if(chartOuter.querySelector(`input#${label.getAttribute('for')}`)?.checked)
|
|
89
108
|
label.setAttribute('part','key-checked');
|
|
90
109
|
else
|
|
91
110
|
label.setAttribute('part','key-unchecked');
|
|
92
111
|
});
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
shadowTable.innerHTML = table.innerHTML;
|
|
115
|
+
setCellData(chartElement,shadowTable);
|
|
116
|
+
|
|
93
117
|
});
|
|
94
118
|
}
|
|
95
119
|
|
|
@@ -105,7 +129,7 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
105
129
|
|
|
106
130
|
for (const mutation of mutationList) {
|
|
107
131
|
|
|
108
|
-
if(mutation.attributeName == 'class' || (mutation.type === 'attributes'
|
|
132
|
+
if(mutation.attributeName == 'class' || (mutation.type === 'attributes') || mutation.type === 'attributes') {
|
|
109
133
|
|
|
110
134
|
shadowTable.innerHTML = table.innerHTML;
|
|
111
135
|
setupChart(chartElement,chartOuter,shadowTable);
|
|
@@ -146,48 +170,46 @@ export const setEventObservers = function(chartElement:any,chartOuter:any) {
|
|
|
146
170
|
// #endregion
|
|
147
171
|
|
|
148
172
|
// #region GET functions
|
|
149
|
-
export const getChartData = function(chartElement:any
|
|
173
|
+
export const getChartData = function(chartElement:any){
|
|
150
174
|
|
|
151
175
|
|
|
152
|
-
let table =
|
|
176
|
+
let table = chartElement.shadowRoot.querySelector('.chart__wrapper table');
|
|
153
177
|
|
|
154
178
|
let min:any = chartElement.hasAttribute('data-min') ? chartElement.getAttribute('data-min') : 0;
|
|
155
|
-
let max:any = chartElement.hasAttribute('data-max') ? chartElement.getAttribute('data-max') : getLargestValue(table);
|
|
156
|
-
let type:string = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
179
|
+
let max:any = chartElement.hasAttribute('data-max') ? chartElement.getAttribute('data-max') : getLargestValue(chartElement,table);
|
|
180
|
+
//let type:string = chartElement.hasAttribute('data-type') ? chartElement.getAttribute('data-type') : 'column';
|
|
157
181
|
let yaxis:any = chartElement.hasAttribute('data-yaxis') ? chartElement.getAttribute('data-yaxis').split(',') : [];
|
|
158
182
|
let guidelines:any = chartElement.hasAttribute('data-guidelines') ? chartElement.getAttribute('data-guidelines').split(',') : [];
|
|
159
|
-
let targets:any = chartElement.hasAttribute('data-targets') ? JSON.parse(chartElement.getAttribute('data-targets')) : null;
|
|
160
|
-
let events:any = chartElement.hasAttribute('data-events') ? JSON.parse(chartElement.getAttribute('data-events')) : null;
|
|
183
|
+
//let targets:any = chartElement.hasAttribute('data-targets') ? JSON.parse(chartElement.getAttribute('data-targets')) : null;
|
|
184
|
+
//let events:any = chartElement.hasAttribute('data-events') ? JSON.parse(chartElement.getAttribute('data-events')) : null;
|
|
161
185
|
let xaxis:any = chartElement.hasAttribute('data-xaxis') ? chartElement.getAttribute('data-xaxis').split(',') : null;
|
|
162
|
-
let increment = chartElement.hasAttribute('data-increment') ? chartElement.getAttribute('data-increment'): null;
|
|
186
|
+
//let increment = chartElement.hasAttribute('data-increment') ? chartElement.getAttribute('data-increment'): null;
|
|
163
187
|
|
|
164
|
-
let start:any = chartElement.hasAttribute('data-start') ? chartElement.getAttribute('data-start') : 0;
|
|
165
|
-
let end:any = chartElement.hasAttribute('data-end') ? chartElement.getAttribute('data-end') : getLargestValue(table); // TODO - get largest value from the data-xaxis
|
|
188
|
+
//let start:any = chartElement.hasAttribute('data-start') ? chartElement.getAttribute('data-start') : 0;
|
|
189
|
+
//let end:any = chartElement.hasAttribute('data-end') ? chartElement.getAttribute('data-end') : getLargestValue(chartElement,table); // TODO - get largest value from the data-xaxis
|
|
166
190
|
|
|
167
191
|
|
|
168
|
-
let slope:any = chartElement.hasAttribute('data-slope') ? chartElement.getAttribute('data-slope') : null;
|
|
169
|
-
let yInt:any = chartElement.hasAttribute('data-yint') ? chartElement.getAttribute('data-yint') : null;
|
|
192
|
+
//let slope:any = chartElement.hasAttribute('data-slope') ? chartElement.getAttribute('data-slope') : null;
|
|
193
|
+
//let yInt:any = chartElement.hasAttribute('data-yint') ? chartElement.getAttribute('data-yint') : null;
|
|
170
194
|
|
|
171
|
-
return {min,max,
|
|
195
|
+
return {min,max,yaxis,xaxis,guidelines};
|
|
172
196
|
}
|
|
173
197
|
|
|
174
|
-
function getLargestValue(table:any){
|
|
198
|
+
function getLargestValue(chartElement:any,table:any){
|
|
199
|
+
|
|
200
|
+
const selector = chartElement.classList.contains('chart--stacked') ? 'tbody tr' : 'tbody td:not(:first-child)';
|
|
175
201
|
|
|
176
|
-
let values = Array.from(table.querySelectorAll(
|
|
202
|
+
let values = Array.from(table.querySelectorAll(selector)).map((element: any) => {
|
|
177
203
|
|
|
178
|
-
let currentValue
|
|
179
|
-
currentValue = currentValue.replace('£','');
|
|
180
|
-
currentValue = currentValue.replace('%','');
|
|
181
|
-
currentValue = currentValue.replace(',','');
|
|
182
|
-
currentValue = Number.parseFloat(currentValue);
|
|
204
|
+
let currentValue = element.getAttribute('data-numeric');
|
|
183
205
|
|
|
184
206
|
return currentValue;
|
|
185
|
-
})
|
|
207
|
+
});
|
|
186
208
|
|
|
187
|
-
let
|
|
209
|
+
let largestValue:number = Math.max(...values);
|
|
188
210
|
|
|
189
211
|
// TO DO round to the nearest 10, 100, 1000 and so on
|
|
190
|
-
return Math.ceil(
|
|
212
|
+
return Math.ceil(largestValue);
|
|
191
213
|
}
|
|
192
214
|
|
|
193
215
|
const getValues = function(value:number,min:any,max:any,start?:number){
|
|
@@ -227,12 +249,29 @@ const getValues = function(value:number,min:any,max:any,start?:number){
|
|
|
227
249
|
// #endregion
|
|
228
250
|
|
|
229
251
|
// #region SET functions - set data attributes and classes
|
|
230
|
-
export const setCellData = function(chartElement:any,
|
|
252
|
+
export const setCellData = function(chartElement:any,table:any){
|
|
231
253
|
|
|
232
|
-
|
|
254
|
+
Array.from(table.querySelectorAll('tbody tr')).forEach((tr:any) => {
|
|
255
|
+
|
|
256
|
+
let rowValue = 0;
|
|
257
|
+
// Set the data numeric value if not set
|
|
258
|
+
Array.from(tr.querySelectorAll('td:not(:first-child)')).forEach((td:any) => {
|
|
259
|
+
|
|
260
|
+
let value = parseFloat(td.textContent.replace('£','').replace('%','').replace(',',''));
|
|
261
|
+
|
|
262
|
+
td.setAttribute('data-numeric',value);
|
|
263
|
+
td.setAttribute('data-value',td.textContent);
|
|
264
|
+
|
|
265
|
+
let display = getComputedStyle(td).display;
|
|
266
|
+
|
|
267
|
+
if(display != 'none')
|
|
268
|
+
rowValue += value;
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
tr.setAttribute('data-numeric',rowValue);
|
|
272
|
+
});
|
|
233
273
|
|
|
234
|
-
let
|
|
235
|
-
let startDay = min;
|
|
274
|
+
let {min, max} = getChartData(chartElement);
|
|
236
275
|
|
|
237
276
|
Array.from(table.querySelectorAll('tbody tr')).forEach((tr:any, index) => {
|
|
238
277
|
|
|
@@ -240,24 +279,10 @@ export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
|
240
279
|
|
|
241
280
|
tr.setAttribute('part','group');
|
|
242
281
|
|
|
243
|
-
// Set the data numeric value if not set
|
|
244
|
-
Array.from(tr.querySelectorAll('td:not([data-numeric]):not(:first-child)')).forEach((td:any) => {
|
|
245
|
-
|
|
246
|
-
let value = parseFloat(td.textContent.replace('£','').replace('%','').replace(',',''));
|
|
247
|
-
let start = 0;
|
|
248
|
-
if(increment == "days"){
|
|
249
|
-
let dates = td.textContent.split(' - ');
|
|
250
|
-
if(dates[1]){
|
|
251
|
-
|
|
252
|
-
value = numberOfDays(dates[0],dates[1]);
|
|
253
|
-
start = numberOfDays(startDay,dates[0]) - 1;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
282
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
283
|
+
let percent = ((tr.getAttribute('data-numeric') - min)/(max - min)) * 100;
|
|
284
|
+
|
|
285
|
+
tr.style.setProperty('--percent',`${percent}%`)
|
|
261
286
|
|
|
262
287
|
// Set the data label value if not set
|
|
263
288
|
Array.from(tr.querySelectorAll('td:not([data-label])')).forEach((td:any, index) => {
|
|
@@ -271,19 +296,6 @@ export const setCellData = function(chartElement:any,chartOuter:any,table:any){
|
|
|
271
296
|
td.setAttribute('data-label',table.querySelectorAll('thead th')[index].textContent);
|
|
272
297
|
});
|
|
273
298
|
|
|
274
|
-
/*
|
|
275
|
-
if(tr.querySelector('[data-label="Total"]')){
|
|
276
|
-
tr.setAttribute('data-total',tr.querySelector('[data-label="Total"][data-numeric]').getAttribute('data-numeric'));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if(tr.querySelector('[data-label="Min"]')){
|
|
280
|
-
tr.setAttribute('data-min',tr.querySelector('[data-label="Min"][data-numeric]').getAttribute('data-numeric'));
|
|
281
|
-
}
|
|
282
|
-
if(tr.querySelector('[data-label="Max"]')){
|
|
283
|
-
tr.setAttribute('data-max',tr.querySelector('[data-label="Max"][data-numeric]').getAttribute('data-numeric'));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
*/
|
|
287
299
|
|
|
288
300
|
let rowMin = tr.hasAttribute('data-min') ? tr.getAttribute('data-min') : min;
|
|
289
301
|
let rowMax = tr.hasAttribute('data-max') ? tr.getAttribute('data-max') : max;
|
|
@@ -385,6 +397,8 @@ function createChartKeyItem(chartID:string,index:number,text:Array<string>,chart
|
|
|
385
397
|
let input = document.createElement('input');
|
|
386
398
|
input.setAttribute('name',`${chartID}-dataset-${index}`);
|
|
387
399
|
input.setAttribute('id',`${chartID}-dataset-${index}`);
|
|
400
|
+
input.setAttribute('data-dataset',`${index}`);
|
|
401
|
+
input.setAttribute('data-label',`${text}`);
|
|
388
402
|
input.checked = true;
|
|
389
403
|
input.setAttribute('type',`checkbox`);
|
|
390
404
|
|
|
@@ -407,20 +421,13 @@ function createChartKeyItem(chartID:string,index:number,text:Array<string>,chart
|
|
|
407
421
|
return previousInput;
|
|
408
422
|
}
|
|
409
423
|
|
|
410
|
-
export const createChartGuidelines = function(chartElement:any,
|
|
424
|
+
export const createChartGuidelines = function(chartElement:any,chartGuidelines:any){
|
|
411
425
|
|
|
412
|
-
let {min, max, yaxis,
|
|
426
|
+
let {min, max, yaxis, guidelines} = getChartData(chartElement);
|
|
413
427
|
|
|
414
428
|
if(!guidelines.length)
|
|
415
429
|
guidelines = yaxis;
|
|
416
430
|
|
|
417
|
-
|
|
418
|
-
if(increment == "days"){
|
|
419
|
-
|
|
420
|
-
max = numberOfDays(min,max);
|
|
421
|
-
min = 0;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
431
|
chartGuidelines.innerHTML = '';
|
|
425
432
|
for (var i = 0; i < guidelines.length; i++) {
|
|
426
433
|
|
|
@@ -433,56 +440,30 @@ export const createChartGuidelines = function(chartElement:any,chartOuter:any,ch
|
|
|
433
440
|
}
|
|
434
441
|
}
|
|
435
442
|
|
|
436
|
-
export const createChartYaxis = function(chartElement:any,
|
|
437
|
-
|
|
438
|
-
let {min, max, yaxis, increment} = getChartData(chartElement,chartOuter);
|
|
439
|
-
|
|
440
|
-
let startDay = min;
|
|
441
|
-
|
|
442
|
-
if(increment == "days"){
|
|
443
|
-
|
|
444
|
-
max = numberOfDays(min,max);
|
|
445
|
-
min = 0;
|
|
446
|
-
}
|
|
443
|
+
export const createChartYaxis = function(chartElement:any,chartYaxis:any){
|
|
447
444
|
|
|
445
|
+
let {min, max, yaxis} = getChartData(chartElement);
|
|
448
446
|
|
|
449
447
|
chartYaxis.innerHTML = '';
|
|
450
448
|
for (var i = 0; i < yaxis.length; i++) {
|
|
451
449
|
|
|
452
450
|
let value = parseFloat(yaxis[i].replace('£','').replace('%',''));
|
|
453
451
|
|
|
454
|
-
if(increment == "days"){
|
|
455
|
-
|
|
456
|
-
value = numberOfDays(startDay,yaxis[i]);
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
|
|
460
452
|
let { axis } = getValues(value,min,max);
|
|
461
453
|
chartYaxis.innerHTML += `<div class="axis__point" style="--percent:${axis}%;"><span>${yaxis[i]}</span></div>`;
|
|
462
454
|
}
|
|
463
455
|
}
|
|
464
456
|
|
|
465
|
-
export const createXaxis = function(
|
|
457
|
+
export const createXaxis = function(chartOuter:any){
|
|
466
458
|
|
|
467
459
|
const chart = chartOuter.querySelector('.chart');
|
|
468
460
|
let chartXaxis = chartOuter.querySelector('.chart__xaxis');
|
|
469
461
|
|
|
470
|
-
let {increment,start,end} = getChartData(chartElement,chartOuter);
|
|
471
|
-
|
|
472
462
|
if(!chartXaxis){
|
|
473
463
|
chartXaxis = document.createElement('div');
|
|
474
464
|
chartXaxis.setAttribute('class','chart__xaxis');
|
|
475
465
|
}
|
|
476
|
-
if(increment && start && end){
|
|
477
|
-
chartXaxis.innerHTML = '';
|
|
478
|
-
for (var i = 0; i < xaxis.length; i++) {
|
|
479
466
|
|
|
480
|
-
let value = parseFloat(xaxis[i].replace('£','').replace('%',''));
|
|
481
|
-
let position = ((value - start)/(end - start)) * 100;
|
|
482
|
-
|
|
483
|
-
chartXaxis.innerHTML += `<div class="axis__point" style="--percent:${position}%;"><span>${xaxis[i]}</span></div>`;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
467
|
chart.prepend(chartXaxis);
|
|
487
468
|
}
|
|
488
469
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import '@testing-library/jest-dom'
|
|
3
|
+
import {getChartData} from "../modules/chart.module";
|
|
4
|
+
import puppeteer from 'puppeteer';
|
|
5
|
+
import "expect-puppeteer";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import iamBarChart from "../components/barchart/barchart.component";
|
|
9
|
+
|
|
10
|
+
describe('The bar chart component', () => {
|
|
11
|
+
|
|
12
|
+
if (!window.customElements.get(`iam-barchart`))
|
|
13
|
+
window.customElements.define(`iam-barchart`, iamBarChart);
|
|
14
|
+
|
|
15
|
+
document.body.innerHTML = `
|
|
16
|
+
<iam-barchart>
|
|
17
|
+
<table>
|
|
18
|
+
<thead>
|
|
19
|
+
<tr>
|
|
20
|
+
<th>Items</th>
|
|
21
|
+
<th>Value</th>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody>
|
|
25
|
+
<tr>
|
|
26
|
+
<td>Item 1</td>
|
|
27
|
+
<td>300</td>
|
|
28
|
+
</tr>
|
|
29
|
+
<tr>
|
|
30
|
+
<td>Item 2</td>
|
|
31
|
+
<td>150</td>
|
|
32
|
+
</tr>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>Item 3</td>
|
|
35
|
+
<td>100</td>
|
|
36
|
+
</tr>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
</iam-barchart>`;
|
|
40
|
+
|
|
41
|
+
test('should create the min attribute as 0', () => {
|
|
42
|
+
|
|
43
|
+
let component = document.querySelector('iam-barchart');
|
|
44
|
+
let {min} = getChartData(component);
|
|
45
|
+
|
|
46
|
+
expect(min).toEqual(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('should equal the largest single value', () => {
|
|
50
|
+
|
|
51
|
+
let component = document.querySelector('iam-barchart');
|
|
52
|
+
let {max} = getChartData(component);
|
|
53
|
+
|
|
54
|
+
expect(max).toEqual(300);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('should equal the largest single value', () => {
|
|
58
|
+
|
|
59
|
+
let component = document.querySelector('iam-barchart');
|
|
60
|
+
let {max} = getChartData(component);
|
|
61
|
+
|
|
62
|
+
expect(max).toEqual(300);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('should have the class of .chart--fit-content added as there is less than 10 bars', () => {
|
|
66
|
+
|
|
67
|
+
let component = document.querySelector('iam-barchart');
|
|
68
|
+
expect(component.classList).toContain("chart--fit-content");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('should have the class of .chart--no-scale added as there is less than 5 bars', () => {
|
|
72
|
+
|
|
73
|
+
let component = document.querySelector('iam-barchart');
|
|
74
|
+
expect(component.classList).toContain("chart--no-scale");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
package/dist/components.es.js
CHANGED
|
@@ -67,7 +67,7 @@ const Ra = /* @__PURE__ */ m(U, [["render", G]]), J = (t) => t.charAt(0).toUpper
|
|
|
67
67
|
},
|
|
68
68
|
created() {
|
|
69
69
|
this.$nextTick(function() {
|
|
70
|
-
import("./table.component.min-
|
|
70
|
+
import("./table.component.min-e37ebd8f.mjs").then((t) => {
|
|
71
71
|
window.customElements.get("iam-table") || window.customElements.define("iam-table", t.default);
|
|
72
72
|
}).catch((t) => {
|
|
73
73
|
console.log(t.message);
|
|
@@ -453,7 +453,7 @@ const N = /* @__PURE__ */ m(ne, [["render", Se]]), xe = {
|
|
|
453
453
|
},
|
|
454
454
|
created() {
|
|
455
455
|
this.$nextTick(function() {
|
|
456
|
-
import("./fileupload.component.min-
|
|
456
|
+
import("./fileupload.component.min-1428f816.mjs").then((t) => {
|
|
457
457
|
window.customElements.get("iam-fileupload") || window.customElements.define("iam-fileupload", t.default);
|
|
458
458
|
}).catch((t) => {
|
|
459
459
|
console.log(t.message);
|
|
@@ -483,7 +483,7 @@ const qe = {
|
|
|
483
483
|
props: {},
|
|
484
484
|
mounted() {
|
|
485
485
|
this.$nextTick(function() {
|
|
486
|
-
import("./accordion.component.min-
|
|
486
|
+
import("./accordion.component.min-62ce9a03.mjs").then((t) => {
|
|
487
487
|
window.customElements.get("iam-accordion") || window.customElements.define("iam-accordion", t.default);
|
|
488
488
|
}).catch((t) => {
|
|
489
489
|
console.log(t.message);
|
|
@@ -592,7 +592,7 @@ const Va = /* @__PURE__ */ m(Ne, [["render", Fe]]), ze = {
|
|
|
592
592
|
name: "Card",
|
|
593
593
|
created() {
|
|
594
594
|
this.$nextTick(function() {
|
|
595
|
-
import("./card.component.min-
|
|
595
|
+
import("./card.component.min-c7fcb932.mjs").then((t) => {
|
|
596
596
|
window.customElements.get("iam-card") || window.customElements.define("iam-card", t.default);
|
|
597
597
|
}).catch((t) => {
|
|
598
598
|
console.log(t.message);
|
|
@@ -623,7 +623,7 @@ const Fa = /* @__PURE__ */ m(ze, [["render", Be]]), Oe = {
|
|
|
623
623
|
},
|
|
624
624
|
mounted() {
|
|
625
625
|
this.$nextTick(function() {
|
|
626
|
-
import("./carousel.component.min-
|
|
626
|
+
import("./carousel.component.min-561f6fb9.mjs").then((t) => {
|
|
627
627
|
window.customElements.get("iam-carousel") || window.customElements.define("iam-carousel", t.default);
|
|
628
628
|
}).catch((t) => {
|
|
629
629
|
console.log(t.message);
|
|
@@ -652,7 +652,7 @@ const za = /* @__PURE__ */ m(Oe, [["render", We]]), Ke = {
|
|
|
652
652
|
},
|
|
653
653
|
mounted() {
|
|
654
654
|
this.$nextTick(function() {
|
|
655
|
-
import("./header.component.min-
|
|
655
|
+
import("./header.component.min-98618cb0.mjs").then((t) => {
|
|
656
656
|
window.customElements.get("iam-header") || window.customElements.define("iam-header", t.default);
|
|
657
657
|
}).catch((t) => {
|
|
658
658
|
console.log(t.message);
|
|
@@ -1048,7 +1048,7 @@ const Wa = /* @__PURE__ */ m(_t, [["render", Ht]]), Mt = {
|
|
|
1048
1048
|
name: "Nav",
|
|
1049
1049
|
mounted() {
|
|
1050
1050
|
this.$nextTick(function() {
|
|
1051
|
-
import("./nav.component.min-
|
|
1051
|
+
import("./nav.component.min-78e6bbef.mjs").then((t) => {
|
|
1052
1052
|
window.customElements.get("iam-nav") || window.customElements.define("iam-nav", t.default);
|
|
1053
1053
|
}).catch((t) => {
|
|
1054
1054
|
console.log(t.message);
|
|
@@ -1168,7 +1168,7 @@ const Zt = {
|
|
|
1168
1168
|
name: "Tabs",
|
|
1169
1169
|
created() {
|
|
1170
1170
|
this.$nextTick(function() {
|
|
1171
|
-
import("./tabs.component.min-
|
|
1171
|
+
import("./tabs.component.min-6a848435.mjs").then((t) => {
|
|
1172
1172
|
window.customElements.get("iam-tabs") || window.customElements.define("iam-tabs", t.default);
|
|
1173
1173
|
}).catch((t) => {
|
|
1174
1174
|
console.log(t.message);
|
|
@@ -1315,7 +1315,7 @@ function ha(t, a, e, i, r, s) {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
const es = /* @__PURE__ */ m(pa, [["render", ha]]);
|
|
1317
1317
|
/*!
|
|
1318
|
-
* iamKey
|
|
1318
|
+
* iamKey v6.0.0
|
|
1319
1319
|
* Copyright 2022-2024 iamproperty
|
|
1320
1320
|
*/
|
|
1321
1321
|
function fa(t, a) {
|
|
@@ -1485,7 +1485,7 @@ const as = /* @__PURE__ */ m(ka, [["render", Aa]]), La = {
|
|
|
1485
1485
|
props: {},
|
|
1486
1486
|
mounted() {
|
|
1487
1487
|
this.$nextTick(function() {
|
|
1488
|
-
import("./actionbar.component.min-
|
|
1488
|
+
import("./actionbar.component.min-80250f38.mjs").then((t) => {
|
|
1489
1489
|
window.customElements.get("iam-actionbar") || window.customElements.define("iam-actionbar", t.default);
|
|
1490
1490
|
}).catch((t) => {
|
|
1491
1491
|
console.log(t.message);
|
|
@@ -1500,7 +1500,7 @@ function Sa(t, a, e, i, r, s) {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
const ss = /* @__PURE__ */ m(La, [["render", Sa]]);
|
|
1502
1502
|
/*!
|
|
1503
|
-
* iamKey
|
|
1503
|
+
* iamKey v6.0.0
|
|
1504
1504
|
* Copyright 2022-2024 iamproperty
|
|
1505
1505
|
*/
|
|
1506
1506
|
class R extends HTMLElement {
|