@pingux/astro 2.206.2 → 2.207.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/lib/cjs/components/Button/Buttons.styles.d.ts +14 -0
  2. package/lib/cjs/components/Button/Buttons.styles.js +11 -1
  3. package/lib/cjs/components/TableBase/TableBase.js +138 -32
  4. package/lib/cjs/components/TableBase/TableBase.mdx +46 -13
  5. package/lib/cjs/components/TableBase/TableBase.stories.js +52 -2
  6. package/lib/cjs/components/TableBase/TableBase.styles.d.ts +84 -9
  7. package/lib/cjs/components/TableBase/TableBase.styles.js +61 -10
  8. package/lib/cjs/components/TableBase/TableBase.test.js +585 -105
  9. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +14 -0
  10. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +16 -2
  11. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +10 -0
  12. package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +7 -0
  13. package/lib/cjs/styles/themes/next-gen/variants/button.js +4 -1
  14. package/lib/cjs/styles/themes/next-gen/variants/tableBase.d.ts +3 -0
  15. package/lib/cjs/styles/themes/next-gen/variants/tableBase.js +6 -1
  16. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +3 -0
  17. package/lib/cjs/types/tableBase.d.ts +21 -5
  18. package/lib/components/Button/Buttons.styles.js +11 -1
  19. package/lib/components/TableBase/TableBase.js +139 -33
  20. package/lib/components/TableBase/TableBase.mdx +46 -13
  21. package/lib/components/TableBase/TableBase.stories.js +51 -1
  22. package/lib/components/TableBase/TableBase.styles.js +61 -10
  23. package/lib/components/TableBase/TableBase.test.js +585 -105
  24. package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +16 -2
  25. package/lib/styles/themes/next-gen/variants/button.js +4 -1
  26. package/lib/styles/themes/next-gen/variants/tableBase.js +6 -1
  27. package/package.json +1 -1
@@ -2043,5 +2043,19 @@ declare const _default: {
2043
2043
  flexShrink: number;
2044
2044
  whiteSpace: string;
2045
2045
  };
2046
+ tableHeaderButton: {
2047
+ fontSize: string;
2048
+ fontWeight: string;
2049
+ color: string;
2050
+ lineHeight: string;
2051
+ backgroundColor: string;
2052
+ borderRadius: string;
2053
+ textAlign: string;
2054
+ '&.is-focused': {
2055
+ outline: string;
2056
+ outlineColor: string;
2057
+ outlineOffset: string;
2058
+ };
2059
+ };
2046
2060
  };
2047
2061
  export default _default;
@@ -349,5 +349,15 @@ var _default = exports["default"] = {
349
349
  withIcon: withIcon,
350
350
  filter: filter,
351
351
  searchNavTabLabel: tabLabelButton,
352
- selectLink: selectLink
352
+ selectLink: selectLink,
353
+ tableHeaderButton: {
354
+ fontSize: 'md',
355
+ fontWeight: '1',
356
+ color: 'text.primary',
357
+ lineHeight: 'body',
358
+ backgroundColor: 'transparent',
359
+ borderRadius: '0px',
360
+ textAlign: 'left',
361
+ '&.is-focused': _objectSpread({}, defaultFocus)
362
+ }
353
363
  };
@@ -31,7 +31,7 @@ var _table2 = require("@react-stately/table");
31
31
  var _ = require("../..");
32
32
  var _hooks = require("../../hooks");
33
33
  var _react2 = require("@emotion/react");
34
- var _excluded = ["caption", "selectionMode", "selectionBehavior", "hasSelectionCheckboxes", "isStickyHeader", "className", "isLastColumnSticky"],
34
+ var _excluded = ["caption", "selectionMode", "selectionBehavior", "hasSelectionCheckboxes", "isStickyHeader", "className", "isLastColumnSticky", "onResizeStart", "onResize", "onResizeEnd"],
35
35
  _excluded2 = ["caption"],
36
36
  _excluded3 = ["type", "children", "className", "isSticky"];
