Socket
Socket
Sign inDemoInstall

@neovici/cosmoz-input

Package Overview
Dependencies
Maintainers
4
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neovici/cosmoz-input - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.3.0](https://github.com/neovici/cosmoz-input/compare/v1.2.0...v1.3.0) (2021-02-09)
### Features
* adds allowed-pattern support ([9e73006](https://github.com/neovici/cosmoz-input/commit/9e73006d103fbb22c4d4fe82b4b75915d67aec46))
## [1.2.0](https://github.com/neovici/cosmoz-input/compare/v1.1.1...v1.2.0) (2021-02-09)

@@ -2,0 +9,0 @@

21

cosmoz-input.js

@@ -8,3 +8,3 @@ import { html, nothing } from 'lit-html'; // eslint-disable-line object-curly-newline

import {
component, useCallback, useEffect
component, useCallback, useEffect, useMemo
} from 'haunted';

@@ -114,2 +114,3 @@

pattern,
allowedPattern,
value,

@@ -125,4 +126,16 @@ label,

root = host.shadowRoot,
onChange = useCallback(e => host.dispatchEvent(new Event(e.type, { bubbles: e.bubbles })), []),
onInput = useCallback(e => notifyProperty(host, 'value', e.target.value), []),
onBeforeInput = useMemo(() => {
if (allowedPattern == null) {
return;
}
const regexp = new RegExp(allowedPattern, 'u');
return e => {
if (!e.defaultPrevent && e.data && !regexp.test(e.data)) {
e.preventDefault();
}
onInput = useCallback(e => notifyProperty(host, 'value', e.target.value), []),
};
}, [allowedPattern]),
onFocus = useCallback(e => notifyProperty(host, 'focused', e.type === 'focus'), []),

@@ -169,3 +182,4 @@ focus = useCallback(() => root.querySelector('input')?.focus(), []),

.value=${ live(value ?? '') } autocomplete=${ ifDefined(autocomplete) }
@input=${ onInput } @focus=${ onFocus } @blur=${ onFocus }
@beforeinput=${ onBeforeInput } @input=${ onInput }
@change=${ onChange } @focus=${ onFocus } @blur=${ onFocus }
>

@@ -185,2 +199,3 @@ ${ label ? html`<label for="input" part="label">${ label }</label>` : nothing }

'pattern',
'allowed-pattern',
'readonly',

@@ -187,0 +202,0 @@ 'disabled',

2

package.json
{
"name": "@neovici/cosmoz-input",
"version": "1.2.0",
"version": "1.3.0",
"description": "A input web component",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc