Skip to content

Commit

Permalink
Update country-region-data
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Nov 22, 2024
1 parent d7b3232 commit 27a9389
Show file tree
Hide file tree
Showing 10 changed files with 46,408 additions and 18,870 deletions.
245 changes: 122 additions & 123 deletions README.md

Large diffs are not rendered by default.

64,020 changes: 45,745 additions & 18,275 deletions example/package-lock.json

Large diffs are not rendered by default.

874 changes: 468 additions & 406 deletions example/src/Examples.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import Examples from './Examples';

const root = ReactDOM.createRoot(document.getElementById("examples"));
const root = ReactDOM.createRoot(document.getElementById('examples'));

root.render(<Examples />);
root.render(<Examples />);
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Project: https://github.com/country-regions/react-country-region-selector
// Definitions by: Kyle Davis <https://github.com/kyledavisdev>, Ben Keen <https://github.com/benkeen>

import * as React from "react";
import * as React from 'react';

export type ValueType = "full" | "short";
export type ValueType = 'full' | 'short';

export interface CountryDropdownProps<T = Element> {
/**
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-country-region-selector",
"version": "3.6.1",
"version": "3.7.0",
"description": "CountryDropdown and RegionDropdown React components for your forms.",
"author": "country-regions",
"license": "MIT",
Expand Down Expand Up @@ -37,7 +37,7 @@
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"country-region-data": "^2.6.0",
"country-region-data": "^3.1.0",
"cross-env": "^5.1.4",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
Expand Down
56 changes: 30 additions & 26 deletions rollup-plugin-parse-country-list.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
export default (options = {}) => {
const convertFormat = (countries) => {
return countries.map((countryData) => [
countryData.countryName,
countryData.countryShortCode,
countryData.regions
.map((regionData) => `${regionData.name}~${regionData.shortCode}`)
.join('|'),
]);
};

const convertFormat = (countries) => {
return countries.map((countryData) => [
countryData.countryName,
countryData.countryShortCode,
countryData.regions.map((regionData) => `${regionData.name}~${regionData.shortCode}`).join('|')
]);
};
return {
name: 'ParseCountryList',
transform: (source, id) => {
if (!/country-region-data\/data\.json$/.test(id)) {
return;
}

return {
name: 'ParseCountryList',
transform: (source, id) => {
if (!(/country-region-data\/data\.json$/.test(id))) {
return;
}
let json = JSON.parse(source);

let json = JSON.parse(source);
// filter out those countries that the user wants
if (options.countries.length > 0) {
json = json.filter(
(countryData) =>
options.countries.indexOf(countryData.countryShortCode) !== -1
);
}

// filter out those countries that the user wants
if (options.countries.length > 0) {
json = json.filter((countryData) => options.countries.indexOf(countryData.countryShortCode) !== -1);
}

// and return the converted data structure for bundling with the script
return {
code: JSON.stringify(convertFormat(json)),
map: { mappings: '' }
};
}
};
// and return the converted data structure for bundling with the script
return {
code: JSON.stringify(convertFormat(json)),
map: { mappings: '' },
};
},
};
};
55 changes: 29 additions & 26 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,36 @@ const argv = require('minimist')(process.argv.slice(2));
// e.g. rollup -c --config-countries=GB,CA,US
let countries = [];
if (argv.hasOwnProperty('config-countries')) {
countries = argv['config-countries'].split(',');
countries = argv['config-countries'].split(',');
}

export default {
input: 'src/index.js',
output: [{
file: pkg.main,
format: 'cjs',
sourcemap: true
}, {
file: pkg.module,
format: 'es',
sourcemap: true
}],
plugins: [
parseCountryList({ countries }),
external(),
postcss({
modules: true
}),
json(),
url(),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers']
}),
resolve(),
commonjs()
]
input: 'src/index.js',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
},
],
plugins: [
parseCountryList({ countries }),
external(),
postcss({
modules: true,
}),
json(),
url(),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
}),
resolve(),
commonjs(),
],
};
8 changes: 4 additions & 4 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
DISPLAY_TYPE_FULL: 'full',
DISPLAY_TYPE_SHORT: 'short',
REGION_LIST_DELIMITER: '|',
SINGLE_REGION_DELIMITER: '~'
DISPLAY_TYPE_FULL: 'full',
DISPLAY_TYPE_SHORT: 'short',
REGION_LIST_DELIMITER: '|',
SINGLE_REGION_DELIMITER: '~',
};

0 comments on commit 27a9389

Please sign in to comment.