@primer/components 31.0.0-rc.f601fc1f → 31.0.2-rc.1e80de40
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/.github/workflows/check_for_changeset.yml +25 -0
- package/CHANGELOG.md +14 -2
- package/dist/browser.esm.js +40 -37
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +34 -31
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/Autocomplete.mdx +51 -21
- package/lib/ActionList/Item.js +3 -3
- package/lib/Button/Button.js +1 -1
- package/lib/Button/ButtonTableList.js +1 -1
- package/lib/Pagination/Pagination.js +1 -1
- package/lib/TextInputWithTokens.js +17 -10
- package/lib/Token/Token.js +13 -2
- package/lib/Token/TokenBase.js +0 -4
- package/lib/Token/_RemoveTokenButton.js +15 -2
- package/lib/_TextInputWrapper.js +1 -1
- package/lib/stories/Autocomplete.stories.js +67 -56
- package/lib/stories/Button.stories.js +12 -1
- package/lib/stories/useAnchoredPosition.stories.js +1 -1
- package/lib-esm/ActionList/Item.js +3 -3
- package/lib-esm/Button/Button.js +1 -1
- package/lib-esm/Button/ButtonTableList.js +1 -1
- package/lib-esm/Pagination/Pagination.js +1 -1
- package/lib-esm/TextInputWithTokens.js +17 -10
- package/lib-esm/Token/Token.js +13 -2
- package/lib-esm/Token/TokenBase.js +0 -4
- package/lib-esm/Token/_RemoveTokenButton.js +11 -2
- package/lib-esm/_TextInputWrapper.js +1 -1
- package/lib-esm/stories/Autocomplete.stories.js +67 -56
- package/lib-esm/stories/Button.stories.js +8 -0
- package/lib-esm/stories/useAnchoredPosition.stories.js +1 -1
- package/package-lock.json +6090 -7003
- package/package.json +6 -6
- package/src/ActionList/Item.tsx +3 -3
- package/src/Button/Button.tsx +1 -1
- package/src/Button/ButtonTableList.tsx +1 -1
- package/src/Pagination/Pagination.tsx +1 -1
- package/src/TextInputWithTokens.tsx +49 -40
- package/src/Token/Token.tsx +16 -2
- package/src/Token/TokenBase.tsx +0 -5
- package/src/Token/_RemoveTokenButton.tsx +15 -2
- package/src/_TextInputWrapper.tsx +1 -1
- package/src/__tests__/Pagination/__snapshots__/Pagination.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +3 -3
- package/src/__tests__/__snapshots__/Button.test.tsx.snap +3 -3
- package/src/__tests__/__snapshots__/ConfirmationDialog.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/Dropdown.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/SelectMenu.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -1
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +3374 -3166
- package/src/__tests__/__snapshots__/Token.test.tsx.snap +31 -24
- package/src/stories/Autocomplete.stories.tsx +142 -59
- package/src/stories/Button.stories.tsx +4 -0
- package/src/stories/useAnchoredPosition.stories.tsx +13 -1
- package/stats.html +1 -1
@@ -7,49 +7,28 @@ import Autocomplete from '../Autocomplete/Autocomplete';
|
|
7
7
|
import { AnchoredOverlay } from '../AnchoredOverlay';
|
8
8
|
import { ButtonInvisible } from '../Button';
|
9
9
|
const items = [{
|
10
|
-
text: '
|
10
|
+
text: 'css',
|
11
11
|
id: 0
|
12
12
|
}, {
|
13
|
-
text: '
|
13
|
+
text: 'css-in-js',
|
14
14
|
id: 1
|
15
15
|
}, {
|
16
|
-
text: '
|
16
|
+
text: 'styled-system',
|
17
17
|
id: 2
|
18
18
|
}, {
|
19
|
-
text: '
|
19
|
+
text: 'javascript',
|
20
20
|
id: 3
|
21
21
|
}, {
|
22
|
-
text: '
|
22
|
+
text: 'typescript',
|
23
23
|
id: 4
|
24
24
|
}, {
|
25
|
-
text: '
|
25
|
+
text: 'react',
|
26
26
|
id: 5
|
27
27
|
}, {
|
28
|
-
text: '
|
28
|
+
text: 'design-systems',
|
29
29
|
id: 6
|
30
|
-
}, {
|
31
|
-
text: 'seven',
|
32
|
-
id: 7
|
33
|
-
}, {
|
34
|
-
text: 'twenty',
|
35
|
-
id: 20
|
36
|
-
}, {
|
37
|
-
text: 'twentyone',
|
38
|
-
id: 21
|
39
|
-
}];
|
40
|
-
const mockTokens = [{
|
41
|
-
text: 'zero',
|
42
|
-
id: 0
|
43
|
-
}, {
|
44
|
-
text: 'one',
|
45
|
-
id: 1
|
46
|
-
}, {
|
47
|
-
text: 'three',
|
48
|
-
id: 3
|
49
|
-
}, {
|
50
|
-
text: 'four',
|
51
|
-
id: 4
|
52
30
|
}];
|
31
|
+
const mockTokens = [...items].slice(0, 3);
|
53
32
|
export default {
|
54
33
|
title: 'Forms/Autocomplete',
|
55
34
|
decorators: [Story => {
|
@@ -69,12 +48,15 @@ export default {
|
|
69
48
|
}]
|
70
49
|
};
|
71
50
|
export const SingleSelect = () => {
|
72
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
51
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
52
|
+
fontWeight: "bold",
|
53
|
+
fontSize: 1,
|
73
54
|
as: "label",
|
74
55
|
display: "block",
|
75
56
|
htmlFor: "autocompleteInput",
|
76
57
|
id: "autocompleteLabel"
|
77
|
-
}, "Pick
|
58
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
59
|
+
block: true,
|
78
60
|
id: "autocompleteInput"
|
79
61
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
80
62
|
items: items,
|
@@ -100,12 +82,14 @@ export const MultiSelect = () => {
|
|
100
82
|
sx: {
|
101
83
|
gap: '1em'
|
102
84
|
}
|
103
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(
|
85
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
|
86
|
+
fontWeight: "bold",
|
87
|
+
fontSize: 1,
|
104
88
|
as: "label",
|
105
89
|
display: "block",
|
106
90
|
htmlFor: "autocompleteInput",
|
107
91
|
id: "autocompleteLabel"
|
108
|
-
}, "Pick
|
92
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
109
93
|
id: "autocompleteInput"
|
110
94
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
111
95
|
items: items,
|
@@ -126,7 +110,8 @@ export const MultiSelect = () => {
|
|
126
110
|
};
|
127
111
|
MultiSelect.displayName = "MultiSelect";
|
128
112
|
export const MultiSelectWithTokenInput = () => {
|
129
|
-
const [tokens, setTokens] = useState(
|
113
|
+
const [tokens, setTokens] = useState([]); // [items[0], items[2]]
|
114
|
+
|
130
115
|
const selectedTokenIds = tokens.map(token => token.id);
|
131
116
|
const [selectedItemIds, setSelectedItemIds] = useState(selectedTokenIds);
|
132
117
|
|
@@ -164,12 +149,15 @@ export const MultiSelectWithTokenInput = () => {
|
|
164
149
|
})));
|
165
150
|
};
|
166
151
|
|
167
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
152
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
153
|
+
fontWeight: "bold",
|
154
|
+
fontSize: 1,
|
168
155
|
as: "label",
|
169
156
|
display: "block",
|
170
157
|
htmlFor: "autocompleteInput",
|
171
158
|
id: "autocompleteLabel"
|
172
|
-
}, "Pick
|
159
|
+
}, "Pick tags"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
160
|
+
block: true,
|
173
161
|
as: TextInputTokens,
|
174
162
|
tokens: tokens,
|
175
163
|
onTokenRemove: onTokenRemove,
|
@@ -235,14 +223,19 @@ export const MultiSelectAddNewItem = () => {
|
|
235
223
|
setFilterVal(e.currentTarget.value);
|
236
224
|
};
|
237
225
|
|
238
|
-
return /*#__PURE__*/React.createElement(
|
226
|
+
return /*#__PURE__*/React.createElement(Box, {
|
227
|
+
maxWidth: "300px"
|
228
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
229
|
+
fontWeight: "bold",
|
230
|
+
fontSize: 1,
|
239
231
|
as: "label",
|
240
232
|
display: "block",
|
241
233
|
htmlFor: "autocompleteInput",
|
242
234
|
id: "autocompleteLabel"
|
243
|
-
}, "Pick
|
235
|
+
}, "Pick tags"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
236
|
+
block: true,
|
244
237
|
as: TextInputTokens,
|
245
|
-
tokens:
|
238
|
+
tokens: [],
|
246
239
|
onTokenRemove: onTokenRemove,
|
247
240
|
onChange: handleChange,
|
248
241
|
id: "autocompleteInput"
|
@@ -264,13 +257,16 @@ export const MultiSelectAddNewItem = () => {
|
|
264
257
|
"aria-labelledby": "autocompleteLabel"
|
265
258
|
}))));
|
266
259
|
};
|
260
|
+
MultiSelectAddNewItem.displayName = "MultiSelectAddNewItem";
|
267
261
|
export const CustomEmptyStateMessage = () => {
|
268
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
262
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
263
|
+
fontWeight: "bold",
|
264
|
+
fontSize: 1,
|
269
265
|
as: "label",
|
270
266
|
display: "block",
|
271
267
|
htmlFor: "autocompleteInput",
|
272
268
|
id: "autocompleteLabel"
|
273
|
-
}, "Pick
|
269
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
274
270
|
id: "autocompleteInput"
|
275
271
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
276
272
|
items: items,
|
@@ -288,12 +284,14 @@ export const CustomSearchFilter = () => {
|
|
288
284
|
|
289
285
|
const customFilterFn = item => item.text.includes(filterVal);
|
290
286
|
|
291
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
287
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
288
|
+
fontWeight: "bold",
|
289
|
+
fontSize: 1,
|
292
290
|
as: "label",
|
293
291
|
display: "block",
|
294
292
|
htmlFor: "autocompleteInput",
|
295
293
|
id: "autocompleteLabel"
|
296
|
-
}, "Pick
|
294
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
297
295
|
id: "autocompleteInput",
|
298
296
|
onChange: handleChange
|
299
297
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
@@ -323,12 +321,14 @@ export const CustomSortAfterMenuClose = () => {
|
|
323
321
|
|
324
322
|
const customSortFn = (itemIdA, itemIdB) => isItemSelected(itemIdA) === isItemSelected(itemIdB) ? 0 : isItemSelected(itemIdA) ? 1 : -1;
|
325
323
|
|
326
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
324
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
325
|
+
fontWeight: "bold",
|
326
|
+
fontSize: 1,
|
327
327
|
as: "label",
|
328
328
|
display: "block",
|
329
329
|
htmlFor: "autocompleteInput",
|
330
330
|
id: "autocompleteLabel"
|
331
|
-
}, "Pick
|
331
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
332
332
|
id: "autocompleteInput"
|
333
333
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
334
334
|
items: items,
|
@@ -356,12 +356,14 @@ export const WithCallbackWhenOverlayOpenStateChanges = () => {
|
|
356
356
|
sx: {
|
357
357
|
gap: '1em'
|
358
358
|
}
|
359
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(
|
359
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
|
360
|
+
fontWeight: "bold",
|
361
|
+
fontSize: 1,
|
360
362
|
as: "label",
|
361
363
|
display: "block",
|
362
364
|
htmlFor: "autocompleteInput",
|
363
365
|
id: "autocompleteLabel"
|
364
|
-
}, "Pick
|
366
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
365
367
|
id: "autocompleteInput"
|
366
368
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
367
369
|
items: items,
|
@@ -380,12 +382,14 @@ export const AsyncLoadingOfItems = () => {
|
|
380
382
|
}, 1500);
|
381
383
|
};
|
382
384
|
|
383
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
385
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
386
|
+
fontWeight: "bold",
|
387
|
+
fontSize: 1,
|
384
388
|
as: "label",
|
385
389
|
display: "block",
|
386
390
|
htmlFor: "autocompleteInput",
|
387
391
|
id: "autocompleteLabel"
|
388
|
-
}, "Pick
|
392
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
389
393
|
id: "autocompleteInput"
|
390
394
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, null, /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
391
395
|
items: loadedItems,
|
@@ -396,12 +400,14 @@ export const AsyncLoadingOfItems = () => {
|
|
396
400
|
}))));
|
397
401
|
};
|
398
402
|
export const RenderingTheMenuOutsideAnOverlay = () => {
|
399
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
403
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
404
|
+
fontWeight: "bold",
|
405
|
+
fontSize: 1,
|
400
406
|
as: "label",
|
401
407
|
display: "block",
|
402
408
|
htmlFor: "autocompleteInput",
|
403
409
|
id: "autocompleteLabel"
|
404
|
-
}, "Pick
|
410
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
405
411
|
id: "autocompleteInput"
|
406
412
|
}), /*#__PURE__*/React.createElement(Autocomplete.Menu, {
|
407
413
|
items: items,
|
@@ -420,11 +426,14 @@ export const CustomOverlayMenuAnchor = () => {
|
|
420
426
|
border: '1px solid black',
|
421
427
|
padding: '1em'
|
422
428
|
};
|
423
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
429
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
430
|
+
fontWeight: "bold",
|
431
|
+
fontSize: 1,
|
424
432
|
as: "label",
|
433
|
+
display: "block",
|
425
434
|
htmlFor: "autocompleteInput",
|
426
435
|
id: "autocompleteLabel"
|
427
|
-
}, "Pick
|
436
|
+
}, "Pick tags"), /*#__PURE__*/React.createElement(Box, _extends({}, anchorWrapperStyles, {
|
428
437
|
ref: menuAnchorRef
|
429
438
|
}), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
430
439
|
as: TextInput,
|
@@ -452,12 +461,14 @@ export const CustomOverlayMenuAnchor = () => {
|
|
452
461
|
}, "The overlay menu's position is anchored to the div with the black border instead of to the text input"));
|
453
462
|
};
|
454
463
|
export const WithCustomOverlayProps = () => {
|
455
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
464
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Text, {
|
465
|
+
fontWeight: "bold",
|
466
|
+
fontSize: 1,
|
456
467
|
as: "label",
|
457
468
|
display: "block",
|
458
469
|
htmlFor: "autocompleteInput",
|
459
470
|
id: "autocompleteLabel"
|
460
|
-
}, "Pick
|
471
|
+
}, "Pick a tag"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Autocomplete.Input, {
|
461
472
|
id: "autocompleteInput"
|
462
473
|
}), /*#__PURE__*/React.createElement(Autocomplete.Overlay, {
|
463
474
|
overlayProps: {
|
@@ -508,7 +519,7 @@ export const InOverlayWithCustomScrollContainerRef = () => {
|
|
508
519
|
whiteSpace: 'nowrap',
|
509
520
|
borderWidth: '0'
|
510
521
|
}
|
511
|
-
}, "Pick
|
522
|
+
}, "Pick tags"), /*#__PURE__*/React.createElement(Autocomplete, null, /*#__PURE__*/React.createElement(Box, {
|
512
523
|
display: "flex",
|
513
524
|
flexDirection: "column",
|
514
525
|
height: "100%"
|
@@ -52,6 +52,14 @@ export const buttonGroup = args => /*#__PURE__*/React.createElement(ButtonGroup,
|
|
52
52
|
buttonGroup.displayName = "buttonGroup";
|
53
53
|
export const buttonTableList = args => /*#__PURE__*/React.createElement(ButtonTableList, args, "Button Table List");
|
54
54
|
buttonTableList.displayName = "buttonTableList";
|
55
|
+
export const disabledButton = args => {
|
56
|
+
const props = {
|
57
|
+
disabled: true,
|
58
|
+
...args
|
59
|
+
};
|
60
|
+
return /*#__PURE__*/React.createElement(Button, props, "Disabled");
|
61
|
+
};
|
62
|
+
disabledButton.displayName = "disabledButton";
|
55
63
|
defaultButton.args = {
|
56
64
|
variant: 'medium'
|
57
65
|
};
|
@@ -117,7 +117,7 @@ export const UseAnchoredPosition = args => {
|
|
117
117
|
anchorOffset: args.anchorOffset && parseInt(args.anchorOffset, 10),
|
118
118
|
alignmentOffset: args.alignmentOffset && parseInt(args.alignmentOffset, 10),
|
119
119
|
allowOutOfBounds: (_args$allowOutOfBound = args.allowOutOfBounds) !== null && _args$allowOutOfBound !== void 0 ? _args$allowOutOfBound : undefined
|
120
|
-
}, [args]);
|
120
|
+
}, [args.anchorY, args.anchorX, args.anchorPosition, args.anchorSide, args.anchorAlignment, args.anchorOffset, args.alignmentOffset, args.allowOutOfBounds, args.floatHeight, args.floatWidth]);
|
121
121
|
return /*#__PURE__*/React.createElement(Box, {
|
122
122
|
position: "relative",
|
123
123
|
m: 2
|