@madgex/design-system 1.59.1 → 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.
Files changed (67) hide show
  1. package/__tests__/unit/src/components/combobox.spec.js +1 -1
  2. package/coverage/cobertura-coverage.xml +190 -151
  3. package/coverage/components/accordion/accordion.js.html +1 -1
  4. package/coverage/components/accordion/index.html +1 -1
  5. package/coverage/components/inputs/combobox/combobox.js.html +1 -1
  6. package/coverage/components/inputs/combobox/index.html +1 -1
  7. package/coverage/components/inputs/combobox/vue-components/Combobox.vue.html +68 -38
  8. package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +5 -5
  9. package/coverage/components/inputs/combobox/vue-components/index.html +19 -19
  10. package/coverage/components/inputs/file-upload/file-upload.js.html +38 -89
  11. package/coverage/components/inputs/file-upload/index.html +7 -7
  12. package/coverage/components/inputs/multi-select/index.html +1 -1
  13. package/coverage/components/inputs/multi-select/multi-select.js.html +1 -1
  14. package/coverage/components/inputs/multi-select/vue-components/MultiSelect.vue.html +1 -1
  15. package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckbox.vue.html +1 -1
  16. package/coverage/components/inputs/multi-select/vue-components/MultiSelectCheckboxGroup.vue.html +1 -1
  17. package/coverage/components/inputs/multi-select/vue-components/index.html +1 -1
  18. package/coverage/components/inputs/textarea/character-count.js.html +1 -1
  19. package/coverage/components/inputs/textarea/index.html +1 -1
  20. package/coverage/components/modal/index.html +1 -1
  21. package/coverage/components/modal/modal.js.html +1 -1
  22. package/coverage/components/notification/index.html +1 -1
  23. package/coverage/components/notification/notification.js.html +1 -1
  24. package/coverage/components/popover/index.html +1 -1
  25. package/coverage/components/popover/popover.js.html +1 -1
  26. package/coverage/components/switch-state/index.html +1 -1
  27. package/coverage/components/switch-state/switch-state.js.html +1 -1
  28. package/coverage/components/tabs/index.html +1 -1
  29. package/coverage/components/tabs/tabs.js.html +1 -1
  30. package/coverage/index.html +25 -25
  31. package/coverage/js/common.js.html +1 -1
  32. package/coverage/js/fractal-scripts/combobox.js.html +1 -1
  33. package/coverage/js/fractal-scripts/index.html +1 -1
  34. package/coverage/js/fractal-scripts/notification.js.html +1 -1
  35. package/coverage/js/fractal-scripts/switch-state.js.html +1 -1
  36. package/coverage/js/index-fractal.js.html +1 -1
  37. package/coverage/js/index-polyfills.js.html +8 -2
  38. package/coverage/js/index-vue.js.html +1 -1
  39. package/coverage/js/index.html +1 -1
  40. package/coverage/js/index.js.html +2 -2
  41. package/coverage/js/polyfills/arrayPrototypeFind.js.html +217 -0
  42. package/coverage/js/polyfills/closest.js.html +1 -1
  43. package/coverage/js/polyfills/index.html +35 -5
  44. package/coverage/js/polyfills/objectAssign.js.html +169 -0
  45. package/coverage/js/polyfills/remove.js.html +1 -1
  46. package/coverage/tokens/_config.js.html +1 -1
  47. package/coverage/tokens/index.html +1 -1
  48. package/dist/_tokens/css/_tokens.css +1 -1
  49. package/dist/_tokens/js/_tokens-module.js +1 -1
  50. package/dist/_tokens/scss/_tokens.scss +1 -1
  51. package/dist/assets/icons.json +1 -1
  52. package/dist/css/index.css +1 -1
  53. package/dist/js/index.js +5 -5
  54. package/package.json +1 -1
  55. package/src/components/inputs/combobox/README.md +1 -0
  56. package/src/components/inputs/combobox/_template.njk +4 -4
  57. package/src/components/inputs/combobox/combobox.njk +2 -1
  58. package/src/components/inputs/combobox/combobox.scss +1 -0
  59. package/src/components/inputs/combobox/vue-components/Combobox.vue +16 -6
  60. package/src/components/inputs/file-upload/README.md +5 -3
  61. package/src/components/inputs/file-upload/_template.njk +1 -1
  62. package/src/components/inputs/file-upload/file-upload.js +32 -49
  63. package/src/components/inputs/file-upload/file-upload.scss +5 -5
  64. package/src/js/index-polyfills.js +2 -0
  65. package/src/js/index.js +1 -1
  66. package/src/js/polyfills/arrayPrototypeFind.js +46 -0
  67. package/src/js/polyfills/objectAssign.js +30 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@madgex/design-system",
3
3
  "author": "Madgex",
4
4
  "license": "UNLICENSED",
