envoc-form 4.0.1-9 → 4.2.0

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 (239) hide show
  1. package/README.md +9443 -12
  2. package/es/AddressInput/AddressInput.d.ts +15 -5
  3. package/es/AddressInput/AddressInput.js +10 -0
  4. package/es/ConfirmBaseForm/ConfirmBaseForm.d.ts +14 -0
  5. package/es/ConfirmBaseForm/ConfirmBaseForm.js +6 -0
  6. package/es/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +13 -0
  7. package/es/ConfirmDeleteForm/ConfirmDeleteForm.js +5 -0
  8. package/es/DatePicker/DatePickerGroup.d.ts +7 -2
  9. package/es/DatePicker/DatePickerGroup.js +18 -7
  10. package/es/DatePicker/StringDateOnlyPickerGroup.d.ts +6 -1
  11. package/es/DatePicker/StringDateOnlyPickerGroup.js +5 -0
  12. package/es/DatePicker/StringDatePickerGroup.d.ts +6 -1
  13. package/es/DatePicker/StringDatePickerGroup.js +5 -0
  14. package/es/DateTimePicker/DateTimePickerGroup.d.ts +13 -0
  15. package/es/DateTimePicker/DateTimePickerGroup.js +87 -0
  16. package/es/DateTimePicker/DateTimePickerHelper.d.ts +3 -0
  17. package/es/DateTimePicker/DateTimePickerHelper.js +1 -0
  18. package/es/DateTimePicker/StringDateTimePickerGroup.d.ts +10 -0
  19. package/es/DateTimePicker/StringDateTimePickerGroup.js +53 -0
  20. package/es/Field/Field.d.ts +9 -3
  21. package/es/Field/Field.js +9 -4
  22. package/es/Field/FieldErrorScrollTarget.d.ts +1 -0
  23. package/es/Field/FieldErrorScrollTarget.js +1 -0
  24. package/es/Field/StandAloneInput.d.ts +4 -0
  25. package/es/Field/StandAloneInput.js +1 -0
  26. package/es/Field/useStandardField.d.ts +6 -0
  27. package/es/Field/useStandardField.js +8 -9
  28. package/es/FieldArray/FieldArray.d.ts +11 -2
  29. package/es/FieldArray/FieldArray.js +7 -2
  30. package/es/File/FileGroup.d.ts +3 -1
  31. package/es/File/FileGroup.js +4 -3
  32. package/es/File/FileList.d.ts +2 -2
  33. package/es/Form/FocusError.d.ts +2 -0
  34. package/es/Form/FocusError.js +1 -0
  35. package/es/Form/Form.d.ts +6 -0
  36. package/es/Form/Form.js +1 -0
  37. package/es/Form/FormBasedPreventNavigation.d.ts +3 -1
  38. package/es/Form/FormBasedPreventNavigation.js +12 -45
  39. package/es/Form/LegacyFormBasedPreventNavigation.d.ts +17 -0
  40. package/es/Form/LegacyFormBasedPreventNavigation.js +69 -0
  41. package/es/Form/NewFormBasedPreventNavigation.d.ts +14 -0
  42. package/es/Form/NewFormBasedPreventNavigation.js +39 -0
  43. package/es/Form/ServerErrorContext.d.ts +1 -0
  44. package/es/Form/ServerErrorContext.js +1 -0
  45. package/es/FormActions.d.ts +6 -0
  46. package/es/FormActions.js +1 -0
  47. package/es/FormDefaults.d.ts +1 -0
  48. package/es/FormDefaults.js +1 -0
  49. package/es/Group.d.ts +7 -4
  50. package/es/Group.js +4 -3
  51. package/es/Input/IconInputGroup.d.ts +4 -1
  52. package/es/Input/IconInputGroup.js +3 -1
  53. package/es/Input/InputGroup.d.ts +4 -4
  54. package/es/Input/InputGroup.js +4 -4
  55. package/es/Input/MoneyInputGroup.d.ts +3 -1
  56. package/es/Input/MoneyInputGroup.js +1 -0
  57. package/es/Input/NumberInputGroup.d.ts +3 -1
  58. package/es/Input/NumberInputGroup.js +1 -0
  59. package/es/Input/PhoneNumberInputGroup.d.ts +10 -0
  60. package/es/Input/PhoneNumberInputGroup.js +47 -0
  61. package/es/Input/StringInputGroup.d.ts +2 -1
  62. package/es/Input/StringInputGroup.js +3 -1
  63. package/es/Normalization/normalizers.d.ts +4 -2
  64. package/es/Normalization/normalizers.js +2 -0
  65. package/es/Select/BooleanSelectGroup.d.ts +2 -1
  66. package/es/Select/BooleanSelectGroup.js +1 -0
  67. package/es/Select/NumberSelectGroup.d.ts +4 -2
  68. package/es/Select/NumberSelectGroup.js +2 -0
  69. package/es/Select/SelectGroup.d.ts +8 -2
  70. package/es/Select/SelectGroup.js +5 -4
  71. package/es/Select/StringSelectGroup.d.ts +2 -0
  72. package/es/Select/StringSelectGroup.js +2 -0
  73. package/es/StandardFormActions.d.ts +5 -0
  74. package/es/StandardFormActions.js +1 -0
  75. package/es/SubmitFormButton.d.ts +4 -1
  76. package/es/SubmitFormButton.js +1 -0
  77. package/es/TextArea/TextAreaGroup.d.ts +2 -1
  78. package/es/TextArea/TextAreaGroup.js +5 -4
  79. package/es/Validation/validators.d.ts +11 -8
  80. package/es/Validation/validators.js +6 -2
  81. package/es/hooks/index.d.ts +2 -0
  82. package/es/hooks/index.js +2 -0
  83. package/es/hooks/useFormValue.d.ts +2 -0
  84. package/es/hooks/useFormValue.js +7 -0
  85. package/es/index.d.ts +10 -4
  86. package/es/index.js +4 -0
  87. package/es/setupTests.d.ts +1 -0
  88. package/es/setupTests.js +1 -0
  89. package/lib/AddressInput/AddressInput.d.ts +15 -5
  90. package/lib/AddressInput/AddressInput.js +10 -0
  91. package/lib/ConfirmBaseForm/ConfirmBaseForm.d.ts +14 -0
  92. package/lib/ConfirmBaseForm/ConfirmBaseForm.js +6 -0
  93. package/lib/ConfirmDeleteForm/ConfirmDeleteForm.d.ts +13 -0
  94. package/lib/ConfirmDeleteForm/ConfirmDeleteForm.js +5 -0
  95. package/lib/DatePicker/DatePickerGroup.d.ts +7 -2
  96. package/lib/DatePicker/DatePickerGroup.js +18 -7
  97. package/lib/DatePicker/StringDateOnlyPickerGroup.d.ts +6 -1
  98. package/lib/DatePicker/StringDateOnlyPickerGroup.js +5 -0
  99. package/lib/DatePicker/StringDatePickerGroup.d.ts +6 -1
  100. package/lib/DatePicker/StringDatePickerGroup.js +5 -0
  101. package/lib/DateTimePicker/DateTimePickerGroup.d.ts +13 -0
  102. package/lib/DateTimePicker/DateTimePickerGroup.js +93 -0
  103. package/lib/DateTimePicker/DateTimePickerHelper.d.ts +3 -0
  104. package/lib/DateTimePicker/DateTimePickerHelper.js +2 -0
  105. package/lib/DateTimePicker/StringDateTimePickerGroup.d.ts +10 -0
  106. package/lib/DateTimePicker/StringDateTimePickerGroup.js +59 -0
  107. package/lib/Field/Field.d.ts +9 -3
  108. package/lib/Field/Field.js +9 -4
  109. package/lib/Field/FieldErrorScrollTarget.d.ts +1 -0
  110. package/lib/Field/FieldErrorScrollTarget.js +1 -0
  111. package/lib/Field/StandAloneInput.d.ts +4 -0
  112. package/lib/Field/StandAloneInput.js +1 -0
  113. package/lib/Field/useStandardField.d.ts +6 -0
  114. package/lib/Field/useStandardField.js +8 -9
  115. package/lib/FieldArray/FieldArray.d.ts +11 -2
  116. package/lib/FieldArray/FieldArray.js +7 -2
  117. package/lib/File/FileGroup.d.ts +3 -1
  118. package/lib/File/FileGroup.js +4 -3
  119. package/lib/File/FileList.d.ts +2 -2
  120. package/lib/Form/FocusError.d.ts +2 -0
  121. package/lib/Form/FocusError.js +1 -0
  122. package/lib/Form/Form.d.ts +6 -0
  123. package/lib/Form/Form.js +1 -0
  124. package/lib/Form/FormBasedPreventNavigation.d.ts +3 -1
  125. package/lib/Form/FormBasedPreventNavigation.js +13 -43
  126. package/lib/Form/LegacyFormBasedPreventNavigation.d.ts +17 -0
  127. package/lib/Form/LegacyFormBasedPreventNavigation.js +72 -0
  128. package/lib/Form/NewFormBasedPreventNavigation.d.ts +14 -0
  129. package/lib/Form/NewFormBasedPreventNavigation.js +42 -0
  130. package/lib/Form/ServerErrorContext.d.ts +1 -0
  131. package/lib/Form/ServerErrorContext.js +1 -0
  132. package/lib/FormActions.d.ts +6 -0
  133. package/lib/FormActions.js +1 -0
  134. package/lib/FormDefaults.d.ts +1 -0
  135. package/lib/FormDefaults.js +1 -0
  136. package/lib/Group.d.ts +7 -4
  137. package/lib/Group.js +4 -3
  138. package/lib/Input/IconInputGroup.d.ts +4 -1
  139. package/lib/Input/IconInputGroup.js +3 -1
  140. package/lib/Input/InputGroup.d.ts +4 -4
  141. package/lib/Input/InputGroup.js +4 -4
  142. package/lib/Input/MoneyInputGroup.d.ts +3 -1
  143. package/lib/Input/MoneyInputGroup.js +1 -0
  144. package/lib/Input/NumberInputGroup.d.ts +3 -1
  145. package/lib/Input/NumberInputGroup.js +1 -0
  146. package/lib/Input/PhoneNumberInputGroup.d.ts +10 -0
  147. package/lib/Input/PhoneNumberInputGroup.js +52 -0
  148. package/lib/Input/StringInputGroup.d.ts +2 -1
  149. package/lib/Input/StringInputGroup.js +3 -1
  150. package/lib/Normalization/normalizers.d.ts +4 -2
  151. package/lib/Normalization/normalizers.js +2 -0
  152. package/lib/Select/BooleanSelectGroup.d.ts +2 -1
  153. package/lib/Select/BooleanSelectGroup.js +1 -0
  154. package/lib/Select/NumberSelectGroup.d.ts +4 -2
  155. package/lib/Select/NumberSelectGroup.js +2 -0
  156. package/lib/Select/SelectGroup.d.ts +8 -2
  157. package/lib/Select/SelectGroup.js +5 -4
  158. package/lib/Select/StringSelectGroup.d.ts +2 -0
  159. package/lib/Select/StringSelectGroup.js +2 -0
  160. package/lib/StandardFormActions.d.ts +5 -0
  161. package/lib/StandardFormActions.js +1 -0
  162. package/lib/SubmitFormButton.d.ts +4 -1
  163. package/lib/SubmitFormButton.js +1 -0
  164. package/lib/TextArea/TextAreaGroup.d.ts +2 -1
  165. package/lib/TextArea/TextAreaGroup.js +5 -4
  166. package/lib/Validation/validators.d.ts +11 -8
  167. package/lib/Validation/validators.js +6 -2
  168. package/lib/hooks/index.d.ts +2 -0
  169. package/lib/{__Tests__ → hooks}/index.js +3 -3
  170. package/lib/hooks/useFormValue.d.ts +2 -0
  171. package/lib/hooks/useFormValue.js +10 -0
  172. package/lib/index.d.ts +10 -4
  173. package/lib/index.js +8 -1
  174. package/lib/setupTests.d.ts +1 -0
  175. package/lib/setupTests.js +3 -0
  176. package/package.json +12 -8
  177. package/src/AddressInput/AddressInput.tsx +15 -5
  178. package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +8 -4
  179. package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +14 -0
  180. package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +13 -0
  181. package/src/DatePicker/DatePicker.test.tsx +1 -1
  182. package/src/DatePicker/DatePickerGroup.tsx +23 -7
  183. package/src/DatePicker/StringDateOnlyPickerGroup.tsx +7 -2
  184. package/src/DatePicker/StringDatePickerGroup.tsx +7 -1
  185. package/src/DateTimePicker/DateTimePicker.test.tsx +243 -0
  186. package/src/DateTimePicker/DateTimePickerGroup.tsx +116 -0
  187. package/src/DateTimePicker/DateTimePickerHelper.ts +4 -0
  188. package/src/DateTimePicker/StringDateTimePickerGroup.tsx +61 -0
  189. package/src/DateTimePicker/__snapshots__/DateTimePicker.test.tsx.snap +216 -0
  190. package/src/Field/Field.tsx +20 -7
  191. package/src/Field/FieldErrorScrollTarget.tsx +1 -0
  192. package/src/Field/StandAloneInput.tsx +4 -0
  193. package/src/Field/useStandardField.ts +13 -9
  194. package/src/FieldArray/FieldArray.tsx +14 -5
  195. package/src/File/FileGroup.tsx +9 -3
  196. package/src/File/FileList.tsx +2 -2
  197. package/src/Form/FocusError.tsx +3 -0
  198. package/src/Form/Form.tsx +6 -0
  199. package/src/Form/FormBasedPreventNavigation.tsx +28 -46
  200. package/src/Form/LegacyFormBasedPreventNavigation.tsx +77 -0
  201. package/src/Form/NewFormBasedPreventNavigation.tsx +59 -0
  202. package/src/Form/ServerErrorContext.ts +1 -0
  203. package/src/FormActions.tsx +7 -0
  204. package/src/FormDefaults.ts +1 -0
  205. package/src/Group.tsx +12 -4
  206. package/src/Input/IconInputGroup.tsx +5 -2
  207. package/src/Input/InputGroup.tsx +13 -5
  208. package/src/Input/MoneyInputGroup.tsx +3 -1
  209. package/src/Input/NumberInputGroup.tsx +3 -1
  210. package/src/Input/PhoneNumberInputGroup.tsx +49 -0
  211. package/src/Input/StringInputGroup.tsx +3 -2
  212. package/src/Input/__Tests__/PhoneNumberInputGroup.test.tsx +37 -0
  213. package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +1 -0
  214. package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +1 -0
  215. package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +1 -0
  216. package/src/Input/__Tests__/__snapshots__/PhoneNumberInputGroup.test.tsx.snap +33 -0
  217. package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +1 -0
  218. package/src/Normalization/normalizers.ts +4 -2
  219. package/src/Select/BooleanSelectGroup.tsx +2 -1
  220. package/src/Select/NumberSelectGroup.tsx +4 -2
  221. package/src/Select/SelectGroup.tsx +13 -2
  222. package/src/Select/StringSelectGroup.tsx +2 -0
  223. package/src/StandardFormActions.tsx +5 -0
  224. package/src/SubmitFormButton.tsx +5 -1
  225. package/src/TextArea/TextAreaGroup.tsx +6 -4
  226. package/src/Validation/validators.ts +19 -14
  227. package/src/__Tests__/FormTestBase.tsx +10 -8
  228. package/src/__Tests__/RealisticForm.test.tsx +82 -0
  229. package/src/hooks/index.ts +3 -0
  230. package/src/hooks/useFormValue.ts +16 -0
  231. package/src/index.ts +14 -4
  232. package/src/setupTests.ts +1 -0
  233. package/es/__Tests__/FormTestBase.d.ts +0 -27
  234. package/es/__Tests__/FormTestBase.js +0 -83
  235. package/es/__Tests__/index.d.ts +0 -2
  236. package/es/__Tests__/index.js +0 -2
  237. package/lib/__Tests__/FormTestBase.d.ts +0 -27
  238. package/lib/__Tests__/FormTestBase.js +0 -86
  239. package/lib/__Tests__/index.d.ts +0 -2
