@mantine-vue/table 2.2.1 → 2.3.0
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/cjs/index.cjs +43 -27
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +44 -28
- package/esm/index.mjs.map +1 -1
- package/lib/mantine.types.d.ts +3 -27
- package/lib/types.d.ts +1 -1
- package/package.json +4 -4
package/esm/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { ActionIcon, Alert, Autocomplete, Badge, Box, Button, Checkbox, Collapse
|
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { compareItems, rankItem, rankings } from "@tanstack/match-sorter-utils";
|
|
6
6
|
import { IconArrowAutofitContent, IconArrowsSort, IconBaselineDensityLarge, IconBaselineDensityMedium, IconBaselineDensitySmall, IconBoxMultiple, IconChevronDown, IconChevronLeft, IconChevronLeftPipe, IconChevronRight, IconChevronRightPipe, IconChevronsDown, IconCircleX, IconClearAll, IconColumns, IconDeviceFloppy, IconDots, IconDotsVertical, IconEdit, IconEyeOff, IconFilter, IconFilterCog, IconFilterOff, IconGripHorizontal, IconMaximize, IconMinimize, IconPinned, IconPinnedOff, IconSearch, IconSearchOff, IconSortAscending, IconSortDescending, IconX } from "@tabler/icons-vue";
|
|
7
|
-
import { useDebouncedValue } from "@mantine-vue/hooks";
|
|
7
|
+
import { useDebouncedValue, useMediaQuery } from "@mantine-vue/hooks";
|
|
8
8
|
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/vue-virtual";
|
|
9
9
|
import { DateInput } from "@mantine-vue/dates";
|
|
10
10
|
//#region src/utils/column.utils.ts
|
|
@@ -1458,6 +1458,16 @@ var useMVT_TableOptions = (rawOptions) => {
|
|
|
1458
1458
|
enumerable: true,
|
|
1459
1459
|
get: () => rawOptions.columns
|
|
1460
1460
|
});
|
|
1461
|
+
Object.defineProperty(definedOptions, "state", {
|
|
1462
|
+
configurable: true,
|
|
1463
|
+
enumerable: true,
|
|
1464
|
+
get: () => rawOptions.state
|
|
1465
|
+
});
|
|
1466
|
+
Object.defineProperty(definedOptions, "rowCount", {
|
|
1467
|
+
configurable: true,
|
|
1468
|
+
enumerable: true,
|
|
1469
|
+
get: () => rawOptions.rowCount
|
|
1470
|
+
});
|
|
1461
1471
|
return definedOptions;
|
|
1462
1472
|
};
|
|
1463
1473
|
//#endregion
|
|
@@ -1593,10 +1603,20 @@ var useMVT_TableInstance = (definedTableOptions) => {
|
|
|
1593
1603
|
const showColumnFilters = ref(initialState?.showColumnFilters ?? false);
|
|
1594
1604
|
const showGlobalFilter = ref(initialState?.showGlobalFilter ?? false);
|
|
1595
1605
|
const showToolbarDropZone = ref(initialState?.showToolbarDropZone ?? false);
|
|
1596
|
-
const
|
|
1597
|
-
const
|
|
1606
|
+
const stateDescriptor = Object.getOwnPropertyDescriptor(definedTableOptions, "state");
|
|
1607
|
+
const readUserState = () => (stateDescriptor?.get ? stateDescriptor.get.call(definedTableOptions) : stateDescriptor?.value) ?? {};
|
|
1608
|
+
const userStateKeys = new Set(Object.keys(readUserState()));
|
|
1609
|
+
const state = {};
|
|
1610
|
+
userStateKeys.forEach((key) => {
|
|
1611
|
+
Object.defineProperty(state, key, {
|
|
1612
|
+
configurable: true,
|
|
1613
|
+
enumerable: true,
|
|
1614
|
+
get: () => readUserState()[key]
|
|
1615
|
+
});
|
|
1616
|
+
});
|
|
1598
1617
|
const defineState = (key, getter) => {
|
|
1599
|
-
if (!(key
|
|
1618
|
+
if (!userStateKeys.has(key)) Object.defineProperty(state, key, {
|
|
1619
|
+
configurable: true,
|
|
1600
1620
|
enumerable: true,
|
|
1601
1621
|
get: getter
|
|
1602
1622
|
});
|
|
@@ -1620,7 +1640,12 @@ var useMVT_TableInstance = (definedTableOptions) => {
|
|
|
1620
1640
|
defineState("showColumnFilters", () => showColumnFilters.value);
|
|
1621
1641
|
defineState("showGlobalFilter", () => showGlobalFilter.value);
|
|
1622
1642
|
defineState("showToolbarDropZone", () => showToolbarDropZone.value);
|
|
1623
|
-
definedTableOptions
|
|
1643
|
+
Object.defineProperty(definedTableOptions, "state", {
|
|
1644
|
+
configurable: true,
|
|
1645
|
+
enumerable: true,
|
|
1646
|
+
writable: true,
|
|
1647
|
+
value: state
|
|
1648
|
+
});
|
|
1624
1649
|
const statefulTableOptions = definedTableOptions;
|
|
1625
1650
|
let columnDefsCache = [];
|
|
1626
1651
|
const columns = computed(() => {
|
|
@@ -1647,7 +1672,7 @@ var useMVT_TableInstance = (definedTableOptions) => {
|
|
|
1647
1672
|
const s = statefulTableOptions.state;
|
|
1648
1673
|
return (s.isLoading || s.showSkeletons) && !definedTableOptions.data.length ? [...Array(Math.min(s.pagination.pageSize, 20)).fill(null)].map(() => Object.assign({}, ...getAllLeafColumnDefs(columns.value).map((col) => ({ [getColumnId(col)]: null })))) : definedTableOptions.data;
|
|
1649
1674
|
});
|
|
1650
|
-
const { columns: _columns, data: _data, ...restOptions } = statefulTableOptions;
|
|
1675
|
+
const { columns: _columns, data: _data, rowCount: _rowCount, ...restOptions } = statefulTableOptions;
|
|
1651
1676
|
const table = useVueTable({
|
|
1652
1677
|
onColumnOrderChange: (updater) => applyUpdater(columnOrder, updater),
|
|
1653
1678
|
onColumnSizingInfoChange: (updater) => applyUpdater(columnSizingInfo, updater),
|
|
@@ -1660,6 +1685,9 @@ var useMVT_TableInstance = (definedTableOptions) => {
|
|
|
1660
1685
|
get data() {
|
|
1661
1686
|
return data.value;
|
|
1662
1687
|
},
|
|
1688
|
+
get rowCount() {
|
|
1689
|
+
return definedTableOptions.rowCount;
|
|
1690
|
+
},
|
|
1663
1691
|
globalFilterFn: statefulTableOptions.filterFns?.[globalFilterFn.value ?? "fuzzy"]
|
|
1664
1692
|
});
|
|
1665
1693
|
table.refs = {
|
|
@@ -1980,13 +2008,7 @@ var MVT_BottomToolbar = defineComponent({
|
|
|
1980
2008
|
required: true
|
|
1981
2009
|
} },
|
|
1982
2010
|
setup(props, { attrs }) {
|
|
1983
|
-
const isMobile =
|
|
1984
|
-
onMounted(() => {
|
|
1985
|
-
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
1986
|
-
const mql = window.matchMedia("(max-width: 720px)");
|
|
1987
|
-
isMobile.value = mql.matches;
|
|
1988
|
-
mql.addEventListener("change", (e) => isMobile.value = e.matches);
|
|
1989
|
-
});
|
|
2011
|
+
const isMobile = useMediaQuery("(max-width: 720px)");
|
|
1990
2012
|
return () => {
|
|
1991
2013
|
const { table } = props;
|
|
1992
2014
|
const { getState, options: { enablePagination, mantineBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions }, refs: { bottomToolbarRef } } = table;
|
|
@@ -2690,16 +2712,6 @@ var MVT_TopToolbar_module_default = {
|
|
|
2690
2712
|
};
|
|
2691
2713
|
//#endregion
|
|
2692
2714
|
//#region src/components/toolbar/MVT_TopToolbar.ts
|
|
2693
|
-
var useMedia = (query) => {
|
|
2694
|
-
const matches = ref(false);
|
|
2695
|
-
onMounted(() => {
|
|
2696
|
-
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
2697
|
-
const mql = window.matchMedia(query);
|
|
2698
|
-
matches.value = mql.matches;
|
|
2699
|
-
mql.addEventListener("change", (e) => matches.value = e.matches);
|
|
2700
|
-
});
|
|
2701
|
-
return matches;
|
|
2702
|
-
};
|
|
2703
2715
|
var MVT_TopToolbar = defineComponent({
|
|
2704
2716
|
name: "MVTTopToolbar",
|
|
2705
2717
|
inheritAttrs: false,
|
|
@@ -2708,8 +2720,8 @@ var MVT_TopToolbar = defineComponent({
|
|
|
2708
2720
|
required: true
|
|
2709
2721
|
} },
|
|
2710
2722
|
setup(props, { attrs }) {
|
|
2711
|
-
const isMobile =
|
|
2712
|
-
const isTablet =
|
|
2723
|
+
const isMobile = useMediaQuery("(max-width: 720px)");
|
|
2724
|
+
const isTablet = useMediaQuery("(max-width: 1024px)");
|
|
2713
2725
|
return () => {
|
|
2714
2726
|
const { table } = props;
|
|
2715
2727
|
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, mantineTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions }, refs: { topToolbarRef } } = table;
|
|
@@ -2719,7 +2731,10 @@ var MVT_TopToolbar = defineComponent({
|
|
|
2719
2731
|
...attrs
|
|
2720
2732
|
};
|
|
2721
2733
|
const stackAlertBanner = isMobile.value || !!renderTopToolbarCustomActions || showGlobalFilter && isTablet.value;
|
|
2722
|
-
const globalFilterProps = {
|
|
2734
|
+
const globalFilterProps = {
|
|
2735
|
+
style: !isTablet.value ? { zIndex: 3 } : void 0,
|
|
2736
|
+
table
|
|
2737
|
+
};
|
|
2723
2738
|
return h(Box, {
|
|
2724
2739
|
...toolbarProps,
|
|
2725
2740
|
class: clsx(common_styles_module_default["common-toolbar-styles"], MVT_TopToolbar_module_default["root"], isFullScreen && MVT_TopToolbar_module_default["root-fullscreen"], toolbarProps?.class),
|
|
@@ -2736,7 +2751,7 @@ var MVT_TopToolbar = defineComponent({
|
|
|
2736
2751
|
table
|
|
2737
2752
|
}),
|
|
2738
2753
|
["both", "top"].includes(positionToolbarDropZone ?? "") && h(MVT_ToolbarDropZone, { table }),
|
|
2739
|
-
h(Flex, { class:
|
|
2754
|
+
h(Flex, { class: [MVT_TopToolbar_module_default["actions-container"], stackAlertBanner ? MVT_TopToolbar_module_default["actions-container-stack-alert"] : void 0] }, () => [
|
|
2740
2755
|
enableGlobalFilter && positionGlobalFilter === "left" && h(MVT_GlobalFilterTextInput, globalFilterProps),
|
|
2741
2756
|
parseFromValuesOrFunc(renderTopToolbarCustomActions, { table }) ?? h("span"),
|
|
2742
2757
|
enableToolbarInternalActions ? h(Flex, {
|
|
@@ -2773,6 +2788,7 @@ var MVT_EditRowModal = defineComponent({
|
|
|
2773
2788
|
},
|
|
2774
2789
|
emits: { close: () => true },
|
|
2775
2790
|
setup(props, { attrs, emit, slots }) {
|
|
2791
|
+
const mvtSlots = useMVT_Slots();
|
|
2776
2792
|
return () => {
|
|
2777
2793
|
const { table } = props;
|
|
2778
2794
|
const state = table.getState();
|
|
@@ -2810,7 +2826,7 @@ var MVT_EditRowModal = defineComponent({
|
|
|
2810
2826
|
modalProps.onClose?.();
|
|
2811
2827
|
emit("close");
|
|
2812
2828
|
};
|
|
2813
|
-
const custom = (state.creatingRow ? slots.create ?? slots.default : slots.edit ?? slots.default)?.({
|
|
2829
|
+
const custom = (state.creatingRow ? slots.create ?? mvtSlots.createRowModalContent ?? slots.default : slots.edit ?? mvtSlots.editRowModalContent ?? slots.default)?.({
|
|
2814
2830
|
internalEditComponents,
|
|
2815
2831
|
row,
|
|
2816
2832
|
table
|