nsw-design-system 3.3.0 → 3.5.0
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/CHANGELOG.md +19 -0
- package/dist/css/core.css +1 -1
- package/dist/css/main.css +1 -1
- package/dist/js/main.js +512 -0
- package/package.json +1 -1
- package/src/components/_all.scss +4 -0
- package/src/components/file-upload/_file-upload.scss +56 -0
- package/src/components/file-upload/file-upload.js +87 -0
- package/src/components/form/_form.scss +1 -32
- package/src/components/loader/_loader.scss +62 -0
- package/src/components/select/_select.scss +121 -0
- package/src/components/select/select.js +390 -0
- package/src/components/status-labels/_status-labels.scss +19 -0
- package/src/global/scss/settings/_palette.scss +4 -4
- package/src/main.js +17 -1
- package/src/main.scss +4 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
class FileUpload {
|
|
3
|
+
constructor(element) {
|
|
4
|
+
this.element = element
|
|
5
|
+
this.input = this.element.querySelector('.nsw-file-upload__input')
|
|
6
|
+
this.label = this.element.querySelector('.nsw-file-upload__label')
|
|
7
|
+
this.multipleUpload = this.input.hasAttribute('multiple')
|
|
8
|
+
this.replaceFiles = this.element.hasAttribute('data-replace-files')
|
|
9
|
+
this.filesList = false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
init() {
|
|
13
|
+
if (!this.input) return
|
|
14
|
+
|
|
15
|
+
this.input.addEventListener('change', () => {
|
|
16
|
+
if (this.input.value === '') return
|
|
17
|
+
this.updateFileList()
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
createFileList() {
|
|
22
|
+
const ul = document.createElement('ul')
|
|
23
|
+
ul.classList.add('nsw-file-upload__list')
|
|
24
|
+
this.label.insertAdjacentElement('afterend', ul)
|
|
25
|
+
this.filesList = this.element.querySelector('.nsw-file-upload__list')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
createFileItem(file) {
|
|
29
|
+
const li = document.createElement('li')
|
|
30
|
+
li.classList.add('nsw-file-upload__item')
|
|
31
|
+
const html = `
|
|
32
|
+
<span class="nsw-file-upload__item-filename"></span>
|
|
33
|
+
<button type="button" class="nsw-icon-button">
|
|
34
|
+
<span class="sr-only">Remove file</span>
|
|
35
|
+
<span class="material-icons nsw-material-icons" focusable="false" aria-hidden="true">cancel</span>
|
|
36
|
+
</button>`
|
|
37
|
+
|
|
38
|
+
li.insertAdjacentHTML('afterbegin', html)
|
|
39
|
+
li.querySelector('.nsw-file-upload__item-filename').textContent = this.constructor.truncateString(file.name, 50)
|
|
40
|
+
return li.outerHTML
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
updateFileList() {
|
|
44
|
+
if (!this.filesList) {
|
|
45
|
+
this.createFileList()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.filesList.classList.add('active')
|
|
49
|
+
|
|
50
|
+
let string = ''
|
|
51
|
+
for (let i = 0; i < this.input.files.length; i += 1) {
|
|
52
|
+
const file = this.input.files[i]
|
|
53
|
+
string = this.createFileItem(file) + string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.replaceFiles) {
|
|
57
|
+
this.filesList.innerHTML = string
|
|
58
|
+
} else {
|
|
59
|
+
this.filesList.insertAdjacentHTML('beforeend', string)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.removeFile()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
removeFile() {
|
|
66
|
+
this.filesList.addEventListener('click', (event) => {
|
|
67
|
+
if (!event.target.closest('.nsw-icon-button')) return
|
|
68
|
+
event.preventDefault()
|
|
69
|
+
const item = event.target.closest('.nsw-file-upload__item')
|
|
70
|
+
|
|
71
|
+
item.remove()
|
|
72
|
+
|
|
73
|
+
if (event.currentTarget.children.length === 0) {
|
|
74
|
+
this.filesList.classList.remove('active')
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static truncateString(str, num) {
|
|
80
|
+
if (str.length <= num) {
|
|
81
|
+
return str
|
|
82
|
+
}
|
|
83
|
+
return `${str.slice(0, num)}...`
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default FileUpload
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
$nsw-form-chevron-down: '<svg fill="#333333" version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M16 26l16-16-4-4-12 12-12-12-4 4 16 16z"></path></svg>';
|
|
2
1
|
$nsw-form-tick: '<svg fill="#ffffff" version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M29.362 3.742l-18.867 19.204-7.857-7.997-2.638 2.685 9.175 9.34 1.319 1.284 1.318-1.284 20.187-20.547z"></path></svg>';
|
|
3
2
|
|
|
4
3
|
.nsw-form {
|
|
@@ -80,8 +79,7 @@ $nsw-form-tick: '<svg fill="#ffffff" version="1.1" xmlns="http://www.w3.org/2000
|
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
&__input
|
|
84
|
-
&__select {
|
|
82
|
+
&__input {
|
|
85
83
|
@include font-size('sm');
|
|
86
84
|
padding: rem(11px) rem(16px);
|
|
87
85
|
border-radius: var(--nsw-border-radius);
|
|
@@ -128,35 +126,6 @@ $nsw-form-tick: '<svg fill="#ffffff" version="1.1" xmlns="http://www.w3.org/2000
|
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
|
|
131
|
-
&__select {
|
|
132
|
-
padding-right: rem(48px);
|
|
133
|
-
background: var(--nsw-white) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
134
|
-
background-size: rem(16px) auto;
|
|
135
|
-
|
|
136
|
-
&:hover {
|
|
137
|
-
background: svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center, linear-gradient(var(--nsw-text-hover), var(--nsw-text-hover));
|
|
138
|
-
background-size: rem(16px) auto, auto;
|
|
139
|
-
background-color: var(--nsw-white);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
&:disabled {
|
|
143
|
-
background: var(--nsw-off-white) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
144
|
-
background-size: rem(16px) auto;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
&[aria-invalid='true'],
|
|
148
|
-
&.has-error {
|
|
149
|
-
&:hover {
|
|
150
|
-
background: var(--nsw-status-error-bg) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
151
|
-
background-size: rem(16px) auto;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
option {
|
|
156
|
-
background-color: var(--nsw-white);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
129
|
&__input-group {
|
|
161
130
|
display: flex;
|
|
162
131
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//Variations
|
|
2
|
+
$nsw-loaders: (
|
|
3
|
+
sm: (
|
|
4
|
+
size: rem(24px),
|
|
5
|
+
border: 3px,
|
|
6
|
+
),
|
|
7
|
+
md: (
|
|
8
|
+
size: rem(32px),
|
|
9
|
+
border: 3px,
|
|
10
|
+
),
|
|
11
|
+
lg: (
|
|
12
|
+
size: rem(48px),
|
|
13
|
+
border: 4px,
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
.nsw-loader {
|
|
18
|
+
text-align: center;
|
|
19
|
+
width: fit-content;
|
|
20
|
+
|
|
21
|
+
&__circle {
|
|
22
|
+
position: relative;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
border-style: solid;
|
|
26
|
+
animation-name: nsw-loader-animation-rotate;
|
|
27
|
+
animation-duration: 1.4s;
|
|
28
|
+
animation-timing-function: linear;
|
|
29
|
+
animation-iteration-count: infinite;
|
|
30
|
+
width: rem(64px);
|
|
31
|
+
height: rem(64px);
|
|
32
|
+
border-width: 4px;
|
|
33
|
+
transform-origin: 50% 50% calc((4rem / 2) + 4px);
|
|
34
|
+
border-color: var(--nsw-grey-03);
|
|
35
|
+
border-top-color: var(--nsw-brand-accent);
|
|
36
|
+
|
|
37
|
+
@each $size, $variant in $nsw-loaders {
|
|
38
|
+
&--#{"" + $size} {
|
|
39
|
+
width: map-get($variant, size);
|
|
40
|
+
height: map-get($variant, size);
|
|
41
|
+
transform-origin: 50% 50% calc((#{map-get($variant, size)} / 2) + #{map-get($variant, border)});
|
|
42
|
+
@if map-get($variant, border) == 3px {
|
|
43
|
+
border-width: map-get($variant, border);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&__label {
|
|
50
|
+
display: block;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@keyframes nsw-loader-animation-rotate {
|
|
55
|
+
0% {
|
|
56
|
+
transform: rotate(0deg);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
100% {
|
|
60
|
+
transform: rotate(360deg);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
$nsw-form-chevron-down: '<svg fill="#333333" version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><path d="M16 26l16-16-4-4-12 12-12-12-4 4 16 16z"></path></svg>';
|
|
2
|
+
|
|
3
|
+
.nsw-form {
|
|
4
|
+
&__select {
|
|
5
|
+
@include font-size('sm');
|
|
6
|
+
padding: rem(11px) rem(16px);
|
|
7
|
+
border-radius: var(--nsw-border-radius);
|
|
8
|
+
background-color: var(--nsw-white);
|
|
9
|
+
color: var(--nsw-text-dark);
|
|
10
|
+
border: 1px solid var(--nsw-grey-01);
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
appearance: none;
|
|
13
|
+
-webkit-appearance: none; /* stylelint-disable-line property-no-vendor-prefix */
|
|
14
|
+
width: 100%;
|
|
15
|
+
padding-right: rem(48px);
|
|
16
|
+
background: var(--nsw-white) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
17
|
+
background-size: rem(16px) auto;
|
|
18
|
+
|
|
19
|
+
&:hover {
|
|
20
|
+
background: svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center, linear-gradient(var(--nsw-text-hover), var(--nsw-text-hover));
|
|
21
|
+
background-size: rem(16px) auto, auto;
|
|
22
|
+
background-color: var(--nsw-white);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&:focus {
|
|
26
|
+
@include nsw-focus;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:disabled {
|
|
30
|
+
background: var(--nsw-off-white) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
31
|
+
background-size: rem(16px) auto;
|
|
32
|
+
border-color: var(--nsw-grey-03);
|
|
33
|
+
color: var(--nsw-grey-03);
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
opacity: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&[aria-invalid='true'],
|
|
39
|
+
&.has-error {
|
|
40
|
+
border-color: var(--nsw-status-error);
|
|
41
|
+
border-width: 2px;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background: var(--nsw-status-error-bg) svg-url($nsw-form-chevron-down) no-repeat right rem(16px) center;
|
|
45
|
+
background-size: rem(16px) auto;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
option {
|
|
50
|
+
background-color: var(--nsw-white);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nsw-multi-select {
|
|
56
|
+
position: relative;
|
|
57
|
+
|
|
58
|
+
select {
|
|
59
|
+
display: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__button {
|
|
63
|
+
background-color: var(--nsw-white);
|
|
64
|
+
color: var(--nsw-text-dark);
|
|
65
|
+
border: 1px solid var(--nsw-grey-01);
|
|
66
|
+
font-weight: normal;
|
|
67
|
+
margin-top: rem(4px);
|
|
68
|
+
padding: rem(10px) rem(10px) rem(10px) rem(16px);
|
|
69
|
+
width: 100%;
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
|
|
73
|
+
.nsw-material-icons {
|
|
74
|
+
font-size: rem(32px);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&__label {
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
text-overflow: ellipsis;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__dropdown {
|
|
85
|
+
@include z-index('upper');
|
|
86
|
+
position: absolute;
|
|
87
|
+
left: 0;
|
|
88
|
+
top: 100%;
|
|
89
|
+
min-width: rem(200px);
|
|
90
|
+
width: 100%;
|
|
91
|
+
background-color: var(--nsw-white);
|
|
92
|
+
border-radius: var(--nsw-border-radius);
|
|
93
|
+
box-shadow: var(--nsw-box-shadow);
|
|
94
|
+
overflow: auto;
|
|
95
|
+
visibility: hidden;
|
|
96
|
+
opacity: 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&__button[aria-expanded=true] + &__dropdown {
|
|
100
|
+
visibility: visible;
|
|
101
|
+
opacity: 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&__list {
|
|
105
|
+
list-style-type: none;
|
|
106
|
+
padding: rem(11px) rem(16px);
|
|
107
|
+
|
|
108
|
+
&:not(:first-of-type) {
|
|
109
|
+
padding-top: rem(16px);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&:not(:last-of-type) {
|
|
113
|
+
border-bottom: 1px solid var(--nsw-grey-04);
|
|
114
|
+
padding-bottom: rem(16px);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&__option {
|
|
119
|
+
padding: rem(8px) 0;
|
|
120
|
+
}
|
|
121
|
+
}
|