@react-typed-forms/schemas 3.0.0-dev.98 → 4.0.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/.babelrc +4 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/operation/update-readme/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +581 -7
- package/README.md +292 -0
- package/lib/controlBuilder.d.ts +14 -0
- package/lib/controlRender.d.ts +96 -80
- package/lib/hooks.d.ts +9 -9
- package/lib/index.d.ts +5 -1
- package/lib/index.js +1835 -19
- package/lib/index.js.map +1 -0
- package/lib/renderers.d.ts +171 -0
- package/lib/schemaBuilder.d.ts +53 -70
- package/lib/tailwind.d.ts +2 -0
- package/lib/types.d.ts +108 -43
- package/lib/util.d.ts +35 -0
- package/lib/validators.d.ts +4 -0
- package/package.json +15 -8
- package/src/controlBuilder.ts +121 -0
- package/src/controlRender.tsx +533 -437
- package/src/hooks.tsx +153 -0
- package/src/index.ts +5 -1
- package/src/renderers.tsx +846 -0
- package/src/schemaBuilder.ts +45 -66
- package/src/tailwind.tsx +25 -0
- package/src/types.ts +164 -48
- package/src/util.ts +360 -0
- package/src/validators.ts +116 -0
- package/tsconfig.json +4 -3
- package/.rush/temp/package-deps_build.json +0 -13
- package/lib/controlRender.js +0 -230
- package/lib/hooks.js +0 -93
- package/lib/schemaBuilder.js +0 -82
- package/lib/types.js +0 -73
- package/schemas.build.log +0 -2
- package/src/hooks.ts +0 -167
package/src/util.ts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionControlDefinition,
|
|
3
|
+
CompoundField,
|
|
4
|
+
ControlDefinition,
|
|
5
|
+
ControlDefinitionType,
|
|
6
|
+
DataControlDefinition,
|
|
7
|
+
DataRenderType,
|
|
8
|
+
DisplayControlDefinition,
|
|
9
|
+
FieldOption,
|
|
10
|
+
FieldType,
|
|
11
|
+
GridRenderer,
|
|
12
|
+
GroupedControlsDefinition,
|
|
13
|
+
GroupRenderType,
|
|
14
|
+
SchemaField,
|
|
15
|
+
visitControlDefinition,
|
|
16
|
+
} from "./types";
|
|
17
|
+
import { MutableRefObject, useRef } from "react";
|
|
18
|
+
import { Control } from "@react-typed-forms/core";
|
|
19
|
+
|
|
20
|
+
export interface ControlGroupContext {
|
|
21
|
+
groupControl: Control<any>;
|
|
22
|
+
fields: SchemaField[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function applyDefaultValues(
|
|
26
|
+
v: { [k: string]: any } | undefined,
|
|
27
|
+
fields: SchemaField[],
|
|
28
|
+
): any {
|
|
29
|
+
if (!v) return defaultValueForFields(fields);
|
|
30
|
+
const applyValue = fields.filter(
|
|
31
|
+
(x) => isCompoundField(x) || !(x.field in v),
|
|
32
|
+
);
|
|
33
|
+
if (!applyValue.length) return v;
|
|
34
|
+
const out = { ...v };
|
|
35
|
+
applyValue.forEach((x) => {
|
|
36
|
+
out[x.field] =
|
|
37
|
+
x.field in v
|
|
38
|
+
? applyDefaultForField(v[x.field], x, fields)
|
|
39
|
+
: defaultValueForField(x);
|
|
40
|
+
});
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function applyDefaultForField(
|
|
45
|
+
v: any,
|
|
46
|
+
field: SchemaField,
|
|
47
|
+
parent: SchemaField[],
|
|
48
|
+
notElement?: boolean,
|
|
49
|
+
): any {
|
|
50
|
+
if (field.collection && !notElement) {
|
|
51
|
+
return ((v as any[]) ?? []).map((x) =>
|
|
52
|
+
applyDefaultForField(x, field, parent, true),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (isCompoundField(field)) {
|
|
56
|
+
if (!v && !field.required) return v;
|
|
57
|
+
return applyDefaultValues(v, field.treeChildren ? parent : field.children);
|
|
58
|
+
}
|
|
59
|
+
return defaultValueForField(field);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function defaultValueForFields(fields: SchemaField[]): any {
|
|
63
|
+
return Object.fromEntries(
|
|
64
|
+
fields.map((x) => [x.field, defaultValueForField(x)]),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function defaultValueForField(
|
|
69
|
+
sf: SchemaField,
|
|
70
|
+
required?: boolean | null,
|
|
71
|
+
): any {
|
|
72
|
+
if (sf.defaultValue !== undefined) return sf.defaultValue;
|
|
73
|
+
const isRequired = !!(required || sf.required);
|
|
74
|
+
if (isCompoundField(sf)) {
|
|
75
|
+
if (isRequired) {
|
|
76
|
+
const childValue = defaultValueForFields(sf.children);
|
|
77
|
+
return sf.collection ? [childValue] : childValue;
|
|
78
|
+
}
|
|
79
|
+
return sf.notNullable ? (sf.collection ? [] : {}) : undefined;
|
|
80
|
+
}
|
|
81
|
+
if (sf.collection) {
|
|
82
|
+
return isRequired ? [undefined] : [];
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function elementValueForField(sf: SchemaField): any {
|
|
88
|
+
if (isCompoundField(sf)) {
|
|
89
|
+
return defaultValueForFields(sf.children);
|
|
90
|
+
}
|
|
91
|
+
return sf.defaultValue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function findScalarField(
|
|
95
|
+
fields: SchemaField[],
|
|
96
|
+
field: string,
|
|
97
|
+
): SchemaField | undefined {
|
|
98
|
+
return findField(fields, field);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function findCompoundField(
|
|
102
|
+
fields: SchemaField[],
|
|
103
|
+
field: string,
|
|
104
|
+
): CompoundField | undefined {
|
|
105
|
+
return findField(fields, field) as CompoundField | undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function findField(
|
|
109
|
+
fields: SchemaField[],
|
|
110
|
+
field: string,
|
|
111
|
+
): SchemaField | undefined {
|
|
112
|
+
return fields.find((x) => x.field === field);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function isScalarField(sf: SchemaField): sf is SchemaField {
|
|
116
|
+
return !isCompoundField(sf);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function isCompoundField(sf: SchemaField): sf is CompoundField {
|
|
120
|
+
return sf.type === FieldType.Compound;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function isDataControl(
|
|
124
|
+
c: ControlDefinition,
|
|
125
|
+
): c is DataControlDefinition {
|
|
126
|
+
return c.type === ControlDefinitionType.Data;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function isGroupControl(
|
|
130
|
+
c: ControlDefinition,
|
|
131
|
+
): c is GroupedControlsDefinition {
|
|
132
|
+
return c.type === ControlDefinitionType.Group;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function fieldHasTag(field: SchemaField, tag: string) {
|
|
136
|
+
return Boolean(field.tags?.includes(tag));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function fieldDisplayName(field: SchemaField) {
|
|
140
|
+
return field.displayName ?? field.field;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function hasOptions(o: { options: FieldOption[] | undefined | null }) {
|
|
144
|
+
return (o.options?.length ?? 0) > 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function defaultControlForField(
|
|
148
|
+
sf: SchemaField,
|
|
149
|
+
): DataControlDefinition | GroupedControlsDefinition {
|
|
150
|
+
if (isCompoundField(sf)) {
|
|
151
|
+
return {
|
|
152
|
+
type: ControlDefinitionType.Group,
|
|
153
|
+
title: sf.displayName,
|
|
154
|
+
compoundField: sf.field,
|
|
155
|
+
groupOptions: {
|
|
156
|
+
type: GroupRenderType.Grid,
|
|
157
|
+
hideTitle: false,
|
|
158
|
+
} as GridRenderer,
|
|
159
|
+
children: sf.children.map(defaultControlForField),
|
|
160
|
+
} satisfies GroupedControlsDefinition;
|
|
161
|
+
} else if (isScalarField(sf)) {
|
|
162
|
+
const htmlEditor = sf.tags?.includes("_HtmlEditor");
|
|
163
|
+
return {
|
|
164
|
+
type: ControlDefinitionType.Data,
|
|
165
|
+
title: sf.displayName,
|
|
166
|
+
field: sf.field,
|
|
167
|
+
required: sf.required,
|
|
168
|
+
renderOptions: {
|
|
169
|
+
type: htmlEditor ? DataRenderType.HtmlEditor : DataRenderType.Standard,
|
|
170
|
+
},
|
|
171
|
+
} satisfies DataControlDefinition;
|
|
172
|
+
}
|
|
173
|
+
throw "Unknown schema field";
|
|
174
|
+
}
|
|
175
|
+
function findReferencedControl(
|
|
176
|
+
field: string,
|
|
177
|
+
control: ControlDefinition,
|
|
178
|
+
): ControlDefinition | undefined {
|
|
179
|
+
if (isDataControl(control) && field === control.field) return control;
|
|
180
|
+
if (isGroupControl(control)) {
|
|
181
|
+
if (control.compoundField)
|
|
182
|
+
return field === control.compoundField ? control : undefined;
|
|
183
|
+
return findReferencedControlInArray(field, control.children ?? []);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function findReferencedControlInArray(
|
|
189
|
+
field: string,
|
|
190
|
+
controls: ControlDefinition[],
|
|
191
|
+
): ControlDefinition | undefined {
|
|
192
|
+
for (const c of controls) {
|
|
193
|
+
const ref = findReferencedControl(field, c);
|
|
194
|
+
if (ref) return ref;
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export function addMissingControls(
|
|
200
|
+
fields: SchemaField[],
|
|
201
|
+
controls: ControlDefinition[],
|
|
202
|
+
): ControlDefinition[] {
|
|
203
|
+
const changes: {
|
|
204
|
+
field: SchemaField;
|
|
205
|
+
existing: ControlDefinition | undefined;
|
|
206
|
+
}[] = fields.flatMap((x) => {
|
|
207
|
+
if (fieldHasTag(x, "_NoControl")) return [];
|
|
208
|
+
const existing = findReferencedControlInArray(x.field, controls);
|
|
209
|
+
if (!existing || isCompoundField(x)) return { field: x, existing };
|
|
210
|
+
return [];
|
|
211
|
+
});
|
|
212
|
+
const changedCompounds = controls.map((x) => {
|
|
213
|
+
const ex = changes.find((c) => c.existing === x);
|
|
214
|
+
if (!ex) return x;
|
|
215
|
+
const cf = x as GroupedControlsDefinition;
|
|
216
|
+
return {
|
|
217
|
+
...cf,
|
|
218
|
+
children: addMissingControls(
|
|
219
|
+
(ex.field as CompoundField).children,
|
|
220
|
+
cf.children ?? [],
|
|
221
|
+
),
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
return changedCompounds.concat(
|
|
225
|
+
changes
|
|
226
|
+
.filter((x) => !x.existing)
|
|
227
|
+
.map((x) => defaultControlForField(x.field)),
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function useUpdatedRef<A>(a: A): MutableRefObject<A> {
|
|
232
|
+
const r = useRef(a);
|
|
233
|
+
r.current = a;
|
|
234
|
+
return r;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function getTypeField(
|
|
238
|
+
context: ControlGroupContext,
|
|
239
|
+
): Control<string> | undefined {
|
|
240
|
+
const typeSchemaField = context.fields.find((x) => x.isTypeField);
|
|
241
|
+
return typeSchemaField
|
|
242
|
+
? context.groupControl.fields?.[typeSchemaField.field]
|
|
243
|
+
: undefined;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function visitControlDataArray<A>(
|
|
247
|
+
controls: ControlDefinition[] | undefined | null,
|
|
248
|
+
context: ControlGroupContext,
|
|
249
|
+
cb: (
|
|
250
|
+
definition: DataControlDefinition,
|
|
251
|
+
field: SchemaField,
|
|
252
|
+
control: Control<any>,
|
|
253
|
+
element: boolean,
|
|
254
|
+
) => A | undefined,
|
|
255
|
+
): A | undefined {
|
|
256
|
+
if (!controls) return undefined;
|
|
257
|
+
for (const c of controls) {
|
|
258
|
+
const r = visitControlData(c, context, cb);
|
|
259
|
+
if (r !== undefined) return r;
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function visitControlData<A>(
|
|
265
|
+
definition: ControlDefinition,
|
|
266
|
+
ctx: ControlGroupContext,
|
|
267
|
+
cb: (
|
|
268
|
+
definition: DataControlDefinition,
|
|
269
|
+
field: SchemaField,
|
|
270
|
+
control: Control<any>,
|
|
271
|
+
element: boolean,
|
|
272
|
+
) => A | undefined,
|
|
273
|
+
): A | undefined {
|
|
274
|
+
return visitControlDefinition<A | undefined>(
|
|
275
|
+
definition,
|
|
276
|
+
{
|
|
277
|
+
data(def: DataControlDefinition) {
|
|
278
|
+
return processData(def, def.field, def.children);
|
|
279
|
+
},
|
|
280
|
+
group(d: GroupedControlsDefinition) {
|
|
281
|
+
return processData(undefined, d.compoundField, d.children);
|
|
282
|
+
},
|
|
283
|
+
action: () => undefined,
|
|
284
|
+
display: () => undefined,
|
|
285
|
+
},
|
|
286
|
+
() => undefined,
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
function processData(
|
|
290
|
+
def: DataControlDefinition | undefined,
|
|
291
|
+
fieldName: string | undefined | null,
|
|
292
|
+
children: ControlDefinition[] | null | undefined,
|
|
293
|
+
) {
|
|
294
|
+
const fieldData = fieldName ? findField(ctx.fields, fieldName) : undefined;
|
|
295
|
+
if (!fieldData)
|
|
296
|
+
return !fieldName ? visitControlDataArray(children, ctx, cb) : undefined;
|
|
297
|
+
|
|
298
|
+
const control = ctx.groupControl.fields[fieldData.field];
|
|
299
|
+
const result = def ? cb(def, fieldData, control, false) : undefined;
|
|
300
|
+
if (result !== undefined) return result;
|
|
301
|
+
if (fieldData.collection) {
|
|
302
|
+
for (const c of control.elements ?? []) {
|
|
303
|
+
const elemResult = def ? cb(def, fieldData, c, true) : undefined;
|
|
304
|
+
if (elemResult !== undefined) return elemResult;
|
|
305
|
+
if (isCompoundField(fieldData)) {
|
|
306
|
+
const cfResult = visitControlDataArray(
|
|
307
|
+
children,
|
|
308
|
+
{ fields: fieldData.children, groupControl: c },
|
|
309
|
+
cb,
|
|
310
|
+
);
|
|
311
|
+
if (cfResult !== undefined) return cfResult;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function cleanDataForSchema(
|
|
319
|
+
v: { [k: string]: any } | undefined,
|
|
320
|
+
fields: SchemaField[],
|
|
321
|
+
): any {
|
|
322
|
+
if (!v) return v;
|
|
323
|
+
const typeField = fields.find((x) => x.isTypeField);
|
|
324
|
+
if (!typeField) return v;
|
|
325
|
+
const typeValue = v[typeField.field];
|
|
326
|
+
const cleanableFields = fields.filter(
|
|
327
|
+
(x) => isCompoundField(x) || (x.onlyForTypes?.length ?? 0) > 0,
|
|
328
|
+
);
|
|
329
|
+
if (!cleanableFields.length) return v;
|
|
330
|
+
const out = { ...v };
|
|
331
|
+
cleanableFields.forEach((x) => {
|
|
332
|
+
const childValue = v[x.field];
|
|
333
|
+
if (
|
|
334
|
+
x.onlyForTypes?.includes(typeValue) === false ||
|
|
335
|
+
(!x.notNullable && canBeNull())
|
|
336
|
+
) {
|
|
337
|
+
delete out[x.field];
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (isCompoundField(x)) {
|
|
341
|
+
const childFields = x.treeChildren ? fields : x.children;
|
|
342
|
+
if (x.collection) {
|
|
343
|
+
if (Array.isArray(childValue)) {
|
|
344
|
+
out[x.field] = childValue.map((cv) =>
|
|
345
|
+
cleanDataForSchema(cv, childFields),
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
} else {
|
|
349
|
+
out[x.field] = cleanDataForSchema(childValue, childFields);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function canBeNull() {
|
|
353
|
+
return (
|
|
354
|
+
x.collection && Array.isArray(childValue) && !childValue.length
|
|
355
|
+
//|| (x.type === FieldType.Bool && childValue === false)
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
return out;
|
|
360
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlDefinition,
|
|
3
|
+
DataControlDefinition,
|
|
4
|
+
DateComparison,
|
|
5
|
+
DateValidator,
|
|
6
|
+
isDataControlDefinition,
|
|
7
|
+
JsonataValidator,
|
|
8
|
+
ValidatorType,
|
|
9
|
+
} from "./types";
|
|
10
|
+
import {
|
|
11
|
+
Control,
|
|
12
|
+
useControlEffect,
|
|
13
|
+
useValidator,
|
|
14
|
+
useValueChangeEffect,
|
|
15
|
+
} from "@react-typed-forms/core";
|
|
16
|
+
import { useCallback } from "react";
|
|
17
|
+
import { ControlGroupContext, useUpdatedRef } from "./util";
|
|
18
|
+
import { useJsonataExpression } from "./hooks";
|
|
19
|
+
|
|
20
|
+
export function useValidationHook(
|
|
21
|
+
definition: ControlDefinition,
|
|
22
|
+
): (
|
|
23
|
+
control: Control<any>,
|
|
24
|
+
hidden: boolean,
|
|
25
|
+
groupContext: ControlGroupContext,
|
|
26
|
+
) => void {
|
|
27
|
+
const validatorTypes = isDataControlDefinition(definition)
|
|
28
|
+
? definition.validators?.map((x) => x.type) ?? []
|
|
29
|
+
: null;
|
|
30
|
+
const r = useUpdatedRef(definition as DataControlDefinition);
|
|
31
|
+
return useCallback(
|
|
32
|
+
(control, hidden, groupContext) => {
|
|
33
|
+
if (!validatorTypes) return;
|
|
34
|
+
const dd = r.current;
|
|
35
|
+
|
|
36
|
+
useValueChangeEffect(control, () => control.setError("default", ""));
|
|
37
|
+
useValidator(
|
|
38
|
+
control,
|
|
39
|
+
(v) =>
|
|
40
|
+
!hidden &&
|
|
41
|
+
dd.required &&
|
|
42
|
+
(v == null || v === "" || (Array.isArray(v) && v.length === 0))
|
|
43
|
+
? "Please enter a value"
|
|
44
|
+
: null,
|
|
45
|
+
"required",
|
|
46
|
+
);
|
|
47
|
+
(dd.validators ?? []).forEach((x, i) => {
|
|
48
|
+
switch (x.type) {
|
|
49
|
+
case ValidatorType.Jsonata:
|
|
50
|
+
return useJsonataValidator(
|
|
51
|
+
control,
|
|
52
|
+
groupContext,
|
|
53
|
+
x as JsonataValidator,
|
|
54
|
+
hidden,
|
|
55
|
+
i,
|
|
56
|
+
);
|
|
57
|
+
case ValidatorType.Date:
|
|
58
|
+
return useDateValidator(control, x as DateValidator, i);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
validatorTypes ? validatorTypes : [null],
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function useJsonataValidator(
|
|
67
|
+
control: Control<any>,
|
|
68
|
+
context: ControlGroupContext,
|
|
69
|
+
expr: JsonataValidator,
|
|
70
|
+
hidden: boolean,
|
|
71
|
+
i: number,
|
|
72
|
+
) {
|
|
73
|
+
const errorMsg = useJsonataExpression(expr.expression, context.groupControl);
|
|
74
|
+
useControlEffect(
|
|
75
|
+
() => [hidden, errorMsg.value],
|
|
76
|
+
([hidden, msg]) => control.setError("jsonata" + i, !hidden ? msg : null),
|
|
77
|
+
true,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function useDateValidator(
|
|
82
|
+
control: Control<string | null | undefined>,
|
|
83
|
+
dv: DateValidator,
|
|
84
|
+
i: number,
|
|
85
|
+
) {
|
|
86
|
+
let comparisonDate: number;
|
|
87
|
+
if (dv.fixedDate) {
|
|
88
|
+
comparisonDate = Date.parse(dv.fixedDate);
|
|
89
|
+
} else {
|
|
90
|
+
const nowDate = new Date();
|
|
91
|
+
comparisonDate = Date.UTC(
|
|
92
|
+
nowDate.getFullYear(),
|
|
93
|
+
nowDate.getMonth(),
|
|
94
|
+
nowDate.getDate(),
|
|
95
|
+
);
|
|
96
|
+
if (dv.daysFromCurrent) {
|
|
97
|
+
comparisonDate += dv.daysFromCurrent * 86400000;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
useValidator(
|
|
101
|
+
control,
|
|
102
|
+
(v) => {
|
|
103
|
+
if (v) {
|
|
104
|
+
const selDate = Date.parse(v);
|
|
105
|
+
const notAfter = dv.comparison === DateComparison.NotAfter;
|
|
106
|
+
if (notAfter ? selDate > comparisonDate : selDate < comparisonDate) {
|
|
107
|
+
return `Date must not be ${notAfter ? "after" : "before"} ${new Date(
|
|
108
|
+
comparisonDate,
|
|
109
|
+
).toDateString()}`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
},
|
|
114
|
+
"date" + i,
|
|
115
|
+
);
|
|
116
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ESNext",
|
|
4
4
|
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
5
|
"allowJs": true,
|
|
6
6
|
"skipLibCheck": true,
|
|
7
7
|
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
8
9
|
"forceConsistentCasingInFileNames": true,
|
|
9
10
|
"esModuleInterop": true,
|
|
10
11
|
"declaration": true,
|
|
11
|
-
"module": "
|
|
12
|
+
"module": "ESNext",
|
|
12
13
|
"moduleResolution": "node",
|
|
13
14
|
"resolveJsonModule": true,
|
|
14
15
|
"isolatedModules": true,
|
|
15
|
-
"jsx": "
|
|
16
|
+
"jsx": "preserve",
|
|
16
17
|
"outDir": "lib"
|
|
17
18
|
},
|
|
18
19
|
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/schemas/.rush/temp/shrinkwrap-deps.json": "5ce6417fae765db5c61e400f851ecafe0ce756f0",
|
|
4
|
-
"packages/schemas/package.json": "bf139da03e9c398c9ef59a9dcf3a4ba25e92c2bb",
|
|
5
|
-
"packages/schemas/src/controlRender.tsx": "b54a8e7ad36207ccd6684c30af2027789d9f806d",
|
|
6
|
-
"packages/schemas/src/hooks.ts": "a34545b7c63dc78ea77974f6c2fc386daaee80ea",
|
|
7
|
-
"packages/schemas/src/index.ts": "b15fbb6de132cd912cf8141d5c4d2329e947546e",
|
|
8
|
-
"packages/schemas/src/schemaBuilder.ts": "4662698fd46ac14459f429ce24d919ef91992de2",
|
|
9
|
-
"packages/schemas/src/types.ts": "0f55d35f7e4b052a01bc433799647d8288e237ab",
|
|
10
|
-
"packages/schemas/tsconfig.json": "52e4f044fa580f4e0ad5830f3cfca574e2788372"
|
|
11
|
-
},
|
|
12
|
-
"arguments": "rimraf ./lib/ && tsc "
|
|
13
|
-
}
|