@okta/odyssey-react-mui 0.21.4 → 0.22.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.
Files changed (135) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/Autocomplete.js +58 -0
  3. package/dist/Autocomplete.js.map +1 -0
  4. package/dist/Button.js +46 -0
  5. package/dist/Button.js.map +1 -0
  6. package/dist/Field.js +59 -0
  7. package/dist/Field.js.map +1 -0
  8. package/dist/FieldError.js +34 -0
  9. package/dist/FieldError.js.map +1 -0
  10. package/dist/FieldHint.js +29 -0
  11. package/dist/FieldHint.js.map +1 -0
  12. package/dist/FieldLabel.js +32 -0
  13. package/dist/FieldLabel.js.map +1 -0
  14. package/dist/MenuButton.js +2 -2
  15. package/dist/MenuButton.js.map +1 -1
  16. package/dist/MenuItem.js +0 -1
  17. package/dist/MenuItem.js.map +1 -1
  18. package/dist/PasswordField.js +68 -0
  19. package/dist/PasswordField.js.map +1 -0
  20. package/dist/SearchField.js +54 -0
  21. package/dist/SearchField.js.map +1 -0
  22. package/dist/Tag.js +28 -0
  23. package/dist/Tag.js.map +1 -0
  24. package/dist/TagList.js +26 -0
  25. package/dist/TagList.js.map +1 -0
  26. package/dist/TagListContext.js +16 -0
  27. package/dist/TagListContext.js.map +1 -0
  28. package/dist/TextField.js +26 -61
  29. package/dist/TextField.js.map +1 -1
  30. package/dist/index.js +10 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/src/Autocomplete.d.ts +27 -0
  33. package/dist/src/Autocomplete.d.ts.map +1 -0
  34. package/dist/src/Button.d.ts +31 -0
  35. package/dist/src/Button.d.ts.map +1 -0
  36. package/dist/src/Field.d.ts +54 -0
  37. package/dist/src/Field.d.ts.map +1 -0
  38. package/dist/src/FieldError.d.ts +19 -0
  39. package/dist/src/FieldError.d.ts.map +1 -0
  40. package/dist/src/FieldHint.d.ts +19 -0
  41. package/dist/src/FieldHint.d.ts.map +1 -0
  42. package/dist/src/FieldLabel.d.ts +23 -0
  43. package/dist/src/FieldLabel.d.ts.map +1 -0
  44. package/dist/src/Icon.d.ts +1 -1
  45. package/dist/src/Link.d.ts +1 -1
  46. package/dist/src/MenuButton.d.ts.map +1 -1
  47. package/dist/src/MenuItem.d.ts +1 -1
  48. package/dist/src/MenuItem.d.ts.map +1 -1
  49. package/dist/src/PasswordField.d.ts +75 -0
  50. package/dist/src/PasswordField.d.ts.map +1 -0
  51. package/dist/src/SearchField.d.ts +59 -0
  52. package/dist/src/SearchField.d.ts.map +1 -0
  53. package/dist/src/Tag.d.ts +22 -0
  54. package/dist/src/Tag.d.ts.map +1 -0
  55. package/dist/src/TagList.d.ts +19 -0
  56. package/dist/src/TagList.d.ts.map +1 -0
  57. package/dist/src/TagListContext.d.ts +18 -0
  58. package/dist/src/TagListContext.d.ts.map +1 -0
  59. package/dist/src/TextField.d.ts +3 -8
  60. package/dist/src/TextField.d.ts.map +1 -1
  61. package/dist/src/iconDictionary/Add.d.ts +1 -1
  62. package/dist/src/iconDictionary/AddCircle.d.ts +1 -1
  63. package/dist/src/iconDictionary/AlertCircle.d.ts +1 -1
  64. package/dist/src/iconDictionary/AlertCircleFilled.d.ts +1 -1
  65. package/dist/src/iconDictionary/AlertTriangleFilled.d.ts +1 -1
  66. package/dist/src/iconDictionary/Anchor.d.ts +1 -1
  67. package/dist/src/iconDictionary/ArrowDown.d.ts +1 -1
  68. package/dist/src/iconDictionary/ArrowLeft.d.ts +1 -1
  69. package/dist/src/iconDictionary/ArrowRight.d.ts +1 -1
  70. package/dist/src/iconDictionary/ArrowUp.d.ts +1 -1
  71. package/dist/src/iconDictionary/ArrowUpDown.d.ts +1 -1
  72. package/dist/src/iconDictionary/Calendar.d.ts +1 -1
  73. package/dist/src/iconDictionary/Check.d.ts +1 -1
  74. package/dist/src/iconDictionary/CheckCircleFilled.d.ts +1 -1
  75. package/dist/src/iconDictionary/ChevronDown.d.ts +1 -1
  76. package/dist/src/iconDictionary/ChevronUp.d.ts +1 -1
  77. package/dist/src/iconDictionary/Close.d.ts +1 -1
  78. package/dist/src/iconDictionary/CloseCircleFilled.d.ts +1 -1
  79. package/dist/src/iconDictionary/Copy.d.ts +1 -1
  80. package/dist/src/iconDictionary/Delete.d.ts +1 -1
  81. package/dist/src/iconDictionary/Download.d.ts +1 -1
  82. package/dist/src/iconDictionary/DragHandle.d.ts +1 -1
  83. package/dist/src/iconDictionary/Edit.d.ts +1 -1
  84. package/dist/src/iconDictionary/ExternalLink.d.ts +1 -1
  85. package/dist/src/iconDictionary/Eye.d.ts +1 -1
  86. package/dist/src/iconDictionary/EyeOff.d.ts +1 -1
  87. package/dist/src/iconDictionary/Filter.d.ts +1 -1
  88. package/dist/src/iconDictionary/Globe.d.ts +1 -1
  89. package/dist/src/iconDictionary/Home.d.ts +1 -1
  90. package/dist/src/iconDictionary/InformationCircle.d.ts +1 -1
  91. package/dist/src/iconDictionary/InformationCircleFilled.d.ts +1 -1
  92. package/dist/src/iconDictionary/Notification.d.ts +1 -1
  93. package/dist/src/iconDictionary/OverflowVertical.d.ts +1 -1
  94. package/dist/src/iconDictionary/QuestionCircle.d.ts +1 -1
  95. package/dist/src/iconDictionary/QuestionCircleFilled.d.ts +1 -1
  96. package/dist/src/iconDictionary/Search.d.ts +1 -1
  97. package/dist/src/iconDictionary/Settings.d.ts +1 -1
  98. package/dist/src/iconDictionary/Subtract.d.ts +1 -1
  99. package/dist/src/iconDictionary/User.d.ts +1 -1
  100. package/dist/src/iconDictionary/UserGroup.d.ts +1 -1
  101. package/dist/src/iconDictionary/index.d.ts +40 -40
  102. package/dist/src/index.d.ts +11 -3
  103. package/dist/src/index.d.ts.map +1 -1
  104. package/dist/src/theme/components.d.ts.map +1 -1
  105. package/dist/src/theme/components.types.d.ts +0 -8
  106. package/dist/src/theme/components.types.d.ts.map +1 -1
  107. package/dist/theme/components.js +217 -124
  108. package/dist/theme/components.js.map +1 -1
  109. package/dist/theme/components.types.js.map +1 -1
  110. package/dist/tsconfig.production.tsbuildinfo +1 -1
  111. package/package.json +3 -3
  112. package/src/Autocomplete.tsx +132 -0
  113. package/src/Button.tsx +75 -0
  114. package/src/Field.tsx +112 -0
  115. package/src/FieldError.tsx +34 -0
  116. package/src/FieldHint.tsx +28 -0
  117. package/src/FieldLabel.tsx +57 -0
  118. package/src/MenuButton.tsx +2 -3
  119. package/src/MenuItem.tsx +0 -1
  120. package/src/OdysseyCacheProvider.test.tsx +1 -1
  121. package/src/PasswordField.tsx +174 -0
  122. package/src/SearchField.tsx +136 -0
  123. package/src/Tag.tsx +41 -0
  124. package/src/TagList.tsx +43 -0
  125. package/src/TagListContext.tsx +23 -0
  126. package/src/TextField.tsx +43 -101
  127. package/src/index.ts +9 -3
  128. package/src/theme/components.tsx +87 -18
  129. package/src/theme/components.types.ts +0 -8
  130. package/dist/PasswordInput.js +0 -87
  131. package/dist/PasswordInput.js.map +0 -1
  132. package/dist/src/PasswordInput.d.ts +0 -21
  133. package/dist/src/PasswordInput.d.ts.map +0 -1
  134. package/src/PasswordInput.test.tsx +0 -51
  135. package/src/PasswordInput.tsx +0 -111
