carbon-react 13.12.0 → 13.12.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/CHANGELOG.md +7 -0
- package/lib/__deprecated__/components/dropdown-filter-ajax/dropdown-filter-ajax.stories.js +1 -4
- package/lib/__spec_helper__/index.js +1 -1
- package/lib/components/table-ajax/table-ajax.stories.js +0 -3
- package/package.json +10 -12
- package/.storybook/utils/xhr/data/countries.js +0 -195
- package/.storybook/utils/xhr/xhr-mock.js +0 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### [13.12.1](https://github.com/Sage/carbon/compare/v13.12.0...v13.12.1) (2022-07-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update react and react-dom to v17 ([b0a5ff2](https://github.com/Sage/carbon/commit/b0a5ff23b3cd62243baef20e4f6837f56bd7fd97))
|
|
7
|
+
|
|
1
8
|
## [13.12.0](https://github.com/Sage/carbon/compare/v13.11.0...v13.12.0) (2020-03-11)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -24,8 +24,6 @@ var _Info = _interopRequireDefault(require("./documentation/Info"));
|
|
|
24
24
|
|
|
25
25
|
var _dropdownFilterAjax = _interopRequireDefault(require("./dropdown-filter-ajax"));
|
|
26
26
|
|
|
27
|
-
var _xhrMock = require("../../../../.storybook/utils/xhr/xhr-mock");
|
|
28
|
-
|
|
29
27
|
var _docgenInfo = _interopRequireDefault(require("../../../utils/helpers/docgen-info"));
|
|
30
28
|
|
|
31
29
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -36,8 +34,7 @@ _dropdownFilterAjax.default.__docgenInfo = (0, _docgenInfo.default)(require('./d
|
|
|
36
34
|
var store = new _storybookState.Store({
|
|
37
35
|
value: '',
|
|
38
36
|
visibleValue: ''
|
|
39
|
-
});
|
|
40
|
-
(0, _xhrMock.enableMock)(); // Shared Props
|
|
37
|
+
}); // Shared Props
|
|
41
38
|
|
|
42
39
|
var onChange = function onChange(evt) {
|
|
43
40
|
store.set({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _enzyme = _interopRequireDefault(require("enzyme"));
|
|
4
4
|
|
|
5
|
-
var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-
|
|
5
|
+
var _enzymeAdapterReact = _interopRequireDefault(require("@wojtekmaj/enzyme-adapter-react-17"));
|
|
6
6
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
@@ -32,8 +32,6 @@ var _storybookState = require("@sambego/storybook-state");
|
|
|
32
32
|
|
|
33
33
|
var _themeSelectors = require("../../../.storybook/theme-selectors");
|
|
34
34
|
|
|
35
|
-
var _xhrMock = require("../../../.storybook/utils/xhr/xhr-mock");
|
|
36
|
-
|
|
37
35
|
var _tableAjax = require("./table-ajax");
|
|
38
36
|
|
|
39
37
|
var _button = _interopRequireDefault(require("../button"));
|
|
@@ -96,7 +94,6 @@ var handleChange = function handleChange(data) {
|
|
|
96
94
|
|
|
97
95
|
function makeStory(name, themeSelector) {
|
|
98
96
|
var component = function component() {
|
|
99
|
-
(0, _xhrMock.enableMock)();
|
|
100
97
|
var pageSize = (0, _addonKnobs.text)('pageSize', '5');
|
|
101
98
|
var paginate = (0, _addonKnobs.boolean)('paginate', _tableAjax.TableAjax.defaultProps.paginate);
|
|
102
99
|
var customHeaders = (0, _addonKnobs.object)('customHeaders', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "13.12.
|
|
3
|
+
"version": "13.12.1",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"engineStrict": true,
|
|
6
6
|
"engines": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/Sage/carbon#readme",
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"react": "^16.12.0",
|
|
52
|
-
"react-dom": "^16.12.0",
|
|
51
|
+
"react": "^16.12.0 || ^17.0.2",
|
|
52
|
+
"react-dom": "^16.12.0 || ^17.0.2",
|
|
53
53
|
"i18n-js": "^3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"@storybook/addon-viewport": "^5.3.3",
|
|
69
69
|
"@storybook/react": "^5.3.3",
|
|
70
70
|
"@types/enzyme": "^3.10.3",
|
|
71
|
-
"@types/enzyme-adapter-react-16": "^1.0.5",
|
|
72
71
|
"@types/jest": "23.3.13",
|
|
73
72
|
"@types/node": "10.12.18",
|
|
74
|
-
"@types/react": "
|
|
75
|
-
"@types/react-dom": "
|
|
73
|
+
"@types/react": "^17.0.2",
|
|
74
|
+
"@types/react-dom": "^17.0.2",
|
|
75
|
+
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
|
|
76
76
|
"babel-standalone": "~6.17.0",
|
|
77
77
|
"carbon-factory": "^11.0.1",
|
|
78
78
|
"carbon-state-management": "^1.0.0",
|
|
@@ -85,7 +85,6 @@
|
|
|
85
85
|
"cypress-cucumber-preprocessor": "^2.0.1",
|
|
86
86
|
"cz-conventional-changelog": "^3.0.2",
|
|
87
87
|
"enzyme": "^3.3.0",
|
|
88
|
-
"enzyme-adapter-react-16": "^1.14.0",
|
|
89
88
|
"enzyme-to-json": "^3.4.0",
|
|
90
89
|
"eslint-plugin-cypress": "^2.0.1",
|
|
91
90
|
"events": "~1.1.1",
|
|
@@ -98,16 +97,15 @@
|
|
|
98
97
|
"mockdate": "^2.0.2",
|
|
99
98
|
"moxios": "^0.4.0",
|
|
100
99
|
"raf": "^3.4.0",
|
|
101
|
-
"react": "^
|
|
100
|
+
"react": "^17.0.2",
|
|
102
101
|
"react-dnd-test-backend": "^10.0.2",
|
|
103
102
|
"react-dnd-test-utils": "^10.0.2",
|
|
104
|
-
"react-dom": "^
|
|
103
|
+
"react-dom": "^17.0.2",
|
|
105
104
|
"react-highlight": "briancappello/react-highlight#react-v16-compiled",
|
|
106
|
-
"react-test-renderer": "^
|
|
105
|
+
"react-test-renderer": "^17.0.2",
|
|
107
106
|
"rimraf": "^2.6.3",
|
|
108
107
|
"semantic-release": "^16.0.1",
|
|
109
|
-
"underscore.string": "~3.3.4"
|
|
110
|
-
"xhr-mock": "git://github.com/resin-io-modules/xhr-mock.git#improvements"
|
|
108
|
+
"underscore.string": "~3.3.4"
|
|
111
109
|
},
|
|
112
110
|
"dependencies": {
|
|
113
111
|
"allure-commandline": "^2.13.0",
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import Immutable from 'immutable';
|
|
2
|
-
|
|
3
|
-
export default Immutable.fromJS([
|
|
4
|
-
{ id: '1', value: 'AF', name: 'Afghanistan' },
|
|
5
|
-
{ id: '2', value: 'AL', name: 'Albania' },
|
|
6
|
-
{ id: '3', value: 'DZ', name: 'Algeria' },
|
|
7
|
-
{ id: '5', value: 'AD', name: 'Andorra' },
|
|
8
|
-
{ id: '6', value: 'AO', name: 'Angola' },
|
|
9
|
-
{ id: '10', value: 'AR', name: 'Argentina' },
|
|
10
|
-
{ id: '11', value: 'AM', name: 'Armenia' },
|
|
11
|
-
{ id: '12', value: 'AW', name: 'Aruba' },
|
|
12
|
-
{ id: '13', value: 'AU', name: 'Australia' },
|
|
13
|
-
{ id: '14', value: 'AT', name: 'Austria' },
|
|
14
|
-
{ id: '15', value: 'AZ', name: 'Azerbaijan' },
|
|
15
|
-
{ id: '16', value: 'BS', name: 'Bahamas' },
|
|
16
|
-
{ id: '17', value: 'BH', name: 'Bahrain' },
|
|
17
|
-
{ id: '18', value: 'BD', name: 'Bangladesh' },
|
|
18
|
-
{ id: '19', value: 'BB', name: 'Barbados' },
|
|
19
|
-
{ id: '20', value: 'BY', name: 'Belarus' },
|
|
20
|
-
{ id: '21', value: 'BE', name: 'Belgium' },
|
|
21
|
-
{ id: '22', value: 'BZ', name: 'Belize' },
|
|
22
|
-
{ id: '23', value: 'BJ', name: 'Benin' },
|
|
23
|
-
{ id: '24', value: 'BM', name: 'Bermuda' },
|
|
24
|
-
{ id: '25', value: 'BT', name: 'Bhutan' },
|
|
25
|
-
{ id: '26', value: 'BO', name: 'Bolivia' },
|
|
26
|
-
{ id: '27', value: 'BA', name: 'Bosnia and Herzegovina' },
|
|
27
|
-
{ id: '28', value: 'BW', name: 'Botswana' },
|
|
28
|
-
{ id: '30', value: 'BR', name: 'Brazil' },
|
|
29
|
-
{ id: '32', value: 'BN', name: 'Brunei Darussalam' },
|
|
30
|
-
{ id: '33', value: 'BG', name: 'Bulgaria' },
|
|
31
|
-
{ id: '34', value: 'BF', name: 'Burkina Faso' },
|
|
32
|
-
{ id: '35', value: 'BI', name: 'Burundi' },
|
|
33
|
-
{ id: '36', value: 'KH', name: 'Cambodia' },
|
|
34
|
-
{ id: '37', value: 'CM', name: 'Cameroon' },
|
|
35
|
-
{ id: '38', value: 'CA', name: 'Canada' },
|
|
36
|
-
{ id: '39', value: 'CV', name: 'Cape Verde' },
|
|
37
|
-
{ id: '40', value: 'KY', name: 'Cayman Islands' },
|
|
38
|
-
{ id: '41', value: 'CF', name: 'Central African Republic' },
|
|
39
|
-
{ id: '42', value: 'TD', name: 'Chad' },
|
|
40
|
-
{ id: '43', value: 'CL', name: 'Chile' },
|
|
41
|
-
{ id: '44', value: 'CN', name: 'China' },
|
|
42
|
-
{ id: '47', value: 'CO', name: 'Colombia' },
|
|
43
|
-
{ id: '48', value: 'KM', name: 'Comoros' },
|
|
44
|
-
{ id: '49', value: 'CG', name: 'Congo' },
|
|
45
|
-
{ id: '51', value: 'CR', name: 'Costa Rica' },
|
|
46
|
-
{ id: '52', value: 'HR', name: 'Croatia' },
|
|
47
|
-
{ id: '53', value: 'CU', name: 'Cuba' },
|
|
48
|
-
{ id: '54', value: 'CY', name: 'Cyprus' },
|
|
49
|
-
{ id: '55', value: 'CZ', name: 'Czech Republic' },
|
|
50
|
-
{ id: '56', value: 'DK', name: 'Denmark' },
|
|
51
|
-
{ id: '57', value: 'DJ', name: 'Djibouti' },
|
|
52
|
-
{ id: '58', value: 'DM', name: 'Dominica' },
|
|
53
|
-
{ id: '59', value: 'DO', name: 'Dominican Republic' },
|
|
54
|
-
{ id: '60', value: 'TP', name: 'East Timor' },
|
|
55
|
-
{ id: '61', value: 'EC', name: 'Ecuador' },
|
|
56
|
-
{ id: '62', value: 'EG', name: 'Egypt' },
|
|
57
|
-
{ id: '63', value: 'SV', name: 'El Salvador' },
|
|
58
|
-
{ id: '64', value: 'GQ', name: 'Equatorial Guinea' },
|
|
59
|
-
{ id: '65', value: 'ER', name: 'Eritrea' },
|
|
60
|
-
{ id: '66', value: 'EE', name: 'Estonia' },
|
|
61
|
-
{ id: '67', value: 'ET', name: 'Ethiopia' },
|
|
62
|
-
{ id: '70', value: 'FJ', name: 'Fiji' },
|
|
63
|
-
{ id: '71', value: 'FI', name: 'Finland' },
|
|
64
|
-
{ id: '72', value: 'FR', name: 'France' },
|
|
65
|
-
{ id: '76', value: 'GA', name: 'Gabon' },
|
|
66
|
-
{ id: '77', value: 'GM', name: 'Gambia' },
|
|
67
|
-
{ id: '78', value: 'GE', name: 'Georgia' },
|
|
68
|
-
{ id: '79', value: 'DE', name: 'Germany' },
|
|
69
|
-
{ id: '80', value: 'GH', name: 'Ghana' },
|
|
70
|
-
{ id: '81', value: 'GI', name: 'Gibraltar' },
|
|
71
|
-
{ id: '82', value: 'GR', name: 'Greece' },
|
|
72
|
-
{ id: '84', value: 'GD', name: 'Grenada' },
|
|
73
|
-
{ id: '85', value: 'GP', name: 'Guadaloupe' },
|
|
74
|
-
{ id: '86', value: 'GU', name: 'Guam' },
|
|
75
|
-
{ id: '87', value: 'GT', name: 'Guatemala' },
|
|
76
|
-
{ id: '88', value: 'GN', name: 'Guinea' },
|
|
77
|
-
{ id: '90', value: 'GY', name: 'Guyana' },
|
|
78
|
-
{ id: '91', value: 'HT', name: 'Haiti' },
|
|
79
|
-
{ id: '93', value: 'HN', name: 'Honduras' },
|
|
80
|
-
{ id: '94', value: 'HK', name: 'Hong Kong' },
|
|
81
|
-
{ id: '95', value: 'HU', name: 'Hungary' },
|
|
82
|
-
{ id: '96', value: 'IS', name: 'Iceland' },
|
|
83
|
-
{ id: '97', value: 'IN', name: 'India' },
|
|
84
|
-
{ id: '98', value: 'ID', name: 'Indonesia' },
|
|
85
|
-
{ id: '99', value: 'IR', name: 'Iran' },
|
|
86
|
-
{ id: '100', value: 'IQ', name: 'Iraq' },
|
|
87
|
-
{ id: '101', value: 'IE', name: 'Ireland' },
|
|
88
|
-
{ id: '102', value: 'IL', name: 'Israel' },
|
|
89
|
-
{ id: '103', value: 'IT', name: 'Italy' },
|
|
90
|
-
{ id: '104', value: 'CI', name: 'Ivory Coast' },
|
|
91
|
-
{ id: '105', value: 'JM', name: 'Jamaica' },
|
|
92
|
-
{ id: '106', value: 'JP', name: 'Japan' },
|
|
93
|
-
{ id: '107', value: 'JO', name: 'Jordan' },
|
|
94
|
-
{ id: '108', value: 'KZ', name: 'Kazakhstan' },
|
|
95
|
-
{ id: '109', value: 'KE', name: 'Kenya' },
|
|
96
|
-
{ id: '110', value: 'KP', name: 'North Korea' },
|
|
97
|
-
{ id: '111', value: 'KR', name: 'South Korea' },
|
|
98
|
-
{ id: '112', value: 'KW', name: 'Kuwait' },
|
|
99
|
-
{ id: '113', value: 'KG', name: 'Kyrgyzstan' },
|
|
100
|
-
{ id: '114', value: 'LA', name: 'Laos' },
|
|
101
|
-
{ id: '115', value: 'LV', name: 'Latvia' },
|
|
102
|
-
{ id: '116', value: 'LN', name: 'Lebanon' },
|
|
103
|
-
{ id: '117', value: 'LS', name: 'Lesotho' },
|
|
104
|
-
{ id: '118', value: 'LR', name: 'Liberia' },
|
|
105
|
-
{ id: '119', value: 'LY', name: 'Libya' },
|
|
106
|
-
{ id: '120', value: 'LI', name: 'Liechtenstein' },
|
|
107
|
-
{ id: '121', value: 'LT', name: 'Lithuania' },
|
|
108
|
-
{ id: '122', value: 'LU', name: 'Luxembourg' },
|
|
109
|
-
{ id: '123', value: 'MO', name: 'Macau' },
|
|
110
|
-
{ id: '124', value: 'MK', name: 'Macedonia' },
|
|
111
|
-
{ id: '125', value: 'MG', name: 'Madagascar' },
|
|
112
|
-
{ id: '126', value: 'MW', name: 'Malawi' },
|
|
113
|
-
{ id: '127', value: 'MY', name: 'Malaysia' },
|
|
114
|
-
{ id: '128', value: 'MV', name: 'Maldives' },
|
|
115
|
-
{ id: '129', value: 'ML', name: 'Mali' },
|
|
116
|
-
{ id: '130', value: 'MT', name: 'Malta' },
|
|
117
|
-
{ id: '134', value: 'MU', name: 'Mauritius' },
|
|
118
|
-
{ id: '136', value: 'MX', name: 'Mexico' },
|
|
119
|
-
{ id: '138', value: 'MD', name: 'Moldova' },
|
|
120
|
-
{ id: '139', value: 'MC', name: 'Monaco' },
|
|
121
|
-
{ id: '140', value: 'MN', name: 'Mongolia' },
|
|
122
|
-
{ id: '235', value: 'ME', name: 'Montenegro' },
|
|
123
|
-
{ id: '142', value: 'MA', name: 'Morocco' },
|
|
124
|
-
{ id: '143', value: 'MZ', name: 'Mozambique' },
|
|
125
|
-
{ id: '145', value: 'NA', name: 'Namibia' },
|
|
126
|
-
{ id: '147', value: 'NP', name: 'Nepal' },
|
|
127
|
-
{ id: '148', value: 'NL', name: 'Netherlands' },
|
|
128
|
-
{ id: '149', value: 'AN', name: 'Netherlands Antilles' },
|
|
129
|
-
{ id: '152', value: 'NZ', name: 'New Zealand' },
|
|
130
|
-
{ id: '153', value: 'NI', name: 'Nicaragua' },
|
|
131
|
-
{ id: '154', value: 'NE', name: 'Niger' },
|
|
132
|
-
{ id: '155', value: 'NG', name: 'Nigeria' },
|
|
133
|
-
{ id: '158', value: 'NO', name: 'Norway' },
|
|
134
|
-
{ id: '159', value: 'OM', name: 'Oman' },
|
|
135
|
-
{ id: '160', value: 'PK', name: 'Pakistan' },
|
|
136
|
-
{ id: '162', value: 'PA', name: 'Panama' },
|
|
137
|
-
{ id: '163', value: 'PG', name: 'Papua New Guinea' },
|
|
138
|
-
{ id: '164', value: 'PY', name: 'Paraguay' },
|
|
139
|
-
{ id: '165', value: 'PE', name: 'Peru' },
|
|
140
|
-
{ id: '166', value: 'PH', name: 'Philippines' },
|
|
141
|
-
{ id: '168', value: 'PL', name: 'Poland' },
|
|
142
|
-
{ id: '169', value: 'PT', name: 'Portugal' },
|
|
143
|
-
{ id: '170', value: 'PR', name: 'Puerto Rico' },
|
|
144
|
-
{ id: '171', value: 'QA', name: 'Qatar' },
|
|
145
|
-
{ id: '173', value: 'RO', name: 'Romania' },
|
|
146
|
-
{ id: '174', value: 'RU', name: 'Russia' },
|
|
147
|
-
{ id: '175', value: 'RW', name: 'Rwanda' },
|
|
148
|
-
{ id: '178', value: 'LC', name: 'St. Lucia' },
|
|
149
|
-
{ id: '181', value: 'WS', name: 'Samoa' },
|
|
150
|
-
{ id: '182', value: 'SM', name: 'San Marino' },
|
|
151
|
-
{ id: '183', value: 'ST', name: 'Sao Tome and Principe' },
|
|
152
|
-
{ id: '184', value: 'SA', name: 'Saudi Arabia' },
|
|
153
|
-
{ id: '234', value: 'RS', name: 'Serbia' },
|
|
154
|
-
{ id: '185', value: 'SN', name: 'Senegal' },
|
|
155
|
-
{ id: '186', value: 'SC', name: 'Seychelles' },
|
|
156
|
-
{ id: '187', value: 'SL', name: 'Sierra Leone' },
|
|
157
|
-
{ id: '188', value: 'SG', name: 'Singapore' },
|
|
158
|
-
{ id: '189', value: 'SK', name: 'Slovakia' },
|
|
159
|
-
{ id: '190', value: 'SI', name: 'Slovenia' },
|
|
160
|
-
{ id: '191', value: 'SB', name: 'Solomon Islands' },
|
|
161
|
-
{ id: '192', value: 'SO', name: 'Somalia' },
|
|
162
|
-
{ id: '193', value: 'ZA', name: 'South Africa' },
|
|
163
|
-
{ id: '194', value: 'ES', name: 'Spain' },
|
|
164
|
-
{ id: '195', value: 'LK', name: 'Sri Lanka' },
|
|
165
|
-
{ id: '196', value: 'SD', name: 'Sudan' },
|
|
166
|
-
{ id: '197', value: 'SR', name: 'Surinam' },
|
|
167
|
-
{ id: '199', value: 'SZ', name: 'Swaziland' },
|
|
168
|
-
{ id: '200', value: 'SE', name: 'Sweden' },
|
|
169
|
-
{ id: '201', value: 'CH', name: 'Switzerland' },
|
|
170
|
-
{ id: '202', value: 'SY', name: 'Syria' },
|
|
171
|
-
{ id: '203', value: 'TW', name: 'Taiwan' },
|
|
172
|
-
{ id: '204', value: 'TJ', name: 'Tajikistan' },
|
|
173
|
-
{ id: '205', value: 'TZ', name: 'Tanzania' },
|
|
174
|
-
{ id: '206', value: 'TH', name: 'Thailand' },
|
|
175
|
-
{ id: '207', value: 'TG', name: 'Togo' },
|
|
176
|
-
{ id: '209', value: 'TO', name: 'Tonga' },
|
|
177
|
-
{ id: '210', value: 'TT', name: 'Trinidad and Tobago' },
|
|
178
|
-
{ id: '211', value: 'TN', name: 'Tunisia' },
|
|
179
|
-
{ id: '212', value: 'TR', name: 'Turkey' },
|
|
180
|
-
{ id: '215', value: 'UG', name: 'Uganda' },
|
|
181
|
-
{ id: '216', value: 'UA', name: 'Ukraine' },
|
|
182
|
-
{ id: '217', value: 'AE', name: 'United Arab Emirates' },
|
|
183
|
-
{ id: '218', value: 'GB', name: 'United Kingdom' },
|
|
184
|
-
{ id: '219', value: 'US', name: 'United States' },
|
|
185
|
-
{ id: '221', value: 'UY', name: 'Uruguay' },
|
|
186
|
-
{ id: '222', value: 'UZ', name: 'Uzbekistan' },
|
|
187
|
-
{ id: '224', value: 'VE', name: 'Venezuela' },
|
|
188
|
-
{ id: '225', value: 'VN', name: 'Vietnam' },
|
|
189
|
-
{ id: '226', value: 'VI', name: 'Virgin Islands U.S.' },
|
|
190
|
-
{ id: '228', value: 'EH', name: 'Western Sahara' },
|
|
191
|
-
{ id: '229', value: 'YE', name: 'Yemen' },
|
|
192
|
-
{ id: '231', value: 'ZR', name: 'Zaire' },
|
|
193
|
-
{ id: '232', value: 'ZM', name: 'Zambia' },
|
|
194
|
-
{ id: '233', value: 'ZW', name: 'Zimbabwe' }
|
|
195
|
-
]);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import mock from 'xhr-mock';
|
|
2
|
-
import escapeStringRegexp from 'escape-string-regexp';
|
|
3
|
-
import countries from './data/countries';
|
|
4
|
-
|
|
5
|
-
export function disableMock() {
|
|
6
|
-
mock.teardown();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function enableMock() {
|
|
10
|
-
mock.setup();
|
|
11
|
-
|
|
12
|
-
mock.get(/countries/, (req, res) => {
|
|
13
|
-
let query = req.query(),
|
|
14
|
-
filter = query.value || query.name || "",
|
|
15
|
-
filteredCountries = countries,
|
|
16
|
-
text = decodeURIComponent(filter),
|
|
17
|
-
page = Number(query.page),
|
|
18
|
-
rows = Number(query.rows),
|
|
19
|
-
skip = (page - 1) * rows,
|
|
20
|
-
regex = new RegExp(escapeStringRegexp(text), "i");
|
|
21
|
-
|
|
22
|
-
filteredCountries = filteredCountries.filter((item) => {
|
|
23
|
-
return item.get('name').search(regex) > -1;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (query.sord && query.sidx) {
|
|
27
|
-
filteredCountries = filteredCountries.sort((a, b) => {
|
|
28
|
-
if (query.sord === "asc") {
|
|
29
|
-
return a.get(query.sidx).localeCompare(b.get(query.sidx));
|
|
30
|
-
} else {
|
|
31
|
-
return b.get(query.sidx).localeCompare(a.get(query.sidx));
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let numberOfResults = filteredCountries.count();
|
|
37
|
-
|
|
38
|
-
let i = 0;
|
|
39
|
-
filteredCountries = filteredCountries.skip(skip).takeUntil(() => {
|
|
40
|
-
i++;
|
|
41
|
-
return(i == (rows + 1));
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
let data = {
|
|
45
|
-
rows: filteredCountries.toJS(),
|
|
46
|
-
records: numberOfResults,
|
|
47
|
-
current_page: page,
|
|
48
|
-
data: [{items: filteredCountries, page: page, records: numberOfResults }]
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
return res
|
|
52
|
-
.status(201)
|
|
53
|
-
.header('Content-Type', 'application/json')
|
|
54
|
-
.body(JSON.stringify(data));
|
|
55
|
-
});
|
|
56
|
-
}
|