GithubHelp home page GithubHelp logo

tayloradamca / blazorcleave Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 519 KB

A Blazor class library for cleave.js

Home Page: https://www.nuget.org/packages/BlazorCleave/

License: MIT License

HTML 24.52% C# 44.92% JavaScript 15.33% TypeScript 10.04% CSS 5.19%

blazorcleave's Introduction

BlazorCleave

A Blazor class library that wraps the functionality of Cleave.js.

Usage

  1. In a Blazor Server or Blazor WebAssembly project, add a reference to the BlazorCleave package.

  2. In your _Imports.razor file, add the following statements:

@using BlazorCleave
@using BlazorCleave.Data
  1. In your _Host.cshtml (for Blazor Server) or index.html (for Blazor WebAssembly) file, add the following tags somewhere before the reference to the Blazor .js file:
    <script src="_content/BlazorCleave/BlazorCleave.js"></script>
    <script src="_content/BlazorCleave/cleave-phone.i18n.js"></script>
  1. If you want to add some default styling, in your _Host.cshtml (for Blazor Server) or index.html (for Blazor WebAssembly) file add the following after your current stylesheet link:
    <link href="_content/BlazorCleave/style.css" rel="stylesheet" />

You're now ready to use the package. For example, inside a .razor file,

//Time formatting
<Cleave Placeholder="hh:mm" TimeFormat="@( new TimeFormat{
        Format = new[] { 'h', 'm' }
    })" InputType="InputType.Time" />

// Date formatting
<Cleave Placeholder="YYYY/MM/DD" DateFormat="@(new DateFormat{
        Delimiter = '/',
        Format = new char[] { 'Y', 'm', 'd' }
    })" InputType="InputType.Date" />

// Phone number formatting
<Cleave Placeholder="Phone Number" CountryCode="CountryCode.CA" InputType="InputType.PhoneNumber" />

// Credit card formatting
<Cleave Placeholder="Credit Card" InputType="InputType.CreditCard" />

// Numeral formatting
<Cleave Placeholder="Numeral formatting" InputType="NumeralTypes.Type.Thousand" />

Notes

This is still a WIP, although it does work well, there is always improvements to be made.

Please contribute if you have any suggestions/reccomendations.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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.