@primer/view-components 0.31.0-rc.5dfe6191 → 0.31.0-rc.61d58bdb

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.
@@ -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';
@@ -73,6 +73,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
73
73
  _SelectPanelElement_selectedItems.set(this, new Map());
74
74
  _SelectPanelElement_loadingDelayTimeoutId.set(this, null);
75
75
  _SelectPanelElement_loadingAnnouncementTimeoutId.set(this, null);
76
+ _SelectPanelElement_hasLoadedData.set(this, false);
76
77
  }
77
78
  get open() {
78
79
  return this.dialog.open;
@@ -385,6 +386,7 @@ _SelectPanelElement_inputName = new WeakMap();
385
386
  _SelectPanelElement_selectedItems = new WeakMap();
386
387
  _SelectPanelElement_loadingDelayTimeoutId = new WeakMap();
387
388
  _SelectPanelElement_loadingAnnouncementTimeoutId = new WeakMap();
389
+ _SelectPanelElement_hasLoadedData = new WeakMap();
388
390
  _SelectPanelElement_instances = new WeakSet();
389
391
  _SelectPanelElement_waitForCondition = function _SelectPanelElement_waitForCondition(condition, body) {
390
392
  if (condition()) {
@@ -422,7 +424,7 @@ _SelectPanelElement_updateTabIndices = function _SelectPanelElement_updateTabInd
422
424
  itemContent.setAttribute('tabindex', '-1');
423
425
  }
424
426
  // <li> elements should not themselves be tabbable
425
- item.setAttribute('tabindex', '-1');
427
+ item.removeAttribute('tabindex');
426
428
  }
427
429
  }
428
430
  else {
@@ -437,7 +439,7 @@ _SelectPanelElement_updateTabIndices = function _SelectPanelElement_updateTabInd
437
439
  itemContent.setAttribute('tabindex', '-1');
438
440
  }
439
441
  // <li> elements should not themselves be tabbable
440
- item.setAttribute('tabindex', '-1');
442
+ item.removeAttribute('tabindex');
441
443
  }
442
444
  }
443
445
  if (!setZeroTabIndex && __classPrivateFieldGet(this, _SelectPanelElement_instances, "a", _SelectPanelElement_firstItem_get)) {
@@ -502,7 +504,10 @@ _SelectPanelElement_addSelectedItem = function _SelectPanelElement_addSelectedIt
502
504
  }
503
505
  };
504
506
  _SelectPanelElement_removeSelectedItem = function _SelectPanelElement_removeSelectedItem(item) {
505
- const value = item.getAttribute('data-value');
507
+ const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
508
+ if (!itemContent)
509
+ return;
510
+ const value = itemContent.getAttribute('data-value');
506
511
  if (value) {
507
512
  __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").delete(value);
508
513
  }
@@ -608,9 +613,9 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
608
613
  }
609
614
  }
610
615
  else if (key === 'ArrowDown') {
611
- const item = (this.focusableItem || this.visibleItems[0]);
616
+ const item = (this.focusableItem || __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, this.visibleItems[0]));
612
617
  if (item) {
613
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
618
+ item.focus();
614
619
  event.preventDefault();
615
620
  }
616
621
  }
@@ -672,7 +677,13 @@ _SelectPanelElement_updateItemVisibility = function _SelectPanelElement_updateIt
672
677
  if (!itemContent)
673
678
  continue;
674
679
  const value = itemContent.getAttribute('data-value');
675
- if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value) && this.isItemChecked(item)) {
680
+ if (__classPrivateFieldGet(this, _SelectPanelElement_hasLoadedData, "f")) {
681
+ if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value)) {
682
+ itemContent.setAttribute(this.ariaSelectionType, 'false');
683
+ }
684
+ }
685
+ else if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value) && this.isItemChecked(item)) {
686
+ __classPrivateFieldSet(this, _SelectPanelElement_hasLoadedData, true, "f");
676
687
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
677
688
  }
678
689
  }
@@ -814,17 +825,16 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
814
825
  return;
815
826
  const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
816
827
  if (this.selectVariant === 'single') {
828
+ const element = this.selectedItems[0]?.element;
829
+ if (element) {
830
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, element)?.setAttribute(this.ariaSelectionType, 'false');
831
+ }
832
+ __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").clear();
817
833
  // Only check, never uncheck here. Single-select mode does not allow unchecking a checked item.
818
834
  if (checked) {
819
835
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
820
836
  itemContent?.setAttribute(this.ariaSelectionType, 'true');
821
837
  }
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
838
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_setDynamicLabel).call(this);
829
839
  }
830
840
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.31.0-rc.5dfe6191",
3
+ "version": "0.31.0-rc.61d58bdb",
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,14 @@
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": "test_selector",
996
+ "type": "String",
997
+ "default": "N/A",
998
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
999
+ }
995
1000
  ]
996
1001
  },
997
1002
  {
@@ -5547,9 +5552,14 @@
5547
5552
  },
5548
5553
  {
5549
5554
  "name": "description",
5550
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
5555
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
5551
5556
  "parameters": [
5552
-
5557
+ {
5558
+ "name": "test_selector",
5559
+ "type": "String",
5560
+ "default": "N/A",
5561
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
5562
+ }
5553
5563
  ]
5554
5564
  },
5555
5565
  {
@@ -14687,9 +14697,14 @@
14687
14697
  },
14688
14698
  {
14689
14699
  "name": "description",
14690
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
14700
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
14691
14701
  "parameters": [
14692
-
14702
+ {
14703
+ "name": "test_selector",
14704
+ "type": "String",
14705
+ "default": "N/A",
14706
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
14707
+ }
14693
14708
  ]
14694
14709
  },
14695
14710
  {
@@ -15349,9 +15364,9 @@
15349
15364
  },
15350
15365
  {
15351
15366
  "name": "prefix",
15352
- "type": "sring",
15367
+ "type": "String",
15353
15368
  "default": "`nil`",
15354
- "description": "What to prefix the relative ime display with."
15369
+ "description": "What to prefix the relative time display with."
15355
15370
  },
15356
15371
  {
15357
15372
  "name": "second",
@@ -15403,7 +15418,7 @@
15403
15418
  },
15404
15419
  {
15405
15420
  "name": "threshold",
15406
- "type": "string",
15421
+ "type": "String",
15407
15422
  "default": "`nil`",
15408
15423
  "description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
15409
15424
  },
@@ -15427,13 +15442,13 @@
15427
15442
  },
15428
15443
  {
15429
15444
  "name": "lang",
15430
- "type": "string",
15445
+ "type": "String",
15431
15446
  "default": "`nil`",
15432
15447
  "description": "The language to use."
15433
15448
  },
15434
15449
  {
15435
15450
  "name": "title",
15436
- "type": "string",
15451
+ "type": "String",
15437
15452
  "default": "`nil`",
15438
15453
  "description": "Provide a custom title to the element."
15439
15454
  },