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,221 @@
|
|
|
1
|
+
/* Conversation */
|
|
2
|
+
.cp-conversation {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
height: 100%;
|
|
6
|
+
background: var(--ui-background);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cp-conversation__header {
|
|
10
|
+
padding: 1rem 1.5rem;
|
|
11
|
+
border-bottom: 1px solid var(--ui-border);
|
|
12
|
+
background: var(--ui-background);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.cp-conversation__title {
|
|
16
|
+
font-size: 1.125rem;
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
color: var(--ui-foreground);
|
|
19
|
+
margin: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.cp-conversation__messages {
|
|
23
|
+
flex: 1;
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.cp-conversation__empty {
|
|
28
|
+
display: flex;
|
|
29
|
+
height: 100%;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
color: var(--ui-muted-foreground);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cp-conversation__empty-content {
|
|
36
|
+
text-align: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.cp-conversation__empty-title {
|
|
40
|
+
margin-bottom: 0.5rem;
|
|
41
|
+
font-size: 1.5rem;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.cp-conversation__empty-subtitle {
|
|
46
|
+
font-size: 0.875rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.cp-conversation__streaming-hidden {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Conversation Message */
|
|
54
|
+
.cp-conversation-message {
|
|
55
|
+
padding: 2rem 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cp-conversation-message--user {
|
|
59
|
+
background: var(--ui-background);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.cp-conversation-message--assistant {
|
|
63
|
+
background: var(--ui-accent);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cp-conversation-message--error {
|
|
67
|
+
background: var(--ui-background);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.cp-conversation-message--system {
|
|
71
|
+
background: var(--ui-accent);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.cp-conversation-message__container {
|
|
75
|
+
max-width: 48rem;
|
|
76
|
+
margin: 0 auto;
|
|
77
|
+
padding: 0 1.5rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cp-conversation-message__row {
|
|
81
|
+
display: flex;
|
|
82
|
+
gap: 1rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.cp-conversation-message__avatar-wrapper {
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cp-conversation-message__avatar {
|
|
90
|
+
display: flex;
|
|
91
|
+
width: 2rem;
|
|
92
|
+
height: 2rem;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
border-radius: 9999px;
|
|
96
|
+
font-size: 0.875rem;
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
color: white;
|
|
99
|
+
background: var(--ui-muted-foreground);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.cp-conversation-message__avatar--user {
|
|
103
|
+
background: var(--ui-primary);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.cp-conversation-message__avatar--assistant {
|
|
107
|
+
background: #16a34a;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.cp-conversation-message__avatar--error {
|
|
111
|
+
background: var(--ui-destructive);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.cp-conversation-message__avatar--system {
|
|
115
|
+
background: var(--ui-muted-foreground);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.cp-conversation-message__content {
|
|
119
|
+
flex: 1;
|
|
120
|
+
min-width: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.cp-conversation-message__role {
|
|
124
|
+
margin-bottom: 0.25rem;
|
|
125
|
+
font-size: 0.875rem;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
color: var(--ui-foreground);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.cp-conversation-message__body {
|
|
131
|
+
white-space: pre-wrap;
|
|
132
|
+
color: var(--ui-foreground);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.cp-conversation-message__timestamp {
|
|
136
|
+
margin-top: 0.25rem;
|
|
137
|
+
font-size: 0.75rem;
|
|
138
|
+
color: var(--ui-muted-foreground);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Conversation Streaming Indicator */
|
|
142
|
+
.cp-conversation-streaming {
|
|
143
|
+
padding: 2rem 0;
|
|
144
|
+
background: var(--ui-accent);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.cp-conversation-streaming__container {
|
|
148
|
+
max-width: 48rem;
|
|
149
|
+
margin: 0 auto;
|
|
150
|
+
padding: 0 1.5rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.cp-conversation-streaming__row {
|
|
154
|
+
display: flex;
|
|
155
|
+
gap: 1rem;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.cp-conversation-streaming__avatar-wrapper {
|
|
159
|
+
flex-shrink: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.cp-conversation-streaming__avatar {
|
|
163
|
+
display: flex;
|
|
164
|
+
width: 2rem;
|
|
165
|
+
height: 2rem;
|
|
166
|
+
align-items: center;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
border-radius: 9999px;
|
|
169
|
+
font-size: 0.875rem;
|
|
170
|
+
font-weight: 600;
|
|
171
|
+
color: white;
|
|
172
|
+
background: var(--ui-muted-foreground);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.cp-conversation-streaming__avatar--user {
|
|
176
|
+
background: var(--ui-primary);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.cp-conversation-streaming__avatar--assistant {
|
|
180
|
+
background: #16a34a;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.cp-conversation-streaming__content {
|
|
184
|
+
flex: 1;
|
|
185
|
+
min-width: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.cp-conversation-streaming__label {
|
|
189
|
+
margin-bottom: 0.25rem;
|
|
190
|
+
font-size: 0.875rem;
|
|
191
|
+
font-weight: 600;
|
|
192
|
+
color: var(--ui-foreground);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cp-conversation-streaming__dots {
|
|
196
|
+
display: flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
gap: 0.25rem;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.cp-conversation-streaming__dot {
|
|
202
|
+
width: 0.5rem;
|
|
203
|
+
height: 0.5rem;
|
|
204
|
+
border-radius: 9999px;
|
|
205
|
+
background: var(--ui-muted-foreground);
|
|
206
|
+
animation: cp-bounce 1s infinite;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@keyframes cp-bounce {
|
|
210
|
+
0%, 100% {
|
|
211
|
+
transform: translateY(0);
|
|
212
|
+
}
|
|
213
|
+
50% {
|
|
214
|
+
transform: translateY(-0.25rem);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/* Conversation User Box */
|
|
219
|
+
.cp-conversation-user-box {
|
|
220
|
+
/* Container for user input - styled by content */
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="cp-conversation-user-box"><%= content %></div>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<div class="cp-drawer" data-controller="<%= controller_name %>" id="<%= id %>">
|
|
2
|
+
<% if trigger %>
|
|
3
|
+
<div data-action="click-><%= controller_name %>#open">
|
|
4
|
+
<%= trigger %>
|
|
5
|
+
</div>
|
|
6
|
+
<% end %>
|
|
7
|
+
|
|
8
|
+
<% wrapper = -> (&block) { standalone ? capture(&block) : turbo_frame_tag("drawer", &block) } %>
|
|
9
|
+
<%= wrapper.call do %>
|
|
10
|
+
<div data-action="<%= data_actions %>">
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
class="cp-drawer__backdrop"
|
|
14
|
+
data-action="click-><%= controller_name %>#close"
|
|
15
|
+
data-<%= controller_name %>-target="background"
|
|
16
|
+
></button>
|
|
17
|
+
<div
|
|
18
|
+
class="cp-drawer__panel"
|
|
19
|
+
style="width: <%= width %>"
|
|
20
|
+
data-<%= controller_name %>-target="wrapper"
|
|
21
|
+
>
|
|
22
|
+
<div class="cp-drawer__container">
|
|
23
|
+
<% if header %>
|
|
24
|
+
<div class="cp-drawer__header">
|
|
25
|
+
<div class="cp-drawer__header-content"><%= header %></div>
|
|
26
|
+
<button data-action="click-><%= controller_name %>#close" type="button" class="cp-drawer__close">
|
|
27
|
+
<%= lucide_icon("x", class: "cp-drawer__close-icon") %>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
<% end %>
|
|
31
|
+
<div class="cp-drawer__body">
|
|
32
|
+
<%= content %>
|
|
33
|
+
</div>
|
|
34
|
+
<% if footer %>
|
|
35
|
+
<div class="cp-drawer__footer">
|
|
36
|
+
<%= footer %>
|
|
37
|
+
</div>
|
|
38
|
+
<% end %>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
<% end %>
|
|
43
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Aeno::Primitives::Drawer
|
|
2
|
+
class Component < ::Aeno::ApplicationViewComponent
|
|
3
|
+
prop :width, description: "Drawer width (CSS value)", default: -> { "33%" }
|
|
4
|
+
prop :id, description: "HTML id attribute", optional: true
|
|
5
|
+
prop :standalone, description: "Skip turbo frame wrapper", default: -> { false }
|
|
6
|
+
prop :form_submit_close, description: "Close on form submit", default: -> { true }
|
|
7
|
+
|
|
8
|
+
renders_one(:header)
|
|
9
|
+
renders_one(:trigger)
|
|
10
|
+
renders_one(:footer)
|
|
11
|
+
|
|
12
|
+
examples("Drawer", description: "Slide-in panel from the right") do |b|
|
|
13
|
+
b.example(:default, title: "Default") do |e|
|
|
14
|
+
e.preview
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
b.example(:widths, title: "Widths") do |e|
|
|
18
|
+
e.preview width: "25%"
|
|
19
|
+
e.preview width: "50%"
|
|
20
|
+
e.preview width: "400px"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def data_actions
|
|
27
|
+
actions = []
|
|
28
|
+
actions << "turbo:frame-load->#{controller_name}#open" unless standalone
|
|
29
|
+
actions << "turbo:submit-end->#{controller_name}#closeOnSubmit" if form_submit_close
|
|
30
|
+
actions.join(" ").presence
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
|
2
|
+
|
|
3
|
+
const BASE_Z_INDEX = 40;
|
|
4
|
+
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = ["background", "wrapper"];
|
|
7
|
+
|
|
8
|
+
connect() {
|
|
9
|
+
this.#stackAboveExisting();
|
|
10
|
+
document.addEventListener("keydown", this.handleKeydown);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
disconnect() {
|
|
14
|
+
document.removeEventListener("keydown", this.handleKeydown);
|
|
15
|
+
this.#restoreBodyScroll();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
handleKeydown = (event) => {
|
|
19
|
+
if (event.key === "Escape") this.#closeTopmost();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
open() {
|
|
23
|
+
requestAnimationFrame(() => {
|
|
24
|
+
this.backgroundTarget.classList.add("cp-drawer__backdrop--open");
|
|
25
|
+
this.wrapperTarget.classList.add("cp-drawer__panel--open");
|
|
26
|
+
document.body.style.overflow = "hidden";
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
close() {
|
|
31
|
+
this.backgroundTarget.classList.remove("cp-drawer__backdrop--open");
|
|
32
|
+
this.wrapperTarget.classList.remove("cp-drawer__panel--open");
|
|
33
|
+
this.#restoreBodyScroll();
|
|
34
|
+
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
const frame = this.element.querySelector("turbo-frame");
|
|
37
|
+
if (frame) {
|
|
38
|
+
frame.src = undefined;
|
|
39
|
+
frame.innerHTML = "";
|
|
40
|
+
}
|
|
41
|
+
}, 300);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
closeOnSubmit(event) {
|
|
45
|
+
if (event.detail?.success) {
|
|
46
|
+
this.close();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Private
|
|
51
|
+
|
|
52
|
+
#stackAboveExisting() {
|
|
53
|
+
if (!this.hasBackgroundTarget || !this.hasWrapperTarget) return;
|
|
54
|
+
|
|
55
|
+
const allBackgrounds = document.querySelectorAll(
|
|
56
|
+
`[data-${this.identifier}-target="background"]`,
|
|
57
|
+
);
|
|
58
|
+
const allWrappers = document.querySelectorAll(
|
|
59
|
+
`[data-${this.identifier}-target="wrapper"]`,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const highest = Math.max(
|
|
63
|
+
BASE_Z_INDEX,
|
|
64
|
+
this.#highestZIndex(allBackgrounds),
|
|
65
|
+
this.#highestZIndex(allWrappers),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
this.backgroundTarget.style.zIndex = highest + 1;
|
|
69
|
+
this.wrapperTarget.style.zIndex = highest + 2;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#highestZIndex(elements) {
|
|
73
|
+
return Math.max(
|
|
74
|
+
0,
|
|
75
|
+
...Array.from(elements).map(
|
|
76
|
+
(el) => parseInt(getComputedStyle(el).zIndex) || 0,
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#closeTopmost() {
|
|
82
|
+
const allWrappers = document.querySelectorAll(
|
|
83
|
+
`[data-${this.identifier}-target="wrapper"]`,
|
|
84
|
+
);
|
|
85
|
+
const zIndexes = Array.from(allWrappers).map((el) => ({
|
|
86
|
+
el,
|
|
87
|
+
z: parseInt(getComputedStyle(el).zIndex) || 0,
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
const topmost = zIndexes.sort((a, b) => b.z - a.z)[0];
|
|
91
|
+
if (topmost?.el === this.wrapperTarget) {
|
|
92
|
+
this.close();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
#restoreBodyScroll() {
|
|
97
|
+
const openDrawers = document.querySelectorAll(
|
|
98
|
+
".cp-drawer__backdrop--open",
|
|
99
|
+
);
|
|
100
|
+
if (openDrawers.length <= 1) {
|
|
101
|
+
document.body.style.overflow = "";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* Drawer */
|
|
2
|
+
.cp-drawer {
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.cp-drawer__backdrop {
|
|
6
|
+
position: fixed;
|
|
7
|
+
inset: 0;
|
|
8
|
+
background: rgb(0 0 0 / 0.5);
|
|
9
|
+
transition: opacity 0.3s ease;
|
|
10
|
+
opacity: 0;
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cp-drawer__backdrop--open {
|
|
15
|
+
opacity: 1;
|
|
16
|
+
pointer-events: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.cp-drawer__panel {
|
|
20
|
+
position: fixed;
|
|
21
|
+
top: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
bottom: 0;
|
|
24
|
+
height: 100%;
|
|
25
|
+
background: var(--ui-background);
|
|
26
|
+
border-left: 1px solid var(--ui-border);
|
|
27
|
+
box-shadow: var(--ui-shadow-xl);
|
|
28
|
+
transition: transform 0.3s ease;
|
|
29
|
+
transform: translateX(100%);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.cp-drawer__panel--open {
|
|
33
|
+
transform: translateX(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.cp-drawer__container {
|
|
37
|
+
height: 100vh;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cp-drawer__header {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: space-between;
|
|
46
|
+
padding: var(--ui-spacing-lg);
|
|
47
|
+
border-bottom: 1px solid var(--ui-border);
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.cp-drawer__header-content {
|
|
52
|
+
flex: 1;
|
|
53
|
+
min-width: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.cp-drawer__close {
|
|
57
|
+
margin-left: var(--ui-spacing);
|
|
58
|
+
width: 2.5rem;
|
|
59
|
+
height: 2.5rem;
|
|
60
|
+
border-radius: 9999px;
|
|
61
|
+
background: var(--ui-muted);
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
transition: background-color 0.15s ease;
|
|
67
|
+
border: none;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.cp-drawer__close:hover {
|
|
72
|
+
background: var(--ui-accent);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cp-drawer__close-icon {
|
|
76
|
+
width: 1.25rem;
|
|
77
|
+
height: 1.25rem;
|
|
78
|
+
color: var(--ui-muted-foreground);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cp-drawer__body {
|
|
82
|
+
flex: 1;
|
|
83
|
+
overflow-y: auto;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.cp-drawer__footer {
|
|
87
|
+
border-top: 1px solid var(--ui-border);
|
|
88
|
+
padding: var(--ui-spacing-lg);
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Aeno::Primitives::Dropdown
|
|
2
|
+
class Checkbox < ::Aeno::ApplicationViewComponent
|
|
3
|
+
option :name
|
|
4
|
+
option :checked, default: -> { false }
|
|
5
|
+
option :icon, optional: true
|
|
6
|
+
|
|
7
|
+
erb_template <<~ERB
|
|
8
|
+
<button type="button"
|
|
9
|
+
class="cp-dropdown__item cp-dropdown__item--checkbox"
|
|
10
|
+
role="menuitemcheckbox"
|
|
11
|
+
aria-checked="<%= checked %>"
|
|
12
|
+
data-action="click->aeno--primitives--dropdown#toggleCheckbox"
|
|
13
|
+
data-name="<%= name %>">
|
|
14
|
+
<span class="cp-dropdown__item-check">
|
|
15
|
+
<% if checked %><%= lucide_icon("check", class: "cp-dropdown__check-icon") %><% end %>
|
|
16
|
+
</span>
|
|
17
|
+
<% if icon %><%= lucide_icon(icon, class: "cp-dropdown__item-icon") %><% end %>
|
|
18
|
+
<span class="cp-dropdown__item-label"><%= content %></span>
|
|
19
|
+
</button>
|
|
20
|
+
ERB
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<div class="cp-dropdown"
|
|
2
|
+
data-controller="aeno--primitives--dropdown"
|
|
3
|
+
data-aeno--primitives--dropdown-placement-value="<%= placement %>"
|
|
4
|
+
data-aeno--primitives--dropdown-strategy-value="<%= strategy %>"
|
|
5
|
+
data-aeno--primitives--dropdown-searchable-value="<%= searchable %>">
|
|
6
|
+
|
|
7
|
+
<div class="cp-dropdown__trigger" data-aeno--primitives--dropdown-target="trigger" data-action="click->aeno--primitives--dropdown#toggle">
|
|
8
|
+
<%= trigger %>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="cp-dropdown__content"
|
|
12
|
+
role="menu"
|
|
13
|
+
aria-orientation="vertical"
|
|
14
|
+
data-aeno--primitives--dropdown-target="content">
|
|
15
|
+
|
|
16
|
+
<% if searchable %>
|
|
17
|
+
<div class="cp-dropdown__search">
|
|
18
|
+
<input type="text"
|
|
19
|
+
class="cp-dropdown__search-input"
|
|
20
|
+
placeholder="<%= placeholder %>"
|
|
21
|
+
data-aeno--primitives--dropdown-target="search"
|
|
22
|
+
data-action="input->aeno--primitives--dropdown#filter" />
|
|
23
|
+
</div>
|
|
24
|
+
<% end %>
|
|
25
|
+
|
|
26
|
+
<div class="cp-dropdown__items" data-aeno--primitives--dropdown-target="items">
|
|
27
|
+
<% items.each do |item| %>
|
|
28
|
+
<%= item %>
|
|
29
|
+
<% end %>
|
|
30
|
+
|
|
31
|
+
<% if searchable %>
|
|
32
|
+
<div class="cp-dropdown__empty" data-aeno--primitives--dropdown-target="empty">
|
|
33
|
+
No results found
|
|
34
|
+
</div>
|
|
35
|
+
<% end %>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Aeno::Primitives::Dropdown
|
|
2
|
+
class Component < ::Aeno::ApplicationViewComponent
|
|
3
|
+
prop :placement, description: "Dropdown position",
|
|
4
|
+
values: [:top, :bottom, :left, :right],
|
|
5
|
+
default: -> { :bottom }
|
|
6
|
+
prop :strategy, description: "Positioning strategy",
|
|
7
|
+
values: [:absolute, :fixed],
|
|
8
|
+
default: -> { :absolute }
|
|
9
|
+
prop :searchable, description: "Enable search input", default: -> { false }
|
|
10
|
+
prop :placeholder, description: "Search placeholder", default: -> { "Search..." }
|
|
11
|
+
|
|
12
|
+
examples("Dropdown", description: "Floating menu with items") do |b|
|
|
13
|
+
b.example(:default, title: "Default") do |e|
|
|
14
|
+
e.preview
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
b.example(:placement, title: "Placement", description: "Position options") do |e|
|
|
18
|
+
e.preview placement: :bottom
|
|
19
|
+
e.preview placement: :top
|
|
20
|
+
e.preview placement: :left
|
|
21
|
+
e.preview placement: :right
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
b.example(:searchable, title: "Searchable") do |e|
|
|
25
|
+
e.preview searchable: true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
renders_one :trigger
|
|
30
|
+
renders_many :items, types: {
|
|
31
|
+
item: {
|
|
32
|
+
renders: ->(**opts, &block) { Item.new(**opts, &block) },
|
|
33
|
+
as: :item
|
|
34
|
+
},
|
|
35
|
+
label: {
|
|
36
|
+
renders: ->(**opts, &block) { Label.new(**opts, &block) },
|
|
37
|
+
as: :label
|
|
38
|
+
},
|
|
39
|
+
separator: {
|
|
40
|
+
renders: -> { Separator.new },
|
|
41
|
+
as: :separator
|
|
42
|
+
},
|
|
43
|
+
radio_group: {
|
|
44
|
+
renders: ->(**opts, &block) { RadioGroup.new(**opts, &block) },
|
|
45
|
+
as: :radio_group
|
|
46
|
+
},
|
|
47
|
+
checkbox: {
|
|
48
|
+
renders: ->(**opts, &block) { Checkbox.new(**opts, &block) },
|
|
49
|
+
as: :checkbox
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
end
|