@cube-dev/ui-kit 0.6.56 → 0.6.60

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.
Files changed (35) hide show
  1. package/dist/cjs/components/forms/Form/Field.d.ts +6 -3
  2. package/dist/cjs/components/forms/Form/Form.d.ts +9 -6
  3. package/dist/cjs/components/forms/Form/index.d.ts +1 -0
  4. package/dist/cjs/components/forms/Form/useForm.d.ts +13 -13
  5. package/dist/cjs/components/forms/TextInput/TextInput.d.ts +3 -1
  6. package/dist/cjs/components/overlays/Dialog/Dialog.d.ts +5 -0
  7. package/dist/cjs/components/overlays/Dialog/DialogContainer.d.ts +1 -1
  8. package/dist/cjs/components/overlays/Dialog/DialogForm.d.ts +9 -1
  9. package/dist/cjs/components/types.d.ts +12 -16
  10. package/dist/cjs/index.d.ts +8 -5
  11. package/dist/cjs/index.js +4 -4
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/shared/form.d.ts +6 -0
  14. package/dist/cjs/stories/FormFieldArgs.d.ts +9 -30
  15. package/dist/cjs/stories/components/ConfirmDeletionDialogForm.d.ts +7 -0
  16. package/dist/cjs/stories/components/DialogFormApp.d.ts +2 -0
  17. package/dist/cjs/stories/lists/baseProps.d.ts +1 -0
  18. package/dist/mjs/components/forms/Form/Field.d.ts +6 -3
  19. package/dist/mjs/components/forms/Form/Form.d.ts +9 -6
  20. package/dist/mjs/components/forms/Form/index.d.ts +1 -0
  21. package/dist/mjs/components/forms/Form/useForm.d.ts +13 -13
  22. package/dist/mjs/components/forms/TextInput/TextInput.d.ts +3 -1
  23. package/dist/mjs/components/overlays/Dialog/Dialog.d.ts +5 -0
  24. package/dist/mjs/components/overlays/Dialog/DialogContainer.d.ts +1 -1
  25. package/dist/mjs/components/overlays/Dialog/DialogForm.d.ts +9 -1
  26. package/dist/mjs/components/types.d.ts +12 -16
  27. package/dist/mjs/index.d.ts +8 -5
  28. package/dist/mjs/index.js +5 -5
  29. package/dist/mjs/index.js.map +1 -1
  30. package/dist/mjs/shared/form.d.ts +6 -0
  31. package/dist/mjs/stories/FormFieldArgs.d.ts +9 -30
  32. package/dist/mjs/stories/components/ConfirmDeletionDialogForm.d.ts +7 -0
  33. package/dist/mjs/stories/components/DialogFormApp.d.ts +2 -0
  34. package/dist/mjs/stories/lists/baseProps.d.ts +1 -0
  35. package/package.json +8 -5
