@designil/labdsnov 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +133 -2
  3. package/dist/components/Accordion/Accordion.d.ts +8 -0
  4. package/dist/components/Accordion/Accordion.js +82 -0
  5. package/dist/components/Accordion/Accordion.module.css.js +23 -0
  6. package/dist/components/Accordion/index.d.ts +1 -0
  7. package/dist/components/Alert/Alert.d.ts +17 -0
  8. package/dist/components/Alert/Alert.js +58 -0
  9. package/dist/components/Alert/Alert.module.css.js +17 -0
  10. package/dist/components/Alert/index.d.ts +1 -0
  11. package/dist/components/AlertDialog/AlertDialog.d.ts +29 -0
  12. package/dist/components/AlertDialog/AlertDialog.js +150 -0
  13. package/dist/components/AlertDialog/AlertDialog.module.css.js +23 -0
  14. package/dist/components/AlertDialog/index.d.ts +1 -0
  15. package/dist/components/Avatar/Avatar.d.ts +23 -0
  16. package/dist/components/Avatar/Avatar.js +84 -0
  17. package/dist/components/Avatar/Avatar.module.css.js +23 -0
  18. package/dist/components/Avatar/index.d.ts +1 -0
  19. package/dist/components/Badge/Badge.d.ts +17 -0
  20. package/dist/components/Badge/Badge.js +37 -0
  21. package/dist/components/Badge/Badge.module.css.js +19 -0
  22. package/dist/components/Badge/index.d.ts +1 -0
  23. package/dist/components/Breadcrumb/Breadcrumb.d.ts +15 -0
  24. package/dist/components/Breadcrumb/Breadcrumb.js +111 -0
  25. package/dist/components/Breadcrumb/Breadcrumb.module.css.js +19 -0
  26. package/dist/components/Breadcrumb/index.d.ts +1 -0
  27. package/dist/components/Button/Button.d.ts +39 -0
  28. package/dist/components/Button/Button.js +62 -0
  29. package/dist/components/Button/Button.module.css.js +37 -0
  30. package/dist/components/Button/index.d.ts +1 -0
  31. package/dist/components/ButtonGroup/ButtonGroup.d.ts +21 -0
  32. package/dist/components/ButtonGroup/ButtonGroup.js +59 -0
  33. package/dist/components/ButtonGroup/ButtonGroup.module.css.js +15 -0
  34. package/dist/components/ButtonGroup/index.d.ts +1 -0
  35. package/dist/components/Calendar/Calendar.d.ts +17 -0
  36. package/dist/components/Calendar/Calendar.js +154 -0
  37. package/dist/components/Calendar/Calendar.module.css.js +67 -0
  38. package/dist/components/Calendar/index.d.ts +1 -0
  39. package/dist/components/Card/Card.d.ts +20 -0
  40. package/dist/components/Card/Card.js +87 -0
  41. package/dist/components/Card/Card.module.css.js +23 -0
  42. package/dist/components/Card/index.d.ts +1 -0
  43. package/dist/components/Chart/Chart.d.ts +59 -0
  44. package/dist/components/Chart/Chart.js +199 -0
  45. package/dist/components/Chart/Chart.module.css.js +47 -0
  46. package/dist/components/Chart/index.d.ts +1 -0
  47. package/dist/components/Checkbox/Checkbox.d.ts +4 -0
  48. package/dist/components/Checkbox/Checkbox.js +44 -0
  49. package/dist/components/Checkbox/Checkbox.module.css.js +13 -0
  50. package/dist/components/Checkbox/index.d.ts +1 -0
  51. package/dist/components/Collapsible/Collapsible.d.ts +8 -0
  52. package/dist/components/Collapsible/Collapsible.js +28 -0
  53. package/dist/components/Collapsible/Collapsible.module.css.js +7 -0
  54. package/dist/components/Collapsible/index.d.ts +1 -0
  55. package/dist/components/Combobox/Combobox.d.ts +36 -0
  56. package/dist/components/Combobox/Combobox.js +296 -0
  57. package/dist/components/Combobox/Combobox.module.css.js +39 -0
  58. package/dist/components/Combobox/index.d.ts +1 -0
  59. package/dist/components/DatePicker/DatePicker.d.ts +28 -0
  60. package/dist/components/DatePicker/DatePicker.js +73 -0
  61. package/dist/components/DatePicker/DatePicker.module.css.js +9 -0
  62. package/dist/components/DatePicker/index.d.ts +1 -0
  63. package/dist/components/Dialog/Dialog.d.ts +27 -0
  64. package/dist/components/Dialog/Dialog.js +144 -0
  65. package/dist/components/Dialog/Dialog.module.css.js +29 -0
  66. package/dist/components/Dialog/index.d.ts +1 -0
  67. package/dist/components/Drawer/Drawer.d.ts +22 -0
  68. package/dist/components/Drawer/Drawer.js +166 -0
  69. package/dist/components/Drawer/Drawer.module.css.js +23 -0
  70. package/dist/components/Drawer/index.d.ts +1 -0
  71. package/dist/components/DropdownMenu/DropdownMenu.d.ts +32 -0
  72. package/dist/components/DropdownMenu/DropdownMenu.js +245 -0
  73. package/dist/components/DropdownMenu/DropdownMenu.module.css.js +33 -0
  74. package/dist/components/DropdownMenu/index.d.ts +1 -0
  75. package/dist/components/Empty/Empty.d.ts +18 -0
  76. package/dist/components/Empty/Empty.js +76 -0
  77. package/dist/components/Empty/Empty.module.css.js +21 -0
  78. package/dist/components/Empty/index.d.ts +1 -0
  79. package/dist/components/Field/Field.d.ts +53 -0
  80. package/dist/components/Field/Field.js +172 -0
  81. package/dist/components/Field/Field.module.css.js +41 -0
  82. package/dist/components/Field/index.d.ts +1 -0
  83. package/dist/components/FundCard/FundCard.d.ts +18 -0
  84. package/dist/components/FundCard/FundCard.js +66 -0
  85. package/dist/components/FundCard/FundCard.module.css.js +25 -0
  86. package/dist/components/FundCard/index.d.ts +1 -0
  87. package/dist/components/HoverCard/HoverCard.d.ts +8 -0
  88. package/dist/components/HoverCard/HoverCard.js +42 -0
  89. package/dist/components/HoverCard/HoverCard.module.css.js +9 -0
  90. package/dist/components/HoverCard/index.d.ts +1 -0
  91. package/dist/components/Input/Input.d.ts +12 -0
  92. package/dist/components/Input/Input.js +23 -0
  93. package/dist/components/Input/Input.module.css.js +11 -0
  94. package/dist/components/Input/index.d.ts +1 -0
  95. package/dist/components/InputGroup/InputGroup.d.ts +39 -0
  96. package/dist/components/InputGroup/InputGroup.js +103 -0
  97. package/dist/components/InputGroup/InputGroup.module.css.js +31 -0
  98. package/dist/components/InputGroup/index.d.ts +1 -0
  99. package/dist/components/InputOTP/InputOTP.d.ts +18 -0
  100. package/dist/components/InputOTP/InputOTP.js +72 -0
  101. package/dist/components/InputOTP/InputOTP.module.css.js +19 -0
  102. package/dist/components/InputOTP/index.d.ts +1 -0
  103. package/dist/components/Kbd/Kbd.d.ts +5 -0
  104. package/dist/components/Kbd/Kbd.js +20 -0
  105. package/dist/components/Kbd/Kbd.module.css.js +9 -0
  106. package/dist/components/Kbd/index.d.ts +1 -0
  107. package/dist/components/Label/Label.d.ts +7 -0
  108. package/dist/components/Label/Label.js +17 -0
  109. package/dist/components/Label/Label.module.css.js +9 -0
  110. package/dist/components/Label/index.d.ts +1 -0
  111. package/dist/components/NavigationMenu/NavigationMenu.d.ts +20 -0
  112. package/dist/components/NavigationMenu/NavigationMenu.js +153 -0
  113. package/dist/components/NavigationMenu/NavigationMenu.module.css.js +29 -0
  114. package/dist/components/NavigationMenu/index.d.ts +1 -0
  115. package/dist/components/Pagination/Pagination.d.ts +29 -0
  116. package/dist/components/Pagination/Pagination.js +133 -0
  117. package/dist/components/Pagination/Pagination.module.css.js +19 -0
  118. package/dist/components/Pagination/index.d.ts +1 -0
  119. package/dist/components/Popover/Popover.d.ts +10 -0
  120. package/dist/components/Popover/Popover.js +78 -0
  121. package/dist/components/Popover/Popover.module.css.js +15 -0
  122. package/dist/components/Popover/index.d.ts +1 -0
  123. package/dist/components/Progress/Progress.d.ts +12 -0
  124. package/dist/components/Progress/Progress.js +74 -0
  125. package/dist/components/Progress/Progress.module.css.js +15 -0
  126. package/dist/components/Progress/index.d.ts +1 -0
  127. package/dist/components/RadioGroup/RadioGroup.d.ts +6 -0
  128. package/dist/components/RadioGroup/RadioGroup.js +37 -0
  129. package/dist/components/RadioGroup/RadioGroup.module.css.js +13 -0
  130. package/dist/components/RadioGroup/index.d.ts +1 -0
  131. package/dist/components/ScrollArea/ScrollArea.d.ts +9 -0
  132. package/dist/components/ScrollArea/ScrollArea.js +60 -0
  133. package/dist/components/ScrollArea/ScrollArea.module.css.js +17 -0
  134. package/dist/components/ScrollArea/index.d.ts +1 -0
  135. package/dist/components/Select/Select.d.ts +23 -0
  136. package/dist/components/Select/Select.js +188 -0
  137. package/dist/components/Select/Select.module.css.js +37 -0
  138. package/dist/components/Select/index.d.ts +1 -0
  139. package/dist/components/Separator/Separator.d.ts +4 -0
  140. package/dist/components/Separator/Separator.js +22 -0
  141. package/dist/components/Separator/Separator.module.css.js +7 -0
  142. package/dist/components/Separator/index.d.ts +1 -0
  143. package/dist/components/Skeleton/Skeleton.d.ts +4 -0
  144. package/dist/components/Skeleton/Skeleton.js +16 -0
  145. package/dist/components/Skeleton/Skeleton.module.css.js +7 -0
  146. package/dist/components/Skeleton/index.d.ts +1 -0
  147. package/dist/components/Slider/Slider.d.ts +13 -0
  148. package/dist/components/Slider/Slider.js +61 -0
  149. package/dist/components/Slider/Slider.module.css.js +15 -0
  150. package/dist/components/Slider/index.d.ts +1 -0
  151. package/dist/components/Spinner/Spinner.d.ts +6 -0
  152. package/dist/components/Spinner/Spinner.js +22 -0
  153. package/dist/components/Spinner/Spinner.module.css.js +7 -0
  154. package/dist/components/Spinner/index.d.ts +1 -0
  155. package/dist/components/Switch/Switch.d.ts +13 -0
  156. package/dist/components/Switch/Switch.js +29 -0
  157. package/dist/components/Switch/Switch.module.css.js +13 -0
  158. package/dist/components/Switch/index.d.ts +1 -0
  159. package/dist/components/Table/Table.d.ts +12 -0
  160. package/dist/components/Table/Table.js +96 -0
  161. package/dist/components/Table/Table.module.css.js +23 -0
  162. package/dist/components/Table/index.d.ts +1 -0
  163. package/dist/components/Tabs/Tabs.d.ts +16 -0
  164. package/dist/components/Tabs/Tabs.js +55 -0
  165. package/dist/components/Tabs/Tabs.module.css.js +17 -0
  166. package/dist/components/Tabs/index.d.ts +1 -0
  167. package/dist/components/Textarea/Textarea.d.ts +4 -0
  168. package/dist/components/Textarea/Textarea.js +16 -0
  169. package/dist/components/Textarea/Textarea.module.css.js +7 -0
  170. package/dist/components/Textarea/index.d.ts +1 -0
  171. package/dist/components/Toaster/Toaster.d.ts +8 -0
  172. package/dist/components/Toaster/Toaster.js +85 -0
  173. package/dist/components/Toaster/Toaster.module.css.js +11 -0
  174. package/dist/components/Toaster/index.d.ts +1 -0
  175. package/dist/components/Toggle/Toggle.d.ts +26 -0
  176. package/dist/components/Toggle/Toggle.js +35 -0
  177. package/dist/components/Toggle/Toggle.module.css.js +17 -0
  178. package/dist/components/Toggle/index.d.ts +1 -0
  179. package/dist/components/ToggleGroup/ToggleGroup.d.ts +20 -0
  180. package/dist/components/ToggleGroup/ToggleGroup.js +64 -0
  181. package/dist/components/ToggleGroup/ToggleGroup.module.css.js +11 -0
  182. package/dist/components/ToggleGroup/index.d.ts +1 -0
  183. package/dist/components/Tooltip/Tooltip.d.ts +8 -0
  184. package/dist/components/Tooltip/Tooltip.js +61 -0
  185. package/dist/components/Tooltip/Tooltip.module.css.js +11 -0
  186. package/dist/components/Tooltip/index.d.ts +1 -0
  187. package/dist/index.d.ts +47 -0
  188. package/dist/index.js +265 -0
  189. package/dist/styles.css +1 -0
  190. package/docs/Accessibility.md +129 -0
  191. package/docs/Colors.md +96 -0
  192. package/docs/ComponentTokens.md +191 -0
  193. package/docs/Contributing.md +97 -0
  194. package/docs/GettingStarted.md +106 -0
  195. package/docs/Radius.md +25 -0
  196. package/docs/Typography.md +38 -0
  197. package/package.json +79 -3
  198. package/src/components/Accordion/Accordion.md +102 -0
  199. package/src/components/Alert/Alert.md +90 -0
  200. package/src/components/AlertDialog/AlertDialog.md +131 -0
  201. package/src/components/Avatar/Avatar.md +77 -0
  202. package/src/components/Badge/Badge.md +124 -0
  203. package/src/components/Breadcrumb/Breadcrumb.md +110 -0
  204. package/src/components/Button/Button.md +165 -0
  205. package/src/components/ButtonGroup/ButtonGroup.md +96 -0
  206. package/src/components/Calendar/Calendar.md +111 -0
  207. package/src/components/Card/Card.md +99 -0
  208. package/src/components/Chart/Chart.md +112 -0
  209. package/src/components/Checkbox/Checkbox.md +105 -0
  210. package/src/components/Collapsible/Collapsible.md +86 -0
  211. package/src/components/Combobox/Combobox.md +143 -0
  212. package/src/components/DatePicker/DatePicker.md +82 -0
  213. package/src/components/Dialog/Dialog.md +193 -0
  214. package/src/components/Drawer/Drawer.md +125 -0
  215. package/src/components/DropdownMenu/DropdownMenu.md +151 -0
  216. package/src/components/Empty/Empty.md +90 -0
  217. package/src/components/Field/Field.md +139 -0
  218. package/src/components/FundCard/FundCard.md +93 -0
  219. package/src/components/HoverCard/HoverCard.md +100 -0
  220. package/src/components/Input/Input.md +115 -0
  221. package/src/components/InputGroup/InputGroup.md +115 -0
  222. package/src/components/InputOTP/InputOTP.md +105 -0
  223. package/src/components/Kbd/Kbd.md +85 -0
  224. package/src/components/Label/Label.md +75 -0
  225. package/src/components/NavigationMenu/NavigationMenu.md +128 -0
  226. package/src/components/Pagination/Pagination.md +115 -0
  227. package/src/components/Popover/Popover.md +111 -0
  228. package/src/components/Progress/Progress.md +83 -0
  229. package/src/components/RadioGroup/RadioGroup.md +123 -0
  230. package/src/components/ScrollArea/ScrollArea.md +88 -0
  231. package/src/components/Select/Select.md +170 -0
  232. package/src/components/Separator/Separator.md +68 -0
  233. package/src/components/Skeleton/Skeleton.md +68 -0
  234. package/src/components/Slider/Slider.md +107 -0
  235. package/src/components/Spinner/Spinner.md +64 -0
  236. package/src/components/Switch/Switch.md +101 -0
  237. package/src/components/Table/Table.md +117 -0
  238. package/src/components/Tabs/Tabs.md +173 -0
  239. package/src/components/Textarea/Textarea.md +89 -0
  240. package/src/components/Toaster/Toaster.md +107 -0
  241. package/src/components/Toggle/Toggle.md +103 -0
  242. package/src/components/ToggleGroup/ToggleGroup.md +95 -0
  243. package/src/components/Tooltip/Tooltip.md +104 -0
