Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormKit Integration #4

Open
cpreston321 opened this issue Oct 3, 2022 · 8 comments
Open

FormKit Integration #4

cpreston321 opened this issue Oct 3, 2022 · 8 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@cpreston321
Copy link

cpreston321 commented Oct 3, 2022

馃啋 Your use case

When integrating with FormKit you can add custom inputs which in this case it would be nice to see examples on how to best integrate with FormKit. I would like to have the option to just a make a new input and add the captcha to the form automatically. FormKit is a super nice library for validation creation of forms.

FormKit

馃啎 The solution you'd like

I would like to see if formkit is enabled it automatically registers a new FormKit type of turnstile if that is possible.

馃攳 Alternatives you've considered

No response

鈩癸笍 Additional info

Links & Context

It would be awesome to integrate globally so it can be easier to use.

@cpreston321 cpreston321 added the enhancement New feature or request label Oct 3, 2022
@cpreston321 cpreston321 changed the title Formkit Integration FormKit Integration Oct 3, 2022
@danielroe danielroe added the good first issue Good for newcomers label Oct 3, 2022
@danielroe
Copy link
Collaborator

danielroe commented Oct 3, 2022

Not sure if this is something for this library or whether some integrating code should be added in FormKit, but I'd welcome this kind of integration or some kind of API for component libraries.

@cpreston321
Copy link
Author

@danielroe It could be a separate module. But since the component lives here you could possibly check to see if the @formkit/nuxt is being used and automatically setup the custom integration plugin that makes it feel like magic so you won't have to install two vs one module.

I am just thinking out-loud. Maybe it's more complex than I am making it sound :)

I appreciate the instant feedback! let me know where I could help.

Thanks 馃挌

Copy link
Collaborator

Well, a good start would be a sample project with both <Turnstile> and FormKit. Maybe a stackblitz to show me the ideal API/DX, with an explanation of what might be nice to happen?

@cpreston321
Copy link
Author

I got you thanks!

@AdrianoCahete
Copy link

Hey @danielroe, this feature is something that I like to have in my project. If you need a sponsor to do that, how much will be (remember that I'm just a solo dev hahaha)?

@danielroe
Copy link
Collaborator

Sponsorship is always welcome 馃槉 but I'm happy to implement this anyway when I have time.

The first thing to do would be to spell out a little bit more of the kind of API/experience you're looking for as a user of FormKit. Make that as high-level as you like.

@AdrianoCahete
Copy link

Today I'm using FormKit for the forms and NaiveUI for the components, until I have time to create my own components, but I'll keep using FormKit because forms are hard work that I'm not following to self-made.

With that in mind, I'm using your module easily, but an auto import with, I don't know, little config on nuxt.config or some prop in FormKit form type will be awesome (but not sure if it's really can be reach from FK side). If not, just a <FormKit :type="turnstile" /> will be awesome and will make FK user's code more standardized.

(I'm having a problem with this lib on nuxt.config, that cannot set theme option, but since it's not my main concern yet, I just commented out for now)

@ineshbose
Copy link

Hi, I haven't made use of this project yet but I would think that integrating with FormKit may not be its scope. Instead, FormKit does make it very easy to add custom inputs. This is how I would do it:

components/FKTurnstile.vue (custom wrapper)

<script setup>
const props = defineProps({
  context: Object,
})

function handleInput(token) {
  props.context.node.input(token)
}
</script>

<template>
  <Turnstile v-model="props.context._value" @update:modelValue="handleInput" />
</template>

formkit.config.ts (FormKit configuration and component registration)

import { createInput } from '@formkit/vue';
import FKTurnstile from '~/components/FKTurnstile.vue';

export default {
  inputs: {
    turnstile: createInput(FKTurnstile, {})
  },
};

Here's a stackblitz with this: https://stackblitz.com/edit/github-ryz8tl?file=app.vue (may get deleted later); feel free to share any improvements you think can be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants