@algolia/satellite 1.0.0-beta.121 → 1.0.0-beta.125

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 (102) hide show
  1. package/cjs/Button/styles.d.ts +1 -1
  2. package/cjs/Checkbox/Checkbox.js +1 -0
  3. package/cjs/DatePicker/DatePicker.tailwind.js +7 -2
  4. package/cjs/Dropdown/DropdownButton.d.ts +1 -1
  5. package/cjs/Pagination/DotPagination/DotPagination.d.ts +2 -1
  6. package/cjs/Pagination/DotPagination/DotPagination.js +4 -2
  7. package/cjs/Pagination/Pagination/Pagination.js +3 -0
  8. package/cjs/ProgressSpinner/ProgressSpinner.js +1 -1
  9. package/cjs/Tables/DataTable/DataTable.d.ts +41 -0
  10. package/cjs/Tables/DataTable/DataTable.js +275 -0
  11. package/cjs/Tables/DataTable/DataTable.tailwind.d.ts +5 -0
  12. package/cjs/Tables/DataTable/DataTable.tailwind.js +23 -0
  13. package/cjs/Tables/DataTable/components/Body.d.ts +14 -0
  14. package/cjs/Tables/DataTable/components/Body.js +125 -0
  15. package/cjs/Tables/DataTable/components/Footer.d.ts +8 -0
  16. package/cjs/Tables/DataTable/components/Footer.js +81 -0
  17. package/cjs/Tables/DataTable/components/Header.d.ts +10 -0
  18. package/cjs/Tables/DataTable/components/Header.js +44 -0
  19. package/cjs/Tables/DataTable/components/HeaderCell.d.ts +11 -0
  20. package/cjs/Tables/DataTable/components/HeaderCell.js +61 -0
  21. package/cjs/Tables/DataTable/components/Loader.d.ts +6 -0
  22. package/cjs/Tables/DataTable/components/Loader.js +63 -0
  23. package/cjs/Tables/DataTable/components/index.d.ts +5 -0
  24. package/cjs/Tables/DataTable/components/index.js +70 -0
  25. package/cjs/Tables/DataTable/index.d.ts +3 -0
  26. package/cjs/Tables/DataTable/index.js +46 -0
  27. package/cjs/Tables/DataTable/types.d.ts +49 -0
  28. package/cjs/Tables/DataTable/types.js +5 -0
  29. package/cjs/Tables/DataTable/utils.d.ts +4 -0
  30. package/cjs/Tables/DataTable/utils.js +32 -0
  31. package/cjs/{Table → Tables/Table}/Table.d.ts +1 -1
  32. package/cjs/{Table → Tables/Table}/Table.js +8 -6
  33. package/cjs/Tables/Table/Table.tailwind.d.ts +5 -0
  34. package/cjs/{Table → Tables/Table}/Table.tailwind.js +6 -20
  35. package/cjs/Tables/Table/components/Footer.d.ts +8 -0
  36. package/cjs/Tables/Table/components/Footer.js +35 -0
  37. package/cjs/Tables/Table/index.d.ts +2 -0
  38. package/cjs/{Table → Tables/Table}/index.js +7 -5
  39. package/cjs/Tables/index.d.ts +3 -0
  40. package/cjs/Tables/index.js +46 -0
  41. package/cjs/index.d.ts +1 -1
  42. package/cjs/index.js +4 -4
  43. package/cjs/styles/tailwind.config.js +1 -1
  44. package/cjs/utils/index.d.ts +1 -0
  45. package/cjs/utils/index.js +9 -1
  46. package/cjs/utils/toSentenceCase.d.ts +3 -0
  47. package/cjs/utils/toSentenceCase.js +21 -0
  48. package/esm/Button/styles.d.ts +1 -1
  49. package/esm/Checkbox/Checkbox.js +1 -0
  50. package/esm/DatePicker/DatePicker.tailwind.js +7 -2
  51. package/esm/Dropdown/DropdownButton.d.ts +1 -1
  52. package/esm/Pagination/DotPagination/DotPagination.d.ts +2 -1
  53. package/esm/Pagination/DotPagination/DotPagination.js +4 -2
  54. package/esm/Pagination/Pagination/Pagination.js +3 -0
  55. package/esm/ProgressSpinner/ProgressSpinner.js +1 -1
  56. package/esm/Tables/DataTable/DataTable.d.ts +41 -0
  57. package/esm/Tables/DataTable/DataTable.js +243 -0
  58. package/esm/Tables/DataTable/DataTable.tailwind.d.ts +5 -0
  59. package/esm/Tables/DataTable/DataTable.tailwind.js +21 -0
  60. package/esm/Tables/DataTable/components/Body.d.ts +14 -0
  61. package/esm/Tables/DataTable/components/Body.js +106 -0
  62. package/esm/Tables/DataTable/components/Footer.d.ts +8 -0
  63. package/esm/Tables/DataTable/components/Footer.js +60 -0
  64. package/esm/Tables/DataTable/components/Header.d.ts +10 -0
  65. package/esm/Tables/DataTable/components/Header.js +29 -0
  66. package/esm/Tables/DataTable/components/HeaderCell.d.ts +11 -0
  67. package/esm/Tables/DataTable/components/HeaderCell.js +42 -0
  68. package/esm/Tables/DataTable/components/Loader.d.ts +6 -0
  69. package/esm/Tables/DataTable/components/Loader.js +40 -0
  70. package/esm/Tables/DataTable/components/index.d.ts +5 -0
  71. package/esm/Tables/DataTable/components/index.js +5 -0
  72. package/esm/Tables/DataTable/index.d.ts +3 -0
  73. package/esm/Tables/DataTable/index.js +3 -0
  74. package/esm/Tables/DataTable/types.d.ts +49 -0
  75. package/esm/Tables/DataTable/types.js +1 -0
  76. package/esm/Tables/DataTable/utils.d.ts +4 -0
  77. package/esm/Tables/DataTable/utils.js +14 -0
  78. package/esm/{Table → Tables/Table}/Table.d.ts +1 -1
  79. package/esm/{Table → Tables/Table}/Table.js +7 -6
  80. package/esm/Tables/Table/Table.tailwind.d.ts +5 -0
  81. package/esm/{Table → Tables/Table}/Table.tailwind.js +6 -20
  82. package/esm/Tables/Table/components/Footer.d.ts +8 -0
  83. package/esm/Tables/Table/components/Footer.js +20 -0
  84. package/esm/Tables/Table/index.d.ts +2 -0
  85. package/esm/Tables/Table/index.js +2 -0
  86. package/esm/Tables/index.d.ts +3 -0
  87. package/esm/Tables/index.js +3 -0
  88. package/esm/index.d.ts +1 -1
  89. package/esm/index.js +1 -1
  90. package/esm/styles/tailwind.config.js +1 -1
  91. package/esm/utils/index.d.ts +1 -0
  92. package/esm/utils/index.js +2 -1
  93. package/esm/utils/toSentenceCase.d.ts +3 -0
  94. package/esm/utils/toSentenceCase.js +9 -0
  95. package/package.json +1 -1
  96. package/satellite.css +18 -18
  97. package/satellite.min.css +1 -1
  98. package/cjs/Table/Table.tailwind.d.ts +0 -5
  99. package/cjs/Table/index.d.ts +0 -3
  100. package/esm/Table/Table.tailwind.d.ts +0 -5
  101. package/esm/Table/index.d.ts +0 -3
  102. package/esm/Table/index.js +0 -3
