@entur/table 4.10.6 → 4.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/table.cjs.js +12 -11
- package/dist/table.cjs.js.map +1 -1
- package/dist/table.esm.js +12 -11
- package/dist/table.esm.js.map +1 -1
- package/dist/useSortableTable.d.ts +0 -1
- package/package.json +5 -5
package/dist/table.cjs.js
CHANGED
|
@@ -242,6 +242,9 @@ const SortableHeaderCellButton = ({
|
|
|
242
242
|
};
|
|
243
243
|
function useSortableData(tableData, externalSortConfig = { key: "", order: "none" }) {
|
|
244
244
|
const [sortConfig, setSortConfig] = React.useState(externalSortConfig);
|
|
245
|
+
React.useEffect(() => {
|
|
246
|
+
setSortConfig(externalSortConfig);
|
|
247
|
+
}, [externalSortConfig.key, externalSortConfig.order]);
|
|
245
248
|
const onSortRequested = (key) => {
|
|
246
249
|
const sortingNewColumn = key !== sortConfig.key;
|
|
247
250
|
if (sortingNewColumn || sortConfig.order === "none")
|
|
@@ -251,18 +254,17 @@ function useSortableData(tableData, externalSortConfig = { key: "", order: "none
|
|
|
251
254
|
if (sortConfig.order === "descending")
|
|
252
255
|
return setSortConfig({ key, order: "none" });
|
|
253
256
|
};
|
|
254
|
-
const tableSortedAscending = React.useMemo(
|
|
255
|
-
|
|
257
|
+
const tableSortedAscending = React.useMemo(() => {
|
|
258
|
+
const collator = new Intl.Collator(["no", "en"], {
|
|
259
|
+
numeric: true,
|
|
260
|
+
sensitivity: "base"
|
|
261
|
+
});
|
|
262
|
+
return [...tableData].sort((a, b) => {
|
|
256
263
|
const valueOfA = get(a, sortConfig.key, a)?.toString() ?? "";
|
|
257
264
|
const valueOfB = get(b, sortConfig.key, b)?.toString() ?? "";
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
262
|
-
return stringComparator.compare(valueOfA, valueOfB);
|
|
263
|
-
}),
|
|
264
|
-
[tableData, sortConfig.key]
|
|
265
|
-
);
|
|
265
|
+
return collator.compare(valueOfA, valueOfB);
|
|
266
|
+
});
|
|
267
|
+
}, [tableData, sortConfig.key]);
|
|
266
268
|
const sortedData = React.useMemo(() => {
|
|
267
269
|
switch (sortConfig.order) {
|
|
268
270
|
case "ascending": {
|
|
@@ -302,7 +304,6 @@ function useSortableData(tableData, externalSortConfig = { key: "", order: "none
|
|
|
302
304
|
} = {}) => {
|
|
303
305
|
return {
|
|
304
306
|
sortable,
|
|
305
|
-
sortConfig,
|
|
306
307
|
...props
|
|
307
308
|
};
|
|
308
309
|
};
|
package/dist/table.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.cjs.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, { useEffect, useRef } from 'react';\nimport classNames from 'classnames';\nimport { useRandomId, mergeRefs } from '@entur/utils';\nimport { VisuallyHidden } from '@entur/a11y';\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 /** Om header-raden skal bli værende på skjermen når man skroller tabellen\n * @default false\n */\n stickyHeader?: 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 changeSortDescription = 'Tabelloverskrifter med knapper kan trykkes på for å endre sortering,',\n stickyHeader = false,\n ...rest\n },\n ref,\n ) => {\n const sortableHeaderId = useRandomId('sortable-header');\n\n const tableRef = useRef<HTMLTableElement>(null);\n\n useEffect(() => {\n if (stickyHeader) {\n /* We check when an inserted div above the header \n is outside our scrolling container to determine when\n the table header becomes sticky. This is necessary\n to conditionally add our box-shadow when the \n header is overlapping table rows */\n const tableElement = tableRef.current;\n const observerElement = document.createElement('div');\n observerElement.classList.add('sticky-observer');\n\n tableElement?.parentNode?.insertBefore(observerElement, tableElement);\n\n const observer = new IntersectionObserver(\n entries => {\n tableElement?.classList.toggle(\n 'eds-table--sticky-header--active',\n !entries[0].isIntersecting,\n );\n },\n { threshold: [0, 1] },\n );\n\n observer.observe(observerElement);\n\n return () => {\n observer.unobserve(observerElement);\n observerElement.remove();\n };\n }\n }, [stickyHeader]);\n\n return (\n <>\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 { 'eds-table--sticky-header': stickyHeader },\n className,\n )}\n ref={mergeRefs(ref, tableRef)}\n aria-describedby={sortable ? sortableHeaderId : undefined}\n {...rest}\n />\n {sortable && (\n <VisuallyHidden id={sortableHeaderId}>\n {changeSortDescription}\n </VisuallyHidden>\n )}\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\nimport { BulletBadge } from '@entur/layout';\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst danger = 'danger';\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 /** @deprecated bruk variant */\n status?: 'positive' | 'negative' | 'neutral';\n /** Hvilken type status man vil vise */\n variant?: 'primary' | 'neutral' | VariantType | typeof danger | typeof info;\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nfunction mapStatusToVariant(\n status: 'positive' | 'negative' | 'neutral',\n): DataCellProps['variant'] {\n switch (status) {\n case 'positive':\n return 'success';\n case 'negative':\n return 'negative';\n case 'neutral':\n return 'neutral';\n default:\n return 'neutral';\n }\n}\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status, variant, children, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => {\n // If variant is undefined and status is defined, map status to variant\n if (!variant && status) {\n variant = mapStatusToVariant(status);\n }\n return (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\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 {variant ? (\n <BulletBadge variant={variant}>{children}</BulletBadge>\n ) : (\n children\n )}\n </td>\n );\n },\n);\n","import React, { useEffect, useState } from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\nimport { VisuallyHidden } from '@entur/a11y';\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 sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: 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 sortedAscendingAriaLabel = ', sortert stigende',\n sortedDescendingAriaLabel = ', sortert synkende',\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 : undefined;\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 ariaSort={ariaSort}\n sortedAscendingAriaLabel={sortedAscendingAriaLabel}\n sortedDescendingAriaLabel={sortedDescendingAriaLabel}\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 ariaSort?: 'none' | 'ascending' | 'descending' | 'other' | undefined;\n sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: string;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n ariaSort,\n sortedAscendingAriaLabel,\n sortedDescendingAriaLabel,\n}) => {\n const [sortedAriaInfo, setSortedAriaInfo] = useState<string | undefined>('');\n\n const { className, ...rest } = sortableButtonProps;\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n useEffect(() => {\n const DISMISS_SORT_INFO_TIME = 3000;\n if (sortConfig.order == 'ascending') {\n setSortedAriaInfo(sortedAscendingAriaLabel);\n } else if (sortConfig.order == 'descending') {\n setSortedAriaInfo(sortedDescendingAriaLabel);\n }\n const dismissAriaTimer = setTimeout(() => {\n setSortedAriaInfo('');\n if (isFirefox) setSortedAriaInfo(', sort ' + sortConfig.order);\n }, DISMISS_SORT_INFO_TIME);\n\n return () => clearTimeout(dismissAriaTimer);\n }, [sortConfig.order]);\n\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n aria-sort={ariaSort}\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n <VisuallyHidden>{isCurrentlySorted && sortedAriaInfo}</VisuallyHidden>\n </button>\n );\n};\n","import {\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n useMemo,\n useState,\n} 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: (\n args?: SortableTableProps,\n ) => 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 = useMemo(\n () =>\n [...tableData].sort((a: any, b: any) => {\n const valueOfA: string = get(a, sortConfig.key, a)?.toString() ?? '';\n const valueOfB: string = get(b, sortConfig.key, b)?.toString() ?? '';\n\n const stringComparator = new Intl.Collator(['no', 'en'], {\n numeric: true,\n sensitivity: 'base',\n });\n\n return stringComparator.compare(valueOfA, valueOfB);\n }),\n [tableData, sortConfig.key],\n );\n\n const sortedData = useMemo(() => {\n switch (sortConfig.order) {\n case 'ascending': {\n return tableSortedAscending;\n }\n case 'descending': {\n return [...tableSortedAscending].reverse();\n }\n case 'none': {\n return tableData;\n }\n default: {\n return tableData;\n }\n }\n }, [sortConfig.order, tableData, tableSortedAscending]);\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';\n\nimport { VariantProvider } from '@entur/form';\nimport { VariantType } from '@entur/utils';\nimport { Tooltip } from '@entur/tooltip';\n\nimport './EditableCell.scss';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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 | typeof error | typeof info;\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 ? 'negative' : 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 type=\"button\"\n {...rest}\n >\n <DownArrowIcon aria-hidden 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":["useRandomId","useRef","useEffect","jsxs","Fragment","jsx","mergeRefs","VisuallyHidden","BulletBadge","useState","UnsortedIcon","UpArrowIcon","DownArrowIcon","useMemo","VariantProvider","Tooltip","BaseExpand","IconButton","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;AAwBO,MAAM,QAAQ,MAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,mBAAmBA,MAAAA,YAAY,iBAAiB;AAEtD,UAAM,WAAWC,MAAAA,OAAyB,IAAI;AAE9CC,UAAAA,UAAU,MAAM;AACd,UAAI,cAAc;AAMhB,cAAM,eAAe,SAAS;AAC9B,cAAM,kBAAkB,SAAS,cAAc,KAAK;AACpD,wBAAgB,UAAU,IAAI,iBAAiB;AAE/C,sBAAc,YAAY,aAAa,iBAAiB,YAAY;AAEpE,cAAM,WAAW,IAAI;AAAA,UACnB,CAAA,YAAW;AACT,0BAAc,UAAU;AAAA,cACtB;AAAA,cACA,CAAC,QAAQ,CAAC,EAAE;AAAA,YAAA;AAAA,UAEhB;AAAA,UACA,EAAE,WAAW,CAAC,GAAG,CAAC,EAAA;AAAA,QAAE;AAGtB,iBAAS,QAAQ,eAAe;AAEhC,eA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Y,cAAc,SAAS;AACtE,sBAAc,OAAO;AAAA,MACvB;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EAEP;AACA,SAAO,EAAE,4BAA4B,4BAAA;AACvC;ACzFAiB,MAAAA,uBAAuB,OAAO;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"table.cjs.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, { useEffect, useRef } from 'react';\nimport classNames from 'classnames';\nimport { useRandomId, mergeRefs } from '@entur/utils';\nimport { VisuallyHidden } from '@entur/a11y';\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 /** Om header-raden skal bli værende på skjermen når man skroller tabellen\n * @default false\n */\n stickyHeader?: 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 changeSortDescription = 'Tabelloverskrifter med knapper kan trykkes på for å endre sortering,',\n stickyHeader = false,\n ...rest\n },\n ref,\n ) => {\n const sortableHeaderId = useRandomId('sortable-header');\n\n const tableRef = useRef<HTMLTableElement>(null);\n\n useEffect(() => {\n if (stickyHeader) {\n /* We check when an inserted div above the header \n is outside our scrolling container to determine when\n the table header becomes sticky. This is necessary\n to conditionally add our box-shadow when the \n header is overlapping table rows */\n const tableElement = tableRef.current;\n const observerElement = document.createElement('div');\n observerElement.classList.add('sticky-observer');\n\n tableElement?.parentNode?.insertBefore(observerElement, tableElement);\n\n const observer = new IntersectionObserver(\n entries => {\n tableElement?.classList.toggle(\n 'eds-table--sticky-header--active',\n !entries[0].isIntersecting,\n );\n },\n { threshold: [0, 1] },\n );\n\n observer.observe(observerElement);\n\n return () => {\n observer.unobserve(observerElement);\n observerElement.remove();\n };\n }\n }, [stickyHeader]);\n\n return (\n <>\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 { 'eds-table--sticky-header': stickyHeader },\n className,\n )}\n ref={mergeRefs(ref, tableRef)}\n aria-describedby={sortable ? sortableHeaderId : undefined}\n {...rest}\n />\n {sortable && (\n <VisuallyHidden id={sortableHeaderId}>\n {changeSortDescription}\n </VisuallyHidden>\n )}\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\nimport { BulletBadge } from '@entur/layout';\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst danger = 'danger';\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 /** @deprecated bruk variant */\n status?: 'positive' | 'negative' | 'neutral';\n /** Hvilken type status man vil vise */\n variant?: 'primary' | 'neutral' | VariantType | typeof danger | typeof info;\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nfunction mapStatusToVariant(\n status: 'positive' | 'negative' | 'neutral',\n): DataCellProps['variant'] {\n switch (status) {\n case 'positive':\n return 'success';\n case 'negative':\n return 'negative';\n case 'neutral':\n return 'neutral';\n default:\n return 'neutral';\n }\n}\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status, variant, children, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => {\n // If variant is undefined and status is defined, map status to variant\n if (!variant && status) {\n variant = mapStatusToVariant(status);\n }\n return (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\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 {variant ? (\n <BulletBadge variant={variant}>{children}</BulletBadge>\n ) : (\n children\n )}\n </td>\n );\n },\n);\n","import React, { useEffect, useState } from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\nimport { VisuallyHidden } from '@entur/a11y';\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 sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: 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 sortedAscendingAriaLabel = ', sortert stigende',\n sortedDescendingAriaLabel = ', sortert synkende',\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 : undefined;\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 ariaSort={ariaSort}\n sortedAscendingAriaLabel={sortedAscendingAriaLabel}\n sortedDescendingAriaLabel={sortedDescendingAriaLabel}\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 ariaSort?: 'none' | 'ascending' | 'descending' | 'other' | undefined;\n sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: string;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n ariaSort,\n sortedAscendingAriaLabel,\n sortedDescendingAriaLabel,\n}) => {\n const [sortedAriaInfo, setSortedAriaInfo] = useState<string | undefined>('');\n\n const { className, ...rest } = sortableButtonProps;\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n useEffect(() => {\n const DISMISS_SORT_INFO_TIME = 3000;\n if (sortConfig.order == 'ascending') {\n setSortedAriaInfo(sortedAscendingAriaLabel);\n } else if (sortConfig.order == 'descending') {\n setSortedAriaInfo(sortedDescendingAriaLabel);\n }\n const dismissAriaTimer = setTimeout(() => {\n setSortedAriaInfo('');\n if (isFirefox) setSortedAriaInfo(', sort ' + sortConfig.order);\n }, DISMISS_SORT_INFO_TIME);\n\n return () => clearTimeout(dismissAriaTimer);\n }, [sortConfig.order]);\n\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n aria-sort={ariaSort}\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n <VisuallyHidden>{isCurrentlySorted && sortedAriaInfo}</VisuallyHidden>\n </button>\n );\n};\n","import {\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n useEffect,\n useMemo,\n useState,\n} 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: (\n args?: SortableTableProps,\n ) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = useState(externalSortConfig);\n\n useEffect(() => {\n setSortConfig(externalSortConfig);\n }, [externalSortConfig.key, externalSortConfig.order]);\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 = useMemo(() => {\n const collator = new Intl.Collator(['no', 'en'], {\n numeric: true,\n sensitivity: 'base',\n });\n\n return [...tableData].sort((a: any, b: any) => {\n const valueOfA: string = get(a, sortConfig.key, a)?.toString() ?? '';\n const valueOfB: string = get(b, sortConfig.key, b)?.toString() ?? '';\n\n return collator.compare(valueOfA, valueOfB);\n });\n }, [tableData, sortConfig.key]);\n\n const sortedData = useMemo(() => {\n switch (sortConfig.order) {\n case 'ascending': {\n return tableSortedAscending;\n }\n case 'descending': {\n return [...tableSortedAscending].reverse();\n }\n case 'none': {\n return tableData;\n }\n default: {\n return tableData;\n }\n }\n }, [sortConfig.order, tableData, tableSortedAscending]);\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 ...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 [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\n\nimport { VariantProvider } from '@entur/form';\nimport { VariantType } from '@entur/utils';\nimport { Tooltip } from '@entur/tooltip';\n\nimport './EditableCell.scss';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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 | typeof error | typeof info;\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 ? 'negative' : 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 type=\"button\"\n {...rest}\n >\n <DownArrowIcon aria-hidden 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":["useRandomId","useRef","useEffect","jsxs","Fragment","jsx","mergeRefs","VisuallyHidden","BulletBadge","useState","UnsortedIcon","UpArrowIcon","DownArrowIcon","useMemo","VariantProvider","Tooltip","BaseExpand","IconButton","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;AAwBO,MAAM,QAAQ,MAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,mBAAmBA,MAAAA,YAAY,iBAAiB;AAEtD,UAAM,WAAWC,MAAAA,OAAyB,IAAI;AAE9CC,UAAAA,UAAU,MAAM;AACd,UAAI,cAAc;AAMhB,cAAM,eAAe,SAAS;AAC9B,cAAM,kBAAkB,SAAS,cAAc,KAAK;AACpD,wBAAgB,UAAU,IAAI,iBAAiB;AAE/C,sBAAc,YAAY,aAAa,iBAAiB,YAAY;AAEpE,cAAM,WAAW,IAAI;AAAA,UACnB,CAAA,YAAW;AACT,0BAAc,UAAU;AAAA,cACtB;AAAA,cACA,CAAC,QAAQ,CAAC,EAAE;AAAA,YAAA;AAAA,UAEhB;AAAA,UACA,EAAE,WAAW,CAAC,GAAG,CAAC,EAAA;AAAA,QAAE;AAGtB,iBAAS,QAAQ,eAAe;AAEhC,eAAO,MAAM;AACX,mBAAS,UAAU,eAAe;AAClC,0BAAgB,OAAA;AAAA,QAClB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,YAAY,CAAC;AAEjB,WACEC,2BAAAA,KAAAC,qBAAA,EACE,UAAA;AAAA,MAAAC,2BAAAA;AAAAA,QAAC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AAO,EAAE,4BAA4B,4BAAA;AACvC;ACzFAiB,MAAAA,uBAAuB,OAAO;;;;;;;;;;;;;"}
|
package/dist/table.esm.js
CHANGED
|
@@ -240,6 +240,9 @@ const SortableHeaderCellButton = ({
|
|
|
240
240
|
};
|
|
241
241
|
function useSortableData(tableData, externalSortConfig = { key: "", order: "none" }) {
|
|
242
242
|
const [sortConfig, setSortConfig] = useState(externalSortConfig);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
setSortConfig(externalSortConfig);
|
|
245
|
+
}, [externalSortConfig.key, externalSortConfig.order]);
|
|
243
246
|
const onSortRequested = (key) => {
|
|
244
247
|
const sortingNewColumn = key !== sortConfig.key;
|
|
245
248
|
if (sortingNewColumn || sortConfig.order === "none")
|
|
@@ -249,18 +252,17 @@ function useSortableData(tableData, externalSortConfig = { key: "", order: "none
|
|
|
249
252
|
if (sortConfig.order === "descending")
|
|
250
253
|
return setSortConfig({ key, order: "none" });
|
|
251
254
|
};
|
|
252
|
-
const tableSortedAscending = useMemo(
|
|
253
|
-
|
|
255
|
+
const tableSortedAscending = useMemo(() => {
|
|
256
|
+
const collator = new Intl.Collator(["no", "en"], {
|
|
257
|
+
numeric: true,
|
|
258
|
+
sensitivity: "base"
|
|
259
|
+
});
|
|
260
|
+
return [...tableData].sort((a, b) => {
|
|
254
261
|
const valueOfA = get(a, sortConfig.key, a)?.toString() ?? "";
|
|
255
262
|
const valueOfB = get(b, sortConfig.key, b)?.toString() ?? "";
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
});
|
|
260
|
-
return stringComparator.compare(valueOfA, valueOfB);
|
|
261
|
-
}),
|
|
262
|
-
[tableData, sortConfig.key]
|
|
263
|
-
);
|
|
263
|
+
return collator.compare(valueOfA, valueOfB);
|
|
264
|
+
});
|
|
265
|
+
}, [tableData, sortConfig.key]);
|
|
264
266
|
const sortedData = useMemo(() => {
|
|
265
267
|
switch (sortConfig.order) {
|
|
266
268
|
case "ascending": {
|
|
@@ -300,7 +302,6 @@ function useSortableData(tableData, externalSortConfig = { key: "", order: "none
|
|
|
300
302
|
} = {}) => {
|
|
301
303
|
return {
|
|
302
304
|
sortable,
|
|
303
|
-
sortConfig,
|
|
304
305
|
...props
|
|
305
306
|
};
|
|
306
307
|
};
|
package/dist/table.esm.js.map
CHANGED
|
@@ -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.ts","../src/index.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport classNames from 'classnames';\nimport { useRandomId, mergeRefs } from '@entur/utils';\nimport { VisuallyHidden } from '@entur/a11y';\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 /** Om header-raden skal bli værende på skjermen når man skroller tabellen\n * @default false\n */\n stickyHeader?: 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 changeSortDescription = 'Tabelloverskrifter med knapper kan trykkes på for å endre sortering,',\n stickyHeader = false,\n ...rest\n },\n ref,\n ) => {\n const sortableHeaderId = useRandomId('sortable-header');\n\n const tableRef = useRef<HTMLTableElement>(null);\n\n useEffect(() => {\n if (stickyHeader) {\n /* We check when an inserted div above the header \n is outside our scrolling container to determine when\n the table header becomes sticky. This is necessary\n to conditionally add our box-shadow when the \n header is overlapping table rows */\n const tableElement = tableRef.current;\n const observerElement = document.createElement('div');\n observerElement.classList.add('sticky-observer');\n\n tableElement?.parentNode?.insertBefore(observerElement, tableElement);\n\n const observer = new IntersectionObserver(\n entries => {\n tableElement?.classList.toggle(\n 'eds-table--sticky-header--active',\n !entries[0].isIntersecting,\n );\n },\n { threshold: [0, 1] },\n );\n\n observer.observe(observerElement);\n\n return () => {\n observer.unobserve(observerElement);\n observerElement.remove();\n };\n }\n }, [stickyHeader]);\n\n return (\n <>\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 { 'eds-table--sticky-header': stickyHeader },\n className,\n )}\n ref={mergeRefs(ref, tableRef)}\n aria-describedby={sortable ? sortableHeaderId : undefined}\n {...rest}\n />\n {sortable && (\n <VisuallyHidden id={sortableHeaderId}>\n {changeSortDescription}\n </VisuallyHidden>\n )}\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\nimport { BulletBadge } from '@entur/layout';\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst danger = 'danger';\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 /** @deprecated bruk variant */\n status?: 'positive' | 'negative' | 'neutral';\n /** Hvilken type status man vil vise */\n variant?: 'primary' | 'neutral' | VariantType | typeof danger | typeof info;\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nfunction mapStatusToVariant(\n status: 'positive' | 'negative' | 'neutral',\n): DataCellProps['variant'] {\n switch (status) {\n case 'positive':\n return 'success';\n case 'negative':\n return 'negative';\n case 'neutral':\n return 'neutral';\n default:\n return 'neutral';\n }\n}\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status, variant, children, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => {\n // If variant is undefined and status is defined, map status to variant\n if (!variant && status) {\n variant = mapStatusToVariant(status);\n }\n return (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\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 {variant ? (\n <BulletBadge variant={variant}>{children}</BulletBadge>\n ) : (\n children\n )}\n </td>\n );\n },\n);\n","import React, { useEffect, useState } from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\nimport { VisuallyHidden } from '@entur/a11y';\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 sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: 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 sortedAscendingAriaLabel = ', sortert stigende',\n sortedDescendingAriaLabel = ', sortert synkende',\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 : undefined;\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 ariaSort={ariaSort}\n sortedAscendingAriaLabel={sortedAscendingAriaLabel}\n sortedDescendingAriaLabel={sortedDescendingAriaLabel}\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 ariaSort?: 'none' | 'ascending' | 'descending' | 'other' | undefined;\n sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: string;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n ariaSort,\n sortedAscendingAriaLabel,\n sortedDescendingAriaLabel,\n}) => {\n const [sortedAriaInfo, setSortedAriaInfo] = useState<string | undefined>('');\n\n const { className, ...rest } = sortableButtonProps;\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n useEffect(() => {\n const DISMISS_SORT_INFO_TIME = 3000;\n if (sortConfig.order == 'ascending') {\n setSortedAriaInfo(sortedAscendingAriaLabel);\n } else if (sortConfig.order == 'descending') {\n setSortedAriaInfo(sortedDescendingAriaLabel);\n }\n const dismissAriaTimer = setTimeout(() => {\n setSortedAriaInfo('');\n if (isFirefox) setSortedAriaInfo(', sort ' + sortConfig.order);\n }, DISMISS_SORT_INFO_TIME);\n\n return () => clearTimeout(dismissAriaTimer);\n }, [sortConfig.order]);\n\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n aria-sort={ariaSort}\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n <VisuallyHidden>{isCurrentlySorted && sortedAriaInfo}</VisuallyHidden>\n </button>\n );\n};\n","import {\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n useMemo,\n useState,\n} 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: (\n args?: SortableTableProps,\n ) => 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 = useMemo(\n () =>\n [...tableData].sort((a: any, b: any) => {\n const valueOfA: string = get(a, sortConfig.key, a)?.toString() ?? '';\n const valueOfB: string = get(b, sortConfig.key, b)?.toString() ?? '';\n\n const stringComparator = new Intl.Collator(['no', 'en'], {\n numeric: true,\n sensitivity: 'base',\n });\n\n return stringComparator.compare(valueOfA, valueOfB);\n }),\n [tableData, sortConfig.key],\n );\n\n const sortedData = useMemo(() => {\n switch (sortConfig.order) {\n case 'ascending': {\n return tableSortedAscending;\n }\n case 'descending': {\n return [...tableSortedAscending].reverse();\n }\n case 'none': {\n return tableData;\n }\n default: {\n return tableData;\n }\n }\n }, [sortConfig.order, tableData, tableSortedAscending]);\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';\n\nimport { VariantProvider } from '@entur/form';\nimport { VariantType } from '@entur/utils';\nimport { Tooltip } from '@entur/tooltip';\n\nimport './EditableCell.scss';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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 | typeof error | typeof info;\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 ? 'negative' : 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 type=\"button\"\n {...rest}\n >\n <DownArrowIcon aria-hidden 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":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,QAAQ,MAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,mBAAmB,YAAY,iBAAiB;AAEtD,UAAM,WAAW,OAAyB,IAAI;AAE9C,cAAU,MAAM;AACd,UAAI,cAAc;AAMhB,cAAM,eAAe,SAAS;AAC9B,cAAM,kBAAkB,SAAS,cAAc,KAAK;AACpD,wBAAgB,UAAU,IAAI,iBAAiB;AAE/C,sBAAc,YAAY,aAAa,iBAAiB,YAAY;AAEpE,cAAM,WAAW,IAAI;AAAA,UACnB,CAAA,YAAW;AACT,0BAAc,UAAU;AAAA,cACtB;AAAA,cACA,CAAC,QAAQ,CAAC,EAAE;AAAA,YAAA;AAAA,UAEhB;AAAA,UACA,EAAE,WAAW,CAAC,GAAG,CAAC,EAAA;AAAA,QAAE;AAGtB,iBAAS,QAAQ,eAAe;AAEhC,eAAO,MAAM;AACX,mBAAS,UAAU,eAAe;AAClC,0BAAgB,OAAA;AAAA,QAClB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,YAAY,CAAC;AAEjB,WACE,qBAAA,UAAA,EACE,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA,EAAE,oBAAoB,MAAA;AAAA,YACtB,EAAE,qBAAqB,YAAY,SAAA;AAAA,YACnC,EAAE,oBAAoB,YAAY,QAAA;AAAA,YAClC,EAAE,uBAAuB,SAAA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Aa,QAAQ,WACnB,UACF,EAAE,WAAW,CAAC,EAAE,eAAe,MAAA;AAAA,EACnC,GAAG,CAAC,YAAY,aAAa,CAAC;AAE9B,WAAS,+BAA+B,MAAoC;AAC1E,WAAO;AAAA,MACL,KAAK;AAAA,MACL,GAAG;AAAA,IAAA;AAAA,EAEP;AAEA,QAAM,cAAc,OAA4B,IAAI;AACpD,WAAS,2BACP,QACG,MACqB;AACxB,QAAI,OAAO,QAAQ;AACjB,gBAAU,MAAM,CAAC;AAAA,IACnB;AACA,UAAM,WAAW,aAAa,IAAI;AAClC,WAAO;AAAA,MACL;AAAA,MACA,KAAK;AAAA,MACL,SAAS,MAAM,cAAc,GAAG;AAAA,MAChC,WAAW,CAAC,MAAqB;AAC/B,cAAM,UAAU,gBAAgB,GAAG,YAAY,cAAc,SAAS;AACtE,sBAAc,OAAO;AAAA,MACvB;AAAA,MACA,GAAG;AAAA,IAAA;AAAA,EAEP;AACA,SAAO,EAAE,4BAA4B,4BAAA;AACvC;ACzFA,uBAAuB,OAAO;"}
|
|
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, { useEffect, useRef } from 'react';\nimport classNames from 'classnames';\nimport { useRandomId, mergeRefs } from '@entur/utils';\nimport { VisuallyHidden } from '@entur/a11y';\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 /** Om header-raden skal bli værende på skjermen når man skroller tabellen\n * @default false\n */\n stickyHeader?: 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 changeSortDescription = 'Tabelloverskrifter med knapper kan trykkes på for å endre sortering,',\n stickyHeader = false,\n ...rest\n },\n ref,\n ) => {\n const sortableHeaderId = useRandomId('sortable-header');\n\n const tableRef = useRef<HTMLTableElement>(null);\n\n useEffect(() => {\n if (stickyHeader) {\n /* We check when an inserted div above the header \n is outside our scrolling container to determine when\n the table header becomes sticky. This is necessary\n to conditionally add our box-shadow when the \n header is overlapping table rows */\n const tableElement = tableRef.current;\n const observerElement = document.createElement('div');\n observerElement.classList.add('sticky-observer');\n\n tableElement?.parentNode?.insertBefore(observerElement, tableElement);\n\n const observer = new IntersectionObserver(\n entries => {\n tableElement?.classList.toggle(\n 'eds-table--sticky-header--active',\n !entries[0].isIntersecting,\n );\n },\n { threshold: [0, 1] },\n );\n\n observer.observe(observerElement);\n\n return () => {\n observer.unobserve(observerElement);\n observerElement.remove();\n };\n }\n }, [stickyHeader]);\n\n return (\n <>\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 { 'eds-table--sticky-header': stickyHeader },\n className,\n )}\n ref={mergeRefs(ref, tableRef)}\n aria-describedby={sortable ? sortableHeaderId : undefined}\n {...rest}\n />\n {sortable && (\n <VisuallyHidden id={sortableHeaderId}>\n {changeSortDescription}\n </VisuallyHidden>\n )}\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\nimport { BulletBadge } from '@entur/layout';\nimport { VariantType } from '@entur/utils';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst danger = 'danger';\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 /** @deprecated bruk variant */\n status?: 'positive' | 'negative' | 'neutral';\n /** Hvilken type status man vil vise */\n variant?: 'primary' | 'neutral' | VariantType | typeof danger | typeof info;\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nfunction mapStatusToVariant(\n status: 'positive' | 'negative' | 'neutral',\n): DataCellProps['variant'] {\n switch (status) {\n case 'positive':\n return 'success';\n case 'negative':\n return 'negative';\n case 'neutral':\n return 'neutral';\n default:\n return 'neutral';\n }\n}\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status, variant, children, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => {\n // If variant is undefined and status is defined, map status to variant\n if (!variant && status) {\n variant = mapStatusToVariant(status);\n }\n return (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\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 {variant ? (\n <BulletBadge variant={variant}>{children}</BulletBadge>\n ) : (\n children\n )}\n </td>\n );\n },\n);\n","import React, { useEffect, useState } from 'react';\nimport classNames from 'classnames';\n\nimport { DownArrowIcon, UpArrowIcon, UnsortedIcon } from '@entur/icons';\n\nimport { ExternalSortConfig } from '.';\n\nimport './HeaderCell.scss';\nimport { VisuallyHidden } from '@entur/a11y';\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 sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: 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 sortedAscendingAriaLabel = ', sortert stigende',\n sortedDescendingAriaLabel = ', sortert synkende',\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 : undefined;\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 ariaSort={ariaSort}\n sortedAscendingAriaLabel={sortedAscendingAriaLabel}\n sortedDescendingAriaLabel={sortedDescendingAriaLabel}\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 ariaSort?: 'none' | 'ascending' | 'descending' | 'other' | undefined;\n sortedAscendingAriaLabel?: string;\n sortedDescendingAriaLabel?: string;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n ariaSort,\n sortedAscendingAriaLabel,\n sortedDescendingAriaLabel,\n}) => {\n const [sortedAriaInfo, setSortedAriaInfo] = useState<string | undefined>('');\n\n const { className, ...rest } = sortableButtonProps;\n\n const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n\n useEffect(() => {\n const DISMISS_SORT_INFO_TIME = 3000;\n if (sortConfig.order == 'ascending') {\n setSortedAriaInfo(sortedAscendingAriaLabel);\n } else if (sortConfig.order == 'descending') {\n setSortedAriaInfo(sortedDescendingAriaLabel);\n }\n const dismissAriaTimer = setTimeout(() => {\n setSortedAriaInfo('');\n if (isFirefox) setSortedAriaInfo(', sort ' + sortConfig.order);\n }, DISMISS_SORT_INFO_TIME);\n\n return () => clearTimeout(dismissAriaTimer);\n }, [sortConfig.order]);\n\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n aria-sort={ariaSort}\n {...rest}\n >\n {children}\n {(!isCurrentlySorted || sortConfig.order === 'none') && (\n <UnsortedIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"1em\"\n className=\"eds-table__header-cell-button-icon\"\n aria-hidden=\"true\"\n />\n )}\n <VisuallyHidden>{isCurrentlySorted && sortedAriaInfo}</VisuallyHidden>\n </button>\n );\n};\n","import {\n ButtonHTMLAttributes,\n DetailedHTMLProps,\n useEffect,\n useMemo,\n useState,\n} 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: (\n args?: SortableTableProps,\n ) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = useState(externalSortConfig);\n\n useEffect(() => {\n setSortConfig(externalSortConfig);\n }, [externalSortConfig.key, externalSortConfig.order]);\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 = useMemo(() => {\n const collator = new Intl.Collator(['no', 'en'], {\n numeric: true,\n sensitivity: 'base',\n });\n\n return [...tableData].sort((a: any, b: any) => {\n const valueOfA: string = get(a, sortConfig.key, a)?.toString() ?? '';\n const valueOfB: string = get(b, sortConfig.key, b)?.toString() ?? '';\n\n return collator.compare(valueOfA, valueOfB);\n });\n }, [tableData, sortConfig.key]);\n\n const sortedData = useMemo(() => {\n switch (sortConfig.order) {\n case 'ascending': {\n return tableSortedAscending;\n }\n case 'descending': {\n return [...tableSortedAscending].reverse();\n }\n case 'none': {\n return tableData;\n }\n default: {\n return tableData;\n }\n }\n }, [sortConfig.order, tableData, tableSortedAscending]);\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 ...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 [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\n\nimport { VariantProvider } from '@entur/form';\nimport { VariantType } from '@entur/utils';\nimport { Tooltip } from '@entur/tooltip';\n\nimport './EditableCell.scss';\n\n/** @deprecated use variant=\"information\" instead */\nconst info = 'info';\n/** @deprecated use variant=\"negative\" instead */\nconst error = 'error';\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 | typeof error | typeof info;\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 ? 'negative' : 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 type=\"button\"\n {...rest}\n >\n <DownArrowIcon aria-hidden 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":[],"mappings":";;;;;;;;;;;;AAwBO,MAAM,QAAQ,MAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX,wBAAwB;AAAA,IACxB,eAAe;AAAA,IACf,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,mBAAmB,YAAY,iBAAiB;AAEtD,UAAM,WAAW,OAAyB,IAAI;AAE9C,cAAU,MAAM;AACd,UAAI,cAAc;AAMhB,cAAM,eAAe,SAAS;AAC9B,cAAM,kBAAkB,SAAS,cAAc,KAAK;AACpD,wBAAgB,UAAU,IAAI,iBAAiB;AAE/C,sBAAc,YAAY,aAAa,iBAAiB,YAAY;AAEpE,cAAM,WAAW,IAAI;AAAA,UACnB,CAAA,YAAW;AACT,0BAAc,UAAU;AAAA,cACtB;AAAA,cACA,CAAC,QAAQ,CAAC,EAAE;AAAA,YAAA;AAAA,UAE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|
1
1
|
{
|
|
2
2
|
"name": "@entur/table",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.7",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/table.cjs.js",
|
|
6
6
|
"module": "dist/table.esm.js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@entur/a11y": "^0.2.107",
|
|
31
31
|
"@entur/button": "^4.0.3",
|
|
32
32
|
"@entur/expand": "^3.7.4",
|
|
33
|
-
"@entur/form": "^9.2.
|
|
33
|
+
"@entur/form": "^9.2.7",
|
|
34
34
|
"@entur/icons": "^8.4.3",
|
|
35
|
-
"@entur/layout": "^3.4.
|
|
35
|
+
"@entur/layout": "^3.4.2",
|
|
36
36
|
"@entur/tokens": "^3.22.2",
|
|
37
|
-
"@entur/tooltip": "^5.3.
|
|
37
|
+
"@entur/tooltip": "^5.3.7",
|
|
38
38
|
"@entur/utils": "^0.13.1",
|
|
39
39
|
"classnames": "^2.5.1",
|
|
40
40
|
"lodash.get": "^4.4.2"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"vite": "^7.1.3",
|
|
54
54
|
"vite-plugin-dts": "^4.5.4"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "ee1f35746ed0ce1e2ab24377ec9d1bb78f6fabac"
|
|
57
57
|
}
|