shadcn_phlexcomponents 0.1.11 → 0.1.14

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/javascript/controllers/accordion_controller.ts +65 -62
  3. data/app/javascript/controllers/alert_dialog_controller.ts +12 -0
  4. data/app/javascript/controllers/avatar_controller.ts +7 -2
  5. data/app/javascript/controllers/checkbox_controller.ts +11 -4
  6. data/app/javascript/controllers/collapsible_controller.ts +12 -5
  7. data/app/javascript/controllers/combobox_controller.ts +270 -39
  8. data/app/javascript/controllers/command_controller.ts +223 -51
  9. data/app/javascript/controllers/date_picker_controller.ts +185 -125
  10. data/app/javascript/controllers/date_range_picker_controller.ts +89 -79
  11. data/app/javascript/controllers/dialog_controller.ts +59 -57
  12. data/app/javascript/controllers/dropdown_menu_controller.ts +212 -36
  13. data/app/javascript/controllers/dropdown_menu_sub_controller.ts +31 -29
  14. data/app/javascript/controllers/form_field_controller.ts +6 -1
  15. data/app/javascript/controllers/hover_card_controller.ts +36 -26
  16. data/app/javascript/controllers/loading_button_controller.ts +6 -1
  17. data/app/javascript/controllers/popover_controller.ts +42 -65
  18. data/app/javascript/controllers/progress_controller.ts +9 -3
  19. data/app/javascript/controllers/radio_group_controller.ts +16 -9
  20. data/app/javascript/controllers/select_controller.ts +206 -65
  21. data/app/javascript/controllers/slider_controller.ts +23 -16
  22. data/app/javascript/controllers/switch_controller.ts +11 -4
  23. data/app/javascript/controllers/tabs_controller.ts +26 -18
  24. data/app/javascript/controllers/theme_switcher_controller.ts +6 -1
  25. data/app/javascript/controllers/toast_container_controller.ts +6 -1
  26. data/app/javascript/controllers/toast_controller.ts +7 -1
  27. data/app/javascript/controllers/toggle_controller.ts +28 -0
  28. data/app/javascript/controllers/toggle_group_controller.ts +28 -0
  29. data/app/javascript/controllers/tooltip_controller.ts +43 -31
  30. data/app/javascript/shadcn_phlexcomponents.ts +29 -25
  31. data/app/javascript/utils/command.ts +544 -0
  32. data/app/javascript/utils/floating_ui.ts +196 -0
  33. data/app/javascript/utils/index.ts +417 -0
  34. data/app/stylesheets/date_picker.css +118 -0
  35. data/lib/shadcn_phlexcomponents/alias.rb +3 -0
  36. data/lib/shadcn_phlexcomponents/components/accordion.rb +2 -1
  37. data/lib/shadcn_phlexcomponents/components/alert_dialog.rb +18 -15
  38. data/lib/shadcn_phlexcomponents/components/base.rb +14 -0
  39. data/lib/shadcn_phlexcomponents/components/collapsible.rb +1 -2
  40. data/lib/shadcn_phlexcomponents/components/combobox.rb +87 -57
  41. data/lib/shadcn_phlexcomponents/components/command.rb +77 -47
  42. data/lib/shadcn_phlexcomponents/components/date_picker.rb +25 -81
  43. data/lib/shadcn_phlexcomponents/components/date_range_picker.rb +21 -4
  44. data/lib/shadcn_phlexcomponents/components/dialog.rb +14 -12
  45. data/lib/shadcn_phlexcomponents/components/dropdown_menu.rb +5 -4
  46. data/lib/shadcn_phlexcomponents/components/dropdown_menu_sub.rb +2 -1
  47. data/lib/shadcn_phlexcomponents/components/form/form_combobox.rb +64 -0
  48. data/lib/shadcn_phlexcomponents/components/form.rb +14 -0
  49. data/lib/shadcn_phlexcomponents/components/hover_card.rb +3 -2
  50. data/lib/shadcn_phlexcomponents/components/popover.rb +3 -3
  51. data/lib/shadcn_phlexcomponents/components/select.rb +10 -25
  52. data/lib/shadcn_phlexcomponents/components/sheet.rb +15 -11
  53. data/lib/shadcn_phlexcomponents/components/table.rb +1 -1
  54. data/lib/shadcn_phlexcomponents/components/tabs.rb +1 -1
  55. data/lib/shadcn_phlexcomponents/components/toast_container.rb +1 -1
  56. data/lib/shadcn_phlexcomponents/components/toggle.rb +54 -0
  57. data/lib/shadcn_phlexcomponents/components/tooltip.rb +3 -2
  58. data/lib/shadcn_phlexcomponents/engine.rb +1 -5
  59. data/lib/shadcn_phlexcomponents/version.rb +1 -1
  60. metadata +9 -4
  61. data/app/javascript/controllers/command_root_controller.ts +0 -355
  62. data/app/javascript/controllers/dropdown_menu_root_controller.ts +0 -234
  63. data/app/javascript/utils.ts +0 -437