5
- "version": "1.59.1",
5
+ "version": "1.59.3",
6
6
  "scripts": {
7
7
  "clean": "rimraf dist public tokens/build",
8
8
  "commit": "commit",
@@ -13,6 +13,7 @@
13
13
  - `tooltipMessage`: Toggles a tooltip with this message to appear on the input _optional_
14
14
  - `validationError`: The error message provided by validation _optional_,
15
15
  - `state`: The current state of the input, currently the only allowed value is `error` _optional_
16
+ - `type`: name of the options api e.g "location-lookup"
16
17
 
17
18
  ## Props - Vue component
18
19
 
@@ -5,9 +5,9 @@
5
5
  {%- if params.id -%}
6
6
  {{ params.id }}
7
7
  {%- else -%}
8
- {#
8
+ {#
9
9
  if the id is missing it will be constructed using:
10
- [component name]-[item labelText]-[index]
10
+ [component name]-[item labelText]-[index]
11
11
  e.g. period-next-week-2
12
12
  #}
13
13
  {%- if params.name -%}{{ params.name | lower | trim | replace(' ', '-')}}{%- else -%}
@@ -29,8 +29,8 @@
29
29
  {%- endif -%}
30
30
  {% endset -%}
31
31
 
32
- {%- if comboboxId -%}
33
- <div class="mds-form-element mds-form-element--combobox js-mds-combobox{% if params.classes %} {{params.classes}}{% endif %}{% if params.state %} mds-form-element--{{params.state}}{% endif %}" data-combobox-id="{{ comboboxId }}" data-test="combobox">
32
+ {%- if comboboxId -%}
33
+ <div class="mds-form-element mds-form-element--combobox js-mds-combobox{% if params.classes %} {{params.classes}}{% endif %}{% if params.state %} mds-form-element--{{params.state}}{% endif %}" data-combobox-id="{{ comboboxId }}" data-test="combobox" data-type="{{ params.type }}">
34
34
  {{ MdsInputLabel({
35
35
  labelText: params.labelText,
36
36
  hideLabel: params.hideLabel,
@@ -12,7 +12,8 @@
12
12
  value: value,
13
13
  fallbackTo: fallbackTo,
14
14
  classes: classes,
15
- placeholder: placeholder
15
+ placeholder: placeholder,
16
+ type: type
16
17
  }) }}
17
18
  <br><br>
18
19
  </div>
@@ -15,6 +15,7 @@
15
15
 
16
16
  & .mds-combobox-loading {
17
17
  padding: $mds-size-baseline * 2 0;
18
+ background-color: $mds-color-background-body;
18
19
  & .mds-icon--spinner {
19
20
  display: block;
20
21
  margin: 0 auto;
@@ -10,7 +10,7 @@
10
10
  @keydown.enter.stop.prevent="chooseOption"
11
11
  >
12
12
  <ComboboxInput
13
- @focus="makeActive"
13
+ @change="handleChange"
14
14
  @blur="onInputBlur"
15
15
  :id="comboboxid"
16
16
  :name="name"
@@ -21,7 +21,12 @@
21
21
  :activeDescendent="selectedOptionId"
22
22
  v-model="inputValue"
23
23
  />
24
- <ListBox :id="listBoxId" :aria-labelledby="labelId" :hidden="listBoxHidden" :isLoading="isLoading">
24
+ <ListBox
25
+ :id="listBoxId"
26
+ :aria-labelledby="labelId"
27
+ :hidden="listBoxHidden"
28
+ :isLoading="isLoading"
29
+ >
25
30
  <template>
26
31
  <ListBoxOption
27
32
  v-for="(option, index) in visibleOptions"
@@ -34,9 +39,7 @@
34
39
  />
35
40
  </template>
36
41
  </ListBox>
37
- <div aria-live="polite" role="status" class="mds-visually-hidden">
38
- {{ resultCount }}
39
- </div>
42
+ <div aria-live="polite" role="status" class="mds-visually-hidden">{{ resultCount }}</div>
40
43
  </div>
41
44
  </template>
42
45
 
@@ -111,7 +114,7 @@ export default {
111
114
  // Reset any chosen option if user is typing again
112
115
  this.chosenOption = null;
113
116
  this.searchValue = event.target ? event.target.value : '';
114
- this.makeActive();
117
+ this.handleChange();
115
118
  this.$emit('search', this.searchValue);
116
119
  },
117
120
  },
@@ -182,6 +185,13 @@ export default {
182
185
  makeInactive() {
183
186
  this.expanded = false;
184
187
  },
188
+ handleChange() {
189
+ if (this.searchValue.length > 1) {
190
+ this.makeActive();
191
+ } else {
192
+ this.makeInactive();
193
+ }
194
+ },
185
195
  clickOption(option = this.selectedOption) {
186
196
  this.chosenOption = option;
187
197
  this.makeInactive();
@@ -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, probably when there is only one input in the form.
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
- const fileNameContainer = uploader.querySelector(fileNameContainerClass);
12
- const input = uploader.querySelector('input[type=file]');
13
- const removeButton = uploader.querySelector(removeButtonClass);
14
- let droppedFiles = null;
15
-
16
- function showFiles(file) {
17
- fileNameContainer.textContent = file[0].name;
18
- uploader.classList.add(selectedFileClass);
19
- }
20
-
21
- input.addEventListener('change', () => {
22
- if (input.files && input.files.length) {
23
- showFiles(input.files);
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
- ['dragleave', 'dragend'].forEach((event) => {
44
- input.addEventListener(event, (e) => {
45
- e.preventDefault();
46
- e.stopPropagation();
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
- droppedFiles = e.dataTransfer.files;
34
+ ['dragover', 'dragenter'].forEach((event) => {
35
+ input.addEventListener(event, (e) => {
36
+ e.stopPropagation();
37
+ uploader.classList.add(dragOverClass);
38
+ });
39
+ });
59
40
 
60
- if (droppedFiles) {
61
- input.files = droppedFiles;
62
- showFiles(droppedFiles);
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
  }
@@ -1,3 +1,5 @@
1
1
  import 'svgxuse';
2
2
  import './polyfills/closest';
3
3
  import './polyfills/remove';
4
+ import './polyfills/objectAssign';
5
+ import './polyfills/arrayPrototypeFind';
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
+ }