diff --git a/example/app.css b/example/app.css new file mode 100644 index 00000000..3cb918ee --- /dev/null +++ b/example/app.css @@ -0,0 +1 @@ +@import '~antd/dist/antd.css'; \ No newline at end of file diff --git a/example/app.jsx b/example/app.jsx index 54249444..83f233d6 100644 --- a/example/app.jsx +++ b/example/app.jsx @@ -4,6 +4,8 @@ import { BoardGrid, PureBoardGrid, setLocale, getLocale, getTheme, setTheme } fr import layout from './mock/data'; // import layout2 from './mock/data2'; import { useMount } from 'react-use'; +import { Button } from 'antd'; +import './app.css' function App() { console.log('current locale:', getLocale()); @@ -17,16 +19,14 @@ function App() {
语言: - - + + 主题: - - + +
{ console.log(saveLayout); }} /> - {/* {'>>>>>>>>>>>>>>>>>>>>>>>>>>>sasasa'} - */}
); } diff --git a/example/index.js b/example/index.js index 399a7a42..62008320 100644 --- a/example/index.js +++ b/example/index.js @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { Input } from '@terminus/nusi'; +import { Input } from 'antd'; import { registDataConvertor, registControl, registChartOption, registTheme } from '../src'; import { ajaxConvertor } from './mock/ajax-data'; import { darkTheme } from './theme'; diff --git a/package.json b/package.json index 8d3fb329..340fb50d 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "dependencies": { "@babel/runtime": "^7.14.0", "@terminus/nusi": "^3.10.78", + "antd": "^4.15.4", "classnames": "^2.2.6", "cube-state": "1.2.1", "dom-to-image": "^2.6.0", diff --git a/src/common/DcEmpty/index.tsx b/src/common/DcEmpty/index.tsx index 0d462a36..2ca47e0d 100644 --- a/src/common/DcEmpty/index.tsx +++ b/src/common/DcEmpty/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Empty } from '@terminus/nusi'; +import { Empty } from 'antd'; interface IProps { condition?: any; diff --git a/src/common/DcFormModal/index.tsx b/src/common/DcFormModal/index.tsx index f17d79f2..e45c814b 100644 --- a/src/common/DcFormModal/index.tsx +++ b/src/common/DcFormModal/index.tsx @@ -1,5 +1,5 @@ import React, { useRef } from 'react'; -import { Modal } from '@terminus/nusi'; +import { Modal } from 'antd'; import { DcFormBuilder } from '..'; interface IProps { @@ -22,7 +22,6 @@ const DcFormModal = ({ title, visible, fields, onCancel, onOk }: IProps) => { return ( - + @@ -100,16 +99,16 @@ const EditorPanel = () => { - - + diff --git a/src/components/DcChartEditor/pick-chart-modal/index.tsx b/src/components/DcChartEditor/pick-chart-modal/index.tsx index d69506fb..85533732 100644 --- a/src/components/DcChartEditor/pick-chart-modal/index.tsx +++ b/src/components/DcChartEditor/pick-chart-modal/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Modal, Row, Col } from '@terminus/nusi'; +import { Col, Row, Modal } from 'antd'; import { map } from 'lodash'; import ChartEditorStore from '../../../stores/chart-editor'; import DashboardStore from '../../../stores/dash-board'; diff --git a/src/components/DcChartEditor/switch-chart-type/index.tsx b/src/components/DcChartEditor/switch-chart-type/index.tsx index 5ccf84cd..38b4df26 100644 --- a/src/components/DcChartEditor/switch-chart-type/index.tsx +++ b/src/components/DcChartEditor/switch-chart-type/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { map } from 'lodash'; -import { Popover } from '@terminus/nusi'; +import { Popover } from 'antd'; import DC from 'src/types'; import classnames from 'classnames'; import { DcIcon } from '../../../common'; @@ -26,7 +26,7 @@ const SwitchChartType = ({ return (
{map(basicCharts, ({ name, enName, icon }: DC.ViewDefItem, chartType) => ( - +
) => { // 初始化全国地图 client('https://geo.datav.aliyun.com/areas_v2/bound/100000_full.json', { referrer: '' }) .then((res) => registerMap('中华人民共和国', res)) - .catch((err) => { Toast.error(err); }); + .catch((err) => { message.error(err); }); }); const loadMapDataSource = (_mapTypes: string[]) => { @@ -99,7 +99,7 @@ const ChartMap = React.forwardRef((props: IProps, ref: React.Ref) => { const adcode = adcodeMap.get(mapType); client(`https://geo.datav.aliyun.com/areas_v2/bound/${adcode}_full.json`, { referrer: '' }) .then((res) => registerMap(mapType, res)) - .catch((err) => { Toast.error(err); }); + .catch((err) => { message.error(err); }); }; return ( diff --git a/src/components/DcCharts/chart-pie/configurator.tsx b/src/components/DcCharts/chart-pie/configurator.tsx index 2dda302f..f5f6a0f7 100644 --- a/src/components/DcCharts/chart-pie/configurator.tsx +++ b/src/components/DcCharts/chart-pie/configurator.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Checkbox } from '@terminus/nusi'; +import { Checkbox } from 'antd'; import produce from 'immer'; import { CommonConfigurator } from '../common'; import ChartEditorStore from '../../../stores/chart-editor'; diff --git a/src/components/DcCharts/chart-table/configurator.tsx b/src/components/DcCharts/chart-table/configurator.tsx index 1d10a778..b171d48b 100644 --- a/src/components/DcCharts/chart-table/configurator.tsx +++ b/src/components/DcCharts/chart-table/configurator.tsx @@ -1,7 +1,7 @@ import React, { FocusEvent, useState, useEffect } from 'react'; import produce from 'immer'; import { get, map } from 'lodash'; -import { Select, Input } from '@terminus/nusi'; +import { Select, Input } from 'antd'; import { CommonConfigurator } from '../common'; import ChartEditorStore from '../../../stores/chart-editor'; import DashboardStore from '../../../stores/dash-board'; diff --git a/src/components/DcCharts/chart-table/index.tsx b/src/components/DcCharts/chart-table/index.tsx index 3a95e6ae..797bb9fa 100644 --- a/src/components/DcCharts/chart-table/index.tsx +++ b/src/components/DcCharts/chart-table/index.tsx @@ -2,8 +2,8 @@ * 数据表格 */ import React, { useCallback } from 'react'; -import { Table } from '@terminus/nusi'; -import { map, get, find } from 'lodash'; +import { Table } from 'antd'; +import { map, get } from 'lodash'; interface IProps { results: Array<{ [k: string]: any }>; diff --git a/src/components/DcCharts/common/chart-mask/index.tsx b/src/components/DcCharts/common/chart-mask/index.tsx index 47795ce0..1f6ec809 100644 --- a/src/components/DcCharts/common/chart-mask/index.tsx +++ b/src/components/DcCharts/common/chart-mask/index.tsx @@ -1,4 +1,4 @@ -import { Spin } from '@terminus/nusi'; +import { Spin } from 'antd'; import React from 'react'; import './index.scss'; diff --git a/src/components/DcCharts/common/common-configurator.tsx b/src/components/DcCharts/common/common-configurator.tsx index d501b29d..2b04a938 100644 --- a/src/components/DcCharts/common/common-configurator.tsx +++ b/src/components/DcCharts/common/common-configurator.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Input } from '@terminus/nusi'; +import { Input } from 'antd'; import { DcFormBuilder } from '../../../common'; import ChartEditorStore from '../../../stores/chart-editor'; import DashboardStore from '../../../stores/dash-board'; diff --git a/src/components/DcContainer/index.tsx b/src/components/DcContainer/index.tsx index 042b200e..1719fbec 100644 --- a/src/components/DcContainer/index.tsx +++ b/src/components/DcContainer/index.tsx @@ -5,7 +5,7 @@ * @Last Modified time: 2021-04-22 14:07:06 */ import React, { ReactElement, useRef, useEffect, useCallback } from 'react'; -import { Tooltip, Select, Toast, Button } from '@terminus/nusi'; +import { Button, Tooltip, Select, message } from 'antd'; import classnames from 'classnames'; import { isEmpty, get, isFunction, reduce, isString, map, merge } from 'lodash'; import { useUpdate, DcIcon, DcEmpty } from '../../common'; diff --git a/src/components/DcContainer/options.tsx b/src/components/DcContainer/options.tsx index 1ef13403..77ef7511 100644 --- a/src/components/DcContainer/options.tsx +++ b/src/components/DcContainer/options.tsx @@ -6,7 +6,8 @@ */ import React, { useCallback, useEffect, useMemo, RefObject, ReactNode, memo } from 'react'; -import { Modal, Menu, Toast, Dropdown } from '@terminus/nusi'; +import { Dropdown, Modal, message } from 'antd'; +import { Menu } from '@terminus/nusi'; import { get } from 'lodash'; import { useFullscreen, useToggle } from 'react-use'; import { getConfig } from '../../config'; @@ -92,7 +93,7 @@ const Options = ({ view, viewId, viewRef, children, disabled = false, toggleFull }; if (metricName) { - const _exportingData = Toast.loading(textMap['exporting data'], 0); + const _exportingData = message.loading(textMap['exporting data'], 0); toggleExportingDataStatus(); exportChartData(metricName, _query, payload).then((res: Blob) => { const blob = new Blob([res]); @@ -109,7 +110,7 @@ const Options = ({ view, viewId, viewRef, children, disabled = false, toggleFull _exportingData(); toggleExportingDataStatus(); }).catch(() => { - Toast.error(textMap['export data error']); + message.error(textMap['export data error']); _exportingData(); toggleExportingDataStatus(); }); diff --git a/src/components/DcGlobalFilters/config-modal.tsx b/src/components/DcGlobalFilters/config-modal.tsx index 9d84a297..fbc574f1 100644 --- a/src/components/DcGlobalFilters/config-modal.tsx +++ b/src/components/DcGlobalFilters/config-modal.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; -import { Button, Modal, Tabs, Title, Dropdown, Menu, Tooltip, Input, Toast } from '@terminus/nusi'; +import { Title, Menu } from '@terminus/nusi'; +import { Button, Tooltip, Input, Dropdown, Tabs, Modal, message } from 'antd'; import { useImmer } from 'use-immer'; import { remove, find, findIndex, map } from 'lodash'; import { DcIcon, DcInfoIcon } from '../../common'; @@ -8,7 +9,8 @@ import DashboardStore, { TextType } from '../../stores/dash-board'; import GlobalFiltersStore from '../../stores/global-filters'; import './config-modal.scss'; -import { IconType } from '@terminus/nusi/es/notification'; + +type IconType = 'success' | 'info' | 'error' | 'warning'; interface FilterOption { icon?: IconType; @@ -158,7 +160,7 @@ export const ConfigGlobalFiltersModal = () => { onChange(e: React.FocusEvent) { const val = e.target.value; if (!val) { - Toast.warning('筛选项名称不能为空!'); + message.warning('筛选项名称不能为空!'); updateFilter(key, { name }); return; } diff --git a/src/components/DcGlobalFilters/filter-component/TimeSelector/index.tsx b/src/components/DcGlobalFilters/filter-component/TimeSelector/index.tsx index 6d9bff7d..d378fab4 100644 --- a/src/components/DcGlobalFilters/filter-component/TimeSelector/index.tsx +++ b/src/components/DcGlobalFilters/filter-component/TimeSelector/index.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { DatePicker } from '@terminus/nusi'; +import { DatePicker } from 'antd'; import moment, { Moment } from 'moment'; import { getTimeRanges, getTimeSpan, ITimeSpan } from './utils'; diff --git a/src/components/DcGlobalFilters/filter-component/index.tsx b/src/components/DcGlobalFilters/filter-component/index.tsx index d6087eb4..fa2ded67 100644 --- a/src/components/DcGlobalFilters/filter-component/index.tsx +++ b/src/components/DcGlobalFilters/filter-component/index.tsx @@ -1,9 +1,10 @@ import * as React from 'react'; import TimeSelector from './TimeSelector'; -import { Search } from '@terminus/nusi'; - +import { Input } from 'antd'; import './index.scss'; +const { Search } = Input; + type IProps = Merge<{ className: string; onChange: (val: any) => void; @@ -23,7 +24,6 @@ const FilterComp = ({ className, type, label, placeholder, defaultValue, onChang {}} /> diff --git a/src/utils/cascader-filter.tsx b/src/utils/cascader-filter.tsx index f90549d7..6987549a 100644 --- a/src/utils/cascader-filter.tsx +++ b/src/utils/cascader-filter.tsx @@ -2,12 +2,12 @@ import * as React from 'react'; interface CascaderOptionType { value?: string | number; - label?: string; + label?: React.ReactNode; disabled?: boolean; isLeaf?: boolean; loading?: boolean; children?: CascaderOptionType[]; - [key: string]: unknown; + [key: string]: any; } interface FilledFieldNamesType { diff --git a/src/utils/comp.ts b/src/utils/comp.ts index 43f00447..821ddf6a 100644 --- a/src/utils/comp.ts +++ b/src/utils/comp.ts @@ -2,7 +2,7 @@ /* eslint-disable no-unused-vars */ // import { forEach, replace } from 'lodash'; import domtoimage from 'dom-to-image'; -import { Toast } from '@terminus/nusi'; +import { message as Toast } from 'antd'; import DashboardStore from '../stores/dash-board'; export const formItemLayout = { diff --git a/src/utils/locale.ts b/src/utils/locale.ts new file mode 100644 index 00000000..e5585a7e --- /dev/null +++ b/src/utils/locale.ts @@ -0,0 +1,4 @@ +import zhCN from 'antd/lib/locale/zh_CN'; +import enUS from 'antd/es/locale-provider/en_US'; + +export const localeMap = { zh: zhCN, en: enUS };