@xyo-network/react-shared 2.38.0-rc.5 → 2.38.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Ellipsize.d.ts +3 -0
- package/dist/cjs/components/Ellipsize.d.ts.map +1 -1
- package/dist/cjs/components/Ellipsize.js +16 -15
- package/dist/cjs/components/Ellipsize.js.map +1 -1
- package/dist/cjs/components/TableCell/EllipsisTableCell.js +1 -1
- package/dist/cjs/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/docs.json +1810 -1694
- package/dist/esm/components/Ellipsize.d.ts +3 -0
- package/dist/esm/components/Ellipsize.d.ts.map +1 -1
- package/dist/esm/components/Ellipsize.js +24 -13
- package/dist/esm/components/Ellipsize.js.map +1 -1
- package/dist/esm/components/TableCell/EllipsisTableCell.js +1 -1
- package/dist/esm/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Ellipsize.tsx +39 -23
- package/src/components/TableCell/EllipsisTableCell.tsx +1 -1
|
@@ -3,10 +3,13 @@ import { WithChildren } from '@xylabs/react-shared';
|
|
|
3
3
|
import React, { ElementType } from 'react';
|
|
4
4
|
interface TypographyWithComponentProps<Comp extends ElementType = ElementType> extends TypographyProps {
|
|
5
5
|
component?: Comp;
|
|
6
|
+
ellipsisPosition?: 'start' | 'end';
|
|
6
7
|
}
|
|
7
8
|
export interface EllipsizeBoxProps extends BoxProps {
|
|
8
9
|
typographyProps?: TypographyWithComponentProps;
|
|
10
|
+
ellipsisPosition?: 'start' | 'end';
|
|
9
11
|
}
|
|
12
|
+
export declare const EllipsizeBoxInner: React.FC<WithChildren<EllipsizeBoxProps>>;
|
|
10
13
|
export declare const EllipsizeBox: React.FC<WithChildren<EllipsizeBoxProps>>;
|
|
11
14
|
export {};
|
|
12
15
|
//# sourceMappingURL=Ellipsize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ellipsize.d.ts","sourceRoot":"","sources":["../../../src/components/Ellipsize.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAsB,eAAe,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"Ellipsize.d.ts","sourceRoot":"","sources":["../../../src/components/Ellipsize.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAsB,eAAe,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAqC,MAAM,OAAO,CAAA;AA0E7E,UAAU,4BAA4B,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,eAAe;IACpG,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,gBAAgB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CACnC;AAED,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,eAAe,CAAC,EAAE,4BAA4B,CAAA;IAC9C,gBAAgB,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CACnC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAevE,CAAA;AAGD,eAAO,MAAM,YAAY,2CAAoB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, styled, Typography } from '@mui/material';
|
|
3
|
-
import { useCallback, useState } from 'react';
|
|
3
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
|
|
6
6
|
*/
|
|
@@ -32,16 +32,25 @@ const EllipsizeInnerWrap = styled(Box, {
|
|
|
32
32
|
}));
|
|
33
33
|
const EllipsizeContentWrap = styled(Typography, {
|
|
34
34
|
name: ComponentName,
|
|
35
|
+
shouldForwardProp: (prop) => prop !== 'ellipsisPosition',
|
|
35
36
|
slot: 'contentWrap',
|
|
36
|
-
})(() =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
})(({ ellipsisPosition }) => {
|
|
38
|
+
return {
|
|
39
|
+
fontFamily: 'monospace',
|
|
40
|
+
left: 0,
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
right: 0,
|
|
44
|
+
textOverflow: 'ellipsis',
|
|
45
|
+
whiteSpace: 'nowrap',
|
|
46
|
+
...(ellipsisPosition === 'end'
|
|
47
|
+
? {
|
|
48
|
+
direction: 'rtl',
|
|
49
|
+
textAlign: 'left',
|
|
50
|
+
}
|
|
51
|
+
: {}),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
45
54
|
const useClientHeight = () => {
|
|
46
55
|
const [contentWrapHeight, setContentWrapHeight] = useState();
|
|
47
56
|
const contentWrapRef = useCallback((node) => {
|
|
@@ -51,9 +60,11 @@ const useClientHeight = () => {
|
|
|
51
60
|
}, []);
|
|
52
61
|
return { contentWrapHeight, contentWrapRef };
|
|
53
62
|
};
|
|
54
|
-
export const
|
|
63
|
+
export const EllipsizeBoxInner = forwardRef(({ children, ellipsisPosition = 'end', typographyProps, ...props }, ref) => {
|
|
55
64
|
// Allow syncing of :before pseudo element height with contentWrapHeight
|
|
56
65
|
const { contentWrapRef, contentWrapHeight } = useClientHeight();
|
|
57
|
-
return (_jsx(EllipsizeRoot, { beforeLineHeight: contentWrapHeight, ...props, children: _jsx(EllipsizeInnerWrap, { children: _jsx(EllipsizeContentWrap, { ref: contentWrapRef, component: 'span', ...typographyProps, children: children }) }) }));
|
|
58
|
-
};
|
|
66
|
+
return (_jsx(EllipsizeRoot, { beforeLineHeight: contentWrapHeight, ref: ref, ...props, children: _jsx(EllipsizeInnerWrap, { children: _jsx(EllipsizeContentWrap, { ref: contentWrapRef, component: 'span', ellipsisPosition: ellipsisPosition, ...typographyProps, children: children }) }) }));
|
|
67
|
+
});
|
|
68
|
+
EllipsizeBoxInner.displayName = 'EllipsizeBox';
|
|
69
|
+
export const EllipsizeBox = EllipsizeBoxInner;
|
|
59
70
|
//# sourceMappingURL=Ellipsize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ellipsize.js","sourceRoot":"","sources":["../../../src/components/Ellipsize.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAElF,OAAc,EAAe,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Ellipsize.js","sourceRoot":"","sources":["../../../src/components/Ellipsize.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAY,MAAM,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAA;AAElF,OAAc,EAAe,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE7E;;GAEG;AAEH,MAAM,aAAa,GAAG,WAAW,CAAA;AAMjC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,EAAE;IAChC,IAAI,EAAE,aAAa;IACnB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,kBAAkB;IACxD,IAAI,EAAE,MAAM;CACb,CAAC,CAAqB,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;IAChD,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;YACp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EAAE,cAAc,EAAE,CAAA;AAC9C,CAAC,CAAA;AAaD,MAAM,CAAC,MAAM,iBAAiB,GAA8C,UAAU,CACpF,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAG,KAAK,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACzE,wEAAwE;IACxE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,GAAG,eAAe,EAAE,CAAA;IAE/D,OAAO,CACL,KAAC,aAAa,IAAC,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,EAAE,GAAG,KAAM,KAAK,YACrE,KAAC,kBAAkB,cACjB,KAAC,oBAAoB,IAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,KAAM,eAAe,YAClH,QAAQ,GACY,GACJ,GACP,CACjB,CAAA;AACH,CAAC,CACF,CAAA;AAED,iBAAiB,CAAC,WAAW,GAAG,cAAc,CAAA;AAC9C,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAA"}
|
|
@@ -10,6 +10,6 @@ const EllipsisTableCellRoot = styled(TableCell, {
|
|
|
10
10
|
width,
|
|
11
11
|
}));
|
|
12
12
|
export const EllipsisTableCell = ({ children, href, to, value, ...props }) => {
|
|
13
|
-
return (_jsx(EllipsisTableCellRoot, { ...props, children: _jsx(EllipsizeBox, { children: children ? (children) : href || to ? (_jsx(LinkEx, { to: to, href: href, target: href ? '_blank' : undefined, children: value })) : (value) }) }));
|
|
13
|
+
return (_jsx(EllipsisTableCellRoot, { ...props, children: _jsx(EllipsizeBox, { children: children ? (children) : href || to ? (_jsx(LinkEx, { title: value, to: to, href: href, target: href ? '_blank' : undefined, children: value })) : (value) }) }));
|
|
14
14
|
};
|
|
15
15
|
//# sourceMappingURL=EllipsisTableCell.js.map
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,qBAAqB,GAAG,MAAM,CAAC,SAAS,EAAE;IAC9C,IAAI,EAAE,mBAAmB;IACzB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1B,KAAK;CACN,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,YAAY,cACV,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,
|
|
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,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,qBAAqB,GAAG,MAAM,CAAC,SAAS,EAAE;IAC9C,IAAI,EAAE,mBAAmB;IACzB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1B,KAAK;CACN,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,YAAY,cACV,QAAQ,CAAC,CAAC,CAAC,CACV,QAAQ,CACT,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CACf,KAAC,MAAM,IAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,YAC1E,KAAK,GACC,CACV,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACY,GACO,CACzB,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Box, BoxProps, styled, Typography, TypographyProps } from '@mui/material'
|
|
2
2
|
import { WithChildren } from '@xylabs/react-shared'
|
|
3
|
-
import React, { ElementType, useCallback, useState } from 'react'
|
|
3
|
+
import React, { ElementType, forwardRef, useCallback, useState } from 'react'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
|
|
@@ -41,16 +41,25 @@ const EllipsizeInnerWrap = styled(Box, {
|
|
|
41
41
|
|
|
42
42
|
const EllipsizeContentWrap = styled(Typography, {
|
|
43
43
|
name: ComponentName,
|
|
44
|
+
shouldForwardProp: (prop) => prop !== 'ellipsisPosition',
|
|
44
45
|
slot: 'contentWrap',
|
|
45
|
-
})<TypographyWithComponentProps>(() =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
})<TypographyWithComponentProps>(({ ellipsisPosition }) => {
|
|
47
|
+
return {
|
|
48
|
+
fontFamily: 'monospace',
|
|
49
|
+
left: 0,
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
right: 0,
|
|
53
|
+
textOverflow: 'ellipsis',
|
|
54
|
+
whiteSpace: 'nowrap',
|
|
55
|
+
...(ellipsisPosition === 'end'
|
|
56
|
+
? {
|
|
57
|
+
direction: 'rtl',
|
|
58
|
+
textAlign: 'left',
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
}
|
|
62
|
+
})
|
|
54
63
|
|
|
55
64
|
const useClientHeight = () => {
|
|
56
65
|
const [contentWrapHeight, setContentWrapHeight] = useState<string>()
|
|
@@ -67,23 +76,30 @@ const useClientHeight = () => {
|
|
|
67
76
|
// See - https://mui.com/material-ui/guides/composition/#with-typescript
|
|
68
77
|
interface TypographyWithComponentProps<Comp extends ElementType = ElementType> extends TypographyProps {
|
|
69
78
|
component?: Comp
|
|
79
|
+
ellipsisPosition?: 'start' | 'end'
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
export interface EllipsizeBoxProps extends BoxProps {
|
|
73
83
|
typographyProps?: TypographyWithComponentProps
|
|
84
|
+
ellipsisPosition?: 'start' | 'end'
|
|
74
85
|
}
|
|
75
86
|
|
|
76
|
-
export const
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
export const EllipsizeBoxInner: React.FC<WithChildren<EllipsizeBoxProps>> = forwardRef(
|
|
88
|
+
({ children, ellipsisPosition = 'end', typographyProps, ...props }, ref) => {
|
|
89
|
+
// Allow syncing of :before pseudo element height with contentWrapHeight
|
|
90
|
+
const { contentWrapRef, contentWrapHeight } = useClientHeight()
|
|
79
91
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
92
|
+
return (
|
|
93
|
+
<EllipsizeRoot beforeLineHeight={contentWrapHeight} ref={ref} {...props}>
|
|
94
|
+
<EllipsizeInnerWrap>
|
|
95
|
+
<EllipsizeContentWrap ref={contentWrapRef} component={'span'} ellipsisPosition={ellipsisPosition} {...typographyProps}>
|
|
96
|
+
{children}
|
|
97
|
+
</EllipsizeContentWrap>
|
|
98
|
+
</EllipsizeInnerWrap>
|
|
99
|
+
</EllipsizeRoot>
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
EllipsizeBoxInner.displayName = 'EllipsizeBox'
|
|
105
|
+
export const EllipsizeBox = EllipsizeBoxInner
|
|
@@ -33,7 +33,7 @@ export const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>> =
|
|
|
33
33
|
{children ? (
|
|
34
34
|
children
|
|
35
35
|
) : href || to ? (
|
|
36
|
-
<LinkEx to={to} href={href} target={href ? '_blank' : undefined}>
|
|
36
|
+
<LinkEx title={value} to={to} href={href} target={href ? '_blank' : undefined}>
|
|
37
37
|
{value}
|
|
38
38
|
</LinkEx>
|
|
39
39
|
) : (
|