@entur/table 4.9.13 → 4.9.14-beta.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.
package/dist/table.esm.js CHANGED
@@ -1,428 +1,745 @@
1
- import { useRandomId, mergeRefs, warnAboutMissingStyles } from '@entur/utils';
2
- import React, { useRef, useEffect, useState, useMemo } from 'react';
3
- import classNames from 'classnames';
4
- import { VisuallyHidden } from '@entur/a11y';
5
- import { BulletBadge } from '@entur/layout';
6
- import { UnsortedIcon, UpArrowIcon, DownArrowIcon } from '@entur/icons';
7
- import get from 'lodash.get';
8
- import { VariantProvider } from '@entur/form';
9
- import { Tooltip } from '@entur/tooltip';
10
- import { BaseExpand } from '@entur/expand';
11
- import { IconButton } from '@entur/button';
12
-
13
- function _extends() {
14
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
15
- for (var e = 1; e < arguments.length; e++) {
16
- var t = arguments[e];
17
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
18
- }
19
- return n;
20
- }, _extends.apply(null, arguments);
21
- }
22
- function _objectDestructuringEmpty(t) {
23
- if (null == t) throw new TypeError("Cannot destructure " + t);
1
+ import { useRandomId, mergeRefs, warnAboutMissingStyles } from "@entur/utils";
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import React, { useRef, useEffect, useState, useMemo } from "react";
4
+ import { VisuallyHidden } from "@entur/a11y";
5
+ import { BulletBadge } from "@entur/layout";
6
+ import { UnsortedIcon, UpArrowIcon, DownArrowIcon } from "@entur/icons";
7
+ import { VariantProvider } from "@entur/form";
8
+ import { Tooltip } from "@entur/tooltip";
9
+ import { BaseExpand } from "@entur/expand";
10
+ import { IconButton } from "@entur/button";
11
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
12
+ function getDefaultExportFromCjs(x) {
13
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
24
14
  }
25
- function _objectWithoutPropertiesLoose(r, e) {
26
- if (null == r) return {};
27
- var t = {};
28
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
29
- if (e.includes(n)) continue;
30
- t[n] = r[n];
31
- }
32
- return t;
15
+ var classnames = { exports: {} };
16
+ /*!
17
+ Copyright (c) 2018 Jed Watson.
18
+ Licensed under the MIT License (MIT), see
19
+ http://jedwatson.github.io/classnames
20
+ */
21
+ var hasRequiredClassnames;
22
+ function requireClassnames() {
23
+ if (hasRequiredClassnames) return classnames.exports;
24
+ hasRequiredClassnames = 1;
25
+ (function(module) {
26
+ (function() {
27
+ var hasOwn = {}.hasOwnProperty;
28
+ function classNames2() {
29
+ var classes = "";
30
+ for (var i = 0; i < arguments.length; i++) {
31
+ var arg = arguments[i];
32
+ if (arg) {
33
+ classes = appendClass(classes, parseValue(arg));
34
+ }
35
+ }
36
+ return classes;
37
+ }
38
+ function parseValue(arg) {
39
+ if (typeof arg === "string" || typeof arg === "number") {
40
+ return arg;
41
+ }
42
+ if (typeof arg !== "object") {
43
+ return "";
44
+ }
45
+ if (Array.isArray(arg)) {
46
+ return classNames2.apply(null, arg);
47
+ }
48
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
49
+ return arg.toString();
50
+ }
51
+ var classes = "";
52
+ for (var key in arg) {
53
+ if (hasOwn.call(arg, key) && arg[key]) {
54
+ classes = appendClass(classes, key);
55
+ }
56
+ }
57
+ return classes;
58
+ }
59
+ function appendClass(value, newClass) {
60
+ if (!newClass) {
61
+ return value;
62
+ }
63
+ if (value) {
64
+ return value + " " + newClass;
65
+ }
66
+ return value + newClass;
67
+ }
68
+ if (module.exports) {
69
+ classNames2.default = classNames2;
70
+ module.exports = classNames2;
71
+ } else {
72
+ window.classNames = classNames2;
73
+ }
74
+ })();
75
+ })(classnames);
76
+ return classnames.exports;
33
77
  }
