@iamproperty/components 7.8.2--beta4 → 7.8.2--beta5
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/actionbar.component.css +1 -1
- package/assets/css/components/actionbar.component.css.map +1 -1
- package/assets/css/components/calendar.component.css +1 -1
- package/assets/css/components/calendar.component.css.map +1 -1
- package/assets/css/components/card.component.css +1 -1
- package/assets/css/components/card.component.css.map +1 -1
- package/assets/css/components/carousel.config.css +1 -1
- package/assets/css/components/carousel.config.css.map +1 -1
- package/assets/css/components/modal.component.css +1 -1
- package/assets/css/components/modal.component.css.map +1 -1
- package/assets/css/components/multi-step-modal.component.css +1 -1
- package/assets/css/components/multi-step-modal.component.css.map +1 -1
- package/assets/css/components/nav.component.css +1 -1
- package/assets/css/components/nav.component.css.map +1 -1
- package/assets/css/components/nav.global.css +1 -1
- package/assets/css/components/nav.global.css.map +1 -1
- package/assets/css/components/notification.global.css +1 -1
- package/assets/css/components/notification.global.css.map +1 -1
- package/assets/css/components/std-nav-standalone.component.css +1 -1
- package/assets/css/components/std-nav-standalone.component.css.map +1 -1
- package/assets/css/components/video-card.component.css +1 -1
- package/assets/css/components/video-card.component.css.map +1 -1
- package/assets/css/components/video-modal.component.css +1 -1
- package/assets/css/components/video-modal.component.css.map +1 -1
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/elements/dialog.css +1 -1
- package/assets/css/elements/dialog.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/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +3 -3
- package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
- package/assets/js/components/advanced-select/advanced-select.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/banner/banner.component.min.js +1 -1
- package/assets/js/components/barchart/barchart.component.min.js +1 -1
- package/assets/js/components/bento-grid/bento-grid.component.min.js +1 -1
- package/assets/js/components/bone/bone.component.min.js +1 -1
- package/assets/js/components/button/button.component.min.js +1 -1
- package/assets/js/components/calendar/calendar.component.min.js +2 -2
- package/assets/js/components/card/card.component.min.js +6 -6
- 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/config/config.component.min.js +1 -1
- package/assets/js/components/content/content.component.min.js +1 -1
- package/assets/js/components/darkmode/darkmode.component.min.js +1 -1
- package/assets/js/components/doughnutchart/doughnutchart.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.component.min.js +1 -1
- package/assets/js/components/filter-card/filter-card.component.min.js +2 -2
- package/assets/js/components/filter-card/filter-card.component.min.js.map +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/form/form.component.js +42 -151
- package/assets/js/components/form/form.component.min.js +3 -3
- package/assets/js/components/form/form.component.min.js.map +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/input/input.component.min.js +1 -1
- package/assets/js/components/input-range/input-range.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/menu/menu.component.min.js +1 -1
- package/assets/js/components/milestone/milestone.component.min.js +1 -1
- package/assets/js/components/milestone-group/milestone-group.component.min.js +1 -1
- package/assets/js/components/modal/modal.component.js +16 -11
- package/assets/js/components/modal/modal.component.min.js +7 -7
- package/assets/js/components/modal/modal.component.min.js.map +1 -1
- package/assets/js/components/multi-step/multi-step.component.min.js +1 -1
- package/assets/js/components/multi-step-modal/multi-step-modal.component.min.js +4 -4
- package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
- package/assets/js/components/nav/nav.component.js +88 -79
- package/assets/js/components/nav/nav.component.min.js +8 -8
- package/assets/js/components/nav/nav.component.min.js.map +1 -1
- package/assets/js/components/notification/notification.component.min.js +2 -2
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/password/password.component.min.js +1 -1
- package/assets/js/components/popover/popover.component.min.js +1 -1
- package/assets/js/components/rank/rank.component.min.js +1 -1
- package/assets/js/components/rankings/rankings.component.min.js +1 -1
- package/assets/js/components/rating/rating.component.min.js +1 -1
- package/assets/js/components/record-card/record-card.component.min.js +2 -2
- package/assets/js/components/record-card/record-card.component.min.js.map +1 -1
- package/assets/js/components/search/search.component.js +2 -1
- package/assets/js/components/search/search.component.min.js +3 -3
- package/assets/js/components/search/search.component.min.js.map +1 -1
- package/assets/js/components/skeleton/skeleton.component.min.js +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/split-button/split-button.component.min.js +1 -1
- package/assets/js/components/std-address-lookup/std-address-lookup.component.min.js +1 -1
- package/assets/js/components/std-nav/std-nav.component.js +2 -0
- package/assets/js/components/std-nav/std-nav.component.min.js +12 -12
- package/assets/js/components/std-nav/std-nav.component.min.js.map +1 -1
- package/assets/js/components/std-nav-standalone/std-nav-standalone.component.min.js +2 -2
- package/assets/js/components/table/table.component.min.js +1 -1
- package/assets/js/components/table-ajax/table-ajax.component.min.js +1 -1
- package/assets/js/components/table-basic/table-basic.component.min.js +1 -1
- package/assets/js/components/table-no-submit/table-no-submit.component.min.js +1 -1
- package/assets/js/components/table-submit/table-submit.component.min.js +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +1 -1
- package/assets/js/components/tag/tag.component.min.js +1 -1
- package/assets/js/components/tooltip/tooltip.component.min.js +1 -1
- package/assets/js/components/video/video.component.min.js +1 -1
- package/assets/js/components/video-card/video-card.component.min.js +6 -6
- package/assets/js/components/video-card/video-card.component.min.js.map +1 -1
- package/assets/js/components/video-modal/video-modal.component.min.js +5 -5
- package/assets/js/components/word-count/word-count.component.min.js +1 -1
- package/assets/js/modules/card.module.js +1 -1
- package/assets/js/modules/form.js +129 -0
- package/assets/js/modules/form.test.js +132 -0
- package/assets/js/modules/test-dom.js +5 -0
- package/assets/js/scripts.bundle.js +1 -1
- package/assets/js/scripts.bundle.min.js +1 -1
- package/assets/sass/_utilities.scss +1 -0
- package/assets/sass/components/carousel.config.scss +5 -0
- package/assets/sass/components/modal.component.scss +5 -1
- package/assets/sass/components/nav.global.scss +0 -10
- package/assets/sass/components/notification.global.scss +8 -0
- package/assets/sass/elements/dialog.scss +43 -0
- package/assets/sass/foundations/colours.scss +0 -24
- package/assets/sass/foundations/reboot.scss +4 -0
- package/assets/sass/utilities/wordpress.css +7 -0
- package/assets/ts/components/form/form.component.ts +54 -213
- package/assets/ts/components/modal/modal.component.ts +27 -19
- package/assets/ts/components/nav/nav.component.ts +107 -95
- package/assets/ts/components/search/search.component.ts +5 -1
- package/assets/ts/components/std-nav/std-nav.component.ts +3 -1
- package/assets/ts/modules/card.module.ts +1 -1
- package/assets/ts/modules/form.test.ts +183 -0
- package/assets/ts/modules/form.ts +210 -0
- package/assets/ts/modules/test-dom.ts +5 -0
- package/dist/components.es.js +24 -24
- package/dist/components.umd.js +143 -143
- package/package.json +1 -1
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
@use 'sass:math';
|
|
2
2
|
@use '../_func' as *;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
4
|
/* Default colour */
|
|
7
5
|
:is(iam-nav,.iam-nav) {
|
|
8
6
|
|
|
9
|
-
> :not([slot="logo"],[slot="secondary"]) {
|
|
10
|
-
color-scheme: light;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
> [slot="secondary"] {
|
|
14
|
-
color-scheme: light;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
7
|
> .nav--menu {
|
|
18
8
|
--colour-heading: var(--colour-primary-theme);
|
|
19
9
|
color-scheme: light;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
@use '../_func' as *;
|
|
2
2
|
|
|
3
3
|
.container.notification__holder {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
position-anchor: --nav;
|
|
7
|
+
|
|
8
|
+
top: anchor(bottom);
|
|
9
|
+
|
|
4
10
|
position: fixed;
|
|
5
11
|
top: var(--nav-height);
|
|
6
12
|
left: 50%;
|
|
@@ -19,6 +25,8 @@
|
|
|
19
25
|
align-content: flex-end;
|
|
20
26
|
align-items: flex-end;
|
|
21
27
|
|
|
28
|
+
|
|
29
|
+
|
|
22
30
|
:is(.iam-notification, iam-notification) {
|
|
23
31
|
pointer-events: all;
|
|
24
32
|
margin: 0.5rem 0 0.5rem 0;
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
padding-bottom: 0;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
|
|
36
37
|
dialog[open]:has(iam-modal) {
|
|
37
38
|
--modal-inner-dialog-display: contents;
|
|
38
39
|
place-self: center;
|
|
39
40
|
}
|
|
41
|
+
|
|
40
42
|
@media (prefers-color-scheme: light) {
|
|
41
43
|
dialog[open]:has(iam-modal) {
|
|
42
44
|
|
|
@@ -47,6 +49,47 @@
|
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
/* Size variants */
|
|
53
|
+
/* small */
|
|
54
|
+
@media screen and (min-width: 36em) {
|
|
55
|
+
|
|
56
|
+
*:not(.dialog__wrapper) > dialog[open]:has(.modal--sm) {
|
|
57
|
+
|
|
58
|
+
min-width: 20.9375rem;
|
|
59
|
+
width: 20.9375rem;
|
|
60
|
+
max-width: 20.9375rem;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media screen and (min-width: 62em) {
|
|
65
|
+
|
|
66
|
+
*:not(.dialog__wrapper) > dialog[open]:has(.modal--sm) {
|
|
67
|
+
min-width: 28.375rem;
|
|
68
|
+
width: 28.375rem;
|
|
69
|
+
max-width: 28.375rem;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* large */
|
|
74
|
+
@media screen and (min-width: 36em) {
|
|
75
|
+
|
|
76
|
+
*:not(.dialog__wrapper) > dialog[open]:has(.modal--lg) {
|
|
77
|
+
min-width: 42.875rem;
|
|
78
|
+
width: 42.875rem;
|
|
79
|
+
max-width: 42.875rem;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media screen and (min-width: 62em) {
|
|
84
|
+
|
|
85
|
+
*:not(.dialog__wrapper) > dialog[open]:has(.modal--lg) {
|
|
86
|
+
min-width: 46rem;
|
|
87
|
+
width: 46rem;
|
|
88
|
+
max-width: 46rem;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
50
93
|
dialog::backdrop {
|
|
51
94
|
background: rgba(0, 0, 0, 0.3);
|
|
52
95
|
backdrop-filter: blur(4px);
|
|
@@ -61,30 +61,6 @@
|
|
|
61
61
|
color: var(--colour-body);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
@media (prefers-color-scheme: dark) {
|
|
66
|
-
html:not(.light-theme) :is(.bg-primary, .bg-danger, .bg-dark):not(iam-header) {
|
|
67
|
-
|
|
68
|
-
--colour-heading: var(--colour-primary-theme);
|
|
69
|
-
--colour-body: var(--colour-primary-theme);
|
|
70
|
-
color: var(--colour-primary-theme);
|
|
71
|
-
|
|
72
|
-
/* Apply the light colour scheme not on the background element but just its children so that the background colour isn't overwritten */
|
|
73
|
-
> * {
|
|
74
|
-
color-scheme: light;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
html:not(.light-theme) .bg-light {
|
|
79
|
-
|
|
80
|
-
color-scheme: light;
|
|
81
|
-
--colour-body: #595959;
|
|
82
|
-
|
|
83
|
-
p {
|
|
84
|
-
color: var(--colour-body);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
64
|
/* #endregion */
|
|
89
65
|
|
|
90
66
|
.invert-colours {
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { trackComponentRegistered } from '../_global';
|
|
2
|
+
import {
|
|
3
|
+
isFormValid,
|
|
4
|
+
showIf,
|
|
5
|
+
hideIf,
|
|
6
|
+
disabledIf,
|
|
7
|
+
enabledIf,
|
|
8
|
+
requiredIf,
|
|
9
|
+
readonlyIf,
|
|
10
|
+
writeIf,
|
|
11
|
+
emptyIf,
|
|
12
|
+
limitCheckboxes
|
|
13
|
+
} from '../../modules/form';
|
|
14
|
+
|
|
15
|
+
trackComponentRegistered('iam-form');
|
|
5
16
|
|
|
6
17
|
class iamForm extends HTMLElement {
|
|
7
18
|
constructor() {
|
|
8
19
|
super();
|
|
9
|
-
this.attachShadow({ mode: 'open' });
|
|
20
|
+
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
10
21
|
|
|
11
22
|
const template = document.createElement('template');
|
|
12
23
|
template.innerHTML = `
|
|
@@ -15,260 +26,90 @@ class iamForm extends HTMLElement {
|
|
|
15
26
|
</div>
|
|
16
27
|
`;
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
isFormValid(form):boolean {
|
|
22
|
-
|
|
23
|
-
if (form.querySelector(':invalid'))
|
|
24
|
-
return false;
|
|
25
|
-
|
|
26
|
-
if (form.querySelector('.pwd-checker[data-strength="1"]') || form.querySelector('.pwd-checker[data-strength="2"]'))
|
|
27
|
-
return false;
|
|
28
|
-
|
|
29
|
-
if (form.querySelector('iam-multiselect[data-is-required][data-error]'))
|
|
30
|
-
return false;
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
checkConditions = (conditions):boolean => {
|
|
36
|
-
|
|
37
|
-
let meetsCondition = true;
|
|
38
|
-
|
|
39
|
-
JSON.parse(conditions).forEach((condition) => {
|
|
40
|
-
if(this.querySelector(`#${condition['if']}`).value != condition['equals'])
|
|
41
|
-
meetsCondition = false;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return meetsCondition;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
showIf = ():void => {
|
|
48
|
-
|
|
49
|
-
Array.from(this.querySelectorAll('[data-show-if]')).forEach((element) => {
|
|
50
|
-
|
|
51
|
-
if(!this.checkConditions(element.getAttribute('data-show-if')))
|
|
52
|
-
element.classList.add('d-none');
|
|
53
|
-
else
|
|
54
|
-
element.classList.remove('d-none');
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
hideIf = ():void => {
|
|
60
|
-
|
|
61
|
-
Array.from(this.querySelectorAll('[data-hide-if]')).forEach((element) => {
|
|
62
|
-
|
|
63
|
-
if(this.checkConditions(element.getAttribute('data-hide-if')))
|
|
64
|
-
element.classList.add('d-none');
|
|
65
|
-
else
|
|
66
|
-
element.classList.remove('d-none');
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
disabledIf = ():void => {
|
|
72
|
-
|
|
73
|
-
Array.from(this.querySelectorAll('[data-disabled-if]')).forEach((element) => {
|
|
74
|
-
|
|
75
|
-
if(this.checkConditions(element.getAttribute('data-disabled-if')))
|
|
76
|
-
element.setAttribute('disabled','disabled');
|
|
77
|
-
else
|
|
78
|
-
element.removeAttribute('disabled');
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
enabledIf = ():void => {
|
|
84
|
-
|
|
85
|
-
Array.from(this.querySelectorAll('[data-enabled-if]')).forEach((element) => {
|
|
86
|
-
|
|
87
|
-
if(!this.checkConditions(element.getAttribute('data-enabled-if')))
|
|
88
|
-
element.setAttribute('disabled','disabled');
|
|
89
|
-
else
|
|
90
|
-
element.removeAttribute('disabled');
|
|
91
|
-
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
requiredIf = ():void => {
|
|
96
|
-
|
|
97
|
-
Array.from(this.querySelectorAll('[data-required-if]')).forEach((element) => {
|
|
98
|
-
|
|
99
|
-
if(this.checkConditions(element.getAttribute('data-required-if')))
|
|
100
|
-
element.setAttribute('required','required');
|
|
101
|
-
else
|
|
102
|
-
element.removeAttribute('required');
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
readonlyIf = ():void => {
|
|
108
|
-
|
|
109
|
-
Array.from(this.querySelectorAll('[data-readonly-if]')).forEach((element) => {
|
|
110
|
-
|
|
111
|
-
if(this.checkConditions(element.getAttribute('data-readonly-if')))
|
|
112
|
-
element.setAttribute('readonly','readonly');
|
|
113
|
-
else
|
|
114
|
-
element.removeAttribute('readonly');
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
writeIf = ():void => {
|
|
120
|
-
|
|
121
|
-
Array.from(this.querySelectorAll('[data-write-if]')).forEach((element) => {
|
|
122
|
-
|
|
123
|
-
if(!this.checkConditions(element.getAttribute('data-write-if')))
|
|
124
|
-
element.setAttribute('readonly','readonly');
|
|
125
|
-
else
|
|
126
|
-
element.removeAttribute('readonly');
|
|
127
|
-
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
emptyIf = ():void => {
|
|
132
|
-
|
|
133
|
-
Array.from(this.querySelectorAll('[data-empty-if]')).forEach((element) => {
|
|
134
|
-
|
|
135
|
-
if(this.checkConditions(element.getAttribute('data-empty-if')))
|
|
136
|
-
element.value = "";
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
getCheckboxLimit = (element):number => {
|
|
142
|
-
|
|
143
|
-
const limit = parseInt(element.getAttribute('data-checkbox-limit') || '10', 10);
|
|
144
|
-
|
|
145
|
-
return !isNaN(limit) && limit > 0 ? limit : 10;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
limitCheckboxes = (event?:Event):void => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const target = event?.target instanceof HTMLInputElement ? event.target : null;
|
|
153
|
-
const changedCheckbox = target?.matches('input[type="checkbox"]') ? target : null;
|
|
154
|
-
const checkboxLimitGroup = changedCheckbox?.closest('[data-checkbox-limit]');
|
|
155
|
-
const checkboxLimitGroups = checkboxLimitGroup
|
|
156
|
-
? [checkboxLimitGroup]
|
|
157
|
-
: [
|
|
158
|
-
...(this.hasAttribute('data-checkbox-limit') ? [this] : []),
|
|
159
|
-
...Array.from(this.querySelectorAll('[data-checkbox-limit]')),
|
|
160
|
-
];
|
|
161
|
-
|
|
162
|
-
checkboxLimitGroups.forEach((group) => {
|
|
163
|
-
|
|
164
|
-
const limit = this.getCheckboxLimit(group);
|
|
165
|
-
const checked = Array.from(group.querySelectorAll('input[type="checkbox"]:checked'));
|
|
166
|
-
const notChecked = Array.from(group.querySelectorAll('input[type="checkbox"]:not(:checked)'));
|
|
167
|
-
|
|
168
|
-
notChecked.forEach((checkbox) => {
|
|
169
|
-
|
|
170
|
-
checkbox.setAttribute('disabled','disabled');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
if(checked.length < limit){
|
|
174
|
-
notChecked.forEach((checkbox) => {
|
|
175
|
-
|
|
176
|
-
checkbox.removeAttribute('disabled');
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if(checked.length <= limit)
|
|
181
|
-
return;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if(changedCheckbox?.checked && group.contains(changedCheckbox)) {
|
|
185
|
-
changedCheckbox.checked = false;
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
checked.slice(limit).forEach((checkbox) => {
|
|
190
|
-
|
|
191
|
-
checkbox.checked = false;
|
|
192
|
-
});
|
|
193
|
-
});
|
|
29
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
194
30
|
}
|
|
195
31
|
|
|
196
32
|
connectedCallback(): void {
|
|
197
33
|
|
|
198
|
-
const form = this.querySelector('form');
|
|
34
|
+
const form = this.querySelector<HTMLFormElement>('form') ?? this;
|
|
199
35
|
|
|
200
36
|
if(!form)
|
|
201
|
-
return
|
|
37
|
+
return;
|
|
202
38
|
|
|
203
39
|
form.setAttribute('novalidate','true');
|
|
204
40
|
|
|
205
41
|
// Form validation
|
|
206
|
-
form.addEventListener('submit', (
|
|
42
|
+
form.addEventListener('submit', (event) => {
|
|
207
43
|
|
|
208
44
|
form.classList.add('was-validated');
|
|
209
45
|
|
|
210
|
-
if (!
|
|
46
|
+
if (!isFormValid(form)) {
|
|
211
47
|
|
|
212
|
-
|
|
213
|
-
form
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
form.querySelector<HTMLInputElement>('input:invalid')?.scrollIntoView();
|
|
214
50
|
}
|
|
215
51
|
});
|
|
216
52
|
|
|
217
53
|
// conditional reveal required fields
|
|
218
|
-
|
|
54
|
+
form.querySelectorAll<HTMLElement>('.conditional [required]').forEach((input) => {
|
|
219
55
|
|
|
220
56
|
input.setAttribute('data-conditional-required','true');
|
|
221
57
|
input.removeAttribute('required');
|
|
222
58
|
});
|
|
223
59
|
|
|
224
60
|
// conditional reveal required fields (for fields inside of components like the address lookup)
|
|
225
|
-
|
|
61
|
+
form.querySelectorAll<HTMLElement>('.conditional [data-required]').forEach((input) => {
|
|
226
62
|
|
|
227
63
|
input.setAttribute('data-conditional-data-required','true');
|
|
228
64
|
input.removeAttribute('data-required');
|
|
229
65
|
});
|
|
230
66
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
67
|
+
showIf(this);
|
|
68
|
+
hideIf(this);
|
|
69
|
+
disabledIf(this);
|
|
70
|
+
enabledIf(this);
|
|
71
|
+
requiredIf(this);
|
|
72
|
+
readonlyIf(this);
|
|
73
|
+
writeIf(this);
|
|
74
|
+
emptyIf(this);
|
|
75
|
+
limitCheckboxes(null, this);
|
|
241
76
|
|
|
242
77
|
form.addEventListener('change', (event) => {
|
|
243
78
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
79
|
+
showIf(this);
|
|
80
|
+
hideIf(this);
|
|
81
|
+
disabledIf(this);
|
|
82
|
+
enabledIf(this);
|
|
83
|
+
requiredIf(this);
|
|
84
|
+
readonlyIf(this);
|
|
85
|
+
writeIf(this);
|
|
86
|
+
emptyIf(this);
|
|
87
|
+
limitCheckboxes(event, form);
|
|
253
88
|
|
|
254
|
-
|
|
89
|
+
form.querySelectorAll<HTMLElement>('.conditional [data-conditional-required], .conditional [data-conditional-data-required]').forEach((input) => {
|
|
255
90
|
|
|
256
91
|
input.removeAttribute('required');
|
|
257
92
|
input.removeAttribute('data-required');
|
|
258
93
|
});
|
|
259
94
|
|
|
260
95
|
|
|
261
|
-
|
|
96
|
+
form.querySelectorAll<HTMLElement>('.conditional [data-conditional-required]').forEach((input) => {
|
|
262
97
|
|
|
263
|
-
const
|
|
98
|
+
const conditionalElement = input.closest<HTMLElement>('.conditional');
|
|
99
|
+
if(!conditionalElement) return;
|
|
100
|
+
|
|
101
|
+
const conditionalStyles = window.getComputedStyle(conditionalElement);
|
|
264
102
|
|
|
265
103
|
if(conditionalStyles.getPropertyValue("display") == 'block')
|
|
266
104
|
input.setAttribute('required', 'required');
|
|
267
105
|
});
|
|
268
106
|
|
|
269
|
-
|
|
107
|
+
form.querySelectorAll<HTMLElement>('.conditional [data-conditional-data-required]').forEach((input) => {
|
|
108
|
+
|
|
109
|
+
const conditionalElement = input.closest<HTMLElement>('.conditional');
|
|
110
|
+
if(!conditionalElement) return;
|
|
270
111
|
|
|
271
|
-
const conditionalStyles = window.getComputedStyle(
|
|
112
|
+
const conditionalStyles = window.getComputedStyle(conditionalElement);
|
|
272
113
|
|
|
273
114
|
if(conditionalStyles.getPropertyValue("display") == 'block')
|
|
274
115
|
input.setAttribute('data-required', 'true');
|
|
@@ -17,7 +17,7 @@ class iamModal extends HTMLElement {
|
|
|
17
17
|
template.innerHTML = `
|
|
18
18
|
<style>
|
|
19
19
|
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
${loadCSS}
|
|
22
22
|
</style>
|
|
23
23
|
<link rel="stylesheet" href="https://kit.fontawesome.com/8bd0fca975.css" crossorigin="anonymous" />
|
|
@@ -41,6 +41,7 @@ class iamModal extends HTMLElement {
|
|
|
41
41
|
|
|
42
42
|
connectedCallback(): void {
|
|
43
43
|
|
|
44
|
+
const hasDialogParent = this.closest('dialog[id]');
|
|
44
45
|
const originalDialog = this.querySelector('dialog');
|
|
45
46
|
|
|
46
47
|
const id = this.hasAttribute('id') ? this.getAttribute('id') : originalDialog?.getAttribute('id');
|
|
@@ -50,6 +51,10 @@ class iamModal extends HTMLElement {
|
|
|
50
51
|
const agreedButton = this.querySelector('button[slot="agreed-button"]') ? this.querySelector('button[slot="agreed-button"]') : this.shadowRoot?.querySelector('[data-agreed]');
|
|
51
52
|
const modalType = this.hasAttribute('data-type') ? this.getAttribute('data-type') : 'passive';
|
|
52
53
|
|
|
54
|
+
|
|
55
|
+
if(hasDialogParent)
|
|
56
|
+
this.classList.add('has-parent-dialog');
|
|
57
|
+
|
|
53
58
|
const agreed = (close = true) => {
|
|
54
59
|
const agreedEvent = new CustomEvent('agreed', {
|
|
55
60
|
detail: { modalId: id },
|
|
@@ -62,20 +67,20 @@ class iamModal extends HTMLElement {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
document.addEventListener('click', (e) => {
|
|
65
|
-
|
|
70
|
+
|
|
66
71
|
if(e.target.matches(`[command="show-modal"][commandfor="${id}"]`) || e.target.matches(`[data-modal="${id}"]`)){
|
|
67
72
|
openModal(this);
|
|
68
73
|
}
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
document.addEventListener('click', (e) => {
|
|
72
|
-
|
|
77
|
+
|
|
73
78
|
if(e.target.matches(`[command="close"][commandfor="${id}"]`)){
|
|
74
79
|
closeModal(this);
|
|
75
80
|
}
|
|
76
81
|
});
|
|
77
|
-
|
|
78
|
-
// Disable the original event
|
|
82
|
+
|
|
83
|
+
// Disable the original event
|
|
79
84
|
originalDialog?.addEventListener('command', (e) => {
|
|
80
85
|
|
|
81
86
|
if (event.command == "show-modal") {
|
|
@@ -103,7 +108,7 @@ class iamModal extends HTMLElement {
|
|
|
103
108
|
if(originalDialog) {
|
|
104
109
|
Array.from(originalDialog?.querySelectorAll('[slot]')).forEach((element) => {
|
|
105
110
|
this.moveBefore(element, originalDialog);
|
|
106
|
-
});
|
|
111
|
+
});
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
closeButton?.addEventListener('click', () => {
|
|
@@ -118,30 +123,33 @@ class iamModal extends HTMLElement {
|
|
|
118
123
|
|
|
119
124
|
agreed();
|
|
120
125
|
});
|
|
121
|
-
|
|
126
|
+
|
|
122
127
|
|
|
123
128
|
this.addEventListener('close-modal', () => {
|
|
124
129
|
closeModal(this);
|
|
125
130
|
});
|
|
126
131
|
|
|
127
|
-
// Hijack the default form submission
|
|
128
|
-
|
|
132
|
+
// Hijack the default form submission
|
|
133
|
+
if(!hasDialogParent){
|
|
134
|
+
originalDialog?.addEventListener('submit', (e) => {
|
|
135
|
+
|
|
136
|
+
if(e.submitter && e.submitter.hasAttribute('formmethod') && e.submitter.getAttribute('formmethod') =="dialog"){
|
|
137
|
+
|
|
138
|
+
closeModal(this);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
agreed(false);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
129
145
|
|
|
130
|
-
if(e.submitter && e.submitter.hasAttribute('formmethod') && e.submitter.getAttribute('formmethod') =="dialog"){
|
|
131
|
-
|
|
132
|
-
closeModal(this);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
agreed(false);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
146
|
|
|
139
147
|
Array.from(this.querySelectorAll('button[type="submit"]')).forEach((button)=> {
|
|
140
148
|
|
|
141
149
|
button.addEventListener('click', (e) => {
|
|
142
150
|
|
|
143
151
|
if(!button.closest('form') && !button.hasAttribute('formmethod')){
|
|
144
|
-
|
|
152
|
+
|
|
145
153
|
agreed();
|
|
146
154
|
}
|
|
147
155
|
});
|
|
@@ -179,7 +187,7 @@ class iamModal extends HTMLElement {
|
|
|
179
187
|
</i>`
|
|
180
188
|
);
|
|
181
189
|
}
|
|
182
|
-
|
|
190
|
+
|
|
183
191
|
}
|
|
184
192
|
}
|
|
185
193
|
|