A collection of some additional input types to use with FormKit

Overview

FormKit Inputs

A collection of some additional input types to use with FormKit. Most of these additional input types are based on my personal needs, but feel free to submit PRs to add more.

How to use

Install the package

In order to use this package you have to install it first, use your preferred package manager to install it.

npm install @kgierke/formkit-inputs

Setup the package

After you've installed the package it's time to set it up. The minimal setup requires you only to import the createFormKitInputsPlugin function and use the resulting output as plugin in your FormKit configuration. Below is an example of the minimal setup.

import createApp from "vue";
import App from "./App.vue";
import { defaultConfig, plugin } from "@formkit/vue";
import { createFormKitInputsPlugin } from "@kgierke/formkit-inputs";

const formKitInputPlugin = createFormKitInputsPlugin();

const app = createApp(App);
app
  .use(
    plugin,
    defaultConfig({
      plugins: [formKitInputPlugin],
    })
  )
  .mount("#app");

Passing options

The createFormKitInputsPlugin function accepts an optional options argument. The following options are available:

{
    /**
     * To use the image input type with an automatic upload function
     * you have to pass an uploadHandler function.
     * This can also be passed as a property to the `image` input type.
     *
     * The uploadHandler receives the HTML5 `File` object
     * as first argument and expects an src string as return value.
     */
    uploadHandler: (file: File) => Promise<string> | string,
}

Included Inputs

Image

The image input type is an alternative to the file input type. It allows you to upload images and have a preview directly in the form. It also allows you to individually add and remove images (Possible with the multiple property). It is also possible to directly upload images to your server once they are selected and block the form from submitting until the upload is finished. To do so you have to pass an uploadHandler function as property or through the global configuration. The uploadHandler receives the HTML5 File object as first argument and expects an src string as return value.

">
<template>
  <FormKit type="form">
    <FormKit
      type="image"
      name="image"
      label="Image"
      multiple
      uploadHandler="uploadHandler"
    />
  FormKit>
template>

<script setup lang="ts">
import { FormKit } from "@formkit/vue";

const uploadHandler = async (file: File) => {
  const formData = new FormData();
  formData.append("file", file);

  const response = await fetch("/upload", {
    method: "POST",
    body: formData,
  });

  return response.url;
};
script>
Comments
  • Can't be used with @formkit v1.0.0-beta.9

    Can't be used with @formkit v1.0.0-beta.9

    After upgrade to beta-9 I can't start the application. image

    Breaking changes

    Composables from @formkit/inputs have been replaced with "sections". This should only affect users who were creating their own inputs from pre-existing composables.

    Composable useSchema require a function as first param.
    Can you fix it or tell how to do that and I can make a PR?.

    Thanks

    bug 
    opened by alvaro-canepa 3
  • Package distribution improvements

    Package distribution improvements

    Wanted to give this a try on a project using laravel mix and was unable to run it:

    image

    Bunding for package distribution can be a pain. Here are a few things that might help:

    1. An export map in packages.json:
    {
      ...
      "exports": {
        ".": {
          "import": "./dist/index.mjs",
          "require": "./dist/index.cjs",
          "types": "./dist/index.d.ts"
        }
      }
    }
    
    1. A module key in your package.json, like:
      "module": "dist/index.mjs",
    
    1. Rollup into a single .mjs and a .cjs file. You can use rollup for this (admittedly a pain).
    opened by justin-schroeder 2
  • Allow string value for single image input

    Allow string value for single image input

    If the input doesn't allow for multiple files it shouldn't be an array. Instead the input value should be a string representing the image url or a file object.

    enhancement 
    opened by kgierke 0
  • Reset input value after user input (image type)

    Reset input value after user input (image type)

    Reset the file input value to null after the user has selected a file to allow a re-selection of that file if it got cleared through the interface or if the user wants to add multiple times the same file.

    bug 
    opened by kgierke 0
  • Info output doesn't work on 'single' type uploads

    Info output doesn't work on 'single' type uploads

    Hi,

    When NOT using multiple="true" (i.e. single image uploads only), the information about the upload (name, upload state) does not work correctly:

    • The file name is not show
    • The state says 'uploaded' at all times, even while uploading

    I've had a quick poke around and it seems that the file value in the schema for the single version that this output depends on appears to be 'undefined' (which looks like it's related to the previous PR where the single and multiple were separated).

    opened by oldskool73 1
Magically convert a simple text input into a cool tag list with this jQuery plugin.

