@tsed/react-formio 3.0.0-rc.2 → 3.0.0-rc.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.
Files changed (109) 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/SelectFilter.js +22 -20
  47. package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
  48. package/dist/molecules/table/filters/TextFieldFilter.js +16 -16
  49. package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
  50. package/dist/molecules/table/hooks/useTable.d.ts +4 -11
  51. package/dist/molecules/table/hooks/useTable.js +14 -14
  52. package/dist/molecules/table/hooks/useTable.js.map +1 -1
  53. package/dist/molecules/table/hooks/useUniqValues.d.ts +8 -5
  54. package/dist/molecules/table/hooks/useUniqValues.js +23 -7
  55. package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
  56. package/dist/molecules/table/interfaces/extends.d.ts +3 -0
  57. package/dist/molecules/table/utils/mapFormToColumns.d.ts +5 -1
  58. package/dist/molecules/table/utils/mapFormToColumns.js +53 -26
  59. package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
  60. package/dist/organisms/form/Form.d.ts +3 -11
  61. package/dist/organisms/form/Form.js.map +1 -1
  62. package/dist/organisms/form/actions/FormAction.js +5 -5
  63. package/dist/organisms/form/types.d.ts +1 -9
  64. package/dist/organisms/form/useForm.d.ts +4 -11
  65. package/dist/organisms/form/useForm.js.map +1 -1
  66. package/dist/organisms/table/forms/components/FormsCell.js +1 -1
  67. package/dist/organisms/table/submissions/SubmissionsTable.d.ts +4 -11
  68. package/dist/organisms/table/submissions/SubmissionsTable.js +2 -5
  69. package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
  70. package/dist/organisms/views/FormViews.d.ts +4 -11
  71. package/dist/organisms/views/FormViews.js.map +1 -1
  72. package/package.json +3 -3
  73. package/src/all.ts +2 -0
  74. package/src/interfaces/JSONRecord.ts +2 -0
  75. package/src/interfaces/Operation.ts +3 -6
  76. package/src/interfaces/SubmissionType.ts +4 -8
  77. package/src/interfaces/index.ts +0 -1
  78. package/src/molecules/forms/select/Select.interface.ts +0 -4
  79. package/src/molecules/table/Table.stories.tsx +101 -66
  80. package/src/molecules/table/Table.tsx +57 -56
  81. package/src/molecules/table/all.ts +2 -0
  82. package/src/molecules/table/components/DefaultBooleanCell.spec.tsx +42 -0
  83. package/src/molecules/table/components/DefaultBooleanCell.tsx +11 -0
  84. package/src/molecules/table/components/DefaultCell.spec.tsx +32 -0
  85. package/src/molecules/table/components/DefaultCell.tsx +8 -9
  86. package/src/molecules/table/components/DefaultCellOperations.tsx +4 -3
  87. package/src/molecules/table/components/DefaultDateCell.spec.tsx +43 -0
  88. package/src/molecules/table/components/DefaultDateCell.tsx +23 -0
  89. package/src/molecules/table/components/DefaultFilter.tsx +10 -7
  90. package/src/molecules/table/components/DefaultOperationButton.tsx +4 -4
  91. package/src/molecules/table/filters/Filters.d.ts +3 -1
  92. package/src/molecules/table/filters/SelectFilter.tsx +5 -3
  93. package/src/molecules/table/filters/TextFieldFilter.tsx +5 -3
  94. package/src/molecules/table/hooks/useTable.tsx +8 -13
  95. package/src/molecules/table/hooks/useUniqValues.spec.tsx +82 -0
  96. package/src/molecules/table/hooks/useUniqValues.tsx +42 -6
  97. package/src/molecules/table/interfaces/extends.ts +3 -0
  98. package/src/molecules/table/utils/mapFormToColumns.spec.tsx +116 -0
  99. package/src/molecules/table/utils/mapFormToColumns.tsx +66 -26
  100. package/src/organisms/form/Form.stories.tsx +7 -2
  101. package/src/organisms/form/Form.tsx +3 -3
  102. package/src/organisms/form/types.ts +1 -6
  103. package/src/organisms/form/useForm.ts +6 -5
  104. package/src/organisms/table/submissions/SubmissionsTable.tsx +5 -10
  105. package/src/organisms/views/FormViews.tsx +6 -9
  106. package/dist/interfaces/QueryOptions.d.ts +0 -23
  107. package/dist/interfaces/QueryOptions.js +0 -2
  108. package/dist/interfaces/QueryOptions.js.map +0 -1
  109. package/src/interfaces/QueryOptions.ts +0 -24
