@entur/table 4.4.1 → 4.5.3
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 +23 -0
- package/dist/HeaderCell.d.ts +13 -3
- package/dist/styles.css +31 -25
- package/dist/table.cjs.development.js +33 -15
- package/dist/table.cjs.development.js.map +1 -1
- package/dist/table.cjs.production.min.js +1 -1
- package/dist/table.cjs.production.min.js.map +1 -1
- package/dist/table.esm.js +33 -15
- package/dist/table.esm.js.map +1 -1
- package/dist/useSortableTable.d.ts +3 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.3](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.5.2...@entur/table@4.5.3) (2022-01-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @entur/table
|
|
9
|
+
|
|
10
|
+
## [4.5.2](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.5.1...@entur/table@4.5.2) (2022-01-05)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @entur/table
|
|
13
|
+
|
|
14
|
+
## [4.5.1](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.5.0...@entur/table@4.5.1) (2021-12-10)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @entur/table
|
|
17
|
+
|
|
18
|
+
# [4.5.0](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.4.1...@entur/table@4.5.0) (2021-11-17)
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- **headercell:** improve typings of props ([f8fff33](https://bitbucket.org/enturas/design-system/commits/f8fff33a6a94d1932d9d21df946ee62702ba6690))
|
|
23
|
+
- **useSortableTable:** apply focus styling for sortable HeaderCells ([cf481eb](https://bitbucket.org/enturas/design-system/commits/cf481eb8528c056e3e07ab8e37b94e374d1ca5d7))
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
- **usesortabletable:** add buttonProps to getSortableeHeaderProps ([a5f3d48](https://bitbucket.org/enturas/design-system/commits/a5f3d48518f2ab729a91df0c58e367279fbdaa69))
|
|
28
|
+
|
|
6
29
|
## [4.4.1](https://bitbucket.org/enturas/design-system/compare/@entur/table@4.4.0...@entur/table@4.4.1) (2021-10-25)
|
|
7
30
|
|
|
8
31
|
### Bug Fixes
|
package/dist/HeaderCell.d.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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>>;
|
package/dist/styles.css
CHANGED
|
@@ -162,33 +162,12 @@
|
|
|
162
162
|
position: absolute;
|
|
163
163
|
top: 0.75rem;
|
|
164
164
|
margin-left: 0.25rem;
|
|
165
|
-
}/* DO NOT CHANGE!*/
|
|
166
|
-
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
167
|
-
.eds-expand-row-button {
|
|
168
|
-
background: #ffffff;
|
|
169
|
-
border: none;
|
|
170
|
-
border-radius: 50%;
|
|
171
|
-
font-family: inherit;
|
|
172
|
-
cursor: pointer;
|
|
173
|
-
height: 1.5rem;
|
|
174
|
-
width: 1.5rem;
|
|
175
|
-
padding: 0.25rem;
|
|
176
165
|
}
|
|
177
|
-
.eds-
|
|
178
|
-
outline:
|
|
179
|
-
box-shadow: 0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #181c56;
|
|
180
|
-
}
|
|
181
|
-
.eds-contrast .eds-expand-row-button:focus {
|
|
182
|
-
box-shadow: 0 0 0 0.125rem #181c56, 0 0 0 0.25rem #ffffff;
|
|
183
|
-
}
|
|
184
|
-
.eds-contrast .eds-expand-row-button {
|
|
185
|
-
background: #181c56;
|
|
186
|
-
}
|
|
187
|
-
.eds-expand-row-button--open .eds-expand-row-button__icon {
|
|
188
|
-
transform: rotate(90deg);
|
|
166
|
+
.eds-table__header-cell-button:focus {
|
|
167
|
+
outline: 2px solid #181c56;
|
|
189
168
|
}
|
|
190
|
-
.eds-
|
|
191
|
-
|
|
169
|
+
.eds-contrast .eds-table__header-cell-button:focus {
|
|
170
|
+
outline: 2px solid #ffffff;
|
|
192
171
|
}/* DO NOT CHANGE!*/
|
|
193
172
|
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
194
173
|
.eds-editable-cell {
|
|
@@ -281,4 +260,31 @@
|
|
|
281
260
|
}
|
|
282
261
|
.eds-table--small .eds-editable-cell .eds-form-control-wrapper .eds-form-control {
|
|
283
262
|
padding: calc(0.25rem - 0.125rem) calc(0.5rem - 0.0625rem);
|
|
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;
|
|
284
290
|
}
|
|
@@ -138,21 +138,21 @@ var DataCell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
138
138
|
var HeaderCell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
139
139
|
var className = _ref.className,
|
|
140
140
|
children = _ref.children,
|
|
141
|
-
onClick = _ref.onClick,
|
|
142
141
|
name = _ref.name,
|
|
143
142
|
_ref$sortable = _ref.sortable,
|
|
144
143
|
sortable = _ref$sortable === void 0 ? false : _ref$sortable,
|
|
145
144
|
sortConfig = _ref.sortConfig,
|
|
146
145
|
_ref$padding = _ref.padding,
|
|
147
146
|
padding = _ref$padding === void 0 ? 'default' : _ref$padding,
|
|
148
|
-
|
|
147
|
+
sortableButtonProps = _ref.sortableButtonProps,
|
|
148
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["className", "children", "name", "sortable", "sortConfig", "padding", "sortableButtonProps"]);
|
|
149
149
|
|
|
150
150
|
var _React$useState = React__default.useState(false),
|
|
151
151
|
isCurrentlySorted = _React$useState[0],
|
|
152
152
|
setIsCurrentlySorted = _React$useState[1];
|
|
153
153
|
|
|
154
154
|
React__default.useEffect(function () {
|
|
155
|
-
setIsCurrentlySorted(sortConfig && name === sortConfig.key);
|
|
155
|
+
sortConfig && name && setIsCurrentlySorted(sortConfig && name === sortConfig.key);
|
|
156
156
|
}, [sortConfig, name]);
|
|
157
157
|
var ariaSort = isCurrentlySorted ? sortConfig && sortConfig.order : 'none';
|
|
158
158
|
return React__default.createElement("th", Object.assign({
|
|
@@ -164,18 +164,33 @@ var HeaderCell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
164
164
|
}),
|
|
165
165
|
"aria-sort": ariaSort,
|
|
166
166
|
ref: ref
|
|
167
|
-
}, rest), sortable ? React__default.createElement(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}, children
|
|
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, {
|
|
172
187
|
size: "16px",
|
|
173
188
|
className: "eds-table__header-cell-button-icon"
|
|
174
189
|
}), isCurrentlySorted && sortConfig.order === 'descending' && React__default.createElement(icons.DownArrowIcon, {
|
|
175
190
|
size: "16px",
|
|
176
191
|
className: "eds-table__header-cell-button-icon"
|
|
177
|
-
}))
|
|
178
|
-
}
|
|
192
|
+
}));
|
|
193
|
+
};
|
|
179
194
|
|
|
180
195
|
function useSortableData(rawData, externalSortConfig) {
|
|
181
196
|
if (externalSortConfig === void 0) {
|
|
@@ -231,15 +246,18 @@ function useSortableData(rawData, externalSortConfig) {
|
|
|
231
246
|
var name = _ref.name,
|
|
232
247
|
_ref$sortable = _ref.sortable,
|
|
233
248
|
sortable = _ref$sortable === void 0 ? true : _ref$sortable,
|
|
234
|
-
|
|
249
|
+
buttonProps = _ref.buttonProps,
|
|
250
|
+
props = _objectWithoutPropertiesLoose(_ref, ["name", "sortable", "buttonProps"]);
|
|
235
251
|
|
|
236
252
|
return _extends({
|
|
237
253
|
name: name,
|
|
238
254
|
sortable: sortable,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
255
|
+
sortConfig: sortConfig,
|
|
256
|
+
sortableButtonProps: _extends({
|
|
257
|
+
onClick: function onClick() {
|
|
258
|
+
return onSortRequested(name);
|
|
259
|
+
}
|
|
260
|
+
}, buttonProps)
|
|
243
261
|
}, props);
|
|
244
262
|
}
|
|
245
263
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.cjs.development.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n [key: string]: any;\n};\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableHeaderCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n onClick,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\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 ? (\n <button\n className=\"eds-table__header-cell-button\"\n type=\"button\"\n onClick={onClick}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n onClick: () => onSortRequested(name),\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n onClick: () => void;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","onClick","name","sortConfig","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","type","UpArrowIcon","size","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","RightArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,KAAK,gBAAGC,cAAK,CAACC,UAAN,CACnB,gB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MC,WAAW,GAAG5F,cAAK,CAACgF,MAAN,CAAkC,IAAlC,CAApB;AAEA,QAAIa,QAAQ,GAAG,CAAC,CAAhB;AACAF,IAAAA,GAAG,KAAKrB,UAAR,GAAsBuB,QAAQ,GAAG,CAAjC,GAAsCzE,SAAtC;;uCARGb;AAAAA,MAAAA;;;AASH;AACEsF,MAAAA,QAAQ,EAARA,QADF;AAEE3F,MAAAA,GAAG,EAAE0F,WAFP;AAGErE,MAAAA,OAAO,EAAE;AAAA,eAAMsD,aAAa,CAACc,GAAD,CAAnB;AAAA,OAHX;AAIEG,MAAAA,SAAS,EAAE,mBAACC,CAAD;AACT,YAAMC,OAAO,GAAG5B,eAAe,CAAC2B,CAAD,EAAIzB,UAAJ,EAAgBM,YAAhB,EAA8BJ,SAA9B,CAA/B;AACAK,QAAAA,aAAa,CAACmB,OAAD,CAAb;AACD;AAPH,OAQKzF,IARL;AAUD;;AACD,SAAO;AAAEmF,IAAAA,0BAA0B,EAA1BA,0BAAF;AAA8BD,IAAAA,2BAA2B,EAA3BA;AAA9B,GAAP;AACD,CAjDM;;AC1CPQ,4BAAsB,CAAC,OAAD,CAAtB;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"table.cjs.development.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\nimport { ExternalSortConfig } from '.';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","type","UpArrowIcon","size","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","RightArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;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D,CAjDM;;AC1CPQ,4BAAsB,CAAC,OAAD,CAAtB;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@entur/utils"),t=require("react"),a=e(t),n=e(require("classnames")),o=require("@entur/icons"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@entur/utils"),t=require("react"),a=e(t),n=e(require("classnames")),o=require("@entur/icons"),s=e(require("lodash.get")),l=require("@entur/form"),d=require("@entur/tooltip"),c=require("@entur/expand");function i(){return(i=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}function u(e,r){if(null==e)return{};var t,a,n={},o=Object.keys(e);for(a=0;a<o.length;a++)r.indexOf(t=o[a])>=0||(n[t]=e[t]);return n}var b=a.forwardRef((function(e,r){var t=e.className,o=e.fixed,s=void 0!==o&&o,l=e.spacing,d=void 0===l?"default":l,c=e.sortable,i=void 0!==c&&c,b=u(e,["className","fixed","spacing","sortable"]);return a.createElement("table",Object.assign({className:n("eds-table",{"eds-table--fixed":s},{"eds-table--middle":"middle"===d},{"eds-table--small":"small"===d},{"eds-table--sortable":i},t),ref:r},b))})),f=a.forwardRef((function(e,r){var t=e.className,o=u(e,["className"]);return a.createElement("thead",Object.assign({className:n("eds-table__head",t),ref:r},o))})),v=a.forwardRef((function(e,r){var t=e.className,o=u(e,["className"]);return a.createElement("tbody",Object.assign({className:n("eds-table__body",t),ref:r},o))})),m=a.forwardRef((function(e,r){var t=i({},e);return a.createElement("tfoot",Object.assign({ref:r},t))})),p=a.forwardRef((function(e,r){var t=e.className,o=e.hover,s=void 0!==o&&o,l=e.active,d=void 0!==l&&l,c=e.error,i=void 0!==c&&c,b=u(e,["className","hover","active","error"]);return a.createElement("tr",Object.assign({className:n("eds-table__row",t,{"eds-table__row--hover":s,"eds-table__row--active":d,"eds-table__row--error":i}),ref:r},b))})),g=a.forwardRef((function(e,r){var t,o=e.className,s=e.padding,l=void 0===s?"default":s,d=e.status,c=void 0===d?void 0:d,i=u(e,["className","padding","status"]);return a.createElement("td",Object.assign({ref:r,className:n("eds-table__data-cell",o,(t={},t["eds-table__data-cell--status-"+c]=c,t["eds-table__data-cell--padding-checkbox"]="checkbox"===l,t["eds-table__data-cell--padding-radio"]="radio"===l,t["eds-table__data-cell--padding-overflow-menu"]="overflow-menu"===l,t))},i))})),_=a.forwardRef((function(e,r){var t=e.className,o=e.children,s=e.name,l=e.sortable,d=void 0!==l&&l,c=e.sortConfig,i=e.padding,b=void 0===i?"default":i,f=e.sortableButtonProps,v=u(e,["className","children","name","sortable","sortConfig","padding","sortableButtonProps"]),m=a.useState(!1),p=m[0],g=m[1];a.useEffect((function(){c&&s&&g(c&&s===c.key)}),[c,s]);var _=p?c&&c.order:"none";return a.createElement("th",Object.assign({className:n("eds-table__header-cell",t,{"eds-table__header-cell--sortable":d,"eds-table__header-cell--padding-radio":"radio"===b,"eds-table__header-cell--padding-checkbox":"checkbox"===b,"eds-table__header-cell--padding-overflow-menu":"overflow-menu"===b}),"aria-sort":_,ref:r},v),d&&c&&f?a.createElement(h,{sortableButtonProps:f,sortConfig:c,isCurrentlySorted:p},o):o)})),h=function(e){var r=e.sortConfig,t=e.sortableButtonProps,s=e.isCurrentlySorted,l=e.children,d=t.className,c=u(t,["className"]);return a.createElement("button",Object.assign({className:n("eds-table__header-cell-button",d),type:"button"},c),l,s&&"ascending"===r.order&&a.createElement(o.UpArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon"}),s&&"descending"===r.order&&a.createElement(o.DownArrowIcon,{size:"16px",className:"eds-table__header-cell-button-icon"}))};function w(e,r,t,a){switch(e.key){case"ArrowUp":return e.preventDefault(),a?0===r?t-1:r-1:r>0?r-1:0;case"ArrowDown":return e.preventDefault(),a?r===t-1?0:r+1:r<t-1?r+1:r;default:return r}}r.warnAboutMissingStyles("table"),exports.DataCell=g,exports.EditableCell=function(e){var r=e.children,t=e.className,o=e.feedback,s=e.variant,c=e.outlined,i=void 0!==c&&c,b=u(e,["children","className","feedback","variant","outlined"]);return a.createElement(l.VariantProvider,{variant:s},a.createElement(g,Object.assign({className:n("eds-editable-cell",{"eds-editable-cell--outlined":i},t)},b),a.createElement(d.Tooltip,{disableHoverListener:!o,disableFocusListener:!o,placement:"bottom",content:o||void 0,variant:o?"error":void 0},r)))},exports.ExpandRowButton=function(e){var r=e.open,t=e.onClick,s=u(e,["open","onClick"]);return a.createElement("button",Object.assign({className:n("eds-expand-row-button",{"eds-expand-row-button--open":r}),onClick:t},s),a.createElement(o.RightArrowIcon,{className:"eds-expand-row-button__icon"}))},exports.ExpandableRow=function(e){var r=e.open;return a.createElement("tr",null,a.createElement("td",{colSpan:e.colSpan},a.createElement(c.BaseExpand,{open:void 0!==r&&r},e.children)))},exports.HeaderCell=_,exports.Table=b,exports.TableBody=v,exports.TableFooter=m,exports.TableHead=f,exports.TableRow=p,exports.useSortableData=function(e,r){void 0===r&&(r={key:"",order:"none"});var t=a.useState(r),n=t[0],o=t[1],l=e.slice();return a.useEffect((function(){o({key:r.key,order:r.order})}),[r.key,r.order]),{sortedData:a.useMemo((function(){return"none"===n.order?l:[].concat(e).sort((function(e,r){return s(e,n.key)<s(r,n.key)?"ascending"===n.order?-1:1:s(e,n.key)>s(r,n.key)?"ascending"===n.order?1:-1:0}))}),[e,l,n]),getSortableHeaderProps:function(e){var r=e.name,t=e.sortable,a=void 0===t||t,s=e.buttonProps,l=u(e,["name","sortable","buttonProps"]);return i({name:r,sortable:a,sortConfig:n,sortableButtonProps:i({onClick:function(){return t="ascending",n.key===(e=r)&&"ascending"===n.order?t="descending":n.key===e&&"descending"===n.order&&(t="none"),void o({key:e,order:t});var e,t}},s)},l)},getSortableTableProps:function(e){var r=e.sortable,t=void 0===r||r,a=u(e,["sortable"]);return i({sortable:t,sortConfig:n},a)}}},exports.useTableKeyboardNavigation=function(e,r){var n;void 0===e&&(e=0),void 0===r&&(r=!0);var o=t.useState(e),s=o[0],l=o[1],d=t.useState(0),c=d[0],u=d[1],b=a.useRef(null),f=null==b||null===(n=b.current)||void 0===n?void 0:n.contains(document.activeElement);return a.useEffect((function(){var e;b&&b.current&&f&&(null===(e=b.current.childNodes[s].childNodes[0].parentElement)||void 0===e||e.focus())}),[s]),{getTableRowNavigationProps:function(t){a.useEffect((function(){t>=c&&u(t+1)}),[]);var n=a.useRef(null),o=-1;t===s&&(o=0);for(var d=arguments.length,b=new Array(d>1?d-1:0),f=1;f<d;f++)b[f-1]=arguments[f];return i({tabIndex:o,ref:n,onClick:function(){return l(t)},onKeyDown:function(t){var a=w(t,s,e,r);l(a)}},b)},getTableBodyNavigationProps:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return i({ref:b},r)}}};
|
|
2
2
|
//# sourceMappingURL=table.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.cjs.production.min.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx","../src/EditableCell.tsx","../src/ExpandRowButton.tsx","../src/ExpandableRow.tsx","../src/useSortableTable.ts"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n [key: string]: any;\n};\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableHeaderCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n onClick,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\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 ? (\n <button\n className=\"eds-table__header-cell-button\"\n type=\"button\"\n onClick={onClick}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n onClick: () => onSortRequested(name),\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n onClick: () => void;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","onClick","name","sortConfig","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","type","UpArrowIcon","size","DownArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","preventDefault","warnAboutMissingStyles","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","open","RightArrowIcon","colSpan","BaseExpand","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","getSortableHeaderProps","getSortableTableProps","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","_tableBodyRef$current","contains","document","activeElement","childNodes","parentElement","_tableBodyRef$current2","focus","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","getTableBodyNavigationProps"],"mappings":"yrBAkBaA,EAAQC,EAAMC,YACzB,WAQEC,OANEC,IAAAA,cACAC,MAAAA,oBACAC,QAAAA,aAAU,gBACVC,SAAAA,gBACGC,yDAKHP,uCACEG,UAAWK,EACT,YACA,oBAAsBJ,GACtB,qBAAmC,WAAZC,GACvB,oBAAkC,UAAZA,GACtB,uBAAyBC,GACzBH,GAEFD,IAAKA,GACDK,OC3BCE,EAAYT,EAAMC,YAG7B,WAA0BC,OAAvBC,IAAAA,UAAcO,4BACjBV,uCACEG,UAAWK,EAAW,kBAAmBL,GACzCD,IAAKA,GACDQ,OCNKC,EAAYX,EAAMC,YAG7B,WAAyBC,OAAtBC,IAAAA,UAAcI,4BACjBP,uCACEG,UAAWK,EAAW,kBAAmBL,GACzCD,IAAKA,GACDK,OCXKK,EAAcZ,EAAMC,YAG/B,WAAeC,OAATQ,iBAAiBV,uCAAOE,IAAKA,GAASQ,OCajCG,EAAWb,EAAMC,YAC5B,WAEEC,OADEC,IAAAA,cAAWW,MAAAA,oBAAeC,OAAAA,oBAAgBC,MAAAA,gBAAkBT,qDAG9DP,oCACEG,UAAWK,EAAW,iBAAkBL,EAAW,yBACxBW,2BACCC,0BACDC,IAE3Bd,IAAKA,GACDK,OCrBGU,EAAWjB,EAAMC,YAI5B,WAEEC,SADEC,IAAAA,cAAWe,QAAAA,aAAU,gBAAWC,OAAAA,kBAASC,IAAcb,+CAGzDP,oCACEE,IAAKA,EACLC,UAAWK,EAAW,uBAAwBL,0CACXgB,GAAWA,IAC5C,0CAAsD,aAAZD,IAC1C,uCAAmD,UAAZA,IACvC,+CACc,kBAAZA,OAEAX,OCnBGc,EAAarB,EAAMC,YAI9B,WAWEC,OATEC,IAAAA,UACAmB,IAAAA,SACAC,IAAAA,QACAC,IAAAA,SACAlB,SAAAA,gBACAmB,I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,GAA9Bc,OAAQgC,OAETC,EAAezE,EAAM0E,OAAgC,MACrDC,EAAgBF,MAAAA,aAAAA,EAAcG,4BAAdC,EAAuBC,SAASC,SAASC,sBAE/DhF,EAAM6B,WAAU,iBACd4C,GACEA,EAAaG,SACbD,cACAF,EAAaG,QAAQK,WACnB1C,GACA0C,WAAW,GAAGC,4BAFhBC,EAE+BC,WAChC,CAAC7C,IA+BG,CAAE8C,oCArBPC,GAGAtF,EAAM6B,WAAU,WACdyD,GAAO9C,GAAUgC,EAAUc,EAAM,KAChC,QACGC,EAAcvF,EAAM0E,OAA4B,MAElDc,GAAY,EAChBF,IAAQ/C,IAAciD,EAAW,8BAR9BjF,mCAAAA,8BAUDiF,SAAAA,EACAtF,IAAKqF,EACLhE,QAAS,kBAAMgD,EAAce,IAC7BG,UAAW,SAACC,OACJC,EAAUtD,EAAgBqD,EAAGnD,EAAY+B,EAAc7B,GAC7D8B,EAAcoB,KAEbpF,IAG8BqF,kEA7BGrF,2BAAAA,4BAEpCL,IAAKuE,GACFlE"}
|
|
1
|
+
{"version":3,"file":"table.cjs.production.min.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx","../src/EditableCell.tsx","../src/ExpandRowButton.tsx","../src/ExpandableRow.tsx","../src/useSortableTable.ts"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\nimport { ExternalSortConfig } from '.';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","type","UpArrowIcon","size","DownArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","preventDefault","warnAboutMissingStyles","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","open","onClick","RightArrowIcon","colSpan","BaseExpand","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","getSortableHeaderProps","buttonProps","getSortableTableProps","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","_tableBodyRef$current","contains","document","activeElement","childNodes","parentElement","_tableBodyRef$current2","focus","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","getTableBodyNavigationProps"],"mappings":"yrBAkBaA,EAAQC,EAAMC,YACzB,WAQEC,OANEC,IAAAA,cACAC,MAAAA,oBACAC,QAAAA,aAAU,gBACVC,SAAAA,gBACGC,yDAKHP,uCACEG,UAAWK,EACT,YACA,oB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,SACShD,WAAS,GAA9Be,OAAQkC,OAETC,EAAe5E,EAAM6E,OAAgC,MACrDC,EAAgBF,MAAAA,aAAAA,EAAcG,4BAAdC,EAAuBC,SAASC,SAASC,sBAE/DnF,EAAM6B,WAAU,iBACd+C,GACEA,EAAaG,SACbD,cACAF,EAAaG,QAAQK,WACnB5C,GACA4C,WAAW,GAAGC,4BAFhBC,EAE+BC,WAChC,CAAC/C,IA+BG,CAAEgD,oCArBPC,GAGAzF,EAAM6B,WAAU,WACd4D,GAAOhD,GAAUkC,EAAUc,EAAM,KAChC,QACGC,EAAc1F,EAAM6E,OAA4B,MAElDc,GAAY,EAChBF,IAAQjD,IAAcmD,EAAW,8BAR9BpF,mCAAAA,8BAUDoF,SAAAA,EACAzF,IAAKwF,EACLnC,QAAS,kBAAMmB,EAAce,IAC7BG,UAAW,SAACC,OACJC,EAAUxD,EAAgBuD,EAAGrD,EAAYiC,EAAc/B,GAC7DgC,EAAcoB,KAEbvF,IAG8BwF,kEA7BGxF,2BAAAA,4BAEpCL,IAAK0E,GACFrE"}
|
package/dist/table.esm.js
CHANGED
|
@@ -131,21 +131,21 @@ var DataCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
131
131
|
var HeaderCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
132
132
|
var className = _ref.className,
|
|
133
133
|
children = _ref.children,
|
|
134
|
-
onClick = _ref.onClick,
|
|
135
134
|
name = _ref.name,
|
|
136
135
|
_ref$sortable = _ref.sortable,
|
|
137
136
|
sortable = _ref$sortable === void 0 ? false : _ref$sortable,
|
|
138
137
|
sortConfig = _ref.sortConfig,
|
|
139
138
|
_ref$padding = _ref.padding,
|
|
140
139
|
padding = _ref$padding === void 0 ? 'default' : _ref$padding,
|
|
141
|
-
|
|
140
|
+
sortableButtonProps = _ref.sortableButtonProps,
|
|
141
|
+
rest = _objectWithoutPropertiesLoose(_ref, ["className", "children", "name", "sortable", "sortConfig", "padding", "sortableButtonProps"]);
|
|
142
142
|
|
|
143
143
|
var _React$useState = React.useState(false),
|
|
144
144
|
isCurrentlySorted = _React$useState[0],
|
|
145
145
|
setIsCurrentlySorted = _React$useState[1];
|
|
146
146
|
|
|
147
147
|
React.useEffect(function () {
|
|
148
|
-
setIsCurrentlySorted(sortConfig && name === sortConfig.key);
|
|
148
|
+
sortConfig && name && setIsCurrentlySorted(sortConfig && name === sortConfig.key);
|
|
149
149
|
}, [sortConfig, name]);
|
|
150
150
|
var ariaSort = isCurrentlySorted ? sortConfig && sortConfig.order : 'none';
|
|
151
151
|
return React.createElement("th", Object.assign({
|
|
@@ -157,18 +157,33 @@ var HeaderCell = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
157
157
|
}),
|
|
158
158
|
"aria-sort": ariaSort,
|
|
159
159
|
ref: ref
|
|
160
|
-
}, rest), sortable ? React.createElement(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}, children
|
|
160
|
+
}, rest), sortable && sortConfig && sortableButtonProps ? React.createElement(SortableHeaderCellButton, {
|
|
161
|
+
sortableButtonProps: sortableButtonProps,
|
|
162
|
+
sortConfig: sortConfig,
|
|
163
|
+
isCurrentlySorted: isCurrentlySorted
|
|
164
|
+
}, children) : children);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
var SortableHeaderCellButton = function SortableHeaderCellButton(_ref2) {
|
|
168
|
+
var sortConfig = _ref2.sortConfig,
|
|
169
|
+
sortableButtonProps = _ref2.sortableButtonProps,
|
|
170
|
+
isCurrentlySorted = _ref2.isCurrentlySorted,
|
|
171
|
+
children = _ref2.children;
|
|
172
|
+
|
|
173
|
+
var className = sortableButtonProps.className,
|
|
174
|
+
rest = _objectWithoutPropertiesLoose(sortableButtonProps, ["className"]);
|
|
175
|
+
|
|
176
|
+
return React.createElement("button", Object.assign({
|
|
177
|
+
className: classNames('eds-table__header-cell-button', className),
|
|
178
|
+
type: "button"
|
|
179
|
+
}, rest), children, isCurrentlySorted && sortConfig.order === 'ascending' && React.createElement(UpArrowIcon, {
|
|
165
180
|
size: "16px",
|
|
166
181
|
className: "eds-table__header-cell-button-icon"
|
|
167
182
|
}), isCurrentlySorted && sortConfig.order === 'descending' && React.createElement(DownArrowIcon, {
|
|
168
183
|
size: "16px",
|
|
169
184
|
className: "eds-table__header-cell-button-icon"
|
|
170
|
-
}))
|
|
171
|
-
}
|
|
185
|
+
}));
|
|
186
|
+
};
|
|
172
187
|
|
|
173
188
|
function useSortableData(rawData, externalSortConfig) {
|
|
174
189
|
if (externalSortConfig === void 0) {
|
|
@@ -224,15 +239,18 @@ function useSortableData(rawData, externalSortConfig) {
|
|
|
224
239
|
var name = _ref.name,
|
|
225
240
|
_ref$sortable = _ref.sortable,
|
|
226
241
|
sortable = _ref$sortable === void 0 ? true : _ref$sortable,
|
|
227
|
-
|
|
242
|
+
buttonProps = _ref.buttonProps,
|
|
243
|
+
props = _objectWithoutPropertiesLoose(_ref, ["name", "sortable", "buttonProps"]);
|
|
228
244
|
|
|
229
245
|
return _extends({
|
|
230
246
|
name: name,
|
|
231
247
|
sortable: sortable,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
248
|
+
sortConfig: sortConfig,
|
|
249
|
+
sortableButtonProps: _extends({
|
|
250
|
+
onClick: function onClick() {
|
|
251
|
+
return onSortRequested(name);
|
|
252
|
+
}
|
|
253
|
+
}, buttonProps)
|
|
236
254
|
}, props);
|
|
237
255
|
}
|
|
238
256
|
|
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.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n [key: string]: any;\n};\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableHeaderCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n onClick,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\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 ? (\n <button\n className=\"eds-table__header-cell-button\"\n type=\"button\"\n onClick={onClick}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n onClick: () => onSortRequested(name),\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n onClick: () => void;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","onClick","name","sortConfig","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","type","UpArrowIcon","size","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","RightArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,KAAK,gBAAGC,KAAK,CAACC,UAAN,CACnB,gBAQEC,GARF;MAEIC,iBAAAA;wBACAC;MAAAA,gCAAQ;0BACRC;MAAAA,oCAAU;2BACVC;MAAAA,sCAAW;MACRC;;AAIL,SACEP,mBAAA,QAAA;AACEG,IAAAA,SAAS,EAAEK,UAAU,CACnB,WADmB,EAEnB;AAAE,0BAAoBJ;AAAtB,KAFmB,EAGnB;AAAE,2BAAqBC,OAAO,KAAK;AAAnC,KAHmB,EAInB;AAAE,0BAAoBA,OAAO,KAAK;AAAlC,KAJmB,EAKnB;AAAE,6BAAuBC;AAAzB,KALmB,EAMnBH,SANmB;AAQrBD,IAAAA,GAAG,EAAEA;KACDK,KAVN,CADF;AAcD,CAzBkB;;ICLRE,SAAS,gBAAGT,KAAK,CAACC,UAAN,CAGvB,gBAA0BC,GAA1B;AAAA,MAAGC,SAAH,QAAGA,SAAH;AAAA,MAAiBO,KAAjB;;AAAA,SACAV,mBAAA,QAAA;AACEG,IAAAA,SAAS,EAAEK,UAAU,CAAC,iBAAD,EAAoBL,SAApB;AACrBD,IAAAA,GAAG,EAAEA;KACDQ,MAHN,CADA;AAAA,CAHuB,CAAlB;;ICCMC,SAAS,gBAAG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;;"}
|
|
1
|
+
{"version":3,"file":"table.esm.js","sources":["../src/Table.tsx","../src/TableHead.tsx","../src/TableBody.tsx","../src/TableFooter.tsx","../src/TableRow.tsx","../src/DataCell.tsx","../src/HeaderCell.tsx","../src/useSortableTable.ts","../src/EditableCell.tsx","../src/ExpandableRow.tsx","../src/ExpandRowButton.tsx","../src/useTableKeyboardNavigation.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Setter tettheten mellom rader og kolonner. Bruk gjerne middle og small for for sider med høy informasjonstetthet\n * @default \"default\"\n */\n spacing?: 'default' | 'middle' | 'small';\n /** Setter kolonne-layout til å være uavhengig av innhold\n * @default false\n */\n fixed?: boolean;\n /** Innholdet i tabellen */\n children: React.ReactNode;\n [key: string]: any;\n};\nexport const Table = React.forwardRef<HTMLTableElement, TableProps>(\n (\n {\n className,\n fixed = false,\n spacing = 'default',\n sortable = false,\n ...rest\n },\n ref,\n ) => {\n return (\n <table\n className={classNames(\n 'eds-table',\n { 'eds-table--fixed': fixed },\n { 'eds-table--middle': spacing === 'middle' },\n { 'eds-table--small': spacing === 'small' },\n { 'eds-table--sortable': sortable },\n className,\n )}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableHeadProps = {\n /** Kolonneoverskrifter */\n children: React.ReactNode;\n /** Esktra klassenavn */\n className?: string;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableHead = React.forwardRef<\n HTMLTableSectionElement,\n TableHeadProps\n>(({ className, ...props }, ref) => (\n <thead\n className={classNames('eds-table__head', className)}\n ref={ref}\n {...props}\n />\n));\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableBodyProps = {\n /** Tabellrader */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n ref?: React.Ref<HTMLTableSectionElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableBody = React.forwardRef<\n HTMLTableSectionElement,\n TableBodyProps\n>(({ className, ...rest }, ref) => (\n <tbody\n className={classNames('eds-table__body', className)}\n ref={ref}\n {...rest}\n />\n));\n","import React from 'react';\n\nexport type TableFooterProps = {\n /** Tabellrader */\n children: React.ReactNode;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableSectionElement>,\n HTMLTableSectionElement\n>;\n\nexport const TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n TableFooterProps\n>(({ ...props }, ref) => <tfoot ref={ref} {...props} />);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type TableRowProps = {\n /** Tabellceller */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /**Hvis satt, så vil tabellraden endre fargen ved hover\n * @default false\n */\n hover?: boolean;\n /** Om raden er klikkbar, så vil raden endre farge, og musepekeren vil symbolisere interaktivitet\n * @default false\n */\n active?: boolean;\n /**Signalisere om at det er en feil i tabellraden\n * @default false\n */\n error?: boolean;\n ref?: React.Ref<HTMLTableRowElement>;\n} & React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLTableRowElement>,\n HTMLTableRowElement\n>;\n\nexport const TableRow = React.forwardRef<HTMLTableRowElement, TableRowProps>(\n (\n { className, hover = false, active = false, error = false, ...rest },\n ref: React.Ref<HTMLTableRowElement>,\n ) => (\n <tr\n className={classNames('eds-table__row', className, {\n 'eds-table__row--hover': hover,\n 'eds-table__row--active': active,\n 'eds-table__row--error': error,\n })}\n ref={ref}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\n\nexport type DataCellProps = {\n /** Innholdet i tabellcellen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for DataCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n /** Viser en status-sirkel for DataCell */\n status?: 'positive' | 'negative' | 'neutral';\n} & React.DetailedHTMLProps<\n React.TdHTMLAttributes<HTMLTableDataCellElement>,\n HTMLTableDataCellElement\n>;\n\nexport const DataCell = React.forwardRef<\n HTMLTableDataCellElement,\n DataCellProps\n>(\n (\n { className, padding = 'default', status = undefined, ...rest },\n ref: React.Ref<HTMLTableDataCellElement>,\n ) => (\n <td\n ref={ref}\n className={classNames('eds-table__data-cell', className, {\n [`eds-table__data-cell--status-${status}`]: status,\n 'eds-table__data-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__data-cell--padding-radio': padding === 'radio',\n 'eds-table__data-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n {...rest}\n />\n ),\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { DownArrowIcon, UpArrowIcon } from '@entur/icons';\nimport './HeaderCell.scss';\nimport { ExternalSortConfig } from '.';\n\nexport type HeaderCellProps = {\n /** Kolonneoverskrift */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Størrelse som settes for HeaderCell for ulikt innhold av komponenter */\n padding?: 'default' | 'checkbox' | 'radio' | 'overflow-menu';\n\n /** Ekstra props som kan sendes til sorteringsknappelementet. Benyttes via useSortableTable */\n sortableButtonProps?: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n\n /** Om komponenten brukes til sortering. Benytt via useSortableTable\n * @default false\n */\n sortable?: boolean;\n /** Konfigurering og rekkefølgen på sortering. Benyttes via useSortableTable */\n sortConfig?: ExternalSortConfig;\n /** Navnet det skal sorteres på. Benyttes via useSortableTable */\n name?: string;\n} & React.DetailedHTMLProps<\n React.ThHTMLAttributes<HTMLTableCellElement>,\n HTMLTableCellElement\n>;\n\nexport const HeaderCell = React.forwardRef<\n HTMLTableCellElement,\n HeaderCellProps\n>(\n (\n {\n className,\n children,\n name,\n sortable = false,\n sortConfig,\n padding = 'default',\n sortableButtonProps,\n ...rest\n },\n ref,\n ) => {\n const [isCurrentlySorted, setIsCurrentlySorted] =\n React.useState<boolean>(false);\n React.useEffect(() => {\n sortConfig &&\n name &&\n setIsCurrentlySorted(sortConfig && name === sortConfig.key);\n }, [sortConfig, name]);\n const ariaSort = isCurrentlySorted\n ? sortConfig && sortConfig.order\n : 'none';\n\n return (\n <th\n className={classNames('eds-table__header-cell', className, {\n 'eds-table__header-cell--sortable': sortable,\n 'eds-table__header-cell--padding-radio': padding === 'radio',\n 'eds-table__header-cell--padding-checkbox': padding === 'checkbox',\n 'eds-table__header-cell--padding-overflow-menu':\n padding === 'overflow-menu',\n })}\n aria-sort={ariaSort}\n ref={ref}\n {...rest}\n >\n {sortable && sortConfig && sortableButtonProps ? (\n <SortableHeaderCellButton\n sortableButtonProps={sortableButtonProps}\n sortConfig={sortConfig}\n isCurrentlySorted={isCurrentlySorted}\n >\n {children}\n </SortableHeaderCellButton>\n ) : (\n children\n )}\n </th>\n );\n },\n);\n\ntype SortableHeaderCellButtonProps = {\n sortConfig: ExternalSortConfig;\n isCurrentlySorted: boolean;\n sortableButtonProps: React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >;\n};\n\nconst SortableHeaderCellButton: React.FC<SortableHeaderCellButtonProps> = ({\n sortConfig,\n sortableButtonProps,\n isCurrentlySorted,\n children,\n}) => {\n const { className, ...rest } = sortableButtonProps;\n return (\n <button\n className={classNames('eds-table__header-cell-button', className)}\n type=\"button\"\n {...rest}\n >\n {children}\n {isCurrentlySorted && sortConfig.order === 'ascending' && (\n <UpArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n {isCurrentlySorted && sortConfig.order === 'descending' && (\n <DownArrowIcon\n size=\"16px\"\n className=\"eds-table__header-cell-button-icon\"\n />\n )}\n </button>\n );\n};\n","import React from 'react';\nimport get from 'lodash.get';\n\nexport type ExternalSortConfig = {\n /**\n * @default \"\"\n */\n key: string;\n /** @default \"none\" */\n order: 'ascending' | 'descending' | 'none';\n};\n\nexport function useSortableData<T>(\n rawData: T[],\n externalSortConfig: ExternalSortConfig = { key: '', order: 'none' },\n): {\n sortedData: T[];\n getSortableHeaderProps: (\n args: SortableHeaderProps,\n ) => SortableHeaderReturnProps;\n getSortableTableProps: (args: SortableTableProps) => SortableTableReturnProps;\n} {\n const [sortConfig, setSortConfig] = React.useState(externalSortConfig);\n const tableCopy = rawData.slice();\n\n React.useEffect(() => {\n setSortConfig({\n key: externalSortConfig.key,\n order: externalSortConfig.order,\n });\n }, [externalSortConfig.key, externalSortConfig.order]);\n\n const sortedData: T[] = React.useMemo(() => {\n if (sortConfig.order === 'none') {\n return tableCopy;\n }\n return [...rawData].sort((a: any, b: any) => {\n if (get(a, sortConfig.key) < get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? -1 : 1;\n } else if (get(a, sortConfig.key) > get(b, sortConfig.key)) {\n return sortConfig.order === 'ascending' ? 1 : -1;\n } else {\n return 0;\n }\n });\n }, [rawData, tableCopy, sortConfig]);\n\n const onSortRequested = (key: string) => {\n let order: 'ascending' | 'descending' | 'none' = 'ascending';\n if (sortConfig.key === key && sortConfig.order === 'ascending') {\n order = 'descending';\n } else if (sortConfig.key === key && sortConfig.order === 'descending') {\n order = 'none';\n }\n\n setSortConfig({ key, order });\n };\n\n function getSortableHeaderProps({\n name,\n sortable = true,\n buttonProps,\n ...props\n }: SortableHeaderProps): SortableHeaderReturnProps {\n return {\n name,\n sortable,\n sortConfig: sortConfig,\n sortableButtonProps: {\n onClick: () => onSortRequested(name),\n ...buttonProps,\n },\n ...props,\n };\n }\n\n function getSortableTableProps({\n sortable = true,\n ...props\n }: SortableTableProps): SortableTableReturnProps {\n return {\n sortable,\n sortConfig: sortConfig,\n ...props,\n };\n }\n\n return { sortedData, getSortableHeaderProps, getSortableTableProps };\n}\n\nexport type SortableHeaderProps = {\n /** Navnet headeren skal se etter i forhold til sortering av items */\n name: string;\n /** Om headeren skal være sorterbar eller ikke\n * @default true */\n sortable?: boolean;\n /** Props som sendes til knapp-elementet */\n buttonProps?: Omit<\n React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n >,\n 'type' | 'onClick'\n >;\n [key: string]: any;\n};\n\nexport type SortableHeaderReturnProps = {\n name: string;\n sortable: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n\nexport type SortableTableProps = {\n /** @default true */\n sortable?: boolean;\n [key: string]: any;\n};\n\nexport type SortableTableReturnProps = {\n /** @default true */\n sortable?: boolean;\n sortConfig: ExternalSortConfig;\n [key: string]: any;\n};\n","import classNames from 'classnames';\nimport React from 'react';\nimport { DataCell } from './DataCell';\nimport { VariantProvider, VariantType } from '@entur/form';\nimport { Tooltip } from '@entur/tooltip';\nimport './EditableCell.scss';\n\ntype EditableCellProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Inputelementet som skal være i tabellcellen */\n children: React.ReactElement;\n /** Valideringsvariant for EditableCell */\n variant?: VariantType;\n /** Varselmelding, som vil komme som en Tooltip under EditableCell */\n feedback?: string;\n /** Om cellen skal vise omriss til enhver tid\n * @default false\n */\n outlined?: boolean;\n [key: string]: any;\n};\n\nexport const EditableCell: React.FC<EditableCellProps> = ({\n children,\n className,\n feedback,\n variant,\n outlined = false,\n ...rest\n}) => {\n return (\n <VariantProvider variant={variant}>\n <DataCell\n className={classNames(\n 'eds-editable-cell',\n {\n 'eds-editable-cell--outlined': outlined,\n },\n className,\n )}\n {...rest}\n >\n <Tooltip\n disableHoverListener={!feedback}\n disableFocusListener={!feedback}\n placement=\"bottom\"\n content={feedback || undefined}\n variant={feedback ? 'error' : undefined}\n >\n {children}\n </Tooltip>\n </DataCell>\n </VariantProvider>\n );\n};\n","import React from 'react';\nimport { BaseExpand } from '@entur/expand';\n\nexport type ExpandableRowProps = {\n /** Antall kolonner tabellraden er */\n colSpan: number;\n /** Innholdet til ExpandableRow */\n children: React.ReactNode;\n /** Om ExpandableRow er åpen\n * @default false\n */\n open?: boolean;\n};\n\nexport const ExpandableRow: React.FC<ExpandableRowProps> = ({\n open = false,\n children,\n colSpan,\n}) => {\n return (\n <tr>\n <td colSpan={colSpan}>\n <BaseExpand open={open}>{children}</BaseExpand>\n </td>\n </tr>\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport { RightArrowIcon } from '@entur/icons';\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 <button\n className={classNames('eds-expand-row-button', {\n 'eds-expand-row-button--open': open,\n })}\n onClick={onClick}\n {...rest}\n >\n <RightArrowIcon className=\"eds-expand-row-button__icon\" />\n </button>\n );\n};\n","import React, { useState } from 'react';\nimport { TableBodyProps, TableRowProps } from './index';\n\nfunction onTableKeypress(\n event: React.KeyboardEvent,\n currentRow: number,\n maxRow: number,\n allowWrap?: boolean,\n) {\n const keyPress = event.key;\n switch (keyPress) {\n case 'ArrowUp':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === 0 ? maxRow - 1 : currentRow - 1;\n } else {\n return currentRow > 0 ? currentRow - 1 : 0;\n }\n case 'ArrowDown':\n event.preventDefault();\n if (allowWrap) {\n return currentRow === maxRow - 1 ? 0 : currentRow + 1;\n } else {\n return currentRow < maxRow - 1 ? currentRow + 1 : currentRow;\n }\n default:\n return currentRow;\n }\n}\n\nexport type useTableKeyboardNavigationProps = (\n /** Antall rader i tabellen */\n numberOfRows: number,\n /** Tillate at man kan navigere sirkulært\n * @default false\n */\n allowWrap?: boolean,\n) => {\n getTableRowNavigationProps: (\n /** Raden i tabellen (0-indeksert) */\n row: number,\n ) => Partial<TableRowProps>;\n getTableBodyNavigationProps: () => Partial<TableBodyProps>;\n};\n\nexport const useTableKeyboardNavigation: useTableKeyboardNavigationProps = (\n numberOfRows = 0,\n allowWrap = true,\n) => {\n const [currentRow, setCurrentRow] = useState(numberOfRows);\n const [maxRow, setMaxRow] = useState(0);\n\n const tableBodyRef = React.useRef<HTMLTableSectionElement>(null);\n const tableHasFocus = tableBodyRef?.current?.contains(document.activeElement);\n\n React.useEffect(() => {\n tableBodyRef &&\n tableBodyRef.current &&\n tableHasFocus &&\n tableBodyRef.current.childNodes[\n currentRow\n ].childNodes[0].parentElement?.focus();\n }, [currentRow]);\n\n function getTableBodyNavigationProps(...rest: any): Partial<TableBodyProps> {\n return {\n ref: tableBodyRef,\n ...rest,\n };\n }\n\n function getTableRowNavigationProps(\n row: number,\n ...rest: any\n ): Partial<TableRowProps> {\n React.useEffect(() => {\n row >= maxRow && setMaxRow(row + 1);\n }, []);\n const tableRowRef = React.useRef<HTMLTableRowElement>(null);\n\n let tabIndex = -1;\n row === currentRow ? (tabIndex = 0) : undefined;\n return {\n tabIndex,\n ref: tableRowRef,\n onClick: () => setCurrentRow(row),\n onKeyDown: (e: React.KeyboardEvent) => {\n const newCell = onTableKeypress(e, currentRow, numberOfRows, allowWrap);\n setCurrentRow(newCell);\n },\n ...rest,\n };\n }\n return { getTableRowNavigationProps, getTableBodyNavigationProps };\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('table');\n\nexport * from './Table';\nexport * from './TableHead';\nexport * from './TableBody';\nexport * from './TableFooter';\nexport * from './TableRow';\nexport * from './DataCell';\nexport * from './HeaderCell';\nexport * from './useSortableTable';\nexport * from './EditableCell';\nexport * from './ExpandableRow';\nexport * from './ExpandRowButton';\nexport * from './useTableKeyboardNavigation';\n"],"names":["Table","React","forwardRef","ref","className","fixed","spacing","sortable","rest","classNames","TableHead","props","TableBody","TableFooter","TableRow","hover","active","error","DataCell","padding","status","undefined","HeaderCell","children","name","sortConfig","sortableButtonProps","useState","isCurrentlySorted","setIsCurrentlySorted","useEffect","key","ariaSort","order","SortableHeaderCellButton","type","UpArrowIcon","size","DownArrowIcon","useSortableData","rawData","externalSortConfig","setSortConfig","tableCopy","slice","sortedData","useMemo","sort","a","b","get","onSortRequested","getSortableHeaderProps","buttonProps","onClick","getSortableTableProps","EditableCell","feedback","variant","outlined","VariantProvider","Tooltip","disableHoverListener","disableFocusListener","placement","content","ExpandableRow","open","colSpan","BaseExpand","ExpandRowButton","RightArrowIcon","onTableKeypress","event","currentRow","maxRow","allowWrap","keyPress","preventDefault","useTableKeyboardNavigation","numberOfRows","setCurrentRow","setMaxRow","tableBodyRef","useRef","tableHasFocus","current","contains","document","activeElement","childNodes","parentElement","focus","getTableBodyNavigationProps","getTableRowNavigationProps","row","tableRowRef","tabIndex","onKeyDown","e","newCell","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,KAAK,gBAAGC,KAAK,CAACC,UAAN,CACnB,gBAQEC,GARF;MAEIC,iBAAAA;wBACAC;MAAAA,gCAAQ;0BACRC;MAAAA,oCAAU;2BACVC;MAAAA,sCAAW;MACRC;;AAIL,SACEP,mBAAA,QAAA;AACEG,IAAAA,SAAS,EAAEK,UAAU,CACnB,WADmB,EAEnB;AAAE,0BAAoBJ;AAAtB,KAFmB,EAGnB;AAAE,2BAAqBC,OAAO,KAAK;AAAnC,KAHmB,EAInB;AAAE,0BAAoBA,OAAO,KAAK;AAAlC,KAJmB,EAKnB;AAAE,6BAAuBC;AAAzB,KALmB,EAMnBH,SANmB;AAQrBD,IAAAA,GAAG,EAAEA;KACDK,KAVN,CADF;AAcD,CAzBkB;;ICLRE,SAAS,gBAAGT,KAAK,CAACC,UAAN,CAGvB,gBAA0BC,GAA1B;AAAA,MAAGC,SAAH,QAAGA,SAAH;AAAA,MAAiBO,KAAjB;;AAAA,SACAV,mBAAA,QAAA;AACEG,IAAAA,SAAS,EAAEK,UAAU,CAAC,iBAAD,EAAoBL,SAApB;AACrBD,IAAAA,GAAG,EAAEA;KAC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CARGb;AAAAA,MAAAA;;;AASH;AACEyF,MAAAA,QAAQ,EAARA,QADF;AAEE9F,MAAAA,GAAG,EAAE6F,WAFP;AAGE1C,MAAAA,OAAO,EAAE;AAAA,eAAM2B,aAAa,CAACc,GAAD,CAAnB;AAAA,OAHX;AAIEG,MAAAA,SAAS,EAAE,mBAACC,CAAD;AACT,YAAMC,OAAO,GAAG5B,eAAe,CAAC2B,CAAD,EAAIzB,UAAJ,EAAgBM,YAAhB,EAA8BJ,SAA9B,CAA/B;AACAK,QAAAA,aAAa,CAACmB,OAAD,CAAb;AACD;AAPH,OAQK5F,IARL;AAUD;;AACD,SAAO;AAAEsF,IAAAA,0BAA0B,EAA1BA,0BAAF;AAA8BD,IAAAA,2BAA2B,EAA3BA;AAA9B,GAAP;AACD,CAjDM;;AC1CPQ,sBAAsB,CAAC,OAAD,CAAtB;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare type ExternalSortConfig = {
|
|
2
3
|
/**
|
|
3
4
|
* @default ""
|
|
@@ -17,12 +18,13 @@ export declare type SortableHeaderProps = {
|
|
|
17
18
|
/** Om headeren skal være sorterbar eller ikke
|
|
18
19
|
* @default true */
|
|
19
20
|
sortable?: boolean;
|
|
21
|
+
/** Props som sendes til knapp-elementet */
|
|
22
|
+
buttonProps?: Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, 'type' | 'onClick'>;
|
|
20
23
|
[key: string]: any;
|
|
21
24
|
};
|
|
22
25
|
export declare type SortableHeaderReturnProps = {
|
|
23
26
|
name: string;
|
|
24
27
|
sortable: boolean;
|
|
25
|
-
onClick: () => void;
|
|
26
28
|
sortConfig: ExternalSortConfig;
|
|
27
29
|
[key: string]: any;
|
|
28
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/table.esm.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"react-dom": ">=16.8.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@entur/expand": "^3.3.
|
|
31
|
-
"@entur/form": "^5.1
|
|
30
|
+
"@entur/expand": "^3.3.6",
|
|
31
|
+
"@entur/form": "^5.2.1",
|
|
32
32
|
"@entur/utils": "^0.4.2",
|
|
33
33
|
"@types/lodash.get": "^4.4.6",
|
|
34
34
|
"classnames": "^2.3.1",
|
|
35
35
|
"lodash.get": "^4.4.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@entur/tokens": "^3.
|
|
38
|
+
"@entur/tokens": "^3.3.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "6a15d9e27a27775ee3f86e1d3c09d0e9ce484749"
|
|
41
41
|
}
|