@firecms/collection_editor 3.0.0-beta.2-pre.3 → 3.0.0-beta.2-pre.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.
Files changed (49) hide show
  1. package/dist/index.es.js +1610 -1748
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +2 -2
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/ui/collection_editor/PropertyEditView.d.ts +1 -1
  6. package/dist/ui/collection_editor/SwitchControl.d.ts +1 -1
  7. package/package.json +6 -5
  8. package/src/ConfigControllerProvider.tsx +1 -1
  9. package/src/ui/RootCollectionSuggestions.tsx +1 -1
  10. package/src/ui/collection_editor/CollectionDetailsForm.tsx +1 -1
  11. package/src/ui/collection_editor/CollectionEditorDialog.tsx +2 -4
  12. package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +1 -1
  13. package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +2 -2
  14. package/src/ui/collection_editor/EnumForm.tsx +1 -1
  15. package/src/ui/collection_editor/PropertyEditView.tsx +3 -2
  16. package/src/ui/collection_editor/SubcollectionsEditTab.tsx +1 -1
  17. package/src/ui/collection_editor/SwitchControl.tsx +1 -1
  18. package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +1 -1
  19. package/src/ui/collection_editor/properties/BlockPropertyField.tsx +1 -1
  20. package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +1 -1
  21. package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +1 -1
  22. package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +1 -1
  23. package/src/ui/collection_editor/properties/EnumPropertyField.tsx +1 -1
  24. package/src/ui/collection_editor/properties/MapPropertyField.tsx +1 -1
  25. package/src/ui/collection_editor/properties/NumberPropertyField.tsx +1 -1
  26. package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +1 -1
  27. package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +1 -1
  28. package/src/ui/collection_editor/properties/StoragePropertyField.tsx +1 -1
  29. package/src/ui/collection_editor/properties/StringPropertyField.tsx +1 -1
  30. package/src/ui/collection_editor/properties/UrlPropertyField.tsx +1 -1
  31. package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +1 -1
  32. package/src/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +1 -1
  33. package/src/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +1 -1
  34. package/src/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +1 -1
  35. package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +2 -2
  36. package/src/useCollectionEditorPlugin.tsx +1 -16
  37. package/dist/form/Field.d.ts +0 -53
  38. package/dist/form/Formex.d.ts +0 -4
  39. package/dist/form/index.d.ts +0 -5
  40. package/dist/form/types.d.ts +0 -25
  41. package/dist/form/useCreateFormex.d.ts +0 -9
  42. package/dist/form/utils.d.ts +0 -44
  43. package/src/form/Field.tsx +0 -162
  44. package/src/form/Formex.tsx +0 -8
  45. package/src/form/README.md +0 -165
  46. package/src/form/index.ts +0 -5
  47. package/src/form/types.ts +0 -27
  48. package/src/form/useCreateFormex.tsx +0 -137
  49. package/src/form/utils.ts +0 -169
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { FormexController } from "../../form";
2
+ import { FormexController } from "@firecms/formex";
3
3
  import { Property, PropertyConfig } from "@firecms/core";
