@pingux/astro 2.133.0-alpha.3 → 2.134.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 (37) hide show
  1. package/lib/cjs/components/Box/Box.styles.d.ts +4 -0
  2. package/lib/cjs/components/Box/Box.styles.js +5 -0
  3. package/lib/cjs/components/TableBase/TableBase.js +36 -6
  4. package/lib/cjs/components/TableBase/TableBase.stories.d.ts +14 -0
  5. package/lib/cjs/components/TableBase/TableBase.stories.js +193 -6
  6. package/lib/cjs/components/TableBase/TableBase.styles.d.ts +17 -1
  7. package/lib/cjs/components/TableBase/TableBase.styles.js +11 -2
  8. package/lib/cjs/components/TableBase/TableBase.test.js +267 -0
  9. package/lib/cjs/components/TableBase/stories/NextGenTableBase.js +2 -4
  10. package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +2 -0
  11. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/icons.d.ts +2 -0
  12. package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +2 -0
  13. package/lib/cjs/styles/themes/astro/customProperties/icons.d.ts +2 -0
  14. package/lib/cjs/styles/themes/astro/customProperties/icons.js +1 -1
  15. package/lib/cjs/styles/themes/astro/customProperties/index.d.ts +2 -0
  16. package/lib/cjs/styles/themes/next-gen/customProperties/icons.d.ts +2 -0
  17. package/lib/cjs/styles/themes/next-gen/customProperties/icons.js +1 -1
  18. package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +2 -0
  19. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +7 -3
  20. package/lib/cjs/styles/themes/next-gen/variants/cards.d.ts +0 -1
  21. package/lib/cjs/styles/themes/next-gen/variants/cards.js +1 -3
  22. package/lib/cjs/styles/themes/next-gen/variants/tableBase.d.ts +4 -2
  23. package/lib/cjs/styles/themes/next-gen/variants/tableBase.js +4 -2
  24. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +7 -2
  25. package/lib/cjs/styles/themes/next-gen/variants/variants.js +4 -0
  26. package/lib/components/Box/Box.styles.js +5 -0
  27. package/lib/components/TableBase/TableBase.js +38 -8
  28. package/lib/components/TableBase/TableBase.stories.js +195 -8
  29. package/lib/components/TableBase/TableBase.styles.js +11 -2
  30. package/lib/components/TableBase/TableBase.test.js +267 -1
  31. package/lib/components/TableBase/stories/NextGenTableBase.js +3 -5
  32. package/lib/styles/themes/astro/customProperties/icons.js +1 -1
  33. package/lib/styles/themes/next-gen/customProperties/icons.js +1 -1
  34. package/lib/styles/themes/next-gen/variants/cards.js +1 -3
  35. package/lib/styles/themes/next-gen/variants/tableBase.js +4 -2
  36. package/lib/styles/themes/next-gen/variants/variants.js +4 -0
  37. package/package.json +1 -1
