From 64e3882f1cd2fb52964710848674f58d8c9a3865 Mon Sep 17 00:00:00 2001 From: Jinke Li Date: Mon, 18 Nov 2024 10:07:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20s2-react=20=E7=A7=BB=E9=99=A4=20antd=20?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96=E5=92=8C=E9=83=A8=E5=88=86=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E7=BB=84=E4=BB=B6,=20=E7=9B=B8=E5=85=B3=E5=88=86?= =?UTF-8?q?=E6=9E=90=E7=BB=84=E4=BB=B6=E8=BF=81=E7=A7=BB=E5=88=B0=20s2-rea?= =?UTF-8?q?ct-components=20=20=E4=B8=AD=20(#2887)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build: esm 模块按目录打包, 使用 bundless 的方式支持 tree shaking * build: 修复打包尺寸校验失败 * build: 自动打开分析工具 * refactor: 解决所有循环依赖问题 * build: 使用 bundless * docs: 新增变更文档 * chore: 修复 size-limit 错误 * chore: 移除别名配置 * build: 预编译 s2-shared, 解决 bundless 的问题 * build: 修复 react-components 和 vue 打包失败 * feat: s2-react 移除 antd 的依赖, 相关分析组件迁移到 s2-react-components 中 只保留 drill-down, pagination, tooltip 三个基础能力组件 BREAKING CHANGE: 移除 header props 参数 (不再内置行列切换, 导出, 高级排序), 移除 antd ConfigProvider 包裹 * feat: 移除 header * feat: 移除 SheetComponent 中的 Spin 组件 * feat: 移除分页组件 * docs: 更新文档 * feat: 解耦操作栏 Menu 组件 * feat: 移除编辑表的 Input 依赖 * feat: 迁移下钻组件 * docs: 更新文档 * docs: 完善分页文档 * docs: 完善导出文档 * docs: 调整目录结构 * refactor: 优化分页组件的使用方式 * docs: 完善导出和维度切换组件文档 * test: 迁移并修复 s2-react 中的分析组件单测 * test: 完善 s2-react-components 中高级排序/下钻/导出 单测 * feat: 完善 switcher 功能和单测 * feat: 统一入口文件风格 * test: 更新单测 * feat: 移除 s2-react 的 antd peerDependencies * chore: 更新 lock * docs: 更新文档 * docs: 完善文档和示例 * feat: 优化目录结构和文档合理性 * fix: 修复类型问题 * test: 调整单测路径 * feat: shared 包移动到 s2-core 中, 优化打包方式 * chore: 移除 s2-react-components 中的 shared 依赖 * chore: 移除 s2-vue 中的 shared 依赖 * test: 迁移 shared 单测 * docs: 完善文档 * fix: 修复布局错误 * build: 修复 umd 打包失败 * chore: 调整 size-limit * docs: 完善文档 * build: 使用 tsc 打包 * test: 修复单测 * build: 移除 father * build: 移除 father * chore: 修复 ci * test: 更新 jest 别名 * test: 修复 svg mock 不生效 * docs: 优化文档 * test: 修复单测 * test: 更新快照 * docs: 优化文档跳转效果和迁移文档 * docs: 优化 2.0-next => 2.0 迁移文档 * docs: 更新贡献指南 * chore: 移除无用开发依赖 * chore: 更新 lock * chore(ci): 尝试解决 CI 单测进程挂起的问题 * chore(ci): 尝试解决 CI 单测进程挂起的问题 --------- Co-authored-by: Wenjun Xu <906626481@qq.com> Co-authored-by: 卿珂 --- .eslintrc.js | 7 +- .github/workflows/auto-release.yml | 3 + .github/workflows/compressed-size.yml | 4 +- .gitignore | 1 + CONTRIBUTING.md | 6 +- README.en-US.md | 20 +- README.md | 20 +- build.config.base.mjs | 145 ++ jest.config.base.js | 4 +- package.json | 7 +- packages/s2-core/README.en-US.md | 4 +- packages/s2-core/README.md | 6 +- packages/s2-core/__tests__/setup.js | 2 + .../interaction/row-column-resize-spec.ts | 40 +- .../__snapshots__/drill-down-spec.ts.snap | 0 .../utils/__snapshots__/options-spec.ts.snap | 0 .../unit/shared}/utils/classnames-spec.ts | 2 +- .../unit/shared}/utils/drill-down-spec.ts | 12 +- .../unit/shared}/utils/options-spec.ts | 4 +- .../unit/shared}/utils/resize-spec.ts | 7 +- .../__snapshots__/formatter-spec.ts.snap | 4 + packages/s2-core/__tests__/util/helpers.ts | 6 + packages/s2-core/package.json | 20 +- packages/s2-core/rollup.config.mjs | 9 +- packages/s2-core/scripts/test-live.mjs | 4 +- packages/s2-core/src/cell/merged-cell.ts | 6 +- packages/s2-core/src/facet/index.ts | 10 +- .../src/facet/layout/build-gird-hierarchy.ts | 10 +- .../facet/layout/build-header-hierarchy.ts | 14 +- .../src/facet/layout/build-table-hierarchy.ts | 2 + packages/s2-core/src/facet/layout/index.ts | 4 + .../s2-core/src/facet/layout/interface.ts | 1 + packages/s2-core/src/index.ts | 5 +- .../src/shared}/constant/classnames.ts | 2 +- .../src/shared}/constant/i18n/en_US.ts | 0 .../src/shared}/constant/i18n/index.ts | 2 +- .../src/shared}/constant/i18n/ru_RU.ts | 0 .../src/shared}/constant/i18n/zh_CN.ts | 0 .../src/shared}/constant/index.ts | 0 .../src/shared}/constant/option.ts | 2 +- .../src/shared}/constant/resize.ts | 0 .../src/shared}/constant/sort.ts | 2 +- .../src/shared}/constant/theme.ts | 2 +- .../src/shared}/icons/calendar-icon.svg | 0 .../src/shared}/icons/col-icon.svg | 0 .../src/shared}/icons/dot-icon.svg | 0 .../src/shared}/icons/location-icon.svg | 0 .../src/shared}/icons/row-icon.svg | 0 .../src/shared}/icons/search-icon.svg | 0 .../src/shared}/icons/sort-icon.svg | 0 .../src/shared}/icons/switcher-icon.svg | 0 .../src/shared}/icons/text-icon.svg | 0 .../src/shared}/icons/value-icon.svg | 0 packages/s2-core/src/shared/index.ts | 5 + .../src => s2-core/src/shared}/interface.ts | 57 +- .../src/shared}/styles/drill-down.less | 5 +- .../src/shared}/styles/theme/dark.less | 0 .../src/shared}/styles/tooltip/index.less | 2 +- .../src/shared}/styles/tooltip/operator.less | 0 .../src/shared}/styles/variables.less | 5 +- .../src/shared}/utils/classnames.ts | 0 .../src/shared}/utils/drill-down.ts | 12 +- packages/s2-core/src/shared/utils/index.ts | 4 + .../src/shared}/utils/options.ts | 3 +- .../src/shared}/utils/resize.ts | 2 +- .../s2-core/src/sheet-type/spread-sheet.ts | 1 + packages/s2-core/src/styles/variables.less | 7 +- .../s2-core/src/utils/cell/header-cell.ts | 7 +- packages/s2-core/src/utils/cell/index.ts | 6 + .../s2-core/src/utils/cell/merged-cell.ts | 140 ++ .../s2-core/src/utils/export/copy/common.ts | 13 +- .../s2-core/src/utils/export/copy/core.ts | 57 +- .../s2-core/src/utils/export/copy/index.ts | 15 +- .../utils/export/copy/pivot-data-cell-copy.ts | 2 +- .../src/utils/export/copy}/strategy-copy.ts | 27 +- .../src/utils/export/copy/table-copy.ts | 3 +- packages/s2-core/src/utils/export/index.ts | 10 +- packages/s2-core/src/utils/export/utils.ts | 49 - packages/s2-core/src/utils/index.ts | 3 +- .../src/utils/interaction/merge-cell.ts | 140 -- .../src/utils/layout/generate-header-nodes.ts | 6 +- packages/s2-core/src/utils/theme.ts | 7 +- packages/s2-core/tsconfig.build.json | 7 + packages/s2-core/tsconfig.declaration.json | 10 - packages/s2-core/tsconfig.json | 1 - packages/s2-react-components/README.md | 4 +- .../__tests__/__mocks__/svg.ts | 4 + .../__tests__/bugs/issue-1736-spec.tsx | 22 +- .../__snapshots__/advanced-sort-spec.tsx.snap | 81 ++ .../__snapshots__/custom-sort-spec.tsx.snap | 646 ++++++++ .../advanced-sort/advanced-sort-spec.tsx | 68 + .../advanced-sort/custom-sort-spec.tsx | 24 + .../__snapshots__/drill-down-spec.tsx.snap | 688 +++++++++ .../components/drill-down/drill-down-spec.tsx | 74 + .../export/__snapshots__/export-spec.tsx.snap | 69 + .../unit/components/export/export-spec.tsx | 100 ++ .../__snapshots__/index-spec.tsx.snap | 0 .../__snapshots__/index-spec.tsx.snap | 0 .../frozen-input-number/index-spec.tsx | 0 .../{config => }/frozen-panel/index-spec.tsx | 0 .../__snapshots__/switcher-spec.tsx.snap | 122 ++ .../content/__snapshots__/index-spec.tsx.snap | 75 + .../switcher/content/index-spec.tsx | 11 + .../components/switcher/switcher-spec.tsx | 49 + .../unit/components/switcher/util-spec.ts | 10 +- .../__snapshots__/index-spec.tsx.snap | 0 .../text-align-panel/index-spec.tsx | 0 .../__snapshots__/index-spec.tsx.snap | 0 .../__snapshots__/utils-spec.ts.snap | 0 .../__snapshots__/index-spec.tsx.snap | 0 .../theme-panel/color-box/index-spec.tsx | 0 .../__snapshots__/index-spec.tsx.snap | 0 .../color-picker-panel/index-spec.tsx | 0 .../hooks/useHistoryColorList-spec.ts | 2 +- .../{config => }/theme-panel/index-spec.tsx | 0 .../{config => }/theme-panel/utils-spec.ts | 2 +- .../__tests__/util/helpers.ts | 5 - packages/s2-react-components/package.json | 36 +- .../playground/Header}/index.less | 4 +- .../playground/Header/index.tsx | 167 +++ .../s2-react-components/playground/config.tsx | 12 +- .../s2-react-components/playground/index.less | 1 + .../s2-react-components/playground/index.tsx | 210 ++- .../advanced-sort/advanced-sort.tsx} | 85 +- .../components/advanced-sort/custom-sort.tsx | 20 +- .../src/components/advanced-sort/index.less | 2 +- .../src/components/advanced-sort/index.ts | 12 + .../src/components/advanced-sort/interface.ts | 44 + .../src/components/analysis/index.ts | 1 - .../components/analysis/switcher/index.tsx | 5 - .../src/components/common/icons/index.less | 5 + .../src/components/common/icons/index.tsx | 9 + .../src/components/common/index.ts | 9 +- .../components/common/radio-group/index.ts | 2 + .../{index.tsx => radio-group.tsx} | 0 .../components/common/reset-button/index.ts | 2 + .../{index.tsx => reset-button.tsx} | 0 .../components/common/reset-group/index.ts | 2 + .../{index.tsx => reset-group.tsx} | 0 .../common/tooltip-wrapper/index.ts | 2 + .../{index.tsx => tooltip-wrapper.tsx} | 0 .../src/components/config/index.ts | 10 - .../src/components/drill-down/drill-down.tsx} | 48 +- .../src/components/drill-down/index.less | 1 + .../src/components/drill-down/index.ts | 3 + .../src/components/drill-down/interface.ts | 13 + .../src/components/export/export.tsx} | 61 +- .../src/components/export/index.ts | 4 + .../src/components/export/interface.ts | 27 + .../src/components/export/strategy-export.tsx | 10 + .../frozen-input-number/index.tsx | 0 .../frozen-input-number/interface.ts | 0 .../frozen-panel.tsx} | 2 +- .../{config => }/frozen-panel/index.less | 0 .../src/components/frozen-panel/index.ts | 4 + .../{config => }/frozen-panel/interface.ts | 2 +- .../src/components/index.ts | 11 +- .../src/components/switcher/constant.ts | 0 .../components/switcher/content/index.less | 2 +- .../src/components/switcher/content/index.tsx | 2 +- .../components/switcher/dimension/index.less | 2 +- .../components/switcher/dimension/index.tsx | 0 .../src/components/switcher/index.less | 2 +- .../src/components/switcher/index.ts | 8 + .../src/components/switcher/interface.ts | 2 + .../src/components/switcher/item/index.less | 6 +- .../src/components/switcher/item/index.tsx | 0 .../components/switcher/item/single-item.tsx | 0 .../src/components/switcher/switcher.tsx} | 10 +- .../src/components/switcher/util.ts | 4 +- .../{config => }/text-align-panel/icons.tsx | 2 +- .../{config => }/text-align-panel/index.less | 0 .../src/components/text-align-panel/index.ts | 3 + .../text-align-panel/interface.ts | 2 +- .../text-align-panel.tsx} | 9 +- .../{config => }/text-align-panel/utils.ts | 2 +- .../theme-panel/color-box/index.less | 0 .../theme-panel/color-box/index.tsx | 0 .../theme-panel/color-box/interface.ts | 0 .../theme-panel/color-picker-panel/index.less | 0 .../theme-panel/color-picker-panel/index.tsx | 4 +- .../color-picker-panel/interface.ts | 0 .../theme-panel/hooks/useHistoryColorList.ts | 2 +- .../{config => }/theme-panel/icons.tsx | 2 +- .../{config => }/theme-panel/index.less | 0 .../src/components/theme-panel/index.ts | 5 + .../{config => }/theme-panel/interface.ts | 4 +- .../index.tsx => theme-panel/theme-panel.tsx} | 6 +- .../{config => }/theme-panel/utils.ts | 2 +- .../s2-react-components/tsconfig.build.json | 7 + .../tsconfig.declaration.json | 10 - packages/s2-react-components/tsconfig.json | 4 +- packages/s2-react-components/vite.config.ts | 112 +- packages/s2-react/README.md | 2 +- .../__tests__/bugs/issue-594-spec.tsx | 3 +- .../__tests__/bugs/issue-652-spec.tsx | 2 +- .../__snapshots__/pagination-spec.tsx.snap | 233 +++ .../__tests__/spreadsheet/adaptive-spec.tsx | 3 +- .../__tests__/spreadsheet/pagination-spec.tsx | 101 +- .../spreadsheet/table-sheet-spec.tsx | 12 +- .../__tests__/spreadsheet/tooltip-spec.tsx | 6 + .../__snapshots__/index-spec.tsx.snap | 23 - .../components/advanced-sort/index-spec.tsx | 16 - .../__snapshots__/index-spec.tsx.snap | 155 -- .../unit/components/drill-down/index-spec.tsx | 15 - .../export/__snapshots__/index-spec.tsx.snap | 12 - .../unit/components/export/index-spec.tsx | 16 - .../header/__snapshots__/index-spec.tsx.snap | 91 -- .../unit/components/header/index-spec.tsx | 66 - .../__snapshots__/index-spec.tsx.snap | 262 ---- .../unit/components/pagination/index-spec.tsx | 19 - .../sheets/__snapshots__/index-spec.tsx.snap | 1293 +---------------- .../unit/components/sheets/index-spec.tsx | 8 +- .../__snapshots__/index-spec.tsx.snap | 165 +++ .../sheets/strategy-sheet/index-spec.tsx | 2 +- .../__snapshots__/index-spec.tsx.snap | 19 - .../components/switcher/headerUtil-spec.ts | 304 ---- .../unit/components/switcher/index-spec.tsx | 11 - .../tooltip/__snapshots__/index-spec.tsx.snap | 12 +- .../unit/components/tooltip/index-spec.tsx | 11 +- .../unit/hooks/usePagination-spec.ts | 47 +- .../unit/hooks/useSpreadSheet-spec.ts | 16 + .../__tests__/unit/utils/drill-down-spec.ts | 6 +- packages/s2-react/__tests__/util/helpers.ts | 12 +- packages/s2-react/package.json | 35 +- .../playground/components/ChartSheet.tsx | 5 - .../components/ConfigProvider}/index.tsx | 6 +- .../playground/components/CustomGrid.tsx | 5 - .../playground/components/CustomTree.tsx | 53 +- .../playground/components/Header/index.less | 57 + .../playground/components/Header/index.tsx | 108 ++ .../playground/components/Plugins.tsx | 3 - .../playground/components/StrategySheet.tsx | 98 +- packages/s2-react/playground/config.tsx | 16 +- packages/s2-react/playground/drill-down.tsx | 15 +- packages/s2-react/playground/index.tsx | 84 +- packages/s2-react/scripts/test-live.mjs | 4 +- .../s2-react/src/common/icons/html-icon.less | 2 +- .../s2-react/src/components/header/index.tsx | 76 - .../s2-react/src/components/icons/index.less | 5 - .../s2-react/src/components/icons/index.tsx | 24 - packages/s2-react/src/components/index.ts | 13 - .../src/components/pagination/index.tsx | 52 - .../components/sheets/base-sheet/index.less | 24 +- .../components/sheets/base-sheet/index.tsx | 43 +- .../custom-cell/edit-cell/index.less | 27 +- .../custom-cell/edit-cell/index.tsx | 5 +- .../drag-copy/drag-copy-mask.less | 2 +- .../drag-copy/drag-copy-point.less | 2 +- .../s2-react/src/components/sheets/index.tsx | 7 +- .../src/components/sheets/interface.ts | 39 +- .../components/sheets/pivot-sheet/index.tsx | 37 +- .../custom-tooltip/col-cell-tooltip.tsx | 2 +- .../custom-tooltip/data-cell-tooltip.tsx | 2 +- .../strategy-sheet/custom-tooltip/index.less | 2 +- .../custom-tooltip/row-cell-tooltip.tsx | 7 +- .../sheets/strategy-sheet/index.tsx | 10 - .../src/components/switcher/header.tsx | 98 -- .../src/components/switcher/headerUtil.ts | 124 -- .../tooltip/components/operator.tsx | 34 +- .../src/components/tooltip/custom-tooltip.tsx | 28 +- .../src/components/tooltip/index.less | 3 +- .../src/components/tooltip/interface.ts | 29 +- packages/s2-react/src/hooks/usePagination.ts | 65 +- .../s2-react/src/hooks/usePivotSheetUpdate.ts | 2 +- packages/s2-react/src/hooks/usePrevious.ts | 11 - packages/s2-react/src/hooks/useResize.ts | 2 +- packages/s2-react/src/hooks/useSpreadSheet.ts | 25 +- packages/s2-react/src/utils/extendLocale.ts | 3 +- packages/s2-react/src/utils/options.ts | 2 +- packages/s2-react/tsconfig.build.json | 7 + packages/s2-react/tsconfig.declaration.json | 10 - packages/s2-react/tsconfig.json | 10 +- packages/s2-react/vite.config.ts | 116 +- packages/s2-shared/__tests__/setup.js | 3 - packages/s2-shared/__tests__/util/helpers.ts | 5 - packages/s2-shared/jest.config.js | 1 - packages/s2-shared/package.json | 27 - packages/s2-shared/src/index.ts | 7 - packages/s2-shared/src/utils/theme.ts | 11 - packages/s2-shared/tsconfig.declaration.json | 10 - packages/s2-shared/tsconfig.json | 4 - packages/s2-vue/README.md | 4 +- packages/s2-vue/package.json | 28 +- packages/s2-vue/playground/App.vue | 15 +- .../src/components/drill-down/index.vue | 23 +- .../src/components/sheets/base-sheet.vue | 2 +- .../s2-vue/src/components/sheets/index.vue | 2 +- .../src/components/sheets/pivot-sheet.vue | 16 +- .../tooltip/components/operator/index.vue | 4 +- .../s2-vue/src/components/tooltip/index.vue | 3 +- packages/s2-vue/src/hooks/useResize.ts | 2 +- packages/s2-vue/src/hooks/useSheetUpdate.ts | 6 +- packages/s2-vue/src/interface.ts | 17 +- packages/s2-vue/src/utils/extendLocale.ts | 3 +- packages/s2-vue/src/utils/initPropAndEmits.ts | 15 +- packages/s2-vue/src/utils/options.ts | 2 +- packages/s2-vue/tsconfig.build.json | 7 + packages/s2-vue/tsconfig.declaration.json | 9 - packages/s2-vue/tsconfig.json | 5 + packages/s2-vue/vite.config.ts | 89 +- pnpm-lock.yaml | 1086 +++++++++----- s2-site/.dumi/global.ts | 16 +- s2-site/.dumirc.ts | 8 + s2-site/docs/api/basic-class/base-cell.en.md | 4 +- s2-site/docs/api/basic-class/base-cell.zh.md | 4 +- .../docs/api/basic-class/base-data-set.en.md | 10 +- .../docs/api/basic-class/base-data-set.zh.md | 14 +- s2-site/docs/api/basic-class/base-facet.en.md | 2 +- s2-site/docs/api/basic-class/base-facet.zh.md | 80 +- .../docs/api/basic-class/base-tooltip.zh.md | 2 +- s2-site/docs/api/basic-class/hierarchy.zh.md | 20 +- .../docs/api/basic-class/interaction.zh.md | 8 +- s2-site/docs/api/basic-class/node.zh.md | 12 +- .../docs/api/basic-class/spreadsheet.en.md | 26 +- .../docs/api/basic-class/spreadsheet.zh.md | 52 +- s2-site/docs/api/basic-class/store.en.md | 2 +- s2-site/docs/api/basic-class/store.zh.md | 10 +- .../docs/api/components/advanced-sort.en.md | 8 +- .../docs/api/components/advanced-sort.zh.md | 22 +- s2-site/docs/api/components/drill-down.en.md | 4 +- s2-site/docs/api/components/drill-down.zh.md | 19 +- s2-site/docs/api/components/export.zh.md | 21 +- s2-site/docs/api/components/header.en.md | 38 - s2-site/docs/api/components/header.zh.md | 36 - .../docs/api/components/sheet-component.en.md | 39 +- .../docs/api/components/sheet-component.zh.md | 142 +- s2-site/docs/api/components/switcher.zh.md | 18 +- ...2DataConfig.en.md => s2-data-config.en.md} | 2 - ...2DataConfig.zh.md => s2-data-config.zh.md} | 2 - .../general/{S2Event.en.md => s2-event.en.md} | 0 .../general/{S2Event.zh.md => s2-event.zh.md} | 5 +- .../{S2Options.en.md => s2-options.en.md} | 0 .../{S2Options.zh.md => s2-options.zh.md} | 16 +- .../general/{S2Theme.en.md => s2-theme.en.md} | 0 .../general/{S2Theme.zh.md => s2-theme.zh.md} | 0 s2-site/docs/api/graphic.en.md | 2 - s2-site/docs/api/graphic.zh.md | 12 +- s2-site/docs/common/browser.en.md | 12 +- s2-site/docs/common/browser.zh.md | 15 +- s2-site/docs/common/copy-export.zh.md | 8 +- s2-site/docs/common/custom-tooltip.zh.md | 10 +- .../docs/common/custom/layoutArrange.zh.md | 4 +- .../docs/common/custom/layoutCoordinate.zh.md | 6 +- .../docs/common/custom/layoutHierarchy.zh.md | 4 +- .../custom/layoutSeriesNumberNodes.zh.md | 4 +- s2-site/docs/common/header.en.md | 17 - s2-site/docs/common/header.zh.md | 19 - s2-site/docs/common/install.en.md | 0 s2-site/docs/common/install.zh.md | 37 + s2-site/docs/common/interaction.zh.md | 18 +- s2-site/docs/common/packages.zh.md | 25 +- s2-site/docs/common/pagination.zh.md | 31 +- s2-site/docs/common/style.zh.md | 8 +- s2-site/docs/common/totals.en.md | 4 +- s2-site/docs/manual/advanced/adaptive.en.md | 2 +- s2-site/docs/manual/advanced/adaptive.zh.md | 2 +- .../manual/advanced/analysis/advanced.en.md | 2 +- .../manual/advanced/analysis/advanced.zh.md | 77 +- .../manual/advanced/analysis/drill-down.zh.md | 35 +- .../manual/advanced/analysis/export.zh.md | 93 +- .../manual/advanced/analysis/header.en.md | 5 - .../manual/advanced/analysis/header.zh.md | 80 - .../advanced/analysis/introduction.en.md | 5 + .../advanced/analysis/introduction.zh.md | 40 + .../manual/advanced/analysis/pagination.zh.md | 72 +- .../manual/advanced/analysis/switcher.zh.md | 26 +- .../manual/advanced/custom/cell-align.en.md | 18 +- .../manual/advanced/custom/cell-align.zh.md | 24 +- .../manual/advanced/custom/cell-size.en.md | 2 +- .../manual/advanced/custom/cell-size.zh.md | 6 +- .../advanced/custom/custom-header.en.md | 4 +- .../advanced/custom/custom-header.zh.md | 6 +- .../manual/advanced/custom/custom-icon.zh.md | 4 +- .../manual/advanced/custom/custom-order.en.md | 2 +- .../manual/advanced/custom/custom-order.zh.md | 41 +- .../docs/manual/advanced/get-cell-data.zh.md | 18 +- .../docs/manual/advanced/get-instance.zh.md | 2 +- .../manual/advanced/interaction/basic.en.md | 2 +- .../manual/advanced/interaction/basic.zh.md | 26 +- .../manual/advanced/interaction/custom.zh.md | 2 +- .../advanced/interaction/hide-columns.zh.md | 12 +- .../manual/advanced/interaction/scroll.zh.md | 2 +- .../{analysis => sheet}/editable-mode.en.md | 2 +- .../{analysis => sheet}/editable-mode.zh.md | 11 +- .../{analysis => sheet}/strategy.en.md | 4 +- .../{analysis => sheet}/strategy.zh.md | 18 +- .../manual/advanced/{analysis => }/vue.en.md | 0 .../manual/advanced/{analysis => }/vue.zh.md | 6 +- .../manual/basic/analysis/editable-mode.zh.md | 2 +- .../manual/basic/analysis/pagination.zh.md | 75 - s2-site/docs/manual/basic/conditions.en.md | 10 +- s2-site/docs/manual/basic/conditions.zh.md | 10 +- s2-site/docs/manual/basic/pagination.en.md | 5 + s2-site/docs/manual/basic/pagination.zh.md | 15 + .../manual/basic/sheet-type/pivot-mode.en.md | 2 +- .../manual/basic/sheet-type/pivot-mode.zh.md | 2 +- .../manual/basic/sheet-type/table-mode.en.md | 2 +- .../manual/basic/sheet-type/table-mode.zh.md | 2 +- s2-site/docs/manual/basic/sort/basic.en.md | 4 +- s2-site/docs/manual/basic/sort/basic.zh.md | 4 +- s2-site/docs/manual/basic/sort/group.zh.md | 26 +- s2-site/docs/manual/basic/theme.en.md | 10 +- s2-site/docs/manual/basic/theme.zh.md | 10 +- s2-site/docs/manual/basic/tooltip.en.md | 10 +- s2-site/docs/manual/basic/tooltip.zh.md | 87 +- s2-site/docs/manual/basic/totals.en.md | 6 +- s2-site/docs/manual/basic/totals.zh.md | 2 +- s2-site/docs/manual/contribution.zh.md | 6 +- .../extended-reading/layout/table.zh.md | 2 +- .../manual/extended-reading/performance.zh.md | 4 +- s2-site/docs/manual/faq.en.md | 10 +- s2-site/docs/manual/faq.zh.md | 32 +- s2-site/docs/manual/getting-started.en.md | 6 +- s2-site/docs/manual/getting-started.zh.md | 91 +- s2-site/docs/manual/introduction.zh.md | 8 +- s2-site/docs/manual/migration-v2.zh.md | 462 ++++-- .../examples/analysis/sort/demo/advanced.tsx | 2 +- .../analysis/sort/demo/group-sort-base.ts | 2 +- .../analysis/sort/demo/group-sort.tsx | 8 +- .../analysis/sort/demo/table-sort.tsx | 2 +- s2-site/examples/basic/pivot/API.en.md | 4 +- s2-site/examples/basic/pivot/API.zh.md | 4 +- s2-site/examples/basic/table/API.en.md | 4 +- s2-site/examples/basic/table/API.zh.md | 4 +- s2-site/examples/case/art/demo/lost-text.tsx | 2 +- s2-site/examples/case/art/demo/mosaic.tsx | 2 +- .../case/art/demo/time-spend-abstract.tsx | 2 +- .../comparison/demo/measure-comparison.tsx | 2 +- .../demo/multiple-people-comparison.tsx | 2 +- .../case/comparison/demo/philosophers.tsx | 3 +- .../case/comparison/demo/time-spend.tsx | 2 +- .../examples/case/data-preview/demo/excel.tsx | 2 +- .../examples/case/data-preview/demo/house.tsx | 14 +- .../examples/case/data-preview/demo/index.tsx | 2 +- .../examples/case/kpi-strategy/demo/basic.tsx | 2 +- .../case/kpi-strategy/demo/covid-trend.tsx | 2 +- .../case/performance-compare/demo/basic.tsx | 2 +- .../case/proportion/demo/group-drill-down.tsx | 2 +- .../demo/single-population-proportion.tsx | 2 +- .../examples/custom/custom-dataset/API.en.md | 2 +- .../examples/custom/custom-dataset/API.zh.md | 2 +- .../demo/custom-header-action-icon.ts | 2 +- .../custom-order/demo/custom-order-base.ts | 131 ++ .../custom/custom-order/demo/custom-order.tsx | 32 +- .../custom/custom-order/demo/meta.json | 10 +- .../interaction/advanced/demo/intercepts.ts | 4 +- .../advanced/demo/pivot-hide-columns.ts | 2 +- .../advanced/demo/table-hide-columns.ts | 8 +- .../custom/demo/disable-context-menu.ts | 4 +- .../custom/demo/row-col-hover-tooltip.ts | 4 +- .../layout/multi-line-text/demo/pivot.ts | 2 +- .../layout/multi-line-text/demo/table.ts | 2 +- .../drill-down/demo/basic-panel.tsx | 15 +- .../drill-down/demo/for-pivot.tsx | 6 +- .../export/demo/export-strategy.tsx | 155 ++ .../react-component/export/demo/export.tsx | 73 +- .../react-component/export/demo/meta.json | 9 + .../examples/react-component/header/API.en.md | 6 - .../examples/react-component/header/API.zh.md | 6 - .../react-component/header/demo/default.tsx | 78 - .../react-component/header/demo/meta.json | 16 - .../react-component/header/index.en.md | 4 - .../react-component/header/index.zh.md | 4 - .../react-component/pagination/demo/pivot.tsx | 46 +- .../react-component/pagination/demo/table.tsx | 61 +- .../react-component/sheet/demo/pivot.tsx | 2 +- .../sheet/demo/strategy-mini-chart.tsx | 2 +- .../react-component/sheet/demo/strategy.tsx | 2 +- .../react-component/sheet/demo/table.tsx | 2 +- .../react-component/switcher/demo/meta.json | 8 - .../switcher/demo/pivot-header.tsx | 2 +- .../switcher/demo/pivot-with-children.tsx | 10 +- .../react-component/switcher/demo/pivot.tsx | 10 +- .../switcher/demo/pure-switcher.tsx | 38 +- .../react-component/switcher/demo/table.tsx | 10 +- .../react-component/tooltip/API.en.md | 2 +- .../react-component/tooltip/API.zh.md | 2 +- .../react-component/tooltip/demo/basic.tsx | 2 +- .../demo/custom-click-show-tooltip.tsx | 10 +- .../tooltip/demo/custom-content-base.ts | 4 +- .../tooltip/demo/custom-content-react.tsx | 2 +- .../tooltip/demo/custom-description.tsx | 2 +- .../demo/custom-hover-show-tooltip.tsx | 10 +- .../tooltip/demo/custom-operation.tsx | 14 +- .../tooltip/demo/custom-show-tooltip.tsx | 15 +- .../tooltip/demo/custom-tooltip.tsx | 2 +- .../tooltip/demo/operation.tsx | 13 +- s2-site/examples/theme/custom/API.en.md | 2 +- s2-site/examples/theme/custom/API.zh.md | 2 +- .../custom/demo/custom-generate-palette.tsx | 2 +- .../custom/demo/custom-manual-palette.tsx | 2 +- .../demo/custom-transparent-background.ts | 6 +- s2-site/examples/theme/default/API.en.md | 2 +- s2-site/examples/theme/default/API.zh.md | 2 +- s2-site/package.json | 5 +- s2-site/playground/sheet-component/index.tsx | 27 +- scripts/api-extractor.json | 2 - tsconfig.base.json | 11 +- 499 files changed, 7161 insertions(+), 6146 deletions(-) create mode 100644 build.config.base.mjs rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/__snapshots__/drill-down-spec.ts.snap (100%) rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/__snapshots__/options-spec.ts.snap (100%) rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/classnames-spec.ts (79%) rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/drill-down-spec.ts (93%) rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/options-spec.ts (84%) rename packages/{s2-shared/__tests__/unit => s2-core/__tests__/unit/shared}/utils/resize-spec.ts (90%) create mode 100644 packages/s2-core/src/facet/layout/index.ts rename packages/{s2-shared/src => s2-core/src/shared}/constant/classnames.ts (70%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/i18n/en_US.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/i18n/index.ts (76%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/i18n/ru_RU.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/i18n/zh_CN.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/index.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/option.ts (84%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/resize.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/sort.ts (90%) rename packages/{s2-shared/src => s2-core/src/shared}/constant/theme.ts (71%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/calendar-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/col-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/dot-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/location-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/row-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/search-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/sort-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/switcher-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/text-icon.svg (100%) rename packages/{s2-shared/src => s2-core/src/shared}/icons/value-icon.svg (100%) create mode 100644 packages/s2-core/src/shared/index.ts rename packages/{s2-shared/src => s2-core/src/shared}/interface.ts (92%) rename packages/{s2-shared/src => s2-core/src/shared}/styles/drill-down.less (94%) rename packages/{s2-shared/src => s2-core/src/shared}/styles/theme/dark.less (100%) rename packages/{s2-shared/src => s2-core/src/shared}/styles/tooltip/index.less (98%) rename packages/{s2-shared/src => s2-core/src/shared}/styles/tooltip/operator.less (100%) rename packages/{s2-shared/src => s2-core/src/shared}/styles/variables.less (84%) rename packages/{s2-shared/src => s2-core/src/shared}/utils/classnames.ts (100%) rename packages/{s2-shared/src => s2-core/src/shared}/utils/drill-down.ts (95%) create mode 100644 packages/s2-core/src/shared/utils/index.ts rename packages/{s2-shared/src => s2-core/src/shared}/utils/options.ts (72%) rename packages/{s2-shared/src => s2-core/src/shared}/utils/resize.ts (98%) create mode 100644 packages/s2-core/src/utils/cell/index.ts create mode 100644 packages/s2-core/src/utils/cell/merged-cell.ts rename packages/{s2-react/src/components/export => s2-core/src/utils/export/copy}/strategy-copy.ts (91%) create mode 100644 packages/s2-core/tsconfig.build.json delete mode 100644 packages/s2-core/tsconfig.declaration.json create mode 100644 packages/s2-react-components/__tests__/__mocks__/svg.ts rename packages/{s2-react => s2-react-components}/__tests__/bugs/issue-1736-spec.tsx (58%) create mode 100644 packages/s2-react-components/__tests__/unit/components/advanced-sort/__snapshots__/advanced-sort-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/advanced-sort/__snapshots__/custom-sort-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/advanced-sort/advanced-sort-spec.tsx create mode 100644 packages/s2-react-components/__tests__/unit/components/advanced-sort/custom-sort-spec.tsx create mode 100644 packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/drill-down/drill-down-spec.tsx create mode 100644 packages/s2-react-components/__tests__/unit/components/export/__snapshots__/export-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/export/export-spec.tsx rename packages/s2-react-components/__tests__/unit/components/{config => }/frozen-panel/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/frozen-panel/frozen-input-number/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/frozen-panel/frozen-input-number/index-spec.tsx (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/frozen-panel/index-spec.tsx (100%) create mode 100644 packages/s2-react-components/__tests__/unit/components/switcher/__snapshots__/switcher-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/switcher/content/__snapshots__/index-spec.tsx.snap create mode 100644 packages/s2-react-components/__tests__/unit/components/switcher/content/index-spec.tsx create mode 100644 packages/s2-react-components/__tests__/unit/components/switcher/switcher-spec.tsx rename packages/{s2-react => s2-react-components}/__tests__/unit/components/switcher/util-spec.ts (97%) rename packages/s2-react-components/__tests__/unit/components/{config => }/text-align-panel/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/text-align-panel/index-spec.tsx (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/__snapshots__/utils-spec.ts.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/color-box/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/color-box/index-spec.tsx (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/color-picker-panel/__snapshots__/index-spec.tsx.snap (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/color-picker-panel/index-spec.tsx (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/hooks/useHistoryColorList-spec.ts (87%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/index-spec.tsx (100%) rename packages/s2-react-components/__tests__/unit/components/{config => }/theme-panel/utils-spec.ts (95%) delete mode 100644 packages/s2-react-components/__tests__/util/helpers.ts rename packages/{s2-react/src/components/header => s2-react-components/playground/Header}/index.less (93%) create mode 100644 packages/s2-react-components/playground/Header/index.tsx rename packages/{s2-react/src/components/advanced-sort/index.tsx => s2-react-components/src/components/advanced-sort/advanced-sort.tsx} (88%) rename packages/{s2-react => s2-react-components}/src/components/advanced-sort/custom-sort.tsx (84%) rename packages/{s2-react => s2-react-components}/src/components/advanced-sort/index.less (98%) create mode 100644 packages/s2-react-components/src/components/advanced-sort/index.ts create mode 100644 packages/s2-react-components/src/components/advanced-sort/interface.ts delete mode 100644 packages/s2-react-components/src/components/analysis/index.ts delete mode 100644 packages/s2-react-components/src/components/analysis/switcher/index.tsx create mode 100644 packages/s2-react-components/src/components/common/icons/index.less create mode 100644 packages/s2-react-components/src/components/common/icons/index.tsx create mode 100644 packages/s2-react-components/src/components/common/radio-group/index.ts rename packages/s2-react-components/src/components/common/radio-group/{index.tsx => radio-group.tsx} (100%) create mode 100644 packages/s2-react-components/src/components/common/reset-button/index.ts rename packages/s2-react-components/src/components/common/reset-button/{index.tsx => reset-button.tsx} (100%) create mode 100644 packages/s2-react-components/src/components/common/reset-group/index.ts rename packages/s2-react-components/src/components/common/reset-group/{index.tsx => reset-group.tsx} (100%) create mode 100644 packages/s2-react-components/src/components/common/tooltip-wrapper/index.ts rename packages/s2-react-components/src/components/common/tooltip-wrapper/{index.tsx => tooltip-wrapper.tsx} (100%) delete mode 100644 packages/s2-react-components/src/components/config/index.ts rename packages/{s2-react/src/components/drill-down/index.tsx => s2-react-components/src/components/drill-down/drill-down.tsx} (72%) create mode 100644 packages/s2-react-components/src/components/drill-down/index.less create mode 100644 packages/s2-react-components/src/components/drill-down/index.ts create mode 100644 packages/s2-react-components/src/components/drill-down/interface.ts rename packages/{s2-react/src/components/export/index.tsx => s2-react-components/src/components/export/export.tsx} (71%) create mode 100644 packages/s2-react-components/src/components/export/index.ts create mode 100644 packages/s2-react-components/src/components/export/interface.ts create mode 100644 packages/s2-react-components/src/components/export/strategy-export.tsx rename packages/s2-react-components/src/components/{config => }/frozen-panel/frozen-input-number/index.tsx (100%) rename packages/s2-react-components/src/components/{config => }/frozen-panel/frozen-input-number/interface.ts (100%) rename packages/s2-react-components/src/components/{config/frozen-panel/index.tsx => frozen-panel/frozen-panel.tsx} (98%) rename packages/s2-react-components/src/components/{config => }/frozen-panel/index.less (100%) create mode 100644 packages/s2-react-components/src/components/frozen-panel/index.ts rename packages/s2-react-components/src/components/{config => }/frozen-panel/interface.ts (91%) rename packages/{s2-react => s2-react-components}/src/components/switcher/constant.ts (100%) rename packages/{s2-react => s2-react-components}/src/components/switcher/content/index.less (95%) rename packages/{s2-react => s2-react-components}/src/components/switcher/content/index.tsx (99%) rename packages/{s2-react => s2-react-components}/src/components/switcher/dimension/index.less (95%) rename packages/{s2-react => s2-react-components}/src/components/switcher/dimension/index.tsx (100%) rename packages/{s2-react => s2-react-components}/src/components/switcher/index.less (84%) create mode 100644 packages/s2-react-components/src/components/switcher/index.ts rename packages/{s2-react => s2-react-components}/src/components/switcher/interface.ts (96%) rename packages/{s2-react => s2-react-components}/src/components/switcher/item/index.less (95%) rename packages/{s2-react => s2-react-components}/src/components/switcher/item/index.tsx (100%) rename packages/{s2-react => s2-react-components}/src/components/switcher/item/single-item.tsx (100%) rename packages/{s2-react/src/components/switcher/index.tsx => s2-react-components/src/components/switcher/switcher.tsx} (86%) rename packages/{s2-react => s2-react-components}/src/components/switcher/util.ts (97%) rename packages/s2-react-components/src/components/{config => }/text-align-panel/icons.tsx (99%) rename packages/s2-react-components/src/components/{config => }/text-align-panel/index.less (100%) create mode 100644 packages/s2-react-components/src/components/text-align-panel/index.ts rename packages/s2-react-components/src/components/{config => }/text-align-panel/interface.ts (86%) rename packages/s2-react-components/src/components/{config/text-align-panel/index.tsx => text-align-panel/text-align-panel.tsx} (94%) rename packages/s2-react-components/src/components/{config => }/text-align-panel/utils.ts (95%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-box/index.less (100%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-box/index.tsx (100%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-box/interface.ts (100%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-picker-panel/index.less (100%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-picker-panel/index.tsx (96%) rename packages/s2-react-components/src/components/{config => }/theme-panel/color-picker-panel/interface.ts (100%) rename packages/s2-react-components/src/components/{config => }/theme-panel/hooks/useHistoryColorList.ts (96%) rename packages/s2-react-components/src/components/{config => }/theme-panel/icons.tsx (99%) rename packages/s2-react-components/src/components/{config => }/theme-panel/index.less (100%) create mode 100644 packages/s2-react-components/src/components/theme-panel/index.ts rename packages/s2-react-components/src/components/{config => }/theme-panel/interface.ts (90%) rename packages/s2-react-components/src/components/{config/theme-panel/index.tsx => theme-panel/theme-panel.tsx} (97%) rename packages/s2-react-components/src/components/{config => }/theme-panel/utils.ts (99%) create mode 100644 packages/s2-react-components/tsconfig.build.json delete mode 100644 packages/s2-react-components/tsconfig.declaration.json create mode 100644 packages/s2-react/__tests__/spreadsheet/__snapshots__/pagination-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/advanced-sort/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/advanced-sort/index-spec.tsx delete mode 100644 packages/s2-react/__tests__/unit/components/drill-down/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/drill-down/index-spec.tsx delete mode 100644 packages/s2-react/__tests__/unit/components/export/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/export/index-spec.tsx delete mode 100644 packages/s2-react/__tests__/unit/components/header/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/header/index-spec.tsx delete mode 100644 packages/s2-react/__tests__/unit/components/pagination/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/pagination/index-spec.tsx delete mode 100644 packages/s2-react/__tests__/unit/components/switcher/__snapshots__/index-spec.tsx.snap delete mode 100644 packages/s2-react/__tests__/unit/components/switcher/headerUtil-spec.ts delete mode 100644 packages/s2-react/__tests__/unit/components/switcher/index-spec.tsx rename packages/s2-react/{src/components/config-provider => playground/components/ConfigProvider}/index.tsx (83%) create mode 100644 packages/s2-react/playground/components/Header/index.less create mode 100644 packages/s2-react/playground/components/Header/index.tsx delete mode 100644 packages/s2-react/src/components/header/index.tsx delete mode 100644 packages/s2-react/src/components/icons/index.less delete mode 100644 packages/s2-react/src/components/icons/index.tsx delete mode 100644 packages/s2-react/src/components/pagination/index.tsx delete mode 100644 packages/s2-react/src/components/switcher/header.tsx delete mode 100644 packages/s2-react/src/components/switcher/headerUtil.ts delete mode 100644 packages/s2-react/src/hooks/usePrevious.ts create mode 100644 packages/s2-react/tsconfig.build.json delete mode 100644 packages/s2-react/tsconfig.declaration.json delete mode 100644 packages/s2-shared/__tests__/setup.js delete mode 100644 packages/s2-shared/__tests__/util/helpers.ts delete mode 100644 packages/s2-shared/jest.config.js delete mode 100644 packages/s2-shared/package.json delete mode 100644 packages/s2-shared/src/index.ts delete mode 100644 packages/s2-shared/src/utils/theme.ts delete mode 100644 packages/s2-shared/tsconfig.declaration.json delete mode 100644 packages/s2-shared/tsconfig.json create mode 100644 packages/s2-vue/tsconfig.build.json delete mode 100644 packages/s2-vue/tsconfig.declaration.json delete mode 100644 s2-site/docs/api/components/header.en.md delete mode 100644 s2-site/docs/api/components/header.zh.md rename s2-site/docs/api/general/{S2DataConfig.en.md => s2-data-config.en.md} (99%) rename s2-site/docs/api/general/{S2DataConfig.zh.md => s2-data-config.zh.md} (99%) rename s2-site/docs/api/general/{S2Event.en.md => s2-event.en.md} (100%) rename s2-site/docs/api/general/{S2Event.zh.md => s2-event.zh.md} (99%) rename s2-site/docs/api/general/{S2Options.en.md => s2-options.en.md} (100%) rename s2-site/docs/api/general/{S2Options.zh.md => s2-options.zh.md} (96%) rename s2-site/docs/api/general/{S2Theme.en.md => s2-theme.en.md} (100%) rename s2-site/docs/api/general/{S2Theme.zh.md => s2-theme.zh.md} (100%) delete mode 100644 s2-site/docs/common/header.en.md delete mode 100644 s2-site/docs/common/header.zh.md create mode 100644 s2-site/docs/common/install.en.md create mode 100644 s2-site/docs/common/install.zh.md delete mode 100644 s2-site/docs/manual/advanced/analysis/header.en.md delete mode 100644 s2-site/docs/manual/advanced/analysis/header.zh.md create mode 100644 s2-site/docs/manual/advanced/analysis/introduction.en.md create mode 100644 s2-site/docs/manual/advanced/analysis/introduction.zh.md rename s2-site/docs/manual/advanced/{analysis => sheet}/editable-mode.en.md (98%) rename s2-site/docs/manual/advanced/{analysis => sheet}/editable-mode.zh.md (92%) rename s2-site/docs/manual/advanced/{analysis => sheet}/strategy.en.md (98%) rename s2-site/docs/manual/advanced/{analysis => sheet}/strategy.zh.md (88%) rename s2-site/docs/manual/advanced/{analysis => }/vue.en.md (100%) rename s2-site/docs/manual/advanced/{analysis => }/vue.zh.md (95%) delete mode 100644 s2-site/docs/manual/basic/analysis/pagination.zh.md create mode 100644 s2-site/docs/manual/basic/pagination.en.md create mode 100644 s2-site/docs/manual/basic/pagination.zh.md create mode 100644 s2-site/examples/custom/custom-order/demo/custom-order-base.ts create mode 100644 s2-site/examples/react-component/export/demo/export-strategy.tsx delete mode 100644 s2-site/examples/react-component/header/API.en.md delete mode 100644 s2-site/examples/react-component/header/API.zh.md delete mode 100644 s2-site/examples/react-component/header/demo/default.tsx delete mode 100644 s2-site/examples/react-component/header/demo/meta.json delete mode 100644 s2-site/examples/react-component/header/index.en.md delete mode 100644 s2-site/examples/react-component/header/index.zh.md diff --git a/.eslintrc.js b/.eslintrc.js index d0205f56a7..a0d0701bbe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -43,7 +43,12 @@ module.exports = { tabWidth: 2, trailingComma: 'all', printWidth: 80, + arrowParens: 'always', proseWrap: 'never', + htmlWhitespaceSensitivity: 'css', + embeddedLanguageFormatting: 'auto', + singleAttributePerLine: false, + bracketSpacing: true, overrides: [ { files: '.eslintrc', options: { parser: 'json' } }, { files: '.prettierrc', options: { parser: 'json' } }, @@ -57,7 +62,7 @@ module.exports = { ], 'import/no-duplicates': [2, { considerQueryString: true }], 'import/no-deprecated': 1, - 'import/no-cycle': 1, + 'import/no-cycle': 2, 'import/order': [ 2, { diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 000f900171..93cca60d9f 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -54,6 +54,9 @@ jobs: - name: Install dependencies run: pnpm bootstrap:ci + - name: Build doctor + run: pnpm build:doctor + - name: Build run: pnpm build diff --git a/.github/workflows/compressed-size.yml b/.github/workflows/compressed-size.yml index fe79eec36a..ff05016645 100644 --- a/.github/workflows/compressed-size.yml +++ b/.github/workflows/compressed-size.yml @@ -30,6 +30,6 @@ jobs: - uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./packages/{s2-core,s2-react,s2-vue}/dist/**/*.{js,css}" - build-script: "build:umd" + pattern: "./packages/{s2-core,s2-react,s2-react-components,s2-vue}/dist/**/*.{js,css}" + build-script: "build" clean-script: "clean" diff --git a/.gitignore b/.gitignore index 9936a09d18..2c7368fef0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ packages/s2-*/dist/ packages/s2-*/temp/ packages/s2-*/coverage/ packages/s2-*/stats.html +packages/**/*.css .swc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d65dbc444b..891e15c6c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,11 @@ "我代码水平不行", "会不会受到鄙视?", "会不会不太好?", 放心,不存在的! -我们欢迎任何形式的贡献,不管是一个**错别字的修改**,还是**一次友好的建议**,不管是通过提交 [Issue](https://github.com/antvis/S2/issues/new/choose), 还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是一次钉钉群的讨论,参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。 +我们欢迎任何形式的贡献,不管是一个**错别字的修改**,还是**一次友好的建议**,不管是通过提交 [Issue](https://github.com/antvis/S2/issues/new/choose), 还是一个帅气 [pull request](https://github.com/antvis/S2/pulls), 亦或是参与 [discussions](https://github.com/antvis/S2/discussions) 的讨论。 + +这是一个开源项目,我们也有繁忙的业务要做,是用自己的业余时间在维护,为爱发电,精力有限,所以有时候 issue 响应速度不是那么及时。 + +如果你遇到了问题,或者对 Issues 和 Discussions 列表的问题感兴趣,可以直接认领并尝试修复,帮助 S2 变得更好,期待在 [贡献者列表](https://github.com/antvis/S2/graphs/contributors) 里看见你的头像。 ## 分支管理 diff --git a/README.en-US.md b/README.en-US.md index 95392e2148..9623c6c970 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -30,7 +30,7 @@ A practical visualization library for tabular analysis.

- npm bundle size + npm bundle size GitHub discussions @@ -77,9 +77,9 @@ demo components and expansion capabilities, it allows developers to use it quick ## 📦 Installation ```bash -$ npm install @antv/s2@next --save -# yarn add @antv/s2@next -# pnpm add @antv/s2@next +$ npm install @antv/s2 --save +# yarn add @antv/s2 +# pnpm add @antv/s2 ``` ## 🔨 Getting Started @@ -208,11 +208,13 @@ bootstrap() ### 📦 Packages -| Package | Latest | Beta | Alpha | Next | Size | Download | -| - | - | - | - | - | - | - | -| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | -| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | -| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | +| Package | Latest | Next | Size | Download | +| - | - | - | - | - | +| -------- | ------ | --------- | ---------- | ------ | +| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg?logo=npm) | +| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg?logo=npm) | +| [@antv/s2-react-components](https://github.com/antvis/S2/tree/next/packages/s2-react-components) | ![latest](https://img.shields.io/npm/v/@antv/s2-react-components/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react-components/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react-components@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react-components.svg?logo=npm) | +| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg?logo=npm) | ### 🖥️ Browser Compatibility diff --git a/README.md b/README.md index ebb7941e60..677a3404f0 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@

- npm bundle size + npm bundle size GitHub discussions @@ -73,9 +73,9 @@ S2 是 AntV 在多维交叉分析表格领域的解决方案,完全基于数 ## 📦 安装 ```bash -$ npm install @antv/s2@next --save -# yarn add @antv/s2@next -# pnpm add @antv/s2@next +$ npm install @antv/s2 --save +# yarn add @antv/s2 +# pnpm add @antv/s2 ``` ## 🔨 使用 @@ -204,11 +204,13 @@ bootstrap() ### 📦 版本 -| Package | Latest | Beta | Alpha | Next | Size | Download | -| - | - | - | - | - | - | - | -| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | -| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | -| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | +| Package | Latest | Next | Size | Download | +| - | - | - | - | - | +| -------- | ------ | --------- | ---------- | ------ | +| [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg?logo=npm) | +| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg?logo=npm) | +| [@antv/s2-react-components](https://github.com/antvis/S2/tree/next/packages/s2-react-components) | ![latest](https://img.shields.io/npm/v/@antv/s2-react-components/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-react-components/next.svg?logo=npm)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react-components@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react-components.svg?logo=npm) | +| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg?logo=npm) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg?logo=npm) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg?logo=npm) | ### 🖥️ 兼容环境 diff --git a/build.config.base.mjs b/build.config.base.mjs new file mode 100644 index 0000000000..a2a703a47b --- /dev/null +++ b/build.config.base.mjs @@ -0,0 +1,145 @@ +/* eslint-disable max-lines-per-function */ +/* eslint-disable import/order */ +import { viteCommonjs } from '@originjs/vite-plugin-commonjs'; +import { toLower } from 'lodash'; +import path from 'path'; +import peerDepsExternal from 'rollup-plugin-peer-deps-external'; +import { visualizer } from 'rollup-plugin-visualizer'; + +export const getBaseConfig = () => { + const entry = './src/index.ts'; + + const OUT_DIR_NAME_MAP = { + es: 'esm', + cjs: 'lib', + umd: 'dist', + }; + + const format = process.env.FORMAT; + const isAnalysisMode = process.env.ANALYSIS; + const isDevMode = process.env.PLAYGROUND; + const outDir = OUT_DIR_NAME_MAP[format]; + const isUMD = format === 'umd'; + const isESM = format === 'es'; + + const define = { + 'process.env.NODE_ENV': JSON.stringify( + isDevMode ? 'development' : 'production', + ), + }; + + const resolve = { + mainFields: ['src', 'module', 'main'], + alias: [], + }; + + if (isDevMode) { + // 防止开发模式下直接加载 s2-core 中的主题 less + resolve.alias.push( + ...[ + { + find: /^(.*)\/theme\/(.*)\.less$/, + replacement: '$1/theme/$2.less?inline', + }, + { + find: /^@antv\/s2$/, + replacement: path.join(__dirname, './packages/s2-core/src'), + }, + ], + ); + } + + const getViteConfig = ( + { port, name, libName, plugins } = { + port: 3001, + plugins: [], + }, + ) => { + const filename = isUMD ? `${toLower(name || libName)}.min` : '[name]'; + + return { + server: { + port, + hmr: true, + }, + + resolve, + + define: { + 'process.env.NODE_ENV': JSON.stringify( + isDevMode ? 'development' : 'production', + ), + }, + + plugins: [ + peerDepsExternal(), + !isDevMode && viteCommonjs(), + isAnalysisMode && + visualizer({ + open: true, + gzipSize: true, + brotliSize: true, + }), + ...plugins, + ].filter(Boolean), + + css: { + preprocessorOptions: { + less: { + javascriptEnabled: true, + }, + }, + modules: { + /** + * 样式小驼峰转化 + * css: goods-list => tsx: goodsList + */ + localsConvention: 'camelCase', + }, + }, + + build: { + target: 'es2015', + minify: isUMD ? 'esbuild' : false, + sourcemap: true, + lib: { + name: libName, + entry, + formats: [format], + }, + outDir, + rollupOptions: { + output: { + dir: outDir, + entryFileNames: `${filename}.js`, + assetFileNames: `${filename}.[ext]`, + globals: { + vue: 'Vue', + react: 'React', + 'react-dom': 'ReactDOM', + '@antv/s2': 'S2', + '@antv/s2-react': 'S2React', + lodash: '_', + antd: 'antd', + 'ant-design-vue': 'antd', + }, + }, + }, + }, + }; + }; + + return { + entry, + getViteConfig, + define, + format, + resolve, + isAnalysisMode, + outDir, + OUT_DIR_NAME_MAP, + isDevMode, + isUMD, + isESM, + }; +}; diff --git a/jest.config.base.js b/jest.config.base.js index 7a9905c693..38232a0aa7 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -43,16 +43,16 @@ module.exports = { '\\.svg$': 'jest-raw-loader', }, moduleNameMapper: { + '\\.svg$': '/__tests__/__mocks__/svg.ts', '^@/(.*)': '/src/$1', '^tests/(.*)': '/__tests__/$1', '^@antv/s2$': path.join(__dirname, 'packages/s2-core/src'), - '^@antv/s2-shared$': path.join(__dirname, 'packages/s2-shared/src'), + '^@antv/s2/esm/(.*)$': path.join(__dirname, 'packages/s2-core/src/$1'), '^@antv/s2-react$': path.join(__dirname, 'packages/s2-react/src'), '^@antv/s2-react-components$': path.join( __dirname, 'packages/s2-react-components/src', ), - '\\.svg$': '/__tests__/__mocks__/svg.ts', /* ignore module query: foo.less?a=1 -> foo.less */ '(.+)\\.(.+)\\?(.*)$': '$1.$2', }, diff --git a/package.json b/package.json index f03c70a303..32bbc30fea 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "url": "https://github.com/antvis/S2.git" }, "license": "MIT", + "files": [], "scripts": { "preinstall": "npx only-allow pnpm", "bootstrap": "pnpm install", @@ -32,6 +33,7 @@ "core:start": "pnpm --filter @antv/s2 start", "core:watch": " pnpm --filter @antv/s2 watch", "core:build": "pnpm --filter @antv/s2 build", + "core:build-esm": "pnpm --filter @antv/s2 build:esm", "core:test": "pnpm --filter @antv/s2 test", "core:test-coverage": "pnpm --filter @antv/s2 test:coverage", "core:sync-event": "pnpm --filter @antv/s2 sync-event", @@ -55,7 +57,7 @@ "build:umd": "pnpm -r --filter './packages/*' --stream build:umd", "build:size-limit": "pnpm -r --filter './packages/*' --stream build:size-limit", "build:size-limit-json": "pnpm -r --filter './packages/*' --stream build:size-limit-json", - "release": "pnpm -r --filter !@antv/s2-shared --filter !@antv/s2-site --workspace-concurrency=1 exec npx --no-install semantic-release", + "release": "pnpm -r --filter !@antv/s2-site --workspace-concurrency=1 exec npx --no-install semantic-release", "release:preview": "pnpm release --dry-run --no-ci", "release:bump-version": "node ./scripts/bump-version.js", "test": "pnpm -r --filter './packages/*' --stream test", @@ -77,7 +79,6 @@ "site:build": "NODE_OPTIONS='--max-old-space-size=4096' pnpm --filter @antv/s2-site build", "site:preview": "pnpm --filter @antv/s2-site preview", "site:deploy": "pnpm --filter @antv/s2-site deploy", - "share:test": "pnpm --filter @antv/s2-shared test", "format": "prettier . --write" }, "commitlint": { @@ -162,7 +163,7 @@ "jest-url-loader": "^0.1.0", "less": "^4.2.0", "lint-staged": "^15.2.5", - "lodash-es": "^4.17.21", + "lodash": "^4.17.21", "markdownlint-cli": "^0.41.0", "npm-run-all": "^4.1.5", "ora": "^8.0.1", diff --git a/packages/s2-core/README.en-US.md b/packages/s2-core/README.en-US.md index dfdd422fa8..bd7894d5a1 100644 --- a/packages/s2-core/README.en-US.md +++ b/packages/s2-core/README.en-US.md @@ -211,8 +211,8 @@ bootstrap() | Package | Latest | Beta | Alpha | Next | Size | Download | | - | - | - | - | - | - | - | | [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | -| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | -| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | +| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react/dist/s2-react.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | +| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue/dist/s2-vue.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | ## 👤 Author diff --git a/packages/s2-core/README.md b/packages/s2-core/README.md index c6dca6a56e..3c03e975aa 100644 --- a/packages/s2-core/README.md +++ b/packages/s2-core/README.md @@ -29,7 +29,7 @@

- npm bundle size + npm bundle size GitHub discussions @@ -207,8 +207,8 @@ bootstrap() | Package | Latest | Beta | Alpha | Next | Size | Download | | - | - | - | - | - | - | - | | [@antv/s2](https://github.com/antvis/S2/tree/next/packages/s2-core) | ![latest](https://img.shields.io/npm/v/@antv/s2/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2.svg) | -| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | -| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/index.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | +| [@antv/s2-react](https://github.com/antvis/S2/tree/next/packages/s2-react) | ![latest](https://img.shields.io/npm/v/@antv/s2-react/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-react/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-react/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-react/next.svg)| ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-react@latest/dist/s2-react.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-react.svg) | +| [@antv/s2-vue](https://github.com/antvis/S2/tree/next/packages/s2-vue) | ![latest](https://img.shields.io/npm/v/@antv/s2-vue/latest.svg) | ![beta](https://img.shields.io/npm/v/@antv/s2-vue/beta.svg) | ![alpha](https://img.shields.io/npm/v/@antv/s2-vue/alpha.svg) | ![next](https://img.shields.io/npm/v/@antv/s2-vue/next.svg) | ![size](https://img.badgesize.io/https:/unpkg.com/@antv/s2-vue@latest/dist/s2-vue.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) | ## 问题反馈 diff --git a/packages/s2-core/__tests__/setup.js b/packages/s2-core/__tests__/setup.js index 95ba1ba1bb..1f37195929 100644 --- a/packages/s2-core/__tests__/setup.js +++ b/packages/s2-core/__tests__/setup.js @@ -14,3 +14,5 @@ jest.mock('@/ui/hd-adapter', () => { }), }; }); + +jest.setTimeout(60 * 1000); diff --git a/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts b/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts index a1e069dd0e..d07288ceea 100644 --- a/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts +++ b/packages/s2-core/__tests__/unit/interaction/row-column-resize-spec.ts @@ -134,6 +134,22 @@ describe('Interaction Row Column Resize Tests', () => { return resizeInfo; }; + const createCells = () => { + const children = [ + createMockCellInfo('test-cell-a', { isLeaf: true }).getNode(), + createMockCellInfo('test-cell-b', { isLeaf: true }).getNode(), + ]; + + return [ + createMockCellInfo('test-row-cell-1', { + children, + }).mockCell, + createMockCellInfo('test-row-cell-2', { + children, + }).mockCell, + ]; + }; + beforeEach(() => { MockRootInteraction.mockClear(); @@ -167,14 +183,6 @@ describe('Interaction Row Column Resize Tests', () => { createMockCellInfo('test-col-cell-a').mockCell, createMockCellInfo('test-col-cell-b').mockCell, ]; - - // 模拟多选 - jest - .spyOn(Node, 'getAllLeaveNodes') - .mockImplementationOnce(() => [ - createMockCellInfo('test-cell-a').getNode(), - createMockCellInfo('test-cell-b').getNode(), - ]); }); test('should register events', () => { @@ -825,6 +833,9 @@ describe('Interaction Row Column Resize Tests', () => { }, }); + jest + .spyOn(s2.interaction, 'getActiveColCells') + .mockImplementationOnce(() => createCells()); jest .spyOn(s2.interaction, 'isSelectedState') .mockImplementationOnce(() => true); @@ -845,6 +856,9 @@ describe('Interaction Row Column Resize Tests', () => { }, }); + jest + .spyOn(s2.interaction, 'getActiveRowCells') + .mockImplementationOnce(() => createCells()); jest .spyOn(s2.interaction, 'isSelectedState') .mockImplementationOnce(() => true); @@ -858,10 +872,7 @@ describe('Interaction Row Column Resize Tests', () => { // 模拟多选 jest .spyOn(s2.interaction, 'getActiveRowCells') - .mockImplementationOnce(() => [ - createMockCellInfo('test-row-cell-1').mockCell, - createMockCellInfo('test-row-cell-2').mockCell, - ]); + .mockImplementationOnce(() => createCells()); jest .spyOn(s2.interaction, 'isSelectedState') .mockImplementationOnce(() => true); @@ -884,10 +895,7 @@ describe('Interaction Row Column Resize Tests', () => { // 模拟多选 jest .spyOn(s2.interaction, 'getActiveColCells') - .mockImplementationOnce(() => [ - createMockCellInfo('test-col-cell-1').mockCell, - createMockCellInfo('test-col-cell-2').mockCell, - ]); + .mockImplementationOnce(() => createCells()); jest .spyOn(s2.interaction, 'isSelectedState') .mockImplementationOnce(() => true); diff --git a/packages/s2-shared/__tests__/unit/utils/__snapshots__/drill-down-spec.ts.snap b/packages/s2-core/__tests__/unit/shared/utils/__snapshots__/drill-down-spec.ts.snap similarity index 100% rename from packages/s2-shared/__tests__/unit/utils/__snapshots__/drill-down-spec.ts.snap rename to packages/s2-core/__tests__/unit/shared/utils/__snapshots__/drill-down-spec.ts.snap diff --git a/packages/s2-shared/__tests__/unit/utils/__snapshots__/options-spec.ts.snap b/packages/s2-core/__tests__/unit/shared/utils/__snapshots__/options-spec.ts.snap similarity index 100% rename from packages/s2-shared/__tests__/unit/utils/__snapshots__/options-spec.ts.snap rename to packages/s2-core/__tests__/unit/shared/utils/__snapshots__/options-spec.ts.snap diff --git a/packages/s2-shared/__tests__/unit/utils/classnames-spec.ts b/packages/s2-core/__tests__/unit/shared/utils/classnames-spec.ts similarity index 79% rename from packages/s2-shared/__tests__/unit/utils/classnames-spec.ts rename to packages/s2-core/__tests__/unit/shared/utils/classnames-spec.ts index 8aaf270005..449817e2f7 100644 --- a/packages/s2-shared/__tests__/unit/utils/classnames-spec.ts +++ b/packages/s2-core/__tests__/unit/shared/utils/classnames-spec.ts @@ -1,4 +1,4 @@ -import { getStrategySheetTooltipClsName } from '../../../src/utils/classnames'; +import { getStrategySheetTooltipClsName } from '../../../../src/shared'; describe('classnames test', () => { test('#getStrategySheetTooltipClsName()', () => { diff --git a/packages/s2-shared/__tests__/unit/utils/drill-down-spec.ts b/packages/s2-core/__tests__/unit/shared/utils/drill-down-spec.ts similarity index 93% rename from packages/s2-shared/__tests__/unit/utils/drill-down-spec.ts rename to packages/s2-core/__tests__/unit/shared/utils/drill-down-spec.ts index e9bb7ae3a4..2c9c4fb2a0 100644 --- a/packages/s2-shared/__tests__/unit/utils/drill-down-spec.ts +++ b/packages/s2-core/__tests__/unit/shared/utils/drill-down-spec.ts @@ -1,20 +1,20 @@ import { - GEvent, - PivotDataSet, S2Event, Store, + type GEvent, type Node, + type PivotDataSet, type SpreadSheet, -} from '@antv/s2'; -import type { PartDrillDown } from '../../../src/interface'; +} from '../../../../src'; +import type { PartDrillDown } from '../../../../src/shared'; import { buildDrillDownOptions, defaultPartDrillDownDisplayCondition, getDrillDownCache, handleActionIconClick, handleDrillDown, -} from '../../../src/utils/drill-down'; -import { sleep } from '../../util/helpers'; +} from '../../../../src/shared'; +import { sleep } from '../../../util/helpers'; describe('drill-down test', () => { let s2: SpreadSheet; diff --git a/packages/s2-shared/__tests__/unit/utils/options-spec.ts b/packages/s2-core/__tests__/unit/shared/utils/options-spec.ts similarity index 84% rename from packages/s2-shared/__tests__/unit/utils/options-spec.ts rename to packages/s2-core/__tests__/unit/shared/utils/options-spec.ts index 909e1fe25b..22b1a80674 100644 --- a/packages/s2-shared/__tests__/unit/utils/options-spec.ts +++ b/packages/s2-core/__tests__/unit/shared/utils/options-spec.ts @@ -1,5 +1,5 @@ -import { type S2Options } from '@antv/s2'; -import { getBaseSheetComponentOptions } from '../../../src/utils/options'; +import type { S2Options } from '../../../../src'; +import { getBaseSheetComponentOptions } from '../../../../src/shared'; describe('Options Tests', () => { test('should get safety options', () => { diff --git a/packages/s2-shared/__tests__/unit/utils/resize-spec.ts b/packages/s2-core/__tests__/unit/shared/utils/resize-spec.ts similarity index 90% rename from packages/s2-shared/__tests__/unit/utils/resize-spec.ts rename to packages/s2-core/__tests__/unit/shared/utils/resize-spec.ts index 7097678881..5bb8e561bd 100644 --- a/packages/s2-shared/__tests__/unit/utils/resize-spec.ts +++ b/packages/s2-core/__tests__/unit/shared/utils/resize-spec.ts @@ -1,8 +1,5 @@ -import { PivotSheet } from '@antv/s2'; -import { - analyzeAdaptive, - createResizeObserver, -} from '../../../src/utils/resize'; +import { PivotSheet } from '../../../../src'; +import { analyzeAdaptive, createResizeObserver } from '../../../../src/shared'; describe('resize test', () => { test('#analyzeAdaptive()', () => { diff --git a/packages/s2-core/__tests__/unit/utils/interaction/__snapshots__/formatter-spec.ts.snap b/packages/s2-core/__tests__/unit/utils/interaction/__snapshots__/formatter-spec.ts.snap index a93b98952b..cfabafa96b 100644 --- a/packages/s2-core/__tests__/unit/utils/interaction/__snapshots__/formatter-spec.ts.snap +++ b/packages/s2-core/__tests__/unit/utils/interaction/__snapshots__/formatter-spec.ts.snap @@ -4,6 +4,7 @@ exports[`#getBaseCellData() should get correctly cell data 1`] = ` Object { "target": Object { "cellType": undefined, + "children": Array [], "colId": "0", "colIndex": 0, "cornerType": "", @@ -15,6 +16,7 @@ Object { "getStyle": [MockFunction], "hideInteractionShape": [MockFunction], "id": "test-a", + "isLeaf": false, "isTextOverflowing": [MockFunction], "level": 0, "parentNode": [Circular], @@ -42,11 +44,13 @@ Object { "y": 0, }, "viewMeta": Object { + "children": Array [], "colId": "0", "colIndex": 0, "cornerType": "", "field": "test-a", "id": "test-a", + "isLeaf": false, "level": 0, "rowIndex": 0, "spreadsheet": Object { diff --git a/packages/s2-core/__tests__/util/helpers.ts b/packages/s2-core/__tests__/util/helpers.ts index da05d2ce6f..bca47a2757 100644 --- a/packages/s2-core/__tests__/util/helpers.ts +++ b/packages/s2-core/__tests__/util/helpers.ts @@ -257,6 +257,8 @@ export const createMockCellInfo = ( level = 0, cornerType = '', cellType = undefined, + children = [], + isLeaf = false, }: Partial = {}, ) => { const mockCellViewMeta: Partial = { @@ -270,6 +272,8 @@ export const createMockCellInfo = ( cornerType, x: 0, y: 0, + children, + isLeaf, spreadsheet: { dataCfg: { meta: null, @@ -297,6 +301,8 @@ export const createMockCellInfo = ( 'colId', 'field', 'cornerType', + 'children', + 'isLeaf', ]); const mockCell = { ...mockCellViewMeta, diff --git a/packages/s2-core/package.json b/packages/s2-core/package.json index 4fc9953ca3..06ff5b6462 100644 --- a/packages/s2-core/package.json +++ b/packages/s2-core/package.json @@ -27,7 +27,7 @@ "dist/*" ], "main": "lib/index.js", - "unpkg": "dist/index.min.js", + "unpkg": "dist/s2.min.js", "module": "esm/index.js", "types": "esm/index.d.ts", "directories": { @@ -41,20 +41,18 @@ "README.md" ], "scripts": { - "build": "npm-run-all clean --parallel build:umd build:cjs build:esm build:dts", + "build": "npm-run-all clean --parallel build:cjs build:esm build:umd", "build:analysis": "cross-env FORMAT=esm ANALYSIS=true rollup -c rollup.config.mjs", - "build:cjs": "cross-env FORMAT=cjs rollup -c rollup.config.mjs", - "build:dts": "run-s dts:*", - "build:esm": "cross-env FORMAT=es rollup -c rollup.config.mjs", + "build:cjs": "tsc --module commonjs --outDir lib -p tsconfig.build.json && pnpm build:sync-assets lib/", + "build:esm": "tsc --module ESNext --outDir esm -p tsconfig.build.json && pnpm build:sync-assets esm/", "build:size-limit": "size-limit", "build:size-limit-json": "pnpm build:size-limit -- --json", + "build:sync-assets": "rsync -av --include='*/' --include='*.less' --include='*.svg' --exclude='*' src/", "build:umd": "cross-env FORMAT=umd rollup -c rollup.config.mjs", "clean": "rimraf lib esm dist temp", - "dts:build": "tsc -p tsconfig.declaration.json", - "dts:extract": "cross-env LIB=s2-core node ../../scripts/dts.js", "start": "pnpm test:live", "sync-event": "node ./scripts/sync-event.mjs", - "test": "jest --passWithNoTests --detectOpenHandles", + "test": "jest --passWithNoTests", "test:ci": "pnpm test -- --maxWorkers=3", "test:ci-coverage": "pnpm test:coverage --maxWorkers=3", "test:coverage": "pnpm test -- --coverage", @@ -90,12 +88,12 @@ }, "size-limit": [ { - "path": "./dist/index.min.js", + "path": "./dist/s2.min.js", "import": "{ createComponent }", - "limit": "200 kB" + "limit": "240 kB" }, { - "path": "./dist/style.min.css", + "path": "./dist/s2.min.css", "limit": "5 kB" } ], diff --git a/packages/s2-core/rollup.config.mjs b/packages/s2-core/rollup.config.mjs index c92c130032..1244e2952e 100644 --- a/packages/s2-core/rollup.config.mjs +++ b/packages/s2-core/rollup.config.mjs @@ -33,7 +33,6 @@ const plugins = [ peerDepsExternal(), alias({ entries: [ - { find: 'lodash', replacement: 'lodash-es' }, { find: /^(?.*).less\?inline$/, replacement: '$1.less', @@ -52,6 +51,10 @@ const plugins = [ tsconfigOverride: { outDir, include: ['src', '../../global.d.ts'], + compilerOptions: { + declaration: false, + useDefineForClassFields: false, + }, }, }), postcss({ @@ -62,7 +65,7 @@ const plugins = [ stylus: null, less: { javascriptEnabled: true }, }, - extract: `style${isUmdFormat ? '.min' : ''}.css`, + extract: `s2${isUmdFormat ? '.min' : ''}.css`, }), /** 主题变量 less 不需要 extract&inject */ postcss({ @@ -82,7 +85,7 @@ if (enableAnalysis) { } if (isUmdFormat) { - output.file = 'dist/index.min.js'; + output.file = 'dist/s2.min.js'; plugins.push(terser()); } else { output.dir = outDir; diff --git a/packages/s2-core/scripts/test-live.mjs b/packages/s2-core/scripts/test-live.mjs index a29a794bc4..ac491d2ea5 100644 --- a/packages/s2-core/scripts/test-live.mjs +++ b/packages/s2-core/scripts/test-live.mjs @@ -1,14 +1,14 @@ /* eslint-disable import/no-extraneous-dependencies */ import { execSync } from 'child_process'; -import ora from 'ora'; import { glob } from 'glob'; import { default as inquirer } from 'inquirer'; import { default as autoCompletePrompt } from 'inquirer-autocomplete-prompt'; +import ora from 'ora'; inquirer.registerPrompt('autocomplete', autoCompletePrompt); function run(path) { - const command = `cross-env DEBUG_MODE=1 npx jest ${path} --passWithNoTests --detectOpenHandles`; + const command = `cross-env DEBUG_MODE=1 npx jest ${path} --passWithNoTests`; const jestSpinner = ora(`[测试运行中]: ${command}`).start(); try { diff --git a/packages/s2-core/src/cell/merged-cell.ts b/packages/s2-core/src/cell/merged-cell.ts index 4c7ca45b8c..c344240eee 100644 --- a/packages/s2-core/src/cell/merged-cell.ts +++ b/packages/s2-core/src/cell/merged-cell.ts @@ -2,12 +2,12 @@ import { isEmpty } from 'lodash'; import { CellType } from '../common/constant'; import { CellBorderPosition, type ViewMeta } from '../common/interface'; import type { SpreadSheet } from '../sheet-type'; -import { getBorderPositionAndStyle } from '../utils'; -import { renderLine, renderPolygon } from '../utils/g-renders'; +import { getBorderPositionAndStyle } from '../utils/cell/cell'; import { getPolygonPoints, getRightAndBottomCells, -} from '../utils/interaction/merge-cell'; +} from '../utils/cell/merged-cell'; +import { renderLine, renderPolygon } from '../utils/g-renders'; import { drawCustomContent } from '../utils/text'; import { DataCell } from './data-cell'; diff --git a/packages/s2-core/src/facet/index.ts b/packages/s2-core/src/facet/index.ts index 080b7e7092..432f387965 100644 --- a/packages/s2-core/src/facet/index.ts +++ b/packages/s2-core/src/facet/index.ts @@ -1,7 +1,7 @@ -import { BaseFacet } from './base-facet'; -import { FrozenFacet } from './frozen-facet'; -import { PivotFacet } from './pivot-facet'; -import { TableFacet } from './table-facet'; +export { BaseFacet } from './base-facet'; +export { FrozenFacet } from './frozen-facet'; +export { PivotFacet } from './pivot-facet'; +export { TableFacet } from './table-facet'; export * from './header'; -export { BaseFacet, FrozenFacet, PivotFacet, TableFacet }; +export * from './layout'; diff --git a/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts b/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts index 53f32bf23c..eeae45bc32 100644 --- a/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts +++ b/packages/s2-core/src/facet/layout/build-gird-hierarchy.ts @@ -76,6 +76,8 @@ const buildTotalGridHierarchy = (params: GridHeaderParams) => { level: index, parentNode, query, + // eslint-disable-next-line @typescript-eslint/no-use-before-define + handler: buildGridHierarchy, }); }; @@ -130,18 +132,18 @@ const buildNormalGridHierarchy = (params: GridHeaderParams) => { level: index, parentNode, query, + // eslint-disable-next-line @typescript-eslint/no-use-before-define + handler: buildGridHierarchy, }); }; /** * Build grid hierarchy in rows or columns - * - * @param params */ -export const buildGridHierarchy = (params: GridHeaderParams) => { +export function buildGridHierarchy(params: GridHeaderParams) { if (params.parentNode.isTotals) { buildTotalGridHierarchy(params); } else { buildNormalGridHierarchy(params); } -}; +} diff --git a/packages/s2-core/src/facet/layout/build-header-hierarchy.ts b/packages/s2-core/src/facet/layout/build-header-hierarchy.ts index 1048f3e3ae..5a6732d0e3 100644 --- a/packages/s2-core/src/facet/layout/build-header-hierarchy.ts +++ b/packages/s2-core/src/facet/layout/build-header-hierarchy.ts @@ -5,17 +5,17 @@ import { type CustomTreeNode, } from '../../common'; import type { PivotDataSet } from '../../data-set'; -import { buildGridHierarchy } from '../layout/build-gird-hierarchy'; -import { buildCustomTreeHierarchy } from '../layout/build-row-custom-tree-hierarchy'; -import { buildRowTreeHierarchy } from '../layout/build-row-tree-hierarchy'; -import { buildTableHierarchy } from '../layout/build-table-hierarchy'; -import { Hierarchy } from '../layout/hierarchy'; +import { buildGridHierarchy } from './build-gird-hierarchy'; +import { buildCustomTreeHierarchy } from './build-row-custom-tree-hierarchy'; +import { buildRowTreeHierarchy } from './build-row-tree-hierarchy'; +import { buildTableHierarchy } from './build-table-hierarchy'; +import { Hierarchy } from './hierarchy'; import type { BuildHeaderParams, BuildHeaderResult, HeaderParams, -} from '../layout/interface'; -import { Node } from '../layout/node'; +} from './interface'; +import { Node } from './node'; const handleCustomTreeHierarchy = (params: HeaderParams) => { const { rootNode, hierarchy, fields, spreadsheet, isRowHeader } = params; diff --git a/packages/s2-core/src/facet/layout/build-table-hierarchy.ts b/packages/s2-core/src/facet/layout/build-table-hierarchy.ts index 7f2abfcacd..fd01a57540 100644 --- a/packages/s2-core/src/facet/layout/build-table-hierarchy.ts +++ b/packages/s2-core/src/facet/layout/build-table-hierarchy.ts @@ -1,5 +1,6 @@ import { SERIES_NUMBER_FIELD } from '../../common/constant'; import { generateHeaderNodes } from '../../utils/layout/generate-header-nodes'; +import { buildGridHierarchy } from './build-gird-hierarchy'; import type { HeaderParams } from './interface'; export const buildTableHierarchy = (params: HeaderParams) => { @@ -30,5 +31,6 @@ export const buildTableHierarchy = (params: HeaderParams) => { query: {}, addMeasureInTotalQuery: false, addTotalMeasureInTotal: false, + handler: buildGridHierarchy, }); }; diff --git a/packages/s2-core/src/facet/layout/index.ts b/packages/s2-core/src/facet/layout/index.ts new file mode 100644 index 0000000000..7a167beddb --- /dev/null +++ b/packages/s2-core/src/facet/layout/index.ts @@ -0,0 +1,4 @@ +export { buildGridHierarchy } from './build-gird-hierarchy'; +export { buildTableHierarchy } from './build-table-hierarchy'; +export { Hierarchy } from './hierarchy'; +export { Node } from './node'; diff --git a/packages/s2-core/src/facet/layout/interface.ts b/packages/s2-core/src/facet/layout/interface.ts index ec30f09da9..f458f5a266 100644 --- a/packages/s2-core/src/facet/layout/interface.ts +++ b/packages/s2-core/src/facet/layout/interface.ts @@ -43,6 +43,7 @@ export interface HeaderNodesParams extends GridHeaderParams { fieldValues: FieldValue[]; level: number; query: Record; + handler: (params: HeaderNodesParams) => void; } export interface HeaderParams { diff --git a/packages/s2-core/src/index.ts b/packages/s2-core/src/index.ts index fbb947e838..11823b302d 100644 --- a/packages/s2-core/src/index.ts +++ b/packages/s2-core/src/index.ts @@ -1,7 +1,5 @@ export { FederatedPointerEvent as GEvent } from '@antv/g'; -export { buildTableHierarchy } from './facet/layout/build-table-hierarchy'; -export { Hierarchy } from './facet/layout/hierarchy'; -export { Node } from './facet/layout/node'; + export { getTheme } from './theme'; export * from './cell'; @@ -9,6 +7,7 @@ export * from './common'; export * from './data-set'; export * from './facet'; export * from './interaction'; +export * from './shared'; export * from './sheet-type'; export * from './ui/tooltip'; export * from './utils'; diff --git a/packages/s2-shared/src/constant/classnames.ts b/packages/s2-core/src/shared/constant/classnames.ts similarity index 70% rename from packages/s2-shared/src/constant/classnames.ts rename to packages/s2-core/src/shared/constant/classnames.ts index 29b190edfb..5f42e2f6f4 100644 --- a/packages/s2-shared/src/constant/classnames.ts +++ b/packages/s2-core/src/shared/constant/classnames.ts @@ -1,4 +1,4 @@ -import { S2_PREFIX_CLS } from '@antv/s2'; +import { S2_PREFIX_CLS } from '../../common/constant/classnames'; export const DRILL_DOWN_PRE_CLASS = `${S2_PREFIX_CLS}-drill-down`; diff --git a/packages/s2-shared/src/constant/i18n/en_US.ts b/packages/s2-core/src/shared/constant/i18n/en_US.ts similarity index 100% rename from packages/s2-shared/src/constant/i18n/en_US.ts rename to packages/s2-core/src/shared/constant/i18n/en_US.ts diff --git a/packages/s2-shared/src/constant/i18n/index.ts b/packages/s2-core/src/shared/constant/i18n/index.ts similarity index 76% rename from packages/s2-shared/src/constant/i18n/index.ts rename to packages/s2-core/src/shared/constant/i18n/index.ts index 5ad2364fba..1ed7ac81db 100644 --- a/packages/s2-shared/src/constant/i18n/index.ts +++ b/packages/s2-core/src/shared/constant/i18n/index.ts @@ -1,4 +1,4 @@ -import type { LocaleType } from '@antv/s2'; +import type { LocaleType } from '../../../common/i18n'; import { EN_US } from './en_US'; import { RU } from './ru_RU'; import { ZH_CN } from './zh_CN'; diff --git a/packages/s2-shared/src/constant/i18n/ru_RU.ts b/packages/s2-core/src/shared/constant/i18n/ru_RU.ts similarity index 100% rename from packages/s2-shared/src/constant/i18n/ru_RU.ts rename to packages/s2-core/src/shared/constant/i18n/ru_RU.ts diff --git a/packages/s2-shared/src/constant/i18n/zh_CN.ts b/packages/s2-core/src/shared/constant/i18n/zh_CN.ts similarity index 100% rename from packages/s2-shared/src/constant/i18n/zh_CN.ts rename to packages/s2-core/src/shared/constant/i18n/zh_CN.ts diff --git a/packages/s2-shared/src/constant/index.ts b/packages/s2-core/src/shared/constant/index.ts similarity index 100% rename from packages/s2-shared/src/constant/index.ts rename to packages/s2-core/src/shared/constant/index.ts diff --git a/packages/s2-shared/src/constant/option.ts b/packages/s2-core/src/shared/constant/option.ts similarity index 84% rename from packages/s2-shared/src/constant/option.ts rename to packages/s2-core/src/shared/constant/option.ts index 8c4e359e48..98808b3be5 100644 --- a/packages/s2-shared/src/constant/option.ts +++ b/packages/s2-core/src/shared/constant/option.ts @@ -1,4 +1,4 @@ -import type { S2Options } from '@antv/s2'; +import type { S2Options } from '../../common'; export const SHEET_COMPONENT_DEFAULT_OPTIONS: S2Options = { tooltip: { diff --git a/packages/s2-shared/src/constant/resize.ts b/packages/s2-core/src/shared/constant/resize.ts similarity index 100% rename from packages/s2-shared/src/constant/resize.ts rename to packages/s2-core/src/shared/constant/resize.ts diff --git a/packages/s2-shared/src/constant/sort.ts b/packages/s2-core/src/shared/constant/sort.ts similarity index 90% rename from packages/s2-shared/src/constant/sort.ts rename to packages/s2-core/src/shared/constant/sort.ts index 8464aa5467..d8b92ce702 100644 --- a/packages/s2-shared/src/constant/sort.ts +++ b/packages/s2-core/src/shared/constant/sort.ts @@ -1,4 +1,4 @@ -import { S2_PREFIX_CLS, i18n } from '@antv/s2'; +import { i18n, S2_PREFIX_CLS } from '../../common'; export const getSortMethod = () => [ { diff --git a/packages/s2-shared/src/constant/theme.ts b/packages/s2-core/src/shared/constant/theme.ts similarity index 71% rename from packages/s2-shared/src/constant/theme.ts rename to packages/s2-core/src/shared/constant/theme.ts index b9691f0832..8bb0c51171 100644 --- a/packages/s2-shared/src/constant/theme.ts +++ b/packages/s2-core/src/shared/constant/theme.ts @@ -1,4 +1,4 @@ -import { S2_PREFIX_CLS } from '@antv/s2'; +import { S2_PREFIX_CLS } from '../../common'; /** * 注入主题 css 变量的节点名 diff --git a/packages/s2-shared/src/icons/calendar-icon.svg b/packages/s2-core/src/shared/icons/calendar-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/calendar-icon.svg rename to packages/s2-core/src/shared/icons/calendar-icon.svg diff --git a/packages/s2-shared/src/icons/col-icon.svg b/packages/s2-core/src/shared/icons/col-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/col-icon.svg rename to packages/s2-core/src/shared/icons/col-icon.svg diff --git a/packages/s2-shared/src/icons/dot-icon.svg b/packages/s2-core/src/shared/icons/dot-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/dot-icon.svg rename to packages/s2-core/src/shared/icons/dot-icon.svg diff --git a/packages/s2-shared/src/icons/location-icon.svg b/packages/s2-core/src/shared/icons/location-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/location-icon.svg rename to packages/s2-core/src/shared/icons/location-icon.svg diff --git a/packages/s2-shared/src/icons/row-icon.svg b/packages/s2-core/src/shared/icons/row-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/row-icon.svg rename to packages/s2-core/src/shared/icons/row-icon.svg diff --git a/packages/s2-shared/src/icons/search-icon.svg b/packages/s2-core/src/shared/icons/search-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/search-icon.svg rename to packages/s2-core/src/shared/icons/search-icon.svg diff --git a/packages/s2-shared/src/icons/sort-icon.svg b/packages/s2-core/src/shared/icons/sort-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/sort-icon.svg rename to packages/s2-core/src/shared/icons/sort-icon.svg diff --git a/packages/s2-shared/src/icons/switcher-icon.svg b/packages/s2-core/src/shared/icons/switcher-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/switcher-icon.svg rename to packages/s2-core/src/shared/icons/switcher-icon.svg diff --git a/packages/s2-shared/src/icons/text-icon.svg b/packages/s2-core/src/shared/icons/text-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/text-icon.svg rename to packages/s2-core/src/shared/icons/text-icon.svg diff --git a/packages/s2-shared/src/icons/value-icon.svg b/packages/s2-core/src/shared/icons/value-icon.svg similarity index 100% rename from packages/s2-shared/src/icons/value-icon.svg rename to packages/s2-core/src/shared/icons/value-icon.svg diff --git a/packages/s2-core/src/shared/index.ts b/packages/s2-core/src/shared/index.ts new file mode 100644 index 0000000000..28e208300f --- /dev/null +++ b/packages/s2-core/src/shared/index.ts @@ -0,0 +1,5 @@ +export * from './constant'; +export * from './interface'; +export * from './utils'; + +export * from './interface'; diff --git a/packages/s2-shared/src/interface.ts b/packages/s2-core/src/shared/interface.ts similarity index 92% rename from packages/s2-shared/src/interface.ts rename to packages/s2-core/src/shared/interface.ts index 89a9d57527..3e901b69dc 100644 --- a/packages/s2-shared/src/interface.ts +++ b/packages/s2-core/src/shared/interface.ts @@ -1,39 +1,41 @@ +import { FederatedPointerEvent as GEvent } from '@antv/g'; +import type { + ColCell, + CornerCell, + DataCell, + MergedCell, + RowCell, + SeriesNumberCell, + TableDataCell, +} from '../cell'; import type { BaseTooltipOperatorMenuOptions, CellScrollPosition, CellSelectedHandler, - ColCell, CopyableList, - CornerCell, - DataCell, - GEvent, HeaderActionIcon, HiddenColumnsInfo, LayoutResult, - MergedCell, - Node, Pagination, RawData, ResizeInfo, ResizeParams, - RowCell, RowCellCollapsedParams, S2CellType, S2DataConfig, S2MountContainer, S2Options, S2RenderOptions, - SeriesNumberCell, SortParams, - SpreadSheet, - TableDataCell, TargetCellInfo, ThemeCfg, TooltipContentType, TooltipOperatorOptions, ViewMeta, ViewMetaData, -} from '@antv/s2'; +} from '../common'; +import type { Node } from '../facet/layout/node'; +import type { SpreadSheet } from '../sheet-type'; // 是否开启自适应宽高,并指定容器 export type Adaptive = @@ -61,27 +63,10 @@ export type LayoutPaginationParams = { total: number; current: number; }; -type _ShowPagination = - | boolean - | { - onShowSizeChange?: (pageSize: number) => void; - onChange?: (current: number) => void; - }; - -type ShowPagination = - OverrideShowPagination extends true - ? Options extends { - pagination?: { onShowSizeChange?: unknown; onChange?: unknown }; - } - ? boolean | Options['pagination'] - : _ShowPagination - : _ShowPagination; export interface BaseSheetComponentProps< PartialDrillDown = PartDrillDown, - Header = unknown, Options = S2Options, - OverrideShowPagination = false, > { sheetType?: SheetType; spreadsheet?: ( @@ -94,9 +79,7 @@ export interface BaseSheetComponentProps< loading?: boolean; partDrillDown?: PartialDrillDown; adaptive?: Adaptive; - showPagination?: ShowPagination; themeCfg?: ThemeCfg; - header?: Header; // ============== Row Cell ==================== onRowCellHover?: (data: TargetCellInfo) => void; @@ -185,8 +168,9 @@ export interface BaseSheetComponentProps< onBeforeRender?: () => void; onAfterRender?: () => void; onMounted?: (spreadsheet: SpreadSheet) => void; - onUpdate?: (renderOptions: S2RenderOptions) => S2RenderOptions; + onUpdate?: (renderOptions: S2RenderOptions) => S2RenderOptions | void; onUpdateAfterRender?: (renderOptions: S2RenderOptions) => void; + onLoading?: (loading: boolean) => void; onDestroy?: () => void; // ============== Resize ==================== @@ -258,18 +242,21 @@ export interface TooltipOperatorProps

} // 下钻相关类型 -export interface BaseDataSet { +export interface BaseDrillDownDataSet { name: string; value: string; type?: 'text' | 'location' | 'date'; disabled?: boolean; } -export interface BaseDrillDownComponentProps { +export interface BaseDrillDownComponentProps< + DataSet = BaseDrillDownDataSet, + Text = string, +> { className?: string; - titleText?: string; + title?: Text; searchText?: string; - clearButtonText?: string; + clearText?: Text; dataSet?: DataSet[] | undefined; drillFields?: string[]; disabledFields?: string[]; diff --git a/packages/s2-shared/src/styles/drill-down.less b/packages/s2-core/src/shared/styles/drill-down.less similarity index 94% rename from packages/s2-shared/src/styles/drill-down.less rename to packages/s2-core/src/shared/styles/drill-down.less index 40beb64006..4d4ec9e556 100644 --- a/packages/s2-shared/src/styles/drill-down.less +++ b/packages/s2-core/src/shared/styles/drill-down.less @@ -12,14 +12,15 @@ font-size: 14px; padding: 0 16px; margin-top: 16px; + align-items: center; + justify-content: space-between; button { position: absolute; right: 0; - top: -4px; + top: 0; font-size: 12px; color: #1890ff; - letter-spacing: -0.2px; line-height: 20px; } } diff --git a/packages/s2-shared/src/styles/theme/dark.less b/packages/s2-core/src/shared/styles/theme/dark.less similarity index 100% rename from packages/s2-shared/src/styles/theme/dark.less rename to packages/s2-core/src/shared/styles/theme/dark.less diff --git a/packages/s2-shared/src/styles/tooltip/index.less b/packages/s2-core/src/shared/styles/tooltip/index.less similarity index 98% rename from packages/s2-shared/src/styles/tooltip/index.less rename to packages/s2-core/src/shared/styles/tooltip/index.less index 9276ce94a4..9918ab9578 100644 --- a/packages/s2-shared/src/styles/tooltip/index.less +++ b/packages/s2-core/src/shared/styles/tooltip/index.less @@ -1,4 +1,4 @@ -@import '../variables.less'; +@import '../../../ui/tooltip/index.less'; .@{tooltip-cls-prefix} { &-tips, diff --git a/packages/s2-shared/src/styles/tooltip/operator.less b/packages/s2-core/src/shared/styles/tooltip/operator.less similarity index 100% rename from packages/s2-shared/src/styles/tooltip/operator.less rename to packages/s2-core/src/shared/styles/tooltip/operator.less diff --git a/packages/s2-shared/src/styles/variables.less b/packages/s2-core/src/shared/styles/variables.less similarity index 84% rename from packages/s2-shared/src/styles/variables.less rename to packages/s2-core/src/shared/styles/variables.less index 8dacd99a63..aeacc6a3a3 100644 --- a/packages/s2-shared/src/styles/variables.less +++ b/packages/s2-core/src/shared/styles/variables.less @@ -1,4 +1,4 @@ -@import '@antv/s2/src/styles/variables.less'; +@import '../../styles/variables.less'; @tooltip-operator-cls-prefix: ~'@{s2-cls-prefix}-tooltip-operator'; @tooltip-menu-item-text-color: rgba(0, 0, 0, 0.65); @@ -19,6 +19,3 @@ // 头部组件 @header-cls-prefix: ~'@{s2-cls-prefix}-header'; - -// 图标 -@icon-cls-prefix: ~'@{s2-cls-prefix}-icon'; diff --git a/packages/s2-shared/src/utils/classnames.ts b/packages/s2-core/src/shared/utils/classnames.ts similarity index 100% rename from packages/s2-shared/src/utils/classnames.ts rename to packages/s2-core/src/shared/utils/classnames.ts diff --git a/packages/s2-shared/src/utils/drill-down.ts b/packages/s2-core/src/shared/utils/drill-down.ts similarity index 95% rename from packages/s2-shared/src/utils/drill-down.ts rename to packages/s2-core/src/shared/utils/drill-down.ts index 22b3e82b19..3bceec5f95 100644 --- a/packages/s2-shared/src/utils/drill-down.ts +++ b/packages/s2-core/src/shared/utils/drill-down.ts @@ -1,14 +1,14 @@ +import { FederatedPointerEvent as GEvent } from '@antv/g'; +import { clone, filter, isEmpty, size } from 'lodash'; import { S2Event, - type GEvent, type HeaderActionIcon, - type Node, type PartDrillDownDataCache, - type PivotDataSet, type S2Options, - type SpreadSheet, -} from '@antv/s2'; -import { clone, filter, isEmpty, size } from 'lodash'; +} from '../../common'; +import type { PivotDataSet } from '../../data-set'; +import type { Node } from '../../facet/layout/node'; +import type { SpreadSheet } from '../../sheet-type'; import type { PartDrillDown, PartDrillDownInfo } from '../interface'; export interface DrillDownParams { diff --git a/packages/s2-core/src/shared/utils/index.ts b/packages/s2-core/src/shared/utils/index.ts new file mode 100644 index 0000000000..c02e3a9f01 --- /dev/null +++ b/packages/s2-core/src/shared/utils/index.ts @@ -0,0 +1,4 @@ +export * from './classnames'; +export * from './drill-down'; +export * from './options'; +export * from './resize'; diff --git a/packages/s2-shared/src/utils/options.ts b/packages/s2-core/src/shared/utils/options.ts similarity index 72% rename from packages/s2-shared/src/utils/options.ts rename to packages/s2-core/src/shared/utils/options.ts index 52be6f8424..c33f488184 100644 --- a/packages/s2-shared/src/utils/options.ts +++ b/packages/s2-core/src/shared/utils/options.ts @@ -1,4 +1,5 @@ -import { customMerge, DEFAULT_OPTIONS, type S2Options } from '@antv/s2'; +import { DEFAULT_OPTIONS, type S2Options } from '../../common'; +import { customMerge } from '../../utils'; import { SHEET_COMPONENT_DEFAULT_OPTIONS } from '../constant/option'; export const getBaseSheetComponentOptions = ( diff --git a/packages/s2-shared/src/utils/resize.ts b/packages/s2-core/src/shared/utils/resize.ts similarity index 98% rename from packages/s2-shared/src/utils/resize.ts rename to packages/s2-core/src/shared/utils/resize.ts index 5e0c1fd46a..8d278c1f12 100644 --- a/packages/s2-shared/src/utils/resize.ts +++ b/packages/s2-core/src/shared/utils/resize.ts @@ -1,5 +1,5 @@ -import { floor } from '@antv/s2'; import { debounce, isBoolean } from 'lodash'; +import { floor } from '../../utils'; import { RESIZE_RENDER_DELAY } from '../constant/resize'; import type { Adaptive, ResizeEffectParams } from '../interface'; diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts index 3a38d9edb5..28b888d1d1 100644 --- a/packages/s2-core/src/sheet-type/spread-sheet.ts +++ b/packages/s2-core/src/sheet-type/spread-sheet.ts @@ -488,6 +488,7 @@ export abstract class SpreadSheet extends EE { const canvas = this.getCanvasElement(); if (canvas) { + // @ts-ignore // eslint-disable-next-line no-underscore-dangle delete canvas.__s2_instance__; } diff --git a/packages/s2-core/src/styles/variables.less b/packages/s2-core/src/styles/variables.less index 9bf51d15f8..a74d8d3dab 100644 --- a/packages/s2-core/src/styles/variables.less +++ b/packages/s2-core/src/styles/variables.less @@ -1,8 +1,11 @@ // s2 类名前缀 @s2-cls-prefix: antv-s2; +// css 变量前缀 +@css-var-prefix: ~'--@{s2-cls-prefix}'; + // Tooltip @tooltip-cls-prefix: ~'@{s2-cls-prefix}-tooltip'; -// css 变量前缀 -@css-var-prefix: ~'--@{s2-cls-prefix}'; +// 图标 +@icon-cls-prefix: ~'@{s2-cls-prefix}-icon'; diff --git a/packages/s2-core/src/utils/cell/header-cell.ts b/packages/s2-core/src/utils/cell/header-cell.ts index eb16aee33c..cca3206659 100644 --- a/packages/s2-core/src/utils/cell/header-cell.ts +++ b/packages/s2-core/src/utils/cell/header-cell.ts @@ -14,16 +14,17 @@ import type { import type { Node } from '../../facet/layout/node'; const normalizeIcons = ( - icons: HeaderActionName[], + icons: HeaderActionName[] = [], position: IconPosition = 'right', -) => - icons.map((icon) => { +) => { + return icons.map((icon) => { if (typeof icon === 'string') { return { name: icon, position }; } return icon; }); +}; const normalizeActionIconCfg = (actionIconList: HeaderActionIcon[] = []) => actionIconList.map( diff --git a/packages/s2-core/src/utils/cell/index.ts b/packages/s2-core/src/utils/cell/index.ts new file mode 100644 index 0000000000..e7b8f4e0bc --- /dev/null +++ b/packages/s2-core/src/utils/cell/index.ts @@ -0,0 +1,6 @@ +export * from './cell'; +export * from './data-cell'; +export * from './header-cell'; +export * from './merged-cell'; +export * from './table-col-cell'; +export * from './text-scrolling'; diff --git a/packages/s2-core/src/utils/cell/merged-cell.ts b/packages/s2-core/src/utils/cell/merged-cell.ts new file mode 100644 index 0000000000..378335f457 --- /dev/null +++ b/packages/s2-core/src/utils/cell/merged-cell.ts @@ -0,0 +1,140 @@ +import { find, forEach, includes, isEqual } from 'lodash'; +import type { DataCell } from '../../cell'; + +/** + * according to the coordinates of the starting point of the rectangle, + * return the four sides of the rectangle in a clockwise direction. + * [TopLeft] --- [TopRight] + * | | + * [BottomLeft] -[BottomRight] + * @param x + * @param y + * @param width + * @param height + */ +export const getRectangleEdges = ( + x: number, + y: number, + width: number, + height: number, +) => { + const topLeft: [number, number] = [x, y]; + + const topRight: [number, number] = [x + width, y]; + + const bottomRight: [number, number] = [x + width, y + height]; + + const bottomLeft: [number, number] = [x, y + height]; + + return [ + [topLeft, topRight], + [topRight, bottomRight], + [bottomRight, bottomLeft], + [bottomLeft, topLeft], + ]; +}; + +/** + * return the edges without overlapping edges + * @param edges the collection of edges + */ +export const unique = (edges: [number, number][][]) => { + const result: [number, number][][] = []; + + forEach(edges, (edge) => { + const reverseEdge = [edge[1], edge[0]]; + + if (!JSON.stringify(edges).includes(JSON.stringify(reverseEdge))) { + result.push(edge); + } + }); + + return result; +}; + +/** + * return the edge according to the coordinate of current edge + * eg: curEdge: [[0,0], [100,0]] then the next edge: [[100, 0 ], [100, 100]] + * @param curEdge the coordinate of current edge + * @param edges the collection of edges + */ +export const getNextEdge = ( + curEdge: [number, number][], + edges: [number, number][][], +): [number, number][] | undefined => + find(edges, (edge) => isEqual(edge[0], curEdge[1])); +/** + * return all the points of the polygon + * @param cells the collection of information of cells which needed be merged + */ +export const getPolygonPoints = (cells: DataCell[]) => { + let allEdges: [number, number][][] = []; + + cells.forEach((cell) => { + const meta = cell.getMeta(); + const { x, y, width, height } = meta; + + allEdges = allEdges.concat(getRectangleEdges(x, y, width, height)); + }); + allEdges = unique(allEdges); + + let allPoints: [number, number][] = []; + const startEdge = allEdges[0]; + let curEdge = startEdge; + let nextEdge: [number, number][] | undefined = []; + + while (!isEqual(startEdge, nextEdge)) { + allPoints = allPoints.concat(curEdge); + nextEdge = getNextEdge(curEdge, allEdges); + curEdge = nextEdge!; + } + + return allPoints; +}; + +export const getRightAndBottomCells = (cells: DataCell[]) => { + const right: DataCell[] = []; + const bottom: DataCell[] = []; + const bottomRightCornerCell: DataCell[] = []; + + cells.forEach((cell) => { + const [row, col] = cell.position || []; + + if ( + !find( + cells, + (temp) => temp.position?.[0] === row + 1 && temp.position?.[1] === col, + ) + ) { + bottom.push(cell); + } + + if ( + !find( + cells, + (temp) => temp.position?.[1] === col + 1 && temp.position?.[0] === row, + ) + ) { + right.push(cell); + } + }); + + // 在绘制了 right border 后,如果它上面的 cell 也是 merge cell 中的,且无需绘制 right 时,需要单独为其位置 bottomRight corner 的 border,反正连线会断 + right.forEach((cell) => { + const [row, col] = cell.position || []; + const top = find( + cells, + (temp) => temp.position?.[0] === row - 1 && temp.position?.[1] === col, + ); + + if (top && !includes(right, top)) { + bottomRightCornerCell.push(top); + } + }); + + return { + bottom, + right, + bottomRightCornerCell, + }; +}; diff --git a/packages/s2-core/src/utils/export/copy/common.ts b/packages/s2-core/src/utils/export/copy/common.ts index d47f3ef743..5737cd1a38 100644 --- a/packages/s2-core/src/utils/export/copy/common.ts +++ b/packages/s2-core/src/utils/export/copy/common.ts @@ -1,5 +1,5 @@ import { escape, map, max } from 'lodash'; -import type { DataItem, SimpleData } from '../../../common'; +import type { CellMeta, DataItem, SimpleData } from '../../../common'; import { LINE_SEPARATOR, ROOT_NODE_ID, TAB_SEPARATOR } from '../../../common'; import { CopyMIMEType, @@ -13,6 +13,7 @@ import { type Transformer, } from '../../../common/interface/export'; import type { Node } from '../../../facet/layout/node'; +import type { SpreadSheet } from '../../../sheet-type/spread-sheet'; // 把 string[][] 矩阵转换成 CopyablePlain export const matrixPlainTextTransformer = ( @@ -228,3 +229,13 @@ export const getNodeFormatData = (leafNode: Node) => { return line; }; + +export const getHeaderNodeFromMeta = ( + meta: CellMeta, + spreadsheet: SpreadSheet, +) => { + const { rowIndex, colIndex } = meta; + const { facet } = spreadsheet; + + return [facet.getRowNodeByIndex(rowIndex), facet.getColNodeByIndex(colIndex)]; +}; diff --git a/packages/s2-core/src/utils/export/copy/core.ts b/packages/s2-core/src/utils/export/copy/core.ts index 109f9dd6da..a5f71ff55e 100644 --- a/packages/s2-core/src/utils/export/copy/core.ts +++ b/packages/s2-core/src/utils/export/copy/core.ts @@ -27,16 +27,6 @@ import { processSelectedTableByHeader, } from './table-copy'; -export const getHeaderNodeFromMeta = ( - meta: CellMeta, - spreadsheet: SpreadSheet, -) => { - const { rowIndex, colIndex } = meta; - const { facet } = spreadsheet; - - return [facet.getRowNodeByIndex(rowIndex), facet.getColNodeByIndex(colIndex)]; -}; - /** * 返回选中数据单元格生成的二维数组( CellMeta[][]) * @param { CellMeta[] } cells @@ -222,3 +212,50 @@ export const asyncProcessAllSelected = ( return asyncProcessSelectedAllTable(params); }; + +/** + * 异步获取文本数据 (text/plain) + * @example + const data = await asyncGetAllPlainData({ + sheetInstance: s2, + split: '\t', + formatOptions: true, + }); + */ +export const asyncGetAllPlainData = async (params: CopyAllDataParams) => { + const result = await asyncProcessAllSelected(params); + + return result[0].content; +}; + +/** + * 异步获取富文本数据 (text/html) + * @example + const data = await asyncGetAllHtmlData({ + sheetInstance: s2, + split: '\t', + formatOptions: true, + }); + */ +export const asyncGetAllHtmlData = async (params: CopyAllDataParams) => { + const result = await asyncProcessAllSelected(params); + + return result[1].content; +}; + +/** + * 异步获取数据 + * - 文本 (text/plain) + * - 富文本 (text/html) + * @example + const data = await asyncGetAllData({ + sheetInstance: s2, + split: '\t', + formatOptions: true, + }); + */ +export const asyncGetAllData = async (params: CopyAllDataParams) => { + const result = await asyncProcessAllSelected(params); + + return result; +}; diff --git a/packages/s2-core/src/utils/export/copy/index.ts b/packages/s2-core/src/utils/export/copy/index.ts index dd7fcf3393..330a27906b 100644 --- a/packages/s2-core/src/utils/export/copy/index.ts +++ b/packages/s2-core/src/utils/export/copy/index.ts @@ -1,6 +1,9 @@ -import type { SheetCopyConstructorParams } from '../../../common/interface/export'; -import { getSelectedData } from './core'; -import { PivotDataCellCopy } from './pivot-data-cell-copy'; - -export { PivotDataCellCopy, getSelectedData }; -export type { SheetCopyConstructorParams }; +export type { SheetCopyConstructorParams } from '../../../common/interface/export'; +export { + asyncGetAllData, + asyncGetAllHtmlData, + asyncGetAllPlainData, + getSelectedData, +} from './core'; +export { PivotDataCellCopy } from './pivot-data-cell-copy'; +export { strategyCopy } from './strategy-copy'; diff --git a/packages/s2-core/src/utils/export/copy/pivot-data-cell-copy.ts b/packages/s2-core/src/utils/export/copy/pivot-data-cell-copy.ts index de0759c258..72e21f42cb 100644 --- a/packages/s2-core/src/utils/export/copy/pivot-data-cell-copy.ts +++ b/packages/s2-core/src/utils/export/copy/pivot-data-cell-copy.ts @@ -38,10 +38,10 @@ import { BaseDataCellCopy } from './base-data-cell-copy'; import { assembleMatrix, completeMatrix, + getHeaderNodeFromMeta, getMaxRowLen, getNodeFormatData, } from './common'; -import { getHeaderNodeFromMeta } from './core'; export class PivotDataCellCopy extends BaseDataCellCopy { protected leafRowNodes: Node[] = []; diff --git a/packages/s2-react/src/components/export/strategy-copy.ts b/packages/s2-core/src/utils/export/copy/strategy-copy.ts similarity index 91% rename from packages/s2-react/src/components/export/strategy-copy.ts rename to packages/s2-core/src/utils/export/copy/strategy-copy.ts index a7f838c3e4..f5d635ae8e 100644 --- a/packages/s2-react/src/components/export/strategy-copy.ts +++ b/packages/s2-core/src/utils/export/copy/strategy-copy.ts @@ -1,18 +1,17 @@ -import { - PivotDataCellCopy, - assembleMatrix, - getEmptyPlaceholder, - getHeaderList, - getNodeFormatData, - safeJsonParse, - type CopyAllDataParams, - type CopyableList, - type Node, - type SheetCopyConstructorParams, - type SimpleData, - type ViewMeta, -} from '@antv/s2'; import { flatten, forEach, get, isArray, isNil, isObject, map } from 'lodash'; +import type { + CopyAllDataParams, + CopyableList, + SheetCopyConstructorParams, + SimpleData, + ViewMeta, +} from '../../../common'; +import type { Node } from '../../../facet/layout/node'; +import { safeJsonParse } from '../../common'; +import { getEmptyPlaceholder } from '../../text'; +import { getHeaderList } from '../method'; +import { assembleMatrix, getNodeFormatData } from './common'; +import { PivotDataCellCopy } from './pivot-data-cell-copy'; /** * Process the multi-measure with single-lines diff --git a/packages/s2-core/src/utils/export/copy/table-copy.ts b/packages/s2-core/src/utils/export/copy/table-copy.ts index 22d281044e..92dbda7abb 100644 --- a/packages/s2-core/src/utils/export/copy/table-copy.ts +++ b/packages/s2-core/src/utils/export/copy/table-copy.ts @@ -18,8 +18,7 @@ import { getSelectedRows, } from '../method'; import { BaseDataCellCopy } from './base-data-cell-copy'; -import { assembleMatrix } from './common'; -import { getHeaderNodeFromMeta } from './core'; +import { assembleMatrix, getHeaderNodeFromMeta } from './common'; class TableDataCellCopy extends BaseDataCellCopy { private displayData: RawData[]; diff --git a/packages/s2-core/src/utils/export/index.ts b/packages/s2-core/src/utils/export/index.ts index f5998817fc..694abfb13a 100644 --- a/packages/s2-core/src/utils/export/index.ts +++ b/packages/s2-core/src/utils/export/index.ts @@ -1,11 +1,11 @@ -import type { +export type { CopyableList, FormatOptions, } from '../../common/interface/export'; -import { assembleMatrix, getMaxRowLen, getNodeFormatData } from './copy/common'; -import { getHeaderList } from './method'; + +export { assembleMatrix, getMaxRowLen, getNodeFormatData } from './copy/common'; +export { asyncGetAllPlainData } from './copy/core'; +export { getHeaderList } from './method'; export * from './copy'; export * from './utils'; -export { assembleMatrix, getHeaderList, getMaxRowLen, getNodeFormatData }; -export type { CopyableList, FormatOptions }; diff --git a/packages/s2-core/src/utils/export/utils.ts b/packages/s2-core/src/utils/export/utils.ts index d12f34dbf3..7799d081bf 100644 --- a/packages/s2-core/src/utils/export/utils.ts +++ b/packages/s2-core/src/utils/export/utils.ts @@ -1,11 +1,9 @@ import { concat, get } from 'lodash'; import { CopyMIMEType, - type CopyAllDataParams, type Copyable, type CopyableItem, } from '../../common/interface/export'; -import { asyncProcessAllSelected } from './copy/core'; /** * 同步复制 @@ -114,50 +112,3 @@ export const download = (dataString: string, fileName: string) => { console.error(error); } }; - -/** - * 异步获取文本数据 (text/plain) - * @example - const data = await asyncGetAllPlainData({ - sheetInstance: s2, - split: '\t', - formatOptions: true, - }); - */ -export const asyncGetAllPlainData = async (params: CopyAllDataParams) => { - const result = await asyncProcessAllSelected(params); - - return result[0].content; -}; - -/** - * 异步获取富文本数据 (text/html) - * @example - const data = await asyncGetAllHtmlData({ - sheetInstance: s2, - split: '\t', - formatOptions: true, - }); - */ -export const asyncGetAllHtmlData = async (params: CopyAllDataParams) => { - const result = await asyncProcessAllSelected(params); - - return result[1].content; -}; - -/** - * 异步获取数据 - * - 文本 (text/plain) - * - 富文本 (text/html) - * @example - const data = await asyncGetAllData({ - sheetInstance: s2, - split: '\t', - formatOptions: true, - }); - */ -export const asyncGetAllData = async (params: CopyAllDataParams) => { - const result = await asyncProcessAllSelected(params); - - return result; -}; diff --git a/packages/s2-core/src/utils/index.ts b/packages/s2-core/src/utils/index.ts index 74db754040..7f1c657c26 100644 --- a/packages/s2-core/src/utils/index.ts +++ b/packages/s2-core/src/utils/index.ts @@ -1,8 +1,7 @@ export { auto } from './formatter'; export * from './canvas'; -export * from './cell/cell'; -export * from './cell/data-cell'; +export * from './cell'; export * from './color'; export * from './common'; export * from './export'; diff --git a/packages/s2-core/src/utils/interaction/merge-cell.ts b/packages/s2-core/src/utils/interaction/merge-cell.ts index 4804104755..4d4329c089 100644 --- a/packages/s2-core/src/utils/interaction/merge-cell.ts +++ b/packages/s2-core/src/utils/interaction/merge-cell.ts @@ -4,7 +4,6 @@ import { filter, find, forEach, - includes, isEmpty, isEqual, map, @@ -20,145 +19,6 @@ import type { } from '../../common/interface'; import type { SpreadSheet } from '../../sheet-type'; -/** - * according to the coordinates of the starting point of the rectangle, - * return the four sides of the rectangle in a clockwise direction. - * [TopLeft] --- [TopRight] - * | | - * [BottomLeft] -[BottomRight] - * @param x - * @param y - * @param width - * @param height - */ -export const getRectangleEdges = ( - x: number, - y: number, - width: number, - height: number, -) => { - const topLeft: [number, number] = [x, y]; - - const topRight: [number, number] = [x + width, y]; - - const bottomRight: [number, number] = [x + width, y + height]; - - const bottomLeft: [number, number] = [x, y + height]; - - return [ - [topLeft, topRight], - [topRight, bottomRight], - [bottomRight, bottomLeft], - [bottomLeft, topLeft], - ]; -}; - -/** - * return the edges without overlapping edges - * @param edges the collection of edges - */ -export const unique = (edges: [number, number][][]) => { - const result: [number, number][][] = []; - - forEach(edges, (edge) => { - const reverseEdge = [edge[1], edge[0]]; - - if (!JSON.stringify(edges).includes(JSON.stringify(reverseEdge))) { - result.push(edge); - } - }); - - return result; -}; - -/** - * return the edge according to the coordinate of current edge - * eg: curEdge: [[0,0], [100,0]] then the next edge: [[100, 0 ], [100, 100]] - * @param curEdge the coordinate of current edge - * @param edges the collection of edges - */ -export const getNextEdge = ( - curEdge: [number, number][], - edges: [number, number][][], -): [number, number][] | undefined => - find(edges, (edge) => isEqual(edge[0], curEdge[1])); - -/** - * return all the points of the polygon - * @param cells the collection of information of cells which needed be merged - */ -export const getPolygonPoints = (cells: DataCell[]) => { - let allEdges: [number, number][][] = []; - - cells.forEach((cell) => { - const meta = cell.getMeta(); - const { x, y, width, height } = meta; - - allEdges = allEdges.concat(getRectangleEdges(x, y, width, height)); - }); - allEdges = unique(allEdges); - - let allPoints: [number, number][] = []; - const startEdge = allEdges[0]; - let curEdge = startEdge; - let nextEdge: [number, number][] | undefined = []; - - while (!isEqual(startEdge, nextEdge)) { - allPoints = allPoints.concat(curEdge); - nextEdge = getNextEdge(curEdge, allEdges); - curEdge = nextEdge!; - } - - return allPoints; -}; - -export const getRightAndBottomCells = (cells: DataCell[]) => { - const right: DataCell[] = []; - const bottom: DataCell[] = []; - const bottomRightCornerCell: DataCell[] = []; - - cells.forEach((cell) => { - const [row, col] = cell.position || []; - - if ( - !find( - cells, - (temp) => temp.position?.[0] === row + 1 && temp.position?.[1] === col, - ) - ) { - bottom.push(cell); - } - - if ( - !find( - cells, - (temp) => temp.position?.[1] === col + 1 && temp.position?.[0] === row, - ) - ) { - right.push(cell); - } - }); - - // 在绘制了 right border 后,如果它上面的 cell 也是 merge cell 中的,且无需绘制 right 时,需要单独为其位置 bottomRight corner 的 border,反正连线会断 - right.forEach((cell) => { - const [row, col] = cell.position || []; - const top = find( - cells, - (temp) => temp.position?.[0] === row - 1 && temp.position?.[1] === col, - ); - - if (top && !includes(right, top)) { - bottomRightCornerCell.push(top); - } - }); - - return { - bottom, - right, - bottomRightCornerCell, - }; -}; - /** * get cells on the outside of visible area through mergeCellInfo * @param invisibleCellInfo diff --git a/packages/s2-core/src/utils/layout/generate-header-nodes.ts b/packages/s2-core/src/utils/layout/generate-header-nodes.ts index b17e6ca92c..677ecafcf2 100644 --- a/packages/s2-core/src/utils/layout/generate-header-nodes.ts +++ b/packages/s2-core/src/utils/layout/generate-header-nodes.ts @@ -1,6 +1,5 @@ import { EMPTY_FIELD_VALUE, EXTRA_FIELD } from '../../common/constant'; import { i18n } from '../../common/i18n'; -import { buildGridHierarchy } from '../../facet/layout/build-gird-hierarchy'; import type { FieldValue, HeaderNodesParams, @@ -25,6 +24,7 @@ export const generateHeaderNodes = (params: HeaderNodesParams) => { addMeasureInTotalQuery, addTotalMeasureInTotal, spreadsheet, + handler, } = params; const isTableMode = spreadsheet.isTableMode(); @@ -150,7 +150,7 @@ export const generateHeaderNodes = (params: HeaderNodesParams) => { hierarchy.pushIndexNode(node); node.rowIndex = hierarchy.getIndexNodes().length - 1; } else { - buildGridHierarchy({ + handler?.({ addTotalMeasureInTotal, addMeasureInTotalQuery, parentNode: node, @@ -158,7 +158,7 @@ export const generateHeaderNodes = (params: HeaderNodesParams) => { fields, hierarchy, spreadsheet, - }); + } as HeaderNodesParams); } } }; diff --git a/packages/s2-core/src/utils/theme.ts b/packages/s2-core/src/utils/theme.ts index f84f16242e..6cbf01a3e5 100644 --- a/packages/s2-core/src/utils/theme.ts +++ b/packages/s2-core/src/utils/theme.ts @@ -1,6 +1,6 @@ import { PALETTE_MAP, STYLE_ELEMENT_ID } from '../common/constant'; import type { Palette, ThemeName } from '../common/interface/theme'; -import DarkVars from '../styles/theme/dark.less?inline'; +import DarkVars from '../styles/theme/dark.less'; import { injectCssText } from './inject-css-text'; /** @@ -15,5 +15,8 @@ export const getPalette = (themeName?: ThemeName): Palette => { */ export const injectThemeVars = (themeName?: ThemeName) => { // 目前仅 dark 主题需要定制 - injectCssText(STYLE_ELEMENT_ID, themeName === 'dark' ? DarkVars : ''); + injectCssText( + STYLE_ELEMENT_ID, + themeName === 'dark' ? (DarkVars as string) : '', + ); }; diff --git a/packages/s2-core/tsconfig.build.json b/packages/s2-core/tsconfig.build.json new file mode 100644 index 0000000000..5edc7028ae --- /dev/null +++ b/packages/s2-core/tsconfig.build.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": ["src/**/*", "./typings.d.ts", "../../global.d.ts"], + "compilerOptions": { + "paths": {} + } +} diff --git a/packages/s2-core/tsconfig.declaration.json b/packages/s2-core/tsconfig.declaration.json deleted file mode 100644 index 2dc92e6c64..0000000000 --- a/packages/s2-core/tsconfig.declaration.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declarationDir": "temp", - "declaration": true, - "emitDeclarationOnly": true, - "paths": {} - }, - "include": ["src", "../../global.d.ts"] -} diff --git a/packages/s2-core/tsconfig.json b/packages/s2-core/tsconfig.json index 0c0c597cfc..197cba5581 100644 --- a/packages/s2-core/tsconfig.json +++ b/packages/s2-core/tsconfig.json @@ -3,7 +3,6 @@ "compilerOptions": { "paths": { "@antv/s2": ["s2-core/src/index.ts"], - "@antv/s2-shared": ["s2-shared/src/index.ts"], "@/*": ["s2-core/src/*"], "tests/*": ["s2-core/__tests__/*"] }, diff --git a/packages/s2-react-components/README.md b/packages/s2-react-components/README.md index d31c6b5198..e06763c763 100644 --- a/packages/s2-react-components/README.md +++ b/packages/s2-react-components/README.md @@ -34,7 +34,7 @@ $ pnpm add @antv/s2-react-components ```tsx import React from 'React' import { ThemePanel, TextAlignPanel, FrozenPanel } from '@antv/s2-react-components' -import '@antv/s2-components/dist/style.min.css' +import '@antv/s2-react-components/dist/s2-react-components.min.css' const App = () => { return ( @@ -84,7 +84,7 @@ const App = () => { ```tsx import React from 'React' import { ThemePanel } from '@antv/s2-react-components' -import '@antv/s2-components/dist/style.min.css' +import '@antv/s2-react-components/dist/s2-react-components.min.css' const App = () => { const s2Ref = React.useRef(); diff --git a/packages/s2-react-components/__tests__/__mocks__/svg.ts b/packages/s2-react-components/__tests__/__mocks__/svg.ts new file mode 100644 index 0000000000..828bbe5d33 --- /dev/null +++ b/packages/s2-react-components/__tests__/__mocks__/svg.ts @@ -0,0 +1,4 @@ +// eslint-disable-next-line import/no-default-export +export default 'SvgrURL'; + +export const ReactComponent = 'div'; diff --git a/packages/s2-react/__tests__/bugs/issue-1736-spec.tsx b/packages/s2-react-components/__tests__/bugs/issue-1736-spec.tsx similarity index 58% rename from packages/s2-react/__tests__/bugs/issue-1736-spec.tsx rename to packages/s2-react-components/__tests__/bugs/issue-1736-spec.tsx index 57b683e029..c919df4ca2 100644 --- a/packages/s2-react/__tests__/bugs/issue-1736-spec.tsx +++ b/packages/s2-react-components/__tests__/bugs/issue-1736-spec.tsx @@ -3,11 +3,14 @@ * https://github.com/antvis/S2/issues/1736 * Export dropdown visible state error */ -import { Export } from '@/components/export'; +import { Export } from '@/components'; import { waitFor } from '@testing-library/react'; import React from 'react'; import type { Root } from 'react-dom/client'; -import { getMockSheetInstance, renderComponent } from 'tests/util/helpers'; +import { + getMockSheetInstance, + renderComponent, +} from '../../../s2-react/__tests__/util/helpers'; describe('header export component render tests', () => { let unmount: Root['unmount']; @@ -16,27 +19,12 @@ describe('header export component render tests', () => { unmount?.(); }); - test('should render export and dropdown keep invisible', async () => { - const sheet = getMockSheetInstance(); - - unmount = renderComponent(); - - await waitFor(() => { - // export 组件 - expect(document.querySelector('.antv-s2-export')).toBeDefined(); - - // dropdown 不应该渲染 - expect(document.querySelector('.ant-dropdown')).toBe(null); - }); - }); - test('should render export dropdown menu', async () => { const sheet = getMockSheetInstance(); unmount = renderComponent( +
+ +
+ +`; + +exports[`AdvancedSort Component Tests should render custom icon and text 1`] = ` + +
+ +
+
+`; diff --git a/packages/s2-react-components/__tests__/unit/components/advanced-sort/__snapshots__/custom-sort-spec.tsx.snap b/packages/s2-react-components/__tests__/unit/components/advanced-sort/__snapshots__/custom-sort-spec.tsx.snap new file mode 100644 index 0000000000..42d036cd3f --- /dev/null +++ b/packages/s2-react-components/__tests__/unit/components/advanced-sort/__snapshots__/custom-sort-spec.tsx.snap @@ -0,0 +1,646 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CustomSort Component Tests should render component 1`] = ` + +
+
+
  • + + 杭州市 + + + + + + + + + + + + + + + + +
  • +
  • + + 绍兴市 + + + + + + + + + + + + + + + + +
  • +
  • + + 宁波市 + + + + + + + + + + + + + + + + +
  • +
  • + + 舟山市 + + + + + + + + + + + + + + + + +
  • +
  • + + 成都市 + + + + + + + + + + + + + + + + +
  • +
  • + + 绵阳市 + + + + + + + + + + + + + + + + +
  • +
  • + + 南充市 + + + + + + + + + + + + + + + + +
  • +
  • + + 乐山市 + + + + + + + + + + + + + + + + +
  • +
    +
    +
    +`; diff --git a/packages/s2-react-components/__tests__/unit/components/advanced-sort/advanced-sort-spec.tsx b/packages/s2-react-components/__tests__/unit/components/advanced-sort/advanced-sort-spec.tsx new file mode 100644 index 0000000000..3a725ae3dd --- /dev/null +++ b/packages/s2-react-components/__tests__/unit/components/advanced-sort/advanced-sort-spec.tsx @@ -0,0 +1,68 @@ +import { AdvancedSort } from '@/components'; +import { StepForwardOutlined } from '@ant-design/icons'; +import type { BaseDataSet } from '@antv/s2'; +import { fireEvent, render, screen } from '@testing-library/react'; +import React from 'react'; +import { getMockSheetInstance } from '../../../../../s2-react/__tests__/util/helpers'; + +describe('AdvancedSort Component Tests', () => { + const sheetInstance = getMockSheetInstance(); + + sheetInstance.dataCfg = { + data: [], + fields: { + rows: ['a', 'b'], + columns: ['c', 'd'], + values: ['e', 'f'], + }, + }; + sheetInstance.dataSet = { + ...sheetInstance.dataCfg, + getFieldName: jest.fn(), + getDimensionValues: jest.fn(), + } as unknown as BaseDataSet; + + test('should render component', () => { + const { asFragment, container } = render( + , + ); + + expect(asFragment()).toMatchSnapshot(); + expect(screen.getByText('高级排序')).toBeDefined(); + expect(container.querySelector('.antv-s2-advanced-sort-btn')).toBeDefined(); + }); + + test('should render custom icon and text', () => { + const { asFragment, container } = render( + } + text="自定义" + className="test" + sheetInstance={sheetInstance} + />, + ); + + expect(asFragment()).toMatchSnapshot(); + expect(container.querySelector('.test')).toBeDefined(); + expect(container.querySelector('.anticon-step-forward')).toBeDefined(); + expect(screen.getByText('自定义')).toBeDefined(); + }); + + test('should open sort panel', () => { + const onSortOpen = jest.fn(); + const onSortConfirm = jest.fn(); + + render( + , + ); + + fireEvent.click(screen.getByText('高级排序')); + + expect(screen.getByText('可选字段')).toBeDefined(); + expect(onSortOpen).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/s2-react-components/__tests__/unit/components/advanced-sort/custom-sort-spec.tsx b/packages/s2-react-components/__tests__/unit/components/advanced-sort/custom-sort-spec.tsx new file mode 100644 index 0000000000..6886ef22fb --- /dev/null +++ b/packages/s2-react-components/__tests__/unit/components/advanced-sort/custom-sort-spec.tsx @@ -0,0 +1,24 @@ +import { CustomSort } from '@/components'; +import { render } from '@testing-library/react'; +import React from 'react'; + +describe('CustomSort Component Tests', () => { + test('should render component', () => { + const { asFragment } = render( + , + ); + + expect(asFragment()).toMatchSnapshot(); + }); +}); diff --git a/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap b/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap new file mode 100644 index 0000000000..a57365cea4 --- /dev/null +++ b/packages/s2-react-components/__tests__/unit/components/drill-down/__snapshots__/drill-down-spec.tsx.snap @@ -0,0 +1,688 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DrillDown Component Tests should render component 1`] = ` + +
    +
    +
    + 选择下钻维度 +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + +
    +
    + No data +
    +
    +