@tsed/react-formio 1.10.5 → 1.10.9

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.5",
3
+ "version": "1.10.9",
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.5",
16
+ "@tsed/redux-utils": "1.10.9",
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.5",
32
- "@tsed/tailwind-formio": "1.10.5"
31
+ "@tsed/tailwind": "1.10.9",
32
+ "@tsed/tailwind-formio": "1.10.9"
33
33
  },
34
34
  "repository": "https://github.com/TypedProject/tsed-formio",
35
35
  "bugs": {
@@ -62,14 +62,6 @@ export const useForm = (props: any): any => {
62
62
  });
63
63
  }
64
64
 
65
- useEffect(() => {
66
- props.onSubmit && events.current.set("onSubmit", props.onSubmit);
67
- }, [props.onSubmit, events]);
68
-
69
- useEffect(() => {
70
- props.onSubmitDone && events.current.set("onSubmitDone", props.onSubmit);
71
- }, [props.onSubmitDone, events]);
72
-
73
65
  return instance.current;
74
66
  };
75
67
 
@@ -103,6 +95,26 @@ export const useForm = (props: any): any => {
103
95
  }
104
96
  }, [src]);
105
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
+
106
118
  return {
107
119
  element
108
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";
@@ -10,7 +10,7 @@ function RemoveModalFooter({
10
10
  valueToCompare,
11
11
  onSubmit,
12
12
  onClose,
13
- i18n = noop
13
+ i18n = (f: string) => f
14
14
  }: ModalProps) {
15
15
  return (
16
16
  <div className={"flex items-center justify-center bg-white p-2"}>
@@ -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;