shadcn_phlexcomponents 0.1.0 → 0.1.2
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 +26 -9
- 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/form.rb +59 -0
- data/lib/components/form_error.rb +17 -0
- data/lib/components/form_hint.rb +17 -0
- data/lib/components/form_input.rb +49 -0
- 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 +4 -93
- data/lib/shadcn_phlexcomponents/version.rb +1 -1
- metadata +14 -5
- data/app/javascript/controllers/datepicker_controller.js +0 -47
- data/lib/components/datepicker.rb +0 -38
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class HoverCard < Base
|
5
|
-
STYLES = "inline-block"
|
5
|
+
STYLES = "inline-block"
|
6
6
|
|
7
7
|
def initialize(side: :bottom, **attributes)
|
8
8
|
@side = side
|
@@ -11,7 +11,7 @@ module ShadcnPhlexcomponents
|
|
11
11
|
|
12
12
|
def content(**attributes, &)
|
13
13
|
HoverCardContent(**attributes, &)
|
14
|
-
end
|
14
|
+
end
|
15
15
|
|
16
16
|
def trigger(**attributes, &)
|
17
17
|
HoverCardTrigger(side: @side, **attributes, &)
|
@@ -21,13 +21,13 @@ module ShadcnPhlexcomponents
|
|
21
21
|
{
|
22
22
|
data: {
|
23
23
|
controller: "shadcn-phlexcomponents--hover-card",
|
24
|
-
side: @side
|
25
|
-
}
|
26
|
-
}
|
24
|
+
side: @side,
|
25
|
+
},
|
26
|
+
}
|
27
27
|
end
|
28
28
|
|
29
29
|
def view_template(&)
|
30
30
|
div(**@attributes, &)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
33
|
+
end
|
@@ -2,22 +2,20 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class HoverCardContent < Base
|
5
|
-
STYLES = <<~HEREDOC
|
6
|
-
|
7
|
-
|
8
|
-
data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95
|
5
|
+
STYLES = <<~HEREDOC
|
6
|
+
rounded-md border w-64 bg-popover p-4 text-popover-foreground shadow-md outline-none#{" "}
|
7
|
+
animate-in fade-in-0 zoom-in-95
|
9
8
|
data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
|
10
|
-
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2
|
9
|
+
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2#{" "}
|
11
10
|
HEREDOC
|
12
|
-
|
11
|
+
|
13
12
|
def initialize(side: :bottom, **attributes)
|
14
13
|
@side = side
|
15
14
|
super(**attributes)
|
16
15
|
end
|
17
16
|
|
18
|
-
|
19
17
|
def view_template(&)
|
20
|
-
div(class:
|
18
|
+
div(class: "hidden", data: { "shadcn-phlexcomponents--hover-card-target": "content" }) do
|
21
19
|
div(**@attributes, &)
|
22
20
|
end
|
23
21
|
end
|
@@ -27,10 +25,8 @@ module ShadcnPhlexcomponents
|
|
27
25
|
tabindex: -1,
|
28
26
|
data: {
|
29
27
|
side: @side,
|
30
|
-
|
31
|
-
action: "mouseover->shadcn-phlexcomponents--hover-card#clearCloseTimer mouseout->shadcn-phlexcomponents--hover-card#closeWithDelay"
|
32
|
-
}
|
28
|
+
},
|
33
29
|
}
|
34
30
|
end
|
35
31
|
end
|
36
|
-
end
|
32
|
+
end
|
@@ -21,8 +21,8 @@ module ShadcnPhlexcomponents
|
|
21
21
|
if element.name == "button"
|
22
22
|
merged_attributes.delete(:role)
|
23
23
|
end
|
24
|
-
|
25
|
-
send(element.name, **merged_attributes) do
|
24
|
+
|
25
|
+
send(element.name, **merged_attributes) do
|
26
26
|
sanitize_as_child(element.children.to_s)
|
27
27
|
end
|
28
28
|
else
|
@@ -35,16 +35,10 @@ module ShadcnPhlexcomponents
|
|
35
35
|
id: @id,
|
36
36
|
role: "button",
|
37
37
|
data: {
|
38
|
-
state: "closed",
|
39
38
|
as_child: @as_child.to_s,
|
40
|
-
|
41
|
-
|
42
|
-
mouseover->shadcn-phlexcomponents--hover-card#openWithDelay
|
43
|
-
mouseout->shadcn-phlexcomponents--hover-card#closeWithDelay
|
44
|
-
HEREDOC
|
45
|
-
"shadcn-phlexcomponents--hover-card-target": "trigger"
|
46
|
-
}
|
39
|
+
"shadcn-phlexcomponents--hover-card-target": "trigger",
|
40
|
+
},
|
47
41
|
}
|
48
42
|
end
|
49
43
|
end
|
50
|
-
end
|
44
|
+
end
|
data/lib/components/input.rb
CHANGED
data/lib/components/label.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
|
-
|
5
4
|
class Label < Base
|
6
5
|
STYLES = <<~HEREDOC
|
7
6
|
text-sm font-medium leading-none peer-disabled:cursor-not-allowed
|
@@ -12,4 +11,4 @@ module ShadcnPhlexcomponents
|
|
12
11
|
label(**@attributes, &)
|
13
12
|
end
|
14
13
|
end
|
15
|
-
end
|
14
|
+
end
|
data/lib/components/link.rb
CHANGED
@@ -11,7 +11,10 @@ module ShadcnPhlexcomponents
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def view_template(&)
|
14
|
-
|
14
|
+
if block_given?
|
15
|
+
@html_options = @options
|
16
|
+
@options = @name
|
17
|
+
end
|
15
18
|
@html_options ||= {}
|
16
19
|
@html_options = mix(default_attributes, @html_options)
|
17
20
|
@html_options[:class] = TAILWIND_MERGER.merge("#{default_styles} #{@html_options[:class]}")
|
@@ -23,4 +26,4 @@ module ShadcnPhlexcomponents
|
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
|
-
end
|
29
|
+
end
|
@@ -7,7 +7,7 @@ module ShadcnPhlexcomponents
|
|
7
7
|
def link(**attributes, &)
|
8
8
|
PaginationLink(**attributes, &)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def previous(**attributes, &)
|
12
12
|
PaginationPrevious(**attributes, &)
|
13
13
|
end
|
@@ -15,7 +15,7 @@ module ShadcnPhlexcomponents
|
|
15
15
|
def next(**attributes, &)
|
16
16
|
PaginationNext(**attributes, &)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def ellipsis(**attributes, &)
|
20
20
|
PaginationEllipsis(**attributes, &)
|
21
21
|
end
|
@@ -25,7 +25,7 @@ module ShadcnPhlexcomponents
|
|
25
25
|
role: "navigation",
|
26
26
|
aria: {
|
27
27
|
label: "navigation",
|
28
|
-
}
|
28
|
+
},
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
@@ -35,4 +35,4 @@ module ShadcnPhlexcomponents
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class PaginationLink < Base
|
5
5
|
def initialize(href: nil, active: false, **attributes)
|
6
|
-
@href = href
|
6
|
+
@href = href
|
7
7
|
@active = active
|
8
8
|
super(**attributes)
|
9
9
|
end
|
@@ -20,9 +20,9 @@ module ShadcnPhlexcomponents
|
|
20
20
|
{
|
21
21
|
href: @href,
|
22
22
|
aria: {
|
23
|
-
current: @active ? "page" : nil
|
24
|
-
}
|
25
|
-
}
|
23
|
+
current: @active ? "page" : nil,
|
24
|
+
},
|
25
|
+
}
|
26
26
|
end
|
27
27
|
|
28
28
|
def view_template(&)
|
@@ -31,4 +31,4 @@ module ShadcnPhlexcomponents
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class PaginationNext < Base
|
5
5
|
def initialize(href: nil, **attributes)
|
6
|
-
@href = href
|
6
|
+
@href = href
|
7
7
|
super(**attributes)
|
8
8
|
end
|
9
9
|
|
@@ -15,9 +15,9 @@ module ShadcnPhlexcomponents
|
|
15
15
|
{
|
16
16
|
href: @href,
|
17
17
|
aria: {
|
18
|
-
label: "Go to next page"
|
19
|
-
}
|
20
|
-
}
|
18
|
+
label: "Go to next page",
|
19
|
+
},
|
20
|
+
}
|
21
21
|
end
|
22
22
|
|
23
23
|
def view_template(&)
|
@@ -29,4 +29,4 @@ module ShadcnPhlexcomponents
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
@@ -11,9 +11,9 @@ module ShadcnPhlexcomponents
|
|
11
11
|
{
|
12
12
|
href: @href,
|
13
13
|
aria: {
|
14
|
-
label: "Go to previous page"
|
15
|
-
}
|
16
|
-
}
|
14
|
+
label: "Go to previous page",
|
15
|
+
},
|
16
|
+
}
|
17
17
|
end
|
18
18
|
|
19
19
|
def default_styles
|
@@ -29,4 +29,4 @@ module ShadcnPhlexcomponents
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
data/lib/components/popover.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
|
-
|
5
4
|
class Popover < Base
|
6
|
-
STYLES = "inline-block"
|
5
|
+
STYLES = "inline-block"
|
7
6
|
|
8
7
|
def initialize(side: :bottom, aria_id: "popover-#{SecureRandom.hex(5)}", **attributes)
|
9
8
|
@side = side
|
@@ -13,7 +12,7 @@ module ShadcnPhlexcomponents
|
|
13
12
|
|
14
13
|
def content(**attributes, &)
|
15
14
|
PopoverContent(side: @side, aria_id: @aria_id, **attributes, &)
|
16
|
-
end
|
15
|
+
end
|
17
16
|
|
18
17
|
def trigger(**attributes, &)
|
19
18
|
PopoverTrigger(aria_id: @aria_id, **attributes, &)
|
@@ -23,13 +22,13 @@ module ShadcnPhlexcomponents
|
|
23
22
|
{
|
24
23
|
data: {
|
25
24
|
controller: "shadcn-phlexcomponents--popover",
|
26
|
-
side: @side
|
27
|
-
}
|
28
|
-
}
|
25
|
+
side: @side,
|
26
|
+
},
|
27
|
+
}
|
29
28
|
end
|
30
29
|
|
31
30
|
def view_template(&)
|
32
31
|
div(**@attributes, &)
|
33
32
|
end
|
34
33
|
end
|
35
|
-
end
|
34
|
+
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class PopoverContent < Base
|
5
|
-
STYLES = <<~HEREDOC
|
6
|
-
z-50 rounded-md border w-72 bg-popover p-4 text-popover-foreground shadow-md outline-none
|
7
|
-
data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0
|
8
|
-
data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95
|
5
|
+
STYLES = <<~HEREDOC
|
6
|
+
z-50 rounded-md border w-72 bg-popover p-4 text-popover-foreground shadow-md outline-none#{" "}
|
7
|
+
data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0#{" "}
|
8
|
+
data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95#{" "}
|
9
9
|
data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
|
10
|
-
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2
|
10
|
+
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2#{" "}
|
11
11
|
HEREDOC
|
12
|
-
|
12
|
+
|
13
13
|
def initialize(side: :bottom, aria_id: nil, **attributes)
|
14
14
|
@side = side
|
15
15
|
@aria_id = aria_id
|
@@ -17,7 +17,10 @@ module ShadcnPhlexcomponents
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def view_template(&)
|
20
|
-
div(
|
20
|
+
div(
|
21
|
+
class: "hidden fixed top-0 left-0 w-max z-50",
|
22
|
+
data: { "shadcn-phlexcomponents--popover-target": "contentWrapper" },
|
23
|
+
) do
|
21
24
|
div(**@attributes, &)
|
22
25
|
end
|
23
26
|
end
|
@@ -29,9 +32,9 @@ module ShadcnPhlexcomponents
|
|
29
32
|
role: "dialog",
|
30
33
|
data: {
|
31
34
|
side: @side,
|
32
|
-
"shadcn-phlexcomponents--popover-target": "content"
|
33
|
-
}
|
35
|
+
"shadcn-phlexcomponents--popover-target": "content",
|
36
|
+
},
|
34
37
|
}
|
35
38
|
end
|
36
39
|
end
|
37
|
-
end
|
40
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
|
-
|
5
4
|
class PopoverTrigger < Base
|
6
5
|
def initialize(as_child: false, aria_id: nil, **attributes)
|
7
6
|
@as_child = as_child
|
@@ -24,7 +23,7 @@ module ShadcnPhlexcomponents
|
|
24
23
|
merged_attributes.delete(:role)
|
25
24
|
end
|
26
25
|
|
27
|
-
send(element.name, **merged_attributes) do
|
26
|
+
send(element.name, **merged_attributes) do
|
28
27
|
sanitize_as_child(element.children.to_s)
|
29
28
|
end
|
30
29
|
else
|
@@ -39,14 +38,14 @@ module ShadcnPhlexcomponents
|
|
39
38
|
aria: {
|
40
39
|
haspopup: "dialog",
|
41
40
|
expanded: false,
|
42
|
-
controls: "#{@aria_id}-content"
|
41
|
+
controls: "#{@aria_id}-content",
|
43
42
|
},
|
44
43
|
data: {
|
45
44
|
as_child: @as_child.to_s,
|
46
45
|
action: "click->shadcn-phlexcomponents--popover#toggle",
|
47
|
-
"shadcn-phlexcomponents--popover-target": "trigger"
|
48
|
-
}
|
46
|
+
"shadcn-phlexcomponents--popover-target": "trigger",
|
47
|
+
},
|
49
48
|
}
|
50
49
|
end
|
51
50
|
end
|
52
|
-
end
|
51
|
+
end
|
data/lib/components/progress.rb
CHANGED
@@ -6,7 +6,7 @@ module ShadcnPhlexcomponents
|
|
6
6
|
|
7
7
|
def initialize(value: 0, **attributes)
|
8
8
|
@value = value
|
9
|
-
super(**attributes)
|
9
|
+
super(**attributes)
|
10
10
|
end
|
11
11
|
|
12
12
|
def default_attributes
|
@@ -19,19 +19,19 @@ module ShadcnPhlexcomponents
|
|
19
19
|
},
|
20
20
|
data: {
|
21
21
|
controller: "shadcn-phlexcomponents--progress",
|
22
|
-
"shadcn-phlexcomponents--progress-progress-value": @value
|
23
|
-
}
|
22
|
+
"shadcn-phlexcomponents--progress-progress-value": @value,
|
23
|
+
},
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
27
|
def view_template
|
28
28
|
div(**@attributes) do
|
29
29
|
div(
|
30
|
-
class: "h-full w-full flex-1 bg-primary transition-all",
|
31
|
-
style: "transform: translateX(-#{100
|
32
|
-
data: { "shadcn-phlexcomponents--progress-target": "bar"}
|
30
|
+
class: "h-full w-full flex-1 bg-primary transition-all",
|
31
|
+
style: "transform: translateX(-#{100 - @value}%)",
|
32
|
+
data: { "shadcn-phlexcomponents--progress-target": "bar" },
|
33
33
|
)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -19,7 +19,7 @@ module ShadcnPhlexcomponents
|
|
19
19
|
def items(collection, value_method:, text_method:, wrapper_class: nil)
|
20
20
|
wrapper_class = TAILWIND_MERGER.merge("flex items-center space-x-2 #{wrapper_class}")
|
21
21
|
|
22
|
-
if collection.first
|
22
|
+
if collection.first&.is_a?(Hash)
|
23
23
|
collection = convert_collection_hash_to_struct(collection, value_method: value_method, text_method: text_method)
|
24
24
|
end
|
25
25
|
|
@@ -46,7 +46,7 @@ module ShadcnPhlexcomponents
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def default_attributes
|
49
|
-
{
|
49
|
+
{
|
50
50
|
role: "radiogroup",
|
51
51
|
dir: @dir,
|
52
52
|
aria: {
|
@@ -55,8 +55,8 @@ module ShadcnPhlexcomponents
|
|
55
55
|
data: {
|
56
56
|
controller: "shadcn-phlexcomponents--radio-group",
|
57
57
|
"shadcn-phlexcomponents--radio-group-selected-value": @value,
|
58
|
-
}
|
58
|
+
},
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end
|
62
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class RadioGroupItem < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow
|
7
7
|
focus:outline-none focus-visible:ring-1 focus-visible:ring-ring
|
8
8
|
disabled:cursor-not-allowed disabled:opacity-50 relative cursor-pointer
|
@@ -20,8 +20,8 @@ module ShadcnPhlexcomponents
|
|
20
20
|
def view_template(&)
|
21
21
|
button(**@attributes) do
|
22
22
|
span(
|
23
|
-
|
24
|
-
|
23
|
+
class: "items-center justify-center hidden group-data-[checked=true]/radio:flex",
|
24
|
+
) do
|
25
25
|
icon("circle", class: "size-2.5 fill-primary")
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ module ShadcnPhlexcomponents
|
|
33
33
|
tabindex: -1,
|
34
34
|
checked: @checked,
|
35
35
|
aria: { hidden: true },
|
36
|
-
data: { input: "" }
|
36
|
+
data: { input: "" },
|
37
37
|
)
|
38
38
|
end
|
39
39
|
end
|
@@ -46,12 +46,12 @@ module ShadcnPhlexcomponents
|
|
46
46
|
role: "radio",
|
47
47
|
aria: {
|
48
48
|
checked: @checked.to_s,
|
49
|
-
},
|
49
|
+
},
|
50
50
|
data: {
|
51
51
|
checked: @checked.to_s,
|
52
52
|
value: @value,
|
53
53
|
"shadcn-phlexcomponents--radio-group-target": "item",
|
54
|
-
action: <<~HEREDOC
|
54
|
+
action: <<~HEREDOC,
|
55
55
|
click->shadcn-phlexcomponents--radio-group#setChecked
|
56
56
|
keydown.right->shadcn-phlexcomponents--radio-group#setCheckedToNext:prevent
|
57
57
|
keydown.down->shadcn-phlexcomponents--radio-group#setCheckedToNext:prevent
|
@@ -59,8 +59,8 @@ module ShadcnPhlexcomponents
|
|
59
59
|
keydown.left->shadcn-phlexcomponents--radio-group#setCheckedToPrev:prevent
|
60
60
|
keydown.enter->shadcn-phlexcomponents--radio-group#preventDefault
|
61
61
|
HEREDOC
|
62
|
-
}
|
62
|
+
},
|
63
63
|
}
|
64
64
|
end
|
65
65
|
end
|
66
|
-
end
|
66
|
+
end
|