primer_view_components 0.26.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/app/assets/javascripts/app/components/primer/alpha/action_menu/action_menu_element.d.ts +0 -9
  4. data/app/assets/javascripts/app/components/primer/alpha/select_panel_element.d.ts +64 -0
  5. data/app/assets/javascripts/app/components/primer/aria_live.d.ts +8 -0
  6. data/app/assets/javascripts/app/components/primer/primer.d.ts +4 -0
  7. data/app/assets/javascripts/app/components/primer/shared_events.d.ts +9 -0
  8. data/app/assets/javascripts/primer_view_components.js +1 -1
  9. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  10. data/app/assets/styles/primer_view_components.css +1 -1
  11. data/app/assets/styles/primer_view_components.css.map +1 -1
  12. data/app/components/primer/alpha/action_list/item.rb +5 -3
  13. data/app/components/primer/alpha/action_list.css +1 -1
  14. data/app/components/primer/alpha/action_list.css.map +1 -1
  15. data/app/components/primer/alpha/action_list.pcss +1 -0
  16. data/app/components/primer/alpha/action_list.rb +14 -2
  17. data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +0 -9
  18. data/app/components/primer/alpha/action_menu/action_menu_element.ts +0 -11
  19. data/app/components/primer/alpha/action_menu.rb +17 -7
  20. data/app/components/primer/alpha/select_panel.html.erb +100 -0
  21. data/app/components/primer/alpha/select_panel.rb +473 -0
  22. data/app/components/primer/alpha/select_panel_element.d.ts +64 -0
  23. data/app/components/primer/alpha/select_panel_element.js +924 -0
  24. data/app/components/primer/alpha/select_panel_element.ts +1045 -0
  25. data/app/components/primer/alpha/text_field.css +1 -1
  26. data/app/components/primer/alpha/text_field.css.map +1 -1
  27. data/app/components/primer/aria_live.d.ts +8 -0
  28. data/app/components/primer/aria_live.js +38 -0
  29. data/app/components/primer/aria_live.ts +41 -0
  30. data/app/components/primer/base_component.rb +1 -1
  31. data/app/components/primer/focus_group.js +1 -1
  32. data/app/components/primer/focus_group.ts +1 -1
  33. data/app/components/primer/primer.d.ts +4 -0
  34. data/app/components/primer/primer.js +4 -0
  35. data/app/components/primer/primer.ts +4 -0
  36. data/app/components/primer/shared_events.d.ts +9 -0
  37. data/app/components/primer/shared_events.js +1 -0
  38. data/app/components/primer/shared_events.ts +10 -0
  39. data/app/forms/example_toggle_switch_form/example_field_caption.html.erb +1 -1
  40. data/lib/primer/classify/utilities.rb +13 -13
  41. data/lib/primer/forms/toggle_switch.html.erb +1 -2
  42. data/lib/primer/static/generate_info_arch.rb +3 -2
  43. data/lib/primer/view_components/version.rb +2 -2
  44. data/lib/primer/yard/component_manifest.rb +2 -0
  45. data/previews/primer/alpha/action_list_preview.rb +19 -0
  46. data/previews/primer/alpha/action_menu_preview.rb +1 -1
  47. data/previews/primer/alpha/select_panel_preview/_interaction_subject_js.html.erb +25 -0
  48. data/previews/primer/alpha/select_panel_preview/eventually_local_fetch.html.erb +16 -0
  49. data/previews/primer/alpha/select_panel_preview/eventually_local_fetch_initial_failure.html.erb +12 -0
  50. data/previews/primer/alpha/select_panel_preview/eventually_local_fetch_no_results.html.erb +16 -0
  51. data/previews/primer/alpha/select_panel_preview/footer_buttons.html.erb +23 -0
  52. data/previews/primer/alpha/select_panel_preview/local_fetch.html.erb +19 -0
  53. data/previews/primer/alpha/select_panel_preview/local_fetch_no_results.html.erb +15 -0
  54. data/previews/primer/alpha/select_panel_preview/multiselect.html.erb +17 -0
  55. data/previews/primer/alpha/select_panel_preview/multiselect_form.html.erb +31 -0
  56. data/previews/primer/alpha/select_panel_preview/playground.html.erb +19 -0
  57. data/previews/primer/alpha/select_panel_preview/remote_fetch.html.erb +16 -0
  58. data/previews/primer/alpha/select_panel_preview/remote_fetch_filter_failure.html.erb +13 -0
  59. data/previews/primer/alpha/select_panel_preview/remote_fetch_initial_failure.html.erb +12 -0
  60. data/previews/primer/alpha/select_panel_preview/remote_fetch_no_results.html.erb +16 -0
  61. data/previews/primer/alpha/select_panel_preview/single_select.html.erb +20 -0
  62. data/previews/primer/alpha/select_panel_preview/single_select_form.html.erb +33 -0
  63. data/previews/primer/alpha/select_panel_preview/with_avatar_items.html.erb +19 -0
  64. data/previews/primer/alpha/select_panel_preview/with_dynamic_label.html.erb +23 -0
  65. data/previews/primer/alpha/select_panel_preview/with_dynamic_label_and_aria_prefix.html.erb +24 -0
  66. data/previews/primer/alpha/select_panel_preview/with_leading_icons.html.erb +31 -0
  67. data/previews/primer/alpha/select_panel_preview/with_subtitle.html.erb +25 -0
  68. data/previews/primer/alpha/select_panel_preview/with_trailing_icons.html.erb +19 -0
  69. data/previews/primer/alpha/select_panel_preview.rb +239 -0
  70. data/static/arguments.json +136 -0
  71. data/static/audited_at.json +1 -0
  72. data/static/constants.json +22 -0
  73. data/static/info_arch.json +936 -117
  74. data/static/previews.json +307 -0
  75. data/static/statuses.json +1 -0
  76. metadata +39 -2
