@primer/react 34.0.0 → 34.0.1

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 (113) 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/ActionList2/Selection.js +0 -1
  8. package/lib/ActionMenu2.d.ts +0 -2
  9. package/lib/ActionMenu2.js +1 -3
  10. package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  11. package/lib/Autocomplete/Autocomplete.d.ts +12 -3
  12. package/lib/Autocomplete/AutocompleteInput.d.ts +12 -3
  13. package/lib/Autocomplete/AutocompleteMenu.js +10 -5
  14. package/lib/Dialog/ConfirmationDialog.js +2 -2
  15. package/lib/Dialog/Dialog.js +2 -2
  16. package/lib/FilteredActionList/FilteredActionList.js +10 -3
  17. package/lib/NewButton/button-base.d.ts +6 -0
  18. package/lib/NewButton/button-base.js +69 -0
  19. package/lib/NewButton/button-link.d.ts +27 -0
  20. package/lib/NewButton/button-link.js +31 -0
  21. package/lib/NewButton/button.d.ts +2 -11
  22. package/lib/NewButton/button.js +6 -283
  23. package/lib/NewButton/icon-button.d.ts +4 -0
  24. package/lib/NewButton/icon-button.js +62 -0
  25. package/lib/NewButton/index.d.ts +6 -11
  26. package/lib/NewButton/index.js +18 -0
  27. package/lib/NewButton/styles.d.ts +204 -0
  28. package/lib/NewButton/styles.js +249 -0
  29. package/lib/NewButton/types.d.ts +28 -8
  30. package/lib/NewButton/types.js +19 -1
  31. package/lib/Overlay.d.ts +1 -1
  32. package/lib/SelectMenu/SelectMenu.d.ts +12 -3
  33. package/lib/TextInput.d.ts +8 -1
  34. package/lib/TextInput.js +19 -6
  35. package/lib/TextInputWithTokens.d.ts +12 -3
  36. package/lib/TextInputWithTokens.js +14 -11
  37. package/lib/_TextInputWrapper.d.ts +6 -1
  38. package/lib/_TextInputWrapper.js +21 -8
  39. package/lib/hooks/useAnchoredPosition.d.ts +1 -1
  40. package/lib/hooks/useAnchoredPosition.js +2 -2
  41. package/lib/hooks/useFocusTrap.js +2 -2
  42. package/lib/hooks/useFocusZone.d.ts +3 -1
  43. package/lib/hooks/useFocusZone.js +8 -2
  44. package/lib/hooks/useOpenAndCloseFocus.js +2 -2
  45. package/lib-esm/ActionList/Item.js +1 -1
  46. package/lib-esm/ActionList/List.js +1 -1
  47. package/lib-esm/ActionList2/Selection.js +0 -1
  48. package/lib-esm/ActionMenu2.d.ts +0 -2
  49. package/lib-esm/ActionMenu2.js +1 -1
  50. package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -1
  51. package/lib-esm/Autocomplete/Autocomplete.d.ts +12 -3
  52. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +12 -3
  53. package/lib-esm/Autocomplete/AutocompleteMenu.js +9 -4
  54. package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
  55. package/lib-esm/Dialog/Dialog.js +1 -1
  56. package/lib-esm/FilteredActionList/FilteredActionList.js +9 -3
  57. package/lib-esm/NewButton/button-base.d.ts +6 -0
  58. package/lib-esm/NewButton/button-base.js +47 -0
  59. package/lib-esm/NewButton/button-link.d.ts +27 -0
  60. package/lib-esm/NewButton/button-link.js +15 -0
  61. package/lib-esm/NewButton/button.d.ts +2 -11
  62. package/lib-esm/NewButton/button.js +4 -275
  63. package/lib-esm/NewButton/icon-button.d.ts +4 -0
  64. package/lib-esm/NewButton/icon-button.js +39 -0
  65. package/lib-esm/NewButton/index.d.ts +6 -11
  66. package/lib-esm/NewButton/index.js +4 -1
  67. package/lib-esm/NewButton/styles.d.ts +204 -0
  68. package/lib-esm/NewButton/styles.js +230 -0
  69. package/lib-esm/NewButton/types.d.ts +28 -8
  70. package/lib-esm/NewButton/types.js +6 -1
  71. package/lib-esm/Overlay.d.ts +1 -1
  72. package/lib-esm/SelectMenu/SelectMenu.d.ts +12 -3
  73. package/lib-esm/TextInput.d.ts +8 -1
  74. package/lib-esm/TextInput.js +19 -6
  75. package/lib-esm/TextInputWithTokens.d.ts +12 -3
  76. package/lib-esm/TextInputWithTokens.js +12 -9
  77. package/lib-esm/_TextInputWrapper.d.ts +6 -1
  78. package/lib-esm/_TextInputWrapper.js +19 -7
  79. package/lib-esm/hooks/useAnchoredPosition.d.ts +1 -1
  80. package/lib-esm/hooks/useAnchoredPosition.js +1 -1
  81. package/lib-esm/hooks/useFocusTrap.js +1 -1
  82. package/lib-esm/hooks/useFocusZone.d.ts +3 -1
  83. package/lib-esm/hooks/useFocusZone.js +2 -1
  84. package/lib-esm/hooks/useOpenAndCloseFocus.js +1 -1
  85. package/package.json +6 -10
  86. package/lib/behaviors/anchoredPosition.d.ts +0 -89
  87. package/lib/behaviors/anchoredPosition.js +0 -316
  88. package/lib/behaviors/focusTrap.d.ts +0 -12
  89. package/lib/behaviors/focusTrap.js +0 -179
  90. package/lib/behaviors/focusZone.d.ts +0 -137
  91. package/lib/behaviors/focusZone.js +0 -578
  92. package/lib/behaviors/scrollIntoViewingArea.d.ts +0 -1
  93. package/lib/behaviors/scrollIntoViewingArea.js +0 -39
  94. package/lib/utils/iterateFocusableElements.d.ts +0 -42
  95. package/lib/utils/iterateFocusableElements.js +0 -113
  96. package/lib/utils/uniqueId.d.ts +0 -1
  97. package/lib/utils/uniqueId.js +0 -12
  98. package/lib/utils/userAgent.d.ts +0 -1
  99. package/lib/utils/userAgent.js +0 -15
  100. package/lib-esm/behaviors/anchoredPosition.d.ts +0 -89
  101. package/lib-esm/behaviors/anchoredPosition.js +0 -309
  102. package/lib-esm/behaviors/focusTrap.d.ts +0 -12
  103. package/lib-esm/behaviors/focusTrap.js +0 -170
  104. package/lib-esm/behaviors/focusZone.d.ts +0 -137
  105. package/lib-esm/behaviors/focusZone.js +0 -560
  106. package/lib-esm/behaviors/scrollIntoViewingArea.d.ts +0 -1
  107. package/lib-esm/behaviors/scrollIntoViewingArea.js +0 -30
  108. package/lib-esm/utils/iterateFocusableElements.d.ts +0 -42
  109. package/lib-esm/utils/iterateFocusableElements.js +0 -102
  110. package/lib-esm/utils/uniqueId.d.ts +0 -1
  111. package/lib-esm/utils/uniqueId.js +0 -5
  112. package/lib-esm/utils/userAgent.d.ts +0 -1
  113. package/lib-esm/utils/userAgent.js +0 -8
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.textInputHorizPadding = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
@@ -19,7 +19,24 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
19
 
