@primer/react 0.0.0-20260220144011 → 0.0.0-20260220144739
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 +6 -2
- package/dist/Autocomplete/Autocomplete.js +76 -159
- package/dist/Autocomplete/AutocompleteMenu.js +128 -333
- package/dist/Autocomplete/AutocompleteOverlay.js +49 -130
- package/dist/Banner/Banner.js +64 -238
- package/dist/Button/Button.js +11 -34
- package/dist/Button/IconButton.js +51 -140
- package/dist/Button/LinkButton.js +11 -39
- package/dist/Checkbox/Checkbox.js +55 -163
- package/dist/Dialog/Dialog.js +105 -347
- package/dist/PageLayout/PageLayout.js +622 -1560
- package/dist/UnderlineNav/UnderlineNavItem.js +56 -149
- package/dist/experimental/SelectPanel2/SelectPanel.js +209 -593
- package/dist/hooks/useRefObjectAsForwardedRef.d.ts.map +1 -1
- package/dist/hooks/useRefObjectAsForwardedRef.js +10 -2
- package/dist/hooks/useScrollFlash.js +17 -27
- package/dist/hooks/useSlots.d.ts +50 -6
- package/dist/hooks/useSlots.d.ts.map +1 -1
- package/dist/hooks/useSlots.js +114 -36
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { c } from 'react-compiler-runtime';
|
|
2
1
|
import React, { useState, useEffect } from 'react';
|
|
3
|
-
import { AlertIcon,
|
|
2
|
+
import { AlertIcon, SearchIcon, XCircleFillIcon, ArrowLeftIcon, FilterRemoveIcon, XIcon } from '@primer/octicons-react';
|
|
4
3
|
import { ActionListContainerContext } from '../../ActionList/ActionListContainerContext.js';
|
|
5
4
|
import { useSlots } from '../../hooks/useSlots.js';
|
|
6
5
|
import { BaseOverlay, heightMap } from '../../Overlay/Overlay.js';
|
|
@@ -16,14 +15,14 @@ import { useId } from '../../hooks/useId.js';
|
|
|
16
15
|
import { useAnchoredPosition } from '../../hooks/useAnchoredPosition.js';
|
|
17
16
|
import { AriaStatus } from '../../live-region/AriaStatus.js';
|
|
18
17
|
import Octicon from '../../Octicon/Octicon.js';
|
|
18
|
+
import Spinner from '../../Spinner/Spinner.js';
|
|
19
|
+
import { ButtonComponent } from '../../Button/Button.js';
|
|
19
20
|
import TextInput from '../../TextInput/TextInput.js';
|
|
21
|
+
import { IconButton } from '../../Button/IconButton.js';
|
|
22
|
+
import Heading from '../../Heading/Heading.js';
|
|
20
23
|
import { useFormControlForwardedProps } from '../../FormControl/_FormControlContext.js';
|
|
21
|
-
import { ButtonComponent } from '../../Button/Button.js';
|
|
22
24
|
import Link from '../../Link/Link.js';
|
|
23
25
|
import Checkbox from '../../Checkbox/Checkbox.js';
|
|
24
|
-
import { IconButton } from '../../Button/IconButton.js';
|
|
25
|
-
import Heading from '../../Heading/Heading.js';
|
|
26
|
-
import Spinner from '../../Spinner/Spinner.js';
|
|
27
26
|
|
|
28
27
|
const SelectPanelContext = /*#__PURE__*/React.createContext({
|
|
29
28
|
title: '',
|
|
@@ -114,10 +113,10 @@ const Panel = ({
|
|
|
114
113
|
const onInternalClearSelection = () => {
|
|
115
114
|
if (typeof propsOnClearSelection === 'function') propsOnClearSelection();
|
|
116
115
|
};
|
|
117
|
-
const internalAfterSelect =
|
|
116
|
+
const internalAfterSelect = event => {
|
|
118
117
|
if (selectionVariant === 'instant') onInternalSubmit();
|
|
119
|
-
if (
|
|
120
|
-
if (
|
|
118
|
+
if (event.type === 'keypress') {
|
|
119
|
+
if (event.key === 'Enter') onInternalSubmit();
|
|
121
120
|
}
|
|
122
121
|
};
|
|
123
122
|
|
|
@@ -159,12 +158,12 @@ const Panel = ({
|
|
|
159
158
|
|
|
160
159
|
// Esc handler
|
|
161
160
|
React.useEffect(() => {
|
|
162
|
-
const
|
|
163
|
-
const handler =
|
|
164
|
-
if (
|
|
161
|
+
const dialogEl = dialogRef.current;
|
|
162
|
+
const handler = event => {
|
|
163
|
+
if (event.key === 'Escape') onInternalCancel();
|
|
165
164
|
};
|
|
166
|
-
|
|
167
|
-
return () =>
|
|
165
|
+
dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.addEventListener('keydown', handler);
|
|
166
|
+
return () => dialogEl === null || dialogEl === void 0 ? void 0 : dialogEl.removeEventListener('keydown', handler);
|
|
168
167
|
}, [onInternalCancel]);
|
|
169
168
|
|
|
170
169
|
// Autofocus hack: React doesn't support autoFocus for dialog: https://github.com/facebook/react/issues/23301
|
|
@@ -218,8 +217,8 @@ const Panel = ({
|
|
|
218
217
|
},
|
|
219
218
|
className: clsx(classes.Overlay, className),
|
|
220
219
|
...props,
|
|
221
|
-
onClick:
|
|
222
|
-
if (
|
|
220
|
+
onClick: event => {
|
|
221
|
+
if (event.target === event.currentTarget) onClickOutside();
|
|
223
222
|
},
|
|
224
223
|
children: internalOpen && /*#__PURE__*/jsx(Fragment, {
|
|
225
224
|
children: /*#__PURE__*/jsx(SelectPanelContext.Provider, {
|
|
@@ -287,40 +286,15 @@ const SelectPanelButton = /*#__PURE__*/React.forwardRef((props, anchorRef) => {
|
|
|
287
286
|
}
|
|
288
287
|
});
|
|
289
288
|
SelectPanelButton.__SLOT__ = Symbol('SelectPanel.Button');
|
|
290
|
-
const SelectPanelHeader =
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
onBack,
|
|
300
|
-
className,
|
|
301
|
-
...props
|
|
302
|
-
} = t0);
|
|
303
|
-
$[0] = t0;
|
|
304
|
-
$[1] = children;
|
|
305
|
-
$[2] = className;
|
|
306
|
-
$[3] = onBack;
|
|
307
|
-
$[4] = props;
|
|
308
|
-
} else {
|
|
309
|
-
children = $[1];
|
|
310
|
-
className = $[2];
|
|
311
|
-
onBack = $[3];
|
|
312
|
-
props = $[4];
|
|
313
|
-
}
|
|
314
|
-
let t1;
|
|
315
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
316
|
-
t1 = {
|
|
317
|
-
searchInput: SelectPanelSearchInput
|
|
318
|
-
};
|
|
319
|
-
$[5] = t1;
|
|
320
|
-
} else {
|
|
321
|
-
t1 = $[5];
|
|
322
|
-
}
|
|
323
|
-
const [slots, childrenWithoutSlots] = useSlots(children, t1);
|
|
289
|
+
const SelectPanelHeader = ({
|
|
290
|
+
children,
|
|
291
|
+
onBack,
|
|
292
|
+
className,
|
|
293
|
+
...props
|
|
294
|
+
}) => {
|
|
295
|
+
const [slots, childrenWithoutSlots] = useSlots(children, {
|
|
296
|
+
searchInput: SelectPanelSearchInput
|
|
297
|
+
});
|
|
324
298
|
const {
|
|
325
299
|
title,
|
|
326
300
|
description,
|
|
@@ -328,604 +302,246 @@ const SelectPanelHeader = t0 => {
|
|
|
328
302
|
onCancel,
|
|
329
303
|
onClearSelection
|
|
330
304
|
} = React.useContext(SelectPanelContext);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
$[7] = t2;
|
|
336
|
-
} else {
|
|
337
|
-
t2 = $[7];
|
|
338
|
-
}
|
|
339
|
-
const t3 = description ? true : undefined;
|
|
340
|
-
const t4 = slots.searchInput ? true : undefined;
|
|
341
|
-
let t5;
|
|
342
|
-
if ($[8] !== onBack) {
|
|
343
|
-
t5 = onBack ? /*#__PURE__*/jsx(IconButton, {
|
|
344
|
-
type: "button",
|
|
345
|
-
variant: "invisible",
|
|
346
|
-
icon: ArrowLeftIcon,
|
|
347
|
-
"aria-label": "Back",
|
|
348
|
-
onClick: () => onBack()
|
|
349
|
-
}) : null;
|
|
350
|
-
$[8] = onBack;
|
|
351
|
-
$[9] = t5;
|
|
352
|
-
} else {
|
|
353
|
-
t5 = $[9];
|
|
354
|
-
}
|
|
355
|
-
const t6 = description ? true : undefined;
|
|
356
|
-
const t7 = onBack ? true : undefined;
|
|
357
|
-
const t8 = `${panelId}--title`;
|
|
358
|
-
let t9;
|
|
359
|
-
if ($[10] !== t8 || $[11] !== title) {
|
|
360
|
-
t9 = /*#__PURE__*/jsx(Heading, {
|
|
361
|
-
as: "h1",
|
|
362
|
-
id: t8,
|
|
363
|
-
className: classes.Title,
|
|
364
|
-
children: title
|
|
365
|
-
});
|
|
366
|
-
$[10] = t8;
|
|
367
|
-
$[11] = title;
|
|
368
|
-
$[12] = t9;
|
|
369
|
-
} else {
|
|
370
|
-
t9 = $[12];
|
|
371
|
-
}
|
|
372
|
-
let t10;
|
|
373
|
-
if ($[13] !== description || $[14] !== panelId) {
|
|
374
|
-
t10 = description ? /*#__PURE__*/jsx("span", {
|
|
375
|
-
id: `${panelId}--description`,
|
|
376
|
-
className: classes.Description,
|
|
377
|
-
children: description
|
|
378
|
-
}) : null;
|
|
379
|
-
$[13] = description;
|
|
380
|
-
$[14] = panelId;
|
|
381
|
-
$[15] = t10;
|
|
382
|
-
} else {
|
|
383
|
-
t10 = $[15];
|
|
384
|
-
}
|
|
385
|
-
let t11;
|
|
386
|
-
if ($[16] !== t10 || $[17] !== t6 || $[18] !== t7 || $[19] !== t9) {
|
|
387
|
-
t11 = /*#__PURE__*/jsxs("div", {
|
|
388
|
-
className: classes.TitleWrapper,
|
|
389
|
-
"data-description": t6,
|
|
390
|
-
"data-on-back": t7,
|
|
391
|
-
children: [t9, t10]
|
|
392
|
-
});
|
|
393
|
-
$[16] = t10;
|
|
394
|
-
$[17] = t6;
|
|
395
|
-
$[18] = t7;
|
|
396
|
-
$[19] = t9;
|
|
397
|
-
$[20] = t11;
|
|
398
|
-
} else {
|
|
399
|
-
t11 = $[20];
|
|
400
|
-
}
|
|
401
|
-
let t12;
|
|
402
|
-
if ($[21] !== t11 || $[22] !== t5) {
|
|
403
|
-
t12 = /*#__PURE__*/jsxs("div", {
|
|
404
|
-
className: classes.FlexBox,
|
|
405
|
-
children: [t5, t11]
|
|
406
|
-
});
|
|
407
|
-
$[21] = t11;
|
|
408
|
-
$[22] = t5;
|
|
409
|
-
$[23] = t12;
|
|
410
|
-
} else {
|
|
411
|
-
t12 = $[23];
|
|
412
|
-
}
|
|
413
|
-
let t13;
|
|
414
|
-
if ($[24] !== onClearSelection) {
|
|
415
|
-
t13 = onClearSelection ? /*#__PURE__*/jsx(IconButton, {
|
|
416
|
-
type: "button",
|
|
417
|
-
variant: "invisible",
|
|
418
|
-
icon: FilterRemoveIcon,
|
|
419
|
-
"aria-label": "Clear selection",
|
|
420
|
-
onClick: onClearSelection
|
|
421
|
-
}) : null;
|
|
422
|
-
$[24] = onClearSelection;
|
|
423
|
-
$[25] = t13;
|
|
424
|
-
} else {
|
|
425
|
-
t13 = $[25];
|
|
426
|
-
}
|
|
427
|
-
let t14;
|
|
428
|
-
if ($[26] !== onCancel) {
|
|
429
|
-
t14 = /*#__PURE__*/jsx(IconButton, {
|
|
430
|
-
type: "button",
|
|
431
|
-
variant: "invisible",
|
|
432
|
-
icon: XIcon,
|
|
433
|
-
"aria-label": "Close",
|
|
434
|
-
onClick: () => onCancel()
|
|
435
|
-
});
|
|
436
|
-
$[26] = onCancel;
|
|
437
|
-
$[27] = t14;
|
|
438
|
-
} else {
|
|
439
|
-
t14 = $[27];
|
|
440
|
-
}
|
|
441
|
-
let t15;
|
|
442
|
-
if ($[28] !== t13 || $[29] !== t14) {
|
|
443
|
-
t15 = /*#__PURE__*/jsxs("div", {
|
|
444
|
-
children: [t13, t14]
|
|
445
|
-
});
|
|
446
|
-
$[28] = t13;
|
|
447
|
-
$[29] = t14;
|
|
448
|
-
$[30] = t15;
|
|
449
|
-
} else {
|
|
450
|
-
t15 = $[30];
|
|
451
|
-
}
|
|
452
|
-
let t16;
|
|
453
|
-
if ($[31] !== t12 || $[32] !== t15 || $[33] !== t3 || $[34] !== t4) {
|
|
454
|
-
t16 = /*#__PURE__*/jsxs("div", {
|
|
305
|
+
return /*#__PURE__*/jsxs("div", {
|
|
306
|
+
className: clsx(classes.Header, className),
|
|
307
|
+
...props,
|
|
308
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
455
309
|
className: classes.HeaderContent,
|
|
456
|
-
"data-description":
|
|
457
|
-
"data-search-input":
|
|
458
|
-
children: [
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
310
|
+
"data-description": description ? true : undefined,
|
|
311
|
+
"data-search-input": slots.searchInput ? true : undefined,
|
|
312
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
313
|
+
className: classes.FlexBox,
|
|
314
|
+
children: [onBack ? /*#__PURE__*/jsx(IconButton, {
|
|
315
|
+
type: "button",
|
|
316
|
+
variant: "invisible",
|
|
317
|
+
icon: ArrowLeftIcon,
|
|
318
|
+
"aria-label": "Back",
|
|
319
|
+
onClick: () => onBack()
|
|
320
|
+
}) : null, /*#__PURE__*/jsxs("div", {
|
|
321
|
+
className: classes.TitleWrapper,
|
|
322
|
+
"data-description": description ? true : undefined,
|
|
323
|
+
"data-on-back": onBack ? true : undefined,
|
|
324
|
+
children: [/*#__PURE__*/jsx(Heading, {
|
|
325
|
+
as: "h1",
|
|
326
|
+
id: `${panelId}--title`,
|
|
327
|
+
className: classes.Title,
|
|
328
|
+
children: title
|
|
329
|
+
}), description ? /*#__PURE__*/jsx("span", {
|
|
330
|
+
id: `${panelId}--description`,
|
|
331
|
+
className: classes.Description,
|
|
332
|
+
children: description
|
|
333
|
+
}) : null]
|
|
334
|
+
})]
|
|
335
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
336
|
+
children: [onClearSelection ? /*#__PURE__*/jsx(IconButton, {
|
|
337
|
+
type: "button",
|
|
338
|
+
variant: "invisible",
|
|
339
|
+
icon: FilterRemoveIcon,
|
|
340
|
+
"aria-label": "Clear selection",
|
|
341
|
+
onClick: onClearSelection
|
|
342
|
+
}) : null, /*#__PURE__*/jsx(IconButton, {
|
|
343
|
+
type: "button",
|
|
344
|
+
variant: "invisible",
|
|
345
|
+
icon: XIcon,
|
|
346
|
+
"aria-label": "Close",
|
|
347
|
+
onClick: () => onCancel()
|
|
348
|
+
})]
|
|
349
|
+
})]
|
|
350
|
+
}), slots.searchInput, childrenWithoutSlots]
|
|
351
|
+
});
|
|
485
352
|
};
|
|
353
|
+
SelectPanelHeader.displayName = "SelectPanelHeader";
|
|
486
354
|
SelectPanelHeader.__SLOT__ = Symbol('SelectPanel.Header');
|
|
487
|
-
const SelectPanelSearchInput =
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
onChange: propsOnChange,
|
|
496
|
-
onKeyDown: propsOnKeyDown,
|
|
497
|
-
className,
|
|
498
|
-
...props
|
|
499
|
-
} = t0);
|
|
500
|
-
$[0] = t0;
|
|
501
|
-
$[1] = className;
|
|
502
|
-
$[2] = props;
|
|
503
|
-
$[3] = propsOnChange;
|
|
504
|
-
$[4] = propsOnKeyDown;
|
|
505
|
-
} else {
|
|
506
|
-
className = $[1];
|
|
507
|
-
props = $[2];
|
|
508
|
-
propsOnChange = $[3];
|
|
509
|
-
propsOnKeyDown = $[4];
|
|
510
|
-
}
|
|
511
|
-
let t1;
|
|
512
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
513
|
-
t1 = /*#__PURE__*/React.createRef();
|
|
514
|
-
$[5] = t1;
|
|
515
|
-
} else {
|
|
516
|
-
t1 = $[5];
|
|
517
|
-
}
|
|
518
|
-
const inputRef = t1;
|
|
355
|
+
const SelectPanelSearchInput = ({
|
|
356
|
+
onChange: propsOnChange,
|
|
357
|
+
onKeyDown: propsOnKeyDown,
|
|
358
|
+
className,
|
|
359
|
+
...props
|
|
360
|
+
}) => {
|
|
361
|
+
// TODO: use forwardedRef
|
|
362
|
+
const inputRef = /*#__PURE__*/React.createRef();
|
|
519
363
|
const {
|
|
520
364
|
setSearchQuery,
|
|
521
365
|
moveFocusToList
|
|
522
366
|
} = React.useContext(SelectPanelContext);
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
t3 = event_0 => {
|
|
542
|
-
if (event_0.key === "ArrowDown") {
|
|
543
|
-
event_0.preventDefault();
|
|
544
|
-
moveFocusToList();
|
|
545
|
-
}
|
|
546
|
-
if (typeof propsOnKeyDown === "function") {
|
|
547
|
-
propsOnKeyDown(event_0);
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
$[9] = moveFocusToList;
|
|
551
|
-
$[10] = propsOnKeyDown;
|
|
552
|
-
$[11] = t3;
|
|
553
|
-
} else {
|
|
554
|
-
t3 = $[11];
|
|
555
|
-
}
|
|
556
|
-
const internalKeyDown = t3;
|
|
557
|
-
let t4;
|
|
558
|
-
if ($[12] !== propsOnChange) {
|
|
559
|
-
t4 = /*#__PURE__*/jsx(TextInput.Action, {
|
|
367
|
+
const internalOnChange = event => {
|
|
368
|
+
// If props.onChange is given, the application controls search,
|
|
369
|
+
// otherwise the component does
|
|
370
|
+
if (typeof propsOnChange === 'function') propsOnChange(event);else setSearchQuery(event.target.value);
|
|
371
|
+
};
|
|
372
|
+
const internalKeyDown = event => {
|
|
373
|
+
if (event.key === 'ArrowDown') {
|
|
374
|
+
event.preventDefault(); // prevent scroll
|
|
375
|
+
moveFocusToList();
|
|
376
|
+
}
|
|
377
|
+
if (typeof propsOnKeyDown === 'function') propsOnKeyDown(event);
|
|
378
|
+
};
|
|
379
|
+
return /*#__PURE__*/jsx(TextInput, {
|
|
380
|
+
ref: inputRef,
|
|
381
|
+
block: true,
|
|
382
|
+
leadingVisual: SearchIcon,
|
|
383
|
+
placeholder: "Search",
|
|
384
|
+
trailingAction: /*#__PURE__*/jsx(TextInput.Action, {
|
|
560
385
|
icon: XCircleFillIcon,
|
|
561
386
|
"aria-label": "Clear",
|
|
562
387
|
tooltipDirection: "w",
|
|
563
388
|
className: classes.ClearAction,
|
|
564
389
|
onClick: () => {
|
|
565
|
-
if (inputRef.current)
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (typeof propsOnChange === "function") {
|
|
390
|
+
if (inputRef.current) inputRef.current.value = '';
|
|
391
|
+
if (typeof propsOnChange === 'function') {
|
|
392
|
+
// @ts-ignore TODO this is a hacky solution to clear
|
|
569
393
|
propsOnChange({
|
|
570
394
|
target: inputRef.current,
|
|
571
395
|
currentTarget: inputRef.current
|
|
572
396
|
});
|
|
573
397
|
}
|
|
574
398
|
}
|
|
575
|
-
})
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
let t5;
|
|
582
|
-
if ($[14] !== className) {
|
|
583
|
-
t5 = clsx(classes.TextInput, className);
|
|
584
|
-
$[14] = className;
|
|
585
|
-
$[15] = t5;
|
|
586
|
-
} else {
|
|
587
|
-
t5 = $[15];
|
|
588
|
-
}
|
|
589
|
-
let t6;
|
|
590
|
-
if ($[16] !== internalKeyDown || $[17] !== internalOnChange || $[18] !== props || $[19] !== t4 || $[20] !== t5) {
|
|
591
|
-
t6 = /*#__PURE__*/jsx(TextInput, {
|
|
592
|
-
ref: inputRef,
|
|
593
|
-
block: true,
|
|
594
|
-
leadingVisual: SearchIcon,
|
|
595
|
-
placeholder: "Search",
|
|
596
|
-
trailingAction: t4,
|
|
597
|
-
className: t5,
|
|
598
|
-
onChange: internalOnChange,
|
|
599
|
-
onKeyDown: internalKeyDown,
|
|
600
|
-
...props
|
|
601
|
-
});
|
|
602
|
-
$[16] = internalKeyDown;
|
|
603
|
-
$[17] = internalOnChange;
|
|
604
|
-
$[18] = props;
|
|
605
|
-
$[19] = t4;
|
|
606
|
-
$[20] = t5;
|
|
607
|
-
$[21] = t6;
|
|
608
|
-
} else {
|
|
609
|
-
t6 = $[21];
|
|
610
|
-
}
|
|
611
|
-
return t6;
|
|
399
|
+
}),
|
|
400
|
+
className: clsx(classes.TextInput, className),
|
|
401
|
+
onChange: internalOnChange,
|
|
402
|
+
onKeyDown: internalKeyDown,
|
|
403
|
+
...props
|
|
404
|
+
});
|
|
612
405
|
};
|
|
406
|
+
SelectPanelSearchInput.displayName = "SelectPanelSearchInput";
|
|
613
407
|
SelectPanelSearchInput.__SLOT__ = Symbol('SelectPanel.SearchInput');
|
|
614
408
|
const FooterContext = /*#__PURE__*/React.createContext(false);
|
|
615
|
-
const SelectPanelFooter =
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
if ($[0] !== t0) {
|
|
619
|
-
({
|
|
620
|
-
...props
|
|
621
|
-
} = t0);
|
|
622
|
-
$[0] = t0;
|
|
623
|
-
$[1] = props;
|
|
624
|
-
} else {
|
|
625
|
-
props = $[1];
|
|
626
|
-
}
|
|
409
|
+
const SelectPanelFooter = ({
|
|
410
|
+
...props
|
|
411
|
+
}) => {
|
|
627
412
|
const {
|
|
628
413
|
onCancel,
|
|
629
414
|
selectionVariant
|
|
630
415
|
} = React.useContext(SelectPanelContext);
|
|
631
|
-
const hidePrimaryActions = selectionVariant ===
|
|
632
|
-
const buttonSize = useResponsiveValue(responsiveButtonSizes,
|
|
416
|
+
const hidePrimaryActions = selectionVariant === 'instant';
|
|
417
|
+
const buttonSize = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
633
418
|
if (hidePrimaryActions && !props.children) {
|
|
419
|
+
// nothing to render
|
|
420
|
+
// todo: we can inform them the developer footer will render nothing
|
|
634
421
|
return null;
|
|
635
422
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
onClick: () => onCancel(),
|
|
659
|
-
children: "Cancel"
|
|
660
|
-
}), /*#__PURE__*/jsx(ButtonComponent, {
|
|
661
|
-
type: "submit",
|
|
662
|
-
size: buttonSize,
|
|
663
|
-
variant: "primary",
|
|
664
|
-
children: "Save"
|
|
423
|
+
return /*#__PURE__*/jsx(FooterContext.Provider, {
|
|
424
|
+
value: true,
|
|
425
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
426
|
+
className: classes.Footer,
|
|
427
|
+
"data-hide-primary-actions": hidePrimaryActions || undefined,
|
|
428
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
429
|
+
className: classes.FooterContent,
|
|
430
|
+
"data-hide-primary-actions": hidePrimaryActions || undefined,
|
|
431
|
+
children: props.children
|
|
432
|
+
}), hidePrimaryActions ? null : /*#__PURE__*/jsxs("div", {
|
|
433
|
+
className: classes.FooterActions,
|
|
434
|
+
children: [/*#__PURE__*/jsx(ButtonComponent, {
|
|
435
|
+
type: "button",
|
|
436
|
+
size: buttonSize,
|
|
437
|
+
onClick: () => onCancel(),
|
|
438
|
+
children: "Cancel"
|
|
439
|
+
}), /*#__PURE__*/jsx(ButtonComponent, {
|
|
440
|
+
type: "submit",
|
|
441
|
+
size: buttonSize,
|
|
442
|
+
variant: "primary",
|
|
443
|
+
children: "Save"
|
|
444
|
+
})]
|
|
665
445
|
})]
|
|
666
|
-
})
|
|
667
|
-
|
|
668
|
-
$[6] = hidePrimaryActions;
|
|
669
|
-
$[7] = onCancel;
|
|
670
|
-
$[8] = t4;
|
|
671
|
-
} else {
|
|
672
|
-
t4 = $[8];
|
|
673
|
-
}
|
|
674
|
-
let t5;
|
|
675
|
-
if ($[9] !== t1 || $[10] !== t3 || $[11] !== t4) {
|
|
676
|
-
t5 = /*#__PURE__*/jsx(FooterContext.Provider, {
|
|
677
|
-
value: true,
|
|
678
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
679
|
-
className: classes.Footer,
|
|
680
|
-
"data-hide-primary-actions": t1,
|
|
681
|
-
children: [t3, t4]
|
|
682
|
-
})
|
|
683
|
-
});
|
|
684
|
-
$[9] = t1;
|
|
685
|
-
$[10] = t3;
|
|
686
|
-
$[11] = t4;
|
|
687
|
-
$[12] = t5;
|
|
688
|
-
} else {
|
|
689
|
-
t5 = $[12];
|
|
690
|
-
}
|
|
691
|
-
return t5;
|
|
446
|
+
})
|
|
447
|
+
});
|
|
692
448
|
};
|
|
449
|
+
SelectPanelFooter.displayName = "SelectPanelFooter";
|
|
693
450
|
SelectPanelFooter.__SLOT__ = Symbol('SelectPanel.Footer');
|
|
694
451
|
const SecondaryButton = props => {
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
block: true,
|
|
703
|
-
...props
|
|
704
|
-
});
|
|
705
|
-
$[0] = props;
|
|
706
|
-
$[1] = size;
|
|
707
|
-
$[2] = t0;
|
|
708
|
-
} else {
|
|
709
|
-
t0 = $[2];
|
|
710
|
-
}
|
|
711
|
-
return t0;
|
|
452
|
+
const size = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
453
|
+
return /*#__PURE__*/jsx(ButtonComponent, {
|
|
454
|
+
type: "button",
|
|
455
|
+
size: size,
|
|
456
|
+
block: true,
|
|
457
|
+
...props
|
|
458
|
+
});
|
|
712
459
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
$[1] = className;
|
|
724
|
-
$[2] = props;
|
|
725
|
-
} else {
|
|
726
|
-
className = $[1];
|
|
727
|
-
props = $[2];
|
|
728
|
-
}
|
|
729
|
-
const size = useResponsiveValue(responsiveButtonSizes, "small");
|
|
730
|
-
let t1;
|
|
731
|
-
if ($[3] !== className) {
|
|
732
|
-
t1 = clsx(classes.SmallText, className);
|
|
733
|
-
$[3] = className;
|
|
734
|
-
$[4] = t1;
|
|
735
|
-
} else {
|
|
736
|
-
t1 = $[4];
|
|
737
|
-
}
|
|
738
|
-
let t2;
|
|
739
|
-
if ($[5] !== props || $[6] !== size || $[7] !== t1) {
|
|
740
|
-
t2 = /*#__PURE__*/jsx(ButtonComponent, {
|
|
460
|
+
SecondaryButton.displayName = "SecondaryButton";
|
|
461
|
+
const SecondaryLink = ({
|
|
462
|
+
className,
|
|
463
|
+
...props
|
|
464
|
+
}) => {
|
|
465
|
+
const size = useResponsiveValue(responsiveButtonSizes, 'small');
|
|
466
|
+
return (
|
|
467
|
+
/*#__PURE__*/
|
|
468
|
+
// @ts-ignore TODO: is as prop is not recognised by button?
|
|
469
|
+
jsx(ButtonComponent, {
|
|
741
470
|
as: Link,
|
|
742
471
|
size: size,
|
|
743
472
|
variant: "invisible",
|
|
744
473
|
block: true,
|
|
745
474
|
...props,
|
|
746
|
-
className:
|
|
475
|
+
className: clsx(classes.SmallText, className),
|
|
747
476
|
children: props.children
|
|
748
|
-
})
|
|
749
|
-
|
|
750
|
-
$[6] = size;
|
|
751
|
-
$[7] = t1;
|
|
752
|
-
$[8] = t2;
|
|
753
|
-
} else {
|
|
754
|
-
t2 = $[8];
|
|
755
|
-
}
|
|
756
|
-
return t2;
|
|
477
|
+
})
|
|
478
|
+
);
|
|
757
479
|
};
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
({
|
|
766
|
-
id,
|
|
767
|
-
children,
|
|
768
|
-
className,
|
|
769
|
-
...props
|
|
770
|
-
} = t0);
|
|
771
|
-
$[0] = t0;
|
|
772
|
-
$[1] = children;
|
|
773
|
-
$[2] = className;
|
|
774
|
-
$[3] = id;
|
|
775
|
-
$[4] = props;
|
|
776
|
-
} else {
|
|
777
|
-
children = $[1];
|
|
778
|
-
className = $[2];
|
|
779
|
-
id = $[3];
|
|
780
|
-
props = $[4];
|
|
781
|
-
}
|
|
480
|
+
SecondaryLink.displayName = "SecondaryLink";
|
|
481
|
+
const SecondaryCheckbox = ({
|
|
482
|
+
id,
|
|
483
|
+
children,
|
|
484
|
+
className,
|
|
485
|
+
...props
|
|
486
|
+
}) => {
|
|
782
487
|
const checkboxId = useId(id);
|
|
783
488
|
const {
|
|
784
489
|
selectionVariant
|
|
785
490
|
} = React.useContext(SelectPanelContext);
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
} else {
|
|
793
|
-
t1 = $[6];
|
|
794
|
-
}
|
|
795
|
-
let t2;
|
|
796
|
-
if ($[7] !== checkboxId || $[8] !== props || $[9] !== t1) {
|
|
797
|
-
t2 = /*#__PURE__*/jsx(Checkbox, {
|
|
491
|
+
|
|
492
|
+
// Checkbox should not be used with instant selection
|
|
493
|
+
!(selectionVariant !== 'instant') ? process.env.NODE_ENV !== "production" ? invariant(false, 'Sorry! SelectPanel.SecondaryAction with variant="checkbox" is not allowed inside selectionVariant="instant"') : invariant(false) : void 0;
|
|
494
|
+
return /*#__PURE__*/jsxs("div", {
|
|
495
|
+
className: classes.SecondaryCheckbox,
|
|
496
|
+
children: [/*#__PURE__*/jsx(Checkbox, {
|
|
798
497
|
id: checkboxId,
|
|
799
|
-
className:
|
|
498
|
+
className: clsx(classes.Checkbox, className),
|
|
800
499
|
...props
|
|
801
|
-
})
|
|
802
|
-
$[7] = checkboxId;
|
|
803
|
-
$[8] = props;
|
|
804
|
-
$[9] = t1;
|
|
805
|
-
$[10] = t2;
|
|
806
|
-
} else {
|
|
807
|
-
t2 = $[10];
|
|
808
|
-
}
|
|
809
|
-
let t3;
|
|
810
|
-
if ($[11] !== checkboxId || $[12] !== children) {
|
|
811
|
-
t3 = /*#__PURE__*/jsx(InputLabel, {
|
|
500
|
+
}), /*#__PURE__*/jsx(InputLabel, {
|
|
812
501
|
htmlFor: checkboxId,
|
|
813
502
|
className: classes.SmallText,
|
|
814
503
|
children: children
|
|
815
|
-
})
|
|
816
|
-
|
|
817
|
-
$[12] = children;
|
|
818
|
-
$[13] = t3;
|
|
819
|
-
} else {
|
|
820
|
-
t3 = $[13];
|
|
821
|
-
}
|
|
822
|
-
let t4;
|
|
823
|
-
if ($[14] !== t2 || $[15] !== t3) {
|
|
824
|
-
t4 = /*#__PURE__*/jsxs("div", {
|
|
825
|
-
className: classes.SecondaryCheckbox,
|
|
826
|
-
children: [t2, t3]
|
|
827
|
-
});
|
|
828
|
-
$[14] = t2;
|
|
829
|
-
$[15] = t3;
|
|
830
|
-
$[16] = t4;
|
|
831
|
-
} else {
|
|
832
|
-
t4 = $[16];
|
|
833
|
-
}
|
|
834
|
-
return t4;
|
|
504
|
+
})]
|
|
505
|
+
});
|
|
835
506
|
};
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
({
|
|
842
|
-
variant,
|
|
843
|
-
...props
|
|
844
|
-
} = t0);
|
|
845
|
-
$[0] = t0;
|
|
846
|
-
$[1] = props;
|
|
847
|
-
$[2] = variant;
|
|
848
|
-
} else {
|
|
849
|
-
props = $[1];
|
|
850
|
-
variant = $[2];
|
|
851
|
-
}
|
|
507
|
+
SecondaryCheckbox.displayName = "SecondaryCheckbox";
|
|
508
|
+
const SelectPanelSecondaryAction = ({
|
|
509
|
+
variant,
|
|
510
|
+
...props
|
|
511
|
+
}) => {
|
|
852
512
|
const insideFooter = React.useContext(FooterContext);
|
|
853
|
-
!insideFooter ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
let t1;
|
|
869
|
-
if ($[5] !== props) {
|
|
870
|
-
t1 = /*#__PURE__*/jsx(SecondaryLink, {
|
|
871
|
-
...props
|
|
872
|
-
});
|
|
873
|
-
$[5] = props;
|
|
874
|
-
$[6] = t1;
|
|
875
|
-
} else {
|
|
876
|
-
t1 = $[6];
|
|
877
|
-
}
|
|
878
|
-
return t1;
|
|
879
|
-
} else {
|
|
880
|
-
if (variant === "checkbox") {
|
|
881
|
-
let t1;
|
|
882
|
-
if ($[7] !== props) {
|
|
883
|
-
t1 = /*#__PURE__*/jsx(SecondaryCheckbox, {
|
|
884
|
-
...props
|
|
885
|
-
});
|
|
886
|
-
$[7] = props;
|
|
887
|
-
$[8] = t1;
|
|
888
|
-
} else {
|
|
889
|
-
t1 = $[8];
|
|
890
|
-
}
|
|
891
|
-
return t1;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
513
|
+
!insideFooter ? process.env.NODE_ENV !== "production" ? invariant(false, 'SelectPanel.SecondaryAction is only allowed inside SelectPanel.Footer') : invariant(false) : void 0;
|
|
514
|
+
|
|
515
|
+
// @ts-ignore TODO
|
|
516
|
+
if (variant === 'button') return /*#__PURE__*/jsx(SecondaryButton, {
|
|
517
|
+
...props
|
|
518
|
+
});
|
|
519
|
+
// @ts-ignore TODO
|
|
520
|
+
else if (variant === 'link') return /*#__PURE__*/jsx(SecondaryLink, {
|
|
521
|
+
...props
|
|
522
|
+
});
|
|
523
|
+
// @ts-ignore TODO
|
|
524
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
525
|
+
else if (variant === 'checkbox') return /*#__PURE__*/jsx(SecondaryCheckbox, {
|
|
526
|
+
...props
|
|
527
|
+
});
|
|
895
528
|
};
|
|
896
|
-
const SelectPanelLoading =
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
904
|
-
t2 = /*#__PURE__*/jsx(Spinner, {
|
|
529
|
+
const SelectPanelLoading = ({
|
|
530
|
+
children = 'Fetching items...'
|
|
531
|
+
}) => {
|
|
532
|
+
return /*#__PURE__*/jsxs(AriaStatus, {
|
|
533
|
+
announceOnShow: true,
|
|
534
|
+
className: classes.SelectPanelLoading,
|
|
535
|
+
children: [/*#__PURE__*/jsx(Spinner, {
|
|
905
536
|
size: "medium",
|
|
906
537
|
srText: null
|
|
907
|
-
})
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
}
|
|
912
|
-
let t3;
|
|
913
|
-
if ($[1] !== children) {
|
|
914
|
-
t3 = /*#__PURE__*/jsxs(AriaStatus, {
|
|
915
|
-
announceOnShow: true,
|
|
916
|
-
className: classes.SelectPanelLoading,
|
|
917
|
-
children: [t2, /*#__PURE__*/jsx("span", {
|
|
918
|
-
className: classes.LoadingText,
|
|
919
|
-
children: children
|
|
920
|
-
})]
|
|
921
|
-
});
|
|
922
|
-
$[1] = children;
|
|
923
|
-
$[2] = t3;
|
|
924
|
-
} else {
|
|
925
|
-
t3 = $[2];
|
|
926
|
-
}
|
|
927
|
-
return t3;
|
|
538
|
+
}), /*#__PURE__*/jsx("span", {
|
|
539
|
+
className: classes.LoadingText,
|
|
540
|
+
children: children
|
|
541
|
+
})]
|
|
542
|
+
});
|
|
928
543
|
};
|
|
544
|
+
SelectPanelLoading.displayName = "SelectPanelLoading";
|
|
929
545
|
const SelectPanelMessage = ({
|
|
930
546
|
variant = 'warning',
|
|
931
547
|
size = variant === 'empty' ? 'full' : 'inline',
|