@servicetitan/docs-anvil-uikit-contrib 29.2.0 → 29.3.1

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 (2) hide show
  1. package/docs/table.mdx +46 -1
  2. package/package.json +2 -2
package/docs/table.mdx CHANGED
@@ -168,7 +168,7 @@ export interface TableProps<T, TId extends IdType = any, P = never, PId extends
168
168
 
169
169
  #### Basic
170
170
 
171
- Simple example with some out of the box functionality.
171
+ Simple example with some out of the box functionality. This example enables keyboard navigation and is accessible for screen readers.
172
172
 
173
173
  <CodeDemo example={TableExample} srcPath="table/src/demo/overview/table.tsx" theme="light" />
174
174
 
@@ -224,3 +224,48 @@ const tableState = useTableState(
224
224
  - `OnUpdateDataRoot` (default) - the current page will be reset when the reference to the `data` variable changes. When only the inner contents of the array are changed - the table page is kept.
225
225
 
226
226
  You can check the demonstration of different pagination reset modes at [anvil-uikit-contrib's Storybook page](https://anvil-uikit-contrib.st.dev/?path=/story/table-useobservingtablestate)
227
+
228
+ ## Keyboard navigation and accessibility
229
+
230
+ To enable keyboard navigation, pass the `navigatable` prop to the `Table` component. It will enable keyboard navigation for built-in Anvil 1 and `@servicetitan/table` cells.
231
+
232
+ To make your custom cells compatible, spread the supplied `tdProps` to the `td` element.
233
+
234
+ :::info
235
+
236
+ It's recommended to spread `tdProps` to custom cells even if `navigatable` is disabled as it provides standard and accessibility attributes to `td` elements generated inside Anvil 1 table.
237
+
238
+ :::
239
+
240
+ Simple custom cell:
241
+
242
+ ```tsx
243
+ import { FC } from 'react';
244
+ import { TableCellProps } from '@servicetitan/table';
245
+
246
+ const CustomCell: FC<TableCellProps> = ({ tdProps }) => {
247
+ return <td {...props.tdProps}>I'm a custom cell!</td>;
248
+ };
249
+ ```
250
+
251
+ The same works for editable cells created with `getEditableCell` method:
252
+
253
+ ```tsx
254
+ import { FC } from 'react';
255
+ import { DatePicker } from '@servicetitan/design-system';
256
+ import { getEditableCell, EditorProps } from '@servicetitan/table';
257
+
258
+ const DateEditor = observer<FC<EditorProps<Date | string | undefined>>>(
259
+ ({ fieldState: { value, onChange, hasError }, className, tdProps }) => {
260
+ return (
261
+ <td className={className} {...tdProps}>
262
+ <DatePicker value={value} onChange={onChange} error={hasError} />
263
+ </td>
264
+ );
265
+ }
266
+ );
267
+
268
+ export const DateEditableCell = getEditableCell({
269
+ editor: DateEditor,
270
+ });
271
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-anvil-uikit-contrib",
3
- "version": "29.2.0",
3
+ "version": "29.3.1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,5 +16,5 @@
16
16
  "cli": {
17
17
  "webpack": false
18
18
  },
19
- "gitHead": "ca96fa4e0aaf009f3d5b6a1a8f7cfc489e60dcdf"
19
+ "gitHead": "b3d36831303c3b53747c9bd11bf11a080a82fc89"
20
20
  }