37
37
  function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -66,6 +66,9 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
66
66
  isStickyHeader = _props$isStickyHeader === void 0 ? false : _props$isStickyHeader,
67
67
  className = props.className,
68
68
  isLastColumnSticky = props.isLastColumnSticky,
69
+ onResizeStart = props.onResizeStart,
70
+ onResize = props.onResize,
71
+ onResizeEnd = props.onResizeEnd,
69
72
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
70
73
  var tableRef = (0, _hooks.useLocalOrForwardRef)(ref);
71
74
  var headerRef = (0, _react.useRef)(null);
@@ -146,7 +149,10 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
146
149
  key: column.key,
147
150
  column: column,
148
151
  state: state,
149
- layoutState: layoutState
152
+ layoutState: layoutState,
153
+ onResizeStart: onResizeStart,
154
+ onResize: onResize,
155
+ onResizeEnd: onResizeEnd
150
156
  });
151
157
  }));
152
158
  })), (0, _react2.jsx)(TableRowGroup, (0, _extends2["default"])({
@@ -164,12 +170,13 @@ var TableBase = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
164
170
  }, (0, _react2.jsx)(_.Loader, {
165
171
  variant: "loader.withinDataTable"
166
172
  })), (0, _map["default"])(_context3 = (0, _from["default"])(collection.body.childNodes)).call(_context3, function (row) {
167
- var _context4;
173
+ var _context4, _collection$getChildr, _collection$getChildr2;
168
174
  return (0, _react2.jsx)(TableRow, {
169
175
  key: row.key,
170
176
  item: row,
171
- state: state
172
- }, (0, _map["default"])(_context4 = (0, _from["default"])(collection.getChildren(row.key))).call(_context4, function (cell) {
177
+ state: state,
178
+ hasSelectionCheckboxes: hasSelectionCheckboxes
179
+ }, (0, _map["default"])(_context4 = (0, _from["default"])((_collection$getChildr = (_collection$getChildr2 = collection.getChildren) === null || _collection$getChildr2 === void 0 ? void 0 : _collection$getChildr2.call(collection, row.key)) !== null && _collection$getChildr !== void 0 ? _collection$getChildr : [])).call(_context4, function (cell) {
173
180
  return cell.props.isSelectionCell ? (0, _react2.jsx)(TableCheckboxCell, {
174
181
  key: cell.key,
175
182
  cell: cell,
@@ -235,39 +242,87 @@ function TableHeaderRow(props) {
235
242
  ref: ref
236
243
  }), children);
237
244
  }
245
+ function Resizer(props) {
246
+ var column = props.column,
247
+ layoutState = props.layoutState,
248
+ triggerRef = props.triggerRef,
249
+ onResizeStart = props.onResizeStart,
250
+ onResize = props.onResize,
251
+ onResizeEnd = props.onResizeEnd;
252
+ var ref = (0, _react.useRef)(null);
253
+ var _useTableColumnResize = (0, _table.useTableColumnResize)({
254
+ column: column,
255
+ 'aria-label': "".concat(column.textValue, " column width"),
256
+ triggerRef: triggerRef,
257
+ onResizeStart: onResizeStart,
258
+ onResize: onResize,
259
+ onResizeEnd: onResizeEnd
260
+ }, layoutState, ref),
261
+ resizerProps = _useTableColumnResize.resizerProps,
262
+ inputProps = _useTableColumnResize.inputProps;
263
+ var _useFocusRing = (0, _focus.useFocusRing)(),
264
+ isFocusVisible = _useFocusRing.isFocusVisible,
265
+ focusProps = _useFocusRing.focusProps;
266
+
267
+ // The input must be nested inside the Box that carries resizerProps so that
268
+ // keyboard events fired on the input (Enter to start resize, Escape/Tab to
269
+ // end it) bubble up to the element with the keyboard handlers.
270
+
271
+ var _useStatusClasses3 = (0, _hooks.useStatusClasses)('', {
272
+ isFocused: isFocusVisible
273
+ }),
274
+ classNames = _useStatusClasses3.classNames;
275
+ return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
276
+ role: "presentation",
277
+ variant: "tableBase.resizer",
278
+ className: classNames
279
+ }, resizerProps), (0, _react2.jsx)("input", (0, _extends2["default"])({
280
+ ref: ref
281
+ }, (0, _utils.mergeProps)(inputProps, focusProps))));
282
+ }
238
283
  function TableColumnHeader(props) {
239
- var _column$props;
284
+ var _column$props, _column$props2;
240
285
  var column = props.column,
241
286
  state = props.state,
242
287
  className = props.className,
243
- layoutState = props.layoutState;
288
+ layoutState = props.layoutState,
289
+ onResizeStart = props.onResizeStart,
290
+ onResize = props.onResize,
291
+ onResizeEnd = props.onResizeEnd;
244
292
  var ref = (0, _react.useRef)(null);
245
293
  var _useTableColumnHeader = (0, _table.useTableColumnHeader)({
246
294
  node: column
247
295
  }, state, ref),
248
296
  columnHeaderProps = _useTableColumnHeader.columnHeaderProps;
249
- var _useFocusRing = (0, _focus.useFocusRing)(),
250
- isFocusVisible = _useFocusRing.isFocusVisible,
251
- focusProps = _useFocusRing.focusProps;
297
+
298
+ // within: true catches keyboard focus on the resizer <input> child so the
299
+ // <th> shows its focus ring even when the child is the active element.
300
+ var _useFocusRing2 = (0, _focus.useFocusRing)({
301
+ within: true
302
+ }),
303
+ isFocusVisible = _useFocusRing2.isFocusVisible,
304
+ focusProps = _useFocusRing2.focusProps;
252
305
  var allowsSorting = (_column$props = column.props) === null || _column$props === void 0 ? void 0 : _column$props.allowsSorting;
306
+ var allowsResizing = (_column$props2 = column.props) === null || _column$props2 === void 0 ? void 0 : _column$props2.allowsResizing;
253
307
  var _useGetTheme = (0, _hooks.useGetTheme)(),
254
308
  icons = _useGetTheme.icons;
255
309
  var Ascending = icons.Ascending,
256
310
  Descending = icons.Descending;
257
311
  var sortDescriptor = state.sortDescriptor;
258
- var arrowIcon = (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.column) === column.key && (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.direction) === 'ascending' ? Ascending : Descending;
312
+ var isSortedAscending = (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.column) === column.key && (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.direction) === 'ascending';
313
+ var arrowIcon = isSortedAscending ? Ascending : Descending;
259
314
  var sortIcon = (0, _react2.jsx)(_.Icon, {
260
315
  icon: arrowIcon,
261
316
  size: "xs",
262
317
  "aria-hidden": "true",
263
318
  title: {
264
- name: (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.direction) === 'ascending' ? 'Sort ascending' : 'Sort descending'
319
+ name: isSortedAscending ? 'Sort ascending' : 'Sort descending'
265
320
  }
266
321
  });
267
- var _useStatusClasses3 = (0, _hooks.useStatusClasses)(className, {
322
+ var _useStatusClasses4 = (0, _hooks.useStatusClasses)(className, {
268
323
  isFocused: isFocusVisible
269
324
  }),
270
- classNames = _useStatusClasses3.classNames;
325
+ classNames = _useStatusClasses4.classNames;
271
326
  useHandleFocusRef(ref);
272
327
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
273
328
  as: "th",
@@ -276,19 +331,27 @@ function TableColumnHeader(props) {
276
331
  variant: "tableBase.head",
277
332
  className: classNames,
278
333
  sx: _objectSpread({
279
- width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
334
+ width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key),
335
+ position: 'relative'
280
336
  }, column.props.sx)
281
337
  }, (0, _utils.mergeProps)(columnHeaderProps, focusProps, column.props)), (0, _react2.jsx)(_.Box, {
282
338
  isRow: true,
283
339
  gap: "sm",
284
340
  alignItems: "center"
285
- }, (0, _react2.jsx)(_.Text, null, column.rendered), allowsSorting && sortIcon));
341
+ }, (0, _react2.jsx)(_.Text, null, column.rendered), allowsSorting && sortIcon), allowsResizing && (0, _react2.jsx)(Resizer, {
342
+ column: column,
343
+ layoutState: layoutState,
344
+ onResizeStart: onResizeStart,
345
+ onResize: onResize,
346
+ onResizeEnd: onResizeEnd
347
+ }));
286
348
  }
