@atom-learning/components 2.28.3-beta.2 → 2.29.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/components/accordion/Accordion.d.ts +1 -266
  2. package/dist/components/accordion/AccordionContent.d.ts +1 -266
  3. package/dist/components/accordion/AccordionContent.js +1 -1
  4. package/dist/components/accordion/AccordionItem.d.ts +1 -266
  5. package/dist/components/accordion/AccordionItem.js +1 -1
  6. package/dist/components/accordion/AccordionTrigger.d.ts +2 -270
  7. package/dist/components/accordion/AccordionTrigger.js +1 -1
  8. package/dist/components/action-icon/ActionIcon.d.ts +1 -281
  9. package/dist/components/alert-dialog/AlertDialog.d.ts +1 -266
  10. package/dist/components/alert-dialog/AlertDialogContent.d.ts +1 -268
  11. package/dist/components/alert-dialog/alert-context/AlertDialog.d.ts +1 -1
  12. package/dist/components/avatar/Avatar.d.ts +2 -536
  13. package/dist/components/badge/Badge.d.ts +1 -534
  14. package/dist/components/box/Box.d.ts +1 -266
  15. package/dist/components/button/Button.d.ts +2 -283
  16. package/dist/components/calendar/Calendar.d.ts +1 -1
  17. package/dist/components/calendar/Day.d.ts +1 -270
  18. package/dist/components/carousel/Carousel.d.ts +1 -1
  19. package/dist/components/carousel/CarouselArrows.d.ts +1 -1
  20. package/dist/components/carousel/CarouselPagination.d.ts +1 -267
  21. package/dist/components/carousel/CarouselSlide.d.ts +1 -266
  22. package/dist/components/carousel/CarouselSlider.d.ts +1 -269
  23. package/dist/components/checkbox/Checkbox.d.ts +1 -269
  24. package/dist/components/checkbox-field/CheckboxField.d.ts +2 -2
  25. package/dist/components/chip/Chip.d.ts +5 -1879
  26. package/dist/components/chip/ChipGroup.d.ts +1 -1
  27. package/dist/components/chip-dismissible-group/ChipDismissibleGroupItem.d.ts +2 -547
  28. package/dist/components/chip-dismissible-group/ChipDismissibleGroupRoot.d.ts +1 -5
  29. package/dist/components/chip-toggle-group/ChipToggleGroupItem.d.ts +1 -546
  30. package/dist/components/chip-toggle-group/ChipToggleGroupRoot.d.ts +1 -562
  31. package/dist/components/combobox/Combobox.d.ts +1 -266
  32. package/dist/components/combobox/ComboboxInput.d.ts +1 -268
  33. package/dist/components/combobox/ComboboxList.d.ts +1 -266
  34. package/dist/components/combobox/ComboboxOption.d.ts +1 -266
  35. package/dist/components/combobox/ComboboxPopover.d.ts +1 -266
  36. package/dist/components/data-table/DataTableLoading.d.ts +1 -270
  37. package/dist/components/data-table/drag-and-drop/Handle.d.ts +1 -559
  38. package/dist/components/data-table/pagination/Pagination.d.ts +1 -266
  39. package/dist/components/data-table/pagination/PaginationButtons.d.ts +1 -1
  40. package/dist/components/date-field/DateField.d.ts +2 -2
  41. package/dist/components/dialog/Dialog.d.ts +1 -266
  42. package/dist/components/dialog/DialogBackground.d.ts +1 -531
  43. package/dist/components/dialog/DialogClose.d.ts +1 -267
  44. package/dist/components/dialog/DialogContent.d.ts +1 -268
  45. package/dist/components/dismissible-group/DismissibleGroupItem.d.ts +1 -1
  46. package/dist/components/dismissible-group/index.d.ts +1 -1
  47. package/dist/components/divider/Divider.d.ts +1 -268
  48. package/dist/components/dropdown-menu/DropdownMenu.d.ts +1 -266
  49. package/dist/components/dropdown-menu/DropdownMenuContent.d.ts +1 -267
  50. package/dist/components/dropdown-menu/DropdownMenuItem.d.ts +1 -267
  51. package/dist/components/dropdown-menu/DropdownMenuSeparator.d.ts +1 -267
  52. package/dist/components/dropdown-menu/DropdownMenuTrigger.d.ts +1 -267
  53. package/dist/components/empty-state/EmptyState.d.ts +1 -533
  54. package/dist/components/empty-state/EmptyStateBody.d.ts +1 -543
  55. package/dist/components/empty-state/EmptyStateImage.d.ts +2 -542
  56. package/dist/components/empty-state/EmptyStateTitle.d.ts +1 -268
  57. package/dist/components/field-wrapper/FieldDescription.d.ts +1 -1
  58. package/dist/components/field-wrapper/FieldWrapper.d.ts +2 -2
  59. package/dist/components/field-wrapper/InlineFieldWrapper.d.ts +1 -1
  60. package/dist/components/flex/Flex.d.ts +1 -266
  61. package/dist/components/form/Form.d.ts +1 -266
  62. package/dist/components/grid/Grid.d.ts +1 -268
  63. package/dist/components/heading/Heading.d.ts +2 -270
  64. package/dist/components/icon/Icon.d.ts +2 -269
  65. package/dist/components/image/Image.d.ts +2 -269
  66. package/dist/components/inline-message/InlineMessage.config.d.ts +1 -1
  67. package/dist/components/inline-message/InlineMessage.d.ts +1 -534
  68. package/dist/components/input/Input.d.ts +2 -270
  69. package/dist/components/input-field/InputField.d.ts +2 -2
  70. package/dist/components/label/Label.d.ts +2 -272
  71. package/dist/components/link/Link.d.ts +3 -271
  72. package/dist/components/list/List.d.ts +2 -537
  73. package/dist/components/loader/Loader.d.ts +1 -1
  74. package/dist/components/markdown-content/MarkdownContent.d.ts +1 -1
  75. package/dist/components/markdown-content/components/MarkdownEmphasis.d.ts +1 -266
  76. package/dist/components/markdown-content/components/MarkdownImage.d.ts +1 -1
  77. package/dist/components/markdown-content/components/MarkdownList.d.ts +1 -1
  78. package/dist/components/markdown-content/components/MarkdownThematicBreak.d.ts +1 -1
  79. package/dist/components/navigation/NavigationMenu.d.ts +1 -1
  80. package/dist/components/navigation/NavigationMenuDropdown.d.ts +1 -1
  81. package/dist/components/navigation/NavigationMenuDropdownItem.d.ts +4 -543
  82. package/dist/components/navigation/NavigationMenuLink.d.ts +1 -1
  83. package/dist/components/notification-badge/NotificationBadge.d.ts +1 -531
  84. package/dist/components/number-input/NumberInput.d.ts +1 -1
  85. package/dist/components/number-input-field/NumberInputField.d.ts +2 -2
  86. package/dist/components/password-field/PasswordField.d.ts +2 -2
  87. package/dist/components/password-input/PasswordInput.d.ts +1 -1
  88. package/dist/components/popover/Popover.d.ts +1 -266
  89. package/dist/components/popover/PopoverContent.d.ts +1 -268
  90. package/dist/components/progress-bar/ProgressBar.d.ts +1 -269
  91. package/dist/components/radio-button/RadioButton.d.ts +2 -268
  92. package/dist/components/radio-button/RadioButtonGroup.d.ts +1 -270
  93. package/dist/components/radio-button-field/RadioButtonField.d.ts +2 -2
  94. package/dist/components/radio-button-field/RadioField.d.ts +3 -3
  95. package/dist/components/radio-card/RadioCard.d.ts +1 -271
  96. package/dist/components/radio-card/RadioCardGroup.d.ts +1 -1
  97. package/dist/components/search-field/SearchField.d.ts +2 -2
  98. package/dist/components/search-input/SearchInput.d.ts +2 -2
  99. package/dist/components/select/Select.d.ts +2 -270
  100. package/dist/components/select-field/SelectField.d.ts +2 -2
  101. package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionContent.d.ts +1 -266
  102. package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionItem.d.ts +1 -267
  103. package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionRoot.d.ts +1 -267
  104. package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionTrigger.d.ts +1 -268
  105. package/dist/components/sidedrawer/SidedrawerContent.d.ts +1 -266
  106. package/dist/components/sidedrawer/SidedrawerFooter.d.ts +1 -266
  107. package/dist/components/sidedrawer/SidedrawerHeader.d.ts +1 -266
  108. package/dist/components/sidedrawer/SidedrawerOverlay.d.ts +1 -267
  109. package/dist/components/sidedrawer/SidedrawerTrigger.d.ts +1 -267
  110. package/dist/components/slider/Slider.d.ts +1 -268
  111. package/dist/components/slider-field/SliderField.d.ts +3 -3
  112. package/dist/components/stack/Stack.d.ts +2 -273
  113. package/dist/components/stack-content/StackContent.d.ts +2 -267
  114. package/dist/components/stepper/StepperStepBullet.d.ts +1 -533
  115. package/dist/components/stepper/StepperStepContainer.d.ts +1 -536
  116. package/dist/components/stepper/StepperStepLabel.d.ts +1 -544
  117. package/dist/components/stepper/types.d.ts +1 -1
  118. package/dist/components/switch/Switch.d.ts +1 -267
  119. package/dist/components/table/Table.d.ts +1 -269
  120. package/dist/components/table/TableBody.d.ts +1 -268
  121. package/dist/components/table/TableCell.d.ts +1 -266
  122. package/dist/components/table/TableFooter.d.ts +1 -266
  123. package/dist/components/table/TableFooterCell.d.ts +1 -266
  124. package/dist/components/table/TableHeader.d.ts +1 -268
  125. package/dist/components/table/TableHeaderCell.d.ts +1 -266
  126. package/dist/components/table/TableRow.d.ts +2 -536
  127. package/dist/components/tabs/TabTrigger.d.ts +8 -0
  128. package/dist/components/tabs/TabTrigger.js +1 -0
  129. package/dist/components/tabs/Tabs.d.ts +7 -272
  130. package/dist/components/tabs/Tabs.js +1 -1
  131. package/dist/components/tabs/TabsTriggerList.d.ts +6 -270
  132. package/dist/components/tabs/TabsTriggerList.js +1 -1
  133. package/dist/components/tabs/utils.d.ts +2 -0
  134. package/dist/components/tabs/utils.js +1 -0
  135. package/dist/components/text/Text.d.ts +3 -271
  136. package/dist/components/textarea/Textarea.d.ts +1 -268
  137. package/dist/components/textarea-field/TextareaField.d.ts +2 -2
  138. package/dist/components/toast/Toast.d.ts +1 -268
  139. package/dist/components/toggle-group/ToggleGroupButton.d.ts +1 -534
  140. package/dist/components/toggle-group/ToggleGroupItem.d.ts +2 -534
  141. package/dist/components/toggle-group/ToggleGroupRoot.d.ts +1 -271
  142. package/dist/components/toggle-group/index.d.ts +3 -1352
  143. package/dist/components/tooltip/TooltipContent.d.ts +1 -268
  144. package/dist/components/top-bar/TopBar.d.ts +2 -270
  145. package/dist/components/top-bar/TopBar.js +1 -1
  146. package/dist/components/top-bar/TopBarBrand.d.ts +4 -808
  147. package/dist/components/video/Video.d.ts +4 -535
  148. package/dist/index.cjs.js +1 -1
  149. package/dist/index.d.ts +1 -1
  150. package/dist/stitches.d.ts +46 -1993
  151. package/dist/stitches.js +1 -1
  152. package/dist/utilities/create-theme-variants/createThemeVariants.d.ts +1 -109
  153. package/dist/utilities/css-wrapper/CSSWrapper.d.ts +1 -1
  154. package/dist/utilities/hooks/useCallbackRef.js +1 -1
  155. package/dist/utilities/hooks/useScrollPosition.d.ts +3 -6
  156. package/dist/utilities/hooks/useScrollPosition.js +1 -1
  157. package/dist/utilities/style/capsize.d.ts +1 -1
  158. package/dist/utilities/style/keyframe-animations.d.ts +8 -32
  159. package/package.json +4 -5
  160. package/CHANGELOG.md +0 -200
  161. package/dist/components/tabs/TabsContent.d.ts +0 -267
  162. package/dist/components/tabs/TabsContent.js +0 -1
  163. package/dist/components/tabs/TabsTrigger.d.ts +0 -272
  164. package/dist/components/tabs/TabsTrigger.js +0 -1
  165. package/dist/docgen.json +0 -1
  166. package/dist/docs/Accordion.mdx +0 -94
  167. package/dist/docs/ActionIcon.mdx +0 -87
  168. package/dist/docs/AlertDialog.mdx +0 -40
  169. package/dist/docs/Avatar.mdx +0 -129
  170. package/dist/docs/Badge.mdx +0 -55
  171. package/dist/docs/Box.mdx +0 -52
  172. package/dist/docs/Button.mdx +0 -76
  173. package/dist/docs/CONTRIBUTING.md +0 -224
  174. package/dist/docs/CSSWrapper.mdx +0 -10
  175. package/dist/docs/Carousel.mdx +0 -88
  176. package/dist/docs/Checkbox.mdx +0 -19
  177. package/dist/docs/CheckboxField.mdx +0 -14
  178. package/dist/docs/Chip.mdx +0 -118
  179. package/dist/docs/ChipDismissibleGroup.mdx +0 -33
  180. package/dist/docs/ChipToggleGroup.mdx +0 -27
  181. package/dist/docs/Combobox.mdx +0 -44
  182. package/dist/docs/DataTable.mdx +0 -279
  183. package/dist/docs/DateField.mdx +0 -20
  184. package/dist/docs/DateInput.mdx +0 -87
  185. package/dist/docs/Dialog.mdx +0 -68
  186. package/dist/docs/Dismissible.mdx +0 -48
  187. package/dist/docs/DismissibleGroup.mdx +0 -29
  188. package/dist/docs/Divider.mdx +0 -16
  189. package/dist/docs/DropdownMenu.mdx +0 -30
  190. package/dist/docs/EmptyState.mdx +0 -23
  191. package/dist/docs/FieldWrapper.mdx +0 -30
  192. package/dist/docs/FileInput.mdx +0 -45
  193. package/dist/docs/Flex.mdx +0 -16
  194. package/dist/docs/Form.mdx +0 -411
  195. package/dist/docs/Grid.mdx +0 -28
  196. package/dist/docs/Heading.mdx +0 -30
  197. package/dist/docs/Icon.mdx +0 -30
  198. package/dist/docs/Image.mdx +0 -14
  199. package/dist/docs/InlineMessage.mdx +0 -52
  200. package/dist/docs/Input.mdx +0 -24
  201. package/dist/docs/InputField.mdx +0 -26
  202. package/dist/docs/Label.mdx +0 -32
  203. package/dist/docs/Link.mdx +0 -53
  204. package/dist/docs/List.mdx +0 -38
  205. package/dist/docs/Loader.mdx +0 -16
  206. package/dist/docs/MarkdownContent.mdx +0 -77
  207. package/dist/docs/NavigationMenu.mdx +0 -144
  208. package/dist/docs/NotificationBadge.mdx +0 -35
  209. package/dist/docs/NumberInput.mdx +0 -37
  210. package/dist/docs/NumberInputField.mdx +0 -26
  211. package/dist/docs/PasswordField.mdx +0 -23
  212. package/dist/docs/PasswordInput.mdx +0 -15
  213. package/dist/docs/Popover.mdx +0 -29
  214. package/dist/docs/ProgressBar.mdx +0 -56
  215. package/dist/docs/README.mdx +0 -79
  216. package/dist/docs/RadioButton.mdx +0 -10
  217. package/dist/docs/RadioButtonField.mdx +0 -25
  218. package/dist/docs/RadioCard.mdx +0 -62
  219. package/dist/docs/SearchField.mdx +0 -26
  220. package/dist/docs/SearchInput.mdx +0 -13
  221. package/dist/docs/Select.mdx +0 -56
  222. package/dist/docs/SelectField.mdx +0 -17
  223. package/dist/docs/Sidedrawer.mdx +0 -155
  224. package/dist/docs/Slider.mdx +0 -117
  225. package/dist/docs/SliderField.mdx +0 -35
  226. package/dist/docs/Stack.mdx +0 -24
  227. package/dist/docs/StackContent.mdx +0 -32
  228. package/dist/docs/Stepper.mdx +0 -154
  229. package/dist/docs/Styling.mdx +0 -85
  230. package/dist/docs/Switch.mdx +0 -28
  231. package/dist/docs/Table.mdx +0 -146
  232. package/dist/docs/Tabs.mdx +0 -76
  233. package/dist/docs/Text.mdx +0 -24
  234. package/dist/docs/Textarea.mdx +0 -12
  235. package/dist/docs/TextareaField.mdx +0 -21
  236. package/dist/docs/Toast.mdx +0 -20
  237. package/dist/docs/ToggleGroup.mdx +0 -88
  238. package/dist/docs/Tooltip.mdx +0 -25
  239. package/dist/docs/TopBar.mdx +0 -95
  240. package/dist/docs/Video.mdx +0 -12
  241. package/dist/docs/accessibility.mdx +0 -67
  242. package/dist/docs/coreconcepts.mdx +0 -77
  243. package/dist/docs/introduction.mdx +0 -33
  244. package/dist/docs/versioning.mdx +0 -40
  245. package/dist/experiments/color-scheme/ColorScheme.d.ts +0 -201
  246. package/dist/experiments/color-scheme/ColorScheme.js +0 -1
  247. package/dist/experiments/color-scheme/blue.json.js +0 -1
  248. package/dist/experiments/color-scheme/generateAlphaColors.d.ts +0 -1
  249. package/dist/experiments/color-scheme/generateAlphaColors.js +0 -1
  250. package/dist/experiments/color-scheme/index.d.ts +0 -1
  251. package/dist/experiments/color-scheme/slate.json.js +0 -1
  252. package/dist/experiments/color-scheme/stitches.colorscheme.config.d.ts +0 -452
  253. package/dist/experiments/color-scheme/stitches.colorscheme.config.js +0 -1
  254. package/dist/utilities/hooks/useWindowScrollPosition.d.ts +0 -6
  255. package/dist/utilities/hooks/useWindowScrollPosition.js +0 -1
  256. package/dist/utilities/hooks/useWindowSize.d.ts +0 -8
  257. package/dist/utilities/hooks/useWindowSize.js +0 -1
