@mackin.com/styleguide 11.0.7 → 11.0.8

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.
Files changed (3) hide show
  1. package/index.esm.js +35 -3
  2. package/index.js +35 -3
  3. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -565,7 +565,6 @@ const Accordion = (props) => {
565
565
  }, [open]);
566
566
  React.useEffect(() => {
567
567
  var _a;
568
- console.warn('props.open', 'changed', props.open);
569
568
  if (props.open === undefined) {
570
569
  // technically, we only need to use this effect if props.open was initialized with a boolean.
571
570
  // you can't have conditional effects so here we go...
@@ -982,8 +981,32 @@ const TabLocker = (props) => {
982
981
  if (e.key === 'Tab') {
983
982
  e.preventDefault();
984
983
  e.stopPropagation();
985
- const tabElements = Array.from((_b = (_a = tabLocker.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')) !== null && _b !== void 0 ? _b : []).filter(el => !el.hasAttribute('disabled'));
986
- if (tabElements.length) {
984
+ let tabElements;
985
+ try {
986
+ tabElements = Array.from((_b = (_a = tabLocker.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(tabQuery)) !== null && _b !== void 0 ? _b : [])
987
+ .filter(el => {
988
+ if (el.hasAttribute('disabled')) {
989
+ // seems to be unreliable when done in the query itself
990
+ return false;
991
+ }
992
+ if (el.getAttribute('tabindex') === '-1') {
993
+ // '[tabindex]:not([tabindex="-1"])' is in the query, but is ignored for controls that can already
994
+ // receive focus like buttons. We'll leave it in because it DOSE ignore non-focus elements with a tabindex.
995
+ return false;
996
+ }
997
+ if (el.hasAttribute('hidden')) {
998
+ return false;
999
+ }
1000
+ if (el.closest('[hidden]')) {
1001
+ return false;
1002
+ }
1003
+ return true;
1004
+ });
1005
+ }
1006
+ catch (err) {
1007
+ console.error(err);
1008
+ }
1009
+ if (tabElements === null || tabElements === void 0 ? void 0 : tabElements.length) {
987
1010
  const direction = e.shiftKey ? -1 : 1;
988
1011
  const index = tabElements.findIndex(x => x === document.activeElement);
989
1012
  if (index === undefined) {
@@ -1002,6 +1025,15 @@ const TabLocker = (props) => {
1002
1025
  }
1003
1026
  } }, props.children));
1004
1027
  };
1028
+ // easier to look at!
1029
+ const tabQuery = [
1030
+ 'a',
1031
+ 'button',
1032
+ 'input',
1033
+ 'textarea',
1034
+ 'select',
1035
+ '[tabindex]:not([tabindex="-1"])'
1036
+ ].join(',');
1005
1037
 
1006
1038
  /*
1007
1039
  ARIA info:
package/index.js CHANGED
@@ -583,7 +583,6 @@ const Accordion = (props) => {
583
583
  }, [open]);
584
584
  React__namespace.useEffect(() => {
585
585
  var _a;
586
- console.warn('props.open', 'changed', props.open);
587
586
  if (props.open === undefined) {
588
587
  // technically, we only need to use this effect if props.open was initialized with a boolean.
589
588
  // you can't have conditional effects so here we go...
@@ -1000,8 +999,32 @@ const TabLocker = (props) => {
1000
999
  if (e.key === 'Tab') {
1001
1000
  e.preventDefault();
1002
1001
  e.stopPropagation();
1003
- const tabElements = Array.from((_b = (_a = tabLocker.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])')) !== null && _b !== void 0 ? _b : []).filter(el => !el.hasAttribute('disabled'));
1004
- if (tabElements.length) {
1002
+ let tabElements;
1003
+ try {
1004
+ tabElements = Array.from((_b = (_a = tabLocker.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(tabQuery)) !== null && _b !== void 0 ? _b : [])
1005
+ .filter(el => {
1006
+ if (el.hasAttribute('disabled')) {
1007
+ // seems to be unreliable when done in the query itself
1008
+ return false;
1009
+ }
1010
+ if (el.getAttribute('tabindex') === '-1') {
1011
+ // '[tabindex]:not([tabindex="-1"])' is in the query, but is ignored for controls that can already
1012
+ // receive focus like buttons. We'll leave it in because it DOSE ignore non-focus elements with a tabindex.
1013
+ return false;
1014
+ }
1015
+ if (el.hasAttribute('hidden')) {
1016
+ return false;
1017
+ }
1018
+ if (el.closest('[hidden]')) {
1019
+ return false;
1020
+ }
1021
+ return true;
1022
+ });
1023
+ }
1024
+ catch (err) {
1025
+ console.error(err);
1026
+ }
1027
+ if (tabElements === null || tabElements === void 0 ? void 0 : tabElements.length) {
1005
1028
  const direction = e.shiftKey ? -1 : 1;
1006
1029
  const index = tabElements.findIndex(x => x === document.activeElement);
1007
1030
  if (index === undefined) {
@@ -1020,6 +1043,15 @@ const TabLocker = (props) => {
1020
1043
  }
1021
1044
  } }, props.children));
1022
1045
  };
1046
+ // easier to look at!
1047
+ const tabQuery = [
1048
+ 'a',
1049
+ 'button',
1050
+ 'input',
1051
+ 'textarea',
1052
+ 'select',
1053
+ '[tabindex]:not([tabindex="-1"])'
1054
+ ].join(',');
1023
1055
 
1024
1056
  /*
1025
1057
  ARIA info:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mackin.com/styleguide",
3
- "version": "11.0.7",
3
+ "version": "11.0.8",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "module": "./index.esm.js",