287
349
  function TableRow(props) {
288
350
  var item = props.item,
289
351
  state = props.state,
290
352
  children = props.children,
291
- className = props.className;
353
+ className = props.className,
354
+ hasSelectionCheckboxes = props.hasSelectionCheckboxes;
292
355
  var ref = (0, _react.useRef)(null);
293
356
  var _useTableRow = (0, _table.useTableRow)({
294
357
  node: item
@@ -296,31 +359,50 @@ function TableRow(props) {
296
359
  rowProps = _useTableRow.rowProps;
297
360
  var isSelected = state.selectionManager.isSelected(item.key);
298
361
  var isDisabled = state.disabledKeys.has(item.key);
299
- var _useFocusRing2 = (0, _focus.useFocusRing)(),
300
- isFocusVisible = _useFocusRing2.isFocusVisible,
301
- focusProps = _useFocusRing2.focusProps;
362
+ var _useFocusRing3 = (0, _focus.useFocusRing)(),
363
+ isFocusVisible = _useFocusRing3.isFocusVisible,
364
+ focusProps = _useFocusRing3.focusProps;
302
365
  var _useHover = (0, _interactions.useHover)({}),
303
366
  hoverProps = _useHover.hoverProps,
304
367
  isHovered = _useHover.isHovered;
368
+
369
+ // allowTextSelectionOnPress: true prevents the press handler from suppressing
370
+ // native text-selection drags (user-select: none is not applied on pointer down).
371
+ // When hasSelectionCheckboxes is true, isDisabled: true disables the visual
372
+ // isPressed state — selection is handled solely by the checkbox cells.
305
373
  var _usePress = (0, _interactions.usePress)({
306
- ref: ref
374
+ ref: ref,
375
+ allowTextSelectionOnPress: true,
376
+ isDisabled: !!hasSelectionCheckboxes
307
377
  }),
308
378
  pressProps = _usePress.pressProps,
309
379
  isPressed = _usePress.isPressed;
310
- var _useStatusClasses4 = (0, _hooks.useStatusClasses)(className, {
380
+
381
+ // React Aria's useSelectableItem only maps Space to selection (not Enter).
382
+ // Enter is reserved for "action" which is unused here, so we manually toggle
383
+ // selection on Enter to match expected keyboard behavior.
384
+ var enterKeyProps = (0, _react.useCallback)(function (e) {
385
+ if (e.key !== 'Enter') return;
386
+ if (isDisabled || state.selectionManager.selectionMode === 'none') return;
387
+ e.preventDefault();
388
+ state.selectionManager.toggleSelection(item.key);
389
+ }, [isDisabled, item.key, state.selectionManager]);
390
+ var _useStatusClasses5 = (0, _hooks.useStatusClasses)(className, {
311
391
  isSelected: isSelected,
312
392
  isHovered: isHovered,
313
393
  isPressed: isPressed,
314
394
  isFocused: isFocusVisible,
315
395
  isDisabled: isDisabled
316
396
  }),
317
- classNames = _useStatusClasses4.classNames;
397
+ classNames = _useStatusClasses5.classNames;
318
398
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
319
399
  as: "tr",
320
400
  display: "table-row",
321
401
  className: classNames,
322
402
  variant: "tableBase.row"
323
- }, (0, _utils.mergeProps)(rowProps, focusProps, hoverProps, pressProps), {
403
+ }, (0, _utils.mergeProps)(rowProps, focusProps, hoverProps, pressProps, {
404
+ onKeyDown: enterKeyProps
405
+ }), {
324
406
  ref: ref
325
407
  }), children);
326
408
  }
@@ -334,14 +416,19 @@ function TableCell(props) {
334
416
  node: cell
335
417
  }, state, ref),
336
418
  gridCellProps = _useTableCell.gridCellProps;
337
- var _useFocusRing3 = (0, _focus.useFocusRing)(),
338
- isFocusVisible = _useFocusRing3.isFocusVisible,
339
- focusProps = _useFocusRing3.focusProps;
340
- var _useStatusClasses5 = (0, _hooks.useStatusClasses)(className, {
419
+ var _useFocusRing4 = (0, _focus.useFocusRing)(),
420
+ isFocusVisible = _useFocusRing4.isFocusVisible,
421
+ focusProps = _useFocusRing4.focusProps;
422
+ var _useStatusClasses6 = (0, _hooks.useStatusClasses)(className, {
341
423
  isFocused: isFocusVisible
342
424
  }),
343
- classNames = _useStatusClasses5.classNames;
425
+ classNames = _useStatusClasses6.classNames;
344
426
  useHandleFocusRef(ref);
427
+
428
+ // Prevents pointer events reaching the row's press handler, allowing native text-selection drags.
429
+ var stopPointerPropagation = (0, _react.useCallback)(function (e) {
430
+ e.stopPropagation();
431
+ }, []);
345
432
  return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
346
433
  as: "td",
347
434
  display: "table-cell",
@@ -351,8 +438,22 @@ function TableCell(props) {
351
438
  sx: _objectSpread({
352
439
  width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(cell.column.key)
353
440
  }, cell.props.sx)
354
- }, (0, _utils.mergeProps)(gridCellProps, focusProps, cell.props)), cell.rendered);
441
+ }, (0, _utils.mergeProps)({
442
+ onPointerDown: stopPointerPropagation,
443
+ onMouseDown: stopPointerPropagation
444
+ }, gridCellProps, focusProps, cell.props)), cell.rendered);
355
445
  }
