@xyo-network/react-shared 2.64.0 → 2.64.2

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.
Files changed (147) hide show
  1. package/dist/browser/components/Ampersand.js +3 -2
  2. package/dist/browser/components/Ampersand.js.map +1 -1
  3. package/dist/browser/components/BasicHero/BasicHero.js +71 -5
  4. package/dist/browser/components/BasicHero/BasicHero.js.map +1 -1
  5. package/dist/browser/components/BasicHero/index.js +203 -1
  6. package/dist/browser/components/BasicHero/index.js.map +1 -1
  7. package/dist/browser/components/Ellipsize.js +28 -8
  8. package/dist/browser/components/Ellipsize.js.map +1 -1
  9. package/dist/browser/components/ErrorBoundary.js +4 -3
  10. package/dist/browser/components/ErrorBoundary.js.map +1 -1
  11. package/dist/browser/components/ListItemButtonEx.js +4 -3
  12. package/dist/browser/components/ListItemButtonEx.js.map +1 -1
  13. package/dist/browser/components/LoadResult.js +19 -6
  14. package/dist/browser/components/LoadResult.js.map +1 -1
  15. package/dist/browser/components/NotFound.js +3 -2
  16. package/dist/browser/components/NotFound.js.map +1 -1
  17. package/dist/browser/components/Pipe.js +3 -2
  18. package/dist/browser/components/Pipe.js.map +1 -1
  19. package/dist/browser/components/ScrollTableOnSm.js +4 -3
  20. package/dist/browser/components/ScrollTableOnSm.js.map +1 -1
  21. package/dist/browser/components/SectionSpacingRow/SectionSpacingRow.js +3 -2
  22. package/dist/browser/components/SectionSpacingRow/SectionSpacingRow.js.map +1 -1
  23. package/dist/browser/components/SectionSpacingRow/index.js +26 -1
  24. package/dist/browser/components/SectionSpacingRow/index.js.map +1 -1
  25. package/dist/browser/components/StyleGuide/AppBars.example.js +3 -2
  26. package/dist/browser/components/StyleGuide/AppBars.example.js.map +1 -1
  27. package/dist/browser/components/StyleGuide/Buttons.example.js +5 -4
  28. package/dist/browser/components/StyleGuide/Buttons.example.js.map +1 -1
  29. package/dist/browser/components/StyleGuide/Papers.example.js +3 -2
  30. package/dist/browser/components/StyleGuide/Papers.example.js.map +1 -1
  31. package/dist/browser/components/StyleGuide/StyleGuide.example.js +99 -12
  32. package/dist/browser/components/StyleGuide/StyleGuide.example.js.map +1 -1
  33. package/dist/browser/components/StyleGuide/Texts.example.js +3 -2
  34. package/dist/browser/components/StyleGuide/Texts.example.js.map +1 -1
  35. package/dist/browser/components/StyleGuide/VariantContext.example.js +2 -1
  36. package/dist/browser/components/StyleGuide/VariantContext.example.js.map +1 -1
  37. package/dist/browser/components/TableCell/AddressTableCell.js +124 -4
  38. package/dist/browser/components/TableCell/AddressTableCell.js.map +1 -1
  39. package/dist/browser/components/TableCell/EllipsisTableCell.js +98 -9
  40. package/dist/browser/components/TableCell/EllipsisTableCell.js.map +1 -1
  41. package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.js +107 -6
  42. package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.js.map +1 -1
  43. package/dist/browser/components/TableCell/HashTableCell.js +126 -6
  44. package/dist/browser/components/TableCell/HashTableCell.js.map +1 -1
  45. package/dist/browser/components/TableCell/findParent.js +2 -1
  46. package/dist/browser/components/TableCell/findParent.js.map +1 -1
  47. package/dist/browser/components/TableCell/getRemainingRowWidth.js +2 -1
  48. package/dist/browser/components/TableCell/getRemainingRowWidth.js.map +1 -1
  49. package/dist/browser/components/TableCell/getSmallestParentWidth.js +2 -1
  50. package/dist/browser/components/TableCell/getSmallestParentWidth.js.map +1 -1
  51. package/dist/browser/components/TableCell/index.js +160 -3
  52. package/dist/browser/components/TableCell/index.js.map +1 -1
  53. package/dist/browser/components/ThemeTokenAvatar/ThemeTokenAvatar.js +3 -2
  54. package/dist/browser/components/ThemeTokenAvatar/ThemeTokenAvatar.js.map +1 -1
  55. package/dist/browser/components/ThemeTokenAvatar/index.js +10 -1
  56. package/dist/browser/components/ThemeTokenAvatar/index.js.map +1 -1
  57. package/dist/browser/components/ThemeTokenAvatarGroup/ThemeTokenAvatarGroup.js +14 -4
  58. package/dist/browser/components/ThemeTokenAvatarGroup/ThemeTokenAvatarGroup.js.map +1 -1
  59. package/dist/browser/components/ThemeTokenAvatarGroup/index.js +19 -1
  60. package/dist/browser/components/ThemeTokenAvatarGroup/index.js.map +1 -1
  61. package/dist/browser/components/TokenBar/TokenBar.js +3 -2
  62. package/dist/browser/components/TokenBar/TokenBar.js.map +1 -1
  63. package/dist/browser/components/TokenBar/index.js +19 -1
  64. package/dist/browser/components/TokenBar/index.js.map +1 -1
  65. package/dist/browser/components/TokenData/TokenData.js +34 -17
  66. package/dist/browser/components/TokenData/TokenData.js.map +1 -1
  67. package/dist/browser/components/TokenData/img/index.js +1 -0
  68. package/dist/browser/components/TokenData/img/index.js.map +1 -1
  69. package/dist/browser/components/TokenData/index.js +153 -2
  70. package/dist/browser/components/TokenData/index.js.map +1 -1
  71. package/dist/browser/components/TokenData/useGetTokenData.js +143 -2
  72. package/dist/browser/components/TokenData/useGetTokenData.js.map +1 -1
  73. package/dist/browser/components/TokenSummary/TokenSummary.js +16 -6
  74. package/dist/browser/components/TokenSummary/TokenSummary.js.map +1 -1
  75. package/dist/browser/components/TokenSummary/index.js +29 -1
  76. package/dist/browser/components/TokenSummary/index.js.map +1 -1
  77. package/dist/browser/components/TypographyEx.js +57 -3
  78. package/dist/browser/components/TypographyEx.js.map +1 -1
  79. package/dist/browser/components/index.js +730 -18
  80. package/dist/browser/components/index.js.map +1 -1
  81. package/dist/browser/components/pluginValidation/DataMissing.js +3 -2
  82. package/dist/browser/components/pluginValidation/DataMissing.js.map +1 -1
  83. package/dist/browser/components/pluginValidation/index.js +12 -1
  84. package/dist/browser/components/pluginValidation/index.js.map +1 -1
  85. package/dist/browser/contexts/ListMode/Context.js +6 -2
  86. package/dist/browser/contexts/ListMode/Context.js.map +1 -1
  87. package/dist/browser/contexts/ListMode/Provider.js +12 -3
  88. package/dist/browser/contexts/ListMode/Provider.js.map +1 -1
  89. package/dist/browser/contexts/ListMode/index.js +44 -4
  90. package/dist/browser/contexts/ListMode/index.js.map +1 -1
  91. package/dist/browser/contexts/ListMode/use.js +19 -3
  92. package/dist/browser/contexts/ListMode/use.js.map +1 -1
  93. package/dist/browser/contexts/Pixel/Context.js +6 -2
  94. package/dist/browser/contexts/Pixel/Context.js.map +1 -1
  95. package/dist/browser/contexts/Pixel/Provider.js +12 -3
  96. package/dist/browser/contexts/Pixel/Provider.js.map +1 -1
  97. package/dist/browser/contexts/Pixel/index.js +45 -4
  98. package/dist/browser/contexts/Pixel/index.js.map +1 -1
  99. package/dist/browser/contexts/Pixel/use.js +19 -3
  100. package/dist/browser/contexts/Pixel/use.js.map +1 -1
  101. package/dist/browser/contexts/contextEx/create.js +2 -1
  102. package/dist/browser/contexts/contextEx/create.js.map +1 -1
  103. package/dist/browser/contexts/contextEx/index.js +22 -4
  104. package/dist/browser/contexts/contextEx/index.js.map +1 -1
  105. package/dist/browser/contexts/contextEx/use.js +3 -2
  106. package/dist/browser/contexts/contextEx/use.js.map +1 -1
  107. package/dist/browser/contexts/diviner/Context.js +6 -2
  108. package/dist/browser/contexts/diviner/Context.js.map +1 -1
  109. package/dist/browser/contexts/diviner/Provider.js +3 -2
  110. package/dist/browser/contexts/diviner/Provider.js.map +1 -1
  111. package/dist/browser/contexts/diviner/index.js +40 -3
  112. package/dist/browser/contexts/diviner/index.js.map +1 -1
  113. package/dist/browser/contexts/index.js +116 -4
  114. package/dist/browser/contexts/index.js.map +1 -1
  115. package/dist/browser/hooks/GradientStyles/GradientStyles.js +4 -3
  116. package/dist/browser/hooks/GradientStyles/GradientStyles.js.map +1 -1
  117. package/dist/browser/hooks/GradientStyles/index.js +56 -1
  118. package/dist/browser/hooks/GradientStyles/index.js.map +1 -1
  119. package/dist/browser/hooks/index.js +126 -7
  120. package/dist/browser/hooks/index.js.map +1 -1
  121. package/dist/browser/hooks/useDataState.js +2 -1
  122. package/dist/browser/hooks/useDataState.js.map +1 -1
  123. package/dist/browser/hooks/useIsMobile.js +7 -2
  124. package/dist/browser/hooks/useIsMobile.js.map +1 -1
  125. package/dist/browser/hooks/useMediaQuery.js +1 -0
  126. package/dist/browser/hooks/useMediaQuery.js.map +1 -1
  127. package/dist/browser/hooks/usePayloadHash.js +3 -2
  128. package/dist/browser/hooks/usePayloadHash.js.map +1 -1
  129. package/dist/browser/hooks/usePromise.js +2 -1
  130. package/dist/browser/hooks/usePromise.js.map +1 -1
  131. package/dist/browser/hooks/useShareForwardRef.js +2 -1
  132. package/dist/browser/hooks/useShareForwardRef.js.map +1 -1
  133. package/dist/browser/index.js +988 -6
  134. package/dist/browser/index.js.map +1 -1
  135. package/dist/browser/lib/assertDefinedEx.js +2 -1
  136. package/dist/browser/lib/assertDefinedEx.js.map +1 -1
  137. package/dist/browser/lib/getActualPaddingX.js +4 -3
  138. package/dist/browser/lib/getActualPaddingX.js.map +1 -1
  139. package/dist/browser/lib/index.js +101 -3
  140. package/dist/browser/lib/index.js.map +1 -1
  141. package/dist/browser/lib/networkComponents.js +5 -4
  142. package/dist/browser/lib/networkComponents.js.map +1 -1
  143. package/dist/browser/lib/xyo.js +3 -2
  144. package/dist/browser/lib/xyo.js.map +1 -1
  145. package/dist/browser/models/index.js +0 -1
  146. package/dist/browser/models/index.js.map +1 -1
  147. package/package.json +13 -13
