@norges-domstoler/dds-components 10.0.1 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cjs/components/Stack/Stack.d.ts +37 -0
- package/dist/cjs/components/Stack/Stack.stories.d.ts +10 -0
- package/dist/cjs/components/Stack/Stack.tokens.d.ts +20 -0
- package/dist/cjs/components/Stack/index.d.ts +1 -0
- package/dist/cjs/components/Table/Cell.d.ts +5 -0
- package/dist/cjs/components/Table/Row.d.ts +3 -20
- package/dist/cjs/components/Table/Table.d.ts +2 -14
- package/dist/cjs/components/Table/Table.stories.d.ts +4 -4
- package/dist/cjs/components/Table/Table.styles.d.ts +10 -0
- package/dist/cjs/components/Table/Table.tokens.d.ts +5 -0
- package/dist/cjs/components/Table/Table.types.d.ts +37 -0
- package/dist/cjs/components/Table/collapsible/CollapsibleRow.d.ts +6 -0
- package/dist/cjs/components/Table/collapsible/CollapsibleTable.d.ts +9 -0
- package/dist/cjs/components/Table/collapsible/CollapsibleTable.stories.d.ts +48 -0
- package/dist/cjs/components/Table/collapsible/Table.context.d.ts +9 -0
- package/dist/cjs/components/Table/index.d.ts +11 -3
- package/dist/cjs/components/Typography/Paragraph/Paragraph.stories.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +692 -410
- package/dist/components/ProgressTracker/ProgressTracker.tokens.js +0 -1
- package/dist/components/Search/Search.js +1 -1
- package/dist/components/Search/SearchAutocompleteWrapper.js +5 -2
- package/dist/components/Stack/Stack.d.ts +37 -0
- package/dist/components/Stack/Stack.js +46 -0
- package/dist/components/Stack/Stack.stories.d.ts +10 -0
- package/dist/components/Stack/Stack.tokens.d.ts +20 -0
- package/dist/components/Stack/Stack.tokens.js +26 -0
- package/dist/components/Stack/index.d.ts +1 -0
- package/dist/components/Table/Cell.d.ts +5 -0
- package/dist/components/Table/Cell.js +13 -4
- package/dist/components/Table/Row.d.ts +3 -20
- package/dist/components/Table/Row.js +1 -25
- package/dist/components/Table/Table.d.ts +2 -14
- package/dist/components/Table/Table.js +1 -1
- package/dist/components/Table/Table.stories.d.ts +4 -4
- package/dist/components/Table/Table.styles.d.ts +10 -0
- package/dist/components/Table/Table.styles.js +28 -0
- package/dist/components/Table/Table.tokens.d.ts +5 -0
- package/dist/components/Table/Table.tokens.js +10 -2
- package/dist/components/Table/Table.types.d.ts +37 -0
- package/dist/components/Table/collapsible/CollapsibleRow.d.ts +6 -0
- package/dist/components/Table/collapsible/CollapsibleRow.js +157 -0
- package/dist/components/Table/collapsible/CollapsibleTable.d.ts +9 -0
- package/dist/components/Table/collapsible/CollapsibleTable.js +42 -0
- package/dist/components/Table/collapsible/CollapsibleTable.stories.d.ts +48 -0
- package/dist/components/Table/collapsible/Table.context.d.ts +9 -0
- package/dist/components/Table/collapsible/Table.context.js +11 -0
- package/dist/components/Table/index.d.ts +11 -3
- package/dist/components/Table/index.js +5 -1
- package/dist/components/Tooltip/Tooltip.js +40 -6
- package/dist/components/Typography/Paragraph/Paragraph.stories.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
4
|
+
import { forwardRef, useState, useEffect, Children, Fragment, isValidElement, cloneElement } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { Table } from '../index.js';
|
|
7
|
+
import { removeButtonStyling } from '../../../helpers/styling/removeButtonStyling.js';
|
|
8
|
+
import { focusVisibleTransitionValue, focusVisible } from '../../../helpers/styling/focusVisible.js';
|
|
9
|
+
import '../../../helpers/styling/hover.js';
|
|
10
|
+
import '../../../helpers/styling/focus.js';
|
|
11
|
+
import '../../../helpers/styling/danger.js';
|
|
12
|
+
import '../../../helpers/styling/selection.js';
|
|
13
|
+
import { derivativeIdGenerator, spaceSeparatedIdListGenerator } from '../../../utils/idGenerator.js';
|
|
14
|
+
import '../../../utils/color.js';
|
|
15
|
+
import { DescriptionList } from '../../DescriptionList/DescriptionList.js';
|
|
16
|
+
import { DescriptionListTerm } from '../../DescriptionList/DescriptionListTerm.js';
|
|
17
|
+
import '../../DescriptionList/DescriptionListDesc.js';
|
|
18
|
+
import '../../DescriptionList/DescriptionListGroup.js';
|
|
19
|
+
import { VisuallyHidden } from '../../VisuallyHidden/VisuallyHidden.js';
|
|
20
|
+
import { Cell } from '../Cell.js';
|
|
21
|
+
import { useCollapsibleTableContext } from './Table.context.js';
|
|
22
|
+
import '../../../helpers/Backdrop/Backdrop.js';
|
|
23
|
+
import { AnimatedChevronUpDown } from '../../../helpers/Chevron/AnimatedChevronUpDown.js';
|
|
24
|
+
import '../../../helpers/HiddenInput/HiddenInput.js';
|
|
25
|
+
import '../../../helpers/Input/Input.styles.js';
|
|
26
|
+
import '../../../helpers/Input/Input.tokens.js';
|
|
27
|
+
import '../../InputMessage/InputMessage.js';
|
|
28
|
+
import '../../../helpers/Paper/Paper.js';
|
|
29
|
+
import '../../../helpers/RequiredMarker/RequiredMarker.js';
|
|
30
|
+
import { StyledRow } from '../Table.styles.js';
|
|
31
|
+
import { tableTokens } from '../Table.tokens.js';
|
|
32
|
+
|
|
33
|
+
var collapseButton = tableTokens.collapseButton;
|
|
34
|
+
var CollapseButton = styled.button.withConfig({
|
|
35
|
+
displayName: "CollapsibleRow__CollapseButton",
|
|
36
|
+
componentId: "sc-1bsqre3-0"
|
|
37
|
+
})(["", " margin-left:auto;margin-right:auto;display:flex;align-items:center;justify-content:center;transition:", ";border-radius:", ";height:", ";width:", ";&:focus-visible{", "}"], removeButtonStyling, focusVisibleTransitionValue, collapseButton.borderRadius, collapseButton.height, collapseButton.width, focusVisible);
|
|
38
|
+
var DescriptionListCell = styled(Cell).withConfig({
|
|
39
|
+
displayName: "CollapsibleRow__DescriptionListCell",
|
|
40
|
+
componentId: "sc-1bsqre3-1"
|
|
41
|
+
})(["& > div{display:block;}"]);
|
|
42
|
+
var CollapsibleRow = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
43
|
+
var _a$type = _a.type,
|
|
44
|
+
type = _a$type === void 0 ? 'body' : _a$type,
|
|
45
|
+
_a$mode = _a.mode,
|
|
46
|
+
mode = _a$mode === void 0 ? 'normal' : _a$mode,
|
|
47
|
+
children = _a.children,
|
|
48
|
+
rest = __rest(_a, ["type", "mode", "children"]);
|
|
49
|
+
var rowProps = Object.assign({
|
|
50
|
+
type: type,
|
|
51
|
+
mode: mode
|
|
52
|
+
}, rest);
|
|
53
|
+
var _useCollapsibleTableC = useCollapsibleTableContext(),
|
|
54
|
+
isCollapsed = _useCollapsibleTableC.isCollapsed,
|
|
55
|
+
headerValues = _useCollapsibleTableC.headerValues,
|
|
56
|
+
definingColumnIndex = _useCollapsibleTableC.definingColumnIndex;
|
|
57
|
+
var _useState = useState(true),
|
|
58
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
59
|
+
childrenCollapsed = _useState2[0],
|
|
60
|
+
setChildrenCollapsed = _useState2[1];
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
!isCollapsed && setChildrenCollapsed(true);
|
|
63
|
+
}, [isCollapsed]);
|
|
64
|
+
var collapsedHeaderValues = headerValues.filter(function (column, index) {
|
|
65
|
+
return definingColumnIndex.indexOf(index) === -1;
|
|
66
|
+
});
|
|
67
|
+
var childrenArray = Children.toArray(children);
|
|
68
|
+
var collapsedChildren = childrenArray.filter(function (column, index) {
|
|
69
|
+
return definingColumnIndex.indexOf(index) === -1;
|
|
70
|
+
});
|
|
71
|
+
var prefix = 'collapsibleRow';
|
|
72
|
+
var collapsibleIds = [];
|
|
73
|
+
var collapsedRenderedChildren = isCollapsed && collapsedHeaderValues.length > 0 ? collapsedChildren.map(function (child, index) {
|
|
74
|
+
var id = derivativeIdGenerator(prefix, index.toString());
|
|
75
|
+
collapsibleIds.push(id);
|
|
76
|
+
return jsxs(Fragment, {
|
|
77
|
+
children: [jsx(DescriptionListTerm, {
|
|
78
|
+
children: collapsedHeaderValues[index].content
|
|
79
|
+
}), /*#__PURE__*/isValidElement(child) && /*#__PURE__*/cloneElement(child, {
|
|
80
|
+
collapsibleProps: {
|
|
81
|
+
isCollapsibleChild: true
|
|
82
|
+
}
|
|
83
|
+
})]
|
|
84
|
+
}, "DL-".concat(index));
|
|
85
|
+
}) : null;
|
|
86
|
+
var collapsedRows = collapsedRenderedChildren && collapsedRenderedChildren.length > 0 ? jsx(StyledRow, Object.assign({
|
|
87
|
+
type: "body"
|
|
88
|
+
}, {
|
|
89
|
+
children: jsx(DescriptionListCell, Object.assign({
|
|
90
|
+
colSpan: definingColumnIndex.length + 1
|
|
91
|
+
}, {
|
|
92
|
+
children: jsx(DescriptionList, {
|
|
93
|
+
children: collapsedRenderedChildren
|
|
94
|
+
})
|
|
95
|
+
}))
|
|
96
|
+
})) : null;
|
|
97
|
+
var definingColumnCells = childrenArray.slice().filter(function (column, index) {
|
|
98
|
+
return definingColumnIndex.indexOf(index) > -1;
|
|
99
|
+
}).sort(function (a, b) {
|
|
100
|
+
return definingColumnIndex.indexOf(childrenArray.indexOf(a)) - definingColumnIndex.indexOf(childrenArray.indexOf(b));
|
|
101
|
+
});
|
|
102
|
+
var headerRow = function headerRow() {
|
|
103
|
+
if (type !== 'head' || !isCollapsed) return null;
|
|
104
|
+
return jsx(StyledRow, Object.assign({
|
|
105
|
+
ref: ref
|
|
106
|
+
}, rowProps, {
|
|
107
|
+
children: jsxs(Fragment$1, {
|
|
108
|
+
children: [definingColumnCells, jsxs(Table.Cell, Object.assign({
|
|
109
|
+
type: "head",
|
|
110
|
+
layout: "center"
|
|
111
|
+
}, {
|
|
112
|
+
children: ["Utvid", jsx(VisuallyHidden, Object.assign({
|
|
113
|
+
as: "span"
|
|
114
|
+
}, {
|
|
115
|
+
children: "raden"
|
|
116
|
+
}))]
|
|
117
|
+
}))]
|
|
118
|
+
})
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
var idList = spaceSeparatedIdListGenerator(collapsibleIds);
|
|
122
|
+
var rowWithChevron = function rowWithChevron() {
|
|
123
|
+
if (type !== 'body' || !isCollapsed) return null;
|
|
124
|
+
return jsxs(StyledRow, Object.assign({
|
|
125
|
+
ref: ref
|
|
126
|
+
}, rowProps, {
|
|
127
|
+
"data-isopencollapsibleheader": !childrenCollapsed && true
|
|
128
|
+
}, {
|
|
129
|
+
children: [definingColumnCells, jsx(Table.Cell, {
|
|
130
|
+
children: jsx(CollapseButton, Object.assign({
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
return setChildrenCollapsed(!childrenCollapsed);
|
|
133
|
+
},
|
|
134
|
+
"aria-expanded": !childrenCollapsed,
|
|
135
|
+
"aria-controls": idList
|
|
136
|
+
}, {
|
|
137
|
+
children: jsx(AnimatedChevronUpDown, {
|
|
138
|
+
isUp: childrenCollapsed ? false : true,
|
|
139
|
+
height: "7.5px",
|
|
140
|
+
width: "12px"
|
|
141
|
+
})
|
|
142
|
+
}))
|
|
143
|
+
})]
|
|
144
|
+
}));
|
|
145
|
+
};
|
|
146
|
+
return isCollapsed && collapsedRenderedChildren && collapsedRenderedChildren.length > 0 ? jsxs(Fragment$1, {
|
|
147
|
+
children: [headerRow(), type === 'body' && jsxs(Fragment$1, {
|
|
148
|
+
children: [rowWithChevron(), childrenCollapsed ? null : collapsedRows]
|
|
149
|
+
})]
|
|
150
|
+
}) : jsx(StyledRow, Object.assign({
|
|
151
|
+
ref: ref
|
|
152
|
+
}, rowProps, {
|
|
153
|
+
children: children
|
|
154
|
+
}));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
export { CollapsibleRow };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CollapsibleTable: import("react").ForwardRefExoticComponent<{
|
|
2
|
+
isCollapsed?: boolean | undefined;
|
|
3
|
+
headerValues: import("../Table.types").HeaderValues;
|
|
4
|
+
definingColumnIndex?: number[] | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
density?: import("../Table.types").TableDensity | undefined;
|
|
7
|
+
stickyHeader?: boolean | undefined;
|
|
8
|
+
withDividers?: boolean | undefined;
|
|
9
|
+
} & import("react").HTMLAttributes<HTMLTableElement> & import("react").RefAttributes<HTMLTableElement>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import styled, { css } from 'styled-components';
|
|
5
|
+
import { Table } from '../Table.js';
|
|
6
|
+
import { CollapsibleTableContext } from './Table.context.js';
|
|
7
|
+
|
|
8
|
+
var StyledTable = styled(Table).withConfig({
|
|
9
|
+
displayName: "CollapsibleTable__StyledTable",
|
|
10
|
+
componentId: "sc-1slp1a9-0"
|
|
11
|
+
})(["width:100%;", ""], function (_ref) {
|
|
12
|
+
var withDividers = _ref.withDividers;
|
|
13
|
+
return withDividers && css(["tr[data-isopencollapsibleheader='true']{border-bottom:none;}"]);
|
|
14
|
+
});
|
|
15
|
+
var CollapsibleTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
|
+
var _props$density = props.density,
|
|
17
|
+
density = _props$density === void 0 ? 'normal' : _props$density,
|
|
18
|
+
children = props.children,
|
|
19
|
+
isCollapsed = props.isCollapsed,
|
|
20
|
+
headerValues = props.headerValues,
|
|
21
|
+
_props$definingColumn = props.definingColumnIndex,
|
|
22
|
+
definingColumnIndex = _props$definingColumn === void 0 ? [0] : _props$definingColumn,
|
|
23
|
+
rest = __rest(props, ["density", "children", "isCollapsed", "headerValues", "definingColumnIndex"]);
|
|
24
|
+
var tableProps = Object.assign({
|
|
25
|
+
ref: ref,
|
|
26
|
+
density: density,
|
|
27
|
+
isCollapsed: isCollapsed
|
|
28
|
+
}, rest);
|
|
29
|
+
return jsx(CollapsibleTableContext.Provider, Object.assign({
|
|
30
|
+
value: {
|
|
31
|
+
isCollapsed: isCollapsed,
|
|
32
|
+
headerValues: headerValues,
|
|
33
|
+
definingColumnIndex: definingColumnIndex
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
children: jsx(StyledTable, Object.assign({}, tableProps, {
|
|
37
|
+
children: children
|
|
38
|
+
}))
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export { CollapsibleTable };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CollapsibleTableProps } from '..';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<{
|
|
5
|
+
isCollapsed?: boolean | undefined;
|
|
6
|
+
headerValues: import("../Table.types").HeaderValues;
|
|
7
|
+
definingColumnIndex?: number[] | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
density?: import("..").TableDensity | undefined;
|
|
10
|
+
stickyHeader?: boolean | undefined;
|
|
11
|
+
withDividers?: boolean | undefined;
|
|
12
|
+
} & import("react").HTMLAttributes<HTMLTableElement> & import("react").RefAttributes<HTMLTableElement>> & {
|
|
13
|
+
Row: import("react").ForwardRefExoticComponent<{
|
|
14
|
+
type?: import("..").TableRowType | undefined;
|
|
15
|
+
mode?: import("../Table.types").RowMode | undefined;
|
|
16
|
+
selected?: boolean | undefined;
|
|
17
|
+
hoverable?: boolean | undefined;
|
|
18
|
+
} & import("react").HTMLAttributes<HTMLTableRowElement> & import("react").RefAttributes<HTMLTableRowElement>>;
|
|
19
|
+
};
|
|
20
|
+
argTypes: {
|
|
21
|
+
isCollapsed: {
|
|
22
|
+
control: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
stickyHeader: {
|
|
27
|
+
control: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
parameters: {
|
|
33
|
+
controls: {
|
|
34
|
+
exclude: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export default _default;
|
|
39
|
+
export declare const SingleDefiningColumn: (args: CollapsibleTableProps) => JSX.Element;
|
|
40
|
+
export declare const MultipleDefiningColumns: (args: CollapsibleTableProps) => JSX.Element;
|
|
41
|
+
export declare const PrioritizedDefiningColumns: (args: CollapsibleTableProps) => JSX.Element;
|
|
42
|
+
export declare const withDividers: (args: CollapsibleTableProps) => JSX.Element;
|
|
43
|
+
export declare const Compact: (args: CollapsibleTableProps) => JSX.Element;
|
|
44
|
+
export declare const StickyHeader: (args: CollapsibleTableProps) => JSX.Element;
|
|
45
|
+
export declare const WithButtonAndIcons: (args: CollapsibleTableProps) => JSX.Element;
|
|
46
|
+
export declare const Responsive: (args: CollapsibleTableProps) => JSX.Element;
|
|
47
|
+
export declare const ResposiveMultipleBreakpoints: (args: CollapsibleTableProps) => JSX.Element;
|
|
48
|
+
export declare const Example: () => JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HeaderValues } from '../Table.types';
|
|
2
|
+
declare type CollapsibleTableContextProps = {
|
|
3
|
+
isCollapsed?: boolean;
|
|
4
|
+
headerValues: HeaderValues;
|
|
5
|
+
definingColumnIndex: number[];
|
|
6
|
+
};
|
|
7
|
+
export declare const CollapsibleTableContext: import("react").Context<CollapsibleTableContextProps>;
|
|
8
|
+
export declare const useCollapsibleTableContext: () => CollapsibleTableContextProps;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext, createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
var CollapsibleTableContext = /*#__PURE__*/createContext({
|
|
4
|
+
headerValues: [],
|
|
5
|
+
definingColumnIndex: [0]
|
|
6
|
+
});
|
|
7
|
+
var useCollapsibleTableContext = function useCollapsibleTableContext() {
|
|
8
|
+
return useContext(CollapsibleTableContext);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { CollapsibleTableContext, useCollapsibleTableContext };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Table as BaseTable
|
|
1
|
+
import { Table as BaseTable } from './Table';
|
|
2
|
+
import { CollapsibleTable as BaseCollapsibleTable } from './collapsible/CollapsibleTable';
|
|
3
|
+
import { TableProps, TableDensity, CollapsibleTableProps, TableRowProps, TableRowType } from './Table.types';
|
|
2
4
|
import { Head, TableHeadProps } from './Head';
|
|
3
5
|
import { Body, TableBodyProps } from './Body';
|
|
4
6
|
import { Foot, TableFootProps } from './Foot';
|
|
5
|
-
import { Row
|
|
7
|
+
import { Row } from './Row';
|
|
8
|
+
import { CollapsibleRow } from './collapsible/CollapsibleRow';
|
|
6
9
|
import { Cell, TableCellProps, TableCellLayout, TableCellType } from './Cell';
|
|
7
10
|
import { SortCell, TableSortCellProps, SortOrder } from './SortCell';
|
|
8
11
|
import { TableWrapper } from './TableWrapper';
|
|
@@ -16,5 +19,10 @@ declare type TableCompoundProps = typeof BaseTable & {
|
|
|
16
19
|
SortCell: typeof SortCell;
|
|
17
20
|
};
|
|
18
21
|
declare const Table: TableCompoundProps;
|
|
22
|
+
declare type CollapsibleTableCompoundProps = typeof BaseCollapsibleTable & {
|
|
23
|
+
Row: typeof CollapsibleRow;
|
|
24
|
+
};
|
|
25
|
+
declare const CollapsibleTable: CollapsibleTableCompoundProps;
|
|
19
26
|
export { Table };
|
|
20
|
-
export
|
|
27
|
+
export { CollapsibleTable };
|
|
28
|
+
export type { TableCellProps, TableDensity, TableProps, TableRowProps, TableRowType, TableHeadProps, TableBodyProps, TableFootProps, TableSortCellProps, SortOrder, TableCellLayout, TableCellType, CollapsibleTableProps, };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Table as Table$1 } from './Table.js';
|
|
2
|
+
import { CollapsibleTable as CollapsibleTable$1 } from './collapsible/CollapsibleTable.js';
|
|
2
3
|
import { Head } from './Head.js';
|
|
3
4
|
import { Body } from './Body.js';
|
|
4
5
|
import { Foot } from './Foot.js';
|
|
5
6
|
import { Row } from './Row.js';
|
|
7
|
+
import { CollapsibleRow } from './collapsible/CollapsibleRow.js';
|
|
6
8
|
import { Cell } from './Cell.js';
|
|
7
9
|
import { SortCell } from './SortCell.js';
|
|
8
10
|
import { TableWrapper } from './TableWrapper.js';
|
|
@@ -15,5 +17,7 @@ Table.Cell = Cell;
|
|
|
15
17
|
Table.SortCell = SortCell;
|
|
16
18
|
Table.Row = Row;
|
|
17
19
|
Table.Foot = Foot;
|
|
20
|
+
var CollapsibleTable = CollapsibleTable$1;
|
|
21
|
+
CollapsibleTable.Row = CollapsibleRow;
|
|
18
22
|
|
|
19
|
-
export { Table };
|
|
23
|
+
export { CollapsibleTable, Table };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { forwardRef, useId, useState, useEffect, Children, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import { forwardRef, useId, useState, useRef, useEffect, Children, isValidElement, cloneElement } from 'react';
|
|
5
5
|
import { useCombinedRef } from '../../hooks/useCombinedRefs.js';
|
|
6
6
|
import { useOnKeyDown } from '../../hooks/useOnKeyDown.js';
|
|
7
7
|
import { useFloatPosition } from '../../hooks/useFloatPosition.js';
|
|
@@ -34,17 +34,51 @@ var Tooltip = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
34
34
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
35
|
open = _useState2[0],
|
|
36
36
|
setOpen = _useState2[1];
|
|
37
|
-
var _useState3 = useState(
|
|
37
|
+
var _useState3 = useState(false),
|
|
38
38
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
inView = _useState4[0],
|
|
40
|
+
setInView = _useState4[1];
|
|
41
|
+
var _useState5 = useState(null),
|
|
42
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
+
arrowElement = _useState6[0],
|
|
44
|
+
setArrowElement = _useState6[1];
|
|
41
45
|
var _useFloatPosition = useFloatPosition(arrowElement, {
|
|
42
46
|
placement: placement
|
|
43
47
|
}),
|
|
44
48
|
reference = _useFloatPosition.reference,
|
|
45
49
|
floating = _useFloatPosition.floating,
|
|
46
50
|
styles = _useFloatPosition.styles;
|
|
47
|
-
var
|
|
51
|
+
var tooltipRef = useRef(null);
|
|
52
|
+
var combinedRef = useCombinedRef(ref, floating, tooltipRef);
|
|
53
|
+
var closeWhenNotInView = function closeWhenNotInView(entries) {
|
|
54
|
+
var _entries = _slicedToArray(entries, 1),
|
|
55
|
+
entry = _entries[0];
|
|
56
|
+
entry.isIntersecting ? setInView(true) : setInView(false);
|
|
57
|
+
};
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
var options = {
|
|
60
|
+
root: null,
|
|
61
|
+
rootMargin: '0px'
|
|
62
|
+
};
|
|
63
|
+
var ref = tooltipRef.current;
|
|
64
|
+
var observer = new IntersectionObserver(closeWhenNotInView, options);
|
|
65
|
+
if (ref) observer.observe(ref);
|
|
66
|
+
return function () {
|
|
67
|
+
if (ref) observer.unobserve(ref);
|
|
68
|
+
};
|
|
69
|
+
}, [tooltipRef]);
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
if (tooltipRef.current) {
|
|
72
|
+
window.addEventListener('scroll', function () {
|
|
73
|
+
closeTooltip();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return function () {
|
|
77
|
+
if (tooltipRef.current) {
|
|
78
|
+
window.removeEventListener('scroll', function () {});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
48
82
|
var timer;
|
|
49
83
|
useEffect(function () {
|
|
50
84
|
return function () {
|
|
@@ -83,7 +117,7 @@ var Tooltip = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
83
117
|
ref: combinedRef,
|
|
84
118
|
role: 'tooltip',
|
|
85
119
|
'aria-hidden': !open,
|
|
86
|
-
open: open,
|
|
120
|
+
open: open && inView,
|
|
87
121
|
style: Object.assign({}, styles.floating)
|
|
88
122
|
};
|
|
89
123
|
var arrowWrapperProps = {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { Heading } from './components/Typography/Heading/Heading.js';
|
|
|
16
16
|
export { Link } from './components/Typography/Link/Link.js';
|
|
17
17
|
export { Legend } from './components/Typography/Legend/Legend.js';
|
|
18
18
|
export { Caption } from './components/Typography/Caption/Caption.js';
|
|
19
|
-
export { Table } from './components/Table/index.js';
|
|
19
|
+
export { CollapsibleTable, Table } from './components/Table/index.js';
|
|
20
20
|
export { Breadcrumb } from './components/Breadcrumbs/Breadcrumb.js';
|
|
21
21
|
export { Breadcrumbs } from './components/Breadcrumbs/Breadcrumbs.js';
|
|
22
22
|
export { Icon } from './components/Icon/Icon.js';
|
|
@@ -213,3 +213,4 @@ export { InlineEditTextArea } from './components/InlineEdit/InlineEditTextArea.j
|
|
|
213
213
|
export { InlineEditInput } from './components/InlineEdit/InlineEditInput.js';
|
|
214
214
|
export { StyledTextArea, TextArea } from './components/TextArea/TextArea.js';
|
|
215
215
|
export { SplitButton } from './components/SplitButton/SplitButton.js';
|
|
216
|
+
export { HStack, VStack } from './components/Stack/Stack.js';
|