@xyo-network/react-shared 2.37.6 → 2.37.8

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.
@@ -1,5 +1,12 @@
1
- /// <reference types="react" />
2
- import { BoxProps } from '@mui/material';
1
+ import { BoxProps, TypographyProps } from '@mui/material';
3
2
  import { WithChildren } from '@xylabs/react-shared';
4
- export declare const Ellipsize: React.FC<WithChildren<BoxProps>>;
3
+ import React, { ElementType } from 'react';
4
+ interface TypographyWithComponentProps<Comp extends ElementType = ElementType> extends TypographyProps {
5
+ component?: Comp;
6
+ }
7
+ export interface EllipsizeBoxProps extends BoxProps {
8
+ typographyProps?: TypographyWithComponentProps;
9
+ }
10
+ export declare const EllipsizeBox: React.FC<WithChildren<EllipsizeBoxProps>>;
11
+ export {};
5
12
  //# 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,EAAU,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AA6CnD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAQtD,CAAA"}
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,EAAyB,MAAM,OAAO,CAAA;AAiEjE,UAAU,4BAA4B,CAAC,IAAI,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,eAAe;IACpG,SAAS,CAAC,EAAE,IAAI,CAAA;CACjB;AAED,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,eAAe,CAAC,EAAE,4BAA4B,CAAA;CAC/C;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAalE,CAAA"}
@@ -1,13 +1,15 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Box, styled } from '@mui/material';
2
+ import { Box, styled, Typography } from '@mui/material';
3
+ import { useCallback, useState } from 'react';
3
4
  /**
4
5
  * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
5
6
  */
6
7
  const ComponentName = 'Ellipsize';
