@primer/components 0.0.0-20219818220 → 0.0.0-202198182351
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.
- package/CHANGELOG.md +1 -1
- package/dist/browser.esm.js +313 -297
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +387 -371
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib/FilteredActionList/FilteredActionList.js +31 -5
- package/lib/Overlay.d.ts +1 -2
- package/lib/Overlay.js +5 -10
- package/lib/TextInput.d.ts +12 -4
- package/lib/TextInput.js +46 -4
- package/lib/Token/AvatarToken.d.ts +7 -0
- package/lib/Token/{ProfileToken.js → AvatarToken.js} +4 -4
- package/lib/Token/_TokenTextContainer.js +3 -14
- package/lib/Token/index.d.ts +1 -1
- package/lib/Token/index.js +3 -3
- package/lib/hooks/useOpenAndCloseFocus.d.ts +1 -2
- package/lib/hooks/useOpenAndCloseFocus.js +2 -7
- package/lib/hooks/useOverlay.d.ts +1 -2
- package/lib/hooks/useOverlay.js +2 -4
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -18
- package/lib/utils/types/index.d.ts +0 -1
- package/lib/utils/types/index.js +0 -13
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib-esm/FilteredActionList/FilteredActionList.js +31 -3
- package/lib-esm/Overlay.d.ts +1 -2
- package/lib-esm/Overlay.js +5 -8
- package/lib-esm/TextInput.d.ts +12 -4
- package/lib-esm/TextInput.js +37 -4
- package/lib-esm/Token/AvatarToken.d.ts +7 -0
- package/lib-esm/Token/{ProfileToken.js → AvatarToken.js} +4 -4
- package/lib-esm/Token/_TokenTextContainer.js +2 -11
- package/lib-esm/Token/index.d.ts +1 -1
- package/lib-esm/Token/index.js +1 -1
- package/lib-esm/hooks/useOpenAndCloseFocus.d.ts +1 -2
- package/lib-esm/hooks/useOpenAndCloseFocus.js +2 -7
- package/lib-esm/hooks/useOverlay.d.ts +1 -2
- package/lib-esm/hooks/useOverlay.js +2 -4
- package/lib-esm/index.d.ts +1 -3
- package/lib-esm/index.js +1 -3
- package/lib-esm/utils/types/index.d.ts +0 -1
- package/lib-esm/utils/types/index.js +1 -2
- package/package.json +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib/Autocomplete/Autocomplete.js +0 -68
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib/Autocomplete/AutocompleteInput.js +0 -150
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib/Autocomplete/AutocompleteMenu.js +0 -223
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteOverlay.js +0 -69
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/TextInputWithTokens.d.ts +0 -323
- package/lib/TextInputWithTokens.js +0 -244
- package/lib/Token/ProfileToken.d.ts +0 -7
- package/lib/_TextInputWrapper.d.ts +0 -10
- package/lib/_TextInputWrapper.js +0 -51
- package/lib/_UnstyledTextInput.d.ts +0 -2
- package/lib/_UnstyledTextInput.js +0 -20
- package/lib/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib/utils/scrollIntoViewingArea.js +0 -39
- package/lib/utils/types/MandateProps.d.ts +0 -3
- package/lib/utils/types/MandateProps.js +0 -1
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib-esm/Autocomplete/Autocomplete.js +0 -47
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -131
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -204
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +0 -51
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/TextInputWithTokens.d.ts +0 -323
- package/lib-esm/TextInputWithTokens.js +0 -219
- package/lib-esm/Token/ProfileToken.d.ts +0 -7
- package/lib-esm/_TextInputWrapper.d.ts +0 -10
- package/lib-esm/_TextInputWrapper.js +0 -31
- package/lib-esm/_UnstyledTextInput.d.ts +0 -2
- package/lib-esm/_UnstyledTextInput.js +0 -7
- package/lib-esm/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/utils/scrollIntoViewingArea.js +0 -30
- package/lib-esm/utils/types/MandateProps.d.ts +0 -3
- package/lib-esm/utils/types/MandateProps.js +0 -1
@@ -1,7 +1,6 @@
|
|
1
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
2
|
|
3
3
|
import React, { useCallback, useEffect, useRef } from 'react';
|
4
|
-
import { useSSRSafeId } from '@react-aria/ssr';
|
5
4
|
import TextInput from '../TextInput';
|
6
5
|
import Box from '../Box';
|
7
6
|
import { ActionList } from '../ActionList';
|
@@ -12,7 +11,36 @@ import styled from 'styled-components';
|
|
12
11
|
import { get } from '../constants';
|
13
12
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate';
|
14
13
|
import useScrollFlash from '../hooks/useScrollFlash';
|
15
|
-
import {
|
14
|
+
import { useSSRSafeId } from '@react-aria/ssr';
|
15
|
+
|
16
|
+
function scrollIntoViewingArea(child, container, margin = 8, behavior = 'smooth') {
|
17
|
+
const {
|
18
|
+
top: childTop,
|
19
|
+
bottom: childBottom
|
20
|
+
} = child.getBoundingClientRect();
|
21
|
+
const {
|
22
|
+
top: containerTop,
|
23
|
+
bottom: containerBottom
|
24
|
+
} = container.getBoundingClientRect();
|
25
|
+
const isChildTopAboveViewingArea = childTop < containerTop + margin;
|
26
|
+
const isChildBottomBelowViewingArea = childBottom > containerBottom - margin;
|
27
|
+
|
28
|
+
if (isChildTopAboveViewingArea) {
|
29
|
+
const scrollHeightToChildTop = childTop - containerTop + container.scrollTop;
|
30
|
+
container.scrollTo({
|
31
|
+
behavior,
|
32
|
+
top: scrollHeightToChildTop - margin
|
33
|
+
});
|
34
|
+
} else if (isChildBottomBelowViewingArea) {
|
35
|
+
const scrollHeightToChildBottom = childBottom - containerBottom + container.scrollTop;
|
36
|
+
container.scrollTo({
|
37
|
+
behavior,
|
38
|
+
top: scrollHeightToChildBottom + margin
|
39
|
+
});
|
40
|
+
} // either completely in view or outside viewing area on both ends, don't scroll
|
41
|
+
|
42
|
+
}
|
43
|
+
|
16
44
|
const StyledHeader = styled.div.withConfig({
|
17
45
|
displayName: "FilteredActionList__StyledHeader",
|
18
46
|
componentId: "yg3jkv-0"
|
@@ -67,7 +95,7 @@ export function FilteredActionList({
|
|
67
95
|
useEffect(() => {
|
68
96
|
// if items changed, we want to instantly move active descendant into view
|
69
97
|
if (activeDescendantRef.current && scrollContainerRef.current) {
|
70
|
-
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current,
|
98
|
+
scrollIntoViewingArea(activeDescendantRef.current, scrollContainerRef.current, undefined, 'auto');
|
71
99
|
}
|
72
100
|
}, [items]);
|
73
101
|
useScrollFlash(scrollContainerRef);
|
package/lib-esm/Overlay.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { ComponentProps } from './utils/types';
|
|
4
4
|
import { TouchOrMouseEvent } from './hooks';
|
5
5
|
import { SxProp } from './sx';
|
6
6
|
import { AnchorSide } from './behaviors/anchoredPosition';
|
7
|
-
|
7
|
+
declare type StyledOverlayProps = {
|
8
8
|
width?: keyof typeof widthMap;
|
9
9
|
height?: keyof typeof heightMap;
|
10
10
|
maxHeight?: keyof Omit<typeof heightMap, 'auto' | 'initial'>;
|
@@ -40,7 +40,6 @@ export declare type OverlayProps = {
|
|
40
40
|
top: number;
|
41
41
|
left: number;
|
42
42
|
portalContainerName?: string;
|
43
|
-
preventFocusOnOpen?: boolean;
|
44
43
|
} & Omit<ComponentProps<typeof StyledOverlay>, 'visibility' | keyof SystemPositionProps>;
|
45
44
|
/**
|
46
45
|
* An `Overlay` is a flexible floating surface, used to display transient content such as menus,
|
package/lib-esm/Overlay.js
CHANGED
@@ -92,7 +92,6 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
92
92
|
left,
|
93
93
|
anchorSide,
|
94
94
|
portalContainerName,
|
95
|
-
preventFocusOnOpen,
|
96
95
|
...rest
|
97
96
|
}, forwardedRef) => {
|
98
97
|
const overlayRef = useRef(null);
|
@@ -108,8 +107,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
108
107
|
onEscape,
|
109
108
|
ignoreClickRefs,
|
110
109
|
onClickOutside,
|
111
|
-
initialFocusRef
|
112
|
-
preventFocusOnOpen
|
110
|
+
initialFocusRef
|
113
111
|
});
|
114
112
|
useEffect(() => {
|
115
113
|
var _combinedRef$current;
|
@@ -138,7 +136,9 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
138
136
|
easing: slideAnimationEasing
|
139
137
|
});
|
140
138
|
}, [anchorSide, slideAnimationDistance, slideAnimationEasing, visibility]);
|
141
|
-
|
139
|
+
return /*#__PURE__*/React.createElement(Portal, {
|
140
|
+
containerName: portalContainerName
|
141
|
+
}, /*#__PURE__*/React.createElement(StyledOverlay, _extends({
|
142
142
|
height: height,
|
143
143
|
role: role
|
144
144
|
}, rest, {
|
@@ -149,10 +149,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
149
149
|
...rest.style,
|
150
150
|
'--styled-overlay-visibility': visibility
|
151
151
|
}
|
152
|
-
}));
|
153
|
-
return /*#__PURE__*/React.createElement(Portal, {
|
154
|
-
containerName: portalContainerName
|
155
|
-
}, styledOverlay);
|
152
|
+
})));
|
156
153
|
});
|
157
154
|
Overlay.defaultProps = {
|
158
155
|
height: 'auto',
|
package/lib-esm/TextInput.d.ts
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
|
3
|
+
import { SxProp } from './sx';
|
2
4
|
import { ComponentProps, Merge } from './utils/types';
|
3
|
-
import
|
4
|
-
import
|
5
|
+
declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
6
|
+
declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
|
7
|
+
disabled?: boolean | undefined;
|
8
|
+
hasIcon?: boolean | undefined;
|
9
|
+
block?: boolean | undefined;
|
10
|
+
contrast?: boolean | undefined;
|
11
|
+
variant?: "large" | "small" | undefined;
|
12
|
+
} & WidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>> & MinWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MinWidth<import("styled-system").TLengthStyledSystem>> & MaxWidthProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, import("csstype").Property.MaxWidth<import("styled-system").TLengthStyledSystem>> & SxProp, never>;
|
5
13
|
declare type NonPassthroughProps = {
|
6
14
|
className?: string;
|
7
15
|
icon?: React.ComponentType<{
|
8
16
|
className?: string;
|
9
17
|
}>;
|
10
|
-
} & Pick<ComponentProps<typeof
|
11
|
-
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof
|
18
|
+
} & Pick<ComponentProps<typeof Wrapper>, 'block' | 'contrast' | 'disabled' | 'sx' | 'theme' | 'width' | 'maxWidth' | 'minWidth' | 'variant'>;
|
19
|
+
declare type TextInputInternalProps = Merge<React.ComponentPropsWithoutRef<typeof Input>, NonPassthroughProps>;
|
12
20
|
declare const TextInput: React.ForwardRefExoticComponent<Pick<TextInputInternalProps, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
13
21
|
export declare type TextInputProps = ComponentProps<typeof TextInput>;
|
14
22
|
export default TextInput;
|
package/lib-esm/TextInput.js
CHANGED
@@ -2,8 +2,41 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
2
2
|
|
3
3
|
import classnames from 'classnames';
|
4
4
|
import React from 'react';
|
5
|
-
import
|
6
|
-
import
|
5
|
+
import styled, { css } from 'styled-components';
|
6
|
+
import { maxWidth, minWidth, variant, width } from 'styled-system';
|
7
|
+
import { get } from './constants';
|
8
|
+
import sx from './sx';
|
9
|
+
const sizeVariants = variant({
|
10
|
+
variants: {
|
11
|
+
small: {
|
12
|
+
minHeight: '28px',
|
13
|
+
px: 2,
|
14
|
+
py: '3px',
|
15
|
+
fontSize: 0,
|
16
|
+
lineHeight: '20px'
|
17
|
+
},
|
18
|
+
large: {
|
19
|
+
px: 2,
|
20
|
+
py: '10px',
|
21
|
+
fontSize: 3
|
22
|
+
}
|
23
|
+
}
|
24
|
+
});
|
25
|
+
const Input = styled.input.withConfig({
|
26
|
+
displayName: "TextInput__Input",
|
27
|
+
componentId: "sc-1apmpmt-0"
|
28
|
+
})(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;width:100%;&:focus{outline:0;}"]);
|
29
|
+
const Wrapper = styled.span.withConfig({
|
30
|
+
displayName: "TextInput__Wrapper",
|
31
|
+
componentId: "sc-1apmpmt-1"
|
32
|
+
})(["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:", ";", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), props => {
|
33
|
+
if (props.hasIcon) {
|
34
|
+
return css(["padding:0;"]);
|
35
|
+
} else {
|
36
|
+
return css(["padding:6px 12px;"]);
|
37
|
+
}
|
38
|
+
}, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.fg.muted'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx); // Props that are not passed through to Input:
|
39
|
+
|
7
40
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
8
41
|
const TextInput = /*#__PURE__*/React.forwardRef(({
|
9
42
|
icon: IconComponent,
|
@@ -21,7 +54,7 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
21
54
|
}, ref) => {
|
22
55
|
// this class is necessary to style FilterSearch, plz no touchy!
|
23
56
|
const wrapperClasses = classnames(className, 'TextInput-wrapper');
|
24
|
-
return /*#__PURE__*/React.createElement(
|
57
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
25
58
|
block: block,
|
26
59
|
className: wrapperClasses,
|
27
60
|
contrast: contrast,
|
@@ -35,7 +68,7 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
35
68
|
variant: variantProp
|
36
69
|
}, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
|
37
70
|
className: "TextInput-icon"
|
38
|
-
}), /*#__PURE__*/React.createElement(
|
71
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({
|
39
72
|
ref: ref,
|
40
73
|
disabled: disabled
|
41
74
|
}, inputProps)));
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { TokenBaseProps } from './TokenBase';
|
3
|
+
export interface AvatarTokenProps extends TokenBaseProps {
|
4
|
+
avatarSrc: string;
|
5
|
+
}
|
6
|
+
declare const AvatarToken: React.ForwardRefExoticComponent<Pick<AvatarTokenProps, "sizes" | "color" | "content" | "height" | "translate" | "width" | "hidden" | "children" | "value" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "text" | "list" | "default" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "start" | "step" | "size" | "wrap" | "open" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "href" | "classID" | "useMap" | "wmode" | "download" | "hrefLang" | "rel" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "integrity" | "charSet" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "kind" | "srcLang" | "poster" | "onRemove" | "isSelected" | "avatarSrc"> & React.RefAttributes<HTMLElement>>;
|
7
|
+
export default AvatarToken;
|
@@ -6,7 +6,7 @@ import { get } from '../constants';
|
|
6
6
|
import { defaultTokenSize, tokenSizes } from './TokenBase';
|
7
7
|
import Token from './Token';
|
8
8
|
import { Avatar } from '..';
|
9
|
-
const
|
9
|
+
const AvatarToken = /*#__PURE__*/forwardRef(({
|
10
10
|
avatarSrc,
|
11
11
|
id,
|
12
12
|
size,
|
@@ -26,8 +26,8 @@ const ProfileToken = /*#__PURE__*/forwardRef(({
|
|
26
26
|
ref: forwardedRef
|
27
27
|
}));
|
28
28
|
});
|
29
|
-
|
29
|
+
AvatarToken.defaultProps = {
|
30
30
|
size: defaultTokenSize
|
31
31
|
};
|
32
|
-
|
33
|
-
export default
|
32
|
+
AvatarToken.displayName = 'AvatarToken';
|
33
|
+
export default AvatarToken;
|
@@ -1,15 +1,6 @@
|
|
1
|
-
import styled
|
1
|
+
import styled from 'styled-components';
|
2
2
|
const TokenTextContainer = styled('span').withConfig({
|
3
3
|
displayName: "_TokenTextContainer__TokenTextContainer",
|
4
4
|
componentId: "sc-4t2bev-0"
|
5
|
-
})(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;&:after{content:'';position:absolute;left:0;top:0;right:0;bottom:0;}"
|
6
|
-
if (props.as === 'a') {
|
7
|
-
return css(["color:currentColor;text-decoration:none;"]);
|
8
|
-
}
|
9
|
-
|
10
|
-
if (props.as === 'button') {
|
11
|
-
// reset button styles, make the cursor a pointer, and add line-height
|
12
|
-
return css(["background:transparent;border:none;color:inherit;font:inherit;margin:0;overflow:visible;padding:0;width:auto;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-appearance:none;cursor:pointer;line-height:1;"]);
|
13
|
-
}
|
14
|
-
});
|
5
|
+
})(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:transparent;border:none;color:inherit;font:inherit;margin:0;overflow:visible;padding:0;width:auto;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-appearance:none;cursor:pointer;line-height:1;color:currentColor;text-decoration:none;&:after{content:'';position:absolute;left:0;top:0;right:0;bottom:0;}"]);
|
15
6
|
export default TokenTextContainer;
|
package/lib-esm/Token/index.d.ts
CHANGED
package/lib-esm/Token/index.js
CHANGED
@@ -3,6 +3,5 @@ export declare type UseOpenAndCloseFocusSettings = {
|
|
3
3
|
initialFocusRef?: React.RefObject<HTMLElement>;
|
4
4
|
containerRef: React.RefObject<HTMLElement>;
|
5
5
|
returnFocusRef: React.RefObject<HTMLElement>;
|
6
|
-
preventFocusOnOpen?: boolean;
|
7
6
|
};
|
8
|
-
export declare function useOpenAndCloseFocus({ initialFocusRef, returnFocusRef, containerRef
|
7
|
+
export declare function useOpenAndCloseFocus({ initialFocusRef, returnFocusRef, containerRef }: UseOpenAndCloseFocusSettings): void;
|
@@ -3,14 +3,9 @@ import { iterateFocusableElements } from '../utils/iterateFocusableElements';
|
|
3
3
|
export function useOpenAndCloseFocus({
|
4
4
|
initialFocusRef,
|
5
5
|
returnFocusRef,
|
6
|
-
containerRef
|
7
|
-
preventFocusOnOpen
|
6
|
+
containerRef
|
8
7
|
}) {
|
9
8
|
useEffect(() => {
|
10
|
-
if (preventFocusOnOpen) {
|
11
|
-
return;
|
12
|
-
}
|
13
|
-
|
14
9
|
const returnRef = returnFocusRef.current;
|
15
10
|
|
16
11
|
if (initialFocusRef && initialFocusRef.current) {
|
@@ -23,5 +18,5 @@ export function useOpenAndCloseFocus({
|
|
23
18
|
return function () {
|
24
19
|
returnRef === null || returnRef === void 0 ? void 0 : returnRef.focus();
|
25
20
|
};
|
26
|
-
}, [initialFocusRef, returnFocusRef, containerRef
|
21
|
+
}, [initialFocusRef, returnFocusRef, containerRef]);
|
27
22
|
}
|
@@ -7,9 +7,8 @@ export declare type UseOverlaySettings = {
|
|
7
7
|
onEscape: (e: KeyboardEvent) => void;
|
8
8
|
onClickOutside: (e: TouchOrMouseEvent) => void;
|
9
9
|
overlayRef?: React.RefObject<HTMLDivElement>;
|
10
|
-
preventFocusOnOpen?: boolean;
|
11
10
|
};
|
12
11
|
export declare type OverlayReturnProps = {
|
13
12
|
ref: React.RefObject<HTMLDivElement>;
|
14
13
|
};
|
15
|
-
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside
|
14
|
+
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside }: UseOverlaySettings) => OverlayReturnProps;
|
@@ -8,15 +8,13 @@ export const useOverlay = ({
|
|
8
8
|
initialFocusRef,
|
9
9
|
onEscape,
|
10
10
|
ignoreClickRefs,
|
11
|
-
onClickOutside
|
12
|
-
preventFocusOnOpen
|
11
|
+
onClickOutside
|
13
12
|
}) => {
|
14
13
|
const overlayRef = useProvidedRefOrCreate(_overlayRef);
|
15
14
|
useOpenAndCloseFocus({
|
16
15
|
containerRef: overlayRef,
|
17
16
|
returnFocusRef,
|
18
|
-
initialFocusRef
|
19
|
-
preventFocusOnOpen
|
17
|
+
initialFocusRef
|
20
18
|
});
|
21
19
|
useOnOutsideClick({
|
22
20
|
containerRef: overlayRef,
|
package/lib-esm/index.d.ts
CHANGED
@@ -24,7 +24,6 @@ export { useConfirm } from './Dialog/ConfirmationDialog';
|
|
24
24
|
export { ActionList } from './ActionList';
|
25
25
|
export { ActionMenu } from './ActionMenu';
|
26
26
|
export type { ActionMenuProps } from './ActionMenu';
|
27
|
-
export { default as Autocomplete } from './Autocomplete';
|
28
27
|
export { default as Avatar } from './Avatar';
|
29
28
|
export type { AvatarProps } from './Avatar';
|
30
29
|
export { default as AvatarPair } from './AvatarPair';
|
@@ -99,12 +98,11 @@ export { default as TabNav } from './TabNav';
|
|
99
98
|
export type { TabNavProps, TabNavLinkProps } from './TabNav';
|
100
99
|
export { default as TextInput } from './TextInput';
|
101
100
|
export type { TextInputProps } from './TextInput';
|
102
|
-
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
103
101
|
export { default as Text } from './Text';
|
104
102
|
export type { TextProps } from './Text';
|
105
103
|
export { default as Timeline } from './Timeline';
|
106
104
|
export type { TimelineProps, TimelineBadgeProps, TimelineBodyProps, TimelineBreakProps, TimelineItemsProps } from './Timeline';
|
107
|
-
export { default as Token, IssueLabelToken,
|
105
|
+
export { default as Token, IssueLabelToken, AvatarToken } from './Token';
|
108
106
|
export { default as Tooltip } from './Tooltip';
|
109
107
|
export type { TooltipProps } from './Tooltip';
|
110
108
|
export { default as Truncate } from './Truncate';
|
package/lib-esm/index.js
CHANGED
@@ -19,7 +19,6 @@ export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
|
|
19
19
|
|
20
20
|
export { ActionList } from './ActionList';
|
21
21
|
export { ActionMenu } from './ActionMenu';
|
22
|
-
export { default as Autocomplete } from './Autocomplete';
|
23
22
|
export { default as Avatar } from './Avatar';
|
24
23
|
export { default as AvatarPair } from './AvatarPair';
|
25
24
|
export { default as AvatarStack } from './AvatarStack';
|
@@ -62,10 +61,9 @@ export { default as StyledOcticon } from './StyledOcticon';
|
|
62
61
|
export { default as SubNav } from './SubNav';
|
63
62
|
export { default as TabNav } from './TabNav';
|
64
63
|
export { default as TextInput } from './TextInput';
|
65
|
-
export { default as TextInputWithTokens } from './TextInputWithTokens';
|
66
64
|
export { default as Text } from './Text';
|
67
65
|
export { default as Timeline } from './Timeline';
|
68
|
-
export { default as Token, IssueLabelToken,
|
66
|
+
export { default as Token, IssueLabelToken, AvatarToken } from './Token';
|
69
67
|
export { default as Tooltip } from './Tooltip';
|
70
68
|
export { default as Truncate } from './Truncate';
|
71
69
|
export { default as UnderlineNav } from './UnderlineNav';
|
package/package.json
CHANGED
@@ -1,40 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { ComponentProps } from '../utils/types';
|
3
|
-
import AutocompleteMenu from './AutocompleteMenu';
|
4
|
-
declare const Autocomplete: React.FC<{
|
5
|
-
id?: string;
|
6
|
-
}>;
|
7
|
-
export declare type AutocompleteProps = ComponentProps<typeof Autocomplete>;
|
8
|
-
export type { AutocompleteInputProps } from './AutocompleteInput';
|
9
|
-
export type { AutocompleteMenuProps } from './AutocompleteMenu';
|
10
|
-
export type { AutocompleteOverlayProps } from './AutocompleteOverlay';
|
11
|
-
declare const _default: React.FC<{
|
12
|
-
id?: string | undefined;
|
13
|
-
}> & {
|
14
|
-
AutocompleteContext: React.Context<{
|
15
|
-
activeDescendantRef?: React.MutableRefObject<HTMLElement | null> | undefined;
|
16
|
-
autocompleteSuggestion?: string | undefined;
|
17
|
-
id?: string | undefined;
|
18
|
-
inputRef?: React.MutableRefObject<HTMLInputElement | null> | undefined;
|
19
|
-
inputValue?: string | undefined;
|
20
|
-
isMenuDirectlyActivated?: boolean | undefined;
|
21
|
-
scrollContainerRef?: React.MutableRefObject<HTMLElement | null> | undefined;
|
22
|
-
selectedItemLength?: number | undefined;
|
23
|
-
setAutocompleteSuggestion?: React.Dispatch<React.SetStateAction<string>> | undefined;
|
24
|
-
setInputValue?: React.Dispatch<React.SetStateAction<string>> | undefined;
|
25
|
-
setIsMenuDirectlyActivated?: React.Dispatch<React.SetStateAction<boolean>> | undefined;
|
26
|
-
setSelectedItemLength?: React.Dispatch<React.SetStateAction<number | undefined>> | undefined;
|
27
|
-
setShowMenu?: React.Dispatch<React.SetStateAction<boolean>> | undefined;
|
28
|
-
showMenu?: boolean | undefined;
|
29
|
-
}>;
|
30
|
-
Input: import("@radix-ui/react-polymorphic").ForwardRefComponent<"input", {
|
31
|
-
as?: React.ComponentType<any> | undefined;
|
32
|
-
}>;
|
33
|
-
Menu: typeof AutocompleteMenu;
|
34
|
-
Overlay: React.FC<{
|
35
|
-
menuAnchorRef?: React.RefObject<HTMLElement> | undefined;
|
36
|
-
overlayProps?: Partial<import("..").OverlayProps> | undefined;
|
37
|
-
children?: React.ReactNode;
|
38
|
-
} & Pick<React.AriaAttributes, "aria-labelledby">>;
|
39
|
-
};
|
40
|
-
export default _default;
|
@@ -1,68 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
9
|
-
|
10
|
-
var _uniqueId = require("../utils/uniqueId");
|
11
|
-
|
12
|
-
var _AutocompleteContext = require("./AutocompleteContext");
|
13
|
-
|
14
|
-
var _AutocompleteInput = _interopRequireDefault(require("./AutocompleteInput"));
|
15
|
-
|
16
|
-
var _AutocompleteMenu = _interopRequireDefault(require("./AutocompleteMenu"));
|
17
|
-
|
18
|
-
var _AutocompleteOverlay = _interopRequireDefault(require("./AutocompleteOverlay"));
|
19
|
-
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
|
-
|
22
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
23
|
-
|
24
|
-
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; }
|
25
|
-
|
26
|
-
const Autocomplete = ({
|
27
|
-
children,
|
28
|
-
id: idProp
|
29
|
-
}) => {
|
30
|
-
const activeDescendantRef = (0, _react.useRef)(null);
|
31
|
-
const scrollContainerRef = (0, _react.useRef)(null);
|
32
|
-
const inputRef = (0, _react.useRef)(null);
|
33
|
-
const [inputValue, setInputValue] = (0, _react.useState)('');
|
34
|
-
const [showMenu, setShowMenu] = (0, _react.useState)(false);
|
35
|
-
const [autocompleteSuggestion, setAutocompleteSuggestion] = (0, _react.useState)('');
|
36
|
-
const [isMenuDirectlyActivated, setIsMenuDirectlyActivated] = (0, _react.useState)(false);
|
37
|
-
const [selectedItemLength, setSelectedItemLength] = (0, _react.useState)();
|
38
|
-
const id = idProp || (0, _uniqueId.uniqueId)();
|
39
|
-
return /*#__PURE__*/_react.default.createElement(_AutocompleteContext.AutocompleteContext.Provider, {
|
40
|
-
value: {
|
41
|
-
activeDescendantRef,
|
42
|
-
autocompleteSuggestion,
|
43
|
-
id,
|
44
|
-
inputRef,
|
45
|
-
inputValue,
|
46
|
-
isMenuDirectlyActivated,
|
47
|
-
scrollContainerRef,
|
48
|
-
selectedItemLength,
|
49
|
-
setAutocompleteSuggestion,
|
50
|
-
setInputValue,
|
51
|
-
setIsMenuDirectlyActivated,
|
52
|
-
setShowMenu,
|
53
|
-
setSelectedItemLength,
|
54
|
-
showMenu
|
55
|
-
}
|
56
|
-
}, children);
|
57
|
-
};
|
58
|
-
|
59
|
-
Autocomplete.displayName = "Autocomplete";
|
60
|
-
|
61
|
-
var _default = Object.assign(Autocomplete, {
|
62
|
-
AutocompleteContext: _AutocompleteContext.AutocompleteContext,
|
63
|
-
Input: _AutocompleteInput.default,
|
64
|
-
Menu: _AutocompleteMenu.default,
|
65
|
-
Overlay: _AutocompleteOverlay.default
|
66
|
-
});
|
67
|
-
|
68
|
-
exports.default = _default;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
export declare const AutocompleteContext: import("react").Context<{
|
3
|
-
activeDescendantRef?: import("react").MutableRefObject<HTMLElement | null> | undefined;
|
4
|
-
autocompleteSuggestion?: string | undefined;
|
5
|
-
id?: string | undefined;
|
6
|
-
inputRef?: import("react").MutableRefObject<HTMLInputElement | null> | undefined;
|
7
|
-
inputValue?: string | undefined;
|
8
|
-
isMenuDirectlyActivated?: boolean | undefined;
|
9
|
-
scrollContainerRef?: import("react").MutableRefObject<HTMLElement | null> | undefined;
|
10
|
-
selectedItemLength?: number | undefined;
|
11
|
-
setAutocompleteSuggestion?: import("react").Dispatch<import("react").SetStateAction<string>> | undefined;
|
12
|
-
setInputValue?: import("react").Dispatch<import("react").SetStateAction<string>> | undefined;
|
13
|
-
setIsMenuDirectlyActivated?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
|
14
|
-
setSelectedItemLength?: import("react").Dispatch<import("react").SetStateAction<number | undefined>> | undefined;
|
15
|
-
setShowMenu?: import("react").Dispatch<import("react").SetStateAction<boolean>> | undefined;
|
16
|
-
showMenu?: boolean | undefined;
|
17
|
-
}>;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.AutocompleteContext = void 0;
|
7
|
-
|
8
|
-
var _react = require("react");
|
9
|
-
|
10
|
-
const AutocompleteContext = /*#__PURE__*/(0, _react.createContext)({});
|
11
|
-
exports.AutocompleteContext = AutocompleteContext;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
|
3
|
-
import { ComponentProps } from '../utils/types';
|
4
|
-
declare type InternalAutocompleteInputProps = {
|
5
|
-
as?: React.ComponentType<any>;
|
6
|
-
};
|
7
|
-
declare const AutocompleteInput: PolymorphicForwardRefComponent<"input", InternalAutocompleteInputProps>;
|
8
|
-
export declare type AutocompleteInputProps = ComponentProps<typeof AutocompleteInput>;
|
9
|
-
export default AutocompleteInput;
|