@cleanweb/react 2.1.0-beta.0 → 2.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/classy/class/index.d.ts +18 -0
- package/build/classy/class/index.js +20 -20
- package/build/classy/instance/index.d.ts +24 -1
- package/build/classy/instance/index.js +19 -18
- package/build/classy/instance/types/hook.d.ts +3 -3
- package/build/classy/logic/index.d.ts +31 -1
- package/build/classy/logic/index.js +26 -45
- package/build/classy/logic/types/hook.d.ts +3 -3
- package/build/helpers/index.d.ts +1 -0
- package/build/helpers/index.js +1 -0
- package/build/{classy/class/utils → helpers}/rerender.js +1 -1
- package/package.json +1 -1
- /package/build/classy/class/{utils/use-component → use-component}/index.d.ts +0 -0
- /package/build/classy/class/{utils/use-component → use-component}/index.js +0 -0
- /package/build/classy/class/{utils/use-component → use-component}/types.d.ts +0 -0
- /package/build/classy/class/{utils/use-component → use-component}/types.js +0 -0
- /package/build/{classy/class/utils → helpers}/rerender.d.ts +0 -0
@@ -81,3 +81,21 @@ export declare class ClassComponent<TProps extends object = WeakEmptyObject> ext
|
|
81
81
|
static readonly FC: Extractor;
|
82
82
|
}
|
83
83
|
export { ClassComponent as Component };
|
84
|
+
export { Use } from './use-component';
|
85
|
+
/** /
|
86
|
+
testing: {
|
87
|
+
const a: object = {b: ''};
|
88
|
+
|
89
|
+
type t = keyof typeof a;
|
90
|
+
|
91
|
+
class MyComponentLogic extends ClassComponent<{a: ''}> {
|
92
|
+
getInitialState = () => ({a: '' as const});
|
93
|
+
// a = () => this.hooks.a = '';
|
94
|
+
|
95
|
+
useHooks = () => {
|
96
|
+
this.state.a;
|
97
|
+
};
|
98
|
+
};
|
99
|
+
|
100
|
+
const Template = MyComponentLogic.FC();
|
101
|
+
}/**/
|
@@ -15,11 +15,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
15
15
|
};
|
16
16
|
})();
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
18
|
-
exports.Component = exports.ClassComponent = void 0;
|
18
|
+
exports.Use = exports.Component = exports.ClassComponent = void 0;
|
19
19
|
var react_1 = require("react");
|
20
20
|
var instance_1 = require("../instance");
|
21
21
|
var function_name_1 = require("./utils/function-name");
|
22
|
-
var rerender_1 = require("
|
22
|
+
var rerender_1 = require("../../helpers/rerender");
|
23
23
|
/**
|
24
24
|
* A superset of {@link ComponentInstance} that allows defining your
|
25
25
|
* component's JSX template directly inside the class.
|
@@ -128,22 +128,22 @@ var ClassComponent = /** @class */ (function (_super) {
|
|
128
128
|
}(instance_1.ComponentInstance));
|
129
129
|
exports.ClassComponent = ClassComponent;
|
130
130
|
exports.Component = ClassComponent;
|
131
|
-
|
131
|
+
var use_component_1 = require("./use-component");
|
132
|
+
Object.defineProperty(exports, "Use", { enumerable: true, get: function () { return use_component_1.Use; } });
|
133
|
+
/** /
|
132
134
|
testing: {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
var Template = MyComponentLogic.FC();
|
149
|
-
} /**/
|
135
|
+
const a: object = {b: ''};
|
136
|
+
|
137
|
+
type t = keyof typeof a;
|
138
|
+
|
139
|
+
class MyComponentLogic extends ClassComponent<{a: ''}> {
|
140
|
+
getInitialState = () => ({a: '' as const});
|
141
|
+
// a = () => this.hooks.a = '';
|
142
|
+
|
143
|
+
useHooks = () => {
|
144
|
+
this.state.a;
|
145
|
+
};
|
146
|
+
};
|
147
|
+
|
148
|
+
const Template = MyComponentLogic.FC();
|
149
|
+
}/**/
|
@@ -10,7 +10,7 @@ export declare const noOp: () => void;
|
|
10
10
|
*
|
11
11
|
* @see https://github.com/cleanjsweb/neat-react#lifecycle-useinstance
|
12
12
|
*/
|
13
|
-
export declare class ComponentInstance<TProps extends object =
|
13
|
+
export declare class ComponentInstance<TProps extends object = NonPrimitive> extends ComponentLogic<TProps> {
|
14
14
|
/**
|
15
15
|
* Runs only _before_ first render,
|
16
16
|
* i.e before the component instance is mounted.
|
@@ -62,3 +62,26 @@ export declare class ComponentInstance<TProps extends object = {}> extends Compo
|
|
62
62
|
}
|
63
63
|
export declare const useInstance: UseInstance;
|
64
64
|
export {};
|
65
|
+
/** /
|
66
|
+
testing: {
|
67
|
+
class A extends ComponentInstance<WeakEmptyObject> {
|
68
|
+
getInitialState = (p?: object) => ({putan: ''});
|
69
|
+
// k = this.props.o
|
70
|
+
am = this.state['_initialValues_'];
|
71
|
+
k = this.am.putan;
|
72
|
+
|
73
|
+
beforeRender = () => ({g: ''});
|
74
|
+
|
75
|
+
useHooks = () => {
|
76
|
+
return {j: 9};
|
77
|
+
};
|
78
|
+
}
|
79
|
+
|
80
|
+
const a = useInstance(A, {});
|
81
|
+
a.am;
|
82
|
+
|
83
|
+
// a.props['o'];
|
84
|
+
type bbbb = A['state'];
|
85
|
+
type ttt = bbbb['put'];
|
86
|
+
}
|
87
|
+
/**/
|
@@ -148,25 +148,26 @@ var useInstance = function () {
|
|
148
148
|
return instance;
|
149
149
|
};
|
150
150
|
exports.useInstance = useInstance;
|
151
|
-
|
151
|
+
/** /
|
152
152
|
testing: {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
return A;
|
168
|
-
}(ComponentInstance));
|
169
|
-
var a = (0, exports.useInstance)(A, {});
|
153
|
+
class A extends ComponentInstance<WeakEmptyObject> {
|
154
|
+
getInitialState = (p?: object) => ({putan: ''});
|
155
|
+
// k = this.props.o
|
156
|
+
am = this.state['_initialValues_'];
|
157
|
+
k = this.am.putan;
|
158
|
+
|
159
|
+
beforeRender = () => ({g: ''});
|
160
|
+
|
161
|
+
useHooks = () => {
|
162
|
+
return {j: 9};
|
163
|
+
};
|
164
|
+
}
|
165
|
+
|
166
|
+
const a = useInstance(A, {});
|
170
167
|
a.am;
|
168
|
+
|
169
|
+
// a.props['o'];
|
170
|
+
type bbbb = A['state'];
|
171
|
+
type ttt = bbbb['put'];
|
171
172
|
}
|
172
173
|
/**/
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { ComponentInstance } from '..';
|
2
|
-
type UIClassParam = typeof ComponentInstance<
|
2
|
+
type UIClassParam = typeof ComponentInstance<any>;
|
3
3
|
type UIProplessClassParam = typeof ComponentInstance<HardEmptyObject>;
|
4
4
|
export type UseInstance = {
|
5
5
|
<Class extends UIProplessClassParam>(Methods: Class): InstanceType<Class>;
|
6
6
|
<Class extends UIClassParam>(Methods: Class, props: InstanceType<Class>['props']): InstanceType<Class>;
|
7
7
|
};
|
8
8
|
export type UIParams = [
|
9
|
-
Class: typeof ComponentInstance
|
9
|
+
Class: typeof ComponentInstance<any>,
|
10
10
|
props?: object
|
11
11
|
];
|
12
|
-
export type UIReturn = ComponentInstance
|
12
|
+
export type UIReturn = ComponentInstance<any>;
|
13
13
|
export {};
|
@@ -14,7 +14,7 @@ export type WeakEmpty = WeakEmptyObject;
|
|
14
14
|
*
|
15
15
|
* Call the {@link useLogic} hook inside your function component to instantiate the class.
|
16
16
|
*/
|
17
|
-
export declare class ComponentLogic<TProps extends object =
|
17
|
+
export declare class ComponentLogic<TProps extends object = NonPrimitive> {
|
18
18
|
/**
|
19
19
|
* A {@link TCleanState | `CleanState`} object.
|
20
20
|
* Holds all of your component's state,
|
@@ -46,3 +46,33 @@ export declare class ComponentLogic<TProps extends object = {}> {
|
|
46
46
|
useHooks: () => object | void;
|
47
47
|
}
|
48
48
|
export declare const useLogic: UseLogic;
|
49
|
+
/** /
|
50
|
+
testing: {
|
51
|
+
const a: object = {b: ''};
|
52
|
+
|
53
|
+
type t = keyof typeof a;
|
54
|
+
|
55
|
+
class MyComponentLogic extends ComponentLogic<{}> {
|
56
|
+
getInitialState = () => ({b: 7});
|
57
|
+
b = () => 8 + this.state.b;
|
58
|
+
|
59
|
+
useHooks = () => ({a: 'undefined'});
|
60
|
+
};
|
61
|
+
|
62
|
+
type tt = keyof {};
|
63
|
+
|
64
|
+
const self = useLogic(MyComponentLogic);
|
65
|
+
self.hooks;
|
66
|
+
self.useHooks();
|
67
|
+
|
68
|
+
|
69
|
+
const A = class C extends ComponentLogic {
|
70
|
+
getInitialState = () => ({a: 'l'});
|
71
|
+
a = () => this.state.a = '';
|
72
|
+
}
|
73
|
+
|
74
|
+
// const oa = {['a' as unknown as symbol]: 'boo'};
|
75
|
+
const oa = {['a']: 'boo'};
|
76
|
+
useLogic(A, oa);
|
77
|
+
}
|
78
|
+
/**/
|
@@ -1,20 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
3
|
-
var extendStatics = function (d, b) {
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7
|
-
return extendStatics(d, b);
|
8
|
-
};
|
9
|
-
return function (d, b) {
|
10
|
-
if (typeof b !== "function" && b !== null)
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12
|
-
extendStatics(d, b);
|
13
|
-
function __() { this.constructor = d; }
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
-
};
|
16
|
-
})();
|
17
|
-
var _a;
|
18
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
19
3
|
exports.useLogic = exports.ComponentLogic = void 0;
|
20
4
|
var react_1 = require("react");
|
@@ -78,36 +62,33 @@ var useLogic = function () {
|
|
78
62
|
return self;
|
79
63
|
};
|
80
64
|
exports.useLogic = useLogic;
|
81
|
-
|
65
|
+
/** /
|
82
66
|
testing: {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
107
|
-
return C;
|
108
|
-
}(ComponentLogic));
|
67
|
+
const a: object = {b: ''};
|
68
|
+
|
69
|
+
type t = keyof typeof a;
|
70
|
+
|
71
|
+
class MyComponentLogic extends ComponentLogic<{}> {
|
72
|
+
getInitialState = () => ({b: 7});
|
73
|
+
b = () => 8 + this.state.b;
|
74
|
+
|
75
|
+
useHooks = () => ({a: 'undefined'});
|
76
|
+
};
|
77
|
+
|
78
|
+
type tt = keyof {};
|
79
|
+
|
80
|
+
const self = useLogic(MyComponentLogic);
|
81
|
+
self.hooks;
|
82
|
+
self.useHooks();
|
83
|
+
|
84
|
+
|
85
|
+
const A = class C extends ComponentLogic {
|
86
|
+
getInitialState = () => ({a: 'l'});
|
87
|
+
a = () => this.state.a = '';
|
88
|
+
}
|
89
|
+
|
109
90
|
// const oa = {['a' as unknown as symbol]: 'boo'};
|
110
|
-
|
111
|
-
|
91
|
+
const oa = {['a']: 'boo'};
|
92
|
+
useLogic(A, oa);
|
112
93
|
}
|
113
94
|
/**/
|
@@ -3,15 +3,15 @@ import type { ComponentLogic } from '..';
|
|
3
3
|
* # Hooks *
|
4
4
|
**************************************/
|
5
5
|
/** */
|
6
|
-
type ULClassParam = typeof ComponentLogic<
|
6
|
+
type ULClassParam = typeof ComponentLogic<any>;
|
7
7
|
type ULProplessClassParam = typeof ComponentLogic<HardEmptyObject>;
|
8
8
|
export type UseLogic = {
|
9
9
|
<Class extends ULProplessClassParam>(Methods: Class): InstanceType<Class>;
|
10
10
|
<Class extends ULClassParam>(Methods: Class, props: InstanceType<Class>['props']): InstanceType<Class>;
|
11
11
|
};
|
12
12
|
export type ULParams = [
|
13
|
-
Class: typeof ComponentLogic
|
13
|
+
Class: typeof ComponentLogic<any>,
|
14
14
|
props?: object
|
15
15
|
];
|
16
|
-
export type ULReturn = ComponentLogic
|
16
|
+
export type ULReturn = ComponentLogic<any>;
|
17
17
|
export {};
|
package/build/helpers/index.d.ts
CHANGED
package/build/helpers/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.useRerender = void 0;
|
4
|
-
var mount_state_1 = require("
|
4
|
+
var mount_state_1 = require("../helpers/mount-state");
|
5
5
|
var react_1 = require("react");
|
6
6
|
var useRerender = function () {
|
7
7
|
var isMounted = (0, mount_state_1.useMountState)();
|
package/package.json
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|