@@ -0,0 +1,21 @@
1
+ // purgecss whitelist: th, td, tr
2
+
3
+ /**
4
+ * @type {import('../../tailwind-types').TailwindPlugin}
5
+ */
6
+ var datatablePlugin = function datatablePlugin(_ref) {
7
+ var addComponents = _ref.addComponents,
8
+ theme = _ref.theme;
9
+ addComponents({
10
+ ".datatable": {
11
+ "tr.row-disabled td": {
12
+ cursor: "not-allowed"
13
+ },
14
+ "tr:not(.row-disabled):hover td": {
15
+ backgroundColor: theme("colors.grey.50")
16
+ }
17
+ }
18
+ });
19
+ };
20
+
21
+ export default datatablePlugin;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import type { DataTableProps } from "../DataTable";
3
+ import type { Row, AdvancedColumnDefinition, Status, SelectMode } from "../types";
4
+ export interface BodyProps<Item> extends Pick<DataTableProps<Item>, "selection" | "onSelectionChange" | "canHoverRow"> {
5
+ rows: Row<Item>[];
6
+ status?: Status;
7
+ noDataContent?: React.ReactNode;
8
+ errorContent?: React.ReactNode;
9
+ columns: AdvancedColumnDefinition<Item>[];
10
+ onRowHoverChange(row: Row<Item> | null): void;
11
+ selectMode: SelectMode;
12
+ }
13
+ export declare const Body: <Item extends {}>({ rows, columns, status, noDataContent, errorContent, selectMode, selection, onSelectionChange, onRowHoverChange, canHoverRow, }: BodyProps<Item>) => JSX.Element;
14
+ export default Body;
@@ -0,0 +1,106 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
5
+
6
+ var _templateObject, _templateObject2, _templateObject3;
7
+
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
9
+
10
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
11
+
12
+ import React from "react";
13
+ import stl from "../../../styles/helpers/satellitePrefixer";
14
+ import EmptyState from "../../../EmptyState";
15
+ import { getCellValue } from "../utils";
16
+ export var Body = function Body(_ref) {
17
+ var rows = _ref.rows,
18
+ columns = _ref.columns,
19
+ status = _ref.status,
20
+ noDataContent = _ref.noDataContent,
21
+ errorContent = _ref.errorContent,
22
+ selectMode = _ref.selectMode,
23
+ _ref$selection = _ref.selection,
24
+ selection = _ref$selection === void 0 ? [] : _ref$selection,
25
+ onSelectionChange = _ref.onSelectionChange,
26
+ onRowHoverChange = _ref.onRowHoverChange,
27
+ _ref$canHoverRow = _ref.canHoverRow,
28
+ canHoverRow = _ref$canHoverRow === void 0 ? function () {
29
+ return true;
30
+ } : _ref$canHoverRow;
31
+
32
+ var handleRowSelection = function handleRowSelection(row) {
33
+ if (!onSelectionChange) return;
34
+ var rowId = row.id;
35
+ var isSelected = selection.includes(rowId);
36
+ var newSelection = isSelected ? selection.filter(function (id) {
37
+ return id !== rowId;
38
+ }) : selectMode === "multi" ? [].concat(_toConsumableArray(selection), [rowId]) : [rowId];
39
+ onSelectionChange(newSelection);
40
+ };
41
+
42
+ var additionalRowProps = function additionalRowProps(row) {
43
+ return _objectSpread(_objectSpread({}, canHoverRow(row) ? {
44
+ onMouseEnter: function onMouseEnter() {
45
+ return onRowHoverChange(row);
46
+ },
47
+ onMouseLeave: function onMouseLeave() {
48
+ return onRowHoverChange(null);
49
+ },
50
+ className: "hoverable"
51
+ } : {
52
+ className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["row-disabled"])))
53
+ }), row.selectable && {
54
+ onClick: function onClick() {
55
+ return handleRowSelection(row);
56
+ }
57
+ });
58
+ };
59
+
60
+ if (status === "error") {
61
+ return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
62
+ colSpan: columns.length
63
+ }, /*#__PURE__*/React.createElement("span", {
64
+ className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["flex justify-center py-6"])))
65
+ }, errorContent || /*#__PURE__*/React.createElement(EmptyState, {
66
+ title: "Error",
67
+ description: "An error occurred while loading data.",
68
+ centered: true,
69
+ usageContext: "result"
70
+ })))));
71
+ }
72
+
73
+ if (rows.length === 0 && status !== "loading") {
74
+ return /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
75
+ colSpan: columns.length
76
+ }, /*#__PURE__*/React.createElement("span", {
77
+ className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["flex justify-center py-6"])))
78
+ }, noDataContent || /*#__PURE__*/React.createElement(EmptyState, {
79
+ title: "Empty",
80
+ description: "There is no data to display",
81
+ centered: true,
82
+ usageContext: "result"
83
+ })))));
84
+ }
85
+
86
+ return /*#__PURE__*/React.createElement("tbody", null, rows.map(function (row, rowIndex) {
87
+ return /*#__PURE__*/React.createElement("tr", _extends({}, additionalRowProps(row), {
88
+ key: rowIndex
89
+ }), columns.map(function (column) {
90
+ var value = getCellValue(column, row);
91
+ var Cell = column.Cell;
92
+ return Cell ? /*#__PURE__*/React.createElement("td", {
93
+ className: column === null || column === void 0 ? void 0 : column.className,
94
+ key: column.id
95
+ }, /*#__PURE__*/React.createElement(Cell, {
96
+ row: rows[rowIndex],
97
+ column: column,
98
+ value: value
99
+ })) : /*#__PURE__*/React.createElement("td", {
100
+ className: column === null || column === void 0 ? void 0 : column.className,
101
+ key: column.id
102
+ }, value !== null && value !== void 0 ? value : "-");
103
+ }));
104
+ }));
105
+ };
106
+ export default Body;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { PaginationConfiguration, DataConfiguration } from "../types";
3
+ export interface FooterProps {
4
+ pagination: PaginationConfiguration;
5
+ onChange(dataConfiguration: DataConfiguration): void;
6
+ }
7
+ export declare const Footer: ({ pagination, onChange }: FooterProps) => JSX.Element | null;
8
+ export default Footer;
@@ -0,0 +1,60 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ import React from "react";
8
+ import Pagination, { CompactPagination } from "../../../Pagination";
9
+ import { isDeterminatePagination, isIndeterminatePagination } from "../utils";
10
+ export var Footer = function Footer(_ref) {
11
+ var pagination = _ref.pagination,
12
+ onChange = _ref.onChange;
13
+ return isDeterminatePagination(pagination) ? /*#__PURE__*/React.createElement(Pagination, {
14
+ nbPages: Math.ceil(pagination.totalItemsCount / pagination.itemsPerPage),
15
+ currentPage: pagination.currentPage,
16
+ maxButtons: 8,
17
+ onChange: function (_onChange) {
18
+ function onChange(_x) {
19
+ return _onChange.apply(this, arguments);
20
+ }
21
+
22
+ onChange.toString = function () {
23
+ return _onChange.toString();
24
+ };
25
+
26
+ return onChange;
27
+ }(function (page) {
28
+ return onChange({
29
+ pagination: _objectSpread(_objectSpread({}, pagination), {}, {
30
+ currentPage: page
31
+ }),
32
+ sorting: []
33
+ });
34
+ })
35
+ }) : isIndeterminatePagination(pagination) ? /*#__PURE__*/React.createElement(CompactPagination, {
36
+ label: "compact",
37
+ currentPage: pagination.currentPage,
38
+ showGoToFirstPage: true,
39
+ nextDisabled: pagination.isLastPage,
40
+ onChange: function (_onChange2) {
41
+ function onChange(_x2) {
42
+ return _onChange2.apply(this, arguments);
43
+ }
44
+
45
+ onChange.toString = function () {
46
+ return _onChange2.toString();
47
+ };
48
+
49
+ return onChange;
50
+ }(function (page) {
51
+ return onChange({
52
+ pagination: _objectSpread(_objectSpread({}, pagination), {}, {
53
+ currentPage: page
54
+ }),
55
+ sorting: []
56
+ });
57
+ })
58
+ }) : null;
59
+ };
60
+ export default Footer;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import type { AdvancedColumnDefinition, Sorting, SortingDirection } from "../types";
3
+ export interface HeaderProps<Item> {
4
+ columns: AdvancedColumnDefinition<Item>[];
5
+ sorting?: Sorting[];
6
+ onToggleSort: (columnId: string, direction: SortingDirection) => void;
7
+ disabled?: boolean;
8
+ }
9
+ export declare const Header: <Item extends {}>({ columns, sorting, onToggleSort, disabled }: HeaderProps<Item>) => JSX.Element;
10
+ export default Header;
@@ -0,0 +1,29 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React from "react";
3
+ import HeaderCell from "./HeaderCell";
4
+ export var Header = function Header(_ref) {
5
+ var columns = _ref.columns,
6
+ _ref$sorting = _ref.sorting,
7
+ sorting = _ref$sorting === void 0 ? [] : _ref$sorting,
8
+ onToggleSort = _ref.onToggleSort,
9
+ disabled = _ref.disabled;
10
+ return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, columns.map(function (column) {
11
+ var Header = column.Header;
12
+ var sortingDirection = sorting.find(function (_ref2) {
13
+ var _ref3 = _slicedToArray(_ref2, 1),
14
+ colId = _ref3[0];
15
+
16
+ return colId === column.id;
17
+ }) || [null];
18
+ return /*#__PURE__*/React.createElement(HeaderCell, {
19
+ key: column.id,
20
+ column: column,
21
+ disabled: disabled,
22
+ sortingDirection: sortingDirection[1],
23
+ onToggleSort: onToggleSort
24
+ }, !Header ? null : typeof Header === "string" ? Header : /*#__PURE__*/React.createElement(Header, {
25
+ column: column
26
+ }));
27
+ })));
28
+ };
29
+ export default Header;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import type { AdvancedColumnDefinition, SortingDirection } from "../types";
3
+ export interface HeaderCellProps<Item> extends React.HTMLAttributes<HTMLTableCellElement> {
4
+ column: AdvancedColumnDefinition<Item>;
5
+ disabled?: boolean;
6
+ sortingDirection?: SortingDirection;
7
+ onToggleSort: (columnId: string, sortingDirection: SortingDirection) => void;
8
+ children: React.ReactNode;
9
+ }
10
+ export declare const HeaderCell: <Item extends {}>({ sortingDirection, onToggleSort, column: { id, className, sort }, disabled, children, ...props }: HeaderCellProps<Item>) => JSX.Element;
11
+ export default HeaderCell;
@@ -0,0 +1,42 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+ var _excluded = ["sortingDirection", "onToggleSort", "column", "disabled", "children"];
5
+
6
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
7
+
8
+ import React from "react";
9
+ import cx from "classnames";
10
+ import { ChevronDown, ChevronUp } from "react-feather";
11
+ import stl from "../../../styles/helpers/satellitePrefixer";
12
+ var iconClassName = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["h-4 inline ml-1"])));
13
+ export var HeaderCell = function HeaderCell(_ref) {
14
+ var _ref$sortingDirection = _ref.sortingDirection,
15
+ sortingDirection = _ref$sortingDirection === void 0 ? "none" : _ref$sortingDirection,
16
+ onToggleSort = _ref.onToggleSort,
17
+ _ref$column = _ref.column,
18
+ id = _ref$column.id,
19
+ className = _ref$column.className,
20
+ _ref$column$sort = _ref$column.sort,
21
+ sort = _ref$column$sort === void 0 ? false : _ref$column$sort,
22
+ disabled = _ref.disabled,
23
+ children = _ref.children,
24
+ props = _objectWithoutProperties(_ref, _excluded);
25
+
26
+ return /*#__PURE__*/React.createElement("th", _extends({}, props, {
27
+ "aria-sort": sortingDirection === "desc" ? "descending" : sortingDirection === "asc" ? "ascending" : "none",
28
+ onClick: function onClick() {
29
+ return sort && !disabled && onToggleSort(id, sortingDirection === "desc" ? "asc" : sortingDirection === "asc" ? "none" : "desc");
30
+ },
31
+ className: cx(className, stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["group ", ""])), sort && (disabled ? "cursor-not-allowed" : "cursor-pointer")))
32
+ }), /*#__PURE__*/React.createElement("span", {
33
+ className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["inline-flex items-center"])))
34
+ }, children, sort ? sortingDirection === "desc" ? /*#__PURE__*/React.createElement(ChevronDown, {
35
+ className: iconClassName
36
+ }) : sortingDirection === "asc" ? /*#__PURE__*/React.createElement(ChevronUp, {
37
+ className: iconClassName
38
+ }) : /*#__PURE__*/React.createElement(ChevronDown, {
39
+ className: cx(iconClassName, stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["text-grey-300 opacity-0 group-hover:opacity-100"]))))
40
+ }) : null));
41
+ };
42
+ export default HeaderCell;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface LoaderProps {
3
+ className?: string;
4
+ }
5
+ export declare const Loader: ({ className }: LoaderProps) => JSX.Element;
6
+ export default Loader;
@@ -0,0 +1,40 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+
4
+ var _templateObject;
5
+
6
+ import React, { useEffect, useState } from "react";
7
+ import stl from "../../../styles/helpers/satellitePrefixer";
8
+ import EmptyState from "../../../EmptyState";
9
+ import ProgressSpinner from "../../../ProgressSpinner";
10
+ export var Loader = function Loader(_ref) {
11
+ var className = _ref.className;
12
+
13
+ var _useState = useState(false),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ showLoadMessage = _useState2[0],
16
+ setShowLoadMessage = _useState2[1];
17
+
18
+ useEffect(function () {
19
+ // See https://github.com/algolia/AlgoliaWeb/blob/develop/_client/src/common/components/AsyncWrapper/AsyncWrapper.tsx#L56
20
+ var loadTimer = setTimeout(function () {
21
+ return setShowLoadMessage(true);
22
+ }, 5000);
23
+ return function () {
24
+ clearTimeout(loadTimer);
25
+ setShowLoadMessage(false);
26
+ };
27
+ }, []);
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ className: className
30
+ }, showLoadMessage ? /*#__PURE__*/React.createElement(EmptyState, {
31
+ usageContext: "result",
32
+ medallion: /*#__PURE__*/React.createElement("div", {
33
+ className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["flex justify-center"])))
34
+ }, /*#__PURE__*/React.createElement(ProgressSpinner, null)),
35
+ title: "It appears to be taking a while to get your data",
36
+ description: "Please hold or try again later",
37
+ centered: true
38
+ }) : /*#__PURE__*/React.createElement(ProgressSpinner, null));
39
+ };
40
+ export default Loader;
@@ -0,0 +1,5 @@
1
+ export * from "./Header";
2
+ export * from "./HeaderCell";
3
+ export * from "./Body";
4
+ export * from "./Footer";
5
+ export * from "./Loader";
@@ -0,0 +1,5 @@
1
+ export * from "./Header";
2
+ export * from "./HeaderCell";
3
+ export * from "./Body";
4
+ export * from "./Footer";
5
+ export * from "./Loader";
@@ -0,0 +1,3 @@
1
+ export * from "./DataTable";
2
+ export * from "./types";
3
+ export { default } from "./DataTable";
@@ -0,0 +1,3 @@
1
+ export * from "./DataTable";
2
+ export * from "./types";
3
+ export { default } from "./DataTable";
@@ -0,0 +1,49 @@
1
+ /// <reference types="react" />
2
+ export declare type Status = "loading" | "error" | "success";
3
+ export declare type SelectMode = "single" | "multi" | "none";
4
+ export declare type SortingDirection = "asc" | "desc" | "none";
5
+ export declare type Sorting = [columnId: string, direction: SortingDirection];
6
+ export declare type GetItemId<Item> = string | ((item: Item, idx: number) => string);
7
+ export interface Row<Item> {
8
+ item: Item;
9
+ id: string;
10
+ hovered: boolean;
11
+ selected: boolean;
12
+ selectable: boolean;
13
+ }
14
+ export interface CellProps<Item> {
15
+ value: any;
16
+ row: Row<Item>;
17
+ column: AdvancedColumnDefinition<Item>;
18
+ }
19
+ export interface HeaderProps<Item> {
20
+ column: AdvancedColumnDefinition<Item>;
21
+ }
22
+ export interface AdvancedColumnDefinition<Item> {
23
+ /** The ID of the column - Should be unique */
24
+ id: string;
25
+ /** A string or a function which determines how to get the column data */
26
+ accessor: string | ((item: Item) => any);
27
+ sort?: boolean;
28
+ Header?: React.ComponentType<HeaderProps<Item>> | string | false;
29
+ Cell?: React.ComponentType<CellProps<Item>>;
30
+ className?: string;
31
+ }
32
+ export declare type ColumnDefinition<Item> = string | AdvancedColumnDefinition<Item>;
33
+ export interface IndeterminatePagination {
34
+ currentPage: number;
35
+ itemsPerPage: number;
36
+ isLastPage?: boolean;
37
+ }
38
+ export interface DeterminatePagination {
39
+ currentPage: number;
40
+ itemsPerPage: number;
41
+ totalItemsCount: number;
42
+ }
43
+ export declare type PaginationConfiguration = false | IndeterminatePagination | DeterminatePagination;
44
+ export interface DataConfiguration {
45
+ /** The current pagination configuration */
46
+ pagination: PaginationConfiguration;
47
+ /** The current sorting configuration */
48
+ sorting: Sorting[];
49
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { Row, DeterminatePagination, IndeterminatePagination, PaginationConfiguration, AdvancedColumnDefinition } from "./types";
2
+ export declare const isDeterminatePagination: (pagination: PaginationConfiguration) => pagination is DeterminatePagination;
3
+ export declare const isIndeterminatePagination: (pagination: PaginationConfiguration) => pagination is IndeterminatePagination;
4
+ export declare const getCellValue: <Item extends {}>(column: AdvancedColumnDefinition<Item>, row: Row<Item>) => any;
@@ -0,0 +1,14 @@
1
+ import get from "lodash/get";
2
+ export var isDeterminatePagination = function isDeterminatePagination(pagination) {
3
+ return pagination !== false && "totalItemsCount" in pagination;
4
+ };
5
+ export var isIndeterminatePagination = function isIndeterminatePagination(pagination) {
6
+ return pagination !== false && !("totalItemsCount" in pagination) && "currentPage" in pagination && typeof pagination.currentPage === "number";
7
+ };
8
+ export var getCellValue = function getCellValue(column, row) {
9
+ if (typeof column.accessor === "string") {
10
+ return get(row.item, column.accessor);
11
+ }
12
+
13
+ return column.accessor(row.item);
14
+ };
@@ -6,7 +6,7 @@ export interface TableProps extends React.DetailedHTMLProps<React.TableHTMLAttri
6
6
  highlight?: boolean;
7
7
  }
8
8
  /**
9
- * Data tables are used to structure content in a grid to make it easier to see relationships and to facilitate understanding.
9
+ * Tables are used to structure content in a grid to make it easier to see relationships and to facilitate understanding.
10
10
  *
11
11
  * #### Do
12
12
  *
@@ -2,15 +2,16 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
 
5
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
5
+ var _templateObject, _templateObject2, _templateObject3;
6
6
 
7
7
  var _excluded = ["className", "footer", "smallFooter", "hasActions", "highlight"];
8
8
  import React from "react";
9
9
  import cx from "classnames";
10
- import stl from "../styles/helpers/satellitePrefixer";
10
+ import stl from "../../styles/helpers/satellitePrefixer";
11
+ import Footer from "./components/Footer";
11
12
 
12
13
  /**
13
- * Data tables are used to structure content in a grid to make it easier to see relationships and to facilitate understanding.
14
+ * Tables are used to structure content in a grid to make it easier to see relationships and to facilitate understanding.
14
15
  *
15
16
  * #### Do
16
17
  *
@@ -39,13 +40,13 @@ export var Table = function Table(_ref) {
39
40
  props = _objectWithoutProperties(_ref, _excluded);
40
41
 
41
42
  return /*#__PURE__*/React.createElement("div", {
42
- className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["table-wrapper rounded text-grey-900 bg-white display-body"]))), className)
43
+ className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["rounded text-grey-900 bg-white display-body"]))), className)
43
44
  }, /*#__PURE__*/React.createElement("div", {
44
45
  className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["overflow-x-auto"])))