@@ -1,31 +1,120 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { styled, TableCell } from "@mui/material";
1
+ // src/components/TableCell/EllipsisTableCell.tsx
2
+ import { styled as styled2, TableCell } from "@mui/material";
3
3
  import { LinkEx } from "@xylabs/react-link";
4
- import { forwardRef, useMemo } from "react";
5
- import { EllipsizeBox } from "../Ellipsize";
6
- const EllipsisTableCellRoot = styled(TableCell, {
4
+ import { forwardRef as forwardRef2, useMemo } from "react";
5
+
6
+ // src/components/Ellipsize.tsx
7
+ import { Box, styled, Typography } from "@mui/material";
8
+ import { forwardRef, useCallback, useState } from "react";
9
+
10
+ // src/hooks/useShareForwardRef.ts
11
+ import { useEffect, useRef } from "react";
12
+ var useShareForwardedRef = (forwardedRef, refresh = 0) => {
13
+ const innerRef = useRef(null);
14
+ useEffect(() => {
15
+ if (!forwardedRef) {
16
+ return;
17
+ }
18
+ if (typeof forwardedRef === "function") {
19
+ forwardedRef(innerRef.current);
20
+ return;
21
+ } else {
22
+ forwardedRef.current = innerRef.current;
23
+ }
24
+ }, [forwardedRef, refresh]);
25
+ return innerRef;
26
+ };
27
+
28
+ // src/components/Ellipsize.tsx
29
+ import { jsx } from "react/jsx-runtime";
30
+ var ComponentName = "Ellipsize";
31
+ var EllipsizeRoot = styled(Box, {
32
+ name: ComponentName,
33
+ shouldForwardProp: (prop) => prop !== "beforeLineHeight",
34
+ slot: "Root"
35
+ })(({ beforeLineHeight }) => ({
36
+ "&": {
37
+ // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
38
+ // the pseudo element with a hidden character establishes the proper height of the content and hides it
39
+ ":before": {
40
+ content: "'nbsp;'",
41
+ display: "block",
42
+ // take the pseudo element out of the `display: block` flow so it won't push against our actual content
43
+ float: "left",
44
+ visibility: "hidden",
45
+ // since we are `display: block`, lineHeight is the height
46
+ ...beforeLineHeight && { lineHeight: beforeLineHeight }
47
+ }
48
+ }
49
+ }));
50
+ var EllipsizeInnerWrap = styled(Box, {
51
+ name: ComponentName,
52
+ slot: "innerWrap"
53
+ })(() => ({
54
+ position: "relative"
55
+ }));
56
+ var EllipsizeContentWrap = styled(Typography, {
57
+ name: ComponentName,
58
+ shouldForwardProp: (prop) => prop !== "ellipsisPosition",
59
+ slot: "contentWrap"
60
+ })(({ theme, ellipsisPosition, fontFamily }) => {
61
+ return theme.unstable_sx({
62
+ fontFamily: fontFamily ?? "monospace",
63
+ left: 0,
64
+ overflow: "hidden",
65
+ position: "absolute",
66
+ right: 0,
67
+ textOverflow: "ellipsis",
68
+ whiteSpace: "nowrap",
69
+ ...ellipsisPosition === "start" ? {
70
+ direction: "rtl",
71
+ textAlign: "left"
72
+ } : {}
73
+ });
74
+ });
75
+ var useClientHeight = () => {
76
+ const [contentWrapHeight, setContentWrapHeight] = useState();
77
+ const contentWrapRef = useCallback((node) => {
78
+ if (node !== null) {
79
+ setContentWrapHeight(node.clientHeight + "px");
80
+ }
81
+ }, []);
82
+ return { contentWrapHeight, contentWrapRef };
83
+ };
84
+ var EllipsizeBox = forwardRef(
85
+ ({ children, ellipsisPosition = "start", disableSharedRef, typographyProps, ...props }, ref) => {
86
+ const { contentWrapRef, contentWrapHeight } = useClientHeight();
87
+ const sharedRef = useShareForwardedRef(ref);
88
+ return /* @__PURE__ */ jsx(EllipsizeRoot, { beforeLineHeight: !!sharedRef && !disableSharedRef ? contentWrapHeight : void 0, ...props, ref, children: /* @__PURE__ */ jsx(EllipsizeInnerWrap, { children: /* @__PURE__ */ jsx(EllipsizeContentWrap, { ref: contentWrapRef, component: "span", ellipsisPosition, variant: "body2", ...typographyProps, children }) }) });
89
+ }
90
+ );
91
+ EllipsizeBox.displayName = "EllipsizeBox";
92
+
93
+ // src/components/TableCell/EllipsisTableCell.tsx
94
+ import { jsx as jsx2 } from "react/jsx-runtime";
95
+ var EllipsisTableCellRoot = styled2(TableCell, {
7
96
  name: "EllipsisTableCell",
8
97
  shouldForwardProp: (prop) => prop !== "width",
9
98
  slot: "Root"
10
99
  })(({ width = "100%" }) => ({
11
100
  width
12
101
  }));
13
- const EllipsisTableCellWithRef = forwardRef(
102
+ var EllipsisTableCellWithRef = forwardRef2(
14
103
  ({ children, href, link = false, to, value, ...props }, ref) => {
15
104
  const data = useMemo(() => {
16
105
  if (children) {
17
106
  return children;
18
107
  }
19
108
  if (href || link || to) {
20
- return /* @__PURE__ */ jsx(LinkEx, { title: value, to, href, target: href ? "_blank" : void 0, children: value });
109
+ return /* @__PURE__ */ jsx2(LinkEx, { title: value, to, href, target: href ? "_blank" : void 0, children: value });
21
110
  }
22
111
  return value;
23
112
  }, [children, href, link, to, value]);
24
- return /* @__PURE__ */ jsx(EllipsisTableCellRoot, { ref, ...props, children: /* @__PURE__ */ jsx(EllipsizeBox, { sx: { cursor: link || to || href ? "pointer" : "inherit" }, children: data }) });
113
+ return /* @__PURE__ */ jsx2(EllipsisTableCellRoot, { ref, ...props, children: /* @__PURE__ */ jsx2(EllipsizeBox, { sx: { cursor: link || to || href ? "pointer" : "inherit" }, children: data }) });
25
114
  }
26
115
  );
27
116
  EllipsisTableCellWithRef.displayName = "EllipsisTableCell";
28
- const EllipsisTableCell = EllipsisTableCellWithRef;
117
+ var EllipsisTableCell = EllipsisTableCellWithRef;
29
118
  export {
30
119
  EllipsisTableCell,
31
120
  EllipsisTableCellWithRef
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport { forwardRef, useMemo } from 'react'\nimport { To } from 'react-router-dom'\n\nimport { EllipsizeBox } from '../Ellipsize'\n\nconst EllipsisTableCellRoot = styled(TableCell, {\n name: 'EllipsisTableCell',\n shouldForwardProp: (prop) => prop !== 'width',\n slot: 'Root',\n})(({ width = '100%' }) => ({\n width,\n}))\n\nexport interface EllipsisTableCellProps extends TableCellProps {\n href?: string\n link?: boolean\n to?: To\n value?: string\n /**\n * Width of the table cell.\n *\n * Note: When using percentages, this value can be different than what you expect\n * if used on a cell that is not the first cell in the first row.\n */\n width?: string | number\n}\n\nexport const EllipsisTableCellWithRef: React.FC<WithChildren<EllipsisTableCellProps>> = forwardRef(\n ({ children, href, link = false, to, value, ...props }, ref) => {\n const data = useMemo(() => {\n if (children) {\n return children\n }\n if (href || link || to) {\n return (\n <LinkEx title={value} to={to} href={href} target={href ? '_blank' : undefined}>\n {value}\n </LinkEx>\n )\n }\n return value\n }, [children, href, link, to, value])\n return (\n <EllipsisTableCellRoot ref={ref} {...props}>\n <EllipsizeBox sx={{ cursor: link || to || href ? 'pointer' : 'inherit' }}>{data}</EllipsizeBox>\n </EllipsisTableCellRoot>\n )\n },\n)\n\nEllipsisTableCellWithRef.displayName = 'EllipsisTableCell'\nexport const EllipsisTableCell = EllipsisTableCellWithRef\n"],"mappings":"AAsCU;AAtCV,SAAS,QAAQ,iBAAiC;AAClD,SAAS,cAAc;AAEvB,SAAS,YAAY,eAAe;AAGpC,SAAS,oBAAoB;AAE7B,MAAM,wBAAwB,OAAO,WAAW;AAAA,EAC9C,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,SAAS;AAAA,EACtC,MAAM;AACR,CAAC,EAAE,CAAC,EAAE,QAAQ,OAAO,OAAO;AAAA,EAC1B;AACF,EAAE;AAgBK,MAAM,2BAA2E;AAAA,EACtF,CAAC,EAAE,UAAU,MAAM,OAAO,OAAO,IAAI,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC9D,UAAM,OAAO,QAAQ,MAAM;AACzB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,QAAQ,IAAI;AACtB,eACE,oBAAC,UAAO,OAAO,OAAO,IAAQ,MAAY,QAAQ,OAAO,WAAW,QACjE,iBACH;AAAA,MAEJ;AACA,aAAO;AAAA,IACT,GAAG,CAAC,UAAU,MAAM,MAAM,IAAI,KAAK,CAAC;AACpC,WACE,oBAAC,yBAAsB,KAAW,GAAG,OACnC,8BAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,MAAM,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport { forwardRef, useMemo } from 'react'\nimport { To } from 'react-router-dom'\n\nimport { EllipsizeBox } from '../Ellipsize'\n\nconst EllipsisTableCellRoot = styled(TableCell, {\n name: 'EllipsisTableCell',\n shouldForwardProp: (prop) => prop !== 'width',\n slot: 'Root',\n})(({ width = '100%' }) => ({\n width,\n}))\n\nexport interface EllipsisTableCellProps extends TableCellProps {\n href?: string\n link?: boolean\n to?: To\n value?: string\n /**\n * Width of the table cell.\n *\n * Note: When using percentages, this value can be different than what you expect\n * if used on a cell that is not the first cell in the first row.\n */\n width?: string | number\n}\n\nexport const EllipsisTableCellWithRef: React.FC<WithChildren<EllipsisTableCellProps>> = forwardRef(\n ({ children, href, link = false, to, value, ...props }, ref) => {\n const data = useMemo(() => {\n if (children) {\n return children\n }\n if (href || link || to) {\n return (\n <LinkEx title={value} to={to} href={href} target={href ? '_blank' : undefined}>\n {value}\n </LinkEx>\n )\n }\n return value\n }, [children, href, link, to, value])\n return (\n <EllipsisTableCellRoot ref={ref} {...props}>\n <EllipsizeBox sx={{ cursor: link || to || href ? 'pointer' : 'inherit' }}>{data}</EllipsizeBox>\n </EllipsisTableCellRoot>\n )\n },\n)\n\nEllipsisTableCellWithRef.displayName = 'EllipsisTableCell'\nexport const EllipsisTableCell = EllipsisTableCellWithRef\n","import { Box, BoxProps, styled, Typography, TypographyProps, TypographyTypeMap } from '@mui/material'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { forwardRef, useCallback, useState } from 'react'\n\nimport { useShareForwardedRef } from '../hooks'\n\n/**\n * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259\n */\n\nconst ComponentName = 'Ellipsize'\n\nexport interface EllipsizeRootProps extends BoxProps {\n beforeLineHeight?: string | number\n}\n\nconst EllipsizeRoot = styled(Box, {\n name: ComponentName,\n shouldForwardProp: (prop) => prop !== 'beforeLineHeight',\n slot: 'Root',\n})<EllipsizeRootProps>(({ beforeLineHeight }) => ({\n '&': {\n // because the cell content ends up absolutely positioned, the cell doesn't know the content height.\n // the pseudo element with a hidden character establishes the proper height of the content and hides it\n ':before': {\n content: \"'nbsp;'\",\n display: 'block',\n // take the pseudo element out of the `display: block` flow so it won't push against our actual content\n float: 'left',\n visibility: 'hidden',\n // since we are `display: block`, lineHeight is the height\n ...(beforeLineHeight && { lineHeight: beforeLineHeight }),\n },\n },\n}))\n\nconst EllipsizeInnerWrap = styled(Box, {\n name: ComponentName,\n slot: 'innerWrap',\n})(() => ({\n position: 'relative',\n}))\n\nconst EllipsizeContentWrap = styled(Typography, {\n name: ComponentName,\n shouldForwardProp: (prop) => prop !== 'ellipsisPosition',\n slot: 'contentWrap',\n})<TypographyWithComponentProps>(({ theme, ellipsisPosition, fontFamily }) => {\n return theme.unstable_sx({\n fontFamily: fontFamily ?? 'monospace',\n left: 0,\n overflow: 'hidden',\n position: 'absolute',\n right: 0,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n ...(ellipsisPosition === 'start'\n ? {\n direction: 'rtl',\n textAlign: 'left',\n }\n : {}),\n })\n})\n\nconst useClientHeight = () => {\n const [contentWrapHeight, setContentWrapHeight] = useState<string>()\n\n const contentWrapRef = useCallback((node: HTMLElement) => {\n if (node !== null) {\n setContentWrapHeight(node.clientHeight + 'px')\n }\n }, [])\n\n return { contentWrapHeight, contentWrapRef }\n}\n\n// See - https://mui.com/material-ui/guides/composition/#with-typescript\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type TypographyWithComponentProps<D extends React.ElementType = TypographyTypeMap['defaultComponent'], P = {}> = TypographyProps<D, P> & {\n ellipsisPosition?: 'start' | 'end'\n}\n\nexport interface EllipsizeBoxProps extends BoxProps {\n disableSharedRef?: boolean\n ellipsisPosition?: 'start' | 'end'\n typographyProps?: TypographyWithComponentProps\n}\n\nexport const EllipsizeBox = forwardRef<HTMLDivElement, WithChildren<EllipsizeBoxProps>>(\n ({ children, ellipsisPosition = 'start', disableSharedRef, typographyProps, ...props }, ref) => {\n // Allow syncing of :before pseudo element height with contentWrapHeight\n const { contentWrapRef, contentWrapHeight } = useClientHeight()\n const sharedRef = useShareForwardedRef(ref)\n\n return (\n <EllipsizeRoot beforeLineHeight={!!sharedRef && !disableSharedRef ? contentWrapHeight : undefined} {...props} ref={ref}>\n <EllipsizeInnerWrap>\n <EllipsizeContentWrap ref={contentWrapRef} component={'span'} ellipsisPosition={ellipsisPosition} variant=\"body2\" {...typographyProps}>\n {children}\n </EllipsizeContentWrap>\n </EllipsizeInnerWrap>\n </EllipsizeRoot>\n )\n },\n)\nEllipsizeBox.displayName = 'EllipsizeBox'\n","import { ForwardedRef, useEffect, useRef } from 'react'\n\nexport const useShareForwardedRef = <T>(forwardedRef: ForwardedRef<T>, refresh = 0) => {\n // final ref that will share value with forward ref. this is the one to be attached to components\n const innerRef = useRef<T>(null)\n\n useEffect(() => {\n if (!forwardedRef) {\n return\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(innerRef.current)\n return\n } else {\n forwardedRef.current = innerRef.current\n }\n }, [forwardedRef, refresh])\n\n return innerRef\n}\n"],"mappings":";AAAA,SAAS,UAAAA,SAAQ,iBAAiC;AAClD,SAAS,cAAc;AAEvB,SAAS,cAAAC,aAAY,eAAe;;;ACHpC,SAAS,KAAe,QAAQ,kBAAsD;AAEtF,SAAS,YAAY,aAAa,gBAAgB;;;ACFlD,SAAuB,WAAW,cAAc;AAEzC,IAAM,uBAAuB,CAAI,cAA+B,UAAU,MAAM;AAErF,QAAM,WAAW,OAAU,IAAI;AAE/B,YAAU,MAAM;AACd,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AACA,QAAI,OAAO,iBAAiB,YAAY;AACtC,mBAAa,SAAS,OAAO;AAC7B;AAAA,IACF,OAAO;AACL,mBAAa,UAAU,SAAS;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,SAAO;AACT;;;AD+EU;AAxFV,IAAM,gBAAgB;AAMtB,IAAM,gBAAgB,OAAO,KAAK;AAAA,EAChC,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,SAAS;AAAA,EACtC,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,iBAAiB,OAAO;AAAA,EAChD,KAAK;AAAA;AAAA;AAAA,IA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,oBAAoB,QAAY,GAAG,OAAO,KAC5G,8BAAC,sBACC,8BAAC,wBAAqB,KAAK,gBAAgB,WAAW,QAAQ,kBAAoC,SAAQ,SAAS,GAAG,iBACnH,UACH,GACF,GACF;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;;;ADpEjB,gBAAAC,YAAA;AA9BV,IAAM,wBAAwBC,QAAO,WAAW;AAAA,EAC9C,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,SAAS;AAAA,EACtC,MAAM;AACR,CAAC,EAAE,CAAC,EAAE,QAAQ,OAAO,OAAO;AAAA,EAC1B;AACF,EAAE;AAgBK,IAAM,2BAA2EC;AAAA,EACtF,CAAC,EAAE,UAAU,MAAM,OAAO,OAAO,IAAI,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC9D,UAAM,OAAO,QAAQ,MAAM;AACzB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,QAAQ,IAAI;AACtB,eACE,gBAAAF,KAAC,UAAO,OAAO,OAAO,IAAQ,MAAY,QAAQ,OAAO,WAAW,QACjE,iBACH;AAAA,MAEJ;AACA,aAAO;AAAA,IACT,GAAG,CAAC,UAAU,MAAM,MAAM,IAAI,KAAK,CAAC;AACpC,WACE,gBAAAA,KAAC,yBAAsB,KAAW,GAAG,OACnC,0BAAAA,KAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;","names":["styled","forwardRef","jsx","styled","forwardRef"]}
@@ -1,12 +1,113 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ // src/components/TableCell/EllipsisTableCellDeprecated.tsx
2
2
  import { TableCell, useTheme } from "@mui/material";
3
3
  import { LinkEx } from "@xylabs/react-link";
4
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
- const EllipsisTableCellDeprecated = ({ children, value, to, forCell, href, ...props }) => {
5
+
6
+ // src/lib/getActualPaddingX.ts
7
+ var parseMeausureString = (measure, absolute) => {
8
+ if (measure !== void 0 && measure !== null && measure.length > 0) {
9
+ if (measure.endsWith("px")) {
10
+ return parseFloat(measure.substring(0, measure.length - 2));
11
+ } else if (measure.endsWith("%")) {
12
+ if (absolute !== void 0) {
13
+ return parseFloat(measure.substring(0, measure.length - 1)) / 100 * absolute;
14
+ }
15
+ throw Error("Error Parsing Measure [missing absolute]");
16
+ } else if (measure.endsWith("vw")) {
17
+ return parseFloat(measure.substring(0, measure.length - 2)) / 100 * window.innerWidth;
18
+ } else if (measure.endsWith("vh")) {
19
+ return parseFloat(measure.substring(0, measure.length - 2)) / 100 * window.innerHeight;
20
+ }
21
+ throw Error(`Error Parsing Measure [${measure}]`);
22
+ }
23
+ };
24
+ var parsePadding = (padding) => {
25
+ const parts = padding.split(" ");
26
+ switch (parts.length) {
27
+ case 4: {
28
+ return {
29
+ bottom: parts[2],
30
+ left: parts[3],
31
+ right: parts[1],
32
+ top: parts[0]
33
+ };
34
+ }
35
+ case 3: {
36
+ return {
37
+ bottom: parts[2],
38
+ right: parts[1],
39
+ top: parts[0]
40
+ };
41
+ }
42
+ case 2: {
43
+ return {
44
+ bottom: parts[0],
45
+ left: parts[1],
46
+ right: parts[1],
47
+ top: parts[0]
48
+ };
49
+ }
50
+ case 1: {
51
+ return {
52
+ bottom: parts[0],
53
+ left: parts[0],
54
+ right: parts[0],
55
+ top: parts[0]
56
+ };
57
+ }
58
+ }
59
+ };
60
+ var getActualPaddingX = (element) => {
61
+ const padding = parsePadding(window.getComputedStyle(element, null).getPropertyValue("padding"));
62
+ const paddingLeft = parseMeausureString(window.getComputedStyle(element, null).getPropertyValue("padding-left") ?? padding?.left, element.clientWidth) ?? 0;
63
+ const paddingRight = parseMeausureString(window.getComputedStyle(element, null).getPropertyValue("padding-right") ?? padding?.right, element.clientWidth) ?? 0;
64
+ return paddingLeft + paddingRight;
65
+ };
66
+
67
+ // src/components/TableCell/findParent.ts
68
+ var findParent = (tagName, element = null) => {
69
+ let currentElement = element;
70
+ while (currentElement) {
71
+ if (currentElement.tagName.toLowerCase() === tagName.toLowerCase()) {
72
+ return currentElement;
73
+ } else {
74
+ currentElement = currentElement.parentElement;
75
+ }
76
+ }
77
+ };
78
+
79
+ // src/components/TableCell/getRemainingRowWidth.ts
80
+ var getRemainingRowWidth = (row, forCell = 0) => {
81
+ let width = 0;
82
+ for (let i = 0; i < (row?.childElementCount ?? 0); i++) {
83
+ const item = row?.children.item(i);
84
+ if (item) {
85
+ if (i !== forCell) {
86
+ width += item?.clientWidth ?? 0;
87
+ }
88
+ }
89
+ }
90
+ return width;
91
+ };
92
+
93
+ // src/components/TableCell/getSmallestParentWidth.ts
94
+ var getSmallestParentWidth = (element, maxDepth = 4) => {
95
+ let currentElement = element?.parentElement;
96
+ let width = currentElement?.clientWidth ?? screen.width;
97
+ let maxDepthCounter = maxDepth;
98
+ while (currentElement && maxDepthCounter > 0) {
99
+ if (width > currentElement.clientWidth) {
100
+ width = currentElement.clientWidth;
101
+ }
102
+ currentElement = currentElement.parentElement;
103
+ maxDepthCounter--;
104
+ }
105
+ return width;
106
+ };
107
+
108
+ // src/components/TableCell/EllipsisTableCellDeprecated.tsx
109
+ import { jsx } from "react/jsx-runtime";
110
+ var EllipsisTableCellDeprecated = ({ children, value, to, forCell, href, ...props }) => {
10
111
  const [calcCellWidth, setCalcCellWidth] = useState(0);
11
112
  const hashDivRef = useRef(null);
12
113
  const theme = useTheme();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"sourcesContent":["import { TableCell, TableCellProps, useTheme } from '@mui/material'\nimport { LinkEx } from '@xylabs/react-link'\nimport { useEffect, useRef, useState } from 'react'\nimport { To } from 'react-router-dom'\n\nimport { getActualPaddingX } from '../../lib'\nimport { findParent } from './findParent'\nimport { getRemainingRowWidth } from './getRemainingRowWidth'\nimport { getSmallestParentWidth } from './getSmallestParentWidth'\n\nexport interface EllipsisTableCellProps extends TableCellProps {\n forCell?: number //cell index for ellipsized table cell\n href?: string | undefined\n to?: To | undefined\n value?: string\n}\n\n/** @deprecated - use new EllipsisTableCell */\nexport const EllipsisTableCellDeprecated: React.FC<EllipsisTableCellProps> = ({ children, value, to, forCell, href, ...props }) => {\n const [calcCellWidth, setCalcCellWidth] = useState<number>(0)\n const hashDivRef = useRef<HTMLDivElement>(null)\n const theme = useTheme()\n\n useEffect(() => {\n const currentElement = hashDivRef.current?.parentElement\n const cell = findParent('td', currentElement)\n const row = findParent('tr', currentElement)\n\n const checkWidth = (cell: HTMLElement) => {\n const smallestParentWidth = getSmallestParentWidth(cell)\n if (smallestParentWidth && row) {\n const remainingWidth = getRemainingRowWidth(row, forCell)\n const actualPaddingX = getActualPaddingX(cell)\n const remainderWidth = smallestParentWidth - remainingWidth - actualPaddingX\n cell.style.width = `${remainderWidth}`\n setCalcCellWidth(remainderWidth)\n }\n }\n\n const onResize = () => {\n if (cell) {\n checkWidth(cell)\n }\n }\n\n if (cell) {\n checkWidth(cell)\n window.addEventListener('resize', onResize)\n row?.addEventListener('resize', onResize)\n }\n return () => {\n window.removeEventListener('resize', onResize)\n row?.removeEventListener('resize', onResize)\n }\n }, [forCell, hashDivRef])\n\n return (\n <TableCell {...props}>\n <div ref={hashDivRef}>\n {children ? (\n <span\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {children}\n </span>\n ) : href || to ? (\n <LinkEx\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n to={to}\n href={href}\n target={href ? '_blank' : undefined}\n >\n {value}\n </LinkEx>\n ) : (\n <span\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {value}\n </span>\n )}\n </div>\n </TableCell>\n )\n}\n"],"mappings":"AA4DU;AA5DV,SAAS,WAA2B,gBAAgB;AACpD,SAAS,cAAc;AACvB,SAAS,WAAW,QAAQ,gBAAgB;AAG5C,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AAUhC,MAAM,8BAAgE,CAAC,EAAE,UAAU,OAAO,IAAI,SAAS,MAAM,GAAG,MAAM,MAAM;AACjI,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,CAAC;AAC5D,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,QAAQ,SAAS;AAEvB,YAAU,MAAM;AACd,UAAM,iBAAiB,WAAW,SAAS;AAC3C,UAAM,OAAO,WAAW,MAAM,cAAc;AAC5C,UAAM,MAAM,WAAW,MAAM,cAAc;AAE3C,UAAM,aAAa,CAACA,UAAsB;AACxC,YAAM,sBAAsB,uBAAuBA,KAAI;AACvD,UAAI,uBAAuB,KAAK;AAC9B,cAAM,iBAAiB,qBAAqB,KAAK,OAAO;AACxD,cAAM,iBAAiB,kBAAkBA,KAAI;AAC7C,cAAM,iBAAiB,sBAAsB,iBAAiB;AAC9D,QAAAA,MAAK,MAAM,QAAQ,GAAG,cAAc;AACpC,yBAAiB,cAAc;AAAA,MACjC;AAAA,IACF;AAEA,UAAM,WAAW,MAAM;AACrB,UAAI,MAAM;AACR,mBAAW,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,QAAI,MAAM;AACR,iBAAW,IAAI;AACf,aAAO,iBAAiB,UAAU,QAAQ;AAC1C,WAAK,iBAAiB,UAAU,QAAQ;AAAA,IAC1C;AACA,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,QAAQ;AAC7C,WAAK,oBAAoB,UAAU,QAAQ;AAAA,IAC7C;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,CAAC;AAExB,SACE,oBAAC,aAAW,GAAG,OACb,8BAAC,SAAI,KAAK,YACP,qBACC;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,UAAU,MAAM,QAAQ,EAAE;AAAA,QAC1B,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MACd;AAAA,MAEC;AAAA;AAAA,EACH,IACE,QAAQ,KACV;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,UAAU,MAAM,QAAQ,EAAE;AAAA,QAC1B,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,WAAW;AAAA,MAEzB;AAAA;AAAA,EACH,IAEA;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,UAAU;AAAA,QACV,UAAU,MAAM,QAAQ,EAAE;AAAA,QAC1B,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MACd;AAAA,MAEC;AAAA;AAAA,EACH,GAEJ,GACF;AAEJ;","names":["cell"]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx","../../../../src/lib/getActualPaddingX.ts","../../../../src/components/TableCell/findParent.ts","../../../../src/components/TableCell/getRemainingRowWidth.ts","../../../../src/components/TableCell/getSmallestParentWidth.ts"],"sourcesContent":["import { TableCell, TableCellProps, useTheme } from '@mui/material'\nimport { LinkEx } from '@xylabs/react-link'\nimport { useEffect, useRef, useState } from 'react'\nimport { To } from 'react-router-dom'\n\nimport { getActualPaddingX } from '../../lib'\nimport { findParent } from './findParent'\nimport { getRemainingRowWidth } from './getRemainingRowWidth'\nimport { getSmallestParentWidth } from './getSmallestParentWidth'\n\nexport interface EllipsisTableCellProps extends TableCellProps {\n forCell?: number //cell index for ellipsized table cell\n href?: string | undefined\n to?: To | undefined\n value?: string\n}\n\n/** @deprecated - use new EllipsisTableCell */\nexport const EllipsisTableCellDeprecated: React.FC<EllipsisTableCellProps> = ({ children, value, to, forCell, href, ...props }) => {\n const [calcCellWidth, setCalcCellWidth] = useState<number>(0)\n const hashDivRef = useRef<HTMLDivElement>(null)\n const theme = useTheme()\n\n useEffect(() => {\n const currentElement = hashDivRef.current?.parentElement\n const cell = findParent('td', currentElement)\n const row = findParent('tr', currentElement)\n\n const checkWidth = (cell: HTMLElement) => {\n const smallestParentWidth = getSmallestParentWidth(cell)\n if (smallestParentWidth && row) {\n const remainingWidth = getRemainingRowWidth(row, forCell)\n const actualPaddingX = getActualPaddingX(cell)\n const remainderWidth = smallestParentWidth - remainingWidth - actualPaddingX\n cell.style.width = `${remainderWidth}`\n setCalcCellWidth(remainderWidth)\n }\n }\n\n const onResize = () => {\n if (cell) {\n checkWidth(cell)\n }\n }\n\n if (cell) {\n checkWidth(cell)\n window.addEventListener('resize', onResize)\n row?.addEventListener('resize', onResize)\n }\n return () => {\n window.removeEventListener('resize', onResize)\n row?.removeEventListener('resize', onResize)\n }\n }, [forCell, hashDivRef])\n\n return (\n <TableCell {...props}>\n <div ref={hashDivRef}>\n {children ? (\n <span\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {children}\n </span>\n ) : href || to ? (\n <LinkEx\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n to={to}\n href={href}\n target={href ? '_blank' : undefined}\n >\n {value}\n </LinkEx>\n ) : (\n <span\n style={{\n display: 'block',\n maxWidth: calcCellWidth,\n minWidth: theme.spacing(10),\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {value}\n </span>\n )}\n </div>\n </TableCell>\n )\n}\n","export const parseMeausureString = (measure?: string, absolute?: number) => {\n if (measure !== undefined && measure !== null && measure.length > 0) {\n if (measure.endsWith('px')) {\n return parseFloat(measure.substring(0, measure.length - 2))\n } else if (measure.endsWith('%')) {\n if (absolute !== undefined) {\n return (parseFloat(measure.substring(0, measure.length - 1)) / 100) * absolute\n }\n throw Error('Error Parsing Measure [missing absolute]')\n } else if (measure.endsWith('vw')) {\n return (parseFloat(measure.substring(0, measure.length - 2)) / 100) * window.innerWidth\n } else if (measure.endsWith('vh')) {\n return (parseFloat(measure.substring(0, measure.length - 2)) / 100) * window.innerHeight\n }\n throw Error(`Error Parsing Measure [${measure}]`)\n }\n}\n\nexport const parsePadding = (padding: string) => {\n const parts = padding.split(' ')\n switch (parts.length) {\n case 4: {\n return {\n bottom: parts[2],\n left: parts[3],\n right: parts[1],\n top: parts[0],\n }\n }\n case 3: {\n return {\n bottom: parts[2],\n right: parts[1],\n top: parts[0],\n }\n }\n case 2: {\n return {\n bottom: parts[0],\n left: parts[1],\n right: parts[1],\n top: parts[0],\n }\n }\n case 1: {\n return {\n bottom: parts[0],\n left: parts[0],\n right: parts[0],\n top: parts[0],\n }\n }\n }\n}\n\nexport const getActualPaddingX = (element: HTMLElement) => {\n const padding = parsePadding(window.getComputedStyle(element, null).getPropertyValue('padding'))\n const paddingLeft =\n parseMeausureString(window.getComputedStyle(element, null).getPropertyValue('padding-left') ?? padding?.left, element.clientWidth) ?? 0\n const paddingRight =\n parseMeausureString(window.getComputedStyle(element, null).getPropertyValue('padding-right') ?? padding?.right, element.clientWidth) ?? 0\n return paddingLeft + paddingRight\n}\n","export const findParent = (tagName: string, element: HTMLElement | null = null) => {\n let currentElement = element\n while (currentElement) {\n if (currentElement.tagName.toLowerCase() === tagName.toLowerCase()) {\n return currentElement\n } else {\n currentElement = currentElement.parentElement\n }\n }\n}\n","/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */\nexport const getRemainingRowWidth = (row: HTMLElement, forCell = 0) => {\n let width = 0\n for (let i = 0; i < (row?.childElementCount ?? 0); i++) {\n const item = row?.children.item(i)\n if (item) {\n if (i !== forCell) {\n width += item?.clientWidth ?? 0\n }\n }\n }\n\n return width\n}\n","export const getSmallestParentWidth = (element: HTMLElement, maxDepth = 4) => {\n let currentElement: HTMLElement | null = element?.parentElement\n let width = currentElement?.clientWidth ?? screen.width\n let maxDepthCounter = maxDepth\n while (currentElement && maxDepthCounter > 0) {\n if (width > currentElement.clientWidth) {\n width = currentElement.clientWidth\n }\n currentElement = currentElement.parentElement\n maxDepthCounter--\n }\n return width\n}\n"],"mappings":";AAAA,SAAS,WAA2B,gBAAgB;AACpD,SAAS,cAAc;AACvB,SAAS,WAAW,QAAQ,gBAAgB;;;ACFrC,IAAM,sBAAsB,CAAC,SAAkB,aAAsB;AAC1E,MAAI,YAAY,UAAa,YAAY,QAAQ,QAAQ,SAAS,GAAG;AACnE,QAAI,QAAQ,SAAS,IAAI,GAAG;AAC1B,aAAO,WAAW,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC;AAAA,IAC5D,WAAW,QAAQ,SAAS,GAAG,GAAG;AAChC,UAAI,aAAa,QAAW;AAC1B,eAAQ,WAAW,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC,IAAI,MAAO;AAAA,MACxE;AACA,YAAM,MAAM,0CAA0C;AAAA,IACxD,WAAW,QAAQ,SAAS,IAAI,GAAG;AACjC,aAAQ,WAAW,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC,IAAI,MAAO,OAAO;AAAA,IAC/E,WAAW,QAAQ,SAAS,IAAI,GAAG;AACjC,aAAQ,WAAW,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC,IAAI,MAAO,OAAO;AAAA,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AAEJ;","names":["cell"]}
@@ -1,16 +1,136 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ // src/components/TableCell/HashTableCell.tsx
2
2
  import { useEvent } from "@xyo-network/react-event";
3
- import { useRef } from "react";
4
- import { EllipsisTableCell } from "./EllipsisTableCell";
5
- const HashTableCell = ({ value, archive, dataType, network, exploreDomain, ...props }) => {
6
- const ref = useRef(null);
3
+ import { useRef as useRef2 } from "react";
4
+
5
+ // src/components/TableCell/EllipsisTableCell.tsx
6
+ import { styled as styled2, TableCell } from "@mui/material";
7
+ import { LinkEx } from "@xylabs/react-link";
8
+ import { forwardRef as forwardRef2, useMemo } from "react";
9
+
10
+ // src/components/Ellipsize.tsx
11
+ import { Box, styled, Typography } from "@mui/material";
12
+ import { forwardRef, useCallback, useState } from "react";
13
+
14
+ // src/hooks/useShareForwardRef.ts
15
+ import { useEffect, useRef } from "react";
16
+ var useShareForwardedRef = (forwardedRef, refresh = 0) => {
17
+ const innerRef = useRef(null);
18
+ useEffect(() => {
19
+ if (!forwardedRef) {
20
+ return;
21
+ }
22
+ if (typeof forwardedRef === "function") {
23
+ forwardedRef(innerRef.current);
24
+ return;
25
+ } else {
26
+ forwardedRef.current = innerRef.current;
27
+ }
28
+ }, [forwardedRef, refresh]);
29
+ return innerRef;
30
+ };
31
+
32
+ // src/components/Ellipsize.tsx
33
+ import { jsx } from "react/jsx-runtime";
34
+ var ComponentName = "Ellipsize";
35
+ var EllipsizeRoot = styled(Box, {
36
+ name: ComponentName,
37
+ shouldForwardProp: (prop) => prop !== "beforeLineHeight",
38
+ slot: "Root"
39
+ })(({ beforeLineHeight }) => ({
40
+ "&": {
41
+ // because the cell content ends up absolutely positioned, the cell doesn't know the content height.
42
+ // the pseudo element with a hidden character establishes the proper height of the content and hides it
43
+ ":before": {
44
+ content: "'nbsp;'",
45
+ display: "block",
46
+ // take the pseudo element out of the `display: block` flow so it won't push against our actual content
47
+ float: "left",
48
+ visibility: "hidden",
49
+ // since we are `display: block`, lineHeight is the height
50
+ ...beforeLineHeight && { lineHeight: beforeLineHeight }
51
+ }
52
+ }
53
+ }));
54
+ var EllipsizeInnerWrap = styled(Box, {
55
+ name: ComponentName,
56
+ slot: "innerWrap"
57
+ })(() => ({
58
+ position: "relative"
59
+ }));
60
+ var EllipsizeContentWrap = styled(Typography, {
61
+ name: ComponentName,
62
+ shouldForwardProp: (prop) => prop !== "ellipsisPosition",
63
+ slot: "contentWrap"
64
+ })(({ theme, ellipsisPosition, fontFamily }) => {
65
+ return theme.unstable_sx({
66
+ fontFamily: fontFamily ?? "monospace",
67
+ left: 0,
68
+ overflow: "hidden",
69
+ position: "absolute",
70
+ right: 0,
71
+ textOverflow: "ellipsis",
72
+ whiteSpace: "nowrap",
73
+ ...ellipsisPosition === "start" ? {
74
+ direction: "rtl",
75
+ textAlign: "left"
76
+ } : {}
77
+ });
78
+ });
79
+ var useClientHeight = () => {
80
+ const [contentWrapHeight, setContentWrapHeight] = useState();
81
+ const contentWrapRef = useCallback((node) => {
82
+ if (node !== null) {
83
+ setContentWrapHeight(node.clientHeight + "px");
84
+ }
85
+ }, []);
86
+ return { contentWrapHeight, contentWrapRef };
87
+ };
88
+ var EllipsizeBox = forwardRef(
89
+ ({ children, ellipsisPosition = "start", disableSharedRef, typographyProps, ...props }, ref) => {
90
+ const { contentWrapRef, contentWrapHeight } = useClientHeight();
91
+ const sharedRef = useShareForwardedRef(ref);
92
+ return /* @__PURE__ */ jsx(EllipsizeRoot, { beforeLineHeight: !!sharedRef && !disableSharedRef ? contentWrapHeight : void 0, ...props, ref, children: /* @__PURE__ */ jsx(EllipsizeInnerWrap, { children: /* @__PURE__ */ jsx(EllipsizeContentWrap, { ref: contentWrapRef, component: "span", ellipsisPosition, variant: "body2", ...typographyProps, children }) }) });
93
+ }
94
+ );
95
+ EllipsizeBox.displayName = "EllipsizeBox";
96
+
97
+ // src/components/TableCell/EllipsisTableCell.tsx
98
+ import { jsx as jsx2 } from "react/jsx-runtime";
99
+ var EllipsisTableCellRoot = styled2(TableCell, {
100
+ name: "EllipsisTableCell",
101
+ shouldForwardProp: (prop) => prop !== "width",
102
+ slot: "Root"
103
+ })(({ width = "100%" }) => ({
104
+ width
105
+ }));
106
+ var EllipsisTableCellWithRef = forwardRef2(
107
+ ({ children, href, link = false, to, value, ...props }, ref) => {
108
+ const data = useMemo(() => {
109
+ if (children) {
110
+ return children;
111
+ }
112
+ if (href || link || to) {
113
+ return /* @__PURE__ */ jsx2(LinkEx, { title: value, to, href, target: href ? "_blank" : void 0, children: value });
114
+ }
115
+ return value;
116
+ }, [children, href, link, to, value]);
117
+ return /* @__PURE__ */ jsx2(EllipsisTableCellRoot, { ref, ...props, children: /* @__PURE__ */ jsx2(EllipsizeBox, { sx: { cursor: link || to || href ? "pointer" : "inherit" }, children: data }) });
118
+ }
119
+ );
120
+ EllipsisTableCellWithRef.displayName = "EllipsisTableCell";
121
+ var EllipsisTableCell = EllipsisTableCellWithRef;
122
+
123
+ // src/components/TableCell/HashTableCell.tsx
124
+ import { jsx as jsx3 } from "react/jsx-runtime";
125
+ var HashTableCell = ({ value, archive, dataType, network, exploreDomain, ...props }) => {
126
+ const ref = useRef2(null);
7
127
  const [tableCellRef, dispatch] = useEvent(void 0, ref);
8
128
  const hashPath = `/${dataType}/hash/${value}?network=${network ?? "main"}`;
9
129
  const explorePath = archive ? `/archive/${archive}${hashPath}` : hashPath;
10
130
  const handleCellClick = () => {
11
131
  dispatch?.("hash", "click", value);
12
132
  };
13
- return /* @__PURE__ */ jsx(
133
+ return /* @__PURE__ */ jsx3(
14
134
  EllipsisTableCell,
15
135
  {
16
136
  onClick: handleCellClick,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/HashTableCell.tsx"],"sourcesContent":["import { useEvent } from '@xyo-network/react-event'\nimport { useRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface HashTableCellProps extends EllipsisTableCellProps {\n archive?: string\n dataType?: 'block' | 'payload'\n exploreDomain?: string\n network?: string\n}\n\nexport const HashTableCell: React.FC<HashTableCellProps> = ({ value, archive, dataType, network, exploreDomain, ...props }) => {\n const ref = useRef<HTMLTableCellElement | null>(null)\n const [tableCellRef, dispatch] = useEvent<HTMLTableCellElement>(undefined, ref)\n const hashPath = `/${dataType}/hash/${value}?network=${network ?? 'main'}`\n const explorePath = archive ? `/archive/${archive}${hashPath}` : hashPath\n\n const handleCellClick = () => {\n dispatch?.('hash', 'click', value)\n }\n\n return (\n <EllipsisTableCell\n onClick={handleCellClick}\n ref={tableCellRef}\n value={value}\n href={exploreDomain ? `${exploreDomain}${explorePath}}` : undefined}\n to={exploreDomain ? undefined : explorePath}\n {...props}\n />\n )\n}\n"],"mappings":"AAuBI;AAvBJ,SAAS,gBAAgB;AACzB,SAAS,cAAc;AAEvB,SAAS,yBAAiD;AASnD,MAAM,gBAA8C,CAAC,EAAE,OAAO,SAAS,UAAU,SAAS,eAAe,GAAG,MAAM,MAAM;AAC7H,QAAM,MAAM,OAAoC,IAAI;AACpD,QAAM,CAAC,cAAc,QAAQ,IAAI,SAA+B,QAAW,GAAG;AAC9E,QAAM,WAAW,IAAI,QAAQ,SAAS,KAAK,YAAY,WAAW,MAAM;AACxE,QAAM,cAAc,UAAU,YAAY,OAAO,GAAG,QAAQ,KAAK;AAEjE,QAAM,kBAAkB,MAAM;AAC5B,eAAW,QAAQ,SAAS,KAAK;AAAA,EACnC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAS;AAAA,MACT,KAAK;AAAA,MACL;AAAA,MACA,MAAM,gBAAgB,GAAG,aAAa,GAAG,WAAW,MAAM;AAAA,MAC1D,IAAI,gBAAgB,SAAY;AAAA,MAC/B,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/HashTableCell.tsx","../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { useEvent } from '@xyo-network/react-event'\nimport { useRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface HashTableCellProps extends EllipsisTableCellProps {\n archive?: string\n dataType?: 'block' | 'payload'\n exploreDomain?: string\n network?: string\n}\n\nexport const HashTableCell: React.FC<HashTableCellProps> = ({ value, archive, dataType, network, exploreDomain, ...props }) => {\n const ref = useRef<HTMLTableCellElement | null>(null)\n const [tableCellRef, dispatch] = useEvent<HTMLTableCellElement>(undefined, ref)\n const hashPath = `/${dataType}/hash/${value}?network=${network ?? 'main'}`\n const explorePath = archive ? `/archive/${archive}${hashPath}` : hashPath\n\n const handleCellClick = () => {\n dispatch?.('hash', 'click', value)\n }\n\n return (\n <EllipsisTableCell\n onClick={handleCellClick}\n ref={tableCellRef}\n value={value}\n href={exploreDomain ? `${exploreDomain}${explorePath}}` : undefined}\n to={exploreDomain ? undefined : explorePath}\n {...props}\n />\n )\n}\n","import { styled, TableCell, TableCellProps } from '@mui/material'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport { forwardRef, useMemo } from 'react'\nimport { To } from 'react-router-dom'\n\nimport { EllipsizeBox } from '../Ellipsize'\n\nconst EllipsisTableCellRoot = styled(TableCell, {\n name: 'EllipsisTableCell',\n shouldForwardProp: (prop) => prop !== 'width',\n slot: 'Root',\n})(({ width = '100%' }) => ({\n width,\n}))\n\nexport interface EllipsisTableCellProps extends TableCellProps {\n href?: string\n link?: boolean\n to?: To\n value?: string\n /**\n * Width of the table cell.\n *\n * Note: When using percentages, this value can be different than what you expect\n * if used on a cell that is not the first cell in the first row.\n */\n width?: string | number\n}\n\nexport const EllipsisTableCellWithRef: React.FC<WithChildren<EllipsisTableCellProps>> = forwardRef(\n ({ children, href, link = false, to, value, ...props }, ref) => {\n const data = useMemo(() => {\n if (children) {\n return children\n }\n if (href || link || to) {\n return (\n <LinkEx title={value} to={to} href={href} target={href ? '_blank' : undefined}>\n {value}\n </LinkEx>\n )\n }\n return value\n }, [children, href, link, to, value])\n return (\n <EllipsisTableCellRoot ref={ref} {...props}>\n <EllipsizeBox sx={{ cursor: link || to || href ? 'pointer' : 'inherit' }}>{data}</EllipsizeBox>\n </EllipsisTableCellRoot>\n )\n },\n)\n\nEllipsisTableCellWithRef.displayName = 'EllipsisTableCell'\nexport const EllipsisTableCell = EllipsisTableCellWithRef\n","import { Box, BoxProps, styled, Typography, TypographyProps, TypographyTypeMap } from '@mui/material'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { forwardRef, useCallback, useState } from 'react'\n\nimport { useShareForwardedRef } from '../hooks'\n\n/**\n * Heavily inspired by - https://stackoverflow.com/a/30362531/2803259\n */\n\nconst ComponentName = 'Ellipsize'\n\nexport interface EllipsizeRootProps extends BoxProps {\n beforeLineHeight?: string | number\n}\n\nconst EllipsizeRoot = styled(Box, {\n name: ComponentName,\n shouldForwardProp: (prop) => prop !== 'beforeLineHeight',\n slot: 'Root',\n})<EllipsizeRootProps>(({ beforeLineHeight }) => ({\n '&': {\n // because the cell content ends up absolutely positioned, the cell doesn't know the content height.\n // the pseudo element with a hidden character establishes the proper height of the content and hides it\n ':before': {\n content: \"'nbsp;'\",\n display: 'block',\n // take the pseudo element out of the `display: block` flow so it won't push against our actual content\n float: 'left',\n visibility: 'hidden',\n // since we are `display: block`, lineHeight is the height\n ...(beforeLineHeight && { lineHeight: beforeLineHeight }),\n },\n },\n}))\n\nconst EllipsizeInnerWrap = styled(Box, {\n name: ComponentName,\n slot: 'innerWrap',\n})(() => ({\n position: 'relative',\n}))\n\nconst EllipsizeContentWrap = styled(Typography, {\n name: ComponentName,\n shouldForwardProp: (prop) => prop !== 'ellipsisPosition',\n slot: 'contentWrap',\n})<TypographyWithComponentProps>(({ theme, ellipsisPosition, fontFamily }) => {\n return theme.unstable_sx({\n fontFamily: fontFamily ?? 'monospace',\n left: 0,\n overflow: 'hidden',\n position: 'absolute',\n right: 0,\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n ...(ellipsisPosition === 'start'\n ? {\n direction: 'rtl',\n textAlign: 'left',\n }\n : {}),\n })\n})\n\nconst useClientHeight = () => {\n const [contentWrapHeight, setContentWrapHeight] = useState<string>()\n\n const contentWrapRef = useCallback((node: HTMLElement) => {\n if (node !== null) {\n setContentWrapHeight(node.clientHeight + 'px')\n }\n }, [])\n\n return { contentWrapHeight, contentWrapRef }\n}\n\n// See - https://mui.com/material-ui/guides/composition/#with-typescript\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type TypographyWithComponentProps<D extends React.ElementType = TypographyTypeMap['defaultComponent'], P = {}> = TypographyProps<D, P> & {\n ellipsisPosition?: 'start' | 'end'\n}\n\nexport interface EllipsizeBoxProps extends BoxProps {\n disableSharedRef?: boolean\n ellipsisPosition?: 'start' | 'end'\n typographyProps?: TypographyWithComponentProps\n}\n\nexport const EllipsizeBox = forwardRef<HTMLDivElement, WithChildren<EllipsizeBoxProps>>(\n ({ children, ellipsisPosition = 'start', disableSharedRef, typographyProps, ...props }, ref) => {\n // Allow syncing of :before pseudo element height with contentWrapHeight\n const { contentWrapRef, contentWrapHeight } = useClientHeight()\n const sharedRef = useShareForwardedRef(ref)\n\n return (\n <EllipsizeRoot beforeLineHeight={!!sharedRef && !disableSharedRef ? contentWrapHeight : undefined} {...props} ref={ref}>\n <EllipsizeInnerWrap>\n <EllipsizeContentWrap ref={contentWrapRef} component={'span'} ellipsisPosition={ellipsisPosition} variant=\"body2\" {...typographyProps}>\n {children}\n </EllipsizeContentWrap>\n </EllipsizeInnerWrap>\n </EllipsizeRoot>\n )\n },\n)\nEllipsizeBox.displayName = 'EllipsizeBox'\n","import { ForwardedRef, useEffect, useRef } from 'react'\n\nexport const useShareForwardedRef = <T>(forwardedRef: ForwardedRef<T>, refresh = 0) => {\n // final ref that will share value with forward ref. this is the one to be attached to components\n const innerRef = useRef<T>(null)\n\n useEffect(() => {\n if (!forwardedRef) {\n return\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(innerRef.current)\n return\n } else {\n forwardedRef.current = innerRef.current\n }\n }, [forwardedRef, refresh])\n\n return innerRef\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,UAAAA,eAAc;;;ACDvB,SAAS,UAAAC,SAAQ,iBAAiC;AAClD,SAAS,cAAc;AAEvB,SAAS,cAAAC,aAAY,eAAe;;;ACHpC,SAAS,KAAe,QAAQ,kBAAsD;AAEtF,SAAS,YAAY,aAAa,gBAAgB;;;ACFlD,SAAuB,WAAW,cAAc;AAEzC,IAAM,uBAAuB,CAAI,cAA+B,UAAU,MAAM;AAErF,QAAM,WAAW,OAAU,IAAI;AAE/B,YAAU,MAAM;AACd,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AACA,QAAI,OAAO,iBAAiB,YAAY;AACtC,mBAAa,SAAS,OAAO;AAC7B;AAAA,IACF,OAAO;AACL,mBAAa,UAAU,SAAS;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,cAAc,OAAO,CAAC;AAE1B,SAAO;AACT;;;AD+EU;AAxFV,IAAM,gBAAgB;AAMtB,IAAM,gBAAgB,OAAO,KAAK;AAAA,EAChC,MAAM;AAAA,EACN,mBAAmB,CAAC,SAAS,SAAS;AAAA,EACtC,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,iBAAiB,OAAO;AAAA,EAChD,KAAK;AAAA;AAAA;AAAA,IAGH,WAAW;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA;AAAA,MAET,OAAO;AAAA,MACP,YAAY;AAAA;AAAA,MAEZ,GAAI,oBAAoB,EAAE,YAAY,iBAAiB;AAAA,IACzD;AAAA,EACF;AACF,EAAE;AAEF,IAAM,qBAAqB,OAAO,KAAK;AAAA,EACrC,MAAM;AAAA,EACN,MAAM;AACR,CAAC,EAAE,OAAO;AAAA,EACR,UAAU;AACZ,EAAE;AAEF,IAAM,uBAAuB,OAAO,YAAY;AAAA,EAC9C,MAAM;AAAA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styled","forwardRef","jsx","styled","forwardRef","jsx","useRef"]}
@@ -1,4 +1,5 @@
1
- const findParent = (tagName, element = null) => {
1
+ // src/components/TableCell/findParent.ts
2
+ var findParent = (tagName, element = null) => {
2
3
  let currentElement = element;
3
4
  while (currentElement) {
4
5
  if (currentElement.tagName.toLowerCase() === tagName.toLowerCase()) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/findParent.ts"],"sourcesContent":["export const findParent = (tagName: string, element: HTMLElement | null = null) => {\n let currentElement = element\n while (currentElement) {\n if (currentElement.tagName.toLowerCase() === tagName.toLowerCase()) {\n return currentElement\n } else {\n currentElement = currentElement.parentElement\n }\n }\n}\n"],"mappings":"AAAO,MAAM,aAAa,CAAC,SAAiB,UAA8B,SAAS;AACjF,MAAI,iBAAiB;AACrB,SAAO,gBAAgB;AACrB,QAAI,eAAe,QAAQ,YAAY,MAAM,QAAQ,YAAY,GAAG;AAClE,aAAO;AAAA,IACT,OAAO;AACL,uBAAiB,eAAe;AAAA,IAClC;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/findParent.ts"],"sourcesContent":["export const findParent = (tagName: string, element: HTMLElement | null = null) => {\n let currentElement = element\n while (currentElement) {\n if (currentElement.tagName.toLowerCase() === tagName.toLowerCase()) {\n return currentElement\n } else {\n currentElement = currentElement.parentElement\n }\n }\n}\n"],"mappings":";AAAO,IAAM,aAAa,CAAC,SAAiB,UAA8B,SAAS;AACjF,MAAI,iBAAiB;AACrB,SAAO,gBAAgB;AACrB,QAAI,eAAe,QAAQ,YAAY,MAAM,QAAQ,YAAY,GAAG;AAClE,aAAO;AAAA,IACT,OAAO;AACL,uBAAiB,eAAe;AAAA,IAClC;AAAA,EACF;AACF;","names":[]}
@@ -1,4 +1,5 @@
1
- const getRemainingRowWidth = (row, forCell = 0) => {
1
+ // src/components/TableCell/getRemainingRowWidth.ts
2
+ var getRemainingRowWidth = (row, forCell = 0) => {
2
3
  let width = 0;
3
4
  for (let i = 0; i < (row?.childElementCount ?? 0); i++) {
4
5
  const item = row?.children.item(i);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/getRemainingRowWidth.ts"],"sourcesContent":["/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */\nexport const getRemainingRowWidth = (row: HTMLElement, forCell = 0) => {\n let width = 0\n for (let i = 0; i < (row?.childElementCount ?? 0); i++) {\n const item = row?.children.item(i)\n if (item) {\n if (i !== forCell) {\n width += item?.clientWidth ?? 0\n }\n }\n }\n\n return width\n}\n"],"mappings":"AACO,MAAM,uBAAuB,CAAC,KAAkB,UAAU,MAAM;AACrE,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,KAAK,KAAK,qBAAqB,IAAI,KAAK;AACtD,UAAM,OAAO,KAAK,SAAS,KAAK,CAAC;AACjC,QAAI,MAAM;AACR,UAAI,MAAM,SAAS;AACjB,iBAAS,MAAM,eAAe;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/getRemainingRowWidth.ts"],"sourcesContent":["/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */\nexport const getRemainingRowWidth = (row: HTMLElement, forCell = 0) => {\n let width = 0\n for (let i = 0; i < (row?.childElementCount ?? 0); i++) {\n const item = row?.children.item(i)\n if (item) {\n if (i !== forCell) {\n width += item?.clientWidth ?? 0\n }\n }\n }\n\n return width\n}\n"],"mappings":";AACO,IAAM,uBAAuB,CAAC,KAAkB,UAAU,MAAM;AACrE,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,KAAK,KAAK,qBAAqB,IAAI,KAAK;AACtD,UAAM,OAAO,KAAK,SAAS,KAAK,CAAC;AACjC,QAAI,MAAM;AACR,UAAI,MAAM,SAAS;AACjB,iBAAS,MAAM,eAAe;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,4 +1,5 @@
1
- const getSmallestParentWidth = (element, maxDepth = 4) => {
1
+ // src/components/TableCell/getSmallestParentWidth.ts
2
+ var getSmallestParentWidth = (element, maxDepth = 4) => {
2
3
  let currentElement = element?.parentElement;
3
4
  let width = currentElement?.clientWidth ?? screen.width;
4
5
  let maxDepthCounter = maxDepth;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/TableCell/getSmallestParentWidth.ts"],"sourcesContent":["export const getSmallestParentWidth = (element: HTMLElement, maxDepth = 4) => {\n let currentElement: HTMLElement | null = element?.parentElement\n let width = currentElement?.clientWidth ?? screen.width\n let maxDepthCounter = maxDepth\n while (currentElement && maxDepthCounter > 0) {\n if (width > currentElement.clientWidth) {\n width = currentElement.clientWidth\n }\n currentElement = currentElement.parentElement\n maxDepthCounter--\n }\n return width\n}\n"],"mappings":"AAAO,MAAM,yBAAyB,CAAC,SAAsB,WAAW,MAAM;AAC5E,MAAI,iBAAqC,SAAS;AAClD,MAAI,QAAQ,gBAAgB,eAAe,OAAO;AAClD,MAAI,kBAAkB;AACtB,SAAO,kBAAkB,kBAAkB,GAAG;AAC5C,QAAI,QAAQ,eAAe,aAAa;AACtC,cAAQ,eAAe;AAAA,IACzB;AACA,qBAAiB,eAAe;AAChC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/components/TableCell/getSmallestParentWidth.ts"],"sourcesContent":["export const getSmallestParentWidth = (element: HTMLElement, maxDepth = 4) => {\n let currentElement: HTMLElement | null = element?.parentElement\n let width = currentElement?.clientWidth ?? screen.width\n let maxDepthCounter = maxDepth\n while (currentElement && maxDepthCounter > 0) {\n if (width > currentElement.clientWidth) {\n width = currentElement.clientWidth\n }\n currentElement = currentElement.parentElement\n maxDepthCounter--\n }\n return width\n}\n"],"mappings":";AAAO,IAAM,yBAAyB,CAAC,SAAsB,WAAW,MAAM;AAC5E,MAAI,iBAAqC,SAAS;AAClD,MAAI,QAAQ,gBAAgB,eAAe,OAAO;AAClD,MAAI,kBAAkB;AACtB,SAAO,kBAAkB,kBAAkB,GAAG;AAC5C,QAAI,QAAQ,eAAe,aAAa;AACtC,cAAQ,eAAe;AAAA,IACzB;AACA,qBAAiB,eAAe;AAChC;AAAA,EACF;AACA,SAAO;AACT;","names":[]}