Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade site Next.js version with Babel and TypeScript #848

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion components/table/table-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const defaultProps = {
}

type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props<any>>
export type TableBodyProps<TableDataItem> = Props<TableDataItem> & NativeAttrs
export type TableBodyProps<TableDataItem extends TableDataItemBase> =
Props<TableDataItem> & NativeAttrs

const TableBody = <TableDataItem extends TableDataItemBase>({
data,
Expand Down
2 changes: 1 addition & 1 deletion components/table/table-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TableCell = <TableDataItem extends TableDataItemBase>({

return (
<td
key={`row-td-${index}-${column.prop}`}
key={`row-td-${index}-${String(column.prop)}`}
onClick={() => onCellClick && onCellClick(currentRowValue, rowIndex, index)}
className={column.className}>
<div className="cell">
Expand Down
4 changes: 2 additions & 2 deletions components/table/table-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultProps = {
render: () => {},
}

export type TableColumnProps<TableDataItem> = {
export type TableColumnProps<TableDataItem extends TableDataItemBase> = {
prop: keyof TableDataItem
label?: string
width?: number
Expand All @@ -29,7 +29,7 @@ const TableColumn = <TableDataItem extends TableDataItemBase>(
} = columnProps as React.PropsWithChildren<TableColumnProps<TableDataItem>> &
typeof defaultProps
const { updateColumn } = useTableContext<TableDataItem>()
const safeProp = `${prop}`.trim()
const safeProp = String(prop).trim()
if (!safeProp) {
useWarning('The props "prop" is required.', 'Table.Column')
}
Expand Down
6 changes: 3 additions & 3 deletions components/table/table-context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { TableAbstractColumn } from './table-types'
import { TableAbstractColumn, TableDataItemBase } from './table-types'

export interface TableConfig<T> {
export interface TableConfig<T extends TableDataItemBase> {
columns: Array<TableAbstractColumn<T>>
updateColumn: (column: TableAbstractColumn<T>) => void
}
Expand All @@ -13,5 +13,5 @@ const defaultContext = {

export const TableContext = React.createContext<TableConfig<any>>(defaultContext)

export const useTableContext = <T>(): TableConfig<T> =>
export const useTableContext = <T extends TableDataItemBase>(): TableConfig<T> =>
React.useContext<TableConfig<T>>(TableContext)
9 changes: 6 additions & 3 deletions components/table/table-head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const defaultProps = {
}

type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props<any>>
export type TableHeadProps<TableDataItem> = Props<TableDataItem> & NativeAttrs
export type TableHeadProps<TableDataItem extends TableDataItemBase> =
Props<TableDataItem> & NativeAttrs

const makeColgroup = <TableDataItem,>(
const makeColgroup = <TableDataItem extends TableDataItemBase>(
width: number,
columns: Array<TableAbstractColumn<TableDataItem>>,
) => {
Expand Down Expand Up @@ -51,7 +52,9 @@ const TableHead = <TableDataItem extends TableDataItemBase>(
<thead>
<tr>
{columns.map((column, index) => (
<th key={`table-th-${column.prop}-${index}`} className={column.className}>
<th
key={`table-th-${String(column.prop)}-${index}`}
className={column.className}>
<div className="thead-box">{column.label}</div>
</th>
))}
Expand Down
2 changes: 1 addition & 1 deletion components/table/table-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type TableColumnRender<Item extends TableDataItemBase> = (
rowIndex: number,
) => JSX.Element | void

export type TableAbstractColumn<TableDataItem> = {
export type TableAbstractColumn<TableDataItem extends TableDataItemBase> = {
prop: keyof TableDataItem
label: React.ReactNode | string
className: string
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@
],
"sideEffects": false,
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@geist-ui/icons": "^1.0.1",
"@babel/cli": "^7.23.0",
"@babel/plugin-transform-runtime": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.23.2",
"@geist-ui/icons": "^1.0.2",
"@geist-ui/prettier-config": "^1.0.1",
"@mapbox/rehype-prism": "^0.6.0",
"@mapbox/rehype-prism": "^0.8.0",
"@mdx-js/loader": "^1.6.22",
"@mdx-js/react": "^1.6.22",
"@next/bundle-analyzer": "^12.0.10",
"@next/mdx": "^12.0.8",
"@next/mdx": "^12.3.4",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@testing-library/dom": "^8.1.0",
Expand All @@ -69,9 +69,9 @@
"@testing-library/user-event": "^13.2.0",
"@types/enzyme": "^3.10.8",
"@types/jest": "^26.0.23",
"@types/react": "^17.0.38",
"@types/react-color": "^3.0.4",
"@types/react-dom": "^17.0.11",
"@types/react": "^17.0.69",
"@types/react-color": "^3.0.9",
"@types/react-dom": "^17.0.22",
"@typescript-eslint/eslint-plugin": "^4.27.0",
"@typescript-eslint/parser": "^4.27.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2",
Expand All @@ -82,11 +82,11 @@
"eslint": "^7.29.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-ts-lambdas": "^1.2.3",
"eslint-plugin-react": "^7.22.0",
"extract-mdx-metadata": "^1.0.0",
"fs-extra": "^10.0.0",
"eslint-plugin-react": "^7.33.2",
"extract-mdx-metadata": "^2.0.0",
"fs-extra": "^11.1.1",
"jest": "^27.0.5",
"next": "^12.0.9-canary.0",
"next": "^12.3.4",
"prettier": "^2.3.1",
"react": "^17.0.2",
"react-color": "^2.19.3",
Expand All @@ -98,12 +98,12 @@
"rollup-plugin-local-resolve": "^1.0.7",
"styled-jsx": "4.0.1",
"ts-jest": "^27.0.3",
"ttypescript": "^1.5.13",
"typescript": "^4.5.4",
"ttypescript": "^1.5.15",
"typescript": "^4.9.5",
"typescript-transform-paths": "^3.3.1"
},
"dependencies": {
"@babel/runtime": "^7.16.7"
"@babel/runtime": "^7.23.2"
},
"peerDependencies": {
"react": ">=16.9.0",
Expand Down
Loading