basecoat-css 1.0.0-beta.7 → 1.0.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.
Files changed (74) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +83 -35
  3. package/dist/base/base.css +3 -45
  4. package/dist/basecoat-base.cdn.css +171 -132
  5. package/dist/basecoat-base.cdn.min.css +2 -2
  6. package/dist/basecoat-compat.cdn.css +27 -31
  7. package/dist/basecoat-compat.cdn.min.css +2 -2
  8. package/dist/basecoat-components.css +1 -0
  9. package/dist/basecoat-luma.cdn.css +278 -240
  10. package/dist/basecoat-luma.cdn.min.css +2 -2
  11. package/dist/basecoat-lyra.cdn.css +299 -260
  12. package/dist/basecoat-lyra.cdn.min.css +2 -2
  13. package/dist/basecoat-maia.cdn.css +287 -249
  14. package/dist/basecoat-maia.cdn.min.css +2 -2
  15. package/dist/basecoat-mira.cdn.css +315 -277
  16. package/dist/basecoat-mira.cdn.min.css +2 -2
  17. package/dist/basecoat-nova.cdn.css +316 -277
  18. package/dist/basecoat-nova.cdn.min.css +2 -2
  19. package/dist/basecoat-rhea.cdn.css +301 -263
  20. package/dist/basecoat-rhea.cdn.min.css +2 -2
  21. package/dist/basecoat-sera.cdn.css +269 -230
  22. package/dist/basecoat-sera.cdn.min.css +2 -2
  23. package/dist/basecoat-vega.cdn.css +296 -257
  24. package/dist/basecoat-vega.cdn.min.css +2 -2
  25. package/dist/basecoat.cdn.css +296 -257
  26. package/dist/basecoat.cdn.min.css +2 -2
  27. package/dist/compat/legacy.css +19 -1
  28. package/dist/components/input-group.css +1 -1
  29. package/dist/components/scrollbar.css +46 -0
  30. package/dist/components/select.css +16 -16
  31. package/dist/js/accordion.min.js +1 -1
  32. package/dist/js/all.js +28 -8
  33. package/dist/js/all.min.js +1 -1
  34. package/dist/js/basecoat.js +26 -6
  35. package/dist/js/basecoat.min.js +1 -1
  36. package/dist/js/chart.min.js +1 -1
  37. package/dist/js/combobox.min.js +1 -1
  38. package/dist/js/command.min.js +1 -1
  39. package/dist/js/drawer.min.js +1 -1
  40. package/dist/js/dropdown-menu.min.js +1 -1
  41. package/dist/js/popover.min.js +1 -1
  42. package/dist/js/range.min.js +1 -1
  43. package/dist/js/select.min.js +1 -1
  44. package/dist/js/sidebar.js +2 -2
  45. package/dist/js/sidebar.min.js +1 -1
  46. package/dist/js/tabs.min.js +1 -1
  47. package/dist/js/toast.min.js +1 -1
  48. package/dist/styles/luma.css +15 -15
  49. package/dist/styles/lyra.css +14 -14
  50. package/dist/styles/maia.css +15 -15
  51. package/dist/styles/mira.css +16 -16
  52. package/dist/styles/nova.css +14 -14
  53. package/dist/styles/rhea.css +15 -15
  54. package/dist/styles/sera.css +16 -16
  55. package/dist/styles/vega.css +14 -14
  56. package/package.json +26 -6
  57. package/templates/jinja/combobox.html.jinja +147 -0
  58. package/templates/jinja/command.html.jinja +210 -0
  59. package/templates/jinja/dialog.html.jinja +97 -0
  60. package/templates/jinja/dropdown-menu.html.jinja +130 -0
  61. package/templates/jinja/popover.html.jinja +51 -0
  62. package/templates/jinja/select.html.jinja +191 -0
  63. package/templates/jinja/sidebar.html.jinja +149 -0
  64. package/templates/jinja/tabs.html.jinja +82 -0
  65. package/templates/jinja/toast.html.jinja +139 -0
  66. package/templates/nunjucks/combobox.njk +157 -0
  67. package/templates/nunjucks/command.njk +203 -0
  68. package/templates/nunjucks/dialog.njk +92 -0
  69. package/templates/nunjucks/dropdown-menu.njk +125 -0
  70. package/templates/nunjucks/popover.njk +48 -0
  71. package/templates/nunjucks/select.njk +184 -0
  72. package/templates/nunjucks/sidebar.njk +144 -0
  73. package/templates/nunjucks/tabs.njk +39 -0
  74. package/templates/nunjucks/toast.njk +137 -0
