@tsed/react-formio 3.0.0-rc.13 → 3.0.0-rc.14

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 (38) hide show
  1. package/dist/all.js +2 -0
  2. package/dist/all.js.map +1 -1
  3. package/dist/chunks/index2.js +19748 -22277
  4. package/dist/chunks/index2.js.map +1 -1
  5. package/dist/chunks/moment.js +2535 -0
  6. package/dist/chunks/moment.js.map +1 -0
  7. package/dist/molecules/forms/select/Select.interface.d.ts +0 -4
  8. package/dist/molecules/table/all.js +2 -0
  9. package/dist/molecules/table/all.js.map +1 -1
  10. package/dist/molecules/table/components/DefaultBooleanCell.d.ts +2 -0
  11. package/dist/molecules/table/components/DefaultBooleanCell.js +12 -0
  12. package/dist/molecules/table/components/DefaultBooleanCell.js.map +1 -0
  13. package/dist/molecules/table/components/DefaultCell.js +7 -7
  14. package/dist/molecules/table/components/DefaultCell.js.map +1 -1
  15. package/dist/molecules/table/components/DefaultDateCell.d.ts +2 -0
  16. package/dist/molecules/table/components/DefaultDateCell.js +16 -0
  17. package/dist/molecules/table/components/DefaultDateCell.js.map +1 -0
  18. package/dist/molecules/table/components/DefaultFilter.d.ts +5 -7
  19. package/dist/molecules/table/components/DefaultFilter.js +8 -8
  20. package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
  21. package/dist/molecules/table/interfaces/extends.d.ts +3 -0
  22. package/dist/molecules/table/utils/mapFormToColumns.js +36 -24
  23. package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
  24. package/dist/organisms/table/forms/components/FormsCell.js +1 -1
  25. package/package.json +3 -3
  26. package/src/all.ts +2 -0
  27. package/src/molecules/forms/select/Select.interface.ts +0 -4
  28. package/src/molecules/table/all.ts +2 -0
  29. package/src/molecules/table/components/DefaultBooleanCell.spec.tsx +42 -0
  30. package/src/molecules/table/components/DefaultBooleanCell.tsx +11 -0
  31. package/src/molecules/table/components/DefaultCell.tsx +1 -1
  32. package/src/molecules/table/components/DefaultDateCell.spec.tsx +43 -0
  33. package/src/molecules/table/components/DefaultDateCell.tsx +23 -0
  34. package/src/molecules/table/components/DefaultFilter.tsx +10 -7
  35. package/src/molecules/table/filters/Filters.d.ts +1 -0
  36. package/src/molecules/table/interfaces/extends.ts +3 -0
  37. package/src/molecules/table/utils/mapFormToColumns.spec.tsx +20 -0
  38. package/src/molecules/table/utils/mapFormToColumns.tsx +27 -14
@@ -24,10 +24,6 @@ export interface SelectProps<Data = string> extends FormControlProps<Data, Selec
24
24
  searchEnabled?: boolean;
25
25
  customProperties?: Record<string, any>;
26
26
  options: (SelectOptionBaseProps<Data> | Omit<SelectOptionProps<Data>, "value">)[];
27
- /**
28
- * @deprecated
29
- */
30
- choices?: (SelectOptionBaseProps<Data> | Omit<SelectOptionProps<Data>, "value">)[];
31
27
  }
32
28
  export interface SelectSingle<Data = string> extends SelectProps<Data> {
33
29
  multiple?: false | undefined;
@@ -1,6 +1,8 @@
1
1
  import "./components/DefaultFilter.js";
2
2
  import "./components/DefaultArrowSort.js";
3
3
  import "./components/DefaultCell.js";
4
+ import "./components/DefaultBooleanCell.js";
5
+ import "./components/DefaultDateCell.js";
4
6
  import "./components/DefaultCellOperations.js";
5
7
  import "./components/DefaultOperationButton.js";
6
8
  import "./components/DefaultCellHeader.js";
@@ -1 +1 @@
1
- {"version":3,"file":"all.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"all.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ import { CellContext } from '@tanstack/react-table';
2
+ export declare function DefaultCellBoolean<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, boolean>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { registerComponent as o } from "../../../registries/components.js";
3
+ function l({ getValue: t, column: { columnDef: e } }) {
4
+ const n = t();
5
+ return /* @__PURE__ */ r("span", { children: String(n ? e.meta?.labels?.yes || "Yes" : e.meta?.labels?.No || "No") });
6
+ }
7
+ o("Cell.boolean", l);
8
+ o("Cell.checkbox", l);
9
+ export {
10
+ l as DefaultCellBoolean
11
+ };
12
+ //# sourceMappingURL=DefaultBooleanCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultBooleanCell.js","sources":["../../../../src/molecules/table/components/DefaultBooleanCell.tsx"],"sourcesContent":["import { CellContext } from \"@tanstack/react-table\";\n\nimport { registerComponent } from \"../../../registries/components\";\n\nexport function DefaultCellBoolean<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, boolean>) {\n const value = getValue();\n return <span>{String(value ? columnDef.meta?.labels?.[\"yes\"] || \"Yes\" : columnDef.meta?.labels?.[\"No\"] || \"No\")}</span>;\n}\n\nregisterComponent(\"Cell.boolean\", DefaultCellBoolean);\nregisterComponent(\"Cell.checkbox\", DefaultCellBoolean);\n"],"names":["DefaultCellBoolean","getValue","columnDef","value","registerComponent"],"mappings":";;AAIO,SAASA,EAAwC,EAAE,UAAAC,GAAU,QAAQ,EAAE,WAAAC,EAAA,KAA2C;AACvH,QAAMC,IAAQF,EAAA;AACd,2BAAQ,QAAA,EAAM,UAAA,OAAOE,IAAQD,EAAU,MAAM,QAAS,OAAU,QAAQA,EAAU,MAAM,QAAS,MAAS,IAAI,GAAE;AAClH;AAEAE,EAAkB,gBAAgBJ,CAAkB;AACpDI,EAAkB,iBAAiBJ,CAAkB;"}
@@ -1,14 +1,14 @@
1
- import { jsx as n } from "react/jsx-runtime";
1
+ import { jsx as e } from "react/jsx-runtime";
2
2
  import { registerComponent as t } from "../../../registries/components.js";
3
- function l({ getValue: o, renderValue: i }) {
4
- const e = o();
5
- if (e === void 0)
6
- return /* @__PURE__ */ n("span", {});
3
+ function l({ getValue: i, renderValue: o }) {
7
4
  const r = i();
8
- return r != null && e !== r ? /* @__PURE__ */ n("div", { dangerouslySetInnerHTML: { __html: String(r) } }) : /* @__PURE__ */ n("span", { children: String(e) });
5
+ if (r === void 0)
6
+ return /* @__PURE__ */ e("span", {});
7
+ const n = o();
8
+ return n != null && r !== n ? /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: String(n) } }) : /* @__PURE__ */ e("span", { children: String(r) });
9
9
  }
