basecoat-css 1.0.0-beta.6 → 1.0.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.
- package/LICENSE.md +21 -0
- package/README.md +82 -35
- package/dist/base/base.css +3 -45
- package/dist/basecoat-base.cdn.css +226 -22
- package/dist/basecoat-base.cdn.min.css +1 -1
- package/dist/basecoat-compat.cdn.css +16 -20
- package/dist/basecoat-compat.cdn.min.css +1 -1
- package/dist/basecoat-components.css +2 -0
- package/dist/basecoat-luma.cdn.css +375 -91
- package/dist/basecoat-luma.cdn.min.css +1 -1
- package/dist/basecoat-lyra.cdn.css +358 -96
- package/dist/basecoat-lyra.cdn.min.css +1 -1
- package/dist/basecoat-maia.cdn.css +364 -84
- package/dist/basecoat-maia.cdn.min.css +1 -1
- package/dist/basecoat-mira.cdn.css +366 -94
- package/dist/basecoat-mira.cdn.min.css +1 -1
- package/dist/basecoat-nova.cdn.css +369 -96
- package/dist/basecoat-nova.cdn.min.css +1 -1
- package/dist/basecoat-rhea.cdn.css +376 -91
- package/dist/basecoat-rhea.cdn.min.css +1 -1
- package/dist/basecoat-sera.cdn.css +342 -71
- package/dist/basecoat-sera.cdn.min.css +1 -1
- package/dist/basecoat-vega.cdn.css +366 -92
- package/dist/basecoat-vega.cdn.min.css +1 -1
- package/dist/basecoat.cdn.css +366 -92
- package/dist/basecoat.cdn.min.css +1 -1
- package/dist/compat/legacy.css +19 -1
- package/dist/components/drawer.css +89 -0
- package/dist/components/input-group.css +1 -1
- package/dist/components/scrollbar.css +46 -0
- package/dist/components/select.css +16 -16
- package/dist/js/all.js +85 -0
- package/dist/js/all.min.js +1 -1
- package/dist/js/drawer.js +84 -0
- package/dist/js/drawer.min.js +1 -0
- package/dist/styles/luma.css +47 -14
- package/dist/styles/lyra.css +64 -14
- package/dist/styles/maia.css +47 -14
- package/dist/styles/mira.css +48 -15
- package/dist/styles/nova.css +64 -14
- package/dist/styles/rhea.css +47 -14
- package/dist/styles/sera.css +66 -16
- package/dist/styles/vega.css +64 -14
- package/package.json +28 -6
- package/templates/jinja/combobox.html.jinja +147 -0
- package/templates/jinja/command.html.jinja +210 -0
- package/templates/jinja/dialog.html.jinja +97 -0
- package/templates/jinja/dropdown-menu.html.jinja +130 -0
- package/templates/jinja/popover.html.jinja +51 -0
- package/templates/jinja/select.html.jinja +191 -0
- package/templates/jinja/sidebar.html.jinja +149 -0
- package/templates/jinja/tabs.html.jinja +82 -0
- package/templates/jinja/toast.html.jinja +139 -0
- package/templates/nunjucks/combobox.njk +157 -0
- package/templates/nunjucks/command.njk +203 -0
- package/templates/nunjucks/dialog.njk +92 -0
- package/templates/nunjucks/dropdown-menu.njk +125 -0
- package/templates/nunjucks/popover.njk +48 -0
- package/templates/nunjucks/select.njk +184 -0
- package/templates/nunjucks/sidebar.njk +144 -0
- package/templates/nunjucks/tabs.njk +39 -0
- package/templates/nunjucks/toast.njk +137 -0
|
@@ -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 %}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Renders a standalone command menu component with search and keyboard navigation.
|
|
3
|
+
|
|
4
|
+
@param id {string} [optional] - Unique identifier for the command component.
|
|
5
|
+
@param items {array} [optional] - Array of items to render (alternative to using caller).
|
|
6
|
+
@param placeholder {string} [optional] [default="Type a command or search..."] - Placeholder text for the search input.
|
|
7
|
+
@param empty_text {string} [optional] [default="No results found."] - Text displayed when no results match the search.
|
|
8
|
+
@param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
|
|
9
|
+
@param input_attrs {object} [optional] - Additional HTML attributes for the search input.
|
|
10
|
+
@param menu_attrs {object} [optional] - Additional HTML attributes for the menu div.
|
|
11
|
+
#}
|
|
12
|
+
{% macro command(
|
|
13
|
+
id=None,
|
|
14
|
+
items=None,
|
|
15
|
+
placeholder="Type a command or search...",
|
|
16
|
+
empty_text="No results found.",
|
|
17
|
+
main_attrs={},
|
|
18
|
+
input_attrs={},
|
|
19
|
+
menu_attrs={}
|
|
20
|
+
) %}
|
|
21
|
+
{% set id = id or ("command-" + (range(100000, 999999) | random | string)) %}
|
|
22
|
+
<div
|
|
23
|
+
id="{{ id }}"
|
|
24
|
+
class="command {{ main_attrs.class }}"
|
|
25
|
+
aria-label="Command menu"
|
|
26
|
+
{% for key, value in main_attrs %}
|
|
27
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
28
|
+
{% endfor %}
|
|
29
|
+
>
|
|
30
|
+
<header>
|
|
31
|
+
<svg 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="lucide lucide-search-icon lucide-search"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
|
32
|
+
<input
|
|
33
|
+
type="text"
|
|
34
|
+
id="{{ id }}-input"
|
|
35
|
+
placeholder="{{ placeholder }}"
|
|
36
|
+
autocomplete="off"
|
|
37
|
+
autocorrect="off"
|
|
38
|
+
spellcheck="false"
|
|
39
|
+
aria-autocomplete="list"
|
|
40
|
+
role="combobox"
|
|
41
|
+
aria-expanded="true"
|
|
42
|
+
aria-controls="{{ id }}-menu"
|
|
43
|
+
{% for key, value in input_attrs %}
|
|
44
|
+
{{ key }}="{{ value }}"
|
|
45
|
+
{% endfor %}
|
|
46
|
+
>
|
|
47
|
+
</header>
|
|
48
|
+
<div
|
|
49
|
+
role="menu"
|
|
50
|
+
id="{{ id }}-menu"
|
|
51
|
+
aria-orientation="vertical"
|
|
52
|
+
data-empty="{{ empty_text }}"
|
|
53
|
+
class="{{ menu_attrs.class }}"
|
|
54
|
+
{% for key, value in menu_attrs %}
|
|
55
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
56
|
+
{% endfor %}
|
|
57
|
+
>
|
|
58
|
+
{% if items and items.length > 0 %}
|
|
59
|
+
{{ render_command_items(items, id ~ "-items" if id else "items") }}
|
|
60
|
+
{% else %}
|
|
61
|
+
{{ caller() if caller }}
|
|
62
|
+
{% endif %}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
{% endmacro %}
|
|
66
|
+
|
|
67
|
+
{#
|
|
68
|
+
Renders a command dialog (modal command palette).
|
|
69
|
+
|
|
70
|
+
@param id {string} [optional] - Unique identifier for the command dialog.
|
|
71
|
+
@param items {array} [optional] - Array of items to render (alternative to using caller).
|
|
72
|
+
@param placeholder {string} [optional] [default="Type a command or search..."] - Placeholder text for the search input.
|
|
73
|
+
@param empty_text {string} [optional] [default="No results found."] - Text displayed when no results match the search.
|
|
74
|
+
@param dialog_attrs {object} [optional] - Additional HTML attributes for the dialog element.
|
|
75
|
+
@param input_attrs {object} [optional] - Additional HTML attributes for the search input.
|
|
76
|
+
@param menu_attrs {object} [optional] - Additional HTML attributes for the menu div.
|
|
77
|
+
@param open {boolean} [optional] [default=false] - Whether the command dialog should be open initially.
|
|
78
|
+
#}
|
|
79
|
+
{% macro command_dialog(
|
|
80
|
+
id=None,
|
|
81
|
+
items=None,
|
|
82
|
+
placeholder="Type a command or search...",
|
|
83
|
+
empty_text="No results found.",
|
|
84
|
+
dialog_attrs={},
|
|
85
|
+
input_attrs={},
|
|
86
|
+
menu_attrs={},
|
|
87
|
+
open=false
|
|
88
|
+
) %}
|
|
89
|
+
{% set id = id or ("command-dialog-" + (range(100000, 999999) | random | string)) %}
|
|
90
|
+
<dialog
|
|
91
|
+
id="{{ id }}"
|
|
92
|
+
class="command-dialog {{ dialog_attrs.class }}"
|
|
93
|
+
aria-label="Command menu"
|
|
94
|
+
{% if open %}open{% endif %}
|
|
95
|
+
onclick="if (event.target === this) this.close()"
|
|
96
|
+
{% for key, value in dialog_attrs %}
|
|
97
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
98
|
+
{% endfor %}
|
|
99
|
+
>
|
|
100
|
+
<div class="command">
|
|
101
|
+
<header>
|
|
102
|
+
<svg 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="lucide lucide-search-icon lucide-search"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
|
|
103
|
+
<input
|
|
104
|
+
type="text"
|
|
105
|
+
id="{{ id }}-input"
|
|
106
|
+
placeholder="{{ placeholder }}"
|
|
107
|
+
autocomplete="off"
|
|
108
|
+
autocorrect="off"
|
|
109
|
+
spellcheck="false"
|
|
110
|
+
aria-autocomplete="list"
|
|
111
|
+
role="combobox"
|
|
112
|
+
aria-expanded="true"
|
|
113
|
+
aria-controls="{{ id }}-menu"
|
|
114
|
+
{% for key, value in input_attrs %}
|
|
115
|
+
{{ key }}="{{ value }}"
|
|
116
|
+
{% endfor %}
|
|
117
|
+
>
|
|
118
|
+
</header>
|
|
119
|
+
<div
|
|
120
|
+
role="menu"
|
|
121
|
+
id="{{ id }}-menu"
|
|
122
|
+
aria-orientation="vertical"
|
|
123
|
+
data-empty="{{ empty_text }}"
|
|
124
|
+
class="{{ menu_attrs.class }}"
|
|
125
|
+
{% for key, value in menu_attrs %}
|
|
126
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
127
|
+
{% endfor %}
|
|
128
|
+
>
|
|
129
|
+
{% if items and items.length > 0 %}
|
|
130
|
+
{{ render_command_items(items, id ~ "-items" if id else "items") }}
|
|
131
|
+
{% else %}
|
|
132
|
+
{{ caller() if caller }}
|
|
133
|
+
{% endif %}
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</dialog>
|
|
137
|
+
{% endmacro %}
|
|
138
|
+
|
|
139
|
+
{#
|
|
140
|
+
Renders a list of items for the command component.
|
|
141
|
+
|
|
142
|
+
@param items {array} - Array of items to render. Each item can be:
|
|
143
|
+
- { type: "item", label: "Text or HTML", icon: "HTML", url: "href", keywords: "search terms", disabled: true, attrs: {} }
|
|
144
|
+
- { type: "group", label: "Group Title", items: [...] }
|
|
145
|
+
- { type: "separator" }
|
|
146
|
+
Note: Use attrs to add data-label for alternative search text if needed. If url is provided, renders as <a role="menuitem"> instead of <div role="menuitem">. Label supports HTML (marked as safe).
|
|
147
|
+
@param parent_id_prefix {string} [optional] - The prefix for the item id.
|
|
148
|
+
#}
|
|
149
|
+
{% macro render_command_items(items, parent_id_prefix="items") %}
|
|
150
|
+
{% for item in items %}
|
|
151
|
+
{% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
|
|
152
|
+
{% if item.type == "group" %}
|
|
153
|
+
{% set group_label_id = item.id if item.id else "group-label-" + item_id %}
|
|
154
|
+
<div
|
|
155
|
+
role="group"
|
|
156
|
+
aria-labelledby="{{ group_label_id }}"
|
|
157
|
+
{% if item.attrs %}
|
|
158
|
+
{% for key, value in item.attrs %}
|
|
159
|
+
{{ key }}="{{ value }}"
|
|
160
|
+
{% endfor %}
|
|
161
|
+
{% endif %}
|
|
162
|
+
>
|
|
163
|
+
<span role="heading" id="{{ group_label_id }}">{{ item.label | safe }}</span>
|
|
164
|
+
{{ render_command_items(item.items, item_id) if item.items }}
|
|
165
|
+
</div>
|
|
166
|
+
{% elif item.type == "separator" %}
|
|
167
|
+
<hr role="separator" />
|
|
168
|
+
{% elif item.type == "item" or not item.type %}
|
|
169
|
+
{% if item.url %}
|
|
170
|
+
<a
|
|
171
|
+
id="{{ item_id }}"
|
|
172
|
+
href="{{ item.url }}"
|
|
173
|
+
role="menuitem"
|
|
174
|
+
{% if item.keywords %}data-keywords="{{ item.keywords }}"{% endif %}
|
|
175
|
+
{% if item.disabled %}aria-disabled="true"{% endif %}
|
|
176
|
+
{% if item.attrs %}
|
|
177
|
+
{% for key, value in item.attrs %}
|
|
178
|
+
{% if key != "href" %}{{ key }}="{{ value }}"{% endif %}
|
|
179
|
+
{% endfor %}
|
|
180
|
+
{% endif %}
|
|
181
|
+
>
|
|
182
|
+
{% if item.icon %}{{ item.icon | safe }}{% endif %}
|
|
183
|
+
{{ item.label | safe }}
|
|
184
|
+
</a>
|
|
185
|
+
{% else %}
|
|
186
|
+
<div
|
|
187
|
+
id="{{ item_id }}"
|
|
188
|
+
role="menuitem"
|
|
189
|
+
{% if item.keywords %}data-keywords="{{ item.keywords }}"{% endif %}
|
|
190
|
+
{% if item.disabled %}aria-disabled="true"{% endif %}
|
|
191
|
+
{% if item.attrs %}
|
|
192
|
+
{% for key, value in item.attrs %}
|
|
193
|
+
{{ key }}="{{ value }}"
|
|
194
|
+
{% endfor %}
|
|
195
|
+
{% endif %}
|
|
196
|
+
>
|
|
197
|
+
{% if item.icon %}{{ item.icon | safe }}{% endif %}
|
|
198
|
+
{{ item.label | safe }}
|
|
199
|
+
</div>
|
|
200
|
+
{% endif %}
|
|
201
|
+
{% endif %}
|
|
202
|
+
{% endfor %}
|
|
203
|
+
{% endmacro %}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Renders a dialog component with optional trigger, header, body, and footer.
|
|
3
|
+
|
|
4
|
+
@param id {string} - Unique identifier for the dialog component.
|
|
5
|
+
@param trigger {string} [optional] - Text or HTML for the button that triggers the dialog.
|
|
6
|
+
@param title {string} [optional] - Title text displayed in the dialog header.
|
|
7
|
+
@param description {string} [optional] - Description text displayed below the title.
|
|
8
|
+
@param footer {string} [optional] - HTML content for the dialog footer.
|
|
9
|
+
@param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger button.
|
|
10
|
+
@param dialog_attrs {object} [optional] - Additional HTML attributes for the dialog content container.
|
|
11
|
+
@param header_attrs {object} [optional] - Additional HTML attributes for the dialog header.
|
|
12
|
+
@param body_attrs {object} [optional] - Additional HTML attributes for the dialog body section.
|
|
13
|
+
@param footer_attrs {object} [optional] - Additional HTML attributes for the dialog footer.
|
|
14
|
+
@param open {boolean} [optional] [default=false] - Whether the dialog should be open initially.
|
|
15
|
+
@param close_button {boolean} [optional] [default=true] - Whether to include a close button.
|
|
16
|
+
@param close_on_overlay_click {boolean} [optional] [default=true] - Whether clicking the overlay closes the dialog.
|
|
17
|
+
#}
|
|
18
|
+
{% macro dialog(
|
|
19
|
+
id=None,
|
|
20
|
+
trigger=None,
|
|
21
|
+
title=None,
|
|
22
|
+
description=None,
|
|
23
|
+
footer=None,
|
|
24
|
+
dialog_attrs={},
|
|
25
|
+
trigger_attrs={},
|
|
26
|
+
header_attrs={},
|
|
27
|
+
body_attrs={},
|
|
28
|
+
footer_attrs={},
|
|
29
|
+
open=false,
|
|
30
|
+
close_button=true,
|
|
31
|
+
close_on_overlay_click=true
|
|
32
|
+
) %}
|
|
33
|
+
{% set id = id or ("dialog-" + (range(100000, 999999) | random | string)) %}
|
|
34
|
+
{% if trigger %}
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
onclick="document.getElementById('{{ id }}').showModal()"
|
|
38
|
+
{% for key, value in trigger_attrs %}
|
|
39
|
+
{{ key }}="{{ value }}"
|
|
40
|
+
{% endfor %}
|
|
41
|
+
>
|
|
42
|
+
{{ trigger | safe }}
|
|
43
|
+
</button>
|
|
44
|
+
{% endif %}
|
|
45
|
+
<dialog
|
|
46
|
+
id="{{ id }}"
|
|
47
|
+
class="dialog {{ dialog_attrs.class }}"
|
|
48
|
+
{% if title %}aria-labelledby="{{ id }}-title"{% endif %}
|
|
49
|
+
{% if description %}aria-describedby="{{ id }}-description"{% endif %}
|
|
50
|
+
{% if open %}open{% endif %}
|
|
51
|
+
{% if close_on_overlay_click %}onclick="if (event.target === this) this.close()"{% endif %}
|
|
52
|
+
{% for key, value in dialog_attrs %}
|
|
53
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
54
|
+
{% endfor %}
|
|
55
|
+
>
|
|
56
|
+
<div>
|
|
57
|
+
{% if title or description %}
|
|
58
|
+
<header
|
|
59
|
+
{% for key, value in header_attrs %}
|
|
60
|
+
{{ key }}="{{ value }}"
|
|
61
|
+
{% endfor %}
|
|
62
|
+
>
|
|
63
|
+
{% if title %}<h2 id="{{ id }}-title">{{ title | safe }}</h2>{% endif %}
|
|
64
|
+
{% if description %}<p id="{{ id }}-description">{{ description | safe }}</p>{% endif %}
|
|
65
|
+
</header>
|
|
66
|
+
{% endif %}
|
|
67
|
+
{% if caller %}
|
|
68
|
+
<section
|
|
69
|
+
{% for key, value in body_attrs %}
|
|
70
|
+
{{ key }}="{{ value }}"
|
|
71
|
+
{% endfor %}
|
|
72
|
+
>
|
|
73
|
+
{{ caller() }}
|
|
74
|
+
</section>
|
|
75
|
+
{% endif %}
|
|
76
|
+
{% if footer %}
|
|
77
|
+
<footer
|
|
78
|
+
{% for key, value in footer_attrs %}
|
|
79
|
+
{{ key }}="{{ value }}"
|
|
80
|
+
{% endfor %}
|
|
81
|
+
>
|
|
82
|
+
{{ footer | safe }}
|
|
83
|
+
</footer>
|
|
84
|
+
{% endif %}
|
|
85
|
+
{% if close_button %}
|
|
86
|
+
<button type="button" class="btn" data-variant="ghost" data-size="icon-sm" aria-label="Close dialog" onclick="this.closest('dialog').close()">
|
|
87
|
+
<svg 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="lucide lucide-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
|
88
|
+
</button>
|
|
89
|
+
{% endif %}
|
|
90
|
+
</div>
|
|
91
|
+
</dialog>
|
|
92
|
+
{% endmacro %}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Renders a dropdown menu component.
|
|
3
|
+
|
|
4
|
+
@param id {string} [optional] - Unique identifier for the dropdown component.
|
|
5
|
+
@param trigger {string} [optional] - HTML content for the button that triggers the dropdown.
|
|
6
|
+
@param items {array} [optional] - Array of menu items for the dropdown.
|
|
7
|
+
@param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
|
|
8
|
+
@param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger button.
|
|
9
|
+
@param popover_attrs {object} [optional] - Additional HTML attributes for the dropdown content div.
|
|
10
|
+
@param menu_attrs {object} [optional] - Additional HTML attributes for the menu div.
|
|
11
|
+
#}
|
|
12
|
+
{% macro dropdown_menu(
|
|
13
|
+
trigger,
|
|
14
|
+
id=None,
|
|
15
|
+
items=None,
|
|
16
|
+
main_attrs={},
|
|
17
|
+
trigger_attrs={},
|
|
18
|
+
popover_attrs={},
|
|
19
|
+
menu_attrs={}
|
|
20
|
+
) %}
|
|
21
|
+
{% set id = id or ("dropdown-menu-" + (range(100000, 999999) | random | string)) %}
|
|
22
|
+
|
|
23
|
+
<div
|
|
24
|
+
id="{{ id }}"
|
|
25
|
+
class="dropdown-menu {{ main_attrs.class }}"
|
|
26
|
+
{% for key, value in main_attrs %}
|
|
27
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
28
|
+
{% endfor %}
|
|
29
|
+
>
|
|
30
|
+
<button
|
|
31
|
+
type="button"
|
|
32
|
+
id="{{ id }}-trigger"
|
|
33
|
+
aria-haspopup="menu"
|
|
34
|
+
aria-controls="{{ id }}-menu"
|
|
35
|
+
aria-expanded="false"
|
|
36
|
+
{% for key, value in trigger_attrs %}
|
|
37
|
+
{{ key }}="{{ value }}"
|
|
38
|
+
{% endfor %}
|
|
39
|
+
>
|
|
40
|
+
{{ trigger | safe }}
|
|
41
|
+
</button>
|
|
42
|
+
<div
|
|
43
|
+
id="{{ id }}-popover"
|
|
44
|
+
data-popover
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
{% for key, value in popover_attrs %}
|
|
47
|
+
{{ key }}="{{ value }}"
|
|
48
|
+
{% endfor %}
|
|
49
|
+
>
|
|
50
|
+
<div
|
|
51
|
+
role="menu"
|
|
52
|
+
id="{{ id }}-menu"
|
|
53
|
+
aria-labelledby="{{ id }}-trigger"
|
|
54
|
+
{% for key, value in menu_attrs %}
|
|
55
|
+
{{ key }}="{{ value }}"
|
|
56
|
+
{% endfor %}
|
|
57
|
+
>
|
|
58
|
+
{% if items %}
|
|
59
|
+
{{ render_dropdown_items(items, id ~ "-items" if id else "items") }}
|
|
60
|
+
{% else %}
|
|
61
|
+
{{ caller() if caller }}
|
|
62
|
+
{% endif %}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
{% endmacro %}
|
|
67
|
+
|
|
68
|
+
{#
|
|
69
|
+
Renders dropdown menu items recursively.
|
|
70
|
+
|
|
71
|
+
@param items {array} - The array of items to render.
|
|
72
|
+
@param parent_id_prefix {string} [optional] - Prefix for generating element IDs.
|
|
73
|
+
#}
|
|
74
|
+
{% macro render_dropdown_items(items, parent_id_prefix="items") %}
|
|
75
|
+
{% for item in items %}
|
|
76
|
+
{% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
|
|
77
|
+
|
|
78
|
+
{% if item.type == "group" %}
|
|
79
|
+
{% set group_label_id = item.id if item.id else "group-label-" + item_id %}
|
|
80
|
+
<div
|
|
81
|
+
role="group"
|
|
82
|
+
aria-labelledby="{{ group_label_id }}"
|
|
83
|
+
{% if item.attrs %}
|
|
84
|
+
{% for key, value in item.attrs %}
|
|
85
|
+
{{ key }}="{{ value }}"
|
|
86
|
+
{% endfor %}
|
|
87
|
+
{% endif %}
|
|
88
|
+
>
|
|
89
|
+
<div role="heading" id="{{ group_label_id }}">{{ item.label }}</div>
|
|
90
|
+
{{ render_dropdown_items(item.items, item_id) if item.items }}
|
|
91
|
+
</div>
|
|
92
|
+
{% elif item.type == "separator" %}
|
|
93
|
+
<hr role="separator" />
|
|
94
|
+
{% elif item.type == "item" or not item.type %}
|
|
95
|
+
{% if item.url %}
|
|
96
|
+
<a
|
|
97
|
+
id="{{ item_id }}"
|
|
98
|
+
role="menuitem"
|
|
99
|
+
href="{{ item.url }}"
|
|
100
|
+
{% if item.attrs %}
|
|
101
|
+
{% for key, value in item.attrs %}
|
|
102
|
+
{% if key != "href" and key != "url" %} {{ key }}="{{ value }}" {% endif %}
|
|
103
|
+
{% endfor %}
|
|
104
|
+
{% endif %}
|
|
105
|
+
>
|
|
106
|
+
{% if item.icon %}{{ item.icon | safe }}{% endif %}
|
|
107
|
+
{{ item.label | safe }}
|
|
108
|
+
</a>
|
|
109
|
+
{% else %}
|
|
110
|
+
<div
|
|
111
|
+
id="{{ item_id }}"
|
|
112
|
+
role="menuitem"
|
|
113
|
+
{% if item.attrs %}
|
|
114
|
+
{% for key, value in item.attrs %}
|
|
115
|
+
{{ key }}="{{ value }}"
|
|
116
|
+
{% endfor %}
|
|
117
|
+
{% endif %}
|
|
118
|
+
>
|
|
119
|
+
{% if item.icon %}{{ item.icon | safe }}{% endif %}
|
|
120
|
+
{{ item.label | safe }}
|
|
121
|
+
</div>
|
|
122
|
+
{% endif %}
|
|
123
|
+
{% endif %}
|
|
124
|
+
{% endfor %}
|
|
125
|
+
{% endmacro %}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Renders a generic popover component, often used internally by other components like dropdowns or selects.
|
|
3
|
+
|
|
4
|
+
@param id {string} [optional] - Unique identifier for the popover component.
|
|
5
|
+
@param trigger {string} [optional] - HTML content for the element that triggers the popover.
|
|
6
|
+
@param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
|
|
7
|
+
@param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger element.
|
|
8
|
+
@param popover_attrs {object} [optional] - Additional HTML attributes for the popover content div.
|
|
9
|
+
#}
|
|
10
|
+
{% macro popover(
|
|
11
|
+
trigger,
|
|
12
|
+
id=None,
|
|
13
|
+
main_attrs={},
|
|
14
|
+
trigger_attrs={},
|
|
15
|
+
popover_attrs={}
|
|
16
|
+
) %}
|
|
17
|
+
{% set id = id or ("popover-" + (range(100000, 999999) | random | string)) %}
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
id="{{ id }}"
|
|
21
|
+
class="popover {{ main_attrs.class }}"
|
|
22
|
+
{% for key, value in main_attrs %}
|
|
23
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
24
|
+
{% endfor %}
|
|
25
|
+
>
|
|
26
|
+
<button
|
|
27
|
+
id="{{ id }}-trigger"
|
|
28
|
+
type="button"
|
|
29
|
+
aria-expanded="false"
|
|
30
|
+
aria-controls="{{ id }}-popover"
|
|
31
|
+
{% for key, value in trigger_attrs %}
|
|
32
|
+
{{ key }}="{{ value }}"
|
|
33
|
+
{% endfor %}
|
|
34
|
+
>
|
|
35
|
+
{{ trigger | safe }}
|
|
36
|
+
</button>
|
|
37
|
+
<div
|
|
38
|
+
id="{{ id }}-popover"
|
|
39
|
+
data-popover
|
|
40
|
+
aria-hidden="true"
|
|
41
|
+
{% for key, value in popover_attrs %}
|
|
42
|
+
{{ key }}="{{ value }}"
|
|
43
|
+
{% endfor %}
|
|
44
|
+
>
|
|
45
|
+
{{ caller() if caller }}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
{% endmacro %}
|