@okta/odyssey-react-mui 1.39.1 → 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/README.md +1 -1
- 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/Buttons/BaseMenuButton.cjs.map +1 -1
- package/dist/cjs/Buttons/MenuItem.cjs +1 -2
- package/dist/cjs/Buttons/MenuItem.cjs.map +1 -1
- package/dist/cjs/CheckboxGroup.cjs +1 -2
- package/dist/cjs/CheckboxGroup.cjs.map +1 -1
- package/dist/cjs/DataTable/DataTable.cjs.map +1 -1
- package/dist/cjs/DatePickers/datePickerTheme.cjs +1 -2
- package/dist/cjs/DatePickers/datePickerTheme.cjs.map +1 -1
- package/dist/cjs/Drawer.cjs.map +1 -1
- package/dist/cjs/Link.cjs.map +1 -1
- package/dist/cjs/NativeSelect.cjs +1 -2
- package/dist/cjs/NativeSelect.cjs.map +1 -1
- package/dist/cjs/OdysseyCacheProvider.cjs.map +1 -1
- package/dist/cjs/OdysseyDesignTokensContext.cjs +1 -2
- package/dist/cjs/OdysseyDesignTokensContext.cjs.map +1 -1
- package/dist/cjs/OdysseyThemeProvider.cjs +1 -2
- package/dist/cjs/OdysseyThemeProvider.cjs.map +1 -1
- package/dist/cjs/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/RadioGroup.cjs +1 -2
- package/dist/cjs/RadioGroup.cjs.map +1 -1
- package/dist/cjs/Tag.cjs +9 -2
- package/dist/cjs/Tag.cjs.map +1 -1
- package/dist/cjs/inputUtils.cjs.map +1 -1
- package/dist/cjs/labs/DataFilters.cjs.map +1 -1
- package/dist/cjs/labs/DataTable.cjs +11 -10
- package/dist/cjs/labs/DataTable.cjs.map +1 -1
- package/dist/cjs/labs/DataView/componentTypes.cjs.map +1 -1
- package/dist/cjs/labs/DataView/dataTypes.cjs.map +1 -1
- package/dist/cjs/labs/DataView/testSupportData.cjs.map +1 -1
- package/dist/cjs/labs/GroupPicker.cjs +1 -2
- package/dist/cjs/labs/GroupPicker.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/useContrastMode.cjs +1 -2
- package/dist/cjs/useContrastMode.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/cjs/web-component/renderReactInWebComponent.cjs +1 -2
- package/dist/cjs/web-component/renderReactInWebComponent.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/Buttons/BaseMenuButton.js.map +1 -1
- package/dist/esm/DataTable/DataTable.js.map +1 -1
- package/dist/esm/Drawer.js.map +1 -1
- package/dist/esm/Link.js.map +1 -1
- package/dist/esm/OdysseyCacheProvider.js.map +1 -1
- package/dist/esm/Pagination/Pagination.js.map +1 -1
- package/dist/esm/Tag.js +9 -2
- package/dist/esm/Tag.js.map +1 -1
- package/dist/esm/inputUtils.js.map +1 -1
- package/dist/esm/labs/DataFilters.js.map +1 -1
- package/dist/esm/labs/DataTable.js +2 -1
- package/dist/esm/labs/DataTable.js.map +1 -1
- package/dist/esm/labs/DataView/componentTypes.js.map +1 -1
- package/dist/esm/labs/DataView/dataTypes.js.map +1 -1
- package/dist/esm/labs/DataView/testSupportData.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 +231 -0
- package/dist/index.d.ts +233 -0
- package/dist/index.mjs +229 -0
- package/dist/index.scss +549 -0
- 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/Buttons/BaseMenuButton.d.ts +2 -2
- package/dist/types/CssBaseline.d.ts.map +1 -1
- package/dist/types/DataTable/DataTable.d.ts +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 +1 -1
- package/dist/types/inputUtils.d.ts.map +1 -1
- package/dist/types/labs/DataTable.d.ts +4 -4
- package/dist/types/labs/DataTable.d.ts.map +1 -1
- package/dist/types/labs/DataView/componentTypes.d.ts +1 -1
- package/dist/types/labs/DataView/componentTypes.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 +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 +19 -19
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,KAAA;AAM9D,OAAO,MAAMC,iBAAiB,GAAG,CAAC,SAAS,EAAE,YAAY,CAAU;AA4CnE,MAAMC,IAAI,GAAGA,CAAC;EACZC,SAAS;EACTC,QAAQ;EACRC,IAAI;EACJC,IAAI;EACJC,OAAO;EACPC,GAAG;EACHC,MAAM;EACNC,MAAM;EACNC,SAAS;EACTC,OAAO;EACPC;AACS,CAAC,KAAK;EACf,MAAMC,YAAY,GAAGnB,MAAM,CAAoB,IAAI,CAAC;EACpDD,mBAAmB,CAACa,OAAO,EAAE,MAAM;IACjC,OAAO;MACLQ,KAAK,EAAEA,CAAA,KAAM;QACXD,YAAY,CAACE,OAAO,EAAED,KAAK,CAAC,CAAC;MAC/B;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OACEf,KAAA,CAAAiB,KAAA;IACE,cAAYd,SAAU;IACtB,WAASO,MAAO;IAChBL,IAAI,EAAEA,IAAK;IACXa,GAAG,EAAEJ,YAAa;IAClBN,GAAG,EAAEA,GAAI;IACTC,MAAM,EAAEA,MAAO;IACfE,SAAS,EAAEA,SAAU;IACrBC,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IAAAT,QAAA,GAEhBE,IAAI,IAAIR,IAAA;MAAMqB,SAAS,EAAC,WAAW;MAAAf,QAAA,EAAEE;IAAI,CAAO,CAAC,EAEjDF,QAAQ,EAERK,MAAM,KAAK,QAAQ,IAClBX,IAAA;MAAMqB,SAAS,EAAC,gBAAgB;MAACC,IAAI,EAAC,cAAc;MAAAhB,QAAA,EAClDN,IAAA,CAACF,gBAAgB,IAAE;IAAC,CAChB,CACP;EAAA,CACM,CAAC;AAEd,CAAC;AAED,MAAMyB,YAAY,GAAG5B,IAAI,CAACS,IAAI,CAAC;AAE/BmB,YAAY,CAACC,WAAW,GAAG,MAAM;AAEjC,SAASD,YAAY,IAAInB,IAAI","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","memo","useMemo","useUniqueAlphabeticalId","CacheProvider","jsx","_jsx","OdysseyCacheProvider","children","emotionRoot","emotionRootElement","hasShadowDom","hasShadowDomProp","nonce","shadowDomElement","stylisPlugins","uniqueAlphabeticalId","emotionCache","container","key","globalThis","cspNonce","prepend","speedy","value","MemoizedOdysseyCacheProvider","displayName"],"sources":["../../src/OdysseyCacheProvider.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\ndeclare global {\n
|
|
1
|
+
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","memo","useMemo","useUniqueAlphabeticalId","CacheProvider","jsx","_jsx","OdysseyCacheProvider","children","emotionRoot","emotionRootElement","hasShadowDom","hasShadowDomProp","nonce","shadowDomElement","stylisPlugins","uniqueAlphabeticalId","emotionCache","container","key","globalThis","cspNonce","prepend","speedy","value","MemoizedOdysseyCacheProvider","displayName"],"sources":["../../src/OdysseyCacheProvider.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\ndeclare global {\n var cspNonce: string; // Adding types to `globalThis` requires we use `var`.\n}\n\nimport createCache, { StylisPlugin } from \"@emotion/cache\";\nimport { memo, useMemo, ReactNode } from \"react\";\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId.js\";\nimport { CacheProvider } from \"@emotion/react\";\n\nexport type OdysseyCacheProviderProps = {\n children: ReactNode;\n /**\n * Emotion caches styles into the style element.\n * When enabling this prop, Emotion caches the styles at this element, rather than in <head>.\n * @deprecated Use `EmotionRootElement` instead. This was incorrectly configured as an `HTMLStyleElement`, but then we're rendering `<style>` inside `<style>`. We need this to be a `<div>` instead.\n */\n emotionRoot?: HTMLStyleElement;\n /**\n * Emotion adds `<style>` elements into this DOM node. Normally, Emotion puts these in `document.head`.\n * This is useful if you want to render into a Shadow DOM or iframe.\n */\n emotionRootElement?: HTMLElement;\n hasShadowDom?: boolean;\n nonce?: string;\n /**\n * Emotion renders into this HTML element.\n * When enabling this prop, Emotion renders at the top of this component rather than the bottom like it does in the HTML `<head>`.\n * @deprecated Will be removed in a future Odyssey version. Use `hasShadowDomElement` instead.\n */\n shadowDomElement?: HTMLDivElement | HTMLElement;\n stylisPlugins?: StylisPlugin[];\n};\n\nconst OdysseyCacheProvider = ({\n children,\n emotionRoot,\n emotionRootElement,\n hasShadowDom: hasShadowDomProp,\n nonce,\n shadowDomElement,\n stylisPlugins,\n}: OdysseyCacheProviderProps) => {\n const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n const hasShadowDom = hasShadowDomProp || shadowDomElement;\n\n const emotionCache = useMemo(() => {\n return createCache({\n ...((emotionRootElement || emotionRoot) && {\n container: emotionRootElement || emotionRoot,\n }),\n key: uniqueAlphabeticalId,\n nonce: nonce ?? globalThis.cspNonce,\n prepend: true,\n speedy: hasShadowDom ? false : true, // <-- Needs to be set to false when shadow-dom is used! https://github.com/emotion-js/emotion/issues/2053#issuecomment-713429122\n ...(stylisPlugins && { stylisPlugins }),\n });\n }, [\n emotionRoot,\n emotionRootElement,\n hasShadowDom,\n nonce,\n stylisPlugins,\n uniqueAlphabeticalId,\n ]);\n\n return <CacheProvider value={emotionCache}>{children}</CacheProvider>;\n};\n\nconst MemoizedOdysseyCacheProvider = memo(OdysseyCacheProvider);\nMemoizedOdysseyCacheProvider.displayName = \"OdysseyCacheProvider\";\n\nexport { MemoizedOdysseyCacheProvider as OdysseyCacheProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAOA,WAAW,MAAwB,gBAAgB;AAC1D,SAASC,IAAI,EAAEC,OAAO,QAAmB,OAAO;AAChD,SAASC,uBAAuB,QAAQ,8BAA8B;AACtE,SAASC,aAAa,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA0B/C,MAAMC,oBAAoB,GAAGA,CAAC;EAC5BC,QAAQ;EACRC,WAAW;EACXC,kBAAkB;EAClBC,YAAY,EAAEC,gBAAgB;EAC9BC,KAAK;EACLC,gBAAgB;EAChBC;AACyB,CAAC,KAAK;EAC/B,MAAMC,oBAAoB,GAAGb,uBAAuB,CAAC,CAAC;EAEtD,MAAMQ,YAAY,GAAGC,gBAAgB,IAAIE,gBAAgB;EAEzD,MAAMG,YAAY,GAAGf,OAAO,CAAC,MAAM;IACjC,OAAOF,WAAW,CAAC;MACjB,IAAI,CAACU,kBAAkB,IAAID,WAAW,KAAK;QACzCS,SAAS,EAAER,kBAAkB,IAAID;MACnC,CAAC,CAAC;MACFU,GAAG,EAAEH,oBAAoB;MACzBH,KAAK,EAAEA,KAAK,IAAIO,UAAU,CAACC,QAAQ;MACnCC,OAAO,EAAE,IAAI;MACbC,MAAM,EAAEZ,YAAY,GAAG,KAAK,GAAG,IAAI;MACnC,IAAII,aAAa,IAAI;QAAEA;MAAc,CAAC;IACxC,CAAC,CAAC;EACJ,CAAC,EAAE,CACDN,WAAW,EACXC,kBAAkB,EAClBC,YAAY,EACZE,KAAK,EACLE,aAAa,EACbC,oBAAoB,CACrB,CAAC;EAEF,OAAOV,IAAA,CAACF,aAAa;IAACoB,KAAK,EAAEP,YAAa;IAAAT,QAAA,EAAEA;EAAQ,CAAgB,CAAC;AACvE,CAAC;AAED,MAAMiB,4BAA4B,GAAGxB,IAAI,CAACM,oBAAoB,CAAC;AAC/DkB,4BAA4B,CAACC,WAAW,GAAG,sBAAsB;AAEjE,SAASD,4BAA4B,IAAIlB,oBAAoB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","names":["styled","memo","useCallback","useEffect","useMemo","useRef","useState","useTranslation","Box","Button","ArrowLeftIcon","ArrowRightIcon","useOdysseyDesignTokens","usePagination","Paragraph","jsx","_jsx","jsxs","_jsxs","PaginationContainer","display","justifyContent","PaginationSegment","shouldForwardProp","prop","odysseyDesignTokens","alignItems","gap","Spacing4","Spacing2","PaginationInput","_InputBase","borderColor","HueNeutral200","borderRadius","BorderRadiusTight","height","Spacing6","width","HueNeutral400","PalettePrimaryMain","PaginationButtonContainer","marginInlineStart","Pagination","currentPageLabel","currentPageLabelProp","currentRowsCount","hasPageInput","hasRowCountInput","hasRowCountLabel","isDisabled","isMoreDisabled","lastRow","loadMoreLabel","loadMoreLabelProp","maxPageIndex","maxPageSize","nextLabel","nextLabelProp","onPaginationChange","onPaginationChangeProp","pageIndex","pageSize","previousLabel","previousLabelProp","rowsPerPageLabel","rowsPerPageLabelProp","totalRows","variant","t","page","setPage","rowsPerPage","setRowsPerPage","initialRowsPerPage","totalRowsLabel","handlePaginationChange","updatedPage","updatedRowsPerPage","Math","ceil","handlePageSubmit","event","key","Number","currentTarget","value","handleRowsPerPageSubmit","setPageFromEvent","min","target","max","setRowsPerPageFromEvent","handleLoadMore","current","handleNextButton","handlePreviousButton","loadMoreIsDisabled","nextButtonDisabled","previousButtonDisabled","rowsPerPageInputProps","currentPageInputProps","children","component","color","type","onChange","onBlur","onKeyDown","disabled","inputProps","startIcon","size","ariaLabel","onClick","endIcon","label","MemoizedPagination","displayName"],"sources":["../../../src/Pagination/Pagination.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 styled from \"@emotion/styled\";\nimport { InputBase } from \"@mui/material\";\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Box } from \"../Box.js\";\nimport { Button } from \"../Buttons/index.js\";\nimport { paginationTypeValues } from \"./constants.js\";\nimport { ArrowLeftIcon, ArrowRightIcon } from \"../icons.generated/index.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport { usePagination } from \"./usePagination.js\";\nimport { Paragraph } from \"../Typography.js\";\nimport \"../i18n.js\";\n\nconst PaginationContainer = styled(\"nav\")({\n display: \"flex\",\n justifyContent: \"space-between\",\n});\n\nconst PaginationSegment = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(({ odysseyDesignTokens }) => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing4,\n \"& > div\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing2,\n },\n}));\n\nconst PaginationInput = styled(InputBase, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(({ odysseyDesignTokens }) => ({\n borderColor: odysseyDesignTokens.HueNeutral200,\n borderRadius: odysseyDesignTokens.BorderRadiusTight,\n height: odysseyDesignTokens.Spacing6,\n width: \"4.5714285714rem\", // This is a hardcoded value, keep as string\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral400,\n },\n \"&.Mui-focused:hover\": {\n borderColor: odysseyDesignTokens.PalettePrimaryMain,\n },\n}));\n\nconst PaginationButtonContainer = styled(\"div\")({\n \"& > *\": {\n marginInlineStart: `0 !important`,\n },\n});\n\nexport type PaginationProps = {\n /**\n * The labeled rendered for the current page index\n */\n currentPageLabel?: string;\n /**\n * The number of items currently visible on the page\n */\n currentRowsCount?: number;\n /**\n * If true, the page input will be visible and the user can directly manipulate which page\n * is visible.\n */\n hasPageInput?: boolean;\n /**\n * If true, the row count input will be visible and the user can directly manipulate how many rows\n * are visible.\n */\n hasRowCountInput?: boolean;\n /**\n * If true, the \"X - X of total X\" label will be visible\n */\n hasRowCountLabel?: boolean;\n /**\n * If true, the pagination controls will be disabled\n */\n isDisabled?: boolean;\n /**\n * If true, the next or Show More button will be disabled\n */\n isMoreDisabled?: boolean;\n /**\n * The current page last row index\n */\n lastRow?: number;\n /**\n * If the pagination is of \"loadMore\" variant, then this is the the load more label\n */\n loadMoreLabel?: string;\n /**\n * The max page\n */\n maxPageIndex?: number;\n /**\n * The max rows per page\n */\n maxPageSize?: number;\n /**\n * The label for the next control\n */\n nextLabel?: string;\n /**\n * Page index and page size setter\n */\n onPaginationChange: ({\n pageIndex,\n pageSize,\n }: {\n pageIndex: number;\n pageSize: number;\n }) => void;\n /**\n * The current page index\n */\n pageIndex: number;\n /**\n * The current page size\n */\n pageSize: number;\n /**\n * The label for the previous control\n */\n previousLabel?: string;\n /**\n * The label that shows how many results are rendered per page\n */\n rowsPerPageLabel?: string;\n /**\n * Total rows count\n */\n totalRows?: number;\n /**\n * The type of pagination controls shown. Defaults to next/prev buttons, but can be\n * set to a simple \"Load more\" button by setting to \"loadMore\".\n */\n variant?: (typeof paginationTypeValues)[number];\n};\n\nconst Pagination = ({\n currentPageLabel: currentPageLabelProp,\n currentRowsCount,\n hasPageInput = true,\n hasRowCountInput = true,\n hasRowCountLabel = true,\n isDisabled,\n isMoreDisabled,\n lastRow,\n loadMoreLabel: loadMoreLabelProp,\n maxPageIndex,\n maxPageSize,\n nextLabel: nextLabelProp,\n onPaginationChange: onPaginationChangeProp,\n pageIndex,\n pageSize,\n previousLabel: previousLabelProp,\n rowsPerPageLabel: rowsPerPageLabelProp,\n totalRows,\n variant,\n}: PaginationProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const [page, setPage] = useState<number>(pageIndex);\n const [rowsPerPage, setRowsPerPage] = useState<number>(pageSize);\n const initialRowsPerPage = useRef<number>(pageSize);\n\n const currentPageLabel = currentPageLabelProp ?? t(\"pagination.page\");\n const loadMoreLabel = loadMoreLabelProp ?? t(\"pagination.loadmore\");\n const nextLabel = nextLabelProp ?? t(\"pagination.next\");\n const previousLabel = previousLabelProp ?? t(\"pagination.previous\");\n const rowsPerPageLabel = rowsPerPageLabelProp ?? t(\"pagination.rowsperpage\");\n\n useEffect(() => {\n setPage(pageIndex);\n setRowsPerPage(pageSize);\n }, [pageIndex, pageSize]);\n\n const onPaginationChange = useCallback(\n ({ pageIndex, pageSize }: { pageIndex: number; pageSize: number }) => {\n onPaginationChangeProp({ pageIndex, pageSize });\n },\n [onPaginationChangeProp],\n );\n\n const { totalRowsLabel } = usePagination({\n pageIndex,\n pageSize,\n currentRowsCount: currentRowsCount || 0,\n totalRows,\n });\n\n const handlePaginationChange = useCallback(() => {\n let updatedPage = page;\n let updatedRowsPerPage = rowsPerPage;\n\n if (totalRows) {\n const maxPageIndex = Math.ceil(totalRows / updatedRowsPerPage);\n\n // Ensure rowsPerPage does not exceed totalRows\n if (updatedRowsPerPage > totalRows) {\n updatedRowsPerPage = totalRows;\n }\n\n // Ensure page is within valid range\n if (updatedPage > maxPageIndex) {\n updatedPage = maxPageIndex;\n } else if (updatedPage < 1) {\n updatedPage = 1;\n }\n }\n\n onPaginationChange({\n pageIndex: updatedPage,\n pageSize: updatedRowsPerPage,\n });\n }, [page, rowsPerPage, onPaginationChange, totalRows]);\n\n // The following handlers use React.KeyboardEvent (rather than just KeyboardEvent) becuase React.KeyboardEvent\n // is generic, while plain KeyboardEvent is not. We need this generic so we can specify the HTMLInputElement,\n // which allows us to use currentTarget.value\n const handlePageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: Number(event.currentTarget.value),\n pageSize: rowsPerPage,\n });\n }\n },\n [rowsPerPage, onPaginationChange],\n );\n\n const handleRowsPerPageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: page,\n pageSize: Number(event.currentTarget.value),\n });\n }\n },\n [page, onPaginationChange],\n );\n\n const setPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageIndex\n ? Math.min(Number(event.target.value), maxPageIndex)\n : Number(event.target.value);\n\n // Ensure the value can't be less than 1\n setPage(Math.max(1, value));\n },\n [setPage, maxPageIndex],\n );\n\n const setRowsPerPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageSize\n ? Math.min(Number(event.target.value), maxPageSize)\n : Number(event.target.value);\n\n // Ensure the value can't be less than 1\n setRowsPerPage(Math.max(1, value));\n },\n [setRowsPerPage, maxPageSize],\n );\n\n const handleLoadMore = useCallback(() => {\n onPaginationChange({\n pageIndex: 1,\n pageSize: rowsPerPage + initialRowsPerPage.current,\n });\n }, [rowsPerPage, onPaginationChange]);\n\n const handleNextButton = useCallback(() => {\n onPaginationChange({ pageIndex: page + 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const handlePreviousButton = useCallback(() => {\n onPaginationChange({ pageIndex: page - 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const loadMoreIsDisabled = useMemo(() => {\n return isMoreDisabled || (totalRows ? rowsPerPage >= totalRows : false);\n }, [isMoreDisabled, rowsPerPage, totalRows]);\n\n const nextButtonDisabled = useMemo(\n () =>\n isMoreDisabled ||\n (lastRow && (totalRows ? lastRow >= totalRows : false)) ||\n isDisabled,\n [isMoreDisabled, totalRows, lastRow, isDisabled],\n );\n\n const previousButtonDisabled = useMemo(\n () => pageIndex <= 1 || isDisabled,\n [pageIndex, isDisabled],\n );\n\n const rowsPerPageInputProps = useMemo(\n () => ({\n \"aria-label\": rowsPerPageLabel,\n max: maxPageSize || totalRows,\n }),\n [maxPageSize, rowsPerPageLabel, totalRows],\n );\n\n const currentPageInputProps = useMemo(\n () => ({\n \"aria-label\": currentPageLabel,\n max: maxPageIndex,\n }),\n [currentPageLabel, maxPageIndex],\n );\n\n return variant === \"paged\" ? (\n <PaginationContainer aria-label={t(\"pagination.label\")}>\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {hasRowCountInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {rowsPerPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={rowsPerPage}\n onChange={setRowsPerPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handleRowsPerPageSubmit}\n disabled={isDisabled}\n inputProps={rowsPerPageInputProps}\n />\n </Box>\n )}\n {hasRowCountLabel && (\n <Paragraph component=\"span\" color=\"textSecondary\">\n {totalRowsLabel}\n </Paragraph>\n )}\n </PaginationSegment>\n\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {totalRows && hasPageInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {currentPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={page}\n onChange={setPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handlePageSubmit}\n disabled={isDisabled}\n inputProps={currentPageInputProps}\n />\n </Box>\n )}\n <PaginationButtonContainer>\n <Button\n startIcon={<ArrowLeftIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={previousLabel}\n onClick={handlePreviousButton}\n isDisabled={previousButtonDisabled}\n />\n <Button\n endIcon={<ArrowRightIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={nextLabel}\n onClick={handleNextButton}\n isDisabled={nextButtonDisabled}\n />\n </PaginationButtonContainer>\n </PaginationSegment>\n </PaginationContainer>\n ) : (\n <Button\n variant=\"secondary\"\n label={loadMoreLabel}\n onClick={handleLoadMore}\n isDisabled={loadMoreIsDisabled}\n />\n );\n};\n\nconst MemoizedPagination = memo(Pagination);\nMemoizedPagination.displayName = \"Pagination\";\n\nexport { MemoizedPagination as Pagination };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAi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CAACP,MAAM;IACL2D,OAAO,EAAC,WAAW;IACnBgD,KAAK,EAAE/D,aAAc;IACrB6D,OAAO,EAAErB,cAAe;IACxB3C,UAAU,EAAE+C;EAAmB,CAChC,CACF;AACH,CAAC;AAED,MAAMoB,kBAAkB,GAAGpH,IAAI,CAAC0C,UAAU,CAAC;AAC3C0E,kBAAkB,CAACC,WAAW,GAAG,YAAY;AAE7C,SAASD,kBAAkB,IAAI1E,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Pagination.js","names":["styled","memo","useCallback","useEffect","useMemo","useRef","useState","useTranslation","Box","Button","ArrowLeftIcon","ArrowRightIcon","useOdysseyDesignTokens","usePagination","Paragraph","jsx","_jsx","jsxs","_jsxs","PaginationContainer","display","justifyContent","PaginationSegment","shouldForwardProp","prop","odysseyDesignTokens","alignItems","gap","Spacing4","Spacing2","PaginationInput","_InputBase","borderColor","HueNeutral200","borderRadius","BorderRadiusTight","height","Spacing6","width","HueNeutral400","PalettePrimaryMain","PaginationButtonContainer","marginInlineStart","Pagination","currentPageLabel","currentPageLabelProp","currentRowsCount","hasPageInput","hasRowCountInput","hasRowCountLabel","isDisabled","isMoreDisabled","lastRow","loadMoreLabel","loadMoreLabelProp","maxPageIndex","maxPageSize","nextLabel","nextLabelProp","onPaginationChange","onPaginationChangeProp","pageIndex","pageSize","previousLabel","previousLabelProp","rowsPerPageLabel","rowsPerPageLabelProp","totalRows","variant","t","page","setPage","rowsPerPage","setRowsPerPage","initialRowsPerPage","totalRowsLabel","handlePaginationChange","updatedPage","updatedRowsPerPage","Math","ceil","handlePageSubmit","event","key","Number","currentTarget","value","handleRowsPerPageSubmit","setPageFromEvent","min","target","max","setRowsPerPageFromEvent","handleLoadMore","current","handleNextButton","handlePreviousButton","loadMoreIsDisabled","nextButtonDisabled","previousButtonDisabled","rowsPerPageInputProps","currentPageInputProps","children","component","color","type","onChange","onBlur","onKeyDown","disabled","inputProps","startIcon","size","ariaLabel","onClick","endIcon","label","MemoizedPagination","displayName"],"sources":["../../../src/Pagination/Pagination.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 styled from \"@emotion/styled\";\nimport { InputBase } from \"@mui/material\";\nimport { memo, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Box } from \"../Box.js\";\nimport { Button } from \"../Buttons/index.js\";\nimport { paginationTypeValues } from \"./constants.js\";\nimport { ArrowLeftIcon, ArrowRightIcon } from \"../icons.generated/index.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"../OdysseyDesignTokensContext.js\";\nimport { usePagination } from \"./usePagination.js\";\nimport { Paragraph } from \"../Typography.js\";\nimport \"../i18n.js\";\n\nconst PaginationContainer = styled(\"nav\")({\n display: \"flex\",\n justifyContent: \"space-between\",\n});\n\nconst PaginationSegment = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(({ odysseyDesignTokens }) => ({\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing4,\n \"& > div\": {\n display: \"flex\",\n alignItems: \"center\",\n gap: odysseyDesignTokens.Spacing2,\n },\n}));\n\nconst PaginationInput = styled(InputBase, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(({ odysseyDesignTokens }) => ({\n borderColor: odysseyDesignTokens.HueNeutral200,\n borderRadius: odysseyDesignTokens.BorderRadiusTight,\n height: odysseyDesignTokens.Spacing6,\n width: \"4.5714285714rem\", // This is a hardcoded value, keep as string\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral400,\n },\n \"&.Mui-focused:hover\": {\n borderColor: odysseyDesignTokens.PalettePrimaryMain,\n },\n}));\n\nconst PaginationButtonContainer = styled(\"div\")({\n \"& > *\": {\n marginInlineStart: `0 !important`,\n },\n});\n\nexport type PaginationProps = {\n /**\n * The labeled rendered for the current page index\n */\n currentPageLabel?: string;\n /**\n * The number of items currently visible on the page\n */\n currentRowsCount?: number;\n /**\n * If true, the page input will be visible and the user can directly manipulate which page\n * is visible.\n */\n hasPageInput?: boolean;\n /**\n * If true, the row count input will be visible and the user can directly manipulate how many rows\n * are visible.\n */\n hasRowCountInput?: boolean;\n /**\n * If true, the \"X - X of total X\" label will be visible\n */\n hasRowCountLabel?: boolean;\n /**\n * If true, the pagination controls will be disabled\n */\n isDisabled?: boolean;\n /**\n * If true, the next or Show More button will be disabled\n */\n isMoreDisabled?: boolean;\n /**\n * The current page last row index\n */\n lastRow?: number;\n /**\n * If the pagination is of \"loadMore\" variant, then this is the the load more label\n */\n loadMoreLabel?: string;\n /**\n * The max page\n */\n maxPageIndex?: number;\n /**\n * The max rows per page\n */\n maxPageSize?: number;\n /**\n * The label for the next control\n */\n nextLabel?: string;\n /**\n * Page index and page size setter\n */\n onPaginationChange: ({\n pageIndex,\n pageSize,\n }: {\n pageIndex: number;\n pageSize: number;\n }) => void;\n /**\n * The current page index\n */\n pageIndex: number;\n /**\n * The current page size\n */\n pageSize: number;\n /**\n * The label for the previous control\n */\n previousLabel?: string;\n /**\n * The label that shows how many results are rendered per page\n */\n rowsPerPageLabel?: string;\n /**\n * Total rows count\n */\n totalRows?: number;\n /**\n * The type of pagination controls shown. Defaults to next/prev buttons, but can be\n * set to a simple \"Load more\" button by setting to \"loadMore\".\n */\n variant?: (typeof paginationTypeValues)[number];\n};\n\nconst Pagination = ({\n currentPageLabel: currentPageLabelProp,\n currentRowsCount,\n hasPageInput = true,\n hasRowCountInput = true,\n hasRowCountLabel = true,\n isDisabled,\n isMoreDisabled,\n lastRow,\n loadMoreLabel: loadMoreLabelProp,\n maxPageIndex,\n maxPageSize,\n nextLabel: nextLabelProp,\n onPaginationChange: onPaginationChangeProp,\n pageIndex,\n pageSize,\n previousLabel: previousLabelProp,\n rowsPerPageLabel: rowsPerPageLabelProp,\n totalRows,\n variant,\n}: PaginationProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n\n const [page, setPage] = useState<number>(pageIndex);\n const [rowsPerPage, setRowsPerPage] = useState<number>(pageSize);\n const initialRowsPerPage = useRef<number>(pageSize);\n\n const currentPageLabel = currentPageLabelProp ?? t(\"pagination.page\");\n const loadMoreLabel = loadMoreLabelProp ?? t(\"pagination.loadmore\");\n const nextLabel = nextLabelProp ?? t(\"pagination.next\");\n const previousLabel = previousLabelProp ?? t(\"pagination.previous\");\n const rowsPerPageLabel = rowsPerPageLabelProp ?? t(\"pagination.rowsperpage\");\n\n useEffect(() => {\n setPage(pageIndex);\n setRowsPerPage(pageSize);\n }, [pageIndex, pageSize]);\n\n const onPaginationChange = useCallback(\n ({ pageIndex, pageSize }: { pageIndex: number; pageSize: number }) => {\n onPaginationChangeProp({ pageIndex, pageSize });\n },\n [onPaginationChangeProp],\n );\n\n const { totalRowsLabel } = usePagination({\n pageIndex,\n pageSize,\n currentRowsCount: currentRowsCount || 0,\n totalRows,\n });\n\n const handlePaginationChange = useCallback(() => {\n let updatedPage = page;\n let updatedRowsPerPage = rowsPerPage;\n\n if (totalRows) {\n const maxPageIndex = Math.ceil(totalRows / updatedRowsPerPage);\n\n // Ensure rowsPerPage does not exceed totalRows\n if (updatedRowsPerPage > totalRows) {\n updatedRowsPerPage = totalRows;\n }\n\n // Ensure page is within valid range\n if (updatedPage > maxPageIndex) {\n updatedPage = maxPageIndex;\n } else if (updatedPage < 1) {\n updatedPage = 1;\n }\n }\n\n onPaginationChange({\n pageIndex: updatedPage,\n pageSize: updatedRowsPerPage,\n });\n }, [page, rowsPerPage, onPaginationChange, totalRows]);\n\n // The following handlers use React.KeyboardEvent (rather than just KeyboardEvent) because React.KeyboardEvent\n // is generic, while plain KeyboardEvent is not. We need this generic so we can specify the HTMLInputElement,\n // which allows us to use currentTarget.value\n const handlePageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: Number(event.currentTarget.value),\n pageSize: rowsPerPage,\n });\n }\n },\n [rowsPerPage, onPaginationChange],\n );\n\n const handleRowsPerPageSubmit = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key === \"Enter\") {\n onPaginationChange({\n pageIndex: page,\n pageSize: Number(event.currentTarget.value),\n });\n }\n },\n [page, onPaginationChange],\n );\n\n const setPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageIndex\n ? Math.min(Number(event.target.value), maxPageIndex)\n : Number(event.target.value);\n\n // Ensure the value can't be less than 1\n setPage(Math.max(1, value));\n },\n [setPage, maxPageIndex],\n );\n\n const setRowsPerPageFromEvent = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const value = maxPageSize\n ? Math.min(Number(event.target.value), maxPageSize)\n : Number(event.target.value);\n\n // Ensure the value can't be less than 1\n setRowsPerPage(Math.max(1, value));\n },\n [setRowsPerPage, maxPageSize],\n );\n\n const handleLoadMore = useCallback(() => {\n onPaginationChange({\n pageIndex: 1,\n pageSize: rowsPerPage + initialRowsPerPage.current,\n });\n }, [rowsPerPage, onPaginationChange]);\n\n const handleNextButton = useCallback(() => {\n onPaginationChange({ pageIndex: page + 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const handlePreviousButton = useCallback(() => {\n onPaginationChange({ pageIndex: page - 1, pageSize: rowsPerPage });\n }, [onPaginationChange, page, rowsPerPage]);\n\n const loadMoreIsDisabled = useMemo(() => {\n return isMoreDisabled || (totalRows ? rowsPerPage >= totalRows : false);\n }, [isMoreDisabled, rowsPerPage, totalRows]);\n\n const nextButtonDisabled = useMemo(\n () =>\n isMoreDisabled ||\n (lastRow && (totalRows ? lastRow >= totalRows : false)) ||\n isDisabled,\n [isMoreDisabled, totalRows, lastRow, isDisabled],\n );\n\n const previousButtonDisabled = useMemo(\n () => pageIndex <= 1 || isDisabled,\n [pageIndex, isDisabled],\n );\n\n const rowsPerPageInputProps = useMemo(\n () => ({\n \"aria-label\": rowsPerPageLabel,\n max: maxPageSize || totalRows,\n }),\n [maxPageSize, rowsPerPageLabel, totalRows],\n );\n\n const currentPageInputProps = useMemo(\n () => ({\n \"aria-label\": currentPageLabel,\n max: maxPageIndex,\n }),\n [currentPageLabel, maxPageIndex],\n );\n\n return variant === \"paged\" ? (\n <PaginationContainer aria-label={t(\"pagination.label\")}>\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {hasRowCountInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {rowsPerPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={rowsPerPage}\n onChange={setRowsPerPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handleRowsPerPageSubmit}\n disabled={isDisabled}\n inputProps={rowsPerPageInputProps}\n />\n </Box>\n )}\n {hasRowCountLabel && (\n <Paragraph component=\"span\" color=\"textSecondary\">\n {totalRowsLabel}\n </Paragraph>\n )}\n </PaginationSegment>\n\n <PaginationSegment odysseyDesignTokens={odysseyDesignTokens}>\n {totalRows && hasPageInput && (\n <Box>\n <Paragraph component=\"span\" color=\"textSecondary\">\n {currentPageLabel}\n </Paragraph>\n <PaginationInput\n odysseyDesignTokens={odysseyDesignTokens}\n type=\"number\"\n value={page}\n onChange={setPageFromEvent}\n onBlur={handlePaginationChange}\n onKeyDown={handlePageSubmit}\n disabled={isDisabled}\n inputProps={currentPageInputProps}\n />\n </Box>\n )}\n <PaginationButtonContainer>\n <Button\n startIcon={<ArrowLeftIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={previousLabel}\n onClick={handlePreviousButton}\n isDisabled={previousButtonDisabled}\n />\n <Button\n endIcon={<ArrowRightIcon />}\n variant=\"floating\"\n size=\"small\"\n ariaLabel={nextLabel}\n onClick={handleNextButton}\n isDisabled={nextButtonDisabled}\n />\n </PaginationButtonContainer>\n </PaginationSegment>\n </PaginationContainer>\n ) : (\n <Button\n variant=\"secondary\"\n label={loadMoreLabel}\n onClick={handleLoadMore}\n isDisabled={loadMoreIsDisabled}\n />\n );\n};\n\nconst MemoizedPagination = memo(Pagination);\nMemoizedPagination.displayName = \"Pagination\";\n\nexport { MemoizedPagination as Pagination };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,MAAM,MAAM,iBAAiB;AAEpC,SAASC,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC/E,SAASC,cAAc,QAAQ,eAAe;AAE9C,SAASC,GAAG,QAAQ,WAAW;AAC/B,SAASC,MAAM,QAAQ,qBAAqB;AAE5C,SAASC,aAAa,EAAEC,cAAc,QAAQ,6BAA6B;AAC3E,SAEEC,sBAAsB,QACjB,kCAAkC;AACzC,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAO,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpB,MAAMC,mBAAmB,GAAGnB,MAAM,CAAC,KAAK,CAAC,CAAC;EACxCoB,OAAO,EAAE,MAAM;EACfC,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGtB,MAAM,CAAC,KAAK,EAAE;EACtCuB,iBAAiB,EAAGC,IAAI,IA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;MAAA,CACC,CACN,EACDnF,KAAA,CAACuB,yBAAyB;QAAA6D,QAAA,GACxBtF,IAAA,CAACP,MAAM;UACLsG,SAAS,EAAE/F,IAAA,CAACN,aAAa,IAAE,CAAE;UAC7B0D,OAAO,EAAC,UAAU;UAClB4C,IAAI,EAAC,OAAO;UACZC,SAAS,EAAElD,aAAc;UACzBmD,OAAO,EAAElB,oBAAqB;UAC9B9C,UAAU,EAAEiD;QAAuB,CACpC,CAAC,EACFnF,IAAA,CAACP,MAAM;UACL0G,OAAO,EAAEnG,IAAA,CAACL,cAAc,IAAE,CAAE;UAC5ByD,OAAO,EAAC,UAAU;UAClB4C,IAAI,EAAC,OAAO;UACZC,SAAS,EAAExD,SAAU;UACrByD,OAAO,EAAEnB,gBAAiB;UAC1B7C,UAAU,EAAEgD;QAAmB,CAChC,CAAC;MAAA,CACuB,CAAC;IAAA,CACX,CAAC;EAAA,CACD,CAAC,GAEtBlF,IAAA,CAACP,MAAM;IACL2D,OAAO,EAAC,WAAW;IACnBgD,KAAK,EAAE/D,aAAc;IACrB6D,OAAO,EAAErB,cAAe;IACxB3C,UAAU,EAAE+C;EAAmB,CAChC,CACF;AACH,CAAC;AAED,MAAMoB,kBAAkB,GAAGpH,IAAI,CAAC0C,UAAU,CAAC;AAC3C0E,kBAAkB,CAACC,WAAW,GAAG,YAAY;AAE7C,SAASD,kBAAkB,IAAI1E,UAAU","ignoreList":[]}
|
package/dist/esm/Tag.js
CHANGED
|
@@ -17,6 +17,7 @@ import { MuiPropsContext } from "./MuiPropsContext.js";
|
|
|
17
17
|
import { useOdysseyDesignTokens } from "./OdysseyDesignTokensContext.js";
|
|
18
18
|
import { TagListContext } from "./TagListContext.js";
|
|
19
19
|
import { useContrastModeContext } from "./useContrastMode.js";
|
|
20
|
+
import { useTranslation } from "react-i18next";
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
export const tagSizeValues = ["medium", "small"];
|
|
22
23
|
export const tagColorVariants = ["accentFour", "accentOne", "accentThree", "accentTwo", "default", "info"];
|
|
@@ -204,6 +205,9 @@ const Tag = ({
|
|
|
204
205
|
testId,
|
|
205
206
|
translate
|
|
206
207
|
}) => {
|
|
208
|
+
const {
|
|
209
|
+
t
|
|
210
|
+
} = useTranslation();
|
|
207
211
|
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
208
212
|
const {
|
|
209
213
|
chipElementType
|
|
@@ -219,7 +223,10 @@ const Tag = ({
|
|
|
219
223
|
colorVariant: colorVariant,
|
|
220
224
|
contrastMode: contrastMode,
|
|
221
225
|
"data-se": testId,
|
|
222
|
-
deleteIcon: _jsx(CloseCircleFilledIcon, {
|
|
226
|
+
deleteIcon: _jsx(CloseCircleFilledIcon, {
|
|
227
|
+
role: "button",
|
|
228
|
+
titleAccess: t("tag.remove")
|
|
229
|
+
}),
|
|
223
230
|
disabled: isDisabled,
|
|
224
231
|
icon: icon,
|
|
225
232
|
label: label,
|
|
@@ -228,7 +235,7 @@ const Tag = ({
|
|
|
228
235
|
onDelete: onRemove,
|
|
229
236
|
size: size,
|
|
230
237
|
translate: translate
|
|
231
|
-
}), [chipElementType, colorVariant, contrastMode, icon, isDisabled, label, odysseyDesignTokens, onClick, onRemove, size, testId, translate]);
|
|
238
|
+
}), [t, chipElementType, colorVariant, contrastMode, icon, isDisabled, label, odysseyDesignTokens, onClick, onRemove, size, testId, translate]);
|
|
232
239
|
return _jsx(MuiPropsContext.Consumer, {
|
|
233
240
|
children: renderTag
|
|
234
241
|
});
|
package/dist/esm/Tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","names":["memo","useCallback","useContext","styled","CloseCircleFilledIcon","MuiPropsContext","useOdysseyDesignTokens","TagListContext","useContrastModeContext","jsx","_jsx","tagSizeValues","tagColorVariants","getChipColors","colorVariant","contrastMode","odysseyDesignTokens","colors","default","background","HueNeutral200","text","HueNeutral700","textDisabled","HueNeutral400","HueNeutral100","HueNeutral300","hover","active","border","deleteIcon","HueNeutral500","deleteIconHover","icon","iconDisabled","info","HueBlue200","HueBlue700","HueBlue400","HueBlue100","HueBlue300","HueBlue500","accentOne","HueAccentOne200","HueAccentOne700","HueAccentOne400","HueAccentOne100","HueAccentOne300","HueAccentOne500","accentTwo","HueAccentTwo200","HueAccentTwo800","HueAccentTwo400","HueAccentTwo100","HueAccentTwo700","HueAccentTwo300","HueAccentTwo500","accentThree","HueAccentThree200","HueAccentThree700","HueAccentThree400","HueAccentThree100","HueAccentThree300","HueAccentThree500","accentFour","HueAccentFour200","HueAccentFour700","HueAccentFour400","HueAccentFour100","HueAccentFour300","HueAccentFour500","StyledTag","_Chip","shouldForwardProp","prop","includes","clickable","size","backgroundColor","color","borderColor","paddingBlock","Spacing1","Tag","isDisabled","label","onClick","onRemove","testId","translate","chipElementType","renderTag","muiProps","as","Boolean","disabled","onDelete","Consumer","children","MemoizedTag","displayName"],"sources":["../../src/Tag.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 { Chip as MuiChip, ChipProps as MuiChipProps } from \"@mui/material\";\nimport { memo, ReactElement, useCallback, useContext } from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport { CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport { MuiPropsContext, MuiPropsContextType } from \"./MuiPropsContext.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TagListContext } from \"./TagListContext.js\";\nimport { ContrastMode, useContrastModeContext } from \"./useContrastMode.js\";\n\nexport const tagSizeValues = [\"medium\", \"small\"] as const;\n\nexport const tagColorVariants = [\n \"accentFour\",\n \"accentOne\",\n \"accentThree\",\n \"accentTwo\",\n \"default\",\n \"info\",\n] as const;\n\ntype TagColorVariant = (typeof tagColorVariants)[number];\ntype TagSize = (typeof tagSizeValues)[number];\n\nexport type TagProps = {\n icon?: ReactElement;\n isDisabled?: boolean;\n /**\n * The label text for the Tag\n */\n label: string;\n /**\n * Callback fired when the Tag is clicked\n */\n onClick?: MuiChipProps[\"onClick\"];\n /**\n * Callback fired when the remove button of the Tag is clicked\n */\n onRemove?: MuiChipProps[\"onDelete\"];\n /**\n * Color variant of the Tag, affecting its appearance\n */\n colorVariant?: TagColorVariant;\n /*\n * Size variant of the Tag\n */\n size?: TagSize;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst getChipColors = ({\n colorVariant,\n contrastMode,\n odysseyDesignTokens,\n}: {\n colorVariant: TagColorVariant;\n contrastMode: ContrastMode;\n odysseyDesignTokens: DesignTokens;\n}) => {\n const colors = {\n default: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueNeutral200,\n text: odysseyDesignTokens.HueNeutral700,\n textDisabled: odysseyDesignTokens.HueNeutral400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueNeutral100,\n text: odysseyDesignTokens.HueNeutral700,\n textDisabled: odysseyDesignTokens.HueNeutral300,\n }),\n hover: odysseyDesignTokens.HueNeutral200,\n active: odysseyDesignTokens.HueNeutral300,\n border: odysseyDesignTokens.HueNeutral200,\n deleteIcon: odysseyDesignTokens.HueNeutral500,\n deleteIconHover: odysseyDesignTokens.HueNeutral700,\n icon: odysseyDesignTokens.HueNeutral700,\n iconDisabled: odysseyDesignTokens.HueNeutral300,\n },\n info: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueBlue200,\n text: odysseyDesignTokens.HueBlue700,\n textDisabled: odysseyDesignTokens.HueBlue400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueBlue100,\n text: odysseyDesignTokens.HueBlue700,\n textDisabled: odysseyDesignTokens.HueBlue300,\n }),\n hover: odysseyDesignTokens.HueBlue200,\n active: odysseyDesignTokens.HueBlue300,\n border: odysseyDesignTokens.HueBlue200,\n deleteIcon: odysseyDesignTokens.HueBlue500,\n deleteIconHover: odysseyDesignTokens.HueBlue700,\n icon: odysseyDesignTokens.HueBlue700,\n iconDisabled: odysseyDesignTokens.HueBlue300,\n },\n accentOne: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentOne200,\n text: odysseyDesignTokens.HueAccentOne700,\n textDisabled: odysseyDesignTokens.HueAccentOne400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentOne100,\n text: odysseyDesignTokens.HueAccentOne700,\n textDisabled: odysseyDesignTokens.HueAccentOne300,\n }),\n hover: odysseyDesignTokens.HueAccentOne200,\n active: odysseyDesignTokens.HueAccentOne300,\n border: odysseyDesignTokens.HueAccentOne200,\n deleteIcon: odysseyDesignTokens.HueAccentOne500,\n deleteIconHover: odysseyDesignTokens.HueAccentOne700,\n icon: odysseyDesignTokens.HueAccentOne700,\n iconDisabled: odysseyDesignTokens.HueAccentOne300,\n },\n accentTwo: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentTwo200,\n text: odysseyDesignTokens.HueAccentTwo800,\n textDisabled: odysseyDesignTokens.HueAccentTwo400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentTwo100,\n text: odysseyDesignTokens.HueAccentTwo700,\n textDisabled: odysseyDesignTokens.HueAccentTwo300,\n }),\n hover: odysseyDesignTokens.HueAccentTwo200,\n active: odysseyDesignTokens.HueAccentTwo300,\n border: odysseyDesignTokens.HueAccentTwo200,\n deleteIcon: odysseyDesignTokens.HueAccentTwo500,\n deleteIconHover: odysseyDesignTokens.HueAccentTwo700,\n icon: odysseyDesignTokens.HueAccentTwo700,\n iconDisabled: odysseyDesignTokens.HueAccentTwo300,\n },\n accentThree: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentThree200,\n text: odysseyDesignTokens.HueAccentThree700,\n textDisabled: odysseyDesignTokens.HueAccentThree400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentThree100,\n text: odysseyDesignTokens.HueAccentThree700,\n textDisabled: odysseyDesignTokens.HueAccentThree300,\n }),\n hover: odysseyDesignTokens.HueAccentThree200,\n active: odysseyDesignTokens.HueAccentThree300,\n border: odysseyDesignTokens.HueAccentThree200,\n deleteIcon: odysseyDesignTokens.HueAccentThree500,\n deleteIconHover: odysseyDesignTokens.HueAccentThree700,\n icon: odysseyDesignTokens.HueAccentThree700,\n iconDisabled: odysseyDesignTokens.HueAccentThree300,\n },\n accentFour: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentFour200,\n text: odysseyDesignTokens.HueAccentFour700,\n textDisabled: odysseyDesignTokens.HueAccentFour400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentFour100,\n text: odysseyDesignTokens.HueAccentFour700,\n textDisabled: odysseyDesignTokens.HueAccentFour300,\n }),\n hover: odysseyDesignTokens.HueAccentFour200,\n active: odysseyDesignTokens.HueAccentFour300,\n border: odysseyDesignTokens.HueAccentFour200,\n deleteIcon: odysseyDesignTokens.HueAccentFour500,\n deleteIconHover: odysseyDesignTokens.HueAccentFour700,\n icon: odysseyDesignTokens.HueAccentFour700,\n iconDisabled: odysseyDesignTokens.HueAccentFour300,\n },\n };\n\n return colors[colorVariant] || colors.default;\n};\n\nconst StyledTag = styled(MuiChip, {\n shouldForwardProp: (prop) =>\n ![\"colorVariant\", \"contrastMode\", \"odysseyDesignTokens\", \"size\"].includes(\n prop,\n ),\n})<{\n as?: React.ElementType; // Allow the 'as' prop to be forwarded\n clickable?: boolean;\n colorVariant: TagColorVariant;\n contrastMode: ContrastMode;\n odysseyDesignTokens: DesignTokens;\n size?: TagSize;\n}>(({ colorVariant, contrastMode, odysseyDesignTokens, clickable, size }) => {\n const colors = getChipColors({\n colorVariant,\n odysseyDesignTokens,\n contrastMode,\n });\n\n return {\n backgroundColor: colors.background,\n color: colors.text,\n\n ...(clickable === true && {\n borderColor: colors.border,\n }),\n\n ...(clickable === false && {\n borderColor: \"transparent\",\n }),\n\n ...(size === \"small\" && {\n paddingBlock: `calc(${odysseyDesignTokens.Spacing1})`,\n }),\n\n \"&.MuiChip-clickable:hover\": {\n backgroundColor: colors.hover,\n },\n\n \"&.MuiChip-clickable:active\": {\n backgroundColor: colors.active,\n },\n\n \"&.Mui-disabled\": {\n color: colors.textDisabled,\n borderColor: colors.border,\n \"& .MuiChip-icon, & .MuiChip-deleteIcon\": {\n color: colors.iconDisabled,\n },\n },\n\n \"& .MuiChip-icon\": {\n color: colors.icon,\n },\n\n \"& .MuiChip-deleteIcon\": {\n color: colors.deleteIcon,\n \"&:hover\": {\n color: colors.deleteIconHover,\n },\n },\n };\n});\n\nconst Tag = ({\n colorVariant = \"default\",\n icon,\n isDisabled,\n label,\n onClick,\n onRemove,\n size = \"medium\",\n testId,\n translate,\n}: TagProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { chipElementType } = useContext(TagListContext);\n const { contrastMode } = useContrastModeContext();\n\n const renderTag = useCallback(\n (muiProps: MuiPropsContextType) => (\n <StyledTag\n {...muiProps}\n aria-disabled={isDisabled}\n as={chipElementType}\n clickable={Boolean(onClick)}\n colorVariant={colorVariant}\n contrastMode={contrastMode}\n data-se={testId}\n deleteIcon={<CloseCircleFilledIcon />}\n disabled={isDisabled}\n icon={icon}\n label={label}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={onClick}\n onDelete={onRemove}\n size={size}\n translate={translate}\n />\n ),\n [\n chipElementType,\n colorVariant,\n contrastMode,\n icon,\n isDisabled,\n label,\n odysseyDesignTokens,\n onClick,\n onRemove,\n size,\n testId,\n translate,\n ],\n );\n\n return <MuiPropsContext.Consumer>{renderTag}</MuiPropsContext.Consumer>;\n};\n\nconst MemoizedTag = memo(Tag);\nMemoizedTag.displayName = \"Tag\";\n\nexport { MemoizedTag as Tag };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,EAAgBC,WAAW,EAAEC,UAAU,QAAQ,OAAO;AACnE,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAASC,qBAAqB,QAAQ,4BAA4B;AAElE,SAASC,eAAe,QAA6B,sBAAsB;AAC3E,SAEEC,sBAAsB,QACjB,iCAAiC;AACxC,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAAuBC,sBAAsB,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5E,OAAO,MAAMC,aAAa,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;AAEzD,OAAO,MAAMC,gBAAgB,GAAG,CAC9B,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,MAAM,CACE;AA8BV,MAAMC,aAAa,GAAGA,CAAC;EACrBC,YAAY;EACZC,YAAY;EACZC;AAKF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAG;IACbC,OAAO,EAAE;MACP,IAAIH,YAAY,KAAK,cAAc,IAAI;QACrCI,UAAU,EAAEH,mBAAmB,CAACI,aAAa;QAC7CC,IAAI,EAAEL,mBAAmB,CAACM,aAAa;QACvCC,YAAY,EAAEP,mBAAmB,CAACQ;MACpC,CAAC,CAAC;MACF,IAAIT,YAAY,KAAK,aAAa,IAAI;QACpCI,UAAU,EAAEH,mBAAmB,CAACS,aAAa;QAC7CJ,IAAI,EAAEL,mBAAmB,CAACM,aAAa;QACvCC,YAAY,EAAEP,mBAAmB,CAACU;MACpC,CAAC,CAAC;MACFC,KAAK,EAA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AAU,EACVC,KAAK,EACLrE,mBAAmB,EACnBsE,OAAO,EACPC,QAAQ,EACRV,IAAI,EACJW,MAAM,EACNC,SAAS,CAEb,CAAC;EAED,OAAO/E,IAAA,CAACL,eAAe,CAAC4F,QAAQ;IAAAC,QAAA,EAAEP;EAAS,CAA2B,CAAC;AACzE,CAAC;AAED,MAAMQ,WAAW,GAAGnG,IAAI,CAACmF,GAAG,CAAC;AAC7BgB,WAAW,CAACC,WAAW,GAAG,KAAK;AAE/B,SAASD,WAAW,IAAIhB,GAAG","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Tag.js","names":["memo","useCallback","useContext","styled","CloseCircleFilledIcon","MuiPropsContext","useOdysseyDesignTokens","TagListContext","useContrastModeContext","useTranslation","jsx","_jsx","tagSizeValues","tagColorVariants","getChipColors","colorVariant","contrastMode","odysseyDesignTokens","colors","default","background","HueNeutral200","text","HueNeutral700","textDisabled","HueNeutral400","HueNeutral100","HueNeutral300","hover","active","border","deleteIcon","HueNeutral500","deleteIconHover","icon","iconDisabled","info","HueBlue200","HueBlue700","HueBlue400","HueBlue100","HueBlue300","HueBlue500","accentOne","HueAccentOne200","HueAccentOne700","HueAccentOne400","HueAccentOne100","HueAccentOne300","HueAccentOne500","accentTwo","HueAccentTwo200","HueAccentTwo800","HueAccentTwo400","HueAccentTwo100","HueAccentTwo700","HueAccentTwo300","HueAccentTwo500","accentThree","HueAccentThree200","HueAccentThree700","HueAccentThree400","HueAccentThree100","HueAccentThree300","HueAccentThree500","accentFour","HueAccentFour200","HueAccentFour700","HueAccentFour400","HueAccentFour100","HueAccentFour300","HueAccentFour500","StyledTag","_Chip","shouldForwardProp","prop","includes","clickable","size","backgroundColor","color","borderColor","paddingBlock","Spacing1","Tag","isDisabled","label","onClick","onRemove","testId","translate","t","chipElementType","renderTag","muiProps","as","Boolean","role","titleAccess","disabled","onDelete","Consumer","children","MemoizedTag","displayName"],"sources":["../../src/Tag.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 { Chip as MuiChip, ChipProps as MuiChipProps } from \"@mui/material\";\nimport { memo, ReactElement, useCallback, useContext } from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport { CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport { HtmlProps } from \"./HtmlProps.js\";\nimport { MuiPropsContext, MuiPropsContextType } from \"./MuiPropsContext.js\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TagListContext } from \"./TagListContext.js\";\nimport { ContrastMode, useContrastModeContext } from \"./useContrastMode.js\";\nimport { useTranslation } from \"react-i18next\";\n\nexport const tagSizeValues = [\"medium\", \"small\"] as const;\n\nexport const tagColorVariants = [\n \"accentFour\",\n \"accentOne\",\n \"accentThree\",\n \"accentTwo\",\n \"default\",\n \"info\",\n] as const;\n\ntype TagColorVariant = (typeof tagColorVariants)[number];\ntype TagSize = (typeof tagSizeValues)[number];\n\nexport type TagProps = {\n icon?: ReactElement;\n isDisabled?: boolean;\n /**\n * The label text for the Tag\n */\n label: string;\n /**\n * Callback fired when the Tag is clicked\n */\n onClick?: MuiChipProps[\"onClick\"];\n /**\n * Callback fired when the remove button of the Tag is clicked\n */\n onRemove?: MuiChipProps[\"onDelete\"];\n /**\n * Color variant of the Tag, affecting its appearance\n */\n colorVariant?: TagColorVariant;\n /*\n * Size variant of the Tag\n */\n size?: TagSize;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst getChipColors = ({\n colorVariant,\n contrastMode,\n odysseyDesignTokens,\n}: {\n colorVariant: TagColorVariant;\n contrastMode: ContrastMode;\n odysseyDesignTokens: DesignTokens;\n}) => {\n const colors = {\n default: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueNeutral200,\n text: odysseyDesignTokens.HueNeutral700,\n textDisabled: odysseyDesignTokens.HueNeutral400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueNeutral100,\n text: odysseyDesignTokens.HueNeutral700,\n textDisabled: odysseyDesignTokens.HueNeutral300,\n }),\n hover: odysseyDesignTokens.HueNeutral200,\n active: odysseyDesignTokens.HueNeutral300,\n border: odysseyDesignTokens.HueNeutral200,\n deleteIcon: odysseyDesignTokens.HueNeutral500,\n deleteIconHover: odysseyDesignTokens.HueNeutral700,\n icon: odysseyDesignTokens.HueNeutral700,\n iconDisabled: odysseyDesignTokens.HueNeutral300,\n },\n info: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueBlue200,\n text: odysseyDesignTokens.HueBlue700,\n textDisabled: odysseyDesignTokens.HueBlue400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueBlue100,\n text: odysseyDesignTokens.HueBlue700,\n textDisabled: odysseyDesignTokens.HueBlue300,\n }),\n hover: odysseyDesignTokens.HueBlue200,\n active: odysseyDesignTokens.HueBlue300,\n border: odysseyDesignTokens.HueBlue200,\n deleteIcon: odysseyDesignTokens.HueBlue500,\n deleteIconHover: odysseyDesignTokens.HueBlue700,\n icon: odysseyDesignTokens.HueBlue700,\n iconDisabled: odysseyDesignTokens.HueBlue300,\n },\n accentOne: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentOne200,\n text: odysseyDesignTokens.HueAccentOne700,\n textDisabled: odysseyDesignTokens.HueAccentOne400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentOne100,\n text: odysseyDesignTokens.HueAccentOne700,\n textDisabled: odysseyDesignTokens.HueAccentOne300,\n }),\n hover: odysseyDesignTokens.HueAccentOne200,\n active: odysseyDesignTokens.HueAccentOne300,\n border: odysseyDesignTokens.HueAccentOne200,\n deleteIcon: odysseyDesignTokens.HueAccentOne500,\n deleteIconHover: odysseyDesignTokens.HueAccentOne700,\n icon: odysseyDesignTokens.HueAccentOne700,\n iconDisabled: odysseyDesignTokens.HueAccentOne300,\n },\n accentTwo: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentTwo200,\n text: odysseyDesignTokens.HueAccentTwo800,\n textDisabled: odysseyDesignTokens.HueAccentTwo400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentTwo100,\n text: odysseyDesignTokens.HueAccentTwo700,\n textDisabled: odysseyDesignTokens.HueAccentTwo300,\n }),\n hover: odysseyDesignTokens.HueAccentTwo200,\n active: odysseyDesignTokens.HueAccentTwo300,\n border: odysseyDesignTokens.HueAccentTwo200,\n deleteIcon: odysseyDesignTokens.HueAccentTwo500,\n deleteIconHover: odysseyDesignTokens.HueAccentTwo700,\n icon: odysseyDesignTokens.HueAccentTwo700,\n iconDisabled: odysseyDesignTokens.HueAccentTwo300,\n },\n accentThree: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentThree200,\n text: odysseyDesignTokens.HueAccentThree700,\n textDisabled: odysseyDesignTokens.HueAccentThree400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentThree100,\n text: odysseyDesignTokens.HueAccentThree700,\n textDisabled: odysseyDesignTokens.HueAccentThree300,\n }),\n hover: odysseyDesignTokens.HueAccentThree200,\n active: odysseyDesignTokens.HueAccentThree300,\n border: odysseyDesignTokens.HueAccentThree200,\n deleteIcon: odysseyDesignTokens.HueAccentThree500,\n deleteIconHover: odysseyDesignTokens.HueAccentThree700,\n icon: odysseyDesignTokens.HueAccentThree700,\n iconDisabled: odysseyDesignTokens.HueAccentThree300,\n },\n accentFour: {\n ...(contrastMode === \"highContrast\" && {\n background: odysseyDesignTokens.HueAccentFour200,\n text: odysseyDesignTokens.HueAccentFour700,\n textDisabled: odysseyDesignTokens.HueAccentFour400,\n }),\n ...(contrastMode === \"lowContrast\" && {\n background: odysseyDesignTokens.HueAccentFour100,\n text: odysseyDesignTokens.HueAccentFour700,\n textDisabled: odysseyDesignTokens.HueAccentFour300,\n }),\n hover: odysseyDesignTokens.HueAccentFour200,\n active: odysseyDesignTokens.HueAccentFour300,\n border: odysseyDesignTokens.HueAccentFour200,\n deleteIcon: odysseyDesignTokens.HueAccentFour500,\n deleteIconHover: odysseyDesignTokens.HueAccentFour700,\n icon: odysseyDesignTokens.HueAccentFour700,\n iconDisabled: odysseyDesignTokens.HueAccentFour300,\n },\n };\n\n return colors[colorVariant] || colors.default;\n};\n\nconst StyledTag = styled(MuiChip, {\n shouldForwardProp: (prop) =>\n ![\"colorVariant\", \"contrastMode\", \"odysseyDesignTokens\", \"size\"].includes(\n prop,\n ),\n})<{\n as?: React.ElementType; // Allow the 'as' prop to be forwarded\n clickable?: boolean;\n colorVariant: TagColorVariant;\n contrastMode: ContrastMode;\n odysseyDesignTokens: DesignTokens;\n size?: TagSize;\n}>(({ colorVariant, contrastMode, odysseyDesignTokens, clickable, size }) => {\n const colors = getChipColors({\n colorVariant,\n odysseyDesignTokens,\n contrastMode,\n });\n\n return {\n backgroundColor: colors.background,\n color: colors.text,\n\n ...(clickable === true && {\n borderColor: colors.border,\n }),\n\n ...(clickable === false && {\n borderColor: \"transparent\",\n }),\n\n ...(size === \"small\" && {\n paddingBlock: `calc(${odysseyDesignTokens.Spacing1})`,\n }),\n\n \"&.MuiChip-clickable:hover\": {\n backgroundColor: colors.hover,\n },\n\n \"&.MuiChip-clickable:active\": {\n backgroundColor: colors.active,\n },\n\n \"&.Mui-disabled\": {\n color: colors.textDisabled,\n borderColor: colors.border,\n \"& .MuiChip-icon, & .MuiChip-deleteIcon\": {\n color: colors.iconDisabled,\n },\n },\n\n \"& .MuiChip-icon\": {\n color: colors.icon,\n },\n\n \"& .MuiChip-deleteIcon\": {\n color: colors.deleteIcon,\n \"&:hover\": {\n color: colors.deleteIconHover,\n },\n },\n };\n});\n\nconst Tag = ({\n colorVariant = \"default\",\n icon,\n isDisabled,\n label,\n onClick,\n onRemove,\n size = \"medium\",\n testId,\n translate,\n}: TagProps) => {\n const { t } = useTranslation();\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { chipElementType } = useContext(TagListContext);\n const { contrastMode } = useContrastModeContext();\n\n const renderTag = useCallback(\n (muiProps: MuiPropsContextType) => (\n <StyledTag\n {...muiProps}\n aria-disabled={isDisabled}\n as={chipElementType}\n clickable={Boolean(onClick)}\n colorVariant={colorVariant}\n contrastMode={contrastMode}\n data-se={testId}\n deleteIcon={\n <CloseCircleFilledIcon role=\"button\" titleAccess={t(\"tag.remove\")} />\n }\n disabled={isDisabled}\n icon={icon}\n label={label}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={onClick}\n onDelete={onRemove}\n size={size}\n translate={translate}\n />\n ),\n [\n t,\n chipElementType,\n colorVariant,\n contrastMode,\n icon,\n isDisabled,\n label,\n odysseyDesignTokens,\n onClick,\n onRemove,\n size,\n testId,\n translate,\n ],\n );\n\n return <MuiPropsContext.Consumer>{renderTag}</MuiPropsContext.Consumer>;\n};\n\nconst MemoizedTag = memo(Tag);\nMemoizedTag.displayName = \"Tag\";\n\nexport { MemoizedTag as Tag };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,EAAgBC,WAAW,EAAEC,UAAU,QAAQ,OAAO;AACnE,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAASC,qBAAqB,QAAQ,4BAA4B;AAElE,SAASC,eAAe,QAA6B,sBAAsB;AAC3E,SAEEC,sBAAsB,QACjB,iCAAiC;AACxC,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAAuBC,sBAAsB,QAAQ,sBAAs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|
1
|
-
{"version":3,"file":"inputUtils.js","names":["useMemo","ComponentControlledState","CONTROLLED","UNCONTROLLED","getControlState","controlledValue","uncontrolledValue","undefined","useInputValues","defaultValue","value","controlState","inputValues"],"sources":["../../src/inputUtils.ts"],"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 { useMemo } from \"react\";\n\nexport type FocusHandle = {\n focus: () => void;\n};\n\ntype UseControlledStateProps<Value> = {\n controlledValue?: Value;\n uncontrolledValue?: Value;\n};\n\nexport const ComponentControlledState = {\n CONTROLLED: \"CONTROLLED\",\n UNCONTROLLED: \"UNCONTROLLED\",\n};\n\nexport type ModeType = keyof typeof ComponentControlledState;\nexport type ModeTypeValue = (typeof ComponentControlledState)[ModeType];\n\nexport const getControlState = <Value>({\n controlledValue,\n uncontrolledValue,\n}: UseControlledStateProps<Value>): ModeTypeValue => {\n if (uncontrolledValue !== undefined || controlledValue === undefined) {\n return ComponentControlledState.UNCONTROLLED;\n }\n return ComponentControlledState.CONTROLLED;\n};\n\ntype InputValueProps<Value> = {\n defaultValue?: Value;\n value?: Value;\n controlState: ModeTypeValue;\n};\n\ntype InputValue<Value> =\n | {\n defaultValue: Value | undefined;\n value?: undefined;\n }\n | {\n value: Value | undefined;\n defaultValue?: undefined;\n };\n\n/**\n * In components that support being used in a controlled or uncontrolled way, the defaultValue and value props need\n * to be
|
|
1
|
+
{"version":3,"file":"inputUtils.js","names":["useMemo","ComponentControlledState","CONTROLLED","UNCONTROLLED","getControlState","controlledValue","uncontrolledValue","undefined","useInputValues","defaultValue","value","controlState","inputValues"],"sources":["../../src/inputUtils.ts"],"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 { useMemo } from \"react\";\n\nexport type FocusHandle = {\n focus: () => void;\n};\n\ntype UseControlledStateProps<Value> = {\n controlledValue?: Value;\n uncontrolledValue?: Value;\n};\n\nexport const ComponentControlledState = {\n CONTROLLED: \"CONTROLLED\",\n UNCONTROLLED: \"UNCONTROLLED\",\n};\n\nexport type ModeType = keyof typeof ComponentControlledState;\nexport type ModeTypeValue = (typeof ComponentControlledState)[ModeType];\n\nexport const getControlState = <Value>({\n controlledValue,\n uncontrolledValue,\n}: UseControlledStateProps<Value>): ModeTypeValue => {\n if (uncontrolledValue !== undefined || controlledValue === undefined) {\n return ComponentControlledState.UNCONTROLLED;\n }\n return ComponentControlledState.CONTROLLED;\n};\n\ntype InputValueProps<Value> = {\n defaultValue?: Value;\n value?: Value;\n controlState: ModeTypeValue;\n};\n\ntype InputValue<Value> =\n | {\n defaultValue: Value | undefined;\n value?: undefined;\n }\n | {\n value: Value | undefined;\n defaultValue?: undefined;\n };\n\n/**\n * In components that support being used in a controlled or uncontrolled way, the defaultValue and value props need\n * to be supplied values in a mutually exclusive way.\n * If a `value` is being provided to the component, then it is being used in a controlled manner and `defaultValue` needs to be undefined.\n * If `value` is undefined, then that means the component is being used in an uncontrolled way and `defaultValue` is either Value or undefined.\n * This helper helps ensure this mutual exclusivity between the 2 props so the component can operate as expected.\n *\n * @param {InputValueProps<Value>}: { defaultValue: Value | undefined, value: Value | undefined }\n * @returns {InputValue<Value>}: { defaultValue: Value | undefined, value?: undefined } | { defaultValue?: undefined, value: Value }\n */\nexport const useInputValues = <Value>({\n defaultValue,\n value,\n controlState,\n}: InputValueProps<Value>): InputValue<Value> => {\n const inputValues = useMemo(() => {\n if (controlState === ComponentControlledState.CONTROLLED) {\n return { value };\n }\n return { defaultValue };\n }, [controlState, defaultValue, value]);\n return inputValues;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,OAAO;AAW/B,OAAO,MAAMC,wBAAwB,GAAG;EACtCC,UAAU,EAAE,YAAY;EACxBC,YAAY,EAAE;AAChB,CAAC;AAKD,OAAO,MAAMC,eAAe,GAAGA,CAAQ;EACrCC,eAAe;EACfC;AAC8B,CAAC,KAAoB;EACnD,IAAIA,iBAAiB,KAAKC,SAAS,IAAIF,eAAe,KAAKE,SAAS,EAAE;IACpE,OAAON,wBAAwB,CAACE,YAAY;EAC9C;EACA,OAAOF,wBAAwB,CAACC,UAAU;AAC5C,CAAC;AA4BD,OAAO,MAAMM,cAAc,GAAGA,CAAQ;EACpCC,YAAY;EACZC,KAAK;EACLC;AACsB,CAAC,KAAwB;EAC/C,MAAMC,WAAW,GAAGZ,OAAO,CAAC,MAAM;IAChC,IAAIW,YAAY,KAAKV,wBAAwB,CAACC,UAAU,EAAE;MACxD,OAAO;QAAEQ;MAAM,CAAC;IAClB;IACA,OAAO;MAAED;IAAa,CAAC;EACzB,CAAC,EAAE,CAACE,YAAY,EAAEF,YAAY,EAAEC,KAAK,CAAC,CAAC;EACvC,OAAOE,WAAW;AACpB,CAAC","ignoreList":[]}
|