@@ -1,279 +0,0 @@
1
- ---
2
- title: DataTable
3
- component: DataTable, DataTable.Table, DataTable.Head, DataTable.HeaderCell, DataTable.Body, DataTable.Row, DataTable.DataCell, DataTable.GlobalFilter, DataTable.Loading, DataTable.Error
4
- description: Displays tabular data with features such as sorting and pagination
5
- category: Content
6
- ---
7
-
8
- `DataTable` provides complex features for tables, like sorting and pagination. It's built around the `@tanstack/react-table` library and exposes the `table` state from that library directly. All util functions from the library are also compatible with `DataTable`. It's worth a good read of [`@tanstack/react-table`'s documentation](https://tanstack.com/table/v8/docs/guide/introduction) too, since we won't be repeating much of it here.
9
-
10
- `DataTable` and its subcomponents are designed to be very simple to use. This is achieved by abstracting complex and/or boilerplate logic away from the consumer. For example, `DataTable.Pagination` can be dropped inside a `DataTable` to paginate the table's data without the need to add any configuration on `DataTable` itself. This is achieved by having `DataTable.Pagination` itself use the `applyPagination` and `setPageSize` methods exposed by `useDataTable` on its first render. This pattern should be replicated wherever practical to maintain the best developer experience possible.
11
-
12
- ## Anatomy
13
-
14
- The root `DataTable` component manages the table's state and exposes it via the React Context API. This state can be accessed by any child components by calling `useDataTable`. You can pass an `initialState` prop to `DataTable` as described in the [`@tanstack/react-table` docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate).
15
-
16
- Other `DataTable` components call `useDataTable` and provide useful default implementations for common patterns. For example, `DataTable.Head` will render a header for every column defined in the parent `DataTable`. `DataTable.Body` will render a row for every data item. `DataTable.Table` combines both `DataTable.Head` and `DataTable.Body`.
17
-
18
- ### Using defaults vs rolling your own
19
-
20
- Here's a simple config for some table data and columns.
21
-
22
- ```tsx
23
- // import { createColumnHelper } from '@tanstack/react-table'
24
-
25
- const columnHelper = createColumnHelper<{
26
- name: string
27
- hobby: string
28
- }>()
29
-
30
- const columns = [
31
- columnHelper.accessor('name', {
32
- cell: (info) => info.getValue()
33
- }),
34
- columnHelper.accessor('hobby', {
35
- cell: (info) => info.getValue()
36
- }),
37
- // Columns created with columnHelper.display won't be sortable.
38
- // They need a header to be set manually since they're not just reading
39
- // a property from the row.
40
- columnHelper.display({
41
- cell: (info) => <button>do something</button>,
42
- header: 'Actions'
43
- })
44
- ]
45
-
46
- const data = [
47
- { name: 'chrissy', hobby: 'bare-knuckle boxing' },
48
- { name: 'agatha', hobby: 'crossfit' },
49
- { name: 'betty', hobby: 'acting' }
50
- ]
51
- ```
52
-
53
- There are basically two ways to use `DataTable` to build a table from this config. The first uses the highest-level components that are bundled into `DataTable` to provide useful default behaviours with minimal code. The second directly accesses the state from `DataTable` and combines it with the `Table` UI components to achieve the same thing. This demonstrates how you could create more custom table UIs without the need to extend the high-level components.
54
-
55
- #### With Defaults
56
-
57
- The following two examples are exactly equivalent in their output. The second example is included to demonstrate what `DataTable`'s subcomponents do: they bundle up UI components and logic to provide useful defaults. They exist at various levels of abstraction, e.g. `DataTable.Table` renders `DataTable.Body`, which renders `DataTable.Row`. This means that you can use whichever component provides useful functionality for your use case while still being low-level enough to let you combine it with your own custom logic.
58
-
59
- ```tsx
60
- <DataTable columns={columns} data={data}>
61
- <DataTable.Table sortable css={{mb: '$4'}}/>
62
- <DataTable.Pagination pageSize={5} />
63
- </DataTable>
64
-
65
- <DataTable columns={columns} data={data}>
66
- <Table>
67
- <DataTable.Head sortable />
68
- <DataTable.Body />
69
- </Table>
70
- <DataTable.Pagination pageSize={5} />
71
- </DataTable>
72
- ```
73
-
74
- ### Rolling your own
75
-
76
- If you need more flexibility than the default implementations provide, you can roll your own. Note that you can mix and match default implementations with your own. For example you could write your own table head implementation but use `DataTable.Body` for the body.
77
-
78
- Note also that `useDataTable` can only be called by a child component of `DataTable`. In a real example, you'll probably have a separate named component which makes the `useDataTable` call, because if you're not using the defaults as above then you probably have some complex logic involved. In this example we've got an inline child component for simplicity.
79
-
80
- Note that if you update the value of the `data` prop, it will reset the state of the table. This is useful if you are manipulating the data outside the context of the table.
81
-
82
- ```tsx
83
- <DataTable columns={columns} data={data}>
84
- {() => {
85
- const { getHeaderGroups, getRowModel, setGlobalFilter, getState } =
86
- useDataTable()
87
- const { globalFilter } = getState()
88
-
89
- return (
90
- <>
91
- <Label htmlFor="search">User search</Label>
92
- <SearchInput
93
- name="search"
94
- value={globalFilter}
95
- onChange={setGlobalFilter}
96
- />
97
- <Table>
98
- <Table.Header>
99
- {getHeaderGroups().map((headerGroup) => (
100
- <Table.Row key={headerGroup.id}>
101
- {headerGroup.headers.map((header) => {
102
- const sort = header.column.getIsSorted()
103
- return (
104
- <Table.HeaderCell
105
- onClick={header.column.getToggleSortingHandler()}
106
- {...props}
107
- >
108
- {flexRender(
109
- header.column.columnDef.header,
110
- header.getContext()
111
- )}
112
- {sort && { asc: '^', desc: 'v' }[sort as string]}
113
- </Table.HeaderCell>
114
- )
115
- })}
116
- </Table.Row>
117
- ))}
118
- </Table.Header>
119
- <Table.Body>
120
- {getRowModel().rows.map((row) => (
121
- <Table.Row>
122
- {row.getVisibleCells().map((cell) => (
123
- <Table.Cell key={cell.id}>
124
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
125
- </Table.Cell>
126
- ))}
127
- </Table.Row>
128
- ))}
129
- </Table.Body>
130
- </Table>
131
- </>
132
- // Then you could build your own pagination here too I guess? If you really wanted to?
133
- )
134
- }}
135
- </DataTable>
136
- ```
137
-
138
- ### Server-side pagination and sorting
139
-
140
- `DataTable` can be used with local pagination or server-side pagination (getting only the data needed for the current page). To use one or the other, you have to use the `data` or `getAsyncData` prop respectively.
141
-
142
- The `getAsyncData` function accepts an object with the necessary parameters to get the relevant piece of data for the current page and order. All the parameters are optional, with these defaults:
143
-
144
- ```
145
- {
146
- pageIndex: 0,
147
- pageSize: 10,
148
- sortBy: undefined,
149
- sortDirection: undefined,
150
- globalFilter: ''
151
- }
152
- ```
153
-
154
- The response from the `getAsyncData` function must match the following schema:
155
-
156
- ```ts
157
- {
158
- results: Array<Record<string, unknown>> // your current page data, sorted if specified
159
- total: number // the total number of elements in your data
160
- }
161
- ```
162
-
163
- A loading state using `<DataTable.Loading>` is automatically included in `DataTable` which is visible while the `getAsyncData` promise is pending.
164
-
165
- You can use `DataTable.Error` to display your own error component when the `getAsyncData` function promise rejects. Notice `DataTable.Error` doesn't render anything on its own, but whatever is passed as childern.
166
-
167
- ```tsx
168
- <DataTable
169
- columns={columns}
170
- defaultPageSize={10}
171
- defaultSort={{ column: 'name', direction: 'asc' }}
172
- initialState={{ pagination: { pageIndex: 0, pageSize: 10 } }}
173
- getAsyncData={async ({
174
- pageIndex,
175
- pageSize,
176
- sortBy,
177
- sortDirection,
178
- globalFilter
179
- }) => {
180
- const params = new URLSearchParams({
181
- page: pageIndex,
182
- pageSize,
183
- order: sortBy,
184
- dir: sortDirection,
185
- search: globalFilter
186
- })
187
- const response = await fetch(`https://your-api?${params.toString()}`)
188
- const { results, total } = await response.json()
189
-
190
- return { results, total }
191
- }}
192
- >
193
- <DataTable.Table sortable css={{ mb: '$4', minWidth: '500px' }} />
194
- <DataTable.Error>
195
- {(retry) => <Button onClick={retry}>Try again</Button>}
196
- </DataTable.Error>
197
- <DataTable.Pagination />
198
- </DataTable>
199
- ```
200
-
201
- `DataTable.Error` provides a `retry` function to the children which allows you to recall the `getAsyncData` function. The `retry` function can be called with all the paginated parameters as an optional object. If no parameters are provided, `retry` will be called with the last paginated options.
202
-
203
- ```tsx
204
- <DataTable.Error>
205
- {(retry) => (
206
- <Button
207
- onClick={() =>
208
- retry?.({
209
- pageIndex: 5,
210
- pageSize: 10,
211
- sortBy: 'name',
212
- sortDirection: 'asc',
213
- globalFilter: ''
214
- })
215
- }
216
- >
217
- Retry
218
- </Button>
219
- )}
220
- </DataTable.Error>
221
- ```
222
-
223
- ## Features
224
-
225
- ### Search
226
-
227
- `DataTable.Search` renders a search input that filters the whole table by matching the input against values from any table column.
228
-
229
- ### Sorting
230
-
231
- A `DataTable`'s data can be sorted by default and can also be sortable by the user. These two options are independent of each other.
232
-
233
- #### Default sorting
234
-
235
- `DataTable` takes an optional `defaultSort` prop to configure the column and direction for the table's default sorting, e.g. `{column: 'name', direction: 'asc'}`
236
-
237
- #### User sorting
238
-
239
- If `DataTable`'s `isSortable` state is `true`, then `DataTable.Header` will be clickable to toggle between ascending, descending and no sorting in any sortable columns. `DataTable.Head` and `DataTable.Table` take an optional boolean `sortable` prop to configure this option.
240
-
241
- ### Pagination
242
-
243
- `DataTable.Pagination` can be passed as a child to `DataTable` to render the pagination UI and configure the parent `DataTable` to paginate its data. Note: there is currently a bug where `DataTable` will render all rows on the initial render, even when paginated. There is no visible effect, but it can cause performance issues on large tables. The workaround for this is to pass an `initialState` prop to `DataTable`. E.g. `initialState={pagination: {pageSize: 5, pageIndex: 0}}`. This will force pagination to apply properly on the initial render. Make sure the `pagination` prop matches the config you use in `DataTable.Pagination`, as the latter will take precedence after the initial render.
244
-
245
- ### Drag and drop
246
-
247
- The `DataTable.DragAndDropTable` can be rendered in place of `DataTable.Table` to allow users to reorder table rows via drag and drop. It takes an optional `onDragAndDrop` prop which is a function that fires when rows have been re-ordered via drag-and-drop. Use this to sync those changes with external data sources.
248
-
249
- Note that column sorting conflicts with drag and drop behaviour. In any context where you allow drag and drop reordering, you probably want to disable column sorting (see User Sorting above). Similarly, you should probably disable pagination because users won't be able to drag rows across page boundaries.
250
-
251
- #### Row IDs
252
-
253
- Drag-and-drop functionality relies on each table row having a unique ID. `DataTable.DragAndDropContainer` will throw an error if your don't provide unique IDs for each row in the `data` provided to `DataTable`, so you should consider wrapping your table in an `ErrorBoundary` to reduce the impact on your user if there is a problem with your data. By default, `DataTable.DragAndDropContainer` will look for this id in an `id` property on each object in `data`. You can use the `idColumn` prop to provide the name of a different property, e.g. `userId`, that already exists on your data so that you don't have to generate new IDs just for the table. For example, you could provide data like this with no additional configuration:
254
-
255
- ```tsx
256
- const data = [
257
- { name: 'chrissy', hobby: 'bare-knuckle boxing', id: 1 },
258
- { name: 'agatha', hobby: 'crossfit', id: 2 },
259
- { name: 'betty', hobby: 'acting', id: 3 }
260
- ]`
261
-
262
- <DataTable data={data} columns={columns}>
263
- <DataTable.DragAndDropTable onDragAndDrop={(oldIndex, newIndex, newData) => console.log(oldIndex, newIndex, newData)}/>
264
- </DataTable>
265
- ```
266
-
267
- Or you could provide this data and specify the id column accordingly:
268
-
269
- ```tsx
270
- const data = [
271
- { name: 'chrissy', hobby: 'bare-knuckle boxing', userId: 1 },
272
- { name: 'agatha', hobby: 'crossfit', userId: 2 },
273
- { name: 'betty', hobby: 'acting', userId: 3 }
274
- ]`
275
-
276
- <DataTable data={data} columns={columns}>
277
- <DataTable.DragAndDropTable idColumn="userId" onDragAndDrop={(oldIndex, newIndex, newData) => console.log(oldIndex, newIndex, newData)} />
278
- </DataTable>
279
- ```
@@ -1,20 +0,0 @@
1
- ---
2
- title: Date Field
3
- component: DateField
4
- description: DateField renders a field composed of an DateInput, a Label and a InlineMessage
5
- category: Form fields
6
- ---
7
-
8
- `DateField` is the preferred way to render a form field for dates.
9
-
10
- In addition to text `Label` (required) and a validation error (optional), `DateField` accepts all the same props as `DateInput` and will pass them on to the `DateInput` it renders. However, as with all our composed components,
11
- `DateField`’s `css` prop will be applied to a containing `Box`—the styling of the individual components inside `DateField` cannot be altered.
12
-
13
- Err on the side of using consistent form fields, but if you really need something with different styling then consider composing your own field from the
14
- `DateInput`, `Label` and `InlineMessage` components.
15
-
16
- ```tsx preview
17
- <Form>
18
- <DateField name="exam-date" label="Exam date" initialDate={new Date()} />
19
- </Form>
20
- ```
@@ -1,87 +0,0 @@
1
- ---
2
- title: Date Input
3
- component: DateInput
4
- description: A form component that provides a styled date selector without a label
5
- category: Form primitives
6
- ---
7
-
8
- Date Inputs should be accompanied by labels, so rather than using `DateInput` directly in a UI,
9
- it’s normally best to the `DateField` component, which combines a `DateInput` with a `Label` and
10
- displays validation errors. Alternatively, use this `DateInput` component to compose other field components
11
- with more specific requirements.
12
-
13
- `DateInput` is composed from [Dayzed](https://github.com/deseretdigital/dayzed), so further reading on the API can be found there. Some options from Dayzed are set by default in order to provide a uniform experience. For example, the prop `showOutsideDays`, which shows days outside the current calendar month that would appear on the grid, defaults to true in order to avoid extra whitespace.
14
-
15
- ```tsx preview
16
- <DateInput />
17
- ```
18
-
19
- ## Initial Date
20
-
21
- The `DateInput` component allows passing of an initial date, which will be selected by default. If you wish this to be the current date, you can use `new Date()` as per the preview below. Strings are also accepted and default to the `DD/MM/YYYY` format. It is recommended to use standard constructors for the date object as per MDN specifications.
22
-
23
- ```tsx preview
24
- <DateInput initialDate={new Date()} />
25
- ```
26
-
27
- ## Date Format
28
-
29
- Any combination of date formats can be passed in as a string, such as `DD/MM/YY` or `YYYY/MM/DD`. The default is `DD/MM/YYYY`. A full list of possible formats can be found [here](https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens).
30
-
31
- ```tsx
32
- <DateInput dateFormat="YYYY/MM/DD" />
33
- ```
34
-
35
- ## Dayzed customisation
36
-
37
- ### First Day of Week
38
-
39
- The calendar that is rendered by this component can have its first day of the week customised for different locales. The default is 1 (Monday), but for locales such as the US, pass in `firstDayOfWeek={0}` to set it to Sunday.
40
-
41
- ```tsx
42
- <DateInput firstDayOfWeek={0} />
43
- ```
44
-
45
- ## Translations
46
-
47
- The weekday and month names can be changed to anything you wish by passing in an array of strings to `weekdayNames` and `monthNames`.
48
-
49
- > NOTE: It is very important that you keep these labels in the right order. Weekdays must be `Sun -> Sat` and months must be `Jan -> Dec`.
50
-
51
- ```tsx preview
52
- <DateInput
53
- weekdayNames={['D', 'L', 'M', 'X', 'J', 'V', 'S']}
54
- monthNames={[
55
- 'Enero',
56
- 'Febrero',
57
- 'Marzo',
58
- 'Abril',
59
- 'Mayo',
60
- 'Junio',
61
- 'Julio',
62
- 'Agosto',
63
- 'Septiembre',
64
- 'Octubre',
65
- 'Noviembre',
66
- 'Diciembre'
67
- ]}
68
- />
69
- ```
70
-
71
- You can also translate the internal labels for accessibility purposes. The `labels` prop accepts an object containing three keys, `open`, `next`, and `previous`. These should all be strings.
72
-
73
- ```tsx
74
- <DateInput
75
- labels={{
76
- open: 'Open label',
77
- next: 'Next month label',
78
- previous: 'Previous month label'
79
- }}
80
- />
81
- ```
82
-
83
- If you need even finer control over what happens with the selected date, you can pass `onChange`, which takes a `Date` type as input.
84
-
85
- ```tsx
86
- <DateInput onChange={(date) => doSomethingWith(date)} />
87
- ```
@@ -1,68 +0,0 @@
1
- ---
2
- title: Dialog
3
- component: Dialog,Dialog.Trigger,Dialog.Content,Dialog.Close
4
- description: The Dialog component renders its children inside a modal and puts a dimmer over the rest of the screen
5
- category: Surfaces
6
- ---
7
-
8
- `Dialog` exports many components that combine to create a modal. The `Dialog.Trigger` renders a `<button>` by default, but this can be overridden with the `asChild` prop, which will instead add all the functional and accessibility requirements to the child component instead (see the below example).
9
-
10
- Also, note that the component must accept a `ref`.
11
-
12
- Read more about the underlying UI component on the [Radix UI documentation site](https://radix-ui.com/primitives/docs/components/dialog).
13
-
14
- ```tsx preview
15
- <Dialog>
16
- <Dialog.Trigger asChild>
17
- <Button>Open Dialog</Button>
18
- </Dialog.Trigger>
19
- <Dialog.Content>
20
- <Heading size="sm" css={{ mb: '$3' }}>
21
- Dialog
22
- </Heading>
23
- <Text size="sm" css={{ mb: '$3' }}>
24
- The `Dialog` can display any type of element as a trigger and has the
25
- content hidden by default
26
- </Text>
27
- <Button appearance="outline" size="sm" as={Dialog.Close}>
28
- Close Dialog
29
- </Button>
30
- </Dialog.Content>
31
- </Dialog>
32
- ```
33
-
34
- `Dialog` may be rendered without a close button. It's important to note that in case the default close button is hidden, one would need to provide an action button explicitly, to close the dialog.
35
-
36
- ```tsx
37
- <Dialog>
38
- <Dialog.Trigger>Open Dialog</Dialog.Trigger>
39
- <Dialog.Content showCloseButton={false}>
40
- <Text>
41
- Dialog.Close is used below to retain the correct accessible roles and
42
- related logic
43
- </Text>
44
- <Button as={Dialog.Close}>Close</Button>
45
- </Dialog.Content>
46
- </Dialog>
47
- ```
48
-
49
- `Dialog` can also be rendered with a custom background. Important to note that `Dialog.Background` needs to be a child of `Dialog.Content`
50
-
51
- ```tsx
52
- <Dialog>
53
- <Dialog.Trigger>Open Dialog</Dialog.Trigger>
54
- <Dialog.Content>
55
- <Dialog.Background>
56
- <Text>
57
- Custom Background Content
58
- </Text>
59
- </Dialog.Background>
60
- <Text>
61
- Dialog.Background will appear above the Overlay, but below the DialogContent
62
- </Text>
63
- <Button as={Dialog.Close}>Close</Button>
64
- </Dialog.Content>
65
- </Dialog>
66
- ```
67
-
68
- For any modifications of the default `Dialog` visuals, for example bypassing the panel design entirely, we recommend utilising the Radix UI Dialog component directly. You will need to wrap each exported component within a `styled()` function to enable `css` and `as`, and compose together `Dialog.Overlay` and `Dialog.Close` within `Dialog.Content` to mimic the behaviour of this modal.
@@ -1,48 +0,0 @@
1
- ---
2
- title: Dismissible
3
- component: DismissibleRoot,Dismissible.Trigger
4
- description: An element with a dismiss button which removes it from the view
5
- category: Primitives
6
- ---
7
-
8
- `Dismissible` itself is a primitive. It has not been designed so it should not be used out-of-the-box as a user facing component.
9
- Test the component is accessible depending on each implementation use case.
10
-
11
- ```tsx preview
12
- <Dismissible
13
- value="a"
14
- onDismiss={(value) => {
15
- alert(`dismiss ${value}`)
16
- }}
17
- >
18
- Press the trigger to dismiss this ->
19
- <Dismissible.Trigger aria-label="Dismiss 'a'" />
20
- </Dismissible>
21
- ```
22
-
23
- ```tsx preview
24
- <Dismissible
25
- value="custom"
26
- onDismiss={(value) => {
27
- alert(`dismiss ${value}`)
28
- }}
29
- asChild
30
- >
31
- <Box
32
- css={{
33
- width: '100%',
34
- fontFamily: 'system-ui',
35
- border: '1px solid',
36
- borderRadius: 4,
37
- display: 'flex',
38
- justifyContent: 'space-between',
39
- padding: 8
40
- }}
41
- >
42
- Basic custom implementation example
43
- <Dismissible.Trigger asChild>
44
- <button type="button">Custom Dismiss Trigger</button>
45
- </Dismissible.Trigger>
46
- </Box>
47
- </Dismissible>
48
- ```
@@ -1,29 +0,0 @@
1
- ---
2
- title: Dismissible Group
3
- component: DismissibleGroupRoot,DismissibleGroup.Item,DismissibleGroup.Trigger
4
- description: A set of dismissible elements.
5
- category: Primitives
6
- ---
7
-
8
- `DismissibleGroup` itself is a primitive. It has not been designed so it should not be used out-of-the-box as a user facing component.
9
- Test the component is accessible depending on each implementation use case.
10
-
11
- ```tsx preview
12
- <DismissibleGroup
13
- onDismiss={(value) => {
14
- alert(`dismiss ${value}`)
15
- }}
16
- >
17
- <DismissibleGroup.Item value="a">
18
- A
19
- <DismissibleGroup.Trigger aria-label="Dismiss A" />
20
- </DismissibleGroup.Item>
21
- <DismissibleGroup.Item value="b" disabled>
22
- B
23
- <DismissibleGroup.Trigger />
24
- </DismissibleGroup.Item>
25
- <DismissibleGroup.Item value="c" disabled>
26
- C
27
- </DismissibleGroup.Item>
28
- </DismissibleGroup>
29
- ```
@@ -1,16 +0,0 @@
1
- ---
2
- title: Divider
3
- component: Divider
4
- description: Use Divider to render a horizontal or vertical line which will extend to parent node's width / height
5
- category: Content
6
- ---
7
-
8
- It adds default styling and the `css` prop. Provide `orientation` as `horizontal` or `vertical` to achieve desirable output
9
-
10
- ```tsx preview
11
- <Divider />
12
- ```
13
-
14
- ```tsx preview
15
- <Divider orientation="vertical"/>
16
- ```
@@ -1,30 +0,0 @@
1
- ---
2
- title: Dropdown Menu
3
- component: DropdownMenu,DropdownMenu.Trigger,DropdownMenu.Content,DropdownMenu.Item,DropdownMenu.Separator
4
- description: The DropdownMenu components can be composed to create flexible dropdown menus with different types of items.
5
- category: Surfaces
6
- ---
7
-
8
- `DropdownMenu` exports many components that combine to create a dropdown menu. The `DropdownMenu.Trigger` renders a `<button>` by default, but this can be overridden with the `asChild` prop, which will instead add all the functional and accessibility requirements to the child component instead (see the below example).
9
-
10
- Also, note that the component must accept a `ref`.
11
-
12
- Read more about the underlying UI component on the [Radix UI documentation site](https://radix-ui.com/primitives/docs/components/dropdown-menu).
13
-
14
- ```tsx preview
15
- <DropdownMenu>
16
- <DropdownMenu.Trigger asChild>
17
- <Button>Click me</Button>
18
- </DropdownMenu.Trigger>
19
- <DropdownMenu.Content sideOffset={16}>
20
- <DropdownMenu.Item onClick={() => alert('Great clicking!')}>
21
- Item 1
22
- </DropdownMenu.Item>
23
- <DropdownMenu.Item>Item 2</DropdownMenu.Item>
24
- <DropdownMenu.Separator />
25
- <DropdownMenu.LinkItem href="/logout">Log Out</DropdownMenu.LinkItem>
26
- </DropdownMenu.Content>
27
- </DropdownMenu>
28
- ```
29
-
30
- For any modifications of the default `DropdownMenu` visuals, we recommend utilising the Radix UI DropdownMenu component directly. You will need to wrap each exported component within a `styled()` function to enable the `css` prop.
@@ -1,23 +0,0 @@
1
- ---
2
- title: Empty State
3
- component: EmptyState
4
- description: Empty states are messages that provide an explanation of an interface in absence of content.
5
- category: Content
6
- ---
7
-
8
- `EmptyState` exports a number of components that can be composed together to create an `EmptyState` message.
9
- The message can include Title and/or Body and sometimes they appear together with an illustration and actionable buttons.
10
- There are 5 different size variants of `EmptyState` ( 'xs', 'sm', 'md', 'lg' and 'xl').
11
-
12
- ```jsx preview live
13
- <EmptyState size="lg">
14
- <EmptyState.Image
15
- src="https://app.atomlearning.com/dist/29a378dc127c669808f2.svg"
16
- alt=""
17
- />
18
- <EmptyState.Title>No users found!</EmptyState.Title>
19
- <EmptyState.Body>
20
- You need to add some users before you can use this feature
21
- </EmptyState.Body>
22
- </EmptyState>
23
- ```
@@ -1,30 +0,0 @@
1
- ---
2
- title: Field Wrapper
3
- component: FieldWrapper,InlineFieldWrapper
4
- description: A utility component to help with composing consistent form fields
5
- category: Form primitives
6
- ---
7
-
8
- `FieldWrapper` renders a `Label` and (when applicable) a `InlineMessage`. Use it to wrap any type of input to create a consistent set of form fields.
9
-
10
- ```tsx preview
11
- <FieldWrapper label="Example Field" fieldId="example">
12
- <Input name="example" id="example" />
13
- </FieldWrapper>
14
- ```
15
-
16
- `InlineFieldWrapper` does the same but renders the label inline with the input, for example:`Checkbox`es and `Radio`s.
17
-
18
- ```tsx preview
19
- <InlineFieldWrapper label="Example Checkbox">
20
- <Checkbox name="example2" id="example2" />
21
- </InlineFieldWrapper>
22
- ```
23
-
24
- It can also be used alongside components like `Input`, `Select` or `Switch` when you may require some condensed inline fields. You can use the `direction` and `align` props to handle how the label is positioned relative to the component, in this case the label is placed on the right with `direction="reverse"` and it's aligned centrally with the switch.
25
-
26
- ```tsx preview
27
- <InlineFieldWrapper direction="reverse" align="center" label="Toggle a field">
28
- <Switch />
29
- </InlineFieldWrapper>
30
- ```