@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,143 @@
1
+ # Combobox (ช่องค้นหาและเลือก)
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
+ Combobox,
18
+ ComboboxContent,
19
+ ComboboxEmpty,
20
+ ComboboxInput,
21
+ ComboboxItem,
22
+ ComboboxList,
23
+ Label,
24
+ } from "@designil/labdsnov"
25
+
26
+ <Label htmlFor="country">ประเทศที่พำนักทางภาษี</Label>
27
+ <Combobox items={countries}>
28
+ <ComboboxInput id="country" placeholder="พิมพ์เพื่อค้นหา" />
29
+ <ComboboxContent>
30
+ <ComboboxEmpty>ไม่พบประเทศที่ค้นหา</ComboboxEmpty>
31
+ <ComboboxList>
32
+ {(item: string) => <ComboboxItem key={item} value={item}>{item}</ComboboxItem>}
33
+ </ComboboxList>
34
+ </ComboboxContent>
35
+ </Combobox>
36
+ ```
37
+
38
+ - ส่งรายการทั้งหมดเป็น `items` แล้วใช้ฟังก์ชันใน `ComboboxList` เพื่อแสดงเฉพาะที่ตรงกับคำค้น
39
+ - ใส่ `ComboboxEmpty` เสมอ แสดงเมื่อไม่มีรายการตรงกับคำค้น
40
+ - รายการที่เป็น object ใช้ `itemToStringLabel` ของ `Combobox` บอกว่าข้อความไหนใช้ค้นหาและแสดง
41
+
42
+ ## When to use
43
+
44
+ - เลือกหนึ่งค่าจากรายการยาวมากที่ผู้ใช้รู้ชื่ออยู่แล้ว เช่น ประเทศ ธนาคาร
45
+ - เลือกหลายค่า (`multiple`) แสดงเป็นชิป เช่น ประเทศที่เคยทำงาน
46
+
47
+ ## When not to use
48
+
49
+ | สถานการณ์ | ใช้แทน |
50
+ | ---------------------------------- | ------------ |
51
+ | รายการไม่ยาว (ไม่ถึงประมาณ 15 ตัวเลือก) | `Select` |
52
+ | 2–5 ตัวเลือกที่ควรเห็นทั้งหมด | `RadioGroup` |
53
+ | ข้อความอิสระที่ไม่ต้องตรงกับรายการ | `Input` |
54
+
55
+ TODO: ยังไม่ได้กำหนดจำนวนตัวเลือกที่ควรเปลี่ยนจาก `Select` เป็น Combobox
56
+
57
+ ## Props and variants
58
+
59
+ ### ComboboxInput
60
+
61
+ | Prop | ค่าเริ่มต้น | ความหมาย |
62
+ | ------------- | ------- | ----------------------------- |
63
+ | `showTrigger` | `true` | ปุ่มลูกศรเปิดรายการ |
64
+ | `showClear` | `false` | ปุ่ม "×" ล้างค่า (ซ่อนลูกศรเมื่อมีปุ่มนี้) |
65
+ | `disabled` | `false` | ปิดใช้งาน |
66
+ | `placeholder` | – | เช่น "พิมพ์เพื่อค้นหา" |
67
+
68
+ หน้าตาเหมือน `InputGroup` (และ `Input` แบบ `filled`) กว้างตามเนื้อหา ใส่ `className="w-full"` ในฟอร์ม
69
+
70
+ ### Combobox
71
+
72
+ | Prop | ความหมาย |
73
+ | ------------------------- | ----------------------------------- |
74
+ | `items` | รายการทั้งหมด |
75
+ | `value` / `onValueChange` | ควบคุมค่าที่เลือกจากภายนอก |
76
+ | `defaultValue` | ค่าที่เลือกไว้ตอนแรก |
77
+ | `multiple` | เลือกได้หลายค่า (ใช้กับ `ComboboxChips`) |
78
+
79
+ ### เลือกหลายค่า (ชิป)
80
+
81
+ ใช้ `ComboboxChips` + `ComboboxValue` + `ComboboxChip` + `ComboboxChipsInput` แทน `ComboboxInput` และส่ง `anchor` จาก `useComboboxAnchor()` ให้ `ComboboxContent` (ดู story `MultipleChips`) ชิปแต่ละอันมีปุ่ม "นำออก"
82
+
83
+ ### ส่วนอื่น ๆ
84
+
85
+ `ComboboxGroup` + `ComboboxLabel` จัดกลุ่มรายการ, `ComboboxSeparator` เส้นคั่น, `ComboboxItem` `disabled` รายการที่เลือกไม่ได้ รายการที่เลือกแล้วมีเครื่องหมายถูกด้านขวา
86
+
87
+ ## Tokens used
88
+
89
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
90
+
91
+ ### Component tokens
92
+
93
+ token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
94
+
95
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
96
+ | -------------------------- | --------------------- | ------------------- | ----------------------------------------------- |
97
+ | `--field-icon` | `--muted-foreground` | – | ไอคอนในช่อง เช่น ลูกศร |
98
+ | `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
99
+ | `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
100
+ | `--menu-item-highlight-bg` | `--accent` | – | พื้นรายการที่ไฮไลต์ |
101
+ | `--menu-item-highlight-fg` | `--accent-foreground` | – | ตัวอักษรรายการที่ไฮไลต์ |
102
+ | `--menu-label-fg` | `--muted-foreground` | – | หัวข้อกลุ่ม, ปุ่มลัด |
103
+ | `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
104
+ | `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
105
+ | `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
106
+
107
+ ### Semantic tokens
108
+
109
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
110
+ | ---------------------- | -------------------------- | -------------------------- | --------------------------- |
111
+ | `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นช่องกรอกและชิป |
112
+ | `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นรายการ |
113
+ | `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรในรายการ |
114
+ | `--accent` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | พื้นรายการที่ไฮไลต์ |
115
+ | `--accent-foreground` | `oklch(0.228 0.013 107.4)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรรายการที่ไฮไลต์ |
116
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ลูกศร, หัวข้อกลุ่ม, ข้อความไม่พบ |
117
+ | `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นคั่น |
118
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
119
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
120
+ | `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
121
+
122
+ ## Example
123
+
124
+ จาก story `MultipleChips` ใน `Combobox.stories.tsx`:
125
+
126
+ ```tsx
127
+ const anchor = useComboboxAnchor()
128
+
129
+ <Combobox items={countries} multiple defaultValue={["ไทย", "ออสเตรเลีย"]}>
130
+ <ComboboxChips ref={anchor}>
131
+ <ComboboxValue>
132
+ {(values: string[]) => values.map((value) => <ComboboxChip key={value}>{value}</ComboboxChip>)}
133
+ </ComboboxValue>
134
+ <ComboboxChipsInput id="cb-chips" placeholder="เพิ่มประเทศ" />
135
+ </ComboboxChips>
136
+ <ComboboxContent anchor={anchor}>
137
+ <ComboboxEmpty>ไม่พบประเทศที่ค้นหา</ComboboxEmpty>
138
+ <ComboboxList>
139
+ {(item: string) => <ComboboxItem key={item} value={item}>{item}</ComboboxItem>}
140
+ </ComboboxList>
141
+ </ComboboxContent>
142
+ </Combobox>
143
+ ```
@@ -0,0 +1,82 @@
1
+ # DatePicker (ช่องเลือกวันที่)
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 { DatePicker, Label } from "@designil/labdsnov"
17
+
18
+ <Label htmlFor="start-date">วันที่เริ่มงาน</Label>
19
+ <DatePicker id="start-date" value={date} onValueChange={setDate} />
20
+ ```
21
+
22
+ - แสดงวันที่แบบเดียวกับ `FundCard` เช่น "13 พ.ย. 2569"
23
+ - เลือกแล้วกล่องปิดเอง
24
+ - shadcn ไม่มีคอมโพเนนต์นี้ (มีแค่ตัวอย่างการประกอบ) ระบบนี้ประกอบจาก `Popover` + `Calendar` + `Button` ให้แล้ว
25
+
26
+ ## When to use
27
+
28
+ - ช่องวันที่ในฟอร์ม เช่น วันที่เริ่มงาน วันที่ต้องการให้มีผล
29
+
30
+ ## When not to use
31
+
32
+ - **ช่วงวันที่**: TODO: ยังไม่รองรับช่วง ใช้ `Calendar mode="range"` ใน `Popover` เอง
33
+ - **วันที่ไกลมาก เช่น วันเกิด**: ใช้ได้ แต่ต้องเปิด dropdown ปี (story `DateOfBirth`) TODO: ยังไม่มีช่องพิมพ์วันที่
34
+ - **แสดงวันที่อย่างเดียว**: ใช้ข้อความ
35
+
36
+ ## Props and variants
37
+
38
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
39
+ | ------------------------- | -------------------- | --------- | ---------------------------------------------------------------------- |
40
+ | `value` / `onValueChange` | `Date` / ฟังก์ชัน | – | ควบคุมค่าจากภายนอก |
41
+ | `defaultValue` | `Date` | – | วันที่เลือกไว้ตอนแรก |
42
+ | `placeholder` | ข้อความ | "เลือกวันที่" | แสดงเมื่อยังไม่เลือก (สี muted) |
43
+ | `id` | ข้อความ | – | ผูกกับ `Label` ผ่าน `htmlFor` |
44
+ | `disabled` | `boolean` | `false` | ปิดใช้งาน |
45
+ | `aria-invalid` | `boolean` | – | ข้อมูลไม่ถูกต้อง |
46
+ | `aria-describedby` | id | – | ผูกข้อความช่วยเหลือหรือข้อความผิดพลาด |
47
+ | `calendarProps` | props ของ `Calendar` | – | เช่น `disabled` วันที่เลือกไม่ได้, `captionLayout="dropdown"`, `defaultMonth` |
48
+ | `className` | class | – | ปกติกว้าง 240px ใส่ `w-full` ในฟอร์ม |
49
+
50
+ หน้าตา: ปุ่ม outline ไอคอนปฏิทินด้านซ้าย ข้อความชิดซ้าย TODO: หน้าตาต่างจาก `Input` / `Select` (แบบ `filled`) ยังไม่ได้ตัดสินใจว่าจะทำให้เหมือนกันหรือไม่
51
+
52
+ ## Tokens used
53
+
54
+ ใช้ token ของ `Button` (`outline`), `Popover` และ `Calendar`
55
+
56
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
57
+
58
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
59
+ | -------------------- | ------------------------- | -------------------------- | ------------ |
60
+ | `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบปุ่ม |
61
+ | `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | พื้นปุ่ม |
62
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | placeholder |
63
+ | `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
64
+ | `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
65
+
66
+ ## Example
67
+
68
+ จาก story `DateOfBirth` ใน `DatePicker.stories.tsx`:
69
+
70
+ ```tsx
71
+ <Label htmlFor="dp-dob">วันเกิด</Label>
72
+ <DatePicker
73
+ id="dp-dob"
74
+ calendarProps={{
75
+ captionLayout: "dropdown",
76
+ defaultMonth: new Date(1985, 0),
77
+ startMonth: new Date(1940, 0),
78
+ endMonth: new Date(2026, 10),
79
+ disabled: { after: new Date(2026, 10, 13) },
80
+ }}
81
+ />
82
+ ```
@@ -0,0 +1,193 @@
1
+ # Dialog (กล่องโต้ตอบ)
2
+
3
+ ## Purpose
4
+
5
+ หน้าต่างแบบ modal ที่ลอยทับหน้า ให้ผู้ใช้ตัดสินใจหรือกรอกข้อมูลสั้น ๆ ให้เสร็จก่อนกลับไปทำงานต่อ
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
+ Button,
18
+ Dialog,
19
+ DialogClose,
20
+ DialogContent,
21
+ DialogDescription,
22
+ DialogFooter,
23
+ DialogHeader,
24
+ DialogTitle,
25
+ DialogTrigger,
26
+ } from "@designil/labdsnov"
27
+
28
+ ;<Dialog>
29
+ <DialogTrigger render={<Button variant="outline" />}>
30
+ เปลี่ยนแผนการลงทุน
31
+ </DialogTrigger>
32
+ <DialogContent>
33
+ <DialogHeader>
34
+ <DialogTitle>เปลี่ยนแผนการลงทุน</DialogTitle>
35
+ <DialogDescription>การเปลี่ยนแผนจะมีผลกับเงินสมทบงวดถัดไป</DialogDescription>
36
+ </DialogHeader>
37
+ <DialogFooter>
38
+ <DialogClose render={<Button variant="outline" />}>ยกเลิก</DialogClose>
39
+ <DialogClose render={<Button />}>เปลี่ยนแผน</DialogClose>
40
+ </DialogFooter>
41
+ </DialogContent>
42
+ </Dialog>
43
+ ```
44
+
45
+ ควบคุมการเปิด/ปิดเอง (เช่น ปิดหลังบันทึกสำเร็จ) ใช้ `open` กับ `onOpenChange` ในไฟล์ที่มี `"use client"`:
46
+
47
+ ```tsx
48
+ "use client"
49
+
50
+ import { useState } from "react"
51
+
52
+ const [open, setOpen] = useState(false)
53
+
54
+ <Dialog open={open} onOpenChange={setOpen}>…</Dialog>
55
+ ```
56
+
57
+ ## When to use
58
+
59
+ - ยืนยันการตัดสินใจสำคัญที่ผู้ใช้เริ่มเอง เช่น เปลี่ยนแผนการลงทุน
60
+ - ยืนยันการกระทำที่ย้อนกลับไม่ได้: **ใช้ `AlertDialog`** (ดู [AlertDialog](../AlertDialog/AlertDialog.md)) ซึ่งประกาศเป็น `alertdialog` และปิดด้วยการคลิกนอกกล่องไม่ได้ ตัวอย่าง `ConfirmDelete` ด้านล่างเขียนไว้ก่อนมี AlertDialog
61
+ - ฟอร์มสั้น ๆ 1–3 ช่อง ที่ไม่ต้องออกจากหน้าเดิม เช่น แก้ไขข้อมูลบัญชี
62
+
63
+ ใช้เท่าที่จำเป็น ระบบดีไซน์หลัก (Carbon, Atlassian, Polaris) ถือว่า modal เป็นทางเลือกท้าย ๆ เพราะขัดจังหวะผู้ใช้
64
+
65
+ ## When not to use
66
+
67
+ | สถานการณ์ | ใช้แทน |
68
+ | ---------------------------------- | -------------------------------------------- |
69
+ | ข้อความแจ้งที่ไม่ต้องตอบ (เช่น "บันทึกแล้ว") | `toast` (ดู [Toaster](../Toaster/Toaster.md)) |
70
+ | งานที่ผู้ใช้ทำบ่อย | ทำในหน้าโดยตรง |
71
+ | เนื้อหายาว ตารางใหญ่ หรือฟอร์มหลายขั้นตอน | หน้าใหม่ |
72
+ | การกระทำที่ย้อนกลับได้ (ลบแล้วกู้คืนได้) | ทำทันทีแล้วให้ "เลิกทำ" แทนการถามยืนยัน |
73
+ | เปิด dialog ซ้อนจาก dialog | รวมเป็น dialog เดียว หรือย้ายไปหน้าใหม่ |
74
+ | ตัวเลือกเล็ก ๆ ข้างปุ่ม | `Popover` หรือ `DropdownMenu` |
75
+ | แผงที่เลื่อนขึ้นจากขอบจอบนมือถือ | `Drawer` (ดู [Drawer](../Drawer/Drawer.md)) |
76
+
77
+ ## Anatomy
78
+
79
+ ประกอบด้วยส่วนเหล่านี้ ซ้อนกันตามลำดับ:
80
+
81
+ - **Dialog**: ตัวครอบ ควบคุมการเปิด/ปิด
82
+ - **DialogTrigger**: ปุ่มที่เปิด dialog (ใช้ `Button` ผ่าน `render`)
83
+ - **DialogContent**: กล่องที่ลอยกลางจอ มีฉากหลังมืดและเบลอ และปุ่ม "ปิด" มุมขวาบน
84
+ - **DialogHeader** → **DialogTitle** (บังคับ) + **DialogDescription** (แนะนำ)
85
+ - เนื้อหา เช่น ช่องกรอกข้อมูล
86
+ - **DialogFooter** → ปุ่ม **DialogClose** (ใช้ `Button` ผ่าน `render`)
87
+
88
+ ชื่อเรื่องและคำอธิบายจะถูกอ่านโดยโปรแกรมอ่านหน้าจอเมื่อเปิด dialog จึงต้องมี `DialogTitle` เสมอ
89
+
90
+ ## Props and variants
91
+
92
+ ### Dialog
93
+
94
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
95
+ | ------------------------- | ------------------------------- | ------- | ----------------------------------------------- |
96
+ | `open` / `onOpenChange` | `boolean` / ฟังก์ชัน | – | ควบคุมการเปิด/ปิดจากภายนอก |
97
+ | `defaultOpen` | `boolean` | `false` | เปิดไว้ตั้งแต่แรก |
98
+ | `modal` | `true`, `false`, `"trap-focus"` | `true` | `true` = ล็อกโฟกัส ล็อกการเลื่อนหน้า และกดนอกกล่องไม่ได้ |
99
+ | `disablePointerDismissal` | `boolean` | `false` | ปิดการปิด dialog เมื่อคลิกนอกกล่อง |
100
+
101
+ ### DialogContent
102
+
103
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
104
+ | ----------------- | --------------------------- | ------------- | --------------------------------------------- |
105
+ | `size` | `sm`, `default`, `lg`, `xl` | `default` | ความกว้างสูงสุด (ดูตารางด้านล่าง) |
106
+ | `showCloseButton` | `boolean` | `true` | แสดงปุ่มไอคอน "ปิด" มุมขวาบน |
107
+ | `initialFocus` | element | ช่องแรกที่โฟกัสได้ | element ที่ได้โฟกัสเมื่อเปิด |
108
+ | `finalFocus` | element | ปุ่มที่เปิด | element ที่ได้โฟกัสเมื่อปิด |
109
+ | `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของ dialog เสมอ |
110
+
111
+ | Size | ความกว้างสูงสุด (จอ 640px ขึ้นไป) | ใช้กับ (จาก stories) |
112
+ | --------- | ---------------------------- | ------------------------- |
113
+ | `sm` | 384px | ยืนยันการลบ, ฟอร์มสั้น |
114
+ | `default` | 448px | ยืนยันการตัดสินใจทั่วไป |
115
+ | `lg` | 512px | TODO: ยังไม่มีตัวอย่างการใช้งาน |
116
+ | `xl` | 672px | TODO: ยังไม่มีตัวอย่างการใช้งาน |
117
+
118
+ บนจอแคบกว่า 640px ทุกขนาดกว้างเต็มจอ เว้นขอบซ้าย-ขวาข้างละ 16px
119
+
120
+ ### DialogFooter
121
+
122
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
123
+ | ----------------- | --------- | ------- | ------------------------------------------------------ |
124
+ | `showCloseButton` | `boolean` | `false` | เพิ่มปุ่ม outline "ปิด" ท้ายแถว ใช้กับ dialog ที่แจ้งข้อมูลอย่างเดียว |
125
+
126
+ ### พฤติกรรมที่มีให้แล้ว
127
+
128
+ - กด **Escape**, ปุ่ม "ปิด", หรือคลิกนอกกล่อง (ค่าเริ่มต้น) เพื่อปิด
129
+ - เปิดแล้วโฟกัสย้ายเข้า dialog ไปที่ช่องแรกที่โฟกัสได้ และวนอยู่ภายใน dialog ปิดแล้วโฟกัสกลับไปที่ปุ่มที่เปิด
130
+ - หน้าด้านหลังเลื่อนและคลิกไม่ได้ขณะเปิด
131
+ - ปุ่มใน footer: จอกว้างเรียงเป็นแถวชิดขวา จอแคบซ้อนเป็นแนวตั้งโดยปุ่มสุดท้ายอยู่บนสุด ดังนั้น **ใส่ปุ่มยกเลิกก่อน แล้วปุ่มหลักทีหลัง** ปุ่มหลักจะอยู่ขวาสุด (จอกว้าง) หรือบนสุด (จอแคบ)
132
+ - เปิด/ปิดด้วยการจางและย่อ-ขยายเล็กน้อย 100ms
133
+
134
+ ## Content rules
135
+
136
+ ตามแนวทางของ WAI-ARIA APG, Carbon, Atlassian, Polaris และ Apple HIG
137
+
138
+ - **ชื่อเรื่อง**: บอกสิ่งที่กำลังจะทำ ใช้คำเดียวกับปุ่มที่เปิด (เปิดจาก "แก้ไขข้อมูลบัญชี" → ชื่อ "แก้ไขข้อมูลบัญชี") สำหรับการยืนยัน เขียนเป็นคำถาม เช่น "ลบบัญชีผู้รับผลประโยชน์?"
139
+ - **คำอธิบาย**: บอกผลที่จะตามมา ถ้าย้อนกลับไม่ได้ต้องบอกตรง ๆ ไม่ต้องอธิบายว่าปุ่มทำอะไร
140
+ - **ปุ่ม**: ไม่เกิน 3 ปุ่ม มีปุ่มหลักปุ่มเดียว ใช้คำกริยาที่เจาะจง ("บันทึก", "ลบ", "เปลี่ยนแผน") หลีกเลี่ยง "ตกลง", "ใช่/ไม่", "ส่ง"
141
+ - **การกระทำอันตราย**: ปุ่มหลักใช้ `Button variant="destructive"` และต้องมีปุ่ม "ยกเลิก" เสมอ
142
+ - **ปุ่ม "ปิด" มุมขวาบน**: เก็บไว้เป็นค่าเริ่มต้น ซ่อนได้ (`showCloseButton={false}`) เฉพาะเมื่อ footer มีปุ่ม "ยกเลิก" ให้ออกได้แล้ว เช่น การยืนยันการลบ
143
+ - **เนื้อหายาว**: TODO: ตอนนี้ dialog ไม่จำกัดความสูงและไม่มีการเลื่อนเฉพาะเนื้อหา ถ้าเนื้อหาสูงกว่าจอให้ย้ายไปหน้าใหม่ จนกว่าจะตัดสินใจเรื่องนี้
144
+
145
+ ## Tokens used
146
+
147
+ ค่าทั้งหมดมาจาก `src/styles/theme.css` ปุ่มใน dialog ใช้ token ของ `Button`
148
+
149
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
150
+ | ---------------------- | -------------------------------- | ---------------------------- | -------------------------------------- |
151
+ | `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นของกล่อง |
152
+ | `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษรในกล่อง |
153
+ | `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | เส้นขอบบาง ๆ รอบกล่อง (5% สว่าง, 10% มืด) |
154
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ตัวอักษรคำอธิบาย |
155
+ | `--secondary` | `oklch(0.967 0.001 286.375)` | `oklch(0.274 0.006 286.033)` | พื้นปุ่ม "ปิด" มุมขวาบน |
156
+ | `--radius` | `0.625rem` | – | มุมโค้งของกล่อง (`--radius × 2.6` = 26px) |
157
+ | `--font-heading` | กำหนดโดยแอป (IBM Plex Sans Thai) | – | ชื่อเรื่อง (16px, medium) |
158
+ | `--font-sans` | system font stack | – | คำอธิบายและเนื้อหา (14px) |
159
+
160
+ ฉากหลังเป็นสีดำ 30% และเบลอ ซึ่งเป็นค่าตายตัว ไม่ใช่ token TODO: ตัดสินใจว่าควรเป็น token หรือไม่ ระยะห่างภายในกล่องคือ 24px
161
+
162
+ ## Example
163
+
164
+ จาก story `ConfirmDelete` ใน `Dialog.stories.tsx`:
165
+
166
+ ```tsx
167
+ <Dialog>
168
+ <DialogTrigger render={<Button variant="destructive" />}>
169
+ ยืนยันการลบ
170
+ </DialogTrigger>
171
+ <DialogContent size="sm" showCloseButton={false}>
172
+ <DialogHeader>
173
+ <DialogTitle>ลบบัญชีผู้รับผลประโยชน์?</DialogTitle>
174
+ <DialogDescription>
175
+ การลบนี้ไม่สามารถย้อนกลับได้ ข้อมูลผู้รับผลประโยชน์จะถูกลบออกจากบัญชีของคุณ
176
+ </DialogDescription>
177
+ </DialogHeader>
178
+ <DialogFooter>
179
+ <DialogClose render={<Button variant="outline" />}>ยกเลิก</DialogClose>
180
+ <DialogClose render={<Button variant="destructive" />}>ลบ</DialogClose>
181
+ </DialogFooter>
182
+ </DialogContent>
183
+ </Dialog>
184
+ ```
185
+
186
+ ## Open questions (TODO)
187
+
188
+ ช่องว่างระหว่าง Dialog ปัจจุบันกับมาตรฐาน ยังไม่ได้แก้:
189
+
190
+ - **Alert dialog**: แก้แล้ว ใช้ `AlertDialog` สำหรับการยืนยัน TODO: ย้ายตัวอย่าง `ConfirmDelete` ไปใช้ AlertDialog
191
+ - **โฟกัสแรกในการยืนยันการลบ**: ใน `AlertDialog` โฟกัสไปที่ "ยกเลิก" ตามที่ APG แนะนำ (มี story `OpenAndCancel` ตรวจ)
192
+ - **คลิกนอกกล่อง**: Carbon ไม่ให้ปิดเมื่อ dialog มีปุ่มการกระทำ ส่วน Atlassian และ Base UI ให้ปิด ตอนนี้ปิดได้ (ค่าเริ่มต้น)
193
+ - **มือถือ**: มี `Drawer` แล้ว TODO: ยังไม่ได้ตัดสินใจว่าจะสลับ Dialog กับ Drawer ตามขนาดจออัตโนมัติหรือไม่
@@ -0,0 +1,125 @@
1
+ # Drawer (แผงเลื่อน)
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
+ Button,
18
+ Drawer,
19
+ DrawerClose,
20
+ DrawerContent,
21
+ DrawerDescription,
22
+ DrawerFooter,
23
+ DrawerHeader,
24
+ DrawerTitle,
25
+ DrawerTrigger,
26
+ } from "@designil/labdsnov"
27
+
28
+ ;<Drawer showSwipeHandle>
29
+ <DrawerTrigger render={<Button variant="outline" />}>
30
+ เพิ่มเงินสมทบ
31
+ </DrawerTrigger>
32
+ <DrawerContent>
33
+ <DrawerHeader>
34
+ <DrawerTitle>เพิ่มเงินสมทบ</DrawerTitle>
35
+ <DrawerDescription>เงินจะเข้าบัญชีภายใน 3 วันทำการ</DrawerDescription>
36
+ </DrawerHeader>
37
+ …
38
+ <DrawerFooter>
39
+ <Button>ยืนยัน</Button>
40
+ <DrawerClose render={<Button variant="outline" />}>ยกเลิก</DrawerClose>
41
+ </DrawerFooter>
42
+ </DrawerContent>
43
+ </Drawer>
44
+ ```
45
+
46
+ - ใส่ `DrawerTitle` เสมอ เป็นชื่อของแผงสำหรับโปรแกรมอ่านหน้าจอ
47
+
48
+ ## When to use
49
+
50
+ - งานสั้น ๆ บนมือถือ เช่น ฟอร์มสั้น ตัวเลือก ตัวกรอง (ตอบ TODO "drawer" ใน `Dialog.md`)
51
+ - แผงด้านข้าง (`swipeDirection="right"`) เช่น ตัวกรองของตาราง
52
+
53
+ ## When not to use
54
+
55
+ | สถานการณ์ | ใช้แทน |
56
+ | --------------------------- | -------------- |
57
+ | ยืนยันการกระทำที่ย้อนกลับไม่ได้ | `AlertDialog` |
58
+ | บนจอกว้างที่กล่องกลางจอเหมาะกว่า | `Dialog` |
59
+ | เมนูคำสั่ง | `DropdownMenu` |
60
+
61
+ TODO: ยังไม่ได้ตัดสินใจว่าจะสลับ Dialog (จอกว้าง) กับ Drawer (มือถือ) อัตโนมัติหรือไม่ (shadcn มีตัวอย่าง "Responsive")
62
+
63
+ ## Props and variants
64
+
65
+ ### Drawer
66
+
67
+ | Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
68
+ | ----------------------- | ----------------------------- | ------- | --------------------------------------------------- |
69
+ | `swipeDirection` | `down`, `up`, `left`, `right` | `down` | ทิศที่ปัดเพื่อปิด และขอบที่แผงเลื่อนออกมา (`down` = จากด้านล่าง) |
70
+ | `showSwipeHandle` | `boolean` | `false` | แถบจับสำหรับปัด |
71
+ | `open` / `onOpenChange` | `boolean` / ฟังก์ชัน | – | ควบคุมการเปิด/ปิด |
72
+ | `modal` | `boolean` | `true` | มีฉากหลังมืด และหน้าด้านหลังกดไม่ได้ |
73
+ | `snapPoints` | รายการความสูง | – | จุดหยุดระหว่างปัด TODO: ยังไม่มีตัวอย่าง |
74
+
75
+ ### ขนาด
76
+
77
+ - จากด้านล่าง/บน: กว้างเต็มจอ สูงตามเนื้อหา สูงสุดเท่าจอลบ 96px
78
+ - จากด้านข้าง: กว้าง 75% บนมือถือ และ 384px บนจอ 640px ขึ้นไป
79
+ - ห่างขอบจอ 8px มุมโค้ง 26px
80
+
81
+ ### ส่วนอื่น ๆ
82
+
83
+ `DrawerHeader` (หัวข้อกึ่งกลางบนมือถือ ชิดซ้ายบนจอ 768px ขึ้นไป), `DrawerFooter` (ปุ่มเรียงลงมา), `DrawerClose` (ปิด ใช้ `render={<Button … />}`)
84
+
85
+ ## Tokens used
86
+
87
+ ค่าทั้งหมดมาจาก `src/styles/theme.css`
88
+
89
+ | Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
90
+ | ---------------------- | -------------------------------- | -------------------------- | ------------------------------- |
91
+ | `--popover` | `oklch(1 0 0)` | `oklch(0.228 0.013 107.4)` | พื้นแผง |
92
+ | `--popover-foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ตัวอักษร |
93
+ | `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | คำอธิบาย |
94
+ | `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | แถบจับ |
95
+ | `--border` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 10%)` | เส้นขอบ (โหมดมืด) |
96
+ | `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 2.6` = 26px) |
97
+ | `--font-heading` | กำหนดโดยแอป (IBM Plex Sans Thai) | – | หัวข้อ |
98
+
99
+ ฉากหลังสีดำ 30% และเบลอ จางลงตามระยะที่ปัด
100
+
101
+ ## Example
102
+
103
+ จาก story `Playground` ใน `Drawer.stories.tsx`:
104
+
105
+ ```tsx
106
+ <Drawer swipeDirection="down" showSwipeHandle>
107
+ <DrawerTrigger render={<Button variant="outline" />}>
108
+ เพิ่มเงินสมทบ
109
+ </DrawerTrigger>
110
+ <DrawerContent>
111
+ <DrawerHeader>
112
+ <DrawerTitle>เพิ่มเงินสมทบ</DrawerTitle>
113
+ <DrawerDescription>เงินจะเข้าบัญชีภายใน 3 วันทำการ</DrawerDescription>
114
+ </DrawerHeader>
115
+ <div className="grid gap-2 p-4">
116
+ <Label htmlFor="drawer-amount">จำนวนเงิน (AUD)</Label>
117
+ <Input id="drawer-amount" type="number" placeholder="0.00" />
118
+ </div>
119
+ <DrawerFooter>
120
+ <Button>ยืนยัน</Button>
121
+ <DrawerClose render={<Button variant="outline" />}>ยกเลิก</DrawerClose>
122
+ </DrawerFooter>
123
+ </DrawerContent>
124
+ </Drawer>
125
+ ```