Skip to content

Commit

Permalink
docs(form): [form] optimize form demos
Browse files Browse the repository at this point in the history
  • Loading branch information
gimmyhehe committed Nov 7, 2024
1 parent 56f14af commit 1540f19
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 189 deletions.
10 changes: 5 additions & 5 deletions examples/sites/demos/pc/app/form/basic-usage-composition-api.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div class="demo-form">
<tiny-form label-width="100px">
<tiny-form-item label="数字">
<tiny-numeric v-model="createData.quantity"></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="单选">
<tiny-radio v-model="createData.sex" label="1"> 男 </tiny-radio>
<tiny-radio v-model="createData.sex" label="2" text=""></tiny-radio>
</tiny-form-item>
<tiny-form-item label="数字">
<tiny-numeric v-model="createData.quantity"></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="日期">
<tiny-date-picker v-model="createData.datepicker"></tiny-date-picker>
</tiny-form-item>
Expand All @@ -16,7 +16,7 @@
</tiny-form-item>
<tiny-form-item label="提示">
<tiny-tooltip effect="light" content="TinyUI Form Demo" placement="right">
<tiny-input v-model="createData.input" placeholder="click"></tiny-input>
<tiny-input v-model="createData.input"></tiny-input>
</tiny-tooltip>
</tiny-form-item>
<tiny-form-item label="文本">
Expand All @@ -30,7 +30,7 @@
</template>

