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-name

v2.0.0

Published

Thai name input for React: 177 name titles (ranks, academic, royal, religious) with English, gender and Royal Institute name formatting

Readme

@inverz/thai-name

ช่องชื่อ-นามสกุลสำหรับ React พร้อม คำนำหน้า 177 รายการ ทั้งทั่วไป ยศตำรวจ ทหารบก ทหารเรือ ทหารอากาศ ตำแหน่งวิชาการ แพทย์ ราชสกุล และนักบวช คำนำหน้าภาษาอังกฤษตามตารางทางการ เลือกเพศให้เองจากคำนำหน้า และจัดชื่อหลายคำนำหน้าตามหลักเกณฑ์ราชบัณฑิตยสภา มีฟังก์ชันแยกให้ใช้ฝั่ง server โดยไม่ต้องมี React

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

A React name input with 177 Thai titles and ranks (with official English equivalents), automatic gender from the title, and Royal Institute name formatting. React-free helpers for the server.

ติดตั้ง

npm i @inverz/thai-name
import "@inverz/thai-name/style.css"; // ไม่บังคับ
import { ThaiNameInput, TitleSelect, formatName } from "@inverz/thai-name";

ThaiNameInput

const [name, setName] = useState({});

<ThaiNameInput value={name} onChange={(value, info) => setName(value)} english showPreview />

ค่าที่ได้:

{
  titleId: 12,          // เก็บตัวนี้ในฐานข้อมูล
  gender: "M",          // "M" | "F" | null
  firstNameTh: "สมชาย",
  lastNameTh: "ใจดี",
  firstNameEn: "Somchai",
  lastNameEn: "Jaidee",
}

info มี title (ข้อมูลคำนำหน้าเต็ม), errors, valid และ formatted: { th, en } เช่น "พ.ต.อ. สมชาย ใจดี" / "Pol.Col. Somchai Jaidee"

  • เลือกคำนำหน้าที่บอกเพศได้ (นาย นาง พ.ต.อ.หญิง) จะตั้ง gender ให้เอง คำนำหน้าที่ใช้ได้ทั้งสองเพศ (ดร. ศ. ม.ร.ว.) จะขึ้นตัวเลือกเพศ
  • ช่องชื่อ-นามสกุลหลักรับได้ทุกภาษา (ใส่ script="thai" ถ้าต้องการเฉพาะอักษรไทย) ช่องอังกฤษรับเฉพาะตัวอักษรอังกฤษ ชื่ออังกฤษขึ้นต้นตัวพิมพ์ใหญ่ให้ตอนออกจากช่อง
  • english แสดงแถวชื่อภาษาอังกฤษ คำนำหน้าอังกฤษมาจากคำนำหน้าไทยให้เอง

| prop | ค่าเริ่มต้น | คำอธิบาย | |---|---|---| | value / defaultValue | | ค่าแบบข้างบน | | onChange | | (value, info) => void | | english | false | แสดงช่องชื่อภาษาอังกฤษ | | groups | ทุกหมวด | จำกัดหมวดคำนำหน้า เช่น ["general", "academic"] | | locale | "th" | "en" เปลี่ยนป้ายและรายการเป็นภาษาอังกฤษ | | titleDisplay | "both" | รายการคำนำหน้าแสดงเป็น "short" ตัวย่อ (พ.ต.อ.) · "full" ตัวเต็ม (พันตำรวจเอก) · "both" ตัวย่อ (ตัวเต็ม) | | script | "any" | ช่องชื่อ-นามสกุลหลักรับ "any" ทุกภาษา เช่น ชื่อชาวต่างชาติ · "thai" อักษรไทยเท่านั้น (อักษรอื่นขึ้นเตือน) | | formatStyle | "short" | คำนำหน้าในผลลัพธ์ (info.formatted, preview, ช่อง Title อังกฤษ) "short" → พ.ต.อ. สมชาย ใจดี · "full" → พันตำรวจเอก สมชาย ใจดี | | showPreview | false | แสดงชื่อที่จัดรูปแบบแล้ว | | required, disabled | false | | | name | | ส่งค่าในฟอร์มเป็น hidden input name[titleId], name[firstNameTh] … |

TitleSelect

ใช้เลือกเฉพาะคำนำหน้า onChange ได้ข้อมูลคำนำหน้า (หรือ null)

