Small and Independent Provider Component for Simple Element Auto-inputting

react-auto-tab

This is a lightweight package that allows you to easily implement auto-tabbing (focusing the next input), even in your existing project. You can auto-tab forward on maxLength, keypress, or both! You can even reverse-tab on backspacing an empty input!

Demo / Example

[Go to this page to see a live demo!] (https://okdv.github.io/react-auto-tab/)

Installation

Use the package manager npm to install react-auto-tab.

npm install --save react-auto-tab

Basic Usage

To start, all you have to do is wrap your code in the <AutoTabProvider> element. Wrap each group that you would like have auto-tabbing in. All input, textarea and select elements are included as focusable, by default

import React from 'react'
import { AutoTabProvider } from 'react-auto-tab'

const App = () => {
  return (
    <AutoTabProvider>
      <label>Birthday: </label>
      <input type='text' maxLength='2' placeholder='MM' />
      <span>/</span>
      <input type='text' maxLength='2' placeholder='DD' />
      <span>/</span>
      <input type='text' maxLength='4' placeholder='YYYY' />
    </AutoTabProvider>
  )
}

Props

There are a few props available. Only one prop is currently unique to the children elements, none are unique to AutoTabProvider.

To pass props to the wrapping <div>, which replaces <AutoTabProvider> in the DOM, include each props as an object property. Pass this object to the element with the settings prop.

const settings = {
  className: 'myClass',
  id: 'myId',
  focusonkey: 'enter'
  //...
}
return <AutoTabProvider settings={settings}>...</AutoTabProvider>

To pass props to a child of <AutoTabProvider>, just include it as a prop on the element

<AutoTabProvider>
  <label for="myInput-1" className="myClass" myId="myId" style="">You</label>
  <input type="text" ignorefocus="{1}" className="myClass" maxlength="2" />
  <span className="mySpan">Are</span>
  <input
    type="number"
    customProp="customValue"
    focusonmax="false"
    focusonkey="enter"
  />
  <p>Awesome</p>
  <input type="text" maxlength="3" />
</AutoTabProvider>

These are all of the properties that can be use in AutoTabProvider.props.settings as well as props on children elements. The parent settings will set the behavior for all elements, unless the same prop is present on a child.

  • prevonkey: integer Toggle back-tab/focus previous on backspacing an empty input, {1} or ‘true’ by default.
  • nextonkey: string Auto-tab/focus next element on press of this key, for example ‘enter’. null, or off, by default.
  • nextonmax: integer Toggle auto-tab/focus next element on hitting an elements maxLength. If there is no maxLength on that element, it will be 0 or ‘false’. 1, or true by default.

There is currently only one prop unique to children, and no props unique to the parent settings. The below prop is unique to focusable children elements.

  • ignorefocus: integer If set to 1, element will be ignored and ‘jumped’ in the focus sequence. 0, or false, by default

As a note, nextonmax and nextonkey can be active at the same time and running whichever is triggered first. If you have maxLength set and do not want to auto-tab on max length, nextonmax must be disabled.

Styling and Other Info

Styling, and using your own props on both AutoTabProvider and its children, is super easy. Just include whatever props, like className, id, style or customProp, using the same technique as the packages props, listed above.

As mentioned, any input, textarea, and select elements are included as focusable, by default. You can use the provided ignore prop on children to skip any of the elements mentioned.

Non-direct children will not be focusable, but they will still be rendered. For example, the input in the below example with id: 'nonDirect' will be skipped without use of ignore, but it will still render

<AutoTabProvider>
  <input type="text" maxlength="2" />
  <div>
    <input type="text" maxlength="3" id="nonDirect" />
  </div>
  <input type="text" maxlength="2" />
</AutoTabProvider>

It is also totally fine to use several AutoTabProvider elements back to back!

Technically, this should work with any input types. That being said, it has only been tested using password, text, and number. When possible, it is recommended to use type text. Please report any found issues with other types using the issues info below.

Examples

Just to make sure all bases are covered here, here are several examples of usage. To see some live examples, you will need to download and run the example from here.

First we will just turn off prevonkey, so when we backspace on an empty element here, it wont back-tab to the previous element.

<AutoTabProvider settings="{{prevonkey:" false}}>
  <input type="text" maxlength="3" />
  <span>-</span>
  <input type="text" maxlength="2" />
  <span>-</span>
  <input type="text" maxlength="4" />