446
+
447
+ // Native checkboxes only toggle on Space, not Enter. This handler makes Enter
448
+ // behave the same as Space by calling the checkbox's onChange callback.
449
+ var handleCheckboxEnterKey = function handleCheckboxEnterKey(onChange, isSelected) {
450
+ return function (e) {
451
+ if (e.key === 'Enter') {
452
+ e.preventDefault();
453
+ onChange === null || onChange === void 0 || onChange(!isSelected);
454
+ }
455
+ };
456
+ };
356
457
  function TableSelectAllCell(props) {
357
458
  var column = props.column,
358
459
  state = props.state,
@@ -375,7 +476,8 @@ function TableSelectAllCell(props) {
375
476
  ref: ref
376
477
  }), state.selectionManager.selectionMode === 'single' ? (0, _react2.jsx)(_visuallyHidden.VisuallyHidden, null, checkboxProps['aria-label']) : (0, _react2.jsx)(_.CheckboxField, (0, _extends2["default"])({
377
478
  checkBoxProps: {
378
- 'data-testid': 'select-all-checkbox'
479
+ 'data-testid': 'select-all-checkbox',
480
+ onKeyDown: handleCheckboxEnterKey(checkboxProps.onChange, checkboxProps.isSelected)
379
481
  }
380
482
  }, checkboxProps)));