34
-
35
- var _excluded$8 = ["className", "fixed", "spacing", "sortable", "changeSortDescription", "stickyHeader"];
36
- var Table = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
37
- var className = _ref.className,
38
- _ref$fixed = _ref.fixed,
39
- fixed = _ref$fixed === void 0 ? false : _ref$fixed,
40
- _ref$spacing = _ref.spacing,
41
- spacing = _ref$spacing === void 0 ? 'default' : _ref$spacing,
42
- _ref$sortable = _ref.sortable,
43
- sortable = _ref$sortable === void 0 ? false : _ref$sortable,
44
- _ref$changeSortDescri = _ref.changeSortDescription,
45
- changeSortDescription = _ref$changeSortDescri === void 0 ? 'Tabelloverskrifter med knapper kan trykkes på for å endre sortering,' : _ref$changeSortDescri,
46
- _ref$stickyHeader = _ref.stickyHeader,
47
- stickyHeader = _ref$stickyHeader === void 0 ? false : _ref$stickyHeader,
48
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
49
- var sortableHeaderId = useRandomId('sortable-header');
50
- var tableRef = useRef(null);
51
- useEffect(function () {
52
- if (stickyHeader) {
53
- var _tableElement$parentN;
54
- /* We check when an inserted div above the header
55
- is outside our scrolling container to determine when
56
- the table header becomes sticky. This is necessary
57
- to conditionally add our box-shadow when the
58
- header is overlapping table rows */
59
- var tableElement = tableRef.current;
60
- var observerElement = document.createElement('div');
61
- observerElement.classList.add('sticky-observer');
62
- tableElement == null || (_tableElement$parentN = tableElement.parentNode) == null || _tableElement$parentN.insertBefore(observerElement, tableElement);
63
- var observer = new IntersectionObserver(function (entries) {
64
- tableElement == null || tableElement.classList.toggle('eds-table--sticky-header--active', !entries[0].isIntersecting);
65
- }, {
66
- threshold: [0, 1]
67
- });
68
- observer.observe(observerElement);
69
- return function () {
70
- observer.unobserve(observerElement);
71
- observerElement.remove();
72
- };
78
+ var classnamesExports = requireClassnames();
79
+ const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
80
+ const Table = React.forwardRef(
81
+ ({
82
+ className,
83
+ fixed = false,
84
+ spacing = "default",
85
+ sortable = false,
86
+ changeSortDescription = "Tabelloverskrifter med knapper kan trykkes på for å endre sortering,",
87
+ stickyHeader = false,
88
+ ...rest
89
+ }, ref) => {
90
+ const sortableHeaderId = useRandomId("sortable-header");
91
+ const tableRef = useRef(null);
92
+ useEffect(() => {
93
+ if (stickyHeader) {
94
+ const tableElement = tableRef.current;
95
+ const observerElement = document.createElement("div");
96
+ observerElement.classList.add("sticky-observer");
97
+ tableElement?.parentNode?.insertBefore(observerElement, tableElement);
98
+ const observer = new IntersectionObserver(
99
+ (entries) => {
100
+ tableElement?.classList.toggle(
101
+ "eds-table--sticky-header--active",
102
+ !entries[0].isIntersecting
103
+ );
104
+ },
105
+ { threshold: [0, 1] }
106
+ );
107
+ observer.observe(observerElement);
108
+ return () => {
109
+ observer.unobserve(observerElement);
110
+ observerElement.remove();
111
+ };
112
+ }
113
+ }, [stickyHeader]);
114
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
115
+ /* @__PURE__ */ jsx(
116
+ "table",
117
+ {
118
+ className: classNames(
119
+ "eds-table",
120
+ { "eds-table--fixed": fixed },
121
+ { "eds-table--middle": spacing === "middle" },
122
+ { "eds-table--small": spacing === "small" },
123
+ { "eds-table--sortable": sortable },
124
+ { "eds-table--sticky-header": stickyHeader },
125
+ className
126
+ ),
127
+ ref: mergeRefs(ref, tableRef),
128
+ "aria-describedby": sortable ? sortableHeaderId : void 0,
129
+ ...rest
130
+ }
131
+ ),
132
+ sortable && /* @__PURE__ */ jsx(VisuallyHidden, { id: sortableHeaderId, children: changeSortDescription })
133
+ ] });
134
+ }
135
+ );
136
+ const TableHead = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
137
+ "thead",
138
+ {
139
+ className: classNames("eds-table__head", className),
140
+ ref,
141
+ ...props
142
+ }
143
+ ));
144
+ const TableBody = React.forwardRef(({ className, ...rest }, ref) => /* @__PURE__ */ jsx(
145
+ "tbody",
146
+ {
147
+ className: classNames("eds-table__body", className),
148
+ ref,
149
+ ...rest
150
+ }
151
+ ));
152
+ const TableFooter = React.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("tfoot", { ref, ...props }));
153
+ const TableRow = React.forwardRef(
154
+ ({ className, hover = false, active = false, error = false, ...rest }, ref) => /* @__PURE__ */ jsx(
155
+ "tr",
156
+ {
157
+ className: classNames("eds-table__row", className, {
158
+ "eds-table__row--hover": hover,
159
+ "eds-table__row--active": active,
160
+ "eds-table__row--error": error
161
+ }),
162
+ ref,
163
+ ...rest
73
164
  }
74
- }, [stickyHeader]);
75
- return React.createElement(React.Fragment, null, React.createElement("table", _extends({
76
- className: classNames('eds-table', {
77
- 'eds-table--fixed': fixed
78
- }, {
79
- 'eds-table--middle': spacing === 'middle'
80
- }, {
81
- 'eds-table--small': spacing === 'small'
82
- }, {
83
- 'eds-table--sortable': sortable
84
- }, {
85
- 'eds-table--sticky-header': stickyHeader
86
- }, className),
87
- ref: mergeRefs(ref, tableRef),
88
- "aria-describedby": sortable ? sortableHeaderId : undefined
89
- }, rest)), sortable && React.createElement(VisuallyHidden, {
90
- id: sortableHeaderId
91
- }, changeSortDescription));
92
- });
93
-
94
- var _excluded$7 = ["className"];
95
- var TableHead = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
96
- var className = _ref.className,
97
- props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
98
- return React.createElement("thead", _extends({
99
- className: classNames('eds-table__head', className),
100
- ref: ref
101
- }, props));
102
- });
103
-
104
- var _excluded$6 = ["className"];
105
- var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
106
- var className = _ref.className,
107
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
108
- return React.createElement("tbody", _extends({
109
- className: classNames('eds-table__body', className),
110
- ref: ref
111
- }, rest));
112
- });
113
-
114
- var TableFooter = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
115
- var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
116
- return React.createElement("tfoot", _extends({
117
- ref: ref
118
- }, props));
119
- });
120
-
121
- var _excluded$5 = ["className", "hover", "active", "error"];
122
- var TableRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
123
- var className = _ref.className,
124
- _ref$hover = _ref.hover,
125
- hover = _ref$hover === void 0 ? false : _ref$hover,
126
- _ref$active = _ref.active,
127
- active = _ref$active === void 0 ? false : _ref$active,
128
- _ref$error = _ref.error,
129
- error = _ref$error === void 0 ? false : _ref$error,
130
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
131
- return React.createElement("tr", _extends({
132
- className: classNames('eds-table__row', className, {
133
- 'eds-table__row--hover': hover,
134
- 'eds-table__row--active': active,
135
- 'eds-table__row--error': error
136
- }),
137
- ref: ref
138
- }, rest));
139
- });
140
-
141
- var _excluded$4 = ["className", "padding", "status", "variant", "children"];
165
+ )
166
+ );
142
167
  function mapStatusToVariant(status) {
143
168
  switch (status) {
144
- case 'positive':
145
- return 'success';
146
- case 'negative':
147
- return 'negative';
148
- case 'neutral':
149
- return 'neutral';
169
+ case "positive":
170
+ return "success";
171
+ case "negative":
172
+ return "negative";
173
+ case "neutral":
174
+ return "neutral";
150
175
  default:
151
- return 'neutral';
176
+ return "neutral";
152
177
  }
153
178
  }
