diff --git a/CONTRIBUTING.en-US.md b/CONTRIBUTING.en-US.md index b472e67a3d..b45ecd7065 100644 --- a/CONTRIBUTING.en-US.md +++ b/CONTRIBUTING.en-US.md @@ -1,5 +1,9 @@ # CONTRIBUTING +> 暂未翻译。 +> +> Not yet translated. + English | [Chinese](https://github.com/FightingDesign/fighting-design/blob/master/CONTRIBUTING.md) ## 👋 写在前面 @@ -52,8 +56,7 @@ pnpm dev:docs 编辑器强烈推荐使用 [Visual Studio Code](https://code.visualstudio.com/),内置插件请务必安装以下几款: -- [Vue Language Features (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 -- [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) 用于支持在 TS 中 import `*.vue` 文件 +- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) 代码格式校验,如果不安装,那么 [fighting-eslint-config](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-eslint-config) 则不生效 - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) 用于检测单词拼写错误 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b472e67a3d..048ee69f7e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# CONTRIBUTING +# 贡献指南 -English | [Chinese](https://github.com/FightingDesign/fighting-design/blob/master/CONTRIBUTING.md) +[English](https://github.com/FightingDesign/fighting-design/blob/master/CONTRIBUTING.en-US.md) | Chinese ## 👋 写在前面 @@ -52,8 +52,7 @@ pnpm dev:docs 编辑器强烈推荐使用 [Visual Studio Code](https://code.visualstudio.com/),内置插件请务必安装以下几款: -- [Vue Language Features (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 -- [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) 用于支持在 TS 中 import `*.vue` 文件 +- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) 代码格式校验,如果不安装,那么 [fighting-eslint-config](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-eslint-config) 则不生效 - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) 用于检测单词拼写错误 diff --git a/README.md b/README.md index 9af3bb492d..91ffad0662 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ - 👍 Maintained by the community team - ❤️ Developed according to actual demand - 📃 High quality detailed documentation -- 📌 Improve RFC - ☝️ Put forward demands and keep improving - 🌍 More configuration options & flexible components - 🛠 More features are under development @@ -71,7 +70,9 @@ import App from './App.vue' import FightingDesign from 'fighting-design' import 'fighting-design/dist/index.css' -createApp(App).use(FightingDesign).mount('#app') +const app = createApp(App) +app.use(FightingDesign) +app.mount('#app') ``` ## 🪂 Quick experience @@ -132,7 +133,7 @@ createApp(App).use(FightingDesign).mount('#app') Add WeChat & please note the `Github` username - + ## 💌 Special Thanks diff --git a/README.zh-CN.md b/README.zh-CN.md index c7796419f6..d674fd2867 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -36,7 +36,6 @@ - 👍 社区团队维护 - ❤️ 根据实际需求开发 - 📃 优质详细的文档 -- 📌 完善 RFC - ☝️ 提出需求,不断完善 - 🌍 更多配置项,灵活组件 - 🛠 更多特性开发中 @@ -68,10 +67,13 @@ yarn add --save-dev fighting-design ```ts import { createApp } from 'vue' import App from './App.vue' + import FightingDesign from 'fighting-design' import 'fighting-design/dist/index.css' -createApp(App).use(FightingDesign).mount('#app') +const app = createApp(App) +app.use(FightingDesign) +app.mount('#app') ``` ## 🪂 快速体验 @@ -132,7 +134,7 @@ createApp(App).use(FightingDesign).mount('#app') 添加微信请备注 `Github` 用户名 - + ## 💌 特别感谢 diff --git a/docs/components/date-picker.md b/docs/components/date-picker.md index 1d1859d9fc..9259161e92 100644 --- a/docs/components/date-picker.md +++ b/docs/components/date-picker.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/date-picker) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/date-picker.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 使用 `v-model:date` 绑定一个值 diff --git a/docs/components/input-number.md b/docs/components/input-number.md index 3559c51344..d2b8ba8573 100644 --- a/docs/components/input-number.md +++ b/docs/components/input-number.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/input-number) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/input-number.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 使用 `v-model` 绑定一个值,`model` 可配置不同的模式 diff --git a/docs/components/loading.md b/docs/components/loading.md index 34422137d6..1d810e6a02 100644 --- a/docs/components/loading.md +++ b/docs/components/loading.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/loading) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/loading.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 可以在指定元素上通过`fighting-design`内置指令 `v-loading` 来实现加载状态 diff --git a/docs/components/menu.md b/docs/components/menu.md index ab833f5b45..e4f55bdca3 100644 --- a/docs/components/menu.md +++ b/docs/components/menu.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/menu) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/menu.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 ::: demo diff --git a/docs/components/notification.md b/docs/components/notification.md index 8af4f2ab6c..d7dbb63ffd 100644 --- a/docs/components/notification.md +++ b/docs/components/notification.md @@ -244,7 +244,7 @@ | `background` | 自定义背景色 | string | —— | —— | | `placement` | 弹出位置 | NotificationPlacement | `top-left` `top-right` `bottom-left` `bottom-right` | top-right | | `offset` | 偏移距离 | number | —— | 20 | -| `close-btn` | 自定义关闭按钮 | string / FightingIcon | —— | —— | +| `close-btn` | 自定义关闭按钮 | string / FightingIcon | —— | —— | | `z-index` | 层级 | boolean | —— | 1000 | | `on-close` | 关闭之后回调 | MessageClose | —— | —— | diff --git a/docs/components/pagination.md b/docs/components/pagination.md index ba375940db..2012885887 100644 --- a/docs/components/pagination.md +++ b/docs/components/pagination.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/pagination) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/pagination.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 `v-model:current` 属性来绑定当前页码 diff --git a/docs/components/slider.md b/docs/components/slider.md index bec265de79..cf75d63c7b 100644 --- a/docs/components/slider.md +++ b/docs/components/slider.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/slider) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/slider.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 使用 `v-model` 绑定一个数字 diff --git a/docs/components/table.md b/docs/components/table.md index f53563dcf7..14e77911cb 100644 --- a/docs/components/table.md +++ b/docs/components/table.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/table) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/table.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 `data` 属性绑定需要展示的数据 diff --git a/docs/components/time-picker.md b/docs/components/time-picker.md index 345e4cc925..cc954e601d 100644 --- a/docs/components/time-picker.md +++ b/docs/components/time-picker.md @@ -5,10 +5,6 @@ - [源代码](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-design/time-picker) - [文档编辑](https://github.com/FightingDesign/fighting-design/blob/master/docs/components/time-picker.md) -:::danger -组件仍在测试阶段,高频更新中,部分参数暂不稳定! -::: - ## 基本使用 使用 `v-model:time` 绑定一个值 diff --git a/docs/docs/contributing.md b/docs/docs/contributing.md index c6b86f7b46..048ee69f7e 100644 --- a/docs/docs/contributing.md +++ b/docs/docs/contributing.md @@ -1,6 +1,6 @@ # 贡献指南 -English | [Chinese](https://github.com/FightingDesign/fighting-design/blob/master/CONTRIBUTING.md) +[English](https://github.com/FightingDesign/fighting-design/blob/master/CONTRIBUTING.en-US.md) | Chinese ## 👋 写在前面 @@ -52,8 +52,7 @@ pnpm dev:docs 编辑器强烈推荐使用 [Visual Studio Code](https://code.visualstudio.com/),内置插件请务必安装以下几款: -- [Vue Language Features (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 -- [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) 用于支持在 TS 中 import `*.vue` 文件 +- [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) Vue3 官方开发插件 - [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) 代码格式校验,如果不安装,那么 [fighting-eslint-config](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-eslint-config) 则不生效 - [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) 用于检测单词拼写错误 @@ -61,29 +60,30 @@ pnpm dev:docs fighting-design 内部设置了很多的命令,在 [package.json](https://github.com/FightingDesign/fighting-design/blob/master/package.json) 中可进行查看。下面详细介绍每一条命令: -| script 字段 | 对应命令 | 命令说明 | -| ------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `clear` | `pnpm clear` | 清除 dist 打包目录 | -| `start` | `pnpm start` | 启动测试开发项目 [start](https://github.com/FightingDesign/fighting-design/tree/master/start) | -| `dev:play` | `pnpm dev:play` | 启动演练场项目 [fighting-playground](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-playground) | -| `dev:docs` | `pnpm dev:docs` | 启动文档项目 [docs](https://github.com/FightingDesign/fighting-design/tree/master/docs) | -| `build` | `pnpm build` | 命令集合。打包所有组件、样式、类型。打包出来的就是最终需要发布的包 执行配置文件 [vite.config.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.ts) | -| `build:css` | `pnpm build:css` | 分别打包组件的样式,执行配置文件 [vite.config.css.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.css.ts) | -| `build:theme` | `pnpm build:theme` | 打包完整的主题样式,执行配置文件 [vite.config.theme.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.theme.ts) | -| `build:icon` | `pnpm build:icon` | 打包 [fighting-icon](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-icon),执行配置文件 [vite.config.icon.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.icon.ts) | -| `build:docs` | `pnpm build:docs` | 打包文档项目 [docs](https://github.com/FightingDesign/fighting-design/tree/master/docs) | -| `build:start` | `pnpm build:start` | 打包 `start` 测试项目 [start](https://github.com/FightingDesign/fighting-design/tree/master/start) | -| `build:play` | `pnpm build:play` | 打包 `演练场` 项目 [fighting-playground](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-playground) | -| `serve:docs` | `pnpm serve:docs` | 预览打包后的文档 | -| `new` | `pnpm new xxx` | 构建全新组件,生产组件所需要的文件,执行配置文件 [index.ts](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/index.ts),详情参考 [README.md](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/README.md) | -| `test` | `pnpm test` | 执行单元测试 | -| `prettier` | `pnpm prettier` | 全局格式化 | -| `commit` | `pnpm commit` | commit 钩子 | -| `lint` | `pnpm lint` | 全局 eslint 检测,规则参考 [](https://github.com/FightingDesign/fighting-design/blob/master/packages/eslint-config/index.js) | -| `lint:fix` | `pnpm lint:fix` | 全局 eSLint 检测 + 修复 | -| `changelog` | `pnpm changelog` | 同步文档的更新日志 | -| `ver` | `pnpm ver x.x.x` | 设置新的版本号 | -| `format` | `pnpm format` | 全局格式化 + 修复 | +| script 字段 | 对应命令 | 命令说明 | +| --------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `clear` | `pnpm clear` | 清除 dist 打包目录 | +| `start` | `pnpm start` | 启动测试开发项目 [start](https://github.com/FightingDesign/fighting-design/tree/master/start) | +| `dev:play` | `pnpm dev:play` | 启动演练场项目 [fighting-playground](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-playground) | +| `dev:docs` | `pnpm dev:docs` | 启动文档项目 [docs](https://github.com/FightingDesign/fighting-design/tree/master/docs) | +| `build` | `pnpm build` | 命令集合。打包所有组件、样式、类型。打包出来的就是最终需要发布的包 执行配置文件 [vite.config.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.ts) | +| `build:css` | `pnpm build:css` | 分别打包组件的样式,执行配置文件 [vite.config.css.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.css.ts) | +| `build:theme` | `pnpm build:theme` | 打包完整的主题样式,执行配置文件 [vite.config.theme.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.theme.ts) | +| `build:icon` | `pnpm build:icon` | 打包 [fighting-icon](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-icon),执行配置文件 [vite.config.icon.ts](https://github.com/FightingDesign/fighting-design/blob/master/vite.config.icon.ts) | +| `build:docs` | `pnpm build:docs` | 打包文档项目 [docs](https://github.com/FightingDesign/fighting-design/tree/master/docs) | +| `build:start` | `pnpm build:start` | 打包 `start` 测试项目 [start](https://github.com/FightingDesign/fighting-design/tree/master/start) | +| `build:play` | `pnpm build:play` | 打包 `演练场` 项目 [fighting-playground](https://github.com/FightingDesign/fighting-design/tree/master/packages/fighting-playground) | +| `serve:docs` | `pnpm serve:docs` | 预览打包后的文档 | +| `new` | `pnpm new xxx` | 构建全新组件,生产组件所需要的文件,执行配置文件 [index.ts](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/index.ts),详情参考 [README.md](https://github.com/FightingDesign/fighting-design/blob/master/packages/fighting-add-component/README.md) | +| `test` | `pnpm test` | 执行单元测试 | +| `test:coverage` | `pnpm test:coverage` | 查看单元测试覆盖率,可在终端中生成覆盖率,也可查看项目根目录下的 `coverage/index.html`,参考 [Coverage](https://vitest.dev/guide/coverage.html) | +| `prettier` | `pnpm prettier` | 全局格式化 | +| `commit` | `pnpm commit` | commit 钩子 | +| `lint` | `pnpm lint` | 全局 eslint 检测,规则参考 [](https://github.com/FightingDesign/fighting-design/blob/master/packages/eslint-config/index.js) | +| `lint:fix` | `pnpm lint:fix` | 全局 eSLint 检测 + 修复 | +| `changelog` | `pnpm changelog` | 同步文档的更新日志 | +| `ver` | `pnpm ver x.x.x` | 设置新的版本号 | +| `format` | `pnpm format` | 全局格式化 + 修复 | ## 🚧 开发规范 diff --git a/docs/docs/import.md b/docs/docs/import.md index dadc625c28..16ffe845ab 100644 --- a/docs/docs/import.md +++ b/docs/docs/import.md @@ -11,7 +11,9 @@ import App from './App.vue' import FightingDesign from 'fighting-design' import 'fighting-design/dist/index.css' -createApp(App).use(FightingDesign).mount('#app') +const app = createApp(App) +app.use(FightingDesign) +app.mount('#app') ``` ## 按需引入 @@ -29,7 +31,10 @@ import { FButton, FCard } from 'fighting-design' import 'fighting-design/theme/button.css' import 'fighting-design/theme/card.css' -createApp(App).use(FButton).use(FCard).mount('#app') +const app = createApp(App) +app.use(FButton) +app.use(FCard) +app.mount('#app') ``` ## 使用 UMD diff --git a/docs/docs/introduce.md b/docs/docs/introduce.md index f7b6869adf..d677be6234 100644 --- a/docs/docs/introduce.md +++ b/docs/docs/introduce.md @@ -22,7 +22,6 @@ - 👍 社区团队维护 - ❤️ 根据实际需求开发 - 📃 优质详细的文档 -- 📌 完善 RFC - ☝️ 提出需求,不断完善 - 🌍 更多配置项,灵活组件 - 🛠 更多特性开发中 diff --git a/docs/docs/join.md b/docs/docs/join.md index b7da8c4ebc..983475c0a9 100644 --- a/docs/docs/join.md +++ b/docs/docs/join.md @@ -6,7 +6,7 @@ 加微信邀请入 `Fighting Design 社区讨论` 群 - + ## 社区组织 diff --git a/package.json b/package.json index 035ebfec18..995a6cfceb 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "build:docs": "pnpm run -C docs build", "build:start": "pnpm run -C start build", "build:play": "pnpm run -C packages/fighting-playground build", - "build:resolver": "pnpm run -C packages/fighting-resolver build", "serve:docs": "pnpm run -C docs serve", "new": "pnpm run -C packages/fighting-add-component new", "test": "vitest", @@ -78,4 +77,4 @@ "eslint --fix" ] } -} \ No newline at end of file +} diff --git a/packages/fighting-design/_hooks/use-message/index.ts b/packages/fighting-design/_hooks/use-message/index.ts index 01bbe454e8..bd393e047f 100644 --- a/packages/fighting-design/_hooks/use-message/index.ts +++ b/packages/fighting-design/_hooks/use-message/index.ts @@ -120,9 +120,9 @@ const updatePosition = (closeInstance: ComponentInternalInstance): void => { instances[placement] as ComponentInternalInstance[] )[index] - // 减少后面的组件实例偏移量 - ; (instance.exposed as Record>).offsetVal.value -= - getNextElementInterval(closeInstance) + // 减少后面的组件实例偏移量 + ;(instance.exposed as Record>).offsetVal.value -= + getNextElementInterval(closeInstance) } } @@ -137,13 +137,13 @@ export const removeInstance = (instance: ComponentInternalInstance): void => { /** 当前组件的方位 */ const placement: MessagePlacement | NotificationPlacement = getPlacement(instance) - /** - * @see Array.prototype.splice() https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/splice - */ - ; (instances[placement] as ComponentInternalInstance[]).splice( - getIndexByInstance(instance), - 1 - ) + /** + * @see Array.prototype.splice() https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/splice + */ + ;(instances[placement] as ComponentInternalInstance[]).splice( + getIndexByInstance(instance), + 1 + ) } /** @@ -170,7 +170,7 @@ export const useMessage = ( const placement: MessagePlacement | NotificationPlacement = getPlacement(instance) if (instances[placement]) { - // 如果对象中存在当前方位数组,则往数组中追加组件实例 + // 如果对象中存在当前方位数组,则往数组中追加组件实例 (instances[placement] as ComponentInternalInstance[]).push(instance) } else { // 否则新建一个数组存储当前组件实例 @@ -192,7 +192,7 @@ export const useMessage = ( /** 获取到当前方位的组件实例集合 */ const placementInstance: ComponentInternalInstance[] | undefined = instances[ - options.placement ? options.placement : name === 'message' ? 'top' : 'top-right' + options.placement ? options.placement : name === 'message' ? 'top' : 'top-right' ] if (placementInstance) { @@ -267,7 +267,7 @@ export const useMessage = ( ...options } - // 如果传入的时间不是一个数字,则强制修改成为数字类型 + // 如果传入的时间不是一个数字,则强制修改成为数字类型 if (!isNumber(defaultOptions.duration)) { defaultOptions.duration = 2500 diff --git a/packages/fighting-design/_hooks/use-page/index.ts b/packages/fighting-design/_hooks/use-page/index.ts index 8ec82081d8..5759d92b46 100644 --- a/packages/fighting-design/_hooks/use-page/index.ts +++ b/packages/fighting-design/_hooks/use-page/index.ts @@ -122,7 +122,7 @@ export const usePage = ( /** 翻页映射方法 */ const changeMap = { - /** + /** * 下一页切换 */ next: () => { diff --git a/packages/fighting-design/_utils/is/__test__/utils.spec.ts b/packages/fighting-design/_utils/is/__test__/utils.spec.ts index 0facd41e37..295cb346d6 100644 --- a/packages/fighting-design/_utils/is/__test__/utils.spec.ts +++ b/packages/fighting-design/_utils/is/__test__/utils.spec.ts @@ -1,5 +1,14 @@ import { expect, test } from 'vitest' -import { isDate, isString, isNumber, isBoolean, isObject, isFunction, isArray, isTrue } from '..' +import { + isDate, + isString, + isNumber, + isBoolean, + isObject, + isFunction, + isArray, + isTrue +} from '..' test('isDate', () => { expect(isDate(1)).toBe(false) @@ -13,21 +22,21 @@ test('isDate', () => { expect(isDate(new Set())).toBe(false) expect(isDate(Date())).toBe(false) expect(isDate(new Date())).toBe(true) - expect(isDate(new Date)).toBe(true) + expect(isDate(new Date())).toBe(true) expect(isDate(Date)).toBe(false) }) test('isString', () => { expect(isString(1)).toBe(false) expect(isString('2024')).toBe(true) - expect(isString(`2024`)).toBe(true) + expect(isString('2024')).toBe(true) expect(isString(true)).toBe(false) expect(isString(null)).toBe(false) expect(isString(void 0)).toBe(false) expect(isString({})).toBe(false) expect(isString([])).toBe(false) expect(isString(new Set())).toBe(false) - expect(isString(new Date)).toBe(false) + expect(isString(new Date())).toBe(false) expect(isString(Date)).toBe(false) }) @@ -36,14 +45,14 @@ test('isNumber', () => { expect(isNumber(1.111)).toBe(true) expect(isNumber(NaN)).toBe(false) expect(isNumber('2024')).toBe(false) - expect(isNumber(`2024`)).toBe(false) + expect(isNumber('2024')).toBe(false) expect(isNumber(false)).toBe(false) expect(isNumber(null)).toBe(false) expect(isNumber(void 0)).toBe(false) expect(isNumber({})).toBe(false) expect(isNumber([])).toBe(false) expect(isNumber(new Set())).toBe(false) - expect(isNumber(new Date)).toBe(false) + expect(isNumber(new Date())).toBe(false) expect(isNumber(Date)).toBe(false) }) @@ -52,7 +61,7 @@ test('isBoolean', () => { expect(isBoolean(1.111)).toBe(false) expect(isBoolean(NaN)).toBe(false) expect(isBoolean('2024')).toBe(false) - expect(isBoolean(`2024`)).toBe(false) + expect(isBoolean('2024')).toBe(false) expect(isBoolean(false)).toBe(true) expect(isBoolean(true)).toBe(true) expect(isBoolean(null)).toBe(false) @@ -61,28 +70,28 @@ test('isBoolean', () => { expect(isBoolean({})).toBe(false) expect(isBoolean([])).toBe(false) expect(isBoolean(new Set())).toBe(false) - expect(isBoolean(new Date)).toBe(false) + expect(isBoolean(new Date())).toBe(false) expect(isBoolean(Date)).toBe(false) }) -class User { } +class User {} test('isObject', () => { expect(isObject(1)).toBe(false) expect(isObject(1.111)).toBe(false) expect(isObject(NaN)).toBe(false) expect(isObject('2024')).toBe(false) - expect(isObject(`2024`)).toBe(false) + expect(isObject('2024')).toBe(false) expect(isObject(false)).toBe(false) expect(isObject(true)).toBe(false) expect(isObject(null)).toBe(false) expect(isObject(!null)).toBe(false) expect(isObject(void 0)).toBe(false) expect(isObject({})).toBe(true) - expect(isObject(new User)).toBe(true) + expect(isObject(new User())).toBe(true) expect(isObject([])).toBe(false) expect(isObject(new Set())).toBe(false) - expect(isObject(new Date)).toBe(false) + expect(isObject(new Date())).toBe(false) expect(isObject(Date)).toBe(false) }) @@ -91,22 +100,22 @@ test('isFunction', () => { expect(isFunction(1.111)).toBe(false) expect(isFunction(NaN)).toBe(false) expect(isFunction('2024')).toBe(false) - expect(isFunction(`2024`)).toBe(false) + expect(isFunction('2024')).toBe(false) expect(isFunction(false)).toBe(false) expect(isFunction(true)).toBe(false) expect(isFunction(null)).toBe(false) expect(isFunction(!null)).toBe(false) expect(isFunction(void 0)).toBe(false) expect(isFunction({})).toBe(false) - expect(isFunction(new User)).toBe(false) + expect(isFunction(new User())).toBe(false) expect(isFunction([])).toBe(false) expect(isFunction(new Set())).toBe(false) - expect(isFunction(new Date)).toBe(false) + expect(isFunction(new Date())).toBe(false) expect(isFunction(Date)).toBe(true) expect(isFunction(new Function())).toBe(true) - expect(isFunction(new Function)).toBe(true) - expect(isFunction(() => { })).toBe(true) - expect(isFunction(function () { })).toBe(true) + expect(isFunction(new Function())).toBe(true) + expect(isFunction(() => {})).toBe(true) + expect(isFunction(function () {})).toBe(true) }) test('isArray', () => { @@ -114,22 +123,22 @@ test('isArray', () => { expect(isArray(1.111)).toBe(false) expect(isArray(NaN)).toBe(false) expect(isArray('2024')).toBe(false) - expect(isArray(`2024`)).toBe(false) + expect(isArray('2024')).toBe(false) expect(isArray(false)).toBe(false) expect(isArray(true)).toBe(false) expect(isArray(null)).toBe(false) expect(isArray(!null)).toBe(false) expect(isArray(void 0)).toBe(false) expect(isArray({})).toBe(false) - expect(isArray(new User)).toBe(false) + expect(isArray(new User())).toBe(false) + expect(isArray([])).toBe(true) + expect(isArray([])).toBe(true) expect(isArray([])).toBe(true) - expect(isArray(new Array)).toBe(true) - expect(isArray(new Array)).toBe(true) expect(isArray(new Set())).toBe(false) - expect(isArray(new Date)).toBe(false) + expect(isArray(new Date())).toBe(false) expect(isArray(Date)).toBe(false) - expect(isArray(() => { })).toBe(false) - expect(isArray(function () { })).toBe(false) + expect(isArray(() => {})).toBe(false) + expect(isArray(function () {})).toBe(false) }) test('isTrue', () => { @@ -137,20 +146,20 @@ test('isTrue', () => { expect(isTrue(1.111)).toBe(true) expect(isTrue(NaN)).toBe(false) expect(isTrue('2024')).toBe(true) - expect(isTrue(`2024`)).toBe(true) + expect(isTrue('2024')).toBe(true) expect(isTrue(false)).toBe(true) expect(isTrue(true)).toBe(true) expect(isTrue(null)).toBe(false) expect(isTrue(!null)).toBe(true) expect(isTrue(void 0)).toBe(false) expect(isTrue({})).toBe(true) - expect(isTrue(new User)).toBe(true) + expect(isTrue(new User())).toBe(true) + expect(isTrue([])).toBe(true) + expect(isTrue([])).toBe(true) expect(isTrue([])).toBe(true) - expect(isTrue(new Array)).toBe(true) - expect(isTrue(new Array)).toBe(true) expect(isTrue(new Set())).toBe(true) - expect(isTrue(new Date)).toBe(true) + expect(isTrue(new Date())).toBe(true) expect(isTrue(Date)).toBe(true) - expect(isTrue(() => { })).toBe(true) - expect(isTrue(function () { })).toBe(true) -}) \ No newline at end of file + expect(isTrue(() => {})).toBe(true) + expect(isTrue(function () {})).toBe(true) +}) diff --git a/packages/fighting-design/_utils/is/index.ts b/packages/fighting-design/_utils/is/index.ts index 91c0c2c606..a431267247 100644 --- a/packages/fighting-design/_utils/is/index.ts +++ b/packages/fighting-design/_utils/is/index.ts @@ -27,9 +27,9 @@ export const isString = (value: any): value is string => typeof value === 'strin /** * 检测一个数据是否为 number 类型 - * + * * 千万不要使用 isNaN - * + * * isNaN({}) -> true * Number.isNaN({}) -> false * @@ -71,11 +71,11 @@ export const isBrowser: boolean = typeof window !== void 0 /** * 是否为真值 - * + * * 这里的规则只是按断是非不为 NaN、undefined、null 的值都为真 - * + * * 千万不要使用 isNaN - * + * * isNaN({}) -> true * Number.isNaN({}) -> false * diff --git a/packages/fighting-design/_utils/utils/__test__/utils.spec.ts b/packages/fighting-design/_utils/utils/__test__/utils.spec.ts index 20fdf2cb83..57636877c6 100644 --- a/packages/fighting-design/_utils/utils/__test__/utils.spec.ts +++ b/packages/fighting-design/_utils/utils/__test__/utils.spec.ts @@ -1,5 +1,12 @@ import { expect, test } from 'vitest' -import { financial, zeroPad, convertSize, sizeToNum, convertFormat, splitString } from '..' +import { + financial, + zeroPad, + convertSize, + sizeToNum, + convertFormat, + splitString +} from '..' test('financial', () => { expect(financial(1.2222)).toBe(1.22) diff --git a/packages/fighting-design/_utils/utils/index.ts b/packages/fighting-design/_utils/utils/index.ts index 4fef36d197..9dc4e71a6f 100644 --- a/packages/fighting-design/_utils/utils/index.ts +++ b/packages/fighting-design/_utils/utils/index.ts @@ -114,14 +114,17 @@ const convertFormatRegExp = /([A-Z])/g * @returns { string } 短横线命名 */ export const convertFormat = (str: string): string => { - return str.replace(convertFormatRegExp, (_: string, p1: string, offset: number): string => { - // 判断是否为首字母,如果首字母大写的话就不加 - - if (offset === 0) { - return p1.toLowerCase() + return str.replace( + convertFormatRegExp, + (_: string, p1: string, offset: number): string => { + // 判断是否为首字母,如果首字母大写的话就不加 - + if (offset === 0) { + return p1.toLowerCase() + } + + return '-' + p1.toLowerCase() } - - return '-' + p1.toLowerCase() - }) + ) } /** diff --git a/packages/fighting-design/alert/__test__/alert.spec.ts b/packages/fighting-design/alert/__test__/alert.spec.ts index 77d02f78b1..23b934bab6 100644 --- a/packages/fighting-design/alert/__test__/alert.spec.ts +++ b/packages/fighting-design/alert/__test__/alert.spec.ts @@ -156,7 +156,7 @@ describe('FAlert', () => { test('closeIcon', () => { const wrapper = mount(FAlert, { - props: { + props: { close: true, closeIcon: markRaw(FIconFaceSmile) } diff --git a/packages/fighting-design/button/__test__/button.spec.ts b/packages/fighting-design/button/__test__/button.spec.ts index 0c547d30a0..f60b976d7b 100644 --- a/packages/fighting-design/button/__test__/button.spec.ts +++ b/packages/fighting-design/button/__test__/button.spec.ts @@ -103,7 +103,9 @@ describe('FButton', () => { const wrapper = mount(FButton, { props: { loading: true } }) - expect(wrapper.findComponent(FSvgIcon).classes()).toContain('f-button__loading-animation') + expect(wrapper.findComponent(FSvgIcon).classes()).toContain( + 'f-button__loading-animation' + ) }) test('disabled', () => { @@ -193,7 +195,9 @@ describe('FButton', () => { props: { ripples: true, ripplesColor: 'green' } }) wrapper.trigger('click') - expect(wrapper.find('.f-button__ripples').attributes('style')).toContain('background: green') + expect(wrapper.find('.f-button__ripples').attributes('style')).toContain( + 'background: green' + ) }) test('nativeType', () => { diff --git a/packages/fighting-design/calendar/__test__/calendar.spec.ts b/packages/fighting-design/calendar/__test__/calendar.spec.ts index b325ec5940..cbdc617e0f 100644 --- a/packages/fighting-design/calendar/__test__/calendar.spec.ts +++ b/packages/fighting-design/calendar/__test__/calendar.spec.ts @@ -4,58 +4,51 @@ import { FCalendar } from '../index' describe('Calendar', () => { test('class', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date() } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date() } + }) expect(wrapper.classes()).toContain('f-calendar') }) test('border', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), border: true } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), border: true } + }) expect(wrapper.classes()).toContain('f-calendar__border') }) test('borderColor', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), border: true, borderColor: 'red' } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), border: true, borderColor: 'red' } + }) expect(wrapper.attributes('style')).toContain('--calendar-border-color: red') }) test('dayCellHeight', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), dayCellHeight: '20px' } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), dayCellHeight: '20px' } + }) expect(wrapper.attributes('style')).toContain('--calendar-day-cell-height: 20px') }) test('dayCellHeight', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), dayCellHeight: 44 } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), dayCellHeight: 44 } + }) expect(wrapper.attributes('style')).toContain('--calendar-day-cell-height: 44px') }) test('weekCellHeight', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), weekCellHeight: '20px' } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), weekCellHeight: '20px' } + }) expect(wrapper.attributes('style')).toContain('--calendar-week-cell-height: 20px') }) test('weekCellHeight', () => { - const wrapper = mount(FCalendar, - { - props: { date: new Date(), weekCellHeight: 44 } - }) + const wrapper = mount(FCalendar, { + props: { date: new Date(), weekCellHeight: 44 } + }) expect(wrapper.attributes('style')).toContain('--calendar-week-cell-height: 44px') }) }) diff --git a/packages/fighting-design/card/__test__/card.spec.ts b/packages/fighting-design/card/__test__/card.spec.ts index 1fb4e59b8b..4a0146d168 100644 --- a/packages/fighting-design/card/__test__/card.spec.ts +++ b/packages/fighting-design/card/__test__/card.spec.ts @@ -8,7 +8,7 @@ describe('FCard', () => { const wrapper = mount(FCard) expect(wrapper.find('div').classes()).toContain('f-card') }) - + test('title', () => { const wrapper = mount(FCard, { props: { title: '这是卡片标题' } @@ -52,21 +52,27 @@ describe('FCard', () => { const wrapper = mount(FCard, { props: { borderColor: 'red' } }) - expect(wrapper.find('.f-card').attributes('style')).toContain('--card-border-color: red') + expect(wrapper.find('.f-card').attributes('style')).toContain( + '--card-border-color: red' + ) }) test('background', () => { const wrapper = mount(FCard, { props: { background: 'red' } }) - expect(wrapper.find('.f-card').attributes('style')).toContain('--card-background: red') + expect(wrapper.find('.f-card').attributes('style')).toContain( + '--card-background: red' + ) }) test('titleColor', () => { const wrapper = mount(FCard, { props: { titleColor: 'red' } }) - expect(wrapper.find('.f-card').attributes('style')).toContain('--card-title-color: red') + expect(wrapper.find('.f-card').attributes('style')).toContain( + '--card-title-color: red' + ) }) test('titleBold', () => { diff --git a/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts b/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts index e387517095..9814d18fd3 100644 --- a/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts +++ b/packages/fighting-design/checkbox-group/__test__/checkbox-group.spec.ts @@ -19,7 +19,7 @@ const getWrapper = (props = '', options = {}) => { FCheckbox, FCheckboxGroup }, - setup() { + setup () { return { labelList, checkList, @@ -38,7 +38,7 @@ const getWrapper = (props = '', options = {}) => { return wrapper } -describe('FCheckboxGroup', () => { +describe('FCheckboxGroup', () => { test('create', () => { const wrapper = getWrapper() expect(wrapper.classes()).toContain('f-checkbox-group') @@ -82,7 +82,9 @@ describe('FCheckboxGroup', () => { test('columnGap', () => { const wrapper = getWrapper(':columnGap=50') - expect(wrapper.get('.f-checkbox-group').attributes('style')).toContain('--checkbox-group-column-gap: 50px') + expect(wrapper.get('.f-checkbox-group').attributes('style')).toContain( + '--checkbox-group-column-gap: 50px' + ) }) test('rowGap', () => { diff --git a/packages/fighting-design/close-btn/__test__/close-btn.spec.ts b/packages/fighting-design/close-btn/__test__/close-btn.spec.ts index 9061c7056b..0472abb7d8 100644 --- a/packages/fighting-design/close-btn/__test__/close-btn.spec.ts +++ b/packages/fighting-design/close-btn/__test__/close-btn.spec.ts @@ -4,7 +4,7 @@ import { vi, describe, expect, test } from 'vitest' import { FIconCross } from '@fighting-design/fighting-icon' import { FCloseBtn } from '../index' -describe('CloseBtn', () => { +describe('CloseBtn', () => { test('create', () => { const wrapper = mount(FCloseBtn) expect(wrapper.classes()).toContain('f-close-btn') @@ -13,11 +13,13 @@ describe('CloseBtn', () => { test('size prop supports both number and string types', () => { const size = 100 const sizeList = [size, `${size}px`] - sizeList.forEach((item) => { + sizeList.forEach(item => { const wrapper = mount(FCloseBtn, { props: { size: item } }) - expect(wrapper.find('.f-svg-icon').attributes('style')).toContain(`--svg-icon-size: ${size}px`) + expect(wrapper.find('.f-svg-icon').attributes('style')).toContain( + `--svg-icon-size: ${size}px` + ) }) }) diff --git a/packages/fighting-design/input/__test__/input.spec.ts b/packages/fighting-design/input/__test__/input.spec.ts index 128746dcaf..6670a7ddee 100644 --- a/packages/fighting-design/input/__test__/input.spec.ts +++ b/packages/fighting-design/input/__test__/input.spec.ts @@ -16,7 +16,7 @@ describe('Input', () => { test('v-model', async () => { const wrapper = mount(FInput, { - props: { + props: { modelValue: 'initialText', 'onUpdate:modelValue': (val: string | number) => { wrapper.setProps({ modelValue: val }) @@ -49,7 +49,7 @@ describe('Input', () => { test('disabled', async () => { const wrapper = mount(FInput, { props: { - disabled: true, + disabled: true } }) expect(wrapper.classes()).toContain('f-input__disabled') @@ -106,12 +106,11 @@ describe('Input', () => { test('fontSize', () => { const fontSize = 14 const fontSizeList: [number, string] = [fontSize, `${fontSize}px`] - fontSizeList.forEach((item) => { + fontSizeList.forEach(item => { const wrapper = mount(FInput, { props: { fontSize: item } }) expect(wrapper.attributes('style')).toContain(`--input-font-size: ${fontSize}px`) - }) }) @@ -125,7 +124,7 @@ describe('Input', () => { test('width', () => { const width = 100 const widthList: [number, string] = [width, `${width}px`] - widthList.forEach((item) => { + widthList.forEach(item => { const wrapper = mount(FInput, { props: { width: item } }) @@ -136,7 +135,7 @@ describe('Input', () => { test('height', () => { const height = 100 const heightList: [number, string] = [height, `${height}px`] - heightList.forEach((item) => { + heightList.forEach(item => { const wrapper = mount(FInput, { props: { height: item } }) @@ -168,7 +167,7 @@ describe('Input', () => { test('clicking the search button should invoke `onSearch` callback', async () => { const modelValue = 'test' - const onSearch = vi.fn((val: string, evt: Event) => val) + const onSearch = vi.fn((val: string) => val) const wrapper = mount(FInput, { props: { onSearch, @@ -221,7 +220,7 @@ describe('Input', () => { test('pressing the enter key should invoke `onEnter` callback', async () => { const modelValue = 'test' - const onEnter = vi.fn((val: string, evt: Event) => val) + const onEnter = vi.fn((val: string) => val) const wrapper = mount(FInput, { props: { modelValue, @@ -234,10 +233,10 @@ describe('Input', () => { }) test('onChange', async () => { - const onChange = vi.fn((val: number | string, evt: Event) => val) + const onChange = vi.fn((val: number | string) => val) const wrapper = mount(FInput, { props: { - onChange, + onChange } }) await wrapper.find('input').setValue('test') @@ -246,7 +245,7 @@ describe('Input', () => { }) test('onInput', async () => { - const onInput = vi.fn((val: number | string, evt: Event) => val) + const onInput = vi.fn((val: number | string) => val) const wrapper = mount(FInput, { props: { onInput } }) @@ -294,7 +293,7 @@ describe('Input', () => { test('should render searchBtn slot', () => { const wrapper = mount(FInput, { props: { - search: true, + search: true }, slots: { searchBtn: 'searchBtn slot' diff --git a/packages/fighting-design/layout/__test__/layout.spec.ts b/packages/fighting-design/layout/__test__/layout.spec.ts index 783fa51c2e..5ee9cbd481 100644 --- a/packages/fighting-design/layout/__test__/layout.spec.ts +++ b/packages/fighting-design/layout/__test__/layout.spec.ts @@ -39,7 +39,7 @@ describe('f-layout', () => { }) test('slot', () => { - const wrapper = mount(FLayout, { + const wrapper = mount(FLayout, { slots: { default: 'hello' } }) expect(wrapper.text()).toBe('hello') diff --git a/packages/fighting-design/layout/src/props.ts b/packages/fighting-design/layout/src/props.ts index f6785b0b23..c48b32a740 100644 --- a/packages/fighting-design/layout/src/props.ts +++ b/packages/fighting-design/layout/src/props.ts @@ -8,12 +8,9 @@ export const Props = { * * @values horizontal vertical */ - direction: setStringProp( - void 0, - (val: LayoutDirection): boolean => { - return (['horizontal', 'vertical'] as const).includes(val) - } - ) + direction: setStringProp(void 0, (val: LayoutDirection): boolean => { + return (['horizontal', 'vertical'] as const).includes(val) + }) } as const /** layout 组件 props 类型 */ diff --git a/packages/fighting-design/message/__test__/message.spec.ts b/packages/fighting-design/message/__test__/message.spec.ts index 1f5a399f85..141498feaa 100644 --- a/packages/fighting-design/message/__test__/message.spec.ts +++ b/packages/fighting-design/message/__test__/message.spec.ts @@ -10,15 +10,17 @@ import type { ComponentPublicInstance } from 'vue' const AXIOM = 'The electric light dancing at your fingertips is my unchanging faith' -type MessageInstance = ComponentPublicInstance +type MessageInstance = ComponentPublicInstance< + MessageProps & { + visible: boolean + } +> describe('FMessage', () => { test('basic render', async () => { const wrapper = mount(FMessageVue, { props: { - message: AXIOM, + message: AXIOM } }) expect(wrapper.find('.f-message').exists()).toBe(true) @@ -36,7 +38,7 @@ describe('FMessage', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((type) => { + FIGHTING_TYPE.forEach(type => { const wrapper = mount(FMessageVue, { props: { type @@ -70,7 +72,9 @@ describe('FMessage', () => { color: 'red' } }) - expect(wrapper.find('.f-message').attributes('style')).toContain('--message-color: red') + expect(wrapper.find('.f-message').attributes('style')).toContain( + '--message-color: red' + ) }) test('background', () => { @@ -79,7 +83,9 @@ describe('FMessage', () => { background: 'red' } }) - expect(wrapper.find('.f-message').attributes('style')).toContain('--message-background: red') + expect(wrapper.find('.f-message').attributes('style')).toContain( + '--message-background: red' + ) }) test('offset', () => { @@ -97,12 +103,21 @@ describe('FMessage', () => { zIndex: 100 } }) - expect(wrapper.find('.f-message').attributes('style')).toContain('--message-z-index: 100') + expect(wrapper.find('.f-message').attributes('style')).toContain( + '--message-z-index: 100' + ) }) test('placement', () => { - const messagePlacement: MessagePlacement[] = ['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right'] - messagePlacement.forEach((placement) => { + const messagePlacement: MessagePlacement[] = [ + 'top', + 'top-left', + 'top-right', + 'bottom', + 'bottom-left', + 'bottom-right' + ] + messagePlacement.forEach(placement => { const wrapper = mount(FMessageVue, { props: { placement diff --git a/packages/fighting-design/notification/__test__/notification.spec.ts b/packages/fighting-design/notification/__test__/notification.spec.ts index def69c4ffa..57c41f2dc0 100644 --- a/packages/fighting-design/notification/__test__/notification.spec.ts +++ b/packages/fighting-design/notification/__test__/notification.spec.ts @@ -11,16 +11,18 @@ import type { ComponentPublicInstance } from 'vue' const NAME = 'Mikoto Misaka' const AXIOM = 'The electric light dancing at your fingertips is my unchanging faith' -type NotificationInstance = ComponentPublicInstance +type NotificationInstance = ComponentPublicInstance< + NotificationProps & { + visible: boolean + } +> -describe('FNotification', () => { +describe('FNotification', () => { test('basic render', async () => { const wrapper = mount(FNotificationVue, { props: { title: NAME, - message: AXIOM, + message: AXIOM } }) expect(wrapper.find('.f-notification').exists()).toBe(true) @@ -48,7 +50,7 @@ describe('FNotification', () => { }) test('type', () => { - FIGHTING_TYPE.forEach((type) => { + FIGHTING_TYPE.forEach(type => { const wrapper = mount(FNotificationVue, { props: { type @@ -82,7 +84,9 @@ describe('FNotification', () => { color: 'red' } }) - expect(wrapper.find('.f-notification').attributes('style')).toContain('--notification-color: red') + expect(wrapper.find('.f-notification').attributes('style')).toContain( + '--notification-color: red' + ) }) test('background', () => { @@ -91,7 +95,9 @@ describe('FNotification', () => { background: 'red' } }) - expect(wrapper.find('.f-notification').attributes('style')).toContain('--notification-background: red') + expect(wrapper.find('.f-notification').attributes('style')).toContain( + '--notification-background: red' + ) }) test('offset', () => { @@ -109,18 +115,27 @@ describe('FNotification', () => { zIndex: 100 } }) - expect(wrapper.find('.f-notification').attributes('style')).toContain('--notification-z-index: 100') + expect(wrapper.find('.f-notification').attributes('style')).toContain( + '--notification-z-index: 100' + ) }) test('placement', () => { - const notificationPlacement: NotificationPlacement[] = ['top-left', 'top-right', 'bottom-left', 'bottom-right'] - notificationPlacement.forEach((placement) => { + const notificationPlacement: NotificationPlacement[] = [ + 'top-left', + 'top-right', + 'bottom-left', + 'bottom-right' + ] + notificationPlacement.forEach(placement => { const wrapper = mount(FNotificationVue, { props: { placement } }) - expect(wrapper.find('.f-notification').classes()).toContain(`f-notification__${placement}`) + expect(wrapper.find('.f-notification').classes()).toContain( + `f-notification__${placement}` + ) }) }) diff --git a/packages/fighting-design/number-animate/__test__/number-animate.spec.ts b/packages/fighting-design/number-animate/__test__/number-animate.spec.ts index 98522baefe..1bcba7bc30 100644 --- a/packages/fighting-design/number-animate/__test__/number-animate.spec.ts +++ b/packages/fighting-design/number-animate/__test__/number-animate.spec.ts @@ -4,9 +4,7 @@ import { FNumberAnimate } from '../index' describe('FNumberAnimate', () => { test('class', () => { - const wrapper = mount(FNumberAnimate, - { props: { form: 0, to: 20 } } - ) + const wrapper = mount(FNumberAnimate, { props: { form: 0, to: 20 } }) expect(wrapper.classes()).toContain('f-number-animate') }) }) diff --git a/packages/fighting-design/package.json b/packages/fighting-design/package.json index 9c8118c327..6b5b78e6e7 100644 --- a/packages/fighting-design/package.json +++ b/packages/fighting-design/package.json @@ -58,4 +58,4 @@ }, "homepage": "https://fighting.tianyuhao.cn", "repository": "https://github.com/FightingDesign/fighting-design" -} \ No newline at end of file +} diff --git a/packages/fighting-design/radio-group/__test__/radio-group.spec.ts b/packages/fighting-design/radio-group/__test__/radio-group.spec.ts index d8b6b89ed3..da8cc0d873 100644 --- a/packages/fighting-design/radio-group/__test__/radio-group.spec.ts +++ b/packages/fighting-design/radio-group/__test__/radio-group.spec.ts @@ -18,7 +18,7 @@ const getWrapper = (props = '', options = {}) => { FRadio, FRadioGroup }, - setup() { + setup () { return { labelList, selectedRadio, @@ -72,7 +72,7 @@ describe('RadioGroup', () => { }) test('size', () => { - FIGHTING_SIZE.forEach((item) => { + FIGHTING_SIZE.forEach(item => { const wrapper = getWrapper(`size=${item}`) expect(wrapper.classes()).toContain(`f-radio-group__${item}`) }) @@ -80,7 +80,9 @@ describe('RadioGroup', () => { test('columnGap', () => { const wrapper = getWrapper(':columnGap=50') - expect(wrapper.get('.f-radio-group').attributes('style')).toContain('--radio-group-column-gap: 50px') + expect(wrapper.get('.f-radio-group').attributes('style')).toContain( + '--radio-group-column-gap: 50px' + ) }) test('rowGap', () => { diff --git a/packages/fighting-design/radio/__test__/radio.spec.ts b/packages/fighting-design/radio/__test__/radio.spec.ts index 81fbd4dcfc..b91f65c323 100644 --- a/packages/fighting-design/radio/__test__/radio.spec.ts +++ b/packages/fighting-design/radio/__test__/radio.spec.ts @@ -65,7 +65,7 @@ describe('FRadio', () => { props: { modelValue: '', label: '1', - onChange, + onChange } }) await wrapper.trigger('click') diff --git a/packages/fighting-design/rate/__test__/rate.spec.ts b/packages/fighting-design/rate/__test__/rate.spec.ts index 1e4620ae7b..2ecc750176 100644 --- a/packages/fighting-design/rate/__test__/rate.spec.ts +++ b/packages/fighting-design/rate/__test__/rate.spec.ts @@ -16,7 +16,7 @@ describe('FRate', () => { test('clicking the star should be reactive', async () => { const wrapper = mount(FRate, { - props: { + props: { modelValue: 2, 'onUpdate:modelValue': (val: number) => { wrapper.setProps({ modelValue: val }) @@ -50,7 +50,7 @@ describe('FRate', () => { modelValue: activeStarCount } }) - wrapper.findAll('.f-svg-icon').forEach((itemWrapper, index)=> { + wrapper.findAll('.f-svg-icon').forEach((itemWrapper, index) => { if (index < activeStarCount) { expect(itemWrapper.attributes('style')).toContain('--svg-icon-color: red') } @@ -65,7 +65,7 @@ describe('FRate', () => { modelValue: activeStarCount } }) - wrapper.findAll('.f-svg-icon').forEach((itemWrapper, index)=> { + wrapper.findAll('.f-svg-icon').forEach((itemWrapper, index) => { if (index >= activeStarCount) { expect(itemWrapper.attributes('style')).toContain('--svg-icon-color: #eee') } @@ -83,7 +83,7 @@ describe('FRate', () => { const activeStarCount = 2 const wrapper = mount(FRate, { props: { - readonly: true, + readonly: true, modelValue: activeStarCount, 'onUpdate:modelValue': (val: number) => { wrapper.setProps({ modelValue: val }) @@ -108,7 +108,9 @@ describe('FRate', () => { const wrapper = mount(FRate, { props: { size: 20 } }) - expect(wrapper.find('.f-svg-icon').attributes('style')).toContain('--svg-icon-size: 20px') + expect(wrapper.find('.f-svg-icon').attributes('style')).toContain( + '--svg-icon-size: 20px' + ) }) test('textShow', async () => { diff --git a/packages/fighting-design/svg-icon/src/svg-icon.vue b/packages/fighting-design/svg-icon/src/svg-icon.vue index 84ac5b3126..c8daf2f7d8 100644 --- a/packages/fighting-design/svg-icon/src/svg-icon.vue +++ b/packages/fighting-design/svg-icon/src/svg-icon.vue @@ -23,7 +23,13 @@