@xyo-network/react-shared 2.37.0 → 2.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/TableCell/EllipsisTableCell.d.ts +11 -4
- package/dist/cjs/components/TableCell/EllipsisTableCell.d.ts.map +1 -1
- package/dist/cjs/components/TableCell/EllipsisTableCell.js +41 -61
- package/dist/cjs/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/cjs/components/TableCell/EllipsisTableCellDeprecated.d.ts +12 -0
- package/dist/cjs/components/TableCell/EllipsisTableCellDeprecated.d.ts.map +1 -0
- package/dist/cjs/components/TableCell/EllipsisTableCellDeprecated.js +73 -0
- package/dist/cjs/components/TableCell/EllipsisTableCellDeprecated.js.map +1 -0
- package/dist/cjs/components/TableCell/HashTableCell.d.ts +0 -1
- package/dist/cjs/components/TableCell/HashTableCell.d.ts.map +1 -1
- package/dist/cjs/components/TableCell/HashTableCell.js +2 -2
- package/dist/cjs/components/TableCell/HashTableCell.js.map +1 -1
- package/dist/docs.json +371 -308
- package/dist/esm/components/TableCell/EllipsisTableCell.d.ts +11 -4
- package/dist/esm/components/TableCell/EllipsisTableCell.d.ts.map +1 -1
- package/dist/esm/components/TableCell/EllipsisTableCell.js +42 -61
- package/dist/esm/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/esm/components/TableCell/EllipsisTableCellDeprecated.d.ts +12 -0
- package/dist/esm/components/TableCell/EllipsisTableCellDeprecated.d.ts.map +1 -0
- package/dist/esm/components/TableCell/EllipsisTableCellDeprecated.js +66 -0
- package/dist/esm/components/TableCell/EllipsisTableCellDeprecated.js.map +1 -0
- package/dist/esm/components/TableCell/HashTableCell.d.ts +0 -1
- package/dist/esm/components/TableCell/HashTableCell.d.ts.map +1 -1
- package/dist/esm/components/TableCell/HashTableCell.js +2 -2
- package/dist/esm/components/TableCell/HashTableCell.js.map +1 -1
- package/package.json +6 -6
- package/src/components/TableCell/EllipsisTableCell.tsx +69 -93
- package/src/components/TableCell/EllipsisTableCellDeprecated.tsx +106 -0
- package/src/components/TableCell/EllipsizeTableCell.stories.tsx +99 -0
- package/src/components/TableCell/HashTableCell.tsx +1 -3
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
|
+
import { WithChildren } from '@xylabs/react-shared';
|
|
3
4
|
import { To } from 'react-router-dom';
|
|
4
5
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
6
|
+
/**
|
|
7
|
+
* Width of the table cell.
|
|
8
|
+
*
|
|
9
|
+
* Note: When using percentages, this value can be different than what you expect
|
|
10
|
+
* if used on a cell that is not the first cell in the first row.
|
|
11
|
+
*/
|
|
12
|
+
width?: string | number;
|
|
13
|
+
href?: string;
|
|
14
|
+
to?: To;
|
|
5
15
|
value?: string;
|
|
6
|
-
to?: To | undefined;
|
|
7
|
-
href?: string | undefined;
|
|
8
|
-
forCell?: number;
|
|
9
16
|
}
|
|
10
|
-
export declare const EllipsisTableCell: React.FC<EllipsisTableCellProps
|
|
17
|
+
export declare const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>>;
|
|
11
18
|
//# sourceMappingURL=EllipsisTableCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCell.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"EllipsisTableCell.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,cAAc,EAAE,MAAM,eAAe,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AA8CrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAkB5E,CAAA"}
|
|
@@ -1,65 +1,46 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { styled, TableCell } from '@mui/material';
|
|
3
3
|
import { LinkEx } from '@xylabs/react-link';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
minWidth: theme.spacing(10),
|
|
46
|
-
overflow: 'hidden',
|
|
47
|
-
textOverflow: 'ellipsis',
|
|
48
|
-
whiteSpace: 'nowrap',
|
|
49
|
-
}, children: children })) : href || to ? (_jsx(LinkEx, { style: {
|
|
50
|
-
display: 'block',
|
|
51
|
-
maxWidth: calcCellWidth,
|
|
52
|
-
minWidth: theme.spacing(10),
|
|
53
|
-
overflow: 'hidden',
|
|
54
|
-
textOverflow: 'ellipsis',
|
|
55
|
-
whiteSpace: 'nowrap',
|
|
56
|
-
}, to: to, href: href, target: href ? '_blank' : undefined, children: value })) : (_jsx("span", { style: {
|
|
57
|
-
display: 'block',
|
|
58
|
-
maxWidth: calcCellWidth,
|
|
59
|
-
minWidth: theme.spacing(10),
|
|
60
|
-
overflow: 'hidden',
|
|
61
|
-
textOverflow: 'ellipsis',
|
|
62
|
-
whiteSpace: 'nowrap',
|
|
63
|
-
}, children: value })) }) }));
|
|
4
|
+
/**
|
|
5
|
+
* Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
|
|
6
|
+
*/
|
|
7
|
+
const ComponentName = 'EllipsisTableCell';
|
|
8
|
+
const EllipsisTableCellRoot = styled(TableCell, {
|
|
9
|
+
name: ComponentName,
|
|
10
|
+
shouldForwardProp: (prop) => prop !== 'width',
|
|
11
|
+
slot: 'Root',
|
|
12
|
+
})(({ width = '100%' }) => ({
|
|
13
|
+
'&': {
|
|
14
|
+
// because the cell content ends up absolutely positioned, the cell doesn't know the content height.
|
|
15
|
+
// the pseudo element with a hidden character establishes the proper height of the content and hides it
|
|
16
|
+
':before': {
|
|
17
|
+
content: "'nbsp;'",
|
|
18
|
+
display: 'block',
|
|
19
|
+
// take the pseudo element out of the `display: block` flow so it won't push against our actual content
|
|
20
|
+
float: 'left',
|
|
21
|
+
visibility: 'hidden',
|
|
22
|
+
},
|
|
23
|
+
width,
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
const EllipsisTableCellInnerWrap = styled('div', {
|
|
27
|
+
name: ComponentName,
|
|
28
|
+
slot: 'innerWrap',
|
|
29
|
+
})(() => ({
|
|
30
|
+
position: 'relative',
|
|
31
|
+
}));
|
|
32
|
+
const EllipsisTableCellContentWrap = styled('span', {
|
|
33
|
+
name: ComponentName,
|
|
34
|
+
slot: 'contentWrap',
|
|
35
|
+
})(() => ({
|
|
36
|
+
left: 0,
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
right: 0,
|
|
40
|
+
textOverflow: 'ellipsis',
|
|
41
|
+
whiteSpace: 'nowrap',
|
|
42
|
+
}));
|
|
43
|
+
export const EllipsisTableCell = ({ children, href, to, value, ...props }) => {
|
|
44
|
+
return (_jsx(EllipsisTableCellRoot, { ...props, children: _jsx(EllipsisTableCellInnerWrap, { children: _jsx(EllipsisTableCellContentWrap, { children: children ? (children) : href || to ? (_jsx(LinkEx, { to: to, href: href, target: href ? '_blank' : undefined, children: value })) : (value) }) }) }));
|
|
64
45
|
};
|
|
65
46
|
//# sourceMappingURL=EllipsisTableCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAkB,
|
|
1
|
+
{"version":3,"file":"EllipsisTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAkB,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAI3C;;GAEG;AAEH,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAEzC,MAAM,qBAAqB,GAAG,MAAM,CAAC,SAAS,EAAE;IAC9C,IAAI,EAAE,aAAa;IACnB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC,CAAyB,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAClD,GAAG,EAAE;QACH,oGAAoG;QACpG,uGAAuG;QACvG,SAAS,EAAE;YACT,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,OAAO;YAChB,uGAAuG;YACvG,KAAK,EAAE,MAAM;YACb,UAAU,EAAE,QAAQ;SACrB;QACD,KAAK;KACN;CACF,CAAC,CAAC,CAAA;AAEH,MAAM,0BAA0B,GAAG,MAAM,CAAC,KAAK,EAAE;IAC/C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,WAAW;CAClB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,UAAU;CACrB,CAAC,CAAC,CAAA;AAEH,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE;IAClD,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACR,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,CAAC;IACR,YAAY,EAAE,UAAU;IACxB,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC,CAAA;AAeH,MAAM,CAAC,MAAM,iBAAiB,GAAmD,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAC3H,OAAO,CACL,KAAC,qBAAqB,OAAK,KAAK,YAC9B,KAAC,0BAA0B,cACzB,KAAC,4BAA4B,cAC1B,QAAQ,CAAC,CAAC,CAAC,CACV,QAAQ,CACT,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CACf,KAAC,MAAM,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAC5D,KAAK,GACC,CACV,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GAC4B,GACJ,GACP,CACzB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableCellProps } from '@mui/material';
|
|
3
|
+
import { To } from 'react-router-dom';
|
|
4
|
+
export interface EllipsisTableCellProps extends TableCellProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
to?: To | undefined;
|
|
7
|
+
href?: string | undefined;
|
|
8
|
+
forCell?: number;
|
|
9
|
+
}
|
|
10
|
+
/** @deprecated - use new EllipsisTableCell */
|
|
11
|
+
export declare const EllipsisTableCellDeprecated: React.FC<EllipsisTableCellProps>;
|
|
12
|
+
//# sourceMappingURL=EllipsisTableCellDeprecated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAOrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,EAAE,GAAG,SAAS,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,8CAA8C;AAC9C,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAuFxE,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TableCell, useTheme } from '@mui/material';
|
|
3
|
+
import { LinkEx } from '@xylabs/react-link';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { getActualPaddingX } from '../../lib';
|
|
6
|
+
import { findParent } from './findParent';
|
|
7
|
+
import { getRemainingRowWidth } from './getRemainingRowWidth';
|
|
8
|
+
import { getSmallestParentWidth } from './getSmallestParentWidth';
|
|
9
|
+
/** @deprecated - use new EllipsisTableCell */
|
|
10
|
+
export const EllipsisTableCellDeprecated = ({ children, value, to, forCell, href, ...props }) => {
|
|
11
|
+
const [calcCellWidth, setCalcCellWidth] = useState(0);
|
|
12
|
+
const hashDivRef = useRef(null);
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const currentElement = hashDivRef.current?.parentElement;
|
|
16
|
+
const cell = findParent('td', currentElement);
|
|
17
|
+
const row = findParent('tr', currentElement);
|
|
18
|
+
const checkWidth = (cell) => {
|
|
19
|
+
const smallestParentWidth = getSmallestParentWidth(cell);
|
|
20
|
+
if (smallestParentWidth && row) {
|
|
21
|
+
const remainingWidth = getRemainingRowWidth(row, forCell);
|
|
22
|
+
const actualPaddingX = getActualPaddingX(cell);
|
|
23
|
+
const remainderWidth = smallestParentWidth - remainingWidth - actualPaddingX;
|
|
24
|
+
cell.style.width = `${remainderWidth}`;
|
|
25
|
+
setCalcCellWidth(remainderWidth);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const onResize = () => {
|
|
29
|
+
if (cell) {
|
|
30
|
+
checkWidth(cell);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (cell) {
|
|
34
|
+
checkWidth(cell);
|
|
35
|
+
window.addEventListener('resize', onResize);
|
|
36
|
+
row?.addEventListener('resize', onResize);
|
|
37
|
+
}
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener('resize', onResize);
|
|
40
|
+
row?.removeEventListener('resize', onResize);
|
|
41
|
+
};
|
|
42
|
+
}, [forCell, hashDivRef]);
|
|
43
|
+
return (_jsx(TableCell, { ...props, children: _jsx("div", { ref: hashDivRef, children: children ? (_jsx("span", { style: {
|
|
44
|
+
display: 'block',
|
|
45
|
+
maxWidth: calcCellWidth,
|
|
46
|
+
minWidth: theme.spacing(10),
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
textOverflow: 'ellipsis',
|
|
49
|
+
whiteSpace: 'nowrap',
|
|
50
|
+
}, children: children })) : href || to ? (_jsx(LinkEx, { style: {
|
|
51
|
+
display: 'block',
|
|
52
|
+
maxWidth: calcCellWidth,
|
|
53
|
+
minWidth: theme.spacing(10),
|
|
54
|
+
overflow: 'hidden',
|
|
55
|
+
textOverflow: 'ellipsis',
|
|
56
|
+
whiteSpace: 'nowrap',
|
|
57
|
+
}, to: to, href: href, target: href ? '_blank' : undefined, children: value })) : (_jsx("span", { style: {
|
|
58
|
+
display: 'block',
|
|
59
|
+
maxWidth: calcCellWidth,
|
|
60
|
+
minWidth: theme.spacing(10),
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
textOverflow: 'ellipsis',
|
|
63
|
+
whiteSpace: 'nowrap',
|
|
64
|
+
}, children: value })) }) }));
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=EllipsisTableCellDeprecated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EllipsisTableCellDeprecated.js","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AASjE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,2BAA2B,GAAqC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAChI,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAA;IAC7D,MAAM,UAAU,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block' | 'payload';
|
|
6
6
|
exploreDomain?: string;
|
|
7
7
|
network?: string;
|
|
8
|
-
forCell?: number;
|
|
9
8
|
}
|
|
10
9
|
export declare const HashTableCell: React.FC<HashTableCellProps>;
|
|
11
10
|
//# sourceMappingURL=HashTableCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashTableCell.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/HashTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"HashTableCell.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/HashTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAWtD,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { EllipsisTableCell } from './EllipsisTableCell';
|
|
3
|
-
export const HashTableCell = ({ value, archive,
|
|
3
|
+
export const HashTableCell = ({ value, archive, dataType, network, exploreDomain, ...props }) => {
|
|
4
4
|
const hashPath = `/${dataType}/hash/${value}?network=${network ?? 'main'}`;
|
|
5
5
|
const explorePath = archive ? `/archive/${archive}${hashPath}` : hashPath;
|
|
6
|
-
return (_jsx(EllipsisTableCell, {
|
|
6
|
+
return (_jsx(EllipsisTableCell, { value: value, href: exploreDomain ? `${exploreDomain}${explorePath}}` : undefined, to: exploreDomain ? undefined : explorePath, ...props }));
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=HashTableCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/HashTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"HashTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/HashTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,qBAAqB,CAAA;AAS/E,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAC5H,MAAM,QAAQ,GAAG,IAAI,QAAQ,SAAS,KAAK,YAAY,OAAO,IAAI,MAAM,EAAE,CAAA;IAC1E,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,YAAY,OAAO,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;IACzE,OAAO,CACL,KAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,SAAS,EACnE,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,KACvC,KAAK,GACT,CACH,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/pixel": "^1.4.5",
|
|
14
|
-
"@xylabs/react-appbar": "^2.
|
|
15
|
-
"@xylabs/react-button": "^2.
|
|
16
|
-
"@xylabs/react-flexbox": "^2.
|
|
17
|
-
"@xylabs/react-link": "^2.
|
|
18
|
-
"@xylabs/react-shared": "^2.
|
|
14
|
+
"@xylabs/react-appbar": "^2.15.0",
|
|
15
|
+
"@xylabs/react-button": "^2.15.0",
|
|
16
|
+
"@xylabs/react-flexbox": "^2.15.0",
|
|
17
|
+
"@xylabs/react-link": "^2.15.0",
|
|
18
|
+
"@xylabs/react-shared": "^2.15.0",
|
|
19
19
|
"tslib": "^2.4.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
71
|
"types": "dist/esm/index.d.ts",
|
|
72
|
-
"version": "2.37.
|
|
72
|
+
"version": "2.37.1"
|
|
73
73
|
}
|
|
@@ -1,105 +1,81 @@
|
|
|
1
|
-
import { TableCell, TableCellProps
|
|
1
|
+
import { styled, TableCell, TableCellProps } from '@mui/material'
|
|
2
2
|
import { LinkEx } from '@xylabs/react-link'
|
|
3
|
-
import {
|
|
3
|
+
import { WithChildren } from '@xylabs/react-shared'
|
|
4
4
|
import { To } from 'react-router-dom'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { getSmallestParentWidth } from './getSmallestParentWidth'
|
|
6
|
+
/**
|
|
7
|
+
* Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
|
|
8
|
+
*/
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
value?: string
|
|
13
|
-
to?: To | undefined
|
|
14
|
-
href?: string | undefined
|
|
15
|
-
forCell?: number //cell index for ellipsized table cell
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const EllipsisTableCell: React.FC<EllipsisTableCellProps> = ({ children, value, to, forCell, href, ...props }) => {
|
|
19
|
-
const [calcCellWidth, setCalcCellWidth] = useState<number>(0)
|
|
20
|
-
const hashDivRef = useRef<HTMLDivElement>(null)
|
|
21
|
-
const theme = useTheme()
|
|
10
|
+
const ComponentName = 'EllipsisTableCell'
|
|
22
11
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
const EllipsisTableCellRoot = styled(TableCell, {
|
|
13
|
+
name: ComponentName,
|
|
14
|
+
shouldForwardProp: (prop) => prop !== 'width',
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
})<EllipsisTableCellProps>(({ width = '100%' }) => ({
|
|
17
|
+
'&': {
|
|
18
|
+
// because the cell content ends up absolutely positioned, the cell doesn't know the content height.
|
|
19
|
+
// the pseudo element with a hidden character establishes the proper height of the content and hides it
|
|
20
|
+
':before': {
|
|
21
|
+
content: "'nbsp;'",
|
|
22
|
+
display: 'block',
|
|
23
|
+
// take the pseudo element out of the `display: block` flow so it won't push against our actual content
|
|
24
|
+
float: 'left',
|
|
25
|
+
visibility: 'hidden',
|
|
26
|
+
},
|
|
27
|
+
width,
|
|
28
|
+
},
|
|
29
|
+
}))
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
cell.style.width = `${remainderWidth}`
|
|
35
|
-
setCalcCellWidth(remainderWidth)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
31
|
+
const EllipsisTableCellInnerWrap = styled('div', {
|
|
32
|
+
name: ComponentName,
|
|
33
|
+
slot: 'innerWrap',
|
|
34
|
+
})(() => ({
|
|
35
|
+
position: 'relative',
|
|
36
|
+
}))
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const EllipsisTableCellContentWrap = styled('span', {
|
|
39
|
+
name: ComponentName,
|
|
40
|
+
slot: 'contentWrap',
|
|
41
|
+
})(() => ({
|
|
42
|
+
left: 0,
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
right: 0,
|
|
46
|
+
textOverflow: 'ellipsis',
|
|
47
|
+
whiteSpace: 'nowrap',
|
|
48
|
+
}))
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
export interface EllipsisTableCellProps extends TableCellProps {
|
|
51
|
+
/**
|
|
52
|
+
* Width of the table cell.
|
|
53
|
+
*
|
|
54
|
+
* Note: When using percentages, this value can be different than what you expect
|
|
55
|
+
* if used on a cell that is not the first cell in the first row.
|
|
56
|
+
*/
|
|
57
|
+
width?: string | number
|
|
58
|
+
href?: string
|
|
59
|
+
to?: To
|
|
60
|
+
value?: string
|
|
61
|
+
}
|
|
55
62
|
|
|
63
|
+
export const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>> = ({ children, href, to, value, ...props }) => {
|
|
56
64
|
return (
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
) : href || to ? (
|
|
73
|
-
<LinkEx
|
|
74
|
-
style={{
|
|
75
|
-
display: 'block',
|
|
76
|
-
maxWidth: calcCellWidth,
|
|
77
|
-
minWidth: theme.spacing(10),
|
|
78
|
-
overflow: 'hidden',
|
|
79
|
-
textOverflow: 'ellipsis',
|
|
80
|
-
whiteSpace: 'nowrap',
|
|
81
|
-
}}
|
|
82
|
-
to={to}
|
|
83
|
-
href={href}
|
|
84
|
-
target={href ? '_blank' : undefined}
|
|
85
|
-
>
|
|
86
|
-
{value}
|
|
87
|
-
</LinkEx>
|
|
88
|
-
) : (
|
|
89
|
-
<span
|
|
90
|
-
style={{
|
|
91
|
-
display: 'block',
|
|
92
|
-
maxWidth: calcCellWidth,
|
|
93
|
-
minWidth: theme.spacing(10),
|
|
94
|
-
overflow: 'hidden',
|
|
95
|
-
textOverflow: 'ellipsis',
|
|
96
|
-
whiteSpace: 'nowrap',
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
{value}
|
|
100
|
-
</span>
|
|
101
|
-
)}
|
|
102
|
-
</div>
|
|
103
|
-
</TableCell>
|
|
65
|
+
<EllipsisTableCellRoot {...props}>
|
|
66
|
+
<EllipsisTableCellInnerWrap>
|
|
67
|
+
<EllipsisTableCellContentWrap>
|
|
68
|
+
{children ? (
|
|
69
|
+
children
|
|
70
|
+
) : href || to ? (
|
|
71
|
+
<LinkEx to={to} href={href} target={href ? '_blank' : undefined}>
|
|
72
|
+
{value}
|
|
73
|
+
</LinkEx>
|
|
74
|
+
) : (
|
|
75
|
+
value
|
|
76
|
+
)}
|
|
77
|
+
</EllipsisTableCellContentWrap>
|
|
78
|
+
</EllipsisTableCellInnerWrap>
|
|
79
|
+
</EllipsisTableCellRoot>
|
|
104
80
|
)
|
|
105
81
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { TableCell, TableCellProps, useTheme } from '@mui/material'
|
|
2
|
+
import { LinkEx } from '@xylabs/react-link'
|
|
3
|
+
import { useEffect, useRef, useState } from 'react'
|
|
4
|
+
import { To } from 'react-router-dom'
|
|
5
|
+
|
|
6
|
+
import { getActualPaddingX } from '../../lib'
|
|
7
|
+
import { findParent } from './findParent'
|
|
8
|
+
import { getRemainingRowWidth } from './getRemainingRowWidth'
|
|
9
|
+
import { getSmallestParentWidth } from './getSmallestParentWidth'
|
|
10
|
+
|
|
11
|
+
export interface EllipsisTableCellProps extends TableCellProps {
|
|
12
|
+
value?: string
|
|
13
|
+
to?: To | undefined
|
|
14
|
+
href?: string | undefined
|
|
15
|
+
forCell?: number //cell index for ellipsized table cell
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @deprecated - use new EllipsisTableCell */
|
|
19
|
+
export const EllipsisTableCellDeprecated: React.FC<EllipsisTableCellProps> = ({ children, value, to, forCell, href, ...props }) => {
|
|
20
|
+
const [calcCellWidth, setCalcCellWidth] = useState<number>(0)
|
|
21
|
+
const hashDivRef = useRef<HTMLDivElement>(null)
|
|
22
|
+
const theme = useTheme()
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const currentElement = hashDivRef.current?.parentElement
|
|
26
|
+
const cell = findParent('td', currentElement)
|
|
27
|
+
const row = findParent('tr', currentElement)
|
|
28
|
+
|
|
29
|
+
const checkWidth = (cell: HTMLElement) => {
|
|
30
|
+
const smallestParentWidth = getSmallestParentWidth(cell)
|
|
31
|
+
if (smallestParentWidth && row) {
|
|
32
|
+
const remainingWidth = getRemainingRowWidth(row, forCell)
|
|
33
|
+
const actualPaddingX = getActualPaddingX(cell)
|
|
34
|
+
const remainderWidth = smallestParentWidth - remainingWidth - actualPaddingX
|
|
35
|
+
cell.style.width = `${remainderWidth}`
|
|
36
|
+
setCalcCellWidth(remainderWidth)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const onResize = () => {
|
|
41
|
+
if (cell) {
|
|
42
|
+
checkWidth(cell)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (cell) {
|
|
47
|
+
checkWidth(cell)
|
|
48
|
+
window.addEventListener('resize', onResize)
|
|
49
|
+
row?.addEventListener('resize', onResize)
|
|
50
|
+
}
|
|
51
|
+
return () => {
|
|
52
|
+
window.removeEventListener('resize', onResize)
|
|
53
|
+
row?.removeEventListener('resize', onResize)
|
|
54
|
+
}
|
|
55
|
+
}, [forCell, hashDivRef])
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<TableCell {...props}>
|
|
59
|
+
<div ref={hashDivRef}>
|
|
60
|
+
{children ? (
|
|
61
|
+
<span
|
|
62
|
+
style={{
|
|
63
|
+
display: 'block',
|
|
64
|
+
maxWidth: calcCellWidth,
|
|
65
|
+
minWidth: theme.spacing(10),
|
|
66
|
+
overflow: 'hidden',
|
|
67
|
+
textOverflow: 'ellipsis',
|
|
68
|
+
whiteSpace: 'nowrap',
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</span>
|
|
73
|
+
) : href || to ? (
|
|
74
|
+
<LinkEx
|
|
75
|
+
style={{
|
|
76
|
+
display: 'block',
|
|
77
|
+
maxWidth: calcCellWidth,
|
|
78
|
+
minWidth: theme.spacing(10),
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
textOverflow: 'ellipsis',
|
|
81
|
+
whiteSpace: 'nowrap',
|
|
82
|
+
}}
|
|
83
|
+
to={to}
|
|
84
|
+
href={href}
|
|
85
|
+
target={href ? '_blank' : undefined}
|
|
86
|
+
>
|
|
87
|
+
{value}
|
|
88
|
+
</LinkEx>
|
|
89
|
+
) : (
|
|
90
|
+
<span
|
|
91
|
+
style={{
|
|
92
|
+
display: 'block',
|
|
93
|
+
maxWidth: calcCellWidth,
|
|
94
|
+
minWidth: theme.spacing(10),
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
textOverflow: 'ellipsis',
|
|
97
|
+
whiteSpace: 'nowrap',
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{value}
|
|
101
|
+
</span>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
</TableCell>
|
|
105
|
+
)
|
|
106
|
+
}
|