@primer/components 0.0.0-202195193757 → 0.0.0-202195195659

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/browser.esm.js +93 -74
  3. package/dist/browser.esm.js.map +1 -1
  4. package/dist/browser.umd.js +85 -66
  5. package/dist/browser.umd.js.map +1 -1
  6. package/lib/Autocomplete/AutocompleteInput.d.ts +1 -1
  7. package/lib/Autocomplete/AutocompleteInput.js +12 -12
  8. package/lib/Autocomplete/AutocompleteMenu.js +4 -6
  9. package/lib/Autocomplete/AutocompleteOverlay.js +1 -1
  10. package/lib/Autocomplete/index.d.ts +1 -1
  11. package/lib/TextInput.d.ts +1 -1
  12. package/lib/TextInputWithTokens.d.ts +298 -16
  13. package/lib/TextInputWithTokens.js +34 -26
  14. package/lib/Token/IssueLabelToken.d.ts +14 -0
  15. package/lib/Token/{TokenLabel.js → IssueLabelToken.js} +35 -28
  16. package/lib/Token/{TokenProfile.d.ts → ProfileToken.d.ts} +3 -3
  17. package/lib/Token/{TokenProfile.js → ProfileToken.js} +7 -7
  18. package/lib/Token/Token.d.ts +2 -2
  19. package/lib/Token/Token.js +34 -22
  20. package/lib/Token/TokenBase.d.ts +5 -5
  21. package/lib/Token/TokenBase.js +41 -25
  22. package/lib/Token/_RemoveTokenButton.d.ts +11 -2
  23. package/lib/Token/_RemoveTokenButton.js +53 -22
  24. package/lib/Token/_TokenTextContainer.d.ts +3 -0
  25. package/lib/Token/_TokenTextContainer.js +34 -0
  26. package/lib/Token/index.d.ts +2 -2
  27. package/lib/Token/index.js +6 -6
  28. package/lib/index.d.ts +1 -1
  29. package/lib/index.js +4 -4
  30. package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -1
  31. package/lib-esm/Autocomplete/AutocompleteInput.js +12 -12
  32. package/lib-esm/Autocomplete/AutocompleteMenu.js +4 -6
  33. package/lib-esm/Autocomplete/AutocompleteOverlay.js +1 -1
  34. package/lib-esm/Autocomplete/index.d.ts +1 -1
  35. package/lib-esm/TextInput.d.ts +1 -1
  36. package/lib-esm/TextInputWithTokens.d.ts +298 -16
  37. package/lib-esm/TextInputWithTokens.js +34 -26
  38. package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
  39. package/lib-esm/Token/{TokenLabel.js → IssueLabelToken.js} +34 -28
  40. package/lib-esm/Token/{TokenProfile.d.ts → ProfileToken.d.ts} +3 -3
  41. package/lib-esm/Token/{TokenProfile.js → ProfileToken.js} +7 -7
  42. package/lib-esm/Token/Token.d.ts +2 -2
  43. package/lib-esm/Token/Token.js +33 -22
  44. package/lib-esm/Token/TokenBase.d.ts +5 -5
  45. package/lib-esm/Token/TokenBase.js +41 -25
  46. package/lib-esm/Token/_RemoveTokenButton.d.ts +11 -2
  47. package/lib-esm/Token/_RemoveTokenButton.js +52 -22
  48. package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
  49. package/lib-esm/Token/_TokenTextContainer.js +21 -0
  50. package/lib-esm/Token/index.d.ts +2 -2
  51. package/lib-esm/Token/index.js +2 -2
  52. package/lib-esm/_UnstyledTextInput.js +1 -1
  53. package/lib-esm/index.d.ts +1 -1
  54. package/lib-esm/index.js +1 -1
  55. package/package.json +1 -1
  56. package/lib/Token/TokenLabel.d.ts +0 -14
  57. package/lib/Token/_tokenButtonUtils.d.ts +0 -10
  58. package/lib/Token/_tokenButtonUtils.js +0 -42
  59. package/lib-esm/Token/TokenLabel.d.ts +0 -14
  60. package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -10
  61. package/lib-esm/Token/_tokenButtonUtils.js +0 -26
