修复打包,发布报错等问题,调整类型声明等问题 (#108)

* fix(tiny-loading): 修复loading组件在vue2.0版本报错bug

* fix(build):  修复打包报错

* feat(build): 添加vue2和vue3版本发布脚本

* fix(build):修复svg图标打包失败bug

* fix(build): 修复icon打包失败问题

* fix(build): 修复icon打包失败问题

* fix(build): svg图标也添加类型声明

* fix(build): 修改package.json 包名

* fix(type): 修复form等组件类型声明文件生成失败问题

* fix(type): 修复common和locale类型声明文件生成失败问题

* fix(type): 修复less没有转化成功地问题

* fix(type): 修复icon文件名称后缀错误,修复echarts依赖丢失问题

* fix(type): 修复类型声明文件生成错误bug

* fix(type): 修复file-upload组件缺少streamsaver依赖问题

* fix(type): 修复@better-scroll没有排除导致报错问题

* fix(type): 修复scrollbar打包报错问题

* fix(type): 修复grid-toolbar报错问题

* fix(type): 修复icon打包后使用报错的问题

* fix(build): 重构入口文件生成方法

* fix(type): renderless工程添加release脚本

* fix(type): 修复组件运行时报错

* fix(type): 修复组件运行时报错

* fix(type): 修复主入口package.json

* fix(type): 修复chart入口package.json

* fix(type): 修复loading组件类型声明报错问题

* fix(type): 添加声明文件配置

* fix(type): 修复vue2打包内联模块名称重复导致报错问题
This commit is contained in:
ajaxzheng 2023-04-06 02:01:16 -07:00 committed by GitHub
parent 501010d66e
commit f21d114a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 701 additions and 653 deletions

View File

@ -7,7 +7,7 @@ import dtsPlugin from 'vite-plugin-dts'
import vue3SvgPlugin from 'vite-svg-loader'
import { getAlias, pathFromWorkspaceRoot } from '../../config/vite.js'
import * as config from '../../shared/config.js'
import { getAllIcons, getAllModules, getByName, type Module } from '../../shared/module-utils.js'
import { getAllIcons, getAllModules, getByName, Module } from '../../shared/module-utils.js'
import * as utils from '../../shared/utils.js'
import generatePackageJsonPlugin from './rollup/generate-package-json.js'
import inlineChunksPlugin from './rollup/inline-chunks.js'
@ -22,10 +22,7 @@ export const getVuePlugins = (vueVersion: string) => {
'2': () => {
const vue2Plugin = requireModules('examples/vue2/node_modules/vite-plugin-vue2').createVuePlugin
const vue2SvgPlugin = requireModules('examples/vue2/node_modules/vite-plugin-vue2-svg').createSvgPlugin
return [
vue2Plugin({ jsx: true }),
vue2SvgPlugin(),
]
return [vue2Plugin({ jsx: true }), vue2SvgPlugin()]
},
'2.7': () => {
const vue27Plugin = requireModules('examples/vue2.7/node_modules/@vitejs/plugin-vue2')
@ -45,20 +42,16 @@ export const getVuePlugins = (vueVersion: string) => {
const vue3Plugin = requireModules('examples/vue3/node_modules/@vitejs/plugin-vue')
const vue3JsxPlugin = requireModules('examples/vue3/node_modules/@vitejs/plugin-vue-jsx')
return [
vue3Plugin(),
vue3JsxPlugin(),
vue3SvgPlugin({ defaultImport: 'component', svgoConfig: {} })
]
return [vue3Plugin(), vue3JsxPlugin(), vue3SvgPlugin({ defaultImport: 'component', svgoConfig: {} })]
}
}
return pluginMap[vueVersion]() || []
}
export const ns = ver => ({ '2': '', '2.7': '2', '3': '3' })[ver] || ''
export const ns = (ver) => ({ '2': '', '2.7': '2', '3': '3' }[ver] || '')
export const getBaseConfig = ({ vueVersion, dtsInclude, dts }) => {
export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget }) => {
// 处理tsconfig中配置主要是处理paths映射确保dts可以找到正确的包
const compilerOptions = require(pathFromWorkspaceRoot(`tsconfig.vue${vueVersion}.json`)).compilerOptions
@ -68,42 +61,80 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts }) => {
// pc和mobile的总入口可能是/src/index.ts或者/src/index.vue
virtualTemplatePlugin({ include: ['**/packages/vue/**/src/index.ts', '**/packages/vue/**/src/index.vue'] }),
...getVuePlugins(vueVersion),
dts ?
dtsPlugin({
root: pathFromWorkspaceRoot(),
tsConfigFilePath: `tsconfig.vue${vueVersion}.json`,
compilerOptions: {
paths: {
...compilerOptions.paths,
// 一定要映射到 packages/vue 下对应的 vue 版本和 @vue/composition-api 才能正确生成 dts
'vue': [`packages/vue/node_modules/vue${vueVersion}`],
'@vue/runtime-core': ['packages/vue/node_modules/@vue/runtime-core'],
'@vue/runtime-dom': ['packages/vue/node_modules/@vue/runtime-dom'],
'@vue/composition-api': ['packages/vue/node_modules/@vue/composition-api'],
dts
? dtsPlugin({
root: pathFromWorkspaceRoot(),
tsConfigFilePath: `tsconfig.vue${vueVersion}.json`,
aliasesExclude: [/@opentiny\/vue.+/],
compilerOptions: {
paths: {
...compilerOptions.paths,
// 一定要映射到 packages/vue 下对应的 vue 版本和 @vue/composition-api 才能正确生成 dts
'vue': [`packages/vue/node_modules/vue${vueVersion}`],
'@vue/runtime-core': ['packages/vue/node_modules/@vue/runtime-core'],
'@vue/runtime-dom': ['packages/vue/node_modules/@vue/runtime-dom'],
'@vue/composition-api': ['packages/vue/node_modules/@vue/composition-api']
}
},
include: [...dtsInclude, 'packages/vue/*.d.ts'],
// 忽略类型检查错误,保证生成不会阻断
skipDiagnostics: true,
beforeWriteFile: (filePath, content) => {
return {
// "vue/src/alert/index.d.ts" ==> "alert/index.d.ts"
filePath: filePath.replace('/vue/src', '').replace('\\vue\\src', ''),
content: content
// vue 2.7 还不能正常识别 vue-common
.replace(/import\('[./]+vue-common.+'\)/, 'import("vue")')
.replace(/\("vue[1-9\.]+/g, '("vue')
}
}
},
include: [...dtsInclude, 'packages/vue/*.d.ts'],
skipDiagnostics: true,
beforeWriteFile: (filePath, content) => {
return {
// "vue/src/alert/index.d.ts" ==> "alert/index.d.ts"
filePath: filePath.replace('/vue/src', '').replace('\\vue\\src', ''),
content: content
// vue 2.7 还不能正常识别 vue-common
.replace(/import\('[./]+vue-common.+'\)/, 'import("vue")')
.replace(/\("vue[1-9\.]+/g, '("vue')
}
}
})
})
: undefined,
inlineChunksPlugin({ deleteInlinedFiles: true }),
generatePackageJsonPlugin({
beforeWriteFile: (filePath, content) => {
content.main = './lib/index.js'
const versionTarget = `${vueVersion}.${buildTarget}`
const themeAndRenderlessVersion = `3.${buildTarget}`
const isThemeOrRenderless = (key) =>
key.includes('@opentiny/vue-theme') || key.includes('@opentiny/vue-renderless')
const dependencies = {}
Object.entries(content.dependencies).forEach(([key, value]) => {
if (isThemeOrRenderless(key)) {
dependencies[key] = `~${themeAndRenderlessVersion}`
} else if ((value as string).includes('workspace:~')) {
dependencies[key] = `~${versionTarget}`
} else {
dependencies[key] = value
}
})
if (filePath.includes('vue-common') && vueVersion === '2') {
dependencies['@vue/composition-api'] = '~1.2.2'
}
// 如果是主入口或者svg图标则直接指向相同路径
if (filePath === 'vue-icon' || filePath === 'vue') {
content.main = './index.js'
} else {
content.main = './lib/index.js'
}
content.types = 'index.d.ts'
if (filePath.includes('vue-common') || filePath.includes('vue-locale')) {
content.types = './src/index.d.ts'
}
content.version = versionTarget
content.dependencies = dependencies
delete content.module
delete content.devDependencies
delete content.private
delete content.exports
return {
filePath: filePath.replace(/[\\/]lib$/, ''),
@ -117,7 +148,7 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts }) => {
extensions: ['.js', '.ts', '.tsx', '.vue'],
alias: {
...getAlias(vueVersion),
'@vue/babel-helper-vue-jsx-merge-props': 'node_modules/@vue/babel-helper-vue-jsx-merge-props/dist/helper.js',
'@vue/babel-helper-vue-jsx-merge-props': 'node_modules/@vue/babel-helper-vue-jsx-merge-props/dist/helper.js'
}
},
define: {
@ -126,7 +157,7 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts }) => {
})
}
async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts }) {
async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget }) {
const rootDir = pathFromPackages('')
const outDir = path.resolve(rootDir, `dist${vueVersion}/@opentiny`)
await batchBuild({
@ -150,9 +181,6 @@ async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir,
return new Set(
libs
.filter((item) => ['module', 'component'].includes(item.type))
// 不生成图标的 dts
.filter((item) => item.componentType !== 'icon')
.filter((item) => !item.path.includes('vue-icon'))
.map((lib) => `packages/${lib.dtsRoot ? lib.path : path.dirname(lib.path)}`)
)
}
@ -164,7 +192,7 @@ async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir,
const dtsInclude = toTsInclude(tasks)
await build({
configFile: false,
...getBaseConfig({ vueVersion, dtsInclude, dts }),
...getBaseConfig({ vueVersion, dtsInclude, dts, buildTarget }),
build: {
emptyOutDir,
minify: false,
@ -175,18 +203,30 @@ async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir,
})
],
external: (source, importer, isResolved) => {
if (isResolved || !importer) return false
// vite打包入口文件或者没有解析过得包不能排除依赖
if (isResolved || !importer) {
return false
}
// 图标入口排除子图标
if (/vue-icon\/(index|lowercase)/.test(importer)) {
return /^\.\//.test(source)
}
// 子图标排除周边引用, 这里注意不要排除svg图标
if (/vue-icon\/.+\/index/.test(importer)) {
return !/\.svg/.test(source)
}
if (/src\/index/.test(importer)) {
// 模块入口pc/mobile 文件要分离,同时排除 node_modules 依赖
return /^\.\/(pc|mobile)/.test(source) || config.external(source)
}
// 图标入口排除子图标
if (/vue-icon(-\w+)?\/index/.test(importer)) return /^\.\//.test(source)
// 子图标排除周边引用
if (/vue-icon(-\w+)?\/.+\/index/.test(importer)) return /^vue|@opentiny[\\/](vue)/.test(source)
// @opentiny/vue 入口
if (/vue\/(index|pc|mobile)\.ts$/.test(importer)) return true
// @opentiny/vue 总入口,需要排除所有依赖
if (/vue\/(index|pc|mobile)\.ts$/.test(importer)) {
return true
}
return config.external(source)
},
@ -203,13 +243,13 @@ async function batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir,
},
outDir
}
}
)
})
}
}
export interface BuildUiOption {
vueVersions: string[] // vue的版本
buildTarget: string // 目标版本,必填, 不需要major位因为需要同时打出vue2和vue3的包
formats: string[] // 打包的格式
clean: boolean // 是否清空build产物
dts: boolean // 是否生成TS类型声明文件
@ -219,14 +259,14 @@ export interface BuildUiOption {
function getEntryTasks(): Module[] {
// 读取TinyVue组件库入口文件
return ['index', 'pc', 'mobile'].map(mode => ({
return ['index', 'pc', 'mobile'].map((mode) => ({
path: `vue/${mode}.ts`,
dtsRoot: true,
libPath: `vue/${mode}`,
type: 'module',
name: utils.kebabCase({ str: '@opentiny/vue' }),
global: utils.capitalizeKebabCase('opentinyVue'),
importName: '@opentiny/vue',
importName: '@opentiny/vue'
}))
}
@ -236,10 +276,14 @@ function getTasks(names: string[]): Module[] {
return [...getAllModules(false), ...getEntryTasks()]
}
return names.map(name => getByName({
name: utils.kebabCase({ str: name.replace('@opentiny/vue-', '') }),
isSort: false
})).flat()
return names
.map((name) =>
getByName({
name: utils.kebabCase({ str: name.replace('@opentiny/vue-', '') }),
isSort: false
})
)
.flat()
}
/**
@ -249,32 +293,30 @@ function getTasks(names: string[]): Module[] {
* @param {BuildUiOption} buildUiOption BuildUiOption接口
*/
export async function buildUi(names: string[] = [], {
vueVersions = ['2', '3'],
formats = ['es'],
clean = false,
dts = true,
}: BuildUiOption) {
export async function buildUi(
names: string[] = [],
{ vueVersions = ['2', '3'], buildTarget = '8.0', formats = ['es'], clean = false, dts = true }: BuildUiOption
) {
// 是否清空构建目录
let emptyOutDir = clean
// 要构建的模块
let tasks = getTasks(names)
if (names.some(name => name.includes('icon'))) {
// 如果指定了打包icon或者没有传入任何组件
if (names.some((name) => name.includes('icon')) || !names.length) {
tasks.push(...getByName({ name: utils.kebabCase({ str: 'icon-saas' }), isSort: false }))
tasks.push(...getAllIcons())
}
// 构建 @opentiny/vue
if (names.some(name => ['@opentiny/vue', '@opentiny/vue', 'vue'].includes(name))) {
if (names.some((name) => ['@opentiny/vue', '@opentiny/vue', 'vue'].includes(name))) {
tasks.push(...getEntryTasks())
}
// 要构建的vue框架版本
for (const vueVersion of vueVersions) {
const message = `TINY for vue${vueVersion}: ${JSON.stringify(
names.length ? names : '全量'
)}`
await batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts })
const message = `TINY for vue${vueVersion}: ${JSON.stringify(names.length ? names : '全量')}`
await batchBuildAll({ vueVersion, tasks, formats, message, emptyOutDir, dts, buildTarget })
// 确保只运行一次
emptyOutDir = false
}

View File

@ -21,7 +21,9 @@ export default function ({ deleteInlinedFiles = true }): Plugin {
/^import\s*.+\s*from\s+"[./]+(.+-[a-f0-9]{8}.+)".*$/gim,
(_, chunkName) => {
if (!cache[chunkName]) {
cache[chunkName] = (bundle[chunkName] as OutputChunk).code.replace(/export {[\s\S]+$/, '')
cache[chunkName] = (bundle[chunkName] as OutputChunk).code
.replace(/export {[\s\S]+$/, '')
.replace(/_extends/g, '_extends_tiny')
bundlesToDelete.add(chunkName)
}

View File

@ -18,14 +18,14 @@ export default function (): Plugin {
const suffix = name.match(regexpStr)?.[1]
if (suffix) {
code = code.replace(
/".+\/src\/(pc|mobile)\.vue/g,
`"./$1.${suffix}`
)
code = code
.replace(/".+\/src\/(pc|mobile)\.vue/g, `"./$1.${suffix}`)
.replace(/\.\.\/src/g, './lib')
.replace('../lowercase', './lowercase')
}
// import "@opentiny/vue-theme-*/index.less"; 替换为 css
code = code.replace(/^(import.+@opentiny\/theme.+index)\.less/mg, '$1.css')
code = code.replace(/^(import.+@opentiny\/vue-theme.+index)\.less/gm, '$1.css')
// from "./src/xxx" 替换为 from "./lib/xxx"
code = code.replace(/from "\.\/src\//g, 'from "./lib/')

View File

@ -9,9 +9,14 @@
"type": "module",
"exclude": false
},
"IconLowercase": {
"path": "vue-icon/lowercase.ts",
"type": "module",
"exclude": false
},
"Common": {
"path": "vue-common/src/index.ts",
"type": "module",
"exclude": false
}
}
}

View File

@ -18,5 +18,9 @@ export function createIconSaas() {
fs.copySync(path.resolve(iconDir, item), path.resolve(iconSaasDir, item), { overwrite: true })
)
filesFragmentReplace(path.resolve(iconSaasDir, 'src'), [/@opentiny\/theme\/svgs\//g], ['@opentiny/vue-theme-saas/svgs/'])
filesFragmentReplace(
path.resolve(iconSaasDir, 'src'),
[/@opentiny\/vue-theme\/svgs\//g],
['@opentiny/vue-theme-saas/svgs/']
)
}

View File

@ -1,14 +1,25 @@
import path from 'node:path'
import * as utils from '../../shared/utils'
import { addModule, writeModuleMap, quickSort, readModuleMap } from '../../shared/module-utils'
import { writeModuleMap, quickSort } from '../../shared/module-utils'
import commonMapping from './commonMapping.json'
const isBuildEntryFile = (file, dirs, subPath) => {
// 如果底层文件夹内没有找到 vue 文件,找到 src//index.ts 文件也被认可为组件
return (file.endsWith('.vue') && (dirs.includes('index.ts') || dirs.includes('index.vue'))) || ~subPath.indexOf(['src', 'index.ts'].join(path.sep))
// 每个组件最多三个入口index.ts、pc.vue、mobile.vue 其他文件均不排除,直接打入到组件中
const isMainEntry = file.includes('index') && dirs.includes('package.json')
const isPcEntry = file.includes('pc.') && subPath.includes(`src${path.sep}pc.`)
const isMobileEntry = file.includes('mobile.') && subPath.includes(`src${path.sep}mobile.`)
return {
isBuildEntryFile: isMainEntry || isPcEntry || isMobileEntry,
isMainEntry,
isPcEntry,
isMobileEntry
}
}
const getTemplateName = (currentPaths) => currentPaths.slice(2).map(utils.capitalize).join('/').split('.')[0].replace('/', '')
const getTemplateName = (currentPaths, entryObj) => {
const subFix = entryObj.isPcEntry ? 'Pc' : (entryObj.isMobileEntry ? 'Mobile' : '')
return `${currentPaths.split('-').map(utils.capitalize).join('')}${subFix}`
}
/**
* index.vue modules.json
@ -16,8 +27,6 @@ const getTemplateName = (currentPaths) => currentPaths.slice(2).map(utils.capita
const makeModules = () => {
const templates = { ...commonMapping }
// 获取老的odules.json
const oldModules = readModuleMap()
// 获取存放所有组件的文件夹
const packagesStr = 'packages/vue/src'
utils.walkFileTree({
@ -26,42 +35,38 @@ const makeModules = () => {
fileFilter({ file }) {
return !/node_modules|helper|common|assets/.test(file)
},
// file:模块文件名称subPath:处于同一文件夹的文件集合dirs:文件所在的绝对路径
callback({ file, subPath, dirs }) {
// 判断是否是需要作为打包入口文件
if (isBuildEntryFile(file, dirs, subPath)) {
const isEntry = file.startsWith('index')
const subPaths = subPath.split(path.sep)
const currentPaths = subPaths.slice(subPaths.indexOf('src') + 1)
const templateName = getTemplateName(currentPaths)
const templatePath = currentPaths[currentPaths.length - 1].split('.')[0]
const componentName = []
currentPaths.every((dirName) => {
if (dirName === 'src') {
return false
const entryObj = isBuildEntryFile(file, dirs, subPath)
if (entryObj.isBuildEntryFile) {
const modulePath = subPath.slice(subPath.lastIndexOf(`vue${path.sep}src`)).replaceAll(path.sep, '/')
const matchArr = modulePath.match(/.+\/(.+?)\/(index\.ts|src\/pc\.|src\/mobile\.)/)
if (matchArr?.[1]) {
const compName = getTemplateName(matchArr[1], entryObj)
templates[compName] = {
path: modulePath,
type: entryObj.isMainEntry ? 'component' : 'template',
exclude: false
}
componentName.push(dirName)
return true
})
const globalName = componentName[componentName.length - 1].split('-').map(utils.capitalize).join('')
const moduleName = globalName + (isEntry ? '' : templateName)
const oldModuleItem = oldModules[moduleName] || {}
const oldKeys = Object.keys(oldModuleItem)
const newModuleItem = addModule({
componentName: componentName.join('/'),
templateName: templatePath
})
oldKeys.forEach((key) => {
if (typeof newModuleItem[key] === 'undefined' || key === 'onlyMode') {
newModuleItem[key] = oldModuleItem[key]
}
})
newModuleItem.exclude = oldModuleItem.exclude || false
templates[moduleName] = newModuleItem
}
}
}
})
writeModuleMap(quickSort({ sortData: templates, returnType: 'object' }))
const modulesJson = quickSort({ sortData: templates, returnType: 'object' })
Object.entries(modulesJson).forEach(([key, value]) => {
if (!key.includes('Pc') && !key.includes('Mobile')) {
if (modulesJson[`${key}Pc`] && !modulesJson[`${key}Mobile`]) {
value.onlyMode = 'pc'
} else if (!modulesJson[`${key}Pc`] && modulesJson[`${key}Mobile`]) {
value.onlyMode = 'mobile'
}
}
})
writeModuleMap(modulesJson)
}
try {

View File

@ -13,10 +13,7 @@ const program = new Command()
// .option('--cover', '覆盖原文件', false)
// .action(create)
program
.command('build:entry')
.description('生成组件库入口')
.action(buildEntry)
program.command('build:entry').description('生成组件库入口').action(buildEntry)
program
.command('build:ui')
@ -24,6 +21,7 @@ program
.argument('[names...]', '构建指定组件,如 button alert不指定则构建全量组件')
.addOption(new Option('-v --vue-versions <vueVersions...>', '目标框架,默认所有').choices(['2', '2.7', '3']))
.addOption(new Option('-f --formats <formats...>', '目标格式,默认 ["es"]').choices(['es', 'cjs']))
.addOption(new Option('-t --build-target <buildTarget>', '组件的目标版本'))
.option('-s, --scope <scope>', 'npm scope默认是 opentiny会以 @opentiny 发布到 npm')
.option('-c, --clean', '清空构建目录')
.option('--no-dts', '不生成 dts')

View File

@ -11,10 +11,7 @@ const EXTENERAL = [
'shepherd.js'
]
const external = (deps) => {
return (
EXTENERAL.includes(deps) ||
/^@opentiny[\\/]|@originjs|echarts|cropperjs|crypto-js/.test(deps)
)
return EXTENERAL.includes(deps) || /^@opentiny[\\/]|@originjs|echarts|cropperjs|@better-scroll|crypto-js/.test(deps)
}
export { external }

View File

@ -127,6 +127,7 @@ const getSortModules = ({ filterIntercept, isSort = true }) => {
const importName = '@opentiny/vue'
Object.entries(moduleMap).forEach(([key, module]) => {
let component = module as Module
component.name = key
// filterIntercept过滤筛选命令行传过来的组件名称只输出命令行传递过来的组件
if (filterIntercept(component) === true && component.exclude !== true) {
@ -150,6 +151,7 @@ const getSortModules = ({ filterIntercept, isSort = true }) => {
.replace('vue-locale/src/', 'packages/locale/')
.replace('vue-icon/src/', 'packages/icon/')
.replace('/index.ts', '/src/index.js')
.replace('/lowercase.ts', '/lowercase.js')
.replace('/src/', '/dist/lib/')
.replace('.vue', '.js')
@ -182,7 +184,10 @@ const getSortModules = ({ filterIntercept, isSort = true }) => {
// "vue-common/src/index.ts" ==> "vue-common/lib/index"
if (component.type === 'module') {
component.libPath = component.path.replace('/src/', '/lib/').replace('index.ts', 'index')
component.libPath = component.path
.replace('/src/', '/lib/')
.replace('index.ts', 'index')
.replace('lowercase.ts', 'lowercase')
}
// "vue/src/button/index.ts" ==> "button/lib/index"
@ -337,7 +342,7 @@ const isArraySortData = (sortData, setIndex) => {
}
const isNotArrayObject = (sortData, key, setIndex) => {
if (!(Array.isArray(sortData)) && typeof sortData === 'object') {
if (!Array.isArray(sortData) && typeof sortData === 'object') {
for (const sortKey in sortData) {
const dataItem = sortData[sortKey]
let sortItem = {}
@ -359,7 +364,7 @@ const isNotArrayObject = (sortData, key, setIndex) => {
const isNotArrayNotObject = (sortData) => {
const ret = { flag: false, result: null }
if (!(Array.isArray(sortData)) && !(typeof sortData === 'object')) {
if (!Array.isArray(sortData) && !(typeof sortData === 'object')) {
ret.flag = true
ret.result = sortData
}
@ -372,14 +377,14 @@ const isNotArrayNotObject = (sortData) => {
* @param {Boolean} isSort
* @returns
*/
const getMobileComponents = (isSort = true) => {
const getMobileComponents = (isSort = true, hasModuleType = false) => {
const modules = getAllModules(isSort)
const componentNames = modules.filter((item) => item.tmpName.includes('mobile')).map((item) => item.UpperName)
const moduleTyps = ['component']
hasModuleType && moduleTyps.push('module')
const components = modules.filter(
(item) =>
(item.onlyMode && item.onlyMode.includes('mobile')) ||
(item.type === 'component' && componentNames.includes(item.UpperName))
(item) => moduleTyps.includes(item.type) && (!item.onlyMode || item.onlyMode.includes('mobile'))
)
return components
@ -476,17 +481,17 @@ const createModuleMapping = (componentName, isMobile = false) => {
const getAllIcons = () => {
const entries = fg.sync('vue-icon*/src/*', { cwd: utils.pathFromWorkspaceRoot('packages'), onlyDirectories: true })
return entries.map(item => {
return entries.map((item) => {
const name = path.basename(item)
return {
path: item + '/index.ts',
libPath: item.replace('/src/', '/lib/') + '.js',
libPath: item.replace('/src/', '/lib/'),
type: 'component',
componentType: 'icon',
name: utils.kebabCase({ str: name }),
global: utils.capitalizeKebabCase(name),
importName: '@opentiny/vue-' + item,
importName: '@opentiny/vue-' + item
} as Module
})
}
@ -502,5 +507,5 @@ export {
getPcComponents,
createModuleMapping,
getMobileComponents,
getAllIcons,
getAllIcons
}

View File

@ -27,12 +27,6 @@
},
"sideEffects": false,
"main": "packages/index.js",
"files": [
"index.js",
"pc.js",
"mobile.js",
"runtime"
],
"engines": {
"node": ">=14",
"pnpm": ">=7"
@ -52,6 +46,8 @@
"build:runtime": "pnpm -C internals/cli build:runtime",
"build:ui": "pnpm -C internals/cli build:ui",
"build:renderless": "pnpm -C packages/renderless build",
"build:theme": "pnpm -C packages/theme build",
"build:themeMobile": "pnpm -C packages/theme-mobile build",
"build:internals": "pnpm \"--filter=./internals/*\" build",
"release:vue2": "pnpm -C internals/cli release:vue2",
"release:vue3": "pnpm -C internals/cli release:vue3",
@ -60,6 +56,8 @@
"release:ui-test-vue2": "pnpm -C internals/cli release:ui-test-vue2",
"/* pubTgz */": "部署带绿标的 npm 包",
"pubTgz": "node .cloudbuild/pub-tgzs.js",
"pub2": "pnpm --filter=\"./packages/dist2/**\" publish --no-git-checks",
"pub3": "pnpm --filter=\"./packages/dist3/**\" publish --no-git-checks",
"format": "prettier --write --cache packages/**/{*.vue,*.js,*.ts,*.jsx,*.tsx} examples/**/{*.vue,*.js,*.ts,*.jsx,*.tsx} internal/**/{*.js,*.ts}",
"lint": "eslint \"packages/**/{*.vue,*.js,*.ts,*.jsx,*.tsx}\" --quiet",
"lint:doc": "eslint \"examples/**/{*.vue,*.js,*.ts,*.jsx,*.tsx}\" --quiet",
@ -69,7 +67,7 @@
"test:pub": "npm run build:ui-vue2 && npm run release:ui-vue2 && npm run build:ui-vue3 && npm run release:ui-vue3 && mv -f tgzs/*.tgz ./ && npm run pubTgz -- production",
"test:pub-runtime": "npm run build:runtime-vue2 && npm run release:vue2 && npm run build:runtime-vue3 && npm run release:vue3 && mv -f tgzs/*.tgz ./ && npm run pubTgz -- production",
"test:pubTgz": "npm run pubTgz -- production",
"clean:build": "rimraf packages/dist packages/renderless/dist",
"clean:build": "rimraf packages/dist2 packages/dist3 packages/renderless/dist",
"clean:dependencies": "rm -rf node_modules /**/node_modules",
"// ---------- 构建【mf】版本 ----------": "",
"preci:deployMfPatch": "pnpm clean:build && lerna version prepatch --conventional-prerelease --include-merged-tags --preid mf --no-push --yes",

View File

@ -7,8 +7,7 @@
"ActionSheet": {
"path": "vue/src/action-sheet/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Alert": {
"path": "vue/src/alert/index.ts",
@ -35,16 +34,6 @@
"type": "component",
"exclude": false
},
"Anchor": {
"path": "packages/anchor/index.js",
"type": "component",
"exclude": false
},
"Anchor": {
"path": "packages/anchor/index.js",
"type": "component",
"exclude": false
},
"Area": {
"path": "vue/src/area/index.ts",
"type": "component",
@ -53,7 +42,8 @@
"Autocomplete": {
"path": "vue/src/autocomplete/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"AutocompletePc": {
"path": "vue/src/autocomplete/src/pc.vue",
@ -68,8 +58,7 @@
"Avatar": {
"path": "vue/src/avatar/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Badge": {
"path": "vue/src/badge/index.ts",
@ -94,12 +83,14 @@
"Breadcrumb": {
"path": "vue/src/breadcrumb/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"BreadcrumbItem": {
"path": "vue/src/breadcrumb-item/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"BreadcrumbItemPc": {
"path": "vue/src/breadcrumb-item/src/pc.vue",
@ -114,7 +105,8 @@
"BulletinBoard": {
"path": "vue/src/bulletin-board/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"BulletinBoardPc": {
"path": "vue/src/bulletin-board/src/pc.vue",
@ -129,7 +121,8 @@
"ButtonGroup": {
"path": "vue/src/button-group/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ButtonGroupPc": {
"path": "vue/src/button-group/src/pc.vue",
@ -149,7 +142,8 @@
"Calendar": {
"path": "vue/src/calendar/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CalendarPc": {
"path": "vue/src/calendar/src/pc.vue",
@ -159,7 +153,8 @@
"CardTemplate": {
"path": "vue/src/card-template/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CardTemplatePc": {
"path": "vue/src/card-template/src/pc.vue",
@ -169,12 +164,14 @@
"Carousel": {
"path": "vue/src/carousel/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CarouselItem": {
"path": "vue/src/carousel-item/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CarouselItemPc": {
"path": "vue/src/carousel-item/src/pc.vue",
@ -189,7 +186,8 @@
"Cascader": {
"path": "vue/src/cascader/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CascaderMenu": {
"path": "vue/src/cascader-menu/index.ts",
@ -329,7 +327,8 @@
"CheckboxButton": {
"path": "vue/src/checkbox-button/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CheckboxButtonPc": {
"path": "vue/src/checkbox-button/src/pc.vue",
@ -364,7 +363,8 @@
"Col": {
"path": "vue/src/col/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ColPc": {
"path": "vue/src/col/src/pc.vue",
@ -374,12 +374,14 @@
"Collapse": {
"path": "vue/src/collapse/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CollapseItem": {
"path": "vue/src/collapse-item/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CollapseItemPc": {
"path": "vue/src/collapse-item/src/pc.vue",
@ -404,7 +406,8 @@
"Company": {
"path": "vue/src/company/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CompanyPc": {
"path": "vue/src/company/src/pc.vue",
@ -414,7 +417,8 @@
"Container": {
"path": "vue/src/container/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ContainerPc": {
"path": "vue/src/container/src/pc.vue",
@ -424,7 +428,8 @@
"Country": {
"path": "vue/src/country/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CountryPc": {
"path": "vue/src/country/src/pc.vue",
@ -434,12 +439,14 @@
"CreditCard": {
"path": "vue/src/credit-card/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CreditCardForm": {
"path": "vue/src/credit-card-form/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CreditCardFormPc": {
"path": "vue/src/credit-card-form/src/pc.vue",
@ -459,7 +466,8 @@
"Currency": {
"path": "vue/src/currency/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"CurrencyPc": {
"path": "vue/src/currency/src/pc.vue",
@ -474,8 +482,7 @@
"DatePicker": {
"path": "vue/src/date-picker/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"DatePickerMobile": {
"path": "vue/src/date-picker/src/mobile.vue",
@ -500,7 +507,8 @@
"Dept": {
"path": "vue/src/dept/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"DeptPc": {
"path": "vue/src/dept/src/pc.vue",
@ -510,7 +518,8 @@
"DetailPage": {
"path": "vue/src/detail-page/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"DetailPagePc": {
"path": "vue/src/detail-page/src/pc.vue",
@ -535,7 +544,8 @@
"DropRoles": {
"path": "vue/src/drop-roles/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"DropRolesPc": {
"path": "vue/src/drop-roles/src/pc.vue",
@ -545,7 +555,8 @@
"DropTimes": {
"path": "vue/src/drop-times/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"DropTimesPc": {
"path": "vue/src/drop-times/src/pc.vue",
@ -560,8 +571,7 @@
"DropdownItem": {
"path": "vue/src/dropdown-item/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"DropdownItemMobile": {
"path": "vue/src/dropdown-item/src/mobile.vue",
@ -576,8 +586,7 @@
"DropdownMenu": {
"path": "vue/src/dropdown-menu/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"DropdownMenuMobile": {
"path": "vue/src/dropdown-menu/src/mobile.vue",
@ -592,7 +601,8 @@
"Espace": {
"path": "vue/src/espace/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"EspacePc": {
"path": "vue/src/espace/src/pc.vue",
@ -602,13 +612,13 @@
"Exception": {
"path": "vue/src/exception/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"FallMenu": {
"path": "vue/src/fall-menu/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"FallMenuPc": {
"path": "vue/src/fall-menu/src/pc.vue",
@ -633,7 +643,8 @@
"Floatbar": {
"path": "vue/src/floatbar/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"FloatbarPc": {
"path": "vue/src/floatbar/src/pc.vue",
@ -648,8 +659,7 @@
"FormItem": {
"path": "vue/src/form-item/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"FormMobile": {
"path": "vue/src/form/src/mobile.vue",
@ -664,8 +674,7 @@
"Fullscreen": {
"path": "vue/src/fullscreen/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"Grid": {
"path": "vue/src/grid/index.ts",
@ -687,35 +696,11 @@
"type": "component",
"exclude": false
},
"GridToolbarCustom": {
"path": "vue/src/grid-toolbar/src/custom.vue",
"type": "template",
"exclude": false
},
"GridToolbarCustom-select": {
"path": "vue/src/grid-toolbar/src/custom-select.vue",
"type": "template",
"exclude": false
},
"GridToolbarCustom-select": {
"path": "packages/grid-toolbar/src/custom-select.vue",
"type": "template",
"exclude": false
},
"GridToolbarCustom-select": {
"path": "packages/grid-toolbar/src/custom-select.vue",
"type": "template",
"exclude": false
},
"GridToolbarCustom-switch": {
"path": "vue/src/grid-toolbar/src/custom-switch.vue",
"type": "template",
"exclude": false
},
"Hrapprover": {
"path": "vue/src/hrapprover/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"HrapproverPc": {
"path": "vue/src/hrapprover/src/pc.vue",
@ -727,10 +712,16 @@
"type": "module",
"exclude": false
},
"IconLowercase": {
"path": "vue-icon/lowercase.ts",
"type": "module",
"exclude": false
},
"Image": {
"path": "vue/src/image/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ImagePc": {
"path": "vue/src/image/src/pc.vue",
@ -755,13 +746,19 @@
"IndexBar": {
"path": "vue/src/index-bar/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "mobile"
},
"IndexBarAnchor": {
"path": "vue/src/index-bar-anchor/index.ts",
"type": "component",
"exclude": false
},
"IndexBarMobile": {
"path": "vue/src/index-bar/src/mobile.vue",
"type": "template",
"exclude": false
},
"Input": {
"path": "vue/src/input/index.ts",
"type": "component",
@ -777,15 +774,11 @@
"type": "template",
"exclude": false
},
"InputTall-storage": {
"path": "vue/src/input/src/tall-storage.vue",
"type": "template",
"exclude": false
},
"IpAddress": {
"path": "vue/src/ip-address/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"IpAddressPc": {
"path": "vue/src/ip-address/src/pc.vue",
@ -795,7 +788,8 @@
"Layout": {
"path": "vue/src/layout/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"LayoutPc": {
"path": "vue/src/layout/src/pc.vue",
@ -805,12 +799,14 @@
"Link": {
"path": "vue/src/link/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"LinkMenu": {
"path": "vue/src/link-menu/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"LinkMenuPc": {
"path": "vue/src/link-menu/src/pc.vue",
@ -825,8 +821,7 @@
"List": {
"path": "vue/src/list/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Loading": {
"path": "vue/src/loading/index.ts",
@ -861,7 +856,8 @@
"Logout": {
"path": "vue/src/logout/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"LogoutPc": {
"path": "vue/src/logout/src/pc.vue",
@ -871,7 +867,8 @@
"Milestone": {
"path": "vue/src/milestone/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"MilestonePc": {
"path": "vue/src/milestone/src/pc.vue",
@ -881,8 +878,7 @@
"MiniPicker": {
"path": "vue/src/mini-picker/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Modal": {
"path": "vue/src/modal/index.ts",
@ -912,7 +908,8 @@
"MultiSelect": {
"path": "vue/src/multi-select/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "mobile"
},
"MultiSelectMobile": {
"path": "vue/src/multi-select/src/mobile.vue",
@ -922,13 +919,13 @@
"NavBar": {
"path": "vue/src/nav-bar/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"NavMenu": {
"path": "vue/src/nav-menu/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"NavMenuPc": {
"path": "vue/src/nav-menu/src/pc.vue",
@ -973,13 +970,13 @@
"PagerItem": {
"path": "vue/src/pager-item/index.ts",
"type": "component",
"exclude": false,
"private": "Pager"
"exclude": false
},
"Panel": {
"path": "vue/src/panel/index.ts",
"type": "component",
"exclude": true
"exclude": false,
"onlyMode": "pc"
},
"PanelPc": {
"path": "vue/src/panel/src/pc.vue",
@ -994,13 +991,13 @@
"PickerColumn": {
"path": "vue/src/picker-column/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"PopUpload": {
"path": "vue/src/pop-upload/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"PopUploadPc": {
"path": "vue/src/pop-upload/src/pc.vue",
@ -1010,7 +1007,8 @@
"Popeditor": {
"path": "vue/src/popeditor/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"PopeditorPc": {
"path": "vue/src/popeditor/src/pc.vue",
@ -1035,8 +1033,7 @@
"Popup": {
"path": "vue/src/popup/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Progress": {
"path": "vue/src/progress/index.ts",
@ -1056,8 +1053,7 @@
"PullRefresh": {
"path": "vue/src/pull-refresh/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Radio": {
"path": "vue/src/radio/index.ts",
@ -1067,7 +1063,8 @@
"RadioButton": {
"path": "vue/src/radio-button/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"RadioButtonPc": {
"path": "vue/src/radio-button/src/pc.vue",
@ -1077,7 +1074,8 @@
"RadioGroup": {
"path": "vue/src/radio-group/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"RadioGroupPc": {
"path": "vue/src/radio-group/src/pc.vue",
@ -1097,7 +1095,8 @@
"Rate": {
"path": "vue/src/rate/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"RatePc": {
"path": "vue/src/rate/src/pc.vue",
@ -1107,7 +1106,8 @@
"Roles": {
"path": "vue/src/roles/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"RolesPc": {
"path": "vue/src/roles/src/pc.vue",
@ -1117,7 +1117,8 @@
"Row": {
"path": "vue/src/row/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"RowPc": {
"path": "vue/src/row/src/pc.vue",
@ -1127,7 +1128,8 @@
"ScrollText": {
"path": "vue/src/scroll-text/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ScrollTextPc": {
"path": "vue/src/scroll-text/src/pc.vue",
@ -1139,11 +1141,6 @@
"type": "component",
"exclude": false
},
"ScrollbarBar": {
"path": "vue/src/scrollbar/src/bar.vue",
"type": "template",
"exclude": false
},
"Search": {
"path": "vue/src/search/index.ts",
"type": "component",
@ -1162,12 +1159,14 @@
"Select": {
"path": "vue/src/select/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"SelectDropdown": {
"path": "vue/src/select-dropdown/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"SelectDropdownPc": {
"path": "vue/src/select-dropdown/src/pc.vue",
@ -1182,7 +1181,8 @@
"SlideBar": {
"path": "vue/src/slide-bar/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"SlideBarPc": {
"path": "vue/src/slide-bar/src/pc.vue",
@ -1207,7 +1207,8 @@
"Split": {
"path": "vue/src/split/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"SplitPc": {
"path": "vue/src/split/src/pc.vue",
@ -1217,7 +1218,8 @@
"Steps": {
"path": "vue/src/steps/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"StepsPc": {
"path": "vue/src/steps/src/pc.vue",
@ -1247,14 +1249,12 @@
"TabItem": {
"path": "vue/src/tab-item/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"Tabbar": {
"path": "vue/src/tabbar/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"TabbarItem": {
"path": "vue/src/tabbar-item/index.ts",
@ -1265,8 +1265,7 @@
"TabbarItemMobile": {
"path": "vue/src/tabbar-item/src/mobile.vue",
"type": "template",
"exclude": false,
"onlyMode": "mobile"
"exclude": false
},
"Table": {
"path": "vue/src/table/index.ts",
@ -1298,20 +1297,11 @@
"type": "template",
"exclude": false
},
"TabsTab-navTab-bar": {
"path": "packages/tabs/src/tab-bar.vue",
"type": "template",
"exclude": false
},
"TabsTab-navTab-bar": {
"path": "packages/tabs/src/tab-bar.vue",
"type": "template",
"exclude": false
},
"Tag": {
"path": "vue/src/tag/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"TagPc": {
"path": "vue/src/tag/src/pc.vue",
@ -1321,7 +1311,8 @@
"TextPopup": {
"path": "vue/src/text-popup/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"TextPopupPc": {
"path": "vue/src/text-popup/src/pc.vue",
@ -1376,7 +1367,8 @@
"ToggleMenu": {
"path": "vue/src/toggle-menu/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"ToggleMenuPc": {
"path": "vue/src/toggle-menu/src/pc.vue",
@ -1391,7 +1383,8 @@
"TopBox": {
"path": "vue/src/top-box/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"TopBoxPc": {
"path": "vue/src/top-box/src/pc.vue",
@ -1401,7 +1394,8 @@
"Transfer": {
"path": "vue/src/transfer/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"TransferPanel": {
"path": "vue/src/transfer-panel/index.ts",
@ -1416,7 +1410,8 @@
"Tree": {
"path": "vue/src/tree/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"TreeMenu": {
"path": "vue/src/tree-menu/index.ts",
@ -1428,16 +1423,10 @@
"type": "template",
"exclude": false
},
"TreeTree-node": {
"path": "vue/src/tree/src/tree-node.vue",
"type": "template",
"exclude": false
},
"Upload": {
"path": "vue/src/upload/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"UploadDragger": {
"path": "vue/src/upload-dragger/index.ts",
@ -1447,18 +1436,19 @@
"UploadList": {
"path": "vue/src/upload-list/index.ts",
"type": "component",
"exclude": false,
"onlyMode": "all"
"exclude": false
},
"User": {
"path": "vue/src/user/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"UserAccount": {
"path": "vue/src/user-account/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"UserAccountPc": {
"path": "vue/src/user-account/src/pc.vue",
@ -1468,7 +1458,8 @@
"UserContact": {
"path": "vue/src/user-contact/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"UserContactPc": {
"path": "vue/src/user-contact/src/pc.vue",
@ -1493,7 +1484,8 @@
"UserLink": {
"path": "vue/src/user-link/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"UserLinkPc": {
"path": "vue/src/user-link/src/pc.vue",
@ -1513,7 +1505,8 @@
"Wizard": {
"path": "vue/src/wizard/index.ts",
"type": "component",
"exclude": false
"exclude": false,
"onlyMode": "pc"
},
"WizardPc": {
"path": "vue/src/wizard/src/pc.vue",
@ -1524,25 +1517,5 @@
"path": "vue/src/year-table/index.ts",
"type": "component",
"exclude": false
},
"IndexBar": {
"path": "packages/index-bar/index.js",
"type": "component",
"exclude": false
},
"IndexBarAnchor": {
"path": "packages/index-bar-anchor/index.js",
"type": "component",
"exclude": false
},
"IndexBar": {
"path": "packages/index-bar/index.js",
"type": "component",
"exclude": false
},
"IndexBarAnchor": {
"path": "packages/index-bar-anchor/index.js",
"type": "component",
"exclude": false
}
}

View File

@ -20,7 +20,8 @@
"sideEffects": false,
"scripts": {
"build": "tsup",
"postversion": "pnpm build"
"postversion": "pnpm build",
"release": "esno ./scripts/postbuild.ts"
},
"dependencies": {
"xss": "1.0.11"

View File

@ -58,7 +58,18 @@ const appendPopper = ({ options, props, state, parent }) => {
}
}
const setWatchFn = ({ watch, props, state, emit, nextTick, updatePopper, destroyPopper, onBeforeUnmount, onDeactivated, doDestroy }) => {
const setWatchFn = ({
watch,
props,
state,
emit,
nextTick,
updatePopper,
destroyPopper,
onBeforeUnmount,
onDeactivated,
doDestroy
}) => {
watch(
() => props.modelValue,
(val) => {
@ -101,57 +112,71 @@ const setWatchFn = ({ watch, props, state, emit, nextTick, updatePopper, destroy
})
}
const createPopperFn = ({ state, props, refs, slots, appendArrow, emit, resetTransformOrigin, nextTick, updatePopper, nextZIndex, parent }) => (dom) => {
if (isServer) {
return
const createPopperFn =
({
state,
props,
refs,
slots,
appendArrow,
emit,
resetTransformOrigin,
nextTick,
updatePopper,
nextZIndex,
parent
}) =>
(dom) => {
if (isServer) {
return
}
state.currentPlacement = state.currentPlacement || props.placement
if (!/^(top|bottom|left|right)(-start|-end)?$/g.test(state.currentPlacement)) {
return
}
const options = props.popperOptions || { gpuAcceleration: false }
state.popperElm = state.popperElm || props.popper || refs.popper || dom
const popper = state.popperElm
let reference = getReference({ state, props, refs, slots })
if (!popper || !reference || reference.nodeType !== Node.ELEMENT_NODE) {
return
}
if (props.visibleArrow) {
appendArrow(popper)
}
appendPopper({ options, props, state, parent })
if (props.popperJS && state.popperJS.destroy) {
state.popperJS.destroy()
}
options.placement = state.currentPlacement
options.offset = props.offset || 0
options.arrowOffset = props.arrowOffset || 0
options.adjustArrow = props.adjustArrow || false
state.popperJS = new PopperJS(reference, popper, options)
state.popperJS.onCreate(() => {
emit('created', state)
resetTransformOrigin()
// 原来代码逻辑会触发2次updatePopper,暂时注释掉这一处,待观察
// new PopperJS 内部已经调用this.update了所以屏蔽 nextTick(updatePopper)
})
if (typeof options.onUpdate === 'function') {
state.popperJS.onUpdate(options.onUpdate)
}
state.popperJS._popper.style.zIndex = nextZIndex(state.popperJS._reference)
on(state.popperElm, 'click', stop)
}
state.currentPlacement = state.currentPlacement || props.placement
if (!/^(top|bottom|left|right)(-start|-end)?$/g.test(state.currentPlacement)) {
return
}
const options = props.popperOptions || { gpuAcceleration: false }
state.popperElm = state.popperElm || props.popper || refs.popper || dom
const popper = state.popperElm
let reference = getReference({ state, props, refs, slots })
if (!popper || !reference || reference.nodeType !== Node.ELEMENT_NODE) {
return
}
if (props.visibleArrow) {
appendArrow(popper)
}
appendPopper({ options, props, state, parent })
if (props.popperJS && state.popperJS.destroy) {
state.popperJS.destroy()
}
options.placement = state.currentPlacement
options.offset = props.offset || 0
options.arrowOffset = props.arrowOffset || 0
options.adjustArrow = props.adjustArrow || false
state.popperJS = new PopperJS(reference, popper, options)
state.popperJS.onCreate(() => {
emit('created', state)
resetTransformOrigin()
// 原来代码逻辑会触发2次updatePopper,暂时注释掉这一处,待观察
// new PopperJS 内部已经调用this.update了所以屏蔽 nextTick(updatePopper)
})
if (typeof options.onUpdate === 'function') {
state.popperJS.onUpdate(options.onUpdate)
}
state.popperJS._popper.style.zIndex = nextZIndex(state.popperJS._reference)
on(state.popperElm, 'click', stop)
}
const appendArrowFn = (state) => (el) => {
let hash
if (state.appended) {
@ -160,7 +185,7 @@ const appendArrowFn = (state) => (el) => {
state.appended = true
for (const item in el.attributes) {
if (el.attributes[item].name.startsWith('_v-')) {
if (el.attributes[item].name?.startsWith('_v-')) {
hash = el.attributes[item].name
break
}
@ -189,11 +214,25 @@ const resetTransformOriginFn = (state, props) => () => {
if (typeof props.transformOrigin === 'string') {
state.popperJS._popper.style.transformOrigin = props.transformOrigin
} else {
state.popperJS._popper.style.transformOrigin = ['top', 'bottom'].includes(placement) ? `center ${origin}` : `${origin} center`
state.popperJS._popper.style.transformOrigin = ['top', 'bottom'].includes(placement)
? `center ${origin}`
: `${origin} center`
}
}
export default ({ parent, emit, nextTick, onBeforeUnmount, onDeactivated, props, watch, reactive, refs, slots, toRefs }) => {
export default ({
parent,
emit,
nextTick,
onBeforeUnmount,
onDeactivated,
props,
watch,
reactive,
refs,
slots,
toRefs
}) => {
const state = reactive({
popperJS: null,
appended: false,
@ -203,7 +242,8 @@ export default ({ parent, emit, nextTick, onBeforeUnmount, onDeactivated, props,
currentPlacement: ''
})
const nextZIndex = (reference) => (props.zIndex === 'relative' ? getReferMaxZIndex(reference) : PopupManager.nextZIndex())
const nextZIndex = (reference) =>
props.zIndex === 'relative' ? getReferMaxZIndex(reference) : PopupManager.nextZIndex()
const appendArrow = appendArrowFn(state)
const resetTransformOrigin = resetTransformOriginFn(state, props)
let createPopper
@ -219,7 +259,19 @@ export default ({ parent, emit, nextTick, onBeforeUnmount, onDeactivated, props,
createPopper(dom)
}
}
createPopper = createPopperFn({ state, props, refs, slots, appendArrow, emit, resetTransformOrigin, nextTick, updatePopper, nextZIndex, parent })
createPopper = createPopperFn({
state,
props,
refs,
slots,
appendArrow,
emit,
resetTransformOrigin,
nextTick,
updatePopper,
nextZIndex,
parent
})
const doDestroy = (forceDestroy) => {
if (!state.popperJS || (state.showPopper && !forceDestroy)) {
return
@ -241,7 +293,18 @@ export default ({ parent, emit, nextTick, onBeforeUnmount, onDeactivated, props,
}
}
}
setWatchFn({ watch, props, state, emit, nextTick, updatePopper, destroyPopper, onBeforeUnmount, onDeactivated, doDestroy })
setWatchFn({
watch,
props,
state,
emit,
nextTick,
updatePopper,
destroyPopper,
onBeforeUnmount,
onDeactivated,
doDestroy
})
return { doDestroy, appendArrow, createPopper, updatePopper, destroyPopper, resetTransformOrigin, ...toRefs(state) }
}

View File

@ -319,7 +319,7 @@ import IconWriting from './src/writing'
import IconYes from './src/yes'
import IconZoomIn from './src/zoom-in'
import IconZoomOut from './src/zoom-out'
export * from './src/lowercase'
export * from './lowercase'
export {
IconAdd,
IconAdministrator,

View File

@ -4,19 +4,17 @@
"version": "3.7.0",
"description": "opentiny vue components",
"type": "module",
"files": [
"index.js",
"pc.js",
"mobile.js",
"runtime"
],
"sideEffects": false,
"dependencies": {
"@opentiny/vue-action-menu": "workspace:~",
"@opentiny/vue-action-sheet": "workspace:~",
"@opentiny/vue-alert": "workspace:~",
"@opentiny/vue-amount": "workspace:~",
"@opentiny/vue-anchor": "workspace:~",
"@opentiny/vue-area": "workspace:~",
"@opentiny/vue-autocomplete": "workspace:~",
"@opentiny/vue-autonavi-map": "workspace:~",
"@opentiny/vue-avatar": "workspace:~",
"@opentiny/vue-badge": "workspace:~",
"@opentiny/vue-baidu-map": "workspace:~",
"@opentiny/vue-breadcrumb": "workspace:~",
@ -61,10 +59,11 @@
"@opentiny/vue-collapse": "workspace:~",
"@opentiny/vue-collapse-item": "workspace:~",
"@opentiny/vue-collapse-transition": "workspace:~",
"@opentiny/vue-common": "workspace:~",
"@opentiny/vue-company": "workspace:~",
"@opentiny/vue-container": "workspace:~",
"@opentiny/vue-country": "workspace:~",
"@opentiny/vue-credit-card": "workspace:~",
"@opentiny/vue-credit-card-form": "workspace:~",
"@opentiny/vue-crop": "workspace:~",
"@opentiny/vue-currency": "workspace:~",
"@opentiny/vue-date-panel": "workspace:~",
@ -80,6 +79,7 @@
"@opentiny/vue-dropdown-item": "workspace:~",
"@opentiny/vue-dropdown-menu": "workspace:~",
"@opentiny/vue-espace": "workspace:~",
"@opentiny/vue-exception": "workspace:~",
"@opentiny/vue-fall-menu": "workspace:~",
"@opentiny/vue-file-upload": "workspace:~",
"@opentiny/vue-floatbar": "workspace:~",
@ -93,19 +93,25 @@
"@opentiny/vue-hrapprover": "workspace:~",
"@opentiny/vue-image": "workspace:~",
"@opentiny/vue-image-viewer": "workspace:~",
"@opentiny/vue-index-bar": "workspace:~",
"@opentiny/vue-index-bar-anchor": "workspace:~",
"@opentiny/vue-input": "workspace:~",
"@opentiny/vue-ip-address": "workspace:~",
"@opentiny/vue-layout": "workspace:~",
"@opentiny/vue-link": "workspace:~",
"@opentiny/vue-link-menu": "workspace:~",
"@opentiny/vue-list": "workspace:~",
"@opentiny/vue-loading": "workspace:~",
"@opentiny/vue-locales": "workspace:~",
"@opentiny/vue-logon-user": "workspace:~",
"@opentiny/vue-logout": "workspace:~",
"@opentiny/vue-milestone": "workspace:~",
"@opentiny/vue-mini-picker": "workspace:~",
"@opentiny/vue-modal": "workspace:~",
"@opentiny/vue-month-range": "workspace:~",
"@opentiny/vue-month-table": "workspace:~",
"@opentiny/vue-multi-select": "workspace:~",
"@opentiny/vue-nav-bar": "workspace:~",
"@opentiny/vue-nav-menu": "workspace:~",
"@opentiny/vue-notify": "workspace:~",
"@opentiny/vue-numeric": "workspace:~",
@ -114,10 +120,13 @@
"@opentiny/vue-pager": "workspace:~",
"@opentiny/vue-pager-item": "workspace:~",
"@opentiny/vue-picker": "workspace:~",
"@opentiny/vue-picker-column": "workspace:~",
"@opentiny/vue-pop-upload": "workspace:~",
"@opentiny/vue-popeditor": "workspace:~",
"@opentiny/vue-popover": "workspace:~",
"@opentiny/vue-popup": "workspace:~",
"@opentiny/vue-progress": "workspace:~",
"@opentiny/vue-pull-refresh": "workspace:~",
"@opentiny/vue-radio": "workspace:~",
"@opentiny/vue-radio-button": "workspace:~",
"@opentiny/vue-radio-group": "workspace:~",
@ -136,6 +145,8 @@
"@opentiny/vue-svg-icon": "workspace:~",
"@opentiny/vue-switch": "workspace:~",
"@opentiny/vue-tab-item": "workspace:~",
"@opentiny/vue-tabbar": "workspace:~",
"@opentiny/vue-tabbar-item": "workspace:~",
"@opentiny/vue-table": "workspace:~",
"@opentiny/vue-tabs": "workspace:~",
"@opentiny/vue-tag": "workspace:~",
@ -149,6 +160,7 @@
"@opentiny/vue-time-spinner": "workspace:~",
"@opentiny/vue-toggle-menu": "workspace:~",
"@opentiny/vue-tooltip": "workspace:~",
"@opentiny/vue-top-box": "workspace:~",
"@opentiny/vue-transfer": "workspace:~",
"@opentiny/vue-transfer-panel": "workspace:~",
"@opentiny/vue-tree": "workspace:~",
@ -161,6 +173,7 @@
"@opentiny/vue-user-contact": "workspace:~",
"@opentiny/vue-user-head": "workspace:~",
"@opentiny/vue-user-link": "workspace:~",
"@opentiny/vue-wheel": "workspace:~",
"@opentiny/vue-wizard": "workspace:~",
"@opentiny/vue-year-table": "workspace:~"
},

View File

@ -13,13 +13,21 @@
<div class="tiny-mobile-action-sheet" v-show="visible" @click="visibleHandle">
<div class="tiny-mobile-action-sheet__mask" :style="state.sheetMaskStyle" v-if="!contentPosition"></div>
<div
:class="['tiny-mobile-action-sheet__content', state.toggle ? 'is-toggle' : '', contentPosition ? '' : 'is-not-content']"
:class="[
'tiny-mobile-action-sheet__content',
state.toggle ? 'is-toggle' : '',
contentPosition ? '' : 'is-not-content'
]"
:style="[state.sheetContentStyle]"
ref="scrollMenu"
>
<div :class="['tiny-mobile-action-sheet__menu', ellipsis ? 'is-ellipsis' : '']">
<div
:class="['tiny-mobile-action-sheet__item', item.warn ? 'is-warn' : '', item.id === modelValue || item.id === state.active ? 'is-active' : '']"
:class="[
'tiny-mobile-action-sheet__item',
item.warn ? 'is-warn' : '',
item.id === modelValue || item.id === state.active ? 'is-active' : ''
]"
v-for="(item, index) in menus"
:key="index"
@click="menuHandle(item, index)"

View File

@ -39,16 +39,15 @@ export default defineComponent({
},
type: {
type: String,
validator: (value) => ~['primary', 'success', 'warning', 'info', 'danger'].indexOf(value)
validator: (value: string) => Boolean(~['primary', 'success', 'warning', 'info', 'danger'].indexOf(value))
},
badgeClass: String,
offset: {
type: Array,
default: [0, 0]
default: () => [0, 0]
}
},
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -23,7 +23,7 @@ export default defineComponent({
mode: {
type: String,
default: 'month',
validator: (value) => ~['month', 'year'].indexOf(value)
validator: (value: string) => Boolean(~['month', 'year'].indexOf(value))
},
/**
@ -63,5 +63,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -53,7 +53,7 @@ export default defineComponent({
},
type: {
type: String,
validator: (value) => !value || ~['card', 'vertical'].indexOf(value)
validator: (value: string) => Boolean(!value || ~['card', 'vertical'].indexOf(value))
},
showTitle: {
type: Boolean,

View File

@ -6,13 +6,15 @@
"module": "index.ts",
"files": [
"index.js",
"lib"
"lib",
"index.d.ts",
"src"
],
"devDependencies": {
"devDependencies": {
"@opentiny-internal/vue-test-utils": "workspace:*",
"vitest": "^0.25.7"
},
"scripts": {
"scripts": {
"build": "pnpm -w build:ui $npm_package_name",
"//postversion": "pnpm build"
},

View File

@ -23,7 +23,7 @@ export default defineComponent({
span: {
type: Number,
default: 12,
validator: (value) => Math.floor(value) === value && value > 0 && value <= 12
validator: (value: number) => Math.floor(value) === value && value > 0 && value <= 12
},
/**
@ -32,7 +32,7 @@ export default defineComponent({
offset: {
type: Number,
default: 0,
validator: (value) => value >= 0
validator: (value: number) => value >= 0
},
/**
@ -97,5 +97,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -1,5 +1,6 @@
import Company from './src/index'
import '@opentiny/vue-theme/company/index.less'
import { version } from './package.json'
Company.model = {
prop: 'modelValue',

View File

@ -31,7 +31,7 @@ export default defineComponent({
pattern: {
type: String,
default: 'default',
validator: (value) => !!$constants[value.toUpperCase()]
validator: (value: string) => !!$constants[value.toUpperCase()]
},
headerHeight: {
type: [Number, String],
@ -49,5 +49,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -38,7 +38,9 @@
<div class="tiny-crop__dialog-content">
<div class="tiny-crop__dialog-content__crop">
<img v-if="state.cropImg" :src="state.cropImg" alt="post-crop" />
<h1 v-else>{{ t('ui.crop.croppedImage') }}</h1>
<h1 v-else>
{{ t('ui.crop.croppedImage') }}
</h1>
</div>
</div>
</div>
@ -49,7 +51,17 @@
<script lang="tsx">
import { $prefix, setup, defineComponent } from '@opentiny/vue-common'
import { renderless, api } from '@opentiny/vue-renderless/crop/vue'
import { iconConmentRefresh, iconNew, iconZoomIn, iconZoomOut, iconRepeat, iconRefres, iconClose, iconYes, iconCrop } from '@opentiny/vue-icon'
import {
iconConmentRefresh,
iconNew,
iconZoomIn,
iconZoomOut,
iconRepeat,
iconRefres,
iconClose,
iconYes,
iconCrop
} from '@opentiny/vue-icon'
import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.css'
@ -158,7 +170,7 @@ export default defineComponent({
quality: {
type: Number,
default: 0.92,
validator: (value) => value <= 1 && value > 0
validator: (value: number) => value <= 1 && value > 0
},
rotatable: {
type: Boolean,

View File

@ -44,7 +44,9 @@ const validator = (value) => {
value === undefined ||
typeof value === 'string' ||
value instanceof String ||
(Array.isArray(value) && value.length === 2 && value.every((item) => typeof item === 'string' || item instanceof String))
(Array.isArray(value) &&
value.length === 2 &&
value.every((item) => typeof item === 'string' || item instanceof String))
return result
}
@ -123,12 +125,12 @@ export default defineComponent({
minDate: {
type: Date,
default: () => new Date(currentYear - 10, 0, 1),
validator: (val) => Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime())
validator: (val: Date) => Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime())
},
maxDate: {
type: Date,
default: () => new Date(currentYear + 10, 11, 31),
validator: (val) => Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime())
validator: (val: Date) => Object.prototype.toString.call(val) === '[object Date]' && !isNaN(val.getTime())
},
formatter: {
type: Function,
@ -139,5 +141,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -19,12 +19,18 @@
>
<tbody>
<tr>
<th v-if="showWeekNumber">{{ t('ui.datepicker.week') }}</th>
<th v-if="showWeekNumber">
{{ t('ui.datepicker.week') }}
</th>
<th v-for="(weekDay, key) in state.weeks" :key="key">
{{ t(`ui.datepicker.weeks.${weekDay}`) }}
</th>
</tr>
<tr v-for="(row, key) in state.rows" :class="['tiny-date-table__row', { current: isWeekActive(row[1]) }]" :key="key">
<tr
v-for="(row, key) in state.rows"
:class="['tiny-date-table__row', { current: isWeekActive(row[1]) }]"
:key="key"
>
<td v-for="(cellValue, key) in row" :key="key" :class="getCellClasses(cellValue)">
<div>
<span>
@ -55,7 +61,7 @@ export default defineComponent({
firstDayOfWeek: {
default: 7,
type: Number,
validator: (value) => value >= 1 && value <= 7
validator: (value: number) => value >= 1 && value <= 7
},
date: {},
selectionMode: {

View File

@ -4,11 +4,11 @@
"description": "",
"main": "lib/index.js",
"module": "index.ts",
"devDependencies": {
"devDependencies": {
"@opentiny-internal/vue-test-utils": "workspace:*",
"vitest": "^0.25.7"
},
"scripts": {
"scripts": {
"build": "pnpm -w build:ui $npm_package_name",
"//postversion": "pnpm build"
},
@ -17,7 +17,8 @@
"@opentiny/vue-renderless": "workspace:~",
"@opentiny/vue-progress": "workspace:~",
"@opentiny/vue-upload-list": "workspace:~",
"@opentiny/vue-upload": "workspace:~"
"@opentiny/vue-upload": "workspace:~",
"streamsaver": "2.0.6"
},
"license": "MIT"
}

View File

@ -122,7 +122,7 @@ export default defineComponent({
listType: {
type: String,
default: () => 'text',
validator: (value) => !!$constants.LIST_TYPE[value.toUpperCase().replace('-', '_')]
validator: (value: string) => !!$constants.LIST_TYPE[value.toUpperCase().replace('-', '_')]
},
mergeService: {
type: Boolean,
@ -193,5 +193,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -42,7 +42,7 @@ export default defineComponent({
labelPosition: {
type: String,
default: 'right',
validator: (value) => ~['left', 'top', 'right'].indexOf(value)
validator: (value: string) => Boolean(~['left', 'top', 'right'].indexOf(value))
},
labelWidth: {
type: String,
@ -68,8 +68,8 @@ export default defineComponent({
validateType: {
type: String,
default: 'tip',
validator(value) {
return ~['tip', 'text'].indexOf(value)
validator(value: string) {
return Boolean(~['tip', 'text'].indexOf(value))
}
},
manual: {
@ -88,5 +88,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -14,10 +14,9 @@ import useAntd from './antd'
import useiView from './iview'
import useElementUI from './element-ui'
export default defineComponent({
export default {
useAntd,
useiView,
useElementUI,
Interceptor: GridAdapter
}
)

View File

@ -4,21 +4,28 @@
"description": "",
"main": "lib/index.js",
"module": "index.ts",
"devDependencies": {
"devDependencies": {
"@opentiny-internal/vue-test-utils": "workspace:*",
"vitest": "^0.25.7"
},
"scripts": {
"scripts": {
"build": "pnpm -w build:ui $npm_package_name",
"//postversion": "pnpm build"
},
"dependencies": {
"@opentiny/vue-button": "workspace:~",
"@opentiny/vue-select": "workspace:~",
"@opentiny/vue-option": "workspace:~",
"@opentiny/vue-locale": "workspace:~",
"@opentiny/vue-modal": "workspace:~",
"@opentiny/vue-icon": "workspace:~",
"@opentiny/vue-grid": "workspace:~",
"@opentiny/vue-common": "workspace:~",
"@opentiny/vue-layout": "workspace:~",
"@opentiny/vue-row": "workspace:~",
"@opentiny/vue-col": "workspace:~",
"@opentiny/vue-alert": "workspace:~",
"@opentiny/vue-dialog-box": "workspace:~",
"@opentiny/vue-renderless": "workspace:~"
},
"license": "MIT"

View File

@ -43,7 +43,10 @@
</ul>
</div>
<div class="tiny-grid-custom__tabs-body">
<div v-show="activeName === 'base'" :class="['tabs-body-item', animateShow === 'base' ? 'active-item' : '']">
<div
v-show="activeName === 'base'"
:class="['tabs-body-item', animateShow === 'base' ? 'active-item' : '']"
>
<div class="tiny-grid-custom__alert">
<component class="tiny-svg-size" is="icon-help" />
<p>{{ t('ui.grid.individuation.tabs.base.tips') }}</p>
@ -76,7 +79,14 @@
<tiny-grid-column field="property" width="120px" class-name="setting-item">
<template v-slot="{ row, ...data }">
<div v-if="!row.children" class="setting-icon">
<span class="icon" :title="row.visible ? t('ui.grid.individuation.colConfigs.visible') : t('ui.grid.individuation.colConfigs.invisible')">
<span
class="icon"
:title="
row.visible
? t('ui.grid.individuation.colConfigs.visible')
: t('ui.grid.individuation.colConfigs.invisible')
"
>
<component
:class="[{ hide: !row.visible }, { open: row.visible }]"
:is="row.visible ? 'icon-eyeopen' : 'icon-eyeclose'"
@ -124,16 +134,25 @@
</div>
</template>
</tiny-grid-column>
<tiny-grid-column v-if="numberSorting && !isGroup" width="100px" :editor="{}" :renderer="renderNumberSorting">
<tiny-grid-column
v-if="numberSorting && !isGroup"
width="100px"
:editor="{}"
:renderer="renderNumberSorting"
>
<template v-slot:edit="{ row }">
<tiny-select v-model="row.sortingIndex" @change="handelNumberSorting($event, row)">
<tiny-option v-for="item in sortingOptions" :key="item" :label="item" :value="item"> </tiny-option>
<tiny-option v-for="item in sortingOptions" :key="item" :label="item" :value="item">
</tiny-option>
</tiny-select>
</template>
</tiny-grid-column>
</tiny-grid>
</div>
<div v-show="activeName === 'other'" :class="['tabs-body-item', animateShow === 'other' ? 'active-item' : '']">
<div
v-show="activeName === 'other'"
:class="['tabs-body-item', animateShow === 'other' ? 'active-item' : '']"
>
<div class="tiny-grid-custom__alert">
<component class="tiny-svg-size" is="icon-help" />
<p>{{ t('ui.grid.individuation.tabs.other.tips') }}</p>
@ -142,23 +161,39 @@
<li class="setting-item">
<span class="label">{{ t('ui.grid.individuation.tabs.other.sortType') }}</span>
<span class="selection">
<tiny-radio v-model="settings.sortType" label="page">{{ t('ui.grid.individuation.tabs.other.currPageSort') }}</tiny-radio>
<tiny-radio v-model="settings.sortType" label="all">{{ t('ui.grid.individuation.tabs.other.allDataSort') }}</tiny-radio>
<tiny-radio v-model="settings.sortType" label="page">{{
t('ui.grid.individuation.tabs.other.currPageSort')
}}</tiny-radio>
<tiny-radio v-model="settings.sortType" label="all">{{
t('ui.grid.individuation.tabs.other.allDataSort')
}}</tiny-radio>
</span>
</li>
<li class="setting-item">
<span class="label">{{ t('ui.grid.individuation.tabs.other.pageSize') }}</span>
<span class="selection">
<tiny-radio v-for="(item, index) in initSettings.pageSizes" :key="index" v-model="settings.pageSize" :label="item">{{ item }}</tiny-radio>
<tiny-radio
v-for="(item, index) in initSettings.pageSizes"
:key="index"
v-model="settings.pageSize"
:label="item"
>{{ item }}</tiny-radio
>
</span>
</li>
</ul>
</div>
<tiny-custom-switch v-if="multipleHistory && activeName === 'base'" ref="switch" :history-config="historyConfig"></tiny-custom-switch>
<tiny-custom-switch
v-if="multipleHistory && activeName === 'base'"
ref="switch"
:history-config="historyConfig"
></tiny-custom-switch>
</div>
</div>
<div v-if="!multipleHistory || (multipleHistory && activeName === 'base')" class="tiny-grid-custom__footer">
<tiny-button type="primary" @click="saveSettings" :disabled="saveDisabled">{{ t('ui.grid.individuation.saveBtn') }}</tiny-button>
<tiny-button type="primary" @click="saveSettings" :disabled="saveDisabled">{{
t('ui.grid.individuation.saveBtn')
}}</tiny-button>
<tiny-button @click="resetSettings">{{ t('ui.grid.individuation.resetBtn') }}</tiny-button>
<tiny-button @click="cancelSettings">{{ t('ui.grid.individuation.cancelBtn') }}</tiny-button>
</div>
@ -187,7 +222,7 @@ import {
} from '@opentiny/vue-icon'
import Select from '@opentiny/vue-select'
import Option from '@opentiny/vue-option'
import CustomSwitch from './custom-switch'
import CustomSwitch from './custom-switch.vue'
import { extend } from '@opentiny/vue-renderless/common/object'
import { isNull } from '@opentiny/vue-renderless/grid/static/'
@ -315,7 +350,8 @@ export default {
return this.tinyTable.isGroup
},
historyConfig() {
const multipleHistory = isNull(this.multipleHistory) || typeof this.multipleHistory === 'boolean' ? {} : this.multipleHistory
const multipleHistory =
isNull(this.multipleHistory) || typeof this.multipleHistory === 'boolean' ? {} : this.multipleHistory
return extend(true, {}, this.initSettings.multipleHistory || {}, multipleHistory)
}

View File

@ -26,7 +26,13 @@ import { isNumber } from '@opentiny/vue-renderless/common/type'
import { iconMinscreen, iconFullscreen } from '@opentiny/vue-icon'
import { h, hooks, $prefix, defineComponent } from '@opentiny/vue-common'
import { toStringJSON, isEmpty, isPlainObject, toJSONString, find } from '@opentiny/vue-renderless/grid/static/'
import { getFuncText, emitEvent, getEventTargetNode, GlobalEvent, getListeners } from '@opentiny/vue-renderless/grid/utils'
import {
getFuncText,
emitEvent,
getEventTargetNode,
GlobalEvent,
getListeners
} from '@opentiny/vue-renderless/grid/utils'
import GridCustom from './custom.vue'
import GridCustomSelect from './custom-select.vue'
import { GridButton, GridConfig, GridAdapter, GridTools } from '@opentiny/vue-grid'
@ -84,15 +90,15 @@ function renderCustomWrapper({ _vm, settingStore, settingsBtnOns, tableFullColum
h('div', { class: 'tiny-grid-custom__setting-btn', on: settingsBtnOns }, [
setting?.simple
? h('tiny-grid-custom-select', {
on: {
saveSettings: _vm.handleSaveSettings
},
props: {
data: tableFullColumn,
setting,
value: settingStore.customVisible
}
})
on: {
saveSettings: _vm.handleSaveSettings
},
props: {
data: tableFullColumn,
setting,
value: settingStore.customVisible
}
})
: h(GridConfig.icon.custom, { class: 'tiny-svg-size' })
]),
h('div', { class: 'tiny-grid-custom__option-wrapper' }, [
@ -462,7 +468,9 @@ export default defineComponent({
if (settingsStorage && settingsStorage.pageSize) {
const pageSize = settingsStorage.pageSize
this.$grid.pagerConfig && this.$grid.pagerConfig.pageSize !== pageSize && this.$grid.pageSizeChange(pageSize, $grid.autoLoad === false)
this.$grid.pagerConfig &&
this.$grid.pagerConfig.pageSize !== pageSize &&
this.$grid.pageSizeChange(pageSize, $grid.autoLoad === false)
}
}
@ -673,7 +681,9 @@ export default defineComponent({
handleClickCustomEvent() {
let { settingStore } = this
this.$refs.custom.settings.pageSize =
(this.$grid.pagerConfig && this.$grid.pagerConfig.pageSize) || (this.settingOpts.storage === 'local' && this.$refs.custom.settings.pageSize) || 10
(this.$grid.pagerConfig && this.$grid.pagerConfig.pageSize) ||
(this.settingOpts.storage === 'local' && this.$refs.custom.settings.pageSize) ||
10
settingStore.customVisible = !settingStore.customVisible
},
@ -761,5 +771,4 @@ export default defineComponent({
}
}
}
}
)
})

View File

@ -1,5 +1,6 @@
import Hrapprover from './src/index'
import '@opentiny/vue-theme/hrapprover/index.less'
import { version } from './package.json'
Hrapprover.model = {
prop: 'modelValue',

View File

@ -10,6 +10,7 @@
*
*/
import IndexBarAnchor from './src/index.vue'
import { version } from './package.json'
/* istanbul ignore next */
IndexBarAnchor.install = function (Vue) {

View File

@ -29,7 +29,7 @@ export default defineComponent({
type: {
type: String,
default: 'IPv4',
validator: (value) => ~['IPv4', 'IPv6'].indexOf(value)
validator: (value: string) => Boolean(~['IPv4', 'IPv6'].indexOf(value))
},
/**
@ -53,5 +53,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -28,11 +28,10 @@ export default defineComponent({
size: {
type: String,
default: 'medium',
validator: (value) => ~['medium', 'small', 'mini'].indexOf(value)
validator: (value: string) => Boolean(~['medium', 'small', 'mini'].indexOf(value))
}
},
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -35,7 +35,7 @@ export default defineComponent({
},
maxItem: {
type: Number,
validator: (value) => value >= 0
validator: (value: number) => value >= 0
},
title: {
type: String,
@ -65,5 +65,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -15,7 +15,7 @@ import '@opentiny/vue-theme/loading/index.less'
import { setupComponent } from '@opentiny/vue-common'
import { version } from './package.json'
let Loadings = {}
let Loadings: any = {}
/* istanbul ignore next */
Loadings.install = function (app) {

View File

@ -10,7 +10,7 @@
*
*/
import { $props, $prefix, $setup, defineComponent } from '@opentiny/vue-common'
import { constants, tinyMode } from './service'
import { constants } from './service'
import template from 'virtual-template?pc|mobile'
export default defineComponent({
@ -20,7 +20,7 @@ export default defineComponent({
...$props,
type: {
type: String,
validator: (value) => ~['primary', 'simple'].indexOf(value)
validator: (value: string) => Boolean(~['primary', 'simple'].indexOf(value))
},
loadtext: {
type: String,
@ -31,5 +31,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -1,45 +0,0 @@
<!--
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
-->
<template>
<transition name="tiny-loading-fade" @after-leave="handleAfterLeave">
<div
v-show="state.visible"
class="tiny-loading tiny-loading__mask"
:style="{ backgroundColor: state.background || '' }"
:class="[state.customClass, { 'is-fullscreen': state.fullscreen }]"
>
<div class="tiny-loading__spinner">
<svg v-if="!state.spinner" class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="24" fill="none" />
</svg>
<component v-else :is="state.spinner" class="tiny-icon-loading" />
<p v-if="state.text" class="tiny-loading__text">{{ state.text }}</p>
</div>
</div>
</transition>
</template>
<script lang="tsx">
import { $prefix, setup, defineComponent } from '@opentiny/vue-common'
import { renderless, api } from '@opentiny/vue-renderless/loading/vue'
export default defineComponent({
inheritAttrs: false,
name: $prefix + 'Loading',
props: {
_constants: Object
},
setup(props, context) {
return setup({ props, context, renderless, api, mono: true })
}
})
</script>

View File

@ -70,7 +70,7 @@ export default defineComponent({
trigger: {
type: String,
default: 'click',
validator: (value) => ~['click', 'focus', 'hover', 'manual'].indexOf(value)
validator: (value: string) => Boolean(~['click', 'focus', 'hover', 'manual'].indexOf(value))
},
visibleArrow: {
default: true
@ -89,5 +89,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -94,7 +94,7 @@ export default defineComponent({
trigger: {
type: String,
default: 'click',
validator: (value) => ~['click', 'focus', 'hover', 'manual'].indexOf(value)
validator: (value: string) => Boolean(~['click', 'focus', 'hover', 'manual'].indexOf(value))
},
visibleArrow: {
default: true

View File

@ -54,7 +54,7 @@ export default defineComponent({
type: Number,
default: 0,
required: true,
validator: (val) => val >= 0 && val <= 100
validator: (val: number) => val >= 0 && val <= 100
},
showText: {
type: Boolean,
@ -62,7 +62,7 @@ export default defineComponent({
},
status: {
type: String,
validator: (value) => !!$constants.PROGRESS_STATUS[value.toUpperCase()]
validator: (value: string) => !!$constants.PROGRESS_STATUS[value.toUpperCase()]
},
strokeWidth: {
type: Number,
@ -75,7 +75,7 @@ export default defineComponent({
type: {
type: String,
default: $constants.PROGRESS_TYPE.LINE,
validator: (value) => !!$constants.PROGRESS_TYPE[value.toUpperCase()]
validator: (value: string) => !!$constants.PROGRESS_TYPE[value.toUpperCase()]
},
width: {
type: Number,
@ -85,5 +85,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -21,23 +21,23 @@ export default defineComponent({
gutter: {
type: Number,
default: 0,
validator(value) {
validator(value: number) {
return value >= 0
}
},
justify: {
type: String,
default: 'start',
validator: (value) => ~['start', 'center', 'end', 'space-between', 'space-around'].indexOf(value)
validator: (value: string) => Boolean(~['start', 'center', 'end', 'space-between', 'space-around'].indexOf(value))
},
align: {
type: String,
default: 'top',
validator: (value) => ~['top', 'middle', 'bottom'].indexOf(value)
validator: (value: string) => Boolean(~['top', 'middle', 'bottom'].indexOf(value))
},
order: {
type: String,
validator: (value) => ~['asc', 'des'].indexOf(value)
validator: (value: string) => Boolean(~['asc', 'des'].indexOf(value))
},
tag: {
type: String,
@ -51,5 +51,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -39,7 +39,7 @@ export default defineComponent({
direction: {
type: String,
default: 'left',
validator: (value) => ~['up', 'left', 'down', 'right'].indexOf(value)
validator: (value: string) => Boolean(~['up', 'left', 'down', 'right'].indexOf(value))
},
hoverStop: {
type: Boolean,
@ -49,5 +49,4 @@ export default defineComponent({
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -72,11 +72,10 @@ export default defineComponent({
themeType: {
type: String,
default: 'primary',
validator: (value) => ['primary', 'gray'].includes(value)
validator: (value: string) => ['primary', 'gray'].includes(value)
}
},
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -11,6 +11,7 @@
*/
import Tabbar from './src/index.vue'
import '@opentiny/vue-theme-mobile/tabbar/index.less'
import { version } from './package.json'
Tabbar.model = {
prop: 'modelValue',

View File

@ -1,35 +0,0 @@
/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import { $props, $prefix, $setup } from '@opentiny/vue-common'
import PCTemplate from './pc'
import MobileTemplate from './mobile'
const template = (mode) => {
if (process.env.TINY_MODE === 'pc') return PCTemplate
else if (process.env.TINY_MODE === 'mobile') return MobileTemplate
else return mode === 'mobile' ? MobileTemplate : PCTemplate
}
export default {
name: $prefix + 'Table',
props: {
...$props,
columns: Array,
data: Array,
width: String,
defaultChecked: Array,
keys: String
},
setup(props, context) {
return $setup({ props, context, template })
}
}

View File

@ -69,27 +69,27 @@ export default {
expandTabsTitle,
expandTabsMode
} = this
const tabsExpandIcon = showExpandTabs
? (
const tabsExpandIcon = showExpandTabs ? (
<div class="tiny-mobile-tabs__expand-icon">
<span
slot="reference"
class="tiny-mobile-tabs__expand"
onClick={() => {
expandTabShow()
}}
>
}}>
<icon-chevron-down></icon-chevron-down>
</span>
</div>
)
: null
) : null
const tabsExpandContent = (
<div
class="tiny-mobile-tabs__expand-content"
style={state.showExpandItem ? { display: 'block', width: expandPanesWidth ? expandPanesWidth + 'px' : '' } : { display: 'none' }}
>
style={
state.showExpandItem
? { display: 'block', width: expandPanesWidth ? expandPanesWidth + 'px' : '' }
: { display: 'none' }
}>
<div class="tiny-mobile-tabs__expand-mask"></div>
<div class="tiny-mobile-tabs__expand-header">
<label class="tiny-mobile-tabs__expand-header-title" style={state.expandHeaderStyle}>
@ -109,8 +109,7 @@ export default {
class={{
'tiny-mobile-tabs__expand-item': true,
[`tiny-mobile-tabs__expand-mode-${expandTabsMode}`]: expandTabsMode === 'columns'
}}
>
}}>
<div
class={{
'tiny-mobile-tabs__expand-item-title': true,
@ -118,52 +117,7 @@ export default {
}}
onClick={(e) => {
onTabClick(pane, tabName, e)
}}
>
{tabTitle}
</div>
</div>
)
})}
</div>
</div>
)
const tabsExpandContent = (
<div
class="tiny-mobile-tabs__expand-content"
style={state.showExpandItem ? { display: 'block', width: expandPanesWidth ? expandPanesWidth + 'px' : '' } : { display: 'none' }}
>
<div class="tiny-mobile-tabs__expand-mask"></div>
<div class="tiny-mobile-tabs__expand-header">
<label class="tiny-mobile-tabs__expand-header-title" style={state.expandHeaderStyle}>
{expandTabsTitle}
</label>
<span slot="reference" class="tiny-mobile-tabs__expand" style={{ transform: 'rotate(180deg)' }}>
<icon-chevron-down></icon-chevron-down>
</span>
</div>
<div class="tiny-mobile-tabs__expand-list">
{panes.map((pane, index) => {
const tabName = pane.name || pane.state.index || index
const tabTitle = pane.$slots.title || pane.title
return (
<div
class={{
'tiny-mobile-tabs__expand-item': true,
[`tiny-mobile-tabs__expand-mode-${expandTabsMode}`]: expandTabsMode === 'columns'
}}
>
<div
class={{
'tiny-mobile-tabs__expand-item-title': true,
'is-current': currentName === tabName
}}
onClick={(e) => {
onTabClick(pane, tabName, e)
}}
>
}}>
{tabTitle}
</div>
</div>
@ -184,7 +138,6 @@ export default {
<span class="tiny-mobile-tabs__icon-close">
<icon-close
onClick={(e) => {
/* eslint-disable no-useless-call */
onTabRemove(pane, e)
}}
/>
@ -210,8 +163,7 @@ export default {
aria-selected={pane.state.active}
onClick={(e) => {
onTabClick(pane, tabName, e)
}}
>
}}>
<span class="tiny-mobile-tabs__name" style={activeColor && pane.state.active ? { color: activeColor } : {}}>
{tabTitle}
{btnClose}
@ -229,12 +181,13 @@ export default {
panes.length > 4 ? 'tiny-mobile-tabs__wrap-scrollable' : '',
showExpandTabs ? 'is-show-expand' : '',
`is-${state.rootTabs.position}`
]}
>
]}>
<div class={['tiny-mobile-tabs__nav-scroll']} ref="navScroll">
<div class={['tiny-mobile-tabs__nav', `is-${state.rootTabs.position}`]} ref="nav" role="tablist">
{tabs}
<div class="tiny-mobile-tabs__line" style={[state.navStyle, activeColor ? { backgroundColor: activeColor } : {}]}></div>
<div
class="tiny-mobile-tabs__line"
style={[state.navStyle, activeColor ? { backgroundColor: activeColor } : {}]}></div>
</div>
</div>
{[tabsExpandIcon, tabsExpandContent]}

View File

@ -25,12 +25,11 @@ export default defineComponent({
effect: {
type: String,
default: 'light',
validator: (value) => ~['dark', 'light', 'plain'].indexOf(value)
validator: (value: string) => Boolean(~['dark', 'light', 'plain'].indexOf(value))
},
beforeDelete: Function
},
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})

View File

@ -21,7 +21,7 @@ export default defineComponent({
visible: {
type: String,
default: () => 'always',
validator: (value) => ['always', 'auto'].includes(value)
validator: (value: string) => ['always', 'auto'].includes(value)
},
adjustArrow: {
type: Boolean,
@ -92,7 +92,7 @@ export default defineComponent({
},
type: {
type: String,
validator: (value) => ~['normal', 'warning', 'error', 'info', 'success'].indexOf(value)
validator: (value: string) => Boolean(~['normal', 'warning', 'error', 'info', 'success'].indexOf(value))
},
visibleArrow: {
type: Boolean,
@ -157,8 +157,7 @@ export default defineComponent({
role="tooltip"
aria-hidden={this.disabled || !this.state.showPopper ? 'true' : 'false'}
onMouseenter={() => mouseenter()}
onMouseleave={() => mouseleave()}
>
onMouseleave={() => mouseleave()}>
{content}
</div>
])
@ -176,7 +175,9 @@ export default defineComponent({
const stringifyClassArr = (classArr) =>
classArr
.filter((item) => item)
.map((item) => (typeof item === 'string' ? item.trim() : typeof item === 'object' ? stringifyClassObj(item) : ''))
.map((item) =>
typeof item === 'string' ? item.trim() : typeof item === 'object' ? stringifyClassObj(item) : ''
)
.join(' ')
const addTooltipClass = (bindClass) => {

View File

@ -46,7 +46,7 @@ export default defineComponent({
*/
data: {
type: Object,
validator: (value) =>
validator: (value: any) =>
typeof value.userName === 'string' && value.imgUrl
? typeof value.imgUrl === 'string'
: true && typeof value.userDescription === 'string' && (!value.values || Array.isArray(value.values))

View File

@ -46,7 +46,7 @@ export default defineComponent({
type: {
type: String,
default: 'label',
validator: (value) => ~['icon', 'image', 'label'].indexOf(value)
validator: (value: string) => Boolean(~['icon', 'image', 'label'].indexOf(value))
},
/**
@ -69,7 +69,7 @@ export default defineComponent({
messageType: {
type: String,
default: 'details',
validator: (value) => ~['details', 'basic'].indexOf(value)
validator: (value: string) => Boolean(~['details', 'basic'].indexOf(value))
},
/**
@ -87,12 +87,11 @@ export default defineComponent({
type: [Number, String],
default: 'medium',
validator(val) {
return typeof val === 'string' ? ~['large', 'medium', 'small'].indexOf(val) : typeof val === 'number'
return Boolean(typeof val === 'string' ? ~['large', 'medium', 'small'].indexOf(val) : typeof val === 'number')
}
}
},
setup(props, context) {
return $setup({ props, context, template })
}
}
)
})