@neovici/cosmoz-input 3.10.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styles.js CHANGED
@@ -29,6 +29,7 @@ export const styles = css `
29
29
  --bg: var(--cosmoz-input-background);
30
30
  --focused-bg: var(--cosmoz-input-focused-background, var(--bg));
31
31
  --color: var(--cosmoz-input-color, var(--secondary-text-color, #737373));
32
+ --line-color: var(--cosmoz-input-line-color, var(--color));
32
33
  --focused-color: var(
33
34
  --cosmoz-input-focused-color,
34
35
  var(--primary-color, #3f51b5)
@@ -110,7 +111,7 @@ export const styles = css `
110
111
 
111
112
  .line {
112
113
  padding-top: 1px;
113
- border-bottom: 1px solid var(--color);
114
+ border-bottom: 1px solid var(--line-color);
114
115
  position: relative;
115
116
  }
116
117
  .line::before {
@@ -4,12 +4,11 @@ export interface BaseInput extends HTMLElement {
4
4
  maxRows?: number;
5
5
  focused?: boolean;
6
6
  disabled?: boolean;
7
- onInputRef?: (el: Input) => void;
8
7
  }
9
8
  export declare const useInput: <T extends BaseInput>(host: T) => {
10
9
  onChange: (e: Event) => boolean;
11
10
  onFocus: (e: FocusEvent) => void;
12
11
  onInput: (e: InputEvent) => void;
13
- onRef: (el?: Element) => void;
12
+ onRef: (el?: Element) => Input;
14
13
  };
15
14
  export {};
package/dist/use-input.js CHANGED
@@ -2,13 +2,8 @@ import { useCallback, useEffect, useRef } from 'haunted';
2
2
  import { useImperativeApi } from '@neovici/cosmoz-utils/hooks/use-imperative-api';
3
3
  import { notifyProperty } from '@neovici/cosmoz-utils/hooks/use-notify-property';
4
4
  export const useInput = (host) => {
5
- const { onInputRef } = host;
6
5
  const inputRef = useRef(undefined);
7
- const onRef = useCallback((el) => {
8
- const ref = el;
9
- inputRef.current = ref;
10
- onInputRef?.(ref);
11
- }, [onInputRef]);
6
+ const onRef = useCallback((el) => (inputRef.current = el), []);
12
7
  const root = host.shadowRoot, onChange = useCallback((e) => host.dispatchEvent(new Event(e.type, { bubbles: e.bubbles })), []), onInput = useCallback((e) => notifyProperty(host, 'value', e.target.value), []), onFocus = useCallback((e) => notifyProperty(host, 'focused', e.type === 'focus'), []), focus = useCallback(() => inputRef.current?.focus(), []), validate = useCallback(() => {
13
8
  const valid = inputRef.current?.checkValidity();
14
9
  host.toggleAttribute('invalid', !valid);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-input",
3
- "version": "3.10.0",
3
+ "version": "3.12.0",
4
4
  "description": "A input web component",
5
5
  "keywords": [
6
6
  "lit-html",