basecoat-cli 0.2.0-beta.1 → 0.2.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.
@@ -6,7 +6,7 @@
6
6
  @param name {string} [optional] - The name attribute for the hidden input storing the selected value.
7
7
  @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
8
8
  @param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger button.
9
- @param content_attrs {object} [optional] - Additional HTML attributes for the popover content div.
9
+ @param popover_attrs {object} [optional] - Additional HTML attributes for the popover content div.
10
10
  @param listbox_attrs {object} [optional] - Additional HTML attributes for the listbox div.
11
11
  @param input_attrs {object} [optional] - Additional HTML attributes for the hidden input.
12
12
  @param search_placeholder {string} [optional] [default="Search entries..."] - Placeholder text for the search input (combobox only).
@@ -17,9 +17,11 @@
17
17
  selected=None,
18
18
  name=None,
19
19
  items=None,
20
+ main_attrs={},
20
21
  trigger_attrs={},
21
22
  popover_attrs={},
22
23
  listbox_attrs={},
24
+ input_attrs={},
23
25
  search_placeholder="Search entries...",
24
26
  is_combobox=false
25
27
  ) %}
@@ -28,34 +30,40 @@
28
30
  {% set first_option = [] %}
29
31
  {% set selected_option = [] %}
30
32
 
31
- {% for item in items %}
32
- {% if item.type == "group" %}
33
- {% for sub_item in item.items %}
33
+ {% if items %}
34
+ {% for item in items %}
35
+ {% if item.type == "group" %}
36
+ {% for sub_item in item.items %}
37
+ {% if not first_option[0] %}
38
+ {% set first_option = (first_option.push(sub_item), first_option) %}
39
+ {% endif %}
40
+ {% if selected and sub_item.value == selected and not selected_option[0] %}
41
+ {% set selected_option = (selected_option.push(sub_item), selected_option) %}
42
+ {% endif %}
43
+ {% endfor %}
44
+ {% else %}
34
45
  {% if not first_option[0] %}
35
- {% set first_option = (first_option.push(sub_item), first_option) %}
46
+ {% set first_option = (first_option.push(item), first_option) %}
36
47
  {% endif %}
37
- {% if selected and sub_item.value == selected and not selected_option[0] %}
38
- {% set selected_option = (selected_option.push(sub_item), selected_option) %}
48
+ {% if selected and item.value == selected and not selected_option[0] %}
49
+ {% set selected_option = (selected_option.push(item), selected_option) %}
39
50
  {% endif %}
40
- {% endfor %}
41
- {% else %}
42
- {% if not first_option[0] %}
43
- {% set first_option = (first_option.push(item), first_option) %}
44
51
  {% endif %}
45
- {% if selected and item.value == selected and not selected_option[0] %}
46
- {% set selected_option = (selected_option.push(item), selected_option) %}
47
- {% endif %}
48
- {% endif %}
49
- {% endfor %}
52
+ {% endfor %}
53
+ {% endif %}
50
54
 
51
55
  {% set default_option = selected_option[0] or first_option[0] or None %}
52
56
 
53
- <div class="select">
57
+ <div
58
+ class="select {{ main_attrs.class }}"
59
+ {% for key, value in main_attrs %}
60
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
61
+ {% endfor %}
62
+ >
54
63
  <button
55
64
  type="button"
56
65
  class="btn-outline justify-between font-normal {{ trigger_attrs.class }}"
57
66
  id="{{ id }}-trigger"
58
- popovertarget="{{ id }}"
59
67
  aria-haspopup="listbox"
60
68
  aria-expanded="false"
61
69
  aria-controls="{{ id }}-listbox"
@@ -71,11 +79,11 @@
71
79
  {% endif %}
72
80
  </button>
73
81
  <div
74
- popover
75
82
  id="{{ id }}"
76
- class="popover {{ popover_attrs.class }}"
83
+ data-popover
84
+ aria-hidden="true"
77
85
  {% for key, value in popover_attrs %}
78
- {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
86
+ {{ key }}="{{ value }}"
79
87
  {% endfor %}
80
88
  >
81
89
  {% if is_combobox %}
@@ -90,8 +98,8 @@
90
98
  spellcheck="false"
91
99
  aria-autocomplete="list"
92
100
  role="combobox"
93
- aria-expanded="true"
94
- aria-controls="{{ id }}-content"
101
+ aria-expanded="false"
102
+ aria-controls="{{ id }}-listbox"
95
103
  aria-labelledby="{{ id }}-trigger"
96
104
  >
97
105
  </header>
@@ -105,7 +113,7 @@
105
113
  {{ key }}="{{ value }}"
106
114
  {% endfor %}
107
115
  >
108
- {% if items.length > 0 %}
116
+ {% if items and items.length > 0 %}
109
117
  {{ render_select_items(items, default_option.value, id ~ "-items" if id else "items") }}
110
118
  {% else %}
111
119
  {{ caller() if caller }}
@@ -115,7 +123,7 @@
115
123
  <input
116
124
  type="hidden"
117
125
  name="{{ name or id ~ '-value' }}"
118
- value="{{ selected or '' }}"
126
+ value="{{ (default_option.value if default_option) or '' }}"
119
127
  {% for key, value in input_attrs %}
120
128
  {% if key != 'name' and key != 'value' %}{{ key }}="{{ value }}"{% endif %}
121
129
  {% endfor %}
@@ -141,7 +149,7 @@
141
149
  {{ key }}="{{ value }}"
142
150
  {% endfor %}
143
151
  >
144
- <div role="heading" id="{{ group_label_id }}">{{ item.label }}</div>
152
+ <div role="presentation" id="{{ group_label_id }}">{{ item.label }}</div>
145
153
  {{ render_select_items(item.items, selected, item_id) if item.items }}
146
154
  </div>
147
155
  {% elif item.type == "separator" %}
@@ -14,9 +14,9 @@
14
14
  ) %}
15
15
  <div
16
16
  id="{{ id }}"
17
- class="toaster"
17
+ class="toaster {{ attrs.class }}"
18
18
  {% for key, value in attrs %}
19
- {{ key }}="{{ value }}"
19
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
20
20
  {% endfor %}
21
21
  >
22
22
  {% for item in toasts %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basecoat-cli",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0",
4
4
  "description": "Add Basecoat components to your project",
5
5
  "author": "hunvreus",
6
6
  "license": "MIT",