@xyo-network/react-shared 2.25.67 → 2.25.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/PageCard.d.ts +8 -0
- package/dist/cjs/components/PageCard.js +14 -0
- package/dist/cjs/components/PageCard.js.map +1 -0
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/esm/components/PageCard.d.ts +8 -0
- package/dist/esm/components/PageCard.js +8 -0
- package/dist/esm/components/PageCard.js.map +1 -0
- package/dist/esm/components/TableCell/EllipsisTableCell.js +2 -4
- package/dist/esm/components/TableCell/EllipsisTableCell.js.map +1 -1
- package/dist/esm/components/TableCell/getRemainingRowWidth.d.ts +1 -1
- package/dist/esm/components/TableCell/getRemainingRowWidth.js +1 -1
- package/dist/esm/components/TableCell/getRemainingRowWidth.js.map +1 -1
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/PageCard.stories.tsx +62 -0
- package/src/components/PageCard.tsx +37 -0
- package/src/components/TableCell/EllipsisTableCell.tsx +2 -6
- package/src/components/TableCell/getRemainingRowWidth.ts +1 -1
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardHeaderProps, CardProps, SvgIconProps } from '@mui/material';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface PageCardProps extends CardProps {
|
|
4
|
+
icon?: (props?: SvgIconProps) => ReactNode;
|
|
5
|
+
onRefresh?: () => void;
|
|
6
|
+
subheader?: CardHeaderProps['subheader'];
|
|
7
|
+
}
|
|
8
|
+
export declare const PageCard: React.FC<PageCardProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageCard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const Refresh_1 = tslib_1.__importDefault(require("@mui/icons-material/Refresh"));
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const TypographyEx_1 = require("./TypographyEx");
|
|
9
|
+
const PageCard = (_a) => {
|
|
10
|
+
var { subheader, title, icon, onRefresh, children, style } = _a, props = tslib_1.__rest(_a, ["subheader", "title", "icon", "onRefresh", "children", "style"]);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Card, Object.assign({ style: Object.assign({ position: 'relative' }, style) }, props, { children: [icon === null || icon === void 0 ? void 0 : icon({ style: { fontSize: 512, left: '-144px', opacity: 0.05, position: 'absolute', top: '-144px' } }), (0, jsx_runtime_1.jsx)(material_1.CardHeader, { title: (0, jsx_runtime_1.jsx)(TypographyEx_1.TypographyEx, Object.assign({ variant: "h4", gradient: "text" }, { children: title })), subheader: subheader, action: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: onRefresh ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => onRefresh === null || onRefresh === void 0 ? void 0 : onRefresh() }, { children: (0, jsx_runtime_1.jsx)(Refresh_1.default, {}) }))) : null }) }), children] })));
|
|
12
|
+
};
|
|
13
|
+
exports.PageCard = PageCard;
|
|
14
|
+
//# sourceMappingURL=PageCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageCard.js","sourceRoot":"","sources":["../../../src/components/PageCard.tsx"],"names":[],"mappings":";;;;;AAAA,kFAAqD;AACrD,4CAAsG;AAGtG,iDAA6C;AAQtC,MAAM,QAAQ,GAA4B,CAAC,EAAgE,EAAE,EAAE;QAApE,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,OAAY,EAAP,KAAK,sBAA9D,gEAAgE,CAAF;IAC9G,OAAO,CACL,wBAAC,eAAI,kBAAC,KAAK,kBAAI,QAAQ,EAAE,UAAU,IAAK,KAAK,KAAQ,KAAK,eACvD,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,EACzG,uBAAC,qBAAU,IACT,KAAK,EACH,uBAAC,2BAAY,kBAAC,OAAO,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM,gBACvC,KAAK,IACO,EAEjB,SAAS,EAAE,SAAS,EACpB,MAAM,EACJ,2DACG,SAAS,CAAC,CAAC,CAAC,CACX,uBAAC,qBAAU,kBAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,EAAI,gBACtC,uBAAC,iBAAW,KAAG,IACJ,CACd,CAAC,CAAC,CAAC,IAAI,GACP,GAEL,EACD,QAAQ,KACJ,CACR,CAAA;AACH,CAAC,CAAA;AAxBY,QAAA,QAAQ,YAwBpB"}
|
|
@@ -4,6 +4,7 @@ export * from './ErrorBoundry';
|
|
|
4
4
|
export * from './FullWidthCard';
|
|
5
5
|
export * from './JsonRouteWrapper';
|
|
6
6
|
export * from './ListItemButtonEx';
|
|
7
|
+
export * from './PageCard';
|
|
7
8
|
export * from './Pipe';
|
|
8
9
|
export * from './ScrollTableOnSm';
|
|
9
10
|
export * from './SectionSpacingRow';
|
|
@@ -7,6 +7,7 @@ tslib_1.__exportStar(require("./ErrorBoundry"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./FullWidthCard"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./JsonRouteWrapper"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./ListItemButtonEx"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./PageCard"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./Pipe"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./ScrollTableOnSm"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./SectionSpacingRow"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAC3B,sDAA2B;AAC3B,yDAA8B;AAC9B,0DAA+B;AAC/B,6DAAkC;AAClC,6DAAkC;AAClC,iDAAsB;AACtB,4DAAiC;AACjC,8DAAmC;AACnC,uDAA4B;AAC5B,sDAA2B;AAC3B,yDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAC3B,sDAA2B;AAC3B,yDAA8B;AAC9B,0DAA+B;AAC/B,6DAAkC;AAClC,6DAAkC;AAClC,qDAA0B;AAC1B,iDAAsB;AACtB,4DAAiC;AACjC,8DAAmC;AACnC,uDAA4B;AAC5B,sDAA2B;AAC3B,yDAA8B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CardHeaderProps, CardProps, SvgIconProps } from '@mui/material';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface PageCardProps extends CardProps {
|
|
4
|
+
icon?: (props?: SvgIconProps) => ReactNode;
|
|
5
|
+
onRefresh?: () => void;
|
|
6
|
+
subheader?: CardHeaderProps['subheader'];
|
|
7
|
+
}
|
|
8
|
+
export declare const PageCard: React.FC<PageCardProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
3
|
+
import { Card, CardHeader, IconButton } from '@mui/material';
|
|
4
|
+
import { TypographyEx } from './TypographyEx';
|
|
5
|
+
export const PageCard = ({ subheader, title, icon, onRefresh, children, style, ...props }) => {
|
|
6
|
+
return (_jsxs(Card, { style: { position: 'relative', ...style }, ...props, children: [icon?.({ style: { fontSize: 512, left: '-144px', opacity: 0.05, position: 'absolute', top: '-144px' } }), _jsx(CardHeader, { title: _jsx(TypographyEx, { variant: "h4", gradient: "text", children: title }), subheader: subheader, action: _jsx(_Fragment, { children: onRefresh ? (_jsx(IconButton, { onClick: () => onRefresh?.(), children: _jsx(RefreshIcon, {}) })) : null }) }), children] }));
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=PageCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageCard.js","sourceRoot":"","sources":["../../../src/components/PageCard.tsx"],"names":[],"mappings":";AAAA,OAAO,WAAW,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,UAAU,EAA8B,UAAU,EAAgB,MAAM,eAAe,CAAA;AAGtG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQ7C,MAAM,CAAC,MAAM,QAAQ,GAA4B,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACpH,OAAO,CACL,MAAC,IAAI,IAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,KAAM,KAAK,aACvD,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,EACzG,KAAC,UAAU,IACT,KAAK,EACH,KAAC,YAAY,IAAC,OAAO,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM,YACvC,KAAK,GACO,EAEjB,SAAS,EAAE,SAAS,EACpB,MAAM,EACJ,4BACG,SAAS,CAAC,CAAC,CAAC,CACX,KAAC,UAAU,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,YACtC,KAAC,WAAW,KAAG,GACJ,CACd,CAAC,CAAC,CAAC,IAAI,GACP,GAEL,EACD,QAAQ,IACJ,CACR,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -19,8 +19,6 @@ export const EllipsisTableCell = ({ value, to, href, ...props }) => {
|
|
|
19
19
|
const [calcCellWidth, setCalcCellWidth] = useState(0);
|
|
20
20
|
const hashDivRef = useRef(null);
|
|
21
21
|
const theme = useTheme();
|
|
22
|
-
// We calulate the spacing since we know that table rows use padding.
|
|
23
|
-
const spacing = parseInt(theme.spacing(4).substring(-2));
|
|
24
22
|
useEffect(() => {
|
|
25
23
|
const currentElement = hashDivRef.current?.parentElement;
|
|
26
24
|
const cell = findParent('td', currentElement);
|
|
@@ -28,7 +26,7 @@ export const EllipsisTableCell = ({ value, to, href, ...props }) => {
|
|
|
28
26
|
const checkWidth = (cell) => {
|
|
29
27
|
const smallestParentWidth = getSmallestParentWidth(cell);
|
|
30
28
|
if (smallestParentWidth && row) {
|
|
31
|
-
const remainderWidth = smallestParentWidth - getRemainingRowWidth(row) - spacing;
|
|
29
|
+
const remainderWidth = smallestParentWidth - getRemainingRowWidth(row) - parseInt(theme.spacing(4).substring(0, -2)) * 4;
|
|
32
30
|
setCalcCellWidth(remainderWidth);
|
|
33
31
|
}
|
|
34
32
|
};
|
|
@@ -44,7 +42,7 @@ export const EllipsisTableCell = ({ value, to, href, ...props }) => {
|
|
|
44
42
|
return () => {
|
|
45
43
|
window.removeEventListener('resize', onResize);
|
|
46
44
|
};
|
|
47
|
-
}, [hashDivRef
|
|
45
|
+
}, [hashDivRef]);
|
|
48
46
|
return (_jsx(TableCell, { ...props, children: _jsx("div", { ref: hashDivRef, style: {
|
|
49
47
|
display: 'block',
|
|
50
48
|
maxWidth: calcCellWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAkB,UAAU,EAAmB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAOjE,MAAM,cAAc,GAAkC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IAClG,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAC,OAAO,EACf,UAAU,EAAC,WAAW,EACtB,KAAK,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,QAAQ;YAClB,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,QAAQ;YACpB,GAAG,KAAK;SACT,KACG,KAAK,YAER,KAAK,GACK,CACd,CAAA;AACH,CAAC,CAAA;AAQD,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE;IACnG,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAS,CAAC,CAAC,CAAA;IAC7D,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"EllipsisTableCell.js","sourceRoot":"","sources":["../../../../src/components/TableCell/EllipsisTableCell.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAk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C7D,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,GACvD,CACV,CAAC,CAAC,CAAC,CACF,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CAC/D,GACG,GACI,CACb,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** @description This is the width of all the cells (except the one passed) in the row combined */
|
|
1
|
+
/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */
|
|
2
2
|
export declare const getRemainingRowWidth: (row: HTMLElement, forCell?: number) => number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @description This is the width of all the cells (except the one passed) in the row combined */
|
|
1
|
+
/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */
|
|
2
2
|
export const getRemainingRowWidth = (row, forCell = 0) => {
|
|
3
3
|
let width = 0;
|
|
4
4
|
for (let i = 0; i < (row?.childElementCount ?? 0); i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRemainingRowWidth.js","sourceRoot":"","sources":["../../../../src/components/TableCell/getRemainingRowWidth.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"getRemainingRowWidth.js","sourceRoot":"","sources":["../../../../src/components/TableCell/getRemainingRowWidth.ts"],"names":[],"mappings":"AAAA,mIAAmI;AACnI,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAgB,EAAE,OAAO,GAAG,CAAC,EAAE,EAAE;IACpE,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACtD,MAAM,IAAI,GAAG,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAClC,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,KAAK,OAAO,EAAE;gBACjB,MAAM,YAAY,GAAG,IAAI,EAAE,qBAAqB,EAAE,CAAA;gBAClD,KAAK,IAAI,YAAY,EAAE,KAAK,IAAI,CAAC,CAAA;aAClC;SACF;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -4,6 +4,7 @@ export * from './ErrorBoundry';
|
|
|
4
4
|
export * from './FullWidthCard';
|
|
5
5
|
export * from './JsonRouteWrapper';
|
|
6
6
|
export * from './ListItemButtonEx';
|
|
7
|
+
export * from './PageCard';
|
|
7
8
|
export * from './Pipe';
|
|
8
9
|
export * from './ScrollTableOnSm';
|
|
9
10
|
export * from './SectionSpacingRow';
|
|
@@ -4,6 +4,7 @@ export * from './ErrorBoundry';
|
|
|
4
4
|
export * from './FullWidthCard';
|
|
5
5
|
export * from './JsonRouteWrapper';
|
|
6
6
|
export * from './ListItemButtonEx';
|
|
7
|
+
export * from './PageCard';
|
|
7
8
|
export * from './Pipe';
|
|
8
9
|
export * from './ScrollTableOnSm';
|
|
9
10
|
export * from './SectionSpacingRow';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,QAAQ,CAAA;AACtB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@xylabs/react-common": "^2.14.4",
|
|
21
21
|
"@xylabs/react-flexbox": "^2.14.4",
|
|
22
22
|
"@xylabs/react-shared": "^2.14.4",
|
|
23
|
-
"@xylabs/sdk-js": "^2.5.
|
|
23
|
+
"@xylabs/sdk-js": "^2.5.9",
|
|
24
24
|
"@xyo-network/api": "^2.20.45",
|
|
25
25
|
"@xyo-network/network": "^2.20.45",
|
|
26
26
|
"axios": "^0.27.2",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@babel/preset-env": "^7.18.2",
|
|
37
37
|
"@storybook/react": "^6.5.9",
|
|
38
38
|
"@xylabs/pixel": "^1.3.9",
|
|
39
|
-
"@xylabs/sdk-js": "^2.5.
|
|
39
|
+
"@xylabs/sdk-js": "^2.5.9",
|
|
40
40
|
"@xylabs/tsconfig": "^1.0.13"
|
|
41
41
|
},
|
|
42
42
|
"browser": "dist/esm/index.js",
|
|
@@ -88,6 +88,6 @@
|
|
|
88
88
|
},
|
|
89
89
|
"sideEffects": false,
|
|
90
90
|
"types": "dist/esm/index.d.ts",
|
|
91
|
-
"version": "2.25.
|
|
91
|
+
"version": "2.25.70",
|
|
92
92
|
"packageManager": "yarn@3.1.1"
|
|
93
93
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable import/no-internal-modules */
|
|
2
|
+
import { CardContent, Typography } from '@mui/material'
|
|
3
|
+
import { ComponentStory, Meta } from '@storybook/react'
|
|
4
|
+
import { useState } from 'react'
|
|
5
|
+
|
|
6
|
+
import { PageCard } from './PageCard'
|
|
7
|
+
|
|
8
|
+
const StorybookEntry: Meta = {
|
|
9
|
+
argTypes: {
|
|
10
|
+
onRefresh: {
|
|
11
|
+
table: {
|
|
12
|
+
disable: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
component: PageCard,
|
|
17
|
+
parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
page: null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
title: 'shared/PageCard',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Template: ComponentStory<typeof PageCard> = (props) => {
|
|
26
|
+
const [refreshedValue, setRefreshedValue] = useState<number>(Math.random)
|
|
27
|
+
return (
|
|
28
|
+
<PageCard title="Page Card" subheader="subheader" onRefresh={() => setRefreshedValue(Math.random())} {...props}>
|
|
29
|
+
<CardContent>
|
|
30
|
+
<Typography variant="body1">Page Card Content</Typography>
|
|
31
|
+
<Typography variant="body1">Refreshed Value: {refreshedValue?.toString()}</Typography>
|
|
32
|
+
</CardContent>
|
|
33
|
+
</PageCard>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const TemplateWithNoOnRefresh: ComponentStory<typeof PageCard> = (props) => {
|
|
38
|
+
return (
|
|
39
|
+
<PageCard title="Page Card" subheader="subheader" {...props}>
|
|
40
|
+
<CardContent>
|
|
41
|
+
<Typography variant="body1">Page Card Content</Typography>
|
|
42
|
+
</CardContent>
|
|
43
|
+
</PageCard>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const Default = Template.bind({})
|
|
48
|
+
Default.args = {}
|
|
49
|
+
Default.parameters = {
|
|
50
|
+
actions: { argTypesRegex: '' },
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const WithNoOnRefresh = TemplateWithNoOnRefresh.bind({})
|
|
54
|
+
WithNoOnRefresh.args = {}
|
|
55
|
+
WithNoOnRefresh.parameters = {
|
|
56
|
+
actions: { argTypesRegex: '' },
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { Default, WithNoOnRefresh }
|
|
60
|
+
|
|
61
|
+
// eslint-disable-next-line import/no-default-export
|
|
62
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import RefreshIcon from '@mui/icons-material/Refresh'
|
|
2
|
+
import { Card, CardHeader, CardHeaderProps, CardProps, IconButton, SvgIconProps } from '@mui/material'
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
import { TypographyEx } from './TypographyEx'
|
|
6
|
+
|
|
7
|
+
export interface PageCardProps extends CardProps {
|
|
8
|
+
icon?: (props?: SvgIconProps) => ReactNode
|
|
9
|
+
onRefresh?: () => void
|
|
10
|
+
subheader?: CardHeaderProps['subheader']
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const PageCard: React.FC<PageCardProps> = ({ subheader, title, icon, onRefresh, children, style, ...props }) => {
|
|
14
|
+
return (
|
|
15
|
+
<Card style={{ position: 'relative', ...style }} {...props}>
|
|
16
|
+
{icon?.({ style: { fontSize: 512, left: '-144px', opacity: 0.05, position: 'absolute', top: '-144px' } })}
|
|
17
|
+
<CardHeader
|
|
18
|
+
title={
|
|
19
|
+
<TypographyEx variant="h4" gradient="text">
|
|
20
|
+
{title}
|
|
21
|
+
</TypographyEx>
|
|
22
|
+
}
|
|
23
|
+
subheader={subheader}
|
|
24
|
+
action={
|
|
25
|
+
<>
|
|
26
|
+
{onRefresh ? (
|
|
27
|
+
<IconButton onClick={() => onRefresh?.()}>
|
|
28
|
+
<RefreshIcon />
|
|
29
|
+
</IconButton>
|
|
30
|
+
) : null}
|
|
31
|
+
</>
|
|
32
|
+
}
|
|
33
|
+
/>
|
|
34
|
+
{children}
|
|
35
|
+
</Card>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -41,12 +41,8 @@ export interface EllipsisTableCellProps extends TableCellProps {
|
|
|
41
41
|
export const EllipsisTableCell: React.FC<EllipsisTableCellProps> = ({ value, to, href, ...props }) => {
|
|
42
42
|
const [calcCellWidth, setCalcCellWidth] = useState<number>(0)
|
|
43
43
|
const hashDivRef = useRef<HTMLDivElement>(null)
|
|
44
|
-
|
|
45
44
|
const theme = useTheme()
|
|
46
45
|
|
|
47
|
-
// We calulate the spacing since we know that table rows use padding.
|
|
48
|
-
const spacing = parseInt(theme.spacing(4).substring(-2))
|
|
49
|
-
|
|
50
46
|
useEffect(() => {
|
|
51
47
|
const currentElement = hashDivRef.current?.parentElement
|
|
52
48
|
const cell = findParent('td', currentElement)
|
|
@@ -55,7 +51,7 @@ export const EllipsisTableCell: React.FC<EllipsisTableCellProps> = ({ value, to,
|
|
|
55
51
|
const checkWidth = (cell: HTMLElement) => {
|
|
56
52
|
const smallestParentWidth = getSmallestParentWidth(cell)
|
|
57
53
|
if (smallestParentWidth && row) {
|
|
58
|
-
const remainderWidth = smallestParentWidth - getRemainingRowWidth(row) - spacing
|
|
54
|
+
const remainderWidth = smallestParentWidth - getRemainingRowWidth(row) - parseInt(theme.spacing(4).substring(0, -2)) * 4
|
|
59
55
|
setCalcCellWidth(remainderWidth)
|
|
60
56
|
}
|
|
61
57
|
}
|
|
@@ -73,7 +69,7 @@ export const EllipsisTableCell: React.FC<EllipsisTableCellProps> = ({ value, to,
|
|
|
73
69
|
return () => {
|
|
74
70
|
window.removeEventListener('resize', onResize)
|
|
75
71
|
}
|
|
76
|
-
}, [hashDivRef
|
|
72
|
+
}, [hashDivRef])
|
|
77
73
|
|
|
78
74
|
return (
|
|
79
75
|
<TableCell {...props}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @description This is the width of all the cells (except the one passed) in the row combined */
|
|
1
|
+
/** @description This is the width of all the cells (except the one passed) in the row combined and the spacing of the main cell */
|
|
2
2
|
export const getRemainingRowWidth = (row: HTMLElement, forCell = 0) => {
|
|
3
3
|
let width = 0
|
|
4
4
|
for (let i = 0; i < (row?.childElementCount ?? 0); i++) {
|
package/src/components/index.ts
CHANGED