@cleanweb/react 1.1.1-beta.7 → 1.1.1-beta.8
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.js
CHANGED
@@ -110,8 +110,9 @@ testing: {
|
|
110
110
|
function MyComponentLogic() {
|
111
111
|
return _super !== null && _super.apply(this, arguments) || this;
|
112
112
|
}
|
113
|
-
MyComponentLogic.getInitialState = function () { return ({}); };
|
113
|
+
MyComponentLogic.getInitialState = function () { return ({ a: '' }); };
|
114
114
|
return MyComponentLogic;
|
115
115
|
}(ClassComponent));
|
116
116
|
;
|
117
|
+
var Template = MyComponentLogic.FC();
|
117
118
|
}
|
@@ -52,6 +52,9 @@ type o = object;
|
|
52
52
|
type InstanceClassParams = ConstructorParameters<typeof ComponentInstance<o, o, o>>;
|
53
53
|
export interface IComponentInstanceClass<Instance extends ComponentInstance<o, o, o> = ComponentInstance, Params extends InstanceClassParams = InstanceClassParams> extends IComponentLogicClass<Instance, Params> {
|
54
54
|
}
|
55
|
-
type
|
56
|
-
|
55
|
+
type UseInstance2 = {
|
56
|
+
<Class extends typeof ComponentInstance<EmptyObject, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, ...props: ([] | [EmptyObject])): InstanceType<Class>;
|
57
|
+
<Class extends typeof ComponentInstance<o, o, o>>(Methods: Class & IComponentInstanceClass<InstanceType<Class>>, ...props: [InstanceType<Class>['props']]): InstanceType<Class>;
|
58
|
+
};
|
59
|
+
export declare const useInstance: UseInstance2;
|
57
60
|
export {};
|
package/build/classy/instance.js
CHANGED
@@ -14,15 +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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
19
|
-
if (ar || !(i in from)) {
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
21
|
-
ar[i] = from[i];
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
25
|
-
};
|
26
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
27
18
|
exports.useInstance = exports.ComponentInstance = exports.noOp = exports.useMountCallbacks = void 0;
|
28
19
|
var react_1 = require("react");
|
@@ -118,14 +109,15 @@ exports.ComponentInstance = ComponentInstance;
|
|
118
109
|
* the second param is given `{}` as a default follow to account for the empty tuple case. TypeScript
|
119
110
|
* just wants us to use the rest parameter explicitly by force.
|
120
111
|
*/
|
121
|
-
var useInstance = function (
|
112
|
+
var useInstance = function () {
|
122
113
|
var _a;
|
123
114
|
var args = [];
|
124
|
-
for (var _i =
|
125
|
-
args[_i
|
115
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
116
|
+
args[_i] = arguments[_i];
|
126
117
|
}
|
118
|
+
var Component = args[0], _b = args[1], props = _b === void 0 ? {} : _b;
|
127
119
|
// useHooks.
|
128
|
-
var instance =
|
120
|
+
var instance = (0, logic_1.useLogic)(Component, props); // Must spread rest parameter, rather than passing a single `props` argument directly.
|
129
121
|
/**
|
130
122
|
* Argument of type '
|
131
123
|
* [
|
package/build/classy/logic.d.ts
CHANGED
@@ -12,6 +12,9 @@ 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
|
-
type
|
16
|
-
|
17
|
-
|
15
|
+
type UseLogic2 = {
|
16
|
+
<Class extends typeof ComponentLogic<Empty, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>, ...props: ([] | [EmptyObject])): InstanceType<Class>;
|
17
|
+
<Class extends typeof ComponentLogic<o, o, o>>(Methods: Class & IComponentLogicClass<InstanceType<Class>>, ...props: [InstanceType<Class>['props']]): InstanceType<Class>;
|
18
|
+
};
|
19
|
+
declare const useLogic: UseLogic2;
|
20
|
+
export { useLogic };
|
package/build/classy/logic.js
CHANGED
@@ -26,9 +26,13 @@ var ComponentLogic = /** @class */ (function () {
|
|
26
26
|
}());
|
27
27
|
exports.ComponentLogic = ComponentLogic;
|
28
28
|
;
|
29
|
-
var useLogic = function (
|
29
|
+
var useLogic = function () {
|
30
30
|
var _a, _b;
|
31
|
-
|
31
|
+
var args = [];
|
32
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
33
|
+
args[_i] = arguments[_i];
|
34
|
+
}
|
35
|
+
var Methods = args[0], _c = args[1], props = _c === void 0 ? {} : _c;
|
32
36
|
var state = (0, state_1.useCleanState)(Methods.getInitialState, props);
|
33
37
|
var methods = (0, react_1.useRef)((0, react_1.useMemo)(function () {
|
34
38
|
return new Methods();
|
@@ -53,21 +57,18 @@ testing: {
|
|
53
57
|
}(ComponentLogic));
|
54
58
|
;
|
55
59
|
MyComponentLogic.getInitialState;
|
56
|
-
var self_1 =
|
60
|
+
var self_1 = useLogic(MyComponentLogic);
|
57
61
|
}
|
58
62
|
testing: {
|
59
63
|
var A = /** @class */ (function (_super) {
|
60
64
|
__extends(C, _super);
|
61
65
|
function C() {
|
62
|
-
|
63
|
-
// static getInitialState = () => ({a: 'l'});
|
64
|
-
_this.b = _this.state.a;
|
65
|
-
return _this;
|
66
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
66
67
|
}
|
67
68
|
return C;
|
68
69
|
}(ComponentLogic));
|
69
70
|
A.getInitialState();
|
70
|
-
var self_2 = (
|
71
|
+
var self_2 = useLogic(A, { a: 'boo' });
|
71
72
|
}
|
72
73
|
// export type ComponentClassStatics<Instance extends ComponentLogic<object, object, object>> = {
|
73
74
|
// getInitialState: (props?: Instance['props']) => TState<Instance['state']>;
|
package/build/globals.d.ts
CHANGED
@@ -57,9 +57,7 @@ declare global {
|
|
57
57
|
''?: never;
|
58
58
|
};
|
59
59
|
type TEmptyObject2 = Record<symbol, never>;
|
60
|
-
type EmptyObject =
|
61
|
-
[key: keyof any]: never;
|
62
|
-
};
|
60
|
+
type EmptyObject = __FromPrivateHelpers['EmptyObject2'];
|
63
61
|
type EmptyObject2 = __FromPrivateHelpers['EmptyObject2'];
|
64
62
|
type EmptyObject3 = __FromPrivateHelpers['EmptyObject3'];
|
65
63
|
type valueof<TObject> = TObject[keyof TObject];
|