4
4
  export type PropertyWithId = Property & {
5
5
  id?: string;
@@ -1,4 +1,4 @@
1
- import { FormexFieldProps } from "../../form";
1
+ import { FormexFieldProps } from "@firecms/formex";
2
2
  export declare function SwitchControl({ field, form, label, tooltip, disabled, size, allowIndeterminate }: FormexFieldProps & {
3
3
  label: string;
4
4
  tooltip?: string;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.2-pre.3",
4
+ "version": "3.0.0-beta.2-pre.4",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
- "@firecms/data_import_export": "^3.0.0-beta.2-pre.3",
11
- "@firecms/schema_inference": "^3.0.0-beta.2-pre.3",
12
- "@firecms/ui": "^3.0.0-beta.2-pre.3",
10
+ "@firecms/data_import_export": "^3.0.0-beta.2-pre.4",
11
+ "@firecms/formex": "^3.0.0-beta.2-pre.4",
12
+ "@firecms/schema_inference": "^3.0.0-beta.2-pre.4",
13
+ "@firecms/ui": "^3.0.0-beta.2-pre.4",
13
14
  "json5": "^2.2.3",
14
15
  "prism-react-renderer": "^2.3.1"
15
16
  },
@@ -72,5 +73,5 @@
72
73
  "publishConfig": {
73
74
  "access": "public"
74
75
  },
75
- "gitHead": "c78c58643c73ba776dfbcb8315d1a99160bb607a"
76
+ "gitHead": "a947c08aada0e374aec7dff2b0dc9e540e170834"
76
77
  }
@@ -80,7 +80,7 @@ export const ConfigControllerProvider = React.memo(
80
80
  const {
81
81
  collections
82
82
  } = navigation;
83
- const existingPaths = collections.map(col => col.path.trim().toLowerCase());
83
+ const existingPaths = (collections ?? []).map(col => col.path.trim().toLowerCase());
84
84
 
85
85
  const [rootPathSuggestions, setRootPathSuggestions] = React.useState<string[] | undefined>();
86
86
  useEffect(() => {
@@ -17,7 +17,7 @@ export function RootCollectionSuggestions() {
17
17
 
18
18
  const rootPathSuggestions = collectionEditorController.rootPathSuggestions ?? [];
19
19
 
20
- const showSuggestions = rootPathSuggestions.length > 3 || (navigationController.collections.length === 0 && rootPathSuggestions.length > 0);
20
+ const showSuggestions = rootPathSuggestions.length > 3 || ((navigationController.collections ?? []).length === 0 && rootPathSuggestions.length > 0);
21
21
  return <Collapse
22
22
  in={showSuggestions}>
23
23
 
@@ -21,7 +21,7 @@ import {
21
21
  } from "@firecms/ui";
22
22
 
23
23
  import { FieldHelperView } from "./properties/FieldHelperView";
24
- import { useFormex, Field, getIn } from "../../form";
24
+ import { useFormex, Field, getIn } from "@firecms/formex";
25
25
 
26
26
  export function CollectionDetailsForm({
27
27
  isNewCollection,
@@ -51,7 +51,7 @@ import { CollectionEditorImportMapping } from "./import/CollectionEditorImportMa
51
51
  import { CollectionEditorImportDataPreview } from "./import/CollectionEditorImportDataPreview";
52
52
  import { cleanPropertiesFromImport } from "./import/clean_import_data";
53
53
  import { PersistedCollection } from "../../types/persisted_collection";
54
- import { Formex, FormexController, useCreateFormex } from "../../form";
54
+ import { Formex, FormexController, useCreateFormex } from "@firecms/formex";
55
55
  import { getFullIdPath } from "./util";
56
56
 
57
57
  export interface CollectionEditorDialogProps {
@@ -536,7 +536,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
536
536
  </Tabs>}
537
537
 
538
538
  <form noValidate
539
- onSubmit={formController.submitForm}
539
+ onSubmit={formController.handleSubmit}
540
540
  className={cn(
541
541
  isNewCollection ? "h-full" : "h-[calc(100%-48px)]",
542
542
  "flex-grow flex flex-col relative")}>
@@ -610,12 +610,10 @@ function CollectionEditorInternal<M extends Record<string, any>>({
610
610
  isNewCollection={isNewCollection}
611
611
  reservedGroups={reservedGroups}
612
612
  onPropertyError={(propertyKey, namespace, error) => {
613
- console.debug("!!!onPropertyError", { propertyKey, namespace, error })
614
613
  const current = removeUndefined({
615
614
  ...propertyErrorsRef.current,
616
615
  [getFullIdPath(propertyKey, namespace)]: removeUndefined(error, true)
617
616
  }, true);
618
- console.debug("aa!!!onPropertyError", { current })
619
617
  propertyErrorsRef.current = current;
620
618
  formController.validate();
621
619
  }}
@@ -7,7 +7,7 @@ import { blogCollectionTemplate } from "./templates/blog_template";
7
7
  import { usersCollectionTemplate } from "./templates/users_template";
8
8
  import { ImportFileUpload } from "@firecms/data_import_export";
9
9
  import { pagesCollectionTemplate } from "./templates/pages_template";
10
- import { useFormex } from "../../form";
10
+ import { useFormex } from "@firecms/formex";
11
11
 
12
12
  export function CollectionEditorWelcomeView({
13
13
  path,
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useEffect, useMemo, useState } from "react";
2
2
 
3
- import { Field, getIn } from "../../form";
3
+ import { Field, getIn } from "@firecms/formex";
4
4
  import {
5
5
  EntityCollection,
6
6
  ErrorBoundary,
@@ -34,7 +34,7 @@ import { OnPropertyChangedParams, PropertyForm, PropertyFormDialog } from "./Pro
34
34
  import { PropertyTree } from "./PropertyTree";
35
35
  import { PersistedCollection } from "../../types/persisted_collection";
36
36
  import { GetCodeDialog } from "./GetCodeDialog";
37
- import { useFormex } from "../../form/Formex";
37
+ import { useFormex } from "@firecms/formex";
38
38
 
39
39
  type CollectionEditorFormProps = {
40
40
  showErrors: boolean;
@@ -19,7 +19,7 @@ import {
19
19
  } from "@firecms/ui";
20
20
  import { FieldHelperView } from "./properties/FieldHelperView";
21
21
  import { extractEnumFromValues } from "@firecms/schema_inference";
22
- import { Field, Formex, getIn, useCreateFormex, useFormex } from "../../form";
22
+ import { Field, Formex, getIn, useCreateFormex, useFormex } from "@firecms/formex";
23
23
 
24
24
  type EnumFormProps = {
25
25
  enumValues: EnumValueConfig[];
@@ -1,7 +1,7 @@
1
1
  import React, { useDeferredValue, useEffect, useRef, useState } from "react";
2
2
  import equal from "react-fast-compare"
3
3
 
4
- import { Formex, FormexController, getIn, useCreateFormex } from "../../form";
4
+ import { Formex, FormexController, getIn, useCreateFormex } from "@firecms/formex";
5
5
  import {
6
6
  DEFAULT_FIELD_CONFIGS,
7
7
  DeleteConfirmationDialog,
@@ -255,10 +255,11 @@ export function PropertyFormDialog({
255
255
  fullWidth={true}
256
256
  >
257
257
  <form noValidate={true}
258
+ autoComplete={"off"}
258
259
  onSubmit={(e) => {
259
260
  e.preventDefault();
260
261
  e.stopPropagation();
261
- formexRef.current?.submitForm(e)
262
+ formexRef.current?.handleSubmit(e)
262
263
  }}>
263
264
  <DialogContent>
264
265
  <PropertyForm {...formProps}
@@ -27,7 +27,7 @@ import { CollectionsConfigController } from "../../types/config_controller";
27
27
  import { PersistedCollection } from "../../types/persisted_collection";
28
28
  import { CollectionInference } from "../../types/collection_inference";
29
29
  import { EntityCustomViewsSelectDialog } from "./EntityCustomViewsSelectDialog";
30
- import { useFormex } from "../../form/Formex";
30
+ import { useFormex } from "@firecms/formex";
31
31
 
32
32
  export function SubcollectionsEditTab({
33
33
  collection,
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
3
  import { BooleanSwitchWithLabel, Tooltip } from "@firecms/ui";
4
- import { FormexFieldProps } from "../../form";
4
+ import { FormexFieldProps } from "@firecms/formex";
5
5
 
6
6
  export function SwitchControl({
7
7
  field,
@@ -4,7 +4,7 @@ import {
4
4
  ImportConfig,
5
5
  ImportNewPropertyFieldPreview
6
6
  } from "@firecms/data_import_export";
7
- import { getIn, useFormex } from "../../../form";
7
+ import { getIn, useFormex } from "@firecms/formex";
8
8
 
9
9
  import { PropertyConfigBadge, getFieldConfig, getFieldId, Properties, Property, PropertyConfig, } from "@firecms/core";
10
10
  import { Container, Select, Tooltip, Typography } from "@firecms/ui";
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback, useState } from "react";
2
2
  import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
3
- import { getIn, useFormex } from "../../../form";
3
+ import { getIn, useFormex } from "@firecms/formex";
4
4
  import { PropertyFormDialog } from "../PropertyEditView";
5
5
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
6
6
  import { PropertyTree } from "../PropertyTree";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Field, FormexFieldProps, getIn, useFormex } from "../../../form";
2
+ import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
3
3
 
4
4
  import { GeneralPropertyValidation } from "./validation/GeneralPropertyValidation";
5
5
  import { ValidationPanel } from "./validation/ValidationPanel";
@@ -1,4 +1,4 @@
1
- import { Field, getIn, useFormex } from "../../../form";
1
+ import { Field, getIn, useFormex } from "@firecms/formex";
2
2
  import { DebouncedTextField } from "@firecms/ui";
3
3
  import { PropertyWithId } from "../PropertyEditView";
4
4
  import React from "react";
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { getIn, useFormex } from "../../../form";
2
+ import { getIn, useFormex } from "@firecms/formex";
3
3
  import { NumberProperty, StringProperty } from "@firecms/core";
4
4
  import { Select, SelectItem } from "@firecms/ui";
5
5
  import { GeneralPropertyValidation } from "./validation/GeneralPropertyValidation";
@@ -1,5 +1,5 @@
1
1
  import React, { useMemo } from "react";
2
- import { getIn, useFormex } from "../../../form";
2
+ import { getIn, useFormex } from "@firecms/formex";
3
3
  import { EnumValueConfig, resolveEnumValues, useSnackbarController } from "@firecms/core";
4
4
  import { Select, SelectItem } from "@firecms/ui";
5
5
  import { EnumForm } from "../EnumForm";
@@ -2,7 +2,7 @@ import React, { useCallback, useState } from "react";
2
2
  import { MapProperty, Property, PropertyConfig, } from "@firecms/core";
3
3
  import { AddIcon, BooleanSwitchWithLabel, Button, Paper, Typography } from "@firecms/ui";
4
4
  import { PropertyFormDialog } from "../PropertyEditView";
5
- import { getIn, useFormex } from "../../../form";
5
+ import { getIn, useFormex } from "@firecms/formex";
6
6
  import { PropertyTree } from "../PropertyTree";
7
7
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
8
8
  import { FieldHelperView } from "./FieldHelperView";
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { NumberPropertyValidation } from "./validation/NumberPropertyValidation";
3
3
  import { ValidationPanel } from "./validation/ValidationPanel";
4
4
  import { TextField } from "@firecms/ui";
5
- import { getIn, useFormex } from "../../../form";
5
+ import { getIn, useFormex } from "@firecms/formex";
6
6
 
7
7
  export function NumberPropertyField({ disabled }: {
8
8
  disabled: boolean;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Field, getIn, useFormex } from "../../../form";
2
+ import { Field, getIn, useFormex } from "@firecms/formex";
3
3
  import { IconForView, NumberProperty, StringProperty, useNavigationController } from "@firecms/core";
4
4
  import { CircularProgress, Select, SelectGroup, SelectItem, Typography, } from "@firecms/ui";
5
5
  import { FieldHelperView } from "./FieldHelperView";
@@ -1,7 +1,7 @@
1
1
  import React, { useCallback, useState } from "react";
2
2
  import { ArrayProperty, getFieldConfig, Property, PropertyConfig } from "@firecms/core";
3
3
  import { Button, Paper, Typography } from "@firecms/ui";
4
- import { Field, getIn, useFormex } from "../../../form";
4
+ import { Field, getIn, useFormex } from "@firecms/formex";
5
5
  import { PropertyFormDialog } from "../PropertyEditView";
6
6
  import { PropertyFieldPreview } from "../PropertyFieldPreview";
7
7
  import { ArrayPropertyValidation } from "./validation/ArrayPropertyValidation";
@@ -10,7 +10,7 @@ import {
10
10
  Typography
11
11
  } from "@firecms/ui";
12
12
 
13
- import { Field, FormexFieldProps, getIn, useFormex } from "../../../form";
13
+ import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
14
14
  import { GeneralPropertyValidation } from "./validation/GeneralPropertyValidation";
15
15
  import { ArrayPropertyValidation } from "./validation/ArrayPropertyValidation";
16
16
  import { ValidationPanel } from "./validation/ValidationPanel";
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { StringPropertyValidation } from "./validation/StringPropertyValidation";
3
3
  import { ValidationPanel } from "./validation/ValidationPanel";
4
- import { getIn, useFormex } from "../../../form";
4
+ import { getIn, useFormex } from "@firecms/formex";
5
5
 
6
6
  import { TextField } from "@firecms/ui";
7
7
 
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { StringPropertyValidation } from "./validation/StringPropertyValidation";
3
3
  import { ValidationPanel } from "./validation/ValidationPanel";
4
- import { getIn, useFormex } from "../../../form";
4
+ import { getIn, useFormex } from "@firecms/formex";
5
5
 
6
6
  import { Select, SelectItem, TextField } from "@firecms/ui";
7
7
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { Field, FormexFieldProps } from "../../../../form";
3
+ import { Field, FormexFieldProps } from "@firecms/formex";
4
4
  import { SwitchControl } from "../../SwitchControl";
5
5
 
6
6
  export function AdvancedPropertyValidation({ disabled }: {
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { getIn, useFormex } from "../../../../form";
3
+ import { getIn, useFormex } from "@firecms/formex";
4
4
  import { DebouncedTextField } from "@firecms/ui";
5
5
  import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { Field, FormexFieldProps, getIn, useFormex } from "../../../../form";
3
+ import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
4
4
  import { DebouncedTextField } from "@firecms/ui";
5
5
  import { SwitchControl } from "../../SwitchControl";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { Field, FormexFieldProps, getIn, useFormex } from "../../../../form";
3
+ import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
4
4
  import { DebouncedTextField } from "@firecms/ui";
5
5
  import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
6
6
  import { SwitchControl } from "../../SwitchControl";
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
- import { Field, FormexFieldProps, getIn, useFormex } from "../../../../form";
4
- import { isValidRegExp, serializeRegExp } from "@firecms/core";
3
+ import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
4
+ import { serializeRegExp } from "@firecms/core";
5
5
  import { DebouncedTextField, } from "@firecms/ui";
6
6
  import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
7
7
  import { FieldHelperView } from "../FieldHelperView";
@@ -86,27 +86,12 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
86
86
  onAnalyticsEvent
87
87
  }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
88
88
 
89
- const injectCollections = (baseCollections: EntityCollection[]) => {
90
-
91
- const markAsEditable = (c: PersistedCollection) => {
92
- makePropertiesEditable(c.properties as Properties);
93
- c.subcollections?.forEach(markAsEditable);
94
- };
95
- const storedCollections = collectionConfigController.collections ?? [];
96
- storedCollections.forEach(markAsEditable);
97
-
98
- console.debug("Collections specified in code:", baseCollections);
99
- console.debug("Collections stored in the backend", storedCollections);
100
- const result = joinCollectionLists(baseCollections, storedCollections, [], modifyCollection);
101
- console.debug("Collections after joining:", result);
102
- return result;
103
- };
89
+
104
90
 
105
91
  return {
106
92
  name: "Collection Editor",
107
93
  loading: collectionConfigController.loading,
108
94
  collections: {
109
- injectCollections,
110
95
  CollectionActions: EditorCollectionAction
111
96
  },
112
97
  provider: {
@@ -1,53 +0,0 @@
1
- import * as React from "react";
2
- import { FormexController } from "./types";
3
- export interface FieldInputProps<Value> {
4
- /** Value of the field */
5
- value: Value;
6
- /** Name of the field */
7
- name: string;
8
- /** Multiple select? */
9
- multiple?: boolean;
10
- /** Is the field checked? */
11
- checked?: boolean;
12
- /** Change event handler */
13
- onChange: (event: React.SyntheticEvent) => void;
14
- /** Blur event handler */
15
- onBlur: (event: React.FocusEvent) => void;
16
- }
17
- export interface FormexFieldProps<Value = any, FormValues extends object = any> {
18
- field: FieldInputProps<Value>;
19
- form: FormexController<FormValues>;
20
- }
21
- export type FieldValidator = (value: any) => string | void | Promise<string | void>;
22
- export interface FieldConfig<V = any, C extends React.ElementType | undefined = undefined> {
23
- /**
24
- * Component to render. Can either be a string e.g. 'select', 'input', or 'textarea', or a component.
25
- */
26
- as?: C | string | React.ForwardRefExoticComponent<any>;
27
- /**
28
- * Children render function <Field name>{props => ...}</Field>)
29
- */
30
- children?: ((props: FormexFieldProps<V>) => React.ReactNode) | React.ReactNode;
31
- /**
32
- * Validate a single field value independently
33
- */
34
- /**
35
- * Used for 'select' and related input types.
36
- */
37
- multiple?: boolean;
38
- /**
39
- * Field name
40
- */
41
- name: string;
42
- /** HTML input type */
43
- type?: string;
44
- /** Field value */
45
- value?: any;
46
- /** Inner ref */
47
- innerRef?: (instance: any) => void;
48
- }
49
- export type FieldProps<T, C extends React.ElementType | undefined> = {
50
- as?: C;
51
- } & (C extends React.ElementType ? (React.ComponentProps<C> & FieldConfig<T, C>) : FieldConfig<T, C>);
52
- export declare function Field<T, C extends React.ElementType | undefined = undefined>({ validate, name, children, as: is, // `as` is reserved in typescript lol
53
- className, ...props }: FieldProps<T, C>): any;
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- import { FormexController } from "./types";
3
- export declare const useFormex: <T extends object>() => FormexController<T>;
4
- export declare const Formex: React.Provider<FormexController<any>>;
@@ -1,5 +0,0 @@
1
- export * from "./Field";
2
- export * from "./Formex";
3
- export * from "./types";
4
- export * from "./utils";
5
- export * from "./useCreateFormex";
@@ -1,25 +0,0 @@
1
- import React, { FormEvent } from "react";
2
- export type FormexController<T extends object> = {
3
- values: T;
4
- setValues: (values: T) => void;
5
- setFieldValue: (key: string, value: any, shouldValidate?: boolean) => void;
6
- touched: Record<string, boolean>;
7
- setFieldTouched: (key: string, touched: boolean, shouldValidate?: boolean) => void;
8
- dirty: boolean;
9
- setDirty: (dirty: boolean) => void;
10
- setSubmitCount: (submitCount: number) => void;
11
- errors: Record<string, string>;
12
- setFieldError: (key: string, error?: string) => void;
13
- handleChange: (event: React.SyntheticEvent) => void;
14
- handleBlur: (event: React.FocusEvent) => void;
15
- submitForm: (event?: FormEvent<HTMLFormElement>) => void;
16
- validate: () => void;
17
- resetForm: (props?: FormexResetProps<T>) => void;
18
- submitCount: number;
19
- isSubmitting: boolean;
20
- };
21
- export type FormexResetProps<T extends object> = {
22
- values?: T;
23
- errors?: Record<string, string>;
24
- touched?: Record<string, boolean>;
25
- };
@@ -1,9 +0,0 @@
1
- import { FormexController } from "./types";
2
- export declare function useCreateFormex<T extends object>({ initialValues, initialErrors, validation, validateOnChange, onSubmit, validateOnInitialRender }: {
3
- initialValues: T;
4
- initialErrors?: Record<string, string>;
5
- validateOnChange?: boolean;
6
- validateOnInitialRender?: boolean;
7
- validation?: (values: T) => Record<string, string>;
8
- onSubmit?: (values: T, controller: FormexController<T>) => void | Promise<void>;
9
- }): FormexController<T>;
@@ -1,44 +0,0 @@
1
- import * as React from "react";
2
- /** @private is the value an empty array? */
3
- export declare const isEmptyArray: (value?: any) => boolean;
4
- /** @private is the given object a Function? */
5
- export declare const isFunction: (obj: any) => obj is Function;
6
- /** @private is the given object an Object? */
7
- export declare const isObject: (obj: any) => obj is Object;
8
- /** @private is the given object an integer? */
9
- export declare const isInteger: (obj: any) => boolean;
10
- /** @private is the given object a string? */
11
- export declare const isString: (obj: any) => obj is string;
12
- /** @private is the given object a NaN? */
13
- export declare const isNaN: (obj: any) => boolean;
14
- /** @private Does a React component have exactly 0 children? */
15
- export declare const isEmptyChildren: (children: any) => boolean;
16
- /** @private is the given object/value a promise? */
17
- export declare const isPromise: (value: any) => value is PromiseLike<any>;
18
- /** @private is the given object/value a type of synthetic event? */
19
- export declare const isInputEvent: (value: any) => value is React.SyntheticEvent<any, Event>;
20
- /**
21
- * Same as document.activeElement but wraps in a try-catch block. In IE it is
22
- * not safe to call document.activeElement if there is nothing focused.
23
- *
24
- * The activeElement will be null only if the document or document body is not
25
- * yet defined.
26
- *
27
- * @param {?Document} doc Defaults to current document.
28
- * @return {Element | null}
29
- * @see https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/dom/getActiveElement.js
30
- */
31
- export declare function getActiveElement(doc?: Document): Element | null;
32
- /**
33
- * Deeply get a value from an object via its path.
34
- */
35
- export declare function getIn(obj: any, key: string | string[], def?: any, p?: number): any;
36
- export declare function setIn(obj: any, path: string, value: any): any;
37
- /**
38
- * Recursively a set the same value for all keys and arrays nested object, cloning
39
- * @param object
40
- * @param value
41
- * @param visited
42
- * @param response
43
- */
44
- export declare function setNestedObjectValues<T>(object: any, value: any, visited?: any, response?: any): T;