<TitleSelect groups={["general", "medical"]} gender="F" onChange={(title) => setTitle(title)} />

display เลือกรูปแบบในรายการ: "short" → พ.ต.อ. · "full" → พันตำรวจเอก · "both" (ค่าเริ่มต้น) → พ.ต.อ. (พันตำรวจเอก) ถ้าต้องการข้อความเดียวกันนอก select ใช้ titleLabel(title, { display, locale })

หมวด (group): general ทั่วไป · academic ตำแหน่งวิชาการ · medical การแพทย์ · police ตำรวจ · army ทหารบก · navy ทหารเรือ · air_force ทหารอากาศ · acting ว่าที่ยศ · royal ราชสกุล / บรรดาศักดิ์ · religious นักบวช · english ภาษาอังกฤษ

formatName

formatName(["รองศาสตราจารย์", "พันโทหญิง", "ดร."], "สุชาดา", "ใจดี");
// "รศ. พ.ท.หญิง ดร.สุชาดา ใจดี"

formatName(["รองศาสตราจารย์", "พันโทหญิง", "ดร."], "Suchada", "Jaidee", { locale: "en" });
// "Assoc.Prof. Lt.Col. Dr. Suchada Jaidee"

formatName("นาย", "สมชาย", "ใจดี", { style: "full" }); // "นายสมชาย ใจดี"

ส่งคำนำหน้าเป็น id, ชื่อไทย/อังกฤษ (ย่อหรือเต็ม) หรือ object ก็ได้ เรียงแบบไหนก็ได้

กฎที่ใช้ (หลักเกณฑ์การเว้นวรรคของราชบัณฑิตยสภา 2563):

  • คำนำหน้าหลายคำ เรียงตามลำดับ: ตำแหน่งวิชาการ → ยศ → ดร. → วิชาชีพ (นพ. พญ.) → คำนำหน้าทั่วไป → ราชสกุล
  • เว้นวรรคระหว่างคำนำหน้า ตัวสุดท้ายเขียนติดชื่อ (รศ. ดร.สมหญิง) ยกเว้นยศ เว้นวรรคก่อนชื่อ (พ.ต.อ. สมชาย) และชื่อที่ไม่ใช่อักษรไทย เว้นวรรคก่อนชื่อ (นาย John Smith)
  • ภาษาอังกฤษ ทุกคำนำหน้าเป็นคำแยก และไม่ใส่ Dr. ซ้ำ

ใช้ฝั่ง server

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

import { findTitle, formatName, isThaiName, isEnglishName } from "@inverz/thai-name/core";

findTitle(12);          // { id: 12, short: "พ.ต.อ.", full: "พันตำรวจเอก", shortEn: "Pol.Col.", fullEn: "Police Colonel", gender: "M", group: "police", … }
findTitle("Pol.Col.");  // ตัวเดียวกัน
isThaiName("สมชาย");     // true

| ฟังก์ชัน | คำอธิบาย | |---|---| | TITLES, TITLE_GROUPS | ข้อมูลคำนำหน้าและหมวดทั้งหมด | | findTitle(query) | หาจาก id หรือชื่อไทย/อังกฤษ | | titlesByGroup({ groups, gender }) | คำนำหน้าแบ่งตามหมวด | | titleLabel(title, { display, locale }) | "พ.ต.อ." / "พันตำรวจเอก" / "พ.ต.อ. (พันตำรวจเอก)" | | titleFitsGender(title, "M") | คำนำหน้าใช้กับเพศนี้ได้ไหม | | genderOfTitle(title) | เพศที่คำนำหน้าบอก หรือ null ถ้าได้ทั้งคู่ | | isThaiName, isEnglishName | ตรวจตัวอักษร | | capitalizeName("o'neil-smith") | "O'Neil-Smith" | | formatName(titles, first, last, options) | ดูด้านบน |

ธีม

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

แหล่งข้อมูล

ภาษาอังกฤษของยศตำรวจ ทหาร และคำนำหน้านาม อ้างอิงเอกสารที่เผยแพร่ผ่านกระทรวงการต่างประเทศ คำนำหน้าบางกลุ่ม (ยศพิเศษ พลตำรวจ นักบวช เภสัชกร คำนำหน้าแพทย์) ยังไม่มีแหล่งทางการ ใช้ตามแบบที่นิยม

License

MIT © 2026 Inverz Solutions Co.,Ltd.