mp-design-system 1.2.5 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +0,0 @@
1
- {# <div class="c-combobox">
2
- <input type="text" class="c-combobox__input" id="combobox-input" aria-haspopup="listbox" aria-expanded="false" aria-labelledby="combobox-label" autocomplete="off" placeholder="Select an option" role="combobox" aria-owns="combobox-options">
3
- <ul class="c-combobox__dropdown" id="combobox-options" role="listbox" aria-labelledby="combobox-input">
4
- <li data-value="option1" role="option">Option 1</li>
5
- <li data-value="option2" role="option">Option 2</li>
6
- <li data-value="option3" role="option">Option 3</li>
7
- </ul>
8
- <div> #}
9
-
10
- <div class="c-combobox">
11
- <input type="text" id="combobox-input" class="c-combobox__input" placeholder="Type to search..." autocomplete="off" aria-controls="combobox-list" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-owns="combobox-select">
12
- <ul id="combobox-select" class="c-combobox__select" role="listbox" aria-label="Options" tabindex="-1">
13
- <li role="option" aria-selected="false">Option 1</li>
14
- <li role="option" aria-selected="false">Option 2</li>
15
- <li role="option" aria-selected="false">Option 3</li>
16
- </ul>
17
- </div>
@@ -1,31 +0,0 @@
1
- .c-combobox {
2
- position: relative;
3
- display: inline-block;
4
-
5
- &__input {
6
- width: 200px;
7
- padding: 5px;
8
- }
9
-
10
- &__select {
11
- position: absolute;
12
- z-index: 1;
13
- list-style-type: none;
14
- padding: 0;
15
- margin: 0;
16
- background-color: #f9f9f9;
17
- border: 1px solid #ccc;
18
- border-top: none;
19
- display: none;
20
-
21
- li {
22
- padding: 10px;
23
- cursor: pointer;
24
-
25
- &[aria-selected="true"] {
26
- background-color: #e6e6e6;
27
- }
28
- }
29
- }
30
-
31
- }
@@ -1,49 +0,0 @@
1
- const categories = require('../component/categories');
2
-
3
- module.exports = {
4
- title: 'Combobox',
5
- category: categories.form,
6
- component: {
7
- name: 'combobox',
8
- folder: 'input'
9
- },
10
- figma: 'https://www.figma.com/file/rUQ6aPQAfBX55o3hH0Lqb3/Design-exploration?node-id=213%3A918',
11
- preview: 'form',
12
- context: {
13
- label: 'Label',
14
- name: 'name',
15
- id: 'id',
16
- type: 'text',
17
- placeholder: 'Placeholder',
18
- required: true
19
- },
20
- variants: [
21
- {
22
- title: 'With error',
23
- context: {
24
- error: true
25
- }
26
- },
27
- {
28
- title: 'With error message',
29
- context: {
30
- error: 'This field is required'
31
- }
32
- },
33
- {
34
- title: 'Disabled',
35
- context: {
36
- disabled: true
37
- }
38
- }
39
- ],
40
- props: [
41
- {
42
- table: [
43
- ['label', 'string'],
44
- ['id', 'string', 'ID attribute'],
45
- ['name', 'string', 'Name attribute (falls back to ID)'],
46
- ]
47
- }
48
- ]
49
- }
@@ -1,66 +0,0 @@
1
- function Combobox() {
2
- const comboboxes = Array.from(document.querySelectorAll('.c-combobox'));
3
-
4
- comboboxes.forEach(function (combobox) {
5
- const input = combobox.querySelector('.c-combobox__input');
6
- const select = combobox.querySelector('.c-combobox__select');
7
- const options = Array.from(select.querySelectorAll('li[role="option"]'));
8
-
9
- // Set initial state
10
- input.setAttribute('aria-expanded', 'false');
11
- input.setAttribute('aria-owns', select.id);
12
- input.setAttribute('aria-controls', select.id);
13
-
14
- // Event listeners
15
- input.addEventListener('focus', function () {
16
- input.setAttribute('aria-expanded', 'true');
17
- select.setAttribute('aria-expanded', 'true');
18
- });
19
-
20
- input.addEventListener('blur', function () {
21
- input.setAttribute('aria-expanded', 'false');
22
- select.setAttribute('aria-expanded', 'false');
23
- });
24
-
25
- input.addEventListener('input', function () {
26
- const inputValue = input.value.toLowerCase();
27
-
28
- options.forEach(function (option) {
29
- const optionText = option.textContent.toLowerCase();
30
-
31
- if (optionText.includes(inputValue)) {
32
- option.style.display = '';
33
- option.setAttribute('aria-hidden', 'false');
34
- } else {
35
- option.style.display = 'none';
36
- option.setAttribute('aria-hidden', 'true');
37
- }
38
- });
39
- });
40
-
41
- select.addEventListener('click', function (event) {
42
- const target = event.target;
43
- const isOption = target.getAttribute('role') === 'option';
44
-
45
- if (isOption) {
46
- const selectedOption = select.querySelector('[aria-selected="true"]');
47
- if (selectedOption) {
48
- selectedOption.setAttribute('aria-selected', 'false');
49
- }
50
-
51
- target.setAttribute('aria-selected', 'true');
52
- input.value = target.textContent;
53
-
54
- input.focus();
55
- }
56
- });
57
-
58
- // Display options initially
59
- options.forEach(function (option) {
60
- option.style.display = '';
61
- option.setAttribute('aria-hidden', 'false');
62
- });
63
- });
64
- }
65
-
66
- export default Combobox;