@primer/components 0.0.0-2021919182815 → 0.0.0-2021919184749
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 +605 -604
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +175 -174
- package/dist/browser.umd.js.map +1 -1
- package/lib/TextInputWithTokens.d.ts +4 -0
- package/lib/TextInputWithTokens.js +61 -8
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -8
- package/lib-esm/TextInputWithTokens.d.ts +4 -0
- package/lib-esm/TextInputWithTokens.js +61 -9
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/index.d.ts +0 -1
- package/lib-esm/index.js +0 -1
- package/package.json +1 -1
- package/lib/ActionList2/Description.d.ts +0 -5
- package/lib/ActionList2/Description.js +0 -45
- package/lib/ActionList2/Divider.d.ts +0 -8
- package/lib/ActionList2/Divider.js +0 -42
- package/lib/ActionList2/Group.d.ts +0 -8
- package/lib/ActionList2/Group.js +0 -39
- package/lib/ActionList2/Header.d.ts +0 -26
- package/lib/ActionList2/Header.js +0 -55
- package/lib/ActionList2/Item.d.ts +0 -52
- package/lib/ActionList2/Item.js +0 -171
- package/lib/ActionList2/List.d.ts +0 -18
- package/lib/ActionList2/List.js +0 -52
- package/lib/ActionList2/Selection.d.ts +0 -5
- package/lib/ActionList2/Selection.js +0 -67
- package/lib/ActionList2/Visuals.d.ts +0 -12
- package/lib/ActionList2/Visuals.js +0 -87
- package/lib/ActionList2/hacks.d.ts +0 -30
- package/lib/ActionList2/hacks.js +0 -38
- package/lib/ActionList2/index.d.ts +0 -26
- package/lib/ActionList2/index.js +0 -36
- package/lib/utils/create-slots.d.ts +0 -15
- package/lib/utils/create-slots.js +0 -101
- package/lib/utils/use-force-update.d.ts +0 -1
- package/lib/utils/use-force-update.js +0 -19
- package/lib-esm/ActionList2/Description.d.ts +0 -5
- package/lib-esm/ActionList2/Description.js +0 -30
- package/lib-esm/ActionList2/Divider.d.ts +0 -8
- package/lib-esm/ActionList2/Divider.js +0 -30
- package/lib-esm/ActionList2/Group.d.ts +0 -8
- package/lib-esm/ActionList2/Group.js +0 -29
- package/lib-esm/ActionList2/Header.d.ts +0 -26
- package/lib-esm/ActionList2/Header.js +0 -45
- package/lib-esm/ActionList2/Item.d.ts +0 -52
- package/lib-esm/ActionList2/Item.js +0 -172
- package/lib-esm/ActionList2/List.d.ts +0 -18
- package/lib-esm/ActionList2/List.js +0 -42
- package/lib-esm/ActionList2/Selection.d.ts +0 -5
- package/lib-esm/ActionList2/Selection.js +0 -50
- package/lib-esm/ActionList2/Visuals.d.ts +0 -12
- package/lib-esm/ActionList2/Visuals.js +0 -66
- package/lib-esm/ActionList2/hacks.d.ts +0 -30
- package/lib-esm/ActionList2/hacks.js +0 -30
- package/lib-esm/ActionList2/index.d.ts +0 -26
- package/lib-esm/ActionList2/index.js +0 -23
- package/lib-esm/utils/create-slots.d.ts +0 -15
- package/lib-esm/utils/create-slots.js +0 -80
- package/lib-esm/utils/use-force-update.d.ts +0 -1
- package/lib-esm/utils/use-force-update.js +0 -6
@@ -32,6 +32,10 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
32
32
|
* Whether the remove buttons should be rendered in the tokens
|
33
33
|
*/
|
34
34
|
hideTokenRemoveButtons?: boolean | undefined;
|
35
|
+
/**
|
36
|
+
* The number of tokens to display before truncating
|
37
|
+
*/
|
38
|
+
visibleTokenCount?: number | undefined;
|
35
39
|
} & Pick<Omit<Pick<{
|
36
40
|
[x: string]: any;
|
37
41
|
[x: number]: any;
|
@@ -25,6 +25,8 @@ var _TextInputWrapper = _interopRequireDefault(require("./_TextInputWrapper"));
|
|
25
25
|
|
26
26
|
var _Box = _interopRequireDefault(require("./Box"));
|
27
27
|
|
28
|
+
var _Text = _interopRequireDefault(require("./Text"));
|
29
|
+
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29
31
|
|
30
32
|
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); }
|
@@ -33,7 +35,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
33
35
|
|
34
36
|
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); }
|
35
37
|
|
36
|
-
|
38
|
+
const overflowCountFontSizeMap = {
|
39
|
+
small: 0,
|
40
|
+
medium: 1,
|
41
|
+
large: 1,
|
42
|
+
extralarge: 2
|
43
|
+
}; // using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
44
|
+
|
37
45
|
function TextInputWithTokensInnerComponent({
|
38
46
|
icon: IconComponent,
|
39
47
|
contrast,
|
@@ -53,9 +61,11 @@ function TextInputWithTokensInnerComponent({
|
|
53
61
|
minWidth: minWidthProp,
|
54
62
|
maxWidth: maxWidthProp,
|
55
63
|
variant: variantProp,
|
64
|
+
visibleTokenCount,
|
56
65
|
...rest
|
57
66
|
}, externalRef) {
|
58
67
|
const {
|
68
|
+
onBlur,
|
59
69
|
onFocus,
|
60
70
|
onKeyDown,
|
61
71
|
...inputPropsRest
|
@@ -64,6 +74,7 @@ function TextInputWithTokensInnerComponent({
|
|
64
74
|
const localInputRef = (0, _react.useRef)(null);
|
65
75
|
const combinedInputRef = (0, _useCombinedRefs.useCombinedRefs)(localInputRef, ref);
|
66
76
|
const [selectedTokenIndex, setSelectedTokenIndex] = (0, _react.useState)();
|
77
|
+
const [tokensAreTruncated, setTokensAreTruncated] = (0, _react.useState)(Boolean(visibleTokenCount));
|
67
78
|
const {
|
68
79
|
containerRef
|
69
80
|
} = (0, _useFocusZone.useFocusZone)({
|
@@ -113,20 +124,45 @@ function TextInputWithTokensInnerComponent({
|
|
113
124
|
};
|
114
125
|
|
115
126
|
const handleTokenBlur = () => {
|
116
|
-
setSelectedTokenIndex(undefined);
|
127
|
+
setSelectedTokenIndex(undefined); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
128
|
+
// this prevents the tokens from hiding when the user is moving focus between tokens,
|
129
|
+
// but still hides the tokens when the user blurs the token by tabbing out or clicking somewhere else on the page
|
130
|
+
|
131
|
+
setTimeout(() => {
|
132
|
+
var _containerRef$current3;
|
133
|
+
|
134
|
+
if (!((_containerRef$current3 = containerRef.current) !== null && _containerRef$current3 !== void 0 && _containerRef$current3.contains(document.activeElement))) {
|
135
|
+
setTokensAreTruncated(true);
|
136
|
+
}
|
137
|
+
}, 0);
|
117
138
|
};
|
118
139
|
|
119
|
-
const handleTokenKeyUp =
|
120
|
-
if (
|
140
|
+
const handleTokenKeyUp = event => {
|
141
|
+
if (event.key === 'Escape') {
|
121
142
|
var _ref$current;
|
122
143
|
|
123
144
|
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
124
145
|
}
|
125
146
|
};
|
126
147
|
|
127
|
-
const handleInputFocus =
|
128
|
-
onFocus && onFocus(
|
148
|
+
const handleInputFocus = event => {
|
149
|
+
onFocus && onFocus(event);
|
129
150
|
setSelectedTokenIndex(undefined);
|
151
|
+
setTokensAreTruncated(false);
|
152
|
+
};
|
153
|
+
|
154
|
+
const handleInputBlur = event => {
|
155
|
+
onBlur && onBlur(event); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
156
|
+
// this prevents the tokens from hiding when the user is moving focus from the input to a token,
|
157
|
+
// but still hides the tokens when the user blurs the input by tabbing out or clicking somewhere else on the page
|
158
|
+
|
159
|
+
setTimeout(() => {
|
160
|
+
var _containerRef$current4;
|
161
|
+
|
162
|
+
if (!((_containerRef$current4 = containerRef.current) !== null && _containerRef$current4 !== void 0 && _containerRef$current4.contains(document.activeElement))) {
|
163
|
+
setTokensAreTruncated(true);
|
164
|
+
}
|
165
|
+
}, 0);
|
130
166
|
};
|
131
167
|
|
132
168
|
const handleInputKeyDown = e => {
|
@@ -164,6 +200,17 @@ function TextInputWithTokensInnerComponent({
|
|
164
200
|
}
|
165
201
|
};
|
166
202
|
|
203
|
+
const focusInput = () => {
|
204
|
+
var _combinedInputRef$cur;
|
205
|
+
|
206
|
+
(_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
|
207
|
+
};
|
208
|
+
|
209
|
+
const preventTokenClickPropagation = event => {
|
210
|
+
event.stopPropagation();
|
211
|
+
};
|
212
|
+
|
213
|
+
const visibleTokens = tokensAreTruncated ? tokens.slice(0, visibleTokenCount) : tokens;
|
167
214
|
return /*#__PURE__*/_react.default.createElement(_TextInputWrapper.default, {
|
168
215
|
block: block,
|
169
216
|
className: className,
|
@@ -176,6 +223,7 @@ function TextInputWithTokensInnerComponent({
|
|
176
223
|
maxWidth: maxWidthProp,
|
177
224
|
variant: variantProp,
|
178
225
|
ref: containerRef,
|
226
|
+
onClick: focusInput,
|
179
227
|
sx: {
|
180
228
|
alignItems: 'center',
|
181
229
|
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
@@ -207,12 +255,13 @@ function TextInputWithTokensInnerComponent({
|
|
207
255
|
ref: combinedInputRef,
|
208
256
|
disabled: disabled,
|
209
257
|
onFocus: handleInputFocus,
|
258
|
+
onBlur: handleInputBlur,
|
210
259
|
onKeyDown: handleInputKeyDown,
|
211
260
|
type: "text",
|
212
261
|
sx: {
|
213
262
|
height: '100%'
|
214
263
|
}
|
215
|
-
}, inputPropsRest))),
|
264
|
+
}, inputPropsRest))), TokenComponent ? visibleTokens.map(({
|
216
265
|
id,
|
217
266
|
...tokenRest
|
218
267
|
}, i) => /*#__PURE__*/_react.default.createElement(TokenComponent, _extends({
|
@@ -220,6 +269,7 @@ function TextInputWithTokensInnerComponent({
|
|
220
269
|
onFocus: handleTokenFocus(i),
|
221
270
|
onBlur: handleTokenBlur,
|
222
271
|
onKeyUp: handleTokenKeyUp,
|
272
|
+
onClick: preventTokenClickPropagation,
|
223
273
|
isSelected: selectedTokenIndex === i,
|
224
274
|
onRemove: () => {
|
225
275
|
handleTokenRemove(id);
|
@@ -227,7 +277,10 @@ function TextInputWithTokensInnerComponent({
|
|
227
277
|
hideRemoveButton: hideTokenRemoveButtons,
|
228
278
|
size: size,
|
229
279
|
tabIndex: 0
|
230
|
-
}, tokenRest))) : null
|
280
|
+
}, tokenRest))) : null, tokensAreTruncated ? /*#__PURE__*/_react.default.createElement(_Text.default, {
|
281
|
+
color: "fg.muted",
|
282
|
+
fontSize: size && overflowCountFontSizeMap[size]
|
283
|
+
}, "+", tokens.length - visibleTokens.length) : null);
|
231
284
|
}
|
232
285
|
|
233
286
|
TextInputWithTokensInnerComponent.displayName = "TextInputWithTokensInnerComponent";
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -39,7 +39,7 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
39
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
40
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
41
41
|
componentId: "sc-5vfcis-0"
|
42
|
-
})(["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:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
42
|
+
})(["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:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
43
43
|
if (props.hasIcon) {
|
44
44
|
return (0, _styledComponents.css)(["padding:0;"]);
|
45
45
|
} else {
|
package/lib/index.d.ts
CHANGED
@@ -22,7 +22,6 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
|
|
22
22
|
export { useOverlay } from './hooks/useOverlay';
|
23
23
|
export { useConfirm } from './Dialog/ConfirmationDialog';
|
24
24
|
export { ActionList } from './ActionList';
|
25
|
-
export { ActionList as ActionList2 } from './ActionList2';
|
26
25
|
export { ActionMenu } from './ActionMenu';
|
27
26
|
export type { ActionMenuProps } from './ActionMenu';
|
28
27
|
export { default as Autocomplete } from './Autocomplete';
|
package/lib/index.js
CHANGED
@@ -147,12 +147,6 @@ Object.defineProperty(exports, "ActionList", {
|
|
147
147
|
return _ActionList.ActionList;
|
148
148
|
}
|
149
149
|
});
|
150
|
-
Object.defineProperty(exports, "ActionList2", {
|
151
|
-
enumerable: true,
|
152
|
-
get: function () {
|
153
|
-
return _ActionList2.ActionList;
|
154
|
-
}
|
155
|
-
});
|
156
150
|
Object.defineProperty(exports, "ActionMenu", {
|
157
151
|
enumerable: true,
|
158
152
|
get: function () {
|
@@ -542,8 +536,6 @@ var _ConfirmationDialog = require("./Dialog/ConfirmationDialog");
|
|
542
536
|
|
543
537
|
var _ActionList = require("./ActionList");
|
544
538
|
|
545
|
-
var _ActionList2 = require("./ActionList2");
|
546
|
-
|
547
539
|
var _ActionMenu = require("./ActionMenu");
|
548
540
|
|
549
541
|
var _Autocomplete = _interopRequireDefault(require("./Autocomplete"));
|
@@ -32,6 +32,10 @@ declare const TextInputWithTokens: React.ForwardRefExoticComponent<Pick<{
|
|
32
32
|
* Whether the remove buttons should be rendered in the tokens
|
33
33
|
*/
|
34
34
|
hideTokenRemoveButtons?: boolean | undefined;
|
35
|
+
/**
|
36
|
+
* The number of tokens to display before truncating
|
37
|
+
*/
|
38
|
+
visibleTokenCount?: number | undefined;
|
35
39
|
} & Pick<Omit<Pick<{
|
36
40
|
[x: string]: any;
|
37
41
|
[x: number]: any;
|
@@ -9,9 +9,16 @@ import Token from './Token/Token';
|
|
9
9
|
import { useProvidedRefOrCreate } from './hooks';
|
10
10
|
import UnstyledTextInput from './_UnstyledTextInput';
|
11
11
|
import TextInputWrapper from './_TextInputWrapper';
|
12
|
-
import Box from './Box';
|
12
|
+
import Box from './Box';
|
13
|
+
import Text from './Text'; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
14
|
+
|
15
|
+
const overflowCountFontSizeMap = {
|
16
|
+
small: 0,
|
17
|
+
medium: 1,
|
18
|
+
large: 1,
|
19
|
+
extralarge: 2
|
20
|
+
}; // using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
13
21
|
|
14
|
-
// using forwardRef is important so that other components (ex. Autocomplete) can use the ref
|
15
22
|
function TextInputWithTokensInnerComponent({
|
16
23
|
icon: IconComponent,
|
17
24
|
contrast,
|
@@ -31,9 +38,11 @@ function TextInputWithTokensInnerComponent({
|
|
31
38
|
minWidth: minWidthProp,
|
32
39
|
maxWidth: maxWidthProp,
|
33
40
|
variant: variantProp,
|
41
|
+
visibleTokenCount,
|
34
42
|
...rest
|
35
43
|
}, externalRef) {
|
36
44
|
const {
|
45
|
+
onBlur,
|
37
46
|
onFocus,
|
38
47
|
onKeyDown,
|
39
48
|
...inputPropsRest
|
@@ -42,6 +51,7 @@ function TextInputWithTokensInnerComponent({
|
|
42
51
|
const localInputRef = useRef(null);
|
43
52
|
const combinedInputRef = useCombinedRefs(localInputRef, ref);
|
44
53
|
const [selectedTokenIndex, setSelectedTokenIndex] = useState();
|
54
|
+
const [tokensAreTruncated, setTokensAreTruncated] = useState(Boolean(visibleTokenCount));
|
45
55
|
const {
|
46
56
|
containerRef
|
47
57
|
} = useFocusZone({
|
@@ -91,20 +101,45 @@ function TextInputWithTokensInnerComponent({
|
|
91
101
|
};
|
92
102
|
|
93
103
|
const handleTokenBlur = () => {
|
94
|
-
setSelectedTokenIndex(undefined);
|
104
|
+
setSelectedTokenIndex(undefined); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
105
|
+
// this prevents the tokens from hiding when the user is moving focus between tokens,
|
106
|
+
// but still hides the tokens when the user blurs the token by tabbing out or clicking somewhere else on the page
|
107
|
+
|
108
|
+
setTimeout(() => {
|
109
|
+
var _containerRef$current3;
|
110
|
+
|
111
|
+
if (!((_containerRef$current3 = containerRef.current) !== null && _containerRef$current3 !== void 0 && _containerRef$current3.contains(document.activeElement))) {
|
112
|
+
setTokensAreTruncated(true);
|
113
|
+
}
|
114
|
+
}, 0);
|
95
115
|
};
|
96
116
|
|
97
|
-
const handleTokenKeyUp =
|
98
|
-
if (
|
117
|
+
const handleTokenKeyUp = event => {
|
118
|
+
if (event.key === 'Escape') {
|
99
119
|
var _ref$current;
|
100
120
|
|
101
121
|
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
102
122
|
}
|
103
123
|
};
|
104
124
|
|
105
|
-
const handleInputFocus =
|
106
|
-
onFocus && onFocus(
|
125
|
+
const handleInputFocus = event => {
|
126
|
+
onFocus && onFocus(event);
|
107
127
|
setSelectedTokenIndex(undefined);
|
128
|
+
setTokensAreTruncated(false);
|
129
|
+
};
|
130
|
+
|
131
|
+
const handleInputBlur = event => {
|
132
|
+
onBlur && onBlur(event); // HACK: wait a tick and check the focused element before hiding truncated tokens
|
133
|
+
// this prevents the tokens from hiding when the user is moving focus from the input to a token,
|
134
|
+
// but still hides the tokens when the user blurs the input by tabbing out or clicking somewhere else on the page
|
135
|
+
|
136
|
+
setTimeout(() => {
|
137
|
+
var _containerRef$current4;
|
138
|
+
|
139
|
+
if (!((_containerRef$current4 = containerRef.current) !== null && _containerRef$current4 !== void 0 && _containerRef$current4.contains(document.activeElement))) {
|
140
|
+
setTokensAreTruncated(true);
|
141
|
+
}
|
142
|
+
}, 0);
|
108
143
|
};
|
109
144
|
|
110
145
|
const handleInputKeyDown = e => {
|
@@ -142,6 +177,17 @@ function TextInputWithTokensInnerComponent({
|
|
142
177
|
}
|
143
178
|
};
|
144
179
|
|
180
|
+
const focusInput = () => {
|
181
|
+
var _combinedInputRef$cur;
|
182
|
+
|
183
|
+
(_combinedInputRef$cur = combinedInputRef.current) === null || _combinedInputRef$cur === void 0 ? void 0 : _combinedInputRef$cur.focus();
|
184
|
+
};
|
185
|
+
|
186
|
+
const preventTokenClickPropagation = event => {
|
187
|
+
event.stopPropagation();
|
188
|
+
};
|
189
|
+
|
190
|
+
const visibleTokens = tokensAreTruncated ? tokens.slice(0, visibleTokenCount) : tokens;
|
145
191
|
return /*#__PURE__*/React.createElement(TextInputWrapper, {
|
146
192
|
block: block,
|
147
193
|
className: className,
|
@@ -154,6 +200,7 @@ function TextInputWithTokensInnerComponent({
|
|
154
200
|
maxWidth: maxWidthProp,
|
155
201
|
variant: variantProp,
|
156
202
|
ref: containerRef,
|
203
|
+
onClick: focusInput,
|
157
204
|
sx: {
|
158
205
|
alignItems: 'center',
|
159
206
|
flexWrap: preventTokenWrapping ? 'nowrap' : 'wrap',
|
@@ -185,12 +232,13 @@ function TextInputWithTokensInnerComponent({
|
|
185
232
|
ref: combinedInputRef,
|
186
233
|
disabled: disabled,
|
187
234
|
onFocus: handleInputFocus,
|
235
|
+
onBlur: handleInputBlur,
|
188
236
|
onKeyDown: handleInputKeyDown,
|
189
237
|
type: "text",
|
190
238
|
sx: {
|
191
239
|
height: '100%'
|
192
240
|
}
|
193
|
-
}, inputPropsRest))),
|
241
|
+
}, inputPropsRest))), TokenComponent ? visibleTokens.map(({
|
194
242
|
id,
|
195
243
|
...tokenRest
|
196
244
|
}, i) => /*#__PURE__*/React.createElement(TokenComponent, _extends({
|
@@ -198,6 +246,7 @@ function TextInputWithTokensInnerComponent({
|
|
198
246
|
onFocus: handleTokenFocus(i),
|
199
247
|
onBlur: handleTokenBlur,
|
200
248
|
onKeyUp: handleTokenKeyUp,
|
249
|
+
onClick: preventTokenClickPropagation,
|
201
250
|
isSelected: selectedTokenIndex === i,
|
202
251
|
onRemove: () => {
|
203
252
|
handleTokenRemove(id);
|
@@ -205,7 +254,10 @@ function TextInputWithTokensInnerComponent({
|
|
205
254
|
hideRemoveButton: hideTokenRemoveButtons,
|
206
255
|
size: size,
|
207
256
|
tabIndex: 0
|
208
|
-
}, tokenRest))) : null
|
257
|
+
}, tokenRest))) : null, tokensAreTruncated ? /*#__PURE__*/React.createElement(Text, {
|
258
|
+
color: "fg.muted",
|
259
|
+
fontSize: size && overflowCountFontSizeMap[size]
|
260
|
+
}, "+", tokens.length - visibleTokens.length) : null);
|
209
261
|
}
|
210
262
|
|
211
263
|
TextInputWithTokensInnerComponent.displayName = "TextInputWithTokensInnerComponent";
|
@@ -21,7 +21,7 @@ const sizeVariants = variant({
|
|
21
21
|
const TextInputWrapper = styled.span.withConfig({
|
22
22
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
23
23
|
componentId: "sc-5vfcis-0"
|
24
|
-
})(["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 => {
|
24
|
+
})(["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:", ";cursor:text;", " .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 => {
|
25
25
|
if (props.hasIcon) {
|
26
26
|
return css(["padding:0;"]);
|
27
27
|
} else {
|
package/lib-esm/index.d.ts
CHANGED
@@ -22,7 +22,6 @@ export { useOnEscapePress } from './hooks/useOnEscapePress';
|
|
22
22
|
export { useOverlay } from './hooks/useOverlay';
|
23
23
|
export { useConfirm } from './Dialog/ConfirmationDialog';
|
24
24
|
export { ActionList } from './ActionList';
|
25
|
-
export { ActionList as ActionList2 } from './ActionList2';
|
26
25
|
export { ActionMenu } from './ActionMenu';
|
27
26
|
export type { ActionMenuProps } from './ActionMenu';
|
28
27
|
export { default as Autocomplete } from './Autocomplete';
|
package/lib-esm/index.js
CHANGED
@@ -18,7 +18,6 @@ export { useOverlay } from './hooks/useOverlay';
|
|
18
18
|
export { useConfirm } from './Dialog/ConfirmationDialog'; // Components
|
19
19
|
|
20
20
|
export { ActionList } from './ActionList';
|
21
|
-
export { ActionList as ActionList2 } from './ActionList2';
|
22
21
|
export { ActionMenu } from './ActionMenu';
|
23
22
|
export { default as Autocomplete } from './Autocomplete';
|
24
23
|
export { default as Avatar } from './Avatar';
|
package/package.json
CHANGED
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Description = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _Truncate = _interopRequireDefault(require("../Truncate"));
|
13
|
-
|
14
|
-
var _Item = require("./Item");
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
|
-
const Description = ({
|
19
|
-
variant = 'inline',
|
20
|
-
...props
|
21
|
-
}) => {
|
22
|
-
const styles = {
|
23
|
-
color: 'fg.muted',
|
24
|
-
fontSize: 0,
|
25
|
-
lineHeight: '16px',
|
26
|
-
flexGrow: 1,
|
27
|
-
flexBasis: 0,
|
28
|
-
minWidth: 0,
|
29
|
-
marginLeft: variant === 'block' ? 0 : 2
|
30
|
-
};
|
31
|
-
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
32
|
-
name: variant === 'block' ? 'BlockDescription' : 'InlineDescription'
|
33
|
-
}, variant === 'block' ? /*#__PURE__*/_react.default.createElement(_Box.default, {
|
34
|
-
as: "span",
|
35
|
-
sx: styles
|
36
|
-
}, props.children) : /*#__PURE__*/_react.default.createElement(_Truncate.default, {
|
37
|
-
sx: styles,
|
38
|
-
title: props.children,
|
39
|
-
inline: true,
|
40
|
-
maxWidth: "100%"
|
41
|
-
}, props.children));
|
42
|
-
};
|
43
|
-
|
44
|
-
exports.Description = Description;
|
45
|
-
Description.displayName = "Description";
|
@@ -1,42 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Divider = Divider;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _constants = require("../constants");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Visually separates `Item`s or `Group`s in an `ActionList`.
|
18
|
-
*/
|
19
|
-
function Divider() {
|
20
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, {
|
21
|
-
as: "hr",
|
22
|
-
sx: {
|
23
|
-
border: 'none',
|
24
|
-
// override browser styles
|
25
|
-
height: 1,
|
26
|
-
backgroundColor: 'border.muted',
|
27
|
-
marginTop: theme => `calc(${(0, _constants.get)('space.2')(theme)} - 1px)`,
|
28
|
-
marginBottom: 2
|
29
|
-
},
|
30
|
-
"data-component": "ActionList.Divider"
|
31
|
-
});
|
32
|
-
}
|
33
|
-
|
34
|
-
Divider.displayName = "Divider";
|
35
|
-
|
36
|
-
/**
|
37
|
-
* `Divider` fulfills the `ItemPropsWithCustomRenderer` contract,
|
38
|
-
* so it can be used inline in an `ActionList`’s `items` prop.
|
39
|
-
* In other words, `items={[ActionList.Divider]}` is supported as a concise
|
40
|
-
* alternative to `items={[{renderItem: () => <ActionList.Divider />}]}`.
|
41
|
-
*/
|
42
|
-
Divider.renderItem = Divider;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* show item dividers
|
3
|
-
*/
|
4
|
-
/// <reference types="react" />
|
5
|
-
import { SxProp } from '../sx';
|
6
|
-
import { HeaderProps } from './Header';
|
7
|
-
export declare type GroupProps = HeaderProps & SxProp;
|
8
|
-
export declare function Group({ title, variant, auxiliaryText, sx, ...props }: GroupProps): JSX.Element;
|
package/lib/ActionList2/Group.js
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Group = Group;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _Header = require("./Header");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
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); }
|
17
|
-
|
18
|
-
function Group({
|
19
|
-
title,
|
20
|
-
variant,
|
21
|
-
auxiliaryText,
|
22
|
-
sx = {},
|
23
|
-
...props
|
24
|
-
}) {
|
25
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
26
|
-
sx: {
|
27
|
-
'&:not(:first-child)': {
|
28
|
-
marginTop: 2
|
29
|
-
},
|
30
|
-
...sx
|
31
|
-
}
|
32
|
-
}, props), title && /*#__PURE__*/_react.default.createElement(_Header.Header, {
|
33
|
-
title: title,
|
34
|
-
variant: variant,
|
35
|
-
auxiliaryText: auxiliaryText
|
36
|
-
}), props.children);
|
37
|
-
}
|
38
|
-
|
39
|
-
Group.displayName = "Group";
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { SxProp } from '../sx';
|
3
|
-
/**
|
4
|
-
* Contract for props passed to the `Header` component.
|
5
|
-
*/
|
6
|
-
export interface HeaderProps extends React.ComponentPropsWithoutRef<'div'>, SxProp {
|
7
|
-
/**
|
8
|
-
* Style variations. Usage is discretionary.
|
9
|
-
*
|
10
|
-
* - `"filled"` - Superimposed on a background, offset from nearby content
|
11
|
-
* - `"subtle"` - Relatively less offset from nearby content
|
12
|
-
*/
|
13
|
-
variant?: 'subtle' | 'filled';
|
14
|
-
/**
|
15
|
-
* Primary text which names a `Group`.
|
16
|
-
*/
|
17
|
-
title?: string;
|
18
|
-
/**
|
19
|
-
* Secondary text which provides additional information about a `Group`.
|
20
|
-
*/
|
21
|
-
auxiliaryText?: string;
|
22
|
-
}
|
23
|
-
/**
|
24
|
-
* Displays the name and description of a `Group`.
|
25
|
-
*/
|
26
|
-
export declare function Header({ variant, title, auxiliaryText, children: _children, sx, ...props }: HeaderProps): JSX.Element;
|
@@ -1,55 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Header = Header;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
-
|
12
|
-
var _List = require("./List");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
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); }
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Displays the name and description of a `Group`.
|
20
|
-
*/
|
21
|
-
function Header({
|
22
|
-
variant = 'subtle',
|
23
|
-
title,
|
24
|
-
auxiliaryText,
|
25
|
-
children: _children,
|
26
|
-
sx = {},
|
27
|
-
...props
|
28
|
-
}) {
|
29
|
-
const {
|
30
|
-
variant: listVariant
|
31
|
-
} = _react.default.useContext(_List.ListContext);
|
32
|
-
|
33
|
-
const styles = {
|
34
|
-
paddingY: '6px',
|
35
|
-
paddingX: listVariant === 'full' ? 2 : 3,
|
36
|
-
fontSize: 0,
|
37
|
-
fontWeight: 'bold',
|
38
|
-
color: 'fg.muted',
|
39
|
-
...(variant === 'filled' && {
|
40
|
-
backgroundColor: 'canvas.subtle',
|
41
|
-
marginX: 0,
|
42
|
-
marginBottom: 2,
|
43
|
-
borderTop: '1px solid',
|
44
|
-
borderBottom: '1px solid',
|
45
|
-
borderColor: 'neutral.muted'
|
46
|
-
}),
|
47
|
-
...sx
|
48
|
-
};
|
49
|
-
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
50
|
-
sx: styles,
|
51
|
-
role: "heading"
|
52
|
-
}, props), title, auxiliaryText && /*#__PURE__*/_react.default.createElement("span", null, "auxiliaryText"));
|
53
|
-
}
|
54
|
-
|
55
|
-
Header.displayName = "Header";
|