@tsed/react-formio 2.3.0 → 2.3.2

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 (26) hide show
  1. package/coverage.json +4 -4
  2. package/dist/components/actions-table/actionsTable.stories.d.ts +8 -53
  3. package/dist/components/form-access/formAccess.component.d.ts +2 -13
  4. package/dist/components/form-access/formAccess.stories.d.ts +3 -44
  5. package/dist/components/form-control/formControl.component.d.ts +3 -11
  6. package/dist/components/select/select.component.d.ts +5 -18
  7. package/dist/components/table/components/defaultCellOperations.component.d.ts +12 -1
  8. package/dist/components/table/components/defaultOperationButton.component.d.ts +4 -4
  9. package/dist/components/table/hooks/useOperations.hook.d.ts +2 -2
  10. package/dist/index.js +1113 -1265
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.modern.js +226 -244
  13. package/dist/index.modern.js.map +1 -1
  14. package/package.json +13 -6
  15. package/src/components/__fixtures__/form-actions.json +240 -0
  16. package/src/components/actions-table/__fixtures__/data.json +12 -0
  17. package/src/components/actions-table/actionsTable.component.spec.tsx +42 -11
  18. package/src/components/actions-table/actionsTable.component.tsx +2 -1
  19. package/src/components/actions-table/actionsTable.stories.tsx +71 -289
  20. package/src/components/form-access/formAccess.component.tsx +2 -12
  21. package/src/components/form-access/formAccess.stories.tsx +55 -49
  22. package/src/components/form-control/formControl.component.tsx +4 -11
  23. package/src/components/select/select.component.tsx +9 -22
  24. package/src/components/table/components/defaultCellOperations.component.tsx +17 -4
  25. package/src/components/table/components/defaultOperationButton.component.tsx +9 -4
  26. package/src/components/table/hooks/useOperations.hook.tsx +3 -3
package/coverage.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "statements": 56.02,
3
- "branches": 46.56,
4
- "functions": 48.33,
5
- "lines": 56.04
2
+ "statements": 0,
3
+ "branches": 0,
4
+ "functions": 0,
5
+ "lines": 0
6
6
  }
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type { StoryObj } from "@storybook/react";
2
2
  import { ActionsTable } from "./actionsTable.component";