@@ -1,87 +0,0 @@
1
- import _Box from "@mui/material/Box";
2
- import _OutlinedInput from "@mui/material/OutlinedInput";
3
- import _InputAdornment from "@mui/material/InputAdornment";
4
- import _Tooltip from "@mui/material/Tooltip";
5
- import _IconButton from "@mui/material/IconButton";
6
- import _Visibility from "@mui/icons-material/Visibility";
7
- import _VisibilityOff from "@mui/icons-material/VisibilityOff";
8
- import _InputLabel from "@mui/material/InputLabel";
9
-
10
- /*!
11
- * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
12
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
13
- *
14
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- *
19
- * See the License for the specific language governing permissions and limitations under the License.
20
- */
21
- import { forwardRef, useState, useMemo } from "react";
22
- import { useUniqueId } from "./useUniqueId.js";
23
- import { jsx as _jsx } from "react/jsx-runtime";
24
- import { jsxs as _jsxs } from "react/jsx-runtime";
25
- export const PasswordInput = forwardRef((props, ref) => {
26
- const {
27
- tooltipLabel,
28
- id,
29
- label,
30
- defaultValue: password = "",
31
- inputProps,
32
- ...rest
33
- } = props;
34
- const [values, setValues] = useState({
35
- password,
36
- showPassword: false
37
- });
38
-
39
- const handlePasswordChange = event => {
40
- setValues({ ...values,
41
- password: event.target.value
42
- });
43
- props.onChange?.(event);
44
- };
45
-
46
- const handleClickShowPassword = () => {
47
- setValues({ ...values,
48
- showPassword: !values.showPassword
49
- });
50
- };
51
-
52
- const handleMouseDownPassword = event => {
53
- event.preventDefault();
54
- };
55
-
56
- const tooltipTitle = useMemo(() => {
57
- return typeof tooltipLabel === "function" ? tooltipLabel(values.showPassword === false) : tooltipLabel;
58
- }, [values, tooltipLabel]);
59
- const uniqueId = useUniqueId(id);
60
- return _jsxs(_Box, {
61
- children: [_jsx(_InputLabel, {
62
- htmlFor: uniqueId,
63
- children: label
64
- }), _jsx(_OutlinedInput, { ...rest,
65
- id: uniqueId,
66
- inputProps: inputProps,
67
- inputRef: ref,
68
- onChange: handlePasswordChange,
69
- type: values.showPassword ? "text" : "password",
70
- value: values.password,
71
- endAdornment: _jsx(_InputAdornment, {
72
- position: "end",
73
- children: _jsx(_Tooltip, {
74
- title: tooltipTitle,
75
- children: _jsx(_IconButton, {
76
- "aria-label": "toggle password visibility",
77
- onClick: handleClickShowPassword,
78
- onMouseDown: handleMouseDownPassword,
79
- edge: "end",
80
- children: values.showPassword ? _jsx(_VisibilityOff, {}) : _jsx(_Visibility, {})
81
- })
82
- })
83
- })
84
- })]
85
- });
86
- });
87
- //# sourceMappingURL=PasswordInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PasswordInput.js","names":["forwardRef","useState","useMemo","useUniqueId","PasswordInput","props","ref","tooltipLabel","id","label","defaultValue","password","inputProps","rest","values","setValues","showPassword","handlePasswordChange","event","target","value","onChange","handleClickShowPassword","handleMouseDownPassword","preventDefault","tooltipTitle","uniqueId"],"sources":["../src/PasswordInput.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { forwardRef, useState, useMemo } from \"react\";\nimport type { Ref, ChangeEvent, MouseEvent } from \"react\";\nimport type { OutlinedInputProps, TooltipProps } from \"@mui/material\";\nimport {\n Tooltip,\n IconButton,\n Box,\n InputLabel,\n OutlinedInput,\n InputAdornment,\n} from \"@mui/material\";\nimport { Visibility, VisibilityOff } from \"@mui/icons-material\";\nimport { useUniqueId } from \"./useUniqueId\";\n\ninterface State {\n password: string;\n showPassword: boolean;\n}\n\nexport interface PasswordInputProps\n extends Omit<OutlinedInputProps, \"type\" | \"label\" | \"defaultValue\" | \"ref\"> {\n ref?: Ref<HTMLInputElement>;\n defaultValue?: string;\n label: string;\n tooltipLabel?:\n | TooltipProps[\"title\"]\n | ((isHidden: boolean) => TooltipProps[\"title\"]);\n}\n\nexport const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\n (props, ref) => {\n const {\n tooltipLabel,\n id,\n label,\n defaultValue: password = \"\",\n inputProps,\n ...rest\n } = props;\n\n const [values, setValues] = useState<State>({\n password,\n showPassword: false,\n });\n\n const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {\n setValues({ ...values, password: event.target.value });\n props.onChange?.(event);\n };\n\n const handleClickShowPassword = () => {\n setValues({\n ...values,\n showPassword: !values.showPassword,\n });\n };\n\n const handleMouseDownPassword = (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n };\n\n const tooltipTitle = useMemo(() => {\n return typeof tooltipLabel === \"function\"\n ? tooltipLabel(values.showPassword === false)\n : tooltipLabel;\n }, [values, tooltipLabel]);\n\n const uniqueId = useUniqueId(id);\n\n return (\n <Box>\n <InputLabel htmlFor={uniqueId}>{label}</InputLabel>\n <OutlinedInput\n {...rest}\n id={uniqueId}\n inputProps={inputProps}\n inputRef={ref}\n onChange={handlePasswordChange}\n type={values.showPassword ? \"text\" : \"password\"}\n value={values.password}\n endAdornment={\n <InputAdornment position=\"end\">\n <Tooltip title={tooltipTitle}>\n <IconButton\n aria-label=\"toggle password visibility\"\n onClick={handleClickShowPassword}\n onMouseDown={handleMouseDownPassword}\n edge=\"end\"\n >\n {values.showPassword ? <VisibilityOff /> : <Visibility />}\n </IconButton>\n </Tooltip>\n </InputAdornment>\n }\n />\n </Box>\n );\n }\n);\n"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,OAA/B,QAA8C,OAA9C;SAYSC,W;;;AAiBT,OAAO,MAAMC,aAAa,GAAGJ,UAAU,CACrC,CAACK,KAAD,EAAQC,GAAR,KAAgB;EACd,MAAM;IACJC,YADI;IAEJC,EAFI;IAGJC,KAHI;IAIJC,YAAY,EAAEC,QAAQ,GAAG,EAJrB;IAKJC,UALI;IAMJ,GAAGC;EANC,IAOFR,KAPJ;EASA,MAAM,CAACS,MAAD,EAASC,SAAT,IAAsBd,QAAQ,CAAQ;IAC1CU,QAD0C;IAE1CK,YAAY,EAAE;EAF4B,CAAR,CAApC;;EAKA,MAAMC,oBAAoB,GAAIC,KAAD,IAA0C;IACrEH,SAAS,CAAC,EAAE,GAAGD,MAAL;MAAaH,QAAQ,EAAEO,KAAK,CAACC,MAAN,CAAaC;IAApC,CAAD,CAAT;IACAf,KAAK,CAACgB,QAAN,GAAiBH,KAAjB;EACD,CAHD;;EAKA,MAAMI,uBAAuB,GAAG,MAAM;IACpCP,SAAS,CAAC,EACR,GAAGD,MADK;MAERE,YAAY,EAAE,CAACF,MAAM,CAACE;IAFd,CAAD,CAAT;EAID,CALD;;EAOA,MAAMO,uBAAuB,GAAIL,KAAD,IAA0C;IACxEA,KAAK,CAACM,cAAN;EACD,CAFD;;EAIA,MAAMC,YAAY,GAAGvB,OAAO,CAAC,MAAM;IACjC,OAAO,OAAOK,YAAP,KAAwB,UAAxB,GACHA,YAAY,CAACO,MAAM,CAACE,YAAP,KAAwB,KAAzB,CADT,GAEHT,YAFJ;EAGD,CAJ2B,EAIzB,CAACO,MAAD,EAASP,YAAT,CAJyB,CAA5B;EAMA,MAAMmB,QAAQ,GAAGvB,WAAW,CAACK,EAAD,CAA5B;EAEA,OACE;IAAA,WACE;MAAY,OAAO,EAAEkB,QAArB;MAAA,UAAgCjB;IAAhC,EADF,EAEE,0BACMI,IADN;MAEE,EAAE,EAAEa,QAFN;MAGE,UAAU,EAAEd,UAHd;MAIE,QAAQ,EAAEN,GAJZ;MAKE,QAAQ,EAAEW,oBALZ;MAME,IAAI,EAAEH,MAAM,CAACE,YAAP,GAAsB,MAAtB,GAA+B,UANvC;MAOE,KAAK,EAAEF,MAAM,CAACH,QAPhB;MAQE,YAAY,EACV;QAAgB,QAAQ,EAAC,KAAzB;QAAA,UACE;UAAS,KAAK,EAAEc,YAAhB;UAAA,UACE;YACE,cAAW,4BADb;YAEE,OAAO,EAAEH,uBAFX;YAGE,WAAW,EAAEC,uBAHf;YAIE,IAAI,EAAC,KAJP;YAAA,UAMGT,MAAM,CAACE,YAAP,GAAsB,wBAAtB,GAA0C;UAN7C;QADF;MADF;IATJ,EAFF;EAAA,EADF;AA4BD,CApEoC,CAAhC"}
@@ -1,21 +0,0 @@
1
- /*!
2
- * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- */
12
- import type { Ref } from "react";
13
- import type { OutlinedInputProps, TooltipProps } from "@mui/material";
14
- export interface PasswordInputProps extends Omit<OutlinedInputProps, "type" | "label" | "defaultValue" | "ref"> {
15
- ref?: Ref<HTMLInputElement>;
16
- defaultValue?: string;
17
- label: string;
18
- tooltipLabel?: TooltipProps["title"] | ((isHidden: boolean) => TooltipProps["title"]);
19
- }
20
- export declare const PasswordInput: import("react").ForwardRefExoticComponent<Pick<PasswordInputProps, "label" | "name" | "onChange" | "value" | "classes" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "sx" | "autoFocus" | "inputProps" | "inputRef" | "readOnly" | "required" | "error" | "fullWidth" | "margin" | "size" | "autoComplete" | "rows" | "slotProps" | "slots" | "components" | "componentsProps" | "disableInjectingGlobalStyles" | "endAdornment" | "inputComponent" | "multiline" | "renderSuffix" | "maxRows" | "minRows" | "startAdornment" | "notched" | "tooltipLabel"> & import("react").RefAttributes<HTMLInputElement>>;
21
- //# sourceMappingURL=PasswordInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PasswordInput.d.ts","sourceRoot":"","sources":["../../src/PasswordInput.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,GAAG,EAA2B,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAiBtE,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,KAAK,CAAC;IAC3E,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EACT,YAAY,CAAC,OAAO,CAAC,GACrB,CAAC,CAAC,QAAQ,EAAE,OAAO,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,aAAa,sgKAqEzB,CAAC"}
@@ -1,51 +0,0 @@
1
- /*!
2
- * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- */
12
-
13
- import { render, screen } from "@testing-library/react";
14
-
15
- import { a11yCheck } from "./a11yCheck";
16
- import { PasswordInput } from "./PasswordInput";
17
-
18
- const label = "Password";
19
- const tooltipOnLabel = "Show password";
20
- const tooltipOffLabel = "Hide password";
21
-
22
- describe("PasswordInput", () => {
23
- it("renders into the document", () => {
24
- render(<PasswordInput label={label} tooltipLabel={tooltipOnLabel} />);
25
- expect(screen.getByLabelText(label)).toBeVisible();
26
- });
27
-
28
- it("has a button that changes the type when clicked", () => {
29
- const tooltipLabel = (isHidden: boolean) => {
30
- return isHidden ? tooltipOnLabel : tooltipOffLabel;
31
- };
32
- render(
33
- <PasswordInput
34
- label={label}
35
- tooltipLabel={tooltipLabel}
36
- defaultValue="Imma password"
37
- />
38
- );
39
- const inputElement = screen.getByLabelText(label);
40
- expect(inputElement).toHaveValue("Imma password");
41
- expect(inputElement).toHaveAttribute("type", "password");
42
- const eyeButton = screen.getByRole("button");
43
- expect(eyeButton).toBeInTheDocument();
44
- eyeButton.click();
45
- expect(inputElement).toHaveAttribute("type", "text");
46
- });
47
-
48
- a11yCheck(() =>
49
- render(<PasswordInput label="input label" tooltipLabel="tooltip label" />)
50
- );
51
- });
@@ -1,111 +0,0 @@
1
- /*!
2
- * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
3
- * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
4
- *
5
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
6
- * Unless required by applicable law or agreed to in writing, software
7
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9
- *
10
- * See the License for the specific language governing permissions and limitations under the License.
11
- */
12
-
13
- import { forwardRef, useState, useMemo } from "react";
14
- import type { Ref, ChangeEvent, MouseEvent } from "react";
15
- import type { OutlinedInputProps, TooltipProps } from "@mui/material";
16
- import {
17
- Tooltip,
18
- IconButton,
19
- Box,
20
- InputLabel,
21
- OutlinedInput,
22
- InputAdornment,
23
- } from "@mui/material";
24
- import { Visibility, VisibilityOff } from "@mui/icons-material";
25
- import { useUniqueId } from "./useUniqueId";
26
-
27
- interface State {
28
- password: string;
29
- showPassword: boolean;
30
- }
31
-
32
- export interface PasswordInputProps
33
- extends Omit<OutlinedInputProps, "type" | "label" | "defaultValue" | "ref"> {
34
- ref?: Ref<HTMLInputElement>;
35
- defaultValue?: string;
36
- label: string;
37
- tooltipLabel?:
38
- | TooltipProps["title"]
39
- | ((isHidden: boolean) => TooltipProps["title"]);
40
- }
41
-
42
- export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
43
- (props, ref) => {
44
- const {
45
- tooltipLabel,
46
- id,
47
- label,
48
- defaultValue: password = "",
49
- inputProps,
50
- ...rest
51
- } = props;
52
-
53
- const [values, setValues] = useState<State>({
54
- password,
55
- showPassword: false,
56
- });
57
-
58
- const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
59
- setValues({ ...values, password: event.target.value });
60
- props.onChange?.(event);
61
- };
62
-
63
- const handleClickShowPassword = () => {
64
- setValues({
65
- ...values,
66
- showPassword: !values.showPassword,
67
- });
68
- };
69
-
70
- const handleMouseDownPassword = (event: MouseEvent<HTMLButtonElement>) => {
71
- event.preventDefault();
72
- };
73
-
74
- const tooltipTitle = useMemo(() => {
75
- return typeof tooltipLabel === "function"
76
- ? tooltipLabel(values.showPassword === false)
77
- : tooltipLabel;
78
- }, [values, tooltipLabel]);
79
-
80
- const uniqueId = useUniqueId(id);
81
-
82
- return (
83
- <Box>
84
- <InputLabel htmlFor={uniqueId}>{label}</InputLabel>
85
- <OutlinedInput
86
- {...rest}
87
- id={uniqueId}
88
- inputProps={inputProps}
89
- inputRef={ref}
90
- onChange={handlePasswordChange}
91
- type={values.showPassword ? "text" : "password"}
92
- value={values.password}
93
- endAdornment={
94
- <InputAdornment position="end">
95
- <Tooltip title={tooltipTitle}>
96
- <IconButton
97
- aria-label="toggle password visibility"
98
- onClick={handleClickShowPassword}
99
- onMouseDown={handleMouseDownPassword}
100
- edge="end"
101
- >
102
- {values.showPassword ? <VisibilityOff /> : <Visibility />}
103
- </IconButton>
104
- </Tooltip>
105
- </InputAdornment>
106
- }
107
- />
108
- </Box>
109
- );
110
- }
111
- );