@okta/odyssey-react-mui 1.35.2 → 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.
- package/dist/cjs/DatePickers/useOdysseyDateFields.cjs +2 -2
- package/dist/cjs/DatePickers/useOdysseyDateFields.cjs.map +1 -1
- package/dist/cjs/Field.cjs +1 -1
- package/dist/cjs/Field.cjs.map +1 -1
- package/dist/cjs/Pagination/Pagination.cjs +0 -6
- package/dist/cjs/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/inputUtils.cjs +1 -1
- package/dist/cjs/inputUtils.cjs.map +1 -1
- package/dist/cjs/labs/DataFilters.cjs +4 -4
- package/dist/cjs/labs/DataFilters.cjs.map +1 -1
- package/dist/cjs/labs/DataView/DataCard.cjs +18 -18
- package/dist/cjs/labs/DataView/DataCard.cjs.map +1 -1
- package/dist/cjs/labs/DataView/DataView.cjs +10 -10
- package/dist/cjs/labs/DataView/DataView.cjs.map +1 -1
- package/dist/cjs/labs/DataView/useFilterConversion.cjs +1 -1
- package/dist/cjs/labs/DataView/useFilterConversion.cjs.map +1 -1
- package/dist/cjs/theme/useMediaQuery.cjs +1 -1
- package/dist/cjs/theme/useMediaQuery.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs +79 -48
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs +84 -112
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs.map +1 -1
- package/dist/cjs/ui-shell/WideUiShellContent.cjs +2 -1
- package/dist/cjs/ui-shell/WideUiShellContent.cjs.map +1 -1
- package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs +1 -1
- package/dist/cjs/ui-shell/useMatchAppElementToUiShellAppArea.cjs.map +1 -1
- package/dist/cjs/ui-shell/useScrollState.cjs +71 -21
- package/dist/cjs/ui-shell/useScrollState.cjs.map +1 -1
- package/dist/cjs/web-component/createReactRootElements.cjs +5 -3
- package/dist/cjs/web-component/createReactRootElements.cjs.map +1 -1
- package/dist/esm/DatePickers/useOdysseyDateFields.js +2 -2
- package/dist/esm/DatePickers/useOdysseyDateFields.js.map +1 -1
- package/dist/esm/Field.js +1 -1
- package/dist/esm/Field.js.map +1 -1
- package/dist/esm/Pagination/Pagination.js +0 -6
- package/dist/esm/Pagination/Pagination.js.map +1 -1
- package/dist/esm/inputUtils.js +1 -1
- package/dist/esm/inputUtils.js.map +1 -1
- package/dist/esm/labs/DataFilters.js +4 -4
- package/dist/esm/labs/DataFilters.js.map +1 -1
- package/dist/esm/labs/DataView/DataCard.js +18 -18
- package/dist/esm/labs/DataView/DataCard.js.map +1 -1
- package/dist/esm/labs/DataView/DataView.js +10 -10
- package/dist/esm/labs/DataView/DataView.js.map +1 -1
- package/dist/esm/labs/DataView/useFilterConversion.js +1 -1
- package/dist/esm/labs/DataView/useFilterConversion.js.map +1 -1
- package/dist/esm/theme/useMediaQuery.js +1 -1
- package/dist/esm/theme/useMediaQuery.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNav.js +80 -49
- package/dist/esm/ui-shell/SideNav/SideNav.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js +85 -113
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js.map +1 -1
- package/dist/esm/ui-shell/WideUiShellContent.js +2 -1
- package/dist/esm/ui-shell/WideUiShellContent.js.map +1 -1
- package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js +1 -1
- package/dist/esm/ui-shell/useMatchAppElementToUiShellAppArea.js.map +1 -1
- package/dist/esm/ui-shell/useScrollState.js +67 -21
- package/dist/esm/ui-shell/useScrollState.js.map +1 -1
- package/dist/esm/web-component/createReactRootElements.js +4 -2
- package/dist/esm/web-component/createReactRootElements.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.scss +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/DatePickers/useOdysseyDateFields.d.ts.map +1 -1
- package/dist/types/Pagination/Pagination.d.ts.map +1 -1
- package/dist/types/labs/DataView/DataCard.d.ts.map +1 -1
- package/dist/types/labs/DataView/DataView.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNav.d.ts +2 -0
- package/dist/types/ui-shell/SideNav/SideNav.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts +15 -8
- package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts.map +1 -1
- package/dist/types/ui-shell/WideUiShellContent.d.ts.map +1 -1
- package/dist/types/ui-shell/useMatchAppElementToUiShellAppArea.d.ts.map +1 -1
- package/dist/types/ui-shell/useScrollState.d.ts +9 -1
- package/dist/types/ui-shell/useScrollState.d.ts.map +1 -1
- package/dist/types/web-component/createReactRootElements.d.ts +2 -0
- package/dist/types/web-component/createReactRootElements.d.ts.map +1 -1
- package/package.json +13 -10
|
@@ -30,6 +30,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
30
30
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
+
const appSwitcherDefaultAppIcons = [];
|
|
33
34
|
const StyledAppContainer = (0, _styled.default)("div", {
|
|
34
35
|
shouldForwardProp: prop => prop !== "appBackgroundColor" && prop !== "odysseyDesignTokens"
|
|
35
36
|
})(({
|
|
@@ -108,8 +109,8 @@ const WideUiShellContent = ({
|
|
|
108
109
|
fallback: null,
|
|
109
110
|
onError: onError,
|
|
110
111
|
children: (0, _jsxRuntime.jsx)(_index.AppSwitcher, {
|
|
112
|
+
appIcons: appSwitcherDefaultAppIcons,
|
|
111
113
|
isLoading: true,
|
|
112
|
-
appIcons: [],
|
|
113
114
|
selectedAppName: ""
|
|
114
115
|
})
|
|
115
116
|
}), appSwitcherProps && (0, _jsxRuntime.jsx)(_reactErrorBoundary.ErrorBoundary, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WideUiShellContent.cjs","names":["_styled","_interopRequireDefault","require","_react","_reactErrorBoundary","_index","_InnerAppContainer","_OdysseyDesignTokensContext","_index2","_index3","_useScrollState","_useMatchAppElementToUiShellAppArea","_UiShellProvider","_uiShellSharedConstants","_jsxRuntime","e","__esModule","default","StyledAppContainer","styled","shouldForwardProp","prop","appBackgroundColor","backgroundColor","gridArea","pointerEvents","position","StyledAppSwitcherContainer","StyledBannersContainer","StyledSideNavContainer","StyledShellContainer","odysseyDesignTokens","HueNeutral50","display","gridGap","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","width","StyledTopNavContainer","WideUiShellContent","appElement","appElementScrollingMode","appSwitcherProps","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","optionalComponents","sideNavProps","topNavProps","useOdysseyDesignTokens","uiShellContext","useUiShellContext","isContentScrolled","useScrollState","sideNavContainerRef","useRef","topNavContainerRef","uiShellAppAreaRef","parentContainerRef","useMatchAppElementToUiShellAppArea","paddingMode","uiShellResizableRefs","jsxs","ref","children","jsx","banners","includes","ErrorBoundary","fallback","AppSwitcher","isLoading","appIcons","selectedAppName","undefined","SideNav","sideNavItems","emptySideNavItems","hasCustomFooter","sideNavFooter","footerComponent","footerItems","TopNav","leftSideComponent","topNavLeftSide","rightSideComponent","topNavRightSide","tabIndex","InnerAppContainer","MemoizedWideUiShellContent","exports","memo","displayName"],"sources":["../../../src/ui-shell/WideUiShellContent.tsx"],"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 styled from \"@emotion/styled\";\nimport { memo, useRef } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { AppSwitcher } from \"./AppSwitcher/index.js\";\nimport { InnerAppContainer } from \"./InnerAppContainer.js\";\nimport {\n useOdysseyDesignTokens,\n type DesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport { SideNav } from \"./SideNav/index.js\";\nimport { TopNav } from \"./TopNav/index.js\";\nimport { useScrollState } from \"./useScrollState.js\";\nimport { useMatchAppElementToUiShellAppArea } from \"./useMatchAppElementToUiShellAppArea.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport { UiShellColors, useUiShellContext } from \"./UiShellProvider.js\";\nimport { emptySideNavItems } from \"./uiShellSharedConstants.js\";\n\nconst StyledAppContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"appBackgroundColor\" && prop !== \"odysseyDesignTokens\",\n})<{\n appBackgroundColor?: UiShellColors[\"appBackgroundColor\"];\n}>(({ appBackgroundColor }) => ({\n backgroundColor: appBackgroundColor,\n gridArea: \"app-content\",\n pointerEvents: \"none\",\n position: \"relative\",\n}));\n\nconst StyledAppSwitcherContainer = styled(\"div\")({\n gridArea: \"app-switcher\",\n});\n\nconst StyledBannersContainer = styled(\"div\")({\n gridArea: \"banners\",\n});\n\nconst StyledSideNavContainer = styled(\"div\")({\n gridArea: \"side-nav\",\n});\n\nconst StyledShellContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n display: \"grid\",\n gridGap: 0,\n gridTemplateAreas: `\n \"banners banners banners\"\n \"app-switcher side-nav top-nav\"\n \"app-switcher side-nav app-content\"\n `,\n gridTemplateColumns: \"auto auto 1fr\",\n gridTemplateRows: \"auto auto 1fr\",\n height: \"100vh\",\n width: \"100vw\",\n}));\n\nconst StyledTopNavContainer = styled(\"div\")({\n gridArea: \"top-nav\",\n});\n\nexport type WideUiShellContentProps = UiShellNavComponentProps &\n UiShellContentProps;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst WideUiShellContent = ({\n appElement,\n appElementScrollingMode,\n appSwitcherProps,\n hasStandardAppContentPadding = true,\n initialVisibleSections = [\"TopNav\", \"SideNav\", \"AppSwitcher\"],\n onError = console.error,\n optionalComponents,\n sideNavProps,\n topNavProps,\n}: WideUiShellContentProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n const { isContentScrolled } = useScrollState(appElement);\n\n const sideNavContainerRef = useRef<HTMLDivElement>(null);\n const topNavContainerRef = useRef<HTMLDivElement>(null);\n const uiShellAppAreaRef = useRef<HTMLDivElement>(null);\n\n const { parentContainerRef } = useMatchAppElementToUiShellAppArea({\n appElement,\n appElementScrollingMode,\n paddingMode: hasStandardAppContentPadding ? \"comfortable\" : \"none\",\n uiShellAppAreaRef,\n uiShellResizableRefs: [\n sideNavContainerRef,\n topNavContainerRef,\n uiShellAppAreaRef,\n ],\n });\n\n return (\n <StyledShellContainer\n odysseyDesignTokens={odysseyDesignTokens}\n ref={parentContainerRef}\n >\n <StyledBannersContainer>\n {optionalComponents?.banners}\n </StyledBannersContainer>\n\n <StyledAppSwitcherContainer>\n {\n /* If AppSwitcher should be initially visible and we have not yet received props, render AppSwitcher in the loading state */\n initialVisibleSections?.includes(\"AppSwitcher\") &&\n !appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher isLoading appIcons={[]} selectedAppName=\"\" />\n </ErrorBoundary>\n )\n }\n\n {appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher {...appSwitcherProps} />\n </ErrorBoundary>\n )}\n </StyledAppSwitcherContainer>\n\n <StyledSideNavContainer ref={sideNavContainerRef}>\n {\n /* If SideNav should be initially visible and we have not yet received props, render SideNav with minimal inputs */\n initialVisibleSections?.includes(\"SideNav\") &&\n sideNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav isLoading sideNavItems={emptySideNavItems} />\n </ErrorBoundary>\n )\n }\n\n {sideNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav\n {...{\n ...sideNavProps,\n ...(sideNavProps.hasCustomFooter &&\n optionalComponents?.sideNavFooter\n ? {\n footerComponent: optionalComponents.sideNavFooter,\n footerItems: undefined,\n hasCustomFooter: sideNavProps.hasCustomFooter,\n }\n : {\n footerItems: sideNavProps.footerItems,\n hasCustomFooter: false,\n }),\n }}\n />\n </ErrorBoundary>\n )}\n </StyledSideNavContainer>\n\n <StyledTopNavContainer ref={topNavContainerRef}>\n {\n /* If TopNav should be initially visible and we have not yet received props, render Topnav with minimal inputs */\n initialVisibleSections?.includes(\"TopNav\") &&\n topNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )\n }\n\n {topNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n {...topNavProps}\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )}\n </StyledTopNavContainer>\n\n <StyledAppContainer\n appBackgroundColor={uiShellContext?.appBackgroundColor}\n tabIndex={0}\n ref={uiShellAppAreaRef}\n >\n <InnerAppContainer isContentScrolled={isContentScrolled} />\n </StyledAppContainer>\n </StyledShellContainer>\n );\n};\n\nconst MemoizedWideUiShellContent = memo(WideUiShellContent);\nMemoizedWideUiShellContent.displayName = \"WideUiShellContent\";\n\nexport { MemoizedWideUiShellContent as WideUiShell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OAAA,CAAA6E,MAAM;UACLC,iBAAiB,EAAErC,kBAAkB,EAAEsC,cAAe;UACtDC,kBAAkB,EAAEvC,kBAAkB,EAAEwC;QAAgB,CACzD;MAAC,CACW,CAChB,EAGJtC,WAAW,IACV,IAAAtC,WAAA,CAAAuD,GAAA,EAACjE,mBAAA,CAAAoE,aAAa;QAACC,QAAQ,EAAE,IAAK;QAAC1B,OAAO,EAAEA,OAAQ;QAAAqB,QAAA,EAC9C,IAAAtD,WAAA,CAAAuD,GAAA,EAAC5D,OAAA,CAAA6E,MAAM;UAAA,GACDlC,WAAW;UACfmC,iBAAiB,EAAErC,kBAAkB,EAAEsC,cAAe;UACtDC,kBAAkB,EAAEvC,kBAAkB,EAAEwC;QAAgB,CACzD;MAAC,CACW,CAChB;IAAA,CACoB,CAAC,EAExB,IAAA5E,WAAA,CAAAuD,GAAA,EAACnD,kBAAkB;MACjBI,kBAAkB,EAAEgC,cAAc,EAAEhC,kBAAmB;MACvDqE,QAAQ,EAAE,CAAE;MACZxB,GAAG,EAAEN,iBAAkB;MAAAO,QAAA,EAEvB,IAAAtD,WAAA,CAAAuD,GAAA,EAAC/D,kBAAA,CAAAsF,iBAAiB;QAACpC,iBAAiB,EAAEA;MAAkB,CAAE;IAAC,CACzC,CAAC;EAAA,CACD,CAAC;AAE3B,CAAC;AAED,MAAMqC,0BAA0B,GAAAC,OAAA,CAAArD,kBAAA,GAAG,IAAAsD,WAAI,EAACtD,kBAAkB,CAAC;AAC3DoD,0BAA0B,CAACG,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"WideUiShellContent.cjs","names":["_styled","_interopRequireDefault","require","_react","_reactErrorBoundary","_index","_InnerAppContainer","_OdysseyDesignTokensContext","_index2","_index3","_useScrollState","_useMatchAppElementToUiShellAppArea","_UiShellProvider","_uiShellSharedConstants","_jsxRuntime","e","__esModule","default","appSwitcherDefaultAppIcons","StyledAppContainer","styled","shouldForwardProp","prop","appBackgroundColor","backgroundColor","gridArea","pointerEvents","position","StyledAppSwitcherContainer","StyledBannersContainer","StyledSideNavContainer","StyledShellContainer","odysseyDesignTokens","HueNeutral50","display","gridGap","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","width","StyledTopNavContainer","WideUiShellContent","appElement","appElementScrollingMode","appSwitcherProps","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","optionalComponents","sideNavProps","topNavProps","useOdysseyDesignTokens","uiShellContext","useUiShellContext","isContentScrolled","useScrollState","sideNavContainerRef","useRef","topNavContainerRef","uiShellAppAreaRef","parentContainerRef","useMatchAppElementToUiShellAppArea","paddingMode","uiShellResizableRefs","jsxs","ref","children","jsx","banners","includes","ErrorBoundary","fallback","AppSwitcher","appIcons","isLoading","selectedAppName","undefined","SideNav","sideNavItems","emptySideNavItems","hasCustomFooter","sideNavFooter","footerComponent","footerItems","TopNav","leftSideComponent","topNavLeftSide","rightSideComponent","topNavRightSide","tabIndex","InnerAppContainer","MemoizedWideUiShellContent","exports","memo","displayName"],"sources":["../../../src/ui-shell/WideUiShellContent.tsx"],"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 styled from \"@emotion/styled\";\nimport { memo, useRef } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { AppSwitcher } from \"./AppSwitcher/index.js\";\nimport { AppSwitcherAppIconData } from \"./AppSwitcher/AppSwitcherApp.js\";\nimport { InnerAppContainer } from \"./InnerAppContainer.js\";\nimport {\n useOdysseyDesignTokens,\n type DesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport { SideNav } from \"./SideNav/index.js\";\nimport { TopNav } from \"./TopNav/index.js\";\nimport { useScrollState } from \"./useScrollState.js\";\nimport { useMatchAppElementToUiShellAppArea } from \"./useMatchAppElementToUiShellAppArea.js\";\nimport {\n UiShellNavComponentProps,\n UiShellContentProps,\n} from \"./uiShellContentTypes.js\";\nimport { UiShellColors, useUiShellContext } from \"./UiShellProvider.js\";\nimport { emptySideNavItems } from \"./uiShellSharedConstants.js\";\n\nconst appSwitcherDefaultAppIcons = [] satisfies AppSwitcherAppIconData[];\n\nconst StyledAppContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"appBackgroundColor\" && prop !== \"odysseyDesignTokens\",\n})<{\n appBackgroundColor?: UiShellColors[\"appBackgroundColor\"];\n}>(({ appBackgroundColor }) => ({\n backgroundColor: appBackgroundColor,\n gridArea: \"app-content\",\n pointerEvents: \"none\",\n position: \"relative\",\n}));\n\nconst StyledAppSwitcherContainer = styled(\"div\")({\n gridArea: \"app-switcher\",\n});\n\nconst StyledBannersContainer = styled(\"div\")({\n gridArea: \"banners\",\n});\n\nconst StyledSideNavContainer = styled(\"div\")({\n gridArea: \"side-nav\",\n});\n\nconst StyledShellContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n display: \"grid\",\n gridGap: 0,\n gridTemplateAreas: `\n \"banners banners banners\"\n \"app-switcher side-nav top-nav\"\n \"app-switcher side-nav app-content\"\n `,\n gridTemplateColumns: \"auto auto 1fr\",\n gridTemplateRows: \"auto auto 1fr\",\n height: \"100vh\",\n width: \"100vw\",\n}));\n\nconst StyledTopNavContainer = styled(\"div\")({\n gridArea: \"top-nav\",\n});\n\nexport type WideUiShellContentProps = UiShellNavComponentProps &\n UiShellContentProps;\n\n/**\n * Our new Unified Platform UI Shell.\n *\n * This includes the top and side navigation as well as the footer and provides a spot for your app to render into.\n *\n * If an error occurs, this will revert to only showing the app.\n */\nconst WideUiShellContent = ({\n appElement,\n appElementScrollingMode,\n appSwitcherProps,\n hasStandardAppContentPadding = true,\n initialVisibleSections = [\"TopNav\", \"SideNav\", \"AppSwitcher\"],\n onError = console.error,\n optionalComponents,\n sideNavProps,\n topNavProps,\n}: WideUiShellContentProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const uiShellContext = useUiShellContext();\n\n const { isContentScrolled } = useScrollState(appElement);\n\n const sideNavContainerRef = useRef<HTMLDivElement>(null);\n const topNavContainerRef = useRef<HTMLDivElement>(null);\n const uiShellAppAreaRef = useRef<HTMLDivElement>(null);\n\n const { parentContainerRef } = useMatchAppElementToUiShellAppArea({\n appElement,\n appElementScrollingMode,\n paddingMode: hasStandardAppContentPadding ? \"comfortable\" : \"none\",\n uiShellAppAreaRef,\n uiShellResizableRefs: [\n sideNavContainerRef,\n topNavContainerRef,\n uiShellAppAreaRef,\n ],\n });\n\n return (\n <StyledShellContainer\n odysseyDesignTokens={odysseyDesignTokens}\n ref={parentContainerRef}\n >\n <StyledBannersContainer>\n {optionalComponents?.banners}\n </StyledBannersContainer>\n\n <StyledAppSwitcherContainer>\n {\n /* If AppSwitcher should be initially visible and we have not yet received props, render AppSwitcher in the loading state */\n initialVisibleSections?.includes(\"AppSwitcher\") &&\n !appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher\n appIcons={appSwitcherDefaultAppIcons}\n isLoading\n selectedAppName=\"\"\n />\n </ErrorBoundary>\n )\n }\n\n {appSwitcherProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <AppSwitcher {...appSwitcherProps} />\n </ErrorBoundary>\n )}\n </StyledAppSwitcherContainer>\n\n <StyledSideNavContainer ref={sideNavContainerRef}>\n {\n /* If SideNav should be initially visible and we have not yet received props, render SideNav with minimal inputs */\n initialVisibleSections?.includes(\"SideNav\") &&\n sideNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav isLoading sideNavItems={emptySideNavItems} />\n </ErrorBoundary>\n )\n }\n\n {sideNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <SideNav\n {...{\n ...sideNavProps,\n ...(sideNavProps.hasCustomFooter &&\n optionalComponents?.sideNavFooter\n ? {\n footerComponent: optionalComponents.sideNavFooter,\n footerItems: undefined,\n hasCustomFooter: sideNavProps.hasCustomFooter,\n }\n : {\n footerItems: sideNavProps.footerItems,\n hasCustomFooter: false,\n }),\n }}\n />\n </ErrorBoundary>\n )}\n </StyledSideNavContainer>\n\n <StyledTopNavContainer ref={topNavContainerRef}>\n {\n /* If TopNav should be initially visible and we have not yet received props, render Topnav with minimal inputs */\n initialVisibleSections?.includes(\"TopNav\") &&\n topNavProps === undefined && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )\n }\n\n {topNavProps && (\n <ErrorBoundary fallback={null} onError={onError}>\n <TopNav\n {...topNavProps}\n leftSideComponent={optionalComponents?.topNavLeftSide}\n rightSideComponent={optionalComponents?.topNavRightSide}\n />\n </ErrorBoundary>\n )}\n </StyledTopNavContainer>\n\n <StyledAppContainer\n appBackgroundColor={uiShellContext?.appBackgroundColor}\n tabIndex={0}\n ref={uiShellAppAreaRef}\n >\n <InnerAppContainer isContentScrolled={isContentScrolled} />\n </StyledAppContainer>\n </StyledShellContainer>\n );\n};\n\nconst MemoizedWideUiShellContent = memo(WideUiShellContent);\nMemoizedWideUiShellContent.displayName = \"WideUiShellContent\";\n\nexport { MemoizedWideUiShellContent as WideUiShellContent };\n"],"mappings":";;;;;;AAYA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA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,CACW,CAChB,EAGJtC,WAAW,IACV,IAAAvC,WAAA,CAAAwD,GAAA,EAAClE,mBAAA,CAAAqE,aAAa;QAACC,QAAQ,EAAE,IAAK;QAAC1B,OAAO,EAAEA,OAAQ;QAAAqB,QAAA,EAC9C,IAAAvD,WAAA,CAAAwD,GAAA,EAAC7D,OAAA,CAAA8E,MAAM;UAAA,GACDlC,WAAW;UACfmC,iBAAiB,EAAErC,kBAAkB,EAAEsC,cAAe;UACtDC,kBAAkB,EAAEvC,kBAAkB,EAAEwC;QAAgB,CACzD;MAAC,CACW,CAChB;IAAA,CACoB,CAAC,EAExB,IAAA7E,WAAA,CAAAwD,GAAA,EAACnD,kBAAkB;MACjBI,kBAAkB,EAAEgC,cAAc,EAAEhC,kBAAmB;MACvDqE,QAAQ,EAAE,CAAE;MACZxB,GAAG,EAAEN,iBAAkB;MAAAO,QAAA,EAEvB,IAAAvD,WAAA,CAAAwD,GAAA,EAAChE,kBAAA,CAAAuF,iBAAiB;QAACpC,iBAAiB,EAAEA;MAAkB,CAAE;IAAC,CACzC,CAAC;EAAA,CACD,CAAC;AAE3B,CAAC;AAED,MAAMqC,0BAA0B,GAAAC,OAAA,CAAArD,kBAAA,GAAG,IAAAsD,WAAI,EAACtD,kBAAkB,CAAC;AAC3DoD,0BAA0B,CAACG,WAAW,GAAG,oBAAoB","ignoreList":[]}
|
|
@@ -100,7 +100,7 @@ const useMatchAppElementToUiShellAppArea = ({
|
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
102
|
return () => {};
|
|
103
|
-
}, [appElement, appContainerElementStyles, uiShellAppAreaRef]);
|
|
103
|
+
}, [appElement, appContainerElementStyles, uiShellAppAreaRef, uiShellResizableRefs]);
|
|
104
104
|
return {
|
|
105
105
|
parentContainerRef
|
|
106
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMatchAppElementToUiShellAppArea.cjs","names":["_react","require","_OdysseyDesignTokensContext","convertCamelCaseToKebabCase","string","replace","toLowerCase","exports","setStylesToMatchElement","additionalStyles","appContainerElement","appContentReferenceElement","parentElement","appContentReferenceRectangle","getBoundingClientRect","parentElementRectangle","style","setProperty","top","left","width","height","Object","entries","forEach","cssPropertyName","cssPropertyValue","String","useMatchAppElementToUiShellAppArea","appElement","appElementScrollingMode","paddingMode","uiShellAppAreaRef","uiShellResizableRefs","odysseyDesignTokens","useOdysseyDesignTokens","parentContainerRef","useRef","appContainerElementStyles","useMemo","boxSizing","zIndex","paddingBlock","Spacing5","paddingInline","Spacing8","overflowX","overflowY","useEffect","current","animationFrameId","updateStyles","cancelAnimationFrame","requestAnimationFrame","resizingElements","map","resizingRef","filter","element","Boolean","observer","ResizeObserver","resizingElement","addEventListener","observe","disconnect","removeEventListener"],"sources":["../../../src/ui-shell/useMatchAppElementToUiShellAppArea.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 { CSSProperties, RefObject, useEffect, useMemo, useRef } from \"react\";\n\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext.js\";\nimport { UiShellContentProps } from \"./uiShellContentTypes.js\";\n\nexport const convertCamelCaseToKebabCase = (string: string) =>\n string.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\nexport const setStylesToMatchElement = ({\n additionalStyles,\n appContainerElement,\n appContentReferenceElement,\n parentElement,\n}: {\n additionalStyles: CSSProperties;\n appContainerElement: HTMLElement;\n appContentReferenceElement: HTMLElement;\n parentElement: HTMLElement;\n}) => {\n const appContentReferenceRectangle =\n appContentReferenceElement.getBoundingClientRect();\n const parentElementRectangle = parentElement.getBoundingClientRect();\n\n appContainerElement.style.setProperty(\"position\", \"absolute\");\n appContainerElement.style.setProperty(\n \"top\",\n `${appContentReferenceRectangle.top - parentElementRectangle.top}px`,\n );\n appContainerElement.style.setProperty(\n \"left\",\n `${appContentReferenceRectangle.left - parentElementRectangle.left}px`,\n );\n appContainerElement.style.setProperty(\n \"width\",\n `${appContentReferenceRectangle.width}px`,\n );\n appContainerElement.style.setProperty(\n \"height\",\n `${appContentReferenceRectangle.height}px`,\n );\n\n (\n Object.entries(additionalStyles) as Array<\n [\n keyof typeof additionalStyles,\n (typeof additionalStyles)[keyof typeof additionalStyles],\n ]\n >\n ).forEach(([cssPropertyName, cssPropertyValue]) => {\n appContainerElement.style.setProperty(\n convertCamelCaseToKebabCase(cssPropertyName),\n String(cssPropertyValue),\n );\n });\n};\n\nexport type UseMatchAppElementToUiShellAppAreaProps = {\n /**\n * Padding around the app area. \"comfortable\" is designed for wider views whereas \"compact\" is designed for narrower views.\n */\n paddingMode: \"comfortable\" | \"compact\" | \"none\";\n /**\n * Ref for the App Container in UI Shell. This should be the one inside the Shell, **not** the element we're going to align.\n */\n uiShellAppAreaRef: RefObject<HTMLDivElement>;\n /**\n * Array of refs of items that indirectly resize the app content area such as \"side nav\" and \"top nav\".\n */\n uiShellResizableRefs: Array<RefObject<HTMLDivElement>>;\n} & Pick<UiShellContentProps, \"appElement\" | \"appElementScrollingMode\">;\n\nexport const useMatchAppElementToUiShellAppArea = ({\n appElement,\n appElementScrollingMode,\n paddingMode,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n}: UseMatchAppElementToUiShellAppAreaProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n\n const appContainerElementStyles = useMemo<CSSProperties>(\n () => ({\n boxSizing: \"border-box\",\n zIndex: 1,\n ...(paddingMode === \"comfortable\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing8,\n }\n : {}),\n\n ...(paddingMode === \"compact\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing5,\n }\n : {}),\n\n ...(appElementScrollingMode === \"horizontal\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowX: \"auto\",\n }\n : {\n overflowX: \"hidden\",\n }),\n\n ...(appElementScrollingMode === \"vertical\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowY: \"auto\",\n }\n : {\n overflowY: \"hidden\",\n }),\n }),\n [appElementScrollingMode, paddingMode, odysseyDesignTokens],\n );\n\n useEffect(() => {\n // Once `appContainerRef` is rendered, we can position `appContainerElement` on top to match.\n if (uiShellAppAreaRef.current && appElement && parentContainerRef.current) {\n let animationFrameId: number;\n\n const updateStyles = () => {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = requestAnimationFrame(() => {\n if (uiShellAppAreaRef.current && parentContainerRef.current) {\n setStylesToMatchElement({\n additionalStyles: appContainerElementStyles,\n appContentReferenceElement: uiShellAppAreaRef.current,\n appContainerElement: appElement,\n parentElement: parentContainerRef.current,\n });\n }\n });\n };\n\n // These refs might change by the time we unsubscribe, so we need to keep references to the original elements.\n const resizingElements = uiShellResizableRefs\n .map((resizingRef) => resizingRef.current)\n .filter((element): element is NonNullable<typeof element> =>\n Boolean(element),\n );\n\n // Set up a mutation observer to sync later updates\n const observer = new ResizeObserver(updateStyles);\n\n // document.addEventListener(\"ready\", updateStyles);\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.addEventListener(\"transitionend\", updateStyles);\n\n observer.observe(resizingElement);\n });\n\n // Set the initial styles\n updateStyles();\n\n return () => {\n observer.disconnect();\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.removeEventListener(\"transitionend\", updateStyles);\n });\n };\n }\n return () => {};\n }, [appElement, appContainerElementStyles, uiShellAppAreaRef]);\n\n return {\n parentContainerRef,\n };\n};\n"],"mappings":";;;;;;AAYA,IAAAA,MAA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,"file":"useMatchAppElementToUiShellAppArea.cjs","names":["_react","require","_OdysseyDesignTokensContext","convertCamelCaseToKebabCase","string","replace","toLowerCase","exports","setStylesToMatchElement","additionalStyles","appContainerElement","appContentReferenceElement","parentElement","appContentReferenceRectangle","getBoundingClientRect","parentElementRectangle","style","setProperty","top","left","width","height","Object","entries","forEach","cssPropertyName","cssPropertyValue","String","useMatchAppElementToUiShellAppArea","appElement","appElementScrollingMode","paddingMode","uiShellAppAreaRef","uiShellResizableRefs","odysseyDesignTokens","useOdysseyDesignTokens","parentContainerRef","useRef","appContainerElementStyles","useMemo","boxSizing","zIndex","paddingBlock","Spacing5","paddingInline","Spacing8","overflowX","overflowY","useEffect","current","animationFrameId","updateStyles","cancelAnimationFrame","requestAnimationFrame","resizingElements","map","resizingRef","filter","element","Boolean","observer","ResizeObserver","resizingElement","addEventListener","observe","disconnect","removeEventListener"],"sources":["../../../src/ui-shell/useMatchAppElementToUiShellAppArea.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 { CSSProperties, RefObject, useEffect, useMemo, useRef } from \"react\";\n\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext.js\";\nimport { UiShellContentProps } from \"./uiShellContentTypes.js\";\n\nexport const convertCamelCaseToKebabCase = (string: string) =>\n string.replace(/([A-Z])/g, \"-$1\").toLowerCase();\n\nexport const setStylesToMatchElement = ({\n additionalStyles,\n appContainerElement,\n appContentReferenceElement,\n parentElement,\n}: {\n additionalStyles: CSSProperties;\n appContainerElement: HTMLElement;\n appContentReferenceElement: HTMLElement;\n parentElement: HTMLElement;\n}) => {\n const appContentReferenceRectangle =\n appContentReferenceElement.getBoundingClientRect();\n const parentElementRectangle = parentElement.getBoundingClientRect();\n\n appContainerElement.style.setProperty(\"position\", \"absolute\");\n appContainerElement.style.setProperty(\n \"top\",\n `${appContentReferenceRectangle.top - parentElementRectangle.top}px`,\n );\n appContainerElement.style.setProperty(\n \"left\",\n `${appContentReferenceRectangle.left - parentElementRectangle.left}px`,\n );\n appContainerElement.style.setProperty(\n \"width\",\n `${appContentReferenceRectangle.width}px`,\n );\n appContainerElement.style.setProperty(\n \"height\",\n `${appContentReferenceRectangle.height}px`,\n );\n\n (\n Object.entries(additionalStyles) as Array<\n [\n keyof typeof additionalStyles,\n (typeof additionalStyles)[keyof typeof additionalStyles],\n ]\n >\n ).forEach(([cssPropertyName, cssPropertyValue]) => {\n appContainerElement.style.setProperty(\n convertCamelCaseToKebabCase(cssPropertyName),\n String(cssPropertyValue),\n );\n });\n};\n\nexport type UseMatchAppElementToUiShellAppAreaProps = {\n /**\n * Padding around the app area. \"comfortable\" is designed for wider views whereas \"compact\" is designed for narrower views.\n */\n paddingMode: \"comfortable\" | \"compact\" | \"none\";\n /**\n * Ref for the App Container in UI Shell. This should be the one inside the Shell, **not** the element we're going to align.\n */\n uiShellAppAreaRef: RefObject<HTMLDivElement>;\n /**\n * Array of refs of items that indirectly resize the app content area such as \"side nav\" and \"top nav\".\n */\n uiShellResizableRefs: Array<RefObject<HTMLDivElement>>;\n} & Pick<UiShellContentProps, \"appElement\" | \"appElementScrollingMode\">;\n\nexport const useMatchAppElementToUiShellAppArea = ({\n appElement,\n appElementScrollingMode,\n paddingMode,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n}: UseMatchAppElementToUiShellAppAreaProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const parentContainerRef = useRef<HTMLDivElement>(null);\n\n const appContainerElementStyles = useMemo<CSSProperties>(\n () => ({\n boxSizing: \"border-box\",\n zIndex: 1,\n ...(paddingMode === \"comfortable\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing8,\n }\n : {}),\n\n ...(paddingMode === \"compact\"\n ? {\n paddingBlock: odysseyDesignTokens.Spacing5,\n paddingInline: odysseyDesignTokens.Spacing5,\n }\n : {}),\n\n ...(appElementScrollingMode === \"horizontal\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowX: \"auto\",\n }\n : {\n overflowX: \"hidden\",\n }),\n\n ...(appElementScrollingMode === \"vertical\" ||\n appElementScrollingMode === \"both\"\n ? {\n overflowY: \"auto\",\n }\n : {\n overflowY: \"hidden\",\n }),\n }),\n [appElementScrollingMode, paddingMode, odysseyDesignTokens],\n );\n\n useEffect(() => {\n // Once `appContainerRef` is rendered, we can position `appContainerElement` on top to match.\n if (uiShellAppAreaRef.current && appElement && parentContainerRef.current) {\n let animationFrameId: number;\n\n const updateStyles = () => {\n cancelAnimationFrame(animationFrameId);\n\n animationFrameId = requestAnimationFrame(() => {\n if (uiShellAppAreaRef.current && parentContainerRef.current) {\n setStylesToMatchElement({\n additionalStyles: appContainerElementStyles,\n appContentReferenceElement: uiShellAppAreaRef.current,\n appContainerElement: appElement,\n parentElement: parentContainerRef.current,\n });\n }\n });\n };\n\n // These refs might change by the time we unsubscribe, so we need to keep references to the original elements.\n const resizingElements = uiShellResizableRefs\n .map((resizingRef) => resizingRef.current)\n .filter((element): element is NonNullable<typeof element> =>\n Boolean(element),\n );\n\n // Set up a mutation observer to sync later updates\n const observer = new ResizeObserver(updateStyles);\n\n // document.addEventListener(\"ready\", updateStyles);\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.addEventListener(\"transitionend\", updateStyles);\n\n observer.observe(resizingElement);\n });\n\n // Set the initial styles\n updateStyles();\n\n return () => {\n observer.disconnect();\n\n resizingElements.forEach((resizingElement) => {\n resizingElement.removeEventListener(\"transitionend\", updateStyles);\n });\n };\n }\n return () => {};\n }, [\n appElement,\n appContainerElementStyles,\n uiShellAppAreaRef,\n uiShellResizableRefs,\n ]);\n\n return {\n parentContainerRef,\n };\n};\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,2BAAA,GAAAD,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,MAAME,2BAA2B,GAAIC,MAAc,IACxDA,MAAM,CAACC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAACC,WAAW,CAAC,CAAC;AAACC,OAAA,CAAAJ,2BAAA,GAAAA,2BAAA;AAE3C,MAAMK,uBAAuB,GAAGA,CAAC;EACtCC,gBAAgB;EAChBC,mBAAmB;EACnBC,0BAA0B;EAC1BC;AAMF,CAAC,KAAK;EACJ,MAAMC,4BAA4B,GAChCF,0BAA0B,CAACG,qBAAqB,CAAC,CAAC;EACpD,MAAMC,sBAAsB,GAAGH,aAAa,CAACE,qBAAqB,CAAC,CAAC;EAEpEJ,mBAAmB,CAACM,KAAK,CAACC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC;EAC7DP,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,KAAK,EACL,GAAGJ,4BAA4B,CAACK,GAAG,GAAGH,sBAAsB,CAACG,GAAG,IAClE,CAAC;EACDR,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,MAAM,EACN,GAAGJ,4BAA4B,CAACM,IAAI,GAAGJ,sBAAsB,CAACI,IAAI,IACpE,CAAC;EACDT,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,OAAO,EACP,GAAGJ,4BAA4B,CAACO,KAAK,IACvC,CAAC;EACDV,mBAAmB,CAACM,KAAK,CAACC,WAAW,CACnC,QAAQ,EACR,GAAGJ,4BAA4B,CAACQ,MAAM,IACxC,CAAC;EAGCC,MAAM,CAACC,OAAO,CAACd,gBAAgB,CAAC,CAMhCe,OAAO,CAAC,CAAC,CAACC,eAAe,EAAEC,gBAAgB,CAAC,K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CACrB,CAAC;EAEF,OAAO;IACLG;EACF,CAAC;AACH,CAAC;AAAC7B,OAAA,CAAAqB,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
40
|
-
|
|
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","
|
|
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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"__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",
|
|
24
|
-
stylesRootElement.setAttribute("id",
|
|
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"
|
|
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":[]}
|
|
@@ -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,
|
|
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;EACnCC,YAAY;EACZC,aAAa,GAAGA,CAAA,KAAM,IAAI;EAC1BC,cAAc,GAAGA,CAAA,KAAM,IAAI;EAC3BC,aAAa,GAAGA,CAAA,KAAM,IAAI;EAC1BC,OAAO,EAAEC,WAAW;EACpBC,OAAO,EAAEC,WAAW;EACpBC,aAAa,EAAEC,iBAAiB;EAChCC,QAAQ,GAAG,QAAQ;EACnBC;AAawC,CAAC,KAAK;EAC9C,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGhC,QAAQ,CAAC,KAAK,CAAC;EAC3C,MAAM,CAACiC,aAAa,EAAEC,gBAAgB,CAAC,GAAGlC,QAAQ,CAA0B,CAAC;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BAAgB;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,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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AClB,CAAC,EAAE,CAACA,SAAS,CAAC,CAAC;EAEf,MAAMuC,eAAe,GAAIZ,IAAc,IAAKA,IAAI,CAACa,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":[]}
|
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,
|
package/dist/esm/Field.js.map
CHANGED
|
@@ -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","
|
|
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 { Memoized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