3
3
  declare const _default: {
4
4
  title: string;
@@ -6,37 +6,27 @@ declare const _default: {
6
6
  argTypes: {
7
7
  data: {
8
8
  control: {
9
- type: string;
9
+ type: "object";
10
10
  };
11
11
  };
12
12
  operations: {
13
13
  control: {
14
- type: string;
14
+ type: "object";
15
15
  };
16
16
  };
17
17
  isLoading: {
18
18
  control: {
19
- type: string;
20
- };
21
- };
22
- isEmpty: {
23
- control: {
24
- type: string;
19
+ type: "boolean";
25
20
  };
26
21
  };
27
22
  disableFilters: {
28
23
  control: {
29
- type: string;
24
+ type: "boolean";
30
25
  };
31
26
  };
32
27
  disablePagination: {
33
28
  control: {
34
- type: string;
35
- };
36
- };
37
- tags: {
38
- control: {
39
- type: string;
29
+ type: "boolean";
40
30
  };
41
31
  };
42
32
  onAddAction: {
@@ -46,40 +36,5 @@ declare const _default: {
46
36
  parameters: {};
47
37
  };
48
38
  export default _default;
49
- export declare const Sandbox: {
50
- (args: any): React.JSX.Element;
51
- args: {
52
- icon: string;
53
- availableActions: {
54
- label: string;
55
- value: string;
56
- }[];
57
- data: {
58
- _id: string;
59
- handler: string[];
60
- method: string[];
61
- priority: number;
62
- name: string;
63
- title: string;
64
- form: string;
65
- machineName: string;
66
- }[];
67
- operations: ({
68
- title: string;
69
- action: string;
70
- alias: string;
71
- path: string;
72
- icon: string;
73
- permissionsResolver(): boolean;
74
- buttonType?: undefined;
75
- } | {
76
- action: string;
77
- path: string;
78
- icon: string;
79
- buttonType: string;
80
- permissionsResolver(): boolean;
81
- title?: undefined;
82
- alias?: undefined;
83
- })[];
84
- };
85
- };
39
+ type Story = StoryObj<typeof ActionsTable>;
40
+ export declare const Sandbox: Story;
@@ -1,5 +1,4 @@
1
- import PropTypes from "prop-types";
2
- import { PropsWithChildren, ReactElement } from "react";
1
+ import React, { PropsWithChildren } from "react";
3
2
  import type { FormOptions, FormSchema } from "../../interfaces";
4
3
  export interface FormAccessProps {
5
4
  form: Partial<FormSchema>;
@@ -7,14 +6,4 @@ export interface FormAccessProps {
7
6
  onSubmit?: Function;
8
7
  options?: FormOptions;
9
8
  }
10
- export declare function FormAccess(props: PropsWithChildren<FormAccessProps>): ReactElement;
11
- export declare namespace FormAccess {
12
- var propTypes: {
13
- type: PropTypes.Validator<string>;
14
- form: PropTypes.Requireable<object>;
15
- roles: PropTypes.Requireable<any>;
16
- children: PropTypes.Requireable<any>;
17
- options: PropTypes.Requireable<any>;
18
- onSubmit: PropTypes.Requireable<(...args: any[]) => any>;
19
- };
20
- }
9
+ export declare function FormAccess(props: PropsWithChildren<FormAccessProps>): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type { StoryObj } from "@storybook/react";
2
2
  import { FormAccess } from "./formAccess.component";
3
3
  declare const _default: {
4
4
  title: string;
@@ -7,16 +7,6 @@ declare const _default: {
7
7
  onSubmit: {
8
8
  action: string;
9
9
  };
10
- actionInfo: {
11
- control: {
12
- type: string;
13
- };
14
- };
15
- options: {
16
- control: {
17
- type: string;
18
- };
19
- };
20
10
  };
21
11
  parameters: {
22
12
  docs: {
@@ -27,36 +17,5 @@ declare const _default: {
27
17
  };
28
18
  };
29
19
  export default _default;
30
- export declare const Sandbox: {
31
- (args: any): React.JSX.Element;
32
- args: {
33
- form: {
34
- _id: string;
35
- type: string;
36
- tags: never[];
37
- owner: string;
38
- access: {
39
- roles: string[];
40
- type: string;
41
- }[];
42
- submissionAccess: {
43
- roles: string[];
44
- type: string;
45
- }[];
46
- controller: string;
47
- properties: {};
48
- settings: {};
49
- name: string;
50
- path: string;
51
- machineName: string;
52
- };
53
- roles: {
54
- title: string;
55
- _id: string;
56
- }[];
57
- options: {
58
- template: string;
59
- iconset: string;
60
- };
61
- };
62
- };
20
+ type Story = StoryObj<typeof FormAccess>;
21
+ export declare const Sandbox: Story;
@@ -1,22 +1,14 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
- export interface FormControlProps {
2
+ export interface FormControlProps<Data = any> {
4
3
  name: string;
4
+ value?: Data;
5
5
  required?: boolean;
6
6
  label?: string;
7
7
  className?: string;
8
+ onChange?: (name: string, value: any) => void;
8
9
  description?: string | React.ComponentType | any;
9
10
  prefix?: JSX.Element | React.ComponentType | any;
10
11
  suffix?: JSX.Element | React.ComponentType | any;
11
12
  shadow?: boolean;
12
13
  }
13
14
  export declare function FormControl({ children, name, required, prefix, suffix, description, label, className }: React.PropsWithChildren<FormControlProps>): React.JSX.Element;
14
- export declare namespace FormControl {
15
- var propTypes: {
16
- label: PropTypes.Requireable<string>;
17
- name: PropTypes.Validator<string>;
18
- children: PropTypes.Requireable<any>;
19
- required: PropTypes.Requireable<boolean>;
20
- description: PropTypes.Requireable<any>;
21
- };
22
- }
@@ -1,27 +1,14 @@
1
- import PropTypes from "prop-types";
2
- import { ReactElement } from "react";
1
+ import { HTMLAttributes, ReactElement } from "react";
3
2
  import { FormControlProps } from "../form-control/formControl.component";
4
- export interface SelectProps<T = any> extends FormControlProps {
5
- value?: any;
3
+ export interface SelectProps<Data = any> extends FormControlProps, Omit<HTMLAttributes<HTMLSelectElement>, "onChange" | "prefix"> {
6
4
  size?: string;
7
- onChange?: (name: string, value: any) => void;
8
5
  placeholder?: string;
9
6
  choices: {
10
7
  label: string;
11
- value: T;
8
+ value: Data;
12
9
  }[];
13
10
  layout?: "html5" | "choicesjs";
11
+ disabled?: boolean;
14
12
  multiple?: boolean;
15
- [key: string]: any;
16
- }
17
- export declare function Select<T = any>({ name, label, size, onChange, required, value, choices, description, placeholder, prefix, suffix, multiple, layout, ...props }: SelectProps<T>): ReactElement;
18
- export declare namespace Select {
19
- var propTypes: {
20
- label: PropTypes.Requireable<string>;
21
- name: PropTypes.Validator<string>;
22
- value: PropTypes.Requireable<any>;
23
- required: PropTypes.Requireable<boolean>;
24
- onChange: PropTypes.Requireable<(...args: any[]) => any>;
25
- choices: PropTypes.Validator<any[]>;
26
- };
27
13
  }
14
+ export declare function Select<Data = any>({ name, label, size, onChange, required, value, choices, description, placeholder, prefix, suffix, multiple, layout, ...props }: SelectProps<Data>): ReactElement;
@@ -1,2 +1,13 @@
1
1
  import React from "react";
2
- export declare function DefaultCellOperations({ operations, row, onClick, ctx, i18n }: any): React.JSX.Element;
2
+ import { DefaultOperationButton, OperationButtonProps } from "./defaultOperationButton.component";
3
+ export interface DefaultCellOperationsProps {
4
+ operations: (OperationButtonProps & {
5
+ OperationButton: typeof DefaultOperationButton;
6
+ permissionsResolver?(data: unknown, ctx: any): boolean;
7
+ })[];
8
+ row: any;
9
+ onClick: (data: any, action: string) => void;
10
+ ctx: any;
11
+ i18n: (i18n: string) => string;
12
+ }
13
+ export declare function DefaultCellOperations({ operations, row, onClick, ctx, i18n }: DefaultCellOperationsProps): React.JSX.Element;
@@ -1,6 +1,5 @@
1
- import React from "react";
2
- export interface OperationButtonProps {
3
- className?: string;
1
+ import { HTMLAttributes } from "react";
2
+ export interface OperationButtonProps extends Omit<HTMLAttributes<HTMLButtonElement>, "onClick"> {
4
3
  buttonType?: string;
5
4
  buttonSize?: string;
6
5
  buttonOutline?: boolean;
@@ -10,5 +9,6 @@ export interface OperationButtonProps {
10
9
  icon?: string;
11
10
  title?: string;
12
11
  i18n?: (i18n: string) => string;
12
+ ctx?: any;
13
13
  }
14
- export declare function DefaultOperationButton(props: OperationButtonProps): React.JSX.Element;
14
+ export declare function DefaultOperationButton(props: OperationButtonProps): import("react").JSX.Element;
@@ -1,8 +1,8 @@
1
- import React from "react";
1
+ import { type ComponentType, type FunctionComponent } from "react";
2
2
  import { Hooks } from "react-table";
3
3
  import { Operation } from "../../../interfaces";
4
4
  export type UseOperationsHookProps = {
5
- CellOperations?: React.ComponentType;
5
+ CellOperations?: FunctionComponent | ComponentType<{}>;
6
6
  operations: Operation[];
7
7
  onClick?: (data: any, event: string) => void;
8
8
  i18n?: (f: string) => string;