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

ngx-input-eip

v0.1.2

Published

Lightweight edit in place text editor.

Downloads

19

Readme

Input edit in place

# Summary

Lightweight edit in place text editor.

Example

Example project here

git clone https://gitlab.opinioni.net/angular-components/ngx-input-eip-example.git

Getting started

  1. Install the library using npm
npm i --save ngx-input-eip
  1. Import the module to yourmodule.module.ts
import { NgxInputEipModule } from 'ngx-input-eip';
  1. Add the module to the imports
@NgModule({
  declarations: [
    MyComponentPage
  ],
  imports: [
    CommonModule,
    NgxInputEipModule // Adding the module import here
  ]
})
export class MyComponentModule { }
  1. Start using the library
<!-- Mandatory short field -->
<ngx-input-eip [isMandatory]="true" [(ngModel)]="user.fullname" ></ngx-input-eip>

<!-- Non-mandatory long field. -->
<ngx-input-eip [isShort]="false" [(ngModel)]="user.funnyStory" ></ngx-input-eip>

Api

Inputs

| Input | Type | Default | Description | | ----- | ---- | ------- | ----------- | | [isShort] | boolean | true | If the input should appear as input or textarea. | | [isMandatory] | boolean | false | If the input is required. | | [enableValidations] | boolean | true | If the input should be validated. | | [placeholder] | string | "Type here..." | The text to display when the input is empty. | | [label] | string | "" | The label of the input. You can use html templates by using label attribute. | | [showLabel] | boolean | true | If the label should be shown. | | [autosave] | boolean \| null | null | If the input should ask confirmation before emitting the changes. | | [classes] | string | "" | Classes to add to the input. | | [customValidators] | ValidatorFn[] | [] | Adding validators to the input. | | [isDisabled] | boolean | false | If the input should be disabled. | | [numbersOnly] | boolean | false | If the input should be numbers only. | | [min] | undefined \| number | undefined | Minimum vaule for numerical input. | | [max] | undefined \| number | undefined | Maximum value for numerical input. | | [maxLength] | undefined \| number | undefined | Maximum string length for non-numerical inputs. | | [minLength] | undefined \| number | undefined | Minimum string length for non-numerical inputs. | | [submitButtonLabel] | string | "Confirm" | The label for the submit button. You can pass html using submitButton attribute. | | [cancelButtonLabel] | string | "Cancel" | The label for the cancel button. You can pass html using cancelButton attribute. | | [actionbarMode] | "always"\|"show"\|"overlay" | isShort ? 'overlay' : 'show' | How the actionbar should be displayed. Default value is "overlay" if [isShort]="true", otherwise it's "show". Mode "always" means that the actionbar takes always the necessary space, but it has visibility: hidden if hasn't any changes. Mode "show" means that the actionbar does not take space if no changes, but when there are any changes, the actionbar takes the necessary space. Mode "overlay" means that the actionbar has position: absolute. | | [animateActionbar] | boolean | true | If [actionBarMode]="'show'", should the actionbar be shown with a transition or not. | | [allowInvalid] | boolean | false | If the input should be able to emit invalid values. The input is invalid if it has at least one error. Custom error messages are counded too. ([customErrorMessages]=['Some error message']) | | [errorsParser] | (c: AbstractControl) => (string\|TemplateRef<any>)[] | DefaultErrorsParser | Function that formats errors. Default value is a function that returns the most common errors in english. | | [showErrors] | boolean | true | If the error should be shown or not. You can validate the input and set is a invalid, but choose to avoid showing the errors. | | [customErrorMessages] | (string\|TemplateRef<any>)[] | [] | Add custom errors messages. This messages will counded as errors of the input itself, and they will prevent the input from emitting changes if [allowInvalid]="false" | | [customErrorsMap] | { [key: string]: ((e?: any) => string\|TemplateRef<any>)\|string\|TemplateRef<any> } | {} | Custom errors mapping. Overwrite default messages and show your custom errors. | | [inputStyle] | [ngStyle] | {} | Custom ngStyle for the input. |

Outpus

Most of the common events from the html element will be trasmitted. | Output | Type | Description | | ------ | ---- | ----------- | | (onSubmit) | {value: string, valid: boolean, errors: any} | This event will be emitted when the input is submitted. WARNING: This event will not be emitted if [autosave]="true" | | (onCancel) | void | Emitted when the changes are cancelled (click on "deny/cancel" button). WARNING: this event will not be emitted if [autosave]="true" | | (areUnsavedChanges) | boolean | Is there any changes that hasnt been emitted to parent? Useful to block user from leaving the page if there are any unsaved changes. | | (onChange) | any | Event emitted by the input. | | (onInput) | any | Event emitted by the input. | | (onClick) | any | Event emitted by the input. | | (onFocus) | any | Event emitted by the input. | | (onKeyDown) | any | Event emitted by the input. | | (onResize) | any | Event emitted by the input. | | (onDblclick) | any | Event emitted by the input. | | (onBlur) | any | Event emitted by the input. | | (onKeyPress) | any | Event emitted by the input. | | (onKeyUp) | any | Event emitted by the input. |

Html params

Params that you can use to edit the dom.

<ngx-input-eip>
  <span label >Label for the input</span>

  <button submitButton i18n >Conferma</button>
  <button cancelButton i18n >Annulla</button>
</ngx-input-eip>

Public properties

Public properties that can be useful; You can call any of this on the component. | Method | Description | | ------ | ----------- | | get debugJson(): any | This getter will return a hash of information. Cool if you want to see exactly what is going on inside the component. | | submit(): void | Function called when the submit button is clicked. | | cancel(): void | Function called when the cancel button is clicked. | | input?: ElementRef; | The actual input where user can write. WARNING: this is a <textarea>, not an <input>. | | get allErrorsMessages(): (string \| TemplateRef<any>)[] | Get all the error messages. |

Examples

All the examples below skip the initial setup

  1. Simple short input
<ngx-input-eip [(ngModel)]="myValue" ></ngx-input-eip>
  1. Textarea edit-in-place
<!-- [short]="false" -->
<ngx-input-eip [short]="false" [(ngModel)]="myValue"></ngx-input-eip>
  1. Numerical input
<ngx-input-eip formControlName="myValue" [numerical]="true" [min]="0" [max]="100" ></ngx-input-eip>
  1. With custom html label and/or buttons
<ngx-input-eip formControlName="myValue">
  <app-my-label [for]="'myValue'" label ></app-my-label>

  <button submitButton i18n >Conferma</button>
  <button cancelButton i18n >Annulla</button>
</ngx-input-eip>
  1. Calling public properties
<ngx-input-eip #input formControlName="myValue"></ngx-input-eip>

<hr>

<pre [innerText]="input.debugJson | json" ></pre>

Next features

  • On numerical input, +1 if arrow up and -1 if arrow down.
  • On numerical input, do not allow text input. (delete everything except the numbers)
  • On numerical input, add input [step] to define how much should the value be shifted with the arrows (down/up).
  • On numerical input, allow negative and decimal numbers.
  • Labels: TemplateRef can be passed too, not only strings.