|
6 | 6 | import React, { useEffect, useLayoutEffect, useRef, useState } from 'react'; |
7 | 7 | import { chevronDownIcon } from './icon'; |
8 | 8 |
|
9 | | -interface ContextDropdownProps { |
10 | | - optionsContext: () => string; |
11 | | - defaultOptionLabel: () => string; |
12 | | - defaultOptionValue: () => string; |
13 | | - defaultAction: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; |
14 | | - allOptions?: () => { label: string; value: string; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[]; |
15 | | - optionsTitle: string; |
16 | | - disabled?: boolean; |
17 | | - hasSingleAction?: boolean; |
18 | | - spreadable: boolean; |
19 | | - isSecondary?: boolean; |
| 9 | +interface ContextDropdownProps { |
| 10 | + optionsContext: () => string; |
| 11 | + defaultOptionLabel: () => string | React.ReactNode; |
| 12 | + defaultOptionValue: () => string; |
| 13 | + defaultAction: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; |
| 14 | + allOptions?: () => { label: string; value: string; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[]; |
| 15 | + optionsTitle: string; |
| 16 | + disabled?: boolean; |
| 17 | + hasSingleAction?: boolean; |
| 18 | + spreadable: boolean; |
| 19 | + isSecondary?: boolean; |
20 | 20 | } |
21 | 21 |
|
22 | 22 | function useWindowSize() { |
@@ -59,10 +59,10 @@ export const ContextDropdown = ({ optionsContext, defaultOptionLabel, defaultOpt |
59 | 59 | return <button className='inlined-dropdown' key={value} title={label} disabled={disabled} onClick={action} value={value}>{label}</button>; |
60 | 60 | }) |
61 | 61 | : |
62 | | - <div className='primary-split-button'> |
63 | | - <button className={`split-left${isSecondary ? ' secondary' : ''}`} disabled={disabled} onClick={defaultAction} value={defaultOptionValue()} |
64 | | - title={defaultOptionLabel()}> |
65 | | - {defaultOptionLabel()} |
| 62 | + <div className='primary-split-button'> |
| 63 | + <button className={`split-left${isSecondary ? ' secondary' : ''}`} disabled={disabled} onClick={defaultAction} value={defaultOptionValue()} |
| 64 | + title={typeof defaultOptionLabel() === 'string' ? defaultOptionLabel() as string : optionsTitle}> |
| 65 | + {defaultOptionLabel()} |
66 | 66 | </button> |
67 | 67 | {hasSingleAction ? null : |
68 | 68 | <div className={`split${isSecondary ? ' secondary' : ''}${disabled ? ' disabled' : ''}`}><div className={`separator${disabled ? ' disabled' : ''}`}></div></div> |
|
0 commit comments