@ghentcdh/json-forms-core 0.6.6 → 0.6.8
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/index.cjs +1 -1
- package/index.d.ts +1 -1
- package/index.js +133 -89
- package/lib/{schema.model.d.ts → create-schema.d.ts} +4 -2
- package/lib/layout/control.builder.d.ts +15 -4
- package/lib/layout/layout.builder.d.ts +13 -4
- package/package.json +1 -3
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("zod");var z=(e=>(e.xs="xs",e.sm="sm",e.lg="lg",e.xl="xl",e))(z||{});const j=e=>{const t=e.anyOf;if(!Array.isArray(t)||t.length!==2)return;const s=t.find(o=>o.type!=="null"),r=t.some(o=>o.type==="null");s&&r&&(delete e.anyOf,Object.assign(e,s))},C=e=>{const t=i.toJSONSchema(e,{unrepresentable:"any",target:"draft-07"});t.additionalProperties=!0;const s=t.properties;if(s)for(const r of Object.keys(s))j(s[r]);return t},P=e=>{if(!e.schema)throw new Error("no schema provided");const t=e.schema,s=e.dtoSchema,r=C(s),o=C(t.partial());return{dtoSchema:s,responseSchema:e.responseSchema??s,schema:{form:{uiSchema:e.uiSchema,schema:r,modalSize:e.modalSize??"sm"},table:e.tableSchema?{uiSchema:e.tableSchema,schema:o}:void 0,filter:e.filterSchema?{uiSchema:e.filterSchema,schema:o}:void 0,uri:e.uri,searchUri:e.searchUri??`${e.uri}?filter=`}}},L=(e,t)=>{if(!e.scope)return{id:null,property:null};const s=e.scope?.substring(13),r=t?.properties?.[s]??{};return{id:s,property:r}},k=(e,t)=>{const{id:s,property:r}=L(e,t);return{...e,id:s,label:s,...r}};class p{constructor(t){this.type=t}}class m extends p{constructor(){super(...arguments),this.elements=[]}addControl(t){return this.elements.push(t),this}addControls(...t){return this.elements.push(...t),this}buildElements(){return this.elements.map(t=>t.build())}}const h={HorizontalLayout:"HorizontalLayout",VerticalLayout:"VerticalLayout",CollapseLayout:"CollapseLayout"};class a extends m{constructor(t,s={}){super(t),this.options=s}static horizontal(){return new a(h.HorizontalLayout)}static collapse(){return new a(h.CollapseLayout)}static vertical(){return new a(h.VerticalLayout)}titleKey(t){return this.addOptions({titleKey:t})}title(t){return this.addOptions({title:t})}addOptions(t){return this.options={...this.options,...t},this}build(){return{type:this.type,elements:this.buildElements(),options:this.options}}}class f extends p{constructor(t,s="TextCell"){super(s),this.scope=t}static properties(t){return new f(`#/properties/${t}`)}key(t){return this.options={format:"keyValue",key:t},this}setSortId(t){return this.options={...this.options??{format:"TextCell"},sortId:t},this}build(){return{type:this.type,scope:this.scope,options:this.options}}}class y{constructor(){this.builder=a.horizontal()}static init(){return new y}addControl(t){return this.builder.addControls(t),this}addControls(...t){return this.builder.addControls(...t),this}build(){return this.builder.build()}}const n={number:"number",string:"string",integer:"Integer",autocomplete:"autocomplete",textArea:"textArea",markdown:"markdown",array:"array",custom:"custom"};class l extends p{constructor(t,s="Control"){super(s),this.scope=t,this.options={format:"Control",styles:{control:{wrapper:"w-full"}}}}static asObject(t){return new l(`#/properties/${t}`,"Object")}static properties(t){return new l(`#/properties/${t}`)}static asCustom(t,s){const r=new l(`#/properties/${t}`);return r.options={format:n.custom,type:s},r}detail(t,s){return this._detail=t,this.options={...this.options??{},format:n.array,elementLabelProp:s},this}addAction(t){const s=this.options?.actions??[];return s.push(t),this.options={...this.options??{},actions:s},this}detailFixed(t,s={}){return this._detail=t,this.options={...this.options??{},hideActions:!0,format:n.array,layout:s.layout??"column",elementLabelProp:s.label},this}labelKey(t){return this.options={...this.options??{},labelKey:t},this}readonly(){return this.options={format:n.string,readonly:!0},this}markdown(){return this.options={format:n.markdown},this}textArea(t){return this.options={format:n.textArea,...t??{}},this}autocomplete(t){return this.options={format:n.autocomplete,dataField:"data",...t},this}width(t){const s={xs:"w-12",sm:"w-24",md:"w-36",lg:"w-48",xl:"w-64",full:"w-full"};return this.addOptions({styles:{...this.options?.styles,control:{wrapper:` ${s[t]??s.sm}`}}})}customLabel(t){return this.addOptions({label:t})}placeHolder(t){return this.addOptions({placeholder:t})}hideLabel(){return this.addOptions({hideLabel:!0})}addOptions(t){return this.options={...this.options,...t},this}build(){return{type:this.type,scope:this.scope,options:{...this.options,detail:this._detail?this._detail?.build():void 0}}}}class b extends m{constructor(t){super(t),this.label=t,this.rule={effect:"SHOW",condition:{}}}static label(t){return new b(t)}build(){return{type:"Category",label:this.label,rule:this.rule,elements:this.buildElements()}}}class S extends m{constructor(t){super(t),this.label=t}static label(t){return new S(t)}build(){return{type:"Group",label:this.label,elements:this.buildElements()}}}const u=()=>i.z.coerce.number().int().positive().nonnegative(),v=()=>i.z.string().or(i.z.array(i.z.string())).transform(e=>Array.isArray(e)?e:[e]),A=i.z.enum(["asc","desc"]),g=i.z.object({page:u().optional().default(1),pageSize:u().optional().default(20),sort:i.z.string().optional().default("id"),sortDir:A.optional().default("asc"),filter:v().optional().default([])}),F=g.transform(e=>{const{page:t,pageSize:s,sort:r}=e;return{...e,sort:r||"id",offset:(t-1)*s}}),R=g.extend({count:u(),totalPages:u()}),K=i.z.object({data:i.z.array(i.z.unknown()),request:R}),q=["contains","equals"],E=e=>{const[t,s,r]=e.split(":"),o=q.includes(r)?r:"contains";return{key:t,value:s,operator:o}},T=(e,t)=>{if(e.length===1)return{key:e[0],filterObj:t};const s=e.pop();return T(e,{[s]:t})},N=(e,t)=>w(e.split("."),t),w=(e,t)=>{if(e.length===1)return{[e[0]]:t};const s=e.pop();return w(e,{[s]:t})},$=e=>{const t={};return e?.forEach(s=>{const{key:r,value:o,operator:c}=E(s);if(!r)return;const d=c||"contains",O={[c||"contains"]:o.toLowerCase()};d==="contains"&&(O.mode="insensitive");const x=T(r.split("."),O);t[x.key]=x.filterObj}),t},H=e=>{const t=[];return e.forEach(s=>{const{key:r,value:o,operator:c}=E(s);if(!r)return;const d=r;t.push({label:d,key:r,value:o,operator:c})}),t};exports.CategoryBuilder=b;exports.ControlBuilder=l;exports.ControlType=n;exports.GroupBuilder=S;exports.LayoutBuilder=a;exports.LayoutTypes=h;exports.Operator=q;exports.PositiveRequestNumber=u;exports.RequestSchema=g;exports.RequestSchemaWithOffset=F;exports.ResponseRequestSchema=R;exports.ResponseSchema=K;exports.Size=z;exports.SortDirEnum=A;exports.StringOrArray=v;exports.TableBuilder=y;exports.TextCellBuilder=f;exports.buildFilter=$;exports.buildSort=N;exports.buildSortKey=w;exports.createSchema=P;exports.extractFilters=H;exports.findColumnDef=k;exports.findProperty=L;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import { toJSONSchema as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { toJSONSchema as v, z as n } from "zod";
|
|
2
|
+
var E = /* @__PURE__ */ ((e) => (e.xs = "xs", e.sm = "sm", e.lg = "lg", e.xl = "xl", e))(E || {});
|
|
3
|
+
const j = (e) => {
|
|
4
|
+
const t = e.anyOf;
|
|
5
|
+
if (!Array.isArray(t) || t.length !== 2) return;
|
|
6
|
+
const s = t.find(
|
|
7
|
+
(o) => o.type !== "null"
|
|
8
|
+
), r = t.some(
|
|
9
|
+
(o) => o.type === "null"
|
|
10
|
+
);
|
|
11
|
+
s && r && (delete e.anyOf, Object.assign(e, s));
|
|
12
|
+
}, y = (e) => {
|
|
13
|
+
const t = v(e, {
|
|
14
|
+
unrepresentable: "any",
|
|
15
|
+
target: "draft-07"
|
|
16
|
+
});
|
|
17
|
+
t.additionalProperties = !0;
|
|
18
|
+
const s = t.properties;
|
|
19
|
+
if (s)
|
|
20
|
+
for (const r of Object.keys(s))
|
|
21
|
+
j(s[r]);
|
|
22
|
+
return t;
|
|
23
|
+
}, R = (e) => {
|
|
8
24
|
if (!e.schema)
|
|
9
25
|
throw new Error("no schema provided");
|
|
10
|
-
const t = e.schema, s = e.dtoSchema, r =
|
|
26
|
+
const t = e.schema, s = e.dtoSchema, r = y(s), o = y(t.partial());
|
|
11
27
|
return {
|
|
12
28
|
dtoSchema: s,
|
|
13
29
|
responseSchema: e.responseSchema ?? s,
|
|
@@ -19,11 +35,11 @@ const b = (e) => E(e, {
|
|
|
19
35
|
},
|
|
20
36
|
table: e.tableSchema ? {
|
|
21
37
|
uiSchema: e.tableSchema,
|
|
22
|
-
schema:
|
|
38
|
+
schema: o
|
|
23
39
|
} : void 0,
|
|
24
40
|
filter: e.filterSchema ? {
|
|
25
41
|
uiSchema: e.filterSchema,
|
|
26
|
-
schema:
|
|
42
|
+
schema: o
|
|
27
43
|
} : void 0,
|
|
28
44
|
uri: e.uri,
|
|
29
45
|
searchUri: e.searchUri ?? `${e.uri}?filter=`
|
|
@@ -34,16 +50,16 @@ const b = (e) => E(e, {
|
|
|
34
50
|
return { id: null, property: null };
|
|
35
51
|
const s = e.scope?.substring(13), r = t?.properties?.[s] ?? {};
|
|
36
52
|
return { id: s, property: r };
|
|
37
|
-
},
|
|
53
|
+
}, $ = (e, t) => {
|
|
38
54
|
const { id: s, property: r } = k(e, t);
|
|
39
55
|
return { ...e, id: s, label: s, ...r };
|
|
40
56
|
};
|
|
41
|
-
class
|
|
57
|
+
class d {
|
|
42
58
|
constructor(t) {
|
|
43
59
|
this.type = t;
|
|
44
60
|
}
|
|
45
61
|
}
|
|
46
|
-
class
|
|
62
|
+
class m extends d {
|
|
47
63
|
constructor() {
|
|
48
64
|
super(...arguments), this.elements = [];
|
|
49
65
|
}
|
|
@@ -57,24 +73,35 @@ class d extends p {
|
|
|
57
73
|
return this.elements.map((t) => t.build());
|
|
58
74
|
}
|
|
59
75
|
}
|
|
60
|
-
|
|
76
|
+
const p = {
|
|
77
|
+
HorizontalLayout: "HorizontalLayout",
|
|
78
|
+
VerticalLayout: "VerticalLayout",
|
|
79
|
+
CollapseLayout: "CollapseLayout"
|
|
80
|
+
};
|
|
81
|
+
class a extends m {
|
|
61
82
|
constructor(t, s = {}) {
|
|
62
83
|
super(t), this.options = s;
|
|
63
84
|
}
|
|
64
85
|
static horizontal() {
|
|
65
|
-
return new a(
|
|
66
|
-
}
|
|
67
|
-
static stepper(t = !1) {
|
|
68
|
-
return new a("Categorization", {
|
|
69
|
-
variant: "stepper",
|
|
70
|
-
showNavButtons: !t
|
|
71
|
-
});
|
|
86
|
+
return new a(p.HorizontalLayout);
|
|
72
87
|
}
|
|
73
|
-
static
|
|
74
|
-
return new a(
|
|
88
|
+
static collapse() {
|
|
89
|
+
return new a(p.CollapseLayout);
|
|
75
90
|
}
|
|
76
91
|
static vertical() {
|
|
77
|
-
return new a(
|
|
92
|
+
return new a(p.VerticalLayout);
|
|
93
|
+
}
|
|
94
|
+
titleKey(t) {
|
|
95
|
+
return this.addOptions({ titleKey: t });
|
|
96
|
+
}
|
|
97
|
+
title(t) {
|
|
98
|
+
return this.addOptions({ title: t });
|
|
99
|
+
}
|
|
100
|
+
addOptions(t) {
|
|
101
|
+
return this.options = {
|
|
102
|
+
...this.options,
|
|
103
|
+
...t
|
|
104
|
+
}, this;
|
|
78
105
|
}
|
|
79
106
|
build() {
|
|
80
107
|
return {
|
|
@@ -84,12 +111,12 @@ class a extends d {
|
|
|
84
111
|
};
|
|
85
112
|
}
|
|
86
113
|
}
|
|
87
|
-
class
|
|
114
|
+
class S extends d {
|
|
88
115
|
constructor(t, s = "TextCell") {
|
|
89
116
|
super(s), this.scope = t;
|
|
90
117
|
}
|
|
91
118
|
static properties(t) {
|
|
92
|
-
return new
|
|
119
|
+
return new S(`#/properties/${t}`);
|
|
93
120
|
}
|
|
94
121
|
key(t) {
|
|
95
122
|
return this.options = {
|
|
@@ -111,12 +138,12 @@ class y extends p {
|
|
|
111
138
|
};
|
|
112
139
|
}
|
|
113
140
|
}
|
|
114
|
-
class
|
|
141
|
+
class g {
|
|
115
142
|
constructor() {
|
|
116
|
-
this.builder = a.
|
|
143
|
+
this.builder = a.horizontal();
|
|
117
144
|
}
|
|
118
145
|
static init() {
|
|
119
|
-
return new
|
|
146
|
+
return new g();
|
|
120
147
|
}
|
|
121
148
|
addControl(t) {
|
|
122
149
|
return this.builder.addControls(t), this;
|
|
@@ -135,11 +162,10 @@ const i = {
|
|
|
135
162
|
autocomplete: "autocomplete",
|
|
136
163
|
textArea: "textArea",
|
|
137
164
|
markdown: "markdown",
|
|
138
|
-
fixedArray: "fixedArray",
|
|
139
165
|
array: "array",
|
|
140
166
|
custom: "custom"
|
|
141
167
|
};
|
|
142
|
-
class
|
|
168
|
+
class u extends d {
|
|
143
169
|
constructor(t, s = "Control") {
|
|
144
170
|
super(s), this.scope = t, this.options = {
|
|
145
171
|
format: "Control",
|
|
@@ -151,16 +177,16 @@ class c extends p {
|
|
|
151
177
|
};
|
|
152
178
|
}
|
|
153
179
|
static asObject(t) {
|
|
154
|
-
return new
|
|
180
|
+
return new u(
|
|
155
181
|
`#/properties/${t}`,
|
|
156
182
|
"Object"
|
|
157
183
|
);
|
|
158
184
|
}
|
|
159
185
|
static properties(t) {
|
|
160
|
-
return new
|
|
186
|
+
return new u(`#/properties/${t}`);
|
|
161
187
|
}
|
|
162
188
|
static asCustom(t, s) {
|
|
163
|
-
const r = new
|
|
189
|
+
const r = new u(
|
|
164
190
|
`#/properties/${t}`
|
|
165
191
|
);
|
|
166
192
|
return r.options = {
|
|
@@ -182,11 +208,13 @@ class c extends p {
|
|
|
182
208
|
actions: s
|
|
183
209
|
}, this;
|
|
184
210
|
}
|
|
185
|
-
detailFixed(t, s) {
|
|
211
|
+
detailFixed(t, s = {}) {
|
|
186
212
|
return this._detail = t, this.options = {
|
|
187
213
|
...this.options ?? {},
|
|
188
|
-
|
|
189
|
-
|
|
214
|
+
hideActions: !0,
|
|
215
|
+
format: i.array,
|
|
216
|
+
layout: s.layout ?? "column",
|
|
217
|
+
elementLabelProp: s.label
|
|
190
218
|
}, this;
|
|
191
219
|
}
|
|
192
220
|
labelKey(t) {
|
|
@@ -223,16 +251,31 @@ class c extends p {
|
|
|
223
251
|
sm: "w-24",
|
|
224
252
|
md: "w-36",
|
|
225
253
|
lg: "w-48",
|
|
226
|
-
xl: "w-64"
|
|
254
|
+
xl: "w-64",
|
|
255
|
+
full: "w-full"
|
|
227
256
|
};
|
|
228
|
-
return this.
|
|
229
|
-
...this.options,
|
|
257
|
+
return this.addOptions({
|
|
230
258
|
styles: {
|
|
231
259
|
...this.options?.styles,
|
|
232
260
|
control: {
|
|
233
|
-
wrapper: s[t] ?? s.sm
|
|
261
|
+
wrapper: ` ${s[t] ?? s.sm}`
|
|
234
262
|
}
|
|
235
263
|
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
customLabel(t) {
|
|
267
|
+
return this.addOptions({ label: t });
|
|
268
|
+
}
|
|
269
|
+
placeHolder(t) {
|
|
270
|
+
return this.addOptions({ placeholder: t });
|
|
271
|
+
}
|
|
272
|
+
hideLabel() {
|
|
273
|
+
return this.addOptions({ hideLabel: !0 });
|
|
274
|
+
}
|
|
275
|
+
addOptions(t) {
|
|
276
|
+
return this.options = {
|
|
277
|
+
...this.options,
|
|
278
|
+
...t
|
|
236
279
|
}, this;
|
|
237
280
|
}
|
|
238
281
|
build() {
|
|
@@ -246,7 +289,7 @@ class c extends p {
|
|
|
246
289
|
};
|
|
247
290
|
}
|
|
248
291
|
}
|
|
249
|
-
class w extends
|
|
292
|
+
class w extends m {
|
|
250
293
|
constructor(t) {
|
|
251
294
|
super(t), this.label = t, this.rule = {
|
|
252
295
|
effect: "SHOW",
|
|
@@ -265,12 +308,12 @@ class w extends d {
|
|
|
265
308
|
};
|
|
266
309
|
}
|
|
267
310
|
}
|
|
268
|
-
class
|
|
311
|
+
class x extends m {
|
|
269
312
|
constructor(t) {
|
|
270
313
|
super(t), this.label = t;
|
|
271
314
|
}
|
|
272
315
|
static label(t) {
|
|
273
|
-
return new
|
|
316
|
+
return new x(t);
|
|
274
317
|
}
|
|
275
318
|
build() {
|
|
276
319
|
return {
|
|
@@ -280,83 +323,84 @@ class g extends d {
|
|
|
280
323
|
};
|
|
281
324
|
}
|
|
282
325
|
}
|
|
283
|
-
const
|
|
284
|
-
page:
|
|
285
|
-
pageSize:
|
|
326
|
+
const c = () => n.coerce.number().int().positive().nonnegative(), z = () => n.string().or(n.array(n.string())).transform((e) => Array.isArray(e) ? e : [e]), q = n.enum(["asc", "desc"]), O = n.object({
|
|
327
|
+
page: c().optional().default(1),
|
|
328
|
+
pageSize: c().optional().default(20),
|
|
286
329
|
// TODO add sorting and so
|
|
287
|
-
sort:
|
|
288
|
-
sortDir:
|
|
330
|
+
sort: n.string().optional().default("id"),
|
|
331
|
+
sortDir: q.optional().default("asc"),
|
|
289
332
|
// Filter is of the format key:value:operator (e.g. name:john:eq) operator is optional
|
|
290
|
-
filter:
|
|
291
|
-
}),
|
|
333
|
+
filter: z().optional().default([])
|
|
334
|
+
}), H = O.transform((e) => {
|
|
292
335
|
const { page: t, pageSize: s, sort: r } = e;
|
|
293
336
|
return {
|
|
294
337
|
...e,
|
|
295
338
|
sort: r || "id",
|
|
296
339
|
offset: (t - 1) * s
|
|
297
340
|
};
|
|
298
|
-
}), F =
|
|
299
|
-
count:
|
|
300
|
-
totalPages:
|
|
301
|
-
}),
|
|
302
|
-
data:
|
|
341
|
+
}), F = O.extend({
|
|
342
|
+
count: c(),
|
|
343
|
+
totalPages: c()
|
|
344
|
+
}), N = n.object({
|
|
345
|
+
data: n.array(n.unknown()),
|
|
303
346
|
request: F
|
|
304
|
-
}),
|
|
305
|
-
const [t, s, r] = e.split(":"),
|
|
306
|
-
return { key: t, value: s, operator:
|
|
307
|
-
},
|
|
347
|
+
}), K = ["contains", "equals"], C = (e) => {
|
|
348
|
+
const [t, s, r] = e.split(":"), o = K.includes(r) ? r : "contains";
|
|
349
|
+
return { key: t, value: s, operator: o };
|
|
350
|
+
}, L = (e, t) => {
|
|
308
351
|
if (e.length === 1)
|
|
309
352
|
return { key: e[0], filterObj: t };
|
|
310
353
|
const s = e.pop();
|
|
311
|
-
return
|
|
312
|
-
},
|
|
354
|
+
return L(e, { [s]: t });
|
|
355
|
+
}, T = (e, t) => A(e.split("."), t), A = (e, t) => {
|
|
313
356
|
if (e.length === 1)
|
|
314
357
|
return { [e[0]]: t };
|
|
315
358
|
const s = e.pop();
|
|
316
359
|
return A(e, { [s]: t });
|
|
317
|
-
},
|
|
360
|
+
}, V = (e) => {
|
|
318
361
|
const t = {};
|
|
319
362
|
return e?.forEach((s) => {
|
|
320
|
-
const { key: r, value:
|
|
363
|
+
const { key: r, value: o, operator: l } = C(s);
|
|
321
364
|
if (!r) return;
|
|
322
|
-
const h = l || "contains",
|
|
323
|
-
[l || "contains"]:
|
|
365
|
+
const h = l || "contains", f = {
|
|
366
|
+
[l || "contains"]: o.toLowerCase()
|
|
324
367
|
};
|
|
325
|
-
h === "contains" && (
|
|
326
|
-
const
|
|
327
|
-
t[
|
|
368
|
+
h === "contains" && (f.mode = "insensitive");
|
|
369
|
+
const b = L(r.split("."), f);
|
|
370
|
+
t[b.key] = b.filterObj;
|
|
328
371
|
}), t;
|
|
329
|
-
},
|
|
372
|
+
}, W = (e) => {
|
|
330
373
|
const t = [];
|
|
331
374
|
return e.forEach((s) => {
|
|
332
|
-
const { key: r, value:
|
|
375
|
+
const { key: r, value: o, operator: l } = C(s);
|
|
333
376
|
if (!r) return;
|
|
334
377
|
const h = r;
|
|
335
|
-
t.push({ label: h, key: r, value:
|
|
378
|
+
t.push({ label: h, key: r, value: o, operator: l });
|
|
336
379
|
}), t;
|
|
337
380
|
};
|
|
338
381
|
export {
|
|
339
382
|
w as CategoryBuilder,
|
|
340
|
-
|
|
383
|
+
u as ControlBuilder,
|
|
341
384
|
i as ControlType,
|
|
342
|
-
|
|
385
|
+
x as GroupBuilder,
|
|
343
386
|
a as LayoutBuilder,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
387
|
+
p as LayoutTypes,
|
|
388
|
+
K as Operator,
|
|
389
|
+
c as PositiveRequestNumber,
|
|
390
|
+
O as RequestSchema,
|
|
391
|
+
H as RequestSchemaWithOffset,
|
|
348
392
|
F as ResponseRequestSchema,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
393
|
+
N as ResponseSchema,
|
|
394
|
+
E as Size,
|
|
395
|
+
q as SortDirEnum,
|
|
396
|
+
z as StringOrArray,
|
|
397
|
+
g as TableBuilder,
|
|
398
|
+
S as TextCellBuilder,
|
|
399
|
+
V as buildFilter,
|
|
400
|
+
T as buildSort,
|
|
357
401
|
A as buildSortKey,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
402
|
+
R as createSchema,
|
|
403
|
+
W as extractFilters,
|
|
404
|
+
$ as findColumnDef,
|
|
361
405
|
k as findProperty
|
|
362
406
|
};
|
|
@@ -7,9 +7,11 @@ export declare enum Size {
|
|
|
7
7
|
lg = "lg",
|
|
8
8
|
xl = "xl"
|
|
9
9
|
}
|
|
10
|
+
export type SizeType = keyof typeof Size;
|
|
10
11
|
export type JsonFormsLayout = {
|
|
11
12
|
uiSchema: Layout;
|
|
12
|
-
|
|
13
|
+
schema: JsonSchema;
|
|
14
|
+
modalSize?: SizeType;
|
|
13
15
|
};
|
|
14
16
|
export type FormSchemaModel = {
|
|
15
17
|
form: JsonFormsLayout;
|
|
@@ -27,7 +29,7 @@ export declare const createSchema: (props: {
|
|
|
27
29
|
responseSchema?: ZodObject<any>;
|
|
28
30
|
uri: string;
|
|
29
31
|
searchUri?: string;
|
|
30
|
-
modalSize?:
|
|
32
|
+
modalSize?: SizeType;
|
|
31
33
|
}) => {
|
|
32
34
|
dtoSchema: ZodObject<any, import('zod/v4/core').$strip>;
|
|
33
35
|
responseSchema: ZodObject<any, import('zod/v4/core').$strip>;
|
|
@@ -7,7 +7,6 @@ export declare const ControlType: {
|
|
|
7
7
|
readonly autocomplete: "autocomplete";
|
|
8
8
|
readonly textArea: "textArea";
|
|
9
9
|
readonly markdown: "markdown";
|
|
10
|
-
readonly fixedArray: "fixedArray";
|
|
11
10
|
readonly array: "array";
|
|
12
11
|
readonly custom: "custom";
|
|
13
12
|
};
|
|
@@ -15,12 +14,14 @@ export interface TextAreaOptions extends ControlOption {
|
|
|
15
14
|
format: 'textArea';
|
|
16
15
|
}
|
|
17
16
|
export interface DetailOptions extends ControlOption {
|
|
18
|
-
format: '
|
|
17
|
+
format: 'array';
|
|
18
|
+
layout: 'row' | 'column';
|
|
19
19
|
}
|
|
20
20
|
export interface AutocompleteOptions extends ControlOption {
|
|
21
21
|
format: 'autocomplete';
|
|
22
22
|
uri: string;
|
|
23
23
|
dataField?: string;
|
|
24
|
+
skipAuth?: boolean;
|
|
24
25
|
field: {
|
|
25
26
|
id: string;
|
|
26
27
|
label: string;
|
|
@@ -40,6 +41,9 @@ export interface ControlOption {
|
|
|
40
41
|
elementLabelProp?: string;
|
|
41
42
|
labelKey?: string;
|
|
42
43
|
actions?: ArrayAction[];
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
hideLabel?: boolean;
|
|
46
|
+
hideActions?: boolean;
|
|
43
47
|
}
|
|
44
48
|
export type ControlTypes = {
|
|
45
49
|
type: 'Control' | 'Object' | 'TextCell';
|
|
@@ -56,12 +60,19 @@ export declare class ControlBuilder<TYPE, KEY = keyof TYPE> extends Builder<Cont
|
|
|
56
60
|
static asCustom<TYPE>(property: keyof TYPE, type: string): ControlBuilder<TYPE>;
|
|
57
61
|
detail<TYPE>(layoutBuilder: LayoutBuilder<TYPE>, label?: string): this;
|
|
58
62
|
addAction(action: ArrayAction): this;
|
|
59
|
-
detailFixed<TYPE>(layoutBuilder: LayoutBuilder<TYPE>,
|
|
63
|
+
detailFixed<TYPE>(layoutBuilder: LayoutBuilder<TYPE>, options?: {
|
|
64
|
+
label?: string;
|
|
65
|
+
layout?: 'row' | 'column';
|
|
66
|
+
}): this;
|
|
60
67
|
labelKey(labelKey: string): this;
|
|
61
68
|
readonly(): ControlBuilder<TYPE>;
|
|
62
69
|
markdown(): ControlBuilder<TYPE>;
|
|
63
70
|
textArea(options?: Omit<TextAreaOptions, 'format'>): this;
|
|
64
71
|
autocomplete(options: Omit<AutocompleteOptions, 'format'>): this;
|
|
65
|
-
width(width: 'xs' | 'sm' | 'md' | 'lg' | 'xl'): this;
|
|
72
|
+
width(width: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full'): this;
|
|
73
|
+
customLabel(label: string): this;
|
|
74
|
+
placeHolder(placeholder: string): this;
|
|
75
|
+
hideLabel(): this;
|
|
76
|
+
private addOptions;
|
|
66
77
|
build(): ControlTypes;
|
|
67
78
|
}
|
|
@@ -4,16 +4,25 @@ import { ControlBuilder, ControlTypes } from './control.builder';
|
|
|
4
4
|
import { GroupBuilder } from './group.builder';
|
|
5
5
|
import { TextCellBuilder } from '../table/builder';
|
|
6
6
|
export type ElementBuilder<TYPE> = ControlBuilder<TYPE> | LayoutBuilder<TYPE> | CategoryBuilder<TYPE> | GroupBuilder<TYPE> | TextCellBuilder<TYPE>;
|
|
7
|
+
export declare const LayoutTypes: {
|
|
8
|
+
readonly HorizontalLayout: "HorizontalLayout";
|
|
9
|
+
readonly VerticalLayout: "VerticalLayout";
|
|
10
|
+
readonly CollapseLayout: "CollapseLayout";
|
|
11
|
+
};
|
|
12
|
+
type _LayoutTypes = (typeof LayoutTypes)[keyof typeof LayoutTypes];
|
|
7
13
|
export type LayoutType = {
|
|
8
|
-
type: '
|
|
14
|
+
type: 'LayoutTypes';
|
|
9
15
|
elements: Array<ControlTypes | LayoutType>;
|
|
10
16
|
};
|
|
11
17
|
export declare class LayoutBuilder<TYPE> extends BuilderWithElements<LayoutType, TYPE> {
|
|
12
18
|
private options;
|
|
13
|
-
protected constructor(type:
|
|
19
|
+
protected constructor(type: _LayoutTypes, options?: {});
|
|
14
20
|
static horizontal<TYPE>(): LayoutBuilder<TYPE>;
|
|
15
|
-
static
|
|
16
|
-
static table(): LayoutBuilder<unknown>;
|
|
21
|
+
static collapse<TYPE>(): LayoutBuilder<TYPE>;
|
|
17
22
|
static vertical<TYPE>(): LayoutBuilder<TYPE>;
|
|
23
|
+
titleKey(titleKey: string): this;
|
|
24
|
+
title(title: string): this;
|
|
25
|
+
private addOptions;
|
|
18
26
|
build(): LayoutType;
|
|
19
27
|
}
|
|
28
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghentcdh/json-forms-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -14,13 +14,11 @@
|
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@anatine/zod-openapi": "^2.2.0",
|
|
16
16
|
"@jsonforms/core": "^3.4.0",
|
|
17
|
-
"lodash-es": "^4.17.0",
|
|
18
17
|
"zod": "^3.24.0"
|
|
19
18
|
},
|
|
20
19
|
"devDependencies": {
|
|
21
20
|
"@anatine/zod-openapi": "2.2.8",
|
|
22
21
|
"@jsonforms/core": "3.7.0",
|
|
23
|
-
"lodash-es": "4.17.23",
|
|
24
22
|
"zod": "4.3.6"
|
|
25
23
|
},
|
|
26
24
|
"repository": {
|