@tsed/react-formio 3.0.0-rc.2 → 3.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +2 -0
- package/dist/all.js.map +1 -1
- package/dist/chunks/_baseGet.js +102 -0
- package/dist/chunks/_baseGet.js.map +1 -0
- package/dist/chunks/_baseSlice.js +12 -65
- package/dist/chunks/_baseSlice.js.map +1 -1
- package/dist/chunks/camelCase.js +1 -1
- package/dist/chunks/get.js +16 -0
- package/dist/chunks/get.js.map +1 -0
- package/dist/chunks/index2.js +19746 -22285
- package/dist/chunks/index2.js.map +1 -1
- package/dist/chunks/moment.js +2535 -0
- package/dist/chunks/moment.js.map +1 -0
- package/dist/chunks/omit.js +173 -268
- package/dist/chunks/omit.js.map +1 -1
- package/dist/chunks/toString.js +56 -0
- package/dist/chunks/toString.js.map +1 -0
- package/dist/interfaces/JSONRecord.d.ts +4 -0
- package/dist/interfaces/JSONRecord.js +2 -0
- package/dist/interfaces/JSONRecord.js.map +1 -0
- package/dist/interfaces/Operation.d.ts +3 -12
- package/dist/interfaces/SubmissionType.d.ts +4 -14
- package/dist/interfaces/index.d.ts +0 -1
- package/dist/molecules/forms/select/Select.interface.d.ts +0 -4
- package/dist/molecules/table/Table.d.ts +4 -12
- package/dist/molecules/table/Table.js +34 -33
- package/dist/molecules/table/Table.js.map +1 -1
- package/dist/molecules/table/all.js +2 -0
- package/dist/molecules/table/all.js.map +1 -1
- package/dist/molecules/table/components/DefaultBooleanCell.d.ts +2 -0
- package/dist/molecules/table/components/DefaultBooleanCell.js +12 -0
- package/dist/molecules/table/components/DefaultBooleanCell.js.map +1 -0
- package/dist/molecules/table/components/DefaultCell.d.ts +2 -5
- package/dist/molecules/table/components/DefaultCell.js +8 -6
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/components/DefaultCellOperations.d.ts +4 -11
- package/dist/molecules/table/components/DefaultCellOperations.js.map +1 -1
- package/dist/molecules/table/components/DefaultDateCell.d.ts +2 -0
- package/dist/molecules/table/components/DefaultDateCell.js +16 -0
- package/dist/molecules/table/components/DefaultDateCell.js.map +1 -0
- package/dist/molecules/table/components/DefaultFilter.d.ts +5 -7
- package/dist/molecules/table/components/DefaultFilter.js +8 -8
- package/dist/molecules/table/components/DefaultFilter.js.map +1 -1
- package/dist/molecules/table/components/DefaultOperationButton.d.ts +4 -11
- package/dist/molecules/table/components/DefaultOperationButton.js.map +1 -1
- package/dist/molecules/table/filters/Filters.d.ts +27 -0
- package/dist/molecules/table/filters/Filters.js +2 -0
- package/dist/molecules/table/filters/Filters.js.map +1 -0
- package/dist/molecules/table/filters/SelectFilter.js +22 -20
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/filters/TextFieldFilter.js +16 -16
- package/dist/molecules/table/filters/TextFieldFilter.js.map +1 -1
- package/dist/molecules/table/hooks/useTable.d.ts +4 -11
- package/dist/molecules/table/hooks/useTable.js +14 -14
- package/dist/molecules/table/hooks/useTable.js.map +1 -1
- package/dist/molecules/table/hooks/useUniqValues.d.ts +4 -5
- package/dist/molecules/table/hooks/useUniqValues.js +23 -7
- package/dist/molecules/table/hooks/useUniqValues.js.map +1 -1
- package/dist/molecules/table/interfaces/extends.d.ts +3 -0
- package/dist/molecules/table/utils/mapFormToColumns.d.ts +5 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +53 -26
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/organisms/form/Form.d.ts +3 -11
- package/dist/organisms/form/Form.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +5 -5
- package/dist/organisms/form/types.d.ts +1 -9
- package/dist/organisms/form/useForm.d.ts +4 -11
- package/dist/organisms/form/useForm.js.map +1 -1
- package/dist/organisms/table/forms/components/FormsCell.js +1 -1
- package/dist/organisms/table/submissions/SubmissionsTable.d.ts +4 -11
- package/dist/organisms/table/submissions/SubmissionsTable.js +2 -5
- package/dist/organisms/table/submissions/SubmissionsTable.js.map +1 -1
- package/dist/organisms/views/FormViews.d.ts +4 -11
- package/dist/organisms/views/FormViews.js.map +1 -1
- package/package.json +3 -3
- package/src/all.ts +2 -0
- package/src/interfaces/JSONRecord.ts +2 -0
- package/src/interfaces/Operation.ts +3 -6
- package/src/interfaces/SubmissionType.ts +4 -8
- package/src/interfaces/index.ts +0 -1
- package/src/molecules/forms/select/Select.interface.ts +0 -4
- package/src/molecules/table/Table.stories.tsx +101 -66
- package/src/molecules/table/Table.tsx +57 -56
- package/src/molecules/table/all.ts +2 -0
- package/src/molecules/table/components/DefaultBooleanCell.spec.tsx +42 -0
- package/src/molecules/table/components/DefaultBooleanCell.tsx +11 -0
- package/src/molecules/table/components/DefaultCell.spec.tsx +32 -0
- package/src/molecules/table/components/DefaultCell.tsx +8 -9
- package/src/molecules/table/components/DefaultCellOperations.tsx +4 -3
- package/src/molecules/table/components/DefaultDateCell.spec.tsx +43 -0
- package/src/molecules/table/components/DefaultDateCell.tsx +23 -0
- package/src/molecules/table/components/DefaultFilter.tsx +10 -7
- package/src/molecules/table/components/DefaultOperationButton.tsx +4 -4
- package/src/molecules/table/filters/{Filters.d.ts → Filters.ts} +7 -3
- package/src/molecules/table/filters/SelectFilter.tsx +5 -3
- package/src/molecules/table/filters/TextFieldFilter.tsx +5 -3
- package/src/molecules/table/hooks/useTable.tsx +8 -13
- package/src/molecules/table/hooks/useUniqValues.spec.tsx +82 -0
- package/src/molecules/table/hooks/useUniqValues.tsx +38 -6
- package/src/molecules/table/interfaces/extends.ts +3 -0
- package/src/molecules/table/utils/mapFormToColumns.spec.tsx +116 -0
- package/src/molecules/table/utils/mapFormToColumns.tsx +67 -27
- package/src/organisms/form/Form.stories.tsx +7 -2
- package/src/organisms/form/Form.tsx +3 -3
- package/src/organisms/form/types.ts +1 -6
- package/src/organisms/form/useForm.ts +6 -5
- package/src/organisms/table/submissions/SubmissionsTable.tsx +5 -10
- package/src/organisms/views/FormViews.tsx +6 -9
- package/dist/interfaces/QueryOptions.d.ts +0 -23
- package/dist/interfaces/QueryOptions.js +0 -2
- package/dist/interfaces/QueryOptions.js.map +0 -1
- package/dist/molecules/table/filters/Filters.d.js +0 -2
- package/dist/molecules/table/filters/Filters.d.js.map +0 -1
- package/src/interfaces/QueryOptions.ts +0 -24
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { registerComponent as
|
|
3
|
-
import { useUniqValues as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
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 ${
|
|
9
|
-
},
|
|
8
|
+
placeholder: `Filter by ${e.column.columnDef.header}`
|
|
9
|
+
}, r = [
|
|
10
10
|
{
|
|
11
|
-
label: `Filter by ${
|
|
11
|
+
label: `Filter by ${e.column.columnDef.header}`,
|
|
12
12
|
value: ""
|
|
13
13
|
}
|
|
14
|
-
].concat(
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
|
|
14
|
+
].concat(u);
|
|
15
|
+
return /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(
|
|
16
|
+
c,
|
|
17
17
|
{
|
|
18
18
|
size: "small",
|
|
19
|
-
...
|
|
20
|
-
...
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
30
|
+
o("Filter.select", n);
|
|
31
|
+
o("Filter.boolean", n);
|
|
30
32
|
export {
|
|
31
|
-
|
|
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,
|
|
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
|
|
2
|
-
import { registerComponent as
|
|
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
|
|
5
|
-
const o = d("InputText"),
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
!
|
|
8
|
-
/* @__PURE__ */
|
|
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 ${
|
|
13
|
-
...
|
|
14
|
-
name: `filter_${
|
|
15
|
-
"data-testid": `filter_${
|
|
16
|
-
value:
|
|
17
|
-
list:
|
|
18
|
-
onChange: (
|
|
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
|
-
|
|
23
|
+
m("Filter.text", F);
|
|
24
24
|
export {
|
|
25
|
-
|
|
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
|
|
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,
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
2
|
-
import { useReactTable as
|
|
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
|
|
6
|
-
function
|
|
7
|
-
const n =
|
|
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: (
|
|
11
|
+
cell: (R) => /* @__PURE__ */ w(n, { info: R, operations: e.operations, metadata: e.metadata, onClick: e.onClick, i18n: t })
|
|
12
12
|
}
|
|
13
|
-
] : [], o =
|
|
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 :
|
|
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 :
|
|
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:
|
|
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,
|
|
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
|
-
|
|
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
|
|
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,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}): any[];
|
|
1
|
+
import { SelectOptionProps } from '../../../molecules/forms/select/Select.interface';
|
|
2
|
+
import { FilterProps } from '../components/DefaultFilter';
|
|
3
|
+
import { FilterSelectOptions } from '../filters/Filters';
|
|
4
|
+
export declare function useUniqValues<Data = any>({ header, options }: FilterProps<Data, FilterSelectOptions>): SelectOptionProps[];
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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 {
|
|
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\nexport function useUniqValues<Data = any>({ header, options }: FilterProps<Data, FilterSelectOptions>): 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":";AAMO,SAASA,EAA0B,EAAE,QAAAC,GAAQ,SAAAC,KAAwE;AAC1H,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
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
8
|
-
const
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
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
|
-
...
|
|
46
|
+
...s || {}
|
|
26
47
|
});
|
|
27
|
-
}).
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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 {
|
|
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\";\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 {
|
|
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 {
|
|
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 {
|
|
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:
|
|
22
|
-
const
|
|
23
|
-
return { form: b(t.settingsForm), submission: { data:
|
|
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:
|
|
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
|
|
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,
|
|
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
|
};
|