381
483
  }
@@ -401,6 +503,10 @@ function TableCheckboxCell(props) {
401
503
  }, cell.props.sx)
402
504
  }, gridCellProps, {
403
505
  ref: ref
404
- }), (0, _react2.jsx)(_.CheckboxField, checkboxProps));
506
+ }), (0, _react2.jsx)(_.CheckboxField, (0, _extends2["default"])({
507
+ checkBoxProps: {
508
+ onKeyDown: handleCheckboxEnterKey(checkboxProps.onChange, checkboxProps.isSelected)
509
+ }
510
+ }, checkboxProps)));
405
511
  }
406
512
  var _default = exports["default"] = TableBase;
@@ -3,29 +3,62 @@ import * as TableBaseStories from './TableBase.stories';
3
3
 
4
4
  <Meta of={TableBaseStories} isTemplate />
5
5
 
6
- # Table
6
+ # TableBase
7
7
 
8
- Data tables display information in a grid-like format of rows and columns.
9
- They organize information in a way thats easy to scan so that users can look for patterns and develop insights from data.
8
+ Data tables display information in a grid-like format of rows and columns.
9
+ They organize information in a way that's easy to scan so that users can look for patterns and develop insights from data.
10
10
 
11
- Column header names describe the type of content displayed in each column.
11
+ Column header names describe the type of content displayed in each column.
12
12
  Each row contains data related to a single entity.
