@tsed/react-formio 3.0.0-rc.11 → 3.0.0-rc.13
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/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 +4494 -4504
- package/dist/chunks/index2.js.map +1 -1
- 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/index.d.ts +0 -1
- package/dist/molecules/table/components/DefaultCell.d.ts +2 -5
- package/dist/molecules/table/components/DefaultCell.js +11 -9
- package/dist/molecules/table/components/DefaultCell.js.map +1 -1
- package/dist/molecules/table/filters/SelectFilter.js +8 -7
- package/dist/molecules/table/filters/SelectFilter.js.map +1 -1
- package/dist/molecules/table/utils/mapFormToColumns.js +21 -22
- package/dist/molecules/table/utils/mapFormToColumns.js.map +1 -1
- package/dist/organisms/form/actions/FormAction.js +5 -5
- package/package.json +3 -3
- package/src/interfaces/index.ts +0 -1
- package/src/molecules/table/components/DefaultCell.spec.tsx +32 -0
- package/src/molecules/table/components/DefaultCell.tsx +8 -9
- package/src/molecules/table/filters/SelectFilter.tsx +1 -0
- package/src/molecules/table/utils/mapFormToColumns.spec.tsx +35 -0
- package/src/molecules/table/utils/mapFormToColumns.tsx +2 -10
- package/src/organisms/form/Form.stories.tsx +7 -2
- package/dist/interfaces/QueryOptions.d.ts +0 -23
- package/dist/interfaces/QueryOptions.js +0 -2
- package/dist/interfaces/QueryOptions.js.map +0 -1
- package/src/interfaces/QueryOptions.ts +0 -24
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { a as q, b as p, c as T, d } from "./_baseClone.js";
|
|
2
|
+
var s, g;
|
|
3
|
+
function _() {
|
|
4
|
+
if (g) return s;
|
|
5
|
+
g = 1;
|
|
6
|
+
var t = q(), r = p(), n = "[object Symbol]";
|
|
7
|
+
function i(e) {
|
|
8
|
+
return typeof e == "symbol" || r(e) && t(e) == n;
|
|
9
|
+
}
|
|
10
|
+
return s = i, s;
|
|
11
|
+
}
|
|
12
|
+
var u, c;
|
|
13
|
+
function h() {
|
|
14
|
+
if (c) return u;
|
|
15
|
+
c = 1;
|
|
16
|
+
function t(r, n) {
|
|
17
|
+
for (var i = -1, e = r == null ? 0 : r.length, o = Array(e); ++i < e; )
|
|
18
|
+
o[i] = n(r[i], i, r);
|
|
19
|
+
return o;
|
|
20
|
+
}
|
|
21
|
+
return u = t, u;
|
|
22
|
+
}
|
|
23
|
+
var b, m;
|
|
24
|
+
function v() {
|
|
25
|
+
if (m) return b;
|
|
26
|
+
m = 1;
|
|
27
|
+
var t = T(), r = h(), n = d(), i = _(), e = t ? t.prototype : void 0, o = e ? e.toString : void 0;
|
|
28
|
+
function y(a) {
|
|
29
|
+
if (typeof a == "string")
|
|
30
|
+
return a;
|
|
31
|
+
if (n(a))
|
|
32
|
+
return r(a, y) + "";
|
|
33
|
+
if (i(a))
|
|
34
|
+
return o ? o.call(a) : "";
|
|
35
|
+
var S = a + "";
|
|
36
|
+
return S == "0" && 1 / a == -1 / 0 ? "-0" : S;
|
|
37
|
+
}
|
|
38
|
+
return b = y, b;
|
|
39
|
+
}
|
|
40
|
+
var f, l;
|
|
41
|
+
function M() {
|
|
42
|
+
if (l) return f;
|
|
43
|
+
l = 1;
|
|
44
|
+
var t = v();
|
|
45
|
+
function r(n) {
|
|
46
|
+
return n == null ? "" : t(n);
|
|
47
|
+
}
|
|
48
|
+
return f = r, f;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
M as a,
|
|
52
|
+
h as b,
|
|
53
|
+
v as c,
|
|
54
|
+
_ as r
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=toString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toString.js","sources":["../../../../node_modules/lodash/isSymbol.js","../../../../node_modules/lodash/_arrayMap.js","../../../../node_modules/lodash/_baseToString.js","../../../../node_modules/lodash/toString.js"],"sourcesContent":["var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array == null ? 0 : array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\nmodule.exports = arrayMap;\n","var Symbol = require('./_Symbol'),\n arrayMap = require('./_arrayMap'),\n isArray = require('./isArray'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar INFINITY = 1 / 0;\n\n/** Used to convert symbols to primitives and strings. */\nvar symbolProto = Symbol ? Symbol.prototype : undefined,\n symbolToString = symbolProto ? symbolProto.toString : undefined;\n\n/**\n * The base implementation of `_.toString` which doesn't convert nullish\n * values to empty strings.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\nfunction baseToString(value) {\n // Exit early for strings to avoid a performance hit in some environments.\n if (typeof value == 'string') {\n return value;\n }\n if (isArray(value)) {\n // Recursively convert values (susceptible to call stack limits).\n return arrayMap(value, baseToString) + '';\n }\n if (isSymbol(value)) {\n return symbolToString ? symbolToString.call(value) : '';\n }\n var result = (value + '');\n return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;\n}\n\nmodule.exports = baseToString;\n","var baseToString = require('./_baseToString');\n\n/**\n * Converts `value` to a string. An empty string is returned for `null`\n * and `undefined` values. The sign of `-0` is preserved.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n * @example\n *\n * _.toString(null);\n * // => ''\n *\n * _.toString(-0);\n * // => '-0'\n *\n * _.toString([1, 2, 3]);\n * // => '1,2,3'\n */\nfunction toString(value) {\n return value == null ? '' : baseToString(value);\n}\n\nmodule.exports = toString;\n"],"names":["baseGetTag","require$$0","isObjectLike","require$$1","symbolTag","isSymbol","value","isSymbol_1","arrayMap","array","iteratee","index","length","result","_arrayMap","Symbol","isArray","require$$2","require$$3","symbolProto","symbolToString","baseToString","_baseToString","toString","toString_1"],"mappings":";;;;;AAAA,MAAIA,IAAaC,EAAA,GACbC,IAAeC,EAAA,GAGfC,IAAY;AAmBhB,WAASC,EAASC,GAAO;AACvB,WAAO,OAAOA,KAAS,YACpBJ,EAAaI,CAAK,KAAKN,EAAWM,CAAK,KAAKF;AAAA,EACjD;AAEA,SAAAG,IAAiBF;;;;;;ACnBjB,WAASG,EAASC,GAAOC,GAAU;AAKjC,aAJIC,IAAQ,IACRC,IAASH,KAAS,OAAO,IAAIA,EAAM,QACnCI,IAAS,MAAMD,CAAM,GAElB,EAAED,IAAQC;AACf,MAAAC,EAAOF,CAAK,IAAID,EAASD,EAAME,CAAK,GAAGA,GAAOF,CAAK;AAErD,WAAOI;AAAA,EACT;AAEA,SAAAC,IAAiBN;;;;;;ACpBjB,MAAIO,IAASd,EAAA,GACTO,IAAWL,EAAA,GACXa,IAAUC,EAAA,GACVZ,IAAWa,EAAA,GAMXC,IAAcJ,IAASA,EAAO,YAAY,QAC1CK,IAAiBD,IAAcA,EAAY,WAAW;AAU1D,WAASE,EAAaf,GAAO;AAE3B,QAAI,OAAOA,KAAS;AAClB,aAAOA;AAET,QAAIU,EAAQV,CAAK;AAEf,aAAOE,EAASF,GAAOe,CAAY,IAAI;AAEzC,QAAIhB,EAASC,CAAK;AAChB,aAAOc,IAAiBA,EAAe,KAAKd,CAAK,IAAI;AAEvD,QAAIO,IAAUP,IAAQ;AACtB,WAAQO,KAAU,OAAQ,IAAIP,KAAU,SAAa,OAAOO;AAAA,EAC9D;AAEA,SAAAS,IAAiBD;;;;;;ACpCjB,MAAIA,IAAepB,EAAA;AAuBnB,WAASsB,EAASjB,GAAO;AACvB,WAAOA,KAAS,OAAO,KAAKe,EAAaf,CAAK;AAAA,EAChD;AAEA,SAAAkB,IAAiBD;;","x_google_ignoreList":[0,1,2,3]}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
render?: (value: Data) => any;
|
|
4
|
-
}
|
|
5
|
-
export declare function DefaultCell<Data = any>({ value, render }: DefaultCellProps<Data>): JSX.Element;
|
|
1
|
+
import { CellContext } from '@tanstack/react-table';
|
|
2
|
+
export declare function DefaultCell<Data = any>({ getValue, renderValue }: CellContext<Data, any>): JSX.Element;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { registerComponent as
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
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", {});
|
|
7
|
+
const r = i();
|
|
8
|
+
return r != null && e !== r ? /* @__PURE__ */ n("div", { dangerouslySetInnerHTML: { __html: String(r) } }) : /* @__PURE__ */ n("span", { children: String(e) });
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
t("Cell", l);
|
|
11
|
+
t("Cell.text", l);
|
|
10
12
|
export {
|
|
11
|
-
|
|
13
|
+
l as DefaultCell
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=DefaultCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCell.js","sources":["../../../../src/molecules/table/components/DefaultCell.tsx"],"sourcesContent":["import {
|
|
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,28 +1,29 @@
|
|
|
1
|
-
import { jsx as o, Fragment as
|
|
1
|
+
import { jsx as o, Fragment as s } from "react/jsx-runtime";
|
|
2
2
|
import { registerComponent as a, getComponent as p } from "../../../registries/components.js";
|
|
3
3
|
import { useUniqValues as f } from "../hooks/useUniqValues.js";
|
|
4
4
|
function F({ header: t, options: e }) {
|
|
5
|
-
const n = p("Select"), i = t.column.getFilterValue(), c = f({ header: t, filterVariant: "text" }),
|
|
5
|
+
const n = p("Select"), i = t.column.getFilterValue(), c = f({ header: t, filterVariant: "text" }), m = e.layout === "choicesjs" ? {
|
|
6
6
|
placeholder: void 0
|
|
7
7
|
} : {
|
|
8
8
|
placeholder: `Filter by ${t.column.columnDef.header}`
|
|
9
|
-
},
|
|
9
|
+
}, r = [
|
|
10
10
|
{
|
|
11
11
|
label: `Filter by ${t.column.columnDef.header}`,
|
|
12
12
|
value: ""
|
|
13
13
|
}
|
|
14
14
|
].concat(e.options || c.map((l) => ({ label: l, value: l })));
|
|
15
|
-
return /* @__PURE__ */ o(
|
|
15
|
+
return /* @__PURE__ */ o(s, { children: /* @__PURE__ */ o(
|
|
16
16
|
n,
|
|
17
17
|
{
|
|
18
18
|
size: "small",
|
|
19
19
|
...e,
|
|
20
|
-
...
|
|
21
|
-
|
|
20
|
+
...m,
|
|
21
|
+
autoComplete: "off",
|
|
22
|
+
options: r,
|
|
22
23
|
name: `filter_${t.column.id}`,
|
|
23
24
|
"data-testid": `filter_${t.column.id}`,
|
|
24
25
|
value: i,
|
|
25
|
-
onChange: (l,
|
|
26
|
+
onChange: (l, u) => t.column.setFilterValue(u)
|
|
26
27
|
}
|
|
27
28
|
) });
|
|
28
29
|
}
|
|
@@ -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, 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 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);\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,cAAa;AAAA,MACb,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,39 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const k = /* @__PURE__ */ x(y), v = {
|
|
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";
|
|
5
|
+
import { getComponent as d } from "../../../registries/components.js";
|
|
6
|
+
var C = f();
|
|
7
|
+
const g = /* @__PURE__ */ i(C), x = {
|
|
9
8
|
number: "range",
|
|
10
9
|
currency: "range",
|
|
11
10
|
checkbox: "boolean"
|
|
12
11
|
};
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return
|
|
16
|
-
const t = e,
|
|
17
|
-
let
|
|
18
|
-
return
|
|
12
|
+
function h(a, l = []) {
|
|
13
|
+
const c = p(), o = u(l), n = d("Cell");
|
|
14
|
+
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}`, {
|
|
19
18
|
header: (t.label || t.title || t.key)?.replace(/:/, ""),
|
|
20
|
-
cell:
|
|
19
|
+
cell: n,
|
|
21
20
|
meta: {
|
|
22
|
-
filter: { variant:
|
|
23
|
-
...
|
|
21
|
+
filter: { variant: x[t.type] || "text" },
|
|
22
|
+
...r?.meta || {}
|
|
24
23
|
},
|
|
25
|
-
...
|
|
24
|
+
...r || {}
|
|
26
25
|
});
|
|
27
|
-
}).concat(
|
|
26
|
+
}).concat(o).map((e, t) => ({
|
|
28
27
|
...e,
|
|
29
28
|
meta: {
|
|
30
29
|
...e.meta || {},
|
|
31
|
-
order:
|
|
30
|
+
order: g(e, "meta.order", t * 10)
|
|
32
31
|
},
|
|
33
|
-
cell: e.cell ||
|
|
32
|
+
cell: e.cell || n
|
|
34
33
|
})).sort((e, t) => e.meta.order > t.meta.order ? 1 : -1);
|
|
35
34
|
}
|
|
36
35
|
export {
|
|
37
|
-
|
|
36
|
+
h as mapFormToColumns
|
|
38
37
|
};
|
|
39
38
|
//# 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.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,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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/react-formio",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.13",
|
|
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.
|
|
48
|
-
"@tsed/typescript": "3.0.0-rc.
|
|
47
|
+
"@tsed/tailwind-formio": "3.0.0-rc.13",
|
|
48
|
+
"@tsed/typescript": "3.0.0-rc.13",
|
|
49
49
|
"microbundle": "0.13.0",
|
|
50
50
|
"vite": "7.1.5",
|
|
51
51
|
"vitest": "3.2.4"
|
package/src/interfaces/index.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
|
|
3
|
+
import { DefaultCell } from "./DefaultCell";
|
|
4
|
+
|
|
5
|
+
function createCellContext(value: unknown, rendered: unknown) {
|
|
6
|
+
return {
|
|
7
|
+
getValue: () => value,
|
|
8
|
+
renderValue: () => rendered
|
|
9
|
+
} as any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe("DefaultCell", () => {
|
|
13
|
+
it("should render an empty span when value is undefined", () => {
|
|
14
|
+
render(<DefaultCell {...createCellContext(undefined, undefined)} />);
|
|
15
|
+
|
|
16
|
+
expect(screen.getByText("", { selector: "span" })).toBeInTheDocument();
|
|
17
|
+
expect(screen.queryByText(/.+/)).not.toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should render html when rendered value differs from raw value", () => {
|
|
21
|
+
render(<DefaultCell {...createCellContext("hello", "<strong>hello</strong>")} />);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByText("hello", { selector: "strong" })).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should render text when rendered value matches raw value", () => {
|
|
27
|
+
render(<DefaultCell {...createCellContext("hello", "hello")} />);
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText("hello", { selector: "span" })).toBeInTheDocument();
|
|
30
|
+
expect(screen.queryByText("hello", { selector: "strong" })).not.toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CellContext } from "@tanstack/react-table";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: Data;
|
|
5
|
-
render?: (value: Data) => any;
|
|
6
|
-
}
|
|
3
|
+
import { registerComponent } from "../../../registries/components";
|
|
7
4
|
|
|
8
|
-
export function DefaultCell<Data = any>({
|
|
5
|
+
export function DefaultCell<Data = any>({ getValue, renderValue }: CellContext<Data, any>): JSX.Element {
|
|
6
|
+
const value = getValue();
|
|
9
7
|
if (value === undefined) {
|
|
10
8
|
return <span></span>;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
const rendered =
|
|
11
|
+
const rendered = renderValue();
|
|
14
12
|
|
|
15
|
-
if (value !== rendered) {
|
|
16
|
-
return <div dangerouslySetInnerHTML={{ __html: rendered }} />;
|
|
13
|
+
if (rendered != null && value !== rendered) {
|
|
14
|
+
return <div dangerouslySetInnerHTML={{ __html: String(rendered) }} />;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
return <span>{String(value)}</span>;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
registerComponent("Cell", DefaultCell);
|
|
21
|
+
registerComponent("Cell.text", DefaultCell);
|
|
@@ -34,6 +34,7 @@ export function SelectFilter<Data = any>({ header, options }: FilterProps<Data,
|
|
|
34
34
|
size='small'
|
|
35
35
|
{...(options as any)}
|
|
36
36
|
{...opts}
|
|
37
|
+
autoComplete='off'
|
|
37
38
|
options={listOptions}
|
|
38
39
|
name={`filter_${header.column.id}`}
|
|
39
40
|
data-testid={`filter_${header.column.id}`}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DefaultCell } from "../components/DefaultCell";
|
|
2
|
+
import { mapFormToColumns } from "./mapFormToColumns";
|
|
3
|
+
|
|
4
|
+
describe("mapFormToColumns", () => {
|
|
5
|
+
it("should use DefaultCell for mapped table columns", () => {
|
|
6
|
+
const form = {
|
|
7
|
+
components: [
|
|
8
|
+
{
|
|
9
|
+
type: "checkbox",
|
|
10
|
+
key: "enabled",
|
|
11
|
+
label: "Enabled:",
|
|
12
|
+
tableView: true
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
} as any;
|
|
16
|
+
|
|
17
|
+
const [column] = mapFormToColumns(form) as any[];
|
|
18
|
+
|
|
19
|
+
expect(column.accessorKey).toEqual("data.enabled");
|
|
20
|
+
expect(column.header).toEqual("Enabled");
|
|
21
|
+
expect(column.meta.filter.variant).toEqual("boolean");
|
|
22
|
+
expect(column.cell).toBe(DefaultCell);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should fallback to DefaultCell for kept columns without a cell renderer", () => {
|
|
26
|
+
const form = {
|
|
27
|
+
components: []
|
|
28
|
+
} as any;
|
|
29
|
+
|
|
30
|
+
const [column] = mapFormToColumns(form, [{ accessorKey: "data.other", header: "Other" } as any]) as any[];
|
|
31
|
+
|
|
32
|
+
expect(column.accessorKey).toEqual("data.other");
|
|
33
|
+
expect(column.cell).toBe(DefaultCell);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "../interfaces/extends";
|
|
2
2
|
|
|
3
|
-
import { Components } from "@formio/js";
|
|
4
3
|
import { ColumnDef, ColumnDefResolved, createColumnHelper } from "@tanstack/react-table";
|
|
5
4
|
import cloneDeep from "lodash/cloneDeep";
|
|
6
5
|
import get from "lodash/get";
|
|
@@ -33,7 +32,6 @@ export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefR
|
|
|
33
32
|
.filter((component) => component?.tableView)
|
|
34
33
|
.map((c) => {
|
|
35
34
|
const component = c as ComponentType;
|
|
36
|
-
const cmp: any = Components.create(component, {}, null);
|
|
37
35
|
|
|
38
36
|
const columnIndex = columnsToKeep.findIndex(({ accessorKey }) => {
|
|
39
37
|
return accessorKey === `data.${component.key}`;
|
|
@@ -47,9 +45,7 @@ export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefR
|
|
|
47
45
|
|
|
48
46
|
return columnHelper.accessor(`data.${component.key}` as any, {
|
|
49
47
|
header: (component.label || component.title || component.key)?.replace(/:/, ""),
|
|
50
|
-
cell:
|
|
51
|
-
return <Cell value={info.getValue() as Data} render={(value: Data) => cmp.asString(value)} />;
|
|
52
|
-
},
|
|
48
|
+
cell: Cell,
|
|
53
49
|
meta: {
|
|
54
50
|
filter: { variant: MAP_TYPES[component.type!] || "text" },
|
|
55
51
|
...(column?.meta || {})
|
|
@@ -64,11 +60,7 @@ export function mapFormToColumns<Data = any>(form: FormType, columns: ColumnDefR
|
|
|
64
60
|
...(column.meta || {}),
|
|
65
61
|
order: get(column, "meta.order", index * 10)
|
|
66
62
|
},
|
|
67
|
-
cell:
|
|
68
|
-
column.cell ||
|
|
69
|
-
((info) => {
|
|
70
|
-
return <Cell value={info.getValue() as Data} render={(value: Data) => value} />;
|
|
71
|
-
})
|
|
63
|
+
cell: column.cell || Cell
|
|
72
64
|
}));
|
|
73
65
|
|
|
74
66
|
return mergedColumns.sort((a, b) => (a.meta.order > b.meta.order ? 1 : -1)) as ColumnDef<Data, any>[];
|
|
@@ -260,12 +260,17 @@ export const WithSubmissionData: Story = {
|
|
|
260
260
|
*/
|
|
261
261
|
export const WithOnSubmit: Story = {
|
|
262
262
|
render(args) {
|
|
263
|
+
type OnSubmitData = {
|
|
264
|
+
firstName?: string;
|
|
265
|
+
[key: string]: unknown;
|
|
266
|
+
};
|
|
267
|
+
|
|
263
268
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
264
|
-
const [data, setData] = useState(() => args.submission!.data);
|
|
269
|
+
const [data, setData] = useState<OnSubmitData>(() => args.submission!.data as OnSubmitData);
|
|
265
270
|
|
|
266
271
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
267
272
|
useEffect(() => {
|
|
268
|
-
setData(args.submission!.data);
|
|
273
|
+
setData(args.submission!.data as OnSubmitData);
|
|
269
274
|
}, [args.submission]);
|
|
270
275
|
|
|
271
276
|
return (
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ColumnIdentifier } from './ColumnIdentifier';
|
|
2
|
-
export type QueryOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* Current displayed page
|
|
5
|
-
*/
|
|
6
|
-
pageIndex: any;
|
|
7
|
-
/**
|
|
8
|
-
* Pagination size
|
|
9
|
-
*/
|
|
10
|
-
pageSize: any;
|
|
11
|
-
/**
|
|
12
|
-
* SortBy state
|
|
13
|
-
*/
|
|
14
|
-
sortBy: ColumnIdentifier[];
|
|
15
|
-
/**
|
|
16
|
-
* Filters state
|
|
17
|
-
*/
|
|
18
|
-
filters: ColumnIdentifier[];
|
|
19
|
-
/**
|
|
20
|
-
* Focused input filter (let the Table component retrieve focus state when we fill the filter)
|
|
21
|
-
*/
|
|
22
|
-
filterId: string;
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryOptions.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ColumnIdentifier } from "./ColumnIdentifier";
|
|
2
|
-
|
|
3
|
-
export type QueryOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Current displayed page
|
|
6
|
-
*/
|
|
7
|
-
pageIndex: any;
|
|
8
|
-
/**
|
|
9
|
-
* Pagination size
|
|
10
|
-
*/
|
|
11
|
-
pageSize: any;
|
|
12
|
-
/**
|
|
13
|
-
* SortBy state
|
|
14
|
-
*/
|
|
15
|
-
sortBy: ColumnIdentifier[];
|
|
16
|
-
/**
|
|
17
|
-
* Filters state
|
|
18
|
-
*/
|
|
19
|
-
filters: ColumnIdentifier[];
|
|
20
|
-
/**
|
|
21
|
-
* Focused input filter (let the Table component retrieve focus state when we fill the filter)
|
|
22
|
-
*/
|
|
23
|
-
filterId: string;
|
|
24
|
-
};
|