@tsed/react-formio 3.0.0-alpha.10 → 3.0.0-alpha.12

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 (215) hide show
  1. package/dist/atoms/icon/Icon.js.map +1 -1
  2. package/dist/chunks/index.js +33 -30
  3. package/dist/chunks/index.js.map +1 -1
  4. package/dist/chunks/index.module.js +16 -16
  5. package/dist/chunks/index.module.js.map +1 -1
  6. package/dist/chunks/react-select-animated.esm.js +1204 -1101
  7. package/dist/chunks/react-select-animated.esm.js.map +1 -1
  8. package/dist/hooks/keyboard.constants.d.ts +38 -0
  9. package/dist/hooks/keyboard.constants.js +7 -0
  10. package/dist/hooks/keyboard.constants.js.map +1 -0
  11. package/dist/hooks/useKeyboardControls.d.ts +12 -0
  12. package/dist/hooks/useKeyboardControls.js +35 -0
  13. package/dist/hooks/useKeyboardControls.js.map +1 -0
  14. package/dist/hooks/useTooltip.js.map +1 -1
  15. package/dist/interfaces/Operation.d.ts +12 -2
  16. package/dist/molecules/alert/Alert.js.map +1 -1
  17. package/dist/molecules/button/Button.d.ts +18 -5
  18. package/dist/molecules/button/Button.js +22 -26
  19. package/dist/molecules/button/Button.js.map +1 -1
  20. package/dist/molecules/card/Card.js +7 -5
  21. package/dist/molecules/card/Card.js.map +1 -1
  22. package/dist/molecules/forms/form-control/FormControl.js.map +1 -1
  23. package/dist/molecules/forms/input-tags/InputTags.js +14 -14
  24. package/dist/molecules/forms/input-tags/InputTags.js.map +1 -1
  25. package/dist/molecules/forms/input-tags/components/ChoicesTags.js +26 -26
  26. package/dist/molecules/forms/input-tags/components/ChoicesTags.js.map +1 -1
  27. package/dist/molecules/forms/input-tags/components/ReactTags.js +289 -300
  28. package/dist/molecules/forms/input-tags/components/ReactTags.js.map +1 -1
  29. package/dist/molecules/forms/input-text/InputText.js +3 -3
  30. package/dist/molecules/forms/input-text/InputText.js.map +1 -1
  31. package/dist/molecules/forms/select/Select.js.map +1 -1
  32. package/dist/molecules/forms/select/components/ChoicesSelect.js +71 -73
  33. package/dist/molecules/forms/select/components/ChoicesSelect.js.map +1 -1
  34. package/dist/molecules/forms/select/components/HtmlSelect.js.map +1 -1
  35. package/dist/molecules/forms/select/components/ReactSelect.js +13 -14
  36. package/dist/molecules/forms/select/components/ReactSelect.js.map +1 -1
  37. package/dist/molecules/forms/select/components/choices.template.js +2340 -2257
  38. package/dist/molecules/forms/select/components/choices.template.js.map +1 -1
  39. package/dist/molecules/forms/select/hooks/useOptions.js.map +1 -1
  40. package/dist/molecules/loader/Loader.js.map +1 -1
  41. package/dist/molecules/modal/Modal.js +23 -24
  42. package/dist/molecules/modal/Modal.js.map +1 -1
  43. package/dist/molecules/pagination/Pagination.js +19 -19
  44. package/dist/molecules/pagination/Pagination.js.map +1 -1
  45. package/dist/molecules/pagination/PaginationButton.js.map +1 -1
  46. package/dist/molecules/pagination/utils/getPageNumbers.js.map +1 -1
  47. package/dist/molecules/table/Table.d.ts +11 -3
  48. package/dist/molecules/table/Table.js +31 -32
  49. package/dist/molecules/table/Table.js.map +1 -1
  50. package/dist/molecules/table/components/DefaultArrowSort.js.map +1 -1
  51. package/dist/molecules/table/components/DefaultCell.js.map +1 -1
  52. package/dist/molecules/table/components/DefaultCellFooter.js.map +1 -1
  53. package/dist/molecules/table/components/DefaultCellHeader.js.map +1 -1
  54. package/dist/molecules/table/components/DefaultCellOperations.d.ts +12 -4
  55. package/dist/molecules/table/components/DefaultCellOperations.js +13 -7
  56. package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
  57. package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
  58. package/dist/molecules/table/components/DefaultOperationButton.d.ts +12 -4
  59. package/dist/molecules/table/components/DefaultOperationButton.js +1 -1
  60. package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
  61. package/dist/molecules/table/filters/RangeFilter.js +23 -24
  62. package/dist/molecules/table/filters/RangeFilter.js.map +1 -1
  63. package/dist/molecules/table/filters/SelectFilter.js +11 -13
  64. package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
  65. package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
  66. package/dist/molecules/table/hooks/useTable.d.ts +12 -4
  67. package/dist/molecules/table/hooks/useTable.js +7 -7
  68. package/dist/molecules/table/hooks/useTable.js.map +1 -1
  69. package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
  70. package/dist/molecules/table/utils/mapFormToColumns.js +20 -21
  71. package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
  72. package/dist/molecules/tabs/Tab.d.ts +13 -0
  73. package/dist/molecules/tabs/Tab.js +66 -0
  74. package/dist/molecules/tabs/Tab.js.map +1 -0
  75. package/dist/molecules/tabs/TabList.d.ts +2 -0
  76. package/dist/molecules/tabs/TabList.js +23 -0
  77. package/dist/molecules/tabs/TabList.js.map +1 -0
  78. package/dist/molecules/tabs/TabPanel.d.ts +9 -0
  79. package/dist/molecules/tabs/TabPanel.js +27 -0
  80. package/dist/molecules/tabs/TabPanel.js.map +1 -0
  81. package/dist/molecules/tabs/Tabs.d.ts +4 -16
  82. package/dist/molecules/tabs/Tabs.js +7 -67
  83. package/dist/molecules/tabs/Tabs.js.map +1 -1
  84. package/dist/molecules/tabs/TabsBody.d.ts +1 -0
  85. package/dist/molecules/tabs/TabsBody.js +10 -0
  86. package/dist/molecules/tabs/TabsBody.js.map +1 -0
  87. package/dist/molecules/tabs/TabsLegacy.d.ts +17 -0
  88. package/dist/molecules/tabs/TabsLegacy.js +49 -0
  89. package/dist/molecules/tabs/TabsLegacy.js.map +1 -0
  90. package/dist/molecules/tabs/all.d.ts +5 -0
  91. package/dist/molecules/tabs/all.js +13 -0
  92. package/dist/molecules/tabs/all.js.map +1 -0
  93. package/dist/molecules/tabs/context/TabControl.d.ts +52 -0
  94. package/dist/molecules/tabs/context/TabControl.js +85 -0
  95. package/dist/molecules/tabs/context/TabControl.js.map +1 -0
  96. package/dist/molecules/tabs/hooks/tabControl.d.ts +44 -0
  97. package/dist/molecules/tabs/hooks/tabControl.js +34 -0
  98. package/dist/molecules/tabs/hooks/tabControl.js.map +1 -0
  99. package/dist/organisms/form/Form.js.map +1 -1
  100. package/dist/organisms/form/access/FormAccess.js +41 -41
  101. package/dist/organisms/form/access/FormAccess.js.map +1 -1
  102. package/dist/organisms/form/access/FormAccess.schema.js.map +1 -1
  103. package/dist/organisms/form/access/FormAccess.utils.js +2 -2
  104. package/dist/organisms/form/access/FormAccess.utils.js.map +1 -1
  105. package/dist/organisms/form/{action → actions}/FormAction.js +7 -8
  106. package/dist/organisms/form/actions/FormAction.js.map +1 -0
  107. package/dist/organisms/form/builder/FormBuilder.js.map +1 -1
  108. package/dist/organisms/form/builder/FormEdit.d.ts +3 -1
  109. package/dist/organisms/form/builder/FormEdit.js +38 -35
  110. package/dist/organisms/form/builder/FormEdit.js.map +1 -1
  111. package/dist/organisms/form/builder/FormEdit.reducer.js.map +1 -1
  112. package/dist/organisms/form/builder/FormEditCtas.js +34 -34
  113. package/dist/organisms/form/builder/FormEditCtas.js.map +1 -1
  114. package/dist/organisms/form/builder/FormParameters.js.map +1 -1
  115. package/dist/organisms/form/builder/useFormBuilder.js +41 -38
  116. package/dist/organisms/form/builder/useFormBuilder.js.map +1 -1
  117. package/dist/organisms/form/builder/useFormEdit.js +1 -1
  118. package/dist/organisms/form/builder/useFormEdit.js.map +1 -1
  119. package/dist/organisms/form/exports/FormExport.d.ts +5 -0
  120. package/dist/organisms/form/exports/FormExport.js +55 -0
  121. package/dist/organisms/form/exports/FormExport.js.map +1 -0
  122. package/dist/organisms/form/preview/FormPreview.d.ts +6 -0
  123. package/dist/organisms/form/preview/FormPreview.js +11 -0
  124. package/dist/organisms/form/preview/FormPreview.js.map +1 -0
  125. package/dist/organisms/form/settings/FormSettings.js +24 -24
  126. package/dist/organisms/form/settings/FormSettings.js.map +1 -1
  127. package/dist/organisms/form/settings/FormSettings.schema.js.map +1 -1
  128. package/dist/organisms/form/settings/FormSettings.utils.js.map +1 -1
  129. package/dist/organisms/form/useForm.js +664 -661
  130. package/dist/organisms/form/useForm.js.map +1 -1
  131. package/dist/organisms/modal/RemoveModal.js +16 -17
  132. package/dist/organisms/modal/RemoveModal.js.map +1 -1
  133. package/dist/organisms/table/actions/ActionsTable.js.map +1 -1
  134. package/dist/organisms/table/forms/FormsTable.js.map +1 -1
  135. package/dist/organisms/table/forms/components/FormsCell.js.map +1 -1
  136. package/dist/organisms/table/submissions/SubmissionsTable.d.ts +11 -3
  137. package/dist/organisms/table/submissions/SubmissionsTable.js +4 -1
  138. package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
  139. package/dist/organisms/views/FormViews.d.ts +24 -0
  140. package/dist/organisms/views/FormViews.js +96 -0
  141. package/dist/organisms/views/FormViews.js.map +1 -0
  142. package/dist/registries/components.js.map +1 -1
  143. package/dist/utils/getEventValue.js.map +1 -1
  144. package/dist/utils/iconClass.js.map +1 -1
  145. package/dist/utils/mapPagination.js.map +1 -1
  146. package/dist/utils/stopPropagationWrapper.js.map +1 -1
  147. package/package.json +7 -7
  148. package/src/atoms/icon/Icon.stories.tsx +1 -1
  149. package/src/hooks/keyboard.constants.ts +40 -0
  150. package/src/hooks/useKeyboardControls.spec.tsx +208 -0
  151. package/src/hooks/useKeyboardControls.ts +84 -0
  152. package/src/interfaces/Operation.ts +9 -3
  153. package/src/molecules/button/Button.stories.tsx +1 -1
  154. package/src/molecules/button/Button.tsx +43 -24
  155. package/src/molecules/card/Card.tsx +4 -0
  156. package/src/molecules/forms/form-control/FormControl.stories.tsx +1 -1
  157. package/src/molecules/forms/input-tags/InputTags.tsx +1 -1
  158. package/src/molecules/forms/input-tags/components/ChoicesTags.stories.tsx +1 -1
  159. package/src/molecules/forms/input-tags/components/ReactTags.stories.tsx +1 -1
  160. package/src/molecules/forms/input-text/InputText.stories.tsx +2 -2
  161. package/src/molecules/forms/select/components/ChoicesSelect.stories.tsx +2 -2
  162. package/src/molecules/forms/select/components/HtmlSelect.stories.tsx +2 -2
  163. package/src/molecules/forms/select/components/ReactSelect.stories.tsx +2 -2
  164. package/src/molecules/loader/Loader.stories.tsx +1 -1
  165. package/src/molecules/modal/Modal.stories.tsx +1 -1
  166. package/src/molecules/pagination/Pagination.stories.tsx +1 -8
  167. package/src/molecules/pagination/Pagination.tsx +0 -1
  168. package/src/molecules/table/Table.stories.tsx +36 -3
  169. package/src/molecules/table/Table.tsx +12 -6
  170. package/src/molecules/table/components/DefaultCellOperations.tsx +13 -7
  171. package/src/molecules/table/components/DefaultOperationButton.tsx +5 -4
  172. package/src/molecules/table/filters/SelectFilter.tsx +1 -1
  173. package/src/molecules/table/hooks/useTable.tsx +5 -5
  174. package/src/molecules/tabs/Tab.tsx +106 -0
  175. package/src/molecules/tabs/TabList.tsx +37 -0
  176. package/src/molecules/tabs/TabPanel.tsx +37 -0
  177. package/src/molecules/tabs/Tabs.spec.tsx +126 -73
  178. package/src/molecules/tabs/Tabs.stories.tsx +298 -65
  179. package/src/molecules/tabs/Tabs.tsx +10 -81
  180. package/src/molecules/tabs/TabsBody.tsx +11 -0
  181. package/src/molecules/tabs/TabsLegacy.stories.tsx +103 -0
  182. package/src/molecules/tabs/TabsLegacy.tsx +84 -0
  183. package/src/molecules/tabs/all.ts +5 -0
  184. package/src/molecules/tabs/context/TabControl.tsx +166 -0
  185. package/src/molecules/tabs/hooks/tabControl.spec.tsx +388 -0
  186. package/src/molecules/tabs/hooks/tabControl.ts +52 -0
  187. package/src/organisms/__fixtures__/form-firstname.fixture.json +1 -0
  188. package/src/organisms/__fixtures__/form.fixture.json +1 -0
  189. package/src/organisms/form/Form.stories.tsx +94 -118
  190. package/src/organisms/form/access/FormAccess.stories.tsx +2 -2
  191. package/src/organisms/form/actions/FormAction.stories.tsx +422 -0
  192. package/src/organisms/form/builder/FormBuilder.stories.tsx +4 -1
  193. package/src/organisms/form/builder/FormEdit.stories.tsx +1 -1
  194. package/src/organisms/form/builder/FormEdit.tsx +7 -1
  195. package/src/organisms/form/builder/useFormBuilder.ts +5 -1
  196. package/src/organisms/form/builder/useFormEdit.ts +1 -1
  197. package/src/organisms/form/exports/FormExport.stories.tsx +71 -0
  198. package/src/organisms/form/exports/FormExport.tsx +58 -0
  199. package/src/organisms/form/preview/FormPreview.stories.tsx +61 -0
  200. package/src/organisms/form/preview/FormPreview.tsx +21 -0
  201. package/src/organisms/modal/RemoveModal.stories.tsx +1 -1
  202. package/src/organisms/table/actions/ActionsTable.stories.tsx +38 -36
  203. package/src/organisms/table/submissions/SubmissionsTable.stories.tsx +103 -57
  204. package/src/organisms/table/submissions/SubmissionsTable.tsx +10 -4
  205. package/src/organisms/views/FormViews.stories.tsx +224 -0
  206. package/src/organisms/views/FormViews.tsx +146 -0
  207. package/vite.config.mts +2 -2
  208. package/dist/organisms/form/action/FormAction.js.map +0 -1
  209. package/src/organisms/form/action/FormAction.stories.tsx +0 -364
  210. package/tsconfig.app.json +0 -11
  211. package/tsconfig.json +0 -21
  212. package/tsconfig.node.json +0 -13
  213. package/tsconfig.spec.json +0 -14
  214. /package/dist/organisms/form/{action → actions}/FormAction.d.ts +0 -0
  215. /package/src/organisms/form/{action → actions}/FormAction.tsx +0 -0