</AutoTabProvider>

Next we will turn on nextonkey and set it to ‘Enter’, expect for the middle input, it will focus on maxLength this. This can be accomplished by simply not setting a maxLength for the other inputs, or you can disable maxLength in the AutoTabProvider settings, and only enable it for the middle input. Lets see both

<AutoTabProvider settings={{nextonkey: 'enter'}}>
   <label>Name</label>
   <input type="text" placeholder="First" />
   <input type="text" maxLength="1" placeholder="M" />
   <span>.  </span>
   <input type="text" placeholder="Last" />
</AutoTabProvider>

<AutoTabProvider settings={{nextonkey: 'enter', nextonmax: 0}}>
   <label>Name</label>
   <input type="text" maxLength="30" placeholder="First" />
   <input type="text" nextonmax={1} maxLength="1" placeholder="M" />
   <span>.  </span>
   <input maxLength="30" type="text" placeholder="Last" />
</AutoTabProvider>

What if you just wanted to ignore the middle name in the above example?

<AutoTabProvider settings={{nextonkey: 'enter'}}>
   <label>Name</label>
   <input type="text" placeholder="First" />
   <input type="text" ignorefocus={1} maxLength="1" placeholder="M" />
   <span>.  </span>
   <input type="text" placeholder="Last" />
</AutoTabProvider>

Anything that you think should be added to the documentation? See how to get in touch in the issues section below

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Issues

If you have any feedback, notice any bugs, or just have a burning question feel free to open an issue on Github.

Download Details:

Author: okdv

Demo: https://okdv.github.io/react-auto-tab/

Source Code: https://github.com/okdv/react-auto-tab

#react #reactjs #javascript

What is GEEK

Buddha Community

Small and Independent Provider Component for Simple Element Auto-inputting

Small and Independent Provider Component for Simple Element Auto-inputting

react-auto-tab

This is a lightweight package that allows you to easily implement auto-tabbing (focusing the next input), even in your existing project. You can auto-tab forward on maxLength, keypress, or both! You can even reverse-tab on backspacing an empty input!

Demo / Example

