@ghentcdh/json-forms-core 0.6.8 → 0.7.0
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.js +131 -122
- package/lib/create-schema.d.ts +1 -2
- package/lib/layout/control.builder.d.ts +25 -8
- package/lib/layout/layout.builder.d.ts +2 -0
- package/package.json +1 -1
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 n=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 r=t.find(o=>o.type!=="null"),s=t.some(o=>o.type==="null");r&&s&&(delete e.anyOf,Object.assign(e,r))},w=e=>{const t=n.toJSONSchema(e,{unrepresentable:"any",target:"draft-07"});t.additionalProperties=!0;const r=t.properties;if(r)for(const s of Object.keys(r))j(r[s]);return t},P=e=>{if(!e.schema)throw new Error("no schema provided");const t=e.schema,r=e.dtoSchema,s=w(r),o=w(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: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 r=e.scope?.substring(13),s=t?.properties?.[r]??{};return{id:r,property:s}},k=(e,t)=>{const{id:r,property:s}=L(e,t);return{...e,id:r,label:r,...s}};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 l={HorizontalLayout:"HorizontalLayout",VerticalLayout:"VerticalLayout",CollapseLayout:"CollapseLayout",GridLayout:"GridLayout"};class a extends m{constructor(t,r={}){super(t),this.options=r}static horizontal(){return new a(l.HorizontalLayout)}static collapse(){return new a(l.CollapseLayout)}static vertical(){return new a(l.VerticalLayout)}static grid(){return new a(l.GridLayout)}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 y extends p{constructor(t,r="TextCell"){super(r),this.scope=t}static properties(t){return new y(`#/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.horizontal()}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 i={number:"number",string:"string",integer:"Integer",autocomplete:"autocomplete",textArea:"textArea",markdown:"markdown",array:"array",custom:"custom",select:"select",mutliSelect:"mutliSelect",boolean:"boolean"};class u extends p{constructor(t,r="Control"){super(r),this.scope=t,this.options={format:"Control",styles:{}}}static asObject(t){return new u(`#/properties/${t}`,"Object")}static properties(t){return new u(`#/properties/${t}`)}static asCustom(t,r){const s=new u(`#/properties/${t}`);return s.addOptions({format:i.custom,type:r}),s}detail(t,r){return this._detail=t,this.addOptions({format:i.array,elementLabelProp:r}),this}addAction(t){const r=this.options?.actions??[];return r.push(t),this.addOptions({actions:r})}detailFixed(t,r={}){return this._detail=t,this.addOptions({hideActions:!0,format:i.array,layout:r.layout??"column",elementLabelProp:r.label})}labelKey(t){return this.addOptions({labelKey:t})}readonly(){return this.addOptions({format:i.string,readonly:!0})}markdown(t){return this.addOptions({format:i.markdown,...t??{}})}textArea(t){return this.addOptions({format:i.textArea,...t??{}})}autocomplete(t){return this.addOptions({format:i.autocomplete,dataField:"data",...t??{}})}control(t,r){return this.addOptions({format:t,...r})}select(t){return this.addOptions({format:i.select,...t})}mutliSelect(t){return this.addOptions({format:i.mutliSelect,...t})}width(t){return this.addOptions({styles:{...this.options?.styles,width:t,control:{wrapper:`input-${t}`}}})}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 f extends m{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 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 c=()=>n.z.coerce.number().int().positive().nonnegative(),v=()=>n.z.string().or(n.z.array(n.z.string())).transform(e=>Array.isArray(e)?e:[e]),A=n.z.enum(["asc","desc"]),O=n.z.object({page:c().optional().default(1),pageSize:c().optional().default(20),sort:n.z.string().optional().default("id"),sortDir:A.optional().default("asc"),filter:v().optional().default([])}),F=O.transform(e=>{const{page:t,pageSize:r,sort:s}=e;return{...e,sort:s||"id",offset:(t-1)*r}}),R=O.extend({count:c(),totalPages:c()}),K=n.z.object({data:n.z.array(n.z.unknown()),request:R}),q=["contains","equals"],E=e=>{const[t,r,s]=e.split(":"),o=q.includes(s)?s:"contains";return{key:t,value:r,operator:o}},T=(e,t)=>{if(e.length===1)return{key:e[0],filterObj:t};const r=e.pop();return T(e,{[r]:t})},N=(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:o,operator:d}=E(r);if(!s)return;const h=d||"contains",x={[d||"contains"]:o.toLowerCase()};h==="contains"&&(x.mode="insensitive");const C=T(s.split("."),x);t[C.key]=C.filterObj}),t},G=e=>{const t=[];return e.forEach(r=>{const{key:s,value:o,operator:d}=E(r);if(!s)return;const h=s;t.push({label:h,key:s,value:o,operator:d})}),t};exports.CategoryBuilder=f;exports.ControlBuilder=u;exports.ControlType=i;exports.GroupBuilder=S;exports.LayoutBuilder=a;exports.LayoutTypes=l;exports.Operator=q;exports.PositiveRequestNumber=c;exports.RequestSchema=O;exports.RequestSchemaWithOffset=F;exports.ResponseRequestSchema=R;exports.ResponseSchema=K;exports.Size=z;exports.SortDirEnum=A;exports.StringOrArray=v;exports.TableBuilder=b;exports.TextCellBuilder=y;exports.buildFilter=$;exports.buildSort=N;exports.buildSortKey=g;exports.createSchema=P;exports.extractFilters=G;exports.findColumnDef=k;exports.findProperty=L;
|
package/index.js
CHANGED
|
@@ -3,34 +3,34 @@ var E = /* @__PURE__ */ ((e) => (e.xs = "xs", e.sm = "sm", e.lg = "lg", e.xl = "
|
|
|
3
3
|
const j = (e) => {
|
|
4
4
|
const t = e.anyOf;
|
|
5
5
|
if (!Array.isArray(t) || t.length !== 2) return;
|
|
6
|
-
const
|
|
6
|
+
const r = t.find(
|
|
7
7
|
(o) => o.type !== "null"
|
|
8
|
-
),
|
|
8
|
+
), s = t.some(
|
|
9
9
|
(o) => o.type === "null"
|
|
10
10
|
);
|
|
11
|
-
|
|
11
|
+
r && s && (delete e.anyOf, Object.assign(e, r));
|
|
12
12
|
}, y = (e) => {
|
|
13
13
|
const t = v(e, {
|
|
14
14
|
unrepresentable: "any",
|
|
15
15
|
target: "draft-07"
|
|
16
16
|
});
|
|
17
17
|
t.additionalProperties = !0;
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
for (const
|
|
21
|
-
j(s
|
|
18
|
+
const r = t.properties;
|
|
19
|
+
if (r)
|
|
20
|
+
for (const s of Object.keys(r))
|
|
21
|
+
j(r[s]);
|
|
22
22
|
return t;
|
|
23
23
|
}, R = (e) => {
|
|
24
24
|
if (!e.schema)
|
|
25
25
|
throw new Error("no schema provided");
|
|
26
|
-
const t = e.schema,
|
|
26
|
+
const t = e.schema, r = e.dtoSchema, s = y(r), o = y(t.partial());
|
|
27
27
|
return {
|
|
28
|
-
dtoSchema:
|
|
29
|
-
responseSchema: e.responseSchema ??
|
|
28
|
+
dtoSchema: r,
|
|
29
|
+
responseSchema: e.responseSchema ?? r,
|
|
30
30
|
schema: {
|
|
31
31
|
form: {
|
|
32
32
|
uiSchema: e.uiSchema,
|
|
33
|
-
schema:
|
|
33
|
+
schema: s,
|
|
34
34
|
modalSize: e.modalSize ?? "sm"
|
|
35
35
|
},
|
|
36
36
|
table: e.tableSchema ? {
|
|
@@ -48,18 +48,18 @@ const j = (e) => {
|
|
|
48
48
|
}, k = (e, t) => {
|
|
49
49
|
if (!e.scope)
|
|
50
50
|
return { id: null, property: null };
|
|
51
|
-
const
|
|
52
|
-
return { id:
|
|
51
|
+
const r = e.scope?.substring(13), s = t?.properties?.[r] ?? {};
|
|
52
|
+
return { id: r, property: s };
|
|
53
53
|
}, $ = (e, t) => {
|
|
54
|
-
const { id:
|
|
55
|
-
return { ...e, id:
|
|
54
|
+
const { id: r, property: s } = k(e, t);
|
|
55
|
+
return { ...e, id: r, label: r, ...s };
|
|
56
56
|
};
|
|
57
|
-
class
|
|
57
|
+
class p {
|
|
58
58
|
constructor(t) {
|
|
59
59
|
this.type = t;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
class m extends
|
|
62
|
+
class m extends p {
|
|
63
63
|
constructor() {
|
|
64
64
|
super(...arguments), this.elements = [];
|
|
65
65
|
}
|
|
@@ -73,23 +73,27 @@ class m extends d {
|
|
|
73
73
|
return this.elements.map((t) => t.build());
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const u = {
|
|
77
77
|
HorizontalLayout: "HorizontalLayout",
|
|
78
78
|
VerticalLayout: "VerticalLayout",
|
|
79
|
-
CollapseLayout: "CollapseLayout"
|
|
79
|
+
CollapseLayout: "CollapseLayout",
|
|
80
|
+
GridLayout: "GridLayout"
|
|
80
81
|
};
|
|
81
82
|
class a extends m {
|
|
82
|
-
constructor(t,
|
|
83
|
-
super(t), this.options =
|
|
83
|
+
constructor(t, r = {}) {
|
|
84
|
+
super(t), this.options = r;
|
|
84
85
|
}
|
|
85
86
|
static horizontal() {
|
|
86
|
-
return new a(
|
|
87
|
+
return new a(u.HorizontalLayout);
|
|
87
88
|
}
|
|
88
89
|
static collapse() {
|
|
89
|
-
return new a(
|
|
90
|
+
return new a(u.CollapseLayout);
|
|
90
91
|
}
|
|
91
92
|
static vertical() {
|
|
92
|
-
return new a(
|
|
93
|
+
return new a(u.VerticalLayout);
|
|
94
|
+
}
|
|
95
|
+
static grid() {
|
|
96
|
+
return new a(u.GridLayout);
|
|
93
97
|
}
|
|
94
98
|
titleKey(t) {
|
|
95
99
|
return this.addOptions({ titleKey: t });
|
|
@@ -111,12 +115,12 @@ class a extends m {
|
|
|
111
115
|
};
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
|
-
class
|
|
115
|
-
constructor(t,
|
|
116
|
-
super(
|
|
118
|
+
class O extends p {
|
|
119
|
+
constructor(t, r = "TextCell") {
|
|
120
|
+
super(r), this.scope = t;
|
|
117
121
|
}
|
|
118
122
|
static properties(t) {
|
|
119
|
-
return new
|
|
123
|
+
return new O(`#/properties/${t}`);
|
|
120
124
|
}
|
|
121
125
|
key(t) {
|
|
122
126
|
return this.options = {
|
|
@@ -138,12 +142,12 @@ class S extends d {
|
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
|
-
class
|
|
145
|
+
class S {
|
|
142
146
|
constructor() {
|
|
143
147
|
this.builder = a.horizontal();
|
|
144
148
|
}
|
|
145
149
|
static init() {
|
|
146
|
-
return new
|
|
150
|
+
return new S();
|
|
147
151
|
}
|
|
148
152
|
addControl(t) {
|
|
149
153
|
return this.builder.addControls(t), this;
|
|
@@ -163,102 +167,107 @@ const i = {
|
|
|
163
167
|
textArea: "textArea",
|
|
164
168
|
markdown: "markdown",
|
|
165
169
|
array: "array",
|
|
166
|
-
custom: "custom"
|
|
170
|
+
custom: "custom",
|
|
171
|
+
select: "select",
|
|
172
|
+
mutliSelect: "mutliSelect",
|
|
173
|
+
boolean: "boolean"
|
|
167
174
|
};
|
|
168
|
-
class
|
|
169
|
-
constructor(t,
|
|
170
|
-
super(
|
|
175
|
+
class c extends p {
|
|
176
|
+
constructor(t, r = "Control") {
|
|
177
|
+
super(r), this.scope = t, this.options = {
|
|
171
178
|
format: "Control",
|
|
172
|
-
styles: {
|
|
173
|
-
control: {
|
|
174
|
-
wrapper: "w-full"
|
|
175
|
-
}
|
|
176
|
-
}
|
|
179
|
+
styles: {}
|
|
177
180
|
};
|
|
178
181
|
}
|
|
179
182
|
static asObject(t) {
|
|
180
|
-
return new
|
|
183
|
+
return new c(
|
|
181
184
|
`#/properties/${t}`,
|
|
182
185
|
"Object"
|
|
183
186
|
);
|
|
184
187
|
}
|
|
185
188
|
static properties(t) {
|
|
186
|
-
return new
|
|
189
|
+
return new c(`#/properties/${t}`);
|
|
187
190
|
}
|
|
188
|
-
static asCustom(t,
|
|
189
|
-
const
|
|
191
|
+
static asCustom(t, r) {
|
|
192
|
+
const s = new c(
|
|
190
193
|
`#/properties/${t}`
|
|
191
194
|
);
|
|
192
|
-
return
|
|
195
|
+
return s.addOptions({
|
|
193
196
|
format: i.custom,
|
|
194
|
-
type:
|
|
195
|
-
},
|
|
197
|
+
type: r
|
|
198
|
+
}), s;
|
|
196
199
|
}
|
|
197
|
-
detail(t,
|
|
198
|
-
return this._detail = t, this.
|
|
199
|
-
...this.options ?? {},
|
|
200
|
+
detail(t, r) {
|
|
201
|
+
return this._detail = t, this.addOptions({
|
|
200
202
|
format: i.array,
|
|
201
|
-
elementLabelProp:
|
|
202
|
-
}, this;
|
|
203
|
+
elementLabelProp: r
|
|
204
|
+
}), this;
|
|
203
205
|
}
|
|
204
206
|
addAction(t) {
|
|
205
|
-
const
|
|
206
|
-
return
|
|
207
|
-
...this.options ?? {},
|
|
208
|
-
actions: s
|
|
209
|
-
}, this;
|
|
207
|
+
const r = this.options?.actions ?? [];
|
|
208
|
+
return r.push(t), this.addOptions({ actions: r });
|
|
210
209
|
}
|
|
211
|
-
detailFixed(t,
|
|
212
|
-
return this._detail = t, this.
|
|
213
|
-
...this.options ?? {},
|
|
210
|
+
detailFixed(t, r = {}) {
|
|
211
|
+
return this._detail = t, this.addOptions({
|
|
214
212
|
hideActions: !0,
|
|
215
213
|
format: i.array,
|
|
216
|
-
layout:
|
|
217
|
-
elementLabelProp:
|
|
218
|
-
}
|
|
214
|
+
layout: r.layout ?? "column",
|
|
215
|
+
elementLabelProp: r.label
|
|
216
|
+
});
|
|
219
217
|
}
|
|
220
218
|
labelKey(t) {
|
|
221
|
-
return this.
|
|
222
|
-
...this.options ?? {},
|
|
223
|
-
labelKey: t
|
|
224
|
-
}, this;
|
|
219
|
+
return this.addOptions({ labelKey: t });
|
|
225
220
|
}
|
|
226
221
|
readonly() {
|
|
227
|
-
return this.
|
|
222
|
+
return this.addOptions({
|
|
228
223
|
format: i.string,
|
|
229
224
|
readonly: !0
|
|
230
|
-
}
|
|
225
|
+
});
|
|
231
226
|
}
|
|
232
|
-
markdown() {
|
|
233
|
-
return this.
|
|
227
|
+
markdown(t) {
|
|
228
|
+
return this.addOptions({
|
|
229
|
+
format: i.markdown,
|
|
230
|
+
...t ?? {}
|
|
231
|
+
});
|
|
234
232
|
}
|
|
235
233
|
textArea(t) {
|
|
236
|
-
return this.
|
|
234
|
+
return this.addOptions({
|
|
237
235
|
format: i.textArea,
|
|
238
236
|
...t ?? {}
|
|
239
|
-
}
|
|
237
|
+
});
|
|
240
238
|
}
|
|
241
239
|
autocomplete(t) {
|
|
242
|
-
return this.
|
|
240
|
+
return this.addOptions({
|
|
243
241
|
format: i.autocomplete,
|
|
244
242
|
dataField: "data",
|
|
243
|
+
...t ?? {}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
control(t, r) {
|
|
247
|
+
return this.addOptions({
|
|
248
|
+
format: t,
|
|
249
|
+
...r
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
select(t) {
|
|
253
|
+
return this.addOptions({
|
|
254
|
+
format: i.select,
|
|
245
255
|
...t
|
|
246
|
-
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
mutliSelect(t) {
|
|
259
|
+
return this.addOptions({
|
|
260
|
+
format: i.mutliSelect,
|
|
261
|
+
...t
|
|
262
|
+
});
|
|
247
263
|
}
|
|
248
264
|
width(t) {
|
|
249
|
-
const s = {
|
|
250
|
-
xs: "w-12",
|
|
251
|
-
sm: "w-24",
|
|
252
|
-
md: "w-36",
|
|
253
|
-
lg: "w-48",
|
|
254
|
-
xl: "w-64",
|
|
255
|
-
full: "w-full"
|
|
256
|
-
};
|
|
257
265
|
return this.addOptions({
|
|
258
266
|
styles: {
|
|
259
267
|
...this.options?.styles,
|
|
268
|
+
width: t,
|
|
260
269
|
control: {
|
|
261
|
-
wrapper: `
|
|
270
|
+
wrapper: `input-${t}`
|
|
262
271
|
}
|
|
263
272
|
}
|
|
264
273
|
});
|
|
@@ -289,7 +298,7 @@ class u extends d {
|
|
|
289
298
|
};
|
|
290
299
|
}
|
|
291
300
|
}
|
|
292
|
-
class
|
|
301
|
+
class g extends m {
|
|
293
302
|
constructor(t) {
|
|
294
303
|
super(t), this.label = t, this.rule = {
|
|
295
304
|
effect: "SHOW",
|
|
@@ -297,7 +306,7 @@ class w extends m {
|
|
|
297
306
|
};
|
|
298
307
|
}
|
|
299
308
|
static label(t) {
|
|
300
|
-
return new
|
|
309
|
+
return new g(t);
|
|
301
310
|
}
|
|
302
311
|
build() {
|
|
303
312
|
return {
|
|
@@ -308,12 +317,12 @@ class w extends m {
|
|
|
308
317
|
};
|
|
309
318
|
}
|
|
310
319
|
}
|
|
311
|
-
class
|
|
320
|
+
class w extends m {
|
|
312
321
|
constructor(t) {
|
|
313
322
|
super(t), this.label = t;
|
|
314
323
|
}
|
|
315
324
|
static label(t) {
|
|
316
|
-
return new
|
|
325
|
+
return new w(t);
|
|
317
326
|
}
|
|
318
327
|
build() {
|
|
319
328
|
return {
|
|
@@ -323,84 +332,84 @@ class x extends m {
|
|
|
323
332
|
};
|
|
324
333
|
}
|
|
325
334
|
}
|
|
326
|
-
const
|
|
327
|
-
page:
|
|
328
|
-
pageSize:
|
|
335
|
+
const d = () => 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"]), x = n.object({
|
|
336
|
+
page: d().optional().default(1),
|
|
337
|
+
pageSize: d().optional().default(20),
|
|
329
338
|
// TODO add sorting and so
|
|
330
339
|
sort: n.string().optional().default("id"),
|
|
331
340
|
sortDir: q.optional().default("asc"),
|
|
332
341
|
// Filter is of the format key:value:operator (e.g. name:john:eq) operator is optional
|
|
333
342
|
filter: z().optional().default([])
|
|
334
|
-
}), H =
|
|
335
|
-
const { page: t, pageSize:
|
|
343
|
+
}), H = x.transform((e) => {
|
|
344
|
+
const { page: t, pageSize: r, sort: s } = e;
|
|
336
345
|
return {
|
|
337
346
|
...e,
|
|
338
|
-
sort:
|
|
339
|
-
offset: (t - 1) *
|
|
347
|
+
sort: s || "id",
|
|
348
|
+
offset: (t - 1) * r
|
|
340
349
|
};
|
|
341
|
-
}), F =
|
|
342
|
-
count:
|
|
343
|
-
totalPages:
|
|
350
|
+
}), F = x.extend({
|
|
351
|
+
count: d(),
|
|
352
|
+
totalPages: d()
|
|
344
353
|
}), N = n.object({
|
|
345
354
|
data: n.array(n.unknown()),
|
|
346
355
|
request: F
|
|
347
356
|
}), K = ["contains", "equals"], C = (e) => {
|
|
348
|
-
const [t,
|
|
349
|
-
return { key: t, value:
|
|
357
|
+
const [t, r, s] = e.split(":"), o = K.includes(s) ? s : "contains";
|
|
358
|
+
return { key: t, value: r, operator: o };
|
|
350
359
|
}, L = (e, t) => {
|
|
351
360
|
if (e.length === 1)
|
|
352
361
|
return { key: e[0], filterObj: t };
|
|
353
|
-
const
|
|
354
|
-
return L(e, { [
|
|
362
|
+
const r = e.pop();
|
|
363
|
+
return L(e, { [r]: t });
|
|
355
364
|
}, T = (e, t) => A(e.split("."), t), A = (e, t) => {
|
|
356
365
|
if (e.length === 1)
|
|
357
366
|
return { [e[0]]: t };
|
|
358
|
-
const
|
|
359
|
-
return A(e, { [
|
|
367
|
+
const r = e.pop();
|
|
368
|
+
return A(e, { [r]: t });
|
|
360
369
|
}, V = (e) => {
|
|
361
370
|
const t = {};
|
|
362
|
-
return e?.forEach((
|
|
363
|
-
const { key:
|
|
364
|
-
if (!
|
|
371
|
+
return e?.forEach((r) => {
|
|
372
|
+
const { key: s, value: o, operator: l } = C(r);
|
|
373
|
+
if (!s) return;
|
|
365
374
|
const h = l || "contains", f = {
|
|
366
375
|
[l || "contains"]: o.toLowerCase()
|
|
367
376
|
};
|
|
368
377
|
h === "contains" && (f.mode = "insensitive");
|
|
369
|
-
const b = L(
|
|
378
|
+
const b = L(s.split("."), f);
|
|
370
379
|
t[b.key] = b.filterObj;
|
|
371
380
|
}), t;
|
|
372
|
-
},
|
|
381
|
+
}, G = (e) => {
|
|
373
382
|
const t = [];
|
|
374
|
-
return e.forEach((
|
|
375
|
-
const { key:
|
|
376
|
-
if (!
|
|
377
|
-
const h =
|
|
378
|
-
t.push({ label: h, key:
|
|
383
|
+
return e.forEach((r) => {
|
|
384
|
+
const { key: s, value: o, operator: l } = C(r);
|
|
385
|
+
if (!s) return;
|
|
386
|
+
const h = s;
|
|
387
|
+
t.push({ label: h, key: s, value: o, operator: l });
|
|
379
388
|
}), t;
|
|
380
389
|
};
|
|
381
390
|
export {
|
|
382
|
-
|
|
383
|
-
|
|
391
|
+
g as CategoryBuilder,
|
|
392
|
+
c as ControlBuilder,
|
|
384
393
|
i as ControlType,
|
|
385
|
-
|
|
394
|
+
w as GroupBuilder,
|
|
386
395
|
a as LayoutBuilder,
|
|
387
|
-
|
|
396
|
+
u as LayoutTypes,
|
|
388
397
|
K as Operator,
|
|
389
|
-
|
|
390
|
-
|
|
398
|
+
d as PositiveRequestNumber,
|
|
399
|
+
x as RequestSchema,
|
|
391
400
|
H as RequestSchemaWithOffset,
|
|
392
401
|
F as ResponseRequestSchema,
|
|
393
402
|
N as ResponseSchema,
|
|
394
403
|
E as Size,
|
|
395
404
|
q as SortDirEnum,
|
|
396
405
|
z as StringOrArray,
|
|
397
|
-
|
|
398
|
-
|
|
406
|
+
S as TableBuilder,
|
|
407
|
+
O as TextCellBuilder,
|
|
399
408
|
V as buildFilter,
|
|
400
409
|
T as buildSort,
|
|
401
410
|
A as buildSortKey,
|
|
402
411
|
R as createSchema,
|
|
403
|
-
|
|
412
|
+
G as extractFilters,
|
|
404
413
|
$ as findColumnDef,
|
|
405
414
|
k as findProperty
|
|
406
415
|
};
|
package/lib/create-schema.d.ts
CHANGED
|
@@ -9,23 +9,37 @@ export declare const ControlType: {
|
|
|
9
9
|
readonly markdown: "markdown";
|
|
10
10
|
readonly array: "array";
|
|
11
11
|
readonly custom: "custom";
|
|
12
|
+
readonly select: "select";
|
|
13
|
+
readonly mutliSelect: "mutliSelect";
|
|
14
|
+
readonly boolean: "boolean";
|
|
12
15
|
};
|
|
13
16
|
export interface TextAreaOptions extends ControlOption {
|
|
14
17
|
format: 'textArea';
|
|
15
18
|
}
|
|
19
|
+
export interface MarkdownOptions extends ControlOption {
|
|
20
|
+
format: 'markdown';
|
|
21
|
+
minHeight: string;
|
|
22
|
+
}
|
|
16
23
|
export interface DetailOptions extends ControlOption {
|
|
17
24
|
format: 'array';
|
|
18
25
|
layout: 'row' | 'column';
|
|
19
26
|
}
|
|
20
|
-
export interface
|
|
27
|
+
export interface SelectOptions extends ControlOption {
|
|
28
|
+
format: 'select' | 'multiselect';
|
|
29
|
+
options: Array<any>;
|
|
30
|
+
labelKey?: string;
|
|
31
|
+
valueKey?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AutocompleteOptions extends Omit<SelectOptions, 'format'> {
|
|
34
|
+
format: 'autocomplete';
|
|
35
|
+
freeText?: boolean;
|
|
36
|
+
enableCreate?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface AutocompleteRemoteOptions extends Omit<AutocompleteOptions, 'format' | 'options'> {
|
|
21
39
|
format: 'autocomplete';
|
|
22
40
|
uri: string;
|
|
23
41
|
dataField?: string;
|
|
24
42
|
skipAuth?: boolean;
|
|
25
|
-
field: {
|
|
26
|
-
id: string;
|
|
27
|
-
label: string;
|
|
28
|
-
};
|
|
29
43
|
}
|
|
30
44
|
export type ArrayActionType = 'edit';
|
|
31
45
|
export type ArrayAction = {
|
|
@@ -39,7 +53,7 @@ export interface ControlOption {
|
|
|
39
53
|
styles?: Partial<any>;
|
|
40
54
|
elements?: any;
|
|
41
55
|
elementLabelProp?: string;
|
|
42
|
-
|
|
56
|
+
customLabel?: string;
|
|
43
57
|
actions?: ArrayAction[];
|
|
44
58
|
placeholder?: string;
|
|
45
59
|
hideLabel?: boolean;
|
|
@@ -66,9 +80,12 @@ export declare class ControlBuilder<TYPE, KEY = keyof TYPE> extends Builder<Cont
|
|
|
66
80
|
}): this;
|
|
67
81
|
labelKey(labelKey: string): this;
|
|
68
82
|
readonly(): ControlBuilder<TYPE>;
|
|
69
|
-
markdown(): ControlBuilder<TYPE>;
|
|
83
|
+
markdown(options?: Omit<MarkdownOptions, 'format'>): ControlBuilder<TYPE>;
|
|
70
84
|
textArea(options?: Omit<TextAreaOptions, 'format'>): this;
|
|
71
|
-
autocomplete(options: Omit<AutocompleteOptions, 'format'>): this;
|
|
85
|
+
autocomplete(options: Omit<AutocompleteOptions, 'format'> | Omit<AutocompleteRemoteOptions, 'format'>): this;
|
|
86
|
+
control(format: string, options?: Partial<ControlOption>): this;
|
|
87
|
+
select(options: Omit<SelectOptions, 'format'>): this;
|
|
88
|
+
mutliSelect(options: Omit<SelectOptions, 'format'>): this;
|
|
72
89
|
width(width: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full'): this;
|
|
73
90
|
customLabel(label: string): this;
|
|
74
91
|
placeHolder(placeholder: string): this;
|
|
@@ -8,6 +8,7 @@ export declare const LayoutTypes: {
|
|
|
8
8
|
readonly HorizontalLayout: "HorizontalLayout";
|
|
9
9
|
readonly VerticalLayout: "VerticalLayout";
|
|
10
10
|
readonly CollapseLayout: "CollapseLayout";
|
|
11
|
+
readonly GridLayout: "GridLayout";
|
|
11
12
|
};
|
|
12
13
|
type _LayoutTypes = (typeof LayoutTypes)[keyof typeof LayoutTypes];
|
|
13
14
|
export type LayoutType = {
|
|
@@ -20,6 +21,7 @@ export declare class LayoutBuilder<TYPE> extends BuilderWithElements<LayoutType,
|
|
|
20
21
|
static horizontal<TYPE>(): LayoutBuilder<TYPE>;
|
|
21
22
|
static collapse<TYPE>(): LayoutBuilder<TYPE>;
|
|
22
23
|
static vertical<TYPE>(): LayoutBuilder<TYPE>;
|
|
24
|
+
static grid<TYPE>(): LayoutBuilder<TYPE>;
|
|
23
25
|
titleKey(titleKey: string): this;
|
|
24
26
|
title(title: string): this;
|
|
25
27
|
private addOptions;
|