From a7877606014de5fa1eafb1dbf5be918e47a16808 Mon Sep 17 00:00:00 2001 From: Barrior Date: Tue, 17 Dec 2024 11:08:18 +0800 Subject: [PATCH] feat: solution for support ssr --- examples/core-react/001-intro.md | 26 ++++-- package.json | 3 - packages/core-react/.fatherrc.ts | 28 ------ packages/core-react/package.json | 13 +-- packages/form-render-react/.fatherrc.ts | 17 ---- packages/form-render-react/package.json | 12 +-- packages/form-render-react/src/FormRender.tsx | 2 +- .../form-render-react/src/cssinjs/index.ts | 12 --- .../src/{index.style.ts => index.module.css} | 8 +- packages/form-render-react/src/index.tsx | 1 - .../{styles.ts => index.module.css} | 56 ++++++------ .../src/itemLayouts/Horizontal/index.tsx | 2 +- .../Vertical/{styles.ts => index.module.css} | 40 ++++----- .../src/itemLayouts/Vertical/index.tsx | 2 +- .../form-render-react/src/typings/global.d.ts | 1 + packages/search-react/.fatherrc.ts | 17 ---- packages/search-react/package.json | 11 +-- packages/search-table-react/.fatherrc.ts | 17 ---- packages/search-table-react/package.json | 11 +-- .../{index.style.ts => index.module.css} | 66 +++++++------- .../components/ColumnSettingContent/index.tsx | 2 +- .../useColumns/helpers/actions.module.css | 18 ++++ .../src/hooks/useColumns/helpers/actions.tsx | 23 +---- .../src/hooks/useTitle/index.module.css | 3 + .../{useTitle.tsx => useTitle/index.tsx} | 13 +-- .../src/typings/global.d.ts | 1 + scripts/build-cli.mjs | 27 ------ scripts/build.mjs | 88 ------------------- scripts/config/swc.cjs.json | 19 ---- scripts/config/swc.esm.json | 23 ----- 30 files changed, 146 insertions(+), 416 deletions(-) delete mode 100644 packages/core-react/.fatherrc.ts delete mode 100644 packages/form-render-react/.fatherrc.ts delete mode 100644 packages/form-render-react/src/cssinjs/index.ts rename packages/form-render-react/src/{index.style.ts => index.module.css} (85%) rename packages/form-render-react/src/itemLayouts/Horizontal/{styles.ts => index.module.css} (62%) rename packages/form-render-react/src/itemLayouts/Vertical/{styles.ts => index.module.css} (54%) create mode 100644 packages/form-render-react/src/typings/global.d.ts delete mode 100644 packages/search-react/.fatherrc.ts delete mode 100644 packages/search-table-react/.fatherrc.ts rename packages/search-table-react/src/components/ColumnSettingContent/{index.style.ts => index.module.css} (52%) create mode 100644 packages/search-table-react/src/hooks/useColumns/helpers/actions.module.css create mode 100644 packages/search-table-react/src/hooks/useTitle/index.module.css rename packages/search-table-react/src/hooks/{useTitle.tsx => useTitle/index.tsx} (94%) create mode 100644 packages/search-table-react/src/typings/global.d.ts delete mode 100644 scripts/build-cli.mjs delete mode 100644 scripts/build.mjs delete mode 100644 scripts/config/swc.cjs.json delete mode 100644 scripts/config/swc.esm.json diff --git a/examples/core-react/001-intro.md b/examples/core-react/001-intro.md index 2f9e0f3..02ee153 100644 --- a/examples/core-react/001-intro.md +++ b/examples/core-react/001-intro.md @@ -2,18 +2,18 @@ group: title: 介绍 order: 0 -toc: false +toc: content --- # 简介 ## SchemaRender -`SchemaRender` 是一套 `默认简单`,但又追求 `灵活`、`可高定`、`好用的` 表单渲染解决方案,旨在沉淀解决常见表单案例的渲染库,与相关的通用组件,以提升研发效率。 +`SchemaRender` 是一套 `默认简单`,但又追求 `灵活`、`可高定`、`好用的` 表单渲染解决方案,旨在沉淀解决常见表单案例的渲染库,与相关的通用组件,以提升研发效率;支持 SSR(Server-Side Rendering) 渲染。 内容目录: -- `Core`: 表单渲染库内核,通过一套简易的 [JSON Schema](./003-schema.md) 构建出一套表单,内核主要处理 Schema 协议、渲染器编排、逻辑联动、校验能力等,支持 SSR(Server-Side Rendering)。 +- `Core`: 表单渲染库内核,通过一套简易的 [JSON Schema](./003-schema.md) 构建出一套表单,内核主要处理 Schema 协议、渲染器编排、逻辑联动、校验能力等。 - `FormRender`: 基于 Core + [Antd](https://ant.design) 封装的开箱即用的表单渲染库。 - `Search`:基于 FormRender 封装的开箱即用的条件搜索组件。 - `SearchTable`:基于 Search + Antd Table 封装的条件搜索表格。 @@ -22,14 +22,22 @@ toc: false 目前项目是基于 React 技术栈实现的,所以后缀都加了 `-react` 字眼,后续可能会将 Core 抽离成不依赖于技术栈的纯 JavaScript 项目,以便支持任何技术框架。 ::: -FormRender、Search 没有很好的支持 SSR,如果是 Next.js 项目,可以动态导入并配置 ssr 为不启用,如下示例。 +## SSR -```jsx | pure -import dynamic from 'next/dynamic' +FormRender、Search、SearchTable 使用的是 css module 的样式方案,故项目需要开启模块编译。 + +`Next.js` 项目须配置 `next.config.js` 文件: -const FormRender = dynamic(() => import('@schema-render/form-render-react'), { - ssr: false, -}) +```jsx | pure +// 编译 node_modules 下的模块 +{ + transpilePackages: [ + '@schema-render/core-react', + '@schema-render/form-render-react', + '@schema-render/search-react', + '@schema-render/search-table-react', + ] +} ``` ## Core diff --git a/package.json b/package.json index f27988c..3cb5238 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,6 @@ "name": "root", "private": true, "scripts": { - "build": "node scripts/build-cli.mjs", "cov": "yarn test --coverage", "dev": "yarn docs", "docs": "ERROR_OVERLAY=none dumi dev", @@ -41,8 +40,6 @@ "@j-lints/eslint-config-ts-react": "^0.0.2", "@j-lints/stylelint-config-scss": "^0.0.2", "@jest/types": "^29.6.3", - "@swc/cli": "^0.1.62", - "@swc/core": "^1.3.44", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/react-hooks": "^8.0.1", diff --git a/packages/core-react/.fatherrc.ts b/packages/core-react/.fatherrc.ts deleted file mode 100644 index b4fa3ff..0000000 --- a/packages/core-react/.fatherrc.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { defineConfig } from 'father' - -export default defineConfig({ - // more father config: https://github.com/umijs/father/blob/master/docs/config.md - esm: { - input: 'src', - output: 'dist/esm', - transformer: 'swc', - platform: 'node', - }, - cjs: { - input: 'src', - output: 'dist/cjs', - transformer: 'swc', - platform: 'browser', - }, - umd: { - name: 'SchemaRenderCore', - entry: { - 'src/index': {}, - }, - output: 'dist/umd', - platform: 'browser', - externals: { - react: 'react', - }, - }, -}) diff --git a/packages/core-react/package.json b/packages/core-react/package.json index 8e592f4..5a2628b 100644 --- a/packages/core-react/package.json +++ b/packages/core-react/package.json @@ -15,17 +15,12 @@ }, "license": "MIT", "sideEffects": false, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", + "main": "src/index.tsx", + "types": "src/index.tsx", "files": [ - "dist/cjs", - "dist/esm", - "dist/umd" + "src" ], - "scripts": { - "build": "father build" - }, + "scripts": {}, "dependencies": {}, "peerDependencies": { "react": ">=16.9.0", diff --git a/packages/form-render-react/.fatherrc.ts b/packages/form-render-react/.fatherrc.ts deleted file mode 100644 index cf64e4b..0000000 --- a/packages/form-render-react/.fatherrc.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from 'father' - -export default defineConfig({ - // more father config: https://github.com/umijs/father/blob/master/docs/config.md - esm: { - input: 'src', - output: 'dist/esm', - transformer: 'swc', - platform: 'node', - }, - cjs: { - input: 'src', - output: 'dist/cjs', - transformer: 'swc', - platform: 'browser', - }, -}) diff --git a/packages/form-render-react/package.json b/packages/form-render-react/package.json index e6a4c46..7a640df 100644 --- a/packages/form-render-react/package.json +++ b/packages/form-render-react/package.json @@ -15,17 +15,13 @@ }, "license": "MIT", "sideEffects": false, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", + "main": "src/index.tsx", + "types": "src/index.tsx", "files": [ - "dist" + "src" ], - "scripts": { - "build": "father build" - }, + "scripts": {}, "dependencies": { - "@emotion/css": "^11.11.2", "@schema-render/core-react": "^1.10.1", "dayjs": "^1.11.0" }, diff --git a/packages/form-render-react/src/FormRender.tsx b/packages/form-render-react/src/FormRender.tsx index f81d439..13481d7 100644 --- a/packages/form-render-react/src/FormRender.tsx +++ b/packages/form-render-react/src/FormRender.tsx @@ -9,7 +9,7 @@ import FormRenderContext from './FormRenderContext' import useActions from './hooks/useActions' import useItemLayout from './hooks/useItemLayout' import useSchema from './hooks/useSchema' -import * as styles from './index.style' +import styles from './index.module.css' import zh_CN from './locale/zh_CN' import renderers from './renderers/index' import type { diff --git a/packages/form-render-react/src/cssinjs/index.ts b/packages/form-render-react/src/cssinjs/index.ts deleted file mode 100644 index a690542..0000000 --- a/packages/form-render-react/src/cssinjs/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import createEmotion from '@emotion/css/create-instance' - -// ref https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript -const randomAlphabeticalCharacters = Math.random() - .toString(36) - .substring(7) - .replace(/\d/g, 'x') - -// 创建随机类名 key -export const { css: cij } = createEmotion({ - key: `schema-render-${randomAlphabeticalCharacters}`, -}) diff --git a/packages/form-render-react/src/index.style.ts b/packages/form-render-react/src/index.module.css similarity index 85% rename from packages/form-render-react/src/index.style.ts rename to packages/form-render-react/src/index.module.css index ce12b23..00c841f 100644 --- a/packages/form-render-react/src/index.style.ts +++ b/packages/form-render-react/src/index.module.css @@ -1,11 +1,9 @@ -import { cij } from './cssinjs' - -export const formRender = cij` +.formRender { --schema-render-color-description: #999; --schema-render-color-required-mark: #ff4d4f; --schema-render-color-warning: #faad14; --schema-render-color-error: #ff4d4f; - font-size: 16px; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans',sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Noto Color Emoji'; -` + font-size: 16px; +} diff --git a/packages/form-render-react/src/index.tsx b/packages/form-render-react/src/index.tsx index 116303f..fa6e52d 100644 --- a/packages/form-render-react/src/index.tsx +++ b/packages/form-render-react/src/index.tsx @@ -1,5 +1,4 @@ import FormRender from './FormRender' -export { cij } from './cssinjs' export default FormRender diff --git a/packages/form-render-react/src/itemLayouts/Horizontal/styles.ts b/packages/form-render-react/src/itemLayouts/Horizontal/index.module.css similarity index 62% rename from packages/form-render-react/src/itemLayouts/Horizontal/styles.ts rename to packages/form-render-react/src/itemLayouts/Horizontal/index.module.css index cff8cfe..9417511 100644 --- a/packages/form-render-react/src/itemLayouts/Horizontal/styles.ts +++ b/packages/form-render-react/src/itemLayouts/Horizontal/index.module.css @@ -1,59 +1,57 @@ -import { cij } from '../../cssinjs' - -export const main = cij` +.main { display: flex; align-items: center; -` +} -export const header = cij` - flex: 0 0 100px; - justify-content: flex-end; +.header { display: flex; align-items: center; - margin-right: 15px; + justify-content: flex-end; + flex: 0 0 100px; height: max-content; -` + margin-right: 15px; +} -export const title = cij` +.title { word-break: break-all; -` +} -export const mark = cij` +.mark { margin-right: 4px; color: var(--schema-render-color-required-mark); position: relative; top: 2px; -` +} -export const titleTooltip = cij` +.titleTooltip { margin-left: 4px; position: relative; top: 1px; -` +} -export const body = cij` +.body { flex-grow: 1; -` +} -export const footer = cij` - word-break: break-all; +.footer { padding-left: 115px; + word-break: break-all; +} - &:empty { - display: none; - } -` +.footer:empty { + display: none; +} -export const description = cij` +.description { margin-top: 6px; color: var(--schema-render-color-description); -` +} -export const errorMsg = cij` +.errorMsg { margin-top: 6px; color: var(--schema-render-color-error); -` +} -export const warningMsg = cij` +.warningMsg { color: var(--schema-render-color-warning); -` +} diff --git a/packages/form-render-react/src/itemLayouts/Horizontal/index.tsx b/packages/form-render-react/src/itemLayouts/Horizontal/index.tsx index 11cdeca..c6a45e2 100644 --- a/packages/form-render-react/src/itemLayouts/Horizontal/index.tsx +++ b/packages/form-render-react/src/itemLayouts/Horizontal/index.tsx @@ -6,7 +6,7 @@ import type { FC } from 'react' import useFormRenderContext from '../../hooks/useFormRenderContext' import type { IFormRenderProps } from '../../typings' -import * as styles from './styles' +import styles from './index.module.css' const { classNames } = utils diff --git a/packages/form-render-react/src/itemLayouts/Vertical/styles.ts b/packages/form-render-react/src/itemLayouts/Vertical/index.module.css similarity index 54% rename from packages/form-render-react/src/itemLayouts/Vertical/styles.ts rename to packages/form-render-react/src/itemLayouts/Vertical/index.module.css index 2a23c96..eaec2b5 100644 --- a/packages/form-render-react/src/itemLayouts/Vertical/styles.ts +++ b/packages/form-render-react/src/itemLayouts/Vertical/index.module.css @@ -1,42 +1,40 @@ -import { cij } from '../../cssinjs' - -export const header = cij` +.header { margin-bottom: 8px; -` +} -export const title = cij` +.title { word-break: break-all; -` +} -export const mark = cij` +.mark { margin-right: 4px; color: var(--schema-render-color-required-mark); position: relative; top: 2px; -` +} -export const titleTooltip = cij` +.titleTooltip { margin-left: 4px; -` +} -export const footer = cij` +.footer { word-break: break-all; +} - &:empty { - display: none; - } -` +.footer:empty { + display: none; +} -export const description = cij` +.description{ margin-top: 8px; color: var(--schema-render-color-description); -` +} -export const errorMsg = cij` +.errorMsg{ margin-top: 8px; color: var(--schema-render-color-error); -` +} -export const warningMsg = cij` +.warningMsg { color: var(--schema-render-color-warning); -` +} diff --git a/packages/form-render-react/src/itemLayouts/Vertical/index.tsx b/packages/form-render-react/src/itemLayouts/Vertical/index.tsx index a17541e..810dde6 100644 --- a/packages/form-render-react/src/itemLayouts/Vertical/index.tsx +++ b/packages/form-render-react/src/itemLayouts/Vertical/index.tsx @@ -6,7 +6,7 @@ import type { FC } from 'react' import useFormRenderContext from '../../hooks/useFormRenderContext' import type { IFormRenderProps } from '../../typings' -import * as styles from './styles' +import styles from './index.module.css' const { classNames } = utils diff --git a/packages/form-render-react/src/typings/global.d.ts b/packages/form-render-react/src/typings/global.d.ts new file mode 100644 index 0000000..6c344ed --- /dev/null +++ b/packages/form-render-react/src/typings/global.d.ts @@ -0,0 +1 @@ +declare module '*.module.css' diff --git a/packages/search-react/.fatherrc.ts b/packages/search-react/.fatherrc.ts deleted file mode 100644 index cf64e4b..0000000 --- a/packages/search-react/.fatherrc.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from 'father' - -export default defineConfig({ - // more father config: https://github.com/umijs/father/blob/master/docs/config.md - esm: { - input: 'src', - output: 'dist/esm', - transformer: 'swc', - platform: 'node', - }, - cjs: { - input: 'src', - output: 'dist/cjs', - transformer: 'swc', - platform: 'browser', - }, -}) diff --git a/packages/search-react/package.json b/packages/search-react/package.json index f36bc8c..d25eb55 100644 --- a/packages/search-react/package.json +++ b/packages/search-react/package.json @@ -16,15 +16,12 @@ }, "license": "MIT", "sideEffects": false, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", + "main": "src/index.tsx", + "types": "src/index.tsx", "files": [ - "dist" + "src" ], - "scripts": { - "build": "father build" - }, + "scripts": {}, "dependencies": { "@schema-render/form-render-react": "^1.10.1" }, diff --git a/packages/search-table-react/.fatherrc.ts b/packages/search-table-react/.fatherrc.ts deleted file mode 100644 index cf64e4b..0000000 --- a/packages/search-table-react/.fatherrc.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { defineConfig } from 'father' - -export default defineConfig({ - // more father config: https://github.com/umijs/father/blob/master/docs/config.md - esm: { - input: 'src', - output: 'dist/esm', - transformer: 'swc', - platform: 'node', - }, - cjs: { - input: 'src', - output: 'dist/cjs', - transformer: 'swc', - platform: 'browser', - }, -}) diff --git a/packages/search-table-react/package.json b/packages/search-table-react/package.json index 3666d47..fc30fa5 100644 --- a/packages/search-table-react/package.json +++ b/packages/search-table-react/package.json @@ -17,15 +17,12 @@ }, "license": "MIT", "sideEffects": false, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", - "types": "dist/esm/index.d.ts", + "main": "src/index.tsx", + "types": "src/index.tsx", "files": [ - "dist" + "src" ], - "scripts": { - "build": "father build" - }, + "scripts": {}, "dependencies": { "@dnd-kit/core": "6.1.0", "@dnd-kit/modifiers": "7.0.0", diff --git a/packages/search-table-react/src/components/ColumnSettingContent/index.style.ts b/packages/search-table-react/src/components/ColumnSettingContent/index.module.css similarity index 52% rename from packages/search-table-react/src/components/ColumnSettingContent/index.style.ts rename to packages/search-table-react/src/components/ColumnSettingContent/index.module.css index f8dbba6..45df5ec 100644 --- a/packages/search-table-react/src/components/ColumnSettingContent/index.style.ts +++ b/packages/search-table-react/src/components/ColumnSettingContent/index.module.css @@ -1,68 +1,66 @@ -import { cij } from '@schema-render/form-render-react' - -export const header = cij` +.header { display: flex; padding: 12px 0; border-bottom: 1px solid #f0f0f0; + font-weight: bold; background: #fafafa; border-radius: 8px 8px 0 0; - font-weight: bold; -` +} -export const list = cij` +.list { max-height: calc(100vh - 260px); overflow: auto; +} - &::-webkit-scrollbar { - width: 6px; - } +.list::-webkit-scrollbar { + width: 6px; +} - &::-webkit-scrollbar-thumb { - background: #ccc; - border-radius: 6px; - } +.list::-webkit-scrollbar-thumb { + background: #ccc; + border-radius: 6px; +} - &::-webkit-scrollbar-thumb:hover { - background: #999; - } -` +.list::-webkit-scrollbar-thumb:hover { + background: #999; +} -export const rowWrapper = cij` +.rowWrapper { border-top: 1px solid #f0f0f0; +} - &:first-of-type { - border-top: none; - } -` +.rowWrapper:first-of-type { + border-top: none; +} -export const rowWrapperOverlay = cij` +.rowWrapperOverlay { + border: 1px solid #f0f0f0; background-color: #fff; transform: scale(1.05); - border: 1px solid #f0f0f0; border-radius: 8px; transition: 200ms ease-out; -` +} -export const row = cij` +.row { display: flex; padding: 8px 0; background-color: #fff; +} - &:hover { - background-color: #fafafa; - } -` +.row:hover { + background-color: #fafafa; +} -export const col = cij` +.col { display: flex; align-items: center; padding: 0 12px; word-break: break-all; flex-shrink: 0; -` +} -export const footer = cij` +.footer { text-align: right; padding-top: 12px; border-top: 1px solid #f0f0f0; -` +} diff --git a/packages/search-table-react/src/components/ColumnSettingContent/index.tsx b/packages/search-table-react/src/components/ColumnSettingContent/index.tsx index 9085984..4c4086b 100644 --- a/packages/search-table-react/src/components/ColumnSettingContent/index.tsx +++ b/packages/search-table-react/src/components/ColumnSettingContent/index.tsx @@ -7,7 +7,7 @@ import useRootContext from '../../hooks/useRootContext' import type { IColumnType } from '../../typings/table' import Sortable from '../Sortable' import { createColumns } from './index.column' -import * as styles from './index.style' +import styles from './index.module.css' export interface IColumnSettingContentProps { sortColumns: IColumnType[] diff --git a/packages/search-table-react/src/hooks/useColumns/helpers/actions.module.css b/packages/search-table-react/src/hooks/useColumns/helpers/actions.module.css new file mode 100644 index 0000000..a5f7b92 --- /dev/null +++ b/packages/search-table-react/src/hooks/useColumns/helpers/actions.module.css @@ -0,0 +1,18 @@ +.dropdownCls { + padding: 6px; + background-color: #fff; + box-shadow: 0 4px 12px 0 #ececec; + border-radius: 8px; + min-width: 70px; +} + +.dropdownCls > * { + display: block; + width: 100%; + height: auto !important; + padding: 3px 6px !important; +} + +.dropdownCls > *:hover { + background: #f6f6f6 !important; +} diff --git a/packages/search-table-react/src/hooks/useColumns/helpers/actions.tsx b/packages/search-table-react/src/hooks/useColumns/helpers/actions.tsx index c0933d0..f4c7b8f 100644 --- a/packages/search-table-react/src/hooks/useColumns/helpers/actions.tsx +++ b/packages/search-table-react/src/hooks/useColumns/helpers/actions.tsx @@ -1,7 +1,6 @@ import { DownOutlined } from '@ant-design/icons' import type { IObjectAny } from '@schema-render/core-react' import { utils } from '@schema-render/core-react' -import { cij } from '@schema-render/form-render-react' import { Button, Dropdown, Popconfirm } from 'antd' import type { ReactNode } from 'react' import { Fragment } from 'react' @@ -9,28 +8,10 @@ import { Fragment } from 'react' import ButtonLoading from '../../../components/ButtonLoading' import type { ILocale, ISearchTableProps } from '../../../typings' import type { IActionItem } from '../../../typings/table.d' +import styles from './actions.module.css' const { isArray, isString, omit } = utils -const dropdownCls = cij` - background-color: #fff; - border-radius: 8px; - box-shadow: 0 4px 12px 0 #ececec; - min-width: 70px; - padding: 6px; - - > * { - display: block; - width: 100%; - height: auto !important; - padding: 3px 6px !important; - - &:hover { - background: #f6f6f6 !important; - } - } -` - /** * 创建「操作栏」按钮 */ @@ -123,7 +104,7 @@ export function createActions({ placement="bottomRight" {...actionItemsDropdownProps} dropdownRender={() => ( -
+
{dropdownItems.map((label, i) => ( {label} ))} diff --git a/packages/search-table-react/src/hooks/useTitle/index.module.css b/packages/search-table-react/src/hooks/useTitle/index.module.css new file mode 100644 index 0000000..04de7b8 --- /dev/null +++ b/packages/search-table-react/src/hooks/useTitle/index.module.css @@ -0,0 +1,3 @@ +.tabsHideLine > div::before { + content: none !important; +} diff --git a/packages/search-table-react/src/hooks/useTitle.tsx b/packages/search-table-react/src/hooks/useTitle/index.tsx similarity index 94% rename from packages/search-table-react/src/hooks/useTitle.tsx rename to packages/search-table-react/src/hooks/useTitle/index.tsx index 3e3e104..93ef870 100644 --- a/packages/search-table-react/src/hooks/useTitle.tsx +++ b/packages/search-table-react/src/hooks/useTitle/index.tsx @@ -1,6 +1,5 @@ import { SettingOutlined, SyncOutlined } from '@ant-design/icons' import { useMemoizedFn, utils } from '@schema-render/core-react' -import { cij } from '@schema-render/form-render-react' import { Button, Space, Tabs, Tooltip } from 'antd' import type { TabBarExtraMap } from 'rc-tabs/lib/interface.d.ts' import type { ReactNode } from 'react' @@ -11,7 +10,8 @@ import type { ILocale, ISearchTableProps, ISearchTableRef, -} from '../typings' +} from '../../typings' +import styles from './index.module.css' interface IUseTitleParams { locale: ILocale @@ -24,13 +24,6 @@ interface IUseTitleParams { const { classNames } = utils -// 隐藏 Tabs 下划线 -const tabsHideLine = cij` - > div::before { - content: none !important; - } -` - export default function useTitle({ locale, title = {}, @@ -124,7 +117,7 @@ export default function useTitle({ { - buildProject({ packages: answers }) - }) diff --git a/scripts/build.mjs b/scripts/build.mjs deleted file mode 100644 index 2765e54..0000000 --- a/scripts/build.mjs +++ /dev/null @@ -1,88 +0,0 @@ -import swc from '@swc/core' -import { execaCommandSync } from 'execa' -import { writeFileSync } from 'fs' -import { globSync } from 'glob' -import ora from 'ora' -import path from 'path' -import { fileURLToPath } from 'url' - -const __dirname = path.dirname(fileURLToPath(import.meta.url)) -const DIR_PACKAGES = path.resolve(__dirname, '../packages') - -const spinner = ora() - -class Build { - constructor(packageName) { - this.inputDir = path.resolve(DIR_PACKAGES, `${packageName}/src`) - this.outputDir = path.resolve(DIR_PACKAGES, `${packageName}/dist`) - this.runWorkflow() - } - - runWorkflow() { - this.cleanDir() - this.buildFiles() - } - - cleanDir() { - execaCommandSync(`rm -rf ${this.outputDir}`) - } - - buildFiles() { - const files = globSync('**', { - cwd: this.inputDir, - dot: false, - nodir: true, - ignore: ['**/node_modules/**'], - }) - spinner.succeed('====== Build esm ======') - this.buildESM(files) - spinner.succeed('====== Build cjs ======') - this.buildCJS(files) - } - - writeFile(filename, content, type) { - filename = filename.replace(/\.tsx?$/, '.js') - const destPath = path.resolve(this.outputDir, type, filename) - - execaCommandSync(`mkdir -p ${path.dirname(destPath)}`) - writeFileSync(destPath, content, { encoding: 'utf8' }) - - spinner.succeed(`Write file succeed: ${destPath}`) - } - - buildESM(files) { - files.forEach((filename) => { - const absPath = path.resolve(this.inputDir, filename) - - if (/\.tsx?$/.test(filename)) { - const output = swc.transformFileSync(absPath, { - inputSourceMap: false, - isModule: true, - configFile: path.resolve(__dirname, './config/swc.esm.json'), - }) - this.writeFile(filename, output.code, 'esm') - } - }) - } - - buildCJS(files) { - files.forEach((filename) => { - const absPath = path.resolve(this.inputDir, filename) - - if (/\.tsx?$/.test(filename)) { - const output = swc.transformFileSync(absPath, { - inputSourceMap: false, - isModule: true, - configFile: path.resolve(__dirname, './config/swc.cjs.json'), - }) - this.writeFile(filename, output.code, 'cjs') - } - }) - } -} - -export default function buildProject(opts) { - opts.packages.forEach((packageName) => { - new Build(packageName) - }) -} diff --git a/scripts/config/swc.cjs.json b/scripts/config/swc.cjs.json deleted file mode 100644 index 0491cbe..0000000 --- a/scripts/config/swc.cjs.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "jsc": { - "target": "es5", - "loose": true, - "parser": { - "syntax": "typescript", - "tsx": false, - "decorators": false - }, - "externalHelpers": false - }, - "module": { - "type": "commonjs", - "strict": false, - "strictMode": true, - "lazy": false, - "noInterop": false - } -} diff --git a/scripts/config/swc.esm.json b/scripts/config/swc.esm.json deleted file mode 100644 index 647082d..0000000 --- a/scripts/config/swc.esm.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "jsc": { - "target": "es2016", - "loose": false, - "externalHelpers": false, - "parser": { - "syntax": "typescript", - "tsx": true, - "decorators": true - }, - "transform": { - "legacyDecorator": true, - "decoratorMetadata": true - } - }, - "module": { - "type": "es6", - "strict": false, - "strictMode": false, - "lazy": false, - "noInterop": false - } -}