45
46
  }, /*#__PURE__*/React.createElement("table", _extends({}, props, {
46
47
  className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["table ", " ", ""])), hasActions && "table-with-actions", highlight && "table-with-highlight")
47
- }))), footer && /*#__PURE__*/React.createElement("div", {
48
- className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["table-footer ", ""])), smallFooter && "table-footer-small")
48
+ }))), footer && /*#__PURE__*/React.createElement(Footer, {
49
+ size: smallFooter ? "small" : "default"
49
50
  }, footer));
50
51
  };
51
52
  export default Table;
@@ -0,0 +1,5 @@
1
+ export = tablePlugin;
2
+ /**
3
+ * @type {import('../../tailwind-types').TailwindPlugin}
4
+ */
5
+ declare const tablePlugin: import('../../tailwind-types').TailwindPlugin;
@@ -1,18 +1,12 @@
1
- import _rgba from "../styles/rgba";
2
- // @ts-check
3
- var rgba = _rgba; // purgecss whitelist: th, td, tr
1
+ // purgecss whitelist: th, td, tr
4
2
 
5
3
  /**
6
- * @type {import('../tailwind-types').TailwindPlugin}
4
+ * @type {import('../../tailwind-types').TailwindPlugin}
7
5
  */
8
-
9
6
  var tablePlugin = function tablePlugin(_ref) {
10
7
  var addComponents = _ref.addComponents,
11
8
  theme = _ref.theme;
12
9
  addComponents({
13
- ".table-wrapper": {
14
- border: "1px solid ".concat(theme("colors.grey.200"))
15
- },
16
10
  ".table": {
17
11
  width: "100%",
18
12
  borderCollapse: "collapse",
@@ -20,6 +14,9 @@ var tablePlugin = function tablePlugin(_ref) {
20
14
  "th, td": {
21
15
  padding: "14px 16px"
22
16
  },
17
+ thead: {
18
+ backgroundColor: theme("colors.grey.50")
19
+ },
23
20
  th: {
24
21
  borderBottom: "1px solid ".concat(theme("colors.grey.200")),
25
22
  fontWeight: "normal"
@@ -35,19 +32,8 @@ var tablePlugin = function tablePlugin(_ref) {
35
32
  },
36
33
  ".table-with-highlight": {
37
34
  "tr:hover td": {
38
- backgroundColor: rgba(theme("colors.grey.100"), 0.6)
35
+ backgroundColor: theme("colors.grey.50")
39
36
  }
40
- },
41
- ".table-footer": {
42
- backgroundColor: theme("colors.grey.100"),
43
- display: "flex",
44
- alignItems: "center",
45
- justifyContent: "center",
46
- color: theme("colors.grey.600"),
47
- padding: "12px 16px"
48
- },
49
- ".table-footer-small": {
50
- padding: "4px 16px"
51
37
  }
52
38
  });
53
39
  };
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ export declare type FooterSizes = "default" | "small";
3
+ export interface FooterProps {
4
+ size?: FooterSizes;
5
+ children?: React.ReactNode;
6
+ }
7
+ export declare const Footer: ({ size, children }: FooterProps) => JSX.Element;
8
+ export default Footer;
@@ -0,0 +1,20 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2, _templateObject3;
4
+
5
+ import React from "react";
6
+ import cx from "classnames";
7
+ import stl from "../../../styles/helpers/satellitePrefixer";
8
+ export var Footer = function Footer(_ref) {
9
+ var _ref$size = _ref.size,
10
+ size = _ref$size === void 0 ? "default" : _ref$size,
11
+ children = _ref.children;
12
+ var SIZE_CLASSNAMES = {
13
+ "default": stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["py-3 px-4"]))),
14
+ small: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["py-1 px-4"])))
15
+ };
16
+ return /*#__PURE__*/React.createElement("div", {
17
+ className: cx(stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["bg-grey-100 border-t border-grey-200 text-grey-600 flex items-center justify-center"]))), SIZE_CLASSNAMES[size])
18
+ }, children);
19
+ };
20
+ export default Footer;
@@ -0,0 +1,2 @@
1
+ export * from "./Table";
2
+ export { default } from "./Table";
@@ -0,0 +1,2 @@
1
+ export * from "./Table";
2
+ export { default } from "./Table";
@@ -0,0 +1,3 @@
1
+ export * from "./Table";
2
+ export * from "./DataTable";
3
+ export { default } from "./Table";
@@ -0,0 +1,3 @@
1
+ export * from "./Table";
2
+ export * from "./DataTable";
3
+ export { default } from "./Table";
package/esm/index.d.ts CHANGED
@@ -34,7 +34,7 @@ export * from "./Satellite";
34
34
  export * from "./Select";
35
35
  export * from "./Sidebar";
36
36
  export * from "./Switch";
37
- export * from "./Table";
37
+ export * from "./Tables";
38
38
  export * from "./Tabs";
39
39
  export * from "./Tag";
40
40
  export * from "./TextArea";
package/esm/index.js CHANGED
@@ -34,7 +34,7 @@ export * from "./Satellite";
34
34
  export * from "./Select";
35
35
  export * from "./Sidebar";
36
36
  export * from "./Switch";
37
- export * from "./Table";
37
+ export * from "./Tables";
38
38
  export * from "./Tabs";
39
39
  export * from "./Tag";
40
40
  export * from "./TextArea";