@@ -0,0 +1,115 @@
1
+ # Input (ช่องกรอกข้อมูล)
2
+
3
+ ## Purpose
4
+
5
+ ช่องกรอกข้อความบรรทัดเดียว เช่น ชื่อ อีเมล รหัสผ่าน เบอร์โทรศัพท์ หรือเลือกไฟล์
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ```tsx
16
+ import { Input, Label } from "@designil/labdsnov"
17
+
18
+ ;<div className="grid gap-2">
19
+ <Label htmlFor="email" required>
20
+ อีเมล
21
+ </Label>
22
+ <Input id="email" type="email" required placeholder="you@example.com" />
23
+ </div>
24
+ ```
25
+
26
+ ## When to use
27
+
28
+ - ข้อมูลสั้นบรรทัดเดียวในฟอร์ม เช่น ฟอร์มแก้ไขข้อมูลบัญชี เข้าสู่ระบบ
29
+ - ใช้คู่กับ `Label` เสมอ (ดู [Label](../Label/Label.md))
30
+ - เลือก `type` ให้ตรงกับข้อมูล (`email`, `password`, `tel`, `number`, `search`, `file`) เพื่อให้มือถือแสดงแป้นพิมพ์ที่เหมาะสม
31
+
32
+ ## When not to use
33
+
34
+ - **ข้อความหลายบรรทัด**: ใช้ `Textarea`
35
+ - **เลือกจากรายการ หรือเปิด/ปิด**: ใช้ `Select`, `RadioGroup`, `Checkbox` หรือ `Switch`
36
+ - **เลือกวันที่**: ใช้ `DatePicker`
37
+ - **ใช้ placeholder แทนป้ายชื่อ**: placeholder หายไปเมื่อเริ่มพิมพ์ ใช้แค่ยกตัวอย่างรูปแบบ เช่น "04xx xxx xxx"
38
+
39
+ ## Props and variants
40
+
41
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
42
+ | -------------------- | ------------------- | -------- | ----------------------------------------------------------- |
43
+ | `variant` | `filled`, `outline` | `filled` | หน้าตาของช่อง (ดูตารางด้านล่าง) |
44
+ | `type` | ชนิดของ input | `text` | ชนิดข้อมูล |
45
+ | `id` | ข้อความ | – | ใช้ผูกกับ `Label` ผ่าน `htmlFor` |
46
+ | `placeholder` | ข้อความ | – | ตัวอย่างรูปแบบ เป็นภาษาไทยหรือรูปแบบข้อมูล |
47
+ | `value` / `onChange` | ข้อความ / ฟังก์ชัน | – | ควบคุมค่าจากภายนอก (หรือใช้ `defaultValue`) |
48
+ | `disabled` | `boolean` | `false` | ปิดใช้งาน จางลง 50% โฟกัสไม่ได้ |
49
+ | `aria-invalid` | `boolean` | – | ข้อมูลไม่ถูกต้อง แสดงเส้นขอบสีแดงและวงแหวนแดงจาง |
50
+ | `aria-describedby` | id ของข้อความ | – | ผูกข้อความช่วยเหลือหรือข้อความผิดพลาดใต้ช่อง ให้โปรแกรมอ่านหน้าจออ่านด้วย |
51
+ | `required` | `boolean` | `false` | บังคับกรอก ต้องใส่เองแม้ `Label` จะมี `required` แล้ว |
52
+ | `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของช่องเสมอ |
53
+
54
+ ### Variants
55
+
56
+ | Variant | หน้าตา | ใช้เมื่อ |
57
+ | --------- | ---------------- | ------------------------- |
58
+ | `filled` | พื้นทึบอ่อน มีเส้นขอบ | ค่าเริ่มต้น ใช้ในฟอร์มทั่วไป |
59
+ | `outline` | พื้นโปร่งใส มีเส้นขอบ | TODO: ยังไม่ได้กำหนดว่าใช้ที่ไหน |
60
+
61
+ ช่องสูง 36px กว้างเต็มพื้นที่ ทรงแคปซูล ตัวอักษร 16px บนจอแคบ และ 14px บนจอ 768px ขึ้นไป
62
+
63
+ ### States
64
+
65
+ - **Focus จากคีย์บอร์ด**: เส้นขอบและวงแหวนทึบสี `--focus-ring`
66
+ - **ปิดใช้งาน**: จางลง 50%
67
+ - **ข้อมูลไม่ถูกต้อง** (`aria-invalid`): เส้นขอบสีแดงและวงแหวนแดงจาง เมื่อโฟกัสวงแหวนเป็นสีแดงทึบ ต้องมีข้อความบอกว่าผิดอย่างไรใต้ช่องเสมอ ใช้ `FieldError` (ดู [Field](../Field/Field.md))
68
+
69
+ ## Tokens used
70
+
71
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
72
+
73
+ ### Component tokens
74
+
75
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
76
+
77
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
78
+ | --------------------- | -------------------- | ------------------- | ----------------------------------------------- |
79
+ | `--field-placeholder` | `--muted-foreground` | – | placeholder |
80
+ | `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
81
+ | `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
82
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
83
+ | `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
84
+ | `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
85
+
86
+ ### Semantic tokens
87
+
88
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
89
+ | -------------------- | -------------------------- | -------------------------- | ----------------------------------- |
90
+ | `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้น `filled` (50%), เส้นขอบ `outline` |
91
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | placeholder |
92
+ | `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรที่พิมพ์ (สืบทอด), ปุ่มเลือกไฟล์ |
93
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | เส้นขอบและวงแหวน focus |
94
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
95
+ | `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.2` = 22px) |
96
+ | `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
97
+
98
+ ## Example
99
+
100
+ จาก story `Invalid` ใน `Input.stories.tsx`:
101
+
102
+ ```tsx
103
+ <div className="grid gap-2">
104
+ <Label htmlFor="input-tfn">เลขประจำตัวผู้เสียภาษี (TFN)</Label>
105
+ <Input
106
+ id="input-tfn"
107
+ aria-invalid
108
+ defaultValue="123-456"
109
+ aria-describedby="input-tfn-hint"
110
+ />
111
+ <p id="input-tfn-hint" className="text-xs text-destructive">
112
+ เลขประจำตัวผู้เสียภาษี (TFN) ต้องมี 9 หลัก
113
+ </p>
114
+ </div>
115
+ ```
@@ -0,0 +1,115 @@
1
+ # InputGroup (ช่องกรอกพร้อมส่วนเสริม)
2
+
3
+ ## Purpose
4
+
5
+ ช่องกรอกที่มีไอคอน ข้อความ หรือปุ่มอยู่ในกรอบเดียวกัน เช่น "AU$" หน้าจำนวนเงิน หรือปุ่มคัดลอก
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ```tsx
16
+ import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText, Label } from "@designil/labdsnov"
17
+
18
+ <Label htmlFor="amount">จำนวนเงินสมทบเพิ่มเติม</Label>
19
+ <InputGroup>
20
+ <InputGroupInput id="amount" type="number" placeholder="0.00" />
21
+ <InputGroupAddon>
22
+ <InputGroupText>AU$</InputGroupText>
23
+ </InputGroupAddon>
24
+ </InputGroup>
25
+ ```
26
+
27
+ - ใช้ `InputGroupInput` / `InputGroupTextarea` แทน `Input` / `Textarea` ในกลุ่ม (ไม่มีพื้นและกรอบของตัวเอง)
28
+ - วาง `InputGroupAddon` ไว้หลังช่องกรอกใน code ได้เสมอ ตำแหน่งที่แสดงกำหนดด้วย `align`
29
+
30
+ ## When to use
31
+
32
+ - หน่วยหรือสกุลเงินที่ติดกับค่า เช่น "AU$", "%"
33
+ - ไอคอนค้นหาในช่องค้นหา
34
+ - ปุ่มที่ทำงานกับค่าในช่อง เช่น แสดง/ซ่อนรหัสผ่าน คัดลอก
35
+ - ช่องข้อความที่มีแถวด้านล่าง เช่น ตัวนับตัวอักษร
36
+
37
+ ## When not to use
38
+
39
+ - **ปุ่มส่งฟอร์ม**: วาง `Button` นอกช่อง
40
+ - **ป้ายชื่อของช่อง**: ใช้ `Label` / `FieldLabel` ไม่ใช่ข้อความในกลุ่ม
41
+ - **เลือกจากรายการ**: ใช้ `Select` หรือ `Combobox`
42
+
43
+ ## Props and variants
44
+
45
+ หน้าตาเหมือน `Input` แบบ `filled` สูง 36px เมื่อช่องกรอกได้โฟกัส ทั้งกลุ่มมีวงแหวน เมื่อช่องกรอกมี `aria-invalid` ทั้งกลุ่มเป็นสีแดง
46
+
47
+ ### InputGroupAddon `align`
48
+
49
+ | Align | ตำแหน่ง |
50
+ | -------------- | -------------------------- |
51
+ | `inline-start` | ซ้ายของช่องกรอก (ค่าเริ่มต้น) |
52
+ | `inline-end` | ขวาของช่องกรอก |
53
+ | `block-start` | แถวด้านบน (กลุ่มสูงขึ้นเป็นแนวตั้ง) |
54
+ | `block-end` | แถวด้านล่าง เช่น ตัวนับตัวอักษร |
55
+
56
+ คลิกที่ addon (นอกปุ่ม) แล้วโฟกัสไปที่ช่องกรอก
57
+
58
+ ### InputGroupButton `size`
59
+
60
+ | Size | ขนาด |
61
+ | -------------- | ------------------------- |
62
+ | `xs` (ค่าเริ่มต้น) | สูง 24px มีข้อความ |
63
+ | `sm` | ตามขนาด `sm` ของ `Button` |
64
+ | `icon-xs` | 24×24px ไอคอนอย่างเดียว |
65
+ | `icon-sm` | 32×32px ไอคอนอย่างเดียว |
66
+
67
+ ปุ่มเป็น `ghost` โดยค่าเริ่มต้น ปุ่มไอคอนอย่างเดียวต้องมี `aria-label`
68
+
69
+ - **InputGroupText**: ข้อความหรือไอคอนสี muted เช่น "AU$"
70
+ - TODO: ยังไม่มีสถานะปิดใช้งานของทั้งกลุ่มที่ตั้งให้อัตโนมัติ ต้องใส่ `data-disabled="true"` ที่ `InputGroup` เอง
71
+
72
+ ## Tokens used
73
+
74
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
75
+
76
+ ### Component tokens
77
+
78
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
79
+
80
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
81
+ | ------------------ | ------------------- | ------------------- | ----------------------------------------------- |
82
+ | `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
83
+ | `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
84
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
85
+ | `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
86
+ | `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
87
+
88
+ ### Semantic tokens
89
+
90
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
91
+ | -------------------- | ------------------------- | -------------------------- | ------------------------------------------------- |
92
+ | `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นกลุ่ม (50%) |
93
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ข้อความและไอคอนใน addon |
94
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus ของทั้งกลุ่ม |
95
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
96
+ | `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.6` = 26px, มี textarea: 18px) |
97
+ | `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
98
+
99
+ ## Example
100
+
101
+ จาก story `WithButtons` ใน `InputGroup.stories.tsx`:
102
+
103
+ ```tsx
104
+ <InputGroup className="w-80">
105
+ <InputGroupInput defaultValue="123 456 789" aria-label="เลขสมาชิก" readOnly />
106
+ <InputGroupAddon align="inline-end">
107
+ <InputGroupButton size="icon-xs" aria-label="แสดง">
108
+ <HugeiconsIcon icon={ViewIcon} strokeWidth={2} />
109
+ </InputGroupButton>
110
+ <InputGroupButton size="icon-xs" aria-label="คัดลอก">
111
+ <HugeiconsIcon icon={Copy01Icon} strokeWidth={2} />
112
+ </InputGroupButton>
113
+ </InputGroupAddon>
114
+ </InputGroup>
115
+ ```
@@ -0,0 +1,105 @@
1
+ # InputOTP (ช่องกรอกรหัสยืนยัน)
2
+
3
+ ## Purpose
4
+
5
+ ช่องกรอกรหัสยืนยันแบบใช้ครั้งเดียว (OTP) แยกกล่องละหนึ่งตัวอักษร เช่น รหัส 6 หลักทาง SMS
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ใช้ไลบรารี `input-otp` (ติดตั้งมากับ `@designil/labdsnov` แล้ว)
16
+
17
+ ```tsx
18
+ import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Label } from "@designil/labdsnov"
19
+
20
+ <Label htmlFor="otp">รหัสยืนยัน 6 หลัก</Label>
21
+ <InputOTP id="otp" maxLength={6} onComplete={verify}>
22
+ <InputOTPGroup>
23
+ <InputOTPSlot index={0} />
24
+ <InputOTPSlot index={1} />
25
+ <InputOTPSlot index={2} />
26
+ </InputOTPGroup>
27
+ <InputOTPSeparator />
28
+ <InputOTPGroup>
29
+ <InputOTPSlot index={3} />
30
+ <InputOTPSlot index={4} />
31
+ <InputOTPSlot index={5} />
32
+ </InputOTPGroup>
33
+ </InputOTP>
34
+ ```
35
+
36
+ - มีช่องกรอกจริงหนึ่งช่องซ้อนอยู่ใต้กล่อง จึงวาง (paste) รหัสทั้งชุด และกรอกอัตโนมัติจาก SMS บนมือถือได้
37
+ - ใส่ `InputOTPSlot` ให้ครบตาม `maxLength` โดย `index` เริ่มที่ 0
38
+
39
+ ## When to use
40
+
41
+ - รหัสยืนยันตัวตนแบบใช้ครั้งเดียว เมื่อเข้าสู่ระบบหรือยืนยันการถอนเงิน
42
+
43
+ ## When not to use
44
+
45
+ - **รหัสผ่าน หรือตัวเลขยาวอื่น ๆ** (เลขบัญชี, TFN): ใช้ `Input`
46
+ - **PIN ที่ต้องซ่อนตัวเลข**: TODO: ยังไม่มีตัวเลือกซ่อนตัวเลขในกล่อง
47
+
48
+ ## Props and variants
49
+
50
+ ไม่มี variant หรือ size กล่องละ 36px หน้าตาเหมือน `Input` แบบ `filled` กล่องในกลุ่มเดียวกันต่อกันเป็นแคปซูล
51
+
52
+ | ส่วน / Prop | ความหมาย |
53
+ | ------------------------------- | ---------------------------------------------------- |
54
+ | `InputOTP` `maxLength` | **บังคับ** จำนวนตัวอักษร |
55
+ | `InputOTP` `value` / `onChange` | ควบคุมค่าจากภายนอก |
56
+ | `InputOTP` `onComplete` | เรียกเมื่อกรอกครบ ใช้ส่งรหัสไปตรวจได้ทันที |
57
+ | `InputOTP` `pattern` | จำกัดตัวอักษรที่กรอกได้ TODO: ยังไม่มีตัวอย่าง (เช่น ตัวเลขเท่านั้น) |
58
+ | `InputOTP` `disabled` | ปิดใช้งาน จางลง 50% |
59
+ | `InputOTPGroup` | กลุ่มกล่องที่ต่อกัน |
60
+ | `InputOTPSlot` `index` | **บังคับ** ตำแหน่งของกล่อง |
61
+ | `InputOTPSlot` `aria-invalid` | รหัสไม่ถูกต้อง เส้นขอบสีแดง |
62
+ | `InputOTPSeparator` | ขีดคั่นระหว่างกลุ่ม |
63
+
64
+ กล่องที่กำลังกรอกมีวงแหวนทึบสี `--focus-ring` (สีแดงเมื่อข้อมูลไม่ถูกต้อง) และเคอร์เซอร์กะพริบ
65
+
66
+ ## Tokens used
67
+
68
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
69
+
70
+ ### Component tokens
71
+
72
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
73
+
74
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
75
+ | ------------------ | ------------------- | ------------------- | ----------------------------------------------- |
76
+ | `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
77
+ | `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
78
+ | `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
79
+ | `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
80
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
81
+
82
+ ### Semantic tokens
83
+
84
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
85
+ | ------------------ | -------------------------- | -------------------------- | --------------------------- |
86
+ | `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นกล่อง (50%) และเส้นขอบ |
87
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | กล่องที่กำลังกรอก |
88
+ | `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เคอร์เซอร์ |
89
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
90
+ | `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
91
+
92
+ ## Example
93
+
94
+ จาก story `Invalid` ใน `InputOTP.stories.tsx`:
95
+
96
+ ```tsx
97
+ <InputOTP id="otp-invalid" maxLength={6} defaultValue="123456">
98
+ <InputOTPGroup>
99
+ {[0, 1, 2, 3, 4, 5].map((index) => (
100
+ <InputOTPSlot key={index} index={index} aria-invalid />
101
+ ))}
102
+ </InputOTPGroup>
103
+ </InputOTP>
104
+ <p className="text-sm text-destructive">รหัสไม่ถูกต้อง กรุณาลองอีกครั้ง</p>
105
+ ```
@@ -0,0 +1,85 @@
1
+ # Kbd (ปุ่มคีย์บอร์ด)
2
+
3
+ ## Purpose
4
+
5
+ แสดงปุ่มบนคีย์บอร์ดหรือคีย์ลัด เช่น ⌘ K ในข้อความ เมนู หรือ Tooltip
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ```tsx
16
+ import { Kbd, KbdGroup } from "@designil/labdsnov"
17
+
18
+ ;<p>
19
+ กด{" "}
20
+ <KbdGroup>
21
+ <Kbd>⌘</Kbd>
22
+ <Kbd>K</Kbd>
23
+ </KbdGroup>{" "}
24
+ เพื่อค้นหากองทุน
25
+ </p>
26
+ ```
27
+
28
+ - ปุ่มที่กดพร้อมกันใส่ใน `KbdGroup`
29
+ - เขียนชื่อปุ่มตามที่พิมพ์บนคีย์บอร์ด (`Enter`, `Esc`, `⌘`) ไม่แปลเป็นภาษาไทย
30
+ - TODO: ยังไม่ได้กำหนดว่าจะแสดง ⌘ (macOS) หรือ Ctrl (Windows) ตามเครื่องของผู้ใช้อย่างไร
31
+
32
+ ## When to use
33
+
34
+ - บอกคีย์ลัดใน Tooltip, เมนู หรือข้อความช่วยเหลือ
35
+ - คำใบ้ในช่องค้นหา (ใน `InputGroup`)
36
+
37
+ ## When not to use
38
+
39
+ - **เป็นปุ่มให้กด**: ใช้ `Button` (Kbd กดไม่ได้)
40
+ - **โค้ดหรือค่าที่ผู้ใช้ต้องพิมพ์ตาม เช่น เลขสมาชิก**: ใช้ `<code>` หรือข้อความปกติ
41
+
42
+ ## Props and variants
43
+
44
+ ไม่มี variant หรือ size สูง 22px ตัวอักษร 12px มุมโค้ง 10px
45
+
46
+ - **ใน Tooltip**: สีกลับตาม Tooltip อัตโนมัติ
47
+ - **ใน InputGroup**: พื้นเปลี่ยนตามช่องกรอก
48
+ - `Kbd` และ `KbdGroup` เป็น `<kbd>` ใส่ `className` ได้
49
+
50
+ ## Tokens used
51
+
52
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
53
+
54
+ ### Component tokens
55
+
56
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
57
+
58
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
59
+ | ------------------ | -------------------- | ------------------ | ------------------------ |
60
+ | `--kbd-bg` | `--muted` | – | พื้นปุ่มคีย์บอร์ด |
61
+ | `--kbd-fg` | `--muted-foreground` | – | ตัวอักษรปุ่มคีย์บอร์ด |
62
+ | `--kbd-tooltip-bg` | `--tooltip-fg` 20% | `--tooltip-fg` 12% | พื้นปุ่มคีย์บอร์ดใน Tooltip |
63
+ | `--kbd-tooltip-fg` | `--tooltip-fg` | – | ตัวอักษรปุ่มคีย์บอร์ดใน Tooltip |
64
+
65
+ ### Semantic tokens
66
+
67
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
68
+ | -------------------- | -------------------------- | -------------------------- | --------------------------- |
69
+ | `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
70
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
71
+
72
+ ## Example
73
+
74
+ จาก story `Shortcut` ใน `Kbd.stories.tsx`:
75
+
76
+ ```tsx
77
+ <p className="text-sm">
78
+ กด{" "}
79
+ <KbdGroup>
80
+ <Kbd>⌘</Kbd>
81
+ <Kbd>K</Kbd>
82
+ </KbdGroup>{" "}
83
+ เพื่อค้นหากองทุน
84
+ </p>
85
+ ```
@@ -0,0 +1,75 @@
1
+ # Label (ป้ายชื่อช่องกรอก)
2
+
3
+ ## Purpose
4
+
5
+ ป้ายชื่อของช่องกรอกข้อมูล บอกว่าช่องนั้นให้กรอกอะไร และบอกว่าบังคับกรอกหรือไม่
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ```tsx
16
+ import { Input, Label } from "@designil/labdsnov"
17
+
18
+ ;<div className="grid gap-2">
19
+ <Label htmlFor="full-name" required>
20
+ ชื่อ-นามสกุล
21
+ </Label>
22
+ <Input id="full-name" required />
23
+ </div>
24
+ ```
25
+
26
+ `htmlFor` ของ Label ต้องตรงกับ `id` ของช่องกรอก
27
+
28
+ ## When to use
29
+
30
+ - ทุกช่อง `Input` ต้องมี Label ผูกไว้ คลิกที่ Label แล้วโฟกัสจะไปที่ช่อง และโปรแกรมอ่านหน้าจออ่านชื่อนี้เป็นชื่อของช่อง
31
+ - วางไว้เหนือช่อง ห่างกัน 8px ตาม stories
32
+ - ช่องที่บังคับกรอก ใส่ `required` ให้มีดอกจันสีแดงต่อท้าย
33
+
34
+ ## When not to use
35
+
36
+ - **หัวข้อของส่วนหรือของหน้า**: ใช้หัวข้อ (heading) แทน
37
+ - **ข้อความช่วยเหลือหรือข้อความผิดพลาดใต้ช่อง**: ใช้ `FieldDescription` / `FieldError` ผูกด้วย `aria-describedby` (ดู [Field](../Field/Field.md)) ในฟอร์มใช้ `FieldLabel` แทน Label ได้
38
+ - **ป้ายที่ไม่ได้ผูกกับช่องใด**: ถ้าไม่มี `htmlFor` ป้ายจะไม่ทำหน้าที่ใด ๆ
39
+
40
+ ## Props and variants
41
+
42
+ ไม่มี variant หรือ size ตัวอักษร 14px น้ำหนัก medium
43
+
44
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
45
+ | ----------- | --------- | ------- | ------------------------------------------- |
46
+ | `htmlFor` | id ของช่อง | – | ผูกป้ายกับช่องกรอก **ต้องใส่เสมอ** |
47
+ | `required` | `boolean` | `false` | แสดงดอกจันสีแดงต่อท้ายข้อความ |
48
+ | `children` | ข้อความ | – | ชื่อช่อง เป็นภาษาไทย สั้น เช่น "อีเมล", "ชื่อ-นามสกุล" |
49
+ | `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของป้ายเสมอ |
50
+
51
+ - `required` เป็นแค่เครื่องหมายที่มองเห็น ไม่ได้ทำให้ช่องบังคับกรอก ต้องใส่ `required` ที่ `Input` ด้วย TODO: ยังไม่ได้ตรวจว่าโปรแกรมอ่านหน้าจออ่านดอกจันออกมาหรือไม่
52
+ - **สถานะปิดใช้งาน**: ป้ายจางลง 50% เมื่อช่องที่ผูกไว้ถูกปิดใช้งาน แต่ **ไม่เกิดขึ้นเอง** ต้องจัดโครงสร้างตาม story `DisabledPeer` หรือ `DisabledGroup` ถ้าวางป้ายเหนือช่องแบบปกติ ป้ายจะไม่จาง
53
+
54
+ ## Tokens used
55
+
56
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
57
+
58
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
59
+ | --------------- | -------------------------- | -------------------------- | -------------------- |
60
+ | `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ข้อความ (สืบทอดจากหน้า) |
61
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | ดอกจันของ `required` |
62
+ | `--font-sans` | system font stack | – | ข้อความ |
63
+
64
+ ## Example
65
+
66
+ จาก story `WithInput` ใน `Label.stories.tsx`:
67
+
68
+ ```tsx
69
+ <div className="grid w-80 gap-2">
70
+ <Label htmlFor="label-email" required>
71
+ อีเมล
72
+ </Label>
73
+ <Input id="label-email" type="email" placeholder="you@example.com" />
74
+ </div>
75
+ ```
@@ -0,0 +1,128 @@
1
+ # NavigationMenu (เมนูนำทาง)
2
+
3
+ ## Purpose
4
+
5
+ แถบเมนูหลักของเว็บ มีลิงก์ตรงและเมนูที่เปิดแผงลิงก์ย่อย
6
+
7
+ ## Import and usage
8
+
9
+ **ตั้งค่าครั้งเดียวในแอป** (ใช้ร่วมกันทุกคอมโพเนนต์):
10
+
11
+ 1. ติดตั้ง `@designil/labdsnov` (`pnpm add @designil/labdsnov`) พร้อม `react` และ `react-dom` 19
12
+ 2. import สไตล์ครั้งเดียวที่ root layout: `import "@designil/labdsnov/styles.css"`
13
+ 3. กำหนดตัวแปร `--font-heading` (แอปใช้ IBM Plex Sans Thai) และใส่ class `dark` ที่ `<html>` เมื่อต้องการโหมดมืด
14
+
15
+ ```tsx
16
+ import {
17
+ NavigationMenu,
18
+ NavigationMenuContent,
19
+ NavigationMenuItem,
20
+ NavigationMenuLink,
21
+ NavigationMenuList,
22
+ NavigationMenuTrigger,
23
+ navigationMenuTriggerStyle,
24
+ } from "@designil/labdsnov"
25
+
26
+ ;<NavigationMenu aria-label="เมนูหลัก">
27
+ <NavigationMenuList>
28
+ <NavigationMenuItem>
29
+ <NavigationMenuLink href="/" className={navigationMenuTriggerStyle()}>
30
+ หน้าแรก
31
+ </NavigationMenuLink>
32
+ </NavigationMenuItem>
33
+ <NavigationMenuItem>
34
+ <NavigationMenuTrigger>บัญชีของฉัน</NavigationMenuTrigger>
35
+ <NavigationMenuContent>
36
+ <NavigationMenuLink href="/transactions">ธุรกรรม</NavigationMenuLink>
37
+ </NavigationMenuContent>
38
+ </NavigationMenuItem>
39
+ </NavigationMenuList>
40
+ </NavigationMenu>
41
+ ```
42
+
43
+ - ลิงก์ระดับบนที่ไม่มีแผงย่อย ใส่ `className={navigationMenuTriggerStyle()}` ให้หน้าตาเหมือนปุ่มเปิดเมนู
44
+ - ใส่ `aria-label` ให้เมนูเมื่อมีเมนูนำทางหลายชุดในหน้า
45
+ - ลิงก์ของ Next.js ใช้ `render={<Link href="…" />}`
46
+
47
+ ## When to use
48
+
49
+ - เมนูหลักบนจอกว้าง ที่มีหมวดหมู่และลิงก์ย่อย เช่น บัญชีของฉัน / ลงทุน / เอกสาร
50
+
51
+ ## When not to use
52
+
53
+ | สถานการณ์ | ใช้แทน |
54
+ | ------------------------- | ------------------------------------------ |
55
+ | เมนูบนมือถือ | TODO: ยังไม่ได้ออกแบบเมนูบนมือถือ (เช่น `Drawer`) |
56
+ | คำสั่งของรายการ (แก้ไข / ลบ) | `DropdownMenu` |
57
+ | สลับมุมมองในหน้าเดียวกัน | `Tabs` |
58
+ | บอกตำแหน่งของหน้าปัจจุบัน | `Breadcrumb` |
59
+
60
+ ## Props and variants
61
+
62
+ | ส่วน / Prop | ความหมาย |
63
+ | ------------------------------------------ | ----------------------------------------------------------- |
64
+ | `NavigationMenu` `align` | การจัดแนวแผงย่อยตามปุ่ม: `start` (ค่าเริ่มต้น), `center`, `end` |
65
+ | `NavigationMenu` `value` / `onValueChange` | ควบคุมว่าแผงไหนเปิด |
66
+ | `NavigationMenuTrigger` | ปุ่มเปิดแผงย่อย มีลูกศรที่หมุนเมื่อเปิด |
67
+ | `NavigationMenuContent` | แผงลิงก์ย่อย กำหนดความกว้างเอง เช่น `<ul className="grid w-80">` |
68
+ | `NavigationMenuLink` `active` | หน้าปัจจุบัน: พื้นเทาจาง |
69
+ | `NavigationMenuIndicator` | ลูกศรเล็กใต้ปุ่มที่เปิด (ไม่บังคับ) |
70
+
71
+ ### พฤติกรรมที่มีให้แล้ว
72
+
73
+ - เปิดแผงเมื่อชี้เมาส์หรือคลิก แผงทุกอันใช้กล่องเดียวกันที่เปลี่ยนขนาดและเลื่อนระหว่างแผง
74
+ - คีย์บอร์ด: Tab ไปที่ปุ่ม Enter/Space เปิด Escape ปิด TODO: ยังไม่ได้ตรวจการใช้ลูกศรระหว่างปุ่ม
75
+
76
+ ## Tokens used
77
+
78
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
79
+
80
+ ### Component tokens
81
+
82
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
83
+
84
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
85
+ | -------------- | -------- | ------ | --------------------------------------------- |
86
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
87
+
88
+ ### Semantic tokens
89
+
90
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
91
+ | ---------------------- | -------------------------- | -------------------------- | -------------------------------------------- |
92
+ | `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | hover / focus ของปุ่มและลิงก์, ลิงก์ที่ active (50%) |
93
+ | `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นแผงย่อย |
94
+ | `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรในแผง |
95
+ | `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เส้นขอบบาง ๆ รอบแผง (5% สว่าง, 10% มืด) |
96
+ | `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | ลูกศร indicator |
97
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
98
+
99
+ ## Example
100
+
101
+ จาก story `Playground` ใน `NavigationMenu.stories.tsx` (บางส่วน):
102
+
103
+ ```tsx
104
+ <NavigationMenu aria-label="เมนูหลัก">
105
+ <NavigationMenuList>
106
+ <NavigationMenuItem>
107
+ <NavigationMenuLink href="#home" className={navigationMenuTriggerStyle()}>
108
+ หน้าแรก
109
+ </NavigationMenuLink>
110
+ </NavigationMenuItem>
111
+ <NavigationMenuItem>
112
+ <NavigationMenuTrigger>ลงทุน</NavigationMenuTrigger>
113
+ <NavigationMenuContent>
114
+ <ul className="grid w-64 gap-1">
115
+ <li>
116
+ <NavigationMenuLink href="#options">
117
+ ตัวเลือกการลงทุน
118
+ </NavigationMenuLink>
119
+ </li>
120
+ <li>
121
+ <NavigationMenuLink href="#switch">เปลี่ยนแผน</NavigationMenuLink>
122
+ </li>
123
+ </ul>
124
+ </NavigationMenuContent>
125
+ </NavigationMenuItem>
126
+ </NavigationMenuList>
127
+ </NavigationMenu>
128
+ ```