@aweebit/react-essentials 0.10.5 → 0.10.6
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/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
const useEventListener: UseEventListener;
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Defined in: [hooks/useEventListener.ts:135](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
23
|
+
Defined in: [hooks/useEventListener.ts:135](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L135)
|
|
24
24
|
|
|
25
25
|
Adds `handler` as a listener for the event `eventName` of `target` with the
|
|
26
26
|
provided `options` applied
|
|
@@ -71,7 +71,7 @@ function useReducerWithDeps<S, A>(
|
|
|
71
71
|
): [S, ActionDispatch<A>];
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
Defined in: [hooks/useReducerWithDeps.ts:59](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
74
|
+
Defined in: [hooks/useReducerWithDeps.ts:59](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useReducerWithDeps.ts#L59)
|
|
75
75
|
|
|
76
76
|
`useReducer` hook with an additional dependency array `deps` that resets the
|
|
77
77
|
state to `initialState` when dependencies change
|
|
@@ -214,7 +214,7 @@ function useStateWithDeps<S>(
|
|
|
214
214
|
): [S, Dispatch<SetStateAction<S>>];
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
Defined in: [hooks/useStateWithDeps.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
217
|
+
Defined in: [hooks/useStateWithDeps.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useStateWithDeps.ts#L62)
|
|
218
218
|
|
|
219
219
|
`useState` hook with an additional dependency array `deps` that resets the
|
|
220
220
|
state to `initialState` when dependencies change
|
|
@@ -341,10 +341,10 @@ Dependencies that reset the state to `initialState`
|
|
|
341
341
|
## contextualize()
|
|
342
342
|
|
|
343
343
|
```ts
|
|
344
|
-
function contextualize(children): ContextualizePipe
|
|
344
|
+
function contextualize<Children>(children): ContextualizePipe<Children>;
|
|
345
345
|
```
|
|
346
346
|
|
|
347
|
-
Defined in: [misc/contextualize.tsx:79](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
347
|
+
Defined in: [misc/contextualize.tsx:79](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/contextualize.tsx#L79)
|
|
348
348
|
|
|
349
349
|
An alternative way to provide context values to component trees that avoids
|
|
350
350
|
ever-increasing indentation
|
|
@@ -386,6 +386,25 @@ return contextualize(jsx)
|
|
|
386
386
|
.end();
|
|
387
387
|
```
|
|
388
388
|
|
|
389
|
+
### Type Parameters
|
|
390
|
+
|
|
391
|
+
<table>
|
|
392
|
+
<thead>
|
|
393
|
+
<tr>
|
|
394
|
+
<th>Type Parameter</th>
|
|
395
|
+
</tr>
|
|
396
|
+
</thead>
|
|
397
|
+
<tbody>
|
|
398
|
+
<tr>
|
|
399
|
+
<td>
|
|
400
|
+
|
|
401
|
+
`Children` _extends_ `ReactNode`
|
|
402
|
+
|
|
403
|
+
</td>
|
|
404
|
+
</tr>
|
|
405
|
+
</tbody>
|
|
406
|
+
</table>
|
|
407
|
+
|
|
389
408
|
### Parameters
|
|
390
409
|
|
|
391
410
|
<table>
|
|
@@ -405,7 +424,7 @@ return contextualize(jsx)
|
|
|
405
424
|
</td>
|
|
406
425
|
<td>
|
|
407
426
|
|
|
408
|
-
`
|
|
427
|
+
`Children`
|
|
409
428
|
|
|
410
429
|
</td>
|
|
411
430
|
<td>
|
|
@@ -419,7 +438,7 @@ The children to contextualize
|
|
|
419
438
|
|
|
420
439
|
### Returns
|
|
421
440
|
|
|
422
|
-
[`ContextualizePipe`](#contextualizepipe)
|
|
441
|
+
[`ContextualizePipe`](#contextualizepipe)\<`Children`\>
|
|
423
442
|
|
|
424
443
|
An object with the following properties:
|
|
425
444
|
|
|
@@ -444,7 +463,7 @@ function createSafeContext<T>(): <DisplayName>(displayName) => {
|
|
|
444
463
|
};
|
|
445
464
|
```
|
|
446
465
|
|
|
447
|
-
Defined in: [misc/createSafeContext.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
466
|
+
Defined in: [misc/createSafeContext.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/createSafeContext.ts#L62)
|
|
448
467
|
|
|
449
468
|
For a given type `T`, returns a function that produces both a context of that
|
|
450
469
|
type and a hook that returns the current context value if one was provided,
|
|
@@ -589,7 +608,7 @@ A function that accepts a single string argument `displayName` (e.g.
|
|
|
589
608
|
function wrapJSX<Children>(children): JSXWrapPipe<Children>;
|
|
590
609
|
```
|
|
591
610
|
|
|
592
|
-
Defined in: [misc/wrapJSX.tsx:99](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
611
|
+
Defined in: [misc/wrapJSX.tsx:99](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/wrapJSX.tsx#L99)
|
|
593
612
|
|
|
594
613
|
An alternative way to compose JSX that avoids ever-increasing indentation
|
|
595
614
|
|
|
@@ -704,7 +723,7 @@ type UseEventListener = UseEventListenerWithImplicitWindowTarget &
|
|
|
704
723
|
UseEventListenerWithAnyExplicitTarget;
|
|
705
724
|
```
|
|
706
725
|
|
|
707
|
-
Defined in: [hooks/useEventListener.ts:12](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
726
|
+
Defined in: [hooks/useEventListener.ts:12](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L12)
|
|
708
727
|
|
|
709
728
|
The type of [`useEventListener`](#useeventlistener)
|
|
710
729
|
|
|
@@ -723,7 +742,7 @@ The type of [`useEventListener`](#useeventlistener)
|
|
|
723
742
|
type UseEventListenerWithImplicitWindowTarget = <K>(...args) => void;
|
|
724
743
|
```
|
|
725
744
|
|
|
726
|
-
Defined in: [hooks/useEventListener.ts:21](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
745
|
+
Defined in: [hooks/useEventListener.ts:21](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L21)
|
|
727
746
|
|
|
728
747
|
### Type Parameters
|
|
729
748
|
|
|
@@ -791,7 +810,7 @@ type UseEventListenerWithExplicitGlobalTarget =
|
|
|
791
810
|
UseEventListenerWithExplicitTarget<MathMLElement, MathMLElementEventMap>;
|
|
792
811
|
```
|
|
793
812
|
|
|
794
|
-
Defined in: [hooks/useEventListener.ts:32](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
813
|
+
Defined in: [hooks/useEventListener.ts:32](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L32)
|
|
795
814
|
|
|
796
815
|
### See
|
|
797
816
|
|
|
@@ -808,7 +827,7 @@ type UseEventListenerWithExplicitTarget<Target, EventMap> = <T, K>(
|
|
|
808
827
|
) => void;
|
|
809
828
|
```
|
|
810
829
|
|
|
811
|
-
Defined in: [hooks/useEventListener.ts:44](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
830
|
+
Defined in: [hooks/useEventListener.ts:44](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L44)
|
|
812
831
|
|
|
813
832
|
### Type Parameters
|
|
814
833
|
|
|
@@ -907,7 +926,7 @@ type UseEventListenerWithAnyExplicitTarget = UseEventListenerWithExplicitTarget<
|
|
|
907
926
|
>;
|
|
908
927
|
```
|
|
909
928
|
|
|
910
|
-
Defined in: [hooks/useEventListener.ts:56](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
929
|
+
Defined in: [hooks/useEventListener.ts:56](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L56)
|
|
911
930
|
|
|
912
931
|
### See
|
|
913
932
|
|
|
@@ -928,7 +947,7 @@ type UseEventListenerWithImplicitWindowTargetArgs<K> =
|
|
|
928
947
|
: never;
|
|
929
948
|
```
|
|
930
949
|
|
|
931
|
-
Defined in: [hooks/useEventListener.ts:64](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
950
|
+
Defined in: [hooks/useEventListener.ts:64](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L64)
|
|
932
951
|
|
|
933
952
|
### Type Parameters
|
|
934
953
|
|
|
@@ -973,7 +992,7 @@ type UseEventListenerWithExplicitTargetArgs<EventMap, T, K> = [
|
|
|
973
992
|
];
|
|
974
993
|
```
|
|
975
994
|
|
|
976
|
-
Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
995
|
+
Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/hooks/useEventListener.ts#L78)
|
|
977
996
|
|
|
978
997
|
### Type Parameters
|
|
979
998
|
|
|
@@ -1017,13 +1036,13 @@ Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-esse
|
|
|
1017
1036
|
## ContextualizePipe
|
|
1018
1037
|
|
|
1019
1038
|
```ts
|
|
1020
|
-
type ContextualizePipe = {
|
|
1039
|
+
type ContextualizePipe<Children> = {
|
|
1021
1040
|
with: ContextualizeWith;
|
|
1022
|
-
end: () =>
|
|
1041
|
+
end: () => Children;
|
|
1023
1042
|
};
|
|
1024
1043
|
```
|
|
1025
1044
|
|
|
1026
|
-
Defined in: [misc/contextualize.tsx:13](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1045
|
+
Defined in: [misc/contextualize.tsx:13](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/contextualize.tsx#L13)
|
|
1027
1046
|
|
|
1028
1047
|
The return type of [`contextualize`](#contextualize)
|
|
1029
1048
|
|
|
@@ -1032,6 +1051,25 @@ The return type of [`contextualize`](#contextualize)
|
|
|
1032
1051
|
[`contextualize`](#contextualize),
|
|
1033
1052
|
[`ContextualizeWith`](#contextualizewith)
|
|
1034
1053
|
|
|
1054
|
+
### Type Parameters
|
|
1055
|
+
|
|
1056
|
+
<table>
|
|
1057
|
+
<thead>
|
|
1058
|
+
<tr>
|
|
1059
|
+
<th>Type Parameter</th>
|
|
1060
|
+
</tr>
|
|
1061
|
+
</thead>
|
|
1062
|
+
<tbody>
|
|
1063
|
+
<tr>
|
|
1064
|
+
<td>
|
|
1065
|
+
|
|
1066
|
+
`Children` _extends_ `ReactNode`
|
|
1067
|
+
|
|
1068
|
+
</td>
|
|
1069
|
+
</tr>
|
|
1070
|
+
</tbody>
|
|
1071
|
+
</table>
|
|
1072
|
+
|
|
1035
1073
|
### Properties
|
|
1036
1074
|
|
|
1037
1075
|
<table>
|
|
@@ -1062,7 +1100,7 @@ The return type of [`contextualize`](#contextualize)
|
|
|
1062
1100
|
</td>
|
|
1063
1101
|
<td>
|
|
1064
1102
|
|
|
1065
|
-
() => `
|
|
1103
|
+
() => `Children`
|
|
1066
1104
|
|
|
1067
1105
|
</td>
|
|
1068
1106
|
</tr>
|
|
@@ -1074,10 +1112,10 @@ The return type of [`contextualize`](#contextualize)
|
|
|
1074
1112
|
## ContextualizeWith()
|
|
1075
1113
|
|
|
1076
1114
|
```ts
|
|
1077
|
-
type ContextualizeWith = <T>(Context, value) => ContextualizePipe
|
|
1115
|
+
type ContextualizeWith = <T>(Context, value) => ContextualizePipe<ReactElement>;
|
|
1078
1116
|
```
|
|
1079
1117
|
|
|
1080
|
-
Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1118
|
+
Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/contextualize.tsx#L23)
|
|
1081
1119
|
|
|
1082
1120
|
### Type Parameters
|
|
1083
1121
|
|
|
@@ -1137,7 +1175,7 @@ Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essenti
|
|
|
1137
1175
|
|
|
1138
1176
|
### Returns
|
|
1139
1177
|
|
|
1140
|
-
[`ContextualizePipe`](#contextualizepipe)
|
|
1178
|
+
[`ContextualizePipe`](#contextualizepipe)\<`ReactElement`\>
|
|
1141
1179
|
|
|
1142
1180
|
### See
|
|
1143
1181
|
|
|
@@ -1155,7 +1193,7 @@ type JSXWrapPipe<Children> = {
|
|
|
1155
1193
|
};
|
|
1156
1194
|
```
|
|
1157
1195
|
|
|
1158
|
-
Defined in: [misc/wrapJSX.tsx:19](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1196
|
+
Defined in: [misc/wrapJSX.tsx:19](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/wrapJSX.tsx#L19)
|
|
1159
1197
|
|
|
1160
1198
|
The return type of [`wrapJSX`](#wrapjsx)
|
|
1161
1199
|
|
|
@@ -1228,7 +1266,7 @@ The return type of [`wrapJSX`](#wrapjsx)
|
|
|
1228
1266
|
type WrapJSXWith<Children> = <C>(...args) => JSXWrapPipe<ReactElement>;
|
|
1229
1267
|
```
|
|
1230
1268
|
|
|
1231
|
-
Defined in: [misc/wrapJSX.tsx:29](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1269
|
+
Defined in: [misc/wrapJSX.tsx:29](https://github.com/aweebit/react-essentials/blob/v0.10.6/src/misc/wrapJSX.tsx#L29)
|
|
1232
1270
|
|
|
1233
1271
|
### Type Parameters
|
|
1234
1272
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context, ReactNode } from 'react';
|
|
1
|
+
import type { Context, ReactElement, ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* The return type of {@linkcode contextualize}
|
|
4
4
|
*
|
|
@@ -6,16 +6,16 @@ import type { Context, ReactNode } from 'react';
|
|
|
6
6
|
* {@linkcode contextualize},
|
|
7
7
|
* {@linkcode ContextualizeWith}
|
|
8
8
|
*/
|
|
9
|
-
export type ContextualizePipe = {
|
|
9
|
+
export type ContextualizePipe<Children extends ReactNode> = {
|
|
10
10
|
with: ContextualizeWith;
|
|
11
|
-
end: () =>
|
|
11
|
+
end: () => Children;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* @see
|
|
15
15
|
* {@linkcode contextualize},
|
|
16
16
|
* {@linkcode ContextualizePipe}
|
|
17
17
|
*/
|
|
18
|
-
export type ContextualizeWith = <T>(Context: Context<T>, value: NoInfer<T>) => ContextualizePipe
|
|
18
|
+
export type ContextualizeWith = <T>(Context: Context<T>, value: NoInfer<T>) => ContextualizePipe<ReactElement>;
|
|
19
19
|
/**
|
|
20
20
|
* An alternative way to provide context values to component trees that avoids
|
|
21
21
|
* ever-increasing indentation
|
|
@@ -67,5 +67,5 @@ export type ContextualizeWith = <T>(Context: Context<T>, value: NoInfer<T>) => C
|
|
|
67
67
|
* @see
|
|
68
68
|
* {@linkcode ContextualizePipe}
|
|
69
69
|
*/
|
|
70
|
-
export declare function contextualize(children:
|
|
70
|
+
export declare function contextualize<Children extends ReactNode>(children: Children): ContextualizePipe<Children>;
|
|
71
71
|
//# sourceMappingURL=contextualize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextualize.d.ts","sourceRoot":"","sources":["../../src/misc/contextualize.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"contextualize.d.ts","sourceRoot":"","sources":["../../src/misc/contextualize.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK9D;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,SAAS,IAAI;IAC1D,IAAI,EAAE,iBAAiB,CAAC;IACxB,GAAG,EAAE,MAAM,QAAQ,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KACd,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,SAAS,EACtD,QAAQ,EAAE,QAAQ,GACjB,iBAAiB,CAAC,QAAQ,CAAC,CAW7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextualize.js","sourceRoot":"","sources":["../../src/misc/contextualize.tsx"],"names":[],"mappings":";AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,UAAU,aAAa,
|
|
1
|
+
{"version":3,"file":"contextualize.js","sourceRoot":"","sources":["../../src/misc/contextualize.tsx"],"names":[],"mappings":";AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAkB;IAElB,OAAO;QACL,IAAI,CAAI,OAAmB,EAAE,KAAQ;YACnC,OAAO,aAAa,CAClB,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAoB,CAC9D,CAAC;QACJ,CAAC;QACD,GAAG;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context, ReactNode } from 'react';
|
|
1
|
+
import type { Context, ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
4
|
import type { wrapJSX } from './wrapJSX.js';
|
|
@@ -10,9 +10,9 @@ import type { wrapJSX } from './wrapJSX.js';
|
|
|
10
10
|
* {@linkcode contextualize},
|
|
11
11
|
* {@linkcode ContextualizeWith}
|
|
12
12
|
*/
|
|
13
|
-
export type ContextualizePipe = {
|
|
13
|
+
export type ContextualizePipe<Children extends ReactNode> = {
|
|
14
14
|
with: ContextualizeWith;
|
|
15
|
-
end: () =>
|
|
15
|
+
end: () => Children;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -23,7 +23,7 @@ export type ContextualizePipe = {
|
|
|
23
23
|
export type ContextualizeWith = <T>(
|
|
24
24
|
Context: Context<T>,
|
|
25
25
|
value: NoInfer<T>,
|
|
26
|
-
) => ContextualizePipe
|
|
26
|
+
) => ContextualizePipe<ReactElement>;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* An alternative way to provide context values to component trees that avoids
|
|
@@ -76,7 +76,9 @@ export type ContextualizeWith = <T>(
|
|
|
76
76
|
* @see
|
|
77
77
|
* {@linkcode ContextualizePipe}
|
|
78
78
|
*/
|
|
79
|
-
export function contextualize
|
|
79
|
+
export function contextualize<Children extends ReactNode>(
|
|
80
|
+
children: Children,
|
|
81
|
+
): ContextualizePipe<Children> {
|
|
80
82
|
return {
|
|
81
83
|
with<T>(Context: Context<T>, value: T) {
|
|
82
84
|
return contextualize(
|