jQuery Tags Input Plugin Do you use tags to organize content on your site? This plugin will turn your boring tag list into a magical input that turns

XOXCO 2.3k Dec 23, 2022
Types generator will help user to create TS types from JSON. Just paste your single object JSON the Types generator will auto-generate the interfaces for you. You can give a name for the root object

Types generator Types generator is a utility tool that will help User to create TS Interfaces from JSON. All you have to do is paste your single objec

Vineeth.TR 16 Dec 6, 2022
Alpine.js wrapper for @formkit/auto-animate.

?? Alpine AutoAnimate ?? An Alpine.js wrapper for @formkit/auto-animate. ?? Installation CDN Include the following <script> tag in the <head> of your

Marc Reichel 16 Dec 28, 2022
Express typescript boilerplate using @types/node, @types/express

Express framework boilerplate in typescript.

Harris Gurung 3 Sep 21, 2022
Compile-time tests for types. Useful to make sure types don't regress into being overly-permissive as changes go in over time.

expect-type Compile-time tests for types. Useful to make sure types don't regress into being overly-permissive as changes go in over time. Similar to

Misha Kaletsky 82 Jan 8, 2023
🎊 A Collection of TypeScript types for the Kirby CMS

kirby-fest A collection of TypeScript types to work with Kirby, mainly in the context of the Kirby Query Language. Setup # pnpm pnpm add -D kirby-fest

Johann Schopplich 5 Nov 22, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Tag-input - A versetile tag input component built with Vue 3 Composition API

TagInput A versetile tag input component built with Vue 3 Composition API. Please read this article to learn how to build this package step by step an

Mayank 12 Oct 12, 2022
Vue-input-validator - 🛡️ Highly extensible & customizable input validator for Vue 2

??️ Vue-input-validator demo! What is this package all about? By using this package, you can create input validators only with the help of a single di

null 14 May 26, 2022
A Bootstrap plugin to create input spinner elements for number input

bootstrap-input-spinner A Bootstrap / jQuery plugin to create input spinner elements for number input. Demo page with examples Examples with floating-

Stefan Haack 220 Nov 7, 2022
A phone input component that uses intl-tel-input for Laravel Filament

Filament Phone Input This package provides a phone input component for Laravel Filament. It uses International Telephone Input to provide a dropdown o

Yusuf Kaya 24 Nov 29, 2022
A K6 Multi Scenario template applying some best practices along some examples

K6-Multi-Scenario-Template It is a performance testing template that shows how to use K6 to implement a Multi Scenario template applying some best pra

Swiss Life OSS 33 Nov 27, 2022
A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ💯

A simple react project that contain a single page application (SPA) And a simple caculator to make some calculation and there is a section you can see some Math quotes. Ⓜ??

Reem janina 7 May 31, 2022
This Repo Contains projects that demonstrate some concepts / algorithms / implemetation in some form of digital visualisation

Hacktoberfest 2022 OPEN FIRST Pull Request - GET STARTED WITH OPENSOURCE AND WIN SOME AWWSOME SWAGS ?? Contributors of Hacktoberfest 2022 This project

null 5 Nov 7, 2022
Drop-in replacements for @apollo/client's useQuery, useMutation and useSubscription hooks with reduced overhead and additional functionality.

apollo-augmented-hooks Drop-in replacements for @apollo/client's useQuery, useMutation and useSubscription hooks with reduced overhead and additional

appmotion Devs 57 Nov 18, 2022
PDF.js Read Only is an additional readonly mode for PDF.js

PDF.js Read Only PDF.js Read Only is an additional readonly mode for PDF.js, a Portable Document Format (PDF) viewer that is built with HTML5 which is

Aprillio Latuminggi 19 Dec 22, 2022
Windows notepad in web with additional features! Made with typescript and react.

Notepad Windows notepad in web with additional features! ?? Table of Contents ?? About Why I created ? Helpful for ? Who can contribute ? ?? Getting S

Muhammed Rahif 22 Jan 3, 2023
A simple and responsive quizlet-like flashcard component with a few additional options

Welcome to react-quizlet-flashcard ?? A simple and responsive quizlet-like flashcard component with a few additional options. Front and back card acce

A.B.Santhosh 14 Dec 17, 2022
A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online evaluations

Peer-Learning-Platform A platform designed specifically as an additional layer on top of Google Classroom for students to gain the best out of online

Rahul Dhakar 3 Jun 12, 2022