@aweebit/react-essentials 0.10.2 → 0.10.4
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 +33 -33
- package/dist/misc/contextualize.d.ts +6 -6
- package/dist/misc/contextualize.d.ts.map +1 -1
- package/dist/misc/contextualize.js +6 -6
- package/dist/misc/contextualize.js.map +1 -1
- package/dist/misc/wrapJSX.d.ts +6 -6
- package/dist/misc/wrapJSX.d.ts.map +1 -1
- package/dist/misc/wrapJSX.js +6 -6
- package/dist/misc/wrapJSX.js.map +1 -1
- package/package.json +1 -1
- package/src/misc/contextualize.tsx +8 -10
- package/src/misc/wrapJSX.tsx +8 -7
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.4/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.4/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.4/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(
|
|
344
|
+
function contextualize(children): ContextualizePipe;
|
|
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.4/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
|
|
@@ -400,17 +400,17 @@ return contextualize(jsx)
|
|
|
400
400
|
<tr>
|
|
401
401
|
<td>
|
|
402
402
|
|
|
403
|
-
`
|
|
403
|
+
`children`
|
|
404
404
|
|
|
405
405
|
</td>
|
|
406
406
|
<td>
|
|
407
407
|
|
|
408
|
-
`
|
|
408
|
+
`ReactNode`
|
|
409
409
|
|
|
410
410
|
</td>
|
|
411
411
|
<td>
|
|
412
412
|
|
|
413
|
-
The
|
|
413
|
+
The children to contextualize
|
|
414
414
|
|
|
415
415
|
</td>
|
|
416
416
|
</tr>
|
|
@@ -425,8 +425,8 @@ An object with the following properties:
|
|
|
425
425
|
|
|
426
426
|
- `with`: a function that accepts a context `Context` and a value `value` for
|
|
427
427
|
it as arguments and returns
|
|
428
|
-
`contextualize(<Context.Provider value={value}>{
|
|
429
|
-
- `end`: a function that returns `
|
|
428
|
+
`contextualize(<Context.Provider value={value}>{children}</Context.Provider>)`
|
|
429
|
+
- `end`: a function that returns `children`
|
|
430
430
|
|
|
431
431
|
### See
|
|
432
432
|
|
|
@@ -444,7 +444,7 @@ function createSafeContext<T>(): <DisplayName>(displayName) => {
|
|
|
444
444
|
};
|
|
445
445
|
```
|
|
446
446
|
|
|
447
|
-
Defined in: [misc/createSafeContext.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
447
|
+
Defined in: [misc/createSafeContext.ts:62](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/createSafeContext.ts#L62)
|
|
448
448
|
|
|
449
449
|
For a given type `T`, returns a function that produces both a context of that
|
|
450
450
|
type and a hook that returns the current context value if one was provided,
|
|
@@ -586,10 +586,10 @@ A function that accepts a single string argument `displayName` (e.g.
|
|
|
586
586
|
## wrapJSX()
|
|
587
587
|
|
|
588
588
|
```ts
|
|
589
|
-
function wrapJSX(
|
|
589
|
+
function wrapJSX(children): JSXWrapPipe;
|
|
590
590
|
```
|
|
591
591
|
|
|
592
|
-
Defined in: [misc/wrapJSX.tsx:
|
|
592
|
+
Defined in: [misc/wrapJSX.tsx:94](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/wrapJSX.tsx#L94)
|
|
593
593
|
|
|
594
594
|
An alternative way to compose JSX that avoids ever-increasing indentation
|
|
595
595
|
|
|
@@ -643,17 +643,17 @@ createRoot(document.getElementById('root')!).render(
|
|
|
643
643
|
<tr>
|
|
644
644
|
<td>
|
|
645
645
|
|
|
646
|
-
`
|
|
646
|
+
`children`
|
|
647
647
|
|
|
648
648
|
</td>
|
|
649
649
|
<td>
|
|
650
650
|
|
|
651
|
-
`
|
|
651
|
+
`ReactNode`
|
|
652
652
|
|
|
653
653
|
</td>
|
|
654
654
|
<td>
|
|
655
655
|
|
|
656
|
-
The
|
|
656
|
+
The children to wrap
|
|
657
657
|
|
|
658
658
|
</td>
|
|
659
659
|
</tr>
|
|
@@ -668,8 +668,8 @@ An object with the following properties:
|
|
|
668
668
|
|
|
669
669
|
- `with`: a function that accepts a component `Component` and props `props`
|
|
670
670
|
for it as arguments and returns
|
|
671
|
-
`wrapJSX(<Component {...props}>{
|
|
672
|
-
- `end`: a function that returns `
|
|
671
|
+
`wrapJSX(<Component {...props}>{children}</Component>)`
|
|
672
|
+
- `end`: a function that returns `children`
|
|
673
673
|
|
|
674
674
|
### See
|
|
675
675
|
|
|
@@ -685,7 +685,7 @@ type UseEventListener = UseEventListenerWithImplicitWindowTarget &
|
|
|
685
685
|
UseEventListenerWithAnyExplicitTarget;
|
|
686
686
|
```
|
|
687
687
|
|
|
688
|
-
Defined in: [hooks/useEventListener.ts:12](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
688
|
+
Defined in: [hooks/useEventListener.ts:12](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L12)
|
|
689
689
|
|
|
690
690
|
The type of [`useEventListener`](#useeventlistener)
|
|
691
691
|
|
|
@@ -704,7 +704,7 @@ The type of [`useEventListener`](#useeventlistener)
|
|
|
704
704
|
type UseEventListenerWithImplicitWindowTarget = <K>(...args) => void;
|
|
705
705
|
```
|
|
706
706
|
|
|
707
|
-
Defined in: [hooks/useEventListener.ts:21](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
707
|
+
Defined in: [hooks/useEventListener.ts:21](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L21)
|
|
708
708
|
|
|
709
709
|
### Type Parameters
|
|
710
710
|
|
|
@@ -772,7 +772,7 @@ type UseEventListenerWithExplicitGlobalTarget =
|
|
|
772
772
|
UseEventListenerWithExplicitTarget<MathMLElement, MathMLElementEventMap>;
|
|
773
773
|
```
|
|
774
774
|
|
|
775
|
-
Defined in: [hooks/useEventListener.ts:32](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
775
|
+
Defined in: [hooks/useEventListener.ts:32](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L32)
|
|
776
776
|
|
|
777
777
|
### See
|
|
778
778
|
|
|
@@ -789,7 +789,7 @@ type UseEventListenerWithExplicitTarget<Target, EventMap> = <T, K>(
|
|
|
789
789
|
) => void;
|
|
790
790
|
```
|
|
791
791
|
|
|
792
|
-
Defined in: [hooks/useEventListener.ts:44](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
792
|
+
Defined in: [hooks/useEventListener.ts:44](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L44)
|
|
793
793
|
|
|
794
794
|
### Type Parameters
|
|
795
795
|
|
|
@@ -888,7 +888,7 @@ type UseEventListenerWithAnyExplicitTarget = UseEventListenerWithExplicitTarget<
|
|
|
888
888
|
>;
|
|
889
889
|
```
|
|
890
890
|
|
|
891
|
-
Defined in: [hooks/useEventListener.ts:56](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
891
|
+
Defined in: [hooks/useEventListener.ts:56](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L56)
|
|
892
892
|
|
|
893
893
|
### See
|
|
894
894
|
|
|
@@ -909,7 +909,7 @@ type UseEventListenerWithImplicitWindowTargetArgs<K> =
|
|
|
909
909
|
: never;
|
|
910
910
|
```
|
|
911
911
|
|
|
912
|
-
Defined in: [hooks/useEventListener.ts:64](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
912
|
+
Defined in: [hooks/useEventListener.ts:64](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L64)
|
|
913
913
|
|
|
914
914
|
### Type Parameters
|
|
915
915
|
|
|
@@ -954,7 +954,7 @@ type UseEventListenerWithExplicitTargetArgs<EventMap, T, K> = [
|
|
|
954
954
|
];
|
|
955
955
|
```
|
|
956
956
|
|
|
957
|
-
Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
957
|
+
Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/hooks/useEventListener.ts#L78)
|
|
958
958
|
|
|
959
959
|
### Type Parameters
|
|
960
960
|
|
|
@@ -1000,11 +1000,11 @@ Defined in: [hooks/useEventListener.ts:78](https://github.com/aweebit/react-esse
|
|
|
1000
1000
|
```ts
|
|
1001
1001
|
type ContextualizePipe = {
|
|
1002
1002
|
with: ContextualizeWith;
|
|
1003
|
-
end: () =>
|
|
1003
|
+
end: () => ReactNode;
|
|
1004
1004
|
};
|
|
1005
1005
|
```
|
|
1006
1006
|
|
|
1007
|
-
Defined in: [misc/contextualize.tsx:13](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1007
|
+
Defined in: [misc/contextualize.tsx:13](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/contextualize.tsx#L13)
|
|
1008
1008
|
|
|
1009
1009
|
The return type of [`contextualize`](#contextualize)
|
|
1010
1010
|
|
|
@@ -1043,7 +1043,7 @@ The return type of [`contextualize`](#contextualize)
|
|
|
1043
1043
|
</td>
|
|
1044
1044
|
<td>
|
|
1045
1045
|
|
|
1046
|
-
() => `
|
|
1046
|
+
() => `ReactNode`
|
|
1047
1047
|
|
|
1048
1048
|
</td>
|
|
1049
1049
|
</tr>
|
|
@@ -1058,7 +1058,7 @@ The return type of [`contextualize`](#contextualize)
|
|
|
1058
1058
|
type ContextualizeWith = <T>(Context, value) => ContextualizePipe;
|
|
1059
1059
|
```
|
|
1060
1060
|
|
|
1061
|
-
Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essentials/blob/v0.10.
|
|
1061
|
+
Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/contextualize.tsx#L23)
|
|
1062
1062
|
|
|
1063
1063
|
### Type Parameters
|
|
1064
1064
|
|
|
@@ -1132,11 +1132,11 @@ Defined in: [misc/contextualize.tsx:23](https://github.com/aweebit/react-essenti
|
|
|
1132
1132
|
```ts
|
|
1133
1133
|
type JSXWrapPipe = {
|
|
1134
1134
|
with: WrapJSXWith;
|
|
1135
|
-
end: () =>
|
|
1135
|
+
end: () => ReactNode;
|
|
1136
1136
|
};
|
|
1137
1137
|
```
|
|
1138
1138
|
|
|
1139
|
-
Defined in: [misc/wrapJSX.tsx:
|
|
1139
|
+
Defined in: [misc/wrapJSX.tsx:18](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/wrapJSX.tsx#L18)
|
|
1140
1140
|
|
|
1141
1141
|
The return type of [`wrapJSX`](#wrapjsx)
|
|
1142
1142
|
|
|
@@ -1175,7 +1175,7 @@ The return type of [`wrapJSX`](#wrapjsx)
|
|
|
1175
1175
|
</td>
|
|
1176
1176
|
<td>
|
|
1177
1177
|
|
|
1178
|
-
() => `
|
|
1178
|
+
() => `ReactNode`
|
|
1179
1179
|
|
|
1180
1180
|
</td>
|
|
1181
1181
|
</tr>
|
|
@@ -1190,7 +1190,7 @@ The return type of [`wrapJSX`](#wrapjsx)
|
|
|
1190
1190
|
type WrapJSXWith = <C>(...args) => JSXWrapPipe;
|
|
1191
1191
|
```
|
|
1192
1192
|
|
|
1193
|
-
Defined in: [misc/wrapJSX.tsx:
|
|
1193
|
+
Defined in: [misc/wrapJSX.tsx:28](https://github.com/aweebit/react-essentials/blob/v0.10.4/src/misc/wrapJSX.tsx#L28)
|
|
1194
1194
|
|
|
1195
1195
|
### Type Parameters
|
|
1196
1196
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Context,
|
|
1
|
+
import type { Context, ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* The return type of {@linkcode contextualize}
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import type { Context, default as React } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
export type ContextualizePipe = {
|
|
10
10
|
with: ContextualizeWith;
|
|
11
|
-
end: () =>
|
|
11
|
+
end: () => ReactNode;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* @see
|
|
@@ -56,16 +56,16 @@ export type ContextualizeWith = <T>(Context: Context<T>, value: NoInfer<T>) => C
|
|
|
56
56
|
* .end();
|
|
57
57
|
* ```
|
|
58
58
|
*
|
|
59
|
-
* @param
|
|
59
|
+
* @param children The children to contextualize
|
|
60
60
|
*
|
|
61
61
|
* @returns An object with the following properties:
|
|
62
62
|
* - `with`: a function that accepts a context `Context` and a value `value` for
|
|
63
63
|
* it as arguments and returns
|
|
64
|
-
* `contextualize(<Context.Provider value={value}>{
|
|
65
|
-
* - `end`: a function that returns `
|
|
64
|
+
* `contextualize(<Context.Provider value={value}>{children}</Context.Provider>)`
|
|
65
|
+
* - `end`: a function that returns `children`
|
|
66
66
|
*
|
|
67
67
|
* @see
|
|
68
68
|
* {@linkcode ContextualizePipe}
|
|
69
69
|
*/
|
|
70
|
-
export declare function contextualize(
|
|
70
|
+
export declare function contextualize(children: ReactNode): ContextualizePipe;
|
|
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,
|
|
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;AAKhD;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,iBAAiB,CAAC;IACxB,GAAG,EAAE,MAAM,SAAS,CAAC;CACtB,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;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,GAAG,iBAAiB,CAWpE"}
|
|
@@ -39,24 +39,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
39
39
|
* .end();
|
|
40
40
|
* ```
|
|
41
41
|
*
|
|
42
|
-
* @param
|
|
42
|
+
* @param children The children to contextualize
|
|
43
43
|
*
|
|
44
44
|
* @returns An object with the following properties:
|
|
45
45
|
* - `with`: a function that accepts a context `Context` and a value `value` for
|
|
46
46
|
* it as arguments and returns
|
|
47
|
-
* `contextualize(<Context.Provider value={value}>{
|
|
48
|
-
* - `end`: a function that returns `
|
|
47
|
+
* `contextualize(<Context.Provider value={value}>{children}</Context.Provider>)`
|
|
48
|
+
* - `end`: a function that returns `children`
|
|
49
49
|
*
|
|
50
50
|
* @see
|
|
51
51
|
* {@linkcode ContextualizePipe}
|
|
52
52
|
*/
|
|
53
|
-
export function contextualize(
|
|
53
|
+
export function contextualize(children) {
|
|
54
54
|
return {
|
|
55
55
|
with(Context, value) {
|
|
56
|
-
return contextualize(_jsx(Context.Provider, { value: value, children:
|
|
56
|
+
return contextualize(_jsx(Context.Provider, { value: value, children: children }));
|
|
57
57
|
},
|
|
58
58
|
end() {
|
|
59
|
-
return
|
|
59
|
+
return children;
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -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,CAAC,QAAmB;IAC/C,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/dist/misc/wrapJSX.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentProps, JSXElementConstructor, default as React } from 'react';
|
|
1
|
+
import type { ComponentProps, JSXElementConstructor, default as React, ReactNode } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* The return type of {@linkcode wrapJSX}
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import type { ComponentProps, JSXElementConstructor, default as React } from 're
|
|
|
8
8
|
*/
|
|
9
9
|
export type JSXWrapPipe = {
|
|
10
10
|
with: WrapJSXWith;
|
|
11
|
-
end: () =>
|
|
11
|
+
end: () => ReactNode;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* @see
|
|
@@ -61,16 +61,16 @@ export type WrapJSXWith = <C extends keyof JSX.IntrinsicElements | JSXElementCon
|
|
|
61
61
|
* );
|
|
62
62
|
* ```
|
|
63
63
|
*
|
|
64
|
-
* @param
|
|
64
|
+
* @param children The children to wrap
|
|
65
65
|
*
|
|
66
66
|
* @returns An object with the following properties:
|
|
67
67
|
* - `with`: a function that accepts a component `Component` and props `props`
|
|
68
68
|
* for it as arguments and returns
|
|
69
|
-
* `wrapJSX(<Component {...props}>{
|
|
70
|
-
* - `end`: a function that returns `
|
|
69
|
+
* `wrapJSX(<Component {...props}>{children}</Component>)`
|
|
70
|
+
* - `end`: a function that returns `children`
|
|
71
71
|
*
|
|
72
72
|
* @see
|
|
73
73
|
* {@linkcode JSXWrapPipe}
|
|
74
74
|
*/
|
|
75
|
-
export declare function wrapJSX(
|
|
75
|
+
export declare function wrapJSX(children: ReactNode): JSXWrapPipe;
|
|
76
76
|
//# sourceMappingURL=wrapJSX.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapJSX.d.ts","sourceRoot":"","sources":["../../src/misc/wrapJSX.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,OAAO,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"wrapJSX.d.ts","sourceRoot":"","sources":["../../src/misc/wrapJSX.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,OAAO,IAAI,KAAK,EAChB,SAAS,EACV,MAAM,OAAO,CAAC;AAKf;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,SAAS,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAErB,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,iBAAiB,GAAG,qBAAqB,CAAC,GAAG,CAAC,EACjE,GAAG,IAAI,EAAE;IACP,SAAS,EAAE,CAAC;IACZ,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,GAClE;QACE,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,GACnC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;KACtC,GACD;QACE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,GAClC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC;KACtC,CAAC;CACP,KACE,WAAW,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,SAAS,GAAG,WAAW,CAcxD"}
|
package/dist/misc/wrapJSX.js
CHANGED
|
@@ -37,24 +37,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
37
37
|
* );
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
|
-
* @param
|
|
40
|
+
* @param children The children to wrap
|
|
41
41
|
*
|
|
42
42
|
* @returns An object with the following properties:
|
|
43
43
|
* - `with`: a function that accepts a component `Component` and props `props`
|
|
44
44
|
* for it as arguments and returns
|
|
45
|
-
* `wrapJSX(<Component {...props}>{
|
|
46
|
-
* - `end`: a function that returns `
|
|
45
|
+
* `wrapJSX(<Component {...props}>{children}</Component>)`
|
|
46
|
+
* - `end`: a function that returns `children`
|
|
47
47
|
*
|
|
48
48
|
* @see
|
|
49
49
|
* {@linkcode JSXWrapPipe}
|
|
50
50
|
*/
|
|
51
|
-
export function wrapJSX(
|
|
51
|
+
export function wrapJSX(children) {
|
|
52
52
|
return {
|
|
53
53
|
with(Component, props = {}) {
|
|
54
|
-
return wrapJSX(_jsx(Component, { ...props, children:
|
|
54
|
+
return wrapJSX(_jsx(Component, { ...props, children: children }));
|
|
55
55
|
},
|
|
56
56
|
end() {
|
|
57
|
-
return
|
|
57
|
+
return children;
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
}
|
package/dist/misc/wrapJSX.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapJSX.js","sourceRoot":"","sources":["../../src/misc/wrapJSX.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"wrapJSX.js","sourceRoot":"","sources":["../../src/misc/wrapJSX.tsx"],"names":[],"mappings":";AA4CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,UAAU,OAAO,CAAC,QAAmB;IACzC,OAAO;QACL,IAAI,CACF,SAEiC,EACjC,QAAgB,EAAE;YAElB,OAAO,OAAO,CAAC,KAAC,SAAS,OAAK,KAAK,YAAG,QAAQ,GAAa,CAAC,CAAC;QAC/D,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,
|
|
1
|
+
import type { Context, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
4
|
import type { wrapJSX } from './wrapJSX.js';
|
|
@@ -12,7 +12,7 @@ import type { wrapJSX } from './wrapJSX.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export type ContextualizePipe = {
|
|
14
14
|
with: ContextualizeWith;
|
|
15
|
-
end: () =>
|
|
15
|
+
end: () => ReactNode;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -65,28 +65,26 @@ export type ContextualizeWith = <T>(
|
|
|
65
65
|
* .end();
|
|
66
66
|
* ```
|
|
67
67
|
*
|
|
68
|
-
* @param
|
|
68
|
+
* @param children The children to contextualize
|
|
69
69
|
*
|
|
70
70
|
* @returns An object with the following properties:
|
|
71
71
|
* - `with`: a function that accepts a context `Context` and a value `value` for
|
|
72
72
|
* it as arguments and returns
|
|
73
|
-
* `contextualize(<Context.Provider value={value}>{
|
|
74
|
-
* - `end`: a function that returns `
|
|
73
|
+
* `contextualize(<Context.Provider value={value}>{children}</Context.Provider>)`
|
|
74
|
+
* - `end`: a function that returns `children`
|
|
75
75
|
*
|
|
76
76
|
* @see
|
|
77
77
|
* {@linkcode ContextualizePipe}
|
|
78
78
|
*/
|
|
79
|
-
export function contextualize(
|
|
80
|
-
jsx: React.JSX.Element | undefined,
|
|
81
|
-
): ContextualizePipe {
|
|
79
|
+
export function contextualize(children: ReactNode): ContextualizePipe {
|
|
82
80
|
return {
|
|
83
81
|
with<T>(Context: Context<T>, value: T) {
|
|
84
82
|
return contextualize(
|
|
85
|
-
<Context.Provider value={value}>{
|
|
83
|
+
<Context.Provider value={value}>{children}</Context.Provider>,
|
|
86
84
|
);
|
|
87
85
|
},
|
|
88
86
|
end() {
|
|
89
|
-
return
|
|
87
|
+
return children;
|
|
90
88
|
},
|
|
91
89
|
};
|
|
92
90
|
}
|
package/src/misc/wrapJSX.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
ComponentProps,
|
|
3
3
|
JSXElementConstructor,
|
|
4
4
|
default as React,
|
|
5
|
+
ReactNode,
|
|
5
6
|
} from 'react';
|
|
6
7
|
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -16,7 +17,7 @@ import type { contextualize } from './contextualize.js';
|
|
|
16
17
|
*/
|
|
17
18
|
export type JSXWrapPipe = {
|
|
18
19
|
with: WrapJSXWith;
|
|
19
|
-
end: () =>
|
|
20
|
+
end: () => ReactNode;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -79,18 +80,18 @@ export type WrapJSXWith =
|
|
|
79
80
|
* );
|
|
80
81
|
* ```
|
|
81
82
|
*
|
|
82
|
-
* @param
|
|
83
|
+
* @param children The children to wrap
|
|
83
84
|
*
|
|
84
85
|
* @returns An object with the following properties:
|
|
85
86
|
* - `with`: a function that accepts a component `Component` and props `props`
|
|
86
87
|
* for it as arguments and returns
|
|
87
|
-
* `wrapJSX(<Component {...props}>{
|
|
88
|
-
* - `end`: a function that returns `
|
|
88
|
+
* `wrapJSX(<Component {...props}>{children}</Component>)`
|
|
89
|
+
* - `end`: a function that returns `children`
|
|
89
90
|
*
|
|
90
91
|
* @see
|
|
91
92
|
* {@linkcode JSXWrapPipe}
|
|
92
93
|
*/
|
|
93
|
-
export function wrapJSX(
|
|
94
|
+
export function wrapJSX(children: ReactNode): JSXWrapPipe {
|
|
94
95
|
return {
|
|
95
96
|
with(
|
|
96
97
|
Component:
|
|
@@ -98,10 +99,10 @@ export function wrapJSX(jsx: React.JSX.Element | undefined): JSXWrapPipe {
|
|
|
98
99
|
| JSXElementConstructor<object>,
|
|
99
100
|
props: object = {},
|
|
100
101
|
) {
|
|
101
|
-
return wrapJSX(<Component {...props}>{
|
|
102
|
+
return wrapJSX(<Component {...props}>{children}</Component>);
|
|
102
103
|
},
|
|
103
104
|
end() {
|
|
104
|
-
return
|
|
105
|
+
return children;
|
|
105
106
|
},
|
|
106
107
|
};
|
|
107
108
|
}
|