@primer/components 0.0.0-20219283497 → 0.0.0-202192953933
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 +17 -1
- package/dist/browser.esm.js +147 -143
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +147 -143
- package/dist/browser.umd.js.map +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +28 -28
- package/lib/Autocomplete/AutocompleteInput.d.ts +28 -28
- package/lib/Button/Button.d.ts +26 -26
- package/lib/Button/ButtonBase.d.ts +1 -1
- package/lib/Button/ButtonClose.d.ts +27 -27
- package/lib/Button/ButtonDanger.d.ts +26 -26
- package/lib/Button/ButtonInvisible.d.ts +26 -26
- package/lib/Button/ButtonOutline.d.ts +26 -26
- package/lib/Button/ButtonPrimary.d.ts +26 -26
- package/lib/Button/ButtonStyles.js +1 -1
- package/lib/CircleBadge.d.ts +2 -2
- package/lib/CircleOcticon.d.ts +30 -30
- package/lib/Dialog.d.ts +33 -33
- package/lib/Dropdown.d.ts +114 -114
- package/lib/DropdownMenu/DropdownButton.d.ts +28 -28
- package/lib/FilterList.d.ts +25 -25
- package/lib/Flash.d.ts +1 -1
- package/lib/Label.d.ts +1 -1
- package/lib/NewButton/button.d.ts +65 -65
- package/lib/NewButton/button.js +62 -27
- package/lib/NewButton/buttonStyles.d.ts +2 -0
- package/lib/NewButton/buttonStyles.js +14 -0
- package/lib/Position.d.ts +4 -4
- package/lib/SelectMenu/SelectMenu.d.ts +159 -159
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +32 -28
- package/lib/TextInputWithTokens.js +102 -29
- package/lib/Timeline.d.ts +31 -31
- package/lib/Token/AvatarToken.d.ts +1 -1
- package/lib/Token/IssueLabelToken.d.ts +1 -1
- package/lib/Token/Token.d.ts +1 -1
- package/lib/Token/Token.js +13 -2
- package/lib/Token/TokenBase.js +0 -4
- package/lib/Token/_RemoveTokenButton.js +15 -2
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/sx.d.ts +8 -2
- package/lib/theme.d.ts +78 -0
- package/lib/theme.js +3 -1
- package/lib/utils/testing.d.ts +1 -1
- package/lib/utils/types/KeyPaths.d.ts +3 -0
- package/lib/utils/types/KeyPaths.js +1 -0
- package/lib-esm/Autocomplete/Autocomplete.d.ts +28 -28
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +28 -28
- package/lib-esm/Button/Button.d.ts +26 -26
- package/lib-esm/Button/ButtonBase.d.ts +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +27 -27
- package/lib-esm/Button/ButtonDanger.d.ts +26 -26
- package/lib-esm/Button/ButtonInvisible.d.ts +26 -26
- package/lib-esm/Button/ButtonOutline.d.ts +26 -26
- package/lib-esm/Button/ButtonPrimary.d.ts +26 -26
- package/lib-esm/Button/ButtonStyles.js +1 -1
- package/lib-esm/CircleBadge.d.ts +2 -2
- package/lib-esm/CircleOcticon.d.ts +30 -30
- package/lib-esm/Dialog.d.ts +33 -33
- package/lib-esm/Dropdown.d.ts +114 -114
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +28 -28
- package/lib-esm/FilterList.d.ts +25 -25
- package/lib-esm/Flash.d.ts +1 -1
- package/lib-esm/Label.d.ts +1 -1
- package/lib-esm/NewButton/button.d.ts +65 -65
- package/lib-esm/NewButton/button.js +62 -27
- package/lib-esm/NewButton/buttonStyles.d.ts +2 -0
- package/lib-esm/NewButton/buttonStyles.js +3 -0
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/SelectMenu/SelectMenu.d.ts +159 -159
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +32 -28
- package/lib-esm/TextInputWithTokens.js +101 -30
- package/lib-esm/Timeline.d.ts +31 -31
- package/lib-esm/Token/AvatarToken.d.ts +1 -1
- package/lib-esm/Token/IssueLabelToken.d.ts +1 -1
- package/lib-esm/Token/Token.d.ts +1 -1
- package/lib-esm/Token/Token.js +13 -2
- package/lib-esm/Token/TokenBase.js +0 -4
- package/lib-esm/Token/_RemoveTokenButton.js +11 -2
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/sx.d.ts +8 -2
- package/lib-esm/theme.d.ts +78 -0
- package/lib-esm/theme.js +2 -1
- package/lib-esm/utils/testing.d.ts +1 -1
- package/lib-esm/utils/types/KeyPaths.d.ts +3 -0
- package/lib-esm/utils/types/KeyPaths.js +1 -0
- package/package.json +2 -1
@@ -10,6 +10,6 @@ declare type SelectMenuItemInteralProps = {
|
|
10
10
|
as?: React.ElementType;
|
11
11
|
selected?: boolean;
|
12
12
|
} & ComponentProps<typeof StyledItem>;
|
13
|
-
declare const SelectMenuItem: React.ForwardRefExoticComponent<Pick<SelectMenuItemInteralProps, "translate" | "
|
13
|
+
declare const SelectMenuItem: React.ForwardRefExoticComponent<Pick<SelectMenuItemInteralProps, "translate" | "hidden" | "style" | "slot" | "title" | "theme" | "type" | "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" | "children" | "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" | "sx" | "as" | keyof SystemCommonProps | "media" | "target" | "href" | "hrefLang" | "referrerPolicy" | "rel" | "selected" | "download" | "ping"> & React.RefAttributes<HTMLAnchorElement>>;
|
14
14
|
export declare type SelectMenuItemProps = ComponentProps<typeof SelectMenuItem>;
|
15
15
|
export default SelectMenuItem;
|
@@ -10,6 +10,6 @@ declare const ModalWrapper: import("styled-components").StyledComponent<"div", a
|
|
10
10
|
align?: "left" | "right" | undefined;
|
11
11
|
} & SystemCommonProps & SxProp, never>;
|
12
12
|
declare type SelectMenuModalInternalProps = Pick<StyledModalProps, 'width'> & ComponentProps<typeof ModalWrapper>;
|
13
|
-
declare const SelectMenuModal: React.ForwardRefExoticComponent<Pick<SelectMenuModalInternalProps, "backgroundColor" | "color" | "display" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "opacity" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "width" | "margin" | "padding" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "
|
13
|
+
declare const SelectMenuModal: React.ForwardRefExoticComponent<Pick<SelectMenuModalInternalProps, "backgroundColor" | "color" | "display" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "opacity" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "width" | "margin" | "padding" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "hidden" | "style" | "slot" | "title" | "theme" | "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" | "children" | "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" | "sx" | "align"> & React.RefAttributes<HTMLDivElement>>;
|
14
14
|
export declare type SelectMenuModalProps = ComponentProps<typeof SelectMenuModal>;
|
15
15
|
export default SelectMenuModal;
|
@@ -32,6 +32,10 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
32
32
|
* Whether the remove buttons should be rendered in the tokens
|
33
33
|
*/
|
34
34
|
hideTokenRemoveButtons?: boolean | undefined;
|
35
|
+
/**
|
36
|
+
* The number of tokens to display before truncating
|
37
|
+
*/
|
38
|
+
visibleTokenCount?: number | undefined;
|
35
39
|
} & Pick<Omit<Pick<{
|
36
40
|
[x: string]: any;
|
37
41
|
[x: number]: any;
|
@@ -40,7 +44,7 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
40
44
|
} & {
|
41
45
|
as?: string | React.ComponentType<any> | undefined;
|
42
46
|
forwardedAs?: string | React.ComponentType<any> | undefined;
|
43
|
-
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "
|
47
|
+
}, string | number | symbol>, "maxWidth" | "minWidth" | "width" | "block" | "icon" | "theme" | "className" | "sx" | "disabled" | "variant" | "contrast"> & {
|
44
48
|
className?: string | undefined;
|
45
49
|
icon?: React.ComponentType<{
|
46
50
|
className?: string | undefined;
|
@@ -51,8 +55,10 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
51
55
|
minWidth?: import("styled-system").ResponsiveValue<import("csstype").Property.MinWidth<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
52
56
|
translate?: "yes" | "no" | undefined;
|
53
57
|
width?: import("styled-system").ResponsiveValue<import("csstype").Property.Width<import("styled-system").TLengthStyledSystem>, Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> | undefined;
|
54
|
-
|
58
|
+
hidden?: boolean | undefined;
|
55
59
|
style?: React.CSSProperties | undefined;
|
60
|
+
block?: boolean | undefined;
|
61
|
+
slot?: string | undefined;
|
56
62
|
title?: string | undefined;
|
57
63
|
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
58
64
|
key?: React.Key | null | undefined;
|
@@ -62,15 +68,14 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
62
68
|
suppressHydrationWarning?: boolean | undefined;
|
63
69
|
accessKey?: string | undefined;
|
64
70
|
className?: string | undefined;
|
65
|
-
contentEditable?:
|
71
|
+
contentEditable?: "inherit" | (boolean | "false" | "true") | undefined;
|
66
72
|
contextMenu?: string | undefined;
|
67
73
|
dir?: string | undefined;
|
68
|
-
draggable?: (boolean | "
|
69
|
-
hidden?: boolean | undefined;
|
74
|
+
draggable?: (boolean | "false" | "true") | undefined;
|
70
75
|
id?: string | undefined;
|
71
76
|
lang?: string | undefined;
|
72
77
|
placeholder?: string | undefined;
|
73
|
-
spellCheck?: (boolean | "
|
78
|
+
spellCheck?: (boolean | "false" | "true") | undefined;
|
74
79
|
tabIndex?: number | undefined;
|
75
80
|
radioGroup?: string | undefined;
|
76
81
|
role?: React.AriaRole | undefined;
|
@@ -93,50 +98,50 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
93
98
|
results?: number | undefined;
|
94
99
|
security?: string | undefined;
|
95
100
|
unselectable?: "on" | "off" | undefined;
|
96
|
-
inputMode?: "
|
101
|
+
inputMode?: "search" | "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | undefined;
|
97
102
|
is?: string | undefined;
|
98
103
|
'aria-activedescendant'?: string | undefined;
|
99
|
-
'aria-atomic'?: boolean | "
|
100
|
-
'aria-autocomplete'?: "
|
101
|
-
'aria-busy'?: boolean | "
|
102
|
-
'aria-checked'?: boolean | "
|
104
|
+
'aria-atomic'?: boolean | "false" | "true" | undefined;
|
105
|
+
'aria-autocomplete'?: "none" | "both" | "inline" | "list" | undefined;
|
106
|
+
'aria-busy'?: boolean | "false" | "true" | undefined;
|
107
|
+
'aria-checked'?: boolean | "mixed" | "false" | "true" | undefined;
|
103
108
|
'aria-colcount'?: number | undefined;
|
104
109
|
'aria-colindex'?: number | undefined;
|
105
110
|
'aria-colspan'?: number | undefined;
|
106
111
|
'aria-controls'?: string | undefined;
|
107
|
-
'aria-current'?: boolean | "
|
112
|
+
'aria-current'?: boolean | "page" | "false" | "true" | "time" | "step" | "location" | "date" | undefined;
|
108
113
|
'aria-describedby'?: string | undefined;
|
109
114
|
'aria-details'?: string | undefined;
|
110
|
-
'aria-disabled'?: boolean | "
|
115
|
+
'aria-disabled'?: boolean | "false" | "true" | undefined;
|
111
116
|
'aria-dropeffect'?: "link" | "none" | "copy" | "move" | "execute" | "popup" | undefined;
|
112
117
|
'aria-errormessage'?: string | undefined;
|
113
|
-
'aria-expanded'?: boolean | "
|
118
|
+
'aria-expanded'?: boolean | "false" | "true" | undefined;
|
114
119
|
'aria-flowto'?: string | undefined;
|
115
|
-
'aria-grabbed'?: boolean | "
|
116
|
-
'aria-haspopup'?: boolean | "grid" | "
|
117
|
-
'aria-hidden'?: boolean | "
|
118
|
-
'aria-invalid'?: boolean | "
|
120
|
+
'aria-grabbed'?: boolean | "false" | "true" | undefined;
|
121
|
+
'aria-haspopup'?: boolean | "grid" | "listbox" | "menu" | "false" | "true" | "dialog" | "tree" | undefined;
|
122
|
+
'aria-hidden'?: boolean | "false" | "true" | undefined;
|
123
|
+
'aria-invalid'?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
119
124
|
'aria-keyshortcuts'?: string | undefined;
|
120
125
|
'aria-label'?: string | undefined;
|
121
126
|
'aria-labelledby'?: string | undefined;
|
122
127
|
'aria-level'?: number | undefined;
|
123
128
|
'aria-live'?: "off" | "assertive" | "polite" | undefined;
|
124
|
-
'aria-modal'?: boolean | "
|
125
|
-
'aria-multiline'?: boolean | "
|
126
|
-
'aria-multiselectable'?: boolean | "
|
129
|
+
'aria-modal'?: boolean | "false" | "true" | undefined;
|
130
|
+
'aria-multiline'?: boolean | "false" | "true" | undefined;
|
131
|
+
'aria-multiselectable'?: boolean | "false" | "true" | undefined;
|
127
132
|
'aria-orientation'?: "horizontal" | "vertical" | undefined;
|
128
133
|
'aria-owns'?: string | undefined;
|
129
134
|
'aria-placeholder'?: string | undefined;
|
130
135
|
'aria-posinset'?: number | undefined;
|
131
|
-
'aria-pressed'?: boolean | "
|
132
|
-
'aria-readonly'?: boolean | "
|
136
|
+
'aria-pressed'?: boolean | "mixed" | "false" | "true" | undefined;
|
137
|
+
'aria-readonly'?: boolean | "false" | "true" | undefined;
|
133
138
|
'aria-relevant'?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals" | undefined;
|
134
|
-
'aria-required'?: boolean | "
|
139
|
+
'aria-required'?: boolean | "false" | "true" | undefined;
|
135
140
|
'aria-roledescription'?: string | undefined;
|
136
141
|
'aria-rowcount'?: number | undefined;
|
137
142
|
'aria-rowindex'?: number | undefined;
|
138
143
|
'aria-rowspan'?: number | undefined;
|
139
|
-
'aria-selected'?: boolean | "
|
144
|
+
'aria-selected'?: boolean | "false" | "true" | undefined;
|
140
145
|
'aria-setsize'?: number | undefined;
|
141
146
|
'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined;
|
142
147
|
'aria-valuemax'?: number | undefined;
|
@@ -307,15 +312,14 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
307
312
|
onAnimationIterationCapture?: React.AnimationEventHandler<HTMLSpanElement> | undefined;
|
308
313
|
onTransitionEnd?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
|
309
314
|
onTransitionEndCapture?: React.TransitionEventHandler<HTMLSpanElement> | undefined;
|
310
|
-
|
311
|
-
sx?: import("@styled-system/css").SystemStyleObject | undefined;
|
315
|
+
sx?: import("./sx").BetterSystemStyleObject | undefined;
|
312
316
|
disabled?: boolean | undefined;
|
313
317
|
variant?: "small" | "large" | undefined;
|
314
318
|
hasIcon?: boolean | undefined;
|
315
319
|
contrast?: boolean | undefined;
|
316
320
|
} & {
|
317
321
|
theme?: any;
|
318
|
-
}, "maxWidth" | "minWidth" | "width" | "
|
322
|
+
}, "maxWidth" | "minWidth" | "width" | "block" | "theme" | "sx" | "disabled" | "variant" | "contrast">, string | number | symbol> & React.RefAttributes<HTMLInputElement> & {
|
319
323
|
selectedTokenIndex: number | undefined;
|
320
324
|
setSelectedTokenIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
321
325
|
}, string | number | symbol> & React.RefAttributes<HTMLInputElement>>;
|
@@ -25,6 +25,10 @@ var _TextInputWrapper = _interopRequireDefault(require("./_TextInputWrapper"));
|
|
25
25
|
|
26
26
|
var _Box = _interopRequireDefault(require("./Box"));
|
27
27
|
|
28
|
+
var _Text = _interopRequireDefault(require("./Text"));
|
29
|
+
|
30
|
+
var _iterateFocusableElements = require("./utils/iterateFocusableElements");
|
31
|
+
|
28
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
33
|
|
30
34
|
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); }
|
@@ -33,7 +37,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
33
37
|
|
34
38
|
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); }
|
35
39
|
|
36
|
-
|
40
|
+
const overflowCountFontSizeMap = {
|
41
|
+
small: 0,
|
42
|
+
medium: 1,
|
43
|
+
large: 1,
|
44
|
+
extralarge: 2
|
45
|
+
}; // using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
46
|
+
|
37
47
|
function TextInputWithTokensInnerComponent({
|
38
48
|
icon: IconComponent,
|
39
49
|
contrast,
|
@@ -53,9 +63,11 @@ function TextInputWithTokensInnerComponent({
|
|
53
63
|
minWidth: minWidthProp,
|
54
64
|
maxWidth: maxWidthProp,
|
55
65
|
variant: variantProp,
|
66
|
+
visibleTokenCount,
|
56
67
|
...rest
|
57
68
|
}, externalRef) {
|
58
69
|
const {
|
70
|
+
onBlur,
|
59
71
|
onFocus,
|
60
72
|
onKeyDown,
|
61
73
|
...inputPropsRest
|
@@ -64,6 +76,7 @@ function TextInputWithTokensInnerComponent({
|
|
64
76
|
const localInputRef = (0, _react.useRef)(null);
|
65
77
|
const combinedInputRef = (0, _useCombinedRefs.useCombinedRefs)(localInputRef, ref);
|
66
78
|
const [selectedTokenIndex, setSelectedTokenIndex] = (0, _react.useState)();
|
79
|
+
const [tokensAreTruncated, setTokensAreTruncated] = (0, _react.useState)(Boolean(visibleTokenCount));
|
67
80
|
const {
|
68
81
|
containerRef
|
69
82
|
} = (0, _useFocusZone.useFocusZone)({
|
@@ -98,14 +111,25 @@ function TextInputWithTokensInnerComponent({
|
|
98
111
|
}, [selectedTokenIndex]);
|
99
112
|
|
100
113
|
const handleTokenRemove = tokenId => {
|
101
|
-
onTokenRemove(tokenId);
|
114
|
+
onTokenRemove(tokenId); // HACK: wait a tick for the the token node to be removed from the DOM
|
102
115
|
|
103
|
-
|
104
|
-
var _containerRef$current2;
|
116
|
+
setTimeout(() => {
|
117
|
+
var _containerRef$current2, _containerRef$current3;
|
105
118
|
|
106
|
-
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex];
|
107
|
-
|
108
|
-
|
119
|
+
const nextElementToFocus = (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.children[selectedTokenIndex || 0]; // when removing the first token by keying "Backspace" or "Delete",
|
120
|
+
// `nextFocusableElement` is the div that wraps the input
|
121
|
+
|
122
|
+
const firstFocusable = nextElementToFocus && (0, _iterateFocusableElements.isFocusable)(nextElementToFocus) ? nextElementToFocus : Array.from(((_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.children) || []).find(el => (0, _iterateFocusableElements.isFocusable)(el));
|
123
|
+
|
124
|
+
if (firstFocusable) {
|
125
|
+
firstFocusable.focus();
|
126
|
+
} else {
|
127
|
+
var _ref$current;
|
128
|
+
|
129
|
+
// if there are no tokens left, focus the input
|
130
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
131
|
+
}
|
132
|
+
}, 0);
|
109
133
|
};
|
110
134
|
|
111
135
|
const handleTokenFocus = tokenIndex => () => {
|
@@ -113,30 +137,55 @@ function TextInputWithTokensInnerComponent({
|
|
113
137
|
};
|
114
138
|
|
115
139
|
const handleTokenBlur = () => {
|
116
|
-
setSelectedTokenIndex(undefined);
|
140
|
+
setSelectedTokenIndex(undefined); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
141
|
+
// this prevents the tokens from hiding when the user is moving focus between tokens,
|
142
|
+
// but still hides the tokens when the user blurs the token by tabbing out or clicking somewhere else on the page
|
143
|
+
|
144
|
+
setTimeout(() => {
|
145
|
+
var _containerRef$current4;
|
146
|
+
|
147
|
+
if (!((_containerRef$current4 = containerRef.current) !== null && _containerRef$current4 !== void 0 && _containerRef$current4.contains(document.activeElement)) && visibleTokenCount) {
|
148
|
+
setTokensAreTruncated(true);
|
149
|
+
}
|
150
|
+
}, 0);
|
117
151
|
};
|
118
152
|
|
119
|
-
const handleTokenKeyUp =
|
120
|
-
if (
|
121
|
-
var _ref$
|
153
|
+
const handleTokenKeyUp = event => {
|
154
|
+
if (event.key === 'Escape') {
|
155
|
+
var _ref$current2;
|
122
156
|
|
123
|
-
(_ref$
|
157
|
+
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.focus();
|
124
158
|
}
|
125
159
|
};
|
126
160
|
|
127
|
-
const handleInputFocus =
|
128
|
-
onFocus && onFocus(
|
161
|
+
const handleInputFocus = event => {
|
162
|
+
onFocus && onFocus(event);
|
129
163
|
setSelectedTokenIndex(undefined);
|
164
|
+
visibleTokenCount && setTokensAreTruncated(false);
|
165
|
+
};
|
166
|
+
|
167
|
+
const handleInputBlur = event => {
|
168
|
+
onBlur && onBlur(event); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
169
|
+
// this prevents the tokens from hiding when the user is moving focus from the input to a token,
|
170
|
+
// but still hides the tokens when the user blurs the input by tabbing out or clicking somewhere else on the page
|
171
|
+
|
172
|
+
setTimeout(() => {
|
173
|
+
var _containerRef$current5;
|
174
|
+
|
175
|
+
if (!((_containerRef$current5 = containerRef.current) !== null && _containerRef$current5 !== void 0 && _containerRef$current5.contains(document.activeElement)) && visibleTokenCount) {
|
176
|
+
setTokensAreTruncated(true);
|
177
|
+
}
|
178
|
+
}, 0);
|
130
179
|
};
|
131
180
|
|
132
181
|
const handleInputKeyDown = e => {
|
133
|
-
var _ref$
|
182
|
+
var _ref$current3;
|
134
183
|
|
135
184
|
if (onKeyDown) {
|
136
185
|
onKeyDown(e);
|
137
186
|
}
|
138
187
|
|
139
|
-
if ((_ref$
|
188
|
+
if ((_ref$current3 = ref.current) !== null && _ref$current3 !== void 0 && _ref$current3.value) {
|
140
189
|
return;
|
141
190
|
}
|
142
191
|
|
@@ -157,13 +206,24 @@ function TextInputWithTokensInnerComponent({
|
|
157
206
|
|
158
207
|
|
159
208
|
setTimeout(() => {
|
160
|
-
var _ref$
|
209
|
+
var _ref$current4;
|
161
210
|
|
162
|
-
(_ref$
|
211
|
+
(_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.select();
|
163
212
|
}, 0);
|
164
213
|
}
|
165
214
|
};
|
166
215
|
|
216
|
+
const focusInput = () => {
|
217
|
+
var _combinedInputRef$cur;
|
218
|
+
|
219
|
+
(_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
|
220
|
+
};
|
221
|
+
|
222
|
+
const preventTokenClickPropagation = event => {
|
223
|
+
event.stopPropagation();
|
224
|
+
};
|
225
|
+
|
226
|
+
const visibleTokens = tokensAreTruncated ? tokens.slice(0, visibleTokenCount) : tokens;
|
167
227
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
168
228
|
block: block,
|
169
229
|
className: className,
|
@@ -175,15 +235,8 @@ function TextInputWithTokensInnerComponent({
|
|
175
235
|
minWidth: minWidthProp,
|
176
236
|
maxWidth: maxWidthProp,
|
177
237
|
variant: variantProp,
|
178
|
-
|
179
|
-
sx: {
|
180
|
-
alignItems: 'center',
|
181
|
-
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
182
|
-
gap: '0.25rem',
|
183
|
-
'> *': {
|
184
|
-
flexShrink: 0
|
185
|
-
},
|
186
|
-
...(block ? {
|
238
|
+
onClick: focusInput,
|
239
|
+
sx: { ...(block ? {
|
187
240
|
display: 'flex',
|
188
241
|
width: '100%'
|
189
242
|
} : {}),
|
@@ -196,6 +249,21 @@ function TextInputWithTokensInnerComponent({
|
|
196
249
|
} : {}),
|
197
250
|
...sxProp
|
198
251
|
}
|
252
|
+
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
253
|
+
ref: containerRef,
|
254
|
+
display: "flex",
|
255
|
+
sx: {
|
256
|
+
alignItems: 'center',
|
257
|
+
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
258
|
+
marginLeft: '-0.25rem',
|
259
|
+
marginBottom: '-0.25rem',
|
260
|
+
flexGrow: 1,
|
261
|
+
'> *': {
|
262
|
+
flexShrink: 0,
|
263
|
+
marginLeft: '0.25rem',
|
264
|
+
marginBottom: '0.25rem'
|
265
|
+
}
|
266
|
+
}
|
199
267
|
}, /*#__PURE__*/_react.default.createElement(_Box.default, {
|
200
268
|
sx: {
|
201
269
|
order: 1,
|
@@ -207,12 +275,13 @@ function TextInputWithTokensInnerComponent({
|
|
207
275
|
ref: combinedInputRef,
|
208
276
|
disabled: disabled,
|
209
277
|
onFocus: handleInputFocus,
|
278
|
+
onBlur: handleInputBlur,
|
210
279
|
onKeyDown: handleInputKeyDown,
|
211
280
|
type: "text",
|
212
281
|
sx: {
|
213
282
|
height: '100%'
|
214
283
|
}
|
215
|
-
}, inputPropsRest))),
|
284
|
+
}, inputPropsRest))), TokenComponent ? visibleTokens.map(({
|
216
285
|
id,
|
217
286
|
...tokenRest
|
218
287
|
}, i) => /*#__PURE__*/_react.default.createElement(TokenComponent, _extends({
|
@@ -220,6 +289,7 @@ function TextInputWithTokensInnerComponent({
|
|
220
289
|
onFocus: handleTokenFocus(i),
|
221
290
|
onBlur: handleTokenBlur,
|
222
291
|
onKeyUp: handleTokenKeyUp,
|
292
|
+
onClick: preventTokenClickPropagation,
|
223
293
|
isSelected: selectedTokenIndex === i,
|
224
294
|
onRemove: () => {
|
225
295
|
handleTokenRemove(id);
|
@@ -227,7 +297,10 @@ function TextInputWithTokensInnerComponent({
|
|
227
297
|
hideRemoveButton: hideTokenRemoveButtons,
|
228
298
|
size: size,
|
229
299
|
tabIndex: 0
|
230
|
-
}, tokenRest))) : null
|
300
|
+
}, tokenRest))) : null, tokensAreTruncated ? /*#__PURE__*/_react.default.createElement(_Text.default, {
|
301
|
+
color: "fg.muted",
|
302
|
+
fontSize: size && overflowCountFontSizeMap[size]
|
303
|
+
}, "+", tokens.length - visibleTokens.length) : null));
|
231
304
|
}
|
232
305
|
|
233
306
|
TextInputWithTokensInnerComponent.displayName = "TextInputWithTokensInnerComponent";
|