Repository navigation
v2.3.0 — Gridory
·
10 commits
to main
since this release
Minor release of Gridory: CountrySelect and PhoneInput cover what a form needs to replace its own country and
phone pickers, and the country catalog gets its own entry. Everything new is opt-in: without the new props both
controls render and emit exactly what they did in 2.2.0.
English
Upgrade
npm install gridory@2.3.0New
- Country catalog:
gridory/countries.CountryFlag,getCountryName(code, locale?),getDialCode(code),
findCountryByDialCode(dialCode),listCountries(locale?)andisCountryCode, to show countries in a table, a
card or a filter without loading the selects (about 2.5 KB gzip, no Radix, no icons). The 14 dial codes shared by
several countries always give their most populous one, from a fixed table:+1is the United States. idandname. On the number ofPhoneInputand on the combobox ofCountrySelect: an outside
<label htmlFor>works, and a form can move the focus to its first error by id or by name.disabled. On both controls: nativedisabledon their buttons and inputs, an open list closes, the box
carriesdata-disabled, and the look comes from--gdy-country-select-disabled-*and
--gdy-phone-input-disabled-*(opacity 0.5 and the muted background by default).- "Not applicable" in
CountrySelect.notApplicableOptionadds it as the first option, single selection only.
It is an answer, apart fromnulland from every country:requiredtakes it. Its value is
COUNTRY_NOT_APPLICABLE("not-applicable") or your ownnotApplicableValue(""works; a country code throws
InvalidNotApplicableValueError, and mind that"NA"is Namibia). Its text, "No aplica" by default, is
texts.notApplicable, and it is used in the list, the field and the search. - Number rule in
PhoneInput.numberCharacters="digits"keeps digits only ("phone", the 2.2.0 rule, stays the
default);maxNumberLengthlimits the length after that rule;splitPastedDialCodeturns a pasted
+51 987 654 321into Peru in the prefix and987654321in the number, in a singleonValueChange.
<CountrySelect id="country" name="country" required notApplicableOption disabled={isSaving} />
<PhoneInput id="whatsapp" name="whatsapp" numberCharacters="digits" maxNumberLength={9} splitPastedDialCode />Good to know
- The character rule and the maximum apply to what is typed or pasted; the initial value is shown as given. The rule
filters the whole value on each change, as in 2.2.0: editing an old987654321 / 912345678in digits mode joins
both numbers. - A paste is split only when it starts with
+, the dial code is known and it replaces the whole number. Area codes
are not read: a pasted+1 809…picks the United States unless a+1country was already chosen. - Types:
CountrySelectPropsis now generic,CountrySelectProps<TNotApplicable = CountryNotApplicable>, and its
union has a third member,NotApplicableCountrySelectProps. Rendering<CountrySelect … />compiles as before,
wrappers typed withCountrySelectPropsincluded. Only code that readsprops.valuefrom aCountrySelectProps
object sees the wider type.CountrySelectTexts.notApplicableis optional, so a full texts object written for
2.2.0 still compiles. - In the selects nothing changes without the new props: same ids, no name, same list, same paste.
See the Country select,
Phone input and
Countries guides.
Español
Actualizar
npm install gridory@2.3.0Novedades
- Catálogo de países:
gridory/countries.CountryFlag,getCountryName(code, locale?),getDialCode(code),
findCountryByDialCode(dialCode),listCountries(locale?)eisCountryCode, para mostrar países en una tabla, una
ficha o un filtro sin cargar los selectores (unos 2,5 KB gzip, sin Radix ni íconos). Los 14 prefijos que comparten
varios países devuelven siempre el más poblado, de una tabla fija:+1es EE. UU. idyname. En el número dePhoneInputy en el combobox deCountrySelect: funciona un<label htmlFor>
externo, y un formulario puede llevar el foco a su primer error por id o por nombre.disabled. En los dos controles:disablednativo en sus botones e inputs, la lista abierta se cierra, la caja
llevadata-disabledy el aspecto sale de--gdy-country-select-disabled-*y--gdy-phone-input-disabled-*
(opacidad 0,5 y el fondo apagado por defecto).- "No aplica" en
CountrySelect.notApplicableOptionla suma como primera opción, solo en selección simple. Es
una respuesta, distinta denully de cualquier país:requiredla acepta. Su valor esCOUNTRY_NOT_APPLICABLE
("not-applicable") o tu propionotApplicableValue(sirve""; un código de país lanza
InvalidNotApplicableValueError, y ojo que"NA"es Namibia). Su texto, "No aplica" por defecto, es
texts.notApplicable, y se usa en la lista, en el campo y en la búsqueda. - Regla del número en
PhoneInput.numberCharacters="digits"guarda solo dígitos ("phone", la regla de la
2.2.0, sigue por defecto);maxNumberLengthlimita el largo después de esa regla;splitPastedDialCodeconvierte un
+51 987 654 321pegado en Perú en el prefijo y987654321en el número, en un soloonValueChange.
<CountrySelect id="country" name="country" required notApplicableOption disabled={isSaving} />
<PhoneInput id="whatsapp" name="whatsapp" numberCharacters="digits" maxNumberLength={9} splitPastedDialCode />Para tener en cuenta
- La regla de caracteres y el máximo se aplican a lo que se escribe o se pega; el valor inicial se muestra tal cual.
La regla filtra el valor entero en cada cambio, como en la 2.2.0: editar un987654321 / 912345678viejo en modo
dígitos junta los dos números. - Un pegado se separa solo si empieza con
+, el prefijo es conocido y reemplaza todo el número. No se leen códigos
de área: un+1 809…pegado elige EE. UU. salvo que ya hubiera un país+1elegido. - Tipos:
CountrySelectPropsahora es genérico,CountrySelectProps<TNotApplicable = CountryNotApplicable>, y su
unión tiene un tercer miembro,NotApplicableCountrySelectProps. Renderizar<CountrySelect … />compila igual
que antes, también desde envoltorios tipados conCountrySelectProps. Solo el código que leeprops.valuede un
objetoCountrySelectPropsve el tipo más amplio.CountrySelectTexts.notApplicablees opcional, así un objeto de
textos completo escrito para la 2.2.0 sigue compilando. - En los selectores nada cambia sin las props nuevas: mismos ids, sin name, la misma lista y el mismo pegado.
Ver las guías del Selector de país,
del Teléfono con prefijo y de
Países.