envoc-form 5.0.3 → 5.0.6
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 +163 -20
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +2 -2
- package/es/DatePicker/DatePickerGroup.js +2 -2
- package/es/FieldArray/FieldArray.js +4 -4
- package/es/File/FileGroup.js +3 -3
- package/es/Form/Form.js +2 -2
- package/es/Group.js +3 -3
- package/es/Input/CheckboxGroup.d.ts +6 -0
- package/es/Input/CheckboxGroup.js +14 -0
- package/es/Input/CheckboxInputGroup.d.ts +13 -0
- package/es/Input/CheckboxInputGroup.js +41 -0
- package/es/Input/IconInputGroup.js +2 -2
- package/es/Input/InputGroup.js +2 -2
- package/es/Input/MoneyInputGroup.js +2 -2
- package/es/Input/NumberInputGroup.js +2 -2
- package/es/Input/PhoneNumberInputGroup.js +2 -2
- package/es/Input/StringInputGroup.js +2 -2
- package/es/Select/SelectGroup.js +3 -3
- package/es/StandardFormActions.js +3 -3
- package/es/SubmitFormButton.js +2 -2
- package/es/TextArea/TextAreaGroup.js +2 -2
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +2 -5
- package/lib/DatePicker/DatePickerGroup.js +2 -2
- package/lib/FieldArray/FieldArray.js +4 -4
- package/lib/File/FileGroup.js +3 -3
- package/lib/Form/Form.js +2 -2
- package/lib/Group.js +3 -3
- package/lib/Input/CheckboxGroup.d.ts +6 -0
- package/lib/Input/CheckboxGroup.js +20 -0
- package/lib/Input/CheckboxInputGroup.d.ts +13 -0
- package/lib/Input/CheckboxInputGroup.js +46 -0
- package/lib/Input/IconInputGroup.js +2 -2
- package/lib/Input/InputGroup.js +2 -2
- package/lib/Input/MoneyInputGroup.js +2 -2
- package/lib/Input/NumberInputGroup.js +2 -2
- package/lib/Input/PhoneNumberInputGroup.js +2 -2
- package/lib/Input/StringInputGroup.js +2 -2
- package/lib/Select/SelectGroup.js +3 -3
- package/lib/StandardFormActions.js +3 -3
- package/lib/SubmitFormButton.js +2 -2
- package/lib/TextArea/TextAreaGroup.js +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/package.json +111 -111
- package/src/AddressInput/AddressInput.test.tsx +27 -27
- package/src/AddressInput/AddressInput.tsx +82 -82
- package/src/AddressInput/UsStates.ts +55 -55
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +182 -182
- package/src/ConfirmBaseForm/ConfirmBaseForm.test.tsx +24 -24
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +74 -74
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +23 -23
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.tsx +24 -24
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +87 -87
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +25 -25
- package/src/DatePicker/DatePicker.test.tsx +48 -48
- package/src/DatePicker/DatePickerGroup.tsx +109 -115
- package/src/DatePicker/DatePickerHelper.ts +4 -4
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +28 -28
- package/src/DatePicker/StringDatePickerGroup.tsx +20 -20
- package/src/DatePicker/__snapshots__/DatePicker.test.tsx.snap +152 -152
- package/src/Field/CustomFieldInputProps.ts +10 -10
- package/src/Field/CustomFieldMetaProps.ts +5 -5
- package/src/Field/Field.tsx +113 -113
- package/src/Field/FieldErrorScrollTarget.tsx +12 -12
- package/src/Field/FieldNameContext.ts +6 -6
- package/src/Field/FieldSection.tsx +18 -18
- package/src/Field/InjectedFieldProps.ts +8 -8
- package/src/Field/StandAloneInput.tsx +55 -55
- package/src/Field/useStandardField.ts +125 -125
- package/src/FieldArray/FieldArray.tsx +154 -154
- package/src/File/FileGroup.test.tsx +35 -35
- package/src/File/FileGroup.tsx +82 -85
- package/src/File/FileList.tsx +21 -21
- package/src/File/__snapshots__/FileGroup.test.tsx.snap +34 -34
- package/src/File/humanFileSize.ts +8 -8
- package/src/Form/FocusError.tsx +55 -55
- package/src/Form/Form.test.tsx +14 -14
- package/src/Form/Form.tsx +234 -237
- package/src/Form/FormBasedPreventNavigation.tsx +56 -56
- package/src/Form/LegacyFormBasedPreventNavigation.tsx +77 -77
- package/src/Form/NewFormBasedPreventNavigation.tsx +59 -59
- package/src/Form/ServerErrorContext.ts +18 -18
- package/src/Form/__snapshots__/Form.test.tsx.snap +10 -10
- package/src/FormActions.tsx +47 -47
- package/src/FormDefaults.ts +2 -2
- package/src/Group.tsx +62 -62
- package/src/Input/CheckboxGroup.tsx +60 -0
- package/src/Input/CheckboxInputGroup.tsx +78 -0
- package/src/Input/IconInputGroup.tsx +54 -54
- package/src/Input/InputGroup.tsx +66 -72
- package/src/Input/MoneyInputGroup.tsx +47 -50
- package/src/Input/NumberInputGroup.tsx +45 -48
- package/src/Input/PhoneNumberInputGroup.tsx +45 -45
- package/src/Input/StringInputGroup.tsx +50 -53
- package/src/Input/__Tests__/CheckboxInputGroup.test.tsx +26 -0
- package/src/Input/__Tests__/IconInputGroup.test.tsx +35 -35
- package/src/Input/__Tests__/MoneyInputGroup.test.tsx +37 -37
- package/src/Input/__Tests__/NumberInputGroup.test.tsx +35 -35
- package/src/Input/__Tests__/PhoneNumberInputGroup.test.tsx +36 -36
- package/src/Input/__Tests__/StringInputGroup.test.tsx +27 -27
- package/src/Input/__Tests__/__snapshots__/CheckboxInputGroup.test.tsx.snap +33 -0
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +32 -32
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +34 -34
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +32 -32
- package/src/Input/__Tests__/__snapshots__/PhoneNumberInputGroup.test.tsx.snap +33 -33
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +31 -31
- package/src/Normalization/NormalizationFunction.ts +4 -4
- package/src/Normalization/normalizers.ts +44 -44
- package/src/Select/BooleanSelectGroup.tsx +28 -28
- package/src/Select/NumberSelectGroup.tsx +16 -16
- package/src/Select/SelectGroup.tsx +124 -124
- package/src/Select/SelectGroupPropsHelper.ts +4 -4
- package/src/Select/StringSelectGroup.tsx +16 -16
- package/src/Select/__tests__/BooleanSelectGroup.test.tsx +35 -35
- package/src/Select/__tests__/NumberSelectGroup.test.tsx +87 -87
- package/src/Select/__tests__/StringSelectGroup.test.tsx +89 -89
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +98 -98
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +195 -195
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +195 -195
- package/src/StandardFormActions.tsx +41 -41
- package/src/SubmitFormButton.tsx +54 -54
- package/src/TextArea/TextAreaGroup.tsx +64 -64
- package/src/Validation/ValidatedApiResult.ts +8 -8
- package/src/Validation/ValidationError.ts +6 -6
- package/src/Validation/ValidationFunction.ts +4 -4
- package/src/Validation/validators.test.tsx +81 -81
- package/src/Validation/validators.ts +97 -97
- package/src/__Tests__/FormTestBase.tsx +65 -64
- package/src/__Tests__/RealisticForm.test.tsx +82 -82
- package/src/__Tests__/StandardFormActions.test.tsx +17 -17
- package/src/__Tests__/SubmitFormButton.test.tsx +17 -17
- package/src/__Tests__/__snapshots__/StandardFormActions.test.tsx.snap +27 -27
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.tsx.snap +20 -20
- package/src/__Tests__/index.ts +3 -3
- package/src/_variables.scss +11 -11
- package/src/index.ts +156 -153
- package/src/react-app-env.d.ts +1 -1
- package/src/setupTests.ts +1 -1
- package/src/utils/objectContainsNonSerializableProperty.test.tsx +49 -49
- package/src/utils/objectContainsNonSerializableProperty.ts +17 -17
- package/src/utils/objectToFormData.test.tsx +76 -76
- package/src/utils/objectToFormData.ts +105 -105
- package/src/utils/typeChecks.ts +18 -18
package/package.json
CHANGED
@@ -1,111 +1,111 @@
|
|
1
|
-
{
|
2
|
-
"name": "envoc-form",
|
3
|
-
"version": "5.0.
|
4
|
-
"description": "Envoc form components",
|
5
|
-
"keywords": [
|
6
|
-
"react-component",
|
7
|
-
"react",
|
8
|
-
"forms",
|
9
|
-
"components",
|
10
|
-
"envoc"
|
11
|
-
],
|
12
|
-
"homepage": "",
|
13
|
-
"repository": "",
|
14
|
-
"license": "MIT",
|
15
|
-
"author": "Envoc Developers",
|
16
|
-
"sideEffects": false,
|
17
|
-
"main": "lib/index.js",
|
18
|
-
"module": "es/index.js",
|
19
|
-
"files": [
|
20
|
-
"dist",
|
21
|
-
"src",
|
22
|
-
"lib",
|
23
|
-
"es"
|
24
|
-
],
|
25
|
-
"scripts": {
|
26
|
-
"build": "yarn verify-imports && yarn build:esm && yarn build:cjs && yarn build:css && yarn build:docs",
|
27
|
-
"rebuild": "rimraf ./{dist,es,lib} && yarn build",
|
28
|
-
"build:esm": "cross-env BABEL_ENV=esm-dir tsc -p tsconfig.esm.json",
|
29
|
-
"build:css": "sass src/styles.scss dist/css/envoc-form-styles.css",
|
30
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
31
|
-
"build:docs": "yarn rimraf README.md && yarn typedoc --options typedoc.json src/index.ts && npx concat-md --decrease-title-levels --dir-name-as-title docs > README.md &&
|
32
|
-
"verify-imports": "node ../../scripts/check-for-scss-imports.js envoc-form",
|
33
|
-
"start": "webpack serve --config ./webpack.demo.config.js",
|
34
|
-
"test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false",
|
35
|
-
"coverage": "yarn test --verbose --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura"
|
36
|
-
},
|
37
|
-
"dependencies": {
|
38
|
-
"axios": "^0.21.1",
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"react-
|
45
|
-
"react-
|
46
|
-
"react-
|
47
|
-
"react-
|
48
|
-
"react-
|
49
|
-
"
|
50
|
-
"
|
51
|
-
"
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"@fortawesome/
|
55
|
-
"@fortawesome/
|
56
|
-
"
|
57
|
-
},
|
58
|
-
"devDependencies": {
|
59
|
-
"@babel/cli": "^7.14.5",
|
60
|
-
"@babel/core": "^7.14.6",
|
61
|
-
"@babel/plugin-transform-runtime": "^7.14.5",
|
62
|
-
"@babel/preset-env": "^7.14.7",
|
63
|
-
"@babel/preset-react": "^7.14.5",
|
64
|
-
"@testing-library/jest-dom": "^5.14.1",
|
65
|
-
"@testing-library/react": "^11.2.5",
|
66
|
-
"@testing-library/user-event": "^12.7.1",
|
67
|
-
"@types/jest": "^26.0.24",
|
68
|
-
"@types/react": "~18",
|
69
|
-
"@types/testing-library__jest-dom": "5.14.5",
|
70
|
-
"@types/smoothscroll-polyfill": "^0.3.1",
|
71
|
-
"@types/uuid": "^8.3.2",
|
72
|
-
"babel-loader": "^8.2.2",
|
73
|
-
"bootstrap": "^4.6.0",
|
74
|
-
"clean-webpack-plugin": "^3.0.0",
|
75
|
-
"cross-env": "7.0.3",
|
76
|
-
"css-loader": "^5.0.2",
|
77
|
-
"eslint": "^8.32.0",
|
78
|
-
"eslint-config-react-app": "^7.0.1",
|
79
|
-
"html-webpack-plugin": "^5.3.2",
|
80
|
-
"identity-obj-proxy": "^3.0.0",
|
81
|
-
"jest-junit": "~12.2.0",
|
82
|
-
"react": "~18",
|
83
|
-
"react-dom": "~18",
|
84
|
-
"react-router-dom": "^6.2.1",
|
85
|
-
"react-scripts": "^4.0.3",
|
86
|
-
"rimraf": "~3.0.2",
|
87
|
-
"sass": "^1.35.2",
|
88
|
-
"sass-loader": "^11.0.1",
|
89
|
-
"style-loader": "^2.0.0",
|
90
|
-
"webpack": "^5.45.0",
|
91
|
-
"webpack-cli": "^4.7.2",
|
92
|
-
"webpack-dev-server": "^3.11.2",
|
93
|
-
"ts-loader": "^9.2.8",
|
94
|
-
"typescript": "^5.1.6",
|
95
|
-
"typedoc-plugin-markdown": "^3.15.0",
|
96
|
-
"typedoc": "^0.24.1",
|
97
|
-
"concat-md": "~0.3.5"
|
98
|
-
},
|
99
|
-
"peerDependencies": {
|
100
|
-
"@babel/runtime": "^7.14.6",
|
101
|
-
"formik": "^2.2.9",
|
102
|
-
"react": ">=18",
|
103
|
-
"react-dom": ">=18",
|
104
|
-
"react-router-dom": "^6.2.1"
|
105
|
-
},
|
106
|
-
"jest": {
|
107
|
-
"transformIgnorePatterns": [
|
108
|
-
"
|
109
|
-
]
|
110
|
-
}
|
111
|
-
}
|
1
|
+
{
|
2
|
+
"name": "envoc-form",
|
3
|
+
"version": "5.0.6",
|
4
|
+
"description": "Envoc form components",
|
5
|
+
"keywords": [
|
6
|
+
"react-component",
|
7
|
+
"react",
|
8
|
+
"forms",
|
9
|
+
"components",
|
10
|
+
"envoc"
|
11
|
+
],
|
12
|
+
"homepage": "",
|
13
|
+
"repository": "",
|
14
|
+
"license": "MIT",
|
15
|
+
"author": "Envoc Developers",
|
16
|
+
"sideEffects": false,
|
17
|
+
"main": "lib/index.js",
|
18
|
+
"module": "es/index.js",
|
19
|
+
"files": [
|
20
|
+
"dist",
|
21
|
+
"src",
|
22
|
+
"lib",
|
23
|
+
"es"
|
24
|
+
],
|
25
|
+
"scripts": {
|
26
|
+
"build": "yarn verify-imports && yarn build:esm && yarn build:cjs && yarn build:css && yarn build:docs",
|
27
|
+
"rebuild": "rimraf ./{dist,es,lib} && yarn build",
|
28
|
+
"build:esm": "cross-env BABEL_ENV=esm-dir tsc -p tsconfig.esm.json",
|
29
|
+
"build:css": "sass src/styles.scss dist/css/envoc-form-styles.css",
|
30
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
31
|
+
"build:docs": "yarn rimraf README.md && yarn typedoc --options typedoc.json src/index.ts && npx concat-md --decrease-title-levels --dir-name-as-title docs > README.md && yarn rimraf docs",
|
32
|
+
"verify-imports": "node ../../scripts/check-for-scss-imports.js envoc-form",
|
33
|
+
"start": "webpack serve --config ./webpack.demo.config.js",
|
34
|
+
"test": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false",
|
35
|
+
"coverage": "yarn test --verbose --reporters=default --reporters=jest-junit --coverage --coverageReporters=cobertura"
|
36
|
+
},
|
37
|
+
"dependencies": {
|
38
|
+
"axios": "^0.21.1",
|
39
|
+
"date-fns": "^2.22.1",
|
40
|
+
"envoc-request": "^5.0.6",
|
41
|
+
"lru-cache": "^6.0.0",
|
42
|
+
"prop-types": "^15.7.2",
|
43
|
+
"react-date-picker": "^8.2.0",
|
44
|
+
"react-dropzone": "^11.3.4",
|
45
|
+
"react-router": "^6.2.1",
|
46
|
+
"react-select": "^5.2.2",
|
47
|
+
"react-textarea-autosize": "^8.3.3",
|
48
|
+
"react-toastify": "^7.0.4",
|
49
|
+
"reactstrap": "^8.9.0",
|
50
|
+
"history": "^5.2.0",
|
51
|
+
"smoothscroll-polyfill": "^0.4.4",
|
52
|
+
"uuid": "^8.3.2",
|
53
|
+
"@fortawesome/react-fontawesome": "~0.1.16",
|
54
|
+
"@fortawesome/free-solid-svg-icons": "~5.15.4",
|
55
|
+
"@fortawesome/fontawesome-svg-core": "~1.2.36",
|
56
|
+
"clsx": "^2.1.0"
|
57
|
+
},
|
58
|
+
"devDependencies": {
|
59
|
+
"@babel/cli": "^7.14.5",
|
60
|
+
"@babel/core": "^7.14.6",
|
61
|
+
"@babel/plugin-transform-runtime": "^7.14.5",
|
62
|
+
"@babel/preset-env": "^7.14.7",
|
63
|
+
"@babel/preset-react": "^7.14.5",
|
64
|
+
"@testing-library/jest-dom": "^5.14.1",
|
65
|
+
"@testing-library/react": "^11.2.5",
|
66
|
+
"@testing-library/user-event": "^12.7.1",
|
67
|
+
"@types/jest": "^26.0.24",
|
68
|
+
"@types/react": "~18",
|
69
|
+
"@types/testing-library__jest-dom": "5.14.5",
|
70
|
+
"@types/smoothscroll-polyfill": "^0.3.1",
|
71
|
+
"@types/uuid": "^8.3.2",
|
72
|
+
"babel-loader": "^8.2.2",
|
73
|
+
"bootstrap": "^4.6.0",
|
74
|
+
"clean-webpack-plugin": "^3.0.0",
|
75
|
+
"cross-env": "7.0.3",
|
76
|
+
"css-loader": "^5.0.2",
|
77
|
+
"eslint": "^8.32.0",
|
78
|
+
"eslint-config-react-app": "^7.0.1",
|
79
|
+
"html-webpack-plugin": "^5.3.2",
|
80
|
+
"identity-obj-proxy": "^3.0.0",
|
81
|
+
"jest-junit": "~12.2.0",
|
82
|
+
"react": "~18",
|
83
|
+
"react-dom": "~18",
|
84
|
+
"react-router-dom": "^6.2.1",
|
85
|
+
"react-scripts": "^4.0.3",
|
86
|
+
"rimraf": "~3.0.2",
|
87
|
+
"sass": "^1.35.2",
|
88
|
+
"sass-loader": "^11.0.1",
|
89
|
+
"style-loader": "^2.0.0",
|
90
|
+
"webpack": "^5.45.0",
|
91
|
+
"webpack-cli": "^4.7.2",
|
92
|
+
"webpack-dev-server": "^3.11.2",
|
93
|
+
"ts-loader": "^9.2.8",
|
94
|
+
"typescript": "^5.1.6",
|
95
|
+
"typedoc-plugin-markdown": "^3.15.0",
|
96
|
+
"typedoc": "^0.24.1",
|
97
|
+
"concat-md": "~0.3.5"
|
98
|
+
},
|
99
|
+
"peerDependencies": {
|
100
|
+
"@babel/runtime": "^7.14.6",
|
101
|
+
"formik": "^2.2.9",
|
102
|
+
"react": ">=18",
|
103
|
+
"react-dom": ">=18",
|
104
|
+
"react-router-dom": "^6.2.1"
|
105
|
+
},
|
106
|
+
"jest": {
|
107
|
+
"transformIgnorePatterns": [
|
108
|
+
"^.+/.module/.(css|sass|scss)$"
|
109
|
+
]
|
110
|
+
}
|
111
|
+
}
|
@@ -1,27 +1,27 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import AddressInput from './AddressInput';
|
4
|
-
import FormTestBase from '../__Tests__/FormTestBase';
|
5
|
-
|
6
|
-
describe('AddressInput', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
12
|
-
)}
|
13
|
-
</FormTestBase>
|
14
|
-
);
|
15
|
-
});
|
16
|
-
|
17
|
-
it('has matching snapshot', () => {
|
18
|
-
const renderResult = render(
|
19
|
-
<FormTestBase>
|
20
|
-
{({ Field }) => (
|
21
|
-
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
22
|
-
)}
|
23
|
-
</FormTestBase>
|
24
|
-
);
|
25
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
26
|
-
});
|
27
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import AddressInput from './AddressInput';
|
4
|
+
import FormTestBase from '../__Tests__/FormTestBase';
|
5
|
+
|
6
|
+
describe('AddressInput', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
12
|
+
)}
|
13
|
+
</FormTestBase>
|
14
|
+
);
|
15
|
+
});
|
16
|
+
|
17
|
+
it('has matching snapshot', () => {
|
18
|
+
const renderResult = render(
|
19
|
+
<FormTestBase>
|
20
|
+
{({ Field }) => (
|
21
|
+
<AddressInput fieldBuilder={{ Field }} name="normalAddressInput" />
|
22
|
+
)}
|
23
|
+
</FormTestBase>
|
24
|
+
);
|
25
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
26
|
+
});
|
27
|
+
});
|
@@ -1,82 +1,82 @@
|
|
1
|
-
import UsStates from './UsStates';
|
2
|
-
import { SingleStringSelectGroup, StringInputGroup } from '../';
|
3
|
-
import FieldSection from '../Field/FieldSection';
|
4
|
-
import { FormBuilderProp } from '../Form/Form';
|
5
|
-
import { zipCode as zipCodeNormalizer } from '../Normalization/normalizers';
|
6
|
-
import {
|
7
|
-
required,
|
8
|
-
zipCode as zipCodeValidator,
|
9
|
-
} from '../Validation/validators';
|
10
|
-
|
11
|
-
// TODO: find a permanent home for these interfaces
|
12
|
-
// TODO: but also, maybe they are comfortable here?
|
13
|
-
export interface AddressInputProps {
|
14
|
-
fieldBuilder: Pick<FormBuilderProp<AddressDto>, 'Field'>;
|
15
|
-
name: string;
|
16
|
-
}
|
17
|
-
|
18
|
-
interface AddressDto {
|
19
|
-
address1?: string | null;
|
20
|
-
address2?: string | null;
|
21
|
-
zipCode?: string | null;
|
22
|
-
city?: string | null;
|
23
|
-
state?: string | null;
|
24
|
-
}
|
25
|
-
|
26
|
-
/**
|
27
|
-
* Collection of `<Field/>`s for inputting an address. Includes:
|
28
|
-
* ```txt
|
29
|
-
* Address 1
|
30
|
-
* Address 2
|
31
|
-
* City
|
32
|
-
* State
|
33
|
-
* Zip
|
34
|
-
* ```
|
35
|
-
*/
|
36
|
-
export default function AddressInput({
|
37
|
-
fieldBuilder: { Field },
|
38
|
-
name,
|
39
|
-
}: AddressInputProps) {
|
40
|
-
return (
|
41
|
-
<>
|
42
|
-
<FieldSection name={name}>
|
43
|
-
<Field
|
44
|
-
name="address1"
|
45
|
-
placeholder="Address, Line 1"
|
46
|
-
label="Address 1"
|
47
|
-
Component={StringInputGroup}
|
48
|
-
validate={required}
|
49
|
-
/>
|
50
|
-
<Field
|
51
|
-
name="address2"
|
52
|
-
placeholder="Address, Line 2"
|
53
|
-
label="Address 2"
|
54
|
-
Component={StringInputGroup}
|
55
|
-
/>
|
56
|
-
<Field
|
57
|
-
name="city"
|
58
|
-
placeholder="City"
|
59
|
-
label="City"
|
60
|
-
Component={StringInputGroup}
|
61
|
-
validate={required}
|
62
|
-
/>
|
63
|
-
<Field
|
64
|
-
name="state"
|
65
|
-
placeholder="State"
|
66
|
-
label="State"
|
67
|
-
Component={SingleStringSelectGroup}
|
68
|
-
options={UsStates}
|
69
|
-
validate={required}
|
70
|
-
/>
|
71
|
-
<Field
|
72
|
-
name="zipCode"
|
73
|
-
placeholder="Zip"
|
74
|
-
label="Zip"
|
75
|
-
Component={StringInputGroup}
|
76
|
-
normalize={zipCodeNormalizer}
|
77
|
-
validate={[required, zipCodeValidator]}
|
78
|
-
/>
|
79
|
-
</FieldSection>
|
80
|
-
</>
|
81
|
-
);
|
82
|
-
}
|
1
|
+
import UsStates from './UsStates';
|
2
|
+
import { SingleStringSelectGroup, StringInputGroup } from '../';
|
3
|
+
import FieldSection from '../Field/FieldSection';
|
4
|
+
import { FormBuilderProp } from '../Form/Form';
|
5
|
+
import { zipCode as zipCodeNormalizer } from '../Normalization/normalizers';
|
6
|
+
import {
|
7
|
+
required,
|
8
|
+
zipCode as zipCodeValidator,
|
9
|
+
} from '../Validation/validators';
|
10
|
+
|
11
|
+
// TODO: find a permanent home for these interfaces
|
12
|
+
// TODO: but also, maybe they are comfortable here?
|
13
|
+
export interface AddressInputProps {
|
14
|
+
fieldBuilder: Pick<FormBuilderProp<AddressDto>, 'Field'>;
|
15
|
+
name: string;
|
16
|
+
}
|
17
|
+
|
18
|
+
interface AddressDto {
|
19
|
+
address1?: string | null;
|
20
|
+
address2?: string | null;
|
21
|
+
zipCode?: string | null;
|
22
|
+
city?: string | null;
|
23
|
+
state?: string | null;
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Collection of `<Field/>`s for inputting an address. Includes:
|
28
|
+
* ```txt
|
29
|
+
* Address 1
|
30
|
+
* Address 2
|
31
|
+
* City
|
32
|
+
* State
|
33
|
+
* Zip
|
34
|
+
* ```
|
35
|
+
*/
|
36
|
+
export default function AddressInput({
|
37
|
+
fieldBuilder: { Field },
|
38
|
+
name,
|
39
|
+
}: AddressInputProps) {
|
40
|
+
return (
|
41
|
+
<>
|
42
|
+
<FieldSection name={name}>
|
43
|
+
<Field
|
44
|
+
name="address1"
|
45
|
+
placeholder="Address, Line 1"
|
46
|
+
label="Address 1"
|
47
|
+
Component={StringInputGroup}
|
48
|
+
validate={required}
|
49
|
+
/>
|
50
|
+
<Field
|
51
|
+
name="address2"
|
52
|
+
placeholder="Address, Line 2"
|
53
|
+
label="Address 2"
|
54
|
+
Component={StringInputGroup}
|
55
|
+
/>
|
56
|
+
<Field
|
57
|
+
name="city"
|
58
|
+
placeholder="City"
|
59
|
+
label="City"
|
60
|
+
Component={StringInputGroup}
|
61
|
+
validate={required}
|
62
|
+
/>
|
63
|
+
<Field
|
64
|
+
name="state"
|
65
|
+
placeholder="State"
|
66
|
+
label="State"
|
67
|
+
Component={SingleStringSelectGroup}
|
68
|
+
options={UsStates}
|
69
|
+
validate={required}
|
70
|
+
/>
|
71
|
+
<Field
|
72
|
+
name="zipCode"
|
73
|
+
placeholder="Zip"
|
74
|
+
label="Zip"
|
75
|
+
Component={StringInputGroup}
|
76
|
+
normalize={zipCodeNormalizer}
|
77
|
+
validate={[required, zipCodeValidator]}
|
78
|
+
/>
|
79
|
+
</FieldSection>
|
80
|
+
</>
|
81
|
+
);
|
82
|
+
}
|
@@ -1,55 +1,55 @@
|
|
1
|
-
import { SelectOption } from '../Select/SelectGroup';
|
2
|
-
|
3
|
-
const states: SelectOption<string>[] = [
|
4
|
-
{ label: 'Alabama', value: 'AL' },
|
5
|
-
{ label: 'Alaska', value: 'AK' },
|
6
|
-
{ label: 'Arizona', value: 'AZ' },
|
7
|
-
{ label: 'Arkansas', value: 'AR' },
|
8
|
-
{ label: 'California', value: 'CA' },
|
9
|
-
{ label: 'Colorado', value: 'CO' },
|
10
|
-
{ label: 'Connecticut', value: 'CT' },
|
11
|
-
{ label: 'Delaware', value: 'DE' },
|
12
|
-
{ label: 'Florida', value: 'FL' },
|
13
|
-
{ label: 'Georgia', value: 'GA' },
|
14
|
-
{ label: 'Hawaii', value: 'HI' },
|
15
|
-
{ label: 'Idaho', value: 'ID' },
|
16
|
-
{ label: 'Illinois', value: 'IL' },
|
17
|
-
{ label: 'Indiana', value: 'IN' },
|
18
|
-
{ label: 'Iowa', value: 'IA' },
|
19
|
-
{ label: 'Kansas', value: 'KS' },
|
20
|
-
{ label: 'Kentucky', value: 'KY' },
|
21
|
-
{ label: 'Louisiana', value: 'LA' },
|
22
|
-
{ label: 'Maine', value: 'ME' },
|
23
|
-
{ label: 'Maryland', value: 'MD' },
|
24
|
-
{ label: 'Massachusetts', value: 'MA' },
|
25
|
-
{ label: 'Michigan', value: 'MI' },
|
26
|
-
{ label: 'Minnesota', value: 'MN' },
|
27
|
-
{ label: 'Mississippi', value: 'MS' },
|
28
|
-
{ label: 'Missouri', value: 'MO' },
|
29
|
-
{ label: 'Montana', value: 'MT' },
|
30
|
-
{ label: 'Nebraska', value: 'NE' },
|
31
|
-
{ label: 'Nevada', value: 'NV' },
|
32
|
-
{ label: 'New Hampshire', value: 'NH' },
|
33
|
-
{ label: 'New Jersey', value: 'NJ' },
|
34
|
-
{ label: 'New Mexico', value: 'NM' },
|
35
|
-
{ label: 'New York', value: 'NY' },
|
36
|
-
{ label: 'North Carolina', value: 'NC' },
|
37
|
-
{ label: 'North Dakota', value: 'ND' },
|
38
|
-
{ label: 'Ohio', value: 'OH' },
|
39
|
-
{ label: 'Oklahoma', value: 'OK' },
|
40
|
-
{ label: 'Oregon', value: 'OR' },
|
41
|
-
{ label: 'Pennsylvania', value: 'PA' },
|
42
|
-
{ label: 'Rhode Island', value: 'RI' },
|
43
|
-
{ label: 'South Carolina', value: 'SC' },
|
44
|
-
{ label: 'South Dakota', value: 'SD' },
|
45
|
-
{ label: 'Tennessee', value: 'TN' },
|
46
|
-
{ label: 'Texas', value: 'TX' },
|
47
|
-
{ label: 'Utah', value: 'UT' },
|
48
|
-
{ label: 'Vermont', value: 'VT' },
|
49
|
-
{ label: 'Virginia', value: 'VA' },
|
50
|
-
{ label: 'Washington', value: 'WA' },
|
51
|
-
{ label: 'West Virginia', value: 'WV' },
|
52
|
-
{ label: 'Wisconsin', value: 'WI' },
|
53
|
-
{ label: 'Wyoming', value: 'WY' },
|
54
|
-
];
|
55
|
-
export default states;
|
1
|
+
import { SelectOption } from '../Select/SelectGroup';
|
2
|
+
|
3
|
+
const states: SelectOption<string>[] = [
|
4
|
+
{ label: 'Alabama', value: 'AL' },
|
5
|
+
{ label: 'Alaska', value: 'AK' },
|
6
|
+
{ label: 'Arizona', value: 'AZ' },
|
7
|
+
{ label: 'Arkansas', value: 'AR' },
|
8
|
+
{ label: 'California', value: 'CA' },
|
9
|
+
{ label: 'Colorado', value: 'CO' },
|
10
|
+
{ label: 'Connecticut', value: 'CT' },
|
11
|
+
{ label: 'Delaware', value: 'DE' },
|
12
|
+
{ label: 'Florida', value: 'FL' },
|
13
|
+
{ label: 'Georgia', value: 'GA' },
|
14
|
+
{ label: 'Hawaii', value: 'HI' },
|
15
|
+
{ label: 'Idaho', value: 'ID' },
|
16
|
+
{ label: 'Illinois', value: 'IL' },
|
17
|
+
{ label: 'Indiana', value: 'IN' },
|
18
|
+
{ label: 'Iowa', value: 'IA' },
|
19
|
+
{ label: 'Kansas', value: 'KS' },
|
20
|
+
{ label: 'Kentucky', value: 'KY' },
|
21
|
+
{ label: 'Louisiana', value: 'LA' },
|
22
|
+
{ label: 'Maine', value: 'ME' },
|
23
|
+
{ label: 'Maryland', value: 'MD' },
|
24
|
+
{ label: 'Massachusetts', value: 'MA' },
|
25
|
+
{ label: 'Michigan', value: 'MI' },
|
26
|
+
{ label: 'Minnesota', value: 'MN' },
|
27
|
+
{ label: 'Mississippi', value: 'MS' },
|
28
|
+
{ label: 'Missouri', value: 'MO' },
|
29
|
+
{ label: 'Montana', value: 'MT' },
|
30
|
+
{ label: 'Nebraska', value: 'NE' },
|
31
|
+
{ label: 'Nevada', value: 'NV' },
|
32
|
+
{ label: 'New Hampshire', value: 'NH' },
|
33
|
+
{ label: 'New Jersey', value: 'NJ' },
|
34
|
+
{ label: 'New Mexico', value: 'NM' },
|
35
|
+
{ label: 'New York', value: 'NY' },
|
36
|
+
{ label: 'North Carolina', value: 'NC' },
|
37
|
+
{ label: 'North Dakota', value: 'ND' },
|
38
|
+
{ label: 'Ohio', value: 'OH' },
|
39
|
+
{ label: 'Oklahoma', value: 'OK' },
|
40
|
+
{ label: 'Oregon', value: 'OR' },
|
41
|
+
{ label: 'Pennsylvania', value: 'PA' },
|
42
|
+
{ label: 'Rhode Island', value: 'RI' },
|
43
|
+
{ label: 'South Carolina', value: 'SC' },
|
44
|
+
{ label: 'South Dakota', value: 'SD' },
|
45
|
+
{ label: 'Tennessee', value: 'TN' },
|
46
|
+
{ label: 'Texas', value: 'TX' },
|
47
|
+
{ label: 'Utah', value: 'UT' },
|
48
|
+
{ label: 'Vermont', value: 'VT' },
|
49
|
+
{ label: 'Virginia', value: 'VA' },
|
50
|
+
{ label: 'Washington', value: 'WA' },
|
51
|
+
{ label: 'West Virginia', value: 'WV' },
|
52
|
+
{ label: 'Wisconsin', value: 'WI' },
|
53
|
+
{ label: 'Wyoming', value: 'WY' },
|
54
|
+
];
|
55
|
+
export default states;
|