@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.
@@ -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.optionLabelPath %}option-label-path="{{params.optionLabelPath}}"{% endif%}
51
- {% if params.optionValuePath %}option-value-path="{{params.optionValuePath}}"{% endif%}
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
- {# matches Combobox Vue component #}
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
- {%- if _options -%}
79
- {%- for option in _options -%}
80
- <option
81
- value="{{ option[_optionValuePath] }}"
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.value %} value="{{params.value[_optionValuePath]}}"{% endif %}
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
- options: optionsDistance,
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
- options: optionsSalary,
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
- optionLabelPath: 'word',
54
- optionValuePath: 'score',
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 prefilled',
67
+ name: 'AJAX autocomplete pre-selected',
68
68
  context: {
69
69
  useAutocomplete: true,
70
- variantTitle: 'AJAX autocomplete prefilled',
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
- value: { word: 'Initial Value', score: 'the-value' },
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
- optionLabelPath: 'word',
82
- optionValuePath: 'score',
81
+ apiOptionLabelPath: 'word',
82
+ apiOptionValuePath: 'score',
83
83
  },
84
84
  },
85
85
  {
86
- name: 'AJAX autocomplete prefilled with validation error',
86
+ name: 'AJAX autocomplete pre-selected with validation error',
87
87
  context: {
88
88
  useAutocomplete: true,
89
- variantTitle: 'AJAX autocomplete prefilled with validation error',
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
- value: { word: 'Initial Value', score: 'the-value' },
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
- optionLabelPath: 'word',
100
- optionValuePath: 'score',
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
- optionLabelPath: 'word',
118
- optionValuePath: 'score',
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
- value: [
141
- { word: 'Initial Value 1', score: 'the-value-1' },
142
- { word: 'Initial Value 2', score: 'the-value-2' },
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
- optionLabelPath: 'word',
150
- optionValuePath: 'score',
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
- optionLabelPath: optionLabelPath,
27
- optionValuePath: optionValuePath,
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>
@@ -8,6 +8,9 @@
8
8
  gap: $constant-size-baseline;
9
9
  }
10
10
  }
11
+ .mds-combobox option {
12
+ display: none;
13
+ }
11
14
  .mds-combobox__search-input {
12
15
  flex: 1;
13
16
  min-width: 180px;
@@ -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: { 5: 'Within 5 miles', 10: 'Within 10 miles', 15: 'Within 15 miles', 20: 'Within 20 miles' },
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
- {{ MdsCombobox({
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({