swoop-common 1.0.13 → 1.0.15
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/README.md +1 -1
- package/package.json +1 -1
- package/dist/api/consts.d.ts +0 -1
- package/dist/api/consts.js +0 -2
- package/dist/components/SchemaValidator.d.ts +0 -3
- package/dist/components/SchemaValidator.js +0 -6
- package/dist/components/StyledFormView.d.ts +0 -34
- package/dist/components/StyledFormView.js +0 -12
- package/dist/default_registration/fields_base.d.ts +0 -1
- package/dist/default_registration/fields_base.js +0 -129
- package/dist/hooks/errors.d.ts +0 -6
- package/dist/hooks/errors.js +0 -17
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -9
- package/dist/prebuild/generated/import_generated.d.ts +0 -15
- package/dist/prebuild/generated/import_generated.js +0 -18
- package/dist/prebuild/import.d.ts +0 -1
- package/dist/prebuild/import.js +0 -32
- package/dist/registry/components.d.ts +0 -13
- package/dist/registry/components.js +0 -49
- package/dist/registry/fields.d.ts +0 -10
- package/dist/registry/fields.js +0 -19
- package/dist/registry/types.d.ts +0 -5
- package/dist/registry/types.js +0 -5
- package/dist/renderers/Address.d.ts +0 -1
- package/dist/renderers/Address.js +0 -67
- package/dist/renderers/ComponentPicker.d.ts +0 -19
- package/dist/renderers/ComponentPicker.js +0 -68
- package/dist/renderers/Debug.d.ts +0 -1
- package/dist/renderers/Debug.js +0 -13
- package/dist/renderers/Example.d.ts +0 -1
- package/dist/renderers/Example.js +0 -31
- package/dist/renderers/Image/ImageForm.d.ts +0 -10
- package/dist/renderers/Image/ImageForm.js +0 -78
- package/dist/renderers/Image/ImagePresentation.d.ts +0 -6
- package/dist/renderers/Image/ImagePresentation.js +0 -62
- package/dist/renderers/StagedText.d.ts +0 -1
- package/dist/renderers/StagedText.js +0 -20
- package/dist/renderers/TemplatePicker.d.ts +0 -1
- package/dist/renderers/TemplatePicker.js +0 -55
- package/dist/renderers/address/AddressForm.d.ts +0 -1
- package/dist/renderers/address/AddressForm.js +0 -46
- package/dist/renderers/address/AddressPresentation.d.ts +0 -1
- package/dist/renderers/address/AddressPresentation.js +0 -34
- package/dist/renderers/textfield/MultilineForm.d.ts +0 -1
- package/dist/renderers/textfield/MultilineForm.js +0 -21
- package/dist/renderers/textfield/MultilinePresentation.d.ts +0 -1
- package/dist/renderers/textfield/MultilinePresentation.js +0 -13
- package/dist/schema/formBuilders/formBuilderJsonSchema.d.ts +0 -11
- package/dist/schema/formBuilders/formBuilderJsonSchema.js +0 -178
- package/dist/schema/formBuilders/formBuilderUiSchema.d.ts +0 -2
- package/dist/schema/formBuilders/formBuilderUiSchema.js +0 -208
- package/dist/schema/formSchemaTypes.d.ts +0 -15
- package/dist/schema/formSchemaTypes.js +0 -6
- package/dist/schema/generate/formSchemaGenerate.d.ts +0 -3
- package/dist/schema/generate/formSchemaGenerate.js +0 -19
- package/dist/schema/generate/jsonSchemaGenerate.d.ts +0 -3
- package/dist/schema/generate/jsonSchemaGenerate.js +0 -150
- package/dist/schema/generate/jsonSchemaGeneratewip.d.ts +0 -4
- package/dist/schema/generate/jsonSchemaGeneratewip.js +0 -59
- package/dist/schema/generate/uiSchemaGenerate.d.ts +0 -3
- package/dist/schema/generate/uiSchemaGenerate.js +0 -33
- package/dist/schema/schema.d.ts +0 -48
- package/dist/schema/schema.js +0 -1
- package/dist/schema/template/constraint.d.ts +0 -17
- package/dist/schema/template/constraint.js +0 -119
- package/dist/schema/template/type.d.ts +0 -94
- package/dist/schema/template/type.js +0 -1
- package/dist/schema/util.d.ts +0 -1
- package/dist/schema/util.js +0 -22
- package/dist/test.d.ts +0 -6
- package/dist/test.js +0 -5
- package/dist/types/address.d.ts +0 -10
- package/dist/types/address.js +0 -1
- package/dist/types/jsonSchema.d.ts +0 -4
- package/dist/types/jsonSchema.js +0 -1
- package/dist/types/util.d.ts +0 -1
- package/dist/types/util.js +0 -1
- package/dist/util/xtype.d.ts +0 -3
- package/dist/util/xtype.js +0 -18
- package/dist/validation/schemaValidator.d.ts +0 -4
- package/dist/validation/schemaValidator.js +0 -6
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import { debounce, Paper, TextField, Typography } from '@mui/material';
|
|
3
|
-
import { useLocalErrors } from '../hooks/errors';
|
|
4
|
-
import { ComponentPool } from '../registry/types';
|
|
5
|
-
import { registerComponent } from '../registry/components';
|
|
6
|
-
// The base component used to render. Can be exported for external use
|
|
7
|
-
const FormExample = ({ text, onChange, getError, label, enabled }) => {
|
|
8
|
-
var _a;
|
|
9
|
-
const [val, setVal] = useState(text);
|
|
10
|
-
// Gets any error associated with this component. If there are multiple, it gets the first
|
|
11
|
-
const error = getError ? (_a = getError("example")) === null || _a === void 0 ? void 0 : _a.message : undefined;
|
|
12
|
-
const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
|
|
13
|
-
// Handle internal state, and debounce submission to avoid constant validations
|
|
14
|
-
const update = (value) => {
|
|
15
|
-
setVal(value);
|
|
16
|
-
onChangeDebounced(value);
|
|
17
|
-
};
|
|
18
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, background: "#CBC3E3", mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
19
|
-
!enabled && "THIS IS DISABLED",
|
|
20
|
-
React.createElement(Typography, { variant: 'h6' }, label),
|
|
21
|
-
React.createElement(TextField, { label: "Example label", value: val, onChange: (e) => update(e.target.value), error: !!error, helperText: error, disabled: !enabled })));
|
|
22
|
-
};
|
|
23
|
-
// Wrapper component for converting the base component into a jsonforms compatible version
|
|
24
|
-
const FormRendererExample = ({ data, handleChange, path, label, enabled }) => {
|
|
25
|
-
const getError = useLocalErrors(path);
|
|
26
|
-
return React.createElement(FormExample, { text: data, onChange: (addr) => handleChange(path, addr), getError: getError, label: label, enabled: enabled });
|
|
27
|
-
};
|
|
28
|
-
// Register this component for x-type: example
|
|
29
|
-
// Register this component for all form modes
|
|
30
|
-
registerComponent("example", FormRendererExample, ComponentPool.FORM);
|
|
31
|
-
registerComponent("example", FormRendererExample, ComponentPool.PRESENTATION);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ErrorObject } from "ajv";
|
|
3
|
-
interface Props {
|
|
4
|
-
url: string;
|
|
5
|
-
onChange: (string: string) => void;
|
|
6
|
-
getError?: (field: string) => ErrorObject<string, Record<string, any>, unknown> | undefined;
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare const FormImage: React.FC<Props>;
|
|
10
|
-
export default FormImage;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import { Box, CircularProgress, debounce, Paper, TextField, Typography } from '@mui/material';
|
|
3
|
-
import { useLocalErrors } from '../../hooks/errors';
|
|
4
|
-
import { ComponentPool } from '../../registry/types';
|
|
5
|
-
import { registerComponent } from '../../registry/components';
|
|
6
|
-
const FormImage = ({ url, onChange, getError, enabled }) => {
|
|
7
|
-
if (!getError)
|
|
8
|
-
getError = () => undefined;
|
|
9
|
-
const [val, setVal] = useState(url);
|
|
10
|
-
const [imgError, setImgError] = useState(false);
|
|
11
|
-
const [loading, setLoading] = useState(false);
|
|
12
|
-
const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
|
|
13
|
-
const update = (value) => {
|
|
14
|
-
setVal(value);
|
|
15
|
-
setImgError(false);
|
|
16
|
-
setLoading(true);
|
|
17
|
-
onChangeDebounced(value);
|
|
18
|
-
};
|
|
19
|
-
const error = getError('image');
|
|
20
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
21
|
-
React.createElement(Typography, { variant: "h5" }, "Image"),
|
|
22
|
-
React.createElement(TextField, { label: "Image URL", value: val, onChange: (e) => update(e.target.value), required: true, error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, fullWidth: true, disabled: !enabled }),
|
|
23
|
-
(() => {
|
|
24
|
-
if (error)
|
|
25
|
-
return null;
|
|
26
|
-
if (imgError) {
|
|
27
|
-
return (React.createElement(Box, { sx: {
|
|
28
|
-
width: '100%',
|
|
29
|
-
bgcolor: 'background.paper',
|
|
30
|
-
display: 'flex',
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
justifyContent: 'center',
|
|
33
|
-
p: 1,
|
|
34
|
-
minHeight: 48,
|
|
35
|
-
borderRadius: 1,
|
|
36
|
-
} },
|
|
37
|
-
React.createElement(Typography, { color: "text.secondary", variant: "body2" }, "Image failed to load")));
|
|
38
|
-
}
|
|
39
|
-
return (React.createElement(Box, { sx: {
|
|
40
|
-
position: 'relative',
|
|
41
|
-
width: '100%',
|
|
42
|
-
maxHeight: 400,
|
|
43
|
-
bgcolor: 'background.paper',
|
|
44
|
-
borderRadius: 1,
|
|
45
|
-
overflow: 'hidden',
|
|
46
|
-
} },
|
|
47
|
-
React.createElement(Box, { component: "img", src: val, alt: "Preview", sx: {
|
|
48
|
-
width: '100%',
|
|
49
|
-
height: loading ? 48 : "",
|
|
50
|
-
objectFit: 'contain',
|
|
51
|
-
borderRadius: 1,
|
|
52
|
-
opacity: loading ? 0 : 1,
|
|
53
|
-
transition: 'opacity 0.3s ease',
|
|
54
|
-
display: 'block',
|
|
55
|
-
}, onLoad: () => setLoading(false), onError: () => {
|
|
56
|
-
setImgError(true);
|
|
57
|
-
setLoading(false);
|
|
58
|
-
}, loading: "lazy" }),
|
|
59
|
-
loading && (React.createElement(Box, { sx: {
|
|
60
|
-
position: 'absolute',
|
|
61
|
-
top: 0,
|
|
62
|
-
left: 0,
|
|
63
|
-
right: 0,
|
|
64
|
-
bottom: 0,
|
|
65
|
-
display: 'flex',
|
|
66
|
-
justifyContent: 'center',
|
|
67
|
-
alignItems: 'center',
|
|
68
|
-
bgcolor: 'background.paper',
|
|
69
|
-
} },
|
|
70
|
-
React.createElement(CircularProgress, { size: 24 })))));
|
|
71
|
-
})()));
|
|
72
|
-
};
|
|
73
|
-
export default FormImage;
|
|
74
|
-
const FormRendererImage = ({ data, handleChange, path, enabled }) => {
|
|
75
|
-
const getError = useLocalErrors(path);
|
|
76
|
-
return React.createElement(FormImage, { url: data, onChange: (addr) => handleChange(path, addr), getError: getError, enabled: enabled });
|
|
77
|
-
};
|
|
78
|
-
registerComponent("image", FormRendererImage, ComponentPool.FORM);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Box, CircularProgress, Paper, Typography } from '@mui/material';
|
|
3
|
-
import { ComponentPool } from '../../registry/types';
|
|
4
|
-
import { registerComponent } from '../../registry/components';
|
|
5
|
-
const FormImage = ({ url }) => {
|
|
6
|
-
const [imgError, setImgError] = useState(false);
|
|
7
|
-
const [loading, setLoading] = useState(false);
|
|
8
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
9
|
-
React.createElement(Typography, { variant: "h5" }, "Image"),
|
|
10
|
-
(() => {
|
|
11
|
-
if (imgError) {
|
|
12
|
-
return (React.createElement(Box, { sx: {
|
|
13
|
-
width: '100%',
|
|
14
|
-
bgcolor: 'background.paper',
|
|
15
|
-
display: 'flex',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
justifyContent: 'center',
|
|
18
|
-
p: 1,
|
|
19
|
-
minHeight: 48,
|
|
20
|
-
borderRadius: 1,
|
|
21
|
-
} },
|
|
22
|
-
React.createElement(Typography, { color: "text.secondary", variant: "body2" }, "Image failed to load")));
|
|
23
|
-
}
|
|
24
|
-
return (React.createElement(Box, { sx: {
|
|
25
|
-
position: 'relative',
|
|
26
|
-
width: '100%',
|
|
27
|
-
maxHeight: 400,
|
|
28
|
-
bgcolor: 'background.paper',
|
|
29
|
-
borderRadius: 1,
|
|
30
|
-
overflow: 'hidden',
|
|
31
|
-
} },
|
|
32
|
-
React.createElement(Box, { component: "img", src: url, alt: "Preview", sx: {
|
|
33
|
-
width: '100%',
|
|
34
|
-
height: loading ? 48 : "",
|
|
35
|
-
objectFit: 'contain',
|
|
36
|
-
borderRadius: 1,
|
|
37
|
-
opacity: loading ? 0 : 1,
|
|
38
|
-
transition: 'opacity 0.3s ease',
|
|
39
|
-
display: 'block',
|
|
40
|
-
}, onLoad: () => setLoading(false), onError: () => {
|
|
41
|
-
setImgError(true);
|
|
42
|
-
setLoading(false);
|
|
43
|
-
}, loading: "lazy" }),
|
|
44
|
-
loading && (React.createElement(Box, { sx: {
|
|
45
|
-
position: 'absolute',
|
|
46
|
-
top: 0,
|
|
47
|
-
left: 0,
|
|
48
|
-
right: 0,
|
|
49
|
-
bottom: 0,
|
|
50
|
-
display: 'flex',
|
|
51
|
-
justifyContent: 'center',
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
bgcolor: 'background.paper',
|
|
54
|
-
} },
|
|
55
|
-
React.createElement(CircularProgress, { size: 24 })))));
|
|
56
|
-
})()));
|
|
57
|
-
};
|
|
58
|
-
export default FormImage;
|
|
59
|
-
const FormRendererImage = ({ data, }) => {
|
|
60
|
-
return React.createElement(FormImage, { url: data });
|
|
61
|
-
};
|
|
62
|
-
registerComponent("image", FormRendererImage, ComponentPool.PRESENTATION);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Paper, Typography, TextField } from '@mui/material';
|
|
3
|
-
import { useLocalErrors } from '../hooks/errors';
|
|
4
|
-
import { ComponentPool } from '../registry/types';
|
|
5
|
-
import { registerComponent } from '../registry/components';
|
|
6
|
-
const stages = ['website', 'quote', 'finalItinerary'];
|
|
7
|
-
const FormStagedText = ({ data, onChange, enabled, label }) => {
|
|
8
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 2, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
9
|
-
React.createElement(Typography, { variant: "h6" }, label),
|
|
10
|
-
stages.map((stage) => (React.createElement(TextField, { key: stage, label: stage.replace(/([A-Z])/g, ' $1'), value: data[stage] || '', onChange: (e) => onChange(stage, e.target.value), multiline: true, rows: 3, disabled: !enabled })))));
|
|
11
|
-
};
|
|
12
|
-
const FormRendererStagedText = ({ data, handleChange, path, label, enabled }) => {
|
|
13
|
-
const safeData = data || { website: '', quote: '', finalItinerary: '' };
|
|
14
|
-
const getError = useLocalErrors(path);
|
|
15
|
-
const handleStageChange = (stage, value) => {
|
|
16
|
-
handleChange(`${path}.${stage}`, value);
|
|
17
|
-
};
|
|
18
|
-
return (React.createElement(FormStagedText, { data: safeData, onChange: handleStageChange, enabled: enabled, label: label, getError: getError }));
|
|
19
|
-
};
|
|
20
|
-
registerComponent("stagedText", FormRendererStagedText, ComponentPool.FORM);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetchTemplates: () => Promise<any>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
import React, { useEffect, useState } from 'react';
|
|
12
|
-
import { Paper, Typography, Box, TextField, Chip, Autocomplete } from '@mui/material';
|
|
13
|
-
import { useLocalErrors } from '../hooks/errors';
|
|
14
|
-
import { registerComponent } from '../registry/components';
|
|
15
|
-
import { ComponentPool } from '../registry/types';
|
|
16
|
-
import { BASE_API_URL } from '../api/consts';
|
|
17
|
-
const FormTemplatePicker = ({ templates, selectedTemplates, onChange, label, enabled }) => {
|
|
18
|
-
const selectedValues = templates.filter(t => selectedTemplates.includes(t.id));
|
|
19
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 2, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
20
|
-
React.createElement(Typography, { variant: "h6" }, label),
|
|
21
|
-
React.createElement(Autocomplete, { multiple: true, options: templates, getOptionLabel: (option) => option.name, value: selectedValues, onChange: (_, newValue) => {
|
|
22
|
-
onChange(newValue.map(template => template.id));
|
|
23
|
-
}, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { variant: "outlined", placeholder: "Search and select templates", disabled: !enabled }))), renderTags: (value, getTagProps) => value.map((option, index) => (React.createElement(Chip, Object.assign({ label: option.name }, getTagProps({ index }), { key: option.id })))), renderOption: (props, option) => (React.createElement("li", Object.assign({}, props),
|
|
24
|
-
React.createElement(Box, null,
|
|
25
|
-
React.createElement(Typography, { variant: "body1" }, option.name),
|
|
26
|
-
React.createElement(Typography, { variant: "caption", color: "text.secondary" },
|
|
27
|
-
"Version: v",
|
|
28
|
-
option.revision)))), disabled: !enabled })));
|
|
29
|
-
};
|
|
30
|
-
const FormRendererTemplatePicker = ({ data, handleChange, path, label, enabled }) => {
|
|
31
|
-
const [templates, setTemplates] = useState([]);
|
|
32
|
-
const getError = useLocalErrors(path);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const load = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
try {
|
|
36
|
-
const result = yield fetchTemplates();
|
|
37
|
-
setTemplates(result);
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
console.error('Error loading templates:', err);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
load();
|
|
44
|
-
}, []);
|
|
45
|
-
return (React.createElement(FormTemplatePicker, { templates: templates, selectedTemplates: data || [], onChange: (ids) => handleChange(path, ids), getError: getError, label: label, enabled: enabled }));
|
|
46
|
-
};
|
|
47
|
-
registerComponent("componentOptions", FormRendererTemplatePicker, ComponentPool.FORM);
|
|
48
|
-
export const fetchTemplates = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const response = yield fetch(`${BASE_API_URL}/core-data-service/v1/templates?limit=2000`);
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error("Failed to fetch templates");
|
|
52
|
-
}
|
|
53
|
-
const result = yield response.json();
|
|
54
|
-
return result.data || [];
|
|
55
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import { Box, debounce, MenuItem, Paper, TextField, Typography } from '@mui/material';
|
|
3
|
-
import { useLocalErrors } from '../../hooks/errors';
|
|
4
|
-
import { ComponentPool } from '../../registry/types';
|
|
5
|
-
import { registerComponent } from '../../registry/components';
|
|
6
|
-
const FormAddress = ({ address, onChange, getError, label, enabled }) => {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
8
|
-
if (!getError)
|
|
9
|
-
getError = () => undefined;
|
|
10
|
-
const [val, setVal] = useState(address || {
|
|
11
|
-
line1: "",
|
|
12
|
-
city: "",
|
|
13
|
-
postcode: "",
|
|
14
|
-
});
|
|
15
|
-
// Errors, stored to reduce num of calls for performance
|
|
16
|
-
const line1Error = (_a = getError("line1")) === null || _a === void 0 ? void 0 : _a.message;
|
|
17
|
-
const line2Error = (_b = getError("line2")) === null || _b === void 0 ? void 0 : _b.message;
|
|
18
|
-
const cityError = (_c = getError("city")) === null || _c === void 0 ? void 0 : _c.message;
|
|
19
|
-
const postcodeError = (_d = getError("postcode")) === null || _d === void 0 ? void 0 : _d.message;
|
|
20
|
-
const numberError = (_e = getError("number")) === null || _e === void 0 ? void 0 : _e.message;
|
|
21
|
-
const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
|
|
22
|
-
const update = (field, value) => {
|
|
23
|
-
const newVal = Object.assign(Object.assign({}, val), { [field]: value });
|
|
24
|
-
setVal(newVal);
|
|
25
|
-
onChangeDebounced(newVal);
|
|
26
|
-
};
|
|
27
|
-
return (React.createElement(Paper, { component: "form", noValidate: true, autoComplete: "off", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 } },
|
|
28
|
-
React.createElement(Typography, { variant: 'h5' }, label),
|
|
29
|
-
React.createElement(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 } },
|
|
30
|
-
React.createElement(TextField, { label: "Line 1", value: (_f = val.line1) !== null && _f !== void 0 ? _f : "", onChange: (e) => update('line1', e.target.value), required: true, error: !!line1Error, helperText: line1Error, disabled: !enabled }),
|
|
31
|
-
React.createElement(TextField, { label: "Line 2", value: (_g = val.line2) !== null && _g !== void 0 ? _g : "", onChange: (e) => update('line2', e.target.value), error: !!line2Error, helperText: line2Error, disabled: !enabled })),
|
|
32
|
-
React.createElement(TextField, { select: true, label: "City", value: (_h = val.city) !== null && _h !== void 0 ? _h : "London", onChange: (e) => update('city', e.target.value), required: true, fullWidth: true, error: !!cityError, helperText: cityError, disabled: !enabled },
|
|
33
|
-
React.createElement(MenuItem, { value: "London" }, "Londonhn"),
|
|
34
|
-
React.createElement(MenuItem, { value: "Newcastle" }, "Newcastle"),
|
|
35
|
-
React.createElement(MenuItem, { value: "Bristol" }, "Bristol")),
|
|
36
|
-
React.createElement(Box, { sx: { display: 'flex', gap: 2 } },
|
|
37
|
-
React.createElement(TextField, { label: "Postcode", value: (_j = val.postcode) !== null && _j !== void 0 ? _j : "", onChange: (e) => update('postcode', e.target.value), required: true, error: !!postcodeError, helperText: postcodeError, fullWidth: true, disabled: !enabled }),
|
|
38
|
-
React.createElement(TextField, { label: "Number", type: "number", value: (_k = val.number) !== null && _k !== void 0 ? _k : "", onChange: (e) => update('number', +e.target.value), required: true, error: !!numberError, helperText: numberError, fullWidth: true, disabled: !enabled }))));
|
|
39
|
-
};
|
|
40
|
-
const FormRendererAddress = ({ data, handleChange, path, label, enabled, schema }) => {
|
|
41
|
-
const getError = useLocalErrors(path);
|
|
42
|
-
console.log("tt", JSON.stringify(schema));
|
|
43
|
-
//if(isValidAgainstSchema(schema, data))
|
|
44
|
-
return React.createElement(FormAddress, { address: data, label: label, onChange: (addr) => handleChange(path, addr), getError: getError, enabled: enabled });
|
|
45
|
-
};
|
|
46
|
-
registerComponent("-address", FormRendererAddress, ComponentPool.FORM);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Paper, Typography } from '@mui/material';
|
|
3
|
-
import { ComponentPool } from '../../registry/types';
|
|
4
|
-
import { registerComponent } from '../../registry/components';
|
|
5
|
-
const FormAddress = ({ address }) => {
|
|
6
|
-
return (React.createElement(Paper, { sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, elevation: 1 },
|
|
7
|
-
React.createElement(Typography, { variant: "h6", gutterBottom: true }, "Addressssssss Details"),
|
|
8
|
-
React.createElement(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 0.5 } },
|
|
9
|
-
React.createElement(Typography, null,
|
|
10
|
-
React.createElement("strong", null, "Line 1:"),
|
|
11
|
-
" ", address === null || address === void 0 ? void 0 :
|
|
12
|
-
address.line1),
|
|
13
|
-
(address === null || address === void 0 ? void 0 : address.line2) && (React.createElement(Typography, null,
|
|
14
|
-
React.createElement("strong", null, "Line 2:"),
|
|
15
|
-
" ",
|
|
16
|
-
address.line2))),
|
|
17
|
-
React.createElement(Typography, null,
|
|
18
|
-
React.createElement("strong", null, "City:"),
|
|
19
|
-
" ", address === null || address === void 0 ? void 0 :
|
|
20
|
-
address.city),
|
|
21
|
-
React.createElement(Box, { sx: { display: 'flex', gap: 2 } },
|
|
22
|
-
React.createElement(Typography, null,
|
|
23
|
-
React.createElement("strong", null, "Postcode:"),
|
|
24
|
-
" ", address === null || address === void 0 ? void 0 :
|
|
25
|
-
address.postcode),
|
|
26
|
-
React.createElement(Typography, null,
|
|
27
|
-
React.createElement("strong", null, "Number:"),
|
|
28
|
-
" ", address === null || address === void 0 ? void 0 :
|
|
29
|
-
address.number))));
|
|
30
|
-
};
|
|
31
|
-
const FormRendererAddress = ({ data }) => {
|
|
32
|
-
return React.createElement(FormAddress, { address: data });
|
|
33
|
-
};
|
|
34
|
-
registerComponent("-address", FormRendererAddress, ComponentPool.PRESENTATION);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import { debounce, TextField } from '@mui/material';
|
|
3
|
-
import { useLocalErrors } from '../../hooks/errors';
|
|
4
|
-
import { ComponentPool } from '../../registry/types';
|
|
5
|
-
import { registerComponent } from '../../registry/components';
|
|
6
|
-
const FormTextfield = ({ text, onChange, getError, label, enabled }) => {
|
|
7
|
-
var _a;
|
|
8
|
-
const [val, setVal] = useState(text);
|
|
9
|
-
const error = getError ? (_a = getError("multiline")) === null || _a === void 0 ? void 0 : _a.message : undefined;
|
|
10
|
-
const onChangeDebounced = useMemo(() => debounce(onChange, 300), [onChange]);
|
|
11
|
-
const update = (value) => {
|
|
12
|
-
setVal(value);
|
|
13
|
-
onChangeDebounced(value);
|
|
14
|
-
};
|
|
15
|
-
return (React.createElement(TextField, { label: label, value: val, onChange: (e) => update(e.target.value), error: !!error, helperText: error, multiline: true, fullWidth: true, sx: { mb: 1 }, disabled: !enabled }));
|
|
16
|
-
};
|
|
17
|
-
const FormRendererExample = ({ data, handleChange, path, label, enabled }) => {
|
|
18
|
-
const getError = useLocalErrors(path);
|
|
19
|
-
return React.createElement(FormTextfield, { text: data, onChange: (addr) => handleChange(path, addr), getError: getError, label: label, enabled: enabled });
|
|
20
|
-
};
|
|
21
|
-
registerComponent("multiline", FormRendererExample, ComponentPool.FORM);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Paper, Typography } from '@mui/material';
|
|
3
|
-
import { ComponentPool } from '../../registry/types';
|
|
4
|
-
import { registerComponent } from '../../registry/components';
|
|
5
|
-
const FormTextfield = ({ text, label }) => {
|
|
6
|
-
return (React.createElement(Paper, { component: "form", sx: { display: 'flex', flexDirection: 'column', gap: 1, p: 2, mb: 1 }, noValidate: true, autoComplete: "off" },
|
|
7
|
-
React.createElement(Typography, { variant: "subtitle2", color: "textSecondary", gutterBottom: true }, label),
|
|
8
|
-
React.createElement(Typography, { variant: "body1", sx: { whiteSpace: 'pre-wrap' } }, text)));
|
|
9
|
-
};
|
|
10
|
-
const FormRendererExample = ({ data, label }) => {
|
|
11
|
-
return React.createElement(FormTextfield, { text: data, label: label });
|
|
12
|
-
};
|
|
13
|
-
registerComponent("multiline", FormRendererExample, ComponentPool.PRESENTATION);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { JsonSchema } from "@jsonforms/core";
|
|
2
|
-
import { FormBuilderSchema } from "../template/type";
|
|
3
|
-
import { JsonSchemaWithXType } from "../../types/jsonSchema";
|
|
4
|
-
export interface TemplateField {
|
|
5
|
-
name: string;
|
|
6
|
-
options?: JsonSchema;
|
|
7
|
-
title: string;
|
|
8
|
-
optionsRequired: boolean;
|
|
9
|
-
schema: JsonSchemaWithXType;
|
|
10
|
-
}
|
|
11
|
-
export declare const FORM_BUILDER_JSON_SCHEMA: FormBuilderSchema;
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { CONSTRAINT_DEFINITIONS } from "../template/constraint";
|
|
2
|
-
import { getAllTypes } from "../../registry/fields";
|
|
3
|
-
const fields = getAllTypes();
|
|
4
|
-
const fieldsToTypeDef = fields.map(f => ({
|
|
5
|
-
"x-type": f.name,
|
|
6
|
-
properties: Object.assign({ fieldType: { const: f.name }, [f.name + "Options"]: { type: "object" } }, f.optionsRequired && { required: [f.name + "Options"] }),
|
|
7
|
-
}));
|
|
8
|
-
const fieldsToConst = fields.map(f => ({ const: f.name, title: f.title }));
|
|
9
|
-
const fieldsToOptionsRecord = fields.reduce((prev, curr) => {
|
|
10
|
-
if (!curr.options)
|
|
11
|
-
return prev;
|
|
12
|
-
prev[curr.name + "Options"] = Object.assign({}, curr.options);
|
|
13
|
-
return prev;
|
|
14
|
-
}, {});
|
|
15
|
-
export const FORM_BUILDER_JSON_SCHEMA = {
|
|
16
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
name: {
|
|
20
|
-
type: "string",
|
|
21
|
-
minLength: 1,
|
|
22
|
-
description: "Name of your template",
|
|
23
|
-
},
|
|
24
|
-
formFields: {
|
|
25
|
-
type: "array",
|
|
26
|
-
items: { $ref: "#/$defs/fieldDefinition" },
|
|
27
|
-
},
|
|
28
|
-
ibFormFields: {
|
|
29
|
-
type: "array",
|
|
30
|
-
items: { $ref: "#/$defs/fieldDefinition" },
|
|
31
|
-
},
|
|
32
|
-
constraints: {
|
|
33
|
-
type: "array",
|
|
34
|
-
items: {
|
|
35
|
-
type: "object",
|
|
36
|
-
properties: {
|
|
37
|
-
type: {
|
|
38
|
-
type: "string",
|
|
39
|
-
enum: Object.keys(CONSTRAINT_DEFINITIONS),
|
|
40
|
-
title: "Constraint Type",
|
|
41
|
-
},
|
|
42
|
-
mustHaveOneOfOptions: {
|
|
43
|
-
type: "object",
|
|
44
|
-
title: "Must Have One Of Options",
|
|
45
|
-
properties: {
|
|
46
|
-
templateIds: {
|
|
47
|
-
type: "array",
|
|
48
|
-
title: "Select Templates",
|
|
49
|
-
items: {
|
|
50
|
-
type: "string",
|
|
51
|
-
},
|
|
52
|
-
minItems: 1,
|
|
53
|
-
options: {
|
|
54
|
-
custom: {
|
|
55
|
-
renderer: "template-picker",
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
required: ["templateIds"],
|
|
61
|
-
},
|
|
62
|
-
mustHaveAllOfOptions: {
|
|
63
|
-
type: "object",
|
|
64
|
-
title: "Must Have All Of Options",
|
|
65
|
-
properties: {
|
|
66
|
-
templateIds: {
|
|
67
|
-
type: "array",
|
|
68
|
-
title: "Select Templates",
|
|
69
|
-
items: {
|
|
70
|
-
type: "string",
|
|
71
|
-
},
|
|
72
|
-
minItems: 1,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
required: ["templateIds"],
|
|
76
|
-
},
|
|
77
|
-
mustNotHaveOptions: {
|
|
78
|
-
type: "object",
|
|
79
|
-
title: "Must Not Have Options",
|
|
80
|
-
properties: {
|
|
81
|
-
templateIds: {
|
|
82
|
-
type: "array",
|
|
83
|
-
title: "Select Templates",
|
|
84
|
-
items: {
|
|
85
|
-
type: "string",
|
|
86
|
-
},
|
|
87
|
-
minItems: 1,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
required: ["templateIds"],
|
|
91
|
-
},
|
|
92
|
-
customOptions: {
|
|
93
|
-
type: "object",
|
|
94
|
-
title: "Custom Options",
|
|
95
|
-
properties: {
|
|
96
|
-
name: {
|
|
97
|
-
type: "string",
|
|
98
|
-
title: "Constraint Name",
|
|
99
|
-
},
|
|
100
|
-
customParameters: {
|
|
101
|
-
type: "object",
|
|
102
|
-
title: "Custom Parameters",
|
|
103
|
-
properties: {},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
required: ["name"],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
required: ["type"],
|
|
110
|
-
dependencies: {
|
|
111
|
-
type: {
|
|
112
|
-
oneOf: [
|
|
113
|
-
{
|
|
114
|
-
properties: {
|
|
115
|
-
type: { const: "MustHaveOneOf" },
|
|
116
|
-
mustHaveOneOfOptions: { type: "object" },
|
|
117
|
-
},
|
|
118
|
-
required: ["mustHaveOneOfOptions"],
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
properties: {
|
|
122
|
-
type: { const: "MustHaveAllOf" },
|
|
123
|
-
mustHaveAllOfOptions: { type: "object" },
|
|
124
|
-
},
|
|
125
|
-
required: ["mustHaveAllOfOptions"],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
properties: {
|
|
129
|
-
type: { const: "MustNotHave" },
|
|
130
|
-
mustNotHaveOptions: { type: "object" },
|
|
131
|
-
},
|
|
132
|
-
required: ["mustNotHaveOptions"],
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
properties: {
|
|
136
|
-
type: { const: "Custom" },
|
|
137
|
-
customOptions: { type: "object" },
|
|
138
|
-
},
|
|
139
|
-
required: ["customOptions"],
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
required: ["name", "formFields"],
|
|
148
|
-
$defs: {
|
|
149
|
-
fieldDefinition: {
|
|
150
|
-
type: "object",
|
|
151
|
-
properties: Object.assign({ fieldType: {
|
|
152
|
-
oneOf: fieldsToConst
|
|
153
|
-
}, name: {
|
|
154
|
-
type: "string",
|
|
155
|
-
minLength: 1,
|
|
156
|
-
description: "Field name (used for both label and ID generation)",
|
|
157
|
-
}, description: { type: "string" }, required: { type: "boolean", default: false } }, fieldsToOptionsRecord),
|
|
158
|
-
required: ["fieldType", "name"],
|
|
159
|
-
dependencies: {
|
|
160
|
-
fieldType: {
|
|
161
|
-
oneOf: fieldsToTypeDef
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
arrayItemDefinition: {
|
|
166
|
-
type: "object",
|
|
167
|
-
properties: Object.assign({ fieldType: {
|
|
168
|
-
oneOf: fieldsToConst
|
|
169
|
-
} }, fieldsToOptionsRecord),
|
|
170
|
-
required: ["fieldType"],
|
|
171
|
-
dependencies: {
|
|
172
|
-
fieldType: {
|
|
173
|
-
oneOf: fieldsToTypeDef
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
}
|
|
178
|
-
};
|