@xyo-network/react-table 2.77.2 → 2.78.1
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/index.cjs +103 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +80 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +103 -1
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +80 -1
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +113 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +80 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +7 -7
package/dist/browser/index.cjs
CHANGED
|
@@ -1,2 +1,104 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
TableCellEx: () => TableCellEx,
|
|
24
|
+
TableEx: () => TableEx,
|
|
25
|
+
TableExWithRef: () => TableExWithRef,
|
|
26
|
+
TableFooterEx: () => TableFooterEx,
|
|
27
|
+
TableHeightContext: () => TableHeightContext,
|
|
28
|
+
TableHeightProvider: () => TableHeightProvider,
|
|
29
|
+
useTableHeight: () => useTableHeight
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
34
|
+
var import_material = require("@mui/material");
|
|
35
|
+
var TableCellEx = (0, import_material.styled)(import_material.TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
36
|
+
({ noBgColor = true }) => ({
|
|
37
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// src/components/TableEx/TableEx.tsx
|
|
42
|
+
var import_material2 = require("@mui/material");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var TableExInner = (0, import_react.forwardRef)(({ children, ...props }, ref) => {
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.Table, { ref, ...props, children });
|
|
47
|
+
});
|
|
48
|
+
TableExInner.displayName = "TableExInner";
|
|
49
|
+
var TableExWithRef = (0, import_react.forwardRef)(({ variant, children, ...props }, ref) => {
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
51
|
+
});
|
|
52
|
+
TableExWithRef.displayName = "TableEx";
|
|
53
|
+
var TableEx = TableExWithRef;
|
|
54
|
+
|
|
55
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
56
|
+
var import_material3 = require("@mui/material");
|
|
57
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
58
|
+
var TableFooterExRoot = (0, import_material3.styled)(import_material3.TableFooter, {
|
|
59
|
+
name: "TableFooterEx",
|
|
60
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
61
|
+
slot: "Root"
|
|
62
|
+
})(({ variant, theme }) => ({
|
|
63
|
+
backgroundColor: theme.palette.background.default,
|
|
64
|
+
bottom: "unset",
|
|
65
|
+
position: "relative",
|
|
66
|
+
...variant === "scrollable" && {
|
|
67
|
+
bottom: 0,
|
|
68
|
+
position: "sticky"
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableFooterExRoot, { ...props, children });
|
|
72
|
+
|
|
73
|
+
// src/context/TableHeight/Context.ts
|
|
74
|
+
var import_react_shared = require("@xyo-network/react-shared");
|
|
75
|
+
var TableHeightContext = (0, import_react_shared.createContextEx)();
|
|
76
|
+
|
|
77
|
+
// src/context/TableHeight/Provider.tsx
|
|
78
|
+
var import_react2 = require("react");
|
|
79
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
80
|
+
var TableHeightProvider = ({
|
|
81
|
+
children,
|
|
82
|
+
additionalRows = 0,
|
|
83
|
+
defaultVisibleRows,
|
|
84
|
+
heightFormat = "px"
|
|
85
|
+
}) => {
|
|
86
|
+
const [visibleRows, setVisibleRows] = (0, import_react2.useState)(defaultVisibleRows);
|
|
87
|
+
const [height, setHeight] = (0, import_react2.useState)();
|
|
88
|
+
const [rowHeight, setRowHeight] = (0, import_react2.useState)();
|
|
89
|
+
const formattedHeight = (0, import_react2.useMemo)(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
setVisibleRows(defaultVisibleRows);
|
|
92
|
+
}, [defaultVisibleRows]);
|
|
93
|
+
(0, import_react2.useEffect)(() => {
|
|
94
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
95
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
96
|
+
}
|
|
97
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/context/TableHeight/use.tsx
|
|
102
|
+
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
103
|
+
var useTableHeight = (required = false) => (0, import_react_shared2.useContextEx)(TableHeightContext, "TableHeight", required);
|
|
2
104
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAkD;AAM3C,IAAM,kBAAc,wBAAO,2BAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,IAAAA,mBAAkC;AAClC,mBAA8C;AAU1C;AAFJ,IAAM,mBAAe,yBAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,4CAAC,0BAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,qBAAiB,yBAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,4CAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,IAAAC,mBAAsD;AAuBiC,IAAAC,sBAAA;AAlBvF,IAAM,wBAAoB,yBAAO,8BAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,6CAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,0BAAgC;AAIzB,IAAM,yBAAqB,qCAAkC;;;ACFpE,IAAAC,gBAA6C;AAkCzC,IAAAC,sBAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,QAAI,wBAA6B;AAE/D,QAAM,sBAAkB,uBAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,+BAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,+BAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,6CAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,IAAAC,uBAA6B;AAItB,IAAM,iBAAiB,CAAC,WAAW,cAAU,mCAAa,oBAAoB,eAAe,QAAQ;","names":["import_material","import_material","import_jsx_runtime","import_react","import_jsx_runtime","import_react_shared"]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
2
|
+
import { styled, TableCell } from "@mui/material";
|
|
3
|
+
var TableCellEx = styled(TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
4
|
+
({ noBgColor = true }) => ({
|
|
5
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
6
|
+
})
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
// src/components/TableEx/TableEx.tsx
|
|
10
|
+
import { Table } from "@mui/material";
|
|
11
|
+
import { forwardRef } from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
var TableExInner = forwardRef(({ children, ...props }, ref) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(Table, { ref, ...props, children });
|
|
15
|
+
});
|
|
16
|
+
TableExInner.displayName = "TableExInner";
|
|
17
|
+
var TableExWithRef = forwardRef(({ variant, children, ...props }, ref) => {
|
|
18
|
+
return /* @__PURE__ */ jsx(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
19
|
+
});
|
|
20
|
+
TableExWithRef.displayName = "TableEx";
|
|
21
|
+
var TableEx = TableExWithRef;
|
|
22
|
+
|
|
23
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
24
|
+
import { styled as styled2, TableFooter } from "@mui/material";
|
|
25
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
26
|
+
var TableFooterExRoot = styled2(TableFooter, {
|
|
27
|
+
name: "TableFooterEx",
|
|
28
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
29
|
+
slot: "Root"
|
|
30
|
+
})(({ variant, theme }) => ({
|
|
31
|
+
backgroundColor: theme.palette.background.default,
|
|
32
|
+
bottom: "unset",
|
|
33
|
+
position: "relative",
|
|
34
|
+
...variant === "scrollable" && {
|
|
35
|
+
bottom: 0,
|
|
36
|
+
position: "sticky"
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ jsx2(TableFooterExRoot, { ...props, children });
|
|
40
|
+
|
|
41
|
+
// src/context/TableHeight/Context.ts
|
|
42
|
+
import { createContextEx } from "@xyo-network/react-shared";
|
|
43
|
+
var TableHeightContext = createContextEx();
|
|
44
|
+
|
|
45
|
+
// src/context/TableHeight/Provider.tsx
|
|
46
|
+
import { useEffect, useMemo, useState } from "react";
|
|
47
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
48
|
+
var TableHeightProvider = ({
|
|
49
|
+
children,
|
|
50
|
+
additionalRows = 0,
|
|
51
|
+
defaultVisibleRows,
|
|
52
|
+
heightFormat = "px"
|
|
53
|
+
}) => {
|
|
54
|
+
const [visibleRows, setVisibleRows] = useState(defaultVisibleRows);
|
|
55
|
+
const [height, setHeight] = useState();
|
|
56
|
+
const [rowHeight, setRowHeight] = useState();
|
|
57
|
+
const formattedHeight = useMemo(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setVisibleRows(defaultVisibleRows);
|
|
60
|
+
}, [defaultVisibleRows]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
63
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
64
|
+
}
|
|
65
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
66
|
+
return /* @__PURE__ */ jsx3(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/context/TableHeight/use.tsx
|
|
70
|
+
import { useContextEx } from "@xyo-network/react-shared";
|
|
71
|
+
var useTableHeight = (required = false) => useContextEx(TableHeightContext, "TableHeight", required);
|
|
72
|
+
export {
|
|
73
|
+
TableCellEx,
|
|
74
|
+
TableEx,
|
|
75
|
+
TableExWithRef,
|
|
76
|
+
TableFooterEx,
|
|
77
|
+
TableHeightContext,
|
|
78
|
+
TableHeightProvider,
|
|
79
|
+
useTableHeight
|
|
80
|
+
};
|
|
2
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";AAAA,SAAS,QAAQ,iBAAiC;AAM3C,IAAM,cAAc,OAAO,WAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,SAAS,aAAyB;AAClC,SAAS,kBAAqC;AAU1C;AAFJ,IAAM,eAAe,WAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,oBAAC,SAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,iBAAiB,WAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,oBAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,SAAS,UAAAA,SAAQ,mBAAqC;AAuBiC,gBAAAC,YAAA;AAlBvF,IAAM,oBAAoBD,QAAO,aAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,gBAAAC,KAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,SAAS,uBAAuB;AAIzB,IAAM,qBAAqB,gBAAkC;;;ACFpE,SAAS,WAAW,SAAS,gBAAgB;AAkCzC,gBAAAC,YAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,IAAI,SAA6B;AAE/D,QAAM,kBAAkB,QAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,YAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,YAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,gBAAAA,KAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,SAAS,oBAAoB;AAItB,IAAM,iBAAiB,CAAC,WAAW,UAAU,aAAa,oBAAoB,eAAe,QAAQ;","names":["styled","jsx","jsx"]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,2 +1,104 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
TableCellEx: () => TableCellEx,
|
|
24
|
+
TableEx: () => TableEx,
|
|
25
|
+
TableExWithRef: () => TableExWithRef,
|
|
26
|
+
TableFooterEx: () => TableFooterEx,
|
|
27
|
+
TableHeightContext: () => TableHeightContext,
|
|
28
|
+
TableHeightProvider: () => TableHeightProvider,
|
|
29
|
+
useTableHeight: () => useTableHeight
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
34
|
+
var import_material = require("@mui/material");
|
|
35
|
+
var TableCellEx = (0, import_material.styled)(import_material.TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
36
|
+
({ noBgColor = true }) => ({
|
|
37
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// src/components/TableEx/TableEx.tsx
|
|
42
|
+
var import_material2 = require("@mui/material");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var TableExInner = (0, import_react.forwardRef)(({ children, ...props }, ref) => {
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.Table, { ref, ...props, children });
|
|
47
|
+
});
|
|
48
|
+
TableExInner.displayName = "TableExInner";
|
|
49
|
+
var TableExWithRef = (0, import_react.forwardRef)(({ variant, children, ...props }, ref) => {
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
51
|
+
});
|
|
52
|
+
TableExWithRef.displayName = "TableEx";
|
|
53
|
+
var TableEx = TableExWithRef;
|
|
54
|
+
|
|
55
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
56
|
+
var import_material3 = require("@mui/material");
|
|
57
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
58
|
+
var TableFooterExRoot = (0, import_material3.styled)(import_material3.TableFooter, {
|
|
59
|
+
name: "TableFooterEx",
|
|
60
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
61
|
+
slot: "Root"
|
|
62
|
+
})(({ variant, theme }) => ({
|
|
63
|
+
backgroundColor: theme.palette.background.default,
|
|
64
|
+
bottom: "unset",
|
|
65
|
+
position: "relative",
|
|
66
|
+
...variant === "scrollable" && {
|
|
67
|
+
bottom: 0,
|
|
68
|
+
position: "sticky"
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableFooterExRoot, { ...props, children });
|
|
72
|
+
|
|
73
|
+
// src/context/TableHeight/Context.ts
|
|
74
|
+
var import_react_shared = require("@xyo-network/react-shared");
|
|
75
|
+
var TableHeightContext = (0, import_react_shared.createContextEx)();
|
|
76
|
+
|
|
77
|
+
// src/context/TableHeight/Provider.tsx
|
|
78
|
+
var import_react2 = require("react");
|
|
79
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
80
|
+
var TableHeightProvider = ({
|
|
81
|
+
children,
|
|
82
|
+
additionalRows = 0,
|
|
83
|
+
defaultVisibleRows,
|
|
84
|
+
heightFormat = "px"
|
|
85
|
+
}) => {
|
|
86
|
+
const [visibleRows, setVisibleRows] = (0, import_react2.useState)(defaultVisibleRows);
|
|
87
|
+
const [height, setHeight] = (0, import_react2.useState)();
|
|
88
|
+
const [rowHeight, setRowHeight] = (0, import_react2.useState)();
|
|
89
|
+
const formattedHeight = (0, import_react2.useMemo)(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
setVisibleRows(defaultVisibleRows);
|
|
92
|
+
}, [defaultVisibleRows]);
|
|
93
|
+
(0, import_react2.useEffect)(() => {
|
|
94
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
95
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
96
|
+
}
|
|
97
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/context/TableHeight/use.tsx
|
|
102
|
+
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
103
|
+
var useTableHeight = (required = false) => (0, import_react_shared2.useContextEx)(TableHeightContext, "TableHeight", required);
|
|
2
104
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAkD;AAM3C,IAAM,kBAAc,wBAAO,2BAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,IAAAA,mBAAkC;AAClC,mBAA8C;AAU1C;AAFJ,IAAM,mBAAe,yBAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,4CAAC,0BAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,qBAAiB,yBAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,4CAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,IAAAC,mBAAsD;AAuBiC,IAAAC,sBAAA;AAlBvF,IAAM,wBAAoB,yBAAO,8BAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,6CAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,0BAAgC;AAIzB,IAAM,yBAAqB,qCAAkC;;;ACFpE,IAAAC,gBAA6C;AAkCzC,IAAAC,sBAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,QAAI,wBAA6B;AAE/D,QAAM,sBAAkB,uBAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,+BAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,+BAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,6CAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,IAAAC,uBAA6B;AAItB,IAAM,iBAAiB,CAAC,WAAW,cAAU,mCAAa,oBAAoB,eAAe,QAAQ;","names":["import_material","import_material","import_jsx_runtime","import_react","import_jsx_runtime","import_react_shared"]}
|
package/dist/neutral/index.js
CHANGED
|
@@ -1,2 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
2
|
+
import { styled, TableCell } from "@mui/material";
|
|
3
|
+
var TableCellEx = styled(TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
4
|
+
({ noBgColor = true }) => ({
|
|
5
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
6
|
+
})
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
// src/components/TableEx/TableEx.tsx
|
|
10
|
+
import { Table } from "@mui/material";
|
|
11
|
+
import { forwardRef } from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
var TableExInner = forwardRef(({ children, ...props }, ref) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(Table, { ref, ...props, children });
|
|
15
|
+
});
|
|
16
|
+
TableExInner.displayName = "TableExInner";
|
|
17
|
+
var TableExWithRef = forwardRef(({ variant, children, ...props }, ref) => {
|
|
18
|
+
return /* @__PURE__ */ jsx(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
19
|
+
});
|
|
20
|
+
TableExWithRef.displayName = "TableEx";
|
|
21
|
+
var TableEx = TableExWithRef;
|
|
22
|
+
|
|
23
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
24
|
+
import { styled as styled2, TableFooter } from "@mui/material";
|
|
25
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
26
|
+
var TableFooterExRoot = styled2(TableFooter, {
|
|
27
|
+
name: "TableFooterEx",
|
|
28
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
29
|
+
slot: "Root"
|
|
30
|
+
})(({ variant, theme }) => ({
|
|
31
|
+
backgroundColor: theme.palette.background.default,
|
|
32
|
+
bottom: "unset",
|
|
33
|
+
position: "relative",
|
|
34
|
+
...variant === "scrollable" && {
|
|
35
|
+
bottom: 0,
|
|
36
|
+
position: "sticky"
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ jsx2(TableFooterExRoot, { ...props, children });
|
|
40
|
+
|
|
41
|
+
// src/context/TableHeight/Context.ts
|
|
42
|
+
import { createContextEx } from "@xyo-network/react-shared";
|
|
43
|
+
var TableHeightContext = createContextEx();
|
|
44
|
+
|
|
45
|
+
// src/context/TableHeight/Provider.tsx
|
|
46
|
+
import { useEffect, useMemo, useState } from "react";
|
|
47
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
48
|
+
var TableHeightProvider = ({
|
|
49
|
+
children,
|
|
50
|
+
additionalRows = 0,
|
|
51
|
+
defaultVisibleRows,
|
|
52
|
+
heightFormat = "px"
|
|
53
|
+
}) => {
|
|
54
|
+
const [visibleRows, setVisibleRows] = useState(defaultVisibleRows);
|
|
55
|
+
const [height, setHeight] = useState();
|
|
56
|
+
const [rowHeight, setRowHeight] = useState();
|
|
57
|
+
const formattedHeight = useMemo(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setVisibleRows(defaultVisibleRows);
|
|
60
|
+
}, [defaultVisibleRows]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
63
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
64
|
+
}
|
|
65
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
66
|
+
return /* @__PURE__ */ jsx3(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/context/TableHeight/use.tsx
|
|
70
|
+
import { useContextEx } from "@xyo-network/react-shared";
|
|
71
|
+
var useTableHeight = (required = false) => useContextEx(TableHeightContext, "TableHeight", required);
|
|
72
|
+
export {
|
|
73
|
+
TableCellEx,
|
|
74
|
+
TableEx,
|
|
75
|
+
TableExWithRef,
|
|
76
|
+
TableFooterEx,
|
|
77
|
+
TableHeightContext,
|
|
78
|
+
TableHeightProvider,
|
|
79
|
+
useTableHeight
|
|
80
|
+
};
|
|
2
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";AAAA,SAAS,QAAQ,iBAAiC;AAM3C,IAAM,cAAc,OAAO,WAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,SAAS,aAAyB;AAClC,SAAS,kBAAqC;AAU1C;AAFJ,IAAM,eAAe,WAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,oBAAC,SAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,iBAAiB,WAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,oBAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,SAAS,UAAAA,SAAQ,mBAAqC;AAuBiC,gBAAAC,YAAA;AAlBvF,IAAM,oBAAoBD,QAAO,aAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,gBAAAC,KAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,SAAS,uBAAuB;AAIzB,IAAM,qBAAqB,gBAAkC;;;ACFpE,SAAS,WAAW,SAAS,gBAAgB;AAkCzC,gBAAAC,YAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,IAAI,SAA6B;AAE/D,QAAM,kBAAkB,QAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,YAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,YAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,gBAAAA,KAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,SAAS,oBAAoB;AAItB,IAAM,iBAAiB,CAAC,WAAW,UAAU,aAAa,oBAAoB,eAAe,QAAQ;","names":["styled","jsx","jsx"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,2 +1,114 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
TableCellEx: () => TableCellEx,
|
|
24
|
+
TableEx: () => TableEx,
|
|
25
|
+
TableExWithRef: () => TableExWithRef,
|
|
26
|
+
TableFooterEx: () => TableFooterEx,
|
|
27
|
+
TableHeightContext: () => TableHeightContext,
|
|
28
|
+
TableHeightProvider: () => TableHeightProvider,
|
|
29
|
+
useTableHeight: () => useTableHeight
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
34
|
+
var import_material = require("@mui/material");
|
|
35
|
+
var TableCellEx = (0, import_material.styled)(import_material.TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
36
|
+
({ noBgColor = true }) => ({
|
|
37
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// src/components/TableEx/TableEx.tsx
|
|
42
|
+
var import_material2 = require("@mui/material");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
45
|
+
var TableExInner = (0, import_react.forwardRef)(({ children, ...props }, ref) => {
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material2.Table, { ref, ...props, children });
|
|
47
|
+
});
|
|
48
|
+
TableExInner.displayName = "TableExInner";
|
|
49
|
+
var TableExWithRef = (0, import_react.forwardRef)(({ variant, children, ...props }, ref) => {
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
51
|
+
});
|
|
52
|
+
TableExWithRef.displayName = "TableEx";
|
|
53
|
+
var TableEx = TableExWithRef;
|
|
54
|
+
|
|
55
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
56
|
+
var import_material3 = require("@mui/material");
|
|
57
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
58
|
+
var TableFooterExRoot = (0, import_material3.styled)(import_material3.TableFooter, {
|
|
59
|
+
name: "TableFooterEx",
|
|
60
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
61
|
+
slot: "Root"
|
|
62
|
+
})(({ variant, theme }) => ({
|
|
63
|
+
backgroundColor: theme.palette.background.default,
|
|
64
|
+
bottom: "unset",
|
|
65
|
+
position: "relative",
|
|
66
|
+
...variant === "scrollable" && {
|
|
67
|
+
bottom: 0,
|
|
68
|
+
position: "sticky"
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TableFooterExRoot, { ...props, children });
|
|
72
|
+
|
|
73
|
+
// src/context/TableHeight/Context.ts
|
|
74
|
+
var import_react_shared = require("@xyo-network/react-shared");
|
|
75
|
+
var TableHeightContext = (0, import_react_shared.createContextEx)();
|
|
76
|
+
|
|
77
|
+
// src/context/TableHeight/Provider.tsx
|
|
78
|
+
var import_react2 = require("react");
|
|
79
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
80
|
+
var TableHeightProvider = ({
|
|
81
|
+
children,
|
|
82
|
+
additionalRows = 0,
|
|
83
|
+
defaultVisibleRows,
|
|
84
|
+
heightFormat = "px"
|
|
85
|
+
}) => {
|
|
86
|
+
const [visibleRows, setVisibleRows] = (0, import_react2.useState)(defaultVisibleRows);
|
|
87
|
+
const [height, setHeight] = (0, import_react2.useState)();
|
|
88
|
+
const [rowHeight, setRowHeight] = (0, import_react2.useState)();
|
|
89
|
+
const formattedHeight = (0, import_react2.useMemo)(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
90
|
+
(0, import_react2.useEffect)(() => {
|
|
91
|
+
setVisibleRows(defaultVisibleRows);
|
|
92
|
+
}, [defaultVisibleRows]);
|
|
93
|
+
(0, import_react2.useEffect)(() => {
|
|
94
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
95
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
96
|
+
}
|
|
97
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/context/TableHeight/use.tsx
|
|
102
|
+
var import_react_shared2 = require("@xyo-network/react-shared");
|
|
103
|
+
var useTableHeight = (required = false) => (0, import_react_shared2.useContextEx)(TableHeightContext, "TableHeight", required);
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
TableCellEx,
|
|
107
|
+
TableEx,
|
|
108
|
+
TableExWithRef,
|
|
109
|
+
TableFooterEx,
|
|
110
|
+
TableHeightContext,
|
|
111
|
+
TableHeightProvider,
|
|
112
|
+
useTableHeight
|
|
113
|
+
});
|
|
2
114
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["export * from './components'\nexport * from './context'\nexport * from './types'\n","import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAkD;AAM3C,IAAM,kBAAc,wBAAO,2BAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,IAAAA,mBAAkC;AAClC,mBAA8C;AAU1C;AAFJ,IAAM,mBAAe,yBAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,4CAAC,0BAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,qBAAiB,yBAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,4CAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,IAAAC,mBAAsD;AAuBiC,IAAAC,sBAAA;AAlBvF,IAAM,wBAAoB,yBAAO,8BAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,6CAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,0BAAgC;AAIzB,IAAM,yBAAqB,qCAAkC;;;ACFpE,IAAAC,gBAA6C;AAkCzC,IAAAC,sBAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,QAAI,wBAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,QAAI,wBAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,QAAI,wBAA6B;AAE/D,QAAM,sBAAkB,uBAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,+BAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,+BAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,6CAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,IAAAC,uBAA6B;AAItB,IAAM,iBAAiB,CAAC,WAAW,cAAU,mCAAa,oBAAoB,eAAe,QAAQ;","names":["import_material","import_material","import_jsx_runtime","import_react","import_jsx_runtime","import_react_shared"]}
|
package/dist/node/index.js
CHANGED
|
@@ -1,2 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
// src/components/TableEx/TableCellEx.tsx
|
|
2
|
+
import { styled, TableCell } from "@mui/material";
|
|
3
|
+
var TableCellEx = styled(TableCell, { name: "TableCellNoBgColor", shouldForwardProp: (prop) => prop !== "noBgColor" })(
|
|
4
|
+
({ noBgColor = true }) => ({
|
|
5
|
+
...noBgColor && { backgroundColor: "transparent" }
|
|
6
|
+
})
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
// src/components/TableEx/TableEx.tsx
|
|
10
|
+
import { Table } from "@mui/material";
|
|
11
|
+
import { forwardRef } from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
var TableExInner = forwardRef(({ children, ...props }, ref) => {
|
|
14
|
+
return /* @__PURE__ */ jsx(Table, { ref, ...props, children });
|
|
15
|
+
});
|
|
16
|
+
TableExInner.displayName = "TableExInner";
|
|
17
|
+
var TableExWithRef = forwardRef(({ variant, children, ...props }, ref) => {
|
|
18
|
+
return /* @__PURE__ */ jsx(TableExInner, { stickyHeader: variant === "scrollable", ref, ...props, children });
|
|
19
|
+
});
|
|
20
|
+
TableExWithRef.displayName = "TableEx";
|
|
21
|
+
var TableEx = TableExWithRef;
|
|
22
|
+
|
|
23
|
+
// src/components/TableEx/TableFooterEx.tsx
|
|
24
|
+
import { styled as styled2, TableFooter } from "@mui/material";
|
|
25
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
26
|
+
var TableFooterExRoot = styled2(TableFooter, {
|
|
27
|
+
name: "TableFooterEx",
|
|
28
|
+
shouldForwardProp: (propName) => propName !== "scrollable",
|
|
29
|
+
slot: "Root"
|
|
30
|
+
})(({ variant, theme }) => ({
|
|
31
|
+
backgroundColor: theme.palette.background.default,
|
|
32
|
+
bottom: "unset",
|
|
33
|
+
position: "relative",
|
|
34
|
+
...variant === "scrollable" && {
|
|
35
|
+
bottom: 0,
|
|
36
|
+
position: "sticky"
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
var TableFooterEx = ({ children, ...props }) => /* @__PURE__ */ jsx2(TableFooterExRoot, { ...props, children });
|
|
40
|
+
|
|
41
|
+
// src/context/TableHeight/Context.ts
|
|
42
|
+
import { createContextEx } from "@xyo-network/react-shared";
|
|
43
|
+
var TableHeightContext = createContextEx();
|
|
44
|
+
|
|
45
|
+
// src/context/TableHeight/Provider.tsx
|
|
46
|
+
import { useEffect, useMemo, useState } from "react";
|
|
47
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
48
|
+
var TableHeightProvider = ({
|
|
49
|
+
children,
|
|
50
|
+
additionalRows = 0,
|
|
51
|
+
defaultVisibleRows,
|
|
52
|
+
heightFormat = "px"
|
|
53
|
+
}) => {
|
|
54
|
+
const [visibleRows, setVisibleRows] = useState(defaultVisibleRows);
|
|
55
|
+
const [height, setHeight] = useState();
|
|
56
|
+
const [rowHeight, setRowHeight] = useState();
|
|
57
|
+
const formattedHeight = useMemo(() => height === void 0 ? void 0 : `${height}${heightFormat}`, [height, heightFormat]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setVisibleRows(defaultVisibleRows);
|
|
60
|
+
}, [defaultVisibleRows]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (rowHeight !== void 0 && visibleRows !== void 0) {
|
|
63
|
+
setHeight(rowHeight * (visibleRows + additionalRows));
|
|
64
|
+
}
|
|
65
|
+
}, [defaultVisibleRows, rowHeight, visibleRows, additionalRows]);
|
|
66
|
+
return /* @__PURE__ */ jsx3(TableHeightContext.Provider, { value: { height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }, children });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/context/TableHeight/use.tsx
|
|
70
|
+
import { useContextEx } from "@xyo-network/react-shared";
|
|
71
|
+
var useTableHeight = (required = false) => useContextEx(TableHeightContext, "TableHeight", required);
|
|
72
|
+
export {
|
|
73
|
+
TableCellEx,
|
|
74
|
+
TableEx,
|
|
75
|
+
TableExWithRef,
|
|
76
|
+
TableFooterEx,
|
|
77
|
+
TableHeightContext,
|
|
78
|
+
TableHeightProvider,
|
|
79
|
+
useTableHeight
|
|
80
|
+
};
|
|
2
81
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/TableEx/TableCellEx.tsx","../../src/components/TableEx/TableEx.tsx","../../src/components/TableEx/TableFooterEx.tsx","../../src/context/TableHeight/Context.ts","../../src/context/TableHeight/Provider.tsx","../../src/context/TableHeight/use.tsx"],"sourcesContent":["import { styled, TableCell, TableCellProps } from '@mui/material'\n\nexport interface TableCellExProps extends TableCellProps {\n noBgColor?: boolean\n}\n\nexport const TableCellEx = styled(TableCell, { name: 'TableCellNoBgColor', shouldForwardProp: (prop) => prop !== 'noBgColor' })<TableCellExProps>(\n ({ noBgColor = true }) => ({\n ...(noBgColor && { backgroundColor: 'transparent' }),\n }),\n)\n","import { Table, TableProps } from '@mui/material'\nimport { forwardRef, PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nexport interface TableExProps extends PropsWithChildren, TableProps {\n variant?: TableExVariants\n}\n\nconst TableExInner = forwardRef<HTMLTableElement, TableExProps>(({ children, ...props }, ref) => {\n return (\n <Table ref={ref} {...props}>\n {children}\n </Table>\n )\n})\n\nTableExInner.displayName = 'TableExInner'\n\nexport const TableExWithRef = forwardRef<HTMLTableElement, TableExProps>(({ variant, children, ...props }, ref) => {\n return (\n <TableExInner stickyHeader={variant === 'scrollable'} ref={ref} {...props}>\n {children}\n </TableExInner>\n )\n})\n\nTableExWithRef.displayName = 'TableEx'\n\nexport const TableEx = TableExWithRef\n","import { styled, TableFooter, TableFooterProps } from '@mui/material'\nimport { PropsWithChildren } from 'react'\n\nimport { TableExVariants } from './types'\n\nconst TableFooterExRoot = styled(TableFooter, {\n name: 'TableFooterEx',\n shouldForwardProp: (propName) => propName !== 'scrollable',\n slot: 'Root',\n})<TableFooterExProps>(({ variant, theme }) => ({\n backgroundColor: theme.palette.background.default,\n bottom: 'unset',\n position: 'relative',\n ...(variant === 'scrollable' && {\n bottom: 0,\n position: 'sticky',\n }),\n}))\n\nexport interface TableFooterExProps extends PropsWithChildren, TableFooterProps {\n variant?: TableExVariants\n}\n\nexport const TableFooterEx: React.FC<TableFooterExProps> = ({ children, ...props }) => <TableFooterExRoot {...props}>{children}</TableFooterExRoot>\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightState } from './State'\n\nexport const TableHeightContext = createContextEx<TableHeightState>()\n","import { WithChildren } from '@xylabs/react-shared'\nimport { ContextExProviderProps } from '@xyo-network/react-shared'\nimport { useEffect, useMemo, useState } from 'react'\n\nimport { TableHeightContext } from './Context'\n\nexport interface TableHeightProviderProps extends ContextExProviderProps, WithChildren {\n /** @field Account for optional header and footer rows */\n additionalRows?: number\n defaultVisibleRows?: number\n heightFormat?: string\n}\n\nexport const TableHeightProvider: React.FC<TableHeightProviderProps> = ({\n children,\n additionalRows = 0,\n defaultVisibleRows,\n heightFormat = 'px',\n}) => {\n const [visibleRows, setVisibleRows] = useState(defaultVisibleRows)\n const [height, setHeight] = useState<number | undefined>()\n const [rowHeight, setRowHeight] = useState<number | undefined>()\n\n const formattedHeight = useMemo(() => (height === undefined ? undefined : `${height}${heightFormat}`), [height, heightFormat])\n\n useEffect(() => {\n setVisibleRows(defaultVisibleRows)\n }, [defaultVisibleRows])\n\n useEffect(() => {\n if (rowHeight !== undefined && visibleRows !== undefined) {\n setHeight(rowHeight * (visibleRows + additionalRows))\n }\n }, [defaultVisibleRows, rowHeight, visibleRows, additionalRows])\n\n return (\n <TableHeightContext.Provider value={{ height: formattedHeight, provided: true, rowHeight, setRowHeight, setVisibleRows, visibleRows }}>\n {children}\n </TableHeightContext.Provider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { TableHeightContext } from './Context'\n\nexport const useTableHeight = (required = false) => useContextEx(TableHeightContext, 'TableHeight', required)\n"],"mappings":";AAAA,SAAS,QAAQ,iBAAiC;AAM3C,IAAM,cAAc,OAAO,WAAW,EAAE,MAAM,sBAAsB,mBAAmB,CAAC,SAAS,SAAS,YAAY,CAAC;AAAA,EAC5H,CAAC,EAAE,YAAY,KAAK,OAAO;AAAA,IACzB,GAAI,aAAa,EAAE,iBAAiB,cAAc;AAAA,EACpD;AACF;;;ACVA,SAAS,aAAyB;AAClC,SAAS,kBAAqC;AAU1C;AAFJ,IAAM,eAAe,WAA2C,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ;AAC/F,SACE,oBAAC,SAAM,KAAW,GAAG,OAClB,UACH;AAEJ,CAAC;AAED,aAAa,cAAc;AAEpB,IAAM,iBAAiB,WAA2C,CAAC,EAAE,SAAS,UAAU,GAAG,MAAM,GAAG,QAAQ;AACjH,SACE,oBAAC,gBAAa,cAAc,YAAY,cAAc,KAAW,GAAG,OACjE,UACH;AAEJ,CAAC;AAED,eAAe,cAAc;AAEtB,IAAM,UAAU;;;AC7BvB,SAAS,UAAAA,SAAQ,mBAAqC;AAuBiC,gBAAAC,YAAA;AAlBvF,IAAM,oBAAoBD,QAAO,aAAa;AAAA,EAC5C,MAAM;AAAA,EACN,mBAAmB,CAAC,aAAa,aAAa;AAAA,EAC9C,MAAM;AACR,CAAC,EAAsB,CAAC,EAAE,SAAS,MAAM,OAAO;AAAA,EAC9C,iBAAiB,MAAM,QAAQ,WAAW;AAAA,EAC1C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAI,YAAY,gBAAgB;AAAA,IAC9B,QAAQ;AAAA,IACR,UAAU;AAAA,EACZ;AACF,EAAE;AAMK,IAAM,gBAA8C,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,gBAAAC,KAAC,qBAAmB,GAAG,OAAQ,UAAS;;;ACvB/H,SAAS,uBAAuB;AAIzB,IAAM,qBAAqB,gBAAkC;;;ACFpE,SAAS,WAAW,SAAS,gBAAgB;AAkCzC,gBAAAC,YAAA;AAvBG,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA,eAAe;AACjB,MAAM;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,kBAAkB;AACjE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B;AACzD,QAAM,CAAC,WAAW,YAAY,IAAI,SAA6B;AAE/D,QAAM,kBAAkB,QAAQ,MAAO,WAAW,SAAY,SAAY,GAAG,MAAM,GAAG,YAAY,IAAK,CAAC,QAAQ,YAAY,CAAC;AAE7H,YAAU,MAAM;AACd,mBAAe,kBAAkB;AAAA,EACnC,GAAG,CAAC,kBAAkB,CAAC;AAEvB,YAAU,MAAM;AACd,QAAI,cAAc,UAAa,gBAAgB,QAAW;AACxD,gBAAU,aAAa,cAAc,eAAe;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,oBAAoB,WAAW,aAAa,cAAc,CAAC;AAE/D,SACE,gBAAAA,KAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM,WAAW,cAAc,gBAAgB,YAAY,GACjI,UACH;AAEJ;;;ACxCA,SAAS,oBAAoB;AAItB,IAAM,iBAAiB,CAAC,WAAW,UAAU,aAAa,oBAAoB,eAAe,QAAQ;","names":["styled","jsx","jsx"]}
|
package/package.json
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/react-shared": "^3.1.7",
|
|
14
|
-
"@xyo-network/react-shared": "
|
|
14
|
+
"@xyo-network/react-shared": "^2.78.1"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@storybook/react": "^7.6.
|
|
18
|
-
"@xylabs/ts-scripts-yarn3": "^3.11.
|
|
19
|
-
"@xylabs/tsconfig-react": "^3.11.
|
|
20
|
-
"@xyo-network/react-storybook": "
|
|
21
|
-
"typescript": "^5.
|
|
17
|
+
"@storybook/react": "^7.6.20",
|
|
18
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.12",
|
|
19
|
+
"@xylabs/tsconfig-react": "^3.11.12",
|
|
20
|
+
"@xyo-network/react-storybook": "^2.78.1",
|
|
21
|
+
"typescript": "^5.5.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@mui/icons-material": "^5",
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
},
|
|
79
79
|
"sideEffects": false,
|
|
80
80
|
"types": "dist/browser/index.d.ts",
|
|
81
|
-
"version": "2.
|
|
81
|
+
"version": "2.78.1",
|
|
82
82
|
"type": "module"
|
|
83
83
|
}
|