@faasjs/react 3.7.0-beta.3 → 3.7.0-beta.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/dist/index.d.mts CHANGED
@@ -153,7 +153,7 @@ declare function createSplittingContext<T extends Record<string, any>>(defaultVa
153
153
  use: <NewT extends T = T>() => Readonly<NewT>;
154
154
  };
155
155
 
156
- type SetPrefix<S extends string | number | symbol> = S extends string ? (S extends `${infer First}${infer Rest}` ? `set${Capitalize<First>}${Rest}` : never) : never;
156
+ type SetPrefix<S extends string | number | symbol> = S extends string ? S extends `${infer First}${infer Rest}` ? `set${Capitalize<First>}${Rest}` : never : never;
157
157
  type StateSetters<T> = {
158
158
  [K in keyof T as SetPrefix<K>]: Dispatch<SetStateAction<T[K]>>;
159
159
  };
@@ -374,9 +374,10 @@ declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
374
374
  whyDidYouRender: boolean;
375
375
  };
376
376
 
377
- type FormRules = {
378
- type?: 'string' | 'number';
379
- required?: boolean;
377
+ type FormButtonElementProps = {
378
+ children?: React.ReactNode;
379
+ disabled?: boolean;
380
+ submit?: () => void;
380
381
  };
381
382
 
382
383
  type FormInputElementProps = {
@@ -385,6 +386,11 @@ type FormInputElementProps = {
385
386
  onChange: (value: any) => void;
386
387
  };
387
388
 
389
+ type FormRules = {
390
+ type?: 'string' | 'number';
391
+ required?: boolean;
392
+ };
393
+
388
394
  type InferFormInputProps<T extends ComponentType<FormInputElementProps> | JSXElementConstructor<any>> = T extends ComponentType<FormInputElementProps> ? Omit<ComponentProps<T>, 'name' | 'value' | 'onChange'> : Omit<ComponentProps<T>, 'name' | 'value'>;
389
395
  type FormInputProps<FormElements extends FormElementTypes = FormElementTypes> = {
390
396
  Input?: ComponentType<FormInputElementProps>;
@@ -400,12 +406,6 @@ type FormLabelElementProps<FormElements extends FormElementTypes = FormElementTy
400
406
  input?: FormInputProps<FormElements>;
401
407
  };
402
408
 
403
- type FormButtonElementProps = {
404
- children?: React.ReactNode;
405
- disabled?: boolean;
406
- onClick?: () => void;
407
- };
408
-
409
409
  type FormElementTypes = {
410
410
  Label: ComponentType<FormLabelElementProps>;
411
411
  Input: ComponentType<FormInputElementProps>;
package/dist/index.d.ts CHANGED
@@ -153,7 +153,7 @@ declare function createSplittingContext<T extends Record<string, any>>(defaultVa
153
153
  use: <NewT extends T = T>() => Readonly<NewT>;
154
154
  };
155
155
 
156
- type SetPrefix<S extends string | number | symbol> = S extends string ? (S extends `${infer First}${infer Rest}` ? `set${Capitalize<First>}${Rest}` : never) : never;
156
+ type SetPrefix<S extends string | number | symbol> = S extends string ? S extends `${infer First}${infer Rest}` ? `set${Capitalize<First>}${Rest}` : never : never;
157
157
  type StateSetters<T> = {
158
158
  [K in keyof T as SetPrefix<K>]: Dispatch<SetStateAction<T[K]>>;
159
159
  };
@@ -374,9 +374,10 @@ declare const OptionalWrapper: React.FC<OptionalWrapperProps> & {
374
374
  whyDidYouRender: boolean;
375
375
  };
376
376
 
377
- type FormRules = {
378
- type?: 'string' | 'number';
379
- required?: boolean;
377
+ type FormButtonElementProps = {
378
+ children?: React.ReactNode;
379
+ disabled?: boolean;
380
+ submit?: () => void;
380
381
  };
381
382
 
382
383
  type FormInputElementProps = {
@@ -385,6 +386,11 @@ type FormInputElementProps = {
385
386
  onChange: (value: any) => void;
386
387
  };
387
388
 
389
+ type FormRules = {
390
+ type?: 'string' | 'number';
391
+ required?: boolean;
392
+ };
393
+
388
394
  type InferFormInputProps<T extends ComponentType<FormInputElementProps> | JSXElementConstructor<any>> = T extends ComponentType<FormInputElementProps> ? Omit<ComponentProps<T>, 'name' | 'value' | 'onChange'> : Omit<ComponentProps<T>, 'name' | 'value'>;
389
395
  type FormInputProps<FormElements extends FormElementTypes = FormElementTypes> = {
390
396
  Input?: ComponentType<FormInputElementProps>;
@@ -400,12 +406,6 @@ type FormLabelElementProps<FormElements extends FormElementTypes = FormElementTy
400
406
  input?: FormInputProps<FormElements>;
401
407
  };
402
408
 
403
- type FormButtonElementProps = {
404
- children?: React.ReactNode;
405
- disabled?: boolean;
406
- onClick?: () => void;
407
- };
408
-
409
409
  type FormElementTypes = {
410
410
  Label: ComponentType<FormLabelElementProps>;
411
411
  Input: ComponentType<FormInputElementProps>;
package/dist/index.js CHANGED
@@ -122,7 +122,10 @@ function useSplittingState(initialStates) {
122
122
  const states = {};
123
123
  for (const key of Object.keys(initialStates)) {
124
124
  const state = react.useState(initialStates[key]);
125
- Object.assign(states, { [key]: state[0], [`set${String(key).charAt(0).toUpperCase()}${String(key).slice(1)}`]: state[1] });
125
+ Object.assign(states, {
126
+ [key]: state[0],
127
+ [`set${String(key).charAt(0).toUpperCase()}${String(key).slice(1)}`]: state[1]
128
+ });
126
129
  }
127
130
  return states;
128
131
  }
@@ -163,6 +166,17 @@ FaasDataWrapper.whyDidYouRender = true;
163
166
  function withFaasData(Component2, faasProps) {
164
167
  return (props) => /* @__PURE__ */ jsxRuntime.jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsxRuntime.jsx(Component2, { ...props }) });
165
168
  }
169
+
170
+ // src/faas.ts
171
+ async function faas(action, params, options) {
172
+ const client = getClient(options?.baseUrl);
173
+ if (client.onError)
174
+ return client.browserClient.action(action, params, options).catch(async (res) => {
175
+ await client.onError(action, params)(res);
176
+ return Promise.reject(res);
177
+ });
178
+ return client.browserClient.action(action, params, options);
179
+ }
166
180
  function useFaas(action, defaultParams, options = {}) {
167
181
  const [loading, setLoading] = react.useState(true);
168
182
  const [data, setData] = react.useState();
@@ -261,17 +275,6 @@ function useFaas(action, defaultParams, options = {}) {
261
275
  };
262
276
  }
263
277
  useFaas.whyDidYouRender = true;
264
-
265
- // src/faas.ts
266
- async function faas(action, params, options) {
267
- const client = getClient(options?.baseUrl);
268
- if (client.onError)
269
- return client.browserClient.action(action, params, options).catch(async (res) => {
270
- await client.onError(action, params)(res);
271
- return Promise.reject(res);
272
- });
273
- return client.browserClient.action(action, params, options);
274
- }
275
278
  var clients = {};
276
279
  function FaasReactClient({ baseUrl, options, onError } = {
277
280
  baseUrl: "/"
@@ -340,7 +343,15 @@ OptionalWrapper.displayName = "OptionalWrapper";
340
343
  OptionalWrapper.whyDidYouRender = true;
341
344
 
342
345
  // src/Form/context.tsx
343
- var FormContext = createSplittingContext(["items", "onSubmit", "Elements", "submitting", "setSubmitting", "values", "setValues"]);
346
+ var FormContext = createSplittingContext([
347
+ "items",
348
+ "onSubmit",
349
+ "Elements",
350
+ "submitting",
351
+ "setSubmitting",
352
+ "values",
353
+ "setValues"
354
+ ]);
344
355
  var FormContextProvider = FormContext.Provider;
345
356
  var useFormContext = FormContext.use;
346
357
  function FormLabel(props) {
@@ -356,6 +367,35 @@ function FormBody() {
356
367
  }
357
368
  FormBody.displayName = "FormBody";
358
369
  FormBody.whyDidYouRender = true;
370
+ function FormFooter() {
371
+ const { submitting, setSubmitting, onSubmit, values, Elements } = useFormContext();
372
+ return /* @__PURE__ */ jsxRuntime.jsx(
373
+ Elements.Button,
374
+ {
375
+ disabled: submitting,
376
+ submit: () => {
377
+ setSubmitting(true);
378
+ onSubmit(values).finally(() => setSubmitting(false));
379
+ },
380
+ children: "Submit"
381
+ }
382
+ );
383
+ }
384
+ FormFooter.displayName = "FormFooter";
385
+ FormFooter.whyDidYouRender = true;
386
+ var FormButtonElement = react.forwardRef(({ disabled, children, submit, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
387
+ "button",
388
+ {
389
+ type: "button",
390
+ disabled,
391
+ onClick: submit,
392
+ ...props,
393
+ ref,
394
+ children
395
+ }
396
+ ));
397
+ FormButtonElement.displayName = "FormButtonElement";
398
+ FormButtonElement.whyDidYouRender = true;
359
399
  var FormInputElement = react.forwardRef(({ onChange, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("input", { ...props, onChange: (e) => onChange(e.target.value), ref }));
360
400
  FormInputElement.displayName = "FormInputElement";
361
401
  FormInputElement.whyDidYouRender = true;
@@ -405,19 +445,6 @@ var FormLabelElement = ({
405
445
  };
406
446
  FormLabelElement.displayName = "FormLabelElement";
407
447
  FormLabelElement.whyDidYouRender = true;
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
- ));
419
- FormButtonElement.displayName = "FormButtonElement";
420
- FormButtonElement.whyDidYouRender = true;
421
448
 
422
449
  // src/Form/elements/index.ts
423
450
  var FormDefaultElements = {
@@ -425,22 +452,6 @@ var FormDefaultElements = {
425
452
  Input: FormInputElement,
426
453
  Button: FormButtonElement
427
454
  };
428
- function FormFooter() {
429
- const { submitting, setSubmitting, onSubmit, values, Elements } = useFormContext();
430
- return /* @__PURE__ */ jsxRuntime.jsx(
431
- Elements.Button,
432
- {
433
- disabled: submitting,
434
- onClick: () => {
435
- setSubmitting(true);
436
- onSubmit(values).finally(() => setSubmitting(false));
437
- },
438
- children: "Submit"
439
- }
440
- );
441
- }
442
- FormFooter.displayName = "FormFooter";
443
- FormFooter.whyDidYouRender = true;
444
455
  function mergeValues(items, defaultValues = {}) {
445
456
  const values = {};
446
457
  for (const item of items)
package/dist/index.mjs CHANGED
@@ -120,7 +120,10 @@ function useSplittingState(initialStates) {
120
120
  const states = {};
121
121
  for (const key of Object.keys(initialStates)) {
122
122
  const state = useState(initialStates[key]);
123
- Object.assign(states, { [key]: state[0], [`set${String(key).charAt(0).toUpperCase()}${String(key).slice(1)}`]: state[1] });
123
+ Object.assign(states, {
124
+ [key]: state[0],
125
+ [`set${String(key).charAt(0).toUpperCase()}${String(key).slice(1)}`]: state[1]
126
+ });
124
127
  }
125
128
  return states;
126
129
  }
@@ -161,6 +164,17 @@ FaasDataWrapper.whyDidYouRender = true;
161
164
  function withFaasData(Component2, faasProps) {
162
165
  return (props) => /* @__PURE__ */ jsx(FaasDataWrapper, { ...faasProps, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
163
166
  }
167
+
168
+ // src/faas.ts
169
+ async function faas(action, params, options) {
170
+ const client = getClient(options?.baseUrl);
171
+ if (client.onError)
172
+ return client.browserClient.action(action, params, options).catch(async (res) => {
173
+ await client.onError(action, params)(res);
174
+ return Promise.reject(res);
175
+ });
176
+ return client.browserClient.action(action, params, options);
177
+ }
164
178
  function useFaas(action, defaultParams, options = {}) {
165
179
  const [loading, setLoading] = useState(true);
166
180
  const [data, setData] = useState();
@@ -259,17 +273,6 @@ function useFaas(action, defaultParams, options = {}) {
259
273
  };
260
274
  }
261
275
  useFaas.whyDidYouRender = true;
262
-
263
- // src/faas.ts
264
- async function faas(action, params, options) {
265
- const client = getClient(options?.baseUrl);
266
- if (client.onError)
267
- return client.browserClient.action(action, params, options).catch(async (res) => {
268
- await client.onError(action, params)(res);
269
- return Promise.reject(res);
270
- });
271
- return client.browserClient.action(action, params, options);
272
- }
273
276
  var clients = {};
274
277
  function FaasReactClient({ baseUrl, options, onError } = {
275
278
  baseUrl: "/"
@@ -338,7 +341,15 @@ OptionalWrapper.displayName = "OptionalWrapper";
338
341
  OptionalWrapper.whyDidYouRender = true;
339
342
 
340
343
  // src/Form/context.tsx
341
- var FormContext = createSplittingContext(["items", "onSubmit", "Elements", "submitting", "setSubmitting", "values", "setValues"]);
344
+ var FormContext = createSplittingContext([
345
+ "items",
346
+ "onSubmit",
347
+ "Elements",
348
+ "submitting",
349
+ "setSubmitting",
350
+ "values",
351
+ "setValues"
352
+ ]);
342
353
  var FormContextProvider = FormContext.Provider;
343
354
  var useFormContext = FormContext.use;
344
355
  function FormLabel(props) {
@@ -354,6 +365,35 @@ function FormBody() {
354
365
  }
355
366
  FormBody.displayName = "FormBody";
356
367
  FormBody.whyDidYouRender = true;
368
+ function FormFooter() {
369
+ const { submitting, setSubmitting, onSubmit, values, Elements } = useFormContext();
370
+ return /* @__PURE__ */ jsx(
371
+ Elements.Button,
372
+ {
373
+ disabled: submitting,
374
+ submit: () => {
375
+ setSubmitting(true);
376
+ onSubmit(values).finally(() => setSubmitting(false));
377
+ },
378
+ children: "Submit"
379
+ }
380
+ );
381
+ }
382
+ FormFooter.displayName = "FormFooter";
383
+ FormFooter.whyDidYouRender = true;
384
+ var FormButtonElement = forwardRef(({ disabled, children, submit, ...props }, ref) => /* @__PURE__ */ jsx(
385
+ "button",
386
+ {
387
+ type: "button",
388
+ disabled,
389
+ onClick: submit,
390
+ ...props,
391
+ ref,
392
+ children
393
+ }
394
+ ));
395
+ FormButtonElement.displayName = "FormButtonElement";
396
+ FormButtonElement.whyDidYouRender = true;
357
397
  var FormInputElement = forwardRef(({ onChange, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, onChange: (e) => onChange(e.target.value), ref }));
358
398
  FormInputElement.displayName = "FormInputElement";
359
399
  FormInputElement.whyDidYouRender = true;
@@ -403,19 +443,6 @@ var FormLabelElement = ({
403
443
  };
404
444
  FormLabelElement.displayName = "FormLabelElement";
405
445
  FormLabelElement.whyDidYouRender = true;
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
- ));
417
- FormButtonElement.displayName = "FormButtonElement";
418
- FormButtonElement.whyDidYouRender = true;
419
446
 
420
447
  // src/Form/elements/index.ts
421
448
  var FormDefaultElements = {
@@ -423,22 +450,6 @@ var FormDefaultElements = {
423
450
  Input: FormInputElement,
424
451
  Button: FormButtonElement
425
452
  };
426
- function FormFooter() {
427
- const { submitting, setSubmitting, onSubmit, values, Elements } = useFormContext();
428
- return /* @__PURE__ */ jsx(
429
- Elements.Button,
430
- {
431
- disabled: submitting,
432
- onClick: () => {
433
- setSubmitting(true);
434
- onSubmit(values).finally(() => setSubmitting(false));
435
- },
436
- children: "Submit"
437
- }
438
- );
439
- }
440
- FormFooter.displayName = "FormFooter";
441
- FormFooter.whyDidYouRender = true;
442
453
  function mergeValues(items, defaultValues = {}) {
443
454
  const values = {};
444
455
  for (const item of items)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/react",
3
- "version": "3.7.0-beta.3",
3
+ "version": "3.7.0-beta.4",
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.3"
37
+ "@faasjs/browser": "3.7.0-beta.4"
38
38
  },
39
39
  "devDependencies": {
40
- "@faasjs/browser": "3.7.0-beta.3",
40
+ "@faasjs/browser": "3.7.0-beta.4",
41
41
  "@types/react": "*",
42
42
  "react": "*"
43
43
  },