@primer/components 0.0.0-2021816151443 → 0.0.0-2021816212749

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/browser.esm.js +667 -621
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +301 -255
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/ActionList/Item.js +3 -3
  7. package/lib/AnchoredOverlay/AnchoredOverlay.js +2 -2
  8. package/lib/Avatar.d.ts +4 -0
  9. package/lib/Dialog/Dialog.js +4 -4
  10. package/lib/FilteredActionList/FilteredActionList.js +3 -3
  11. package/lib/Overlay.d.ts +0 -1
  12. package/lib/Overlay.js +5 -10
  13. package/lib/SelectMenu/SelectMenu.d.ts +11 -327
  14. package/lib/SelectMenu/SelectMenuFilter.d.ts +1 -1
  15. package/lib/TextInput.d.ts +6 -6
  16. package/lib/TextInput.js +21 -16
  17. package/lib/Timeline.js +12 -15
  18. package/lib/hooks/useOverlay.d.ts +1 -2
  19. package/lib/hooks/useOverlay.js +6 -11
  20. package/lib/index.d.ts +1 -0
  21. package/lib/index.js +14 -0
  22. package/lib/theme-preval.js +1705 -1957
  23. package/lib/utils/ssr.d.ts +1 -0
  24. package/lib/utils/ssr.js +19 -0
  25. package/lib/utils/testing.d.ts +2431 -2929
  26. package/lib/utils/uniqueId.js +1 -0
  27. package/lib-esm/ActionList/Item.js +4 -4
  28. package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -3
  29. package/lib-esm/Avatar.d.ts +4 -0
  30. package/lib-esm/Dialog/Dialog.js +3 -3
  31. package/lib-esm/FilteredActionList/FilteredActionList.js +3 -3
  32. package/lib-esm/Overlay.d.ts +0 -1
  33. package/lib-esm/Overlay.js +5 -8
  34. package/lib-esm/SelectMenu/SelectMenu.d.ts +11 -327
  35. package/lib-esm/SelectMenu/SelectMenuFilter.d.ts +1 -1
  36. package/lib-esm/TextInput.d.ts +6 -6
  37. package/lib-esm/TextInput.js +22 -16
  38. package/lib-esm/Timeline.js +8 -13
  39. package/lib-esm/hooks/useOverlay.d.ts +1 -2
  40. package/lib-esm/hooks/useOverlay.js +6 -11
  41. package/lib-esm/index.d.ts +1 -0
  42. package/lib-esm/index.js +2 -1
  43. package/lib-esm/theme-preval.js +1705 -1957
  44. package/lib-esm/utils/ssr.d.ts +1 -0
  45. package/lib-esm/utils/ssr.js +1 -0
  46. package/lib-esm/utils/testing.d.ts +2431 -2929
  47. package/lib-esm/utils/uniqueId.js +1 -0
  48. package/package.json +5 -7
  49. package/lib/Autocomplete/Autocomplete.d.ts +0 -8
  50. package/lib/Autocomplete/Autocomplete.js +0 -49
  51. package/lib/Autocomplete/AutocompleteContext.d.ts +0 -13
  52. package/lib/Autocomplete/AutocompleteContext.js +0 -11
  53. package/lib/Autocomplete/AutocompleteInput.d.ts +0 -7
  54. package/lib/Autocomplete/AutocompleteInput.js +0 -78
  55. package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -19
  56. package/lib/Autocomplete/AutocompleteMenu.js +0 -226
  57. package/lib/Badge/Badge.d.ts +0 -8
  58. package/lib/Badge/Badge.js +0 -59
  59. package/lib/Badge/BadgeState.d.ts +0 -13
  60. package/lib/Badge/BadgeState.js +0 -51
  61. package/lib/Badge/_badgeStyleUtils.d.ts +0 -3
  62. package/lib/Badge/_badgeStyleUtils.js +0 -39
  63. package/lib/TextInputTokens.d.ts +0 -32
  64. package/lib/TextInputTokens.js +0 -225
  65. package/lib/TextInputWithTokens.d.ts +0 -41
  66. package/lib/TextInputWithTokens.js +0 -396
  67. package/lib/Token/Token.d.ts +0 -7
  68. package/lib/Token/Token.js +0 -66
  69. package/lib/Token/TokenBase.d.ts +0 -16
  70. package/lib/Token/TokenBase.js +0 -76
  71. package/lib/Token/TokenLabel.d.ts +0 -8
  72. package/lib/Token/TokenLabel.js +0 -116
  73. package/lib/Token/TokenProfile.d.ts +0 -7
  74. package/lib/Token/TokenProfile.js +0 -45
  75. package/lib/Token/_AddTokenButton.d.ts +0 -3
  76. package/lib/Token/_AddTokenButton.js +0 -42
  77. package/lib/Token/_RemoveTokenButton.d.ts +0 -3
  78. package/lib/Token/_RemoveTokenButton.js +0 -42
  79. package/lib/Token/_tokenButtonUtils.d.ts +0 -8
  80. package/lib/Token/_tokenButtonUtils.js +0 -42
  81. package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -8
  82. package/lib-esm/Autocomplete/Autocomplete.js +0 -36
  83. package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -13
  84. package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
  85. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -7
  86. package/lib-esm/Autocomplete/AutocompleteInput.js +0 -59
  87. package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -19
  88. package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -203
  89. package/lib-esm/Badge/Badge.d.ts +0 -8
  90. package/lib-esm/Badge/Badge.js +0 -44
  91. package/lib-esm/Badge/BadgeState.d.ts +0 -13
  92. package/lib-esm/Badge/BadgeState.js +0 -40
  93. package/lib-esm/Badge/_badgeStyleUtils.d.ts +0 -3
  94. package/lib-esm/Badge/_badgeStyleUtils.js +0 -29
  95. package/lib-esm/TextInputTokens.d.ts +0 -32
  96. package/lib-esm/TextInputTokens.js +0 -195
  97. package/lib-esm/TextInputWithTokens.d.ts +0 -41
  98. package/lib-esm/TextInputWithTokens.js +0 -361
  99. package/lib-esm/Token/Token.d.ts +0 -7
  100. package/lib-esm/Token/Token.js +0 -46
  101. package/lib-esm/Token/TokenBase.d.ts +0 -16
  102. package/lib-esm/Token/TokenBase.js +0 -56
  103. package/lib-esm/Token/TokenLabel.d.ts +0 -8
  104. package/lib-esm/Token/TokenLabel.js +0 -100
  105. package/lib-esm/Token/TokenProfile.d.ts +0 -7
  106. package/lib-esm/Token/TokenProfile.js +0 -28
  107. package/lib-esm/Token/_AddTokenButton.d.ts +0 -3
  108. package/lib-esm/Token/_AddTokenButton.js +0 -27
  109. package/lib-esm/Token/_RemoveTokenButton.d.ts +0 -3
  110. package/lib-esm/Token/_RemoveTokenButton.js +0 -27
  111. package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -8
  112. package/lib-esm/Token/_tokenButtonUtils.js +0 -26
