Skip to content

Commit 0268761

Browse files
base-field state.Field type fixed.
OnStoreUpdated setState fixed to return the state after mutation. simplr-forms-dom preparations for convenient publishing.
1 parent 15b3d20 commit 0268761

File tree

14 files changed

+507
-312
lines changed

14 files changed

+507
-312
lines changed

packages/simplr-forms-core/src/abstractions/base-field.ts

Lines changed: 289 additions & 285 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "simplr-forms-dom",
3-
"version": "4.0.0-pre-alpha.10",
3+
"version": "4.0.0-pre-alpha.13",
44
"description": "DOM components for simplr-forms.",
55
"repository": "SimplrJS/simplr-forms",
66
"homepage": "https://github.com/SimplrJS/simplr-forms",
7-
"main": "dist/simplr-forms-dom.js",
8-
"types": "@types/index.d.ts",
7+
"main": "main.js",
8+
"types": "index.d.ts",
99
"author": "simplrjs <[email protected]> (https://github.com/simplrjs)",
1010
"scripts": {
1111
"build": "webpack && npm run tslint",
@@ -15,15 +15,17 @@
1515
"release": "npm run build && npm run uglifyjs",
1616
"test": "jest",
1717
"test-watch": "jest --watchAll",
18-
"test-coverage": "npm test -- --coverage"
18+
"test-coverage": "npm test -- --coverage",
19+
"prepublishOnly": "npm run build && node tools/postbuild.js",
20+
"postpublish": "git clean -fd"
1921
},
2022
"license": "AGPL-3.0",
2123
"files": [
22-
"dist",
23-
"@types",
2424
"**/*.md",
2525
"*.js",
26-
"!*.config.js"
26+
"*.d.ts",
27+
"!*.config.js",
28+
"!tools"
2729
],
2830
"devDependencies": {
2931
"@types/enzyme": "^2.7.7",
@@ -32,17 +34,21 @@
3234
"enzyme": "^2.8.0",
3335
"jest": "^19.0.2",
3436
"jest-enzyme": "^3.0.0",
37+
"mkdirp": "^0.5.1",
38+
"mv": "^2.1.1",
39+
"mz": "^2.6.0",
3540
"sinon": "^2.1.0",
3641
"ts-jest": "^19.0.8",
3742
"ts-loader": "^2.0.3",
3843
"tslint": "^5.0.0",
3944
"typescript": "2.3.0",
40-
"webpack": "^2.4.1"
45+
"webpack": "^2.4.1",
46+
"simplr-forms-publish": "0.0.0-dev"
4147
},
4248
"dependencies": {
4349
"@types/react": "^15.0.21",
4450
"react": "^15.5.4",
45-
"simplr-forms-core": "^4.0.0-pre-alpha.10"
51+
"simplr-forms-core": "^4.0.0-pre-alpha.11"
4652
},
4753
"jest": {
4854
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
@@ -56,4 +62,4 @@
5662
"js"
5763
]
5864
}
59-
}
65+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./abstractions/index";

packages/simplr-forms-dom/src/components/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/simplr-forms-dom/src/components/text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Text extends BaseDomField<TextProps, BaseDomFieldState> {
4242
if (this.props != null && this.props.value != null) {
4343
return this.props.value;
4444
}
45-
return "";
45+
return this.DefaultValue;
4646
}
4747

4848
protected get DefaultValue(): CoreContracts.FieldValue {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./contracts/field";

packages/simplr-forms-dom/src/contracts/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
import * as Abstractions from "./abstractions/index";
2-
import * as Components from "./components/index";
3-
import * as Contracts from "./contracts/index";
4-
5-
export {
6-
Abstractions,
7-
Components,
8-
Contracts
9-
};
1+
export * from "./components/form";
2+
export * from "./components/text";
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const mv = require("mv");
2+
const fs = require("mz/fs");
3+
const path = require("path");
4+
const process = require("process");
5+
const mkdirp = require("mkdirp");
6+
7+
async function move(from, to, recursively = true, removeFromDirectory = true, rootFrom = undefined) {
8+
from = path.resolve(from);
9+
to = path.resolve(to);
10+
11+
rootFrom = rootFrom || from;
12+
13+
const files = await fs.readdir(from);
14+
for (const file of files) {
15+
const stats = await fs.stat(path.join(from, file));
16+
if (await stats.isFile()) {
17+
const fileResolved = path.resolve(from, file);
18+
const fromDirectory = path.dirname(fileResolved);
19+
const toDirectory = fromDirectory.replace(rootFrom, to);
20+
const toFile = path.join(toDirectory, fileResolved.replace(fromDirectory, ""));
21+
22+
try {
23+
await mkdirpAsync(toDirectory);
24+
await fs.rename(fileResolved, toFile);
25+
} catch (err) {
26+
console.log(err);
27+
}
28+
}
29+
if (await stats.isDirectory()) {
30+
if (recursively === true) {
31+
const fromDirectory = path.join(from, file);
32+
await move(fromDirectory, to, recursively, removeFromDirectory, from);
33+
if (removeFromDirectory === true && await fs.exists(fromDirectory)) {
34+
await fs.rmdir(fromDirectory);
35+
}
36+
}
37+
}
38+
}
39+
if (removeFromDirectory === true && await fs.exists(from)) {
40+
await fs.rmdir(from);
41+
}
42+
}
43+
44+
async function mkdirpAsync(dir) {
45+
return new Promise((resolve, reject) => {
46+
mkdirp(dir, (err, made) => {
47+
if (err) {
48+
reject(err);
49+
return;
50+
}
51+
resolve(made);
52+
});
53+
});
54+
}
55+
56+
async function run() {
57+
const from = "./dist";
58+
const to = ".";
59+
await move(from, to, true);
60+
}
61+
62+
run();

packages/simplr-forms-dom/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"sourceMap": false,
1010
"skipDefaultLibCheck": true,
1111
"declaration": true,
12-
"declarationDir": "@types",
1312
"pretty": true,
1413
"strict": true,
1514
"lib": [

0 commit comments

Comments
 (0)