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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/tailwind/choices.css +324 -0
  3. data/app/assets/tailwind/vanilla-calendar-pro.css +5 -0
  4. data/app/javascript/controllers/combobox_controller.js +19 -276
  5. data/app/javascript/controllers/date_picker_controller.js +118 -0
  6. data/app/javascript/controllers/date_range_picker_controller.js +231 -0
  7. data/app/javascript/controllers/dropdown_menu_controller.js +1 -1
  8. data/app/javascript/controllers/hover_card_controller.js +33 -126
  9. data/app/javascript/controllers/sidebar_controller.js +0 -1
  10. data/app/javascript/controllers/tooltip_controller.js +32 -126
  11. data/lib/components/accordion.rb +3 -3
  12. data/lib/components/accordion_content.rb +12 -10
  13. data/lib/components/accordion_item.rb +3 -3
  14. data/lib/components/accordion_trigger.rb +3 -3
  15. data/lib/components/alert_description.rb +1 -1
  16. data/lib/components/alert_dialog.rb +2 -2
  17. data/lib/components/alert_dialog_action.rb +2 -2
  18. data/lib/components/alert_dialog_action_to.rb +5 -2
  19. data/lib/components/alert_dialog_cancel.rb +1 -1
  20. data/lib/components/alert_dialog_content.rb +1 -1
  21. data/lib/components/alert_dialog_description.rb +1 -1
  22. data/lib/components/alert_dialog_footer.rb +1 -1
  23. data/lib/components/alert_dialog_header.rb +1 -1
  24. data/lib/components/alert_dialog_title.rb +1 -1
  25. data/lib/components/alert_dialog_trigger.rb +2 -2
  26. data/lib/components/aspect_ratio.rb +1 -1
  27. data/lib/components/avatar.rb +1 -1
  28. data/lib/components/avatar_fallback.rb +1 -1
  29. data/lib/components/avatar_image.rb +1 -2
  30. data/lib/components/badge.rb +2 -8
  31. data/lib/components/base.rb +5 -5
  32. data/lib/components/breadcrumb.rb +1 -1
  33. data/lib/components/breadcrumb_ellipsis.rb +1 -1
  34. data/lib/components/breadcrumb_item.rb +1 -1
  35. data/lib/components/breadcrumb_link.rb +1 -1
  36. data/lib/components/breadcrumb_page.rb +1 -1
  37. data/lib/components/breadcrumb_separator.rb +1 -1
  38. data/lib/components/button.rb +1 -1
  39. data/lib/components/card.rb +1 -1
  40. data/lib/components/card_content.rb +1 -1
  41. data/lib/components/card_description.rb +1 -1
  42. data/lib/components/card_footer.rb +1 -1
  43. data/lib/components/card_header.rb +1 -1
  44. data/lib/components/card_title.rb +1 -1
  45. data/lib/components/checkbox.rb +14 -10
  46. data/lib/components/checkbox_group.rb +9 -8
  47. data/lib/components/collapsible.rb +2 -3
  48. data/lib/components/collapsible_content.rb +2 -3
  49. data/lib/components/collapsible_trigger.rb +5 -5
  50. data/lib/components/combobox.rb +57 -0
  51. data/lib/components/combobox_item.rb +9 -0
  52. data/lib/components/date_picker.rb +94 -0
  53. data/lib/components/date_range_picker.rb +113 -0
  54. data/lib/components/dialog.rb +1 -1
  55. data/lib/components/dialog_close.rb +1 -1
  56. data/lib/components/dialog_content.rb +2 -2
  57. data/lib/components/dialog_description.rb +1 -1
  58. data/lib/components/dialog_footer.rb +1 -1
  59. data/lib/components/dialog_header.rb +1 -1
  60. data/lib/components/dialog_title.rb +1 -1
  61. data/lib/components/dialog_trigger.rb +2 -2
  62. data/lib/components/dropdown_menu.rb +5 -5
  63. data/lib/components/dropdown_menu_content.rb +12 -9
  64. data/lib/components/dropdown_menu_item.rb +5 -6
  65. data/lib/components/dropdown_menu_item_to.rb +6 -3
  66. data/lib/components/dropdown_menu_label.rb +2 -3
  67. data/lib/components/dropdown_menu_separator.rb +5 -5
  68. data/lib/components/dropdown_menu_trigger.rb +9 -10
  69. data/lib/components/hover_card.rb +6 -6
  70. data/lib/components/hover_card_content.rb +8 -12
  71. data/lib/components/hover_card_trigger.rb +5 -11
  72. data/lib/components/input.rb +1 -1
  73. data/lib/components/label.rb +1 -2
  74. data/lib/components/link.rb +5 -2
  75. data/lib/components/loading_button.rb +1 -1
  76. data/lib/components/pagination.rb +4 -4
  77. data/lib/components/pagination_ellipsis.rb +3 -3
  78. data/lib/components/pagination_link.rb +5 -5
  79. data/lib/components/pagination_next.rb +5 -5
  80. data/lib/components/pagination_previous.rb +4 -4
  81. data/lib/components/popover.rb +6 -7
  82. data/lib/components/popover_content.rb +13 -10
  83. data/lib/components/popover_trigger.rb +5 -6
  84. data/lib/components/progress.rb +7 -7
  85. data/lib/components/radio_group.rb +4 -4
  86. data/lib/components/radio_group_item.rb +8 -8
  87. data/lib/components/select.rb +67 -72
  88. data/lib/components/select_content.rb +12 -7
  89. data/lib/components/select_group.rb +3 -3
  90. data/lib/components/select_item.rb +9 -8
  91. data/lib/components/select_label.rb +6 -5
  92. data/lib/components/select_trigger.rb +12 -10
  93. data/lib/components/separator.rb +3 -3
  94. data/lib/components/sheet.rb +9 -9
  95. data/lib/components/sheet_close.rb +4 -4
  96. data/lib/components/sheet_content.rb +13 -15
  97. data/lib/components/sheet_description.rb +3 -3
  98. data/lib/components/sheet_footer.rb +2 -2
  99. data/lib/components/sheet_header.rb +2 -2
  100. data/lib/components/sheet_title.rb +3 -3
  101. data/lib/components/sheet_trigger.rb +6 -6
  102. data/lib/components/sidebar.rb +30 -25
  103. data/lib/components/sidebar_container.rb +1 -1
  104. data/lib/components/sidebar_content.rb +1 -1
  105. data/lib/components/sidebar_footer.rb +2 -2
  106. data/lib/components/sidebar_group.rb +1 -1
  107. data/lib/components/sidebar_group_content.rb +1 -1
  108. data/lib/components/sidebar_group_label.rb +2 -2
  109. data/lib/components/sidebar_header.rb +2 -2
  110. data/lib/components/sidebar_inset.rb +1 -1
  111. data/lib/components/sidebar_menu.rb +2 -2
  112. data/lib/components/sidebar_menu_button.rb +5 -5
  113. data/lib/components/sidebar_menu_item.rb +1 -1
  114. data/lib/components/sidebar_menu_sub.rb +2 -2
  115. data/lib/components/sidebar_menu_sub_button.rb +7 -7
  116. data/lib/components/sidebar_menu_sub_item.rb +1 -1
  117. data/lib/components/sidebar_trigger.rb +5 -5
  118. data/lib/components/skeleton.rb +2 -2
  119. data/lib/components/switch.rb +10 -9
  120. data/lib/components/table.rb +7 -5
  121. data/lib/components/table_body.rb +2 -2
  122. data/lib/components/table_caption.rb +2 -2
  123. data/lib/components/table_cell.rb +2 -2
  124. data/lib/components/table_footer.rb +2 -2
  125. data/lib/components/table_head.rb +3 -3
  126. data/lib/components/table_header.rb +2 -2
  127. data/lib/components/table_row.rb +2 -2
  128. data/lib/components/tabs.rb +3 -3
  129. data/lib/components/tabs_content.rb +5 -5
  130. data/lib/components/tabs_list.rb +4 -4
  131. data/lib/components/tabs_trigger.rb +3 -3
  132. data/lib/components/textarea.rb +1 -1
  133. data/lib/components/theme_switcher.rb +2 -2
  134. data/lib/components/toast.rb +15 -14
  135. data/lib/components/toast_action.rb +5 -4
  136. data/lib/components/toast_action_to.rb +5 -2
  137. data/lib/components/toast_container.rb +5 -5
  138. data/lib/components/toast_content.rb +1 -1
  139. data/lib/components/toast_description.rb +1 -1
  140. data/lib/components/toast_title.rb +1 -1
  141. data/lib/components/tooltip.rb +8 -8
  142. data/lib/components/tooltip_content.rb +8 -11
  143. data/lib/components/tooltip_trigger.rb +9 -11
  144. data/lib/shadcn_phlexcomponents/alias.rb +3 -1
  145. data/lib/shadcn_phlexcomponents/version.rb +1 -1
  146. metadata +9 -4
  147. data/app/javascript/controllers/datepicker_controller.js +0 -47
  148. data/lib/components/datepicker.rb +0 -38
