Comments (7)
This is gonna be an interesting one that I've been pondering for a while. FormKit does not always use props for its props 😂 some of the "props" are actually "attrs" that are picked up and treated as props (inheritAttrs
is false
). I haven’t found a way (yet) to give type annotations for attributes in Vue 3. If you know of a way, i’m all ears.
from formkit.
Interesting. My experimentation with FormKit is also my first-time with vue 3.
I'll try and do some investigation. There are other typing improvements I would like to see, like strongly typed type
and perhaps then using a discriminated union on this to restrict the other props. Would obviously need to consider how this would work with custom components though.
from formkit.
2 things:
- I've been able to add support for these "synthetic" props without being forced to define them all as actual props (to keep them out of the JS and only in the
d.ts
file) (https://github.com/formkit/formkit/blob/release/beta.1/packages/vue/src/props.ts). This isn’t quite as robust as it will need to be in order to handle custom inputs, but Vue uses atype
internally for its props instead of an interface, so I dont currently see any obvious way to change those props apparent from explicit declarations like this. - I too would like to see strong types for the
value
— although I think this is going to be really challenging because values are determined at runtime. Inputs can output any value type, some are arrays, some objects, some strings — and these value types can be determined at runtime. That said I think we could "force" the typings to be strong by introducing something likeconst FormKitText = defineFormKit<TypingsHere>()
where FormKitText is then the strictly typed component. This definitely removes some of the convenience of FormKit but it might be required in order to get strongly typed values.
from formkit.
Are you suggesting we would have to in our files call that defineFormKit
function? Do you not think a discriminated union would work? I.e. (and sorry if you already know what this is):
type FormKitText = {
type: "text",
value: string
};
type FormKitNumber = {
type: "number",
value: number
};
type FormKitForm = {
type: "form",
submitLabel: string,
formClass: string,
};
type FormKit = FormKitText | FormKitNumber | FormKitForm;
Other props/types omitted for brevity.
from formkit.
In reference to the defineFormKit
idea, we would call that internally for all the input types that we export from the package, but for end users wanting to create custom inputs it would give them an easy way to have type safety.
Fundamentally a discriminated union is exactly what we need, unfortunately I'm not sure we're gonna get away with using it as the prop typing for vue's defineComponent
but I've only started experimenting with it.
from formkit.
I'm getting this error and wondering if related to this issue?
Property 'value' does not exist on type 'IntrinsicAttributes & Partial<{ config: Record<string, any>; plugins: FormKitPlugin[]; type: string | FormKitTypeDefinition; errors: string[]; inputErrors: Record<...>; sectionsSchema: Record<...>; }> & Omit<...>'.ts(2322)
<FormKit
type="text"
label="Display name"
:value="displayName"
/>
from formkit.
Not related but that error doesn't look right to me. I'm guessing there's some kind of implementation issue. Happy to check it out if you provide a reproduction
from formkit.
Related Issues (20)
- File Input FormKit element resetting bug
- Transfer List Max Not Working HOT 1
- Multiple Formkit with same schema HOT 2
- Dark mode text hard to read (select type) HOT 2
- Docs say wrong number of arguments for createInput HOT 1
- Blurred state stays false
- Hydration warnings on page refresh using Radio in a List HOT 3
- The autocomplete selection does not appear the second time HOT 5
- Make ShowMask property reactive
- Сursor jumps to the beginning of the value in the float input field while erasing
- Naked `floating-label` attribute on FormKit component does not work HOT 1
- Delay prop being overridden (to zero) by parent nodes
- Inputs break all component slots except `default` HOT 3
- `v-if` not working on messages empty object HOT 1
- FormKit Pro not synced with the current version HOT 2
- Categories in transfer list component
- Unable to use `$remove:` in a schema definition HOT 2
- Allow disabling types for default FormKit inputs HOT 1
- Custom taglist validation error only shows up when you focus out HOT 1
- Nuxt Layers and FormKit theme HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formkit.