@okta/odyssey-react-mui 1.7.1 → 1.8.1

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 (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/@types/react-augment.d.js +2 -0
  3. package/dist/@types/react-augment.d.js.map +1 -0
  4. package/dist/Autocomplete.js +32 -23
  5. package/dist/Autocomplete.js.map +1 -1
  6. package/dist/Checkbox.js +33 -18
  7. package/dist/Checkbox.js.map +1 -1
  8. package/dist/NativeSelect.js +22 -8
  9. package/dist/NativeSelect.js.map +1 -1
  10. package/dist/PasswordField.js +19 -5
  11. package/dist/PasswordField.js.map +1 -1
  12. package/dist/RadioGroup.js +11 -8
  13. package/dist/RadioGroup.js.map +1 -1
  14. package/dist/SearchField.js +17 -16
  15. package/dist/SearchField.js.map +1 -1
  16. package/dist/Select.js +34 -18
  17. package/dist/Select.js.map +1 -1
  18. package/dist/TextField.js +20 -6
  19. package/dist/TextField.js.map +1 -1
  20. package/dist/inputUtils.js +46 -0
  21. package/dist/inputUtils.js.map +1 -0
  22. package/dist/labs/VirtualizedAutocomplete.js +29 -23
  23. package/dist/labs/VirtualizedAutocomplete.js.map +1 -1
  24. package/dist/src/Autocomplete.d.ts +0 -1
  25. package/dist/src/Autocomplete.d.ts.map +1 -1
  26. package/dist/src/Checkbox.d.ts +5 -1
  27. package/dist/src/Checkbox.d.ts.map +1 -1
  28. package/dist/src/NativeSelect.d.ts +19 -44
  29. package/dist/src/NativeSelect.d.ts.map +1 -1
  30. package/dist/src/PasswordField.d.ts +10 -2
  31. package/dist/src/PasswordField.d.ts.map +1 -1
  32. package/dist/src/RadioGroup.d.ts.map +1 -1
  33. package/dist/src/SearchField.d.ts +10 -2
  34. package/dist/src/SearchField.d.ts.map +1 -1
  35. package/dist/src/Select.d.ts +5 -1
  36. package/dist/src/Select.d.ts.map +1 -1
  37. package/dist/src/TextField.d.ts +8 -0
  38. package/dist/src/TextField.d.ts.map +1 -1
  39. package/dist/src/inputUtils.d.ts +47 -0
  40. package/dist/src/inputUtils.d.ts.map +1 -0
  41. package/dist/src/labs/VirtualizedAutocomplete.d.ts.map +1 -1
  42. package/dist/tsconfig.production.tsbuildinfo +1 -1
  43. package/package.json +3 -3
  44. package/src/@types/react-augment.d.ts +19 -0
  45. package/src/Autocomplete.tsx +49 -43
  46. package/src/Checkbox.tsx +41 -22
  47. package/src/NativeSelect.tsx +78 -25
  48. package/src/PasswordField.tsx +32 -4
  49. package/src/RadioGroup.tsx +12 -10
  50. package/src/SearchField.tsx +24 -18
  51. package/src/Select.tsx +43 -25
  52. package/src/TextField.tsx +33 -5
  53. package/src/inputUtils.ts +76 -0
  54. package/src/labs/VirtualizedAutocomplete.tsx +48 -42
  55. package/dist/src/useControlledState.d.ts +0 -28
  56. package/dist/src/useControlledState.d.ts.map +0 -1
  57. package/dist/useControlledState.js +0 -33
  58. package/dist/useControlledState.js.map +0 -1
  59. package/src/useControlledState.ts +0 -56
@@ -1,56 +0,0 @@
1
- /*!
2
- * Copyright (c) 2023-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 { useEffect, useRef, useState } from "react";
14
-
15
- type UseControlledStateProps<Value> = {
16
- controlledValue?: Value; // isChecked
17
- uncontrolledValue?: Value; // isDefaultChecked
18
- };
19
-
20
- /**
21
- * Use the same way as `useState`. Returns a stateful value, and a function to update it.
22
- * When `initialState` is passed, the returned function to update it does nothing. This is
23
- * useful to handle values in components that may be controlled externally when that value is
24
- * passed in props and thus wish to prevent internal updates of the same value.
25
- *
26
- * @param initialState
27
- * @see https://react.dev/reference/react/useState
28
- */
29
- export const useControlledState = <Value>({
30
- controlledValue,
31
- uncontrolledValue,
32
- }: UseControlledStateProps<Value>) => {
33
- const isControlledMode = useRef(controlledValue !== undefined);
34
- const [stateValue, setStateValue] = useState(
35
- isControlledMode.current ? controlledValue : uncontrolledValue
36
- );
37
-
38
- useEffect(() => {
39
- if (isControlledMode.current) {
40
- setStateValue(controlledValue);
41
- }
42
- }, [controlledValue]);
43
-
44
- const setState: typeof setStateValue = (value) => {
45
- if (!isControlledMode.current) {
46
- setStateValue(value);
47
- }
48
- };
49
-
50
- return [
51
- stateValue,
52
- // If `value` is controlled externally, ignore calls to the setter.
53
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
54
- setState,
55
- ] as const;
56
- };