[Go to this page to see a live demo!] (https://okdv.github.io/react-auto-tab/)

Installation

Use the package manager npm to install react-auto-tab.

npm install --save react-auto-tab

Basic Usage

To start, all you have to do is wrap your code in the <AutoTabProvider> element. Wrap each group that you would like have auto-tabbing in. All input, textarea and select elements are included as focusable, by default

import React from 'react'
import { AutoTabProvider } from 'react-auto-tab'

const App = () => {
  return (
    <AutoTabProvider>
      <label>Birthday: </label>
      <input type='text' maxLength='2' placeholder='MM' />
      <span>/</span>
      <input type='text' maxLength='2' placeholder='DD' />
      <span>/</span>
      <input type='text' maxLength='4' placeholder='YYYY' />
    </AutoTabProvider>
  )
}

Props

There are a few props available. Only one prop is currently unique to the children elements, none are unique to AutoTabProvider.

To pass props to the wrapping <div>, which replaces <AutoTabProvider> in the DOM, include each props as an object property. Pass this object to the element with the settings prop.

const settings = {
  className: 'myClass',
  id: 'myId',
  focusonkey: 'enter'
  //...
}
return <AutoTabProvider settings={settings}>...</AutoTabProvider>

To pass props to a child of <AutoTabProvider>, just include it as a prop on the element

<AutoTabProvider>
  <label for="myInput-1" className="myClass" myId="myId" style="">You</label>
  <input type="text" ignorefocus="{1}" className="myClass" maxlength="2" />
  <span className="mySpan">Are</span>
  <input
    type="number"
    customProp="customValue"
    focusonmax="false"
    focusonkey="enter"
  />
  <p>Awesome</p>
  <input type="text" maxlength="3" />
</AutoTabProvider>

These are all of the properties that can be use in AutoTabProvider.props.settings as well as props on children elements. The parent settings will set the behavior for all elements, unless the same prop is present on a child.

  • prevonkey: integer Toggle back-tab/focus previous on backspacing an empty input, {1} or ‘true’ by default.
  • nextonkey: string Auto-tab/focus next element on press of this key, for example ‘enter’. null, or off, by default.
  • nextonmax: integer Toggle auto-tab/focus next element on hitting an elements maxLength. If there is no maxLength on that element, it will be 0 or ‘false’. 1, or true by default.

There is currently only one prop unique to children, and no props unique to the parent settings. The below prop is unique to focusable children elements.

  • ignorefocus: integer If set to 1, element will be ignored and ‘jumped’ in the focus sequence. 0, or false, by default

As a note, nextonmax and nextonkey can be active at the same time and running whichever is triggered first. If you have maxLength set and do not want to auto-tab on max length, nextonmax must be disabled.

Styling and Other Info

Styling, and using your own props on both AutoTabProvider and its children, is super easy. Just include whatever props, like className, id, style or customProp, using the same technique as the packages props, listed above.

As mentioned, any input, textarea, and select elements are included as focusable, by default. You can use the provided ignore prop on children to skip any of the elements mentioned.

Non-direct children will not be focusable, but they will still be rendered. For example, the input in the below example with id: 'nonDirect' will be skipped without use of ignore, but it will still render

<AutoTabProvider>
  <input type="text" maxlength="2" />
  <div>
    <input type="text" maxlength="3" id="nonDirect" />
  </div>
  <input type="text" maxlength="2" />
</AutoTabProvider>

It is also totally fine to use several AutoTabProvider elements back to back!

Technically, this should work with any input types. That being said, it has only been tested using password, text, and number. When possible, it is recommended to use type text. Please report any found issues with other types using the issues info below.

Examples

Just to make sure all bases are covered here, here are several examples of usage. To see some live examples, you will need to download and run the example from here.

First we will just turn off prevonkey, so when we backspace on an empty element here, it wont back-tab to the previous element.

<AutoTabProvider settings="{{prevonkey:" false}}>
  <input type="text" maxlength="3" />
  <span>-</span>
  <input type="text" maxlength="2" />
  <span>-</span>
  <input type="text" maxlength="4" />
</AutoTabProvider>

Next we will turn on nextonkey and set it to ‘Enter’, expect for the middle input, it will focus on maxLength this. This can be accomplished by simply not setting a maxLength for the other inputs, or you can disable maxLength in the AutoTabProvider settings, and only enable it for the middle input. Lets see both

<AutoTabProvider settings={{nextonkey: 'enter'}}>
   <label>Name</label>
   <input type="text" placeholder="First" />
   <input type="text" maxLength="1" placeholder="M" />
   <span>.  </span>
   <input type="text" placeholder="Last" />
</AutoTabProvider>

<AutoTabProvider settings={{nextonkey: 'enter', nextonmax: 0}}>
   <label>Name</label>
   <input type="text" maxLength="30" placeholder="First" />
   <input type="text" nextonmax={1} maxLength="1" placeholder="M" />
   <span>.  </span>
   <input maxLength="30" type="text" placeholder="Last" />
</AutoTabProvider>

What if you just wanted to ignore the middle name in the above example?

<AutoTabProvider settings={{nextonkey: 'enter'}}>
   <label>Name</label>
   <input type="text" placeholder="First" />
   <input type="text" ignorefocus={1} maxLength="1" placeholder="M" />
   <span>.  </span>
   <input type="text" placeholder="Last" />
</AutoTabProvider>

Anything that you think should be added to the documentation? See how to get in touch in the issues section below

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Issues

If you have any feedback, notice any bugs, or just have a burning question feel free to open an issue on Github.

Download Details:

Author: okdv

Demo: https://okdv.github.io/react-auto-tab/

