@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 CHANGED
@@ -1482,6 +1482,16 @@ var useMVT_TableOptions = (rawOptions) => {
1482
1482
  enumerable: true,
1483
1483
  get: () => rawOptions.columns
1484
1484
  });
1485
+ Object.defineProperty(definedOptions, "state", {
1486
+ configurable: true,
1487
+ enumerable: true,
1488
+ get: () => rawOptions.state
1489
+ });
1490
+ Object.defineProperty(definedOptions, "rowCount", {
1491
+ configurable: true,
1492
+ enumerable: true,
1493
+ get: () => rawOptions.rowCount
1494
+ });
1485
1495
  return definedOptions;
1486
1496
  };
1487
1497
  //#endregion
@@ -1617,10 +1627,20 @@ var useMVT_TableInstance = (definedTableOptions) => {
1617
1627
  const showColumnFilters = (0, vue.ref)(initialState?.showColumnFilters ?? false);
1618
1628
  const showGlobalFilter = (0, vue.ref)(initialState?.showGlobalFilter ?? false);
1619
1629
  const showToolbarDropZone = (0, vue.ref)(initialState?.showToolbarDropZone ?? false);
1620
- const userState = definedTableOptions.state ?? {};
1621
- const state = { ...userState };
1630
+ const stateDescriptor = Object.getOwnPropertyDescriptor(definedTableOptions, "state");
1631
+ const readUserState = () => (stateDescriptor?.get ? stateDescriptor.get.call(definedTableOptions) : stateDescriptor?.value) ?? {};
1632
+ const userStateKeys = new Set(Object.keys(readUserState()));
1633
+ const state = {};
1634
+ userStateKeys.forEach((key) => {
1635
+ Object.defineProperty(state, key, {
1636
+ configurable: true,
1637
+ enumerable: true,
1638
+ get: () => readUserState()[key]
1639
+ });
1640
+ });
1622
1641
  const defineState = (key, getter) => {
1623
- if (!(key in userState)) Object.defineProperty(state, key, {
1642
+ if (!userStateKeys.has(key)) Object.defineProperty(state, key, {
1643
+ configurable: true,
1624
1644
  enumerable: true,
1625
1645
  get: getter
1626
1646
  });
@@ -1644,7 +1664,12 @@ var useMVT_TableInstance = (definedTableOptions) => {
1644
1664
  defineState("showColumnFilters", () => showColumnFilters.value);
1645
1665
  defineState("showGlobalFilter", () => showGlobalFilter.value);
1646
1666
  defineState("showToolbarDropZone", () => showToolbarDropZone.value);
1647
- definedTableOptions.state = state;
1667
+ Object.defineProperty(definedTableOptions, "state", {
1668
+ configurable: true,
1669
+ enumerable: true,
1670
+ writable: true,
1671
+ value: state
1672
+ });
1648
1673
  const statefulTableOptions = definedTableOptions;
1649
1674
  let columnDefsCache = [];
1650
1675
  const columns = (0, vue.computed)(() => {
@@ -1671,7 +1696,7 @@ var useMVT_TableInstance = (definedTableOptions) => {
1671
1696
  const s = statefulTableOptions.state;
1672
1697
  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;
1673
1698
  });
1674
- const { columns: _columns, data: _data, ...restOptions } = statefulTableOptions;
1699
+ const { columns: _columns, data: _data, rowCount: _rowCount, ...restOptions } = statefulTableOptions;
1675
1700
  const table = (0, _tanstack_vue_table.useVueTable)({
1676
1701
  onColumnOrderChange: (updater) => applyUpdater(columnOrder, updater),
1677
1702
  onColumnSizingInfoChange: (updater) => applyUpdater(columnSizingInfo, updater),
@@ -1684,6 +1709,9 @@ var useMVT_TableInstance = (definedTableOptions) => {
1684
1709
  get data() {
1685
1710
  return data.value;
1686
1711
  },
1712
+ get rowCount() {
1713
+ return definedTableOptions.rowCount;
1714
+ },
1687
1715
  globalFilterFn: statefulTableOptions.filterFns?.[globalFilterFn.value ?? "fuzzy"]
1688
1716
  });
1689
1717
  table.refs = {
@@ -2004,13 +2032,7 @@ var MVT_BottomToolbar = (0, vue.defineComponent)({
2004
2032
  required: true
2005
2033
  } },
2006
2034
  setup(props, { attrs }) {
2007
- const isMobile = (0, vue.ref)(false);
2008
- (0, vue.onMounted)(() => {
2009
- if (typeof window === "undefined" || !window.matchMedia) return;
2010
- const mql = window.matchMedia("(max-width: 720px)");
2011
- isMobile.value = mql.matches;
2012
- mql.addEventListener("change", (e) => isMobile.value = e.matches);
2013
- });
2035
+ const isMobile = (0, _mantine_vue_hooks.useMediaQuery)("(max-width: 720px)");
2014
2036
  return () => {
2015
2037
  const { table } = props;
2016
2038
  const { getState, options: { enablePagination, mantineBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions }, refs: { bottomToolbarRef } } = table;
@@ -2714,16 +2736,6 @@ var MVT_TopToolbar_module_default = {
2714
2736
  };
2715
2737
  //#endregion
2716
2738
  //#region src/components/toolbar/MVT_TopToolbar.ts
2717
- var useMedia = (query) => {
2718
- const matches = (0, vue.ref)(false);
2719
- (0, vue.onMounted)(() => {
2720
- if (typeof window === "undefined" || !window.matchMedia) return;
2721
- const mql = window.matchMedia(query);
2722
- matches.value = mql.matches;
2723
- mql.addEventListener("change", (e) => matches.value = e.matches);
2724
- });
2725
- return matches;
2726
- };
2727
2739
  var MVT_TopToolbar = (0, vue.defineComponent)({
2728
2740
  name: "MVTTopToolbar",
2729
2741
  inheritAttrs: false,
@@ -2732,8 +2744,8 @@ var MVT_TopToolbar = (0, vue.defineComponent)({
2732
2744
  required: true
2733
2745
  } },
2734
2746
  setup(props, { attrs }) {
2735
- const isMobile = useMedia("(max-width: 720px)");
2736
- const isTablet = useMedia("(max-width: 1024px)");
2747
+ const isMobile = (0, _mantine_vue_hooks.useMediaQuery)("(max-width: 720px)");
2748
+ const isTablet = (0, _mantine_vue_hooks.useMediaQuery)("(max-width: 1024px)");
2737
2749
  return () => {
2738
2750
  const { table } = props;
2739
2751
  const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, mantineTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions }, refs: { topToolbarRef } } = table;
@@ -2743,7 +2755,10 @@ var MVT_TopToolbar = (0, vue.defineComponent)({
2743
2755
  ...attrs
2744
2756
  };
2745
2757
  const stackAlertBanner = isMobile.value || !!renderTopToolbarCustomActions || showGlobalFilter && isTablet.value;
2746
- const globalFilterProps = { table };
2758
+ const globalFilterProps = {
2759
+ style: !isTablet.value ? { zIndex: 3 } : void 0,
2760
+ table
2761
+ };
2747
2762
  return (0, vue.h)(_mantine_vue_core.Box, {
2748
2763
  ...toolbarProps,
2749
2764
  class: (0, clsx.default)(common_styles_module_default["common-toolbar-styles"], MVT_TopToolbar_module_default["root"], isFullScreen && MVT_TopToolbar_module_default["root-fullscreen"], toolbarProps?.class),
@@ -2760,7 +2775,7 @@ var MVT_TopToolbar = (0, vue.defineComponent)({
2760
2775
  table
2761
2776
  }),
2762
2777
  ["both", "top"].includes(positionToolbarDropZone ?? "") && (0, vue.h)(MVT_ToolbarDropZone, { table }),
2763
- (0, vue.h)(_mantine_vue_core.Flex, { class: (0, clsx.default)(MVT_TopToolbar_module_default["actions-container"], stackAlertBanner && MVT_TopToolbar_module_default["actions-container-stack-alert"]) }, () => [
2778
+ (0, vue.h)(_mantine_vue_core.Flex, { class: [MVT_TopToolbar_module_default["actions-container"], stackAlertBanner ? MVT_TopToolbar_module_default["actions-container-stack-alert"] : void 0] }, () => [
2764
2779
  enableGlobalFilter && positionGlobalFilter === "left" && (0, vue.h)(MVT_GlobalFilterTextInput, globalFilterProps),
2765
2780
  parseFromValuesOrFunc(renderTopToolbarCustomActions, { table }) ?? (0, vue.h)("span"),
2766
2781
  enableToolbarInternalActions ? (0, vue.h)(_mantine_vue_core.Flex, {
@@ -2797,6 +2812,7 @@ var MVT_EditRowModal = (0, vue.defineComponent)({
2797
2812
  },
2798
2813
  emits: { close: () => true },
2799
2814
  setup(props, { attrs, emit, slots }) {
2815
+ const mvtSlots = useMVT_Slots();
2800
2816
  return () => {
2801
2817
  const { table } = props;
2802
2818
  const state = table.getState();
@@ -2834,7 +2850,7 @@ var MVT_EditRowModal = (0, vue.defineComponent)({
2834
2850
  modalProps.onClose?.();
2835
2851
  emit("close");
2836
2852
  };
2837
- const custom = (state.creatingRow ? slots.create ?? slots.default : slots.edit ?? slots.default)?.({
2853
+ const custom = (state.creatingRow ? slots.create ?? mvtSlots.createRowModalContent ?? slots.default : slots.edit ?? mvtSlots.editRowModalContent ?? slots.default)?.({
2838
2854
  internalEditComponents,
2839
2855
  row,
2840
2856
  table