@bonprix-ds/react-password-field 1.0.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/index.d.ts +30 -0
- package/dist/index.js +2 -0
- package/dist/src/PasswordField.js +21 -0
- package/dist/src/PasswordField.js.map +1 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
import { TextFieldBaseProps } from '@bonprix-ds/react-text-field';
|
|
4
|
+
|
|
5
|
+
declare interface BaseProps extends TextFieldBaseProps {
|
|
6
|
+
/** Reference to the input element. */
|
|
7
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare type ControlledInputProps = BaseProps & {
|
|
11
|
+
/** The current value of the input field. Should be used in conjunction with `onChange`, when controlling the input. Should be `undefined` otherwise. */
|
|
12
|
+
value: string;
|
|
13
|
+
/** The default value of the input field. Should be used when the input is uncontrolled. */
|
|
14
|
+
defaultValue?: never;
|
|
15
|
+
/** Callback that is triggered when the input value changes. Should be used in conjunction with `value`, when controlling the input. Optional otherwise. */
|
|
16
|
+
onChange: (value: string) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
declare const PasswordField: (props: PasswordFieldProps) => default_2.JSX.Element;
|
|
20
|
+
export default PasswordField;
|
|
21
|
+
|
|
22
|
+
export declare type PasswordFieldProps = ControlledInputProps | UncontrolledInputProps;
|
|
23
|
+
|
|
24
|
+
declare type UncontrolledInputProps = BaseProps & {
|
|
25
|
+
value?: never;
|
|
26
|
+
defaultValue: string;
|
|
27
|
+
onChange?: (value: string) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "@bonprix-ds/react-base-input-field";
|
|
3
|
+
import { useState as t } from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/PasswordField.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let [i, a] = t("password");
|
|
8
|
+
return /* @__PURE__ */ n(e, {
|
|
9
|
+
type: i,
|
|
10
|
+
buttonIcon: i === "password" ? "visibility" : "visibility-off",
|
|
11
|
+
onIconButtonClick: () => a((e) => e === "password" ? "text" : "password"),
|
|
12
|
+
iconButtonLabel: i === "password" ? "Passwort anzeigen" : "Passwort verstecken",
|
|
13
|
+
hideClear: !0,
|
|
14
|
+
...r,
|
|
15
|
+
componentName: "password-field"
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as default };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=PasswordField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordField.js","names":[],"sources":["../../src/PasswordField.tsx"],"sourcesContent":["\"use client\";\n\nimport BaseInputField from \"@bonprix-ds/react-base-input-field\";\nimport type { TextFieldBaseProps } from \"@bonprix-ds/react-text-field\";\nimport React, { RefObject, useState } from \"react\";\n\ninterface BaseProps extends TextFieldBaseProps {\n /** Reference to the input element. */\n inputRef?: RefObject<HTMLInputElement>;\n}\n\ntype ControlledInputProps = BaseProps & {\n /** The current value of the input field. Should be used in conjunction with `onChange`, when controlling the input. Should be `undefined` otherwise. */\n value: string;\n /** The default value of the input field. Should be used when the input is uncontrolled. */\n defaultValue?: never;\n /** Callback that is triggered when the input value changes. Should be used in conjunction with `value`, when controlling the input. Optional otherwise. */\n onChange: (value: string) => void;\n};\n\ntype UncontrolledInputProps = BaseProps & {\n value?: never;\n defaultValue: string;\n onChange?: (value: string) => void;\n};\n\nexport type Props = ControlledInputProps | UncontrolledInputProps;\n\nconst PasswordField = (props: Props) => {\n const [type, setType] = useState<\"password\" | \"text\">(\"password\");\n\n const onVisibilityChange = () => setType((prev) => (prev === \"password\" ? \"text\" : \"password\"));\n const inputIcon = type === \"password\" ? \"visibility\" : \"visibility-off\";\n const iconButtonLabel = type === \"password\" ? \"Passwort anzeigen\" : \"Passwort verstecken\";\n\n return (\n <BaseInputField\n type={type}\n buttonIcon={inputIcon}\n onIconButtonClick={onVisibilityChange}\n iconButtonLabel={iconButtonLabel}\n hideClear\n {...props}\n componentName=\"password-field\"\n />\n );\n};\nexport default PasswordField;\n"],"mappings":";;;;;AA4BA,IAAM,KAAiB,MAAiB;CACtC,IAAM,CAAC,GAAM,KAAW,EAA8B,UAAU;CAMhE,OACE,kBAAC,GAAD;EACQ;EACN,YANc,MAAS,aAAa,eAAe;EAOnD,yBAR6B,GAAS,MAAU,MAAS,aAAa,SAAS,UAAW;EASzE,iBAPG,MAAS,aAAa,sBAAsB;EAQhE,WAAA;EACA,GAAI;EACJ,eAAc;CACf,CAAA;AAEL"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bonprix-ds/react-password-field",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "PasswordField component, implemented in React, for the Bonprix Design System.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "UNLICENSED",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/bonprix/design-system.git",
|
|
29
|
+
"directory": "packages/react/password-field"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@bonprix-ds/react-base-input-field": "1.0.0",
|
|
33
|
+
"@bonprix-ds/react-text-field": "1.0.0",
|
|
34
|
+
"@bonprix-ds/utils": "0.2.1"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^19.0.0",
|
|
38
|
+
"react-dom": "^19.0.0",
|
|
39
|
+
"tailwind-variants": "0.3.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"vite": "8.2.2",
|
|
43
|
+
"@types/react": "19.2.18",
|
|
44
|
+
"@vitejs/plugin-react": "6.1.1",
|
|
45
|
+
"rollup-preserve-directives": "1.1.3",
|
|
46
|
+
"unplugin-dts": "1.0.3",
|
|
47
|
+
"@microsoft/api-extractor": "7.59.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "vite build"
|
|
51
|
+
}
|
|
52
|
+
}
|