@faasjs/react 2.6.1 → 2.7.0
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 +2 -0
- package/dist/index.d.mts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +6 -0
- package/dist/index.mjs +7 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ const client = FaasReactClient({
|
|
|
54
54
|
- [FaasParams](type-aliases/FaasParams.md)
|
|
55
55
|
- [FaasReactClientInstance](type-aliases/FaasReactClientInstance.md)
|
|
56
56
|
- [FaasReactClientOptions](type-aliases/FaasReactClientOptions.md)
|
|
57
|
+
- [OptionalWrapperProps](type-aliases/OptionalWrapperProps.md)
|
|
57
58
|
- [Options](type-aliases/Options.md)
|
|
58
59
|
- [ResponseHeaders](type-aliases/ResponseHeaders.md)
|
|
59
60
|
- [useFaasOptions](type-aliases/useFaasOptions.md)
|
|
@@ -62,6 +63,7 @@ const client = FaasReactClient({
|
|
|
62
63
|
|
|
63
64
|
- [FaasDataWrapper](functions/FaasDataWrapper.md)
|
|
64
65
|
- [FaasReactClient](functions/FaasReactClient.md)
|
|
66
|
+
- [OptionalWrapper](functions/OptionalWrapper.md)
|
|
65
67
|
- [createSplitedContext](functions/createSplitedContext.md)
|
|
66
68
|
- [createSplittingContext](functions/createSplittingContext.md)
|
|
67
69
|
- [faas](functions/faas.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
|
3
3
|
import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
|
|
4
4
|
export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { ReactNode, ReactElement, Component } from 'react';
|
|
6
|
+
import { ReactNode, ReactElement, Component, ComponentType, ComponentProps } from 'react';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -240,4 +240,34 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
240
240
|
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
type OptionalWrapperProps<TWrapper extends ComponentType<{
|
|
244
|
+
children: ReactNode;
|
|
245
|
+
}> = any> = {
|
|
246
|
+
condition: boolean;
|
|
247
|
+
Wrapper: TWrapper;
|
|
248
|
+
wrapperProps?: ComponentProps<TWrapper>;
|
|
249
|
+
children: ReactNode;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* A wrapper component that conditionally wraps its children with a provided wrapper component.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* import { OptionalWrapper } from '@faasjs/react'
|
|
257
|
+
*
|
|
258
|
+
* const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
259
|
+
* <div className='wrapper'>{children}</div>
|
|
260
|
+
* )
|
|
261
|
+
*
|
|
262
|
+
* const App = () => (
|
|
263
|
+
* <OptionalWrapper condition={true} Wrapper={Wrapper}>
|
|
264
|
+
* <span>Test</span>
|
|
265
|
+
* </OptionalWrapper>
|
|
266
|
+
* )
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
|
|
270
|
+
whyDidYouRender: boolean;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, OptionalWrapper, type OptionalWrapperProps, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
|
3
3
|
import { Options, ResponseError, Response as Response$1 } from '@faasjs/browser';
|
|
4
4
|
export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { ReactNode, ReactElement, Component } from 'react';
|
|
6
|
+
import { ReactNode, ReactElement, Component, ComponentType, ComponentProps } from 'react';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -240,4 +240,34 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
240
240
|
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
type OptionalWrapperProps<TWrapper extends ComponentType<{
|
|
244
|
+
children: ReactNode;
|
|
245
|
+
}> = any> = {
|
|
246
|
+
condition: boolean;
|
|
247
|
+
Wrapper: TWrapper;
|
|
248
|
+
wrapperProps?: ComponentProps<TWrapper>;
|
|
249
|
+
children: ReactNode;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* A wrapper component that conditionally wraps its children with a provided wrapper component.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* import { OptionalWrapper } from '@faasjs/react'
|
|
257
|
+
*
|
|
258
|
+
* const Wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
259
|
+
* <div className='wrapper'>{children}</div>
|
|
260
|
+
* )
|
|
261
|
+
*
|
|
262
|
+
* const App = () => (
|
|
263
|
+
* <OptionalWrapper condition={true} Wrapper={Wrapper}>
|
|
264
|
+
* <span>Test</span>
|
|
265
|
+
* </OptionalWrapper>
|
|
266
|
+
* )
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
|
|
270
|
+
whyDidYouRender: boolean;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, OptionalWrapper, type OptionalWrapperProps, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas, type useFaasOptions };
|
package/dist/index.js
CHANGED
|
@@ -268,10 +268,16 @@ var ErrorBoundary = class extends react.Component {
|
|
|
268
268
|
};
|
|
269
269
|
ErrorBoundary.whyDidYouRender = true;
|
|
270
270
|
ErrorBoundary.whyDidYouRender = true;
|
|
271
|
+
var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
|
|
272
|
+
console.debug("[OptionalWrapper] %s %s", Wrapper.name, condition);
|
|
273
|
+
return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
274
|
+
};
|
|
275
|
+
OptionalWrapper.whyDidYouRender = true;
|
|
271
276
|
|
|
272
277
|
exports.ErrorBoundary = ErrorBoundary;
|
|
273
278
|
exports.FaasDataWrapper = FaasDataWrapper;
|
|
274
279
|
exports.FaasReactClient = FaasReactClient;
|
|
280
|
+
exports.OptionalWrapper = OptionalWrapper;
|
|
275
281
|
exports.createSplitedContext = createSplitedContext;
|
|
276
282
|
exports.createSplittingContext = createSplittingContext;
|
|
277
283
|
exports.faas = faas;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRef, createContext, useState, useEffect, Component, cloneElement, useContext, useCallback, useMemo } from 'react';
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { FaasBrowserClient } from '@faasjs/browser';
|
|
4
4
|
|
|
5
5
|
// src/constant.ts
|
|
@@ -266,5 +266,10 @@ var ErrorBoundary = class extends Component {
|
|
|
266
266
|
};
|
|
267
267
|
ErrorBoundary.whyDidYouRender = true;
|
|
268
268
|
ErrorBoundary.whyDidYouRender = true;
|
|
269
|
+
var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
|
|
270
|
+
console.debug("[OptionalWrapper] %s %s", Wrapper.name, condition);
|
|
271
|
+
return condition ? /* @__PURE__ */ jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsx(Fragment, { children });
|
|
272
|
+
};
|
|
273
|
+
OptionalWrapper.whyDidYouRender = true;
|
|
269
274
|
|
|
270
|
-
export { ErrorBoundary, FaasDataWrapper, FaasReactClient, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas };
|
|
275
|
+
export { ErrorBoundary, FaasDataWrapper, FaasReactClient, OptionalWrapper, createSplitedContext, createSplittingContext, faas, getClient, useConstant, useFaas };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://faasjs.com/doc/react",
|
|
20
|
+
"homepage": "https://faasjs.com/doc/react/",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
23
|
"url": "git+https://github.com/faasjs/faasjs.git",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@faasjs/browser": "2.
|
|
37
|
+
"@faasjs/browser": "2.7.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "*"
|