@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.
- package/CHANGELOG.md +1 -1
- package/dist/browser.esm.js +93 -74
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +85 -66
- package/dist/browser.umd.js.map +1 -1
- package/lib/Autocomplete/AutocompleteInput.d.ts +1 -1
- package/lib/Autocomplete/AutocompleteInput.js +12 -12
- package/lib/Autocomplete/AutocompleteMenu.js +4 -6
- package/lib/Autocomplete/AutocompleteOverlay.js +1 -1
- package/lib/Autocomplete/index.d.ts +1 -1
- package/lib/TextInput.d.ts +1 -1
- package/lib/TextInputWithTokens.d.ts +298 -16
- package/lib/TextInputWithTokens.js +34 -26
- package/lib/Token/IssueLabelToken.d.ts +14 -0
- package/lib/Token/{TokenLabel.js → IssueLabelToken.js} +35 -28
- package/lib/Token/{TokenProfile.d.ts → ProfileToken.d.ts} +3 -3
- package/lib/Token/{TokenProfile.js → ProfileToken.js} +7 -7
- package/lib/Token/Token.d.ts +2 -2
- package/lib/Token/Token.js +34 -22
- package/lib/Token/TokenBase.d.ts +5 -5
- package/lib/Token/TokenBase.js +41 -25
- package/lib/Token/_RemoveTokenButton.d.ts +11 -2
- package/lib/Token/_RemoveTokenButton.js +53 -22
- package/lib/Token/_TokenTextContainer.d.ts +3 -0
- package/lib/Token/_TokenTextContainer.js +34 -0
- package/lib/Token/index.d.ts +2 -2
- package/lib/Token/index.js +6 -6
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +1 -1
- package/lib-esm/Autocomplete/AutocompleteInput.js +12 -12
- package/lib-esm/Autocomplete/AutocompleteMenu.js +4 -6
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +1 -1
- package/lib-esm/Autocomplete/index.d.ts +1 -1
- package/lib-esm/TextInput.d.ts +1 -1
- package/lib-esm/TextInputWithTokens.d.ts +298 -16
- package/lib-esm/TextInputWithTokens.js +34 -26
- package/lib-esm/Token/IssueLabelToken.d.ts +14 -0
- package/lib-esm/Token/{TokenLabel.js → IssueLabelToken.js} +34 -28
- package/lib-esm/Token/{TokenProfile.d.ts → ProfileToken.d.ts} +3 -3
- package/lib-esm/Token/{TokenProfile.js → ProfileToken.js} +7 -7
- package/lib-esm/Token/Token.d.ts +2 -2
- package/lib-esm/Token/Token.js +33 -22
- package/lib-esm/Token/TokenBase.d.ts +5 -5
- package/lib-esm/Token/TokenBase.js +41 -25
- package/lib-esm/Token/_RemoveTokenButton.d.ts +11 -2
- package/lib-esm/Token/_RemoveTokenButton.js +52 -22
- package/lib-esm/Token/_TokenTextContainer.d.ts +3 -0
- package/lib-esm/Token/_TokenTextContainer.js +21 -0
- package/lib-esm/Token/index.d.ts +2 -2
- package/lib-esm/Token/index.js +2 -2
- package/lib-esm/_UnstyledTextInput.js +1 -1
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +1 -1
- package/package.json +1 -1
- package/lib/Token/TokenLabel.d.ts +0 -14
- package/lib/Token/_tokenButtonUtils.d.ts +0 -10
- package/lib/Token/_tokenButtonUtils.js +0 -42
- package/lib-esm/Token/TokenLabel.d.ts +0 -14
- package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -10
- 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
|
25
|
-
displayName: "
|
26
|
-
componentId: "
|
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
|
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
|
-
|
37
|
+
onRemove,
|
41
38
|
id,
|
42
39
|
isSelected,
|
43
40
|
ref,
|
44
41
|
text,
|
45
|
-
|
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
|
-
|
87
|
+
tinycolor(fillColor).darken(10).toString();
|
84
88
|
}
|
85
89
|
}
|
86
90
|
|
87
|
-
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(
|
91
|
+
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
|
88
92
|
|
89
|
-
const
|
93
|
+
const onRemoveClick = e => {
|
90
94
|
e.stopPropagation();
|
91
|
-
|
95
|
+
onRemove && onRemove();
|
92
96
|
};
|
93
97
|
|
94
|
-
return /*#__PURE__*/React.createElement(
|
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
|
-
|
102
|
-
|
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
|
-
|
109
|
-
}, rest), /*#__PURE__*/React.createElement(TokenTextContainer,
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
124
|
+
IssueLabelToken.defaultProps = {
|
119
125
|
fillColor: '#999'
|
120
126
|
};
|
121
|
-
export default
|
127
|
+
export default IssueLabelToken;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { TokenBaseProps } from './TokenBase';
|
3
|
-
export interface
|
3
|
+
export interface ProfileTokenProps extends TokenBaseProps {
|
4
4
|
avatarSrc: string;
|
5
5
|
}
|
6
|
-
declare const
|
7
|
-
export default
|
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: "
|
12
|
-
componentId: "
|
11
|
+
displayName: "ProfileToken__StyledToken",
|
12
|
+
componentId: "sg4u2f-0"
|
13
13
|
})(["padding-left:", ";"], get('space.1'));
|
14
|
-
const
|
14
|
+
const ProfileToken = /*#__PURE__*/forwardRef(({
|
15
15
|
avatarSrc,
|
16
16
|
id,
|
17
17
|
ref,
|
18
|
-
|
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[
|
23
|
+
size: parseInt(tokenSizes[size || defaultTokenSize], 10) - parseInt(primitives.spacing.normal.spacer[1], 10) * 2
|
24
24
|
}),
|
25
|
-
|
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
|
29
|
+
export default ProfileToken;
|
package/lib-esm/Token/Token.d.ts
CHANGED
@@ -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.
|
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" | "
|
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;
|
package/lib-esm/Token/Token.js
CHANGED
@@ -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:", "
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
})
|
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-
|
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
|
-
|
25
|
+
onRemove,
|
25
26
|
id,
|
26
27
|
leadingVisual: LeadingVisual,
|
27
28
|
ref,
|
28
29
|
text,
|
29
|
-
|
30
|
+
size,
|
30
31
|
hideRemoveButton,
|
32
|
+
href,
|
33
|
+
onClick,
|
31
34
|
...rest
|
32
35
|
} = props;
|
33
|
-
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(
|
36
|
+
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
|
34
37
|
|
35
|
-
const
|
38
|
+
const onRemoveClick = e => {
|
36
39
|
e.stopPropagation();
|
37
|
-
|
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
|
-
|
42
|
-
|
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
|
-
|
48
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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 = '
|
3
|
-
export declare const tokenSizes: Record<TokenSizeKeys,
|
4
|
-
export declare const defaultTokenSize
|
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
|
-
|
7
|
+
onRemove?: () => void;
|
8
8
|
isSelected?: boolean;
|
9
9
|
tabIndex?: number;
|
10
10
|
text: string;
|
11
11
|
id?: number | string;
|
12
|
-
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
small: '16px',
|
6
|
+
medium: '20px',
|
7
|
+
large: '24px',
|
8
|
+
xlarge: '32px'
|
9
9
|
};
|
10
|
-
export const defaultTokenSize = '
|
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
|
-
|
20
|
+
small: {
|
20
21
|
fontSize: 0,
|
21
22
|
gap: 1,
|
22
|
-
height:
|
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
|
-
|
33
|
+
medium: {
|
27
34
|
fontSize: 0,
|
28
35
|
gap: 1,
|
29
|
-
height:
|
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
|
-
|
43
|
+
large: {
|
34
44
|
fontSize: 0,
|
35
45
|
gap: 2,
|
36
|
-
height:
|
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
|
-
|
53
|
+
xlarge: {
|
41
54
|
fontSize: 1,
|
42
55
|
gap: 2,
|
43
|
-
height:
|
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
|
-
|
52
|
-
|
67
|
+
onRemove,
|
68
|
+
onKeyDown
|
53
69
|
}) => ({
|
54
|
-
|
55
|
-
|
70
|
+
onKeyDown: event => {
|
71
|
+
onKeyDown && onKeyDown(event);
|
56
72
|
|
57
|
-
if ((
|
58
|
-
|
73
|
+
if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
|
74
|
+
onRemove();
|
59
75
|
}
|
60
76
|
},
|
61
|
-
'aria-label':
|
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
|
-
|
84
|
+
size: defaultTokenSize
|
69
85
|
};
|
70
86
|
export default TokenBase;
|
@@ -1,3 +1,12 @@
|
|
1
|
-
|
2
|
-
|
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 {
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
57
|
+
size: defaultTokenSize
|
28
58
|
};
|
29
59
|
export default RemoveTokenButton;
|
@@ -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;
|
package/lib-esm/Token/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
export { default } from './Token';
|
2
|
-
export { default as
|
3
|
-
export { default as
|
2
|
+
export { default as IssueLabelToken } from './IssueLabelToken';
|
3
|
+
export { default as ProfileToken } from './ProfileToken';
|
package/lib-esm/Token/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
export { default } from './Token';
|
2
|
-
export { default as
|
3
|
-
export { default as
|
2
|
+
export { default as IssueLabelToken } from './IssueLabelToken';
|
3
|
+
export { default as ProfileToken } from './ProfileToken';
|