schummar-table 0.51.5 → 0.51.7
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/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -464,7 +464,7 @@ const defaultTableTheme = {
|
|
|
464
464
|
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/hooks/useTableMemo.tsx
|
|
467
|
-
const TableMemoContext = (0, react.createContext)(
|
|
467
|
+
const TableMemoContext = (0, react.createContext)(void 0);
|
|
468
468
|
function TableMemoContextProvider({ children }) {
|
|
469
469
|
return /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(TableMemoContext.Provider, {
|
|
470
470
|
value: (0, react.useMemo)(() => /* @__PURE__ */ new Map(), []),
|
|
@@ -472,7 +472,9 @@ function TableMemoContextProvider({ children }) {
|
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
function useTableMemo() {
|
|
475
|
-
const
|
|
475
|
+
const contextCache = (0, react.useContext)(TableMemoContext);
|
|
476
|
+
const localCache = (0, react.useRef)();
|
|
477
|
+
const memoCache = contextCache ?? (localCache.current ??= /* @__PURE__ */ new Map());
|
|
476
478
|
return (key, function_) => {
|
|
477
479
|
let deps;
|
|
478
480
|
if (Array.isArray(function_)) {
|
|
@@ -3393,7 +3395,7 @@ function ColumnSelection() {
|
|
|
3393
3395
|
const cssVariables = useCssVariables();
|
|
3394
3396
|
const table = useTableContext();
|
|
3395
3397
|
const reset = (0, react.useContext)(TableResetContext);
|
|
3396
|
-
const columns = table.useState((state) => state.props.columns.filter((column) => state.displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(state.displaySize)));
|
|
3398
|
+
const columns = table.useState((state) => orderBy(state.props.columns.filter((column) => state.displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(state.displaySize)), [(column) => state.columnOrder.indexOf(column.id)]));
|
|
3397
3399
|
const hiddenColumns = table.useState((state) => state.hiddenColumns);
|
|
3398
3400
|
const [anchorElement, setAnchorElement] = (0, react.useState)(null);
|
|
3399
3401
|
const toggle$1 = (column, state) => {
|
|
@@ -3905,9 +3907,15 @@ function Virtualized({ header, footer, children,...props }) {
|
|
|
3905
3907
|
//#region src/components/table.tsx
|
|
3906
3908
|
const Table = (0, react.forwardRef)(_Table);
|
|
3907
3909
|
function _Table(props, ref) {
|
|
3910
|
+
return /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(TableMemoContextProvider, { children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(TableWithState, {
|
|
3911
|
+
props,
|
|
3912
|
+
tableRef: ref
|
|
3913
|
+
}) });
|
|
3914
|
+
}
|
|
3915
|
+
function TableWithState({ props, tableRef }) {
|
|
3908
3916
|
const [table, resetState] = useTableState(props);
|
|
3909
3917
|
const [isHydrated, clearStorage] = useTableStateStorage(table);
|
|
3910
|
-
useTableRef(table,
|
|
3918
|
+
useTableRef(table, tableRef);
|
|
3911
3919
|
async function reset() {
|
|
3912
3920
|
await clearStorage();
|
|
3913
3921
|
resetState();
|
|
@@ -3919,7 +3927,7 @@ function _Table(props, ref) {
|
|
|
3919
3927
|
value: table,
|
|
3920
3928
|
children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(TableResetContext.Provider, {
|
|
3921
3929
|
value: reset,
|
|
3922
|
-
children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(
|
|
3930
|
+
children: /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(TableLoadingState, { isHydrated })
|
|
3923
3931
|
})
|
|
3924
3932
|
});
|
|
3925
3933
|
}
|