-
Notifications
You must be signed in to change notification settings - Fork 278
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
feat(form): [form] form component adapt to old theme #2562
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<div> | ||
<tiny-config-provider :design="design"> | ||
<tiny-form :model="formData" class="demo-form"> | ||
<tiny-form-item label="年龄" prop="age" required> | ||
<tiny-numeric v-model="formData.age"></tiny-numeric> | ||
</tiny-form-item> | ||
<tiny-form-item label="姓名" prop="name" required> | ||
<tiny-input v-model="formData.name"></tiny-input> | ||
</tiny-form-item> | ||
</tiny-form> | ||
</tiny-config-provider> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { TinyConfigProvider, TinyForm, TinyFormItem, TinyInput, TinyNumeric } from '@opentiny/vue' | ||
|
||
const design = ref({ | ||
name: 'smb', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Form: { | ||
hideRequiredAsterisk: true | ||
} | ||
} | ||
}) | ||
|
||
const formData = ref({ | ||
name: '', | ||
age: '' | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.demo-form { | ||
width: 380px; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('测试隐藏星号', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('config-provider#form') | ||
|
||
await expect(page.locator('#form .tiny-form')).toBeVisible() | ||
const beforeElement = await page.evaluate(() => { | ||
const labelBefore = document.querySelector('.tiny-form .tiny-form-item__label') | ||
const { display, content } = window.getComputedStyle(labelBefore, '::before') | ||
return { display, content } | ||
}) | ||
expect(beforeElement.content).toBe('none') | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div> | ||
<tiny-config-provider :design="design"> | ||
<tiny-form :model="formData" class="demo-form"> | ||
<tiny-form-item label="年龄" prop="age" required> | ||
<tiny-numeric v-model="formData.age"></tiny-numeric> | ||
</tiny-form-item> | ||
<tiny-form-item label="姓名" prop="name" required> | ||
<tiny-input v-model="formData.name"></tiny-input> | ||
</tiny-form-item> | ||
</tiny-form> | ||
</tiny-config-provider> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { TinyConfigProvider, TinyForm, TinyFormItem, TinyInput, TinyNumeric } from '@opentiny/vue' | ||
|
||
export default { | ||
components: { | ||
TinyConfigProvider, | ||
TinyForm, | ||
TinyFormItem, | ||
TinyInput, | ||
TinyNumeric | ||
}, | ||
data() { | ||
return { | ||
design: { | ||
name: 'smb', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Form: { | ||
hideRequiredAsterisk: true | ||
} | ||
} | ||
}, | ||
formData: { | ||
name: '', | ||
age: '' | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.demo-form { | ||
width: 380px; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ import { test, expect } from '@playwright/test' | |
|
||
test('必填项红色星号', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('form#smb-required') | ||
await page.goto('form#hide-required') | ||
|
||
const demo = page.locator('#smb-required') | ||
const demo = page.locator('#hide-required') | ||
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Inconsistency found in demo ID configuration The test file has been updated to use 'hide-required', but there's an inconsistency in the configuration:
This mismatch needs to be fixed to maintain consistency across the codebase. 🔗 Analysis chainLGTM! Verify the demo ID changes across related files. The navigation and selector updates are consistent with the renamed demo ID. Let's verify the demo ID changes are consistent across related files: The previous results show that 'smb-required' is still present in apis/form.js while the test was updated to use 'hide-required'. Let's verify all occurrences and related files to ensure consistency. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify that all references to the old demo ID 'smb-required' have been updated to 'hide-required'
# Search for any remaining references to the old ID
echo "Checking for any remaining references to 'smb-required'..."
rg "smb-required"
# Search for the new ID to confirm it exists in demo configuration
echo "Verifying 'hide-required' exists in demo files..."
rg "hide-required" "examples/sites/demos/webdoc/form.js"
Length of output: 464 Script: #!/bin/bash
# Let's check all possible demo configuration files and related files
echo "Checking for 'hide-required' in all files..."
rg "hide-required"
echo -e "\nChecking form demo configuration files..."
fd "form.js" examples/sites/demos/
Length of output: 2455 |
||
const form = demo.locator('.tiny-form') | ||
const firstLabel = form.locator('.tiny-form-item__label').first() | ||
const switchBtn = demo.locator('.tiny-switch') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ export const computedAutoLabelWidth = | |
export const computedHideRequiredAsterisk = | ||
({ props, designConfig }: Pick<IFormRenderlessParams, 'props' | 'designConfig'>) => | ||
(): boolean => { | ||
return props.hideRequiredAsterisk ?? designConfig?.hideRequiredAsterisk ?? true | ||
return props.hideRequiredAsterisk ?? designConfig?.hideRequiredAsterisk ?? false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Breaking Change: Default behavior change requires attention The demo files confirm this is a breaking change. Both the Options API and Composition API examples explicitly set Action items:
🔗 Analysis chainBreaking Change: Required asterisk visibility default behavior has changed The default behavior for hiding required asterisks has been inverted from Let's verify the impact on existing forms and documentation: Action items:
The previous results show extensive usage of 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for form usages and documentation that might need updates
# Check for form component usage in templates
rg -t vue "v-tiny-form|tiny-form" -A 5
# Check for hideRequiredAsterisk property usage
rg "hideRequiredAsterisk"
# Check documentation files
fd -e md -e mdx | xargs rg "hideRequiredAsterisk|required asterisk"
Length of output: 3520 Script: #!/bin/bash
# Let's check the git history to understand if this was indeed a breaking change
git log -L :computedHideRequiredAsterisk:packages/renderless/src/form/index.ts
# Check for any tests related to this functionality
rg -l "hideRequiredAsterisk.*test"
# Check the demo files to understand the documented behavior
cat examples/sites/demos/pc/app/form/hide-required.vue
cat examples/sites/demos/pc/app/form/hide-required-composition-api.vue
Length of output: 3597 |
||
} | ||
|
||
export const computedValidateIcon = | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve style evaluation reliability and clarity
The current style evaluation could be more robust and self-documenting:
📝 Committable suggestion