Skip to content

Commit

Permalink
Merge branch 'master' into Refactor-MTableGroupRow-class-to-functiona…
Browse files Browse the repository at this point in the history
…l-component
  • Loading branch information
matthewoestreich authored Jan 13, 2021
2 parents 4662d5f + a536f91 commit 1502e3f
Show file tree
Hide file tree
Showing 54 changed files with 8,986 additions and 4,154 deletions.
3 changes: 2 additions & 1 deletion configs/.eslintignore → .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
types
.github
demo
dist
dist
__tests__
3 changes: 2 additions & 1 deletion configs/.eslintrc → .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"one-var": "off",
"semi": ["error", "always", {
"omitLastInOneLineBlock": true
}]
}],
"space-before-function-paren": "off"
},
"parser": "babel-eslint",
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build --if-present
- run: npm run build
28 changes: 22 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
#
# Will publish a new version to npm if the version has been changed and
# the commit pattern matches "^Release (\\S+)"
#

name: Publish

#
#
# ~ IMPORTANT ~
# If your commit message starts with `Release`
# If your commit summary starts with `Release`
# - We will attempt to automatically publish your commit (although, your commit will not be automatically approved)
# - *NOTE*
# - We **DO NOT** increase the package.json version please do this yourself!!
# - We will attempt to create a new release using the commit description as release notes
#
#

Expand All @@ -37,3 +33,23 @@ jobs:
npm config set @material-table:registry https://registry.npmjs.org/
npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_AUTH_TOKEN }}
npm publish --ignore-scripts
create-release:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get Tag
# GH Actions passes the tag as `/refs/foo/bar`, this allows us to just grab `bar`
run: echo "FULL_RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ $FULL_RELEASE_VERSION }}
release_name: ${{ $FULL_RELEASE_VERSION }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ node_modules
yarn.lock
.idea
.DS_Store
*.iml
*.iml
cypress/videos
__tests__/coverage
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
}
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
>
</a>
<!-- publish status -->
<!--
<a href="https://github.com/material-table-core/core/actions?query=workflow%3APublish">
<img
title="Publish"
src="https://github.com/material-table-core/core/workflows/Publish/badge.svg"
>
</a>
-->
<!-- npm package -->
<a href="https://www.npmjs.com/package/@material-table/core">
<img
Expand All @@ -43,20 +45,20 @@
</a>
</section>
<section>
<!-- gitter -->
<a href="https://gitter.im/MaterialTableCore/community">
<!-- discord -->
<a href="https://discord.com/channels/796859493412765697/">
<img
title="chat_on_gitter"
src="https://img.shields.io/gitter/room/material-table-core/core"
>
alt="Discord"
src="https://img.shields.io/discord/796859493412765697?label=discord"
>
</a>
</section>
</p>
<!-- ^^^ end badges ^^^ -->

</div>