@@ -11,6 +11,7 @@ require_relative "form/form_checkbox_group"
11
11
  require_relative "form/form_date_picker"
12
12
  require_relative "form/form_date_range_picker"
13
13
  require_relative "form/form_select"
14
+ require_relative "form/form_combobox"
14
15
  require_relative "form/form_radio_group"
15
16
  require_relative "form/form_slider"
16
17
 
@@ -83,6 +84,19 @@ module ShadcnPhlexcomponents
83
84
  )
84
85
  end
85
86
 
87
+ def combobox(method = nil, collection = [], value_method:, text_method:, **attributes, &)
88
+ FormCombobox(
89
+ method,
90
+ model: @model,
91
+ object_name: @object_name,
92
+ collection: collection,
93
+ value_method: value_method,
94
+ text_method: text_method,
95
+ **attributes,
96
+ &
97
+ )
98
+ end
99
+
86
100
  def date_picker(method = nil, **attributes, &)
87
101
  FormDatePicker(method, model: @model, object_name: @object_name, **attributes, &)
88
102
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ShadcnPhlexcomponents
4
4
  class HoverCard < Base
5
- class_variants(base: "inline-block max-w-fit")
5
+ class_variants(base: "inline-flex max-w-fit")
6
6
 
7
7
  def initialize(open: false, **attributes)
8
8
  @open = open
@@ -88,7 +88,8 @@ module ShadcnPhlexcomponents
88
88
 
89
89
  def view_template(&)
90
90
  div(
91
- class: "hidden fixed top-0 left-0 w-max z-50",
91
+ style: { display: "none" },
92
+ class: "fixed top-0 left-0 w-max z-50",
92
93
  data: { hover_card_target: "contentContainer" },
93
94
  ) do
94
95
  div(**@attributes, &)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ShadcnPhlexcomponents
4
4
  class Popover < Base
5
- class_variants(base: "inline-block max-w-fit")
5
+ class_variants(base: "inline-flex max-w-fit")
6
6
 
7
7
  def initialize(open: false, **attributes)
8
8
  @open = open
@@ -23,7 +23,6 @@ module ShadcnPhlexcomponents
23
23
  data: {
24
24
  controller: "popover",
25
25
  popover_is_open_value: @open.to_s,
26
- side: @side,
27
26
  },
28
27
  }
29
28
  end
@@ -92,7 +91,8 @@ module ShadcnPhlexcomponents
92
91
 
93
92
  def view_template(&)
94
93
  div(
95
- class: "hidden fixed top-0 left-0 w-max z-50",
94
+ style: { display: "none" },
95
+ class: "fixed top-0 left-0 w-max z-50",
96
96
  data: { popover_target: "contentContainer" },
97
97
  ) do
98
98
  div(**@attributes, &)
@@ -10,7 +10,6 @@ module ShadcnPhlexcomponents
10
10
  value: nil,
