diff --git a/.eslintignore b/.eslintignore index 4ce89ab663..c260bbe6cd 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ .yarn/ utilities/icons/src/react/**/*.js **/locales/ +*.d.ts diff --git a/.eslintrc.js b/.eslintrc.js index 9861b1c164..0bd37b6457 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,6 +33,7 @@ const config = { '*.stories*.js', '**/__stories__/*.js', '**/__stories__/**/*.js', + '*.d.ts', ], rules: { 'import/no-extraneous-dependencies': 'error', diff --git a/collections/forms/package.json b/collections/forms/package.json index 6318ab868e..1f4c6aa1f1 100644 --- a/collections/forms/package.json +++ b/collections/forms/package.json @@ -49,10 +49,12 @@ "react-final-form": "^6.5.3" }, "files": [ - "build" + "build", + "types" ], "devDependencies": { "react": "16.13", "react-dom": "16.13" - } + }, + "types": "types" } diff --git a/collections/ui/package.json b/collections/ui/package.json index d009fed03e..c9b16288b1 100644 --- a/collections/ui/package.json +++ b/collections/ui/package.json @@ -83,5 +83,10 @@ "react": "16.13", "react-dom": "16.13", "styled-jsx": "^4.0.1" - } + }, + "files": [ + "build", + "types" + ], + "types": "types" } diff --git a/collections/ui/types/index.d.ts b/collections/ui/types/index.d.ts new file mode 100644 index 0000000000..cb74eda88b --- /dev/null +++ b/collections/ui/types/index.d.ts @@ -0,0 +1,65 @@ +export * from '@dhis2/ui-constants' +export * from '@dhis2/ui-icons' + +// DEPRECATED? +export * from '@dhis2/ui-forms' + +// components +export * from '@dhis2-ui/alert' +export * from '@dhis2-ui/button' +export * from '@dhis2-ui/box' +export * from '@dhis2-ui/calendar' +export * from '@dhis2-ui/card' +export * from '@dhis2-ui/center' +export * from '@dhis2-ui/checkbox' +export * from '@dhis2-ui/chip' +export * from '@dhis2-ui/cover' +export * from '@dhis2-ui/css' +export * from '@dhis2-ui/divider' +export * from '@dhis2-ui/field' +export * from '@dhis2-ui/file-input' +export * from '@dhis2-ui/header-bar' +export * from '@dhis2-ui/help' +export * from '@dhis2-ui/input' +export * from '@dhis2-ui/intersection-detector' +export * from '@dhis2-ui/label' +export * from '@dhis2-ui/layer' +export * from '@dhis2-ui/legend' +export * from '@dhis2-ui/loader' +export * from '@dhis2-ui/logo' +export * from '@dhis2-ui/menu' +export * from '@dhis2-ui/modal' +export * from '@dhis2-ui/node' +export * from '@dhis2-ui/notice-box' +export * from '@dhis2-ui/organisation-unit-tree' +export * from '@dhis2-ui/popover' +export { Popper, PopperProps } from '@dhis2-ui/popper' +export * from '@dhis2-ui/portal' +export * from '@dhis2-ui/radio' +export * from '@dhis2-ui/required' +export { Pagination, PaginationProps } from '@dhis2-ui/pagination' +export * from '@dhis2-ui/sharing-dialog' +export { + SingleSelect, + SingleSelectField, + SingleSelectOption, + MultiSelect, + MultiSelectField, + MultiSelectOption, + SingleSelectProps, + SingleSelectFieldProps, + SingleSelectOptionProps, + MultiSelectProps, + MultiSelectFieldProps, + MultiSelectOptionProps, +} from '@dhis2-ui/select' +export * from '@dhis2-ui/selector-bar' +export * from '@dhis2-ui/switch' +export * from '@dhis2-ui/table' +export * from '@dhis2-ui/tab' +export * from '@dhis2-ui/tag' +export * from '@dhis2-ui/text-area' +export * from '@dhis2-ui/tooltip' +export * from '@dhis2-ui/transfer' +export * from '@dhis2-ui/user-avatar' +export * from '@dhis2-ui/segmented-control' diff --git a/components/alert/package.json b/components/alert/package.json index 7fb2de53db..83755deba2 100644 --- a/components/alert/package.json +++ b/components/alert/package.json @@ -39,11 +39,13 @@ "prop-types": "^15.7.2" }, "files": [ - "build" + "build", + "types" ], "devDependencies": { "react": "16.13", "react-dom": "16.13", "styled-jsx": "^4.0.1" - } + }, + "types": "types" } diff --git a/components/alert/types/index.d.ts b/components/alert/types/index.d.ts new file mode 100644 index 0000000000..388ad5dd1d --- /dev/null +++ b/components/alert/types/index.d.ts @@ -0,0 +1,49 @@ +import * as React from 'react' + +export interface ActionsAction { + label: string + onClick: React.MouseEventHandler +} + +type ActionActionTuple = [ActionsAction?, ActionsAction?] + +export interface AlertBarProps { + /** + * An array of 0-2 action objects + */ + actions?: ActionActionTuple + /** + * The message string for the alert + */ + children?: string + className?: string + /** + * Alert bars with `critical` will not autohide + */ + critical?: boolean + dataTest?: string + duration?: number + hidden?: boolean + /** + * A specific icon to override the default icon in the bar. + * If `false` is provided, no icon will be shown. + */ + icon?: Element | boolean + permanent?: boolean + success?: boolean + /** + * Alert bars with `warning` will not autohide + */ + warning?: boolean + onHidden?: (arg0: {}, argv1: null) => void +} + +export const AlertBar: React.FC + +export interface AlertStackProps { + children?: React.ReactNode + className?: string + dataTest?: string +} + +export const AlertStack: React.FC diff --git a/components/box/package.json b/components/box/package.json index 5b730bd2e5..70651ba495 100644 --- a/components/box/package.json +++ b/components/box/package.json @@ -37,11 +37,13 @@ "prop-types": "^15.7.2" }, "files": [ - "build" + "build", + "types" ], "devDependencies": { "react": "16.13", "react-dom": "16.13", "styled-jsx": "^4.0.1" - } + }, + "types": "types" } diff --git a/components/box/types/index.d.ts b/components/box/types/index.d.ts new file mode 100644 index 0000000000..5d03067df8 --- /dev/null +++ b/components/box/types/index.d.ts @@ -0,0 +1,17 @@ +import * as React from 'react' + +export interface BoxProps { + children?: React.ReactNode + className?: string + dataTest?: string + height?: string + marginTop?: string + maxHeight?: string + maxWidth?: string + minHeight?: string + minWidth?: string + overflow?: string + width?: string +} + +export const Box: React.FC diff --git a/components/button/package.json b/components/button/package.json index 47c9e0a0d7..9dd3b27688 100644 --- a/components/button/package.json +++ b/components/button/package.json @@ -41,11 +41,13 @@ "prop-types": "^15.7.2" }, "files": [ - "build" + "build", + "types" ], "devDependencies": { "react": "16.13", "react-dom": "16.13", "styled-jsx": "^4.0.1" - } + }, + "types": "types" } diff --git a/components/button/types/index.d.ts b/components/button/types/index.d.ts new file mode 100644 index 0000000000..b67e153f17 --- /dev/null +++ b/components/button/types/index.d.ts @@ -0,0 +1,256 @@ +import * as React from 'react' + +export type ButtonType = 'submit' | 'reset' | 'button' + +export interface ButtonEventPayload { + value?: string + name?: string +} + +type ButtonEventHandler = ( + arg0: ButtonEventPayload, + event: Event +) => void + +type ButtonOpenEventHandler< + Event extends React.SyntheticEvent = React.MouseEvent +> = (arg0: ButtonEventPayload & { open: boolean }, event: Event) => void + +export interface ButtonProps { + /** + * Component to render inside the button + */ + children?: React.ReactNode + /** + * A className that will be passed to the `