@madgex/design-system 13.4.0 → 13.5.1
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/dist/assets/icons.json +1 -1
- package/dist/css/index.css +1 -1
- package/dist/js/components/mds-image-cropper-standalone.js +4 -0
- package/dist/js/image-cropper-BlqRRHAU.js +58 -0
- package/dist/js/index-fractal.js +2 -2
- package/dist/js/index.js +1 -1
- package/package.json +6 -4
- package/src/components/_macro-index.njk +1 -0
- package/src/components/accordion/README.md +9 -6
- package/src/components/image-cropper/README.md +80 -0
- package/src/components/image-cropper/helpers.js +229 -0
- package/src/components/image-cropper/helpers.spec.js +111 -0
- package/src/components/image-cropper/image-cropper-standalone.scss +2 -0
- package/src/components/image-cropper/image-cropper-touch-area.js +270 -0
- package/src/components/image-cropper/image-cropper.config.js +6 -0
- package/src/components/image-cropper/image-cropper.js +447 -0
- package/src/components/image-cropper/image-cropper.njk +99 -0
- package/src/components/image-cropper/image-cropper.scss +93 -0
- package/src/components/image-cropper/mds-image-cropper-standalone.js +39 -0
- package/src/components/inputs/_form-elements.scss +4 -0
- package/src/components/inputs/category-picker/README.md +45 -0
- package/src/components/inputs/category-picker/_macro.njk +3 -0
- package/src/components/inputs/category-picker/_template.njk +83 -0
- package/src/components/inputs/category-picker/category-picker.config.js +176 -0
- package/src/components/inputs/category-picker/category-picker.js +302 -0
- package/src/components/inputs/category-picker/category-picker.njk +81 -0
- package/src/components/inputs/category-picker/category-picker.scss +148 -0
- package/src/components/inputs/checkbox-list/README.md +1 -0
- package/src/components/inputs/checkbox-list/_template.njk +2 -1
- package/src/js/index-fractal.js +1 -0
- package/src/js/index.js +8 -0
- package/src/scss/components/__index.scss +2 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{% from "./inputs/checkbox-list/_macro.njk" import MdsCheckboxList %}
|
|
2
|
+
{% from "./inputs/label/_macro.njk" import MdsInputLabel %}
|
|
3
|
+
{% from "./inputs/_message/_macro.njk" import MdsInputMessages %}
|
|
4
|
+
{% from "./icons/_macro.njk" import MdsIcon %}
|
|
5
|
+
|
|
6
|
+
{%- set pickerId = checkboxList.id | default('category-picker') -%}
|
|
7
|
+
{%- set dropdownId = pickerId ~ '-dropdown' -%}
|
|
8
|
+
{%- set searchId = pickerId ~ '-search' -%}
|
|
9
|
+
|
|
10
|
+
{% if checkboxList.helpText %}
|
|
11
|
+
{% set helpTextId = [pickerId, '-help-text'] | join %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
{% if checkboxList.validationError %}
|
|
14
|
+
{% set validationErrorId = [pickerId, '-validation-error'] | join %}
|
|
15
|
+
{% endif %}
|
|
16
|
+
{% if helpTextId or validationErrorId or checkboxList.describedBy %}
|
|
17
|
+
{% set ariaDescribedBy = [validationErrorId, helpTextId, checkboxList.describedBy] | join(' ') | trim %}
|
|
18
|
+
{% endif %}
|
|
19
|
+
|
|
20
|
+
{{ sectionTitle | safe }}
|
|
21
|
+
<div class="mds-border mds-padding-b3 mds-margin-bottom-b12">
|
|
22
|
+
<div class="mds-form-element{% if checkboxList.state %} mds-form-element--{{ checkboxList.state }}{% endif %}">
|
|
23
|
+
{{ MdsInputLabel({
|
|
24
|
+
labelText: checkboxList.labelText,
|
|
25
|
+
hideLabel: checkboxList.hideLabel,
|
|
26
|
+
inputId: searchId,
|
|
27
|
+
optional: checkboxList.optional,
|
|
28
|
+
i18n: checkboxList.i18n
|
|
29
|
+
}) }}
|
|
30
|
+
{{ MdsInputMessages({
|
|
31
|
+
id: pickerId,
|
|
32
|
+
helpTextId: helpTextId,
|
|
33
|
+
helpText: checkboxList.helpText,
|
|
34
|
+
validationErrorId: validationErrorId,
|
|
35
|
+
validationError: checkboxList.validationError
|
|
36
|
+
}) }}
|
|
37
|
+
|
|
38
|
+
<mds-category-picker i18n="{{ (i18n or {}) | dump }}">
|
|
39
|
+
<span class="mds-category-picker__templates">{# Removed with JS on load #}
|
|
40
|
+
<ul><li class="mds-category-picker__pill mds-border"></li></ul>
|
|
41
|
+
<button class="mds-category-picker__clear-pill" type="button" aria-label="{{ removeButtonAria | default('remove category') }}">{{- MdsIcon({ iconName: 'close' }) -}}</button>
|
|
42
|
+
</span>
|
|
43
|
+
|
|
44
|
+
<div class="mds-category-picker__input-wrapper">
|
|
45
|
+
<span class="mds-visually-hidden">{{ (i18n or {}).selectedTermsLabel | default('Selected terms:') }}</span>
|
|
46
|
+
<ul class="mds-category-picker__pillbox" role="list">{# Pills added with JS #}</ul>
|
|
47
|
+
<input
|
|
48
|
+
class="mds-category-picker__search"
|
|
49
|
+
id="{{ searchId }}"
|
|
50
|
+
type="text"
|
|
51
|
+
role="combobox"
|
|
52
|
+
autocomplete="off"
|
|
53
|
+
aria-expanded="false"
|
|
54
|
+
aria-controls="{{ dropdownId }}"
|
|
55
|
+
aria-autocomplete="list"
|
|
56
|
+
aria-haspopup="dialog"
|
|
57
|
+
placeholder="{{ searchPlaceholder | default('Search or select…') }}"
|
|
58
|
+
{% if ariaDescribedBy %}aria-describedby="{{ ariaDescribedBy }}"{% endif %}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div id="{{ dropdownId }}" class="mds-category-picker__dropdown" role="dialog" aria-label="{{ checkboxList.labelText | default('Options') }}">
|
|
63
|
+
{{ MdsCheckboxList({
|
|
64
|
+
labelText: checkboxList.labelText,
|
|
65
|
+
hideLabel: true,
|
|
66
|
+
id: checkboxList.id,
|
|
67
|
+
name: checkboxList.name,
|
|
68
|
+
options: checkboxList.options,
|
|
69
|
+
selectedOptions: checkboxList.selectedOptions,
|
|
70
|
+
disabled: checkboxList.disabled,
|
|
71
|
+
containerClasses: checkboxList.containerClasses,
|
|
72
|
+
i18n: checkboxList.i18n,
|
|
73
|
+
describedBy: checkboxList.describedBy
|
|
74
|
+
}) }}
|
|
75
|
+
<div class="mds-category-picker__no-results">{{ (i18n or {}).noResults | default('No matching options') }}</div>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="mds-category-picker__live-region mds-visually-hidden" aria-live="polite" aria-atomic="true"></div>
|
|
79
|
+
</mds-category-picker>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
mds-category-picker {
|
|
2
|
+
display: block;
|
|
3
|
+
position: relative;
|
|
4
|
+
|
|
5
|
+
// Author styles on .mds-form-check override the UA [hidden] rule.
|
|
6
|
+
// Force display:none so filtering works inside the checkbox-list.
|
|
7
|
+
[hidden] {
|
|
8
|
+
display: none !important;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.mds-category-picker__templates {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// --- Input wrapper (looks like a text input) ---
|
|
16
|
+
.mds-category-picker__input-wrapper {
|
|
17
|
+
@extend .mds-form-control;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: $constant-size-baseline;
|
|
22
|
+
padding: $constant-size-baseline ($constant-size-baseline * 2);
|
|
23
|
+
cursor: text;
|
|
24
|
+
min-height: $constant-size-baseline * 12; // match standard input height
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Pillbox becomes transparent to flex layout — pills are direct flex items
|
|
28
|
+
.mds-category-picker__pillbox {
|
|
29
|
+
display: contents;
|
|
30
|
+
list-style: none;
|
|
31
|
+
margin: 0;
|
|
32
|
+
padding: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// --- Search input inside wrapper ---
|
|
36
|
+
.mds-category-picker__search {
|
|
37
|
+
flex: 1;
|
|
38
|
+
min-width: 80px;
|
|
39
|
+
border: 0;
|
|
40
|
+
outline: 0;
|
|
41
|
+
padding: $constant-size-baseline ($constant-size-baseline * 2);
|
|
42
|
+
font-size: inherit;
|
|
43
|
+
line-height: inherit;
|
|
44
|
+
background: transparent;
|
|
45
|
+
appearance: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// --- Pill tags inside input ---
|
|
49
|
+
.mds-category-picker__pill {
|
|
50
|
+
font-size: var(--mds-font-type-s-1-size);
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 0;
|
|
54
|
+
border-radius: $border-radius;
|
|
55
|
+
padding: $constant-size-baseline ($constant-size-baseline * 2);
|
|
56
|
+
max-width: 100%;
|
|
57
|
+
min-width: 0;
|
|
58
|
+
background-color: $constant-color-neutral-lightest;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mds-category-picker__pill-text {
|
|
62
|
+
flex: 1 1 0;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.mds-category-picker__clear-pill {
|
|
70
|
+
background: none;
|
|
71
|
+
border: none;
|
|
72
|
+
padding: 0 0 0 ($constant-size-baseline);
|
|
73
|
+
margin: 0;
|
|
74
|
+
cursor: pointer;
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
|
|
79
|
+
.mds-icon {
|
|
80
|
+
top: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:focus {
|
|
84
|
+
@include inputFocusStyle();
|
|
85
|
+
border-radius: $border-radius;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// --- Dropdown panel ---
|
|
90
|
+
.mds-category-picker__dropdown {
|
|
91
|
+
display: none;
|
|
92
|
+
position: absolute;
|
|
93
|
+
left: 0;
|
|
94
|
+
right: 0;
|
|
95
|
+
top: 100%;
|
|
96
|
+
max-height: 300px;
|
|
97
|
+
overflow-y: auto;
|
|
98
|
+
border: $input-border;
|
|
99
|
+
border-top: none;
|
|
100
|
+
border-radius: 0 0 $border-radius $border-radius;
|
|
101
|
+
background-color: #fff;
|
|
102
|
+
@include z-index();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&.mds-category-picker--open .mds-category-picker__dropdown {
|
|
106
|
+
display: block;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Remove fixed height constraint from checkbox container when inside dropdown
|
|
110
|
+
.mds-category-picker__dropdown .mds-form-check-container--border {
|
|
111
|
+
border: 0;
|
|
112
|
+
border-radius: 0;
|
|
113
|
+
max-height: none;
|
|
114
|
+
min-height: 0;
|
|
115
|
+
overflow: visible;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Bold selected items and parent labels with checked children
|
|
119
|
+
.mds-form-check--has-selection > .mds-form-check__label,
|
|
120
|
+
.mds-form-check__input:checked + .mds-form-check__label {
|
|
121
|
+
font-weight: bold;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// --- No results message ---
|
|
125
|
+
.mds-category-picker__no-results {
|
|
126
|
+
display: none;
|
|
127
|
+
padding: ($constant-size-baseline * 3);
|
|
128
|
+
text-align: center;
|
|
129
|
+
color: $constant-color-neutral-base;
|
|
130
|
+
|
|
131
|
+
&--visible {
|
|
132
|
+
display: block;
|
|
133
|
+
@extend .mds-font-s-1;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --- No-JS fallback: show checkbox list normally ---
|
|
138
|
+
html:not(.js) & .mds-category-picker__input-wrapper {
|
|
139
|
+
display: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
html:not(.js) & .mds-category-picker__dropdown {
|
|
143
|
+
display: block;
|
|
144
|
+
position: static;
|
|
145
|
+
border: 0;
|
|
146
|
+
max-height: none;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
- `describedBy`: adding aria-describeby to the fieldset (if multiple checkboxes) or the input field if only one checkbox - **optional**
|
|
13
13
|
- `options`: This is an array of objects containing the parameters for each option: `labelText`, `value`, `id`, `classes`
|
|
14
14
|
- `selectedOptions`: Preselected checkboxes - Array or comma-separated string **optional**
|
|
15
|
+
- `containerClasses`: Extra classes to add to the scrollable checkbox container (e.g. `mds-form-check-container--border--tall` for a taller list) **optional**
|
|
15
16
|
- `i18n`: Text to translate/customise (object) **optional**
|
|
16
17
|
|
|
17
18
|
```
|
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
validationErrorId: validationErrorId,
|
|
131
131
|
validationError: params.validationError
|
|
132
132
|
}) }}
|
|
133
|
-
|
|
133
|
+
|
|
134
|
+
<div class="mds-form-check-container{% if hasBorder %} mds-form-check-container--border{% endif %}{% if params.containerClasses %} {{ params.containerClasses }}{% endif %}">
|
|
134
135
|
{{ createCheckboxes({
|
|
135
136
|
options: params.options,
|
|
136
137
|
selectedOptions: params.selectedOptions,
|
package/src/js/index-fractal.js
CHANGED
|
@@ -5,4 +5,5 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
5
5
|
switchStateScript.init();
|
|
6
6
|
notificationScript.init();
|
|
7
7
|
await import('../components/timeout-dialog/mds-timeout-dialog-standalone.js');
|
|
8
|
+
await import('../components/image-cropper/mds-image-cropper-standalone.js');
|
|
8
9
|
});
|
package/src/js/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import { MdsDropdownNav } from '../components/dropdown-nav/dropdown-nav';
|
|
|
13
13
|
import { MdsTimeoutDialog } from '../components/timeout-dialog/timeout-dialog';
|
|
14
14
|
import { MdsCardLink } from '../components/card/card-link';
|
|
15
15
|
import { MdsConditionalSection } from '../components/conditional-section/conditional-section';
|
|
16
|
+
import { MdsImageCropper } from '../components/image-cropper/image-cropper';
|
|
17
|
+
import { MdsCategoryPicker } from '../components/inputs/category-picker/category-picker';
|
|
16
18
|
|
|
17
19
|
if (!window.customElements.get('mds-dropdown-nav')) {
|
|
18
20
|
window.customElements.define('mds-dropdown-nav', MdsDropdownNav);
|
|
@@ -26,6 +28,12 @@ if (!window.customElements.get('mds-card-link')) {
|
|
|
26
28
|
if (!window.customElements.get('mds-conditional-section')) {
|
|
27
29
|
window.customElements.define('mds-conditional-section', MdsConditionalSection);
|
|
28
30
|
}
|
|
31
|
+
if (!window.customElements.get('mds-image-cropper')) {
|
|
32
|
+
window.customElements.define('mds-image-cropper', MdsImageCropper);
|
|
33
|
+
}
|
|
34
|
+
if (!window.customElements.get('mds-category-picker')) {
|
|
35
|
+
window.customElements.define('mds-category-picker', MdsCategoryPicker);
|
|
36
|
+
}
|
|
29
37
|
|
|
30
38
|
const initAll = () => {
|
|
31
39
|
tabs.init();
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
@import '../../components/popover/popover';
|
|
10
10
|
@import '../../components/notification/notification';
|
|
11
11
|
@import '../../components/inputs/form-elements';
|
|
12
|
+
@import '../../components/inputs/category-picker/category-picker';
|
|
12
13
|
@import '../../components/inputs/combobox/combobox';
|
|
13
14
|
@import '../../components/inputs/file-upload/file-upload';
|
|
14
15
|
@import '../../components/inputs/textarea/textarea';
|
|
@@ -17,3 +18,4 @@
|
|
|
17
18
|
@import '../../components/skip-link/skip-link';
|
|
18
19
|
@import '../../components/media-block/media-block';
|
|
19
20
|
@import '../../components/timeout-dialog/timeout-dialog';
|
|
21
|
+
@import '../../components/image-cropper/image-cropper';
|