<script setup>
import { ref, reactive } from 'vue'
import { reactive } from 'vue'
import {
TinyForm,
TinyFormItem,
Expand Down
4 changes: 0 additions & 4 deletions examples/sites/demos/pc/app/form/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ test('测试基本表单', async ({ page }) => {
await page.getByRole('listitem').filter({ hasText: '00:30' }).click()
await expect(timePicker).toHaveValue('00:30')

// 其他输入
await demo.getByPlaceholder('click').first().hover()
await expect(page.getByRole('tooltip', { name: 'TinyUI Form Demo' })).toBeVisible()

// 提交按钮
const dialog = page.locator('.tiny-modal.active')
await demo.getByRole('button', { name: '提交' }).click()
Expand Down
8 changes: 4 additions & 4 deletions examples/sites/demos/pc/app/form/basic-usage.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div class="demo-form">
<tiny-form label-width="100px">
<tiny-form-item label="数字">
<tiny-numeric v-model="createData.quantity"></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="单选">
<tiny-radio v-model="createData.sex" label="1"> 男 </tiny-radio>
<tiny-radio v-model="createData.sex" label="2" text=""></tiny-radio>
</tiny-form-item>
<tiny-form-item label="数字">
<tiny-numeric v-model="createData.quantity"></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="日期">
<tiny-date-picker v-model="createData.datepicker"></tiny-date-picker>
</tiny-form-item>
Expand All @@ -16,7 +16,7 @@
</tiny-form-item>
<tiny-form-item label="提示">
<tiny-tooltip effect="light" content="TinyUI Form Demo" placement="right">
<tiny-input v-model="createData.input" placeholder="click"></tiny-input>
<tiny-input v-model="createData.input"></tiny-input>
</tiny-tooltip>
</tiny-form-item>
<tiny-form-item label="文本">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</tiny-form-item>
<tiny-form-item>
<tiny-button type="primary" @click="handleSubmit()"> 注册 </tiny-button>
<tiny-button type="primary" @click="changeRule"> 改变校验规则 </tiny-button>
<tiny-button @click="changeRule"> 改变校验规则 </tiny-button>
</tiny-form-item>
</tiny-form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</tiny-form-item>
<tiny-form-item>
<tiny-button type="primary" @click="handleSubmit()"> 注册 </tiny-button>
<tiny-button type="primary" @click="changeRule"> 改变校验规则 </tiny-button>
<tiny-button @click="changeRule"> 改变校验规则 </tiny-button>
</tiny-form-item>
</tiny-form>
</div>
Expand Down
39 changes: 19 additions & 20 deletions examples/sites/demos/pc/app/form/display-only-composition-api.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
<div class="demo-form">
<div class="title">表单是否仅展示:<tiny-switch v-model="displayOnly"></tiny-switch></div>
<tiny-form :inline="inline" label-position="top" :display-only="displayOnly">
<tiny-form-item label="超长文字">
<tiny-input v-model="formData.input"></tiny-input>
<tiny-form-item label="开关">
<tiny-switch></tiny-switch>
</tiny-form-item>
<tiny-form-item label="radio">
<tiny-radio v-model="formData.radioValue" label="1">男</tiny-radio>
<tiny-radio v-model="formData.radioValue" label="2" text=""></tiny-radio>
</tiny-form-item>
<tiny-form-item label="复选框">
<tiny-checkbox v-model="formData.checked">复选框</tiny-checkbox>
</tiny-form-item>
<tiny-form-item label="复选框组">
<tiny-checkbox-group v-model="formData.checkedArr">
<tiny-checkbox label="复选框1" name="name1"></tiny-checkbox>
<tiny-checkbox label="复选框2" name="name2"></tiny-checkbox>
</tiny-checkbox-group>
</tiny-form-item>
<tiny-form-item label="select">
<tiny-select v-model="formData.select">
<tiny-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </tiny-option>
Expand All @@ -19,27 +28,12 @@
<tiny-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </tiny-option>
</tiny-select>
</tiny-form-item>
<tiny-form-item label="文本域">
<tiny-input v-model="formData.textareaValue" type="textarea"></tiny-input>
</tiny-form-item>
<tiny-form-item label="我的密码">
<tiny-input v-model="formData.passwordValue" type="password"></tiny-input>
</tiny-form-item>
<tiny-form-item label="数字">
<tiny-numeric v-model="formData.quantity" unit=""></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="复选框">
<tiny-checkbox v-model="formData.checked">复选框</tiny-checkbox>
</tiny-form-item>
<tiny-form-item label="复选框组">
<tiny-checkbox-group v-model="formData.checkedArr">
<tiny-checkbox label="复选框1" name="name1"></tiny-checkbox>
<tiny-checkbox label="复选框2" name="name2"></tiny-checkbox>
</tiny-checkbox-group>
</tiny-form-item>
<tiny-form-item label="开关">
<tiny-switch></tiny-switch>
</tiny-form-item>
<tiny-form-item label="自动完成">
<tiny-autocomplete
v-model="formData.autocompleteValue"
Expand All @@ -50,6 +44,12 @@
<tiny-form-item label="datePicker">
<tiny-date-picker v-model="formData.datePicker"></tiny-date-picker>
</tiny-form-item>
<tiny-form-item label="超长文字">
<tiny-input v-model="formData.input"></tiny-input>
</tiny-form-item>
<tiny-form-item label="文本域">
<tiny-input v-model="formData.textareaValue" type="textarea"></tiny-input>
</tiny-form-item>
</tiny-form>
</div>
</template>
Expand Down Expand Up @@ -146,7 +146,7 @@ const pickerOptions = ref({
})
const formData = ref({
input:
'111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',
'TinyVue 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践,欢迎尝试使用 TinyVue。',
radioValue: '1',
select: '选项1',
select1: ['选项1', '选项2'],
Expand All @@ -164,7 +164,7 @@ const formData = ref({
monthrange: ['2022-01', '2023-01'],
quantity: 1,
textareaValue:
'大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦',
'OpenTiny 是一套企业级组件库解决方案,适配 PC 端 / 移动端等多端,涵盖 Vue2 / Vue3 / Angular 多技术栈,拥有主题配置系统 / 中后台模板 / CLI 命令行等效率提升工具,可帮助开发者高效开发 Web 应用。',
checked: true,
checkedArr: ['复选框1'],
rate1: 2,
Expand Down Expand Up @@ -202,7 +202,6 @@ function createFilter(queryString) {
}
.title {
margin-bottom: 30px;
margin-left: 16px;
font-size: 14px;
}
</style>
8 changes: 4 additions & 4 deletions examples/sites/demos/pc/app/form/display-only.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ test('表单仅展示', async ({ page }) => {
const getItem = (index: number) => demo.locator('.tiny-form-item__content').nth(index)

await switchBtn.click()
await expect(demo.locator('.tiny-form-item').first().locator('input')).toBeVisible()
await expect(getItem(10).locator('input')).toBeVisible()

await switchBtn.click()
await expect(demo.locator('.tiny-form-item').first().locator('input')).not.toBeVisible()
await expect(getItem(1).locator('.tiny-radio__inner')).not.toBeVisible()
await expect(getItem(1)).toHaveText('男')
await expect(getItem(2).locator('input')).not.toBeVisible()
await expect(getItem(2).locator('.tiny-input-display-only__content')).toHaveText('黄金糕')
await expect(getItem(3).locator('.tiny-input-display-only__content')).toHaveText('黄金糕; 双皮奶')
await expect(getItem(4).locator('input')).not.toBeVisible()
await expect(getItem(4).locator('.tiny-input-display-only__content')).toHaveText('黄金糕')
await expect(getItem(5).locator('.tiny-input-display-only__content')).toHaveText('黄金糕; 双皮奶')
})
39 changes: 19 additions & 20 deletions examples/sites/demos/pc/app/form/display-only.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
<div class="demo-form">
<div class="title">表单是否仅展示:<tiny-switch v-model="displayOnly"></tiny-switch></div>
<tiny-form :inline="inline" label-position="top" :display-only="displayOnly">
<tiny-form-item label="超长文字">
<tiny-input v-model="formData.input"></tiny-input>
<tiny-form-item label="开关">
<tiny-switch></tiny-switch>
</tiny-form-item>
<tiny-form-item label="radio">
<tiny-radio v-model="formData.radioValue" label="1">男</tiny-radio>
<tiny-radio v-model="formData.radioValue" label="2" text=""></tiny-radio>
</tiny-form-item>
<tiny-form-item label="复选框">
<tiny-checkbox v-model="formData.checked">复选框</tiny-checkbox>
</tiny-form-item>
<tiny-form-item label="复选框组">
<tiny-checkbox-group v-model="formData.checkedArr">
<tiny-checkbox label="复选框1" name="name1"></tiny-checkbox>
<tiny-checkbox label="复选框2" name="name2"></tiny-checkbox>
</tiny-checkbox-group>
</tiny-form-item>
<tiny-form-item label="select">
<tiny-select v-model="formData.select">
<tiny-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </tiny-option>
Expand All @@ -19,27 +28,12 @@
<tiny-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </tiny-option>
</tiny-select>
</tiny-form-item>
<tiny-form-item label="文本域">
<tiny-input v-model="formData.textareaValue" type="textarea"></tiny-input>
</tiny-form-item>
<tiny-form-item label="我的密码">
<tiny-input v-model="formData.passwordValue" type="password"></tiny-input>
</tiny-form-item>
<tiny-form-item label="数字">
<tiny-numeric v-model="formData.quantity" unit=""></tiny-numeric>
</tiny-form-item>
<tiny-form-item label="复选框">
<tiny-checkbox v-model="formData.checked">复选框</tiny-checkbox>
</tiny-form-item>
<tiny-form-item label="复选框组">
<tiny-checkbox-group v-model="formData.checkedArr">
<tiny-checkbox label="复选框1" name="name1"></tiny-checkbox>
<tiny-checkbox label="复选框2" name="name2"></tiny-checkbox>
</tiny-checkbox-group>
</tiny-form-item>
<tiny-form-item label="开关">
<tiny-switch></tiny-switch>
</tiny-form-item>
<tiny-form-item label="自动完成">
<tiny-autocomplete
v-model="formData.autocompleteValue"
Expand All @@ -50,6 +44,12 @@
<tiny-form-item label="datePicker">
<tiny-date-picker v-model="formData.datePicker"></tiny-date-picker>
</tiny-form-item>
<tiny-form-item label="超长文字">
<tiny-input v-model="formData.input"></tiny-input>
</tiny-form-item>
<tiny-form-item label="文本域">
<tiny-input v-model="formData.textareaValue" type="textarea"></tiny-input>
</tiny-form-item>
</tiny-form>
</div>
</template>
Expand Down Expand Up @@ -162,7 +162,7 @@ export default {
},
formData: {
input:
'111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111',
'TinyVue 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践,欢迎尝试使用 TinyVue。',
radioValue: '1',
select: '选项1',
select1: ['选项1', '选项2'],
Expand All @@ -180,7 +180,7 @@ export default {
monthrange: ['2022-01', '2023-01'],
quantity: 1,
textareaValue:
'大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦大苏打撒旦',
'OpenTiny 是一套企业级组件库解决方案,适配 PC 端 / 移动端等多端,涵盖 Vue2 / Vue3 / Angular 多技术栈,拥有主题配置系统 / 中后台模板 / CLI 命令行等效率提升工具,可帮助开发者高效开发 Web 应用。',
checked: true,
checkedArr: ['复选框1'],
rate1: 2,
Expand Down Expand Up @@ -219,7 +219,6 @@ export default {
}
.title {
margin-bottom: 30px;
margin-left: 16px;
font-size: 14px;
}
</style>
Loading

0 comments on commit 1540f19

Please sign in to comment.