Source Code: https://github.com/okdv/react-auto-tab

#react #reactjs #javascript

Ethan Hughes

Ethan Hughes

1578498958

Collection of 15 Vue Input Component for Your Vue.js App

Vue input component gives you a baseline to create your own custom inputs. It consists of a prepend/append slot, messages, and a default slot. In this article I will share 15 Vue input components to you.

1. Maska

  • No dependencies
  • Small size (~2 Kb gziped)
  • Ability to define custom tokens
  • Supports repeat symbols and dynamic masks
  • Works on any input (custom or native)

Maska

Demo

Download


2. v-range-flyout

A vue component that wraps a input type=number with a customizable range slider flyout with 2-way binding.

v-range-flyout

Demo

Download


3. vue-tel-input

International Telephone Input with Vue.

vue-tel-input

Demo

Download


4. Restricted Input

Allow restricted character sets in input elements.

Features

  • Disallow arbitrary characters based on patterns
  • Maintains caret position
  • Format/Update on paste
  • Works in IE11+

Restricted Input

Demo

Download


5. Vue Currency Input

The Vue Currency Input plugin allows an easy input of currency formatted numbers.

Vue Currency Input

Demo

Download


6. vue-fields

Input components for vue.js.

vue-fields

Demo

Download


7. vue-material-input

Simple example of issue I am seeing with input labels.

vue-material-input

Demo

Download


8. vue-tribute

A Vue.js wrapper for Zurb’s Tribute library for native @mentions.

vue-tribute

Demo

Download


9. vue-number-smarty

Number input with rich functionality for Vue.js.

Features

  • integer/float
  • signed/unsigned
  • step size
  • increment/decrement value by scrolling when focused
  • align variants
  • min and max boundaries
  • max length of integer part (only for float type)
  • max length of float part (only for float type)
  • max length of string
  • error state
  • readonly state
  • theme options

vue-number-smarty

Demo

Download


10. Vue input mask

Super tiny input mask library for vue.js based on PureMask.js (~2kb) exposed as directive. No dependencies.

Vue input mask

Demo

Download


11. vue-r-mask

mask directive for vue.js

  • Template similar to javascript regular expression. /\d{2}/
  • Directive useful for your own input or textarea.
  • Arbitrary number of digits in template /\d{1,10}/

vue-r-mask

Demo

Download


12. Vue IP

An ip address input with port and material design support.

Vue IP

Demo

Download


13. v-money Mask for Vue.js

Tiny input/directive mask for currency

Features

  • Lightweight (<2KB gzipped)
  • Dependency free
  • Mobile support
  • Component or Directive flavors
  • Accept copy/paste
  • Editable

v-money Mask for Vue.js

Demo

Download


14. Vue Masked Input

Dead simple masked input component for Vue.js 2.X. Based on inputmask-core.

Vue Masked Input

Demo

Download


15. VueJS input component

Mobile & Desktop friendly VueJS input component
Features used
CSS variables
Vue’s transition-group
Flexbox

VueJS input component

Demo


I hope you like them!

#vue-js #vue-input #vue-input-component #input-vue

Desmond  Gerber

Desmond Gerber

1670440320

How to Accept Text input From Users in A Phaser Game

When you create a game, you may find yourself needing to accept keyboard input from the user. I’m not talking about using the keyboard to control your player, but instead to accept text from the keyboard to be used as a username or for the in-game chat.

If you’ve been keeping up with the Phaser content releasing on the blog, you might remember the tutorial titled, Creating a Multiplayer Drawing Game with Phaser and MongoDB. This tutorial demonstrated taking user input to be used as the game information, but it did so with a bit of HTML hacking.

There are better ways!

In this tutorial we’re going to see how to take user keyboard input directly within a Phaser 3.x game using embedded HTML and JavaScript, rather than HTML layered on top of the game.

To get an idea of what we want to accomplish, take a look at the following animated image:

Text Input in a Phaser Game

In the above example we have a single game scene. This scene has rendered text as well as an input field directly in the game canvas. When you add input to the text field, the rendered text updates when you press the return key.

