@tsed/react-formio 3.0.0-rc.2 → 3.0.0-rc.21

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 (114) hide show
  1. package/dist/all.js +2 -0
  2. package/dist/all.js.map +1 -1
  3. package/dist/chunks/_baseGet.js +102 -0
  4. package/dist/chunks/_baseGet.js.map +1 -0
  5. package/dist/chunks/_baseSlice.js +12 -65
  6. package/dist/chunks/_baseSlice.js.map +1 -1
  7. package/dist/chunks/camelCase.js +1 -1
  8. package/dist/chunks/get.js +16 -0
  9. package/dist/chunks/get.js.map +1 -0
  10. package/dist/chunks/index2.js +19746 -22285
  11. package/dist/chunks/index2.js.map +1 -1
  12. package/dist/chunks/moment.js +2535 -0
  13. package/dist/chunks/moment.js.map +1 -0
  14. package/dist/chunks/omit.js +173 -268
  15. package/dist/chunks/omit.js.map +1 -1
  16. package/dist/chunks/toString.js +56 -0
  17. package/dist/chunks/toString.js.map +1 -0
  18. package/dist/interfaces/JSONRecord.d.ts +4 -0
  19. package/dist/interfaces/JSONRecord.js +2 -0
  20. package/dist/interfaces/JSONRecord.js.map +1 -0
  21. package/dist/interfaces/Operation.d.ts +3 -12
  22. package/dist/interfaces/SubmissionType.d.ts +4 -14
  23. package/dist/interfaces/index.d.ts +0 -1
  24. package/dist/molecules/forms/select/Select.interface.d.ts +0 -4
  25. package/dist/molecules/table/Table.d.ts +4 -12
  26. package/dist/molecules/table/Table.js +34 -33
  27. package/dist/molecules/table/Table.js.map +1 -1
  28. package/dist/molecules/table/all.js +2 -0
  29. package/dist/molecules/table/all.js.map +1 -1
  30. package/dist/molecules/table/components/DefaultBooleanCell.d.ts +2 -0
  31. package/dist/molecules/table/components/DefaultBooleanCell.js +12 -0
  32. package/dist/molecules/table/components/DefaultBooleanCell.js.map +1 -0
  33. package/dist/molecules/table/components/DefaultCell.d.ts +2 -5
  34. package/dist/molecules/table/components/DefaultCell.js +8 -6
  35. package/dist/molecules/table/components/DefaultCell.js.map +1 -1
  36. package/dist/molecules/table/components/DefaultCellOperations.d.ts +4 -11
  37. package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
  38. package/dist/molecules/table/components/DefaultDateCell.d.ts +2 -0
  39. package/dist/molecules/table/components/DefaultDateCell.js +16 -0
  40. package/dist/molecules/table/components/DefaultDateCell.js.map +1 -0
  41. package/dist/molecules/table/components/DefaultFilter.d.ts +5 -7
  42. package/dist/molecules/table/components/DefaultFilter.js +8 -8
  43. package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
  44. package/dist/molecules/table/components/DefaultOperationButton.d.ts +4 -11
  45. package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
  46. package/dist/molecules/table/filters/Filters.d.ts +27 -0
  47. package/dist/molecules/table/filters/Filters.js +2 -0
  48. package/dist/molecules/table/filters/Filters.js.map +1 -0
  49. package/dist/molecules/table/filters/SelectFilter.js +22 -20
  50. package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
  51. package/dist/molecules/table/filters/TextFieldFilter.js +16 -16
  52. package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
  53. package/dist/molecules/table/hooks/useTable.d.ts +4 -11
  54. package/dist/molecules/table/hooks/useTable.js +14 -14
  55. package/dist/molecules/table/hooks/useTable.js.map +1 -1
  56. package/dist/molecules/table/hooks/useUniqValues.d.ts +4 -5
  57. package/dist/molecules/table/hooks/useUniqValues.js +23 -7
  58. package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
  59. package/dist/molecules/table/interfaces/extends.d.ts +3 -0
  60. package/dist/molecules/table/utils/mapFormToColumns.d.ts +5 -1
  61. package/dist/molecules/table/utils/mapFormToColumns.js +53 -26
  62. package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
  63. package/dist/organisms/form/Form.d.ts +3 -11
  64. package/dist/organisms/form/Form.js.map +1 -1
  65. package/dist/organisms/form/actions/FormAction.js +5 -5
  66. package/dist/organisms/form/types.d.ts +1 -9
  67. package/dist/organisms/form/useForm.d.ts +4 -11
  68. package/dist/organisms/form/useForm.js.map +1 -1
  69. package/dist/organisms/table/forms/components/FormsCell.js +1 -1
  70. package/dist/organisms/table/submissions/SubmissionsTable.d.ts +4 -11
  71. package/dist/organisms/table/submissions/SubmissionsTable.js +2 -5
  72. package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
  73. package/dist/organisms/views/FormViews.d.ts +4 -11
  74. package/dist/organisms/views/FormViews.js.map +1 -1
  75. package/package.json +3 -3
  76. package/src/all.ts +2 -0
  77. package/src/interfaces/JSONRecord.ts +2 -0
  78. package/src/interfaces/Operation.ts +3 -6
  79. package/src/interfaces/SubmissionType.ts +4 -8
  80. package/src/interfaces/index.ts +0 -1
  81. package/src/molecules/forms/select/Select.interface.ts +0 -4
  82. package/src/molecules/table/Table.stories.tsx +101 -66
  83. package/src/molecules/table/Table.tsx +57 -56
  84. package/src/molecules/table/all.ts +2 -0
  85. package/src/molecules/table/components/DefaultBooleanCell.spec.tsx +42 -0
  86. package/src/molecules/table/components/DefaultBooleanCell.tsx +11 -0
  87. package/src/molecules/table/components/DefaultCell.spec.tsx +32 -0
  88. package/src/molecules/table/components/DefaultCell.tsx +8 -9
  89. package/src/molecules/table/components/DefaultCellOperations.tsx +4 -3
  90. package/src/molecules/table/components/DefaultDateCell.spec.tsx +43 -0
  91. package/src/molecules/table/components/DefaultDateCell.tsx +23 -0
  92. package/src/molecules/table/components/DefaultFilter.tsx +10 -7
  93. package/src/molecules/table/components/DefaultOperationButton.tsx +4 -4
  94. package/src/molecules/table/filters/{Filters.d.ts → Filters.ts} +7 -3
  95. package/src/molecules/table/filters/SelectFilter.tsx +5 -3
  96. package/src/molecules/table/filters/TextFieldFilter.tsx +5 -3
  97. package/src/molecules/table/hooks/useTable.tsx +8 -13
  98. package/src/molecules/table/hooks/useUniqValues.spec.tsx +82 -0
  99. package/src/molecules/table/hooks/useUniqValues.tsx +38 -6
  100. package/src/molecules/table/interfaces/extends.ts +3 -0
  101. package/src/molecules/table/utils/mapFormToColumns.spec.tsx +116 -0
  102. package/src/molecules/table/utils/mapFormToColumns.tsx +67 -27
  103. package/src/organisms/form/Form.stories.tsx +7 -2
  104. package/src/organisms/form/Form.tsx +3 -3
  105. package/src/organisms/form/types.ts +1 -6
  106. package/src/organisms/form/useForm.ts +6 -5
  107. package/src/organisms/table/submissions/SubmissionsTable.tsx +5 -10
  108. package/src/organisms/views/FormViews.tsx +6 -9
  109. package/dist/interfaces/QueryOptions.d.ts +0 -23
  110. package/dist/interfaces/QueryOptions.js +0 -2
  111. package/dist/interfaces/QueryOptions.js.map +0 -1
  112. package/dist/molecules/table/filters/Filters.d.js +0 -2
  113. package/dist/molecules/table/filters/Filters.d.js.map +0 -1
  114. package/src/interfaces/QueryOptions.ts +0 -24
