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,147 @@
|
|
|
1
|
+
{#
|
|
2
|
+
Renders an input-first combobox component.
|
|
3
|
+
#}
|
|
4
|
+
{% macro combobox(
|
|
5
|
+
id=None,
|
|
6
|
+
selected=None,
|
|
7
|
+
name=None,
|
|
8
|
+
multiple=false,
|
|
9
|
+
placeholder=None,
|
|
10
|
+
close_on_select=false,
|
|
11
|
+
clear=false,
|
|
12
|
+
auto_highlight=false,
|
|
13
|
+
format="value",
|
|
14
|
+
main_attrs={},
|
|
15
|
+
input_attrs={},
|
|
16
|
+
popover_attrs={},
|
|
17
|
+
listbox_attrs={},
|
|
18
|
+
hidden_input_attrs={}
|
|
19
|
+
) %}
|
|
20
|
+
{% set id = id or ("combobox-" + (range(100000, 999999) | random | string)) %}
|
|
21
|
+
{% set main_attrs = main_attrs or {} %}
|
|
22
|
+
{% set input_attrs = input_attrs or {} %}
|
|
23
|
+
{% set popover_attrs = popover_attrs or {} %}
|
|
24
|
+
{% set listbox_attrs = listbox_attrs or {} %}
|
|
25
|
+
{% set hidden_input_attrs = hidden_input_attrs or {} %}
|
|
26
|
+
{% set selected_entries = namespace(items=[]) %}
|
|
27
|
+
{% if selected is defined and selected is iterable and selected is not string %}
|
|
28
|
+
{% set selected_values = selected %}
|
|
29
|
+
{% for item in selected %}
|
|
30
|
+
{% if item.value is defined %}
|
|
31
|
+
{% set selected_entries.items = selected_entries.items + [{'value': item.value, 'label': item.label if item.label is defined else item.value}] %}
|
|
32
|
+
{% else %}
|
|
33
|
+
{% set selected_entries.items = selected_entries.items + [{'value': item, 'label': item}] %}
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endfor %}
|
|
36
|
+
{% elif selected is defined and selected %}
|
|
37
|
+
{% if selected.value is defined %}
|
|
38
|
+
{% set selected_values = [selected.value] %}
|
|
39
|
+
{% set selected_entries.items = [{'value': selected.value, 'label': selected.label if selected.label is defined else selected.value}] %}
|
|
40
|
+
{% else %}
|
|
41
|
+
{% set selected_values = [selected] %}
|
|
42
|
+
{% set selected_entries.items = [{'value': selected, 'label': selected}] %}
|
|
43
|
+
{% endif %}
|
|
44
|
+
{% else %}
|
|
45
|
+
{% set selected_values = [] %}
|
|
46
|
+
{% endif %}
|
|
47
|
+
{% set hidden_value = ((selected_entries.items | tojson if multiple else ((selected_entries.items[0] if selected_entries.items else none) | tojson)) if format == "object" else (selected_values | tojson if multiple else (selected_values[0] if selected_values else ''))) %}
|
|
48
|
+
|
|
49
|
+
<div
|
|
50
|
+
id="{{ id }}"
|
|
51
|
+
class="combobox {{ main_attrs.class | default('') }}"
|
|
52
|
+
{% if format == "object" %}data-format="object"{% endif %}
|
|
53
|
+
{% if multiple and close_on_select %}data-close-on-select="true"{% endif %}
|
|
54
|
+
{% if auto_highlight %}data-auto-highlight="true"{% endif %}
|
|
55
|
+
{% for key, value in main_attrs.items() %}
|
|
56
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
57
|
+
{% endfor %}
|
|
58
|
+
>
|
|
59
|
+
{% if multiple %}
|
|
60
|
+
<input
|
|
61
|
+
type="text"
|
|
62
|
+
role="combobox"
|
|
63
|
+
class="{{ input_attrs.class | default('') }}"
|
|
64
|
+
placeholder="{{ placeholder or '' }}"
|
|
65
|
+
autocomplete="off"
|
|
66
|
+
autocorrect="off"
|
|
67
|
+
spellcheck="false"
|
|
68
|
+
aria-autocomplete="list"
|
|
69
|
+
aria-expanded="false"
|
|
70
|
+
aria-controls="{{ id }}-listbox"
|
|
71
|
+
{% for key, value in input_attrs.items() %}
|
|
72
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
73
|
+
{% endfor %}
|
|
74
|
+
>
|
|
75
|
+
{% elif clear %}
|
|
76
|
+
<div class="input-group {{ input_attrs.class | default('') }}">
|
|
77
|
+
<input
|
|
78
|
+
type="text"
|
|
79
|
+
role="combobox"
|
|
80
|
+
placeholder="{{ placeholder or '' }}"
|
|
81
|
+
autocomplete="off"
|
|
82
|
+
autocorrect="off"
|
|
83
|
+
spellcheck="false"
|
|
84
|
+
aria-autocomplete="list"
|
|
85
|
+
aria-expanded="false"
|
|
86
|
+
aria-controls="{{ id }}-listbox"
|
|
87
|
+
{% for key, value in input_attrs.items() %}
|
|
88
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
89
|
+
{% endfor %}
|
|
90
|
+
>
|
|
91
|
+
<span role="group" data-align="inline-end">
|
|
92
|
+
<button type="button" data-clear aria-label="Clear selection">
|
|
93
|
+
<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>
|
|
94
|
+
</button>
|
|
95
|
+
<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">
|
|
96
|
+
<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>
|
|
97
|
+
</button>
|
|
98
|
+
</span>
|
|
99
|
+
</div>
|
|
100
|
+
{% else %}
|
|
101
|
+
<input
|
|
102
|
+
type="text"
|
|
103
|
+
role="combobox"
|
|
104
|
+
placeholder="{{ placeholder or '' }}"
|
|
105
|
+
autocomplete="off"
|
|
106
|
+
autocorrect="off"
|
|
107
|
+
spellcheck="false"
|
|
108
|
+
aria-autocomplete="list"
|
|
109
|
+
aria-expanded="false"
|
|
110
|
+
aria-controls="{{ id }}-listbox"
|
|
111
|
+
class="{{ input_attrs.class | default('') }}"
|
|
112
|
+
{% for key, value in input_attrs.items() %}
|
|
113
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
114
|
+
{% endfor %}
|
|
115
|
+
>
|
|
116
|
+
<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>
|
|
117
|
+
{% endif %}
|
|
118
|
+
<div
|
|
119
|
+
id="{{ id }}-popover"
|
|
120
|
+
data-popover
|
|
121
|
+
aria-hidden="true"
|
|
122
|
+
{% for key, value in popover_attrs.items() %}
|
|
123
|
+
{{ key }}="{{ value }}"
|
|
124
|
+
{% endfor %}
|
|
125
|
+
>
|
|
126
|
+
<div
|
|
127
|
+
role="listbox"
|
|
128
|
+
id="{{ id }}-listbox"
|
|
129
|
+
aria-orientation="vertical"
|
|
130
|
+
{% if multiple %}aria-multiselectable="true"{% endif %}
|
|
131
|
+
{% for key, value in listbox_attrs.items() %}
|
|
132
|
+
{{ key }}="{{ value }}"
|
|
133
|
+
{% endfor %}
|
|
134
|
+
>
|
|
135
|
+
{{ caller() if caller is defined else '' }}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
<input
|
|
139
|
+
type="hidden"
|
|
140
|
+
{% if name %}name="{{ name }}"{% endif %}
|
|
141
|
+
value='{{ hidden_value }}'
|
|
142
|
+
{% for key, value in hidden_input_attrs.items() %}
|
|
143
|
+
{{ key }}="{{ value }}"
|
|
144
|
+
{% endfor %}
|
|
145
|
+
>
|
|
146
|
+
</div>
|
|
147
|
+
{% endmacro %}
|
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
{% set main_attrs = main_attrs or {} %}
|
|
23
|
+
{% set input_attrs = input_attrs or {} %}
|
|
24
|
+
{% set menu_attrs = menu_attrs or {} %}
|
|
25
|
+
<div
|
|
26
|
+
id="{{ id }}"
|
|
27
|
+
class="command {{ main_attrs.class | default('') }}"
|
|
28
|
+
aria-label="Command menu"
|
|
29
|
+
{% for key, value in main_attrs.items() %}
|
|
30
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
31
|
+
{% endfor %}
|
|
32
|
+
>
|
|
33
|
+
<header>
|
|
34
|
+
<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>
|
|
35
|
+
<input
|
|
36
|
+
type="text"
|
|
37
|
+
id="{{ id }}-input"
|
|
38
|
+
placeholder="{{ placeholder }}"
|
|
39
|
+
autocomplete="off"
|
|
40
|
+
autocorrect="off"
|
|
41
|
+
spellcheck="false"
|
|
42
|
+
aria-autocomplete="list"
|
|
43
|
+
role="combobox"
|
|
44
|
+
aria-expanded="true"
|
|
45
|
+
aria-controls="{{ id }}-menu"
|
|
46
|
+
{% for key, value in input_attrs.items() %}
|
|
47
|
+
{{ key }}="{{ value }}"
|
|
48
|
+
{% endfor %}
|
|
49
|
+
>
|
|
50
|
+
</header>
|
|
51
|
+
<div
|
|
52
|
+
role="menu"
|
|
53
|
+
id="{{ id }}-menu"
|
|
54
|
+
aria-orientation="vertical"
|
|
55
|
+
data-empty="{{ empty_text }}"
|
|
56
|
+
class="{{ menu_attrs.class | default('') }}"
|
|
57
|
+
{% for key, value in menu_attrs.items() %}
|
|
58
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
59
|
+
{% endfor %}
|
|
60
|
+
>
|
|
61
|
+
{% if items and items|length > 0 %}
|
|
62
|
+
{{ render_command_items(items, id ~ "-items" if id else "items") }}
|
|
63
|
+
{% else %}
|
|
64
|
+
{{ caller() if caller is defined }}
|
|
65
|
+
{% endif %}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
{% endmacro %}
|
|
69
|
+
|
|
70
|
+
{#
|
|
71
|
+
Renders a command dialog (modal command palette).
|
|
72
|
+
|
|
73
|
+
@param id {string} [optional] - Unique identifier for the command dialog.
|
|
74
|
+
@param items {array} [optional] - Array of items to render (alternative to using caller).
|
|
75
|
+
@param placeholder {string} [optional] [default="Type a command or search..."] - Placeholder text for the search input.
|
|
76
|
+
@param empty_text {string} [optional] [default="No results found."] - Text displayed when no results match the search.
|
|
77
|
+
@param dialog_attrs {object} [optional] - Additional HTML attributes for the dialog element.
|
|
78
|
+
@param input_attrs {object} [optional] - Additional HTML attributes for the search input.
|
|
79
|
+
@param menu_attrs {object} [optional] - Additional HTML attributes for the menu div.
|
|
80
|
+
@param open {boolean} [optional] [default=False] - Whether the command dialog should be open initially.
|
|
81
|
+
#}
|
|
82
|
+
{% macro command_dialog(
|
|
83
|
+
id=None,
|
|
84
|
+
items=None,
|
|
85
|
+
placeholder="Type a command or search...",
|
|
86
|
+
empty_text="No results found.",
|
|
87
|
+
dialog_attrs={},
|
|
88
|
+
input_attrs={},
|
|
89
|
+
menu_attrs={},
|
|
90
|
+
open=False
|
|
91
|
+
) %}
|
|
92
|
+
{% set id = id or ("command-dialog-" ~ range(100000, 999999) | random | string) %}
|
|
93
|
+
{% set dialog_attrs = dialog_attrs or {} %}
|
|
94
|
+
{% set input_attrs = input_attrs or {} %}
|
|
95
|
+
{% set menu_attrs = menu_attrs or {} %}
|
|
96
|
+
<dialog
|
|
97
|
+
id="{{ id }}"
|
|
98
|
+
class="command-dialog {{ dialog_attrs.class | default('') }}"
|
|
99
|
+
aria-label="Command menu"
|
|
100
|
+
{% if open %}open{% endif %}
|
|
101
|
+
onclick="if (event.target === this) this.close()"
|
|
102
|
+
{% for key, value in dialog_attrs.items() %}
|
|
103
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
104
|
+
{% endfor %}
|
|
105
|
+
>
|
|
106
|
+
<div class="command">
|
|
107
|
+
<header>
|
|
108
|
+
<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>
|
|
109
|
+
<input
|
|
110
|
+
type="text"
|
|
111
|
+
id="{{ id }}-input"
|
|
112
|
+
placeholder="{{ placeholder }}"
|
|
113
|
+
autocomplete="off"
|
|
114
|
+
autocorrect="off"
|
|
115
|
+
spellcheck="false"
|
|
116
|
+
aria-autocomplete="list"
|
|
117
|
+
role="combobox"
|
|
118
|
+
aria-expanded="true"
|
|
119
|
+
aria-controls="{{ id }}-menu"
|
|
120
|
+
{% for key, value in input_attrs.items() %}
|
|
121
|
+
{{ key }}="{{ value }}"
|
|
122
|
+
{% endfor %}
|
|
123
|
+
>
|
|
124
|
+
</header>
|
|
125
|
+
<div
|
|
126
|
+
role="menu"
|
|
127
|
+
id="{{ id }}-menu"
|
|
128
|
+
aria-orientation="vertical"
|
|
129
|
+
data-empty="{{ empty_text }}"
|
|
130
|
+
class="{{ menu_attrs.class | default('') }}"
|
|
131
|
+
{% for key, value in menu_attrs.items() %}
|
|
132
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
133
|
+
{% endfor %}
|
|
134
|
+
>
|
|
135
|
+
{% if items and items|length > 0 %}
|
|
136
|
+
{{ render_command_items(items, id ~ "-items" if id else "items") }}
|
|
137
|
+
{% else %}
|
|
138
|
+
{{ caller() if caller is defined }}
|
|
139
|
+
{% endif %}
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</dialog>
|
|
143
|
+
{% endmacro %}
|
|
144
|
+
|
|
145
|
+
{#
|
|
146
|
+
Renders a list of items for the command component.
|
|
147
|
+
|
|
148
|
+
@param items {array} - Array of items to render. Each item can be:
|
|
149
|
+
- { type: "item", label: "Text or HTML", icon: "HTML", url: "href", keywords: "search terms", disabled: true, attrs: {} }
|
|
150
|
+
- { type: "group", label: "Group Title", items: [...] }
|
|
151
|
+
- { type: "separator" }
|
|
152
|
+
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).
|
|
153
|
+
@param parent_id_prefix {string} [optional] - The prefix for the item id.
|
|
154
|
+
#}
|
|
155
|
+
{% macro render_command_items(items, parent_id_prefix="items") %}
|
|
156
|
+
{% for item in items %}
|
|
157
|
+
{% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
|
|
158
|
+
{% set item_type = item.type | default("item") %}
|
|
159
|
+
{% if item_type == "group" %}
|
|
160
|
+
{% set group_label_id = item.id | default("group-label-" + item_id) %}
|
|
161
|
+
<div
|
|
162
|
+
role="group"
|
|
163
|
+
aria-labelledby="{{ group_label_id }}"
|
|
164
|
+
{% if item.attrs is defined and item.attrs %}
|
|
165
|
+
{% for key, value in item.attrs.items() %}
|
|
166
|
+
{{ key }}="{{ value }}"
|
|
167
|
+
{% endfor %}
|
|
168
|
+
{% endif %}
|
|
169
|
+
>
|
|
170
|
+
<span role="heading" id="{{ group_label_id }}">{{ item.label | default('') | safe }}</span>
|
|
171
|
+
{{ render_command_items(item.get('items', []), item_id) if item.get('items') }}
|
|
172
|
+
</div>
|
|
173
|
+
{% elif item_type == "separator" %}
|
|
174
|
+
<hr role="separator" />
|
|
175
|
+
{% elif item_type == "item" %}
|
|
176
|
+
{% if item.url is defined and item.url %}
|
|
177
|
+
<a
|
|
178
|
+
id="{{ item_id }}"
|
|
179
|
+
href="{{ item.url }}"
|
|
180
|
+
role="menuitem"
|
|
181
|
+
{% if item.keywords is defined and item.keywords %}data-keywords="{{ item.keywords }}"{% endif %}
|
|
182
|
+
{% if item.disabled is defined and item.disabled %}aria-disabled="true"{% endif %}
|
|
183
|
+
{% if item.attrs is defined and item.attrs %}
|
|
184
|
+
{% for key, value in item.attrs.items() %}
|
|
185
|
+
{% if key != "href" %}{{ key }}="{{ value }}"{% endif %}
|
|
186
|
+
{% endfor %}
|
|
187
|
+
{% endif %}
|
|
188
|
+
>
|
|
189
|
+
{% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
|
|
190
|
+
{{ item.label | default('') | safe }}
|
|
191
|
+
</a>
|
|
192
|
+
{% else %}
|
|
193
|
+
<div
|
|
194
|
+
id="{{ item_id }}"
|
|
195
|
+
role="menuitem"
|
|
196
|
+
{% if item.keywords is defined and item.keywords %}data-keywords="{{ item.keywords }}"{% endif %}
|
|
197
|
+
{% if item.disabled is defined and item.disabled %}aria-disabled="true"{% endif %}
|
|
198
|
+
{% if item.attrs is defined and item.attrs %}
|
|
199
|
+
{% for key, value in item.attrs.items() %}
|
|
200
|
+
{{ key }}="{{ value }}"
|
|
201
|
+
{% endfor %}
|
|
202
|
+
{% endif %}
|
|
203
|
+
>
|
|
204
|
+
{% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
|
|
205
|
+
{{ item.label | default('') | safe }}
|
|
206
|
+
</div>
|
|
207
|
+
{% endif %}
|
|
208
|
+
{% endif %}
|
|
209
|
+
{% endfor %}
|
|
210
|
+
{% endmacro %}
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
{% set dialog_attrs = dialog_attrs or {} %}
|
|
35
|
+
{% set trigger_attrs = trigger_attrs or {} %}
|
|
36
|
+
{% set header_attrs = header_attrs or {} %}
|
|
37
|
+
{% set body_attrs = body_attrs or {} %}
|
|
38
|
+
{% set footer_attrs = footer_attrs or {} %}
|
|
39
|
+
{% if trigger %}
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
onclick="document.getElementById('{{ id }}').showModal()"
|
|
43
|
+
{% for key, value in trigger_attrs.items() %}
|
|
44
|
+
{{ key }}="{{ value }}"
|
|
45
|
+
{% endfor %}
|
|
46
|
+
>
|
|
47
|
+
{{ trigger | safe }}
|
|
48
|
+
</button>
|
|
49
|
+
{% endif %}
|
|
50
|
+
<dialog
|
|
51
|
+
id="{{ id }}"
|
|
52
|
+
class="dialog {{ dialog_attrs.class | default('') }}"
|
|
53
|
+
{% if title %}aria-labelledby="{{ id }}-title"{% endif %}
|
|
54
|
+
{% if description %}aria-describedby="{{ id }}-description"{% endif %}
|
|
55
|
+
{% if open %}open{% endif %}
|
|
56
|
+
{% if close_on_overlay_click %}onclick="if (event.target === this) this.close()"{% endif %}
|
|
57
|
+
{% for key, value in dialog_attrs.items() %}
|
|
58
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
59
|
+
{% endfor %}
|
|
60
|
+
>
|
|
61
|
+
<div>
|
|
62
|
+
{% if title or description %}
|
|
63
|
+
<header
|
|
64
|
+
{% for key, value in header_attrs.items() %}
|
|
65
|
+
{{ key }}="{{ value }}"
|
|
66
|
+
{% endfor %}
|
|
67
|
+
>
|
|
68
|
+
{% if title %}<h2 id="{{ id }}-title">{{ title | safe }}</h2>{% endif %}
|
|
69
|
+
{% if description %}<p id="{{ id }}-description">{{ description | safe }}</p>{% endif %}
|
|
70
|
+
</header>
|
|
71
|
+
{% endif %}
|
|
72
|
+
{% if caller is defined %}
|
|
73
|
+
<section
|
|
74
|
+
{% for key, value in body_attrs.items() %}
|
|
75
|
+
{{ key }}="{{ value }}"
|
|
76
|
+
{% endfor %}
|
|
77
|
+
>
|
|
78
|
+
{{ caller() }}
|
|
79
|
+
</section>
|
|
80
|
+
{% endif %}
|
|
81
|
+
{% if footer %}
|
|
82
|
+
<footer
|
|
83
|
+
{% for key, value in footer_attrs.items() %}
|
|
84
|
+
{{ key }}="{{ value }}"
|
|
85
|
+
{% endfor %}
|
|
86
|
+
>
|
|
87
|
+
{{ footer | safe }}
|
|
88
|
+
</footer>
|
|
89
|
+
{% endif %}
|
|
90
|
+
{% if close_button %}
|
|
91
|
+
<button type="button" class="btn" data-variant="ghost" data-size="icon-sm" aria-label="Close dialog" onclick="this.closest('dialog').close()">
|
|
92
|
+
<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>
|
|
93
|
+
</button>
|
|
94
|
+
{% endif %}
|
|
95
|
+
</div>
|
|
96
|
+
</dialog>
|
|
97
|
+
{% endmacro %}
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
{% set main_attrs = main_attrs or {} %}
|
|
23
|
+
{% set trigger_attrs = trigger_attrs or {} %}
|
|
24
|
+
{% set popover_attrs = popover_attrs or {} %}
|
|
25
|
+
{% set menu_attrs = menu_attrs or {} %}
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
id="{{ id }}"
|
|
29
|
+
class="dropdown-menu {{ main_attrs.class | default('') }}"
|
|
30
|
+
{% for key, value in main_attrs.items() %}
|
|
31
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
32
|
+
{% endfor %}
|
|
33
|
+
>
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
id="{{ id }}-trigger"
|
|
37
|
+
aria-haspopup="menu"
|
|
38
|
+
aria-controls="{{ id }}-menu"
|
|
39
|
+
aria-expanded="false"
|
|
40
|
+
{% for key, value in trigger_attrs.items() %}
|
|
41
|
+
{{ key }}="{{ value }}"
|
|
42
|
+
{% endfor %}
|
|
43
|
+
>
|
|
44
|
+
{{ trigger | safe }}
|
|
45
|
+
</button>
|
|
46
|
+
<div
|
|
47
|
+
id="{{ id }}-popover"
|
|
48
|
+
data-popover
|
|
49
|
+
aria-hidden="true"
|
|
50
|
+
{% for key, value in popover_attrs.items() %}
|
|
51
|
+
{{ key }}="{{ value }}"
|
|
52
|
+
{% endfor %}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
role="menu"
|
|
56
|
+
id="{{ id }}-menu"
|
|
57
|
+
aria-labelledby="{{ id }}-trigger"
|
|
58
|
+
{% for key, value in menu_attrs.items() %}
|
|
59
|
+
{{ key }}="{{ value }}"
|
|
60
|
+
{% endfor %}
|
|
61
|
+
>
|
|
62
|
+
{% if items %}
|
|
63
|
+
{{ render_dropdown_items(items, id ~ "-items" if id else "items") }}
|
|
64
|
+
{% else %}
|
|
65
|
+
{{ caller() if caller is defined }}
|
|
66
|
+
{% endif %}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
{% endmacro %}
|
|
71
|
+
|
|
72
|
+
{#
|
|
73
|
+
Renders dropdown menu items recursively.
|
|
74
|
+
|
|
75
|
+
@param items {array} - The array of items to render.
|
|
76
|
+
@param parent_id_prefix {string} [optional] - Prefix for generating element IDs.
|
|
77
|
+
#}
|
|
78
|
+
{% macro render_dropdown_items(items, parent_id_prefix="items") %}
|
|
79
|
+
{% for item in items %}
|
|
80
|
+
{% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
|
|
81
|
+
|
|
82
|
+
{% set item_type = item.type | default("item") %}
|
|
83
|
+
{% if item_type == "group" %}
|
|
84
|
+
{% set group_label_id = item.id | default("group-label-" + item_id) %}
|
|
85
|
+
<div
|
|
86
|
+
role="group"
|
|
87
|
+
aria-labelledby="{{ group_label_id }}"
|
|
88
|
+
{% if item.attrs is defined and item.attrs %}
|
|
89
|
+
{% for key, value in item.attrs.items() %}
|
|
90
|
+
{{ key }}="{{ value }}"
|
|
91
|
+
{% endfor %}
|
|
92
|
+
{% endif %}
|
|
93
|
+
>
|
|
94
|
+
<div role="heading" id="{{ group_label_id }}">{{ item.label | default('') }}</div>
|
|
95
|
+
{{ render_dropdown_items(item.get('items', []), item_id) if item.get('items') }}
|
|
96
|
+
</div>
|
|
97
|
+
{% elif item_type == "separator" %}
|
|
98
|
+
<hr role="separator" />
|
|
99
|
+
{% elif item_type == "item" %}
|
|
100
|
+
{% if item.url is defined and item.url %}
|
|
101
|
+
<a
|
|
102
|
+
id="{{ item_id }}"
|
|
103
|
+
role="menuitem"
|
|
104
|
+
href="{{ item.url }}"
|
|
105
|
+
{% if item.attrs is defined and item.attrs %}
|
|
106
|
+
{% for key, value in item.attrs.items() %}
|
|
107
|
+
{% if key != "href" and key != "url" %} {{ key }}="{{ value }}" {% endif %}
|
|
108
|
+
{% endfor %}
|
|
109
|
+
{% endif %}
|
|
110
|
+
>
|
|
111
|
+
{% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
|
|
112
|
+
{{ item.label | default('') | safe }}
|
|
113
|
+
</a>
|
|
114
|
+
{% else %}
|
|
115
|
+
<div
|
|
116
|
+
id="{{ item_id }}"
|
|
117
|
+
role="menuitem"
|
|
118
|
+
{% if item.attrs is defined and item.attrs %}
|
|
119
|
+
{% for key, value in item.attrs.items() %}
|
|
120
|
+
{{ key }}="{{ value }}"
|
|
121
|
+
{% endfor %}
|
|
122
|
+
{% endif %}
|
|
123
|
+
>
|
|
124
|
+
{% if item.icon is defined and item.icon %}{{ item.icon | safe }}{% endif %}
|
|
125
|
+
{{ item.label | default('') | safe }}
|
|
126
|
+
</div>
|
|
127
|
+
{% endif %}
|
|
128
|
+
{% endif %}
|
|
129
|
+
{% endfor %}
|
|
130
|
+
{% endmacro %}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
{% set main_attrs = main_attrs or {} %}
|
|
19
|
+
{% set trigger_attrs = trigger_attrs or {} %}
|
|
20
|
+
{% set popover_attrs = popover_attrs or {} %}
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
id="{{ id }}"
|
|
24
|
+
class="popover {{ main_attrs.class | default('') }}"
|
|
25
|
+
{% for key, value in main_attrs.items() %}
|
|
26
|
+
{% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
|
|
27
|
+
{% endfor %}
|
|
28
|
+
>
|
|
29
|
+
<button
|
|
30
|
+
id="{{ id }}-trigger"
|
|
31
|
+
type="button"
|
|
32
|
+
aria-expanded="false"
|
|
33
|
+
aria-controls="{{ id }}-popover"
|
|
34
|
+
{% for key, value in trigger_attrs.items() %}
|
|
35
|
+
{{ key }}="{{ value }}"
|
|
36
|
+
{% endfor %}
|
|
37
|
+
>
|
|
38
|
+
{{ trigger | safe }}
|
|
39
|
+
</button>
|
|
40
|
+
<div
|
|
41
|
+
id="{{ id }}-popover"
|
|
42
|
+
data-popover
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
{% for key, value in popover_attrs.items() %}
|
|
45
|
+
{{ key }}="{{ value }}"
|
|
46
|
+
{% endfor %}
|
|
47
|
+
>
|
|
48
|
+
{{ caller() if caller is defined }}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
{% endmacro %}
|