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