@entur/table 4.5.40 → 4.5.41-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.
@@ -196,50 +196,51 @@ var SortableHeaderCellButton = function SortableHeaderCellButton(_ref2) {
196
196
 
197
197
  var _excluded$2 = ["name", "sortable", "buttonProps"],
198
198
  _excluded2 = ["sortable"];
199
- function useSortableData(rawData, externalSortConfig) {
199
+ function useSortableData(tableData, externalSortConfig) {
200
200
  if (externalSortConfig === void 0) {
201
201
  externalSortConfig = {
202
202
  key: '',
203
203
  order: 'none'
204
204
  };
205
205
  }
206
- var _React$useState = React__default["default"].useState(externalSortConfig),
207
- sortConfig = _React$useState[0],
208
- setSortConfig = _React$useState[1];
209
- var tableCopy = rawData.slice();
210
- React__default["default"].useEffect(function () {
211
- setSortConfig({
212
- key: externalSortConfig.key,
213
- order: externalSortConfig.order
206
+ var _useState = React.useState(externalSortConfig),
207
+ sortConfig = _useState[0],
208
+ setSortConfig = _useState[1];
209
+ var onSortRequested = function onSortRequested(key) {
210
+ var sortingNewColumn = key !== sortConfig.key;
211
+ if (sortingNewColumn || sortConfig.order === 'none') return setSortConfig({
212
+ key: key,
213
+ order: 'ascending'
214
214
  });
215
- }, [externalSortConfig.key, externalSortConfig.order]);
216
- var sortedData = React__default["default"].useMemo(function () {
217
- if (sortConfig.order === 'none') {
218
- return tableCopy;
219
- }
220
- return [].concat(rawData).sort(function (a, b) {
221
- if (get__default["default"](a, sortConfig.key) < get__default["default"](b, sortConfig.key)) {
222
- return sortConfig.order === 'ascending' ? -1 : 1;
223
- } else if (get__default["default"](a, sortConfig.key) > get__default["default"](b, sortConfig.key)) {
224
- return sortConfig.order === 'ascending' ? 1 : -1;
225
- } else {
226
- return 0;
227
- }
215
+ if (sortConfig.order === 'ascending') return setSortConfig({
216
+ key: key,
217
+ order: 'descending'
228
218
  });
229
- }, [rawData, tableCopy, sortConfig]);
230
- var onSortRequested = function onSortRequested(key) {
231
- var order = 'ascending';
232
- if (sortConfig.key === key && sortConfig.order === 'ascending') {
233
- order = 'descending';
234
- } else if (sortConfig.key === key && sortConfig.order === 'descending') {
235
- order = 'none';
236
- }
237
- setSortConfig({
219
+ if (sortConfig.order === 'descending') return setSortConfig({
238
220
  key: key,
239
- order: order
221
+ order: 'none'
240
222
  });
241
223
  };
242
- function getSortableHeaderProps(_ref) {
224
+ var tableSortedAscending = [].concat(tableData).sort(function (a, b) {
225
+ var valueOfA = get__default["default"](a, sortConfig.key, a);
226
+ var valueOfB = get__default["default"](b, sortConfig.key, b);
227
+ var comparableAValue = typeof valueOfA === 'string' ? valueOfA.toLowerCase() : valueOfA;
228
+ var comparableBValue = typeof valueOfB === 'string' ? valueOfB.toLowerCase() : valueOfB;
229
+ if (comparableAValue < comparableBValue) return -1;
230
+ if (comparableAValue > comparableBValue) return 1;
231
+ return 0;
232
+ });
233
+ var getSortedData = function getSortedData() {
234
+ if (sortConfig.order === 'none') {
235
+ return tableData;
236
+ }
237
+ if (sortConfig.order === 'descending') {
238
+ return [].concat(tableSortedAscending).reverse();
239
+ }
240
+ return tableSortedAscending;
241
+ };
242
+ var sortedData = getSortedData();
243
+ var getSortableHeaderProps = function getSortableHeaderProps(_ref) {
243
244
  var name = _ref.name,
244
245
  _ref$sortable = _ref.sortable,
245
246
  sortable = _ref$sortable === void 0 ? true : _ref$sortable,
@@ -255,8 +256,8 @@ function useSortableData(rawData, externalSortConfig) {
255
256
  }
256
257
  }, buttonProps)
257
258
  }, props);
258
- }
259
- function getSortableTableProps(_ref2) {
259
+ };
260
+ var getSortableTableProps = function getSortableTableProps(_ref2) {
260
261
  var _ref2$sortable = _ref2.sortable,
261
262
  sortable = _ref2$sortable === void 0 ? true : _ref2$sortable,
262
263
  props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
@@ -264,7 +265,7 @@ function useSortableData(rawData, externalSortConfig) {
264
265
  sortable: sortable,
265
266
  sortConfig: sortConfig
266
267
  }, props);
267
- }
268
+ };
268
269
  return {
269
270
  sortedData: sortedData,
270
271
  getSortableHeaderProps: getSortableHeaderProps,
@@ -359,9 +360,9 @@ var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRow
359
360
  var _useState2 = React.useState(0),
360
361
  maxRow = _useState2[0],
361
362
  setMaxRow = _useState2[1];
362
- var tableBodyRef = React__default["default"].useRef(null);
363
+ var tableBodyRef = React.useRef(null);
363
364
  var tableHasFocus = tableBodyRef == null ? void 0 : (_tableBodyRef$current = tableBodyRef.current) == null ? void 0 : _tableBodyRef$current.contains(document.activeElement);
364
- React__default["default"].useEffect(function () {
365
+ React.useEffect(function () {
365
366
  var _tableBodyRef$current2;
366
367
  tableBodyRef && tableBodyRef.current && tableHasFocus && ((_tableBodyRef$current2 = tableBodyRef.current.childNodes[currentRow].childNodes[0].parentElement) == null ? void 0 : _tableBodyRef$current2.focus());
367
368
  }, [currentRow, tableHasFocus]);
@@ -373,7 +374,7 @@ var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRow
373
374
  ref: tableBodyRef
374
375
  }, rest);
375
376
  }
376
- var tableRowRef = React__default["default"].useRef(null);
377
+ var tableRowRef = React.useRef(null);
377
378
  function getTableRowNavigationProps(row) {
378
379
  if (row >= maxRow) {
379
380
  setMaxRow(row + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"table.cjs.development.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","_excluded","classNames","TableHead","props","TableBody","TableFooter","createElement","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","IconButton","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","tableRowRef","getTableRowNavigationProps","row","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAMA,KAAK,gBAAGC,yBAAK,CAACC,UAAU,CACnC,UAQEC,IAAAA,EAAAA,GAAG,EACD;EAAA,IAPAC,SAAS,QAATA,SAAS;AAAA,IAAA,UAAA,GAAA,IAAA,CACTC,KAAK;AAALA,IAAAA,KAAK,2BAAG,KAAK,GAAA,UAAA;AAAA,IAAA,YAAA,GAAA,IAAA,CACbC,OAAO;AAAPA,IAAAA,OAAO,6BAAG,SAAS,GAAA,YAAA;AAAA,IAAA,aAAA,GAAA,IAAA,CACnBC,QAAQ;AAARA,IAAAA,QAAQ,8BAAG,KAAK,GAAA,aAAA;IACbC,IAAI,GAAA,6BAAA,CAAA,IAAA,EAAAC,WAAA,CAAA,CAAA;AAIT,EAAA,OACER;AACEG,IAAAA,SAAS,EAAEM,8BAAU,CACnB,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEL,KAAAA;AAAK,KAAE,EAC7B;MAAE,mBAAmB,EAAEC,OAAO,KAAK,QAAA;AAAQ,KAAE,EAC7C;MAAE,kBAAkB,EAAEA,OAAO,KAAK,OAAA;AAAO,KAAE,EAC3C;AAAE,MAAA,qBAAqB,EAAEC,QAAAA;KAAU,EACnCH,SAAS,CACV;AACDD,IAAAA,GAAG,EAAEA,GAAAA;AAAG,GAAA,EACJK,IAAI,CACR,CAAA,CAAA;AAEN,CAAC;;;AC9BI,IAAMG,SAAS,gBAAGV,yBAAK,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C,CAAC,CAAA;AACnB,KAAA;AACD,IAAA,IAAMC,QAAQ,GAAGvB,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAAC,IAAA,KAAA,IAAA,KAAA,GAAA,SAAA,CAAA,MAAA,EALlCtE,IAAS,GAAA,IAAA,KAAA,CAAA,KAAA,GAAA,CAAA,GAAA,KAAA,GAAA,CAAA,GAAA,CAAA,CAAA,EAAA,KAAA,GAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA;MAATA,IAAS,CAAA,KAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KAAA;AAMZ,IAAA,OAAA,QAAA,CAAA;AACE6F,MAAAA,QAAQ,EAARA,QAAQ;AACRlG,MAAAA,GAAG,EAAE+F,WAAW;AAChBxC,MAAAA,OAAO,EAAE,SAAA,OAAA,GAAA;QAAA,OAAM2B,aAAa,CAACe,GAAG,CAAC,CAAA;AAAA,OAAA;MACjCE,SAAS,EAAE,SAACC,SAAAA,CAAAA,CAAsB,EAAI;QACpC,IAAMC,OAAO,GAAG5B,eAAe,CAAC2B,CAAC,EAAEzB,UAAU,EAAEM,YAAY,EAAEJ,SAAS,CAAC,CAAA;QACvEK,aAAa,CAACmB,OAAO,CAAC,CAAA;AACxB,OAAA;AAAC,KAAA,EACEhG,IAAI,CAAA,CAAA;AAEX,GAAA;EACA,OAAO;AAAE2F,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAAEF,IAAAA,2BAA2B,EAA3BA,2BAAAA;GAA6B,CAAA;AACpE;;ACzFAQ,4BAAsB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"table.cjs.development.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.ts","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import { useState, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n tableData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = useState(externalSortConfig);\n\n const onSortRequested = (key: string) => {\n const sortingNewColumn = key !== sortConfig.key;\n if (sortingNewColumn || sortConfig.order === 'none')\n return setSortConfig({ key, order: 'ascending' });\n if (sortConfig.order === 'ascending')\n return setSortConfig({ key, order: 'descending' });\n if (sortConfig.order === 'descending')\n return setSortConfig({ key, order: 'none' });\n };\n\n const tableSortedAscending = [...tableData].sort((a: any, b: any) => {\n const valueOfA = get(a, sortConfig.key, a);\n const valueOfB = get(b, sortConfig.key, b);\n\n const comparableAValue =\n typeof valueOfA === 'string' ? valueOfA.toLowerCase() : valueOfA;\n const comparableBValue =\n typeof valueOfB === 'string' ? valueOfB.toLowerCase() : valueOfB;\n\n if (comparableAValue < comparableBValue) return -1;\n if (comparableAValue > comparableBValue) return 1;\n return 0;\n });\n\n const getSortedData: () => T[] = () => {\n if (sortConfig.order === 'none') {\n return tableData;\n }\n if (sortConfig.order === 'descending') {\n return [...tableSortedAscending].reverse();\n }\n return tableSortedAscending;\n };\n\n const sortedData = getSortedData();\n\n const getSortableHeaderProps = ({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps => {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n };\n\n const getSortableTableProps = ({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps => {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n };\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import { useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","_excluded","classNames","TableHead","props","TableBody","TableFooter","createElement","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","useSortableData","tableData","externalSortConfig","setSortConfig","onSortRequested","sortingNewColumn","tableSortedAscending","sort","a","b","valueOfA","get","valueOfB","comparableAValue","toLowerCase","comparableBValue","getSortedData","reverse","sortedData","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","IconButton","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","tableRowRef","getTableRowNavigationProps","row","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAMA,KAAK,gBAAGC,yBAAK,CAACC,UAAU,CACnC,UAQEC,IAAAA,EAAAA,GAAG,EACD;EAAA,IAPAC,SAAS,QAATA,SAAS;AAAA,IAAA,UAAA,GAAA,IAAA,CACTC,KAAK;AAALA,IAAAA,KAAK,2BAAG,KAAK,GAAA,UAAA;AAAA,IAAA,YAAA,GAAA,IAAA,CACbC,OAAO;AAAPA,IAAAA,OAAO,6BAAG,SAAS,GAAA,YAAA;AAAA,IAAA,aAAA,GAAA,IAAA,CACnBC,QAAQ;AAARA,IAAAA,QAAQ,8BAAG,KAAK,GAAA,aAAA;IACbC,IAAI,GAAA,6BAAA,CAAA,IAAA,EAAAC,WAAA,CAAA,CAAA;AAIT,EAAA,OACER;AACEG,IAAAA,SAAS,E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QACvEK,aAAa,CAACmB,OAAO,CAAC,CAAA;AACxB,OAAA;AAAC,KAAA,EACEtG,IAAI,CAAA,CAAA;AAEX,GAAA;EACA,OAAO;AAAEiG,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAAEF,IAAAA,2BAA2B,EAA3BA,2BAAAA;GAA6B,CAAA;AACpE;;ACzFAQ,4BAAsB,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),a=require("classnames"),r=require("@entur/icons"),n=require("lodash.get"),l=require("@entur/form"),o=require("@entur/tooltip"),d=require("@entur/expand"),s=require("@entur/button");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t),i=u(a),f=u(n);function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},b.apply(this,arguments)}function v(e,t){if(null==e)return{};var a,r,n={},l=Object.keys(e);for(r=0;r<l.length;r++)t.indexOf(a=l[r])>=0||(n[a]=e[a]);return n}var m=["className","fixed","spacing","sortable"],p=c.default.forwardRef((function(e,t){var a=e.className,r=e.fixed,n=void 0!==r&&r,l=e.spacing,o=void 0===l?"default":l,d=e.sortable,s=void 0!==d&&d,u=v(e,m);return c.default.createElement("table",b({className:i.default("eds-table",{"eds-table--fixed":n},{"eds-table--middle":"middle"===o},{"eds-table--small":"small"===o},{"eds-table--sortable":s},a),ref:t},u))})),_=["className"],g=c.default.forwardRef((function(e,t){var a=e.className,r=v(e,_);return c.default.createElement("thead",b({className:i.default("eds-table__head",a),ref:t},r))})),w=["className"],h=c.default.forwardRef((function(e,t){var a=e.className,r=v(e,w);return c.default.createElement("tbody",b({className:i.default("eds-table__body",a),ref:t},r))})),N=c.default.forwardRef((function(e,t){var a=b({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(e),e));return c.default.createElement("tfoot",b({ref:t},a))})),y=["className","hover","active","error"],x=c.default.forwardRef((function(e,t){var a=e.className,r=e.hover,n=void 0!==r&&r,l=e.active,o=void 0!==l&&l,d=e.error,s=void 0!==d&&d,u=v(e,y);return c.default.createElement("tr",b({className:i.default("eds-table__row",a,{"eds-table__row--hover":n,"eds-table__row--active":o,"eds-table__row--error":s}),ref:t},u))})),k=["className","padding","status"],E=c.default.forwardRef((function(e,t){var a,r=e.className,n=e.padding,l=void 0===n?"default":n,o=e.status,d=void 0===o?void 0:o,s=v(e,k);return c.default.createElement("td",b({ref:t,className:i.default("eds-table__data-cell",r,(a={},a["eds-table__data-cell--status-"+d]=d,a["eds-table__data-cell--padding-checkbox"]="checkbox"===l,a["eds-table__data-cell--padding-radio"]="radio"===l,a["eds-table__data-cell--padding-overflow-menu"]="overflow-menu"===l,a))},s))})),C=["className","children","name","sortable","sortConfig","padding","sortableButtonProps"],P=["className"],R=c.default.forwardRef((function(e,t){var a=e.className,r=e.children,n=e.name,l=e.sortable,o=void 0!==l&&l,d=e.sortConfig,s=e.padding,u=void 0===s?"default":s,f=e.sortableButtonProps,m=v(e,C),p=c.default.useState(!1),_=p[0],g=p[1];c.default.useEffect((function(){d&&n&&g(d&&n===d.key)}),[d,n]);var w=_?d&&d.order:"none";return c.default.createElement("th",b({className:i.default("eds-table__header-cell",a,{"eds-table__header-cell--sortable":o,"eds-table__header-cell--padding-radio":"radio"===u,"eds-table__header-cell--padding-checkbox":"checkbox"===u,"eds-table__header-cell--padding-overflow-menu":"overflow-menu"===u}),"aria-sort":w,ref:t},m),o&&d&&f?c.default.createElement(S,{sortableButtonProps:f,sortConfig:d,isCurrentlySorted:_},r):r)})),S=function(e){var t=e.sortConfig,a=e.sortableButtonProps,n=e.isCurrentlySorted,l=e.children,o=a.className,d=v(a,P);return c.default.createElement("button",b({className:i.default("eds-table__header-cell-button",o),type:"button"},d),l,(!n||"none"===t.order)&&c.default.createElement(r.UnsortedIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"usortert kolonne"}),n&&"ascending"===t.order&&c.default.createElement(r.UpArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"stigende sortert kolonne"}),n&&"descending"===t.order&&c.default.createElement(r.DownArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"synkende sortert kolonne"}))},T=["name","sortable","buttonProps"],B=["sortable"],q=["children","className","feedback","variant","outlined"],D=["open","onClick"];function A(e,t,a,r){switch(e.key){case"ArrowUp":return e.preventDefault(),r?0===t?a-1:t-1:t>0?t-1:0;case"ArrowDown":return e.preventDefault(),r?t===a-1?0:t+1:t<a-1?t+1:t;default:return t}}e.warnAboutMissingStyles("table"),exports.DataCell=E,exports.EditableCell=function(e){var t=e.children,a=e.className,r=e.feedback,n=e.variant,d=e.outlined,s=void 0!==d&&d,u=v(e,q);return c.default.createElement(l.VariantProvider,{variant:n},c.default.createElement(E,b({className:i.default("eds-editable-cell",{"eds-editable-cell--outlined":s},a)},u),c.default.createElement(o.Tooltip,{disableHoverListener:!r,disableFocusListener:!r,placement:"bottom",content:r||void 0,variant:r?"error":void 0},t)))},exports.ExpandRowButton=function(e){var t=e.open,a=e.onClick,n=v(e,D);return c.default.createElement(s.IconButton,b({className:i.default("eds-expand-row-button",{"eds-expand-row-button--open":t}),onClick:a,"aria-label":t?"Lukk tabellrad":"Utvid tabellrad"},n),c.default.createElement(r.DownArrowIcon,{className:"eds-expand-row-button__icon"}))},exports.ExpandableRow=function(e){var t=e.open;return c.default.createElement("tr",null,c.default.createElement("td",{colSpan:e.colSpan},c.default.createElement(d.BaseExpand,{open:void 0!==t&&t},e.children)))},exports.HeaderCell=R,exports.Table=p,exports.TableBody=h,exports.TableFooter=N,exports.TableHead=g,exports.TableRow=x,exports.useSortableData=function(e,t){void 0===t&&(t={key:"",order:"none"});var a=c.default.useState(t),r=a[0],n=a[1],l=e.slice();return c.default.useEffect((function(){n({key:t.key,order:t.order})}),[t.key,t.order]),{sortedData:c.default.useMemo((function(){return"none"===r.order?l:[].concat(e).sort((function(e,t){return f.default(e,r.key)<f.default(t,r.key)?"ascending"===r.order?-1:1:f.default(e,r.key)>f.default(t,r.key)?"ascending"===r.order?1:-1:0}))}),[e,l,r]),getSortableHeaderProps:function(e){var t=e.name,a=e.sortable,l=void 0===a||a,o=e.buttonProps,d=v(e,T);return b({name:t,sortable:l,sortConfig:r,sortableButtonProps:b({onClick:function(){return a="ascending",r.key===(e=t)&&"ascending"===r.order?a="descending":r.key===e&&"descending"===r.order&&(a="none"),void n({key:e,order:a});var e,a}},o)},d)},getSortableTableProps:function(e){var t=e.sortable,a=void 0===t||t,n=v(e,B);return b({sortable:a,sortConfig:r},n)}}},exports.useTableKeyboardNavigation=function(e,a){var r;void 0===e&&(e=0),void 0===a&&(a=!0);var n=t.useState(e),l=n[0],o=n[1],d=t.useState(0),s=d[0],u=d[1],i=c.default.useRef(null),f=null==i||null==(r=i.current)?void 0:r.contains(document.activeElement);c.default.useEffect((function(){var e;i&&i.current&&f&&(null==(e=i.current.childNodes[l].childNodes[0].parentElement)||e.focus())}),[l,f]);var v=c.default.useRef(null);return{getTableRowNavigationProps:function(t){t>=s&&u(t+1);for(var r=l?0:-1,n=arguments.length,d=new Array(n>1?n-1:0),c=1;c<n;c++)d[c-1]=arguments[c];return b({tabIndex:r,ref:v,onClick:function(){return o(t)},onKeyDown:function(t){var r=A(t,l,e,a);o(r)}},d)},getTableBodyNavigationProps:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return b({ref:i},t)}}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),t=require("react"),a=require("classnames"),r=require("@entur/icons"),n=require("lodash.get"),o=require("@entur/form"),l=require("@entur/tooltip"),d=require("@entur/expand"),s=require("@entur/button");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(t),i=u(a),f=u(n);function b(){return b=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},b.apply(this,arguments)}function v(e,t){if(null==e)return{};var a,r,n={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(a=o[r])>=0||(n[a]=e[a]);return n}var p=["className","fixed","spacing","sortable"],m=c.default.forwardRef((function(e,t){var a=e.className,r=e.fixed,n=void 0!==r&&r,o=e.spacing,l=void 0===o?"default":o,d=e.sortable,s=void 0!==d&&d,u=v(e,p);return c.default.createElement("table",b({className:i.default("eds-table",{"eds-table--fixed":n},{"eds-table--middle":"middle"===l},{"eds-table--small":"small"===l},{"eds-table--sortable":s},a),ref:t},u))})),_=["className"],g=c.default.forwardRef((function(e,t){var a=e.className,r=v(e,_);return c.default.createElement("thead",b({className:i.default("eds-table__head",a),ref:t},r))})),w=["className"],h=c.default.forwardRef((function(e,t){var a=e.className,r=v(e,w);return c.default.createElement("tbody",b({className:i.default("eds-table__body",a),ref:t},r))})),N=c.default.forwardRef((function(e,t){var a=b({},(function(e){if(null==e)throw new TypeError("Cannot destructure "+e)}(e),e));return c.default.createElement("tfoot",b({ref:t},a))})),x=["className","hover","active","error"],y=c.default.forwardRef((function(e,t){var a=e.className,r=e.hover,n=void 0!==r&&r,o=e.active,l=void 0!==o&&o,d=e.error,s=void 0!==d&&d,u=v(e,x);return c.default.createElement("tr",b({className:i.default("eds-table__row",a,{"eds-table__row--hover":n,"eds-table__row--active":l,"eds-table__row--error":s}),ref:t},u))})),E=["className","padding","status"],k=c.default.forwardRef((function(e,t){var a,r=e.className,n=e.padding,o=void 0===n?"default":n,l=e.status,d=void 0===l?void 0:l,s=v(e,E);return c.default.createElement("td",b({ref:t,className:i.default("eds-table__data-cell",r,(a={},a["eds-table__data-cell--status-"+d]=d,a["eds-table__data-cell--padding-checkbox"]="checkbox"===o,a["eds-table__data-cell--padding-radio"]="radio"===o,a["eds-table__data-cell--padding-overflow-menu"]="overflow-menu"===o,a))},s))})),C=["className","children","name","sortable","sortConfig","padding","sortableButtonProps"],P=["className"],R=c.default.forwardRef((function(e,t){var a=e.className,r=e.children,n=e.name,o=e.sortable,l=void 0!==o&&o,d=e.sortConfig,s=e.padding,u=void 0===s?"default":s,f=e.sortableButtonProps,p=v(e,C),m=c.default.useState(!1),_=m[0],g=m[1];c.default.useEffect((function(){d&&n&&g(d&&n===d.key)}),[d,n]);var w=_?d&&d.order:"none";return c.default.createElement("th",b({className:i.default("eds-table__header-cell",a,{"eds-table__header-cell--sortable":l,"eds-table__header-cell--padding-radio":"radio"===u,"eds-table__header-cell--padding-checkbox":"checkbox"===u,"eds-table__header-cell--padding-overflow-menu":"overflow-menu"===u}),"aria-sort":w,ref:t},p),l&&d&&f?c.default.createElement(S,{sortableButtonProps:f,sortConfig:d,isCurrentlySorted:_},r):r)})),S=function(e){var t=e.sortConfig,a=e.sortableButtonProps,n=e.isCurrentlySorted,o=e.children,l=a.className,d=v(a,P);return c.default.createElement("button",b({className:i.default("eds-table__header-cell-button",l),type:"button"},d),o,(!n||"none"===t.order)&&c.default.createElement(r.UnsortedIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"usortert kolonne"}),n&&"ascending"===t.order&&c.default.createElement(r.UpArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"stigende sortert kolonne"}),n&&"descending"===t.order&&c.default.createElement(r.DownArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon","aria-label":"synkende sortert kolonne"}))},T=["name","sortable","buttonProps"],B=["sortable"],q=["children","className","feedback","variant","outlined"],D=["open","onClick"];function A(e,t,a,r){switch(e.key){case"ArrowUp":return e.preventDefault(),r?0===t?a-1:t-1:t>0?t-1:0;case"ArrowDown":return e.preventDefault(),r?t===a-1?0:t+1:t<a-1?t+1:t;default:return t}}e.warnAboutMissingStyles("table"),exports.DataCell=k,exports.EditableCell=function(e){var t=e.children,a=e.className,r=e.feedback,n=e.variant,d=e.outlined,s=void 0!==d&&d,u=v(e,q);return c.default.createElement(o.VariantProvider,{variant:n},c.default.createElement(k,b({className:i.default("eds-editable-cell",{"eds-editable-cell--outlined":s},a)},u),c.default.createElement(l.Tooltip,{disableHoverListener:!r,disableFocusListener:!r,placement:"bottom",content:r||void 0,variant:r?"error":void 0},t)))},exports.ExpandRowButton=function(e){var t=e.open,a=e.onClick,n=v(e,D);return c.default.createElement(s.IconButton,b({className:i.default("eds-expand-row-button",{"eds-expand-row-button--open":t}),onClick:a,"aria-label":t?"Lukk tabellrad":"Utvid tabellrad"},n),c.default.createElement(r.DownArrowIcon,{className:"eds-expand-row-button__icon"}))},exports.ExpandableRow=function(e){var t=e.open;return c.default.createElement("tr",null,c.default.createElement("td",{colSpan:e.colSpan},c.default.createElement(d.BaseExpand,{open:void 0!==t&&t},e.children)))},exports.HeaderCell=R,exports.Table=m,exports.TableBody=h,exports.TableFooter=N,exports.TableHead=g,exports.TableRow=y,exports.useSortableData=function(e,a){void 0===a&&(a={key:"",order:"none"});var r=t.useState(a),n=r[0],o=r[1],l=[].concat(e).sort((function(e,t){var a=f.default(e,n.key,e),r=f.default(t,n.key,t),o="string"==typeof a?a.toLowerCase():a,l="string"==typeof r?r.toLowerCase():r;return o<l?-1:o>l?1:0}));return{sortedData:"none"===n.order?e:"descending"===n.order?[].concat(l).reverse():l,getSortableHeaderProps:function(e){var t=e.name,a=e.sortable,r=void 0===a||a,l=e.buttonProps,d=v(e,T);return b({name:t,sortable:r,sortConfig:n,sortableButtonProps:b({onClick:function(){return(e=t)!==n.key||"none"===n.order?o({key:e,order:"ascending"}):"ascending"===n.order?o({key:e,order:"descending"}):"descending"===n.order?o({key:e,order:"none"}):void 0;var e}},l)},d)},getSortableTableProps:function(e){var t=e.sortable,a=void 0===t||t,r=v(e,B);return b({sortable:a,sortConfig:n},r)}}},exports.useTableKeyboardNavigation=function(e,a){var r;void 0===e&&(e=0),void 0===a&&(a=!0);var n=t.useState(e),o=n[0],l=n[1],d=t.useState(0),s=d[0],u=d[1],c=t.useRef(null),i=null==c||null==(r=c.current)?void 0:r.contains(document.activeElement);t.useEffect((function(){var e;c&&c.current&&i&&(null==(e=c.current.childNodes[o].childNodes[0].parentElement)||e.focus())}),[o,i]);var f=t.useRef(null);return{getTableRowNavigationProps:function(t){t>=s&&u(t+1);for(var r=o?0:-1,n=arguments.length,d=new Array(n>1?n-1:0),c=1;c<n;c++)d[c-1]=arguments[c];return b({tabIndex:r,ref:f,onClick:function(){return l(t)},onKeyDown:function(t){var r=A(t,o,e,a);l(r)}},d)},getTableBodyNavigationProps:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return b({ref:c},t)}}};
2
2
  //# sourceMappingURL=table.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"table.cjs.production.min.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx","../src/EditableCell.tsx","../src/ExpandRowButton.tsx","../src/ExpandableRow.tsx","../src/useSortableTable.ts"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n"],"names":["Table","React","forwardRef","ref","className","_ref$fixed","_ref","fixed","_ref$spacing","spacing","_ref$sortable","sortable","rest","_objectWithoutPropertiesLoose","_excluded","classNames","TableHead","props","TableBody","TableFooter","_extends","_objectDestructuringEmpty","createElement","TableRow","_ref$hover","hover","_ref$active","active","_ref$error","error","DataCell","_classNames","_ref$padding","padding","_ref$status","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","_React$useState","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_ref2","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","preventDefault","warnAboutMissingStyles","feedback","variant","_ref$outlined","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","open","onClick","IconButton","_ref$open","colSpan","BaseExpand","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","concat","sort","a","b","get","getSortableHeaderProps","buttonProps","getSortableTableProps","_ref2$sortable","numberOfRows","_tableBodyRef$current","_useState","setCurrentRow","_useState2","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","_tableBodyRef$current2","childNodes","parentElement","focus","tableRowRef","getTableRowNavigationProps","row","tabIndex","_len2","arguments","length","Array","_key2","onKeyDown","e","newCell","getTableBodyNavigationProps","_len","_key"],"mappings":"oyBAkBaA,EAAQC,EAAAA,QAAMC,YACzB,SAQEC,EAAAA,GACE,IAPAC,IAAAA,UAASC,EAAAC,EACTC,MAAAA,cAAaF,EAAAG,EAAAF,EACbG,QAAAA,aAAU,UAASD,EAAAE,EAAAJ,EACnBK,SAAAA,cAAgBD,EACbE,EAAIC,EAAAP,EAAAQ,GAIT,OACEb,mCACEG,UAAWW,EAAU,QACnB,YACA,CAAE,mBAAoBR,GACtB,CAAE,oBAAiC,WAAZE,GACvB,CAAE,mBAAgC,UAAZA,GACtB,CAAE,sBAAuBE,GACzBP,GAEFD,IAAKA,GACDS,uBC3BCI,EAAYf,EAAAA,QAAMC,YAG7B,WAA0BC,GAAG,IAA1BC,IAAAA,UAAca,EAAKJ,EAAAP,EAAAQ,GAAA,OACtBb,mCACEG,UAAWW,EAAAA,QAAW,kBAAmBX,GACzCD,IAAKA,GACDc,uBCNKC,EAAYjB,EAAAA,QAAMC,YAG7B,WAAyBC,GAAG,IAAzBC,IAAAA,UAAcQ,EAAIC,EAAAP,EAAAQ,GAAA,OACrBb,mCACEG,UAAWW,EAAAA,QAAW,kBAAmBX,GACzCD,IAAKA,GACDS,OCXKO,EAAclB,EAAAA,QAAMC,YAG/B,WAAeC,GAAG,IAAZc,EAAKG,EAAA,wEAAAC,CAAAf,GAAAA,IAAA,OAAYL,UAAOqB,cAAA,QAAAF,EAAA,CAAAjB,IAAKA,GAASc,gDCajCM,EAAWtB,EAAAA,QAAMC,YAC5B,WAEEC,GAAmC,IADjCC,IAAAA,UAASoB,EAAAlB,EAAEmB,MAAAA,cAAaD,EAAAE,EAAApB,EAAEqB,OAAAA,cAAcD,EAAAE,EAAAtB,EAAEuB,MAAAA,cAAaD,EAAKhB,EAAIC,EAAAP,EAAAQ,GAAA,OAGlEb,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aG,SACbD,IAG6B,OAF7BF,EAAAA,EAAaG,QAAQK,WACnBnD,GACAmD,WAAW,GAAGC,gBAFhBF,EAE+BG,WAChC,CAACrD,EAAY6C,IAShB,IAAMS,EAAcjH,EAAAA,QAAMuG,OAA4B,MAoBtD,MAAO,CAAEW,2BAnBT,SACEC,GAGIA,GAAOvD,GACTyC,EAAUc,EAAM,GAEmB,IAArC,IAAMC,EAAWzD,EAAa,GAAK,EAAE0D,EAAAC,UAAAC,OALlC5G,EAAS,IAAA6G,MAAAH,EAAA,EAAAA,EAAA,EAAA,GAAAI,EAAA,EAAAA,EAAAJ,EAAAI,IAAT9G,EAAS8G,EAAA,GAAAH,UAAAG,GAMZ,OAAAtG,EAAA,CACEiG,SAAAA,EACAlH,IAAK+G,EACLtC,QAAS,WAAA,OAAMwB,EAAcgB,IAC7BO,UAAW,SAACC,GACV,IAAMC,EAAUnE,EAAgBkE,EAAGhE,EAAYqC,EAAcnC,GAC7DsC,EAAcyB,KAEbjH,IAG8BkH,4BA3BrC,WAAiD,IAAA,IAAAC,EAAAR,UAAAC,OAAT5G,EAAS,IAAA6G,MAAAM,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,IAATpH,EAASoH,GAAAT,UAAAS,GAC/C,OAAA5G,EAAA,CACEjB,IAAKoG,GACF3F"}
1
+ {"version":3,"file":"table.cjs.production.min.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useTableKeyboardNavigation.ts","../src/index.tsx","../src/EditableCell.tsx","../src/ExpandRowButton.tsx","../src/ExpandableRow.tsx","../src/useSortableTable.ts"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import { useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import { useState, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n tableData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = useState(externalSortConfig);\n\n const onSortRequested = (key: string) => {\n const sortingNewColumn = key !== sortConfig.key;\n if (sortingNewColumn || sortConfig.order === 'none')\n return setSortConfig({ key, order: 'ascending' });\n if (sortConfig.order === 'ascending')\n return setSortConfig({ key, order: 'descending' });\n if (sortConfig.order === 'descending')\n return setSortConfig({ key, order: 'none' });\n };\n\n const tableSortedAscending = [...tableData].sort((a: any, b: any) => {\n const valueOfA = get(a, sortConfig.key, a);\n const valueOfB = get(b, sortConfig.key, b);\n\n const comparableAValue =\n typeof valueOfA === 'string' ? valueOfA.toLowerCase() : valueOfA;\n const comparableBValue =\n typeof valueOfB === 'string' ? valueOfB.toLowerCase() : valueOfB;\n\n if (comparableAValue < comparableBValue) return -1;\n if (comparableAValue > comparableBValue) return 1;\n return 0;\n });\n\n const getSortedData: () => T[] = () => {\n if (sortConfig.order === 'none') {\n return tableData;\n }\n if (sortConfig.order === 'descending') {\n return [...tableSortedAscending].reverse();\n }\n return tableSortedAscending;\n };\n\n const sortedData = getSortedData();\n\n const getSortableHeaderProps = ({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps => {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n };\n\n const getSortableTableProps = ({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps => {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n };\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n"],"names":["Table","React","forwardRef","ref","className","_ref$fixed","_ref","fixed","_ref$spacing","spacing","_ref$sortable","sortable","rest","_objectWithoutPropertiesLoose","_excluded","classNames","TableHead","props","TableBody","TableFooter","_extends","_objectDestructuringEmpty","createElement","TableRow","_ref$hover","hover","_ref$active","active","_ref$error","error","DataCell","_classNames","_ref$padding","padding","_ref$status","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","_React$useState","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_ref2","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","preventDefault","warnAboutMissingStyles","feedback","variant","_ref$outlined","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","open","onClick","IconButton","_ref$open","colSpan","BaseExpand","tableData","externalSortConfig","_useState","setSortConfig","tableSortedAscending","concat","sort","a","b","valueOfA","get","valueOfB","comparableAValue","toLowerCase","comparableBValue","sortedData","reverse","getSortableHeaderProps","buttonProps","getSortableTableProps","_ref2$sortable","numberOfRows","_tableBodyRef$current","setCurrentRow","_useState2","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","_tableBodyRef$current2","childNodes","parentElement","focus","tableRowRef","getTableRowNavigationProps","row","tabIndex","_len2","arguments","length","Array","_key2","onKeyDown","e","newCell","getTableBodyNavigationProps","_len","_key"],"mappings":"oyBAkBaA,EAAQC,EAAAA,QAAMC,YACzB,SAQEC,EAAAA,GACE,IAPAC,IAAAA,UAASC,EAAAC,EACTC,MAAAA,cAAaF,EAAAG,EAAAF,EACbG,QAAAA,aAAU,UAASD,EAAAE,EAAAJ,EACnBK,SAAAA,cAAgBD,EACbE,EAAIC,EAAAP,EAAAQ,GAIT,OACEb,mCACEG,UAAWW,EAAU,QACnB,YACA,CAAE,mBAAoBR,GACtB,CAAE,oBAAiC,WAAZE,GACvB,CAAE,mBAAgC,UAAZA,GACtB,CAAE,sBAAuBE,GACzBP,GAEFD,IAAKA,GACDS,uBC3BCI,EAAYf,EAAAA,QAAMC,YAG7B,WAA0BC,GAAG,IAA1BC,IAAAA,UAAca,EAAKJ,EAAAP,EAAAQ,GAAA,OACtBb,mCACEG,UAAWW,EAAAA,QAAW,kBAAmBX,GACzCD,IAAKA,GACDc,uBCNKC,EAAYjB,EAAAA,QAAMC,YAG7B,WAAyBC,GAAG,IAAzBC,IAAAA,UAAcQ,EAAIC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} from 'react';
2
+ import React, { useState, useRef, useEffect } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { UnsortedIcon, UpArrowIcon, DownArrowIcon } from '@entur/icons';
5
5
  import get from 'lodash.get';
@@ -186,50 +186,51 @@ var SortableHeaderCellButton = function SortableHeaderCellButton(_ref2) {
186
186
 
187
187
  var _excluded$2 = ["name", "sortable", "buttonProps"],
188
188
  _excluded2 = ["sortable"];
189
- function useSortableData(rawData, externalSortConfig) {
189
+ function useSortableData(tableData, externalSortConfig) {
190
190
  if (externalSortConfig === void 0) {
191
191
  externalSortConfig = {
192
192
  key: '',
193
193
  order: 'none'
194
194
  };
195
195
  }
196
- var _React$useState = React.useState(externalSortConfig),
197
- sortConfig = _React$useState[0],
198
- setSortConfig = _React$useState[1];
199
- var tableCopy = rawData.slice();
200
- React.useEffect(function () {
201
- setSortConfig({
202
- key: externalSortConfig.key,
203
- order: externalSortConfig.order
196
+ var _useState = useState(externalSortConfig),
197
+ sortConfig = _useState[0],
198
+ setSortConfig = _useState[1];
199
+ var onSortRequested = function onSortRequested(key) {
200
+ var sortingNewColumn = key !== sortConfig.key;
201
+ if (sortingNewColumn || sortConfig.order === 'none') return setSortConfig({
202
+ key: key,
203
+ order: 'ascending'
204
204
  });
205
- }, [externalSortConfig.key, externalSortConfig.order]);
206
- var sortedData = React.useMemo(function () {
207
- if (sortConfig.order === 'none') {
208
- return tableCopy;
209
- }
210
- return [].concat(rawData).sort(function (a, b) {
211
- if (get(a, sortConfig.key) < get(b, sortConfig.key)) {
212
- return sortConfig.order === 'ascending' ? -1 : 1;
213
- } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {
214
- return sortConfig.order === 'ascending' ? 1 : -1;
215
- } else {
216
- return 0;
217
- }
205
+ if (sortConfig.order === 'ascending') return setSortConfig({
206
+ key: key,
207
+ order: 'descending'
218
208
  });
219
- }, [rawData, tableCopy, sortConfig]);
220
- var onSortRequested = function onSortRequested(key) {
221
- var order = 'ascending';
222
- if (sortConfig.key === key && sortConfig.order === 'ascending') {
223
- order = 'descending';
224
- } else if (sortConfig.key === key && sortConfig.order === 'descending') {
225
- order = 'none';
226
- }
227
- setSortConfig({
209
+ if (sortConfig.order === 'descending') return setSortConfig({
228
210
  key: key,
229
- order: order
211
+ order: 'none'
230
212
  });
231
213
  };
232
- function getSortableHeaderProps(_ref) {
214
+ var tableSortedAscending = [].concat(tableData).sort(function (a, b) {
215
+ var valueOfA = get(a, sortConfig.key, a);
216
+ var valueOfB = get(b, sortConfig.key, b);
217
+ var comparableAValue = typeof valueOfA === 'string' ? valueOfA.toLowerCase() : valueOfA;
218
+ var comparableBValue = typeof valueOfB === 'string' ? valueOfB.toLowerCase() : valueOfB;
219
+ if (comparableAValue < comparableBValue) return -1;
220
+ if (comparableAValue > comparableBValue) return 1;
221
+ return 0;
222
+ });
223
+ var getSortedData = function getSortedData() {
224
+ if (sortConfig.order === 'none') {
225
+ return tableData;
226
+ }
227
+ if (sortConfig.order === 'descending') {
228
+ return [].concat(tableSortedAscending).reverse();
229
+ }
230
+ return tableSortedAscending;
231
+ };
232
+ var sortedData = getSortedData();
233
+ var getSortableHeaderProps = function getSortableHeaderProps(_ref) {
233
234
  var name = _ref.name,
234
235
  _ref$sortable = _ref.sortable,
235
236
  sortable = _ref$sortable === void 0 ? true : _ref$sortable,
@@ -245,8 +246,8 @@ function useSortableData(rawData, externalSortConfig) {
245
246
  }
246
247
  }, buttonProps)
247
248
  }, props);
248
- }
249
- function getSortableTableProps(_ref2) {
249
+ };
250
+ var getSortableTableProps = function getSortableTableProps(_ref2) {
250
251
  var _ref2$sortable = _ref2.sortable,
251
252
  sortable = _ref2$sortable === void 0 ? true : _ref2$sortable,
252
253
  props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
@@ -254,7 +255,7 @@ function useSortableData(rawData, externalSortConfig) {
254
255
  sortable: sortable,
255
256
  sortConfig: sortConfig
256
257
  }, props);
257
- }
258
+ };
258
259
  return {
259
260
  sortedData: sortedData,
260
261
  getSortableHeaderProps: getSortableHeaderProps,
@@ -349,9 +350,9 @@ var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRow
349
350
  var _useState2 = useState(0),
350
351
  maxRow = _useState2[0],
351
352
  setMaxRow = _useState2[1];
352
- var tableBodyRef = React.useRef(null);
353
+ var tableBodyRef = useRef(null);
353
354
  var tableHasFocus = tableBodyRef == null ? void 0 : (_tableBodyRef$current = tableBodyRef.current) == null ? void 0 : _tableBodyRef$current.contains(document.activeElement);
354
- React.useEffect(function () {
355
+ useEffect(function () {
355
356
  var _tableBodyRef$current2;
356
357
  tableBodyRef && tableBodyRef.current && tableHasFocus && ((_tableBodyRef$current2 = tableBodyRef.current.childNodes[currentRow].childNodes[0].parentElement) == null ? void 0 : _tableBodyRef$current2.focus());
357
358
  }, [currentRow, tableHasFocus]);
@@ -363,7 +364,7 @@ var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRow
363
364
  ref: tableBodyRef
364
365
  }, rest);
365
366
  }
366
- var tableRowRef = React.useRef(null);
367
+ var tableRowRef = useRef(null);
367
368
  function getTableRowNavigationProps(row) {
368
369
  if (row >= maxRow) {
369
370
  setMaxRow(row + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"table.esm.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","_excluded","classNames","TableHead","props","TableBody","TableFooter","createElement","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","IconButton","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","tableRowRef","getTableRowNavigationProps","row","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAMA,KAAK,gBAAGC,KAAK,CAACC,UAAU,CACnC,UAQEC,IAAAA,EAAAA,GAAG,EACD;EAAA,IAPAC,SAAS,QAATA,SAAS;AAAA,IAAA,UAAA,GAAA,IAAA,CACTC,KAAK;AAALA,IAAAA,KAAK,2BAAG,KAAK,GAAA,UAAA;AAAA,IAAA,YAAA,GAAA,IAAA,CACbC,OAAO;AAAPA,IAAAA,OAAO,6BAAG,SAAS,GAAA,YAAA;AAAA,IAAA,aAAA,GAAA,IAAA,CACnBC,QAAQ;AAARA,IAAAA,QAAQ,8BAAG,KAAK,GAAA,aAAA;IACbC,IAAI,GAAA,6BAAA,CAAA,IAAA,EAAAC,WAAA,CAAA,CAAA;AAIT,EAAA,OACER;AACEG,IAAAA,SAAS,EAAEM,UAAU,CACnB,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEL,KAAAA;AAAK,KAAE,EAC7B;MAAE,mBAAmB,EAAEC,OAAO,KAAK,QAAA;AAAQ,KAAE,EAC7C;MAAE,kBAAkB,EAAEA,OAAO,KAAK,OAAA;AAAO,KAAE,EAC3C;AAAE,MAAA,qBAAqB,EAAEC,QAAAA;KAAU,EACnCH,SAAS,CACV;AACDD,IAAAA,GAAG,EAAEA,GAAAA;AAAG,GAAA,EACJK,IAAI,CACR,CAAA,CAAA;AAEN,CAAC;;;AC9BI,IAAMG,SAAS,gBAAGV,KAAK,CAACC,UAAU,CAGvC,gBAA0BC,GAAG,EAAA;EAAA,IAA1BC,SAAS,QAATA,SAAS;IAAKQ,K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AAA,CAAA,MAAA,EALlCtE,IAAS,GAAA,IAAA,KAAA,CAAA,KAAA,GAAA,CAAA,GAAA,KAAA,GAAA,CAAA,GAAA,CAAA,CAAA,EAAA,KAAA,GAAA,CAAA,EAAA,KAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA;MAATA,IAAS,CAAA,KAAA,GAAA,CAAA,CAAA,GAAA,SAAA,CAAA,KAAA,CAAA,CAAA;AAAA,KAAA;AAMZ,IAAA,OAAA,QAAA,CAAA;AACE6F,MAAAA,QAAQ,EAARA,QAAQ;AACRlG,MAAAA,GAAG,EAAE+F,WAAW;AAChBxC,MAAAA,OAAO,EAAE,SAAA,OAAA,GAAA;QAAA,OAAM2B,aAAa,CAACe,GAAG,CAAC,CAAA;AAAA,OAAA;MACjCE,SAAS,EAAE,SAACC,SAAAA,CAAAA,CAAsB,EAAI;QACpC,IAAMC,OAAO,GAAG5B,eAAe,CAAC2B,CAAC,EAAEzB,UAAU,EAAEM,YAAY,EAAEJ,SAAS,CAAC,CAAA;QACvEK,aAAa,CAACmB,OAAO,CAAC,CAAA;AACxB,OAAA;AAAC,KAAA,EACEhG,IAAI,CAAA,CAAA;AAEX,GAAA;EACA,OAAO;AAAE2F,IAAAA,0BAA0B,EAA1BA,0BAA0B;AAAEF,IAAAA,2BAA2B,EAA3BA,2BAAAA;GAA6B,CAAA;AACpE;;ACzFAQ,sBAAsB,CAAC,OAAO,CAAC;;;;"}
1
+ {"version":3,"file":"table.esm.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.ts","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"usortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"stigende sortert kolonne\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n aria-label=\"synkende sortert kolonne\"\n />\n )}\n </button>\n );\n};\n","import { useState, DetailedHTMLProps, ButtonHTMLAttributes } from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n tableData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = useState(externalSortConfig);\n\n const onSortRequested = (key: string) => {\n const sortingNewColumn = key !== sortConfig.key;\n if (sortingNewColumn || sortConfig.order === 'none')\n return setSortConfig({ key, order: 'ascending' });\n if (sortConfig.order === 'ascending')\n return setSortConfig({ key, order: 'descending' });\n if (sortConfig.order === 'descending')\n return setSortConfig({ key, order: 'none' });\n };\n\n const tableSortedAscending = [...tableData].sort((a: any, b: any) => {\n const valueOfA = get(a, sortConfig.key, a);\n const valueOfB = get(b, sortConfig.key, b);\n\n const comparableAValue =\n typeof valueOfA === 'string' ? valueOfA.toLowerCase() : valueOfA;\n const comparableBValue =\n typeof valueOfB === 'string' ? valueOfB.toLowerCase() : valueOfB;\n\n if (comparableAValue < comparableBValue) return -1;\n if (comparableAValue > comparableBValue) return 1;\n return 0;\n });\n\n const getSortedData: () => T[] = () => {\n if (sortConfig.order === 'none') {\n return tableData;\n }\n if (sortConfig.order === 'descending') {\n return [...tableSortedAscending].reverse();\n }\n return tableSortedAscending;\n };\n\n const sortedData = getSortedData();\n\n const getSortableHeaderProps = ({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps => {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n };\n\n const getSortableTableProps = ({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps => {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n };\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n DetailedHTMLProps<\n ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon } from '@entur/icons';\nimport { IconButton } from '@entur/button';\nimport './ExpandRowButton.scss';\n\nexport type ExpandRowButtonProps = {\n open: boolean;\n onClick: (e: React.MouseEvent) => void;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const ExpandRowButton: React.FC<ExpandRowButtonProps> = ({\n open,\n onClick,\n ...rest\n}) => {\n return (\n <IconButton\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n aria-label={open ? 'Lukk tabellrad' : 'Utvid tabellrad'}\n {...rest}\n >\n <DownArrowIcon className=\"eds-expand-row-button__icon\" />\n </IconButton>\n );\n};\n","import { useState, useEffect, useRef, KeyboardEvent } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow, tableHasFocus]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n const tableRowRef = useRef<HTMLTableRowElement>(null);\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n if (row >= maxRow) {\n setMaxRow(row + 1);\n }\n const tabIndex = currentRow ? 0 : -1;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","_excluded","classNames","TableHead","props","TableBody","TableFooter","createElement","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","_excluded2","type","UnsortedIcon","size","UpArrowIcon","DownArrowIcon","useSortableData","tableData","externalSortConfig","setSortConfig","onSortRequested","sortingNewColumn","tableSortedAscending","sort","a","b","valueOfA","get","valueOfB","comparableAValue","toLowerCase","comparableBValue","getSortedData","reverse","sortedData","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","IconButton","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","tableRowRef","getTableRowNavigationProps","row","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAMA,KAAK,gBAAGC,KAAK,CAACC,UAAU,CACnC,UAQEC,IAAAA,EAAAA,GAAG,EACD;EAAA,IAPAC,SAAS,QAATA,SAAS;AAAA,IAAA,UAAA,GAAA,IAAA,CACTC,KAAK;AAALA,IAAAA,KAAK,2BAAG,KAAK,GAAA,UAAA;AAAA,IAAA,YAAA,GAAA,IAAA,CACbC,OAAO;AAAPA,IAAAA,OAAO,6BAAG,SAAS,GAAA,YAAA;AAAA,IAAA,aAAA,GAAA,IAAA,CACnBC,QAAQ;AAARA,IAAAA,QAAQ,8BAAG,KAAK,GAAA,aAAA;IACbC,IAAI,GAAA,6BAAA,CAAA,IAAA,EAAAC,WAAA,CAAA,CAAA;AAIT,EAAA,OACER;AACEG,IAAAA,SAAS,EAAEM,UAAU,CACnB,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEL,KAAAA;AAAK,KAAE,EAC7B;MAAE,mBAAmB,EAAEC,OAAO,KAAK,QAAA;AAAQ,KAAE,EAC7C;MAAE,kBAAkB,EAAEA,OAAO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,sBAAsB,CAAC,OAAO,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { DetailedHTMLProps, ButtonHTMLAttributes } from 'react';
2
2
  export type ExternalSortConfig = {
3
3
  /**
4
4
  * @default ""
@@ -7,7 +7,7 @@ export type ExternalSortConfig = {
7
7
  /** @default "none" */
8
8
  order: 'ascending' | 'descending' | 'none';
9
9
  };
10
- export declare function useSortableData<T>(rawData: T[], externalSortConfig?: ExternalSortConfig): {
10
+ export declare function useSortableData<T>(tableData: T[], externalSortConfig?: ExternalSortConfig): {
11
11
  sortedData: T[];
12
12
  getSortableHeaderProps: (args: SortableHeaderProps) => SortableHeaderReturnProps;
13
13
  getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;
@@ -19,7 +19,7 @@ export type SortableHeaderProps = {
19
19
  * @default true */
20
20
  sortable?: boolean;
21
21
  /** Props som sendes til knapp-elementet */
22
- buttonProps?: Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, 'type' | 'onClick'>;
22
+ buttonProps?: Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, 'type' | 'onClick'>;
23
23
  [key: string]: any;
24
24
  };
25
25
  export type SortableHeaderReturnProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/table",
3
- "version": "4.5.40",
3
+ "version": "4.5.41-beta.0",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/table.esm.js",
@@ -38,5 +38,5 @@
38
38
  "classnames": "^2.3.1",
39
39
  "lodash.get": "^4.4.2"
40
40
  },
41
- "gitHead": "1e78a655ffc4c4ca80d8e54495768282dc374201"
41
+ "gitHead": "913bab069b386c0ca314df27348522b48ae5e42a"
42
42
  }