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