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
data/lib/components/select.rb
CHANGED
@@ -2,29 +2,29 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Select < Base
|
5
|
-
STYLES = "w-full"
|
6
|
-
|
7
|
-
NATIVE_STYLES = <<~HEREDOC
|
5
|
+
STYLES = "w-full"
|
6
|
+
|
7
|
+
NATIVE_STYLES = <<~HEREDOC
|
8
8
|
flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-2 pr-8
|
9
9
|
text-base shadow-sm transition-colors placeholder:text-muted-foreground
|
10
10
|
focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
|
11
11
|
disabled:cursor-not-allowed disabled:opacity-50 md:text-sm appearance-none
|
12
|
-
relative
|
12
|
+
relative#{" "}
|
13
13
|
HEREDOC
|
14
|
-
|
15
|
-
NATIVE_OPTION_STYLES = "bg-popover text-popover-foreground"
|
14
|
+
|
15
|
+
NATIVE_OPTION_STYLES = "bg-popover text-popover-foreground"
|
16
16
|
|
17
17
|
def initialize(id: nil,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
name: nil,
|
19
|
+
value: nil,
|
20
|
+
placeholder: nil,
|
21
|
+
side: :bottom,
|
22
|
+
native: false,
|
23
|
+
dir: "ltr",
|
24
|
+
include_blank: false,
|
25
|
+
disabled: false,
|
26
|
+
aria_id: "select-#{SecureRandom.hex(5)}",
|
27
|
+
**attributes)
|
28
28
|
@id = id || name
|
29
29
|
@name = name
|
30
30
|
@value = value
|
@@ -37,43 +37,47 @@ module ShadcnPhlexcomponents
|
|
37
37
|
@aria_id = aria_id
|
38
38
|
super(**attributes)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def trigger(**attributes)
|
42
42
|
SelectTrigger(
|
43
|
-
id: @id,
|
44
|
-
aria_id: @aria_id,
|
45
|
-
dir: @dir,
|
46
|
-
value: @value,
|
47
|
-
placeholder: @placeholder,
|
43
|
+
id: @id,
|
44
|
+
aria_id: @aria_id,
|
45
|
+
dir: @dir,
|
46
|
+
value: @value,
|
47
|
+
placeholder: @placeholder,
|
48
48
|
disabled: @disabled,
|
49
|
-
**attributes
|
50
|
-
|
49
|
+
**attributes,
|
50
|
+
)
|
51
|
+
end
|
51
52
|
|
52
53
|
def content(**attributes, &)
|
53
|
-
SelectContent(
|
54
|
-
|
54
|
+
SelectContent(
|
55
|
+
side: @side, aria_id: @aria_id, dir: @dir, include_blank: @include_blank, native: @native, **attributes, &
|
56
|
+
)
|
57
|
+
end
|
55
58
|
|
56
59
|
def item(**attributes, &)
|
57
60
|
SelectItem(aria_id: @aria_id, **attributes, &)
|
58
|
-
end
|
61
|
+
end
|
59
62
|
|
60
63
|
def label(**attributes, &)
|
61
64
|
SelectLabel(aria_id: @aria_id, **attributes, &)
|
62
|
-
end
|
65
|
+
end
|
63
66
|
|
64
67
|
def group(**attributes, &)
|
65
68
|
SelectGroup(aria_id: @aria_id, **attributes, &)
|
66
|
-
end
|
67
|
-
|
69
|
+
end
|
70
|
+
|
68
71
|
def items(collection)
|
69
72
|
SelectTrigger(
|
70
|
-
id: @id,
|
71
|
-
aria_id: @aria_id,
|
72
|
-
dir: @dir,
|
73
|
-
value: @value,
|
74
|
-
placeholder: @placeholder,
|
75
|
-
disabled: @disabled
|
76
|
-
|
73
|
+
id: @id,
|
74
|
+
aria_id: @aria_id,
|
75
|
+
dir: @dir,
|
76
|
+
value: @value,
|
77
|
+
placeholder: @placeholder,
|
78
|
+
disabled: @disabled,
|
79
|
+
)
|
80
|
+
|
77
81
|
SelectContent(aria_id: @aria_id, dir: @dir, include_blank: @include_blank, native: @native) do
|
78
82
|
collection.each do |option|
|
79
83
|
SelectItem(value: option[:value], aria_id: @aria_id, disabled: option[:disabled]) { option[:name] }
|
@@ -85,7 +89,7 @@ module ShadcnPhlexcomponents
|
|
85
89
|
content = capture(&)
|
86
90
|
element = Nokogiri::HTML.fragment(content.to_s)
|
87
91
|
content_element = element.css('[data-shadcn-phlexcomponents--select-target="content"]')
|
88
|
-
|
92
|
+
|
89
93
|
if @native
|
90
94
|
div(class: "relative") do
|
91
95
|
select(**@attributes) do
|
@@ -105,21 +109,10 @@ module ShadcnPhlexcomponents
|
|
105
109
|
select(
|
106
110
|
name: @name,
|
107
111
|
disabled: @disabled,
|
108
|
-
|
109
|
-
position: 'absolute',
|
110
|
-
border: '0px',
|
111
|
-
width: '1px',
|
112
|
-
height: '1px',
|
113
|
-
padding: '0px',
|
114
|
-
margin: '-1px',
|
115
|
-
overflow: 'hidden',
|
116
|
-
clip: 'rect(0px, 0px, 0px, 0px)',
|
117
|
-
'white-space': 'nowrap',
|
118
|
-
'overflow-wrap': 'normal'
|
119
|
-
},
|
112
|
+
class: "sr-only",
|
120
113
|
data: {
|
121
|
-
"shadcn-phlexcomponents--select-target": "select"
|
122
|
-
}
|
114
|
+
"shadcn-phlexcomponents--select-target": "select",
|
115
|
+
},
|
123
116
|
) do
|
124
117
|
option(value: "")
|
125
118
|
build_native_options(content_element)
|
@@ -136,13 +129,12 @@ module ShadcnPhlexcomponents
|
|
136
129
|
end
|
137
130
|
end
|
138
131
|
|
139
|
-
|
140
132
|
def default_attributes
|
141
|
-
if @native
|
142
|
-
{
|
143
|
-
id: @id,
|
144
|
-
name
|
145
|
-
disabled: @disabled
|
133
|
+
if @native
|
134
|
+
{
|
135
|
+
id: @id,
|
136
|
+
name: @name,
|
137
|
+
disabled: @disabled,
|
146
138
|
}
|
147
139
|
else
|
148
140
|
{
|
@@ -150,8 +142,8 @@ module ShadcnPhlexcomponents
|
|
150
142
|
side: @side,
|
151
143
|
aria_id: @aria_id,
|
152
144
|
controller: "shadcn-phlexcomponents--select",
|
153
|
-
"shadcn-phlexcomponents--select-selected-value": @value
|
154
|
-
}
|
145
|
+
"shadcn-phlexcomponents--select-selected-value": @value,
|
146
|
+
},
|
155
147
|
}
|
156
148
|
end
|
157
149
|
end
|
@@ -160,30 +152,33 @@ module ShadcnPhlexcomponents
|
|
160
152
|
content_element.children.each do |content_child|
|
161
153
|
next if content_child.is_a?(Nokogiri::XML::Text) || content_child.is_a?(Nokogiri::XML::Comment)
|
162
154
|
|
163
|
-
if content_child.attributes[
|
155
|
+
if content_child.attributes["data-shadcn-phlexcomponents--select-target"]&.value == "group"
|
164
156
|
group_label = content_child.at_css('[data-shadcn-phlexcomponents--select-target="label"]')&.text
|
165
157
|
|
166
|
-
optgroup(label: group_label, class: NATIVE_OPTION_STYLES) do
|
158
|
+
optgroup(label: group_label, class: NATIVE_OPTION_STYLES) do
|
167
159
|
content_child.css('[data-shadcn-phlexcomponents--select-target="item"]').each do |i|
|
168
160
|
option(
|
169
|
-
value: i.attributes[
|
161
|
+
value: i.attributes["data-value"].value,
|
170
162
|
class: NATIVE_OPTION_STYLES,
|
171
|
-
selected: i.attributes[
|
172
|
-
disabled: i.attributes[
|
173
|
-
|
163
|
+
selected: i.attributes["data-value"].value == @value,
|
164
|
+
disabled: i.attributes["data-disabled"]&.value == "",
|
165
|
+
) do
|
166
|
+
i.text
|
174
167
|
end
|
175
168
|
end
|
176
169
|
end
|
177
|
-
elsif content_child.attributes[
|
170
|
+
elsif content_child.attributes["data-shadcn-phlexcomponents--select-target"]&.value == "item"
|
178
171
|
|
179
|
-
option(
|
180
|
-
|
181
|
-
|
182
|
-
|
172
|
+
option(
|
173
|
+
value: content_child.attributes["data-value"].value,
|
174
|
+
class: NATIVE_OPTION_STYLES,
|
175
|
+
selected: content_child.attributes["data-value"].value == @value,
|
176
|
+
disabled: content_child.attributes["data-disabled"]&.value == "",
|
177
|
+
) do
|
183
178
|
content_child.text
|
184
179
|
end
|
185
180
|
end
|
186
181
|
end
|
187
182
|
end
|
188
183
|
end
|
189
|
-
end
|
184
|
+
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SelectContent < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
relative z-50 min-w-[8rem] max-h-108 overflow-y-auto overflow-x-hidden rounded-md border
|
7
7
|
bg-popover text-popover-foreground p-1 shadow-md outline-none
|
8
8
|
data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0
|
9
9
|
data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95
|
10
10
|
data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2
|
11
11
|
data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2
|
12
|
-
data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1
|
12
|
+
data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1#{" "}
|
13
13
|
data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1
|
14
14
|
HEREDOC
|
15
15
|
|
@@ -23,10 +23,15 @@ module ShadcnPhlexcomponents
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def view_template(&)
|
26
|
-
div(
|
26
|
+
div(
|
27
|
+
class: "hidden fixed top-0 left-0 w-max z-50",
|
28
|
+
data: { "shadcn-phlexcomponents--select-target": "contentWrapper" },
|
29
|
+
) do
|
27
30
|
div(**@attributes) do
|
28
31
|
if @include_blank && !@native
|
29
|
-
SelectItem(aria_id: @aria_id, value: "", class: "h-8", hide_icon: true)
|
32
|
+
SelectItem(aria_id: @aria_id, value: "", class: "h-8", hide_icon: true) do
|
33
|
+
@include_blank.is_a?(String) ? @include_blank : ""
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
yield
|
@@ -42,7 +47,7 @@ module ShadcnPhlexcomponents
|
|
42
47
|
role: "listbox",
|
43
48
|
aria: {
|
44
49
|
labelledby: "#{@aria_id}-trigger",
|
45
|
-
orientation: "vertical"
|
50
|
+
orientation: "vertical",
|
46
51
|
},
|
47
52
|
data: {
|
48
53
|
state: "closed",
|
@@ -52,8 +57,8 @@ module ShadcnPhlexcomponents
|
|
52
57
|
keydown.up->shadcn-phlexcomponents--select#focusLastItem:prevent
|
53
58
|
keydown.down->shadcn-phlexcomponents--select#focusFirstItem:prevent
|
54
59
|
HEREDOC
|
55
|
-
}
|
60
|
+
},
|
56
61
|
}
|
57
62
|
end
|
58
63
|
end
|
59
|
-
end
|
64
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SelectItem < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
group/item relative flex w-full cursor-default select-none items-center
|
7
7
|
rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent
|
8
|
-
focus:text-accent-foreground data-[disabled]:pointer-events-none
|
8
|
+
focus:text-accent-foreground data-[disabled]:pointer-events-none#{" "}
|
9
9
|
data-[disabled]:opacity-50
|
10
10
|
HEREDOC
|
11
11
|
|
@@ -21,9 +21,10 @@ module ShadcnPhlexcomponents
|
|
21
21
|
def view_template(&)
|
22
22
|
div(**@attributes) do
|
23
23
|
span(id: @aria_labelledby, &)
|
24
|
-
|
24
|
+
|
25
25
|
unless @hide_icon
|
26
|
-
span(class: "absolute right-2 h-3.5 w-3.5 items-center hidden justify-center
|
26
|
+
span(class: "absolute right-2 h-3.5 w-3.5 items-center hidden justify-center
|
27
|
+
group-aria-[selected=true]/item:flex") do
|
27
28
|
icon("check", class: "size-4")
|
28
29
|
end
|
29
30
|
end
|
@@ -36,7 +37,7 @@ module ShadcnPhlexcomponents
|
|
36
37
|
tabindex: -1,
|
37
38
|
aria: {
|
38
39
|
selected: false,
|
39
|
-
labelledby: @aria_labelledby
|
40
|
+
labelledby: @aria_labelledby,
|
40
41
|
},
|
41
42
|
data: {
|
42
43
|
disabled: @disabled,
|
@@ -50,9 +51,9 @@ module ShadcnPhlexcomponents
|
|
50
51
|
mouseover->shadcn-phlexcomponents--select#focusItem
|
51
52
|
mouseout->shadcn-phlexcomponents--select#focusContent
|
52
53
|
HEREDOC
|
53
|
-
"shadcn-phlexcomponents--select-target": "item"
|
54
|
-
}
|
54
|
+
"shadcn-phlexcomponents--select-target": "item",
|
55
|
+
},
|
55
56
|
}
|
56
57
|
end
|
57
58
|
end
|
58
|
-
end
|
59
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module ShadcnPhlexcomponents
|
3
4
|
class SelectLabel < Base
|
4
|
-
STYLES = "px-2 py-1.5 text-sm font-semibold"
|
5
|
+
STYLES = "px-2 py-1.5 text-sm font-semibold"
|
5
6
|
|
6
7
|
def initialize(aria_id: nil, **attributes)
|
7
8
|
@aria_id = aria_id
|
8
9
|
super(**attributes)
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
def view_template(&)
|
12
13
|
div(**@attributes, &)
|
13
14
|
end
|
@@ -15,9 +16,9 @@ module ShadcnPhlexcomponents
|
|
15
16
|
def default_attributes
|
16
17
|
{
|
17
18
|
data: {
|
18
|
-
"shadcn-phlexcomponents--select-target": "label"
|
19
|
-
}
|
19
|
+
"shadcn-phlexcomponents--select-target": "label",
|
20
|
+
},
|
20
21
|
}
|
21
22
|
end
|
22
23
|
end
|
23
|
-
end
|
24
|
+
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SelectTrigger < Base
|
5
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
6
6
|
flex h-9 items-center justify-between whitespace-nowrap rounded-md border
|
7
|
-
border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background
|
7
|
+
border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background#{" "}
|
8
8
|
data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1
|
9
9
|
focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1
|
10
10
|
w-full cursor-pointer
|
@@ -21,7 +21,9 @@ module ShadcnPhlexcomponents
|
|
21
21
|
|
22
22
|
def view_template
|
23
23
|
button(**@attributes) do
|
24
|
-
span(class: "pointer-events-none", data: { "shadcn-phlexcomponents--select-target": "triggerText" })
|
24
|
+
span(class: "pointer-events-none", data: { "shadcn-phlexcomponents--select-target": "triggerText" }) do
|
25
|
+
@value || @placeholder
|
26
|
+
end
|
25
27
|
|
26
28
|
icon("chevron-down", class: "size-4 opacity-50")
|
27
29
|
end
|
@@ -36,19 +38,19 @@ module ShadcnPhlexcomponents
|
|
36
38
|
aria: {
|
37
39
|
autocomplete: "none",
|
38
40
|
expanded: false,
|
39
|
-
controls: "#{@aria_id}-content"
|
41
|
+
controls: "#{@aria_id}-content",
|
40
42
|
},
|
41
43
|
data: {
|
42
44
|
placeholder: @placeholder.present?,
|
43
45
|
placeholder_text: @placeholder,
|
44
46
|
action: <<~HEREDOC,
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
click->shadcn-phlexcomponents--select#toggle
|
48
|
+
keydown.down->shadcn-phlexcomponents--select#toggle:prevent
|
49
|
+
keydown.up->shadcn-phlexcomponents--select#toggle:prevent
|
48
50
|
HEREDOC
|
49
|
-
"shadcn-phlexcomponents--select-target": "trigger"
|
50
|
-
}
|
51
|
+
"shadcn-phlexcomponents--select-target": "trigger",
|
52
|
+
},
|
51
53
|
}
|
52
54
|
end
|
53
55
|
end
|
54
|
-
end
|
56
|
+
end
|
data/lib/components/separator.rb
CHANGED
@@ -13,12 +13,12 @@ module ShadcnPhlexcomponents
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def default_styles
|
16
|
-
|
16
|
+
ORIENTATIONS[@orientation].to_s
|
17
17
|
end
|
18
18
|
|
19
19
|
def default_attributes
|
20
20
|
{
|
21
|
-
role: "none"
|
21
|
+
role: "none",
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
@@ -26,4 +26,4 @@ module ShadcnPhlexcomponents
|
|
26
26
|
div(**@attributes)
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/lib/components/sheet.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class Sheet < Base
|
5
|
-
STYLES = "inline-block"
|
5
|
+
STYLES = "inline-block"
|
6
6
|
|
7
7
|
def initialize(side: :right, aria_id: "sheet-#{SecureRandom.hex(5)}", **attributes)
|
8
8
|
@side = side
|
@@ -15,7 +15,7 @@ module ShadcnPhlexcomponents
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def content(**attributes, &)
|
18
|
-
|
18
|
+
SheetContent(side: @side, aria_id: @aria_id, **attributes, &)
|
19
19
|
end
|
20
20
|
|
21
21
|
def header(**attributes, &)
|
@@ -23,19 +23,19 @@ module ShadcnPhlexcomponents
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def title(**attributes, &)
|
26
|
-
|
26
|
+
SheetTitle(aria_id: @aria_id, **attributes, &)
|
27
27
|
end
|
28
28
|
|
29
29
|
def description(**attributes, &)
|
30
|
-
|
30
|
+
SheetDescription(aria_id: @aria_id, **attributes, &)
|
31
31
|
end
|
32
32
|
|
33
33
|
def footer(**attributes, &)
|
34
|
-
|
34
|
+
SheetFooter(**attributes, &)
|
35
35
|
end
|
36
36
|
|
37
37
|
def close(**attributes, &)
|
38
|
-
|
38
|
+
SheetClose(**attributes, &)
|
39
39
|
end
|
40
40
|
|
41
41
|
def view_template(&)
|
@@ -45,9 +45,9 @@ module ShadcnPhlexcomponents
|
|
45
45
|
def default_attributes
|
46
46
|
{
|
47
47
|
data: {
|
48
|
-
controller: "shadcn-phlexcomponents--sheet"
|
49
|
-
}
|
48
|
+
controller: "shadcn-phlexcomponents--sheet",
|
49
|
+
},
|
50
50
|
}
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -22,7 +22,7 @@ module ShadcnPhlexcomponents
|
|
22
22
|
merged_attributes.delete(:role)
|
23
23
|
end
|
24
24
|
|
25
|
-
send(element.name, **merged_attributes) do
|
25
|
+
send(element.name, **merged_attributes) do
|
26
26
|
sanitize_as_child(element.children.to_s)
|
27
27
|
end
|
28
28
|
else
|
@@ -34,9 +34,9 @@ module ShadcnPhlexcomponents
|
|
34
34
|
{
|
35
35
|
role: "button",
|
36
36
|
data: {
|
37
|
-
action: "click->shadcn-phlexcomponents--sheet#close"
|
38
|
-
}
|
37
|
+
action: "click->shadcn-phlexcomponents--sheet#close",
|
38
|
+
},
|
39
39
|
}
|
40
40
|
end
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
|
-
|
5
4
|
class SheetContent < Base
|
6
|
-
STYLES = <<~HEREDOC
|
5
|
+
STYLES = <<~HEREDOC
|
7
6
|
fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out
|
8
7
|
data-[state=closed]:duration-300 data-[state=open]:duration-500
|
9
8
|
data-[state=open]:animate-in data-[state=closed]:animate-out
|
10
9
|
HEREDOC
|
11
10
|
|
12
|
-
CLOSE_BUTTON_STYLES = <<~HEREDOC
|
11
|
+
CLOSE_BUTTON_STYLES = <<~HEREDOC
|
13
12
|
absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background
|
14
13
|
transition-opacity hover:opacity-100 focus:outline-none focus:ring-2
|
15
14
|
focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none
|
@@ -17,16 +16,15 @@ module ShadcnPhlexcomponents
|
|
17
16
|
HEREDOC
|
18
17
|
|
19
18
|
SIDES = {
|
20
|
-
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left
|
21
|
-
|
19
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left
|
20
|
+
data-[state=open]:slide-in-from-left sm:max-w-sm",
|
21
|
+
right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right
|
22
|
+
data-[state=open]:slide-in-from-right sm:max-w-sm",
|
22
23
|
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
23
|
-
bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom
|
24
|
+
bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom
|
25
|
+
data-[state=open]:slide-in-from-bottom",
|
24
26
|
}
|
25
27
|
|
26
|
-
def self.default_styles(side)
|
27
|
-
"#{STYLES} #{SIDES[side]}"
|
28
|
-
end
|
29
|
-
|
30
28
|
def initialize(side: :right, aria_id: nil, **attributes)
|
31
29
|
@side = side
|
32
30
|
@aria_id = aria_id
|
@@ -44,7 +42,7 @@ module ShadcnPhlexcomponents
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
47
|
-
|
45
|
+
|
48
46
|
def default_attributes
|
49
47
|
{
|
50
48
|
id: "#{@aria_id}-content",
|
@@ -55,13 +53,13 @@ module ShadcnPhlexcomponents
|
|
55
53
|
labelledby: "#{@aria_id}-title",
|
56
54
|
},
|
57
55
|
data: {
|
58
|
-
"shadcn-phlexcomponents--sheet-target": "content"
|
59
|
-
}
|
56
|
+
"shadcn-phlexcomponents--sheet-target": "content",
|
57
|
+
},
|
60
58
|
}
|
61
59
|
end
|
62
60
|
|
63
61
|
def default_styles
|
64
|
-
|
62
|
+
"#{STYLES} #{SIDES[@side]}"
|
65
63
|
end
|
66
64
|
end
|
67
|
-
end
|
65
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SheetDescription < Base
|
5
|
-
STYLES = "text-sm text-muted-foreground"
|
5
|
+
STYLES = "text-sm text-muted-foreground"
|
6
6
|
|
7
7
|
def initialize(aria_id: nil, **attributes)
|
8
8
|
@aria_id = aria_id
|
@@ -11,7 +11,7 @@ module ShadcnPhlexcomponents
|
|
11
11
|
|
12
12
|
def default_attributes
|
13
13
|
{
|
14
|
-
id: "#{@aria_id}-description"
|
14
|
+
id: "#{@aria_id}-description",
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
@@ -19,4 +19,4 @@ module ShadcnPhlexcomponents
|
|
19
19
|
p(**@attributes, &)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SheetFooter < Base
|
5
|
-
STYLES = "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"
|
5
|
+
STYLES = "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"
|
6
6
|
|
7
7
|
def view_template(&)
|
8
8
|
div(**@attributes, &)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SheetHeader < Base
|
5
|
-
STYLES = "flex flex-col space-y-2 text-center sm:text-left"
|
5
|
+
STYLES = "flex flex-col space-y-2 text-center sm:text-left"
|
6
6
|
|
7
7
|
def view_template(&)
|
8
8
|
div(**@attributes, &)
|
9
9
|
end
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents
|
4
4
|
class SheetTitle < Base
|
5
|
-
STYLES = "text-lg font-semibold text-foreground"
|
5
|
+
STYLES = "text-lg font-semibold text-foreground"
|
6
6
|
|
7
7
|
def initialize(aria_id: nil, **attributes)
|
8
8
|
@aria_id = aria_id
|
@@ -11,7 +11,7 @@ module ShadcnPhlexcomponents
|
|
11
11
|
|
12
12
|
def default_attributes
|
13
13
|
{
|
14
|
-
id: "#{@aria_id}-title"
|
14
|
+
id: "#{@aria_id}-title",
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
@@ -19,4 +19,4 @@ module ShadcnPhlexcomponents
|
|
19
19
|
h2(**@attributes, &)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|