@@ -0,0 +1,149 @@
1
+ {#
2
+ Renders a sidebar component.
3
+
4
+ @param id {string} [optional] - Unique identifier for the sidebar component.
5
+ @param label {string} [optional] - Label for the sidebar navigation.
6
+ @param open {boolean} [optional] - Whether the sidebar is open.
7
+ @param side {string} [optional] - Side of the sidebar to display.
8
+ @param header {string} [optional] - Header content for the sidebar.
9
+ @param footer {string} [optional] - Footer content for the sidebar.
10
+ @param menu {array} [optional] - Array of menu items for the sidebar.
11
+ @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
12
+ @param header_attrs {object} [optional] - Additional HTML attributes for the header div.
13
+ @param content_attrs {object} [optional] - Additional HTML attributes for the content div.
14
+ @param footer_attrs {object} [optional] - Additional HTML attributes for the footer div.
15
+ #}
16
+ {% macro sidebar(
17
+ id=None,
18
+ label="Sidebar navigation",
19
+ open=true,
20
+ side=None,
21
+ header=None,
22
+ footer=None,
23
+ menu=None,
24
+ main_attrs={},
25
+ header_attrs={},
26
+ content_attrs={},
27
+ footer_attrs={}
28
+ ) %}
29
+ {% set main_attrs = main_attrs or {} %}
30
+ {% set header_attrs = header_attrs or {} %}
31
+ {% set content_attrs = content_attrs or {} %}
32
+ {% set footer_attrs = footer_attrs or {} %}
33
+ <aside
34
+ {% if id %}id="{{ id }}"{% endif %}
35
+ class="sidebar {{ main_attrs.class | default('') }}"
36
+ data-side="{{ side if side else "left" }}"
37
+ aria-hidden="{{ "true" if not open else "false" }}"
38
+ {{ "inert" if not open }}
39
+ {% for key, value in main_attrs.items() %}
40
+ {% if key != "class" %}{{ key }}="{{ value }}"{% endif %}
41
+ {% endfor %}
42
+ >
43
+ <nav
44
+ aria-label="{{ label }}"
45
+ >
46
+ {% if header %}
47
+ <header
48
+ {% for key, value in header_attrs.items() %}
49
+ {{ key }}="{{ value }}"
50
+ {% endfor %}
51
+ >
52
+ {{ header | safe }}
53
+ </header>
54
+ {% endif %}
55
+
56
+ <section
57
+ {% for key, value in content_attrs.items() %}
58
+ {{ key }}="{{ value }}"
59
+ {% endfor %}
60
+ >
61
+ {% if menu %}
62
+ {{ render_sidebar_content(menu, id ~ "-content" if id else "content") }}
63
+ {% else %}
64
+ {{ caller() if caller is defined }}
65
+ {% endif %}
66
+ </section>
67
+
68
+ {% if footer %}
69
+ <footer
70
+ {% for key, value in footer_attrs.items() %}
71
+ {{ key }}="{{ value }}"
72
+ {% endfor %}
73
+ >
74
+ {{ footer | safe }}
75
+ </footer>
76
+ {% endif %}
77
+ </nav>
78
+ </aside>
79
+ {% endmacro %}
80
+
81
+ {#
82
+ Renders sidebar content recursively (groups, items, submenus, separators).
83
+
84
+ @param items {array} - The array of items to render.
85
+ @param parent_id_prefix {string} [optional] - Prefix for generating element IDs.
86
+ #}
87
+ {% macro render_sidebar_content(items, parent_id_prefix="content") %}
88
+ {% for item in items %}
89
+ {% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
90
+
91
+ {% set item_type = item.type | default("item") %}
92
+ {% if item_type == "group" %}
93
+ {% set group_label_id = item.id | default("group-label-" + item_id) %}
94
+ <div
95
+ role="group"
96
+ {% if item.label is defined and item.label %}aria-labelledby="{{ group_label_id }}"{% endif %}
97
+ {% if item.attrs is defined and item.attrs %}
98
+ {% for key, value in item.attrs.items() %}
99
+ {{ key }}="{{ value }}"
100
+ {% endfor %}
101
+ {% endif %}
102
+ >
103
+ {% if item.label is defined and item.label %}
104
+ <h3 id="{{ group_label_id }}">{{ item.label }}</h3>
105
+ {% endif %}
106
+ <ul>
107
+ {{ render_sidebar_content(item.get("items", []), item_id) if item.get("items") }}
108
+ </ul>
109
+ </div>
110
+ {% elif item_type == "separator" %}
111
+ <hr role="separator"/>
112
+ {% elif item_type == "submenu" %}
113
+ <li>
114
+ <details
115
+ id="submenu-{{ item_id }}"
116
+ {{ "open" if item.open is defined and item.open }}
117
+ {% if item.attrs is defined and item.attrs %}
118
+ {% for key, value in item.attrs.items() %}
119
+ {% if key != "open" %}{{ key }}="{{ value }}"{% endif %}
120
+ {% endfor %}
121
+ {% endif %}
122
+ >
123
+ <summary aria-controls="submenu-{{ item_id }}-content">
124
+ {% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
125
+ <span>{{ item.label | default('') | safe }}</span>
126
+ </summary>
127
+ <ul id="submenu-{{ item_id }}-content">
128
+ {{ render_sidebar_content(item.get("items", []), item_id) if item.get("items") }}
129
+ </ul>
130
+ </details>
131
+ </li>
132
+ {% elif item_type == "item" %}
133
+ <li>
134
+ <a
135
+ href="{{ item.url | default('#') }}"
136
+ {% if item.current is defined and item.current %}aria-current="page"{% endif %}
137
+ {% if item.attrs is defined and item.attrs %}
138
+ {% for key, value in item.attrs.items() %}
139
+ {% if key != "href" and key != "aria-current" %}{{ key }}="{{ value }}"{% endif %}
140
+ {% endfor %}
141
+ {% endif %}
142
+ >
143
+ {% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
144
+ <span>{{ item.label | default('') | safe }}</span>
145
+ </a>
146
+ </li>
147
+ {% endif %}
148
+ {% endfor %}
149
+ {% endmacro %}
@@ -0,0 +1,82 @@
1
+ {#
2
+ Renders a tabs component.
3
+
4
+ @param id {string} - Unique identifier for the tabs component.
5
+ @param tabsets {array} - An array of objects, each representing a tab and its panel.
6
+ Each object should have:
7
+ - tab {string}: HTML content for the tab button.
8
+ - panel {string} [optional]: HTML content for the tab panel.
9
+ - tab_attrs {object} [optional]: Additional HTML attributes for the tab button.
10
+ - panel_attrs {object} [optional]: Additional HTML attributes for the tab panel div.
11
+ @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
12
+ @param tablist_attrs {object} [optional] - Additional HTML attributes for the tablist nav element.
13
+ Set aria-orientation="vertical" for vertical tabs or data-variant="line" for line tabs.
14
+ @param default_tab_index {number} [optional] [default=1] - The 1-based index of the tab to be active initially.
15
+ #}
16
+ {% macro tabs(
17
+ id=None,
18
+ tabsets=[],
19
+ main_attrs={},
20
+ tablist_attrs={},
21
+ default_tab_index=1
22
+ )
23
+ %}
24
+ {% set id = id or ("tabs-" + (range(100000, 999999) | random | string)) %}
25
+ {% set main_attrs = main_attrs or {} %}
26
+ {% set tablist_attrs = tablist_attrs or {} %}
27
+ {% set orientation = tablist_attrs.get('aria-orientation', 'horizontal') %}
28
+ <div
29
+ class="tabs {{ main_attrs.class | default('') }}"
30
+ id="{{ id }}"
31
+ {% for key, value in main_attrs.items() %}
32
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
33
+ {% endfor %}
34
+ >
35
+ <nav
36
+ role="tablist"
37
+ aria-orientation="{{ orientation }}"
38
+ {% for key, value in tablist_attrs.items() %}
39
+ {% if key != 'aria-orientation' %}{{ key }}="{{ value }}"{% endif %}
40
+ {% endfor %}
41
+ >
42
+ {% for tabset in tabsets %}
43
+ {% set tab_attrs = tabset.tab_attrs | default({}) %}
44
+ <button
45
+ type="button"
46
+ role="tab"
47
+ id="{{ id }}-tab-{{ loop.index }}"
48
+ aria-controls="{{ id }}-panel-{{ loop.index }}"
49
+ aria-selected="{{ 'true' if loop.index == default_tab_index else 'false' }}"
50
+ tabindex="{{ '0' if loop.index == default_tab_index and not (tab_attrs.disabled | default(false)) and (tab_attrs['aria-disabled'] | default('false')) != 'true' else '-1' }}"
51
+ {% if tab_attrs %}
52
+ {% for key, value in tab_attrs.items() %}
53
+ {{ key }}="{{ value }}"
54
+ {% endfor %}
55
+ {% endif %}
56
+ >
57
+ {{ tabset.tab | safe }}
58
+ </button>
59
+ {% endfor %}
60
+ </nav>
61
+
62
+ {% for tabset in tabsets %}
63
+ {% if tabset.panel is defined and tabset.panel %}
64
+ <div
65
+ role="tabpanel"
66
+ id="{{ id }}-panel-{{ loop.index }}"
67
+ aria-labelledby="{{ id }}-tab-{{ loop.index }}"
68
+ tabindex="-1"
69
+ aria-selected="{{ 'true' if loop.index == default_tab_index else 'false' }}"
70
+ {% if loop.index != default_tab_index %}hidden{% endif %}
71
+ {% if tabset.panel_attrs is defined and tabset.panel_attrs %}
72
+ {% for key, value in tabset.panel_attrs.items() %}
73
+ {{ key }}="{{ value }}"
74
+ {% endfor %}
75
+ {% endif %}
76
+ >
77
+ {{ tabset.panel | safe }}
78
+ </div>
79
+ {% endif %}
80
+ {% endfor %}
81
+ </div>
82
+ {% endmacro %}
@@ -0,0 +1,139 @@
1
+ {#
2
+ Renders a toaster container and individual toast messages.
3
+ Can render the initial container or be used with htmx OOB swaps to add toasts dynamically.
4
+
5
+ @param id {string} [optional] [default="toaster"] - Unique identifier for the toaster container.
6
+ @param toasts {array} [optional] - An array of toast objects to render initially. See the <code>toast()</code> macro for more details.
7
+ @param attrs {object} [optional] - Additional HTML attributes for the main toaster container div.
8
+
9
+ Supports caller() for custom toast markup.
10
+ #}
11
+ {% macro toaster(
12
+ id="toaster",
13
+ toasts=[],
14
+ attrs={}
15
+ ) %}
16
+ {% set attrs = attrs or {} %}
17
+ <div
18
+ id="{{ id }}"
19
+ class="toaster {{ attrs.class | default('') }}"
20
+ {% for key, value in attrs.items() %}
21
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
22
+ {% endfor %}
23
+ >
24
+ {% for item in toasts %}
25
+ {{ toast(
26
+ category=item.category | default("success"),
27
+ title=item.title | default(""),
28
+ description=item.description | default(""),
29
+ action=item.action | default(None),
30
+ cancel=item.cancel | default(None),
31
+ duration=item.duration | default(None),
32
+ icon=item.icon | default(None),
33
+ attrs=item.attrs | default({})
34
+ ) }}
35
+ {% endfor %}
36
+ {{ caller() if caller is defined }}
37
+ </div>
38
+ {% endmacro %}
39
+
40
+ {#
41
+ Renders a single toast message.
42
+
43
+ @param category {string} [optional] [default="success"] - Type of toast ('success', 'error', 'info', 'warning'). Determines icon and ARIA role.
44
+ @param title {string} [optional] - The main title text of the toast.
45
+ @param description {string} [optional] - The secondary description text.
46
+ @param duration {number} [optional] - Timeout in milliseconds. Use -1 to keep the toast open.
47
+ @param icon {string} [optional] - Custom icon HTML. Defaults to the category icon.
48
+ @param action {object} [optional] - Defines an action button.
49
+ - label {string}: Button text.
50
+ - onclick {string}: JavaScript code to execute on click.
51
+ - href {string}: URL for an anchor link button.
52
+ @param cancel {object} [optional] - Defines a cancel/dismiss button (similar structure to action).
53
+ - label {string}: Button text.
54
+ - onclick {string}: JavaScript code to execute on click.
55
+ - href {string}: URL for an anchor link button.
56
+ @param attrs {object} [optional] - Additional HTML attributes for the toast div.
57
+ #}
58
+ {% macro toast(
59
+ category="success",
60
+ title="",
61
+ description="",
62
+ action=None,
63
+ cancel=None,
64
+ duration=None,
65
+ icon=None,
66
+ attrs={}
67
+ ) %}
68
+ {% set attrs = attrs or {} %}
69
+ {% set action_href = action.href if action and action.href is defined and action.href else (action.url if action and action.url is defined and action.url else None) %}
70
+ {% set cancel_href = cancel.href if cancel and cancel.href is defined and cancel.href else (cancel.url if cancel and cancel.url is defined and cancel.url else None) %}
71
+ <div
72
+ class="toast {{ attrs.class | default('') }}"
73
+ role="{{ 'alert' if category == 'error' else 'status' }}"
74
+ aria-atomic="true"
75
+ aria-hidden="false"
76
+ {% if category %}data-category="{{ category }}"{% endif %}
77
+ {% if duration is not none %}data-duration="{{ duration }}"{% endif %}
78
+ {% for key, value in attrs.items() %}
79
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
80
+ {% endfor %}
81
+ >
82
+ <div class="toast-content">
83
+ {% if icon %}
84
+ {{ icon | safe }}
85
+ {% elif category in ["error", "success", "info", "warning"] %}
86
+ {% if category == "success" %}
87
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
88
+ {% elif category == "error" %}
89
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>
90
+ {% elif category == "info" %}
91
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
92
+ {% elif category == "warning" %}
93
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
94
+ {% endif %}
95
+ {% endif %}
96
+ <section>
97
+ {% if title %}<h2>{{ title }}</h2>{% endif %}
98
+ {% if description %}<p>{{ description }}</p>{% endif %}
99
+ </section>
100
+ {% if action or cancel %}
101
+ <footer>
102
+ {% if action %}
103
+ {% if action_href %}
104
+ <a
105
+ href="{{ action_href }}"
106
+ class="btn" data-size="sm"
107
+ data-toast-action
108
+ >{{ action.label | default('') }}</a>
109
+ {% else %}
110
+ <button
111
+ type="button"
112
+ class="btn"
113
+ data-size="sm"
114
+ data-toast-action
115
+ {% if action.onclick is defined and action.onclick %}onclick="{{ action.onclick }}"{% endif %}
116
+ >{{ action.label | default('') }}</button>
117
+ {% endif %}
118
+ {% endif %}
119
+ {% if cancel %}
120
+ {% if cancel_href %}
121
+ <a
122
+ href="{{ cancel_href }}"
123
+ class="btn" data-variant="outline" data-size="sm"
124
+ data-toast-cancel
125
+ >{{ cancel.label | default('') }}</a>
126
+ {% else %}
127
+ <button
128
+ type="button"
129
+ class="btn" data-variant="outline" data-size="sm"
130
+ data-toast-cancel
131
+ {% if cancel.onclick is defined and cancel.onclick %}onclick="{{ cancel.onclick }}"{% endif %}
132
+ >{{ cancel.label | default('') }}</button>
133
+ {% endif %}
134
+ {% endif %}
135
+ </footer>
136
+ {% endif %}
137
+ </div>
138
+ </div>
139
+ {% endmacro %}
@@ -0,0 +1,157 @@
1
+ {#
2
+ Renders an input-first combobox component.
3
+
4
+ @param id {string} [optional] - Unique identifier for the combobox component.
5
+ @param selected {string|array} [optional] - The initially selected value(s).
6
+ @param name {string} [optional] - The name attribute for the hidden input storing the selected value.
7
+ @param multiple {boolean} [optional] [default=false] - Enables multiple selection mode with chips.
8
+ @param placeholder {string} [optional] - Placeholder text for the visible input.
9
+ @param close_on_select {boolean} [optional] [default=false] - Closes the popover when selecting an option in multiple mode.
10
+ @param clear {boolean} [optional] [default=false] - Shows a clear button in single-select mode.
11
+ @param auto_highlight {boolean} [optional] [default=false] - Highlights the first matching option while filtering.
12
+ @param format {string} [optional] [default="value"] - Hidden input serialization format: "value" or "object".
13
+ @param main_attrs {object} [optional] - Additional HTML attributes for the root div.
14
+ @param input_attrs {object} [optional] - Additional HTML attributes for the visible input.
15
+ @param popover_attrs {object} [optional] - Additional HTML attributes for the popover div.
16
+ @param listbox_attrs {object} [optional] - Additional HTML attributes for the listbox div.
17
+ @param hidden_input_attrs {object} [optional] - Additional HTML attributes for the hidden input.
18
+ #}
19
+ {% macro combobox(
20
+ id=None,
21
+ selected=None,
22
+ name=None,
23
+ multiple=false,
24
+ placeholder=None,
25
+ close_on_select=false,
26
+ clear=false,
27
+ auto_highlight=false,
28
+ format="value",
29
+ main_attrs={},
30
+ input_attrs={},
31
+ popover_attrs={},
32
+ listbox_attrs={},
33
+ hidden_input_attrs={}
34
+ ) %}
35
+ {% set id = id or ("combobox-" + (range(100000, 999999) | random | string)) %}
36
+ {% set selected_values = [] %}
37
+ {% set selected_entries = [] %}
38
+ {% if selected is defined and selected is iterable and selected is not string %}
39
+ {% for item in selected %}
40
+ {% if item.value is defined %}
41
+ {% set selected_values = (selected_values.push(item.value), selected_values) %}
42
+ {% set selected_entries = (selected_entries.push({ value: item.value, label: (item.label if item.label is defined else item.value) }), selected_entries) %}
43
+ {% else %}
44
+ {% set selected_values = (selected_values.push(item), selected_values) %}
45
+ {% set selected_entries = (selected_entries.push({ value: item, label: item }), selected_entries) %}
46
+ {% endif %}
47
+ {% endfor %}
48
+ {% elif selected is defined and selected %}
49
+ {% if selected.value is defined %}
50
+ {% set selected_values = [selected.value] %}
51
+ {% set selected_entries = [{ value: selected.value, label: (selected.label if selected.label is defined else selected.value) }] %}
52
+ {% else %}
53
+ {% set selected_values = [selected] %}
54
+ {% set selected_entries = [{ value: selected, label: selected }] %}
55
+ {% endif %}
56
+ {% endif %}
57
+ {% set hidden_value = ((selected_entries | dump if multiple else ((selected_entries[0] if selected_entries[0] else None) | dump)) if format == "object" else (selected_values | dump if multiple else (selected_values[0] if selected_values[0] else ''))) %}
58
+
59
+ <div
60
+ id="{{ id }}"
61
+ class="combobox {{ main_attrs.class }}"
62
+ {% if format == "object" %}data-format="object"{% endif %}
63
+ {% if multiple and close_on_select %}data-close-on-select="true"{% endif %}
64
+ {% if auto_highlight %}data-auto-highlight="true"{% endif %}
65
+ {% for key, value in main_attrs %}
66
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
67
+ {% endfor %}
68
+ >
69
+ {% if multiple %}
70
+ <input
71
+ type="text"
72
+ role="combobox"
73
+ class="{{ input_attrs.class }}"
74
+ placeholder="{{ placeholder or '' }}"
75
+ autocomplete="off"
76
+ autocorrect="off"
77
+ spellcheck="false"
78
+ aria-autocomplete="list"
79
+ aria-expanded="false"
80
+ aria-controls="{{ id }}-listbox"
81
+ {% for key, value in input_attrs %}
82
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
83
+ {% endfor %}
84
+ >
85
+ {% elif clear %}
86
+ <div class="input-group {{ input_attrs.class }}">
87
+ <input
88
+ type="text"
89
+ role="combobox"
90
+ placeholder="{{ placeholder or '' }}"
91
+ autocomplete="off"
92
+ autocorrect="off"
93
+ spellcheck="false"
94
+ aria-autocomplete="list"
95
+ aria-expanded="false"
96
+ aria-controls="{{ id }}-listbox"
97
+ {% for key, value in input_attrs %}
98
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
99
+ {% endfor %}
100
+ >
101
+ <span role="group" data-align="inline-end">
102
+ <button type="button" data-clear aria-label="Clear selection">
103
+ <svg class="size-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
104
+ </button>
105
+ <button type="button" class="btn" data-variant="ghost" data-size="icon-xs" aria-label="Open suggestions" aria-haspopup="listbox" aria-expanded="false" aria-controls="{{ id }}-listbox">
106
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
107
+ </button>
108
+ </span>
109
+ </div>
110
+ {% else %}
111
+ <input
112
+ type="text"
113
+ role="combobox"
114
+ placeholder="{{ placeholder or '' }}"
115
+ autocomplete="off"
116
+ autocorrect="off"
117
+ spellcheck="false"
118
+ aria-autocomplete="list"
119
+ aria-expanded="false"
120
+ aria-controls="{{ id }}-listbox"
121
+ class="{{ input_attrs.class }}"
122
+ {% for key, value in input_attrs %}
123
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
124
+ {% endfor %}
125
+ >
126
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="combobox-trigger-icon"><path d="m6 9 6 6 6-6"/></svg>
127
+ {% endif %}
128
+ <div
129
+ id="{{ id }}-popover"
130
+ data-popover
131
+ aria-hidden="true"
132
+ {% for key, value in popover_attrs %}
133
+ {{ key }}="{{ value }}"
134
+ {% endfor %}
135
+ >
136
+ <div
137
+ role="listbox"
138
+ id="{{ id }}-listbox"
139
+ aria-orientation="vertical"
140
+ {% if multiple %}aria-multiselectable="true"{% endif %}
141
+ {% for key, value in listbox_attrs %}
142
+ {{ key }}="{{ value }}"
143
+ {% endfor %}
144
+ >
145
+ {{ caller() if caller else '' }}
146
+ </div>
147
+ </div>
148
+ <input
149
+ type="hidden"
150
+ {% if name %}name="{{ name }}"{% endif %}
151
+ value='{{ hidden_value }}'
152
+ {% for key, value in hidden_input_attrs %}
153
+ {{ key }}="{{ value }}"
154
+ {% endfor %}
155
+ >
156
+ </div>
157
+ {% endmacro %}