@primer/components 0.0.0-2021116165050 → 0.0.0-202111619107

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 (135) hide show
  1. package/dist/browser.esm.js +2 -2
  2. package/dist/browser.esm.js.map +1 -1
  3. package/dist/browser.umd.js +2 -2
  4. package/dist/browser.umd.js.map +1 -1
  5. package/lib/ActionList/Item.js +3 -3
  6. package/lib/ActionList/List.js +2 -2
  7. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  8. package/lib/Autocomplete/AutocompleteMenu.js +23 -11
  9. package/lib/Dialog/ConfirmationDialog.js +2 -2
  10. package/lib/Dialog/Dialog.js +2 -2
  11. package/lib/FilteredActionList/FilteredActionList.js +10 -3
  12. package/lib/Overlay.d.ts +1 -1
  13. package/lib/TextInputWithTokens.js +4 -4
  14. package/lib/hooks/useAnchoredPosition.d.ts +1 -1
  15. package/lib/hooks/useAnchoredPosition.js +2 -2
  16. package/lib/hooks/useFocusTrap.js +2 -2
  17. package/lib/hooks/useFocusZone.d.ts +1 -1
  18. package/lib/hooks/useFocusZone.js +2 -2
  19. package/lib/hooks/useOpenAndCloseFocus.js +2 -2
  20. package/lib/index.d.ts +0 -3
  21. package/lib/index.js +0 -24
  22. package/lib-esm/ActionList/Item.js +1 -1
  23. package/lib-esm/ActionList/List.js +1 -1
  24. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  25. package/lib-esm/Autocomplete/AutocompleteMenu.js +22 -7
  26. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  27. package/lib-esm/Dialog/Dialog.js +1 -1
  28. package/lib-esm/FilteredActionList/FilteredActionList.js +9 -3
  29. package/lib-esm/Overlay.d.ts +1 -1
  30. package/lib-esm/TextInputWithTokens.js +2 -2
  31. package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
  32. package/lib-esm/hooks/useAnchoredPosition.js +1 -1
  33. package/lib-esm/hooks/useFocusTrap.js +1 -1
  34. package/lib-esm/hooks/useFocusZone.d.ts +1 -1
  35. package/lib-esm/hooks/useFocusZone.js +1 -1
  36. package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
  37. package/lib-esm/index.d.ts +0 -3
  38. package/lib-esm/index.js +0 -3
  39. package/package.json +3 -6
  40. package/lib/CheckboxInputField.d.ts +0 -10
  41. package/lib/CheckboxInputField.js +0 -73
  42. package/lib/RadioInputField.d.ts +0 -9
  43. package/lib/RadioInputField.js +0 -74
  44. package/lib/TextInputField.d.ts +0 -583
  45. package/lib/TextInputField.js +0 -66
  46. package/lib/_InputCaption.d.ts +0 -13
  47. package/lib/_InputCaption.js +0 -26
  48. package/lib/_InputField/InputField.d.ts +0 -39
  49. package/lib/_InputField/InputField.js +0 -90
  50. package/lib/_InputField/InputFieldCaption.d.ts +0 -3
  51. package/lib/_InputField/InputFieldCaption.js +0 -30
  52. package/lib/_InputField/InputFieldLabel.d.ts +0 -9
  53. package/lib/_InputField/InputFieldLabel.js +0 -34
  54. package/lib/_InputField/InputFieldValidation.d.ts +0 -6
  55. package/lib/_InputField/InputFieldValidation.js +0 -17
  56. package/lib/_InputField/ToggleInputField.d.ts +0 -13
  57. package/lib/_InputField/ToggleInputField.js +0 -71
  58. package/lib/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  59. package/lib/_InputField/ToggleInputLeadingVisual.js +0 -22
  60. package/lib/_InputField/ValidationAnimationContainer.d.ts +0 -6
  61. package/lib/_InputField/ValidationAnimationContainer.js +0 -48
  62. package/lib/_InputField/index.d.ts +0 -1
  63. package/lib/_InputField/index.js +0 -15
  64. package/lib/_InputField/slots.d.ts +0 -13
  65. package/lib/_InputField/slots.js +0 -17
  66. package/lib/_InputLabel.d.ts +0 -8
  67. package/lib/_InputLabel.js +0 -44
  68. package/lib/_InputValidation.d.ts +0 -8
  69. package/lib/_InputValidation.js +0 -56
  70. package/lib/_VisuallyHidden.d.ts +0 -6
  71. package/lib/_VisuallyHidden.js +0 -39
  72. package/lib/behaviors/anchoredPosition.d.ts +0 -89
  73. package/lib/behaviors/anchoredPosition.js +0 -316
  74. package/lib/behaviors/focusTrap.d.ts +0 -12
  75. package/lib/behaviors/focusTrap.js +0 -179
  76. package/lib/behaviors/focusZone.d.ts +0 -137
  77. package/lib/behaviors/focusZone.js +0 -578
  78. package/lib/behaviors/scrollIntoViewingArea.d.ts +0 -1
  79. package/lib/behaviors/scrollIntoViewingArea.js +0 -39
  80. package/lib/utils/iterateFocusableElements.d.ts +0 -42
  81. package/lib/utils/iterateFocusableElements.js +0 -113
  82. package/lib/utils/types/FormValidationStatus.d.ts +0 -1
  83. package/lib/utils/types/FormValidationStatus.js +0 -1
  84. package/lib/utils/uniqueId.d.ts +0 -1
  85. package/lib/utils/uniqueId.js +0 -12
  86. package/lib/utils/userAgent.d.ts +0 -1
  87. package/lib/utils/userAgent.js +0 -15
  88. package/lib-esm/CheckboxInputField.d.ts +0 -10
  89. package/lib-esm/CheckboxInputField.js +0 -56
  90. package/lib-esm/RadioInputField.d.ts +0 -9
  91. package/lib-esm/RadioInputField.js +0 -56
  92. package/lib-esm/TextInputField.d.ts +0 -583
  93. package/lib-esm/TextInputField.js +0 -50
  94. package/lib-esm/_InputCaption.d.ts +0 -13
  95. package/lib-esm/_InputCaption.js +0 -15
  96. package/lib-esm/_InputField/InputField.d.ts +0 -39
  97. package/lib-esm/_InputField/InputField.js +0 -70
  98. package/lib-esm/_InputField/InputFieldCaption.d.ts +0 -3
  99. package/lib-esm/_InputField/InputFieldCaption.js +0 -18
  100. package/lib-esm/_InputField/InputFieldLabel.d.ts +0 -9
  101. package/lib-esm/_InputField/InputFieldLabel.js +0 -22
  102. package/lib-esm/_InputField/InputFieldValidation.d.ts +0 -6
  103. package/lib-esm/_InputField/InputFieldValidation.js +0 -7
  104. package/lib-esm/_InputField/ToggleInputField.d.ts +0 -13
  105. package/lib-esm/_InputField/ToggleInputField.js +0 -54
  106. package/lib-esm/_InputField/ToggleInputLeadingVisual.d.ts +0 -3
  107. package/lib-esm/_InputField/ToggleInputLeadingVisual.js +0 -11
  108. package/lib-esm/_InputField/ValidationAnimationContainer.d.ts +0 -6
  109. package/lib-esm/_InputField/ValidationAnimationContainer.js +0 -33
  110. package/lib-esm/_InputField/index.d.ts +0 -1
  111. package/lib-esm/_InputField/index.js +0 -1
  112. package/lib-esm/_InputField/slots.d.ts +0 -13
  113. package/lib-esm/_InputField/slots.js +0 -5
  114. package/lib-esm/_InputLabel.d.ts +0 -8
  115. package/lib-esm/_InputLabel.js +0 -32
  116. package/lib-esm/_InputValidation.d.ts +0 -8
  117. package/lib-esm/_InputValidation.js +0 -43
  118. package/lib-esm/_VisuallyHidden.d.ts +0 -6
  119. package/lib-esm/_VisuallyHidden.js +0 -26
  120. package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
  121. package/lib-esm/behaviors/anchoredPosition.js +0 -309
  122. package/lib-esm/behaviors/focusTrap.d.ts +0 -12
  123. package/lib-esm/behaviors/focusTrap.js +0 -170
  124. package/lib-esm/behaviors/focusZone.d.ts +0 -137
  125. package/lib-esm/behaviors/focusZone.js +0 -560
  126. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +0 -1
  127. package/lib-esm/behaviors/scrollIntoViewingArea.js +0 -30
  128. package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
  129. package/lib-esm/utils/iterateFocusableElements.js +0 -102
  130. package/lib-esm/utils/types/FormValidationStatus.d.ts +0 -1
  131. package/lib-esm/utils/types/FormValidationStatus.js +0 -1
  132. package/lib-esm/utils/uniqueId.d.ts +0 -1
  133. package/lib-esm/utils/uniqueId.js +0 -5
  134. package/lib-esm/utils/userAgent.d.ts +0 -1
  135. package/lib-esm/utils/userAgent.js +0 -8
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.iterateFocusableElements = iterateFocusableElements;
7
- exports.isFocusable = isFocusable;
8
- exports.isTabbable = isTabbable;
9
-
10
- /**
11
- * Options to the focusable elements iterator
12
- */
13
-
14
- /**
15
- * Returns an iterator over all of the focusable elements within `container`.
16
- * Note: If `container` is itself focusable it will be included in the results.
17
- * @param container The container over which to find focusable elements.
18
- * @param reverse If true, iterate backwards through focusable elements.
19
- */
20
- function* iterateFocusableElements(container, options = {}) {
21
- var _options$strict, _options$onlyTabbable;
22
-
23
- const strict = (_options$strict = options.strict) !== null && _options$strict !== void 0 ? _options$strict : false;
24
- const acceptFn = ((_options$onlyTabbable = options.onlyTabbable) !== null && _options$onlyTabbable !== void 0 ? _options$onlyTabbable : false) ? isTabbable : isFocusable;
25
- const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
26
- acceptNode: node => node instanceof HTMLElement && acceptFn(node, strict) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
27
- });
28
- let nextNode = null; // Allow the container to participate
29
-
30
- if (!options.reverse && acceptFn(container, strict)) {
31
- yield container;
32
- } // If iterating in reverse, continue traversing down into the last child until we reach
33
- // a leaf DOM node
34
-
35
-
36
- if (options.reverse) {
37
- let lastChild = walker.lastChild();
38
-
39
- while (lastChild) {
40
- nextNode = lastChild;
41
- lastChild = walker.lastChild();
42
- }
43
- } else {
44
- nextNode = walker.firstChild();
45
- }
46
-
47
- while (nextNode instanceof HTMLElement) {
48
- yield nextNode;
49
- nextNode = options.reverse ? walker.previousNode() : walker.nextNode();
50
- } // Allow the container to participate (in reverse)
51
-
52
-
53
- if (options.reverse && acceptFn(container, strict)) {
54
- yield container;
55
- }
56
-
57
- return undefined;
58
- }
59
- /**
60
- * Determines whether the given element is focusable. If `strict` is true, we may
61
- * perform additional checks that require a reflow (less performant).
62
- * @param elem
63
- * @param strict
64
- */
65
-
66
-
67
- function isFocusable(elem, strict = false) {
68
- // Certain conditions cause an element to never be focusable, even if they have tabindex="0"
69
- const disabledAttrInert = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA', 'OPTGROUP', 'OPTION', 'FIELDSET'].includes(elem.tagName) && elem.disabled;
70
- const hiddenInert = elem.hidden;
71
- const hiddenInputInert = elem instanceof HTMLInputElement && elem.type === 'hidden';
72
-
73
- if (disabledAttrInert || hiddenInert || hiddenInputInert) {
74
- return false;
75
- } // Each of the conditions checked below require a reflow, thus are gated by the `strict`
76
- // argument. If any are true, the element is not focusable, even if tabindex is set.
77
-
78
-
79
- if (strict) {
80
- const sizeInert = elem.offsetWidth === 0 || elem.offsetHeight === 0;
81
- const visibilityInert = ['hidden', 'collapse'].includes(getComputedStyle(elem).visibility);
82
- const clientRectsInert = elem.getClientRects().length === 0;
83
-
84
- if (sizeInert || visibilityInert || clientRectsInert) {
85
- return false;
86
- }
87
- } // Any element with `tabindex` explicitly set can be focusable, even if it's set to "-1"
88
-
89
-
90
- if (elem.getAttribute('tabindex') != null) {
91
- return true;
92
- } // One last way `elem.tabIndex` can be wrong.
93
-
94
-
95
- if (elem instanceof HTMLAnchorElement && elem.getAttribute('href') == null) {
96
- return false;
97
- }
98
-
99
- return elem.tabIndex !== -1;
100
- }
101
- /**
102
- * Determines whether the given element is tabbable. If `strict` is true, we may
103
- * perform additional checks that require a reflow (less performant). This check
104
- * ensures that the element is focusable and that its tabindex is not explicitly
105
- * set to "-1" (which makes it focusable, but removes it from the tab order).
106
- * @param elem
107
- * @param strict
108
- */
109
-
110
-
111
- function isTabbable(elem, strict = false) {
112
- return isFocusable(elem, strict) && elem.getAttribute('tabindex') !== '-1';
113
- }
@@ -1 +0,0 @@
1
- export declare type FormValidationStatus = 'error' | 'success';
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- export declare function uniqueId(): string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.uniqueId = uniqueId;
7
- // Note: uniqueId may be unsafe in SSR contexts if it is used create DOM IDs or otherwise cause a hydration warning. Use useSSRSafeId instead.
8
- let idSeed = 10000;
9
-
10
- function uniqueId() {
11
- return `__primer_id_${idSeed++}`;
12
- }
@@ -1 +0,0 @@
1
- export declare function isMacOS(): boolean;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isMacOS = isMacOS;
7
- let isMac = undefined;
8
-
9
- function isMacOS() {
10
- if (isMac === undefined) {
11
- isMac = /^mac/i.test(window.navigator.platform);
12
- }
13
-
14
- return isMac;
15
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- declare const _default: React.FC<import("./_InputField/ToggleInputField").Props> & {
3
- Input: React.FC<Omit<React.HTMLProps<HTMLInputElement>, "ref"> & {
4
- ref?: React.Ref<HTMLInputElement> | undefined;
5
- }>;
6
- Caption: React.FC<{}>;
7
- Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
8
- LeadingVisual: React.FC<{}>;
9
- };
10
- export default _default;
@@ -1,56 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import { Checkbox } from '.';
5
- import InputField from './_InputField/InputField';
6
- import { Slot } from './_InputField/slots';
7
- import ToggleInputField from './_InputField/ToggleInputField';
8
- import ToggleInputLeadingVisual from './_InputField/ToggleInputLeadingVisual';
9
-
10
- const Input = ({
11
- id: idProp,
12
- required: requiredProp,
13
- disabled: disabledProp,
14
- ...rest
15
- }) => {
16
- if (idProp) {
17
- // eslint-disable-next-line no-console
18
- console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
19
- }
20
-
21
- if (disabledProp) {
22
- // eslint-disable-next-line no-console
23
- console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
24
- }
25
-
26
- if (requiredProp) {
27
- // eslint-disable-next-line no-console
28
- console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
29
- }
30
-
31
- return /*#__PURE__*/React.createElement(Slot, {
32
- name: "Input"
33
- }, ({
34
- disabled,
35
- id,
36
- required,
37
- captionId
38
- }) => /*#__PURE__*/React.createElement(Checkbox, _extends({
39
- "aria-describedby": captionId,
40
- id: id,
41
- required: required,
42
- disabled: disabled
43
- }, rest)));
44
- };
45
-
46
- Input.displayName = "Input";
47
-
48
- const CheckboxInputField = props => /*#__PURE__*/React.createElement(ToggleInputField, props);
49
-
50
- CheckboxInputField.displayName = "CheckboxInputField";
51
- export default Object.assign(CheckboxInputField, {
52
- Input,
53
- Caption: InputField.Caption,
54
- Label: InputField.Label,
55
- LeadingVisual: ToggleInputLeadingVisual
56
- });
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { RadioProps } from '.';
3
- declare const _default: React.FC<import("./_InputField/ToggleInputField").Props> & {
4
- Input: React.FC<RadioProps>;
5
- Caption: React.FC<{}>;
6
- Label: React.FC<import("./_InputField/InputFieldLabel").Props>;
7
- LeadingVisual: React.FC<{}>;
8
- };
9
- export default _default;
@@ -1,56 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React from 'react';
4
- import { Radio } from '.';
5
- import InputField from './_InputField/InputField';
6
- import { Slot } from './_InputField/slots';
7
- import ToggleInputField from './_InputField/ToggleInputField';
8
- import ToggleInputLeadingVisual from './_InputField/ToggleInputLeadingVisual'; // pulling out `id`, `disabled`, and `required` because those should come from the parent TextInputField component
9
-
10
- const Input = ({
11
- id: idProp,
12
- required: requiredProp,
13
- disabled: disabledProp,
14
- ...rest
15
- }) => {
16
- if (idProp) {
17
- // eslint-disable-next-line no-console
18
- console.warn("instead of passing the 'id' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
19
- }
20
-
21
- if (disabledProp) {
22
- // eslint-disable-next-line no-console
23
- console.warn("instead of passing the 'disabled' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
24
- }
25
-
26
- if (requiredProp) {
27
- // eslint-disable-next-line no-console
28
- console.warn("instead of passing the 'required' prop directly to <TextInputField.Input>, it should be passed to the parent component, <TextInputField>");
29
- }
30
-
31
- return /*#__PURE__*/React.createElement(Slot, {
32
- name: "Input"
33
- }, ({
34
- disabled,
35
- id,
36
- required,
37
- captionId
38
- }) => /*#__PURE__*/React.createElement(Radio, _extends({
39
- "aria-describedby": captionId,
40
- id: id,
41
- required: required,
42
- disabled: disabled
43
- }, rest)));
44
- };
45
-
46
- Input.displayName = "Input";
47
-
48
- const RadioInputField = props => /*#__PURE__*/React.createElement(ToggleInputField, props);
49
-
50
- RadioInputField.displayName = "RadioInputField";
51
- export default Object.assign(RadioInputField, {
52
- Input,
53
- Caption: InputField.Caption,
54
- Label: InputField.Label,
55
- LeadingVisual: ToggleInputLeadingVisual
56
- });