13
13
 
14
- Tables should:
14
+ TableBase should:
15
15
  - Have consistently aligned content.
16
16
  - Use multiple heading rows for higher-level grouping of the columns.
17
17
  - Use column dividers sparingly.
18
18
 
19
- Tables shouldn’t use different indicators to represent empty fields.
19
+ This basic component is rendered as an HTML `<table>`, which accepts the `<TBody>` component and the `<THead>` as children.
20
20
 
21
- This basic component is rendered as an HTML `<table>`, which accepts the `<TableBody>` component and the `<TableHead>` as children.
21
+ ### When to Use
22
+
23
+ Use TableBase when you need a fully custom table implementation that goes beyond what higher-level table components provide. Common use cases include:
24
+
25
+ - Sticky columns (e.g., pinning the last column during horizontal scroll)
26
+ - Custom row or column grouping
27
+ - Non-standard selection behaviors
28
+ - Bespoke cell rendering or layout that requires direct control over the table structure
29
+
30
+ TableBase is the lowest-level table primitive in Astro and gives you direct access to the underlying React Aria/Stately table hooks. Use it when you need that level of control.
22
31
 
23
32
  ### Required Components
24
33
 
25
- This component requires these additional components:
34
+ This component requires these additional components:
35
+
36
+ - **TableCaption** — renders an accessible `<caption>` element for the table
37
+ - **THead** — wraps the header section (`<thead>`)
38
+ - **Column** — defines each column header cell (`<th>`)
39
+ - **TBody** — wraps the body section (`<tbody>`)
40
+ - **Row** — defines each data row (`<tr>`)
41
+ - **Cell** — defines each data cell (`<td>`)
42
+
43
+ ### Accessibility
44
+
45
+ #### Keyboard Navigation
46
+
47
+ These keys provide additional functionality to the component.
48
+
49
+ | Keys | Functions |
50
+ | ---- | --------- |
51
+ | Tab | Moves focus to the next focusable component. All focusable components in the table are included in the page tab sequence. |
52
+ | Shift + Tab | Moves focus to the previous focusable component. |
53
+ | Space or Enter | Focuses the component and triggers an action if one is associated with it. |
54
+ | Arrow keys | Can be used to navigate between the components in the table. |
55
+ | Home or Page Up | Shifts the focus to the first row. |
56
+ | End or Page Down | Shifts the focus to the last visible row. |
57
+
58
+ #### Screen Readers
26
59
 
27
- - TableCaption
28
- - TableHead
29
- - TableRow
30
- - TableCell
31
- - TableBody
60
+ This component uses the following attributes to assist screen readers:
61
+ - The **`aria-label`** attribute should be provided on the `TableBase` to give the table an accessible name. When a visible `TableCaption` is present, use **`aria-labelledby`** to associate the caption with the table instead.
62
+ - The **`aria-rowcount`** and **`aria-columncount`** attributes are used to indicate the total number of rows and columns in the grid structure.
63
+ - Each `Row` uses the **`aria-rowindex`** attribute to enumerate its position within the table.
64
+ - Each `Column` and `Cell` uses the **`aria-colindex`** attribute to enumerate its position within its row.
@@ -17,7 +17,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
17
17
  _Object$defineProperty(exports, "__esModule", {
18
18
  value: true
19
19
  });
