@okta/odyssey-react-mui 1.35.0 → 1.35.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.
Files changed (145) hide show
  1. package/dist/cjs/DatePickers/useOdysseyDateFields.cjs +2 -2
  2. package/dist/cjs/DatePickers/useOdysseyDateFields.cjs.map +1 -1
  3. package/dist/cjs/Field.cjs +1 -1
  4. package/dist/cjs/Field.cjs.map +1 -1
  5. package/dist/cjs/Pagination/Pagination.cjs +0 -6
  6. package/dist/cjs/Pagination/Pagination.cjs.map +1 -1
  7. package/dist/cjs/inputUtils.cjs +1 -1
  8. package/dist/cjs/inputUtils.cjs.map +1 -1
  9. package/dist/cjs/labs/DataFilters.cjs +4 -4
  10. package/dist/cjs/labs/DataFilters.cjs.map +1 -1
  11. package/dist/cjs/labs/DataView/DataCard.cjs +18 -18
  12. package/dist/cjs/labs/DataView/DataCard.cjs.map +1 -1
  13. package/dist/cjs/labs/DataView/DataView.cjs +10 -10
  14. package/dist/cjs/labs/DataView/DataView.cjs.map +1 -1
  15. package/dist/cjs/labs/DataView/TableLayoutContent.cjs +4 -1
  16. package/dist/cjs/labs/DataView/TableLayoutContent.cjs.map +1 -1
  17. package/dist/cjs/labs/DataView/useFilterConversion.cjs +1 -1
  18. package/dist/cjs/labs/DataView/useFilterConversion.cjs.map +1 -1
  19. package/dist/cjs/theme/StringWithValue.cjs +6 -0
  20. package/dist/cjs/theme/StringWithValue.cjs.map +1 -0
  21. package/dist/cjs/theme/components.cjs +2590 -2592
  22. package/dist/cjs/theme/components.cjs.map +1 -1
  23. package/dist/cjs/theme/useMediaQuery.cjs +4 -4
  24. package/dist/cjs/theme/useMediaQuery.cjs.map +1 -1
  25. package/dist/cjs/ui-shell/InnerAppContainer.cjs +60 -0
  26. package/dist/cjs/ui-shell/InnerAppContainer.cjs.map +1 -0
  27. package/dist/cjs/ui-shell/NarrowUiShellContent.cjs +6 -1
  28. package/dist/cjs/ui-shell/NarrowUiShellContent.cjs.map +1 -1
  29. package/dist/cjs/ui-shell/SideNav/SideNav.cjs +79 -48
  30. package/dist/cjs/ui-shell/SideNav/SideNav.cjs.map +1 -1
  31. package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs +84 -112
  32. package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs.map +1 -1
  33. package/dist/cjs/ui-shell/TopNav/TopNav.cjs +1 -6
  34. package/dist/cjs/ui-shell/TopNav/TopNav.cjs.map +1 -1
  35. package/dist/cjs/ui-shell/UiShell.cjs +6 -5
  36. package/dist/cjs/ui-shell/UiShell.cjs.map +1 -1
  37. package/dist/cjs/ui-shell/WideUiShellContent.cjs +10 -4
  38. package/dist/cjs/ui-shell/WideUiShellContent.cjs.map +1 -1
  39. package/dist/cjs/ui-shell/index.cjs +29 -9
  40. package/dist/cjs/ui-shell/index.cjs.map +1 -1
  41. package/dist/cjs/ui-shell/renderUiShell.cjs +2 -0
  42. package/dist/cjs/ui-shell/renderUiShell.cjs.map +1 -1
  43. package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs +3 -2
  44. package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs.map +1 -1
  45. package/dist/cjs/ui-shell/useScrollState.cjs +71 -21
  46. package/dist/cjs/ui-shell/useScrollState.cjs.map +1 -1
  47. package/dist/cjs/ui-shell/useUiShellBreakpoints.cjs +20 -15
  48. package/dist/cjs/ui-shell/useUiShellBreakpoints.cjs.map +1 -1
  49. package/dist/cjs/web-component/createReactRootElements.cjs +5 -3
  50. package/dist/cjs/web-component/createReactRootElements.cjs.map +1 -1
  51. package/dist/cjs/web-component/renderReactInWebComponent.cjs +21 -7
  52. package/dist/cjs/web-component/renderReactInWebComponent.cjs.map +1 -1
  53. package/dist/esm/DatePickers/useOdysseyDateFields.js +2 -2
  54. package/dist/esm/DatePickers/useOdysseyDateFields.js.map +1 -1
  55. package/dist/esm/Field.js +1 -1
  56. package/dist/esm/Field.js.map +1 -1
  57. package/dist/esm/Pagination/Pagination.js +0 -6
  58. package/dist/esm/Pagination/Pagination.js.map +1 -1
  59. package/dist/esm/inputUtils.js +1 -1
  60. package/dist/esm/inputUtils.js.map +1 -1
  61. package/dist/esm/labs/DataFilters.js +4 -4
  62. package/dist/esm/labs/DataFilters.js.map +1 -1
  63. package/dist/esm/labs/DataView/DataCard.js +18 -18
  64. package/dist/esm/labs/DataView/DataCard.js.map +1 -1
  65. package/dist/esm/labs/DataView/DataView.js +10 -10
  66. package/dist/esm/labs/DataView/DataView.js.map +1 -1
  67. package/dist/esm/labs/DataView/TableLayoutContent.js +4 -1
  68. package/dist/esm/labs/DataView/TableLayoutContent.js.map +1 -1
  69. package/dist/esm/labs/DataView/useFilterConversion.js +1 -1
  70. package/dist/esm/labs/DataView/useFilterConversion.js.map +1 -1
  71. package/dist/esm/theme/StringWithValue.js +2 -0
  72. package/dist/esm/theme/StringWithValue.js.map +1 -0
  73. package/dist/esm/theme/components.js +2607 -2609
  74. package/dist/esm/theme/components.js.map +1 -1
  75. package/dist/esm/theme/useMediaQuery.js +5 -5
  76. package/dist/esm/theme/useMediaQuery.js.map +1 -1
  77. package/dist/esm/ui-shell/InnerAppContainer.js +56 -0
  78. package/dist/esm/ui-shell/InnerAppContainer.js.map +1 -0
  79. package/dist/esm/ui-shell/NarrowUiShellContent.js +6 -1
  80. package/dist/esm/ui-shell/NarrowUiShellContent.js.map +1 -1
  81. package/dist/esm/ui-shell/SideNav/SideNav.js +80 -49
  82. package/dist/esm/ui-shell/SideNav/SideNav.js.map +1 -1
  83. package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js +85 -113
  84. package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js.map +1 -1
  85. package/dist/esm/ui-shell/TopNav/TopNav.js +1 -6
  86. package/dist/esm/ui-shell/TopNav/TopNav.js.map +1 -1
  87. package/dist/esm/ui-shell/UiShell.js +6 -5
  88. package/dist/esm/ui-shell/UiShell.js.map +1 -1
  89. package/dist/esm/ui-shell/WideUiShellContent.js +10 -4
  90. package/dist/esm/ui-shell/WideUiShellContent.js.map +1 -1
  91. package/dist/esm/ui-shell/index.js +3 -1
  92. package/dist/esm/ui-shell/index.js.map +1 -1
  93. package/dist/esm/ui-shell/renderUiShell.js +2 -0
  94. package/dist/esm/ui-shell/renderUiShell.js.map +1 -1
  95. package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js +3 -2
  96. package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js.map +1 -1
  97. package/dist/esm/ui-shell/useScrollState.js +67 -21
  98. package/dist/esm/ui-shell/useScrollState.js.map +1 -1
  99. package/dist/esm/ui-shell/useUiShellBreakpoints.js +19 -14
  100. package/dist/esm/ui-shell/useUiShellBreakpoints.js.map +1 -1
  101. package/dist/esm/web-component/createReactRootElements.js +4 -2
  102. package/dist/esm/web-component/createReactRootElements.js.map +1 -1
  103. package/dist/esm/web-component/renderReactInWebComponent.js +19 -5
  104. package/dist/esm/web-component/renderReactInWebComponent.js.map +1 -1
  105. package/dist/index.cjs +1 -1
  106. package/dist/index.mjs +1 -1
  107. package/dist/index.scss +1 -1
  108. package/dist/tsconfig.production.tsbuildinfo +1 -1
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/dist/types/DatePickers/useOdysseyDateFields.d.ts.map +1 -1
  111. package/dist/types/Pagination/Pagination.d.ts.map +1 -1
  112. package/dist/types/labs/DataView/DataCard.d.ts.map +1 -1
  113. package/dist/types/labs/DataView/DataView.d.ts.map +1 -1
  114. package/dist/types/labs/DataView/TableLayoutContent.d.ts.map +1 -1
  115. package/dist/types/theme/StringWithValue.d.ts +13 -0
  116. package/dist/types/theme/StringWithValue.d.ts.map +1 -0
  117. package/dist/types/theme/components.d.ts.map +1 -1
  118. package/dist/types/theme/useMediaQuery.d.ts +2 -1
  119. package/dist/types/theme/useMediaQuery.d.ts.map +1 -1
  120. package/dist/types/ui-shell/InnerAppContainer.d.ts +35 -0
  121. package/dist/types/ui-shell/InnerAppContainer.d.ts.map +1 -0
  122. package/dist/types/ui-shell/NarrowUiShellContent.d.ts.map +1 -1
  123. package/dist/types/ui-shell/SideNav/SideNav.d.ts +2 -0
  124. package/dist/types/ui-shell/SideNav/SideNav.d.ts.map +1 -1
  125. package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts +15 -8
  126. package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts.map +1 -1
  127. package/dist/types/ui-shell/TopNav/TopNav.d.ts +1 -1
  128. package/dist/types/ui-shell/TopNav/TopNav.d.ts.map +1 -1
  129. package/dist/types/ui-shell/UiShell.d.ts +8 -1
  130. package/dist/types/ui-shell/UiShell.d.ts.map +1 -1
  131. package/dist/types/ui-shell/WideUiShellContent.d.ts.map +1 -1
  132. package/dist/types/ui-shell/index.d.ts +3 -1
  133. package/dist/types/ui-shell/index.d.ts.map +1 -1
  134. package/dist/types/ui-shell/renderUiShell.d.ts +2 -2
  135. package/dist/types/ui-shell/renderUiShell.d.ts.map +1 -1
  136. package/dist/types/ui-shell/useMatchAppElementToUiShellAppArea.d.ts.map +1 -1
  137. package/dist/types/ui-shell/useScrollState.d.ts +9 -1
  138. package/dist/types/ui-shell/useScrollState.d.ts.map +1 -1
  139. package/dist/types/ui-shell/useUiShellBreakpoints.d.ts +15 -5
  140. package/dist/types/ui-shell/useUiShellBreakpoints.d.ts.map +1 -1
  141. package/dist/types/web-component/createReactRootElements.d.ts +2 -0
  142. package/dist/types/web-component/createReactRootElements.d.ts.map +1 -1
  143. package/dist/types/web-component/renderReactInWebComponent.d.ts +1 -1
  144. package/dist/types/web-component/renderReactInWebComponent.d.ts.map +1 -1
  145. package/package.json +17 -14
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useScrollState = void 0;
6
+ exports.useScrollState = exports.getNestedScrollContainers = exports.getIsYAxisScrolling = exports.getIsYAxisScrollContainer = exports.getIsScrollHeightElement = exports.fakeDefaultContainerElement = void 0;
7
7
  var _react = require("react");
8
8
  /*!
9
9
  * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.
@@ -17,29 +17,79 @@ var _react = require("react");
17
17
  * See the License for the specific language governing permissions and limitations under the License.
18
18
  */
19
19
 
