@cube-dev/ui-kit 0.6.58 → 0.6.62

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 (31) 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/overlays/Dialog/Dialog.d.ts +5 -0
  6. package/dist/cjs/components/overlays/Dialog/DialogForm.d.ts +9 -1
  7. package/dist/cjs/components/types.d.ts +12 -16
  8. package/dist/cjs/index.d.ts +3 -4
  9. package/dist/cjs/index.js +4 -4
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/shared/form.d.ts +6 -0
  12. package/dist/cjs/stories/FormFieldArgs.d.ts +9 -30
  13. package/dist/cjs/stories/components/ConfirmDeletionDialogForm.d.ts +7 -0
  14. package/dist/cjs/stories/components/DialogFormApp.d.ts +2 -0
  15. package/dist/cjs/stories/lists/baseProps.d.ts +1 -0
  16. package/dist/mjs/components/forms/Form/Field.d.ts +6 -3
  17. package/dist/mjs/components/forms/Form/Form.d.ts +9 -6
  18. package/dist/mjs/components/forms/Form/index.d.ts +1 -0
  19. package/dist/mjs/components/forms/Form/useForm.d.ts +13 -13
  20. package/dist/mjs/components/overlays/Dialog/Dialog.d.ts +5 -0
  21. package/dist/mjs/components/overlays/Dialog/DialogForm.d.ts +9 -1
  22. package/dist/mjs/components/types.d.ts +12 -16
  23. package/dist/mjs/index.d.ts +3 -4
  24. package/dist/mjs/index.js +5 -5
  25. package/dist/mjs/index.js.map +1 -1
  26. package/dist/mjs/shared/form.d.ts +6 -0
  27. package/dist/mjs/stories/FormFieldArgs.d.ts +9 -30
  28. package/dist/mjs/stories/components/ConfirmDeletionDialogForm.d.ts +7 -0
  29. package/dist/mjs/stories/components/DialogFormApp.d.ts +2 -0
  30. package/dist/mjs/stories/lists/baseProps.d.ts +1 -0
  31. package/package.json +8 -5
@@ -1,7 +1,9 @@
1
1
  import { Props } from '../components/types';
2
2
  import { Styles } from '../styles/types';
3
3
  import { ReactNode } from 'react';
4
+ /** Where to place label relative to input */
4
5
  export declare type LabelPosition = 'side' | 'top';
6
+ /** The type of necessity indicator */
5
7
  export declare type NecessityIndicator = 'icon' | 'label';
6
8
  /** The validation state of the field */
7
9
  export declare type ValidationState = 'invalid' | 'valid';
@@ -22,13 +24,17 @@ export interface FieldBaseProps extends OptionalFieldBaseProps {
22
24
  name: string[] | string;
23
25
  }
