@contember/react-form 1.3.0-alpha.14
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/dist/development/components/FormCheckbox.cjs +68 -0
- package/dist/development/components/FormCheckbox.cjs.map +1 -0
- package/dist/development/components/FormCheckbox.js +52 -0
- package/dist/development/components/FormCheckbox.js.map +1 -0
- package/dist/development/components/FormError.cjs +22 -0
- package/dist/development/components/FormError.cjs.map +1 -0
- package/dist/development/components/FormError.js +22 -0
- package/dist/development/components/FormError.js.map +1 -0
- package/dist/development/components/FormFieldScope.cjs +15 -0
- package/dist/development/components/FormFieldScope.cjs.map +1 -0
- package/dist/development/components/FormFieldScope.js +15 -0
- package/dist/development/components/FormFieldScope.js.map +1 -0
- package/dist/development/components/FormHasManyRelationScope.cjs +15 -0
- package/dist/development/components/FormHasManyRelationScope.cjs.map +1 -0
- package/dist/development/components/FormHasManyRelationScope.js +15 -0
- package/dist/development/components/FormHasManyRelationScope.js.map +1 -0
- package/dist/development/components/FormHasOneRelationScope.cjs +15 -0
- package/dist/development/components/FormHasOneRelationScope.cjs.map +1 -0
- package/dist/development/components/FormHasOneRelationScope.js +15 -0
- package/dist/development/components/FormHasOneRelationScope.js.map +1 -0
- package/dist/development/components/FormInput.cjs +40 -0
- package/dist/development/components/FormInput.cjs.map +1 -0
- package/dist/development/components/FormInput.js +40 -0
- package/dist/development/components/FormInput.js.map +1 -0
- package/dist/development/components/FormLabel.cjs +24 -0
- package/dist/development/components/FormLabel.cjs.map +1 -0
- package/dist/development/components/FormLabel.js +24 -0
- package/dist/development/components/FormLabel.js.map +1 -0
- package/dist/development/components/FormRadioInput.cjs +39 -0
- package/dist/development/components/FormRadioInput.cjs.map +1 -0
- package/dist/development/components/FormRadioInput.js +39 -0
- package/dist/development/components/FormRadioInput.js.map +1 -0
- package/dist/development/contexts.cjs +14 -0
- package/dist/development/contexts.cjs.map +1 -0
- package/dist/development/contexts.js +14 -0
- package/dist/development/contexts.js.map +1 -0
- package/dist/development/hooks/useFormInputValidationHandler.cjs +64 -0
- package/dist/development/hooks/useFormInputValidationHandler.cjs.map +1 -0
- package/dist/development/hooks/useFormInputValidationHandler.js +48 -0
- package/dist/development/hooks/useFormInputValidationHandler.js.map +1 -0
- package/dist/development/index.cjs +26 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +26 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/internal/useFormInputHandler.cjs +98 -0
- package/dist/development/internal/useFormInputHandler.cjs.map +1 -0
- package/dist/development/internal/useFormInputHandler.js +98 -0
- package/dist/development/internal/useFormInputHandler.js.map +1 -0
- package/dist/production/components/FormCheckbox.cjs +68 -0
- package/dist/production/components/FormCheckbox.cjs.map +1 -0
- package/dist/production/components/FormCheckbox.js +52 -0
- package/dist/production/components/FormCheckbox.js.map +1 -0
- package/dist/production/components/FormError.cjs +22 -0
- package/dist/production/components/FormError.cjs.map +1 -0
- package/dist/production/components/FormError.js +22 -0
- package/dist/production/components/FormError.js.map +1 -0
- package/dist/production/components/FormFieldScope.cjs +15 -0
- package/dist/production/components/FormFieldScope.cjs.map +1 -0
- package/dist/production/components/FormFieldScope.js +15 -0
- package/dist/production/components/FormFieldScope.js.map +1 -0
- package/dist/production/components/FormHasManyRelationScope.cjs +15 -0
- package/dist/production/components/FormHasManyRelationScope.cjs.map +1 -0
- package/dist/production/components/FormHasManyRelationScope.js +15 -0
- package/dist/production/components/FormHasManyRelationScope.js.map +1 -0
- package/dist/production/components/FormHasOneRelationScope.cjs +15 -0
- package/dist/production/components/FormHasOneRelationScope.cjs.map +1 -0
- package/dist/production/components/FormHasOneRelationScope.js +15 -0
- package/dist/production/components/FormHasOneRelationScope.js.map +1 -0
- package/dist/production/components/FormInput.cjs +40 -0
- package/dist/production/components/FormInput.cjs.map +1 -0
- package/dist/production/components/FormInput.js +40 -0
- package/dist/production/components/FormInput.js.map +1 -0
- package/dist/production/components/FormLabel.cjs +24 -0
- package/dist/production/components/FormLabel.cjs.map +1 -0
- package/dist/production/components/FormLabel.js +24 -0
- package/dist/production/components/FormLabel.js.map +1 -0
- package/dist/production/components/FormRadioInput.cjs +39 -0
- package/dist/production/components/FormRadioInput.cjs.map +1 -0
- package/dist/production/components/FormRadioInput.js +39 -0
- package/dist/production/components/FormRadioInput.js.map +1 -0
- package/dist/production/contexts.cjs +14 -0
- package/dist/production/contexts.cjs.map +1 -0
- package/dist/production/contexts.js +14 -0
- package/dist/production/contexts.js.map +1 -0
- package/dist/production/hooks/useFormInputValidationHandler.cjs +64 -0
- package/dist/production/hooks/useFormInputValidationHandler.cjs.map +1 -0
- package/dist/production/hooks/useFormInputValidationHandler.js +48 -0
- package/dist/production/hooks/useFormInputValidationHandler.js.map +1 -0
- package/dist/production/index.cjs +26 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +26 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/internal/useFormInputHandler.cjs +98 -0
- package/dist/production/internal/useFormInputHandler.cjs.map +1 -0
- package/dist/production/internal/useFormInputHandler.js +98 -0
- package/dist/production/internal/useFormInputHandler.js.map +1 -0
- package/dist/types/components/FormCheckbox.d.ts +11 -0
- package/dist/types/components/FormCheckbox.d.ts.map +1 -0
- package/dist/types/components/FormError.d.ts +7 -0
- package/dist/types/components/FormError.d.ts.map +1 -0
- package/dist/types/components/FormFieldScope.d.ts +8 -0
- package/dist/types/components/FormFieldScope.d.ts.map +1 -0
- package/dist/types/components/FormHasManyRelationScope.d.ts +8 -0
- package/dist/types/components/FormHasManyRelationScope.d.ts.map +1 -0
- package/dist/types/components/FormHasOneRelationScope.d.ts +8 -0
- package/dist/types/components/FormHasOneRelationScope.d.ts.map +1 -0
- package/dist/types/components/FormInput.d.ts +10 -0
- package/dist/types/components/FormInput.d.ts.map +1 -0
- package/dist/types/components/FormLabel.d.ts +5 -0
- package/dist/types/components/FormLabel.d.ts.map +1 -0
- package/dist/types/components/FormRadioInput.d.ts +11 -0
- package/dist/types/components/FormRadioInput.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +9 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/contexts.d.ts +8 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useFormInputValidationHandler.d.ts +8 -0
- package/dist/types/hooks/useFormInputValidationHandler.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/internal/useFormInputHandler.d.ts +8 -0
- package/dist/types/internal/useFormInputHandler.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +57 -0
- package/src/components/FormCheckbox.tsx +58 -0
- package/src/components/FormError.tsx +22 -0
- package/src/components/FormFieldScope.tsx +24 -0
- package/src/components/FormHasManyRelationScope.tsx +24 -0
- package/src/components/FormHasOneRelationScope.tsx +24 -0
- package/src/components/FormInput.tsx +46 -0
- package/src/components/FormLabel.tsx +22 -0
- package/src/components/FormRadioInput.tsx +45 -0
- package/src/components/index.ts +8 -0
- package/src/contexts.ts +12 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useFormInputValidationHandler.tsx +47 -0
- package/src/index.ts +3 -0
- package/src/internal/useFormInputHandler.ts +104 -0
- package/src/tsconfig.json +11 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const useFormInputHandler = (field) => {
|
|
5
|
+
return React.useMemo(() => {
|
|
6
|
+
const schema = field.schema;
|
|
7
|
+
const columnType = schema.type;
|
|
8
|
+
const handlerFactory = ColumnTypeHandlerFactories[columnType];
|
|
9
|
+
if (!handlerFactory) {
|
|
10
|
+
throw new Error(`Column type ${columnType} is not supported yet`);
|
|
11
|
+
}
|
|
12
|
+
return handlerFactory(schema, field.getAccessor);
|
|
13
|
+
}, [field.getAccessor, field.schema]);
|
|
14
|
+
};
|
|
15
|
+
const ColumnTypeHandlerFactories = {
|
|
16
|
+
Integer: () => ({
|
|
17
|
+
parseValue: (value) => {
|
|
18
|
+
if (value === "") {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const parsed = parseInt(value, 10);
|
|
22
|
+
return isNaN(parsed) ? null : parsed;
|
|
23
|
+
},
|
|
24
|
+
formatValue: (value) => {
|
|
25
|
+
return value === null ? "" : value.toString(10);
|
|
26
|
+
},
|
|
27
|
+
defaultInputProps: {
|
|
28
|
+
type: "number"
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
Double: () => ({
|
|
32
|
+
parseValue: (value) => {
|
|
33
|
+
if (value === "") {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const parsed = parseFloat(value);
|
|
37
|
+
return isNaN(parsed) ? null : parsed;
|
|
38
|
+
},
|
|
39
|
+
formatValue: (value) => {
|
|
40
|
+
return value === null ? "" : value.toString(10);
|
|
41
|
+
},
|
|
42
|
+
defaultInputProps: {
|
|
43
|
+
type: "number"
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
String: (schema, field) => ({
|
|
47
|
+
parseValue: (value) => {
|
|
48
|
+
if (value === "" && schema.nullable && field().valueOnServer === null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return value;
|
|
52
|
+
},
|
|
53
|
+
formatValue: (value) => value ?? ""
|
|
54
|
+
}),
|
|
55
|
+
Date: () => ({
|
|
56
|
+
parseValue: (value) => {
|
|
57
|
+
if (value === "") {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const parsed = Date.parse(value);
|
|
61
|
+
return isNaN(parsed) ? null : new Date(parsed);
|
|
62
|
+
},
|
|
63
|
+
formatValue: (value) => {
|
|
64
|
+
const parsed = value ? Date.parse(value) : null;
|
|
65
|
+
return !parsed || isNaN(parsed) ? "" : new Date(parsed).toISOString().split("T")[0];
|
|
66
|
+
},
|
|
67
|
+
defaultInputProps: {
|
|
68
|
+
type: "date"
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
DateTime: () => ({
|
|
72
|
+
parseValue: (value) => {
|
|
73
|
+
if (value === "") {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const parsed = Date.parse(value);
|
|
77
|
+
return isNaN(parsed) ? null : new Date(parsed);
|
|
78
|
+
},
|
|
79
|
+
formatValue: (value) => {
|
|
80
|
+
const parsed = value ? Date.parse(value) : null;
|
|
81
|
+
return !parsed || isNaN(parsed) ? "" : new Date(parsed).toISOString().substring(0, 16);
|
|
82
|
+
},
|
|
83
|
+
defaultInputProps: {
|
|
84
|
+
type: "datetime-local"
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
Bool: () => {
|
|
88
|
+
throw new Error("Boolean column type is not supported yet");
|
|
89
|
+
},
|
|
90
|
+
Enum: () => {
|
|
91
|
+
throw new Error("Enum column type is not supported yet");
|
|
92
|
+
},
|
|
93
|
+
Uuid: () => {
|
|
94
|
+
throw new Error("UUID column type is not supported yet");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.useFormInputHandler = useFormInputHandler;
|
|
98
|
+
//# sourceMappingURL=useFormInputHandler.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormInputHandler.cjs","sources":["../../../src/internal/useFormInputHandler.ts"],"sourcesContent":["import { FieldAccessor, SchemaColumn, SchemaKnownColumnType } from '@contember/react-binding'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nexport const useFormInputHandler = (field: FieldAccessor) => {\n\treturn useMemo(() => {\n\t\tconst schema = field.schema\n\t\tconst columnType = schema.type\n\t\tconst handlerFactory = ColumnTypeHandlerFactories[columnType as SchemaKnownColumnType]\n\t\tif (!handlerFactory) {\n\t\t\tthrow new Error(`Column type ${columnType} is not supported yet`)\n\t\t}\n\t\treturn handlerFactory(schema, field.getAccessor)\n\t}, [field.getAccessor, field.schema])\n}\n\ntype ColumnTypeHandlerFactory = (column: SchemaColumn, getAccessor: FieldAccessor.GetFieldAccessor) => {\n\tparseValue: (value: string) => any\n\tformatValue: (value: any) => string\n\tdefaultInputProps?: React.InputHTMLAttributes<HTMLInputElement>\n}\n\nconst ColumnTypeHandlerFactories: Record<SchemaKnownColumnType, ColumnTypeHandlerFactory> = {\n\tInteger: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseInt(value, 10)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tDouble: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseFloat(value)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tString: (schema, field) => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '' && schema.nullable && field().valueOnServer === null) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn value\n\t\t},\n\t\tformatValue: (value: string | null) => value ?? '',\n\t}),\n\tDate: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : new Date(parsed)\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().split('T')[0]\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'date',\n\t\t},\n\t}),\n\tDateTime: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : new Date(parsed)\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().substring(0, 16)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'datetime-local',\n\t\t},\n\t}),\n\tBool: () => {\n\t\tthrow new Error('Boolean column type is not supported yet')\n\t},\n\tEnum: () => {\n\t\tthrow new Error('Enum column type is not supported yet')\n\t},\n\tUuid: () => {\n\t\tthrow new Error('UUID column type is not supported yet')\n\t},\n}\n"],"names":["useMemo"],"mappings":"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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const useFormInputHandler = (field) => {
|
|
3
|
+
return useMemo(() => {
|
|
4
|
+
const schema = field.schema;
|
|
5
|
+
const columnType = schema.type;
|
|
6
|
+
const handlerFactory = ColumnTypeHandlerFactories[columnType];
|
|
7
|
+
if (!handlerFactory) {
|
|
8
|
+
throw new Error(`Column type ${columnType} is not supported yet`);
|
|
9
|
+
}
|
|
10
|
+
return handlerFactory(schema, field.getAccessor);
|
|
11
|
+
}, [field.getAccessor, field.schema]);
|
|
12
|
+
};
|
|
13
|
+
const ColumnTypeHandlerFactories = {
|
|
14
|
+
Integer: () => ({
|
|
15
|
+
parseValue: (value) => {
|
|
16
|
+
if (value === "") {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const parsed = parseInt(value, 10);
|
|
20
|
+
return isNaN(parsed) ? null : parsed;
|
|
21
|
+
},
|
|
22
|
+
formatValue: (value) => {
|
|
23
|
+
return value === null ? "" : value.toString(10);
|
|
24
|
+
},
|
|
25
|
+
defaultInputProps: {
|
|
26
|
+
type: "number"
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
Double: () => ({
|
|
30
|
+
parseValue: (value) => {
|
|
31
|
+
if (value === "") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const parsed = parseFloat(value);
|
|
35
|
+
return isNaN(parsed) ? null : parsed;
|
|
36
|
+
},
|
|
37
|
+
formatValue: (value) => {
|
|
38
|
+
return value === null ? "" : value.toString(10);
|
|
39
|
+
},
|
|
40
|
+
defaultInputProps: {
|
|
41
|
+
type: "number"
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
String: (schema, field) => ({
|
|
45
|
+
parseValue: (value) => {
|
|
46
|
+
if (value === "" && schema.nullable && field().valueOnServer === null) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
formatValue: (value) => value ?? ""
|
|
52
|
+
}),
|
|
53
|
+
Date: () => ({
|
|
54
|
+
parseValue: (value) => {
|
|
55
|
+
if (value === "") {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const parsed = Date.parse(value);
|
|
59
|
+
return isNaN(parsed) ? null : new Date(parsed);
|
|
60
|
+
},
|
|
61
|
+
formatValue: (value) => {
|
|
62
|
+
const parsed = value ? Date.parse(value) : null;
|
|
63
|
+
return !parsed || isNaN(parsed) ? "" : new Date(parsed).toISOString().split("T")[0];
|
|
64
|
+
},
|
|
65
|
+
defaultInputProps: {
|
|
66
|
+
type: "date"
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
DateTime: () => ({
|
|
70
|
+
parseValue: (value) => {
|
|
71
|
+
if (value === "") {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const parsed = Date.parse(value);
|
|
75
|
+
return isNaN(parsed) ? null : new Date(parsed);
|
|
76
|
+
},
|
|
77
|
+
formatValue: (value) => {
|
|
78
|
+
const parsed = value ? Date.parse(value) : null;
|
|
79
|
+
return !parsed || isNaN(parsed) ? "" : new Date(parsed).toISOString().substring(0, 16);
|
|
80
|
+
},
|
|
81
|
+
defaultInputProps: {
|
|
82
|
+
type: "datetime-local"
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
Bool: () => {
|
|
86
|
+
throw new Error("Boolean column type is not supported yet");
|
|
87
|
+
},
|
|
88
|
+
Enum: () => {
|
|
89
|
+
throw new Error("Enum column type is not supported yet");
|
|
90
|
+
},
|
|
91
|
+
Uuid: () => {
|
|
92
|
+
throw new Error("UUID column type is not supported yet");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
export {
|
|
96
|
+
useFormInputHandler
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=useFormInputHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormInputHandler.js","sources":["../../../src/internal/useFormInputHandler.ts"],"sourcesContent":["import { FieldAccessor, SchemaColumn, SchemaKnownColumnType } from '@contember/react-binding'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nexport const useFormInputHandler = (field: FieldAccessor) => {\n\treturn useMemo(() => {\n\t\tconst schema = field.schema\n\t\tconst columnType = schema.type\n\t\tconst handlerFactory = ColumnTypeHandlerFactories[columnType as SchemaKnownColumnType]\n\t\tif (!handlerFactory) {\n\t\t\tthrow new Error(`Column type ${columnType} is not supported yet`)\n\t\t}\n\t\treturn handlerFactory(schema, field.getAccessor)\n\t}, [field.getAccessor, field.schema])\n}\n\ntype ColumnTypeHandlerFactory = (column: SchemaColumn, getAccessor: FieldAccessor.GetFieldAccessor) => {\n\tparseValue: (value: string) => any\n\tformatValue: (value: any) => string\n\tdefaultInputProps?: React.InputHTMLAttributes<HTMLInputElement>\n}\n\nconst ColumnTypeHandlerFactories: Record<SchemaKnownColumnType, ColumnTypeHandlerFactory> = {\n\tInteger: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseInt(value, 10)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tDouble: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = parseFloat(value)\n\t\t\treturn isNaN(parsed) ? null : parsed\n\t\t},\n\t\tformatValue: (value: number | null) => {\n\t\t\treturn value === null ? '' : value.toString(10)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'number',\n\t\t},\n\t}),\n\tString: (schema, field) => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '' && schema.nullable && field().valueOnServer === null) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn value\n\t\t},\n\t\tformatValue: (value: string | null) => value ?? '',\n\t}),\n\tDate: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : new Date(parsed)\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().split('T')[0]\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'date',\n\t\t},\n\t}),\n\tDateTime: () => ({\n\t\tparseValue: (value: string) => {\n\t\t\tif (value === '') {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tconst parsed = Date.parse(value)\n\t\t\treturn isNaN(parsed) ? null : new Date(parsed)\n\t\t},\n\t\tformatValue: (value: string | null) => {\n\t\t\tconst parsed = value ? Date.parse(value) : null\n\t\t\treturn !parsed || isNaN(parsed) ? '' : new Date(parsed).toISOString().substring(0, 16)\n\t\t},\n\t\tdefaultInputProps: {\n\t\t\ttype: 'datetime-local',\n\t\t},\n\t}),\n\tBool: () => {\n\t\tthrow new Error('Boolean column type is not supported yet')\n\t},\n\tEnum: () => {\n\t\tthrow new Error('Enum column type is not supported yet')\n\t},\n\tUuid: () => {\n\t\tthrow new Error('UUID column type is not supported yet')\n\t},\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { OptionallyVariableFieldValue, SugaredRelativeSingleField } from '@contember/react-binding';
|
|
4
|
+
export interface FormCheckboxProps {
|
|
5
|
+
field: SugaredRelativeSingleField['field'];
|
|
6
|
+
isNonbearing?: boolean;
|
|
7
|
+
defaultValue?: OptionallyVariableFieldValue;
|
|
8
|
+
children: ReactElement<HTMLInputElement, 'input'>;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormCheckbox: React.NamedExoticComponent<FormCheckboxProps>;
|
|
11
|
+
//# sourceMappingURL=FormCheckbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormCheckbox.d.ts","sourceRoot":"","sources":["../../../src/components/FormCheckbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAsB,YAAY,EAA0B,MAAM,OAAO,CAAA;AAChF,OAAO,EAAoB,4BAA4B,EAAE,0BAA0B,EAAwC,MAAM,0BAA0B,CAAA;AAQ3J,MAAM,WAAW,iBAAiB;IACjC,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,CAAC,EAAE,4BAA4B,CAAA;IAC3C,QAAQ,EAAE,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;CACjD;AAED,eAAO,MAAM,YAAY,+CAwCvB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ErrorAccessor } from '@contember/react-binding';
|
|
3
|
+
export declare const FormError: ({ children, formatter }: {
|
|
4
|
+
formatter: (errors: ErrorAccessor.Error[]) => ReactNode[];
|
|
5
|
+
children: ReactElement;
|
|
6
|
+
}) => ReactElement<any, string | import("react").JSXElementConstructor<any>>[];
|
|
7
|
+
//# sourceMappingURL=FormError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormError.d.ts","sourceRoot":"","sources":["../../../src/components/FormError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAA;AAEtE,OAAO,EAAgB,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAEtE,eAAO,MAAM,SAAS;wBACD,mBAAmB,EAAE,KAAK,SAAS,EAAE;cAC/C,YAAY;8EAetB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SugaredRelativeSingleField } from '@contember/react-binding';
|
|
3
|
+
export type FormFieldScopeProps = {
|
|
4
|
+
field: SugaredRelativeSingleField['field'];
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const FormFieldScope: ({ field, children }: FormFieldScopeProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FormFieldScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormFieldScope.d.ts","sourceRoot":"","sources":["../../../src/components/FormFieldScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,0BAA0B,EAAY,MAAM,0BAA0B,CAAA;AAI/E,MAAM,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,wBAAyB,mBAAmB,4CAWtE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SugaredRelativeEntityList } from '@contember/react-binding';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type FormHasManyRelationScopeProps = {
|
|
4
|
+
field: SugaredRelativeEntityList['field'];
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const FormHasManyRelationScope: ({ field, children }: FormHasManyRelationScopeProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FormHasManyRelationScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormHasManyRelationScope.d.ts","sourceRoot":"","sources":["../../../src/components/FormHasManyRelationScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAiB,MAAM,0BAA0B,CAAA;AACnF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAM,MAAM,6BAA6B,GAAG;IAC3C,KAAK,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAA;IACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,wBAAwB,wBAAyB,6BAA6B,4CAW1F,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SugaredRelativeSingleEntity } from '@contember/react-binding';
|
|
3
|
+
export type FormHasOneRelationScopeProps = {
|
|
4
|
+
field: SugaredRelativeSingleEntity['field'];
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const FormHasOneRelationScope: ({ field, children }: FormHasOneRelationScopeProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=FormHasOneRelationScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormHasOneRelationScope.d.ts","sourceRoot":"","sources":["../../../src/components/FormHasOneRelationScope.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAE,2BAA2B,EAAa,MAAM,0BAA0B,CAAA;AAIjF,MAAM,MAAM,4BAA4B,GAAG;IAC1C,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,uBAAuB,wBAAyB,4BAA4B,4CAWxF,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { OptionallyVariableFieldValue, SugaredRelativeSingleField } from '@contember/react-binding';
|
|
3
|
+
export interface FormInputProps {
|
|
4
|
+
field: SugaredRelativeSingleField['field'];
|
|
5
|
+
isNonbearing?: boolean;
|
|
6
|
+
defaultValue?: OptionallyVariableFieldValue;
|
|
7
|
+
children: React.ReactElement;
|
|
8
|
+
}
|
|
9
|
+
export declare const FormInput: React.NamedExoticComponent<FormInputProps>;
|
|
10
|
+
//# sourceMappingURL=FormInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../../../src/components/FormInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAoB,4BAA4B,EAAE,0BAA0B,EAAY,MAAM,0BAA0B,CAAA;AAS/H,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,CAAC,EAAE,4BAA4B,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAA;CAC5B;AAED,eAAO,MAAM,SAAS,4CA0BpB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLabel.d.ts","sourceRoot":"","sources":["../../../src/components/FormLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,eAAO,MAAM,SAAS,UAAW;IAChC,QAAQ,EAAE,MAAM,YAAY,CAAA;CAC5B,4CAaA,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OptionallyVariableFieldValue, SugaredRelativeSingleField } from '@contember/react-binding';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export interface FormRadioItemProps {
|
|
4
|
+
field: SugaredRelativeSingleField['field'];
|
|
5
|
+
value: string;
|
|
6
|
+
isNonbearing?: boolean;
|
|
7
|
+
defaultValue?: OptionallyVariableFieldValue;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const FormRadioInput: React.NamedExoticComponent<FormRadioItemProps>;
|
|
11
|
+
//# sourceMappingURL=FormRadioInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormRadioInput.d.ts","sourceRoot":"","sources":["../../../src/components/FormRadioInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,4BAA4B,EAAE,0BAA0B,EAAY,MAAM,0BAA0B,CAAA;AAC/H,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,CAAC,EAAE,4BAA4B,CAAA;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACzB;AAED,eAAO,MAAM,cAAc,gDA0BzB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './FormError';
|
|
2
|
+
export * from './FormCheckbox';
|
|
3
|
+
export * from './FormFieldScope';
|
|
4
|
+
export * from './FormHasOneRelationScope';
|
|
5
|
+
export * from './FormHasManyRelationScope';
|
|
6
|
+
export * from './FormInput';
|
|
7
|
+
export * from './FormLabel';
|
|
8
|
+
export * from './FormRadioInput';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ErrorAccessor } from '@contember/react-binding';
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const FormFieldIdContext: import("react").Context<string | undefined>;
|
|
4
|
+
export declare const useFormFieldId: () => string | undefined;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export declare const FormErrorContext: import("react").Context<ErrorAccessor.Error[] | undefined>;
|
|
7
|
+
export declare const useFormError: () => ErrorAccessor.Error[] | undefined;
|
|
8
|
+
//# sourceMappingURL=contexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../src/contexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAGxD,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,6CAAyB,CAAA;AACxD,eAAO,MAAM,cAAc,0BAAyB,CAAA;AAGpD,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,4DAAuB,CAAA;AACpD,eAAO,MAAM,YAAY,yCAAuB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { FieldAccessor } from '@contember/react-binding';
|
|
3
|
+
export declare const useFormInputValidationHandler: (field: FieldAccessor<any>) => {
|
|
4
|
+
ref: React.RefObject<HTMLInputElement>;
|
|
5
|
+
onFocus: () => void;
|
|
6
|
+
onBlur: () => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useFormInputValidationHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormInputValidationHandler.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFormInputValidationHandler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,aAAa,EAA0B,MAAM,0BAA0B,CAAA;AAEhF,eAAO,MAAM,6BAA6B,UAAW,cAAc,GAAG,CAAC;;;;CA0CtE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FieldAccessor } from '@contember/react-binding';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export declare const useFormInputHandler: (field: FieldAccessor) => {
|
|
4
|
+
parseValue: (value: string) => any;
|
|
5
|
+
formatValue: (value: any) => string;
|
|
6
|
+
defaultInputProps?: React.InputHTMLAttributes<HTMLInputElement> | undefined;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useFormInputHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormInputHandler.d.ts","sourceRoot":"","sources":["../../../src/internal/useFormInputHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAuC,MAAM,0BAA0B,CAAA;AAC7F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,eAAO,MAAM,mBAAmB,UAAW,aAAa;wBAanC,MAAM,KAAK,GAAG;yBACb,GAAG,KAAK,MAAM;;CAJnC,CAAA"}
|