@cleanweb/react 2.1.0-beta.1 → 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.
@@ -82,3 +82,20 @@ export declare class ClassComponent<TProps extends object = WeakEmptyObject> ext
82
82
  }
83
83
  export { ClassComponent as Component };
84
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
+ }/**/
@@ -130,22 +130,20 @@ exports.ClassComponent = ClassComponent;
130
130
  exports.Component = ClassComponent;
131
131
  var use_component_1 = require("./use-component");
132
132
  Object.defineProperty(exports, "Use", { enumerable: true, get: function () { return use_component_1.Use; } });
133
- /**/
133
+ /** /
134
134
  testing: {
135
- var a = { b: '' };
136
- var MyComponentLogic = /** @class */ (function (_super) {
137
- __extends(MyComponentLogic, _super);
138
- function MyComponentLogic() {
139
- var _this = _super !== null && _super.apply(this, arguments) || this;
140
- _this.getInitialState = function () { return ({ a: '' }); };
141
- // a = () => this.hooks.a = '';
142
- _this.useHooks = function () {
143
- _this.state.a;
144
- };
145
- return _this;
146
- }
147
- return MyComponentLogic;
148
- }(ClassComponent));
149
- ;
150
- var Template = MyComponentLogic.FC();
151
- } /**/
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 = {}> extends ComponentLogic<TProps> {
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
- var A = /** @class */ (function (_super) {
154
- __extends(A, _super);
155
- function A() {
156
- var _this = _super !== null && _super.apply(this, arguments) || this;
157
- _this.getInitialState = function (p) { return ({ putan: '' }); };
158
- // k = this.props.o
159
- _this.am = _this.state['_initialValues_'];
160
- _this.k = _this.am.putan;
161
- _this.beforeRender = function () { return ({ g: '' }); };
162
- _this.useHooks = function () {
163
- return { j: 9 };
164
- };
165
- return _this;
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<object>;
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
- var a = { b: '' };
84
- var MyComponentLogic = /** @class */ (function (_super) {
85
- __extends(MyComponentLogic, _super);
86
- function MyComponentLogic() {
87
- var _this = _super !== null && _super.apply(this, arguments) || this;
88
- _this.getInitialState = function () { return ({ b: 7 }); };
89
- _this.b = function () { return 8 + _this.state.b; };
90
- _this.useHooks = function () { return ({ a: 'undefined' }); };
91
- return _this;
92
- }
93
- return MyComponentLogic;
94
- }(ComponentLogic));
95
- ;
96
- var self_1 = (0, exports.useLogic)(MyComponentLogic);
97
- self_1.hooks;
98
- self_1.useHooks();
99
- var A = /** @class */ (function (_super) {
100
- __extends(C, _super);
101
- function C() {
102
- var _this = _super !== null && _super.apply(this, arguments) || this;
103
- _this.getInitialState = function () { return ({ a: 'l' }); };
104
- _this.a = function () { return _this.state.a = ''; };
105
- return _this;
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
- var oa = (_a = {}, _a['a'] = 'boo', _a);
111
- (0, exports.useLogic)(A, oa);
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<object>;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanweb/react",
3
- "version": "2.1.0-beta.1",
3
+ "version": "2.1.0-beta.2",
4
4
  "description": "A suite of helpers for writing cleaner React function components.",
5
5
  "engines": {
6
6
  "node": ">=18"