Skip to content

Commit

Permalink
docs: 完善文档
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Sep 25, 2024
1 parent d962ae7 commit da78b67
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 205 deletions.
4 changes: 2 additions & 2 deletions packages/s2-core/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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@next/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@next/dist/s2-vue.min.js?label=gzip%20size&compression=gzip) | ![download](https://img.shields.io/npm/dm/@antv/s2-vue.svg) |

## 👤 Author

Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |

## 问题反馈

Expand Down
4 changes: 2 additions & 2 deletions packages/s2-react-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $ pnpm add @antv/s2-react-components@next
```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 (
Expand Down Expand Up @@ -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<SpreadSheet>();
Expand Down
111 changes: 14 additions & 97 deletions packages/s2-react-components/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,30 @@
/* eslint-disable import/order */
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable prefer-named-capture-group */
import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
import react from '@vitejs/plugin-react';
import path from 'path';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import { visualizer } from 'rollup-plugin-visualizer';
import {
defineConfig,
type Alias,
type LibraryFormats,
type PluginOption,
} from 'vite';
import type { UserConfig } from 'vite';
import { defineConfig } from 'vite';
import svgr from 'vite-plugin-svgr';
import { getBaseConfig } from '../../build.config.base.mjs';

const OUT_DIR_NAME_MAP: { [key in LibraryFormats]?: string } = {
es: 'esm',
cjs: 'lib',
umd: 'dist',
};
const { getViteConfig, isDevMode } = getBaseConfig();

const format = process.env['FORMAT'] as LibraryFormats;
const isAnalysisMode = process.env['ANALYSIS'];
const isDevMode = process.env['PLAYGROUND'];
const outDir = OUT_DIR_NAME_MAP[format];
const isUmdFormat = format === 'umd';
const root = path.join(__dirname, isDevMode ? 'playground' : '');

const alias: Alias[] = [
{
find: 'lodash',
replacement: 'lodash-es',
},
];

if (isDevMode) {
// 防止开发模式下直接加载s2-core中的主题less
alias.push({
find: /^(.*)\/theme\/(.*)\.less$/,
replacement: '$1/theme/$2.less?inline',
});
}

// eslint-disable-next-line import/no-default-export
export default defineConfig({
// 开发配置
root,
server: {
port: 3002,
hmr: true,
},

// 打包配置
resolve: {
mainFields: ['src', 'module', 'main'],
alias,
},

define: {
'process.env.NODE_ENV': JSON.stringify(
isDevMode ? 'development' : 'production',
),
},

plugins: [
peerDepsExternal(),
!isDevMode && viteCommonjs(),
react({
jsxRuntime: 'classic',
}),
svgr(),
isAnalysisMode && visualizer({ gzipSize: true }),
].filter(Boolean) as PluginOption[],

css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
modules: {
/*
* 样式小驼峰转化
* css: goods-list => tsx: goodsList
*/
localsConvention: 'camelCase',
},
},

build: {
target: 'es2015',
minify: isUmdFormat ? 'esbuild' : false,
sourcemap: true,
lib: {
name: 'S2-React-Components',
entry: './src/index.ts',
formats: [format],
},
outDir,
rollupOptions: {
output: {
entryFileNames: `[name]${isUmdFormat ? '.min' : ''}.js`,
assetFileNames: `[name]${isUmdFormat ? '.min' : ''}.[ext]`,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'@antv/s2': 'S2',
},
},
},
},
...(getViteConfig({
port: 3002,
libName: 'S2ReactComponents',
plugins: [
react({
jsxRuntime: 'classic',
}),
svgr(),
] as UserConfig['plugins'],
}) as UserConfig),
});
2 changes: 1 addition & 1 deletion packages/s2-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig({

...(getViteConfig({
port: 3001,
libName: 'S2-React',
libName: 'S2React',
plugins: [
react({
jsxRuntime: 'classic',
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
},
"size-limit": [
{
"path": "./dist/index.min.js",
"path": "./dist/s2-vue.min.js",
"import": "{ createComponent }",
"limit": "35 kB",
"ignore": [
Expand All @@ -90,7 +90,7 @@
]
},
{
"path": "./dist/style.min.css",
"path": "./dist/s2-vue.min.css",
"limit": "5 kB"
}
],
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-vue/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({

...getViteConfig({
port: 5050,
libName: 'S2-Vue',
libName: 'S2Vue',
plugins: [
vue(),
svgLoader({
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/api/components/advanced-sort.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tag: Updated

```tsx | pure
import { AdvancedSort } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css'

<AdvancedSort sheetInstance={s2} />
```
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/api/components/drill-down.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tag: Updated

```tsx | pure
import { DrillDown } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css'

const s2Options = {
width: 600,
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/api/components/export.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tag: Updated

```tsx | pure
import { Export } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css'

<Export sheetInstance={s2} />
```
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/api/components/sheet-component.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tag: Updated

```tsx | pure
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import '@antv/s2-react/dist/s2-react.min.css';

<SheetComponent sheetType="pivot" />
```
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/api/components/switcher.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tag: Updated

```tsx | pure
import { Switcher } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css'

<Switcher />
```
Expand Down
3 changes: 2 additions & 1 deletion s2-site/docs/common/browser.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ order: 5
如果使用的是 `React` 版本 `@antv/s2-react` , 或者 `Vue3` 版本 `@antv/s2-vue` 还需额外引入样式文件

```html
<link rel="stylesheet" href="./dist/style.min.css"/>
<link rel="stylesheet" href="./dist/s2-react.min.css"/>
<link rel="stylesheet" href="./dist/s2-vue.min.css"/>
```

也可以直接使用 `CDN` (推荐), 比如 [UNPKG](https://unpkg.com/@antv/s2@next) 或者 [![preview](https://data.jsdelivr.com/v1/package/npm/@antv/s2/badge)](https://www.jsdelivr.com/package/npm/@antv/s2)
Expand Down
4 changes: 2 additions & 2 deletions s2-site/docs/manual/advanced/analysis/drill-down.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ S2 提供 `维度下钻` 的基础能力,`@antv/s2-react` 和 `@antv/s2-vue`

```tsx
import { DrillDown } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

const sex = ['', ''];

Expand Down Expand Up @@ -122,7 +122,7 @@ const App = () => {

```tsx | pure
import { DrillDown } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

function App() {
return (
Expand Down
7 changes: 4 additions & 3 deletions s2-site/docs/manual/advanced/analysis/export.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ tag: Updated
import React from 'react'
import { SheetComponent } from '@antv/s2-react'
import { Export } from '@antv/s2-react-components'
import '@antv/s2-react/dist/style.min.css';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react/dist/s2-react.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';


const S2Options = {
interaction: {
Expand Down Expand Up @@ -67,7 +68,7 @@ const App = () => {
import { Button } from 'antd'
import { ExportOutlined } from '@ant-design/icons';
import { Export } from '@antv/s2-react-components'
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

const App = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/manual/advanced/analysis/introduction.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ npm install antd @ant-design/icons --save
```tsx
import React from 'react';
import { AdvancedSort } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

export const App = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion s2-site/docs/manual/getting-started.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const App = () => {
```tsx
import React from 'react';
import { AdvancedSort } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

const App = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import {
PivotSheet,
Node,
S2DataConfig,
TooltipOptions,
type S2Options,
type SortMethod,
type SortParams,
type TooltipOperatorMenuItem,
} from '@antv/s2';
import '@antv/s2/dist/style.min.css';
import '@antv/s2/dist/s2.min.css';

const SortMethodType = {
asc: 'asc',
Expand Down Expand Up @@ -73,6 +72,7 @@ fetch(
// 使用 S2 提供的组内排序方式
meta.spreadsheet.groupSortByMethod(key, meta);
}

meta.spreadsheet.hideTooltip();
};

Expand All @@ -90,6 +90,7 @@ fetch(
// icon 点击之后的执行函数
onClick: (props) => {
const { meta, event } = props;

// 自定义 tooltip 配置,展示 tooltip
meta.spreadsheet.showTooltip({
event,
Expand Down
2 changes: 1 addition & 1 deletion s2-site/examples/custom/custom-order/demo/custom-order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@antv/s2';
import { Menu } from 'antd';
import { SheetComponent, SheetComponentOptions } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';
import '@antv/s2-react/dist/s2-react.min.css';

const SortMethodType = {
asc: 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import { type DrillDownDataSet } from '@antv/s2-react';
import { DrillDown } from '@antv/s2-react-components';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

const dataSet: DrillDownDataSet[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { SheetComponent, type SheetComponentOptions } from '@antv/s2-react';
import { StrategyExport } from '@antv/s2-react-components';
import { Button, Space } from 'antd';
import { isNil } from 'lodash';
import '@antv/s2-react/dist/style.min.css';
import '@antv/s2-react-components/dist/style.min.css';
import '@antv/s2-react/dist/s2-react.min.css';
import '@antv/s2-react-components/dist/s2-react-components.min.css';

// 临时处理老数据格式
function process(children) {
Expand Down
Loading

0 comments on commit da78b67

Please sign in to comment.