@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
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { TokenBaseProps } from './TokenBase';
|
3
|
+
export interface IssueLabelTokenProps extends TokenBaseProps {
|
4
|
+
/**
|
5
|
+
* The color that corresponds to the label
|
6
|
+
*/
|
7
|
+
fillColor?: string;
|
8
|
+
/**
|
9
|
+
* Whether the remove button should be rendered in the token
|
10
|
+
*/
|
11
|
+
hideRemoveButton?: boolean;
|
12
|
+
}
|
13
|
+
declare const IssueLabelToken: React.ForwardRefExoticComponent<Pick<IssueLabelTokenProps, "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" | "hideRemoveButton" | "fillColor"> & React.RefAttributes<HTMLElement>>;
|
14
|
+
export default IssueLabelToken;
|
@@ -17,6 +17,8 @@ var _tinycolor = _interopRequireDefault(require("tinycolor2"));
|
|
17
17
|
|
18
18
|
var _ThemeProvider = require("../ThemeProvider");
|
19
19
|
|
20
|
+
var _TokenTextContainer = _interopRequireDefault(require("./_TokenTextContainer"));
|
21
|
+
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
23
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -40,31 +42,34 @@ const colorModeConfigs = {
|
|
40
42
|
}
|
41
43
|
};
|
42
44
|
const tokenBorderWidthPx = 1;
|
43
|
-
const
|
44
|
-
displayName: "
|
45
|
-
componentId: "
|
45
|
+
const StyledIssueLabelToken = (0, _styledComponents.default)(_TokenBase.default).withConfig({
|
46
|
+
displayName: "IssueLabelToken__StyledIssueLabelToken",
|
47
|
+
componentId: "j8tie2-0"
|
46
48
|
})(["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 => {
|
47
49
|
if (props.isSelected) {
|
48
50
|
return (0, _styledComponents.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);
|
49
51
|
}
|
50
52
|
});
|
51
|
-
const
|
52
|
-
displayName: "TokenLabel__TokenTextContainer",
|
53
|
-
componentId: "sc-1bdmgzv-1"
|
54
|
-
})(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
|
55
|
-
const TokenLabel = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
|
53
|
+
const IssueLabelToken = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
|
56
54
|
const {
|
57
55
|
as,
|
58
56
|
fillColor,
|
59
|
-
|
57
|
+
onRemove,
|
60
58
|
id,
|
61
59
|
isSelected,
|
62
60
|
ref,
|
63
61
|
text,
|
64
|
-
|
62
|
+
size,
|
65
63
|
hideRemoveButton,
|
64
|
+
href,
|
65
|
+
onClick,
|
66
66
|
...rest
|
67
67
|
} = props;
|
68
|
+
const interactiveTokenProps = {
|
69
|
+
as,
|
70
|
+
href,
|
71
|
+
onClick
|
72
|
+
};
|
68
73
|
const {
|
69
74
|
colorScheme
|
70
75
|
} = (0, _ThemeProvider.useTheme)();
|
@@ -94,48 +99,50 @@ const TokenLabel = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) =>
|
|
94
99
|
}
|
95
100
|
|
96
101
|
if (isSelected) {
|
97
|
-
bgColor = isFillColorDark ? (0, _tinycolor.default)(fillColor).lighten(10).toString() // TODO: darken more than 10 if the fillColor is really bright and doesn't darken well
|
102
|
+
bgColor = isFillColorDark ? (0, _tinycolor.default)(fillColor).lighten(10).toString() : // TODO: darken more than 10 if the fillColor is really bright and doesn't darken well
|
98
103
|
// Examples of colors that don't darken well:
|
99
104
|
// - #a2eeef
|
100
105
|
// - #ffd78e
|
101
106
|
// - #a4f287
|
102
|
-
|
107
|
+
(0, _tinycolor.default)(fillColor).darken(10).toString();
|
103
108
|
}
|
104
109
|
}
|
105
110
|
|
106
|
-
const hasMultipleActionTargets = (0, _TokenBase.isTokenInteractive)(props) && Boolean(
|
111
|
+
const hasMultipleActionTargets = (0, _TokenBase.isTokenInteractive)(props) && Boolean(onRemove) && !hideRemoveButton;
|
107
112
|
|
108
|
-
const
|
113
|
+
const onRemoveClick = e => {
|
109
114
|
e.stopPropagation();
|
110
|
-
|
115
|
+
onRemove && onRemove();
|
111
116
|
};
|
112
117
|
|
113
|
-
return /*#__PURE__*/_react.default.createElement(
|
118
|
+
return /*#__PURE__*/_react.default.createElement(StyledIssueLabelToken // specific to labels
|
114
119
|
, _extends({
|
115
120
|
fillColor: fillColor,
|
116
121
|
bgColor: bgColor,
|
117
122
|
borderColor: borderColor,
|
118
123
|
textColor: textColor // common token props
|
119
124
|
,
|
120
|
-
|
121
|
-
|
122
|
-
handleRemove: handleRemove,
|
125
|
+
hideRemoveButton: hideRemoveButton || !onRemove,
|
126
|
+
onRemove: onRemove,
|
123
127
|
id: id === null || id === void 0 ? void 0 : id.toString(),
|
124
128
|
isSelected: isSelected,
|
125
129
|
ref: forwardedRef,
|
126
130
|
text: text,
|
127
|
-
|
128
|
-
}, rest), /*#__PURE__*/_react.default.createElement(
|
131
|
+
size: size
|
132
|
+
}, !hasMultipleActionTargets ? interactiveTokenProps : {}, rest), /*#__PURE__*/_react.default.createElement(_TokenTextContainer.default, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/_react.default.createElement(_RemoveTokenButton.default, {
|
129
133
|
borderOffset: tokenBorderWidthPx,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
134
|
+
onClick: onRemoveClick,
|
135
|
+
size: size,
|
136
|
+
"aria-hidden": hasMultipleActionTargets ? 'true' : 'false',
|
137
|
+
isParentInteractive: (0, _TokenBase.isTokenInteractive)(props),
|
138
|
+
sx: hasMultipleActionTargets ? {
|
139
|
+
position: 'relative',
|
140
|
+
zIndex: '1'
|
141
|
+
} : {}
|
135
142
|
}) : null);
|
136
143
|
});
|
137
|
-
|
144
|
+
IssueLabelToken.defaultProps = {
|
138
145
|
fillColor: '#999'
|
139
146
|
};
|
140
|
-
var _default =
|
147
|
+
var _default = IssueLabelToken;
|
141
148
|
exports.default = _default;
|
@@ -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;
|
@@ -28,23 +28,23 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
28
28
|
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); }
|
29
29
|
|
30
30
|
const StyledToken = (0, _styledComponents.default)(_Token.default).withConfig({
|
31
|
-
displayName: "
|
32
|
-
componentId: "
|
31
|
+
displayName: "ProfileToken__StyledToken",
|
32
|
+
componentId: "sg4u2f-0"
|
33
33
|
})(["padding-left:", ";"], (0, _constants.get)('space.1'));
|
34
|
-
const
|
34
|
+
const ProfileToken = /*#__PURE__*/(0, _react.forwardRef)(({
|
35
35
|
avatarSrc,
|
36
36
|
id,
|
37
37
|
ref,
|
38
|
-
|
38
|
+
size,
|
39
39
|
...rest
|
40
40
|
}, forwardedRef) => /*#__PURE__*/_react.default.createElement(StyledToken, _extends({
|
41
41
|
leadingVisual: () => /*#__PURE__*/_react.default.createElement(_.Avatar, {
|
42
42
|
src: avatarSrc,
|
43
|
-
size: _TokenBase.tokenSizes[
|
43
|
+
size: parseInt(_TokenBase.tokenSizes[size || _TokenBase.defaultTokenSize], 10) - parseInt(_primitives.default.spacing.normal.spacer[1], 10) * 2
|
44
44
|
}),
|
45
|
-
|
45
|
+
size: size,
|
46
46
|
id: id === null || id === void 0 ? void 0 : id.toString(),
|
47
47
|
ref: forwardedRef
|
48
48
|
}, rest)));
|
49
|
-
var _default =
|
49
|
+
var _default = ProfileToken;
|
50
50
|
exports.default = _default;
|
package/lib/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/Token/Token.js
CHANGED
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
-
var _styledComponents =
|
10
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
11
11
|
|
12
12
|
var _constants = require("../constants");
|
13
13
|
|
@@ -15,6 +15,8 @@ var _TokenBase = _interopRequireWildcard(require("./TokenBase"));
|
|
15
15
|
|
16
16
|
var _RemoveTokenButton = _interopRequireDefault(require("./_RemoveTokenButton"));
|
17
17
|
|
18
|
+
var _TokenTextContainer = _interopRequireDefault(require("./_TokenTextContainer"));
|
19
|
+
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
21
|
|
20
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -27,49 +29,59 @@ const tokenBorderWidthPx = 1;
|
|
27
29
|
const DefaultTokenStyled = (0, _styledComponents.default)(_TokenBase.default).withConfig({
|
28
30
|
displayName: "Token__DefaultTokenStyled",
|
29
31
|
componentId: "sc-1dg52pw-0"
|
30
|
-
})(["background-color:", ";border-color:", ";border-style:solid;border-width:1px;color:", ";max-width:100%;padding-right:", "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
})
|
32
|
+
})(["background-color:", ";border-color:", ";border-style:solid;border-width:1px;color:", ";max-width:100%;padding-right:", ";position:relative;", ""], (0, _constants.get)('colors.neutral.subtle'), props => props.isSelected ? (0, _constants.get)('colors.fg.default') : (0, _constants.get)('colors.border.subtle'), props => props.isSelected ? (0, _constants.get)('colors.fg.default') : (0, _constants.get)('colors.fg.muted'), props => !props.hideRemoveButton ? 0 : undefined, props => {
|
33
|
+
if (props.isTokenInteractive) {
|
34
|
+
return (0, _styledComponents.css)(["&:hover{background-color:", ";box-shadow:", ";color:", ";}"], (0, _constants.get)('colors.neutral.muted'), (0, _constants.get)('colors.shadow.medium'), (0, _constants.get)('colors.fg.default'));
|
35
|
+
}
|
36
|
+
});
|
35
37
|
const LeadingVisualContainer = (0, _styledComponents.default)('span').withConfig({
|
36
38
|
displayName: "Token__LeadingVisualContainer",
|
37
|
-
componentId: "sc-1dg52pw-
|
39
|
+
componentId: "sc-1dg52pw-1"
|
38
40
|
})(["flex-shrink:0;line-height:0;"]);
|
39
41
|
const Token = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
|
40
42
|
const {
|
41
43
|
as,
|
42
|
-
|
44
|
+
onRemove,
|
43
45
|
id,
|
44
46
|
leadingVisual: LeadingVisual,
|
45
47
|
ref,
|
46
48
|
text,
|
47
|
-
|
49
|
+
size,
|
48
50
|
hideRemoveButton,
|
51
|
+
href,
|
52
|
+
onClick,
|
49
53
|
...rest
|
50
54
|
} = props;
|
51
|
-
const hasMultipleActionTargets = (0, _TokenBase.isTokenInteractive)(props) && Boolean(
|
55
|
+
const hasMultipleActionTargets = (0, _TokenBase.isTokenInteractive)(props) && Boolean(onRemove) && !hideRemoveButton;
|
52
56
|
|
53
|
-
const
|
57
|
+
const onRemoveClick = e => {
|
54
58
|
e.stopPropagation();
|
55
|
-
|
59
|
+
onRemove && onRemove();
|
56
60
|
};
|
57
61
|
|
62
|
+
const interactiveTokenProps = {
|
63
|
+
as,
|
64
|
+
href,
|
65
|
+
onClick
|
66
|
+
};
|
58
67
|
return /*#__PURE__*/_react.default.createElement(DefaultTokenStyled, _extends({
|
59
|
-
|
60
|
-
|
61
|
-
hideRemoveButton: hideRemoveButton || !handleRemove,
|
68
|
+
onRemove: onRemove,
|
69
|
+
hideRemoveButton: hideRemoveButton || !onRemove,
|
62
70
|
id: id === null || id === void 0 ? void 0 : id.toString(),
|
63
71
|
text: text,
|
64
72
|
ref: forwardedRef,
|
65
|
-
|
66
|
-
|
73
|
+
size: size,
|
74
|
+
isTokenInteractive: (0, _TokenBase.isTokenInteractive)(props)
|
75
|
+
}, !hasMultipleActionTargets ? interactiveTokenProps : {}, rest), LeadingVisual ? /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, null, /*#__PURE__*/_react.default.createElement(LeadingVisual, null)) : null, /*#__PURE__*/_react.default.createElement(_TokenTextContainer.default, hasMultipleActionTargets ? interactiveTokenProps : {}, text), !hideRemoveButton && onRemove ? /*#__PURE__*/_react.default.createElement(_RemoveTokenButton.default, {
|
67
76
|
borderOffset: tokenBorderWidthPx,
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
77
|
+
onClick: onRemoveClick,
|
78
|
+
size: size,
|
79
|
+
isParentInteractive: (0, _TokenBase.isTokenInteractive)(props),
|
80
|
+
"aria-hidden": hasMultipleActionTargets ? 'true' : 'false',
|
81
|
+
sx: hasMultipleActionTargets ? {
|
82
|
+
position: 'relative',
|
83
|
+
zIndex: '1'
|
84
|
+
} : {}
|
73
85
|
}) : null);
|
74
86
|
});
|
75
87
|
var _default = Token;
|
package/lib/Token/TokenBase.d.ts
CHANGED
@@ -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>;
|
package/lib/Token/TokenBase.js
CHANGED
@@ -14,13 +14,13 @@ var _constants = require("../constants");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
|
16
16
|
const tokenSizes = {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
small: '16px',
|
18
|
+
medium: '20px',
|
19
|
+
large: '24px',
|
20
|
+
xlarge: '32px'
|
21
21
|
};
|
22
22
|
exports.tokenSizes = tokenSizes;
|
23
|
-
const defaultTokenSize = '
|
23
|
+
const defaultTokenSize = 'medium';
|
24
24
|
exports.defaultTokenSize = defaultTokenSize;
|
25
25
|
|
26
26
|
const isTokenInteractive = ({
|
@@ -32,51 +32,67 @@ const isTokenInteractive = ({
|
|
32
32
|
|
33
33
|
exports.isTokenInteractive = isTokenInteractive;
|
34
34
|
const variants = (0, _styledSystem.variant)({
|
35
|
+
prop: 'size',
|
35
36
|
variants: {
|
36
|
-
|
37
|
+
small: {
|
37
38
|
fontSize: 0,
|
38
39
|
gap: 1,
|
39
|
-
height:
|
40
|
+
height: tokenSizes.small,
|
41
|
+
// without setting lineHeight to match height, the "x" appears vertically mis-aligned
|
42
|
+
lineHeight: tokenSizes.small,
|
40
43
|
paddingLeft: 1,
|
41
|
-
paddingRight: 1
|
44
|
+
paddingRight: 1,
|
45
|
+
// need to explicitly set padding top and bottom to "0" to override default `<button>` element styles
|
46
|
+
// without setting these, the "x" appears vertically mis-aligned
|
47
|
+
paddingTop: 0,
|
48
|
+
paddingBottom: 0
|
42
49
|
},
|
43
|
-
|
50
|
+
medium: {
|
44
51
|
fontSize: 0,
|
45
52
|
gap: 1,
|
46
|
-
height:
|
53
|
+
height: tokenSizes.medium,
|
54
|
+
lineHeight: tokenSizes.medium,
|
47
55
|
paddingLeft: 2,
|
48
|
-
paddingRight: 2
|
56
|
+
paddingRight: 2,
|
57
|
+
paddingTop: 0,
|
58
|
+
paddingBottom: 0
|
49
59
|
},
|
50
|
-
|
60
|
+
large: {
|
51
61
|
fontSize: 0,
|
52
62
|
gap: 2,
|
53
|
-
height:
|
63
|
+
height: tokenSizes.large,
|
64
|
+
lineHeight: tokenSizes.large,
|
54
65
|
paddingLeft: 2,
|
55
|
-
paddingRight: 2
|
66
|
+
paddingRight: 2,
|
67
|
+
paddingTop: 0,
|
68
|
+
paddingBottom: 0
|
56
69
|
},
|
57
|
-
|
70
|
+
xlarge: {
|
58
71
|
fontSize: 1,
|
59
72
|
gap: 2,
|
60
|
-
height:
|
73
|
+
height: tokenSizes.xlarge,
|
74
|
+
lineHeight: tokenSizes.xlarge,
|
61
75
|
paddingLeft: 3,
|
62
|
-
paddingRight: 3
|
76
|
+
paddingRight: 3,
|
77
|
+
paddingTop: 0,
|
78
|
+
paddingBottom: 0
|
63
79
|
}
|
64
80
|
}
|
65
81
|
});
|
66
82
|
|
67
83
|
const TokenBase = _styledComponents.default.span.attrs(({
|
68
84
|
text,
|
69
|
-
|
70
|
-
|
85
|
+
onRemove,
|
86
|
+
onKeyDown
|
71
87
|
}) => ({
|
72
|
-
|
73
|
-
|
88
|
+
onKeyDown: event => {
|
89
|
+
onKeyDown && onKeyDown(event);
|
74
90
|
|
75
|
-
if ((
|
76
|
-
|
91
|
+
if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
|
92
|
+
onRemove();
|
77
93
|
}
|
78
94
|
},
|
79
|
-
'aria-label':
|
95
|
+
'aria-label': onRemove ? `${text}, press backspace or delete to remove` : undefined
|
80
96
|
})).withConfig({
|
81
97
|
displayName: "TokenBase",
|
82
98
|
componentId: "opajvp-0"
|
@@ -84,7 +100,7 @@ const TokenBase = _styledComponents.default.span.attrs(({
|
|
84
100
|
|
85
101
|
TokenBase.defaultProps = {
|
86
102
|
as: 'span',
|
87
|
-
|
103
|
+
size: defaultTokenSize
|
88
104
|
};
|
89
105
|
var _default = TokenBase;
|
90
106
|
exports.default = _default;
|
@@ -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;
|