|
| 1 | +import { type FormKitTypeDefinition } from '@formkit/core' |
| 2 | +import { casts, createSection, outer } from '@formkit/inputs' |
| 3 | +import { token } from '@formkit/utils' |
| 4 | +import { VaFileUpload } from 'vuestic-ui' |
| 5 | +import { vuesticInputs } from './features/vuesticInputs'; |
| 6 | +import { help, message, messages } from './sections'; |
| 7 | +import { createInputWrapper } from './createInputWrapper'; |
| 8 | + |
| 9 | +const FormKitInputWrapper = createInputWrapper(VaFileUpload) |
| 10 | + |
| 11 | +const fileInput = createSection('input', () => ({ |
| 12 | + $cmp: 'FormKitInputWrapper', |
| 13 | + bind: '$attrs', |
| 14 | + props: { |
| 15 | + context: '$node.context', |
| 16 | + prefixIcon: '$prefixIcon', |
| 17 | + suffixIcon: '$suffixIcon' |
| 18 | + }, |
| 19 | +})) |
| 20 | + |
| 21 | +/** |
| 22 | + * Input definition for a file. |
| 23 | + * @public |
| 24 | + */ |
| 25 | +export const file: FormKitTypeDefinition = { |
| 26 | + /** |
| 27 | + * The actual schema of the input, or a function that returns the schema. |
| 28 | + */ |
| 29 | + schema: outer( |
| 30 | + messages(message()), |
| 31 | + fileInput(), |
| 32 | + help(), |
| 33 | + ), |
| 34 | + /** |
| 35 | + * The type of node, can be a list, group, or input. |
| 36 | + */ |
| 37 | + type: 'input', |
| 38 | + /** |
| 39 | + * The family of inputs this one belongs too. For example "text" and "email" |
| 40 | + * are both part of the "text" family. This is primary used for styling. |
| 41 | + */ |
| 42 | + family: 'text', |
| 43 | + /** |
| 44 | + * An array of extra props to accept for this input. |
| 45 | + */ |
| 46 | + props: [], |
| 47 | + /** |
| 48 | + * A library of components to provide to the internal input schema |
| 49 | + */ |
| 50 | + library: { |
| 51 | + FormKitInputWrapper |
| 52 | + }, |
| 53 | + /** |
| 54 | + * Additional features that should be added to your input |
| 55 | + */ |
| 56 | + features: [casts, vuesticInputs], |
| 57 | + /** |
| 58 | + * The key used to memoize the schema. |
| 59 | + */ |
| 60 | + schemaMemoKey: token(), |
| 61 | +} |
0 commit comments