@@ -1,6 +1,6 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { OptionalFieldBaseProps, ValidationRule } from '../../../shared';
3
- import { FormStore } from './useForm';
3
+ import { CubeFormInstance } from './useForm';
4
4
  export interface CubeFieldProps extends OptionalFieldBaseProps {
5
5
  /** The initial value of the input. */
6
6
  defaultValue?: any;
@@ -10,15 +10,18 @@ export interface CubeFieldProps extends OptionalFieldBaseProps {
10
10
  id?: string;
11
11
  /** The id prefix for the field to avoid collisions between forms */
12
12
  idPrefix?: string;
13
- children?: ReactElement | ((FormStore: any) => ReactElement);
13
+ children?: ReactElement | ((CubeFormInstance: any) => ReactElement);
14
+ /** Function that check whether to perform update of the form state. */
14
15
  shouldUpdate?: boolean | ((prevValues: any, nextValues: any) => boolean);
15
16
  /** Validation rules */
16
17
  rules?: ValidationRule[];
17
18
  /** The form instance */
18
- form?: FormStore;
19
+ form?: CubeFormInstance;
19
20
  /** The message for the field or text for the error */
20
21
  message?: string;
22
+ /** Tooltip for the label that explains something. */
21
23
  tooltip?: ReactNode;
24
+ /** Field name. It's used as a key the form data. */
22
25
  name?: string[] | string;
23
26
  }
24
27
  export declare function Field(allProps: CubeFieldProps): JSX.Element | null;
@@ -1,24 +1,27 @@
1
1
  import { FormHTMLAttributes } from 'react';
2
- import { FormStore, useForm, CubeFormData } from './useForm';
2
+ import { CubeFormInstance, CubeFormData } from './useForm';
3
3
  import { BaseProps, ContainerStyleProps } from '../../types';
4
4
  import { FormBaseProps } from '../../../shared';
5
5
  export declare const FormContext: import("react").Context<{}>;
6
6
  export declare function useFormProps(props: any): any;
7
7
  export interface CubeFormProps extends FormBaseProps, BaseProps, ContainerStyleProps, Pick<FormHTMLAttributes<HTMLFormElement>, 'action' | 'autoComplete' | 'encType' | 'method' | 'target'> {
8
- /** The form name */
8
+ /** Form name */
9
9
  name?: string;
10
+ /** Default field values */
10
11
  defaultValues?: {
11
12
  [key: string]: any;
12
13
  };
14
+ /** Trigger when any value of Field changed */
13
15
  onValuesChange?: (data: CubeFormData) => void | Promise<void>;
16
+ /** Trigger when form submit and success */
14
17
  onSubmit?: (data: CubeFormData) => void | Promise<void>;
18
+ /** Trigger when form submit and failed */
15
19
  onSubmitFailed?: (any?: any) => void | Promise<any>;
16
- form?: FormStore;
20
+ /** Set form instance created by useForm */
21
+ form?: CubeFormInstance;
17
22
  }
18
23
  /**
19
24
  * Forms allow users to enter data that can be submitted while providing alignment and styling for form fields.
20
25
  */
21
- declare const _Form: import("react").ForwardRefExoticComponent<CubeFormProps & import("react").RefAttributes<unknown>> & {
22
- useForm: typeof useForm;
23
- };
26
+ declare const _Form: import("react").ForwardRefExoticComponent<CubeFormProps & import("react").RefAttributes<unknown>>;
24
27
  export { _Form as Form };
@@ -2,3 +2,4 @@ export { Form, useFormProps } from './Form';
2
2
  export type { CubeFormProps } from './Form';
3
3
  export { Field } from './Field';
4
4
  export { useForm } from './useForm';
5
+ export type { CubeFormInstance } from './useForm';
@@ -1,7 +1,7 @@
1
1
  export declare type CubeFormData = {
2
2
  [key: string]: any;
3
3
  };
4
- export declare type CubeField = {
4
+ export declare type CubeFieldData = {
5
5
  value?: any;
6
6
  name: string;
7
7
  errors: string[];
@@ -9,7 +9,7 @@ export declare type CubeField = {
9
9
  rules?: any[];
10
10
  validating?: boolean;
11
11
  };
12
- export declare class FormStore {
12
+ export declare class CubeFormInstance {
13
13
  forceReRender: () => void;
14
14
  private initialFields;
15
15
  private fields;
@@ -21,31 +21,31 @@ export declare class FormStore {
21
21
  submit(): Promise<any>;
22
22
  setFieldsValue(newData: {
23
23
  [key: string]: any;
24
- }, touched?: boolean, reRender?: boolean, createFields?: boolean): void;
24
+ }, touched?: boolean, skipRender?: boolean, createFields?: boolean): void;
25
25
  getFieldValue(name: any): any;
26
26
  getFieldsValue(): CubeFormData;
27
27
  /**
28
28
  * Similar to getFieldsValue() but respects '.' notation and creates nested objects.
29
29
  */
30
30
  getFormData(): CubeFormData;
31
- setFieldValue(name: string, value: any, touched?: boolean, reRender?: boolean): void;
32
- getFieldInstance(name: string): CubeField;
31
+ setFieldValue(name: string, value: any, touched?: boolean, skipRender?: boolean): void;
32
+ getFieldInstance(name: string): CubeFieldData;
33
33
  setInitialFieldsValue(values: {
34
34
  [key: string]: any;
35
35
  }): void;
36
- resetFields(reRender?: boolean): void;
36
+ resetFields(names?: string[], skipRender?: boolean): void;
37
37
  validateField(name: string): Promise<any>;
38
38
  validateFields(list?: string[]): Promise<any>;
39
39
  isFieldValid(name: string): boolean;
40
40
  isFieldInvalid(name: string): boolean;
41
41
  isFieldTouched(name: string): boolean;
42
42
  getFieldError(name: string): string[];
43
- createField(name: string, reRender?: boolean): void;
44
- setFields(newFields: CubeField[]): void;
43
+ createField(name: string, skipRender?: boolean): void;
44
+ setFields(newFields: CubeFieldData[]): void;
45
45
  setSubmitting(isSubmitting: boolean): void;
46
- _createField(name: any, data?: Partial<CubeField>): CubeField;
46
+ _createField(name: any, data?: Partial<CubeFieldData>): CubeFieldData;
47
47
  }
48
- export declare function useForm(form?: FormStore, ref?: any, options?: {
49
- onSubmit?: FormStore['onSubmit'];
50
- onValuesChange?: FormStore['onValuesChange'];
51
- }): [FormStore];
48
+ export declare function useForm(form?: CubeFormInstance, ref?: any, options?: {
49
+ onSubmit?: CubeFormInstance['onSubmit'];
50
+ onValuesChange?: CubeFormInstance['onValuesChange'];
51
+ }): [CubeFormInstance];
@@ -5,5 +5,7 @@ import { CubeTextInputBaseProps } from './TextInputBase';
5
5
  * with a keyboard. Various decorations can be displayed around the field to
6
6
  * communicate the entry requirements.
7
7
  */
8
- declare const _TextInput: import("react").ForwardRefExoticComponent<CubeTextInputBaseProps & import("react").RefAttributes<unknown>>;
8
+ declare const _TextInput: import("react").ForwardRefExoticComponent<CubeTextInputBaseProps & import("react").RefAttributes<unknown>> & {
9
+ cubeInputType: string;
10
+ };
9
11
  export { _TextInput as TextInput };
@@ -2,10 +2,15 @@ import { ReactNode } from 'react';
2
2
  import { BaseProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps } from '../../types';
3
3
  import { AriaDialogProps } from '@react-types/dialog';
4
4
  export interface CubeDialogProps extends Omit<BaseProps, 'role'>, AriaDialogProps, BaseStyleProps, BlockStyleProps, DimensionStyleProps {
5
+ /** The type of the dialog. It affects its size and position. */
5
6
  type?: 'modal' | 'popover' | 'fullscreen' | 'fullscreenTakeover' | 'panel' | 'tray';
7
+ /** The size of the dialog */
6
8
  size?: 'S' | 'M' | 'L';
9
+ /** Whether the dialog is dismissable */
7
10
  isDismissable?: boolean;
11
+ /** Trigger when the dialog is dismissed */
8
12
  onDismiss?: (arg?: any) => void;
13
+ /** That you can replace the close icon with */
9
14
  closeIcon?: ReactNode;
10
15
  }
11
16
  /**
@@ -3,7 +3,7 @@ export interface CubeDialogContainerProps {
3
3
  /** The Dialog to display, if any. */
4
4
  children?: ReactNode;
5
5
  /** Handler that is called when the 'x' button of a dismissable Dialog is clicked. */
6
- onDismiss: (arg?: any) => void;
6
+ onDismiss?: (arg?: any) => void;
7
7
  /**
8
8
  * The type of Dialog that should be rendered. See the visual options below for examples of each.
9
9
  * @default 'modal'
@@ -3,10 +3,18 @@ import { CubeDialogProps } from './Dialog';
3
3
  import { CubeFormProps } from '../../forms/Form/Form';
4
4
  import { CubeButtonProps } from '../../actions/Button/Button';
5
5
  export interface CubeDialogFormProps extends CubeDialogProps, Omit<CubeFormProps, 'role'> {
6
+ /** Whether the submit button has a `danger` theme */
6
7
  danger?: boolean;
8
+ /** Properties for submit button. Use `label` to change text. */
7
9
  submitProps?: CubeButtonProps;
10
+ /** Properties for cancel button. Use `label` to change text. */
8
11
  cancelProps?: CubeButtonProps;
12
+ /** WIP. Preserve form values even if field is deleted */
9
13
  preserve?: boolean;
14
+ /** Whether to hide action button so developer can manually specify them */
15
+ noActions?: boolean;
16
+ /** The title of the dialog */
17
+ title?: string;
10
18
  }
11
19
  export interface CubeDialogFormRef {
12
20
  open: () => void;
@@ -15,5 +23,5 @@ export interface CubeDialogFormRef {
15
23
  /**
16
24
  * DialogForms are a specific type of Dialog. They contain forms to fill.
17
25
  */
18
- declare let _DialogForm: import("react").ForwardRefExoticComponent<Pick<any, string | number | symbol> & import("react").RefAttributes<CubeDialogFormRef>>;
26
+ declare let _DialogForm: import("react").ForwardRefExoticComponent<CubeDialogFormProps & import("react").RefAttributes<CubeDialogFormRef>>;
19
27
  export { _DialogForm as DialogForm };
@@ -2,32 +2,27 @@ import { AllHTMLAttributes, CSSProperties } from 'react';
2
2
  import { Styles } from '../styles/types';
3
3
  import { BASE_STYLES, BLOCK_STYLES, COLOR_STYLES, CONTAINER_STYLES, DIMENSION_STYLES, FLOW_STYLES, OUTER_STYLES, POSITION_STYLES, TEXT_STYLES } from '../styles/list';
4
4
  export interface BasePropsWithoutChildren extends Pick<AllHTMLAttributes<HTMLElement>, 'className' | 'role' | 'id'> {
5
- /** QA ID for e2e testing **/
5
+ /** QA ID for e2e testing. An alias for `data-qa` attribute. */
6
6
  qa?: string;
7
- /** QA value for e2e testing **/
7
+ /** QA value for e2e testing. An alias for `data-qaval` attribute. */
8
8
  qaVal?: string | number;
9
- /** The tag name of the element **/
10
- /** The style map **/
9
+ /** The style map */
11
10
  styles?: Styles;
12
- /** The list of responsive points in pixels **/
11
+ /** The list of responsive points in pixels */
13
12
  breakpoints?: number[];
14
- /** Whether the element has the block layout outside **/
13
+ /** Whether the element has the block layout outside */
15
14
  block?: boolean;
16
- /** Whether the element has the inline layout outside **/
15
+ /** Whether the element has the inline layout outside */
17
16
  inline?: boolean;
18
17
  /** The list of element modifiers **/
19
18
  mods?: {
20
19
  [key: string]: boolean | undefined | null;
21
20
  };
22
- /** Whether the element is hidden (`hidden` attribute is set) **/
21
+ /** Whether the element is hidden (`hidden` attribute is set) */
23
22
  isHidden?: boolean;
24
- /** DEPRECATED: Whether the element is hidden (`hidden` attribute is set) **/
25
- hidden?: boolean;
26
- /** Whether the element is disabled (`disabled` attribute is set) **/
23
+ /** Whether the element is disabled (`disabled` attribute is set) */
27
24
  isDisabled?: boolean;
28
- /** DEPRECATED: Whether the element is disabled (`disabled` attribute is set) **/
29
- disabled?: boolean;
30
- /** Plain css for the element **/
25
+ /** Plain css for the element */
31
26
  css?: string | ((props: Props) => string);
32
27
  /** The element name for using in style overriding */
33
28
  styleName?: string;
@@ -35,12 +30,12 @@ export interface BasePropsWithoutChildren extends Pick<AllHTMLAttributes<HTMLEle
35
30
  style?: CSSProperties | (CSSProperties & {
36
31
  [key: string]: string | number | null;
37
32
  });
38
- /** User-defined theme for the element. Mapped to data-theme attribute. */
33
+ /** User-defined theme for the element. Mapped to data-theme attribute. Use `default`, or `danger`, or any custom string value you need. */
39
34
  theme?: 'default' | 'danger' | string;
40
35
  }
41
36
  export interface BaseProps extends BasePropsWithoutChildren, Pick<AllHTMLAttributes<HTMLElementTagNameMap['div']>, 'children'> {
42
37
  }
43
- export interface AllBaseProps<K extends keyof HTMLElementTagNameMap = 'div'> extends BaseProps, Omit<AllHTMLAttributes<HTMLElementTagNameMap[K]>, 'style' | 'size' | 'disabled' | 'hidden'> {
38
+ export interface AllBaseProps<K extends keyof HTMLElementTagNameMap = 'div'> extends BaseProps, Omit<AllHTMLAttributes<HTMLElementTagNameMap[K]>, 'style' | 'size' | 'disabled' | 'hidden' | 'css'> {
44
39
  as?: string;
45
40
  }
46
41
  export declare type BaseStyleProps = Pick<Styles, typeof BASE_STYLES[number]>;
@@ -67,5 +62,6 @@ export interface Props {
67
62
  }
68
63
  export declare type TagName = keyof HTMLElementTagNameMap;
69
64
  export interface TagNameProps {
65
+ /** The tag name you want to use for the element */
70
66
  as?: TagName;
71
67
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CubeFormProps, Field, useFormProps } from './components/forms/Form';
2
+ import { CubeFormProps, Field, useForm, useFormProps, CubeFormInstance } from './components/forms/Form';
3
3
  import { CubeTextProps, Text } from './components/content/Text';
4
4
  import { CubeTitleProps, Title } from './components/content/Title';
5
5
  import { CubeParagraphProps, Paragraph } from './components/content/Paragraph';
@@ -9,9 +9,8 @@ declare const _Button: import("react").ForwardRefExoticComponent<import("./compo
9
9
  Group: import("react").ForwardRefExoticComponent<import("./components/layout/Space").CubeSpaceProps & import("react").RefAttributes<unknown>>;
10
10
  };
11
11
  declare const Form: import("react").ForwardRefExoticComponent<CubeFormProps & import("react").RefAttributes<unknown>> & {
12
- useForm: typeof import("./components/forms/Form").useForm;
13
- } & {
14
12
  Item: typeof Field;
13
+ useForm: typeof useForm;
15
14
  };
16
15
  export { Item } from '@react-stately/collections';
17
16
  export { Base } from './components/Base';
@@ -89,7 +88,7 @@ export type { CubeSwitchProps } from './components/forms/Switch/Switch';
89
88
  export { Radio } from './components/forms/RadioGroup/Radio';
90
89
  export type { CubeRadioProps } from './components/forms/RadioGroup/Radio';
91
90
  export { Form, Field, useFormProps };
92
- export type { CubeFormProps };
91
+ export type { CubeFormProps, CubeFormInstance };
93
92
  export { ComboBox } from './components/pickers/ComboBox/ComboBox';
94
93
  export type { CubeComboBoxProps } from './components/pickers/ComboBox/ComboBox';
95
94
  export { Select, ListBoxPopup } from './components/pickers/Select/Select';
@@ -150,7 +149,11 @@ export { useContextStyles, StyleProvider } from './providers/StylesProvider';
150
149
  export { Provider } from './provider';
151
150
  export type { useProviderProps } from './provider';
152
151
  declare const Input: import("react").ForwardRefExoticComponent<import("./components/forms/TextInput/TextInputBase").CubeTextInputBaseProps & import("react").RefAttributes<unknown>> & {
153
- Text: import("react").ForwardRefExoticComponent<import("./components/forms/TextInput/TextInputBase").CubeTextInputBaseProps & import("react").RefAttributes<unknown>>;
152
+ cubeInputType: string;
153
+ } & {
154
+ Text: import("react").ForwardRefExoticComponent<import("./components/forms/TextInput/TextInputBase").CubeTextInputBaseProps & import("react").RefAttributes<unknown>> & {
155
+ cubeInputType: string;
156
+ };
154
157
  Password: import("react").ForwardRefExoticComponent<import("./components/forms/TextInput/TextInputBase").CubeTextInputBaseProps & import("react").RefAttributes<unknown>> & {
155
158
  cubeInputType: string;
156
159
  };