Skip to content

Commit

Permalink
Merge pull request #458 from icflorescu/next
Browse files Browse the repository at this point in the history
Switch to tsup bundling, etc.
  • Loading branch information
icflorescu authored Nov 6, 2023
2 parents 5471327 + 72e2940 commit c60dde9
Show file tree
Hide file tree
Showing 36 changed files with 870 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
cache: yarn
- name: Restore cache
uses: actions/cache@v3
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
The following is a list of notable changes to the Mantine DataTable component.
Minor versions that are not listed in the changelog are bug fixes and small improvements.

## 7.1.2 (2023-11-06)

- Switch to `tsup` building, to fix usage issues with Remix & Next.js

## 7.1.1 (2023-11-03)

- Switch to `esm` export only, to fix this issue: https://github.com/icflorescu/mantine-datatable/issues/451
Expand Down
2 changes: 1 addition & 1 deletion app/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import '@mantine/dates/esm/index.css' layer(mantine-dates);
@import '@mantine/notifications/esm/index.css' layer(mantine-notifications);
@import '@mantine/code-highlight/esm/index.css' layer(mantine-code-highlight);
@import 'mantine-contextmenu/dist/css/styles.css' layer(mantine-contextmenu);
@import 'mantine-contextmenu/dist/styles.css' layer(mantine-contextmenu);
@import '../package/styles.css' layer(mantine-datatable);
@import '@docsearch/css';
@import './docsearch-overrides.css';
Expand Down
2 changes: 1 addition & 1 deletion app/styling/examples/fine-grained/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import '@mantine/core/esm/index.css' layer(mantine-core);

/* 👇 Expressly import the mantine-datatable styles into mantine-datatable layer */
@import '__PACKAGE__/dist/css/styles.css' layer(mantine-datatable);
@import '__PACKAGE__/dist/styles.css' layer(mantine-datatable);

/* 👇 Make sure the styles are applied in the correct order */
@layer mantine-core, mantine-datatable;
2 changes: 1 addition & 1 deletion data/async.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DataTableSortStatus } from '__PACKAGE__';
import dayjs, { type Dayjs } from 'dayjs';
import { get, sortBy } from 'lodash';
import type { DataTableSortStatus } from '~/dist/types';
import { delay, type DelayOptions } from '~/lib/examples';
import { companies, departments, employees, type Employee } from '.';

Expand Down
33 changes: 20 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable",
"version": "7.1.1",
"version": "7.1.2",
"description": "The lightweight, dependency-free, dark-theme aware table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagination, intuitive Gmail-style additive batch rows selection, column sorting, custom cell data rendering, row expansion, nesting, context menus, and much more",
"keywords": [
"mantine",
Expand Down Expand Up @@ -40,16 +40,20 @@
"type": "github",
"url": "https://github.com/sponsors/icflorescu"
},
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/types/index.d.ts",
"default": "./dist/esm/index.js"
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./styles.css": "./dist/css/styles.css",
"./styles.layer.css": "./dist/css/styles.layer.css"
"./styles.css": "./dist/styles.css",
"./styles.layer.css": "./dist/styles.layer.css"
},
"files": [
"./dist",
Expand All @@ -58,7 +62,7 @@
],
"scripts": {
"dev": "next dev",
"build:package": "rm -rf dist; tsc -p package/tsconfig.build.json; postcss package/styles*.css --dir dist/css",
"build:package": "rm -rf dist; tsup --config scripts/tsup.esm.ts; tsup --config scripts/tsup.cjs.ts; tsup --config scripts/tsup.dts.ts; postcss package/styles*.css --dir dist",
"build:docs": "next build",
"build": "yarn build:package && yarn build:docs",
"lint": "eslint . && tsc --noEmit --pretty",
Expand All @@ -76,37 +80,40 @@
"@mantine/modals": "^7.1.7",
"@mantine/notifications": "^7.1.7",
"@tabler/icons-react": "^2.40.0",
"@tanstack/react-query": "^5.4.3",
"@tanstack/react-query": "^5.7.2",
"@types/lodash": "^4.14.200",
"@types/node": "^20.8.10",
"@types/react": "^18.2.34",
"@types/react": "^18.2.36",
"@types/react-dom": "^18.2.14",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"clsx": "^2.0.0",
"cssnano": "^6.0.1",
"dayjs": "^1.11.10",
"eslint": "^8.52.0",
"eslint": "^8.53.0",
"eslint-config-next": "^14.0.1",
"eslint-config-prettier": "^9.0.0",
"lodash": "^4.17.21",
"mantine-contextmenu": "^7.1.8",
"mantine-contextmenu": "^7.1.9",
"next": "14.0.1",
"postcss": "^8.4.31",
"postcss-cli": "^10.1.0",
"postcss-import": "^15.1.0",
"postcss-preset-mantine": "^1.9.0",
"postcss-preset-mantine": "^1.9.1",
"postcss-simple-vars": "^7.0.1",
"prettier": "^3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "^0.32.6",
"swr": "^2.2.4",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"webpack": "^5.89.0"
},
"peerDependencies": {
"@mantine/core": ">=7",
"@mantine/hooks": ">=7",
"clsx": ">=2"
"clsx": ">=2",
"react": ">=18"
}
}
2 changes: 0 additions & 2 deletions package/DataTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Box, Table, type MantineSize } from '@mantine/core';
import { useMergedRef } from '@mantine/hooks';
import clsx from 'clsx';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableColumnGroupHeaderCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { TableTh } from '@mantine/core';
import clsx from 'clsx';
import { useMemo } from 'react';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { TableThead, TableTr, type CheckboxProps, type MantineStyleProp } from '@mantine/core';
import clsx from 'clsx';
import { forwardRef } from 'react';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableHeaderCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Box, Center, Group, MantineStyleProp, TableTh, type MantineTheme } from '@mantine/core';
import clsx from 'clsx';
import { DataTableHeaderCellFilter } from './DataTableHeaderCellFilter';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableHeaderCellFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { ActionIcon, Popover, PopoverTarget } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { IconFilter } from './icons/IconFilter';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableHeaderSelectorCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Checkbox, TableTh, type CheckboxProps } from '@mantine/core';
import { POINTER_CURSOR } from './utilityClasses';