10
10
  t("Cell", l);
11
- t("Cell.text", l);
11
+ t("Cell.string", l);
12
12
  export {
13
13
  l as DefaultCell
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultCell.js","sources":["../../../../src/molecules/table/components/DefaultCell.tsx"],"sourcesContent":["import type { CellContext } from \"@tanstack/react-table\";\n\nimport { registerComponent } from \"../../../registries/components\";\n\nexport function DefaultCell<Data = any>({ getValue, renderValue }: CellContext<Data, any>): JSX.Element {\n const value = getValue();\n if (value === undefined) {\n return <span></span>;\n }\n\n const rendered = renderValue();\n\n if (rendered != null && value !== rendered) {\n return <div dangerouslySetInnerHTML={{ __html: String(rendered) }} />;\n }\n\n return <span>{String(value)}</span>;\n}\n\nregisterComponent(\"Cell\", DefaultCell);\nregisterComponent(\"Cell.text\", DefaultCell);\n"],"names":["DefaultCell","getValue","renderValue","value","rendered","jsx","registerComponent"],"mappings":";;AAIO,SAASA,EAAwB,EAAE,UAAAC,GAAU,aAAAC,KAAoD;AACtG,QAAMC,IAAQF,EAAA;AACd,MAAIE,MAAU;AACZ,6BAAQ,QAAA,EAAK;AAGf,QAAMC,IAAWF,EAAA;AAEjB,SAAIE,KAAY,QAAQD,MAAUC,IACzB,gBAAAC,EAAC,SAAI,yBAAyB,EAAE,QAAQ,OAAOD,CAAQ,KAAK,IAG9D,gBAAAC,EAAC,QAAA,EAAM,UAAA,OAAOF,CAAK,GAAE;AAC9B;AAEAG,EAAkB,QAAQN,CAAW;AACrCM,EAAkB,aAAaN,CAAW;"}
1
+ {"version":3,"file":"DefaultCell.js","sources":["../../../../src/molecules/table/components/DefaultCell.tsx"],"sourcesContent":["import type { CellContext } from \"@tanstack/react-table\";\n\nimport { registerComponent } from \"../../../registries/components\";\n\nexport function DefaultCell<Data = any>({ getValue, renderValue }: CellContext<Data, any>): JSX.Element {\n const value = getValue();\n if (value === undefined) {\n return <span></span>;\n }\n\n const rendered = renderValue();\n\n if (rendered != null && value !== rendered) {\n return <div dangerouslySetInnerHTML={{ __html: String(rendered) }} />;\n }\n\n return <span>{String(value)}</span>;\n}\n\nregisterComponent(\"Cell\", DefaultCell);\nregisterComponent(\"Cell.string\", DefaultCell);\n"],"names":["DefaultCell","getValue","renderValue","value","rendered","jsx","registerComponent"],"mappings":";;AAIO,SAASA,EAAwB,EAAE,UAAAC,GAAU,aAAAC,KAAoD;AACtG,QAAMC,IAAQF,EAAA;AACd,MAAIE,MAAU;AACZ,6BAAQ,QAAA,EAAK;AAGf,QAAMC,IAAWF,EAAA;AAEjB,SAAIE,KAAY,QAAQD,MAAUC,IACzB,gBAAAC,EAAC,SAAI,yBAAyB,EAAE,QAAQ,OAAOD,CAAQ,KAAK,IAG9D,gBAAAC,EAAC,QAAA,EAAM,UAAA,OAAOF,CAAK,GAAE;AAC9B;AAEAG,EAAkB,QAAQN,CAAW;AACrCM,EAAkB,eAAeN,CAAW;"}
@@ -0,0 +1,2 @@
1
+ import { CellContext } from '@tanstack/react-table';
2
+ export declare function DefaultDateCell<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, string>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { h as o } from "../../../chunks/moment.js";
3
+ import { registerComponent as n } from "../../../registries/components.js";
4
+ function a({ getValue: i, column: { columnDef: l } }) {
5
+ const e = i();
6
+ if (!e)
7
+ return /* @__PURE__ */ t("span", {});
8
+ const r = o.parseZone(e, o.ISO_8601, !0);
9
+ return r.isValid() ? /* @__PURE__ */ t("span", { children: r.format(l.meta?.format || "L") }) : /* @__PURE__ */ t("span", { children: String(e) });
10
+ }
11
+ n("Cell.date", a);
12
+ n("Cell.datetime", a);
13
+ export {
14
+ a as DefaultDateCell
15
+ };
16
+ //# sourceMappingURL=DefaultDateCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultDateCell.js","sources":["../../../../src/molecules/table/components/DefaultDateCell.tsx"],"sourcesContent":["import { CellContext } from \"@tanstack/react-table\";\nimport moment from \"moment\";\n\nimport { registerComponent } from \"../../../registries/components\";\n\nexport function DefaultDateCell<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, string>) {\n const value = getValue();\n\n if (!value) {\n return <span />;\n }\n\n const date = moment.parseZone(value, moment.ISO_8601, true);\n\n if (!date.isValid()) {\n return <span>{String(value)}</span>;\n }\n\n return <span>{date.format(columnDef.meta?.format || \"L\")}</span>;\n}\n\nregisterComponent(\"Cell.date\", DefaultDateCell);\nregisterComponent(\"Cell.datetime\", DefaultDateCell);\n"],"names":["DefaultDateCell","getValue","columnDef","value","date","moment","jsx","registerComponent"],"mappings":";;;AAKO,SAASA,EAAqC,EAAE,UAAAC,GAAU,QAAQ,EAAE,WAAAC,EAAA,KAA0C;AACnH,QAAMC,IAAQF,EAAA;AAEd,MAAI,CAACE;AACH,6BAAQ,QAAA,EAAK;AAGf,QAAMC,IAAOC,EAAO,UAAUF,GAAOE,EAAO,UAAU,EAAI;AAE1D,SAAKD,EAAK,YAIH,gBAAAE,EAAC,UAAM,UAAAF,EAAK,OAAOF,EAAU,MAAM,UAAU,GAAG,EAAA,CAAE,IAHhD,gBAAAI,EAAC,QAAA,EAAM,UAAA,OAAOH,CAAK,GAAE;AAIhC;AAEAI,EAAkB,aAAaP,CAAe;AAC9CO,EAAkB,iBAAiBP,CAAe;"}
@@ -1,11 +1,9 @@
1
- import { Header } from '@tanstack/react-table';
2
- export interface DefaultFilterProps<Data = any> {
3
- header: Header<Data, unknown>;
1
+ import { Header, RowData } from '@tanstack/react-table';
2
+ export interface DefaultFilterProps<Data extends RowData = any, TValue = unknown> {
3
+ header: Header<Data, TValue>;
4
4
  i18n?: (f: string) => string;
5
5
  }
6
- export interface FilterProps<Data = any, Opts = Record<string, unknown>> {
7
- header: Header<Data, unknown>;
6
+ export interface FilterProps<Data extends RowData = any, Opts = Record<string, unknown>> extends DefaultFilterProps<Data> {
8
7
  options: Opts;
9
- i18n?: (f: string) => string;
10
8
  }
11
- export declare function DefaultFilter<Data = any>({ header, i18n }: DefaultFilterProps<Data>): import("react/jsx-runtime").JSX.Element | null;
9
+ export declare function DefaultFilter<Data extends RowData = any, TValue = unknown>(props: DefaultFilterProps<Data, TValue>): import("react/jsx-runtime").JSX.Element | null;
@@ -1,15 +1,15 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { registerComponent as o, getComponent as c } from "../../../registries/components.js";
3
- function m({ header: t, i18n: n }) {
4
- const {
5
- filter: r = {
2
+ import { registerComponent as a, getComponent as c } from "../../../registries/components.js";
3
+ function s(n) {
4
+ const { header: t, i18n: o } = n, {
5
+ filter: e = {
6
6
  variant: "text"
7
7
  }
8
- } = t.column.columnDef.meta || {}, { variant: i } = r, e = c([`Filter.${t.column.id}`, `Filter.${i}`, "Filter.text"]);
9
- return e ? /* @__PURE__ */ l("div", { className: "table-cell-header__filter", children: /* @__PURE__ */ l(e, { header: t, options: r, i18n: n }) }) : (console.warn("Missing filter for `Filter." + t.column.id + "` or `Filter." + i + "`"), null);
8
+ } = t.column.columnDef.meta || {}, { variant: r } = e, i = c([`Filter.${t.column.id}`, `Filter.${r}`, "Filter.text"]);
9
+ return i ? e.disabled ? null : /* @__PURE__ */ l("div", { className: "table-cell-header__filter", children: /* @__PURE__ */ l(i, { header: t, options: e, i18n: o }) }) : (console.warn("Missing filter for `Filter." + t.column.id + "` or `Filter." + r + "`"), null);
10
10
  }
11
- o("Filter", m);
11
+ a("Filter", s);
12
12
  export {
13
- m as DefaultFilter
13
+ s as DefaultFilter
14
14
  };
15
15
  //# sourceMappingURL=DefaultFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultFilter.js","sources":["../../../../src/molecules/table/components/DefaultFilter.tsx"],"sourcesContent":["import \"../interfaces/extends\";\n\nimport { Header } from \"@tanstack/react-table\";\nimport type { ComponentType } from \"react\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\n\nexport interface DefaultFilterProps<Data = any> {\n header: Header<Data, unknown>;\n i18n?: (f: string) => string;\n}\n\nexport interface FilterProps<Data = any, Opts = Record<string, unknown>> {\n header: Header<Data, unknown>;\n options: Opts;\n i18n?: (f: string) => string;\n}\n\nexport function DefaultFilter<Data = any>({ header, i18n }: DefaultFilterProps<Data>) {\n const {\n filter = {\n variant: \"text\"\n }\n } = header.column.columnDef.meta || {};\n\n const { variant: filterVariant } = filter;\n const Filter = getComponent<ComponentType<FilterProps>>([`Filter.${header.column.id}`, `Filter.${filterVariant}`, \"Filter.text\"]);\n\n if (!Filter) {\n console.warn(\"Missing filter for `Filter.\" + header.column.id + \"` or `Filter.\" + filterVariant + \"`\");\n\n return null;\n }\n\n return (\n <div className='table-cell-header__filter'>\n <Filter header={header} options={filter} i18n={i18n} />\n </div>\n );\n}\n\nregisterComponent(\"Filter\", DefaultFilter);\n"],"names":["DefaultFilter","header","i18n","filter","filterVariant","Filter","getComponent","jsx","registerComponent"],"mappings":";;AAkBO,SAASA,EAA0B,EAAE,QAAAC,GAAQ,MAAAC,KAAkC;AACpF,QAAM;AAAA,IACJ,QAAAC,IAAS;AAAA,MACP,SAAS;AAAA,IAAA;AAAA,EACX,IACEF,EAAO,OAAO,UAAU,QAAQ,CAAA,GAE9B,EAAE,SAASG,EAAA,IAAkBD,GAC7BE,IAASC,EAAyC,CAAC,UAAUL,EAAO,OAAO,EAAE,IAAI,UAAUG,CAAa,IAAI,aAAa,CAAC;AAEhI,SAAKC,IAOH,gBAAAE,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA,gBAAAA,EAACF,KAAO,QAAAJ,GAAgB,SAASE,GAAQ,MAAAD,EAAA,CAAY,EAAA,CACvD,KARA,QAAQ,KAAK,gCAAgCD,EAAO,OAAO,KAAK,kBAAkBG,IAAgB,GAAG,GAE9F;AAQX;AAEAI,EAAkB,UAAUR,CAAa;"}
1
+ {"version":3,"file":"DefaultFilter.js","sources":["../../../../src/molecules/table/components/DefaultFilter.tsx"],"sourcesContent":["import \"../interfaces/extends\";\n\nimport { Header, RowData } from \"@tanstack/react-table\";\nimport type { ComponentType } from \"react\";\n\nimport { getComponent, registerComponent } from \"../../../registries/components\";\n\nexport interface DefaultFilterProps<Data extends RowData = any, TValue = unknown> {\n header: Header<Data, TValue>;\n i18n?: (f: string) => string;\n}\n\nexport interface FilterProps<Data extends RowData = any, Opts = Record<string, unknown>> extends DefaultFilterProps<Data> {\n options: Opts;\n}\n\nexport function DefaultFilter<Data extends RowData = any, TValue = unknown>(props: DefaultFilterProps<Data, TValue>) {\n const { header, i18n } = props;\n const {\n filter = {\n variant: \"text\"\n }\n } = header.column.columnDef.meta || {};\n\n const { variant: filterVariant } = filter;\n const Filter = getComponent<ComponentType<FilterProps>>([`Filter.${header.column.id}`, `Filter.${filterVariant}`, \"Filter.text\"]);\n\n if (!Filter) {\n console.warn(\"Missing filter for `Filter.\" + header.column.id + \"` or `Filter.\" + filterVariant + \"`\");\n\n return null;\n }\n\n if (filter.disabled) {\n return null;\n }\n\n return (\n <div className='table-cell-header__filter'>\n <Filter header={header} options={filter} i18n={i18n} />\n </div>\n );\n}\n\nregisterComponent(\"Filter\", DefaultFilter);\n"],"names":["DefaultFilter","props","header","i18n","filter","filterVariant","Filter","getComponent","jsx","registerComponent"],"mappings":";;AAgBO,SAASA,EAA4DC,GAAyC;AACnH,QAAM,EAAE,QAAAC,GAAQ,MAAAC,EAAA,IAASF,GACnB;AAAA,IACJ,QAAAG,IAAS;AAAA,MACP,SAAS;AAAA,IAAA;AAAA,EACX,IACEF,EAAO,OAAO,UAAU,QAAQ,CAAA,GAE9B,EAAE,SAASG,EAAA,IAAkBD,GAC7BE,IAASC,EAAyC,CAAC,UAAUL,EAAO,OAAO,EAAE,IAAI,UAAUG,CAAa,IAAI,aAAa,CAAC;AAEhI,SAAKC,IAMDF,EAAO,WACF,OAIP,gBAAAI,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA,gBAAAA,EAACF,KAAO,QAAAJ,GAAgB,SAASE,GAAQ,MAAAD,EAAA,CAAY,EAAA,CACvD,KAZA,QAAQ,KAAK,gCAAgCD,EAAO,OAAO,KAAK,kBAAkBG,IAAgB,GAAG,GAE9F;AAYX;AAEAI,EAAkB,UAAUT,CAAa;"}
@@ -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,38 +1,50 @@
1
- import { createColumnHelper as p } from "@tanstack/react-table";
2
- import { c as u } from "../../../chunks/cloneDeep.js";
3
- import { g as i } from "../../../chunks/_commonjsHelpers.js";
4
- import { r as f } from "../../../chunks/get.js";
1
+ import { createColumnHelper as s } from "@tanstack/react-table";
2
+ import { c as p } from "../../../chunks/cloneDeep.js";
3
+ import { g as u } from "../../../chunks/_commonjsHelpers.js";
4
+ import { r as i } from "../../../chunks/get.js";
5
5
  import { getComponent as d } from "../../../registries/components.js";
6
- var C = f();
7
- const g = /* @__PURE__ */ i(C), x = {
6
+ var f = i();
7
+ const y = /* @__PURE__ */ u(f), C = {
8
8
  number: "range",
9
9
  currency: "range",
10
10
  checkbox: "boolean"
11
+ }, b = {
12
+ date: "date",
13
+ datetime: "date",
14
+ number: "number",
15
+ currency: "currency",
16
+ checkbox: "boolean"
11
17
  };
12
- function h(a, l = []) {
13
- const c = p(), o = u(l), n = d("Cell");
18
+ function P(a, m = []) {
19
+ const c = s(), r = p(m);
14
20
  return a.components.flatMap((e) => e.type === "tabs" ? e.components?.flatMap((t) => t.components) : [e]).filter((e) => e?.tableView).map((e) => {
15
- const t = e, m = o.findIndex(({ accessorKey: s }) => s === `data.${t.key}`);
16
- let r = o[m];
17
- return r && o.splice(m, 1), c.accessor(`data.${t.key}`, {
21
+ const t = e, o = r.findIndex(({ accessorKey: l }) => l === `data.${t.key}`);
22
+ let n = r[o];
23
+ return n && r.splice(o, 1), c.accessor(`data.${t.key}`, {
18
24
  header: (t.label || t.title || t.key)?.replace(/:/, ""),
19
- cell: n,
20
25
  meta: {
21
- filter: { variant: x[t.type] || "text" },
22
- ...r?.meta || {}
26
+ type: b[t.type] || t.type,
27
+ filter: {
28
+ ...n?.meta?.filter,
29
+ variant: C[t.type] || "text"
30
+ },
31
+ ...n?.meta || {}
23
32
  },
24
- ...r || {}
33
+ ...n || {}
25
34
  });
26
- }).concat(o).map((e, t) => ({
27
- ...e,
28
- meta: {
29
- ...e.meta || {},
30
- order: g(e, "meta.order", t * 10)
31
- },
32
- cell: e.cell || n
33
- })).sort((e, t) => e.meta.order > t.meta.order ? 1 : -1);
35
+ }).concat(r).map((e, t) => {
36
+ const o = d([`Cell.${e.id}`, `Cell.${e.meta?.type}`, "Cell"]);
37
+ return {
38
+ ...e,
39
+ meta: {
40
+ ...e?.meta,
41
+ order: y(e, "meta.order", t * 10)
42
+ },
43
+ cell: e.cell || o
44
+ };
45
+ }).sort((e, t) => e.meta.order > t.meta.order ? 1 : -1);
34
46
  }
35
47
  export {
36
- h as mapFormToColumns
48
+ P as mapFormToColumns
37
49
  };
38
50
  //# 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 { 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\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: Cell,\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: column.cell || Cell\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","columnIndex","accessorKey","column","index","get","a","b"],"mappings":";;;;;;gCAWMA,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;AA4CpD,SA1C8BP,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,GAEZC,IAAcP,EAAc,UAAU,CAAC,EAAE,aAAAQ,QACtCA,MAAgB,QAAQJ,EAAU,GAAG,EAC7C;AAED,QAAIK,IAAST,EAAcO,CAAW;AAEtC,WAAIE,KACFT,EAAc,OAAOO,GAAa,CAAC,GAG9BT,EAAa,SAAS,QAAQM,EAAU,GAAG,IAAW;AAAA,MAC3D,SAASA,EAAU,SAASA,EAAU,SAASA,EAAU,MAAM,QAAQ,KAAK,EAAE;AAAA,MAC9E,MAAMF;AAAA,MACN,MAAM;AAAA,QACJ,QAAQ,EAAE,SAASR,EAAUU,EAAU,IAAK,KAAK,OAAA;AAAA,QACjD,GAAIK,GAAQ,QAAQ,CAAA;AAAA,MAAC;AAAA,MAEvB,GAAIA,KAAU,CAAA;AAAA,IAAC,CAChB;AAAA,EACH,CAAC,EAEyC,OAAOT,CAAsB,EAAE,IAAI,CAACS,GAAQC,OAAW;AAAA,IACjG,GAAGD;AAAA,IACH,MAAM;AAAA,MACJ,GAAIA,EAAO,QAAQ,CAAA;AAAA,MACnB,OAAOE,EAAIF,GAAQ,cAAcC,IAAQ,EAAE;AAAA,IAAA;AAAA,IAE7C,MAAMD,EAAO,QAAQP;AAAA,EAAA,EACrB,EAEmB,KAAK,CAACU,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\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 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\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 meta: {\n type: MAP_TYPES[component.type as keyof typeof MAP_TYPES] || component.type,\n filter: {\n ...column?.meta?.filter,\n variant: MAP_FILTER_TYPES[component.type!] || \"text\"\n },\n ...(column?.meta || {})\n },\n ...(column || {})\n });\n });\n\n const mergedColumns = columnsFromComponents.concat(columnsToKeep as any[]).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","mapFormToColumns","form","columns","columnHelper","createColumnHelper","columnsToKeep","cloneDeep","component","subComponent","c","columnIndex","accessorKey","column","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;AAEO,SAASC,EAA6BC,GAAgBC,IAA0C,IAA4B;AACjI,QAAMC,IAAeC,EAAA,GACfC,IAAgBC,EAAUJ,CAAO;AAmDvC,SAjD8BD,EAAK,WAChC,QAAQ,CAACM,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,GAEZC,IAAcL,EAAc,UAAU,CAAC,EAAE,aAAAM,QACtCA,MAAgB,QAAQJ,EAAU,GAAG,EAC7C;AAED,QAAIK,IAASP,EAAcK,CAAW;AAEtC,WAAIE,KACFP,EAAc,OAAOK,GAAa,CAAC,GAG9BP,EAAa,SAAS,QAAQI,EAAU,GAAG,IAAW;AAAA,MAC3D,SAASA,EAAU,SAASA,EAAU,SAASA,EAAU,MAAM,QAAQ,KAAK,EAAE;AAAA,MAC9E,MAAM;AAAA,QACJ,MAAMR,EAAUQ,EAAU,IAA8B,KAAKA,EAAU;AAAA,QACvE,QAAQ;AAAA,UACN,GAAGK,GAAQ,MAAM;AAAA,UACjB,SAASd,EAAiBS,EAAU,IAAK,KAAK;AAAA,QAAA;AAAA,QAEhD,GAAIK,GAAQ,QAAQ,CAAA;AAAA,MAAC;AAAA,MAEvB,GAAIA,KAAU,CAAA;AAAA,IAAC,CAChB;AAAA,EACH,CAAC,EAEyC,OAAOP,CAAsB,EAAE,IAAI,CAACO,GAAQC,MAAU;AAChG,UAAMC,IAAOC,EAAiC,CAAC,QAAQH,EAAO,EAAE,IAAI,QAAQA,EAAO,MAAM,IAAI,IAAI,MAAM,CAAC;AAExG,WAAO;AAAA,MACL,GAAGA;AAAA,MACH,MAAM;AAAA,QACJ,GAAGA,GAAQ;AAAA,QACX,OAAOI,EAAIJ,GAAQ,cAAcC,IAAQ,EAAE;AAAA,MAAA;AAAA,MAE7C,MAAMD,EAAO,QAAQE;AAAA,IAAA;AAAA,EAEzB,CAAC,EAEoB,KAAK,CAACG,GAAGC,MAAOD,EAAE,KAAK,QAAQC,EAAE,KAAK,QAAQ,IAAI,EAAG;AAC5E;"}
@@ -1,6 +1,6 @@
1
1
  import { jsxs as e, jsx as a } from "react/jsx-runtime";
2
2
  import { c as t } from "../../../../chunks/index.js";
3
- import { h as m } from "../../../../chunks/index2.js";
3
+ import { h as m } from "../../../../chunks/moment.js";
4
4
  import { registerComponent as c } from "../../../../registries/components.js";
5
5
  import { iconClass as r } from "../../../../utils/iconClass.js";
6
6
  import { stopPropagationWrapper as n } from "../../../../utils/stopPropagationWrapper.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/react-formio",
3
- "version": "3.0.0-rc.13",
3
+ "version": "3.0.0-rc.14",
4
4
  "description": "Provide a react formio wrapper. Written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@tanstack/react-table": ">=8.20.6",
47
- "@tsed/tailwind-formio": "3.0.0-rc.13",
48
- "@tsed/typescript": "3.0.0-rc.13",
47
+ "@tsed/tailwind-formio": "3.0.0-rc.14",
48
+ "@tsed/typescript": "3.0.0-rc.14",
49
49
  "microbundle": "0.13.0",
50
50
  "vite": "7.1.5",
51
51
  "vitest": "3.2.4"
package/src/all.ts CHANGED
@@ -25,6 +25,8 @@ import "./molecules/forms/input-tags/InputTags.interface";
25
25
  import "./molecules/table/components/DefaultFilter";
26
26
  import "./molecules/table/components/DefaultArrowSort";
27
27
  import "./molecules/table/components/DefaultCell";
28
+ import "./molecules/table/components/DefaultBooleanCell";
29
+ import "./molecules/table/components/DefaultDateCell";
28
30
  import "./molecules/table/components/DefaultCellOperations";
29
31
  import "./molecules/table/components/DefaultOperationButton";
30
32
  import "./molecules/table/components/DefaultCellHeader";
@@ -28,10 +28,6 @@ export interface SelectProps<Data = string> extends FormControlProps<Data, Selec
28
28
  searchEnabled?: boolean;
29
29
  customProperties?: Record<string, any>;
30
30
  options: (SelectOptionBaseProps<Data> | Omit<SelectOptionProps<Data>, "value">)[];
31
- /**
32
- * @deprecated
33
- */
34
- choices?: (SelectOptionBaseProps<Data> | Omit<SelectOptionProps<Data>, "value">)[];
35
31
  }
36
32
 
37
33
  export interface SelectSingle<Data = string> extends SelectProps<Data> {
@@ -1,6 +1,8 @@
1
1
  import "./components/DefaultFilter";
2
2
  import "./components/DefaultArrowSort";
3
3
  import "./components/DefaultCell";
4
+ import "./components/DefaultBooleanCell";
5
+ import "./components/DefaultDateCell";
4
6
  import "./components/DefaultCellOperations";
5
7
  import "./components/DefaultOperationButton";
6
8
  import "./components/DefaultCellHeader";
@@ -0,0 +1,42 @@
1
+ import { render, screen } from "@testing-library/react";
2
+
3
+ import { DefaultCellBoolean } from "./DefaultBooleanCell";
4
+
5
+ function createCellContext(value: boolean, labels?: Record<string, string>) {
6
+ return {
7
+ getValue: () => value,
8
+ column: {
9
+ columnDef: {
10
+ meta: {
11
+ labels
12
+ }
13
+ }
14
+ }
15
+ } as any;
16
+ }
17
+
18
+ describe("DefaultCellBoolean", () => {
19
+ it("should render the default yes label for true values", () => {
20
+ render(<DefaultCellBoolean {...createCellContext(true)} />);
21
+
22
+ expect(screen.getByText("Yes", { selector: "span" })).toBeInTheDocument();
23
+ });
24
+
25
+ it("should render the default no label for false values", () => {
26
+ render(<DefaultCellBoolean {...createCellContext(false)} />);
27
+
28
+ expect(screen.getByText("No", { selector: "span" })).toBeInTheDocument();
29
+ });
30
+
31
+ it("should render custom labels from column metadata", () => {
32
+ render(<DefaultCellBoolean {...createCellContext(true, { yes: "Enabled", No: "Disabled" })} />);
33
+
34
+ expect(screen.getByText("Enabled", { selector: "span" })).toBeInTheDocument();
35
+ });
36
+
37
+ it("should render the custom false label from column metadata", () => {
38
+ render(<DefaultCellBoolean {...createCellContext(false, { yes: "Enabled", No: "Disabled" })} />);
39
+
40
+ expect(screen.getByText("Disabled", { selector: "span" })).toBeInTheDocument();
41
+ });
42
+ });
@@ -0,0 +1,11 @@
1
+ import { CellContext } from "@tanstack/react-table";
2
+
3
+ import { registerComponent } from "../../../registries/components";
4
+
5
+ export function DefaultCellBoolean<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, boolean>) {
6
+ const value = getValue();
7
+ return <span>{String(value ? columnDef.meta?.labels?.["yes"] || "Yes" : columnDef.meta?.labels?.["No"] || "No")}</span>;
8
+ }
9
+
10
+ registerComponent("Cell.boolean", DefaultCellBoolean);
11
+ registerComponent("Cell.checkbox", DefaultCellBoolean);
@@ -18,4 +18,4 @@ export function DefaultCell<Data = any>({ getValue, renderValue }: CellContext<D
18
18
  }
19
19
 
20
20
  registerComponent("Cell", DefaultCell);
21
- registerComponent("Cell.text", DefaultCell);
21
+ registerComponent("Cell.string", DefaultCell);
@@ -0,0 +1,43 @@
1
+ import { render, screen } from "@testing-library/react";
2
+
3
+ import { DefaultDateCell } from "./DefaultDateCell";
4
+
5
+ function createCellContext(value: string | undefined, format?: string) {
6
+ return {
7
+ getValue: () => value,
8
+ column: {
9
+ columnDef: {
10
+ meta: {
11
+ format
12
+ }
13
+ }
14
+ }
15
+ } as any;
16
+ }
17
+
18
+ describe("DefaultDateCell", () => {
19
+ it("should render an empty span when value is undefined", () => {
20
+ render(<DefaultDateCell {...createCellContext(undefined)} />);
21
+
22
+ expect(screen.getByText("", { selector: "span" })).toBeInTheDocument();
23
+ expect(screen.queryByText(/.+/)).not.toBeInTheDocument();
24
+ });
25
+
26
+ it("should render the formatted date with the default format", () => {
27
+ render(<DefaultDateCell {...createCellContext("2026-03-12T10:30:00.000Z")} />);
28
+
29
+ expect(screen.getByText("03/12/2026", { selector: "span" })).toBeInTheDocument();
30
+ });
31
+
32
+ it("should render the formatted date with a custom format", () => {
33
+ render(<DefaultDateCell {...createCellContext("2026-03-12T10:30:00.000Z", "YYYY-MM-DD HH:mm")} />);
34
+
35
+ expect(screen.getByText("2026-03-12 10:30", { selector: "span" })).toBeInTheDocument();
36
+ });
37
+
38
+ it("should fallback to the raw value when the date is invalid", () => {
39
+ render(<DefaultDateCell {...createCellContext("not-a-date")} />);
40
+
41
+ expect(screen.getByText("not-a-date", { selector: "span" })).toBeInTheDocument();
42
+ });
43
+ });
@@ -0,0 +1,23 @@
1
+ import { CellContext } from "@tanstack/react-table";
2
+ import moment from "moment";
3
+
4
+ import { registerComponent } from "../../../registries/components";
5
+
6
+ export function DefaultDateCell<Data extends object>({ getValue, column: { columnDef } }: CellContext<Data, string>) {
7
+ const value = getValue();
8
+
9
+ if (!value) {
10
+ return <span />;
11
+ }
12
+
13
+ const date = moment.parseZone(value, moment.ISO_8601, true);
14
+
15
+ if (!date.isValid()) {
16
+ return <span>{String(value)}</span>;
17
+ }
18
+
19
+ return <span>{date.format(columnDef.meta?.format || "L")}</span>;
20
+ }
21
+
22
+ registerComponent("Cell.date", DefaultDateCell);
23
+ registerComponent("Cell.datetime", DefaultDateCell);
@@ -1,22 +1,21 @@
1
1
  import "../interfaces/extends";
2
2
 
3
- import { Header } from "@tanstack/react-table";
3
+ import { Header, RowData } from "@tanstack/react-table";
4
4
  import type { ComponentType } from "react";
5
5
 
6
6
  import { getComponent, registerComponent } from "../../../registries/components";
7
7
 
8
- export interface DefaultFilterProps<Data = any> {
9
- header: Header<Data, unknown>;
8
+ export interface DefaultFilterProps<Data extends RowData = any, TValue = unknown> {
9
+ header: Header<Data, TValue>;
10
10
  i18n?: (f: string) => string;
11
11
  }
12
12
 
13
- export interface FilterProps<Data = any, Opts = Record<string, unknown>> {
14
- header: Header<Data, unknown>;
13
+ export interface FilterProps<Data extends RowData = any, Opts = Record<string, unknown>> extends DefaultFilterProps<Data> {
15
14
  options: Opts;
16
- i18n?: (f: string) => string;
17
15
  }
18
16
 
19
- export function DefaultFilter<Data = any>({ header, i18n }: DefaultFilterProps<Data>) {
17
+ export function DefaultFilter<Data extends RowData = any, TValue = unknown>(props: DefaultFilterProps<Data, TValue>) {
18
+ const { header, i18n } = props;
20
19
  const {
21
20
  filter = {
22
21
  variant: "text"
@@ -32,6 +31,10 @@ export function DefaultFilter<Data = any>({ header, i18n }: DefaultFilterProps<D
32
31
  return null;
33
32
  }
34
33
 
34
+ if (filter.disabled) {
35
+ return null;
36
+ }
37
+
35
38
  return (
36
39
  <div className='table-cell-header__filter'>
37
40
  <Filter header={header} options={filter} i18n={i18n} />
@@ -8,6 +8,7 @@ export interface FilterBaseOptions extends Record<string, unknown> {
8
8
 
9
9
  export interface FilterTextOptions extends FilterBaseOptions {
10
10
  variant: "text";
11
+ disabled?: boolean;
11
12
  disableDatalist?: boolean;
12
13
  }
13
14
 
@@ -7,6 +7,9 @@ declare module "@tanstack/react-table" {
7
7
  //allows us to define custom properties for our columns
8
8
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
9
  interface ColumnMeta<TData extends RowData, TValue> {
10
+ type?: "string" | "number" | "boolean" | "date" | string;
11
+ format?: string;
12
+ labels?: Record<string, string>;
10
13
  filter?: FilterOptions;
11
14
  sort?: string;
12
15
  cellProps?: TdHTMLAttributes<HTMLTableCellElement>;
@@ -1,4 +1,5 @@
1
1
  import { DefaultCell } from "../components/DefaultCell";
2
+ import { DefaultDateCell } from "../components/DefaultDateCell";
2
3
  import { mapFormToColumns } from "./mapFormToColumns";
3
4
 
4
5
  describe("mapFormToColumns", () => {
@@ -32,4 +33,23 @@ describe("mapFormToColumns", () => {
32
33
  expect(column.accessorKey).toEqual("data.other");
33
34
  expect(column.cell).toBe(DefaultCell);
34
35
  });
36
+
37
+ it("should use DefaultDateCell for mapped datetime columns", () => {
38
+ const form = {
39
+ components: [
40
+ {
41
+ type: "datetime",
42
+ key: "createdAt",
43
+ label: "Created at:",
44
+ tableView: true
45
+ }
46
+ ]
47
+ } as any;
48
+
49
+ const [column] = mapFormToColumns(form) as any[];
50
+
51
+ expect(column.accessorKey).toEqual("data.createdAt");
52
+ expect(column.meta.type).toEqual("date");
53
+ expect(column.cell).toBe(DefaultDateCell);
54
+ });
35
55
  });