@primer/view-components 0.30.1-rc.b5ae563d → 0.31.0-rc.1c9eab10

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
15
15
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
16
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
17
  };
18
- var _SelectPanelElement_instances, _SelectPanelElement_dialogIntersectionObserver, _SelectPanelElement_abortController, _SelectPanelElement_originalLabel, _SelectPanelElement_inputName, _SelectPanelElement_selectedItems, _SelectPanelElement_loadingDelayTimeoutId, _SelectPanelElement_loadingAnnouncementTimeoutId, _SelectPanelElement_waitForCondition, _SelectPanelElement_softDisableItems, _SelectPanelElement_updateTabIndices, _SelectPanelElement_potentiallyDisallowActivation, _SelectPanelElement_isAnchorActivationViaSpace, _SelectPanelElement_isActivation, _SelectPanelElement_checkSelectedItems, _SelectPanelElement_addSelectedItem, _SelectPanelElement_removeSelectedItem, _SelectPanelElement_setTextFieldLoadingSpinnerTimer, _SelectPanelElement_handleIncludeFragmentEvent, _SelectPanelElement_toggleIncludeFragmentElements, _SelectPanelElement_handleRemoteInputEvent, _SelectPanelElement_defaultFilterFn, _SelectPanelElement_handleSearchFieldEvent, _SelectPanelElement_updateItemVisibility, _SelectPanelElement_inErrorState, _SelectPanelElement_setErrorState, _SelectPanelElement_clearErrorState, _SelectPanelElement_maybeAnnounce, _SelectPanelElement_fetchStrategy_get, _SelectPanelElement_filterInputTextFieldElement_get, _SelectPanelElement_performFilteringLocally, _SelectPanelElement_handleInvokerActivated, _SelectPanelElement_handleDialogItemActivated, _SelectPanelElement_handleItemActivated, _SelectPanelElement_setDynamicLabel, _SelectPanelElement_updateInput, _SelectPanelElement_firstItem_get, _SelectPanelElement_hideItem, _SelectPanelElement_showItem, _SelectPanelElement_getItemContent;
18
+ var _SelectPanelElement_instances, _SelectPanelElement_dialogIntersectionObserver, _SelectPanelElement_abortController, _SelectPanelElement_originalLabel, _SelectPanelElement_inputName, _SelectPanelElement_selectedItems, _SelectPanelElement_loadingDelayTimeoutId, _SelectPanelElement_loadingAnnouncementTimeoutId, _SelectPanelElement_hasLoadedData, _SelectPanelElement_waitForCondition, _SelectPanelElement_softDisableItems, _SelectPanelElement_updateTabIndices, _SelectPanelElement_potentiallyDisallowActivation, _SelectPanelElement_isAnchorActivationViaSpace, _SelectPanelElement_isActivation, _SelectPanelElement_checkSelectedItems, _SelectPanelElement_addSelectedItem, _SelectPanelElement_removeSelectedItem, _SelectPanelElement_setTextFieldLoadingSpinnerTimer, _SelectPanelElement_handleIncludeFragmentEvent, _SelectPanelElement_toggleIncludeFragmentElements, _SelectPanelElement_handleRemoteInputEvent, _SelectPanelElement_defaultFilterFn, _SelectPanelElement_handleSearchFieldEvent, _SelectPanelElement_updateItemVisibility, _SelectPanelElement_inErrorState, _SelectPanelElement_setErrorState, _SelectPanelElement_clearErrorState, _SelectPanelElement_maybeAnnounce, _SelectPanelElement_fetchStrategy_get, _SelectPanelElement_filterInputTextFieldElement_get, _SelectPanelElement_performFilteringLocally, _SelectPanelElement_handleInvokerActivated, _SelectPanelElement_handleDialogItemActivated, _SelectPanelElement_handleItemActivated, _SelectPanelElement_setDynamicLabel, _SelectPanelElement_updateInput, _SelectPanelElement_firstItem_get, _SelectPanelElement_hideItem, _SelectPanelElement_showItem, _SelectPanelElement_getItemContent;
19
19
  import { getAnchoredPosition } from '@primer/behaviors';
20
20
  import { controller, target } from '@github/catalyst';
21
21
  import { announceFromElement, announce } from '../aria_live';
@@ -55,6 +55,7 @@ const updateWhenVisible = (() => {
55
55
  }));
56
56
  resizeObserver.observe(el.ownerDocument.documentElement);
57
57
  el.addEventListener('dialog:close', () => {
58
+ el.invokerElement?.setAttribute('aria-expanded', 'false');
58
59
  anchors.delete(el);
59
60
  });