@@ -0,0 +1,146 @@
1
+ import type { FormType, JSON, PermissionsResolver } from "../../interfaces/index.js";
2
+ import type { Tab as DefaultTab } from "../../molecules/tabs/Tab.js";
3
+ import type { TabList as DefaultTabList } from "../../molecules/tabs/TabList.js";
4
+ import type { TabPanel as DefaultTabPanel } from "../../molecules/tabs/TabPanel.js";
5
+ import type { Tabs as DefaultTabs } from "../../molecules/tabs/Tabs.js";
6
+ import type { TabsBody as DefaultTabsBody } from "../../molecules/tabs/TabsBody.js";
7
+ import { getComponent } from "../../registries/components.js";
8
+ import { FormAccess, type FormAccessProps } from "../form/access/FormAccess.js";
9
+ import { FormEdit, type FormEditProps } from "../form/builder/FormEdit.js";
10
+ import { FormExport } from "../form/exports/FormExport.js";
11
+ import { FormPreview } from "../form/preview/FormPreview.js";
12
+ import { FormSettings } from "../form/settings/FormSettings.js";
13
+ import { ActionsTable, type ActionsTableProps } from "../table/actions/ActionsTable.js";
14
+ import { SubmissionsTable, type SubmissionsTableProps } from "../table/submissions/SubmissionsTable.js";
15
+
16
+ export type FormViewsProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> = {
17
+ form: FormEditProps["form"];
18
+ submissions: SubmissionsTableProps<Data>["data"];
19
+ availableActions: ActionsTableProps["availableActions"];
20
+ actions: ActionsTableProps["data"];
21
+ roles?: FormAccessProps["roles"];
22
+ i18n?: (key: string) => string;
23
+ onAction: () => void;
24
+ permissionsResolver?: PermissionsResolver<Data>;
25
+ };
26
+
27
+ function useSubmissionsOperations<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(
28
+ permissionsResolver?: PermissionsResolver<Data>
29
+ ) {
30
+ return [
31
+ {
32
+ title: "Edit",
33
+ action: "submission:edit",
34
+ alias: "row",
35
+ icon: "edit",
36
+ permissionsResolver
37
+ },
38
+ {
39
+ action: "submission:delete",
40
+ icon: "trash",
41
+ buttonType: "danger",
42
+ permissionsResolver
43
+ }
44
+ ] as SubmissionsTableProps<Data>["operations"];
45
+ }
46
+
47
+ function useActionsOperations<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(
48
+ permissionsResolver?: PermissionsResolver<Data>
49
+ ) {
50
+ return [
51
+ {
52
+ title: "Edit",
53
+ action: "action:edit",
54
+ alias: "row",
55
+ icon: "edit",
56
+ permissionsResolver
57
+ },
58
+ {
59
+ action: "action:delete",
60
+ icon: "trash",
61
+ buttonType: "danger",
62
+ permissionsResolver
63
+ }
64
+ ] as SubmissionsTableProps<Data>["operations"];
65
+ }
66
+
67
+ export function FormViews<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({
68
+ form,
69
+ roles,
70
+ availableActions,
71
+ actions,
72
+ permissionsResolver,
73
+ submissions,
74
+ i18n = (f) => f
75
+ }: FormViewsProps<Data>) {
76
+ const Tabs = getComponent<typeof DefaultTabs>("Tabs");
77
+ const TabList = getComponent<typeof DefaultTabList>("TabList");
78
+ const Tab = getComponent<typeof DefaultTab>("Tab");
79
+ const TabsBody = getComponent<typeof DefaultTabsBody>("TabsBody");
80
+ const TabPanel = getComponent<typeof DefaultTabPanel>("TabPanel");
81
+ const submissionsOperations = useSubmissionsOperations<Data>(permissionsResolver);
82
+ const actionsOperations = useActionsOperations<any>(permissionsResolver);
83
+
84
+ return (
85
+ <Tabs>
86
+ <TabList>
87
+ <Tab value={0} icon='edit'>
88
+ {i18n("Edit")}
89
+ </Tab>
90
+ <Tab value={1} icon='data'>
91
+ {i18n("Data")}
92
+ </Tab>
93
+ <Tab value={2} icon='test-tube'>
94
+ {i18n("Preview")}
95
+ </Tab>
96
+ <Tab value={3} icon='paper-plane'>
97
+ {i18n("Actions")}
98
+ </Tab>
99
+ <Tab value={4} icon='lock'>
100
+ {i18n("Access")}
101
+ </Tab>
102
+ <Tab value={5} icon='download'>
103
+ {i18n("Export")}
104
+ </Tab>
105
+ <Tab value={6} icon='cog'>
106
+ {i18n("Settings")}
107
+ </Tab>
108
+ </TabList>
109
+ <TabsBody>
110
+ <TabPanel value={0} className='p-3 border-l-1 border-b-1 border-r-1 border-gray-300'>
111
+ <FormEdit form={form} options={{ i18n }} />
112
+ </TabPanel>
113
+ <TabPanel value={1}>
114
+ <SubmissionsTable<Data>
115
+ className={"border-top-0"}
116
+ form={form as FormType}
117
+ data={submissions}
118
+ i18n={i18n}
119
+ operations={submissionsOperations}
120
+ />
121
+ </TabPanel>
122
+ <TabPanel value={2}>
123
+ <FormPreview form={form as FormType} i18n={i18n} />
124
+ </TabPanel>
125
+ <TabPanel value={3}>
126
+ <ActionsTable
127
+ className={"border-top-0"}
128
+ availableActions={availableActions}
129
+ data={actions}
130
+ operations={actionsOperations as any}
131
+ i18n={i18n}
132
+ />
133
+ </TabPanel>
134
+ <TabPanel value={4} className='pt-3'>
135
+ <FormAccess form={form as FormType} roles={roles} options={{ i18n }} />
136
+ </TabPanel>
137
+ <TabPanel value={5} className='pt-3'>
138
+ <FormExport i18n={i18n} />
139
+ </TabPanel>
140
+ <TabPanel value={6} className='p-3 border-l-1 border-b-1 border-r-1 border-gray-300'>
141
+ <FormSettings form={form as FormType} options={{}} />
142
+ </TabPanel>
143
+ </TabsBody>
144
+ </Tabs>
145
+ );
146
+ }
package/vite.config.mts CHANGED
@@ -6,16 +6,16 @@ import {extname, relative} from "path";
6
6
  import preserveDirectives from "rollup-preserve-directives";