11
11
  placeholder: nil,
12
12
  native: false,
13
- dir: "ltr",
14
13
  include_blank: false,
15
14
  disabled: false,
16
15
  **attributes
@@ -20,7 +19,6 @@ module ShadcnPhlexcomponents
20
19
  @value = value
21
20
  @placeholder = placeholder
22
21
  @native = native
23
- @dir = dir
24
22
  @include_blank = include_blank
25
23
  @disabled = disabled
26
24
  @aria_id = "select-#{SecureRandom.hex(5)}"
@@ -39,7 +37,6 @@ module ShadcnPhlexcomponents
39
37
  SelectTrigger(
40
38
  id: @id,
41
39
  aria_id: @aria_id,
42
- dir: @dir,
43
40
  value: @value,
44
41
  placeholder: @placeholder,
45
42
  disabled: @disabled,
@@ -49,7 +46,7 @@ module ShadcnPhlexcomponents
49
46
 
50
47
  def content(**attributes, &)
51
48
  SelectContent(
52
- aria_id: @aria_id, dir: @dir, include_blank: @include_blank, native: @native, **attributes, &
49
+ aria_id: @aria_id, include_blank: @include_blank, native: @native, **attributes, &
53
50
  )
54
51
  end
55
52
 
@@ -75,13 +72,12 @@ module ShadcnPhlexcomponents
75
72
  SelectTrigger(
76
73
  id: @id,
77
74
  aria_id: @aria_id,
78
- dir: @dir,
79
75
  value: @value,
80
76
  placeholder: @placeholder,
81
77
  disabled: @disabled,
82
78
  )
83
79
 
84
- SelectContent(aria_id: @aria_id, dir: @dir, include_blank: @include_blank, native: @native) do
80
+ SelectContent(aria_id: @aria_id, include_blank: @include_blank, native: @native) do
85
81
  collection.each do |item|
86
82
  value = item.public_send(value_method)
87
83
  text = item.public_send(text_method)
@@ -151,7 +147,7 @@ module ShadcnPhlexcomponents
151
147
  next if content_child.is_a?(Nokogiri::XML::Text) || content_child.is_a?(Nokogiri::XML::Comment)
152
148
 
153
149
  if content_child.attributes["data-select-target"]&.value == "group"
154
- group_label = content_child.at_css('[data-select-target="label"]')&.text
150
+ group_label = content_child.at_css('[data-shadcn-phlexcomponents="select-label"]')&.text
155
151
 
156
152
  optgroup(label: group_label, class: NATIVE_OPTION_STYLES) do
157
153
  content_child.css('[data-select-target="item"]').each do |i|
@@ -195,11 +191,10 @@ module ShadcnPhlexcomponents
195
191
  HEREDOC
196
192
  )
197
193
 
198
- def initialize(id: nil, value: nil, placeholder: nil, dir: "ltr", aria_id: nil, **attributes)
194
+ def initialize(id: nil, value: nil, placeholder: nil, aria_id: nil, **attributes)
199
195
  @id = id
200
196
  @value = value
201
197
  @placeholder = placeholder
202
- @dir = dir
203
198
  @aria_id = aria_id
204
199
  super(**attributes)
205
200
  end
@@ -218,7 +213,6 @@ module ShadcnPhlexcomponents
218
213
  {
219
214
  type: "button",
220
215
  id: @id,
221
- dir: @dir,
222
216
  role: "combobox",
223
217
  aria: {
224
218
  autocomplete: "none",
@@ -230,9 +224,9 @@ module ShadcnPhlexcomponents
230
224
  has_value: @value.present?.to_s,
231
225
  action: <<~HEREDOC,
232
226
  click->select#toggle
233
- keydown.space->select#open
234
- keydown.enter->select#open
235
227
  keydown.down->select#open:prevent
228
+ keydown.space->select#open:prevent
229
+ keydown.enter->select#open:prevent
236
230
  HEREDOC
237
231
  select_target: "trigger",
238
232
  },
@@ -252,10 +246,9 @@ module ShadcnPhlexcomponents
252
246
  HEREDOC
253
247
  )