@@ -26,9 +26,10 @@ import classNames from 'classnames';
26
26
  import InputGroup from './InputGroup';
27
27
  import { FormDefaults } from '../FormDefaults';
28
28
  function StringInputGroup(_a, ref) {
29
+ var _b;
29
30
  var className = _a.className, rest = __rest(_a, ["className"]);
30
31
  var input = rest.input;
31
- return (_jsx(InputGroup, __assign({ ref: ref }, rest, { className: classNames(className, FormDefaults.cssClassPrefix + 'string-group'), value: input.value || '', onChange: function (e) {
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) {
32
33
  if (!e.target.value) {
33
34
  input.onChange(undefined);
34
35
  }
@@ -37,5 +38,6 @@ function StringInputGroup(_a, ref) {
37
38
  }
38
39
  } })));
39
40
  }
41
+ /** Standard string input group. */
40
42
  var StringInputGroupWithRef = React.forwardRef(StringInputGroup);
41
43
  export default StringInputGroupWithRef;
@@ -1,2 +1,4 @@
1
- export declare const phoneNumber: (value: string | undefined) => string | undefined;
2
- export declare const zipCode: (value: string | undefined) => string | undefined;
1
+ /** Normalizer for converting a string into a valid phone number. */
2
+ export declare const phoneNumber: (value: string | undefined | null) => string | undefined;
3
+ /** Normalizer for converting a string into a valid zip code. Allows for XXXXX and XXXXX-XXXX format. */
4
+ export declare const zipCode: (value: string | undefined | null) => string | undefined;
@@ -1,3 +1,4 @@
1
+ /** Normalizer for converting a string into a valid phone number. */
1
2
  export var phoneNumber = function (value) {
2
3
  if (!value) {
3
4
  return undefined;
@@ -18,6 +19,7 @@ export var phoneNumber = function (value) {
18
19
  }
19
20
  return onlyNums;
20
21
  };
22
+ /** Normalizer for converting a string into a valid zip code. Allows for XXXXX and XXXXX-XXXX format. */
21
23
  export var zipCode = function (value) {
22
24
  if (!value) {
23
25
  return undefined;
@@ -1,7 +1,8 @@
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
+ /** A `<SelectGroup/>` dropdown with two options. Default options are 'Yes' and 'No' with values of `true` and `false`. */
7
8
  export declare function BooleanSelectGroup(props: BooleanSelectGroupProps): JSX.Element;
@@ -21,6 +21,7 @@ var booleanOptions = [
21
21
  value: false,
22
22
  },
23
23
  ];
24
+ /** A `<SelectGroup/>` dropdown with two options. Default options are 'Yes' and 'No' with values of `true` and `false`. */
24
25
  export function BooleanSelectGroup(props) {
25
26
  var _a;
26
27
  return (_jsx(SelectGroup, __assign({ multiple: false }, props, { options: (_a = props.options) !== null && _a !== void 0 ? _a : booleanOptions })));
@@ -1,8 +1,10 @@
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
+ /** A `<SelectGroup/>` dropdown with values as numbers. Many options can be selected at a time. */
5
6
  export declare function MultiNumberSelectGroup(props: MultiNumberSelectGroupProps): JSX.Element;
6
- export interface SingleNumberSelectGroupProps extends SelectGroupPropsHelper<number> {
7
+ export interface SingleNumberSelectGroupProps extends SelectGroupPropsHelper<number | undefined | null> {
7
8
  }
9
+ /** A `<SelectGroup/>` dropdown with values as numbers. Only one option can be selected at a time. */
8
10
  export declare function SingleNumberSelectGroup(props: SingleNumberSelectGroupProps): JSX.Element;
@@ -11,9 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import SelectGroup from './SelectGroup';
14
+ /** A `<SelectGroup/>` dropdown with values as numbers. Many options can be selected at a time. */
14
15
  export function MultiNumberSelectGroup(props) {
15
16
  return _jsx(SelectGroup, __assign({ multiple: true }, props));
16
17
  }
18
+ /** A `<SelectGroup/>` dropdown with values as numbers. Only one option can be selected at a time. */
17
19
  export function SingleNumberSelectGroup(props) {
18
20
  return _jsx(SelectGroup, __assign({ multiple: false }, props));
19
21
  }
@@ -2,7 +2,9 @@
2
2
  import { InjectedFieldProps } from '../Field/InjectedFieldProps';
3
3
  import { GroupProps } from '../Group';
4
4
  export interface SelectOption<TValue> {
5
+ /** Value for the select. This will be sent to the API. */
5
6
  value: (TValue extends Array<infer P> ? P : TValue) | undefined;
7
+ /** Label for the select. This is displayed to the user. */
6
8
  label: string;
7
9
  }
8
10
  interface OptionsApiResult<TValue> {
@@ -13,10 +15,14 @@ interface OptionsUseServiceResult<TValue> {
13
15
  resp?: Partial<SelectOption<TValue>>[] | OptionsApiResult<TValue> | null;
14
16
  error?: any;
15
17
  }
16
- export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
18
+ export interface SelectGroupProps<TValue> extends InjectedFieldProps<TValue | undefined | null>, Omit<GroupProps, 'input' | 'meta' | 'children'> {
19
+ /** Options for the dropdown. Includes the label and value. */
17
20
  options: SelectOption<TValue>[] | OptionsUseServiceResult<TValue>;
21
+ /** Whether the user should be able to have multiple values selected. */
18
22
  multiple: TValue extends Array<any> ? true : false;
23
+ /** Text diplayed when no value is selected. */
19
24
  placeholder?: string;
20
25
  }
21
- export default function SelectGroup<TValue>({ input, meta, className, options, multiple, placeholder, ...rest }: SelectGroupProps<TValue>): JSX.Element;
26
+ /** Generic select dropdown. Uses [react-select](https://react-select.com/home). */
27
+ export default function SelectGroup<TValue>({ input, meta, className, required, disabled, options, multiple, placeholder, ...rest }: SelectGroupProps<TValue>): JSX.Element;
22
28
  export {};
@@ -23,12 +23,13 @@ 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 Group from '../Group';
27
26
  import { FormDefaults } from '../FormDefaults';
27
+ import Group from '../Group';
28
28
  // TODO: we could also name this "ReactSelectGroup" or similar but the types are strongly defined now so kept the names consistent
29
+ /** Generic select dropdown. Uses [react-select](https://react-select.com/home). */
29
30
  export default function SelectGroup(_a) {
30
31
  var _b;
31
- var input = _a.input, meta = _a.meta, className = _a.className, options = _a.options, multiple = _a.multiple, placeholder = _a.placeholder, rest = __rest(_a, ["input", "meta", "className", "options", "multiple", "placeholder"]);
32
+ 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"]);
32
33
  var effectiveOptions = !options
33
34
  ? []
34
35
  : Array.isArray(options)
@@ -42,10 +43,10 @@ export default function SelectGroup(_a) {
42
43
  ? options.resp
43
44
  : [];
44
45
  var isLoading = (options && 'loading' in options && options.loading) || false;
45
- return (_jsx(Group, __assign({}, rest, { input: input, meta: meta, className: classNames(className, (_b = {},
46
+ return (_jsx(Group, __assign({}, rest, { input: input, meta: meta, required: required, disabled: disabled, className: classNames(className, (_b = {},
46
47
  _b[FormDefaults.cssClassPrefix + 'multiple'] = multiple,
47
48
  _b[FormDefaults.cssClassPrefix + 'loading'] = isLoading,
48
- _b), FormDefaults.cssClassPrefix + 'select-group') }, { children: _jsx(ReactSelect, { inputId: input.id, isMulti: multiple, options: effectiveOptions, onBlur: input.onBlur, value: getValue(), onChange: function (e) {
49
+ _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) {
49
50
  if (multiple === true) {
50
51
  input.onChange(e === null || e === void 0 ? void 0 : e.map(function (x) { return x.value; }));
51
52
  }
@@ -2,7 +2,9 @@
2
2
  import { SelectGroupPropsHelper } from './SelectGroupPropsHelper';
3
3
  export interface MultiStringSelectGroupProps extends SelectGroupPropsHelper<string[]> {
4
4
  }
5
+ /** A `<SelectGroup/>` dropdown with values as strings. Multiple options can be selected at a time. */
5
6
  export declare function MultiStringSelectGroup(props: MultiStringSelectGroupProps): JSX.Element;
6
7
  export interface SingleStringSelectGroupProps extends SelectGroupPropsHelper<string> {
7
8
  }
9
+ /** A `<SelectGroup/>` dropdown with the value as a string. Only one option can be selected at a time. */
8
10
  export declare function SingleStringSelectGroup(props: SingleStringSelectGroupProps): JSX.Element;
@@ -11,9 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import SelectGroup from './SelectGroup';
14
+ /** A `<SelectGroup/>` dropdown with values as strings. Multiple options can be selected at a time. */
14
15
  export function MultiStringSelectGroup(props) {
15
16
  return _jsx(SelectGroup, __assign({ multiple: true }, props));
16
17
  }
18
+ /** A `<SelectGroup/>` dropdown with the value as a string. Only one option can be selected at a time. */
17
19
  export function SingleStringSelectGroup(props) {
18
20
  return _jsx(SelectGroup, __assign({ multiple: false }, props));
19
21
  }
@@ -1,6 +1,11 @@
1
1
  import { MouseEventHandler } from 'react';
2
2
  export interface StandardFormActionsProps {
3
+ /** Allow the form to be submitted without any changes. By default this is not allowed. */
3
4
  allowPristineSubmit?: boolean;
5
+ /** The cancel button's `onClick`.
6
+ * @defaultValue `window.history.back()`
7
+ */
4
8
  handleCancel?: MouseEventHandler<HTMLButtonElement>;
5
9
  }
10
+ /** Standard submit and cancel buttons. */
6
11
  export default function StandardFormActions({ allowPristineSubmit, handleCancel, }: StandardFormActionsProps): JSX.Element;
@@ -14,6 +14,7 @@ import classNames from 'classnames';
14
14
  import { useFormikContext } from 'formik';
15
15
  import SubmitFormButton from './SubmitFormButton';
16
16
  import { FormDefaults } from './FormDefaults';
17
+ /** Standard submit and cancel buttons. */
17
18
  export default function StandardFormActions(_a) {
18
19
  var allowPristineSubmit = _a.allowPristineSubmit, handleCancel = _a.handleCancel;
19
20
  var isSubmitting = useFormikContext().isSubmitting;
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  export interface SubmitFormButtonProps extends Omit<React.HTMLProps<HTMLButtonElement>, 'type'> {
3
+ /** Allow the form to be submitted without any changes. By default this is not allowed. */
3
4
  allowPristineSubmit?: boolean;
5
+ /** Text to display on the button. Default text is 'Submit'. */
4
6
  children?: React.ReactNode;
5
7
  }
6
- declare const _default: React.ComponentType<SubmitFormButtonProps>;
8
+ declare const _default: React.FunctionComponent<SubmitFormButtonProps>;
9
+ /** Generic submit button for forms. */
7
10
  export default _default;
@@ -36,4 +36,5 @@ function SubmitFormButton(_a, ref) {
36
36
  ? "You haven't made any changes"
37
37
  : '', className: classNames(FormDefaults.cssClassPrefix + 'submit-form-button', className) }, { children: children || 'Submit' })));
38
38
  }
39
+ /** Generic submit button for forms. */
39
40
  export default React.forwardRef(SubmitFormButton);
@@ -1,8 +1,9 @@
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
+ /** Generic controlled `<textarea/>` wrapped by a `<Group/>` */
7
8
  declare const TextAreaGroupWithRef: React.ComponentType<TextAreaGroupProps>;
8
9
  export default TextAreaGroupWithRef;
@@ -23,12 +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 Group from '../Group';
27
26
  import { FormDefaults } from '../FormDefaults';
28
- /** generic controlled <textarea/> wrapped by a Group */
27
+ import Group from '../Group';
29
28
  function TextAreaGroup(_a, ref) {
30
- var input = _a.input, meta = _a.meta, label = _a.label, helpText = _a.helpText, className = _a.className, disabled = _a.disabled, icon = _a.icon, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "disabled", "icon"]);
31
- return (_jsxs(Group, __assign({ input: input, meta: meta, disabled: disabled, label: label, helpText: helpText, className: classNames(className, FormDefaults.cssClassPrefix + 'text-area-group') }, { children: [icon, _jsx("textarea", __assign({}, input, rest, { value: input.value, onChange: function (val) { return input.onChange(val.target.value); }, ref: ref, className: classNames(className, FormDefaults.cssClassPrefix + 'text-area-group') }))] })));
29
+ var _b;
30
+ 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"]);
31
+ 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') }))] })));
32
32
  }
33
+ /** Generic controlled `<textarea/>` wrapped by a `<Group/>` */
33
34
  var TextAreaGroupWithRef = React.forwardRef(TextAreaGroup);
34
35
  export default TextAreaGroupWithRef;
@@ -1,15 +1,18 @@
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
+ /** Asserts that the value is a certain number of characters. numbers are coerced to a string */
4
+ export declare const length: (len: number) => (value: string | number | undefined | null) => string | undefined;
5
+ export declare const integer: (val: string | number | undefined | null) => "Must be a whole number" | undefined;
6
+ export declare const maxLength: (len: number) => (value: string | number | undefined | null) => string | undefined;
6
7
  export declare const maxCount: (count: number) => (value: {
7
8
  isDeleted?: boolean;
8
- }[] | undefined) => string | undefined;
9
+ }[] | undefined | null) => string | undefined;
9
10
  export declare const minCount: (count: number) => (value: {
10
11
  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;
12
+ }[] | undefined | null) => string | undefined;
13
+ export declare const maxValue: (max: number) => (value: number | undefined | null) => string | undefined;
14
+ export declare const minValue: (min: number) => (value: number | undefined | null) => string | undefined;
15
+ /** Validate for a ZIP Code. Accepts formats: ##### and #####-#### */
16
+ export declare const zipCode: (value: string | undefined | null) => "Invalid ZIP Code" | undefined;
17
+ /** One of the validators provided must be true. */
15
18
  export declare const any: <TValue>(validatorList: ValidationFunction<TValue>[]) => (value: TValue) => string | undefined;
@@ -7,7 +7,7 @@ export var required = function (value) {
7
7
  ? undefined
8
8
  : 'Required';
9
9
  };
10
- //asserts that the value is a certain number of characters. numbers are coerced to a string
10
+ /** Asserts that the value is a certain number of characters. numbers are coerced to a string */
11
11
  export var length = function (len) { return function (value) {
12
12
  var hasError = getLengthOfValue(value) !== len;
13
13
  return !hasError ? undefined : "Length must be ".concat(len);
@@ -40,12 +40,13 @@ export var minValue = function (min) { return function (value) {
40
40
  var hasError = !value || value < min;
41
41
  return !hasError ? undefined : "Minimum value ".concat(min, " not met");
42
42
  }; };
43
+ /** Validate for a ZIP Code. Accepts formats: ##### and #####-#### */
43
44
  export var zipCode = function (value) {
44
45
  return value && !/^[0-9]{5}(?:-[0-9]{4})?$/.test(value)
45
46
  ? 'Invalid ZIP Code'
46
47
  : undefined;
47
48
  };
48
- //one of the validators provided must be true
49
+ /** One of the validators provided must be true. */
49
50
  export var any = function (validatorList) {
50
51
  return function (value) {
51
52
  if (validatorList.length === 0 || !value) {
@@ -55,6 +56,9 @@ export var any = function (validatorList) {
55
56
  };
56
57
  };
57
58
  function getLengthOfValue(value) {
59
+ if (value === null) {
60
+ return 0;
61
+ }
58
62
  switch (typeof value) {
59
63
  case 'undefined':
60
64
  return 0;
@@ -0,0 +1,2 @@
1
+ import useFormValue from './useFormValue';
2
+ export { useFormValue };
@@ -0,0 +1,2 @@
1
+ import useFormValue from './useFormValue';
2
+ export { useFormValue };
@@ -0,0 +1,2 @@
1
+ import { FormBuilderProp } from 'Form/Form';
2
+ export default function useFormValue<TForm extends object, TPropKey extends keyof TForm>(formBuilder: FormBuilderProp<TForm>, fieldName: TPropKey): readonly [TForm[TPropKey], (value: TForm[TPropKey]) => void];
@@ -0,0 +1,7 @@
1
+ import { useCallback } from 'react';
2
+ import { useFormikContext } from 'formik';
3
+ export default function useFormValue(formBuilder, fieldName) {
4
+ var _a = useFormikContext(), values = _a.values, setFieldValue = _a.setFieldValue;
5
+ var setValue = useCallback(function (value) { return setFieldValue(fieldName, value); }, [fieldName, setFieldValue]);
6
+ return [values[fieldName], setValue];
7
+ }
package/es/index.d.ts CHANGED
@@ -7,13 +7,17 @@ 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 as DatePickerGroupProps } from './DatePicker/DatePickerGroup';
10
+ export type { DatePickerGroupProps } from './DatePicker/DatePickerGroup';
11
11
  export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
12
12
  export type { DatePickerHelper } from './DatePicker/DatePickerHelper';
13
13
  export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
14
14
  export type { StringDatePickerGroupProps } from './DatePicker/StringDatePickerGroup';
15
15
  export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
16
16
  export type { StringDateOnlyPickerGroupProps } from './DatePicker/StringDateOnlyPickerGroup';
17
+ export { default as DateTimePickerGroup } from './DateTimePicker/DateTimePickerGroup';
18
+ export type { DateTimePickerGroupProps } from './DateTimePicker/DateTimePickerGroup';
19
+ export { default as StringDateTimePickerGroup } from './DateTimePicker/StringDateTimePickerGroup';
20
+ export type { StringDateTimePickerGroupProps } from './DateTimePicker/StringDateTimePickerGroup';
17
21
  export { default as Field } from './Field/Field';
18
22
  export type { FieldProps } from './Field/Field';
19
23
  export type { RenderComponent } from './Field/Field';
@@ -34,12 +38,12 @@ export type { FormBuilderProp, FormProps } from './Form/Form';
34
38
  export { ServerErrorContext } from './Form/ServerErrorContext';
35
39
  export type { ServerErrorContextProps, ServerErrors, } from './Form/ServerErrorContext';
36
40
  export { default as FormActions } from './FormActions';
37
- export type { FormActionsProps as FormActionsProps } from './FormActions';
41
+ export type { FormActionsProps } from './FormActions';
38
42
  export { default as StandardFormActions } from './StandardFormActions';
39
- export type { StandardFormActionsProps as StandardFormActionsProps } from './StandardFormActions';
43
+ export type { StandardFormActionsProps } from './StandardFormActions';
40
44
  export { FormDefaults } from './FormDefaults';
41
45
  export { default as Group } from './Group';
42
- export type { GroupProps as GroupProps } from './Group';
46
+ export type { GroupProps } from './Group';
43
47
  export { default as IconInputGroup } from './Input/IconInputGroup';
44
48
  export type { IconInputGroupProps } from './Input/IconInputGroup';
45
49
  export { default as InputGroup } from './Input/InputGroup';
@@ -48,6 +52,8 @@ export { default as MoneyInputGroup } from './Input/MoneyInputGroup';
48
52
  export type { MoneyInputGroupProps } from './Input/MoneyInputGroup';
49
53
  export { default as NumberInputGroup } from './Input/NumberInputGroup';
50
54
  export type { NumberInputGroupProps } from './Input/NumberInputGroup';
55
+ export { default as PhoneNumberInputGroup } from './Input/PhoneNumberInputGroup';
56
+ export type { PhoneNumberInputGroupProps } from './Input/PhoneNumberInputGroup';
51
57
  export { default as StringInputGroup } from './Input/StringInputGroup';
52
58
  export type { StringInputGroupProps } from './Input/StringInputGroup';
53
59
  export type { NormalizationFunction } from './Normalization/NormalizationFunction';
package/es/index.js CHANGED
@@ -11,6 +11,9 @@ export { default as DatePickerGroup } from './DatePicker/DatePickerGroup';
11
11
  export { convertToTimeZoneInsensitiveISOString } from './DatePicker/DatePickerGroup';
12
12
  export { default as StringDatePickerGroup } from './DatePicker/StringDatePickerGroup';
13
13
  export { default as StringDateOnlyPickerGroup } from './DatePicker/StringDateOnlyPickerGroup';
14
+ // DateTime
15
+ export { default as DateTimePickerGroup } from './DateTimePicker/DateTimePickerGroup';
16
+ export { default as StringDateTimePickerGroup } from './DateTimePicker/StringDateTimePickerGroup';
14
17
  // Field
15
18
  export { default as Field } from './Field/Field';
16
19
  export { default as FieldErrorScrollTarget } from './Field/FieldErrorScrollTarget';
@@ -34,6 +37,7 @@ export { default as IconInputGroup } from './Input/IconInputGroup';
34
37
  export { default as InputGroup } from './Input/InputGroup';
35
38
  export { default as MoneyInputGroup } from './Input/MoneyInputGroup';
36
39
  export { default as NumberInputGroup } from './Input/NumberInputGroup';
40
+ export { default as PhoneNumberInputGroup } from './Input/PhoneNumberInputGroup';
37
41
  export { default as StringInputGroup } from './Input/StringInputGroup';
38
42
  export * as normalizers from './Normalization/normalizers';
39
43
  // Select
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom/extend-expect';
@@ -5,11 +5,21 @@ 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
+ /**
15
+ * Collection of `<Field/>`s for inputting an address. Includes:
16
+ * ```txt
17
+ * Address 1
18
+ * Address 2
19
+ * City
20
+ * State
21
+ * Zip
22
+ * ```
23
+ */
14
24
  export default function AddressInput({ fieldBuilder: { Field }, name, }: AddressInputProps): JSX.Element;
15
25
  export {};
@@ -20,6 +20,16 @@ var __1 = require("../");
20
20
  var FieldSection_1 = __importDefault(require("../Field/FieldSection"));
21
21
  var normalizers_1 = require("../Normalization/normalizers");
22
22
  var validators_1 = require("../Validation/validators");
23
+ /**
24
+ * Collection of `<Field/>`s for inputting an address. Includes:
25
+ * ```txt
26
+ * Address 1
27
+ * Address 2
28
+ * City
29
+ * State
30
+ * Zip
31
+ * ```
32
+ */
23
33
  function AddressInput(_a) {
24
34
  var Field = _a.fieldBuilder.Field, name = _a.name;
25
35
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(FieldSection_1.default, __assign({ name: name }, { children: [(0, jsx_runtime_1.jsx)(Field, { name: "address1", placeholder: "Address, Line 1", label: "Address 1", Component: __1.StringInputGroup, validate: validators_1.required }), (0, jsx_runtime_1.jsx)(Field, { name: "address2", placeholder: "Address, Line 2", label: "Address 2", Component: __1.StringInputGroup }), (0, jsx_runtime_1.jsx)(Field, { name: "city", placeholder: "City", label: "City", Component: __1.StringInputGroup, validate: validators_1.required }), (0, jsx_runtime_1.jsx)(Field, { name: "state", placeholder: "State", label: "State", Component: __1.SingleStringSelectGroup, options: UsStates_1.default, validate: validators_1.required }), (0, jsx_runtime_1.jsx)(Field, { name: "zipCode", placeholder: "Zip", label: "Zip", Component: __1.StringInputGroup, normalize: normalizers_1.zipCode, validate: [validators_1.required, validators_1.zipCode] })] })) }));
@@ -1,12 +1,26 @@
1
1
  import React, { MouseEventHandler } from 'react';
2
2
  import { useAxiosRequestProps } from 'envoc-request';
3
3
  export interface ConfirmBaseFormProps {
4
+ /** Function to run when cancel button is clicked. */
4
5
  handleCancel?: MouseEventHandler<HTMLButtonElement>;
6
+ /** Axios request upon confirmation */
5
7
  request: useAxiosRequestProps;
6
8
  style?: React.CSSProperties;
9
+ /** `<h3/>` title text on top of the form. */
7
10
  title?: string;
11
+ /** Custom confirm button text.
12
+ * @defaultValue `Confirm`
13
+ */
8
14
  confirmButtonText?: string;
15
+ /** CSS class for the buttons. */
9
16
  confirmButtonClass?: string;
17
+ /** Any components to be rendered in between the title and the buttons. */
10
18
  children?: React.ReactNode;
11
19
  }
20
+ /**
21
+ * Confimation dialog. Navigates to a different route to allow the user to either confirm or cancel an action.
22
+ * Commonly used for confirming delete and archive.
23
+ *
24
+ * See `<ConfirmDeleteForm/>` if the confirmation is specifically for deletion.
25
+ */
12
26
  export default function ConfirmBaseForm({ handleCancel, request, style, title, confirmButtonText, confirmButtonClass, children, ...props }: ConfirmBaseFormProps): JSX.Element;
@@ -30,6 +30,12 @@ var classnames_1 = __importDefault(require("classnames"));
30
30
  var envoc_request_1 = require("envoc-request");
31
31
  var FormDefaults_1 = require("../FormDefaults");
32
32
  // TODO: ask about how we should use 'children'
33
+ /**
34
+ * Confimation dialog. Navigates to a different route to allow the user to either confirm or cancel an action.
35
+ * Commonly used for confirming delete and archive.
36
+ *
37
+ * See `<ConfirmDeleteForm/>` if the confirmation is specifically for deletion.
38
+ */
33
39
  function ConfirmBaseForm(_a) {
34
40
  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"]);
35
41
  var webRequest = (0, envoc_request_1.useAxiosRequest)(Object.assign({}, request, { autoExecute: false }));
@@ -1,11 +1,24 @@
1
1
  import React from 'react';
2
2
  import { ConfirmBaseFormProps } from '../ConfirmBaseForm/ConfirmBaseForm';
3
3
  export interface ConfirmDeleteFormProps extends Pick<ConfirmBaseFormProps, 'style'> {
4
+ /** Url to navigate to on success. */
4
5
  successUrl?: string;
6
+ /** Form name (key) to apply the confirmation on. */
5
7
  form: string;
8
+ /** Custom message to display.
9
+ * @defaultValue `Are you sure you want to delete this?`
10
+ */
6
11
  title?: string;
12
+ /** Custom function when the axios request succeeds. */
7
13
  handleComplete?: Function;
14
+ /** Custom function when the axios request fails. */
8
15
  handleError?: Function;
16
+ /** Any components to be rendered in between the title and the buttons. */
9
17
  children?: React.ReactNode;
10
18
  }
19
+ /**
20
+ * Deletion confirmation. Navigates to a different route to allow the user to either confirm or cancel an action.
21
+ *
22
+ * Wraps `<ConfirmBaseForm/>`.
23
+ */
11
24
  export default function ConfirmDeleteForm({ successUrl, form, title, handleComplete, handleError, children, ...props }: ConfirmDeleteFormProps): JSX.Element;
@@ -30,6 +30,11 @@ 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
32
  var FormDefaults_1 = require("../FormDefaults");
33
+ /**
34
+ * Deletion confirmation. Navigates to a different route to allow the user to either confirm or cancel an action.
35
+ *
36
+ * Wraps `<ConfirmBaseForm/>`.
37
+ */
33
38
  function ConfirmDeleteForm(_a) {
34
39
  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"]);
35
40
  var navigate = (0, react_router_dom_1.useNavigate)();
@@ -2,8 +2,13 @@
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
+ /**
9
+ * Field for inputting dates. Uses `<Group/>` and `<DatePicker/>`.
10
+ *
11
+ * Uses [react-date-picker](https://www.npmjs.com/package/react-date-picker)
12
+ */
13
+ export default function DatePickerGroup<T>({ input, meta, label, helpText, className, required, disabled, convert, maxDate, minDate, ...rest }: DatePickerGroupProps<T>): JSX.Element;
9
14
  export declare function convertToTimeZoneInsensitiveISOString(date: Date): string;
@@ -33,18 +33,28 @@ var classnames_1 = __importDefault(require("classnames"));
33
33
  var parseISO_1 = __importDefault(require("date-fns/parseISO"));
34
34
  var FormDefaults_1 = require("../FormDefaults");
35
35
  var Group_1 = __importDefault(require("../Group"));
36
+ /**
37
+ * Field for inputting dates. Uses `<Group/>` and `<DatePicker/>`.
38
+ *
39
+ * Uses [react-date-picker](https://www.npmjs.com/package/react-date-picker)
40
+ */
36
41
  function DatePickerGroup(_a) {
37
- 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"]);
38
- var _b = (0, react_1.useState)(null), displayDate = _b[0], setDisplayDate = _b[1];
42
+ 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, _b = _a.maxDate, maxDate = _b === void 0 ? new Date(9999, 11, 31) : _b, _c = _a.minDate, minDate = _c === void 0 ? new Date(1000, 0, 1) : _c, rest = __rest(_a, ["input", "meta", "label", "helpText", "className", "required", "disabled", "convert", "maxDate", "minDate"]);
43
+ var _d = (0, react_1.useState)(null), displayDate = _d[0], setDisplayDate = _d[1];
39
44
  (0, react_1.useEffect)(function () {
40
- if (input.value != null) {
41
- setDisplayDate(new Date("".concat(input.value, "T00:00:00.000")));
42
- }
43
- else {
45
+ if (!input.value) {
44
46
  setDisplayDate(null);
45
47
  }
48
+ else if (typeof input.value === 'string') {
49
+ if (input.value.indexOf('T') === -1) {
50
+ setDisplayDate(new Date("".concat(input.value, "T00:00:00.000")));
51
+ }
52
+ else {
53
+ setDisplayDate(new Date(input.value));
54
+ }
55
+ }
46
56
  }, [setDisplayDate, input.value]);
47
- 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'), 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 })) })));
57
+ 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, maxDate: maxDate, minDate: minDate })) })));
48
58
  function handleChange(e) {
49
59
  var onChange = input.onChange;
50
60
  if (onChange === null) {
@@ -77,6 +87,7 @@ exports.default = DatePickerGroup;
77
87
  function convertToTimeZoneInsensitiveISOString(date) {
78
88
  var year = new Intl.DateTimeFormat('en', { year: 'numeric' })
79
89
  .format(date)
90
+ .substring(0, 4)
80
91
  .padStart(4, '0');
81
92
  var month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(date);
82
93
  var day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date);
@@ -1,5 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { DatePickerHelper } from './DatePickerHelper';
3
- export interface StringDateOnlyPickerGroupProps extends DatePickerHelper<string | undefined> {
3
+ export interface StringDateOnlyPickerGroupProps extends DatePickerHelper<string | undefined | null> {
4
4
  }
5
+ /**
6
+ * Date picker input that consumes and outputs as a date only string in ISO format `YYYY-MM-DD`.
7
+ *
8
+ * Default display to the user is in `MM/DD/YYYY` format.
9
+ */
5
10
  export default function StringDatePickerGroup(props: StringDateOnlyPickerGroupProps): JSX.Element;