feat: 添加 PInputPassword 组件并在 formkit.config.ts 中注册
This commit is contained in:
@ -12,6 +12,7 @@ import { addAsteriskPlugin } from './formkit.config.plugin.addAsteriskPlugin';
|
|||||||
import { debugPlugin } from './formkit.config.plugin.debug';
|
import { debugPlugin } from './formkit.config.plugin.debug';
|
||||||
import { form } from '@/__fk-inputs__/inputs/form';
|
import { form } from '@/__fk-inputs__/inputs/form';
|
||||||
import { PInputText } from '@/__fk-inputs__/inputs/input-text';
|
import { PInputText } from '@/__fk-inputs__/inputs/input-text';
|
||||||
|
import { PInputPassword } from '@/__fk-inputs__/inputs/input-password';
|
||||||
|
|
||||||
// const apiKey = 'fk-6cdd5192223'
|
// const apiKey = 'fk-6cdd5192223'
|
||||||
const config: FormKitOptions = {
|
const config: FormKitOptions = {
|
||||||
@ -25,6 +26,7 @@ const config: FormKitOptions = {
|
|||||||
// ==============================
|
// ==============================
|
||||||
form,
|
form,
|
||||||
PInputText,
|
PInputText,
|
||||||
|
PInputPassword,
|
||||||
}),
|
}),
|
||||||
// createLibraryPlugin(
|
// createLibraryPlugin(
|
||||||
// {
|
// {
|
||||||
|
44
src/__fk-inputs__/inputs/input-password.ts
Normal file
44
src/__fk-inputs__/inputs/input-password.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import { FormKitTypeDefinition } from '@formkit/core';
|
||||||
|
import type { FormKitInputs } from '@formkit/inputs';
|
||||||
|
import { casts, createSection, label, outer } from '@formkit/inputs';
|
||||||
|
import SchemaComponent from 'primevue/password';
|
||||||
|
import { markRaw } from 'vue';
|
||||||
|
import { messages } from '../sections/messages';
|
||||||
|
|
||||||
|
const cmpName = `SchemaComponent${SchemaComponent.name}`;
|
||||||
|
|
||||||
|
export const PInputPassword: FormKitTypeDefinition = {
|
||||||
|
type: 'input',
|
||||||
|
schema: outer(
|
||||||
|
label('$label'),
|
||||||
|
createSection('input', () => ({
|
||||||
|
$cmp: cmpName,
|
||||||
|
bind: '$attrs',
|
||||||
|
props: {
|
||||||
|
invalid: '$state.invalid',
|
||||||
|
disabled: '$disabled',
|
||||||
|
// name: '$node.name',
|
||||||
|
// inputProps: {}
|
||||||
|
onInput: '$handlers.DOMInput',
|
||||||
|
onBlur: '$handlers.blur',
|
||||||
|
modelValue: '$_value',
|
||||||
|
inputId: '$id',
|
||||||
|
},
|
||||||
|
}))(),
|
||||||
|
messages(),
|
||||||
|
),
|
||||||
|
library: {
|
||||||
|
[cmpName]: markRaw(SchemaComponent),
|
||||||
|
},
|
||||||
|
features: [casts],
|
||||||
|
// schemaMemoKey: 'g2f31c24kjh',
|
||||||
|
};
|
||||||
|
|
||||||
|
declare module '@formkit/inputs' {
|
||||||
|
// https://formkit.com/essentials/custom-inputs#typescript-support
|
||||||
|
interface FormKitInputProps<Props extends FormKitInputs<Props>> {
|
||||||
|
PInputPassword: {
|
||||||
|
type: 'PInputPassword';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
import { FormKitTypeDefinition } from '@formkit/core';
|
import { FormKitTypeDefinition } from '@formkit/core';
|
||||||
import type { FormKitInputs } from '@formkit/inputs';
|
import type { FormKitInputs } from '@formkit/inputs';
|
||||||
import { casts, createSection, label, outer } from '@formkit/inputs';
|
import { casts, createSection, label, outer } from '@formkit/inputs';
|
||||||
import InputTextCmp from 'primevue/inputtext';
|
import SchemaComponent from 'primevue/inputtext';
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
import { messages } from '../sections/messages';
|
import { messages } from '../sections/messages';
|
||||||
|
|
||||||
const cmpName = `SchemaComponentPInputText`;
|
const cmpName = `SchemaComponent${SchemaComponent.name}`;
|
||||||
|
|
||||||
export const PInputText: FormKitTypeDefinition = {
|
export const PInputText: FormKitTypeDefinition = {
|
||||||
type: 'input',
|
type: 'input',
|
||||||
@ -23,14 +23,12 @@ export const PInputText: FormKitTypeDefinition = {
|
|||||||
onBlur: '$handlers.blur',
|
onBlur: '$handlers.blur',
|
||||||
modelValue: '$_value',
|
modelValue: '$_value',
|
||||||
id: '$id',
|
id: '$id',
|
||||||
'aria-describedby': '$describedBy',
|
|
||||||
'aria-required': '$state.required || undefined',
|
|
||||||
},
|
},
|
||||||
}))(),
|
}))(),
|
||||||
messages(),
|
messages(),
|
||||||
),
|
),
|
||||||
library: {
|
library: {
|
||||||
[cmpName]: markRaw(InputTextCmp),
|
[cmpName]: markRaw(SchemaComponent),
|
||||||
},
|
},
|
||||||
features: [casts],
|
features: [casts],
|
||||||
// schemaMemoKey: 'g2f31c24kjh',
|
// schemaMemoKey: 'g2f31c24kjh',
|
||||||
|
@ -46,6 +46,16 @@ async function submit() {
|
|||||||
validation="required"
|
validation="required"
|
||||||
>
|
>
|
||||||
</FormKit>
|
</FormKit>
|
||||||
|
<FormKit
|
||||||
|
type="PInputPassword"
|
||||||
|
name="PInputPassword"
|
||||||
|
label="密码"
|
||||||
|
placeholder="输入一个密码"
|
||||||
|
validation="required"
|
||||||
|
toggleMask
|
||||||
|
fluid
|
||||||
|
:feedback="false"
|
||||||
|
/>
|
||||||
<FormKit
|
<FormKit
|
||||||
:type="text"
|
:type="text"
|
||||||
label="customType"
|
label="customType"
|
||||||
|
Reference in New Issue
Block a user