@primer/view-components 0.27.1-rc.54e32349 → 0.28.0-rc.22557eac

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ export declare function announceFromElement(el: HTMLElement, options?: {
2
+ assertive?: boolean;
3
+ element?: HTMLElement;
4
+ }): void;
5
+ export declare function announce(message: string, options?: {
6
+ assertive?: boolean;
7
+ element?: HTMLElement;
8
+ }): void;
@@ -0,0 +1,38 @@
1
+ const safeDocument = typeof document === 'undefined' ? undefined : document;
2
+ // Announce an element's text to the screen reader.
3
+ export function announceFromElement(el, options) {
4
+ announce(getTextContent(el), options);
5
+ }
6
+ // Announce message update to screen reader.
7
+ // Note: Use caution when using this function while a dialog is active.
8
+ // If the message is updated while the dialog is open, the screen reader may not announce the live region.
9
+ export function announce(message, options) {
10
+ const { assertive, element } = options ?? {};
11
+ setContainerContent(message, assertive, element);
12
+ }
13
+ // Set aria-live container to message.
14
+ function setContainerContent(message, assertive, element) {
15
+ const getQuerySelector = () => {
16
+ return assertive ? '#js-global-screen-reader-notice-assertive' : '#js-global-screen-reader-notice';
17
+ };
18
+ const container = element ?? safeDocument?.querySelector(getQuerySelector());
19
+ if (!container)
20
+ return;
21
+ if (container.textContent === message) {
22
+ /* This is a hack due to the way the aria live API works.
23
+ A screen reader will not read a live region again
24
+ if the text is the same. Adding a space character tells
25
+ the browser that the live region has updated,
26
+ which will cause it to read again, but with no audible difference. */
27
+ container.textContent = `${message}\u00A0`;
28
+ }
29
+ else {
30
+ container.textContent = message;
31
+ }
32
+ }
33
+ // Gets the trimmed text content of an element.
34
+ function getTextContent(el) {
35
+ // innerText does not contain hidden text
36
+ /* eslint-disable-next-line github/no-innerText */
37
+ return (el.getAttribute('aria-label') || el.innerText || '').trim();
38
+ }
@@ -1,4 +1,5 @@
1
1
  import '@github/include-fragment-element';
2
+ import '@github/remote-input-element';
2
3
  import './alpha/action_list';
3
4
  import './alpha/action_bar_element';
4
5
  import './alpha/dropdown';
@@ -6,6 +7,8 @@ import './anchored_position';
6
7
  import './dialog_helper';
7
8
  import './focus_group';
8
9
  import './scrollable_region';
10
+ import './aria_live';
11
+ import './shared_events';
9
12
  import './alpha/image_crop';
10
13
  import './alpha/modal_dialog';
11
14
  import './beta/nav_list';
@@ -22,3 +25,4 @@ import '../../../lib/primer/forms/primer_multi_input';
22
25
  import '../../../lib/primer/forms/primer_text_field';
23
26
  import '../../../lib/primer/forms/toggle_switch_input';
24
27
  import './alpha/action_menu/action_menu_element';
28
+ import './alpha/select_panel_element';
@@ -1,4 +1,5 @@
1
1
  import '@github/include-fragment-element';
2
+ import '@github/remote-input-element';
2
3
  import './alpha/action_list';
3
4
  import './alpha/action_bar_element';
4
5
  import './alpha/dropdown';
@@ -6,6 +7,8 @@ import './anchored_position';
6
7
  import './dialog_helper';
7
8
  import './focus_group';
8
9
  import './scrollable_region';
10
+ import './aria_live';
11
+ import './shared_events';
9
12
  import './alpha/image_crop';
10
13
  import './alpha/modal_dialog';
11
14
  import './beta/nav_list';
@@ -22,3 +25,4 @@ import '../../../lib/primer/forms/primer_multi_input';
22
25
  import '../../../lib/primer/forms/primer_text_field';
23
26
  import '../../../lib/primer/forms/toggle_switch_input';
24
27
  import './alpha/action_menu/action_menu_element';
28
+ import './alpha/select_panel_element';
@@ -0,0 +1,9 @@
1
+ export type ItemActivatedEvent = {
2
+ item: Element;
3
+ checked: boolean;
4
+ };
5
+ declare global {
6
+ interface HTMLElementEventMap {
7
+ itemActivated: CustomEvent<ItemActivatedEvent>;
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.27.1-rc.54e32349",
3
+ "version": "0.28.0-rc.22557eac",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -50,6 +50,7 @@
50
50
  "@github/image-crop-element": "^5.0.0",
51
51
  "@github/include-fragment-element": "^6.1.1",
52
52
  "@github/relative-time-element": "^4.0.0",
53
+ "@github/remote-input-element": "^0.4.0",
53
54
  "@github/tab-container-element": "^3.1.2",
54
55
  "@oddbird/popover-polyfill": "^0.4.0",
55
56
  "@primer/behaviors": "^1.3.4"
@@ -2352,6 +2352,124 @@
2352
2352
  }
2353
2353
  ]
2354
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
+ },
2355
2473
  {
2356
2474
  "component": "SubmitButton",
2357
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": "",
@@ -597,6 +597,22 @@
597
597
  },
598
598
  "Primer::Alpha::Select": {
599
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
+ },
600
616
  "Primer::Alpha::SubmitButton": {
601
617
  },
602
618
  "Primer::Alpha::TabContainer": {