Skip to content

Commit e8f9792

Browse files
committed
fix: initial setup for mobile working
1 parent 13b8f2f commit e8f9792

File tree

5 files changed

+127
-25
lines changed

5 files changed

+127
-25
lines changed

demo/examples/stepper/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import schema from './schema.json';
66
import uiSchema from './ui-schema.json';
77
import xhrSchema from './xhr-schema.json';
88
import formData from './form-data.json';
9-
import config from '../../../scripts/generator/components.json';
9+
import config from '../../../scripts/generator/frameworks/react/mui/components.json';
1010

1111
const sessionId = generate();
1212

demo/examples/stepper/index.native.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// JSON
2+
import schema from './schema.json';
3+
import uiSchema from './ui-schema.json';
4+
import xhrSchema from './xhr-schema.json';
5+
import formData from './form-data.json';
6+
import config from '../../../scripts/generator/frameworks/react-native/rnpaper/components.json';
7+
8+
const sessionId = Math.random(123);
9+
10+
formData.SelectComponents = {
11+
sessionId,
12+
};
13+
formData.PublishPackage = {
14+
sessionId,
15+
};
16+
formData.SelectComponents.listOfComponents = [];
17+
formData.SelectComponents.listOfInterceptors = [];
18+
formData.SelectComponents.listOfUtils = [];
19+
20+
Object.keys(config.interceptors).forEach((interceptor) => {
21+
schema.definitions.componentsList.dependencies.selectTheme.oneOf[1].properties.listOfInterceptors.items.enum.push(
22+
{
23+
key: config.interceptors[interceptor].name,
24+
value: config.interceptors[interceptor].name,
25+
disabled: config.interceptors[interceptor].isRequired,
26+
},
27+
);
28+
29+
if (config.interceptors[interceptor].isRequired) {
30+
formData.SelectComponents.listOfInterceptors.push(
31+
config.interceptors[interceptor].name,
32+
);
33+
}
34+
});
35+
36+
Object.keys(config.utils).forEach((util) => {
37+
/**
38+
* Todo: add support for component utils to be selected automatically and disabled
39+
*/
40+
schema.definitions.componentsList.dependencies.selectTheme.oneOf[1].properties.listOfUtils.items.enum.push(
41+
{
42+
key: config.utils[util].name,
43+
value: config.utils[util].name,
44+
disabled: config.utils[util].isRequired,
45+
},
46+
);
47+
48+
if (config.utils[util].isRequired) {
49+
formData.SelectComponents.listOfUtils.push(config.utils[util].name);
50+
}
51+
});
52+
53+
Object.keys(config.components).forEach((comp) => {
54+
const compEnums = schema
55+
.definitions
56+
.componentsList
57+
.dependencies
58+
.selectTheme.oneOf[1]
59+
.properties
60+
.listOfComponents
61+
.items
62+
.enum;
63+
64+
const compEnumVal = {
65+
key: config.components[comp].name,
66+
value: config.components[comp].name,
67+
disabled:
68+
config.components[comp].isDefault || config.components[comp].isRequired,
69+
};
70+
71+
if (config.components[comp]?.utils) {
72+
// Todo: Covert this to rules.json
73+
compEnumVal.onData = {
74+
equals: config.components[comp].name,
75+
adds: {
76+
listOfUtils: [],
77+
},
78+
};
79+
config.components[comp].utils.forEach((cu) => {
80+
const cUtils = config.utils[cu];
81+
compEnumVal.onData.adds.listOfUtils.push(cUtils.name);
82+
});
83+
}
84+
85+
compEnums.push(compEnumVal);
86+
87+
if (config.components[comp].isDefault || config.components[comp].isRequired) {
88+
formData.SelectComponents.listOfComponents.push(
89+
config.components[comp].name,
90+
);
91+
}
92+
});
93+
94+
export default {
95+
title: 'Steps UI',
96+
schema,
97+
uiSchema,
98+
formData,
99+
xhrSchema,
100+
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"test"
4141
],
4242
"dependencies": {
43+
"ts-node": "10.4.0",
44+
"shelljs": "0.8.4"
4345
},
4446
"description": "universal-jsonschema-form with UI and XHR Schema.",
4547
"devDependencies": {

scripts/generator/package-lock.json

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generator/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"@react-jsonschema-form-utils/parse-values": "2.0.1",
1818
"@react-native-jsonschema-form-components/empty-div": "0.0.1",
1919
"@react-native-jsonschema-form-components/material-checkbox": "0.0.1",
20-
"@react-native-jsonschema-form-components/material-input": "0.0.1",
21-
"@react-native-jsonschema-form-components/material-radio-group": "0.0.1",
22-
"@react-native-jsonschema-form-components/material-select": "0.0.1",
20+
"@react-native-jsonschema-form-components/material-input": "0.0.2",
21+
"@react-native-jsonschema-form-components/material-radio-group": "0.0.2",
22+
"@react-native-jsonschema-form-components/material-select": "0.0.3",
2323
"@react-native-jsonschema-form-components/material-switch": "0.0.1"
2424
}
2525
}

0 commit comments

Comments
 (0)