@iamproperty/components 3.2.0 → 3.4.4
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/core.min.css.map +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/main.js +9 -9
- package/assets/js/modules/accordion.js +1 -0
- package/assets/js/modules/alert.js +37 -53
- package/assets/js/modules/carousel.js +74 -100
- package/assets/js/modules/chart.js +142 -209
- package/assets/js/modules/drawer.js +9 -15
- package/assets/js/modules/file-upload.js +30 -45
- package/assets/js/modules/form.js +111 -157
- package/assets/js/modules/helpers.js +64 -93
- package/assets/js/modules/modal.js +67 -88
- package/assets/js/modules/nav.js +17 -27
- package/assets/js/modules/orderablelist.js +84 -115
- package/assets/js/modules/table.js +387 -521
- package/assets/js/modules/testimonial.js +61 -80
- package/assets/js/modules/youtubevideo.js +104 -135
- package/assets/js/scripts.bundle.js +870 -936
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +3 -3
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/sass/_corefiles.scss +9 -9
- package/assets/sass/_forms.scss +1 -1
- package/assets/sass/_tests/{sass.spec.js → colours.spec.js} +2 -2
- package/assets/sass/_tests/func.spec.js +9 -0
- package/assets/sass/_tests/mixins.spec.js +9 -0
- package/assets/sass/_tests/typography.spec.js +9 -0
- package/assets/ts/main.ts +9 -9
- package/assets/ts/modules/accordion.ts +1 -0
- package/assets/ts/modules/alert.ts +58 -0
- package/assets/ts/modules/carousel.ts +103 -0
- package/assets/ts/modules/chart.ts +219 -0
- package/assets/ts/modules/drawer.ts +17 -0
- package/assets/ts/modules/file-upload.ts +49 -0
- package/assets/ts/modules/form.ts +169 -0
- package/assets/ts/modules/helpers.ts +120 -0
- package/assets/ts/modules/modal.ts +91 -0
- package/assets/ts/modules/nav.ts +29 -0
- package/assets/ts/modules/orderablelist.ts +123 -0
- package/assets/ts/modules/table.ts +586 -0
- package/assets/ts/modules/testimonial.ts +84 -0
- package/assets/ts/modules/youtubevideo.ts +146 -0
- package/dist/components.es.js +405 -421
- package/dist/components.umd.js +8 -8
- package/package.json +48 -35
- package/src/components/Accordion/Accordion.vue +1 -1
- package/src/components/Alert/Alert.vue +1 -1
- package/src/{elements → components}/Card/Card.vue +1 -1
- package/src/components/CardDeck/CardDeck.spec.js +1 -1
- package/src/components/CardDeck/CardDeck.vue +1 -1
- package/src/components/Carousel/Carousel.vue +2 -2
- package/src/components/Chart/Chart.vue +2 -2
- package/src/components/Drawer/Drawer.vue +1 -1
- package/src/{elements → components}/FileUploads/FileUploads.vue +1 -1
- package/src/components/Modal/Modal.vue +1 -1
- package/src/components/Nav/Nav.vue +2 -2
- package/src/components/NoteFeed/NoteFeed.vue +2 -2
- package/src/components/PropertySearchbar/PropertySearchbar.vue +1 -1
- package/src/{elements → components}/Table/Table.vue +1 -1
- package/src/components/Testimonial/Testimonial.vue +1 -1
- package/src/foundations/YoutubeVideo/YoutubeVideo.vue +1 -1
- package/src/index.js +4 -4
- package/assets/.DS_Store +0 -0
- package/assets/css/email.min.css +0 -1
- package/assets/css/email.min.css.map +0 -1
- package/assets/css/error.min.css +0 -1
- package/assets/css/error.min.css.map +0 -1
- package/assets/ts/main.js +0 -57
- package/assets/ts/main.js.map +0 -1
- package/assets/ts/modules/accordion.js +0 -33
- package/assets/ts/modules/accordion.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/components/Accordion/Accordion.screenshot.vue +0 -57
- package/src/components/Accordion/__screenshots__/win32/laptop/Accordion.png +0 -0
- package/src/components/Accordion/__screenshots__/win32/mobile/Accordion.png +0 -0
- package/src/components/Accordion/__screenshots__/win32/tablet/Accordion.png +0 -0
- /package/assets/sass/{elements → components}/buttons.scss +0 -0
- /package/assets/sass/{elements → components}/card.scss +0 -0
- /package/assets/sass/{elements → components}/container.scss +0 -0
- /package/assets/sass/{elements → components}/forms.scss +0 -0
- /package/assets/sass/{elements → components}/links.scss +0 -0
- /package/assets/sass/{elements → components}/lists.scss +0 -0
- /package/assets/sass/{elements → components}/panel.scss +0 -0
- /package/assets/sass/{elements → components}/tables.scss +0 -0
- /package/assets/sass/{elements → components}/tooltips.scss +0 -0
- /package/assets/sass/{elements → foundations}/type.scss +0 -0
- /package/src/{elements → components}/Card/README.md +0 -0
- /package/src/{elements → components}/FileUploads/README.md +0 -0
- /package/src/{elements → components}/Input/Input.vue +0 -0
- /package/src/{elements → components}/Input/README.md +0 -0
- /package/src/{elements → components}/Table/README.md +0 -0
- /package/src/{elements → components}/Table/Table.spec.js +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Global helper functions to help maintain and enhance framework elements.
|
|
4
|
+
* @module Helpers
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Add global classes used by the CSS and later JavaScript.
|
|
9
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
10
|
+
*/
|
|
11
|
+
export const addBodyClasses = (body) => {
|
|
12
|
+
|
|
13
|
+
body.classList.add("js-enabled");
|
|
14
|
+
|
|
15
|
+
if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
|
|
16
|
+
|
|
17
|
+
body.classList.add("ie");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Add global events.
|
|
25
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
26
|
+
*/
|
|
27
|
+
export const addGlobalEvents = (body) => {
|
|
28
|
+
|
|
29
|
+
window.addEventListener('hashchange', function() {
|
|
30
|
+
|
|
31
|
+
const hash = location.hash.replace('#','');
|
|
32
|
+
const label = document.querySelector(`label[for="${hash}"]`);
|
|
33
|
+
const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
|
|
34
|
+
|
|
35
|
+
if(label)
|
|
36
|
+
label.click();
|
|
37
|
+
else if(detail)
|
|
38
|
+
detail.setAttribute('open','open');
|
|
39
|
+
|
|
40
|
+
}, false);
|
|
41
|
+
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
|
|
47
|
+
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
48
|
+
*/
|
|
49
|
+
export const checkElements = (element) => {
|
|
50
|
+
|
|
51
|
+
// Tables
|
|
52
|
+
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
53
|
+
|
|
54
|
+
tableStacked(table);
|
|
55
|
+
tableWrap(table);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
61
|
+
* @param {HTMLElement} table Dom table element
|
|
62
|
+
*/
|
|
63
|
+
export const tableWrap = (table) => {
|
|
64
|
+
|
|
65
|
+
if(!table.parentNode.classList.contains('table__wrapper')){
|
|
66
|
+
|
|
67
|
+
const tableHTML = table.outerHTML;
|
|
68
|
+
|
|
69
|
+
table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Creates data attributes to be used by the CSS for mobile views.
|
|
75
|
+
* @param {HTMLElement} table Dom table element
|
|
76
|
+
*/
|
|
77
|
+
export const tableStacked = (table) => {
|
|
78
|
+
|
|
79
|
+
const colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
80
|
+
const colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
81
|
+
|
|
82
|
+
colRows.forEach((row, index) => {
|
|
83
|
+
|
|
84
|
+
const cells = Array.from(row.querySelectorAll('th, td'));
|
|
85
|
+
|
|
86
|
+
cells.forEach((cell, cellIndex) => {
|
|
87
|
+
|
|
88
|
+
const heading = colHeadings[cellIndex];
|
|
89
|
+
if(typeof heading != "undefined"){
|
|
90
|
+
|
|
91
|
+
let tempDiv = document.createElement("div");
|
|
92
|
+
tempDiv.innerHTML = heading.innerHTML;
|
|
93
|
+
let headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
94
|
+
cell.setAttribute('data-label',headingText);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export const isNumeric = function(str) {
|
|
102
|
+
if (typeof str != "string") return false // we only process strings!
|
|
103
|
+
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
104
|
+
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const zeroPad = (num, places) => String(num).padStart(places, '0')
|
|
108
|
+
|
|
109
|
+
export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
110
|
+
export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ')
|
|
111
|
+
export const unsnake = (str) => str.replace(/_/g, ' ')
|
|
112
|
+
export const snake = (str) => str.replace(/ /g, '_')
|
|
113
|
+
export const safeID = function(str){
|
|
114
|
+
|
|
115
|
+
str = str.toLowerCase();
|
|
116
|
+
str = snake(str);
|
|
117
|
+
str = str.replace(/\W/g,'');
|
|
118
|
+
|
|
119
|
+
return str;
|
|
120
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const modal = (element) => {
|
|
3
|
+
|
|
4
|
+
const links = element.querySelectorAll('.modal__outer a, .modal__outer button');
|
|
5
|
+
const firstLink = links[0]
|
|
6
|
+
const lastLink = links[links.length - 1]
|
|
7
|
+
const modalID = element.getAttribute('id');
|
|
8
|
+
|
|
9
|
+
const closeModal = function(){
|
|
10
|
+
const button = document.querySelector('[href="'+window.location.hash+'"]');
|
|
11
|
+
button.focus();
|
|
12
|
+
window.location.hash = "close";
|
|
13
|
+
history.replaceState("", document.title, window.location.pathname + window.location.search);
|
|
14
|
+
|
|
15
|
+
// If there is more than one video lets make sure there is only one playing at a time.
|
|
16
|
+
if(typeof window.player != "undefined" && typeof window.player.pauseVideo == "function")
|
|
17
|
+
window.player.pauseVideo();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Trap the tab focus inside
|
|
21
|
+
element.addEventListener('keydown', function(e){
|
|
22
|
+
|
|
23
|
+
if(e.key === "Tab" && e.shiftKey && document.activeElement == firstLink){
|
|
24
|
+
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
lastLink.focus();
|
|
27
|
+
}
|
|
28
|
+
else if(e.key === "Tab" && !e.shiftKey && document.activeElement == lastLink) {
|
|
29
|
+
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
firstLink.focus();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ESC will close the open modal
|
|
36
|
+
document.addEventListener("keydown", function(e){
|
|
37
|
+
if (e.key === "Escape" && document.querySelector('.modal:target'))
|
|
38
|
+
closeModal();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
element.addEventListener('click', function(e){
|
|
42
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
43
|
+
|
|
44
|
+
// Close links will close the model by default but we want to remove the hash link also
|
|
45
|
+
if (target.matches('[href="#close"]')) {
|
|
46
|
+
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
closeModal();
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
// Dock the modal to the right or left to make the content behind readable
|
|
52
|
+
else if (target.matches('.modal__dock--right')) {
|
|
53
|
+
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
if(!element.classList.contains('modal--left'))
|
|
56
|
+
element.classList.add('modal--right');
|
|
57
|
+
|
|
58
|
+
element.classList.remove('modal--left');
|
|
59
|
+
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
else if (target.matches('.modal__dock--left')) {
|
|
63
|
+
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
|
|
66
|
+
if(!element.classList.contains('modal--right'))
|
|
67
|
+
element.classList.add('modal--left');
|
|
68
|
+
|
|
69
|
+
element.classList.remove('modal--right');
|
|
70
|
+
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function locationHashChanged() {
|
|
77
|
+
if (location.hash === '#'+modalID) {
|
|
78
|
+
console.log("Modal is now open");
|
|
79
|
+
const videoButton = document.querySelector('.modal:target .modal__inner > .youtube-embed:first-child:last-child a');
|
|
80
|
+
|
|
81
|
+
console.log(videoButton)
|
|
82
|
+
if (videoButton){
|
|
83
|
+
videoButton.click();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
window.onhashchange = locationHashChanged;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default modal
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const navbar = (element) => {
|
|
3
|
+
|
|
4
|
+
Array.from(element.querySelectorAll('details')).forEach((detail, index) => {
|
|
5
|
+
|
|
6
|
+
detail.addEventListener('mouseenter', function(e){
|
|
7
|
+
|
|
8
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
9
|
+
detail.setAttribute('open','true')
|
|
10
|
+
}, false);
|
|
11
|
+
|
|
12
|
+
detail.addEventListener('mouseleave', function(e){
|
|
13
|
+
|
|
14
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
15
|
+
detail.removeAttribute('open')
|
|
16
|
+
}, false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if ('IntersectionObserver' in window) {
|
|
20
|
+
const observer = new IntersectionObserver(
|
|
21
|
+
([e]) => e.target.classList.toggle("is-stuck", e.intersectionRatio < 1),
|
|
22
|
+
{ threshold: [1] }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
observer.observe(element);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default navbar
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
function orderlist(list) {
|
|
3
|
+
const randID = 'list_'+Math.random().toString(36).substr(2, 9);
|
|
4
|
+
const listItems = list.querySelectorAll('li');
|
|
5
|
+
const listCount = listItems.length;
|
|
6
|
+
let draggedRow;
|
|
7
|
+
|
|
8
|
+
list.setAttribute('role','list');
|
|
9
|
+
list.setAttribute('tabindex',0);
|
|
10
|
+
list.setAttribute('aria-label','Use the key tab to buttons to move between list items, once you have selected a list item you can move it up and down using the arrow keys.');
|
|
11
|
+
|
|
12
|
+
list.querySelectorAll('li').forEach((item, index) => {
|
|
13
|
+
|
|
14
|
+
// Make draggable
|
|
15
|
+
item.setAttribute('id',randID+'_row_'+(index+1));
|
|
16
|
+
item.setAttribute('data-order',index+1);
|
|
17
|
+
item.setAttribute('draggable','true');
|
|
18
|
+
item.addEventListener("dragstart", setDraggedRow);
|
|
19
|
+
item.setAttribute('tabindex',0);
|
|
20
|
+
item.setAttribute('role','listitem');
|
|
21
|
+
item.setAttribute('aria-label',`${item.innerText}: ${index+1} of ${listCount} moveable items`);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function setDraggedRow(e) {
|
|
25
|
+
e.dataTransfer.setData("text/plain", e.target.id);
|
|
26
|
+
draggedRow = e.target;
|
|
27
|
+
e.target.classList.add('li--dragging');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function resetItems(){
|
|
31
|
+
|
|
32
|
+
// Re label the rows
|
|
33
|
+
Array.from(list.querySelectorAll('li')).forEach((item, index) => {
|
|
34
|
+
item.classList.remove('li--dragging')
|
|
35
|
+
item.classList.remove('li--dropable')
|
|
36
|
+
item.setAttribute('data-order',index+1);
|
|
37
|
+
item.setAttribute('aria-label',`${item.innerText}: ${index+1} of ${listCount} moveable items`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
list.addEventListener("dragover", function( e ) {
|
|
42
|
+
// prevent default to allow drop
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
}, false);
|
|
45
|
+
|
|
46
|
+
list.addEventListener("dragenter", function( e ) {
|
|
47
|
+
// prevent default to allow drop
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.dataTransfer.dropEffect = "move";
|
|
50
|
+
|
|
51
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
52
|
+
if (target.matches('li')) {
|
|
53
|
+
|
|
54
|
+
target.classList.add('li--dropable')
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, false);
|
|
58
|
+
|
|
59
|
+
list.addEventListener("dragleave", function( e ) {
|
|
60
|
+
// prevent default to allow drop
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
63
|
+
if (target.matches('li')) {
|
|
64
|
+
|
|
65
|
+
target.classList.remove('li--dropable')
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, false);
|
|
69
|
+
|
|
70
|
+
list.addEventListener("drop", function(e) {
|
|
71
|
+
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
|
|
74
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
75
|
+
if (target.matches('li')) {
|
|
76
|
+
|
|
77
|
+
if(target.parentNode != null && draggedRow.parentNode != null && target != draggedRow){
|
|
78
|
+
|
|
79
|
+
draggedRow.parentNode.removeChild( draggedRow );
|
|
80
|
+
|
|
81
|
+
if(draggedRow.getAttribute('data-order') > target.getAttribute('data-order'))
|
|
82
|
+
target.parentNode.insertBefore(draggedRow, target);
|
|
83
|
+
else
|
|
84
|
+
target.parentNode.insertBefore(draggedRow, target.nextElementSibling);
|
|
85
|
+
|
|
86
|
+
resetItems();
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
//tableElement.dispatchEvent(reorderedEvent);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, false);
|
|
95
|
+
|
|
96
|
+
list.addEventListener("keydown", function( e ) {
|
|
97
|
+
|
|
98
|
+
let item = e.target;
|
|
99
|
+
|
|
100
|
+
if(e.keyCode == 38){
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
|
|
103
|
+
if (item.previousElementSibling)
|
|
104
|
+
item.parentNode.insertBefore(item, item.previousElementSibling);
|
|
105
|
+
|
|
106
|
+
item.focus();
|
|
107
|
+
}
|
|
108
|
+
else if(e.keyCode == 40){
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
|
|
111
|
+
if (item.nextElementSibling)
|
|
112
|
+
item.parentNode.insertBefore(item.nextElementSibling, item);
|
|
113
|
+
|
|
114
|
+
item.focus();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
resetItems();
|
|
118
|
+
|
|
119
|
+
}, false);
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default orderlist;
|