@okta/odyssey-react-mui 1.40.0 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Autocomplete.cjs +10 -10
- package/dist/cjs/Autocomplete.cjs.map +1 -1
- package/dist/cjs/Breadcrumbs.cjs +1 -0
- package/dist/cjs/Breadcrumbs.cjs.map +1 -1
- package/dist/cjs/Link.cjs.map +1 -1
- package/dist/cjs/OdysseyCacheProvider.cjs.map +1 -1
- package/dist/cjs/Tag.cjs +9 -2
- package/dist/cjs/Tag.cjs.map +1 -1
- package/dist/cjs/properties/ts/odyssey-react-mui.cjs +2 -1
- package/dist/cjs/properties/ts/odyssey-react-mui.cjs.map +1 -1
- package/dist/cjs/theme/components.cjs +1 -0
- package/dist/cjs/theme/components.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs +10 -10
- package/dist/cjs/ui-shell/SideNav/SideNavToggleButton.cjs.map +1 -1
- package/dist/cjs/ui-shell/renderUiShell.cjs +2 -2
- package/dist/cjs/ui-shell/renderUiShell.cjs.map +1 -1
- package/dist/cjs/ui-shell/useScrollState.cjs +4 -2
- package/dist/cjs/ui-shell/useScrollState.cjs.map +1 -1
- package/dist/cjs/useAutocomplete.cjs +2 -2
- package/dist/cjs/useAutocomplete.cjs.map +1 -1
- package/dist/cjs/web-component/odysseyWebComponentVersion.generated.cjs +1 -1
- package/dist/cjs/web-component/odysseyWebComponentVersion.generated.cjs.map +1 -1
- package/dist/esm/Autocomplete.js +10 -10
- package/dist/esm/Autocomplete.js.map +1 -1
- package/dist/esm/Breadcrumbs.js +1 -0
- package/dist/esm/Breadcrumbs.js.map +1 -1
- package/dist/esm/Link.js.map +1 -1
- package/dist/esm/OdysseyCacheProvider.js.map +1 -1
- package/dist/esm/Tag.js +9 -2
- package/dist/esm/Tag.js.map +1 -1
- package/dist/esm/properties/ts/odyssey-react-mui.js +2 -1
- package/dist/esm/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/esm/theme/components.js +1 -0
- package/dist/esm/theme/components.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js +10 -10
- package/dist/esm/ui-shell/SideNav/SideNavToggleButton.js.map +1 -1
- package/dist/esm/ui-shell/renderUiShell.js +2 -2
- package/dist/esm/ui-shell/renderUiShell.js.map +1 -1
- package/dist/esm/ui-shell/useScrollState.js +4 -2
- package/dist/esm/ui-shell/useScrollState.js.map +1 -1
- package/dist/esm/useAutocomplete.js +2 -2
- package/dist/esm/useAutocomplete.js.map +1 -1
- package/dist/esm/web-component/odysseyWebComponentVersion.generated.js +1 -1
- package/dist/esm/web-component/odysseyWebComponentVersion.generated.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.scss +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/types/Autocomplete.d.ts +1 -1
- package/dist/types/Autocomplete.d.ts.map +1 -1
- package/dist/types/Breadcrumbs.d.ts.map +1 -1
- package/dist/types/CssBaseline.d.ts.map +1 -1
- package/dist/types/DataTable/reorderDataRowsLocally.d.ts.map +1 -1
- package/dist/types/DataTable/useRowReordering.d.ts.map +1 -1
- package/dist/types/DataTable/useScrollIndication.d.ts.map +1 -1
- package/dist/types/DatePickers/useOdysseyDateFields.d.ts.map +1 -1
- package/dist/types/Link.d.ts +3 -3
- package/dist/types/Link.d.ts.map +1 -1
- package/dist/types/NativeSelect.d.ts.map +1 -1
- package/dist/types/OdysseyCacheProvider.d.ts.map +1 -1
- package/dist/types/OdysseyTranslationProvider.d.ts +1 -1
- package/dist/types/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/types/Pagination/usePagination.d.ts.map +1 -1
- package/dist/types/Tag.d.ts.map +1 -1
- package/dist/types/addSpecificity.d.ts.map +1 -1
- package/dist/types/createContrastColors.d.ts.map +1 -1
- package/dist/types/hexToRgb.d.ts.map +1 -1
- package/dist/types/i18n.d.ts +1 -0
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/inputUtils.d.ts.map +1 -1
- package/dist/types/labs/DataView/fetchData.d.ts.map +1 -1
- package/dist/types/labs/DataView/tableConstants.d.ts.map +1 -1
- package/dist/types/labs/DataView/testSupportData.d.ts.map +1 -1
- package/dist/types/labs/DataView/useFilterConversion.d.ts.map +1 -1
- package/dist/types/labs/GroupPicker.d.ts.map +1 -1
- package/dist/types/labs/OdysseyPickers/ComposablePicker.d.ts.map +1 -1
- package/dist/types/labs/OdysseyPickers/Picker.d.ts.map +1 -1
- package/dist/types/labs/OdysseyPickers/PickerVirtualizationListBox.d.ts.map +1 -1
- package/dist/types/labs/PaginatedTable.d.ts.map +1 -1
- package/dist/types/labs/StaticTable.d.ts.map +1 -1
- package/dist/types/properties/ts/odyssey-react-mui.d.ts +1 -0
- package/dist/types/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/types/remUtils.d.ts.map +1 -1
- package/dist/types/shadow-dom/shadow-dom.d.ts.map +1 -1
- package/dist/types/test-selectors/getByQuerySelector.d.ts.map +1 -1
- package/dist/types/test-selectors/getComputedAccessibleErrorMessageText.d.ts.map +1 -1
- package/dist/types/test-selectors/getComputedAccessibleText.d.ts.map +1 -1
- package/dist/types/test-selectors/interpolateString.d.ts.map +1 -1
- package/dist/types/test-selectors/linkedHtmlSelectors.d.ts.map +1 -1
- package/dist/types/test-selectors/queryOdysseySelector.d.ts +40 -36
- package/dist/types/test-selectors/queryOdysseySelector.d.ts.map +1 -1
- package/dist/types/test-selectors/querySelector.d.ts +6 -2
- package/dist/types/test-selectors/querySelector.d.ts.map +1 -1
- package/dist/types/test-selectors/sanityChecks.d.ts.map +1 -1
- package/dist/types/theme/components.d.ts.map +1 -1
- package/dist/types/theme/createOdysseyMuiTheme.d.ts.map +1 -1
- package/dist/types/theme/mixins.d.ts.map +1 -1
- package/dist/types/theme/palette.d.ts.map +1 -1
- package/dist/types/theme/pxToRem.d.ts.map +1 -1
- package/dist/types/theme/shape.d.ts.map +1 -1
- package/dist/types/theme/spacing.d.ts.map +1 -1
- package/dist/types/theme/typography.d.ts.map +1 -1
- package/dist/types/theme/useMediaQuery.d.ts.map +1 -1
- package/dist/types/ui-shell/AppSwitcher/AppSwitcherApp.d.ts.map +1 -1
- package/dist/types/ui-shell/InnerAppContainer.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemContent.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavToggleButton.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SortableList/SortableItem.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/useIsSideNavCollapsedSessionStorage.d.ts.map +1 -1
- package/dist/types/ui-shell/bufferLatest.d.ts.map +1 -1
- package/dist/types/ui-shell/createMessageBus.d.ts.map +1 -1
- package/dist/types/ui-shell/createStore.d.ts.map +1 -1
- package/dist/types/ui-shell/renderUiShell.d.ts.map +1 -1
- package/dist/types/ui-shell/useMatchAppElementToUiShellAppArea.d.ts.map +1 -1
- package/dist/types/ui-shell/useScrollState.d.ts +6 -2
- package/dist/types/ui-shell/useScrollState.d.ts.map +1 -1
- package/dist/types/ui-shell/useUiShellBreakpoints.d.ts.map +1 -1
- package/dist/types/useAutocomplete.d.ts.map +1 -1
- package/dist/types/useContrastMode.d.ts.map +1 -1
- package/dist/types/useMountLifecycleEffect.d.ts.map +1 -1
- package/dist/types/useNormalizedKey.d.ts.map +1 -1
- package/dist/types/useSessionStorageState.d.ts.map +1 -1
- package/dist/types/useUniqueAlphabeticalId.d.ts.map +1 -1
- package/dist/types/useUniqueId.d.ts.map +1 -1
- package/dist/types/web-component/odysseyWebComponentVersion.generated.d.ts +1 -1
- package/dist/types/web-component/odysseyWebComponentVersion.generated.d.ts.map +1 -1
- package/dist/types/web-component/renderReactInWebComponent.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -87,7 +87,7 @@ const StyledChevronRightIcon = (0, _styled.default)(_ChevronRight.ChevronRightIc
|
|
|
87
87
|
transitionProperty: "transform",
|
|
88
88
|
transitionTimingFunction: "ease-in-out"
|
|
89
89
|
}));
|
|
90
|
-
const defaultLocalButton = document.createElement("button");
|
|
90
|
+
const defaultLocalButton = typeof window === "undefined" ? null : document.createElement("button");
|
|
91
91
|
const SideNavToggleButton = ({
|
|
92
92
|
ariaControls,
|
|
93
93
|
clickAreaPadding = 0,
|
|
@@ -110,18 +110,18 @@ const SideNavToggleButton = ({
|
|
|
110
110
|
onHighlight?.(false);
|
|
111
111
|
};
|
|
112
112
|
const setFocusHighlighted = () => {
|
|
113
|
-
onHighlight?.(buttonRef.current
|
|
113
|
+
onHighlight?.(Boolean(buttonRef.current?.matches(":focus-visible")));
|
|
114
114
|
};
|
|
115
|
-
buttonRef.current
|
|
116
|
-
buttonRef.current
|
|
117
|
-
buttonRef.current
|
|
118
|
-
buttonRef.current
|
|
115
|
+
buttonRef.current?.addEventListener("mouseenter", setHighlighted);
|
|
116
|
+
buttonRef.current?.addEventListener("mouseleave", setUnhighlighted);
|
|
117
|
+
buttonRef.current?.addEventListener("focus", setFocusHighlighted, true);
|
|
118
|
+
buttonRef.current?.addEventListener("blur", setFocusHighlighted, true);
|
|
119
119
|
setUnhighlighted();
|
|
120
120
|
return () => {
|
|
121
|
-
buttonRef.current
|
|
122
|
-
buttonRef.current
|
|
123
|
-
buttonRef.current
|
|
124
|
-
buttonRef.current
|
|
121
|
+
buttonRef.current?.removeEventListener("mouseenter", setHighlighted);
|
|
122
|
+
buttonRef.current?.removeEventListener("mouseleave", setUnhighlighted);
|
|
123
|
+
buttonRef.current?.removeEventListener("focus", setFocusHighlighted, true);
|
|
124
|
+
buttonRef.current?.removeEventListener("blur", setFocusHighlighted, true);
|
|
125
125
|
};
|
|
126
126
|
}, [onHighlight]);
|
|
127
127
|
const toggleLabel = (0, _react.useMemo)(() => isSideNavCollapsed ? t("sidenav.toggle.expand") : t("sidenav.toggle.collapse"), [isSideNavCollapsed, t]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNavToggleButton.cjs","names":["_react","require","_styled","_interopRequireDefault","_reactI18next","_MuiPropsContext","_OdysseyDesignTokensContext","_Tooltip","_uiShellSharedConstants","_ChevronRight","_jsxRuntime","e","__esModule","default","SIDE_NAV_TOGGLE_ICON_SIZE","exports","SIDE_NAV_TOGGLE_ICON_HALF_SIZE","StyledToggleButton","styled","_Button2","shouldForwardProp","prop","clickAreaPadding","odysseyDesignTokens","border","height","left","padding","position","width","zIndex","UI_SHELL_OVERLAY_Z_INDEX","backgroundColor","borderColor","boxShadow","color","PalettePrimaryText","outline","HueNeutralWhite","borderRadius","ShadowScale1","content","top","StyledChevronRightIcon","ChevronRightIcon","isSideNavCollapsed","fontSize","undefined","right","transform","transitionDuration","TransitionDurationMain","transitionProperty","transitionTimingFunction","defaultLocalButton","document","createElement","SideNavToggleButton","ariaControls","id","onClick","onHighlight","tabIndex","useOdysseyDesignTokens","t","useTranslation","buttonRef","useRef","useEffect","setHighlighted","setUnhighlighted","setFocusHighlighted","current","matches","addEventListener","removeEventListener","toggleLabel","useMemo","renderButton","useCallback","muiProps","jsx","ref","element","variant","children","Tooltip","ariaType","placement","text","MuiPropsContext","Consumer","MemoizedSideNavToggleButton","memo","displayName"],"sources":["../../../../src/ui-shell/SideNav/SideNavToggleButton.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 { Button as MuiButton } from \"@mui/material\";\nimport type { ButtonProps as MuiButtonProps } from \"@mui/material\";\nimport {\n HTMLAttributes,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { MuiPropsContext, MuiPropsContextType } from \"../../MuiPropsContext.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../OdysseyDesignTokensContext.js\";\nimport { Tooltip } from \"../../Tooltip.js\";\nimport { UI_SHELL_OVERLAY_Z_INDEX } from \"../uiShellSharedConstants.js\";\nimport { ChevronRightIcon } from \"../../icons.generated/ChevronRight.js\";\n\nexport const SIDE_NAV_TOGGLE_ICON_SIZE = 24;\nexport const SIDE_NAV_TOGGLE_ICON_HALF_SIZE = SIDE_NAV_TOGGLE_ICON_SIZE / 2;\n\nconst StyledToggleButton = styled(MuiButton, {\n shouldForwardProp: (prop) =>\n prop !== \"clickAreaPadding\" && prop !== \"odysseyDesignTokens\",\n})<{\n clickAreaPadding: number;\n odysseyDesignTokens: DesignTokens;\n}>(({ clickAreaPadding, odysseyDesignTokens }) => ({\n border: 0,\n height: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n left: `-${clickAreaPadding * 2}px`,\n padding: 0,\n position: \"relative\",\n width: `calc(${SIDE_NAV_TOGGLE_ICON_SIZE}px + (${clickAreaPadding}px * 2))`,\n zIndex: UI_SHELL_OVERLAY_Z_INDEX,\n\n // `&&` is a CSS specificity override. Used here to counteract MUI Button styles.\n \"&&\": {\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n boxShadow: \"none\",\n color: odysseyDesignTokens.PalettePrimaryText,\n },\n\n \"&:focus-visible\": {\n outline: \"none\",\n },\n\n \"&:hover, &:focus-visible\": {\n color: odysseyDesignTokens.HueNeutralWhite,\n },\n\n \"&::before\": {\n backgroundColor: odysseyDesignTokens.HueNeutralWhite,\n borderColor: \"transparent\",\n borderRadius: \"50%\",\n boxShadow: odysseyDesignTokens.ShadowScale1,\n color: odysseyDesignTokens.PalettePrimaryText,\n content: \"''\",\n height: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n left: `${clickAreaPadding * 2}px`,\n position: \"absolute\",\n top: 0,\n width: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n },\n\n \"&:hover::before, &:focus-visible::before\": {\n backgroundColor: odysseyDesignTokens.PalettePrimaryText,\n },\n}));\n\nconst StyledChevronRightIcon = styled(ChevronRightIcon, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"isSideNavCollapsed\",\n})<{\n isSideNavCollapsed: boolean;\n odysseyDesignTokens: DesignTokens;\n}>(({ isSideNavCollapsed, odysseyDesignTokens }) => ({\n fontSize: \"125%\",\n left: isSideNavCollapsed ? undefined : \"4px\",\n position: \"absolute\",\n right: isSideNavCollapsed ? \"4px\" : undefined,\n top: \"3px\",\n transform: isSideNavCollapsed ? \"rotate(0deg)\" : \"rotate(-180deg)\", // Leave this as `-180deg` so it rotates over the top, not the bottom.\n transitionDuration: odysseyDesignTokens.TransitionDurationMain,\n transitionProperty: \"transform\",\n transitionTimingFunction: \"ease-in-out\",\n}));\n\nexport type SideNavToggleButtonProps = {\n /**\n * The `id` of the item this button controls\n */\n ariaControls: string;\n /**\n * Left padding in pixels for the click area of the button.\n *\n * Useful when moving the button around when trying to click it. This ensures the click area doesn't move to the right along with the button.\n */\n clickAreaPadding?: number;\n /**\n * HTML `id` attribute for the `<button>` element.\n */\n id?: string;\n isSideNavCollapsed: boolean;\n tabIndex?: HTMLAttributes<HTMLElement>[\"tabIndex\"];\n /**\n * Click event handler for the `<button>` element.\n */\n onClick?: MuiButtonProps[\"onClick\"];\n /**\n * Provides the hovered or focused state of the `<button>` element.\n */\n onHighlight?: (isHighlighted: boolean) => void;\n onKeyDown?: MuiButtonProps[\"onKeyDown\"];\n};\n\n// This allows us to mutate the value with TypeScript. A singleton is fine because it gets overridden on render.\nconst defaultLocalButton = document.createElement(\"button\");\n\nconst SideNavToggleButton = ({\n ariaControls,\n clickAreaPadding = 0,\n id,\n isSideNavCollapsed,\n onClick,\n onHighlight,\n tabIndex,\n}: SideNavToggleButtonProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const buttonRef = useRef(defaultLocalButton);\n\n useEffect(() => {\n const setHighlighted = () => {\n onHighlight?.(true);\n };\n\n const setUnhighlighted = () => {\n onHighlight?.(false);\n };\n\n const setFocusHighlighted = () => {\n onHighlight?.(buttonRef.current.matches(\":focus-visible\"));\n };\n\n buttonRef.current.addEventListener(\"mouseenter\", setHighlighted);\n\n buttonRef.current.addEventListener(\"mouseleave\", setUnhighlighted);\n\n buttonRef.current.addEventListener(\"focus\", setFocusHighlighted, true);\n\n buttonRef.current.addEventListener(\"blur\", setFocusHighlighted, true);\n\n setUnhighlighted();\n\n return () => {\n buttonRef.current.removeEventListener(\"mouseenter\", setHighlighted);\n\n buttonRef.current.removeEventListener(\"mouseleave\", setUnhighlighted);\n\n buttonRef.current.removeEventListener(\"focus\", setFocusHighlighted, true);\n\n buttonRef.current.removeEventListener(\"blur\", setFocusHighlighted, true);\n };\n }, [onHighlight]);\n\n const toggleLabel = useMemo(\n () =>\n isSideNavCollapsed\n ? t(\"sidenav.toggle.expand\")\n : t(\"sidenav.toggle.collapse\"),\n [isSideNavCollapsed, t],\n );\n\n const renderButton = useCallback(\n (muiProps: MuiPropsContextType) => {\n return (\n <StyledToggleButton\n {...muiProps}\n aria-controls={ariaControls}\n aria-expanded={!isSideNavCollapsed}\n aria-label={toggleLabel}\n clickAreaPadding={clickAreaPadding}\n data-se=\"sidenav-toggle-button\"\n data-sidenav-toggle\n id={id}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={onClick}\n ref={(element: HTMLButtonElement) => {\n if (element) {\n buttonRef.current = element;\n //@ts-expect-error `ref` is an optional prop, but TypeScript doesn't know this.\n muiProps.ref?.(element);\n }\n }}\n tabIndex={tabIndex}\n variant=\"floating\"\n >\n <StyledChevronRightIcon\n isSideNavCollapsed={isSideNavCollapsed}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n </StyledToggleButton>\n );\n },\n [\n ariaControls,\n clickAreaPadding,\n id,\n isSideNavCollapsed,\n odysseyDesignTokens,\n onClick,\n tabIndex,\n toggleLabel,\n ],\n );\n\n return (\n <Tooltip ariaType=\"description\" placement=\"right\" text={toggleLabel}>\n <MuiPropsContext.Consumer>{renderButton}</MuiPropsContext.Consumer>\n </Tooltip>\n );\n};\n\nconst MemoizedSideNavToggleButton = memo(SideNavToggleButton);\nMemoizedSideNavToggleButton.displayName = \"SideNavToggleButton\";\n\nexport { MemoizedSideNavToggleButton as SideNavToggleButton };\n"],"mappings":";;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,2BAAA,GAAAL,OAAA;AAIA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAAyE,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAE,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAhCzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBO,MAAMG,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,EAAE;AACpC,MAAME,8BAA8B,GAAAD,OAAA,CAAAC,8BAAA,GAAGF,yBAAyB,GAAG,CAAC;AAE3E,MAAMG,kBAAkB,GAAG,IAAAC,eAAM,EAAAC,QAAA,CAAAN,OAAA,EAAY;EAC3CO,iBAAiB,EAAGC,IAAI,IACtBA,IAAI,KAAK,kBAAkB,IAAIA,IAAI,KAAK;AAC5C,CAAC,CAAC,CAGC,CAAC;EAAEC,gBAAgB;EAAEC;AAAoB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AAO,EAAE;UACXjB,SAAS,CAACM,OAAO,GAAGW,OAAO;UAE3BH,QAAQ,CAACE,GAAG,GAAGC,OAAO,CAAC;QACzB;MACF,CAAE;MACFrB,QAAQ,EAAEA,QAAS;MACnBsB,OAAO,EAAC,UAAU;MAAAC,QAAA,EAElB,IAAA3E,WAAA,CAAAuE,GAAA,EAACtC,sBAAsB;QACrBE,kBAAkB,EAAEA,kBAAmB;QACvCtB,mBAAmB,EAAEA;MAAoB,CAC1C;IAAC,CACgB,CAAC;EAEzB,CAAC,EACD,CACEmC,YAAY,EACZpC,gBAAgB,EAChBqC,EAAE,EACFd,kBAAkB,EAClBtB,mBAAmB,EACnBqC,OAAO,EACPE,QAAQ,EACRc,WAAW,CAEf,CAAC;EAED,OACE,IAAAlE,WAAA,CAAAuE,GAAA,EAAC1E,QAAA,CAAA+E,OAAO;IAACC,QAAQ,EAAC,aAAa;IAACC,SAAS,EAAC,OAAO;IAACC,IAAI,EAAEb,WAAY;IAAAS,QAAA,EAClE,IAAA3E,WAAA,CAAAuE,GAAA,EAAC5E,gBAAA,CAAAqF,eAAe,CAACC,QAAQ;MAAAN,QAAA,EAAEP;IAAY,CAA2B;EAAC,CAC5D,CAAC;AAEd,CAAC;AAED,MAAMc,2BAA2B,GAAA7E,OAAA,CAAA0C,mBAAA,GAAG,IAAAoC,WAAI,EAACpC,mBAAmB,CAAC;AAC7DmC,2BAA2B,CAACE,WAAW,GAAG,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SideNavToggleButton.cjs","names":["_react","require","_styled","_interopRequireDefault","_reactI18next","_MuiPropsContext","_OdysseyDesignTokensContext","_Tooltip","_uiShellSharedConstants","_ChevronRight","_jsxRuntime","e","__esModule","default","SIDE_NAV_TOGGLE_ICON_SIZE","exports","SIDE_NAV_TOGGLE_ICON_HALF_SIZE","StyledToggleButton","styled","_Button2","shouldForwardProp","prop","clickAreaPadding","odysseyDesignTokens","border","height","left","padding","position","width","zIndex","UI_SHELL_OVERLAY_Z_INDEX","backgroundColor","borderColor","boxShadow","color","PalettePrimaryText","outline","HueNeutralWhite","borderRadius","ShadowScale1","content","top","StyledChevronRightIcon","ChevronRightIcon","isSideNavCollapsed","fontSize","undefined","right","transform","transitionDuration","TransitionDurationMain","transitionProperty","transitionTimingFunction","defaultLocalButton","window","document","createElement","SideNavToggleButton","ariaControls","id","onClick","onHighlight","tabIndex","useOdysseyDesignTokens","t","useTranslation","buttonRef","useRef","useEffect","setHighlighted","setUnhighlighted","setFocusHighlighted","Boolean","current","matches","addEventListener","removeEventListener","toggleLabel","useMemo","renderButton","useCallback","muiProps","jsx","ref","element","variant","children","Tooltip","ariaType","placement","text","MuiPropsContext","Consumer","MemoizedSideNavToggleButton","memo","displayName"],"sources":["../../../../src/ui-shell/SideNav/SideNavToggleButton.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 { Button as MuiButton } from \"@mui/material\";\nimport type { ButtonProps as MuiButtonProps } from \"@mui/material\";\nimport {\n HTMLAttributes,\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { MuiPropsContext, MuiPropsContextType } from \"../../MuiPropsContext.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../../OdysseyDesignTokensContext.js\";\nimport { Tooltip } from \"../../Tooltip.js\";\nimport { UI_SHELL_OVERLAY_Z_INDEX } from \"../uiShellSharedConstants.js\";\nimport { ChevronRightIcon } from \"../../icons.generated/ChevronRight.js\";\n\nexport const SIDE_NAV_TOGGLE_ICON_SIZE = 24;\nexport const SIDE_NAV_TOGGLE_ICON_HALF_SIZE = SIDE_NAV_TOGGLE_ICON_SIZE / 2;\n\nconst StyledToggleButton = styled(MuiButton, {\n shouldForwardProp: (prop) =>\n prop !== \"clickAreaPadding\" && prop !== \"odysseyDesignTokens\",\n})<{\n clickAreaPadding: number;\n odysseyDesignTokens: DesignTokens;\n}>(({ clickAreaPadding, odysseyDesignTokens }) => ({\n border: 0,\n height: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n left: `-${clickAreaPadding * 2}px`,\n padding: 0,\n position: \"relative\",\n width: `calc(${SIDE_NAV_TOGGLE_ICON_SIZE}px + (${clickAreaPadding}px * 2))`,\n zIndex: UI_SHELL_OVERLAY_Z_INDEX,\n\n // `&&` is a CSS specificity override. Used here to counteract MUI Button styles.\n \"&&\": {\n backgroundColor: \"transparent\",\n borderColor: \"transparent\",\n boxShadow: \"none\",\n color: odysseyDesignTokens.PalettePrimaryText,\n },\n\n \"&:focus-visible\": {\n outline: \"none\",\n },\n\n \"&:hover, &:focus-visible\": {\n color: odysseyDesignTokens.HueNeutralWhite,\n },\n\n \"&::before\": {\n backgroundColor: odysseyDesignTokens.HueNeutralWhite,\n borderColor: \"transparent\",\n borderRadius: \"50%\",\n boxShadow: odysseyDesignTokens.ShadowScale1,\n color: odysseyDesignTokens.PalettePrimaryText,\n content: \"''\",\n height: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n left: `${clickAreaPadding * 2}px`,\n position: \"absolute\",\n top: 0,\n width: `${SIDE_NAV_TOGGLE_ICON_SIZE}px`,\n },\n\n \"&:hover::before, &:focus-visible::before\": {\n backgroundColor: odysseyDesignTokens.PalettePrimaryText,\n },\n}));\n\nconst StyledChevronRightIcon = styled(ChevronRightIcon, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" && prop !== \"isSideNavCollapsed\",\n})<{\n isSideNavCollapsed: boolean;\n odysseyDesignTokens: DesignTokens;\n}>(({ isSideNavCollapsed, odysseyDesignTokens }) => ({\n fontSize: \"125%\",\n left: isSideNavCollapsed ? undefined : \"4px\",\n position: \"absolute\",\n right: isSideNavCollapsed ? \"4px\" : undefined,\n top: \"3px\",\n transform: isSideNavCollapsed ? \"rotate(0deg)\" : \"rotate(-180deg)\", // Leave this as `-180deg` so it rotates over the top, not the bottom.\n transitionDuration: odysseyDesignTokens.TransitionDurationMain,\n transitionProperty: \"transform\",\n transitionTimingFunction: \"ease-in-out\",\n}));\n\nexport type SideNavToggleButtonProps = {\n /**\n * The `id` of the item this button controls\n */\n ariaControls: string;\n /**\n * Left padding in pixels for the click area of the button.\n *\n * Useful when moving the button around when trying to click it. This ensures the click area doesn't move to the right along with the button.\n */\n clickAreaPadding?: number;\n /**\n * HTML `id` attribute for the `<button>` element.\n */\n id?: string;\n isSideNavCollapsed: boolean;\n tabIndex?: HTMLAttributes<HTMLElement>[\"tabIndex\"];\n /**\n * Click event handler for the `<button>` element.\n */\n onClick?: MuiButtonProps[\"onClick\"];\n /**\n * Provides the hovered or focused state of the `<button>` element.\n */\n onHighlight?: (isHighlighted: boolean) => void;\n onKeyDown?: MuiButtonProps[\"onKeyDown\"];\n};\n\n// This allows us to mutate the value with TypeScript. A singleton is fine because it gets overridden on render.\nconst defaultLocalButton =\n typeof window === \"undefined\" ? null : document.createElement(\"button\");\n\nconst SideNavToggleButton = ({\n ariaControls,\n clickAreaPadding = 0,\n id,\n isSideNavCollapsed,\n onClick,\n onHighlight,\n tabIndex,\n}: SideNavToggleButtonProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const buttonRef = useRef(defaultLocalButton);\n\n useEffect(() => {\n const setHighlighted = () => {\n onHighlight?.(true);\n };\n\n const setUnhighlighted = () => {\n onHighlight?.(false);\n };\n\n const setFocusHighlighted = () => {\n onHighlight?.(Boolean(buttonRef.current?.matches(\":focus-visible\")));\n };\n\n buttonRef.current?.addEventListener(\"mouseenter\", setHighlighted);\n\n buttonRef.current?.addEventListener(\"mouseleave\", setUnhighlighted);\n\n buttonRef.current?.addEventListener(\"focus\", setFocusHighlighted, true);\n\n buttonRef.current?.addEventListener(\"blur\", setFocusHighlighted, true);\n\n setUnhighlighted();\n\n return () => {\n buttonRef.current?.removeEventListener(\"mouseenter\", setHighlighted);\n\n buttonRef.current?.removeEventListener(\"mouseleave\", setUnhighlighted);\n\n buttonRef.current?.removeEventListener(\n \"focus\",\n setFocusHighlighted,\n true,\n );\n\n buttonRef.current?.removeEventListener(\"blur\", setFocusHighlighted, true);\n };\n }, [onHighlight]);\n\n const toggleLabel = useMemo(\n () =>\n isSideNavCollapsed\n ? t(\"sidenav.toggle.expand\")\n : t(\"sidenav.toggle.collapse\"),\n [isSideNavCollapsed, t],\n );\n\n const renderButton = useCallback(\n (muiProps: MuiPropsContextType) => {\n return (\n <StyledToggleButton\n {...muiProps}\n aria-controls={ariaControls}\n aria-expanded={!isSideNavCollapsed}\n aria-label={toggleLabel}\n clickAreaPadding={clickAreaPadding}\n data-se=\"sidenav-toggle-button\"\n data-sidenav-toggle\n id={id}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={onClick}\n ref={(element: HTMLButtonElement) => {\n if (element) {\n buttonRef.current = element;\n //@ts-expect-error `ref` is an optional prop, but TypeScript doesn't know this.\n muiProps.ref?.(element);\n }\n }}\n tabIndex={tabIndex}\n variant=\"floating\"\n >\n <StyledChevronRightIcon\n isSideNavCollapsed={isSideNavCollapsed}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n </StyledToggleButton>\n );\n },\n [\n ariaControls,\n clickAreaPadding,\n id,\n isSideNavCollapsed,\n odysseyDesignTokens,\n onClick,\n tabIndex,\n toggleLabel,\n ],\n );\n\n return (\n <Tooltip ariaType=\"description\" placement=\"right\" text={toggleLabel}>\n <MuiPropsContext.Consumer>{renderButton}</MuiPropsContext.Consumer>\n </Tooltip>\n );\n};\n\nconst MemoizedSideNavToggleButton = memo(SideNavToggleButton);\nMemoizedSideNavToggleButton.displayName = \"SideNavToggleButton\";\n\nexport { MemoizedSideNavToggleButton as SideNavToggleButton };\n"],"mappings":";;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,2BAAA,GAAAL,OAAA;AAIA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAAyE,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAE,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAhCzE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBO,MAAMG,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,EAAE;AACpC,MAAME,8BAA8B,GAAAD,OAAA,CAAAC,8BAAA,GAAGF,yBAAyB,GAAG,CAAC;AAE3E,MAAMG,kBAAkB,GAAG,IAAAC,eAAM,EAAAC,QAAA,CAAAN,OAAA,EAAY;EAC3CO,iBAAiB,EAAGC,IAAI,IACtBA,IAAI,KAAK,kBAAkB,IAAIA,IAAI,KAAK;AAC5C,CAAC,CAAC,CAGC,CAAC;EAAEC,gBAAgB;EAAEC;AAAoB,CAAC,MAAM;EACjDC,MAAM,EAAE,CAAC;EACTC,MAAM,EAAE,GAAGX,yBAAyB,IAAI;EACxCY,IAAI,EAAE,IAAIJ,gBAAgB,GAAG,CAAC,IAAI;EAClCK,OAAO,EAAE,CAAC;EACVC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE,QAAQf,yBAAyB,SAASQ,gBAAgB,UAAU;EAC3EQ,MAAM,EAAEC,gDAAwB;EAGhC,IAAI,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A,EAACxC,sBAAsB;QACrBE,kBAAkB,EAAEA,kBAAmB;QACvCtB,mBAAmB,EAAEA;MAAoB,CAC1C;IAAC,CACgB,CAAC;EAEzB,CAAC,EACD,CACEoC,YAAY,EACZrC,gBAAgB,EAChBsC,EAAE,EACFf,kBAAkB,EAClBtB,mBAAmB,EACnBsC,OAAO,EACPE,QAAQ,EACRe,WAAW,CAEf,CAAC;EAED,OACE,IAAApE,WAAA,CAAAyE,GAAA,EAAC5E,QAAA,CAAAiF,OAAO;IAACC,QAAQ,EAAC,aAAa;IAACC,SAAS,EAAC,OAAO;IAACC,IAAI,EAAEb,WAAY;IAAAS,QAAA,EAClE,IAAA7E,WAAA,CAAAyE,GAAA,EAAC9E,gBAAA,CAAAuF,eAAe,CAACC,QAAQ;MAAAN,QAAA,EAAEP;IAAY,CAA2B;EAAC,CAC5D,CAAC;AAEd,CAAC;AAED,MAAMc,2BAA2B,GAAA/E,OAAA,CAAA2C,mBAAA,GAAG,IAAAqC,WAAI,EAACrC,mBAAmB,CAAC;AAC7DoC,2BAA2B,CAACE,WAAW,GAAG,qBAAqB","ignoreList":[]}
|
|
@@ -101,8 +101,8 @@ const renderUiShell = ({
|
|
|
101
101
|
uiShellStylesElement: reactRootElements.stylesRootElement
|
|
102
102
|
})
|
|
103
103
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
webComponentChildren,
|
|
105
|
+
webComponentParentElement: parentElement
|
|
106
106
|
});
|
|
107
107
|
const unsubscribeFromUnifiedUiShellRendered = subscribeToReactAppSubscribed(() => {
|
|
108
108
|
unsubscribeFromUnifiedUiShellRendered();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderUiShell.cjs","names":["_reactErrorBoundary","require","_bufferLatest","_createMessageBus","_UiShell","_useHasUiShell","_renderReactInWebComponent","_jsxRuntime","optionalComponentSlotNames","exports","banners","rightSideMenu","sideNavFooter","topNavLeftSide","topNavRightSide","renderUiShell","appBackgroundColor","appBackgroundContrastMode","appElement","providedAppElement","appElementScrollingMode","breakpointConfig","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","onRender","parentElement","sideNavBackgroundColor","topNavBackgroundColor","document","createElement","setAttribute","uiShellDataAttribute","publish","publishPropChanges","subscribe","subscribeToPropChanges","createMessageBus","publishSubscriptionCreated","subscribeToReactAppSubscribed","publishAfterReactAppReadyForProps","bufferLatest","closeRightSideMenu","subscribeToCloseRightSideMenu","closeSideNavMenu","subscribeToCloseSideNavMenu","slottedElements","Object","fromEntries","entries","map","optionalComponentKey","slotName","element","webComponentChildren","values","uiShellElement","renderReactInWebComponent","getReactComponent","reactRootElements","jsx","ErrorBoundary","fallback","children","UiShell","onSubscriptionCreated","optionalComponents","name","uiShellAppElement","appRootElement","uiShellStylesElement","stylesRootElement","webComponentParentElement","unsubscribeFromUnifiedUiShellRendered","setComponentProps","appendChild"],"sources":["../../../src/ui-shell/renderUiShell.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 { type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { bufferLatest } from \"./bufferLatest.js\";\nimport { createMessageBus, PublishMessage } from \"./createMessageBus.js\";\nimport { UiShell, UiShellProps } from \"./UiShell.js\";\nimport { UiShellNavComponentProps } from \"./uiShellContentTypes.js\";\nimport { uiShellDataAttribute } from \"./useHasUiShell.js\";\nimport { renderReactInWebComponent } from \"../web-component/renderReactInWebComponent.js\";\n\nexport const optionalComponentSlotNames: Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n string\n> = {\n banners: \"banners\",\n rightSideMenu: \"right-side-menu\",\n sideNavFooter: \"side-nav-footer\",\n topNavLeftSide: \"top-nav-left-side\",\n topNavRightSide: \"top-nav-right-side\",\n};\n\nexport type SlottedElements = Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n HTMLDivElement\n>;\n\nexport type RenderedUiShell = {\n closeRightSideMenu: PublishMessage<void>;\n closeSideNavMenu: PublishMessage<void>;\n setComponentProps: ReturnType<\n typeof bufferLatest<SetStateAction<UiShellNavComponentProps>>\n >;\n slottedElements: SlottedElements;\n uiShellElement: ReturnType<typeof renderReactInWebComponent>;\n} & Partial<Pick<UiShellProps, \"appElement\">>;\n\n/**\n * This function renders UI Shell in a web component.\n * This function is agnostic to the UI framework for your app is using. Your application can be another web component, a React app, or even vanilla HTML.\n *\n * **All styles are self-contained.** Even though your application visually renders as children of the web component, its within the global `document` scope, not the web component's `ShadowRoot`. That means any global styles will not affect UI Shell but will affect your application.\n *\n * It places your app's root element in a web component <slot> and ensures it remains rendered in the event of a UI Shell error.\n * It also provides you with other elements fitted to slots in the web component. **In React, you can portal to these components.**\n */\nexport const renderUiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement: providedAppElement,\n appElementScrollingMode,\n breakpointConfig,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n onRender,\n parentElement,\n sideNavBackgroundColor,\n topNavBackgroundColor,\n}: {\n /**\n * Notifies when a React rendering error occurs. This could be useful for logging, reporting priority 0 issues, and recovering UI Shell when errors occur.\n */\n onError?: () => void;\n /**\n * Notify once when React has rendered UI Shell the first time.\n */\n onRender?: (renderedUiShell: RenderedUiShell) => void;\n /**\n * HTML element used as the container for UI Shell and the App. They're siblings inside this element.\n */\n parentElement: HTMLElement;\n} & Pick<\n UiShellProps,\n | \"appBackgroundColor\"\n | \"appBackgroundContrastMode\"\n | \"appElementScrollingMode\"\n | \"breakpointConfig\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"sideNavBackgroundColor\"\n | \"topNavBackgroundColor\"\n> &\n Partial<Pick<UiShellProps, \"appElement\">>) => {\n const appElement = providedAppElement || document.createElement(\"div\");\n\n // Add this attribute so `PageTemplate` and potentially other components will know if they're in UI Shell with special padding already available.\n parentElement.setAttribute(uiShellDataAttribute, \"\");\n\n const { publish: publishPropChanges, subscribe: subscribeToPropChanges } =\n createMessageBus<SetStateAction<UiShellNavComponentProps>>();\n\n const {\n publish: publishSubscriptionCreated,\n subscribe: subscribeToReactAppSubscribed,\n } = createMessageBus();\n\n const publishAfterReactAppReadyForProps = bufferLatest({\n publish: publishPropChanges,\n subscribe: subscribeToReactAppSubscribed,\n });\n\n const {\n publish: closeRightSideMenu,\n subscribe: subscribeToCloseRightSideMenu,\n } = createMessageBus();\n\n const { publish: closeSideNavMenu, subscribe: subscribeToCloseSideNavMenu } =\n createMessageBus();\n\n const slottedElements = Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => {\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"slot\", slotName);\n\n return [optionalComponentKey, element];\n },\n ),\n ) as SlottedElements;\n\n const webComponentChildren = Object.values(slottedElements);\n\n const uiShellElement = renderReactInWebComponent({\n getReactComponent: (reactRootElements) => (\n <ErrorBoundary fallback={<div data-error />} onError={onError}>\n <UiShell\n breakpointConfig={breakpointConfig}\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n closeSideNavMenu={closeSideNavMenu}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n onSubscriptionCreated={publishSubscriptionCreated}\n // `optionalComponents` doesn't need to be memoized because gets passed in once, and this isn't a React component.\n optionalComponents={Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => [\n optionalComponentKey,\n <slot name={slotName} />,\n ],\n ),\n )}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n subscribeToPropChanges={subscribeToPropChanges}\n topNavBackgroundColor={topNavBackgroundColor}\n uiShellAppElement={reactRootElements.appRootElement}\n uiShellStylesElement={reactRootElements.stylesRootElement}\n />\n </ErrorBoundary>\n ),\n webComponentParentElement: parentElement,\n webComponentChildren,\n });\n\n const unsubscribeFromUnifiedUiShellRendered = subscribeToReactAppSubscribed(\n () => {\n unsubscribeFromUnifiedUiShellRendered();\n\n onRender?.({\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n });\n },\n );\n\n parentElement.appendChild(appElement);\n\n return {\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n };\n};\n"],"mappings":";;;;;;AAaA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,0BAAA,GAAAL,OAAA;AAA0F,IAAAM,WAAA,GAAAN,OAAA;AApB1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,MAAMO,0BAGZ,GAAAC,OAAA,CAAAD,0BAAA,GAAG;EACFE,OAAO,EAAE,SAAS;EAClBC,aAAa,EAAE,iBAAiB;EAChCC,aAAa,EAAE,iBAAiB;EAChCC,cAAc,EAAE,mBAAmB;EACnCC,eAAe,EAAE;AACnB,CAAC;AA0BM,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU,EAAEC,kBAAkB;EAC9BC,uBAAuB;EACvBC,gBA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aAAa;IACxC4B;EACF,CAAC,CAAC;EAEF,MAAMmB,qCAAqC,GAAGlC,6BAA6B,CACzE,MAAM;IACJkC,qCAAqC,CAAC,CAAC;IAEvChD,QAAQ,GAAG;MACTT,UAAU;MACV0B,kBAAkB;MAClBE,gBAAgB;MAChB8B,iBAAiB,EAAElC,iCAAiC;MACpDM,eAAe;MACfU;IACF,CAAC,CAAC;EACJ,CACF,CAAC;EAED9B,aAAa,CAACiD,WAAW,CAAC3D,UAAU,CAAC;EAErC,OAAO;IACLA,UAAU;IACV0B,kBAAkB;IAClBE,gBAAgB;IAChB8B,iBAAiB,EAAElC,iCAAiC;IACpDM,eAAe;IACfU;EACF,CAAC;AACH,CAAC;AAACjD,OAAA,CAAAM,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"renderUiShell.cjs","names":["_reactErrorBoundary","require","_bufferLatest","_createMessageBus","_UiShell","_useHasUiShell","_renderReactInWebComponent","_jsxRuntime","optionalComponentSlotNames","exports","banners","rightSideMenu","sideNavFooter","topNavLeftSide","topNavRightSide","renderUiShell","appBackgroundColor","appBackgroundContrastMode","appElement","providedAppElement","appElementScrollingMode","breakpointConfig","hasStandardAppContentPadding","initialVisibleSections","onError","console","error","onRender","parentElement","sideNavBackgroundColor","topNavBackgroundColor","document","createElement","setAttribute","uiShellDataAttribute","publish","publishPropChanges","subscribe","subscribeToPropChanges","createMessageBus","publishSubscriptionCreated","subscribeToReactAppSubscribed","publishAfterReactAppReadyForProps","bufferLatest","closeRightSideMenu","subscribeToCloseRightSideMenu","closeSideNavMenu","subscribeToCloseSideNavMenu","slottedElements","Object","fromEntries","entries","map","optionalComponentKey","slotName","element","webComponentChildren","values","uiShellElement","renderReactInWebComponent","getReactComponent","reactRootElements","jsx","ErrorBoundary","fallback","children","UiShell","onSubscriptionCreated","optionalComponents","name","uiShellAppElement","appRootElement","uiShellStylesElement","stylesRootElement","webComponentParentElement","unsubscribeFromUnifiedUiShellRendered","setComponentProps","appendChild"],"sources":["../../../src/ui-shell/renderUiShell.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 { type SetStateAction } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nimport { bufferLatest } from \"./bufferLatest.js\";\nimport { createMessageBus, PublishMessage } from \"./createMessageBus.js\";\nimport { UiShell, UiShellProps } from \"./UiShell.js\";\nimport { UiShellNavComponentProps } from \"./uiShellContentTypes.js\";\nimport { uiShellDataAttribute } from \"./useHasUiShell.js\";\nimport { renderReactInWebComponent } from \"../web-component/renderReactInWebComponent.js\";\n\nexport const optionalComponentSlotNames: Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n string\n> = {\n banners: \"banners\",\n rightSideMenu: \"right-side-menu\",\n sideNavFooter: \"side-nav-footer\",\n topNavLeftSide: \"top-nav-left-side\",\n topNavRightSide: \"top-nav-right-side\",\n};\n\nexport type SlottedElements = Record<\n keyof Required<UiShellProps>[\"optionalComponents\"],\n HTMLDivElement\n>;\n\nexport type RenderedUiShell = {\n closeRightSideMenu: PublishMessage<void>;\n closeSideNavMenu: PublishMessage<void>;\n setComponentProps: ReturnType<\n typeof bufferLatest<SetStateAction<UiShellNavComponentProps>>\n >;\n slottedElements: SlottedElements;\n uiShellElement: ReturnType<typeof renderReactInWebComponent>;\n} & Partial<Pick<UiShellProps, \"appElement\">>;\n\n/**\n * This function renders UI Shell in a web component.\n * This function is agnostic to the UI framework for your app is using. Your application can be another web component, a React app, or even vanilla HTML.\n *\n * **All styles are self-contained.** Even though your application visually renders as children of the web component, its within the global `document` scope, not the web component's `ShadowRoot`. That means any global styles will not affect UI Shell but will affect your application.\n *\n * It places your app's root element in a web component <slot> and ensures it remains rendered in the event of a UI Shell error.\n * It also provides you with other elements fitted to slots in the web component. **In React, you can portal to these components.**\n */\nexport const renderUiShell = ({\n appBackgroundColor,\n appBackgroundContrastMode,\n appElement: providedAppElement,\n appElementScrollingMode,\n breakpointConfig,\n hasStandardAppContentPadding,\n initialVisibleSections,\n onError = console.error,\n onRender,\n parentElement,\n sideNavBackgroundColor,\n topNavBackgroundColor,\n}: {\n /**\n * Notifies when a React rendering error occurs. This could be useful for logging, reporting priority 0 issues, and recovering UI Shell when errors occur.\n */\n onError?: () => void;\n /**\n * Notify once when React has rendered UI Shell the first time.\n */\n onRender?: (renderedUiShell: RenderedUiShell) => void;\n /**\n * HTML element used as the container for UI Shell and the App. They're siblings inside this element.\n */\n parentElement: HTMLElement;\n} & Pick<\n UiShellProps,\n | \"appBackgroundColor\"\n | \"appBackgroundContrastMode\"\n | \"appElementScrollingMode\"\n | \"breakpointConfig\"\n | \"hasStandardAppContentPadding\"\n | \"initialVisibleSections\"\n | \"sideNavBackgroundColor\"\n | \"topNavBackgroundColor\"\n> &\n Partial<Pick<UiShellProps, \"appElement\">>) => {\n const appElement = providedAppElement || document.createElement(\"div\");\n\n // Add this attribute so `PageTemplate` and potentially other components will know if they're in UI Shell with special padding already available.\n parentElement.setAttribute(uiShellDataAttribute, \"\");\n\n const { publish: publishPropChanges, subscribe: subscribeToPropChanges } =\n createMessageBus<SetStateAction<UiShellNavComponentProps>>();\n\n const {\n publish: publishSubscriptionCreated,\n subscribe: subscribeToReactAppSubscribed,\n } = createMessageBus();\n\n const publishAfterReactAppReadyForProps = bufferLatest({\n publish: publishPropChanges,\n subscribe: subscribeToReactAppSubscribed,\n });\n\n const {\n publish: closeRightSideMenu,\n subscribe: subscribeToCloseRightSideMenu,\n } = createMessageBus();\n\n const { publish: closeSideNavMenu, subscribe: subscribeToCloseSideNavMenu } =\n createMessageBus();\n\n const slottedElements = Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => {\n const element = document.createElement(\"div\");\n\n element.setAttribute(\"slot\", slotName);\n\n return [optionalComponentKey, element];\n },\n ),\n ) as SlottedElements;\n\n const webComponentChildren = Object.values(slottedElements);\n\n const uiShellElement = renderReactInWebComponent({\n getReactComponent: (reactRootElements) => (\n <ErrorBoundary fallback={<div data-error />} onError={onError}>\n <UiShell\n breakpointConfig={breakpointConfig}\n appBackgroundColor={appBackgroundColor}\n appBackgroundContrastMode={appBackgroundContrastMode}\n appElement={appElement}\n appElementScrollingMode={appElementScrollingMode}\n closeSideNavMenu={closeSideNavMenu}\n hasStandardAppContentPadding={hasStandardAppContentPadding}\n initialVisibleSections={initialVisibleSections}\n onError={onError}\n onSubscriptionCreated={publishSubscriptionCreated}\n // `optionalComponents` doesn't need to be memoized because gets passed in once, and this isn't a React component.\n optionalComponents={Object.fromEntries(\n Object.entries(optionalComponentSlotNames).map(\n ([optionalComponentKey, slotName]) => [\n optionalComponentKey,\n <slot name={slotName} />,\n ],\n ),\n )}\n sideNavBackgroundColor={sideNavBackgroundColor}\n subscribeToCloseRightSideMenu={subscribeToCloseRightSideMenu}\n subscribeToCloseSideNavMenu={subscribeToCloseSideNavMenu}\n subscribeToPropChanges={subscribeToPropChanges}\n topNavBackgroundColor={topNavBackgroundColor}\n uiShellAppElement={reactRootElements.appRootElement}\n uiShellStylesElement={reactRootElements.stylesRootElement}\n />\n </ErrorBoundary>\n ),\n webComponentChildren,\n webComponentParentElement: parentElement,\n });\n\n const unsubscribeFromUnifiedUiShellRendered = subscribeToReactAppSubscribed(\n () => {\n unsubscribeFromUnifiedUiShellRendered();\n\n onRender?.({\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n });\n },\n );\n\n parentElement.appendChild(appElement);\n\n return {\n appElement,\n closeRightSideMenu,\n closeSideNavMenu,\n setComponentProps: publishAfterReactAppReadyForProps,\n slottedElements,\n uiShellElement,\n };\n};\n"],"mappings":";;;;;;AAaA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,0BAAA,GAAAL,OAAA;AAA0F,IAAAM,WAAA,GAAAN,OAAA;AApB1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,MAAMO,0BAGZ,GAAAC,OAAA,CAAAD,0BAAA,GAAG;EACFE,OAAO,EAAE,SAAS;EAClBC,aAAa,EAAE,iBAAiB;EAChCC,aAAa,EAAE,iBAAiB;EAChCC,cAAc,EAAE,mBAAmB;EACnCC,eAAe,EAAE;AACnB,CAAC;AA0BM,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,kBAAkB;EAClBC,yBAAyB;EACzBC,UAAU,EAAEC,kBAAkB;EAC9BC,uBAAuB;EACvBC,gBAAgB;EAChBC,4BAA4B;EAC5BC,sBAAsB;EACtBC,OAAO,GAAGC,OAAO,CAACC,KAAK;EACvBC,QAAQ;EACRC,aAAa;EACbC,sBAAsB;EACtBC;AAyBwC,CAAC,KAAK;EAC9C,MAAMZ,UAAU,GAAGC,kBAAkB,IAAIY,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAGtEJ,aAAa,CAACK,YAAY,CAACC,mCAAoB,EAAE,EAAE,CAAC;EAEpD,MAAM;IAAEC,OAAO,EAAEC,kBAAkB;IAAEC,SAAS,EAAEC;EAAuB,CAAC,GACtE,IAAAC,kCAAgB,EAA2C,CAAC;EAE9D,MAAM;IACJJ,OAAO,EAAEK,0BAA0B;IACnCH,SAAS,EAAEI;EACb,CAAC,GAAG,IAAAF,kCAAgB,EAAC,CAAC;EAEtB,MAAMG,iCAAiC,GAAG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= containerElement => Array.from(containerElemen
|
|
|
38
38
|
element
|
|
39
39
|
})).filter(scrollHeightElement => getIsYAxisScrollContainer(scrollHeightElement));
|
|
40
40
|
exports.getNestedScrollContainers = getNestedScrollContainers;
|
|
41
|
-
const fakeDefaultContainerElement = exports.fakeDefaultContainerElement = document.createElement("div");
|
|
41
|
+
const fakeDefaultContainerElement = exports.fakeDefaultContainerElement = typeof window === "undefined" ? null : document.createElement("div");
|
|
42
42
|
const useScrollState = containerElement => {
|
|
43
43
|
const [isScrolled, setIsScrolled] = (0, _react.useState)(false);
|
|
44
44
|
const requestedAnimationFrameIdRef = (0, _react.useRef)(0);
|
|
@@ -61,7 +61,9 @@ const useScrollState = containerElement => {
|
|
|
61
61
|
}, [updateScrollState]);
|
|
62
62
|
const updateScrollableElements = (0, _react.useCallback)(() => {
|
|
63
63
|
const computedContainerElement = containerElement || fakeDefaultContainerElement;
|
|
64
|
-
|
|
64
|
+
if (computedContainerElement) {
|
|
65
|
+
scrollableElementsRef.current = getNestedScrollContainers(computedContainerElement).concat(computedContainerElement);
|
|
66
|
+
}
|
|
65
67
|
}, [containerElement]);
|
|
66
68
|
const updateScrollListeners = (0, _react.useCallback)(() => {
|
|
67
69
|
removeScrollEventListeners();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollState.cjs","names":["_react","require","getIsScrollHeightElement","containerElement","element","containerElementHeight","getBoundingClientRect","height","elementHeight","exports","getIsYAxisScrollContainer","overflowY","window","getComputedStyle","getIsYAxisScrolling","scrollHeight","clientHeight","getNestedScrollContainers","Array","from","querySelectorAll","filter","scrollHeightElement","fakeDefaultContainerElement","document","createElement","useScrollState","isScrolled","setIsScrolled","useState","requestedAnimationFrameIdRef","useRef","scrollableElementsRef","updateScrollState","useCallback","cancelAnimationFrame","current","requestAnimationFrame","reduce","scrollableElement","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 element,\n}: {\n containerElement: HTMLElement;\n element: HTMLElement;\n}) => {\n const containerElementHeight =\n containerElement.getBoundingClientRect().height;\n const elementHeight = element.getBoundingClientRect().height;\n\n return elementHeight - 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) =>\n getIsScrollHeightElement({\n containerElement,\n element,\n }),\n )\n .filter((scrollHeightElement) =>\n getIsYAxisScrollContainer(scrollHeightElement),\n );\n\nexport const fakeDefaultContainerElement
|
|
1
|
+
{"version":3,"file":"useScrollState.cjs","names":["_react","require","getIsScrollHeightElement","containerElement","element","containerElementHeight","getBoundingClientRect","height","elementHeight","exports","getIsYAxisScrollContainer","overflowY","window","getComputedStyle","getIsYAxisScrolling","scrollHeight","clientHeight","getNestedScrollContainers","Array","from","querySelectorAll","filter","scrollHeightElement","fakeDefaultContainerElement","document","createElement","useScrollState","isScrolled","setIsScrolled","useState","requestedAnimationFrameIdRef","useRef","scrollableElementsRef","updateScrollState","useCallback","cancelAnimationFrame","current","requestAnimationFrame","reduce","scrollableElement","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 element,\n}: {\n containerElement: HTMLElement;\n element: HTMLElement;\n}) => {\n const containerElementHeight =\n containerElement.getBoundingClientRect().height;\n const elementHeight = element.getBoundingClientRect().height;\n\n return elementHeight - 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) =>\n getIsScrollHeightElement({\n containerElement,\n element,\n }),\n )\n .filter((scrollHeightElement) =>\n getIsYAxisScrollContainer(scrollHeightElement),\n );\n\nexport const fakeDefaultContainerElement =\n typeof window === \"undefined\" ? null : 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 if (computedContainerElement) {\n scrollableElementsRef.current = getNestedScrollContainers(\n computedContainerElement,\n ).concat(computedContainerElement);\n }\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,aAAa,GAAGJ,OAAO,CAACE,qBAAqB,CAAC,CAAC,CAACC,MAAM;EAE5D,OAAOC,aAAa,GAAGH,sBAAsB,IAAI,CAAC;AACpD,CAAC;AAACI,OAAA,CAAAP,wBAAA,GAAAA,wBAAA;AAEK,MAAMQ,yBAAyB,GAAIN,OAAoB,IAAK;EACjE,MAAMO,SAAS,GAAGC,MAAM,CAACC,gBAAgB,CAACT,OAAO,CAAC,CAACO,SAAS;EAE5D,OAAOA,SAAS,KAAK,MAAM,IAAIA,SAAS,KAAK,QAAQ;AACvD,CAAC;AAACF,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAEK,MAAMI,mBAAmB,GAAIV,OAAoB,IACtDA,OAAO,CAACW,YAAY,GAAGX,OAAO,CAACY,YAAY,GACvCN,yBAAyB,CAACN,OAAO,CAAC,GAClC,KAAK;AAACK,OAAA,CAAAK,mBAAA,GAAAA,mBAAA;AAEL,MAAMG,yBAAyB,GAAId,gBAA6B,IACrEe,KAAK,CAACC,IAAI,CAAChB,gBAAgB,CAACiB,gBAAgB,CAAc,GAAG,CAAC,CAAC,CAC5DC,MAAM,CAAEjB,OAAO,IACdF,wBAAwB,CAAC;EACvBC,gBAAgB;EAChBC;AACF,CAAC,CACH,CAAC,CACAiB,MAAM,CAAEC,mBAAmB,IAC1BZ,yBAAyB,CAACY,mBAAmB,CAC/C,CAAC;AAACb,OAAA,CAAAQ,y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B,CAAC;AACH,CAAC;AAAClB,OAAA,CAAAiB,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -54,9 +54,9 @@ const useAutocomplete = ({
|
|
|
54
54
|
return value === undefined ? defaultValue : undefined;
|
|
55
55
|
}, [defaultValue, hasMultipleChoices, value]);
|
|
56
56
|
const valueProps = (0, _inputUtils.useInputValues)({
|
|
57
|
+
controlState: controlledStateRef.current,
|
|
57
58
|
defaultValue: defaultValueProp,
|
|
58
|
-
value
|
|
59
|
-
controlState: controlledStateRef.current
|
|
59
|
+
value
|
|
60
60
|
});
|
|
61
61
|
const inputValueProp = (0, _react.useMemo)(() => {
|
|
62
62
|
if (controlledStateRef.current === _inputUtils.ComponentControlledState.CONTROLLED) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutocomplete.cjs","names":["_react","require","_Field","_inputUtils","_jsxRuntime","_interopRequireDefault","e","__esModule","default","useAutocomplete","ariaDescribedBy","defaultValue","errorMessage","errorMessageList","hasMultipleChoices","hint","HintLinkComponent","inputValue","isFullWidth","isOptional","isVirtualized","isVirtualizedProp","label","name","nameOverride","testId","value","controlledStateRef","useRef","getControlState","controlledValue","uncontrolledValue","isVirtualizedRef","Boolean","defaultValueProp","useMemo","undefined","valueProps","useInputValues","controlState","current","inputValueProp","ComponentControlledState","CONTROLLED","renderInput","useCallback","InputLabelProps","InputProps","params","jsx","Field","fieldType","hasVisibleLabel","id","htmlFor","renderFieldComponent","errorMessageElementId","labelElementId","_InputBase2","inputProps","required","exports"],"sources":["../../src/useAutocomplete.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 { useCallback, useMemo, useRef } from \"react\";\nimport {\n InputBase,\n AutocompleteValue,\n AutocompleteRenderInputParams,\n} from \"@mui/material\";\n\nimport { AutocompleteProps } from \"./Autocomplete.js\";\nimport { Field } from \"./Field.js\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\n\nexport type UseAutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n> = Pick<\n AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>,\n | \"ariaDescribedBy\"\n | \"defaultValue\"\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hasMultipleChoices\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"inputValue\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isVirtualized\"\n | \"label\"\n | \"name\"\n | \"testId\"\n | \"value\"\n>;\n\nexport const useAutocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices,\n hint,\n HintLinkComponent,\n inputValue,\n isFullWidth,\n isOptional,\n isVirtualized: isVirtualizedProp,\n label,\n name: nameOverride,\n testId,\n value,\n}: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n IsCustomValueAllowed\n>) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const isVirtualizedRef = useRef(Boolean(isVirtualizedProp));\n\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n
|
|
1
|
+
{"version":3,"file":"useAutocomplete.cjs","names":["_react","require","_Field","_inputUtils","_jsxRuntime","_interopRequireDefault","e","__esModule","default","useAutocomplete","ariaDescribedBy","defaultValue","errorMessage","errorMessageList","hasMultipleChoices","hint","HintLinkComponent","inputValue","isFullWidth","isOptional","isVirtualized","isVirtualizedProp","label","name","nameOverride","testId","value","controlledStateRef","useRef","getControlState","controlledValue","uncontrolledValue","isVirtualizedRef","Boolean","defaultValueProp","useMemo","undefined","valueProps","useInputValues","controlState","current","inputValueProp","ComponentControlledState","CONTROLLED","renderInput","useCallback","InputLabelProps","InputProps","params","jsx","Field","fieldType","hasVisibleLabel","id","htmlFor","renderFieldComponent","errorMessageElementId","labelElementId","_InputBase2","inputProps","required","exports"],"sources":["../../src/useAutocomplete.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 { useCallback, useMemo, useRef } from \"react\";\nimport {\n InputBase,\n AutocompleteValue,\n AutocompleteRenderInputParams,\n} from \"@mui/material\";\n\nimport { AutocompleteProps } from \"./Autocomplete.js\";\nimport { Field } from \"./Field.js\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\n\nexport type UseAutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n> = Pick<\n AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>,\n | \"ariaDescribedBy\"\n | \"defaultValue\"\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hasMultipleChoices\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"inputValue\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isVirtualized\"\n | \"label\"\n | \"name\"\n | \"testId\"\n | \"value\"\n>;\n\nexport const useAutocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices,\n hint,\n HintLinkComponent,\n inputValue,\n isFullWidth,\n isOptional,\n isVirtualized: isVirtualizedProp,\n label,\n name: nameOverride,\n testId,\n value,\n}: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n IsCustomValueAllowed\n>) => {\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const isVirtualizedRef = useRef(Boolean(isVirtualizedProp));\n\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n controlState: controlledStateRef.current,\n defaultValue: defaultValueProp,\n value,\n });\n\n const inputValueProp = useMemo(() => {\n if (controlledStateRef.current === ComponentControlledState.CONTROLLED) {\n return { inputValue };\n }\n return undefined;\n }, [inputValue]);\n\n const renderInput = useCallback(\n ({\n InputLabelProps,\n InputProps,\n ...params\n }: AutocompleteRenderInputParams) => (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n //@ts-expect-error htmlFor exists on `InputLabelProps`, but not the type.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n id={InputLabelProps.htmlFor}\n isFullWidth={isFullWidth}\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({\n ariaDescribedBy,\n id,\n errorMessageElementId,\n labelElementId,\n }) => (\n <InputBase\n {...params}\n {...InputProps}\n inputProps={{\n ...params.inputProps,\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n \"data-se\": testId,\n }}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [\n ariaDescribedBy,\n errorMessage,\n errorMessageList,\n hint,\n HintLinkComponent,\n isFullWidth,\n isOptional,\n label,\n nameOverride,\n testId,\n ],\n );\n\n return {\n inputValueProp,\n isVirtualizedRef,\n renderInput,\n valueProps,\n };\n};\n"],"mappings":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIyB,IAAAG,WAAA,GAAAH,OAAA;AAAA,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAzBzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCO,MAAMG,eAAe,GAAGA,CAI7B;EACAC,eAAe;EACfC,YAAY;EACZC,YAAY;EACZC,gBAAgB;EAChBC,kBAAkB;EAClBC,IAAI;EACJC,iBAAiB;EACjBC,UAAU;EACVC,WAAW;EACXC,UAAU;EACVC,aAAa,EAAEC,iBAAiB;EAChCC,KAAK;EACLC,IAAI,EAAEC,YAAY;EAClBC,MAAM;EACNC;AAKF,CAAC,KAAK;EACJ,MAAMC,kBAAkB,GAAG,IAAAC,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IAAI,EAAEA,IAAK;IACXC,iBAAiB,EAAEA,iBAAkB;IACrCM,KAAK,EAAEA,KAAM;IACbH,UAAU,EAAEA,UAAW;IACvBoC,oBAAoB,EAAEA,CAAC;MACrB7C,eAAe;MACf2C,EAAE;MACFG,qBAAqB;MACrBC;IACF,CAAC,KACC,IAAArD,WAAA,CAAA6C,GAAA,EAAAS,WAAA,CAAAlD,OAAA;MAAA,GACMwC,MAAM;MAAA,GACND,UAAU;MACdY,UAAU,EAAE;QACV,GAAGX,MAAM,CAACW,UAAU;QACpB,mBAAmB,EAAEH,qBAAqB;QAC1C,iBAAiB,EAAEC,cAAc;QACjC,SAAS,EAAEhC;MACb,CAAE;MACF,oBAAkBf,eAAgB;MAClC2C,EAAE,EAAEA,EAAG;MACP9B,IAAI,EAAEC,YAAY,IAAI6B,EAAG;MACzBO,QAAQ,EAAE,CAACzC;IAAW,CACvB;EACD,CACH,CACF,EACD,CACET,eAAe,EACfE,YAAY,EACZC,gBAAgB,EAChBE,IAAI,EACJC,iBAAiB,EACjBE,WAAW,EACXC,UAAU,EACVG,KAAK,EACLE,YAAY,EACZC,MAAM,CAEV,CAAC;EAED,OAAO;IACLgB,cAAc;IACdT,gBAAgB;IAChBY,WAAW;IACXP;EACF,CAAC;AACH,CAAC;AAACwB,OAAA,CAAApD,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -15,5 +15,5 @@ exports.default = void 0;
|
|
|
15
15
|
*
|
|
16
16
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
var _default = exports.default = "
|
|
18
|
+
var _default = exports.default = "1-41-1";
|
|
19
19
|
//# sourceMappingURL=odysseyWebComponentVersion.generated.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odysseyWebComponentVersion.generated.cjs","names":["_default","exports","default"],"sources":["../../../src/web-component/odysseyWebComponentVersion.generated.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\n/**\n * DO NOT UPDATE THIS FILE MANUALLY\n * This file is managed by scripts/updateWebComponentVersion.ts and any changes made will be overwritten\n * This script only needs to be run during release, and shouldn't be used during local development.\n */\nexport default \"
|
|
1
|
+
{"version":3,"file":"odysseyWebComponentVersion.generated.cjs","names":["_default","exports","default"],"sources":["../../../src/web-component/odysseyWebComponentVersion.generated.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\n/**\n * DO NOT UPDATE THIS FILE MANUALLY\n * This file is managed by scripts/updateWebComponentVersion.ts and any changes made will be overwritten\n * This script only needs to be run during release, and shouldn't be used during local development.\n */\n\nexport default \"1-41-1\";\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAkBe,QAAQ","ignoreList":[]}
|
package/dist/esm/Autocomplete.js
CHANGED
|
@@ -51,8 +51,11 @@ const Autocomplete = ({
|
|
|
51
51
|
defaultValue,
|
|
52
52
|
errorMessage,
|
|
53
53
|
errorMessageList,
|
|
54
|
+
getIsOptionEqualToValue,
|
|
54
55
|
getOptionLabel,
|
|
55
56
|
hasMultipleChoices,
|
|
57
|
+
hint,
|
|
58
|
+
HintLinkComponent,
|
|
56
59
|
id: idOverride,
|
|
57
60
|
inputValue,
|
|
58
61
|
isCustomValueAllowed,
|
|
@@ -62,20 +65,17 @@ const Autocomplete = ({
|
|
|
62
65
|
isOptional = false,
|
|
63
66
|
isReadOnly,
|
|
64
67
|
isVirtualized = false,
|
|
65
|
-
hint,
|
|
66
|
-
HintLinkComponent,
|
|
67
68
|
label,
|
|
68
69
|
name: nameOverride,
|
|
69
70
|
noOptionsText,
|
|
70
71
|
onBlur,
|
|
71
72
|
onChange,
|
|
72
|
-
onInputChange,
|
|
73
73
|
onFocus,
|
|
74
|
+
onInputChange,
|
|
74
75
|
options,
|
|
75
|
-
value,
|
|
76
|
-
getIsOptionEqualToValue,
|
|
77
76
|
testId,
|
|
78
|
-
translate
|
|
77
|
+
translate,
|
|
78
|
+
value
|
|
79
79
|
}) => {
|
|
80
80
|
const {
|
|
81
81
|
t
|
|
@@ -113,23 +113,23 @@ const Autocomplete = ({
|
|
|
113
113
|
closeText: t("close.text"),
|
|
114
114
|
disableCloseOnSelect: hasMultipleChoices,
|
|
115
115
|
disabled: isDisabled,
|
|
116
|
-
freeSolo: isCustomValueAllowed,
|
|
117
116
|
filterSelectedOptions: true,
|
|
117
|
+
freeSolo: isCustomValueAllowed,
|
|
118
|
+
fullWidth: isFullWidth,
|
|
118
119
|
getOptionLabel: getOptionLabel,
|
|
119
120
|
id: idOverride,
|
|
120
|
-
|
|
121
|
+
isOptionEqualToValue: getIsOptionEqualToValue,
|
|
121
122
|
loading: isLoading,
|
|
122
123
|
multiple: hasMultipleChoices,
|
|
123
124
|
noOptionsText: noOptionsText || t("autocomplete.nooptions"),
|
|
124
125
|
onBlur: onBlur,
|
|
125
126
|
onChange: onChange,
|
|
126
|
-
onInputChange: onInputChange,
|
|
127
127
|
onFocus: onFocus,
|
|
128
|
+
onInputChange: onInputChange,
|
|
128
129
|
openText: t("open.text"),
|
|
129
130
|
options: options,
|
|
130
131
|
readOnly: isReadOnly,
|
|
131
132
|
renderInput: renderInput,
|
|
132
|
-
isOptionEqualToValue: getIsOptionEqualToValue,
|
|
133
133
|
translate: translate
|
|
134
134
|
});
|
|
135
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.js","names":["memo","useTranslation","PickerVirtualizationListBox","useAutocomplete","jsx","_jsx","AutocompleteTestSelector","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","Autocomplete","ariaDescribedBy","defaultValue","errorMessageList","getOptionLabel","hasMultipleChoices","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","isVirtualized","HintLinkComponent","name","nameOverride","noOptionsText","onBlur","onChange","onInputChange","onFocus","value","getIsOptionEqualToValue","testId","translate","t","inputValueProp","isVirtualizedRef","renderInput","valueProps","_Autocomplete","current","ListboxComponent","clearText","closeText","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","fullWidth","loading","multiple","openText","readOnly","isOptionEqualToValue","MemoizedAutocomplete","displayName"],"sources":["../../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n UseAutocompleteProps as MuiUseAutocompleteProps,\n} from \"@mui/material\";\n\nimport { FieldComponentProps } from \"./FieldComponentProps.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport { PickerVirtualizationListBox } from \"./labs/OdysseyPickers/PickerVirtualizationListBox.js\";\nimport { useAutocomplete } from \"./useAutocomplete.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\n\nexport const AutocompleteTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n children: {\n listItem: {\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"option\",\n },\n },\n },\n isControlledElement: true,\n },\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"combobox\",\n },\n} as const satisfies TestSelector;\n// type SetItemSize = (size: number) => void;\n\nexport type AutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\n /**\n * Used to determine the string value for a given option. It's used to fill the input (and the list box options if renderOption is not provided). If used in free solo mode, it must accept both the type of the options and a string.\n *\n * `function(option: Value) => string`\n */\n getOptionLabel?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"getOptionLabel\"];\n\n /** Used to determine if the option represents the given value. Uses strict equality by default if none provided.\n * Both arguments need to be handled, an option can only match with one value.\n * option: the option to test\n * value: the value to test against\n *\n * You will need to implement this function if your `option` items are objects.\n */\n getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;\n /**\n * Enables multiple choice selection\n */\n hasMultipleChoices?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"multiple\"];\n /**\n * The value for the input\n */\n inputValue?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"inputValue\"];\n /**\n * Allows the input of custom values\n */\n isCustomValueAllowed?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"freeSolo\"];\n /**\n * Disables the Autocomplete input\n */\n isDisabled?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"disabled\"];\n /**\n * Displays a loading indicator\n */\n isLoading?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"loading\"];\n /**\n * Makes the Autocomplete input read-only\n */\n isReadOnly?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"readOnly\"];\n /**\n * If this component is required to display a virtualized list of options,\n * then this value needs to be set to true.\n * It is recommended if you're options are on the order of 10's of hundreds or more.\n */\n isVirtualized?: boolean;\n /**\n * The label text for the autocomplete input\n */\n label: string;\n /**\n * The text to display when no options are available\n *\n * default: \"No options\"\n */\n noOptionsText?: string;\n /**\n * Callback fired when the autocomplete loses focus.\n */\n onBlur?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onBlur\"];\n /**\n * Callback fired when a selection is made.\n */\n onChange?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"];\n /**\n * Callback fired when the textbox receives typed characters.\n */\n onInputChange?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"];\n /**\n * Callback fired when the autocomplete gains focus.\n */\n onFocus?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onFocus\"];\n /**\n * The options for the Autocomplete input\n */\n options: ReadonlyArray<OptionType>;\n /**\n * The value of the Autocomplete input\n */\n value?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\nconst Autocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n getOptionLabel,\n hasMultipleChoices,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n isVirtualized = false,\n hint,\n HintLinkComponent,\n label,\n name: nameOverride,\n noOptionsText,\n onBlur,\n onChange,\n onInputChange,\n onFocus,\n options,\n value,\n getIsOptionEqualToValue,\n testId,\n translate,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const { t } = useTranslation();\n const { inputValueProp, isVirtualizedRef, renderInput, valueProps } =\n useAutocomplete<OptionType, HasMultipleChoices, IsCustomValueAllowed>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices,\n hint,\n HintLinkComponent,\n inputValue,\n isFullWidth,\n isOptional,\n isVirtualized,\n label,\n name: nameOverride,\n testId,\n value,\n });\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // conditionally provide the ListboxComponent if this needs to be virtualized\n {...(isVirtualizedRef.current && {\n ListboxComponent: PickerVirtualizationListBox,\n })}\n // AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div\n aria-disabled={isDisabled}\n clearText={t(\"clear.text\")}\n closeText={t(\"close.text\")}\n disableCloseOnSelect={hasMultipleChoices}\n disabled={isDisabled}\n freeSolo={isCustomValueAllowed}\n filterSelectedOptions={true}\n getOptionLabel={getOptionLabel}\n id={idOverride}\n fullWidth={isFullWidth}\n loading={isLoading}\n multiple={hasMultipleChoices}\n noOptionsText={noOptionsText || t(\"autocomplete.nooptions\")}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n openText={t(\"open.text\")}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n isOptionEqualToValue={getIsOptionEqualToValue}\n translate={translate}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,cAAc,QAAQ,eAAe;AAS9C,SAASC,2BAA2B,QAAQ,sDAAsD;AAClG,SAASC,eAAe,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvD,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,cAAc,EAAE;IACdC,YAAY,EAAE,cAAc;IAC5BC,IAAI,EAAE,aAAa;IACnBC,KAAK,EAAE;EACT,CAAC;EACDC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJD,QAAQ,EAAE;QACRE,QAAQ,EAAE;UACRC,eAAe,EAAE;YACfC,MAAM,EAAE,QAAQ;YAChBC,OAAO,EAAE;cACPN,KAAK,EAAE;YACT,CAAC;YACDO,IAAI,EAAE;UACR;QACF;MACF,CAAC;MACDC,mBAAmB,EAAE;IACvB;EACF,CAAC;EACDJ,eAAe,EAAE;IACfC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE;MACPN,KAAK,EAAE;IACT,CAAC;IACDO,IAAI,EAAE;EACR;AACF,CA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AC/BgC,qBAAqB,EAAE,IAAK;IAC5BrC,cAAc,EAAEA,cAAe;IAC/BE,EAAE,EAAEC,UAAW;IACfmC,SAAS,EAAE/B,WAAY;IACvBgC,OAAO,EAAE/B,SAAU;IACnBgC,QAAQ,EAAEvC,kBAAmB;IAC7Bc,aAAa,EAAEA,aAAa,IAAIS,CAAC,CAAC,wBAAwB,CAAE;IAC5DR,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBC,aAAa,EAAEA,aAAc;IAC7BC,OAAO,EAAEA,OAAQ;IACjBsB,QAAQ,EAAEjB,CAAC,CAAC,WAAW,CAAE;IACzB/B,OAAO,EAAEA,OAAQ;IACjBiD,QAAQ,EAAEhC,UAAW;IACrBiB,WAAW,EAAEA,WAAY;IACzBgB,oBAAoB,EAAEtB,uBAAwB;IAC9CE,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAGD,MAAMqB,oBAAoB,GAAGnE,IAAI,CAACmB,YAAY,CAAwB;AAEtEgD,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIhD,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Autocomplete.js","names":["memo","useTranslation","PickerVirtualizationListBox","useAutocomplete","jsx","_jsx","AutocompleteTestSelector","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","Autocomplete","ariaDescribedBy","defaultValue","errorMessageList","getIsOptionEqualToValue","getOptionLabel","hasMultipleChoices","HintLinkComponent","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","isVirtualized","name","nameOverride","noOptionsText","onBlur","onChange","onFocus","onInputChange","testId","translate","value","t","inputValueProp","isVirtualizedRef","renderInput","valueProps","_Autocomplete","current","ListboxComponent","clearText","closeText","disableCloseOnSelect","disabled","filterSelectedOptions","freeSolo","fullWidth","isOptionEqualToValue","loading","multiple","openText","readOnly","MemoizedAutocomplete","displayName"],"sources":["../../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n UseAutocompleteProps as MuiUseAutocompleteProps,\n} from \"@mui/material\";\n\nimport { FieldComponentProps } from \"./FieldComponentProps.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport { PickerVirtualizationListBox } from \"./labs/OdysseyPickers/PickerVirtualizationListBox.js\";\nimport { useAutocomplete } from \"./useAutocomplete.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\n\nexport const AutocompleteTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n children: {\n listItem: {\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"option\",\n },\n },\n },\n isControlledElement: true,\n },\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"combobox\",\n },\n} as const satisfies TestSelector;\n// type SetItemSize = (size: number) => void;\n\nexport type AutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\n /**\n * Used to determine the string value for a given option. It's used to fill the input (and the list box options if renderOption is not provided). If used in free solo mode, it must accept both the type of the options and a string.\n *\n * `function(option: Value) => string`\n */\n getOptionLabel?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"getOptionLabel\"];\n\n /** Used to determine if the option represents the given value. Uses strict equality by default if none provided.\n * Both arguments need to be handled, an option can only match with one value.\n * option: the option to test\n * value: the value to test against\n *\n * You will need to implement this function if your `option` items are objects.\n */\n getIsOptionEqualToValue?: (option: OptionType, value: OptionType) => boolean;\n /**\n * Enables multiple choice selection\n */\n hasMultipleChoices?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"multiple\"];\n /**\n * The value for the input\n */\n inputValue?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"inputValue\"];\n /**\n * Allows the input of custom values\n */\n isCustomValueAllowed?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"freeSolo\"];\n /**\n * Disables the Autocomplete input\n */\n isDisabled?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"disabled\"];\n /**\n * Displays a loading indicator\n */\n isLoading?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"loading\"];\n /**\n * Makes the Autocomplete input read-only\n */\n isReadOnly?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"readOnly\"];\n /**\n * If this component is required to display a virtualized list of options,\n * then this value needs to be set to true.\n * It is recommended if you're options are on the order of 10's of hundreds or more.\n */\n isVirtualized?: boolean;\n /**\n * The label text for the autocomplete input\n */\n label: string;\n /**\n * The text to display when no options are available\n *\n * default: \"No options\"\n */\n noOptionsText?: string;\n /**\n * Callback fired when the autocomplete loses focus.\n */\n onBlur?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onBlur\"];\n /**\n * Callback fired when a selection is made.\n */\n onChange?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"];\n /**\n * Callback fired when the textbox receives typed characters.\n */\n onInputChange?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"];\n /**\n * Callback fired when the autocomplete gains focus.\n */\n onFocus?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onFocus\"];\n /**\n * The options for the Autocomplete input\n */\n options: ReadonlyArray<OptionType>;\n /**\n * The value of the Autocomplete input\n */\n value?: MuiUseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\nconst Autocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n getIsOptionEqualToValue,\n getOptionLabel,\n hasMultipleChoices,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n isVirtualized = false,\n label,\n name: nameOverride,\n noOptionsText,\n onBlur,\n onChange,\n onFocus,\n onInputChange,\n options,\n testId,\n translate,\n value,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const { t } = useTranslation();\n const { inputValueProp, isVirtualizedRef, renderInput, valueProps } =\n useAutocomplete<OptionType, HasMultipleChoices, IsCustomValueAllowed>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices,\n hint,\n HintLinkComponent,\n inputValue,\n isFullWidth,\n isOptional,\n isVirtualized,\n label,\n name: nameOverride,\n testId,\n value,\n });\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // conditionally provide the ListboxComponent if this needs to be virtualized\n {...(isVirtualizedRef.current && {\n ListboxComponent: PickerVirtualizationListBox,\n })}\n // AutoComplete is wrapped in a div within MUI which does not get the disabled attr. So this aria-disabled gets set in the div\n aria-disabled={isDisabled}\n clearText={t(\"clear.text\")}\n closeText={t(\"close.text\")}\n disableCloseOnSelect={hasMultipleChoices}\n disabled={isDisabled}\n filterSelectedOptions={true}\n freeSolo={isCustomValueAllowed}\n fullWidth={isFullWidth}\n getOptionLabel={getOptionLabel}\n id={idOverride}\n isOptionEqualToValue={getIsOptionEqualToValue}\n loading={isLoading}\n multiple={hasMultipleChoices}\n noOptionsText={noOptionsText || t(\"autocomplete.nooptions\")}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onInputChange={onInputChange}\n openText={t(\"open.text\")}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n translate={translate}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,cAAc,QAAQ,eAAe;AAS9C,SAASC,2BAA2B,QAAQ,sDAAsD;AAClG,SAASC,eAAe,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;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js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","GroupIcon","HomeIcon","UserIcon","Subordinate","useTranslation","styled","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","BreadcrumbContext","breadcrumbType","BreadcrumbContent","span","Breadcrumb","children","href","iconName","onClick","onClickHandler","event","preventDefault","stopPropagation","breadcrumbContent","color","_MenuItem","ariaCurrent","_ButtonBase","breadcrumbProviderValue","currentPage","listItem","menuItem","defaultTruncationValue","BreadcrumbList","homeHref","maxVisibleItems","maxVisibleItemsProp","testId","translate","t","anchorEl","setAnchorEl","Math","min","max","length","breadcrumbSections","beforeMenu","insideMenu","remainingBreadcrumbs","menuStart","floor","menuLength","slice","onMenuButtonClick","currentTarget","onCloseMenu","_Breadcrumbs","maxItems","map","breadcrumb","index","Provider","value","_Menu","open","Boolean","onClose","anchorOrigin","horizontal","vertical","MenuListProps","sx","minWidth","MemoizedBreadcrumbList","displayName"],"sources":["../../src/Breadcrumbs.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 ButtonBase,\n Menu,\n MenuItem,\n Breadcrumbs as MuiBreadcrumbs,\n} from \"@mui/material\";\nimport {\n MouseEventHandler,\n ReactElement,\n createContext,\n memo,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport { GroupIcon, HomeIcon, UserIcon } from \"./icons.generated/index.js\";\nimport { Subordinate } from \"./Typography.js\";\nimport { useTranslation } from \"react-i18next\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport styled from \"@emotion/styled\";\n\nexport type BreadcrumbType = \"listItem\" | \"menuItem\" | \"currentPage\";\n\nexport type BreadcrumbProps = {\n children?: string;\n href?: string;\n iconName?: \"user\" | \"group\";\n onClick?: MouseEventHandler;\n};\n\nexport type BreadcrumbsProps = {\n children: ReactElement<typeof Breadcrumb>[];\n homeHref?: string;\n maxVisibleItems?: number;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nexport type BreadcrumbContextType = {\n breadcrumbType: BreadcrumbType;\n};\n\nexport const BreadcrumbContext = createContext<BreadcrumbContextType>({\n breadcrumbType: \"listItem\",\n});\n\nconst BreadcrumbContent = styled.span`\n white-space: nowrap;\n overflow: hidden;\n max-width: 10rem;\n text-overflow: ellipsis;\n`;\n\nexport const Breadcrumb = ({\n children,\n href,\n iconName,\n onClick,\n}: BreadcrumbProps) => {\n const { breadcrumbType } = useContext(BreadcrumbContext);\n\n const onClickHandler = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n if (onClick) {\n event.preventDefault();\n event.stopPropagation();\n onClick(event);\n }\n },\n [onClick],\n );\n\n const breadcrumbContent = (\n <>\n {iconName === \"group\" ? (\n <GroupIcon />\n ) : iconName === \"user\" ? (\n <UserIcon />\n ) : null}\n <BreadcrumbContent>{children}</BreadcrumbContent>\n </>\n );\n\n if (!href) {\n return <Subordinate color=\"textPrimary\">{breadcrumbContent}</Subordinate>;\n }\n\n if (breadcrumbType === \"menuItem\") {\n return (\n <MenuItem onClick={onClickHandler} href={href}>\n {breadcrumbContent}\n </MenuItem>\n );\n }\n\n if (breadcrumbType === \"currentPage\") {\n return (\n <Subordinate ariaCurrent=\"page\" color=\"textPrimary\">\n {breadcrumbContent}\n </Subordinate>\n );\n }\n\n // breadcrumbType === \"listItem\" is the default\n // Provided here without a conditional to get TS to be quiet\n // about potential undefined returns\n return (\n <ButtonBase onClick={onClickHandler} href={href}>\n {breadcrumbContent}\n </ButtonBase>\n );\n};\n\nconst breadcrumbProviderValue: Record<\n BreadcrumbType,\n { breadcrumbType: BreadcrumbType }\n> = {\n currentPage: {\n breadcrumbType: \"currentPage\",\n },\n listItem: {\n breadcrumbType: \"listItem\",\n },\n menuItem: {\n breadcrumbType: \"menuItem\",\n },\n};\n\nconst defaultTruncationValue = 5;\n\nconst BreadcrumbList = ({\n children,\n homeHref,\n maxVisibleItems: maxVisibleItemsProp = defaultTruncationValue,\n testId,\n translate,\n}: BreadcrumbsProps) => {\n const { t } = useTranslation();\n\n const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);\n\n const maxVisibleItems = useMemo(\n () => Math.min(Math.max(maxVisibleItemsProp, 0), children.length),\n [maxVisibleItemsProp, children],\n );\n\n const breadcrumbSections = useMemo(() => {\n if (children.length <= maxVisibleItems) {\n return {\n beforeMenu: [],\n insideMenu: [],\n remainingBreadcrumbs: children,\n };\n } else {\n const menuStart = Math.floor(maxVisibleItems / 2);\n const menuLength = children.length - maxVisibleItems;\n\n return {\n beforeMenu: children.slice(0, menuStart),\n insideMenu: children.slice(menuStart, menuStart + menuLength),\n remainingBreadcrumbs: children.slice(menuStart + menuLength),\n };\n }\n }, [children, maxVisibleItems]);\n\n const onMenuButtonClick = useCallback<MouseEventHandler<HTMLButtonElement>>(\n (event) => setAnchorEl(event.currentTarget),\n [],\n );\n const onCloseMenu = useCallback(() => {\n setAnchorEl(null);\n }, []);\n\n return (\n <MuiBreadcrumbs\n maxItems={children.length + 1}\n aria-label={t(\"breadcrumbs.label.text\")}\n data-se={testId}\n translate={translate}\n >\n {homeHref && (\n <ButtonBase href={homeHref} aria-label={t(\"breadcrumbs.home.text\")}>\n <HomeIcon />\n </ButtonBase>\n )}\n\n {breadcrumbSections.beforeMenu.map((breadcrumb, index) => (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.listItem}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n ))}\n\n {breadcrumbSections.insideMenu.length > 0 && (\n <>\n <ButtonBase onClick={onMenuButtonClick}>...</ButtonBase>\n <Menu\n open={Boolean(anchorEl)}\n onClose={onCloseMenu}\n anchorEl={anchorEl}\n anchorOrigin={{ horizontal: \"left\", vertical: \"bottom\" }}\n MenuListProps={{\n sx: {\n minWidth: 180,\n },\n }}\n >\n <BreadcrumbContext.Provider\n value={breadcrumbProviderValue.menuItem}\n >\n {breadcrumbSections.insideMenu}\n </BreadcrumbContext.Provider>\n </Menu>\n </>\n )}\n\n {breadcrumbSections.remainingBreadcrumbs.map((breadcrumb, index) => {\n if (index === breadcrumbSections.remainingBreadcrumbs.length - 1) {\n return (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.currentPage}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n );\n }\n return (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.listItem}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n );\n })}\n </MuiBreadcrumbs>\n );\n};\n\nconst MemoizedBreadcrumbList = memo(BreadcrumbList);\nMemoizedBreadcrumbList.displayName = \"BreadcrumbList\";\n\nexport { MemoizedBreadcrumbList as BreadcrumbList };\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA,SAGEA,aAAa,EACbC,IAAI,EACJC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,SAASC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,4BAA4B;AAC1E,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAqBrC,OAAO,MAAMC,iBAAiB,GAAGlB,aAAa,CAAwB;EACpEmB,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,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AAAvC,QAAA,EAAC;MAAG,CAAY,CAAC,EACxDV,IAAA,CAAA2D,KAAA;QACEC,IAAI,EAAEC,OAAO,CAAC1B,QAAQ,CAAE;QACxB2B,OAAO,EAAEX,WAAY;QACrBhB,QAAQ,EAAEA,QAAS;QACnB4B,YAAY,EAAE;UAAEC,UAAU,EAAE,MAAM;UAAEC,QAAQ,EAAE;QAAS,CAAE;QACzDC,aAAa,EAAE;UACbC,EAAE,EAAE;YACFC,QAAQ,EAAE;UACZ;QACF,CAAE;QAAA1D,QAAA,EAEFV,IAAA,CAACK,iBAAiB,CAACoD,QAAQ;UACzBC,KAAK,EAAEnC,uBAAuB,CAACG,QAAS;UAAAhB,QAAA,EAEvC+B,kBAAkB,CAACE;QAAU,CACJ;MAAC,CACzB,CAAC;IAAA,CACP,CACH,EAEAF,kBAAkB,CAACG,oBAAoB,CAACU,GAAG,CAAC,CAACC,UAAU,EAAEC,KAAK,KAAK;MAClE,IAAIA,KAAK,KAAKf,kBAAkB,CAACG,oBAAoB,CAACJ,MAAM,GAAG,CAAC,EAAE;QAChE,OACExC,IAAA,CAACK,iBAAiB,CAACoD,QAAQ;UAEzBC,KAAK,EAAEnC,uBAAuB,CAACC,WAAY;UAAAd,QAAA,EAE1C6C;QAAU,GAHNC,KAIqB,CAAC;MAEjC;MACA,OACExD,IAAA,CAACK,iBAAiB,CAACoD,QAAQ;QAEzBC,KAAK,EAAEnC,uBAAuB,CAACE,QAAS;QAAAf,QAAA,EAEvC6C;MAAU,GAHNC,KAIqB,CAAC;IAEjC,CAAC,CAAC;EAAA,CACY,CAAC;AAErB,CAAC;AAED,MAAMa,sBAAsB,GAAGjF,IAAI,CAACwC,cAAc,CAAC;AACnDyC,sBAAsB,CAACC,WAAW,GAAG,gBAAgB;AAErD,SAASD,sBAAsB,IAAIzC,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.js","names":["createContext","memo","useCallback","useContext","useMemo","useState","GroupIcon","HomeIcon","UserIcon","Subordinate","useTranslation","styled","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","BreadcrumbContext","breadcrumbType","BreadcrumbContent","span","Breadcrumb","children","href","iconName","onClick","onClickHandler","event","preventDefault","stopPropagation","breadcrumbContent","color","_MenuItem","component","ariaCurrent","_ButtonBase","breadcrumbProviderValue","currentPage","listItem","menuItem","defaultTruncationValue","BreadcrumbList","homeHref","maxVisibleItems","maxVisibleItemsProp","testId","translate","t","anchorEl","setAnchorEl","Math","min","max","length","breadcrumbSections","beforeMenu","insideMenu","remainingBreadcrumbs","menuStart","floor","menuLength","slice","onMenuButtonClick","currentTarget","onCloseMenu","_Breadcrumbs","maxItems","map","breadcrumb","index","Provider","value","_Menu","open","Boolean","onClose","anchorOrigin","horizontal","vertical","MenuListProps","sx","minWidth","MemoizedBreadcrumbList","displayName"],"sources":["../../src/Breadcrumbs.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-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 ButtonBase,\n Menu,\n MenuItem,\n Breadcrumbs as MuiBreadcrumbs,\n} from \"@mui/material\";\nimport {\n MouseEventHandler,\n ReactElement,\n createContext,\n memo,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from \"react\";\nimport { GroupIcon, HomeIcon, UserIcon } from \"./icons.generated/index.js\";\nimport { Subordinate } from \"./Typography.js\";\nimport { useTranslation } from \"react-i18next\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport styled from \"@emotion/styled\";\n\nexport type BreadcrumbType = \"listItem\" | \"menuItem\" | \"currentPage\";\n\nexport type BreadcrumbProps = {\n children?: string;\n href?: string;\n iconName?: \"user\" | \"group\";\n onClick?: MouseEventHandler;\n};\n\nexport type BreadcrumbsProps = {\n children: ReactElement<typeof Breadcrumb>[];\n homeHref?: string;\n maxVisibleItems?: number;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nexport type BreadcrumbContextType = {\n breadcrumbType: BreadcrumbType;\n};\n\nexport const BreadcrumbContext = createContext<BreadcrumbContextType>({\n breadcrumbType: \"listItem\",\n});\n\nconst BreadcrumbContent = styled.span`\n white-space: nowrap;\n overflow: hidden;\n max-width: 10rem;\n text-overflow: ellipsis;\n`;\n\nexport const Breadcrumb = ({\n children,\n href,\n iconName,\n onClick,\n}: BreadcrumbProps) => {\n const { breadcrumbType } = useContext(BreadcrumbContext);\n\n const onClickHandler = useCallback<MouseEventHandler<HTMLAnchorElement>>(\n (event) => {\n if (onClick) {\n event.preventDefault();\n event.stopPropagation();\n onClick(event);\n }\n },\n [onClick],\n );\n\n const breadcrumbContent = (\n <>\n {iconName === \"group\" ? (\n <GroupIcon />\n ) : iconName === \"user\" ? (\n <UserIcon />\n ) : null}\n <BreadcrumbContent>{children}</BreadcrumbContent>\n </>\n );\n\n if (!href) {\n return <Subordinate color=\"textPrimary\">{breadcrumbContent}</Subordinate>;\n }\n\n if (breadcrumbType === \"menuItem\") {\n return (\n <MenuItem onClick={onClickHandler} href={href} component=\"a\">\n {breadcrumbContent}\n </MenuItem>\n );\n }\n\n if (breadcrumbType === \"currentPage\") {\n return (\n <Subordinate ariaCurrent=\"page\" color=\"textPrimary\">\n {breadcrumbContent}\n </Subordinate>\n );\n }\n\n // breadcrumbType === \"listItem\" is the default\n // Provided here without a conditional to get TS to be quiet\n // about potential undefined returns\n return (\n <ButtonBase onClick={onClickHandler} href={href}>\n {breadcrumbContent}\n </ButtonBase>\n );\n};\n\nconst breadcrumbProviderValue: Record<\n BreadcrumbType,\n { breadcrumbType: BreadcrumbType }\n> = {\n currentPage: {\n breadcrumbType: \"currentPage\",\n },\n listItem: {\n breadcrumbType: \"listItem\",\n },\n menuItem: {\n breadcrumbType: \"menuItem\",\n },\n};\n\nconst defaultTruncationValue = 5;\n\nconst BreadcrumbList = ({\n children,\n homeHref,\n maxVisibleItems: maxVisibleItemsProp = defaultTruncationValue,\n testId,\n translate,\n}: BreadcrumbsProps) => {\n const { t } = useTranslation();\n\n const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);\n\n const maxVisibleItems = useMemo(\n () => Math.min(Math.max(maxVisibleItemsProp, 0), children.length),\n [maxVisibleItemsProp, children],\n );\n\n const breadcrumbSections = useMemo(() => {\n if (children.length <= maxVisibleItems) {\n return {\n beforeMenu: [],\n insideMenu: [],\n remainingBreadcrumbs: children,\n };\n } else {\n const menuStart = Math.floor(maxVisibleItems / 2);\n const menuLength = children.length - maxVisibleItems;\n\n return {\n beforeMenu: children.slice(0, menuStart),\n insideMenu: children.slice(menuStart, menuStart + menuLength),\n remainingBreadcrumbs: children.slice(menuStart + menuLength),\n };\n }\n }, [children, maxVisibleItems]);\n\n const onMenuButtonClick = useCallback<MouseEventHandler<HTMLButtonElement>>(\n (event) => setAnchorEl(event.currentTarget),\n [],\n );\n const onCloseMenu = useCallback(() => {\n setAnchorEl(null);\n }, []);\n\n return (\n <MuiBreadcrumbs\n maxItems={children.length + 1}\n aria-label={t(\"breadcrumbs.label.text\")}\n data-se={testId}\n translate={translate}\n >\n {homeHref && (\n <ButtonBase href={homeHref} aria-label={t(\"breadcrumbs.home.text\")}>\n <HomeIcon />\n </ButtonBase>\n )}\n\n {breadcrumbSections.beforeMenu.map((breadcrumb, index) => (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.listItem}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n ))}\n\n {breadcrumbSections.insideMenu.length > 0 && (\n <>\n <ButtonBase onClick={onMenuButtonClick}>...</ButtonBase>\n <Menu\n open={Boolean(anchorEl)}\n onClose={onCloseMenu}\n anchorEl={anchorEl}\n anchorOrigin={{ horizontal: \"left\", vertical: \"bottom\" }}\n MenuListProps={{\n sx: {\n minWidth: 180,\n },\n }}\n >\n <BreadcrumbContext.Provider\n value={breadcrumbProviderValue.menuItem}\n >\n {breadcrumbSections.insideMenu}\n </BreadcrumbContext.Provider>\n </Menu>\n </>\n )}\n\n {breadcrumbSections.remainingBreadcrumbs.map((breadcrumb, index) => {\n if (index === breadcrumbSections.remainingBreadcrumbs.length - 1) {\n return (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.currentPage}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n );\n }\n return (\n <BreadcrumbContext.Provider\n key={index}\n value={breadcrumbProviderValue.listItem}\n >\n {breadcrumb}\n </BreadcrumbContext.Provider>\n );\n })}\n </MuiBreadcrumbs>\n );\n};\n\nconst MemoizedBreadcrumbList = memo(BreadcrumbList);\nMemoizedBreadcrumbList.displayName = \"BreadcrumbList\";\n\nexport { MemoizedBreadcrumbList as BreadcrumbList };\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA,SAGEA,aAAa,EACbC,IAAI,EACJC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,QAAQ,QACH,OAAO;AACd,SAASC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,4BAA4B;AAC1E,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAqBrC,OAAO,MAAMC,iBAAiB,GAAGlB,aAAa,CAAwB;EACpEmB,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGT,MAAM,CAACU,IAAI;AACrC;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,UAAU,GAAGA,CAAC;E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EC,OAAO,CAAC1B,QAAQ,CAAE;QACxB2B,OAAO,EAAEX,WAAY;QACrBhB,QAAQ,EAAEA,QAAS;QACnB4B,YAAY,EAAE;UAAEC,UAAU,EAAE,MAAM;UAAEC,QAAQ,EAAE;QAAS,CAAE;QACzDC,aAAa,EAAE;UACbC,EAAE,EAAE;YACFC,QAAQ,EAAE;UACZ;QACF,CAAE;QAAA3D,QAAA,EAEFV,IAAA,CAACK,iBAAiB,CAACqD,QAAQ;UACzBC,KAAK,EAAEnC,uBAAuB,CAACG,QAAS;UAAAjB,QAAA,EAEvCgC,kBAAkB,CAACE;QAAU,CACJ;MAAC,CACzB,CAAC;IAAA,CACP,CACH,EAEAF,kBAAkB,CAACG,oBAAoB,CAACU,GAAG,CAAC,CAACC,UAAU,EAAEC,KAAK,KAAK;MAClE,IAAIA,KAAK,KAAKf,kBAAkB,CAACG,oBAAoB,CAACJ,MAAM,GAAG,CAAC,EAAE;QAChE,OACEzC,IAAA,CAACK,iBAAiB,CAACqD,QAAQ;UAEzBC,KAAK,EAAEnC,uBAAuB,CAACC,WAAY;UAAAf,QAAA,EAE1C8C;QAAU,GAHNC,KAIqB,CAAC;MAEjC;MACA,OACEzD,IAAA,CAACK,iBAAiB,CAACqD,QAAQ;QAEzBC,KAAK,EAAEnC,uBAAuB,CAACE,QAAS;QAAAhB,QAAA,EAEvC8C;MAAU,GAHNC,KAIqB,CAAC;IAEjC,CAAC,CAAC;EAAA,CACY,CAAC;AAErB,CAAC;AAED,MAAMa,sBAAsB,GAAGlF,IAAI,CAACyC,cAAc,CAAC;AACnDyC,sBAAsB,CAACC,WAAW,GAAG,gBAAgB;AAErD,SAASD,sBAAsB,IAAIzC,cAAc","ignoreList":[]}
|
package/dist/esm/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["memo","useImperativeHandle","useRef","ExternalLinkIcon","jsx","_jsx","jsxs","_jsxs","linkVariantValues","Link","ariaLabel","children","href","icon","linkRef","rel","target","testId","translate","variant","onClick","localLinkRef","focus","current","_Link","ref","className","role","MemoizedLink","displayName"],"sources":["../../src/Link.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 {
|
|
1
|
+
{"version":3,"file":"Link.js","names":["memo","useImperativeHandle","useRef","ExternalLinkIcon","jsx","_jsx","jsxs","_jsxs","linkVariantValues","Link","ariaLabel","children","href","icon","linkRef","rel","target","testId","translate","variant","onClick","localLinkRef","focus","current","_Link","ref","className","role","MemoizedLink","displayName"],"sources":["../../src/Link.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 {\n memo,\n ReactElement,\n ReactNode,\n RefObject,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport { ExternalLinkIcon } from \"./icons.generated/index.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport { FocusHandle } from \"./inputUtils.js\";\n\nimport { Link as MuiLink, LinkProps as MuiLinkProps } from \"@mui/material\";\n\nexport const linkVariantValues = [\"default\", \"monochrome\"] as const;\n\nexport type LinkProps = {\n /**\n * The content within the Link\n */\n children: ReactNode;\n /**\n * The Link destination\n */\n href: string;\n /**\n * An optional Icon component at the start of the Link\n */\n icon?: ReactElement;\n /**\n * The ref forwarded to the TextField\n */\n linkRef?: RefObject<FocusHandle>;\n /**\n * The click event handler for the Link\n */\n onClick?: MuiLinkProps[\"onClick\"];\n /**\n * The rel attribute defines the relationship between a linked resource and the current document\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel\n */\n rel?: string;\n /**\n * The HTML `target` attribute for the Link\n */\n target?:\n | \"_self\"\n | \"_blank\"\n | \"_parent\"\n | \"_top\"\n | (string & NonNullable<unknown>);\n /**\n * The visual presentation of the Link (default or monochrome)\n */\n variant?: (typeof linkVariantValues)[number];\n} & Pick<HtmlProps, \"ariaLabel\" | \"testId\" | \"translate\">;\n\nconst Link = ({\n ariaLabel,\n children,\n href,\n icon,\n linkRef,\n rel,\n target,\n testId,\n translate,\n variant,\n onClick,\n}: LinkProps) => {\n const localLinkRef = useRef<HTMLAnchorElement>(null);\n useImperativeHandle(linkRef, () => {\n return {\n focus: () => {\n localLinkRef.current?.focus();\n },\n };\n }, []);\n\n return (\n <MuiLink\n aria-label={ariaLabel}\n data-se={testId}\n href={href}\n ref={localLinkRef}\n rel={rel}\n target={target}\n translate={translate}\n variant={variant}\n onClick={onClick}\n >\n {icon && <span className=\"Link-icon\">{icon}</span>}\n\n {children}\n\n {target === \"_blank\" && (\n <span className=\"Link-indicator\" role=\"presentation\">\n <ExternalLinkIcon />\n </span>\n )}\n </MuiLink>\n );\n};\n\nconst MemoizedLink = memo(Link);\n\nMemoizedLink.displayName = \"Link\";\n\nexport { MemoizedLink as Link };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAIJC,mBAAmB,EACnBC,MAAM,QACD,OAAO;AACd,SAASC,gBAAgB,QAAQ,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KA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