Like I mentioned, we could absolute position an HTML text input on our canvas, but then we lose out on some integration functionality as well as the automatic scaling that Phaser adds to the embedded HTML.

Create a New Phaser 3.x Project for the Game

To get us started, we’re going to create a new Phaser 3.x project using some boilerplate code. The goal here is to not over-complicate the focus of the example, being the text input.

On your computer, create a new directory and within that directory create an index.html file with the following markup:

<!DOCTYPE html>
<html>
    <head>
        <script src="//cdn.jsdelivr.net/npm/phaser@3.24.1/dist/phaser.min.js"></script>
    </head>
    <body>
        <div id="game"></div>
        <script>

            const phaserConfig = {
                type: Phaser.AUTO,
                parent: "game",
                width: 1280,
                height: 720,
                scene: {
                    init: initScene,
                    preload: preloadScene,
                    create: createScene,
                    update: updateScene
                }
            };

            const game = new Phaser.Game(phaserConfig);

            function initScene() { }
            function preloadScene() { }
            function createScene() { }
            function updateScene() { }

        </script>
    </body>
</html>

In the above markup, we’ve included the Phaser package in our project and configured a basic game with unused lifecycle events.

We know that the goal will be to eventually show the user provided text on the screen, so let’s get our text ready to go.

Within the createScene function of our index.html file, add the following JavaScript code:

function createScene() {

    this.message = this.add.text(640, 250, "Hello, --", {
        color: "#FFFFFF",
        fontSize: 60,
        fontStyle: "bold"
    }).setOrigin(0.5);

}

The above code will render some text on the screen. We’re storing a reference to the text object in the this.message variable because we plan to change the text later.

The foundation of our project is ready, so now we can focus on the text input.

Create and Interact with a Loaded HTML Component on the Phaser Canvas

The thought process behind accepting text input from the user is that we want to create a standard HTML form and load it into our Phaser game as if it were just another game asset.

We’ll start by creating an HTML file with our form. Within the project directory, create a new form.html file with the following markup:

<!DOCTYPE html>
<html>
    <head>
        <style>
            #input-form {
                padding: 15px;
                background-color: #931C22;
            }
            #input-form input {
                padding: 10px;
                font-size: 20px;
                width: 400px;
            }
        </style>
    </head>
    <body>
        <div id="input-form">
            <input type="text" name="name" placeholder="Full Name" />
        </div>
    </body>
</html>

The above markup is a properly styled input element. If you take only one thing out of the above markup, take the <input> tag with the name attribute. The name attribute is critical when it comes to what we do in our Phaser game.

We’ll continue, but this time from within the index.html file. Inside the index.html file, we need to modify the phaserConfig so that we can work with DOM elements in our game.

const phaserConfig = {
    type: Phaser.AUTO,
    parent: "game",
    width: 1280,
    height: 720,
    dom: {
        createContainer: true
    },
    scene: {
        init: initScene,
        preload: preloadScene,
        create: createScene,
        update: updateScene
    }
};

Take notice of the dom property. Without this property, anything we attempt to do with the HTML file will not work.

Since the game is now properly configured, we can jump into the preloadScene function:

function preloadScene() {
    this.load.html("form", "form.html");
}

In the above code we are loading the form.html file and giving it a key so we can later reference it in our code. With the HTML file loaded, now we can make use of it in the createScene function:

function createScene() {

    this.nameInput = this.add.dom(640, 360).createFromCache("form");

    this.message = this.add.text(640, 250, "Hello, --", {
        color: "#FFFFFF",
        fontSize: 60,
        fontStyle: "bold"
    }).setOrigin(0.5);

    this.returnKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER);

    this.returnKey.on("down", event => {
        let name = this.nameInput.getChildByName("name");
        if(name.value != "") {
            this.message.setText("Hello, " + name.value);
            name.value = "";
        }
    });

}

The above code has a bit more JavaScript than we previously saw. In addition to rendering our text, now we’re adding the DOM element to the canvas. Remember, in the preloadScene function we were only loading the HTML. In the createScene function we are adding it to the scene to be interacted with.

