@unitedstatespowersquadrons/components 1.2.19 → 1.2.20
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/RailsForm.tsx +25 -0
- package/index.tsx +1 -0
- package/package.json +1 -1
package/RailsForm.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
action: string;
|
|
5
|
+
fileUpload?: boolean;
|
|
6
|
+
id?: string;
|
|
7
|
+
method?: "get" | "post";
|
|
8
|
+
children: React.ReactNode[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const RailsForm = (props: Props) => {
|
|
12
|
+
const { action, children, fileUpload, id, method } = props;
|
|
13
|
+
|
|
14
|
+
const token = document.querySelector("meta[name='csrf-token']");
|
|
15
|
+
const csrfToken = token ? token.getAttribute("content")! : "";
|
|
16
|
+
|
|
17
|
+
return(
|
|
18
|
+
<form action={action} encType={fileUpload ? "multipart/form-data" : undefined} id={id} method={method}>
|
|
19
|
+
<input name="authenticity_token" type="hidden" value={csrfToken} />
|
|
20
|
+
{children}
|
|
21
|
+
</form>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default RailsForm;
|
package/index.tsx
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./Flags";
|
|
|
15
15
|
export { default as ActionButton } from "./ActionButton";
|
|
16
16
|
export { default as IconButton } from "./IconButton";
|
|
17
17
|
export { default as SelectionIconButton } from "./SelectionIconButton";
|
|
18
|
+
export { default as RailsForm } from "./RailsForm";
|
|
18
19
|
export * from "./Toasts";
|
|
19
20
|
export { default as Colors } from "./Colors";
|
|
20
21
|
export { default as Styles } from "./Styles";
|