@xyo-network/react-shared 2.37.2 → 2.37.4

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.
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { BoxProps } from '@mui/material';
3
+ import { WithChildren } from '@xylabs/react-shared';
4
+ export declare const Ellipsize: React.FC<WithChildren<BoxProps>>;
5
+ //# sourceMappingURL=Ellipsize.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, styled } from '@mui/material';
3
+ /**
4
+ * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
5
+ */
6
+ const ComponentName = 'Ellipsize';
7
+ const EllipsizeRoot = styled(Box, {
8
+ name: ComponentName,
9
+ slot: 'Root',
10
+ })(() => ({
11
+ '&': {
12
+ // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
13
+ // the pseudo element with a hidden character establishes the proper height of the content and hides it
14
+ ':before': {
15
+ content: "'nbsp;'",
16
+ display: 'block',
17
+ // take the pseudo element out of the `display: block` flow so it won't push against our actual content
18
+ float: 'left',
19
+ visibility: 'hidden',
20
+ },
21
+ },
22
+ }));
23
+ const EllipsizeInnerWrap = styled(Box, {
24
+ name: ComponentName,
25
+ slot: 'innerWrap',
26
+ })(() => ({
27
+ position: 'relative',
28
+ }));
29
+ const EllipsizeContentWrap = styled('span', {
30
+ name: ComponentName,
31
+ slot: 'contentWrap',
32
+ })(() => ({
33
+ fontFamily: 'monospace',
34
+ left: 0,
35
+ overflow: 'hidden',
36
+ position: 'absolute',
37
+ right: 0,
38
+ textOverflow: 'ellipsis',
39
+ whiteSpace: 'nowrap',
40
+ }));
41
+ export const Ellipsize = ({ children, ...props }) => {
42
+ return (_jsx(EllipsizeRoot, { ...props, children: _jsx(EllipsizeInnerWrap, { children: _jsx(EllipsizeContentWrap, { children: children }) }) }));
43
+ };
44
+ //# sourceMappingURL=Ellipsize.js.map
@@ -0,0 +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,CAAA;AAEH,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE;IAC1C,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;CACpB,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,WAAW;IACvB,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,SAAS,GAAqC,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACpF,OAAO,CACL,KAAC,aAAa,OAAK,KAAK,YACtB,KAAC,kBAAkB,cACjB,KAAC,oBAAoB,cAAE,QAAQ,GAAwB,GACpC,GACP,CACjB,CAAA;AACH,CAAC,CAAA"}
@@ -1 +1 @@
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
+ {"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;AAYrC,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,CAgB5E,CAAA"}
@@ -1,46 +1,15 @@
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
- /**
5
- * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
6
- */
7
- const ComponentName = 'EllipsisTableCell';
4
+ import { Ellipsize } from '../Ellipsize';
8
5
  const EllipsisTableCellRoot = styled(TableCell, {
9
- name: ComponentName,
6
+ name: 'EllipsisTableCell',
10
7
  shouldForwardProp: (prop) => prop !== 'width',
11
8
  slot: 'Root',
12
9
  })(({ 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',
10
+ width,
42
11
  }));
43
12
  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) }) }) }));
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) }) }));
45
14
  };
46
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;;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,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iB,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,SAAS,cACP,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,GACS,GACU,CACzB,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.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",
14
+ "@xylabs/react-appbar": "^2.15.1",
15
+ "@xylabs/react-button": "^2.15.1",
16
+ "@xylabs/react-flexbox": "^2.15.1",
17
+ "@xylabs/react-link": "^2.15.1",
18
+ "@xylabs/react-shared": "^2.15.1",
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.2"
72
+ "version": "2.37.4"
73
73
  }
@@ -0,0 +1,55 @@
1
+ import { Box, BoxProps, styled } from '@mui/material'
2
+ import { WithChildren } from '@xylabs/react-shared'
3
+
4
+ /**
5
+ * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
6
+ */
7
+
8
+ const ComponentName = 'Ellipsize'
9
+
10
+ const EllipsizeRoot = styled(Box, {
11
+ name: ComponentName,
12
+ slot: 'Root',
13
+ })(() => ({
14
+ '&': {
15
+ // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
16
+ // the pseudo element with a hidden character establishes the proper height of the content and hides it
17
+ ':before': {
18
+ content: "'nbsp;'",
19
+ display: 'block',
20
+ // take the pseudo element out of the `display: block` flow so it won't push against our actual content
21
+ float: 'left',
22
+ visibility: 'hidden',
23
+ },
24
+ },
25
+ }))
26
+
27
+ const EllipsizeInnerWrap = styled(Box, {
28
+ name: ComponentName,
29
+ slot: 'innerWrap',
30
+ })(() => ({
31
+ position: 'relative',
32
+ }))
33
+
34
+ const EllipsizeContentWrap = styled('span', {
35
+ name: ComponentName,
36
+ slot: 'contentWrap',
37
+ })(() => ({
38
+ fontFamily: 'monospace',
39
+ left: 0,
40
+ overflow: 'hidden',
41
+ position: 'absolute',
42
+ right: 0,
43
+ textOverflow: 'ellipsis',
44
+ whiteSpace: 'nowrap',
45
+ }))
46
+
47
+ export const Ellipsize: React.FC<WithChildren<BoxProps>> = ({ children, ...props }) => {
48
+ return (
49
+ <EllipsizeRoot {...props}>
50
+ <EllipsizeInnerWrap>
51
+ <EllipsizeContentWrap>{children}</EllipsizeContentWrap>
52
+ </EllipsizeInnerWrap>
53
+ </EllipsizeRoot>
54
+ )
55
+ }
@@ -3,48 +3,14 @@ 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
- /**
7
- * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259
8
- */
9
-
10
- const ComponentName = 'EllipsisTableCell'
6
+ import { Ellipsize } from '../Ellipsize'
11
7
 
12
8
  const EllipsisTableCellRoot = styled(TableCell, {
13
- name: ComponentName,
9
+ name: 'EllipsisTableCell',
14
10
  shouldForwardProp: (prop) => prop !== 'width',
15
11
  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
- }))
30
-
31
- const EllipsisTableCellInnerWrap = styled('div', {
32
- name: ComponentName,
33
- slot: 'innerWrap',
34
- })(() => ({
35
- position: 'relative',
36
- }))
37
-
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',
12
+ })(({ width = '100%' }) => ({
13
+ width,
48
14
  }))
49
15
 
50
16
  export interface EllipsisTableCellProps extends TableCellProps {
@@ -63,19 +29,17 @@ export interface EllipsisTableCellProps extends TableCellProps {
63
29
  export const EllipsisTableCell: React.FC<WithChildren<EllipsisTableCellProps>> = ({ children, href, to, value, ...props }) => {
64
30
  return (
65
31
  <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>
32
+ <Ellipsize>
33
+ {children ? (
34
+ children
35
+ ) : href || to ? (
36
+ <LinkEx to={to} href={href} target={href ? '_blank' : undefined}>
37
+ {value}
38
+ </LinkEx>
39
+ ) : (
40
+ value
41
+ )}
42
+ </Ellipsize>
79
43
  </EllipsisTableCellRoot>
80
44
  )
81
45
  }