@faasjs/react 3.7.0-beta.2 → 3.7.0-beta.3

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/dist/index.d.mts CHANGED
@@ -414,7 +414,7 @@ type FormElementTypes = {
414
414
  declare const FormDefaultElements: FormElementTypes;
415
415
 
416
416
  type FormProps<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes> = {
417
- items: FormLabelElementProps[];
417
+ items: FormLabelElementProps<FormElements>[];
418
418
  onSubmit?: (values: Values) => Promise<void>;
419
419
  elements?: Partial<FormElements>;
420
420
  defaultValues?: Values;
package/dist/index.d.ts CHANGED
@@ -414,7 +414,7 @@ type FormElementTypes = {
414
414
  declare const FormDefaultElements: FormElementTypes;
415
415
 
416
416
  type FormProps<Values extends Record<string, any> = Record<string, any>, FormElements extends FormElementTypes = FormElementTypes> = {
417
- items: FormLabelElementProps[];
417
+ items: FormLabelElementProps<FormElements>[];
418
418
  onSubmit?: (values: Values) => Promise<void>;
419
419
  elements?: Partial<FormElements>;
420
420
  defaultValues?: Values;
package/dist/index.js CHANGED
@@ -4,37 +4,7 @@ var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var browser = require('@faasjs/browser');
6
6
 
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
- };
7
+ // src/constant.ts
38
8
  function useConstant(fn) {
39
9
  const ref = react.useRef();
40
10
  if (!ref.current) {
@@ -118,14 +88,13 @@ function createSplittingContext(defaultValue) {
118
88
  const contexts = {};
119
89
  for (const key of keys) contexts[key] = react.createContext(defaultValues[key]);
120
90
  function Provider(props) {
121
- var _a, _b;
122
91
  let children = props.memo ? useEqualMemo(
123
92
  () => props.children,
124
93
  props.memo === true ? [] : props.memo
125
94
  ) : props.children;
126
95
  for (const key of keys) {
127
96
  const Context = contexts[key];
128
- const value = (_b = (_a = props.value) == null ? void 0 : _a[key]) != null ? _b : defaultValues[key];
97
+ const value = props.value?.[key] ?? defaultValues[key];
129
98
  children = /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value, children });
130
99
  }
131
100
  return children;
@@ -192,7 +161,7 @@ function FaasDataWrapper(props) {
192
161
  FaasDataWrapper.displayName = "FaasDataWrapper";
193
162
  FaasDataWrapper.whyDidYouRender = true;
194
163
  function withFaasData(Component2, faasProps) {
195
- return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, __spreadProps(__spreadValues({}, faasProps), { children: /* @__PURE__ */ jsxRuntime.jsx(Component2, __spreadValues({}, props)) }));
164
+ return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsxRuntime.jsx(Component2, { ...props }) });
196
165
  }
197
166
  function useFaas(action, defaultParams, options = {}) {
198
167
  const [loading, setLoading] = react.useState(true);
@@ -235,9 +204,9 @@ function useFaas(action, defaultParams, options = {}) {
235
204
  options.setData ? options.setData(r.data) : setData(r.data);
236
205
  setLoading(false);
237
206
  }).catch(async (e) => {
238
- if (typeof (e == null ? void 0 : e.message) === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
207
+ if (typeof e?.message === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
239
208
  return;
240
- if (!fails && typeof (e == null ? void 0 : e.message) === "string" && e.message.indexOf("Failed to fetch") >= 0) {
209
+ if (!fails && typeof e?.message === "string" && e.message.indexOf("Failed to fetch") >= 0) {
241
210
  console.warn(`FaasReactClient: ${e.message} retry...`);
242
211
  setFails(1);
243
212
  return send();
@@ -256,16 +225,14 @@ function useFaas(action, defaultParams, options = {}) {
256
225
  if (options.debounce) {
257
226
  const timeout = setTimeout(send, options.debounce);
258
227
  return () => {
259
- var _a;
260
228
  clearTimeout(timeout);
261
- (_a = controllerRef.current) == null ? void 0 : _a.abort();
229
+ controllerRef.current?.abort();
262
230
  setLoading(false);
263
231
  };
264
232
  }
265
233
  send();
266
234
  return () => {
267
- var _a;
268
- (_a = controllerRef.current) == null ? void 0 : _a.abort();
235
+ controllerRef.current?.abort();
269
236
  setLoading(false);
270
237
  };
271
238
  }, [action, options.params || params, reloadTimes, skip]);
@@ -297,7 +264,7 @@ useFaas.whyDidYouRender = true;
297
264
 
298
265
  // src/faas.ts
299
266
  async function faas(action, params, options) {
300
- const client = getClient(options == null ? void 0 : options.baseUrl);
267
+ const client = getClient(options?.baseUrl);
301
268
  if (client.onError)
302
269
  return client.browserClient.action(action, params, options).catch(async (res) => {
303
270
  await client.onError(action, params)(res);
@@ -312,9 +279,9 @@ function FaasReactClient({ baseUrl, options, onError } = {
312
279
  const client = new browser.FaasBrowserClient(baseUrl, options);
313
280
  const reactClient = {
314
281
  id: client.id,
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)),
282
+ faas: async (action, params, options2) => faas(action, params, { baseUrl, ...options2 }),
283
+ useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, { baseUrl, ...options2 }),
284
+ FaasDataWrapper: (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { baseUrl, ...props }),
318
285
  onError,
319
286
  browserClient: client
320
287
  };
@@ -330,6 +297,8 @@ function getClient(host) {
330
297
  return client;
331
298
  }
332
299
  var ErrorBoundary = class extends react.Component {
300
+ static displayName = "ErrorBoundary";
301
+ static whyDidYouRender = true;
333
302
  constructor(props) {
334
303
  super(props);
335
304
  this.state = {
@@ -344,9 +313,8 @@ var ErrorBoundary = class extends react.Component {
344
313
  });
345
314
  }
346
315
  render() {
347
- var _a;
348
316
  const errorMessage = (this.state.error || "").toString();
349
- const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
317
+ const errorDescription = this.state.info?.componentStack ? this.state.info.componentStack : null;
350
318
  if (this.state.error) {
351
319
  if (this.props.onError)
352
320
  this.props.onError(this.state.error, this.state.info);
@@ -365,10 +333,8 @@ var ErrorBoundary = class extends react.Component {
365
333
  return this.props.children;
366
334
  }
367
335
  };
368
- ErrorBoundary.displayName = "ErrorBoundary";
369
- ErrorBoundary.whyDidYouRender = true;
370
336
  var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
371
- return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, __spreadProps(__spreadValues({}, wrapperProps), { children })) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
337
+ return condition ? /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
372
338
  };
373
339
  OptionalWrapper.displayName = "OptionalWrapper";
374
340
  OptionalWrapper.whyDidYouRender = true;
@@ -379,21 +345,18 @@ var FormContextProvider = FormContext.Provider;
379
345
  var useFormContext = FormContext.use;
380
346
  function FormLabel(props) {
381
347
  const { Elements } = useFormContext();
382
- if (props.Label) return /* @__PURE__ */ jsxRuntime.jsx(props.Label, __spreadValues({}, props));
383
- return /* @__PURE__ */ jsxRuntime.jsx(Elements.Label, __spreadValues({}, props));
348
+ if (props.Label) return /* @__PURE__ */ jsxRuntime.jsx(props.Label, { ...props });
349
+ return /* @__PURE__ */ jsxRuntime.jsx(Elements.Label, { ...props });
384
350
  }
385
351
  FormLabel.displayName = "FormLabel";
386
352
  FormLabel.whyDidYouRender = true;
387
353
  function FormBody() {
388
354
  const { items } = useFormContext();
389
- return items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(FormLabel, __spreadValues({}, item), item.name));
355
+ return items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { ...item }, item.name));
390
356
  }
391
357
  FormBody.displayName = "FormBody";
392
358
  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
- });
359
+ var FormInputElement = react.forwardRef(({ onChange, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("input", { ...props, onChange: (e) => onChange(e.target.value), ref }));
397
360
  FormInputElement.displayName = "FormInputElement";
398
361
  FormInputElement.whyDidYouRender = true;
399
362
  var FormLabelElement = ({
@@ -415,13 +378,14 @@ var FormLabelElement = ({
415
378
  }
416
379
  );
417
380
  return /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
418
- title != null ? title : name,
419
- (input == null ? void 0 : input.Input) ? /* @__PURE__ */ jsxRuntime.jsx(
381
+ title ?? name,
382
+ input?.Input ? /* @__PURE__ */ jsxRuntime.jsx(
420
383
  input.Input,
421
384
  {
422
385
  name,
423
386
  value: values[name],
424
- onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
387
+ onChange: (v) => setValues((prev) => ({
388
+ ...prev,
425
389
  [name]: v
426
390
  }))
427
391
  }
@@ -430,7 +394,8 @@ var FormLabelElement = ({
430
394
  {
431
395
  name,
432
396
  value: values[name],
433
- onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
397
+ onChange: (v) => setValues((prev) => ({
398
+ ...prev,
434
399
  [name]: v
435
400
  }))
436
401
  }
@@ -440,20 +405,17 @@ var FormLabelElement = ({
440
405
  };
441
406
  FormLabelElement.displayName = "FormLabelElement";
442
407
  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
- });
408
+ var FormButtonElement = react.forwardRef(({ disabled, children, onClick, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
409
+ "button",
410
+ {
411
+ type: "button",
412
+ disabled,
413
+ onClick,
414
+ ...props,
415
+ ref,
416
+ children
417
+ }
418
+ ));
457
419
  FormButtonElement.displayName = "FormButtonElement";
458
420
  FormButtonElement.whyDidYouRender = true;
459
421
 
@@ -480,14 +442,12 @@ function FormFooter() {
480
442
  FormFooter.displayName = "FormFooter";
481
443
  FormFooter.whyDidYouRender = true;
482
444
  function mergeValues(items, defaultValues = {}) {
483
- var _a;
484
445
  const values = {};
485
446
  for (const item of items)
486
- values[item.name] = (_a = defaultValues[item.name]) != null ? _a : "";
447
+ values[item.name] = defaultValues[item.name] ?? "";
487
448
  return values;
488
449
  }
489
- function FormContainer(_a) {
490
- var _b = _a, { defaultValues, elements } = _b, props = __objRest(_b, ["defaultValues", "elements"]);
450
+ function FormContainer({ defaultValues, elements, ...props }) {
491
451
  const states = useSplittingState({
492
452
  values: mergeValues(props.items, defaultValues),
493
453
  submitting: false,
@@ -496,7 +456,11 @@ function FormContainer(_a) {
496
456
  return /* @__PURE__ */ jsxRuntime.jsxs(
497
457
  FormContextProvider,
498
458
  {
499
- value: __spreadValues(__spreadValues({}, states), props),
459
+ value: {
460
+ ...states,
461
+ ...props
462
+ },
463
+ memo: true,
500
464
  children: [
501
465
  /* @__PURE__ */ jsxRuntime.jsx(FormBody, {}),
502
466
  /* @__PURE__ */ jsxRuntime.jsx(FormFooter, {})
package/dist/index.mjs CHANGED
@@ -2,37 +2,7 @@ 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
- 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
- };
5
+ // src/constant.ts
36
6
  function useConstant(fn) {
37
7
  const ref = useRef();
38
8
  if (!ref.current) {
@@ -116,14 +86,13 @@ function createSplittingContext(defaultValue) {
116
86
  const contexts = {};
117
87
  for (const key of keys) contexts[key] = createContext(defaultValues[key]);
118
88
  function Provider(props) {
119
- var _a, _b;
120
89
  let children = props.memo ? useEqualMemo(
121
90
  () => props.children,
122
91
  props.memo === true ? [] : props.memo
123
92
  ) : props.children;
124
93
  for (const key of keys) {
125
94
  const Context = contexts[key];
126
- const value = (_b = (_a = props.value) == null ? void 0 : _a[key]) != null ? _b : defaultValues[key];
95
+ const value = props.value?.[key] ?? defaultValues[key];
127
96
  children = /* @__PURE__ */ jsx(Context.Provider, { value, children });
128
97
  }
129
98
  return children;
@@ -190,7 +159,7 @@ function FaasDataWrapper(props) {
190
159
  FaasDataWrapper.displayName = "FaasDataWrapper";
191
160
  FaasDataWrapper.whyDidYouRender = true;
192
161
  function withFaasData(Component2, faasProps) {
193
- return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, __spreadProps(__spreadValues({}, faasProps), { children: /* @__PURE__ */ jsx(Component2, __spreadValues({}, props)) }));
162
+ return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
194
163
  }
195
164
  function useFaas(action, defaultParams, options = {}) {
196
165
  const [loading, setLoading] = useState(true);
@@ -233,9 +202,9 @@ function useFaas(action, defaultParams, options = {}) {
233
202
  options.setData ? options.setData(r.data) : setData(r.data);
234
203
  setLoading(false);
235
204
  }).catch(async (e) => {
236
- if (typeof (e == null ? void 0 : e.message) === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
205
+ if (typeof e?.message === "string" && e.message.toLowerCase().indexOf("aborted") >= 0)
237
206
  return;
238
- if (!fails && typeof (e == null ? void 0 : e.message) === "string" && e.message.indexOf("Failed to fetch") >= 0) {
207
+ if (!fails && typeof e?.message === "string" && e.message.indexOf("Failed to fetch") >= 0) {
239
208
  console.warn(`FaasReactClient: ${e.message} retry...`);
240
209
  setFails(1);
241
210
  return send();
@@ -254,16 +223,14 @@ function useFaas(action, defaultParams, options = {}) {
254
223
  if (options.debounce) {
255
224
  const timeout = setTimeout(send, options.debounce);
256
225
  return () => {
257
- var _a;
258
226
  clearTimeout(timeout);
259
- (_a = controllerRef.current) == null ? void 0 : _a.abort();
227
+ controllerRef.current?.abort();
260
228
  setLoading(false);
261
229
  };
262
230
  }
263
231
  send();
264
232
  return () => {
265
- var _a;
266
- (_a = controllerRef.current) == null ? void 0 : _a.abort();
233
+ controllerRef.current?.abort();
267
234
  setLoading(false);
268
235
  };
269
236
  }, [action, options.params || params, reloadTimes, skip]);
@@ -295,7 +262,7 @@ useFaas.whyDidYouRender = true;
295
262
 
296
263
  // src/faas.ts
297
264
  async function faas(action, params, options) {
298
- const client = getClient(options == null ? void 0 : options.baseUrl);
265
+ const client = getClient(options?.baseUrl);
299
266
  if (client.onError)
300
267
  return client.browserClient.action(action, params, options).catch(async (res) => {
301
268
  await client.onError(action, params)(res);
@@ -310,9 +277,9 @@ function FaasReactClient({ baseUrl, options, onError } = {
310
277
  const client = new FaasBrowserClient(baseUrl, options);
311
278
  const reactClient = {
312
279
  id: client.id,
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)),
280
+ faas: async (action, params, options2) => faas(action, params, { baseUrl, ...options2 }),
281
+ useFaas: (action, defaultParams, options2) => useFaas(action, defaultParams, { baseUrl, ...options2 }),
282
+ FaasDataWrapper: (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { baseUrl, ...props }),
316
283
  onError,
317
284
  browserClient: client
318
285
  };
@@ -328,6 +295,8 @@ function getClient(host) {
328
295
  return client;
329
296
  }
330
297
  var ErrorBoundary = class extends Component {
298
+ static displayName = "ErrorBoundary";
299
+ static whyDidYouRender = true;
331
300
  constructor(props) {
332
301
  super(props);
333
302
  this.state = {
@@ -342,9 +311,8 @@ var ErrorBoundary = class extends Component {
342
311
  });
343
312
  }
344
313
  render() {
345
- var _a;
346
314
  const errorMessage = (this.state.error || "").toString();
347
- const errorDescription = ((_a = this.state.info) == null ? void 0 : _a.componentStack) ? this.state.info.componentStack : null;
315
+ const errorDescription = this.state.info?.componentStack ? this.state.info.componentStack : null;
348
316
  if (this.state.error) {
349
317
  if (this.props.onError)
350
318
  this.props.onError(this.state.error, this.state.info);
@@ -363,10 +331,8 @@ var ErrorBoundary = class extends Component {
363
331
  return this.props.children;
364
332
  }
365
333
  };
366
- ErrorBoundary.displayName = "ErrorBoundary";
367
- ErrorBoundary.whyDidYouRender = true;
368
334
  var OptionalWrapper = ({ condition, Wrapper, wrapperProps, children }) => {
369
- return condition ? /* @__PURE__ */ jsx(Wrapper, __spreadProps(__spreadValues({}, wrapperProps), { children })) : /* @__PURE__ */ jsx(Fragment, { children });
335
+ return condition ? /* @__PURE__ */ jsx(Wrapper, { ...wrapperProps, children }) : /* @__PURE__ */ jsx(Fragment, { children });
370
336
  };
371
337
  OptionalWrapper.displayName = "OptionalWrapper";
372
338
  OptionalWrapper.whyDidYouRender = true;
@@ -377,21 +343,18 @@ var FormContextProvider = FormContext.Provider;
377
343
  var useFormContext = FormContext.use;
378
344
  function FormLabel(props) {
379
345
  const { Elements } = useFormContext();
380
- if (props.Label) return /* @__PURE__ */ jsx(props.Label, __spreadValues({}, props));
381
- return /* @__PURE__ */ jsx(Elements.Label, __spreadValues({}, props));
346
+ if (props.Label) return /* @__PURE__ */ jsx(props.Label, { ...props });
347
+ return /* @__PURE__ */ jsx(Elements.Label, { ...props });
382
348
  }
383
349
  FormLabel.displayName = "FormLabel";
384
350
  FormLabel.whyDidYouRender = true;
385
351
  function FormBody() {
386
352
  const { items } = useFormContext();
387
- return items.map((item) => /* @__PURE__ */ jsx(FormLabel, __spreadValues({}, item), item.name));
353
+ return items.map((item) => /* @__PURE__ */ jsx(FormLabel, { ...item }, item.name));
388
354
  }
389
355
  FormBody.displayName = "FormBody";
390
356
  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
- });
357
+ var FormInputElement = forwardRef(({ onChange, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, onChange: (e) => onChange(e.target.value), ref }));
395
358
  FormInputElement.displayName = "FormInputElement";
396
359
  FormInputElement.whyDidYouRender = true;
397
360
  var FormLabelElement = ({
@@ -413,13 +376,14 @@ var FormLabelElement = ({
413
376
  }
414
377
  );
415
378
  return /* @__PURE__ */ jsxs("label", { children: [
416
- title != null ? title : name,
417
- (input == null ? void 0 : input.Input) ? /* @__PURE__ */ jsx(
379
+ title ?? name,
380
+ input?.Input ? /* @__PURE__ */ jsx(
418
381
  input.Input,
419
382
  {
420
383
  name,
421
384
  value: values[name],
422
- onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
385
+ onChange: (v) => setValues((prev) => ({
386
+ ...prev,
423
387
  [name]: v
424
388
  }))
425
389
  }
@@ -428,7 +392,8 @@ var FormLabelElement = ({
428
392
  {
429
393
  name,
430
394
  value: values[name],
431
- onChange: (v) => setValues((prev) => __spreadProps(__spreadValues({}, prev), {
395
+ onChange: (v) => setValues((prev) => ({
396
+ ...prev,
432
397
  [name]: v
433
398
  }))
434
399
  }
@@ -438,20 +403,17 @@ var FormLabelElement = ({
438
403
  };
439
404
  FormLabelElement.displayName = "FormLabelElement";
440
405
  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
- });
406
+ var FormButtonElement = forwardRef(({ disabled, children, onClick, ...props }, ref) => /* @__PURE__ */ jsx(
407
+ "button",
408
+ {
409
+ type: "button",
410
+ disabled,
411
+ onClick,
412
+ ...props,
413
+ ref,
414
+ children
415
+ }
416
+ ));
455
417
  FormButtonElement.displayName = "FormButtonElement";
456
418
  FormButtonElement.whyDidYouRender = true;
457
419
 
@@ -478,14 +440,12 @@ function FormFooter() {
478
440
  FormFooter.displayName = "FormFooter";
479
441
  FormFooter.whyDidYouRender = true;
480
442
  function mergeValues(items, defaultValues = {}) {
481
- var _a;
482
443
  const values = {};
483
444
  for (const item of items)
484
- values[item.name] = (_a = defaultValues[item.name]) != null ? _a : "";
445
+ values[item.name] = defaultValues[item.name] ?? "";
485
446
  return values;
486
447
  }
487
- function FormContainer(_a) {
488
- var _b = _a, { defaultValues, elements } = _b, props = __objRest(_b, ["defaultValues", "elements"]);
448
+ function FormContainer({ defaultValues, elements, ...props }) {
489
449
  const states = useSplittingState({
490
450
  values: mergeValues(props.items, defaultValues),
491
451
  submitting: false,
@@ -494,7 +454,11 @@ function FormContainer(_a) {
494
454
  return /* @__PURE__ */ jsxs(
495
455
  FormContextProvider,
496
456
  {
497
- value: __spreadValues(__spreadValues({}, states), props),
457
+ value: {
458
+ ...states,
459
+ ...props
460
+ },
461
+ memo: true,
498
462
  children: [
499
463
  /* @__PURE__ */ jsx(FormBody, {}),
500
464
  /* @__PURE__ */ jsx(FormFooter, {})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "3.7.0-beta.2",
3
+ "version": "3.7.0-beta.3",
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.2"
37
+ "@faasjs/browser": "3.7.0-beta.3"
38
38
  },
39
39
  "devDependencies": {
40
- "@faasjs/browser": "3.7.0-beta.2",
40
+ "@faasjs/browser": "3.7.0-beta.3",
41
41
  "@types/react": "*",
42
42
  "react": "*"
43
43
  },