Skip to content

Commit

Permalink
feat: input,textarea,inputnumber,numberkeyboard,radio,radiogroup
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1206 committed Jun 27, 2023
1 parent 55c72cc commit 97a1c4c
Show file tree
Hide file tree
Showing 35 changed files with 2,568 additions and 2 deletions.
6 changes: 6 additions & 0 deletions example/src/components.d.ts
Expand Up @@ -36,14 +36,19 @@ declare module '@vue/runtime-core' {
NutIcon: typeof import('uniapp-nutui/components/icon/icon.vue')['default']
NutIndicator: typeof import('uniapp-nutui/components/indicator/indicator.vue')['default']
NutInfiniteloading: typeof import('uniapp-nutui/components/infiniteloading/infiniteloading.vue')['default']
NutInput: typeof import('uniapp-nutui/components/input/input.vue')['default']
NutInputNumber: typeof import('uniapp-nutui/components/inputnumber/inputnumber.vue')['default']
NutMenu: typeof import('uniapp-nutui/components/menu/menu.vue')['default']
NutMenuItem: typeof import('uniapp-nutui/components/menuitem/menuitem.vue')['default']
NutNavbar: typeof import('uniapp-nutui/components/navbar/navbar.vue')['default']
NutNotify: typeof import('uniapp-nutui/components/notify/notify.vue')['default']
NutNumberKeyboard: typeof import('uniapp-nutui/components/numberkeyboard/numberkeyboard.vue')['default']
NutOverlay: typeof import('uniapp-nutui/components/overlay/overlay.vue')['default']
NutPagination: typeof import('uniapp-nutui/components/pagination/pagination.vue')['default']
NutPicker: typeof import('uniapp-nutui/components/picker/picker.vue')['default']
NutPopup: typeof import('uniapp-nutui/components/popup/popup.vue')['default']
NutRadio: typeof import('uniapp-nutui/components/radio/radio.vue')['default']
NutRadioGroup: typeof import('uniapp-nutui/components/radiogroup/radiogroup.vue')['default']
NutRow: typeof import('uniapp-nutui/components/row/row.vue')['default']
NutSideNavbar: typeof import('uniapp-nutui/components/sidenavbar/sidenavbar.vue')['default']
NutSideNavbarItem: typeof import('uniapp-nutui/components/sidenavbaritem/sidenavbaritem.vue')['default']
Expand All @@ -55,6 +60,7 @@ declare module '@vue/runtime-core' {
NutTabbarItem: typeof import('uniapp-nutui/components/tabbaritem/tabbaritem.vue')['default']
NutTabPane: typeof import('uniapp-nutui/components/tabpane/tabpane.vue')['default']
NutTabs: typeof import('uniapp-nutui/components/tabs/tabs.vue')['default']
NutTextarea: typeof import('uniapp-nutui/components/textarea/textarea.vue')['default']
NutToast: typeof import('uniapp-nutui/components/toast/toast.vue')['default']
NutTransition: typeof import('uniapp-nutui/components/transition/transition.vue')['default']
ThemeSwitch: typeof import('./components/ThemeSwitch.vue')['default']
Expand Down
2 changes: 1 addition & 1 deletion example/src/demo/dentry/datepicker/index.vue
Expand Up @@ -125,7 +125,7 @@ export default {
配合 Popup 使用
</h2>
<nut-cell title="选择日期" :desc="popupDesc" @click="show = true" />
<nut-popup v-model:visible="show" position="bottom">
<nut-popup v-model:visible="show" safe-area-inset-bottom position="bottom">
<nut-date-picker
v-model="currentDate"
:min-date="minDate"
Expand Down
184 changes: 184 additions & 0 deletions example/src/demo/dentry/input/index.vue
@@ -0,0 +1,184 @@
<script lang="ts">
import { reactive } from 'vue'
export default {
setup() {
const state = reactive({
val1: '',
val2: '',
text: '',
password: '',
number: '',
digit: '',
tel: '',
readonly: '',
disabled: '',
showIcon: '',
required: '',
error1: '',
error2: '',
buttonVal: '',
format1: '',
format2: '',
textarea: '',
align1: '',
align2: '',
event: '',
slotsValue: '',
clear: '',
clear2: '',
adjustPosition: false,
show: false,
msg: '',
})
setTimeout(() => {
// state.val1 = '异步数据';
}, 2000)
const showToast = (msg: string) => {
state.show = true
state.msg = msg
}
const clear = (value: string | number, event: Event) => {
/* eslint-disable no-console */
console.log('clear:', value, event)
showToast('clear')
}
const clickInput = (value: string | number) => {
console.log('clickInput:', value)
showToast('clickInput')
}
const formatter = (value: string) => value.replace(/\d/g, '')
const clearValue = () => {
state.clear2 = ''
}
return {
state,
clear,
clickInput,
formatter,
clearValue,
}
},
}
</script>

<template>
<div class="demo full">
<h2 class="title">
基础用法
</h2>
<nut-input v-model="state.val1" type="text" placeholder="文本" />

<h2 class="title">
自定义类型
</h2>
<nut-input v-model="state.text" placeholder="文本" />
<nut-input v-model="state.password" type="password" placeholder="密码" />
<nut-input v-model="state.number" type="number" placeholder="数字" />
<nut-input v-model="state.digit" type="digit" placeholder="整数" />

<h2 class="title">
禁用和只读
</h2>
<nut-input v-model="state.readonly" readonly placeholder="只读" />
<nut-input v-model="state.disabled" disabled placeholder="禁用" />

<h2 class="title">
显示清除图标
</h2>
<nut-input v-model="state.clear" clearable clear-size="14" placeholder="显示清除图标" />
<nut-input
v-model="state.clear2"
placeholder="自定义清除图标"
clearable
clear-size="14"
show-word-limit
max-length="50"
:show-clear-icon="true"
>
<template #clear>
<nut-icon name="close" width="12" height="12" size="12" @click="clearValue" />
</template>
</nut-input>
<h2 class="title">
配合表单使用
</h2>
<!-- <nut-form :model-value="state">
<nut-form-item label-align="center" label="文本">
<nut-input v-model="state.val2" placeholder="请输入文本" :border="false" />
</nut-form-item>
</nut-form> -->

<h2 class="title">
格式化输入内容
</h2>
<nut-input v-model="state.format1" error :formatter="formatter" placeholder="在输入时执行格式化" />
<nut-input
v-model="state.format2"
:formatter="formatter"
format-trigger="onBlur"
placeholder="在失焦时执行格式化"
/>

<h2 class="title">
显示字数统计
</h2>
<nut-input
v-model="state.textarea"
type="text"
show-word-limit
rows="2"
max-length="50"
placeholder="留言"
:adjust-position="state.adjustPosition"
/>

<h2 class="title">
无边框
</h2>
<nut-input v-model="state.disabled" :border="false" placeholder="无边框" />
<nut-input v-model="state.showIcon" :border="false" placeholder="无边框" />

<h2 class="title">
事件演示
</h2>
<nut-input
v-model="state.event"
placeholder="事件演示"
clearable
:adjust-position="state.adjustPosition"
@clear="clear"
@click-input="clickInput"
/>
<nut-toast v-model:visible="state.show" :msg="state.msg" type="text" />
<h2 class="title">
插槽演示
</h2>
<nut-input v-model="state.slotsValue" placeholder="插槽演示" clearable :adjust-position="state.adjustPosition">
<template #left>
<nut-icon name="ask" />
</template>
<template #right>
<nut-button type="primary" size="small">
获取验证码
</nut-button>
</template>
</nut-input>
</div>
</template>

<style lang="scss" scoped>
.demo {
.nut-placeholder {
color: #ccc;
}
}
</style>

<route lang="json">
{
"style": {
"navigationBarTitleText": "Input"
}
}
</route>
101 changes: 101 additions & 0 deletions example/src/demo/dentry/inputnumber/index.vue
@@ -0,0 +1,101 @@
<script lang="ts">
import { reactive } from 'vue'
export default {
props: {},
setup() {
const state = reactive({
val1: 1,
val2: 0,
val3: 10,
val4: 0,
val5: 1,
val6: 5.5,
val7: 1,
val8: 1,
step: 1.1,
})
const onChange = (value: number) => {
/* eslint-disable no-console */
console.log('异步演示 2 秒后更改')
setTimeout(() => {
state.val8 = value
}, 2000)
}
const overlimit = () => {
console.log('超出限制事件触发')
}
return {
state,
onChange,
overlimit,
}
},
}
</script>

<template>
<div class="demo">
<h2 class="title">
基础用法
</h2>
<nut-cell>
<nut-input-number v-model="state.val1" />
</nut-cell>
<h2 class="title">
步长设置
</h2>
<nut-cell>
<nut-input-number v-model="state.val2" step="5" />
</nut-cell>
<h2 class="title">
限制输入范围
</h2>
<nut-cell>
<nut-input-number v-model="state.val3" min="10" max="20" @overlimit="overlimit" />
</nut-cell>
<h2 class="title">
禁用操作
</h2>
<nut-cell>
<nut-input-number v-model="state.val4" disabled />
</nut-cell>
<h2 class="title">
只读禁用输入框
</h2>
<nut-cell>
<nut-input-number v-model="state.val5" readonly />
</nut-cell>
<h2 class="title">
支持小数
</h2>
<nut-cell>
<nut-input-number v-model="state.val6" step="0.1" decimal-places="1" readonly />
</nut-cell>
<h2 class="title">
支持异步修改
</h2>
<nut-cell>
<nut-input-number :model-value="state.val8" @change="onChange" />
</nut-cell>
<h2 class="title">
自定义按钮大小
</h2>
<nut-cell>
<nut-input-number v-model="state.val7" button-size="30" input-width="50" />
</nut-cell>
</div>
</template>

<style lang="scss" scoped></style>

<route lang="json">
{
"style": {
"navigationBarTitleText": "InputNumber"
}
}
</route>

0 comments on commit 97a1c4c

Please sign in to comment.