Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form): replace with Taro Form and add the rest property for passt… #3016

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
"dev:rtl": "VITE_RTL=rtl vite --open --force",
"dev:jrkf": "VITE_APP_PROJECT_ID=jrkf vite --open --force",
"dev:taro:rn:dark": "THEME=dark pnpm dev:taro:rn",
"predev:taro": "SKIPDD=1 pnpm run update:taro:entry",
"predev:taro": "pnpm run update:taro:entry",
"dev:taro": "pnpm --dir ./packages/nutui-taro-demo dev",
"dev:taro:h5": "pnpm dev:taro h5",
"predev:jdtaro": "SKIPDD=1 pnpm run update:taro:entry",
"predev:jdtaro": "pnpm run update:taro:entry",
"dev:jdtaro": "JD=1 pnpm --dir ./packages/nutui-taro-demo dev",
"dev:jdtaro:jdharmonycpp": "pnpm run clone:jdharmony cpp && pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp",
"dev:jdtaro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
Expand All @@ -70,7 +70,7 @@
"build:taro:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp node scripts/build-taro.mjs",
"build:site": "npm run checked && vite build --config vite.config.site.mts",
"build:site:jmapp": "npm run checked && VITE_APP_PROJECT_ID=jmapp vite build",
"prebuild:taro:site": "SKIPDD=1 pnpm run update:taro:entry",
"prebuild:taro:site": "pnpm run update:taro:entry",
"build:taro:site": "npm run checked:taro && npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:jdtaro:site": "npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
Expand Down
2 changes: 1 addition & 1 deletion packages/nutui-taro-demo/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const Index = () => {
)}
<View className="index-components-sublist">
{nav.packages.map((com) =>
com.show && com.taro && com.dd && (!search || new RegExp(search, 'ig').test(com.name.toLowerCase())) ? (
com.show && com.taro && (!search || new RegExp(search, 'ig').test(com.name.toLowerCase())) ? (
<View
key={com.name}
className="index-components-sublist-item"
Expand Down
30 changes: 0 additions & 30 deletions scripts/harmony/update-taro-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* 更新nutui-taro-demo入口文件
*/
const fse = require('fs-extra')
const path = require('path')
const config = require('../../src/config.json')
const param = process.env.C

Expand All @@ -13,35 +12,6 @@ function specialComponent(name) {
return entries.includes(name.toLowerCase())
}

// 已适配组件对象
const adaptedArray = []
config.nav.map((item) => {
item.packages.forEach((element) => {
const { name, version, dd } = element
// 通过 pre 命令在 h5 和小程序预览或构建的时候,去掉鸿蒙适配的限制,从而在预览H5 和小程序时展示出未适配鸿蒙的组件
// 例如 Form 组件未适配鸿蒙但适配了 H5 和小程序,启动 H5或小程序开发环境后,Form 组件并未被编译到开发环境中。导致无法查看 Form 组件。
if (!dd && !process.env.SKIPDD) return // 未适配不导出
if (specialComponent(name)) return
adaptedArray.push({
...element,
lowercaseName: element.name.toLowerCase(),
enName: item.enName,
})
})
})
// 子组件
const childAdaptedArray = [
'cellgroup',
'row',
'col',
'griditem',
'swiperitem',
'hoverbuttonitem',
'avatargroup',
'icon',
'tabpane',
]

// 更新 app.config.ts 文件
const createConfig = async () => {
const configRef = []
Expand Down
11 changes: 7 additions & 4 deletions src/packages/form/form.taro.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { ReactNode } from 'react'
import classNames from 'classnames'
import { Form as TForm, FormProps as TFormProps } from '@tarojs/components'
import { Context } from './context'
import { SECRET, useForm } from './useform.taro'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
import { ComponentDefaults } from '@/utils/typings'
import Cell from '@/packages/cell/index.taro'
import { FormInstance } from '@/packages/form/types'

export interface FormProps extends BasicComponent {
export interface FormProps extends TFormProps {
footer: ReactNode
initialValues: any
name: string
Expand Down Expand Up @@ -48,6 +49,7 @@ export const Form = React.forwardRef<FormInstance, Partial<FormProps>>(
labelPosition,
starPosition,
form,
...rest
} = {
...defaultProps,
...props,
Expand Down Expand Up @@ -77,7 +79,8 @@ export const Form = React.forwardRef<FormInstance, Partial<FormProps>>(
}

return (
<form
<TForm
{...rest}
className={classNames(
classPrefix,
PositionInfo[labelPosition],
Expand All @@ -101,7 +104,7 @@ export const Form = React.forwardRef<FormInstance, Partial<FormProps>>(
<Cell className={`${classPrefix}-footer`}>{footer}</Cell>
) : null}
</Cell.Group>
</form>
</TForm>
)
}
)
Expand Down
Loading