20
- const useScrollState = scrollableContentElement => {
21
- const [isContentScrolled, setIsContentScrolled] = (0, _react.useState)(false);
22
- const scrollableElement = (0, _react.useMemo)(() => scrollableContentElement, [scrollableContentElement]);
23
- (0, _react.useEffect)(() => {
24
- if (scrollableElement) {
25
- let requestedAnimationFrameId;
26
- const updateScrollState = () => {
27
- cancelAnimationFrame(requestedAnimationFrameId);
28
- requestedAnimationFrameId = requestAnimationFrame(() => {
29
- setIsContentScrolled(scrollableElement.scrollTop > 0);
30
- });
31
- };
20
+ const getIsScrollHeightElement = ({
21
+ containerElement,
22
+ scrollableElement
23
+ }) => {
24
+ const containerElementHeight = containerElement.getBoundingClientRect().height;
25
+ const scrollableElementHeight = scrollableElement.getBoundingClientRect().height;
26
+ return scrollableElementHeight - containerElementHeight >= 0;
27
+ };
28
+ exports.getIsScrollHeightElement = getIsScrollHeightElement;
29
+ const getIsYAxisScrollContainer = element => {
30
+ const overflowY = window.getComputedStyle(element).overflowY;
31
+ return overflowY === "auto" || overflowY === "scroll";
32
+ };
33
+ exports.getIsYAxisScrollContainer = getIsYAxisScrollContainer;
34
+ const getIsYAxisScrolling = element => element.scrollHeight > element.clientHeight ? getIsYAxisScrollContainer(element) : false;
35
+ exports.getIsYAxisScrolling = getIsYAxisScrolling;
36
+ const getNestedScrollContainers = containerElement => Array.from(containerElement.querySelectorAll("*")).filter(element => getIsYAxisScrollContainer(element)).filter(scrollableElement => getIsScrollHeightElement({
37
+ containerElement,
38
+ scrollableElement
39
+ }));
40
+ exports.getNestedScrollContainers = getNestedScrollContainers;
41
+ const fakeDefaultContainerElement = exports.fakeDefaultContainerElement = document.createElement("div");
42
+ const useScrollState = containerElement => {
43
+ const [isScrolled, setIsScrolled] = (0, _react.useState)(false);
44
+ const requestedAnimationFrameIdRef = (0, _react.useRef)(0);
45
+ const scrollableElementsRef = (0, _react.useRef)([]);
46
+ const updateScrollState = (0, _react.useCallback)(() => {
47
+ cancelAnimationFrame(requestedAnimationFrameIdRef.current);
48
+ requestedAnimationFrameIdRef.current = requestAnimationFrame(() => {
49
+ setIsScrolled(scrollableElementsRef.current.reduce((isScrolled, scrollableElement) => isScrolled || scrollableElement.scrollTop > 0, false));
50
+ });
51
+ }, []);
52
+ const addScrollEventListeners = (0, _react.useCallback)(() => {
53
+ scrollableElementsRef.current.forEach(scrollableElement => {
32
54
  scrollableElement.addEventListener("scroll", updateScrollState);
33
- updateScrollState();
34
- return () => {
35
- scrollableElement.removeEventListener("scroll", updateScrollState);
36
- cancelAnimationFrame(requestedAnimationFrameId);
37
- };
55
+ });
56
+ }, [updateScrollState]);
57
+ const removeScrollEventListeners = (0, _react.useCallback)(() => {
58
+ scrollableElementsRef.current.forEach(scrollableElement => {
59
+ scrollableElement.removeEventListener("scroll", updateScrollState);
60
+ });
61
+ }, [updateScrollState]);
62
+ const updateScrollableElements = (0, _react.useCallback)(() => {
63
+ const computedContainerElement = containerElement || fakeDefaultContainerElement;
64
+ scrollableElementsRef.current = getNestedScrollContainers(computedContainerElement).concat(computedContainerElement);
65
+ }, [containerElement]);
66
+ const updateScrollListeners = (0, _react.useCallback)(() => {
67
+ removeScrollEventListeners();
68
+ updateScrollableElements();
69
+ addScrollEventListeners();
70
+ updateScrollState();
71
+ }, [addScrollEventListeners, removeScrollEventListeners, updateScrollableElements, updateScrollState]);
72
+ (0, _react.useEffect)(() => {
73
+ const mutationObserver = new MutationObserver(() => {
74
+ updateScrollListeners();
75
+ });
76
+ if (containerElement) {
77
+ mutationObserver.observe(containerElement, {
78
+ attributes: true,
79
+ attributeFilter: ["style"],
80
+ childList: true,
81
+ subtree: true
82
+ });
38
83
  }
39
- return () => {};
40
- }, [scrollableElement]);
84
+ updateScrollListeners();
85
+ return () => {
86
+ cancelAnimationFrame(requestedAnimationFrameIdRef.current);
87
+ removeScrollEventListeners();
88
+ mutationObserver.disconnect();
89
+ };
90
+ }, [containerElement, removeScrollEventListeners, updateScrollListeners]);
41
91
  return {
42
- isContentScrolled
92
+ isContentScrolled: isScrolled
43
93
  };
44
94
  };
45
95
  exports.useScrollState = useScrollState;
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollState.cjs","names":["_react","require","useScrollState","scrollableContentElement","isContentScrolled","setIsContentScrolled","useState","scrollableElement","useMemo","useEffect","requestedAnimationFrameId","updateScrollState","cancelAnimationFrame","requestAnimationFrame","scrollTop","addEventListener","removeEventListener","exports"],"sources":["../../../src/ui-shell/useScrollState.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { useEffect, useMemo, useState } from \"react\";\n\nexport const useScrollState = <\n ScrollableContentElement extends HTMLElement = HTMLDivElement,\n>(\n scrollableContentElement?: ScrollableContentElement,\n) => {\n const [isContentScrolled, setIsContentScrolled] = useState(false);\n\n const scrollableElement = useMemo(\n () => scrollableContentElement,\n [scrollableContentElement],\n );\n\n useEffect(() => {\n if (scrollableElement) {\n let requestedAnimationFrameId: number;\n\n const updateScrollState = () => {\n cancelAnimationFrame(requestedAnimationFrameId);\n\n requestedAnimationFrameId = requestAnimationFrame(() => {\n setIsContentScrolled(scrollableElement.scrollTop > 0);\n });\n };\n\n scrollableElement.addEventListener(\"scroll\", updateScrollState);\n\n updateScrollState();\n\n return () => {\n scrollableElement.removeEventListener(\"scroll\", updateScrollState);\n\n cancelAnimationFrame(requestedAnimationFrameId);\n };\n }\n\n return () => {};\n }, [scrollableElement]);\n\n return {\n isContentScrolled,\n };\n};\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,MAAMC,cAAc,GAGzBC,wBAAmD,IAChD;EACH,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAEjE,MAAMC,iBAAiB,GAAG,IAAAC,cAAO,EAC/B,MAAML,wBAAwB,EAC9B,CAACA,wBAAwB,CAC3B,CAAC;EAED,IAAAM,gBAAS,EAAC,MAAM;IACd,IAAIF,iBAAiB,EAAE;MACrB,IAAIG,yBAAiC;MAErC,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;QAC9BC,oBAAoB,CAACF,yBAAyB,CAAC;QAE/CA,yBAAyB,GAAGG,qBAAqB,CAAC,MAAM;UACtDR,oBAAoB,CAACE,iBAAiB,CAACO,SAAS,GAAG,CAAC,CAAC;QACvD,CAAC,CAAC;MACJ,CAAC;MAEDP,iBAAiB,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,iBAAiB,CAAC;MAE/DA,iBAAiB,CAAC,CAAC;MAEnB,OAAO,MAAM;QACXJ,iBAAiB,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,iBAAiB,CAAC;QAElEC,oBAAoB,CAACF,yBAAyB,CAAC;MACjD,CAAC;IACH;IAEA,OAAO,MAAM,CAAC,CAAC;EACjB,CAAC,EAAE,CAACH,iBAAiB,CAAC,CAAC;EAEvB,OAAO;IACLH;EACF,CAAC;AACH,CAAC;AAACa,OAAA,CAAAf,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"useScrollState.cjs","names":["_react","require","getIsScrollHeightElement","containerElement","scrollableElement","containerElementHeight","getBoundingClientRect","height","scrollableElementHeight","exports","getIsYAxisScrollContainer","element","overflowY","window","getComputedStyle","getIsYAxisScrolling","scrollHeight","clientHeight","getNestedScrollContainers","Array","from","querySelectorAll","filter","fakeDefaultContainerElement","document","createElement","useScrollState","isScrolled","setIsScrolled","useState","requestedAnimationFrameIdRef","useRef","scrollableElementsRef","updateScrollState","useCallback","cancelAnimationFrame","current","requestAnimationFrame","reduce","scrollTop","addScrollEventListeners","forEach","addEventListener","removeScrollEventListeners","removeEventListener","updateScrollableElements","computedContainerElement","concat","updateScrollListeners","useEffect","mutationObserver","MutationObserver","observe","attributes","attributeFilter","childList","subtree","disconnect","isContentScrolled"],"sources":["../../../src/ui-shell/useScrollState.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { useCallback, useEffect, useRef, useState } from \"react\";\n\nexport const getIsScrollHeightElement = ({\n containerElement,\n scrollableElement,\n}: {\n containerElement: HTMLElement;\n scrollableElement: HTMLElement;\n}) => {\n const containerElementHeight =\n containerElement.getBoundingClientRect().height;\n const scrollableElementHeight =\n scrollableElement.getBoundingClientRect().height;\n\n return scrollableElementHeight - containerElementHeight >= 0;\n};\n\nexport const getIsYAxisScrollContainer = (element: HTMLElement) => {\n const overflowY = window.getComputedStyle(element).overflowY;\n\n return overflowY === \"auto\" || overflowY === \"scroll\";\n};\n\nexport const getIsYAxisScrolling = (element: HTMLElement) =>\n element.scrollHeight > element.clientHeight\n ? getIsYAxisScrollContainer(element)\n : false;\n\nexport const getNestedScrollContainers = (containerElement: HTMLElement) =>\n Array.from(containerElement.querySelectorAll<HTMLElement>(\"*\"))\n .filter((element) => getIsYAxisScrollContainer(element))\n .filter((scrollableElement) =>\n getIsScrollHeightElement({\n containerElement,\n scrollableElement,\n }),\n );\n\nexport const fakeDefaultContainerElement = document.createElement(\"div\");\n\nexport const useScrollState = <\n ContainerElement extends HTMLElement = HTMLDivElement,\n>(\n /**\n * The element containing a scroll area.\n */\n containerElement: ContainerElement | null,\n) => {\n const [isScrolled, setIsScrolled] = useState(false);\n\n const requestedAnimationFrameIdRef = useRef(0);\n const scrollableElementsRef = useRef<HTMLElement[]>([]);\n\n const updateScrollState = useCallback(() => {\n cancelAnimationFrame(requestedAnimationFrameIdRef.current);\n\n requestedAnimationFrameIdRef.current = requestAnimationFrame(() => {\n setIsScrolled(\n scrollableElementsRef.current.reduce(\n (isScrolled, scrollableElement) =>\n isScrolled || scrollableElement.scrollTop > 0,\n false,\n ),\n );\n });\n }, []);\n\n const addScrollEventListeners = useCallback(() => {\n scrollableElementsRef.current.forEach((scrollableElement) => {\n scrollableElement.addEventListener(\"scroll\", updateScrollState);\n });\n }, [updateScrollState]);\n\n const removeScrollEventListeners = useCallback(() => {\n scrollableElementsRef.current.forEach((scrollableElement) => {\n scrollableElement.removeEventListener(\"scroll\", updateScrollState);\n });\n }, [updateScrollState]);\n\n const updateScrollableElements = useCallback(() => {\n const computedContainerElement =\n containerElement || fakeDefaultContainerElement;\n\n scrollableElementsRef.current = getNestedScrollContainers(\n computedContainerElement,\n ).concat(computedContainerElement);\n }, [containerElement]);\n\n const updateScrollListeners = useCallback(() => {\n removeScrollEventListeners();\n updateScrollableElements();\n addScrollEventListeners();\n updateScrollState();\n }, [\n addScrollEventListeners,\n removeScrollEventListeners,\n updateScrollableElements,\n updateScrollState,\n ]);\n\n useEffect(() => {\n const mutationObserver = new MutationObserver(() => {\n updateScrollListeners();\n });\n\n if (containerElement) {\n mutationObserver.observe(containerElement, {\n attributes: true,\n attributeFilter: [\"style\"],\n childList: true,\n subtree: true,\n });\n }\n\n updateScrollListeners();\n\n return () => {\n cancelAnimationFrame(requestedAnimationFrameIdRef.current);\n removeScrollEventListeners();\n mutationObserver.disconnect();\n };\n }, [containerElement, removeScrollEventListeners, updateScrollListeners]);\n\n return {\n isContentScrolled: isScrolled,\n };\n};\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,MAAMC,wBAAwB,GAAGA,CAAC;EACvCC,gBAAgB;EAChBC;AAIF,CAAC,KAAK;EACJ,MAAMC,sBAAsB,GAC1BF,gBAAgB,CAACG,qBAAqB,CAAC,CAAC,CAACC,MAAM;EACjD,MAAMC,uBAAuB,GAC3BJ,iBAAiB,CAACE,qBAAqB,CAAC,CAAC,CAACC,MAAM;EAElD,OAAOC,uBAAuB,GAAGH,sBAAsB,IAAI,CAAC;AAC9D,CAAC;AAACI,OAAA,CAAAP,wBAAA,GAAAA,wBAAA;AAEK,MAAMQ,yBAAyB,GAAIC,OAAoB,IAAK;EACjE,MAAMC,SAAS,GAAGC,MAAM,CAACC,gBAAgB,CAACH,OAAO,CAAC,CAACC,SAAS;EAE5D,OAAOA,SAAS,KAAK,MAAM,IAAIA,SAAS,KAAK,QAAQ;AACvD,CAAC;AAACH,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAEK,MAAMK,mBAAmB,GAAIJ,OAAoB,IACtDA,OAAO,CAACK,YAAY,GAAGL,OAAO,CAACM,YAAY,GACvCP,yBAAyB,CAACC,OAAO,CAAC,GAClC,KAAK;AAACF,OAAA,CAAAM,mBAAA,GAAAA,mBAAA;AAEL,MAAMG,yBAAyB,GAAIf,gBAA6B,IACrEgB,KAAK,CAACC,IAAI,CAACjB,gBAAgB,CAACkB,gBAAgB,CAAc,GAAG,CAAC,CAAC,CAC5DC,MAAM,CAAEX,OAAO,IAAKD,yBAAyB,CAACC,OAAO,CAAC,CAAC,CACvDW,MAAM,CAAElB,iBAAiB,IACxBF,wBAAwB,CAAC;EACvBC,gBAAgB;EAChBC;AAC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B,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useUiShellBreakpoints = exports.uiShellBreakpoint = void 0;
6
+ exports.useUiShellBreakpoints = exports.defaultUiShellBreakpointConfig = exports.adminAppUiShellBreakpoints = void 0;
7
7
  var _useMediaQuery = require("../theme/useMediaQuery.cjs");
8
8
  /*!
9
9
  * Copyright (c) 2025-present, Okta, Inc. and/or its affiliates. All rights reserved.
@@ -17,23 +17,28 @@ var _useMediaQuery = require("../theme/useMediaQuery.cjs");
17
17
  * See the License for the specific language governing permissions and limitations under the License.
18
18
  */
19
19
 
20
- const uiShellBreakpoint = exports.uiShellBreakpoint = {
21
- comfortable: 800,
22
- compact: 600,
23
- constrained: 0
20
+ const defaultUiShellBreakpointConfig = exports.defaultUiShellBreakpointConfig = {
21
+ narrow: 0,
22
+ medium: 600,
23
+ wide: 800
24
24
  };
25
- const useUiShellBreakpoints = () => {
26
- const isConstrainedView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${uiShellBreakpoint.constrained}px)`);
27
- const isCompactView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${uiShellBreakpoint.compact}px)`);
28
- const isComfortableView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${uiShellBreakpoint.comfortable}px)`);
29
- if (isComfortableView) {
30
- return "comfortable";
25
+ const adminAppUiShellBreakpoints = exports.adminAppUiShellBreakpoints = {
26
+ narrow: 0,
27
+ medium: 600,
28
+ wide: 1304
29
+ };
30
+ const useUiShellBreakpoints = (breakpointConfig = defaultUiShellBreakpointConfig) => {
31
+ const isNarrowView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${breakpointConfig.narrow}px)`);
32
+ const isMediumView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${breakpointConfig.medium}px)`);
33
+ const isWideView = (0, _useMediaQuery.useMediaQuery)(`(min-width: ${breakpointConfig.wide}px)`);
34
+ if (isWideView) {
35
+ return "wide";
31
36
  }
32
- if (isCompactView) {
33
- return "compact";
37
+ if (isMediumView) {
38
+ return "medium";
34
39
  }
35
- if (isConstrainedView) {
36
- return "constrained";
40
+ if (isNarrowView) {
41
+ return "narrow";
37
42
  }
38
43
  return "none";
39
44
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useUiShellBreakpoints.cjs","names":["_useMediaQuery","require","uiShellBreakpoint","exports","comfortable","compact","constrained","useUiShellBreakpoints","isConstrainedView","useMediaQuery","isCompactView","isComfortableView"],"sources":["../../../src/ui-shell/useUiShellBreakpoints.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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 { useMediaQuery } from \"../theme/useMediaQuery.js\";\n\nexport const uiShellBreakpoint = {\n comfortable: 800,\n compact: 600,\n constrained: 0,\n} as const;\n\nexport const useUiShellBreakpoints = ():\n | keyof typeof uiShellBreakpoint\n | \"none\" => {\n const isConstrainedView = useMediaQuery(\n `(min-width: ${uiShellBreakpoint.constrained}px)`,\n );\n\n const isCompactView = useMediaQuery(\n `(min-width: ${uiShellBreakpoint.compact}px)`,\n );\n\n const isComfortableView = useMediaQuery(\n `(min-width: ${uiShellBreakpoint.comfortable}px)`,\n );\n\n if (isComfortableView) {\n return \"comfortable\";\n }\n\n if (isCompactView) {\n return \"compact\";\n }\n\n if (isConstrainedView) {\n return \"constrained\";\n }\n\n // For the initial page load as we don't have media queries until the page loads.\n return \"none\";\n};\n"],"mappings":";;;;;;AAYA,IAAAA,cAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,MAAMC,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAC/BE,WAAW,EAAE,GAAG;EAChBC,OAAO,EAAE,GAAG;EACZC,WAAW,EAAE;AACf,CAAU;AAEH,MAAMC,qBAAqB,GAAGA,CAAA,KAEvB;EACZ,MAAMC,iBAAiB,GAAG,IAAAC,4BAAa,EACrC,eAAeP,iBAAiB,CAACI,WAAW,KAC9C,CAAC;EAED,MAAMI,aAAa,GAAG,IAAAD,4BAAa,EACjC,eAAeP,iBAAiB,CAACG,OAAO,KAC1C,CAAC;EAED,MAAMM,iBAAiB,GAAG,IAAAF,4BAAa,EACrC,eAAeP,iBAAiB,CAACE,WAAW,KAC9C,CAAC;EAED,IAAIO,iBAAiB,EAAE;IACrB,OAAO,aAAa;EACtB;EAEA,IAAID,aAAa,EAAE;IACjB,OAAO,SAAS;EAClB;EAEA,IAAIF,iBAAiB,EAAE;IACrB,OAAO,aAAa;EACtB;EAGA,OAAO,MAAM;AACf,CAAC;AAACL,OAAA,CAAAI,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"useUiShellBreakpoints.cjs","names":["_useMediaQuery","require","defaultUiShellBreakpointConfig","exports","narrow","medium","wide","adminAppUiShellBreakpoints","useUiShellBreakpoints","breakpointConfig","isNarrowView","useMediaQuery","isMediumView","isWideView"],"sources":["../../../src/ui-shell/useUiShellBreakpoints.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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 { useMediaQuery } from \"../theme/useMediaQuery.js\";\n\nexport type UiShellBreakpointConfig = {\n narrow: number;\n medium: number;\n wide: number;\n};\n\nexport const defaultUiShellBreakpointConfig = {\n narrow: 0,\n medium: 600,\n wide: 800,\n} as const satisfies UiShellBreakpointConfig;\n\nexport const adminAppUiShellBreakpoints = {\n narrow: 0,\n medium: 600,\n wide: 1304,\n} as const satisfies UiShellBreakpointConfig;\n\nexport const useUiShellBreakpoints = (\n breakpointConfig: UiShellBreakpointConfig = defaultUiShellBreakpointConfig,\n): keyof UiShellBreakpointConfig | \"none\" => {\n const isNarrowView = useMediaQuery(\n `(min-width: ${breakpointConfig.narrow}px)`,\n );\n\n const isMediumView = useMediaQuery(\n `(min-width: ${breakpointConfig.medium}px)`,\n );\n\n const isWideView = useMediaQuery(`(min-width: ${breakpointConfig.wide}px)`);\n\n if (isWideView) {\n return \"wide\";\n }\n\n if (isMediumView) {\n return \"medium\";\n }\n\n if (isNarrowView) {\n return \"narrow\";\n }\n\n // This is a failsafe in case we don't have any media queries on page load or if media queries were improperly defined (no `0` case). With the default breakpoints, it will never be `\"none\"`.\n return \"none\";\n};\n"],"mappings":";;;;;;AAYA,IAAAA,cAAA,GAAAC,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GAAG;EAC5CE,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,GAAG;EACXC,IAAI,EAAE;AACR,CAA4C;AAErC,MAAMC,0BAA0B,GAAAJ,OAAA,CAAAI,0BAAA,GAAG;EACxCH,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,GAAG;EACXC,IAAI,EAAE;AACR,CAA4C;AAErC,MAAME,qBAAqB,GAAGA,CACnCC,gBAAyC,GAAGP,8BAA8B,KAC/B;EAC3C,MAAMQ,YAAY,GAAG,IAAAC,4BAAa,EAChC,eAAeF,gBAAgB,CAACL,MAAM,KACxC,CAAC;EAED,MAAMQ,YAAY,GAAG,IAAAD,4BAAa,EAChC,eAAeF,gBAAgB,CAACJ,MAAM,KACxC,CAAC;EAED,MAAMQ,UAAU,GAAG,IAAAF,4BAAa,EAAC,eAAeF,gBAAgB,CAACH,IAAI,KAAK,CAAC;EAE3E,IAAIO,UAAU,EAAE;IACd,OAAO,MAAM;EACf;EAEA,IAAID,YAAY,EAAE;IAChB,OAAO,QAAQ;EACjB;EAEA,IAAIF,YAAY,EAAE;IAChB,OAAO,QAAQ;EACjB;EAGA,OAAO,MAAM;AACf,CAAC;AAACP,OAAA,CAAAK,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createReactRootElements = void 0;
6
+ exports.stylesRootElementId = exports.createReactRootElements = exports.appRootElementId = void 0;
7
7
  /*!
8
8
  * Copyright (c) 2025-present, Okta, Inc. and/or its affiliates. All rights reserved.
9
9
  * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
@@ -16,12 +16,14 @@ exports.createReactRootElements = void 0;
16
16
  * See the License for the specific language governing permissions and limitations under the License.
17
17
  */
