@primer/components 0.0.0-2021828205225 → 0.0.0-20218282148
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 +46 -2
- package/dist/browser.esm.js +738 -694
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +759 -715
- package/dist/browser.umd.js.map +1 -1
- package/lib/ActionList/Divider.js +1 -1
- package/lib/ActionList/Header.js +2 -2
- package/lib/ActionList/Item.js +14 -14
- package/lib/ActionList/List.js +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.js +2 -2
- package/lib/Avatar.d.ts +4 -0
- package/lib/AvatarPair.js +1 -1
- package/lib/AvatarStack.js +1 -1
- package/lib/BranchName.js +1 -1
- package/lib/Breadcrumbs.d.ts +40 -0
- package/lib/{Breadcrumb.js → Breadcrumbs.js} +33 -23
- package/lib/Button/Button.d.ts +0 -1
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonClose.d.ts +1 -2
- package/lib/Button/ButtonClose.js +1 -1
- package/lib/Button/ButtonDanger.d.ts +0 -1
- package/lib/Button/ButtonInvisible.d.ts +0 -1
- package/lib/Button/ButtonInvisible.js +1 -1
- package/lib/Button/ButtonOutline.d.ts +0 -1
- package/lib/Button/ButtonPrimary.d.ts +0 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/CircleBadge.js +1 -1
- package/lib/CircleOcticon.d.ts +0 -1
- package/lib/CircleOcticon.js +1 -1
- package/lib/CounterLabel.js +2 -2
- package/lib/Dialog/ConfirmationDialog.js +1 -1
- package/lib/Dialog/Dialog.js +9 -9
- package/lib/Dialog.d.ts +2 -3
- package/lib/Dialog.js +4 -4
- package/lib/Dropdown.d.ts +0 -4
- package/lib/Dropdown.js +2 -2
- package/lib/DropdownMenu/DropdownButton.d.ts +1 -2
- package/lib/DropdownStyles.js +6 -6
- package/lib/FilterList.d.ts +0 -1
- package/lib/FilterList.js +1 -1
- package/lib/FilteredActionList/FilteredActionList.js +34 -8
- package/lib/Flash.js +1 -1
- package/lib/Label.js +2 -2
- package/lib/Link.js +1 -1
- package/lib/Overlay.d.ts +1 -2
- package/lib/Overlay.js +6 -11
- package/lib/Pagehead.js +1 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/Popover.js +1 -1
- package/lib/Position.d.ts +4 -4
- package/lib/ProgressBar.js +1 -1
- package/lib/SelectMenu/SelectMenu.d.ts +15 -344
- package/lib/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib/SelectMenu/SelectMenuFilter.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuItem.js +1 -1
- package/lib/SelectMenu/SelectMenuList.js +1 -1
- package/lib/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
- package/lib/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib/SelectMenu/SelectMenuModal.js +2 -2
- package/lib/SelectMenu/SelectMenuTab.js +1 -1
- package/lib/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib/SelectPanel/SelectPanel.js +3 -2
- package/lib/SideNav.js +5 -5
- package/lib/StateLabel.js +1 -1
- package/lib/SubNav.js +1 -1
- package/lib/TabNav.js +2 -2
- package/lib/TextInput.d.ts +7 -10
- package/lib/TextInput.js +29 -24
- package/lib/Timeline.d.ts +0 -1
- package/lib/Timeline.js +16 -19
- package/lib/Tooltip.js +1 -1
- package/lib/UnderlineNav.js +2 -2
- package/lib/hooks/useOverlay.d.ts +1 -2
- package/lib/hooks/useOverlay.js +6 -11
- package/lib/index.d.ts +3 -2
- package/lib/index.js +22 -2
- package/lib/theme-preval.d.ts +4 -52
- package/lib/theme-preval.js +4003 -1180
- package/lib/utils/ssr.d.ts +1 -0
- package/lib/utils/ssr.js +19 -0
- package/lib/utils/testing.d.ts +889 -5527
- package/lib/utils/types.d.ts +0 -3
- package/lib/utils/uniqueId.js +1 -0
- package/lib-esm/ActionList/Divider.js +1 -1
- package/lib-esm/ActionList/Header.js +2 -2
- package/lib-esm/ActionList/Item.js +15 -15
- package/lib-esm/ActionList/List.js +1 -1
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -3
- package/lib-esm/Avatar.d.ts +4 -0
- package/lib-esm/AvatarPair.js +1 -1
- package/lib-esm/AvatarStack.js +1 -1
- package/lib-esm/BranchName.js +1 -1
- package/lib-esm/Breadcrumbs.d.ts +40 -0
- package/lib-esm/{Breadcrumb.js → Breadcrumbs.js} +30 -21
- package/lib-esm/Button/Button.d.ts +0 -1
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonClose.d.ts +1 -2
- package/lib-esm/Button/ButtonClose.js +1 -1
- package/lib-esm/Button/ButtonDanger.d.ts +0 -1
- package/lib-esm/Button/ButtonInvisible.d.ts +0 -1
- package/lib-esm/Button/ButtonInvisible.js +1 -1
- package/lib-esm/Button/ButtonOutline.d.ts +0 -1
- package/lib-esm/Button/ButtonPrimary.d.ts +0 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/CircleBadge.js +1 -1
- package/lib-esm/CircleOcticon.d.ts +0 -1
- package/lib-esm/CircleOcticon.js +1 -1
- package/lib-esm/CounterLabel.js +2 -2
- package/lib-esm/Dialog/ConfirmationDialog.js +1 -1
- package/lib-esm/Dialog/Dialog.js +8 -8
- package/lib-esm/Dialog.d.ts +2 -3
- package/lib-esm/Dialog.js +4 -4
- package/lib-esm/Dropdown.d.ts +0 -4
- package/lib-esm/Dropdown.js +2 -2
- package/lib-esm/DropdownMenu/DropdownButton.d.ts +1 -2
- package/lib-esm/DropdownStyles.js +6 -6
- package/lib-esm/FilterList.d.ts +0 -1
- package/lib-esm/FilterList.js +1 -1
- package/lib-esm/FilteredActionList/FilteredActionList.js +34 -6
- package/lib-esm/Flash.js +1 -1
- package/lib-esm/Label.js +2 -2
- package/lib-esm/Link.js +1 -1
- package/lib-esm/Overlay.d.ts +1 -2
- package/lib-esm/Overlay.js +6 -9
- package/lib-esm/Pagehead.js +1 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/Popover.js +1 -1
- package/lib-esm/Position.d.ts +4 -4
- package/lib-esm/ProgressBar.js +1 -1
- package/lib-esm/SelectMenu/SelectMenu.d.ts +15 -344
- package/lib-esm/SelectMenu/SelectMenuDivider.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuFilter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuFooter.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuHeader.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuItem.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuItem.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuList.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuLoadingAnimation.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.d.ts +1 -1
- package/lib-esm/SelectMenu/SelectMenuModal.js +2 -2
- package/lib-esm/SelectMenu/SelectMenuTab.js +1 -1
- package/lib-esm/SelectMenu/SelectMenuTabPanel.js +1 -1
- package/lib-esm/SelectPanel/SelectPanel.js +3 -2
- package/lib-esm/SideNav.js +5 -5
- package/lib-esm/StateLabel.js +1 -1
- package/lib-esm/SubNav.js +1 -1
- package/lib-esm/TabNav.js +2 -2
- package/lib-esm/TextInput.d.ts +7 -10
- package/lib-esm/TextInput.js +29 -23
- package/lib-esm/Timeline.d.ts +0 -1
- package/lib-esm/Timeline.js +12 -17
- package/lib-esm/Tooltip.js +1 -1
- package/lib-esm/UnderlineNav.js +2 -2
- package/lib-esm/hooks/useOverlay.d.ts +1 -2
- package/lib-esm/hooks/useOverlay.js +6 -11
- package/lib-esm/index.d.ts +3 -2
- package/lib-esm/index.js +3 -2
- package/lib-esm/theme-preval.d.ts +4 -52
- package/lib-esm/theme-preval.js +4003 -1180
- package/lib-esm/utils/ssr.d.ts +1 -0
- package/lib-esm/utils/ssr.js +1 -0
- package/lib-esm/utils/testing.d.ts +889 -5527
- package/lib-esm/utils/types.d.ts +0 -3
- package/lib-esm/utils/uniqueId.js +1 -0
- package/package.json +15 -15
- package/lib/Autocomplete/Autocomplete.d.ts +0 -26
- package/lib/Autocomplete/Autocomplete.js +0 -55
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -13
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib/Autocomplete/AutocompleteInput.js +0 -134
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -70
- package/lib/Autocomplete/AutocompleteMenu.js +0 -244
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/Badge/Badge.d.ts +0 -8
- package/lib/Badge/Badge.js +0 -59
- package/lib/Badge/BadgeState.d.ts +0 -13
- package/lib/Badge/BadgeState.js +0 -51
- package/lib/Badge/_badgeStyleUtils.d.ts +0 -3
- package/lib/Badge/_badgeStyleUtils.js +0 -39
- package/lib/Breadcrumb.d.ts +0 -23
- package/lib/TextInputTokens.d.ts +0 -43
- package/lib/TextInputTokens.js +0 -231
- package/lib/TextInputWithTokens.d.ts +0 -41
- package/lib/TextInputWithTokens.js +0 -396
- package/lib/Token/Token.d.ts +0 -10
- package/lib/Token/Token.js +0 -63
- package/lib/Token/TokenBase.d.ts +0 -16
- package/lib/Token/TokenBase.js +0 -76
- package/lib/Token/TokenLabel.d.ts +0 -10
- package/lib/Token/TokenLabel.js +0 -121
- package/lib/Token/TokenProfile.d.ts +0 -7
- package/lib/Token/TokenProfile.js +0 -50
- package/lib/Token/_RemoveTokenButton.d.ts +0 -3
- package/lib/Token/_RemoveTokenButton.js +0 -43
- package/lib/Token/_tokenButtonUtils.d.ts +0 -9
- package/lib/Token/_tokenButtonUtils.js +0 -42
- 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-esm/Autocomplete/Autocomplete.d.ts +0 -26
- package/lib-esm/Autocomplete/Autocomplete.js +0 -36
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -13
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -115
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -70
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -218
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/Badge/Badge.d.ts +0 -8
- package/lib-esm/Badge/Badge.js +0 -44
- package/lib-esm/Badge/BadgeState.d.ts +0 -13
- package/lib-esm/Badge/BadgeState.js +0 -40
- package/lib-esm/Badge/_badgeStyleUtils.d.ts +0 -3
- package/lib-esm/Badge/_badgeStyleUtils.js +0 -29
- package/lib-esm/Breadcrumb.d.ts +0 -23
- package/lib-esm/TextInputTokens.d.ts +0 -43
- package/lib-esm/TextInputTokens.js +0 -204
- package/lib-esm/TextInputWithTokens.d.ts +0 -41
- package/lib-esm/TextInputWithTokens.js +0 -361
- package/lib-esm/Token/Token.d.ts +0 -10
- package/lib-esm/Token/Token.js +0 -44
- package/lib-esm/Token/TokenBase.d.ts +0 -16
- package/lib-esm/Token/TokenBase.js +0 -56
- package/lib-esm/Token/TokenLabel.d.ts +0 -10
- package/lib-esm/Token/TokenLabel.js +0 -101
- package/lib-esm/Token/TokenProfile.d.ts +0 -7
- package/lib-esm/Token/TokenProfile.js +0 -29
- package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -3
- package/lib-esm/Token/_RemoveTokenButton.js +0 -28
- package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -9
- package/lib-esm/Token/_tokenButtonUtils.js +0 -26
- 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
@@ -1,43 +0,0 @@
|
|
1
|
-
import React, { ComponentPropsWithoutRef } from 'react';
|
2
|
-
import { ComponentProps, MandateProps } from './utils/types';
|
3
|
-
import Token, { TokenProps } from './Token/Token';
|
4
|
-
import TokenLabel, { TokenLabelProps } from './Token/TokenLabel';
|
5
|
-
import TokenProfile, { TokenProfileProps } from './Token/TokenProfile';
|
6
|
-
import { TokenSizeKeys } from './Token/TokenBase';
|
7
|
-
import { TextInputProps } from './TextInput';
|
8
|
-
declare type AnyTokenProps = Partial<TokenProps & TokenLabelProps & TokenProfileProps>;
|
9
|
-
declare type TokenDatum = MandateProps<AnyTokenProps, 'id' | 'text'>;
|
10
|
-
declare type TextInputWithTokensInternalProps = {
|
11
|
-
/**
|
12
|
-
* The array of tokens to render
|
13
|
-
*/
|
14
|
-
tokens: TokenDatum[];
|
15
|
-
/**
|
16
|
-
* The function that gets called when a token is removed
|
17
|
-
*/
|
18
|
-
onTokenRemove: (tokenId: string | number) => void;
|
19
|
-
/**
|
20
|
-
* The component used to render each token
|
21
|
-
*/
|
22
|
-
tokenComponent?: React.ComponentType<ComponentPropsWithoutRef<typeof Token> | ComponentPropsWithoutRef<typeof TokenLabel> | ComponentPropsWithoutRef<typeof TokenProfile>>;
|
23
|
-
/**
|
24
|
-
* The maximum height of the component. If the content in the input exceeds this height,
|
25
|
-
* it will scroll vertically
|
26
|
-
*/
|
27
|
-
maxHeight?: React.CSSProperties['maxHeight'];
|
28
|
-
/**
|
29
|
-
* Whether tokens should render inline horizontally. By default, tokens wrap to new lines.
|
30
|
-
*/
|
31
|
-
preventTokenWrapping?: boolean;
|
32
|
-
/**
|
33
|
-
* The size of the tokens
|
34
|
-
*/
|
35
|
-
tokenSizeVariant?: TokenSizeKeys;
|
36
|
-
/**
|
37
|
-
* Whether the remove buttons should be rendered in the tokens
|
38
|
-
*/
|
39
|
-
hideTokenRemoveButtons?: boolean;
|
40
|
-
} & TextInputProps;
|
41
|
-
declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInputWithTokensInternalProps, "backgroundColor" | "color" | "display" | "height" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "opacity" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "width" | "margin" | "padding" | "hidden" | "children" | "theme" | "value" | "form" | "p" | "slot" | "style" | "title" | "pattern" | "list" | "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" | "css" | "block" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "step" | "size" | "icon" | "sx" | "max" | "min" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "accept" | "capture" | "checked" | "enterKeyHint" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "as" | "variant" | "hasIcon" | "contrast" | "inputComponent" | "wrapperRef" | "tokens" | "onTokenRemove" | "tokenComponent" | "preventTokenWrapping" | "tokenSizeVariant" | "hideTokenRemoveButtons"> & React.RefAttributes<HTMLInputElement>>;
|
42
|
-
export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
|
43
|
-
export default TextInputWithTokens;
|
@@ -1,204 +0,0 @@
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
|
3
|
-
import React, { useRef, useState } from 'react';
|
4
|
-
import { omit } from '@styled-system/props';
|
5
|
-
import styled from 'styled-components';
|
6
|
-
import { FocusKeys } from './behaviors/focusZone';
|
7
|
-
import { useCombinedRefs } from './hooks/useCombinedRefs';
|
8
|
-
import { useFocusZone } from './hooks/useFocusZone';
|
9
|
-
import Token from './Token/Token';
|
10
|
-
import TextInput from './TextInput';
|
11
|
-
import { useProvidedRefOrCreate } from './hooks';
|
12
|
-
import UnstyledTextInput from './_UnstyledTextInput';
|
13
|
-
const InputWrapper = styled.div.withConfig({
|
14
|
-
displayName: "TextInputTokens__InputWrapper",
|
15
|
-
componentId: "sc-1k54xiz-0"
|
16
|
-
})(["order:1;flex-grow:1;"]);
|
17
|
-
// using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
18
|
-
const TextInputWithTokensComponent = /*#__PURE__*/React.forwardRef(({
|
19
|
-
icon: IconComponent,
|
20
|
-
contrast,
|
21
|
-
className,
|
22
|
-
block,
|
23
|
-
disabled,
|
24
|
-
theme,
|
25
|
-
sx: sxProp,
|
26
|
-
tokens,
|
27
|
-
onTokenRemove,
|
28
|
-
tokenComponent: TokenComponent,
|
29
|
-
preventTokenWrapping,
|
30
|
-
tokenSizeVariant,
|
31
|
-
hideTokenRemoveButtons,
|
32
|
-
selectedTokenIdx,
|
33
|
-
setSelectedTokenIdx,
|
34
|
-
...rest
|
35
|
-
}, externalRef) => {
|
36
|
-
const ref = useProvidedRefOrCreate(externalRef);
|
37
|
-
const {
|
38
|
-
onFocus,
|
39
|
-
onKeyDown,
|
40
|
-
...inputPropsRest
|
41
|
-
} = omit(rest);
|
42
|
-
|
43
|
-
const handleTokenRemove = tokenId => {
|
44
|
-
onTokenRemove(tokenId);
|
45
|
-
};
|
46
|
-
|
47
|
-
const handleTokenFocus = tokenIdx => () => {
|
48
|
-
setSelectedTokenIdx(tokenIdx);
|
49
|
-
};
|
50
|
-
|
51
|
-
const handleTokenBlur = () => {
|
52
|
-
setSelectedTokenIdx(undefined);
|
53
|
-
};
|
54
|
-
|
55
|
-
const handleTokenKeyUp = tokenId => e => {
|
56
|
-
if (e.key === 'Backspace') {
|
57
|
-
handleTokenRemove(tokenId);
|
58
|
-
}
|
59
|
-
|
60
|
-
if (e.key === 'Escape') {
|
61
|
-
var _ref$current;
|
62
|
-
|
63
|
-
ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
64
|
-
}
|
65
|
-
};
|
66
|
-
|
67
|
-
const handleInputFocus = e => {
|
68
|
-
onFocus && onFocus(e);
|
69
|
-
setSelectedTokenIdx(undefined);
|
70
|
-
};
|
71
|
-
|
72
|
-
const handleInputKeyDown = e => {
|
73
|
-
var _ref$current2;
|
74
|
-
|
75
|
-
if (onKeyDown) {
|
76
|
-
onKeyDown(e);
|
77
|
-
}
|
78
|
-
|
79
|
-
if (ref !== null && ref !== void 0 && (_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && _ref$current2.value) {
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
|
83
|
-
const lastToken = tokens[tokens.length - 1];
|
84
|
-
|
85
|
-
if (e.key === 'Backspace' && lastToken) {
|
86
|
-
handleTokenRemove(lastToken.id);
|
87
|
-
|
88
|
-
if (ref !== null && ref !== void 0 && ref.current) {
|
89
|
-
// TODO: eliminate the first hack by making changes to the Autocomplete component
|
90
|
-
// COLEHELP
|
91
|
-
//
|
92
|
-
// HACKS:
|
93
|
-
// 1. Directly setting `ref.current.value` instead of updating state because the autocomplete
|
94
|
-
// highlight behavior doesn't work correctly if we update the value with a setState action in onChange
|
95
|
-
// 2. Adding an extra space so that when I backspace, it doesn't delete the last letter
|
96
|
-
ref.current.value = `${lastToken.text} `;
|
97
|
-
} // HACK: for some reason we need to wait a tick for `.select()` to work
|
98
|
-
|
99
|
-
|
100
|
-
setTimeout(() => {
|
101
|
-
var _ref$current3;
|
102
|
-
|
103
|
-
ref === null || ref === void 0 ? void 0 : (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.select();
|
104
|
-
}, 1);
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputWrapper, {
|
109
|
-
key: "inputWrapper"
|
110
|
-
}, /*#__PURE__*/React.createElement(UnstyledTextInput, _extends({
|
111
|
-
ref: ref,
|
112
|
-
disabled: disabled,
|
113
|
-
onFocus: handleInputFocus,
|
114
|
-
onKeyDown: handleInputKeyDown,
|
115
|
-
type: "text",
|
116
|
-
sx: {
|
117
|
-
height: '100%'
|
118
|
-
}
|
119
|
-
}, inputPropsRest))), tokens !== null && tokens !== void 0 && tokens.length && TokenComponent ? tokens.map(({
|
120
|
-
id,
|
121
|
-
...tokenRest
|
122
|
-
}, i) => /*#__PURE__*/React.createElement(TokenComponent, _extends({
|
123
|
-
key: id,
|
124
|
-
onFocus: handleTokenFocus(i),
|
125
|
-
onBlur: handleTokenBlur,
|
126
|
-
onKeyUp: handleTokenKeyUp(id),
|
127
|
-
isSelected: selectedTokenIdx === i,
|
128
|
-
handleRemove: !hideTokenRemoveButtons ? () => {
|
129
|
-
handleTokenRemove(id);
|
130
|
-
} : undefined,
|
131
|
-
variant: tokenSizeVariant,
|
132
|
-
tabIndex: 0
|
133
|
-
}, tokenRest))) : null);
|
134
|
-
});
|
135
|
-
const TextInputWithTokens = /*#__PURE__*/React.forwardRef(({
|
136
|
-
tokens,
|
137
|
-
sx: sxProp,
|
138
|
-
...props
|
139
|
-
}, ref) => {
|
140
|
-
const localInputRef = useRef(null);
|
141
|
-
const combinedInputRef = useCombinedRefs(localInputRef, ref);
|
142
|
-
const [selectedTokenIdx, setSelectedTokenIdx] = useState();
|
143
|
-
const {
|
144
|
-
containerRef
|
145
|
-
} = useFocusZone({
|
146
|
-
focusOutBehavior: 'wrap',
|
147
|
-
bindKeys: FocusKeys.ArrowHorizontal | FocusKeys.HomeAndEnd,
|
148
|
-
focusableElementFilter: element => {
|
149
|
-
return !(element instanceof HTMLButtonElement);
|
150
|
-
},
|
151
|
-
getNextFocusable: direction => {
|
152
|
-
var _containerRef$current;
|
153
|
-
|
154
|
-
if (!selectedTokenIdx && selectedTokenIdx !== 0) {
|
155
|
-
return undefined;
|
156
|
-
}
|
157
|
-
|
158
|
-
let nextIndex = selectedTokenIdx + 1;
|
159
|
-
|
160
|
-
if (direction === 'next') {
|
161
|
-
nextIndex += 1;
|
162
|
-
}
|
163
|
-
|
164
|
-
if (direction === 'previous') {
|
165
|
-
nextIndex -= 1;
|
166
|
-
}
|
167
|
-
|
168
|
-
if (nextIndex > tokens.length || nextIndex < 1) {
|
169
|
-
return combinedInputRef.current || undefined;
|
170
|
-
}
|
171
|
-
|
172
|
-
return containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.children[nextIndex];
|
173
|
-
}
|
174
|
-
}, [selectedTokenIdx]);
|
175
|
-
return /*#__PURE__*/React.createElement(TextInput, _extends({
|
176
|
-
ref: combinedInputRef,
|
177
|
-
wrapperRef: containerRef,
|
178
|
-
as: TextInputWithTokensComponent,
|
179
|
-
selectedTokenIdx: selectedTokenIdx,
|
180
|
-
setSelectedTokenIdx: setSelectedTokenIdx,
|
181
|
-
tokens: tokens,
|
182
|
-
sx: {
|
183
|
-
'alignItems': props.preventTokenWrapping ? 'center' : undefined,
|
184
|
-
'flexWrap': props.preventTokenWrapping ? 'nowrap' : 'wrap',
|
185
|
-
'gap': '0.25rem',
|
186
|
-
'> *': {
|
187
|
-
'flexShrink': 0
|
188
|
-
},
|
189
|
-
...(props.block ? {
|
190
|
-
display: 'flex',
|
191
|
-
width: '100%'
|
192
|
-
} : {}),
|
193
|
-
...sxProp
|
194
|
-
}
|
195
|
-
}, props));
|
196
|
-
}); // type TestType = ComponentPropsWithoutRef<typeof Token>
|
197
|
-
|
198
|
-
TextInputWithTokens.defaultProps = {
|
199
|
-
tokenComponent: Token,
|
200
|
-
tokenSizeVariant: "xl",
|
201
|
-
hideTokenRemoveButtons: false
|
202
|
-
};
|
203
|
-
TextInputWithTokens.displayName = 'TextInputWithTokens';
|
204
|
-
export default TextInputWithTokens;
|
@@ -1,41 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
|
3
|
-
import { ItemProps } from './ActionList';
|
4
|
-
import { ItemInput } from './ActionList/List';
|
5
|
-
import { SystemCommonProps } from './constants';
|
6
|
-
import { SxProp } from './sx';
|
7
|
-
import { ComponentProps } from './utils/types';
|
8
|
-
import Token from './Token/Token';
|
9
|
-
declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
|
10
|
-
declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
|
11
|
-
disabled?: boolean | undefined;
|
12
|
-
hasIcon?: boolean | undefined;
|
13
|
-
block?: boolean | undefined;
|
14
|
-
contrast?: boolean | undefined;
|
15
|
-
variant?: "large" | "small" | undefined;
|
16
|
-
maxHeight?: React.CSSProperties['maxHeight'];
|
17
|
-
} & SystemCommonProps & 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>;
|
18
|
-
interface Token {
|
19
|
-
text?: string;
|
20
|
-
id: string | number;
|
21
|
-
}
|
22
|
-
declare type TextInputWithTokensInternalProps = {
|
23
|
-
as?: any;
|
24
|
-
icon?: React.ComponentType<{
|
25
|
-
className?: string;
|
26
|
-
}>;
|
27
|
-
tokens: Token[];
|
28
|
-
onTokenRemove: (tokenId: string | number) => void;
|
29
|
-
selectableItems: ItemInput[];
|
30
|
-
onFilterChange: (value: string, e: React.ChangeEvent<HTMLInputElement>) => void;
|
31
|
-
onItemSelect: NonNullable<ItemProps['onAction']>;
|
32
|
-
tokenComponent?: React.FunctionComponent<any>;
|
33
|
-
emptyStateText?: React.ReactNode | false;
|
34
|
-
addNewTokenItem?: Omit<ItemInput, 'onAction'>;
|
35
|
-
onCloseOptionsList?: () => void;
|
36
|
-
maxHeight?: React.CSSProperties['maxHeight'];
|
37
|
-
loading?: boolean;
|
38
|
-
} & ComponentProps<typeof Wrapper> & ComponentProps<typeof Input>;
|
39
|
-
declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<TextInputWithTokensInternalProps, "backgroundColor" | "color" | "display" | "height" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minWidth" | "opacity" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "translate" | "width" | "margin" | "padding" | "hidden" | "children" | "theme" | "value" | "form" | "p" | "slot" | "style" | "title" | "pattern" | "list" | "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" | "css" | "block" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "step" | "size" | "icon" | "sx" | "max" | "min" | "crossOrigin" | "alt" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "autoComplete" | "loading" | "accept" | "capture" | "checked" | "enterKeyHint" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "as" | "variant" | "hasIcon" | "contrast" | "onItemSelect" | "emptyStateText" | "onFilterChange" | "tokens" | "onTokenRemove" | "tokenComponent" | "selectableItems" | "addNewTokenItem" | "onCloseOptionsList"> & React.RefAttributes<HTMLInputElement>>;
|
40
|
-
export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
|
41
|
-
export default TextInputWithTokens;
|