24
26
  export interface FormBaseProps {
27
+ /** Styles of the label */
25
28
  labelStyles?: Styles;
29
+ /** Where to place label relative to input */
26
30
  labelPosition?: LabelPosition;
27
31
  /** Whether the field presents required mark */
28
32
  requiredMark?: boolean;
29
33
  /** Whether the field is required */
30
34
  isRequired?: boolean;
35
+ /** The type of necessity indicator */
31
36
  necessityIndicator?: NecessityIndicator;
37
+ /** That can replace the necessity label */
32
38
  necessityLabel?: ReactNode;
33
39
  /** Whether the field is read only */
34
40
  isReadOnly?: boolean;
@@ -1,11 +1,9 @@
1
+ export declare const DISABLE_BASE_ARGS: {};
1
2
  export declare const LABEL_POSITION_ARG: {
2
3
  labelPosition: {
3
- defaultValue: string;
4
4
  description: string;
5
- control: {
6
- type: string;
7
- options: string[];
8
- };
5
+ options: string[];
6
+ control: string;
9
7
  table: {
10
8
  type: {
11
9
  summary: string;
@@ -18,19 +16,15 @@ export declare const LABEL_POSITION_ARG: {
18
16
  };
19
17
  export declare const LABEL_ARG: {
20
18
  label: {
21
- defaultValue: string;
22
19
  control: string;
23
20
  description: string;
24
21
  };
25
22
  };
26
23
  export declare const NECESSITY_INDICATOR_ARG: {
27
24
  necessityIndicator: {
28
- defaultValue: string;
29
25
  description: string;
30
- control: {
31
- type: string;
32
- options: (string | boolean)[];
33
- };
26
+ options: (string | boolean)[];
27
+ control: string;
34
28
  table: {
35
29
  type: {
36
30
  summary: string;
@@ -43,25 +37,20 @@ export declare const NECESSITY_INDICATOR_ARG: {
43
37
  };
44
38
  export declare const MESSAGE_ARG: {
45
39
  message: {
46
- defaultValue: string;
47
40
  description: string;
48
41
  control: string;
49
42
  };
50
43
  };
51
44
  export declare const PLACEHOLDER_ARG: {
52
45
  placeholder: {
53
- defaultValue: string;
54
46
  control: string;
55
47
  };
56
48
  };
57
49
  export declare const VALIDATION_STATE_ARG: {
58
50
  validationState: {
59
- defaultValue: undefined;
60
51
  description: string;
61
- control: {
62
- type: string;
63
- options: (string | undefined)[];
64
- };
52
+ options: (string | undefined)[];
53
+ control: string;
65
54
  table: {
66
55
  type: {
67
56
  summary: string;
@@ -76,7 +65,6 @@ export declare const IS_LOADING_ARG: {
76
65
  isLoading: {
77
66
  control: string;
78
67
  description: string;
79
- defaultValue: boolean;
80
68
  table: {
81
69
  type: {
82
70
  summary: string;
@@ -89,7 +77,6 @@ export declare const IS_LOADING_ARG: {
89
77
  };
90
78
  export declare const AUTO_FOCUS_ARG: {
91
79
  autoFocus: {
92
- defaultValue: boolean;
93
80
  description: string;
94
81
  control: {
95
82
  type: string;
@@ -106,7 +93,6 @@ export declare const AUTO_FOCUS_ARG: {
106
93
  };
107
94
  export declare const IS_REQUIRED_ARG: {
108
95
  isRequired: {
109
- defaultValue: boolean;
110
96
  description: string;
111
97
  control: {
112
98
  type: string;
@@ -123,7 +109,6 @@ export declare const IS_REQUIRED_ARG: {
123
109
  };
124
110
  export declare const IS_READ_ONLY_ARG: {
125
111
  isReadOnly: {
126
- defaultValue: boolean;
127
112
  description: string;
128
113
  control: {
129
114
  type: string;
@@ -140,7 +125,6 @@ export declare const IS_READ_ONLY_ARG: {
140
125
  };
141
126
  export declare const IS_DISABLED_ARG: {
142
127
  isDisabled: {
143
- defaultValue: boolean;
144
128
  description: string;
145
129
  control: {
146
130
  type: string;
@@ -157,12 +141,9 @@ export declare const IS_DISABLED_ARG: {
157
141
  };
158
142
  export declare const SIZE_ARG: {
159
143
  size: {
160
- defaultValue: undefined;
161
144
  description: string;
162
- control: {
163
- type: string;
164
- options: (string | undefined)[];
165
- };
145
+ options: (string | undefined)[];
146
+ control: string;
166
147
  table: {
167
148
  type: {
168
149
  summary: string;
@@ -175,7 +156,6 @@ export declare const SIZE_ARG: {
175
156
  };
176
157
  export declare const MULTILINE_ARG: {
177
158
  multiLine: {
178
- defaultValue: boolean;
179
159
  description: string;
180
160
  control: {
181
161
  type: string;
@@ -192,7 +172,6 @@ export declare const MULTILINE_ARG: {
192
172
  };
193
173
  export declare const REQUIRED_MARK_ARG: {
194
174
  requiredMark: {
195
- defaultValue: boolean;
196
175
  description: string;
197
176
  control: {
198
177
  type: string;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { CubeDialogFormRef, CubeDialogFormProps } from '../../index';
3
+ interface ConfirmDeletionDialogFormProps extends Pick<CubeDialogFormProps, 'onSubmit' | 'onDismiss' | 'form'> {
4
+ name?: string;
5
+ }
6
+ export declare const ConfirmDeletionDialogForm: import("react").ForwardRefExoticComponent<ConfirmDeletionDialogFormProps & import("react").RefAttributes<CubeDialogFormRef>>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function DialogFormApp(): JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const baseProps: string[];
@@ -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];
@@ -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,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';