@digital-ai/dot-components 1.3.4 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,30 @@
1
- import { ReactNode } from 'react';
1
+ import { ChangeEvent, ReactElement, ReactNode } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
3
  export interface AccordionProps extends CommonProps {
4
4
  /** actionable components (ex: checkbox, button) that can be nested within the expanded Accordion component */
5
5
  actions?: ReactNode;
6
6
  /** The content for the Accordion.*/
7
7
  children: ReactNode;
8
- /** If true, expands the accordion by default. */
8
+ /** DEPRECATED, DO NOT USE */
9
9
  defaultExpanded?: boolean;
10
10
  /** If true, the accordion will be displayed in a disabled state. */
11
11
  disabled?: boolean;
12
+ /** If true, the accordion is expanded. */
13
+ expanded?: boolean;
12
14
  /** If true, the Accordion will have elevation. */
13
15
  hasElevation?: boolean;
14
16
  /** If true, the text will wrap and not be truncated */
15
17
  noWrap?: boolean;
18
+ /**
19
+ Callback fired when the expand/collapse state is changed.
20
+ If provided, the accordion will be a controlled component and it will be the responsibility of the consumer to manage the 'expanded' state.
21
+ */
22
+ onChange?: (event: ChangeEvent, expanded: boolean) => void;
16
23
  /** If true, rounded corners are disabled. */
17
24
  square?: boolean;
18
25
  /** Icon placed before the children. */
19
26
  startIcon?: ReactNode;
20
27
  /** The text within the expanded Accordion */
21
- summary: ReactNode;
28
+ summary: ReactElement;
22
29
  }
