npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@inverz/thai-nationality

v1.0.1

Published

Thai race (เชื้อชาติ) and nationality (สัญชาติ) select for React: all 272 THCC / DOPA codes with English names and ISO country codes

Readme

@inverz/thai-nationality

ช่องเลือก เชื้อชาติ และ สัญชาติ สำหรับ React ใช้รหัสมาตรฐาน รหัสเชื้อชาติ-สัญชาติ 3 หลัก 272 รายการ ชุดเดียวกับที่ใช้ในทะเบียนราษฎรและระบบสาธารณสุข (เช่น 099 ไทย, 048 เมียนมา) พร้อมชื่อภาษาอังกฤษ รหัสประเทศ ISO และจัดการรหัสที่ยกเลิกแล้วให้ มีฟังก์ชันแยกให้ใช้ฝั่ง server โดยไม่ต้องมี React

ดูตัวอย่าง (Demo)

React race and nationality selects using Thailand's standard 3-digit race / nationality codes (272 entries, THCC), with English names, ISO 3166 country codes and retired-code handling. React-free helpers for the server.

ติดตั้ง

npm i @inverz/thai-nationality
import "@inverz/thai-nationality/style.css"; // ไม่บังคับ
import { RaceNationalityInput, NationalitySelect, findNationality } from "@inverz/thai-nationality";

RaceNationalityInput

const [person, setPerson] = useState({});

<RaceNationalityInput value={person} onChange={(value, info) => setPerson(value)} required />

ค่าที่ได้:

{
  raceCode: "099",         // เชื้อชาติ — เก็บตัวนี้ในฐานข้อมูล
  nationalityCode: "099",  // สัญชาติ
}

info มี race, nationality (ข้อมูลเต็มของแต่ละรหัส) และ valid (เลือกครบทั้งสองช่อง)

  • ไทยอยู่บนสุดในหมวด "ใช้บ่อย" เปลี่ยนได้ด้วย pinned เช่น ["099", "048", "056", "057"]
  • เลือกเชื้อชาติตอนที่ยังไม่ได้เลือกสัญชาติ จะตั้งสัญชาติเป็นค่าเดียวกันให้ (ปิดได้ด้วย syncNationality={false})

| prop | ค่าเริ่มต้น | คำอธิบาย | |---|---|---| | value / defaultValue | | ค่าแบบข้างบน | | onChange | | (value, info) => void | | groups | ทุกหมวด | จำกัดหมวดทั้งสองช่อง เช่น ["country"] | | raceGroups, nationalityGroups | ตาม groups | จำกัดหมวดแยกแต่ละช่อง | | pinned | ["099"] | รหัสที่แสดงบนสุด ([] = ไม่มี) | | includeDeprecated | false | แสดงรหัสที่ยกเลิกแล้วในรายการด้วย | | showCode | false | แสดงเป็น 099 ไทย | | syncNationality | true | เลือกเชื้อชาติแล้วเติมสัญชาติที่ยังว่างให้ | | locale | "th" | "en" เปลี่ยนป้ายและรายการเป็นภาษาอังกฤษ | | labels | | เปลี่ยนป้าย เช่น { race: "เชื้อชาติ (ตามบัตร)" } | | required, disabled | false | | | name | | ส่งค่าในฟอร์มเป็น hidden input name[raceCode], name[nationalityCode] |

NationalitySelect

ใช้เลือกช่องเดียว onChange ได้ข้อมูลของรหัสนั้น (หรือ null) รับ prop ของ <select> ปกติได้ทั้งหมด

<div className="tnat">
  <NationalitySelect groups={["country"]} pinned={["099", "048", "056", "057"]} onChange={(n) => setNationality(n?.code)} />
</div>

ห่อด้วย className="tnat" ถ้าต้องการใช้ธีมของแพ็กเกจ

หมวด (group): country ประเทศ · ethnic กลุ่มชาติพันธุ์ (ม้ง กะเหรี่ยง ไทยใหญ่ มอญ …) · status สถานะเฉพาะ (ผู้พลัดถิ่น แรงงาน ไร้สัญชาติ ไม่ระบุ …)

รหัสที่ยกเลิกแล้ว

รหัสบางตัวถูกยกเลิกในชุดมาตรฐาน (เช่น 215 ไต้หวัน → ใช้ 220 จีน (ไต้หวัน)) จะไม่แสดงในรายการ แต่ถ้าข้อมูลเก่าเก็บรหัสนั้นไว้ select ยังแสดงค่าเดิมพร้อมป้าย "ยกเลิกแล้ว" และหาได้ด้วย findNationality ใช้ currentNationality("215") เพื่อได้รหัสที่ใช้แทน

ใช้ฝั่ง server

@inverz/thai-nationality/core มีเฉพาะข้อมูลและฟังก์ชัน ไม่ดึง React

import { findNationality, nationalityFromCountry, nationalityLabel } from "@inverz/thai-nationality/core";

findNationality("099");        // { code: "099", th: "ไทย", en: "Thai", group: "country", iso2: "TH", deprecated: false, replacedBy: "" }
findNationality("Myanmar");    // { code: "048", th: "เมียนมา", … }
nationalityFromCountry("LA");  // { code: "056", th: "ลาว", … }
nationalityLabel("048", { locale: "en" }); // "Myanmar"

| ฟังก์ชัน | คำอธิบาย | |---|---| | NATIONALITIES, NATIONALITY_GROUPS | ข้อมูลทั้งหมดและหมวด | | THAI | "099" | | findNationality(query) | หาจากรหัส ("099" หรือ 99) หรือชื่อไทย/อังกฤษ | | currentNationality(query) | รหัสที่ใช้แทนรหัสที่ยกเลิกแล้ว | | nationalityFromCountry("TH") | หาจากรหัสประเทศ ISO 3166-1 alpha-2 (ใช้ต่อกับ @inverz/world-address ได้) | | isNationalityCode(code, { active }) | ตรวจว่าเป็นรหัสที่มีอยู่ (active: true ไม่นับรหัสที่ยกเลิก) | | nationalitiesByGroup({ groups, locale, includeDeprecated }) | แบ่งตามหมวด เรียงตามชื่อ | | nationalityLabel(query, { locale, withCode }) | "ไทย" / "Thai" / "099 ไทย" |

ธีม

ปรับสีด้วย CSS variables --tnat-brand, --tnat-border-strong, --tnat-surface, --tnat-text, --tnat-font … (ถ้าไม่ตั้ง จะใช้ค่าของแพ็กเกจอื่นใน @inverz ที่ตั้งไว้ เช่น --tdp-brand)

แหล่งข้อมูล

รหัสและชื่อไทยจากรหัสเชื้อชาติ-สัญชาติของศูนย์มาตรฐานรหัสด้านสุขภาพ (THCC) ผ่าน Thai Core Terminology IG (data-source/thcc-nationality.fsh) ชื่อภาษาอังกฤษ หมวด และรหัส ISO แพ็กเกจเพิ่มเอง (data-source/english.tsv) สร้างไฟล์ข้อมูลใหม่ด้วย npm run build:data

License

MIT © 2026 Inverz Solutions Co.,Ltd.