154
- var DataCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
155
- var className = _ref.className,
156
- _ref$padding = _ref.padding,
157
- padding = _ref$padding === void 0 ? 'default' : _ref$padding,
158
- status = _ref.status,
159
- variant = _ref.variant,
160
- children = _ref.children,
161
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
162
- // If variant is undefined and status is defined, map status to variant
163
- if (!variant && status) {
164
- variant = mapStatusToVariant(status);
165
- }
166
- return React.createElement("td", _extends({
167
- ref: ref,
168
- className: classNames('eds-table__data-cell', className, {
169
- 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',
170
- 'eds-table__data-cell--padding-radio': padding === 'radio',
171
- 'eds-table__data-cell--padding-overflow-menu': padding === 'overflow-menu'
172
- })
173
- }, rest), variant ? React.createElement(BulletBadge, {
174
- variant: variant
175
- }, children) : children);
176
- });
177
-
178
- var _excluded$3 = ["className", "children", "name", "sortable", "sortConfig", "padding", "sortableButtonProps", "sortedAscendingAriaLabel", "sortedDescendingAriaLabel"],
179
- _excluded2$1 = ["className"];
180
- var HeaderCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
181
- var className = _ref.className,
182
- children = _ref.children,
183
- name = _ref.name,
184
- _ref$sortable = _ref.sortable,
185
- sortable = _ref$sortable === void 0 ? false : _ref$sortable,
186
- sortConfig = _ref.sortConfig,
187
- _ref$padding = _ref.padding,
188
- padding = _ref$padding === void 0 ? 'default' : _ref$padding,
189
- sortableButtonProps = _ref.sortableButtonProps,
190
- _ref$sortedAscendingA = _ref.sortedAscendingAriaLabel,
191
- sortedAscendingAriaLabel = _ref$sortedAscendingA === void 0 ? ', sortert stigende' : _ref$sortedAscendingA,
192
- _ref$sortedDescending = _ref.sortedDescendingAriaLabel,
193
- sortedDescendingAriaLabel = _ref$sortedDescending === void 0 ? ', sortert synkende' : _ref$sortedDescending,
194
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
195
- var _React$useState = React.useState(false),
196
- isCurrentlySorted = _React$useState[0],
197
- setIsCurrentlySorted = _React$useState[1];
198
- React.useEffect(function () {
199
- sortConfig && name && setIsCurrentlySorted(sortConfig && name === sortConfig.key);
200
- }, [sortConfig, name]);
201
- var ariaSort = isCurrentlySorted ? sortConfig && sortConfig.order : undefined;
202
- return React.createElement("th", _extends({
203
- className: classNames('eds-table__header-cell', className, {
204
- 'eds-table__header-cell--sortable': sortable,
205
- 'eds-table__header-cell--padding-radio': padding === 'radio',
206
- 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',
207
- 'eds-table__header-cell--padding-overflow-menu': padding === 'overflow-menu'
208
- }),
209
- "aria-sort": ariaSort,
210
- ref: ref
211
- }, rest), sortable && sortConfig && sortableButtonProps ? React.createElement(SortableHeaderCellButton, {
212
- sortableButtonProps: sortableButtonProps,
213
- sortConfig: sortConfig,
214
- isCurrentlySorted: isCurrentlySorted,
215
- ariaSort: ariaSort,
216
- sortedAscendingAriaLabel: sortedAscendingAriaLabel,
217
- sortedDescendingAriaLabel: sortedDescendingAriaLabel
218
- }, children) : children);
219
- });
220
- var SortableHeaderCellButton = function SortableHeaderCellButton(_ref2) {
221
- var sortConfig = _ref2.sortConfig,
222
- sortableButtonProps = _ref2.sortableButtonProps,
223
- isCurrentlySorted = _ref2.isCurrentlySorted,
224
- children = _ref2.children,
225
- ariaSort = _ref2.ariaSort,
226
- sortedAscendingAriaLabel = _ref2.sortedAscendingAriaLabel,
227
- sortedDescendingAriaLabel = _ref2.sortedDescendingAriaLabel;
228
- var _useState = useState(''),
229
- sortedAriaInfo = _useState[0],
230
- setSortedAriaInfo = _useState[1];
231
- var className = sortableButtonProps.className,
232
- rest = _objectWithoutPropertiesLoose(sortableButtonProps, _excluded2$1);
233
- var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
234
- useEffect(function () {
235
- var DISMISS_SORT_INFO_TIME = 3000;
236
- if (sortConfig.order == 'ascending') {
179
+ const DataCell = React.forwardRef(
180
+ ({ className, padding = "default", status, variant, children, ...rest }, ref) => {
181
+ if (!variant && status) {
182
+ variant = mapStatusToVariant(status);
183
+ }
184
+ return /* @__PURE__ */ jsx(
185
+ "td",
186
+ {
187
+ ref,
188
+ className: classNames("eds-table__data-cell", className, {
189
+ "eds-table__data-cell--padding-checkbox": padding === "checkbox",
190
+ "eds-table__data-cell--padding-radio": padding === "radio",
191
+ "eds-table__data-cell--padding-overflow-menu": padding === "overflow-menu"
192
+ }),
193
+ ...rest,
194
+ children: variant ? /* @__PURE__ */ jsx(BulletBadge, { variant, children }) : children
195
+ }
196
+ );
197
+ }
198
+ );
199
+ const HeaderCell = React.forwardRef(
200
+ ({
201
+ className,
202
+ children,
203
+ name,
204
+ sortable = false,
205
+ sortConfig,
206
+ padding = "default",
207
+ sortableButtonProps,
208
+ sortedAscendingAriaLabel = ", sortert stigende",
209
+ sortedDescendingAriaLabel = ", sortert synkende",
210
+ ...rest
211
+ }, ref) => {
212
+ const [isCurrentlySorted, setIsCurrentlySorted] = React.useState(false);
213
+ React.useEffect(() => {
214
+ sortConfig && name && setIsCurrentlySorted(sortConfig && name === sortConfig.key);
215
+ }, [sortConfig, name]);
216
+ const ariaSort = isCurrentlySorted ? sortConfig && sortConfig.order : void 0;
217
+ return /* @__PURE__ */ jsx(
218
+ "th",
219
+ {
220
+ className: classNames("eds-table__header-cell", className, {
221
+ "eds-table__header-cell--sortable": sortable,
222
+ "eds-table__header-cell--padding-radio": padding === "radio",
223
+ "eds-table__header-cell--padding-checkbox": padding === "checkbox",
224
+ "eds-table__header-cell--padding-overflow-menu": padding === "overflow-menu"
225
+ }),
226
+ "aria-sort": ariaSort,
227
+ ref,
228
+ ...rest,
229
+ children: sortable && sortConfig && sortableButtonProps ? /* @__PURE__ */ jsx(
230
+ SortableHeaderCellButton,
231
+ {
232
+ sortableButtonProps,
233
+ sortConfig,
234
+ isCurrentlySorted,
235
+ ariaSort,
236
+ sortedAscendingAriaLabel,
237
+ sortedDescendingAriaLabel,
238
+ children
239
+ }
240
+ ) : children
241
+ }
242
+ );
243
+ }
244
+ );
245
+ const SortableHeaderCellButton = ({
246
+ sortConfig,
247
+ sortableButtonProps,
248
+ isCurrentlySorted,
249
+ children,
250
+ ariaSort,
251
+ sortedAscendingAriaLabel,
252
+ sortedDescendingAriaLabel
253
+ }) => {
254
+ const [sortedAriaInfo, setSortedAriaInfo] = useState("");
255
+ const { className, ...rest } = sortableButtonProps;
256
+ const isFirefox = navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
257
+ useEffect(() => {
258
+ const DISMISS_SORT_INFO_TIME = 3e3;
259
+ if (sortConfig.order == "ascending") {
237
260
  setSortedAriaInfo(sortedAscendingAriaLabel);
238
- } else if (sortConfig.order == 'descending') {
261
+ } else if (sortConfig.order == "descending") {
239
262
  setSortedAriaInfo(sortedDescendingAriaLabel);
240
263
  }
241
- var dismissAriaTimer = setTimeout(function () {
242
- setSortedAriaInfo('');
243
- if (isFirefox) setSortedAriaInfo(', sort ' + sortConfig.order);
264
+ const dismissAriaTimer = setTimeout(() => {
265
+ setSortedAriaInfo("");
266
+ if (isFirefox) setSortedAriaInfo(", sort " + sortConfig.order);
244
267
  }, DISMISS_SORT_INFO_TIME);
245
- return function () {
246
- return clearTimeout(dismissAriaTimer);
247
- };
268
+ return () => clearTimeout(dismissAriaTimer);
248
269
  }, [sortConfig.order]);
249
- return React.createElement("button", _extends({
250
- className: classNames('eds-table__header-cell-button', className),
251
- type: "button",
252
- "aria-sort": ariaSort
253
- }, rest), children, (!isCurrentlySorted || sortConfig.order === 'none') && React.createElement(UnsortedIcon, {
254
- size: "1em",
255
- className: "eds-table__header-cell-button-icon",
256
- "aria-hidden": "true"
257
- }), isCurrentlySorted && sortConfig.order === 'ascending' && React.createElement(UpArrowIcon, {
258
- size: "1em",
259
- className: "eds-table__header-cell-button-icon",
260
- "aria-hidden": "true"
261
- }), isCurrentlySorted && sortConfig.order === 'descending' && React.createElement(DownArrowIcon, {
262
- size: "1em",
263
- className: "eds-table__header-cell-button-icon",
264
- "aria-hidden": "true"
265
- }), React.createElement(VisuallyHidden, null, isCurrentlySorted && sortedAriaInfo));
270
+ return /* @__PURE__ */ jsxs(
271
+ "button",
272
+ {
273
+ className: classNames("eds-table__header-cell-button", className),
274
+ type: "button",
275
+ "aria-sort": ariaSort,
276
+ ...rest,
277
+ children: [
278
+ children,
279
+ (!isCurrentlySorted || sortConfig.order === "none") && /* @__PURE__ */ jsx(
280
+ UnsortedIcon,
281
+ {
282
+ size: "1em",
283
+ className: "eds-table__header-cell-button-icon",
284
+ "aria-hidden": "true"
285
+ }
286
+ ),
287
+ isCurrentlySorted && sortConfig.order === "ascending" && /* @__PURE__ */ jsx(
288
+ UpArrowIcon,
289
+ {
290
+ size: "1em",
291
+ className: "eds-table__header-cell-button-icon",
292
+ "aria-hidden": "true"
293
+ }
294
+ ),
295
+ isCurrentlySorted && sortConfig.order === "descending" && /* @__PURE__ */ jsx(
296
+ DownArrowIcon,
297
+ {
298
+ size: "1em",
299
+ className: "eds-table__header-cell-button-icon",
300
+ "aria-hidden": "true"
301
+ }
302
+ ),
303
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: isCurrentlySorted && sortedAriaInfo })
304
+ ]
305
+ }
306
+ );
266
307
  };
267
-
268
- var _excluded$2 = ["name", "sortable", "buttonProps"],
269
- _excluded2 = ["sortable"];
270
- function useSortableData(tableData, externalSortConfig) {
271
- if (externalSortConfig === void 0) {
272
- externalSortConfig = {
273
- key: '',
274
- order: 'none'
308
+ var lodash_get;
309
+ var hasRequiredLodash_get;
310
+ function requireLodash_get() {
311
+ if (hasRequiredLodash_get) return lodash_get;
312
+ hasRequiredLodash_get = 1;
313
+ var FUNC_ERROR_TEXT = "Expected a function";
314
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
315
+ var funcTag = "[object Function]", genTag = "[object GeneratorFunction]", symbolTag = "[object Symbol]";
316
+ var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, reLeadingDot = /^\./, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
317
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
318
+ var reEscapeChar = /\\(\\)?/g;
319
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
320
+ var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
321
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
322
+ var root = freeGlobal || freeSelf || Function("return this")();
323
+ function getValue(object, key) {
324
+ return object == null ? void 0 : object[key];
325
+ }
326
+ function isHostObject(value) {
327
+ var result = false;
328
+ if (value != null && typeof value.toString != "function") {
329
+ try {
330
+ result = !!(value + "");
331
+ } catch (e) {
332
+ }
333
+ }
334
+ return result;
335
+ }
336
+ var arrayProto = Array.prototype, funcProto = Function.prototype, objectProto = Object.prototype;
337
+ var coreJsData = root["__core-js_shared__"];
338
+ var maskSrcKey = function() {
339
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
340
+ return uid ? "Symbol(src)_1." + uid : "";
341
+ }();
342
+ var funcToString = funcProto.toString;
343
+ var hasOwnProperty = objectProto.hasOwnProperty;
344
+ var objectToString = objectProto.toString;
345
+ var reIsNative = RegExp(
346
+ "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
347
+ );
348
+ var Symbol = root.Symbol, splice = arrayProto.splice;
349
+ var Map = getNative(root, "Map"), nativeCreate = getNative(Object, "create");
350
+ var symbolProto = Symbol ? Symbol.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
351
+ function Hash(entries) {
352
+ var index = -1, length = entries ? entries.length : 0;
353
+ this.clear();
354
+ while (++index < length) {
355
+ var entry = entries[index];
356
+ this.set(entry[0], entry[1]);
357
+ }
358
+ }
359
+ function hashClear() {
360
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
361
+ }
362
+ function hashDelete(key) {
363
+ return this.has(key) && delete this.__data__[key];
364
+ }
365
+ function hashGet(key) {
366
+ var data = this.__data__;
367
+ if (nativeCreate) {
368
+ var result = data[key];
369
+ return result === HASH_UNDEFINED ? void 0 : result;
370
+ }
371
+ return hasOwnProperty.call(data, key) ? data[key] : void 0;
372
+ }
373
+ function hashHas(key) {
374
+ var data = this.__data__;
375
+ return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
376
+ }
377
+ function hashSet(key, value) {
378
+ var data = this.__data__;
379
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
380
+ return this;
381
+ }
382
+ Hash.prototype.clear = hashClear;
383
+ Hash.prototype["delete"] = hashDelete;
384
+ Hash.prototype.get = hashGet;
385
+ Hash.prototype.has = hashHas;
386
+ Hash.prototype.set = hashSet;
387
+ function ListCache(entries) {
388
+ var index = -1, length = entries ? entries.length : 0;
389
+ this.clear();
390
+ while (++index < length) {
391
+ var entry = entries[index];
392
+ this.set(entry[0], entry[1]);
393
+ }
394
+ }
395
+ function listCacheClear() {
396
+ this.__data__ = [];
397
+ }
398
+ function listCacheDelete(key) {
399
+ var data = this.__data__, index = assocIndexOf(data, key);
400
+ if (index < 0) {
401
+ return false;
402
+ }
403
+ var lastIndex = data.length - 1;
404
+ if (index == lastIndex) {
405
+ data.pop();
406
+ } else {
407
+ splice.call(data, index, 1);
408
+ }
409
+ return true;
410
+ }
411
+ function listCacheGet(key) {
412
+ var data = this.__data__, index = assocIndexOf(data, key);
413
+ return index < 0 ? void 0 : data[index][1];
414
+ }
415
+ function listCacheHas(key) {
416
+ return assocIndexOf(this.__data__, key) > -1;
417
+ }
418
+ function listCacheSet(key, value) {
419
+ var data = this.__data__, index = assocIndexOf(data, key);
420
+ if (index < 0) {
421
+ data.push([key, value]);
422
+ } else {
423
+ data[index][1] = value;
424
+ }
425
+ return this;
426
+ }
427
+ ListCache.prototype.clear = listCacheClear;
428
+ ListCache.prototype["delete"] = listCacheDelete;
429
+ ListCache.prototype.get = listCacheGet;
430
+ ListCache.prototype.has = listCacheHas;
431
+ ListCache.prototype.set = listCacheSet;
432
+ function MapCache(entries) {
433
+ var index = -1, length = entries ? entries.length : 0;
434
+ this.clear();
435
+ while (++index < length) {
436
+ var entry = entries[index];
437
+ this.set(entry[0], entry[1]);
438
+ }
439
+ }
440
+ function mapCacheClear() {
441
+ this.__data__ = {
442
+ "hash": new Hash(),
443
+ "map": new (Map || ListCache)(),
444
+ "string": new Hash()
275
445
  };
276
446
  }
277
- var _useState = useState(externalSortConfig),
278
- sortConfig = _useState[0],
279
- setSortConfig = _useState[1];
280
- var onSortRequested = function onSortRequested(key) {
281
- var sortingNewColumn = key !== sortConfig.key;
282
- if (sortingNewColumn || sortConfig.order === 'none') return setSortConfig({
283
- key: key,
284
- order: 'ascending'
285
- });
286
- if (sortConfig.order === 'ascending') return setSortConfig({
287
- key: key,
288
- order: 'descending'
289
- });
290
- if (sortConfig.order === 'descending') return setSortConfig({
291
- key: key,
292
- order: 'none'
447
+ function mapCacheDelete(key) {
448
+ return getMapData(this, key)["delete"](key);
449
+ }
450
+ function mapCacheGet(key) {
451
+ return getMapData(this, key).get(key);
452
+ }
453
+ function mapCacheHas(key) {
454
+ return getMapData(this, key).has(key);
455
+ }
456
+ function mapCacheSet(key, value) {
457
+ getMapData(this, key).set(key, value);
458
+ return this;
459
+ }
460
+ MapCache.prototype.clear = mapCacheClear;
461
+ MapCache.prototype["delete"] = mapCacheDelete;
462
+ MapCache.prototype.get = mapCacheGet;
463
+ MapCache.prototype.has = mapCacheHas;
464
+ MapCache.prototype.set = mapCacheSet;
465
+ function assocIndexOf(array, key) {
466
+ var length = array.length;
467
+ while (length--) {
468
+ if (eq(array[length][0], key)) {
469
+ return length;
470
+ }
471
+ }
472
+ return -1;
473
+ }
474
+ function baseGet(object, path) {
475
+ path = isKey(path, object) ? [path] : castPath(path);
476
+ var index = 0, length = path.length;
477
+ while (object != null && index < length) {
478
+ object = object[toKey(path[index++])];
479
+ }
480
+ return index && index == length ? object : void 0;
481
+ }
482
+ function baseIsNative(value) {
483
+ if (!isObject(value) || isMasked(value)) {
484
+ return false;
485
+ }
486
+ var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
487
+ return pattern.test(toSource(value));
488
+ }
489
+ function baseToString(value) {
490
+ if (typeof value == "string") {
491
+ return value;
492
+ }
493
+ if (isSymbol(value)) {
494
+ return symbolToString ? symbolToString.call(value) : "";
495
+ }
496
+ var result = value + "";
497
+ return result == "0" && 1 / value == -Infinity ? "-0" : result;
498
+ }
499
+ function castPath(value) {
500
+ return isArray(value) ? value : stringToPath(value);
501
+ }
502
+ function getMapData(map, key) {
503
+ var data = map.__data__;
504
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
505
+ }
506
+ function getNative(object, key) {
507
+ var value = getValue(object, key);
508
+ return baseIsNative(value) ? value : void 0;
509
+ }
510
+ function isKey(value, object) {
511
+ if (isArray(value)) {
512
+ return false;
513
+ }
514
+ var type = typeof value;
515
+ if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
516
+ return true;
517
+ }
518
+ return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
519
+ }
520
+ function isKeyable(value) {
521
+ var type = typeof value;
522
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
523
+ }
524
+ function isMasked(func) {
525
+ return !!maskSrcKey && maskSrcKey in func;
526
+ }
527
+ var stringToPath = memoize(function(string) {
528
+ string = toString(string);
529
+ var result = [];
530
+ if (reLeadingDot.test(string)) {
531
+ result.push("");
532
+ }
533
+ string.replace(rePropName, function(match, number, quote, string2) {
534
+ result.push(quote ? string2.replace(reEscapeChar, "$1") : number || match);
293
535
  });
536
+ return result;
537
+ });
538
+ function toKey(value) {
539
+ if (typeof value == "string" || isSymbol(value)) {
540
+ return value;
541
+ }
542
+ var result = value + "";
543
+ return result == "0" && 1 / value == -Infinity ? "-0" : result;
544
+ }
545
+ function toSource(func) {
546
+ if (func != null) {
547
+ try {
548
+ return funcToString.call(func);
549
+ } catch (e) {
550
+ }
551
+ try {
552
+ return func + "";
553
+ } catch (e) {
554
+ }
555
+ }
556
+ return "";
557
+ }
558
+ function memoize(func, resolver) {
559
+ if (typeof func != "function" || resolver && typeof resolver != "function") {
560
+ throw new TypeError(FUNC_ERROR_TEXT);
561
+ }
562
+ var memoized = function() {
563
+ var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
564
+ if (cache.has(key)) {
565
+ return cache.get(key);
566
+ }
567
+ var result = func.apply(this, args);
568
+ memoized.cache = cache.set(key, result);
569
+ return result;
570
+ };
571
+ memoized.cache = new (memoize.Cache || MapCache)();
572
+ return memoized;
573
+ }
574
+ memoize.Cache = MapCache;
575
+ function eq(value, other) {
576
+ return value === other || value !== value && other !== other;
577
+ }
578
+ var isArray = Array.isArray;
579
+ function isFunction(value) {
580
+ var tag = isObject(value) ? objectToString.call(value) : "";
581
+ return tag == funcTag || tag == genTag;
582
+ }
583
+ function isObject(value) {
584
+ var type = typeof value;
585
+ return !!value && (type == "object" || type == "function");
586
+ }
587
+ function isObjectLike(value) {
588
+ return !!value && typeof value == "object";
589
+ }
590
+ function isSymbol(value) {
591
+ return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
592
+ }
593
+ function toString(value) {
594
+ return value == null ? "" : baseToString(value);
595
+ }
596
+ function get2(object, path, defaultValue) {
597
+ var result = object == null ? void 0 : baseGet(object, path);
598
+ return result === void 0 ? defaultValue : result;
599
+ }
600
+ lodash_get = get2;
601
+ return lodash_get;
602
+ }
603
+ var lodash_getExports = requireLodash_get();
604
+ const get = /* @__PURE__ */ getDefaultExportFromCjs(lodash_getExports);
605
+ function useSortableData(tableData, externalSortConfig = { key: "", order: "none" }) {
606
+ const [sortConfig, setSortConfig] = useState(externalSortConfig);
607
+ const onSortRequested = (key) => {
608
+ const sortingNewColumn = key !== sortConfig.key;
609
+ if (sortingNewColumn || sortConfig.order === "none")
610
+ return setSortConfig({ key, order: "ascending" });
611
+ if (sortConfig.order === "ascending")
612
+ return setSortConfig({ key, order: "descending" });
613
+ if (sortConfig.order === "descending")
614
+ return setSortConfig({ key, order: "none" });
294
615
  };
295
- var tableSortedAscending = useMemo(function () {
296
- return [].concat(tableData).sort(function (a, b) {
297
- var _get$toString, _get, _get$toString2, _get2;
298
- var valueOfA = (_get$toString = (_get = get(a, sortConfig.key, a)) == null ? void 0 : _get.toString()) != null ? _get$toString : '';
299
- var valueOfB = (_get$toString2 = (_get2 = get(b, sortConfig.key, b)) == null ? void 0 : _get2.toString()) != null ? _get$toString2 : '';
300
- var stringComparator = new Intl.Collator(['no', 'en'], {
616
+ const tableSortedAscending = useMemo(
617
+ () => [...tableData].sort((a, b) => {
618
+ const valueOfA = get(a, sortConfig.key, a)?.toString() ?? "";
619
+ const valueOfB = get(b, sortConfig.key, b)?.toString() ?? "";
620
+ const stringComparator = new Intl.Collator(["no", "en"], {
301
621
  numeric: true,
302
- sensitivity: 'base'
622
+ sensitivity: "base"
303
623
  });
304
624
  return stringComparator.compare(valueOfA, valueOfB);
305
- });
306
- }, [tableData, sortConfig.key]);
307
- var sortedData = useMemo(function () {
625
+ }),
626
+ [tableData, sortConfig.key]
627
+ );
628
+ const sortedData = useMemo(() => {
308
629
  switch (sortConfig.order) {
309
- case 'ascending':
310
- {
311
- return tableSortedAscending;
312
- }
313
- case 'descending':
314
- {
315
- return [].concat(tableSortedAscending).reverse();
316
- }
317
- case 'none':
318
- {
319
- return tableData;
320
- }
321
- default:
322
- {
323
- return tableData;
324
- }
630
+ case "ascending": {
631
+ return tableSortedAscending;
632
+ }
633
+ case "descending": {
634
+ return [...tableSortedAscending].reverse();
635
+ }
636
+ case "none": {
637
+ return tableData;
638
+ }
639
+ default: {
640
+ return tableData;
641
+ }
325
642
  }
326
643
  }, [sortConfig.order, tableData, tableSortedAscending]);
327
- var getSortableHeaderProps = function getSortableHeaderProps(_ref) {
328
- var name = _ref.name,
329
- _ref$sortable = _ref.sortable,
330
- sortable = _ref$sortable === void 0 ? true : _ref$sortable,
331
- buttonProps = _ref.buttonProps,
332
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
333
- return _extends({
334
- name: name,
335
- sortable: sortable,
336
- sortConfig: sortConfig,
337
- sortableButtonProps: _extends({
338
- onClick: function onClick() {
339
- return onSortRequested(name);
340
- }
341
- }, buttonProps)
342
- }, props);
343
- };
344
- var getSortableTableProps = function getSortableTableProps(_temp) {
345
- var _ref2 = _temp === void 0 ? {} : _temp,
346
- _ref2$sortable = _ref2.sortable,
347
- sortable = _ref2$sortable === void 0 ? true : _ref2$sortable,
348
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
349
- return _extends({
350
- sortable: sortable,
351
- sortConfig: sortConfig
352
- }, props);
644
+ const getSortableHeaderProps = ({
645
+ name,
646
+ sortable = true,
647
+ buttonProps,
648
+ ...props
649
+ }) => {
650
+ return {
651
+ name,
652
+ sortable,
653
+ sortConfig,
654
+ sortableButtonProps: {
655
+ onClick: () => onSortRequested(name),
656
+ ...buttonProps
657
+ },
658
+ ...props
659
+ };
353
660
  };
354
- return {
355
- sortedData: sortedData,
356
- getSortableHeaderProps: getSortableHeaderProps,
357
- getSortableTableProps: getSortableTableProps
661
+ const getSortableTableProps = ({
662
+ sortable = true,
663
+ ...props
664
+ } = {}) => {
665
+ return {
666
+ sortable,
667
+ sortConfig,
668
+ ...props
669
+ };
358
670
  };
671
+ return { sortedData, getSortableHeaderProps, getSortableTableProps };
359
672
  }
360
-
361
- var _excluded$1 = ["children", "className", "feedback", "variant", "outlined"];
362
- var EditableCell = function EditableCell(_ref) {
363
- var children = _ref.children,
364
- className = _ref.className,
365
- feedback = _ref.feedback,
366
- variant = _ref.variant,
367
- _ref$outlined = _ref.outlined,
368
- outlined = _ref$outlined === void 0 ? false : _ref$outlined,
369
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
370
- return React.createElement(VariantProvider, {
371
- variant: variant
372
- }, React.createElement(DataCell, _extends({
373
- className: classNames('eds-editable-cell', {
374
- 'eds-editable-cell--outlined': outlined
375
- }, className)
376
- }, rest), React.createElement(Tooltip, {
377
- disableHoverListener: !feedback,
378
- disableFocusListener: !feedback,
379
- placement: "bottom",
380
- content: feedback || undefined,
381
- variant: feedback ? 'negative' : undefined
382
- }, children)));
673
+ const EditableCell = ({
674
+ children,
675
+ className,
676
+ feedback,
677
+ variant,
678
+ outlined = false,
679
+ ...rest
680
+ }) => {
681
+ return /* @__PURE__ */ jsx(VariantProvider, { variant, children: /* @__PURE__ */ jsx(
682
+ DataCell,
683
+ {
684
+ className: classNames(
685
+ "eds-editable-cell",
686
+ {
687
+ "eds-editable-cell--outlined": outlined
688
+ },
689
+ className
690
+ ),
691
+ ...rest,
692
+ children: /* @__PURE__ */ jsx(
693
+ Tooltip,
694
+ {
695
+ disableHoverListener: !feedback,
696
+ disableFocusListener: !feedback,
697
+ placement: "bottom",
698
+ content: feedback || void 0,
699
+ variant: feedback ? "negative" : void 0,
700
+ children
701
+ }
702
+ )
703
+ }
704
+ ) });
383
705
  };
384
-
385
- var ExpandableRow = function ExpandableRow(_ref) {
386
- var _ref$open = _ref.open,
387
- open = _ref$open === void 0 ? false : _ref$open,
388
- children = _ref.children,
389
- colSpan = _ref.colSpan;
390
- return React.createElement("tr", null, React.createElement("td", {
391
- colSpan: colSpan
392
- }, React.createElement(BaseExpand, {
393
- open: open
394
- }, children)));
706
+ const ExpandableRow = ({
707
+ open = false,
708
+ children,
709
+ colSpan
710
+ }) => {
711
+ return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, children: /* @__PURE__ */ jsx(BaseExpand, { open, children }) }) });
395
712
  };
396
-
397
- var _excluded = ["open", "onClick"];
398
- var ExpandRowButton = function ExpandRowButton(_ref) {
399
- var open = _ref.open,
400
- onClick = _ref.onClick,
401
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
402
- return React.createElement(IconButton, _extends({
403
- className: classNames('eds-expand-row-button', {
404
- 'eds-expand-row-button--open': open
405
- }),
406
- onClick: onClick,
407
- "aria-label": open ? 'Lukk tabellrad' : 'Utvid tabellrad',
408
- type: "button"
409
- }, rest), React.createElement(DownArrowIcon, {
410
- "aria-hidden": true,
411
- className: "eds-expand-row-button__icon"
412
- }));
713
+ const ExpandRowButton = ({
714
+ open,
715
+ onClick,
716
+ ...rest
717
+ }) => {
718
+ return /* @__PURE__ */ jsx(
719
+ IconButton,
720
+ {
721
+ className: classNames("eds-expand-row-button", {
722
+ "eds-expand-row-button--open": open
723
+ }),
724
+ onClick,
725
+ "aria-label": open ? "Lukk tabellrad" : "Utvid tabellrad",
726
+ type: "button",
727
+ ...rest,
728
+ children: /* @__PURE__ */ jsx(DownArrowIcon, { "aria-hidden": true, className: "eds-expand-row-button__icon" })
729
+ }
730
+ );
413
731
  };
414
-
415
732
  function onTableKeypress(event, currentRow, maxRow, allowWrap) {
416
- var keyPress = event.key;
733
+ const keyPress = event.key;
417
734
  switch (keyPress) {
418
- case 'ArrowUp':
735
+ case "ArrowUp":
419
736
  event.preventDefault();
420
737
  if (allowWrap) {
421
738
  return currentRow === 0 ? maxRow - 1 : currentRow - 1;
422
739
  } else {
423
740
  return currentRow > 0 ? currentRow - 1 : 0;
424
741
  }
425
- case 'ArrowDown':
742
+ case "ArrowDown":
426
743
  event.preventDefault();
427
744
  if (allowWrap) {
428
745
  return currentRow === maxRow - 1 ? 0 : currentRow + 1;
@@ -433,62 +750,52 @@ function onTableKeypress(event, currentRow, maxRow, allowWrap) {
433
750
  return currentRow;
434
751
  }
435
752
  }
436
- var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRows, allowWrap) {
437
- var _tableBodyRef$current;
438
- if (numberOfRows === void 0) {
439
- numberOfRows = 0;
440
- }
441
- if (allowWrap === void 0) {
442
- allowWrap = true;
443
- }
444
- var _useState = useState(numberOfRows),
445
- currentRow = _useState[0],
446
- setCurrentRow = _useState[1];
447
- var _useState2 = useState(0),
448
- maxRow = _useState2[0],
449
- setMaxRow = _useState2[1];
450
- var tableBodyRef = useRef(null);
451
- var tableHasFocus = tableBodyRef == null || (_tableBodyRef$current = tableBodyRef.current) == null ? void 0 : _tableBodyRef$current.contains(document.activeElement);
452
- useEffect(function () {
453
- var _tableBodyRef$current2;
454
- tableBodyRef && tableBodyRef.current && tableHasFocus && ((_tableBodyRef$current2 = tableBodyRef.current.childNodes[currentRow].childNodes[0].parentElement) == null ? void 0 : _tableBodyRef$current2.focus());
753
+ const useTableKeyboardNavigation = (numberOfRows = 0, allowWrap = true) => {
754
+ const [currentRow, setCurrentRow] = useState(numberOfRows);
755
+ const [maxRow, setMaxRow] = useState(0);
756
+ const tableBodyRef = useRef(null);
757
+ const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);
758
+ useEffect(() => {
759
+ tableBodyRef && tableBodyRef.current && tableHasFocus && tableBodyRef.current.childNodes[currentRow].childNodes[0].parentElement?.focus();
455
760
  }, [currentRow, tableHasFocus]);
456
- function getTableBodyNavigationProps() {
457
- for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
458
- rest[_key] = arguments[_key];
459
- }
460
- return _extends({
461
- ref: tableBodyRef
462
- }, rest);
761
+ function getTableBodyNavigationProps(...rest) {
762
+ return {
763
+ ref: tableBodyRef,
764
+ ...rest
765
+ };
463
766
  }
464
- var tableRowRef = useRef(null);
465
- function getTableRowNavigationProps(row) {
767
+ const tableRowRef = useRef(null);
768
+ function getTableRowNavigationProps(row, ...rest) {
466
769
  if (row >= maxRow) {
467
770
  setMaxRow(row + 1);
468
771
  }
469
- var tabIndex = currentRow ? 0 : -1;
470
- for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
471
- rest[_key2 - 1] = arguments[_key2];
472
- }
473
- return _extends({
474
- tabIndex: tabIndex,
772
+ const tabIndex = currentRow ? 0 : -1;
773
+ return {
774
+ tabIndex,
475
775
  ref: tableRowRef,
476
- onClick: function onClick() {
477
- return setCurrentRow(row);
478
- },
479
- onKeyDown: function onKeyDown(e) {
480
- var newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);
776
+ onClick: () => setCurrentRow(row),
777
+ onKeyDown: (e) => {
778
+ const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);
481
779
  setCurrentRow(newCell);
482
- }
483
- }, rest);
780
+ },
781
+ ...rest
782
+ };
484
783
  }
485
- return {
486
- getTableRowNavigationProps: getTableRowNavigationProps,
487
- getTableBodyNavigationProps: getTableBodyNavigationProps
488
- };
784
+ return { getTableRowNavigationProps, getTableBodyNavigationProps };
785
+ };
786
+ warnAboutMissingStyles("table");
787
+ export {
788
+ DataCell,
789
+ EditableCell,
790
+ ExpandRowButton,
791
+ ExpandableRow,
792
+ HeaderCell,
793
+ Table,
794
+ TableBody,
795
+ TableFooter,
796
+ TableHead,
797
+ TableRow,
798
+ useSortableData,
799
+ useTableKeyboardNavigation
489
800
  };
490
-
491
- warnAboutMissingStyles('table');
492
-
493
- export { DataCell, EditableCell, ExpandRowButton, ExpandableRow, HeaderCell, Table, TableBody, TableFooter, TableHead, TableRow, useSortableData, useTableKeyboardNavigation };
494
801
  //# sourceMappingURL=table.esm.js.map