Skip to content

Commit 0745836

Browse files
wjgogogolcx-seimalijinke666
authored
feat: Vue 1.0 (#1290)
* chore: 添加 antd vue 依赖 * refactor: 重新组织playgorund代码结构,增加less打包配置 * chore: 添加 shared 工具包 * refactor: 删除冗余配置属性s2Options * refactor: 简化useSpreadsheet hook以及相关类型定义 * refactor: 抽离getBaseSheetComponentOptions方法 * feat: 抽离公共类型到shared中 * feat: 加入最基础版base-sheet组件 * chore: update vue-tsc * fix: 修复类型错误 * feat: 添加emit配置 * fix: 处理不是以on开头的emit * refactor: 优化component类型定义 * refactor: 取消App.vue的setup模式 * feat: 增加useEvent hook * feat: 增加event事件demo * fix: 调整监听的生命周期 * fix: 修复getSpreadsheet回调处理方式 * feat: 构建实例时使用原始数据而非响应式数据 * feat: pagination 翻页器 * feat: 增加 useUpdate hooks 用于更新配置 * refactor: 抽离工具函数traverse * refactor: 代码风格优化 * refactor: 重新定义showPagination * refactor: 统一react/vue的i18n * fix: type 重用 * refactor: 优化mutable类型定义 * refactor: useEvents内部处理生命周期 * feat: 增加 useResize hook 事件 * feat: 完善 useResize hook 事件, 重构react中 resize事件 * fix: 修复base sheet props类型问题 fix: 修复useResize ut * refactor: 简化useUpdate处理配置逻辑 * feat: 在useLoading中添加layout响应事件 * refactor: 修复typo * refactor: 删除core层readonly限制 * chore: 升级vue-tsc * fix: 修复类型定义问题 * refactor: 重构i18n * refactor: 处理i18n引入模块问题 * refactor: resize加入trailing配置 * refactor: getInitProps增加对optional key的处理 * feat: 新增 Vue 的 Tooltip 适配 * feat: 新增 Vue 的 Tooltip 适配 * feat: 新增 Vue 的 Tooltip 适配 * feat(interaction): vue 和 react 增加右键事件透传 * fix: 修复 tooltip 类型定义问题 * refactor: 重命名 base sheet props, emits 类型定义 * Revert "refactor: 重命名 base sheet props, emits 类型定义" This reverts commit 59f2d4c. * feat: 增加pivot sheet 组件 * feat: 增加table sheet, sheet入口 组件 * feat: 增加useExpoes hook * fix: remove trailing config for debounce * fix(tooltip): 修复 tooltip 内容不更新的问题 * docs: 添加 vue readme 文档 * docs: 更新 vue issue template * refactor: 细节优化 * docs: 简介添加 vue 版本介绍 * docs: 添加 vue quick start * docs: 添加 vue 获取组件实例文档 Co-authored-by: 刘嘉一 <[email protected]> Co-authored-by: Jinke Li <[email protected]>
1 parent 685cd04 commit 0745836

File tree

136 files changed

+3914
-1801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+3914
-1801
lines changed

.eslintrc.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ module.exports = {
3333
},
3434
},
3535
rules: {
36-
'react-hooks/exhaustive-deps': 'warn',
37-
'react-hooks/rules-of-hooks': 'error',
3836
'prettier/prettier': [
3937
1,
4038
{
@@ -49,7 +47,7 @@ module.exports = {
4947
},
5048
],
5149
'import/order': 2,
52-
'import/no-default-export': 2,
50+
'import/no-default-export': 0,
5351
'no-restricted-syntax': 0,
5452
semi: 0,
5553
'no-console': 2,
@@ -73,6 +71,8 @@ module.exports = {
7371
'@typescript-eslint/no-empty-function': 0,
7472
'@typescript-eslint/explicit-module-boundary-types': 0,
7573
'import/no-named-default': 0,
74+
'react-hooks/exhaustive-deps': 0,
75+
'react-hooks/rules-of-hooks': 0,
7676
'react/jsx-filename-extension': [
7777
1,
7878
{
@@ -112,7 +112,7 @@ module.exports = {
112112
'prefer-arrow-callback': 2,
113113
'prefer-const': 2,
114114
'max-statements-per-line': [2, { max: 1 }],
115-
'max-params': [1, 3],
115+
'max-params': [1, 4],
116116
'no-unreachable': 2,
117117
eqeqeq: [
118118
2,
@@ -122,11 +122,20 @@ module.exports = {
122122
},
123123
],
124124
curly: [2, 'multi-line', 'consistent'],
125+
'guard-for-in': 0,
126+
'vue/multi-word-component-names': 0,
125127
},
126128
overrides: [
127129
{
128130
files: ['*.vue'],
129131
parser: 'vue-eslint-parser',
130132
},
133+
{
134+
files: ['*.tsx'],
135+
rules: {
136+
'react-hooks/exhaustive-deps': 1,
137+
'react-hooks/rules-of-hooks': 2,
138+
},
139+
},
131140
],
132141
};

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ title: '🐛'
1111

1212
| Package | Version |
1313
| -------------- | --------- |
14-
| @antv/s2 | - |
15-
| @antv/s2-react | - |
14+
| @antv/s2 | |
15+
| @antv/s2-react | |
16+
| @antv/s2-vue | |
1617

1718
### Sheet Type
1819

20+
<!-- Required! -->
21+
1922
- [ ] PivotSheet
2023
- [ ] TableSheet
2124
- [ ] GridAnalysisSheet
@@ -44,4 +47,4 @@ title: '🐛'
4447

4548
### 💻 System information
4649

47-
<!-- eg: chrome: v91.0, window -->
50+
<!-- eg: chrome: v91.0, window 🙅🏻‍♀️🚫 `latest`, `1.x` -->

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"build:esm": "lerna run build:esm --include-dependencies --stream --concurrency 1",
3838
"build:umd": "lerna run build:umd --include-dependencies --stream --concurrency 1",
3939
"bundle:size": "lerna run bundle:size --stream",
40-
"release": "lerna exec --concurrency 1 --ignore @antv/s2-vue -- npx --no-install semantic-release",
40+
"release": "lerna exec --concurrency 1 -- npx --no-install semantic-release",
4141
"prepublish:manual": "yarn build",
4242
"publish:manual": "lerna publish",
4343
"test": "lerna run test --stream",

packages/s2-core/__tests__/unit/common/i18n/index-spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { i18n, setEVALocale } from '@/common/i18n';
1+
import { i18n, setLang } from '@/common/i18n';
22

33
describe('I18n Test', () => {
44
test('should show english text when set lang to en', () => {
5-
setEVALocale('en_US');
5+
setLang('en_US');
66
expect(i18n('小计')).toEqual('Total');
77
expect(i18n('总计')).toEqual('Total');
88
expect(i18n('总和')).toEqual('SUM');
@@ -16,14 +16,14 @@ describe('I18n Test', () => {
1616
});
1717

1818
test('should show Chinese text when set lang to zh', () => {
19-
setEVALocale('zh_CN');
19+
setLang('zh_CN');
2020
expect(i18n('小计')).toEqual('小计');
2121
expect(i18n('总计')).toEqual('总计');
2222
expect(i18n('总和')).toEqual('总和');
2323
expect(i18n('项')).toEqual('项');
2424
expect(i18n('已选择')).toEqual('已选择');
2525
expect(i18n('序号')).toEqual('序号');
26-
expect(i18n('度量')).toEqual('所选项');
26+
expect(i18n('度量')).toEqual('度量');
2727
expect(i18n('数值')).toEqual('数值');
2828
expect(i18n('共计')).toEqual('共计');
2929
expect(i18n('条')).toEqual('条');

packages/s2-core/src/common/i18n/en_US.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,11 @@ export const EN_US = {
99
数值: 'Measure',
1010
共计: 'Total',
1111
: '',
12-
选择分析信息: 'Select Analysis Information',
13-
切换指标: 'Switch indicator',
14-
确定: 'Ok',
15-
取消: 'Cancel',
16-
重置: 'Rest',
17-
请输入关键字搜索: 'Please enter a keyword search',
18-
搜索: 'Search',
19-
恢复: 'Recover',
12+
隐藏: 'Hide',
2013
趋势: 'Trend',
21-
'已选 {} 项': 'selected {} item',
22-
所选项: 'selected items',
2314
组内升序: 'Group ASC',
2415
组内降序: 'Group DESC',
2516
升序: 'ASC',
2617
降序: 'DESC',
2718
不排序: 'No order',
28-
选择下钻维度: 'Select drill down dimension',
29-
恢复默认: 'Restore default',
30-
搜索字段: 'Search field',
31-
指标: 'Measure',
32-
// switcher
33-
行列切换: 'Switch Dimensions',
34-
行头: 'Rows',
35-
列头: 'Cols',
36-
: 'Values',
37-
展开子项: 'Expand Children',
38-
首字母: 'Alphabetical order',
39-
手动排序: 'Custom order',
40-
其他字段: 'Other field',
41-
高级排序: 'Advanced order',
42-
设置顺序: 'SetManual',
43-
可选字段: 'Fields',
44-
'按以下规则进行排序(优先级由低到高)':
45-
'Order according to the following rules (from low to high priority)',
46-
: 'By',
4719
};
Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
1-
import { get } from 'lodash';
2-
import { ZH_CN } from './zh_CN';
3-
import { EN_US } from './en_US';
1+
import { get, merge } from 'lodash';
2+
import { ZH_CN as BASE_ZH_CN } from './zh_CN';
3+
import { EN_US as BASE_EN_US } from './en_US';
44

5-
export let Lang = 'zh_CN';
5+
export type LangType = 'zh_CN' | 'en_US';
66

7-
let Locale = ZH_CN;
7+
export type LocaleType = {
8+
[K in LangType]: Record<string, string>;
9+
};
10+
11+
let lang: LangType = 'zh_CN';
12+
13+
let locale: LocaleType = {
14+
zh_CN: BASE_ZH_CN,
15+
en_US: BASE_EN_US,
16+
};
17+
18+
export const getLang = () => lang;
819

9-
const isEnUS = (l: string) => l.indexOf('en') === 0;
20+
const isEnUS = (l: LangType) => l.indexOf('en') === 0;
1021

1122
/**
1223
* 设置语言
1324
* @param lang
1425
*/
15-
export const setEVALocale = (lang: string) => {
16-
Lang = isEnUS(lang) ? 'en_US' : 'zh_CN';
17-
Locale = isEnUS(lang) ? EN_US : ZH_CN;
26+
export const setLang = (l: LangType) => {
27+
lang = isEnUS(l) ? 'en_US' : 'zh_CN';
28+
};
29+
30+
/**
31+
* 拓展locale配置
32+
*/
33+
export const extendLocale = (extend: LocaleType) => {
34+
locale = merge({}, locale, extend);
1835
};
1936

2037
/**
@@ -23,5 +40,5 @@ export const setEVALocale = (lang: string) => {
2340
*
2441
*/
2542
export const i18n = (key: string, defaultValue = key) => {
26-
return get(Locale, key, defaultValue);
43+
return get(locale, [lang, key], defaultValue);
2744
};

packages/s2-core/src/common/i18n/zh_CN.ts

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,15 @@ export const ZH_CN = {
55
: '项',
66
已选择: '已选择',
77
序号: '序号',
8-
度量: '所选项',
8+
度量: '度量',
99
数值: '数值',
1010
共计: '共计',
1111
: '条',
12-
选择分析信息: '选择分析信息',
13-
切换指标: '切换指标',
14-
确定: '确定',
15-
取消: '取消',
16-
重置: '重置',
17-
请输入关键字搜索: '请输入关键字搜索',
18-
搜索: '搜索',
19-
恢复: '恢复',
2012
趋势: '趋势',
21-
'已选 {} 项': '已选 {} 项',
22-
所选项: '所选项',
13+
隐藏: '隐藏',
2314
组内升序: '组内升序',
2415
升序: '升序',
2516
降序: '降序',
2617
组内降序: '组内降序',
2718
不排序: '不排序',
28-
选择下钻维度: '选择下钻维度',
29-
恢复默认: '恢复默认',
30-
搜索字段: '搜索字段',
31-
指标: '指标',
32-
33-
// switcher
34-
行列切换: '行列切换',
35-
行头: '行头',
36-
列头: '列头',
37-
: '值',
38-
展开子项: '展开子项',
39-
首字母: '首字母',
40-
手动排序: '手动排序',
41-
其他字段: '其他字段',
42-
高级排序: '高级排序',
43-
设置顺序: '设置顺序',
44-
可选字段: '可选字段',
45-
'按以下规则进行排序(优先级由低到高)':
46-
'按以下规则进行排序(优先级由低到高)',
47-
: '按',
4819
};

packages/s2-core/src/common/interface/basic.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export enum CellBorderPosition {
4747
export type LayoutWidthType = 'adaptive' | 'colAdaptive' | 'compact';
4848

4949
export interface Meta {
50-
readonly field?: string; // 字段 id
51-
readonly name?: string; // 字段名称
52-
readonly description?: string; // 字段描述
50+
field?: string; // 字段 id
51+
name?: string; // 字段名称
52+
description?: string; // 字段描述
5353
// 格式化
5454
// 数值字段:一般用于格式化数字单位
5555
// 文本字段:一般用于做字段枚举值的别名
56-
readonly formatter?: Formatter;
56+
formatter?: Formatter;
5757
}
5858

5959
/**
@@ -150,8 +150,8 @@ export interface Total {
150150
* 但是内部配置我倾向于仍然按照字段所属维度区,即配置的row,代表的是行维度而不是行小计
151151
*/
152152
export interface Totals {
153-
readonly row?: Partial<Readonly<Total>>;
154-
readonly col?: Partial<Readonly<Total>>;
153+
row?: Partial<Total>;
154+
col?: Partial<Total>;
155155
}
156156

157157
export interface Sort {
@@ -186,19 +186,19 @@ export interface FilterParam {
186186
export type SortParams = SortParam[];
187187

188188
export interface Style {
189-
readonly layoutWidthType?: LayoutWidthType;
189+
layoutWidthType?: LayoutWidthType;
190190
// 是否展示树状分层下的层级占位点
191-
readonly showTreeLeafNodeAlignDot?: boolean;
191+
showTreeLeafNodeAlignDot?: boolean;
192192
// row cell's height in tree mode
193-
readonly treeRowsWidth?: number;
193+
treeRowsWidth?: number;
194194
// row header in tree mode collapse some nodes
195-
readonly collapsedRows?: Record<string, boolean>;
195+
collapsedRows?: Record<string, boolean>;
196196
// col header collapse nodes
197-
readonly collapsedCols?: Record<string, boolean>;
198-
readonly cellCfg?: CellCfg;
199-
readonly colCfg?: ColCfg;
200-
readonly rowCfg?: RowCfg;
201-
readonly device?: 'pc' | 'mobile'; // 设备,pc || mobile
197+
collapsedCols?: Record<string, boolean>;
198+
cellCfg?: CellCfg;
199+
colCfg?: ColCfg;
200+
rowCfg?: RowCfg;
201+
device?: 'pc' | 'mobile'; // 设备,pc || mobile
202202
}
203203

204204
export type Pagination = {

packages/s2-core/src/common/interface/condition.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ export type MappingFunction = (
2525
* One field can hold a condition
2626
*/
2727
export interface Condition {
28-
readonly field: string | RegExp;
29-
readonly mapping: MappingFunction;
28+
field: string | RegExp;
29+
mapping: MappingFunction;
3030
}
3131

3232
export type IconPosition = 'left' | 'right';
3333

3434
export interface IconCondition extends Condition {
35-
readonly position?: IconPosition; // right by default
35+
position?: IconPosition; // right by default
3636
}
3737

3838
export interface Conditions {
39-
readonly text?: Condition[];
40-
readonly background?: Condition[];
41-
readonly interval?: Condition[];
42-
readonly icon?: IconCondition[];
39+
text?: Condition[];
40+
background?: Condition[];
41+
interval?: Condition[];
42+
icon?: IconCondition[];
4343
}
4444

4545
export type IconCfg = Pick<IconTheme, 'size' | 'margin'> &

packages/s2-core/src/common/interface/interaction.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,37 @@ export interface HoverFocusOptions {
110110

111111
export interface InteractionOptions {
112112
// record which row/col field need extra link info
113-
readonly linkFields?: string[];
113+
linkFields?: string[];
114114
// focus selected cell, like the spotlight
115-
readonly selectedCellsSpotlight?: boolean;
115+
selectedCellsSpotlight?: boolean;
116116
// highlight all row header cells and column header cells to which the hovered cell belongs
117-
readonly hoverHighlight?: boolean;
117+
hoverHighlight?: boolean;
118118
// keep cell hovered after 800ms duration
119-
readonly hoverFocus?: boolean | HoverFocusOptions;
119+
hoverFocus?: boolean | HoverFocusOptions;
120120
// enable Command + C to copy spread data
121-
readonly enableCopy?: boolean;
121+
enableCopy?: boolean;
122122
// copy with filed format
123-
readonly copyWithFormat?: boolean;
123+
copyWithFormat?: boolean;
124124
// auto reset sheet style when click outside or press ecs key, default true
125-
readonly autoResetSheetStyle?: boolean;
126-
readonly hiddenColumnFields?: string[];
125+
autoResetSheetStyle?: boolean;
126+
hiddenColumnFields?: string[];
127127
// the ratio to control scroll speed, default set to 1
128-
readonly scrollSpeedRatio?: ScrollSpeedRatio;
128+
scrollSpeedRatio?: ScrollSpeedRatio;
129129
// enable resize area, default set to all enable
130-
readonly resize?: boolean | ResizeActiveOptions;
130+
resize?: boolean | ResizeActiveOptions;
131131
// enable mouse drag brush selection
132-
readonly brushSelection?: boolean;
132+
brushSelection?: boolean;
133133
// enable Command / Ctrl + click multi selection
134-
readonly multiSelection?: boolean;
134+
multiSelection?: boolean;
135135
// enable Shift + click multi selection
136-
readonly rangeSelection?: boolean;
136+
rangeSelection?: boolean;
137137
// use arrow keyboard to move selected cell
138-
readonly selectedCellMove?: boolean;
138+
selectedCellMove?: boolean;
139139
// controls scrollbar's position type
140-
readonly scrollbarPosition?: ScrollbarPositionType;
140+
scrollbarPosition?: ScrollbarPositionType;
141141
// An object that specifies characteristics about the event listener
142142
// https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
143-
readonly eventListenerOptions?: boolean | AddEventListenerOptions;
143+
eventListenerOptions?: boolean | AddEventListenerOptions;
144144
/** ***********CUSTOM INTERACTION HOOKS**************** */
145145
// register custom interactions
146146
customInteractions?: CustomInteraction[];

0 commit comments

Comments
 (0)