254
248
 
255
- def initialize(include_blank: false, native: false, dir: "ltr", side: :bottom, align: :center, aria_id: nil, **attributes)
249
+ def initialize(include_blank: false, native: false, side: :bottom, align: :center, aria_id: nil, **attributes)
256
250
  @include_blank = include_blank
257
251
  @native = native
258
- @dir = dir
259
252
  @side = side
260
253
  @align = align
261
254
  @aria_id = aria_id
@@ -264,12 +257,13 @@ module ShadcnPhlexcomponents
264
257
 
265
258
  def view_template(&)
266
259
  div(
267
- class: "hidden fixed top-0 left-0 w-max z-50",
260
+ style: { display: "none" },
261
+ class: "fixed top-0 left-0 w-max z-50",
268
262
  data: { select_target: "contentContainer" },
269
263
  ) do
270
264
  div(**@attributes) do
271
265
  if @include_blank && !@native
272
- SelectItem(aria_id: @aria_id, value: "", class: "h-8", hide_icon: true) do
266
+ SelectItem(aria_id: @aria_id, value: "", class: "h-8") do
273
267
  @include_blank.is_a?(String) ? @include_blank : ""
274
268
  end
275
269
  end
@@ -282,7 +276,6 @@ module ShadcnPhlexcomponents
282
276
  def default_attributes
283
277
  {
284
278
  id: "#{@aria_id}-content",
285
- dir: @dir,
286
279
  tabindex: -1,
287
280
  role: "listbox",
288
281
  aria: {
@@ -316,14 +309,6 @@ module ShadcnPhlexcomponents
316
309
  def view_template(&)
317
310
  div(**@attributes, &)
318
311
  end
319
-
320
- def default_attributes
321
- {
322
- data: {
323
- select_target: "label",
324
- },
325
- }
326
- end
327
312
  end
328
313
 
329
314
  class SelectItem < Base
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ShadcnPhlexcomponents
4
4
  class Sheet < Base
5
- class_variants(base: "inline-block max-w-fit")
5
+ class_variants(base: "inline-flex max-w-fit")
6
6
 
7
7
  def initialize(open: false, **attributes)
8
8
  @open = open
@@ -42,12 +42,17 @@ module ShadcnPhlexcomponents
42
42
  {
43
43
  data: {
44
44
  controller: "dialog",
45
- },
46
- }
45
+ dialog_is_open_value: @open.to_s
46
+ }
47
+ }
47
48
  end
48
49
 
49
50
  def view_template(&)
50
- div(**@attributes, &)
51
+ div(**@attributes) do
52
+ overlay("dialog")
53
+
54
+ yield
55
+ end
51
56
  end
52
57
  end
53
58
 
@@ -66,10 +71,10 @@ module ShadcnPhlexcomponents
66
71
  expanded: false,
67
72
  controls: "#{@aria_id}-content",
68
73
  },
69
- data: {
74
+ data: {
70
75
  as_child: @as_child.to_s,
71
- action: "click->dialog#open",
72
76
  dialog_target: "trigger",
77
+ action: "click->dialog#open"
73
78
  },
74
79
  }
75
80
  end
@@ -95,7 +100,7 @@ module ShadcnPhlexcomponents
95
100
  base: <<~HEREDOC,
96
101
  bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4
97
102
  shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500
98
- pointer-events-auto
103
+ pointer-events-auto outline-none
99
104
  HEREDOC
