|
| 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 | +}; |
0 commit comments