@opengeoweb/form-fields 2.0.1

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 (34) hide show
  1. package/README.md +11 -0
  2. package/form-fields.esm.js +802 -0
  3. package/form-fields.umd.js +836 -0
  4. package/index.d.ts +1 -0
  5. package/lib/components/ReactHookFormDateTime.d.ts +13 -0
  6. package/lib/components/ReactHookFormDateTime.spec.d.ts +1 -0
  7. package/lib/components/ReactHookFormDateTime.stories.d.ts +6 -0
  8. package/lib/components/ReactHookFormFormControl.d.ts +8 -0
  9. package/lib/components/ReactHookFormFormControl.spec.d.ts +1 -0
  10. package/lib/components/ReactHookFormHiddenInput.d.ts +8 -0
  11. package/lib/components/ReactHookFormHiddenInput.spec.d.ts +1 -0
  12. package/lib/components/ReactHookFormHiddenInput.stories.d.ts +6 -0
  13. package/lib/components/ReactHookFormNumberField.d.ts +13 -0
  14. package/lib/components/ReactHookFormNumberField.spec.d.ts +1 -0
  15. package/lib/components/ReactHookFormNumberField.stories.d.ts +6 -0
  16. package/lib/components/ReactHookFormProvider.d.ts +20 -0
  17. package/lib/components/ReactHookFormProvider.spec.d.ts +1 -0
  18. package/lib/components/ReactHookFormProvider.stories.d.ts +6 -0
  19. package/lib/components/ReactHookFormRadioGroup.d.ts +10 -0
  20. package/lib/components/ReactHookFormRadioGroup.spec.d.ts +1 -0
  21. package/lib/components/ReactHookFormRadioGroup.stories.d.ts +6 -0
  22. package/lib/components/ReactHookFormSelect.d.ts +9 -0
  23. package/lib/components/ReactHookFormSelect.spec.d.ts +1 -0
  24. package/lib/components/ReactHookFormSelect.stories.d.ts +6 -0
  25. package/lib/components/ReactHookFormTextField.d.ts +10 -0
  26. package/lib/components/ReactHookFormTextField.spec.d.ts +1 -0
  27. package/lib/components/ReactHookFormTextField.stories.d.ts +6 -0
  28. package/lib/components/formUtils.d.ts +3 -0
  29. package/lib/components/formUtils.spec.d.ts +1 -0
  30. package/lib/components/index.d.ts +11 -0
  31. package/lib/components/types.d.ts +9 -0
  32. package/lib/components/utils.d.ts +42 -0
  33. package/lib/components/utils.spec.d.ts +1 -0
  34. package/package.json +27 -0
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/components';
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { KeyboardDateTimePickerProps } from '@material-ui/pickers';
3
+ import { Moment } from 'moment-timezone';
4
+ import { Rules } from './types';
5
+ export declare const getFormattedValue: (value: Moment | string) => string | Moment;
6
+ declare type ReactHookKeyboardDateTimePickerProps = Partial<KeyboardDateTimePickerProps> & {
7
+ rules: Rules;
8
+ defaultNullValue?: string;
9
+ value?: string;
10
+ onChange?: (value: any) => void;
11
+ };
12
+ declare const ReactHookKeyboardDateTimePicker: React.FC<ReactHookKeyboardDateTimePickerProps>;
13
+ export default ReactHookKeyboardDateTimePicker;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const DateTime: () => React.ReactElement;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { FormControlProps } from '@material-ui/core';
3
+ import { FieldErrors } from 'react-hook-form';
4
+ interface ReactHookFormFormControlProps extends FormControlProps {
5
+ errors?: FieldErrors;
6
+ }
7
+ declare const ReactHookFormFormControl: React.FC<ReactHookFormFormControlProps>;
8
+ export default ReactHookFormFormControl;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ interface ReactHookFormHiddenInputProps {
3
+ name: string;
4
+ defaultValue?: unknown;
5
+ rules?: unknown;
6
+ }
7
+ declare const ReactHookFormHiddenInput: React.FC<ReactHookFormHiddenInputProps>;
8
+ export default ReactHookFormHiddenInput;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const HiddenInput: () => React.ReactElement;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { TextFieldProps } from '@material-ui/core';
3
+ import { Rules } from './types';
4
+ declare type InputMode = 'numeric' | 'decimal';
5
+ export declare const convertNumericInputValue: (value: string, inputMode: InputMode) => number | string;
6
+ export declare const parseInput: (value: number | string) => string;
7
+ export declare const getAllowedKeys: (inputMode?: InputMode) => string[];
8
+ declare type ReactHookFormNumberFieldProps = Partial<TextFieldProps> & {
9
+ rules: Rules;
10
+ inputMode?: InputMode;
11
+ };
12
+ declare const ReactHookFormNumberField: React.FC<ReactHookFormNumberFieldProps>;
13
+ export default ReactHookFormNumberField;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const NumberField: () => React.ReactElement;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { UseFormOptions } from 'react-hook-form';
3
+ interface WrapperProps {
4
+ children: React.ReactNode;
5
+ options?: UseFormOptions;
6
+ }
7
+ export declare const defaultFormOptions: Partial<{
8
+ mode: keyof import("react-hook-form").ValidationMode;
9
+ reValidateMode: "onBlur" | "onChange" | "onSubmit";
10
+ defaultValues: {
11
+ [x: string]: any;
12
+ };
13
+ resolver: import("react-hook-form").Resolver<import("react-hook-form").FieldValues, object>;
14
+ context: object;
15
+ shouldFocusError: boolean;
16
+ shouldUnregister: boolean;
17
+ criteriaMode: "all" | "firstError";
18
+ }>;
19
+ declare const ReactHookFormProvider: React.FC<WrapperProps>;
20
+ export default ReactHookFormProvider;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const FormProvider: () => React.ReactElement;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { RadioGroupProps } from '@material-ui/core';
3
+ import { Rules } from './types';
4
+ declare type ReactHookFormRadioGroupProps = Partial<RadioGroupProps> & {
5
+ rules: Rules;
6
+ label?: string;
7
+ disabled?: boolean;
8
+ };
9
+ declare const ReactHookFormRadioGroup: React.FC<ReactHookFormRadioGroupProps>;
10
+ export default ReactHookFormRadioGroup;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const RadioGroup: () => React.ReactElement;
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ import { SelectProps } from '@material-ui/core';
3
+ import { Rules } from './types';
4
+ declare type ReactHookFormSelectProps = Partial<SelectProps> & {
5
+ rules: Rules;
6
+ onChange?: (value: any) => void;
7
+ };
8
+ declare const ReactHookFormSelect: React.FC<ReactHookFormSelectProps>;
9
+ export default ReactHookFormSelect;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const Select: () => React.ReactElement;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { TextFieldProps } from '@material-ui/core';
3
+ import { Rules } from './types';
4
+ export declare const convertTextInputValue: (value: string, inCapitals: boolean) => number | string;
5
+ declare type ReactHookFormTextFieldProps = Partial<TextFieldProps> & {
6
+ rules: Rules;
7
+ upperCase?: boolean;
8
+ };
9
+ declare const ReactHookFormTextField: React.FC<ReactHookFormTextFieldProps>;
10
+ export default ReactHookFormTextField;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const TextField: () => React.ReactElement;
@@ -0,0 +1,3 @@
1
+ import { FieldErrors } from 'react-hook-form';
2
+ export declare function getDeepProperty<I>(p: string[], o: I): I;
3
+ export declare const getErrors: (name: string, errors: FieldErrors) => FieldErrors;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export { default as ReactHookFormSelect } from './ReactHookFormSelect';
2
+ export { default as ReactHookFormRadioGroup } from './ReactHookFormRadioGroup';
3
+ export { default as ReactHookFormTextField } from './ReactHookFormTextField';
4
+ export { default as ReactHookFormNumberField } from './ReactHookFormNumberField';
5
+ export { default as ReactHookFormFormControl } from './ReactHookFormFormControl';
6
+ export { default as ReactHookFormDateTime } from './ReactHookFormDateTime';
7
+ export { default as ReactHookFormProvider } from './ReactHookFormProvider';
8
+ export { default as ReactHookFormHiddenInput } from './ReactHookFormHiddenInput';
9
+ export { defaultFormOptions } from './ReactHookFormProvider';
10
+ export { errorMessages, isMaximumOneDrawing, isGeometryDirty, isValidGeoJsonCoordinates, hasIntersectionWithFIR, isValidMax, isValidMin, isInteger, isAfter, isBefore, isBetween, isValidDate, hasMaxFeaturePoints, hasMulitpleIntersections, isXHoursBefore, isXHoursAfter, isLatitude, isLongitude, isNonOrBothCoordinates, containsNoCommas, isEmpty, } from './utils';
11
+ export { getDeepProperty } from './formUtils';
@@ -0,0 +1,9 @@
1
+ import { FormControlProps } from '@material-ui/core';
2
+ import { RegisterOptions } from 'react-hook-form';
3
+ export declare type Rules = RegisterOptions;
4
+ export interface ReactHookFormInput extends FormControlProps {
5
+ name: string;
6
+ label?: string;
7
+ rules?: Rules;
8
+ helperText?: string;
9
+ }
@@ -0,0 +1,42 @@
1
+ import { Moment } from 'moment';
2
+ export declare const errorMessages: {
3
+ required: string;
4
+ isValidDate: string;
5
+ isAfter: string;
6
+ isXHoursBefore: string;
7
+ isXHoursAfter: string;
8
+ isBefore: string;
9
+ minLevel: string;
10
+ isLatitude: string;
11
+ isLongitude: string;
12
+ isValidMax: string;
13
+ isLevelLower: string;
14
+ isNonOrBothCoordinates: string;
15
+ isInteger: string;
16
+ isNumeric: string;
17
+ containsNoCommas: string;
18
+ minVisibility: string;
19
+ maxVisibility: string;
20
+ };
21
+ export declare const isEmpty: (value: number | string) => boolean;
22
+ export declare const isValidDate: (value: Moment | string) => boolean;
23
+ export declare const isBefore: (ownDate: string, referenceDate: string) => boolean;
24
+ export declare const isAfter: (ownDate: string, otherDate: string) => boolean;
25
+ export declare const isBetween: (ownDate: string, otherDateStart: string, otherDateEnd: string) => boolean;
26
+ export declare const isXHoursBefore: (ownDate: string, otherDate: string, hours?: number) => boolean;
27
+ export declare const isXHoursAfter: (ownDate: string, otherDate: string, hours?: number) => boolean;
28
+ export declare const isLatitude: (lat: number) => boolean;
29
+ export declare const isLongitude: (lng: number) => boolean;
30
+ export declare const isValidMax: (value: number, maxValue: number) => boolean;
31
+ export declare const isValidMin: (value: number, minValue: number) => boolean;
32
+ export declare const hasValidGeometry: (geojson: GeoJSON.FeatureCollection) => boolean;
33
+ export declare const isValidGeoJsonCoordinates: (geojson: GeoJSON.FeatureCollection) => boolean;
34
+ export declare const isMaximumOneDrawing: (geojson: GeoJSON.FeatureCollection) => boolean;
35
+ export declare const hasIntersectionWithFIR: (geojson: GeoJSON.FeatureCollection, intersection: GeoJSON.FeatureCollection) => boolean;
36
+ export declare const hasMaxFeaturePoints: (geojson: GeoJSON.FeatureCollection, maxPoints?: number) => boolean;
37
+ export declare const hasMulitpleIntersections: (geojson: GeoJSON.FeatureCollection) => boolean;
38
+ export declare const isGeometryDirty: (geoJSON: GeoJSON.FeatureCollection, formGeoJSON: GeoJSON.FeatureCollection) => boolean;
39
+ export declare const isInteger: (value: number) => boolean;
40
+ export declare const isNumeric: (value: any) => boolean;
41
+ export declare const isNonOrBothCoordinates: (coordinate: number, otherCoordinate: number) => boolean;
42
+ export declare const containsNoCommas: (val: string | number) => boolean;
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@opengeoweb/form-fields",
3
+ "version": "2.0.1",
4
+ "description": "GeoWeb form-fields library for the opengeoweb project",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
+ },
10
+ "main": "./form-fields.umd.js",
11
+ "module": "./form-fields.esm.js",
12
+ "typings": "./index.d.ts",
13
+ "dependencies": {},
14
+ "peerDependencies": {
15
+ "react-hook-form": "^6.12.1",
16
+ "react": "16.14.0",
17
+ "@material-ui/core": "^4.11.0",
18
+ "@material-ui/pickers": "^3.2.10",
19
+ "@date-io/moment": "^1.3.13",
20
+ "moment": "^2.29.0",
21
+ "@opengeoweb/theme": "2.0.1",
22
+ "@material-ui/lab": "^4.0.0-alpha.56",
23
+ "@material-ui/icons": "^4.9.1",
24
+ "moment-timezone": "^0.5.31",
25
+ "lodash": "^4.17.20"
26
+ }
27
+ }