@@ -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
@@ -7,8 +7,8 @@ module ShadcnPhlexcomponents
7
7
  def default_attributes
8
8
  {
9
9
  aria: {
10
- hidden: "true"
11
- }
10
+ hidden: "true",
11
+ },
12
12
  }
13
13
  end
14
14
 
@@ -21,4 +21,4 @@ module ShadcnPhlexcomponents
21
21
  end
22
22
  end
23
23
  end
24
- end
24
+ 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
@@ -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".freeze
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.freeze
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(class: 'hidden fixed top-0 left-0 w-max z-50', data: { "shadcn-phlexcomponents--popover-target": "contentWrapper" }) do
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
@@ -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-@value}%)",
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 && collection.first.is_a?(Hash)
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.freeze
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
- class: "items-center justify-center hidden group-data-[checked=true]/radio:flex"
24
- ) do
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
@@ -2,29 +2,29 @@
2
2
 
3
3
  module ShadcnPhlexcomponents
4
4
  class Select < Base
5
- STYLES = "w-full".freeze
6
-
7
- NATIVE_STYLES = <<~HEREDOC.freeze
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".freeze
14
+
15
+ NATIVE_OPTION_STYLES = "bg-popover text-popover-foreground"
16
16
 
17
17
  def initialize(id: nil,
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)
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
- end
49
+ **attributes,
50
+ )
51
+ end
51
52
 
