Skip to content

Commit

Permalink
Merge pull request #236 from icflorescu/next
Browse files Browse the repository at this point in the history
Export utility functions & bump package version
  • Loading branch information
icflorescu committed Apr 1, 2023
2 parents 8c21dd3 + 923ab88 commit 06235b6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.3.0 (2023-04-01)

- Export utility functions: `differenceBy`, `getValueAtPath`, `humanize`, `uniqBy`

## 2.2.6 (2023-03-25)

- Add Jest tests (thanks to @AlexcastroDev)
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable-docs",
"version": "2.2.10",
"version": "2.3.0",
"description": "Docs website for mantine-datatable; see ../package/package.json for more info",
"private": true,
"scripts": {
Expand All @@ -19,7 +19,7 @@
"@mantine/next": "^6.0.5",
"@mantine/notifications": "^6.0.5",
"@mantine/prism": "^6.0.5",
"@tabler/icons-react": "^2.12.0",
"@tabler/icons-react": "^2.13.0",
"@tanstack/react-query": "^4.28.0",
"dayjs": "^1.11.7",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable-turborepo",
"version": "2.2.10",
"version": "2.3.0",
"description": "This is a monorepo; see package/package.json for more info",
"private": true,
"workspaces": [
Expand Down
1 change: 1 addition & 0 deletions package/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as DataTable } from './DataTable';
export * from './types';
export { differenceBy, getValueAtPath, humanize, uniqBy } from './utils';
4 changes: 2 additions & 2 deletions package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-datatable",
"version": "2.2.10",
"version": "2.3.0",
"description": "Datatable component for Mantine UI, featuring asynchronous data loading support, pagination, multple rows selection, column sorting, custom cell data rendering, row context menu, row expansion and more",
"keywords": [
"ui",
Expand Down Expand Up @@ -44,7 +44,7 @@
"devDependencies": {
"@mantine/core": "^6.0.5",
"@mantine/hooks": "^6.0.5",
"@tabler/icons-react": "^2.12.0",
"@tabler/icons-react": "^2.13.0",
"@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
"esbuild": "^0.17.14",
Expand Down
12 changes: 12 additions & 0 deletions package/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export function useMediaQueryStringOrFunction(mediaQuery: string | ((theme: Mant
return useMediaQuery(mediaQueryValue || '', true);
}

/**
* Utility function that returns a humanized version of a string, e.g. "camelCase" -> "Camel Case"
*/
export function humanize(value: string) {
const str = value
.replace(/([a-z\d])([A-Z]+)/g, '$1 $2')
Expand All @@ -19,14 +22,23 @@ export function humanize(value: string) {
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
}

/**
* Utility function that returns an array of values that are present in the first array but not in the second
*/
export function differenceBy<T>(arr1: T[], arr2: T[], iteratee: (value: T) => unknown) {
return arr1.filter((c) => !arr2.map(iteratee).includes(iteratee(c)));
}

/**
* Utility function that returns an array of unique values from a given array
*/
export function uniqBy<T>(arr: T[], iteratee: (value: T) => unknown) {
return arr.filter((x, i, self) => i === self.findIndex((y) => iteratee(x) === iteratee(y)));
}

/**
* Utility function that returns the value at a given path in an object
*/
export function getValueAtPath(obj: unknown, path: string) {
if (!path) return undefined;
const pathArray = path.match(/([^[.\]])+/g) as string[];
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2068,18 +2068,18 @@
dependencies:
tslib "^2.4.0"

"@tabler/icons-react@^2.12.0":
version "2.12.0"
resolved "https://registry.yarnpkg.com/@tabler/icons-react/-/icons-react-2.12.0.tgz#a1f317de5b4e4c50fde31ddd09a42f40d7a48a0c"
integrity sha512-5O26fB0sigZ9UaDnMTPsht8clU6KYyClvTwhLPud0ZjeTnOMzGhe2Yx5qvfhDkCBNQqz+hIV8kBUe7fvNGv1Ng==
"@tabler/icons-react@^2.13.0":
version "2.13.0"
resolved "https://registry.yarnpkg.com/@tabler/icons-react/-/icons-react-2.13.0.tgz#2396687e9f5a20912c465f39bb291e1bc719365d"
integrity sha512-d1eAnD4+JhFxLnRFwE1h0ukt7el0/KnbqTZ4acSvtZ8yuHuqff266yZU587aCU3ovaX/6zxkgaxJsDnBXiLTEw==
dependencies:
"@tabler/icons" "2.12.0"
"@tabler/icons" "2.13.0"
prop-types "^15.7.2"

"@tabler/icons@2.12.0":
version "2.12.0"
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-2.12.0.tgz#cb4300ec52677b30f9f36c351dcb54cb4fc2ee63"
integrity sha512-PiYD2zUOewNAtfJKU9tBZfyv3NeFlTlUe5LSGTTplvBcM0iuHrNVnd30+HIcUGJQhi3Uf0Ng9FRi/kPqm/q6ZA==
"@tabler/icons@2.13.0":
version "2.13.0"
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-2.13.0.tgz#46d1f3b0ab50c01928204302ce0a2f3e2d70b1d4"
integrity sha512-YF1cl17cdhaAHQayv3zDRzYLT6AX49gm6RGTNkIfFiEcefMsJtyCt1qXbI/mxzFCugrb3LdlPmZPLceYl9kn8A==

"@tanstack/query-core@4.27.0":
version "4.27.0"
Expand Down

0 comments on commit 06235b6

Please sign in to comment.