ariadne_view_components 0.0.80.3 → 0.0.82
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/app/assets/javascripts/ariadne_view_components.js +14 -14
- data/app/assets/javascripts/ariadne_view_components.js.br +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.gz +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css.br +0 -0
- data/app/assets/stylesheets/ariadne_view_components.css.gz +0 -0
- data/app/components/ariadne/base_component.rb +5 -1
- data/app/components/ariadne/form/checkbox/component.html.erb +21 -5
- data/app/components/ariadne/form/checkbox/component.rb +36 -0
- data/app/components/ariadne/form/group/component.html.erb +0 -2
- data/app/components/ariadne/form/group/component.rb +4 -1
- data/app/components/ariadne/form/text_field/component.rb +26 -23
- data/app/components/ariadne/ui/badge/component.rb +12 -17
- data/app/components/ariadne/ui/button/component.rb +1 -0
- data/app/components/ariadne/ui/combobox/component.html.erb +5 -17
- data/app/components/ariadne/ui/combobox/component.rb +8 -28
- data/app/components/ariadne/ui/combobox/component.ts +24 -39
- data/app/components/ariadne/ui/dialog/component.rb +18 -2
- data/app/components/ariadne/ui/flash/component.html.erb +11 -11
- data/app/components/ariadne/ui/flash/component.rb +30 -12
- data/app/components/ariadne/ui/link/component.rb +21 -5
- data/app/components/ariadne/ui/list/component.html.erb +28 -4
- data/app/components/ariadne/ui/list/component.rb +119 -1
- data/app/components/ariadne/ui/list/component.ts +57 -0
- data/app/components/ariadne/ui/popover/component.html.erb +4 -4
- data/app/components/ariadne/ui/popover/component.rb +3 -1
- data/app/components/ariadne/ui/popover/component.ts +1 -1
- data/app/components/ariadne/ui/typography/component.rb +19 -0
- data/app/frontend/ariadne/stimulus_app.ts +2 -2
- data/app/frontend/controllers/{autosubmittable_controller.ts → form_autosubmit_controller.ts} +1 -2
- data/app/lib/ariadne/view_component/style_variants.rb +50 -0
- data/lib/ariadne/forms/dsl/badge.rb +2 -2
- data/lib/ariadne/forms/dsl/button_input.rb +2 -1
- data/lib/ariadne/forms/dsl/clipboard_copy_button.rb +34 -0
- data/lib/ariadne/forms/dsl/input_methods.rb +4 -0
- data/lib/ariadne/view_components/version.rb +1 -1
- metadata +5 -9
- data/app/components/ariadne/ui/combobox/item/component.html.erb +0 -9
- data/app/components/ariadne/ui/combobox/item/component.rb +0 -61
- data/app/components/ariadne/ui/combobox/option/component.html.erb +0 -11
- data/app/components/ariadne/ui/combobox/option/component.rb +0 -44
- data/app/components/ariadne/ui/list/item/component.html.erb +0 -16
- data/app/components/ariadne/ui/list/item/component.rb +0 -17
@@ -11,6 +11,56 @@ module Ariadne
|
|
11
11
|
@default_style_name ||= name.split("::")[-2].underscore.presence || "component"
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
extend ActiveSupport::Concern
|
16
|
+
|
17
|
+
class_methods do
|
18
|
+
def accepts_styles_for(*names, **defaults, &block)
|
19
|
+
names ||= []
|
20
|
+
names << default_style_name
|
21
|
+
|
22
|
+
names.each do |name|
|
23
|
+
style_accessors[name] = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
method_name = :styles
|
27
|
+
ivar_name = :"@styles"
|
28
|
+
|
29
|
+
attr_reader(method_name)
|
30
|
+
|
31
|
+
mod = Module.new do
|
32
|
+
define_method(:initialize) do |**options|
|
33
|
+
value = options.delete(method_name)&.to_h || {}
|
34
|
+
|
35
|
+
super(**options)
|
36
|
+
instance_exec(value, &block) if block
|
37
|
+
instance_variable_set(ivar_name, value)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
prepend(mod)
|
42
|
+
end
|
43
|
+
|
44
|
+
# use `accepts_styles` to allow end users to merge their own styles with Ariadne's provided ones
|
45
|
+
def accepts_styles(*names, **defaults, &block)
|
46
|
+
accepts_styles_for(*names, **defaults, &block)
|
47
|
+
end
|
48
|
+
|
49
|
+
def style_accessors
|
50
|
+
@style_accessors ||=
|
51
|
+
if superclass.respond_to?(:style_accessors)
|
52
|
+
superclass.style_accessors.deep_dup
|
53
|
+
else
|
54
|
+
{}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# merge Araidne style variants with user provided overrides
|
60
|
+
def merged_styles(name = self.class.default_style_name, **variants)
|
61
|
+
default_styles = self.class.style_config.compile(name.to_sym, **variants)
|
62
|
+
Ariadne::ViewComponents.tailwind_merger.merge([default_styles, styles.fetch(name, "")])
|
63
|
+
end
|
14
64
|
end
|
15
65
|
end
|
16
66
|
end
|
@@ -17,7 +17,8 @@ module Ariadne
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_component
|
20
|
-
|
20
|
+
html_attrs = @input_attributes || {}
|
21
|
+
Ariadne::UI::Button::Component.new(**@options, html_attrs: html_attrs).with_content(@label)
|
21
22
|
end
|
22
23
|
|
23
24
|
# :nocov:
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
module Forms
|
5
|
+
module Dsl
|
6
|
+
# :nodoc:
|
7
|
+
class ClipboardCopyButton
|
8
|
+
include InputMethods
|
9
|
+
|
10
|
+
attr_reader :builder, :form, :text, :options
|
11
|
+
|
12
|
+
def initialize(builder:, form:, **options)
|
13
|
+
@builder = builder
|
14
|
+
@form = form
|
15
|
+
@options = options
|
16
|
+
|
17
|
+
yield(self) if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_component
|
21
|
+
Ariadne::UI::ClipboardCopy::Component.new(text: @text, **@options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def type
|
25
|
+
:clipboard_copy
|
26
|
+
end
|
27
|
+
|
28
|
+
def input?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -130,6 +130,10 @@ module Ariadne
|
|
130
130
|
add_input(ButtonInput.new(builder: builder, form: form, **options, &block))
|
131
131
|
end
|
132
132
|
|
133
|
+
def clipboard_copy_button(**options, &block)
|
134
|
+
add_input(ClipboardCopyButton.new(builder: @builder, form: form, **options, &block))
|
135
|
+
end
|
136
|
+
|
133
137
|
# END button input methods
|
134
138
|
|
135
139
|
# @private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ariadne_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.82
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tailwind_merge
|
@@ -194,10 +194,6 @@ files:
|
|
194
194
|
- app/components/ariadne/ui/combobox/component.html.erb
|
195
195
|
- app/components/ariadne/ui/combobox/component.rb
|
196
196
|
- app/components/ariadne/ui/combobox/component.ts
|
197
|
-
- app/components/ariadne/ui/combobox/item/component.html.erb
|
198
|
-
- app/components/ariadne/ui/combobox/item/component.rb
|
199
|
-
- app/components/ariadne/ui/combobox/option/component.html.erb
|
200
|
-
- app/components/ariadne/ui/combobox/option/component.rb
|
201
197
|
- app/components/ariadne/ui/data_table/component.html.erb
|
202
198
|
- app/components/ariadne/ui/data_table/component.rb
|
203
199
|
- app/components/ariadne/ui/dialog/component.html.erb
|
@@ -213,8 +209,7 @@ files:
|
|
213
209
|
- app/components/ariadne/ui/link/component.rb
|
214
210
|
- app/components/ariadne/ui/list/component.html.erb
|
215
211
|
- app/components/ariadne/ui/list/component.rb
|
216
|
-
- app/components/ariadne/ui/list/
|
217
|
-
- app/components/ariadne/ui/list/item/component.rb
|
212
|
+
- app/components/ariadne/ui/list/component.ts
|
218
213
|
- app/components/ariadne/ui/overlay/component.html.erb
|
219
214
|
- app/components/ariadne/ui/overlay/component.rb
|
220
215
|
- app/components/ariadne/ui/overlay/component.ts
|
@@ -238,7 +233,7 @@ files:
|
|
238
233
|
- app/frontend/ariadne/index.ts
|
239
234
|
- app/frontend/ariadne/stimulus_app.ts
|
240
235
|
- app/frontend/ariadne/theme.ts
|
241
|
-
- app/frontend/controllers/
|
236
|
+
- app/frontend/controllers/form_autosubmit_controller.ts
|
242
237
|
- app/frontend/entrypoints/application.ts
|
243
238
|
- app/frontend/stylesheets/ariadne_view_components.css
|
244
239
|
- app/frontend/stylesheets/scrollbar.css
|
@@ -260,6 +255,7 @@ files:
|
|
260
255
|
- lib/ariadne/forms/builder.rb
|
261
256
|
- lib/ariadne/forms/dsl/badge.rb
|
262
257
|
- lib/ariadne/forms/dsl/button_input.rb
|
258
|
+
- lib/ariadne/forms/dsl/clipboard_copy_button.rb
|
263
259
|
- lib/ariadne/forms/dsl/form_object.rb
|
264
260
|
- lib/ariadne/forms/dsl/form_reference_input.rb
|
265
261
|
- lib/ariadne/forms/dsl/hidden_input.rb
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Ariadne
|
5
|
-
module UI
|
6
|
-
module Combobox
|
7
|
-
module Item
|
8
|
-
class Component < Ariadne::BaseComponent
|
9
|
-
option :label
|
10
|
-
option :as, default: proc { :link } # :button
|
11
|
-
|
12
|
-
accepts_html_attributes do |html_attrs|
|
13
|
-
html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(as:), html_attrs[:class]].join(" "))
|
14
|
-
|
15
|
-
# html_attrs["data-input-filter-target"] = "searchString"
|
16
|
-
if as == :link && !html_attrs[:target]
|
17
|
-
html_attrs[:target] = "_top"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(**options)
|
22
|
-
super(**options)
|
23
|
-
end
|
24
|
-
|
25
|
-
style do
|
26
|
-
base do
|
27
|
-
[
|
28
|
-
"ariadne-flex",
|
29
|
-
"ariadne-gap-0.5",
|
30
|
-
"ariadne-items-center",
|
31
|
-
"ariadne-ps-2",
|
32
|
-
"ariadne-pe-1",
|
33
|
-
"ariadne-rounded",
|
34
|
-
"!ariadne-ring-0",
|
35
|
-
"hover:ariadne-bg-zinc-100",
|
36
|
-
"hover:dark:ariadne-bg-zinc-800",
|
37
|
-
"focus-within:ariadne-bg-zinc-100",
|
38
|
-
"focus-within:dark:ariadne-bg-zinc-800",
|
39
|
-
]
|
40
|
-
end
|
41
|
-
variants do
|
42
|
-
as do
|
43
|
-
button do
|
44
|
-
"ariadne-appearance-none ariadne-inline-flex ariadne-w-full"
|
45
|
-
end
|
46
|
-
|
47
|
-
link do
|
48
|
-
"ariadne-cursor-pointer"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def link?
|
55
|
-
as == :link
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<label
|
2
|
-
tabindex="0"
|
3
|
-
role="menuitemcheckbox"
|
4
|
-
class="<%= style %>">
|
5
|
-
<span class="px-1"><%= option_component %></span>
|
6
|
-
<span
|
7
|
-
class="ariadne-truncate <%= text_content ? 'ariadne-px-1' : 'ariadne-inline-flex ariadne-items-center' %>"
|
8
|
-
data-input-filter-target="searchString">
|
9
|
-
<%= content %>
|
10
|
-
</span>
|
11
|
-
</label>
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Ariadne
|
5
|
-
module UI
|
6
|
-
module Combobox
|
7
|
-
module Option
|
8
|
-
class Component < Ariadne::BaseComponent
|
9
|
-
option :as, default: proc { :link } # :button
|
10
|
-
|
11
|
-
option :type, default: proc { :multiple }
|
12
|
-
option :text_content, default: proc { true }
|
13
|
-
|
14
|
-
accepts_html_attributes disabled: false,
|
15
|
-
tabindex: -1,
|
16
|
-
data: proc {
|
17
|
-
{ action: "#{Ariadne::UI::Combobox::Component.stimulus_name}#checkboxClicked" }
|
18
|
-
}
|
19
|
-
|
20
|
-
def option_component
|
21
|
-
cmp = type == :multiple ? Ariadne::Form::Checkbox : Ariadne::Form::Radio
|
22
|
-
render(cmp::Component.new(html_attrs:))
|
23
|
-
end
|
24
|
-
|
25
|
-
style do
|
26
|
-
base do
|
27
|
-
[
|
28
|
-
"ariadne-flex",
|
29
|
-
"ariadne-gap-0.5",
|
30
|
-
"ariadne-items-center",
|
31
|
-
"ariadne-rounded",
|
32
|
-
"!ariadne-ring-0",
|
33
|
-
"hover:ariadne-bg-zinc-100",
|
34
|
-
"hover:dark:ariadne-bg-zinc-800",
|
35
|
-
"focus-within:ariadne-bg-zinc-100",
|
36
|
-
"focus-within:dark:ariadne-bg-zinc-800",
|
37
|
-
]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<div class="ariadne-flex ariadne-gap-3 ariadne-items-center ariadne-py-2">
|
2
|
-
|
3
|
-
<div class="ariadne-shrink-0">
|
4
|
-
<%= leading_item if leading_item? %>
|
5
|
-
</div>
|
6
|
-
<div class="ariadne-overflow-hidden">
|
7
|
-
<%= cell %>
|
8
|
-
</div>
|
9
|
-
<div class="ariadne-grow ariadne-flex ariadne-justify-end">
|
10
|
-
<%= trailing_item if trailing_item? %>
|
11
|
-
</div>
|
12
|
-
<% if trailing_menu? %>
|
13
|
-
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
</div>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# typed: false
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Ariadne
|
5
|
-
module UI
|
6
|
-
module List
|
7
|
-
module Item
|
8
|
-
class Component < Ariadne::BaseComponent
|
9
|
-
renders_one :leading_item, Ariadne::BaseComponent::ACCEPT_ANYTHING
|
10
|
-
renders_one :cell, Ariadne::BaseComponent::ACCEPT_ANYTHING
|
11
|
-
renders_one :trailing_item, Ariadne::BaseComponent::ACCEPT_ANYTHING
|
12
|
-
renders_one :trailing_menu, Ariadne::BaseComponent::ACCEPT_ANYTHING
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|