20
- exports["default"] = exports.WithStickyHeader = exports.WithPagination = exports.WithLastColumnSticky = exports.MultiSelection = exports.DynamicWithSorting = exports.Default = void 0;
20
+ exports["default"] = exports.WithStickyHeader = exports.WithResizableColumns = exports.WithPagination = exports.WithMinMaxColumnWidth = exports.WithLastColumnSticky = exports.MultiSelection = exports.DynamicWithSorting = exports.Default = void 0;
21
21
  var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
22
22
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
23
23
  var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
@@ -46,7 +46,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
46
46
  function _regeneratorDefine2(e, r, n, t) { var i = _Object$defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
47
47
  function _OverloadYield(e, d) { this.v = e, this.k = d; }
48
48
  var _default = exports["default"] = {
49
- title: 'Experimental/Table',
49
+ title: 'Components/TableBase',
50
50
  component: _.TableBase,
51
51
  parameters: {
52
52
  docs: {
@@ -393,6 +393,56 @@ DynamicWithSorting.parameters = {
393
393
  }
394
394
  }
395
395
  };
396
+ var WithResizableColumns = exports.WithResizableColumns = function WithResizableColumns() {
397
+ return (0, _react2.jsx)(_.Card, {
398
+ variant: "cards.tableWrapper"
399
+ }, (0, _react2.jsx)(_.TableBase, {
400
+ caption: "Lorem ipsum",
401
+ "aria-label": "table"
402
+ }, (0, _react2.jsx)(_.THead, null, (0, _react2.jsx)(_.Column, {
403
+ minWidth: 100,
404
+ allowsResizing: true
405
+ }, "Type"), (0, _react2.jsx)(_.Column, {
406
+ minWidth: 100,
407
+ allowsResizing: true
408
+ }, "Date"), (0, _react2.jsx)(_.Column, {
409
+ minWidth: 100
410
+ }, "Additional Grant"), (0, _react2.jsx)(_.Column, {
411
+ minWidth: 100
412
+ }, "Total Grant")), (0, _react2.jsx)(_.TBody, {
413
+ items: objects
414
+ }, function (item) {
415
+ return (0, _react2.jsx)(_.Row, {
416
+ key: item.id
417
+ }, (0, _react2.jsx)(_.Cell, null, item.type), (0, _react2.jsx)(_.Cell, null, item.date), (0, _react2.jsx)(_.Cell, null, item.additional_grant), (0, _react2.jsx)(_.Cell, null, item.total_grant));
418
+ })));
419
+ };
420
+ var WithMinMaxColumnWidth = exports.WithMinMaxColumnWidth = function WithMinMaxColumnWidth() {
421
+ return (0, _react2.jsx)(_.Card, {
422
+ variant: "cards.tableWrapper"
423
+ }, (0, _react2.jsx)(_.TableBase, {
424
+ caption: "Lorem ipsum",
425
+ "aria-label": "table"
426
+ }, (0, _react2.jsx)(_.THead, null, (0, _react2.jsx)(_.Column, {
427
+ minWidth: 80,
428
+ maxWidth: 200
429
+ }, "Type"), (0, _react2.jsx)(_.Column, {
430
+ minWidth: 120,
431
+ maxWidth: 300
432
+ }, "Date"), (0, _react2.jsx)(_.Column, {
433
+ minWidth: 100,
434
+ maxWidth: 180
435
+ }, "Additional Grant"), (0, _react2.jsx)(_.Column, {
436
+ minWidth: 100,
437
+ maxWidth: 180
438
+ }, "Total Grant")), (0, _react2.jsx)(_.TBody, {
439
+ items: objects
440
+ }, function (item) {
441
+ return (0, _react2.jsx)(_.Row, {
442
+ key: item.id
443
+ }, (0, _react2.jsx)(_.Cell, null, item.type), (0, _react2.jsx)(_.Cell, null, item.date), (0, _react2.jsx)(_.Cell, null, item.additional_grant), (0, _react2.jsx)(_.Cell, null, item.total_grant));
444
+ })));
445
+ };
396
446
  var WithLastColumnSticky = exports.WithLastColumnSticky = function WithLastColumnSticky() {
397
447
  return (0, _react2.jsx)(_.Card, {
398
448
  variant: "cards.tableWrapper",
@@ -31,15 +31,35 @@ declare const _default: {
31
31
  position: string;
32
32
  '&.is-last-column-sticky': {
33
33
  'thead tr th:last-of-type': {
34
- position: string;
35
- right: number;
36
- backgroundColor: string;
37
- zIndex: number;
38
34
  '&.is-focused': {
39
35
  borderStyle: string;
40
36
  borderColor: string;
41
37
  borderWidth: string;
42
38
  };
39
+ '&::after': {
40
+ content: string;
41
+ position: string;
42
+ top: number;
43
+ bottom: number;
44
+ left: number;
45
+ width: string;
46
+ backgroundColor: any;
47
+ pointerEvents: string;
48
+ };
49
+ '&::before': {
50
+ content: string;
51
+ position: string;
52
+ top: number;
53
+ bottom: number;
54
+ left: string;
55
+ width: string;
56
+ background: string;
57
+ pointerEvents: string;
58
+ };
59
+ position: string;
60
+ right: number;
61
+ backgroundColor: string;
62
+ zIndex: number;
43
63
  };
44
64
  'tbody tr': {
45
65
  '&.is-focused td:last-of-type': {
@@ -48,24 +68,66 @@ declare const _default: {
48
68
  borderWidth: string;
49
69
  };
50
70
  '&:nth-of-type(odd) td:last-of-type': {
51
- position: string;
52
- right: number;
53
- backgroundColor: string;
54
71
  '&.is-focused': {
55
72
  borderStyle: string;
56
73
  borderColor: string;
57
74
  borderWidth: string;
58
75
  };
59
- };
60
- '&:nth-of-type(even) td:last-of-type': {
76
+ '&::after': {
77
+ content: string;
78
+ position: string;
79
+ top: number;
80
+ bottom: number;
81
+ left: number;
82
+ width: string;
83
+ backgroundColor: any;
84
+ pointerEvents: string;
85
+ };
86
+ '&::before': {
87
+ content: string;
88
+ position: string;
89
+ top: number;
90
+ bottom: number;
91
+ left: string;
92
+ width: string;
93
+ background: string;
94
+ pointerEvents: string;
95
+ };
61
96
  position: string;
62
97
  right: number;
98
+ zIndex: number;
63
99
  backgroundColor: string;
100
+ };
101
+ '&:nth-of-type(even) td:last-of-type': {
64
102
  '&.is-focused': {
65
103
  borderStyle: string;
66
104
  borderColor: string;
67
105
  borderWidth: string;
68
106
  };
107
+ '&::after': {
108
+ content: string;
109
+ position: string;
110
+ top: number;
111
+ bottom: number;
112
+ left: number;
113
+ width: string;
114
+ backgroundColor: any;
115
+ pointerEvents: string;
116
+ };
117
+ '&::before': {
118
+ content: string;
119
+ position: string;
120
+ top: number;
121
+ bottom: number;
122
+ left: string;
123
+ width: string;
124
+ background: string;
125
+ pointerEvents: string;
126
+ };
127
+ position: string;
128
+ right: number;
129
+ zIndex: number;
130
+ backgroundColor: string;
69
131
  };
70
132
  };
71
133
  };
@@ -138,5 +200,18 @@ declare const _default: {
138
200
  };
139
201
  };
140
202
  };
203
+ resizer: {
204
+ cursor: string;
205
+ display: string;
206
+ width: string;
207
+ height: string;
208
+ backgroundColor: string;
209
+ position: string;
210
+ right: string;
211
+ top: string;
212
+ '&.is-focused': {
213
+ backgroundColor: string;
214
+ };
215
+ };
141
216
  };
142
217
  export default _default;