chrisebert / strapi-plugin-country-select Goto Github PK
View Code? Open in Web Editor NEWA strapi custom field for selecting any country based on the ISO 3166-1 country code standard.
License: MIT License
A strapi custom field for selecting any country based on the ISO 3166-1 country code standard.
License: MIT License
A recent change in the Combobox
Strapi design system makes it so that the clear callback needs to be defined, else the clear icon doesn't show up and it's impossible to unset the value of the field.
I fixed the issue by adding this function inside the CountrySelect component:
(...)
const isValidValue = !value || parsedOptions.hasOwnProperty(value);
const handleClear = () => {
onChange({
target: {
name: name,
value: '',
type: attribute.type,
},
});
};
(...)
...and by linking it to the Combobox component clear
attribute:
(...)
<Combobox
placeholder={placeholder && formatMessage(placeholder)}
aria-label={formatMessage(intlLabel)}
aria-disabled={disabled}
disabled={disabled}
value={isValidValue ? value : null}
onChange={countryCode => onChange({ target: { name, value: countryCode, type: attribute.type }})}
onClear={handleClear}
>
(...)
When using the plugin with languages other than the default ones (en, de, fr), the translations from i18n-iso-countries
are not being applied correctly. The translation files are loaded in the browser as JavaScript files, but they are not populating the necessary fields. However, when switching to any of the default languages, the country translations load properly.
Steps to Reproduce:
uk
).Expected Behavior:
Translations from i18n-iso-countries
should be applied correctly for all supported languages, not just the default ones.
Actual Behavior:
Translations are not being applied for languages other than the default ones.
Environment:
First off, what an awesome custom field you've built! Just installed it.
A nice addition to this, that I'm sure you've thought about, would be to allow selection of multiple countries.
Let me know what you think.
i cant get the country name tanzania in [strapi-plugin-country-select] please fix this ASAP
Hi and thank you for your work on this plugin, it's so useful!
I was wondering how much work it would be to add a "Default country" to the settings? So that this country is then automatically pre-selected. I hope it's clear what I mean.
Cheers!
This can lead to very bad surprises. I added the component and sent a country name ("France") instead of its code ("FR"). That made the content manager crash for my content-type.
Some countries or codes may not be available in i18n-iso-countries
.
For example, "UK" is an alias of "GB", "TP" was used instead of "TL" (Timor-Leste) before, ...
Could we make extending the country list possible?
The goal would be to be able to configure some per-locale json files with extra countries in the project's code and to load that json files from the plugin (some dynamic import but coming from a file in the Strapi project, with exception handling if no json has been defined).
For example, with the following .../en.json
in the Strapi project:
{
"TP": "Timor-Leste (TP)",
"UK": ["United Kingdom (UK)", "UK (UK)", "Great Britain (UK)"]
}
We'd have, in the component list:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.