@@ -6,6 +6,7 @@ import TokenBase, { isTokenInteractive } from './TokenBase';
6
6
  import RemoveTokenButton from './_RemoveTokenButton';
7
7
  import tinycolor from 'tinycolor2';
8
8
  import { useTheme } from '../ThemeProvider';
9
+ import TokenTextContainer from './_TokenTextContainer';
9
10
  const colorModeConfigs = {
10
11
  dark: {
11
12
  bgOpacity: 0.18,
@@ -21,31 +22,34 @@ const colorModeConfigs = {
21
22
  }
22
23
  };
23
24
  const tokenBorderWidthPx = 1;
24
- const StyledTokenLabel = styled(TokenBase).withConfig({
25
- displayName: "TokenLabel__StyledTokenLabel",
26
- componentId: "sc-1bdmgzv-0"
25
+ const StyledIssueLabelToken = styled(TokenBase).withConfig({
26
+ displayName: "IssueLabelToken__StyledIssueLabelToken",
27
+ componentId: "j8tie2-0"
27
28
  })(["background-color:", ";border-width:", "px;border-style:solid;border-color:", ";color:", ";padding-right:", ";position:relative;", ""], props => props.bgColor, tokenBorderWidthPx, props => props.borderColor, props => props.textColor, props => !props.hideRemoveButton ? 0 : undefined, props => {
28
29
  if (props.isSelected) {
29
30
  return css(["&:after{content:'';position:absolute;z-index:1;top:-2px;right:-2px;bottom:-2px;left:-2px;display:block;pointer-events:none;box-shadow:0 0 0 2px ", ";border-radius:999px;}"], props.bgColor);
30
31
  }
31
32
  });
32
- const TokenTextContainer = styled('span').withConfig({
33
- displayName: "TokenLabel__TokenTextContainer",
34
- componentId: "sc-1bdmgzv-1"
35
- })(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
36
- const TokenLabel = /*#__PURE__*/forwardRef((props, forwardedRef) => {
33
+ const IssueLabelToken = /*#__PURE__*/forwardRef((props, forwardedRef) => {
37
34
  const {
38
35
  as,
39
36
  fillColor,
40
- handleRemove,
37
+ onRemove,
41
38
  id,
42
39
  isSelected,
43
40
  ref,
44
41
  text,
45
- variant,
42
+ size,
46
43
  hideRemoveButton,
44
+ href,
45
+ onClick,
47
46
  ...rest
48
47
  } = props;
48
+ const interactiveTokenProps = {
49
+ as,
50
+ href,
51
+ onClick
52
+ };
49
53
  const {
50
54
  colorScheme
51
55
  } = useTheme();
@@ -75,47 +79,49 @@ const TokenLabel = /*#__PURE__*/forwardRef((props, forwardedRef) => {
75
79
  }
76
80
 
77
81
  if (isSelected) {
78
- bgColor = isFillColorDark ? tinycolor(fillColor).lighten(10).toString() // TODO: darken more than 10 if the fillColor is really bright and doesn't darken well
82
+ bgColor = isFillColorDark ? tinycolor(fillColor).lighten(10).toString() : // TODO: darken more than 10 if the fillColor is really bright and doesn't darken well
79
83
  // Examples of colors that don't darken well:
80
84
  // - #a2eeef
81
85
  // - #ffd78e
82
86
  // - #a4f287
83
- : tinycolor(fillColor).darken(10).toString();
87
+ tinycolor(fillColor).darken(10).toString();
84
88
  }
85
89
  }
86
90
 
87
- const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(handleRemove) && !hideRemoveButton;
91
+ const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
88
92
 
89
- const handleRemoveClick = e => {
93
+ const onRemoveClick = e => {
90
94
  e.stopPropagation();
91
- handleRemove && handleRemove();
95
+ onRemove && onRemove();
92
96
  };
93
97
 
94
- return /*#__PURE__*/React.createElement(StyledTokenLabel // specific to labels
98
+ return /*#__PURE__*/React.createElement(StyledIssueLabelToken // specific to labels
95
99
  , _extends({
96
100
  fillColor: fillColor,
97
101
  bgColor: bgColor,
98
102
  borderColor: borderColor,
99
103
  textColor: textColor // common token props
100
104
  ,
101
- as: as,
102
- hideRemoveButton: hideRemoveButton || !handleRemove,
103
- handleRemove: handleRemove,
105
+ hideRemoveButton: hideRemoveButton || !onRemove,
106
+ onRemove: onRemove,
104
107
  id: id === null || id === void 0 ? void 0 : id.toString(),
105
108
  isSelected: isSelected,
106
109
  ref: forwardedRef,
107
110
  text: text,
108
- variant: variant
109
- }, rest), /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton && handleRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
111
+ size: size
112
+ }, !hasMultipleActionTargets ? interactiveTokenProps : {}, rest), /*#__PURE__*/React.createElement(TokenTextContainer, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
110
113
  borderOffset: tokenBorderWidthPx,
111
- parentTokenTag: as || 'span',
112
- tabIndex: -1,
113
- onClick: handleRemoveClick,
114
- variant: variant,
115
- "aria-hidden": hasMultipleActionTargets ? "true" : "false"
114
+ onClick: onRemoveClick,
115
+ size: size,
116
+ "aria-hidden": hasMultipleActionTargets ? 'true' : 'false',
117
+ isParentInteractive: isTokenInteractive(props),
118
+ sx: hasMultipleActionTargets ? {
119
+ position: 'relative',
120
+ zIndex: '1'
121
+ } : {}
116
122
  }) : null);
117
123
  });
118
- TokenLabel.defaultProps = {
124
+ IssueLabelToken.defaultProps = {
119
125
  fillColor: '#999'
120
126
  };
121
- export default TokenLabel;
127
+ export default IssueLabelToken;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TokenBaseProps } from './TokenBase';
3
- export interface TokenProfileProps extends TokenBaseProps {
3
+ export interface ProfileTokenProps extends TokenBaseProps {
4
4
  avatarSrc: string;
5
5
  }
6
- declare const TokenProfile: React.ForwardRefExoticComponent<Pick<TokenProfileProps, "sizes" | "color" | "content" | "height" | "translate" | "width" | "hidden" | "children" | "value" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "text" | "list" | "default" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "start" | "step" | "wrap" | "open" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "href" | "classID" | "useMap" | "wmode" | "download" | "hrefLang" | "rel" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "integrity" | "charSet" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "kind" | "srcLang" | "poster" | "variant" | "handleRemove" | "isSelected" | "avatarSrc"> & React.RefAttributes<HTMLElement>>;
7
- export default TokenProfile;
6
+ declare const ProfileToken: React.ForwardRefExoticComponent<Pick<ProfileTokenProps, "sizes" | "color" | "content" | "height" | "translate" | "width" | "hidden" | "children" | "value" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "text" | "list" | "default" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "start" | "step" | "size" | "wrap" | "open" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "href" | "classID" | "useMap" | "wmode" | "download" | "hrefLang" | "rel" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "integrity" | "charSet" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "kind" | "srcLang" | "poster" | "onRemove" | "isSelected" | "avatarSrc"> & React.RefAttributes<HTMLElement>>;
7
+ export default ProfileToken;
@@ -8,22 +8,22 @@ import { defaultTokenSize, tokenSizes } from './TokenBase';
8
8
  import Token from './Token';
9
9
  import { Avatar } from '..';
10
10
  const StyledToken = styled(Token).withConfig({
11
- displayName: "TokenProfile__StyledToken",
12
- componentId: "sc-1vf9jhf-0"
11
+ displayName: "ProfileToken__StyledToken",
12
+ componentId: "sg4u2f-0"
13
13
  })(["padding-left:", ";"], get('space.1'));
14
- const TokenProfile = /*#__PURE__*/forwardRef(({
14
+ const ProfileToken = /*#__PURE__*/forwardRef(({
15
15
  avatarSrc,
16
16
  id,
17
17
  ref,
18
- variant,
18
+ size,
19
19
  ...rest
20
20
  }, forwardedRef) => /*#__PURE__*/React.createElement(StyledToken, _extends({
21
21
  leadingVisual: () => /*#__PURE__*/React.createElement(Avatar, {
22
22
  src: avatarSrc,
23
- size: tokenSizes[variant || defaultTokenSize] - parseInt(primitives.spacing.normal.spacer[1], 10) * 2
23
+ size: parseInt(tokenSizes[size || defaultTokenSize], 10) - parseInt(primitives.spacing.normal.spacer[1], 10) * 2
24
24
  }),
25
- variant: variant,
25
+ size: size,
26
26
  id: id === null || id === void 0 ? void 0 : id.toString(),
27
27
  ref: forwardedRef
28
28
  }, rest)));
29
- export default TokenProfile;
29
+ export default ProfileToken;
@@ -4,11 +4,11 @@ export interface TokenProps extends TokenBaseProps {
4
4
  /**
5
5
  * A function that renders a component before the token text
6
6
  */
7
- leadingVisual?: React.FunctionComponent<any>;
7
+ leadingVisual?: React.ComponentType<any>;
8
8
  /**
9
9
  * Whether the remove button should be rendered in the token
10
10
  */
11
11
  hideRemoveButton?: boolean;
12
12
  }
13
- declare const Token: React.ForwardRefExoticComponent<Pick<TokenProps, "sizes" | "color" | "content" | "height" | "translate" | "width" | "hidden" | "children" | "value" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "text" | "list" | "default" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "start" | "step" | "wrap" | "open" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "href" | "classID" | "useMap" | "wmode" | "download" | "hrefLang" | "rel" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "integrity" | "charSet" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "kind" | "srcLang" | "poster" | "variant" | "leadingVisual" | "handleRemove" | "isSelected" | "hideRemoveButton"> & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLSpanElement>>;
13
+ declare const Token: React.ForwardRefExoticComponent<Pick<TokenProps, "sizes" | "color" | "content" | "height" | "translate" | "width" | "hidden" | "children" | "value" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "text" | "list" | "default" | "type" | "name" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "start" | "step" | "size" | "wrap" | "open" | "max" | "media" | "method" | "min" | "target" | "crossOrigin" | "href" | "classID" | "useMap" | "wmode" | "download" | "hrefLang" | "rel" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "as" | "integrity" | "charSet" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "cellPadding" | "cellSpacing" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "kind" | "srcLang" | "poster" | "leadingVisual" | "onRemove" | "isSelected" | "hideRemoveButton"> & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement | HTMLSpanElement>>;
14
14
  export default Token;
@@ -1,57 +1,68 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import React, { forwardRef } from 'react';
4
- import styled from 'styled-components';
4
+ import styled, { css } from 'styled-components';
5
5
  import { get } from '../constants';
6
6
  import TokenBase, { isTokenInteractive } from './TokenBase';
7
7
  import RemoveTokenButton from './_RemoveTokenButton';
8
+ import TokenTextContainer from './_TokenTextContainer';
8
9
  const tokenBorderWidthPx = 1;
9
10
  const DefaultTokenStyled = styled(TokenBase).withConfig({
10
11
  displayName: "Token__DefaultTokenStyled",
11
12
  componentId: "sc-1dg52pw-0"
12
- })(["background-color:", ";border-color:", ";border-style:solid;border-width:1px;color:", ";max-width:100%;padding-right:", ";&:hover{background-color:", ";box-shadow:", ";color:", ";}"], get('colors.neutral.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.border.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.fg.muted'), props => !props.hideRemoveButton ? 0 : undefined, props => isTokenInteractive(props) ? get('colors.neutral.muted') : undefined, props => isTokenInteractive(props) ? get('colors.shadow.medium') : undefined, props => isTokenInteractive(props) ? get('colors.fg.default') : undefined);
13
- const TokenTextContainer = styled('span').withConfig({
14
- displayName: "Token__TokenTextContainer",
15
- componentId: "sc-1dg52pw-1"
16
- })(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
13
+ })(["background-color:", ";border-color:", ";border-style:solid;border-width:1px;color:", ";max-width:100%;padding-right:", ";position:relative;", ""], get('colors.neutral.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.border.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.fg.muted'), props => !props.hideRemoveButton ? 0 : undefined, props => {
14
+ if (props.isTokenInteractive) {
15
+ return css(["&:hover{background-color:", ";box-shadow:", ";color:", ";}"], get('colors.neutral.muted'), get('colors.shadow.medium'), get('colors.fg.default'));
16
+ }
17
+ });
17
18
  const LeadingVisualContainer = styled('span').withConfig({
18
19
  displayName: "Token__LeadingVisualContainer",
19
- componentId: "sc-1dg52pw-2"
20
+ componentId: "sc-1dg52pw-1"
20
21
  })(["flex-shrink:0;line-height:0;"]);
21
22
  const Token = /*#__PURE__*/forwardRef((props, forwardedRef) => {
22
23
  const {
23
24
  as,
24
- handleRemove,
25
+ onRemove,
25
26
  id,
26
27
  leadingVisual: LeadingVisual,
27
28
  ref,
28
29
  text,
29
- variant,
30
+ size,
30
31
  hideRemoveButton,
32
+ href,
33
+ onClick,
31
34
  ...rest
32
35
  } = props;
33
- const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(handleRemove) && !hideRemoveButton;
36
+ const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
34
37
 
35
- const handleRemoveClick = e => {
38
+ const onRemoveClick = e => {
36
39
  e.stopPropagation();
37
- handleRemove && handleRemove();
40
+ onRemove && onRemove();
38
41
  };
39
42
 
43
+ const interactiveTokenProps = {
44
+ as,
45
+ href,
46
+ onClick
47
+ };
40
48
  return /*#__PURE__*/React.createElement(DefaultTokenStyled, _extends({
41
- as: as,
42
- handleRemove: handleRemove,
43
- hideRemoveButton: hideRemoveButton || !handleRemove,
49
+ onRemove: onRemove,
50
+ hideRemoveButton: hideRemoveButton || !onRemove,
44
51
  id: id === null || id === void 0 ? void 0 : id.toString(),
45
52
  text: text,
46
53
  ref: forwardedRef,
47
- variant: variant
48
- }, rest), LeadingVisual ? /*#__PURE__*/React.createElement(LeadingVisualContainer, null, /*#__PURE__*/React.createElement(LeadingVisual, null)) : null, /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton && handleRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
54
+ size: size,
55
+ isTokenInteractive: isTokenInteractive(props)
56
+ }, !hasMultipleActionTargets ? interactiveTokenProps : {}, rest), LeadingVisual ? /*#__PURE__*/React.createElement(LeadingVisualContainer, null, /*#__PURE__*/React.createElement(LeadingVisual, null)) : null, /*#__PURE__*/React.createElement(TokenTextContainer, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
49
57
  borderOffset: tokenBorderWidthPx,
50
- parentTokenTag: as || 'span',
51
- onClick: handleRemoveClick,
52
- variant: variant,
53
- parentTokenIsInteractive: isTokenInteractive(props),
54
- "aria-hidden": hasMultipleActionTargets ? "true" : "false"
58
+ onClick: onRemoveClick,
59
+ size: size,
60
+ isParentInteractive: isTokenInteractive(props),
61
+ "aria-hidden": hasMultipleActionTargets ? 'true' : 'false',
62
+ sx: hasMultipleActionTargets ? {
63
+ position: 'relative',
64
+ zIndex: '1'
65
+ } : {}
55
66
  }) : null);
56
67
  });
57
68
  export default Token;
@@ -1,15 +1,15 @@
1
1
  /// <reference types="react" />
2
- export declare type TokenSizeKeys = 'sm' | 'md' | 'lg' | 'xl';
3
- export declare const tokenSizes: Record<TokenSizeKeys, number>;
4
- export declare const defaultTokenSize = "md";
2
+ export declare type TokenSizeKeys = 'small' | 'medium' | 'large' | 'xlarge';
3
+ export declare const tokenSizes: Record<TokenSizeKeys, string>;
4
+ export declare const defaultTokenSize: TokenSizeKeys;
5
5
  export interface TokenBaseProps extends Omit<React.HTMLProps<HTMLSpanElement | HTMLButtonElement | HTMLAnchorElement>, 'size' | 'id'> {
6
6
  as?: 'button' | 'a' | 'span';
7
- handleRemove?: () => void;
7
+ onRemove?: () => void;
8
8
  isSelected?: boolean;
9
9
  tabIndex?: number;
10
10
  text: string;
11
11
  id?: number | string;
12
- variant?: TokenSizeKeys;
12
+ size?: TokenSizeKeys;
13
13
  }
14
14
  export declare const isTokenInteractive: ({ as, onClick, onFocus, tabIndex }: TokenBaseProps) => boolean;
15
15
  declare const TokenBase: import("styled-components").StyledComponent<"span", any, TokenBaseProps, never>;
@@ -2,12 +2,12 @@ import styled from 'styled-components';
2
2
  import { variant } from 'styled-system';
3
3
  import { get } from '../constants';
4
4
  export const tokenSizes = {
5
- sm: 16,
6
- md: 20,
7
- lg: 24,
8
- xl: 32
5
+ small: '16px',
6
+ medium: '20px',
7
+ large: '24px',
8
+ xlarge: '32px'
9
9
  };
10
- export const defaultTokenSize = 'md';
10
+ export const defaultTokenSize = 'medium';
11
11
  export const isTokenInteractive = ({
12
12
  as = 'span',
13
13
  onClick,
@@ -15,56 +15,72 @@ export const isTokenInteractive = ({
15
15
  tabIndex = -1
16
16
  }) => Boolean(onFocus || onClick || tabIndex > -1 || ['a', 'button'].includes(as));
17
17
  const variants = variant({
18
+ prop: 'size',
18
19
  variants: {
19
- sm: {
20
+ small: {
20
21
  fontSize: 0,
21
22
  gap: 1,
22
- height: `${tokenSizes.sm}px`,
23
+ height: tokenSizes.small,
24
+ // without setting lineHeight to match height, the "x" appears vertically mis-aligned
25
+ lineHeight: tokenSizes.small,
23
26
  paddingLeft: 1,
24
- paddingRight: 1
27
+ paddingRight: 1,
28
+ // need to explicitly set padding top and bottom to "0" to override default `<button>` element styles
29
+ // without setting these, the "x" appears vertically mis-aligned
30
+ paddingTop: 0,
31
+ paddingBottom: 0
25
32
  },
26
- md: {
33
+ medium: {
27
34
  fontSize: 0,
28
35
  gap: 1,
29
- height: `${tokenSizes.md}px`,
36
+ height: tokenSizes.medium,
37
+ lineHeight: tokenSizes.medium,
30
38
  paddingLeft: 2,
31
- paddingRight: 2
39
+ paddingRight: 2,
40
+ paddingTop: 0,
41
+ paddingBottom: 0
32
42
  },
33
- lg: {
43
+ large: {
34
44
  fontSize: 0,
35
45
  gap: 2,
36
- height: `${tokenSizes.lg}px`,
46
+ height: tokenSizes.large,
47
+ lineHeight: tokenSizes.large,
37
48
  paddingLeft: 2,
38
- paddingRight: 2
49
+ paddingRight: 2,
50
+ paddingTop: 0,
51
+ paddingBottom: 0
39
52
  },
40
- xl: {
53
+ xlarge: {
41
54
  fontSize: 1,
42
55
  gap: 2,
43
- height: `${tokenSizes.xl}px`,
56
+ height: tokenSizes.xlarge,
57
+ lineHeight: tokenSizes.xlarge,
44
58
  paddingLeft: 3,
45
- paddingRight: 3
59
+ paddingRight: 3,
60
+ paddingTop: 0,
61
+ paddingBottom: 0
46
62
  }
47
63
  }
48
64
  });
49
65
  const TokenBase = styled.span.attrs(({
50
66
  text,
51
- handleRemove,
52
- onKeyUp
67
+ onRemove,
68
+ onKeyDown
53
69
  }) => ({
54
- onKeyUp: e => {
55
- onKeyUp && onKeyUp(e);
70
+ onKeyDown: event => {
71
+ onKeyDown && onKeyDown(event);
56
72
 
57
- if ((e.key === 'Backspace' || e.key === 'Delete') && handleRemove) {
58
- handleRemove();
73
+ if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
74
+ onRemove();
59
75
  }
60
76
  },
61
- 'aria-label': handleRemove ? `${text}, press backspace or delete to remove` : undefined
77
+ 'aria-label': onRemove ? `${text}, press backspace or delete to remove` : undefined
62
78
  })).withConfig({
63
79
  displayName: "TokenBase",
64
80
  componentId: "opajvp-0"
65
81
  })(["align-items:center;border-radius:999px;cursor:", ";display:inline-flex;font-weight:", ";text-decoration:none;white-space:nowrap;", ""], props => isTokenInteractive(props) ? 'pointer' : 'auto', get('fontWeights.bold'), variants);
66
82
  TokenBase.defaultProps = {
67
83
  as: 'span',
68
- variant: defaultTokenSize
84
+ size: defaultTokenSize
69
85
  };
70
86
  export default TokenBase;
@@ -1,3 +1,12 @@
1
- import { TokenButtonProps } from './_tokenButtonUtils';
2
- declare const RemoveTokenButton: import("styled-components").StyledComponent<"span", any, TokenButtonProps, never>;
1
+ /// <reference types="react" />
2
+ import { SxProp } from '../sx';
3
+ import { ComponentProps } from '../utils/types';
4
+ import { TokenSizeKeys } from './TokenBase';
5
+ interface TokenButtonProps {
6
+ borderOffset?: number;
7
+ size?: TokenSizeKeys;
8
+ isParentInteractive?: boolean;
9
+ }
10
+ declare const StyledTokenButton: import("styled-components").StyledComponent<"span", any, TokenButtonProps & SxProp, never>;
11
+ declare const RemoveTokenButton: React.FC<ComponentProps<typeof StyledTokenButton>>;
3
12
  export default RemoveTokenButton;
@@ -1,29 +1,59 @@
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
+
1
3
  import { XIcon } from '@primer/octicons-react';
2
4
  import styled from 'styled-components';
3
- import { defaultTokenSize } from "./TokenBase";
4
- import { tokenButtonStyles, variants, getTokenButtonIconSize } from './_tokenButtonUtils';
5
- const RemoveTokenButton = styled.span.attrs(({
6
- borderOffset,
7
- parentTokenTag,
8
- variant,
9
- parentTokenIsInteractive,
5
+ import { variant } from 'styled-system';
6
+ import { get } from '../constants';
7
+ import sx from '../sx';
8
+ import { tokenSizes, defaultTokenSize } from './TokenBase';
9
+ const variants = variant({
10
+ prop: 'size',
11
+ variants: {
12
+ small: {
13
+ height: tokenSizes.small,
14
+ width: tokenSizes.small
15
+ },
16
+ medium: {
17
+ height: tokenSizes.medium,
18
+ width: tokenSizes.medium
19
+ },
20
+ large: {
21
+ height: tokenSizes.large,
22
+ width: tokenSizes.large
23
+ },
24
+ xlarge: {
25
+ height: tokenSizes.xlarge,
26
+ width: tokenSizes.xlarge
27
+ }
28
+ }
29
+ });
30
+
31
+ const getTokenButtonIconSize = variant => parseInt(tokenSizes[variant || defaultTokenSize], 10) * 0.75;
32
+
33
+ const StyledTokenButton = styled.span.withConfig({
34
+ displayName: "_RemoveTokenButton__StyledTokenButton",
35
+ componentId: "sc-14lvcw1-0"
36
+ })(["background-color:transparent;font-family:inherit;color:currentColor;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;user-select:none;appearance:none;text-decoration:none;padding:0;transform:", ";align-self:baseline;border:0;border-radius:999px;&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}", " ", ""], props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`, get('colors.fade.fg10'), get('colors.fade.fg15'), variants, sx);
37
+
38
+ const RemoveTokenButton = ({
39
+ 'aria-label': ariaLabel,
40
+ isParentInteractive,
41
+ size,
42
+ children,
10
43
  ...rest
11
44
  }) => {
12
- delete rest.children;
13
- return {
14
- borderOffset,
15
- as: parentTokenIsInteractive ? 'span' : 'button',
16
- tabIndex: parentTokenIsInteractive ? -1 : undefined,
17
- 'aria-label': !parentTokenIsInteractive ? 'Remove token' : undefined,
18
- children: /*#__PURE__*/React.createElement(XIcon, {
19
- size: getTokenButtonIconSize(variant)
20
- })
21
- };
22
- }).withConfig({
23
- displayName: "_RemoveTokenButton__RemoveTokenButton",
24
- componentId: "sc-14lvcw1-0"
25
- })(["", " ", " transform:", ";"], tokenButtonStyles, variants, props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`);
45
+ return /*#__PURE__*/React.createElement(StyledTokenButton, _extends({
46
+ as: isParentInteractive ? 'span' : 'button',
47
+ tabIndex: isParentInteractive ? -1 : undefined,
48
+ "aria-label": !isParentInteractive ? 'Remove token' : undefined,
49
+ size: size
50
+ }, rest), /*#__PURE__*/React.createElement(XIcon, {
51
+ size: getTokenButtonIconSize(size)
52
+ }));
53
+ };
54
+
55
+ RemoveTokenButton.displayName = "RemoveTokenButton";
26
56
  RemoveTokenButton.defaultProps = {
27
- variant: defaultTokenSize
57
+ size: defaultTokenSize
28
58
  };
29
59
  export default RemoveTokenButton;
@@ -0,0 +1,3 @@
1
+ import { TokenBaseProps } from './TokenBase';
2
+ declare const TokenTextContainer: import("styled-components").StyledComponent<"span", any, Partial<TokenBaseProps>, never>;
3
+ export default TokenTextContainer;
@@ -0,0 +1,21 @@
1
+ import styled, { css } from 'styled-components';
2
+ const TokenTextContainer = styled('span').withConfig({
3
+ displayName: "_TokenTextContainer__TokenTextContainer",
4
+ componentId: "sc-4t2bev-0"
5
+ })(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1;", ""], props => {
6
+ if (props.as === 'a') {
7
+ return css(["color:currentColor;text-decoration:none;"]);
8
+ }
9
+
10
+ if (props.as === 'button') {
11
+ // reset button styles, make the cursor a pointer, and add line-height
12
+ return css(["background:transparent;border:none;color:inherit;font:inherit;margin:0;overflow:visible;padding:0;width:auto;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-appearance:none;cursor:pointer;line-height:1;"]);
13
+ } // position psuedo-element above text content
14
+ // so it gets the click
15
+
16
+
17
+ if (props.as !== 'span') {
18
+ return css(["&:after{content:'';position:absolute;left:0;top:0;right:0;bottom:0;}"]);
19
+ }
20
+ });
21
+ export default TokenTextContainer;
@@ -1,3 +1,3 @@
1
1
  export { default } from './Token';
2
- export { default as TokenLabel } from './TokenLabel';
3
- export { default as TokenProfile } from './TokenProfile';
2
+ export { default as IssueLabelToken } from './IssueLabelToken';
3
+ export { default as ProfileToken } from './ProfileToken';
@@ -1,3 +1,3 @@
1
1
  export { default } from './Token';
2
- export { default as TokenLabel } from './TokenLabel';
3
- export { default as TokenProfile } from './TokenProfile';
2
+ export { default as IssueLabelToken } from './IssueLabelToken';
3
+ export { default as ProfileToken } from './ProfileToken';
@@ -1,4 +1,4 @@
1
- import styled from "styled-components";
1
+ import styled from 'styled-components';
2
2
  import sx from './sx';
3
3
  const UnstyledTextInput = styled.input.withConfig({
4
4
  displayName: "_UnstyledTextInput__UnstyledTextInput",