52
53
  def content(**attributes, &)
53
- SelectContent(side: @side, aria_id: @aria_id, dir: @dir, include_blank: @include_blank, native: @native, **attributes, &)
54
- end
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
- style: {
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:@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['data-shadcn-phlexcomponents--select-target']&.value == 'group'
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['data-value'].value,
161
+ value: i.attributes["data-value"].value,
170
162
  class: NATIVE_OPTION_STYLES,
171
- selected: i.attributes['data-value'].value === @value,
172
- disabled: i.attributes['data-disabled']&.value === '') do
173
- i.text
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['data-shadcn-phlexcomponents--select-target']&.value == 'item'
170
+ elsif content_child.attributes["data-shadcn-phlexcomponents--select-target"]&.value == "item"
178
171
 
179
- option(value: content_child.attributes['data-value'].value,
180
- class: NATIVE_OPTION_STYLES,
181
- selected: content_child.attributes['data-value'].value === @value,
182
- disabled: content_child.attributes['data-disabled']&.value === '') do
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.freeze
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(class: "hidden fixed top-0 left-0 w-max z-50", data: { "shadcn-phlexcomponents--select-target": "contentWrapper" }) do
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) { @include_blank.is_a?(String) ? @include_blank : "" }
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
@@ -15,9 +15,9 @@ module ShadcnPhlexcomponents
15
15
  {
16
16
  role: "group",
17
17
  data: {
18
- "shadcn-phlexcomponents--select-target": "group"
19
- }
18
+ "shadcn-phlexcomponents--select-target": "group",
19
+ },
20
20
  }
21
21
  end
22
22
  end
23
- end
23
+ end