@@ -0,0 +1,239 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Primer
4
+ module Alpha
5
+ # @label SelectPanel
6
+ class SelectPanelPreview < ViewComponent::Preview
7
+ # @label Playground
8
+ #
9
+ # @param title text
10
+ # @param size [Symbol] select [auto, small, medium, medium_portrait, large, xlarge]
11
+ # @param simulate_failure toggle
12
+ # @param simulate_no_results toggle
13
+ # @param no_results_label text
14
+ # @param dynamic_label toggle
15
+ # @param dynamic_label_prefix text
16
+ # @param dynamic_aria_label_prefix text
17
+ # @param show_filter toggle
18
+ # @param open_on_load toggle
19
+ # @param anchor_align [Symbol] select [start, center, end]
20
+ # @param anchor_side [Symbol] select [outside_bottom, outside_top, outside_left, outside_right]
21
+ def playground(
22
+ title: "Sci-fi equipment",
23
+ subtitle: "Various tools from your favorite shows",
24
+ size: :auto,
25
+ simulate_failure: false,
26
+ simulate_no_results: false,
27
+ no_results_label: "No results found",
28
+ dynamic_label: false,
29
+ dynamic_label_prefix: nil,
30
+ dynamic_aria_label_prefix: nil,
31
+ show_filter: true,
32
+ open_on_load: false,
33
+ anchor_align: :start,
34
+ anchor_side: :outside_bottom
35
+ )
36
+ render_with_template(locals: {
37
+ subtitle: subtitle,
38
+ system_arguments: {
39
+ title: title,
40
+ size: size,
41
+ simulate_failure: simulate_failure,
42
+ simulate_no_results: simulate_no_results,
43
+ no_results_label: no_results_label,
44
+ dynamic_label: dynamic_label,
45
+ dynamic_label_prefix: dynamic_label_prefix,
46
+ dynamic_aria_label_prefix: dynamic_aria_label_prefix,
47
+ show_filter: show_filter,
48
+ open_on_load: open_on_load,
49
+ anchor_align: anchor_align,
50
+ anchor_side: anchor_side
51
+ }
52
+ })
53
+ end
54
+
55
+ # @label Default
56
+ #
57
+ # @snapshot interactive
58
+ # @param open_on_load toggle
59
+ def default(open_on_load: false)
60
+ render_with_template(template: "primer/alpha/select_panel_preview/local_fetch", locals: {
61
+ open_on_load: open_on_load
62
+ })
63
+ end
64
+
65
+ # @!group Fetch strategies
66
+
67
+ # @label Local fetch
68
+ #
69
+ # @snapshot interactive
70
+ # @param open_on_load toggle
71
+ def local_fetch(open_on_load: false)
72
+ render_with_template(locals: { open_on_load: open_on_load })
73
+ end
74
+
75
+ # @label Eventually local fetch
76
+ #
77
+ # @snapshot interactive
78
+ # @param open_on_load toggle
79
+ def eventually_local_fetch(open_on_load: false)
80
+ render_with_template(locals: { open_on_load: open_on_load })
81
+ end
82
+
83
+ # @label Remote fetch
84
+ #
85
+ # @snapshot interactive
86
+ # @param open_on_load toggle
87
+ def remote_fetch(open_on_load: false)
88
+ render_with_template(locals: { open_on_load: open_on_load })
89
+ end
90
+
91
+ # @label Local fetch (no results)
92
+ #
93
+ # @snapshot interactive
94
+ # @param open_on_load toggle
95
+ def local_fetch_no_results(open_on_load: false)
96
+ render_with_template(locals: { open_on_load: open_on_load })
97
+ end
98
+
99
+ # @label Eventually local fetch (no results)
100
+ #
101
+ # @snapshot interactive
102
+ # @param open_on_load toggle
103
+ def eventually_local_fetch_no_results(open_on_load: false)
104
+ render_with_template(locals: { open_on_load: open_on_load })
105
+ end
106
+
107
+ # @label Remote fetch (no results)
108
+ #
109
+ # @snapshot interactive
110
+ # @param open_on_load toggle
111
+ def remote_fetch_no_results(open_on_load: false)
112
+ render_with_template(locals: { open_on_load: open_on_load })
113
+ end
114
+
115
+ # @!endgroup
116
+
117
+ # @label Single select
118
+ #
119
+ # @snapshot interactive
120
+ # @param dynamic_label toggle
121
+ # @param open_on_load toggle
122
+ def single_select(dynamic_label: false, open_on_load: false)
123
+ render_with_template(locals: { dynamic_label: dynamic_label, open_on_load: open_on_load })
124
+ end
125
+
126
+ # @label Multiselect
127
+ #
128
+ # @snapshot interactive
129
+ # @param open_on_load toggle
130
+ def multiselect(open_on_load: false)
131
+ render_with_template(locals: { open_on_load: open_on_load })
132
+ end
133
+
134
+ # @!group Dynamic label
135
+
136
+ # @label With dynamic label
137
+ #
138
+ # @snapshot interactive
139
+ # @param open_on_load toggle
140
+ def with_dynamic_label(open_on_load: false)
141
+ render_with_template(locals: { open_on_load: open_on_load })
142
+ end
143
+
144
+ # @label With dynamic label and aria prefix
145
+ #
146
+ # @snapshot interactive
147
+ # @param open_on_load toggle
148
+ def with_dynamic_label_and_aria_prefix(open_on_load: false)
149
+ render_with_template(locals: { open_on_load: open_on_load })
150
+ end
151
+
152
+ # @!endgroup
153
+
154
+ # @label Footer buttons
155
+ #
156
+ # @snapshot interactive
157
+ # @param open_on_load toggle
158
+ def footer_buttons(open_on_load: false)
159
+ render_with_template(locals: { open_on_load: open_on_load })
160
+ end
161
+
162
+ # @label With avatar items
163
+ #
164
+ # @snapshot interactive
165
+ # @param open_on_load toggle
166
+ def with_avatar_items(open_on_load: false)
167
+ render_with_template(locals: { open_on_load: open_on_load })
168
+ end
169
+
170
+ # @!group With icons
171
+
172
+ # @label With leading icons
173
+ #
174
+ # @snapshot interactive
175
+ # @param open_on_load toggle
176
+ def with_leading_icons(open_on_load: false)
177
+ render_with_template(locals: { open_on_load: open_on_load })
178
+ end
179
+
180
+ # @label With trailing icons
181
+ #
182
+ # @snapshot interactive
183
+ # @param open_on_load toggle
184
+ def with_trailing_icons(open_on_load: false)
185
+ render_with_template(locals: { open_on_load: open_on_load })
186
+ end
187
+
188
+ # @!endgroup
189
+
190
+ # @label With subtitle
191
+ #
192
+ # @snapshot interactive
193
+ # @param open_on_load toggle
194
+ def with_subtitle(open_on_load: false)
195
+ render_with_template(locals: { open_on_load: open_on_load })
196
+ end
197
+
198
+ # @label Remote fetch initial failure
199
+ #
200
+ # @snapshot interactive
201
+ # @param open_on_load toggle
202
+ def remote_fetch_initial_failure(open_on_load: false)
203
+ render_with_template(locals: { open_on_load: open_on_load })
204
+ end
205
+
206
+ # @label Remote fetch filter failure
207
+ #
208
+ # @snapshot interactive
209
+ # @param open_on_load toggle
210
+ def remote_fetch_filter_failure(open_on_load: false)
211
+ render_with_template(locals: { open_on_load: open_on_load })
212
+ end
213
+
214
+ # @label Eventually local fetch initial failure
215
+ #
216
+ # @snapshot interactive
217
+ # @param open_on_load toggle
218
+ def eventually_local_fetch_initial_failure(open_on_load: false)
219
+ render_with_template(locals: { open_on_load: open_on_load })
220
+ end
221
+
222
+ # @label Single-select form
223
+ #
224
+ # @snapshot interactive
225
+ # @param open_on_load toggle
226
+ def single_select_form(open_on_load: false, route_format: :html)
227
+ render_with_template(locals: { open_on_load: open_on_load, route_format: route_format })
228
+ end
229
+
230
+ # @label Multi-select form
231
+ #
232
+ # @snapshot interactive
233
+ # @param open_on_load toggle
234
+ def multiselect_form(open_on_load: false, route_format: :html)
235
+ render_with_template(locals: { open_on_load: open_on_load, route_format: route_format })
236
+ end
237
+ end
238
+ end
239
+ end
@@ -104,6 +104,12 @@
104
104
  "default": "`:none`",