💾 [Installation](#installation)
💾 [Installation](https://material-table-core.com/docs/#install)

🎉 [Usage](#usage)

Expand All @@ -79,22 +81,13 @@
- **We are not attempting to hijack what [`mbrn`](https://github.com/mbrn/material-table) has created**
- **We will always remain a true fork of `mbrn/material-table`**
- We plan on pushing all changes upstream
- **We will always remain 100% compatible with `mbrn/material-table`**
- **We will ~~always~~ attempt to remain 100% compatible with `mbrn/material-table`**
- Ok so the "always" part was a stretch. [See here](https://material-table-core.com/docs/getting-started/breakingchanges) for more.
- We are here to resolve issues, not hijack a repo
- Life happens, and `mbrn` has become rather busy
- Only `mbrn` can update `material-table`
- We have chosen to support `mbrn` and `material-table` with the hopes of keeping the project alive

## Installation

#### yarn

`yarn add @material-table/core`

#### npm

`npm install @material-table/core`

## Usage

#### Updating `material-table`
Expand All @@ -108,7 +101,7 @@ Simply update your imports to receive the latest updates!

#### Compatibility

If you can import it from `material-table` you can import it from `@material-table/core`. This will never change.
If you can import it from `material-table` you can import it from `@material-table/core`. ~~This will never change.~~ Ok, we admit, that was a little bold. [Please see here for more info](https://material-table-core.com/docs/getting-started/breakingchanges).

```javascript
import MaterialTable, { MTableAction /*, etc...*/ } from '@material-table/core';
Expand Down
10 changes: 10 additions & 0 deletions __tests__/MTableActions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import MaterialTable from '../src';
import { configure } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

configure({ adapter: new Adapter() });

test('TODO - MAKE TESTS', () => {
expect(true).toBe(true);
});
56 changes: 56 additions & 0 deletions __tests__/MTableFilterRow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { createRef } from 'react';
import MaterialTable from '../src';
import { TEST_DATA, COLUMNS } from './utils';
import { configure, mount, shallow } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';

configure({ adapter: new Adapter() });

describe('MTableFilterRow Tests', () => {
let TABLE_REF = createRef();
beforeEach(() => {
// Needed to silence react-beautiful-dnd console warnings/errors
global.window['__react-beautiful-dnd-disable-dev-warnings'] = true;
TABLE_REF = createRef();
});

test('MaterialTable mounts successfully', () => {
const wrapper = mount(
<MaterialTable
tableRef={TABLE_REF}
data={TEST_DATA}
columns={COLUMNS}
options={{ filtering: true }}
/>
);
const { filtering } = TABLE_REF.current.props.options;
expect(filtering).toBe(true);
wrapper.unmount();
});

test('Custom Filter Algo', () => {
// Update cols with custom search
const cols = [
{
title: 'Given Name',
field: 'name',
customFilterAndSearch: (term, rowData) => term == rowData.name.length
},
{ title: 'Sirname', field: 'sirname' },
{ title: 'Age', field: 'age' }
];

const wrapper = mount(
<MaterialTable
tableRef={TABLE_REF}
data={TEST_DATA}
columns={cols}
options={{ filtering: true }}
/>
);
const els = Array.from(wrapper.find('#m--table--filter--row')) || [];
const el = els[0];
console.log(el.find('#m--table--filter--row'));
expect(TABLE_REF.current.dataManager.filtered).toBe(true);
});
});
61 changes: 61 additions & 0 deletions __tests__/demo/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import { render } from 'react-dom';
import MaterialTable from '../../src';
import { ExportPdf, ExportCsv } from '../../exporters';

const App = () => {
const ref = React.useRef();
return (
<MaterialTable
tableRef={ref}
data={[
{
name: 'Bar',
sirname: 'Zab',
age: 44,
date: new Date('December 1, 1999')
},
{ name: 'Baz', sirname: 'Oof', age: 34, date: new Date('1/1/1970') },
{ name: 'Foo', sirname: 'Rab', age: 24, date: new Date(Date.now()) }
]}
columns={[
{
title: 'Given Name',
field: 'name',
customFilterAndSearch: (term, rowData) => term == rowData.name.length
},
{ title: 'Sirname', field: 'sirname' },
{ title: 'Age', field: 'age' },
{ title: 'Date', field: 'date', type: 'date' }
]}
options={{
filtering: true,
exportMenu: [
{
label: 'Export PDF',
exportFunc: (cols, datas) => ExportPdf(cols, datas, 'mypdffile')
},
{
label: 'Export CSV',
exportFunc: (cols, datas) => ExportCsv(cols, datas, 'mycsvfile')
}
]
}}
cellEditable={{
onCellEditApproved: (newValue, oldValue, rowData, columnDef) => {
return new Promise((resolve, reject) => {
console.log('newValue: ' + newValue);
setTimeout(resolve, 1000);
});
}
}}
onFilterChange={(appliedFilter) => {
console.log({ appliedFilter, ref });
}}
/>
);
};

module.hot.accept();

render(<App />, document.querySelector('#app'));
Loading

0 comments on commit 1502e3f

Please sign in to comment.