openproject-primer_view_components 0.41.1 → 0.43.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -0
- data/app/assets/javascripts/app/components/primer/alpha/select_panel_element.d.ts +0 -1
- data/app/assets/javascripts/app/components/primer/shared_events.d.ts +2 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list/item.html.erb +1 -5
- data/app/components/primer/alpha/action_list/item.rb +10 -3
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +33 -50
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_menu/action_menu_element.js +20 -7
- data/app/components/primer/alpha/action_menu/action_menu_element.ts +20 -7
- data/app/components/primer/alpha/auto_complete.css +1 -1
- data/app/components/primer/alpha/auto_complete.css.json +3 -5
- data/app/components/primer/alpha/auto_complete.css.map +1 -1
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.json +5 -5
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/button_marketing.css +1 -1
- data/app/components/primer/alpha/button_marketing.css.json +1 -4
- data/app/components/primer/alpha/button_marketing.css.map +1 -1
- data/app/components/primer/alpha/dialog.css +1 -1
- data/app/components/primer/alpha/dialog.css.json +7 -7
- data/app/components/primer/alpha/dialog.css.map +1 -1
- data/app/components/primer/alpha/layout.css +1 -1
- data/app/components/primer/alpha/layout.css.json +9 -15
- data/app/components/primer/alpha/layout.css.map +1 -1
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.json +1 -3
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.json +5 -5
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.pcss +1 -0
- data/app/components/primer/alpha/select_panel.rb +5 -4
- data/app/components/primer/alpha/select_panel_element.d.ts +0 -1
- data/app/components/primer/alpha/select_panel_element.js +55 -26
- data/app/components/primer/alpha/select_panel_element.ts +53 -29
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.json +1 -3
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.json +37 -78
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.json +1 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.rb +2 -1
- data/app/components/primer/alpha/tool_tip.js +2 -2
- data/app/components/primer/alpha/tool_tip.ts +2 -2
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.json +2 -4
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/beta/avatar_stack.css +1 -1
- data/app/components/primer/beta/avatar_stack.css.json +8 -8
- data/app/components/primer/beta/avatar_stack.css.map +1 -1
- data/app/components/primer/beta/border_box.css +1 -1
- data/app/components/primer/beta/border_box.css.json +4 -4
- data/app/components/primer/beta/border_box.css.map +1 -1
- data/app/components/primer/beta/breadcrumbs.css +1 -1
- data/app/components/primer/beta/breadcrumbs.css.json +1 -2
- data/app/components/primer/beta/breadcrumbs.css.map +1 -1
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.json +6 -8
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button_group.css +1 -1
- data/app/components/primer/beta/button_group.css.json +3 -3
- data/app/components/primer/beta/button_group.css.map +1 -1
- data/app/components/primer/beta/label.css +1 -1
- data/app/components/primer/beta/label.css.json +1 -2
- data/app/components/primer/beta/label.css.map +1 -1
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +1 -3
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/popover.css +1 -1
- data/app/components/primer/beta/popover.css.json +16 -22
- data/app/components/primer/beta/popover.css.map +1 -1
- data/app/components/primer/beta/relative_time.rb +4 -4
- data/app/components/primer/beta/spinner.html.erb +1 -1
- data/app/components/primer/beta/state.css +1 -1
- data/app/components/primer/beta/state.css.map +1 -1
- data/app/components/primer/beta/state.pcss +4 -0
- data/app/components/primer/beta/truncate.css +1 -1
- data/app/components/primer/beta/truncate.css.json +5 -5
- data/app/components/primer/beta/truncate.css.map +1 -1
- data/app/components/primer/open_project/side_panel/section.css +1 -1
- data/app/components/primer/open_project/side_panel/section.css.json +1 -2
- data/app/components/primer/open_project/side_panel/section.css.map +1 -1
- data/app/components/primer/shared_events.d.ts +2 -0
- data/app/components/primer/shared_events.ts +2 -0
- data/lib/primer/forms/primer_text_field.js +3 -0
- data/lib/primer/forms/primer_text_field.ts +4 -0
- data/lib/primer/view_components/linters/details_menu_migration.rb +30 -1
- data/lib/primer/view_components/linters/tooltipped_migration.rb +1 -1
- data/lib/primer/view_components/version.rb +2 -2
- data/previews/primer/alpha/action_list_preview.rb +1 -1
- data/previews/primer/alpha/select_panel_preview/list_of_links.html.erb +16 -0
- data/previews/primer/alpha/select_panel_preview/no_values.html.erb +19 -0
- data/previews/primer/alpha/select_panel_preview/playground.html.erb +2 -1
- data/previews/primer/alpha/select_panel_preview/remote_fetch.html.erb +4 -1
- data/previews/primer/alpha/select_panel_preview/single_select.html.erb +4 -4
- data/previews/primer/alpha/select_panel_preview.rb +23 -7
- data/static/arguments.json +6 -6
- data/static/classes.json +39 -21
- data/static/info_arch.json +72 -13
- data/static/previews.json +26 -0
- metadata +4 -2
data/static/info_arch.json
CHANGED
@@ -989,9 +989,20 @@
|
|
989
989
|
"slots": [
|
990
990
|
{
|
991
991
|
"name": "description",
|
992
|
-
"description": "Description content that complements the item's label
|
992
|
+
"description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
|
993
993
|
"parameters": [
|
994
|
-
|
994
|
+
{
|
995
|
+
"name": "legacy_content",
|
996
|
+
"type": "String",
|
997
|
+
"default": "N/A",
|
998
|
+
"description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
|
999
|
+
},
|
1000
|
+
{
|
1001
|
+
"name": "test_selector",
|
1002
|
+
"type": "String",
|
1003
|
+
"default": "N/A",
|
1004
|
+
"description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
|
1005
|
+
}
|
995
1006
|
]
|
996
1007
|
},
|
997
1008
|
{
|
@@ -5547,9 +5558,20 @@
|
|
5547
5558
|
},
|
5548
5559
|
{
|
5549
5560
|
"name": "description",
|
5550
|
-
"description": "Description content that complements the item's label
|
5561
|
+
"description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
|
5551
5562
|
"parameters": [
|
5552
|
-
|
5563
|
+
{
|
5564
|
+
"name": "legacy_content",
|
5565
|
+
"type": "String",
|
5566
|
+
"default": "N/A",
|
5567
|
+
"description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
|
5568
|
+
},
|
5569
|
+
{
|
5570
|
+
"name": "test_selector",
|
5571
|
+
"type": "String",
|
5572
|
+
"default": "N/A",
|
5573
|
+
"description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
|
5574
|
+
}
|
5553
5575
|
]
|
5554
5576
|
},
|
5555
5577
|
{
|
@@ -7511,7 +7533,7 @@
|
|
7511
7533
|
},
|
7512
7534
|
{
|
7513
7535
|
"fully_qualified_name": "Primer::Alpha::SelectPanel",
|
7514
|
-
"description": "Select panels allow for selecting from a large number of options and can be thought of as a more capable\nversion of the traditional HTML `<select>` element.\n\nSelect panels:\n\n1. feature an input field at the top that allows an end user to filter the list of results.\n1. can render their items statically or dynamically by fetching results from the server.\n1. allow selecting a single item or multiple items.\n1. permit leading visuals like Octicons, avatars, and custom SVGs.\n1. can be used as form inputs in Rails forms.\n\n## Static list items\n\nThe Rails `SelectPanel` component allows items to be provided statically or loaded dynamically from the\nserver. Providing items statically is done using a fetch strategy of `:local` in combination with the\n`item` slot:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel.new(fetch_strategy: :local))) do |panel| %>\n <% panel.with_show_button { \"Select item\" } %>\n <% panel.with_item(label: \"Item 1\") %>\n <% panel.with_item(label: \"Item 2\") %>\n<% end %>\n```\n\n## Dynamic list items\n\nList items can also be fetched dynamically from the server and will require creating a Rails controller action\nto respond with the list of items in addition to rendering the `SelectPanel` instance. Render the instance as\nnormal, providing your desired [fetch strategy](#fetch-strategies):\n\n```erb\n<%= render(\n Primer::Alpha::SelectPanel.new(\n fetch_strategy: :remote,\n src: search_items_path # perhaps a Rails URL helper\n )\n) %>\n```\n\nDefine a controller action to serve the list of items. The `SelectPanel` component passes any filter text in\nthe `q=` URL parameter.\n\n```ruby\nclass SearchItemsController < ApplicationController\n def show\n # NOTE: params[:q] may be nil since there is no filter string available\n # when the panel is first opened\n @results = SomeModel.search(params[:q] || \"\")\n end\nend\n```\n\nResponses must be HTML fragments, eg. have a content type of `text/html+fragment`. This content type isn't\navailable by default in Rails, so you may have to register it eg. in an initializer:\n\n```ruby\nMime::Type.register(\"text/fragment+html\", :html_fragment)\n```\n\nRender a `Primer::Alpha::SelectPanel::ItemList` in the action's template, search_items/show.html_fragment.erb:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel::ItemList.new) do |list| %>\n <% @results.each do |result| %>\n <% list.with_item(label: result.title) do |item| %>\n <% item.with_description(result.description) %>\n <% end %>\n <% end %>\n<% end %>\n```\n\n### Selection consistency\n\nThe `SelectPanel` component automatically \"remembers\" which items have been selected across item fetch requests,\nmeaning the controller that renders dynamic list items does not (and should not) remember these selections or\npersist them until the user has confirmed them, either by submitting the form or otherwise indicating completion.\nThe `SelectPanel` component does not include unconfirmed selection data in requests.\n\n## Fetch strategies\n\nThe list of items can be fetched from a remote URL, or provided as a static list, configured using the\n`fetch_strategy` attribute. Fetch strategies are summarized below.\n\n1. `:remote`: a query is made to the URL in the `src` attribute every time the input field changes.\n\n2. `:eventually_local`: a query is made to the URL in the `src` attribute when the panel is first opened. The\n results are \"remembered\" and filtered in-memory for all subsequent filter operations, i.e. when the input\n field changes.\n\n3. `:local`: the list of items is provided statically ahead of time and filtered in-memory. No requests are made\n to the server.\n\n## Customizing filter behavior\n\nIf the fetch strategy is `:remote`, then filtering is handled server-side. The server should render a\n`Primer::Alpha::SelectPanel::ItemList` (an alias of {{#link_to_component}}Primer::Alpha::ActionList{{/link_to_component}})\nin the response containing the filtered list of items. The component achieves remote fetching via the\n[remote-input-element](https://github.com/github/remote-input-element), which sends a request to the\nserver with the filter string in the `q=` parameter. Responses must be HTML fragments, eg. have a content\ntype of `text/html+fragment`.\n\n### Local filtering\n\nIf the fetch strategy is `:local` or `:eventually_local`, filtering is performed client-side. Filter behavior can\nbe customized in JavaScript by setting the `filterFn` attribute on the instance of `SelectPanelElement`, eg:\n\n```javascript\ndocument.querySelector(\"select-panel\").filterFn = (item: HTMLElement, query: string): boolean => {\n // return true if the item should be displayed, false otherwise\n}\n```\n\nThe element's default filter function uses the value of the `data-filter-string` attribute, falling back to the\nelement's `innerText` property. It performs a case-insensitive substring match against the filter string.\n\n### `SelectPanel`s as form inputs\n\n`SelectPanel`s can be used as form inputs. They behave very similarly to how HTML `<select>` boxes behave, and\nplay nicely with Rails' built-in form mechanisms. Pass arguments via the `form_arguments:` argument, including\nthe Rails form builder object and the name of the field. Each list item must also have a value specified in\n`content_arguments: { data: { value: } }`.\n\n```erb\n<% form_with(model: Address.new) do |f| %>\n <%= render(Primer::Alpha::SelectPanel.new(form_arguments: { builder: f, name: \"country\" })) do |menu| %>\n <% countries.each do |country|\n <% menu.with_item(label: country.name, content_arguments: { data: { value: country.code } }) %>\n <% end %>\n <% end %>\n<% end %>\n```\n\nThe value of the `data: { value: ... }` argument is sent to the server on submit, keyed using the name provided above\n(eg. `\"country\"`). If no value is provided for an item, the value of that item is the item's label. Here's the\ncorresponding `AddressesController` that might be written to handle the form above:\n\n```ruby\nclass AddressesController < ApplicationController\n def create\n puts \"You chose #{address_params[:country]} as your country\"\n end\n\n private\n\n def address_params\n params.require(:address).permit(:country)\n end\nend\n```\n\nIf items are provided dynamically, things become a bit more complicated. The `form_for` or `form_with` method call\nhappens in the view that renders the `SelectPanel`, which means the form builder object but isn't available in the\nview that renders the list items. In such a case, it can be useful to create an instance of the form builder maually:\n\n```erb\n<% builder = ActionView::Helpers::FormBuilder.new(\n \"address\", # the name of the model, used to wrap input names, eg 'address[country_code]'\n nil, # object (eg. the Address instance, which we can omit)\n self, # template\n {} # options\n) %>\n<%= render(Primer::Alpha::SelectPanel::ItemList.new(\n form_arguments: { builder: builder, name: \"country\" }\n)) do |list| %>\n <% countries.each do |country| %>\n <% menu.with_item(label: country.name, data: { value: country.code }) %>\n <% end %>\n<% end %>\n```\n\n### JavaScript API\n\n`SelectPanel`s render a `<select-panel>` custom element that exposes behavior to the client.\n\n#### Utility methods\n\n* `show()`: Manually open the panel. Under normal circumstances, a show button is used to show the panel, but this method exists to support unusual use-cases.\n* `hide()`: Manually hides (closes) the panel.\n\n#### Query methods\n\n* `getItemById(itemId: string): Element`: Returns the item's HTML `<li>` element. The return value can be passed as the `item` argument to the other methods listed below.\n* `isItemChecked(item: Element): boolean`: Returns `true` if the item is checked, `false` otherwise.\n* `isItemHidden(item: Element): boolean`: Returns `true` if the item is hidden, `false` otherwise.\n* `isItemDisabled(item: Element): boolean`: Returns `true` if the item is disabled, `false` otherwise.\n\nNOTE: Item IDs are special values provided by the user that are attached to `SelectPanel` list items as the `data-item-id`\nHTML attribute. Item IDs can be provided by passing an `item_id:` attribute when adding items to the panel, eg:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel.new) do |panel| %>\n <% panel.with_item(item_id: \"my-id\") %>\n<% end %>\n```\n\nThe same is true when rendering `ItemList`s:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel::ItemList.new) do |list| %>\n <% list.with_item(item_id: \"my-id\") %>\n<% end %>\n```\n\n#### State methods\n\n* `enableItem(item: Element)`: Enables the item, i.e. makes it clickable by the mouse and keyboard.\n* `disableItem(item: Element)`: Disables the item, i.e. makes it unclickable by the mouse and keyboard.\n* `checkItem(item: Element)`: Checks the item. Only has an effect in single- and multi-select modes.\n* `uncheckItem(item: Element)`: Unchecks the item. Only has an effect in multi-select mode, since items cannot be unchecked in single-select mode.\n\n#### Events\n\n|Name |Type |Bubbles |Cancelable |\n|:--------------------|:------------------------------------------|:-------|:----------|\n|`itemActivated` |`CustomEvent<ItemActivatedEvent>` |Yes |No |\n|`beforeItemActivated`|`CustomEvent<ItemActivatedEvent>` |Yes |Yes |\n|`dialog:open` |`CustomEvent<{dialog: HTMLDialogElement}>` |No |No |\n|`panelClosed` |`CustomEvent<{panel: SelectPanelElement}>` |Yes |No |\n\n_Item activation_\n\nThe `<select-panel>` element fires an `itemActivated` event whenever an item is activated (eg. clicked) via the mouse or keyboard.\n\n```typescript\ndocument.querySelector(\"select-panel\").addEventListener(\n \"itemActivated\",\n (event: CustomEvent<ItemActivatedEvent>) => {\n event.detail.item // Element: the <li> item that was activated\n event.detail.checked // boolean: whether or not the result of the activation checked the item\n }\n)\n```\n\nThe `beforeItemActivated` event fires before an item is activated. Canceling this event will prevent the item\nfrom being activated.\n\n```typescript\ndocument.querySelector(\"select-panel\").addEventListener(\n \"beforeItemActivated\",\n (event: CustomEvent<ItemActivatedEvent>) => {\n event.detail.item // Element: the <li> item that was activated\n event.detail.checked // boolean: whether or not the result of the activation checked the item\n event.preventDefault() // Cancel the event to prevent activation (eg. checking/unchecking)\n }\n)\n```",
|
7536
|
+
"description": "Select panels allow for selecting from a large number of options and can be thought of as a more capable\nversion of the traditional HTML `<select>` element.\n\nSelect panels:\n\n1. feature an input field at the top that allows an end user to filter the list of results.\n1. can render their items statically or dynamically by fetching results from the server.\n1. allow selecting a single item or multiple items.\n1. permit leading visuals like Octicons, avatars, and custom SVGs.\n1. can be used as form inputs in Rails forms.\n\n## Static list items\n\nThe Rails `SelectPanel` component allows items to be provided statically or loaded dynamically from the\nserver. Providing items statically is done using a fetch strategy of `:local` in combination with the\n`item` slot:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel.new(fetch_strategy: :local))) do |panel| %>\n <% panel.with_show_button { \"Select item\" } %>\n <% panel.with_item(label: \"Item 1\") %>\n <% panel.with_item(label: \"Item 2\") %>\n<% end %>\n```\n\n## Dynamic list items\n\nList items can also be fetched dynamically from the server and will require creating a Rails controller action\nto respond with the list of items in addition to rendering the `SelectPanel` instance. Render the instance as\nnormal, providing your desired [fetch strategy](#fetch-strategies):\n\n```erb\n<%= render(\n Primer::Alpha::SelectPanel.new(\n fetch_strategy: :remote,\n src: search_items_path # perhaps a Rails URL helper\n )\n) %>\n```\n\nDefine a controller action to serve the list of items. The `SelectPanel` component passes any filter text in\nthe `q=` URL parameter.\n\n```ruby\nclass SearchItemsController < ApplicationController\n def show\n # NOTE: params[:q] may be nil since there is no filter string available\n # when the panel is first opened\n @results = SomeModel.search(params[:q] || \"\")\n end\nend\n```\n\nResponses must be HTML fragments, eg. have a content type of `text/html+fragment`. This content type isn't\navailable by default in Rails, so you may have to register it eg. in an initializer:\n\n```ruby\nMime::Type.register(\"text/fragment+html\", :html_fragment)\n```\n\nRender a `Primer::Alpha::SelectPanel::ItemList` in the action's template, search_items/show.html_fragment.erb:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel::ItemList.new) do |list| %>\n <% @results.each do |result| %>\n <% list.with_item(label: result.title) do |item| %>\n <% item.with_description(result.description) %>\n <% end %>\n <% end %>\n<% end %>\n```\n\n### Selection consistency\n\nThe `SelectPanel` component automatically \"remembers\" which items have been selected across item fetch requests,\nmeaning the controller that renders dynamic list items does not (and should not) remember these selections or\npersist them until the user has confirmed them, either by submitting the form or otherwise indicating completion.\nThe `SelectPanel` component does not include unconfirmed selection data in requests.\n\n## Fetch strategies\n\nThe list of items can be fetched from a remote URL, or provided as a static list, configured using the\n`fetch_strategy` attribute. Fetch strategies are summarized below.\n\n1. `:remote`: a query is made to the URL in the `src` attribute every time the input field changes.\n\n2. `:eventually_local`: a query is made to the URL in the `src` attribute when the panel is first opened. The\n results are \"remembered\" and filtered in-memory for all subsequent filter operations, i.e. when the input\n field changes.\n\n3. `:local`: the list of items is provided statically ahead of time and filtered in-memory. No requests are made\n to the server.\n\n## Customizing filter behavior\n\nIf the fetch strategy is `:remote`, then filtering is handled server-side. The server should render a\n`Primer::Alpha::SelectPanel::ItemList` (an alias of {{#link_to_component}}Primer::Alpha::ActionList{{/link_to_component}})\nin the response containing the filtered list of items. The component achieves remote fetching via the\n[remote-input-element](https://github.com/github/remote-input-element), which sends a request to the\nserver with the filter string in the `q=` parameter. Responses must be HTML fragments, eg. have a content\ntype of `text/html+fragment`.\n\n### Local filtering\n\nIf the fetch strategy is `:local` or `:eventually_local`, filtering is performed client-side. Filter behavior can\nbe customized in JavaScript by setting the `filterFn` attribute on the instance of `SelectPanelElement`, eg:\n\n```javascript\ndocument.querySelector(\"select-panel\").filterFn = (item: HTMLElement, query: string): boolean => {\n // return true if the item should be displayed, false otherwise\n}\n```\n\nThe element's default filter function uses the value of the `data-filter-string` attribute, falling back to the\nelement's `innerText` property. It performs a case-insensitive substring match against the filter string.\n\n### `SelectPanel`s as form inputs\n\n`SelectPanel`s can be used as form inputs. They behave very similarly to how HTML `<select>` boxes behave, and\nplay nicely with Rails' built-in form mechanisms. Pass arguments via the `form_arguments:` argument, including\nthe Rails form builder object and the name of the field. Each list item must also have a value specified in\n`content_arguments: { data: { value: } }`.\n\n```erb\n<% form_with(model: Address.new) do |f| %>\n <%= render(Primer::Alpha::SelectPanel.new(form_arguments: { builder: f, name: \"country\" })) do |menu| %>\n <% countries.each do |country|\n <% menu.with_item(label: country.name, content_arguments: { data: { value: country.code } }) %>\n <% end %>\n <% end %>\n<% end %>\n```\n\nThe value of the `data: { value: ... }` argument is sent to the server on submit, keyed using the name provided above\n(eg. `\"country\"`). If no value is provided for an item, the value of that item is the item's label. Here's the\ncorresponding `AddressesController` that might be written to handle the form above:\n\n```ruby\nclass AddressesController < ApplicationController\n def create\n puts \"You chose #{address_params[:country]} as your country\"\n end\n\n private\n\n def address_params\n params.require(:address).permit(:country)\n end\nend\n```\n\nIf items are provided dynamically, things become a bit more complicated. The `form_for` or `form_with` method call\nhappens in the view that renders the `SelectPanel`, which means the form builder object but isn't available in the\nview that renders the list items. In such a case, it can be useful to create an instance of the form builder maually:\n\n```erb\n<% builder = ActionView::Helpers::FormBuilder.new(\n \"address\", # the name of the model, used to wrap input names, eg 'address[country]'\n nil, # object (eg. the Address instance, which we can omit)\n self, # template\n {} # options\n) %>\n<%= render(Primer::Alpha::SelectPanel::ItemList.new(\n form_arguments: { builder: builder, name: \"country\" }\n)) do |list| %>\n <% countries.each do |country| %>\n <% menu.with_item(label: country.name, content_arguments: { data: { value: country.code } }) %>\n <% end %>\n<% end %>\n```\n\n### JavaScript API\n\n`SelectPanel`s render a `<select-panel>` custom element that exposes behavior to the client.\n\n#### Utility methods\n\n* `show()`: Manually open the panel. Under normal circumstances, a show button is used to show the panel, but this method exists to support unusual use-cases.\n* `hide()`: Manually hides (closes) the panel.\n\n#### Query methods\n\n* `getItemById(itemId: string): Element`: Returns the item's HTML `<li>` element. The return value can be passed as the `item` argument to the other methods listed below.\n* `isItemChecked(item: Element): boolean`: Returns `true` if the item is checked, `false` otherwise.\n* `isItemHidden(item: Element): boolean`: Returns `true` if the item is hidden, `false` otherwise.\n* `isItemDisabled(item: Element): boolean`: Returns `true` if the item is disabled, `false` otherwise.\n\nNOTE: Item IDs are special values provided by the user that are attached to `SelectPanel` list items as the `data-item-id`\nHTML attribute. Item IDs can be provided by passing an `item_id:` attribute when adding items to the panel, eg:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel.new) do |panel| %>\n <% panel.with_item(item_id: \"my-id\") %>\n<% end %>\n```\n\nThe same is true when rendering `ItemList`s:\n\n```erb\n<%= render(Primer::Alpha::SelectPanel::ItemList.new) do |list| %>\n <% list.with_item(item_id: \"my-id\") %>\n<% end %>\n```\n\n#### State methods\n\n* `enableItem(item: Element)`: Enables the item, i.e. makes it clickable by the mouse and keyboard.\n* `disableItem(item: Element)`: Disables the item, i.e. makes it unclickable by the mouse and keyboard.\n* `checkItem(item: Element)`: Checks the item. Only has an effect in single- and multi-select modes.\n* `uncheckItem(item: Element)`: Unchecks the item. Only has an effect in multi-select mode, since items cannot be unchecked in single-select mode.\n\n#### Events\n\n|Name |Type |Bubbles |Cancelable |\n|:--------------------|:------------------------------------------|:-------|:----------|\n|`itemActivated` |`CustomEvent<ItemActivatedEvent>` |Yes |No |\n|`beforeItemActivated`|`CustomEvent<ItemActivatedEvent>` |Yes |Yes |\n|`dialog:open` |`CustomEvent<{dialog: HTMLDialogElement}>` |No |No |\n|`panelClosed` |`CustomEvent<{panel: SelectPanelElement}>` |Yes |No |\n\n_Item activation_\n\nThe `<select-panel>` element fires an `itemActivated` event whenever an item is activated (eg. clicked) via the mouse or keyboard.\n\n```typescript\ndocument.querySelector(\"select-panel\").addEventListener(\n \"itemActivated\",\n (event: CustomEvent<ItemActivatedEvent>) => {\n event.detail.item // Element: the <li> item that was activated\n event.detail.checked // boolean: whether or not the result of the activation checked the item\n }\n)\n```\n\nThe `beforeItemActivated` event fires before an item is activated. Canceling this event will prevent the item\nfrom being activated.\n\n```typescript\ndocument.querySelector(\"select-panel\").addEventListener(\n \"beforeItemActivated\",\n (event: CustomEvent<ItemActivatedEvent>) => {\n event.detail.item // Element: the <li> item that was activated\n event.detail.checked // boolean: whether or not the result of the activation checked the item\n event.preventDefault() // Cancel the event to prevent activation (eg. checking/unchecking)\n }\n)\n```",
|
7515
7537
|
"accessibility_docs": null,
|
7516
7538
|
"is_form_component": false,
|
7517
7539
|
"is_published": true,
|
@@ -7551,7 +7573,7 @@
|
|
7551
7573
|
"name": "select_variant",
|
7552
7574
|
"type": "Symbol",
|
7553
7575
|
"default": "`:single`",
|
7554
|
-
"description": "One of `:multiple`, `:
|
7576
|
+
"description": "One of `:multiple`, `:none`, or `:single`."
|
7555
7577
|
},
|
7556
7578
|
{
|
7557
7579
|
"name": "fetch_strategy",
|
@@ -8083,6 +8105,32 @@
|
|
8083
8105
|
"color-contrast"
|
8084
8106
|
]
|
8085
8107
|
}
|
8108
|
+
},
|
8109
|
+
{
|
8110
|
+
"preview_path": "primer/alpha/select_panel/list_of_links",
|
8111
|
+
"name": "list_of_links",
|
8112
|
+
"snapshot": "interactive",
|
8113
|
+
"skip_rules": {
|
8114
|
+
"wont_fix": [
|
8115
|
+
"region"
|
8116
|
+
],
|
8117
|
+
"will_fix": [
|
8118
|
+
"color-contrast"
|
8119
|
+
]
|
8120
|
+
}
|
8121
|
+
},
|
8122
|
+
{
|
8123
|
+
"preview_path": "primer/alpha/select_panel/no_values",
|
8124
|
+
"name": "no_values",
|
8125
|
+
"snapshot": "interactive",
|
8126
|
+
"skip_rules": {
|
8127
|
+
"wont_fix": [
|
8128
|
+
"region"
|
8129
|
+
],
|
8130
|
+
"will_fix": [
|
8131
|
+
"color-contrast"
|
8132
|
+
]
|
8133
|
+
}
|
8086
8134
|
}
|
8087
8135
|
],
|
8088
8136
|
"subcomponents": [
|
@@ -14687,9 +14735,20 @@
|
|
14687
14735
|
},
|
14688
14736
|
{
|
14689
14737
|
"name": "description",
|
14690
|
-
"description": "Description content that complements the item's label
|
14738
|
+
"description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
|
14691
14739
|
"parameters": [
|
14692
|
-
|
14740
|
+
{
|
14741
|
+
"name": "legacy_content",
|
14742
|
+
"type": "String",
|
14743
|
+
"default": "N/A",
|
14744
|
+
"description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
|
14745
|
+
},
|
14746
|
+
{
|
14747
|
+
"name": "test_selector",
|
14748
|
+
"type": "String",
|
14749
|
+
"default": "N/A",
|
14750
|
+
"description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
|
14751
|
+
}
|
14693
14752
|
]
|
14694
14753
|
},
|
14695
14754
|
{
|
@@ -15349,9 +15408,9 @@
|
|
15349
15408
|
},
|
15350
15409
|
{
|
15351
15410
|
"name": "prefix",
|
15352
|
-
"type": "
|
15411
|
+
"type": "String",
|
15353
15412
|
"default": "`nil`",
|
15354
|
-
"description": "What to prefix the relative
|
15413
|
+
"description": "What to prefix the relative time display with."
|
15355
15414
|
},
|
15356
15415
|
{
|
15357
15416
|
"name": "second",
|
@@ -15403,7 +15462,7 @@
|
|
15403
15462
|
},
|
15404
15463
|
{
|
15405
15464
|
"name": "threshold",
|
15406
|
-
"type": "
|
15465
|
+
"type": "String",
|
15407
15466
|
"default": "`nil`",
|
15408
15467
|
"description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
|
15409
15468
|
},
|
@@ -15427,13 +15486,13 @@
|
|
15427
15486
|
},
|
15428
15487
|
{
|
15429
15488
|
"name": "lang",
|
15430
|
-
"type": "
|
15489
|
+
"type": "String",
|
15431
15490
|
"default": "`nil`",
|
15432
15491
|
"description": "The language to use."
|
15433
15492
|
},
|
15434
15493
|
{
|
15435
15494
|
"name": "title",
|
15436
|
-
"type": "
|
15495
|
+
"type": "String",
|
15437
15496
|
"default": "`nil`",
|
15438
15497
|
"description": "Provide a custom title to the element."
|
15439
15498
|
},
|
data/static/previews.json
CHANGED
@@ -6624,6 +6624,32 @@
|
|
6624
6624
|
"color-contrast"
|
6625
6625
|
]
|
6626
6626
|
}
|
6627
|
+
},
|
6628
|
+
{
|
6629
|
+
"preview_path": "primer/alpha/select_panel/list_of_links",
|
6630
|
+
"name": "list_of_links",
|
6631
|
+
"snapshot": "interactive",
|
6632
|
+
"skip_rules": {
|
6633
|
+
"wont_fix": [
|
6634
|
+
"region"
|
6635
|
+
],
|
6636
|
+
"will_fix": [
|
6637
|
+
"color-contrast"
|
6638
|
+
]
|
6639
|
+
}
|
6640
|
+
},
|
6641
|
+
{
|
6642
|
+
"preview_path": "primer/alpha/select_panel/no_values",
|
6643
|
+
"name": "no_values",
|
6644
|
+
"snapshot": "interactive",
|
6645
|
+
"skip_rules": {
|
6646
|
+
"wont_fix": [
|
6647
|
+
"region"
|
6648
|
+
],
|
6649
|
+
"will_fix": [
|
6650
|
+
"color-contrast"
|
6651
|
+
]
|
6652
|
+
}
|
6627
6653
|
}
|
6628
6654
|
]
|
6629
6655
|
},
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openproject-primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.43.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-08-
|
12
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionview
|
@@ -855,10 +855,12 @@ files:
|
|
855
855
|
- previews/primer/alpha/select_panel_preview/eventually_local_fetch_initial_failure.html.erb
|
856
856
|
- previews/primer/alpha/select_panel_preview/eventually_local_fetch_no_results.html.erb
|
857
857
|
- previews/primer/alpha/select_panel_preview/footer_buttons.html.erb
|
858
|
+
- previews/primer/alpha/select_panel_preview/list_of_links.html.erb
|
858
859
|
- previews/primer/alpha/select_panel_preview/local_fetch.html.erb
|
859
860
|
- previews/primer/alpha/select_panel_preview/local_fetch_no_results.html.erb
|
860
861
|
- previews/primer/alpha/select_panel_preview/multiselect.html.erb
|
861
862
|
- previews/primer/alpha/select_panel_preview/multiselect_form.html.erb
|
863
|
+
- previews/primer/alpha/select_panel_preview/no_values.html.erb
|
862
864
|
- previews/primer/alpha/select_panel_preview/playground.html.erb
|
863
865
|
- previews/primer/alpha/select_panel_preview/remote_fetch.html.erb
|
864
866
|
- previews/primer/alpha/select_panel_preview/remote_fetch_filter_failure.html.erb
|