Expand Down
2 changes: 0 additions & 2 deletions package/DataTablePageSizeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import {
Button,
Group,
Expand Down
2 changes: 0 additions & 2 deletions package/DataTablePagination.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Box, Pagination, Text, rem, type MantineSpacing, type MantineStyleProp } from '@mantine/core';
import clsx from 'clsx';
import { forwardRef, type ForwardedRef } from 'react';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { TableTr, type CheckboxProps, type MantineColor, type MantineStyleProp } from '@mantine/core';
import clsx from 'clsx';
import { DataTableRowCell } from './DataTableRowCell';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableRowCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { TableTd, type MantineStyleProp } from '@mantine/core';
import clsx from 'clsx';
import { useMediaQueryStringOrFunction } from './hooks';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableRowExpansion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Collapse, TableTd, TableTr } from '@mantine/core';
import { useRowExpansionStatus } from './hooks';
import type { DataTableRowExpansionCollapseProps } from './types';
Expand Down
2 changes: 0 additions & 2 deletions package/DataTableRowSelectorCell.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Checkbox, TableTd, type CheckboxProps } from '@mantine/core';
import { POINTER_CURSOR } from './utilityClasses';

Expand Down
2 changes: 0 additions & 2 deletions package/DataTableScrollArea.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Box, ScrollArea, rem, type ScrollAreaProps } from '@mantine/core';
import clsx from 'clsx';

Expand Down
2 changes: 0 additions & 2 deletions package/cssVariables.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { parseThemeColor, type MantineColor, type MantineTheme } from '@mantine/core';
import type { DataTableProps } from './types';

Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useElementOuterSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useResizeObserver } from '@mantine/hooks';

export function useElementOuterSize<T extends HTMLElement>() {
Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useIsomorphicLayoutEffect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useEffect, useLayoutEffect } from 'react';

export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
2 changes: 0 additions & 2 deletions package/hooks/useLastSelectionChangeIndex.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useEffect, useState } from 'react';

export function useLastSelectionChangeIndex(recordIds: unknown[] | undefined) {
Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useMediaQueries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

// Modified from https://github.com/mantinedev/mantine/blob/8c12a76c56da51af34213f18dd67c8b72a0ddb44/src/mantine-hooks/src/use-media-query/use-media-query.ts

import { useEffect, useRef, useState } from 'react';
Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useMediaQueriesStringOrFunction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useMantineTheme, type MantineTheme } from '@mantine/core';
import { useMemo } from 'react';
import { useMediaQueries } from './useMediaQueries';
Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useMediaQueryStringOrFunction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useMantineTheme, type MantineTheme } from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';

Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useRowExpansion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useState } from 'react';
import { DataTableRowExpansionProps } from '../types/DataTableRowExpansionProps';
import { getRecordId } from '../utils';
Expand Down
2 changes: 0 additions & 2 deletions package/hooks/useRowExpansionStatus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { useTimeout } from '@mantine/hooks';
import { useEffect, useState } from 'react';

Expand Down
2 changes: 2 additions & 0 deletions package/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

export { DataTable } from './DataTable';
export * from './types';
export * from './utils';
16 changes: 0 additions & 16 deletions package/tsconfig.build.json

This file was deleted.

2 changes: 2 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
map: { inline: false },
plugins: {
'postcss-import': {},
'postcss-preset-mantine': {},
Expand All @@ -12,4 +13,5 @@ module.exports = {
},
},
},
cssnano: { preset: 'default' },
};
6 changes: 6 additions & 0 deletions scripts/tsconfig.tsup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"jsx": "react-jsx"
}
}
11 changes: 11 additions & 0 deletions scripts/tsup.cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['package/index.ts'],
format: 'cjs',
tsconfig: 'scripts/tsconfig.tsup.json',
target: 'esnext',
minify: true,
sourcemap: true,
clean: false,
});
7 changes: 7 additions & 0 deletions scripts/tsup.dts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['package/index.ts'],
dts: { only: true, compilerOptions: { incremental: false } },
clean: false,
});
11 changes: 11 additions & 0 deletions scripts/tsup.esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['package/index.ts'],
format: 'esm',
tsconfig: 'scripts/tsconfig.tsup.json',
target: 'esnext',
minify: true,
sourcemap: true,
clean: false,
});
Loading

0 comments on commit c60dde9

Please sign in to comment.