@bodynarf/react.components 1.4.6 → 1.4.7
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/components/primitives/password/components/withLabel/index.d.ts +4 -0
- package/components/primitives/password/components/withLabel/index.d.ts.map +1 -0
- package/components/primitives/password/components/withLabel/index.js +51 -0
- package/components/primitives/password/components/withoutLabel/index.d.ts +4 -0
- package/components/primitives/password/components/withoutLabel/index.d.ts.map +1 -0
- package/components/primitives/password/components/withoutLabel/index.js +32 -0
- package/components/primitives/password/index.d.ts +14 -0
- package/components/primitives/password/index.d.ts.map +1 -0
- package/components/primitives/password/index.js +13 -0
- package/components/primitives/password/style.scss +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PasswordProps } from "../..";
|
|
2
|
+
declare const PasswordWithLabel: ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, label, placeholder, canShowPassword, }: PasswordProps) => JSX.Element;
|
|
3
|
+
export default PasswordWithLabel;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withLabel/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,iBAAiB,uIAMpB,aAAa,KAAG,WA8HlB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
|
|
4
|
+
import Icon from "../../../../icon";
|
|
5
|
+
import { getValidationValues } from "../../../../../utils";
|
|
6
|
+
import { InputSize } from "../../../";
|
|
7
|
+
const PasswordWithLabel = ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, label, placeholder, canShowPassword, }) => {
|
|
8
|
+
const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
|
|
9
|
+
const [contentIsHidden, setContentIsHidden] = useState(true);
|
|
10
|
+
const onIconClick = useCallback(() => setContentIsHidden(state => !state), [setContentIsHidden]);
|
|
11
|
+
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
|
|
12
|
+
const elSizeClassName = "is-{0}".format(getValueOrDefault(size, InputSize.Normal));
|
|
13
|
+
const id = name || generateGuid();
|
|
14
|
+
const elClassName = getClassName([
|
|
15
|
+
className,
|
|
16
|
+
elSizeClassName,
|
|
17
|
+
rounded === true ? "is-rounded" : "",
|
|
18
|
+
styleClassName,
|
|
19
|
+
"bbr-password",
|
|
20
|
+
"input",
|
|
21
|
+
]);
|
|
22
|
+
const inputContainerClassName = getClassName([
|
|
23
|
+
"control",
|
|
24
|
+
loading === true ? "is-loading" : "",
|
|
25
|
+
canShowPassword ? "has-icons-right" : "",
|
|
26
|
+
"bbr-password__wrapper",
|
|
27
|
+
]);
|
|
28
|
+
const labelClassName = getClassName([
|
|
29
|
+
"label",
|
|
30
|
+
!label.horizontal ? elSizeClassName : "",
|
|
31
|
+
label.className
|
|
32
|
+
]);
|
|
33
|
+
if (label.horizontal) {
|
|
34
|
+
const labelContainerClassName = getClassName([
|
|
35
|
+
"field-label",
|
|
36
|
+
elSizeClassName,
|
|
37
|
+
label.horizontalContainerClassName
|
|
38
|
+
]);
|
|
39
|
+
const fieldContainerClassName = getClassName([
|
|
40
|
+
"field-body",
|
|
41
|
+
label.horizontalFieldContainerClassName
|
|
42
|
+
]);
|
|
43
|
+
return (_jsxs("div", { className: "bbr-input field is-horizontal", children: [_jsx("div", { className: labelContainerClassName, children: _jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }) }), _jsx("div", { className: fieldContainerClassName, children: _jsxs("div", { className: "field", children: [_jsxs("div", { className: inputContainerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
|
|
44
|
+
_jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, title: "Show password", children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash" }) })] }), isValidationDefined && validationMessages.length > 0 &&
|
|
45
|
+
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }) })] }));
|
|
46
|
+
}
|
|
47
|
+
return (_jsxs("div", { className: "field", children: [_jsx("label", { className: labelClassName, htmlFor: id, children: label.caption }), _jsxs("div", { className: inputContainerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
|
|
48
|
+
_jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash" }) })] }), isValidationDefined && validationMessages.length > 0 &&
|
|
49
|
+
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
50
|
+
};
|
|
51
|
+
export default PasswordWithLabel;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PasswordProps } from "../..";
|
|
2
|
+
declare const PasswordWithoutLabel: ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, placeholder, canShowPassword, }: PasswordProps) => JSX.Element;
|
|
3
|
+
export default PasswordWithoutLabel;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/primitives/password/components/withoutLabel/index.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,QAAA,MAAM,oBAAoB,gIAMvB,aAAa,KAAG,WA0DlB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { generateGuid, getClassName, getValueOrDefault } from "@bodynarf/utils";
|
|
4
|
+
import Icon from "../../../../icon";
|
|
5
|
+
import { InputSize } from "../../../types";
|
|
6
|
+
import { getValidationValues } from "../../../../../utils";
|
|
7
|
+
const PasswordWithoutLabel = ({ onValueChange, disabled, validationState, name, className, size, style, rounded, loading, placeholder, canShowPassword, }) => {
|
|
8
|
+
const onChange = useCallback((event) => onValueChange(event.target.value), [onValueChange]);
|
|
9
|
+
const [contentIsHidden, setContentIsHidden] = useState(true);
|
|
10
|
+
const onIconClick = useCallback(() => setContentIsHidden(state => !state), [setContentIsHidden]);
|
|
11
|
+
const [isValidationDefined, styleClassName, validationMessages] = getValidationValues(style, validationState);
|
|
12
|
+
const elSizeClassName = "is-{0}".format(getValueOrDefault(size, InputSize.Normal));
|
|
13
|
+
const id = name || generateGuid();
|
|
14
|
+
const elClassName = getClassName([
|
|
15
|
+
className,
|
|
16
|
+
elSizeClassName,
|
|
17
|
+
rounded === true ? "is-rounded" : "",
|
|
18
|
+
styleClassName,
|
|
19
|
+
"bbr-password",
|
|
20
|
+
"input",
|
|
21
|
+
]);
|
|
22
|
+
const containerClassName = getClassName([
|
|
23
|
+
"control",
|
|
24
|
+
loading === true ? "is-loading" : "",
|
|
25
|
+
canShowPassword ? "has-icons-right" : "",
|
|
26
|
+
"bbr-password__wrapper",
|
|
27
|
+
]);
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: containerClassName, children: [_jsx("input", { type: contentIsHidden ? "password" : "text", className: elClassName, placeholder: placeholder, disabled: disabled, onChange: onChange, name: id, id: id }), canShowPassword && !loading &&
|
|
29
|
+
_jsx("span", { className: `icon is-right ${elSizeClassName}`, onMouseEnter: onIconClick, onMouseLeave: onIconClick, children: _jsx(Icon, { name: contentIsHidden ? "eye" : "eye-slash" }) })] }), isValidationDefined && validationMessages.length > 0 &&
|
|
30
|
+
_jsx("p", { className: `help m-help ${styleClassName}`, children: validationMessages.join("\n") })] }));
|
|
31
|
+
};
|
|
32
|
+
export default PasswordWithoutLabel;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./style.scss";
|
|
2
|
+
import { BaseInputElementProps } from "../types";
|
|
3
|
+
/** Password component props type */
|
|
4
|
+
export interface PasswordProps extends Omit<BaseInputElementProps<string>, 'defaultValue' | 'readonly'> {
|
|
5
|
+
/**
|
|
6
|
+
* Is icon "Show password" visible.
|
|
7
|
+
* Will show password on click
|
|
8
|
+
*/
|
|
9
|
+
canShowPassword: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Password input component */
|
|
12
|
+
declare const Password: (props: PasswordProps) => JSX.Element;
|
|
13
|
+
export default Password;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/password/index.tsx"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAKjD,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACnG;;;MAGE;IACF,eAAe,EAAE,OAAO,CAAC;CAC5B;AAED,+BAA+B;AAC/B,QAAA,MAAM,QAAQ,UAAW,aAAa,KAAG,WAMxC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isNullOrUndefined } from "@bodynarf/utils";
|
|
3
|
+
import "./style.scss";
|
|
4
|
+
import PasswordWithLabel from "./components/withLabel";
|
|
5
|
+
import PasswordWithoutLabel from "./components/withoutLabel";
|
|
6
|
+
/** Password input component */
|
|
7
|
+
const Password = (props) => {
|
|
8
|
+
if (isNullOrUndefined(props.label)) {
|
|
9
|
+
return _jsx(PasswordWithoutLabel, { ...props });
|
|
10
|
+
}
|
|
11
|
+
return _jsx(PasswordWithLabel, { ...props });
|
|
12
|
+
};
|
|
13
|
+
export default Password;
|