18
18
 
19
+ const appRootElementId = exports.appRootElementId = "app-root";
20
+ const stylesRootElementId = exports.stylesRootElementId = "style-root";
19
21
  const createReactRootElements = () => {
20
22
  const appRootElement = document.createElement("div");
21
23
  const stylesRootElement = document.createElement("div");
22
24
  appRootElement.style.setProperty("height", "inherit");
23
- appRootElement.setAttribute("id", "app-root");
24
- stylesRootElement.setAttribute("id", "style-root");
25
+ appRootElement.setAttribute("id", appRootElementId);
26
+ stylesRootElement.setAttribute("id", stylesRootElementId);
25
27
  stylesRootElement.setAttribute("nonce", window.cspNonce);
26
28
  return {
27
29
  appRootElement,
@@ -1 +1 @@
1
- {"version":3,"file":"createReactRootElements.cjs","names":["createReactRootElements","appRootElement","document","createElement","stylesRootElement","style","setProperty","setAttribute","window","cspNonce","exports"],"sources":["../../../src/web-component/createReactRootElements.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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\nexport type ReactRootElements = {\n /**\n * The element your root React component renders into.\n * React has to render or portal somewhere, and this element can be used for that root element.\n */\n appRootElement: HTMLDivElement;\n /**\n * In React apps, your styles typically go in `document.head`, but you may want to render them somewhere else.\n *\n * Specifically when rendering in a web component, there is no `<head>`, so you have to create a spot for styles to render.\n */\n stylesRootElement: HTMLDivElement | HTMLHeadElement;\n};\n\nexport const createReactRootElements = () => {\n const appRootElement = document.createElement(\"div\");\n const stylesRootElement = document.createElement(\"div\");\n\n // This `div` may cause layout issues unless it inherits the parent's height.\n appRootElement.style.setProperty(\"height\", \"inherit\");\n\n appRootElement.setAttribute(\"id\", \"app-root\");\n stylesRootElement.setAttribute(\"id\", \"style-root\");\n stylesRootElement.setAttribute(\"nonce\", window.cspNonce);\n\n return {\n appRootElement,\n stylesRootElement,\n } satisfies ReactRootElements;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMA,uBAAuB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,cAAc,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EACpD,MAAMC,iBAAiB,GAAGF,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAGvDF,cAAc,CAACI,KAAK,CAACC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC;EAErDL,cAAc,CAACM,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC;EAC7CH,iBAAiB,CAACG,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC;EAClDH,iBAAiB,CAACG,YAAY,CAAC,OAAO,EAAEC,MAAM,CAACC,QAAQ,CAAC;EAExD,OAAO;IACLR,cAAc;IACdG;EACF,CAAC;AACH,CAAC;AAACM,OAAA,CAAAV,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"file":"createReactRootElements.cjs","names":["appRootElementId","exports","stylesRootElementId","createReactRootElements","appRootElement","document","createElement","stylesRootElement","style","setProperty","setAttribute","window","cspNonce"],"sources":["../../../src/web-component/createReactRootElements.ts"],"sourcesContent":["/*!\n * Copyright (c) 2025-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\nexport type ReactRootElements = {\n /**\n * The element your root React component renders into.\n * React has to render or portal somewhere, and this element can be used for that root element.\n */\n appRootElement: HTMLDivElement;\n /**\n * In React apps, your styles typically go in `document.head`, but you may want to render them somewhere else.\n *\n * Specifically when rendering in a web component, there is no `<head>`, so you have to create a spot for styles to render.\n */\n stylesRootElement: HTMLDivElement | HTMLHeadElement;\n};\n\nexport const appRootElementId = \"app-root\";\nexport const stylesRootElementId = \"style-root\";\n\nexport const createReactRootElements = () => {\n const appRootElement = document.createElement(\"div\");\n const stylesRootElement = document.createElement(\"div\");\n\n // This `div` may cause layout issues unless it inherits the parent's height.\n appRootElement.style.setProperty(\"height\", \"inherit\");\n\n appRootElement.setAttribute(\"id\", appRootElementId);\n stylesRootElement.setAttribute(\"id\", stylesRootElementId);\n stylesRootElement.setAttribute(\"nonce\", window.cspNonce);\n\n return {\n appRootElement,\n stylesRootElement,\n } satisfies ReactRootElements;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,UAAU;AACnC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,YAAY;AAExC,MAAMC,uBAAuB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,cAAc,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EACpD,MAAMC,iBAAiB,GAAGF,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAGvDF,cAAc,CAACI,KAAK,CAACC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC;EAErDL,cAAc,CAACM,YAAY,CAAC,IAAI,EAAEV,gBAAgB,CAAC;EACnDO,iBAAiB,CAACG,YAAY,CAAC,IAAI,EAAER,mBAAmB,CAAC;EACzDK,iBAAiB,CAACG,YAAY,CAAC,OAAO,EAAEC,MAAM,CAACC,QAAQ,CAAC;EAExD,OAAO;IACLR,cAAc;IACdG;EACF,CAAC;AACH,CAAC;AAACN,OAAA,CAAAE,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -40,6 +40,7 @@ function __transformExtension(filepath, extMapping) {
40
40
  const reactWebComponentElementName = exports.reactWebComponentElementName = "odyssey-react-web-component";
41
41
  const SsrFriendlyHtmlElementClass = "HTMLElement" in globalThis ? HTMLElement : class {};
42
42
  class ReactInWebComponentElement extends SsrFriendlyHtmlElementClass {
43
+ reactRootPromise = Promise.resolve(null);
43
44
  constructor(getReactComponent) {
44
45
  super();
45
46
  this.getReactComponent = getReactComponent;
@@ -58,17 +59,30 @@ class ReactInWebComponentElement extends SsrFriendlyHtmlElementClass {
58
59
  this.reactRootElements.stylesRootElement.appendChild(styleElement);
59
60
  shadowRoot.appendChild(this.reactRootElements.stylesRootElement);
60
61
  shadowRoot.appendChild(this.reactRootElements.appRootElement);
61
- this.reactRootPromise = (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(__transformExtension("react-dom/client", {
62
- ".js": ".cjs"
63
- })).then(({
64
- createRoot
65
- }) => createRoot(this.reactRootElements.appRootElement));
66
62
  }
67
63
  connectedCallback() {
68
- this.reactRootPromise.then(reactRoot => reactRoot.render(this.getReactComponent(this.reactRootElements)));
64
+ this.reactRootPromise = this.reactRootPromise.then(reactRoot => {
65
+ if (reactRoot) {
66
+ throw new Error(`connectedCallback fired when reactRoot is already mounted.`);
67
+ }
68
+ return (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(__transformExtension("react-dom/client", {
69
+ ".js": ".cjs"
70
+ })).then(({
71
+ createRoot
72
+ }) => createRoot(this.reactRootElements.appRootElement));
73
+ }).then(reactRoot => {
74
+ reactRoot.render(this.getReactComponent(this.reactRootElements));
75
+ return reactRoot;
76
+ });
69
77
  }
70
78
  disconnectedCallback() {
71
- this.reactRootPromise.then(reactRoot => reactRoot.unmount());
79
+ this.reactRootPromise = this.reactRootPromise.then(reactRoot => {
80
+ if (!reactRoot) {
81
+ throw new Error(`disconnectedCallback fired when reactRoot is already unmounted.`);
82
+ }
83
+ reactRoot.unmount();
84
+ return null;
85
+ });
72
86
  }
73
87
  }
74
88
  exports.ReactInWebComponentElement = ReactInWebComponentElement;
@@ -1 +1 @@
1
- {"version":3,"file":"renderReactInWebComponent.cjs","names":["_createReactRootElements","require","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","__transformExtension","filepath","extMapping","startsWith","idx","lastIndexOf","includes","newExt","origExt","entries","sort","b","length","endsWith","slice","reactWebComponentElementName","exports","SsrFriendlyHtmlElementClass","globalThis","HTMLElement","ReactInWebComponentElement","constructor","getReactComponent","reactRootElements","createReactRootElements","styleElement","document","createElement","shadowRoot","attachShadow","mode","innerHTML","setAttribute","window","cspNonce","stylesRootElement","appendChild","appRootElement","reactRootPromise","specifier","Promise","then","s","createRoot","connectedCallback","reactRoot","render","disconnectedCallback","unmount","customElements","define","renderReactInWebComponent","webComponentChildren","webComponentParentElement","webComponentRootElement","reactElement","Array","isArray","forEach","webComponentChild"],"sources":["../../../src/web-component/renderReactInWebComponent.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { type ReactNode } from \"react\";\nimport type { Root } from \"react-dom/client\";\n\nimport {\n createReactRootElements,\n type ReactRootElements,\n} from \"./createReactRootElements.js\";\n\nexport const reactWebComponentElementName = \"odyssey-react-web-component\";\n\nexport type GetReactComponentInWebComponent = (\n reactRootElements: ReactRootElements,\n) => ReactNode;\n\nconst SsrFriendlyHtmlElementClass =\n \"HTMLElement\" in globalThis\n ? HTMLElement\n : (class {} as unknown as typeof globalThis.HTMLElement);\n\nexport class ReactInWebComponentElement extends SsrFriendlyHtmlElementClass {\n getReactComponent: GetReactComponentInWebComponent;\n reactRootElements: ReactRootElements;\n reactRootPromise: Promise<Root>;\n\n constructor(getReactComponent: GetReactComponentInWebComponent) {\n super();\n\n this.getReactComponent = getReactComponent;\n this.reactRootElements = createReactRootElements();\n\n const styleElement = document.createElement(\"style\");\n const shadowRoot = this.attachShadow({ mode: \"open\" });\n\n styleElement.innerHTML = `\n :host {\n all: initial;\n contain: content;\n }\n `;\n\n styleElement.setAttribute(\"nonce\", window.cspNonce);\n\n this.reactRootElements.stylesRootElement.appendChild(styleElement);\n shadowRoot.appendChild(this.reactRootElements.stylesRootElement);\n shadowRoot.appendChild(this.reactRootElements.appRootElement);\n\n // If we want to support React v17 in the future, we can use a try-catch on the import to grab the old `ReactDOM.render` function if `react-dom/client` errors. --Kevin Ghadyani\n this.reactRootPromise = import(\"react-dom/client\").then(({ createRoot }) =>\n createRoot(this.reactRootElements.appRootElement),\n );\n }\n\n connectedCallback() {\n this.reactRootPromise.then((reactRoot) =>\n reactRoot.render(this.getReactComponent(this.reactRootElements)),\n );\n }\n\n disconnectedCallback() {\n this.reactRootPromise.then((reactRoot) => reactRoot.unmount());\n }\n}\n\nif (\n \"customElements\" in globalThis &&\n !customElements.get(reactWebComponentElementName)\n) {\n customElements.define(\n reactWebComponentElementName,\n ReactInWebComponentElement,\n );\n}\n\nexport type RenderReactInWebComponentProps = {\n /**\n * This is a callback function for rendering your React component or app in the Web Component.\n * It gives you access to the Shadow DOM elements if you need them for Odyssey, Emotion, or MUI.\n *\n * You will need to add `<slot>` elements if you want to pass child elements or components or React apps.\n * You can have multiple slots in your app if you add a `name` attribute to your `<slot>` elements.\n */\n getReactComponent: GetReactComponentInWebComponent;\n /**\n * One or more HTML elements that are going to render as `children` of the web component.\n * If your React component doesn't take children, this is unnecessary.\n *\n * Typically, a React app root element is passed, but it can include an array of other elements if there are multiple slots for children.\n *\n * You will need to have rendered `<slot>` elements in your React component or `children` won't show up.\n */\n webComponentChildren?: HTMLElement | HTMLElement[];\n} & (\n | {\n /**\n * The React app renders in the web component, but the web component needs to be rendered in the document.\n *\n * This is the element the web component is rendered into.\n */\n webComponentParentElement: HTMLElement;\n webComponentRootElement?: never;\n }\n | {\n webComponentParentElement?: HTMLElement;\n /**\n * @deprecated Use `webComponentParentElement` instead.\n */\n webComponentRootElement: HTMLElement;\n }\n);\n\n/**\n * Lets you render React apps or components in a Web Component.\n *\n * This is useful when global styles are causing conflicts with your React components.\n */\nexport const renderReactInWebComponent = ({\n getReactComponent,\n webComponentChildren,\n webComponentParentElement,\n webComponentRootElement,\n}: RenderReactInWebComponentProps) => {\n const reactElement = new ReactInWebComponentElement(getReactComponent);\n\n if (webComponentChildren) {\n (Array.isArray(webComponentChildren)\n ? webComponentChildren\n : [webComponentChildren]\n ).forEach((webComponentChild) => {\n reactElement.appendChild(webComponentChild);\n });\n }\n\n if (webComponentParentElement) {\n webComponentParentElement.appendChild(reactElement);\n }\n // Remove this condition when `webComponentRootElement` is no longer a prop.\n else if (webComponentRootElement) {\n webComponentRootElement.appendChild(reactElement);\n }\n\n return reactElement;\n};\n"],"mappings":";;;;;;AAeA,IAAAA,wBAAA,GAAAC,OAAA;AAGsC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAI,GAAA,CAAAP,CAAA,UAAAG,CAAA,CAAAK,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAA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AI,CAAEI,SAAS,IACnCA,SAAS,CAACC,MAAM,CAAC,IAAI,CAACxB,iBAAiB,CAAC,IAAI,CAACC,iBAAiB,CAAC,CACjE,CAAC;EACH;EAEAwB,oBAAoBA,CAAA,EAAG;IACrB,IAAI,CAACT,gBAAgB,CAACG,IAAI,CAAEI,SAAS,IAAKA,SAAS,CAACG,OAAO,CAAC,CAAC,CAAC;EAChE;AACF;AAAChC,OAAA,CAAAI,0BAAA,GAAAA,0BAAA;AAED,IACE,gBAAgB,IAAIF,UAAU,IAC9B,CAAC+B,cAAc,CAAC7D,GAAG,CAAC2B,4BAA4B,CAAC,EACjD;EACAkC,cAAc,CAACC,MAAM,CACnBnC,4BAA4B,EAC5BK,0BACF,CAAC;AACH;AA4CO,MAAM+B,yBAAyB,GAAGA,CAAC;EACxC7B,iBAAiB;EACjB8B,oBAAoB;EACpBC,yBAAyB;EACzBC;AAC8B,CAAC,KAAK;EACpC,MAAMC,YAAY,GAAG,IAAInC,0BAA0B,CAACE,iBAAiB,CAAC;EAEtE,IAAI8B,oBAAoB,EAAE;IACxB,CAACI,KAAK,CAACC,OAAO,CAACL,oBAAoB,CAAC,GAChCA,oBAAoB,GACpB,CAACA,oBAAoB,CAAC,EACxBM,OAAO,CAAEC,iBAAiB,IAAK;MAC/BJ,YAAY,CAACnB,WAAW,CAACuB,iBAAiB,CAAC;IAC7C,CAAC,CAAC;EACJ;EAEA,IAAIN,yBAAyB,EAAE;IAC7BA,yBAAyB,CAACjB,WAAW,CAACmB,YAAY,CAAC;EACrD,CAAC,MAEI,IAAID,uBAAuB,EAAE;IAChCA,uBAAuB,CAAClB,WAAW,CAACmB,YAAY,CAAC;EACnD;EAEA,OAAOA,YAAY;AACrB,CAAC;AAACvC,OAAA,CAAAmC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"file":"renderReactInWebComponent.cjs","names":["_createReactRootElements","require","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","__transformExtension","filepath","extMapping","startsWith","idx","lastIndexOf","includes","newExt","origExt","entries","sort","b","length","endsWith","slice","reactWebComponentElementName","exports","SsrFriendlyHtmlElementClass","globalThis","HTMLElement","ReactInWebComponentElement","reactRootPromise","Promise","resolve","constructor","getReactComponent","reactRootElements","createReactRootElements","styleElement","document","createElement","shadowRoot","attachShadow","mode","innerHTML","setAttribute","window","cspNonce","stylesRootElement","appendChild","appRootElement","connectedCallback","then","reactRoot","Error","specifier","s","createRoot","render","disconnectedCallback","unmount","customElements","define","renderReactInWebComponent","webComponentChildren","webComponentParentElement","webComponentRootElement","reactElement","Array","isArray","forEach","webComponentChild"],"sources":["../../../src/web-component/renderReactInWebComponent.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 { type ReactNode } from \"react\";\nimport type { Root } from \"react-dom/client\";\n\nimport {\n createReactRootElements,\n type ReactRootElements,\n} from \"./createReactRootElements.js\";\n\nexport const reactWebComponentElementName = \"odyssey-react-web-component\";\n\nexport type GetReactComponentInWebComponent = (\n reactRootElements: ReactRootElements,\n) => ReactNode;\n\nconst SsrFriendlyHtmlElementClass =\n \"HTMLElement\" in globalThis\n ? HTMLElement\n : (class {} as unknown as typeof globalThis.HTMLElement);\n\nexport class ReactInWebComponentElement extends SsrFriendlyHtmlElementClass {\n getReactComponent: GetReactComponentInWebComponent;\n reactRootElements: ReactRootElements;\n reactRootPromise: Promise<Root | null> = Promise.resolve(null);\n\n constructor(getReactComponent: GetReactComponentInWebComponent) {\n super();\n\n this.getReactComponent = getReactComponent;\n this.reactRootElements = createReactRootElements();\n\n const styleElement = document.createElement(\"style\");\n const shadowRoot = this.attachShadow({ mode: \"open\" });\n\n styleElement.innerHTML = `\n :host {\n all: initial;\n contain: content;\n }\n `;\n\n styleElement.setAttribute(\"nonce\", window.cspNonce);\n\n this.reactRootElements.stylesRootElement.appendChild(styleElement);\n shadowRoot.appendChild(this.reactRootElements.stylesRootElement);\n shadowRoot.appendChild(this.reactRootElements.appRootElement);\n }\n\n connectedCallback() {\n this.reactRootPromise = this.reactRootPromise\n .then((reactRoot) => {\n if (reactRoot) {\n // Shouldn't ever happen\n throw new Error(\n `connectedCallback fired when reactRoot is already mounted.`,\n );\n }\n\n // Ensure react root is available before mounting\n // If we want to support React v17 in the future, we can use a try-catch on the import to grab the old `ReactDOM.render` function if `react-dom/client` errors. --Kevin Ghadyani\n return import(\"react-dom/client\").then(({ createRoot }) =>\n createRoot(this.reactRootElements.appRootElement),\n );\n })\n .then((reactRoot) => {\n reactRoot.render(this.getReactComponent(this.reactRootElements));\n return reactRoot;\n });\n }\n\n disconnectedCallback() {\n this.reactRootPromise = this.reactRootPromise.then((reactRoot) => {\n if (!reactRoot) {\n // Shouldn't ever happen\n throw new Error(\n `disconnectedCallback fired when reactRoot is already unmounted.`,\n );\n }\n\n reactRoot.unmount();\n // Set root to null. We don't want to attempt to render to a root that's already been unmounted.\n return null;\n });\n }\n}\n\nif (\n \"customElements\" in globalThis &&\n !customElements.get(reactWebComponentElementName)\n) {\n customElements.define(\n reactWebComponentElementName,\n ReactInWebComponentElement,\n );\n}\n\nexport type RenderReactInWebComponentProps = {\n /**\n * This is a callback function for rendering your React component or app in the Web Component.\n * It gives you access to the Shadow DOM elements if you need them for Odyssey, Emotion, or MUI.\n *\n * You will need to add `<slot>` elements if you want to pass child elements or components or React apps.\n * You can have multiple slots in your app if you add a `name` attribute to your `<slot>` elements.\n */\n getReactComponent: GetReactComponentInWebComponent;\n /**\n * One or more HTML elements that are going to render as `children` of the web component.\n * If your React component doesn't take children, this is unnecessary.\n *\n * Typically, a React app root element is passed, but it can include an array of other elements if there are multiple slots for children.\n *\n * You will need to have rendered `<slot>` elements in your React component or `children` won't show up.\n */\n webComponentChildren?: HTMLElement | HTMLElement[];\n} & (\n | {\n /**\n * The React app renders in the web component, but the web component needs to be rendered in the document.\n *\n * This is the element the web component is rendered into.\n */\n webComponentParentElement: HTMLElement;\n webComponentRootElement?: never;\n }\n | {\n webComponentParentElement?: HTMLElement;\n /**\n * @deprecated Use `webComponentParentElement` instead.\n */\n webComponentRootElement: HTMLElement;\n }\n);\n\n/**\n * Lets you render React apps or components in a Web Component.\n *\n * This is useful when global styles are causing conflicts with your React components.\n */\nexport const renderReactInWebComponent = ({\n getReactComponent,\n webComponentChildren,\n webComponentParentElement,\n webComponentRootElement,\n}: RenderReactInWebComponentProps) => {\n const reactElement = new ReactInWebComponentElement(getReactComponent);\n\n if (webComponentChildren) {\n (Array.isArray(webComponentChildren)\n ? webComponentChildren\n : [webComponentChildren]\n ).forEach((webComponentChild) => {\n reactElement.appendChild(webComponentChild);\n });\n }\n\n if (webComponentParentElement) {\n webComponentParentElement.appendChild(reactElement);\n }\n // Remove this condition when `webComponentRootElement` is no longer a prop.\n else if (webComponentRootElement) {\n webComponentRootElement.appendChild(reactElement);\n }\n\n return reactElement;\n};\n"],"mappings":";;;;;;AAeA,IAAAA,wBAAA,GAAAC,OAAA;AAGsC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAA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F,UAAU,IAC9B,CAACiC,cAAc,CAAC/D,GAAG,CAAC2B,4BAA4B,CAAC,EACjD;EACAoC,cAAc,CAACC,MAAM,CACnBrC,4BAA4B,EAC5BK,0BACF,CAAC;AACH;AA4CO,MAAMiC,yBAAyB,GAAGA,CAAC;EACxC5B,iBAAiB;EACjB6B,oBAAoB;EACpBC,yBAAyB;EACzBC;AAC8B,CAAC,KAAK;EACpC,MAAMC,YAAY,GAAG,IAAIrC,0BAA0B,CAACK,iBAAiB,CAAC;EAEtE,IAAI6B,oBAAoB,EAAE;IACxB,CAACI,KAAK,CAACC,OAAO,CAACL,oBAAoB,CAAC,GAChCA,oBAAoB,GACpB,CAACA,oBAAoB,CAAC,EACxBM,OAAO,CAAEC,iBAAiB,IAAK;MAC/BJ,YAAY,CAAClB,WAAW,CAACsB,iBAAiB,CAAC;IAC7C,CAAC,CAAC;EACJ;EAEA,IAAIN,yBAAyB,EAAE;IAC7BA,yBAAyB,CAAChB,WAAW,CAACkB,YAAY,CAAC;EACrD,CAAC,MAEI,IAAID,uBAAuB,EAAE;IAChCA,uBAAuB,CAACjB,WAAW,CAACkB,YAAY,CAAC;EACnD;EAEA,OAAOA,YAAY;AACrB,CAAC;AAACzC,OAAA,CAAAqC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -62,7 +62,7 @@ export const useOdysseyDateFields = ({
62
62
  uncontrolledValue: defaultValue
63
63
  }));
64
64
  const defaultedLanguageCode = isInvalidLocale ? "en-US" : language.replaceAll("_", "-");
65
- const isValidTimeZone = timeZone => DateTime.local().setZone(timeZone).isValid;
65
+ const isValidTimeZone = useCallback(timeZone => DateTime.local().setZone(timeZone).isValid, []);
66
66
  const formatDateTimeToUtcIsoDateString = useCallback(value => value.toUTC().toISO() || undefined, []);
67
67
  const shouldDisableDate = useCallback(date => !isDateEnabled(new Date(date?.toJSDate())) || false, [isDateEnabled]);
68
68
  const shouldDisableMonth = useCallback(date => !isMonthEnabled(new Date(date?.toJSDate())) || false, [isMonthEnabled]);
@@ -85,7 +85,7 @@ export const useOdysseyDateFields = ({
85
85
  }
86
86
  }
87
87
  return null;
88
- }, [defaultValue, validationDateRanges, value]);
88
+ }, [defaultValue, value]);
89
89
  const onTimeZoneChange = useCallback(timeZone => {
90
90
  if (timeZone && isValidTimeZone(timeZone)) {
91
91
  setInternalTimeZone(timeZone);
@@ -1 +1 @@
1
- {"version":3,"file":"useOdysseyDateFields.js","names":["useCallback","useEffect","useMemo","useRef","useState","DateTime","useTranslation","ArrowLeftIcon","ArrowRightIcon","CalendarIcon","ChevronDownIcon","ComponentControlledState","getControlState","useDateFieldsTranslations","CONTROLLED","isValidDateTime","dateTime","isValid","utcDateTimeFromIsoString","dateString","fromISO","toUTC","useOdysseyDateFields","defaultValue","isDateEnabled","isMonthEnabled","isYearEnabled","minDate","minDateProp","maxDate","maxDateProp","onInputChange","onInputChangeProp","timeZone","value","isOpen","setIsOpen","popperElement","setPopperElement","internalTimeZone","setInternalTimeZone","internalValueRef","validationDateRanges","setValidationDateRanges","undefined","startOf","i18n","language","invalidLocales","isInvalidLocale","includes","localeText","controlledStateRef","controlledValue","uncontrolledValue","defaultedLanguageCode","replaceAll","isValidTimeZone","local","setZone","formatDateTimeToUtcIsoDateString","toISO","shouldDisableDate","date","Date","toJSDate","shouldDisableMonth","shouldDisableYear","inputValues","current","valueAsUTCDateTime","defaultValueAsUTCDateTime","onTimeZoneChange","toggleCalendarVisibility","closeCalendar","formatDayOfWeek","toFormat","commonIcons"],"sources":["../../../src/DatePickers/useOdysseyDateFields.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 {\n FocusEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DateTime } from \"luxon\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { FieldComponentProps } from \"../FieldComponentProps.js\";\nimport {\n ArrowLeftIcon,\n ArrowRightIcon,\n CalendarIcon,\n ChevronDownIcon,\n} from \"../icons.generated/index.js\";\nimport { ComponentControlledState, getControlState } from \"../inputUtils.js\";\nimport { TimeZoneOption, TimeZonePickerProps } from \"./TimeZonePicker.js\";\nimport { useDateFieldsTranslations } from \"./useDateFieldsTranslations.js\";\n\nconst { CONTROLLED } = ComponentControlledState;\n\nconst isValidDateTime = (dateTime: DateTime) => dateTime.isValid;\n\nconst utcDateTimeFromIsoString = (dateString: string) =>\n DateTime.fromISO(dateString).toUTC();\n\nexport type OdysseyDateFieldProps = {\n /**\n * default value when uncontrolled.\n *\n * NOTE: Must be a date string in ISO format\n */\n defaultValue?: string;\n /**\n * Disable specific date(s).\n *\n * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.\n */\n isDateEnabled?: (date: Date) => boolean;\n /**\n * Disable specific month(s).\n */\n isMonthEnabled?: (date: Date) => boolean;\n /**\n * Disable specific year(s).\n */\n isYearEnabled?: (date: Date) => boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Minimum date allowed.\n *\n * NOTE: If not a valid date string in ISO format, `minDate` will not apply\n */\n minDate?: string;\n /**\n * Maximum date allowed.\n *\n * NOTE: If not a valid date string in ISO format, `maxDate` will not apply\n */\n maxDate?: string;\n /**\n * Callback fired when the a date field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback fired when the a date is selected with the calendar.\n */\n onCalendarDateChange?: ({\n value,\n timeZone,\n }: {\n value: string | undefined;\n timeZone: string;\n }) => void;\n /**\n * Callback fired when the date/text input changes.\n */\n onInputChange?: (value: string) => void;\n /**\n * a default timezone for the picker\n */\n timeZone?: string;\n /**\n * If provided, a `TimeZonePicker` will be rendered below the DatePicker. These options will populate as the Autocomplete options\n */\n timeZoneOptions?: TimeZoneOption[];\n /**\n * label for `TimeZonePicker`\n */\n timeZonePickerLabel?: TimeZonePickerProps[\"label\"];\n /**\n * value when controlled.\n *\n * NOTE: Must be a date string in ISO format or it will not be applied\n */\n value?: string;\n};\n\ntype FormatDateTimeToUtcIsoDateString = (value: DateTime) => string | undefined;\n\ntype ValidationDateRanges = {\n minDate?: DateTime;\n maxDate?: DateTime;\n};\n\nexport const useOdysseyDateFields = ({\n defaultValue,\n isDateEnabled = () => true,\n isMonthEnabled = () => true,\n isYearEnabled = () => true,\n minDate: minDateProp,\n maxDate: maxDateProp,\n onInputChange: onInputChangeProp,\n timeZone = \"system\",\n value,\n}: Pick<\n OdysseyDateFieldProps,\n | \"defaultValue\"\n | \"isDateEnabled\"\n | \"isMonthEnabled\"\n | \"isYearEnabled\"\n | \"minDate\"\n | \"maxDate\"\n | \"onInputChange\"\n | \"timeZone\"\n | \"value\"\n> &\n Pick<FieldComponentProps, \"errorMessage\">) => {\n const [isOpen, setIsOpen] = useState(false);\n const [popperElement, setPopperElement] = useState<HTMLInputElement | null>();\n const [internalTimeZone, setInternalTimeZone] = useState(timeZone);\n\n const internalValueRef = useRef<DateTime | null>(null);\n\n const [validationDateRanges, setValidationDateRanges] =\n useState<ValidationDateRanges>({\n minDate: undefined,\n maxDate: undefined,\n });\n\n useEffect(() => {\n const minDate = minDateProp ? DateTime.fromISO(minDateProp) : undefined;\n const maxDate = maxDateProp ? DateTime.fromISO(maxDateProp) : undefined;\n\n setValidationDateRanges({\n minDate:\n minDate && isValidDateTime(minDate)\n ? minDate.startOf(\"day\")\n : undefined,\n maxDate:\n maxDate && isValidDateTime(maxDate)\n ? maxDate.startOf(\"day\")\n : undefined,\n });\n }, [minDateProp, maxDateProp]);\n\n const { i18n } = useTranslation();\n const { language } = i18n;\n\n const invalidLocales = [\"ok_PL\", \"ok_SK\"];\n // In the Applitools env the language code is `en-us@posix`. Need to check for that\n const isInvalidLocale =\n invalidLocales.includes(language) || language.includes(\"@\");\n\n const localeText = useDateFieldsTranslations();\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const defaultedLanguageCode = isInvalidLocale\n ? \"en-US\"\n : language.replaceAll(\"_\", \"-\");\n\n const isValidTimeZone = (timeZone: string) =>\n DateTime.local().setZone(timeZone).isValid;\n\n const formatDateTimeToUtcIsoDateString =\n useCallback<FormatDateTimeToUtcIsoDateString>(\n (value) => value.toUTC().toISO() || undefined,\n [],\n );\n\n const shouldDisableDate = useCallback(\n (date: DateTime) => !isDateEnabled(new Date(date?.toJSDate())) || false,\n [isDateEnabled],\n );\n\n const shouldDisableMonth = useCallback(\n (date: DateTime) => !isMonthEnabled(new Date(date?.toJSDate())) || false,\n [isMonthEnabled],\n );\n\n const shouldDisableYear = useCallback(\n (date: DateTime) => !isYearEnabled(new Date(date?.toJSDate())) || false,\n [isYearEnabled],\n );\n\n const inputValues = useMemo(() => {\n if (value && controlledStateRef.current === CONTROLLED) {\n const valueAsUTCDateTime = utcDateTimeFromIsoString(value);\n\n if (isValidDateTime(valueAsUTCDateTime)) {\n return {\n value: valueAsUTCDateTime,\n };\n }\n }\n\n if (defaultValue) {\n const defaultValueAsUTCDateTime = utcDateTimeFromIsoString(defaultValue);\n\n if (isValidDateTime(defaultValueAsUTCDateTime)) {\n return {\n defaultValue: defaultValueAsUTCDateTime,\n };\n }\n }\n\n return null;\n }, [defaultValue, validationDateRanges, value]);\n\n const onTimeZoneChange = useCallback(\n (timeZone: string | undefined) => {\n if (timeZone && isValidTimeZone(timeZone)) {\n setInternalTimeZone(timeZone);\n }\n },\n [isValidTimeZone, setInternalTimeZone],\n );\n\n const toggleCalendarVisibility = useCallback(\n () => setIsOpen(!isOpen),\n [isOpen, setIsOpen],\n );\n\n const closeCalendar = useCallback(() => {\n setIsOpen(false);\n }, [setIsOpen]);\n\n const formatDayOfWeek = (date: DateTime) => date.toFormat(\"EEE\");\n\n const onInputChange = useCallback<(value: string) => void>(\n (value) => {\n onInputChangeProp?.(value);\n },\n [onInputChangeProp],\n );\n\n const commonIcons = {\n ArrowLeftIcon: ArrowLeftIcon,\n ArrowRightIcon: ArrowRightIcon,\n CalendarIcon: CalendarIcon,\n ChevronDownIcon: ChevronDownIcon,\n };\n\n return {\n closeCalendar,\n commonIcons,\n defaultedLanguageCode,\n formatDateTimeToUtcIsoDateString,\n formatDayOfWeek,\n inputValues,\n internalTimeZone,\n internalValueRef,\n isOpen,\n isValidTimeZone,\n localeText,\n maxDate: validationDateRanges.maxDate,\n minDate: validationDateRanges.minDate,\n popperElement,\n onInputChange,\n onTimeZoneChange,\n setInternalTimeZone,\n setIsOpen,\n setPopperElement,\n shouldDisableDate,\n shouldDisableMonth,\n shouldDisableYear,\n toggleCalendarVisibility,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,QAAQ,QAAQ,OAAO;AAChC,SAASC,cAAc,QAAQ,eAAe;AAG9C,SACEC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,eAAe,QACV,6BAA6B;AACpC,SAASC,wBAAwB,EAAEC,eAAe,QAAQ,kBAAkB;AAE5E,SAASC,yBAAyB,QAAQ,gCAAgC;AAE1E,MAAM;EAAEC;AAAW,CAAC,GAAGH,wBAAwB;AAE/C,MAAMI,eAAe,GAAIC,QAAkB,IAAKA,QAAQ,CAACC,OAAO;AAEhE,MAAMC,wBAAwB,GAAIC,UAAkB,IAClDd,QAAQ,CAACe,OAAO,CAACD,UAAU,CAAC,CAACE,KAAK,CAAC,CAAC;AAoFtC,OAAO,MAAMC,oBAAoB,GAAGA,CAAC;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,QAAQ,CAAC,KAAK,CAAC;EAEhE,MAAM7C,aAAa,GAAG/B,WAAW,CAC9BkC,KAAK,IAAK;IACTF,iBAAiB,GAAGE,KAAK,CAAC;EAC5B,CAAC,EACD,CAACF,iBAAiB,CACpB,CAAC;EAED,MAAM6C,WAAW,GAAG;IAClBtE,aAAa,EAAEA,aAAa;IAC5BC,cAAc,EAAEA,cAAc;IAC9BC,YAAY,EAAEA,YAAY;IAC1BC,eAAe,EAAEA;EACnB,CAAC;EAED,OAAO;IACLgE,aAAa;IACbG,WAAW;IACXtB,qBAAqB;IACrBK,gCAAgC;IAChCe,eAAe;IACfP,WAAW;IACX7B,gBAAgB;IAChBE,gBAAgB;IAChBN,MAAM;IACNsB,eAAe;IACfN,UAAU;IACVtB,OAAO,EAAEa,oBAAoB,CAACb,OAAO;IACrCF,OAAO,EAAEe,oBAAoB,CAACf,OAAO;IACrCU,aAAa;IACbN,aAAa;IACbyC,gBAAgB;IAChBhC,mBAAmB;IACnBJ,SAAS;IACTE,gBAAgB;IAChBwB,iBAAiB;IACjBI,kBAAkB;IAClBC,iBAAiB;IACjBM;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useOdysseyDateFields.js","names":["useCallback","useEffect","useMemo","useRef","useState","DateTime","useTranslation","ArrowLeftIcon","ArrowRightIcon","CalendarIcon","ChevronDownIcon","ComponentControlledState","getControlState","useDateFieldsTranslations","CONTROLLED","isValidDateTime","dateTime","isValid","utcDateTimeFromIsoString","dateString","fromISO","toUTC","useOdysseyDateFields","defaultValue","isDateEnabled","isMonthEnabled","isYearEnabled","minDate","minDateProp","maxDate","maxDateProp","onInputChange","onInputChangeProp","timeZone","value","isOpen","setIsOpen","popperElement","setPopperElement","internalTimeZone","setInternalTimeZone","internalValueRef","validationDateRanges","setValidationDateRanges","undefined","startOf","i18n","language","invalidLocales","isInvalidLocale","includes","localeText","controlledStateRef","controlledValue","uncontrolledValue","defaultedLanguageCode","replaceAll","isValidTimeZone","local","setZone","formatDateTimeToUtcIsoDateString","toISO","shouldDisableDate","date","Date","toJSDate","shouldDisableMonth","shouldDisableYear","inputValues","current","valueAsUTCDateTime","defaultValueAsUTCDateTime","onTimeZoneChange","toggleCalendarVisibility","closeCalendar","formatDayOfWeek","toFormat","commonIcons"],"sources":["../../../src/DatePickers/useOdysseyDateFields.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-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 {\n FocusEventHandler,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { DateTime } from \"luxon\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { FieldComponentProps } from \"../FieldComponentProps.js\";\nimport {\n ArrowLeftIcon,\n ArrowRightIcon,\n CalendarIcon,\n ChevronDownIcon,\n} from \"../icons.generated/index.js\";\nimport { ComponentControlledState, getControlState } from \"../inputUtils.js\";\nimport { TimeZoneOption, TimeZonePickerProps } from \"./TimeZonePicker.js\";\nimport { useDateFieldsTranslations } from \"./useDateFieldsTranslations.js\";\n\nconst { CONTROLLED } = ComponentControlledState;\n\nconst isValidDateTime = (dateTime: DateTime) => dateTime.isValid;\n\nconst utcDateTimeFromIsoString = (dateString: string) =>\n DateTime.fromISO(dateString).toUTC();\n\nexport type OdysseyDateFieldProps = {\n /**\n * default value when uncontrolled.\n *\n * NOTE: Must be a date string in ISO format\n */\n defaultValue?: string;\n /**\n * Disable specific date(s).\n *\n * Warning: This function can be called multiple times (for example when rendering date calendar, checking if focus can be moved to a certain date, etc.). Expensive computations can impact performance.\n */\n isDateEnabled?: (date: Date) => boolean;\n /**\n * Disable specific month(s).\n */\n isMonthEnabled?: (date: Date) => boolean;\n /**\n * Disable specific year(s).\n */\n isYearEnabled?: (date: Date) => boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Minimum date allowed.\n *\n * NOTE: If not a valid date string in ISO format, `minDate` will not apply\n */\n minDate?: string;\n /**\n * Maximum date allowed.\n *\n * NOTE: If not a valid date string in ISO format, `maxDate` will not apply\n */\n maxDate?: string;\n /**\n * Callback fired when the a date field loses focus\n */\n onBlur?: FocusEventHandler<HTMLInputElement>;\n /**\n * Callback fired when the a date is selected with the calendar.\n */\n onCalendarDateChange?: ({\n value,\n timeZone,\n }: {\n value: string | undefined;\n timeZone: string;\n }) => void;\n /**\n * Callback fired when the date/text input changes.\n */\n onInputChange?: (value: string) => void;\n /**\n * a default timezone for the picker\n */\n timeZone?: string;\n /**\n * If provided, a `TimeZonePicker` will be rendered below the DatePicker. These options will populate as the Autocomplete options\n */\n timeZoneOptions?: TimeZoneOption[];\n /**\n * label for `TimeZonePicker`\n */\n timeZonePickerLabel?: TimeZonePickerProps[\"label\"];\n /**\n * value when controlled.\n *\n * NOTE: Must be a date string in ISO format or it will not be applied\n */\n value?: string;\n};\n\ntype FormatDateTimeToUtcIsoDateString = (value: DateTime) => string | undefined;\n\ntype ValidationDateRanges = {\n minDate?: DateTime;\n maxDate?: DateTime;\n};\n\nexport const useOdysseyDateFields = ({\n defaultValue,\n isDateEnabled = () => true,\n isMonthEnabled = () => true,\n isYearEnabled = () => true,\n minDate: minDateProp,\n maxDate: maxDateProp,\n onInputChange: onInputChangeProp,\n timeZone = \"system\",\n value,\n}: Pick<\n OdysseyDateFieldProps,\n | \"defaultValue\"\n | \"isDateEnabled\"\n | \"isMonthEnabled\"\n | \"isYearEnabled\"\n | \"minDate\"\n | \"maxDate\"\n | \"onInputChange\"\n | \"timeZone\"\n | \"value\"\n> &\n Pick<FieldComponentProps, \"errorMessage\">) => {\n const [isOpen, setIsOpen] = useState(false);\n const [popperElement, setPopperElement] = useState<HTMLInputElement | null>();\n const [internalTimeZone, setInternalTimeZone] = useState(timeZone);\n\n const internalValueRef = useRef<DateTime | null>(null);\n\n const [validationDateRanges, setValidationDateRanges] =\n useState<ValidationDateRanges>({\n minDate: undefined,\n maxDate: undefined,\n });\n\n useEffect(() => {\n const minDate = minDateProp ? DateTime.fromISO(minDateProp) : undefined;\n const maxDate = maxDateProp ? DateTime.fromISO(maxDateProp) : undefined;\n\n setValidationDateRanges({\n minDate:\n minDate && isValidDateTime(minDate)\n ? minDate.startOf(\"day\")\n : undefined,\n maxDate:\n maxDate && isValidDateTime(maxDate)\n ? maxDate.startOf(\"day\")\n : undefined,\n });\n }, [minDateProp, maxDateProp]);\n\n const { i18n } = useTranslation();\n const { language } = i18n;\n\n const invalidLocales = [\"ok_PL\", \"ok_SK\"];\n // In the Applitools env the language code is `en-us@posix`. Need to check for that\n const isInvalidLocale =\n invalidLocales.includes(language) || language.includes(\"@\");\n\n const localeText = useDateFieldsTranslations();\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const defaultedLanguageCode = isInvalidLocale\n ? \"en-US\"\n : language.replaceAll(\"_\", \"-\");\n\n const isValidTimeZone = useCallback(\n (timeZone: string) => DateTime.local().setZone(timeZone).isValid,\n [],\n );\n\n const formatDateTimeToUtcIsoDateString =\n useCallback<FormatDateTimeToUtcIsoDateString>(\n (value) => value.toUTC().toISO() || undefined,\n [],\n );\n\n const shouldDisableDate = useCallback(\n (date: DateTime) => !isDateEnabled(new Date(date?.toJSDate())) || false,\n [isDateEnabled],\n );\n\n const shouldDisableMonth = useCallback(\n (date: DateTime) => !isMonthEnabled(new Date(date?.toJSDate())) || false,\n [isMonthEnabled],\n );\n\n const shouldDisableYear = useCallback(\n (date: DateTime) => !isYearEnabled(new Date(date?.toJSDate())) || false,\n [isYearEnabled],\n );\n\n const inputValues = useMemo(() => {\n if (value && controlledStateRef.current === CONTROLLED) {\n const valueAsUTCDateTime = utcDateTimeFromIsoString(value);\n\n if (isValidDateTime(valueAsUTCDateTime)) {\n return {\n value: valueAsUTCDateTime,\n };\n }\n }\n\n if (defaultValue) {\n const defaultValueAsUTCDateTime = utcDateTimeFromIsoString(defaultValue);\n\n if (isValidDateTime(defaultValueAsUTCDateTime)) {\n return {\n defaultValue: defaultValueAsUTCDateTime,\n };\n }\n }\n\n return null;\n }, [defaultValue, value]);\n\n const onTimeZoneChange = useCallback(\n (timeZone: string | undefined) => {\n if (timeZone && isValidTimeZone(timeZone)) {\n setInternalTimeZone(timeZone);\n }\n },\n [isValidTimeZone, setInternalTimeZone],\n );\n\n const toggleCalendarVisibility = useCallback(\n () => setIsOpen(!isOpen),\n [isOpen, setIsOpen],\n );\n\n const closeCalendar = useCallback(() => {\n setIsOpen(false);\n }, [setIsOpen]);\n\n const formatDayOfWeek = (date: DateTime) => date.toFormat(\"EEE\");\n\n const onInputChange = useCallback<(value: string) => void>(\n (value) => {\n onInputChangeProp?.(value);\n },\n [onInputChangeProp],\n );\n\n const commonIcons = {\n ArrowLeftIcon: ArrowLeftIcon,\n ArrowRightIcon: ArrowRightIcon,\n CalendarIcon: CalendarIcon,\n ChevronDownIcon: ChevronDownIcon,\n };\n\n return {\n closeCalendar,\n commonIcons,\n defaultedLanguageCode,\n formatDateTimeToUtcIsoDateString,\n formatDayOfWeek,\n inputValues,\n internalTimeZone,\n internalValueRef,\n isOpen,\n isValidTimeZone,\n localeText,\n maxDate: validationDateRanges.maxDate,\n minDate: validationDateRanges.minDate,\n popperElement,\n onInputChange,\n onTimeZoneChange,\n setInternalTimeZone,\n setIsOpen,\n setPopperElement,\n shouldDisableDate,\n shouldDisableMonth,\n shouldDisableYear,\n toggleCalendarVisibility,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,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package/dist/esm/Field.js CHANGED
@@ -55,8 +55,8 @@ const Field = ({
55
55
  component: fieldType === "group" ? "fieldset" : "div",
56
56
  disabled: isDisabled,
57
57
  error: Boolean(errorMessage) || Array.isArray(errorMessageList) && errorMessageList.length > 0,
58
- role: isRadioGroup ? "radiogroup" : undefined,
59
58
  fullWidth: isFullWidth,
59
+ role: isRadioGroup ? "radiogroup" : undefined,
60
60
  children: [fieldType === "group" ? _jsxs(_FormLabel, {
61
61
  component: "legend",
62
62
  id: labelElementId,
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["memo","useMemo","FieldError","FieldHint","FieldLabel","Typography","useFieldset","useTranslation","useUniqueId","jsxs","_jsxs","jsx","_jsx","fieldTypeValues","Field","ariaDescribedBy","errorMessage","errorMessageList","fieldType","hasVisibleLabel","hint","HintLinkComponent","id","idOverride","isDisabled","isDisabledProp","isFullWidth","isRadioGroup","isOptional","isReadOnly","label","renderFieldComponent","t","hintId","undefined","errorMessageElementId","labelElementId","localAriaDescribedBy","join","trim","isFieldsetDisabled","_FormControl","component","disabled","error","Boolean","Array","isArray","length","role","fullWidth","children","_FormLabel","color","inputId","text","LinkComponent","message","messageList","MemoizedField","displayName"],"sources":["../../src/Field.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 { memo, ReactElement, useMemo } from \"react\";\nimport {\n FormControl as MuiFormControl,\n FormLabel as MuiFormLabel,\n} from \"@mui/material\";\nimport { FieldComponentProps } from \"./FieldComponentProps.js\";\nimport { FieldError } from \"./FieldError.js\";\nimport { FieldHint } from \"./FieldHint.js\";\nimport { FieldLabel } from \"./FieldLabel.js\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport { Typography } from \"./Typography.js\";\nimport { useFieldset } from \"./FieldsetContext.js\";\nimport { useTranslation } from \"react-i18next\";\nimport { useUniqueId } from \"./useUniqueId.js\";\n\nexport const fieldTypeValues = [\"single\", \"group\"] as const;\n\nexport type RenderFieldComponentProps = {\n ariaDescribedBy?: string;\n dataSe?: string;\n errorMessageElementId?: string;\n id: string;\n labelElementId: string;\n isReadOnly?: boolean;\n};\n\nexport type FieldProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessageList?: string[];\n /**\n * The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group).\n */\n fieldType: (typeof fieldTypeValues)[number];\n /**\n * If `true`, the Field label will be shown\n */\n hasVisibleLabel: boolean;\n /**\n * Important for narrowing down the `fieldset` role to \"radiogroup\".\n */\n isRadioGroup?: boolean;\n /**\n * Important for determining if children inherit error state\n */\n isCheckboxGroup?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Render-props function that sends back ARIA props to your field component.\n */\n renderFieldComponent: ({\n ariaDescribedBy,\n dataSe,\n errorMessageElementId,\n id,\n labelElementId,\n isReadOnly,\n }: RenderFieldComponentProps) => ReactElement;\n};\n\nconst Field = ({\n ariaDescribedBy,\n errorMessage,\n errorMessageList,\n fieldType,\n hasVisibleLabel,\n hint,\n HintLinkComponent,\n id: idOverride,\n isDisabled: isDisabledProp = false,\n isFullWidth = false,\n isRadioGroup = false,\n isOptional = false,\n isReadOnly = false,\n label,\n renderFieldComponent,\n}: FieldProps &\n Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n > &\n Pick<HtmlProps, \"ariaDescribedBy\">) => {\n const { t } = useTranslation();\n\n const id = useUniqueId(idOverride);\n const hintId = hint ? `${id}-hint` : undefined;\n const errorMessageElementId =\n errorMessage || errorMessageList ? `${id}-error` : undefined;\n const labelElementId = `${id}-label`;\n\n const localAriaDescribedBy = useMemo(\n () =>\n [hintId, errorMessageElementId, ariaDescribedBy].join(\" \").trim() ||\n undefined,\n [ariaDescribedBy, errorMessageElementId, hintId],\n );\n\n const { isDisabled: isFieldsetDisabled } = useFieldset();\n\n const isDisabled = useMemo(\n () => isDisabledProp || isFieldsetDisabled,\n [isDisabledProp, isFieldsetDisabled],\n );\n\n return (\n <MuiFormControl\n component={fieldType === \"group\" ? \"fieldset\" : \"div\"}\n disabled={isDisabled}\n error={\n Boolean(errorMessage) ||\n (Array.isArray(errorMessageList) && errorMessageList.length > 0)\n }\n role={isRadioGroup ? \"radiogroup\" : undefined}\n fullWidth={isFullWidth}\n >\n {fieldType === \"group\" ? (\n <MuiFormLabel component=\"legend\" id={labelElementId}>\n {label}{\" \"}\n {isOptional && label && (\n <Typography component=\"span\" color=\"textSecondary\">\n ({t(\"fieldlabel.optional.text\")})\n </Typography>\n )}\n </MuiFormLabel>\n ) : (\n <FieldLabel\n hasVisibleLabel={hasVisibleLabel}\n id={labelElementId}\n inputId={id}\n isOptional={isOptional}\n text={label}\n />\n )}\n\n {hint && (\n <FieldHint id={hintId} LinkComponent={HintLinkComponent} text={hint} />\n )}\n\n {renderFieldComponent({\n ariaDescribedBy: localAriaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n isReadOnly,\n })}\n\n {(errorMessage || errorMessageList) && (\n <FieldError\n id={errorMessageElementId}\n message={errorMessage}\n messageList={errorMessageList}\n />\n )}\n </MuiFormControl>\n );\n};\n\nconst MemoizedField = memo(Field);\nMemoizedField.displayName = \"Field\";\n\nexport { MemoizedField as Field };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA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AAkB;MAACkC,IAAI,EAAEnC;IAAK,CAAE,CACvE,EAEAW,oBAAoB,CAAC;MACpBhB,eAAe,EAAEsB,oBAAoB;MACrCF,qBAAqB;MACrBb,EAAE;MACFc,cAAc;MACdP;IACF,CAAC,CAAC,EAED,CAACb,YAAY,IAAIC,gBAAgB,KAChCL,IAAA,CAACV,UAAU;MACToB,EAAE,EAAEa,qBAAsB;MAC1BsB,OAAO,EAAEzC,YAAa;MACtB0C,WAAW,EAAEzC;IAAiB,CAC/B,CACF;EAAA,CACa,CAAC;AAErB,CAAC;AAED,MAAM0C,aAAa,GAAG3D,IAAI,CAACc,KAAK,CAAC;AACjC6C,aAAa,CAACC,WAAW,GAAG,OAAO;AAEnC,SAASD,aAAa,IAAI7C,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Field.js","names":["memo","useMemo","FieldError","FieldHint","FieldLabel","Typography","useFieldset","useTranslation","useUniqueId","jsxs","_jsxs","jsx","_jsx","fieldTypeValues","Field","ariaDescribedBy","errorMessage","errorMessageList","fieldType","hasVisibleLabel","hint","HintLinkComponent","id","idOverride","isDisabled","isDisabledProp","isFullWidth","isRadioGroup","isOptional","isReadOnly","label","renderFieldComponent","t","hintId","undefined","errorMessageElementId","labelElementId","localAriaDescribedBy","join","trim","isFieldsetDisabled","_FormControl","component","disabled","error","Boolean","Array","isArray","length","fullWidth","role","children","_FormLabel","color","inputId","text","LinkComponent","message","messageList","MemoizedField","displayName"],"sources":["../../src/Field.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 { memo, ReactElement, useMemo } from \"react\";\nimport {\n FormControl as MuiFormControl,\n FormLabel as MuiFormLabel,\n} from \"@mui/material\";\nimport { FieldComponentProps } from \"./FieldComponentProps.js\";\nimport { FieldError } from \"./FieldError.js\";\nimport { FieldHint } from \"./FieldHint.js\";\nimport { FieldLabel } from \"./FieldLabel.js\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport { Typography } from \"./Typography.js\";\nimport { useFieldset } from \"./FieldsetContext.js\";\nimport { useTranslation } from \"react-i18next\";\nimport { useUniqueId } from \"./useUniqueId.js\";\n\nexport const fieldTypeValues = [\"single\", \"group\"] as const;\n\nexport type RenderFieldComponentProps = {\n ariaDescribedBy?: string;\n dataSe?: string;\n errorMessageElementId?: string;\n id: string;\n labelElementId: string;\n isReadOnly?: boolean;\n};\n\nexport type FieldProps = {\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessageList?: string[];\n /**\n * The field type determines how ARIA components are setup. It's important to use this to denote if you expect only one component (like a text field) or multiple (like a radio group).\n */\n fieldType: (typeof fieldTypeValues)[number];\n /**\n * If `true`, the Field label will be shown\n */\n hasVisibleLabel: boolean;\n /**\n * Important for narrowing down the `fieldset` role to \"radiogroup\".\n */\n isRadioGroup?: boolean;\n /**\n * Important for determining if children inherit error state\n */\n isCheckboxGroup?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * Render-props function that sends back ARIA props to your field component.\n */\n renderFieldComponent: ({\n ariaDescribedBy,\n dataSe,\n errorMessageElementId,\n id,\n labelElementId,\n isReadOnly,\n }: RenderFieldComponentProps) => ReactElement;\n};\n\nconst Field = ({\n ariaDescribedBy,\n errorMessage,\n errorMessageList,\n fieldType,\n hasVisibleLabel,\n hint,\n HintLinkComponent,\n id: idOverride,\n isDisabled: isDisabledProp = false,\n isFullWidth = false,\n isRadioGroup = false,\n isOptional = false,\n isReadOnly = false,\n label,\n renderFieldComponent,\n}: FieldProps &\n Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n > &\n Pick<HtmlProps, \"ariaDescribedBy\">) => {\n const { t } = useTranslation();\n\n const id = useUniqueId(idOverride);\n const hintId = hint ? `${id}-hint` : undefined;\n const errorMessageElementId =\n errorMessage || errorMessageList ? `${id}-error` : undefined;\n const labelElementId = `${id}-label`;\n\n const localAriaDescribedBy = useMemo(\n () =>\n [hintId, errorMessageElementId, ariaDescribedBy].join(\" \").trim() ||\n undefined,\n [ariaDescribedBy, errorMessageElementId, hintId],\n );\n\n const { isDisabled: isFieldsetDisabled } = useFieldset();\n\n const isDisabled = useMemo(\n () => isDisabledProp || isFieldsetDisabled,\n [isDisabledProp, isFieldsetDisabled],\n );\n\n return (\n <MuiFormControl\n component={fieldType === \"group\" ? \"fieldset\" : \"div\"}\n disabled={isDisabled}\n error={\n Boolean(errorMessage) ||\n (Array.isArray(errorMessageList) && errorMessageList.length > 0)\n }\n fullWidth={isFullWidth}\n role={isRadioGroup ? \"radiogroup\" : undefined}\n >\n {fieldType === \"group\" ? (\n <MuiFormLabel component=\"legend\" id={labelElementId}>\n {label}{\" \"}\n {isOptional && label && (\n <Typography component=\"span\" color=\"textSecondary\">\n ({t(\"fieldlabel.optional.text\")})\n </Typography>\n )}\n </MuiFormLabel>\n ) : (\n <FieldLabel\n hasVisibleLabel={hasVisibleLabel}\n id={labelElementId}\n inputId={id}\n isOptional={isOptional}\n text={label}\n />\n )}\n\n {hint && (\n <FieldHint id={hintId} LinkComponent={HintLinkComponent} text={hint} />\n )}\n\n {renderFieldComponent({\n ariaDescribedBy: localAriaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n isReadOnly,\n })}\n\n {(errorMessage || errorMessageList) && (\n <FieldError\n id={errorMessageElementId}\n message={errorMessage}\n messageList={errorMessageList}\n />\n )}\n </MuiFormControl>\n );\n};\n\nconst MemoizedField = memo(Field);\nMemoizedField.displayName = \"Field\";\n\nexport { MemoizedField as Field };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAgBC,OAAO,QAAQ,OAAO;AAMnD,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,WAAW,QAAQ,kBAAkB;AAAC,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA;AAE/C,OAAO,MAAMC,eAAe,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;AAqD3D,MAAMC,KAAK,GAAGA,CAAC;EACbC,eAAe;EACfC,YAAY;EACZC,gBAAgB;EAChBC,SAAS;EACTC,eAAe;EACfC,IAAI;EACJC,iBAAiB;EACjBC,EAAE,EAAEC,UAAU;EACdC,UAAU,EAAEC,cAAc,GAAG,KAAK;EAClCC,WAAW,GAAG,KAAK;EACnBC,YAAY,GAAG,KAAK;EACpBC,UAAU,GAAG,KAAK;EAClBC,UAAU,GAAG,KAAK;EAClBC,KAAK;EACLC;AAciC,CAAC,KAAK;EACvC,MAAM;IAAEC;EAAE,CAAC,GAAGzB,cAAc,CAAC,CAAC;EAE9B,MAAMe,EAAE,GAAGd,WAAW,CAACe,UAAU,CAAC;EAClC,MAAMU,MAAM,GAAGb,IAAI,GAAG,GAAGE,EAAE,OAAO,GAAGY,SAAS;EAC9C,MAAMC,qBAAqB,GACzBnB,YAAY,IAAIC,gBAAgB,GAAG,GAAGK,EAAE,QAAQ,GAAGY,SAAS;EAC9D,MAAME,cAAc,GAAG,GAAGd,EAAE,QAAQ;EA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;MACZM,UAAU,EAAEA,UAAW;MACvB2B,IAAI,EAAEzB;IAAM,CACb,CACF,EAEAV,IAAI,IACHR,IAAA,CAACT,SAAS;MAACmB,EAAE,EAAEW,MAAO;MAACuB,aAAa,EAAEnC,iBAAkB;MAACkC,IAAI,EAAEnC;IAAK,CAAE,CACvE,EAEAW,oBAAoB,CAAC;MACpBhB,eAAe,EAAEsB,oBAAoB;MACrCF,qBAAqB;MACrBb,EAAE;MACFc,cAAc;MACdP;IACF,CAAC,CAAC,EAED,CAACb,YAAY,IAAIC,gBAAgB,KAChCL,IAAA,CAACV,UAAU;MACToB,EAAE,EAAEa,qBAAsB;MAC1BsB,OAAO,EAAEzC,YAAa;MACtB0C,WAAW,EAAEzC;IAAiB,CAC/B,CACF;EAAA,CACa,CAAC;AAErB,CAAC;AAED,MAAM0C,aAAa,GAAG3D,IAAI,CAACc,KAAK,CAAC;AACjC6C,aAAa,CAACC,WAAW,GAAG,OAAO;AAEnC,SAASD,aAAa,IAAI7C,KAAK","ignoreList":[]}
@@ -128,12 +128,6 @@ const Pagination = ({
128
128
  updatedPage = 1;
129
129
  }
130
130
  }
131
- console.log({
132
- page,
133
- updatedPage,
134
- rowsPerPage,
135
- updatedRowsPerPage
136
- });
137
131
  onPaginationChange({
138
132
  pageIndex: updatedPage,
139
133
  pageSize: updatedRowsPerPage