60
61
  el.addEventListener('dialog:open', () => {
@@ -73,6 +74,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
73
74
  _SelectPanelElement_selectedItems.set(this, new Map());
74
75
  _SelectPanelElement_loadingDelayTimeoutId.set(this, null);
75
76
  _SelectPanelElement_loadingAnnouncementTimeoutId.set(this, null);
77
+ _SelectPanelElement_hasLoadedData.set(this, false);
76
78
  }
77
79
  get open() {
78
80
  return this.dialog.open;
@@ -251,6 +253,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
251
253
  if (event.target === this.dialog && event.type === 'close') {
252
254
  // Remove data-ready so it can be set the next time the panel is opened
253
255
  this.dialog.removeAttribute('data-ready');
256
+ this.invokerElement?.setAttribute('aria-expanded', 'false');
254
257
  this.dispatchEvent(new CustomEvent('panelClosed', {
255
258
  detail: { panel: this },
256
259
  bubbles: true,
@@ -300,6 +303,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
300
303
  show() {
301
304
  this.updateAnchorPosition();
302
305
  this.dialog.showModal();
306
+ this.invokerElement?.setAttribute('aria-expanded', 'true');
303
307
  const event = new CustomEvent('dialog:open', {
304
308
  detail: { dialog: this.dialog },
305
309
  });
@@ -385,6 +389,7 @@ _SelectPanelElement_inputName = new WeakMap();
385
389
  _SelectPanelElement_selectedItems = new WeakMap();
386
390
  _SelectPanelElement_loadingDelayTimeoutId = new WeakMap();
387
391
  _SelectPanelElement_loadingAnnouncementTimeoutId = new WeakMap();
392
+ _SelectPanelElement_hasLoadedData = new WeakMap();
388
393
  _SelectPanelElement_instances = new WeakSet();
389
394
  _SelectPanelElement_waitForCondition = function _SelectPanelElement_waitForCondition(condition, body) {
390
395
  if (condition()) {
@@ -422,7 +427,7 @@ _SelectPanelElement_updateTabIndices = function _SelectPanelElement_updateTabInd
422
427
  itemContent.setAttribute('tabindex', '-1');
423
428
  }
424
429
  // <li> elements should not themselves be tabbable
425
- item.setAttribute('tabindex', '-1');
430
+ item.removeAttribute('tabindex');
426
431
  }
427
432
  }
428
433
  else {
@@ -437,7 +442,7 @@ _SelectPanelElement_updateTabIndices = function _SelectPanelElement_updateTabInd
437
442
  itemContent.setAttribute('tabindex', '-1');
438
443
  }
439
444
  // <li> elements should not themselves be tabbable
440
- item.setAttribute('tabindex', '-1');
445
+ item.removeAttribute('tabindex');
441
446
  }
442
447
  }
443
448
  if (!setZeroTabIndex && __classPrivateFieldGet(this, _SelectPanelElement_instances, "a", _SelectPanelElement_firstItem_get)) {
@@ -502,7 +507,10 @@ _SelectPanelElement_addSelectedItem = function _SelectPanelElement_addSelectedIt
502
507
  }
503
508
  };
504
509
  _SelectPanelElement_removeSelectedItem = function _SelectPanelElement_removeSelectedItem(item) {
505
- const value = item.getAttribute('data-value');
510
+ const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
511
+ if (!itemContent)
512
+ return;
513
+ const value = itemContent.getAttribute('data-value');
506
514
  if (value) {
507
515
  __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").delete(value);
508
516
  }
@@ -608,9 +616,9 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
608
616
  }
609
617
  }
610
618
  else if (key === 'ArrowDown') {
611
- const item = (this.focusableItem || this.visibleItems[0]);
619
+ const item = (this.focusableItem || __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, this.visibleItems[0]));
612
620
  if (item) {
613
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
621
+ item.focus();
614
622
  event.preventDefault();
615
623
  }
616
624
  }
@@ -672,7 +680,13 @@ _SelectPanelElement_updateItemVisibility = function _SelectPanelElement_updateIt
672
680
  if (!itemContent)
673
681
  continue;
674
682
  const value = itemContent.getAttribute('data-value');
675
- if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value) && this.isItemChecked(item)) {
683
+ if (__classPrivateFieldGet(this, _SelectPanelElement_hasLoadedData, "f")) {
684
+ if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value)) {
685
+ itemContent.setAttribute(this.ariaSelectionType, 'false');
686
+ }
687
+ }
688
+ else if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value) && this.isItemChecked(item)) {
689
+ __classPrivateFieldSet(this, _SelectPanelElement_hasLoadedData, true, "f");
676
690
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
677
691
  }
