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
@@ -7,8 +7,8 @@ module ShadcnPhlexcomponents
|
|
7
7
|
active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground
|
8
8
|
flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none
|
9
9
|
focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none
|
10
|
-
aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0
|
11
|
-
data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground
|
10
|
+
aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0#{" "}
|
11
|
+
data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground#{" "}
|
12
12
|
text-sm group-data-[collapsible=icon]:hidden cursor-pointer
|
13
13
|
HEREDOC
|
14
14
|
|
@@ -21,9 +21,9 @@ module ShadcnPhlexcomponents
|
|
21
21
|
def default_attributes
|
22
22
|
{
|
23
23
|
data: {
|
24
|
-
active: @active.to_s
|
25
|
-
}
|
26
|
-
}
|
24
|
+
active: @active.to_s,
|
25
|
+
},
|
26
|
+
}
|
27
27
|
end
|
28
28
|
|
29
29
|
def view_template(&)
|
@@ -37,7 +37,7 @@ module ShadcnPhlexcomponents
|
|
37
37
|
merged_attributes = mix(@attributes, element_attributes)
|
38
38
|
merged_attributes[:class] = styles
|
39
39
|
|
40
|
-
send(element.name, **merged_attributes) do
|
40
|
+
send(element.name, **merged_attributes) do
|
41
41
|
sanitize_as_child(element.children.to_s)
|
42
42
|
end
|
43
43
|
else
|
@@ -45,4 +45,4 @@ module ShadcnPhlexcomponents
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
end
|
48
|
+
end
|
@@ -14,15 +14,15 @@ module ShadcnPhlexcomponents
|
|
14
14
|
@sidebar_id = sidebar_id
|
15
15
|
super(**attributes)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def default_attributes
|
19
19
|
{
|
20
20
|
data: {
|
21
21
|
sidebar_id: @sidebar_id,
|
22
22
|
controller: "shadcn-phlexcomponents--sidebar-trigger",
|
23
|
-
action: "click->shadcn-phlexcomponents--sidebar-trigger#toggle"
|
24
|
-
}
|
25
|
-
}
|
23
|
+
action: "click->shadcn-phlexcomponents--sidebar-trigger#toggle",
|
24
|
+
},
|
25
|
+
}
|
26
26
|
end
|
27
27
|
|
28
28
|
def view_template(&)
|
@@ -37,4 +37,4 @@ module ShadcnPhlexcomponents
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end
|
40
|
+
end
|
data/lib/components/skeleton.rb
CHANGED
data/lib/components/switch.rb
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Switch < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full
|
7
|
-
border-2 border-transparent transition-colors focus-visible:outline-none
|
7
|
+
border-2 border-transparent transition-colors focus-visible:outline-none#{" "}
|
8
8
|
focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
9
9
|
focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50
|
10
10
|
data-[checked=true]:bg-primary data-[checked=false]:bg-input group/switch
|
11
11
|
HEREDOC
|
12
12
|
|
13
|
-
def initialize(name: nil, value: "1", unchecked_value: "0", checked: false, id: nil, include_hidden: true,
|
13
|
+
def initialize(name: nil, value: "1", unchecked_value: "0", checked: false, id: nil, include_hidden: true,
|
14
|
+
**attributes)
|
14
15
|
@name = name
|
15
16
|
@value = value
|
16
17
|
@unchecked_value = unchecked_value
|
@@ -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--switch-target": "input"
|
43
|
-
}
|
43
|
+
"shadcn-phlexcomponents--switch-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: "switch",
|
@@ -58,8 +59,8 @@ module ShadcnPhlexcomponents
|
|
58
59
|
controller: "shadcn-phlexcomponents--switch",
|
59
60
|
action: "click->shadcn-phlexcomponents--switch#toggle",
|
60
61
|
"shadcn-phlexcomponents--switch-checked-value": @checked,
|
61
|
-
}
|
62
|
+
},
|
62
63
|
}
|
63
64
|
end
|
64
65
|
end
|
65
|
-
end
|
66
|
+
end
|
data/lib/components/table.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Table < Base
|
5
|
-
STYLES = "w-full caption-bottom text-sm"
|
5
|
+
STYLES = "w-full caption-bottom text-sm"
|
6
6
|
|
7
|
-
def initialize(
|
7
|
+
def initialize(**attributes)
|
8
8
|
@columns = []
|
9
9
|
super(**attributes)
|
10
10
|
end
|
@@ -15,7 +15,7 @@ module ShadcnPhlexcomponents
|
|
15
15
|
|
16
16
|
def header(**attributes, &)
|
17
17
|
TableHeader(**attributes, &)
|
18
|
-
end
|
18
|
+
end
|
19
19
|
|
20
20
|
def caption(**attributes, &)
|
21
21
|
TableCaption(**attributes, &)
|
@@ -58,7 +58,9 @@ module ShadcnPhlexcomponents
|
|
58
58
|
@rows.each do |row|
|
59
59
|
tr(class: TableRow::STYLES) do
|
60
60
|
@columns.each do |column|
|
61
|
-
td(class: TAILWIND_MERGER.merge("#{TableCell::STYLES} #{column[:cell_class]}"))
|
61
|
+
td(class: TAILWIND_MERGER.merge("#{TableCell::STYLES} #{column[:cell_class]}")) do
|
62
|
+
column[:content].call(row)
|
63
|
+
end
|
62
64
|
end
|
63
65
|
end
|
64
66
|
end
|
@@ -70,4 +72,4 @@ module ShadcnPhlexcomponents
|
|
70
72
|
nil
|
71
73
|
end
|
72
74
|
end
|
73
|
-
end
|
75
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TableCell < Base
|
5
|
-
STYLES = "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]"
|
5
|
+
STYLES = "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]"
|
6
6
|
|
7
7
|
def view_template(&)
|
8
8
|
td(**@attributes, &)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TableFooter < Base
|
5
|
-
STYLES = "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0"
|
5
|
+
STYLES = "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0"
|
6
6
|
|
7
7
|
def view_template(&)
|
8
8
|
tfoot(**@attributes, &)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -4,11 +4,11 @@ module ShadcnPhlexcomponents
|
|
4
4
|
class TableHead < Base
|
5
5
|
STYLES = <<~HEREDOC
|
6
6
|
h-10 px-2 text-left align-middle font-medium text-muted-foreground
|
7
|
-
[&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]
|
7
|
+
[&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]#{" "}
|
8
8
|
HEREDOC
|
9
|
-
|
9
|
+
|
10
10
|
def view_template(&)
|
11
11
|
th(**@attributes, &)
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
data/lib/components/table_row.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TableRow < Base
|
5
|
-
STYLES = "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
|
5
|
+
STYLES = "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
|
6
6
|
|
7
7
|
def view_template(&)
|
8
8
|
tr(**@attributes, &)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
data/lib/components/tabs.rb
CHANGED
@@ -18,8 +18,8 @@ module ShadcnPhlexcomponents
|
|
18
18
|
dir: @dir,
|
19
19
|
data: {
|
20
20
|
controller: "shadcn-phlexcomponents--tabs",
|
21
|
-
"shadcn-phlexcomponents--tabs-selected-value": @value
|
22
|
-
}
|
21
|
+
"shadcn-phlexcomponents--tabs-selected-value": @value,
|
22
|
+
},
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
@@ -35,4 +35,4 @@ module ShadcnPhlexcomponents
|
|
35
35
|
TabsContent(aria_id: @aria_id, **attributes, &)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TabsContent < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2
|
7
7
|
focus-visible:ring-ring focus-visible:ring-offset-2 hidden
|
8
8
|
HEREDOC
|
@@ -23,13 +23,13 @@ module ShadcnPhlexcomponents
|
|
23
23
|
role: "tabpanel",
|
24
24
|
tabindex: "0",
|
25
25
|
aria: {
|
26
|
-
labelledby: "#{@aria_id}-trigger-#{@value}"
|
26
|
+
labelledby: "#{@aria_id}-trigger-#{@value}",
|
27
27
|
},
|
28
28
|
data: {
|
29
29
|
value: @value,
|
30
|
-
"shadcn-phlexcomponents--tabs-target": "content"
|
31
|
-
}
|
30
|
+
"shadcn-phlexcomponents--tabs-target": "content",
|
31
|
+
},
|
32
32
|
}
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/lib/components/tabs_list.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TabsList < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground outline-none
|
7
7
|
HEREDOC
|
8
8
|
|
@@ -15,9 +15,9 @@ module ShadcnPhlexcomponents
|
|
15
15
|
role: "tablist",
|
16
16
|
tabindex: "-1",
|
17
17
|
aria: {
|
18
|
-
orientation: "horizontal"
|
19
|
-
}
|
18
|
+
orientation: "horizontal",
|
19
|
+
},
|
20
20
|
}
|
21
21
|
end
|
22
22
|
end
|
23
|
-
end
|
23
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TabsTrigger < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm
|
7
7
|
font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2
|
8
8
|
focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
|
@@ -38,8 +38,8 @@ module ShadcnPhlexcomponents
|
|
38
38
|
keydown.left->shadcn-phlexcomponents--tabs#setActiveToPrev:prevent
|
39
39
|
keydown.right->shadcn-phlexcomponents--tabs#setActiveToNext:prevent
|
40
40
|
HEREDOC
|
41
|
-
}
|
41
|
+
},
|
42
42
|
}
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
data/lib/components/textarea.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class ThemeSwitcher < Base
|
5
5
|
def view_template
|
6
|
-
Button(variant: :ghost, size: :icon, **@attributes)do
|
6
|
+
Button(variant: :ghost, size: :icon, **@attributes) do
|
7
7
|
icon("sun", class: "hidden dark:inline")
|
8
8
|
icon("moon", class: "inline dark:hidden")
|
9
9
|
end
|
@@ -18,4 +18,4 @@ module ShadcnPhlexcomponents
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
data/lib/components/toast.rb
CHANGED
@@ -5,7 +5,7 @@ module ShadcnPhlexcomponents
|
|
5
5
|
STYLES = <<~HEREDOC
|
6
6
|
group pointer-events-auto relative flex w-full items-center justify-between
|
7
7
|
space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all
|
8
|
-
data-[state=open]:animate-in data-[state=closed]:animate-out
|
8
|
+
data-[state=open]:animate-in data-[state=closed]:animate-out#{" "}
|
9
9
|
data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full
|
10
10
|
data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full
|
11
11
|
HEREDOC
|
@@ -29,11 +29,11 @@ module ShadcnPhlexcomponents
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def title(**attributes, &)
|
32
|
-
ToastTitle(data: { title: ""}, **attributes, &)
|
32
|
+
ToastTitle(data: { title: "" }, **attributes, &)
|
33
33
|
end
|
34
34
|
|
35
35
|
def description(**attributes, &)
|
36
|
-
ToastDescription(data: { description: ""}
|
36
|
+
ToastDescription(data: { description: "" }, **attributes, &)
|
37
37
|
end
|
38
38
|
|
39
39
|
def content(**attributes, &)
|
@@ -52,7 +52,7 @@ module ShadcnPhlexcomponents
|
|
52
52
|
html_options ||= {}
|
53
53
|
html_options[:variant] = @variant
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
ToastActionTo(name, options, html_options, &block)
|
57
57
|
end
|
58
58
|
|
@@ -72,29 +72,30 @@ module ShadcnPhlexcomponents
|
|
72
72
|
duration: @duration,
|
73
73
|
state: "open",
|
74
74
|
controller: "shadcn-phlexcomponents--toast",
|
75
|
-
action: <<~HEREDOC
|
75
|
+
action: <<~HEREDOC,
|
76
76
|
focus->shadcn-phlexcomponents--toast#cancelDismiss
|
77
77
|
blur->shadcn-phlexcomponents--toast#dismiss
|
78
78
|
mouseover->shadcn-phlexcomponents--toast#cancelDismiss
|
79
79
|
mouseout->shadcn-phlexcomponents--toast#dismiss
|
80
80
|
keydown.esc->shadcn-phlexcomponents--toast#close
|
81
81
|
HEREDOC
|
82
|
-
}
|
83
|
-
}
|
82
|
+
},
|
83
|
+
}
|
84
84
|
end
|
85
85
|
|
86
86
|
def view_template(&)
|
87
87
|
li(**@attributes) do
|
88
88
|
yield
|
89
|
-
button(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
button(
|
90
|
+
type: "button",
|
91
|
+
class: CLOSE_BUTTON_STYLES,
|
92
|
+
data: {
|
93
|
+
action: "shadcn-phlexcomponents--toast#close",
|
94
|
+
},
|
95
|
+
) do
|
95
96
|
icon("x", class: "size-4")
|
96
97
|
end
|
97
98
|
end
|
98
99
|
end
|
99
100
|
end
|
100
|
-
end
|
101
|
+
end
|
@@ -15,7 +15,7 @@ module ShadcnPhlexcomponents
|
|
15
15
|
@as_child = as_child
|
16
16
|
super(**attributes)
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def view_template(&)
|
20
20
|
if @as_child
|
21
21
|
content = capture(&)
|
@@ -24,10 +24,11 @@ module ShadcnPhlexcomponents
|
|
24
24
|
vanish(&)
|
25
25
|
|
26
26
|
element_attributes = nokogiri_attributes_to_hash(element)
|
27
|
+
styles = TAILWIND_MERGER.merge("#{@attributes[:class]} #{element_attributes[:class]}")
|
27
28
|
merged_attributes = mix(@attributes, element_attributes)
|
28
|
-
merged_attributes[:class] =
|
29
|
+
merged_attributes[:class] = styles
|
29
30
|
|
30
|
-
send(element.name, **merged_attributes) do
|
31
|
+
send(element.name, **merged_attributes) do
|
31
32
|
sanitize_as_child(element.children.to_s)
|
32
33
|
end
|
33
34
|
else
|
@@ -35,4 +36,4 @@ module ShadcnPhlexcomponents
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
38
|
-
end
|
39
|
+
end
|
@@ -9,7 +9,10 @@ module ShadcnPhlexcomponents
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def view_template(&)
|
12
|
-
|
12
|
+
if block_given?
|
13
|
+
@html_options = @options
|
14
|
+
@options = @name
|
15
|
+
end
|
13
16
|
@html_options ||= {}
|
14
17
|
@variant = @html_options.delete(:variant) || :default
|
15
18
|
@html_options = mix(default_attributes, @html_options)
|
@@ -22,4 +25,4 @@ module ShadcnPhlexcomponents
|
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
25
|
-
end
|
28
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module ShadcnPhlexcomponents
|
3
|
+
module ShadcnPhlexcomponents
|
4
4
|
class ToastContainer < Base
|
5
5
|
STYLES = <<~HEREDOC
|
6
6
|
fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4
|
@@ -12,17 +12,17 @@ module ShadcnPhlexcomponents
|
|
12
12
|
tabindex: -1,
|
13
13
|
data: {
|
14
14
|
controller: "shadcn-phlexcomponents--toast-container",
|
15
|
-
}
|
15
|
+
},
|
16
16
|
}
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def view_template(&)
|
20
20
|
div(
|
21
21
|
role: "region",
|
22
22
|
tabindex: -1,
|
23
23
|
aria: {
|
24
24
|
label: "Notifications",
|
25
|
-
}
|
25
|
+
},
|
26
26
|
) do
|
27
27
|
ol(**@attributes) do
|
28
28
|
template(data: { variant: "default" }) { toast(:default) }
|
@@ -41,4 +41,4 @@ module ShadcnPhlexcomponents
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
-
end
|
44
|
+
end
|
data/lib/components/tooltip.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Tooltip < Base
|
5
|
-
STYLES = "inline-block"
|
5
|
+
STYLES = "inline-block"
|
6
6
|
|
7
7
|
def initialize(side: :top, aria_id: "tooltip-#{SecureRandom.hex(5)}", **attributes)
|
8
8
|
@side = side
|
@@ -11,24 +11,24 @@ module ShadcnPhlexcomponents
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def trigger(**attributes, &)
|
14
|
-
render
|
14
|
+
render(TooltipTrigger.new(aria_id: @aria_id, **attributes, &))
|
15
15
|
end
|
16
16
|
|
17
17
|
def content(**attributes, &)
|
18
|
-
render
|
19
|
-
end
|
18
|
+
render(TooltipContent.new(side: @side, aria_id: @aria_id, **attributes, &))
|
19
|
+
end
|
20
20
|
|
21
21
|
def default_attributes
|
22
22
|
{
|
23
23
|
data: {
|
24
24
|
controller: "shadcn-phlexcomponents--tooltip",
|
25
|
-
side: @side
|
26
|
-
}
|
27
|
-
}
|
25
|
+
side: @side,
|
26
|
+
},
|
27
|
+
}
|
28
28
|
end
|
29
29
|
|
30
30
|
def view_template(&)
|
31
31
|
div(**@attributes, &)
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class TooltipContent < Base
|
5
|
-
STYLES = <<~HEREDOC
|
6
|
-
|
7
|
-
animate-in fade-in-0 zoom-in-95
|
8
|
-
data-[
|
5
|
+
STYLES = <<~HEREDOC
|
6
|
+
overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground
|
7
|
+
animate-in fade-in-0 zoom-in-95
|
8
|
+
data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
|
9
9
|
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2
|
10
10
|
HEREDOC
|
11
11
|
|
@@ -16,11 +16,11 @@ module ShadcnPhlexcomponents
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def view_template(&)
|
19
|
-
div(class:
|
19
|
+
div(class: "hidden", data: { "shadcn-phlexcomponents--tooltip-target": "content" }) do
|
20
20
|
div(**@attributes, &)
|
21
21
|
|
22
22
|
span(
|
23
|
-
id: "#{@aria_id}-content",
|
23
|
+
id: "#{@aria_id}-content",
|
24
24
|
role: "tooltip",
|
25
25
|
class: "sr-only",
|
26
26
|
&
|
@@ -30,13 +30,10 @@ module ShadcnPhlexcomponents
|
|
30
30
|
|
31
31
|
def default_attributes
|
32
32
|
{
|
33
|
-
tabindex: -1,
|
34
33
|
data: {
|
35
34
|
side: @side,
|
36
|
-
|
37
|
-
action: "mouseover->shadcn-phlexcomponents--tooltip#clearCloseTimer mouseout->shadcn-phlexcomponents--tooltip#closeWithDelay"
|
38
|
-
}
|
35
|
+
},
|
39
36
|
}
|
40
37
|
end
|
41
38
|
end
|
42
|
-
end
|
39
|
+
end
|