105
105
  "description": "How items may be selected in the list. One of `:multiple`, `:multiple_checkbox`, `:none`, or `:single`."
106
106
  },
107
+ {
108
+ "name": "aria_selection_variant",
109
+ "type": "Symbol",
110
+ "default": "`:checked`",
111
+ "description": "Specifies which aria selection to use. <%= one_of(Primer::Alpha::ActionList::ARIA_SELECTION_VARIANT_OPTIONS) %?"
112
+ },
107
113
  {
108
114
  "name": "form_arguments",
109
115
  "type": "Hash",
@@ -383,6 +389,12 @@
383
389
  "default": "`{}`",
384
390
  "description": "Allows an `ActionMenu` to act as a select list in multi- and single-select modes. Pass the `builder:` and `name:` options to this hash. `builder:` should be an instance of `ActionView::Helpers::FormBuilder`, which are created by the standard Rails `#form_with` and `#form_for` helpers. The `name:` option is the desired name of the field that will be included in the params sent to the server on form submission."
385
391
  },
392
+ {
393
+ "name": "overlay_arguments",
394
+ "type": "Hash",
395
+ "default": "`{}`",
396
+ "description": "Arguments to pass to the underlying [Overlay](/components/alpha/overlay)"
397
+ },
386
398
  {
387
399
  "name": "system_arguments",
388
400
  "type": "Hash",
@@ -435,6 +447,12 @@
435
447
  "default": "`:none`",
436
448
  "description": "How items may be selected in the list. One of `:multiple`, `:multiple_checkbox`, `:none`, or `:single`."
437
449
  },