20
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
+ const sizeDeprecatedVariants = (0, _styledSystem.variant)({
23
+ variants: {
24
+ small: {
25
+ minHeight: '28px',
26
+ px: 2,
27
+ py: '3px',
28
+ fontSize: 0,
29
+ lineHeight: '20px'
30
+ },
31
+ large: {
32
+ px: 2,
33
+ py: '10px',
34
+ fontSize: 3
35
+ }
36
+ }
37
+ });
22
38
  const sizeVariants = (0, _styledSystem.variant)({
39
+ prop: 'size',
23
40
  variants: {
24
41
  small: {
25
42
  minHeight: '28px',
@@ -35,17 +52,13 @@ const sizeVariants = (0, _styledSystem.variant)({
35
52
  }
36
53
  }
37
54
  });
55
+ const textInputHorizPadding = '12px';
56
+ exports.textInputHorizPadding = textInputHorizPadding;
38
57
 
39
58
  const TextInputWrapper = _styledComponents.default.span.withConfig({
40
59
  displayName: "_TextInputWrapper__TextInputWrapper",
41
60
  componentId: "sc-apywy2-0"
42
- })(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
43
- if (props.hasIcon) {
44
- return (0, _styledComponents.css)(["padding:0;"]);
45
- } else {
46
- return (0, _styledComponents.css)(["padding:6px 12px;"]);
47
- }
48
- }, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), props => props.block && props.hasIcon && (0, _styledComponents.css)(["display:flex;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
61
+ })(["min-height:32px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-color:", ";background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;display:inline-flex;align-items:stretch;& >:not(:last-child){margin-right:", ";}", " .TextInput-icon{align-self:center;color:", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.canvas.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), (0, _constants.get)('space.2'), props => (0, _styledComponents.css)(["padding-left:", ";padding-right:", ";> input{padding-left:", ";padding-right:", ";}"], props.hasLeadingVisual ? textInputHorizPadding : 0, props.hasTrailingVisual ? textInputHorizPadding : 0, !props.hasLeadingVisual ? textInputHorizPadding : 0, !props.hasTrailingVisual ? textInputHorizPadding : 0), (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.validationStatus === 'error' && (0, _styledComponents.css)(["border-color:", ";&:focus-within{border-color:", ";box-shadow:", ";}"], (0, _constants.get)('colors.danger.emphasis'), (0, _constants.get)('colors.danger.emphasis'), (0, _constants.get)('shadows.btn.danger.focusShadow')), props => props.validationStatus === 'warning' && (0, _styledComponents.css)(["border-color:", ";&:focus-within{border-color:", ";box-shadow:0 0 0 3px ", ";}"], (0, _constants.get)('colors.attention.emphasis'), (0, _constants.get)('colors.attention.emphasis'), (0, _constants.get)('colors.attention.muted')), props => props.block && (0, _styledComponents.css)(["width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeDeprecatedVariants, sizeVariants, _sx.default);
49
62
 
50
63
  var _default = TextInputWrapper;
51
64
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { PositionSettings, AnchorPosition } from '../behaviors/anchoredPosition';
2
+ import type { AnchorPosition, PositionSettings } from '@primer/behaviors';
3
3
  export interface AnchoredPositionHookSettings extends Partial<PositionSettings> {
4
4
  floatingElementRef?: React.RefObject<Element>;
5
5
  anchorElementRef?: React.RefObject<Element>;
@@ -7,7 +7,7 @@ exports.useAnchoredPosition = useAnchoredPosition;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _anchoredPosition = require("../behaviors/anchoredPosition");
10
+ var _behaviors = require("@primer/behaviors");
11
11
 
12
12
  var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
13
13
 
@@ -34,7 +34,7 @@ function useAnchoredPosition(settings, dependencies = []) {
34
34
 
35
35
  const updatePosition = _react.default.useCallback(() => {
36
36
  if (floatingElementRef.current instanceof Element && anchorElementRef.current instanceof Element) {
37
- setPosition((0, _anchoredPosition.getAnchoredPosition)(floatingElementRef.current, anchorElementRef.current, settings));
37
+ setPosition((0, _behaviors.getAnchoredPosition)(floatingElementRef.current, anchorElementRef.current, settings));
38
38
  } else {
39
39
  setPosition(undefined);
40
40
  }
@@ -7,7 +7,7 @@ exports.useFocusTrap = useFocusTrap;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
10
- var _focusTrap = require("../behaviors/focusTrap");
10
+ var _behaviors = require("@primer/behaviors");
11
11
 
12
12
  var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
13
13
 
@@ -51,7 +51,7 @@ function useFocusTrap(settings, dependencies = []) {
51
51
  if (!disabled) {
52
52
  var _initialFocusRef$curr;
53
53
 
54
- abortController.current = (0, _focusTrap.focusTrap)(containerRef.current, (_initialFocusRef$curr = initialFocusRef.current) !== null && _initialFocusRef$curr !== void 0 ? _initialFocusRef$curr : undefined);
54
+ abortController.current = (0, _behaviors.focusTrap)(containerRef.current, (_initialFocusRef$curr = initialFocusRef.current) !== null && _initialFocusRef$curr !== void 0 ? _initialFocusRef$curr : undefined);
55
55
  return () => {
56
56
  disableTrap();
57
57
  };
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- import { FocusZoneSettings } from '../behaviors/focusZone';
2
+ import type { FocusZoneSettings } from '@primer/behaviors';
3
+ export { FocusKeys } from '@primer/behaviors';
4
+ export type { Direction } from '@primer/behaviors';
3
5
  export interface FocusZoneHookSettings extends Omit<FocusZoneSettings, 'activeDescendantControl'> {
4
6
  /**
5
7
  * Optional ref for the container that holds all elements participating in arrow key focus.
@@ -4,10 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useFocusZone = useFocusZone;
7
+ Object.defineProperty(exports, "FocusKeys", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _behaviors.FocusKeys;
11
+ }
12
+ });
7
13
 
8
14
  var _react = _interopRequireWildcard(require("react"));
9
15
 
10
- var _focusZone = require("../behaviors/focusZone");
16
+ var _behaviors = require("@primer/behaviors");
11
17
 
12
18
  var _useProvidedRefOrCreate = require("./useProvidedRefOrCreate");
13
19
 
@@ -32,7 +38,7 @@ function useFocusZone(settings = {}, dependencies = []) {
32
38
  const vanillaSettings = { ...settings,
33
39
  activeDescendantControl: (_activeDescendantCont = activeDescendantControlRef.current) !== null && _activeDescendantCont !== void 0 ? _activeDescendantCont : undefined
34
40
  };
35
- abortController.current = (0, _focusZone.focusZone)(containerRef.current, vanillaSettings);
41
+ abortController.current = (0, _behaviors.focusZone)(containerRef.current, vanillaSettings);
36
42
  return () => {
37
43
  var _abortController$curr;
38
44
 
@@ -7,7 +7,7 @@ exports.useOpenAndCloseFocus = useOpenAndCloseFocus;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- var _iterateFocusableElements = require("../utils/iterateFocusableElements");
10
+ var _utils = require("@primer/behaviors/utils");
11
11
 
12
12
  function useOpenAndCloseFocus({
13
13
  initialFocusRef,
@@ -25,7 +25,7 @@ function useOpenAndCloseFocus({
25
25
  if (initialFocusRef && initialFocusRef.current) {
26
26
  initialFocusRef.current.focus();
27
27
  } else if (containerRef.current) {
28
- const firstItem = (0, _iterateFocusableElements.iterateFocusableElements)(containerRef.current).next().value;
28
+ const firstItem = (0, _utils.iterateFocusableElements)(containerRef.current).next().value;
29
29
  firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
30
30
  }
31
31
 
@@ -9,7 +9,7 @@ import styled from 'styled-components';
9
9
  import { StyledHeader } from './Header';
10
10
  import { StyledDivider } from './Divider';
11
11
  import { useTheme } from '../ThemeProvider';
12
- import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '../behaviors/focusZone';
12
+ import { activeDescendantActivatedDirectly, activeDescendantActivatedIndirectly, isActiveDescendantAttribute } from '@primer/behaviors';
13
13
  import { useSSRSafeId } from '@react-aria/ssr';
14
14
 
15
15
  const getItemVariant = (variant = 'default', disabled) => {
@@ -6,7 +6,7 @@ import { Item } from './Item';
6
6
  import { Divider } from './Divider';
7
7
  import styled from 'styled-components';
8
8
  import { get } from '../constants';
9
- import { hasActiveDescendantAttribute } from '../behaviors/focusZone';
9
+ import { hasActiveDescendantAttribute } from '@primer/behaviors';
10
10
 
11
11
  /**
12
12
  * Asserts that the given value fulfills the `GroupedListProps` contract.
@@ -28,7 +28,6 @@ export const Selection = ({
28
28
 
29
29
  if (container === 'ActionMenu') {
30
30
  throw new Error('ActionList cannot have a selectionVariant inside ActionMenu, please use DropdownMenu or SelectPanel instead. More information: https://primer.style/design/components/action-list#application');
31
- return null;
32
31
  }
33
32
 
34
33
  if (selectionVariant === 'single') {
@@ -2,8 +2,6 @@ import { ButtonProps } from './Button';
2
2
  import React from 'react';
3
3
  import { AnchoredOverlayProps } from './AnchoredOverlay';
4
4
  import { OverlayProps } from './Overlay';
5
- declare type MenuContextProps = Pick<AnchoredOverlayProps, 'anchorRef' | 'renderAnchor' | 'open' | 'onOpen' | 'onClose'>;
6
- export declare const MenuContext: React.Context<MenuContextProps>;
7
5
  export declare type ActionMenuProps = {
8
6
  /**
9
7
  * Recommended: `ActionMenu.Button` or `ActionMenu.Anchor` with `ActionMenu.Overlay`
@@ -4,7 +4,7 @@ import { AnchoredOverlay } from './AnchoredOverlay';
4
4
  import { useProvidedRefOrCreate, useProvidedStateOrCreate } from './hooks';
5
5
  import { Divider } from './ActionList2/Divider';
6
6
  import { ActionListContainerContext } from './ActionList2/ActionListContainerContext';
7
- export const MenuContext = /*#__PURE__*/React.createContext({
7
+ const MenuContext = /*#__PURE__*/React.createContext({
8
8
  renderAnchor: null,
9
9
  open: false
10
10
  });
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { OverlayProps } from '../Overlay';
3
3
  import { FocusTrapHookSettings } from '../hooks/useFocusTrap';
4
4
  import { FocusZoneHookSettings } from '../hooks/useFocusZone';
5
- import { PositionSettings } from '../behaviors/anchoredPosition';
5
+ import type { PositionSettings } from '@primer/behaviors';
6
6
  interface AnchoredOverlayPropsWithAnchor {
7
7
  /**
8
8
  * A custom function component used to render the anchor element.
@@ -21,11 +21,17 @@ declare const _default: React.FC<{
21
21
  } & {
22
22
  as?: string | React.ComponentType<any> | undefined;
23
23
  forwardedAs?: string | React.ComponentType<any> | undefined;
24
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
24
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
25
25
  className?: string | undefined;
26
26
  icon?: React.ComponentType<{
27
27
  className?: string | undefined;
28
28
  }> | undefined;
29
+ leadingVisual?: string | React.ComponentType<{
30
+ className?: string | undefined;
31
+ }> | undefined;
32
+ trailingVisual?: string | React.ComponentType<{
33
+ className?: string | undefined;
34
+ }> | undefined;
29
35
  } & Pick<{
30
36
  color?: string | undefined;
31
37
  property?: string | undefined;
@@ -39,6 +45,7 @@ declare const _default: React.FC<{
39
45
  slot?: string | undefined;
40
46
  style?: React.CSSProperties | undefined;
41
47
  title?: string | undefined;
48
+ size?: "small" | "large" | undefined;
42
49
  block?: boolean | undefined;
43
50
  variant?: "small" | "large" | undefined;
44
51
  role?: React.AriaRole | undefined;
@@ -293,11 +300,13 @@ declare const _default: React.FC<{
293
300
  onTransitionEndCapture?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
294
301
  css?: import("@emotion/core").InterpolationWithTheme<any>;
295
302
  disabled?: boolean | undefined;
296
- hasIcon?: boolean | undefined;
303
+ validationStatus?: "error" | "warning" | undefined;
304
+ hasLeadingVisual?: boolean | undefined;
305
+ hasTrailingVisual?: boolean | undefined;
297
306
  contrast?: boolean | undefined;
298
307
  } & {
299
308
  theme?: any;
300
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, {
309
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, {
301
310
  as?: React.ComponentType<any> | undefined;
302
311
  }>;
303
312
  Menu: typeof AutocompleteMenu;
@@ -13,11 +13,17 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
13
13
  } & {
14
14
  as?: string | React.ComponentType<any> | undefined;
15
15
  forwardedAs?: string | React.ComponentType<any> | undefined;
16
- }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "contrast"> & {
16
+ }, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "size" | "block" | "icon" | "variant" | "sx" | "className" | "disabled" | "leadingVisual" | "trailingVisual" | "contrast"> & {
17
17
  className?: string | undefined;
18
18
  icon?: React.ComponentType<{
19
19
  className?: string | undefined;
20
20
  }> | undefined;
21
+ leadingVisual?: string | React.ComponentType<{
22
+ className?: string | undefined;
23
+ }> | undefined;
24
+ trailingVisual?: string | React.ComponentType<{
25
+ className?: string | undefined;
26
+ }> | undefined;
21
27
  } & Pick<{
22
28
  color?: string | undefined;
23
29
  property?: string | undefined;
@@ -31,6 +37,7 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
31
37
  slot?: string | undefined;
32
38
  style?: React.CSSProperties | undefined;
33
39
  title?: string | undefined;
40
+ size?: "small" | "large" | undefined;
34
41
  block?: boolean | undefined;
35
42
  variant?: "small" | "large" | undefined;
36
43
  role?: React.AriaRole | undefined;
@@ -285,10 +292,12 @@ declare const AutocompleteInput: PolymorphicForwardRefComponent<React.ForwardRef
285
292
  onTransitionEndCapture?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
286
293
  css?: import("@emotion/core").InterpolationWithTheme<any>;
287
294
  disabled?: boolean | undefined;
288
- hasIcon?: boolean | undefined;
295
+ validationStatus?: "error" | "warning" | undefined;
296
+ hasLeadingVisual?: boolean | undefined;
297
+ hasTrailingVisual?: boolean | undefined;
289
298
  contrast?: boolean | undefined;
290
299
  } & {
291
300
  theme?: any;
292
- }, "maxWidth" | "minWidth" | "width" | "theme" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, InternalAutocompleteInputProps>;
301
+ }, "maxWidth" | "minWidth" | "width" | "size" | "block" | "variant" | "sx" | "disabled" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement>>, InternalAutocompleteInputProps>;
293
302
  export declare type AutocompleteInputProps = ComponentProps<typeof AutocompleteInput>;
294
303
  export default AutocompleteInput;
@@ -4,11 +4,16 @@ import { useFocusZone } from '../hooks/useFocusZone';
4
4
  import { Box, Spinner } from '../';
5
5
  import { AutocompleteContext } from './AutocompleteContext';
6
6
  import { PlusIcon } from '@primer/octicons-react';
7
- import { uniqueId } from '../utils/uniqueId';
8
- import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
7
+ import { uniqueId } from '@primer/behaviors/utils';
8
+ import { scrollIntoView } from '@primer/behaviors';
9
9
 
10
10
  const getDefaultSortFn = isItemSelectedFn => (itemIdA, itemIdB) => isItemSelectedFn(itemIdA) === isItemSelectedFn(itemIdB) ? 0 : isItemSelectedFn(itemIdA) ? -1 : 1;
11
11
 
12
+ const menuScrollMargins = {
13
+ startMargin: 0,
14
+ endMargin: 8
15
+ };
16
+
12
17
  function getDefaultItemFilter(filterValue) {
13
18
  return function (item, _i) {
14
19
  var _item$text;
@@ -134,9 +139,9 @@ function AutocompleteMenu(props) {
134
139
  }
135
140
 
136
141
  if (current && customScrollContainerRef && customScrollContainerRef.current && directlyActivated) {
137
- scrollIntoViewingArea(current, customScrollContainerRef.current);
142
+ scrollIntoView(current, customScrollContainerRef.current, menuScrollMargins);
138
143
  } else if (current && scrollContainerRef.current && directlyActivated) {
139
- scrollIntoViewingArea(current, scrollContainerRef.current);
144
+ scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
140
145
  }
141
146
  }
142
147
  }, [loading]);
@@ -5,7 +5,7 @@ import ReactDOM from 'react-dom';
5
5
  import styled from 'styled-components';
6
6
  import Box from '../Box';
7
7
  import { ThemeProvider, useTheme } from '../ThemeProvider';
8
- import { FocusKeys } from '../behaviors/focusZone';
8
+ import { FocusKeys } from '@primer/behaviors';
9
9
  import { get } from '../constants';
10
10
  import { Dialog } from '../Dialog/Dialog';
11
11
  import { useFocusZone } from '../hooks/useFocusZone';
@@ -11,7 +11,7 @@ import sx from '../sx';
11
11
  import StyledOcticon from '../StyledOcticon';
12
12
  import { XIcon } from '@primer/octicons-react';
13
13
  import { useFocusZone } from '../hooks/useFocusZone';
14
- import { FocusKeys } from '../behaviors/focusZone';
14
+ import { FocusKeys } from '@primer/behaviors';
15
15
  import Portal from '../Portal';
16
16
  import { useCombinedRefs } from '../hooks/useCombinedRefs';
17
17
  import { useSSRSafeId } from '@react-aria/ssr';
@@ -12,7 +12,11 @@ import styled from 'styled-components';
12
12
  import { get } from '../constants';
13
13
  import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
14
14
  import useScrollFlash from '../hooks/useScrollFlash';
15
- import { scrollIntoViewingArea } from '../behaviors/scrollIntoViewingArea';
15
+ import { scrollIntoView } from '@primer/behaviors';
16
+ const menuScrollMargins = {
17
+ startMargin: 0,
18
+ endMargin: 8
19
+ };
16
20
  const StyledHeader = styled.div.withConfig({
17
21
  displayName: "FilteredActionList__StyledHeader",
18
22
  componentId: "sc-1oqgb0s-0"
@@ -59,7 +63,7 @@ export function FilteredActionList({
59
63
  activeDescendantRef.current = current;
60
64
 
61
65
  if (current && scrollContainerRef.current && directlyActivated) {
62
- scrollIntoViewingArea(current, scrollContainerRef.current);
66
+ scrollIntoView(current, scrollContainerRef.current, menuScrollMargins);
63
67
  }
64
68
  }
65
69
  }, [// List ref isn't set while loading. Need to re-bind focus zone when it changes
@@ -67,7 +71,9 @@ export function FilteredActionList({
67
71
  useEffect(() => {
68
72
  // if items changed, we want to instantly move active descendant into view
69
73
  if (activeDescendantRef.current && scrollContainerRef.current) {
70
- scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, 'vertical', undefined, undefined, 'auto');
74
+ scrollIntoView(activeDescendantRef.current, scrollContainerRef.current, { ...menuScrollMargins,
75
+ behavior: 'auto'
76
+ });
71
77
  }
72
78
  }, [items]);
73
79
  useScrollFlash(scrollContainerRef);
@@ -0,0 +1,6 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ import { ButtonProps } from './types';
4
+ declare const ButtonBase: PolymorphicForwardRefComponent<"a" | "button", ButtonProps>;
5
+ export declare type ButtonBaseProps = ComponentPropsWithRef<typeof ButtonBase>;
6
+ export default ButtonBase;
@@ -0,0 +1,47 @@
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, { forwardRef } from 'react';
4
+ import Box from '../Box';
5
+ import { merge } from '../sx';
6
+ import { useTheme } from '../ThemeProvider';
7
+ import { StyledButton } from './types';
8
+ import { getVariantStyles, getSizeStyles, getButtonStyles } from './styles';
9
+ const ButtonBase = /*#__PURE__*/forwardRef(({
10
+ children,
11
+ as: Component = 'button',
12
+ sx: sxProp = {},
13
+ ...props
14
+ }, forwardedRef) => {
15
+ const {
16
+ leadingIcon: LeadingIcon,
17
+ trailingIcon: TrailingIcon,
18
+ variant = 'default',
19
+ size = 'medium'
20
+ } = props;
21
+ const {
22
+ theme
23
+ } = useTheme();
24
+ const iconWrapStyles = {
25
+ display: 'inline-block'
26
+ };
27
+ const sxStyles = merge.all([getButtonStyles(theme), getSizeStyles(size, variant, false), getVariantStyles(variant, theme), sxProp]);
28
+ return /*#__PURE__*/React.createElement(StyledButton, _extends({
29
+ as: Component,
30
+ sx: sxStyles
31
+ }, props, {
32
+ ref: forwardedRef
33
+ }), LeadingIcon && /*#__PURE__*/React.createElement(Box, {
34
+ as: "span",
35
+ "data-component": "leadingIcon",
36
+ sx: iconWrapStyles
37
+ }, /*#__PURE__*/React.createElement(LeadingIcon, null)), /*#__PURE__*/React.createElement("span", {
38
+ "data-component": "text"
39
+ }, children), TrailingIcon && /*#__PURE__*/React.createElement(Box, {
40
+ as: "span",
41
+ "data-component": "trailingIcon",
42
+ sx: { ...iconWrapStyles,
43
+ ml: 2
44
+ }
45
+ }, /*#__PURE__*/React.createElement(TrailingIcon, null)));
46
+ });
47
+ export default ButtonBase;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
3
+ declare const LinkButton: PolymorphicForwardRefComponent<"a", Omit<(Pick<React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "key" | keyof React.AnchorHTMLAttributes<HTMLAnchorElement>> & {
4
+ ref?: ((instance: HTMLAnchorElement | null) => void) | React.RefObject<HTMLAnchorElement> | null | undefined;
5
+ }) | (Pick<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "key" | keyof React.ButtonHTMLAttributes<HTMLButtonElement>> & {
6
+ ref?: ((instance: HTMLButtonElement | null) => void) | React.RefObject<HTMLButtonElement> | null | undefined;
7
+ }), string | number | symbol> & {
8
+ leadingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
+ trailingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
+ children: React.ReactNode;
11
+ } & {
12
+ variant?: import("./types").VariantType | undefined;
13
+ size?: import("./types").Size | undefined;
14
+ disabled?: boolean | undefined;
15
+ } & import("../sx").SxProp & React.HTMLAttributes<HTMLButtonElement> & {
16
+ [x: string]: any;
17
+ [x: number]: any;
18
+ [x: symbol]: any;
19
+ } & {
20
+ theme?: any;
21
+ } & {
22
+ as?: string | React.ComponentType<any> | undefined;
23
+ forwardedAs?: string | React.ComponentType<any> | undefined;
24
+ } & {
25
+ as?: "a" | "button" | undefined;
26
+ }>;
27
+ export default LinkButton;
@@ -0,0 +1,15 @@
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, { forwardRef } from 'react';
4
+ import ButtonBase from './button-base';
5
+ const LinkButton = /*#__PURE__*/forwardRef(({
6
+ children,
7
+ as: Component = 'a',
8
+ ...props
9
+ }, forwardedRef) => {
10
+ return /*#__PURE__*/React.createElement(ButtonBase, _extends({
11
+ as: Component,
12
+ ref: forwardedRef
13
+ }, props), children);
14
+ });
15
+ export default LinkButton;
@@ -1,13 +1,4 @@
1
1
  import React from 'react';
2
- import { SxProp } from '../sx';
3
- import { VariantType } from './types';
4
- declare const Button: React.ForwardRefExoticComponent<{
5
- variant?: VariantType | undefined;
6
- size?: import("./types").Size | undefined;
7
- icon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
8
- leadingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
9
- trailingIcon?: React.FunctionComponent<import("@primer/octicons-react/dist/icons").IconProps> | undefined;
10
- disabled?: boolean | undefined;
11
- children: React.ReactNode;
12
- } & SxProp & React.HTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
2
+ import { ButtonProps } from './types';
3
+ declare const Button: React.ForwardRefExoticComponent<Pick<ButtonProps, string | number | symbol> & React.RefAttributes<HTMLButtonElement>>;
13
4
  export { Button };