Skip to content

Commit 0a56dd4

Browse files
committed
feat: initial commit for universal schema
1 parent 22589b5 commit 0a56dd4

11 files changed

+144
-22
lines changed

src/Form.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Todo:
3+
* - This file should be generated for react framework code gen
4+
* - All Material UI libs should come from UIFramework const
5+
* - All imports should be optional based on what gets selected
6+
*/
17
// Library
28
import React from 'react';
39
import { nanoid as generate } from 'nanoid';
@@ -10,6 +16,7 @@ import CircularProgress from '@material-ui/core/CircularProgress';
1016

1117
// Types
1218
import { FormProps } from '@core-types/Form.type';
19+
import Framework from './universal-schema/react.framework';
1320

1421
// Internal
1522
import formStyles from './form-styles';
@@ -27,6 +34,11 @@ import {
2734
// Initial Contexts
2835
import { LoadingContext, EventContext, StepperContext } from './helpers/context';
2936

37+
// const {
38+
// React,
39+
// nanoId: generate,
40+
// } = Framework.library;
41+
3042
const Form = ({
3143
formData: originalFormData,
3244
schema = {},

src/universal-schema/angular.framework.ts

Whitespace-only changes.

src/universal-schema/ionic.framework.ts

Whitespace-only changes.

src/universal-schema/native-script.framework.ts

Whitespace-only changes.

src/universal-schema/react-native.framework.ts

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { UniversalSchemaFramework } from './types/universal-schema-framework.type';
2+
3+
const Framework: UniversalSchemaFramework = {
4+
library: {
5+
React: import('react'),
6+
nanoId: async () => (await import('nanoid')).nanoid,
7+
},
8+
uiFramework: {
9+
name: 'MaterialUI',
10+
platform: 'web',
11+
components: {
12+
string: {
13+
input: import('@material-ui/core/Input'),
14+
},
15+
array: {
16+
select: import('@material-ui/core/Select'),
17+
},
18+
boolean: {
19+
checkbox: import('@material-ui/core/Checkbox'),
20+
},
21+
null: {
22+
emptyDiv: import('@material-ui/core/Divider'),
23+
},
24+
},
25+
},
26+
interceptors: {
27+
translateRatings: import('@react-jsonschema-form-interceptors/translate-ratings'),
28+
// translateCurrency: import('@react-jsonschema-form-interceptors/translate-currency'),
29+
translateRangeDate: import('@react-jsonschema-form-interceptors/translate-range-date'),
30+
},
31+
parsers: {
32+
enumUtils: import('@react-jsonschema-form-utils/enum-utils'),
33+
parseValues: import('@react-jsonschema-form-utils/parse-values'),
34+
},
35+
};
36+
37+
export default Framework;

src/universal-schema/stencil.framework.ts

Whitespace-only changes.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
interface Library {
2+
// Frameworks
3+
React?: Promise<any>;
4+
Angular?: Promise<any>;
5+
ReactNative?: Promise<any>;
6+
NativeScript?: Promise<any>;
7+
Ionic?: Promise<any>;
8+
Stencil?: Promise<any>;
9+
Vue?: Promise<any>;
10+
11+
// Util Libs
12+
nanoId?: Function;
13+
}
14+
15+
interface Components {
16+
// Mandatory components for every UIFramework
17+
string: {
18+
input: Promise<any>;
19+
20+
// Optional Components
21+
select?: Promise<any>;
22+
radioGroup?: Promise<any>;
23+
autoComplete?: Promise<any>;
24+
picker?: Promise<any>;
25+
upload?: Promise<any>;
26+
richTextEditor?: Promise<any>;
27+
ratings?: Promise<any>;
28+
},
29+
null: {
30+
emptyDiv: Promise<any>;
31+
},
32+
array: {
33+
select: Promise<any>;
34+
35+
// Optional Components
36+
autoComplete?: Promise<any>;
37+
38+
// React Specific Components
39+
creatableSelect?: Promise<any>;
40+
reactSelect?: Promise<any>;
41+
},
42+
boolean: {
43+
checkbox: Promise<any>;
44+
45+
// Optional Components
46+
switch?: Promise<any>;
47+
},
48+
}
49+
50+
interface Parsers {
51+
enumUtils?: Promise<any>;
52+
parseValues?: Promise<any>;
53+
}
54+
55+
interface Interceptors {
56+
translateRatings?: Promise<any>;
57+
translateCurrency?: Promise<any>;
58+
translateRangeDate?: Promise<any>;
59+
}
60+
61+
type UIFrameworkNames = 'MaterialUI' | 'SemanticUI' | 'BootstrapUI' | 'FluentUI' | 'ReactNativePaperUI' | 'Ionic';
62+
type UIFrameworkPlatforms = 'web' | 'mobile' | 'desktop';
63+
64+
interface UIFramework {
65+
name: UIFrameworkNames;
66+
platform: UIFrameworkPlatforms;
67+
components: Components;
68+
}
69+
70+
export interface UniversalSchemaFramework {
71+
library: Library;
72+
parsers: Parsers;
73+
interceptors: Interceptors;
74+
uiFramework: UIFramework;
75+
}

src/universal-schema/vue.framework.ts

Whitespace-only changes.

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@config/*": ["./src/config/*"],
88
},
99
"forceConsistentCasingInFileNames": true,
10-
"module": "es6",
10+
"module": "esnext",
1111
"moduleResolution": "node",
1212
"preserveConstEnums": true,
1313
"declaration": true,
@@ -16,7 +16,7 @@
1616
"noLib": false,
1717
"emitDecoratorMetadata": true,
1818
"experimentalDecorators": true,
19-
"target": "es6",
19+
"target": "esnext",
2020
"resolveJsonModule": true,
2121
"sourceMap": true,
2222
"allowJs": true,

0 commit comments

Comments
 (0)