@@ -1,33 +1,35 @@
1
- import { jsx as o, Fragment as u } from "react/jsx-runtime";
2
- import { registerComponent as a, getComponent as p } from "../../../registries/components.js";
3
- import { useUniqValues as f } from "../hooks/useUniqValues.js";
4
- function F({ header: t, options: e }) {
5
- const n = p("Select"), i = t.column.getFilterValue(), c = f({ header: t, filterVariant: "text" }), r = e.layout === "choicesjs" ? {
1
+ import { jsx as t, Fragment as a } from "react/jsx-runtime";
2
+ import { registerComponent as o, getComponent as f } from "../../../registries/components.js";
3
+ import { useUniqValues as p } from "../hooks/useUniqValues.js";
4
+ function n({ header: e, options: l }) {
5
+ const c = f("Select"), i = e.column.getFilterValue(), u = p({ header: e, options: l }), m = l.layout === "choicesjs" ? {
6
6
  placeholder: void 0
7
7
  } : {
8
- placeholder: `Filter by ${t.column.columnDef.header}`
9
- }, m = [
8
+ placeholder: `Filter by ${e.column.columnDef.header}`
9
+ }, r = [
10
10
  {
11
- label: `Filter by ${t.column.columnDef.header}`,
11
+ label: `Filter by ${e.column.columnDef.header}`,
12
12
  value: ""
13
13
  }
14
- ].concat(e.options || c.map((l) => ({ label: l, value: l })));
15
- return /* @__PURE__ */ o(u, { children: /* @__PURE__ */ o(
16
- n,
14
+ ].concat(u);
15
+ return /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(
16
+ c,
17
17
  {
18
18
  size: "small",
19
- ...e,
20
- ...r,
21
- options: m,
22
- name: `filter_${t.column.id}`,
23
- "data-testid": `filter_${t.column.id}`,
24
- value: i,
25
- onChange: (l, s) => t.column.setFilterValue(s)
19
+ ...l,
20
+ ...m,
21
+ autoComplete: "off",
22
+ options: r,
23
+ name: `filter_${e.column.id}`,
24
+ "data-testid": `filter_${e.column.id}`,
25
+ value: i ?? "",
26
+ onChange: (F, s) => e.column.setFilterValue(s)
26
27
  }
27
28
  ) });
28
29
  }
29
- a("Filter.select", F);
30
+ o("Filter.select", n);
31
+ o("Filter.boolean", n);
30
32
  export {
31
- F as SelectFilter
33
+ n as SelectFilter
32
34
  };
33
35
  //# sourceMappingURL=SelectFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectFilter.js","sources":["../../../../src/molecules/table/filters/SelectFilter.tsx"],"sourcesContent":["import { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { Select as DefaultSelect } from \"../../forms/select/Select\";\nimport { SelectOptionProps } from \"../../forms/select/Select.interface\";\nimport type { FilterProps } from \"../components/DefaultFilter\";\nimport { useUniqValues } from \"../hooks/useUniqValues\";\nimport { FilterSelectOptions } from \"./Filters\";\n\nexport function SelectFilter<Data = any>({ header, options }: FilterProps<Data, FilterSelectOptions>) {\n const Select = getComponent<typeof DefaultSelect>(\"Select\");\n const columnFilterValue = header.column.getFilterValue();\n const uniqValues = useUniqValues<Data>({ header, filterVariant: \"text\" });\n\n const opts =\n options.layout === \"choicesjs\"\n ? {\n placeholder: undefined\n }\n : {\n placeholder: `Filter by ${header.column.columnDef.header}`\n };\n\n const listOptions = (\n [\n {\n label: `Filter by ${header.column.columnDef.header}`,\n value: \"\"\n }\n ] as SelectOptionProps[]\n ).concat(options.options || uniqValues.map((value: any) => ({ label: value, value })));\n\n return (\n <>\n <Select<string>\n size='small'\n {...(options as any)}\n {...opts}\n options={listOptions}\n name={`filter_${header.column.id}`}\n data-testid={`filter_${header.column.id}`}\n value={columnFilterValue as string}\n onChange={(_, value) => header.column.setFilterValue(value)}\n />\n </>\n );\n}\n\nregisterComponent(\"Filter.select\", SelectFilter);\n"],"names":["SelectFilter","header","options","Select","getComponent","columnFilterValue","uniqValues","useUniqValues","opts","listOptions","value","jsx","Fragment","_","registerComponent"],"mappings":";;;AAOO,SAASA,EAAyB,EAAE,QAAAC,GAAQ,SAAAC,KAAmD;AACpG,QAAMC,IAASC,EAAmC,QAAQ,GACpDC,IAAoBJ,EAAO,OAAO,eAAA,GAClCK,IAAaC,EAAoB,EAAE,QAAAN,GAAQ,eAAe,QAAQ,GAElEO,IACJN,EAAQ,WAAW,cACf;AAAA,IACE,aAAa;AAAA,EAAA,IAEf;AAAA,IACE,aAAa,aAAaD,EAAO,OAAO,UAAU,MAAM;AAAA,EAAA,GAG1DQ,IACJ;AAAA,IACE;AAAA,MACE,OAAO,aAAaR,EAAO,OAAO,UAAU,MAAM;AAAA,MAClD,OAAO;AAAA,IAAA;AAAA,EACT,EAEF,OAAOC,EAAQ,WAAWI,EAAW,IAAI,CAACI,OAAgB,EAAE,OAAOA,GAAO,OAAAA,EAAA,EAAQ,CAAC;AAErF,SACE,gBAAAC,EAAAC,GAAA,EACE,UAAA,gBAAAD;AAAA,IAACR;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACJ,GAAID;AAAA,MACJ,GAAGM;AAAA,MACJ,SAASC;AAAA,MACT,MAAM,UAAUR,EAAO,OAAO,EAAE;AAAA,MAChC,eAAa,UAAUA,EAAO,OAAO,EAAE;AAAA,MACvC,OAAOI;AAAA,MACP,UAAU,CAACQ,GAAGH,MAAUT,EAAO,OAAO,eAAeS,CAAK;AAAA,IAAA;AAAA,EAAA,GAE9D;AAEJ;AAEAI,EAAkB,iBAAiBd,CAAY;"}
1
+ {"version":3,"file":"SelectFilter.js","sources":["../../../../src/molecules/table/filters/SelectFilter.tsx"],"sourcesContent":["import { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { Select as DefaultSelect } from \"../../forms/select/Select\";\nimport { SelectOptionProps } from \"../../forms/select/Select.interface\";\nimport type { FilterProps } from \"../components/DefaultFilter\";\nimport { useUniqValues } from \"../hooks/useUniqValues\";\nimport { FilterSelectOptions } from \"./Filters\";\n\nexport function SelectFilter<Data = any>({ header, options }: FilterProps<Data, FilterSelectOptions>) {\n const Select = getComponent<typeof DefaultSelect>(\"Select\");\n const columnFilterValue = header.column.getFilterValue();\n const uniqValues = useUniqValues<Data>({ header, options });\n\n const opts =\n options.layout === \"choicesjs\"\n ? {\n placeholder: undefined\n }\n : {\n placeholder: `Filter by ${header.column.columnDef.header}`\n };\n\n const listOptions = (\n [\n {\n label: `Filter by ${header.column.columnDef.header}`,\n value: \"\"\n }\n ] as SelectOptionProps[]\n ).concat(uniqValues);\n\n return (\n <>\n <Select<string>\n size='small'\n {...(options as any)}\n {...opts}\n autoComplete='off'\n options={listOptions}\n name={`filter_${header.column.id}`}\n data-testid={`filter_${header.column.id}`}\n value={(columnFilterValue ?? \"\") as string}\n onChange={(_, value) => header.column.setFilterValue(value)}\n />\n </>\n );\n}\n\nregisterComponent(\"Filter.select\", SelectFilter);\nregisterComponent(\"Filter.boolean\", SelectFilter);\n"],"names":["SelectFilter","header","options","Select","getComponent","columnFilterValue","uniqValues","useUniqValues","opts","listOptions","jsx","Fragment","_","value","registerComponent"],"mappings":";;;AAOO,SAASA,EAAyB,EAAE,QAAAC,GAAQ,SAAAC,KAAmD;AACpG,QAAMC,IAASC,EAAmC,QAAQ,GACpDC,IAAoBJ,EAAO,OAAO,eAAA,GAClCK,IAAaC,EAAoB,EAAE,QAAAN,GAAQ,SAAAC,GAAS,GAEpDM,IACJN,EAAQ,WAAW,cACf;AAAA,IACE,aAAa;AAAA,EAAA,IAEf;AAAA,IACE,aAAa,aAAaD,EAAO,OAAO,UAAU,MAAM;AAAA,EAAA,GAG1DQ,IACJ;AAAA,IACE;AAAA,MACE,OAAO,aAAaR,EAAO,OAAO,UAAU,MAAM;AAAA,MAClD,OAAO;AAAA,IAAA;AAAA,EACT,EAEF,OAAOK,CAAU;AAEnB,SACE,gBAAAI,EAAAC,GAAA,EACE,UAAA,gBAAAD;AAAA,IAACP;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACJ,GAAID;AAAA,MACJ,GAAGM;AAAA,MACJ,cAAa;AAAA,MACb,SAASC;AAAA,MACT,MAAM,UAAUR,EAAO,OAAO,EAAE;AAAA,MAChC,eAAa,UAAUA,EAAO,OAAO,EAAE;AAAA,MACvC,OAAQI,KAAqB;AAAA,MAC7B,UAAU,CAACO,GAAGC,MAAUZ,EAAO,OAAO,eAAeY,CAAK;AAAA,IAAA;AAAA,EAAA,GAE9D;AAEJ;AAEAC,EAAkB,iBAAiBd,CAAY;AAC/Cc,EAAkB,kBAAkBd,CAAY;"}
@@ -1,27 +1,27 @@
1
- import { jsxs as a, Fragment as u, jsx as i } from "react/jsx-runtime";
2
- import { registerComponent as c, getComponent as d } from "../../../registries/components.js";
1
+ import { jsxs as r, Fragment as c, jsx as e } from "react/jsx-runtime";
2
+ import { registerComponent as m, getComponent as d } from "../../../registries/components.js";
3
3
  import { useUniqValues as p } from "../hooks/useUniqValues.js";
4
- function f({ header: t, options: e }) {
5
- const o = d("InputText"), m = t.column.getFilterValue(), r = p({ header: t, filterVariant: "text" }), n = `data_list_${t.column.id}`;
6
- return /* @__PURE__ */ a(u, { children: [
7
- !e.disableDatalist && /* @__PURE__ */ i("datalist", { id: n, children: r.map((l) => /* @__PURE__ */ i("option", { value: l }, l)) }),
8
- /* @__PURE__ */ i(
4
+ function F({ header: l, options: n }) {
5
+ const o = d("InputText"), u = l.column.getFilterValue(), a = p({ header: l }), i = `data_list_${l.column.id}`;
6
+ return /* @__PURE__ */ r(c, { children: [
7
+ !n.disableDatalist && /* @__PURE__ */ e("datalist", { id: i, children: a.map((t) => /* @__PURE__ */ e("option", { value: t.value, children: t.label || t.value }, t.value)) }),
8
+ /* @__PURE__ */ e(
9
9
  o,
10
10
  {
11
11
  size: "small",
12
- placeholder: `Filter by ${t.column.columnDef.header}`,
13
- ...e,
14
- name: `filter_${t.column.id}`,
15
- "data-testid": `filter_${t.column.id}`,
16
- value: m ?? "",
17
- list: n,
18
- onChange: (l, s) => t.column.setFilterValue(s)
12
+ placeholder: `Filter by ${l.column.columnDef.header}`,
13
+ ...n,
14
+ name: `filter_${l.column.id}`,
15
+ "data-testid": `filter_${l.column.id}`,
16
+ value: u ?? "",
17
+ list: i,
18
+ onChange: (t, s) => l.column.setFilterValue(s)
19
19
  }
20
20
  )
21
21
  ] });
22
22
  }
23
- c("Filter.text", f);
23
+ m("Filter.text", F);
24
24
  export {
25
- f as TextFieldFilter
25
+ F as TextFieldFilter
26
26
  };
27
27
  //# sourceMappingURL=TextFieldFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextFieldFilter.js","sources":["../../../../src/molecules/table/filters/TextFieldFilter.tsx"],"sourcesContent":["import { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { InputText as DefaultInputText } from \"../../forms/input-text/InputText\";\nimport type { FilterProps } from \"../components/DefaultFilter\";\nimport { useUniqValues } from \"../hooks/useUniqValues\";\nimport { FilterTextOptions } from \"./Filters\";\n\nexport function TextFieldFilter<Data = any>({ header, options }: FilterProps<Data, FilterTextOptions>) {\n const InputText = getComponent<typeof DefaultInputText>(\"InputText\");\n const columnFilterValue = header.column.getFilterValue();\n const uniqValues = useUniqValues<Data>({ header, filterVariant: \"text\" });\n const datalistId = `data_list_${header.column.id}`;\n\n return (\n <>\n {!options.disableDatalist && (\n <datalist id={datalistId}>\n {uniqValues.map((value: any) => (\n <option value={value} key={value} />\n ))}\n </datalist>\n )}\n <InputText<string>\n size='small'\n placeholder={`Filter by ${header.column.columnDef.header}`}\n {...options}\n name={`filter_${header.column.id}`}\n data-testid={`filter_${header.column.id}`}\n value={(columnFilterValue ?? \"\") as string}\n list={datalistId}\n onChange={(_, value) => header.column.setFilterValue(value)}\n />\n </>\n );\n}\n\nregisterComponent(\"Filter.text\", TextFieldFilter);\n"],"names":["TextFieldFilter","header","options","InputText","getComponent","columnFilterValue","uniqValues","useUniqValues","datalistId","jsxs","Fragment","jsx","value","_","registerComponent"],"mappings":";;;AAMO,SAASA,EAA4B,EAAE,QAAAC,GAAQ,SAAAC,KAAiD;AACrG,QAAMC,IAAYC,EAAsC,WAAW,GAC7DC,IAAoBJ,EAAO,OAAO,eAAA,GAClCK,IAAaC,EAAoB,EAAE,QAAAN,GAAQ,eAAe,QAAQ,GAClEO,IAAa,aAAaP,EAAO,OAAO,EAAE;AAEhD,SACE,gBAAAQ,EAAAC,GAAA,EACG,UAAA;AAAA,IAAA,CAACR,EAAQ,mBACR,gBAAAS,EAAC,YAAA,EAAS,IAAIH,GACX,UAAAF,EAAW,IAAI,CAACM,MACf,gBAAAD,EAAC,UAAA,EAAO,OAAAC,KAAmBA,CAAO,CACnC,GACH;AAAA,IAEF,gBAAAD;AAAA,MAACR;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,aAAa,aAAaF,EAAO,OAAO,UAAU,MAAM;AAAA,QACvD,GAAGC;AAAA,QACJ,MAAM,UAAUD,EAAO,OAAO,EAAE;AAAA,QAChC,eAAa,UAAUA,EAAO,OAAO,EAAE;AAAA,QACvC,OAAQI,KAAqB;AAAA,QAC7B,MAAMG;AAAA,QACN,UAAU,CAACK,GAAGD,MAAUX,EAAO,OAAO,eAAeW,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAC5D,GACF;AAEJ;AAEAE,EAAkB,eAAed,CAAe;"}
1
+ {"version":3,"file":"TextFieldFilter.js","sources":["../../../../src/molecules/table/filters/TextFieldFilter.tsx"],"sourcesContent":["import { getComponent, registerComponent } from \"../../../registries/components\";\nimport type { InputText as DefaultInputText } from \"../../forms/input-text/InputText\";\nimport type { FilterProps } from \"../components/DefaultFilter\";\nimport { useUniqValues } from \"../hooks/useUniqValues\";\nimport { FilterTextOptions } from \"./Filters\";\n\nexport function TextFieldFilter<Data = any>({ header, options }: FilterProps<Data, FilterTextOptions>) {\n const InputText = getComponent<typeof DefaultInputText>(\"InputText\");\n const columnFilterValue = header.column.getFilterValue();\n const uniqValues = useUniqValues<Data>({ header });\n const datalistId = `data_list_${header.column.id}`;\n\n return (\n <>\n {!options.disableDatalist && (\n <datalist id={datalistId}>\n {uniqValues.map((item) => (\n <option value={item.value} key={item.value}>\n {item.label || item.value}\n </option>\n ))}\n </datalist>\n )}\n <InputText<string>\n size='small'\n placeholder={`Filter by ${header.column.columnDef.header}`}\n {...options}\n name={`filter_${header.column.id}`}\n data-testid={`filter_${header.column.id}`}\n value={(columnFilterValue ?? \"\") as string}\n list={datalistId}\n onChange={(_, value) => header.column.setFilterValue(value)}\n />\n </>\n );\n}\n\nregisterComponent(\"Filter.text\", TextFieldFilter);\n"],"names":["TextFieldFilter","header","options","InputText","getComponent","columnFilterValue","uniqValues","useUniqValues","datalistId","jsxs","Fragment","jsx","item","_","value","registerComponent"],"mappings":";;;AAMO,SAASA,EAA4B,EAAE,QAAAC,GAAQ,SAAAC,KAAiD;AACrG,QAAMC,IAAYC,EAAsC,WAAW,GAC7DC,IAAoBJ,EAAO,OAAO,eAAA,GAClCK,IAAaC,EAAoB,EAAE,QAAAN,GAAQ,GAC3CO,IAAa,aAAaP,EAAO,OAAO,EAAE;AAEhD,SACE,gBAAAQ,EAAAC,GAAA,EACG,UAAA;AAAA,IAAA,CAACR,EAAQ,mBACR,gBAAAS,EAAC,YAAA,EAAS,IAAIH,GACX,UAAAF,EAAW,IAAI,CAACM,MACf,gBAAAD,EAAC,YAAO,OAAOC,EAAK,OACjB,UAAAA,EAAK,SAASA,EAAK,MAAA,GADUA,EAAK,KAErC,CACD,EAAA,CACH;AAAA,IAEF,gBAAAD;AAAA,MAACR;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,aAAa,aAAaF,EAAO,OAAO,UAAU,MAAM;AAAA,QACvD,GAAGC;AAAA,QACJ,MAAM,UAAUD,EAAO,OAAO,EAAE;AAAA,QAChC,eAAa,UAAUA,EAAO,OAAO,EAAE;AAAA,QACvC,OAAQI,KAAqB;AAAA,QAC7B,MAAMG;AAAA,QACN,UAAU,CAACK,GAAGC,MAAUb,EAAO,OAAO,eAAea,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAC5D,GACF;AAEJ;AAEAC,EAAkB,eAAef,CAAe;"}
@@ -1,10 +1,7 @@
1
1
  import { TableOptions, TableState } from '@tanstack/react-table';
2
- import { FormOptions, JSON, Operation } from '../../../interfaces';
3
- export interface UseTableProps<Data extends {
4
- [key: string]: JSON;
5
- } = {
6
- [key: string]: JSON;
7
- }> extends Omit<TableOptions<Data>, "getCoreRowModel" | "onClick"> {
2
+ import { FormOptions, Operation } from '../../../interfaces';
3
+ import { JSONRecord } from '../../../interfaces/JSONRecord.js';
4
+ export interface UseTableProps<Data extends object = JSONRecord> extends Omit<TableOptions<Data>, "onClick" | "getCoreRowModel"> {
8
5
  operations: Operation<Data>[];
9
6
  metadata?: Record<string, unknown>;
10
7
  i18n?: FormOptions["i18n"];
@@ -13,11 +10,7 @@ export interface UseTableProps<Data extends {
13
10
  onChange?: (query: TableState) => void;
14
11
  pageSizes?: number[];
15
12
  }
16
- export declare function useTable<Data extends {
17
- [key: string]: JSON;
18
- } = {
19
- [key: string]: JSON;
20
- }>(props: UseTableProps<Data>): {
13
+ export declare function useTable<Data extends object = JSONRecord>(props: UseTableProps<Data>): {
21
14
  i18n: (key: string, defaultValue?: string) => string;
22
15
  tableInstance: import('@tanstack/table-core').Table<Data>;
23
16
  };
@@ -1,35 +1,35 @@
1
- import { jsx as R } from "react/jsx-runtime";
2
- import { useReactTable as f, getFacetedUniqueValues as w, getFacetedRowModel as M, getSortedRowModel as C, getFilteredRowModel as S, getPaginationRowModel as b, getCoreRowModel as h } from "@tanstack/react-table";
1
+ import { jsx as w } from "react/jsx-runtime";
2
+ import { useReactTable as M, getFacetedUniqueValues as s, getFacetedRowModel as f, getSortedRowModel as C, getFilteredRowModel as S, getPaginationRowModel as b, getCoreRowModel as h } from "@tanstack/react-table";
3
3
  import { useEffect as v } from "react";
4
4
  import { useI18n as O } from "../../../hooks/useI18n.js";
5
- import { getComponent as I } from "../../../registries/components.js";
6
- function z(e) {
7
- const n = I("CellOperations"), { t } = O(e.i18n), i = e.operations.length ? [
5
+ import { getComponent as V } from "../../../registries/components.js";
6
+ function x(e) {
7
+ const n = V("CellOperations"), { t } = O(e.i18n), i = e.operations.length ? [
8
8
  {
9
9
  id: "operations",
10
10
  header: t("Operations"),
11
- cell: (F) => /* @__PURE__ */ R(n, { info: F, operations: e.operations, metadata: e.metadata, onClick: e.onClick, i18n: t })
11
+ cell: (R) => /* @__PURE__ */ w(n, { info: R, operations: e.operations, metadata: e.metadata, onClick: e.onClick, i18n: t })
12
12
  }
13
- ] : [], o = f({
13
+ ] : [], o = M({
14
14
  ...e,
15
15
  columns: [...e.columns, ...i],
16
16
  getCoreRowModel: h(),
17
17
  getPaginationRowModel: b(),
18
- getFilteredRowModel: e.manualFiltering ? void 0 : S(),
19
- getSortedRowModel: e.manualSorting ? void 0 : C(),
20
- getFacetedRowModel: e.manualFaceted ? void 0 : M(),
18
+ getFilteredRowModel: e.manualFiltering ? void 0 : e.getFilteredRowModel || S(),
19
+ getSortedRowModel: e.manualSorting ? void 0 : e.getSortedRowModel || C(),
20
+ getFacetedRowModel: e.manualFaceted ? void 0 : e.getFacetedRowModel || f(),
21
21
  // client-side faceting
22
- getFacetedUniqueValues: e.manualFaceted ? void 0 : w()
22
+ getFacetedUniqueValues: e.manualFaceted ? void 0 : e.getFacetedUniqueValues || s()
23
23
  // generate unique values for select filter/autocomplete
24
- }), { columnFilters: a, sorting: l, pagination: d, columnOrder: g, columnPinning: c, columnSizing: m, columnSizingInfo: r, columnVisibility: u, globalFilter: s } = o.getState();
24
+ }), { columnFilters: a, sorting: l, pagination: d, columnOrder: g, columnPinning: c, columnSizing: m, columnSizingInfo: u, columnVisibility: r, globalFilter: F } = o.getState();
25
25
  return v(() => {
26
26
  e.onChange && e.onChange(o.getState());
27
- }, [a, l, d, g, c, m, r, u, s]), {
27
+ }, [a, l, d, g, c, m, u, r, F]), {
28
28
  i18n: t,
29
29
  tableInstance: o
30
30
  };
31
31
  }
32
32
  export {
33
- z as useTable
33
+ x as useTable
34
34
  };
35
35
  //# sourceMappingURL=useTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../../../src/molecules/table/hooks/useTable.tsx"],"sourcesContent":["import {\n type ColumnDef,\n getCoreRowModel,\n getFacetedRowModel,\n getFacetedUniqueValues,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n type TableOptions,\n type TableState,\n useReactTable\n} from \"@tanstack/react-table\";\nimport { useEffect } from \"react\";\n\nimport { useI18n } from \"../../../hooks/useI18n.js\";\nimport { type FormOptions, type JSON, Operation } from \"../../../interfaces\";\nimport { getComponent } from \"../../../registries/components\";\nimport type { DefaultCellOperations } from \"../components/DefaultCellOperations\";\n\nexport interface UseTableProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }>\n extends Omit<TableOptions<Data>, \"getCoreRowModel\" | \"onClick\"> {\n operations: Operation<Data>[];\n metadata?: Record<string, unknown>;\n i18n?: FormOptions[\"i18n\"];\n onClick?: (data: Data, operation: Operation<Data>) => void;\n manualFaceted?: boolean;\n onChange?: (query: TableState) => void;\n pageSizes?: number[];\n}\n\nexport function useTable<Data extends { [key: string]: JSON } = { [key: string]: JSON }>(props: UseTableProps<Data>) {\n const Operations = getComponent<typeof DefaultCellOperations<Data>>(\"CellOperations\");\n const { t } = useI18n(props.i18n);\n\n // const [pagination, setPagination] = useState({\n // pageIndex: 0, //initial page index\n // pageSize: 10 //default page size\n // });\n\n const operations = props.operations.length\n ? ([\n {\n id: \"operations\",\n header: t(\"Operations\"),\n cell: (info) => (\n <Operations info={info} operations={props.operations} metadata={props.metadata} onClick={props.onClick} i18n={t} />\n )\n }\n ] satisfies ColumnDef<Data>[])\n : [];\n\n const tableInstance = useReactTable({\n ...props,\n columns: [...props.columns, ...operations],\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getFilteredRowModel: !props.manualFiltering ? getFilteredRowModel() : undefined,\n getSortedRowModel: !props.manualSorting ? getSortedRowModel() : undefined,\n getFacetedRowModel: !props.manualFaceted ? getFacetedRowModel() : undefined, // client-side faceting\n getFacetedUniqueValues: !props.manualFaceted ? getFacetedUniqueValues() : undefined // generate unique values for select filter/autocomplete\n });\n\n const { columnFilters, sorting, pagination, columnOrder, columnPinning, columnSizing, columnSizingInfo, columnVisibility, globalFilter } =\n tableInstance.getState();\n\n useEffect(() => {\n if (props.onChange) {\n props.onChange(tableInstance.getState());\n }\n }, [columnFilters, sorting, pagination, columnOrder, columnPinning, columnSizing, columnSizingInfo, columnVisibility, globalFilter]);\n\n return {\n i18n: t,\n tableInstance\n };\n}\n"],"names":["useTable","props","Operations","getComponent","useI18n","operations","info","jsx","tableInstance","useReactTable","getCoreRowModel","getPaginationRowModel","getFilteredRowModel","getSortedRowModel","getFacetedRowModel","getFacetedUniqueValues","columnFilters","sorting","pagination","columnOrder","columnPinning","columnSizing","columnSizingInfo","columnVisibility","globalFilter","useEffect"],"mappings":";;;;;AA8BO,SAASA,EAAyEC,GAA4B;AACnH,QAAMC,IAAaC,EAAiD,gBAAgB,GAC9E,EAAE,EAAA,IAAMC,EAAQH,EAAM,IAAI,GAO1BI,IAAaJ,EAAM,WAAW,SAC/B;AAAA,IACC;AAAA,MACE,IAAI;AAAA,MACJ,QAAQ,EAAE,YAAY;AAAA,MACtB,MAAM,CAACK,MACL,gBAAAC,EAACL,GAAA,EAAW,MAAAI,GAAY,YAAYL,EAAM,YAAY,UAAUA,EAAM,UAAU,SAASA,EAAM,SAAS,MAAM,EAAA,CAAG;AAAA,IAAA;AAAA,EAErH,IAEF,CAAA,GAEEO,IAAgBC,EAAc;AAAA,IAClC,GAAGR;AAAA,IACH,SAAS,CAAC,GAAGA,EAAM,SAAS,GAAGI,CAAU;AAAA,IACzC,iBAAiBK,EAAA;AAAA,IACjB,uBAAuBC,EAAA;AAAA,IACvB,qBAAsBV,EAAM,kBAA0C,SAAxBW;IAC9C,mBAAoBX,EAAM,gBAAsC,SAAtBY;IAC1C,oBAAqBZ,EAAM,gBAAuC,SAAvBa;;IAC3C,wBAAyBb,EAAM,gBAA2C,SAA3Bc;;EAA2B,CAC3E,GAEK,EAAE,eAAAC,GAAe,SAAAC,GAAS,YAAAC,GAAY,aAAAC,GAAa,eAAAC,GAAe,cAAAC,GAAc,kBAAAC,GAAkB,kBAAAC,GAAkB,cAAAC,MACxHhB,EAAc,SAAA;AAEhB,SAAAiB,EAAU,MAAM;AACd,IAAIxB,EAAM,YACRA,EAAM,SAASO,EAAc,UAAU;AAAA,EAE3C,GAAG,CAACQ,GAAeC,GAASC,GAAYC,GAAaC,GAAeC,GAAcC,GAAkBC,GAAkBC,CAAY,CAAC,GAE5H;AAAA,IACL,MAAM;AAAA,IACN,eAAAhB;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../../../src/molecules/table/hooks/useTable.tsx"],"sourcesContent":["import {\n type ColumnDef,\n getCoreRowModel,\n getFacetedRowModel,\n getFacetedUniqueValues,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n type TableOptions,\n type TableState,\n useReactTable\n} from \"@tanstack/react-table\";\nimport { useEffect } from \"react\";\n\nimport { useI18n } from \"../../../hooks/useI18n.js\";\nimport { type FormOptions, Operation } from \"../../../interfaces\";\nimport type { JSONRecord } from \"../../../interfaces/JSONRecord.js\";\nimport { getComponent } from \"../../../registries/components\";\nimport type { DefaultCellOperations } from \"../components/DefaultCellOperations\";\n\nexport interface UseTableProps<Data extends object = JSONRecord> extends Omit<TableOptions<Data>, \"onClick\" | \"getCoreRowModel\"> {\n operations: Operation<Data>[];\n metadata?: Record<string, unknown>;\n i18n?: FormOptions[\"i18n\"];\n onClick?: (data: Data, operation: Operation<Data>) => void;\n manualFaceted?: boolean;\n onChange?: (query: TableState) => void;\n pageSizes?: number[];\n}\n\nexport function useTable<Data extends object = JSONRecord>(props: UseTableProps<Data>) {\n const Operations = getComponent<typeof DefaultCellOperations<Data>>(\"CellOperations\");\n const { t } = useI18n(props.i18n);\n\n const operations = props.operations.length\n ? ([\n {\n id: \"operations\",\n header: t(\"Operations\"),\n cell: (info) => (\n <Operations info={info} operations={props.operations} metadata={props.metadata} onClick={props.onClick} i18n={t} />\n )\n }\n ] satisfies ColumnDef<Data>[])\n : [];\n\n const tableInstance = useReactTable({\n ...props,\n columns: [...props.columns, ...operations],\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getFilteredRowModel: !props.manualFiltering ? props.getFilteredRowModel || getFilteredRowModel() : undefined,\n getSortedRowModel: !props.manualSorting ? props.getSortedRowModel || getSortedRowModel() : undefined,\n getFacetedRowModel: !props.manualFaceted ? props.getFacetedRowModel || getFacetedRowModel() : undefined, // client-side faceting\n getFacetedUniqueValues: !props.manualFaceted ? props.getFacetedUniqueValues || getFacetedUniqueValues() : undefined // generate unique values for select filter/autocomplete\n });\n\n const { columnFilters, sorting, pagination, columnOrder, columnPinning, columnSizing, columnSizingInfo, columnVisibility, globalFilter } =\n tableInstance.getState();\n\n useEffect(() => {\n if (props.onChange) {\n props.onChange(tableInstance.getState());\n }\n }, [columnFilters, sorting, pagination, columnOrder, columnPinning, columnSizing, columnSizingInfo, columnVisibility, globalFilter]);\n\n return {\n i18n: t,\n tableInstance\n };\n}\n"],"names":["useTable","props","Operations","getComponent","useI18n","operations","info","jsx","tableInstance","useReactTable","getCoreRowModel","getPaginationRowModel","getFilteredRowModel","getSortedRowModel","getFacetedRowModel","getFacetedUniqueValues","columnFilters","sorting","pagination","columnOrder","columnPinning","columnSizing","columnSizingInfo","columnVisibility","globalFilter","useEffect"],"mappings":";;;;;AA8BO,SAASA,EAA2CC,GAA4B;AACrF,QAAMC,IAAaC,EAAiD,gBAAgB,GAC9E,EAAE,EAAA,IAAMC,EAAQH,EAAM,IAAI,GAE1BI,IAAaJ,EAAM,WAAW,SAC/B;AAAA,IACC;AAAA,MACE,IAAI;AAAA,MACJ,QAAQ,EAAE,YAAY;AAAA,MACtB,MAAM,CAACK,MACL,gBAAAC,EAACL,GAAA,EAAW,MAAAI,GAAY,YAAYL,EAAM,YAAY,UAAUA,EAAM,UAAU,SAASA,EAAM,SAAS,MAAM,EAAA,CAAG;AAAA,IAAA;AAAA,EAErH,IAEF,CAAA,GAEEO,IAAgBC,EAAc;AAAA,IAClC,GAAGR;AAAA,IACH,SAAS,CAAC,GAAGA,EAAM,SAAS,GAAGI,CAAU;AAAA,IACzC,iBAAiBK,EAAA;AAAA,IACjB,uBAAuBC,EAAA;AAAA,IACvB,qBAAsBV,EAAM,kBAAuE,SAArDA,EAAM,uBAAuBW;IAC3E,mBAAoBX,EAAM,gBAAiE,SAAjDA,EAAM,qBAAqBY;IACrE,oBAAqBZ,EAAM,gBAAmE,SAAnDA,EAAM,sBAAsBa;;IACvE,wBAAyBb,EAAM,gBAA2E,SAA3DA,EAAM,0BAA0Bc;;EAA2B,CAC3G,GAEK,EAAE,eAAAC,GAAe,SAAAC,GAAS,YAAAC,GAAY,aAAAC,GAAa,eAAAC,GAAe,cAAAC,GAAc,kBAAAC,GAAkB,kBAAAC,GAAkB,cAAAC,MACxHhB,EAAc,SAAA;AAEhB,SAAAiB,EAAU,MAAM;AACd,IAAIxB,EAAM,YACRA,EAAM,SAASO,EAAc,UAAU;AAAA,EAE3C,GAAG,CAACQ,GAAeC,GAASC,GAAYC,GAAaC,GAAeC,GAAcC,GAAkBC,GAAkBC,CAAY,CAAC,GAE5H;AAAA,IACL,MAAM;AAAA,IACN,eAAAhB;AAAA,EAAA;AAEJ;"}
@@ -1,5 +1,8 @@
1
- import { Header } from '@tanstack/react-table';
2
- export declare function useUniqValues<Data = any>({ header, filterVariant }: {
3
- header: Header<Data, unknown>;
4
- filterVariant: string;
5
- }): any[];
1
+ import { SelectOptionProps } from '../../../molecules/forms/select/Select.interface';
2
+ import { FilterProps } from '../components/DefaultFilter';
3
+ import { FilterSelectOptions } from '../filters/Filters';
4
+ type UseUniqValuesProps<Data = any> = Omit<FilterProps<Data, FilterSelectOptions>, "options"> & {
5
+ options?: FilterSelectOptions;
6
+ };
7
+ export declare function useUniqValues<Data = any>({ header, options }: UseUniqValuesProps<Data>): SelectOptionProps[];
8
+ export {};
@@ -1,11 +1,27 @@
1
- import { useMemo as u } from "react";
2
- function r({ header: e, filterVariant: o }) {
3
- return u(
4
- () => o === "range" ? [] : Array.from(e.column.getFacetedUniqueValues().keys()).flat().sort().slice(0, 5e3),
5
- [e.column, o]
6
- );
1
+ import { useMemo as o } from "react";
2
+ function m({ header: l, options: t }) {
3
+ return o(() => {
4
+ const n = t?.options;
5
+ if (n)
6
+ return typeof n == "function" ? n({ header: l, options: t }) : n;
7
+ switch (l.column.columnDef.meta?.filter?.variant) {
8
+ case "boolean":
9
+ return [
10
+ { label: l.column.columnDef.meta?.labels?.yes || "Yes", value: "true" },
11
+ {
12
+ label: l.column.columnDef.meta?.labels?.no || l.column.columnDef.meta?.labels?.No || "No",
13
+ value: "false"
14
+ }
15
+ ];
16
+ default:
17
+ return Array.from(l.column.getFacetedUniqueValues().keys()).flat().filter((e) => e != null).map((e) => String(e)).sort().slice(0, 5e3).map((e) => ({
18
+ label: e,
19
+ value: e
20
+ }));
21
+ }
22
+ }, [l, t]);
7
23
  }
8
24
  export {
9
- r as useUniqValues
25
+ m as useUniqValues
10
26
  };
11
27
  //# sourceMappingURL=useUniqValues.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUniqValues.js","sources":["../../../../src/molecules/table/hooks/useUniqValues.tsx"],"sourcesContent":["import type { Header } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\n\nexport function useUniqValues<Data = any>({ header, filterVariant }: { header: Header<Data, unknown>; filterVariant: string }) {\n return useMemo(\n () => (filterVariant === \"range\" ? [] : Array.from(header.column.getFacetedUniqueValues().keys()).flat().sort().slice(0, 5000)),\n\n [header.column, filterVariant]\n );\n}\n"],"names":["useUniqValues","header","filterVariant","useMemo"],"mappings":";AAGO,SAASA,EAA0B,EAAE,QAAAC,GAAQ,eAAAC,KAA2E;AAC7H,SAAOC;AAAA,IACL,MAAOD,MAAkB,UAAU,CAAA,IAAK,MAAM,KAAKD,EAAO,OAAO,uBAAA,EAAyB,KAAA,CAAM,EAAE,KAAA,EAAO,OAAO,MAAM,GAAG,GAAI;AAAA,IAE7H,CAACA,EAAO,QAAQC,CAAa;AAAA,EAAA;AAEjC;"}
1
+ {"version":3,"file":"useUniqValues.js","sources":["../../../../src/molecules/table/hooks/useUniqValues.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { SelectOptionProps } from \"../../../molecules/forms/select/Select.interface\";\nimport type { FilterProps } from \"../components/DefaultFilter\";\nimport { FilterSelectOptions } from \"../filters/Filters\";\n\ntype UseUniqValuesProps<Data = any> = Omit<FilterProps<Data, FilterSelectOptions>, \"options\"> & {\n options?: FilterSelectOptions;\n};\n\nexport function useUniqValues<Data = any>({ header, options }: UseUniqValuesProps<Data>): SelectOptionProps[] {\n return useMemo(() => {\n const providedOptions = options?.options;\n\n if (providedOptions) {\n if (typeof providedOptions === \"function\") {\n return providedOptions({ header, options: options as FilterSelectOptions });\n }\n\n return providedOptions;\n }\n\n switch (header.column.columnDef.meta?.filter?.variant) {\n case \"boolean\":\n return [\n { label: header.column.columnDef.meta?.labels?.[\"yes\"] || \"Yes\", value: \"true\" },\n {\n label: header.column.columnDef.meta?.labels?.[\"no\"] || header.column.columnDef.meta?.labels?.[\"No\"] || \"No\",\n value: \"false\"\n }\n ];\n\n default:\n return Array.from(header.column.getFacetedUniqueValues().keys())\n .flat()\n .filter((value) => value !== undefined && value !== null)\n .map((value) => String(value))\n .sort()\n .slice(0, 5000)\n .map((value) => ({\n label: value,\n value\n }));\n }\n }, [header, options]);\n}\n"],"names":["useUniqValues","header","options","useMemo","providedOptions","value"],"mappings":";AAUO,SAASA,EAA0B,EAAE,QAAAC,GAAQ,SAAAC,KAA0D;AAC5G,SAAOC,EAAQ,MAAM;AACnB,UAAMC,IAAkBF,GAAS;AAEjC,QAAIE;AACF,aAAI,OAAOA,KAAoB,aACtBA,EAAgB,EAAE,QAAAH,GAAQ,SAAAC,GAAyC,IAGrEE;AAGT,YAAQH,EAAO,OAAO,UAAU,MAAM,QAAQ,SAAA;AAAA,MAC5C,KAAK;AACH,eAAO;AAAA,UACL,EAAE,OAAOA,EAAO,OAAO,UAAU,MAAM,QAAS,OAAU,OAAO,OAAO,OAAA;AAAA,UACxE;AAAA,YACE,OAAOA,EAAO,OAAO,UAAU,MAAM,QAAS,MAASA,EAAO,OAAO,UAAU,MAAM,QAAS,MAAS;AAAA,YACvG,OAAO;AAAA,UAAA;AAAA,QACT;AAAA,MAGJ;AACE,eAAO,MAAM,KAAKA,EAAO,OAAO,yBAAyB,KAAA,CAAM,EAC5D,OACA,OAAO,CAACI,MAAiCA,KAAU,IAAI,EACvD,IAAI,CAACA,MAAU,OAAOA,CAAK,CAAC,EAC5B,KAAA,EACA,MAAM,GAAG,GAAI,EACb,IAAI,CAACA,OAAW;AAAA,UACf,OAAOA;AAAA,UACP,OAAAA;AAAA,QAAA,EACA;AAAA,IAAA;AAAA,EAEV,GAAG,CAACJ,GAAQC,CAAO,CAAC;AACtB;"}
@@ -3,6 +3,9 @@ import { TdHTMLAttributes } from 'react';
3
3
  import { FilterOptions } from '../filters/Filters';
4
4
  declare module "@tanstack/react-table" {
5
5
  interface ColumnMeta<TData extends RowData, TValue> {
6
+ type?: "string" | "number" | "boolean" | "date" | string;
7
+ format?: string;
8
+ labels?: Record<string, string>;
6
9
  filter?: FilterOptions;
7
10
  sort?: string;
8
11
  cellProps?: TdHTMLAttributes<HTMLTableCellElement>;
@@ -1,3 +1,7 @@
1
1
  import { ColumnDef, ColumnDefResolved } from '@tanstack/react-table';
2
2
  import { FormType } from '../../../interfaces';
3
- export declare function mapFormToColumns<Data = any>(form: FormType, columns?: ColumnDefResolved<Data, any>[]): ColumnDef<Data, any>[];
3
+ export declare function mapFormToColumns<Data = any>({ form, columns, prefix }: {
4
+ form: FormType;
5
+ columns?: ColumnDefResolved<Data, any>[];
6
+ prefix?: string;
7
+ }): ColumnDef<Data, any>[];
@@ -1,39 +1,66 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { r as f, c as d } from "../../../chunks/index2.js";
3
- import { createColumnHelper as g } from "@tanstack/react-table";
4
- import { c as C } from "../../../chunks/cloneDeep.js";
5
- import { g as x } from "../../../chunks/_commonjsHelpers.js";
1
+ import { createColumnHelper as f } from "@tanstack/react-table";
2
+ import { c as y } from "../../../chunks/cloneDeep.js";
3
+ import { g as C } from "../../../chunks/_commonjsHelpers.js";
4
+ import { r as g } from "../../../chunks/get.js";
6
5
  import { getComponent as b } from "../../../registries/components.js";
7
- var y = f();
8
- const k = /* @__PURE__ */ x(y), v = {
6
+ var x = g();
7
+ const h = /* @__PURE__ */ C(x), K = {
9
8
  number: "range",
10
9
  currency: "range",
11
10
  checkbox: "boolean"
11
+ }, k = {
12
+ date: "date",
13
+ datetime: "date",
14
+ number: "number",
15
+ currency: "currency",
16
+ checkbox: "boolean"
12
17
  };
13
- function H(c, p = []) {
14
- const u = g(), r = C(p), l = b("Cell");
15
- return c.components.flatMap((e) => e.type === "tabs" ? e.components?.flatMap((t) => t.components) : [e]).filter((e) => e?.tableView).map((e) => {
16
- const t = e, n = d.Components.create(t, {}, null), o = r.findIndex(({ accessorKey: m }) => m === `data.${t.key}`);
17
- let a = r[o];
18
- return a && r.splice(o, 1), u.accessor(`data.${t.key}`, {
18
+ function m(r) {
19
+ if ("id" in r && typeof r.id == "string")
20
+ return r.id;
21
+ if ("accessorKey" in r && typeof r.accessorKey == "string")
22
+ return r.accessorKey;
23
+ }
24
+ function S({
25
+ form: r,
26
+ columns: p = [],
27
+ prefix: l = "data."
28
+ }) {
29
+ const d = f(), n = y(p);
30
+ return [...r.components.flatMap((e) => e.type === "tabs" ? e.components?.flatMap((t) => t.components) : [e]).filter((e) => e?.tableView).map((e) => {
31
+ const t = e, o = `${l}${t.key}`, a = /* @__PURE__ */ new Set([t.key, o]), i = n.findIndex((u) => {
32
+ const c = m(u);
33
+ return c ? a.has(c) : !1;
34
+ });
35
+ let s = n[i];
36
+ return s && n.splice(i, 1), d.accessor(o, {
19
37
  header: (t.label || t.title || t.key)?.replace(/:/, ""),
20
- cell: (m) => /* @__PURE__ */ s(l, { value: m.getValue(), render: (i) => n.asString(i) }),
21
38
  meta: {
22
- filter: { variant: v[t.type] || "text" },
23
- ...a?.meta || {}
39
+ type: k[t.type] || t.type,
40
+ filter: {
41
+ ...s?.meta?.filter,
42
+ variant: K[t.type] || "text"
43
+ },
44
+ ...s?.meta || {}
24
45
  },
25
- ...a || {}
46
+ ...s || {}
26
47
  });
27
- }).concat(r).map((e, t) => ({
28
- ...e,
29
- meta: {
30
- ...e.meta || {},
31
- order: k(e, "meta.order", t * 10)
32
- },
33
- cell: e.cell || ((n) => /* @__PURE__ */ s(l, { value: n.getValue(), render: (o) => o }))
34
- })).sort((e, t) => e.meta.order > t.meta.order ? 1 : -1);
48
+ }), ...n].reduce((e, t) => {
49
+ const o = m(t);
50
+ return o && e.some((a) => m(a) === o) || e.push(t), e;
51
+ }, []).map((e, t) => {
52
+ const o = b([`Cell.${e.id}`, `Cell.${e.meta?.type}`, "Cell"]);
53
+ return {
54
+ ...e,
55
+ meta: {
56
+ ...e?.meta,
57
+ order: h(e, "meta.order", t * 10)
58
+ },
59
+ cell: e.cell || o
60
+ };
61
+ }).sort((e, t) => e.meta.order > t.meta.order ? 1 : -1);
35
62
  }
36
63
  export {
37
- H as mapFormToColumns
64
+ S as mapFormToColumns
38
65
  };
39
66
  //# sourceMappingURL=mapFormToColumns.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mapFormToColumns.js","sources":["../../../../src/molecules/table/utils/mapFormToColumns.tsx"],"sourcesContent":["import \"../interfaces/extends\";\n\nimport { Components } from \"@formio/js\";\nimport { ColumnDef, ColumnDefResolved, createColumnHelper } from \"@tanstack/react-table\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport get from \"lodash/get\";\n\nimport type { ComponentType, FormType } from \"../../../interfaces\";\nimport { getComponent } from \"../../../registries/components\";\nimport type { DefaultCell } from \"../components/DefaultCell\";\nimport type { FilterVariants } from \"../filters/Filters.js\";\n\nconst MAP_TYPES: Record<string, FilterVariants> = {\n number: \"range\",\n currency: \"range\",\n checkbox: \"boolean\"\n};\n\nexport function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefResolved<Data, any>[] = []): ColumnDef<Data, any>[] {\n const columnHelper = createColumnHelper<Data>();\n const columnsToKeep = cloneDeep(columns);\n\n const Cell = getComponent<typeof DefaultCell>(\"Cell\");\n\n const columnsFromComponents = form.components\n .flatMap((component) => {\n if (component.type === \"tabs\") {\n return component.components?.flatMap((subComponent: ComponentType) => subComponent.components);\n }\n\n return [component];\n })\n .filter((component) => component?.tableView)\n .map((c) => {\n const component = c as ComponentType;\n const cmp: any = Components.create(component, {}, null);\n\n const columnIndex = columnsToKeep.findIndex(({ accessorKey }) => {\n return accessorKey === `data.${component.key}`;\n });\n\n let column = columnsToKeep[columnIndex];\n\n if (column) {\n columnsToKeep.splice(columnIndex, 1);\n }\n\n return columnHelper.accessor(`data.${component.key}` as any, {\n header: (component.label || component.title || component.key)?.replace(/:/, \"\"),\n cell: (info) => {\n return <Cell value={info.getValue() as Data} render={(value: Data) => cmp.asString(value)} />;\n },\n meta: {\n filter: { variant: MAP_TYPES[component.type!] || \"text\" },\n ...(column?.meta || {})\n },\n ...(column || {})\n });\n });\n\n const mergedColumns = columnsFromComponents.concat(columnsToKeep as any[]).map((column, index) => ({\n ...column,\n meta: {\n ...(column.meta || {}),\n order: get(column, \"meta.order\", index * 10)\n },\n cell:\n column.cell ||\n ((info) => {\n return <Cell value={info.getValue() as Data} render={(value: Data) => value} />;\n })\n }));\n\n return mergedColumns.sort((a, b) => (a.meta.order > b.meta.order ? 1 : -1)) as ColumnDef<Data, any>[];\n}\n"],"names":["MAP_TYPES","mapFormToColumns","form","columns","columnHelper","createColumnHelper","columnsToKeep","cloneDeep","Cell","getComponent","component","subComponent","c","cmp","Components","columnIndex","accessorKey","column","info","jsx","value","index","get","a","b"],"mappings":";;;;;;;gCAYMA,IAA4C;AAAA,EAChD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AACZ;AAEO,SAASC,EAA6BC,GAAgBC,IAA0C,IAA4B;AACjI,QAAMC,IAAeC,EAAA,GACfC,IAAgBC,EAAUJ,CAAO,GAEjCK,IAAOC,EAAiC,MAAM;AAmDpD,SAjD8BP,EAAK,WAChC,QAAQ,CAACQ,MACJA,EAAU,SAAS,SACdA,EAAU,YAAY,QAAQ,CAACC,MAAgCA,EAAa,UAAU,IAGxF,CAACD,CAAS,CAClB,EACA,OAAO,CAACA,MAAcA,GAAW,SAAS,EAC1C,IAAI,CAACE,MAAM;AACV,UAAMF,IAAYE,GACZC,IAAWC,EAAAA,WAAW,OAAOJ,GAAW,CAAA,GAAI,IAAI,GAEhDK,IAAcT,EAAc,UAAU,CAAC,EAAE,aAAAU,QACtCA,MAAgB,QAAQN,EAAU,GAAG,EAC7C;AAED,QAAIO,IAASX,EAAcS,CAAW;AAEtC,WAAIE,KACFX,EAAc,OAAOS,GAAa,CAAC,GAG9BX,EAAa,SAAS,QAAQM,EAAU,GAAG,IAAW;AAAA,MAC3D,SAASA,EAAU,SAASA,EAAU,SAASA,EAAU,MAAM,QAAQ,KAAK,EAAE;AAAA,MAC9E,MAAM,CAACQ,MACE,gBAAAC,EAACX,GAAA,EAAK,OAAOU,EAAK,SAAA,GAAoB,QAAQ,CAACE,MAAgBP,EAAI,SAASO,CAAK,EAAA,CAAG;AAAA,MAE7F,MAAM;AAAA,QACJ,QAAQ,EAAE,SAASpB,EAAUU,EAAU,IAAK,KAAK,OAAA;AAAA,QACjD,GAAIO,GAAQ,QAAQ,CAAA;AAAA,MAAC;AAAA,MAEvB,GAAIA,KAAU,CAAA;AAAA,IAAC,CAChB;AAAA,EACH,CAAC,EAEyC,OAAOX,CAAsB,EAAE,IAAI,CAACW,GAAQI,OAAW;AAAA,IACjG,GAAGJ;AAAA,IACH,MAAM;AAAA,MACJ,GAAIA,EAAO,QAAQ,CAAA;AAAA,MACnB,OAAOK,EAAIL,GAAQ,cAAcI,IAAQ,EAAE;AAAA,IAAA;AAAA,IAE7C,MACEJ,EAAO,SACN,CAACC,MACO,gBAAAC,EAACX,KAAK,OAAOU,EAAK,YAAoB,QAAQ,CAACE,MAAgBA,GAAO;AAAA,EAC/E,EACF,EAEmB,KAAK,CAACG,GAAGC,MAAOD,EAAE,KAAK,QAAQC,EAAE,KAAK,QAAQ,IAAI,EAAG;AAC5E;"}
1
+ {"version":3,"file":"mapFormToColumns.js","sources":["../../../../src/molecules/table/utils/mapFormToColumns.tsx"],"sourcesContent":["import \"../interfaces/extends\";\n\nimport { ColumnDef, ColumnDefResolved, createColumnHelper } from \"@tanstack/react-table\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport get from \"lodash/get\";\n\nimport type { ComponentType, FormType } from \"../../../interfaces\";\nimport { getComponent } from \"../../../registries/components\";\nimport type { DefaultCell } from \"../components/DefaultCell\";\nimport type { FilterVariants } from \"../filters/Filters.js\";\n\nconst MAP_FILTER_TYPES: Record<string, FilterVariants> = {\n number: \"range\",\n currency: \"range\",\n checkbox: \"boolean\"\n} as const;\n\nconst MAP_TYPES = {\n date: \"date\",\n datetime: \"date\",\n number: \"number\",\n currency: \"currency\",\n checkbox: \"boolean\"\n} as const;\n\nfunction getColumnIdentity<Data>(column: ColumnDef<Data, any> | ColumnDefResolved<Data, any>) {\n if (\"id\" in column && typeof column.id === \"string\") {\n return column.id;\n }\n\n if (\"accessorKey\" in column && typeof column.accessorKey === \"string\") {\n return column.accessorKey;\n }\n\n return undefined;\n}\n\nexport function mapFormToColumns<Data = any>({\n form,\n columns = [],\n prefix = \"data.\"\n}: {\n form: FormType;\n columns?: ColumnDefResolved<Data, any>[];\n prefix?: string;\n}): ColumnDef<Data, any>[] {\n const columnHelper = createColumnHelper<Data>();\n const columnsToKeep = cloneDeep(columns);\n\n const columnsFromComponents = form.components\n .flatMap((component) => {\n if (component.type === \"tabs\") {\n return component.components?.flatMap((subComponent: ComponentType) => subComponent.components);\n }\n\n return [component];\n })\n .filter((component) => component?.tableView)\n .map((c) => {\n const component = c as ComponentType;\n const componentColumnKey = `${prefix}${component.key}`;\n const matchingKeys = new Set([component.key, componentColumnKey]);\n\n const columnIndex = columnsToKeep.findIndex((column) => {\n const identity = getColumnIdentity(column);\n\n return identity ? matchingKeys.has(identity) : false;\n });\n\n let column = columnsToKeep[columnIndex];\n\n if (column) {\n columnsToKeep.splice(columnIndex, 1);\n }\n\n return columnHelper.accessor(componentColumnKey as any, {\n header: (component.label || component.title || component.key)?.replace(/:/, \"\"),\n meta: {\n type: (MAP_TYPES[component.type as keyof typeof MAP_TYPES] || component.type) as any,\n filter: {\n ...column?.meta?.filter,\n variant: MAP_FILTER_TYPES[component.type as keyof typeof MAP_FILTER_TYPES] || \"text\"\n },\n ...(column?.meta || {})\n },\n ...(column || {})\n });\n });\n\n const dedupedColumns = [...columnsFromComponents, ...(columnsToKeep as any[])].reduce<ColumnDef<Data, any>[]>((acc, column) => {\n const identity = getColumnIdentity(column);\n\n if (identity && acc.some((existingColumn) => getColumnIdentity(existingColumn) === identity)) {\n return acc;\n }\n\n acc.push(column);\n return acc;\n }, []);\n\n const mergedColumns = dedupedColumns.map((column, index) => {\n const Cell = getComponent<typeof DefaultCell>([`Cell.${column.id}`, `Cell.${column.meta?.type}`, \"Cell\"]);\n\n return {\n ...column,\n meta: {\n ...column?.meta,\n order: get(column, \"meta.order\", index * 10)\n },\n cell: column.cell || Cell\n };\n });\n\n return mergedColumns.sort((a, b) => (a.meta.order > b.meta.order ? 1 : -1)) as ColumnDef<Data, any>[];\n}\n"],"names":["MAP_FILTER_TYPES","MAP_TYPES","getColumnIdentity","column","mapFormToColumns","form","columns","prefix","columnHelper","createColumnHelper","columnsToKeep","cloneDeep","component","subComponent","c","componentColumnKey","matchingKeys","columnIndex","identity","acc","existingColumn","index","Cell","getComponent","get","a","b"],"mappings":";;;;;;gCAWMA,IAAmD;AAAA,EACvD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AACZ,GAEMC,IAAY;AAAA,EAChB,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AACZ;AAEA,SAASC,EAAwBC,GAA6D;AAC5F,MAAI,QAAQA,KAAU,OAAOA,EAAO,MAAO;AACzC,WAAOA,EAAO;AAGhB,MAAI,iBAAiBA,KAAU,OAAOA,EAAO,eAAgB;AAC3D,WAAOA,EAAO;AAIlB;AAEO,SAASC,EAA6B;AAAA,EAC3C,MAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,QAAAC,IAAS;AACX,GAI2B;AACzB,QAAMC,IAAeC,EAAA,GACfC,IAAgBC,EAAUL,CAAO;AAkEvC,SAxBuB,CAAC,GAxCMD,EAAK,WAChC,QAAQ,CAACO,MACJA,EAAU,SAAS,SACdA,EAAU,YAAY,QAAQ,CAACC,MAAgCA,EAAa,UAAU,IAGxF,CAACD,CAAS,CAClB,EACA,OAAO,CAACA,MAAcA,GAAW,SAAS,EAC1C,IAAI,CAACE,MAAM;AACV,UAAMF,IAAYE,GACZC,IAAqB,GAAGR,CAAM,GAAGK,EAAU,GAAG,IAC9CI,IAAe,oBAAI,IAAI,CAACJ,EAAU,KAAKG,CAAkB,CAAC,GAE1DE,IAAcP,EAAc,UAAU,CAACP,MAAW;AACtD,YAAMe,IAAWhB,EAAkBC,CAAM;AAEzC,aAAOe,IAAWF,EAAa,IAAIE,CAAQ,IAAI;AAAA,IACjD,CAAC;AAED,QAAIf,IAASO,EAAcO,CAAW;AAEtC,WAAId,KACFO,EAAc,OAAOO,GAAa,CAAC,GAG9BT,EAAa,SAASO,GAA2B;AAAA,MACtD,SAASH,EAAU,SAASA,EAAU,SAASA,EAAU,MAAM,QAAQ,KAAK,EAAE;AAAA,MAC9E,MAAM;AAAA,QACJ,MAAOX,EAAUW,EAAU,IAA8B,KAAKA,EAAU;AAAA,QACxE,QAAQ;AAAA,UACN,GAAGT,GAAQ,MAAM;AAAA,UACjB,SAASH,EAAiBY,EAAU,IAAqC,KAAK;AAAA,QAAA;AAAA,QAEhF,GAAIT,GAAQ,QAAQ,CAAA;AAAA,MAAC;AAAA,MAEvB,GAAIA,KAAU,CAAA;AAAA,IAAC,CAChB;AAAA,EACH,CAAC,GAE+C,GAAIO,CAAuB,EAAE,OAA+B,CAACS,GAAKhB,MAAW;AAC7H,UAAMe,IAAWhB,EAAkBC,CAAM;AAEzC,WAAIe,KAAYC,EAAI,KAAK,CAACC,MAAmBlB,EAAkBkB,CAAc,MAAMF,CAAQ,KAI3FC,EAAI,KAAKhB,CAAM,GACRgB;AAAA,EACT,GAAG,CAAA,CAAE,EAEgC,IAAI,CAAChB,GAAQkB,MAAU;AAC1D,UAAMC,IAAOC,EAAiC,CAAC,QAAQpB,EAAO,EAAE,IAAI,QAAQA,EAAO,MAAM,IAAI,IAAI,MAAM,CAAC;AAExG,WAAO;AAAA,MACL,GAAGA;AAAA,MACH,MAAM;AAAA,QACJ,GAAGA,GAAQ;AAAA,QACX,OAAOqB,EAAIrB,GAAQ,cAAckB,IAAQ,EAAE;AAAA,MAAA;AAAA,MAE7C,MAAMlB,EAAO,QAAQmB;AAAA,IAAA;AAAA,EAEzB,CAAC,EAEoB,KAAK,CAACG,GAAGC,MAAOD,EAAE,KAAK,QAAQC,EAAE,KAAK,QAAQ,IAAI,EAAG;AAC5E;"}
@@ -1,12 +1,8 @@
1
- import { JSON } from '../../interfaces';
1
+ import { JSONRecord } from '../../interfaces/JSONRecord.js';
2
2
  import { UseFormProps } from './useForm';
3
3
  declare class CSSProperties {
4
4
  }
5
- export interface FormProps<Data extends {
6
- [key: string]: JSON;
7
- } = {
8
- [key: string]: JSON;
9
- }> extends UseFormProps<Data> {
5
+ export interface FormProps<Data extends object = JSONRecord> extends UseFormProps<Data> {
10
6
  ["data-testid"]?: string;
11
7
  /**
12
8
  *
@@ -14,9 +10,5 @@ export interface FormProps<Data extends {
14
10
  className?: string;
15
11
  style?: CSSProperties;
16
12
  }
17
- export declare function Form<Data extends {
18
- [key: string]: JSON;
19
- } = {
20
- [key: string]: JSON;
21
- }>({ style, className, "data-testid": dataTestId, ...props }: Partial<FormProps<Data>>): import("react/jsx-runtime").JSX.Element;
13
+ export declare function Form<Data extends object = JSONRecord>({ style, className, "data-testid": dataTestId, ...props }: Partial<FormProps<Data>>): import("react/jsx-runtime").JSX.Element;
22
14
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","sources":["../../../src/organisms/form/Form.tsx"],"sourcesContent":["import { JSON } from \"../../interfaces\";\nimport { useForm, UseFormProps } from \"./useForm\";\n\nclass CSSProperties {}\n\nexport interface FormProps<Data extends { [key: string]: JSON } = { [key: string]: JSON }> extends UseFormProps<Data> {\n [\"data-testid\"]?: string;\n /**\n *\n */\n className?: string;\n\n style?: CSSProperties;\n}\n\nexport function Form<Data extends { [key: string]: JSON } = { [key: string]: JSON }>({\n style,\n className,\n \"data-testid\": dataTestId = \"formio-container\",\n ...props\n}: Partial<FormProps<Data>>) {\n const { element } = useForm<Data>(props);\n\n return (\n <div>\n <div data-testid={dataTestId} style={style} className={className} ref={element} />\n </div>\n );\n}\n"],"names":["Form","style","className","dataTestId","props","element","useForm","jsx"],"mappings":";;AAeO,SAASA,EAAqE;AAAA,EACnF,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAeC,IAAa;AAAA,EAC5B,GAAGC;AACL,GAA6B;AAC3B,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAcF,CAAK;AAEvC,SACE,gBAAAG,EAAC,OAAA,EACC,UAAA,gBAAAA,EAAC,OAAA,EAAI,eAAaJ,GAAY,OAAAF,GAAc,WAAAC,GAAsB,KAAKG,EAAA,CAAS,EAAA,CAClF;AAEJ;"}
1
+ {"version":3,"file":"Form.js","sources":["../../../src/organisms/form/Form.tsx"],"sourcesContent":["import type { JSONRecord } from \"../../interfaces/JSONRecord.js\";\nimport { useForm, UseFormProps } from \"./useForm\";\n\nclass CSSProperties {}\n\nexport interface FormProps<Data extends object = JSONRecord> extends UseFormProps<Data> {\n [\"data-testid\"]?: string;\n /**\n *\n */\n className?: string;\n\n style?: CSSProperties;\n}\n\nexport function Form<Data extends object = JSONRecord>({\n style,\n className,\n \"data-testid\": dataTestId = \"formio-container\",\n ...props\n}: Partial<FormProps<Data>>) {\n const { element } = useForm<Data>(props);\n\n return (\n <div>\n <div data-testid={dataTestId} style={style} className={className} ref={element} />\n </div>\n );\n}\n"],"names":["Form","style","className","dataTestId","props","element","useForm","jsx"],"mappings":";;AAeO,SAASA,EAAuC;AAAA,EACrD,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAeC,IAAa;AAAA,EAC5B,GAAGC;AACL,GAA6B;AAC3B,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAcF,CAAK;AAEvC,SACE,gBAAAG,EAAC,OAAA,EACC,UAAA,gBAAAA,EAAC,OAAA,EAAI,eAAaJ,GAAY,OAAAF,GAAc,WAAAC,GAAsB,KAAKG,EAAA,CAAS,EAAA,CAClF;AAEJ;"}
@@ -1,6 +1,6 @@
1
1
  import { jsxs as m, jsx as l } from "react/jsx-runtime";
2
2
  import { g as f } from "../../../chunks/_commonjsHelpers.js";
3
- import { a as c } from "../../../chunks/index2.js";
3
+ import { r as c } from "../../../chunks/index2.js";
4
4
  import { Form as p } from "../Form.js";
5
5
  var d = c();
6
6
  const n = /* @__PURE__ */ f(d);
@@ -18,13 +18,13 @@ function b({ action: t, ...s }) {
18
18
  }), s;
19
19
  }
20
20
  function v({ actionInfo: t, children: s, onSubmit: r, options: e, ...i }) {
21
- const { form: u, submission: a } = (() => {
22
- const o = x(i.submission || {}, t.defaults);
23
- return { form: b(t.settingsForm), submission: { data: o } };
21
+ const { form: u, submission: o } = (() => {
22
+ const a = x(i.submission || {}, t.defaults);
23
+ return { form: b(t.settingsForm), submission: { data: a } };
24
24
  })();
25
25
  return /* @__PURE__ */ m("div", { children: [
26
26
  s,
27
- /* @__PURE__ */ l(p, { form: u, submission: a, onSubmit: r, options: e }),
27
+ /* @__PURE__ */ l(p, { form: u, submission: o, onSubmit: r, options: e }),
28
28
  s
29
29
  ] });
30
30
  }
@@ -1,12 +1,4 @@
1
- import { ComponentType, JSON, SubmissionType } from '../../interfaces';
2
- export interface FormPageChangeProps<Data extends {
3
- [key: string]: JSON;
4
- } = {
5
- [key: string]: JSON;
6
- }> {
7
- page: number;
8
- submission: SubmissionType<Data>;
9
- }
1
+ import { ComponentType } from '../../interfaces';
10
2
  export type FormCustomEvent = {
11
3
  type: string;
12
4
  event: string;
@@ -1,6 +1,7 @@
1
1
  import { Form } from '@formio/js';
2
2
  import { MutableRefObject } from 'react';
3
- import { ChangedSubmission, ComponentType, FormOptions, FormType, JSON, SubmissionType } from '../../interfaces';
3
+ import { ChangedSubmission, ComponentType, FormOptions, FormType, SubmissionType } from '../../interfaces';
4
+ import { JSON, JSONRecord } from '../../interfaces/JSONRecord.js';
4
5
  import { FormCustomEvent } from './types';
5
6
  type Webform = any;
6
7
  type EventError = string | Error | Error[] | {
@@ -8,11 +9,7 @@ type EventError = string | Error | Error[] | {
8
9
  } | {
9
10
  message: string;
10
11
  }[];
11
- export interface UseFormProps<Data extends {
12
- [key: string]: JSON;
13
- } = {
14
- [key: string]: JSON;
15
- }> {
12
+ export interface UseFormProps<Data extends object = JSONRecord> {
16
13
  src?: string;
17
14
  url?: string;
18
15
  form?: FormType;
@@ -55,11 +52,7 @@ export interface UseFormProps<Data extends {
55
52
  [event: string]: (...args: any[]) => void;
56
53
  };
57
54
  }
58
- export declare function useForm<Data extends {
59
- [key: string]: JSON;
60
- } = {
61
- [key: string]: JSON;
62
- }>(props: UseFormProps<Data>): {
55
+ export declare function useForm<Data extends object = JSONRecord>(props: UseFormProps<Data>): {
63
56
  element: MutableRefObject<HTMLDivElement | null>;
64
57
  instance: any;
65
58
  };