@primer/components 0.0.0-202194215436 → 0.0.0-202194234612

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.
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _octiconsReact = require("@primer/octicons-react");
9
-
10
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
-
12
- var _styledSystem = require("styled-system");
13
-
14
- var _constants = require("../constants");
15
-
16
- var _TokenBase = require("./TokenBase");
17
-
18
- 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); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- const variants = (0, _styledSystem.variant)({
23
- prop: 'size',
24
- variants: {
25
- sm: {
26
- height: _TokenBase.tokenSizes.sm,
27
- width: _TokenBase.tokenSizes.sm
28
- },
29
- md: {
30
- height: _TokenBase.tokenSizes.md,
31
- width: _TokenBase.tokenSizes.md
32
- },
33
- lg: {
34
- height: _TokenBase.tokenSizes.lg,
35
- width: _TokenBase.tokenSizes.lg
36
- },
37
- xl: {
38
- height: _TokenBase.tokenSizes.xl,
39
- width: _TokenBase.tokenSizes.xl
40
- }
41
- }
42
- });
43
- const tokenButtonStyles = (0, _styledComponents.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:", ";}"], (0, _constants.get)('colors.fade.fg10'), (0, _constants.get)('colors.fade.fg15'));
44
-
45
- const getTokenButtonIconSize = variant => parseInt(_TokenBase.tokenSizes[variant || _TokenBase.defaultTokenSize], 10) * 0.75;
46
-
47
- const RemoveTokenButton = _styledComponents.default.span.attrs(({
48
- borderOffset,
49
- parentTokenTag,
50
- size,
51
- isParentInteractive,
52
- ...rest
53
- }) => {
54
- delete rest.children;
55
- return {
56
- borderOffset,
57
- as: isParentInteractive ? 'span' : 'button',
58
- tabIndex: isParentInteractive ? -1 : undefined,
59
- 'aria-label': !isParentInteractive ? 'Remove token' : undefined,
60
- children: /*#__PURE__*/React.createElement(_octiconsReact.XIcon, {
61
- size: getTokenButtonIconSize(size)
62
- })
63
- };
64
- }).withConfig({
65
- displayName: "_RemoveTokenButton__RemoveTokenButton",
66
- componentId: "sc-14lvcw1-0"
67
- })(["", " ", " transform:", ";"], tokenButtonStyles, variants, props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`);
68
-
69
- RemoveTokenButton.defaultProps = {
70
- size: _TokenBase.defaultTokenSize
71
- };
72
- var _default = RemoveTokenButton;
73
- exports.default = _default;
@@ -1,3 +0,0 @@
1
- export { default } from './Token';
2
- export { default as LabelToken } from './LabelToken';
3
- export { default as TokenProfile } from './TokenProfile';
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _Token.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "LabelToken", {
13
- enumerable: true,
14
- get: function () {
15
- return _LabelToken.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "TokenProfile", {
19
- enumerable: true,
20
- get: function () {
21
- return _TokenProfile.default;
22
- }
23
- });
24
-
25
- var _Token = _interopRequireDefault(require("./Token"));
26
-
27
- var _LabelToken = _interopRequireDefault(require("./LabelToken"));
28
-
29
- var _TokenProfile = _interopRequireDefault(require("./TokenProfile"));
30
-
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { TokenBaseProps } from './TokenBase';
3
- export interface LabelTokenProps 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 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;
@@ -1,121 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React, { forwardRef } from 'react';
4
- import styled, { css } from 'styled-components';
5
- import TokenBase, { isTokenInteractive } from './TokenBase';
6
- import RemoveTokenButton from './_RemoveTokenButton';
7
- import tinycolor from 'tinycolor2';
8
- import { useTheme } from '../ThemeProvider';
9
- const colorModeConfigs = {
10
- dark: {
11
- bgOpacity: 0.18,
12
- borderThreshold: 0,
13
- borderOpacity: 0.3,
14
- lightnessThreshold: 0.6
15
- },
16
- light: {
17
- bgOpacity: 1,
18
- borderThreshold: 0.96,
19
- borderOpacity: 1,
20
- lightnessThreshold: 0.453
21
- }
22
- };
23
- const tokenBorderWidthPx = 1;
24
- const StyledLabelToken = styled(TokenBase).withConfig({
25
- displayName: "LabelToken__StyledLabelToken",
26
- componentId: "sc-1udj0pr-0"
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
- if (props.isSelected) {
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
- }
31
- });
32
- const TokenTextContainer = styled('span').withConfig({
33
- displayName: "LabelToken__TokenTextContainer",
34
- componentId: "sc-1udj0pr-1"
35
- })(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
36
- const LabelToken = /*#__PURE__*/forwardRef((props, forwardedRef) => {
37
- const {
38
- as,
39
- fillColor,
40
- onRemove,
41
- id,
42
- isSelected,
43
- ref,
44
- text,
45
- size,
46
- hideRemoveButton,
47
- ...rest
48
- } = props;
49
- const {
50
- colorScheme
51
- } = useTheme();
52
- const {
53
- bgOpacity,
54
- borderOpacity,
55
- borderThreshold,
56
- lightnessThreshold
57
- } = colorModeConfigs[colorScheme || 'light'];
58
- let bgColor = fillColor;
59
- let borderColor = fillColor;
60
- let textColor = '#FFF';
61
- const perceivedLightness = tinycolor(fillColor).getLuminance();
62
- const isFillColorLight = perceivedLightness >= lightnessThreshold;
63
-
64
- if (colorScheme === 'dark') {
65
- const lightenBy = (perceivedLightness - lightnessThreshold) * 100 * (isFillColorLight ? 1 : 0);
66
- bgColor = isSelected ? tinycolor(fillColor).setAlpha(bgOpacity * 1.2).toRgbString() : tinycolor(fillColor).setAlpha(bgOpacity).toRgbString();
67
- textColor = isSelected ? tinycolor(fillColor).lighten(lightenBy + 10).toString() : tinycolor(fillColor).lighten(lightenBy).toString();
68
- borderColor = isSelected ? tinycolor(fillColor).lighten(lightenBy + 5).toRgbString() : tinycolor(fillColor).lighten(lightenBy).setAlpha(borderOpacity).toRgbString();
69
- } else {
70
- const isFillColorDark = perceivedLightness < 0.1;
71
- borderColor = perceivedLightness >= borderThreshold ? tinycolor(fillColor).darken(25).toString() : 'transparent';
72
-
73
- if (isFillColorLight) {
74
- textColor = '#000';
75
- }
76
-
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
79
- // Examples of colors that don't darken well:
80
- // - #a2eeef
81
- // - #ffd78e
82
- // - #a4f287
83
- tinycolor(fillColor).darken(10).toString();
84
- }
85
- }
86
-
87
- const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
88
-
89
- const onRemoveClick = e => {
90
- e.stopPropagation();
91
- onRemove && onRemove();
92
- };
93
-
94
- return /*#__PURE__*/React.createElement(StyledLabelToken // specific to labels
95
- , _extends({
96
- fillColor: fillColor,
97
- bgColor: bgColor,
98
- borderColor: borderColor,
99
- textColor: textColor // common token props
100
- ,
101
- as: as,
102
- hideRemoveButton: hideRemoveButton || !onRemove,
103
- onRemove: onRemove,
104
- id: id === null || id === void 0 ? void 0 : id.toString(),
105
- isSelected: isSelected,
106
- ref: forwardedRef,
107
- text: text,
108
- size: size
109
- }, rest), /*#__PURE__*/React.createElement(TokenTextContainer, null, text), !hideRemoveButton && onRemove ? /*#__PURE__*/React.createElement(RemoveTokenButton, {
110
- borderOffset: tokenBorderWidthPx,
111
- parentTokenTag: as || 'span',
112
- tabIndex: -1,
113
- onClick: onRemoveClick,
114
- size: size,
115
- "aria-hidden": hasMultipleActionTargets ? 'true' : 'false'
116
- }) : null);
117
- });
118
- LabelToken.defaultProps = {
119
- fillColor: '#999'
120
- };
121
- export default LabelToken;
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { TokenBaseProps } from './TokenBase';
3
- export interface TokenProps extends TokenBaseProps {
4
- /**
5
- * A function that renders a component before the token text
6
- */
7
- leadingVisual?: React.ComponentType<any>;
8
- /**
9
- * Whether the remove button should be rendered in the token
10
- */
11
- hideRemoveButton?: boolean;
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" | "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
- export default Token;
@@ -1,57 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React, { forwardRef } from 'react';
4
- import styled from 'styled-components';
5
- import { get } from '../constants';
6
- import TokenBase, { isTokenInteractive } from './TokenBase';
7
- import RemoveTokenButton from './_RemoveTokenButton';
8
- const tokenBorderWidthPx = 1;
9
- const DefaultTokenStyled = styled(TokenBase).withConfig({
10
- displayName: "Token__DefaultTokenStyled",
11
- componentId: "sc-1dg52pw-0"
12
- })(["background-color:", ";border-color:", ";border-style:solid;border-width:1px;color:", ";max-width:100%;padding-right:", ";&:hover{background-color:", ";box-shadow:", ";color:", ";}"], get('colors.neutral.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.border.subtle'), props => props.isSelected ? get('colors.fg.default') : get('colors.fg.muted'), props => !props.hideRemoveButton ? 0 : undefined, props => isTokenInteractive(props) ? get('colors.neutral.muted') : undefined, props => isTokenInteractive(props) ? get('colors.shadow.medium') : undefined, props => isTokenInteractive(props) ? get('colors.fg.default') : undefined);
13
- const TokenTextContainer = styled('span').withConfig({
14
- displayName: "Token__TokenTextContainer",
15
- componentId: "sc-1dg52pw-1"
16
- })(["flex-grow:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"]);
17
- const LeadingVisualContainer = styled('span').withConfig({
18
- displayName: "Token__LeadingVisualContainer",
19
- componentId: "sc-1dg52pw-2"
20
- })(["flex-shrink:0;line-height:0;"]);
21
- const Token = /*#__PURE__*/forwardRef((props, forwardedRef) => {
22
- const {
23
- as,
24
- onRemove,
25
- id,
26
- leadingVisual: LeadingVisual,
27
- ref,
28
- text,
29
- size,
30
- hideRemoveButton,
31
- ...rest
32
- } = props;
33
- const hasMultipleActionTargets = isTokenInteractive(props) && Boolean(onRemove) && !hideRemoveButton;
34
-
35
- const onRemoveClick = e => {
36
- e.stopPropagation();
37
- onRemove && onRemove();
38
- };
39
-
40
- return /*#__PURE__*/React.createElement(DefaultTokenStyled, _extends({
41
- as: as,
42
- onRemove: onRemove,
43
- hideRemoveButton: hideRemoveButton || !onRemove,
44
- id: id === null || id === void 0 ? void 0 : id.toString(),
45
- text: text,
46
- ref: forwardedRef,
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
- borderOffset: tokenBorderWidthPx,
50
- parentTokenTag: as || 'span',
51
- onClick: onRemoveClick,
52
- size: size,
53
- isParentInteractive: isTokenInteractive(props),
54
- "aria-hidden": hasMultipleActionTargets ? 'true' : 'false'
55
- }) : null);
56
- });
57
- export default Token;
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- export declare type TokenSizeKeys = 'sm' | 'md' | 'lg' | 'xl';
3
- export declare const tokenSizes: Record<TokenSizeKeys, string>;
4
- export declare const defaultTokenSize = "md";
5
- export interface TokenBaseProps extends Omit<React.HTMLProps<HTMLSpanElement | HTMLButtonElement | HTMLAnchorElement>, 'size' | 'id'> {
6
- as?: 'button' | 'a' | 'span';
7
- onRemove?: () => void;
8
- isSelected?: boolean;
9
- tabIndex?: number;
10
- text: string;
11
- id?: number | string;
12
- size?: TokenSizeKeys;
13
- }
14
- export declare const isTokenInteractive: ({ as, onClick, onFocus, tabIndex }: TokenBaseProps) => boolean;
15
- declare const TokenBase: import("styled-components").StyledComponent<"span", any, TokenBaseProps, never>;
16
- export default TokenBase;
@@ -1,71 +0,0 @@
1
- import styled from 'styled-components';
2
- import { variant } from 'styled-system';
3
- import { get } from '../constants';
4
- export const tokenSizes = {
5
- sm: '16px',
6
- md: '20px',
7
- lg: '24px',
8
- xl: '32px'
9
- };
10
- export const defaultTokenSize = 'md';
11
- export const isTokenInteractive = ({
12
- as = 'span',
13
- onClick,
14
- onFocus,
15
- tabIndex = -1
16
- }) => Boolean(onFocus || onClick || tabIndex > -1 || ['a', 'button'].includes(as));
17
- const variants = variant({
18
- prop: 'size',
19
- variants: {
20
- sm: {
21
- fontSize: 0,
22
- gap: 1,
23
- height: tokenSizes.sm,
24
- paddingLeft: 1,
25
- paddingRight: 1
26
- },
27
- md: {
28
- fontSize: 0,
29
- gap: 1,
30
- height: tokenSizes.md,
31
- paddingLeft: 2,
32
- paddingRight: 2
33
- },
34
- lg: {
35
- fontSize: 0,
36
- gap: 2,
37
- height: tokenSizes.lg,
38
- paddingLeft: 2,
39
- paddingRight: 2
40
- },
41
- xl: {
42
- fontSize: 1,
43
- gap: 2,
44
- height: tokenSizes.xl,
45
- paddingLeft: 3,
46
- paddingRight: 3
47
- }
48
- }
49
- });
50
- const TokenBase = styled.span.attrs(({
51
- text,
52
- onRemove,
53
- onKeyDown
54
- }) => ({
55
- onKeyDown: event => {
56
- onKeyDown && onKeyDown(event);
57
-
58
- if ((event.key === 'Backspace' || event.key === 'Delete') && onRemove) {
59
- onRemove();
60
- }
61
- },
62
- 'aria-label': onRemove ? `${text}, press backspace or delete to remove` : undefined
63
- })).withConfig({
64
- displayName: "TokenBase",
65
- componentId: "opajvp-0"
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);
67
- TokenBase.defaultProps = {
68
- as: 'span',
69
- size: defaultTokenSize
70
- };
71
- export default TokenBase;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { TokenBaseProps } from './TokenBase';
3
- export interface TokenProfileProps extends TokenBaseProps {
4
- avatarSrc: string;
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" | "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 TokenProfile;
@@ -1,29 +0,0 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
- import React, { forwardRef } from 'react';
4
- import styled from 'styled-components';
5
- import { get } from '../constants';
6
- import primitives from '@primer/primitives';
7
- import { defaultTokenSize, tokenSizes } from './TokenBase';
8
- import Token from './Token';
9
- import { Avatar } from '..';
10
- const StyledToken = styled(Token).withConfig({
11
- displayName: "TokenProfile__StyledToken",
12
- componentId: "sc-1vf9jhf-0"
13
- })(["padding-left:", ";"], get('space.1'));
14
- const TokenProfile = /*#__PURE__*/forwardRef(({
15
- avatarSrc,
16
- id,
17
- ref,
18
- size,
19
- ...rest
20
- }, forwardedRef) => /*#__PURE__*/React.createElement(StyledToken, _extends({
21
- leadingVisual: () => /*#__PURE__*/React.createElement(Avatar, {
22
- src: avatarSrc,
23
- size: parseInt(tokenSizes[size || defaultTokenSize], 10) - parseInt(primitives.spacing.normal.spacer[1], 10) * 2
24
- }),
25
- size: size,
26
- id: id === null || id === void 0 ? void 0 : id.toString(),
27
- ref: forwardedRef
28
- }, rest)));
29
- export default TokenProfile;
@@ -1,9 +0,0 @@
1
- import { TokenSizeKeys } from './TokenBase';
2
- interface TokenButtonProps {
3
- borderOffset?: number;
4
- parentTokenTag: 'span' | 'button' | 'a';
5
- size?: TokenSizeKeys;
6
- isParentInteractive?: boolean;
7
- }
8
- declare const RemoveTokenButton: import("styled-components").StyledComponent<"span", any, TokenButtonProps, never>;
9
- export default RemoveTokenButton;
@@ -1,55 +0,0 @@
1
- import { XIcon } from '@primer/octicons-react';
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
-
31
- const RemoveTokenButton = styled.span.attrs(({
32
- borderOffset,
33
- parentTokenTag,
34
- size,
35
- isParentInteractive,
36
- ...rest
37
- }) => {
38
- delete rest.children;
39
- return {
40
- borderOffset,
41
- as: isParentInteractive ? 'span' : 'button',
42
- tabIndex: isParentInteractive ? -1 : undefined,
43
- 'aria-label': !isParentInteractive ? 'Remove token' : undefined,
44
- children: /*#__PURE__*/React.createElement(XIcon, {
45
- size: getTokenButtonIconSize(size)
46
- })
47
- };
48
- }).withConfig({
49
- displayName: "_RemoveTokenButton__RemoveTokenButton",
50
- componentId: "sc-14lvcw1-0"
51
- })(["", " ", " transform:", ";"], tokenButtonStyles, variants, props => `translate(${props.borderOffset}px, -${props.borderOffset}px)`);
52
- RemoveTokenButton.defaultProps = {
53
- size: defaultTokenSize
54
- };
55
- export default RemoveTokenButton;
@@ -1,3 +0,0 @@
1
- export { default } from './Token';
2
- export { default as LabelToken } from './LabelToken';
3
- export { default as TokenProfile } from './TokenProfile';
@@ -1,3 +0,0 @@
1
- export { default } from './Token';
2
- export { default as LabelToken } from './LabelToken';
3
- export { default as TokenProfile } from './TokenProfile';