@primer/components 0.0.0-202194183411 → 0.0.0-202194215436
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 +295 -299
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +358 -362
- package/dist/browser.umd.js.map +1 -1
- package/lib/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib/FilteredActionList/FilteredActionList.js +31 -5
- package/lib/Overlay.d.ts +1 -2
- package/lib/Overlay.js +5 -10
- package/lib/SelectMenu/SelectMenu.d.ts +2 -8
- package/lib/TextInput.d.ts +3 -6
- package/lib/TextInput.js +10 -9
- package/{lib-esm/Token/TokenLabel.d.ts → lib/Token/LabelToken.d.ts} +3 -3
- package/lib/Token/{TokenLabel.js → LabelToken.js} +23 -23
- package/lib/Token/Token.d.ts +2 -2
- package/lib/Token/Token.js +13 -13
- package/lib/Token/TokenBase.d.ts +3 -3
- package/lib/Token/TokenBase.js +17 -16
- package/lib/Token/TokenProfile.d.ts +1 -1
- package/lib/Token/TokenProfile.js +3 -3
- package/lib/Token/_RemoveTokenButton.d.ts +7 -1
- package/lib/Token/_RemoveTokenButton.js +40 -11
- package/lib/Token/index.d.ts +1 -1
- package/lib/Token/index.js +3 -3
- package/lib/hooks/useOverlay.d.ts +1 -2
- package/lib/hooks/useOverlay.js +6 -11
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -18
- package/lib/utils/types.d.ts +0 -3
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.d.ts +1 -2
- package/lib-esm/AnchoredOverlay/AnchoredOverlay.js +3 -11
- package/lib-esm/FilteredActionList/FilteredActionList.js +31 -3
- package/lib-esm/Overlay.d.ts +1 -2
- package/lib-esm/Overlay.js +5 -8
- package/lib-esm/SelectMenu/SelectMenu.d.ts +2 -8
- package/lib-esm/TextInput.d.ts +3 -6
- package/lib-esm/TextInput.js +9 -8
- package/{lib/Token/TokenLabel.d.ts → lib-esm/Token/LabelToken.d.ts} +3 -3
- package/lib-esm/Token/{TokenLabel.js → LabelToken.js} +23 -23
- package/lib-esm/Token/Token.d.ts +2 -2
- package/lib-esm/Token/Token.js +13 -13
- package/lib-esm/Token/TokenBase.d.ts +3 -3
- package/lib-esm/Token/TokenBase.js +17 -16
- package/lib-esm/Token/TokenProfile.d.ts +1 -1
- package/lib-esm/Token/TokenProfile.js +3 -3
- package/lib-esm/Token/_RemoveTokenButton.d.ts +7 -1
- package/lib-esm/Token/_RemoveTokenButton.js +36 -10
- package/lib-esm/Token/index.d.ts +1 -1
- package/lib-esm/Token/index.js +1 -1
- package/lib-esm/hooks/useOverlay.d.ts +1 -2
- package/lib-esm/hooks/useOverlay.js +6 -11
- package/lib-esm/index.d.ts +1 -3
- package/lib-esm/index.js +1 -3
- package/lib-esm/utils/types.d.ts +0 -3
- package/package.json +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib/Autocomplete/Autocomplete.js +0 -68
- package/lib/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteContext.js +0 -11
- package/lib/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib/Autocomplete/AutocompleteInput.js +0 -146
- package/lib/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib/Autocomplete/AutocompleteMenu.js +0 -223
- package/lib/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib/Autocomplete/AutocompleteOverlay.js +0 -71
- package/lib/Autocomplete/index.d.ts +0 -2
- package/lib/Autocomplete/index.js +0 -15
- package/lib/TextInputWithTokens.d.ts +0 -43
- package/lib/TextInputWithTokens.js +0 -236
- package/lib/Token/_tokenButtonUtils.d.ts +0 -10
- package/lib/Token/_tokenButtonUtils.js +0 -42
- package/lib/_UnstyledTextInput.d.ts +0 -2
- package/lib/_UnstyledTextInput.js +0 -20
- package/lib/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib/utils/scrollIntoViewingArea.js +0 -39
- package/lib-esm/Autocomplete/Autocomplete.d.ts +0 -40
- package/lib-esm/Autocomplete/Autocomplete.js +0 -47
- package/lib-esm/Autocomplete/AutocompleteContext.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteContext.js +0 -2
- package/lib-esm/Autocomplete/AutocompleteInput.d.ts +0 -9
- package/lib-esm/Autocomplete/AutocompleteInput.js +0 -127
- package/lib-esm/Autocomplete/AutocompleteMenu.d.ts +0 -71
- package/lib-esm/Autocomplete/AutocompleteMenu.js +0 -202
- package/lib-esm/Autocomplete/AutocompleteOverlay.d.ts +0 -17
- package/lib-esm/Autocomplete/AutocompleteOverlay.js +0 -53
- package/lib-esm/Autocomplete/index.d.ts +0 -2
- package/lib-esm/Autocomplete/index.js +0 -1
- package/lib-esm/TextInputWithTokens.d.ts +0 -43
- package/lib-esm/TextInputWithTokens.js +0 -209
- package/lib-esm/Token/_tokenButtonUtils.d.ts +0 -10
- package/lib-esm/Token/_tokenButtonUtils.js +0 -26
- package/lib-esm/_UnstyledTextInput.d.ts +0 -2
- package/lib-esm/_UnstyledTextInput.js +0 -7
- package/lib-esm/utils/scrollIntoViewingArea.d.ts +0 -1
- package/lib-esm/utils/scrollIntoViewingArea.js +0 -30
package/lib-esm/TextInput.js
CHANGED
@@ -6,7 +6,6 @@ import styled, { css } from 'styled-components';
|
|
6
6
|
import { maxWidth, minWidth, variant, width } from 'styled-system';
|
7
7
|
import { get } from './constants';
|
8
8
|
import sx from './sx';
|
9
|
-
import UnstyledTextInput from './_UnstyledTextInput';
|
10
9
|
const sizeVariants = variant({
|
11
10
|
variants: {
|
12
11
|
small: {
|
@@ -23,19 +22,23 @@ const sizeVariants = variant({
|
|
23
22
|
}
|
24
23
|
}
|
25
24
|
});
|
25
|
+
const Input = styled.input.withConfig({
|
26
|
+
displayName: "TextInput__Input",
|
27
|
+
componentId: "sc-1apmpmt-0"
|
28
|
+
})(["border:0;font-size:inherit;font-family:inherit;background-color:transparent;-webkit-appearance:none;color:inherit;width:100%;&:focus{outline:0;}"]);
|
26
29
|
const Wrapper = styled.span.withConfig({
|
27
30
|
displayName: "TextInput__Wrapper",
|
28
|
-
componentId: "sc-1apmpmt-
|
31
|
+
componentId: "sc-1apmpmt-1"
|
29
32
|
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], get('fontSizes.1'), get('colors.fg.default'), get('colors.border.default'), get('radii.2'), get('shadows.primer.shadow.inset'), props => {
|
30
33
|
if (props.hasIcon) {
|
31
34
|
return css(["padding:0;"]);
|
32
35
|
} else {
|
33
36
|
return css(["padding:6px 12px;"]);
|
34
37
|
}
|
35
|
-
}, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.fg.muted'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx);
|
38
|
+
}, get('colors.fg.muted'), get('space.2'), get('colors.accent.emphasis'), get('shadows.primer.shadow.focus'), props => props.contrast && css(["background-color:", ";"], get('colors.canvas.inset')), props => props.disabled && css(["color:", ";background-color:", ";border-color:", ";"], get('colors.fg.muted'), get('colors.input.disabledBg'), get('colors.border.default')), props => props.block && css(["display:block;width:100%;"]), get('breakpoints.1'), get('fontSizes.1'), width, minWidth, maxWidth, sizeVariants, sx); // Props that are not passed through to Input:
|
39
|
+
|
36
40
|
// using forwardRef is important so that other components (ex. SelectMenu) can autofocus the input
|
37
41
|
const TextInput = /*#__PURE__*/React.forwardRef(({
|
38
|
-
inputComponent: InputComponent,
|
39
42
|
icon: IconComponent,
|
40
43
|
block,
|
41
44
|
className,
|
@@ -47,7 +50,6 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
47
50
|
minWidth: minWidthProp,
|
48
51
|
maxWidth: maxWidthProp,
|
49
52
|
variant: variantProp,
|
50
|
-
wrapperRef,
|
51
53
|
...inputProps
|
52
54
|
}, ref) => {
|
53
55
|
// this class is necessary to style FilterSearch, plz no touchy!
|
@@ -63,11 +65,10 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
63
65
|
width: widthProp,
|
64
66
|
minWidth: minWidthProp,
|
65
67
|
maxWidth: maxWidthProp,
|
66
|
-
variant: variantProp
|
67
|
-
ref: wrapperRef
|
68
|
+
variant: variantProp
|
68
69
|
}, IconComponent && /*#__PURE__*/React.createElement(IconComponent, {
|
69
70
|
className: "TextInput-icon"
|
70
|
-
}), /*#__PURE__*/React.createElement(
|
71
|
+
}), /*#__PURE__*/React.createElement(Input, _extends({
|
71
72
|
ref: ref,
|
72
73
|
disabled: disabled
|
73
74
|
}, inputProps)));
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { TokenBaseProps } from './TokenBase';
|
3
|
-
export interface
|
3
|
+
export interface LabelTokenProps extends TokenBaseProps {
|
4
4
|
/**
|
5
5
|
* The color that corresponds to the label
|
6
6
|
*/
|
@@ -10,5 +10,5 @@ export interface TokenLabelProps extends TokenBaseProps {
|
|
10
10
|
*/
|
11
11
|
hideRemoveButton?: boolean;
|
12
12
|
}
|
13
|
-
declare const
|
14
|
-
export default
|
13
|
+
declare const LabelToken: React.ForwardRefExoticComponent<Pick<LabelTokenProps, "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 LabelToken;
|
@@ -21,28 +21,28 @@ const colorModeConfigs = {
|
|
21
21
|
}
|
22
22
|
};
|
23
23
|
const tokenBorderWidthPx = 1;
|
24
|
-
const
|
25
|
-
displayName: "
|
26
|
-
componentId: "sc-
|
24
|
+
const StyledLabelToken = styled(TokenBase).withConfig({
|
25
|
+
displayName: "LabelToken__StyledLabelToken",
|
26
|
+
componentId: "sc-1udj0pr-0"
|
27
27
|
})(["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
28
|
if (props.isSelected) {
|
29
29
|
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
30
|
}
|
31
31
|
});
|
32
32
|
const TokenTextContainer = styled('span').withConfig({
|
33
|
-
displayName: "
|
34
|
-
componentId: "sc-
|
33
|
+
displayName: "LabelToken__TokenTextContainer",
|
34
|
+
componentId: "sc-1udj0pr-1"
|
35
35
|
})(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
|
36
|
-
const
|
36
|
+
const LabelToken = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
37
37
|
const {
|
38
38
|
as,
|
39
39
|
fillColor,
|
40
|
-
|
40
|
+
onRemove,
|
41
41
|
id,
|
42
42
|
isSelected,
|
43
43
|
ref,
|
44
44
|
text,
|
45
|
-
|
45
|
+
size,
|
46
46
|
hideRemoveButton,
|
47
47
|
...rest
|
48
48
|
} = props;
|
@@ -75,23 +75,23 @@ const TokenLabel = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
75
75
|
}
|
76
76
|
|
77
77
|
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
|
78
|
+
bgColor = isFillColorDark ? tinycolor(fillColor).lighten(10).toString() : // TODO: darken more than 10 if the fillColor is really bright and doesn't darken well
|
79
79
|
// Examples of colors that don't darken well:
|
80
80
|
// - #a2eeef
|
81
81
|
// - #ffd78e
|
82
82
|
// - #a4f287
|
83
|
-
|
83
|
+
tinycolor(fillColor).darken(10).toString();
|
84
84
|
}
|
85
85
|
}
|
86
86
|
|
87
|
-
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(
|
87
|
+
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
|
88
88
|
|
89
|
-
const
|
89
|
+
const onRemoveClick = e => {
|
90
90
|
e.stopPropagation();
|
91
|
-
|
91
|
+
onRemove && onRemove();
|
92
92
|
};
|
93
93
|
|
94
|
-
return /*#__PURE__*/React.createElement(
|
94
|
+
return /*#__PURE__*/React.createElement(StyledLabelToken // specific to labels
|
95
95
|
, _extends({
|
96
96
|
fillColor: fillColor,
|
97
97
|
bgColor: bgColor,
|
@@ -99,23 +99,23 @@ const TokenLabel = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
|
99
99
|
textColor: textColor // common token props
|
100
100
|
,
|
101
101
|
as: as,
|
102
|
-
hideRemoveButton: hideRemoveButton || !
|
103
|
-
|
102
|
+
hideRemoveButton: hideRemoveButton || !onRemove,
|
103
|
+
onRemove: onRemove,
|
104
104
|
id: id === null || id === void 0 ? void 0 : id.toString(),
|
105
105
|
isSelected: isSelected,
|
106
106
|
ref: forwardedRef,
|
107
107
|
text: text,
|
108
|
-
|
109
|
-
}, rest), /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton &&
|
108
|
+
size: size
|
109
|
+
}, rest), /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton && onRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
|
110
110
|
borderOffset: tokenBorderWidthPx,
|
111
111
|
parentTokenTag: as || 'span',
|
112
112
|
tabIndex: -1,
|
113
|
-
onClick:
|
114
|
-
|
115
|
-
"aria-hidden": hasMultipleActionTargets ?
|
113
|
+
onClick: onRemoveClick,
|
114
|
+
size: size,
|
115
|
+
"aria-hidden": hasMultipleActionTargets ? 'true' : 'false'
|
116
116
|
}) : null);
|
117
117
|
});
|
118
|
-
|
118
|
+
LabelToken.defaultProps = {
|
119
119
|
fillColor: '#999'
|
120
120
|
};
|
121
|
-
export default
|
121
|
+
export default LabelToken;
|
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
@@ -21,37 +21,37 @@ const LeadingVisualContainer = styled('span').withConfig({
|
|
21
21
|
const Token = /*#__PURE__*/forwardRef((props, forwardedRef) => {
|
22
22
|
const {
|
23
23
|
as,
|
24
|
-
|
24
|
+
onRemove,
|
25
25
|
id,
|
26
26
|
leadingVisual: LeadingVisual,
|
27
27
|
ref,
|
28
28
|
text,
|
29
|
-
|
29
|
+
size,
|
30
30
|
hideRemoveButton,
|
31
31
|
...rest
|
32
32
|
} = props;
|
33
|
-
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(
|
33
|
+
const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
|
34
34
|
|
35
|
-
const
|
35
|
+
const onRemoveClick = e => {
|
36
36
|
e.stopPropagation();
|
37
|
-
|
37
|
+
onRemove && onRemove();
|
38
38
|
};
|
39
39
|
|
40
40
|
return /*#__PURE__*/React.createElement(DefaultTokenStyled, _extends({
|
41
41
|
as: as,
|
42
|
-
|
43
|
-
hideRemoveButton: hideRemoveButton || !
|
42
|
+
onRemove: onRemove,
|
43
|
+
hideRemoveButton: hideRemoveButton || !onRemove,
|
44
44
|
id: id === null || id === void 0 ? void 0 : id.toString(),
|
45
45
|
text: text,
|
46
46
|
ref: forwardedRef,
|
47
|
-
|
48
|
-
}, rest), LeadingVisual ? /*#__PURE__*/React.createElement(LeadingVisualContainer, null, /*#__PURE__*/React.createElement(LeadingVisual, null)) : null, /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton &&
|
47
|
+
size: size
|
48
|
+
}, rest), LeadingVisual ? /*#__PURE__*/React.createElement(LeadingVisualContainer, null, /*#__PURE__*/React.createElement(LeadingVisual, null)) : null, /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton && onRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
|
49
49
|
borderOffset: tokenBorderWidthPx,
|
50
50
|
parentTokenTag: as || 'span',
|
51
|
-
onClick:
|
52
|
-
|
53
|
-
|
54
|
-
"aria-hidden": hasMultipleActionTargets ?
|
51
|
+
onClick: onRemoveClick,
|
52
|
+
size: size,
|
53
|
+
isParentInteractive: isTokenInteractive(props),
|
54
|
+
"aria-hidden": hasMultipleActionTargets ? 'true' : 'false'
|
55
55
|
}) : null);
|
56
56
|
});
|
57
57
|
export default Token;
|
@@ -1,15 +1,15 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
export declare type TokenSizeKeys = 'sm' | 'md' | 'lg' | 'xl';
|
3
|
-
export declare const tokenSizes: Record<TokenSizeKeys,
|
3
|
+
export declare const tokenSizes: Record<TokenSizeKeys, string>;
|
4
4
|
export declare const defaultTokenSize = "md";
|
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,10 +2,10 @@ 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:
|
6
|
-
md:
|
7
|
-
lg:
|
8
|
-
xl:
|
5
|
+
sm: '16px',
|
6
|
+
md: '20px',
|
7
|
+
lg: '24px',
|
8
|
+
xl: '32px'
|
9
9
|
};
|
10
10
|
export const defaultTokenSize = 'md';
|
11
11
|
export const isTokenInteractive = ({
|
@@ -15,32 +15,33 @@ 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
|
sm: {
|
20
21
|
fontSize: 0,
|
21
22
|
gap: 1,
|
22
|
-
height:
|
23
|
+
height: tokenSizes.sm,
|
23
24
|
paddingLeft: 1,
|
24
25
|
paddingRight: 1
|
25
26
|
},
|
26
27
|
md: {
|
27
28
|
fontSize: 0,
|
28
29
|
gap: 1,
|
29
|
-
height:
|
30
|
+
height: tokenSizes.md,
|
30
31
|
paddingLeft: 2,
|
31
32
|
paddingRight: 2
|
32
33
|
},
|
33
34
|
lg: {
|
34
35
|
fontSize: 0,
|
35
36
|
gap: 2,
|
36
|
-
height:
|
37
|
+
height: tokenSizes.lg,
|
37
38
|
paddingLeft: 2,
|
38
39
|
paddingRight: 2
|
39
40
|
},
|
40
41
|
xl: {
|
41
42
|
fontSize: 1,
|
42
43
|
gap: 2,
|
43
|
-
height:
|
44
|
+
height: tokenSizes.xl,
|
44
45
|
paddingLeft: 3,
|
45
46
|
paddingRight: 3
|
46
47
|
}
|
@@ -48,23 +49,23 @@ const variants = variant({
|
|
48
49
|
});
|
49
50
|
const TokenBase = styled.span.attrs(({
|
50
51
|
text,
|
51
|
-
|
52
|
-
|
52
|
+
onRemove,
|
53
|
+
onKeyDown
|
53
54
|
}) => ({
|
54
|
-
|
55
|
-
|
55
|
+
onKeyDown: event => {
|
56
|
+
onKeyDown && onKeyDown(event);
|
56
57
|
|
57
|
-
if ((
|
58
|
-
|
58
|
+
if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
|
59
|
+
onRemove();
|
59
60
|
}
|
60
61
|
},
|
61
|
-
'aria-label':
|
62
|
+
'aria-label': onRemove ? `${text}, press backspace or delete to remove` : undefined
|
62
63
|
})).withConfig({
|
63
64
|
displayName: "TokenBase",
|
64
65
|
componentId: "opajvp-0"
|
65
66
|
})(["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
67
|
TokenBase.defaultProps = {
|
67
68
|
as: 'span',
|
68
|
-
|
69
|
+
size: defaultTokenSize
|
69
70
|
};
|
70
71
|
export default TokenBase;
|
@@ -3,5 +3,5 @@ import { TokenBaseProps } from './TokenBase';
|
|
3
3
|
export interface TokenProfileProps 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" | "
|
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" | "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
7
|
export default TokenProfile;
|
@@ -15,14 +15,14 @@ const TokenProfile = /*#__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)));
|
@@ -1,3 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { TokenSizeKeys } from './TokenBase';
|
2
|
+
interface TokenButtonProps {
|
3
|
+
borderOffset?: number;
|
4
|
+
parentTokenTag: 'span' | 'button' | 'a';
|
5
|
+
size?: TokenSizeKeys;
|
6
|
+
isParentInteractive?: boolean;
|
7
|
+
}
|
2
8
|
declare const RemoveTokenButton: import("styled-components").StyledComponent<"span", any, TokenButtonProps, never>;
|
3
9
|
export default RemoveTokenButton;
|
@@ -1,22 +1,48 @@
|
|
1
1
|
import { XIcon } from '@primer/octicons-react';
|
2
|
-
import styled from 'styled-components';
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import styled, { css } from 'styled-components';
|
3
|
+
import { variant } from 'styled-system';
|
4
|
+
import { get } from '../constants';
|
5
|
+
import { tokenSizes, defaultTokenSize } from './TokenBase';
|
6
|
+
const variants = variant({
|
7
|
+
prop: 'size',
|
8
|
+
variants: {
|
9
|
+
sm: {
|
10
|
+
height: tokenSizes.sm,
|
11
|
+
width: tokenSizes.sm
|
12
|
+
},
|
13
|
+
md: {
|
14
|
+
height: tokenSizes.md,
|
15
|
+
width: tokenSizes.md
|
16
|
+
},
|
17
|
+
lg: {
|
18
|
+
height: tokenSizes.lg,
|
19
|
+
width: tokenSizes.lg
|
20
|
+
},
|
21
|
+
xl: {
|
22
|
+
height: tokenSizes.xl,
|
23
|
+
width: tokenSizes.xl
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
const tokenButtonStyles = css(["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;align-self:baseline;border:0;border-radius:999px;&:hover,&:focus{background-color:", ";}&:active{background-color:", ";}"], get('colors.fade.fg10'), get('colors.fade.fg15'));
|
28
|
+
|
29
|
+
const getTokenButtonIconSize = variant => parseInt(tokenSizes[variant || defaultTokenSize], 10) * 0.75;
|
30
|
+
|
5
31
|
const RemoveTokenButton = styled.span.attrs(({
|
6
32
|
borderOffset,
|
7
33
|
parentTokenTag,
|
8
|
-
|
9
|
-
|
34
|
+
size,
|
35
|
+
isParentInteractive,
|
10
36
|
...rest
|
11
37
|
}) => {
|
12
38
|
delete rest.children;
|
13
39
|
return {
|
14
40
|
borderOffset,
|
15
|
-
as:
|
16
|
-
tabIndex:
|
17
|
-
'aria-label': !
|
41
|
+
as: isParentInteractive ? 'span' : 'button',
|
42
|
+
tabIndex: isParentInteractive ? -1 : undefined,
|
43
|
+
'aria-label': !isParentInteractive ? 'Remove token' : undefined,
|
18
44
|
children: /*#__PURE__*/React.createElement(XIcon, {
|
19
|
-
size: getTokenButtonIconSize(
|
45
|
+
size: getTokenButtonIconSize(size)
|
20
46
|
})
|
21
47
|
};
|
22
48
|
}).withConfig({
|
@@ -24,6 +50,6 @@ const RemoveTokenButton = styled.span.attrs(({
|
|
24
50
|
componentId: "sc-14lvcw1-0"
|
25
51
|
})(["", " ", " transform:", ";"], tokenButtonStyles, variants, props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`);
|
26
52
|
RemoveTokenButton.defaultProps = {
|
27
|
-
|
53
|
+
size: defaultTokenSize
|
28
54
|
};
|
29
55
|
export default RemoveTokenButton;
|
package/lib-esm/Token/index.d.ts
CHANGED
package/lib-esm/Token/index.js
CHANGED
@@ -7,9 +7,8 @@ export declare type UseOverlaySettings = {
|
|
7
7
|
onEscape: (e: KeyboardEvent) => void;
|
8
8
|
onClickOutside: (e: TouchOrMouseEvent) => void;
|
9
9
|
overlayRef?: React.RefObject<HTMLDivElement>;
|
10
|
-
preventFocusOnOpen?: boolean;
|
11
10
|
};
|
12
11
|
export declare type OverlayReturnProps = {
|
13
12
|
ref: React.RefObject<HTMLDivElement>;
|
14
13
|
};
|
15
|
-
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside
|
14
|
+
export declare const useOverlay: ({ overlayRef: _overlayRef, returnFocusRef, initialFocusRef, onEscape, ignoreClickRefs, onClickOutside }: UseOverlaySettings) => OverlayReturnProps;
|
@@ -8,19 +8,14 @@ export const useOverlay = ({
|
|
8
8
|
initialFocusRef,
|
9
9
|
onEscape,
|
10
10
|
ignoreClickRefs,
|
11
|
-
onClickOutside
|
12
|
-
preventFocusOnOpen
|
11
|
+
onClickOutside
|
13
12
|
}) => {
|
14
13
|
const overlayRef = useProvidedRefOrCreate(_overlayRef);
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
initialFocusRef
|
21
|
-
});
|
22
|
-
}
|
23
|
-
|
14
|
+
useOpenAndCloseFocus({
|
15
|
+
containerRef: overlayRef,
|
16
|
+
returnFocusRef,
|
17
|
+
initialFocusRef
|
18
|
+
});
|
24
19
|
useOnOutsideClick({
|
25
20
|
containerRef: overlayRef,
|
26
21
|
ignoreClickRefs,
|