@ratio-ui/core 0.2.0 → 0.4.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/dist/catalogue.json +2690 -749
- package/dist/components/accordion/Accordion.d.ts +19 -0
- package/dist/components/accordion/Accordion.js +52 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/Alert.d.ts +18 -0
- package/dist/components/alert/Alert.js +67 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/alert-dialog/AlertDialog.d.ts +48 -0
- package/dist/components/alert-dialog/AlertDialog.js +76 -0
- package/dist/components/alert-dialog/index.d.ts +2 -0
- package/dist/components/alert-dialog/index.js +1 -0
- package/dist/components/app-shell/AppShell.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +19 -0
- package/dist/components/breadcrumb/Breadcrumb.js +50 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/calendar/Calendar.d.ts +20 -0
- package/dist/components/calendar/Calendar.js +119 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/chart/Chart.d.ts +137 -0
- package/dist/components/chart/Chart.js +238 -0
- package/dist/components/chart/index.d.ts +2 -0
- package/dist/components/chart/index.js +1 -0
- package/dist/components/checkbox-list/CheckboxList.d.ts +36 -0
- package/dist/components/checkbox-list/CheckboxList.js +93 -0
- package/dist/components/checkbox-list/index.d.ts +2 -0
- package/dist/components/checkbox-list/index.js +1 -0
- package/dist/components/collapsible/Collapsible.d.ts +24 -0
- package/dist/components/collapsible/Collapsible.js +58 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox/Combobox.d.ts +52 -0
- package/dist/components/combobox/Combobox.js +92 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/data-table/DataTable.js +2 -2
- package/dist/components/date-picker/DatePicker.d.ts +34 -0
- package/dist/components/date-picker/DatePicker.js +108 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/DateRangePicker.d.ts +40 -0
- package/dist/components/date-range-picker/DateRangePicker.js +146 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/drawer/Drawer.d.ts +52 -0
- package/dist/components/drawer/Drawer.js +120 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/field/Field.d.ts +38 -0
- package/dist/components/field/Field.js +73 -0
- package/dist/components/field/Label.d.ts +8 -0
- package/dist/components/field/Label.js +13 -0
- package/dist/components/field/index.d.ts +3 -0
- package/dist/components/field/index.js +3 -0
- package/dist/components/filter-tabs/FilterTabs.js +1 -1
- package/dist/components/global-search/GlobalSearch.js +1 -1
- package/dist/components/icon/registry.d.ts +2 -2
- package/dist/components/icon/registry.js +5 -1
- package/dist/components/input-group/InputGroup.js +1 -1
- package/dist/components/input-otp/InputOtp.d.ts +43 -0
- package/dist/components/input-otp/InputOtp.js +45 -0
- package/dist/components/input-otp/index.d.ts +2 -0
- package/dist/components/input-otp/index.js +1 -0
- package/dist/components/key-value-list/KeyValueList.d.ts +25 -0
- package/dist/components/key-value-list/KeyValueList.js +40 -0
- package/dist/components/key-value-list/index.d.ts +2 -0
- package/dist/components/key-value-list/index.js +1 -0
- package/dist/components/link/Link.d.ts +22 -0
- package/dist/components/link/Link.js +31 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/link/index.js +1 -0
- package/dist/components/media-grid/MediaGrid.d.ts +49 -0
- package/dist/components/media-grid/MediaGrid.js +303 -0
- package/dist/components/media-grid/index.d.ts +2 -0
- package/dist/components/media-grid/index.js +1 -0
- package/dist/components/money-input/MoneyInput.d.ts +30 -0
- package/dist/components/money-input/MoneyInput.js +72 -0
- package/dist/components/money-input/index.d.ts +2 -0
- package/dist/components/money-input/index.js +1 -0
- package/dist/components/page-header/PageHeader.js +9 -9
- package/dist/components/progress/Progress.d.ts +25 -0
- package/dist/components/progress/Progress.js +38 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.d.ts +18 -0
- package/dist/components/radio-group/RadioGroup.js +32 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/save-bar/SaveBar.d.ts +27 -0
- package/dist/components/save-bar/SaveBar.js +37 -0
- package/dist/components/save-bar/index.d.ts +2 -0
- package/dist/components/save-bar/index.js +1 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +12 -0
- package/dist/components/scroll-area/ScrollArea.js +34 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/search-field/SearchField.js +1 -1
- package/dist/components/select/Select.d.ts +40 -0
- package/dist/components/select/Select.js +84 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/separator/Separator.d.ts +15 -0
- package/dist/components/separator/Separator.js +25 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/sheet/Sheet.d.ts +52 -0
- package/dist/components/sheet/Sheet.js +89 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +1 -0
- package/dist/components/side-nav/SideNav.js +3 -3
- package/dist/components/summary-chips/SummaryChips.d.ts +17 -0
- package/dist/components/summary-chips/SummaryChips.js +19 -0
- package/dist/components/summary-chips/index.d.ts +2 -0
- package/dist/components/summary-chips/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +10 -0
- package/dist/components/switch/Switch.js +20 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/Table.js +1 -1
- package/dist/components/tag-input/TagInput.d.ts +44 -0
- package/dist/components/tag-input/TagInput.js +102 -0
- package/dist/components/tag-input/index.d.ts +2 -0
- package/dist/components/tag-input/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +15 -0
- package/dist/components/textarea/Textarea.js +21 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/top-bar/StoreSwitcher.js +1 -1
- package/dist/components/top-bar/TopBar.js +2 -2
- package/dist/components/unit-input/UnitInput.d.ts +33 -0
- package/dist/components/unit-input/UnitInput.js +47 -0
- package/dist/components/unit-input/index.d.ts +2 -0
- package/dist/components/unit-input/index.js +1 -0
- package/dist/index.d.ts +70 -9
- package/dist/index.js +38 -7
- package/dist/lib/cn.js +9 -2
- package/dist/lib/format.d.ts +65 -4
- package/dist/lib/format.js +163 -6
- package/dist/styles.css +1 -1
- package/package.json +129 -1
package/dist/catalogue.json
CHANGED
|
@@ -1,6 +1,177 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.4.0",
|
|
3
3
|
"components": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Accordion",
|
|
6
|
+
"import": "import { Accordion } from '@ratio-ui/core'",
|
|
7
|
+
"description": "A stack of sections that open and close. One section is open at a time unless multiple is set.",
|
|
8
|
+
"props": [],
|
|
9
|
+
"usage": {
|
|
10
|
+
"whenToUse": "- Grouped help or settings where the reader opens only the section they need\n- A short list of sections with a heading each, such as setup steps or FAQs",
|
|
11
|
+
"whenNotToUse": "- A single block that hides and shows: use a collapsible\n- Switching between views of the same content: use tabs\n- Styling: Accordion takes no `className` and no `style`",
|
|
12
|
+
"example": "<Accordion>\n <AccordionItem value=\"shipping\">\n <AccordionTrigger>Shipping</AccordionTrigger>\n <AccordionContent>Ships in two days.</AccordionContent>\n </AccordionItem>\n</Accordion>"
|
|
13
|
+
},
|
|
14
|
+
"parts": [
|
|
15
|
+
{
|
|
16
|
+
"name": "AccordionItem",
|
|
17
|
+
"import": "import { AccordionItem } from '@ratio-ui/core'",
|
|
18
|
+
"description": "One section: a trigger and its content, separated from the next by a hairline.",
|
|
19
|
+
"props": []
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "AccordionTrigger",
|
|
23
|
+
"import": "import { AccordionTrigger } from '@ratio-ui/core'",
|
|
24
|
+
"description": "The heading row of a section, with a chevron that turns when it is open.",
|
|
25
|
+
"props": []
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "AccordionContent",
|
|
29
|
+
"import": "import { AccordionContent } from '@ratio-ui/core'",
|
|
30
|
+
"description": "The body of a section. It appears and disappears at once, with no height animation.",
|
|
31
|
+
"props": []
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"name": "Alert",
|
|
37
|
+
"import": "import { Alert } from '@ratio-ui/core'",
|
|
38
|
+
"description": "A message that stays in the page: a tone glyph, an optional title and description, and an optional action.",
|
|
39
|
+
"props": [
|
|
40
|
+
{
|
|
41
|
+
"name": "tone",
|
|
42
|
+
"type": "\"critical\" | \"info\" | \"success\" | \"warning\"",
|
|
43
|
+
"required": false,
|
|
44
|
+
"default": "info",
|
|
45
|
+
"description": "The tone. Defaults to info."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "title",
|
|
49
|
+
"type": "ReactNode",
|
|
50
|
+
"required": false,
|
|
51
|
+
"description": "An optional bold first line."
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "description",
|
|
55
|
+
"type": "ReactNode",
|
|
56
|
+
"required": false,
|
|
57
|
+
"description": "An optional second line."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "action",
|
|
61
|
+
"type": "ReactNode",
|
|
62
|
+
"required": false,
|
|
63
|
+
"description": "An optional action on the right, usually one Button."
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "ref",
|
|
67
|
+
"type": "Ref<HTMLDivElement>",
|
|
68
|
+
"required": false,
|
|
69
|
+
"description": "Receives the rendered div."
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"usage": {
|
|
73
|
+
"whenToUse": "- A message that sits in the page and stays until the cause is gone: a banner above a form, a notice in a card\n- Four tones: info, success, warning, critical (question 1 tokens: no fill, strong border, warning glyph)",
|
|
74
|
+
"whenNotToUse": "- A message that disappears by itself: use Toaster\n- A confirmation before a destructive step: use AlertDialog\n- A field error: say it in one clause under the field",
|
|
75
|
+
"example": "```tsx\n<Alert\n tone=\"critical\"\n title=\"Payment failed\"\n description=\"Try another method.\"\n action={<Button>Retry</Button>}\n/>\n```\n\nInfo and success have role status (polite); warning and critical have role alert (assertive)."
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "AlertDialog",
|
|
80
|
+
"import": "import { AlertDialog } from '@ratio-ui/core'",
|
|
81
|
+
"description": "The root of a confirmation. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it, or `defaultOpen` to leave it uncontrolled. Escape closes it; a click outside does not.",
|
|
82
|
+
"props": [],
|
|
83
|
+
"usage": {
|
|
84
|
+
"whenToUse": "- A confirm step before deleting something, or before a money action such as a refund\n- An answer that must be given: Escape closes it, a click outside does not\n- A short question that fits in 480px: the panel is fixed at that width, with a ring outline and no scrim",
|
|
85
|
+
"whenNotToUse": "- A form or any input: use Dialog\n- A message after an action: use toast()\n- A reversible action: do it and offer undo instead",
|
|
86
|
+
"example": "```tsx\n<AlertDialog>\n <AlertDialogTrigger>Delete product</AlertDialogTrigger>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Delete this product?</AlertDialogTitle>\n <AlertDialogDescription>It leaves the storefront at once.</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction>Delete</AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n</AlertDialog>\n```\n\n- `AlertDialogAction` is the Button's destructive variant and closes the dialog after `onClick` runs. Pass `variant=\"main\"` for a non-destructive confirmation such as a refund. For an async action that must stay open until it finishes, control the dialog with `open` and `onOpenChange`.\n- `AlertDialogCancel` is the secondary Button and closes the dialog.\n- Name the action with the verb (\"Delete\", \"Refund\"), never \"OK\". Put the amount in the title for money actions, formatted with the format helpers."
|
|
87
|
+
},
|
|
88
|
+
"parts": [
|
|
89
|
+
{
|
|
90
|
+
"name": "AlertDialogAction",
|
|
91
|
+
"import": "import { AlertDialogAction } from '@ratio-ui/core'",
|
|
92
|
+
"description": "The confirming button. It is the Button's destructive variant and closes the dialog after its onClick runs.",
|
|
93
|
+
"props": [
|
|
94
|
+
{
|
|
95
|
+
"name": "variant",
|
|
96
|
+
"type": "\"destructive\" | \"main\"",
|
|
97
|
+
"required": false,
|
|
98
|
+
"default": "destructive",
|
|
99
|
+
"description": "The Button look. Defaults to destructive; use main for a confirmation that deletes nothing."
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "AlertDialogCancel",
|
|
105
|
+
"import": "import { AlertDialogCancel } from '@ratio-ui/core'",
|
|
106
|
+
"description": "The secondary button that closes the dialog without doing anything.",
|
|
107
|
+
"props": []
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "AlertDialogContent",
|
|
111
|
+
"import": "import { AlertDialogContent } from '@ratio-ui/core'",
|
|
112
|
+
"description": "The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put AlertDialogHeader and AlertDialogFooter inside.",
|
|
113
|
+
"props": [
|
|
114
|
+
{
|
|
115
|
+
"name": "render",
|
|
116
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPopupState>",
|
|
117
|
+
"required": false,
|
|
118
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "AlertDialogDescription",
|
|
124
|
+
"import": "import { AlertDialogDescription } from '@ratio-ui/core'",
|
|
125
|
+
"description": "What will happen, in subdued body text.",
|
|
126
|
+
"props": [
|
|
127
|
+
{
|
|
128
|
+
"name": "render",
|
|
129
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogDescriptionState>",
|
|
130
|
+
"required": false,
|
|
131
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "AlertDialogFooter",
|
|
137
|
+
"import": "import { AlertDialogFooter } from '@ratio-ui/core'",
|
|
138
|
+
"description": "The row of actions at the bottom, aligned to the end.",
|
|
139
|
+
"props": []
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"name": "AlertDialogHeader",
|
|
143
|
+
"import": "import { AlertDialogHeader } from '@ratio-ui/core'",
|
|
144
|
+
"description": "The title and description, stacked.",
|
|
145
|
+
"props": []
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "AlertDialogTitle",
|
|
149
|
+
"import": "import { AlertDialogTitle } from '@ratio-ui/core'",
|
|
150
|
+
"description": "The question, in the b4 style. It names the dialog for assistive technology.",
|
|
151
|
+
"props": [
|
|
152
|
+
{
|
|
153
|
+
"name": "render",
|
|
154
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTitleState>",
|
|
155
|
+
"required": false,
|
|
156
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "AlertDialogTrigger",
|
|
162
|
+
"import": "import { AlertDialogTrigger } from '@ratio-ui/core'",
|
|
163
|
+
"description": "The button that opens the confirmation.",
|
|
164
|
+
"props": [
|
|
165
|
+
{
|
|
166
|
+
"name": "render",
|
|
167
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTriggerState>",
|
|
168
|
+
"required": false,
|
|
169
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
4
175
|
{
|
|
5
176
|
"name": "AppShell",
|
|
6
177
|
"import": "import { AppShell } from '@ratio-ui/core'",
|
|
@@ -94,6 +265,36 @@
|
|
|
94
265
|
"example": "<Avatar name=\"My Store\" shape=\"square\" />\n<Avatar name=\"Kavya Singh\" />"
|
|
95
266
|
}
|
|
96
267
|
},
|
|
268
|
+
{
|
|
269
|
+
"name": "Breadcrumb",
|
|
270
|
+
"import": "import { Breadcrumb } from '@ratio-ui/core'",
|
|
271
|
+
"description": "The trail to the current page: links, chevron separators, the current page as text and an overflow ellipsis.",
|
|
272
|
+
"props": [
|
|
273
|
+
{
|
|
274
|
+
"name": "items",
|
|
275
|
+
"type": "BreadcrumbItem[]",
|
|
276
|
+
"required": true,
|
|
277
|
+
"description": "The trail, from the root to the current page."
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"name": "maxItems",
|
|
281
|
+
"type": "number",
|
|
282
|
+
"required": false,
|
|
283
|
+
"description": "Past this many items the middle ones collapse behind an ellipsis, keeping the first and the last two."
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "ref",
|
|
287
|
+
"type": "Ref<HTMLElement>",
|
|
288
|
+
"required": false,
|
|
289
|
+
"description": "Receives the rendered nav."
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
"usage": {
|
|
293
|
+
"whenToUse": "- Show where a page sits in a hierarchy, with a way back up",
|
|
294
|
+
"whenNotToUse": "- Switching between sibling views: use Tabs",
|
|
295
|
+
"example": "<Breadcrumb items={[{ label: 'Products', href: '/products' }, { label: 'Runner' }]} maxItems={4} />"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
97
298
|
{
|
|
98
299
|
"name": "Button",
|
|
99
300
|
"import": "import { Button } from '@ratio-ui/core'",
|
|
@@ -138,6 +339,17 @@
|
|
|
138
339
|
"example": "<Stack gap={8}>\n <Button><Icon name=\"plus\" />Add customer</Button>\n <Button variant=\"secondary\">Export</Button>\n <Button iconOnly variant=\"ghost\" aria-label=\"Add\"><Icon name=\"plus\" /></Button>\n</Stack>"
|
|
139
340
|
}
|
|
140
341
|
},
|
|
342
|
+
{
|
|
343
|
+
"name": "Calendar",
|
|
344
|
+
"import": "import { Calendar } from '@ratio-ui/core'",
|
|
345
|
+
"description": "A month grid to pick a day or a range of days, drawn by the design system: 28px days with a 6px radius, today in the accent ink, the selected day filled with the accent, a range as accent ends on a tinted band, disabled days at 50% and the days of the months around it in the muted ink. Every day is named in the format module's date order (28/10/2026). Arrow keys move between days and the previous and next buttons between months. It has no fill of its own, so it sits in a popover or a container as drawn.",
|
|
346
|
+
"props": [],
|
|
347
|
+
"usage": {
|
|
348
|
+
"whenToUse": "- Picking one day, such as a \"Best before\" date, inside a popover or a form: `mode=\"single\"`\n- Picking a range of days, such as an analytics period: `mode=\"range\"`, with `numberOfMonths={2}` for a wide range\n- Limiting the days that can be picked: `disabled` (for example `{ before: today }`), `startMonth` and `endMonth`",
|
|
349
|
+
"whenNotToUse": "- A date field people type into: use DatePicker or DateRangePicker, which open this calendar in a popover\n- Showing a date as text: write it with the format module, never with a calendar\n- Styling: Calendar takes no `className`, `classNames`, `style`, `components` or `formatters`; dates are written in the format module's order (28/10/2026)",
|
|
350
|
+
"example": "const [day, setDay] = useState<Date | undefined>()\n\n<Calendar mode=\"single\" selected={day} onSelect={setDay} disabled={{ before: new Date() }} />"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
141
353
|
{
|
|
142
354
|
"name": "Card",
|
|
143
355
|
"import": "import { Card } from '@ratio-ui/core'",
|
|
@@ -190,1125 +402,2609 @@
|
|
|
190
402
|
]
|
|
191
403
|
},
|
|
192
404
|
{
|
|
193
|
-
"name": "
|
|
194
|
-
"import": "import {
|
|
195
|
-
"description": "A
|
|
196
|
-
"props": [],
|
|
197
|
-
"usage": {
|
|
198
|
-
"whenToUse": "- A row selector in a table or list, one box per row\n- A select-all in a table header: set `indeterminate` while only some rows are selected\n- A yes or no option in a form, or a list of channels where several can be on",
|
|
199
|
-
"whenNotToUse": "- A setting that applies at once: use a switch\n- One choice among several: use radio buttons or FilterTabs\n- Styling: Checkbox takes no `className` and no `style`",
|
|
200
|
-
"example": "<Checkbox aria-label=\"Select row\" checked={selected} onCheckedChange={setSelected} />"
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
"name": "DataTable",
|
|
205
|
-
"import": "import { DataTable } from '@ratio-ui/core'",
|
|
206
|
-
"description": "A data table on Table with TanStack Table v9: a selection column, server-side sorting and paging, alignment, one-line truncation, row links, and empty and loading slots. The parent owns the state (sort, page, selection) and passes it in. On phones it keeps the columns marked essential and hides the rest.",
|
|
405
|
+
"name": "Chart",
|
|
406
|
+
"import": "import { Chart } from '@ratio-ui/core'",
|
|
407
|
+
"description": "A chart on Recharts, drawn with the chart tokens. It holds the config the tooltip and legend read, styles Recharts' ticks, grid and cursor with the tokens, and is a figure named by its label and summarised by a description, a visually hidden data table, or both. Motion is colour fades only, so every series passes isAnimationActive false.",
|
|
207
408
|
"props": [
|
|
208
409
|
{
|
|
209
|
-
"name": "
|
|
210
|
-
"type": "
|
|
211
|
-
"required": true,
|
|
212
|
-
"description": "The columns, in order."
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"name": "data",
|
|
216
|
-
"type": "T[]",
|
|
217
|
-
"required": true,
|
|
218
|
-
"description": "The rows of the page on show, already sorted by the parent."
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
"name": "getRowId",
|
|
222
|
-
"type": "(row: T) => string",
|
|
223
|
-
"required": true,
|
|
224
|
-
"description": "A stable id for a row."
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"name": "selectedIds",
|
|
228
|
-
"type": "string[]",
|
|
229
|
-
"required": false,
|
|
230
|
-
"description": "Ids of the selected rows. Pass it with `onSelectedIdsChange` to show a checkbox column."
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
"name": "onSelectedIdsChange",
|
|
234
|
-
"type": "((ids: string[]) => void)",
|
|
235
|
-
"required": false,
|
|
236
|
-
"description": "Called with the ids that are selected after a change."
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"name": "getRowLabel",
|
|
240
|
-
"type": "((row: T) => string)",
|
|
241
|
-
"required": false,
|
|
242
|
-
"description": "The label of one row's checkbox: \"RYZE - 2mg\", which the table prefixes with \"Select \". Defaults to \"Select row N\"."
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
"name": "sort",
|
|
246
|
-
"type": "DataTableSort | null",
|
|
247
|
-
"required": false,
|
|
248
|
-
"default": "null",
|
|
249
|
-
"description": "The sort the parent applied, or null for none."
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
"name": "onSortChange",
|
|
253
|
-
"type": "((sort: DataTableSort | null) => void)",
|
|
254
|
-
"required": false,
|
|
255
|
-
"description": "Called with the next sort, or null to clear it. The parent sorts and passes new data."
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
"name": "page",
|
|
259
|
-
"type": "number",
|
|
410
|
+
"name": "description",
|
|
411
|
+
"type": "string",
|
|
260
412
|
"required": false,
|
|
261
|
-
"description": "
|
|
413
|
+
"description": "One sentence on what the chart shows, read after its name, such as \"Sales peak on Tuesday\"."
|
|
262
414
|
},
|
|
263
415
|
{
|
|
264
|
-
"name": "
|
|
265
|
-
"type": "
|
|
416
|
+
"name": "table",
|
|
417
|
+
"type": "ChartTable",
|
|
266
418
|
"required": false,
|
|
267
|
-
"description": "
|
|
419
|
+
"description": "The chart's rows as a visually hidden table, for assistive technology."
|
|
268
420
|
},
|
|
269
421
|
{
|
|
270
|
-
"name": "
|
|
271
|
-
"type": "
|
|
272
|
-
"required":
|
|
273
|
-
"description": "
|
|
422
|
+
"name": "config",
|
|
423
|
+
"type": "ChartConfig",
|
|
424
|
+
"required": true,
|
|
425
|
+
"description": "The series and categories, by data key: their labels, icons and chart tokens."
|
|
274
426
|
},
|
|
275
427
|
{
|
|
276
|
-
"name": "
|
|
277
|
-
"type": "
|
|
278
|
-
"required":
|
|
279
|
-
"description": "
|
|
428
|
+
"name": "label",
|
|
429
|
+
"type": "string",
|
|
430
|
+
"required": true,
|
|
431
|
+
"description": "The chart's accessible name, such as \"Sales by day\"."
|
|
280
432
|
},
|
|
281
433
|
{
|
|
282
|
-
"name": "
|
|
283
|
-
"type": "
|
|
434
|
+
"name": "aspect",
|
|
435
|
+
"type": "\"fill\" | \"square\" | \"video\"",
|
|
284
436
|
"required": false,
|
|
285
|
-
"
|
|
437
|
+
"default": "video",
|
|
438
|
+
"description": "The size: video (16:9, the default) or square at the full width, or fill to take the parent's size."
|
|
286
439
|
},
|
|
287
440
|
{
|
|
288
|
-
"name": "
|
|
289
|
-
"type": "
|
|
441
|
+
"name": "initialDimension",
|
|
442
|
+
"type": "{ width: number; height: number; }",
|
|
290
443
|
"required": false,
|
|
291
|
-
"
|
|
444
|
+
"default": "{ width: 320, height: 200 } as const",
|
|
445
|
+
"description": "The size the chart is drawn at before it measures its box. Defaults to 320 by 200."
|
|
292
446
|
},
|
|
293
447
|
{
|
|
294
|
-
"name": "
|
|
295
|
-
"type": "
|
|
296
|
-
"required":
|
|
297
|
-
"description": "
|
|
448
|
+
"name": "children",
|
|
449
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>>",
|
|
450
|
+
"required": true,
|
|
451
|
+
"description": "One Recharts chart, such as a BarChart or a LineChart, whose series pass isAnimationActive false."
|
|
298
452
|
}
|
|
299
453
|
],
|
|
300
454
|
"usage": {
|
|
301
|
-
"whenToUse": "-
|
|
302
|
-
"whenNotToUse": "-
|
|
303
|
-
"example": "
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
{
|
|
307
|
-
"name": "Definition",
|
|
308
|
-
"import": "import { Definition } from '@ratio-ui/core'",
|
|
309
|
-
"description": "A term that explains itself. It is a span with the button role and a dotted underline, so it takes the font of the text around it, so keyboard users reach it with Tab and open it with Enter or Space, touch users open it with a tap, and mouse users with hover or click. It does not use the browser's own title tooltip, which keyboard and touch users cannot open. Escape closes it.",
|
|
310
|
-
"props": [
|
|
455
|
+
"whenToUse": "- Analytics: a trend or a comparison over days or categories, as bars or lines\n- The page loader's bar mark\n- With a label and a one-sentence description, a data table, or both, so assistive technology gets the same summary\n- Every series passes isAnimationActive false: motion is colour fades only, and the tooltip never moves",
|
|
456
|
+
"whenNotToUse": "- A single number or a few numbers side by side: use MetricStrip\n- Progress towards an end: use Progress\n- Colours outside chart-1 to chart-5, or chart-4 and chart-5 alone on white: they sit below 3:1, so draw them beside a darker series",
|
|
457
|
+
"example": "import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'\n\nconst config = { sales: { label: 'Sales', color: 'chart-1' } } satisfies ChartConfig\n\n<Chart config={config} label=\"Sales by day\" description=\"Sales peak on Friday\">\n <BarChart data={week} accessibilityLayer>\n <CartesianGrid vertical={false} />\n <XAxis dataKey=\"day\" tickLine={false} axisLine={false} />\n <ChartTooltip content={<ChartTooltipContent formatValue={formatMoney} />} />\n <Bar dataKey=\"sales\" fill={chartColor('chart-1')} isAnimationActive={false} />\n </BarChart>\n</Chart>"
|
|
458
|
+
},
|
|
459
|
+
"parts": [
|
|
311
460
|
{
|
|
312
|
-
"name": "
|
|
313
|
-
"
|
|
314
|
-
"
|
|
315
|
-
"
|
|
461
|
+
"name": "ChartTooltip",
|
|
462
|
+
"import": "import { ChartTooltip } from '@ratio-ui/core'",
|
|
463
|
+
"description": "The chart's tooltip: Recharts' Tooltip, still (no movement), drawing ChartTooltipContent unless given other content.",
|
|
464
|
+
"props": [
|
|
465
|
+
{
|
|
466
|
+
"name": "cursor",
|
|
467
|
+
"type": "boolean",
|
|
468
|
+
"required": false,
|
|
469
|
+
"description": "Shows the cursor line or band under the pointer. On or off: Recharts' SVG props would carry a class name and a style."
|
|
470
|
+
}
|
|
471
|
+
]
|
|
316
472
|
},
|
|
317
473
|
{
|
|
318
|
-
"name": "
|
|
319
|
-
"
|
|
320
|
-
"
|
|
321
|
-
"description": "The explanation shown when the term is opened. Keep it to a sentence."
|
|
322
|
-
}
|
|
323
|
-
],
|
|
324
|
-
"usage": {
|
|
325
|
-
"whenToUse": "- A term in a heading or label that needs a one-sentence explanation, such as a metric title\n- Where keyboard and touch users must be able to read the explanation: it opens with Tab and Enter, with a tap, and on hover",
|
|
326
|
-
"whenNotToUse": "- An icon-only hint: use Tooltip\n- Long or interactive content: use Popover\n- Text that the task cannot be finished without: show it on the screen",
|
|
327
|
-
"example": "<Definition definition=\"Gross merchandise value, before returns\">GMV</Definition>"
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
"name": "Dialog",
|
|
332
|
-
"import": "import { Dialog } from '@ratio-ui/core'",
|
|
333
|
-
"description": "The root of a dialog. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it, or `defaultOpen` to leave it uncontrolled. The page behind is inert while it is open, with no scrim over it.",
|
|
334
|
-
"props": [],
|
|
335
|
-
"usage": {
|
|
336
|
-
"whenToUse": "- A short task that needs the user's full attention before going back to the page, such as adding a product or defining a field\n- A confirm step before a destructive action\n- Work that fits in 480px: the panel is fixed at that width and has no scrim",
|
|
337
|
-
"whenNotToUse": "- A message after an action: use toast()\n- A long form or a multi-step flow: give it a page\n- Help text on a control: use a Tooltip or Popover",
|
|
338
|
-
"example": "<Dialog>\n <DialogTrigger>Add product</DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add product</DialogTitle>\n <DialogDescription>Fill in the basics</DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose>Cancel</DialogClose>\n </DialogFooter>\n </DialogContent>\n</Dialog>"
|
|
339
|
-
},
|
|
340
|
-
"parts": [
|
|
341
|
-
{
|
|
342
|
-
"name": "DialogClose",
|
|
343
|
-
"import": "import { DialogClose } from '@ratio-ui/core'",
|
|
344
|
-
"description": "A button that closes the dialog, such as Cancel in the footer.",
|
|
345
|
-
"props": [
|
|
346
|
-
{
|
|
347
|
-
"name": "render",
|
|
348
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogCloseState>",
|
|
349
|
-
"required": false,
|
|
350
|
-
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
"name": "DialogContent",
|
|
356
|
-
"import": "import { DialogContent } from '@ratio-ui/core'",
|
|
357
|
-
"description": "The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put DialogHeader, the form and DialogFooter inside.",
|
|
474
|
+
"name": "ChartTooltipContent",
|
|
475
|
+
"import": "import { ChartTooltipContent } from '@ratio-ui/core'",
|
|
476
|
+
"description": "The box a chart tooltip draws: the active point's label, then a row per series with its swatch, its config label and its value, a count unless formatValue writes it. A 1px border on white, no shadow.",
|
|
358
477
|
"props": [
|
|
359
478
|
{
|
|
360
|
-
"name": "
|
|
479
|
+
"name": "active",
|
|
361
480
|
"type": "boolean",
|
|
362
481
|
"required": false,
|
|
363
|
-
"
|
|
364
|
-
"description": "Whether the corner close button shows. Defaults to true."
|
|
482
|
+
"description": "Set by the tooltip: whether a point is active."
|
|
365
483
|
},
|
|
366
484
|
{
|
|
367
|
-
"name": "
|
|
368
|
-
"type": "
|
|
485
|
+
"name": "payload",
|
|
486
|
+
"type": "readonly Payload<ValueType, TooltipNameType>[]",
|
|
369
487
|
"required": false,
|
|
370
|
-
"
|
|
371
|
-
"description": "The accessible name of the corner close button. Defaults to Close."
|
|
488
|
+
"description": "Set by the tooltip: the values of the series at the active point."
|
|
372
489
|
},
|
|
373
490
|
{
|
|
374
|
-
"name": "
|
|
375
|
-
"type": "
|
|
491
|
+
"name": "label",
|
|
492
|
+
"type": "ReactNode",
|
|
376
493
|
"required": false,
|
|
377
|
-
"description": "
|
|
378
|
-
}
|
|
379
|
-
]
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
"name": "DialogDescription",
|
|
383
|
-
"import": "import { DialogDescription } from '@ratio-ui/core'",
|
|
384
|
-
"description": "One line that says what the dialog is for, in subdued body text.",
|
|
385
|
-
"props": [
|
|
494
|
+
"description": "Set by the tooltip: the active point's label, such as its x-axis category."
|
|
495
|
+
},
|
|
386
496
|
{
|
|
387
|
-
"name": "
|
|
388
|
-
"type": "
|
|
497
|
+
"name": "labelFormatter",
|
|
498
|
+
"type": "((label: ReactNode, payload: readonly Payload<ValueType, TooltipNameType>[]) => ReactNode)",
|
|
389
499
|
"required": false,
|
|
390
|
-
"description": "
|
|
391
|
-
}
|
|
392
|
-
]
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
"name": "DialogFooter",
|
|
396
|
-
"import": "import { DialogFooter } from '@ratio-ui/core'",
|
|
397
|
-
"description": "The row of actions at the bottom, aligned to the end.",
|
|
398
|
-
"props": []
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
"name": "DialogHeader",
|
|
402
|
-
"import": "import { DialogHeader } from '@ratio-ui/core'",
|
|
403
|
-
"description": "The title and description, stacked.",
|
|
404
|
-
"props": []
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
"name": "DialogTitle",
|
|
408
|
-
"import": "import { DialogTitle } from '@ratio-ui/core'",
|
|
409
|
-
"description": "The dialog's name, in the b4 style. It names the dialog for assistive technology.",
|
|
410
|
-
"props": [
|
|
500
|
+
"description": "Writes the label from it and the payload."
|
|
501
|
+
},
|
|
411
502
|
{
|
|
412
|
-
"name": "
|
|
413
|
-
"type": "
|
|
503
|
+
"name": "formatter",
|
|
504
|
+
"type": "Formatter<ValueType, TooltipNameType>",
|
|
414
505
|
"required": false,
|
|
415
|
-
"description": "
|
|
416
|
-
}
|
|
417
|
-
]
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
"name": "DialogTrigger",
|
|
421
|
-
"import": "import { DialogTrigger } from '@ratio-ui/core'",
|
|
422
|
-
"description": "The button that opens the dialog.",
|
|
423
|
-
"props": [
|
|
506
|
+
"description": "Draws a whole row, in place of the swatch, name and value, from the value, name, item, index and payload."
|
|
507
|
+
},
|
|
424
508
|
{
|
|
425
|
-
"name": "
|
|
426
|
-
"type": "
|
|
509
|
+
"name": "indicator",
|
|
510
|
+
"type": "\"dashed\" | \"dot\" | \"line\"",
|
|
427
511
|
"required": false,
|
|
428
|
-
"
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
]
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
"name": "DropdownMenu",
|
|
436
|
-
"import": "import { DropdownMenu } from '@ratio-ui/core'",
|
|
437
|
-
"description": "The root of a menu of actions that opens from a trigger. Compose it with DropdownMenuTrigger and DropdownMenuContent.",
|
|
438
|
-
"props": [],
|
|
439
|
-
"usage": {
|
|
440
|
-
"whenToUse": "- A short list of actions behind one control: \"More actions\", a store menu, a \"…\" button\n- Actions that belong in groups, with a label per group, a hairline between groups, or a submenu\n- Items that show a key hint, a check (on or off) or one choice out of a few",
|
|
441
|
-
"whenNotToUse": "- Choosing a value for a form field: use a select\n- Content that is not a list of actions, such as notifications or a form: use Popover\n- A destructive action without a confirm step: the destructive item only colours it\n- Styling: the parts take no `className` and no `style`, and the menu has no shadow",
|
|
442
|
-
"example": "<DropdownMenu>\n <DropdownMenuTrigger>More actions</DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuGroup>\n <DropdownMenuLabel>Product</DropdownMenuLabel>\n <DropdownMenuItem>\n Edit\n <DropdownMenuShortcut>⌘E</DropdownMenuShortcut>\n </DropdownMenuItem>\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\">Delete</DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>"
|
|
443
|
-
},
|
|
444
|
-
"parts": [
|
|
445
|
-
{
|
|
446
|
-
"name": "DropdownMenuCheckboxItem",
|
|
447
|
-
"import": "import { DropdownMenuCheckboxItem } from '@ratio-ui/core'",
|
|
448
|
-
"description": "An item that toggles an option. A check shows at its start while it is on and keeps the menu open, so several options can be changed in one visit.",
|
|
449
|
-
"props": [
|
|
512
|
+
"default": "dot",
|
|
513
|
+
"description": "The swatch: a dot (the default), a line or a dashed line."
|
|
514
|
+
},
|
|
450
515
|
{
|
|
451
|
-
"name": "
|
|
452
|
-
"type": "
|
|
516
|
+
"name": "hideLabel",
|
|
517
|
+
"type": "boolean",
|
|
453
518
|
"required": false,
|
|
454
|
-
"
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
"name": "DropdownMenuContent",
|
|
460
|
-
"import": "import { DropdownMenuContent } from '@ratio-ui/core'",
|
|
461
|
-
"description": "The menu panel: a white popup with a hairline ring, 8px corners and no shadow. It opens in a portal.",
|
|
462
|
-
"props": [
|
|
519
|
+
"default": "false",
|
|
520
|
+
"description": "Leaves out the label."
|
|
521
|
+
},
|
|
463
522
|
{
|
|
464
|
-
"name": "
|
|
465
|
-
"type": "
|
|
523
|
+
"name": "hideIndicator",
|
|
524
|
+
"type": "boolean",
|
|
466
525
|
"required": false,
|
|
467
|
-
"default": "
|
|
468
|
-
"description": "
|
|
526
|
+
"default": "false",
|
|
527
|
+
"description": "Leaves out the swatches."
|
|
469
528
|
},
|
|
470
529
|
{
|
|
471
|
-
"name": "
|
|
472
|
-
"type": "
|
|
530
|
+
"name": "nameKey",
|
|
531
|
+
"type": "string",
|
|
473
532
|
"required": false,
|
|
474
|
-
"
|
|
475
|
-
"description": "How the menu lines up with the trigger along that side. Defaults to start."
|
|
533
|
+
"description": "The key of the item, or its data row, whose value names the config entry of a row."
|
|
476
534
|
},
|
|
477
535
|
{
|
|
478
|
-
"name": "
|
|
479
|
-
"type": "
|
|
536
|
+
"name": "labelKey",
|
|
537
|
+
"type": "string",
|
|
480
538
|
"required": false,
|
|
481
|
-
"
|
|
482
|
-
"description": "The gap between the trigger and the menu in px. Defaults to 4."
|
|
539
|
+
"description": "The key whose config entry labels the tooltip, in place of the active point's label."
|
|
483
540
|
},
|
|
484
541
|
{
|
|
485
|
-
"name": "
|
|
486
|
-
"type": "
|
|
542
|
+
"name": "color",
|
|
543
|
+
"type": "\"chart-1\" | \"chart-2\" | \"chart-3\" | \"chart-4\" | \"chart-5\"",
|
|
487
544
|
"required": false,
|
|
488
|
-
"
|
|
489
|
-
"description": "A shift along the side in px. Defaults to 0."
|
|
545
|
+
"description": "One chart token for every swatch, in place of each series' own."
|
|
490
546
|
},
|
|
491
547
|
{
|
|
492
|
-
"name": "
|
|
493
|
-
"type": "
|
|
548
|
+
"name": "formatValue",
|
|
549
|
+
"type": "((value: number) => string)",
|
|
494
550
|
"required": false,
|
|
495
|
-
"description": "
|
|
551
|
+
"description": "Writes a number for its series, such as formatMoney for sales. Defaults to a count."
|
|
496
552
|
}
|
|
497
553
|
]
|
|
498
554
|
},
|
|
499
555
|
{
|
|
500
|
-
"name": "
|
|
501
|
-
"import": "import {
|
|
502
|
-
"description": "
|
|
503
|
-
"props": [
|
|
504
|
-
{
|
|
505
|
-
"name": "render",
|
|
506
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupState>",
|
|
507
|
-
"required": false,
|
|
508
|
-
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
509
|
-
}
|
|
510
|
-
]
|
|
556
|
+
"name": "ChartLegend",
|
|
557
|
+
"import": "import { ChartLegend } from '@ratio-ui/core'",
|
|
558
|
+
"description": "The chart's legend: Recharts' Legend, drawing ChartLegendContent unless given other content.",
|
|
559
|
+
"props": []
|
|
511
560
|
},
|
|
512
561
|
{
|
|
513
|
-
"name": "
|
|
514
|
-
"import": "import {
|
|
515
|
-
"description": "
|
|
562
|
+
"name": "ChartLegendContent",
|
|
563
|
+
"import": "import { ChartLegendContent } from '@ratio-ui/core'",
|
|
564
|
+
"description": "The row a chart legend draws: a swatch in each series' chart token, or its icon, and its config label.",
|
|
516
565
|
"props": [
|
|
517
566
|
{
|
|
518
|
-
"name": "
|
|
519
|
-
"type": "
|
|
567
|
+
"name": "payload",
|
|
568
|
+
"type": "readonly LegendPayload[]",
|
|
520
569
|
"required": false,
|
|
521
|
-
"
|
|
522
|
-
"description": "What the item means. destructive is drawn in the destructive token; a delete action also needs a confirm step. Defaults to default."
|
|
570
|
+
"description": "Set by the legend: its series."
|
|
523
571
|
},
|
|
524
572
|
{
|
|
525
|
-
"name": "
|
|
526
|
-
"type": "
|
|
573
|
+
"name": "verticalAlign",
|
|
574
|
+
"type": "\"bottom\" | \"middle\" | \"top\"",
|
|
527
575
|
"required": false,
|
|
528
|
-
"
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
},
|
|
532
|
-
{
|
|
533
|
-
"name": "DropdownMenuLabel",
|
|
534
|
-
"import": "import { DropdownMenuLabel } from '@ratio-ui/core'",
|
|
535
|
-
"description": "The caption of a group, in the design system's label style: 12px, uppercase, subdued. Place it inside DropdownMenuGroup.",
|
|
536
|
-
"props": [
|
|
576
|
+
"default": "bottom",
|
|
577
|
+
"description": "Set by the legend: whether it sits above or below the chart, which sets the side of its gap."
|
|
578
|
+
},
|
|
537
579
|
{
|
|
538
|
-
"name": "
|
|
539
|
-
"type": "
|
|
580
|
+
"name": "hideIcon",
|
|
581
|
+
"type": "boolean",
|
|
540
582
|
"required": false,
|
|
541
|
-
"
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
"name": "DropdownMenuRadioGroup",
|
|
547
|
-
"import": "import { DropdownMenuRadioGroup } from '@ratio-ui/core'",
|
|
548
|
-
"description": "Holds radio items and the one chosen value.",
|
|
549
|
-
"props": [
|
|
583
|
+
"default": "false",
|
|
584
|
+
"description": "Draws the swatch even where the config gives an icon."
|
|
585
|
+
},
|
|
550
586
|
{
|
|
551
|
-
"name": "
|
|
552
|
-
"type": "
|
|
587
|
+
"name": "nameKey",
|
|
588
|
+
"type": "string",
|
|
553
589
|
"required": false,
|
|
554
|
-
"description": "
|
|
590
|
+
"description": "The key of the item whose value names the config entry of a series."
|
|
555
591
|
}
|
|
556
592
|
]
|
|
593
|
+
}
|
|
594
|
+
]
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
"name": "Checkbox",
|
|
598
|
+
"import": "import { Checkbox } from '@ratio-ui/core'",
|
|
599
|
+
"description": "A 14px box with a 4px radius, drawn with a hairline ring and filled in the primary colour when checked. Set indeterminate for a select-all that stands for some rows. An invisible 24px area around the box takes the tap.",
|
|
600
|
+
"props": [],
|
|
601
|
+
"usage": {
|
|
602
|
+
"whenToUse": "- A row selector in a table or list, one box per row\n- A select-all in a table header: set `indeterminate` while only some rows are selected\n- A yes or no option in a form, or a list of channels where several can be on",
|
|
603
|
+
"whenNotToUse": "- A setting that applies at once: use a switch\n- One choice among several: use radio buttons or FilterTabs\n- Styling: Checkbox takes no `className` and no `style`",
|
|
604
|
+
"example": "<Checkbox aria-label=\"Select row\" checked={selected} onCheckedChange={setSelected} />"
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"name": "CheckboxList",
|
|
609
|
+
"import": "import { CheckboxList } from '@ratio-ui/core'",
|
|
610
|
+
"description": "A titled list of checkboxes with the count of chosen items in the heading (\"4 of 6\"), an optional description under each label and an optional select-all.",
|
|
611
|
+
"props": [
|
|
612
|
+
{
|
|
613
|
+
"name": "title",
|
|
614
|
+
"type": "string",
|
|
615
|
+
"required": true,
|
|
616
|
+
"description": "The heading. The count of chosen items sits beside it."
|
|
557
617
|
},
|
|
558
618
|
{
|
|
559
|
-
"name": "
|
|
560
|
-
"
|
|
561
|
-
"
|
|
562
|
-
"
|
|
563
|
-
{
|
|
564
|
-
"name": "render",
|
|
565
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioItemState>",
|
|
566
|
-
"required": false,
|
|
567
|
-
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
568
|
-
}
|
|
569
|
-
]
|
|
619
|
+
"name": "items",
|
|
620
|
+
"type": "CheckboxListItem[]",
|
|
621
|
+
"required": true,
|
|
622
|
+
"description": "The options."
|
|
570
623
|
},
|
|
571
624
|
{
|
|
572
|
-
"name": "
|
|
573
|
-
"
|
|
574
|
-
"
|
|
575
|
-
"
|
|
576
|
-
{
|
|
577
|
-
"name": "render",
|
|
578
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState>",
|
|
579
|
-
"required": false,
|
|
580
|
-
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
581
|
-
}
|
|
582
|
-
]
|
|
625
|
+
"name": "value",
|
|
626
|
+
"type": "string[]",
|
|
627
|
+
"required": false,
|
|
628
|
+
"description": "The chosen values, when controlled."
|
|
583
629
|
},
|
|
584
630
|
{
|
|
585
|
-
"name": "
|
|
631
|
+
"name": "defaultValue",
|
|
632
|
+
"type": "string[]",
|
|
633
|
+
"required": false,
|
|
634
|
+
"description": "The chosen values to start with, when not controlled."
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
"name": "onValueChange",
|
|
638
|
+
"type": "((value: string[]) => void)",
|
|
639
|
+
"required": false,
|
|
640
|
+
"description": "Called with the new list of chosen values."
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
"name": "selectAll",
|
|
644
|
+
"type": "boolean",
|
|
645
|
+
"required": false,
|
|
646
|
+
"description": "Adds a \"Select all\" box that is mixed while only some are chosen."
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"name": "selectAllLabel",
|
|
650
|
+
"type": "string",
|
|
651
|
+
"required": false,
|
|
652
|
+
"default": "Select all",
|
|
653
|
+
"description": "The label of the select-all box. Defaults to \"Select all\"."
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
"name": "countLabel",
|
|
657
|
+
"type": "((chosen: string, total: string) => string)",
|
|
658
|
+
"required": false,
|
|
659
|
+
"default": "(c, t) => `${c} of ${t}`",
|
|
660
|
+
"description": "Writes the count in the heading from the chosen and total counts, already formatted. Defaults to \"4 of 6\"."
|
|
661
|
+
}
|
|
662
|
+
],
|
|
663
|
+
"usage": {
|
|
664
|
+
"whenToUse": "- A titled list where several options can be on and the heading should say how many (\"Sales channels 4 of 6\")\n- Add `selectAll` for a long list; it shows a mixed box while only some are on",
|
|
665
|
+
"whenNotToUse": "- One choice among several: use radio buttons or FilterTabs\n- A single yes or no: use Checkbox\n- Styling: CheckboxList takes no `className` and no `style`",
|
|
666
|
+
"example": "<CheckboxList title=\"Sales channels\" items={channels} value={on} onValueChange={setOn} selectAll />"
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"name": "Collapsible",
|
|
671
|
+
"import": "import { Collapsible } from '@ratio-ui/core'",
|
|
672
|
+
"description": "A section that opens and closes on its heading and, while closed, still shows its values as chips. The panel appears and disappears with no height animation.",
|
|
673
|
+
"props": [
|
|
674
|
+
{
|
|
675
|
+
"name": "title",
|
|
676
|
+
"type": "string",
|
|
677
|
+
"required": true,
|
|
678
|
+
"description": "The section heading, shown on the trigger."
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
"name": "summary",
|
|
682
|
+
"type": "readonly SummaryChip[]",
|
|
683
|
+
"required": false,
|
|
684
|
+
"description": "The values to show as chips while the section is closed."
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
"name": "open",
|
|
688
|
+
"type": "boolean",
|
|
689
|
+
"required": false,
|
|
690
|
+
"description": "Whether the section is open, when controlled."
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
"name": "defaultOpen",
|
|
694
|
+
"type": "boolean",
|
|
695
|
+
"required": false,
|
|
696
|
+
"default": "false",
|
|
697
|
+
"description": "Whether the section starts open, when uncontrolled. Defaults to closed."
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
"name": "onOpenChange",
|
|
701
|
+
"type": "((open: boolean) => void)",
|
|
702
|
+
"required": false,
|
|
703
|
+
"description": "Called when the section opens or closes."
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
"name": "disabled",
|
|
707
|
+
"type": "boolean",
|
|
708
|
+
"required": false,
|
|
709
|
+
"description": "Stops the section from opening or closing."
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "children",
|
|
713
|
+
"type": "ReactNode",
|
|
714
|
+
"required": true,
|
|
715
|
+
"description": "The section's content, shown when open."
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
"name": "ref",
|
|
719
|
+
"type": "Ref<HTMLDivElement>",
|
|
720
|
+
"required": false,
|
|
721
|
+
"description": "Receives the rendered root."
|
|
722
|
+
}
|
|
723
|
+
],
|
|
724
|
+
"usage": {
|
|
725
|
+
"whenToUse": "- A form section that is rarely edited and can stay closed, such as the pricing details under the price\n- A closed section that must still show its values: pass `summary` and the chips show while it is closed",
|
|
726
|
+
"whenNotToUse": "- Content the person must see to finish the task: leave it open\n- Switching between peer views: use Tabs",
|
|
727
|
+
"example": "```tsx\n<Collapsible title=\"More pricing\" summary={[{ label: 'Cost price', value: '₹450.00' }, { label: 'HSN code', value: '6109' }]}>\n ...fields...\n</Collapsible>\n```\n\nThe panel appears and disappears at once; the library has no height animation."
|
|
728
|
+
}
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
"name": "Combobox",
|
|
732
|
+
"import": "import { Combobox } from '@ratio-ui/core'",
|
|
733
|
+
"description": "A field to choose one option from a list, with a search: type to narrow the list, pick with the mouse or Enter. The field looks like an Input and the list like a Popover panel. For several choices shown as chips, use TagInput. Mark it invalid with aria-invalid; give the list an empty text with emptyText. Inside a Field, the label, hint, error and required mark reach the input.",
|
|
734
|
+
"props": [
|
|
735
|
+
{
|
|
736
|
+
"name": "items",
|
|
737
|
+
"type": "readonly ComboboxItem[]",
|
|
738
|
+
"required": true,
|
|
739
|
+
"description": "The options. Strings or { value, label } objects."
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
"name": "value",
|
|
743
|
+
"type": "string | null",
|
|
744
|
+
"required": false,
|
|
745
|
+
"description": "The chosen value for a controlled combobox, or null for none."
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
"name": "defaultValue",
|
|
749
|
+
"type": "string | null",
|
|
750
|
+
"required": false,
|
|
751
|
+
"description": "The value to start with when the combobox keeps its own state."
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
"name": "onValueChange",
|
|
755
|
+
"type": "((value: string | null, eventDetails: ChangeEventDetails) => void)",
|
|
756
|
+
"required": false,
|
|
757
|
+
"description": "Called with the new value, or null when the choice is cleared."
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
"name": "placeholder",
|
|
761
|
+
"type": "string",
|
|
762
|
+
"required": false,
|
|
763
|
+
"description": "The text shown while nothing is chosen."
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "emptyText",
|
|
767
|
+
"type": "string",
|
|
768
|
+
"required": false,
|
|
769
|
+
"default": "No results found",
|
|
770
|
+
"description": "The text shown when the search matches no option. Defaults to \"No results found\"."
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
"name": "aria-invalid",
|
|
774
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
775
|
+
"required": false,
|
|
776
|
+
"description": "Marks the field invalid and draws the error ring, as on every form control. Field sets it when it shows an error."
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"name": "invalid",
|
|
780
|
+
"type": "boolean",
|
|
781
|
+
"required": false,
|
|
782
|
+
"default": "false",
|
|
783
|
+
"description": "The same as aria-invalid, kept as its alias."
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"name": "clearable",
|
|
787
|
+
"type": "boolean",
|
|
788
|
+
"required": false,
|
|
789
|
+
"default": "true",
|
|
790
|
+
"description": "Shows a button that clears the choice while one is made. Defaults to true."
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
"name": "disabled",
|
|
794
|
+
"type": "boolean",
|
|
795
|
+
"required": false,
|
|
796
|
+
"default": "false",
|
|
797
|
+
"description": "Stops people from changing the choice."
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
"name": "name",
|
|
801
|
+
"type": "string",
|
|
802
|
+
"required": false,
|
|
803
|
+
"description": "The name of the field in a form."
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"name": "aria-label",
|
|
807
|
+
"type": "string",
|
|
808
|
+
"required": false,
|
|
809
|
+
"description": "The accessible name when no label is wired to the field."
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
"name": "aria-labelledby",
|
|
813
|
+
"type": "string",
|
|
814
|
+
"required": false,
|
|
815
|
+
"description": "The ids of the elements that name the field. Field sets it to its label."
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"name": "aria-describedby",
|
|
819
|
+
"type": "string",
|
|
820
|
+
"required": false,
|
|
821
|
+
"description": "The ids of the elements that describe the field, such as its hint or error. Field sets it."
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"name": "aria-required",
|
|
825
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
826
|
+
"required": false,
|
|
827
|
+
"description": "Tells assistive technology that the field must be filled. Field sets it for a required field."
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"name": "id",
|
|
831
|
+
"type": "string",
|
|
832
|
+
"required": false,
|
|
833
|
+
"description": "The id of the input, for a label's htmlFor."
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
"name": "ref",
|
|
837
|
+
"type": "Ref<HTMLInputElement>",
|
|
838
|
+
"required": false,
|
|
839
|
+
"description": "Receives the input element."
|
|
840
|
+
}
|
|
841
|
+
],
|
|
842
|
+
"usage": {
|
|
843
|
+
"whenToUse": "- Choosing one option from a long list that people search, such as a vendor or a product type\n- A field where the list may be empty or the search may match nothing",
|
|
844
|
+
"whenNotToUse": "- A short list of a few options: use a radio group or tabs\n- Several choices shown as chips: use TagInput\n- A list of actions: use DropdownMenu",
|
|
845
|
+
"example": "<Combobox aria-label=\"Vendor\" items={['Acme', 'Northwind']} placeholder=\"Choose a vendor\" onValueChange={setVendor} />"
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
"name": "DataTable",
|
|
850
|
+
"import": "import { DataTable } from '@ratio-ui/core'",
|
|
851
|
+
"description": "A data table on Table with TanStack Table v9: a selection column, server-side sorting and paging, alignment, one-line truncation, row links, and empty and loading slots. The parent owns the state (sort, page, selection) and passes it in. On phones it keeps the columns marked essential and hides the rest.",
|
|
852
|
+
"props": [
|
|
853
|
+
{
|
|
854
|
+
"name": "columns",
|
|
855
|
+
"type": "DataTableColumn<T>[]",
|
|
856
|
+
"required": true,
|
|
857
|
+
"description": "The columns, in order."
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"name": "data",
|
|
861
|
+
"type": "T[]",
|
|
862
|
+
"required": true,
|
|
863
|
+
"description": "The rows of the page on show, already sorted by the parent."
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"name": "getRowId",
|
|
867
|
+
"type": "(row: T) => string",
|
|
868
|
+
"required": true,
|
|
869
|
+
"description": "A stable id for a row."
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"name": "selectedIds",
|
|
873
|
+
"type": "string[]",
|
|
874
|
+
"required": false,
|
|
875
|
+
"description": "Ids of the selected rows. Pass it with `onSelectedIdsChange` to show a checkbox column."
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"name": "onSelectedIdsChange",
|
|
879
|
+
"type": "((ids: string[]) => void)",
|
|
880
|
+
"required": false,
|
|
881
|
+
"description": "Called with the ids that are selected after a change."
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
"name": "getRowLabel",
|
|
885
|
+
"type": "((row: T) => string)",
|
|
886
|
+
"required": false,
|
|
887
|
+
"description": "The label of one row's checkbox: \"RYZE - 2mg\", which the table prefixes with \"Select \". Defaults to \"Select row N\"."
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"name": "sort",
|
|
891
|
+
"type": "DataTableSort | null",
|
|
892
|
+
"required": false,
|
|
893
|
+
"default": "null",
|
|
894
|
+
"description": "The sort the parent applied, or null for none."
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"name": "onSortChange",
|
|
898
|
+
"type": "((sort: DataTableSort | null) => void)",
|
|
899
|
+
"required": false,
|
|
900
|
+
"description": "Called with the next sort, or null to clear it. The parent sorts and passes new data."
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
"name": "page",
|
|
904
|
+
"type": "number",
|
|
905
|
+
"required": false,
|
|
906
|
+
"description": "The page on show, counting from 1. Pass with `pageSize`, `total` and `onPageChange` to show the footer."
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
"name": "pageSize",
|
|
910
|
+
"type": "number",
|
|
911
|
+
"required": false,
|
|
912
|
+
"description": "How many results one page holds."
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
"name": "total",
|
|
916
|
+
"type": "number",
|
|
917
|
+
"required": false,
|
|
918
|
+
"description": "How many results there are in all, across every page."
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
"name": "onPageChange",
|
|
922
|
+
"type": "((page: number) => void)",
|
|
923
|
+
"required": false,
|
|
924
|
+
"description": "Called with the page to show."
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
"name": "rowHref",
|
|
928
|
+
"type": "((row: T) => string)",
|
|
929
|
+
"required": false,
|
|
930
|
+
"description": "Where a row leads. The first data cell of the row becomes a link to it. On a router, LinkProvider draws it with the app's own link."
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
"name": "empty",
|
|
934
|
+
"type": "ReactNode",
|
|
935
|
+
"required": false,
|
|
936
|
+
"description": "Shown in place of the rows when there are none and the table is not loading. Usually an EmptyState."
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"name": "loading",
|
|
940
|
+
"type": "ReactNode",
|
|
941
|
+
"required": false,
|
|
942
|
+
"description": "Shown in place of the whole table while loading, usually a TableLoader. A falsy value shows the table."
|
|
943
|
+
}
|
|
944
|
+
],
|
|
945
|
+
"usage": {
|
|
946
|
+
"whenToUse": "- A list of records with selection, server-side sorting and paging: products, variants, inventory\n- A first load: pass a TableLoader as `loading` and it replaces the table\n- Rows that link to a detail page, with an empty and a loading state\n- Phones: mark the columns a list needs as `essential` and the rest are hidden",
|
|
947
|
+
"whenNotToUse": "- Static content composed by hand: use Table\n- Client-side sorting or paging: the parent owns the sort and the page, and passes already sorted data\n- Styling: it takes no `className` and no `style`",
|
|
948
|
+
"example": "<DataTable\n aria-label=\"Products\"\n columns={[\n { id: 'name', header: 'Product', cell: (p) => p.name, essential: true, sortable: true, truncate: true },\n { id: 'stock', header: 'Stock', cell: (p) => p.stock, numeric: true },\n ]}\n data={products}\n getRowId={(p) => p.id}\n rowHref={(p) => `/products/${p.id}`}\n sort={sort}\n onSortChange={setSort}\n page={page}\n pageSize={20}\n total={84}\n onPageChange={setPage}\n empty=\"No products match this filter\"\n/>"
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
"name": "DatePicker",
|
|
953
|
+
"import": "import { DatePicker } from '@ratio-ui/core'",
|
|
954
|
+
"description": "A field that shows a day as DD/MM/YYYY, reads a typed date through the format module and opens a calendar in a popover from the button at its end. Text that is not a date reports null (as soon as it is typed over a day, and when the field loses focus) and is marked invalid, aria-invalid, when the field loses focus; the app shows Field's error from the null. Under a name, a form submits the day as YYYY-MM-DD (empty when there is none), never the text on screen.",
|
|
955
|
+
"props": [
|
|
956
|
+
{
|
|
957
|
+
"name": "value",
|
|
958
|
+
"type": "Date | null",
|
|
959
|
+
"required": false,
|
|
960
|
+
"description": "The day, or null for an empty field. Pass it to control the field."
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
"name": "defaultValue",
|
|
964
|
+
"type": "Date | null",
|
|
965
|
+
"required": false,
|
|
966
|
+
"default": "null",
|
|
967
|
+
"description": "The starting day when the field is not controlled. Defaults to empty."
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
"name": "onValueChange",
|
|
971
|
+
"type": "((value: Date | null) => void)",
|
|
972
|
+
"required": false,
|
|
973
|
+
"description": "Called with the day when a typed date is complete or a day is picked, and with null when the text is cleared or is not a date."
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
"name": "disabledDays",
|
|
977
|
+
"type": "Matcher | Matcher[]",
|
|
978
|
+
"required": false,
|
|
979
|
+
"description": "The days that cannot be picked in the calendar, for example { before: new Date() }."
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
"name": "startMonth",
|
|
983
|
+
"type": "Date",
|
|
984
|
+
"required": false,
|
|
985
|
+
"description": "The first month the calendar can show."
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
"name": "endMonth",
|
|
989
|
+
"type": "Date",
|
|
990
|
+
"required": false,
|
|
991
|
+
"description": "The last month the calendar can show."
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
"name": "size",
|
|
995
|
+
"type": "32 | 36",
|
|
996
|
+
"required": false,
|
|
997
|
+
"default": "36",
|
|
998
|
+
"description": "The height in px: 36 for forms, 32 for fields inside a table. Defaults to 36."
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"name": "ref",
|
|
1002
|
+
"type": "Ref<HTMLInputElement>",
|
|
1003
|
+
"required": false,
|
|
1004
|
+
"description": "Receives the input element."
|
|
1005
|
+
}
|
|
1006
|
+
],
|
|
1007
|
+
"usage": {
|
|
1008
|
+
"whenToUse": "- One day a person types or picks, such as a \"Best before\" custom field: `value` and `onValueChange` take a `Date` (or null when empty)\n- A date inside a table: `size` 32\n- Limiting the days: `disabledDays` (for example `{ before: new Date() }`), `startMonth` and `endMonth`, which limit the calendar (a typed date is not checked against them)",
|
|
1009
|
+
"whenNotToUse": "- A period of days, such as an analytics range: use DateRangePicker\n- A calendar shown on the page, not behind a field: use Calendar\n- Showing a date as text: write it with the format module (`formatDate`)\n- Custom classes or inline styles: DatePicker takes neither `className` nor `style`",
|
|
1010
|
+
"example": "```tsx\nconst [bestBefore, setBestBefore] = useState<Date | null>(null)\n\n<DatePicker aria-label=\"Best before\" value={bestBefore} onValueChange={setBestBefore} />\n<DatePicker aria-label=\"Expiry\" size={32} aria-invalid aria-describedby=\"expiry-error\" />\n```\n\nThe field shows DD/MM/YYYY and reads typed dates through the format module (\"3/1/2026\" is 3 January). Text that is not a date is never reported as a day: `onValueChange` gets `null` (as soon as a held day is typed over, and again when the field loses focus), and the field turns invalid (`aria-invalid`) when it loses focus."
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
"name": "DateRangePicker",
|
|
1015
|
+
"import": "import { DateRangePicker } from '@ratio-ui/core'",
|
|
1016
|
+
"description": "A field that shows a range as two DD/MM/YYYY days, reads a typed range through the format module and opens a calendar in a popover from the button at its end, for analytics periods. Pick the first day, then the last. Text that is not a range in order reports null (as soon as it is typed over a range, and when the field loses focus) and is marked invalid, aria-invalid, when the field loses focus. Under a name, a form submits two fields, `name.from` and `name.to`, each as YYYY-MM-DD (empty when there is no range), never the text on screen.",
|
|
1017
|
+
"props": [
|
|
1018
|
+
{
|
|
1019
|
+
"name": "value",
|
|
1020
|
+
"type": "DateRangeValue | null",
|
|
1021
|
+
"required": false,
|
|
1022
|
+
"description": "The range, or null for an empty field. Pass it to control the field."
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
"name": "defaultValue",
|
|
1026
|
+
"type": "DateRangeValue | null",
|
|
1027
|
+
"required": false,
|
|
1028
|
+
"default": "null",
|
|
1029
|
+
"description": "The starting range when the field is not controlled. Defaults to empty."
|
|
1030
|
+
},
|
|
1031
|
+
{
|
|
1032
|
+
"name": "onValueChange",
|
|
1033
|
+
"type": "((value: DateRangeValue | null) => void)",
|
|
1034
|
+
"required": false,
|
|
1035
|
+
"description": "Called with the range when a typed range is complete or two days are picked, and with null when the text is cleared or is not a range."
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
"name": "disabledDays",
|
|
1039
|
+
"type": "Matcher | Matcher[]",
|
|
1040
|
+
"required": false,
|
|
1041
|
+
"description": "The days that cannot be picked in the calendar, for example { after: new Date() } for an analytics period."
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
"name": "startMonth",
|
|
1045
|
+
"type": "Date",
|
|
1046
|
+
"required": false,
|
|
1047
|
+
"description": "The first month the calendar can show."
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"name": "endMonth",
|
|
1051
|
+
"type": "Date",
|
|
1052
|
+
"required": false,
|
|
1053
|
+
"description": "The last month the calendar can show."
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
"name": "size",
|
|
1057
|
+
"type": "32 | 36",
|
|
1058
|
+
"required": false,
|
|
1059
|
+
"default": "36",
|
|
1060
|
+
"description": "The height in px: 36 for forms, 32 for fields inside a table. Defaults to 36."
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"name": "ref",
|
|
1064
|
+
"type": "Ref<HTMLInputElement>",
|
|
1065
|
+
"required": false,
|
|
1066
|
+
"description": "Receives the input element."
|
|
1067
|
+
}
|
|
1068
|
+
],
|
|
1069
|
+
"usage": {
|
|
1070
|
+
"whenToUse": "- A period of days a person types or picks, such as an analytics range: `value` and `onValueChange` take `{ from, to }` (or null when empty)\n- Limiting the days: `disabledDays` (for example `{ after: new Date() }` for reports), `startMonth` and `endMonth`, which limit the calendar (a typed range is not checked against them)\n- A range inside a table: `size` 32",
|
|
1071
|
+
"whenNotToUse": "- One day: use DatePicker\n- A calendar shown on the page, not behind a field: use Calendar\n- Showing a range as text: write both days with the format module (`formatDate`)\n- Custom classes or inline styles: DateRangePicker takes neither `className` nor `style`",
|
|
1072
|
+
"example": "```tsx\nconst [period, setPeriod] = useState<DateRangeValue | null>(null)\n\n<DateRangePicker aria-label=\"Period\" value={period} onValueChange={setPeriod} disabledDays={{ after: new Date() }} />\n```\n\nThe field shows `28/10/2026 – 03/11/2026`. Pick the first day, then the last (an earlier second day swaps them). A typed range with the end before the start, or one day only, is never reported as a range: `onValueChange` gets `null` (as soon as a held range is typed over, and again on blur), and the field turns invalid (`aria-invalid`) when it loses focus. Show the error with Field as in DatePicker: `error={touched && range === null ? 'Enter a period as DD/MM/YYYY – DD/MM/YYYY' : undefined}`, `touched` set from `onBlur`.\n\nUnder a `name`, a form submits two fields, `name.from` and `name.to`, each the committed day as `YYYY-MM-DD` (empty strings when the field is empty), not the text on screen: `<DateRangePicker name=\"period\" />` posts `period.from=2026-10-28` and `period.to=2026-11-03`. A disabled field posts nothing."
|
|
1073
|
+
}
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
"name": "Definition",
|
|
1077
|
+
"import": "import { Definition } from '@ratio-ui/core'",
|
|
1078
|
+
"description": "A term that explains itself. It is a span with the button role and a dotted underline, so it takes the font of the text around it, so keyboard users reach it with Tab and open it with Enter or Space, touch users open it with a tap, and mouse users with hover or click. It does not use the browser's own title tooltip, which keyboard and touch users cannot open. Escape closes it.",
|
|
1079
|
+
"props": [
|
|
1080
|
+
{
|
|
1081
|
+
"name": "children",
|
|
1082
|
+
"type": "ReactNode",
|
|
1083
|
+
"required": true,
|
|
1084
|
+
"description": "The term, shown in the text with a dotted underline."
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
"name": "definition",
|
|
1088
|
+
"type": "ReactNode",
|
|
1089
|
+
"required": true,
|
|
1090
|
+
"description": "The explanation shown when the term is opened. Keep it to a sentence."
|
|
1091
|
+
}
|
|
1092
|
+
],
|
|
1093
|
+
"usage": {
|
|
1094
|
+
"whenToUse": "- A term in a heading or label that needs a one-sentence explanation, such as a metric title\n- Where keyboard and touch users must be able to read the explanation: it opens with Tab and Enter, with a tap, and on hover",
|
|
1095
|
+
"whenNotToUse": "- An icon-only hint: use Tooltip\n- Long or interactive content: use Popover\n- Text that the task cannot be finished without: show it on the screen",
|
|
1096
|
+
"example": "<Definition definition=\"Gross merchandise value, before returns\">GMV</Definition>"
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
"name": "Dialog",
|
|
1101
|
+
"import": "import { Dialog } from '@ratio-ui/core'",
|
|
1102
|
+
"description": "The root of a dialog. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it, or `defaultOpen` to leave it uncontrolled. The page behind is inert while it is open, with no scrim over it.",
|
|
1103
|
+
"props": [],
|
|
1104
|
+
"usage": {
|
|
1105
|
+
"whenToUse": "- A short task that needs the user's full attention before going back to the page, such as adding a product or defining a field\n- A confirm step before a destructive action\n- Work that fits in 480px: the panel is fixed at that width and has no scrim",
|
|
1106
|
+
"whenNotToUse": "- A message after an action: use toast()\n- A long form or a multi-step flow: give it a page\n- Help text on a control: use a Tooltip or Popover",
|
|
1107
|
+
"example": "<Dialog>\n <DialogTrigger>Add product</DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Add product</DialogTitle>\n <DialogDescription>Fill in the basics</DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose>Cancel</DialogClose>\n </DialogFooter>\n </DialogContent>\n</Dialog>"
|
|
1108
|
+
},
|
|
1109
|
+
"parts": [
|
|
1110
|
+
{
|
|
1111
|
+
"name": "DialogClose",
|
|
1112
|
+
"import": "import { DialogClose } from '@ratio-ui/core'",
|
|
1113
|
+
"description": "A button that closes the dialog, such as Cancel in the footer.",
|
|
1114
|
+
"props": [
|
|
1115
|
+
{
|
|
1116
|
+
"name": "render",
|
|
1117
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogCloseState>",
|
|
1118
|
+
"required": false,
|
|
1119
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1120
|
+
}
|
|
1121
|
+
]
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
"name": "DialogContent",
|
|
1125
|
+
"import": "import { DialogContent } from '@ratio-ui/core'",
|
|
1126
|
+
"description": "The panel: 480px wide, white, drawn with the ring outline and no shadow, with no scrim behind it. Put DialogHeader, the form and DialogFooter inside.",
|
|
1127
|
+
"props": [
|
|
1128
|
+
{
|
|
1129
|
+
"name": "showCloseButton",
|
|
1130
|
+
"type": "boolean",
|
|
1131
|
+
"required": false,
|
|
1132
|
+
"default": "true",
|
|
1133
|
+
"description": "Whether the corner close button shows. Defaults to true."
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
"name": "closeLabel",
|
|
1137
|
+
"type": "string",
|
|
1138
|
+
"required": false,
|
|
1139
|
+
"default": "Close",
|
|
1140
|
+
"description": "The accessible name of the corner close button. Defaults to Close."
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
"name": "render",
|
|
1144
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPopupState>",
|
|
1145
|
+
"required": false,
|
|
1146
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1147
|
+
}
|
|
1148
|
+
]
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
"name": "DialogDescription",
|
|
1152
|
+
"import": "import { DialogDescription } from '@ratio-ui/core'",
|
|
1153
|
+
"description": "One line that says what the dialog is for, in subdued body text.",
|
|
1154
|
+
"props": [
|
|
1155
|
+
{
|
|
1156
|
+
"name": "render",
|
|
1157
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogDescriptionState>",
|
|
1158
|
+
"required": false,
|
|
1159
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1160
|
+
}
|
|
1161
|
+
]
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
"name": "DialogFooter",
|
|
1165
|
+
"import": "import { DialogFooter } from '@ratio-ui/core'",
|
|
1166
|
+
"description": "The row of actions at the bottom, aligned to the end.",
|
|
1167
|
+
"props": []
|
|
1168
|
+
},
|
|
1169
|
+
{
|
|
1170
|
+
"name": "DialogHeader",
|
|
1171
|
+
"import": "import { DialogHeader } from '@ratio-ui/core'",
|
|
1172
|
+
"description": "The title and description, stacked.",
|
|
1173
|
+
"props": []
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
"name": "DialogTitle",
|
|
1177
|
+
"import": "import { DialogTitle } from '@ratio-ui/core'",
|
|
1178
|
+
"description": "The dialog's name, in the b4 style. It names the dialog for assistive technology.",
|
|
1179
|
+
"props": [
|
|
1180
|
+
{
|
|
1181
|
+
"name": "render",
|
|
1182
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTitleState>",
|
|
1183
|
+
"required": false,
|
|
1184
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1185
|
+
}
|
|
1186
|
+
]
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
"name": "DialogTrigger",
|
|
1190
|
+
"import": "import { DialogTrigger } from '@ratio-ui/core'",
|
|
1191
|
+
"description": "The button that opens the dialog.",
|
|
1192
|
+
"props": [
|
|
1193
|
+
{
|
|
1194
|
+
"name": "render",
|
|
1195
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTriggerState>",
|
|
1196
|
+
"required": false,
|
|
1197
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1198
|
+
}
|
|
1199
|
+
]
|
|
1200
|
+
}
|
|
1201
|
+
]
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
"name": "Drawer",
|
|
1205
|
+
"import": "import { Drawer } from '@ratio-ui/core'",
|
|
1206
|
+
"description": "The root of a drawer: a panel people swipe away on a phone. It holds the open state and renders nothing itself. `swipeDirection` picks the edge it leaves by (down, the default, makes a bottom drawer). Pass `open` and `onOpenChange` to control it, or `defaultOpen`. The page behind is inert while it is open, with no scrim over it.",
|
|
1207
|
+
"props": [
|
|
1208
|
+
{
|
|
1209
|
+
"name": "showSwipeHandle",
|
|
1210
|
+
"type": "boolean",
|
|
1211
|
+
"required": false,
|
|
1212
|
+
"default": "false",
|
|
1213
|
+
"description": "Whether a short bar shows on the edge the drawer is swiped from, as a hint on phones. Defaults to false."
|
|
1214
|
+
}
|
|
1215
|
+
],
|
|
1216
|
+
"usage": {
|
|
1217
|
+
"whenToUse": "- A panel on a phone that people swipe away, such as filters or a short form under the list\n- A bottom drawer by default; a side drawer (swipeDirection left or right) for a phone menu\n- Show the swipe handle on phones as a hint; the corner close button stays for people who do not swipe",
|
|
1218
|
+
"whenNotToUse": "- A large surface on a wide screen, such as Settings: use a Sheet\n- A short task or a confirm step: use a Dialog\n- Help text on a control: use a Tooltip or Popover",
|
|
1219
|
+
"example": "<Drawer showSwipeHandle>\n <DrawerTrigger>Filters</DrawerTrigger>\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Filters</DrawerTitle>\n <DrawerDescription>Narrow the product list</DrawerDescription>\n </DrawerHeader>\n <DrawerFooter>\n <DrawerClose>Done</DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n</Drawer>"
|
|
1220
|
+
},
|
|
1221
|
+
"parts": [
|
|
1222
|
+
{
|
|
1223
|
+
"name": "DrawerClose",
|
|
1224
|
+
"import": "import { DrawerClose } from '@ratio-ui/core'",
|
|
1225
|
+
"description": "A button that closes the drawer, such as Done in the footer.",
|
|
1226
|
+
"props": [
|
|
1227
|
+
{
|
|
1228
|
+
"name": "render",
|
|
1229
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DrawerCloseState>",
|
|
1230
|
+
"required": false,
|
|
1231
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1232
|
+
}
|
|
1233
|
+
]
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
"name": "DrawerContent",
|
|
1237
|
+
"import": "import { DrawerContent } from '@ratio-ui/core'",
|
|
1238
|
+
"description": "The panel, white with a hairline and 24px corners on its inner edge. A bottom drawer spans the screen and sizes to its content; a side drawer is full height and three quarters of a phone screen, 384px from the small breakpoint up. It follows the finger while it is swiped and otherwise does not move: no slide in or out, no scrim, blur or shadow. Put DrawerHeader, the content and DrawerFooter inside.",
|
|
1239
|
+
"props": [
|
|
1240
|
+
{
|
|
1241
|
+
"name": "showCloseButton",
|
|
1242
|
+
"type": "boolean",
|
|
1243
|
+
"required": false,
|
|
1244
|
+
"default": "true",
|
|
1245
|
+
"description": "Whether the corner close button shows. It is the way to close without swiping. Defaults to true."
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
"name": "closeLabel",
|
|
1249
|
+
"type": "string",
|
|
1250
|
+
"required": false,
|
|
1251
|
+
"default": "Close",
|
|
1252
|
+
"description": "The accessible name of the corner close button. Defaults to Close."
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
"name": "render",
|
|
1256
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DrawerPopupState>",
|
|
1257
|
+
"required": false,
|
|
1258
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1259
|
+
}
|
|
1260
|
+
]
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
"name": "DrawerDescription",
|
|
1264
|
+
"import": "import { DrawerDescription } from '@ratio-ui/core'",
|
|
1265
|
+
"description": "One line that says what the drawer is for, in subdued body text.",
|
|
1266
|
+
"props": [
|
|
1267
|
+
{
|
|
1268
|
+
"name": "render",
|
|
1269
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DrawerDescriptionState>",
|
|
1270
|
+
"required": false,
|
|
1271
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1272
|
+
}
|
|
1273
|
+
]
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
"name": "DrawerFooter",
|
|
1277
|
+
"import": "import { DrawerFooter } from '@ratio-ui/core'",
|
|
1278
|
+
"description": "The actions at the bottom of the drawer, stacked full width for a thumb.",
|
|
1279
|
+
"props": []
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
"name": "DrawerHeader",
|
|
1283
|
+
"import": "import { DrawerHeader } from '@ratio-ui/core'",
|
|
1284
|
+
"description": "The title and description, stacked, with room on the right for the close button.",
|
|
1285
|
+
"props": []
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
"name": "DrawerTitle",
|
|
1289
|
+
"import": "import { DrawerTitle } from '@ratio-ui/core'",
|
|
1290
|
+
"description": "The drawer's name, in the b4 style. It names the drawer for assistive technology.",
|
|
1291
|
+
"props": [
|
|
1292
|
+
{
|
|
1293
|
+
"name": "render",
|
|
1294
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DrawerTitleState>",
|
|
1295
|
+
"required": false,
|
|
1296
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1297
|
+
}
|
|
1298
|
+
]
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
"name": "DrawerTrigger",
|
|
1302
|
+
"import": "import { DrawerTrigger } from '@ratio-ui/core'",
|
|
1303
|
+
"description": "The button that opens the drawer.",
|
|
1304
|
+
"props": [
|
|
1305
|
+
{
|
|
1306
|
+
"name": "render",
|
|
1307
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DrawerTriggerState>",
|
|
1308
|
+
"required": false,
|
|
1309
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1310
|
+
}
|
|
1311
|
+
]
|
|
1312
|
+
}
|
|
1313
|
+
]
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
"name": "DropdownMenu",
|
|
1317
|
+
"import": "import { DropdownMenu } from '@ratio-ui/core'",
|
|
1318
|
+
"description": "The root of a menu of actions that opens from a trigger. Compose it with DropdownMenuTrigger and DropdownMenuContent.",
|
|
1319
|
+
"props": [],
|
|
1320
|
+
"usage": {
|
|
1321
|
+
"whenToUse": "- A short list of actions behind one control: \"More actions\", a store menu, a \"…\" button\n- Actions that belong in groups, with a label per group, a hairline between groups, or a submenu\n- Items that show a key hint, a check (on or off) or one choice out of a few",
|
|
1322
|
+
"whenNotToUse": "- Choosing a value for a form field: use a select\n- Content that is not a list of actions, such as notifications or a form: use Popover\n- A destructive action without a confirm step: the destructive item only colours it\n- Styling: the parts take no `className` and no `style`, and the menu has no shadow",
|
|
1323
|
+
"example": "<DropdownMenu>\n <DropdownMenuTrigger>More actions</DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuGroup>\n <DropdownMenuLabel>Product</DropdownMenuLabel>\n <DropdownMenuItem>\n Edit\n <DropdownMenuShortcut>⌘E</DropdownMenuShortcut>\n </DropdownMenuItem>\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\">Delete</DropdownMenuItem>\n </DropdownMenuContent>\n</DropdownMenu>"
|
|
1324
|
+
},
|
|
1325
|
+
"parts": [
|
|
1326
|
+
{
|
|
1327
|
+
"name": "DropdownMenuCheckboxItem",
|
|
1328
|
+
"import": "import { DropdownMenuCheckboxItem } from '@ratio-ui/core'",
|
|
1329
|
+
"description": "An item that toggles an option. A check shows at its start while it is on and keeps the menu open, so several options can be changed in one visit.",
|
|
1330
|
+
"props": [
|
|
1331
|
+
{
|
|
1332
|
+
"name": "render",
|
|
1333
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuCheckboxItemState>",
|
|
1334
|
+
"required": false,
|
|
1335
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1336
|
+
}
|
|
1337
|
+
]
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
"name": "DropdownMenuContent",
|
|
1341
|
+
"import": "import { DropdownMenuContent } from '@ratio-ui/core'",
|
|
1342
|
+
"description": "The menu panel: a white popup with a hairline ring, 8px corners and no shadow. It opens in a portal.",
|
|
1343
|
+
"props": [
|
|
1344
|
+
{
|
|
1345
|
+
"name": "side",
|
|
1346
|
+
"type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
|
|
1347
|
+
"required": false,
|
|
1348
|
+
"default": "bottom",
|
|
1349
|
+
"description": "Which side of the trigger the menu opens on. Defaults to bottom."
|
|
1350
|
+
},
|
|
1351
|
+
{
|
|
1352
|
+
"name": "align",
|
|
1353
|
+
"type": "\"center\" | \"end\" | \"start\"",
|
|
1354
|
+
"required": false,
|
|
1355
|
+
"default": "start",
|
|
1356
|
+
"description": "How the menu lines up with the trigger along that side. Defaults to start."
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
"name": "sideOffset",
|
|
1360
|
+
"type": "number",
|
|
1361
|
+
"required": false,
|
|
1362
|
+
"default": "4",
|
|
1363
|
+
"description": "The gap between the trigger and the menu in px. Defaults to 4."
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
"name": "alignOffset",
|
|
1367
|
+
"type": "number",
|
|
1368
|
+
"required": false,
|
|
1369
|
+
"default": "0",
|
|
1370
|
+
"description": "A shift along the side in px. Defaults to 0."
|
|
1371
|
+
},
|
|
1372
|
+
{
|
|
1373
|
+
"name": "render",
|
|
1374
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPopupState>",
|
|
1375
|
+
"required": false,
|
|
1376
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1377
|
+
}
|
|
1378
|
+
]
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
"name": "DropdownMenuGroup",
|
|
1382
|
+
"import": "import { DropdownMenuGroup } from '@ratio-ui/core'",
|
|
1383
|
+
"description": "Groups items under one DropdownMenuLabel, so assistive technology announces the label with the group.",
|
|
1384
|
+
"props": [
|
|
1385
|
+
{
|
|
1386
|
+
"name": "render",
|
|
1387
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupState>",
|
|
1388
|
+
"required": false,
|
|
1389
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1390
|
+
}
|
|
1391
|
+
]
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
"name": "DropdownMenuItem",
|
|
1395
|
+
"import": "import { DropdownMenuItem } from '@ratio-ui/core'",
|
|
1396
|
+
"description": "One action in the menu. It runs onClick and closes the menu; disabled is drawn at half opacity and cannot be chosen.",
|
|
1397
|
+
"props": [
|
|
1398
|
+
{
|
|
1399
|
+
"name": "variant",
|
|
1400
|
+
"type": "\"default\" | \"destructive\"",
|
|
1401
|
+
"required": false,
|
|
1402
|
+
"default": "default",
|
|
1403
|
+
"description": "What the item means. destructive is drawn in the destructive token; a delete action also needs a confirm step. Defaults to default."
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
"name": "render",
|
|
1407
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuItemState>",
|
|
1408
|
+
"required": false,
|
|
1409
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1410
|
+
}
|
|
1411
|
+
]
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
"name": "DropdownMenuLabel",
|
|
1415
|
+
"import": "import { DropdownMenuLabel } from '@ratio-ui/core'",
|
|
1416
|
+
"description": "The caption of a group, in the design system's label style: 12px, uppercase, subdued. Place it inside DropdownMenuGroup.",
|
|
1417
|
+
"props": [
|
|
1418
|
+
{
|
|
1419
|
+
"name": "render",
|
|
1420
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuGroupLabelState>",
|
|
1421
|
+
"required": false,
|
|
1422
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1423
|
+
}
|
|
1424
|
+
]
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
"name": "DropdownMenuRadioGroup",
|
|
1428
|
+
"import": "import { DropdownMenuRadioGroup } from '@ratio-ui/core'",
|
|
1429
|
+
"description": "Holds radio items and the one chosen value.",
|
|
1430
|
+
"props": [
|
|
1431
|
+
{
|
|
1432
|
+
"name": "render",
|
|
1433
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioGroupState>",
|
|
1434
|
+
"required": false,
|
|
1435
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1436
|
+
}
|
|
1437
|
+
]
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
"name": "DropdownMenuRadioItem",
|
|
1441
|
+
"import": "import { DropdownMenuRadioItem } from '@ratio-ui/core'",
|
|
1442
|
+
"description": "One choice of a DropdownMenuRadioGroup. A dot shows at its start while it is the chosen value.",
|
|
1443
|
+
"props": [
|
|
1444
|
+
{
|
|
1445
|
+
"name": "render",
|
|
1446
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuRadioItemState>",
|
|
1447
|
+
"required": false,
|
|
1448
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1449
|
+
}
|
|
1450
|
+
]
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
"name": "DropdownMenuSeparator",
|
|
1454
|
+
"import": "import { DropdownMenuSeparator } from '@ratio-ui/core'",
|
|
1455
|
+
"description": "A hairline between groups of items.",
|
|
1456
|
+
"props": [
|
|
1457
|
+
{
|
|
1458
|
+
"name": "render",
|
|
1459
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SeparatorState>",
|
|
1460
|
+
"required": false,
|
|
1461
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1462
|
+
}
|
|
1463
|
+
]
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
"name": "DropdownMenuShortcut",
|
|
586
1467
|
"import": "import { DropdownMenuShortcut } from '@ratio-ui/core'",
|
|
587
1468
|
"description": "A key hint pushed to the end of an item. It is a hint only: the host binds the key.",
|
|
588
1469
|
"props": [
|
|
589
1470
|
{
|
|
590
|
-
"name": "children",
|
|
591
|
-
"type": "ReactNode",
|
|
592
|
-
"required": true,
|
|
593
|
-
"description": "The key hint, such as ⌘E. It is text only and does not bind a key."
|
|
1471
|
+
"name": "children",
|
|
1472
|
+
"type": "ReactNode",
|
|
1473
|
+
"required": true,
|
|
1474
|
+
"description": "The key hint, such as ⌘E. It is text only and does not bind a key."
|
|
1475
|
+
}
|
|
1476
|
+
]
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
"name": "DropdownMenuSub",
|
|
1480
|
+
"import": "import { DropdownMenuSub } from '@ratio-ui/core'",
|
|
1481
|
+
"description": "The root of a nested menu. Hold a DropdownMenuSubTrigger and a DropdownMenuSubContent.",
|
|
1482
|
+
"props": []
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
"name": "DropdownMenuSubContent",
|
|
1486
|
+
"import": "import { DropdownMenuSubContent } from '@ratio-ui/core'",
|
|
1487
|
+
"description": "The panel of a submenu. It opens to the side of its trigger.",
|
|
1488
|
+
"props": [
|
|
1489
|
+
{
|
|
1490
|
+
"name": "side",
|
|
1491
|
+
"type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
|
|
1492
|
+
"required": false,
|
|
1493
|
+
"default": "right",
|
|
1494
|
+
"description": "Which side of the trigger the menu opens on. Defaults to bottom."
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
"name": "align",
|
|
1498
|
+
"type": "\"center\" | \"end\" | \"start\"",
|
|
1499
|
+
"required": false,
|
|
1500
|
+
"description": "How the menu lines up with the trigger along that side. Defaults to start."
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
"name": "sideOffset",
|
|
1504
|
+
"type": "number",
|
|
1505
|
+
"required": false,
|
|
1506
|
+
"default": "0",
|
|
1507
|
+
"description": "The gap between the trigger and the menu in px. Defaults to 4."
|
|
1508
|
+
},
|
|
1509
|
+
{
|
|
1510
|
+
"name": "alignOffset",
|
|
1511
|
+
"type": "number",
|
|
1512
|
+
"required": false,
|
|
1513
|
+
"default": "-6",
|
|
1514
|
+
"description": "A shift along the side in px. Defaults to 0."
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
"name": "render",
|
|
1518
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuPopupState>",
|
|
1519
|
+
"required": false,
|
|
1520
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1521
|
+
}
|
|
1522
|
+
]
|
|
1523
|
+
},
|
|
1524
|
+
{
|
|
1525
|
+
"name": "DropdownMenuSubTrigger",
|
|
1526
|
+
"import": "import { DropdownMenuSubTrigger } from '@ratio-ui/core'",
|
|
1527
|
+
"description": "The item that opens a submenu, on hover, click or ArrowRight. A chevron at its end marks it.",
|
|
1528
|
+
"props": [
|
|
1529
|
+
{
|
|
1530
|
+
"name": "render",
|
|
1531
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuSubmenuTriggerState>",
|
|
1532
|
+
"required": false,
|
|
1533
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1534
|
+
}
|
|
1535
|
+
]
|
|
1536
|
+
},
|
|
1537
|
+
{
|
|
1538
|
+
"name": "DropdownMenuTrigger",
|
|
1539
|
+
"import": "import { DropdownMenuTrigger } from '@ratio-ui/core'",
|
|
1540
|
+
"description": "The control that opens the menu. It is a button, and carries aria-expanded and aria-haspopup.",
|
|
1541
|
+
"props": [
|
|
1542
|
+
{
|
|
1543
|
+
"name": "render",
|
|
1544
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, MenuTriggerState>",
|
|
1545
|
+
"required": false,
|
|
1546
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1547
|
+
}
|
|
1548
|
+
]
|
|
1549
|
+
}
|
|
1550
|
+
]
|
|
1551
|
+
},
|
|
1552
|
+
{
|
|
1553
|
+
"name": "EmptyState",
|
|
1554
|
+
"import": "import { EmptyState } from '@ratio-ui/core'",
|
|
1555
|
+
"description": "What a list, table or panel shows when it has nothing to show: one clause and an optional action, centred in a hairline container.",
|
|
1556
|
+
"props": [
|
|
1557
|
+
{
|
|
1558
|
+
"name": "title",
|
|
1559
|
+
"type": "ReactNode",
|
|
1560
|
+
"required": true,
|
|
1561
|
+
"description": "One clause that says why nothing is shown, in sentence case with no period."
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
"name": "description",
|
|
1565
|
+
"type": "ReactNode",
|
|
1566
|
+
"required": false,
|
|
1567
|
+
"description": "An optional second clause that says what to do next."
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
"name": "action",
|
|
1571
|
+
"type": "ReactNode",
|
|
1572
|
+
"required": false,
|
|
1573
|
+
"description": "An optional action, usually one Button."
|
|
1574
|
+
}
|
|
1575
|
+
],
|
|
1576
|
+
"usage": {
|
|
1577
|
+
"whenToUse": "- A list, table or panel with nothing to show, such as a filter that matches no products\n- With one action when the user can fix it, such as clearing the filter",
|
|
1578
|
+
"whenNotToUse": "- A load that is still running: use Skeleton\n- An error: say what failed in one clause, in the error colour, not here",
|
|
1579
|
+
"example": "<EmptyState title=\"No products match this filter\" action={<Button>Clear filter</Button>} />"
|
|
1580
|
+
}
|
|
1581
|
+
},
|
|
1582
|
+
{
|
|
1583
|
+
"name": "Field",
|
|
1584
|
+
"import": "import { Field } from '@ratio-ui/core'",
|
|
1585
|
+
"description": "A form row: label, control, hint and error. It wires the label to the control by id and aria-labelledby (which also names a group such as RadioGroup), links the hint and error with aria-describedby, and sets aria-invalid when there is an error. The control keeps an id it already has.",
|
|
1586
|
+
"props": [
|
|
1587
|
+
{
|
|
1588
|
+
"name": "label",
|
|
1589
|
+
"type": "ReactNode",
|
|
1590
|
+
"required": true,
|
|
1591
|
+
"description": "The label text."
|
|
1592
|
+
},
|
|
1593
|
+
{
|
|
1594
|
+
"name": "hint",
|
|
1595
|
+
"type": "ReactNode",
|
|
1596
|
+
"required": false,
|
|
1597
|
+
"description": "Help text under the control. An error replaces it."
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
"name": "error",
|
|
1601
|
+
"type": "ReactNode",
|
|
1602
|
+
"required": false,
|
|
1603
|
+
"description": "The error message. It shows under the control beside the alert glyph and marks the control invalid."
|
|
1604
|
+
},
|
|
1605
|
+
{
|
|
1606
|
+
"name": "info",
|
|
1607
|
+
"type": "ReactNode",
|
|
1608
|
+
"required": false,
|
|
1609
|
+
"description": "An explanation of the field, opened from a small info icon beside the label by keyboard, touch or hover."
|
|
1610
|
+
},
|
|
1611
|
+
{
|
|
1612
|
+
"name": "required",
|
|
1613
|
+
"type": "boolean",
|
|
1614
|
+
"required": false,
|
|
1615
|
+
"description": "Shows a star after the label and marks the control aria-required."
|
|
1616
|
+
},
|
|
1617
|
+
{
|
|
1618
|
+
"name": "disabled",
|
|
1619
|
+
"type": "boolean",
|
|
1620
|
+
"required": false,
|
|
1621
|
+
"description": "Dims the label and disables the control."
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
"name": "children",
|
|
1625
|
+
"type": "ReactElement<Record<string, unknown>, string | JSXElementConstructor<any>> | ((props: FieldControlProps) => ReactNode)",
|
|
1626
|
+
"required": true,
|
|
1627
|
+
"description": "The control: one element, such as Input, which gets an id, aria-labelledby, aria-describedby, aria-invalid, aria-required and disabled. When the control sits inside a wrapper such as InputGroup, pass a function instead and spread the props it receives onto the input itself."
|
|
1628
|
+
}
|
|
1629
|
+
],
|
|
1630
|
+
"usage": {
|
|
1631
|
+
"whenToUse": "- Every form row: a label, one control, and optional hint, error, info tooltip and required mark\n- Wiring: Field sets the control's id, aria-labelledby, aria-describedby, aria-invalid, aria-required and disabled, so you do not",
|
|
1632
|
+
"whenNotToUse": "- A heading for a group of controls: use a fieldset with a legend\n- A label with no control beside it: use Label alone, with `htmlFor`\n- Long help that must be read to finish the task: put it on the screen as the hint",
|
|
1633
|
+
"example": "```tsx\n<Field label=\"Title\" hint=\"Shown in search results\" error={errors.title} required>\n <Input />\n</Field>\n<Field label=\"MRP\" info=\"Maximum retail price, with tax\">\n <Input inputMode=\"decimal\" />\n</Field>\n```\n\nFor an input inside an InputGroup, pass a function child and spread its props onto the input: `<Field label=\"MRP\">{(props) => <InputGroup>…<InputGroupInput {...props} /></InputGroup>}</Field>`.\n\nA Combobox or a RadioGroup goes straight inside, like an Input: the label names a radio group through `aria-labelledby`, because a label cannot point at a group.\n\nFor a Select, which renders no element of its own, spread the props onto its trigger: `<Field label=\"GST rate\">{(props) => <Select items={rates}><SelectTrigger {...props}><SelectValue /></SelectTrigger><SelectContent>…</SelectContent></Select>}</Field>`.\n\nThe error shows beside the alert glyph in the error ink (question 1) and replaces the hint. Label is the same label as a separate part."
|
|
1634
|
+
},
|
|
1635
|
+
"parts": [
|
|
1636
|
+
{
|
|
1637
|
+
"name": "Label",
|
|
1638
|
+
"import": "import { Label } from '@ratio-ui/core'",
|
|
1639
|
+
"description": "The text that names a control, in the 12px medium label type. Point htmlFor at the control's id; Field does this for you.",
|
|
1640
|
+
"props": [
|
|
1641
|
+
{
|
|
1642
|
+
"name": "ref",
|
|
1643
|
+
"type": "Ref<HTMLLabelElement>",
|
|
1644
|
+
"required": false,
|
|
1645
|
+
"description": "Receives the label element."
|
|
594
1646
|
}
|
|
595
1647
|
]
|
|
1648
|
+
}
|
|
1649
|
+
]
|
|
1650
|
+
},
|
|
1651
|
+
{
|
|
1652
|
+
"name": "FilterTabs",
|
|
1653
|
+
"import": "import { FilterTabs } from '@ratio-ui/core'",
|
|
1654
|
+
"description": "A single choice that filters a list, such as All, Active and Inactive above a table: the design system's Tab chips in a row with an 8px gap. One item is always chosen. For sections of a page use Tabs instead.",
|
|
1655
|
+
"props": [
|
|
1656
|
+
{
|
|
1657
|
+
"name": "items",
|
|
1658
|
+
"type": "FilterTabsItem[]",
|
|
1659
|
+
"required": true,
|
|
1660
|
+
"description": "The choices, in order."
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
"name": "value",
|
|
1664
|
+
"type": "string",
|
|
1665
|
+
"required": false,
|
|
1666
|
+
"description": "The chosen value when controlled."
|
|
1667
|
+
},
|
|
1668
|
+
{
|
|
1669
|
+
"name": "defaultValue",
|
|
1670
|
+
"type": "string",
|
|
1671
|
+
"required": false,
|
|
1672
|
+
"description": "The chosen value at the start when uncontrolled. Defaults to the first item."
|
|
1673
|
+
},
|
|
1674
|
+
{
|
|
1675
|
+
"name": "onValueChange",
|
|
1676
|
+
"type": "((value: string) => void)",
|
|
1677
|
+
"required": false,
|
|
1678
|
+
"description": "Called with the new value when another item is chosen. Choosing the chosen item again does nothing."
|
|
1679
|
+
},
|
|
1680
|
+
{
|
|
1681
|
+
"name": "disabled",
|
|
1682
|
+
"type": "boolean",
|
|
1683
|
+
"required": false,
|
|
1684
|
+
"description": "Disables every item. Defaults to false."
|
|
1685
|
+
}
|
|
1686
|
+
],
|
|
1687
|
+
"usage": {
|
|
1688
|
+
"whenToUse": "- A single choice that filters the list below it, such as All, Active and Inactive above the products table\n- A short set of choices, one chosen at all times, shown as the design system's chip tabs in a row",
|
|
1689
|
+
"whenNotToUse": "- Sections of a page with their own content: use Tabs\n- Choices that can be combined or cleared: use checkboxes or a menu\n- Many choices: the chips wrap onto more lines, so use a select",
|
|
1690
|
+
"example": "<FilterTabs\n aria-label=\"Status\"\n items={[\n { value: 'all', label: 'All' },\n { value: 'active', label: 'Active' },\n { value: 'draft', label: 'Draft' },\n ]}\n defaultValue=\"all\"\n onValueChange={setStatus}\n/>"
|
|
1691
|
+
}
|
|
1692
|
+
},
|
|
1693
|
+
{
|
|
1694
|
+
"name": "GlobalSearch",
|
|
1695
|
+
"import": "import { GlobalSearch } from '@ratio-ui/core'",
|
|
1696
|
+
"description": "The search in the top bar. Typing opens a panel of grouped results that the app supplies, an empty field shows recent items, and the arrow keys, Enter and Escape work the list. Cmd+K or Ctrl+K focuses the field from anywhere.",
|
|
1697
|
+
"props": [
|
|
1698
|
+
{
|
|
1699
|
+
"name": "label",
|
|
1700
|
+
"type": "string",
|
|
1701
|
+
"required": true,
|
|
1702
|
+
"description": "The accessible name of the field, such as \"Search the dashboard\"."
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
"name": "value",
|
|
1706
|
+
"type": "string",
|
|
1707
|
+
"required": true,
|
|
1708
|
+
"description": "The text typed in the field."
|
|
1709
|
+
},
|
|
1710
|
+
{
|
|
1711
|
+
"name": "onValueChange",
|
|
1712
|
+
"type": "(value: string) => void",
|
|
1713
|
+
"required": true,
|
|
1714
|
+
"description": "Called on every change of the text. Debounce and fetch in the app."
|
|
1715
|
+
},
|
|
1716
|
+
{
|
|
1717
|
+
"name": "groups",
|
|
1718
|
+
"type": "GlobalSearchGroup[]",
|
|
1719
|
+
"required": true,
|
|
1720
|
+
"description": "The results for the current text, grouped. The app supplies them; nothing is filtered here."
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
"name": "recent",
|
|
1724
|
+
"type": "GlobalSearchResult[]",
|
|
1725
|
+
"required": false,
|
|
1726
|
+
"default": "[]",
|
|
1727
|
+
"description": "Recent items, shown under \"Recent\" while the field is empty."
|
|
1728
|
+
},
|
|
1729
|
+
{
|
|
1730
|
+
"name": "onSelect",
|
|
1731
|
+
"type": "((result: GlobalSearchResult) => void)",
|
|
1732
|
+
"required": false,
|
|
1733
|
+
"description": "Called when a result is chosen by click or Enter."
|
|
1734
|
+
},
|
|
1735
|
+
{
|
|
1736
|
+
"name": "onShowMore",
|
|
1737
|
+
"type": "((group: GlobalSearchGroup) => void)",
|
|
1738
|
+
"required": false,
|
|
1739
|
+
"description": "Called when a \"+N more\" row is chosen, with its group."
|
|
1740
|
+
},
|
|
1741
|
+
{
|
|
1742
|
+
"name": "placeholder",
|
|
1743
|
+
"type": "string",
|
|
1744
|
+
"required": false,
|
|
1745
|
+
"default": "Search",
|
|
1746
|
+
"description": "The placeholder of the field. Defaults to \"Search\"."
|
|
1747
|
+
},
|
|
1748
|
+
{
|
|
1749
|
+
"name": "emptyText",
|
|
1750
|
+
"type": "string",
|
|
1751
|
+
"required": false,
|
|
1752
|
+
"default": "No results",
|
|
1753
|
+
"description": "The copy when the text matches nothing. Defaults to \"No results\"."
|
|
1754
|
+
}
|
|
1755
|
+
],
|
|
1756
|
+
"usage": {
|
|
1757
|
+
"whenToUse": "- The search in the top bar that finds products, orders, customers and pages across the dashboard\n- Results that the app fetches and groups itself, with recent items while the field is empty",
|
|
1758
|
+
"whenNotToUse": "- Narrowing the rows of one listing: use SearchField\n- Picking a value for a form field: use a select",
|
|
1759
|
+
"example": "<GlobalSearch\n label=\"Search the dashboard\"\n value={query}\n onValueChange={setQuery}\n groups={[{ id: 'products', label: 'Products', total: 8, items: products }]}\n recent={recentItems}\n onSelect={(result) => navigate(result.id)}\n onShowMore={(group) => navigate(`/search?group=${group.id}&q=${query}`)}\n/>"
|
|
1760
|
+
}
|
|
1761
|
+
},
|
|
1762
|
+
{
|
|
1763
|
+
"name": "Icon",
|
|
1764
|
+
"import": "import { Icon } from '@ratio-ui/core'",
|
|
1765
|
+
"description": "Draws one icon of the registry: the design system's own glyphs, filled in a single colour, and Tabler's icons for the rest, drawn with a 1.5px line at every size. The icon is a square box of 8, 12 or 16px and takes the colour of its tone.",
|
|
1766
|
+
"props": [
|
|
1767
|
+
{
|
|
1768
|
+
"name": "name",
|
|
1769
|
+
"type": "\"alert-triangle\" | \"calendar\" | \"check\" | \"chevron-left\" | \"chevron-right\" | \"export\" | \"import\" | \"info-circle\" | \"menu\" | \"more\" | \"nav-analytics\" | \"nav-apps\" | \"nav-caret-down\" | \"nav-chevron\" | \"nav-content\" | \"nav-customers\" | \"nav-discounts\" | \"nav-growth\" | \"nav-home\" | \"nav-markets\" | \"nav-orders\" | \"nav-product\" | \"nav-product-2\" | \"nav-sales-channels\" | \"nav-settings\" | \"nav-shortcut\" | \"plus\" | \"search\" | \"x\"",
|
|
1770
|
+
"required": true,
|
|
1771
|
+
"description": "Which icon to draw, by name."
|
|
596
1772
|
},
|
|
597
1773
|
{
|
|
598
|
-
"name": "
|
|
599
|
-
"
|
|
600
|
-
"
|
|
601
|
-
"
|
|
1774
|
+
"name": "size",
|
|
1775
|
+
"type": "8 | 12 | 16",
|
|
1776
|
+
"required": false,
|
|
1777
|
+
"default": "12",
|
|
1778
|
+
"description": "The square box in px: 8, 12 or 16. Defaults to 12, the size inside controls."
|
|
602
1779
|
},
|
|
603
1780
|
{
|
|
604
|
-
"name": "
|
|
605
|
-
"
|
|
606
|
-
"
|
|
1781
|
+
"name": "tone",
|
|
1782
|
+
"type": "\"current\" | \"icon\" | \"primary\" | \"subdued\"",
|
|
1783
|
+
"required": false,
|
|
1784
|
+
"default": "current",
|
|
1785
|
+
"description": "The colour. current, the default, takes the colour of the text around the icon; the other tones set their own."
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
"name": "label",
|
|
1789
|
+
"type": "string",
|
|
1790
|
+
"required": false,
|
|
1791
|
+
"description": "The accessible name. With a label the icon is an image that assistive technology announces under that name. Without one it is decoration, hidden from assistive technology, and the text beside it has to say what it means."
|
|
1792
|
+
}
|
|
1793
|
+
],
|
|
1794
|
+
"usage": {
|
|
1795
|
+
"whenToUse": "- A glyph beside a label inside a control: the plus on a main button, the magnifier in a search field, the export tray on a secondary button. Use size 12\n- The side navigation: the nav glyphs at size 16 (nav-home and nav-product are the design system's own; nav-orders, nav-customers, nav-growth, nav-discounts, nav-content, nav-markets, nav-analytics, nav-sales-channels, nav-apps and nav-settings are Tabler stand-ins for the dashboard's sections, question 7), and the disclosure caret (nav-chevron or nav-caret-down, one glyph under two names) at size 8\n- The date pickers' open button: calendar (Tabler) at size 12\n- Pagination: chevron-left and chevron-right at size 8\n- A mark that Tabler supplies: check, x, alert-triangle, info-circle, import, more (three dots) and menu (the phone menu button). They are drawn with a 1.5px line at every size, so they sit beside the design system's own glyphs without looking heavier\n- Meaning that lives only in the icon: pass label. The icon is then an image that assistive technology announces under that name. Without a label it is decoration and is hidden from assistive technology\n- Colour: tone current, the default, takes the colour of the text around the icon. icon is the design system's icon ink, subdued is its subdued text ink and primary is the accent\n- Chevron geometry (design question 9): the design system has no vector for its pagination chevrons, only a 1.5px CSS caret in an 8px box, so chevron-left and chevron-right stand in. Each is the outline of a line 1.5 units wide with round ends, two legs at 45 degrees, each 2.5 units across and 2.5 down, through (2.75, 1.5), (5.25, 4) and (2.75, 6.5) in an 8 unit box. They scale like every filled glyph, so draw them at size 8, and expect them to be replaced when the designer sends real vectors",
|
|
1796
|
+
"whenNotToUse": "- Decoration that adds no meaning. An icon next to text that already says the same thing is hidden from assistive technology, so leave the label off, and leave the icon out when it adds nothing\n- An icon the registry does not have. Components accept no className or style, and icons come from the registry only, so a new one is a registry entry: the design system's glyph first, Tabler for the rest\n- An icon-only control without a name. Pass label, or give the control its own accessible name\n- A size other than 8, 12 or 16, or a colour other than the four tones. There is no red, no destructive colour and no third accent: an error is marked with the alert-triangle glyph beside its message, not with a colour\n- Emoji, or unicode arrows and symbols, as icons. Inter's web subsets do not hold them and the design system bans them",
|
|
1797
|
+
"example": "import { Icon } from '@ratio-ui/core'\n\n// Beside text that names it: decoration, hidden from assistive technology\n<button type=\"button\">\n <Icon name=\"plus\" />\n Add product\n</button>\n\n// Alone: the label is the accessible name\n<Icon name=\"search\" tone=\"icon\" label=\"Search\" />\n\n// Pagination chevrons are drawn for an 8px box\n<Icon name=\"chevron-right\" size={8} />"
|
|
1798
|
+
}
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
"name": "Inline",
|
|
1802
|
+
"import": "import { Inline } from '@ratio-ui/core'",
|
|
1803
|
+
"description": "Lays its children out in a row with a fixed space between them. It takes no className and no style: the gap is a step of the design system's spacing scale, and the layout is the only styling it has.",
|
|
1804
|
+
"props": [
|
|
1805
|
+
{
|
|
1806
|
+
"name": "gap",
|
|
1807
|
+
"type": "0 | 1 | 2 | 4 | 6 | 7 | 8 | 11 | 12 | 14 | 24 | 32 | 80",
|
|
1808
|
+
"required": true,
|
|
1809
|
+
"description": "The space between children, a step of the design system's scale in px: 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 24, 32 or 80."
|
|
1810
|
+
},
|
|
1811
|
+
{
|
|
1812
|
+
"name": "align",
|
|
1813
|
+
"type": "\"baseline\" | \"center\" | \"end\" | \"start\" | \"stretch\"",
|
|
1814
|
+
"required": false,
|
|
1815
|
+
"default": "center",
|
|
1816
|
+
"description": "How children line up across the row, which is the vertical axis. Defaults to center."
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
"name": "justify",
|
|
1820
|
+
"type": "\"between\" | \"center\" | \"end\" | \"start\"",
|
|
1821
|
+
"required": false,
|
|
1822
|
+
"default": "start",
|
|
1823
|
+
"description": "How children spread along the row, which is the horizontal axis. Defaults to start."
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
"name": "wrap",
|
|
1827
|
+
"type": "boolean",
|
|
1828
|
+
"required": false,
|
|
1829
|
+
"default": "false",
|
|
1830
|
+
"description": "Whether children move to a new line when the row is full. Defaults to false, which keeps one line."
|
|
1831
|
+
},
|
|
1832
|
+
{
|
|
1833
|
+
"name": "as",
|
|
1834
|
+
"type": "\"aside\" | \"div\" | \"fieldset\" | \"footer\" | \"form\" | \"header\" | \"li\" | \"main\" | \"nav\" | \"ol\" | \"section\" | \"ul\"",
|
|
1835
|
+
"required": false,
|
|
1836
|
+
"default": "div",
|
|
1837
|
+
"description": "The element to render. Defaults to div; use a list, landmark or form element where the content is one."
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
"name": "ref",
|
|
1841
|
+
"type": "Ref<HTMLElement>",
|
|
1842
|
+
"required": false,
|
|
1843
|
+
"description": "Receives the rendered element."
|
|
1844
|
+
}
|
|
1845
|
+
],
|
|
1846
|
+
"usage": {
|
|
1847
|
+
"whenToUse": "- Children side by side with a fixed space between them: a toolbar, a row of tags, a label next to a value\n- Children that spread along the row (`justify`: start, center, end or between) or move to the next line when the row is full (`wrap`)\n- A gap taken from the design system's spacing scale: 0, 1, 2, 4, 6, 7, 8, 11, 12, 14, 24, 32 or 80 px\n- A row that is also a list or a landmark: `as` renders `ul`, `ol`, `li`, `nav`, `header`, `footer`, `main`, `aside`, `section`, `form` or `fieldset` instead of `div`",
|
|
1848
|
+
"whenNotToUse": "- Children one under another: use Stack\n- Columns that have to line up from one row to the next: Inline lays out one row at a time, and wave 0 has no grid\n- Space around one child or at the edge of a container: Inline spaces siblings only, and has no padding or margin\n- Styling: Inline takes no `className` and no `style`\n- A list without markers: `as=\"ul\"` and `as=\"ol\"` leave the browser's list markers as they are",
|
|
1849
|
+
"example": "<Inline gap={8} justify=\"between\" wrap>\n <div>Orders</div>\n <Inline gap={4}>\n <div>Export</div>\n <div>Filter</div>\n </Inline>\n</Inline>"
|
|
1850
|
+
}
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
"name": "Input",
|
|
1854
|
+
"import": "import { Input } from '@ratio-ui/core'",
|
|
1855
|
+
"description": "A single-line text field in the design system's look: 8px radius, a 1px ring that turns blue on focus, 14px body type. It takes every attribute of an input (type, inputMode, value, onChange). For a prefix, suffix, icon or shortcut hint, put an InputGroupInput in an InputGroup.",
|
|
1856
|
+
"props": [
|
|
1857
|
+
{
|
|
1858
|
+
"name": "size",
|
|
1859
|
+
"type": "32 | 36",
|
|
1860
|
+
"required": false,
|
|
1861
|
+
"default": "36",
|
|
1862
|
+
"description": "The height in px: 36 for forms and search, 32 for fields inside a table. Defaults to 36."
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
"name": "ref",
|
|
1866
|
+
"type": "Ref<HTMLInputElement>",
|
|
1867
|
+
"required": false,
|
|
1868
|
+
"description": "Receives the input element."
|
|
1869
|
+
}
|
|
1870
|
+
],
|
|
1871
|
+
"usage": {
|
|
1872
|
+
"whenToUse": "- A single-line text field in a form, a settings page or a table cell: `size` is 36 for forms and 32 for fields inside a table\n- Any input type the browser supports, such as text, email, number or password: Input takes every attribute of an input\n- A field with an error: set `aria-invalid` and the ring changes, and put the error message beside it in text",
|
|
1873
|
+
"whenNotToUse": "- A field with a prefix, suffix, icon or shortcut hint, such as a rupee price, a weight in kg or a search field: use InputGroup\n- Several lines of text: use a textarea\n- A choice from a fixed list: use a select\n- Custom classes or inline styles: Input takes no `className` and no `style`",
|
|
1874
|
+
"example": "<Input aria-label=\"Product title\" placeholder=\"Short sleeve t-shirt\" />\n<Input aria-label=\"Variant stock\" size={32} inputMode=\"numeric\" />"
|
|
1875
|
+
}
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
"name": "InputGroup",
|
|
1879
|
+
"import": "import { InputGroup } from '@ratio-ui/core'",
|
|
1880
|
+
"description": "A field with a prefix, suffix, icon or shortcut hint beside the input, inside one ring. Put an InputGroupInput in it and an InputGroupAddon on either side, for example a rupee sign before a price or kg after a weight.",
|
|
1881
|
+
"props": [
|
|
1882
|
+
{
|
|
1883
|
+
"name": "size",
|
|
1884
|
+
"type": "32 | 36",
|
|
1885
|
+
"required": false,
|
|
1886
|
+
"default": "36",
|
|
1887
|
+
"description": "The height in px: 36 for forms and search, 32 for fields inside a table. Defaults to 36."
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
"name": "ref",
|
|
1891
|
+
"type": "Ref<HTMLDivElement>",
|
|
1892
|
+
"required": false,
|
|
1893
|
+
"description": "Receives the group element."
|
|
1894
|
+
}
|
|
1895
|
+
],
|
|
1896
|
+
"usage": {
|
|
1897
|
+
"whenToUse": "- A field with something beside the input, all inside one ring: a rupee sign before a price, kg after a weight, a search icon, or a shortcut hint such as ⌘K\n- A table search field or the top bar search: an icon at the start and a shortcut hint at the end\n- A compact field in a table: `size` 32, as for Input",
|
|
1898
|
+
"whenNotToUse": "- A plain field with nothing beside the input: use Input\n- A button inside the field: put it next to the group, because an addon holds text and icons only\n- Custom classes or inline styles: none of the parts take `className` or `style`",
|
|
1899
|
+
"example": "<InputGroup>\n <InputGroupAddon>\n <InputGroupText>₹</InputGroupText>\n </InputGroupAddon>\n <InputGroupInput aria-label=\"Selling price\" inputMode=\"decimal\" />\n</InputGroup>\n<InputGroup>\n <InputGroupAddon><Icon name=\"search\" /></InputGroupAddon>\n <InputGroupInput aria-label=\"Search\" placeholder=\"Search by name, email, etc.\" />\n <InputGroupAddon align=\"end\"><InputGroupShortcut>⌘K</InputGroupShortcut></InputGroupAddon>\n</InputGroup>"
|
|
1900
|
+
},
|
|
1901
|
+
"parts": [
|
|
1902
|
+
{
|
|
1903
|
+
"name": "InputGroupAddon",
|
|
1904
|
+
"import": "import { InputGroupAddon } from '@ratio-ui/core'",
|
|
1905
|
+
"description": "Holds an icon, a prefix, a suffix or a shortcut hint on one side of the input. Clicking it, off a button, moves focus to the input.",
|
|
607
1906
|
"props": [
|
|
608
|
-
{
|
|
609
|
-
"name": "side",
|
|
610
|
-
"type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
|
|
611
|
-
"required": false,
|
|
612
|
-
"default": "right",
|
|
613
|
-
"description": "Which side of the trigger the menu opens on. Defaults to bottom."
|
|
614
|
-
},
|
|
615
1907
|
{
|
|
616
1908
|
"name": "align",
|
|
617
|
-
"type": "\"
|
|
618
|
-
"required": false,
|
|
619
|
-
"description": "How the menu lines up with the trigger along that side. Defaults to start."
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
"name": "sideOffset",
|
|
623
|
-
"type": "number",
|
|
624
|
-
"required": false,
|
|
625
|
-
"default": "0",
|
|
626
|
-
"description": "The gap between the trigger and the menu in px. Defaults to 4."
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
"name": "alignOffset",
|
|
630
|
-
"type": "number",
|
|
1909
|
+
"type": "\"end\" | \"start\"",
|
|
631
1910
|
"required": false,
|
|
632
|
-
"default": "
|
|
633
|
-
"description": "
|
|
634
|
-
}
|
|
1911
|
+
"default": "start",
|
|
1912
|
+
"description": "The side of the input: start before it, end after it. Defaults to start."
|
|
1913
|
+
}
|
|
1914
|
+
]
|
|
1915
|
+
},
|
|
1916
|
+
{
|
|
1917
|
+
"name": "InputGroupInput",
|
|
1918
|
+
"import": "import { InputGroupInput } from '@ratio-ui/core'",
|
|
1919
|
+
"description": "The input of an InputGroup. It draws no ring: the group does. Mark it invalid with aria-invalid.",
|
|
1920
|
+
"props": [
|
|
635
1921
|
{
|
|
636
|
-
"name": "
|
|
637
|
-
"type": "
|
|
1922
|
+
"name": "ref",
|
|
1923
|
+
"type": "Ref<HTMLInputElement>",
|
|
638
1924
|
"required": false,
|
|
639
|
-
"description": "
|
|
1925
|
+
"description": "Receives the input element."
|
|
640
1926
|
}
|
|
641
1927
|
]
|
|
642
1928
|
},
|
|
643
1929
|
{
|
|
644
|
-
"name": "
|
|
645
|
-
"import": "import {
|
|
646
|
-
"description": "
|
|
647
|
-
"props": [
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
1930
|
+
"name": "InputGroupShortcut",
|
|
1931
|
+
"import": "import { InputGroupShortcut } from '@ratio-ui/core'",
|
|
1932
|
+
"description": "A shortcut hint such as ⌘K inside an end addon, drawn as a small keycap.",
|
|
1933
|
+
"props": []
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
"name": "InputGroupText",
|
|
1937
|
+
"import": "import { InputGroupText } from '@ratio-ui/core'",
|
|
1938
|
+
"description": "A text prefix or suffix inside an addon, such as a currency sign or a unit, in the muted colour.",
|
|
1939
|
+
"props": []
|
|
1940
|
+
}
|
|
1941
|
+
]
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
"name": "InputOtp",
|
|
1945
|
+
"import": "import { InputOtp } from '@ratio-ui/core'",
|
|
1946
|
+
"description": "A one-time-code field: six 44px digit slots (set `length` for another count) over one hidden input, so the browser offers the SMS code (autocomplete one-time-code), a pasted code fills every slot, and the numeric keypad opens on phones. Digits only.",
|
|
1947
|
+
"props": [
|
|
1948
|
+
{
|
|
1949
|
+
"name": "length",
|
|
1950
|
+
"type": "number",
|
|
1951
|
+
"required": false,
|
|
1952
|
+
"default": "6",
|
|
1953
|
+
"description": "The number of digits. Defaults to 6."
|
|
1954
|
+
},
|
|
1955
|
+
{
|
|
1956
|
+
"name": "value",
|
|
1957
|
+
"type": "string",
|
|
1958
|
+
"required": false,
|
|
1959
|
+
"description": "The code typed so far, for a controlled field."
|
|
1960
|
+
},
|
|
1961
|
+
{
|
|
1962
|
+
"name": "defaultValue",
|
|
1963
|
+
"type": "string",
|
|
1964
|
+
"required": false,
|
|
1965
|
+
"description": "The code typed so far, for an uncontrolled field."
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
"name": "onValueChange",
|
|
1969
|
+
"type": "((value: string) => void)",
|
|
1970
|
+
"required": false,
|
|
1971
|
+
"description": "Called with the whole code on every change, including a paste."
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
"name": "onComplete",
|
|
1975
|
+
"type": "((value: string) => void)",
|
|
1976
|
+
"required": false,
|
|
1977
|
+
"description": "Called once with the code when every slot is filled."
|
|
1978
|
+
},
|
|
1979
|
+
{
|
|
1980
|
+
"name": "disabled",
|
|
1981
|
+
"type": "boolean",
|
|
1982
|
+
"required": false,
|
|
1983
|
+
"description": "Stops editing and halves the opacity."
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
"name": "aria-invalid",
|
|
1987
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
1988
|
+
"required": false,
|
|
1989
|
+
"description": "Draws the error ring on every slot."
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
"name": "aria-label",
|
|
1993
|
+
"type": "string",
|
|
1994
|
+
"required": false,
|
|
1995
|
+
"description": "The accessible name, for example \"6-digit code\"."
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
"name": "aria-labelledby",
|
|
1999
|
+
"type": "string",
|
|
2000
|
+
"required": false,
|
|
2001
|
+
"description": "The id of an element that names the field."
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
"name": "aria-describedby",
|
|
2005
|
+
"type": "string",
|
|
2006
|
+
"required": false,
|
|
2007
|
+
"description": "The ids of the elements that describe the field, such as its hint or error. Field sets it."
|
|
2008
|
+
},
|
|
2009
|
+
{
|
|
2010
|
+
"name": "aria-required",
|
|
2011
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
2012
|
+
"required": false,
|
|
2013
|
+
"description": "Tells assistive technology that the code must be filled. Field sets it for a required field."
|
|
2014
|
+
},
|
|
2015
|
+
{
|
|
2016
|
+
"name": "id",
|
|
2017
|
+
"type": "string",
|
|
2018
|
+
"required": false,
|
|
2019
|
+
"description": "The id of the hidden input, for a label's htmlFor. Field sets it."
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
"name": "name",
|
|
2023
|
+
"type": "string",
|
|
2024
|
+
"required": false,
|
|
2025
|
+
"description": "The form field name."
|
|
2026
|
+
},
|
|
2027
|
+
{
|
|
2028
|
+
"name": "autoFocus",
|
|
2029
|
+
"type": "boolean",
|
|
2030
|
+
"required": false,
|
|
2031
|
+
"description": "Focuses the field on mount."
|
|
2032
|
+
},
|
|
2033
|
+
{
|
|
2034
|
+
"name": "ref",
|
|
2035
|
+
"type": "Ref<HTMLInputElement>",
|
|
2036
|
+
"required": false,
|
|
2037
|
+
"description": "Receives the hidden input element."
|
|
2038
|
+
}
|
|
2039
|
+
],
|
|
2040
|
+
"usage": {
|
|
2041
|
+
"whenToUse": "- The code step of a sign-in: the 6-digit code sent by SMS or email (\"Verify and sign in\")\n- Any short numeric code: set `length` for another count\n- A wrong code: set `aria-invalid` and every slot draws the error ring, and put the message beside the field in text",
|
|
2042
|
+
"whenNotToUse": "- A code with letters: InputOtp takes digits only\n- A long or free-form value: use Input\n- Custom classes or inline styles: InputOtp takes no `className` and no `style`",
|
|
2043
|
+
"example": "```tsx\n<InputOtp aria-label=\"6-digit code\" value={code} onValueChange={setCode} onComplete={(code) => verify(code)} />\n<InputOtp aria-label=\"PIN\" length={4} aria-invalid />\n```\n\nThe browser offers the SMS code through `autocomplete=\"one-time-code\"`, and a pasted code fills every slot."
|
|
2044
|
+
}
|
|
2045
|
+
},
|
|
2046
|
+
{
|
|
2047
|
+
"name": "Kbd",
|
|
2048
|
+
"import": "import { Kbd } from '@ratio-ui/core'",
|
|
2049
|
+
"description": "A key hint, 20px high with a 4px radius, such as ⌘K or esc.",
|
|
2050
|
+
"props": [
|
|
656
2051
|
{
|
|
657
|
-
"name": "
|
|
658
|
-
"
|
|
659
|
-
"
|
|
660
|
-
"
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
2052
|
+
"name": "ref",
|
|
2053
|
+
"type": "Ref<HTMLElement>",
|
|
2054
|
+
"required": false,
|
|
2055
|
+
"description": "Receives the rendered element."
|
|
2056
|
+
}
|
|
2057
|
+
],
|
|
2058
|
+
"usage": {
|
|
2059
|
+
"whenToUse": "- A shortcut hint beside a control or in a menu: ⌘K, ↵, esc\n- Several keys of one shortcut, inside KbdGroup",
|
|
2060
|
+
"whenNotToUse": "- A button that triggers the action: Kbd only shows the key and is not interactive\n- Long text: a key is one symbol or a short name",
|
|
2061
|
+
"example": "<KbdGroup>\n <Kbd>⌘</Kbd>\n <Kbd>K</Kbd>\n</KbdGroup>"
|
|
2062
|
+
},
|
|
2063
|
+
"parts": [
|
|
2064
|
+
{
|
|
2065
|
+
"name": "KbdGroup",
|
|
2066
|
+
"import": "import { KbdGroup } from '@ratio-ui/core'",
|
|
2067
|
+
"description": "Puts the keys of one shortcut in a row with a 4px gap.",
|
|
2068
|
+
"props": []
|
|
668
2069
|
}
|
|
669
2070
|
]
|
|
670
2071
|
},
|
|
671
2072
|
{
|
|
672
|
-
"name": "
|
|
673
|
-
"import": "import {
|
|
674
|
-
"description": "
|
|
2073
|
+
"name": "KeyValueList",
|
|
2074
|
+
"import": "import { KeyValueList } from '@ratio-ui/core'",
|
|
2075
|
+
"description": "Settings rows in a hairline bordered panel: the label on the left, the value on the right and an optional action. It is a description list, so a screen reader announces each label with its value.",
|
|
675
2076
|
"props": [
|
|
676
2077
|
{
|
|
677
|
-
"name": "
|
|
678
|
-
"type": "
|
|
2078
|
+
"name": "items",
|
|
2079
|
+
"type": "KeyValueItem[]",
|
|
679
2080
|
"required": true,
|
|
680
|
-
"description": "
|
|
681
|
-
},
|
|
682
|
-
{
|
|
683
|
-
"name": "description",
|
|
684
|
-
"type": "ReactNode",
|
|
685
|
-
"required": false,
|
|
686
|
-
"description": "An optional second clause that says what to do next."
|
|
2081
|
+
"description": "The rows, in order."
|
|
687
2082
|
},
|
|
688
2083
|
{
|
|
689
|
-
"name": "
|
|
690
|
-
"type": "
|
|
2084
|
+
"name": "emptyValue",
|
|
2085
|
+
"type": "string",
|
|
691
2086
|
"required": false,
|
|
692
|
-
"
|
|
2087
|
+
"default": "Not set",
|
|
2088
|
+
"description": "What an empty value shows. Defaults to \"Not set\"."
|
|
693
2089
|
}
|
|
694
2090
|
],
|
|
695
2091
|
"usage": {
|
|
696
|
-
"whenToUse": "-
|
|
697
|
-
"whenNotToUse": "-
|
|
698
|
-
"example": "<
|
|
2092
|
+
"whenToUse": "- Settings and detail rows: a label on the left, its value on the right, an optional action such as Edit\n- A value that may be empty: it shows a placeholder, \"Not set\" by default",
|
|
2093
|
+
"whenNotToUse": "- Rows of many columns to scan or sort: use Table or DataTable\n- Editing a value in place: use a form with Input",
|
|
2094
|
+
"example": "```tsx\n<KeyValueList\n items={[\n { label: 'Store name', value: 'Maison Yara', action: { label: 'Edit', onClick: edit } },\n { label: 'Phone' },\n ]}\n/>\n```\n\nMoney and dates arrive already formatted; use the format module."
|
|
699
2095
|
}
|
|
700
2096
|
},
|
|
701
2097
|
{
|
|
702
|
-
"name": "
|
|
703
|
-
"import": "import {
|
|
704
|
-
"description": "A
|
|
2098
|
+
"name": "Link",
|
|
2099
|
+
"import": "import { Link } from '@ratio-ui/core'",
|
|
2100
|
+
"description": "A text link to another page, such as \"← Products\" or \"View all variants →\". It is drawn by the app's LinkProvider, so a router navigates without a reload; without one it is a plain <a href>. The arrows are decoration and are hidden from screen readers.",
|
|
705
2101
|
"props": [
|
|
706
2102
|
{
|
|
707
|
-
"name": "
|
|
708
|
-
"type": "
|
|
2103
|
+
"name": "href",
|
|
2104
|
+
"type": "string",
|
|
709
2105
|
"required": true,
|
|
710
|
-
"description": "
|
|
2106
|
+
"description": "Where the link goes."
|
|
711
2107
|
},
|
|
712
2108
|
{
|
|
713
|
-
"name": "
|
|
714
|
-
"type": "
|
|
715
|
-
"required":
|
|
716
|
-
"description": "The
|
|
2109
|
+
"name": "children",
|
|
2110
|
+
"type": "ReactNode",
|
|
2111
|
+
"required": true,
|
|
2112
|
+
"description": "The link text."
|
|
717
2113
|
},
|
|
718
2114
|
{
|
|
719
|
-
"name": "
|
|
720
|
-
"type": "
|
|
2115
|
+
"name": "back",
|
|
2116
|
+
"type": "boolean",
|
|
721
2117
|
"required": false,
|
|
722
|
-
"
|
|
2118
|
+
"default": "false",
|
|
2119
|
+
"description": "Shows a back arrow before the text, as in \"← Products\". Screen readers skip it."
|
|
723
2120
|
},
|
|
724
2121
|
{
|
|
725
|
-
"name": "
|
|
726
|
-
"type": "
|
|
2122
|
+
"name": "forward",
|
|
2123
|
+
"type": "boolean",
|
|
727
2124
|
"required": false,
|
|
728
|
-
"
|
|
2125
|
+
"default": "false",
|
|
2126
|
+
"description": "Shows a forward arrow after the text, as in \"View all variants →\". Screen readers skip it."
|
|
729
2127
|
},
|
|
730
2128
|
{
|
|
731
|
-
"name": "
|
|
732
|
-
"type": "
|
|
2129
|
+
"name": "ref",
|
|
2130
|
+
"type": "Ref<HTMLAnchorElement>",
|
|
733
2131
|
"required": false,
|
|
734
|
-
"description": "
|
|
2132
|
+
"description": "Receives the anchor element."
|
|
735
2133
|
}
|
|
736
2134
|
],
|
|
737
2135
|
"usage": {
|
|
738
|
-
"whenToUse": "- A
|
|
739
|
-
"whenNotToUse": "-
|
|
740
|
-
"example": "<
|
|
2136
|
+
"whenToUse": "- A text link to another page: \"← Products\", \"View all variants →\"\n- A back link in a detail page's body (the page header draws its back link with Link too, so the two look alike)",
|
|
2137
|
+
"whenNotToUse": "- An action that changes something: use Button\n- A whole table row: use DataTable's `rowHref`\n- A navigation row in the side navigation: use SideNav",
|
|
2138
|
+
"example": "<Link href=\"/products\" back>Products</Link>\n<Link href=\"/products/blue-shirt/variants\" forward>View all variants</Link>"
|
|
741
2139
|
}
|
|
742
2140
|
},
|
|
743
2141
|
{
|
|
744
|
-
"name": "
|
|
745
|
-
"import": "import {
|
|
746
|
-
"description": "
|
|
2142
|
+
"name": "LinkProvider",
|
|
2143
|
+
"import": "import { LinkProvider } from '@ratio-ui/core'",
|
|
2144
|
+
"description": "Draws every link of Ratio's components with the app's own router link, so a click navigates without a page reload: SideNav rows with an href, DataTable row links and the PageHeader back link. Wrap the app once, at its root. Without it those links are plain <a href> elements, which reload the page.",
|
|
747
2145
|
"props": [
|
|
748
2146
|
{
|
|
749
|
-
"name": "
|
|
750
|
-
"type": "
|
|
2147
|
+
"name": "render",
|
|
2148
|
+
"type": "LinkRender",
|
|
751
2149
|
"required": true,
|
|
752
|
-
"description": "The
|
|
2150
|
+
"description": "Draws every link Ratio renders. The function receives href, the styling class, the content and attributes such as aria-current and onClick, all to spread onto the element: `({ href, ...props }) => <RouterLink to={href} {...props} />`."
|
|
753
2151
|
},
|
|
754
2152
|
{
|
|
755
|
-
"name": "
|
|
756
|
-
"type": "
|
|
2153
|
+
"name": "children",
|
|
2154
|
+
"type": "ReactNode",
|
|
757
2155
|
"required": true,
|
|
758
|
-
"description": "The
|
|
2156
|
+
"description": "The app, or the part of it that the router serves."
|
|
2157
|
+
}
|
|
2158
|
+
],
|
|
2159
|
+
"usage": {
|
|
2160
|
+
"whenToUse": "- An app on a client-side router (React Router, Next.js, TanStack Router): wrap it once, at its root\n- So that SideNav rows with an href, DataTable row links and the PageHeader back link navigate without a page reload",
|
|
2161
|
+
"whenNotToUse": "- An app whose pages load from the server: the plain links already work\n- A link in your own markup: use your router's link directly",
|
|
2162
|
+
"example": "import { Link as RouterLink } from 'react-router-dom'\n\n<LinkProvider render={({ href, ...props }) => <RouterLink to={href} {...props} />}>\n <App />\n</LinkProvider>"
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
"name": "MediaGrid",
|
|
2167
|
+
"import": "import { MediaGrid } from '@ratio-ui/core'",
|
|
2168
|
+
"description": "The media of a product: a row of square thumbs with an add tile that opens the file picker and takes dropped files. Thumbs reorder by drag (pointer, touch or keyboard) and by the Move left, Move right and Make cover buttons, so no drag is needed. The first image is the cover and carries a badge. Uploads show a thin progress bar and failures an error under the thumb. Every move, cover change and removal is announced to screen readers.",
|
|
2169
|
+
"props": [
|
|
2170
|
+
{
|
|
2171
|
+
"name": "items",
|
|
2172
|
+
"type": "MediaGridItem[]",
|
|
2173
|
+
"required": true,
|
|
2174
|
+
"description": "The images in order. The first one is the cover."
|
|
759
2175
|
},
|
|
760
2176
|
{
|
|
761
|
-
"name": "
|
|
762
|
-
"type": "(
|
|
2177
|
+
"name": "onAdd",
|
|
2178
|
+
"type": "(files: File[]) => void",
|
|
763
2179
|
"required": true,
|
|
764
|
-
"description": "Called
|
|
2180
|
+
"description": "Called with the files chosen in the add tile or dropped on the grid."
|
|
765
2181
|
},
|
|
766
2182
|
{
|
|
767
|
-
"name": "
|
|
768
|
-
"type": "
|
|
2183
|
+
"name": "onReorder",
|
|
2184
|
+
"type": "(ids: string[]) => void",
|
|
769
2185
|
"required": true,
|
|
770
|
-
"description": "
|
|
2186
|
+
"description": "Called with every id in the new order after a drag, Move left, Move right or Make cover."
|
|
771
2187
|
},
|
|
772
2188
|
{
|
|
773
|
-
"name": "
|
|
774
|
-
"type": "
|
|
2189
|
+
"name": "onRemove",
|
|
2190
|
+
"type": "(id: string) => void",
|
|
2191
|
+
"required": true,
|
|
2192
|
+
"description": "Called with the id of the item to take off the grid."
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
"name": "onMakeCover",
|
|
2196
|
+
"type": "((id: string) => void)",
|
|
775
2197
|
"required": false,
|
|
776
|
-
"
|
|
777
|
-
"description": "Recent items, shown under \"Recent\" while the field is empty."
|
|
2198
|
+
"description": "Called with the id after Make cover has moved it first through onReorder, for an app that saves the cover on its own."
|
|
778
2199
|
},
|
|
779
2200
|
{
|
|
780
|
-
"name": "
|
|
781
|
-
"type": "
|
|
2201
|
+
"name": "accept",
|
|
2202
|
+
"type": "Accept",
|
|
782
2203
|
"required": false,
|
|
783
|
-
"
|
|
2204
|
+
"default": "{ 'image/*': [] }",
|
|
2205
|
+
"description": "The file types the add tile takes, as react-dropzone's accept map. Defaults to every image type."
|
|
784
2206
|
},
|
|
785
2207
|
{
|
|
786
|
-
"name": "
|
|
787
|
-
"type": "
|
|
2208
|
+
"name": "disabled",
|
|
2209
|
+
"type": "boolean",
|
|
788
2210
|
"required": false,
|
|
789
|
-
"
|
|
2211
|
+
"default": "false",
|
|
2212
|
+
"description": "Stops adding, dragging and every button."
|
|
790
2213
|
},
|
|
791
2214
|
{
|
|
792
|
-
"name": "
|
|
2215
|
+
"name": "addLabel",
|
|
793
2216
|
"type": "string",
|
|
794
2217
|
"required": false,
|
|
795
|
-
"default": "
|
|
796
|
-
"description": "The
|
|
2218
|
+
"default": "Add media",
|
|
2219
|
+
"description": "The accessible name of the add tile. Defaults to \"Add media\"."
|
|
797
2220
|
},
|
|
798
2221
|
{
|
|
799
|
-
"name": "
|
|
2222
|
+
"name": "id",
|
|
800
2223
|
"type": "string",
|
|
801
2224
|
"required": false,
|
|
802
|
-
"
|
|
803
|
-
|
|
2225
|
+
"description": "The id of the grid."
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
"name": "aria-label",
|
|
2229
|
+
"type": "string",
|
|
2230
|
+
"required": false,
|
|
2231
|
+
"description": "The accessible name of the grid. Defaults to \"Media\" when there is no aria-labelledby."
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
"name": "aria-labelledby",
|
|
2235
|
+
"type": "string",
|
|
2236
|
+
"required": false,
|
|
2237
|
+
"description": "The id of the visible label that names the grid, such as a Field label."
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
"name": "aria-describedby",
|
|
2241
|
+
"type": "string",
|
|
2242
|
+
"required": false,
|
|
2243
|
+
"description": "The id of help text for the grid."
|
|
804
2244
|
}
|
|
805
2245
|
],
|
|
806
2246
|
"usage": {
|
|
807
|
-
"whenToUse": "- The
|
|
808
|
-
"whenNotToUse": "-
|
|
809
|
-
"example": "<
|
|
2247
|
+
"whenToUse": "- The images of a product or any ordered set of images, with an add tile that opens the file picker and takes dropped files\n- The app uploads: MediaGrid reports `onAdd(files)`, `onReorder(ids)`, `onRemove(id)` and `onMakeCover(id)`, and shows each item's `progress` (0 to 100) and `error`\n- The first image is the cover; Make cover moves an image first through `onReorder`, then calls `onMakeCover`\n- Images reorder by drag (pointer, touch or keyboard) and by the Move left and Move right buttons, so no drag is needed",
|
|
2248
|
+
"whenNotToUse": "- A single image such as a logo or an avatar: use Avatar or a single file input\n- Files that are not images in a visual order (documents, CSV imports): use a list\n- Remove has no confirm step, because the save bar's Discard brings an image back; confirm in `onRemove` with AlertDialog when the removal is final\n- Styling: MediaGrid takes no `className` and no `style`",
|
|
2249
|
+
"example": "<MediaGrid\n items={media}\n onAdd={(files) => upload(files)}\n onReorder={(ids) => setMedia(ids.map((id) => media.find((m) => m.id === id)!))}\n onRemove={(id) => setMedia(media.filter((m) => m.id !== id))}\n/>"
|
|
810
2250
|
}
|
|
811
2251
|
},
|
|
812
2252
|
{
|
|
813
|
-
"name": "
|
|
814
|
-
"import": "import {
|
|
815
|
-
"description": "
|
|
2253
|
+
"name": "MetricStrip",
|
|
2254
|
+
"import": "import { MetricStrip } from '@ratio-ui/core'",
|
|
2255
|
+
"description": "A row of metrics in one hairline container: each segment is a title, optionally with a definition, over its value.",
|
|
816
2256
|
"props": [
|
|
817
2257
|
{
|
|
818
|
-
"name": "
|
|
819
|
-
"type": "
|
|
2258
|
+
"name": "segments",
|
|
2259
|
+
"type": "MetricSegment[]",
|
|
820
2260
|
"required": true,
|
|
821
|
-
"description": "
|
|
2261
|
+
"description": "The metrics, left to right."
|
|
822
2262
|
},
|
|
823
2263
|
{
|
|
824
|
-
"name": "
|
|
825
|
-
"type": "
|
|
2264
|
+
"name": "label",
|
|
2265
|
+
"type": "string",
|
|
826
2266
|
"required": false,
|
|
827
|
-
"
|
|
828
|
-
|
|
2267
|
+
"description": "The accessible name of the strip."
|
|
2268
|
+
}
|
|
2269
|
+
],
|
|
2270
|
+
"usage": {
|
|
2271
|
+
"whenToUse": "- A few headline numbers above a listing, such as the Products metrics\n- A metric whose name needs a one-sentence definition",
|
|
2272
|
+
"whenNotToUse": "- A chart or a trend: this is plain values\n- Many metrics or long values: use a table",
|
|
2273
|
+
"example": "<MetricStrip\n label=\"Product metrics\"\n segments={[\n {\n id: 'rate',\n title: 'Average sell-through rate',\n definition: 'Share of stock sold',\n value: '9.95%',\n },\n { id: 'days', title: 'Days of inventory remaining', value: null },\n { id: 'abc', title: 'ABC product analysis', value: 0, format: 'money' },\n ]}\n/>"
|
|
2274
|
+
}
|
|
2275
|
+
},
|
|
2276
|
+
{
|
|
2277
|
+
"name": "MoneyInput",
|
|
2278
|
+
"import": "import { MoneyInput } from '@ratio-ui/core'",
|
|
2279
|
+
"description": "A money field: the currency symbol before the amount, inside one ring. It takes and gives integer paise, shows the amount grouped as India groups it with two decimals (1,23,456.50) once the field loses focus, and reads a pasted amount written with the currency symbol or with either grouping. Under a name, a form submits paise.",
|
|
2280
|
+
"props": [
|
|
2281
|
+
{
|
|
2282
|
+
"name": "value",
|
|
2283
|
+
"type": "number | null",
|
|
2284
|
+
"required": false,
|
|
2285
|
+
"description": "The amount in integer paise (12345650 is 1,23,456 rupees and 50 paise), or null for an empty field. Pass it to control the field."
|
|
829
2286
|
},
|
|
830
2287
|
{
|
|
831
|
-
"name": "
|
|
832
|
-
"type": "
|
|
2288
|
+
"name": "defaultValue",
|
|
2289
|
+
"type": "number | null",
|
|
833
2290
|
"required": false,
|
|
834
|
-
"default": "
|
|
835
|
-
"description": "The
|
|
2291
|
+
"default": "null",
|
|
2292
|
+
"description": "The starting amount in integer paise when the field is not controlled. Defaults to empty."
|
|
836
2293
|
},
|
|
837
2294
|
{
|
|
838
|
-
"name": "
|
|
839
|
-
"type": "
|
|
2295
|
+
"name": "onValueChange",
|
|
2296
|
+
"type": "((paise: number | null) => void)",
|
|
840
2297
|
"required": false,
|
|
841
|
-
"description": "
|
|
2298
|
+
"description": "Called with the amount in integer paise as it is typed, pasted or cleared (null when empty)."
|
|
2299
|
+
},
|
|
2300
|
+
{
|
|
2301
|
+
"name": "min",
|
|
2302
|
+
"type": "number",
|
|
2303
|
+
"required": false,
|
|
2304
|
+
"description": "The smallest amount in integer paise; the field moves a smaller one up to it on blur. Leave it out to allow negatives."
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
"name": "max",
|
|
2308
|
+
"type": "number",
|
|
2309
|
+
"required": false,
|
|
2310
|
+
"description": "The largest amount in integer paise; the field moves a larger one down to it on blur."
|
|
2311
|
+
},
|
|
2312
|
+
{
|
|
2313
|
+
"name": "size",
|
|
2314
|
+
"type": "32 | 36",
|
|
2315
|
+
"required": false,
|
|
2316
|
+
"default": "36",
|
|
2317
|
+
"description": "The height in px: 36 for forms, 32 for prices inside a table. Defaults to 36."
|
|
2318
|
+
},
|
|
2319
|
+
{
|
|
2320
|
+
"name": "ref",
|
|
2321
|
+
"type": "Ref<HTMLInputElement>",
|
|
2322
|
+
"required": false,
|
|
2323
|
+
"description": "Receives the input element."
|
|
842
2324
|
}
|
|
843
2325
|
],
|
|
844
2326
|
"usage": {
|
|
845
|
-
"whenToUse": "-
|
|
846
|
-
"whenNotToUse": "-
|
|
847
|
-
"example": "
|
|
2327
|
+
"whenToUse": "- Any amount of money a person types: MRP, selling price, cost price, variant prices\n- Values stored as integer paise: `value` and `onValueChange` take and give paise, and under a `name` a form submits paise\n- A price inside a table: `size` 32\n- Amounts people paste from a spreadsheet or another page: a pasted amount with the rupee sign or either grouping is read as paise",
|
|
2328
|
+
"whenNotToUse": "- Showing an amount that is not edited: write it with the format module (`formatPaise`) in text\n- A number that is not money, such as a weight or a length: use UnitInput\n- A count of items: use Input with `inputMode=\"numeric\"`\n- Custom classes or inline styles: MoneyInput takes neither `className` nor `style`",
|
|
2329
|
+
"example": "const [mrp, setMrp] = useState<number | null>(129900)\n\n<MoneyInput aria-label=\"MRP\" value={mrp} onValueChange={setMrp} min={0} />\n<MoneyInput aria-label=\"Price of L\" size={32} defaultValue={44900} name=\"price\" />\n<MoneyInput aria-label=\"Selling price\" aria-invalid aria-describedby=\"price-error\" />"
|
|
848
2330
|
}
|
|
849
2331
|
},
|
|
850
2332
|
{
|
|
851
|
-
"name": "
|
|
852
|
-
"import": "import {
|
|
853
|
-
"description": "
|
|
2333
|
+
"name": "PageHeader",
|
|
2334
|
+
"import": "import { PageHeader } from '@ratio-ui/core'",
|
|
2335
|
+
"description": "The top of a page: an optional back link, then an icon, the title and a status pill on the left, and the actions with an overflow menu on the right. It wraps on a phone.",
|
|
854
2336
|
"props": [
|
|
855
2337
|
{
|
|
856
|
-
"name": "
|
|
857
|
-
"type": "
|
|
2338
|
+
"name": "title",
|
|
2339
|
+
"type": "string",
|
|
858
2340
|
"required": true,
|
|
859
|
-
"description": "The
|
|
2341
|
+
"description": "The page title, shown as the level 1 heading."
|
|
2342
|
+
},
|
|
2343
|
+
{
|
|
2344
|
+
"name": "icon",
|
|
2345
|
+
"type": "ReactNode",
|
|
2346
|
+
"required": false,
|
|
2347
|
+
"description": "An icon or logo shown before the title."
|
|
860
2348
|
},
|
|
861
2349
|
{
|
|
862
|
-
"name": "
|
|
863
|
-
"type": "
|
|
2350
|
+
"name": "status",
|
|
2351
|
+
"type": "{ label: string; tone?: StatusPillTone; }",
|
|
864
2352
|
"required": false,
|
|
865
|
-
"
|
|
866
|
-
"description": "How children line up across the row, which is the vertical axis. Defaults to center."
|
|
2353
|
+
"description": "The state of the record, one word, beside the title."
|
|
867
2354
|
},
|
|
868
2355
|
{
|
|
869
|
-
"name": "
|
|
870
|
-
"type": "
|
|
2356
|
+
"name": "backHref",
|
|
2357
|
+
"type": "string",
|
|
871
2358
|
"required": false,
|
|
872
|
-
"
|
|
873
|
-
"description": "How children spread along the row, which is the horizontal axis. Defaults to start."
|
|
2359
|
+
"description": "Where the back link goes. The link shows only with this. On a router, LinkProvider draws it with the app's own link."
|
|
874
2360
|
},
|
|
875
2361
|
{
|
|
876
|
-
"name": "
|
|
877
|
-
"type": "
|
|
2362
|
+
"name": "backLabel",
|
|
2363
|
+
"type": "string",
|
|
878
2364
|
"required": false,
|
|
879
|
-
"default": "
|
|
880
|
-
"description": "
|
|
2365
|
+
"default": "Back",
|
|
2366
|
+
"description": "The text of the back link, such as the parent page's name. Defaults to Back."
|
|
881
2367
|
},
|
|
882
2368
|
{
|
|
883
|
-
"name": "
|
|
884
|
-
"type": "
|
|
2369
|
+
"name": "actions",
|
|
2370
|
+
"type": "ReactNode",
|
|
885
2371
|
"required": false,
|
|
886
|
-
"
|
|
887
|
-
"description": "The element to render. Defaults to div; use a list, landmark or form element where the content is one."
|
|
2372
|
+
"description": "Buttons on the right, such as Export and Add product."
|
|
888
2373
|
},
|
|
889
2374
|
{
|
|
890
|
-
"name": "
|
|
891
|
-
"type": "
|
|
2375
|
+
"name": "menuItems",
|
|
2376
|
+
"type": "PageHeaderMenuItem[]",
|
|
892
2377
|
"required": false,
|
|
893
|
-
"description": "
|
|
2378
|
+
"description": "Entries of the overflow menu. The More actions button shows only when there is at least one."
|
|
894
2379
|
}
|
|
895
2380
|
],
|
|
896
2381
|
"usage": {
|
|
897
|
-
"whenToUse": "-
|
|
898
|
-
"whenNotToUse": "-
|
|
899
|
-
"example": "<
|
|
2382
|
+
"whenToUse": "- The top of a page: Products, Product detail\n- A title with an icon, a one-word status, a back link, actions and an overflow menu",
|
|
2383
|
+
"whenNotToUse": "- A heading inside a panel: use Text\n- More than one main action: keep one main Button, the rest secondary or in the overflow menu",
|
|
2384
|
+
"example": "<PageHeader\n title=\"Blue shirt\"\n status={{ label: 'Active', tone: 'success' }}\n backHref=\"/products\"\n backLabel=\"Products\"\n actions={<Button>Save</Button>}\n menuItems={[\n { label: 'Duplicate', onSelect: duplicate },\n { label: 'Delete', onSelect: remove, destructive: true },\n ]}\n/>"
|
|
900
2385
|
}
|
|
901
2386
|
},
|
|
902
2387
|
{
|
|
903
|
-
"name": "
|
|
904
|
-
"import": "import {
|
|
905
|
-
"description": "
|
|
2388
|
+
"name": "Pagination",
|
|
2389
|
+
"import": "import { Pagination } from '@ratio-ui/core'",
|
|
2390
|
+
"description": "The footer under a table: Previous and Next arrows and the range on show, written \"1 – 20 of 84 results\". An arrow is dimmed to 50% and disabled (aria-disabled, still focusable) when there is no page that way. The parent owns the page: it passes `page` and updates it in `onPageChange`.",
|
|
906
2391
|
"props": [
|
|
907
2392
|
{
|
|
908
|
-
"name": "
|
|
909
|
-
"type": "
|
|
910
|
-
"required":
|
|
911
|
-
"
|
|
912
|
-
"description": "The height in px: 36 for forms and search, 32 for fields inside a table. Defaults to 36."
|
|
2393
|
+
"name": "page",
|
|
2394
|
+
"type": "number",
|
|
2395
|
+
"required": true,
|
|
2396
|
+
"description": "The page being shown, counting from 1."
|
|
913
2397
|
},
|
|
914
2398
|
{
|
|
915
|
-
"name": "
|
|
916
|
-
"type": "
|
|
917
|
-
"required":
|
|
918
|
-
"description": "
|
|
2399
|
+
"name": "pageSize",
|
|
2400
|
+
"type": "number",
|
|
2401
|
+
"required": true,
|
|
2402
|
+
"description": "How many results one page holds."
|
|
2403
|
+
},
|
|
2404
|
+
{
|
|
2405
|
+
"name": "total",
|
|
2406
|
+
"type": "number",
|
|
2407
|
+
"required": true,
|
|
2408
|
+
"description": "How many results there are in all, across every page."
|
|
2409
|
+
},
|
|
2410
|
+
{
|
|
2411
|
+
"name": "onPageChange",
|
|
2412
|
+
"type": "(page: number) => void",
|
|
2413
|
+
"required": true,
|
|
2414
|
+
"description": "Called with the page to show when Previous or Next is pressed."
|
|
919
2415
|
}
|
|
920
2416
|
],
|
|
921
2417
|
"usage": {
|
|
922
|
-
"whenToUse": "-
|
|
923
|
-
"whenNotToUse": "-
|
|
924
|
-
"example": "
|
|
2418
|
+
"whenToUse": "- The footer under a table or list that has more than one page of results\n- When the parent knows the page, the page size and the total",
|
|
2419
|
+
"whenNotToUse": "- Numbered page links or jump to page: this is Previous and Next only\n- Infinite scroll or a load more button\n- Styling: Pagination takes no `className` and no `style`",
|
|
2420
|
+
"example": "const [page, setPage] = useState(1)\n\n<Pagination page={page} pageSize={20} total={84} onPageChange={setPage} />"
|
|
925
2421
|
}
|
|
926
2422
|
},
|
|
927
2423
|
{
|
|
928
|
-
"name": "
|
|
929
|
-
"import": "import {
|
|
930
|
-
"description": "A
|
|
931
|
-
"props": [
|
|
932
|
-
{
|
|
933
|
-
"name": "size",
|
|
934
|
-
"type": "32 | 36",
|
|
935
|
-
"required": false,
|
|
936
|
-
"default": "36",
|
|
937
|
-
"description": "The height in px: 36 for forms and search, 32 for fields inside a table. Defaults to 36."
|
|
938
|
-
},
|
|
939
|
-
{
|
|
940
|
-
"name": "ref",
|
|
941
|
-
"type": "Ref<HTMLDivElement>",
|
|
942
|
-
"required": false,
|
|
943
|
-
"description": "Receives the group element."
|
|
944
|
-
}
|
|
945
|
-
],
|
|
2424
|
+
"name": "Popover",
|
|
2425
|
+
"import": "import { Popover } from '@ratio-ui/core'",
|
|
2426
|
+
"description": "A panel that opens from a trigger and holds more than text, such as a list of notifications. Put a PopoverTrigger and a PopoverContent inside it.",
|
|
2427
|
+
"props": [],
|
|
946
2428
|
"usage": {
|
|
947
|
-
"whenToUse": "- A
|
|
948
|
-
"whenNotToUse": "- A
|
|
949
|
-
"example": "<
|
|
2429
|
+
"whenToUse": "- A small panel that opens from a button and holds more than a sentence, such as the notifications list\n- Content that people read or act on, and that they close with Escape or by clicking away",
|
|
2430
|
+
"whenNotToUse": "- A one-line hint: use Tooltip, or Definition for a term\n- A choice of actions: use DropdownMenu\n- A task that needs the whole screen's attention: use Dialog",
|
|
2431
|
+
"example": "<Popover>\n <PopoverTrigger>Notifications</PopoverTrigger>\n <PopoverContent>\n <PopoverHeader>\n <PopoverTitle>Notifications</PopoverTitle>\n <PopoverDescription>No new notifications</PopoverDescription>\n </PopoverHeader>\n </PopoverContent>\n</Popover>"
|
|
950
2432
|
},
|
|
951
2433
|
"parts": [
|
|
952
2434
|
{
|
|
953
|
-
"name": "
|
|
954
|
-
"import": "import {
|
|
955
|
-
"description": "
|
|
2435
|
+
"name": "PopoverContent",
|
|
2436
|
+
"import": "import { PopoverContent } from '@ratio-ui/core'",
|
|
2437
|
+
"description": "The popover panel: a white panel with a 1px outline and no shadow, 288px wide. It opens below the trigger by default.",
|
|
956
2438
|
"props": [
|
|
957
2439
|
{
|
|
958
|
-
"name": "
|
|
959
|
-
"type": "
|
|
2440
|
+
"name": "render",
|
|
2441
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverPopupState>",
|
|
960
2442
|
"required": false,
|
|
961
|
-
"
|
|
962
|
-
"description": "The side of the input: start before it, end after it. Defaults to start."
|
|
2443
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
963
2444
|
}
|
|
964
2445
|
]
|
|
965
2446
|
},
|
|
966
2447
|
{
|
|
967
|
-
"name": "
|
|
968
|
-
"import": "import {
|
|
969
|
-
"description": "The
|
|
2448
|
+
"name": "PopoverDescription",
|
|
2449
|
+
"import": "import { PopoverDescription } from '@ratio-ui/core'",
|
|
2450
|
+
"description": "The supporting text under the title, in the muted colour.",
|
|
970
2451
|
"props": [
|
|
971
2452
|
{
|
|
972
|
-
"name": "
|
|
973
|
-
"type": "
|
|
2453
|
+
"name": "render",
|
|
2454
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverDescriptionState>",
|
|
974
2455
|
"required": false,
|
|
975
|
-
"description": "
|
|
2456
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
976
2457
|
}
|
|
977
2458
|
]
|
|
978
2459
|
},
|
|
979
2460
|
{
|
|
980
|
-
"name": "
|
|
981
|
-
"import": "import {
|
|
982
|
-
"description": "
|
|
2461
|
+
"name": "PopoverHeader",
|
|
2462
|
+
"import": "import { PopoverHeader } from '@ratio-ui/core'",
|
|
2463
|
+
"description": "Groups a title and a description at the top of the panel.",
|
|
983
2464
|
"props": []
|
|
984
2465
|
},
|
|
985
2466
|
{
|
|
986
|
-
"name": "
|
|
987
|
-
"import": "import {
|
|
988
|
-
"description": "
|
|
989
|
-
"props": [
|
|
2467
|
+
"name": "PopoverTitle",
|
|
2468
|
+
"import": "import { PopoverTitle } from '@ratio-ui/core'",
|
|
2469
|
+
"description": "The title of the panel; it names the dialog for screen readers.",
|
|
2470
|
+
"props": [
|
|
2471
|
+
{
|
|
2472
|
+
"name": "render",
|
|
2473
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTitleState>",
|
|
2474
|
+
"required": false,
|
|
2475
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2476
|
+
}
|
|
2477
|
+
]
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
"name": "PopoverTrigger",
|
|
2481
|
+
"import": "import { PopoverTrigger } from '@ratio-ui/core'",
|
|
2482
|
+
"description": "The element that opens the popover on click or Enter. It renders a button unless render says otherwise.",
|
|
2483
|
+
"props": [
|
|
2484
|
+
{
|
|
2485
|
+
"name": "render",
|
|
2486
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, PopoverTriggerState>",
|
|
2487
|
+
"required": false,
|
|
2488
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2489
|
+
},
|
|
2490
|
+
{
|
|
2491
|
+
"name": "handle",
|
|
2492
|
+
"type": "PopoverHandle<unknown>",
|
|
2493
|
+
"required": false,
|
|
2494
|
+
"description": "A handle to associate the trigger with a popover."
|
|
2495
|
+
},
|
|
2496
|
+
{
|
|
2497
|
+
"name": "payload",
|
|
2498
|
+
"type": "unknown",
|
|
2499
|
+
"required": false,
|
|
2500
|
+
"description": "A payload to pass to the popover when it is opened."
|
|
2501
|
+
},
|
|
2502
|
+
{
|
|
2503
|
+
"name": "delay",
|
|
2504
|
+
"type": "number",
|
|
2505
|
+
"required": false,
|
|
2506
|
+
"default": "300",
|
|
2507
|
+
"description": "How long to wait before the popover may be opened on hover. Specified in milliseconds.\n\nRequires the `openOnHover` prop."
|
|
2508
|
+
},
|
|
2509
|
+
{
|
|
2510
|
+
"name": "closeDelay",
|
|
2511
|
+
"type": "number",
|
|
2512
|
+
"required": false,
|
|
2513
|
+
"default": "0",
|
|
2514
|
+
"description": "How long to wait before closing the popover that was opened on hover. Specified in milliseconds.\n\nRequires the `openOnHover` prop."
|
|
2515
|
+
},
|
|
2516
|
+
{
|
|
2517
|
+
"name": "openOnHover",
|
|
2518
|
+
"type": "boolean",
|
|
2519
|
+
"required": false,
|
|
2520
|
+
"default": "false",
|
|
2521
|
+
"description": "Whether the popover should also open when the trigger is hovered."
|
|
2522
|
+
}
|
|
2523
|
+
]
|
|
990
2524
|
}
|
|
991
2525
|
]
|
|
992
2526
|
},
|
|
993
2527
|
{
|
|
994
|
-
"name": "
|
|
995
|
-
"import": "import {
|
|
996
|
-
"description": "
|
|
2528
|
+
"name": "Progress",
|
|
2529
|
+
"import": "import { Progress } from '@ratio-ui/core'",
|
|
2530
|
+
"description": "The thin progress bar of question 5, 2px high, for page loads and refetches. Determinate with a value, indeterminate without one (a partial bar that moves only when the loading animation token names a motion, question 5). Base UI gives it the progressbar role, its label and its value text.",
|
|
997
2531
|
"props": [
|
|
998
2532
|
{
|
|
999
|
-
"name": "
|
|
1000
|
-
"type": "
|
|
2533
|
+
"name": "value",
|
|
2534
|
+
"type": "number | null",
|
|
1001
2535
|
"required": false,
|
|
1002
|
-
"
|
|
2536
|
+
"default": "null",
|
|
2537
|
+
"description": "The current value; leave it out or pass null for an indeterminate bar."
|
|
2538
|
+
},
|
|
2539
|
+
{
|
|
2540
|
+
"name": "max",
|
|
2541
|
+
"type": "number",
|
|
2542
|
+
"required": false,
|
|
2543
|
+
"default": "100",
|
|
2544
|
+
"description": "The value at which the bar is full. Defaults to 100; for steps, the number of steps."
|
|
2545
|
+
},
|
|
2546
|
+
{
|
|
2547
|
+
"name": "label",
|
|
2548
|
+
"type": "string",
|
|
2549
|
+
"required": false,
|
|
2550
|
+
"description": "A visible label, which also names the bar for screen readers."
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
"name": "showValue",
|
|
2554
|
+
"type": "boolean",
|
|
2555
|
+
"required": false,
|
|
2556
|
+
"description": "Shows the value on the right: a percent, or \"value/max\" with steps."
|
|
2557
|
+
},
|
|
2558
|
+
{
|
|
2559
|
+
"name": "steps",
|
|
2560
|
+
"type": "boolean",
|
|
2561
|
+
"required": false,
|
|
2562
|
+
"description": "The step variant: counts completed steps out of max, such as 0/5 for the setup guide. Implies showValue."
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
"name": "aria-label",
|
|
2566
|
+
"type": "string",
|
|
2567
|
+
"required": false,
|
|
2568
|
+
"description": "The accessible name when there is no visible label."
|
|
1003
2569
|
}
|
|
1004
2570
|
],
|
|
1005
2571
|
"usage": {
|
|
1006
|
-
"whenToUse": "- A
|
|
1007
|
-
"whenNotToUse": "- A
|
|
1008
|
-
"example": "<
|
|
2572
|
+
"whenToUse": "- A page load or a refetch of content already on screen (the thin 2px bar, question 5)\n- The setup guide's step count, with the steps variant (\"0/5\")",
|
|
2573
|
+
"whenNotToUse": "- A first load of a list or table: use Skeleton rows\n- A short wait on one control: use Spinner",
|
|
2574
|
+
"example": "```tsx\n<Progress label=\"Loading orders\" value={60} showValue />\n<Progress label=\"Setup guide\" value={0} max={5} steps />\n<Progress aria-label=\"Refreshing\" />\n```\n\nWithout a value the bar is indeterminate: a static partial bar, since the loading animation token is none."
|
|
2575
|
+
}
|
|
2576
|
+
},
|
|
2577
|
+
{
|
|
2578
|
+
"name": "RadioGroup",
|
|
2579
|
+
"import": "import { RadioGroup } from '@ratio-ui/core'",
|
|
2580
|
+
"description": "A column of radio buttons where exactly one can be on. The arrow keys move the choice. aria-invalid on the group, as Field sets it, draws the error ring on every item.",
|
|
2581
|
+
"props": [],
|
|
2582
|
+
"usage": {
|
|
2583
|
+
"whenToUse": "- One choice among a few options that all deserve to be seen at once, such as a plan or a delivery method\n- A form field where the answer is exactly one of two to five values",
|
|
2584
|
+
"whenNotToUse": "- Several answers can be on: use checkboxes\n- A setting that applies at once: use a switch\n- A long list of options: use a select\n- Styling: RadioGroup and RadioGroupItem take no `className` and no `style`",
|
|
2585
|
+
"example": "```tsx\n<RadioGroup aria-label=\"Plan\" value={plan} onValueChange={setPlan}>\n <Inline gap={8} align=\"center\">\n <RadioGroupItem id=\"plan-free\" value=\"free\" />\n <Label htmlFor=\"plan-free\">Free</Label>\n </Inline>\n <Inline gap={8} align=\"center\">\n <RadioGroupItem id=\"plan-pro\" value=\"pro\" />\n <Label htmlFor=\"plan-pro\">Pro</Label>\n </Inline>\n</RadioGroup>\n```\n\nGive every item an `id` and a visible `Label` that points at it, so the text people read is the radio's name."
|
|
1009
2586
|
},
|
|
1010
2587
|
"parts": [
|
|
1011
2588
|
{
|
|
1012
|
-
"name": "
|
|
1013
|
-
"import": "import {
|
|
1014
|
-
"description": "
|
|
2589
|
+
"name": "RadioGroupItem",
|
|
2590
|
+
"import": "import { RadioGroupItem } from '@ratio-ui/core'",
|
|
2591
|
+
"description": "One choice in a RadioGroup: a 14px round control like the checkbox, drawn with a hairline ring and filled in the primary colour with a white dot when chosen. An invisible 24px area around it takes the tap.",
|
|
1015
2592
|
"props": []
|
|
1016
2593
|
}
|
|
1017
2594
|
]
|
|
1018
2595
|
},
|
|
1019
2596
|
{
|
|
1020
|
-
"name": "
|
|
1021
|
-
"import": "import {
|
|
1022
|
-
"description": "
|
|
2597
|
+
"name": "SaveBar",
|
|
2598
|
+
"import": "import { SaveBar } from '@ratio-ui/core'",
|
|
2599
|
+
"description": "The bar that appears under the top bar when a form is dirty: a message, Discard and Save. It renders in flow, so the page (AppShell) decides where it sits. While saving, Save is disabled; Discard only calls onDiscard.",
|
|
1023
2600
|
"props": [
|
|
1024
2601
|
{
|
|
1025
|
-
"name": "
|
|
1026
|
-
"type": "
|
|
2602
|
+
"name": "dirty",
|
|
2603
|
+
"type": "boolean",
|
|
2604
|
+
"required": true,
|
|
2605
|
+
"description": "Whether the form has unsaved changes. The bar renders nothing when false."
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
"name": "saving",
|
|
2609
|
+
"type": "boolean",
|
|
2610
|
+
"required": false,
|
|
2611
|
+
"default": "false",
|
|
2612
|
+
"description": "True while the save is running: Save is disabled and reads the saving label."
|
|
2613
|
+
},
|
|
2614
|
+
{
|
|
2615
|
+
"name": "onSave",
|
|
2616
|
+
"type": "() => void",
|
|
1027
2617
|
"required": true,
|
|
1028
|
-
"description": "
|
|
2618
|
+
"description": "Called by Save."
|
|
1029
2619
|
},
|
|
1030
2620
|
{
|
|
1031
|
-
"name": "
|
|
1032
|
-
"type": "
|
|
2621
|
+
"name": "onDiscard",
|
|
2622
|
+
"type": "() => void",
|
|
1033
2623
|
"required": true,
|
|
1034
|
-
"description": "The
|
|
2624
|
+
"description": "Called by Discard. The bar asks nothing itself: confirm in the caller if you need to."
|
|
2625
|
+
},
|
|
2626
|
+
{
|
|
2627
|
+
"name": "message",
|
|
2628
|
+
"type": "ReactNode",
|
|
2629
|
+
"required": false,
|
|
2630
|
+
"default": "Unsaved changes",
|
|
2631
|
+
"description": "The message. Defaults to \"Unsaved changes\"."
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
"name": "saveLabel",
|
|
2635
|
+
"type": "ReactNode",
|
|
2636
|
+
"required": false,
|
|
2637
|
+
"default": "Save",
|
|
2638
|
+
"description": "The Save label. Defaults to \"Save\"."
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
"name": "savingLabel",
|
|
2642
|
+
"type": "ReactNode",
|
|
2643
|
+
"required": false,
|
|
2644
|
+
"default": "Saving…",
|
|
2645
|
+
"description": "The Save label while saving. Defaults to \"Saving…\"."
|
|
2646
|
+
},
|
|
2647
|
+
{
|
|
2648
|
+
"name": "discardLabel",
|
|
2649
|
+
"type": "ReactNode",
|
|
2650
|
+
"required": false,
|
|
2651
|
+
"default": "Discard",
|
|
2652
|
+
"description": "The Discard label. Defaults to \"Discard\"."
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
"name": "ref",
|
|
2656
|
+
"type": "Ref<HTMLDivElement>",
|
|
2657
|
+
"required": false,
|
|
2658
|
+
"description": "Receives the rendered div."
|
|
1035
2659
|
}
|
|
1036
2660
|
],
|
|
1037
2661
|
"usage": {
|
|
1038
|
-
"whenToUse": "-
|
|
1039
|
-
"whenNotToUse": "-
|
|
1040
|
-
"example": "
|
|
2662
|
+
"whenToUse": "- Under the top bar of a form page, when the form has unsaved changes: \"Unsaved changes\", Discard, Save\n- Drive `dirty` from the form's dirty state and `saving` from the pending save",
|
|
2663
|
+
"whenNotToUse": "- A confirmation: Discard only calls `onDiscard`; open an AlertDialog yourself if the loss needs confirming\n- Per-field saving: save on change or use the field's own action",
|
|
2664
|
+
"example": "```tsx\n<SaveBar dirty={form.isDirty} saving={form.isSaving} onSave={form.save} onDiscard={form.reset} />\n```\n\nIt renders in flow and nothing when not dirty; the app shell decides where it sits. While saving, Save is disabled."
|
|
1041
2665
|
}
|
|
1042
2666
|
},
|
|
1043
2667
|
{
|
|
1044
|
-
"name": "
|
|
1045
|
-
"import": "import {
|
|
1046
|
-
"description": "A
|
|
2668
|
+
"name": "ScrollArea",
|
|
2669
|
+
"import": "import { ScrollArea } from '@ratio-ui/core'",
|
|
2670
|
+
"description": "A scrolling region that fills its parent, which sets the height or width, with a thin scrollbar in the design system greys.",
|
|
1047
2671
|
"props": [
|
|
1048
2672
|
{
|
|
1049
|
-
"name": "
|
|
1050
|
-
"type": "
|
|
2673
|
+
"name": "children",
|
|
2674
|
+
"type": "ReactNode",
|
|
1051
2675
|
"required": true,
|
|
1052
|
-
"description": "The
|
|
2676
|
+
"description": "The scrolling content."
|
|
1053
2677
|
},
|
|
1054
2678
|
{
|
|
1055
|
-
"name": "
|
|
1056
|
-
"type": "
|
|
2679
|
+
"name": "orientation",
|
|
2680
|
+
"type": "\"both\" | \"horizontal\" | \"vertical\"",
|
|
1057
2681
|
"required": false,
|
|
1058
|
-
"
|
|
2682
|
+
"default": "vertical",
|
|
2683
|
+
"description": "Which scrollbars to offer. Defaults to vertical."
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
"name": "ref",
|
|
2687
|
+
"type": "Ref<HTMLDivElement>",
|
|
2688
|
+
"required": false,
|
|
2689
|
+
"description": "Receives the rendered element."
|
|
1059
2690
|
}
|
|
1060
2691
|
],
|
|
1061
2692
|
"usage": {
|
|
1062
|
-
"whenToUse": "- A
|
|
1063
|
-
"whenNotToUse": "-
|
|
1064
|
-
"example": "<
|
|
2693
|
+
"whenToUse": "- A bounded region (a list, a panel body) that scrolls inside a fixed height or width",
|
|
2694
|
+
"whenNotToUse": "- The page itself: let the page scroll",
|
|
2695
|
+
"example": "<div style={{ height: 240 }}>\n <ScrollArea>{rows}</ScrollArea>\n</div>"
|
|
1065
2696
|
}
|
|
1066
2697
|
},
|
|
1067
2698
|
{
|
|
1068
|
-
"name": "
|
|
1069
|
-
"import": "import {
|
|
1070
|
-
"description": "The
|
|
2699
|
+
"name": "SearchField",
|
|
2700
|
+
"import": "import { SearchField } from '@ratio-ui/core'",
|
|
2701
|
+
"description": "The search field above a listing: a search icon, the input and a clear button that appears once there is text. Escape clears it too. The field reports every change; the debounce stays in the app.",
|
|
1071
2702
|
"props": [
|
|
1072
2703
|
{
|
|
1073
|
-
"name": "
|
|
2704
|
+
"name": "label",
|
|
1074
2705
|
"type": "string",
|
|
1075
2706
|
"required": true,
|
|
1076
|
-
"description": "The
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
"name": "icon",
|
|
1080
|
-
"type": "ReactNode",
|
|
1081
|
-
"required": false,
|
|
1082
|
-
"description": "An icon or logo shown before the title."
|
|
2707
|
+
"description": "The accessible name of the field, such as \"Search products\". Required because the field has no visible label."
|
|
1083
2708
|
},
|
|
1084
2709
|
{
|
|
1085
|
-
"name": "
|
|
1086
|
-
"type": "
|
|
2710
|
+
"name": "value",
|
|
2711
|
+
"type": "string",
|
|
1087
2712
|
"required": false,
|
|
1088
|
-
"description": "The
|
|
2713
|
+
"description": "The text in the field. Pass it with onValueChange to control the field."
|
|
1089
2714
|
},
|
|
1090
2715
|
{
|
|
1091
|
-
"name": "
|
|
2716
|
+
"name": "defaultValue",
|
|
1092
2717
|
"type": "string",
|
|
1093
2718
|
"required": false,
|
|
1094
|
-
"
|
|
2719
|
+
"default": "",
|
|
2720
|
+
"description": "The starting text of an uncontrolled field."
|
|
1095
2721
|
},
|
|
1096
2722
|
{
|
|
1097
|
-
"name": "
|
|
1098
|
-
"type": "string",
|
|
2723
|
+
"name": "onValueChange",
|
|
2724
|
+
"type": "((value: string) => void)",
|
|
1099
2725
|
"required": false,
|
|
1100
|
-
"
|
|
1101
|
-
"description": "The text of the back link, such as the parent page's name. Defaults to Back."
|
|
2726
|
+
"description": "Called with the new text on every change and when the field is cleared. It is not debounced: debounce in the app."
|
|
1102
2727
|
},
|
|
1103
2728
|
{
|
|
1104
|
-
"name": "
|
|
1105
|
-
"type": "
|
|
2729
|
+
"name": "size",
|
|
2730
|
+
"type": "32 | 36",
|
|
1106
2731
|
"required": false,
|
|
1107
|
-
"
|
|
2732
|
+
"default": "36",
|
|
2733
|
+
"description": "The height in px: 36 above a listing, 32 inside a table. Defaults to 36."
|
|
1108
2734
|
},
|
|
1109
2735
|
{
|
|
1110
|
-
"name": "
|
|
1111
|
-
"type": "
|
|
2736
|
+
"name": "ref",
|
|
2737
|
+
"type": "Ref<HTMLInputElement>",
|
|
1112
2738
|
"required": false,
|
|
1113
|
-
"description": "
|
|
2739
|
+
"description": "Receives the input element."
|
|
1114
2740
|
}
|
|
1115
2741
|
],
|
|
1116
2742
|
"usage": {
|
|
1117
|
-
"whenToUse": "- The
|
|
1118
|
-
"whenNotToUse": "- A
|
|
1119
|
-
"example": "<
|
|
2743
|
+
"whenToUse": "- The search above a listing or inside a table, where typing narrows the rows\n- A field that needs a clear button and Escape to clear",
|
|
2744
|
+
"whenNotToUse": "- A search across the whole product from the top bar: use GlobalSearch\n- A field that must wait before searching: debounce in the app, the field reports every keystroke",
|
|
2745
|
+
"example": "<SearchField label=\"Search products\" placeholder=\"Search by name, SKU\" value={query} onValueChange={setQuery} />"
|
|
1120
2746
|
}
|
|
1121
2747
|
},
|
|
1122
2748
|
{
|
|
1123
|
-
"name": "
|
|
1124
|
-
"import": "import {
|
|
1125
|
-
"description": "
|
|
1126
|
-
"props": [
|
|
2749
|
+
"name": "Select",
|
|
2750
|
+
"import": "import { Select } from '@ratio-ui/core'",
|
|
2751
|
+
"description": "A choice from a fixed list. Pass items ({ label, value }[]) so the trigger shows the label of the chosen value. Put a SelectTrigger and a SelectContent inside it.",
|
|
2752
|
+
"props": [],
|
|
2753
|
+
"usage": {
|
|
2754
|
+
"whenToUse": "- A choice from a short, fixed list in a form, such as a GST rate (0, 5, 12, 18, 28%), a return window or a status\n- A field in a table cell: `size={32}` on the trigger\n- A form row with a label, hint, error or required mark: put the Select inside a Field with a function child (see below)",
|
|
2755
|
+
"whenNotToUse": "- A long list, or one the user searches: use a combobox\n- Free text or several values (tags): use Input or TagInput\n- A menu of actions: use DropdownMenu\n- Custom classes or inline styles: no part takes `className` or `style`",
|
|
2756
|
+
"example": "```tsx\nconst rates = [\n { label: '0%', value: '0' },\n { label: '18%', value: '18' },\n]\n\n<Select items={rates} defaultValue=\"18\">\n <SelectTrigger aria-label=\"GST rate\">\n <SelectValue placeholder=\"Choose a rate\" />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n <SelectLabel>Rates</SelectLabel>\n <SelectItem value=\"0\">0%</SelectItem>\n <SelectItem value=\"18\">18%</SelectItem>\n </SelectGroup>\n </SelectContent>\n</Select>\n```\n\nPass `items` to `Select` so the trigger shows the label, not the raw value."
|
|
2757
|
+
},
|
|
2758
|
+
"parts": [
|
|
1127
2759
|
{
|
|
1128
|
-
"name": "
|
|
1129
|
-
"
|
|
1130
|
-
"
|
|
1131
|
-
"
|
|
2760
|
+
"name": "SelectContent",
|
|
2761
|
+
"import": "import { SelectContent } from '@ratio-ui/core'",
|
|
2762
|
+
"description": "The list: the popover look (8px radius, outline, no shadow, 6px 0 padding), as wide as the trigger. It opens below the trigger.",
|
|
2763
|
+
"props": [
|
|
2764
|
+
{
|
|
2765
|
+
"name": "render",
|
|
2766
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectPopupState>",
|
|
2767
|
+
"required": false,
|
|
2768
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2769
|
+
}
|
|
2770
|
+
]
|
|
1132
2771
|
},
|
|
1133
2772
|
{
|
|
1134
|
-
"name": "
|
|
1135
|
-
"
|
|
1136
|
-
"
|
|
1137
|
-
"
|
|
2773
|
+
"name": "SelectGroup",
|
|
2774
|
+
"import": "import { SelectGroup } from '@ratio-ui/core'",
|
|
2775
|
+
"description": "Groups related options under a SelectLabel.",
|
|
2776
|
+
"props": [
|
|
2777
|
+
{
|
|
2778
|
+
"name": "render",
|
|
2779
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectGroupState>",
|
|
2780
|
+
"required": false,
|
|
2781
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2782
|
+
}
|
|
2783
|
+
]
|
|
1138
2784
|
},
|
|
1139
2785
|
{
|
|
1140
|
-
"name": "
|
|
1141
|
-
"
|
|
1142
|
-
"
|
|
1143
|
-
"
|
|
2786
|
+
"name": "SelectItem",
|
|
2787
|
+
"import": "import { SelectItem } from '@ratio-ui/core'",
|
|
2788
|
+
"description": "One option. The highlighted one has the accent background, the chosen one a check at its end, a disabled one is dimmed and cannot be chosen.",
|
|
2789
|
+
"props": [
|
|
2790
|
+
{
|
|
2791
|
+
"name": "render",
|
|
2792
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectItemState>",
|
|
2793
|
+
"required": false,
|
|
2794
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2795
|
+
}
|
|
2796
|
+
]
|
|
1144
2797
|
},
|
|
1145
2798
|
{
|
|
1146
|
-
"name": "
|
|
1147
|
-
"
|
|
1148
|
-
"
|
|
1149
|
-
"
|
|
2799
|
+
"name": "SelectLabel",
|
|
2800
|
+
"import": "import { SelectLabel } from '@ratio-ui/core'",
|
|
2801
|
+
"description": "The heading of a group, in the muted colour.",
|
|
2802
|
+
"props": [
|
|
2803
|
+
{
|
|
2804
|
+
"name": "render",
|
|
2805
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectGroupLabelState>",
|
|
2806
|
+
"required": false,
|
|
2807
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2808
|
+
}
|
|
2809
|
+
]
|
|
2810
|
+
},
|
|
2811
|
+
{
|
|
2812
|
+
"name": "SelectSeparator",
|
|
2813
|
+
"import": "import { SelectSeparator } from '@ratio-ui/core'",
|
|
2814
|
+
"description": "A hairline between groups.",
|
|
2815
|
+
"props": [
|
|
2816
|
+
{
|
|
2817
|
+
"name": "render",
|
|
2818
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectSeparatorState>",
|
|
2819
|
+
"required": false,
|
|
2820
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2821
|
+
}
|
|
2822
|
+
]
|
|
2823
|
+
},
|
|
2824
|
+
{
|
|
2825
|
+
"name": "SelectTrigger",
|
|
2826
|
+
"import": "import { SelectTrigger } from '@ratio-ui/core'",
|
|
2827
|
+
"description": "The closed field: the chosen value (or the placeholder) and a chevron at the right. Put a SelectValue inside it.",
|
|
2828
|
+
"props": [
|
|
2829
|
+
{
|
|
2830
|
+
"name": "render",
|
|
2831
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectTriggerState>",
|
|
2832
|
+
"required": false,
|
|
2833
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2834
|
+
},
|
|
2835
|
+
{
|
|
2836
|
+
"name": "size",
|
|
2837
|
+
"type": "32 | 36",
|
|
2838
|
+
"required": false,
|
|
2839
|
+
"default": "36",
|
|
2840
|
+
"description": "The height in px: 36 for forms, 32 inside a table. Defaults to 36."
|
|
2841
|
+
}
|
|
2842
|
+
]
|
|
2843
|
+
},
|
|
2844
|
+
{
|
|
2845
|
+
"name": "SelectValue",
|
|
2846
|
+
"import": "import { SelectValue } from '@ratio-ui/core'",
|
|
2847
|
+
"description": "Shows the label of the chosen option inside the trigger, or the placeholder while nothing is chosen.",
|
|
2848
|
+
"props": [
|
|
2849
|
+
{
|
|
2850
|
+
"name": "render",
|
|
2851
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, SelectValueState>",
|
|
2852
|
+
"required": false,
|
|
2853
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2854
|
+
}
|
|
2855
|
+
]
|
|
2856
|
+
}
|
|
2857
|
+
]
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
"name": "Separator",
|
|
2861
|
+
"import": "import { Separator } from '@ratio-ui/core'",
|
|
2862
|
+
"description": "A 1px hairline in the divider grey, horizontal or vertical. A horizontal line fills its row and shrinks to share it, so two lines and a word between them in an Inline make the \"or\" divider; a vertical line keeps its 1px.",
|
|
2863
|
+
"props": [
|
|
2864
|
+
{
|
|
2865
|
+
"name": "orientation",
|
|
2866
|
+
"type": "\"horizontal\" | \"vertical\"",
|
|
2867
|
+
"required": false,
|
|
2868
|
+
"default": "horizontal",
|
|
2869
|
+
"description": "The direction of the line. Defaults to horizontal."
|
|
2870
|
+
},
|
|
2871
|
+
{
|
|
2872
|
+
"name": "decorative",
|
|
2873
|
+
"type": "boolean",
|
|
2874
|
+
"required": false,
|
|
2875
|
+
"default": "true",
|
|
2876
|
+
"description": "True, the default, hides the line from assistive technology; false makes it a semantic separator."
|
|
2877
|
+
},
|
|
2878
|
+
{
|
|
2879
|
+
"name": "ref",
|
|
2880
|
+
"type": "Ref<HTMLDivElement>",
|
|
2881
|
+
"required": false,
|
|
2882
|
+
"description": "Receives the rendered element."
|
|
1150
2883
|
}
|
|
1151
2884
|
],
|
|
1152
2885
|
"usage": {
|
|
1153
|
-
"whenToUse": "-
|
|
1154
|
-
"whenNotToUse": "-
|
|
1155
|
-
"example": "
|
|
2886
|
+
"whenToUse": "- A hairline between groups of content, or the \"or\" divider on the login screen\n- A vertical hairline between inline items",
|
|
2887
|
+
"whenNotToUse": "- A card or table edge: those own their border",
|
|
2888
|
+
"example": "```tsx\n<Separator />\n<Inline gap={8}>\n <Separator />\n <Text variant=\"c1\" tone=\"muted\">or</Text>\n <Separator />\n</Inline>\n<Separator orientation=\"vertical\" />\n<Separator decorative={false} />\n```\n\nIn the \"or\" divider the two lines share the row and the word keeps its width. Keep the word short: a longer phrase wraps before the lines give way."
|
|
1156
2889
|
}
|
|
1157
2890
|
},
|
|
1158
2891
|
{
|
|
1159
|
-
"name": "
|
|
1160
|
-
"import": "import {
|
|
1161
|
-
"description": "
|
|
2892
|
+
"name": "Sheet",
|
|
2893
|
+
"import": "import { Sheet } from '@ratio-ui/core'",
|
|
2894
|
+
"description": "The root of a sheet. It holds the open state and renders nothing itself. Pass `open` and `onOpenChange` to control it, or `defaultOpen` to leave it uncontrolled. The page behind is inert while it is open, with no scrim over it.",
|
|
1162
2895
|
"props": [],
|
|
1163
2896
|
"usage": {
|
|
1164
|
-
"whenToUse": "- A
|
|
1165
|
-
"whenNotToUse": "- A
|
|
1166
|
-
"example": "<
|
|
2897
|
+
"whenToUse": "- A bottom sheet for a large surface that sits over the page, such as Settings: it spans the screen and has 24px top corners\n- A side sheet for a panel that keeps the page in view, such as filters or the phone navigation\n- Work that needs more room than a 480px dialog",
|
|
2898
|
+
"whenNotToUse": "- A short task or a confirm step: use a Dialog\n- A panel people swipe away on a phone: use a Drawer\n- Help text on a control: use a Tooltip or Popover",
|
|
2899
|
+
"example": "<Sheet>\n <SheetTrigger>Settings</SheetTrigger>\n <SheetContent side=\"bottom\" closeLabel=\"Close settings\">\n <SheetHeader>\n <SheetTitle>General</SheetTitle>\n <SheetDescription>Store name, contact and address</SheetDescription>\n </SheetHeader>\n <SheetBody>Store details</SheetBody>\n <SheetFooter>\n <SheetClose>Done</SheetClose>\n </SheetFooter>\n </SheetContent>\n</Sheet>"
|
|
1167
2900
|
},
|
|
1168
2901
|
"parts": [
|
|
1169
2902
|
{
|
|
1170
|
-
"name": "
|
|
1171
|
-
"import": "import {
|
|
1172
|
-
"description": "The
|
|
2903
|
+
"name": "SheetBody",
|
|
2904
|
+
"import": "import { SheetBody } from '@ratio-ui/core'",
|
|
2905
|
+
"description": "The content between header and footer. It takes the free height and scrolls when the content is taller.",
|
|
2906
|
+
"props": []
|
|
2907
|
+
},
|
|
2908
|
+
{
|
|
2909
|
+
"name": "SheetClose",
|
|
2910
|
+
"import": "import { SheetClose } from '@ratio-ui/core'",
|
|
2911
|
+
"description": "A button that closes the sheet, such as Done in the footer.",
|
|
1173
2912
|
"props": [
|
|
1174
2913
|
{
|
|
1175
2914
|
"name": "render",
|
|
1176
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps,
|
|
2915
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogCloseState>",
|
|
1177
2916
|
"required": false,
|
|
1178
2917
|
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1179
2918
|
}
|
|
1180
2919
|
]
|
|
1181
2920
|
},
|
|
1182
2921
|
{
|
|
1183
|
-
"name": "
|
|
1184
|
-
"import": "import {
|
|
1185
|
-
"description": "The
|
|
2922
|
+
"name": "SheetContent",
|
|
2923
|
+
"import": "import { SheetContent } from '@ratio-ui/core'",
|
|
2924
|
+
"description": "The panel, white with a hairline on its inner edge. A side sheet is full height and three quarters of a phone screen, 384px from the small breakpoint up; a bottom sheet spans the screen, sizes to its content and has 24px top corners. It appears without sliding and with no scrim, blur or shadow. Put SheetHeader, SheetBody and SheetFooter inside.",
|
|
2925
|
+
"props": [
|
|
2926
|
+
{
|
|
2927
|
+
"name": "side",
|
|
2928
|
+
"type": "\"bottom\" | \"left\" | \"right\"",
|
|
2929
|
+
"required": false,
|
|
2930
|
+
"default": "right",
|
|
2931
|
+
"description": "The edge the sheet sits on: a full-height side sheet, or a bottom sheet with 24px top corners. Defaults to right."
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
"name": "showCloseButton",
|
|
2935
|
+
"type": "boolean",
|
|
2936
|
+
"required": false,
|
|
2937
|
+
"default": "true",
|
|
2938
|
+
"description": "Whether the corner close button shows. Defaults to true."
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
"name": "closeLabel",
|
|
2942
|
+
"type": "string",
|
|
2943
|
+
"required": false,
|
|
2944
|
+
"default": "Close",
|
|
2945
|
+
"description": "The accessible name of the corner close button. Defaults to Close."
|
|
2946
|
+
},
|
|
2947
|
+
{
|
|
2948
|
+
"name": "render",
|
|
2949
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogPopupState>",
|
|
2950
|
+
"required": false,
|
|
2951
|
+
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
2952
|
+
}
|
|
2953
|
+
]
|
|
2954
|
+
},
|
|
2955
|
+
{
|
|
2956
|
+
"name": "SheetDescription",
|
|
2957
|
+
"import": "import { SheetDescription } from '@ratio-ui/core'",
|
|
2958
|
+
"description": "One line that says what the sheet is for, in subdued body text.",
|
|
1186
2959
|
"props": [
|
|
1187
2960
|
{
|
|
1188
2961
|
"name": "render",
|
|
1189
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps,
|
|
2962
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogDescriptionState>",
|
|
1190
2963
|
"required": false,
|
|
1191
2964
|
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1192
2965
|
}
|
|
1193
2966
|
]
|
|
1194
2967
|
},
|
|
1195
2968
|
{
|
|
1196
|
-
"name": "
|
|
1197
|
-
"import": "import {
|
|
1198
|
-
"description": "
|
|
2969
|
+
"name": "SheetFooter",
|
|
2970
|
+
"import": "import { SheetFooter } from '@ratio-ui/core'",
|
|
2971
|
+
"description": "The row of actions at the bottom of the sheet, aligned to the end.",
|
|
1199
2972
|
"props": []
|
|
1200
2973
|
},
|
|
1201
2974
|
{
|
|
1202
|
-
"name": "
|
|
1203
|
-
"import": "import {
|
|
1204
|
-
"description": "The title
|
|
2975
|
+
"name": "SheetHeader",
|
|
2976
|
+
"import": "import { SheetHeader } from '@ratio-ui/core'",
|
|
2977
|
+
"description": "The title and description, stacked, with room on the right for the close button.",
|
|
2978
|
+
"props": []
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
"name": "SheetTitle",
|
|
2982
|
+
"import": "import { SheetTitle } from '@ratio-ui/core'",
|
|
2983
|
+
"description": "The sheet's name, in the b4 style. It names the sheet for assistive technology.",
|
|
1205
2984
|
"props": [
|
|
1206
2985
|
{
|
|
1207
2986
|
"name": "render",
|
|
1208
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps,
|
|
2987
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTitleState>",
|
|
1209
2988
|
"required": false,
|
|
1210
2989
|
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1211
2990
|
}
|
|
1212
2991
|
]
|
|
1213
2992
|
},
|
|
1214
2993
|
{
|
|
1215
|
-
"name": "
|
|
1216
|
-
"import": "import {
|
|
1217
|
-
"description": "The
|
|
2994
|
+
"name": "SheetTrigger",
|
|
2995
|
+
"import": "import { SheetTrigger } from '@ratio-ui/core'",
|
|
2996
|
+
"description": "The button that opens the sheet.",
|
|
1218
2997
|
"props": [
|
|
1219
2998
|
{
|
|
1220
2999
|
"name": "render",
|
|
1221
|
-
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps,
|
|
3000
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, DialogTriggerState>",
|
|
1222
3001
|
"required": false,
|
|
1223
3002
|
"description": "Allows you to replace the component's HTML element with a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
"name": "handle",
|
|
1227
|
-
"type": "PopoverHandle<unknown>",
|
|
1228
|
-
"required": false,
|
|
1229
|
-
"description": "A handle to associate the trigger with a popover."
|
|
1230
|
-
},
|
|
1231
|
-
{
|
|
1232
|
-
"name": "payload",
|
|
1233
|
-
"type": "unknown",
|
|
1234
|
-
"required": false,
|
|
1235
|
-
"description": "A payload to pass to the popover when it is opened."
|
|
1236
|
-
},
|
|
1237
|
-
{
|
|
1238
|
-
"name": "delay",
|
|
1239
|
-
"type": "number",
|
|
1240
|
-
"required": false,
|
|
1241
|
-
"default": "300",
|
|
1242
|
-
"description": "How long to wait before the popover may be opened on hover. Specified in milliseconds.\n\nRequires the `openOnHover` prop."
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
"name": "closeDelay",
|
|
1246
|
-
"type": "number",
|
|
1247
|
-
"required": false,
|
|
1248
|
-
"default": "0",
|
|
1249
|
-
"description": "How long to wait before closing the popover that was opened on hover. Specified in milliseconds.\n\nRequires the `openOnHover` prop."
|
|
1250
|
-
},
|
|
1251
|
-
{
|
|
1252
|
-
"name": "openOnHover",
|
|
1253
|
-
"type": "boolean",
|
|
1254
|
-
"required": false,
|
|
1255
|
-
"default": "false",
|
|
1256
|
-
"description": "Whether the popover should also open when the trigger is hovered."
|
|
1257
3003
|
}
|
|
1258
3004
|
]
|
|
1259
3005
|
}
|
|
1260
3006
|
]
|
|
1261
3007
|
},
|
|
1262
|
-
{
|
|
1263
|
-
"name": "SearchField",
|
|
1264
|
-
"import": "import { SearchField } from '@ratio-ui/core'",
|
|
1265
|
-
"description": "The search field above a listing: a search icon, the input and a clear button that appears once there is text. Escape clears it too. The field reports every change; the debounce stays in the app.",
|
|
1266
|
-
"props": [
|
|
1267
|
-
{
|
|
1268
|
-
"name": "label",
|
|
1269
|
-
"type": "string",
|
|
1270
|
-
"required": true,
|
|
1271
|
-
"description": "The accessible name of the field, such as \"Search products\". Required because the field has no visible label."
|
|
1272
|
-
},
|
|
1273
|
-
{
|
|
1274
|
-
"name": "value",
|
|
1275
|
-
"type": "string",
|
|
1276
|
-
"required": false,
|
|
1277
|
-
"description": "The text in the field. Pass it with onValueChange to control the field."
|
|
1278
|
-
},
|
|
1279
|
-
{
|
|
1280
|
-
"name": "defaultValue",
|
|
1281
|
-
"type": "string",
|
|
1282
|
-
"required": false,
|
|
1283
|
-
"default": "",
|
|
1284
|
-
"description": "The starting text of an uncontrolled field."
|
|
1285
|
-
},
|
|
1286
|
-
{
|
|
1287
|
-
"name": "onValueChange",
|
|
1288
|
-
"type": "((value: string) => void)",
|
|
1289
|
-
"required": false,
|
|
1290
|
-
"description": "Called with the new text on every change and when the field is cleared. It is not debounced: debounce in the app."
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
"name": "size",
|
|
1294
|
-
"type": "32 | 36",
|
|
1295
|
-
"required": false,
|
|
1296
|
-
"default": "36",
|
|
1297
|
-
"description": "The height in px: 36 above a listing, 32 inside a table. Defaults to 36."
|
|
1298
|
-
},
|
|
1299
|
-
{
|
|
1300
|
-
"name": "ref",
|
|
1301
|
-
"type": "Ref<HTMLInputElement>",
|
|
1302
|
-
"required": false,
|
|
1303
|
-
"description": "Receives the input element."
|
|
1304
|
-
}
|
|
1305
|
-
],
|
|
1306
|
-
"usage": {
|
|
1307
|
-
"whenToUse": "- The search above a listing or inside a table, where typing narrows the rows\n- A field that needs a clear button and Escape to clear",
|
|
1308
|
-
"whenNotToUse": "- A search across the whole product from the top bar: use GlobalSearch\n- A field that must wait before searching: debounce in the app, the field reports every keystroke",
|
|
1309
|
-
"example": "<SearchField label=\"Search products\" placeholder=\"Search by name, SKU\" value={query} onValueChange={setQuery} />"
|
|
1310
|
-
}
|
|
1311
|
-
},
|
|
1312
3008
|
{
|
|
1313
3009
|
"name": "SideNav",
|
|
1314
3010
|
"import": "import { SideNav } from '@ratio-ui/core'",
|
|
@@ -1470,6 +3166,41 @@
|
|
|
1470
3166
|
"example": "<StatusPill tone=\"success\">Active</StatusPill>"
|
|
1471
3167
|
}
|
|
1472
3168
|
},
|
|
3169
|
+
{
|
|
3170
|
+
"name": "SummaryChips",
|
|
3171
|
+
"import": "import { SummaryChips } from '@ratio-ui/core'",
|
|
3172
|
+
"description": "A row of 20px chips that summarise values, such as the ones a collapsed section still shows.",
|
|
3173
|
+
"props": [
|
|
3174
|
+
{
|
|
3175
|
+
"name": "items",
|
|
3176
|
+
"type": "readonly SummaryChip[]",
|
|
3177
|
+
"required": true,
|
|
3178
|
+
"description": "The chips, in order. Nothing is rendered when empty."
|
|
3179
|
+
},
|
|
3180
|
+
{
|
|
3181
|
+
"name": "ref",
|
|
3182
|
+
"type": "Ref<HTMLUListElement>",
|
|
3183
|
+
"required": false,
|
|
3184
|
+
"description": "Receives the rendered list."
|
|
3185
|
+
}
|
|
3186
|
+
],
|
|
3187
|
+
"usage": {
|
|
3188
|
+
"whenToUse": "- A collapsed section that still shows its values: \"Cost price · HSN code · Includes GST Yes\"\n- A short read-only summary of a record's settings",
|
|
3189
|
+
"whenNotToUse": "- Values the person can edit or remove: use a tag input\n- A status of a row: use StatusPill",
|
|
3190
|
+
"example": "<SummaryChips items={[{ label: 'Cost price', value: '₹450.00' }, { label: 'Includes GST', value: 'Yes' }]} />"
|
|
3191
|
+
}
|
|
3192
|
+
},
|
|
3193
|
+
{
|
|
3194
|
+
"name": "Switch",
|
|
3195
|
+
"import": "import { Switch } from '@ratio-ui/core'",
|
|
3196
|
+
"description": "An on/off switch, 32px by 18px. Off it is drawn with the control hairline; on it is filled in the primary colour. In forced-colours mode the thumb keeps a system-colour outline, and its side shows the state. The thumb jumps to the other end with no slide, and colours fade over 120ms.",
|
|
3197
|
+
"props": [],
|
|
3198
|
+
"usage": {
|
|
3199
|
+
"whenToUse": "- An on/off setting that takes effect as soon as it changes, such as \"Inventory tracked\" or \"Cash on delivery\"\n- Give it an `aria-label`, or a label that points to it",
|
|
3200
|
+
"whenNotToUse": "- A choice that is sent with a form and several others: use Checkbox\n- Custom classes or inline styles: Switch takes no `className` and no `style`",
|
|
3201
|
+
"example": "<Switch aria-label=\"Inventory tracked\" defaultChecked />"
|
|
3202
|
+
}
|
|
3203
|
+
},
|
|
1473
3204
|
{
|
|
1474
3205
|
"name": "Table",
|
|
1475
3206
|
"import": "import { Table } from '@ratio-ui/core'",
|
|
@@ -1651,6 +3382,123 @@
|
|
|
1651
3382
|
}
|
|
1652
3383
|
]
|
|
1653
3384
|
},
|
|
3385
|
+
{
|
|
3386
|
+
"name": "TagInput",
|
|
3387
|
+
"import": "import { TagInput } from '@ratio-ui/core'",
|
|
3388
|
+
"description": "Several values as chips in one field in the input's look. The picker offers the existing values (typing filters them), a small field below adds a new one on Enter, and a chip goes with its remove button or with Backspace in the empty picker. Base UI's combobox cannot accept a value it does not list, which is why new values have their own field.",
|
|
3389
|
+
"props": [
|
|
3390
|
+
{
|
|
3391
|
+
"name": "options",
|
|
3392
|
+
"type": "readonly string[]",
|
|
3393
|
+
"required": true,
|
|
3394
|
+
"description": "The existing values the picker offers, such as S, M, L, XL and XXL."
|
|
3395
|
+
},
|
|
3396
|
+
{
|
|
3397
|
+
"name": "value",
|
|
3398
|
+
"type": "readonly string[]",
|
|
3399
|
+
"required": false,
|
|
3400
|
+
"description": "The chosen values, in order, when the owner holds the state."
|
|
3401
|
+
},
|
|
3402
|
+
{
|
|
3403
|
+
"name": "defaultValue",
|
|
3404
|
+
"type": "readonly string[]",
|
|
3405
|
+
"required": false,
|
|
3406
|
+
"description": "The values chosen at first, when the component holds the state."
|
|
3407
|
+
},
|
|
3408
|
+
{
|
|
3409
|
+
"name": "onValueChange",
|
|
3410
|
+
"type": "((value: string[]) => void)",
|
|
3411
|
+
"required": false,
|
|
3412
|
+
"description": "Called with every new list of values: after a pick, an added value or a removal."
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
"name": "creatable",
|
|
3416
|
+
"type": "boolean",
|
|
3417
|
+
"required": false,
|
|
3418
|
+
"default": "true",
|
|
3419
|
+
"description": "Shows a small field that adds a typed value on Enter. Defaults to true."
|
|
3420
|
+
},
|
|
3421
|
+
{
|
|
3422
|
+
"name": "addLabel",
|
|
3423
|
+
"type": "string",
|
|
3424
|
+
"required": false,
|
|
3425
|
+
"default": "Add value",
|
|
3426
|
+
"description": "The placeholder and accessible name of the small field. Defaults to \"Add value\"."
|
|
3427
|
+
},
|
|
3428
|
+
{
|
|
3429
|
+
"name": "placeholder",
|
|
3430
|
+
"type": "string",
|
|
3431
|
+
"required": false,
|
|
3432
|
+
"description": "The placeholder of the picker, shown while nothing is chosen."
|
|
3433
|
+
},
|
|
3434
|
+
{
|
|
3435
|
+
"name": "emptyText",
|
|
3436
|
+
"type": "string",
|
|
3437
|
+
"required": false,
|
|
3438
|
+
"default": "No matching values",
|
|
3439
|
+
"description": "The line the list shows when no value matches the typed text. Defaults to \"No matching values\"."
|
|
3440
|
+
},
|
|
3441
|
+
{
|
|
3442
|
+
"name": "name",
|
|
3443
|
+
"type": "string",
|
|
3444
|
+
"required": false,
|
|
3445
|
+
"description": "The form field name: one hidden input per chosen value is submitted under it."
|
|
3446
|
+
},
|
|
3447
|
+
{
|
|
3448
|
+
"name": "disabled",
|
|
3449
|
+
"type": "boolean",
|
|
3450
|
+
"required": false,
|
|
3451
|
+
"description": "Dims the component and stops every change."
|
|
3452
|
+
},
|
|
3453
|
+
{
|
|
3454
|
+
"name": "id",
|
|
3455
|
+
"type": "string",
|
|
3456
|
+
"required": false,
|
|
3457
|
+
"description": "The id of the picker's input, which a label points to."
|
|
3458
|
+
},
|
|
3459
|
+
{
|
|
3460
|
+
"name": "aria-label",
|
|
3461
|
+
"type": "string",
|
|
3462
|
+
"required": false,
|
|
3463
|
+
"description": "The accessible name of the picker, when no label points to it."
|
|
3464
|
+
},
|
|
3465
|
+
{
|
|
3466
|
+
"name": "aria-labelledby",
|
|
3467
|
+
"type": "string",
|
|
3468
|
+
"required": false,
|
|
3469
|
+
"description": "The id of the element that names the picker."
|
|
3470
|
+
},
|
|
3471
|
+
{
|
|
3472
|
+
"name": "aria-describedby",
|
|
3473
|
+
"type": "string",
|
|
3474
|
+
"required": false,
|
|
3475
|
+
"description": "The ids of the hint or error that describe the component."
|
|
3476
|
+
},
|
|
3477
|
+
{
|
|
3478
|
+
"name": "aria-invalid",
|
|
3479
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
3480
|
+
"required": false,
|
|
3481
|
+
"description": "Marks the values as invalid, which draws the error ring."
|
|
3482
|
+
},
|
|
3483
|
+
{
|
|
3484
|
+
"name": "aria-required",
|
|
3485
|
+
"type": "boolean | \"true\" | \"false\"",
|
|
3486
|
+
"required": false,
|
|
3487
|
+
"description": "Marks the values as required."
|
|
3488
|
+
},
|
|
3489
|
+
{
|
|
3490
|
+
"name": "ref",
|
|
3491
|
+
"type": "Ref<HTMLInputElement>",
|
|
3492
|
+
"required": false,
|
|
3493
|
+
"description": "Receives the picker's input element."
|
|
3494
|
+
}
|
|
3495
|
+
],
|
|
3496
|
+
"usage": {
|
|
3497
|
+
"whenToUse": "- Several values in one field, such as a product's tags or a variant option's values (S, M, L, XL, XXL)\n- Picking from existing values, with typing to filter them, and adding a new one in the small field below (Enter adds it)\n- Inside a Field: the label, hint, error and required mark land on the picker",
|
|
3498
|
+
"whenNotToUse": "- One value from a fixed list: use Select\n- A read-only summary of values: use SummaryChips\n- Only existing values and no new ones: keep TagInput and set `creatable={false}`\n- Custom classes or inline styles: TagInput takes no `className` and no `style`",
|
|
3499
|
+
"example": "```tsx\nconst [sizes, setSizes] = useState(['S', 'M'])\n\n<Field label=\"Size\" error={errors.size}>\n <TagInput options={['S', 'M', 'L', 'XL', 'XXL']} value={sizes} onValueChange={setSizes} placeholder=\"Choose sizes\" />\n</Field>\n```\n\nA chip goes with its remove button, or with Backspace in the empty picker. A new value is trimmed, takes the spelling of an existing value that differs only in letter case, and is not added twice. Base UI's combobox cannot accept a value it does not list, so new values have their own field."
|
|
3500
|
+
}
|
|
3501
|
+
},
|
|
1654
3502
|
{
|
|
1655
3503
|
"name": "Text",
|
|
1656
3504
|
"import": "import { Text } from '@ratio-ui/core'",
|
|
@@ -1697,6 +3545,31 @@
|
|
|
1697
3545
|
"example": "<Text as=\"h1\" variant=\"h1\">Settlements</Text>\n<Text tone=\"subdued\">Paid out every weekday</Text>"
|
|
1698
3546
|
}
|
|
1699
3547
|
},
|
|
3548
|
+
{
|
|
3549
|
+
"name": "Textarea",
|
|
3550
|
+
"import": "import { Textarea } from '@ratio-ui/core'",
|
|
3551
|
+
"description": "A multi-line text field in the input's look: 8px radius, 1px ring that turns blue on focus, 10px 12px padding, 88px tall (64px compact).",
|
|
3552
|
+
"props": [
|
|
3553
|
+
{
|
|
3554
|
+
"name": "size",
|
|
3555
|
+
"type": "64 | 88",
|
|
3556
|
+
"required": false,
|
|
3557
|
+
"default": "88",
|
|
3558
|
+
"description": "The height in px: 88 by default, 64 compact. The field can still be dragged taller."
|
|
3559
|
+
},
|
|
3560
|
+
{
|
|
3561
|
+
"name": "ref",
|
|
3562
|
+
"type": "Ref<HTMLTextAreaElement>",
|
|
3563
|
+
"required": false,
|
|
3564
|
+
"description": "Receives the textarea element."
|
|
3565
|
+
}
|
|
3566
|
+
],
|
|
3567
|
+
"usage": {
|
|
3568
|
+
"whenToUse": "- A multi-line text field such as a product description: 88px tall by default, `size={64}` for a compact one\n- A field with an error: set `aria-invalid` and the ring changes, and put the error message beside it in text",
|
|
3569
|
+
"whenNotToUse": "- A single line of text: use Input\n- Custom classes or inline styles: Textarea takes no `className` and no `style`",
|
|
3570
|
+
"example": "<Textarea aria-label=\"Description\" placeholder=\"Describe the product\" />\n<Textarea aria-label=\"Note\" size={64} />"
|
|
3571
|
+
}
|
|
3572
|
+
},
|
|
1700
3573
|
{
|
|
1701
3574
|
"name": "Toaster",
|
|
1702
3575
|
"import": "import { Toaster } from '@ratio-ui/core'",
|
|
@@ -1850,6 +3723,74 @@
|
|
|
1850
3723
|
]
|
|
1851
3724
|
}
|
|
1852
3725
|
]
|
|
3726
|
+
},
|
|
3727
|
+
{
|
|
3728
|
+
"name": "UnitInput",
|
|
3729
|
+
"import": "import { UnitInput } from '@ratio-ui/core'",
|
|
3730
|
+
"description": "A number field with its unit after it, inside one ring: a weight in kg, a length in cm. It takes and gives a number, written without thousands separators as counts are, and keeps at most `decimals` decimals.",
|
|
3731
|
+
"props": [
|
|
3732
|
+
{
|
|
3733
|
+
"name": "unit",
|
|
3734
|
+
"type": "string",
|
|
3735
|
+
"required": true,
|
|
3736
|
+
"description": "The unit after the number, such as kg or cm. Screen readers read it as the field's description."
|
|
3737
|
+
},
|
|
3738
|
+
{
|
|
3739
|
+
"name": "value",
|
|
3740
|
+
"type": "number | null",
|
|
3741
|
+
"required": false,
|
|
3742
|
+
"description": "The number, or null for an empty field. Pass it to control the field."
|
|
3743
|
+
},
|
|
3744
|
+
{
|
|
3745
|
+
"name": "defaultValue",
|
|
3746
|
+
"type": "number | null",
|
|
3747
|
+
"required": false,
|
|
3748
|
+
"description": "The starting number when the field is not controlled. Defaults to empty."
|
|
3749
|
+
},
|
|
3750
|
+
{
|
|
3751
|
+
"name": "onValueChange",
|
|
3752
|
+
"type": "((value: number | null) => void)",
|
|
3753
|
+
"required": false,
|
|
3754
|
+
"description": "Called with the number as it is typed or cleared (null when empty), and with the rounded number on blur."
|
|
3755
|
+
},
|
|
3756
|
+
{
|
|
3757
|
+
"name": "decimals",
|
|
3758
|
+
"type": "number",
|
|
3759
|
+
"required": false,
|
|
3760
|
+
"default": "3",
|
|
3761
|
+
"description": "The most decimals the number keeps; the field rounds to them on blur. Defaults to 3 (grams in kg)."
|
|
3762
|
+
},
|
|
3763
|
+
{
|
|
3764
|
+
"name": "min",
|
|
3765
|
+
"type": "number",
|
|
3766
|
+
"required": false,
|
|
3767
|
+
"description": "The smallest number; the field moves a smaller one up to it on blur."
|
|
3768
|
+
},
|
|
3769
|
+
{
|
|
3770
|
+
"name": "max",
|
|
3771
|
+
"type": "number",
|
|
3772
|
+
"required": false,
|
|
3773
|
+
"description": "The largest number; the field moves a larger one down to it on blur."
|
|
3774
|
+
},
|
|
3775
|
+
{
|
|
3776
|
+
"name": "size",
|
|
3777
|
+
"type": "32 | 36",
|
|
3778
|
+
"required": false,
|
|
3779
|
+
"default": "36",
|
|
3780
|
+
"description": "The height in px: 36 for forms, 32 for fields inside a table. Defaults to 36."
|
|
3781
|
+
},
|
|
3782
|
+
{
|
|
3783
|
+
"name": "ref",
|
|
3784
|
+
"type": "Ref<HTMLInputElement>",
|
|
3785
|
+
"required": false,
|
|
3786
|
+
"description": "Receives the input element."
|
|
3787
|
+
}
|
|
3788
|
+
],
|
|
3789
|
+
"usage": {
|
|
3790
|
+
"whenToUse": "- A number with a unit after it: weight in kg, length in cm, a lead time in days\n- Values stored as numbers: `value` and `onValueChange` take and give a number, null when empty\n- A field inside a table: `size` 32",
|
|
3791
|
+
"whenNotToUse": "- Money: use MoneyInput, which takes and gives paise\n- A unit before the number, or an icon: use InputGroup with an addon\n- Text that is not a number: use Input\n- Custom classes or inline styles: UnitInput takes neither `className` nor `style`",
|
|
3792
|
+
"example": "const [weight, setWeight] = useState<number | null>(0.24)\n\n<UnitInput aria-label=\"Weight\" unit=\"kg\" value={weight} onValueChange={setWeight} min={0} />\n<UnitInput aria-label=\"Length\" unit=\"cm\" decimals={0} defaultValue={30} name=\"length\" />"
|
|
3793
|
+
}
|
|
1853
3794
|
}
|
|
1854
3795
|
]
|
|
1855
3796
|
}
|