Skip to content

Commit 3191809

Browse files
author
Tenny
committed
Squashed commit of the following:
commit ab373ff Author: Tenny <tenny.shu@foxmail.com> Date: Thu Sep 26 11:29:13 2024 +0800 fix: 修复 IconFont 导出错误 feat: 表单增加 label-position
1 parent 1745494 commit 3191809

File tree

10 files changed

+538
-416
lines changed

10 files changed

+538
-416
lines changed

docs/components/form.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@
55
## 演示
66

77
<script setup lang="ts">
8-
import { reactive, watch, ref } from 'vue'
8+
import { reactive, watch, ref, computed } from 'vue'
99
import { FormItem, Input, Form, Button, useFormReset } from '../../src'
10+
import RadioGroup from '../../src/components/radio/RadioGroup.vue'
11+
import Radio from '../../src/components/radio/Radio.vue'
12+
13+
const formAlign = ref('right')
14+
const formItemAlign = ref('null')
15+
16+
const itemAlign = computed(() => {
17+
return formItemAlign.value === 'null' ? null : formItemAlign.value
18+
})
1019

1120
const { formFields, resetFields } = useFormReset({
1221
username: '',
@@ -148,17 +157,71 @@
148157
</nt-form-item>
149158
</textarea>
150159
</CodePreview>
151-
</ClientOnly>`
160+
</ClientOnly>
161+
162+
### 对齐方式
163+
164+
通过设置 `label-position` 来应用标签和内容的对齐方式。
165+
166+
您可以分别设置 `nt-form-item``label-position`. 如果值为空, 则会使用 `nt-form``label-position`
167+
168+
<ClientOnly>
169+
<CodePreview>
170+
<textarea lang="vue-html" v-pre>
171+
<nt-form label-position="right">
172+
<nt-form-item label="用户名">
173+
<nt-input placeholder="请输入用户名"></nt-input>
174+
</nt-form-item>
175+
<nt-form-item label="密码">
176+
<nt-input placeholder="请输入密码"></nt-input>
177+
</nt-form-item>
178+
<nt-form-item>
179+
<nt-button html-type="submit">提交</nt-button>
180+
</nt-form-item>
181+
</nt-form>
182+
</textarea>
183+
<template #preview>
184+
<Form label-width="120px" :label-position="formAlign">
185+
<FormItem label="FormAlign" :label-position="itemAlign">
186+
<RadioGroup v-model="formAlign">
187+
<Radio label="Left" value="left" type="button" />
188+
<Radio label="Right" value="right" type="button" />
189+
<Radio label="Top" value="top" type="button" />
190+
</RadioGroup>
191+
</FormItem>
192+
<FormItem label="FormItemAlign" :label-position="itemAlign">
193+
<RadioGroup v-model="formItemAlign">
194+
<Radio label="Null" value="null" type="button" />
195+
<Radio label="Left" value="left" type="button" />
196+
<Radio label="Right" value="right" type="button" />
197+
<Radio label="Top" value="top" type="button" />
198+
</RadioGroup>
199+
</FormItem>
200+
<FormItem label="用户名" :label-position="itemAlign">
201+
<Input placeholder="请输入用户名"></Input>
202+
</FormItem>
203+
<FormItem label="密码" :label-position="itemAlign">
204+
<Input placeholder="请输入密码"></Input>
205+
</FormItem>
206+
<FormItem label="" :label-position="itemAlign">
207+
<Button html-type="submit">提交</Button>
208+
</FormItem>
209+
</Form>
210+
</template>
211+
</CodePreview>
212+
</ClientOnly>
152213

153214
## API
154215

155216
### Form Props
156217

218+
<!-- prettier-ignore -->
157219
| 参数 | 说明 | 类型 | 默认值 |
158220
| ------------- | --------------------------------------------------------------------------- | --------------------- | ------ |
159221
| `model` | 表单数据对象 | `Record<string, any>` | - |
160222
| `rules` | 表单验证规则 | `FormRule[]` | - |
161223
| `label-width` | 标签的长度,例如 `50px`。 作为 `Form` 直接子元素的 `form-item` 会继承该值。 | `string` | - |
224+
| `label-position` | 标签的位置 | `left``right``top` | `right` |
162225

163226
### Form Events
164227

@@ -168,10 +231,12 @@
168231

169232
### FormItem Props
170233

234+
<!-- prettier-ignore -->
171235
| 参数 | 说明 | 类型 | 默认值 |
172236
| ------------- | -------------------------------------------------------------------------------------- | --------- | ------ |
173237
| `label` | 标签文本 | `string` | - |
174238
| `required` | 是否为必填项,如不设置,则会根据校验规则确认 | `boolean` | - |
175239
| `name` | `model` 的键名; 使用表单校验时必填 | `string` | - |
176240
| `label-width` | 标签宽度,例如 `50px` | `string` | - |
177241
| `error` | 表单域验证错误时的提示信息。设置该值会导致表单验证状态变为 `error`,并显示该错误信息。 | `string` | - |
242+
| `label-position` | 标签位置, *可选* | `left``right``top` | - |

docs/components/theme.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,23 @@ createApp(App).use(router).mount('#app');
3333
ThemeColor
3434
} from '../../src';
3535
import SourceCode from '../../src/app_components/SourceCode.vue'
36-
import { ref, watch } from 'vue';
37-
import { getTheme, applyTheme } from 'ph-utils/theme'
36+
import { ref, watch, onMounted } from 'vue';
3837

39-
const theme = ref(getTheme());
40-
const code = ref(``)
38+
const theme = ref('');
39+
const code = ref('');
4140

42-
watch(theme, async (val) => {
43-
await applyTheme(val);
41+
watch(theme, (val) => {
42+
import('ph-utils/theme').then((module) => {
43+
return module.applyTheme(val);
44+
})
4445
});
4546

47+
onMounted(() => {
48+
import('ph-utils/theme').then((module) => {
49+
theme.value = module.getTheme();
50+
})
51+
})
52+
4653
function handleColorChange() {
4754
const $style = document.getElementById('color-theme-style');
4855
if ($style != null) {

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
"pull": "pwsh scripts/publish.ps1 publish"
1515
},
1616
"devDependencies": {
17-
"@eslint/js": "^9.10.0",
17+
"@eslint/js": "^9.11.1",
1818
"@eslint/markdown": "^6.1.0",
19-
"@types/node": "^22.5.5",
19+
"@types/node": "^22.7.0",
2020
"@vitejs/plugin-vue": "^5.1.4",
21-
"eslint": "^9.10.0",
21+
"eslint": "^9.11.1",
2222
"eslint-plugin-vue": "^9.28.0",
2323
"globals": "^15.9.0",
2424
"less": "^4.2.0",
2525
"prettier": "^3.3.3",
26-
"shiki": "^1.17.7",
26+
"shiki": "^1.18.0",
2727
"typescript": "^5.6.2",
28-
"typescript-eslint": "^8.6.0",
29-
"vite": "^5.4.6",
30-
"vite-plugin-dts": "4.2.1",
28+
"typescript-eslint": "^8.7.0",
29+
"vite": "^5.4.7",
30+
"vite-plugin-dts": "4.2.2",
3131
"vitepress": "^1.3.4",
3232
"vue-tsc": "^2.1.6"
3333
},
@@ -69,7 +69,7 @@
6969
"dependencies": {
7070
"@tanstack/vue-table": "^8.20.5",
7171
"ph-utils": "^0.9.3",
72-
"qrcode-generator-es": "^1.0.2",
72+
"qrcode-generator-es": "^1.0.3",
7373
"vue-router": "^4.4.5"
7474
},
7575
"packageManager": "pnpm@9.0.2"

0 commit comments

Comments
 (0)