Skip to content

Commit

Permalink
fix: 修复未正确导出 useFormReset hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenny committed Jun 18, 2024
1 parent 30db493 commit caa6bba
Show file tree
Hide file tree
Showing 21 changed files with 962 additions and 527 deletions.
22 changes: 6 additions & 16 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
release:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
release_created: ${{ steps.set-output-step.outputs.release_created }}
job_output: ${{ steps.set-output-step.outputs.output_value }}
b: ${{ steps.set-output-step.outputs.b }}
steps:
- uses: googleapis/release-please-action@v4
id: release
Expand All @@ -28,24 +29,12 @@ jobs:
# for more options
release-type: node

- name: Generate output value
id: set-output-step
- name: Output Release Created
id: output-release-created
run: |
echo "Generating output value..."
VALUE="Hello, World!"
release_created=${{ steps.release.outputs.release_created }}
echo "::set-output name=output_value::$VALUE"
echo "::set-output name=release_created::$release_created"
joblog:
runs-on: ubuntu-latest
needs: release
steps:
- name: Print Previous Job Output
run: |
echo "Previous job output: "
echo "${{ toJson(needs.release.outputs) }}"
publish:
runs-on: ubuntu-latest
needs: release
Expand Down Expand Up @@ -74,6 +63,7 @@ jobs:
- name: Build Lib
run: pnpm lib:build