678
692
  }
@@ -814,17 +828,16 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
814
828
  return;
815
829
  const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
816
830
  if (this.selectVariant === 'single') {
831
+ const element = this.selectedItems[0]?.element;
832
+ if (element) {
833
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, element)?.setAttribute(this.ariaSelectionType, 'false');
834
+ }
835
+ __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").clear();
817
836
  // Only check, never uncheck here. Single-select mode does not allow unchecking a checked item.
818
837
  if (checked) {
819
838
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
820
839
  itemContent?.setAttribute(this.ariaSelectionType, 'true');
821
840
  }
822
- for (const checkedItem of this.querySelectorAll(`[${this.ariaSelectionType}]`)) {
823
- if (checkedItem !== itemContent) {
824
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_removeSelectedItem).call(this, checkedItem);
825
- checkedItem.setAttribute(this.ariaSelectionType, 'false');
826
- }
827
- }
828
841
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_setDynamicLabel).call(this);
829
842
  }
830
843
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.30.1-rc.b5ae563d",
3
+ "version": "0.31.0-rc.1c9eab10",
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",
@@ -4336,9 +4336,9 @@
4336
4336
  },
4337
4337
  {
4338
4338
  "name": "prefix",
4339
- "type": "sring",
4339
+ "type": "String",
4340
4340
  "default": "`nil`",
4341
- "description": "What to prefix the relative ime display with."
4341
+ "description": "What to prefix the relative time display with."
4342
4342
  },
4343
4343
  {
4344
4344
  "name": "second",
@@ -4390,7 +4390,7 @@
4390
4390
  },
4391
4391
  {
4392
4392
  "name": "threshold",
4393
- "type": "string",
4393
+ "type": "String",
4394
4394
  "default": "`nil`",
4395
4395
  "description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
4396
4396
  },
@@ -4414,13 +4414,13 @@
4414
4414
  },
4415
4415
  {
4416
4416
  "name": "lang",
4417
- "type": "string",
4417
+ "type": "String",
4418
4418
  "default": "`nil`",
4419
4419
  "description": "The language to use."
4420
4420
  },
4421
4421
  {
4422
4422
  "name": "title",
4423
- "type": "string",
4423
+ "type": "String",
4424
4424
  "default": "`nil`",
4425
4425
  "description": "Provide a custom title to the element."
4426
4426
  },
@@ -989,9 +989,20 @@
989
989
  "slots": [
990
990
  {
991
991
  "name": "description",
992
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
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. See `ActionList`'s `description_scheme` argument\nfor layout options.",
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
  {
@@ -14687,9 +14709,20 @@
14687
14709
  },
14688
14710
  {
14689
14711
  "name": "description",
14690
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
14712
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
14691
14713
  "parameters": [
14692
-
14714
+ {
14715
+ "name": "legacy_content",
14716
+ "type": "String",
14717
+ "default": "N/A",
14718
+ "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\")`."
14719
+ },
14720
+ {
14721
+ "name": "test_selector",
14722
+ "type": "String",
14723
+ "default": "N/A",
14724
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
14725
+ }
14693
14726
  ]
14694
14727
  },
14695
14728
  {
@@ -15349,9 +15382,9 @@
15349
15382
  },
15350
15383
  {
15351
15384
  "name": "prefix",
15352
- "type": "sring",
15385
+ "type": "String",
15353
15386
  "default": "`nil`",
15354
- "description": "What to prefix the relative ime display with."
15387
+ "description": "What to prefix the relative time display with."
15355
15388
  },
15356
15389
  {
15357
15390
  "name": "second",
@@ -15403,7 +15436,7 @@
15403
15436
  },
15404
15437
  {
15405
15438
  "name": "threshold",
15406
- "type": "string",
15439
+ "type": "String",
15407
15440
  "default": "`nil`",
15408
15441
  "description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
15409
15442
  },
@@ -15427,13 +15460,13 @@
15427
15460
  },
15428
15461
  {
15429
15462
  "name": "lang",
15430
- "type": "string",
15463
+ "type": "String",
15431
15464
  "default": "`nil`",
15432
15465
  "description": "The language to use."
15433
15466
  },
15434
15467
  {
15435
15468
  "name": "title",
15436
- "type": "string",
15469
+ "type": "String",
15437
15470
  "default": "`nil`",
15438
15471
  "description": "Provide a custom title to the element."
15439
15472
  },