@financial-times/n-conversion-forms 41.0.0 → 41.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.toolkitstate/ci.json
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import regionConfigByCountry from '../utils/region-config-by-country';
|
|
6
6
|
|
|
7
7
|
export function RegionSelector({
|
|
8
8
|
country = 'USA',
|
|
@@ -20,7 +20,7 @@ export function RegionSelector({
|
|
|
20
20
|
regions = [],
|
|
21
21
|
defaultRegionType,
|
|
22
22
|
label: defaultLabel,
|
|
23
|
-
} =
|
|
23
|
+
} = regionConfigByCountry[country];
|
|
24
24
|
|
|
25
25
|
const dynamicRegionType = regionType || defaultRegionType;
|
|
26
26
|
const dynamicLabel = isBillingSelector
|
package/dist/region-selector.jsx
CHANGED
|
@@ -8,7 +8,7 @@ exports.RegionSelector = RegionSelector;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var
|
|
11
|
+
var _regionConfigByCountry = _interopRequireDefault(require("../utils/region-config-by-country"));
|
|
12
12
|
function RegionSelector(_ref) {
|
|
13
13
|
var _ref$country = _ref.country,
|
|
14
14
|
country = _ref$country === void 0 ? 'USA' : _ref$country,
|
|
@@ -25,11 +25,11 @@ function RegionSelector(_ref) {
|
|
|
25
25
|
regionType = _ref.regionType,
|
|
26
26
|
selectId = _ref.selectId,
|
|
27
27
|
value = _ref.value;
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
regions =
|
|
31
|
-
defaultRegionType =
|
|
32
|
-
defaultLabel =
|
|
28
|
+
var _regionConfigByCountr = _regionConfigByCountry["default"][country],
|
|
29
|
+
_regionConfigByCountr2 = _regionConfigByCountr.regions,
|
|
30
|
+
regions = _regionConfigByCountr2 === void 0 ? [] : _regionConfigByCountr2,
|
|
31
|
+
defaultRegionType = _regionConfigByCountr.defaultRegionType,
|
|
32
|
+
defaultLabel = _regionConfigByCountr.label;
|
|
33
33
|
var dynamicRegionType = regionType || defaultRegionType;
|
|
34
34
|
var dynamicLabel = isBillingSelector ? "Billing ".concat(label || defaultLabel) : label || defaultLabel;
|
|
35
35
|
var dynamicFieldId = fieldId || "".concat(dynamicRegionType, "Field");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@financial-times/n-conversion-forms",
|
|
3
|
-
"version": "41.0.
|
|
3
|
+
"version": "41.0.1",
|
|
4
4
|
"description": "Containing jsx components and styles for forms included on Accounts and Acquisition apps (next-signup, next-profile, next-retention, etc).",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const {
|
|
2
|
+
americanStates,
|
|
3
|
+
canadianProvinces,
|
|
4
|
+
indianStatesAndUnionTerritories,
|
|
5
|
+
} = require('n-common-static-data');
|
|
6
|
+
|
|
7
|
+
const regionConfigByCountry = {
|
|
8
|
+
USA: {
|
|
9
|
+
regions: americanStates.states,
|
|
10
|
+
defaultRegionType: 'state',
|
|
11
|
+
label: 'State',
|
|
12
|
+
},
|
|
13
|
+
CAN: {
|
|
14
|
+
regions: canadianProvinces.provinces,
|
|
15
|
+
defaultRegionType: 'province',
|
|
16
|
+
label: 'Province',
|
|
17
|
+
},
|
|
18
|
+
IND: {
|
|
19
|
+
regions: indianStatesAndUnionTerritories.states,
|
|
20
|
+
defaultRegionType: 'state',
|
|
21
|
+
label: 'State/Union Territory',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
module.exports = regionConfigByCountry;
|
package/utils/region-selector.js
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
canadianProvinces,
|
|
4
|
-
indianStatesAndUnionTerritories,
|
|
5
|
-
} from 'n-common-static-data';
|
|
6
|
-
import FormElement from './form-element';
|
|
7
|
-
|
|
8
|
-
export const configByCountry = {
|
|
9
|
-
USA: {
|
|
10
|
-
regions: americanStates.states,
|
|
11
|
-
defaultRegionType: 'state',
|
|
12
|
-
label: 'State',
|
|
13
|
-
},
|
|
14
|
-
CAN: {
|
|
15
|
-
regions: canadianProvinces.provinces,
|
|
16
|
-
defaultRegionType: 'province',
|
|
17
|
-
label: 'Province',
|
|
18
|
-
},
|
|
19
|
-
IND: {
|
|
20
|
-
regions: indianStatesAndUnionTerritories.states,
|
|
21
|
-
defaultRegionType: 'state',
|
|
22
|
-
label: 'State/Union Territory',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
1
|
+
const FormElement = require('./form-element');
|
|
2
|
+
const regionConfigByCountry = require('./region-config-by-country');
|
|
25
3
|
|
|
26
4
|
/**
|
|
27
5
|
* Class representing a region selector form element.
|
|
@@ -41,7 +19,7 @@ class RegionSelector extends FormElement {
|
|
|
41
19
|
*/
|
|
42
20
|
constructor(document, { country = 'USA', regionType, fieldId } = {}) {
|
|
43
21
|
const defaultRegionType =
|
|
44
|
-
regionType ||
|
|
22
|
+
regionType || regionConfigByCountry[country].defaultRegionType;
|
|
45
23
|
|
|
46
24
|
const selector = fieldId
|
|
47
25
|
? `.ncf #${fieldId}`
|
|
@@ -51,4 +29,4 @@ class RegionSelector extends FormElement {
|
|
|
51
29
|
}
|
|
52
30
|
}
|
|
53
31
|
|
|
54
|
-
|
|
32
|
+
module.exports = RegionSelector;
|