Skip to content

Commit

Permalink
Merge branch 'feat_v3.x' into v_dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyatong authored Dec 27, 2024
2 parents c6f96fd + a91e0e2 commit a00c0b6
Show file tree
Hide file tree
Showing 195 changed files with 3,848 additions and 3,614 deletions.
65 changes: 23 additions & 42 deletions migrate-from-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,8 @@ plugins: [

#### Indicator

- 移除 `block`,暴露自定义节点
- 移除 `align`,暴露自定义节点
- `vertical` 重命名为`direction`,默认值为 `horizontal`,可选 `vertical`
- 移除 `fillZero`,暴露自定义节点
- `size` 重命名为 `total`
- 增加非数字展示,并设置为默认状态
- type 属性的值调整为 `'anchor'``'slide'`
- color 属性的值增加 `'white'`

#### Menu

Expand All @@ -273,16 +269,9 @@ plugins: [

#### NavBar

- `desc` 重命名为 `right`,类型修改为 `React.Node`
- 新增 `left`,左侧内容,渲染在返回区域的右侧
- 新增 `back`,返回区域内容
- `onClickBack` 重命名为 `onBackClick`
- 移除 `title`,通过 `children` 实现
- 移除 `leftText` `leftShow`,通过 `back``left`实现
- `safeAreaInsetTop` 重命名为 `safeArea`
- `border` 废弃
- 移除 `onClickTitle` `onClickRight` `onClickIcon`,通过在`left``title``right`自定义事件实现,参考文档demo示例
-
- 移除 titleAlign 属性,可通过 title 和 children 替代
- 增加 title 属性,默认居中展示
- 组件中出现 children ,则采取 titleAlign 的 left 方式布局

#### Pagination

Expand Down Expand Up @@ -417,6 +406,10 @@ plugins: [

#### Input

- 新增 `plain` 属性,标记为 纯文本型;该值默认为false,标记为 container 容器型;
- 区分了 readonly 和 disabled 的样式;
- 删除一些样式变量,统一到由通用变量控制,如`$input-color``$input-disabled-color`

#### InputNumber

- 增加 `allowEmpty`, 用于允许内容是否为空
Expand Down Expand Up @@ -516,32 +509,21 @@ plugins: [

#### TextArea

- `maxlength` 重命名为 `maxLength`
- `readonly` 重命名为 `readOnly`
- `limitShow` 重命名为 `showCount`
- `autosize` 重命名为 `autoSize`
- 移除 `textAlign`,可通过 `style` 传入
- `defaultValue` 改为非受控,增加受控值 `value`
- 新增 `plain` 属性,标记为 纯文本型;该值默认为false,标记为 container 容器型;
- 新增 `status` 属性,值为 `default` | `error`,可定义输入框的状态;
- 删掉一些可使用基础样式变量,并且建议使用基础样式变量的样式变量,比如 `$textarea-font` `$textarea-limit-color` `$textarea-disabled-color`

#### Uploader

- `maximize` 重命名为 `maxFileSize`
- `maximum` 重命名为 `maxCount`
- `listType ` 重命名为 `previewType`
- `isDeletable ` 重命名为 `deletable`
- `isPreview` 重命名为 ` preview`
- `defaultImg` 重命名为 ` previewUrl`
- `defaultFileList` 重命名为 ` defaultValue`
- `uploadIconTip` 重命名为 `uploadLabel`,类型变更为 `ReactNode`
- `onBeforeUpload` 重命名为 `beforeUpload`
- `onBeforeXhrUpload` 重命名为 `beforeXhrUpload`
- `onBeforeDelete` 重命名为 `beforeDelete`
- `onRemove` 重命名为 `onDelete`
- 增加 `fit`,用于图片填充模式
- 增加 `value`,用于受控传值
- 移除 `uploadIconSize`,可通过 icon 属性传入自定义 icon 或借助 CSS Variables 修改 icon 大小
- `uploadIcon` 类型从 `string` 调整为 `ReactNode`
- `onChange` 参数类型从 `{fileList: FileItem[], event: any}` 调整为 `FileItem[]`
- 移除了组件内部关于ajax相关网络逻辑的处理
- 移除了`url``headers``data``xhrState``withCredentials``timeout` 网络配置相关props
- 移除了`onStart``onProgress``onFailure``beforeXhrUpload` 触发时机函数相关props
- 新增`onOverCount`属性,文件数量超过限制时触发
- 新增`onUploadQueueChange`属性,图片上传队列变化时触发
- 简化`FileItem`类型的使用,除url外其他属性变为可选
- 调整多选状态下`maxCount`属性的默认值为`Number.MAX_VALUE`
- 新增了的 `upload` 方法
- `defaultValue``value` 的类型从 `FileType` 变更为 `FileItem`

### 操作反馈

Expand Down Expand Up @@ -747,9 +729,8 @@ plugins: [

#### Price

- `decimalDigits` 重命名为 `digits`
- 移除 `needSymbol`,通过 `symbol` 判断是否需要加上 symbol 符号
- 新增 `line`,是否展示划线价
- 修改 `size`,增加 'xlarge' 尺寸
- 新增 `color`, 价格类型

#### Progress

Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 75 additions & 18 deletions scripts/build-taro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ async function buildUMD() {
}

async function buildAllCSS() {
// 拷贝styles
async function copyStyles() {
await copy(
resolve(__dirname, '../src/styles'),
resolve(__dirname, '../dist/styles')
)

const content = [
`@import './styles/theme-default.scss';`,
`@import './styles/variables.scss';`,
`@import './styles/mixins/index.scss';`,
`@import './styles/animation/index.scss';`,
]
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
content[1] = `@import '../variables-${projectID}.scss';`
}
const scssFiles = await glob(['dist/es/packages/**/*.scss'])
scssFiles.forEach((file) => {
content.push(
`@import '${relativeFilePath('/dist/style.scss', '/' + file)}';`
)
})
dest('dist/style.scss', content.join('\n'))
}
await copyStyles()
await vite.build({
logLevel: 'error',
resolve: {
Expand All @@ -221,7 +247,7 @@ async function buildAllCSS() {
build: {
emptyOutDir: false,
lib: {
entry: './dist/styles/themes/default.scss',
entry: './dist/style.scss',
formats: ['es'],
name: 'style',
fileName: 'style',
Expand All @@ -230,6 +256,29 @@ async function buildAllCSS() {
})
}

async function buildThemeCSS() {
await vite.build({
logLevel: 'error',
resolve: {
alias: [{ find: '@', replacement: resolve(__dirname, '../src') }],
},
build: {
emptyOutDir: false,
rollupOptions: {
output: [
{
dir: 'dist/styles/themes',
assetFileNames: 'default.css',
},
],
},
lib: {
entry: './dist/styles/themes/default.scss',
},
},
})
}

// 拷贝styles
async function copyStyles() {
await copy(
Expand Down Expand Up @@ -338,39 +387,45 @@ async function buildCSS(p) {

}

console.log('clean dist')
console.time('clean dist')
await deleteAsync('dist')
console.log('clean: ✅')
console.timeEnd('clean dist')

await generate()

console.log('build ES Module')
console.time('build ES Module')
await buildES()
console.log('build ES Module: ✅')
console.timeEnd('build ES Module')

console.log('build CommonJS')
console.time('build CommonJS')
await buildCJS()
console.log('build CommonJS: ✅')
console.timeEnd('build CommonJS')

console.log('build UMD')
console.time('build UMD')
await buildUMD()
console.log('build UMD: ✅')
console.timeEnd('build UMD')

console.log('Build CSS')
console.time('Build CSS')
await buildCSS()
console.log('Build CSS: ✅')
console.timeEnd('Build CSS')

console.log('Copy Styles')
console.time('Copy Styles')
await copyStyles()
console.log('Copy Styles: ✅')
console.timeEnd('Copy Styles')

console.log('Build All CSS')
console.time('Build All CSS')
await buildAllCSS()
console.log('Build All CSS: ✅')
console.timeEnd('Build All CSS')

console.time('Build Theme CSS')
await buildThemeCSS()
console.timeEnd('Build Theme CSS')

console.log('Build Declaration')
console.time('Build Declaration')
await buildDeclaration()
console.log('Build Declaration: ✅')
console.timeEnd('Build Declaration')

// await exportProps()

await deleteAsync([
'dist/es/packages/nutui.react.js',
Expand All @@ -379,4 +434,6 @@ await deleteAsync([
'dist/es/packages/nutui.react.scss.js',
])

codeShift('Taro')
console.time('Build JSDoc')
codeShift()
console.timeEnd('Build JSDoc')
76 changes: 55 additions & 21 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,32 @@ async function buildUMD(p) {
}

async function buildAllCSS() {
// 拷贝styles
async function copyStyles() {
await copy(
resolve(__dirname, '../src/styles'),
resolve(__dirname, '../dist/styles')
)

const content = [
`@import './styles/theme-default.scss';`,
`@import './styles/variables.scss';`,
`@import './styles/mixins/index.scss';`,
`@import './styles/animation/index.scss';`,
]
const projectID = process.env.VITE_APP_PROJECT_ID
if (projectID) {
content[1] = `@import '../variables-${projectID}.scss';`
}
const scssFiles = await glob(['dist/es/packages/**/*.scss'])
scssFiles.forEach((file) => {
content.push(
`@import '${relativeFilePath('/dist/style.scss', '/' + file)}';`
)
})
dest('dist/style.scss', content.join('\n'))
}
await copyStyles()
await vite.build({
logLevel: 'error',
resolve: {
Expand All @@ -181,7 +207,7 @@ async function buildAllCSS() {
build: {
emptyOutDir: false,
lib: {
entry: './dist/styles/themes/default.scss',
entry: './dist/style.scss',
formats: ['es'],
name: 'style',
fileName: 'style',
Expand All @@ -190,6 +216,29 @@ async function buildAllCSS() {
})
}

async function buildThemeCSS() {
await vite.build({
logLevel: 'error',
resolve: {
alias: [{ find: '@', replacement: resolve(__dirname, '../src') }],
},
build: {
emptyOutDir: false,
rollupOptions: {
output: [
{
dir: 'dist/styles/themes',
assetFileNames: 'default.css',
},
],
},
lib: {
entry: './dist/styles/themes/default.scss',
},
},
})
}

// 拷贝styles
async function copyStyles() {
await copy(
Expand Down Expand Up @@ -218,6 +267,7 @@ async function buildCSS(p) {
const cssFiles = await glob(['src/packages/**/*.scss'], {
ignore: ['src/packages/**/demo.scss'],
})

const variables = await readFile(
join(__dirname, '../src/styles/variables.scss')
)
Expand Down Expand Up @@ -296,26 +346,6 @@ async function buildCSS(p) {
}
}

// async function exportProps() {
// const types = []
// const a = await readFile(join(__dirname, '../src/config.json'))
// const componentsConfig = JSON.parse(a.toString())
// componentsConfig.nav.forEach((item) => {
// item.packages.forEach((element) => {
// const { name, show, exportEmpty } = element
// if (show || exportEmpty) {
// const lowerName = name.toLowerCase()
// if (lowerName === 'icon') return
// types.push(`export * from './${lowerName}/index'`)
// }
// })
// })
// await appendFile(
// join(__dirname, '../dist/es/packages/nutui.react.build.d.ts'),
// types.join('\n')
// )
// }

console.time('clean dist')
await deleteAsync('dist')
console.timeEnd('clean dist')
Expand Down Expand Up @@ -346,6 +376,10 @@ console.time('Build All CSS')
await buildAllCSS()
console.timeEnd('Build All CSS')

console.time('Build Theme CSS')
await buildThemeCSS()
console.timeEnd('Build Theme CSS')

console.time('Build Declaration')
await buildDeclaration()
console.timeEnd('Build Declaration')
Expand Down
Loading

0 comments on commit a00c0b6

Please sign in to comment.