@npm_leadtech/legal-lib-components 7.106.31 → 7.106.32

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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { type EnterKeyHint } from './TextInputProps.types';
2
3
  interface InputProps {
3
4
  name: string;
4
5
  placeholder: string;
@@ -15,6 +16,7 @@ interface InputProps {
15
16
  onKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void;
16
17
  country: string;
17
18
  currencySymbol?: string;
19
+ enterKeyHint?: EnterKeyHint;
18
20
  }
19
21
  export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
20
22
  export {};
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
3
3
  import eyeCloseIcon from '../../../../images/svg/eye-close.svg';
4
4
  import eyeIcon from '../../../../images/svg/eye-24-px.svg';
5
5
  import percent from '../../../../images/svg/percent.svg';
6
- export const Input = React.forwardRef(({ value, name, placeholder, className, onChange, onClick, onBlur, onKeyDown, onKeyUp, disabled, type = 'text', maxLength, country, prefix, currencySymbol }, ref) => {
6
+ export const Input = React.forwardRef(({ value, name, placeholder, className, onChange, onClick, onBlur, onKeyDown, onKeyUp, disabled, type = 'text', maxLength, country, prefix, currencySymbol, enterKeyHint }, ref) => {
7
7
  const isShortInput = Boolean(maxLength && maxLength <= 5);
8
8
  const [hidden, setHidden] = useState(true);
9
9
  const showPassword = () => {
@@ -24,7 +24,7 @@ export const Input = React.forwardRef(({ value, name, placeholder, className, on
24
24
  else if (isPercent) {
25
25
  finalClassName += ' has-percent-suffix';
26
26
  }
27
- return (_jsxs(_Fragment, { children: [isCurrency && !!prefix && otherCurrency && currencySymbol && (_jsx("div", { className: 'input-icon-currency-prefix', children: _jsx("span", { children: currencySymbol }) })), _jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: `${finalClassName} ${isShortInput ? 'e-text-input__short' : ''}`, maxLength: maxLength, placeholder: placeholder, onChange: onChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: value, "data-qa": name, disabled: disabled, ref: ref }), type === 'password' && (_jsx("button", { type: 'button', className: 'input-icon-password-button', onClick: showPassword, onKeyDown: (e) => {
27
+ return (_jsxs(_Fragment, { children: [isCurrency && !!prefix && otherCurrency && currencySymbol && (_jsx("div", { className: 'input-icon-currency-prefix', children: _jsx("span", { children: currencySymbol }) })), _jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: `${finalClassName} ${isShortInput ? 'e-text-input__short' : ''}`, maxLength: maxLength, placeholder: placeholder, onChange: onChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: value, "data-qa": name, disabled: disabled, enterKeyHint: enterKeyHint, ref: ref }), type === 'password' && (_jsx("button", { type: 'button', className: 'input-icon-password-button', onClick: showPassword, onKeyDown: (e) => {
28
28
  if (e.key === 'Enter')
29
29
  showPassword();
30
30
  }, children: _jsx("img", { src: hidden ? eyeIcon : eyeCloseIcon, alt: '' }) })), isCurrency
@@ -3,6 +3,7 @@ import React, { useState } from 'react'
3
3
  import eyeCloseIcon from '../../../../images/svg/eye-close.svg'
4
4
  import eyeIcon from '../../../../images/svg/eye-24-px.svg'
5
5
  import percent from '../../../../images/svg/percent.svg'
6
+ import { type EnterKeyHint } from './TextInputProps.types'
6
7
 
7
8
  interface InputProps {
8
9
  name: string
@@ -20,6 +21,7 @@ interface InputProps {
20
21
  onKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void
21
22
  country: string
22
23
  currencySymbol?: string
24
+ enterKeyHint?: EnterKeyHint
23
25
  }
24
26
 
25
27
  export const Input = React.forwardRef<HTMLInputElement, InputProps>(
@@ -39,7 +41,8 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
39
41
  maxLength,
40
42
  country,
41
43
  prefix,
42
- currencySymbol
44
+ currencySymbol,
45
+ enterKeyHint
43
46
  }: InputProps,
44
47
  ref
45
48
  ) => {
@@ -87,6 +90,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
87
90
  value={value}
88
91
  data-qa={name}
89
92
  disabled={disabled}
93
+ enterKeyHint={enterKeyHint}
90
94
  ref={ref}
91
95
  />
92
96
  {type === 'password' && (
@@ -6,7 +6,7 @@ import { Input } from './Input';
6
6
  import { TextInputLabel } from './TextInputLabel';
7
7
  import { TextInputMessage } from './TextInputMessage';
8
8
  import { TextInputTooltip } from './TextInputTooltip';
9
- const TextInput = React.forwardRef(({ label, value, validate = true, isValidGroup = true, format = undefined, name, placeholder, onChange, onClick, onBlur, onKeyDown, onKeyUp, prefix = '', disabled, type = 'text', maxLength, errorMessage = '', notes, dialogMenuTip, tooltip = '', givenClass = '', children, country, currencySymbol }, ref) => {
9
+ const TextInput = React.forwardRef(({ label, value, validate = true, isValidGroup = true, format = undefined, name, placeholder, onChange, onClick, onBlur, onKeyDown, onKeyUp, prefix = '', disabled, type = 'text', maxLength, errorMessage = '', notes, dialogMenuTip, tooltip = '', givenClass = '', children, country, currencySymbol, enterKeyHint }, ref) => {
10
10
  const classnames = classNames('e-text', {
11
11
  [givenClass]: givenClass,
12
12
  'e-text--is-invalid': !validate,
@@ -24,9 +24,9 @@ const TextInput = React.forwardRef(({ label, value, validate = true, isValidGrou
24
24
  };
25
25
  const renderInput = () => {
26
26
  if (Boolean(format) && type !== 'number' && type !== 'tel') {
27
- return (_jsx(NumericFormat, { name: name, id: name, placeholder: placeholder, className: 'e-text-input', onChange: onChange, onClick: onClick, value: value, "data-qa": name, disabled: disabled, maxLength: maxLength, onBlur: onBlur }));
27
+ return (_jsx(NumericFormat, { name: name, id: name, placeholder: placeholder, className: 'e-text-input', onChange: onChange, onClick: onClick, value: value, "data-qa": name, disabled: disabled, maxLength: maxLength, onBlur: onBlur, enterKeyHint: enterKeyHint }));
28
28
  }
29
- return (_jsx(Input, { name: name ?? '', type: type, prefix: prefix, placeholder: placeholder ?? '', className: 'e-text-input', onChange: handleChange, onClick: onClick ?? (() => { }), value: value, "data-qa": name, disabled: disabled ?? false, maxLength: maxLength, onBlur: onBlur ?? (() => { }), ref: ref, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, country: country, currencySymbol: currencySymbol }));
29
+ return (_jsx(Input, { name: name ?? '', type: type, prefix: prefix, placeholder: placeholder ?? '', className: 'e-text-input', onChange: handleChange, onClick: onClick ?? (() => { }), value: value, "data-qa": name, disabled: disabled ?? false, maxLength: maxLength, onBlur: onBlur ?? (() => { }), ref: ref, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, country: country, currencySymbol: currencySymbol, enterKeyHint: enterKeyHint }));
30
30
  };
31
31
  return (_jsxs("div", { className: classnames, children: [Boolean(children) && _jsx("div", { className: 'e-text__children', children: children }), _jsx(TextInputTooltip, { tooltip: tooltip }), _jsx(TextInputMessage, { errorMessage: errorMessage, validate: validate }), renderInput(), _jsx(TextInputLabel, { label: label, htmlFor: name, notes: notes, dialogMenuTip: dialogMenuTip })] }));
32
32
  });
@@ -34,7 +34,8 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
34
34
  givenClass = '',
35
35
  children,
36
36
  country,
37
- currencySymbol
37
+ currencySymbol,
38
+ enterKeyHint
38
39
  }: TextInputProps,
39
40
  ref
40
41
  ) => {
@@ -72,6 +73,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
72
73
  disabled={disabled}
73
74
  maxLength={maxLength}
74
75
  onBlur={onBlur}
76
+ enterKeyHint={enterKeyHint}
75
77
  />
76
78
  )
77
79
  }
@@ -95,6 +97,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
95
97
  onKeyUp={handleKeyUp}
96
98
  country={country}
97
99
  currencySymbol={currencySymbol}
100
+ enterKeyHint={enterKeyHint}
98
101
  />
99
102
  )
100
103
  }
@@ -1,3 +1,4 @@
1
+ export type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
1
2
  export interface TextInputProps {
2
3
  label?: string;
3
4
  name?: string;
@@ -24,4 +25,5 @@ export interface TextInputProps {
24
25
  children?: React.ReactNode;
25
26
  country: string;
26
27
  currencySymbol?: string;
28
+ enterKeyHint?: EnterKeyHint;
27
29
  }
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ export type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'
3
+
2
4
  export interface TextInputProps {
3
5
  label?: string
4
6
  name?: string
@@ -25,4 +27,5 @@ export interface TextInputProps {
25
27
  children?: React.ReactNode
26
28
  country: string
27
29
  currencySymbol?: string
30
+ enterKeyHint?: EnterKeyHint
28
31
  }
@@ -189,3 +189,14 @@ export const SmallMaxLength: Story = {
189
189
  maxLength: 5
190
190
  }
191
191
  }
192
+
193
+ export const WithEnterKeyHint: Story = {
194
+ args: {
195
+ value: '',
196
+ name: 'first_name',
197
+ placeholder: 'First name',
198
+ label: 'First name',
199
+ type: 'text',
200
+ enterKeyHint: 'next'
201
+ }
202
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npm_leadtech/legal-lib-components",
3
- "version": "7.106.31",
3
+ "version": "7.106.32",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",