100
105
  variants: {
101
106
  side: {
@@ -117,8 +122,7 @@ module ShadcnPhlexcomponents
117
122
  end
118
123
 
119
124
  def view_template(&)
120
- @class = @attributes.delete(:class)
121
- div(class: "#{@class} hidden", **@attributes) do
125
+ div(style: { display: "none" }, **@attributes) do
122
126
  yield
123
127
 
124
128
  button(
@@ -145,8 +149,8 @@ module ShadcnPhlexcomponents
145
149
  labelledby: "#{@aria_id}-title",
146
150
  },
147
151
  data: {
148
- dialog_target: "content",
149
- action: "dialog:click:outside->dialog#close",
152
+ state: "closed",
153
+ dialog_target: "content"
150
154
  },
151
155
  }
152
156
  end
@@ -10,7 +10,7 @@ module ShadcnPhlexcomponents
10
10
  end
11
11
 
12
12
  def view_template(&)
13
- div(class: "relative w-full overflow-x-auto", data: { shadcn_phlexcomponents: "table-container" }) do
13
+ div(class: "relative w-full overflow-x-auto") do
14
14
  table(**@attributes, &)
15
15
  end
16
16
  end
@@ -97,7 +97,7 @@ module ShadcnPhlexcomponents
97
97
  action: <<~HEREDOC,
98
98
  click->tabs#setActiveTab
99
99
  keydown.left->tabs#setActiveTab:prevent
100
- keydown.right->tabs#setActiveToNext:prevent
100
+ keydown.right->tabs#setActiveTab:prevent
101
101
  HEREDOC
102
102
  },
103
103
  }
@@ -3,7 +3,7 @@
3
3
  module ShadcnPhlexcomponents
4
4
  class ToastContainer < Base
