Shared:Components:Password-input: add types
This commit is contained in:
parent
320495c358
commit
d9029e834e
@ -54,25 +54,27 @@ import {
|
|||||||
StyledTooltipItem,
|
StyledTooltipItem,
|
||||||
} from "./PasswordInput.styled";
|
} from "./PasswordInput.styled";
|
||||||
import {
|
import {
|
||||||
|
PasswordInputHandle,
|
||||||
PasswordInputProps,
|
PasswordInputProps,
|
||||||
TPasswordSettings,
|
TPasswordSettings,
|
||||||
TPasswordValidation,
|
TPasswordValidation,
|
||||||
|
TState,
|
||||||
} from "./PasswordInput.types";
|
} from "./PasswordInput.types";
|
||||||
|
|
||||||
const PasswordInput = React.forwardRef(
|
const PasswordInput = React.forwardRef<PasswordInputHandle, PasswordInputProps>(
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
inputType = InputType.password,
|
inputType = InputType.password,
|
||||||
inputValue,
|
inputValue,
|
||||||
clipActionResource,
|
clipActionResource,
|
||||||
emailInputName,
|
emailInputName,
|
||||||
|
passwordSettings,
|
||||||
onBlur,
|
onBlur,
|
||||||
onKeyDown,
|
onKeyDown,
|
||||||
onValidateInput,
|
onValidateInput,
|
||||||
onChange,
|
onChange,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
simpleView,
|
simpleView,
|
||||||
passwordSettings,
|
|
||||||
generatorSpecial,
|
generatorSpecial,
|
||||||
|
|
||||||
clipCopiedResource,
|
clipCopiedResource,
|
||||||
@ -102,10 +104,10 @@ const PasswordInput = React.forwardRef(
|
|||||||
tooltipOffsetLeft,
|
tooltipOffsetLeft,
|
||||||
tooltipOffsetTop,
|
tooltipOffsetTop,
|
||||||
isAutoFocussed,
|
isAutoFocussed,
|
||||||
}: PasswordInputProps,
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState<TState>({
|
||||||
type: inputType,
|
type: inputType,
|
||||||
value: inputValue,
|
value: inputValue,
|
||||||
copyLabel: clipActionResource,
|
copyLabel: clipActionResource,
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||||
|
|
||||||
import React from "react";
|
import React, { MouseEvent } from "react";
|
||||||
import { InputSize, InputType } from "../text-input";
|
import { InputSize, InputType } from "../text-input";
|
||||||
|
|
||||||
export type TPasswordSettings = {
|
export type TPasswordSettings = {
|
||||||
@ -46,6 +46,24 @@ export type TPasswordValidation = {
|
|||||||
length: boolean;
|
length: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PasswordInputHandle = {
|
||||||
|
onGeneratePassword: (e: MouseEvent) => void;
|
||||||
|
setState(state: TState): void;
|
||||||
|
value?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TState = {
|
||||||
|
type: InputType.text | InputType.password;
|
||||||
|
value?: string;
|
||||||
|
copyLabel?: string;
|
||||||
|
disableCopyAction?: boolean;
|
||||||
|
displayTooltip: boolean;
|
||||||
|
validLength: boolean;
|
||||||
|
validDigits: boolean;
|
||||||
|
validCapital: boolean;
|
||||||
|
validSpecial: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export interface PasswordInputProps {
|
export interface PasswordInputProps {
|
||||||
/** Allows setting the component id */
|
/** Allows setting the component id */
|
||||||
id?: string;
|
id?: string;
|
||||||
|
@ -24,4 +24,6 @@
|
|||||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||||
|
|
||||||
|
export { PasswordInputHandle } from "./PasswordInput.types";
|
||||||
|
|
||||||
export { PasswordInput } from "./PasswordInput";
|
export { PasswordInput } from "./PasswordInput";
|
||||||
|
Loading…
Reference in New Issue
Block a user