- run: pnpm publish
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [0.6.0](https://github.com/DvShu/neatui-vue/compare/v0.5.4...v0.6.0) (2024-06-14)


### Features

* Form 表单 ([6aef628](https://github.com/DvShu/neatui-vue/commit/6aef628e8f8ccda2dcd1e1efb401413349ff0425))
* Form表单 ([cbe390f](https://github.com/DvShu/neatui-vue/commit/cbe390f7b34eb13043c5cfd847f05f319c435d16))

## [0.5.4](https://github.com/DvShu/neatui-vue/compare/v0.5.3...v0.5.4) (2024-06-07)


Expand Down
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default defineConfig({
{ text: 'Radio 单选框', link: '/components/radio' },
{ text: 'Switch 开关', link: '/components/switch' },
{ text: 'Polygon 多边形', link: '/components/polygon' },
{ text: 'Form 表单', link: '/components/form' },
],
},
],
Expand Down
2 changes: 2 additions & 0 deletions docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import '../../../style/message';
import '../../../style/shadow';
import '../../../style/table';
import '../../../style/switch';
import '../../../style/form';
import '../../../style/form_item';

export default {
extends: DefaultTheme,
Expand Down
120 changes: 120 additions & 0 deletions docs/components/form.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Form

包含数据录入、校验以及对应样式。

## 演示

<script setup lang="ts">
import { reactive, watch, ref } from 'vue'
import { FormItem, Input, Form, Button, useFormReset } from '../../src'

const { formFields, resetFields } = useFormReset({
username: '',
password: ''
})

const rules = [
{
key: 'username',
rules: ['required'],
message: '用户名不能为空'
},
{
key: 'password',
rules: [/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]{6,15})$/],
message: '密码为6~15位字母+数字'
}
]

function handleReset() {
resetFields()
}
</script>

### 基础用法

基本的表单数据域控制展示,包含布局、初始化、验证、提交。数据验证采用 [ph-utils/validator](https://gitee.com/towardly/ph/wikis/utils/validator)

<ClientOnly>
<CodePreview>
<textarea lang="vue">
<script setup lang="ts">
import { reactive, watch, ref } from 'vue'
import { useFormReset } from '@asteres/neatui-vue'
const { formFields, resetFields } = useFormReset({
username: '',
password: ''
})
const rules = [
{
key: 'username',
rules: ['required'],
message: '用户名不能为空'
},
{
key: 'password',
rules: [/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]{6,15})$/],
message: '密码为6~15位字母+数字'
}
]
function handleReset() {
resetFields()
}
</script>
<template>
<nt-form :model="formFields" :rules="rules">
<nt-form-item label="用户名" required name="username">
<nt-input placeholder="请输入用户名" v-model="formFields.username"></nt-input>
</nt-form-item>
<nt-form-item label="密码" required name="password">
<nt-input placeholder="请输入密码" v-model="formFields.password"></nt-input>
</nt-form-item>
<nt-form-item>
<nt-button html-type="submit">提交</nt-button>
<nt-button type="normal" @click="handleReset">重置</nt-button>
</nt-form-item>
</nt-form>
</template>
</textarea>
<template #preview>
<Form :model="formFields" :rules="rules">
<FormItem label="用户名" name="username">
<Input placeholder="请输入用户名" v-model="formFields.username"></Input>
</FormItem>
<FormItem label="密码" required name="password">
<Input placeholder="请输入密码" v-model="formFields.password"></Input>
</FormItem>
<FormItem>
<Button html-type="submit">提交</Button>
<Button type="normal" @click="handleReset">重置</Button>
</FormItem>
</Form>
</template>
</CodePreview>
</ClientOnly>

## API

### Form Props

| 参数 | 说明 | 类型 | 默认值 |
| ------------- | --------------------------------------------------------------------------- | --------------------- | ------ |
| `model` | 表单数据对象 | `Record<string, any>` | - |
| `rules` | 表单验证规则 | `FormRule[]` | - |
| `label-width` | 标签的长度,例如 `50px`。 作为 `Form` 直接子元素的 `form-item` 会继承该值。 | `string` | - |

### Form Events

| 事件名 | 说明 | 类型 |
| -------- | -------------- | ------------ |
| `submit` | 提交表单时触发 | `() => void` |

### FormItem Props

| 参数 | 说明 | 类型 | 默认值 |
| ------------- | -------------------------------------------------------------------------------------- | --------- | ------ |
| `label` | 标签文本 | `string` | - |
| `required` | 是否为必填项,如不设置,则会根据校验规则确认 | `boolean` | - |
| `name` | `model` 的键名; 使用表单校验时必填 | `string` | - |
| `label-width` | 标签宽度,例如 `50px` | `string` | - |
| `error` | 表单域验证错误时的提示信息。设置该值会导致表单验证状态变为 `error`,并显示该错误信息。 | `string` | - |
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@asteres/neatui-vue",
"description": "基于 Vue3 的 UI 组件库",
"version": "0.5.4",
"version": "0.6.0",
"type": "module",
"scripts": {
"g:c": "node scripts/index.js template",
Expand All @@ -12,21 +12,21 @@
"inspect:eslint": "eslint --inspect-config"
},
"devDependencies": {
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@vitejs/plugin-vue": "^5.0.4",
"eslint": "^9.0.0",
"eslint-plugin-vue": "^9.24.1",
"globals": "^15.0.0",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@vitejs/plugin-vue": "^5.0.5",
"eslint": "^9.4.0",
"eslint-plugin-vue": "^9.26.0",
"globals": "^15.4.0",
"less": "^4.2.0",
"prettier": "^3.2.5",
"shiki": "^1.3.0",
"prettier": "^3.3.2",
"shiki": "^1.6.4",
"typescript": "^5.4.5",
"vite": "^5.2.8",
"vite-plugin-dts": "^3.8.2",
"vitepress": "^1.1.0",
"vue-tsc": "^2.0.13"
"vite": "^5.2.13",
"vite-plugin-dts": "^3.9.1",
"vitepress": "^1.2.3",
"vue-tsc": "^2.0.21"
},
"peerDependencies": {
"vue": "^3.3.11"
Expand Down Expand Up @@ -64,7 +64,7 @@
},
"license": "MulanPSL-2.0",
"dependencies": {
"ph-utils": "^0.4.5",
"ph-utils": "^0.4.7",
"qrcode-generator-es": "^0.0.4"
},
"packageManager": "pnpm@9.0.2"
Expand Down
Loading

0 comments on commit caa6bba

Please sign in to comment.