shadcn_phlexcomponents 0.1.1 → 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/lib/components/checkbox_group.rb +17 -1
- 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/shadcn_phlexcomponents/alias.rb +1 -92
- data/lib/shadcn_phlexcomponents/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40670c18613895b2bad8f9e52fa345d364e551bad4ed1ac1894157cd18b6232b
|
4
|
+
data.tar.gz: 44a3519a328c959981a17b999fe1ff28427da1e9234c3dd435439c8ffce720e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8743f25dfe98a0c409b41bb75e0f023032df06a4d177b473ce0e7d9d84b29b9e6fe892828a608024efa80140361c8ae0a2cb905ea2eb705b67548117a8f4c33f
|
7
|
+
data.tar.gz: 58edec39a464e908f2f10ddb11e872e1ecc00cd29de4f23b5413131b818fa725a0742c9041b3057c12e7033064d811345328308a74250baefeb75a6f129f87ef
|
@@ -4,10 +4,11 @@ module ShadcnPhlexcomponents
|
|
4
4
|
class CheckboxGroup < Base
|
5
5
|
STYLES = "space-y-1.5"
|
6
6
|
|
7
|
-
def initialize(name:, value: [], include_hidden: true, **attributes)
|
7
|
+
def initialize(name:, value: [], include_hidden: true, disabled: false, **attributes)
|
8
8
|
@name = name
|
9
9
|
@value = value
|
10
10
|
@include_hidden = include_hidden
|
11
|
+
@disabled = disabled
|
11
12
|
super(**attributes)
|
12
13
|
end
|
13
14
|
|
@@ -24,18 +25,33 @@ module ShadcnPhlexcomponents
|
|
24
25
|
id = "#{@name.parameterize.underscore}_#{value}"
|
25
26
|
|
26
27
|
div(class: wrapper_class) do
|
28
|
+
checkbox_disabled = if @disabled.is_a?(String)
|
29
|
+
value == @disabled
|
30
|
+
elsif @disabled.is_a?(Array)
|
31
|
+
@disabled.include?(value)
|
32
|
+
else
|
33
|
+
@disabled
|
34
|
+
end
|
35
|
+
|
27
36
|
Checkbox(
|
28
37
|
name: "#{@name}[]",
|
29
38
|
id: id,
|
30
39
|
value: value,
|
31
40
|
checked: @value.include?(value),
|
32
41
|
include_hidden: false,
|
42
|
+
disabled: checkbox_disabled,
|
33
43
|
)
|
34
44
|
Label(for: id) { text }
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
38
48
|
|
49
|
+
def default_attributes
|
50
|
+
{
|
51
|
+
role: "group",
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
39
55
|
def view_template(&)
|
40
56
|
div(**@attributes) do
|
41
57
|
yield
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShadcnPhlexcomponents
|
4
|
+
class Form < Base
|
5
|
+
include Phlex::Rails::Helpers::FormWith
|
6
|
+
|
7
|
+
def initialize(model: false, scope: nil, url: nil, format: nil, **options)
|
8
|
+
@model = model
|
9
|
+
@scope = scope
|
10
|
+
@url = url
|
11
|
+
@format = format
|
12
|
+
@options = options
|
13
|
+
@object_name = model ? model.to_model.model_name.param_key : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def field(method = nil, **attributes, &)
|
17
|
+
FormField(method, model: @model, object_name: @object_name, **attributes, &)
|
18
|
+
end
|
19
|
+
|
20
|
+
def submit(variant: :primary, **attributes, &)
|
21
|
+
Button(variant: variant, type: :submit, **attributes) do
|
22
|
+
if block_given?
|
23
|
+
yield
|
24
|
+
else
|
25
|
+
submit_default_value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def view_template(&)
|
31
|
+
form_with(model: @model, scope: @scope, url: @url, format: @format, **@options) do
|
32
|
+
yield
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def submit_default_value
|
37
|
+
object = @model ? @model.to_model : nil
|
38
|
+
key = object ? (object.persisted? ? :update : :create) : :submit
|
39
|
+
|
40
|
+
model = if object.respond_to?(:model_name)
|
41
|
+
object.model_name.human
|
42
|
+
else
|
43
|
+
@object_name.to_s.humanize
|
44
|
+
end
|
45
|
+
|
46
|
+
defaults = []
|
47
|
+
# Object is a model and it is not overwritten by as and scope option.
|
48
|
+
if object.respond_to?(:model_name) && @object_name.to_s == model.downcase
|
49
|
+
defaults << :"helpers.submit.#{object.model_name.i18n_key}.#{key}"
|
50
|
+
else
|
51
|
+
defaults << :"helpers.submit.#{@object_name}.#{key}"
|
52
|
+
end
|
53
|
+
defaults << :"helpers.submit.#{key}"
|
54
|
+
defaults << "#{key.to_s.humanize} #{model}"
|
55
|
+
|
56
|
+
I18n.t(defaults.shift, model: model, default: defaults)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShadcnPhlexcomponents
|
4
|
+
class FormError < Base
|
5
|
+
STYLES = "text-[0.8rem] font-medium text-destructive"
|
6
|
+
|
7
|
+
def initialize(message: nil, aria_id: nil, **attributes)
|
8
|
+
@message = message
|
9
|
+
@id = aria_id ? "#{aria_id}-message" : nil
|
10
|
+
super(**attributes)
|
11
|
+
end
|
12
|
+
|
13
|
+
def view_template(&)
|
14
|
+
p(id: @id, **@attributes) { @message }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShadcnPhlexcomponents
|
4
|
+
class FormHint < Base
|
5
|
+
STYLES = "text-[0.8rem] text-muted-foreground"
|
6
|
+
|
7
|
+
def initialize(message: nil, aria_id: nil, **attributes)
|
8
|
+
@message = message
|
9
|
+
@id = aria_id ? "#{aria_id}-description" : nil
|
10
|
+
super(**attributes)
|
11
|
+
end
|
12
|
+
|
13
|
+
def view_template(&)
|
14
|
+
p(id: @id, **@attributes) { @message }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShadcnPhlexcomponents
|
4
|
+
class FormInput < Base
|
5
|
+
include FormHelpers
|
6
|
+
|
7
|
+
def initialize(
|
8
|
+
method = nil,
|
9
|
+
model: false,
|
10
|
+
object_name: nil,
|
11
|
+
type: :text,
|
12
|
+
value: nil,
|
13
|
+
name: nil,
|
14
|
+
id: nil,
|
15
|
+
label: nil,
|
16
|
+
error: nil,
|
17
|
+
hint: nil,
|
18
|
+
**attributes
|
19
|
+
)
|
20
|
+
@method = method
|
21
|
+
@model = model
|
22
|
+
@object_name = object_name
|
23
|
+
@type = type.to_sym
|
24
|
+
@value = value
|
25
|
+
@model_value = model&.public_send(method)
|
26
|
+
@name = name
|
27
|
+
@id = id
|
28
|
+
@label = label
|
29
|
+
@error = error || (model ? model.errors.full_messages_for(method).first : nil)
|
30
|
+
@hint = hint
|
31
|
+
@aria_id = "form-field-#{SecureRandom.hex(5)}"
|
32
|
+
super(**attributes)
|
33
|
+
end
|
34
|
+
|
35
|
+
def view_template(&)
|
36
|
+
vanish(&)
|
37
|
+
|
38
|
+
@id ||= field_id(@object_name, @method)
|
39
|
+
@name ||= field_name(@object_name, @method)
|
40
|
+
|
41
|
+
div(class: "space-y-2", data: label_and_hint_container_attributes) do
|
42
|
+
render_label(&)
|
43
|
+
Input(type: @type, id: @id, name: @name, value: @value || @model_value, aria: aria_attributes, **@attributes)
|
44
|
+
render_hint(&)
|
45
|
+
render_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -2,133 +2,42 @@
|
|
2
2
|
|
3
3
|
module ShadcnPhlexcomponents; end
|
4
4
|
Accordion = ShadcnPhlexcomponents::Accordion
|
5
|
-
AccordionContent = ShadcnPhlexcomponents::AccordionContent
|
6
|
-
AccordionItem = ShadcnPhlexcomponents::AccordionItem
|
7
|
-
AccordionTrigger = ShadcnPhlexcomponents::AccordionTrigger
|
8
5
|
Alert = ShadcnPhlexcomponents::Alert
|
9
|
-
AlertTitle = ShadcnPhlexcomponents::AlertTitle
|
10
|
-
AlertDescription = ShadcnPhlexcomponents::AlertDescription
|
11
6
|
AlertDialog = ShadcnPhlexcomponents::AlertDialog
|
12
|
-
AlertDialogActionTo = ShadcnPhlexcomponents::AlertDialogActionTo
|
13
|
-
AlertDialogAction = ShadcnPhlexcomponents::AlertDialogAction
|
14
|
-
AlertDialogCancel = ShadcnPhlexcomponents::AlertDialogCancel
|
15
|
-
AlertDialogContent = ShadcnPhlexcomponents::AlertDialogContent
|
16
|
-
AlertDialogDescription = ShadcnPhlexcomponents::AlertDialogDescription
|
17
|
-
AlertDialogFooter = ShadcnPhlexcomponents::AlertDialogFooter
|
18
|
-
AlertDialogHeader = ShadcnPhlexcomponents::AlertDialogHeader
|
19
|
-
AlertDialogTitle = ShadcnPhlexcomponents::AlertDialogTitle
|
20
|
-
AlertDialogTrigger = ShadcnPhlexcomponents::AlertDialogTrigger
|
21
7
|
AspectRatio = ShadcnPhlexcomponents::AspectRatio
|
22
8
|
Avatar = ShadcnPhlexcomponents::Avatar
|
23
|
-
AvatarFallback = ShadcnPhlexcomponents::AvatarFallback
|
24
|
-
AvatarImage = ShadcnPhlexcomponents::AvatarImage
|
25
9
|
Badge = ShadcnPhlexcomponents::Badge
|
26
10
|
Breadcrumb = ShadcnPhlexcomponents::Breadcrumb
|
27
|
-
BreadcrumbEllipsis = ShadcnPhlexcomponents::BreadcrumbEllipsis
|
28
|
-
BreadcrumbItem = ShadcnPhlexcomponents::BreadcrumbItem
|
29
|
-
BreadcrumbLink = ShadcnPhlexcomponents::BreadcrumbLink
|
30
|
-
BreadcrumbPage = ShadcnPhlexcomponents::BreadcrumbPage
|
31
|
-
BreadcrumbSeparator = ShadcnPhlexcomponents::BreadcrumbSeparator
|
32
11
|
Button = ShadcnPhlexcomponents::Button
|
33
12
|
Card = ShadcnPhlexcomponents::Card
|
34
|
-
CardContent = ShadcnPhlexcomponents::CardContent
|
35
|
-
CardDescription = ShadcnPhlexcomponents::CardDescription
|
36
|
-
CardFooter = ShadcnPhlexcomponents::CardFooter
|
37
|
-
CardHeader = ShadcnPhlexcomponents::CardHeader
|
38
|
-
CardTitle = ShadcnPhlexcomponents::CardTitle
|
39
13
|
CheckboxGroup = ShadcnPhlexcomponents::CheckboxGroup
|
40
14
|
Checkbox = ShadcnPhlexcomponents::Checkbox
|
41
15
|
Collapsible = ShadcnPhlexcomponents::Collapsible
|
42
|
-
CollapsibleContent = ShadcnPhlexcomponents::CollapsibleContent
|
43
|
-
CollapsibleTrigger = ShadcnPhlexcomponents::CollapsibleTrigger
|
44
16
|
Combobox = ShadcnPhlexcomponents::Combobox
|
45
17
|
DatePicker = ShadcnPhlexcomponents::DatePicker
|
46
18
|
DateRangePicker = ShadcnPhlexcomponents::DateRangePicker
|
47
19
|
Dialog = ShadcnPhlexcomponents::Dialog
|
48
|
-
DialogClose = ShadcnPhlexcomponents::DialogClose
|
49
|
-
DialogContent = ShadcnPhlexcomponents::DialogContent
|
50
|
-
DialogDescription = ShadcnPhlexcomponents::DialogDescription
|
51
|
-
DialogFooter = ShadcnPhlexcomponents::DialogFooter
|
52
|
-
DialogHeader = ShadcnPhlexcomponents::DialogHeader
|
53
|
-
DialogTitle = ShadcnPhlexcomponents::DialogTitle
|
54
|
-
DialogTrigger = ShadcnPhlexcomponents::DialogTrigger
|
55
20
|
DropdownMenu = ShadcnPhlexcomponents::DropdownMenu
|
56
|
-
|
57
|
-
DropdownMenuItem = ShadcnPhlexcomponents::DropdownMenuItem
|
58
|
-
DropdownMenuLabel = ShadcnPhlexcomponents::DropdownMenuLabel
|
59
|
-
DropdownMenuSeparator = ShadcnPhlexcomponents::DropdownMenuSeparator
|
60
|
-
DropdownMenuTrigger = ShadcnPhlexcomponents::DropdownMenuTrigger
|
21
|
+
Form = ShadcnPhlexcomponents::Form
|
61
22
|
HoverCard = ShadcnPhlexcomponents::HoverCard
|
62
|
-
HoverCardContent = ShadcnPhlexcomponents::HoverCardContent
|
63
|
-
HoverCardTrigger = ShadcnPhlexcomponents::HoverCardTrigger
|
64
23
|
Input = ShadcnPhlexcomponents::Input
|
65
24
|
Label = ShadcnPhlexcomponents::Label
|
66
25
|
Link = ShadcnPhlexcomponents::Link
|
67
26
|
LoadingButton = ShadcnPhlexcomponents::LoadingButton
|
68
27
|
Pagination = ShadcnPhlexcomponents::Pagination
|
69
|
-
PaginationEllipsis = ShadcnPhlexcomponents::PaginationEllipsis
|
70
|
-
PaginationLink = ShadcnPhlexcomponents::PaginationLink
|
71
|
-
PaginationNext = ShadcnPhlexcomponents::PaginationNext
|
72
|
-
PaginationPrevious = ShadcnPhlexcomponents::PaginationPrevious
|
73
28
|
Popover = ShadcnPhlexcomponents::Popover
|
74
|
-
PopoverContent = ShadcnPhlexcomponents::PopoverContent
|
75
|
-
PopoverTrigger = ShadcnPhlexcomponents::PopoverTrigger
|
76
29
|
Progress = ShadcnPhlexcomponents::Progress
|
77
30
|
RadioGroup = ShadcnPhlexcomponents::RadioGroup
|
78
|
-
RadioGroupItem = ShadcnPhlexcomponents::RadioGroupItem
|
79
31
|
Select = ShadcnPhlexcomponents::Select
|
80
|
-
SelectContent = ShadcnPhlexcomponents::SelectContent
|
81
|
-
SelectGroup = ShadcnPhlexcomponents::SelectGroup
|
82
|
-
SelectItem = ShadcnPhlexcomponents::SelectItem
|
83
|
-
SelectLabel = ShadcnPhlexcomponents::SelectLabel
|
84
32
|
Separator = ShadcnPhlexcomponents::Separator
|
85
33
|
Sheet = ShadcnPhlexcomponents::Sheet
|
86
|
-
SheetClose = ShadcnPhlexcomponents::SheetClose
|
87
|
-
SheetContent = ShadcnPhlexcomponents::SheetContent
|
88
|
-
SheetDescription = ShadcnPhlexcomponents::SheetDescription
|
89
|
-
SheetFooter = ShadcnPhlexcomponents::SheetFooter
|
90
|
-
SheetHeader = ShadcnPhlexcomponents::SheetHeader
|
91
|
-
SheetTitle = ShadcnPhlexcomponents::SheetTitle
|
92
|
-
SheetTrigger = ShadcnPhlexcomponents::SheetTrigger
|
93
34
|
Sidebar = ShadcnPhlexcomponents::Sidebar
|
94
|
-
SidebarContainer = ShadcnPhlexcomponents::SidebarContainer
|
95
|
-
SidebarContent = ShadcnPhlexcomponents::SidebarContent
|
96
|
-
SidebarFooter = ShadcnPhlexcomponents::SidebarFooter
|
97
|
-
SidebarGroupContent = ShadcnPhlexcomponents::SidebarGroupContent
|
98
|
-
SidebarGroupLabel = ShadcnPhlexcomponents::SidebarGroupLabel
|
99
|
-
SidebarGroup = ShadcnPhlexcomponents::SidebarGroup
|
100
|
-
SidebarHeader = ShadcnPhlexcomponents::SidebarHeader
|
101
|
-
SidebarInset = ShadcnPhlexcomponents::SidebarInset
|
102
|
-
SidebarMenuButton = ShadcnPhlexcomponents::SidebarMenuButton
|
103
|
-
SidebarMenuItem = ShadcnPhlexcomponents::SidebarMenuItem
|
104
|
-
SidebarMenuSubButton = ShadcnPhlexcomponents::SidebarMenuSubButton
|
105
|
-
SidebarMenuSubItem = ShadcnPhlexcomponents::SidebarMenuSubItem
|
106
|
-
SidebarMenuSub = ShadcnPhlexcomponents::SidebarMenuSub
|
107
|
-
SidebarMenu = ShadcnPhlexcomponents::SidebarMenu
|
108
|
-
SidebarTrigger = ShadcnPhlexcomponents::SidebarTrigger
|
109
35
|
Skeleton = ShadcnPhlexcomponents::Skeleton
|
110
36
|
Switch = ShadcnPhlexcomponents::Switch
|
111
37
|
Table = ShadcnPhlexcomponents::Table
|
112
|
-
TableBody = ShadcnPhlexcomponents::TableBody
|
113
|
-
TableCaption = ShadcnPhlexcomponents::TableCaption
|
114
|
-
TableCell = ShadcnPhlexcomponents::TableCell
|
115
|
-
TableFooter = ShadcnPhlexcomponents::TableFooter
|
116
|
-
TableHead = ShadcnPhlexcomponents::TableHead
|
117
|
-
TableHeader = ShadcnPhlexcomponents::TableHeader
|
118
|
-
TableRow = ShadcnPhlexcomponents::TableRow
|
119
38
|
Tabs = ShadcnPhlexcomponents::Tabs
|
120
|
-
TabsContent = ShadcnPhlexcomponents::TabsContent
|
121
|
-
TabsList = ShadcnPhlexcomponents::TabsList
|
122
|
-
TabsTrigger = ShadcnPhlexcomponents::TabsTrigger
|
123
39
|
Textarea = ShadcnPhlexcomponents::Textarea
|
124
40
|
ThemeSwitcher = ShadcnPhlexcomponents::ThemeSwitcher
|
125
41
|
Toast = ShadcnPhlexcomponents::Toast
|
126
|
-
ToastActionTo = ShadcnPhlexcomponents::ToastActionTo
|
127
|
-
ToastAction = ShadcnPhlexcomponents::ToastAction
|
128
42
|
ToastContainer = ShadcnPhlexcomponents::ToastContainer
|
129
|
-
ToastContent = ShadcnPhlexcomponents::ToastContent
|
130
|
-
ToastDescription = ShadcnPhlexcomponents::ToastDescription
|
131
|
-
ToastTitle = ShadcnPhlexcomponents::ToastTitle
|
132
43
|
Tooltip = ShadcnPhlexcomponents::Tooltip
|
133
|
-
TooltipContent = ShadcnPhlexcomponents::TooltipContent
|
134
|
-
TooltipTrigger = ShadcnPhlexcomponents::TooltipTrigger
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shadcn_phlexcomponents
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Yeoh
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: lucide-rails
|
@@ -161,6 +161,10 @@ files:
|
|
161
161
|
- lib/components/dropdown_menu_label.rb
|
162
162
|
- lib/components/dropdown_menu_separator.rb
|
163
163
|
- lib/components/dropdown_menu_trigger.rb
|
164
|
+
- lib/components/form.rb
|
165
|
+
- lib/components/form_error.rb
|
166
|
+
- lib/components/form_hint.rb
|
167
|
+
- lib/components/form_input.rb
|
164
168
|
- lib/components/hover_card.rb
|
165
169
|
- lib/components/hover_card_content.rb
|
166
170
|
- lib/components/hover_card_trigger.rb
|
@@ -263,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
267
|
- !ruby/object:Gem::Version
|
264
268
|
version: '0'
|
265
269
|
requirements: []
|
266
|
-
rubygems_version: 3.6.
|
270
|
+
rubygems_version: 3.6.7
|
267
271
|
specification_version: 4
|
268
272
|
summary: Shadcn Phlexcomponents is a UI Component library built for Ruby on Rails.
|
269
273
|
test_files: []
|