@faasjs/react 3.7.0-beta.1 → 3.7.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.
- package/README.md +3 -0
- package/dist/index.d.mts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +107 -42
- package/dist/index.mjs +107 -42
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -78,8 +78,11 @@ npm install @faasjs/react
|
|
|
78
78
|
- [FaasParams](type-aliases/FaasParams.md)
|
|
79
79
|
- [FaasReactClientInstance](type-aliases/FaasReactClientInstance.md)
|
|
80
80
|
- [FaasReactClientOptions](type-aliases/FaasReactClientOptions.md)
|
|
81
|
+
- [FormButtonElementProps](type-aliases/FormButtonElementProps.md)
|
|
81
82
|
- [FormContextProps](type-aliases/FormContextProps.md)
|
|
82
83
|
- [FormElementTypes](type-aliases/FormElementTypes.md)
|
|
84
|
+
- [FormInputElementProps](type-aliases/FormInputElementProps.md)
|
|
85
|
+
- [FormLabelElementProps](type-aliases/FormLabelElementProps.md)
|
|
83
86
|
- [FormProps](type-aliases/FormProps.md)
|
|
84
87
|
- [OnError](type-aliases/OnError.md)
|
|
85
88
|
- [OptionalWrapperProps](type-aliases/OptionalWrapperProps.md)
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
|
3
3
|
import { Response, BaseUrl, ResponseError, Options, FaasBrowserClient } from '@faasjs/browser';
|
|
4
4
|
export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { ReactNode, Dispatch, SetStateAction, ReactElement, Component, ComponentType, ComponentProps } from 'react';
|
|
6
|
+
import { ReactNode, Dispatch, SetStateAction, ReactElement, Component, ComponentType, ComponentProps, JSXElementConstructor } from 'react';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -212,6 +212,7 @@ type FaasDataWrapperProps<PathOrData extends FaasAction> = {
|
|
|
212
212
|
};
|
|
213
213
|
declare function FaasDataWrapper<PathOrData extends FaasAction>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
|
|
214
214
|
declare namespace FaasDataWrapper {
|
|
215
|
+
var displayName: string;
|
|
215
216
|
var whyDidYouRender: boolean;
|
|
216
217
|
}
|
|
217
218
|
/**
|
|
@@ -336,6 +337,7 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
336
337
|
componentStack?: string;
|
|
337
338
|
};
|
|
338
339
|
}> {
|
|
340
|
+
static displayName: string;
|
|
339
341
|
static whyDidYouRender: boolean;
|
|
340
342
|
constructor(props: ErrorBoundaryProps);
|
|
341
343
|
componentDidCatch(error: Error | null, info: any): void;
|
|
@@ -383,16 +385,19 @@ type FormInputElementProps = {
|
|
|
383
385
|
onChange: (value: any) => void;
|
|
384
386
|
};
|
|
385
387
|
|
|
386
|
-
type
|
|
388
|
+
type InferFormInputProps<T extends ComponentType<FormInputElementProps> | JSXElementConstructor<any>> = T extends ComponentType<FormInputElementProps> ? Omit<ComponentProps<T>, 'name' | 'value' | 'onChange'> : Omit<ComponentProps<T>, 'name' | 'value'>;
|
|
389
|
+
type FormInputProps<FormElements extends FormElementTypes = FormElementTypes> = {
|
|
390
|
+
Input?: ComponentType<FormInputElementProps>;
|
|
391
|
+
props?: InferFormInputProps<FormElements['Input']>;
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
type FormLabelElementProps<FormElements extends FormElementTypes = FormElementTypes> = {
|
|
387
395
|
name: string;
|
|
388
396
|
rules?: FormRules;
|
|
389
397
|
title?: ReactNode;
|
|
390
398
|
description?: ReactNode;
|
|
391
|
-
Label?:
|
|
392
|
-
input?:
|
|
393
|
-
Input?: ComponentType<FormInputElementProps>;
|
|
394
|
-
props?: FormInputElementProps;
|
|
395
|
-
};
|
|
399
|
+
Label?: FormElements['Label'];
|
|
400
|
+
input?: FormInputProps<FormElements>;
|
|
396
401
|
};
|
|
397
402
|
|
|
398
403
|
type FormButtonElementProps = {
|
|
@@ -411,10 +416,14 @@ declare const FormDefaultElements: FormElementTypes;
|
|
|
411
416
|
type FormProps<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes> = {
|
|
412
417
|
items: FormLabelElementProps[];
|
|
413
418
|
onSubmit?: (values: Values) => Promise<void>;
|
|
414
|
-
elements?: FormElements
|
|
419
|
+
elements?: Partial<FormElements>;
|
|
415
420
|
defaultValues?: Values;
|
|
416
421
|
};
|
|
417
422
|
declare function FormContainer<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes>({ defaultValues, elements, ...props }: FormProps<Values, FormElements>): react_jsx_runtime.JSX.Element;
|
|
423
|
+
declare namespace FormContainer {
|
|
424
|
+
var displayName: string;
|
|
425
|
+
var whyDidYouRender: boolean;
|
|
426
|
+
}
|
|
418
427
|
|
|
419
428
|
type FormContextProps<Values extends Record<string, any> = Record<string, any>> = {
|
|
420
429
|
items: FormLabelElementProps[];
|
|
@@ -432,4 +441,4 @@ declare const FormContextProvider: <NewT extends FormContextProps<Record<string,
|
|
|
432
441
|
}) => react.ReactNode;
|
|
433
442
|
declare const useFormContext: <NewT extends FormContextProps<Record<string, any>> = FormContextProps<Record<string, any>>>() => Readonly<NewT>;
|
|
434
443
|
|
|
435
|
-
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormContextProps, FormContextProvider, FormDefaultElements, type FormElementTypes, type FormProps, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, withFaasData };
|
|
444
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, type FormElementTypes, type FormInputElementProps, type FormLabelElementProps, type FormProps, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, withFaasData };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
|
3
3
|
import { Response, BaseUrl, ResponseError, Options, FaasBrowserClient } from '@faasjs/browser';
|
|
4
4
|
export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
|
|
5
5
|
import * as react from 'react';
|
|
6
|
-
import { ReactNode, Dispatch, SetStateAction, ReactElement, Component, ComponentType, ComponentProps } from 'react';
|
|
6
|
+
import { ReactNode, Dispatch, SetStateAction, ReactElement, Component, ComponentType, ComponentProps, JSXElementConstructor } from 'react';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -212,6 +212,7 @@ type FaasDataWrapperProps<PathOrData extends FaasAction> = {
|
|
|
212
212
|
};
|
|
213
213
|
declare function FaasDataWrapper<PathOrData extends FaasAction>(props: FaasDataWrapperProps<PathOrData>): JSX.Element;
|
|
214
214
|
declare namespace FaasDataWrapper {
|
|
215
|
+
var displayName: string;
|
|
215
216
|
var whyDidYouRender: boolean;
|
|
216
217
|
}
|
|
217
218
|
/**
|
|
@@ -336,6 +337,7 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
|
336
337
|
componentStack?: string;
|
|
337
338
|
};
|
|
338
339
|
}> {
|
|
340
|
+
static displayName: string;
|
|
339
341
|
static whyDidYouRender: boolean;
|
|
340
342
|
constructor(props: ErrorBoundaryProps);
|
|
341
343
|
componentDidCatch(error: Error | null, info: any): void;
|
|
@@ -383,16 +385,19 @@ type FormInputElementProps = {
|
|
|
383
385
|
onChange: (value: any) => void;
|
|
384
386
|
};
|
|
385
387
|
|
|
386
|
-
type
|
|
388
|
+
type InferFormInputProps<T extends ComponentType<FormInputElementProps> | JSXElementConstructor<any>> = T extends ComponentType<FormInputElementProps> ? Omit<ComponentProps<T>, 'name' | 'value' | 'onChange'> : Omit<ComponentProps<T>, 'name' | 'value'>;
|
|
389
|
+
type FormInputProps<FormElements extends FormElementTypes = FormElementTypes> = {
|
|
390
|
+
Input?: ComponentType<FormInputElementProps>;
|
|
391
|
+
props?: InferFormInputProps<FormElements['Input']>;
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
type FormLabelElementProps<FormElements extends FormElementTypes = FormElementTypes> = {
|
|
387
395
|
name: string;
|
|
388
396
|
rules?: FormRules;
|
|
389
397
|
title?: ReactNode;
|
|
390
398
|
description?: ReactNode;
|
|
391
|
-
Label?:
|
|
392
|
-
input?:
|
|
393
|
-
Input?: ComponentType<FormInputElementProps>;
|
|
394
|
-
props?: FormInputElementProps;
|
|
395
|
-
};
|
|
399
|
+
Label?: FormElements['Label'];
|
|
400
|
+
input?: FormInputProps<FormElements>;
|
|
396
401
|
};
|
|
397
402
|
|
|
398
403
|
type FormButtonElementProps = {
|
|
@@ -411,10 +416,14 @@ declare const FormDefaultElements: FormElementTypes;
|
|
|
411
416
|
type FormProps<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes> = {
|
|
412
417
|
items: FormLabelElementProps[];
|
|
413
418
|
onSubmit?: (values: Values) => Promise<void>;
|
|
414
|
-
elements?: FormElements
|
|
419
|
+
elements?: Partial<FormElements>;
|
|
415
420
|
defaultValues?: Values;
|
|
416
421
|
};
|
|
417
422
|
declare function FormContainer<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes>({ defaultValues, elements, ...props }: FormProps<Values, FormElements>): react_jsx_runtime.JSX.Element;
|
|
423
|
+
declare namespace FormContainer {
|
|
424
|
+
var displayName: string;
|
|
425
|
+
var whyDidYouRender: boolean;
|
|
426
|
+
}
|
|
418
427
|
|
|
419
428
|
type FormContextProps<Values extends Record<string, any> = Record<string, any>> = {
|
|
420
429
|
items: FormLabelElementProps[];
|
|
@@ -432,4 +441,4 @@ declare const FormContextProvider: <NewT extends FormContextProps<Record<string,
|
|
|
432
441
|
}) => react.ReactNode;
|
|
433
442
|
declare const useFormContext: <NewT extends FormContextProps<Record<string, any>> = FormContextProps<Record<string, any>>>() => Readonly<NewT>;
|
|
434
443
|
|
|
435
|
-
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormContextProps, FormContextProvider, FormDefaultElements, type FormElementTypes, type FormProps, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, withFaasData };
|
|
444
|
+
export { ErrorBoundary, type ErrorBoundaryProps, type ErrorChildrenProps, type FaasDataInjection, FaasDataWrapper, type FaasDataWrapperProps, FaasReactClient, type FaasReactClientInstance, type FaasReactClientOptions, FormContainer as Form, type FormButtonElementProps, type FormContextProps, FormContextProvider, FormDefaultElements, type FormElementTypes, type FormInputElementProps, type FormLabelElementProps, type FormProps, type OnError, OptionalWrapper, type OptionalWrapperProps, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, type useFaasOptions, useFormContext, useSplittingState, withFaasData };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,37 @@ var react = require('react');
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var browser = require('@faasjs/browser');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defProps = Object.defineProperties;
|
|
9
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __spreadValues = (a, b) => {
|
|
15
|
+
for (var prop in b || (b = {}))
|
|
16
|
+
if (__hasOwnProp.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
if (__getOwnPropSymbols)
|
|
19
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
+
if (__propIsEnum.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
|
+
var __objRest = (source, exclude) => {
|
|
27
|
+
var target = {};
|
|
28
|
+
for (var prop in source)
|
|
29
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
if (source != null && __getOwnPropSymbols)
|
|
32
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
33
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
}
|
|
36
|
+
return target;
|
|
37
|
+
};
|
|
8
38
|
function useConstant(fn) {
|
|
9
39
|
const ref = react.useRef();
|
|
10
40
|
if (!ref.current) {
|
|
@@ -88,17 +118,20 @@ function createSplittingContext(defaultValue) {
|
|
|
88
118
|
const contexts = {};
|
|
89
119
|
for (const key of keys) contexts[key] = react.createContext(defaultValues[key]);
|
|
90
120
|
function Provider(props) {
|
|
121
|
+
var _a, _b;
|
|
91
122
|
let children = props.memo ? useEqualMemo(
|
|
92
123
|
() => props.children,
|
|
93
124
|
props.memo === true ? [] : props.memo
|
|
94
125
|
) : props.children;
|
|
95
126
|
for (const key of keys) {
|
|
96
127
|
const Context = contexts[key];
|
|
97
|
-
const value = props.value
|
|
128
|
+
const value = (_b = (_a = props.value) == null ? void 0 : _a[key]) != null ? _b : defaultValues[key];
|
|
98
129
|
children = /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value, children });
|
|
99
130
|
}
|
|
100
131
|
return children;
|
|
101
132
|
}
|
|
133
|
+
Provider.displayName = "SplittingContextProvider";
|
|
134
|
+
Provider.whyDidYouRender = true;
|
|
102
135
|
function use() {
|
|
103
136
|
return useConstant(() => {
|
|
104
137
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
@@ -110,6 +143,7 @@ function createSplittingContext(defaultValue) {
|
|
|
110
143
|
return Object.freeze(obj);
|
|
111
144
|
});
|
|
112
145
|
}
|
|
146
|
+
use.whyDidYouRender = true;
|
|
113
147
|
return {
|
|
114
148
|
Provider,
|
|
115
149
|
use
|
|
@@ -155,9 +189,10 @@ function FaasDataWrapper(props) {
|
|
|
155
189
|
]);
|
|
156
190
|
return child;
|
|
157
191
|
}
|
|
192
|
+
FaasDataWrapper.displayName = "FaasDataWrapper";
|
|
158
193
|
FaasDataWrapper.whyDidYouRender = true;
|
|
159
194
|
function withFaasData(Component2, faasProps) {
|
|
160
|
-
return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, {
|
|
195
|
+
return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, __spreadProps(__spreadValues({}, faasProps), { children: /* @__PURE__ */ jsxRuntime.jsx(Component2, __spreadValues({}, props)) }));
|
|
161
196
|
}
|
|
162
197
|
function useFaas(action, defaultParams, options = {}) {
|
|
163
198
|
const [loading, setLoading] = react.useState(true);
|
|
@@ -200,9 +235,9 @@ function useFaas(action, defaultParams, options = {}) {
|
|
|
200
235
|
options.setData ? options.setData(r.data) : setData(r.data);
|
|
201
236
|
setLoading(false);
|
|
202
237
|
}).catch(async (e) => {
|
|
203
|
-
if (typeof e
|
|
238
|
+
if (typeof (e == null ? void 0 : e.message) === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
|
|
204
239
|
return;
|
|
205
|
-
if (!fails && typeof e
|
|
240
|
+
if (!fails && typeof (e == null ? void 0 : e.message) === "string" && e.message.indexOf("Failed to fetch") >= 0) {
|
|
206
241
|
console.warn(`FaasReactClient: ${e.message} retry...`);
|
|
207
242
|
setFails(1);
|
|
208
243
|
return send();
|
|
@@ -221,14 +256,16 @@ function useFaas(action, defaultParams, options = {}) {
|
|
|
221
256
|
if (options.debounce) {
|
|
222
257
|
const timeout = setTimeout(send, options.debounce);
|
|
223
258
|
return () => {
|
|
259
|
+
var _a;
|
|
224
260
|
clearTimeout(timeout);
|
|
225
|
-
controllerRef.current
|
|
261
|
+
(_a = controllerRef.current) == null ? void 0 : _a.abort();
|
|
226
262
|
setLoading(false);
|
|
227
263
|
};
|
|
228
264
|
}
|
|
229
265
|
send();
|
|
230
266
|
return () => {
|
|
231
|
-
|
|
267
|
+
var _a;
|
|
268
|
+
(_a = controllerRef.current) == null ? void 0 : _a.abort();
|
|
232
269
|
setLoading(false);
|
|
233
270
|
};
|
|
234
271
|
}, [action, options.params || params, reloadTimes, skip]);
|
|
@@ -260,7 +297,7 @@ useFaas.whyDidYouRender = true;
|
|
|
260
297
|
|
|
261
298
|
// src/faas.ts
|
|
262
299
|
async function faas(action, params, options) {
|
|
263
|
-
const client = getClient(options
|
|
300
|
+
const client = getClient(options == null ? void 0 : options.baseUrl);
|
|
264
301
|
if (client.onError)
|
|
265
302
|
return client.browserClient.action(action, params, options).catch(async (res) => {
|
|
266
303
|
await client.onError(action, params)(res);
|
|
@@ -275,9 +312,9 @@ function FaasReactClient({ baseUrl, options, onError } = {
|
|
|
275
312
|
const client = new browser.FaasBrowserClient(baseUrl, options);
|
|
276
313
|
const reactClient = {
|
|
277
314
|
id: client.id,
|
|
278
|
-
faas: async (action, params, options2) => faas(action, params, { baseUrl,
|
|
279
|
-
useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, { baseUrl,
|
|
280
|
-
FaasDataWrapper: (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { baseUrl,
|
|
315
|
+
faas: async (action, params, options2) => faas(action, params, __spreadValues({ baseUrl }, options2)),
|
|
316
|
+
useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, __spreadValues({ baseUrl }, options2)),
|
|
317
|
+
FaasDataWrapper: (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, __spreadValues({ baseUrl }, props)),
|
|
281
318
|
onError,
|
|
282
319
|
browserClient: client
|
|
283
320
|
};
|
|
@@ -293,7 +330,6 @@ function getClient(host) {
|
|
|
293
330
|
return client;
|
|
294
331
|
}
|
|
295
332
|
var ErrorBoundary = class extends react.Component {
|
|
296
|
-
static whyDidYouRender = true;
|
|
297
333
|
constructor(props) {
|
|
298
334
|
super(props);
|
|
299
335
|
this.state = {
|
|
@@ -308,8 +344,9 @@ var ErrorBoundary = class extends react.Component {
|
|
|
308
344
|
});
|
|
309
345
|
}
|
|
310
346
|
render() {
|
|
347
|
+
var _a;
|
|
311
348
|
const errorMessage = (this.state.error || "").toString();
|
|
312
|
-
const errorDescription = this.state.info
|
|
349
|
+
const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
|
|
313
350
|
if (this.state.error) {
|
|
314
351
|
if (this.props.onError)
|
|
315
352
|
this.props.onError(this.state.error, this.state.info);
|
|
@@ -328,10 +365,12 @@ var ErrorBoundary = class extends react.Component {
|
|
|
328
365
|
return this.props.children;
|
|
329
366
|
}
|
|
330
367
|
};
|
|
368
|
+
ErrorBoundary.displayName = "ErrorBoundary";
|
|
331
369
|
ErrorBoundary.whyDidYouRender = true;
|
|
332
370
|
var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
|
|
333
|
-
return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, {
|
|
371
|
+
return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, __spreadProps(__spreadValues({}, wrapperProps), { children })) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
334
372
|
};
|
|
373
|
+
OptionalWrapper.displayName = "OptionalWrapper";
|
|
335
374
|
OptionalWrapper.whyDidYouRender = true;
|
|
336
375
|
|
|
337
376
|
// src/Form/context.tsx
|
|
@@ -340,14 +379,23 @@ var FormContextProvider = FormContext.Provider;
|
|
|
340
379
|
var useFormContext = FormContext.use;
|
|
341
380
|
function FormLabel(props) {
|
|
342
381
|
const { Elements } = useFormContext();
|
|
343
|
-
if (props.Label) return /* @__PURE__ */ jsxRuntime.jsx(props.Label, {
|
|
344
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Elements.Label, {
|
|
382
|
+
if (props.Label) return /* @__PURE__ */ jsxRuntime.jsx(props.Label, __spreadValues({}, props));
|
|
383
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Elements.Label, __spreadValues({}, props));
|
|
345
384
|
}
|
|
385
|
+
FormLabel.displayName = "FormLabel";
|
|
386
|
+
FormLabel.whyDidYouRender = true;
|
|
346
387
|
function FormBody() {
|
|
347
388
|
const { items } = useFormContext();
|
|
348
|
-
return items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(FormLabel, {
|
|
389
|
+
return items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(FormLabel, __spreadValues({}, item), item.name));
|
|
349
390
|
}
|
|
350
|
-
|
|
391
|
+
FormBody.displayName = "FormBody";
|
|
392
|
+
FormBody.whyDidYouRender = true;
|
|
393
|
+
var FormInputElement = react.forwardRef((_a, ref) => {
|
|
394
|
+
var _b = _a, { onChange } = _b, props = __objRest(_b, ["onChange"]);
|
|
395
|
+
return /* @__PURE__ */ jsxRuntime.jsx("input", __spreadProps(__spreadValues({}, props), { onChange: (e) => onChange(e.target.value), ref }));
|
|
396
|
+
});
|
|
397
|
+
FormInputElement.displayName = "FormInputElement";
|
|
398
|
+
FormInputElement.whyDidYouRender = true;
|
|
351
399
|
var FormLabelElement = ({
|
|
352
400
|
name,
|
|
353
401
|
title,
|
|
@@ -356,16 +404,24 @@ var FormLabelElement = ({
|
|
|
356
404
|
input
|
|
357
405
|
}) => {
|
|
358
406
|
const { values, setValues } = useFormContext();
|
|
359
|
-
if (Label)
|
|
407
|
+
if (Label)
|
|
408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
409
|
+
Label,
|
|
410
|
+
{
|
|
411
|
+
name,
|
|
412
|
+
title,
|
|
413
|
+
description,
|
|
414
|
+
input
|
|
415
|
+
}
|
|
416
|
+
);
|
|
360
417
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
361
|
-
title
|
|
362
|
-
input
|
|
418
|
+
title != null ? title : name,
|
|
419
|
+
(input == null ? void 0 : input.Input) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
363
420
|
input.Input,
|
|
364
421
|
{
|
|
365
422
|
name,
|
|
366
423
|
value: values[name],
|
|
367
|
-
onChange: (v) => setValues((prev) => ({
|
|
368
|
-
...prev,
|
|
424
|
+
onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
369
425
|
[name]: v
|
|
370
426
|
}))
|
|
371
427
|
}
|
|
@@ -374,8 +430,7 @@ var FormLabelElement = ({
|
|
|
374
430
|
{
|
|
375
431
|
name,
|
|
376
432
|
value: values[name],
|
|
377
|
-
onChange: (v) => setValues((prev) => ({
|
|
378
|
-
...prev,
|
|
433
|
+
onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
379
434
|
[name]: v
|
|
380
435
|
}))
|
|
381
436
|
}
|
|
@@ -383,17 +438,24 @@ var FormLabelElement = ({
|
|
|
383
438
|
description
|
|
384
439
|
] });
|
|
385
440
|
};
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
)
|
|
441
|
+
FormLabelElement.displayName = "FormLabelElement";
|
|
442
|
+
FormLabelElement.whyDidYouRender = true;
|
|
443
|
+
var FormButtonElement = react.forwardRef((_a, ref) => {
|
|
444
|
+
var _b = _a, { disabled, children, onClick } = _b, props = __objRest(_b, ["disabled", "children", "onClick"]);
|
|
445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
446
|
+
"button",
|
|
447
|
+
__spreadProps(__spreadValues({
|
|
448
|
+
type: "button",
|
|
449
|
+
disabled,
|
|
450
|
+
onClick
|
|
451
|
+
}, props), {
|
|
452
|
+
ref,
|
|
453
|
+
children
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
});
|
|
457
|
+
FormButtonElement.displayName = "FormButtonElement";
|
|
458
|
+
FormButtonElement.whyDidYouRender = true;
|
|
397
459
|
|
|
398
460
|
// src/Form/elements/index.ts
|
|
399
461
|
var FormDefaultElements = {
|
|
@@ -415,13 +477,17 @@ function FormFooter() {
|
|
|
415
477
|
}
|
|
416
478
|
);
|
|
417
479
|
}
|
|
480
|
+
FormFooter.displayName = "FormFooter";
|
|
481
|
+
FormFooter.whyDidYouRender = true;
|
|
418
482
|
function mergeValues(items, defaultValues = {}) {
|
|
483
|
+
var _a;
|
|
419
484
|
const values = {};
|
|
420
485
|
for (const item of items)
|
|
421
|
-
values[item.name] = defaultValues[item.name]
|
|
486
|
+
values[item.name] = (_a = defaultValues[item.name]) != null ? _a : "";
|
|
422
487
|
return values;
|
|
423
488
|
}
|
|
424
|
-
function FormContainer(
|
|
489
|
+
function FormContainer(_a) {
|
|
490
|
+
var _b = _a, { defaultValues, elements } = _b, props = __objRest(_b, ["defaultValues", "elements"]);
|
|
425
491
|
const states = useSplittingState({
|
|
426
492
|
values: mergeValues(props.items, defaultValues),
|
|
427
493
|
submitting: false,
|
|
@@ -430,10 +496,7 @@ function FormContainer({ defaultValues, elements, ...props }) {
|
|
|
430
496
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
431
497
|
FormContextProvider,
|
|
432
498
|
{
|
|
433
|
-
value: {
|
|
434
|
-
...states,
|
|
435
|
-
...props
|
|
436
|
-
},
|
|
499
|
+
value: __spreadValues(__spreadValues({}, states), props),
|
|
437
500
|
children: [
|
|
438
501
|
/* @__PURE__ */ jsxRuntime.jsx(FormBody, {}),
|
|
439
502
|
/* @__PURE__ */ jsxRuntime.jsx(FormFooter, {})
|
|
@@ -441,6 +504,8 @@ function FormContainer({ defaultValues, elements, ...props }) {
|
|
|
441
504
|
}
|
|
442
505
|
);
|
|
443
506
|
}
|
|
507
|
+
FormContainer.displayName = "FormContainer";
|
|
508
|
+
FormContainer.whyDidYouRender = true;
|
|
444
509
|
|
|
445
510
|
exports.ErrorBoundary = ErrorBoundary;
|
|
446
511
|
exports.FaasDataWrapper = FaasDataWrapper;
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,37 @@ import { forwardRef, useRef, useMemo, useEffect, useCallback, createContext, use
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { FaasBrowserClient } from '@faasjs/browser';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
6
36
|
function useConstant(fn) {
|
|
7
37
|
const ref = useRef();
|
|
8
38
|
if (!ref.current) {
|
|
@@ -86,17 +116,20 @@ function createSplittingContext(defaultValue) {
|
|
|
86
116
|
const contexts = {};
|
|
87
117
|
for (const key of keys) contexts[key] = createContext(defaultValues[key]);
|
|
88
118
|
function Provider(props) {
|
|
119
|
+
var _a, _b;
|
|
89
120
|
let children = props.memo ? useEqualMemo(
|
|
90
121
|
() => props.children,
|
|
91
122
|
props.memo === true ? [] : props.memo
|
|
92
123
|
) : props.children;
|
|
93
124
|
for (const key of keys) {
|
|
94
125
|
const Context = contexts[key];
|
|
95
|
-
const value = props.value
|
|
126
|
+
const value = (_b = (_a = props.value) == null ? void 0 : _a[key]) != null ? _b : defaultValues[key];
|
|
96
127
|
children = /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
97
128
|
}
|
|
98
129
|
return children;
|
|
99
130
|
}
|
|
131
|
+
Provider.displayName = "SplittingContextProvider";
|
|
132
|
+
Provider.whyDidYouRender = true;
|
|
100
133
|
function use() {
|
|
101
134
|
return useConstant(() => {
|
|
102
135
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
@@ -108,6 +141,7 @@ function createSplittingContext(defaultValue) {
|
|
|
108
141
|
return Object.freeze(obj);
|
|
109
142
|
});
|
|
110
143
|
}
|
|
144
|
+
use.whyDidYouRender = true;
|
|
111
145
|
return {
|
|
112
146
|
Provider,
|
|
113
147
|
use
|
|
@@ -153,9 +187,10 @@ function FaasDataWrapper(props) {
|
|
|
153
187
|
]);
|
|
154
188
|
return child;
|
|
155
189
|
}
|
|
190
|
+
FaasDataWrapper.displayName = "FaasDataWrapper";
|
|
156
191
|
FaasDataWrapper.whyDidYouRender = true;
|
|
157
192
|
function withFaasData(Component2, faasProps) {
|
|
158
|
-
return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, {
|
|
193
|
+
return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, __spreadProps(__spreadValues({}, faasProps), { children: /* @__PURE__ */ jsx(Component2, __spreadValues({}, props)) }));
|
|
159
194
|
}
|
|
160
195
|
function useFaas(action, defaultParams, options = {}) {
|
|
161
196
|
const [loading, setLoading] = useState(true);
|
|
@@ -198,9 +233,9 @@ function useFaas(action, defaultParams, options = {}) {
|
|
|
198
233
|
options.setData ? options.setData(r.data) : setData(r.data);
|
|
199
234
|
setLoading(false);
|
|
200
235
|
}).catch(async (e) => {
|
|
201
|
-
if (typeof e
|
|
236
|
+
if (typeof (e == null ? void 0 : e.message) === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
|
|
202
237
|
return;
|
|
203
|
-
if (!fails && typeof e
|
|
238
|
+
if (!fails && typeof (e == null ? void 0 : e.message) === "string" && e.message.indexOf("Failed to fetch") >= 0) {
|
|
204
239
|
console.warn(`FaasReactClient: ${e.message} retry...`);
|
|
205
240
|
setFails(1);
|
|
206
241
|
return send();
|
|
@@ -219,14 +254,16 @@ function useFaas(action, defaultParams, options = {}) {
|
|
|
219
254
|
if (options.debounce) {
|
|
220
255
|
const timeout = setTimeout(send, options.debounce);
|
|
221
256
|
return () => {
|
|
257
|
+
var _a;
|
|
222
258
|
clearTimeout(timeout);
|
|
223
|
-
controllerRef.current
|
|
259
|
+
(_a = controllerRef.current) == null ? void 0 : _a.abort();
|
|
224
260
|
setLoading(false);
|
|
225
261
|
};
|
|
226
262
|
}
|
|
227
263
|
send();
|
|
228
264
|
return () => {
|
|
229
|
-
|
|
265
|
+
var _a;
|
|
266
|
+
(_a = controllerRef.current) == null ? void 0 : _a.abort();
|
|
230
267
|
setLoading(false);
|
|
231
268
|
};
|
|
232
269
|
}, [action, options.params || params, reloadTimes, skip]);
|
|
@@ -258,7 +295,7 @@ useFaas.whyDidYouRender = true;
|
|
|
258
295
|
|
|
259
296
|
// src/faas.ts
|
|
260
297
|
async function faas(action, params, options) {
|
|
261
|
-
const client = getClient(options
|
|
298
|
+
const client = getClient(options == null ? void 0 : options.baseUrl);
|
|
262
299
|
if (client.onError)
|
|
263
300
|
return client.browserClient.action(action, params, options).catch(async (res) => {
|
|
264
301
|
await client.onError(action, params)(res);
|
|
@@ -273,9 +310,9 @@ function FaasReactClient({ baseUrl, options, onError } = {
|
|
|
273
310
|
const client = new FaasBrowserClient(baseUrl, options);
|
|
274
311
|
const reactClient = {
|
|
275
312
|
id: client.id,
|
|
276
|
-
faas: async (action, params, options2) => faas(action, params, { baseUrl,
|
|
277
|
-
useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, { baseUrl,
|
|
278
|
-
FaasDataWrapper: (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { baseUrl,
|
|
313
|
+
faas: async (action, params, options2) => faas(action, params, __spreadValues({ baseUrl }, options2)),
|
|
314
|
+
useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, __spreadValues({ baseUrl }, options2)),
|
|
315
|
+
FaasDataWrapper: (props) => /* @__PURE__ */ jsx(FaasDataWrapper, __spreadValues({ baseUrl }, props)),
|
|
279
316
|
onError,
|
|
280
317
|
browserClient: client
|
|
281
318
|
};
|
|
@@ -291,7 +328,6 @@ function getClient(host) {
|
|
|
291
328
|
return client;
|
|
292
329
|
}
|
|
293
330
|
var ErrorBoundary = class extends Component {
|
|
294
|
-
static whyDidYouRender = true;
|
|
295
331
|
constructor(props) {
|
|
296
332
|
super(props);
|
|
297
333
|
this.state = {
|
|
@@ -306,8 +342,9 @@ var ErrorBoundary = class extends Component {
|
|
|
306
342
|
});
|
|
307
343
|
}
|
|
308
344
|
render() {
|
|
345
|
+
var _a;
|
|
309
346
|
const errorMessage = (this.state.error || "").toString();
|
|
310
|
-
const errorDescription = this.state.info
|
|
347
|
+
const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
|
|
311
348
|
if (this.state.error) {
|
|
312
349
|
if (this.props.onError)
|
|
313
350
|
this.props.onError(this.state.error, this.state.info);
|
|
@@ -326,10 +363,12 @@ var ErrorBoundary = class extends Component {
|
|
|
326
363
|
return this.props.children;
|
|
327
364
|
}
|
|
328
365
|
};
|
|
366
|
+
ErrorBoundary.displayName = "ErrorBoundary";
|
|
329
367
|
ErrorBoundary.whyDidYouRender = true;
|
|
330
368
|
var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
|
|
331
|
-
return condition ? /* @__PURE__ */ jsx(Wrapper, {
|
|
369
|
+
return condition ? /* @__PURE__ */ jsx(Wrapper, __spreadProps(__spreadValues({}, wrapperProps), { children })) : /* @__PURE__ */ jsx(Fragment, { children });
|
|
332
370
|
};
|
|
371
|
+
OptionalWrapper.displayName = "OptionalWrapper";
|
|
333
372
|
OptionalWrapper.whyDidYouRender = true;
|
|
334
373
|
|
|
335
374
|
// src/Form/context.tsx
|
|
@@ -338,14 +377,23 @@ var FormContextProvider = FormContext.Provider;
|
|
|
338
377
|
var useFormContext = FormContext.use;
|
|
339
378
|
function FormLabel(props) {
|
|
340
379
|
const { Elements } = useFormContext();
|
|
341
|
-
if (props.Label) return /* @__PURE__ */ jsx(props.Label, {
|
|
342
|
-
return /* @__PURE__ */ jsx(Elements.Label, {
|
|
380
|
+
if (props.Label) return /* @__PURE__ */ jsx(props.Label, __spreadValues({}, props));
|
|
381
|
+
return /* @__PURE__ */ jsx(Elements.Label, __spreadValues({}, props));
|
|
343
382
|
}
|
|
383
|
+
FormLabel.displayName = "FormLabel";
|
|
384
|
+
FormLabel.whyDidYouRender = true;
|
|
344
385
|
function FormBody() {
|
|
345
386
|
const { items } = useFormContext();
|
|
346
|
-
return items.map((item) => /* @__PURE__ */ jsx(FormLabel, {
|
|
387
|
+
return items.map((item) => /* @__PURE__ */ jsx(FormLabel, __spreadValues({}, item), item.name));
|
|
347
388
|
}
|
|
348
|
-
|
|
389
|
+
FormBody.displayName = "FormBody";
|
|
390
|
+
FormBody.whyDidYouRender = true;
|
|
391
|
+
var FormInputElement = forwardRef((_a, ref) => {
|
|
392
|
+
var _b = _a, { onChange } = _b, props = __objRest(_b, ["onChange"]);
|
|
393
|
+
return /* @__PURE__ */ jsx("input", __spreadProps(__spreadValues({}, props), { onChange: (e) => onChange(e.target.value), ref }));
|
|
394
|
+
});
|
|
395
|
+
FormInputElement.displayName = "FormInputElement";
|
|
396
|
+
FormInputElement.whyDidYouRender = true;
|
|
349
397
|
var FormLabelElement = ({
|
|
350
398
|
name,
|
|
351
399
|
title,
|
|
@@ -354,16 +402,24 @@ var FormLabelElement = ({
|
|
|
354
402
|
input
|
|
355
403
|
}) => {
|
|
356
404
|
const { values, setValues } = useFormContext();
|
|
357
|
-
if (Label)
|
|
405
|
+
if (Label)
|
|
406
|
+
return /* @__PURE__ */ jsx(
|
|
407
|
+
Label,
|
|
408
|
+
{
|
|
409
|
+
name,
|
|
410
|
+
title,
|
|
411
|
+
description,
|
|
412
|
+
input
|
|
413
|
+
}
|
|
414
|
+
);
|
|
358
415
|
return /* @__PURE__ */ jsxs("label", { children: [
|
|
359
|
-
title
|
|
360
|
-
input
|
|
416
|
+
title != null ? title : name,
|
|
417
|
+
(input == null ? void 0 : input.Input) ? /* @__PURE__ */ jsx(
|
|
361
418
|
input.Input,
|
|
362
419
|
{
|
|
363
420
|
name,
|
|
364
421
|
value: values[name],
|
|
365
|
-
onChange: (v) => setValues((prev) => ({
|
|
366
|
-
...prev,
|
|
422
|
+
onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
367
423
|
[name]: v
|
|
368
424
|
}))
|
|
369
425
|
}
|
|
@@ -372,8 +428,7 @@ var FormLabelElement = ({
|
|
|
372
428
|
{
|
|
373
429
|
name,
|
|
374
430
|
value: values[name],
|
|
375
|
-
onChange: (v) => setValues((prev) => ({
|
|
376
|
-
...prev,
|
|
431
|
+
onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
377
432
|
[name]: v
|
|
378
433
|
}))
|
|
379
434
|
}
|
|
@@ -381,17 +436,24 @@ var FormLabelElement = ({
|
|
|
381
436
|
description
|
|
382
437
|
] });
|
|
383
438
|
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
)
|
|
439
|
+
FormLabelElement.displayName = "FormLabelElement";
|
|
440
|
+
FormLabelElement.whyDidYouRender = true;
|
|
441
|
+
var FormButtonElement = forwardRef((_a, ref) => {
|
|
442
|
+
var _b = _a, { disabled, children, onClick } = _b, props = __objRest(_b, ["disabled", "children", "onClick"]);
|
|
443
|
+
return /* @__PURE__ */ jsx(
|
|
444
|
+
"button",
|
|
445
|
+
__spreadProps(__spreadValues({
|
|
446
|
+
type: "button",
|
|
447
|
+
disabled,
|
|
448
|
+
onClick
|
|
449
|
+
}, props), {
|
|
450
|
+
ref,
|
|
451
|
+
children
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
});
|
|
455
|
+
FormButtonElement.displayName = "FormButtonElement";
|
|
456
|
+
FormButtonElement.whyDidYouRender = true;
|
|
395
457
|
|
|
396
458
|
// src/Form/elements/index.ts
|
|
397
459
|
var FormDefaultElements = {
|
|
@@ -413,13 +475,17 @@ function FormFooter() {
|
|
|
413
475
|
}
|
|
414
476
|
);
|
|
415
477
|
}
|
|
478
|
+
FormFooter.displayName = "FormFooter";
|
|
479
|
+
FormFooter.whyDidYouRender = true;
|
|
416
480
|
function mergeValues(items, defaultValues = {}) {
|
|
481
|
+
var _a;
|
|
417
482
|
const values = {};
|
|
418
483
|
for (const item of items)
|
|
419
|
-
values[item.name] = defaultValues[item.name]
|
|
484
|
+
values[item.name] = (_a = defaultValues[item.name]) != null ? _a : "";
|
|
420
485
|
return values;
|
|
421
486
|
}
|
|
422
|
-
function FormContainer(
|
|
487
|
+
function FormContainer(_a) {
|
|
488
|
+
var _b = _a, { defaultValues, elements } = _b, props = __objRest(_b, ["defaultValues", "elements"]);
|
|
423
489
|
const states = useSplittingState({
|
|
424
490
|
values: mergeValues(props.items, defaultValues),
|
|
425
491
|
submitting: false,
|
|
@@ -428,10 +494,7 @@ function FormContainer({ defaultValues, elements, ...props }) {
|
|
|
428
494
|
return /* @__PURE__ */ jsxs(
|
|
429
495
|
FormContextProvider,
|
|
430
496
|
{
|
|
431
|
-
value: {
|
|
432
|
-
...states,
|
|
433
|
-
...props
|
|
434
|
-
},
|
|
497
|
+
value: __spreadValues(__spreadValues({}, states), props),
|
|
435
498
|
children: [
|
|
436
499
|
/* @__PURE__ */ jsx(FormBody, {}),
|
|
437
500
|
/* @__PURE__ */ jsx(FormFooter, {})
|
|
@@ -439,5 +502,7 @@ function FormContainer({ defaultValues, elements, ...props }) {
|
|
|
439
502
|
}
|
|
440
503
|
);
|
|
441
504
|
}
|
|
505
|
+
FormContainer.displayName = "FormContainer";
|
|
506
|
+
FormContainer.whyDidYouRender = true;
|
|
442
507
|
|
|
443
508
|
export { ErrorBoundary, FaasDataWrapper, FaasReactClient, FormContainer as Form, FormContextProvider, FormDefaultElements, OptionalWrapper, createSplittingContext, equal, faas, getClient, useConstant, useEqualCallback, useEqualEffect, useEqualMemo, useEqualMemoize, useFaas, useFormContext, useSplittingState, withFaasData };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@faasjs/browser": "3.7.0-beta.
|
|
37
|
+
"@faasjs/browser": "3.7.0-beta.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@faasjs/browser": "3.7.0-beta.
|
|
40
|
+
"@faasjs/browser": "3.7.0-beta.2",
|
|
41
41
|
"@types/react": "*",
|
|
42
42
|
"react": "*"
|
|
43
43
|
},
|