450
+ {
451
+ "name": "aria_selection_variant",
452
+ "type": "Symbol",
453
+ "default": "`:checked`",
454
+ "description": "Specifies which aria selection to use. <%= one_of(Primer::Alpha::ActionList::ARIA_SELECTION_VARIANT_OPTIONS) %?"
455
+ },
438
456
  {
439
457
  "name": "form_arguments",
440
458
  "type": "Hash",
@@ -2334,6 +2352,124 @@
2334
2352
  }
2335
2353
  ]
2336
2354
  },
2355
+ {
2356
+ "component": "SelectPanel",
2357
+ "status": "alpha",
2358
+ "a11y_reviewed": false,
2359
+ "short_name": "SelectPanel",
2360
+ "source": "https://github.com/primer/view_components/tree/main/app/components/primer/alpha/select_panel.rb",
2361
+ "lookbook": "https://primer.style/view-components/lookbook/inspect/primer/alpha/select_panel/default/",
2362
+ "parameters": [
2363
+ {
2364
+ "name": "src",
2365
+ "type": "String",
2366
+ "default": "`nil`",
2367
+ "description": "The URL to fetch search results from."
2368
+ },
2369
+ {
2370
+ "name": "title",
2371
+ "type": "String",
2372
+ "default": "`\"Menu\"`",
2373
+ "description": "The title that appears at the top of the panel."
2374
+ },
2375
+ {
2376
+ "name": "id",
2377
+ "type": "String",
2378
+ "default": "`self.class.generate_id`",
2379
+ "description": "The unique ID of the panel."
2380
+ },
2381
+ {
2382
+ "name": "size",
2383
+ "type": "Symbol",
2384
+ "default": "`:small`",
2385
+ "description": "The size of the panel. One of `:auto`, `:large`, `:medium`, `:medium_portrait`, `:small`, or `:xlarge`."
2386
+ },
2387
+ {
2388
+ "name": "select_variant",
2389
+ "type": "Symbol",
2390
+ "default": "`:single`",
2391
+ "description": "One of `:multiple`, `:multiple_checkbox`, `:none`, or `:single`."
2392
+ },
2393
+ {
2394
+ "name": "fetch_strategy",
2395
+ "type": "Symbol",
2396
+ "default": "`:remote`",
2397
+ "description": "One of `:eventually_local`, `:local`, or `:remote`."
2398
+ },
2399
+ {
2400
+ "name": "no_results_label",
2401
+ "type": "String",
2402
+ "default": "`\"No results found\"`",
2403
+ "description": "The label to display when no results are found."
2404
+ },
2405
+ {
2406
+ "name": "preload",
2407
+ "type": "Boolean",
2408
+ "default": "`false`",
2409
+ "description": "Whether to preload search results when the page loads. If this option is false, results are loaded when the panel is opened."
2410
+ },
2411
+ {
2412
+ "name": "dynamic_label",
2413
+ "type": "Boolean",
2414
+ "default": "`false`",
2415
+ "description": "Whether or not to display the text of the currently selected item in the show button."
2416
+ },
2417
+ {
2418
+ "name": "dynamic_label_prefix",
2419
+ "type": "String",
2420
+ "default": "`nil`",
2421
+ "description": "If provided, the prefix is prepended to the dynamic label and displayed in the show button."
2422
+ },
2423
+ {
2424
+ "name": "dynamic_aria_label_prefix",
2425
+ "type": "String",
2426
+ "default": "`nil`",
2427
+ "description": "If provided, the prefix is prepended to the dynamic label and set as the value of the `aria-label` attribute on the show button."
2428
+ },
2429
+ {
2430
+ "name": "body_id",
2431
+ "type": "String",
2432
+ "default": "`nil`",
2433
+ "description": "The unique ID of the panel body. If not provided, the body ID will be set to the panel ID with a \"-body\" suffix."
2434
+ },
2435
+ {
2436
+ "name": "list_arguments",
2437
+ "type": "Hash",
2438
+ "default": "`{}`",
2439
+ "description": "Arguments to pass to the underlying [ActionList](/components/alpha/actionlist) component. Only has an effect for the local fetch strategy."
2440
+ },
2441
+ {
2442
+ "name": "form_arguments",
2443
+ "type": "Hash",
2444
+ "default": "`{}`",
2445
+ "description": "Form arguments to pass to the underlying [ActionList](/components/alpha/actionlist) component. Only has an effect for the local fetch strategy."
2446
+ },
2447
+ {
2448
+ "name": "show_filter",
2449
+ "type": "Boolean",
2450
+ "default": "`true`",
2451
+ "description": "Whether or not to show the filter input."
2452
+ },
2453
+ {
2454
+ "name": "open_on_load",
2455
+ "type": "Boolean",
2456
+ "default": "`false`",
2457
+ "description": "Open the panel when the page loads."
2458
+ },
2459
+ {
2460
+ "name": "anchor_align",
2461
+ "type": "Symbol",
2462
+ "default": "`:start`",
2463
+ "description": "The anchor alignment of the Overlay. One of `:center`, `:end`, or `:start`."
2464
+ },
2465
+ {
2466
+ "name": "anchor_side",
2467
+ "type": "Symbol",
2468
+ "default": "`:outside_bottom`",
2469
+ "description": "The side to anchor the Overlay to. One of `:inside_bottom`, `:inside_center`, `:inside_left`, `:inside_right`, `:inside_top`, `:outside_bottom`, `:outside_left`, `:outside_right`, or `:outside_top`."
2470
+ }
2471
+ ]
2472
+ },
2337
2473
  {
2338
2474
  "component": "SubmitButton",
2339
2475
  "status": "alpha",
@@ -52,6 +52,7 @@
52
52
  "Primer::Alpha::SegmentedControl": "2023-02-01",
53
53
  "Primer::Alpha::SegmentedControl::Item": "2023-02-01",
54
54
  "Primer::Alpha::Select": "",
55
+ "Primer::Alpha::SelectPanel": "",
55
56
  "Primer::Alpha::SubmitButton": "",
56
57
  "Primer::Alpha::TabContainer": "",
57
58
  "Primer::Alpha::TabNav": "",
@@ -19,6 +19,11 @@
19
19
  "Primer::Alpha::ActionBar::Item": {
20
20
  },
21
21
  "Primer::Alpha::ActionList": {
22
+ "ARIA_SELECTION_VARIANT_OPTIONS": [
23
+ "selected",
24
+ "checked"
25
+ ],
26
+ "DEFAULT_ARIA_SELECTION_VARIANT": "checked",
22
27
  "DEFAULT_MENU_ITEM_ROLE": "menuitem",
23
28
  "DEFAULT_ROLE": "list",
24
29
  "DEFAULT_SCHEME": "full",
@@ -27,6 +32,7 @@
27
32
  "FormWrapper": "Primer::Alpha::ActionList::FormWrapper",
28
33
  "Heading": "Primer::Alpha::ActionList::Heading",
29
34
  "Item": "Primer::Alpha::ActionList::Item",
35
+ "LIST_BOX_ITEM_ROLE": "option",
30
36
  "MENU_ROLE": "menu",
31
37
  "SCHEME_MAPPINGS": {
32
38
  "full": null,
@@ -591,6 +597,22 @@
591
597
  },
592
598
  "Primer::Alpha::Select": {
593
599
  },
600
+ "Primer::Alpha::SelectPanel": {
601
+ "DEFAULT_FETCH_STRATEGY": "remote",
602
+ "DEFAULT_PRELOAD": false,
603
+ "DEFAULT_SELECT_VARIANT": "single",
604
+ "FETCH_STRATEGIES": [
605
+ "remote",
606
+ "eventually_local",
607
+ "local"
608
+ ],
609
+ "ItemList": "Primer::Alpha::ActionList",
610
+ "SELECT_VARIANT_OPTIONS": [
611
+ "single",
612
+ "multiple",
613
+ "none"
614
+ ]
615
+ },
594
616
  "Primer::Alpha::SubmitButton": {
595
617
  },
596
618
  "Primer::Alpha::TabContainer": {