shadcn_phlexcomponents 0.1.0 → 0.1.1
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/app/assets/tailwind/choices.css +324 -0
- data/app/assets/tailwind/vanilla-calendar-pro.css +5 -0
- data/app/javascript/controllers/combobox_controller.js +19 -276
- data/app/javascript/controllers/date_picker_controller.js +118 -0
- data/app/javascript/controllers/date_range_picker_controller.js +231 -0
- data/app/javascript/controllers/dropdown_menu_controller.js +1 -1
- data/app/javascript/controllers/hover_card_controller.js +33 -126
- data/app/javascript/controllers/sidebar_controller.js +0 -1
- data/app/javascript/controllers/tooltip_controller.js +32 -126
- data/lib/components/accordion.rb +3 -3
- data/lib/components/accordion_content.rb +12 -10
- data/lib/components/accordion_item.rb +3 -3
- data/lib/components/accordion_trigger.rb +3 -3
- data/lib/components/alert_description.rb +1 -1
- data/lib/components/alert_dialog.rb +2 -2
- data/lib/components/alert_dialog_action.rb +2 -2
- data/lib/components/alert_dialog_action_to.rb +5 -2
- data/lib/components/alert_dialog_cancel.rb +1 -1
- data/lib/components/alert_dialog_content.rb +1 -1
- data/lib/components/alert_dialog_description.rb +1 -1
- data/lib/components/alert_dialog_footer.rb +1 -1
- data/lib/components/alert_dialog_header.rb +1 -1
- data/lib/components/alert_dialog_title.rb +1 -1
- data/lib/components/alert_dialog_trigger.rb +2 -2
- data/lib/components/aspect_ratio.rb +1 -1
- data/lib/components/avatar.rb +1 -1
- data/lib/components/avatar_fallback.rb +1 -1
- data/lib/components/avatar_image.rb +1 -2
- data/lib/components/badge.rb +2 -8
- data/lib/components/base.rb +5 -5
- data/lib/components/breadcrumb.rb +1 -1
- data/lib/components/breadcrumb_ellipsis.rb +1 -1
- data/lib/components/breadcrumb_item.rb +1 -1
- data/lib/components/breadcrumb_link.rb +1 -1
- data/lib/components/breadcrumb_page.rb +1 -1
- data/lib/components/breadcrumb_separator.rb +1 -1
- data/lib/components/button.rb +1 -1
- data/lib/components/card.rb +1 -1
- data/lib/components/card_content.rb +1 -1
- data/lib/components/card_description.rb +1 -1
- data/lib/components/card_footer.rb +1 -1
- data/lib/components/card_header.rb +1 -1
- data/lib/components/card_title.rb +1 -1
- data/lib/components/checkbox.rb +14 -10
- data/lib/components/checkbox_group.rb +9 -8
- data/lib/components/collapsible.rb +2 -3
- data/lib/components/collapsible_content.rb +2 -3
- data/lib/components/collapsible_trigger.rb +5 -5
- data/lib/components/combobox.rb +57 -0
- data/lib/components/combobox_item.rb +9 -0
- data/lib/components/date_picker.rb +94 -0
- data/lib/components/date_range_picker.rb +113 -0
- data/lib/components/dialog.rb +1 -1
- data/lib/components/dialog_close.rb +1 -1
- data/lib/components/dialog_content.rb +2 -2
- data/lib/components/dialog_description.rb +1 -1
- data/lib/components/dialog_footer.rb +1 -1
- data/lib/components/dialog_header.rb +1 -1
- data/lib/components/dialog_title.rb +1 -1
- data/lib/components/dialog_trigger.rb +2 -2
- data/lib/components/dropdown_menu.rb +5 -5
- data/lib/components/dropdown_menu_content.rb +12 -9
- data/lib/components/dropdown_menu_item.rb +5 -6
- data/lib/components/dropdown_menu_item_to.rb +6 -3
- data/lib/components/dropdown_menu_label.rb +2 -3
- data/lib/components/dropdown_menu_separator.rb +5 -5
- data/lib/components/dropdown_menu_trigger.rb +9 -10
- data/lib/components/hover_card.rb +6 -6
- data/lib/components/hover_card_content.rb +8 -12
- data/lib/components/hover_card_trigger.rb +5 -11
- data/lib/components/input.rb +1 -1
- data/lib/components/label.rb +1 -2
- data/lib/components/link.rb +5 -2
- data/lib/components/loading_button.rb +1 -1
- data/lib/components/pagination.rb +4 -4
- data/lib/components/pagination_ellipsis.rb +3 -3
- data/lib/components/pagination_link.rb +5 -5
- data/lib/components/pagination_next.rb +5 -5
- data/lib/components/pagination_previous.rb +4 -4
- data/lib/components/popover.rb +6 -7
- data/lib/components/popover_content.rb +13 -10
- data/lib/components/popover_trigger.rb +5 -6
- data/lib/components/progress.rb +7 -7
- data/lib/components/radio_group.rb +4 -4
- data/lib/components/radio_group_item.rb +8 -8
- data/lib/components/select.rb +67 -72
- data/lib/components/select_content.rb +12 -7
- data/lib/components/select_group.rb +3 -3
- data/lib/components/select_item.rb +9 -8
- data/lib/components/select_label.rb +6 -5
- data/lib/components/select_trigger.rb +12 -10
- data/lib/components/separator.rb +3 -3
- data/lib/components/sheet.rb +9 -9
- data/lib/components/sheet_close.rb +4 -4
- data/lib/components/sheet_content.rb +13 -15
- data/lib/components/sheet_description.rb +3 -3
- data/lib/components/sheet_footer.rb +2 -2
- data/lib/components/sheet_header.rb +2 -2
- data/lib/components/sheet_title.rb +3 -3
- data/lib/components/sheet_trigger.rb +6 -6
- data/lib/components/sidebar.rb +30 -25
- data/lib/components/sidebar_container.rb +1 -1
- data/lib/components/sidebar_content.rb +1 -1
- data/lib/components/sidebar_footer.rb +2 -2
- data/lib/components/sidebar_group.rb +1 -1
- data/lib/components/sidebar_group_content.rb +1 -1
- data/lib/components/sidebar_group_label.rb +2 -2
- data/lib/components/sidebar_header.rb +2 -2
- data/lib/components/sidebar_inset.rb +1 -1
- data/lib/components/sidebar_menu.rb +2 -2
- data/lib/components/sidebar_menu_button.rb +5 -5
- data/lib/components/sidebar_menu_item.rb +1 -1
- data/lib/components/sidebar_menu_sub.rb +2 -2
- data/lib/components/sidebar_menu_sub_button.rb +7 -7
- data/lib/components/sidebar_menu_sub_item.rb +1 -1
- data/lib/components/sidebar_trigger.rb +5 -5
- data/lib/components/skeleton.rb +2 -2
- data/lib/components/switch.rb +10 -9
- data/lib/components/table.rb +7 -5
- data/lib/components/table_body.rb +2 -2
- data/lib/components/table_caption.rb +2 -2
- data/lib/components/table_cell.rb +2 -2
- data/lib/components/table_footer.rb +2 -2
- data/lib/components/table_head.rb +3 -3
- data/lib/components/table_header.rb +2 -2
- data/lib/components/table_row.rb +2 -2
- data/lib/components/tabs.rb +3 -3
- data/lib/components/tabs_content.rb +5 -5
- data/lib/components/tabs_list.rb +4 -4
- data/lib/components/tabs_trigger.rb +3 -3
- data/lib/components/textarea.rb +1 -1
- data/lib/components/theme_switcher.rb +2 -2
- data/lib/components/toast.rb +15 -14
- data/lib/components/toast_action.rb +5 -4
- data/lib/components/toast_action_to.rb +5 -2
- data/lib/components/toast_container.rb +5 -5
- data/lib/components/toast_content.rb +1 -1
- data/lib/components/toast_description.rb +1 -1
- data/lib/components/toast_title.rb +1 -1
- data/lib/components/tooltip.rb +8 -8
- data/lib/components/tooltip_content.rb +8 -11
- data/lib/components/tooltip_trigger.rb +9 -11
- data/lib/shadcn_phlexcomponents/alias.rb +3 -1
- data/lib/shadcn_phlexcomponents/version.rb +1 -1
- metadata +9 -4
- data/app/javascript/controllers/datepicker_controller.js +0 -47
- data/lib/components/datepicker.rb +0 -38
data/lib/components/accordion.rb
CHANGED
@@ -4,7 +4,7 @@ module ShadcnPhlexcomponents
|
|
4
4
|
class Accordion < Base
|
5
5
|
def initialize(value: nil, multiple: false, aria_id: "accordion-#{SecureRandom.hex(5)}", **attributes)
|
6
6
|
@multiple = multiple
|
7
|
-
@value = value
|
7
|
+
@value = value&.is_a?(String) ? [value] : value
|
8
8
|
@aria_id = aria_id
|
9
9
|
super(**attributes)
|
10
10
|
end
|
@@ -26,8 +26,8 @@ module ShadcnPhlexcomponents
|
|
26
26
|
data: {
|
27
27
|
value: (@value || []).to_json,
|
28
28
|
multiple: @multiple.to_s,
|
29
|
-
controller: "shadcn-phlexcomponents--accordion"
|
30
|
-
}
|
29
|
+
controller: "shadcn-phlexcomponents--accordion",
|
30
|
+
},
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
@@ -10,17 +10,19 @@ module ShadcnPhlexcomponents
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def view_template(&)
|
13
|
-
div(
|
13
|
+
div(
|
14
|
+
class: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up
|
14
15
|
data-[state=open]:animate-accordion-down hidden",
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
id: "#{@aria_id}-content",
|
17
|
+
role: "region",
|
18
|
+
aria: {
|
19
|
+
labelledby: "#{@aria_id}-trigger",
|
20
|
+
},
|
21
|
+
data: {
|
22
|
+
state: "closed",
|
23
|
+
"shadcn-phlexcomponents--accordion-target": "content",
|
24
|
+
},
|
25
|
+
) do
|
24
26
|
div(**@attributes, &)
|
25
27
|
end
|
26
28
|
end
|
@@ -4,7 +4,7 @@ module ShadcnPhlexcomponents
|
|
4
4
|
class AccordionItem < Base
|
5
5
|
STYLES = "border-b"
|
6
6
|
|
7
|
-
def initialize(value:,
|
7
|
+
def initialize(value:, **attributes)
|
8
8
|
@value = value
|
9
9
|
super(**attributes)
|
10
10
|
end
|
@@ -14,8 +14,8 @@ module ShadcnPhlexcomponents
|
|
14
14
|
data: {
|
15
15
|
state: "closed",
|
16
16
|
value: @value,
|
17
|
-
"shadcn-phlexcomponents--accordion-target": "item"
|
18
|
-
}
|
17
|
+
"shadcn-phlexcomponents--accordion-target": "item",
|
18
|
+
},
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -18,17 +18,17 @@ module ShadcnPhlexcomponents
|
|
18
18
|
id: "#{@aria_id}-trigger",
|
19
19
|
aria: {
|
20
20
|
controls: "#{@aria_id}-content",
|
21
|
-
expanded: "false"
|
21
|
+
expanded: "false",
|
22
22
|
},
|
23
23
|
data: {
|
24
24
|
state: "closed",
|
25
25
|
"shadcn-phlexcomponents--accordion-target": "trigger",
|
26
|
-
action: <<~HEREDOC
|
26
|
+
action: <<~HEREDOC,
|
27
27
|
click->shadcn-phlexcomponents--accordion#toggleItem
|
28
28
|
keydown.up->shadcn-phlexcomponents--accordion#focusPrev:prevent
|
29
29
|
keydown.down->shadcn-phlexcomponents--accordion#focusNext:prevent
|
30
30
|
HEREDOC
|
31
|
-
}
|
31
|
+
},
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
@@ -36,7 +36,7 @@ module ShadcnPhlexcomponents
|
|
36
36
|
def cancel(**attributes, &)
|
37
37
|
AlertDialogCancel(**attributes, &)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def action(**attributes, &)
|
41
41
|
AlertDialogAction(**attributes, &)
|
42
42
|
end
|
@@ -57,4 +57,4 @@ module ShadcnPhlexcomponents
|
|
57
57
|
div(**@attributes, &)
|
58
58
|
end
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
@@ -21,7 +21,10 @@ module ShadcnPhlexcomponents
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def view_template(&)
|
24
|
-
|
24
|
+
if block_given?
|
25
|
+
@html_options = @options
|
26
|
+
@options = @name
|
27
|
+
end
|
25
28
|
@html_options ||= {}
|
26
29
|
@variant = @html_options.delete(:variant) || :primary
|
27
30
|
@html_options = mix(default_attributes, @html_options)
|
@@ -34,4 +37,4 @@ module ShadcnPhlexcomponents
|
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
37
|
-
end
|
40
|
+
end
|
@@ -19,7 +19,7 @@ module ShadcnPhlexcomponents
|
|
19
19
|
data: {
|
20
20
|
action: "click->shadcn-phlexcomponents--alert-dialog#open",
|
21
21
|
"shadcn-phlexcomponents--alert-dialog-target": "trigger",
|
22
|
-
as_child: @as_child.to_s
|
22
|
+
as_child: @as_child.to_s,
|
23
23
|
},
|
24
24
|
}
|
25
25
|
end
|
@@ -47,4 +47,4 @@ module ShadcnPhlexcomponents
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
data/lib/components/avatar.rb
CHANGED
data/lib/components/badge.rb
CHANGED
@@ -14,23 +14,17 @@ module ShadcnPhlexcomponents
|
|
14
14
|
outline: "text-foreground",
|
15
15
|
}.freeze
|
16
16
|
|
17
|
-
class << self
|
18
|
-
def default_styles(variant)
|
19
|
-
"#{STYLES} #{VARIANTS[variant]}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
17
|
def initialize(variant: :primary, **attributes)
|
24
18
|
@variant = variant
|
25
19
|
super(**attributes)
|
26
20
|
end
|
27
21
|
|
28
22
|
def default_styles
|
29
|
-
|
23
|
+
"#{STYLES} #{VARIANTS[@variant]}"
|
30
24
|
end
|
31
25
|
|
32
26
|
def view_template(&)
|
33
27
|
div(**@attributes, &)
|
34
28
|
end
|
35
29
|
end
|
36
|
-
end
|
30
|
+
end
|
data/lib/components/base.rb
CHANGED
@@ -11,7 +11,7 @@ module ShadcnPhlexcomponents
|
|
11
11
|
STYLES = ""
|
12
12
|
|
13
13
|
SANITIZER_ALLOWED_TAGS = (Rails::HTML::SafeListSanitizer.allowed_tags.to_a +
|
14
|
-
[
|
14
|
+
["svg", "path", "polygon", "polyline", "circle", "ellipse", "rect", "line", "use", "defs", "g"]).freeze
|
15
15
|
|
16
16
|
SANITIZER_ALLOWED_ATTRIBUTES = (Rails::HTML::SafeListSanitizer.allowed_attributes.to_a +
|
17
17
|
[
|
@@ -32,7 +32,7 @@ module ShadcnPhlexcomponents
|
|
32
32
|
"stroke-width",
|
33
33
|
"stroke-linecap",
|
34
34
|
"aria-hidden",
|
35
|
-
"class"
|
35
|
+
"class",
|
36
36
|
]).freeze
|
37
37
|
|
38
38
|
def initialize(**attributes)
|
@@ -90,15 +90,15 @@ module ShadcnPhlexcomponents
|
|
90
90
|
def icon(named, **options)
|
91
91
|
options = options.with_indifferent_access
|
92
92
|
size = options.delete(:size)
|
93
|
-
options = options.merge
|
93
|
+
options = options.merge(width: size, height: size) if size
|
94
94
|
|
95
95
|
svg(**LucideRails.default_options.merge(**options)) { LucideRails::IconProvider.icon(named).html_safe }
|
96
96
|
end
|
97
97
|
|
98
98
|
def convert_collection_hash_to_struct(collection, value_method:, text_method:)
|
99
|
-
|
99
|
+
struct_constructor = Struct.new(value_method, text_method)
|
100
100
|
collection.map do |item|
|
101
|
-
struct =
|
101
|
+
struct = struct_constructor.new
|
102
102
|
struct[value_method] = item[value_method]
|
103
103
|
struct[text_method] = item[text_method]
|
104
104
|
struct
|
data/lib/components/button.rb
CHANGED
data/lib/components/card.rb
CHANGED
data/lib/components/checkbox.rb
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Checkbox < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
peer size-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none
|
7
7
|
focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50
|
8
8
|
data-[checked=true]:bg-primary data-[checked=true]:text-primary-foreground relative
|
9
9
|
cursor-pointer group/checkbox
|
10
10
|
HEREDOC
|
11
11
|
|
12
|
-
def initialize(name: nil, value: "1", unchecked_value: "0", checked: false, id: nil, include_hidden: true,
|
12
|
+
def initialize(name: nil, value: "1", unchecked_value: "0", checked: false, id: nil, include_hidden: true,
|
13
|
+
**attributes)
|
13
14
|
@name = name
|
14
15
|
@value = value
|
15
16
|
@unchecked_value = unchecked_value
|
@@ -21,7 +22,7 @@ module ShadcnPhlexcomponents
|
|
21
22
|
|
22
23
|
def view_template(&)
|
23
24
|
button(**@attributes) do
|
24
|
-
span(class: "absolute inset-0 items-center justify-center text-current
|
25
|
+
span(class: "absolute inset-0 items-center justify-center text-current
|
25
26
|
pointer-events-none hidden group-data-[checked=true]/checkbox:flex") do
|
26
27
|
icon("check", class: "size-4")
|
27
28
|
end
|
@@ -31,7 +32,7 @@ module ShadcnPhlexcomponents
|
|
31
32
|
end
|
32
33
|
|
33
34
|
input(
|
34
|
-
type: "checkbox",
|
35
|
+
type: "checkbox",
|
35
36
|
value: @value,
|
36
37
|
class: "-translate-x-full pointer-events-none absolute top-0 left-0 size-4 opacity-0",
|
37
38
|
name: @name,
|
@@ -39,14 +40,14 @@ module ShadcnPhlexcomponents
|
|
39
40
|
checked: @checked,
|
40
41
|
aria: { hidden: true },
|
41
42
|
data: {
|
42
|
-
"shadcn-phlexcomponents--checkbox-target": "input"
|
43
|
-
}
|
43
|
+
"shadcn-phlexcomponents--checkbox-target": "input",
|
44
|
+
},
|
44
45
|
)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
def default_attributes
|
49
|
-
{
|
50
|
+
{
|
50
51
|
id: @id,
|
51
52
|
type: "button",
|
52
53
|
role: "checkbox",
|
@@ -56,10 +57,13 @@ module ShadcnPhlexcomponents
|
|
56
57
|
data: {
|
57
58
|
checked: @checked.to_s,
|
58
59
|
controller: "shadcn-phlexcomponents--checkbox",
|
59
|
-
action:
|
60
|
+
action: <<~HEREDOC,
|
61
|
+
click->shadcn-phlexcomponents--checkbox#toggle
|
62
|
+
keydown.enter->shadcn-phlexcomponents--checkbox#preventDefault
|
63
|
+
HEREDOC
|
60
64
|
"shadcn-phlexcomponents--checkbox-checked-value": @checked,
|
61
|
-
}
|
65
|
+
},
|
62
66
|
}
|
63
67
|
end
|
64
68
|
end
|
65
|
-
end
|
69
|
+
end
|
@@ -14,7 +14,7 @@ module ShadcnPhlexcomponents
|
|
14
14
|
def items(collection, value_method:, text_method:, wrapper_class: nil)
|
15
15
|
wrapper_class = TAILWIND_MERGER.merge("flex items-center space-x-2 #{wrapper_class}")
|
16
16
|
|
17
|
-
if collection.first
|
17
|
+
if collection.first&.is_a?(Hash)
|
18
18
|
collection = convert_collection_hash_to_struct(collection, value_method: value_method, text_method: text_method)
|
19
19
|
end
|
20
20
|
|
@@ -24,12 +24,13 @@ module ShadcnPhlexcomponents
|
|
24
24
|
id = "#{@name.parameterize.underscore}_#{value}"
|
25
25
|
|
26
26
|
div(class: wrapper_class) do
|
27
|
-
Checkbox(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
Checkbox(
|
28
|
+
name: "#{@name}[]",
|
29
|
+
id: id,
|
30
|
+
value: value,
|
31
|
+
checked: @value.include?(value),
|
32
|
+
include_hidden: false,
|
33
|
+
)
|
33
34
|
Label(for: id) { text }
|
34
35
|
end
|
35
36
|
end
|
@@ -45,4 +46,4 @@ module ShadcnPhlexcomponents
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
48
|
-
end
|
49
|
+
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Collapsible < Base
|
5
|
-
|
6
5
|
def initialize(open: false, aria_id: "collapsible-#{SecureRandom.hex(5)}", **attributes)
|
7
6
|
@open = open
|
8
7
|
@aria_id = aria_id
|
@@ -20,8 +19,8 @@ module ShadcnPhlexcomponents
|
|
20
19
|
def default_attributes
|
21
20
|
{
|
22
21
|
data: {
|
23
|
-
controller: "shadcn-phlexcomponents--collapsible"
|
24
|
-
}
|
22
|
+
controller: "shadcn-phlexcomponents--collapsible",
|
23
|
+
},
|
25
24
|
}
|
26
25
|
end
|
27
26
|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class CollapsibleContent < Base
|
5
|
-
|
6
5
|
def initialize(aria_id: :nil, **attributes)
|
7
6
|
@aria_id = aria_id
|
8
7
|
super(**attributes)
|
@@ -12,8 +11,8 @@ module ShadcnPhlexcomponents
|
|
12
11
|
{
|
13
12
|
id: "#{@aria_id}-content",
|
14
13
|
data: {
|
15
|
-
"shadcn-phlexcomponents--collapsible-target": "content"
|
16
|
-
}
|
14
|
+
"shadcn-phlexcomponents--collapsible-target": "content",
|
15
|
+
},
|
17
16
|
}
|
18
17
|
end
|
19
18
|
|
@@ -14,13 +14,13 @@ module ShadcnPhlexcomponents
|
|
14
14
|
role: "button",
|
15
15
|
aria: {
|
16
16
|
expanded: @open.to_s,
|
17
|
-
controls: "#{@aria_id}-content"
|
17
|
+
controls: "#{@aria_id}-content",
|
18
18
|
},
|
19
19
|
data: {
|
20
|
-
state: @open ? "open" :
|
20
|
+
state: @open ? "open" : "closed",
|
21
21
|
action: "click->shadcn-phlexcomponents--collapsible#toggle",
|
22
|
-
"shadcn-phlexcomponents--collapsible-target": "trigger"
|
23
|
-
}
|
22
|
+
"shadcn-phlexcomponents--collapsible-target": "trigger",
|
23
|
+
},
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
@@ -39,7 +39,7 @@ module ShadcnPhlexcomponents
|
|
39
39
|
merged_attributes.delete(:role)
|
40
40
|
end
|
41
41
|
|
42
|
-
send(element.name, **merged_attributes) do
|
42
|
+
send(element.name, **merged_attributes) do
|
43
43
|
sanitize_as_child(element.children.to_s)
|
44
44
|
end
|
45
45
|
else
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShadcnPhlexcomponents
|
4
|
+
class Combobox < Base
|
5
|
+
def initialize(id: nil,
|
6
|
+
name: nil,
|
7
|
+
value: nil,
|
8
|
+
placeholder: nil,
|
9
|
+
disabled: false,
|
10
|
+
include_blank: false,
|
11
|
+
**attributes)
|
12
|
+
@id = id || name
|
13
|
+
@name = name
|
14
|
+
@value = value
|
15
|
+
@placeholder = placeholder
|
16
|
+
@include_blank = include_blank
|
17
|
+
@disabled = disabled
|
18
|
+
super(**attributes)
|
19
|
+
end
|
20
|
+
|
21
|
+
def item(**attributes, &)
|
22
|
+
ComboboxItem(**attributes, &)
|
23
|
+
end
|
24
|
+
|
25
|
+
def items(collection)
|
26
|
+
collection.each do |option|
|
27
|
+
ComboboxItem(value: option[:value], disabled: option[:disabled]) { option[:name] }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def view_template(&)
|
32
|
+
div(**@attributes) do
|
33
|
+
select(
|
34
|
+
id: @id,
|
35
|
+
name: @name,
|
36
|
+
disabled: @disabled,
|
37
|
+
data: { "shadcn-phlexcomponents--combobox-target": "select" },
|
38
|
+
) do
|
39
|
+
option(value: "")
|
40
|
+
|
41
|
+
yield
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_attributes
|
47
|
+
{
|
48
|
+
data: {
|
49
|
+
controller: "shadcn-phlexcomponents--combobox",
|
50
|
+
placeholder: @placeholder,
|
51
|
+
include_blank: @include_blank.to_s,
|
52
|
+
value: @value,
|
53
|
+
},
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|