@@ -23,8 +23,8 @@ import { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTab
23
23
  import { mergeProps, useResizeObserver } from '@react-aria/utils';
24
24
  import { VisuallyHidden } from '@react-aria/visually-hidden';
25
25
  import { useTableColumnResizeState, useTableState } from '@react-stately/table';
26
- import { Box, Card, CheckboxField } from '../..';
27
- import { useLocalOrForwardRef, useStatusClasses } from '../../hooks';
26
+ import { Box, Card, CheckboxField, Icon, Loader } from '../..';
27
+ import { useGetTheme, useLocalOrForwardRef, useStatusClasses } from '../../hooks';
28
28
  import { jsx as ___EmotionJSX } from "@emotion/react";
29
29
  var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
30
30
  var _context, _context3;
@@ -47,7 +47,6 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
47
47
  var bodyRef = useRef(null);
48
48
  var collection = state.collection;
49
49
  var _useTable = useTable(_objectSpread(_objectSpread({}, props), {}, {
50
- 'aria-describedby': props['aria-describedby'] || 'table-caption',
51
50
  scrollRef: bodyRef
52
51
  }), state, tableRef),
53
52
  gridProps = _useTable.gridProps;
@@ -89,8 +88,7 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
89
88
  as: "caption",
90
89
  display: "table-caption",
91
90
  variant: "tableBase.caption",
92
- textAlign: "left",
93
- id: props['aria-describedby'] || 'table-caption'
91
+ textAlign: "left"
94
92
  }, caption), ___EmotionJSX(TableRowGroup, {
95
93
  type: "thead",
96
94
  hasCaption: !!caption,
@@ -117,7 +115,18 @@ var TableBase = /*#__PURE__*/forwardRef(function (props, ref) {
117
115
  })), ___EmotionJSX(TableRowGroup, _extends({
118
116
  ref: bodyRef,
119
117
  type: "tbody"
120
- }, tableBodyProps), _mapInstanceProperty(_context3 = _Array$from(collection)).call(_context3, function (row) {
118
+ }, tableBodyProps), collection.size === 0 && ___EmotionJSX(Box, {
119
+ role: "row",
120
+ key: "loading",
121
+ "data-testid": "loading",
122
+ as: "tr",
123
+ alignItems: "center",
124
+ justifyContent: "center",
125
+ px: "lg",
126
+ py: "md"
127
+ }, ___EmotionJSX(Loader, {
128
+ color: "active"
129
+ })), _mapInstanceProperty(_context3 = _Array$from(collection)).call(_context3, function (row) {
121
130
  var _context4;
122
131
  return ___EmotionJSX(TableRow, {
123
132
  key: row.key,
@@ -177,6 +186,7 @@ export function TableHeaderRow(props) {
177
186
  }), children);
178
187
  }
179
188
  export function TableColumnHeader(props) {
189
+ var _column$props;
180
190
  var column = props.column,
181
191
  state = props.state,
182
192
  className = props.className,
@@ -189,19 +199,37 @@ export function TableColumnHeader(props) {
189
199
  var _useFocusRing = useFocusRing(),
190
200
  isFocusVisible = _useFocusRing.isFocusVisible,
191
201
  focusProps = _useFocusRing.focusProps;
202
+ var allowsSorting = (_column$props = column.props) === null || _column$props === void 0 ? void 0 : _column$props.allowsSorting;
203
+ var _useGetTheme = useGetTheme(),
204
+ icons = _useGetTheme.icons;
205
+ var Ascending = icons.Ascending,
206
+ Descending = icons.Descending;
207
+ var sortDescriptor = state.sortDescriptor;
208
+ 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;
209
+ var sortIcon = ___EmotionJSX(Icon, {
210
+ icon: arrowIcon,
211
+ size: "xs",
212
+ "aria-hidden": "true",
213
+ title: {
214
+ name: (sortDescriptor === null || sortDescriptor === void 0 ? void 0 : sortDescriptor.direction) === 'ascending' ? 'Sort ascending' : 'Sort descending'
215
+ }
216
+ });
192
217
  var _useStatusClasses2 = useStatusClasses(className, {
193
218
  isFocused: isFocusVisible
194
219
  }),
195
220
  classNames = _useStatusClasses2.classNames;
196
221
  return ___EmotionJSX(Box, _extends({
222
+ isRow: true,
197
223
  ref: ref,
198
224
  as: "th",
199
225
  variant: "tableBase.head",
200
226
  className: classNames,
227
+ alignItems: "center",
201
228
  sx: _objectSpread({
229
+ gap: 'sm',
202
230
  width: layoutState === null || layoutState === void 0 ? void 0 : layoutState.getColumnWidth(column.key)
203
231
  }, column.props.sx)
204
- }, mergeProps(columnHeaderProps, focusProps, column.props)), column.rendered);
232
+ }, mergeProps(columnHeaderProps, focusProps, column.props)), column.rendered, allowsSorting && sortIcon);
205
233
  }
206
234
  export function TableRow(props) {
207
235
  var item = props.item,
@@ -214,6 +242,7 @@ export function TableRow(props) {
214
242
  }, state, ref),
215
243
  rowProps = _useTableRow.rowProps;
216
244
  var isSelected = state.selectionManager.isSelected(item.key);
245
+ var isDisabled = state.disabledKeys.has(item.key);
217
246
  var _useFocusRing2 = useFocusRing(),
218
247
  isFocusVisible = _useFocusRing2.isFocusVisible,
219
248
  focusProps = _useFocusRing2.focusProps;
@@ -229,7 +258,8 @@ export function TableRow(props) {
229
258
  isSelected: isSelected,
230
259
  isHovered: isHovered,
231
260
  isPressed: isPressed,
232
- isFocused: isFocusVisible
261
+ isFocused: isFocusVisible,
262
+ isDisabled: isDisabled
233
263
  }),