@@ -2,13 +2,14 @@ import { Form } from "@formio/js";
2
2
  import { EventEmitter2 } from "eventemitter2";
3
3
  import { type MutableRefObject, useEffect, useRef, useState } from "react";
4
4
 
5
- import type { ChangedSubmission, ComponentType, FormOptions, FormType, JSON, SubmissionType } from "../../interfaces";
5
+ import type { ChangedSubmission, ComponentType, FormOptions, FormType, SubmissionType } from "../../interfaces";
6
+ import type { JSON, JSONRecord } from "../../interfaces/JSONRecord.js";
6
7
  import { FormCustomEvent } from "./types";
7
8
 
8
9
  type Webform = any;
9
10
  type EventError = string | Error | Error[] | { message: string } | { message: string }[];
10
11
 
11
- export interface UseFormProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> {
12
+ export interface UseFormProps<Data extends object = JSONRecord> {
12
13
  src?: string;
13
14
  url?: string;
14
15
  form?: FormType;
@@ -54,7 +55,7 @@ const getDefaultEmitter = () => {
54
55
  });
55
56
  };
56
57
 
57
- function onAnyEvent<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(
58
+ function onAnyEvent<Data extends object = JSONRecord>(
58
59
  handlers: Omit<UseFormProps<Data>, "src" | "url" | "form" | "submission" | "options" | "formReady" | "formioform" | "Formio">,
59
60
  ...args: [string, ...any[]]
60
61
  ) {
@@ -95,7 +96,7 @@ const createWebformInstance = async (
95
96
  };
96
97
 
97
98
  // Define effective props (aka I want to rename these props but also maintain backwards compatibility)
98
- function getEffectiveProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(props: UseFormProps<Data>) {
99
+ function getEffectiveProps<Data extends object = JSONRecord>(props: UseFormProps<Data>) {
99
100
  const { FormClass = Form, form, src, url, options, submission, onFormReady, onAsyncSubmit, ...handlers } = props;
100
101
 
101
102
  return {
@@ -126,7 +127,7 @@ function createCustomValidation(customAction: any, ref: MutableRefObject<Webform
126
127
  };
127
128
  }
128
129
 
129
- export function useForm<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(props: UseFormProps<Data>) {
130
+ export function useForm<Data extends object = JSONRecord>(props: UseFormProps<Data>) {
130
131
  const webformRef = useRef<Webform | null>(null);
131
132
  const renderElement = useRef<HTMLDivElement | null>(null);
132
133
  const { formSource, FormClass, options, url, submission, handlers, onFormReady, onAsyncSubmit } = getEffectiveProps(props);
@@ -1,19 +1,14 @@
1
- import type { FormType, JSON, SubmissionType } from "../../../interfaces";
1
+ import type { FormType, SubmissionType } from "../../../interfaces";
2
+ import type { JSONRecord } from "../../../interfaces/JSONRecord";
2
3
  import { Table, type TableProps } from "../../../molecules/table/Table";
3
4
  import { mapFormToColumns } from "../../../molecules/table/utils/mapFormToColumns.js";
4
5
 
5
- export type SubmissionsTableProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> = Omit<
6
- TableProps<SubmissionType<Data>>,
7
- "columns"
8
- > & {
6
+ export type SubmissionsTableProps<Data extends object = JSONRecord> = Omit<TableProps<SubmissionType<Data>>, "columns"> & {
9
7
  form?: FormType;
10
8
  };
11
9
 
12
- export function SubmissionsTable<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({
13
- form,
14
- ...props
15
- }: SubmissionsTableProps<Data>) {
16
- const columns: any[] | undefined = form && mapFormToColumns(form);
10
+ export function SubmissionsTable<Data extends object = JSONRecord>({ form, ...props }: SubmissionsTableProps<Data>) {
11
+ const columns: any[] | undefined = form && mapFormToColumns({ form: form });
17
12
 
18
13
  return <Table {...(props as any)} columns={columns!} />;
19
14
  }
@@ -1,5 +1,6 @@
1
1
  import { useI18n } from "../../hooks/useI18n.js";
2
- import type { FormOptions, FormType, JSON, PermissionsResolver } from "../../interfaces/index.js";
2
+ import type { FormOptions, FormType, PermissionsResolver } from "../../interfaces/index.js";
3
+ import type { JSONRecord } from "../../interfaces/JSONRecord.js";
3
4
  import type { Tab as DefaultTab } from "../../molecules/tabs/Tab.js";
4
5
  import type { TabList as DefaultTabList } from "../../molecules/tabs/TabList.js";
5
6
  import type { TabPanel as DefaultTabPanel } from "../../molecules/tabs/TabPanel.js";
@@ -14,7 +15,7 @@ import { FormSettings } from "../form/settings/FormSettings.js";
14
15
  import { ActionsTable, type ActionsTableProps } from "../table/actions/ActionsTable.js";
15
16
  import { SubmissionsTable, type SubmissionsTableProps } from "../table/submissions/SubmissionsTable.js";
16
17
 
17
- export type FormViewsProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> = {
18
+ export type FormViewsProps<Data extends object = JSONRecord> = {
18
19
  form: FormEditProps["form"];
19
20
  submissions: SubmissionsTableProps<Data>["data"];
20
21
  availableActions: ActionsTableProps["availableActions"];
@@ -25,9 +26,7 @@ export type FormViewsProps<Data extends { [key: string]: JSON } = { [key: string
25
26
  permissionsResolver?: PermissionsResolver<Data>;
26
27
  };
27
28
 
28
- function useSubmissionsOperations<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(
29
- permissionsResolver?: PermissionsResolver<Data>
30
- ) {
29
+ function useSubmissionsOperations<Data extends object = JSONRecord>(permissionsResolver?: PermissionsResolver<Data>) {
31
30
  return [
32
31
  {
33
32
  title: "Edit",
@@ -45,9 +44,7 @@ function useSubmissionsOperations<Data extends { [key: string]: JSON } = { [key:
45
44
  ] as SubmissionsTableProps<Data>["operations"];
46
45
  }
47
46
 
48
- function useActionsOperations<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(
49
- permissionsResolver?: PermissionsResolver<Data>
50
- ) {
47
+ function useActionsOperations<Data extends object = JSONRecord>(permissionsResolver?: PermissionsResolver<Data>) {
51
48
  return [
52
49
  {
53
50
  title: "Edit",
@@ -65,7 +62,7 @@ function useActionsOperations<Data extends { [key: string]: JSON } = { [key: str
65
62
  ] as SubmissionsTableProps<Data>["operations"];
66
63
  }
67
64
 
68
- export function FormViews<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({
65
+ export function FormViews<Data extends object = JSONRecord>({
69
66
  form,
70
67
  roles,
71
68
  availableActions,
@@ -1,23 +0,0 @@
1
- import { ColumnIdentifier } from './ColumnIdentifier';
2
- export type QueryOptions = {
3
- /**
4
- * Current displayed page
5
- */
6
- pageIndex: any;
7
- /**
8
- * Pagination size
9
- */
10
- pageSize: any;
11
- /**
12
- * SortBy state
13
- */
14
- sortBy: ColumnIdentifier[];
15
- /**
16
- * Filters state
17
- */
18
- filters: ColumnIdentifier[];
19
- /**
20
- * Focused input filter (let the Table component retrieve focus state when we fill the filter)
21
- */
22
- filterId: string;
23
- };
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=QueryOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryOptions.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=Filters.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Filters.d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { ColumnIdentifier } from "./ColumnIdentifier";
2
-
3
- export type QueryOptions = {
4
- /**
5
- * Current displayed page
6
- */
7
- pageIndex: any;
8
- /**
9
- * Pagination size
10
- */
11
- pageSize: any;
12
- /**
13
- * SortBy state
14
- */
15
- sortBy: ColumnIdentifier[];
16
- /**
17
- * Filters state
18
- */
19
- filters: ColumnIdentifier[];
20
- /**
21
- * Focused input filter (let the Table component retrieve focus state when we fill the filter)
22
- */
23
- filterId: string;
24
- };