@tsed/react-formio 1.10.4 → 1.10.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "1.10.4",
3
+ "version": "1.10.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.modern.js",
6
6
  "source": "src/index.ts",
@@ -13,7 +13,7 @@
13
13
  "prettier": "prettier '{src,test}/**/*.{ts,tsx}' --write"
14
14
  },
15
15
  "dependencies": {
16
- "@tsed/redux-utils": "1.10.4",
16
+ "@tsed/redux-utils": "1.10.8",
17
17
  "eventemitter2": "^6.4.3",
18
18
  "prop-types": "^15.7.2"
19
19
  },
@@ -28,8 +28,8 @@
28
28
  "tooltip.js": "^1.3.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@tsed/tailwind": "1.10.4",
32
- "@tsed/tailwind-formio": "1.10.4"
31
+ "@tsed/tailwind": "1.10.8",
32
+ "@tsed/tailwind-formio": "1.10.8"
33
33
  },
34
34
  "repository": "https://github.com/TypedProject/tsed-formio",
35
35
  "bugs": {
@@ -42,15 +42,11 @@ export const useForm = (props: any): any => {
42
42
  props.hasOwnProperty(funcName) &&
43
43
  typeof funcs[funcName] === "function"
44
44
  ) {
45
- if (["onSubmit", "onSubmitDone"].includes(funcName)) {
46
- funcs[funcName](...args);
47
- } else {
48
- if (!events.current.has(funcName)) {
49
- const fn = callLast(funcs[funcName], 100);
50
- events.current.set(funcName, fn);
51
- }
52
- events.current.get(funcName)(...args);
45
+ if (!events.current.has(funcName)) {
46
+ const fn = callLast(funcs[funcName], 100);
47
+ events.current.set(funcName, fn);
53
48
  }
49
+ events.current.get(funcName)(...args);
54
50
  }
55
51
  }
56
52
  });
@@ -66,8 +62,6 @@ export const useForm = (props: any): any => {
66
62
  });
67
63
  }
68
64
 
69
- useEffect(() => {}, []);
70
-
71
65
  return instance.current;
72
66
  };
73
67
 
@@ -101,6 +95,26 @@ export const useForm = (props: any): any => {
101
95
  }
102
96
  }, [src]);
103
97
 
98
+ useEffect(() => {
99
+ if (form) {
100
+ createWebForm(form, options);
101
+ }
102
+
103
+ return () => {
104
+ isLoaded.current = false;
105
+ instance.current && instance.current.destroy(true);
106
+ };
107
+ }, []);
108
+
109
+ useEffect(() => {
110
+ props.onSubmit && events.current.set("onSubmit", props.onSubmit);
111
+ }, [props.onSubmit, events]);
112
+
113
+ useEffect(() => {
114
+ props.onSubmitDone &&
115
+ events.current.set("onSubmitDone", props.onSubmitDone);
116
+ }, [props.onSubmitDone, events]);
117
+
104
118
  return {
105
119
  element
106
120
  };
@@ -1,6 +1,6 @@
1
1
  import classnames from "classnames";
2
2
  import noop from "lodash/noop";
3
- import React, { useState } from "react";
3
+ import React, { PropsWithChildren, useState } from "react";
4
4
  import { iconClass } from "../../utils/iconClass";
5
5
  import { InputText } from "../input-text/inputText.component";
6
6
  import { Modal, ModalProps } from "./modal.component";
@@ -42,22 +42,29 @@ export interface RemoveModalProps extends ModalProps {
42
42
  valueToCompare: string;
43
43
  itemType?: string;
44
44
  i18n?: (f: string) => string;
45
+ maxWidth?: string;
45
46
  }
46
47
 
47
- export function RemoveModal(props: RemoveModalProps) {
48
+ export function RemoveModal({
49
+ maxWidth = "300px",
50
+ children,
51
+ ...props
52
+ }: PropsWithChildren<RemoveModalProps>) {
48
53
  const { i18n = noop } = props;
49
54
  const [value, setValue] = useState();
50
55
 
51
56
  return (
52
57
  <Modal
53
58
  {...props}
54
- style={{ maxWidth: "300px" }}
59
+ className={classnames(props.className, "formio-dialog-theme-remove")}
60
+ style={{ maxWidth }}
55
61
  title={`Drop ${props.itemType?.toLowerCase()}`}
56
62
  value={value}
57
63
  footer={RemoveModalFooter}
58
64
  >
59
65
  <div className={"px-4 pt-3 pb-5"}>
60
66
  <div className={"pb-1"}>
67
+ {children}
61
68
  {i18n("To drop")} <strong>{props.valueToCompare}</strong>,&nbsp;
62
69
  {i18n("type the")}&nbsp;
63
70
  <strong>&quot;{props.itemType?.toLowerCase()}&quot;</strong>&nbsp;
@@ -1,6 +1,9 @@
1
1
  import React from "react";
2
2
 
3
- export function Cell({ value, render = (f: any) => f }: any): JSX.Element {
3
+ export function DefaultCell({
4
+ value,
5
+ render = (f: any) => f
6
+ }: any): JSX.Element {
4
7
  if (value === undefined) {
5
8
  return <></>;
6
9
  }
@@ -1,6 +1,6 @@
1
1
  export * from "./utils/useOperations.hook";
2
- export * from "./components/cell.component";
3
2
  export * from "./components/defaultArrowSort.component";
3
+ export * from "./components/defaultCell.component";
4
4
  export * from "./components/defaultCellHeader.component";
5
5
  export * from "./components/defaultCellHeader.component";
6
6
  export * from "./components/defaultCellOperations.component";
@@ -1,9 +1,9 @@
1
+ import React from "react";
1
2
  import { Components, ExtendedComponentSchema } from "formiojs";
2
3
  import FormioUtils from "formiojs/utils";
3
- import React from "react";
4
4
  import { Column } from "react-table";
5
5
  import { FormSchema } from "../../../interfaces";
6
- import { Cell } from "../components/cell.component";
6
+ import { DefaultCell } from "../components/defaultCell.component";
7
7
  import { SelectColumnFilter } from "../filters/selectColumnFilter.component";
8
8
 
9
9
  export function mapFormToColumns(form: FormSchema): Column[] {
@@ -19,7 +19,10 @@ export function mapFormToColumns(form: FormSchema): Column[] {
19
19
  Header: component.label || component.title || component.key,
20
20
  accessor: `data.${component.key}`,
21
21
  Cell: (props: any) => (
22
- <Cell {...props} render={(value: any) => cmp.asString(value)} />
22
+ <DefaultCell
23
+ {...props}
24
+ render={(value: any) => cmp.asString(value)}
25
+ />
23
26
  )
24
27
  };
25
28
 
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function Cell({ value, render }: any): JSX.Element;