@madgex/design-system 14.2.0 → 14.3.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/css/index.css +1 -1
- package/dist/js/index.js +1 -1
- package/package.json +1 -1
- package/src/components/conditional-section/README.md +2 -2
- package/src/components/conditional-section/conditional-section.config.js +54 -0
- package/src/components/conditional-section/conditional-section.js +91 -26
- package/src/components/conditional-section/conditional-section.spec.js +402 -0
- package/src/components/inputs/combobox/README.md +44 -51
- package/src/components/inputs/combobox/_template.njk +11 -31
- package/src/components/inputs/combobox/combobox.config.js +23 -22
- package/src/components/inputs/combobox/combobox.njk +4 -4
- package/src/components/inputs/combobox/combobox.scss +3 -0
- package/src/layout/forms/forms.config.js +7 -1
- package/src/layout/forms/forms.njk +8 -4
|
@@ -41,18 +41,16 @@
|
|
|
41
41
|
<mds-combobox
|
|
42
42
|
combobox-id="{{ comboboxId }}"
|
|
43
43
|
name="{{ comboboxName }}"
|
|
44
|
-
placeholder="{{ params.placeholder }}"
|
|
44
|
+
{% if params.placeholder %}placeholder="{{ params.placeholder }}"{% endif %}
|
|
45
45
|
iconpath="{{ defaultIconPath }}"
|
|
46
|
-
{% if params.options and params.options.length %}options="{{params.options | dump }}"{% endif %}
|
|
47
46
|
{% if params.apiUrl %}api-url="{{params.apiUrl}}"{% endif%}
|
|
48
47
|
{% if params.apiQueryKey %}api-query-key="{{params.apiQueryKey}}"{% endif%}
|
|
49
48
|
{% if params.apiOptionsPath %}api-options-path="{{params.apiOptionsPath}}"{% endif%}
|
|
50
|
-
{% if params.
|
|
51
|
-
{% if params.
|
|
49
|
+
{% if params.apiOptionLabelPath %}api-option-label-path="{{params.apiOptionLabelPath}}"{% endif%}
|
|
50
|
+
{% if params.apiOptionValuePath %}api-option-value-path="{{params.apiOptionValuePath}}"{% endif%}
|
|
52
51
|
i18n="{{ params.i18n | dump }}"
|
|
53
52
|
data-aria-invalid="{{ params.validationError }}"
|
|
54
53
|
{% if params.minSearchCharacters %}min-search-characters="{{ params.minSearchCharacters }}"{% endif %}
|
|
55
|
-
{% if params.value %}value="{{ params.value | dump }}"{% endif %}
|
|
56
54
|
{% if params.searchText %}search-text="{{ params.searchText }}"{% endif %}
|
|
57
55
|
{% if params.multiple %}multiple{% endif %}
|
|
58
56
|
{% if ariaDescribedBy %} describedby-id="{{ariaDescribedBy}}"{% endif -%}
|
|
@@ -60,13 +58,7 @@
|
|
|
60
58
|
>
|
|
61
59
|
{# all 'default slot' fallback content is removed from DOM when vue component loads #}
|
|
62
60
|
<div class="mds-form-element__fallback">
|
|
63
|
-
|
|
64
|
-
{% set _optionValuePath = params.optionValuePath or "value" %}
|
|
65
|
-
{% set _optionLabelPath = params.optionLabelPath or "label" %}
|
|
66
|
-
{# if no provided options, at least try to render select input with value's options #}
|
|
67
|
-
{% set _options = params.options or (params.multiple and params.value) %}
|
|
68
|
-
|
|
69
|
-
{% if params.fallbackTo === 'select' and _options %}
|
|
61
|
+
{% if params.fallbackTo === 'select' %}
|
|
70
62
|
<select
|
|
71
63
|
class="mds-form-control"
|
|
72
64
|
id="{{ comboboxId }}"
|
|
@@ -74,23 +66,11 @@
|
|
|
74
66
|
{% if params.multiple %}multiple{% endif %}
|
|
75
67
|
{% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
|
|
76
68
|
>
|
|
77
|
-
<option>{{ placeholder }}</option>
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{% if not params.multiple and params.value %}
|
|
83
|
-
{# not multiple mode, see if value #}
|
|
84
|
-
{% if params.value[_optionValuePath] === option[_optionValuePath] %}selected{% endif %}
|
|
85
|
-
{% elseif params.value %}
|
|
86
|
-
{# multiple mode, so we assume params.value is an array #}
|
|
87
|
-
{% for valOpt in params.value %}
|
|
88
|
-
{%if valOpt[_optionValuePath] === option[_optionValuePath] %} selected {% endif %}
|
|
89
|
-
{% endfor %}
|
|
90
|
-
{% endif %}
|
|
91
|
-
>{{ option[_optionLabelPath] }}</option>
|
|
92
|
-
{%- endfor -%}
|
|
93
|
-
{%- endif -%}
|
|
69
|
+
{% if params.placeholder %}<option>{{ params.placeholder }}</option>{% endif %}
|
|
70
|
+
{# caller should be a list of `<option>`s, we can reuse this for the select fallback #}
|
|
71
|
+
{% if caller %}
|
|
72
|
+
{{- caller() -}}
|
|
73
|
+
{% endif %}
|
|
94
74
|
</select>
|
|
95
75
|
{# we cant have multiple mode and use input #}
|
|
96
76
|
{% elseif params.fallbackTo === 'input' %}
|
|
@@ -100,8 +80,8 @@
|
|
|
100
80
|
name="{{ comboboxName }}_fallback"
|
|
101
81
|
autocomplete="off"
|
|
102
82
|
id="{{ comboboxId }}"
|
|
103
|
-
{% if params.
|
|
104
|
-
placeholder="{{ placeholder }}"
|
|
83
|
+
{% if params.fallbackValue %} value="{{params.fallbackValue}}"{% endif %}
|
|
84
|
+
{% if params.placeholder %}placeholder="{{ params.placeholder }}"{% endif %}
|
|
105
85
|
{% if params.validationError %}aria-invalid="true"{% endif %}
|
|
106
86
|
{% if ariaDescribedBy %}aria-describedby="{{ariaDescribedBy}}"{% endif %}
|
|
107
87
|
/>
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
id: 'distance-selection',
|
|
19
19
|
optional: 'true',
|
|
20
20
|
labelText: 'How far are you willing to travel?',
|
|
21
|
-
|
|
21
|
+
content: optionsDistance.map((item) => `<option value="${item.value}">${item.label}</option>`).join(''),
|
|
22
22
|
fallbackTo: 'select',
|
|
23
23
|
classes: 'im-a-custom-class',
|
|
24
24
|
},
|
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
|
31
31
|
id: 'salary-selection',
|
|
32
32
|
optional: 'true',
|
|
33
33
|
labelText: 'Salary expectations?',
|
|
34
|
-
|
|
34
|
+
content: optionsSalary.map((item) => `<option value="${item.value}">${item.label}</option>`).join(''),
|
|
35
35
|
searchText: 'Up to',
|
|
36
36
|
fallbackTo: 'select',
|
|
37
37
|
},
|
|
@@ -50,8 +50,8 @@ module.exports = {
|
|
|
50
50
|
apiUrl: 'https://api.datamuse.com/sug',
|
|
51
51
|
apiQueryKey: 's',
|
|
52
52
|
apiOptionsPath: undefined,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
apiOptionLabelPath: 'word',
|
|
54
|
+
apiOptionValuePath: 'score',
|
|
55
55
|
i18n: {
|
|
56
56
|
requiredIcon: 'Required (test i18n)',
|
|
57
57
|
loadingText: 'Loading (test i18n)',
|
|
@@ -64,40 +64,41 @@ module.exports = {
|
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
name: 'AJAX autocomplete
|
|
67
|
+
name: 'AJAX autocomplete pre-selected',
|
|
68
68
|
context: {
|
|
69
69
|
useAutocomplete: true,
|
|
70
|
-
variantTitle: 'AJAX autocomplete
|
|
70
|
+
variantTitle: 'AJAX autocomplete pre-selected',
|
|
71
71
|
name: 'keywords-prefilled',
|
|
72
72
|
id: 'keywords-lookup-prefilled',
|
|
73
73
|
labelText: 'Keywords:',
|
|
74
74
|
placeholder: 'eg. Testimonials',
|
|
75
|
-
|
|
75
|
+
content: `<option value="the-value" selected>Initial Value</option>`,
|
|
76
76
|
fallbackTo: 'input',
|
|
77
77
|
minSearchCharacters: 3,
|
|
78
78
|
apiUrl: 'https://api.datamuse.com/sug',
|
|
79
79
|
apiQueryKey: 's',
|
|
80
80
|
apiOptionsPath: undefined,
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
apiOptionLabelPath: 'word',
|
|
82
|
+
apiOptionValuePath: 'score',
|
|
83
83
|
},
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
name: 'AJAX autocomplete
|
|
86
|
+
name: 'AJAX autocomplete pre-selected with validation error',
|
|
87
87
|
context: {
|
|
88
88
|
useAutocomplete: true,
|
|
89
|
-
variantTitle: 'AJAX autocomplete
|
|
89
|
+
variantTitle: 'AJAX autocomplete pre-selected with validation error',
|
|
90
90
|
name: 'keywordsprefilled-error',
|
|
91
91
|
id: 'keywords-lookup-prefilled-validation-error',
|
|
92
92
|
labelText: 'Keywords:',
|
|
93
93
|
placeholder: 'eg. Testimonials',
|
|
94
|
-
|
|
94
|
+
content: `<option value="the-value" selected>Initial Value</option>`,
|
|
95
95
|
fallbackTo: 'input',
|
|
96
96
|
validationError: 'There was an error',
|
|
97
|
+
apiUrl: 'https://api.datamuse.com/sug',
|
|
97
98
|
apiQueryKey: 's',
|
|
98
99
|
apiOptionsPath: undefined,
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
apiOptionLabelPath: 'word',
|
|
101
|
+
apiOptionValuePath: 'score',
|
|
101
102
|
},
|
|
102
103
|
},
|
|
103
104
|
{
|
|
@@ -114,8 +115,8 @@ module.exports = {
|
|
|
114
115
|
apiUrl: 'https://api.datamuse.com/sug',
|
|
115
116
|
apiQueryKey: 's',
|
|
116
117
|
apiOptionsPath: undefined,
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
apiOptionLabelPath: 'word',
|
|
119
|
+
apiOptionValuePath: 'score',
|
|
119
120
|
multiple: true,
|
|
120
121
|
i18n: {
|
|
121
122
|
requiredIcon: 'Required (test i18n)',
|
|
@@ -137,17 +138,17 @@ module.exports = {
|
|
|
137
138
|
id: 'keywords-lookup-multiselect-prefilled',
|
|
138
139
|
labelText: 'Keywords:',
|
|
139
140
|
placeholder: 'eg. Web developer',
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
content: `
|
|
142
|
+
<option value="the-value-1" selected>Initial Value 1</option>
|
|
143
|
+
<option value="the-value-2" selected>Initial Value 2</option>
|
|
144
|
+
`,
|
|
144
145
|
fallbackTo: 'select',
|
|
145
146
|
minSearchCharacters: 3,
|
|
146
147
|
apiUrl: 'https://api.datamuse.com/sug',
|
|
147
148
|
apiQueryKey: 's',
|
|
148
149
|
apiOptionsPath: undefined,
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
apiOptionLabelPath: 'word',
|
|
151
|
+
apiOptionValuePath: 'score',
|
|
151
152
|
multiple: true,
|
|
152
153
|
i18n: {
|
|
153
154
|
requiredIcon: 'Required (test i18n)',
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
id: id,
|
|
9
9
|
name: name,
|
|
10
10
|
labelText: labelText,
|
|
11
|
-
options: options,
|
|
12
11
|
optional: optional,
|
|
13
|
-
value: value,
|
|
14
12
|
searchText: searchText,
|
|
15
13
|
fallbackTo: fallbackTo,
|
|
16
14
|
classes: classes,
|
|
@@ -23,11 +21,13 @@
|
|
|
23
21
|
apiUrl: apiUrl,
|
|
24
22
|
apiQueryKey: apiQueryKey,
|
|
25
23
|
apiOptionsPath: apiOptionsPath,
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
apiOptionLabelPath: apiOptionLabelPath,
|
|
25
|
+
apiOptionValuePath: apiOptionValuePath,
|
|
28
26
|
multiple: multiple,
|
|
29
27
|
attributes: attributes
|
|
30
28
|
}) %}
|
|
29
|
+
{# this will be `<option>` elements #}
|
|
30
|
+
{{ content | safe }}
|
|
31
31
|
{% endcall %}
|
|
32
32
|
</div>
|
|
33
33
|
</form>
|
|
@@ -32,7 +32,13 @@ module.exports = {
|
|
|
32
32
|
combobox: {
|
|
33
33
|
id: 'distance-selection',
|
|
34
34
|
labelText: 'How far are you willing to travel?',
|
|
35
|
-
options:
|
|
35
|
+
options: [
|
|
36
|
+
{ value: 5, label: 'Within 5 miles' },
|
|
37
|
+
{ value: 10, label: 'Within 10 miles' },
|
|
38
|
+
{ value: 15, label: 'Within 15 miles' },
|
|
39
|
+
{ value: 20, label: 'Within 20 miles' },
|
|
40
|
+
],
|
|
41
|
+
searchText: 'Within',
|
|
36
42
|
fallbackTo: 'select',
|
|
37
43
|
optional: true,
|
|
38
44
|
},
|
|
@@ -29,14 +29,18 @@
|
|
|
29
29
|
}) }}
|
|
30
30
|
</div>
|
|
31
31
|
<div class="mds-form-field">
|
|
32
|
-
{
|
|
32
|
+
{% call MdsCombobox({
|
|
33
33
|
id: combobox.id,
|
|
34
34
|
labelText: combobox.labelText,
|
|
35
|
-
options: combobox.options,
|
|
36
35
|
fallbackTo: combobox.fallbackTo,
|
|
37
36
|
optional: combobox.optional,
|
|
38
|
-
tooltipMessage: combobox.tooltipMessage
|
|
39
|
-
|
|
37
|
+
tooltipMessage: combobox.tooltipMessage,
|
|
38
|
+
searchText:combobox.searchText
|
|
39
|
+
}) %}
|
|
40
|
+
{% for option in combobox.options %}
|
|
41
|
+
<option value="{{option.value}}">{{option.label}}</option>
|
|
42
|
+
{% endfor %}
|
|
43
|
+
{% endcall %}
|
|
40
44
|
</div>
|
|
41
45
|
<div class="mds-form-field">
|
|
42
46
|
{{ MdsFileUpload({
|