@cleanweb/react 1.1.1-beta.3 → 1.1.1-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/build/base/methods.d.ts +1 -1
- package/build/classy/logic.d.ts +1 -2
- package/build/classy/logic.js +20 -18
- package/package.json +1 -1
package/build/base/methods.d.ts
CHANGED
@@ -3,6 +3,6 @@ export declare class ComponentMethods<TState extends object, TProps extends obje
|
|
3
3
|
state: TCleanState<TState>;
|
4
4
|
props: TProps;
|
5
5
|
}
|
6
|
-
type UseMethods = <
|
6
|
+
type UseMethods = <Class extends typeof ComponentMethods<object, object>>(Methods: Class & Constructor<InstanceType<Class>>, state: InstanceType<Class>['state'], props: InstanceType<Class>['props']) => InstanceType<Class>;
|
7
7
|
export declare const useMethods: UseMethods;
|
8
8
|
export {};
|
package/build/classy/logic.d.ts
CHANGED
@@ -5,14 +5,13 @@ export declare class ComponentLogic<TState extends o = Empty, TProps extends o =
|
|
5
5
|
state: TCleanState<TState>;
|
6
6
|
props: TProps;
|
7
7
|
hooks: THooks;
|
8
|
-
static getInitialState:
|
8
|
+
static getInitialState: (p?: o) => {};
|
9
9
|
useHooks?: () => THooks;
|
10
10
|
}
|
11
11
|
type LogicClassParams = ConstructorParameters<typeof ComponentLogic>;
|
12
12
|
export interface IComponentLogicClass<Instance extends ComponentLogic<o, o, o> = ComponentLogic, Params extends LogicClassParams = LogicClassParams> extends Constructor<Instance, Params> {
|
13
13
|
getInitialState: (props?: Instance['props']) => TState<Instance['state']>;
|
14
14
|
}
|
15
|
-
export type TBaseComponentLogic = IComponentLogicClass<ComponentLogic<o, o, o>>;
|
16
15
|
type UseLogic = <Class extends typeof ComponentLogic<o, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>, ...props: valueof<InstanceType<Class>['props']> extends never ? ([] | [EmptyObject] | [InstanceType<Class>['props']]) : [InstanceType<Class>['props']]) => InstanceType<Class>;
|
17
16
|
export declare const useLogic: UseLogic;
|
18
17
|
export {};
|
package/build/classy/logic.js
CHANGED
@@ -14,7 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
15
|
};
|
16
16
|
})();
|
17
|
-
var _a;
|
18
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
19
18
|
exports.useLogic = exports.ComponentLogic = void 0;
|
20
19
|
var react_1 = require("react");
|
@@ -23,12 +22,13 @@ var state_1 = require("../base/state");
|
|
23
22
|
var ComponentLogic = /** @class */ (function () {
|
24
23
|
function ComponentLogic() {
|
25
24
|
}
|
25
|
+
ComponentLogic.getInitialState = function (p) { return ({}); };
|
26
26
|
return ComponentLogic;
|
27
27
|
}());
|
28
28
|
exports.ComponentLogic = ComponentLogic;
|
29
29
|
;
|
30
30
|
var useLogic = function (Methods, props) {
|
31
|
-
var
|
31
|
+
var _a, _b;
|
32
32
|
if (props === void 0) { props = {}; }
|
33
33
|
var state = (0, state_1.useCleanState)(Methods.getInitialState, props);
|
34
34
|
var methods = (0, react_1.useRef)((0, react_1.useMemo)(function () {
|
@@ -36,7 +36,7 @@ var useLogic = function (Methods, props) {
|
|
36
36
|
}, [])).current;
|
37
37
|
methods.state = state;
|
38
38
|
methods.props = props;
|
39
|
-
methods.hooks = (
|
39
|
+
methods.hooks = (_b = (_a = methods.useHooks) === null || _a === void 0 ? void 0 : _a.call(methods)) !== null && _b !== void 0 ? _b : {};
|
40
40
|
return methods;
|
41
41
|
};
|
42
42
|
exports.useLogic = useLogic;
|
@@ -45,28 +45,30 @@ testing: {
|
|
45
45
|
var MyComponentLogic = /** @class */ (function (_super) {
|
46
46
|
__extends(MyComponentLogic, _super);
|
47
47
|
function MyComponentLogic() {
|
48
|
-
|
48
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
49
|
+
_this.b = _this.state.a;
|
50
|
+
return _this;
|
49
51
|
}
|
50
|
-
MyComponentLogic.getInitialState = function () { return ({}); };
|
52
|
+
MyComponentLogic.getInitialState = function (p) { return ({ a: '' }); };
|
51
53
|
return MyComponentLogic;
|
52
54
|
}(ComponentLogic));
|
53
55
|
;
|
54
|
-
|
56
|
+
MyComponentLogic.getInitialState;
|
57
|
+
var self_1 = (0, exports.useLogic)(MyComponentLogic, {});
|
55
58
|
}
|
56
59
|
testing: {
|
57
|
-
var A =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
_a);
|
60
|
+
var A = /** @class */ (function (_super) {
|
61
|
+
__extends(C, _super);
|
62
|
+
function C() {
|
63
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
64
|
+
// static getInitialState = () => ({a: 'l'});
|
65
|
+
_this.b = _this.state.a;
|
66
|
+
return _this;
|
67
|
+
}
|
68
|
+
return C;
|
69
|
+
}(ComponentLogic));
|
68
70
|
A.getInitialState();
|
69
|
-
|
71
|
+
var self_2 = (0, exports.useLogic)(A);
|
70
72
|
}
|
71
73
|
// export type ComponentClassStatics<Instance extends ComponentLogic<object, object, object>> = {
|
72
74
|
// getInitialState: (props?: Instance['props']) => TState<Instance['state']>;
|