Being able to add text to it is great, but we need to know when the user wants to submit it. This is where the keyboard events come into play.

this.returnKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER);

The above line says that we are taking control of the return or enter key.

Since we have control of it, we can listen for down events:

this.returnKey.on("down", event => {
    let name = this.nameInput.getChildByName("name");
    if(name.value != "") {
        this.message.setText("Hello, " + name.value);
        name.value = "";
    }
});

When the key is pressed, we get the child element within the form.html file. Remember the name attribute on the input element? In this example name is not the attribute key, but the value that we set the attribute as. It is only coincidence that they share the same name.

Once we have the input field, we can check if it is empty. If it is not empty, we can change the rendered text and clear the input field.

Conclusion

You just saw how to allow text input in your Phaser 3.x game. This is useful if you need to take keyboard data beyond just knowing if a key was pressed. Maybe you’re creating an online game and you need to give your player a name, or maybe there is another reason. Whatever the reason, accepting user input is valuable.

Like I had previously mentioned, you can just create HTML and absolute position it on top of your game canvas rather than embedding it in the game. The problem with this approach is that you lose out on some scaling that Phaser does as well as the deep integration into the scene. It’s possible, but if I had to recommend something, I’d recommend the approach of embedding it into the game.

Original article source at: https://www.thepolyglotdeveloper.com/

#javascript #game #text #input 

 iOS App Dev

iOS App Dev

1655889360

Element IOS: A Glossy Matrix Collaboration Client for IOS

Element iOS

Element iOS is an iOS Matrix client provided by Element. It is based on MatrixSDK. 

Beta testing

You can try last beta build by accessing our TestFlight Public Link. For questions and feedback about latest TestFlight build, please access the Element iOS Matrix room: #element-ios:matrix.org.

Build instructions

If you have already everything installed, opening the project workspace in Xcode should be as easy as:

$ xcodegen                  # Create the xcodeproj with all project source files
$ pod install               # Create the xcworkspace with all project dependencies
$ open Riot.xcworkspace     # Open Xcode

Else, you can visit our installation guide. This guide also offers more details and advanced usage like using MatrixSDK in its development version.

Contributing

If you want to contribute to Element iOS code or translations, go to the contribution guide.

Support

When you are experiencing an issue on Element iOS, please first search in GitHub issues and then in #element-ios:matrix.org. If after your research you still have a question, ask at #element-ios:matrix.org. Otherwise feel free to create a GitHub issue if you encounter a bug or a crash, by explaining clearly in detail what happened. You can also perform bug reporting (Rageshake) from the Element application by shaking your phone or going to the application settings. This is especially recommended when you encounter a crash.

Download Details:
Author: vector-im
Source Code: https://github.com/vector-im/element-ios
License: Apache-2.0 license

#swift #ios #mobileapp

I am Developer

1597489568

Dynamically Add/Remove Multiple input Fields and Submit to DB with jQuery and Laravel

In this post, i will show you how to dynamically add/remove multiple input fields and submit to database with jquery in php laravel framework. As well as, i will show you how to add/remove multiple input fields and submit to database with validation in laravel.

dynamically add remove multiple input fields and submit to database with jquery and laravel app will looks like, you can see in the following picture:

add/remove multiple input fields dynamically with jquery laravel

Laravel - Add/Remove Multiple Input Fields Using jQuery, javaScript

Follow the below given easy step to create dynamically add or remove multiple input fields and submit to database with jquery in php laravel

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Routes
  • Step 5: Create Controller by Artisan
  • Step 6: Create Blade View
  • Step 7: Run Development Server

https://www.tutsmake.com/add-remove-multiple-input-fields-in-laravel-using-jquery/

#laravel - dynamically add or remove input fields using jquery #dynamically add / remove multiple input fields in laravel 7 using jquery ajax #add/remove multiple input fields dynamically with jquery laravel #dynamically add multiple input fields and submit to database with jquery and laravel #add remove input fields dynamically with jquery and submit to database #sql