7
7
  import {defineConfig} from "vite";
8
8
  import dts from "vite-plugin-dts";
9
- import {resolve} from "node:path";
10
9
 
11
10
  import pkg from "./package.json" with {type: "json"};
11
+ import {resolve} from "node:path";
12
12
 
13
13
  // https://vitejs.dev/config/
14
14
  export default defineConfig({
15
15
  plugins: [
16
16
  react(),
17
17
  dts({
18
- tsconfigPath: "./tsconfig.app.json",
18
+ tsconfigPath: "../../tsconfig.app.json",
19
19
  aliasesExclude: [],
20
20
  include: ["src/**/*.{ts,tsx}"],
21
21
  exclude: ["**/*.spec.{ts,tsx}", "**/*.stories.{ts,tsx}", "**/__*__/**"]
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormAction.js","sources":["../../../../src/organisms/form/action/FormAction.tsx"],"sourcesContent":["import FormioUtils from \"formiojs/utils\";\nimport { PropsWithChildren, ReactElement } from \"react\";\n\nimport { ActionDefaultsType, ActionType, FormOptions, SubmissionType } from \"../../../interfaces\";\nimport { Form } from \"../../form/Form\";\n\nfunction mapData(options: any, defaults: ActionDefaultsType): any {\n return {\n ...defaults,\n ...options\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction mapSettingsForm({ action, ...settingsForm }: any): any {\n FormioUtils.eachComponent(settingsForm.components, (component: any) => {\n const resourceExclude = \"\";\n\n if (component.type === \"resourcefields\") {\n component.type = \"select\";\n component.label = component.title;\n component.dataSrc = \"url\";\n component.data = {\n url: `${component.basePath}?type=resource${resourceExclude}`\n };\n component.valueProperty = \"_id\";\n component.template = \"<span>{{ item.title }}</span>\";\n component.persistent = true;\n }\n });\n\n return settingsForm;\n}\n\nexport interface FormActionProps {\n actionInfo: Partial<ActionType>;\n submission?: Partial<SubmissionType>;\n onSubmit?: (submission: SubmissionType<ActionType>) => void;\n options: FormOptions;\n}\n\nexport function FormAction({ actionInfo, children, onSubmit, options, ...props }: PropsWithChildren<FormActionProps>): ReactElement {\n const { form, submission } = (() => {\n const submission = mapData(props.submission || {}, actionInfo.defaults!);\n const form = mapSettingsForm(actionInfo.settingsForm);\n\n return { form, submission: { data: submission } };\n })();\n\n return (\n <div>\n {children}\n\n <Form<ActionType> form={form} submission={submission} onSubmit={onSubmit} options={options} />\n\n {children}\n </div>\n );\n}\n"],"names":["mapData","options","defaults","mapSettingsForm","action","settingsForm","FormioUtils","component","resourceExclude","FormAction","actionInfo","children","onSubmit","props","form","submission","jsx","Form"],"mappings":";;;AAMA,SAASA,EAAQC,GAAcC,GAAmC;AACzD,SAAA;AAAA,IACL,GAAGA;AAAA,IACH,GAAGD;AAAA,EACL;AACF;AAGA,SAASE,EAAgB,EAAE,QAAAC,GAAQ,GAAGC,KAA0B;AAC9D,SAAAC,EAAY,cAAcD,EAAa,YAAY,CAACE,MAAmB;AACrE,UAAMC,IAAkB;AAEpB,IAAAD,EAAU,SAAS,qBACrBA,EAAU,OAAO,UACjBA,EAAU,QAAQA,EAAU,OAC5BA,EAAU,UAAU,OACpBA,EAAU,OAAO;AAAA,MACf,KAAK,GAAGA,EAAU,QAAQ,iBAAiBC,CAAe;AAAA,IAC5D,GACAD,EAAU,gBAAgB,OAC1BA,EAAU,WAAW,iCACrBA,EAAU,aAAa;AAAA,EACzB,CACD,GAEMF;AACT;AASgB,SAAAI,EAAW,EAAE,YAAAC,GAAY,UAAAC,GAAU,UAAAC,GAAU,SAAAX,GAAS,GAAGY,KAA2D;AAClI,QAAM,EAAE,MAAAC,GAAM,YAAAC,EAAW,KAAK,MAAM;AAClC,UAAMA,IAAaf,EAAQa,EAAM,cAAc,CAAC,GAAGH,EAAW,QAAS;AAGvE,WAAO,EAAE,MAFIP,EAAgBO,EAAW,YAAY,GAErC,YAAY,EAAE,MAAMK,IAAa;AAAA,EAAA,GAC/C;AAEH,2BACG,OACE,EAAA,UAAA;AAAA,IAAAJ;AAAA,IAEA,gBAAAK,EAAAC,GAAA,EAAiB,MAAAH,GAAY,YAAAC,GAAwB,UAAAH,GAAoB,SAAAX,GAAkB;AAAA,IAE3FU;AAAA,EAAA,GACH;AAEJ;"}
@@ -1,364 +0,0 @@
1
- import { FormAction } from "./FormAction";
2
-
3
- /**
4
- *
5
- * ```tsx
6
- * import {FormAction} from "@tsed/react-formio/organisms/form/action/FormAction";
7
- * ```
8
- */
9
- export default {
10
- title: "form/action/FormAction",
11
- component: FormAction,
12
- argTypes: {
13
- onSubmit: { action: "onSubmit" },
14
-
15
- type: {
16
- control: "object"
17
- },
18
- form: {
19
- control: "object"
20
- },
21
- options: {
22
- control: "object"
23
- }
24
- },
25
- parameters: {
26
- docs: {
27
- source: {
28
- type: "code"
29
- }
30
- }
31
- }
32
- };
33
-
34
- export const Sandbox = (args: any) => {
35
- return <FormAction {...args} />;
36
- };
37
-
38
- Sandbox.args = {
39
- actionInfo: {
40
- name: "save",
41
- title: "Save Submission",
42
- description: "Saves the submission into the database.",
43
- priority: 10,
44
- defaults: {
45
- handler: ["before"],
46
- method: ["create", "update"],
47
- priority: 10,
48
- name: "save",
49
- title: "Save Submission"
50
- },
51
- access: {
52
- handler: false,
53
- method: false
54
- },
55
- settingsForm: {
56
- components: [
57
- {
58
- type: "hidden",
59
- input: true,
60
- key: "priority"
61
- },
62
- {
63
- type: "hidden",
64
- input: true,
65
- key: "name"
66
- },
67
- {
68
- type: "textfield",
69
- input: true,
70
- label: "Title",
71
- key: "title"
72
- },
73
- {
74
- type: "fieldset",
75
- input: false,
76
- tree: true,
77
- legend: "Action Settings",
78
- components: [
79
- {
80
- input: false,
81
- type: "container",
82
- key: "settings",
83
- components: [
84
- {
85
- type: "resourcefields",
86
- key: "resource",
87
- title: "Save submission to",
88
- placeholder: "This form",
89
- basePath: "/project/5d0797bc872fc7d140559857/form",
90
- form: "62b18b10fbbba513555c6c5e",
91
- required: false
92
- }
93
- ]
94
- }
95
- ]
96
- },
97
- {
98
- type: "fieldset",
99
- input: false,
100
- tree: false,
101
- key: "conditions",
102
- legend: "Action Execution",
103
- components: [
104
- {
105
- type: "select",
106
- input: true,
107
- key: "handler",
108
- label: "Handler",
109
- placeholder: "Select which handler(s) you would like to trigger",
110
- dataSrc: "json",
111
- data: {
112
- json: '[{"name":"before","title":"Before"},{"name":"after","title":"After"}]'
113
- },
114
- template: "<span>{{ item.title }}</span>",
115
- valueProperty: "name",
116
- multiple: true
117
- },
118
- {
119
- type: "select",
120
- input: true,
121
- label: "Methods",
122
- key: "method",
123
- placeholder: "Trigger action on method(s)",
124
- dataSrc: "json",
125
- data: {
126
- json: '[{"name":"create","title":"Create"},{"name":"update","title":"Update"},{"name":"read","title":"Read"},{"name":"delete","title":"Delete"},{"name":"index","title":"Index"}]'
127
- },
128
- template: "<span>{{ item.title }}</span>",
129
- valueProperty: "name",
130
- multiple: true
131
- }
132
- ]
133
- },
134
- {
135
- key: "fieldset",
136
- type: "fieldset",
137
- input: false,
138
- tree: false,
139
- legend: "Action Conditions (optional)",
140
- components: [
141
- {
142
- type: "container",
143
- key: "condition",
144
- input: false,
145
- tree: true,
146
- components: [
147
- {
148
- key: "columns",
149
- type: "columns",
150
- input: false,
151
- columns: [
152
- {
153
- components: [
154
- {
155
- type: "select",
156
- input: true,
157
- label: "Trigger this action only if field",
158
- key: "field",
159
- placeholder: "Select the conditional field",
160
- template: "<span>{{ item.label || item.key }}</span>",
161
- dataSrc: "json",
162
- data: {
163
- json: '[{"key":""},{"label":"Rules","reorder":false,"addAnotherPosition":"bottom","layoutFixed":false,"enableRowGroups":false,"initEmpty":false,"tableView":false,"defaultValue":[{"path":{},"operator":""}],"key":"rules","type":"datagrid","input":true,"components":[{"label":"Path","widget":"choicesjs","tableView":true,"dataSrc":"url","data":{"url":"/test","headers":[{"key":"","value":""}]},"key":"path","type":"select","input":true,"disableLimit":false},{"label":"Operator","widget":"choicesjs","tableView":true,"data":{"values":[{"label":"default","value":"default"},{"label":"Contains","value":"CONTAINS"}]},"key":"operator","type":"select","input":true},{"customClass":"mt-0 mb-0","key":"fieldset","type":"fieldset","label":"Field Set","input":false,"tableView":false,"components":[{"label":"Value","tableView":true,"key":"value1","customConditional":"show = row.operator === \'CONTAINS\'","type":"textfield","input":true}]},{"label":"Hello","tableView":true,"key":"textField","customConditional":"show = row.operator === \'CONTAINS\'","type":"textfield","input":true}]},{"label":"Path","widget":"choicesjs","tableView":true,"dataSrc":"url","data":{"url":"/test","headers":[{"key":"","value":""}]},"key":"path","type":"select","input":true,"disableLimit":false},{"label":"Operator","widget":"choicesjs","tableView":true,"data":{"values":[{"label":"default","value":"default"},{"label":"Contains","value":"CONTAINS"}]},"key":"operator","type":"select","input":true},{"label":"Value","tableView":true,"key":"value1","customConditional":"show = row.operator === \'CONTAINS\'","type":"textfield","input":true},{"label":"Hello","tableView":true,"key":"textField","customConditional":"show = row.operator === \'CONTAINS\'","type":"textfield","input":true},{"type":"button","label":"Submit","key":"submit","disableOnInvalid":true,"input":true,"tableView":false}]'
164
- },
165
- valueProperty: "key",
166
- multiple: false
167
- },
168
- {
169
- type: "select",
170
- input: true,
171
- label: "",
172
- key: "eq",
173
- placeholder: "Select comparison",
174
- template: "<span>{{ item.label }}</span>",
175
- dataSrc: "values",
176
- data: {
177
- values: [
178
- {
179
- value: "",
180
- label: ""
181
- },
182
- {
183
- value: "equals",
184
- label: "Equals"
185
- },
186
- {
187
- value: "notEqual",
188
- label: "Does Not Equal"
189
- }
190
- ],
191
- json: "",
192
- url: "",
193
- resource: ""
194
- },
195
- valueProperty: "value",
196
- multiple: false
197
- },
198
- {
199
- input: true,
200
- type: "textfield",
201
- inputType: "text",
202
- label: "",
203
- key: "value",
204
- placeholder: "Enter value",
205
- multiple: false
206
- }
207
- ]
208
- },
209
- {
210
- components: [
211
- {
212
- key: "well2",
213
- type: "well",
214
- input: false,
215
- components: [
216
- {
217
- key: "html",
218
- type: "htmlelement",
219
- tag: "h4",
220
- input: false,
221
- content:
222
- 'Or you can provide your own custom JavaScript or <a href="http://jsonlogic.com" target="_blank">JSON</a> condition logic here',
223
- className: ""
224
- },
225
- {
226
- label: "",
227
- type: "textarea",
228
- input: true,
229
- key: "custom",
230
- editorComponents: [
231
- {
232
- label: "Rules",
233
- reorder: false,
234
- addAnotherPosition: "bottom",
235
- layoutFixed: false,
236
- enableRowGroups: false,
237
- initEmpty: false,
238
- tableView: false,
239
- defaultValue: [
240
- {
241
- path: {},
242
- operator: ""
243
- }
244
- ],
245
- key: "rules",
246
- type: "datagrid",
247
- input: true,
248
- components: [
249
- {
250
- label: "Path",
251
- widget: "choicesjs",
252
- tableView: true,
253
- dataSrc: "url",
254
- data: {
255
- url: "/test",
256
- headers: [
257
- {
258
- key: "",
259
- value: ""
260
- }
261
- ]
262
- },
263
- key: "path",
264
- type: "select",
265
- input: true,
266
- disableLimit: false
267
- },
268
- {
269
- label: "Operator",
270
- widget: "choicesjs",
271
- tableView: true,
272
- data: {
273
- values: [
274
- {
275
- label: "default",
276
- value: "default"
277
- },
278
- {
279
- label: "Contains",
280
- value: "CONTAINS"
281
- }
282
- ]
283
- },
284
- key: "operator",
285
- type: "select",
286
- input: true
287
- },
288
- {
289
- customClass: "mt-0 mb-0",
290
- key: "fieldset",
291
- type: "fieldset",
292
- label: "Field Set",
293
- input: false,
294
- tableView: false,
295
- components: [
296
- {
297
- label: "Value",
298
- tableView: true,
299
- key: "value1",
300
- customConditional: "show = row.operator === 'CONTAINS'",
301
- type: "textfield",
302
- input: true
303
- }
304
- ]
305
- },
306
- {
307
- label: "Hello",
308
- tableView: true,
309
- key: "textField",
310
- customConditional: "show = row.operator === 'CONTAINS'",
311
- type: "textfield",
312
- input: true
313
- }
314
- ]
315
- },
316
- {
317
- type: "button",
318
- label: "Submit",
319
- key: "submit",
320
- disableOnInvalid: true,
321
- input: true,
322
- tableView: false
323
- }
324
- ],
325
- placeholder:
326
- '// Example: Only execute if submitted roles has \'authenticated\'.\nJavaScript: execute = (data.roles.indexOf(\'authenticated\') !== -1);\nJSON: { "in": [ "authenticated", { "var": "data.roles" } ] }'
327
- }
328
- ]
329
- }
330
- ]
331
- }
332
- ]
333
- }
334
- ]
335
- }
336
- ]
337
- },
338
- {
339
- key: "html2",
340
- type: "htmlelement",
341
- tag: "hr",
342
- input: false,
343
- content: "",
344
- className: ""
345
- },
346
- {
347
- type: "button",
348
- input: true,
349
- label: "Save Action",
350
- key: "submit",
351
- size: "md",
352
- leftIcon: "",
353
- rightIcon: "",
354
- block: false,
355
- action: "submit",
356
- disableOnInvalid: true,
357
- theme: "primary"
358
- }
359
- ],
360
- action: "/project/5d0797bc872fc7d140559857/form/62b18b10fbbba513555c6c5e/action"
361
- }
362
- },
363
- options: { template: "tailwind", iconset: "bx" }
364
- };
package/tsconfig.app.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@tsed/typescript/tsconfig.web.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "noEmit": true,
6
- "declaration": false,
7
- "composite": false
8
- },
9
- "include": ["src/**/*.ts", "src/**/*.tsx"],
10
- "exclude": ["node_modules", "dist", "src/**/*.spec.ts", "src/**/*.spec.tsx"]
11
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "extends": "@tsed/typescript/tsconfig.web.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "composite": true,
6
- "noEmit": true
7
- },
8
- "include": [],
9
- "exclude": [],
10
- "references": [
11
- {
12
- "path": "./tsconfig.app.json"
13
- },
14
- {
15
- "path": "./tsconfig.node.json"
16
- },
17
- {
18
- "path": "./tsconfig.spec.json"
19
- }
20
- ]
21
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@tsed/typescript/tsconfig.web.json",
3
- "compilerOptions": {
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "baseUrl": ".",
7
- "noEmit": true,
8
- "declaration": false,
9
- "composite": false
10
- },
11
- "include": ["vite.config.mts"],
12
- "exclude": ["node_modules", "dist", "src/**/*.spec.ts", "src/**/*.spec.tsx"]
13
- }
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "@tsed/typescript/tsconfig.web.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "rootDir": ".",
6
- "declaration": false,
7
- "composite": false,
8
- "noEmit": true,
9
- "paths": {},
10
- "types": ["vite/client", "vitest/globals", "@testing-library/jest-dom"]
11
- },
12
- "include": ["src/**/*.spec.tsx", "src/**/*.spec.ts", "vitest.config.mts"],
13
- "exclude": ["node_modules", "dist", "coverage"]
14
- }