@designil/labdsnov 0.0.0-stage → 1.1.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.
- package/LICENSE +21 -0
- package/README.md +150 -2
- package/dist/components/Accordion/Accordion.d.ts +8 -0
- package/dist/components/Accordion/Accordion.js +82 -0
- package/dist/components/Accordion/Accordion.module.css.js +23 -0
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +17 -0
- package/dist/components/Alert/Alert.js +58 -0
- package/dist/components/Alert/Alert.module.css.js +17 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/dist/components/AlertDialog/AlertDialog.js +150 -0
- package/dist/components/AlertDialog/AlertDialog.module.css.js +23 -0
- package/dist/components/AlertDialog/index.d.ts +1 -0
- package/dist/components/Avatar/Avatar.d.ts +23 -0
- package/dist/components/Avatar/Avatar.js +84 -0
- package/dist/components/Avatar/Avatar.module.css.js +23 -0
- package/dist/components/Avatar/index.d.ts +1 -0
- package/dist/components/Badge/Badge.d.ts +17 -0
- package/dist/components/Badge/Badge.js +37 -0
- package/dist/components/Badge/Badge.module.css.js +19 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +15 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +111 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.css.js +19 -0
- package/dist/components/Breadcrumb/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +39 -0
- package/dist/components/Button/Button.js +62 -0
- package/dist/components/Button/Button.module.css.js +37 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ButtonGroup/ButtonGroup.d.ts +21 -0
- package/dist/components/ButtonGroup/ButtonGroup.js +59 -0
- package/dist/components/ButtonGroup/ButtonGroup.module.css.js +15 -0
- package/dist/components/ButtonGroup/index.d.ts +1 -0
- package/dist/components/Calendar/Calendar.d.ts +17 -0
- package/dist/components/Calendar/Calendar.js +154 -0
- package/dist/components/Calendar/Calendar.module.css.js +67 -0
- package/dist/components/Calendar/index.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +20 -0
- package/dist/components/Card/Card.js +87 -0
- package/dist/components/Card/Card.module.css.js +23 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Chart/Chart.d.ts +59 -0
- package/dist/components/Chart/Chart.js +199 -0
- package/dist/components/Chart/Chart.module.css.js +47 -0
- package/dist/components/Chart/index.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.js +44 -0
- package/dist/components/Checkbox/Checkbox.module.css.js +13 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Collapsible/Collapsible.d.ts +8 -0
- package/dist/components/Collapsible/Collapsible.js +28 -0
- package/dist/components/Collapsible/Collapsible.module.css.js +7 -0
- package/dist/components/Collapsible/index.d.ts +1 -0
- package/dist/components/Combobox/Combobox.d.ts +36 -0
- package/dist/components/Combobox/Combobox.js +296 -0
- package/dist/components/Combobox/Combobox.module.css.js +39 -0
- package/dist/components/Combobox/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +28 -0
- package/dist/components/DatePicker/DatePicker.js +73 -0
- package/dist/components/DatePicker/DatePicker.module.css.js +9 -0
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +27 -0
- package/dist/components/Dialog/Dialog.js +144 -0
- package/dist/components/Dialog/Dialog.module.css.js +29 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/Drawer/Drawer.d.ts +22 -0
- package/dist/components/Drawer/Drawer.js +166 -0
- package/dist/components/Drawer/Drawer.module.css.js +23 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +32 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +245 -0
- package/dist/components/DropdownMenu/DropdownMenu.module.css.js +33 -0
- package/dist/components/DropdownMenu/index.d.ts +1 -0
- package/dist/components/Empty/Empty.d.ts +18 -0
- package/dist/components/Empty/Empty.js +76 -0
- package/dist/components/Empty/Empty.module.css.js +21 -0
- package/dist/components/Empty/index.d.ts +1 -0
- package/dist/components/Field/Field.d.ts +53 -0
- package/dist/components/Field/Field.js +172 -0
- package/dist/components/Field/Field.module.css.js +41 -0
- package/dist/components/Field/index.d.ts +1 -0
- package/dist/components/FundCard/FundCard.d.ts +18 -0
- package/dist/components/FundCard/FundCard.js +66 -0
- package/dist/components/FundCard/FundCard.module.css.js +25 -0
- package/dist/components/FundCard/index.d.ts +1 -0
- package/dist/components/HoverCard/HoverCard.d.ts +8 -0
- package/dist/components/HoverCard/HoverCard.js +42 -0
- package/dist/components/HoverCard/HoverCard.module.css.js +9 -0
- package/dist/components/HoverCard/index.d.ts +1 -0
- package/dist/components/Input/Input.d.ts +12 -0
- package/dist/components/Input/Input.js +23 -0
- package/dist/components/Input/Input.module.css.js +11 -0
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/InputGroup/InputGroup.d.ts +39 -0
- package/dist/components/InputGroup/InputGroup.js +103 -0
- package/dist/components/InputGroup/InputGroup.module.css.js +31 -0
- package/dist/components/InputGroup/index.d.ts +1 -0
- package/dist/components/InputOTP/InputOTP.d.ts +18 -0
- package/dist/components/InputOTP/InputOTP.js +72 -0
- package/dist/components/InputOTP/InputOTP.module.css.js +19 -0
- package/dist/components/InputOTP/index.d.ts +1 -0
- package/dist/components/Kbd/Kbd.d.ts +5 -0
- package/dist/components/Kbd/Kbd.js +20 -0
- package/dist/components/Kbd/Kbd.module.css.js +9 -0
- package/dist/components/Kbd/index.d.ts +1 -0
- package/dist/components/Label/Label.d.ts +7 -0
- package/dist/components/Label/Label.js +17 -0
- package/dist/components/Label/Label.module.css.js +9 -0
- package/dist/components/Label/index.d.ts +1 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.ts +20 -0
- package/dist/components/NavigationMenu/NavigationMenu.js +153 -0
- package/dist/components/NavigationMenu/NavigationMenu.module.css.js +29 -0
- package/dist/components/NavigationMenu/index.d.ts +1 -0
- package/dist/components/Pagination/Pagination.d.ts +29 -0
- package/dist/components/Pagination/Pagination.js +133 -0
- package/dist/components/Pagination/Pagination.module.css.js +19 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +10 -0
- package/dist/components/Popover/Popover.js +78 -0
- package/dist/components/Popover/Popover.module.css.js +15 -0
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Progress/Progress.d.ts +12 -0
- package/dist/components/Progress/Progress.js +74 -0
- package/dist/components/Progress/Progress.module.css.js +15 -0
- package/dist/components/Progress/index.d.ts +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +6 -0
- package/dist/components/RadioGroup/RadioGroup.js +37 -0
- package/dist/components/RadioGroup/RadioGroup.module.css.js +13 -0
- package/dist/components/RadioGroup/index.d.ts +1 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +9 -0
- package/dist/components/ScrollArea/ScrollArea.js +60 -0
- package/dist/components/ScrollArea/ScrollArea.module.css.js +17 -0
- package/dist/components/ScrollArea/index.d.ts +1 -0
- package/dist/components/Select/Select.d.ts +23 -0
- package/dist/components/Select/Select.js +188 -0
- package/dist/components/Select/Select.module.css.js +37 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Separator/Separator.d.ts +4 -0
- package/dist/components/Separator/Separator.js +22 -0
- package/dist/components/Separator/Separator.module.css.js +7 -0
- package/dist/components/Separator/index.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +4 -0
- package/dist/components/Skeleton/Skeleton.js +16 -0
- package/dist/components/Skeleton/Skeleton.module.css.js +7 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Slider/Slider.d.ts +13 -0
- package/dist/components/Slider/Slider.js +61 -0
- package/dist/components/Slider/Slider.module.css.js +15 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +6 -0
- package/dist/components/Spinner/Spinner.js +22 -0
- package/dist/components/Spinner/Spinner.module.css.js +7 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/Switch/Switch.d.ts +13 -0
- package/dist/components/Switch/Switch.js +29 -0
- package/dist/components/Switch/Switch.module.css.js +13 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +12 -0
- package/dist/components/Table/Table.js +96 -0
- package/dist/components/Table/Table.module.css.js +23 -0
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Tabs/Tabs.d.ts +16 -0
- package/dist/components/Tabs/Tabs.js +55 -0
- package/dist/components/Tabs/Tabs.module.css.js +17 -0
- package/dist/components/Tabs/index.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +4 -0
- package/dist/components/Textarea/Textarea.js +16 -0
- package/dist/components/Textarea/Textarea.module.css.js +7 -0
- package/dist/components/Textarea/index.d.ts +1 -0
- package/dist/components/Toaster/Toaster.d.ts +8 -0
- package/dist/components/Toaster/Toaster.js +85 -0
- package/dist/components/Toaster/Toaster.module.css.js +11 -0
- package/dist/components/Toaster/index.d.ts +1 -0
- package/dist/components/Toggle/Toggle.d.ts +26 -0
- package/dist/components/Toggle/Toggle.js +35 -0
- package/dist/components/Toggle/Toggle.module.css.js +17 -0
- package/dist/components/Toggle/index.d.ts +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +20 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +64 -0
- package/dist/components/ToggleGroup/ToggleGroup.module.css.js +11 -0
- package/dist/components/ToggleGroup/index.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +8 -0
- package/dist/components/Tooltip/Tooltip.js +61 -0
- package/dist/components/Tooltip/Tooltip.module.css.js +11 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +265 -0
- package/dist/styles.css +1 -0
- package/docs/Accessibility.md +129 -0
- package/docs/Colors.md +149 -0
- package/docs/ComponentTokens.md +191 -0
- package/docs/Contributing.md +104 -0
- package/docs/GettingStarted.md +106 -0
- package/docs/Radius.md +25 -0
- package/docs/Typography.md +38 -0
- package/package.json +88 -4
- package/src/components/Accordion/Accordion.dsds.yaml +195 -0
- package/src/components/Accordion/Accordion.md +102 -0
- package/src/components/Alert/Alert.dsds.yaml +206 -0
- package/src/components/Alert/Alert.md +90 -0
- package/src/components/AlertDialog/AlertDialog.dsds.yaml +243 -0
- package/src/components/AlertDialog/AlertDialog.md +131 -0
- package/src/components/Avatar/Avatar.dsds.yaml +172 -0
- package/src/components/Avatar/Avatar.md +77 -0
- package/src/components/Badge/Badge.dsds.yaml +191 -0
- package/src/components/Badge/Badge.md +124 -0
- package/src/components/Breadcrumb/Breadcrumb.dsds.yaml +162 -0
- package/src/components/Breadcrumb/Breadcrumb.md +110 -0
- package/src/components/Button/Button.dsds.yaml +350 -0
- package/src/components/Button/Button.md +165 -0
- package/src/components/ButtonGroup/ButtonGroup.dsds.yaml +193 -0
- package/src/components/ButtonGroup/ButtonGroup.md +96 -0
- package/src/components/Calendar/Calendar.dsds.yaml +236 -0
- package/src/components/Calendar/Calendar.md +111 -0
- package/src/components/Card/Card.dsds.yaml +199 -0
- package/src/components/Card/Card.md +99 -0
- package/src/components/Chart/Chart.dsds.yaml +216 -0
- package/src/components/Chart/Chart.md +112 -0
- package/src/components/Checkbox/Checkbox.dsds.yaml +215 -0
- package/src/components/Checkbox/Checkbox.md +105 -0
- package/src/components/Collapsible/Collapsible.dsds.yaml +146 -0
- package/src/components/Collapsible/Collapsible.md +86 -0
- package/src/components/Combobox/Combobox.dsds.yaml +241 -0
- package/src/components/Combobox/Combobox.md +143 -0
- package/src/components/DatePicker/DatePicker.dsds.yaml +179 -0
- package/src/components/DatePicker/DatePicker.md +82 -0
- package/src/components/Dialog/Dialog.dsds.yaml +300 -0
- package/src/components/Dialog/Dialog.md +193 -0
- package/src/components/Drawer/Drawer.dsds.yaml +207 -0
- package/src/components/Drawer/Drawer.md +125 -0
- package/src/components/DropdownMenu/DropdownMenu.dsds.yaml +265 -0
- package/src/components/DropdownMenu/DropdownMenu.md +151 -0
- package/src/components/Empty/Empty.dsds.yaml +171 -0
- package/src/components/Empty/Empty.md +90 -0
- package/src/components/Field/Field.dsds.yaml +285 -0
- package/src/components/Field/Field.md +139 -0
- package/src/components/FundCard/FundCard.dsds.yaml +195 -0
- package/src/components/FundCard/FundCard.md +93 -0
- package/src/components/HoverCard/HoverCard.dsds.yaml +157 -0
- package/src/components/HoverCard/HoverCard.md +100 -0
- package/src/components/Input/Input.dsds.yaml +235 -0
- package/src/components/Input/Input.md +115 -0
- package/src/components/InputGroup/InputGroup.dsds.yaml +234 -0
- package/src/components/InputGroup/InputGroup.md +115 -0
- package/src/components/InputOTP/InputOTP.dsds.yaml +184 -0
- package/src/components/InputOTP/InputOTP.md +105 -0
- package/src/components/Kbd/Kbd.dsds.yaml +119 -0
- package/src/components/Kbd/Kbd.md +85 -0
- package/src/components/Label/Label.dsds.yaml +141 -0
- package/src/components/Label/Label.md +75 -0
- package/src/components/NavigationMenu/NavigationMenu.dsds.yaml +196 -0
- package/src/components/NavigationMenu/NavigationMenu.md +128 -0
- package/src/components/Pagination/Pagination.dsds.yaml +172 -0
- package/src/components/Pagination/Pagination.md +115 -0
- package/src/components/Popover/Popover.dsds.yaml +168 -0
- package/src/components/Popover/Popover.md +111 -0
- package/src/components/Progress/Progress.dsds.yaml +169 -0
- package/src/components/Progress/Progress.md +83 -0
- package/src/components/RadioGroup/RadioGroup.dsds.yaml +215 -0
- package/src/components/RadioGroup/RadioGroup.md +123 -0
- package/src/components/ScrollArea/ScrollArea.dsds.yaml +153 -0
- package/src/components/ScrollArea/ScrollArea.md +88 -0
- package/src/components/Select/Select.dsds.yaml +239 -0
- package/src/components/Select/Select.md +170 -0
- package/src/components/Separator/Separator.dsds.yaml +121 -0
- package/src/components/Separator/Separator.md +68 -0
- package/src/components/Skeleton/Skeleton.dsds.yaml +124 -0
- package/src/components/Skeleton/Skeleton.md +68 -0
- package/src/components/Slider/Slider.dsds.yaml +194 -0
- package/src/components/Slider/Slider.md +107 -0
- package/src/components/Spinner/Spinner.dsds.yaml +126 -0
- package/src/components/Spinner/Spinner.md +64 -0
- package/src/components/Switch/Switch.dsds.yaml +198 -0
- package/src/components/Switch/Switch.md +101 -0
- package/src/components/Table/Table.dsds.yaml +195 -0
- package/src/components/Table/Table.md +117 -0
- package/src/components/Tabs/Tabs.dsds.yaml +239 -0
- package/src/components/Tabs/Tabs.md +173 -0
- package/src/components/Textarea/Textarea.dsds.yaml +167 -0
- package/src/components/Textarea/Textarea.md +89 -0
- package/src/components/Toaster/Toaster.dsds.yaml +226 -0
- package/src/components/Toaster/Toaster.md +107 -0
- package/src/components/Toggle/Toggle.dsds.yaml +224 -0
- package/src/components/Toggle/Toggle.md +103 -0
- package/src/components/ToggleGroup/ToggleGroup.dsds.yaml +230 -0
- package/src/components/ToggleGroup/ToggleGroup.md +95 -0
- package/src/components/Tooltip/Tooltip.dsds.yaml +202 -0
- package/src/components/Tooltip/Tooltip.md +104 -0
- package/src/index.dsds.yaml +467 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: tabs
|
|
3
|
+
name: Tabs
|
|
4
|
+
description: >-
|
|
5
|
+
Switches between several parts of the same subject in one area, showing one at a
|
|
6
|
+
time. Horizontal tab list 36px tall, 14px medium text. Wraps Base UI `Tabs`.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [navigation, disclosure]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use to split one subject into parts of equal level that the user reads one at a
|
|
20
|
+
time, e.g. a member account: ภาพรวม / ธุรกรรม / เอกสาร (overview / transactions
|
|
21
|
+
/ documents).
|
|
22
|
+
- level: must-not
|
|
23
|
+
statement: >-
|
|
24
|
+
Never use for steps done in order (multi-step forms). There is no stepper
|
|
25
|
+
component yet.
|
|
26
|
+
checkedBy: manual
|
|
27
|
+
- level: must-not
|
|
28
|
+
statement: >-
|
|
29
|
+
Never use to go to other pages where each tab has its own URL. Use links or
|
|
30
|
+
<dsds:navigation-menu>.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: navigation-menu
|
|
33
|
+
checkedBy: manual
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: >-
|
|
36
|
+
Never use to pick a form value (e.g. an investment plan). Use
|
|
37
|
+
<dsds:radio-group> or <dsds:select>.
|
|
38
|
+
alternatives:
|
|
39
|
+
- to: radio-group
|
|
40
|
+
- to: select
|
|
41
|
+
checkedBy: manual
|
|
42
|
+
- level: should-not
|
|
43
|
+
statement: >-
|
|
44
|
+
Don't use when the user must compare two parts side by side. Show all parts on
|
|
45
|
+
the page.
|
|
46
|
+
- level: should-not
|
|
47
|
+
statement: >-
|
|
48
|
+
Don't use to switch a small display option of one data set (monthly/yearly).
|
|
49
|
+
Use <dsds:toggle-group>.
|
|
50
|
+
alternatives:
|
|
51
|
+
- to: toggle-group
|
|
52
|
+
|
|
53
|
+
- kind: guidelines
|
|
54
|
+
for: all
|
|
55
|
+
items:
|
|
56
|
+
- id: default-value-required
|
|
57
|
+
level: must
|
|
58
|
+
statement: >-
|
|
59
|
+
Always set `defaultValue` (or `value`). The default is `0`, which doesn't match
|
|
60
|
+
string `value`s, so no tab would be open.
|
|
61
|
+
checks:
|
|
62
|
+
- href: ./Tabs.stories.tsx#Playground
|
|
63
|
+
role: test
|
|
64
|
+
note: play function checks the "ภาพรวม" tab is selected and the tabpanel has content
|
|
65
|
+
checkedBy: automated
|
|
66
|
+
- id: values-match
|
|
67
|
+
level: must
|
|
68
|
+
statement: >-
|
|
69
|
+
Each `TabsTrigger` `value` matches the `value` of its `TabsContent`. Every tab
|
|
70
|
+
has its own content.
|
|
71
|
+
checkedBy: manual
|
|
72
|
+
- id: short-labels
|
|
73
|
+
level: must
|
|
74
|
+
statement: >-
|
|
75
|
+
Tab names are 1–2 words and don't wrap. The tab list doesn't scroll or wrap, so
|
|
76
|
+
cut the number of tabs when they don't fit.
|
|
77
|
+
checkedBy: manual
|
|
78
|
+
- id: keep-mounted-forms
|
|
79
|
+
level: should
|
|
80
|
+
statement: >-
|
|
81
|
+
Tabs containing forms need `keepMounted` on `TabsContent`, or entered values are
|
|
82
|
+
lost when switching (unselected tab content is unmounted).
|
|
83
|
+
checkedBy: manual
|
|
84
|
+
- id: url-state
|
|
85
|
+
level: should
|
|
86
|
+
statement: >-
|
|
87
|
+
Tabs the user may share or go back to (e.g. transactions) keep their value in the
|
|
88
|
+
URL via `value` / `onValueChange` in a Client Component.
|
|
89
|
+
checkedBy: manual
|
|
90
|
+
- id: icons-consistent
|
|
91
|
+
level: may
|
|
92
|
+
statement: >-
|
|
93
|
+
Icons are allowed (`data-icon="inline-start"`), but on every tab or none.
|
|
94
|
+
example:
|
|
95
|
+
ref:
|
|
96
|
+
href: ./Tabs.stories.tsx#WithIcons
|
|
97
|
+
rel: demo
|
|
98
|
+
|
|
99
|
+
- kind: guidelines
|
|
100
|
+
for: all
|
|
101
|
+
title: Accessibility
|
|
102
|
+
tags: [accessibility]
|
|
103
|
+
items:
|
|
104
|
+
- id: list-label
|
|
105
|
+
level: must
|
|
106
|
+
statement: >-
|
|
107
|
+
`TabsList` has an `aria-label` (e.g. "ข้อมูลบัญชี" (account information)) when
|
|
108
|
+
no heading says what the tabs are.
|
|
109
|
+
checkedBy: manual
|
|
110
|
+
- id: manual-activation
|
|
111
|
+
level: must
|
|
112
|
+
statement: >-
|
|
113
|
+
Arrows move focus and Enter/Space selects (`activateOnFocus` defaults to
|
|
114
|
+
`false`). Set `activateOnFocus` only when tab content loads fast and has no form.
|
|
115
|
+
evidence:
|
|
116
|
+
- href: https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
|
|
117
|
+
role: WAI-ARIA APG Tabs pattern
|
|
118
|
+
checks:
|
|
119
|
+
- href: ./Tabs.stories.tsx#KeyboardNavigation
|
|
120
|
+
role: test
|
|
121
|
+
checkedBy: automated
|
|
122
|
+
- id: disabled-tab
|
|
123
|
+
level: must
|
|
124
|
+
statement: >-
|
|
125
|
+
A `disabled` tab has `aria-disabled="true"` and can't be selected by keyboard.
|
|
126
|
+
checks:
|
|
127
|
+
- href: ./Tabs.stories.tsx#DisabledTab
|
|
128
|
+
role: test
|
|
129
|
+
checkedBy: automated
|
|
130
|
+
- id: tabs-contrast
|
|
131
|
+
level: must
|
|
132
|
+
statement: >-
|
|
133
|
+
Unselected tabs 5.41:1 / 6.14:1 (`default`) and 5.97:1 / 8.43:1 (`line`); the
|
|
134
|
+
`line` underline 19.59:1 / 18.93:1 (light / dark).
|
|
135
|
+
checks:
|
|
136
|
+
- href: ../../../scripts/tokens.mjs
|
|
137
|
+
role: test
|
|
138
|
+
note: CONTRAST_PAIRS "แท็บ…" and "เส้นใต้แท็บ line"
|
|
139
|
+
checkedBy: automated
|
|
140
|
+
|
|
141
|
+
- kind: definitions
|
|
142
|
+
for: all
|
|
143
|
+
context: anatomy
|
|
144
|
+
items:
|
|
145
|
+
- term: Tabs
|
|
146
|
+
definition: >-
|
|
147
|
+
Root. Takes `defaultValue`, `value` / `onValueChange`, `orientation`.
|
|
148
|
+
- term: TabsList
|
|
149
|
+
definition: >-
|
|
150
|
+
The tab list. Takes `variant`, `aria-label`, `activateOnFocus`, `loopFocus`
|
|
151
|
+
(default `true`).
|
|
152
|
+
- term: TabsTrigger
|
|
153
|
+
definition: >-
|
|
154
|
+
A tab button. Takes `value` (required), `disabled`.
|
|
155
|
+
- term: TabsContent
|
|
156
|
+
definition: >-
|
|
157
|
+
Tab content. Takes `value` (required), `keepMounted`.
|
|
158
|
+
|
|
159
|
+
- kind: definitions
|
|
160
|
+
for: all
|
|
161
|
+
context: keyboard
|
|
162
|
+
items:
|
|
163
|
+
- term: Tab
|
|
164
|
+
definition: >-
|
|
165
|
+
Focuses the selected tab, then moves into the content.
|
|
166
|
+
- term: Left / Right arrows (vertical - Up / Down)
|
|
167
|
+
definition: >-
|
|
168
|
+
Move focus between tabs, looping when `loopFocus`.
|
|
169
|
+
- term: Home / End
|
|
170
|
+
definition: >-
|
|
171
|
+
First / last tab.
|
|
172
|
+
- term: Enter / Space
|
|
173
|
+
definition: >-
|
|
174
|
+
Select the focused tab.
|
|
175
|
+
|
|
176
|
+
- kind: section
|
|
177
|
+
for: all
|
|
178
|
+
title: Open decisions
|
|
179
|
+
freeform:
|
|
180
|
+
- title: TODO
|
|
181
|
+
body: >-
|
|
182
|
+
No criteria yet for choosing `default` vs `line`, no maximum number of tabs on
|
|
183
|
+
mobile, no plan for overflowing tabs, and tab content takes focus but shows no
|
|
184
|
+
focus indicator (WCAG 2.4.7).
|
|
185
|
+
|
|
186
|
+
sourceFiles:
|
|
187
|
+
- platform: react
|
|
188
|
+
file: ./Tabs.tsx
|
|
189
|
+
|
|
190
|
+
imports:
|
|
191
|
+
- platform: react
|
|
192
|
+
code: >-
|
|
193
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@designil/labdsnov"
|
|
194
|
+
package: "@designil/labdsnov"
|
|
195
|
+
|
|
196
|
+
traits:
|
|
197
|
+
- traitType: variant
|
|
198
|
+
kind: enum
|
|
199
|
+
id: listVariant
|
|
200
|
+
name: TabsList variant
|
|
201
|
+
description: >-
|
|
202
|
+
The `variant` prop of `TabsList`.
|
|
203
|
+
values:
|
|
204
|
+
- id: default
|
|
205
|
+
description: >-
|
|
206
|
+
Tabs sit in a grey pill; the selected tab is a raised background-colour pill.
|
|
207
|
+
- id: line
|
|
208
|
+
description: >-
|
|
209
|
+
No background; the selected tab is underlined (vertical: a line on the right).
|
|
210
|
+
- traitType: variant
|
|
211
|
+
kind: enum
|
|
212
|
+
id: orientation
|
|
213
|
+
description: >-
|
|
214
|
+
Direction of the tab list.
|
|
215
|
+
values:
|
|
216
|
+
- id: horizontal
|
|
217
|
+
description: >-
|
|
218
|
+
List on top (default).
|
|
219
|
+
- id: vertical
|
|
220
|
+
description: >-
|
|
221
|
+
Tabs stacked vertically to the left of the content.
|
|
222
|
+
- traitType: state
|
|
223
|
+
kind: boolean
|
|
224
|
+
id: disabled
|
|
225
|
+
description: >-
|
|
226
|
+
A tab that can't be selected, 50% opacity.
|
|
227
|
+
|
|
228
|
+
alternatives:
|
|
229
|
+
- to: navigation-menu
|
|
230
|
+
- to: toggle-group
|
|
231
|
+
- to: accordion
|
|
232
|
+
|
|
233
|
+
refs:
|
|
234
|
+
- href: ./Tabs.md
|
|
235
|
+
rel: relates-to
|
|
236
|
+
role: Thai usage doc
|
|
237
|
+
- href: ./Tabs.stories.tsx
|
|
238
|
+
rel: demo
|
|
239
|
+
role: CSF stories
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Tabs (แท็บ)
|
|
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 { Tabs, TabsContent, TabsList, TabsTrigger } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<Tabs defaultValue="overview">
|
|
19
|
+
<TabsList aria-label="ข้อมูลบัญชี">
|
|
20
|
+
<TabsTrigger value="overview">ภาพรวม</TabsTrigger>
|
|
21
|
+
<TabsTrigger value="transactions">ธุรกรรม</TabsTrigger>
|
|
22
|
+
</TabsList>
|
|
23
|
+
<TabsContent value="overview">…</TabsContent>
|
|
24
|
+
<TabsContent value="transactions">…</TabsContent>
|
|
25
|
+
</Tabs>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- `value` ของ `TabsTrigger` ต้องตรงกับ `value` ของ `TabsContent` ที่คู่กัน
|
|
29
|
+
- **ใส่ `defaultValue` (หรือ `value`) เสมอ** เป็นค่าของแท็บที่เปิดได้ ค่าเริ่มต้นคือ `0` ซึ่งไม่ตรงกับ `value` ที่เป็นข้อความ
|
|
30
|
+
- ควบคุมแท็บที่เลือกเอง (เช่น เก็บไว้ใน URL) ใช้ `value` กับ `onValueChange` ในไฟล์ที่มี `"use client"`
|
|
31
|
+
|
|
32
|
+
ถ้าใช้ไอคอน ให้ติดตั้ง `@hugeicons/react` และ `@hugeicons/core-free-icons` ในแอปด้วย
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
|
|
36
|
+
- แบ่งข้อมูลของเรื่องเดียวกันเป็นส่วน ๆ ที่ระดับเท่ากัน เช่น บัญชีสมาชิก: ภาพรวม / ธุรกรรม / เอกสาร
|
|
37
|
+
- ผู้ใช้ดูทีละส่วนก็พอ ไม่ต้องเปรียบเทียบสองส่วนพร้อมกัน
|
|
38
|
+
- ชื่อแท็บสั้น 1–2 คำ ชื่อแท็บไม่ขึ้นบรรทัดใหม่
|
|
39
|
+
|
|
40
|
+
## When not to use
|
|
41
|
+
|
|
42
|
+
| สถานการณ์ | ใช้แทน |
|
|
43
|
+
| ---------------------------------- | ----------------------------------------------------------------------- |
|
|
44
|
+
| ขั้นตอนที่ต้องทำตามลำดับ (ฟอร์มหลายขั้นตอน) | TODO: ยังไม่มีคอมโพเนนต์ stepper |
|
|
45
|
+
| ไปหน้าอื่น (แต่ละแท็บมี URL ของตัวเอง) | ลิงก์ หรือ `NavigationMenu` |
|
|
46
|
+
| เปรียบเทียบเนื้อหาสองส่วนพร้อมกัน | แสดงทุกส่วนในหน้าเดียว |
|
|
47
|
+
| เลือกค่าในฟอร์ม เช่น เลือกแผนการลงทุน | `RadioGroup` หรือ `Select` |
|
|
48
|
+
| แท็บมากจนไม่พอความกว้าง | ลดจำนวนแท็บ แถบแท็บไม่เลื่อนและไม่ขึ้นบรรทัดใหม่ TODO: ยังไม่ได้กำหนดจำนวนสูงสุดบนมือถือ |
|
|
49
|
+
|
|
50
|
+
## Anatomy
|
|
51
|
+
|
|
52
|
+
- **Tabs**: ตัวครอบ เก็บว่าแท็บไหนถูกเลือก
|
|
53
|
+
- **TabsList**: แถบรวมปุ่มแท็บ
|
|
54
|
+
- **TabsTrigger**: ปุ่มแท็บแต่ละอัน
|
|
55
|
+
- **TabsContent**: เนื้อหาของแต่ละแท็บ แสดงเฉพาะแท็บที่ถูกเลือก
|
|
56
|
+
|
|
57
|
+
## Props and variants
|
|
58
|
+
|
|
59
|
+
### Tabs
|
|
60
|
+
|
|
61
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
62
|
+
| ------------------------- | ------------------------ | ------------ | ---------------------------------------------- |
|
|
63
|
+
| `defaultValue` | value ของแท็บ | `0` | แท็บที่เลือกไว้ตอนแรก |
|
|
64
|
+
| `value` / `onValueChange` | value ของแท็บ / ฟังก์ชัน | – | ควบคุมแท็บที่เลือกจากภายนอก |
|
|
65
|
+
| `orientation` | `horizontal`, `vertical` | `horizontal` | `vertical` = แท็บเรียงแนวตั้งด้านซ้ายของเนื้อหา |
|
|
66
|
+
| `className` | class | – | ปรับหน้าตาเฉพาะจุดครั้งเดียว ชนะสไตล์ของคอมโพเนนต์เสมอ |
|
|
67
|
+
|
|
68
|
+
### TabsList
|
|
69
|
+
|
|
70
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
71
|
+
| ----------------- | ----------------- | --------- | -------------------------------------------------------------- |
|
|
72
|
+
| `variant` | `default`, `line` | `default` | หน้าตาของแถบแท็บ (ดูตารางด้านล่าง) |
|
|
73
|
+
| `aria-label` | ข้อความ | – | ชื่อของแถบแท็บสำหรับโปรแกรมอ่านหน้าจอ ใส่เมื่อไม่มีหัวข้อที่บอกว่าแท็บชุดนี้คืออะไร |
|
|
74
|
+
| `activateOnFocus` | `boolean` | `false` | `true` = เลือกแท็บทันทีเมื่อเลื่อนด้วยลูกศร (ปกติต้องกด Enter หรือ Space) |
|
|
75
|
+
| `loopFocus` | `boolean` | `true` | กดลูกศรเลยแท็บสุดท้ายแล้ววนกลับไปแท็บแรก |
|
|
76
|
+
|
|
77
|
+
| Variant | หน้าตา | ใช้เมื่อ |
|
|
78
|
+
| --------- | ---------------------------------------------- | ---------------------------- |
|
|
79
|
+
| `default` | แท็บอยู่ในแคปซูลพื้นเทา แท็บที่เลือกเป็นแคปซูลสีพื้นหลังยกขึ้นมา | TODO: ยังไม่ได้กำหนดเกณฑ์การเลือก |
|
|
80
|
+
| `line` | ไม่มีพื้น แท็บที่เลือกมีเส้นใต้ (แนวตั้ง: เส้นด้านขวา) | TODO: ยังไม่ได้กำหนดเกณฑ์การเลือก |
|
|
81
|
+
|
|
82
|
+
แถบแท็บแนวนอนสูง 36px กว้างเท่าที่แท็บต้องการ ตัวอักษร 14px น้ำหนัก medium ไอคอน 16px
|
|
83
|
+
|
|
84
|
+
### TabsTrigger
|
|
85
|
+
|
|
86
|
+
| Prop | ค่า | ความหมาย |
|
|
87
|
+
| ---------- | --------- | --------------------------------- |
|
|
88
|
+
| `value` | ข้อความ | **บังคับ** ค่าที่ใช้จับคู่กับ `TabsContent` |
|
|
89
|
+
| `disabled` | `boolean` | ปิดใช้งาน จางลง 50% เลือกไม่ได้ |
|
|
90
|
+
|
|
91
|
+
วางไอคอนหน้าหรือหลังชื่อแท็บได้ตาม story `WithIcons`
|
|
92
|
+
|
|
93
|
+
### TabsContent
|
|
94
|
+
|
|
95
|
+
| Prop | ค่า | ค่าเริ่มต้น | ความหมาย |
|
|
96
|
+
| ------------- | --------- | ------- | ---------------------------------------------------------------------- |
|
|
97
|
+
| `value` | ข้อความ | – | **บังคับ** ตรงกับ `value` ของ `TabsTrigger` |
|
|
98
|
+
| `keepMounted` | `boolean` | `false` | เก็บเนื้อหาแท็บที่ไม่ได้เลือกไว้ในหน้า (ซ่อนไว้) แทนการเอาออก เช่น ฟอร์มที่ต้องจำค่าที่กรอก |
|
|
99
|
+
|
|
100
|
+
### พฤติกรรมที่มีให้แล้ว
|
|
101
|
+
|
|
102
|
+
- กด Tab แล้วโฟกัสไปที่แท็บที่เลือกอยู่ ลูกศรซ้าย/ขวา (แนวตั้ง: ขึ้น/ลง) เลื่อนโฟกัสระหว่างแท็บ Home/End ไปแท็บแรก/สุดท้าย และ Enter หรือ Space เลือกแท็บ
|
|
103
|
+
- เนื้อหาแท็บที่ไม่ได้เลือกถูกเอาออกจากหน้า เว้นแต่ใส่ `keepMounted`
|
|
104
|
+
- **Focus จากคีย์บอร์ด**: แท็บมีวงแหวนทึบสี `--focus-ring`
|
|
105
|
+
|
|
106
|
+
## Tokens used
|
|
107
|
+
|
|
108
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
109
|
+
|
|
110
|
+
### Component tokens
|
|
111
|
+
|
|
112
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
113
|
+
|
|
114
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
115
|
+
| -------------------------- | -------------------- | --------- | --------------------------------------------- |
|
|
116
|
+
| `--tabs-trigger-fg` | `--muted-foreground` | – | ตัวอักษรแท็บที่ไม่ได้เลือก |
|
|
117
|
+
| `--tabs-list-bg` | `--muted` | – | พื้นแคปซูล (`default`) |
|
|
118
|
+
| `--tabs-trigger-active-fg` | `--foreground` | – | ตัวอักษรแท็บที่เลือก และตอน hover |
|
|
119
|
+
| `--tabs-trigger-active-bg` | `--background` | `--input` | พื้นแท็บที่เลือก (`default`) |
|
|
120
|
+
| `--tabs-indicator` | `--foreground` | – | เส้นใต้แท็บที่เลือก (`line`) |
|
|
121
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
122
|
+
|
|
123
|
+
### Semantic tokens
|
|
124
|
+
|
|
125
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
126
|
+
| -------------------- | -------------------------- | -------------------------- | -------------------------------------------------------- |
|
|
127
|
+
| `--muted` | `oklch(0.966 0.005 106.5)` | `oklch(0.286 0.016 107.4)` | พื้นแถบแท็บ (`default`) |
|
|
128
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | ชื่อแท็บที่ไม่ได้เลือก (โหมดมืด) |
|
|
129
|
+
| `--foreground` | `oklch(0.153 0.006 107.1)` | `oklch(0.988 0.003 106.5)` | ชื่อแท็บ (60% เมื่อไม่ได้เลือก), hover, แท็บที่เลือก, เส้นใต้ `line` |
|
|
130
|
+
| `--background` | `oklch(1 0 0)` | `oklch(0.153 0.006 107.1)` | พื้นแท็บที่เลือก (`default`, โหมดสว่าง) |
|
|
131
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นแท็บที่เลือก (`default`, โหมดมืด 30%) |
|
|
132
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | วงแหวน focus |
|
|
133
|
+
| `--radius` | `0.625rem` | – | แนวตั้งใช้มุมโค้ง `--radius × 1.8` = 18px (แนวนอนเป็นทรงแคปซูล) |
|
|
134
|
+
|
|
135
|
+
## Example
|
|
136
|
+
|
|
137
|
+
จาก story `WithIcons` ใน `Tabs.stories.tsx`:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
<Tabs defaultValue="overview">
|
|
141
|
+
<TabsList>
|
|
142
|
+
<TabsTrigger value="overview">
|
|
143
|
+
<HugeiconsIcon
|
|
144
|
+
icon={PieChartIcon}
|
|
145
|
+
strokeWidth={2}
|
|
146
|
+
data-icon="inline-start"
|
|
147
|
+
/>
|
|
148
|
+
ภาพรวม
|
|
149
|
+
</TabsTrigger>
|
|
150
|
+
<TabsTrigger value="transactions">
|
|
151
|
+
<HugeiconsIcon
|
|
152
|
+
icon={Exchange01Icon}
|
|
153
|
+
strokeWidth={2}
|
|
154
|
+
data-icon="inline-start"
|
|
155
|
+
/>
|
|
156
|
+
ธุรกรรม
|
|
157
|
+
</TabsTrigger>
|
|
158
|
+
<TabsTrigger value="documents">
|
|
159
|
+
<HugeiconsIcon
|
|
160
|
+
icon={File01Icon}
|
|
161
|
+
strokeWidth={2}
|
|
162
|
+
data-icon="inline-start"
|
|
163
|
+
/>
|
|
164
|
+
เอกสาร
|
|
165
|
+
</TabsTrigger>
|
|
166
|
+
</TabsList>
|
|
167
|
+
</Tabs>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Open questions (TODO)
|
|
171
|
+
|
|
172
|
+
- **Focus ของเนื้อหาแท็บ**: เนื้อหาแท็บรับโฟกัสจากคีย์บอร์ดได้ (กด Tab ต่อจากแถบแท็บ) แต่ไม่มีเส้นแสดงโฟกัส ตามสไตล์ของ shadcn ยังไม่ได้ตัดสินใจว่าจะเพิ่มหรือไม่ (WCAG 2.4.7)
|
|
173
|
+
- **แถบแท็บบนจอแคบ**: แถบไม่เลื่อนและไม่ขึ้นบรรทัดใหม่ ยังไม่ได้ตัดสินใจว่าจะทำอย่างไรเมื่อแท็บล้น
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: textarea
|
|
3
|
+
name: Textarea
|
|
4
|
+
description: >-
|
|
5
|
+
A multi-line text field that grows with what the user types (at least 64px
|
|
6
|
+
tall). Looks like the `filled` Input.
|
|
7
|
+
metadata:
|
|
8
|
+
status: {status: stable}
|
|
9
|
+
since: 1.0.0
|
|
10
|
+
tags: [form]
|
|
11
|
+
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
items:
|
|
17
|
+
- level: should
|
|
18
|
+
statement: >-
|
|
19
|
+
Use for text that may run past one line, such as a message to staff or
|
|
20
|
+
the reason for a withdrawal.
|
|
21
|
+
- level: must-not
|
|
22
|
+
statement: >-
|
|
23
|
+
Don't use for short single-line data (name, email, numbers). Use
|
|
24
|
+
<dsds:input>.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: input
|
|
27
|
+
checkedBy: manual
|
|
28
|
+
- level: must-not
|
|
29
|
+
statement: >-
|
|
30
|
+
Don't promise formatting (bold, lists). There is no rich text editor yet.
|
|
31
|
+
checkedBy: manual
|
|
32
|
+
|
|
33
|
+
- kind: guidelines
|
|
34
|
+
for: all
|
|
35
|
+
items:
|
|
36
|
+
- id: labelled
|
|
37
|
+
level: must
|
|
38
|
+
statement: >-
|
|
39
|
+
Bind it to a <dsds:label> with `id` / `htmlFor`. The placeholder is an
|
|
40
|
+
example of what to write ("พิมพ์ข้อความถึงเจ้าหน้าที่", "type a message
|
|
41
|
+
to staff"), not the label.
|
|
42
|
+
uses:
|
|
43
|
+
- to: label
|
|
44
|
+
checkedBy: manual
|
|
45
|
+
- id: min-length-message
|
|
46
|
+
level: must
|
|
47
|
+
statement: >-
|
|
48
|
+
If there is a minimum length, say so in `FieldDescription` before the
|
|
49
|
+
user types, and make the error message give the number
|
|
50
|
+
("กรุณาระบุเหตุผลอย่างน้อย 20 ตัวอักษร", "give a reason of at least 20
|
|
51
|
+
characters").
|
|
52
|
+
uses:
|
|
53
|
+
- to: field
|
|
54
|
+
checkedBy: manual
|
|
55
|
+
- id: counter-with-group
|
|
56
|
+
level: should
|
|
57
|
+
statement: >-
|
|
58
|
+
For a character counter with `maxLength`, use `InputGroupTextarea` with
|
|
59
|
+
`InputGroupAddon align="block-end"` from <dsds:input-group>. Textarea has
|
|
60
|
+
no built-in counter.
|
|
61
|
+
alternatives:
|
|
62
|
+
- to: input-group
|
|
63
|
+
example:
|
|
64
|
+
ref:
|
|
65
|
+
href: ../InputGroup/InputGroup.stories.tsx#TextareaWithFooter
|
|
66
|
+
rel: demo
|
|
67
|
+
checkedBy: manual
|
|
68
|
+
- id: auto-grow
|
|
69
|
+
level: may
|
|
70
|
+
statement: >-
|
|
71
|
+
The field grows with its text in browsers that support it. How `rows`
|
|
72
|
+
interacts with that growth hasn't been checked.
|
|
73
|
+
|
|
74
|
+
- kind: guidelines
|
|
75
|
+
for: all
|
|
76
|
+
title: Accessibility
|
|
77
|
+
tags: [accessibility]
|
|
78
|
+
items:
|
|
79
|
+
- id: invalid-described
|
|
80
|
+
level: must
|
|
81
|
+
statement: >-
|
|
82
|
+
A wrong value sets `aria-invalid` and `aria-describedby` pointing at the
|
|
83
|
+
error message.
|
|
84
|
+
refines:
|
|
85
|
+
- to: shared-a11y#invalid-has-message
|
|
86
|
+
checks:
|
|
87
|
+
- href: ./Textarea.stories.tsx#Invalid
|
|
88
|
+
role: test
|
|
89
|
+
note: play function checks toBeInvalid and toHaveAccessibleDescription
|
|
90
|
+
checkedBy: automated
|
|
91
|
+
- id: field-contrast
|
|
92
|
+
level: must
|
|
93
|
+
statement: >-
|
|
94
|
+
It shares the field tokens with Input. The edge (`--field-border`) is
|
|
95
|
+
3.93:1 light / 4.05:1 dark on the page background, and the placeholder
|
|
96
|
+
5.40:1 / 7.17:1.
|
|
97
|
+
checks:
|
|
98
|
+
- href: ../../../scripts/tokens.mjs
|
|
99
|
+
role: test
|
|
100
|
+
note: CONTRAST_PAIRS for field edges and placeholder
|
|
101
|
+
checkedBy: automated
|
|
102
|
+
- refs:
|
|
103
|
+
- to: shared-a11y#invalid-keeps-focus
|
|
104
|
+
rel: same-as
|
|
105
|
+
|
|
106
|
+
- kind: guidelines
|
|
107
|
+
for: agent
|
|
108
|
+
items:
|
|
109
|
+
- refs:
|
|
110
|
+
- to: shared-testing#fire-change-for-typing
|
|
111
|
+
rel: same-as
|
|
112
|
+
|
|
113
|
+
- kind: section
|
|
114
|
+
for: all
|
|
115
|
+
title: Open decisions
|
|
116
|
+
freeform:
|
|
117
|
+
- title: TODO
|
|
118
|
+
body: >-
|
|
119
|
+
No rich text editor yet, no built-in character counter, and the effect
|
|
120
|
+
of `rows` alongside auto-grow hasn't been checked.
|
|
121
|
+
|
|
122
|
+
sourceFiles:
|
|
123
|
+
- platform: react
|
|
124
|
+
file: ./Textarea.tsx
|
|
125
|
+
|
|
126
|
+
imports:
|
|
127
|
+
- platform: react
|
|
128
|
+
code: >-
|
|
129
|
+
import { Textarea } from "@designil/labdsnov"
|
|
130
|
+
package: "@designil/labdsnov"
|
|
131
|
+
|
|
132
|
+
traits:
|
|
133
|
+
- traitType: state
|
|
134
|
+
kind: boolean
|
|
135
|
+
id: disabled
|
|
136
|
+
description: >-
|
|
137
|
+
Disabled, dimmed to 50%.
|
|
138
|
+
- traitType: state
|
|
139
|
+
kind: boolean
|
|
140
|
+
id: aria-invalid
|
|
141
|
+
name: Invalid
|
|
142
|
+
description: >-
|
|
143
|
+
The value is wrong. Red edge and faint red ring.
|
|
144
|
+
|
|
145
|
+
uses:
|
|
146
|
+
- to: label
|
|
147
|
+
alternatives:
|
|
148
|
+
- to: input
|
|
149
|
+
- to: input-group
|
|
150
|
+
|
|
151
|
+
refs:
|
|
152
|
+
- href: ./Textarea.md
|
|
153
|
+
rel: relates-to
|
|
154
|
+
role: usage doc (Thai)
|
|
155
|
+
- href: ./Textarea.stories.tsx
|
|
156
|
+
rel: demo
|
|
157
|
+
role: CSF stories
|
|
158
|
+
- href: https://www.figma.com/design/QsKWb3A53lIh4QBDnAkGHh/labdsnov?node-id=10-63
|
|
159
|
+
rel: design
|
|
160
|
+
role: Textarea in Figma
|
|
161
|
+
- href: ../../../figma/Textarea.figma.ts
|
|
162
|
+
rel: source
|
|
163
|
+
role: Code Connect template
|
|
164
|
+
|
|
165
|
+
$extensions:
|
|
166
|
+
com.figma:
|
|
167
|
+
nodeId: "10:63"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Textarea (ช่องกรอกข้อความหลายบรรทัด)
|
|
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 { Label, Textarea } from "@designil/labdsnov"
|
|
17
|
+
|
|
18
|
+
;<div className="grid gap-2">
|
|
19
|
+
<Label htmlFor="message">ข้อความ</Label>
|
|
20
|
+
<Textarea id="message" placeholder="พิมพ์ข้อความถึงเจ้าหน้าที่" />
|
|
21
|
+
</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## When to use
|
|
25
|
+
|
|
26
|
+
- ข้อความที่อาจยาวเกินหนึ่งบรรทัด เช่น ข้อความถึงเจ้าหน้าที่ เหตุผลในการถอนเงิน
|
|
27
|
+
|
|
28
|
+
## When not to use
|
|
29
|
+
|
|
30
|
+
- **ข้อมูลสั้นบรรทัดเดียว** (ชื่อ อีเมล ตัวเลข): ใช้ `Input`
|
|
31
|
+
- **ข้อความจัดรูปแบบ** (ตัวหนา รายการ): TODO: ยังไม่มีคอมโพเนนต์ rich text editor
|
|
32
|
+
|
|
33
|
+
## Props and variants
|
|
34
|
+
|
|
35
|
+
ไม่มี variant หรือ size หน้าตาเหมือน `Input` แบบ `filled` สูงอย่างน้อย 64px และขยายตามข้อความ (ในเบราว์เซอร์ที่รองรับ) ผู้ใช้ลากปรับขนาดเองไม่ได้ ตัวอักษร 16px บนจอแคบ และ 14px บนจอ 768px ขึ้นไป
|
|
36
|
+
|
|
37
|
+
| Prop | ค่า | ความหมาย |
|
|
38
|
+
| -------------------- | -------------- | -------------------------------------------------------- |
|
|
39
|
+
| `id` | ข้อความ | ผูกกับ `Label` ผ่าน `htmlFor` |
|
|
40
|
+
| `placeholder` | ข้อความ | ตัวอย่างสิ่งที่ควรพิมพ์ ไม่ใช่ป้ายชื่อ |
|
|
41
|
+
| `value` / `onChange` | ข้อความ / ฟังก์ชัน | ควบคุมค่าจากภายนอก (หรือใช้ `defaultValue`) |
|
|
42
|
+
| `rows` | ตัวเลข | TODO: ยังไม่ได้ตรวจว่า `rows` มีผลร่วมกับการขยายตามข้อความอย่างไร |
|
|
43
|
+
| `maxLength` | ตัวเลข | จำกัดจำนวนตัวอักษร TODO: ยังไม่มีตัวนับตัวอักษร |
|
|
44
|
+
| `disabled` | `boolean` | ปิดใช้งาน จางลง 50% |
|
|
45
|
+
| `aria-invalid` | `boolean` | ข้อมูลไม่ถูกต้อง แสดงเส้นขอบสีแดงและวงแหวนแดงจาง |
|
|
46
|
+
| `aria-describedby` | id ของข้อความ | ผูกข้อความช่วยเหลือหรือข้อความผิดพลาดใต้ช่อง |
|
|
47
|
+
| `className` | class | ปรับหน้าตาเฉพาะจุดครั้งเดียว |
|
|
48
|
+
|
|
49
|
+
## Tokens used
|
|
50
|
+
|
|
51
|
+
ค่าทั้งหมดมาจาก `src/styles/theme.css`
|
|
52
|
+
|
|
53
|
+
### Component tokens
|
|
54
|
+
|
|
55
|
+
token เฉพาะของคอมโพเนนต์นี้ ชี้ไปที่ semantic token ด้านล่าง เปลี่ยนที่นี่เพื่อปรับเฉพาะคอมโพเนนต์นี้ (โหมดมืด "–" = ใช้ค่าเดียวกับโหมดสว่าง)
|
|
56
|
+
|
|
57
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
58
|
+
| --------------------- | -------------------- | ------------------- | ----------------------------------------------- |
|
|
59
|
+
| `--field-border` | `--control-border` | – | เส้นขอบช่องกรอก |
|
|
60
|
+
| `--field-bg` | `--input` 50% | – | พื้นช่องกรอก |
|
|
61
|
+
| `--field-placeholder` | `--muted-foreground` | – | placeholder |
|
|
62
|
+
| `--focus-ring` | `--ring` | – | วงแหวน focus จากคีย์บอร์ดของทุกคอมโพเนนต์ (ทึบ 2px) |
|
|
63
|
+
| `--invalid-border` | `--destructive` | – | เส้นขอบเมื่อข้อมูลไม่ถูกต้อง และวงแหวน focus ขณะไม่ถูกต้อง |
|
|
64
|
+
| `--invalid-ring` | `--destructive` 20% | `--destructive` 40% | วงแหวนจางรอบช่องที่ไม่ถูกต้อง (ตกแต่ง) |
|
|
65
|
+
|
|
66
|
+
### Semantic tokens
|
|
67
|
+
|
|
68
|
+
| Token | โหมดสว่าง | โหมดมืด | ใช้ใน |
|
|
69
|
+
| -------------------- | ------------------------- | -------------------------- | ------------------------------- |
|
|
70
|
+
| `--input` | `oklch(0.93 0.007 106.5)` | `oklch(1 0 0 / 15%)` | พื้นช่อง (50%) |
|
|
71
|
+
| `--muted-foreground` | `oklch(0.5 0.027 107.3)` | `oklch(0.737 0.021 106.9)` | placeholder |
|
|
72
|
+
| `--ring` | `oklch(0.45 0.03 106.9)` | `oklch(0.8 0.02 106.9)` | เส้นขอบและวงแหวน focus |
|
|
73
|
+
| `--destructive` | `oklch(0.505 0.2 27.325)` | `oklch(0.75 0.16 22.216)` | สถานะไม่ถูกต้อง |
|
|
74
|
+
| `--radius` | `0.625rem` | – | มุมโค้ง (`--radius × 1.8` = 18px) |
|
|
75
|
+
| `--control-border` | `oklch(0.6 0.02 106.9)` | `oklch(0.55 0.015 106.9)` | ผ่าน token ของคอมโพเนนต์ด้านบน |
|
|
76
|
+
|
|
77
|
+
## Example
|
|
78
|
+
|
|
79
|
+
จาก story `Invalid` ใน `Textarea.stories.tsx`:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<div className="grid w-80 gap-2">
|
|
83
|
+
<Label htmlFor="ta-reason">เหตุผลในการถอนเงิน</Label>
|
|
84
|
+
<Textarea id="ta-reason" aria-invalid aria-describedby="ta-reason-error" />
|
|
85
|
+
<p id="ta-reason-error" className="text-sm text-destructive">
|
|
86
|
+
กรุณาระบุเหตุผลอย่างน้อย 20 ตัวอักษร
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
```
|