@@ -1,8 +0,0 @@
1
- import { BadgeSizeKeys } from './_badgeStyleUtils';
2
- declare type BadgeColorOptions = 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'danger';
3
- interface Props {
4
- color?: BadgeColorOptions;
5
- variant?: BadgeSizeKeys;
6
- }
7
- declare const Badge: import("styled-components").StyledComponent<"span", any, Props, never>;
8
- export default Badge;
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _constants = require("../constants");
11
-
12
- var _badgeStyleUtils = require("./_badgeStyleUtils");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- const badgeColorMap = {
17
- default: {
18
- borderColor: (0, _constants.get)('colors.border.default')
19
- },
20
- primary: {
21
- borderColor: (0, _constants.get)('colors.fg.default')
22
- },
23
- secondary: {
24
- borderColor: (0, _constants.get)('colors.border.muted'),
25
- textColor: (0, _constants.get)('colors.fg.muted')
26
- },
27
- info: {
28
- borderColor: (0, _constants.get)('colors.accent.fg'),
29
- textColor: (0, _constants.get)('colors.accent.fg')
30
- },
31
- success: {
32
- borderColor: (0, _constants.get)('colors.success.fg'),
33
- textColor: (0, _constants.get)('colors.success.emphasis')
34
- },
35
- warning: {
36
- borderColor: (0, _constants.get)('colors.attention.fg'),
37
- textColor: (0, _constants.get)('colors.attention.emphasis')
38
- },
39
- danger: {
40
- borderColor: (0, _constants.get)('colors.danger.fg'),
41
- textColor: (0, _constants.get)('colors.danger.emphasis')
42
- }
43
- };
44
-
45
- const Badge = _styledComponents.default.span.withConfig({
46
- displayName: "Badge",
47
- componentId: "sc-15t9m5z-0"
48
- })(["align-items:center;background-color:transparent;border-width:1px;border-radius:999px;border-style:solid;border-color:", ";color:", ";display:inline-flex;font-weight:", ";line-height:1;white-space:nowrap;", ";"], ({
49
- color = 'default'
50
- }) => badgeColorMap[color].borderColor, ({
51
- color = 'default'
52
- }) => badgeColorMap[color].textColor, (0, _constants.get)('fontWeights.bold'), _badgeStyleUtils.badgeVariants);
53
-
54
- Badge.defaultProps = {
55
- variant: 'sm',
56
- color: 'default'
57
- };
58
- var _default = Badge;
59
- exports.default = _default;
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import { IconProps } from '@primer/octicons-react';
3
- import { BadgeSizeKeys } from './_badgeStyleUtils';
4
- declare type BadgeStateColorOptions = 'default' | 'open' | 'merged' | 'closed';
5
- interface Props {
6
- color?: BadgeStateColorOptions;
7
- icon?: React.ComponentType<{
8
- size?: IconProps['size'];
9
- }>;
10
- variant?: BadgeSizeKeys;
11
- }
12
- declare const BadgeState: React.FC<Props>;
13
- export default BadgeState;
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _constants = require("../constants");
11
-
12
- var _badgeStyleUtils = require("./_badgeStyleUtils");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- 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); }
17
-
18
- const badgeStateColorMap = {
19
- default: (0, _constants.get)('colors.neutral.emphasis'),
20
- open: (0, _constants.get)('colors.success.emphasis'),
21
- merged: (0, _constants.get)('colors.done.emphasis'),
22
- closed: (0, _constants.get)('colors.danger.emphasis')
23
- }; // const badgeStateIconSizeMap: Record<BadgeSizeKeys, number> = {
24
- // 'sm':
25
- // };
26
-
27
- const StyledBadgeState = _styledComponents.default.span.withConfig({
28
- displayName: "BadgeState__StyledBadgeState",
29
- componentId: "sc-5hwzjt-0"
30
- })(["align-items:center;background-color:", ";border-radius:999px;color:", ";display:inline-flex;font-weight:", ";gap:", ";line-height:1;white-space:nowrap;", ";"], ({
31
- color = 'default'
32
- }) => badgeStateColorMap[color], (0, _constants.get)('colors.fg.onEmphasis'), (0, _constants.get)('fontWeights.bold'), (0, _constants.get)('space.1'), _badgeStyleUtils.badgeVariants);
33
-
34
- const BadgeState = ({
35
- children,
36
- icon: IconComponent,
37
- variant,
38
- ...rest
39
- }) => /*#__PURE__*/React.createElement(StyledBadgeState, _extends({
40
- variant: variant
41
- }, rest), IconComponent ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconComponent, {
42
- size: variant === 'sm' ? 12 : 'small'
43
- }), children) : children);
44
-
45
- BadgeState.displayName = "BadgeState";
46
- BadgeState.defaultProps = {
47
- variant: 'lg',
48
- color: 'default'
49
- };
50
- var _default = BadgeState;
51
- exports.default = _default;
@@ -1,3 +0,0 @@
1
- export declare type BadgeSizeKeys = 'sm' | 'md' | 'lg';
2
- export declare const badgeSizes: Record<BadgeSizeKeys, number>;
3
- export declare const badgeVariants: (...args: any[]) => any;
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.badgeVariants = exports.badgeSizes = void 0;
7
-
8
- var _styledSystem = require("styled-system");
9
-
10
- // TODO: consider moving to Primitives
11
- const badgeSizes = {
12
- sm: 20,
13
- md: 24,
14
- lg: 32
15
- };
16
- exports.badgeSizes = badgeSizes;
17
- const badgeVariants = (0, _styledSystem.variant)({
18
- variants: {
19
- sm: {
20
- fontSize: 0,
21
- height: `${badgeSizes.sm}px`,
22
- paddingLeft: 2,
23
- paddingRight: 2
24
- },
25
- md: {
26
- fontSize: 0,
27
- height: `${badgeSizes.md}px`,
28
- paddingLeft: 2,
29
- paddingRight: 2
30
- },
31
- lg: {
32
- fontSize: 1,
33
- height: `${badgeSizes.lg}px`,
34
- paddingLeft: 3,
35
- paddingRight: 3
36
- }
37
- }
38
- });
39
- exports.badgeVariants = badgeVariants;
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { MaxWidthProps, MinWidthProps, WidthProps } from 'styled-system';
3
- import { SystemCommonProps } from './constants';
4
- import { SxProp } from './sx';
5
- import { ComponentProps } from './utils/types';
6
- import Token from './Token/Token';
7
- declare const Input: import("styled-components").StyledComponent<"input", any, {}, never>;
8
- declare const Wrapper: import("styled-components").StyledComponent<"span", any, {
9
- disabled?: boolean | undefined;
10
- hasIcon?: boolean | undefined;
11
- block?: boolean | undefined;
12
- contrast?: boolean | undefined;
13
- variant?: "large" | "small" | undefined;
14
- maxHeight?: React.CSSProperties['maxHeight'];
15
- } & 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>;
16
- interface Token {
17
- text?: string;
18
- id: string | number;
19
- }
20
- declare type TextInputWithTokensInternalProps = {
21
- as?: any;
22
- icon?: React.ComponentType<{
23
- className?: string;
24
- }>;
25
- tokens: Token[];
26
- onTokenRemove: (tokenId: string | number) => void;
27
- tokenComponent?: React.FunctionComponent<any>;
28
- maxHeight?: React.CSSProperties['maxHeight'];
29
- } & ComponentProps<typeof Wrapper> & ComponentProps<typeof Input>;
30
- 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" | "tokens" | "onTokenRemove" | "tokenComponent"> & React.RefAttributes<HTMLInputElement>>;
31
- export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
32
- export default TextInputWithTokens;
@@ -1,225 +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 _props = require("@styled-system/props");
11
-
12
- var _classnames = _interopRequireDefault(require("classnames"));
13
-
14
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
15
-
16
- var _styledSystem = require("styled-system");
17
-
18
- var _focusZone = require("./behaviors/focusZone");
19
-
20
- var _constants = require("./constants");
21
-
22
- var _useCombinedRefs = require("./hooks/useCombinedRefs");
23
-
24
- var _useFocusZone = require("./hooks/useFocusZone");
25
-
26
- var _sx = _interopRequireDefault(require("./sx"));
27
-
28
- var _Token = _interopRequireDefault(require("./Token/Token"));
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- 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
-
34
- 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; }
35
-
36
- 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); }
37
-
38
- const sizeVariants = (0, _styledSystem.variant)({
39
- variants: {
40
- small: {
41
- minHeight: '28px',
42
- px: 2,
43
- py: '3px',
44
- fontSize: 0,
45
- lineHeight: '20px'
46
- },
47
- large: {
48
- px: 2,
49
- py: '10px',
50
- fontSize: 3
51
- }
52
- }
53
- });
54
-
55
- const Input = _styledComponents.default.input.withConfig({
56
- displayName: "TextInputTokens__Input",
57
- componentId: "sc-1k54xiz-0"
58
- })(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;height:100%;width:100%;padding:0;&:focus{outline:0;}"]);
59
-
60
- const InputWrapper = _styledComponents.default.div.withConfig({
61
- displayName: "TextInputTokens__InputWrapper",
62
- componentId: "sc-1k54xiz-1"
63
- })(["position:relative;order:1;flex-grow:1;&:after{content:attr(data-autocompleteSuggestion);pointer-events:none;display:flex;align-items:center;position:absolute;left:0;top:1px;width:100%;height:100%;display:flex;align-items:center;color:rgba(0,0,0,0.5);}"]);
64
-
65
- const Wrapper = _styledComponents.default.span.withConfig({
66
- displayName: "TextInputTokens__Wrapper",
67
- componentId: "sc-1k54xiz-2"
68
- })(["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:", ";flex-wrap:wrap;gap:0.25rem;", " ", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.text.primary'), (0, _constants.get)('colors.border.primary'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.shadow.inset'), props => {
69
- if (props.hasIcon) {
70
- return (0, _styledComponents.css)(["padding:0;"]);
71
- } else {
72
- return (0, _styledComponents.css)(["padding:6px 12px;"]);
73
- }
74
- }, props => {
75
- if (props.maxHeight) {
76
- return (0, _styledComponents.css)(["max-height:", ";overflow:auto;"], props.maxHeight);
77
- }
78
- }, (0, _constants.get)('colors.icon.tertiary'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.state.focus.border'), (0, _constants.get)('shadows.state.focus.shadow'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.input.contrastBg')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.text.secondary'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.input.disabledBorder')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _constants.COMMON, _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
79
-
80
- // using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
81
- const TextInputWithTokens = /*#__PURE__*/_react.default.forwardRef(({
82
- icon: IconComponent,
83
- contrast,
84
- className,
85
- block,
86
- disabled,
87
- theme,
88
- sx: sxProp,
89
- tokens,
90
- onTokenRemove,
91
- tokenComponent: TokenComponent,
92
- ...rest
93
- }, ref) => {
94
- const localInputRef = (0, _react.useRef)(null);
95
- const combinedInputRef = (0, _useCombinedRefs.useCombinedRefs)(localInputRef, ref); // this class is necessary to style FilterSearch, plz no touchy!
96
-
97
- const wrapperClasses = (0, _classnames.default)(className, 'TextInput-wrapper');
98
- const wrapperProps = (0, _props.pick)(rest);
99
- const {
100
- onChange,
101
- onFocus,
102
- onKeyDown,
103
- value,
104
- ...inputPropsRest
105
- } = (0, _props.omit)(rest);
106
- const [selectedTokenIdx, setSelectedTokenIdx] = (0, _react.useState)();
107
- const [inputVal, setInputVal] = (0, _react.useState)(value);
108
- const [autocompleteSuggestion, setAutocompleteSuggestion] = (0, _react.useState)('');
109
- const {
110
- containerRef
111
- } = (0, _useFocusZone.useFocusZone)({
112
- focusOutBehavior: 'wrap',
113
- bindKeys: _focusZone.FocusKeys.ArrowHorizontal | _focusZone.FocusKeys.HomeAndEnd,
114
- focusableElementFilter: element => {
115
- return !(element instanceof HTMLButtonElement);
116
- }
117
- });
118
-
119
- const handleTokenRemove = tokenId => {
120
- onTokenRemove(tokenId);
121
- };
122
-
123
- const handleTokenFocus = tokenIdx => () => {
124
- setSelectedTokenIdx(tokenIdx);
125
- };
126
-
127
- const handleTokenBlur = () => {
128
- setSelectedTokenIdx(undefined);
129
- };
130
-
131
- const handleTokenKeyUp = tokenId => e => {
132
- if (e.key === 'Backspace') {
133
- handleTokenRemove(tokenId);
134
- }
135
-
136
- if (e.key === 'Escape') {
137
- var _combinedInputRef$cur;
138
-
139
- combinedInputRef === null || combinedInputRef === void 0 ? void 0 : (_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
140
- }
141
- };
142
-
143
- const handleInputFocus = e => {
144
- if (onFocus) {
145
- onFocus(e);
146
- }
147
-
148
- setSelectedTokenIdx(undefined);
149
- };
150
-
151
- const handleInputChange = e => {
152
- if (onChange) {
153
- onChange(e);
154
- }
155
-
156
- setInputVal(e.currentTarget.value);
157
- };
158
-
159
- const handleInputKeyDown = e => {
160
- if (onKeyDown) {
161
- onKeyDown(e);
162
- }
163
-
164
- if (inputVal) {
165
- return;
166
- }
167
-
168
- const lastToken = tokens[tokens.length - 1];
169
-
170
- if (e.key === 'Backspace') {
171
- handleTokenRemove(lastToken.id); // HACK: adding an extra space so that when I backspace, it doesn't delete the last letter
172
-
173
- setInputVal(`${lastToken.text} ` || ' '); // TODO: use hooks or something to always trigger `onFilterChange` when `inputVal` is changed
174
- // onFilterChange(lastToken.text || '', e);
175
- // HACK: for some reason we need to wait a tick for `.select()` to work
176
-
177
- setTimeout(() => {
178
- var _combinedInputRef$cur2;
179
-
180
- combinedInputRef === null || combinedInputRef === void 0 ? void 0 : (_combinedInputRef$cur2 = combinedInputRef.current) === null || _combinedInputRef$cur2 === void 0 ? void 0 : _combinedInputRef$cur2.select();
181
- }, 1);
182
- }
183
- };
184
-
185
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Wrapper, _extends({
186
- className: wrapperClasses,
187
- hasIcon: !!IconComponent,
188
- block: block,
189
- theme: theme,
190
- disabled: disabled,
191
- contrast: contrast,
192
- sx: sxProp,
193
- ref: containerRef
194
- }, wrapperProps), /*#__PURE__*/_react.default.createElement(InputWrapper, {
195
- "data-autocompleteSuggestion": autocompleteSuggestion
196
- }, /*#__PURE__*/_react.default.createElement(Input, _extends({
197
- ref: combinedInputRef,
198
- disabled: disabled,
199
- onFocus: handleInputFocus,
200
- onKeyDown: handleInputKeyDown,
201
- onChange: handleInputChange,
202
- type: "text",
203
- value: inputVal
204
- }, inputPropsRest))), tokens !== null && tokens !== void 0 && tokens.length && TokenComponent ? tokens.map((token, i) => /*#__PURE__*/_react.default.createElement(TokenComponent, {
205
- onFocus: handleTokenFocus(i),
206
- onBlur: handleTokenBlur,
207
- onKeyUp: handleTokenKeyUp(token.id),
208
- text: token.text || '' // TODO: just make token.text required
209
- ,
210
- isSelected: selectedTokenIdx === i,
211
- handleRemove: () => {
212
- handleTokenRemove(token.id);
213
- },
214
- variant: "xl",
215
- fillColor: token.labelColor ? token.labelColor : undefined,
216
- tabIndex: 0
217
- })) : null));
218
- });
219
-
220
- TextInputWithTokens.defaultProps = {
221
- tokenComponent: _Token.default
222
- };
223
- TextInputWithTokens.displayName = 'TextInputWithTokens';
224
- var _default = TextInputWithTokens;
225
- exports.default = _default;
@@ -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" | "onFilterChange" | "tokens" | "onTokenRemove" | "tokenComponent" | "selectableItems" | "onItemSelect" | "emptyStateText" | "addNewTokenItem" | "onCloseOptionsList"> & React.RefAttributes<HTMLInputElement>>;
40
- export declare type TextInputWithTokensProps = ComponentProps<typeof TextInputWithTokens>;
41
- export default TextInputWithTokens;