@entur/table 4.3.18 → 4.5.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.5.1](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.5.0...@entur/table@4.5.1) (2021-12-10)
7
+
8
+ **Note:** Version bump only for package @entur/table
9
+
10
+ # [4.5.0](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.4.1...@entur/table@4.5.0) (2021-11-17)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **headercell:** improve typings of props ([f8fff33](https://bitbucket.org/enturas/design-system/commits/f8fff33a6a94d1932d9d21df946ee62702ba6690))
15
+ - **useSortableTable:** apply focus styling for sortable HeaderCells ([cf481eb](https://bitbucket.org/enturas/design-system/commits/cf481eb8528c056e3e07ab8e37b94e374d1ca5d7))
16
+
17
+ ### Features
18
+
19
+ - **usesortabletable:** add buttonProps to getSortableeHeaderProps ([a5f3d48](https://bitbucket.org/enturas/design-system/commits/a5f3d48518f2ab729a91df0c58e367279fbdaa69))
20
+
21
+ ## [4.4.1](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.4.0...@entur/table@4.4.1) (2021-10-25)
22
+
23
+ ### Bug Fixes
24
+
25
+ - **tablebody:** fix typing for ref prop ([fe133f2](https://bitbucket.org/enturas/design-system/commits/fe133f25f882d39b682baf6fb3b214305ac75dfc))
26
+
27
+ # [4.4.0](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.3.18...@entur/table@4.4.0) (2021-10-18)
28
+
29
+ ### Bug Fixes
30
+
31
+ - **sortable table:** fix sort icon position on small and middle table ([f57062f](https://bitbucket.org/enturas/design-system/commits/f57062f6753df1cdba8cd3ba1290e5b1b1f6c724))
32
+ - improve useTableKeyboardNavigation ([2d112cf](https://bitbucket.org/enturas/design-system/commits/2d112cf263a73f9c4ad9dcbaa20db6be27829702))
33
+ - **expand row button:** fix focus styling ([9d94b9c](https://bitbucket.org/enturas/design-system/commits/9d94b9c0bb7b44f881cd769694491d294874988c))
34
+ - **tablebody:** improve typings ([729f69d](https://bitbucket.org/enturas/design-system/commits/729f69d733df82f75bbc010a35757f5bd6c9af06))
35
+ - **tablerow:** export props for component ([8119df0](https://bitbucket.org/enturas/design-system/commits/8119df03209d33603335fd744866bfbee6b0d4c7))
36
+
37
+ ### Features
38
+
39
+ - add hook for enabling keyboard navigation in tables ([cd7ef12](https://bitbucket.org/enturas/design-system/commits/cd7ef12474810aa813a275804e2356b26814c56f))
40
+
6
41
  ## [4.3.18](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.3.17...@entur/table@4.3.18) (2021-09-23)
7
42
 
8
43
  **Note:** Version bump only for package @entur/table
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import './HeaderCell.scss';
3
+ import { ExternalSortConfig } from '.';
3
4
  export declare type HeaderCellProps = {
4
5
  /** Kolonneoverskrift */
5
6
  children: React.ReactNode;
@@ -7,6 +8,15 @@ export declare type HeaderCellProps = {
7
8
  className?: string;
8
9
  /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */
9
10
  padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';
10
- [key: string]: any;
11
- };
12
- export declare const HeaderCell: React.ForwardRefExoticComponent<Pick<HeaderCellProps, React.ReactText> & React.RefAttributes<HTMLTableHeaderCellElement>>;
11
+ /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */
12
+ sortableButtonProps?: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
13
+ /** Om komponenten brukes til sortering. Benytt via useSortableTable
14
+ * @default false
15
+ */
16
+ sortable?: boolean;
17
+ /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */
18
+ sortConfig?: ExternalSortConfig;
19
+ /** Navnet det skal sorteres på. Benyttes via useSortableTable */
20
+ name?: string;
21
+ } & React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableCellElement>, HTMLTableCellElement>;
22
+ export declare const HeaderCell: React.ForwardRefExoticComponent<Pick<HeaderCellProps, "className" | "children" | "name" | "sortable" | "sortConfig" | "padding" | "sortableButtonProps" | "key" | "align" | "colSpan" | "headers" | "rowSpan" | "scope" | "abbr" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLTableCellElement>>;
@@ -4,6 +4,6 @@ export declare type TableBodyProps = {
4
4
  children: React.ReactNode;
5
5
  /** Ekstra klassenavn */
6
6
  className?: string;
7
- [key: string]: any;
8
- };
9
- export declare const TableBody: React.ForwardRefExoticComponent<Pick<TableBodyProps, React.ReactText> & React.RefAttributes<HTMLTableSectionElement>>;
7
+ ref?: React.Ref<HTMLTableSectionElement>;
8
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
9
+ export declare const TableBody: React.ForwardRefExoticComponent<Pick<TableBodyProps, "className" | "children" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLTableSectionElement>>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type TableRowProps = {
2
+ export declare type TableRowProps = {
3
3
  /** Tabellceller */
4
4
  children: React.ReactNode;
5
5
  /** Ekstra klassenavn */
@@ -16,6 +16,6 @@ declare type TableRowProps = {
16
16
  * @default false
17
17
  */
18
18
  error?: boolean;
19
+ ref?: React.Ref<HTMLTableRowElement>;
19
20
  } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
20
21
  export declare const TableRow: React.ForwardRefExoticComponent<Pick<TableRowProps, "className" | "hover" | "active" | "error" | "children" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture"> & React.RefAttributes<HTMLTableRowElement>>;
21
- export {};
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from './useSortableTable';
10
10
  export * from './EditableCell';
11
11
  export * from './ExpandableRow';
12
12
  export * from './ExpandRowButton';
13
+ export * from './useTableKeyboardNavigation';
package/dist/styles.css CHANGED
@@ -22,10 +22,16 @@
22
22
  padding: 0.5rem 1rem;
23
23
  height: 3rem;
24
24
  }
25
+ .eds-table--middle .eds-table__data-cell .eds-table__header-cell-button-icon, .eds-table--middle .eds-table__header-cell .eds-table__header-cell-button-icon {
26
+ top: 0.5rem;
27
+ }
25
28
  .eds-table--small .eds-table__data-cell, .eds-table--small .eds-table__header-cell {
26
29
  padding: 0.25rem 1rem;
27
30
  height: 2rem;
28
31
  }
32
+ .eds-table--small .eds-table__data-cell .eds-table__header-cell-button-icon, .eds-table--small .eds-table__header-cell .eds-table__header-cell-button-icon {
33
+ top: 0.25rem;
34
+ }
29
35
  .eds-table__header-cell {
30
36
  padding-top: 0;
31
37
  }
@@ -88,6 +94,9 @@
88
94
  .eds-contrast .eds-table__body > .eds-table__row {
89
95
  border-color: #393d79;
90
96
  }
97
+ .eds-table__body > .eds-table__row:focus {
98
+ outline: 2px solid #181c56;
99
+ }
91
100
  .eds-table__body > .eds-table__row--hover:hover {
92
101
  background: #f3f3f3;
93
102
  }
@@ -205,28 +214,6 @@
205
214
  padding: calc(0.25rem - 0.125rem) calc(0.5rem - 0.0625rem);
206
215
  }/* DO NOT CHANGE!*/
207
216
  /* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
208
- .eds-expand-row-button {
209
- background: none;
210
- border: none;
211
- font-family: inherit;
212
- cursor: pointer;
213
- padding: 0.25rem;
214
- }
215
- .eds-expand-row-button:focus {
216
- outline: none;
217
- box-shadow: 0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #181c56;
218
- outline-offset: 0.125rem;
219
- }
220
- .eds-contrast .eds-expand-row-button:focus {
221
- box-shadow: 0 0 0 0.125rem #181c56, 0 0 0 0.25rem #ffffff;
222
- }
223
- .eds-expand-row-button--open .eds-expand-row-button__icon {
224
- transform: rotate(90deg);
225
- }
226
- .eds-expand-row-button__icon {
227
- transition: transform ease-in-out 0.2s;
228
- }/* DO NOT CHANGE!*/
229
- /* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
230
217
  .eds-table__header-cell {
231
218
  color: #656782;
232
219
  font-size: 0.875rem;
@@ -267,4 +254,37 @@
267
254
  position: absolute;
268
255
  top: 0.75rem;
269
256
  margin-left: 0.25rem;
257
+ }
258
+ .eds-table__header-cell-button:focus {
259
+ outline: 2px solid #181c56;
260
+ }
261
+ .eds-contrast .eds-table__header-cell-button:focus {
262
+ outline: 2px solid #ffffff;
263
+ }/* DO NOT CHANGE!*/
264
+ /* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
265
+ .eds-expand-row-button {
266
+ background: #ffffff;
267
+ border: none;
268
+ border-radius: 50%;
269
+ font-family: inherit;
270
+ cursor: pointer;
271
+ height: 1.5rem;
272
+ width: 1.5rem;
273
+ padding: 0.25rem;
274
+ }
275
+ .eds-expand-row-button:focus {
276
+ outline: none;
277
+ box-shadow: 0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #181c56;
278
+ }
279
+ .eds-contrast .eds-expand-row-button:focus {
280
+ box-shadow: 0 0 0 0.125rem #181c56, 0 0 0 0.25rem #ffffff;
281
+ }
282
+ .eds-contrast .eds-expand-row-button {
283
+ background: #181c56;
284
+ }
285
+ .eds-expand-row-button--open .eds-expand-row-button__icon {
286
+ transform: rotate(90deg);
287
+ }
288
+ .eds-expand-row-button__icon {
289
+ transition: transform ease-in-out 0.2s;
270
290
  }
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
7
  var utils = require('@entur/utils');
8
- var React = _interopDefault(require('react'));
8
+ var React = require('react');
9
+ var React__default = _interopDefault(React);
9
10
  var classNames = _interopDefault(require('classnames'));
10
11
  var icons = require('@entur/icons');
11
12
  var get = _interopDefault(require('lodash.get'));
@@ -46,7 +47,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
46
47
  return target;
47
48
  }
48
49
 
49
- var Table = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
50
+ var Table = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
50
51
  var className = _ref.className,
51
52
  _ref$fixed = _ref.fixed,
52
53
  fixed = _ref$fixed === void 0 ? false : _ref$fixed,
@@ -56,7 +57,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
56
57
  sortable = _ref$sortable === void 0 ? false : _ref$sortable,
57
58
  rest = _objectWithoutPropertiesLoose(_ref, ["className", "fixed", "spacing", "sortable"]);
58
59
 
59
- return React.createElement("table", Object.assign({
60
+ return React__default.createElement("table", Object.assign({
60
61
  className: classNames('eds-table', {
61
62
  'eds-table--fixed': fixed
62
63
  }, {
@@ -70,35 +71,35 @@ var Table = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
70
71
  }, rest));
71
72
  });
72
73
 
73
- var TableHead = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
74
+ var TableHead = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
74
75
  var className = _ref.className,
75
76
  props = _objectWithoutPropertiesLoose(_ref, ["className"]);
76
77
 
77
- return React.createElement("thead", Object.assign({
78
+ return React__default.createElement("thead", Object.assign({
78
79
  className: classNames('eds-table__head', className),
79
80
  ref: ref
80
81
  }, props));
81
82
  });
82
83
 
83
- var TableBody = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
84
+ var TableBody = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
84
85
  var className = _ref.className,
85
86
  rest = _objectWithoutPropertiesLoose(_ref, ["className"]);
86
87
 
87
- return React.createElement("tbody", Object.assign({
88
+ return React__default.createElement("tbody", Object.assign({
88
89
  className: classNames('eds-table__body', className),
89
90
  ref: ref
90
91
  }, rest));
91
92
  });
92
93
 
93
- var TableFooter = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
94
+ var TableFooter = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
94
95
  var props = _extends({}, _ref);
95
96
 
96
- return React.createElement("tfoot", Object.assign({
97
+ return React__default.createElement("tfoot", Object.assign({
97
98
  ref: ref
98
99
  }, props));
99
100
  });
100
101
 
101
- var TableRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
102
+ var TableRow = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
102
103
  var className = _ref.className,
103
104
  _ref$hover = _ref.hover,
104
105
  hover = _ref$hover === void 0 ? false : _ref$hover,
@@ -108,7 +109,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
108
109
  error = _ref$error === void 0 ? false : _ref$error,
109
110
  rest = _objectWithoutPropertiesLoose(_ref, ["className", "hover", "active", "error"]);
110
111
 
111
- return React.createElement("tr", Object.assign({
112
+ return React__default.createElement("tr", Object.assign({
112
113
  className: classNames('eds-table__row', className, {
113
114
  'eds-table__row--hover': hover,
114
115
  'eds-table__row--active': active,
@@ -118,7 +119,7 @@ var TableRow = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
118
119
  }, rest));
119
120
  });
120
121
 
121
- var DataCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
122
+ var DataCell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
122
123
  var _classNames;
123
124
 
124
125
  var className = _ref.className,
@@ -128,33 +129,33 @@ var DataCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
128
129
  status = _ref$status === void 0 ? undefined : _ref$status,
129
130
  rest = _objectWithoutPropertiesLoose(_ref, ["className", "padding", "status"]);
130
131
 
131
- return React.createElement("td", Object.assign({
132
+ return React__default.createElement("td", Object.assign({
132
133
  ref: ref,
133
134
  className: classNames('eds-table__data-cell', className, (_classNames = {}, _classNames["eds-table__data-cell--status-" + status] = status, _classNames['eds-table__data-cell--padding-checkbox'] = padding === 'checkbox', _classNames['eds-table__data-cell--padding-radio'] = padding === 'radio', _classNames['eds-table__data-cell--padding-overflow-menu'] = padding === 'overflow-menu', _classNames))
134
135
  }, rest));
135
136
  });
136
137
 
137
- var HeaderCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
138
+ var HeaderCell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
138
139
  var className = _ref.className,
139
140
  children = _ref.children,
140
- onClick = _ref.onClick,
141
141
  name = _ref.name,
142
142
  _ref$sortable = _ref.sortable,
143
143
  sortable = _ref$sortable === void 0 ? false : _ref$sortable,
144
144
  sortConfig = _ref.sortConfig,
145
145
  _ref$padding = _ref.padding,
146
146
  padding = _ref$padding === void 0 ? 'default' : _ref$padding,
147
- rest = _objectWithoutPropertiesLoose(_ref, ["className", "children", "onClick", "name", "sortable", "sortConfig", "padding"]);
147
+ sortableButtonProps = _ref.sortableButtonProps,
148
+ rest = _objectWithoutPropertiesLoose(_ref, ["className", "children", "name", "sortable", "sortConfig", "padding", "sortableButtonProps"]);
148
149
 
149
- var _React$useState = React.useState(false),
150
+ var _React$useState = React__default.useState(false),
150
151
  isCurrentlySorted = _React$useState[0],
151
152
  setIsCurrentlySorted = _React$useState[1];
152
153
 
153
- React.useEffect(function () {
154
- setIsCurrentlySorted(sortConfig && name === sortConfig.key);
154
+ React__default.useEffect(function () {
155
+ sortConfig && name && setIsCurrentlySorted(sortConfig && name === sortConfig.key);
155
156
  }, [sortConfig, name]);
156
157
  var ariaSort = isCurrentlySorted ? sortConfig && sortConfig.order : 'none';
157
- return React.createElement("th", Object.assign({
158
+ return React__default.createElement("th", Object.assign({
158
159
  className: classNames('eds-table__header-cell', className, {
159
160
  'eds-table__header-cell--sortable': sortable,
160
161
  'eds-table__header-cell--padding-radio': padding === 'radio',
@@ -163,18 +164,33 @@ var HeaderCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
163
164
  }),
164
165
  "aria-sort": ariaSort,
165
166
  ref: ref
166
- }, rest), sortable ? React.createElement("button", {
167
- className: "eds-table__header-cell-button",
168
- type: "button",
169
- onClick: onClick
170
- }, children, isCurrentlySorted && sortConfig.order === 'ascending' && React.createElement(icons.UpArrowIcon, {
167
+ }, rest), sortable && sortConfig && sortableButtonProps ? React__default.createElement(SortableHeaderCellButton, {
168
+ sortableButtonProps: sortableButtonProps,
169
+ sortConfig: sortConfig,
170
+ isCurrentlySorted: isCurrentlySorted
171
+ }, children) : children);
172
+ });
173
+
174
+ var SortableHeaderCellButton = function SortableHeaderCellButton(_ref2) {
175
+ var sortConfig = _ref2.sortConfig,
176
+ sortableButtonProps = _ref2.sortableButtonProps,
177
+ isCurrentlySorted = _ref2.isCurrentlySorted,
178
+ children = _ref2.children;
179
+
180
+ var className = sortableButtonProps.className,
181
+ rest = _objectWithoutPropertiesLoose(sortableButtonProps, ["className"]);
182
+
183
+ return React__default.createElement("button", Object.assign({
184
+ className: classNames('eds-table__header-cell-button', className),
185
+ type: "button"
186
+ }, rest), children, isCurrentlySorted && sortConfig.order === 'ascending' && React__default.createElement(icons.UpArrowIcon, {
171
187
  size: "16px",
172
188
  className: "eds-table__header-cell-button-icon"
173
- }), isCurrentlySorted && sortConfig.order === 'descending' && React.createElement(icons.DownArrowIcon, {
189
+ }), isCurrentlySorted && sortConfig.order === 'descending' && React__default.createElement(icons.DownArrowIcon, {
174
190
  size: "16px",
175
191
  className: "eds-table__header-cell-button-icon"
176
- })) : children);
177
- });
192
+ }));
193
+ };
178
194
 
179
195
  function useSortableData(rawData, externalSortConfig) {
180
196
  if (externalSortConfig === void 0) {
@@ -184,18 +200,18 @@ function useSortableData(rawData, externalSortConfig) {
184
200
  };
185
201
  }
186
202
 
187
- var _React$useState = React.useState(externalSortConfig),
203
+ var _React$useState = React__default.useState(externalSortConfig),
188
204
  sortConfig = _React$useState[0],
189
205
  setSortConfig = _React$useState[1];
190
206
 
191
207
  var tableCopy = rawData.slice();
192
- React.useEffect(function () {
208
+ React__default.useEffect(function () {
193
209
  setSortConfig({
194
210
  key: externalSortConfig.key,
195
211
  order: externalSortConfig.order
196
212
  });
197
213
  }, [externalSortConfig.key, externalSortConfig.order]);
198
- var sortedData = React.useMemo(function () {
214
+ var sortedData = React__default.useMemo(function () {
199
215
  if (sortConfig.order === 'none') {
200
216
  return tableCopy;
201
217
  }
@@ -230,15 +246,18 @@ function useSortableData(rawData, externalSortConfig) {
230
246
  var name = _ref.name,
231
247
  _ref$sortable = _ref.sortable,
232
248
  sortable = _ref$sortable === void 0 ? true : _ref$sortable,
233
- props = _objectWithoutPropertiesLoose(_ref, ["name", "sortable"]);
249
+ buttonProps = _ref.buttonProps,
250
+ props = _objectWithoutPropertiesLoose(_ref, ["name", "sortable", "buttonProps"]);
234
251
 
235
252
  return _extends({
236
253
  name: name,
237
254
  sortable: sortable,
238
- onClick: function onClick() {
239
- return onSortRequested(name);
240
- },
241
- sortConfig: sortConfig
255
+ sortConfig: sortConfig,
256
+ sortableButtonProps: _extends({
257
+ onClick: function onClick() {
258
+ return onSortRequested(name);
259
+ }
260
+ }, buttonProps)
242
261
  }, props);
243
262
  }
244
263
 
@@ -269,13 +288,13 @@ var EditableCell = function EditableCell(_ref) {
269
288
  outlined = _ref$outlined === void 0 ? false : _ref$outlined,
270
289
  rest = _objectWithoutPropertiesLoose(_ref, ["children", "className", "feedback", "variant", "outlined"]);
271
290
 
272
- return React.createElement(form.VariantProvider, {
291
+ return React__default.createElement(form.VariantProvider, {
273
292
  variant: variant
274
- }, React.createElement(DataCell, Object.assign({
293
+ }, React__default.createElement(DataCell, Object.assign({
275
294
  className: classNames('eds-editable-cell', {
276
295
  'eds-editable-cell--outlined': outlined
277
296
  }, className)
278
- }, rest), React.createElement(tooltip.Tooltip, {
297
+ }, rest), React__default.createElement(tooltip.Tooltip, {
279
298
  disableHoverListener: !feedback,
280
299
  disableFocusListener: !feedback,
281
300
  placement: "bottom",
@@ -289,9 +308,9 @@ var ExpandableRow = function ExpandableRow(_ref) {
289
308
  open = _ref$open === void 0 ? false : _ref$open,
290
309
  children = _ref.children,
291
310
  colSpan = _ref.colSpan;
292
- return React.createElement("tr", null, React.createElement("td", {
311
+ return React__default.createElement("tr", null, React__default.createElement("td", {
293
312
  colSpan: colSpan
294
- }, React.createElement(expand.BaseExpand, {
313
+ }, React__default.createElement(expand.BaseExpand, {
295
314
  open: open
296
315
  }, children)));
297
316
  };
@@ -301,16 +320,111 @@ var ExpandRowButton = function ExpandRowButton(_ref) {
301
320
  onClick = _ref.onClick,
302
321
  rest = _objectWithoutPropertiesLoose(_ref, ["open", "onClick"]);
303
322
 
304
- return React.createElement("button", Object.assign({
323
+ return React__default.createElement("button", Object.assign({
305
324
  className: classNames('eds-expand-row-button', {
306
325
  'eds-expand-row-button--open': open
307
326
  }),
308
327
  onClick: onClick
309
- }, rest), React.createElement(icons.RightArrowIcon, {
328
+ }, rest), React__default.createElement(icons.RightArrowIcon, {
310
329
  className: "eds-expand-row-button__icon"
311
330
  }));
312
331
  };
313
332
 
333
+ function onTableKeypress(event, currentRow, maxRow, allowWrap) {
334
+ var keyPress = event.key;
335
+
336
+ switch (keyPress) {
337
+ case 'ArrowUp':
338
+ event.preventDefault();
339
+
340
+ if (allowWrap) {
341
+ return currentRow === 0 ? maxRow - 1 : currentRow - 1;
342
+ } else {
343
+ return currentRow > 0 ? currentRow - 1 : 0;
344
+ }
345
+
346
+ case 'ArrowDown':
347
+ event.preventDefault();
348
+
349
+ if (allowWrap) {
350
+ return currentRow === maxRow - 1 ? 0 : currentRow + 1;
351
+ } else {
352
+ return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;
353
+ }
354
+
355
+ default:
356
+ return currentRow;
357
+ }
358
+ }
359
+
360
+ var useTableKeyboardNavigation = function useTableKeyboardNavigation(numberOfRows, allowWrap) {
361
+ var _tableBodyRef$current;
362
+
363
+ if (numberOfRows === void 0) {
364
+ numberOfRows = 0;
365
+ }
366
+
367
+ if (allowWrap === void 0) {
368
+ allowWrap = true;
369
+ }
370
+
371
+ var _useState = React.useState(numberOfRows),
372
+ currentRow = _useState[0],
373
+ setCurrentRow = _useState[1];
374
+
375
+ var _useState2 = React.useState(0),
376
+ maxRow = _useState2[0],
377
+ setMaxRow = _useState2[1];
378
+
379
+ var tableBodyRef = React__default.useRef(null);
380
+ var tableHasFocus = tableBodyRef === null || tableBodyRef === void 0 ? void 0 : (_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 ? void 0 : _tableBodyRef$current.contains(document.activeElement);
381
+ React__default.useEffect(function () {
382
+ var _tableBodyRef$current2;
383
+
384
+ tableBodyRef && tableBodyRef.current && tableHasFocus && ((_tableBodyRef$current2 = tableBodyRef.current.childNodes[currentRow].childNodes[0].parentElement) === null || _tableBodyRef$current2 === void 0 ? void 0 : _tableBodyRef$current2.focus());
385
+ }, [currentRow]);
386
+
387
+ function getTableBodyNavigationProps() {
388
+ for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
389
+ rest[_key] = arguments[_key];
390
+ }
391
+
392
+ return _extends({
393
+ ref: tableBodyRef
394
+ }, rest);
395
+ }
396
+
397
+ function getTableRowNavigationProps(row) {
398
+ React__default.useEffect(function () {
399
+ row >= maxRow && setMaxRow(row + 1);
400
+ }, []);
401
+ var tableRowRef = React__default.useRef(null);
402
+ var tabIndex = -1;
403
+ row === currentRow ? tabIndex = 0 : undefined;
404
+
405
+ for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
406
+ rest[_key2 - 1] = arguments[_key2];
407
+ }
408
+
409
+ return _extends({
410
+ tabIndex: tabIndex,
411
+ ref: tableRowRef,
412
+ onClick: function onClick() {
413
+ return setCurrentRow(row);
414
+ },
415
+ onKeyDown: function onKeyDown(e) {
416
+ var newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);
417
+ setCurrentRow(newCell);
418
+ }
419
+ }, rest);
420
+ }
421
+
422
+ return {
423
+ getTableRowNavigationProps: getTableRowNavigationProps,
424
+ getTableBodyNavigationProps: getTableBodyNavigationProps
425
+ };
426
+ };
427
+
314
428
  utils.warnAboutMissingStyles('table');
315
429
 
316
430
  exports.DataCell = DataCell;
@@ -324,4 +438,5 @@ exports.TableFooter = TableFooter;
324
438
  exports.TableHead = TableHead;
325
439
  exports.TableRow = TableRow;
326
440
  exports.useSortableData = useSortableData;
441
+ exports.useTableKeyboardNavigation = useTableKeyboardNavigation;
327
442
  //# sourceMappingURL=table.cjs.development.js.map