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/CHANGELOG.md b/CHANGELOG.md index bd406ec8c4..b304e831c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [9.0.0-alpha.2](https://github.com/dhis2/ui/compare/v9.0.0-alpha.1...v9.0.0-alpha.2) (2023-12-08) + + +### Features + +* **menu-item:** add suffix prop ([77cd949](https://github.com/dhis2/ui/commit/77cd94953cf8c14b21373c53d055a8f8ed68110d)) + # [8.16.0](https://github.com/dhis2/ui/compare/v8.15.1...v8.16.0) (2023-12-07) diff --git a/collections/forms/package.json b/collections/forms/package.json index 76e174697c..abe472a7b2 100644 --- a/collections/forms/package.json +++ b/collections/forms/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2/ui-forms", - "version": "8.16.0", + "version": "9.0.0-alpha.2", "main": "./build/cjs/index.js", "module": "./build/es/index.js", "sideEffects": [ @@ -8,6 +8,7 @@ "build/cjs/locales/index.js" ], "exports": { + "types": "./types/index.d.ts", "import": "./build/es/index.js", "require": "./build/cjs/index.js" }, @@ -34,25 +35,27 @@ }, "dependencies": { "@dhis2/prop-types": "^3.1.2", - "@dhis2-ui/button": "8.16.0", - "@dhis2-ui/checkbox": "8.16.0", - "@dhis2-ui/field": "8.16.0", - "@dhis2-ui/file-input": "8.16.0", - "@dhis2-ui/input": "8.16.0", - "@dhis2-ui/radio": "8.16.0", - "@dhis2-ui/select": "8.16.0", - "@dhis2-ui/switch": "8.16.0", - "@dhis2-ui/text-area": "8.16.0", + "@dhis2-ui/button": "9.0.0-alpha.2", + "@dhis2-ui/checkbox": "9.0.0-alpha.2", + "@dhis2-ui/field": "9.0.0-alpha.2", + "@dhis2-ui/file-input": "9.0.0-alpha.2", + "@dhis2-ui/input": "9.0.0-alpha.2", + "@dhis2-ui/radio": "9.0.0-alpha.2", + "@dhis2-ui/select": "9.0.0-alpha.2", + "@dhis2-ui/switch": "9.0.0-alpha.2", + "@dhis2-ui/text-area": "9.0.0-alpha.2", "classnames": "^2.3.1", "final-form": "^4.20.2", "prop-types": "^15.7.2", "react-final-form": "^6.5.3" }, "files": [ - "build" + "build", + "types" ], "devDependencies": { "react": "16.13", "react-dom": "16.13" - } + }, + "types": "types" } diff --git a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts new file mode 100644 index 0000000000..8375721a23 --- /dev/null +++ b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts @@ -0,0 +1,16 @@ +import type { FieldRenderProps } from 'react-final-form' +import type { CheckboxFieldProps } from '@dhis2-ui/checkbox' +import React from 'react' + +type CheckBoxValue = CheckboxFieldProps['value'] +type CheckboxRestProps = Omit< + CheckboxFieldProps, + 'onChange' | 'value' | 'checked' | 'name' +> + +export type CheckboxFieldFFProps = FieldRenderProps & + CheckboxRestProps & { + showValidStatus?: boolean + } + +export const CheckboxFieldFF: React.FC diff --git a/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts new file mode 100644 index 0000000000..203e544641 --- /dev/null +++ b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts @@ -0,0 +1,9 @@ +import React from 'react' +import type { FieldGroupProps } from '@dhis2-ui/field' + +export type FieldGroupFFProps = Omit< + FieldGroupProps, + 'children' | 'label' | 'name' | 'required' +> + +export const FieldGroupFF: React.FC diff --git a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts new file mode 100644 index 0000000000..338dfc6626 --- /dev/null +++ b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts @@ -0,0 +1,18 @@ +import React from 'react' +import type { FileInputFieldProps } from '@dhis2-ui/file-input' +import type { FieldRenderProps } from 'react-final-form' + +export type FilesValue = File[] | undefined | null | '' + +type FileInputRestProps = Omit< + FileInputFieldProps, + 'onChange' | 'multiple' | 'name' +> + +export type FileInputFieldFFProps = FieldRenderProps & + FileInputRestProps & { + showValidStatus?: boolean + multifile: FileInputFieldProps['multiple'] + } + +export const FileInputFieldFF: React.FC diff --git a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts new file mode 100644 index 0000000000..048590da5e --- /dev/null +++ b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { InputFieldProps } from '@dhis2-ui/input' +import type { FieldRenderProps } from 'react-final-form' + +export type InputValue = InputFieldProps['value'] + +type InputFieldRestProps = Omit + +export type InputFieldFFProps = FieldRenderProps & + InputFieldRestProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + } + +export const InputFieldFF: React.FC diff --git a/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts new file mode 100644 index 0000000000..d30d6b6a04 --- /dev/null +++ b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts @@ -0,0 +1,24 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { + MultiSelectOptionProps, + MultiSelectFieldProps, +} from '@dhis2-ui/select' + +type InputValue = MultiSelectFieldProps['selected'] | '' + +type MultiSelectFieldRestProps = Omit< + MultiSelectFieldProps, + 'onChange' | 'value' +> + +type MultiSelectOptions = Array> + +export type MultiSelectFieldFFProps = FieldRenderProps & + MultiSelectFieldRestProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: MultiSelectOptions + } + +export const MultiSelectFieldFF: React.FC diff --git a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts new file mode 100644 index 0000000000..847b65ae2a --- /dev/null +++ b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts @@ -0,0 +1,17 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { RadioProps } from '@dhis2-ui/radio' + +type InputValue = RadioProps['value'] + +type RadioRestProps = Omit< + RadioProps, + 'onChange' | 'value' | 'checked' | 'name' +> + +export type RadioFieldFFProps = FieldRenderProps & + RadioRestProps & { + showValidStatus?: boolean + } + +export const RadioFieldFF: React.FC diff --git a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts new file mode 100644 index 0000000000..40bb616d5c --- /dev/null +++ b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts @@ -0,0 +1,26 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { + SingleSelectOptionProps, + SingleSelectFieldProps, +} from '@dhis2-ui/select' + +type InputValue = SingleSelectFieldProps['selected'] + +type SingleSelectOptions = Array< + Pick +> + +type SingleSelectRestProps = Omit< + SingleSelectFieldProps, + 'onChange' | 'value' | 'name' +> + +export type SingleSelectFieldFFProps = FieldRenderProps & + SingleSelectRestProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: SingleSelectOptions + } + +export const SingleSelectFieldFF: React.FC diff --git a/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts new file mode 100644 index 0000000000..5996b936c4 --- /dev/null +++ b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { SwitchFieldProps } from '@dhis2-ui/switch' + +type InputValue = SwitchFieldProps['value'] + +type SwitchFieldRestProps = Omit< + SwitchFieldProps, + 'onChange' | 'checked' | 'value' | 'name' +> + +export type SwitchFieldFFProps = FieldRenderProps & + SwitchFieldRestProps + +export const SwitchFieldFF: React.FC diff --git a/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts new file mode 100644 index 0000000000..af829af51e --- /dev/null +++ b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { TextAreaFieldProps } from '@dhis2-ui/text-area' + +type InputValue = TextAreaFieldProps['value'] + +type TextAreaFieldRestProps = Omit< + TextAreaFieldProps, + 'onChange' | 'value' | 'name' +> + +export type TextAreaFieldFFProps = FieldRenderProps & + TextAreaFieldRestProps + +export const TextAreaFieldFF: React.FC diff --git a/collections/forms/types/index.d.ts b/collections/forms/types/index.d.ts new file mode 100644 index 0000000000..844d413348 --- /dev/null +++ b/collections/forms/types/index.d.ts @@ -0,0 +1,28 @@ +import * as FinalForm from 'final-form' +import * as ReactFinalForm from 'react-final-form' + +export { CheckboxFieldFF } from './CheckboxFieldFF/CheckboxFieldFF' +export { FileInputFieldFF } from './FileInputFieldFF/FileInputFieldFF' +export { InputFieldFF } from './InputFieldFF/InputFieldFF' +export { MultiSelectFieldFF } from './MultiSelectFieldFF/MutliSelectFieldFF' +export { SingleSelectFieldFF } from './SingleSelectFieldFF/SingleSelectFieldFF' +export { RadioFieldFF } from './RadioFieldFF/RadioFieldFF' +export { SwitchFieldFF } from './SwitchFieldFF/SwitchFieldFF' +export { TextAreaFieldFF } from './TextAreaFieldFF/TextAreaFieldFF' +export { FieldGroupFF } from './FieldGroupFF/FieldGroupFF' + +export * from './transformers' +export * from './validators' + +/** + * Allows direct access to the FinalForm library. Please note that this is considered advanced + * usage and that you need to stay up to date with breaking changes in the FinalForm library. + */ +export { FinalForm } + +/** + * Allows direct access to the ReactFinalForm library. Please note that this is considered + * advanced usage and that you need to stay up to date with breaking changes in the FinalForm + * library. + */ +export { ReactFinalForm } diff --git a/collections/forms/types/transformers/index.d.ts b/collections/forms/types/transformers/index.d.ts new file mode 100644 index 0000000000..e985979da6 --- /dev/null +++ b/collections/forms/types/transformers/index.d.ts @@ -0,0 +1,6 @@ +export type ValuesWithId = Array<{ id: string }> | undefined + +export const arrayWithIdObjects: { + format: (value: ValuesWithId) => string + pars: (value: string) => ValuesWithId +} diff --git a/collections/forms/types/validators/index.d.ts b/collections/forms/types/validators/index.d.ts new file mode 100644 index 0000000000..0ead88dae6 --- /dev/null +++ b/collections/forms/types/validators/index.d.ts @@ -0,0 +1,31 @@ +export type Validator = (value: unknown) => string | undefined + +export const alphaNumeric: Validator +export const boolean: Validator +export const composeValidators: (...validators: Validator[]) => Validator + +export const createCharacterLengthRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createEqualTo: (key: string, description?: string) => Validator +export const createMaxCharacterLength: (upperBound: number) => Validator +export const createMaxNumber: (upperBound: number) => Validator +export const createMinCharacterLength: (lowerBound: number) => Validator +export const createMinNumber: (lowerBound: number) => Validator +export const createNumberRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createPattern: (pattern: RegExp, message?: string) => Validator +export const dhis2Password: Validator +export const dhis2Username: Validator +export const email: Validator +export const hasValue: Validator +export const integer: Validator +export const internationalPhoneNumber: Validator +export const number: Validator +export const string: Validator +export const url: Validator diff --git a/collections/ui/API.md b/collections/ui/API.md index bba3b0d9ef..696a60c073 100644 --- a/collections/ui/API.md +++ b/collections/ui/API.md @@ -1283,6 +1283,43 @@ import { NoticeBox } from '@dhis2/ui' |valid|custom|||Applies 'valid' message styles. Mutually exclusive with the `error` and `warning` props| |warning|custom|||Applies 'warning' message styles. Mutually exclusive with the `error` and `valid` props| +### OrganisationUnitTreeRootError + +#### Usage + +**Note**: If possible, import the component from the main UI (`@dhis2/ui`) package. + + +```js +import { OrganisationUnitTreeRootError } from '@dhis2/ui' +``` + + +#### Props + +|Name|Type|Default|Required|Description| +|---|---|---|---|---| +|error|string||*|| +|dataTest|string|`'dhis2-uiwidgets-orgunittree-error'`||| + +### OrganisationUnitTreeRootLoading + +#### Usage + +**Note**: If possible, import the component from the main UI (`@dhis2/ui`) package. + + +```js +import { OrganisationUnitTreeRootLoading } from '@dhis2/ui' +``` + + +#### Props + +|Name|Type|Default|Required|Description| +|---|---|---|---|---| +|dataTest|string|`'dhis2-uiwidgets-orgunittree-loading'`||| + ### OrganisationUnitTree #### Usage diff --git a/collections/ui/package.json b/collections/ui/package.json index 21cc749f20..36d4c1e0e8 100644 --- a/collections/ui/package.json +++ b/collections/ui/package.json @@ -1,9 +1,10 @@ { "name": "@dhis2/ui", - "version": "8.16.0", + "version": "9.0.0-alpha.2", "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": { + "types": "./types/index.d.ts", "import": "./build/es/index.js", "require": "./build/cjs/index.js" }, @@ -20,54 +21,54 @@ "build": "d2-app-scripts build" }, "dependencies": { - "@dhis2-ui/alert": "8.16.0", - "@dhis2-ui/box": "8.16.0", - "@dhis2-ui/button": "8.16.0", - "@dhis2-ui/calendar": "8.16.0", - "@dhis2-ui/card": "8.16.0", - "@dhis2-ui/center": "8.16.0", - "@dhis2-ui/checkbox": "8.16.0", - "@dhis2-ui/chip": "8.16.0", - "@dhis2-ui/cover": "8.16.0", - "@dhis2-ui/css": "8.16.0", - "@dhis2-ui/divider": "8.16.0", - "@dhis2-ui/field": "8.16.0", - "@dhis2-ui/file-input": "8.16.0", - "@dhis2-ui/header-bar": "8.16.0", - "@dhis2-ui/help": "8.16.0", - "@dhis2-ui/input": "8.16.0", - "@dhis2-ui/intersection-detector": "8.16.0", - "@dhis2-ui/label": "8.16.0", - "@dhis2-ui/layer": "8.16.0", - "@dhis2-ui/legend": "8.16.0", - "@dhis2-ui/loader": "8.16.0", - "@dhis2-ui/logo": "8.16.0", - "@dhis2-ui/menu": "8.16.0", - "@dhis2-ui/modal": "8.16.0", - "@dhis2-ui/node": "8.16.0", - "@dhis2-ui/notice-box": "8.16.0", - "@dhis2-ui/organisation-unit-tree": "8.16.0", - "@dhis2-ui/pagination": "8.16.0", - "@dhis2-ui/popover": "8.16.0", - "@dhis2-ui/popper": "8.16.0", - "@dhis2-ui/portal": "8.16.0", - "@dhis2-ui/radio": "8.16.0", - "@dhis2-ui/required": "8.16.0", - "@dhis2-ui/segmented-control": "8.16.0", - "@dhis2-ui/select": "8.16.0", - "@dhis2-ui/selector-bar": "8.16.0", - "@dhis2-ui/sharing-dialog": "8.16.0", - "@dhis2-ui/switch": "8.16.0", - "@dhis2-ui/tab": "8.16.0", - "@dhis2-ui/table": "8.16.0", - "@dhis2-ui/tag": "8.16.0", - "@dhis2-ui/text-area": "8.16.0", - "@dhis2-ui/tooltip": "8.16.0", - "@dhis2-ui/transfer": "8.16.0", - "@dhis2-ui/user-avatar": "8.16.0", - "@dhis2/ui-constants": "8.16.0", - "@dhis2/ui-forms": "8.16.0", - "@dhis2/ui-icons": "8.16.0", + "@dhis2-ui/alert": "9.0.0-alpha.2", + "@dhis2-ui/box": "9.0.0-alpha.2", + "@dhis2-ui/button": "9.0.0-alpha.2", + "@dhis2-ui/calendar": "9.0.0-alpha.2", + "@dhis2-ui/card": "9.0.0-alpha.2", + "@dhis2-ui/center": "9.0.0-alpha.2", + "@dhis2-ui/checkbox": "9.0.0-alpha.2", + "@dhis2-ui/chip": "9.0.0-alpha.2", + "@dhis2-ui/cover": "9.0.0-alpha.2", + "@dhis2-ui/css": "9.0.0-alpha.2", + "@dhis2-ui/divider": "9.0.0-alpha.2", + "@dhis2-ui/field": "9.0.0-alpha.2", + "@dhis2-ui/file-input": "9.0.0-alpha.2", + "@dhis2-ui/header-bar": "9.0.0-alpha.2", + "@dhis2-ui/help": "9.0.0-alpha.2", + "@dhis2-ui/input": "9.0.0-alpha.2", + "@dhis2-ui/intersection-detector": "9.0.0-alpha.2", + "@dhis2-ui/label": "9.0.0-alpha.2", + "@dhis2-ui/layer": "9.0.0-alpha.2", + "@dhis2-ui/legend": "9.0.0-alpha.2", + "@dhis2-ui/loader": "9.0.0-alpha.2", + "@dhis2-ui/logo": "9.0.0-alpha.2", + "@dhis2-ui/menu": "9.0.0-alpha.2", + "@dhis2-ui/modal": "9.0.0-alpha.2", + "@dhis2-ui/node": "9.0.0-alpha.2", + "@dhis2-ui/notice-box": "9.0.0-alpha.2", + "@dhis2-ui/organisation-unit-tree": "9.0.0-alpha.2", + "@dhis2-ui/pagination": "9.0.0-alpha.2", + "@dhis2-ui/popover": "9.0.0-alpha.2", + "@dhis2-ui/popper": "9.0.0-alpha.2", + "@dhis2-ui/portal": "9.0.0-alpha.2", + "@dhis2-ui/radio": "9.0.0-alpha.2", + "@dhis2-ui/required": "9.0.0-alpha.2", + "@dhis2-ui/segmented-control": "9.0.0-alpha.2", + "@dhis2-ui/select": "9.0.0-alpha.2", + "@dhis2-ui/selector-bar": "9.0.0-alpha.2", + "@dhis2-ui/sharing-dialog": "9.0.0-alpha.2", + "@dhis2-ui/switch": "9.0.0-alpha.2", + "@dhis2-ui/tab": "9.0.0-alpha.2", + "@dhis2-ui/table": "9.0.0-alpha.2", + "@dhis2-ui/tag": "9.0.0-alpha.2", + "@dhis2-ui/text-area": "9.0.0-alpha.2", + "@dhis2-ui/tooltip": "9.0.0-alpha.2", + "@dhis2-ui/transfer": "9.0.0-alpha.2", + "@dhis2-ui/user-avatar": "9.0.0-alpha.2", + "@dhis2/ui-constants": "9.0.0-alpha.2", + "@dhis2/ui-forms": "9.0.0-alpha.2", + "@dhis2/ui-icons": "9.0.0-alpha.2", "prop-types": "^15.7.2" }, "peerDependencies": { @@ -83,5 +84,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 0d18dd9a35..54f48ae23d 100644 --- a/components/alert/package.json +++ b/components/alert/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2-ui/alert", - "version": "8.16.0", + "version": "9.0.0-alpha.2", "description": "UI Alert", "repository": { "type": "git", @@ -13,6 +13,7 @@ "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": { + "types": "./types/index.d.ts", "import": "./build/es/index.js", "require": "./build/cjs/index.js" }, @@ -32,18 +33,20 @@ }, "dependencies": { "@dhis2/prop-types": "^3.1.2", - "@dhis2-ui/portal": "8.16.0", - "@dhis2/ui-constants": "8.16.0", - "@dhis2/ui-icons": "8.16.0", + "@dhis2-ui/portal": "9.0.0-alpha.2", + "@dhis2/ui-constants": "9.0.0-alpha.2", + "@dhis2/ui-icons": "9.0.0-alpha.2", "classnames": "^2.3.1", "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 8fd4be9f45..3301a1a5a1 100644 --- a/components/box/package.json +++ b/components/box/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2-ui/box", - "version": "8.16.0", + "version": "9.0.0-alpha.2", "description": "UI Box", "repository": { "type": "git", @@ -13,6 +13,7 @@ "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": { + "types": "./types/index.d.ts", "import": "./build/es/index.js", "require": "./build/cjs/index.js" }, @@ -32,16 +33,18 @@ }, "dependencies": { "@dhis2/prop-types": "^3.1.2", - "@dhis2/ui-constants": "8.16.0", + "@dhis2/ui-constants": "9.0.0-alpha.2", "classnames": "^2.3.1", "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 0f128252bf..ab9e941ead 100644 --- a/components/button/package.json +++ b/components/button/package.json @@ -1,6 +1,6 @@ { "name": "@dhis2-ui/button", - "version": "8.16.0", + "version": "9.0.0-alpha.2", "description": "UI Button", "repository": { "type": "git", @@ -13,6 +13,7 @@ "main": "./build/cjs/index.js", "module": "./build/es/index.js", "exports": { + "types": "./types/index.d.ts", "import": "./build/es/index.js", "require": "./build/cjs/index.js" }, @@ -32,20 +33,22 @@ }, "dependencies": { "@dhis2/prop-types": "^3.1.2", - "@dhis2-ui/layer": "8.16.0", - "@dhis2-ui/loader": "8.16.0", - "@dhis2-ui/popper": "8.16.0", - "@dhis2/ui-constants": "8.16.0", - "@dhis2/ui-icons": "8.16.0", + "@dhis2-ui/layer": "9.0.0-alpha.2", + "@dhis2-ui/loader": "9.0.0-alpha.2", + "@dhis2-ui/popper": "9.0.0-alpha.2", + "@dhis2/ui-constants": "9.0.0-alpha.2", + "@dhis2/ui-icons": "9.0.0-alpha.2", "classnames": "^2.3.1", "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..da71d22c49 --- /dev/null +++ b/components/button/types/index.d.ts @@ -0,0 +1,234 @@ +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 `