@madgex/design-system 1.59.2 → 1.59.3
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/coverage/cobertura-coverage.xml +69 -38
- package/coverage/components/accordion/accordion.js.html +1 -1
- package/coverage/components/accordion/index.html +1 -1
- package/coverage/components/inputs/combobox/combobox.js.html +1 -1
- package/coverage/components/inputs/combobox/index.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/Combobox.vue.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +1 -1
- package/coverage/components/inputs/combobox/vue-components/index.html +1 -1
- package/coverage/components/inputs/file-upload/file-upload.js.html +38 -89
- package/coverage/components/inputs/file-upload/index.html +7 -7
- package/coverage/components/inputs/multi-select/index.html +1 -1
- package/coverage/components/inputs/multi-select/multi-select.js.html +1 -1
- package/coverage/components/inputs/multi-select/vue-components/MultiSelect.vue.html +1 -1
- package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckbox.vue.html +1 -1
- package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckboxGroup.vue.html +1 -1
- package/coverage/components/inputs/multi-select/vue-components/index.html +1 -1
- package/coverage/components/inputs/textarea/character-count.js.html +1 -1
- package/coverage/components/inputs/textarea/index.html +1 -1
- package/coverage/components/modal/index.html +1 -1
- package/coverage/components/modal/modal.js.html +1 -1
- package/coverage/components/notification/index.html +1 -1
- package/coverage/components/notification/notification.js.html +1 -1
- package/coverage/components/popover/index.html +1 -1
- package/coverage/components/popover/popover.js.html +1 -1
- package/coverage/components/switch-state/index.html +1 -1
- package/coverage/components/switch-state/switch-state.js.html +1 -1
- package/coverage/components/tabs/index.html +1 -1
- package/coverage/components/tabs/tabs.js.html +1 -1
- package/coverage/index.html +14 -14
- package/coverage/js/common.js.html +1 -1
- package/coverage/js/fractal-scripts/combobox.js.html +1 -1
- package/coverage/js/fractal-scripts/index.html +1 -1
- package/coverage/js/fractal-scripts/notification.js.html +1 -1
- package/coverage/js/fractal-scripts/switch-state.js.html +1 -1
- package/coverage/js/index-fractal.js.html +1 -1
- package/coverage/js/index-polyfills.js.html +8 -2
- package/coverage/js/index-vue.js.html +1 -1
- package/coverage/js/index.html +1 -1
- package/coverage/js/index.js.html +2 -2
- package/coverage/js/polyfills/arrayPrototypeFind.js.html +217 -0
- package/coverage/js/polyfills/closest.js.html +1 -1
- package/coverage/js/polyfills/index.html +35 -5
- package/coverage/js/polyfills/objectAssign.js.html +169 -0
- package/coverage/js/polyfills/remove.js.html +1 -1
- package/coverage/tokens/_config.js.html +1 -1
- package/coverage/tokens/index.html +1 -1
- package/dist/_tokens/css/_tokens.css +1 -1
- package/dist/_tokens/js/_tokens-module.js +1 -1
- package/dist/_tokens/scss/_tokens.scss +1 -1
- package/dist/assets/icons.json +1 -1
- package/dist/css/index.css +1 -1
- package/dist/js/index.js +5 -5
- package/package.json +1 -1
- package/src/components/inputs/file-upload/README.md +5 -3
- package/src/components/inputs/file-upload/_template.njk +1 -1
- package/src/components/inputs/file-upload/file-upload.js +32 -49
- package/src/components/inputs/file-upload/file-upload.scss +5 -5
- package/src/js/index-polyfills.js +2 -0
- package/src/js/index.js +1 -1
- package/src/js/polyfills/arrayPrototypeFind.js +46 -0
- package/src/js/polyfills/objectAssign.js +30 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
- `defaultFileText`: The default text to show in place of a file name when a user has not selected a file yet **required**,
|
|
6
6
|
- `removeButtonText`: The text to show on the button that clears the input when a file has been selected **required**,
|
|
7
7
|
- `hideLabel`: true/false - Add this parameter if you need to visually hide the label **optional**
|
|
8
|
-
**(please see accessibility notes below regarding the use of this parameter)**
|
|
8
|
+
**(please see accessibility notes below regarding the use of this parameter)**
|
|
9
9
|
- `name`: The name of the input field, uses ID unless specified **optional**,
|
|
10
10
|
- `id`: The id attribute of the field, **required**
|
|
11
11
|
- `optional`: Is the input optional, otherwise required **optional**,
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
- `state`: The current state of the input, currently the only allowed value is `error` **optional**,
|
|
16
16
|
- `tooltipMessage`: Toggles a tooltip with this message to appear on the input **optional**
|
|
17
17
|
- `classes`: add extra classes to the trigger - **optional**
|
|
18
|
-
- `fileTypes`: comma separated list of the different types of file you want to allow. It will add the `accept` attribute on the input - **optional ** (see notes on validation)
|
|
18
|
+
- `fileTypes`: comma separated list of the different types of file you want to allow. It will add the `accept` attribute on the input - **optional ** (see notes on validation)
|
|
19
19
|
|
|
20
20
|
## Accessibility
|
|
21
21
|
|
|
22
22
|
This input relies on the browser standard input and its built-in facilities for keyboard and screen reader users.
|
|
23
23
|
Additional accessibility aria attributes are applied to the label `aria-live=polite` to inform users of help text or error messages attributed to a form
|
|
24
24
|
|
|
25
|
-
Avoid using `hideLabel` if you can. Only hide the label when there can be no mistake as to what the input is for,
|
|
25
|
+
Avoid using `hideLabel` if you can. Only hide the label when there can be no mistake as to what the input is for, probably when there is only one input in the form.
|
|
26
26
|
|
|
27
27
|
Useful article: https://www.nngroup.com/articles/form-design-placeholders/
|
|
28
28
|
|
|
@@ -32,6 +32,8 @@ For keyboard users as the file input itself remains visually hidden, when it rec
|
|
|
32
32
|
|
|
33
33
|
The styling falls back completely to a native file input with default design system form field styling if Javascript is not available.
|
|
34
34
|
|
|
35
|
+
The styling falls back to native file input in IE as drag and drop from OS is not working in IE.
|
|
36
|
+
|
|
35
37
|
## Validation
|
|
36
38
|
|
|
37
39
|
The `accept` attribute doesn't validate the types of the selected files; it simply provides hints for browsers to guide users towards selecting the correct file types. It is possible (in most cases) for users to toggle an option in the file chooser that makes it possible to override this and select any file they wish, which could have the incorrect type.
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
-}}
|
|
26
26
|
{%- endset %}
|
|
27
27
|
|
|
28
|
-
<div class="mds-form-element mds-form-element--file{% if params.state %} mds-form-element--{{params.state}}{% endif %}{% if params.classes %} {{params.classes}}{% endif %}" id="{{ params.id }}-container" data-test="input">
|
|
28
|
+
<div class="mds-form-element mds-form-element--file mds-form-element--file-supported{% if params.state %} mds-form-element--{{params.state}}{% endif %}{% if params.classes %} {{params.classes}}{% endif %}" id="{{ params.id }}-container" data-test="input">
|
|
29
29
|
{{ MdsInputLabel({
|
|
30
30
|
labelText: params.labelText,
|
|
31
31
|
hideLabel: params.hideLabel,
|
|
@@ -3,65 +3,48 @@ const selectedFileClass = 'mds-form-element--selected-file';
|
|
|
3
3
|
const dragOverClass = 'mds-form-element--dragover';
|
|
4
4
|
const fileNameContainerClass = '.mds-file-upload__file-name';
|
|
5
5
|
const removeButtonClass = '.mds-file-upload__remove-button';
|
|
6
|
+
const supportedClass = 'mds-form-element--file-supported';
|
|
6
7
|
|
|
7
8
|
const fileUpload = {
|
|
8
9
|
init: () => {
|
|
9
10
|
const fileUploads = Array.from(document.querySelectorAll(fileUploadClass));
|
|
10
11
|
fileUploads.forEach((uploader) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
removeButton.addEventListener('click', (elem) => {
|
|
28
|
-
elem.preventDefault();
|
|
29
|
-
input.value = '';
|
|
30
|
-
fileNameContainer.textContent = '';
|
|
31
|
-
uploader.classList.remove(selectedFileClass);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
['dragover', 'dragenter'].forEach((event) => {
|
|
35
|
-
input.addEventListener(event, (e) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
e.stopPropagation();
|
|
38
|
-
|
|
39
|
-
uploader.classList.add(dragOverClass);
|
|
12
|
+
// fallback for IE
|
|
13
|
+
if (window.document.documentMode) {
|
|
14
|
+
uploader.classList.remove(supportedClass);
|
|
15
|
+
} else {
|
|
16
|
+
const fileNameContainer = uploader.querySelector(fileNameContainerClass);
|
|
17
|
+
const input = uploader.querySelector('input[type=file]');
|
|
18
|
+
const removeButton = uploader.querySelector(removeButtonClass);
|
|
19
|
+
|
|
20
|
+
input.addEventListener('change', () => {
|
|
21
|
+
if (input.files && input.files.length) {
|
|
22
|
+
fileNameContainer.textContent = input.files[0].name;
|
|
23
|
+
uploader.classList.add(selectedFileClass);
|
|
24
|
+
}
|
|
40
25
|
});
|
|
41
|
-
});
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
uploader.classList.remove(dragOverClass);
|
|
27
|
+
removeButton.addEventListener('click', (elem) => {
|
|
28
|
+
elem.preventDefault();
|
|
29
|
+
input.value = '';
|
|
30
|
+
fileNameContainer.textContent = '';
|
|
31
|
+
uploader.classList.remove(selectedFileClass);
|
|
49
32
|
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
input.addEventListener('drop', (e) => {
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
e.stopPropagation();
|
|
55
|
-
|
|
56
|
-
uploader.classList.remove(dragOverClass);
|
|
57
33
|
|
|
58
|
-
|
|
34
|
+
['dragover', 'dragenter'].forEach((event) => {
|
|
35
|
+
input.addEventListener(event, (e) => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
uploader.classList.add(dragOverClass);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
input.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
['dragleave', 'dragend', 'drop'].forEach((event) => {
|
|
42
|
+
input.addEventListener(event, (e) => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
uploader.classList.remove(dragOverClass);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
65
48
|
});
|
|
66
49
|
},
|
|
67
50
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
display: none;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.js .mds-file-upload {
|
|
5
|
+
.js .mds-form-element--file-supported .mds-file-upload {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
background-color: $mds-color-neutral-lightest;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.js .mds-file-upload__input {
|
|
16
|
+
.js .mds-form-element--file-supported .mds-file-upload__input {
|
|
17
17
|
position: relative;
|
|
18
18
|
border: $mds-size-border-width dashed $mds-color-border;
|
|
19
19
|
width: 100%;
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.js .mds-file-upload__prompt {
|
|
65
|
+
.js .mds-form-element--file-supported .mds-file-upload__prompt {
|
|
66
66
|
display: flex;
|
|
67
67
|
align-items: center;
|
|
68
68
|
justify-content: center;
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
@include z-index;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
.js .mds-form-element--selected-file {
|
|
89
|
+
.js .mds-form-element--file-supported .mds-form-element--selected-file {
|
|
90
90
|
@include mq($from: $mds-size-breakpoint-md) {
|
|
91
91
|
width: 50%;
|
|
92
92
|
}
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
.js .mds-form-element--dragover {
|
|
126
|
+
.js .mds-form-element--file-supported .mds-form-element--dragover {
|
|
127
127
|
& .mds-file-upload__input {
|
|
128
128
|
background-color: $mds-color-neutral-white;
|
|
129
129
|
}
|
package/src/js/index.js
CHANGED
|
@@ -18,8 +18,8 @@ import characterCount from '../components/inputs/textarea/character-count';
|
|
|
18
18
|
document.addEventListener('DOMContentLoaded', () => {
|
|
19
19
|
tabs.init();
|
|
20
20
|
accordion.init();
|
|
21
|
-
popovers.init();
|
|
22
21
|
modals.init();
|
|
23
22
|
fileUpload.init();
|
|
24
23
|
characterCount.init();
|
|
24
|
+
popovers.init();
|
|
25
25
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// https://tc39.github.io/ecma262/#sec-array.prototype.find
|
|
2
|
+
if (!Array.prototype.find) {
|
|
3
|
+
Object.defineProperty(Array.prototype, 'find', {
|
|
4
|
+
value: function(predicate) {
|
|
5
|
+
// 1. Let O be ? ToObject(this value).
|
|
6
|
+
if (this == null) {
|
|
7
|
+
throw TypeError('"this" is null or not defined');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var o = Object(this);
|
|
11
|
+
|
|
12
|
+
// 2. Let len be ? ToLength(? Get(O, "length")).
|
|
13
|
+
var len = o.length >>> 0;
|
|
14
|
+
|
|
15
|
+
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
|
16
|
+
if (typeof predicate !== 'function') {
|
|
17
|
+
throw TypeError('predicate must be a function');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
|
21
|
+
var thisArg = arguments[1];
|
|
22
|
+
|
|
23
|
+
// 5. Let k be 0.
|
|
24
|
+
var k = 0;
|
|
25
|
+
|
|
26
|
+
// 6. Repeat, while k < len
|
|
27
|
+
while (k < len) {
|
|
28
|
+
// a. Let Pk be ! ToString(k).
|
|
29
|
+
// b. Let kValue be ? Get(O, Pk).
|
|
30
|
+
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
|
|
31
|
+
// d. If testResult is true, return kValue.
|
|
32
|
+
var kValue = o[k];
|
|
33
|
+
if (predicate.call(thisArg, kValue, k, o)) {
|
|
34
|
+
return kValue;
|
|
35
|
+
}
|
|
36
|
+
// e. Increase k by 1.
|
|
37
|
+
k++;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 7. Return undefined.
|
|
41
|
+
return undefined;
|
|
42
|
+
},
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
if (typeof Object.assign !== 'function') {
|
|
2
|
+
// Must be writable: true, enumerable: false, configurable: true
|
|
3
|
+
Object.defineProperty(Object, 'assign', {
|
|
4
|
+
value: function assign(target, varArgs) {
|
|
5
|
+
// .length of function is 2
|
|
6
|
+
'use strict';
|
|
7
|
+
if (target === null || target === undefined) {
|
|
8
|
+
throw new TypeError('Cannot convert undefined or null to object');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var to = Object(target);
|
|
12
|
+
|
|
13
|
+
for (var index = 1; index < arguments.length; index++) {
|
|
14
|
+
var nextSource = arguments[index];
|
|
15
|
+
|
|
16
|
+
if (nextSource !== null && nextSource !== undefined) {
|
|
17
|
+
for (var nextKey in nextSource) {
|
|
18
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
20
|
+
to[nextKey] = nextSource[nextKey];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
},
|
|
27
|
+
writable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
});
|
|
30
|
+
}
|