1
- import { AlertIcon , InfoIcon , SearchIcon , StopIcon , TriangleDownIcon , XIcon } from '@primer/octicons-react'
1
+ import { AlertIcon , InfoIcon , SearchIcon , StopIcon , TriangleDownIcon } from '@primer/octicons-react'
2
2
import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react'
3
3
import type { AnchoredOverlayProps } from '../AnchoredOverlay'
4
4
import { AnchoredOverlay } from '../AnchoredOverlay'
@@ -11,7 +11,7 @@ import type {OverlayProps} from '../Overlay'
11
11
import type { TextInputProps } from '../TextInput'
12
12
import type { ItemProps , ItemInput } from './types'
13
13
14
- import { Button , IconButton } from '../Button'
14
+ import { Button } from '../Button'
15
15
import { useProvidedRefOrCreate } from '../hooks'
16
16
import type { FocusZoneHookSettings } from '../hooks/useFocusZone'
17
17
import { useId } from '../hooks/useId'
@@ -22,6 +22,7 @@ import type {FilteredActionListLoadingType} from '../FilteredActionList/Filtered
22
22
import { FilteredActionListLoadingTypes } from '../FilteredActionList/FilteredActionListLoaders'
23
23
import { useFeatureFlag } from '../FeatureFlags'
24
24
import { announce } from '@primer/live-region-element'
25
+
25
26
import classes from './SelectPanel.module.css'
26
27
import { clsx } from 'clsx'
27
28
@@ -131,7 +132,6 @@ interface SelectPanelBaseProps {
131
132
text : string | React . ReactElement
132
133
variant : 'info' | 'warning' | 'error'
133
134
}
134
- onCancel ?: ( ) => void
135
135
}
136
136
137
137
export type SelectPanelProps = SelectPanelBaseProps &
@@ -194,7 +194,6 @@ export function SelectPanel({
194
194
width,
195
195
id,
196
196
notice,
197
- onCancel,
198
197
...listProps
199
198
} : SelectPanelProps ) : JSX . Element {
200
199
const titleId = useId ( )
@@ -358,7 +357,7 @@ export function SelectPanel({
358
357
[ onOpenChange ] ,
359
358
)
360
359
const onClose = useCallback (
361
- ( gesture : Parameters < Exclude < AnchoredOverlayProps [ 'onClose' ] , undefined > > [ 0 ] | 'selection' | 'escape' ) => {
360
+ ( gesture : Parameters < Exclude < AnchoredOverlayProps [ 'onClose' ] , undefined > > [ 0 ] | 'selection' ) => {
362
361
onOpenChange ( false , gesture )
363
362
} ,
364
363
[ onOpenChange ] ,
@@ -466,7 +465,6 @@ export function SelectPanel({
466
465
height = { height }
467
466
width = { width }
468
467
anchorId = { id }
469
- variant = { { regular : 'anchored' , narrow : 'fullscreen' } }
470
468
pinPosition = { ! height }
471
469
>
472
470
< LiveRegionOutlet />
@@ -485,54 +483,24 @@ export function SelectPanel({
485
483
sx = { enabled ? undefined : { display : 'flex' , flexDirection : 'column' , height : 'inherit' , maxHeight : 'inherit' } }
486
484
className = { enabled ? classes . Wrapper : undefined }
487
485
>
488
- < Box
489
- sx = {
490
- enabled
491
- ? undefined
492
- : {
493
- display : 'flex' ,
494
- justifyContent : 'space-between' ,
495
- alignItems : 'center' ,
496
- paddingTop : 2 ,
497
- paddingRight : 2 ,
498
- paddingLeft : 2 ,
499
- }
500
- }
501
- className = { enabled ? classes . Header : undefined }
502
- >
503
- < div >
504
- < Heading
505
- as = "h1"
506
- id = { titleId }
507
- sx = { enabled ? undefined : { fontSize : 1 , marginLeft : 2 } }
508
- className = { enabled ? classes . Title : undefined }
486
+ < Box sx = { enabled ? undefined : { pt : 2 , px : 3 } } className = { enabled ? classes . Content : undefined } >
487
+ < Heading
488
+ as = "h1"
489
+ id = { titleId }
490
+ sx = { enabled ? undefined : { fontSize : 1 } }
491
+ className = { enabled ? classes . Title : undefined }
492
+ >
493
+ { title }
494
+ </ Heading >
495
+ { subtitle ? (
496
+ < Box
497
+ id = { subtitleId }
498
+ sx = { enabled ? undefined : { fontSize : 0 , color : 'fg.muted' } }
499
+ className = { enabled ? classes . Subtitle : undefined }
509
500
>
510
- { title }
511
- </ Heading >
512
- { subtitle ? (
513
- < Box
514
- id = { subtitleId }
515
- sx = { enabled ? undefined : { marginLeft : 2 , fontSize : 0 , color : 'fg.muted' } }
516
- className = { enabled ? classes . Subtitle : undefined }
517
- >
518
- { subtitle }
519
- </ Box >
520
- ) : null }
521
- </ div >
522
- { onCancel && (
523
- < IconButton
524
- type = "button"
525
- variant = "invisible"
526
- icon = { XIcon }
527
- aria-label = "Cancel and close"
528
- sx = { enabled ? undefined : { display : [ 'inline-grid' , 'inline-grid' , 'none' , 'none' ] } }
529
- className = { enabled ? classes . ResponsiveCloseButton : undefined }
530
- onClick = { ( ) => {
531
- onCancel ( )
532
- onClose ( 'escape' )
533
- } }
534
- />
535
- ) }
501
+ { subtitle }
502
+ </ Box >
503
+ ) : null }
536
504
</ Box >
537
505
{ notice && (
538
506
< div aria-live = "polite" data-variant = { notice . variant } className = { classes . Notice } >
@@ -563,7 +531,7 @@ export function SelectPanel({
563
531
className = { enabled ? clsx ( className , classes . FilteredActionList ) : className }
564
532
announcementsEnabled = { false }
565
533
/>
566
- { footer ? (
534
+ { footer && (
567
535
< Box
568
536
sx = {
569
537
enabled
@@ -579,31 +547,7 @@ export function SelectPanel({
579
547
>
580
548
{ footer }
581
549
</ Box >
582
- ) : isMultiSelectVariant ( selected ) ? (
583
- /* Save and Cancel buttons are only useful for multiple selection, single selection instantly closes the panel */
584
- < div className = { clsx ( classes . Footer , classes . ResponsiveFooter ) } >
585
- { /* we add a save and cancel button on narrow screens when SelectPanel is full-screen */ }
586
- { onCancel && (
587
- < Button
588
- size = "medium"
589
- onClick = { ( ) => {
590
- onCancel ( )
591
- onClose ( 'escape' )
592
- } }
593
- >
594
- Cancel
595
- </ Button >
596
- ) }
597
- < Button
598
- variant = "primary"
599
- size = "medium"
600
- block = { onCancel ? false : true }
601
- onClick = { ( ) => onClose ( 'click-outside' ) }
602
- >
603
- Save
604
- </ Button >
605
- </ div >
606
- ) : null }
550
+ ) }
607
551
</ Box >
608
552
</ AnchoredOverlay >
609
553
</ LiveRegion >
0 commit comments