envoc-form 4.0.1-1 → 4.0.1-11
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 +2 -2
- package/es/AddressInput/AddressInput.d.ts +5 -5
- package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/es/DatePicker/DatePickerGroup.d.ts +3 -2
- package/es/DatePicker/DatePickerGroup.js +27 -5
- package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +5 -0
- package/es/DatePicker/{DateOnlyDatePickerGroup.js → StringDateOnlyPickerGroup.js} +7 -6
- package/es/DatePicker/StringDatePickerGroup.d.ts +1 -1
- package/es/Field/Field.d.ts +3 -3
- package/es/Field/Field.js +9 -4
- package/es/FieldArray/FieldArray.d.ts +2 -2
- package/es/FieldArray/FieldArray.js +10 -7
- package/es/File/FileGroup.d.ts +1 -1
- package/es/File/FileGroup.js +5 -3
- package/es/File/FileList.d.ts +2 -2
- package/es/File/FileList.js +2 -1
- package/es/Form/Form.d.ts +8 -3
- package/es/Form/Form.js +32 -3
- package/es/Form/FormBasedPreventNavigation.js +31 -14
- package/es/FormActions.js +5 -1
- package/es/FormDefaults.d.ts +3 -0
- package/es/FormDefaults.js +1 -0
- package/es/Group.d.ts +2 -1
- package/es/Group.js +8 -5
- package/es/Input/IconInputGroup.d.ts +1 -1
- package/es/Input/IconInputGroup.js +3 -1
- package/es/Input/InputGroup.d.ts +3 -3
- package/es/Input/InputGroup.js +3 -2
- package/es/Input/MoneyInputGroup.d.ts +1 -1
- package/es/Input/MoneyInputGroup.js +2 -1
- package/es/Input/NumberInputGroup.d.ts +1 -1
- package/es/Input/NumberInputGroup.js +2 -1
- package/es/Input/StringInputGroup.d.ts +1 -1
- package/es/Input/StringInputGroup.js +3 -1
- package/es/Normalization/normalizers.d.ts +2 -2
- package/es/Select/BooleanSelectGroup.d.ts +1 -1
- package/es/Select/NumberSelectGroup.d.ts +2 -2
- package/es/Select/SelectGroup.d.ts +2 -2
- package/es/Select/SelectGroup.js +8 -3
- package/es/StandardFormActions.js +2 -1
- package/es/SubmitFormButton.d.ts +1 -1
- package/es/SubmitFormButton.js +4 -2
- package/es/TextArea/TextAreaGroup.d.ts +1 -1
- package/es/TextArea/TextAreaGroup.js +4 -2
- package/es/Validation/validators.d.ts +8 -8
- package/es/Validation/validators.js +3 -0
- package/es/__Tests__/FormTestBase.d.ts +3 -3
- package/es/__Tests__/FormTestBase.js +1 -1
- package/es/index.d.ts +8 -6
- package/es/index.js +4 -1
- package/lib/AddressInput/AddressInput.d.ts +5 -5
- package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +3 -1
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +3 -2
- package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +2 -1
- package/lib/DatePicker/DatePickerGroup.d.ts +3 -2
- package/lib/DatePicker/DatePickerGroup.js +28 -4
- package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +5 -0
- package/lib/DatePicker/{DateOnlyDatePickerGroup.js → StringDateOnlyPickerGroup.js} +8 -7
- package/lib/DatePicker/StringDatePickerGroup.d.ts +1 -1
- package/lib/Field/Field.d.ts +3 -3
- package/lib/Field/Field.js +9 -4
- package/lib/FieldArray/FieldArray.d.ts +2 -2
- package/lib/FieldArray/FieldArray.js +10 -7
- package/lib/File/FileGroup.d.ts +1 -1
- package/lib/File/FileGroup.js +5 -3
- package/lib/File/FileList.d.ts +2 -2
- package/lib/File/FileList.js +2 -1
- package/lib/Form/Form.d.ts +8 -3
- package/lib/Form/Form.js +32 -3
- package/lib/Form/FormBasedPreventNavigation.js +31 -14
- package/lib/FormActions.js +5 -1
- package/lib/FormDefaults.d.ts +3 -0
- package/lib/FormDefaults.js +4 -0
- package/lib/Group.d.ts +2 -1
- package/lib/Group.js +8 -5
- package/lib/Input/IconInputGroup.d.ts +1 -1
- package/lib/Input/IconInputGroup.js +3 -1
- package/lib/Input/InputGroup.d.ts +3 -3
- package/lib/Input/InputGroup.js +3 -2
- package/lib/Input/MoneyInputGroup.d.ts +1 -1
- package/lib/Input/MoneyInputGroup.js +2 -1
- package/lib/Input/NumberInputGroup.d.ts +1 -1
- package/lib/Input/NumberInputGroup.js +2 -1
- package/lib/Input/StringInputGroup.d.ts +1 -1
- package/lib/Input/StringInputGroup.js +3 -1
- package/lib/Normalization/normalizers.d.ts +2 -2
- package/lib/Select/BooleanSelectGroup.d.ts +1 -1
- package/lib/Select/NumberSelectGroup.d.ts +2 -2
- package/lib/Select/SelectGroup.d.ts +2 -2
- package/lib/Select/SelectGroup.js +8 -3
- package/lib/StandardFormActions.js +2 -1
- package/lib/SubmitFormButton.d.ts +1 -1
- package/lib/SubmitFormButton.js +4 -2
- package/lib/TextArea/TextAreaGroup.d.ts +1 -1
- package/lib/TextArea/TextAreaGroup.js +4 -2
- package/lib/Validation/validators.d.ts +8 -8
- package/lib/Validation/validators.js +3 -0
- package/lib/__Tests__/FormTestBase.d.ts +3 -3
- package/lib/__Tests__/FormTestBase.js +2 -2
- package/lib/index.d.ts +8 -6
- package/lib/index.js +8 -3
- package/package.json +4 -2
- package/src/AddressInput/AddressInput.tsx +5 -5
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +15 -10
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +13 -3
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +3 -3
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +8 -1
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +2 -2
- package/src/DatePicker/DatePicker.test.tsx +3 -3
- package/src/DatePicker/DatePickerGroup.tsx +45 -8
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +23 -0
- package/src/DatePicker/StringDatePickerGroup.tsx +1 -1
- package/src/DatePicker/__snapshots__/DatePicker.test.tsx.snap +3 -2
- package/src/Field/Field.tsx +22 -7
- package/src/FieldArray/FieldArray.tsx +25 -13
- package/src/File/FileGroup.tsx +15 -3
- package/src/File/FileList.tsx +5 -3
- package/src/File/__snapshots__/FileGroup.test.tsx.snap +5 -3
- package/src/Form/Form.tsx +56 -4
- package/src/Form/FormBasedPreventNavigation.tsx +34 -18
- package/src/Form/__snapshots__/Form.test.tsx.snap +1 -0
- package/src/FormActions.tsx +8 -2
- package/src/FormDefaults.ts +1 -0
- package/src/Group.tsx +21 -6
- package/src/Input/IconInputGroup.tsx +7 -4
- package/src/Input/InputGroup.tsx +18 -5
- package/src/Input/MoneyInputGroup.tsx +6 -2
- package/src/Input/NumberInputGroup.tsx +6 -2
- package/src/Input/StringInputGroup.tsx +7 -3
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +4 -2
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +4 -2
- package/src/Normalization/normalizers.ts +2 -2
- package/src/Select/BooleanSelectGroup.tsx +1 -1
- package/src/Select/NumberSelectGroup.tsx +2 -2
- package/src/Select/SelectGroup.tsx +16 -4
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +3 -2
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +6 -4
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +6 -4
- package/src/StandardFormActions.tsx +4 -1
- package/src/SubmitFormButton.tsx +9 -2
- package/src/TextArea/TextAreaGroup.tsx +13 -4
- package/src/Validation/validators.ts +16 -12
- package/src/__Tests__/FormTestBase.tsx +4 -4
- package/src/__Tests__/__snapshots__/StandardFormActions.test.tsx.snap +4 -2
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.tsx.snap +3 -1
- package/src/index.ts +11 -10
- package/es/DatePicker/DateOnlyDatePickerGroup.d.ts +0 -10
- package/lib/DatePicker/DateOnlyDatePickerGroup.d.ts +0 -10
- package/src/DatePicker/DateOnlyDatePickerGroup.tsx +0 -24
package/es/Input/InputGroup.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import React, { ChangeEventHandler, LegacyRef } from 'react';
|
2
2
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
3
3
|
import { GroupProps } from '../Group';
|
4
|
-
export interface InputGroupProps<TValue> extends InjectedFieldProps<TValue>, Omit<React.HTMLProps<HTMLInputElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
4
|
+
export interface InputGroupProps<TValue> extends InjectedFieldProps<TValue>, Omit<React.HTMLProps<HTMLInputElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label' | 'value'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
5
5
|
onChange: ChangeEventHandler<HTMLInputElement>;
|
6
|
-
value: string | number;
|
6
|
+
value: string | number | null | undefined;
|
7
7
|
icon?: React.ReactNode;
|
8
8
|
}
|
9
9
|
/** generic controlled <input/> wrapped by a Group */
|
10
|
-
declare function InputGroup<TValue>({ input, meta, label, helpText, className, disabled, onChange, value, icon, ...rest }: InputGroupProps<TValue>, ref: LegacyRef<HTMLInputElement>): JSX.Element;
|
10
|
+
declare function InputGroup<TValue>({ input, meta, label, helpText, className, required, disabled, onChange, value, icon, ...rest }: InputGroupProps<TValue>, ref: LegacyRef<HTMLInputElement>): JSX.Element;
|
11
11
|
declare const InputGroupWithRef: typeof InputGroup;
|
12
12
|
export default InputGroupWithRef;
|
package/es/Input/InputGroup.js
CHANGED
@@ -23,11 +23,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
|
+
import { FormDefaults } from '../FormDefaults';
|
26
27
|
import Group from '../Group';
|
27
28
|
/** generic controlled <input/> wrapped by a Group */
|
28
29
|
function InputGroup(_a, ref) {
|
29
|
-
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, disabled = _a.disabled, onChange = _a.onChange, value = _a.value, icon = _a.icon, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "disabled", "onChange", "value", "icon"]);
|
30
|
-
return (_jsxs(Group, __assign({ input: input, meta: meta, disabled: disabled, label: label, helpText: helpText, className: classNames(className, 'input-group') }, { children: [icon, _jsx("input", __assign({}, input, rest, { value: value, onChange: onChange, ref: ref, className: classNames(className, 'input-group') }))] })));
|
30
|
+
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, onChange = _a.onChange, value = _a.value, icon = _a.icon, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "onChange", "value", "icon"]);
|
31
|
+
return (_jsxs(Group, __assign({ input: input, meta: meta, required: required, disabled: disabled, label: label, helpText: helpText, className: classNames(className, FormDefaults.cssClassPrefix + 'input-group') }, { children: [icon, _jsx("input", __assign({}, input, rest, { value: value !== null && value !== void 0 ? value : '', onChange: onChange, ref: ref, className: classNames(className, FormDefaults.cssClassPrefix + 'input-group') }))] })));
|
31
32
|
}
|
32
33
|
var InputGroupWithRef = React.forwardRef(InputGroup);
|
33
34
|
export default InputGroupWithRef;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InputGroupProps } from './InputGroup';
|
3
|
-
export interface MoneyInputGroupProps extends Omit<InputGroupProps<number | undefined>, 'onChange' | 'type' | 'value'> {
|
3
|
+
export interface MoneyInputGroupProps extends Omit<InputGroupProps<number | undefined | null>, 'onChange' | 'type' | 'value'> {
|
4
4
|
parseFunc?: typeof parseInt | typeof parseFloat;
|
5
5
|
}
|
6
6
|
declare const MoneyInputGroupWithRef: React.FunctionComponent<MoneyInputGroupProps>;
|
@@ -24,11 +24,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
26
|
import InputGroup from './InputGroup';
|
27
|
+
import { FormDefaults } from '../FormDefaults';
|
27
28
|
function MoneyInputGroup(_a, ref) {
|
28
29
|
var parseFunc = _a.parseFunc, className = _a.className, rest = __rest(_a, ["parseFunc", "className"]);
|
29
30
|
var effectiveParse = parseFunc !== null && parseFunc !== void 0 ? parseFunc : parseFloat;
|
30
31
|
var input = rest.input;
|
31
|
-
return (_jsx(InputGroup, __assign({ ref: ref, step: 0.01, min: 0 }, rest, { type: "number", className: classNames(className, 'money-group'), value: input.value || '', onChange: function (e) {
|
32
|
+
return (_jsx(InputGroup, __assign({ ref: ref, step: 0.01, min: 0 }, rest, { type: "number", className: classNames(className, FormDefaults.cssClassPrefix + 'money-group'), value: input.value || '', onChange: function (e) {
|
32
33
|
if (!e.target.value) {
|
33
34
|
input.onChange(undefined);
|
34
35
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InputGroupProps } from './InputGroup';
|
3
|
-
export interface NumberInputGroupProps extends Omit<InputGroupProps<number | undefined>, 'onChange' | 'type' | 'value'> {
|
3
|
+
export interface NumberInputGroupProps extends Omit<InputGroupProps<number | undefined | null>, 'onChange' | 'type' | 'value'> {
|
4
4
|
parseFunc?: typeof parseInt | typeof parseFloat;
|
5
5
|
}
|
6
6
|
declare const NumberInputGroupWithRef: React.ComponentType<NumberInputGroupProps>;
|
@@ -24,11 +24,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
26
|
import InputGroup from './InputGroup';
|
27
|
+
import { FormDefaults } from '../FormDefaults';
|
27
28
|
function NumberInputGroup(_a, ref) {
|
28
29
|
var parseFunc = _a.parseFunc, className = _a.className, rest = __rest(_a, ["parseFunc", "className"]);
|
29
30
|
var effectiveParse = parseFunc !== null && parseFunc !== void 0 ? parseFunc : parseFloat;
|
30
31
|
var input = rest.input;
|
31
|
-
return (_jsx(InputGroup, __assign({ ref: ref }, rest, { type: "number", className: classNames(className, 'number-group'), value: input.value || '', onChange: function (e) {
|
32
|
+
return (_jsx(InputGroup, __assign({ ref: ref }, rest, { type: "number", className: classNames(className, FormDefaults.cssClassPrefix + 'number-group'), value: input.value || '', onChange: function (e) {
|
32
33
|
if (!e.target.value) {
|
33
34
|
input.onChange(undefined);
|
34
35
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InputGroupProps } from './InputGroup';
|
3
|
-
export interface StringInputGroupProps extends Omit<InputGroupProps<string | undefined>, 'onChange' | 'type' | 'value'> {
|
3
|
+
export interface StringInputGroupProps extends Omit<InputGroupProps<string | undefined | null>, 'onChange' | 'type' | 'value'> {
|
4
4
|
type?: 'color' | 'email' | 'search' | 'tel' | 'text' | 'url' | 'password' | 'textarea';
|
5
5
|
}
|
6
6
|
declare const StringInputGroupWithRef: React.ComponentType<StringInputGroupProps>;
|
@@ -24,10 +24,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
26
|
import InputGroup from './InputGroup';
|
27
|
+
import { FormDefaults } from '../FormDefaults';
|
27
28
|
function StringInputGroup(_a, ref) {
|
29
|
+
var _b;
|
28
30
|
var className = _a.className, rest = __rest(_a, ["className"]);
|
29
31
|
var input = rest.input;
|
30
|
-
return (_jsx(InputGroup, __assign({ ref: ref }, rest, { className: classNames(className, 'string-group'), value: input.value
|
32
|
+
return (_jsx(InputGroup, __assign({ ref: ref }, rest, { className: classNames(className, FormDefaults.cssClassPrefix + 'string-group'), value: (_b = input.value) !== null && _b !== void 0 ? _b : '', onChange: function (e) {
|
31
33
|
if (!e.target.value) {
|
32
34
|
input.onChange(undefined);
|
33
35
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const phoneNumber: (value: string | undefined) => string | undefined;
|
2
|
-
export declare const zipCode: (value: string | undefined) => string | undefined;
|
1
|
+
export declare const phoneNumber: (value: string | undefined | null) => string | undefined;
|
2
|
+
export declare const zipCode: (value: string | undefined | null) => string | undefined;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { SelectOption } from './SelectGroup';
|
3
3
|
import { SelectGroupPropsHelper } from './SelectGroupPropsHelper';
|
4
|
-
export interface BooleanSelectGroupProps extends Omit<SelectGroupPropsHelper<boolean>, 'options'> {
|
4
|
+
export interface BooleanSelectGroupProps extends Omit<SelectGroupPropsHelper<boolean | undefined | null>, 'options'> {
|
5
5
|
options?: SelectOption<boolean>[];
|
6
6
|
}
|
7
7
|
export declare function BooleanSelectGroup(props: BooleanSelectGroupProps): JSX.Element;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { SelectGroupPropsHelper } from './SelectGroupPropsHelper';
|
3
|
-
export interface MultiNumberSelectGroupProps extends SelectGroupPropsHelper<number[]> {
|
3
|
+
export interface MultiNumberSelectGroupProps extends SelectGroupPropsHelper<number[] | undefined | null> {
|
4
4
|
}
|
5
5
|
export declare function MultiNumberSelectGroup(props: MultiNumberSelectGroupProps): JSX.Element;
|
6
|
-
export interface SingleNumberSelectGroupProps extends SelectGroupPropsHelper<number> {
|
6
|
+
export interface SingleNumberSelectGroupProps extends SelectGroupPropsHelper<number | undefined | null> {
|
7
7
|
}
|
8
8
|
export declare function SingleNumberSelectGroup(props: SingleNumberSelectGroupProps): JSX.Element;
|
@@ -13,10 +13,10 @@ interface OptionsUseServiceResult<TValue> {
|
|
13
13
|
resp?: Partial<SelectOption<TValue>>[] | OptionsApiResult<TValue> | null;
|
14
14
|
error?: any;
|
15
15
|
}
|
16
|
-
export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
|
16
|
+
export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined | null>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
|
17
17
|
options: SelectOption<TValue>[] | OptionsUseServiceResult<TValue>;
|
18
18
|
multiple: TValue extends Array<any> ? true : false;
|
19
19
|
placeholder?: string;
|
20
20
|
}
|
21
|
-
export default function SelectGroup<TValue>({ input, meta, className, options, multiple, placeholder, ...rest }: SelectGroupProps<TValue>): JSX.Element;
|
21
|
+
export default function SelectGroup<TValue>({ input, meta, className, required, disabled, options, multiple, placeholder, ...rest }: SelectGroupProps<TValue>): JSX.Element;
|
22
22
|
export {};
|
package/es/Select/SelectGroup.js
CHANGED
@@ -23,10 +23,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
24
|
import { default as ReactSelect } from 'react-select';
|
25
25
|
import classNames from 'classnames';
|
26
|
+
import { FormDefaults } from '../FormDefaults';
|
26
27
|
import Group from '../Group';
|
27
28
|
// TODO: we could also name this "ReactSelectGroup" or similar but the types are strongly defined now so kept the names consistent
|
28
29
|
export default function SelectGroup(_a) {
|
29
|
-
var
|
30
|
+
var _b;
|
31
|
+
var input = _a.input, meta = _a.meta, className = _a.className, required = _a.required, disabled = _a.disabled, options = _a.options, multiple = _a.multiple, placeholder = _a.placeholder, rest = __rest(_a, ["input", "meta", "className", "required", "disabled", "options", "multiple", "placeholder"]);
|
30
32
|
var effectiveOptions = !options
|
31
33
|
? []
|
32
34
|
: Array.isArray(options)
|
@@ -40,14 +42,17 @@ export default function SelectGroup(_a) {
|
|
40
42
|
? options.resp
|
41
43
|
: [];
|
42
44
|
var isLoading = (options && 'loading' in options && options.loading) || false;
|
43
|
-
return (_jsx(Group, __assign({}, rest, { input: input, meta: meta,
|
45
|
+
return (_jsx(Group, __assign({}, rest, { input: input, meta: meta, required: required, disabled: disabled, className: classNames(className, (_b = {},
|
46
|
+
_b[FormDefaults.cssClassPrefix + 'multiple'] = multiple,
|
47
|
+
_b[FormDefaults.cssClassPrefix + 'loading'] = isLoading,
|
48
|
+
_b), FormDefaults.cssClassPrefix + 'select-group') }, { children: _jsx(ReactSelect, { inputId: input.id, isMulti: multiple, isDisabled: disabled, options: effectiveOptions, onBlur: input.onBlur, value: getValue(), onChange: function (e) {
|
44
49
|
if (multiple === true) {
|
45
50
|
input.onChange(e === null || e === void 0 ? void 0 : e.map(function (x) { return x.value; }));
|
46
51
|
}
|
47
52
|
else {
|
48
53
|
input.onChange(e === null || e === void 0 ? void 0 : e.value);
|
49
54
|
}
|
50
|
-
}, getOptionLabel: function (option) { var _a; return (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : ''; }, className: classNames(className, 'select-group'), classNamePrefix: "react-select", menuPortalTarget: document.body, menuPlacement: "auto", placeholder: placeholder }) })));
|
55
|
+
}, getOptionLabel: function (option) { var _a; return (_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : ''; }, className: classNames(className, FormDefaults.cssClassPrefix + 'select-group'), classNamePrefix: "react-select", menuPortalTarget: document.body, menuPlacement: "auto", placeholder: placeholder }) })));
|
51
56
|
function getValue() {
|
52
57
|
if (multiple) {
|
53
58
|
return effectiveOptions.filter(function (o) {
|
@@ -13,10 +13,11 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
13
13
|
import classNames from 'classnames';
|
14
14
|
import { useFormikContext } from 'formik';
|
15
15
|
import SubmitFormButton from './SubmitFormButton';
|
16
|
+
import { FormDefaults } from './FormDefaults';
|
16
17
|
export default function StandardFormActions(_a) {
|
17
18
|
var allowPristineSubmit = _a.allowPristineSubmit, handleCancel = _a.handleCancel;
|
18
19
|
var isSubmitting = useFormikContext().isSubmitting;
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsx(SubmitFormButton, { allowPristineSubmit: allowPristineSubmit }), "\u00A0", _jsx("button", __assign({ className: classNames('standard-form-actions-cancel-button'), type: "button", disabled: isSubmitting, onClick: handleCancel || goBack }, { children: "Cancel" }))] }));
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx(SubmitFormButton, { allowPristineSubmit: allowPristineSubmit }), "\u00A0", _jsx("button", __assign({ className: classNames(FormDefaults.cssClassPrefix + 'standard-form-actions-cancel-button'), type: "button", disabled: isSubmitting, onClick: handleCancel || goBack }, { children: "Cancel" }))] }));
|
20
21
|
function goBack() {
|
21
22
|
window.history.back();
|
22
23
|
}
|
package/es/SubmitFormButton.d.ts
CHANGED
@@ -3,5 +3,5 @@ export interface SubmitFormButtonProps extends Omit<React.HTMLProps<HTMLButtonEl
|
|
3
3
|
allowPristineSubmit?: boolean;
|
4
4
|
children?: React.ReactNode;
|
5
5
|
}
|
6
|
-
declare const _default: React.
|
6
|
+
declare const _default: React.FunctionComponent<SubmitFormButtonProps>;
|
7
7
|
export default _default;
|
package/es/SubmitFormButton.js
CHANGED
@@ -24,14 +24,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
26
|
import { useFormikContext } from 'formik';
|
27
|
+
import { FormDefaults } from './FormDefaults';
|
27
28
|
function SubmitFormButton(_a, ref) {
|
28
29
|
var allowPristineSubmit = _a.allowPristineSubmit, children = _a.children, disabled = _a.disabled, title = _a.title, className = _a.className, props = __rest(_a, ["allowPristineSubmit", "children", "disabled", "title", "className"]);
|
29
30
|
var _b = useFormikContext(), isSubmitting = _b.isSubmitting, dirty = _b.dirty;
|
30
31
|
var preventSubmit = (!dirty && !allowPristineSubmit) || isSubmitting;
|
31
|
-
|
32
|
+
var buttonName = typeof children === 'string' ? children : 'Submit';
|
33
|
+
return (_jsx("button", __assign({}, props, { ref: ref, type: "submit", disabled: preventSubmit || disabled, "aria-label": buttonName, title: title || isSubmitting
|
32
34
|
? 'Loading, please wait...'
|
33
35
|
: preventSubmit
|
34
36
|
? "You haven't made any changes"
|
35
|
-
: '', className: classNames('submit-form-button', className) }, { children: children || 'Submit' })));
|
37
|
+
: '', className: classNames(FormDefaults.cssClassPrefix + 'submit-form-button', className) }, { children: children || 'Submit' })));
|
36
38
|
}
|
37
39
|
export default React.forwardRef(SubmitFormButton);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
3
3
|
import { GroupProps } from '../Group';
|
4
|
-
export interface TextAreaGroupProps extends InjectedFieldProps<string | undefined>, Omit<React.HTMLProps<HTMLTextAreaElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
4
|
+
export interface TextAreaGroupProps extends InjectedFieldProps<string | undefined | null>, Omit<React.HTMLProps<HTMLTextAreaElement>, keyof InjectedFieldProps<any> | 'children' | 'className' | 'label'>, Omit<GroupProps, keyof InjectedFieldProps<any> | 'children'> {
|
5
5
|
icon?: React.ReactNode;
|
6
6
|
}
|
7
7
|
declare const TextAreaGroupWithRef: React.ComponentType<TextAreaGroupProps>;
|
@@ -23,11 +23,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
24
24
|
import React from 'react';
|
25
25
|
import classNames from 'classnames';
|
26
|
+
import { FormDefaults } from '../FormDefaults';
|
26
27
|
import Group from '../Group';
|
27
28
|
/** generic controlled <textarea/> wrapped by a Group */
|
28
29
|
function TextAreaGroup(_a, ref) {
|
29
|
-
var
|
30
|
-
|
30
|
+
var _b;
|
31
|
+
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, icon = _a.icon, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "icon"]);
|
32
|
+
return (_jsxs(Group, __assign({ input: input, meta: meta, required: required, disabled: disabled, label: label, helpText: helpText, className: classNames(className, FormDefaults.cssClassPrefix + 'text-area-group') }, { children: [icon, _jsx("textarea", __assign({}, input, rest, { value: (_b = input.value) !== null && _b !== void 0 ? _b : '', onChange: function (val) { return input.onChange(val.target.value); }, ref: ref, className: classNames(className, FormDefaults.cssClassPrefix + 'text-area-group') }))] })));
|
31
33
|
}
|
32
34
|
var TextAreaGroupWithRef = React.forwardRef(TextAreaGroup);
|
33
35
|
export default TextAreaGroupWithRef;
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import { ValidationFunction } from './ValidationFunction';
|
2
2
|
export declare const required: (value: any) => "Required" | undefined;
|
3
|
-
export declare const length: (len: number) => (value: string | number | undefined) => string | undefined;
|
4
|
-
export declare const integer: (val: string | number | undefined) => "Must be a whole number" | undefined;
|
5
|
-
export declare const maxLength: (len: number) => (value: string | number | undefined) => string | undefined;
|
3
|
+
export declare const length: (len: number) => (value: string | number | undefined | null) => string | undefined;
|
4
|
+
export declare const integer: (val: string | number | undefined | null) => "Must be a whole number" | undefined;
|
5
|
+
export declare const maxLength: (len: number) => (value: string | number | undefined | null) => string | undefined;
|
6
6
|
export declare const maxCount: (count: number) => (value: {
|
7
7
|
isDeleted?: boolean;
|
8
|
-
}[] | undefined) => string | undefined;
|
8
|
+
}[] | undefined | null) => string | undefined;
|
9
9
|
export declare const minCount: (count: number) => (value: {
|
10
10
|
isDeleted?: boolean;
|
11
|
-
}[] | undefined) => string | undefined;
|
12
|
-
export declare const maxValue: (max: number) => (value: number | undefined) => string | undefined;
|
13
|
-
export declare const minValue: (min: number) => (value: number | undefined) => string | undefined;
|
14
|
-
export declare const zipCode: (value: string | undefined) => "Invalid ZIP Code" | undefined;
|
11
|
+
}[] | undefined | null) => string | undefined;
|
12
|
+
export declare const maxValue: (max: number) => (value: number | undefined | null) => string | undefined;
|
13
|
+
export declare const minValue: (min: number) => (value: number | undefined | null) => string | undefined;
|
14
|
+
export declare const zipCode: (value: string | undefined | null) => "Invalid ZIP Code" | undefined;
|
15
15
|
export declare const any: <TValue>(validatorList: ValidationFunction<TValue>[]) => (value: TValue) => string | undefined;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
3
|
-
import {
|
3
|
+
import { FormBuilderProp } from '../';
|
4
4
|
interface FormTestBaseProps<TForm extends object> {
|
5
5
|
children: (formBuilder: FormBuilderProp<TForm>) => JSX.Element;
|
6
6
|
initialValues?: TForm;
|
@@ -13,8 +13,8 @@ interface PersonDto {
|
|
13
13
|
phoneNumber?: string;
|
14
14
|
yearlySalaryUSD?: number;
|
15
15
|
isCool?: boolean;
|
16
|
-
gradDate?:
|
17
|
-
favoriteDate?:
|
16
|
+
gradDate?: string;
|
17
|
+
favoriteDate?: string;
|
18
18
|
favoriteNumber?: number;
|
19
19
|
favoriteColor?: string;
|
20
20
|
favoriteColors?: string[];
|
@@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
48
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
49
49
|
import '@testing-library/jest-dom/extend-expect';
|
50
50
|
import { HashRouter } from 'react-router-dom';
|
51
|
-
import { Form } from '
|
51
|
+
import { Form } from '../';
|
52
52
|
export default function FormTestBase(_a) {
|
53
53
|
var children = _a.children, initialValues = _a.initialValues;
|
54
54
|
return (_jsx(HashRouter, { children: _jsx(Form, __assign({ onSubmit: onSubmit, initialValues: initialValues }, { children: children })) }));
|
package/es/index.d.ts
CHANGED
@@ -7,12 +7,13 @@ export type { ConfirmBaseFormProps } from './ConfirmBaseForm/ConfirmBaseForm';
|
|
7
7
|
export { default as ConfirmDeleteForm } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
8
8
|
export type { ConfirmDeleteFormProps } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
9
9
|
export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
|
10
|
-
export type { DatePickerGroupProps
|
10
|
+
export type { DatePickerGroupProps } from './DatePicker/DatePickerGroup';
|
11
|
+
export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
|
11
12
|
export type { DatePickerHelper } from './DatePicker/DatePickerHelper';
|
12
|
-
export { default as DateOnlyDatePickerGroup } from './DatePicker/DateOnlyDatePickerGroup';
|
13
|
-
export type { DateOnly, DateOnlyDatePickerGroupProps, } from './DatePicker/DateOnlyDatePickerGroup';
|
14
13
|
export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
|
15
14
|
export type { StringDatePickerGroupProps } from './DatePicker/StringDatePickerGroup';
|
15
|
+
export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
|
16
|
+
export type { StringDateOnlyPickerGroupProps } from './DatePicker/StringDateOnlyPickerGroup';
|
16
17
|
export { default as Field } from './Field/Field';
|
17
18
|
export type { FieldProps } from './Field/Field';
|
18
19
|
export type { RenderComponent } from './Field/Field';
|
@@ -33,11 +34,12 @@ export type { FormBuilderProp, FormProps } from './Form/Form';
|
|
33
34
|
export { ServerErrorContext } from './Form/ServerErrorContext';
|
34
35
|
export type { ServerErrorContextProps, ServerErrors, } from './Form/ServerErrorContext';
|
35
36
|
export { default as FormActions } from './FormActions';
|
36
|
-
export type { FormActionsProps
|
37
|
+
export type { FormActionsProps } from './FormActions';
|
37
38
|
export { default as StandardFormActions } from './StandardFormActions';
|
38
|
-
export type { StandardFormActionsProps
|
39
|
+
export type { StandardFormActionsProps } from './StandardFormActions';
|
40
|
+
export { FormDefaults } from './FormDefaults';
|
39
41
|
export { default as Group } from './Group';
|
40
|
-
export type { GroupProps
|
42
|
+
export type { GroupProps } from './Group';
|
41
43
|
export { default as IconInputGroup } from './Input/IconInputGroup';
|
42
44
|
export type { IconInputGroupProps } from './Input/IconInputGroup';
|
43
45
|
export { default as InputGroup } from './Input/InputGroup';
|
package/es/index.js
CHANGED
@@ -8,8 +8,9 @@ export { default as ConfirmBaseForm } from './ConfirmBaseForm/ConfirmBaseForm';
|
|
8
8
|
export { default as ConfirmDeleteForm } from './ConfirmDeleteForm/ConfirmDeleteForm';
|
9
9
|
// Date
|
10
10
|
export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
|
11
|
-
export {
|
11
|
+
export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
|
12
12
|
export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
|
13
|
+
export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
|
13
14
|
// Field
|
14
15
|
export { default as Field } from './Field/Field';
|
15
16
|
export { default as FieldErrorScrollTarget } from './Field/FieldErrorScrollTarget';
|
@@ -25,6 +26,8 @@ export { default as Form } from './Form/Form';
|
|
25
26
|
export { ServerErrorContext } from './Form/ServerErrorContext';
|
26
27
|
export { default as FormActions } from './FormActions';
|
27
28
|
export { default as StandardFormActions } from './StandardFormActions';
|
29
|
+
// FormDefaults
|
30
|
+
export { FormDefaults } from './FormDefaults';
|
28
31
|
// Input
|
29
32
|
export { default as Group } from './Group';
|
30
33
|
export { default as IconInputGroup } from './Input/IconInputGroup';
|
@@ -5,11 +5,11 @@ export interface AddressInputProps {
|
|
5
5
|
name: string;
|
6
6
|
}
|
7
7
|
interface AddressDto {
|
8
|
-
address1?: string;
|
9
|
-
address2?: string;
|
10
|
-
zipCode?: string;
|
11
|
-
city?: string;
|
12
|
-
state?: string;
|
8
|
+
address1?: string | null;
|
9
|
+
address2?: string | null;
|
10
|
+
zipCode?: string | null;
|
11
|
+
city?: string | null;
|
12
|
+
state?: string | null;
|
13
13
|
}
|
14
14
|
export default function AddressInput({ fieldBuilder: { Field }, name, }: AddressInputProps): JSX.Element;
|
15
15
|
export {};
|
@@ -5,6 +5,8 @@ export interface ConfirmBaseFormProps {
|
|
5
5
|
request: useAxiosRequestProps;
|
6
6
|
style?: React.CSSProperties;
|
7
7
|
title?: string;
|
8
|
+
confirmButtonText?: string;
|
9
|
+
confirmButtonClass?: string;
|
8
10
|
children?: React.ReactNode;
|
9
11
|
}
|
10
|
-
export default function ConfirmBaseForm({ handleCancel, request, style, title, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
12
|
+
export default function ConfirmBaseForm({ handleCancel, request, style, title, confirmButtonText, confirmButtonClass, children, ...props }: ConfirmBaseFormProps): JSX.Element;
|
@@ -28,12 +28,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
29
|
var classnames_1 = __importDefault(require("classnames"));
|
30
30
|
var envoc_request_1 = require("envoc-request");
|
31
|
+
var FormDefaults_1 = require("../FormDefaults");
|
31
32
|
// TODO: ask about how we should use 'children'
|
32
33
|
function ConfirmBaseForm(_a) {
|
33
|
-
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "children"]);
|
34
|
+
var handleCancel = _a.handleCancel, request = _a.request, style = _a.style, title = _a.title, confirmButtonText = _a.confirmButtonText, confirmButtonClass = _a.confirmButtonClass, children = _a.children, props = __rest(_a, ["handleCancel", "request", "style", "title", "confirmButtonText", "confirmButtonClass", "children"]);
|
34
35
|
var webRequest = (0, envoc_request_1.useAxiosRequest)(Object.assign({}, request, { autoExecute: false }));
|
35
36
|
var onCancel = handleCancel !== null && handleCancel !== void 0 ? handleCancel : goBack;
|
36
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [(0, jsx_runtime_1.jsx)("h3", { children: title }), children, (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)('confirm-base-form-
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: __assign({ textAlign: 'center' }, style) }, props, { children: [(0, jsx_runtime_1.jsx)("h3", { children: title }), children, (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(confirmButtonClass !== null && confirmButtonClass !== void 0 ? confirmButtonClass : FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-base-form-confirm-button'), type: "button", onClick: webRequest.submitRequest }, { children: confirmButtonText !== null && confirmButtonText !== void 0 ? confirmButtonText : 'Confirm' })), (0, jsx_runtime_1.jsx)("button", __assign({ className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-base-form-cancel-button'), type: "button", onClick: onCancel }, { children: "Cancel" }))] })));
|
37
38
|
function goBack() {
|
38
39
|
window.history.back();
|
39
40
|
}
|
@@ -29,6 +29,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
29
|
var react_router_dom_1 = require("react-router-dom");
|
30
30
|
var react_toastify_1 = require("react-toastify");
|
31
31
|
var ConfirmBaseForm_1 = __importDefault(require("../ConfirmBaseForm/ConfirmBaseForm"));
|
32
|
+
var FormDefaults_1 = require("../FormDefaults");
|
32
33
|
function ConfirmDeleteForm(_a) {
|
33
34
|
var successUrl = _a.successUrl, form = _a.form, title = _a.title, handleComplete = _a.handleComplete, handleError = _a.handleError, children = _a.children, props = __rest(_a, ["successUrl", "form", "title", "handleComplete", "handleError", "children"]);
|
34
35
|
var navigate = (0, react_router_dom_1.useNavigate)();
|
@@ -47,7 +48,7 @@ function ConfirmDeleteForm(_a) {
|
|
47
48
|
onComplete: onComplete,
|
48
49
|
onError: onError,
|
49
50
|
};
|
50
|
-
return ((0, jsx_runtime_1.jsx)(ConfirmBaseForm_1.default, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?' }, props, { children: children })));
|
51
|
+
return ((0, jsx_runtime_1.jsx)(ConfirmBaseForm_1.default, __assign({ request: request, handleCancel: goBack, title: title !== null && title !== void 0 ? title : 'Are you sure you want to delete this?', confirmButtonText: "Yes", confirmButtonClass: FormDefaults_1.FormDefaults.cssClassPrefix + 'confirm-delete-form-yes-button' }, props, { children: children })));
|
51
52
|
function goBack() {
|
52
53
|
if (successUrl) {
|
53
54
|
navigate(successUrl);
|
@@ -2,7 +2,8 @@
|
|
2
2
|
import { DatePickerProps } from 'react-date-picker/dist/entry.nostyle';
|
3
3
|
import { InjectedFieldProps } from '../Field/InjectedFieldProps';
|
4
4
|
import { GroupProps } from '../Group';
|
5
|
-
export interface DatePickerGroupProps<T> extends InjectedFieldProps<T | undefined>, Omit<DatePickerProps, keyof InjectedFieldProps<T> | 'name' | 'value' | 'className'>, Omit<GroupProps, keyof InjectedFieldProps<T> | 'children'> {
|
5
|
+
export interface DatePickerGroupProps<T> extends InjectedFieldProps<T | undefined | null>, Omit<DatePickerProps, keyof InjectedFieldProps<T> | 'name' | 'value' | 'className'>, Omit<GroupProps, keyof InjectedFieldProps<T> | 'children'> {
|
6
6
|
convert: (arg: Date) => T;
|
7
7
|
}
|
8
|
-
export default function DatePickerGroup<T>({ input, meta, label, helpText, className, disabled, convert, ...rest }: DatePickerGroupProps<T>): JSX.Element;
|
8
|
+
export default function DatePickerGroup<T>({ input, meta, label, helpText, className, required, disabled, convert, ...rest }: DatePickerGroupProps<T>): JSX.Element;
|
9
|
+
export declare function convertToTimeZoneInsensitiveISOString(date: Date): string;
|
@@ -25,16 +25,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
26
26
|
};
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
28
|
+
exports.convertToTimeZoneInsensitiveISOString = void 0;
|
28
29
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
29
30
|
var react_1 = require("react");
|
30
31
|
var entry_nostyle_1 = __importDefault(require("react-date-picker/dist/entry.nostyle"));
|
31
32
|
var classnames_1 = __importDefault(require("classnames"));
|
32
33
|
var parseISO_1 = __importDefault(require("date-fns/parseISO"));
|
34
|
+
var FormDefaults_1 = require("../FormDefaults");
|
33
35
|
var Group_1 = __importDefault(require("../Group"));
|
34
36
|
function DatePickerGroup(_a) {
|
35
|
-
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, disabled = _a.disabled, convert = _a.convert, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "disabled", "convert"]);
|
37
|
+
var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, required = _a.required, disabled = _a.disabled, convert = _a.convert, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "convert"]);
|
36
38
|
var _b = (0, react_1.useState)(null), displayDate = _b[0], setDisplayDate = _b[1];
|
37
|
-
|
39
|
+
(0, react_1.useEffect)(function () {
|
40
|
+
if (!input.value) {
|
41
|
+
setDisplayDate(null);
|
42
|
+
}
|
43
|
+
else if (typeof input.value === 'string') {
|
44
|
+
if (input.value.indexOf('T') === -1) {
|
45
|
+
setDisplayDate(new Date("".concat(input.value, "T00:00:00.000")));
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
setDisplayDate(new Date(input.value));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}, [setDisplayDate, input.value]);
|
52
|
+
return ((0, jsx_runtime_1.jsx)(Group_1.default, __assign({ input: input, meta: meta, label: label, helpText: helpText, className: (0, classnames_1.default)(className, FormDefaults_1.FormDefaults.cssClassPrefix + 'date-picker'), required: required, disabled: disabled }, { children: (0, jsx_runtime_1.jsx)(entry_nostyle_1.default, __assign({}, rest, { className: (0, classnames_1.default)(FormDefaults_1.FormDefaults.cssClassPrefix + 'date-picker', className), value: displayDate, onChange: handleChange })) })));
|
38
53
|
function handleChange(e) {
|
39
54
|
var onChange = input.onChange;
|
40
55
|
if (onChange === null) {
|
@@ -51,16 +66,25 @@ function DatePickerGroup(_a) {
|
|
51
66
|
onChange(convert(parsedValue));
|
52
67
|
}
|
53
68
|
else if (e instanceof Date) {
|
54
|
-
var parsedValue = (0, parseISO_1.default)(e
|
69
|
+
var parsedValue = (0, parseISO_1.default)(convertToTimeZoneInsensitiveISOString(e).split('T')[0]);
|
55
70
|
setDisplayDate(parsedValue);
|
56
71
|
onChange(convert(parsedValue));
|
57
72
|
}
|
58
73
|
else {
|
59
74
|
// e is instanceof Date[]
|
60
|
-
var parsedValue = (0, parseISO_1.default)(e[0]
|
75
|
+
var parsedValue = (0, parseISO_1.default)(convertToTimeZoneInsensitiveISOString(e[0]).split('T')[0]);
|
61
76
|
setDisplayDate(parsedValue);
|
62
77
|
onChange(convert(parsedValue));
|
63
78
|
}
|
64
79
|
}
|
65
80
|
}
|
66
81
|
exports.default = DatePickerGroup;
|
82
|
+
function convertToTimeZoneInsensitiveISOString(date) {
|
83
|
+
var year = new Intl.DateTimeFormat('en', { year: 'numeric' })
|
84
|
+
.format(date)
|
85
|
+
.padStart(4, '0');
|
86
|
+
var month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date);
|
87
|
+
var day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date);
|
88
|
+
return "".concat(year, "-").concat(month, "-").concat(day, "T00:00:00.000Z");
|
89
|
+
}
|
90
|
+
exports.convertToTimeZoneInsensitiveISOString = convertToTimeZoneInsensitiveISOString;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { DatePickerHelper } from './DatePickerHelper';
|
3
|
+
export interface StringDateOnlyPickerGroupProps extends DatePickerHelper<string | undefined | null> {
|
4
|
+
}
|
5
|
+
export default function StringDatePickerGroup(props: StringDateOnlyPickerGroupProps): JSX.Element;
|
@@ -16,14 +16,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
18
18
|
var DatePickerGroup_1 = __importDefault(require("./DatePickerGroup"));
|
19
|
-
function
|
19
|
+
function StringDatePickerGroup(props) {
|
20
20
|
return (0, jsx_runtime_1.jsx)(DatePickerGroup_1.default, __assign({}, props, { convert: convertToDateOnly }));
|
21
21
|
}
|
22
|
-
exports.default =
|
22
|
+
exports.default = StringDatePickerGroup;
|
23
23
|
function convertToDateOnly(arg) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
};
|
24
|
+
var year = new Intl.DateTimeFormat('en', { year: 'numeric' })
|
25
|
+
.format(arg)
|
26
|
+
.padStart(4, '0');
|
27
|
+
var month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(arg);
|
28
|
+
var day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(arg);
|
29
|
+
return "".concat(year, "-").concat(month, "-").concat(day);
|
29
30
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { DatePickerHelper } from './DatePickerHelper';
|
3
|
-
export interface StringDatePickerGroupProps extends DatePickerHelper<string | undefined> {
|
3
|
+
export interface StringDatePickerGroupProps extends DatePickerHelper<string | undefined | null> {
|
4
4
|
}
|
5
5
|
export default function StringDatePickerGroup(props: StringDatePickerGroupProps): JSX.Element;
|
package/lib/Field/Field.d.ts
CHANGED
@@ -2,8 +2,8 @@ import { ComponentProps, ElementType, LegacyRef } from 'react';
|
|
2
2
|
import { InjectedFieldProps } from './InjectedFieldProps';
|
3
3
|
import { NormalizationFunction } from '../Normalization/NormalizationFunction';
|
4
4
|
import { ValidationFunction } from '../Validation/ValidationFunction';
|
5
|
-
export declare type RenderComponent<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue>> ? TRenderComponent : never;
|
6
|
-
export declare type RenderComponentProps<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue>> ? ComponentProps<TRenderComponent> : never;
|
5
|
+
export declare type RenderComponent<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue | undefined | null>> ? TRenderComponent : never;
|
6
|
+
export declare type RenderComponentProps<TValue, TRenderComponent extends ElementType> = Partial<ComponentProps<TRenderComponent>> extends Partial<InjectedFieldProps<TValue | undefined | null>> ? ComponentProps<TRenderComponent> : never;
|
7
7
|
/** A specific Field instance to be rendered by the given TRenderComponent or by whatever default is reasonable */
|
8
8
|
export declare type FieldProps<TForm extends object, TProp extends keyof TForm, TRenderComponent extends ElementType> = {
|
9
9
|
name: TProp;
|
@@ -17,6 +17,6 @@ export declare type FieldProps<TForm extends object, TProp extends keyof TForm,
|
|
17
17
|
* Renders whatever Component is passed - injecting the formik values needed to finish wiring up that individual field.
|
18
18
|
* Should no Component be used then the default will be provided by the default lookup based on typeof(TForm[TProp])
|
19
19
|
*/
|
20
|
-
declare function Field<TForm extends object, TProp extends keyof TForm, TRenderComponent extends ElementType>({ name, Component, id,
|
20
|
+
declare function Field<TForm extends object, TProp extends keyof TForm, TRenderComponent extends ElementType>({ name, Component, id, disabled, validate, normalize, ...rest }: FieldProps<TForm, TProp, TRenderComponent>, ref: LegacyRef<any>): JSX.Element;
|
21
21
|
declare const _default: typeof Field;
|
22
22
|
export default _default;
|