GithubHelp home page GithubHelp logo

ukchukx / svelte-inline-input Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 4.0 19 KB

Inline editable input component in Svelte

Home Page: https://www.npmjs.com/package/svelte-inline-input

JavaScript 18.26% Svelte 81.74%
svelte editable inline-editor

svelte-inline-input's Introduction

svelte-inline-input

An inline editable input component for Svelte.

Displays as text and becomes editable by clicking or tapping.

Example

You can read how it was built here

Installation

npm install svelte-inline-input

Browser

<script type="text/javascript" src="https://unpkg.com/svelte-inline-input"></script>

Module

import InlineInput from 'svelte-inline-input';

Usage

Once installed, it can be used in a template as:

<InlineInput bind:value />

See the props table below for the available options.

Props

Property Type Description Default
type string The input type. Could be text, number, textarea or select text
placeholder string Text to be shown as a placeholder while there is no input empty string
labelClasses string CSS classes for the label element empty string
inputClasses string CSS classes for the input element empty string
rows integer Textarea rows 2
cols integer Textarea columns 20
options array Provides the options for selects. Each object should have the format {label: x, value: x} []

Events

Event Description
blur Fired when the input element loses focus. Also provides the input element's value

License

MIT

svelte-inline-input's People

Contributors

dependabot[bot] avatar michaelbrunn3r avatar ukchukx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

svelte-inline-input's Issues

select

select elements are not updating the values for me

Label has extra whitespace

The Label has an extra whitespace on the right. E.g. xยฒ is displayed as x ยฒ.
This seems to be caused by the 'selectCaret' slot.

Input Validation

First and foremost let me say thanks, double thanks in fact, this package is brilliant! ๐Ÿ‘

I'd link the medium article from the github Readme and maybe put the animated gif from the medium article page there as well so folks get a quick grasp of how cool this package actually is ๐Ÿ˜ƒ

One thing I was thinking about is how to do some input validation with svelte-inline-input?!

I'm currently using https://github.com/tjinauyeung/svelte-forms-lib with it's custom helpers such as <Form> and yup https://svelte-forms-lib-sapper-docs.now.sh/helpers but I figure I'd ask you how you do it and then maybe https://svelte-forms-lib-sapper-docs.now.sh/yup is something that could work together with svelte-inline-input?

Would be brilliant if <InlineInput> would be another <Field> like here https://svelte-forms-lib-sapper-docs.now.sh/field

Then using it would look something like this

  <script>
    import { Form, Field } from "svelte-forms-lib";
    import * as yup from "yup";

    const formProps = {
      initialValues: {
        text: "",
        email: "",
        password: "",
        number: 0,
        date: "",
        hobby:""
      },
      validationSchema: yup.object().shape({
        text: yup.string(),
        email: yup.string().email(),
        password: yup.string(),
        number: yup.number(),
        date: yup.date(),
        hobby: yup.string()
      }),
      onSubmit: values => {
        alert(JSON.stringify(values, null, 2));
      }
    };
  </script>

  <Form {...formProps}>
    <label>input[type=text]</label>
    <Field name="text" type="text" />

    <label>input[type=password]</label>
    <Field name="password" type="password" />

    <label>input[type=email]</label>
    <Field name="email" type="email" />

    <label>input[type=number]</label>
    <Field name="number" type="number" />

    <label>input[type=date]</label>
    <Field name="date" type="date" />

    <label>input[type=inline]</label>            // <--- using svelte-inline-input ๐Ÿค”
    <Field name="hobby" type="inline" />

    <button type="submit">submit</button>
  </Form>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.