diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9b07a8379..2bab3697198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # [`master`](https://github.com/elastic/eui/tree/master) - Tweaked sizing, weights, color, line-heights, and added more levels to `EuiTitle` and `EuiText` ([#627](https://github.com/elastic/eui/pull/627)) +- Add TypeScript type defitions for `EuiPortal`, `EuiText` and `EuiTitle` as well as the `calculatePopoverPosition` service ([#638](https://github.com/elastic/eui/pull/638)) **Bug fixes** diff --git a/src/components/index.d.ts b/src/components/index.d.ts index 796d8927f13..d4d01305a17 100644 --- a/src/components/index.d.ts +++ b/src/components/index.d.ts @@ -13,3 +13,6 @@ /// /// /// +/// +/// +/// diff --git a/src/components/portal/index.d.ts b/src/components/portal/index.d.ts new file mode 100644 index 00000000000..709c4edb0e3 --- /dev/null +++ b/src/components/portal/index.d.ts @@ -0,0 +1,14 @@ +declare module '@elastic/eui' { + import { SFC } from 'react'; + + /** + * portal type defs + * + * @see './portal.js' + */ + type EuiPortalProps = { + children: React.ReactNode; + }; + + export const EuiPortal: SFC; +} diff --git a/src/components/text/index.d.ts b/src/components/text/index.d.ts new file mode 100644 index 00000000000..f9a01ba4e89 --- /dev/null +++ b/src/components/text/index.d.ts @@ -0,0 +1,30 @@ +/// + +declare module '@elastic/eui' { + import { SFC, HTMLAttributes } from 'react'; + + /** + * text type defs + * + * @see './text.js' + * @see './text_color.js' + */ + type EuiTextSize = 's' | 'xs'; + + type EuiTextColor = + | 'default' + | 'subdued' + | 'secondary' + | 'accent' + | 'danger' + | 'warning' + | 'ghost'; + + type EuiTextProps = CommonProps & + HTMLAttributes & { + size?: EuiTextSize; + color?: EuiTextColor; + }; + + export const EuiText: SFC; +} diff --git a/src/components/title/index.d.ts b/src/components/title/index.d.ts new file mode 100644 index 00000000000..bef381ec733 --- /dev/null +++ b/src/components/title/index.d.ts @@ -0,0 +1,22 @@ +/// + +declare module '@elastic/eui' { + import { SFC } from 'react'; + + /** + * title type defs + * + * @see './title.js' + */ + + type EuiTitleSize = 'xxxs' | 'xxs' | 'xs' | 's' | 'm' | 'l'; + + type EuiTitleTextTransform = 'uppercase'; + + type EuiTitleProps = CommonProps & { + size?: EuiTitleSize; + textTransform?: EuiTitleTextTransform; + }; + + export const EuiTitle: SFC; +} diff --git a/src/services/index.d.ts b/src/services/index.d.ts index 4420304cc7a..42a6bb261e0 100644 --- a/src/services/index.d.ts +++ b/src/services/index.d.ts @@ -1 +1,2 @@ /// +/// diff --git a/src/services/popover/index.d.ts b/src/services/popover/index.d.ts new file mode 100644 index 00000000000..39972cd5700 --- /dev/null +++ b/src/services/popover/index.d.ts @@ -0,0 +1,29 @@ +declare module '@elastic/eui' { + type EuiToolTipPosition = 'top' | 'right' | 'bottom' | 'left'; + + type EuiPopoverAnchorRect = { + top: number; + left: number; + width: number; + height: number; + }; + + type EuiPopoverDimensions = { + width: number; + height: number; + }; + + export const calculatePopoverPosition: ( + anchorBounds: EuiPopoverAnchorRect, + popoverBounds: EuiPopoverDimensions, + requestedPosition: EuiToolTipPosition, + buffer?: number, + positions?: EuiToolTipPosition[] + ) => { + top: number; + left: number; + width: number; + height: number; + position: EuiToolTipPosition; + }; +}