@madgex/design-system 3.0.2 → 3.0.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/.eslintignore +2 -0
- package/.eslintrc.js +3 -3
- package/__tests__/.eslintrc.js +3 -3
- package/__tests__/unit/src/components/combobox.spec.js +4 -28
- package/__tests__/unit/src/components/notification.spec.js +14 -12
- package/__tests__/unit/src/components/popover.spec.js +4 -0
- package/__tests__/unit/tasks/css.spec.js +3 -2
- package/__tests__/unit/tasks/jsbundle.spec.js +3 -2
- package/__tests__/unit/tasks/svgsprite.spec.js +3 -2
- package/__tests__/unit/tasks/tokens.spec.js +3 -2
- package/coverage/cobertura-coverage.xml +389 -389
- package/coverage/components/accordion/accordion.js.html +164 -127
- package/coverage/components/accordion/index.html +23 -22
- package/coverage/components/button/button.js.html +3 -2
- package/coverage/components/button/index.html +3 -2
- package/coverage/components/inputs/combobox/combobox.js.html +3 -2
- package/coverage/components/inputs/combobox/index.html +3 -2
- package/coverage/components/inputs/combobox/vue-components/Combobox.vue.html +55 -54
- package/coverage/components/inputs/combobox/vue-components/ListBoxOption.vue.html +9 -8
- package/coverage/components/inputs/combobox/vue-components/index.html +21 -20
- package/coverage/components/inputs/file-upload/file-upload.js.html +7 -3
- package/coverage/components/inputs/file-upload/index.html +3 -2
- package/coverage/components/inputs/textarea/character-count.js.html +13 -3
- package/coverage/components/inputs/textarea/index.html +3 -2
- package/coverage/components/modal/index.html +23 -22
- package/coverage/components/modal/modal.js.html +118 -111
- package/coverage/components/notification/index.html +3 -2
- package/coverage/components/notification/notification.js.html +13 -3
- package/coverage/components/popover/index.html +3 -2
- package/coverage/components/popover/popover.js.html +3 -2
- package/coverage/components/switch-state/index.html +19 -18
- package/coverage/components/switch-state/switch-state.js.html +22 -21
- package/coverage/components/tabs/index.html +3 -2
- package/coverage/components/tabs/tabs.js.html +37 -3
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +52 -51
- package/coverage/js/common.js.html +3 -2
- package/coverage/js/fractal-scripts/combobox.js.html +22 -3
- package/coverage/js/fractal-scripts/index.html +3 -2
- package/coverage/js/fractal-scripts/notification.js.html +13 -3
- package/coverage/js/fractal-scripts/switch-state.js.html +13 -3
- package/coverage/js/index-fractal.js.html +3 -2
- package/coverage/js/index-polyfills.js.html +3 -2
- package/coverage/js/index-vue.js.html +3 -2
- package/coverage/js/index.html +3 -2
- package/coverage/js/index.js.html +3 -2
- package/coverage/js/polyfills/arrayPrototypeFind.js.html +20 -10
- package/coverage/js/polyfills/closest.js.html +8 -4
- package/coverage/js/polyfills/index.html +3 -2
- package/coverage/js/polyfills/objectAssign.js.html +19 -9
- package/coverage/js/polyfills/remove.js.html +3 -2
- package/coverage/tokens/_config.js.html +3 -2
- package/coverage/tokens/index.html +3 -2
- package/cypress/.eslintrc.js +6 -6
- package/cypress/fixtures/testuploadfile.txt +1 -0
- package/cypress/integration/components/accordion.spec.js +40 -3
- package/cypress/integration/components/button.spec.js +2 -3
- package/cypress/integration/components/card.spec.js +2 -3
- package/cypress/integration/components/icons.spec.js +10 -0
- package/cypress/integration/components/{combobox.spec.js → inputs/combobox.spec.js} +6 -0
- package/cypress/integration/components/inputs/file-upload.spec.js +45 -0
- package/cypress/integration/components/{input.spec.js → inputs/input.spec.js} +1 -1
- package/cypress/integration/components/inputs/label.spec.js +15 -0
- package/cypress/integration/components/inputs/radio.spec.js +20 -0
- package/cypress/integration/components/inputs/select.spec.js +31 -0
- package/cypress/integration/components/inputs/textarea.spec.js +23 -0
- package/cypress/integration/components/modal.spec.js +65 -0
- package/cypress/integration/components/notifications.spec.js +35 -0
- package/cypress/integration/components/popover.spec.js +36 -0
- package/cypress/integration/components/skip-link.spec.js +9 -0
- package/cypress/plugins/index.js +1 -1
- package/cypress/support/commands.js +14 -0
- package/cypress/support/index.js +2 -0
- package/dist/_tokens/css/_tokens.css +1 -1
- package/dist/_tokens/js/_tokens-module.js +455 -1
- package/dist/_tokens/scss/_tokens.scss +4 -4
- package/dist/assets/icons.json +1 -1
- package/dist/assets/icons.svg +6 -1
- package/dist/js/index.js +1 -1
- package/fractal.js +2 -0
- package/package.json +59 -54
- package/server.js +1 -1
- package/src/components/accordion/accordion.config.js +9 -12
- package/src/components/accordion/accordion.js +12 -0
- package/src/components/inputs/file-upload/file-upload.js +1 -0
- package/src/components/inputs/textarea/character-count.js +3 -0
- package/src/components/modal/modal.js +3 -1
- package/src/components/notification/notification.js +3 -0
- package/src/components/skip-link/skip-link.njk +11 -1
- package/src/components/tabs/tabs.js +11 -0
- package/src/js/fractal-scripts/combobox.js +6 -0
- package/src/js/fractal-scripts/notification.js +3 -0
- package/src/js/fractal-scripts/switch-state.js +3 -0
- package/src/js/polyfills/arrayPrototypeFind.js +9 -6
- package/src/js/polyfills/closest.js +2 -1
- package/src/js/polyfills/objectAssign.js +9 -6
- package/tasks/colorTransforms.js +4 -0
- package/tasks/createMacroIndex.js +1 -0
- package/tasks/css.js +3 -0
- package/tasks/fractal.js +2 -0
- package/tasks/js-bundle.js +6 -2
- package/tasks/svgsprite.js +31 -21
- package/tasks/tokens.js +2 -0
- package/__tests__/unit/src/components/accordion.spec.js +0 -88
- package/__tests__/unit/src/components/modal.spec.js +0 -87
- package/__tests__/unit/src/components/switch-state.spec.js +0 -21
- package/cypress/integration/components/textarea.spec.js +0 -9
- /package/cypress/integration/components/{checkbox-list.spec.js → inputs/checkbox-list.spec.js} +0 -0
- /package/cypress/integration/components/{single-checkbox.spec.js → inputs/single-checkbox.spec.js} +0 -0
package/fractal.js
CHANGED
|
@@ -30,6 +30,7 @@ const icons = require(path.resolve(__dirname, './dist/assets/icons.json')); //es
|
|
|
30
30
|
|
|
31
31
|
// import README.MD into homepage docs
|
|
32
32
|
let pkgReadme = fs.readFileSync(path.join(__dirname, 'README.md'), 'utf8');
|
|
33
|
+
|
|
33
34
|
pkgReadme = pkgReadme.split('\n');
|
|
34
35
|
pkgReadme.shift(0); // drop first line (h1)
|
|
35
36
|
pkgReadme = pkgReadme.join('\n');
|
|
@@ -82,6 +83,7 @@ const madgexTheme = mandelbrot({
|
|
|
82
83
|
styles: ['default', '/assets/css/styles.css'],
|
|
83
84
|
// scripts: ['default', '/assets/theme/js/scripts.js'],
|
|
84
85
|
});
|
|
86
|
+
|
|
85
87
|
/*
|
|
86
88
|
* Specify a template directory to override any view templates
|
|
87
89
|
*/
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@madgex/design-system",
|
|
3
3
|
"author": "Madgex",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.3",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rimraf dist public tokens/build",
|
|
8
8
|
"commit": "commit",
|
|
@@ -10,97 +10,101 @@
|
|
|
10
10
|
"tokens": "style-dictionary --config ./src/tokens/_config.js build",
|
|
11
11
|
"dev": "cross-env NODE_ENV=development gulp dev",
|
|
12
12
|
"debug": "node --inspect ./node_modules/.bin/gulp dev",
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "gulp build",
|
|
14
14
|
"build:icons": "svgo -f src/icons ./dist/assets/icons",
|
|
15
|
-
"build:webpack": "
|
|
16
|
-
"build:fractal": "
|
|
15
|
+
"build:webpack": "webpack",
|
|
16
|
+
"build:fractal": "fractal build",
|
|
17
17
|
"prepublishOnly": "npm run build",
|
|
18
18
|
"lint": "eslint .",
|
|
19
19
|
"lint-fix": "eslint . --fix",
|
|
20
20
|
"test": "jest",
|
|
21
21
|
"cypress": "cypress run",
|
|
22
|
-
"cypress:open": "cypress open"
|
|
22
|
+
"cypress:open": "cypress open",
|
|
23
|
+
"lint-staged": "lint-staged"
|
|
23
24
|
},
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|
|
26
27
|
"url": "https://github.com/madgex/madgex-design-system"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@ctrl/tinycolor": "^
|
|
30
|
-
"@popperjs/core": "2.
|
|
31
|
-
"css-loader": "^
|
|
30
|
+
"@ctrl/tinycolor": "^3.4.0",
|
|
31
|
+
"@popperjs/core": "2.9.2",
|
|
32
|
+
"css-loader": "^5.2.6",
|
|
32
33
|
"document-register-element": "^1.14.3",
|
|
33
34
|
"postcss": "^8.3.5",
|
|
34
35
|
"postcss-cli": "^8.3.1",
|
|
35
|
-
"postcss-loader": "^6.1.
|
|
36
|
-
"sass-loader": "^
|
|
37
|
-
"style-dictionary": "^
|
|
38
|
-
"style-loader": "^0.
|
|
36
|
+
"postcss-loader": "^6.1.1",
|
|
37
|
+
"sass-loader": "^12.1.0",
|
|
38
|
+
"style-dictionary": "^3.0.1",
|
|
39
|
+
"style-loader": "^3.0.0",
|
|
39
40
|
"svgxuse": "^1.2.6",
|
|
40
|
-
"vue": "^2.6.
|
|
41
|
-
"vue-custom-element": "^3.
|
|
41
|
+
"vue": "^2.6.14",
|
|
42
|
+
"vue-custom-element": "^3.3.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "^7.
|
|
45
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
46
|
-
"@babel/preset-env": "^7.
|
|
47
|
-
"@babel/runtime": "^7.
|
|
48
|
-
"@commitlint/cli": "^12.
|
|
49
|
-
"@commitlint/config-conventional": "^12.
|
|
50
|
-
"@commitlint/prompt-cli": "^12.
|
|
45
|
+
"@babel/core": "^7.14.6",
|
|
46
|
+
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
47
|
+
"@babel/preset-env": "^7.14.7",
|
|
48
|
+
"@babel/runtime": "^7.14.6",
|
|
49
|
+
"@commitlint/cli": "^12.1.4",
|
|
50
|
+
"@commitlint/config-conventional": "^12.1.4",
|
|
51
|
+
"@commitlint/prompt-cli": "^12.1.4",
|
|
51
52
|
"@frctl/fractal": "^1.5.8",
|
|
52
53
|
"@frctl/mandelbrot": "^1.9.2",
|
|
53
54
|
"@frctl/nunjucks": "^2.0.11",
|
|
54
55
|
"@madgex/eslint-config-madgex": "^1.4.1",
|
|
55
56
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
56
|
-
"@vue/test-utils": "^1.
|
|
57
|
+
"@vue/test-utils": "^1.2.1",
|
|
57
58
|
"autoprefixer": "^10.2.6",
|
|
58
|
-
"axe-core": "^
|
|
59
|
+
"axe-core": "^4.2.3",
|
|
59
60
|
"babel-core": "^7.0.0-bridge.0",
|
|
60
|
-
"babel-jest": "^
|
|
61
|
-
"babel-loader": "^8.
|
|
62
|
-
"bubleify": "^
|
|
61
|
+
"babel-jest": "^27.0.6",
|
|
62
|
+
"babel-loader": "^8.2.2",
|
|
63
|
+
"bubleify": "^2.0.0",
|
|
63
64
|
"commitizen": "^4.2.4",
|
|
64
65
|
"concurrently": "^6.2.0",
|
|
65
|
-
"core-js": "^3.
|
|
66
|
+
"core-js": "^3.15.2",
|
|
66
67
|
"cross-env": "^7.0.3",
|
|
67
68
|
"cssnano": "^5.0.6",
|
|
68
69
|
"cypress": "^6.9.1",
|
|
69
70
|
"cypress-axe": "^0.12.2",
|
|
70
71
|
"cypress-commands": "^1.1.0",
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
72
|
+
"cypress-file-upload": "^5.0.8",
|
|
73
|
+
"cypress-plugin-tab": "^1.0.5",
|
|
74
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
75
|
+
"del": "^6.0.0",
|
|
76
|
+
"eslint": "^7.30.0",
|
|
77
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
|
75
78
|
"eslint-config-prettier": "^7.2.0",
|
|
76
|
-
"eslint-plugin-cypress": "^2.11.
|
|
77
|
-
"eslint-plugin-import": "^2.
|
|
78
|
-
"eslint-plugin-prettier": "^3.
|
|
79
|
-
"eslint-plugin-promise": "^4.
|
|
80
|
-
"eslint-plugin-vue": "^7.
|
|
79
|
+
"eslint-plugin-cypress": "^2.11.3",
|
|
80
|
+
"eslint-plugin-import": "^2.23.4",
|
|
81
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
82
|
+
"eslint-plugin-promise": "^4.3.1",
|
|
83
|
+
"eslint-plugin-vue": "^7.13.0",
|
|
81
84
|
"file-loader": "^6.2.0",
|
|
82
|
-
"flat": "^
|
|
83
|
-
"globby": "^11.0.
|
|
85
|
+
"flat": "^5.0.2",
|
|
86
|
+
"globby": "^11.0.4",
|
|
84
87
|
"gulp": "^4.0.2",
|
|
85
|
-
"husky": "^
|
|
86
|
-
"jest": "^
|
|
87
|
-
"jsdom": "^
|
|
88
|
+
"husky": "^7.0.1",
|
|
89
|
+
"jest": "^27.0.6",
|
|
90
|
+
"jsdom": "^16.6.0",
|
|
88
91
|
"link-module-alias": "^1.2.0",
|
|
89
|
-
"lint-staged": "^
|
|
90
|
-
"mini-css-extract-plugin": "^1.
|
|
91
|
-
"node-sass": "^
|
|
92
|
-
"nunjucks": "^3.2.
|
|
93
|
-
"prettier": "^2.2
|
|
94
|
-
"rimraf": "^
|
|
92
|
+
"lint-staged": "^11.0.0",
|
|
93
|
+
"mini-css-extract-plugin": "^2.1.0",
|
|
94
|
+
"node-sass": "^6.0.1",
|
|
95
|
+
"nunjucks": "^3.2.3",
|
|
96
|
+
"prettier": "^2.3.2",
|
|
97
|
+
"rimraf": "^3.0.2",
|
|
95
98
|
"semantic-release": "^17.4.4",
|
|
96
|
-
"svg-sprite-loader": "^
|
|
97
|
-
"svgo": "^
|
|
99
|
+
"svg-sprite-loader": "^6.0.9",
|
|
100
|
+
"svgo": "^2.3.1",
|
|
98
101
|
"svgo-loader": "^3.0.0",
|
|
99
102
|
"svgstore": "^3.0.0-2",
|
|
100
|
-
"vue-jest": "^3.0.
|
|
101
|
-
"vue-loader": "^15.9.
|
|
102
|
-
"vue-
|
|
103
|
-
"
|
|
103
|
+
"vue-jest": "^3.0.7",
|
|
104
|
+
"vue-loader": "^15.9.7",
|
|
105
|
+
"vue-loader-plugin": "^1.3.0",
|
|
106
|
+
"vue-template-compiler": "^2.6.14",
|
|
107
|
+
"webpack": "^5.43.0",
|
|
104
108
|
"webpack-cli": "^4.7.2",
|
|
105
109
|
"webpack-dev-server": "^3.11.2",
|
|
106
110
|
"webpack-stream": "^6.1.2"
|
|
@@ -112,7 +116,8 @@
|
|
|
112
116
|
},
|
|
113
117
|
"husky": {
|
|
114
118
|
"hooks": {
|
|
115
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
119
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
120
|
+
"pre-commit": "lint-staged"
|
|
116
121
|
}
|
|
117
122
|
},
|
|
118
123
|
"lint-staged": {
|
package/server.js
CHANGED
|
@@ -3,19 +3,16 @@ const tokens = require('../../../dist/_tokens/js/_tokens-module');
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
title: 'Accordion',
|
|
5
5
|
label: 'Accordion',
|
|
6
|
+
context: {
|
|
7
|
+
name: 'Taxonomy',
|
|
8
|
+
triggerLabel: 'View more categories',
|
|
9
|
+
triggerLabelActive: 'View less categories',
|
|
10
|
+
triggerNoJsHidden: true,
|
|
11
|
+
content:
|
|
12
|
+
'<dl class="mds-list mds-list--definition mds-list--border"><dt class="mds-list__key">Hours</dt><dd class="mds-list__value">Full time</dd><dt class="mds-list__key">Contract</dt><dd class="mds-list__value">Permanent</dd><dt class="mds-list__key">Industry</dt><dd class="mds-list__value">Accountant, Manager</dd></dl>',
|
|
13
|
+
id: 'taxonomy',
|
|
14
|
+
},
|
|
6
15
|
variants: [
|
|
7
|
-
{
|
|
8
|
-
name: 'Taxonomy',
|
|
9
|
-
context: {
|
|
10
|
-
name: 'Taxonomy',
|
|
11
|
-
triggerLabel: 'View more categories',
|
|
12
|
-
triggerLabelActive: 'View less categories',
|
|
13
|
-
triggerNoJsHidden: true,
|
|
14
|
-
content:
|
|
15
|
-
'<dl class="mds-list mds-list--definition mds-list--border"><dt class="mds-list__key">Hours</dt><dd class="mds-list__value">Full time</dd><dt class="mds-list__key">Contract</dt><dd class="mds-list__value">Permanent</dd><dt class="mds-list__key">Industry</dt><dd class="mds-list__value">Accountant, Manager</dd></dl>',
|
|
16
|
-
id: 'taxonomy',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
16
|
{
|
|
20
17
|
name: 'Alternative icons',
|
|
21
18
|
context: {
|
|
@@ -14,6 +14,7 @@ const accordion = {
|
|
|
14
14
|
accordionTriggerList.forEach((trigger) => {
|
|
15
15
|
const accordionContent = trigger.nextElementSibling;
|
|
16
16
|
const isAccordion = accordion.checkBreakpoint(trigger, screenWidth);
|
|
17
|
+
|
|
17
18
|
if (isAccordion) {
|
|
18
19
|
accordion.setAccordion(trigger, accordionContent);
|
|
19
20
|
} else {
|
|
@@ -35,16 +36,19 @@ const accordion = {
|
|
|
35
36
|
case 'px':
|
|
36
37
|
breakpoint = breakpointValue;
|
|
37
38
|
break;
|
|
39
|
+
|
|
38
40
|
case 'em':
|
|
39
41
|
fontSize = window.getComputedStyle(document.querySelector('body'))['font-size'];
|
|
40
42
|
conversionValue = breakpointValue * parseFloat(fontSize);
|
|
41
43
|
breakpoint = conversionValue;
|
|
42
44
|
break;
|
|
45
|
+
|
|
43
46
|
case 'rem':
|
|
44
47
|
fontSize = window.getComputedStyle(document.querySelector('body'))['font-size'];
|
|
45
48
|
conversionValue = breakpointValue * parseFloat(fontSize);
|
|
46
49
|
breakpoint = conversionValue;
|
|
47
50
|
break;
|
|
51
|
+
|
|
48
52
|
default:
|
|
49
53
|
return true;
|
|
50
54
|
}
|
|
@@ -55,6 +59,7 @@ const accordion = {
|
|
|
55
59
|
|
|
56
60
|
return true;
|
|
57
61
|
}
|
|
62
|
+
|
|
58
63
|
return true;
|
|
59
64
|
},
|
|
60
65
|
setAccordion: (accordionTrigger, accordionContent) => {
|
|
@@ -63,16 +68,19 @@ const accordion = {
|
|
|
63
68
|
const labelText = label.innerText;
|
|
64
69
|
const isNonClosing = accordionTrigger.classList.contains(accordionNonClosingClass);
|
|
65
70
|
const triggerButton = accordion.createButton(triggerContainer);
|
|
71
|
+
|
|
66
72
|
triggerContainer.classList.remove('mds-display-none');
|
|
67
73
|
if (accordionContent.nodeName.toLowerCase() !== 'fieldset') {
|
|
68
74
|
accordionContent.setAttribute('aria-label', labelText);
|
|
69
75
|
}
|
|
76
|
+
|
|
70
77
|
triggerContainer.innerHTML = '';
|
|
71
78
|
triggerContainer.appendChild(triggerButton);
|
|
72
79
|
|
|
73
80
|
if (triggerContainer.dataset.expanded) {
|
|
74
81
|
accordion.toggleExpand(triggerButton, triggerContainer, accordionContent, isNonClosing);
|
|
75
82
|
}
|
|
83
|
+
|
|
76
84
|
triggerButton.addEventListener('click', (elem) => {
|
|
77
85
|
elem.preventDefault();
|
|
78
86
|
accordion.toggleExpand(triggerButton, triggerContainer, accordionContent, isNonClosing);
|
|
@@ -81,6 +89,7 @@ const accordion = {
|
|
|
81
89
|
createButton: (element) => {
|
|
82
90
|
const accordionTriggerSpan = element.querySelector(`.${accordionTriggerClass} > span`);
|
|
83
91
|
const accordionTriggerButton = document.createElement('button');
|
|
92
|
+
|
|
84
93
|
accordionTriggerButton.className = accordionTriggerButtonClass;
|
|
85
94
|
// can't use multiple arguments in classList.add() due to IE
|
|
86
95
|
accordionTriggerButton.classList.add('mds-button');
|
|
@@ -98,9 +107,11 @@ const accordion = {
|
|
|
98
107
|
|
|
99
108
|
if (element.dataset.labelinverse) {
|
|
100
109
|
const labelToInverse = element.textContent;
|
|
110
|
+
|
|
101
111
|
element.textContent = element.dataset.labelinverse;
|
|
102
112
|
element.setAttribute(accordionLabelInverseData, labelToInverse);
|
|
103
113
|
}
|
|
114
|
+
|
|
104
115
|
return element;
|
|
105
116
|
},
|
|
106
117
|
toggleExpand: (triggerButton, triggerContainer, accordionContent, isNonClosing) => {
|
|
@@ -127,6 +138,7 @@ const accordion = {
|
|
|
127
138
|
triggerContainer.classList.remove(accordionTriggerExpandedClass);
|
|
128
139
|
accordionContent.classList.remove(accordionContentExpandedClass);
|
|
129
140
|
}
|
|
141
|
+
|
|
130
142
|
accordion.switchLabel(accordionTriggerButtonLabel);
|
|
131
143
|
},
|
|
132
144
|
};
|
|
@@ -9,6 +9,7 @@ const fileUpload = {
|
|
|
9
9
|
init: () => {
|
|
10
10
|
if (!fileUpload.isBrowserIE()) {
|
|
11
11
|
const fileUploads = Array.from(document.querySelectorAll(fileUploadClass));
|
|
12
|
+
|
|
12
13
|
fileUploads.forEach((uploader) => {
|
|
13
14
|
uploader.classList.add(supportedClass);
|
|
14
15
|
const fileNameContainer = uploader.querySelector(fileNameContainerClass);
|
|
@@ -7,11 +7,13 @@ const formControlClass = '.mds-form-control';
|
|
|
7
7
|
const characterCount = {
|
|
8
8
|
init: () => {
|
|
9
9
|
const elementsWithCharacterCount = Array.from(document.querySelectorAll(characterCountClass));
|
|
10
|
+
|
|
10
11
|
elementsWithCharacterCount.forEach((element) => {
|
|
11
12
|
const formControl = element.querySelector(formControlClass);
|
|
12
13
|
const maxLength = formControl.getAttribute('maxlength');
|
|
13
14
|
const message = element.querySelector(messageClass);
|
|
14
15
|
const characterCountNumber = element.querySelector(characterCountNumberClass);
|
|
16
|
+
|
|
15
17
|
formControl.removeAttribute('maxlength');
|
|
16
18
|
characterCount.updateCounter(formControl, maxLength, characterCountNumber, message);
|
|
17
19
|
formControl.addEventListener('keyup', (e) => {
|
|
@@ -25,6 +27,7 @@ const characterCount = {
|
|
|
25
27
|
const newLines = formControl.value.match(/(\r\n|\n|\r)/g);
|
|
26
28
|
const currentCount = formControl.value.length + (newLines ? newLines.length : 0);
|
|
27
29
|
const remainingCount = maxLength - currentCount;
|
|
30
|
+
|
|
28
31
|
characterCountNumber.textContent = remainingCount;
|
|
29
32
|
if (remainingCount < 0) {
|
|
30
33
|
message.classList.add('mds-form-message--error');
|
|
@@ -9,6 +9,7 @@ let focusedElementBeforeModal;
|
|
|
9
9
|
const modals = {
|
|
10
10
|
init: () => {
|
|
11
11
|
const screenWidth = window.innerWidth;
|
|
12
|
+
|
|
12
13
|
if (screenWidth > breakpoint) {
|
|
13
14
|
const triggersList = Array.from(document.querySelectorAll(`[${modalTrigger}]`));
|
|
14
15
|
|
|
@@ -26,6 +27,7 @@ const modals = {
|
|
|
26
27
|
const focusableElementsString =
|
|
27
28
|
'a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]';
|
|
28
29
|
let focusableElements = modal.querySelectorAll(focusableElementsString);
|
|
30
|
+
|
|
29
31
|
// Convert NodeList to Array
|
|
30
32
|
focusableElements = Array.prototype.slice.call(focusableElements);
|
|
31
33
|
|
|
@@ -48,7 +50,7 @@ const modals = {
|
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
closeButtons.forEach((closeButton) => {
|
|
51
|
-
closeButton.addEventListener('click', (elem) => {
|
|
53
|
+
closeButton.addEventListener('click', (/* elem */) => {
|
|
52
54
|
modals.close(modal, focusedElementBeforeModal, siteContainer);
|
|
53
55
|
});
|
|
54
56
|
});
|
|
@@ -3,9 +3,11 @@ const componentClass = 'mds-notification';
|
|
|
3
3
|
const notification = {
|
|
4
4
|
init: (text, type, duration = 3000) => {
|
|
5
5
|
const { body } = document;
|
|
6
|
+
|
|
6
7
|
notification.hide(body);
|
|
7
8
|
|
|
8
9
|
const message = document.createElement('div');
|
|
10
|
+
|
|
9
11
|
message.setAttribute('role', 'alert');
|
|
10
12
|
message.classList.add(componentClass, 'mds-message', `mds-message--${type}`);
|
|
11
13
|
message.innerText = text;
|
|
@@ -18,6 +20,7 @@ const notification = {
|
|
|
18
20
|
},
|
|
19
21
|
hide: (container) => {
|
|
20
22
|
const elementArray = Array.from(container.querySelectorAll(`.${componentClass}`));
|
|
23
|
+
|
|
21
24
|
elementArray.forEach((elem) => {
|
|
22
25
|
elem.parentNode.removeChild(elem);
|
|
23
26
|
});
|
|
@@ -5,4 +5,14 @@
|
|
|
5
5
|
{{ MdsSkipLink({
|
|
6
6
|
text: "Skip to main content",
|
|
7
7
|
href: "#main"
|
|
8
|
-
}) }}
|
|
8
|
+
}) }}
|
|
9
|
+
|
|
10
|
+
<div id="main">
|
|
11
|
+
<style type="text/css">
|
|
12
|
+
#main:target {
|
|
13
|
+
border: 3px solid red;
|
|
14
|
+
height: 100px;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
17
|
+
This is the main content, use the skip link to go to me, I'll show a red border when you focus
|
|
18
|
+
</div>
|
|
@@ -67,15 +67,21 @@ const tabs = {
|
|
|
67
67
|
element.addEventListener('keydown', (elem) => {
|
|
68
68
|
switch (elem.keyCode) {
|
|
69
69
|
case tabsKeys.left:
|
|
70
|
+
|
|
71
|
+
// eslint-disable-next-line no-fallthrough
|
|
70
72
|
case tabsKeys.up:
|
|
71
73
|
elem.preventDefault();
|
|
72
74
|
tabs.moveTab(element, tabsContainer, tabsAll, panelAll, false);
|
|
73
75
|
break;
|
|
76
|
+
|
|
74
77
|
case tabsKeys.right:
|
|
78
|
+
|
|
79
|
+
// eslint-disable-next-line no-fallthrough
|
|
75
80
|
case tabsKeys.down:
|
|
76
81
|
elem.preventDefault();
|
|
77
82
|
tabs.moveTab(element, tabsContainer, tabsAll, panelAll, true);
|
|
78
83
|
break;
|
|
84
|
+
|
|
79
85
|
default:
|
|
80
86
|
break;
|
|
81
87
|
}
|
|
@@ -89,16 +95,19 @@ const tabs = {
|
|
|
89
95
|
if (element.parentElement.previousSibling) {
|
|
90
96
|
return element.parentElement.previousSibling.querySelector(`.${tabsTabClass}`);
|
|
91
97
|
}
|
|
98
|
+
|
|
92
99
|
return false;
|
|
93
100
|
},
|
|
94
101
|
getNextTab: (element) => {
|
|
95
102
|
if (element.parentElement.nextSibling) {
|
|
96
103
|
return element.parentElement.nextSibling.querySelector(`.${tabsTabClass}`);
|
|
97
104
|
}
|
|
105
|
+
|
|
98
106
|
return false;
|
|
99
107
|
},
|
|
100
108
|
getTargetPanel: (element, tabsContainer) => {
|
|
101
109
|
const elementId = element.attributes.href.value;
|
|
110
|
+
|
|
102
111
|
return tabsContainer.querySelector(elementId);
|
|
103
112
|
},
|
|
104
113
|
getAllPanels: (tabsContainer) => {
|
|
@@ -110,9 +119,11 @@ const tabs = {
|
|
|
110
119
|
moveTab: (element, tabsContainer, tabsAll, panelAll, isNext) => {
|
|
111
120
|
const currentElement = tabs.getSelectedTab(element);
|
|
112
121
|
const targetElement = isNext ? tabs.getNextTab(currentElement) : tabs.getPrevTab(currentElement);
|
|
122
|
+
|
|
113
123
|
if (targetElement) {
|
|
114
124
|
const targetId = targetElement.attributes.href.value;
|
|
115
125
|
const targetPanel = tabs.getTargetPanel(targetElement, tabsContainer);
|
|
126
|
+
|
|
116
127
|
tabs.updateTabs(tabsAll, panelAll, targetElement, targetPanel, targetId, false);
|
|
117
128
|
}
|
|
118
129
|
},
|
|
@@ -2,10 +2,12 @@ const elementName = 'mds-combobox';
|
|
|
2
2
|
|
|
3
3
|
function bindToSelect() {
|
|
4
4
|
const el = document.querySelector(`[data-combobox-id="distance-selection"]`);
|
|
5
|
+
|
|
5
6
|
if (el) {
|
|
6
7
|
const selectInput = el.querySelector('select');
|
|
7
8
|
const options = Array.from(selectInput.querySelectorAll('option'));
|
|
8
9
|
const vueSelect = el.querySelector(elementName);
|
|
10
|
+
|
|
9
11
|
vueSelect.options = options.slice(1).map((opt) => ({ value: opt.value, label: opt.textContent }));
|
|
10
12
|
// not sure it's needed ?
|
|
11
13
|
// vueSelect.addEventListener('select-option', (event) => {
|
|
@@ -19,16 +21,20 @@ function bindToSelect() {
|
|
|
19
21
|
|
|
20
22
|
function bindToApi() {
|
|
21
23
|
const el = document.querySelector(`[data-combobox-id="keywords-lookup"]`);
|
|
24
|
+
|
|
22
25
|
if (el) {
|
|
23
26
|
const vueSelect = el.querySelector(elementName);
|
|
27
|
+
|
|
24
28
|
vueSelect.filterOptions = false;
|
|
25
29
|
vueSelect.addEventListener('search', (event) => {
|
|
26
30
|
const [searchValue] = event.detail;
|
|
31
|
+
|
|
27
32
|
if (searchValue) {
|
|
28
33
|
fetch(`https://api.datamuse.com/sug?s=${searchValue}`)
|
|
29
34
|
.then((res) => res.json())
|
|
30
35
|
.then((data) => {
|
|
31
36
|
const options = data.map(({ word }) => ({ value: word, label: word }));
|
|
37
|
+
|
|
32
38
|
vueSelect.options = options;
|
|
33
39
|
return options;
|
|
34
40
|
})
|
|
@@ -3,14 +3,17 @@ import notification from '../../components/notification/notification';
|
|
|
3
3
|
const notificationScript = {
|
|
4
4
|
init: () => {
|
|
5
5
|
const elements = Array.from(document.querySelectorAll('.js-notification-example'));
|
|
6
|
+
|
|
6
7
|
elements.forEach((element) => {
|
|
7
8
|
const trigger = element;
|
|
9
|
+
|
|
8
10
|
trigger.addEventListener('click', (e) => {
|
|
9
11
|
e.preventDefault();
|
|
10
12
|
e.stopPropagation();
|
|
11
13
|
const triggerEl = e.currentTarget;
|
|
12
14
|
const messageText = triggerEl.innerText;
|
|
13
15
|
const { messageType } = triggerEl.dataset;
|
|
16
|
+
|
|
14
17
|
notification.init(messageText, messageType);
|
|
15
18
|
});
|
|
16
19
|
});
|
|
@@ -3,12 +3,15 @@ import switchState from '../../components/switch-state/switch-state';
|
|
|
3
3
|
const switchStateScript = {
|
|
4
4
|
init: () => {
|
|
5
5
|
const elements = Array.from(document.querySelectorAll('.js-mds-switch-state'));
|
|
6
|
+
|
|
6
7
|
elements.forEach((element) => {
|
|
7
8
|
const trigger = element;
|
|
9
|
+
|
|
8
10
|
trigger.addEventListener('click', (e) => {
|
|
9
11
|
e.preventDefault();
|
|
10
12
|
e.stopPropagation();
|
|
11
13
|
const triggerEl = e.currentTarget;
|
|
14
|
+
|
|
12
15
|
if (triggerEl.classList.contains('mds-switch-state--default')) {
|
|
13
16
|
switchState.switchToinverse(triggerEl);
|
|
14
17
|
} else if (triggerEl.classList.contains('mds-switch-state--inverse')) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
/* eslint-disable no-extend-native ,prefer-rest-params, no-bitwise */
|
|
1
2
|
// https://tc39.github.io/ecma262/#sec-array.prototype.find
|
|
2
3
|
if (!Array.prototype.find) {
|
|
3
4
|
Object.defineProperty(Array.prototype, 'find', {
|
|
4
|
-
value
|
|
5
|
+
value(predicate) {
|
|
5
6
|
// 1. Let O be ? ToObject(this value).
|
|
6
7
|
if (this == null) {
|
|
7
8
|
throw TypeError('"this" is null or not defined');
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const o = Object(this);
|
|
11
12
|
|
|
12
13
|
// 2. Let len be ? ToLength(? Get(O, "length")).
|
|
13
|
-
|
|
14
|
+
const len = o.length >>> 0;
|
|
14
15
|
|
|
15
16
|
// 3. If IsCallable(predicate) is false, throw a TypeError exception.
|
|
16
17
|
if (typeof predicate !== 'function') {
|
|
@@ -18,10 +19,10 @@ if (!Array.prototype.find) {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
|
21
|
-
|
|
22
|
+
const thisArg = arguments[1];
|
|
22
23
|
|
|
23
24
|
// 5. Let k be 0.
|
|
24
|
-
|
|
25
|
+
let k = 0;
|
|
25
26
|
|
|
26
27
|
// 6. Repeat, while k < len
|
|
27
28
|
while (k < len) {
|
|
@@ -29,10 +30,12 @@ if (!Array.prototype.find) {
|
|
|
29
30
|
// b. Let kValue be ? Get(O, Pk).
|
|
30
31
|
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
|
|
31
32
|
// d. If testResult is true, return kValue.
|
|
32
|
-
|
|
33
|
+
const kValue = o[k];
|
|
34
|
+
|
|
33
35
|
if (predicate.call(thisArg, kValue, k, o)) {
|
|
34
36
|
return kValue;
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
// e. Increase k by 1.
|
|
37
40
|
k++;
|
|
38
41
|
}
|
|
@@ -4,13 +4,14 @@ if (!Element.prototype.matches) {
|
|
|
4
4
|
|
|
5
5
|
if (!Element.prototype.closest) {
|
|
6
6
|
// eslint-disable-next-line func-names
|
|
7
|
-
Element.prototype.closest = function(s) {
|
|
7
|
+
Element.prototype.closest = function (s) {
|
|
8
8
|
let el = this;
|
|
9
9
|
|
|
10
10
|
do {
|
|
11
11
|
if (el.matches(s)) return el;
|
|
12
12
|
el = el.parentElement || el.parentNode;
|
|
13
13
|
} while (el !== null && el.nodeType === 1);
|
|
14
|
+
|
|
14
15
|
return null;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
if (typeof Object.assign !== 'function') {
|
|
2
2
|
// Must be writable: true, enumerable: false, configurable: true
|
|
3
3
|
Object.defineProperty(Object, 'assign', {
|
|
4
|
-
value: function assign(target, varArgs) {
|
|
4
|
+
value: function assign(target /* , varArgs */) {
|
|
5
5
|
// .length of function is 2
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
if (target === null || target === undefined) {
|
|
8
8
|
throw new TypeError('Cannot convert undefined or null to object');
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const to = Object(target);
|
|
12
12
|
|
|
13
|
-
for (
|
|
14
|
-
|
|
13
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
14
|
+
// eslint-disable-next-line prefer-rest-params
|
|
15
|
+
const nextSource = arguments[index];
|
|
15
16
|
|
|
16
17
|
if (nextSource !== null && nextSource !== undefined) {
|
|
17
|
-
|
|
18
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
19
|
+
for (const nextKey in nextSource) {
|
|
18
20
|
// Avoid bugs when hasOwnProperty is shadowed
|
|
19
21
|
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
20
22
|
to[nextKey] = nextSource[nextKey];
|
|
@@ -22,6 +24,7 @@ if (typeof Object.assign !== 'function') {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
return to;
|
|
26
29
|
},
|
|
27
30
|
writable: true,
|
package/tasks/colorTransforms.js
CHANGED
|
@@ -10,11 +10,13 @@ const TRANSFORM_AMOUNTS = {
|
|
|
10
10
|
// Replicates Sass lightness($color) function
|
|
11
11
|
function lightness(color) {
|
|
12
12
|
const { l } = color.toHsl();
|
|
13
|
+
|
|
13
14
|
return l * 100;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
function createColorsFromBase({ value: baseColor }) {
|
|
17
18
|
const asTinyColor = new TinyColor(baseColor);
|
|
19
|
+
|
|
18
20
|
return {
|
|
19
21
|
light: {
|
|
20
22
|
value: asTinyColor.lighten(TRANSFORM_AMOUNTS.LIGHT).toHexString(),
|
|
@@ -37,6 +39,7 @@ function transformAllColors(colors) {
|
|
|
37
39
|
// eslint-disable-next-line no-param-reassign
|
|
38
40
|
builtBrand[name] = { ...createColorsFromBase(color.base), ...color };
|
|
39
41
|
}
|
|
42
|
+
|
|
40
43
|
return builtBrand;
|
|
41
44
|
}, {});
|
|
42
45
|
}
|
|
@@ -45,6 +48,7 @@ function generateBrandAndStatus({ brand, status }) {
|
|
|
45
48
|
if (status) {
|
|
46
49
|
return { brand: transformAllColors(Object.entries(brand)), status: transformAllColors(Object.entries(status)) };
|
|
47
50
|
}
|
|
51
|
+
|
|
48
52
|
return { brand: transformAllColors(Object.entries(brand)) };
|
|
49
53
|
}
|
|
50
54
|
|