23
- export declare const DotAccordion: ({ actions, ariaLabel, children, className, "data-testid": dataTestId, defaultExpanded, disabled, hasElevation, square, startIcon, summary, noWrap, }: AccordionProps) => JSX.Element;
30
+ export declare const DotAccordion: ({ actions, ariaLabel, children, className, "data-testid": dataTestId, defaultExpanded, disabled, expanded, hasElevation, onChange, square, startIcon, summary, noWrap, }: AccordionProps) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
- export declare type BadgeOverlap = 'circle' | 'rectangle' | 'circular' | 'rectangular';
3
+ export declare type BadgeOverlap = 'circular' | 'rectangular';
4
4
  export interface BadgeProps extends CommonProps {
5
5
  /** custom color code for the badge */
6
6
  badgeColor?: string;
@@ -1,3 +1,6 @@
1
- import { BadgeProps } from './Badge';
2
1
  export declare const rootClassName = "dot-badge";
3
- export declare const StyledBadge: import("styled-components").StyledComponent<import("@material-ui/core/OverridableComponent").OverridableComponent<import("@material-ui/core").BadgeTypeMap<{}, "div">>, any, BadgeProps, never>;
2
+ interface StyledBadgeProps {
3
+ $badgeColor?: string;
4
+ }
5
+ export declare const StyledBadge: import("styled-components").StyledComponent<import("@material-ui/core/OverridableComponent").OverridableComponent<import("@material-ui/core").BadgeTypeMap<{}, "div">>, any, StyledBadgeProps, never>;
6
+ export {};
@@ -8,4 +8,4 @@ export interface DynamicFormProps extends CommonProps {
8
8
  onChange?: (formData: DynamicFormState) => void;
9
9
  onSubmit?: (formData: DynamicFormOutputData) => void;
10
10
  }
11
- export declare const DotDynamicForm: ({ ariaLabel, className, "data-testid": dataTestId, config, disabled, liveValidation, onChange, onSubmit, }: DynamicFormProps) => JSX.Element;
11
+ export declare const DotDynamicForm: ({ ariaLabel, className, "data-testid": dataTestId, config, disabled: isFormDisabled, liveValidation, onChange, onSubmit, }: DynamicFormProps) => JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { ControlClickHandler, DynamicFormConfig } from './models';
2
+ export declare const getDynamicFormConfig: (handleProgressControlClick?: ControlClickHandler) => DynamicFormConfig;
@@ -0,0 +1 @@
1
+ export declare const StyledDynamicFormStory: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  export declare const rootClassName = "dot-dynamic-form";
2
- export declare const StyledDynamicForm: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledDynamicForm: import("styled-components").StyledComponent<({ ariaLabel, children, className, "data-testid": dataTestId, onSubmit, }: import("../form/Form").FormProps) => JSX.Element, any, {}, never>;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { ComponentType, ReactNode } from 'react';
2
2
  import { AutoCompleteProps } from '../auto-complete/AutoComplete';
3
3
  import { ButtonProps } from '../button/Button';
4
4
  import { CheckboxProps } from '../checkbox/Checkbox';
@@ -7,21 +7,35 @@ import { InputSelectProps } from '../input-form-fields/InputSelect';
7
7
  import { CheckboxGroupProps } from '../checkbox/CheckboxGroup';
8
8
  import { RadioGroupProps } from '../radio/RadioGroup';
9
9
  import { SwitchProps } from '../switch/Switch';
10
- export declare type DynamicFormControlType = 'dot-input-text' | 'dot-input-select' | 'dot-checkbox' | 'dot-checkbox-group' | 'dot-autocomplete' | 'dot-button' | 'dot-radio-group' | 'dot-reset' | 'dot-submit' | 'dot-switch' | 'custom-element';
11
- export declare type DynamicFormControlProps = AutoCompleteProps | InputTextProps | InputSelectProps | CheckboxProps | CheckboxGroupProps | ButtonProps | RadioGroupProps | SwitchProps;
10
+ import { ProgressButtonProps } from '../progress-button/ProgressButton';
11
+ export declare type DynamicFormControlType = 'dot-input-text' | 'dot-input-select' | 'dot-checkbox' | 'dot-checkbox-group' | 'dot-autocomplete' | 'dot-button' | 'dot-progress-button' | 'dot-radio-group' | 'dot-reset' | 'dot-submit' | 'dot-progress-submit' | 'dot-switch' | 'dot-form-section' | 'custom-element';
12
+ export declare type DynamicFormControlProps = AutoCompleteProps | InputTextProps | InputSelectProps | CheckboxProps | CheckboxGroupProps | ButtonProps | ProgressButtonProps | RadioGroupProps | SwitchProps;
12
13
  export interface DynamicFormOutputData {
13
14
  [key: string]: unknown;
14
15
  }
15
16
  export declare type ConditionFunction = (formValues: DynamicFormOutputData) => boolean;
16
- export declare type HiddenControl = boolean | ConditionFunction;
17
+ export declare type DisabledConditionFunction = (formValues: DynamicFormOutputData, isFormValid: boolean) => boolean;
18
+ export declare type ControlCondition = boolean | ConditionFunction;
19
+ export declare type DisabledControlCondition = boolean | DisabledConditionFunction;
20
+ export declare type ControlClickHandler = (formValues: DynamicFormOutputData) => void;
21
+ export interface DynamicFormSectionProps {
22
+ sectionControls: ReactNode[];
23
+ }
24
+ export interface DynamicFormSection {
25
+ FormSectionComponent: ComponentType<DynamicFormSectionProps>;
26
+ sectionControls: DynamicFormControl[];
27
+ }
17
28
  export interface DynamicFormControl {
18
29
  controlName?: string;
19
- controlType: DynamicFormControlType;
20
30
  controlProps?: DynamicFormControlProps;
31
+ controlType: DynamicFormControlType;
32
+ formSection?: DynamicFormSection;
33
+ customElement?: ReactNode;
34
+ disabled?: DisabledControlCondition;
35
+ hidden?: ControlCondition;
21
36
  initialValue?: unknown;
37
+ onControlClick?: ControlClickHandler;
22
38
  validation?: DynamicFormValidation;
23
- customElement?: ReactNode;
24
- hidden?: HiddenControl;
25
39
  }
26
40
  export interface FieldValidation {
27
41
  isValid: boolean;
@@ -51,7 +65,7 @@ export interface DynamicFormStateItem {
51
65
  isValid: boolean;
52
66
  isTouched: boolean;
53
67
  errorMessage: string;
54
- hidden?: HiddenControl;
68
+ hidden?: ControlCondition;
55
69
  }
56
70
  export interface DynamicFormState {
57
71
  data: DynamicFormStateData;
@@ -1,4 +1,2 @@
1
- import { DynamicFormConfig, DynamicFormOutputData, DynamicFormState } from './models';
2
- export declare const sampleMiddleNameHiddenFn: (formValues: DynamicFormOutputData) => boolean;
3
- export declare const getSampleConfig: () => DynamicFormConfig;
1
+ import { DynamicFormState } from './models';
4
2
  export declare const getSampleFormState: () => DynamicFormState;
@@ -1,5 +1,5 @@
1
1
  import { ChangeEvent } from 'react';
2
- import { DynamicFormConfig, DynamicFormControlProps, DynamicFormState, DynamicFormStateData } from '../models';
2
+ import { ControlClickHandler, DynamicFormConfig, DynamicFormControl, DynamicFormControlProps, DynamicFormOutputData, DynamicFormState, DynamicFormStateData, DynamicFormStateItem } from '../models';
3
3
  import { AutoCompleteValue } from '../../auto-complete/AutoComplete';
4
4
  import { CheckboxProps } from '../../checkbox/Checkbox';
5
5
  declare type AutoCompleteChangeHandler = (controlName: string) => (e: ChangeEvent<HTMLInputElement>, value: AutoCompleteValue) => void;
@@ -18,9 +18,11 @@ export interface ControlledInputArgs extends InputBaseArgs {
18
18
  }
19
19
  export interface UncontrolledInputArgs extends InputBaseArgs {
20
20
  formState?: DynamicFormState;
21
- handleClick?: () => void;
21
+ handleClick?: (formValues?: DynamicFormOutputData) => void;
22
22
  }
23
+ export declare const getInitialStateFromControl: ({ hidden, initialValue, controlType, validation, formSection, }: DynamicFormControl, liveValidation: boolean, formValues: DynamicFormOutputData) => DynamicFormStateItem;
23
24
  export declare const getInitialFormState: (config: DynamicFormConfig, liveValidation: boolean) => DynamicFormState;
25
+ export declare const getControlClickHandler: (formValues: DynamicFormOutputData, onControlClick?: ControlClickHandler) => () => void;
24
26
  export declare const buildInputTextControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
25
27
  export declare const buildInputSelectControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
26
28
  export declare const buildAutocompleteControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
@@ -28,7 +30,9 @@ export declare const buildRadioGroupControl: ({ controlName, controlProps, disab
28
30
  export declare const buildCheckboxControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
29
31
  export declare const buildCheckboxGroupControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
30
32
  export declare const buildSwitchControl: ({ controlName, controlProps, disabled, formData, handleChange, index, }: ControlledInputArgs) => JSX.Element;
31
- export declare const buildButtonControl: ({ controlProps, disabled, index, }: UncontrolledInputArgs) => JSX.Element;
33
+ export declare const buildButtonControl: ({ controlProps, disabled, index, handleClick, }: UncontrolledInputArgs) => JSX.Element;
34
+ export declare const buildProgressButtonControl: ({ controlProps, disabled, index, handleClick, }: UncontrolledInputArgs) => JSX.Element;
32
35
  export declare const buildResetControl: ({ controlProps, disabled, handleClick, index, }: UncontrolledInputArgs) => JSX.Element;
33
36
  export declare const buildSubmitControl: ({ controlProps, disabled, formState, index, liveValidation, }: UncontrolledInputArgs) => JSX.Element;
37
+ export declare const buildProgressSubmitControl: ({ controlProps, disabled, formState, index, liveValidation, }: UncontrolledInputArgs) => JSX.Element;
34
38
  export {};
@@ -1,5 +1,6 @@
1
- import { DynamicFormConfig, DynamicFormOutputData, DynamicFormState, DynamicFormStateData, HiddenControl } from '../models';
1
+ import { ControlCondition, DisabledControlCondition, DynamicFormConfig, DynamicFormOutputData, DynamicFormState, DynamicFormStateData } from '../models';
2
2
  export declare const getControlValue: <T extends unknown>(controlName: string, data: DynamicFormStateData) => T;
3
3
  export declare const getOutputFormData: (formState: DynamicFormState) => DynamicFormOutputData;
4
- export declare const checkIfHiddenControl: (hidden: HiddenControl, formValues: DynamicFormOutputData) => boolean;
4
+ export declare const checkIfHiddenControl: (hidden: ControlCondition, formValues: DynamicFormOutputData) => boolean;
5
+ export declare const checkIfDisabledControl: (disabled: DisabledControlCondition, formValues: DynamicFormOutputData, isFormValid: boolean) => boolean;
5
6
  export declare const getFormDataFromInitialValues: (config: DynamicFormConfig) => DynamicFormOutputData;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FileWithPath } from 'react-dropzone';
3
+ import { CommonProps } from '../CommonProps';
4
+ export interface FileItemProps extends CommonProps {
5
+ deleteFile: (file: FileWithPath) => void;
6
+ error?: boolean;
7
+ errorText?: string;
8
+ file: FileWithPath;
9
+ }
10
+ export declare const DotFileListItem: ({ ariaLabel, className, "data-testid": dataTestId, deleteFile, error, errorText, file, }: FileItemProps) => JSX.Element;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { CommonProps } from '../CommonProps';
3
+ import { MappedFile } from './uploadHelpers';
4
+ export interface FileUploadProps extends CommonProps {
5
+ /** Unique file type specifiers <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers" target="_blank">More Info</a> */
6
+ accept?: Array<string>;
7
+ /** If true, will only display the button */
8
+ buttonOnly?: boolean;
9
+ /** If true, the upload zone will be disabled */
10
+ disabled?: boolean;
11
+ /** Defines the maximum number of files that can be uploaded at once */
12
+ maxFiles?: number;
13
+ /** Defines the maximum file size (in MB) */
14
+ maxSize: number;
15
+ /** callback triggered when files are added or removed */
16
+ onChange: (files: Array<MappedFile>) => void;
17
+ /** callback triggered when dragenter event occurs */
18
+ onDragEnter?: (event: React.DragEvent<HTMLDivElement>) => void;
19
+ }
20
+ export declare const DotFileUpload: ({ accept, ariaLabel, buttonOnly, className, "data-testid": dataTestId, disabled, maxFiles, maxSize, onChange, onDragEnter, }: FileUploadProps) => JSX.Element;
@@ -0,0 +1,6 @@
1
+ export declare const rootClassName = "dot-file-upload";
2
+ export declare const containerClassName: string;
3
+ export declare const fileClassName: string;
4
+ export declare const dropZoneClassName: string;
5
+ export declare const StyledFileUploadContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ export declare const StyledFileUpload: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { FileWithPath } from 'react-dropzone';
3
+ export interface MappedFile {
4
+ errors: Array<FileUploadError>;
5
+ file: FileWithPath;
6
+ }
7
+ export interface FileUploadError {
8
+ code: string;
9
+ message: string;
10
+ }
11
+ export declare const parseListItem: (deleteFile: (file: FileWithPath) => void, fileToBeParsed: MappedFile, maxSize: number) => {
12
+ child: JSX.Element;
13
+ };
@@ -7,7 +7,7 @@ export type { CheckboxProps } from './checkbox/Checkbox';
7
7
  export type { CheckboxGroupProps } from './checkbox/CheckboxGroup';
8
8
  export type { SubmitButtonProps } from './dialog/Dialog';
9
9
  export type { DynamicFormProps } from './dynamic-form/DynamicForm';
10
- export type { DynamicFormConfig, DynamicFormOutputData, DynamicFormState, FieldValidation, } from './dynamic-form/models';
10
+ export type { ControlClickHandler, DynamicFormConfig, DynamicFormControl, DynamicFormOutputData, DynamicFormState, FieldValidation, DynamicFormSectionProps, } from './dynamic-form/models';
11
11
  export type { IconButtonProps } from './button/IconButton';
12
12
  export type { InputTextProps } from './input-form-fields/InputText';
13
13
  export type { InputSelectProps } from './input-form-fields/InputSelect';
@@ -73,6 +73,7 @@ export { DotSkeleton } from './skeleton/Skeleton';
73
73
  export { DotSnackbar } from './snackbar/Snackbar';
74
74
  export { DotSnackbarContainer, DotSnackbarProvider, useDotSnackbarContext, } from './snackbar/SnackbarProvider';
75
75
  export { DotSplitButton } from './split-button/SplitButton';
76
+ export { DotProgressButton } from './progress-button/ProgressButton';
76
77
  export { DotSwitch } from './switch/Switch';
77
78
  export { DotTable } from './table/Table';
78
79
  export { DotTooltip } from './tooltip/Tooltip';
@@ -80,4 +81,4 @@ export { DotHeaderRow } from './table/TableHeader';
80
81
  export { DotTablePagination } from './table/TablePagination';
81
82
  export { DotTabs } from './tabs/Tabs';
82
83
  export { DotTypography } from './typography/Typography';
83
- export { DotProgressButton } from './progress-button/ProgressButton';
84
+ export { DotFileUpload } from './file-upload/FileUpload';
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, ReactNode, Ref } from 'react';
1
+ import { ChangeEvent, ReactNode, Ref, KeyboardEvent } from 'react';
2
2
  import { CommonProps } from '../CommonProps';
3
3
  export declare type inputSizeOptions = 'small' | 'medium';
4
4
  export interface InputProps extends CommonProps {
@@ -27,8 +27,14 @@ export interface InputProps extends CommonProps {
27
27
  label?: string;
28
28
  /** The name of input element */
29
29
  name: string;
30
+ /** A function that should be executed when the input loses focus */
31
+ onBlur?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
30
32
  /** A function that should be executed when the value of the input changes */
31
33
  onChange?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
34
+ /** A function that should be executed when the input gains focus */
35
+ onFocus?: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
36
+ /** A function that should be executed when key is pressed */
37
+ onKeyDown?: (event: KeyboardEvent) => void;
32
38
  /** If true, the label is displayed as required and the input element` will be required. */
33
39
  required?: boolean;
34
40
  /** Size of the input */
@@ -8,4 +8,4 @@ export interface InputSelectProps extends InputProps {
8
8
  /** value of input field */
9
9
  value?: string;
10
10
  }
11
- export declare const DotInputSelect: ({ ariaLabel, autoFocus, className, "data-testid": dataTestId, defaultValue, disabled, endIcon, error, fullWidth, helperText, id, inputRef, label, name, onChange, options, required, size, startIcon, value, warning, }: InputSelectProps) => JSX.Element;
11
+ export declare const DotInputSelect: ({ ariaLabel, autoFocus, className, "data-testid": dataTestId, defaultValue, disabled, endIcon, error, fullWidth, helperText, id, inputRef, label, name, onBlur, onChange, onFocus, onKeyDown, options, required, size, startIcon, value, warning, }: InputSelectProps) => JSX.Element;
@@ -17,4 +17,4 @@ export interface InputTextProps extends InputProps {
17
17
  /** value of the InputText */
18
18
  value?: string;
19
19
  }
20
- export declare const DotInputText: ({ autoFocus, className, defaultValue, "data-testid": dataTestId, disabled, error, fullWidth, hasDebounce, helperText, endIcon, id, inputRef, label, multiline, name, onChange, placeholder, readOnly, required, rows, rowsMax, startIcon, size, type, value, warning, }: InputTextProps) => JSX.Element;
20
+ export declare const DotInputText: ({ autoFocus, className, defaultValue, "data-testid": dataTestId, disabled, error, fullWidth, hasDebounce, helperText, endIcon, id, inputRef, label, multiline, name, onBlur, onChange, onFocus, onKeyDown, placeholder, readOnly, required, rows, rowsMax, startIcon, size, type, value, warning, }: InputTextProps) => JSX.Element;
@@ -52,10 +52,11 @@ export interface ListItemProps extends CommonProps {
52
52
  endIconId?: string;
53
53
  /** If provided, the list item will be rendered as a link */
54
54
  href?: string;
55
- /** List item index */
55
+ /** DEPRECATED, DO NOT USE */
56
56
  index?: number;
57
57
  /** If provided, the menu item will display a nested list */
58
58
  items?: Array<ListItemProps>;
59
+ isOpened?: boolean;
59
60
  /** If nested list type is 'menu', determines the placement of the menu */
60
61
  menuPlacement?: PopperPlacement;
61
62
  /** If nested type is 'drawer', determines the width of the left spacing */
@@ -64,6 +65,12 @@ export interface ListItemProps extends CommonProps {
64
65
  nestedListType?: NestedListType;
65
66
  /** Event callback */
66
67
  onClick?: (event: MouseEvent) => void;
68
+ /** Menu leave event callback */
69
+ onMenuLeave?: () => void;
70
+ /** The main content element */
71
+ primaryText?: string;
72
+ /** The secondary content element */
73
+ secondaryText?: string;
67
74
  /** Selected list item */
68
75
  selected?: boolean;
69
76
  /** If provided, the icon ID which is displayed on the front of the list item */
@@ -78,4 +85,4 @@ export interface ListItemProps extends CommonProps {
78
85
  tooltip?: string;
79
86
  }
80
87
  export declare const DotList: ({ ariaLabel, children, className, component, "data-testid": dataTestId, dense, disablePadding, items, menuPlacement, nestedDrawerLeftSpacing, nestedListType, width, }: ListProps) => JSX.Element;
81
- export declare const DotListItem: ({ ariaLabel, className, component, "data-testid": dataTestId, divider, endIconId, href, index, onClick, items, menuPlacement, nestedDrawerLeftSpacing, nestedListType, selected, startIconId, target, text, title, tooltip, }: ListItemProps) => JSX.Element;
88
+ export declare const DotListItem: ({ ariaLabel, className, component, "data-testid": dataTestId, divider, endIconId, href, isOpened, onClick, onMenuLeave, index, items, menuPlacement, nestedDrawerLeftSpacing, nestedListType, primaryText, secondaryText, selected, startIconId, target, text, title, tooltip, }: ListItemProps) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-ai/dot-components",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "license": "SEE LICENSE IN <LICENSE.md>",
6
6
  "contributors": [
@@ -28,6 +28,7 @@
28
28
  "dependencies": {
29
29
  "@material-ui/lab": "4.0.0-alpha.56",
30
30
  "@material-ui/core": "4.12.3",
31
+ "react-dropzone": "^11.4.2",
31
32
  "styled-components": "^5.2.1"
32
33
  },
33
34
  "peerDependencies": {