234
264
  classNames = _useStatusClasses3.classNames;
235
265
  return ___EmotionJSX(Box, _extends({
@@ -1,12 +1,28 @@
1
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
2
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
3
+ import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
4
+ import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
7
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
8
+ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
9
+ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
10
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
1
11
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context5; _forEachInstanceProperty(_context5 = ["next", "throw", "return"]).call(_context5, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context6; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context6 = this.tryEntries).call(_context6, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
13
  import _Set from "@babel/runtime-corejs3/core-js-stable/set";
3
14
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
15
  import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
16
+ import _Number$isNaN from "@babel/runtime-corejs3/core-js-stable/number/is-nan";
17
+ import _parseFloat from "@babel/runtime-corejs3/core-js-stable/parse-float";
18
+ import _sortInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/sort";
5
19
  import React, { useState } from 'react';
20
+ import { useCollator } from '@react-aria/i18n';
21
+ import { useAsyncList } from '@react-stately/data';
6
22
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
7
- import { Badge, Cell, Column, Pagination, PaginationProvider, Row, TableBase, TBody, Text, THead } from '../..';
23
+ import { Badge, Box, Cell, Column, Pagination, PaginationProvider, Row, TableBase, TBody, Text, THead } from '../..';
8
24
  import { usePaginationState } from '../../hooks';
9
- import { items } from '../../utils/devUtils/constants/items';
25
+ import { items as listData } from '../../utils/devUtils/constants/items';
10
26
  import TableReadme from './TableBase.mdx';
11
27
  import { jsx as ___EmotionJSX } from "@emotion/react";
12
28
  export default {
@@ -110,6 +126,9 @@ export var WithStickyHeader = function WithStickyHeader() {
110
126
  return ___EmotionJSX(TableBase, {
111
127
  "aria-label": "table",
112
128
  isStickyHeader: true,
129
+ selectionMode: "single",
130
+ defaultSelectedKeys: ['2'],
131
+ disabledKeys: ['3'],
113
132
  tableBodyProps: {
114
133
  style: {
115
134
  height: '300px'
@@ -124,12 +143,12 @@ export var WithStickyHeader = function WithStickyHeader() {
124
143
  }, "Status"), ___EmotionJSX(Column, {
125
144
  width: "1fr"
126
145
  }, "Bio")), ___EmotionJSX(TBody, {
127
- items: items
146
+ items: listData
128
147
  }, function (item) {
129
148
  var _context;
130
149
  return ___EmotionJSX(Row, {
131
- key: item.email
132
- }, ___EmotionJSX(Cell, null, _concatInstanceProperty(_context = "".concat(item.firstName, " ")).call(_context, item.lastName)), ___EmotionJSX(Cell, null, item.email), ___EmotionJSX(Cell, null, ___EmotionJSX(Badge, {
150
+ key: item.id
151
+ }, ___EmotionJSX(Cell, null, _concatInstanceProperty(_context = "".concat(item.firstName, " ")).call(_context, item.lastName), ' ', item.id), ___EmotionJSX(Cell, null, item.email), ___EmotionJSX(Cell, null, ___EmotionJSX(Badge, {
133
152
  variant: statusVariant[item.status],
134
153
  label: item.status
135
154
  })), ___EmotionJSX(Cell, null, ___EmotionJSX(Text, {
@@ -137,10 +156,23 @@ export var WithStickyHeader = function WithStickyHeader() {
137
156
  }, "Lorem ipsum dolor sit amet consectetur adipisicing elit. Quo quidem accusantium architecto tempore facere!")));
138
157
  }));
139
158
  };
159
+ WithStickyHeader.parameters = {
160
+ a11y: {
161
+ config: {
162
+ rules: [{
163
+ id: 'color-contrast',
164
+ enabled: false
165
+ }, {
166
+ id: 'scrollable-region-focusable',
167
+ enabled: false
168
+ }]
169
+ }
170
+ }
171
+ };
140
172
  var ExampleTable = function ExampleTable() {
141
173
  var _usePaginationState = usePaginationState(),
142
174
  paginationState = _usePaginationState.paginationState;
143
- var renderItems = _sliceInstanceProperty(items).call(items, paginationState.firstRenderedIndex, paginationState.lastRenderedIndex + 1);
175
+ var renderItems = _sliceInstanceProperty(listData).call(listData, paginationState.firstRenderedIndex, paginationState.lastRenderedIndex + 1);
144
176
  return ___EmotionJSX(TableBase, {
145
177
  "aria-label": "table"
146
178
  }, ___EmotionJSX(THead, null, ___EmotionJSX(Column, {
@@ -170,10 +202,165 @@ export var WithPagination = function WithPagination() {
170
202
  _useState2 = _slicedToArray(_useState, 2),
171
203
  offsetCount = _useState2[0],
172
204
  setOffsetCount = _useState2[1];
173
- return ___EmotionJSX(PaginationProvider, null, ___EmotionJSX(ExampleTable, null), ___EmotionJSX(Pagination, {
174
- totalCount: items.length,
205
+ return ___EmotionJSX(PaginationProvider, null, ___EmotionJSX(Box, {
206
+ gap: "sm"
207
+ }, ___EmotionJSX(ExampleTable, null), ___EmotionJSX(Pagination, {
208
+ totalCount: listData.length,
175
209
  offsetCount: offsetCount,
176
210
  onOffsetCountChange: setOffsetCount,
177
211
  offsetOptions: [10, 20, 50, 100]
212
+ })));
213
+ };
214
+ WithPagination.parameters = {
215
+ a11y: {
216
+ config: {
217
+ rules: [{
218
+ id: 'color-contrast',
219
+ enabled: false
220
+ }]
221
+ }
222
+ }
223
+ };
224
+ export var DynamicWithSorting = function DynamicWithSorting() {
225
+ var columns = [{
226
+ name: 'Country',
227
+ key: 'country',
228
+ isSortable: true
229
+ }, {
230
+ name: 'Population',
231
+ key: 'population',
232
+ isSortable: true
233
+ }, {
234
+ name: 'Continent',
235
+ key: 'continent',
236
+ isSortable: true
237
+ }];
238
+ var rows = [{
239
+ id: 1,
240
+ country: 'Austria',
241
+ population: '25,000,000',
242
+ continent: 'Oceania'
243
+ }, {
244
+ id: 2,
245
+ country: 'Canada',
246
+ population: '37,000,000',
247
+ continent: 'North America'
248
+ }, {
249
+ id: 3,
250
+ country: 'China',
251
+ population: '1,398,000,000',
252
+ continent: 'Asia'
253
+ }, {
254
+ id: 4,
255
+ country: 'Ethiopia',
256
+ population: '120,000,000',
257
+ continent: 'Africa'
258
+ }, {
259
+ id: 5,
260
+ country: 'France',
261
+ population: '67,000,000',
262
+ continent: 'Europe'
263
+ }, {
264
+ id: 6,
265
+ country: 'Mexico',
266
+ population: '126,000,000',
267
+ continent: 'North America'
268
+ }, {
269
+ id: 7,
270
+ country: 'USA',
271
+ population: '320,000,000',
272
+ continent: 'North America'
273
+ }];
274
+ var collator = useCollator({
275
+ numeric: true
276
+ });
277
+ var list = useAsyncList({
278
+ load: function load() {
279
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
280
+ return _regeneratorRuntime().wrap(function _callee$(_context3) {
281
+ while (1) switch (_context3.prev = _context3.next) {
282
+ case 0:
283
+ return _context3.abrupt("return", {
284
+ items: rows
285
+ });
286
+ case 1:
287
+ case "end":
288
+ return _context3.stop();
289
+ }
290
+ }, _callee);
291
+ }))();
292
+ },
293
+ sort: function sort(_ref) {
294
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
295
+ var items, sortDescriptor, getNumericValue;
296
+ return _regeneratorRuntime().wrap(function _callee2$(_context4) {
297
+ while (1) switch (_context4.prev = _context4.next) {
298
+ case 0:
299
+ items = _ref.items, sortDescriptor = _ref.sortDescriptor;
300
+ getNumericValue = function getNumericValue(str) {
301
+ return !_Number$isNaN(str) && _parseFloat(str.replace(/,/g, ''));
302
+ };
303
+ return _context4.abrupt("return", {
304
+ items: _sortInstanceProperty(items).call(items, function (a, b) {
305
+ if (sortDescriptor.column) {
306
+ var first = a[sortDescriptor.column];
307
+ var second = b[sortDescriptor.column];
308
+ var firstNumericValue = getNumericValue(first);
309
+ var secondNumericValue = getNumericValue(second);
310
+ var cmp = firstNumericValue && secondNumericValue ? firstNumericValue - secondNumericValue : collator.compare(first, second);
311
+ return sortDescriptor.direction === 'descending' ? -cmp : cmp;
312
+ }
313
+ return 1;
314
+ })
315
+ });
316
+ case 3:
317
+ case "end":
318
+ return _context4.stop();
319
+ }
320
+ }, _callee2);
321
+ }))();
322
+ },
323
+ initialSortDescriptor: {
324
+ column: 'country',
325
+ direction: 'ascending'
326
+ }
327
+ });
328
+ return ___EmotionJSX(TableBase, {
329
+ "aria-label": "Dynamic table",
330
+ onSortChange: function onSortChange(descriptor) {
331
+ if (descriptor.column) {
332
+ _sortInstanceProperty(list).call(list, descriptor);
333
+ }
334
+ },
335
+ sortDescriptor: list.sortDescriptor
336
+ }, ___EmotionJSX(THead, {
337
+ columns: columns
338
+ }, function (column) {
339
+ return ___EmotionJSX(Column, {
340
+ minWidth: 155,
341
+ allowsSorting: true
342
+ }, column.name);
343
+ }), ___EmotionJSX(TBody, {
344
+ items: list.items,
345
+ loadingState: list.loadingState,
346
+ onLoadMore: list.loadMore
347
+ }, function (item) {
348
+ return ___EmotionJSX(Row, {
349
+ key: item.name
350
+ }, function (columnKey) {
351
+ return ___EmotionJSX(Cell, null, item[columnKey]);
352
+ });
178
353
  }));
354
+ };
355
+
356
+ // Added to bypass color contrast issue due to virtualizer
357
+ DynamicWithSorting.parameters = {
358
+ a11y: {
359
+ config: {
360
+ rules: [{
361
+ id: 'color-contrast',
362
+ enabled: false
363
+ }]
364
+ }
365
+ }
179
366
  };
@@ -44,6 +44,9 @@ var head = _objectSpread(_objectSpread({}, text.label), {}, {
44
44
  textAlign: 'left',
45
45
  p: 'sm',
46
46
  cursor: 'default',
47
+ '&:focus-visible': {
48
+ outline: 'none'
49
+ },
47
50
  '&.is-focused': _objectSpread({}, defaultFocus)
48
51
  });
49
52
  var tbody = {
@@ -55,12 +58,18 @@ var row = {
55
58
  '&:nth-of-type(odd) ': {
56
59
  bg: 'neutral.95'
57
60
  },
61
+ '&:focus-visible': {
62
+ outline: 'none'
63
+ },
58
64
  '&.is-focused': _objectSpread({}, defaultFocus),
59
65
  '&.is-hovered': {
60
66
  // This is the hover state for the row
61
67
  },
62
- '&.is-selected': {
63
- // This is the selected state for the row
68
+ '&.is-selected': _objectSpread({}, defaultFocus),
69
+ '&.is-disabled': {
70
+ bg: 'neutral.90',
71
+ opacity: 0.5,
72
+ cursor: 'not-allowed'
64
73
  }
65
74
  };
66
75
  var data = _objectSpread(_objectSpread({}, text.tableData), {}, {