swoop-common 1.0.2 → 1.0.4
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/components/Address.d.ts +10 -0
- package/dist/components/Address.js +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/render/StyledFormView.d.ts +9 -0
- package/dist/render/StyledFormView.js +7 -0
- package/dist/router/router.d.ts +6 -0
- package/dist/router/router.js +4 -0
- package/dist/test.d.ts +6 -0
- package/dist/test.js +5 -0
- package/dist/types/address.d.ts +10 -0
- package/dist/types/address.js +1 -0
- package/dist/util/type.d.ts +2 -0
- package/dist/util/type.js +4 -0
- package/package.json +27 -28
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Address } from '../types/address';
|
|
3
|
+
import { CustomType } from '../router/router';
|
|
4
|
+
interface Props {
|
|
5
|
+
address: Address;
|
|
6
|
+
submit?: (address: Address) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const FormAddress: React.FC<Props>;
|
|
9
|
+
export declare const TypeAddress: CustomType;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { getXType } from '../util/type';
|
|
3
|
+
import { Box, Button, TextField } from '@mui/material';
|
|
4
|
+
const tester = (uischema, schema, ctx) => {
|
|
5
|
+
const type = getXType(schema);
|
|
6
|
+
if (!type)
|
|
7
|
+
return -1;
|
|
8
|
+
else
|
|
9
|
+
return 10;
|
|
10
|
+
};
|
|
11
|
+
export const FormAddress = ({ address, submit }) => {
|
|
12
|
+
const [val, setVal] = useState(address);
|
|
13
|
+
// Typescript is great
|
|
14
|
+
const update = (field, value) => {
|
|
15
|
+
setVal(prev => (Object.assign(Object.assign({}, prev), { [field]: value })));
|
|
16
|
+
};
|
|
17
|
+
return (React.createElement(Box, { component: "form", onSubmit: () => submit === null || submit === void 0 ? void 0 : submit(val), sx: { display: 'flex', flexDirection: 'column', gap: 2, width: 400 }, noValidate: true, autoComplete: "off" },
|
|
18
|
+
React.createElement(TextField, { label: "Line 1", value: address.line1, onChange: (e) => update('line1', e.target.value), required: true }),
|
|
19
|
+
React.createElement(TextField, { label: "Line 2", value: address.line2, onChange: (e) => update('line2', e.target.value) }),
|
|
20
|
+
React.createElement(TextField, { label: "City", value: address.city, onChange: (e) => update('city', e.target.value), required: true }),
|
|
21
|
+
React.createElement(TextField, { label: "Postcode", value: address.postcode, onChange: (e) => update('postcode', e.target.value), required: true }),
|
|
22
|
+
React.createElement(TextField, { label: "Number", value: address.postcode, onChange: (e) => update('number', +e.target.value), required: true }),
|
|
23
|
+
React.createElement(Button, { type: "submit", variant: "contained", color: "primary" }, "Submit")));
|
|
24
|
+
};
|
|
25
|
+
const FormRendererAddress = ({ data, handleChange, path }) => {
|
|
26
|
+
return React.createElement(FormAddress, { address: data, submit: (addr) => handleChange(path, addr) });
|
|
27
|
+
};
|
|
28
|
+
export const TypeAddress = {
|
|
29
|
+
renderer: FormRendererAddress,
|
|
30
|
+
tester
|
|
31
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonForms } from '@jsonforms/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FormTypes } from '../router/router';
|
|
4
|
+
const StyledFormView = ({ data, schema, uischema }) => {
|
|
5
|
+
return (React.createElement(JsonForms, { data: data, schema: schema, uischema: uischema, renderers: FormTypes }));
|
|
6
|
+
};
|
|
7
|
+
export default StyledFormView;
|
package/dist/test.d.ts
ADDED
package/dist/test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
2
|
+
"name": "swoop-common",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"build": "tsc"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"description": "",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@jsonforms/core": "^3.5.1",
|
|
18
|
+
"@jsonforms/material-renderers": "^3.5.1",
|
|
19
|
+
"@jsonforms/react": "^3.5.1",
|
|
20
|
+
"@emotion/react": "^11.14.0",
|
|
21
|
+
"@emotion/styled": "^11.14.1",
|
|
22
|
+
"react": "^19.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/react": "^19",
|
|
26
|
+
"typescript": "^5"
|
|
27
|
+
}
|
|
28
|
+
}
|