@xyo-network/react-shared 2.64.7 → 2.64.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.
- package/dist/browser/components/ListItemButtonEx.cjs +2 -2
- package/dist/browser/components/ListItemButtonEx.cjs.map +1 -1
- package/dist/browser/components/ListItemButtonEx.d.cts +1 -1
- package/dist/browser/components/ListItemButtonEx.d.cts.map +1 -1
- package/dist/browser/components/ListItemButtonEx.d.mts +1 -1
- package/dist/browser/components/ListItemButtonEx.d.mts.map +1 -1
- package/dist/browser/components/ListItemButtonEx.d.ts +1 -1
- package/dist/browser/components/ListItemButtonEx.d.ts.map +1 -1
- package/dist/browser/components/ListItemButtonEx.js +1 -1
- package/dist/browser/components/ListItemButtonEx.js.map +1 -1
- package/dist/browser/components/TableCell/AddressTableCell.cjs.map +1 -1
- package/dist/browser/components/TableCell/AddressTableCell.js.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.cjs.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.cts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.cts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.mts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.mts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.ts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.d.ts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.cjs.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.cts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.cts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.mts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.mts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.ts +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.d.ts.map +1 -1
- package/dist/browser/components/TableCell/EllipsisTableCellDeprecated.js.map +1 -1
- package/dist/browser/components/TableCell/HashTableCell.cjs.map +1 -1
- package/dist/browser/components/TableCell/HashTableCell.js.map +1 -1
- package/dist/browser/components/TableCell/index.cjs.map +1 -1
- package/dist/browser/components/TableCell/index.js.map +1 -1
- package/dist/browser/components/index.cjs +2 -2
- package/dist/browser/components/index.cjs.map +1 -1
- package/dist/browser/components/index.js +1 -1
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/docs.json +287 -287
- package/dist/node/components/ListItemButtonEx.cjs +2 -2
- package/dist/node/components/ListItemButtonEx.cjs.map +1 -1
- package/dist/node/components/ListItemButtonEx.d.cts +1 -1
- package/dist/node/components/ListItemButtonEx.d.cts.map +1 -1
- package/dist/node/components/ListItemButtonEx.d.mts +1 -1
- package/dist/node/components/ListItemButtonEx.d.mts.map +1 -1
- package/dist/node/components/ListItemButtonEx.d.ts +1 -1
- package/dist/node/components/ListItemButtonEx.d.ts.map +1 -1
- package/dist/node/components/ListItemButtonEx.js +1 -1
- package/dist/node/components/ListItemButtonEx.js.map +1 -1
- package/dist/node/components/TableCell/AddressTableCell.cjs.map +1 -1
- package/dist/node/components/TableCell/AddressTableCell.js.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.cjs.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.cts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.cts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.mts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.mts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.ts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.d.ts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.cjs.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.cts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.cts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.mts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.mts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.ts +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.d.ts.map +1 -1
- package/dist/node/components/TableCell/EllipsisTableCellDeprecated.js.map +1 -1
- package/dist/node/components/TableCell/HashTableCell.cjs.map +1 -1
- package/dist/node/components/TableCell/HashTableCell.js.map +1 -1
- package/dist/node/components/TableCell/index.cjs.map +1 -1
- package/dist/node/components/TableCell/index.js.map +1 -1
- package/dist/node/components/index.cjs +2 -2
- package/dist/node/components/index.cjs.map +1 -1
- package/dist/node/components/index.js +1 -1
- package/dist/node/components/index.js.map +1 -1
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +12 -12
- package/src/components/BasicHero/BasicHero.stories.tsx +1 -1
- package/src/components/ListItemButtonEx.tsx +1 -1
- package/src/components/SectionSpacingRow/SectionSpacingRow.stories.tsx +1 -1
- package/src/components/TableCell/EllipsisTableCell.tsx +1 -1
- package/src/components/TableCell/EllipsisTableCellDeprecated.tsx +1 -1
- package/src/components/TableCell/EllipsizeTableCell.stories.tsx +1 -1
- package/src/components/ThemeTokenAvatar/ThemeTokenAvatar.stories.tsx +1 -1
- package/src/components/ThemeTokenAvatarGroup/ThemeTokenAvatarGroup.stories.tsx +1 -1
- package/src/components/TokenBar/TokenBar.stories.tsx +1 -1
- package/src/components/TokenSummary/TokenSummary.stories.tsx +1 -1
- package/src/hooks/GradientStyles/GradientStyle.stories.tsx +1 -1
|
@@ -25,10 +25,10 @@ __export(ListItemButtonEx_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(ListItemButtonEx_exports);
|
|
27
27
|
var import_material = require("@mui/material");
|
|
28
|
-
var
|
|
28
|
+
var import_react_router_dom = require("react-router-dom");
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var ListItemButtonExTo = ({ to, toOptions, onClick, ...props }) => {
|
|
31
|
-
const navigate = (0,
|
|
31
|
+
const navigate = (0, import_react_router_dom.useNavigate)();
|
|
32
32
|
const localOnClick = (event) => {
|
|
33
33
|
onClick?.(event);
|
|
34
34
|
if (to) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ListItemButtonEx.tsx"],"sourcesContent":["import { ListItemButton, ListItemButtonProps } from '@mui/material'\nimport { MouseEvent } from 'react'\nimport { NavigateOptions, To, useNavigate } from 'react-router-dom
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ListItemButtonEx.tsx"],"sourcesContent":["import { ListItemButton, ListItemButtonProps } from '@mui/material'\nimport { MouseEvent } from 'react'\nimport { NavigateOptions, To, useNavigate } from 'react-router-dom'\n\nexport interface ListItemButtonExProps extends ListItemButtonProps {\n target?: string\n to?: To\n toOptions?: NavigateOptions\n}\n\nexport const ListItemButtonExTo: React.FC<ListItemButtonExProps> = ({ to, toOptions, onClick, ...props }) => {\n const navigate = useNavigate()\n const localOnClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (to) {\n navigate(to, toOptions)\n }\n }\n\n return <ListItemButton onClick={localOnClick} {...props} />\n}\n\nexport const ListItemButtonEx: React.FC<ListItemButtonExProps> = ({ to, ...props }) => {\n if (to) {\n return <ListItemButtonExTo to={to} {...props} />\n } else {\n return <ListItemButton {...props} />\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoD;AAEpD,8BAAiD;AAiBxC;AATF,IAAM,qBAAsD,CAAC,EAAE,IAAI,WAAW,SAAS,GAAG,MAAM,MAAM;AAC3G,QAAM,eAAW,qCAAY;AAC7B,QAAM,eAAe,CAAC,UAAsC;AAC1D,cAAU,KAAK;AACf,QAAI,IAAI;AACN,eAAS,IAAI,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,4CAAC,kCAAe,SAAS,cAAe,GAAG,OAAO;AAC3D;AAEO,IAAM,mBAAoD,CAAC,EAAE,IAAI,GAAG,MAAM,MAAM;AACrF,MAAI,IAAI;AACN,WAAO,4CAAC,sBAAmB,IAAS,GAAG,OAAO;AAAA,EAChD,OAAO;AACL,WAAO,4CAAC,kCAAgB,GAAG,OAAO;AAAA,EACpC;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ListItemButtonProps } from '@mui/material';
|
|
3
|
-
import { NavigateOptions, To } from 'react-router-dom
|
|
3
|
+
import { NavigateOptions, To } from 'react-router-dom';
|
|
4
4
|
export interface ListItemButtonExProps extends ListItemButtonProps {
|
|
5
5
|
target?: string;
|
|
6
6
|
to?: To;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,kBAAkB,CAAA;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAU9D,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAM5D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ListItemButtonProps } from '@mui/material';
|
|
3
|
-
import { NavigateOptions, To } from 'react-router-dom
|
|
3
|
+
import { NavigateOptions, To } from 'react-router-dom';
|
|
4
4
|
export interface ListItemButtonExProps extends ListItemButtonProps {
|
|
5
5
|
target?: string;
|
|
6
6
|
to?: To;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,kBAAkB,CAAA;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAU9D,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAM5D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ListItemButtonProps } from '@mui/material';
|
|
3
|
-
import { NavigateOptions, To } from 'react-router-dom
|
|
3
|
+
import { NavigateOptions, To } from 'react-router-dom';
|
|
4
4
|
export interface ListItemButtonExProps extends ListItemButtonProps {
|
|
5
5
|
target?: string;
|
|
6
6
|
to?: To;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"ListItemButtonEx.d.ts","sourceRoot":"","sources":["../../../src/components/ListItemButtonEx.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAe,MAAM,kBAAkB,CAAA;AAEnE,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAU9D,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAM5D,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/components/ListItemButtonEx.tsx
|
|
2
2
|
import { ListItemButton } from "@mui/material";
|
|
3
|
-
import { useNavigate } from "react-router-dom
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var ListItemButtonExTo = ({ to, toOptions, onClick, ...props }) => {
|
|
6
6
|
const navigate = useNavigate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/ListItemButtonEx.tsx"],"sourcesContent":["import { ListItemButton, ListItemButtonProps } from '@mui/material'\nimport { MouseEvent } from 'react'\nimport { NavigateOptions, To, useNavigate } from 'react-router-dom
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ListItemButtonEx.tsx"],"sourcesContent":["import { ListItemButton, ListItemButtonProps } from '@mui/material'\nimport { MouseEvent } from 'react'\nimport { NavigateOptions, To, useNavigate } from 'react-router-dom'\n\nexport interface ListItemButtonExProps extends ListItemButtonProps {\n target?: string\n to?: To\n toOptions?: NavigateOptions\n}\n\nexport const ListItemButtonExTo: React.FC<ListItemButtonExProps> = ({ to, toOptions, onClick, ...props }) => {\n const navigate = useNavigate()\n const localOnClick = (event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event)\n if (to) {\n navigate(to, toOptions)\n }\n }\n\n return <ListItemButton onClick={localOnClick} {...props} />\n}\n\nexport const ListItemButtonEx: React.FC<ListItemButtonExProps> = ({ to, ...props }) => {\n if (to) {\n return <ListItemButtonExTo to={to} {...props} />\n } else {\n return <ListItemButton {...props} />\n }\n}\n"],"mappings":";AAAA,SAAS,sBAA2C;AAEpD,SAA8B,mBAAmB;AAiBxC;AATF,IAAM,qBAAsD,CAAC,EAAE,IAAI,WAAW,SAAS,GAAG,MAAM,MAAM;AAC3G,QAAM,WAAW,YAAY;AAC7B,QAAM,eAAe,CAAC,UAAsC;AAC1D,cAAU,KAAK;AACf,QAAI,IAAI;AACN,eAAS,IAAI,SAAS;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,oBAAC,kBAAe,SAAS,cAAe,GAAG,OAAO;AAC3D;AAEO,IAAM,mBAAoD,CAAC,EAAE,IAAI,GAAG,MAAM,MAAM;AACrF,MAAI,IAAI;AACN,WAAO,oBAAC,sBAAmB,IAAS,GAAG,OAAO;AAAA,EAChD,OAAO;AACL,WAAO,oBAAC,kBAAgB,GAAG,OAAO;AAAA,EACpC;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/TableCell/AddressTableCell.tsx","../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { forwardRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface AddressTableCellProps extends EllipsisTableCellProps {\n /** @deprecated - archives are no longer supported */\n archive?: string\n /** @deprecated - use events instead */\n exploreDomain?: string\n link?: boolean\n}\n\nconst AddressTableCell = forwardRef<HTMLTableCellElement, AddressTableCellProps>(({ value, archive, exploreDomain, link, ...props }, ref) => {\n const href = exploreDomain && archive ? `${exploreDomain}/archive/${archive}/address/${value}` : undefined\n const to = exploreDomain === undefined && archive ? `/archive/${archive}/address/${value}` : undefined\n\n return <EllipsisTableCell value={value} href={href} to={to} ref={ref} link={link} {...props} />\n})\n\nAddressTableCell.displayName = 'AddressTableCell'\nexport { AddressTableCell }\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-6'\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;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA2B;;;ACA3B,IAAAC,mBAAkD;AAClD,wBAAuB;AAEvB,IAAAC,gBAAoC;;;ACHpC,sBAAsF;AAEtF,IAAAC,gBAAkD;;;ACFlD,mBAAgD;AAEzC,IAAM,uBAAuB,CAAI,cAA+B,UAAU,MAAM;AAErF,QAAM,eAAW,qBAAU,IAAI;AAE/B,8BAAU,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,oBAAgB,wBAAO,qBAAK;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,yBAAqB,wBAAO,qBAAK;AAAA,EACrC,MAAM;AAAA,EACN,MAAM;AACR,CAAC,EAAE,OAAO;AAAA,EACR,UAAU;AACZ,EAAE;A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S,SAAS;AAAA,EACtC,MAAM;AACR,CAAC,EAAE,CAAC,EAAE,QAAQ,OAAO,OAAO;AAAA,EAC1B;AACF,EAAE;AAgBK,IAAM,+BAA2E;AAAA,EACtF,CAAC,EAAE,UAAU,MAAM,OAAO,OAAO,IAAI,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC9D,UAAM,WAAO,uBAAQ,MAAM;AACzB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,QAAQ,IAAI;AACtB,eACE,6CAAC,4BAAO,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,6CAAC,yBAAsB,KAAW,GAAG,OACnC,uDAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;;;ADtCxB,IAAAC,sBAAA;AAJT,IAAM,uBAAmB,0BAAwD,CAAC,EAAE,OAAO,SAAS,eAAe,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC3I,QAAM,OAAO,iBAAiB,UAAU,GAAG,aAAa,YAAY,OAAO,YAAY,KAAK,KAAK;AACjG,QAAM,KAAK,kBAAkB,UAAa,UAAU,YAAY,OAAO,YAAY,KAAK,KAAK;AAE7F,SAAO,6CAAC,qBAAkB,OAAc,MAAY,IAAQ,KAAU,MAAa,GAAG,OAAO;AAC/F,CAAC;AAED,iBAAiB,cAAc;","names":["import_react","import_material","import_react","import_react","import_jsx_runtime","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/TableCell/AddressTableCell.tsx","../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { forwardRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface AddressTableCellProps extends EllipsisTableCellProps {\n /** @deprecated - archives are no longer supported */\n archive?: string\n /** @deprecated - use events instead */\n exploreDomain?: string\n link?: boolean\n}\n\nconst AddressTableCell = forwardRef<HTMLTableCellElement, AddressTableCellProps>(({ value, archive, exploreDomain, link, ...props }, ref) => {\n const href = exploreDomain && archive ? `${exploreDomain}/archive/${archive}/address/${value}` : undefined\n const to = exploreDomain === undefined && archive ? `/archive/${archive}/address/${value}` : undefined\n\n return <EllipsisTableCell value={value} href={href} to={to} ref={ref} link={link} {...props} />\n})\n\nAddressTableCell.displayName = 'AddressTableCell'\nexport { AddressTableCell }\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;AAA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M;AACzB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,QAAQ,IAAI;AACtB,eACE,6CAAC,4BAAO,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,6CAAC,yBAAsB,KAAW,GAAG,OACnC,uDAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;;;ADtCxB,IAAAC,sBAAA;AAJT,IAAM,uBAAmB,0BAAwD,CAAC,EAAE,OAAO,SAAS,eAAe,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC3I,QAAM,OAAO,iBAAiB,UAAU,GAAG,aAAa,YAAY,OAAO,YAAY,KAAK,KAAK;AACjG,QAAM,KAAK,kBAAkB,UAAa,UAAU,YAAY,OAAO,YAAY,KAAK,KAAK;AAE7F,SAAO,6CAAC,qBAAkB,OAAc,MAAY,IAAQ,KAAU,MAAa,GAAG,OAAO;AAC/F,CAAC;AAED,iBAAiB,cAAc;","names":["import_react","import_material","import_react","import_react","import_jsx_runtime","import_jsx_runtime"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/TableCell/AddressTableCell.tsx","../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { forwardRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface AddressTableCellProps extends EllipsisTableCellProps {\n /** @deprecated - archives are no longer supported */\n archive?: string\n /** @deprecated - use events instead */\n exploreDomain?: string\n link?: boolean\n}\n\nconst AddressTableCell = forwardRef<HTMLTableCellElement, AddressTableCellProps>(({ value, archive, exploreDomain, link, ...props }, ref) => {\n const href = exploreDomain && archive ? `${exploreDomain}/archive/${archive}/address/${value}` : undefined\n const to = exploreDomain === undefined && archive ? `/archive/${archive}/address/${value}` : undefined\n\n return <EllipsisTableCell value={value} href={href} to={to} ref={ref} link={link} {...props} />\n})\n\nAddressTableCell.displayName = 'AddressTableCell'\nexport { AddressTableCell }\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-6'\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,cAAAA,mBAAkB;;;ACA3B,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,c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C,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;;;ADtCxB,gBAAAG,YAAA;AAJT,IAAM,mBAAmBC,YAAwD,CAAC,EAAE,OAAO,SAAS,eAAe,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC3I,QAAM,OAAO,iBAAiB,UAAU,GAAG,aAAa,YAAY,OAAO,YAAY,KAAK,KAAK;AACjG,QAAM,KAAK,kBAAkB,UAAa,UAAU,YAAY,OAAO,YAAY,KAAK,KAAK;AAE7F,SAAO,gBAAAD,KAAC,qBAAkB,OAAc,MAAY,IAAQ,KAAU,MAAa,GAAG,OAAO;AAC/F,CAAC;AAED,iBAAiB,cAAc;","names":["forwardRef","styled","forwardRef","jsx","styled","forwardRef","jsx","forwardRef"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/TableCell/AddressTableCell.tsx","../../../../src/components/TableCell/EllipsisTableCell.tsx","../../../../src/components/Ellipsize.tsx","../../../../src/hooks/useShareForwardRef.ts"],"sourcesContent":["import { forwardRef } from 'react'\n\nimport { EllipsisTableCell, EllipsisTableCellProps } from './EllipsisTableCell'\n\nexport interface AddressTableCellProps extends EllipsisTableCellProps {\n /** @deprecated - archives are no longer supported */\n archive?: string\n /** @deprecated - use events instead */\n exploreDomain?: string\n link?: boolean\n}\n\nconst AddressTableCell = forwardRef<HTMLTableCellElement, AddressTableCellProps>(({ value, archive, exploreDomain, link, ...props }, ref) => {\n const href = exploreDomain && archive ? `${exploreDomain}/archive/${archive}/address/${value}` : undefined\n const to = exploreDomain === undefined && archive ? `/archive/${archive}/address/${value}` : undefined\n\n return <EllipsisTableCell value={value} href={href} to={to} ref={ref} link={link} {...props} />\n})\n\nAddressTableCell.displayName = 'AddressTableCell'\nexport { AddressTableCell }\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,cAAAA,mBAAkB;;;ACA3B,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,U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AEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;;;ADtCxB,gBAAAG,YAAA;AAJT,IAAM,mBAAmBC,YAAwD,CAAC,EAAE,OAAO,SAAS,eAAe,MAAM,GAAG,MAAM,GAAG,QAAQ;AAC3I,QAAM,OAAO,iBAAiB,UAAU,GAAG,aAAa,YAAY,OAAO,YAAY,KAAK,KAAK;AACjG,QAAM,KAAK,kBAAkB,UAAa,UAAU,YAAY,OAAO,YAAY,KAAK,KAAK;AAE7F,SAAO,gBAAAD,KAAC,qBAAkB,OAAc,MAAY,IAAQ,KAAU,MAAa,GAAG,OAAO;AAC/F,CAAC;AAED,iBAAiB,cAAc;","names":["forwardRef","styled","forwardRef","jsx","styled","forwardRef","jsx","forwardRef"]}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAkD;AAClD,wBAAuB;AAEvB,IAAAC,gBAAoC;;;ACHpC,sBAAsF;AAEtF,IAAAC,gBAAkD;;;ACFlD,mBAAgD;AAEzC,IAAM,uBAAuB,CAAI,cAA+B,UAAU,MAAM;AAErF,QAAM,eAAW,qBAAU,IAAI;AAE/B,8BAAU,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,oBAAgB,wBAAO,qBAAK;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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,EAEJ;AACF;AACA,aAAa,cAAc;;;ADpEjB,IAAAC,sBAAA;AA9BV,IAAM,4BAAwB,yBAAO,4BAAW;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,+BAA2E;AAAA,EACtF,CAAC,EAAE,UAAU,MAAM,OAAO,OAAO,IAAI,OAAO,GAAG,MAAM,GAAG,QAAQ;AAC9D,UAAM,WAAO,uBAAQ,MAAM;AACzB,UAAI,UAAU;AACZ,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,QAAQ,IAAI;AACtB,eACE,6CAAC,4BAAO,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,6CAAC,yBAAsB,KAAW,GAAG,OACnC,uDAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;","names":["import_material","import_react","import_react","import_jsx_runtime"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
3
|
import type { WithChildren } from '@xylabs/react-shared';
|
|
4
|
-
import { To } from 'react-router-dom
|
|
4
|
+
import { To } from 'react-router-dom';
|
|
5
5
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
6
6
|
href?: string;
|
|
7
7
|
link?: boolean;
|
|
@@ -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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAYrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAqBnF,CAAA;AAGD,eAAO,MAAM,iBAAiB,0DAA2B,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
3
|
import type { WithChildren } from '@xylabs/react-shared';
|
|
4
|
-
import { To } from 'react-router-dom
|
|
4
|
+
import { To } from 'react-router-dom';
|
|
5
5
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
6
6
|
href?: string;
|
|
7
7
|
link?: boolean;
|
|
@@ -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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAYrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAqBnF,CAAA;AAGD,eAAO,MAAM,iBAAiB,0DAA2B,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
3
|
import type { WithChildren } from '@xylabs/react-shared';
|
|
4
|
-
import { To } from 'react-router-dom
|
|
4
|
+
import { To } from 'react-router-dom';
|
|
5
5
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
6
6
|
href?: string;
|
|
7
7
|
link?: boolean;
|
|
@@ -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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
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,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAYrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAqBnF,CAAA;AAGD,eAAO,MAAM,iBAAiB,0DAA2B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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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9D,UAAM,YAAY,qBAAqB,GAAG;AAE1C,WACE,oBAAC,iBAAc,kBAAkB,CAAC,CAAC,aAAa,CAAC,mBAAmB,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 +1 @@
|
|
|
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-6'\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;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoD;AACpD,wBAAuB;AACvB,mBAA4C;;;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,MAA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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;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoD;A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AAA,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,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
|
-
import { To } from 'react-router-dom
|
|
3
|
+
import { To } from 'react-router-dom';
|
|
4
4
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
5
5
|
forCell?: number;
|
|
6
6
|
href?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAOrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,EAAE,CAAC,EAAE,EAAE,GAAG,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,8CAA8C;AAC9C,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAuFxE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
|
-
import { To } from 'react-router-dom
|
|
3
|
+
import { To } from 'react-router-dom';
|
|
4
4
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
5
5
|
forCell?: number;
|
|
6
6
|
href?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAOrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,EAAE,CAAC,EAAE,EAAE,GAAG,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,8CAA8C;AAC9C,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAuFxE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableCellProps } from '@mui/material';
|
|
3
|
-
import { To } from 'react-router-dom
|
|
3
|
+
import { To } from 'react-router-dom';
|
|
4
4
|
export interface EllipsisTableCellProps extends TableCellProps {
|
|
5
5
|
forCell?: number;
|
|
6
6
|
href?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"EllipsisTableCellDeprecated.d.ts","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCellDeprecated.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAOrC,MAAM,WAAW,sBAAuB,SAAQ,cAAc;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,EAAE,CAAC,EAAE,EAAE,GAAG,SAAS,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,8CAA8C;AAC9C,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAuFxE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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-6'\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,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A,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,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G,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 +1 @@
|
|
|
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-6'\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;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAyB;AACzB,IAAAA,gBAAuB;;;ACDvB,IAAAC,mBAAkD;AAClD,wBAAuB;AAEvB,IAAAC,gBAAoC;;;ACHpC,sBAAsF;AAEtF,IAAAC,gBAAkD;;;ACFlD,mBAAgD;AAEzC,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ACA,aAAO;AAAA,IACT,GAAG,CAAC,UAAU,MAAM,MAAM,IAAI,KAAK,CAAC;AACpC,WACE,6CAAC,yBAAsB,KAAW,GAAG,OACnC,uDAAC,gBAAa,IAAI,EAAE,QAAQ,QAAQ,MAAM,OAAO,YAAY,UAAU,GAAI,gBAAK,GAClF;AAAA,EAEJ;AACF;AAEA,yBAAyB,cAAc;AAChC,IAAM,oBAAoB;;;AD/B7B,IAAAC,sBAAA;AAXG,IAAM,gBAA8C,CAAC,EAAE,OAAO,SAAS,UAAU,SAAS,eAAe,GAAG,MAAM,MAAM;AAC7H,QAAM,UAAM,sBAAoC,IAAI;AACpD,QAAM,CAAC,cAAc,QAAQ,QAAI,6BAA+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":["import_react","import_material","import_react","import_react","import_jsx_runtime","import_jsx_runtime"]}
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAyB;AACzB,IAA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