npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mediaman/angular-form-components

v2.0.11

Published

Angular library of common, un-styled form components.

Downloads

3

Readme

angular-form-components

Angular library of common, un-styled form components.

Build Status npm version

Installation

npm install --save @mediaman/angular-form-components

Importing library

You need to import the module in your application:

import { NgModule } from '@angular/core';
import { AngularFormComponentsModule } from '@mediaman/angular-form-components';

@NgModule({
    imports: [AngularFormComponentsModule]
});
export class AppModule {
}

Enabling XSRF support

You can enable xsrf support to protect your form API agains cross domain forgery by providing an API endpoint to set the XSRF token.

import { NgModule } from '@angular/core';
import { AngularFormComponentsModule } from '@mediaman/angular-form-components';

@NgModule({
    imports: [AngularFormComponentsModule.forRoot({xsrfApiUrl: 'http://example.com/api/v1/csrf'})]
});
export class AppModule {
}

Components

We've also added a demo of the unstyled components with their respective documentation.

Input field

The mm-input component can represent all HTML input fields where a value can be entered.

import { Component } from '@angular/core';

@Component({
    selector: 'contact-form',
    template: `<mm-input [name]="'name'"
                    [id]="'name'"
                    [required]="true"
                    [(ngModel)]="name"
                    [label]="'Your name'"></mm-input>`
})
export class ContactFormComponent {
    public name: string = '';
}

Properties

| name | description | possible values | default value | |----------|-------------|-----------------|---------------| | type | The type of the rendered input element | text, search, number, email, ... | text | | name | The name of the rendered input element | * || | id | The id of the rendered input element | * || | required | The required state of the rendered input element | true, false | false | | pattern | Regular expression the value is checked against. Type must be text, search, tel, url, email, or password | true, false || | label | The label for the input element | * ||

Select

The mm-select component represents a HTML select field.

import { Component } from '@angular/core';
import { SelectOptionInterface } from '@mediaman/angular-form-components';

@Component({
    selector: 'contact-form',
    template: `<mm-select [name]="'gender'"
                    [id]="'gender'"
                    [options]="genderOptions"
                    [required]="true"
                    [(ngModel)]="gender"
                    [label]="'Your gender'"></mm-select>`
})
export class ContactFormComponent {
    public gender: string = '';
    public genderOptions: SelectOptionInterface[] = [
        {
            value: 'female',
            label: 'Female'
        },
        {
            value: 'male',
            label: 'Male'
        },
        {
            value: 'x',
            label: 'I don\'t care'
        },
    ];
}

Properties

| name | description | possible values | default value | |----------|-------------|-----------------|---------------| | name | The name of the rendered select element | * || | id | The id of the rendered select element | * || | options | The select elements options | SelectOptionInterface[] | [] | | required | The required state of the rendered select element | true, false | false | | label | The label for the select element | * ||

Radio button

The mm-radio-button component represents a HTML radio button.

The mm-radio-button component should be used, if possible, in combination with the mm-radio-button-group component.

import { Component } from '@angular/core';

@Component({
    selector: 'contact-form',
    template: `
        <mm-radio-button-group [name]="'contactPossibility'"
            [required]="true"
            [(ngModel)]="contactPossibility">
            <mm-radio-button [id]="'contactPossibilityPhone'"
                [value]="'phone'"
                [label]="'Phone'"></mm-radio-button>
            <mm-radio-button [id]="'contactPossibilityEmail'"
                [value]="'email'"
                [label]="'E-Mail'"></mm-radio-button>
        </mm-radio-button-group>
    `
})
export class ContactFormComponent {
    public contactPossibility: string = '';
}

Checkbox

The mm-checkbox component represents a HTML checkbox.

import { Component } from '@angular/core';

@Component({
    selector: 'contact-form',
    template: `
        <mm-checkbox [id]="'newsletterDoc'"
            [label]="'I want to get the newsletter'"
            [checked]="newsletterDoc"
            (change)="newsletterDoc = !newsletterDoc"></mm-checkbox>
        <mm-checkbox [id]="'emailDoc'"
            [label]="'It is okay for me to get contacted via email'"
            [checked]="emailDoc"
            (change)="emailDoc = !emailDoc"></mm-checkbox>
    `
})
export class ContactFormComponent {
    public newsletterDoc: boolean;
    public emailDoc: boolean;
}

Properties

| name | description | possible values | default value | |----------|-------------|-----------------|---------------| | name | The name of the rendered radio button element | * || | id | The id of the rendered radio button element | * || | value | The value of the rendered datio button element | * || | required | The required state of the rendered radio button element | true, false | false | | label | The label for the radio button element | * ||

Toggle

The mm-toggle component represents a simple toggle element with a hidden checkbox used to store the state.

import { Component } from '@angular/core';

@Component({
    selector: 'contact-form',
    template: `
        <mm-toggle [name]="'privacy'"
                  [id]="'privacy'"
                  [label]="'I accept the terms of usage.'"
                  [required]="true"
                  [(ngModel)]="privacyAccepted"></mm-toggle>
    `
})
export class ContactFormComponent {
    public privacyAccepted: boolean = false;
}

Properties

| name | description | possible values | default value | |----------|-------------|-----------------|---------------| | name | The name of the rendered toggle element | * || | id | The id of the rendered toggle element | * || | required | The required state of the rendered toggle element | true, false | false | | label | The label for the toggle element | * ||