diff --git a/CHANGELOG.md b/CHANGELOG.md index 8db4777f93b..e64635ee99d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `14.5.0`. +**Bug fixes** + +- Fixed missing misc. button and link type definition exports ([#2434](https://github.com/elastic/eui/pull/2434)) ## [`14.5.0`](https://github.com/elastic/eui/tree/v14.5.0) diff --git a/scripts/dtsgenerator.js b/scripts/dtsgenerator.js index ba6a6f35f6a..6cb719150d5 100644 --- a/scripts/dtsgenerator.js +++ b/scripts/dtsgenerator.js @@ -116,7 +116,23 @@ generator.then(() => { // replace relative imports by attaching them to the module's namespace /import\("([.]{1,2}\/.*?)"\)/g, (importStatement, importPath) => { - const target = path.join(path.dirname(moduleName), importPath); + let target = path.join(path.dirname(moduleName), importPath); + + // if the target resolves to an orphaned index.ts file, remap to '@elastic/eui' + const filePath = target.replace('@elastic/eui', baseDir); + const filePathTs = `${filePath}.ts`; + const filePathTsx = `${filePath}.tsx`; + const filePathResolvedToIndex = path.join(filePath, 'index.ts'); + if ( + // fs.existsSync(filePath) === false && // target file doesn't exist + fs.existsSync(filePathTs) === false && // target file (.ts) doesn't exist + fs.existsSync(filePathTsx) === false && // target file (.tsx) doesn't exist + fs.existsSync(filePathResolvedToIndex) && // and it resolves to an index.ts + hasParentIndex(filePathResolvedToIndex) === false // does not get exported at a higher level + ) { + target = '@elastic/eui'; + } + return `import ("${target}")`; } ); diff --git a/src/components/button/button_empty/button_empty.tsx b/src/components/button/button_empty/button_empty.tsx index 9de8162cd72..47ab6f94648 100644 --- a/src/components/button/button_empty/button_empty.tsx +++ b/src/components/button/button_empty/button_empty.tsx @@ -11,6 +11,7 @@ import { import { EuiLoadingSpinner } from '../../loading'; import { getSecureRelForTarget } from '../../../services'; import { IconType, EuiIcon } from '../../icon'; +import { ButtonIconSide } from '../button'; export type EuiButtonEmptyColor = | 'primary' @@ -37,7 +38,9 @@ const sizeToClassNameMap = { export const SIZES = keysOf(sizeToClassNameMap); -const iconSideToClassNameMap = { +export type EuiButtonEmptySizes = keyof typeof sizeToClassNameMap; + +const iconSideToClassNameMap: { [side in ButtonIconSide]: string } = { left: '', right: 'euiButtonEmpty--iconRight', }; @@ -53,9 +56,9 @@ export const FLUSH_TYPES = keysOf(flushTypeToClassNameMap); interface CommonEuiButtonEmptyProps extends CommonProps { iconType?: IconType; - iconSide?: keyof typeof iconSideToClassNameMap; + iconSide?: ButtonIconSide; color?: EuiButtonEmptyColor; - size?: keyof typeof sizeToClassNameMap; + size?: EuiButtonEmptySizes; flush?: keyof typeof flushTypeToClassNameMap; isDisabled?: boolean; href?: string; diff --git a/src/components/button/button_empty/index.ts b/src/components/button/button_empty/index.ts index ad0fc883234..05bfdfbc3a4 100644 --- a/src/components/button/button_empty/index.ts +++ b/src/components/button/button_empty/index.ts @@ -2,6 +2,7 @@ export { COLORS, ICON_SIDES, EuiButtonEmpty, - EuiButtonEmptyProps, EuiButtonEmptyColor, + EuiButtonEmptyProps, + EuiButtonEmptySizes, } from './button_empty'; diff --git a/src/components/button/button_group/button_group.tsx b/src/components/button/button_group/button_group.tsx index ae44b218dc3..1f5ee101629 100644 --- a/src/components/button/button_group/button_group.tsx +++ b/src/components/button/button_group/button_group.tsx @@ -7,7 +7,7 @@ import { ToggleType } from '../../toggle'; import { EuiButtonToggle } from '../button_toggle'; import { Omit, CommonProps } from '../../common'; -import { ButtonColor } from '../button'; +import { ButtonColor, ButtonIconSide } from '../button'; import { IconType } from '../../icon'; export interface EuiButtonGroupIdToSelectedMap { @@ -22,7 +22,7 @@ export interface EuiButtonGroupOption extends CommonProps { name?: string; isDisabled?: boolean; value?: any; - iconSide?: 'left' | 'right'; + iconSide?: ButtonIconSide; iconType?: IconType; } diff --git a/src/components/button/button_icon/button_icon.tsx b/src/components/button/button_icon/button_icon.tsx index 300a7746735..4480598c3fc 100644 --- a/src/components/button/button_icon/button_icon.tsx +++ b/src/components/button/button_icon/button_icon.tsx @@ -19,7 +19,7 @@ import { IconType, IconSize, EuiIcon } from '../../icon'; import { ButtonSize } from '../button'; -export type ButtonIconColor = +export type EuiButtonIconColor = | 'danger' | 'disabled' | 'ghost' @@ -31,7 +31,7 @@ export type ButtonIconColor = export interface EuiButtonIconProps extends CommonProps { iconType?: IconType; - color?: ButtonIconColor; + color?: EuiButtonIconColor; 'aria-label'?: string; 'aria-labelledby'?: string; isDisabled?: boolean; @@ -58,7 +58,7 @@ type Props = ExclusiveUnion< EuiButtonIconPropsForButton >; -const colorToClassNameMap: { [color in ButtonIconColor]: string } = { +const colorToClassNameMap: { [color in EuiButtonIconColor]: string } = { danger: 'euiButtonIcon--danger', disabled: 'euiButtonIcon--disabled', ghost: 'euiButtonIcon--ghost', diff --git a/src/components/button/button_icon/index.ts b/src/components/button/button_icon/index.ts index f1fa004845a..046cf7fc9e9 100644 --- a/src/components/button/button_icon/index.ts +++ b/src/components/button/button_icon/index.ts @@ -1,5 +1,6 @@ export { EuiButtonIcon, + EuiButtonIconColor, EuiButtonIconProps, EuiButtonIconPropsForButton, } from './button_icon'; diff --git a/src/components/button/index.ts b/src/components/button/index.ts index 8872759448f..bb267481e2c 100644 --- a/src/components/button/index.ts +++ b/src/components/button/index.ts @@ -1,9 +1,22 @@ -export { COLORS, ButtonColor, EuiButton, EuiButtonProps } from './button'; +export { + COLORS, + ButtonColor, + ButtonSize, + ButtonIconSide, + EuiButton, + EuiButtonProps, +} from './button'; -export { EuiButtonEmpty, EuiButtonEmptyProps } from './button_empty'; +export { + EuiButtonEmpty, + EuiButtonEmptyColor, + EuiButtonEmptyProps, + EuiButtonEmptySizes, +} from './button_empty'; export { EuiButtonIcon, + EuiButtonIconColor, EuiButtonIconProps, EuiButtonIconPropsForButton, } from './button_icon'; diff --git a/src/components/link/index.ts b/src/components/link/index.ts index bfcad63b818..f84e20e6574 100644 --- a/src/components/link/index.ts +++ b/src/components/link/index.ts @@ -1,6 +1,8 @@ export { EuiLink, + EuiLinkColor, EuiLinkProps, + EuiLinkType, EuiLinkAnchorProps, EuiLinkButtonProps, } from './link'; diff --git a/src/components/link/link.tsx b/src/components/link/link.tsx index 8ea458b42fa..b450931f055 100644 --- a/src/components/link/link.tsx +++ b/src/components/link/link.tsx @@ -9,8 +9,8 @@ import classNames from 'classnames'; import { CommonProps, ExclusiveUnion, keysOf } from '../common'; import { getSecureRelForTarget } from '../../services'; -type EuiLinkType = 'button' | 'reset' | 'submit'; -type EuiLinkColor = +export type EuiLinkType = 'button' | 'reset' | 'submit'; +export type EuiLinkColor = | 'primary' | 'subdued' | 'secondary'