UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

3 lines (2 loc) 1.16 kB
"use client"; import{jsxs as e,jsx as o}from"react/jsx-runtime";import t from"@mui/material/Select";import{useMemo as l}from"react";import r from"@mui/material/MenuItem";import{CountrySelectItem as n}from"./CountrySelectItem.js";import{countries as a}from"../../util/constants.js";import{useTranslate as i}from"../../locales/index.js";import m from"../locale.json.js";const s="NexusCountrySelect",c=c=>{const{includeNoneOption:u=!1,onChange:d,includeCountries:p,excludeCountries:f=[],...C}=c,h=i(m,"FormSelect"),$=l((()=>a.map((e=>({label:e.label,value:e.label,code:e.code}))).filter((e=>!(p&&p.length>0)||p.includes(e.code.toLowerCase()))).filter((e=>!(f&&f.length>0)||!f.includes(e.code.toLowerCase())))),[p,f]);return e(t,{inputProps:{"aria-label":"Country select"},"data-testid":`${s}-root`,className:`${s}-root`,onChange:e=>{d?.(e.target.value)},...C,children:[u&&o(r,{"data-testid":`${s}-option-none`,className:`${s}-option`,value:"",children:o("em",{children:h("None")})},"option-none"),$.map((e=>o(r,{"data-testid":`${s}-option-${e.label}`,className:`${s}-option`,value:e.value,children:o(n,{option:e})},e.value)))]})};export{c as CountrySelect};