5
5
  class_variants(
6
- base: "fixed z-[100] hidden has-[li]:flex flex-col gap-2",
6
+ base: "fixed z-50 hidden has-[li]:flex flex-col gap-2",
7
7
  variants: {
8
8
  side: {
9
9
  top_center: "top-6 left-1/2 -translate-x-1/2",
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShadcnPhlexcomponents
4
+ class Toggle < Base
5
+ class_variants(
6
+ base: <<~HEREDOC,
7
+ inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted
8
+ hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent
9
+ data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4
10
+ [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none
11
+ transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40
12
+ aria-invalid:border-destructive whitespace-nowrap
13
+ HEREDOC
14
+ variants: {
15
+ variant: {
16
+ default: "bg-transparent",
17
+ outline: "border border-input bg-transparent shadow-xs hover:bg-muted hover:text-muted-foreground",
18
+ },
19
+ size: {
20
+ default: "h-9 px-2 min-w-9",
21
+ sm: "h-8 px-1.5 min-w-8",
22
+ lg: "h-10 px-2.5 min-w-10",
23
+ },
24
+ },
25
+ defaults: {
26
+ variant: :default,
27
+ size: :default,
28
+ },
29
+ )
30
+
31
+ def initialize(variant: :default, size: :default, on: false, **attributes)
32
+ @class_variants = { variant: variant, size: size }
33
+ @on = on
34
+ super(**attributes)
35
+ end
36
+
37
+ def default_attributes
38
+ {
39
+ aria: {
40
+ pressed: @on.to_s,
41
+ },
42
+ data: {
43
+ controller: "toggle",
44
+ toggle_is_on_value: @on.to_s,
45
+ action: "click->toggle#toggle"
46
+ },
47
+ }
48
+ end
49
+
50
+ def view_template(&)
51
+ button(**@attributes, &)
52
+ end
53
+ end
54
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ShadcnPhlexcomponents
4
4
  class Tooltip < Base
5
- class_variants(base: "inline-block max-w-fit")
5
+ class_variants(base: "inline-flex max-w-fit")
6
6
 
7
7
  def initialize(open: false, **attributes)
8
8
  @open = open
@@ -93,7 +93,8 @@ module ShadcnPhlexcomponents
93
93
 
94
94
  def view_template(&)
95
95
  div(
96
- class: "hidden fixed top-0 left-0 w-max z-50",
96
+ style: { display: "none" },
97
+ class: "fixed top-0 left-0 w-max z-50",
97
98
  data: { tooltip_target: "contentContainer" },
98
99
  ) do
99
100
  div(**@attributes) do
@@ -3,9 +3,5 @@
3
3
  require "rails"
4
4
 
5
5
  module ShadcnPhlexcomponents
6
- class Engine < ::Rails::Engine
7
- config.app_generators do |g|
8
- g.template_engine(:shadcn_phlexcomponents)
9
- end
10
- end
6
+ class Engine < ::Rails::Engine; end
11
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShadcnPhlexcomponents
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.14"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadcn_phlexcomponents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Yeoh
@@ -74,17 +74,16 @@ files:
74
74
  - README.md
75
75
  - Rakefile
76
76
  - app/javascript/controllers/accordion_controller.ts
77
+ - app/javascript/controllers/alert_dialog_controller.ts
77
78
  - app/javascript/controllers/avatar_controller.ts
78
79
  - app/javascript/controllers/checkbox_controller.ts
79
80
  - app/javascript/controllers/collapsible_controller.ts
80
81
  - app/javascript/controllers/combobox_controller.ts
81
82
  - app/javascript/controllers/command_controller.ts
82
- - app/javascript/controllers/command_root_controller.ts
83
83
  - app/javascript/controllers/date_picker_controller.ts
84
84
  - app/javascript/controllers/date_range_picker_controller.ts
85
85
  - app/javascript/controllers/dialog_controller.ts
86
86
  - app/javascript/controllers/dropdown_menu_controller.ts
87
- - app/javascript/controllers/dropdown_menu_root_controller.ts
88
87
  - app/javascript/controllers/dropdown_menu_sub_controller.ts
89
88
  - app/javascript/controllers/form_field_controller.ts
90
89
  - app/javascript/controllers/hover_card_controller.ts
@@ -101,9 +100,13 @@ files:
101
100
  - app/javascript/controllers/theme_switcher_controller.ts
102
101
  - app/javascript/controllers/toast_container_controller.ts
103
102
  - app/javascript/controllers/toast_controller.ts
103
+ - app/javascript/controllers/toggle_controller.ts
104
+ - app/javascript/controllers/toggle_group_controller.ts
104
105
  - app/javascript/controllers/tooltip_controller.ts
105
106
  - app/javascript/shadcn_phlexcomponents.ts
106
- - app/javascript/utils.ts
107
+ - app/javascript/utils/command.ts
108
+ - app/javascript/utils/floating_ui.ts
109
+ - app/javascript/utils/index.ts
107
110
  - app/stylesheets/date_picker.css
108
111
  - app/stylesheets/nouislider.css
109
112
  - app/stylesheets/tw-animate.css
@@ -133,6 +136,7 @@ files:
133
136
  - lib/shadcn_phlexcomponents/components/form.rb
134
137
  - lib/shadcn_phlexcomponents/components/form/form_checkbox.rb
135
138
  - lib/shadcn_phlexcomponents/components/form/form_checkbox_group.rb
139
+ - lib/shadcn_phlexcomponents/components/form/form_combobox.rb
136
140
  - lib/shadcn_phlexcomponents/components/form/form_date_picker.rb
137
141
  - lib/shadcn_phlexcomponents/components/form/form_date_range_picker.rb
138
142
  - lib/shadcn_phlexcomponents/components/form/form_error.rb
@@ -165,6 +169,7 @@ files:
165
169
  - lib/shadcn_phlexcomponents/components/theme_switcher.rb
166
170
  - lib/shadcn_phlexcomponents/components/toast.rb
167
171
  - lib/shadcn_phlexcomponents/components/toast_container.rb
172
+ - lib/shadcn_phlexcomponents/components/toggle.rb
168
173
  - lib/shadcn_phlexcomponents/components/tooltip.rb
169
174
  - lib/shadcn_phlexcomponents/engine.rb
170
175
  - lib/shadcn_phlexcomponents/initializers/shadcn_phlexcomponents.rb