Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit a009b93

Browse files
committed
fixed examples
1 parent 877dea3 commit a009b93

File tree

22 files changed

+167
-147
lines changed

22 files changed

+167
-147
lines changed

examples/react-native/develop/AwesomeTSProject/core/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { createState, createComputed, createCollection } from '@agile-ts/core';
2-
import { createEvent, Event } from '@agile-ts/event';
2+
import { createEvent } from '@agile-ts/event';
33
import { Alert } from 'react-native';
44

55
export const MY_STATE = createState<string>('MyState', { key: 'my-state' }); //.persist();
66
export const MY_STATE_2 = createState<string>('MyState2'); //.persist("my-state2");
7-
export const MY_STATE_3 = createState<number>(1); //.persist("my-state2");
87

98
MY_STATE.watch('test', (value: any) => {
109
console.log('Watch ' + value);
@@ -37,8 +36,6 @@ MY_COLLECTION.getGroup('myGroup')?.persist({
3736
followCollectionPersistKeyPattern: true,
3837
});
3938

40-
console.log('Initial: myCollection ', MY_COLLECTION);
41-
4239
export const MY_EVENT = createEvent<{ name: string }>();
4340

4441
MY_EVENT.on('Test', (payload) => {

examples/react-native/develop/AwesomeTSProject/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"start": "react-native start",
99
"test": "jest",
1010
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
11-
"install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api & yarn install"
11+
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/event & yarn install",
12+
"install:prod:agile": "yarn add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/event & yarn install"
1213
},
1314
"dependencies": {
1415
"@agile-ts/api": "file:.yalc/@agile-ts/api",

examples/react-native/develop/AwesomeTSProject/yarn.lock

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@
33

44

55
"@agile-ts/api@file:.yalc/@agile-ts/api":
6-
version "0.0.5"
6+
version "0.0.22"
7+
dependencies:
8+
"@agile-ts/utils" "^0.0.8"
79

810
"@agile-ts/core@file:.yalc/@agile-ts/core":
9-
version "0.0.5"
11+
version "0.2.3"
12+
dependencies:
13+
"@agile-ts/utils" "^0.0.8"
14+
15+
"@agile-ts/event@file:.yalc/@agile-ts/event":
16+
version "0.0.11"
1017

1118
"@agile-ts/react@file:.yalc/@agile-ts/react":
12-
version "0.0.5"
19+
version "0.2.0"
20+
21+
"@agile-ts/utils@^0.0.8":
22+
version "0.0.8"
23+
resolved "https://registry.yarnpkg.com/@agile-ts/utils/-/utils-0.0.8.tgz#ab9e1eeaddf282340936bddeb74421a2f77de804"
24+
integrity sha512-ex19gPIS5imgV+rzs5HE2CNAIkQ162hPWH5u3HKNZnHiVU6FX62sikH5tG2oQocbDb7FkeB16D7v9ihQeuKYug==
1325

1426
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4":
1527
version "7.10.4"

examples/react/develop/class-component-ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"build": "react-scripts build",
3030
"test": "react-scripts test",
3131
"eject": "react-scripts eject",
32-
"install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event & yarn install"
32+
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event & yarn install",
33+
"install:prod:agile": "yarn add @agile-ts/core @agile-ts/react @agile-ts/api @agile-ts/multieditor @agile-ts/event & yarn install"
3334
},
3435
"eslintConfig": {
3536
"extends": "react-app"

examples/react/develop/class-component-ts/src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
createComputed,
55
createCollection,
66
} from '@agile-ts/core';
7-
import { createEvent, Event } from '@agile-ts/event';
7+
import { createEvent } from '@agile-ts/event';
88

99
export const MY_STATE = createState<string>('MyState'); //.persist();
1010
export const MY_STATE_2 = createState<string>('MyState2', {

examples/react/develop/class-component-ts/yarn.lock

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33

44

55
"@agile-ts/api@file:.yalc/@agile-ts/api":
6-
version "0.0.14"
6+
version "0.0.22"
7+
dependencies:
8+
"@agile-ts/utils" "^0.0.8"
79

810
"@agile-ts/core@file:.yalc/@agile-ts/core":
9-
version "0.0.13"
11+
version "0.2.3"
12+
dependencies:
13+
"@agile-ts/utils" "^0.0.8"
14+
15+
"@agile-ts/event@file:.yalc/@agile-ts/event":
16+
version "0.0.11"
1017

1118
"@agile-ts/multieditor@file:.yalc/@agile-ts/multieditor":
12-
version "0.0.13"
19+
version "0.0.21"
1320

1421
"@agile-ts/react@file:.yalc/@agile-ts/react":
15-
version "0.0.14"
22+
version "0.2.0"
23+
24+
"@agile-ts/utils@^0.0.8":
25+
version "0.0.8"
26+
resolved "https://registry.yarnpkg.com/@agile-ts/utils/-/utils-0.0.8.tgz#ab9e1eeaddf282340936bddeb74421a2f77de804"
27+
integrity sha512-ex19gPIS5imgV+rzs5HE2CNAIkQ162hPWH5u3HKNZnHiVU6FX62sikH5tG2oQocbDb7FkeB16D7v9ihQeuKYug==
1628

1729
"@babel/code-frame@7.8.3":
1830
version "7.8.3"

examples/react/develop/functional-component-ts/src/core/index.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
import Agile, {
2-
assignSharedAgileInstance,
1+
import {
32
createCollection,
43
createComputed,
54
createState,
65
createStorage,
76
createStorageManager,
87
Item,
9-
assignSharedAgileStorageManager,
8+
assignSharedStorageManager,
109
} from '@agile-ts/core';
1110
import { createEvent } from '@agile-ts/event';
12-
import { assignSharedAgileLoggerConfig, Logger } from '@agile-ts/logger';
11+
import { assignSharedLogger, createLogger, Logger } from '@agile-ts/logger';
1312
import { clone } from '@agile-ts/utils';
1413

1514
export const myStorage: any = {};
1615

17-
assignSharedAgileLoggerConfig({ level: Logger.level.DEBUG });
18-
export const App = new Agile();
19-
assignSharedAgileInstance(App);
16+
assignSharedLogger(createLogger({ level: Logger.level.DEBUG }));
2017

2118
export const storageManager = createStorageManager({ localStorage: true });
22-
assignSharedAgileStorageManager(storageManager);
19+
assignSharedStorageManager(storageManager);
2320

2421
// Register custom second Storage
2522
storageManager.register(

examples/react/develop/multieditor-ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"build": "react-scripts build",
2727
"test": "react-scripts test",
2828
"eject": "react-scripts eject",
29-
"install:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/multieditor & yarn install"
29+
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/multieditor & yarn install",
30+
"install:prod:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/multieditor & yarn install"
3031
},
3132
"eslintConfig": {
3233
"extends": [

examples/react/develop/multieditor-ts/src/core/agile.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 61 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import MultiEditor, { Validator } from '@agile-ts/multieditor';
2-
import App from './agile';
1+
import { createMultieditor, Validator } from '@agile-ts/multieditor';
32
import { generateColor, generateId, isLight } from './utils';
43

54
export const isValidNameValidator = new Validator()
@@ -9,73 +8,66 @@ export const isValidNameValidator = new Validator()
98
.max(10)
109
.matches(/^([^0-9]*)$/, 'No Numbers allowed!');
1110

12-
export const signUpEditor = new MultiEditor(
13-
(editor) => ({
14-
data: {
15-
id: 'myCoolId',
16-
firstName: 'Jeff',
17-
lastName: '',
18-
gender: undefined,
19-
userName: '',
20-
email: '',
21-
aboutYou: '',
22-
age: undefined,
23-
image: {
24-
id: generateId(),
25-
color: generateColor(),
26-
},
11+
export const signUpEditor = createMultieditor((editor) => ({
12+
data: {
13+
id: 'myCoolId',
14+
firstName: 'Jeff',
15+
lastName: '',
16+
gender: undefined,
17+
userName: '',
18+
email: '',
19+
aboutYou: '',
20+
age: undefined,
21+
image: {
22+
id: generateId(),
23+
color: generateColor(),
2724
},
28-
onSubmit: async (preparedData) => {
29-
alert(JSON.stringify(preparedData));
25+
},
26+
onSubmit: async (preparedData) => {
27+
alert(JSON.stringify(preparedData));
28+
},
29+
validateMethods: {
30+
firstName: isValidNameValidator,
31+
lastName: isValidNameValidator,
32+
userName: isValidNameValidator
33+
.clone()
34+
.addValidationMethod(async (key, value, editor) => {
35+
const isValid = value === 'Jeff';
36+
if (!isValid)
37+
editor.setStatus(key, 'error', 'Sry only the name Jeff is allowed!');
38+
return isValid;
39+
}),
40+
email: editor.Validator().required().string().email(),
41+
aboutYou: editor
42+
.Validator()
43+
.required()
44+
.string()
45+
.min(10)
46+
.addValidationMethod(async (key, value, editor) => {
47+
const isValid = typeof value === 'string' && !value.includes('fuck');
48+
if (!isValid)
49+
editor.setStatus(key, 'error', 'The word fuck is not allowed!');
50+
return isValid;
51+
}),
52+
age: editor.Validator().required().number().min(18).max(100),
53+
gender: editor.Validator().required(),
54+
image: editor
55+
.Validator()
56+
.required()
57+
.addValidationMethod(async (key, value, editor) => {
58+
const isValid = isLight(value.color);
59+
if (!isValid) editor.setStatus(key, 'error', 'The Image is to dark!');
60+
return isValid;
61+
}),
62+
},
63+
computeMethods: {
64+
lastName: (value) => {
65+
return value && typeof value === 'string' ? value.toUpperCase() : value;
3066
},
31-
validateMethods: {
32-
firstName: isValidNameValidator,
33-
lastName: isValidNameValidator,
34-
userName: isValidNameValidator
35-
.clone()
36-
.addValidationMethod(async (key, value, editor) => {
37-
const isValid = value === 'Jeff';
38-
if (!isValid)
39-
editor.setStatus(
40-
key,
41-
'error',
42-
'Sry only the name Jeff is allowed!'
43-
);
44-
return isValid;
45-
}),
46-
email: editor.Validator().required().string().email(),
47-
aboutYou: editor
48-
.Validator()
49-
.required()
50-
.string()
51-
.min(10)
52-
.addValidationMethod(async (key, value, editor) => {
53-
const isValid = typeof value === 'string' && !value.includes('fuck');
54-
if (!isValid)
55-
editor.setStatus(key, 'error', 'The word fuck is not allowed!');
56-
return isValid;
57-
}),
58-
age: editor.Validator().required().number().min(18).max(100),
59-
gender: editor.Validator().required(),
60-
image: editor
61-
.Validator()
62-
.required()
63-
.addValidationMethod(async (key, value, editor) => {
64-
const isValid = isLight(value.color);
65-
if (!isValid) editor.setStatus(key, 'error', 'The Image is to dark!');
66-
return isValid;
67-
}),
67+
age: (value) => {
68+
return Number(value) || value;
6869
},
69-
computeMethods: {
70-
lastName: (value) => {
71-
return value && typeof value === 'string' ? value.toUpperCase() : value;
72-
},
73-
age: (value) => {
74-
return Number(value) || value;
75-
},
76-
},
77-
fixedProperties: ['id'],
78-
reValidateMode: 'afterFirstSubmit',
79-
}),
80-
App
81-
);
70+
},
71+
fixedProperties: ['id'],
72+
reValidateMode: 'afterFirstSubmit',
73+
}));

0 commit comments

Comments
 (0)