@bonprix-ds/react-password-field 1.0.3 → 1.0.4

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,21 +1,22 @@
1
1
  "use client";
2
2
  import { useState as e } from "react";
3
3
  import t from "@bonprix-ds/react-base-input-field";
4
- import { jsx as n } from "react/jsx-runtime";
4
+ import { VisibilityIcon as n, VisibilityOffIcon as r } from "@bonprix-ds/react-icon/icons";
5
+ import { jsx as i } from "react/jsx-runtime";
5
6
  //#region src/PasswordField.tsx
6
- var r = (r) => {
7
- let [i, a] = e("password");
8
- return /* @__PURE__ */ n(t, {
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",
7
+ var a = (a) => {
8
+ let [o, s] = e("password");
9
+ return /* @__PURE__ */ i(t, {
10
+ type: o,
11
+ buttonIcon: i(o === "password" ? n : r, {}),
12
+ onIconButtonClick: () => s((e) => e === "password" ? "text" : "password"),
13
+ iconButtonLabel: o === "password" ? "Passwort anzeigen" : "Passwort verstecken",
13
14
  hideClear: !0,
14
- ...r,
15
+ ...a,
15
16
  componentName: "password-field"
16
17
  });
17
18
  };
18
19
  //#endregion
19
- export { r as default };
20
+ export { a as default };
20
21
 
21
22
  //# sourceMappingURL=PasswordField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordField.js","names":["BaseInputField","PasswordField","type","setType","useState","prev","props"],"sources":["../../src/PasswordField.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { RefObject, useState } from \"react\";\n\nimport BaseInputField from \"@bonprix-ds/react-base-input-field\";\nimport type { TextFieldBaseProps } from \"@bonprix-ds/react-text-field\";\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":";;;;;AA6BA,IAAMC,KAAiB,MAAiB;CACtC,IAAM,CAACC,GAAMC,KAAWC,EAA8B,UAAU;CAMhE,OACE,kBAACJ,GAAD;EACQ;EACN,YANcE,MAAS,aAAa,eAAe;EAOnD,yBAR6BC,GAAS,MAAUE,MAAS,aAAa,SAAS,UAAW;EASzE,iBAPGH,MAAS,aAAa,sBAAsB;EAQhE,WAAA;EACA,GAAII;EACJ,eAAc;CACf,CAAA;AAEL"}
1
+ {"version":3,"file":"PasswordField.js","names":["BaseInputField","PasswordField","type","setType","useState","jsx","VisibilityIcon","VisibilityOffIcon","prev","props"],"sources":["../../src/PasswordField.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { RefObject, useState } from \"react\";\n\nimport BaseInputField from \"@bonprix-ds/react-base-input-field\";\nimport { VisibilityIcon, VisibilityOffIcon } from \"@bonprix-ds/react-icon/icons\";\nimport type { TextFieldBaseProps } from \"@bonprix-ds/react-text-field\";\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\" ? <VisibilityIcon /> : <VisibilityOffIcon />;\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":";;;;;;AA8BA,IAAMC,KAAiB,MAAiB;CACtC,IAAM,CAACC,GAAMC,KAAWC,EAA8B,UAAU;CAMhE,OACE,kBAACJ,GAAD;EACQ;EACN,YANoCK,EAAtBH,MAAS,aAAcI,IAAqBC,GAAtB,CAAiB,CAAwB;EAO7E,yBAR6BJ,GAAS,MAAUK,MAAS,aAAa,SAAS,UAAW;EASzE,iBAPGN,MAAS,aAAa,sBAAsB;EAQhE,WAAA;EACA,GAAIO;EACJ,eAAc;CACf,CAAA;AAEL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-password-field",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "PasswordField component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -32,9 +32,10 @@
32
32
  "provenance": true
33
33
  },
34
34
  "dependencies": {
35
- "@bonprix-ds/react-base-input-field": "1.0.3",
36
- "@bonprix-ds/react-text-field": "1.1.0",
37
- "@bonprix-ds/utils": "0.3.0"
35
+ "@bonprix-ds/react-base-input-field": "1.1.0",
36
+ "@bonprix-ds/react-icon": "1.3.0",
37
+ "@bonprix-ds/react-text-field": "1.1.1",
38
+ "@bonprix-ds/utils": "0.4.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/react": "19.3.0",