Files
vue-formkit-example/src/__fk-inputs__/inputs/input-password.ts
严浩 884099b2ee
All checks were successful
/ test (push) Successful in 26s
/ surge (push) Successful in 39s
feat: 更新表单输入组件的 schemaMemoKey,确保唯一性
2024-11-26 15:31:05 +08:00

46 lines
1.2 KiB
TypeScript

import type { 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';
import { floatLabel } from '../sections/floatLabel';
const input = createSection('input', () => ({
$cmp: markRaw(SchemaComponent) as never,
bind: '$attrs',
props: {
invalid: '$state.invalid',
disabled: '$disabled',
// name: '$node.name',
// inputProps: {}
onInput: '$handlers.DOMInput',
onBlur: '$handlers.blur',
modelValue: '$_value',
inputId: '$id',
fluid: true,
},
}));
export const PInputPassword: FormKitTypeDefinition = {
type: 'input',
schema: outer(
floatLabel(
input(), //
label('$label'),
),
messages(),
),
features: [casts],
schemaMemoKey: '9h771fci93n', // Math.random().toString(36).substring(2, 15)
};
declare module '@formkit/inputs' {
// https://formkit.com/essentials/custom-inputs#typescript-support
interface FormKitInputProps<Props extends FormKitInputs<Props>> {
PInputPassword: {
type: 'PInputPassword';
};
}
}