7
8
  const EllipsizeRoot = styled(Box, {
8
9
  name: ComponentName,
10
+ shouldForwardProp: (prop) => prop !== 'beforeLineHeight',
9
11
  slot: 'Root',
10
- })(() => ({
12
+ })(({ beforeLineHeight }) => ({
11
13
  '&': {
12
14
  // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
13
15
  // the pseudo element with a hidden character establishes the proper height of the content and hides it
@@ -17,6 +19,8 @@ const EllipsizeRoot = styled(Box, {
17
19
  // take the pseudo element out of the `display: block` flow so it won't push against our actual content
18
20
  float: 'left',
19
21
  visibility: 'hidden',
22
+ // since we are `display: block`, lineHeight is the height
23
+ ...(beforeLineHeight && { lineHeight: beforeLineHeight }),
20
24
  },
21
25
  },
22
26
  }));
@@ -26,7 +30,7 @@ const EllipsizeInnerWrap = styled(Box, {
26
30
  })(() => ({
27
31
  position: 'relative',
28
32
  }));
29
- const EllipsizeContentWrap = styled('span', {
33
+ const EllipsizeContentWrap = styled(Typography, {
30
34
  name: ComponentName,
31
35
  slot: 'contentWrap',
32
36
  })(() => ({
@@ -38,7 +42,18 @@ const EllipsizeContentWrap = styled('span', {
38
42
  textOverflow: 'ellipsis',
39
43
  whiteSpace: 'nowrap',
40
44
  }));
41
- export const Ellipsize = ({ children, ...props }) => {
42
- return (_jsx(EllipsizeRoot, { ...props, children: _jsx(EllipsizeInnerWrap, { children: _jsx(EllipsizeContentWrap, { children: children }) }) }));
45
+ const useClientHeight = () => {
46
+ const [contentWrapHeight, setContentWrapHeight] = useState();
47
+ const contentWrapRef = useCallback((node) => {
48
+ if (node !== null) {
49
+ setContentWrapHeight(node.clientHeight + 'px');
50
+ }
51
+ }, []);
52
+ return { contentWrapHeight, contentWrapRef };
53
+ };
54
+ export const EllipsizeBox = ({ children, typographyProps, ...props }) => {
55
+ // Allow syncing of :before pseudo element height with contentWrapHeight
56
+ const { contentWrapRef, contentWrapHeight } = useClientHeight();
57
+ return (_jsx(EllipsizeRoot, { beforeLineHeight: contentWrapHeight, ...props, children: _jsx(EllipsizeInnerWrap, { children: _jsx(EllipsizeContentWrap, { ref: contentWrapRef, component: 'span', ...typographyProps, children: children }) }) }));
43
58
  };
44
59
  //# 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,MAAM,eAAe,CAAA;AAGrD;;GAEG;AAEH,MAAM,aAAa,GAAG,WAAW,CAAA;AAEjC,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,EAAE;IAChC,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACR,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;KACF;CACF,CAAC,CAAC,CAAA;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,EAAE;IACrC,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,WAAW;CAClB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,UAAU;CACrB,CAAC,CAAC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AE,CAAA;IAE/D,OAAO,CACL,KAAC,aAAa,IAAC,gBAAgB,EAAE,iBAAiB,KAAM,KAAK,YAC3D,KAAC,kBAAkB,cACjB,KAAC,oBAAoB,IAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,KAAM,eAAe,YAC9E,QAAQ,GACY,GACJ,GACP,CACjB,CAAA;AACH,CAAC,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { styled, TableCell } from '@mui/material';
3
3
  import { LinkEx } from '@xylabs/react-link';
4
- import { Ellipsize } from '../Ellipsize';
4
+ import { EllipsizeBox } from '../Ellipsize';
5
5
  const EllipsisTableCellRoot = styled(TableCell, {
6
6
  name: 'EllipsisTableCell',
7
7
  shouldForwardProp: (prop) => prop !== 'width',
@@ -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(Ellipsize, { 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, { 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,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,qBAAqB,GAAG,MAAM,CAAC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AAE,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,YAC5D,KAAK,GACC,CACV,CAAC,CAAC,CAAC,CACF,KAAK,CACN,GACY,GACO,CACzB,CAAA;AACH,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './Ampersand';
2
2
  export * from './BasicHero';
3
+ export * from './Ellipsize';
3
4
  export * from './ErrorBoundry';
4
5
  export * from './ListItemButtonEx';
5
6
  export * from './NotFound';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './Ampersand';
2
2
  export * from './BasicHero';
3
+ export * from './Ellipsize';
3
4
  export * from './ErrorBoundry';
4
5
  export * from './ListItemButtonEx';
5
6
  export * from './NotFound';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA"}
package/package.json CHANGED
@@ -69,5 +69,5 @@
69
69
  },
70
70
  "sideEffects": false,
71
71
  "types": "dist/esm/index.d.ts",
72
- "version": "2.37.6"
72
+ "version": "2.37.8"
73
73
  }
@@ -1,5 +1,6 @@
1
- import { Box, BoxProps, styled } from '@mui/material'
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
4
 
4
5
  /**
5
6
  * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
@@ -7,10 +8,15 @@ import { WithChildren } from '@xylabs/react-shared'
7
8
 
8
9
  const ComponentName = 'Ellipsize'
9
10
 
11
+ interface EllipsizeRootProps {
12
+ beforeLineHeight?: string | number
13
+ }
14
+
10
15
  const EllipsizeRoot = styled(Box, {
11
16
  name: ComponentName,
17
+ shouldForwardProp: (prop) => prop !== 'beforeLineHeight',
12
18
  slot: 'Root',
13
- })(() => ({
19
+ })<EllipsizeRootProps>(({ beforeLineHeight }) => ({
14
20
  '&': {
15
21
  // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
16
22
  // the pseudo element with a hidden character establishes the proper height of the content and hides it
@@ -20,6 +26,8 @@ const EllipsizeRoot = styled(Box, {
20
26
  // take the pseudo element out of the `display: block` flow so it won't push against our actual content
21
27
  float: 'left',
22
28
  visibility: 'hidden',
29
+ // since we are `display: block`, lineHeight is the height
30
+ ...(beforeLineHeight && { lineHeight: beforeLineHeight }),
23
31
  },
24
32
  },
25
33
  }))
@@ -31,10 +39,10 @@ const EllipsizeInnerWrap = styled(Box, {
31
39
  position: 'relative',
32
40
  }))
33
41
 
34
- const EllipsizeContentWrap = styled('span', {
42
+ const EllipsizeContentWrap = styled(Typography, {
35
43
  name: ComponentName,
36
44
  slot: 'contentWrap',
37
- })(() => ({
45
+ })<TypographyWithComponentProps>(() => ({
38
46
  fontFamily: 'monospace',
39
47
  left: 0,
40
48
  overflow: 'hidden',
@@ -44,11 +52,37 @@ const EllipsizeContentWrap = styled('span', {
44
52
  whiteSpace: 'nowrap',
45
53
  }))
46
54
 
47
- export const Ellipsize: React.FC<WithChildren<BoxProps>> = ({ children, ...props }) => {
55
+ const useClientHeight = () => {
56
+ const [contentWrapHeight, setContentWrapHeight] = useState<string>()
57
+
58
+ const contentWrapRef = useCallback((node: HTMLElement) => {
59
+ if (node !== null) {
60
+ setContentWrapHeight(node.clientHeight + 'px')
61
+ }
62
+ }, [])
63
+
64
+ return { contentWrapHeight, contentWrapRef }
65
+ }
66
+
67
+ // See - https://mui.com/material-ui/guides/composition/#with-typescript
68
+ interface TypographyWithComponentProps<Comp extends ElementType = ElementType> extends TypographyProps {
69
+ component?: Comp
70
+ }
71
+
72
+ export interface EllipsizeBoxProps extends BoxProps {
73
+ typographyProps?: TypographyWithComponentProps
74
+ }
75
+
76
+ export const EllipsizeBox: React.FC<WithChildren<EllipsizeBoxProps>> = ({ children, typographyProps, ...props }) => {
77
+ // Allow syncing of :before pseudo element height with contentWrapHeight
78
+ const { contentWrapRef, contentWrapHeight } = useClientHeight()
79
+
48
80
  return (
49
- <EllipsizeRoot {...props}>
81
+ <EllipsizeRoot beforeLineHeight={contentWrapHeight} {...props}>
50
82
  <EllipsizeInnerWrap>
51
- <EllipsizeContentWrap>{children}</EllipsizeContentWrap>
83
+ <EllipsizeContentWrap ref={contentWrapRef} component={'span'} {...typographyProps}>
84
+ {children}
85
+ </EllipsizeContentWrap>
52
86
  </EllipsizeInnerWrap>
53
87
  </EllipsizeRoot>
54
88
  )
@@ -3,7 +3,7 @@ import { LinkEx } from '@xylabs/react-link'
3
3
  import { WithChildren } from '@xylabs/react-shared'
4
4
  import { To } from 'react-router-dom'
5
5
 
6
- import { Ellipsize } from '../Ellipsize'
6
+ import { EllipsizeBox } from '../Ellipsize'
7
7
 
8
8
  const EllipsisTableCellRoot = styled(TableCell, {
9
9
  name: 'EllipsisTableCell',
@@ -29,7 +29,7 @@ export interface EllipsisTableCellProps extends TableCellProps {
29
29
  export const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>> = ({ children, href, to, value, ...props }) => {
30
30
  return (
31
31
  <EllipsisTableCellRoot {...props}>
32
- <Ellipsize>
32
+ <EllipsizeBox>
33
33
  {children ? (
34
34
  children
35
35
  ) : href || to ? (
@@ -39,7 +39,7 @@ export const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>> =
39
39
  ) : (
40
40
  value
41
41
  )}
42
- </Ellipsize>
42
+ </EllipsizeBox>
43
43
  </EllipsisTableCellRoot>
44
44
  )
45
45
  }
@@ -1,5 +1,6 @@
1
1
  export * from './Ampersand'
2
2
  export * from './BasicHero'
3
+ export * from './Ellipsize'
3
4
  export * from './ErrorBoundry'
4
5
  export * from './ListItemButtonEx'
5
6
  export * from './NotFound'