aeno 0.0.3
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +230 -0
- data/Rakefile +8 -0
- data/app/assets/stylesheets/aeno/application.css +1 -0
- data/app/assets/stylesheets/aeno/base.css +43 -0
- data/app/assets/stylesheets/aeno/reset.css +397 -0
- data/app/assets/stylesheets/aeno/source.css +15 -0
- data/app/assets/stylesheets/aeno/theme.css +6 -0
- data/app/assets/stylesheets/aeno/themes/slate.css +163 -0
- data/app/assets/stylesheets/aeno/themes/zinc.css +163 -0
- data/app/assets/stylesheets/aeno/utilities.css +23 -0
- data/app/components/aeno/application_view_component.rb +219 -0
- data/app/components/aeno/blocks/component_preview/component.html.erb +7 -0
- data/app/components/aeno/blocks/component_preview/component.rb +10 -0
- data/app/components/aeno/blocks/component_preview/styles.css +10 -0
- data/app/components/aeno/form_builder.rb +87 -0
- data/app/components/aeno/pages/showcase/index/component.html.erb +53 -0
- data/app/components/aeno/pages/showcase/index/component.rb +7 -0
- data/app/components/aeno/pages/showcase/index/styles.css +27 -0
- data/app/components/aeno/pages/showcase/placeholder/component.html.erb +7 -0
- data/app/components/aeno/pages/showcase/placeholder/component.rb +10 -0
- data/app/components/aeno/pages/showcase/show/component.html.erb +38 -0
- data/app/components/aeno/pages/showcase/show/component.rb +48 -0
- data/app/components/aeno/primitives/button/component.rb +66 -0
- data/app/components/aeno/primitives/button/controller.js +7 -0
- data/app/components/aeno/primitives/button/styles.css +153 -0
- data/app/components/aeno/primitives/card/component.html.erb +3 -0
- data/app/components/aeno/primitives/card/component.rb +42 -0
- data/app/components/aeno/primitives/card/styles.css +28 -0
- data/app/components/aeno/primitives/conversation/component.html.erb +28 -0
- data/app/components/aeno/primitives/conversation/component.rb +15 -0
- data/app/components/aeno/primitives/conversation/controller.js +18 -0
- data/app/components/aeno/primitives/conversation/message/component.html.erb +24 -0
- data/app/components/aeno/primitives/conversation/message/component.rb +35 -0
- data/app/components/aeno/primitives/conversation/streaming_indicator/component.html.erb +21 -0
- data/app/components/aeno/primitives/conversation/streaming_indicator/component.rb +18 -0
- data/app/components/aeno/primitives/conversation/styles.css +221 -0
- data/app/components/aeno/primitives/conversation/user_message_box/component.html.erb +1 -0
- data/app/components/aeno/primitives/conversation/user_message_box/component.rb +4 -0
- data/app/components/aeno/primitives/drawer/component.html.erb +43 -0
- data/app/components/aeno/primitives/drawer/component.rb +33 -0
- data/app/components/aeno/primitives/drawer/controller.js +104 -0
- data/app/components/aeno/primitives/drawer/styles.css +90 -0
- data/app/components/aeno/primitives/dropdown/checkbox.rb +22 -0
- data/app/components/aeno/primitives/dropdown/component.html.erb +38 -0
- data/app/components/aeno/primitives/dropdown/component.rb +53 -0
- data/app/components/aeno/primitives/dropdown/controller.js +153 -0
- data/app/components/aeno/primitives/dropdown/item.rb +29 -0
- data/app/components/aeno/primitives/dropdown/label.rb +7 -0
- data/app/components/aeno/primitives/dropdown/radio_group.rb +16 -0
- data/app/components/aeno/primitives/dropdown/radio_item.rb +24 -0
- data/app/components/aeno/primitives/dropdown/separator.rb +7 -0
- data/app/components/aeno/primitives/dropdown/styles.css +155 -0
- data/app/components/aeno/primitives/empty/component.html.erb +15 -0
- data/app/components/aeno/primitives/empty/component.rb +18 -0
- data/app/components/aeno/primitives/empty/styles.css +40 -0
- data/app/components/aeno/primitives/input_attachments/component.html.erb +60 -0
- data/app/components/aeno/primitives/input_attachments/component.rb +52 -0
- data/app/components/aeno/primitives/input_attachments/controller.js +357 -0
- data/app/components/aeno/primitives/input_attachments/styles.css +102 -0
- data/app/components/aeno/primitives/input_color/component.html.erb +24 -0
- data/app/components/aeno/primitives/input_color/component.rb +42 -0
- data/app/components/aeno/primitives/input_color/styles.css +64 -0
- data/app/components/aeno/primitives/input_password/component.html.erb +43 -0
- data/app/components/aeno/primitives/input_password/component.rb +20 -0
- data/app/components/aeno/primitives/input_password/controller.js +17 -0
- data/app/components/aeno/primitives/input_password/styles.css +61 -0
- data/app/components/aeno/primitives/input_select/component.html.erb +43 -0
- data/app/components/aeno/primitives/input_select/component.rb +21 -0
- data/app/components/aeno/primitives/input_select/option.rb +14 -0
- data/app/components/aeno/primitives/input_select/styles.css +30 -0
- data/app/components/aeno/primitives/input_slider/component.html.erb +33 -0
- data/app/components/aeno/primitives/input_slider/component.rb +35 -0
- data/app/components/aeno/primitives/input_slider/styles.css +74 -0
- data/app/components/aeno/primitives/input_tagging/component.html.erb +73 -0
- data/app/components/aeno/primitives/input_tagging/component.rb +40 -0
- data/app/components/aeno/primitives/input_tagging/controller.js +326 -0
- data/app/components/aeno/primitives/input_tagging/styles.css +148 -0
- data/app/components/aeno/primitives/input_text/component.html.erb +25 -0
- data/app/components/aeno/primitives/input_text/component.rb +20 -0
- data/app/components/aeno/primitives/input_text/styles.css +38 -0
- data/app/components/aeno/primitives/input_text_area/component.html.erb +23 -0
- data/app/components/aeno/primitives/input_text_area/component.rb +19 -0
- data/app/components/aeno/primitives/input_text_area/styles.css +30 -0
- data/app/components/aeno/primitives/input_text_area_ai/component.html.erb +51 -0
- data/app/components/aeno/primitives/input_text_area_ai/component.rb +47 -0
- data/app/components/aeno/primitives/input_text_area_ai/controller.js +198 -0
- data/app/components/aeno/primitives/input_text_area_ai/styles.css +91 -0
- data/app/components/aeno/primitives/input_wrapper/component.html.erb +20 -0
- data/app/components/aeno/primitives/input_wrapper/component.rb +31 -0
- data/app/components/aeno/primitives/input_wrapper/styles.css +72 -0
- data/app/components/aeno/primitives/layouts/agentic/component.html.erb +4 -0
- data/app/components/aeno/primitives/layouts/agentic/component.rb +9 -0
- data/app/components/aeno/primitives/layouts/agentic/styles.css +23 -0
- data/app/components/aeno/primitives/layouts/app/aside.rb +9 -0
- data/app/components/aeno/primitives/layouts/app/component.html.erb +14 -0
- data/app/components/aeno/primitives/layouts/app/component.rb +11 -0
- data/app/components/aeno/primitives/layouts/app/sidebar.rb +9 -0
- data/app/components/aeno/primitives/layouts/app/styles.css +46 -0
- data/app/components/aeno/primitives/page/component.html.erb +24 -0
- data/app/components/aeno/primitives/page/component.rb +23 -0
- data/app/components/aeno/primitives/page/styles.css +55 -0
- data/app/components/aeno/primitives/sidebar/component.html.erb +25 -0
- data/app/components/aeno/primitives/sidebar/component.rb +14 -0
- data/app/components/aeno/primitives/sidebar/footer.rb +7 -0
- data/app/components/aeno/primitives/sidebar/group.rb +18 -0
- data/app/components/aeno/primitives/sidebar/header.rb +7 -0
- data/app/components/aeno/primitives/sidebar/item.rb +19 -0
- data/app/components/aeno/primitives/sidebar/styles.css +95 -0
- data/app/components/aeno/primitives/spinner/component.rb +36 -0
- data/app/components/aeno/primitives/spinner/styles.css +81 -0
- data/app/components/aeno/primitives/table/cell.rb +7 -0
- data/app/components/aeno/primitives/table/column.rb +7 -0
- data/app/components/aeno/primitives/table/component.html.erb +8 -0
- data/app/components/aeno/primitives/table/component.rb +14 -0
- data/app/components/aeno/primitives/table/header.rb +13 -0
- data/app/components/aeno/primitives/table/row.rb +11 -0
- data/app/components/aeno/primitives/table/styles.css +39 -0
- data/app/controllers/aeno/application_controller.rb +15 -0
- data/app/controllers/aeno/showcase_controller.rb +40 -0
- data/app/controllers/aeno/theme_controller.rb +10 -0
- data/app/helpers/aeno/application_helper.rb +28 -0
- data/app/javascript/aeno/application.js +3 -0
- data/app/javascript/aeno/controllers/application.js +5 -0
- data/app/javascript/aeno/controllers/index.js +5 -0
- data/app/javascript/aeno/controllers/loader.js +62 -0
- data/app/jobs/aeno/application_job.rb +4 -0
- data/app/models/aeno/application_record.rb +5 -0
- data/app/views/layouts/aeno/application.html.erb +55 -0
- data/config/importmap.rb +20 -0
- data/config/routes.rb +5 -0
- data/lib/aeno/configuration.rb +56 -0
- data/lib/aeno/engine.rb +43 -0
- data/lib/aeno/engine_helpers.rb +44 -0
- data/lib/aeno/theme.rb +326 -0
- data/lib/aeno/version.rb +3 -0
- data/lib/aeno.rb +11 -0
- data/lib/tasks/aeno_tasks.rake +39 -0
- metadata +310 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
import { computePosition, flip, shift, offset, autoUpdate } from "@floating-ui/dom";
|
|
3
|
+
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
static targets = ["trigger", "content", "search", "items", "empty"];
|
|
6
|
+
static values = {
|
|
7
|
+
open: { type: Boolean, default: false },
|
|
8
|
+
placement: { type: String, default: "bottom-start" },
|
|
9
|
+
strategy: { type: String, default: "absolute" },
|
|
10
|
+
searchable: { type: Boolean, default: false },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
connect() {
|
|
14
|
+
this.closeOnClickOutside = this.closeOnClickOutside.bind(this);
|
|
15
|
+
this.handleKeydown = this.handleKeydown.bind(this);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
disconnect() {
|
|
19
|
+
this.cleanup?.();
|
|
20
|
+
document.removeEventListener("click", this.closeOnClickOutside);
|
|
21
|
+
document.removeEventListener("keydown", this.handleKeydown);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toggle(event) {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
this.openValue ? this.close() : this.open();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
open() {
|
|
30
|
+
this.openValue = true;
|
|
31
|
+
this.contentTarget.classList.add("cp-dropdown__content--open");
|
|
32
|
+
this.updatePosition();
|
|
33
|
+
|
|
34
|
+
this.cleanup = autoUpdate(this.triggerTarget, this.contentTarget, () => {
|
|
35
|
+
this.updatePosition();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
document.addEventListener("click", this.closeOnClickOutside);
|
|
39
|
+
document.addEventListener("keydown", this.handleKeydown);
|
|
40
|
+
|
|
41
|
+
if (this.searchableValue && this.hasSearchTarget) {
|
|
42
|
+
this.searchTarget.value = "";
|
|
43
|
+
this.filter();
|
|
44
|
+
setTimeout(() => this.searchTarget.focus(), 0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
close() {
|
|
49
|
+
this.openValue = false;
|
|
50
|
+
this.contentTarget.classList.remove("cp-dropdown__content--open");
|
|
51
|
+
this.cleanup?.();
|
|
52
|
+
this.cleanup = null;
|
|
53
|
+
document.removeEventListener("click", this.closeOnClickOutside);
|
|
54
|
+
document.removeEventListener("keydown", this.handleKeydown);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async updatePosition() {
|
|
58
|
+
const { x, y } = await computePosition(this.triggerTarget, this.contentTarget, {
|
|
59
|
+
placement: this.placementValue,
|
|
60
|
+
strategy: this.strategyValue,
|
|
61
|
+
middleware: [
|
|
62
|
+
offset(4),
|
|
63
|
+
flip(),
|
|
64
|
+
shift({ padding: 8 }),
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
Object.assign(this.contentTarget.style, {
|
|
69
|
+
position: this.strategyValue,
|
|
70
|
+
left: `${x}px`,
|
|
71
|
+
top: `${y}px`,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
closeOnClickOutside(event) {
|
|
76
|
+
if (!this.element.contains(event.target)) {
|
|
77
|
+
this.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
handleKeydown(event) {
|
|
82
|
+
if (event.key === "Escape") {
|
|
83
|
+
this.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
filter() {
|
|
88
|
+
if (!this.hasSearchTarget) return;
|
|
89
|
+
|
|
90
|
+
const query = this.searchTarget.value.toLowerCase().trim();
|
|
91
|
+
const items = this.itemsTarget.querySelectorAll("[role='menuitem'], [role='menuitemradio'], [role='menuitemcheckbox']");
|
|
92
|
+
let visibleCount = 0;
|
|
93
|
+
|
|
94
|
+
items.forEach((item) => {
|
|
95
|
+
const label = item.querySelector(".cp-dropdown__item-label")?.textContent.toLowerCase() || "";
|
|
96
|
+
const matches = query === "" || label.includes(query);
|
|
97
|
+
|
|
98
|
+
item.classList.toggle("cp-dropdown__item--hidden", !matches);
|
|
99
|
+
if (matches) visibleCount++;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (this.hasEmptyTarget) {
|
|
103
|
+
this.emptyTarget.classList.toggle("cp-dropdown__empty--visible", visibleCount === 0);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
select(event) {
|
|
108
|
+
const item = event.currentTarget;
|
|
109
|
+
const value = item.dataset.value;
|
|
110
|
+
const label = item.querySelector(".cp-dropdown__item-label")?.textContent.trim();
|
|
111
|
+
|
|
112
|
+
this.dispatch("select", { detail: { value, label } });
|
|
113
|
+
this.close();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
selectRadio(event) {
|
|
117
|
+
const item = event.currentTarget;
|
|
118
|
+
const name = item.dataset.name;
|
|
119
|
+
const value = item.dataset.value;
|
|
120
|
+
|
|
121
|
+
// Update aria-checked for all radio items in the group
|
|
122
|
+
const group = item.closest(".cp-dropdown__radio-group");
|
|
123
|
+
group.querySelectorAll("[role='menuitemradio']").forEach((radio) => {
|
|
124
|
+
const isChecked = radio === item;
|
|
125
|
+
radio.setAttribute("aria-checked", isChecked);
|
|
126
|
+
const checkIcon = radio.querySelector(".cp-dropdown__item-check");
|
|
127
|
+
if (checkIcon) {
|
|
128
|
+
checkIcon.innerHTML = isChecked ? this.checkIconSvg() : "";
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
this.dispatch("radio-change", { detail: { name, value } });
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
toggleCheckbox(event) {
|
|
136
|
+
const item = event.currentTarget;
|
|
137
|
+
const name = item.dataset.name;
|
|
138
|
+
const isChecked = item.getAttribute("aria-checked") === "true";
|
|
139
|
+
const newChecked = !isChecked;
|
|
140
|
+
|
|
141
|
+
item.setAttribute("aria-checked", newChecked);
|
|
142
|
+
const checkIcon = item.querySelector(".cp-dropdown__item-check");
|
|
143
|
+
if (checkIcon) {
|
|
144
|
+
checkIcon.innerHTML = newChecked ? this.checkIconSvg() : "";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.dispatch("checkbox-change", { detail: { name, checked: newChecked } });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
checkIconSvg() {
|
|
151
|
+
return `<svg class="cp-dropdown__check-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Aeno::Primitives::Dropdown
|
|
2
|
+
class Item < ::Aeno::ApplicationViewComponent
|
|
3
|
+
option :href, optional: true
|
|
4
|
+
option :method, optional: true
|
|
5
|
+
option :icon, optional: true
|
|
6
|
+
option :shortcut, optional: true
|
|
7
|
+
option :disabled, default: -> { false }
|
|
8
|
+
option :data, default: -> { {} }
|
|
9
|
+
option :form_data, default: -> { {} }
|
|
10
|
+
|
|
11
|
+
def item_classes
|
|
12
|
+
classes = ["cp-dropdown__item"]
|
|
13
|
+
classes << "cp-dropdown__item--disabled" if disabled
|
|
14
|
+
classes.join(" ")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def item_data
|
|
18
|
+
data.merge("action" => "click->aeno--primitives--dropdown#select")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def call
|
|
22
|
+
action_tag(href: href, method: method, data: item_data, form_data: form_data, class: item_classes, role: "menuitem", disabled: disabled) do
|
|
23
|
+
(icon ? lucide_icon(icon, class: "cp-dropdown__item-icon") : "".html_safe) +
|
|
24
|
+
content_tag(:span, content, class: "cp-dropdown__item-label") +
|
|
25
|
+
(shortcut ? content_tag(:span, shortcut, class: "cp-dropdown__item-shortcut") : "".html_safe)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Aeno::Primitives::Dropdown
|
|
2
|
+
class RadioGroup < ::Aeno::ApplicationViewComponent
|
|
3
|
+
option :name
|
|
4
|
+
option :value, optional: true
|
|
5
|
+
|
|
6
|
+
renders_many :items, ->(value:, **opts, &block) {
|
|
7
|
+
RadioItem.new(name: name, value: value, checked: self.value == value, **opts, &block)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
erb_template <<~ERB
|
|
11
|
+
<div class="cp-dropdown__radio-group" role="group">
|
|
12
|
+
<% items.each do |item| %><%= item %><% end %>
|
|
13
|
+
</div>
|
|
14
|
+
ERB
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Aeno::Primitives::Dropdown
|
|
2
|
+
class RadioItem < ::Aeno::ApplicationViewComponent
|
|
3
|
+
option :name
|
|
4
|
+
option :value
|
|
5
|
+
option :checked, default: -> { false }
|
|
6
|
+
option :icon, optional: true
|
|
7
|
+
|
|
8
|
+
erb_template <<~ERB
|
|
9
|
+
<button type="button"
|
|
10
|
+
class="cp-dropdown__item cp-dropdown__item--radio"
|
|
11
|
+
role="menuitemradio"
|
|
12
|
+
aria-checked="<%= checked %>"
|
|
13
|
+
data-action="click->aeno--primitives--dropdown#selectRadio"
|
|
14
|
+
data-name="<%= name %>"
|
|
15
|
+
data-value="<%= value %>">
|
|
16
|
+
<span class="cp-dropdown__item-check">
|
|
17
|
+
<% if checked %><%= lucide_icon("check", class: "cp-dropdown__check-icon") %><% end %>
|
|
18
|
+
</span>
|
|
19
|
+
<% if icon %><%= lucide_icon(icon, class: "cp-dropdown__item-icon") %><% end %>
|
|
20
|
+
<span class="cp-dropdown__item-label"><%= content %></span>
|
|
21
|
+
</button>
|
|
22
|
+
ERB
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
.cp-dropdown {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
|
|
5
|
+
&__trigger {
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__content {
|
|
10
|
+
position: absolute;
|
|
11
|
+
z-index: 50;
|
|
12
|
+
min-width: 12rem;
|
|
13
|
+
background: var(--ui-menu-bg);
|
|
14
|
+
border: 1px solid var(--ui-menu-border);
|
|
15
|
+
border-radius: var(--ui-menu-radius);
|
|
16
|
+
box-shadow: var(--ui-menu-shadow);
|
|
17
|
+
opacity: 0;
|
|
18
|
+
visibility: hidden;
|
|
19
|
+
transform: scale(0.95);
|
|
20
|
+
transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
|
|
21
|
+
|
|
22
|
+
&--open {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
visibility: visible;
|
|
25
|
+
transform: scale(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__search {
|
|
30
|
+
padding: var(--ui-menu-padding);
|
|
31
|
+
border-bottom: 1px solid var(--ui-menu-border);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&__search-input {
|
|
35
|
+
width: 100%;
|
|
36
|
+
padding: 0.5rem 0.75rem;
|
|
37
|
+
font-size: 0.875rem;
|
|
38
|
+
background: var(--ui-muted);
|
|
39
|
+
border: 1px solid var(--ui-menu-border);
|
|
40
|
+
border-radius: var(--ui-menu-item-radius);
|
|
41
|
+
color: var(--ui-menu-fg);
|
|
42
|
+
outline: none;
|
|
43
|
+
|
|
44
|
+
&::placeholder {
|
|
45
|
+
color: var(--ui-muted-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:focus {
|
|
49
|
+
border-color: var(--ui-ring);
|
|
50
|
+
box-shadow: 0 0 0 2px var(--ui-ring-alpha);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__items {
|
|
55
|
+
padding: var(--ui-menu-padding);
|
|
56
|
+
max-height: 20rem;
|
|
57
|
+
overflow-y: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&__item {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 0.5rem;
|
|
64
|
+
width: 100%;
|
|
65
|
+
padding: 0.5rem 0.75rem;
|
|
66
|
+
font-size: 0.875rem;
|
|
67
|
+
color: var(--ui-menu-fg);
|
|
68
|
+
text-align: left;
|
|
69
|
+
text-decoration: none;
|
|
70
|
+
background: transparent;
|
|
71
|
+
border: none;
|
|
72
|
+
border-radius: var(--ui-menu-item-radius);
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
transition: background-color 0.1s ease;
|
|
75
|
+
|
|
76
|
+
&:hover {
|
|
77
|
+
background: var(--ui-muted);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&--disabled {
|
|
81
|
+
opacity: 0.5;
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&--radio,
|
|
86
|
+
&--checkbox {
|
|
87
|
+
padding-left: 0.5rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&--hidden {
|
|
91
|
+
display: none;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&__item-check {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
width: 1rem;
|
|
100
|
+
height: 1rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&__check-icon {
|
|
104
|
+
width: 0.875rem;
|
|
105
|
+
height: 0.875rem;
|
|
106
|
+
color: var(--ui-menu-fg);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&__item-icon {
|
|
110
|
+
width: 1rem;
|
|
111
|
+
height: 1rem;
|
|
112
|
+
color: var(--ui-muted-color);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__item-label {
|
|
116
|
+
flex: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&__item-shortcut {
|
|
120
|
+
font-size: 0.75rem;
|
|
121
|
+
color: var(--ui-muted-color);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&__label {
|
|
125
|
+
padding: 0.5rem 0.75rem;
|
|
126
|
+
font-size: 0.75rem;
|
|
127
|
+
font-weight: 500;
|
|
128
|
+
color: var(--ui-muted-color);
|
|
129
|
+
text-transform: uppercase;
|
|
130
|
+
letter-spacing: 0.05em;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__separator {
|
|
134
|
+
height: 1px;
|
|
135
|
+
margin: var(--ui-menu-padding) 0;
|
|
136
|
+
background: var(--ui-menu-border);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&__radio-group {
|
|
140
|
+
display: flex;
|
|
141
|
+
flex-direction: column;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&__empty {
|
|
145
|
+
padding: 0.5rem 0.75rem;
|
|
146
|
+
font-size: 0.875rem;
|
|
147
|
+
color: var(--ui-muted-color);
|
|
148
|
+
text-align: center;
|
|
149
|
+
display: none;
|
|
150
|
+
|
|
151
|
+
&--visible {
|
|
152
|
+
display: block;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<div class="cp-empty">
|
|
2
|
+
<div class="cp-empty__container">
|
|
3
|
+
<div class="cp-empty__content">
|
|
4
|
+
<% if icon %>
|
|
5
|
+
<%= lucide_icon(icon, class: "cp-empty__icon") %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% if title %>
|
|
8
|
+
<div class="cp-empty__title"><%= title %></div>
|
|
9
|
+
<% end %>
|
|
10
|
+
<div class="cp-empty__description">
|
|
11
|
+
<%= content %>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Aeno::Primitives::Empty
|
|
2
|
+
class Component < ::Aeno::ApplicationViewComponent
|
|
3
|
+
prop :icon, description: "Lucide icon name", optional: true
|
|
4
|
+
|
|
5
|
+
renders_one(:title)
|
|
6
|
+
|
|
7
|
+
examples("Empty", description: "Empty state placeholder") do |b|
|
|
8
|
+
b.example(:default, title: "Default") do |e|
|
|
9
|
+
e.preview
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
b.example(:with_icon, title: "With Icon") do |e|
|
|
13
|
+
e.preview icon: "inbox"
|
|
14
|
+
e.preview icon: "search"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* Empty */
|
|
2
|
+
.cp-empty {
|
|
3
|
+
padding: var(--ui-spacing-lg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.cp-empty__container {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
border: 1px dashed var(--ui-border);
|
|
12
|
+
border-radius: var(--ui-radius-lg);
|
|
13
|
+
padding: var(--ui-spacing-lg);
|
|
14
|
+
min-height: 200px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cp-empty__content {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: var(--ui-spacing);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cp-empty__icon {
|
|
26
|
+
width: 3rem;
|
|
27
|
+
height: 3rem;
|
|
28
|
+
color: var(--ui-muted-foreground);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cp-empty__title {
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
font-size: 1.125rem;
|
|
34
|
+
color: var(--ui-foreground);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.cp-empty__description {
|
|
38
|
+
color: var(--ui-muted-foreground);
|
|
39
|
+
text-align: center;
|
|
40
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<div class="cp-input-attachments">
|
|
2
|
+
<%= render Aeno::Primitives::InputWrapper::Component.new(
|
|
3
|
+
label: label,
|
|
4
|
+
helper_text: helper_text,
|
|
5
|
+
error_text: error_text,
|
|
6
|
+
name: name,
|
|
7
|
+
id: id,
|
|
8
|
+
disabled: disabled,
|
|
9
|
+
required: required) do %>
|
|
10
|
+
<div class="cp-input-attachments__container"
|
|
11
|
+
data-controller="<%= controller_name %>"
|
|
12
|
+
<%= stimulus_values.map { |k, v| "data-#{k.dasherize}=\"#{ERB::Util.html_escape(v)}\"" }.join(" ").html_safe %>>
|
|
13
|
+
|
|
14
|
+
<div class="cp-input-attachments__dropzone"
|
|
15
|
+
data-<%= controller_name %>-target="dropzone"
|
|
16
|
+
data-action="click-><%= controller_name %>#triggerFileInput dragover-><%= controller_name %>#onDragOver dragleave-><%= controller_name %>#onDragLeave drop-><%= controller_name %>#onDrop">
|
|
17
|
+
<div class="cp-input-attachments__dropzone-content">
|
|
18
|
+
<%= lucide_icon("upload-cloud", class: "cp-input-attachments__icon") %>
|
|
19
|
+
<div class="cp-input-attachments__text">
|
|
20
|
+
<span class="cp-input-attachments__link">Click to upload</span> or drag and drop
|
|
21
|
+
</div>
|
|
22
|
+
<div class="cp-input-attachments__hint">
|
|
23
|
+
<%= accept == "*/*" ? "Any file type" : accept %>
|
|
24
|
+
<% if max_size %>
|
|
25
|
+
(max <%= number_to_human_size(max_size) %>)
|
|
26
|
+
<% end %>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<input type="file"
|
|
31
|
+
class="cp-input-attachments__file-input"
|
|
32
|
+
multiple
|
|
33
|
+
accept="<%= accept %>"
|
|
34
|
+
data-<%= controller_name %>-target="fileInput"
|
|
35
|
+
data-action="change-><%= controller_name %>#onFileSelect"
|
|
36
|
+
<%= 'disabled' if disabled %>>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div class="cp-input-attachments__progress cp-input-attachments__progress--hidden" data-<%= controller_name %>-target="progressContainer">
|
|
40
|
+
<div class="cp-input-attachments__progress-info">
|
|
41
|
+
<%= ui("spinner", size: :sm) %>
|
|
42
|
+
<span>Uploading...</span>
|
|
43
|
+
<span data-<%= controller_name %>-target="progressText">0%</span>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="cp-input-attachments__progress-track">
|
|
46
|
+
<div class="cp-input-attachments__progress-bar"
|
|
47
|
+
style="width: 0%"
|
|
48
|
+
data-<%= controller_name %>-target="progressBar"></div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<div class="cp-input-attachments__previews"
|
|
53
|
+
data-<%= controller_name %>-target="previewsContainer">
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<div data-<%= controller_name %>-target="hiddenInputs">
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<% end %>
|
|
60
|
+
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Aeno::Primitives::InputAttachments
|
|
4
|
+
class Component < ::Aeno::FormBuilder::BaseComponent
|
|
5
|
+
prop :accept, description: "Accepted file types", default: -> { "*/*" }
|
|
6
|
+
prop :max_files, description: "Maximum number of files", optional: true
|
|
7
|
+
prop :max_size, description: "Maximum file size in bytes", optional: true
|
|
8
|
+
prop :existing, description: "Existing attachments", default: -> { [] }
|
|
9
|
+
prop :direct_upload_url, description: "Direct upload URL", optional: true
|
|
10
|
+
|
|
11
|
+
examples("Input Attachments", description: "File upload with drag and drop") do |b|
|
|
12
|
+
b.example(:default, title: "Default") do |e|
|
|
13
|
+
e.preview name: "attachments"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
b.example(:images_only, title: "Images Only") do |e|
|
|
17
|
+
e.preview name: "images", accept: "image/*"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
b.example(:limited, title: "Limited Files") do |e|
|
|
21
|
+
e.preview name: "documents", max_files: 5
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def stimulus_values
|
|
26
|
+
values = {
|
|
27
|
+
"#{controller_name}-accept-value" => accept,
|
|
28
|
+
"#{controller_name}-attachments-value" => normalized_existing.to_json
|
|
29
|
+
}
|
|
30
|
+
values["#{controller_name}-max-files-value"] = max_files if max_files
|
|
31
|
+
values["#{controller_name}-max-size-value"] = max_size if max_size
|
|
32
|
+
values["#{controller_name}-direct-upload-url-value"] = direct_upload_url if direct_upload_url
|
|
33
|
+
values
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def input_name
|
|
37
|
+
"#{name}[]"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def positions_name
|
|
41
|
+
"#{name}_positions"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def normalized_existing
|
|
47
|
+
existing.map.with_index do |item, idx|
|
|
48
|
+
item.merge(position: item[:position] || idx)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|