@okta/odyssey-react-mui 1.40.0 → 1.42.0
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/Select.cjs +1 -1
- package/dist/cjs/Select.cjs.map +1 -1
- package/dist/cjs/Tag.cjs +9 -2
- package/dist/cjs/Tag.cjs.map +1 -1
- package/dist/cjs/createContrastColors.cjs +6 -2
- package/dist/cjs/createContrastColors.cjs.map +1 -1
- package/dist/cjs/getLogicalBoundaries.cjs +33 -0
- package/dist/cjs/getLogicalBoundaries.cjs.map +1 -0
- package/dist/cjs/labs/PageTemplate/PageTemplate.cjs +15 -4
- package/dist/cjs/labs/PageTemplate/PageTemplate.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/properties/ts/odyssey-react-mui_eu.cjs +137 -0
- package/dist/cjs/properties/ts/odyssey-react-mui_eu.cjs.map +1 -0
- package/dist/cjs/theme/components.cjs +1 -0
- package/dist/cjs/theme/components.cjs.map +1 -1
- package/dist/cjs/ui-shell/NarrowUiShellContent.cjs +0 -1
- package/dist/cjs/ui-shell/NarrowUiShellContent.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs +23 -18
- package/dist/cjs/ui-shell/SideNav/SideNav.cjs.map +1 -1
- package/dist/cjs/ui-shell/SideNav/SideNavItemLinkContent.cjs +4 -3
- package/dist/cjs/ui-shell/SideNav/SideNavItemLinkContent.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/UiShell.cjs +2 -0
- package/dist/cjs/ui-shell/UiShell.cjs.map +1 -1
- package/dist/cjs/ui-shell/UiShellProvider.cjs +6 -1
- package/dist/cjs/ui-shell/UiShellProvider.cjs.map +1 -1
- package/dist/cjs/ui-shell/renderUiShell.cjs +4 -2
- package/dist/cjs/ui-shell/renderUiShell.cjs.map +1 -1
- package/dist/cjs/ui-shell/useElementAtContainerEdge.cjs +74 -0
- package/dist/cjs/ui-shell/useElementAtContainerEdge.cjs.map +1 -0
- 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/useMountLifecycleEffect.cjs +3 -3
- package/dist/cjs/useMountLifecycleEffect.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/Select.js +1 -1
- package/dist/esm/Select.js.map +1 -1
- package/dist/esm/Tag.js +9 -2
- package/dist/esm/Tag.js.map +1 -1
- package/dist/esm/createContrastColors.js +6 -2
- package/dist/esm/createContrastColors.js.map +1 -1
- package/dist/esm/getLogicalBoundaries.js +26 -0
- package/dist/esm/getLogicalBoundaries.js.map +1 -0
- package/dist/esm/labs/PageTemplate/PageTemplate.js +16 -5
- package/dist/esm/labs/PageTemplate/PageTemplate.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/properties/ts/odyssey-react-mui_eu.js +131 -0
- package/dist/esm/properties/ts/odyssey-react-mui_eu.js.map +1 -0
- package/dist/esm/theme/components.js +1 -0
- package/dist/esm/theme/components.js.map +1 -1
- package/dist/esm/ui-shell/NarrowUiShellContent.js +0 -1
- package/dist/esm/ui-shell/NarrowUiShellContent.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNav.js +23 -18
- package/dist/esm/ui-shell/SideNav/SideNav.js.map +1 -1
- package/dist/esm/ui-shell/SideNav/SideNavItemLinkContent.js +4 -3
- package/dist/esm/ui-shell/SideNav/SideNavItemLinkContent.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/UiShell.js +2 -0
- package/dist/esm/ui-shell/UiShell.js.map +1 -1
- package/dist/esm/ui-shell/UiShellProvider.js +6 -1
- package/dist/esm/ui-shell/UiShellProvider.js.map +1 -1
- package/dist/esm/ui-shell/renderUiShell.js +4 -2
- package/dist/esm/ui-shell/renderUiShell.js.map +1 -1
- package/dist/esm/ui-shell/useElementAtContainerEdge.js +68 -0
- package/dist/esm/ui-shell/useElementAtContainerEdge.js.map +1 -0
- 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/useMountLifecycleEffect.js +3 -3
- package/dist/esm/useMountLifecycleEffect.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.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.mjs +1 -1
- package/dist/index.scss +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- 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/Select.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 +5 -1
- package/dist/types/createContrastColors.d.ts.map +1 -1
- package/dist/types/getLogicalBoundaries.d.ts +24 -0
- package/dist/types/getLogicalBoundaries.d.ts.map +1 -0
- 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/PageTemplate/PageTemplate.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/properties/ts/odyssey-react-mui_eu.d.ts +131 -0
- package/dist/types/properties/ts/odyssey-react-mui_eu.d.ts.map +1 -0
- 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/NarrowUiShellContent.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNav.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemContent.d.ts.map +1 -1
- package/dist/types/ui-shell/SideNav/SideNavItemLinkContent.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/UiShell.d.ts +1 -1
- package/dist/types/ui-shell/UiShell.d.ts.map +1 -1
- package/dist/types/ui-shell/UiShellProvider.d.ts +10 -4
- package/dist/types/ui-shell/UiShellProvider.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 +2 -2
- package/dist/types/ui-shell/renderUiShell.d.ts.map +1 -1
- package/dist/types/ui-shell/useElementAtContainerEdge.d.ts +43 -0
- package/dist/types/ui-shell/useElementAtContainerEdge.d.ts.map +1 -0
- 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
|
@@ -58,8 +58,11 @@ const Autocomplete = ({
|
|
|
58
58
|
defaultValue,
|
|
59
59
|
errorMessage,
|
|
60
60
|
errorMessageList,
|
|
61
|
+
getIsOptionEqualToValue,
|
|
61
62
|
getOptionLabel,
|
|
62
63
|
hasMultipleChoices,
|
|
64
|
+
hint,
|
|
65
|
+
HintLinkComponent,
|
|
63
66
|
id: idOverride,
|
|
64
67
|
inputValue,
|
|
65
68
|
isCustomValueAllowed,
|
|
@@ -69,20 +72,17 @@ const Autocomplete = ({
|
|
|
69
72
|
isOptional = false,
|
|
70
73
|
isReadOnly,
|
|
71
74
|
isVirtualized = false,
|
|
72
|
-
hint,
|
|
73
|
-
HintLinkComponent,
|
|
74
75
|
label,
|
|
75
76
|
name: nameOverride,
|
|
76
77
|
noOptionsText,
|
|
77
78
|
onBlur,
|
|
78
79
|
onChange,
|
|
79
|
-
onInputChange,
|
|
80
80
|
onFocus,
|
|
81
|
+
onInputChange,
|
|
81
82
|
options,
|
|
82
|
-
value,
|
|
83
|
-
getIsOptionEqualToValue,
|
|
84
83
|
testId,
|
|
85
|
-
translate
|
|
84
|
+
translate,
|
|
85
|
+
value
|
|
86
86
|
}) => {
|
|
87
87
|
const {
|
|
88
88
|
t
|
|
@@ -120,23 +120,23 @@ const Autocomplete = ({
|
|
|
120
120
|
closeText: t("close.text"),
|
|
121
121
|
disableCloseOnSelect: hasMultipleChoices,
|
|
122
122
|
disabled: isDisabled,
|
|
123
|
-
freeSolo: isCustomValueAllowed,
|
|
124
123
|
filterSelectedOptions: true,
|
|
124
|
+
freeSolo: isCustomValueAllowed,
|
|
125
|
+
fullWidth: isFullWidth,
|
|
125
126
|
getOptionLabel: getOptionLabel,
|
|
126
127
|
id: idOverride,
|
|
127
|
-
|
|
128
|
+
isOptionEqualToValue: getIsOptionEqualToValue,
|
|
128
129
|
loading: isLoading,
|
|
129
130
|
multiple: hasMultipleChoices,
|
|
130
131
|
noOptionsText: noOptionsText || t("autocomplete.nooptions"),
|
|
131
132
|
onBlur: onBlur,
|
|
132
133
|
onChange: onChange,
|
|
133
|
-
onInputChange: onInputChange,
|
|
134
134
|
onFocus: onFocus,
|
|
135
|
+
onInputChange: onInputChange,
|
|
135
136
|
openText: t("open.text"),
|
|
136
137
|
options: options,
|
|
137
138
|
readOnly: isReadOnly,
|
|
138
139
|
renderInput: renderInput,
|
|
139
|
-
isOptionEqualToValue: getIsOptionEqualToValue,
|
|
140
140
|
translate: translate
|
|
141
141
|
});
|
|
142
142
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.cjs","names":["_react","require","_reactI18next","_PickerVirtualizationListBox","_useAutocomplete","_jsxRuntime","_interopRequireDefault","e","__esModule","default","AutocompleteTestSelector","exports","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","useTranslation","inputValueProp","isVirtualizedRef","renderInput","valueProps","useAutocomplete","jsx","_Autocomplete2","current","ListboxComponent","PickerVirtualizationListBox","clearText","closeText","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","fullWidth","loading","multiple","openText","readOnly","isOptionEqualToValue","MemoizedAutocomplete","memo","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":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AASA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAAuD,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAvBvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtCE,cAAc,EAAE;IAC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omplete.cjs","names":["_react","require","_reactI18next","_PickerVirtualizationListBox","_useAutocomplete","_jsxRuntime","_interopRequireDefault","e","__esModule","default","AutocompleteTestSelector","exports","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","useTranslation","inputValueProp","isVirtualizedRef","renderInput","valueProps","useAutocomplete","jsx","_Autocomplete2","current","ListboxComponent","PickerVirtualizationListBox","clearText","closeText","disableCloseOnSelect","disabled","filterSelectedOptions","freeSolo","fullWidth","isOptionEqualToValue","loading","multiple","openText","readOnly","MemoizedAutocomplete","memo","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":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AASA,IAAAE,4BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAAuD,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAK,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAvBvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMG,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACtCE,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,CAAiC;AAyKjC,MAAME,YAAY,GAAG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,EAAE,IAAK;IAC5BC,QAAQ,EAAElC,oBAAqB;IAC/BmC,SAAS,EAAEjC,WAAY;IACvBR,cAAc,EAAEA,cAAe;IAC/BG,EAAE,EAAEC,UAAW;IACfsC,oBAAoB,EAAE3C,uBAAwB;IAC9C4C,OAAO,EAAElC,SAAU;IACnBmC,QAAQ,EAAE3C,kBAAmB;IAC7Bc,aAAa,EAAEA,aAAa,IAAIQ,CAAC,CAAC,wBAAwB,CAAE;IAC5DP,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBC,OAAO,EAAEA,OAAQ;IACjBC,aAAa,EAAEA,aAAc;IAC7B0B,QAAQ,EAAEtB,CAAC,CAAC,WAAW,CAAE;IACzB/B,OAAO,EAAEA,OAAQ;IACjBsD,QAAQ,EAAEnC,UAAW;IACrBgB,WAAW,EAAEA,WAAY;IACzBN,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAGD,MAAM0B,oBAAoB,GAAAjE,OAAA,CAAAa,YAAA,GAAG,IAAAqD,WAAI,EAACrD,YAAY,CAAwB;AAEtEoD,oBAAoB,CAACE,WAAW,GAAG,cAAc","ignoreList":[]}
|
package/dist/cjs/Breadcrumbs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Breadcrumbs.cjs","names":["_react","require","_index","_Typography","_reactI18next","_styled","_interopRequireDefault","_jsxRuntime","e","__esModule","default","BreadcrumbContext","exports","createContext","breadcrumbType","BreadcrumbContent","styled","span","Breadcrumb","children","href","iconName","onClick","useContext","onClickHandler","useCallback","event","preventDefault","stopPropagation","breadcrumbContent","jsxs","Fragment","jsx","GroupIcon","UserIcon","Subordinate","color","_MenuItem2","ariaCurrent","_ButtonBase2","breadcrumbProviderValue","currentPage","listItem","menuItem","defaultTruncationValue","BreadcrumbList","homeHref","maxVisibleItems","maxVisibleItemsProp","testId","translate","t","useTranslation","anchorEl","setAnchorEl","useState","useMemo","Math","min","max","length","breadcrumbSections","beforeMenu","insideMenu","remainingBreadcrumbs","menuStart","floor","menuLength","slice","onMenuButtonClick","currentTarget","onCloseMenu","_Breadcrumbs2","maxItems","HomeIcon","map","breadcrumb","index","Provider","value","_Menu2","open","Boolean","onClose","anchorOrigin","horizontal","vertical","MenuListProps","sx","minWidth","MemoizedBreadcrumbList","memo","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":";;;;;;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAqC,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAK,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAhCrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2CO,MAAMG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAAE,oBAAa,EAAwB;EACpEC,cAAc,EAAE;AAClB,CAAC,CAAC;AAEF,MAAMC,iBAAiB,GAAGC,eAAM,CAACC,IAAI;AACrC;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,UAAU,GAAGA,CAAC;EACzBC,QAAQ;EACRC,IAAI;EACJC,QAAQ;EACRC;AACe,CAAC,KAAK;EACrB,MAAM;IAAER;EAAe,CAAC,GAAG,IAAAS,iBAAU,EAACZ,iBAAiB,CAAC;EAExD,MAAMa,cAAc,GAAG,IAAAC,kBAAW,EAC/BC,KAAK,IAAK;IACT,IAAIJ,OAAO,EAAE;MACXI,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBD,KAAK,CAACE,eAAe,CAAC,CAAC;MACvBN,OAAO,CA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;AAErB,CAAC;AAED,MAAMa,sBAAsB,GAAA9E,OAAA,CAAAiC,cAAA,GAAG,IAAA8C,WAAI,EAAC9C,cAAc,CAAC;AACnD6C,sBAAsB,CAACE,WAAW,GAAG,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Breadcrumbs.cjs","names":["_react","require","_index","_Typography","_reactI18next","_styled","_interopRequireDefault","_jsxRuntime","e","__esModule","default","BreadcrumbContext","exports","createContext","breadcrumbType","BreadcrumbContent","styled","span","Breadcrumb","children","href","iconName","onClick","useContext","onClickHandler","useCallback","event","preventDefault","stopPropagation","breadcrumbContent","jsxs","Fragment","jsx","GroupIcon","UserIcon","Subordinate","color","_MenuItem2","component","ariaCurrent","_ButtonBase2","breadcrumbProviderValue","currentPage","listItem","menuItem","defaultTruncationValue","BreadcrumbList","homeHref","maxVisibleItems","maxVisibleItemsProp","testId","translate","t","useTranslation","anchorEl","setAnchorEl","useState","useMemo","Math","min","max","length","breadcrumbSections","beforeMenu","insideMenu","remainingBreadcrumbs","menuStart","floor","menuLength","slice","onMenuButtonClick","currentTarget","onCloseMenu","_Breadcrumbs2","maxItems","HomeIcon","map","breadcrumb","index","Provider","value","_Menu2","open","Boolean","onClose","anchorOrigin","horizontal","vertical","MenuListProps","sx","minWidth","MemoizedBreadcrumbList","memo","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":";;;;;;;;;;AAkBA,IAAAA,MAAA,GAAAC,OAAA;AAUA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAqC,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAK,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,K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zBC,KAAK,EAAEvC,uBAAuB,CAACG,QAAS;UAAAzB,QAAA,EAEvC2C,kBAAkB,CAACE;QAAU,CACJ;MAAC,CACzB,CAAC;IAAA,CACP,CACH,EAEAF,kBAAkB,CAACG,oBAAoB,CAACW,GAAG,CAAC,CAACC,UAAU,EAAEC,KAAK,KAAK;MAClE,IAAIA,KAAK,KAAKhB,kBAAkB,CAACG,oBAAoB,CAACJ,MAAM,GAAG,CAAC,EAAE;QAChE,OACE,IAAAtD,WAAA,CAAAyB,GAAA,EAACrB,iBAAiB,CAACoE,QAAQ;UAEzBC,KAAK,EAAEvC,uBAAuB,CAACC,WAAY;UAAAvB,QAAA,EAE1C0D;QAAU,GAHNC,KAIqB,CAAC;MAEjC;MACA,OACE,IAAAvE,WAAA,CAAAyB,GAAA,EAACrB,iBAAiB,CAACoE,QAAQ;QAEzBC,KAAK,EAAEvC,uBAAuB,CAACE,QAAS;QAAAxB,QAAA,EAEvC0D;MAAU,GAHNC,KAIqB,CAAC;IAEjC,CAAC,CAAC;EAAA,CACY,CAAC;AAErB,CAAC;AAED,MAAMa,sBAAsB,GAAA/E,OAAA,CAAAkC,cAAA,GAAG,IAAA8C,WAAI,EAAC9C,cAAc,CAAC;AACnD6C,sBAAsB,CAACE,WAAW,GAAG,gBAAgB","ignoreList":[]}
|
package/dist/cjs/Link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.cjs","names":["_react","require","_index","_jsxRuntime","_interopRequireDefault","e","__esModule","default","linkVariantValues","exports","Link","ariaLabel","children","href","icon","linkRef","rel","target","testId","translate","variant","onClick","localLinkRef","useRef","useImperativeHandle","focus","current","jsxs","_Link2","ref","jsx","className","role","ExternalLinkIcon","MemoizedLink","memo","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.cjs","names":["_react","require","_index","_jsxRuntime","_interopRequireDefault","e","__esModule","default","linkVariantValues","exports","Link","ariaLabel","children","href","icon","linkRef","rel","target","testId","translate","variant","onClick","localLinkRef","useRef","useImperativeHandle","focus","current","jsxs","_Link2","ref","jsx","className","role","ExternalLinkIcon","MemoizedLink","memo","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":";;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AApB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMG,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,CAAC,SAAS,EAAE,YAAY,CAAU;AA4CnE,MAAME,IAAI,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1
|
-
{"version":3,"file":"OdysseyCacheProvider.cjs","names":["_cache","_interopRequireDefault","require","_react","_useUniqueAlphabeticalId","_react2","_jsxRuntime","e","__esModule","default","OdysseyCacheProvider","children","emotionRoot","emotionRootElement","hasShadowDom","hasShadowDomProp","nonce","shadowDomElement","stylisPlugins","uniqueAlphabeticalId","useUniqueAlphabeticalId","emotionCache","useMemo","createCache","container","key","globalThis","cspNonce","prepend","speedy","jsx","CacheProvider","value","MemoizedOdysseyCacheProvider","exports","memo","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.cjs","names":["_cache","_interopRequireDefault","require","_react","_useUniqueAlphabeticalId","_react2","_jsxRuntime","e","__esModule","default","OdysseyCacheProvider","children","emotionRoot","emotionRootElement","hasShadowDom","hasShadowDomProp","nonce","shadowDomElement","stylisPlugins","uniqueAlphabeticalId","useUniqueAlphabeticalId","emotionCache","useMemo","createCache","container","key","globalThis","cspNonce","prepend","speedy","jsx","CacheProvider","value","MemoizedOdysseyCacheProvider","exports","memo","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":";;;;;;AAgBA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAA+C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAnB/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA,MAAMG,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,GAAG,IAAAC,gDAAuB,EAAC,CAAC;EAEtD,MAAMN,YAAY,GAAGC,gBAAgB,IAAIE,gBAAgB;EAEzD,MAAMI,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM;IACjC,OAAO,IAAAC,cAAW,EAAC;MACjB,IAAI,CAACV,kBAAkB,IAAID,WAAW,KAAK;QACzCY,SAAS,EAAEX,kBAAkB,IAAID;MACnC,CAAC,CAAC;MACFa,GAAG,EAAEN,oBAAoB;MACzBH,KAAK,EAAEA,KAAK,IAAIU,UAAU,CAACC,QAAQ;MACnCC,OAAO,EAAE,IAAI;MACbC,MAAM,EAAEf,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,OAAO,IAAAb,WAAA,CAAAwB,GAAA,EAACzB,OAAA,CAAA0B,aAAa;IAACC,KAAK,EAAEX,YAAa;IAAAV,QAAA,EAAEA;EAAQ,CAAgB,CAAC;AACvE,CAAC;AAED,MAAMsB,4BAA4B,GAAAC,OAAA,CAAAxB,oBAAA,GAAG,IAAAyB,WAAI,EAACzB,oBAAoB,CAAC;AAC/DuB,4BAA4B,CAACG,WAAW,GAAG,sBAAsB","ignoreList":[]}
|
package/dist/cjs/Select.cjs
CHANGED
|
@@ -231,7 +231,7 @@ const Select = ({
|
|
|
231
231
|
isReadOnly
|
|
232
232
|
}) => {
|
|
233
233
|
const stopPropagation = event => event.stopPropagation();
|
|
234
|
-
const hasNonInteractiveIcon = !isInteractive && controlledStateRef.current === CONTROLLED && hasMultipleChoices;
|
|
234
|
+
const hasNonInteractiveIcon = !isInteractive && !isReadOnly && controlledStateRef.current === CONTROLLED && hasMultipleChoices;
|
|
235
235
|
return Array.isArray(internalSelectedValues) && (0, _jsxRuntime.jsx)(ChipsInnerContainer, {
|
|
236
236
|
isInteractive: isInteractive,
|
|
237
237
|
isReadOnly: isReadOnly,
|
package/dist/cjs/Select.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.cjs","names":["_react","require","_styled","_interopRequireDefault","_Field","_index","_inputUtils","_OdysseyDesignTokensContext","_useNormalizedKey","_jsxRuntime","e","__esModule","default","SelectTestSelector","exports","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","SelectContainer","styled","div","ChipsPositioningContainer","shouldForwardProp","prop","odysseyDesignTokens","Spacing0","Spacing5","Spacing1","BorderWidthMain","NonInteractiveIcon","CloseCircleFilledIcon","Spacing2","ChipsInnerContainer","_Box2","isInteractive","isReadOnly","Spacing6","CONTROLLED","ComponentControlledState","Select","ariaDescribedBy","defaultValue","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","selectRef","useRef","useMemo","undefined","controlledStateRef","getControlState","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","useState","current","localInputRef","useOdysseyDesignTokens","useImperativeHandle","focus","useEffect","inputValues","useInputValues","controlState","useCallback","event","child","preventDefault","target","split","normalizedOptions","normalizedOptionsMap","map","option","text","type","lang","language","Map","removeSelectedValue","selectedValue","Array","isArray","newValue","filter","internalSelectedValue","syntheticEvent","Chips","stopPropagation","hasNonInteractiveIcon","jsx","item","length","_Chip2","jsxs","Fragment","get","tabIndex","onDelete","deleteIcon","sx","pointerEvents","onMouseDown","renderedOptions","index","_ListSubheader2","isSelected","includes","_MenuItem2","selected","_Checkbox2","checked","_ListItemSecondaryAction2","CheckIcon","normalizedKey","toString","renderValue","renderFieldComponent","errorMessageElementId","labelElementId","_Select2","displayEmpty","inputProps","readOnly","el","labelId","MenuProps","maxHeight","multiple","Field","fieldType","hasVisibleLabel","MemoizedSelect","memo","displayName"],"sources":["../../src/Select.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 useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useImperativeHandle,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport {\n Box as MuiBox,\n Checkbox as MuiCheckbox,\n Chip as MuiChip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem as MuiMenuItem,\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n SelectChangeEvent,\n} from \"@mui/material\";\n\nimport { Field } from \"./Field.js\";\nimport {\n FieldComponentProps,\n FieldComponentRenderProps,\n} from \"./FieldComponentProps.js\";\nimport { CheckIcon, CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport {\n ComponentControlledState,\n FocusHandle,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\nimport { normalizedKey } from \"./useNormalizedKey.js\";\n\nexport const SelectTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n accessibleText: {\n label: \"label\",\n },\n children: {\n listItem: {\n accessibleText: {\n label: \"label\",\n },\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\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n language?: string;\n};\n\nconst SelectContainer = styled.div`\n position: relative;\n width: 100%;\n display: flex;\n`;\n\nconst ChipsPositioningContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n align-items: center;\n position: absolute;\n top: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n right: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n bottom: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n left: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.BorderWidthMain};\n opacity: 1;\n pointer-events: none;\n`;\n\nconst NonInteractiveIcon = styled(CloseCircleFilledIcon, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n font-size: 1em;\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.Spacing2};\n margin-inline-end: -${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-block-end: -1px;\n`;\n\nconst ChipsInnerContainer = styled(MuiBox, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"isInteractive\" &&\n prop !== \"isReadOnly\",\n})<{\n isInteractive?: boolean;\n isReadOnly?: boolean;\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n flex-wrap: wrap;\n gap: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n pointer-events: none;\n opacity: ${({ isInteractive, isReadOnly }) =>\n isInteractive || isReadOnly ? 1 : 0};\n min-height: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing6};\n`;\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * The ref forwarded to the Select\n */\n inputRef?: React.RefObject<FocusHandle>;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\ntype SelectRenderProps = Partial<\n Pick<FieldComponentRenderProps, \"ariaDescribedBy\" | \"errorMessageElementId\">\n> &\n Pick<FieldComponentRenderProps, \"id\" | \"labelElementId\">;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n isReadOnly = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n translate,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const selectRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect],\n );\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue,\n );\n\n const localInputRef = useRef<HTMLSelectElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n useImperativeHandle(inputRef, () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n }, []);\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n if (isReadOnly) {\n event.preventDefault();\n } else {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" && hasMultipleChoices\n ? value.split(\",\")\n : value) as Value,\n );\n }\n onChangeProp?.(event, child);\n }\n },\n [hasMultipleChoices, onChangeProp, isReadOnly],\n );\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const [normalizedOptions, normalizedOptionsMap] = useMemo(() => {\n const normalizedOptions = options.map((option) => {\n if (typeof option === \"object\") {\n /**\n * If the value of `option?.value is an empty string, we need to make sure that we\n * set an empty string to `value` in the normalized option so that the select component\n * can potentially set it as the selected one in the text input\n */\n const value =\n option?.value === \"\" ? option.value : option.value || option.text;\n return {\n text: option.text,\n value,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n lang: option.language,\n };\n }\n\n return { text: option, value: option, type: \"option\" };\n });\n\n const normalizedOptionsMap = new Map(\n normalizedOptions.map((option) => [option.value, option]),\n );\n return [normalizedOptions, normalizedOptionsMap];\n }, [options]);\n\n const removeSelectedValue = useCallback(\n (selectedValue: string) => {\n if (Array.isArray(internalSelectedValues)) {\n const newValue = internalSelectedValues.filter(\n (internalSelectedValue) => internalSelectedValue !== selectedValue,\n );\n\n const syntheticEvent = {\n target: { value: newValue },\n } as SelectChangeEvent<Value>;\n\n onChange(syntheticEvent, null);\n }\n },\n [internalSelectedValues, onChange],\n );\n\n const Chips = useCallback(\n ({\n isInteractive,\n isReadOnly,\n }: {\n isInteractive: boolean;\n isReadOnly?: boolean;\n }) => {\n const stopPropagation = (event: React.MouseEvent<SVGSVGElement>) =>\n event.stopPropagation();\n\n const hasNonInteractiveIcon =\n !isInteractive &&\n controlledStateRef.current === CONTROLLED &&\n hasMultipleChoices;\n return (\n Array.isArray(internalSelectedValues) && (\n <ChipsInnerContainer\n isInteractive={isInteractive}\n isReadOnly={isReadOnly}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {internalSelectedValues.map(\n (item) =>\n item?.length > 0 && (\n <MuiChip\n key={item}\n label={\n <>\n {normalizedOptionsMap.get(item)?.text}\n {hasNonInteractiveIcon && (\n <NonInteractiveIcon\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </>\n }\n tabIndex={-1}\n onDelete={\n isInteractive && controlledStateRef.current === CONTROLLED\n ? () => removeSelectedValue(item)\n : undefined\n }\n deleteIcon={\n <CloseCircleFilledIcon\n sx={{ pointerEvents: \"auto\" }}\n // We need to stop event propagation on mouse down to prevent the deletion\n // from being blocked by the Select list opening, and also ensure that\n // the pointerEvent is registered even when the parent's are not\n onMouseDown={stopPropagation}\n />\n }\n />\n ),\n )}\n </ChipsInnerContainer>\n )\n );\n },\n [\n controlledStateRef,\n hasMultipleChoices,\n internalSelectedValues,\n odysseyDesignTokens,\n removeSelectedValue,\n normalizedOptionsMap,\n ],\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const renderedOptions = useMemo(\n () =>\n normalizedOptions.map((option, index) => {\n if (option.type === \"heading\") {\n return (\n <ListSubheader key={option.text}> {option.text} </ListSubheader>\n );\n }\n\n const isSelected = hasMultipleChoices\n ? internalSelectedValues?.includes(option.value)\n : internalSelectedValues === option.value;\n\n return (\n <MuiMenuItem\n data-empty={!option.text}\n key={normalizedKey(option.text, index.toString())}\n value={option.value}\n selected={isSelected}\n lang={option.lang}\n >\n {hasMultipleChoices && <MuiCheckbox checked={isSelected} />}\n {option.text}\n {!hasMultipleChoices && internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MuiMenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues],\n );\n\n const renderValue = useCallback(\n (value: Value) => Array.isArray(value) && <Chips isInteractive={false} />,\n [Chips],\n );\n\n const renderFieldComponent = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: SelectRenderProps) => (\n <SelectContainer>\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n displayEmpty\n id={id}\n inputProps={{\n \"data-se\": testId,\n \"aria-disabled\": isDisabled || isReadOnly,\n readOnly: isReadOnly,\n }}\n inputRef={(el: HTMLInputElement | HTMLTextAreaElement | null) => {\n if (localInputRef.current !== el) {\n (localInputRef as React.MutableRefObject<typeof el>).current = el;\n }\n selectRef.current = el;\n }}\n labelId={labelElementId}\n MenuProps={{\n sx: {\n \".MuiPaper-root\": {\n maxHeight: \"50vh\",\n },\n },\n }}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n translate={translate}\n >\n {renderedOptions}\n </MuiSelect>\n {hasMultipleChoices && (\n <>\n <ChipsPositioningContainer\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Chips isInteractive={!isReadOnly} isReadOnly={isReadOnly} />\n </ChipsPositioningContainer>\n </>\n )}\n </SelectContainer>\n ),\n [\n Chips,\n inputValues,\n hasMultipleChoices,\n isDisabled,\n isReadOnly,\n nameOverride,\n odysseyDesignTokens,\n onBlur,\n onChange,\n onFocus,\n renderedOptions,\n renderValue,\n testId,\n translate,\n ],\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAaA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,WAAA,GAAAL,OAAA;AAMA,IAAAM,2BAAA,GAAAN,OAAA;AAKA,IAAAO,iBAAA,GAAAP,OAAA;AAAsD,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AApDtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4CO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,cAAc,EAAE;IACdC,YAAY,EAAE,cAAc;IAC5BC,IAAI,EAAE,aAAa;IACnBC,KAAK,EAAE;EACT,CAAC;EACDC,Q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EAAEA,YAAa;IAC3BmC,gBAAgB,EAAEA,gBAAiB;IACnC0G,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACf7I,IAAI,EAAEA,IAAK;IACXqC,iBAAiB,EAAEA,iBAAkB;IACrCC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvB3C,KAAK,EAAEA,KAAM;IACb8H,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMe,cAAc,GAAAjJ,OAAA,CAAAkC,MAAA,GAAG,IAAAgH,WAAI,EAAChH,MAAM,CAAC;AACnC+G,cAAc,CAACE,WAAW,GAAG,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Select.cjs","names":["_react","require","_styled","_interopRequireDefault","_Field","_index","_inputUtils","_OdysseyDesignTokensContext","_useNormalizedKey","_jsxRuntime","e","__esModule","default","SelectTestSelector","exports","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","SelectContainer","styled","div","ChipsPositioningContainer","shouldForwardProp","prop","odysseyDesignTokens","Spacing0","Spacing5","Spacing1","BorderWidthMain","NonInteractiveIcon","CloseCircleFilledIcon","Spacing2","ChipsInnerContainer","_Box2","isInteractive","isReadOnly","Spacing6","CONTROLLED","ComponentControlledState","Select","ariaDescribedBy","defaultValue","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","selectRef","useRef","useMemo","undefined","controlledStateRef","getControlState","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","useState","current","localInputRef","useOdysseyDesignTokens","useImperativeHandle","focus","useEffect","inputValues","useInputValues","controlState","useCallback","event","child","preventDefault","target","split","normalizedOptions","normalizedOptionsMap","map","option","text","type","lang","language","Map","removeSelectedValue","selectedValue","Array","isArray","newValue","filter","internalSelectedValue","syntheticEvent","Chips","stopPropagation","hasNonInteractiveIcon","jsx","item","length","_Chip2","jsxs","Fragment","get","tabIndex","onDelete","deleteIcon","sx","pointerEvents","onMouseDown","renderedOptions","index","_ListSubheader2","isSelected","includes","_MenuItem2","selected","_Checkbox2","checked","_ListItemSecondaryAction2","CheckIcon","normalizedKey","toString","renderValue","renderFieldComponent","errorMessageElementId","labelElementId","_Select2","displayEmpty","inputProps","readOnly","el","labelId","MenuProps","maxHeight","multiple","Field","fieldType","hasVisibleLabel","MemoizedSelect","memo","displayName"],"sources":["../../src/Select.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 useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useImperativeHandle,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport {\n Box as MuiBox,\n Checkbox as MuiCheckbox,\n Chip as MuiChip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem as MuiMenuItem,\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n SelectChangeEvent,\n} from \"@mui/material\";\n\nimport { Field } from \"./Field.js\";\nimport {\n FieldComponentProps,\n FieldComponentRenderProps,\n} from \"./FieldComponentProps.js\";\nimport { CheckIcon, CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport {\n ComponentControlledState,\n FocusHandle,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\nimport { normalizedKey } from \"./useNormalizedKey.js\";\n\nexport const SelectTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n accessibleText: {\n label: \"label\",\n },\n children: {\n listItem: {\n accessibleText: {\n label: \"label\",\n },\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\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n language?: string;\n};\n\nconst SelectContainer = styled.div`\n position: relative;\n width: 100%;\n display: flex;\n`;\n\nconst ChipsPositioningContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n align-items: center;\n position: absolute;\n top: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n right: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n bottom: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n left: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.BorderWidthMain};\n opacity: 1;\n pointer-events: none;\n`;\n\nconst NonInteractiveIcon = styled(CloseCircleFilledIcon, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n font-size: 1em;\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.Spacing2};\n margin-inline-end: -${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-block-end: -1px;\n`;\n\nconst ChipsInnerContainer = styled(MuiBox, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"isInteractive\" &&\n prop !== \"isReadOnly\",\n})<{\n isInteractive?: boolean;\n isReadOnly?: boolean;\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n flex-wrap: wrap;\n gap: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n pointer-events: none;\n opacity: ${({ isInteractive, isReadOnly }) =>\n isInteractive || isReadOnly ? 1 : 0};\n min-height: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing6};\n`;\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * The ref forwarded to the Select\n */\n inputRef?: React.RefObject<FocusHandle>;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\ntype SelectRenderProps = Partial<\n Pick<FieldComponentRenderProps, \"ariaDescribedBy\" | \"errorMessageElementId\">\n> &\n Pick<FieldComponentRenderProps, \"id\" | \"labelElementId\">;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n isReadOnly = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n translate,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const selectRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect],\n );\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue,\n );\n\n const localInputRef = useRef<HTMLSelectElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n useImperativeHandle(inputRef, () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n }, []);\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n if (isReadOnly) {\n event.preventDefault();\n } else {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" && hasMultipleChoices\n ? value.split(\",\")\n : value) as Value,\n );\n }\n onChangeProp?.(event, child);\n }\n },\n [hasMultipleChoices, onChangeProp, isReadOnly],\n );\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const [normalizedOptions, normalizedOptionsMap] = useMemo(() => {\n const normalizedOptions = options.map((option) => {\n if (typeof option === \"object\") {\n /**\n * If the value of `option?.value is an empty string, we need to make sure that we\n * set an empty string to `value` in the normalized option so that the select component\n * can potentially set it as the selected one in the text input\n */\n const value =\n option?.value === \"\" ? option.value : option.value || option.text;\n return {\n text: option.text,\n value,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n lang: option.language,\n };\n }\n\n return { text: option, value: option, type: \"option\" };\n });\n\n const normalizedOptionsMap = new Map(\n normalizedOptions.map((option) => [option.value, option]),\n );\n return [normalizedOptions, normalizedOptionsMap];\n }, [options]);\n\n const removeSelectedValue = useCallback(\n (selectedValue: string) => {\n if (Array.isArray(internalSelectedValues)) {\n const newValue = internalSelectedValues.filter(\n (internalSelectedValue) => internalSelectedValue !== selectedValue,\n );\n\n const syntheticEvent = {\n target: { value: newValue },\n } as SelectChangeEvent<Value>;\n\n onChange(syntheticEvent, null);\n }\n },\n [internalSelectedValues, onChange],\n );\n\n const Chips = useCallback(\n ({\n isInteractive,\n isReadOnly,\n }: {\n isInteractive: boolean;\n isReadOnly?: boolean;\n }) => {\n const stopPropagation = (event: React.MouseEvent<SVGSVGElement>) =>\n event.stopPropagation();\n\n const hasNonInteractiveIcon =\n !isInteractive &&\n !isReadOnly &&\n controlledStateRef.current === CONTROLLED &&\n hasMultipleChoices;\n\n return (\n Array.isArray(internalSelectedValues) && (\n <ChipsInnerContainer\n isInteractive={isInteractive}\n isReadOnly={isReadOnly}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {internalSelectedValues.map(\n (item) =>\n item?.length > 0 && (\n <MuiChip\n key={item}\n label={\n <>\n {normalizedOptionsMap.get(item)?.text}\n {hasNonInteractiveIcon && (\n <NonInteractiveIcon\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </>\n }\n tabIndex={-1}\n onDelete={\n isInteractive && controlledStateRef.current === CONTROLLED\n ? () => removeSelectedValue(item)\n : undefined\n }\n deleteIcon={\n <CloseCircleFilledIcon\n sx={{ pointerEvents: \"auto\" }}\n // We need to stop event propagation on mouse down to prevent the deletion\n // from being blocked by the Select list opening, and also ensure that\n // the pointerEvent is registered even when the parent's are not\n onMouseDown={stopPropagation}\n />\n }\n />\n ),\n )}\n </ChipsInnerContainer>\n )\n );\n },\n [\n controlledStateRef,\n hasMultipleChoices,\n internalSelectedValues,\n odysseyDesignTokens,\n removeSelectedValue,\n normalizedOptionsMap,\n ],\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const renderedOptions = useMemo(\n () =>\n normalizedOptions.map((option, index) => {\n if (option.type === \"heading\") {\n return (\n <ListSubheader key={option.text}> {option.text} </ListSubheader>\n );\n }\n\n const isSelected = hasMultipleChoices\n ? internalSelectedValues?.includes(option.value)\n : internalSelectedValues === option.value;\n\n return (\n <MuiMenuItem\n data-empty={!option.text}\n key={normalizedKey(option.text, index.toString())}\n value={option.value}\n selected={isSelected}\n lang={option.lang}\n >\n {hasMultipleChoices && <MuiCheckbox checked={isSelected} />}\n {option.text}\n {!hasMultipleChoices && internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MuiMenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues],\n );\n\n const renderValue = useCallback(\n (value: Value) => Array.isArray(value) && <Chips isInteractive={false} />,\n [Chips],\n );\n\n const renderFieldComponent = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: SelectRenderProps) => (\n <SelectContainer>\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n displayEmpty\n id={id}\n inputProps={{\n \"data-se\": testId,\n \"aria-disabled\": isDisabled || isReadOnly,\n readOnly: isReadOnly,\n }}\n inputRef={(el: HTMLInputElement | HTMLTextAreaElement | null) => {\n if (localInputRef.current !== el) {\n (localInputRef as React.MutableRefObject<typeof el>).current = el;\n }\n selectRef.current = el;\n }}\n labelId={labelElementId}\n MenuProps={{\n sx: {\n \".MuiPaper-root\": {\n maxHeight: \"50vh\",\n },\n },\n }}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n translate={translate}\n >\n {renderedOptions}\n </MuiSelect>\n {hasMultipleChoices && (\n <>\n <ChipsPositioningContainer\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Chips isInteractive={!isReadOnly} isReadOnly={isReadOnly} />\n </ChipsPositioningContainer>\n </>\n )}\n </SelectContainer>\n ),\n [\n Chips,\n inputValues,\n hasMultipleChoices,\n isDisabled,\n isReadOnly,\n nameOverride,\n odysseyDesignTokens,\n onBlur,\n onChange,\n onFocus,\n renderedOptions,\n renderValue,\n testId,\n translate,\n ],\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AASA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAaA,IAAAG,MAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,WAAA,GAAAL,OAAA;AAMA,IAAAM,2BAAA,GAAAN,OAAA;AAKA,IAAAO,iBAAA,GAAAP,OAAA;AAAsD,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AApDtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4CO,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,cAAc,EAAE;IACdC,YAAY,EAAE,cAAc;IAC5BC,IAAI,EAAE,aAAa;IACnBC,KAAK,EAAE;EACT,CAAC;EACDC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJL,cAAc,EAAE;QACdG,KAAK,EAAE;MACT,CAAC;MACDC,QAAQ,EAAE;QACRE,QAAQ,EAAE;UACRN,cAAc,EAAE;YACdG,KAAK,EAAE;UACT,CAAC;UACDI,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,CAAiC;AASjC,MAAME,eAAe,GAAGC,eAAM,CAACC,GAAG;AAClC;AACA;AACA;AACA,CAAC;AA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,6 +12,7 @@ var _MuiPropsContext = require("./MuiPropsContext.cjs");
|
|
|
12
12
|
var _OdysseyDesignTokensContext = require("./OdysseyDesignTokensContext.cjs");
|
|
13
13
|
var _TagListContext = require("./TagListContext.cjs");
|
|
14
14
|
var _useContrastMode = require("./useContrastMode.cjs");
|
|
15
|
+
var _reactI18next = require("react-i18next");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
/*!
|
|
@@ -212,6 +213,9 @@ const Tag = ({
|
|
|
212
213
|
testId,
|
|
213
214
|
translate
|
|
214
215
|
}) => {
|
|
216
|
+
const {
|
|
217
|
+
t
|
|
218
|
+
} = (0, _reactI18next.useTranslation)();
|
|
215
219
|
const odysseyDesignTokens = (0, _OdysseyDesignTokensContext.useOdysseyDesignTokens)();
|
|
216
220
|
const {
|
|
217
221
|
chipElementType
|
|
@@ -227,7 +231,10 @@ const Tag = ({
|
|
|
227
231
|
colorVariant: colorVariant,
|
|
228
232
|
contrastMode: contrastMode,
|
|
229
233
|
"data-se": testId,
|
|
230
|
-
deleteIcon: (0, _jsxRuntime.jsx)(_index.CloseCircleFilledIcon, {
|
|
234
|
+
deleteIcon: (0, _jsxRuntime.jsx)(_index.CloseCircleFilledIcon, {
|
|
235
|
+
role: "button",
|
|
236
|
+
titleAccess: t("tag.remove")
|
|
237
|
+
}),
|
|
231
238
|
disabled: isDisabled,
|
|
232
239
|
icon: icon,
|
|
233
240
|
label: label,
|
|
@@ -236,7 +243,7 @@ const Tag = ({
|
|
|
236
243
|
onDelete: onRemove,
|
|
237
244
|
size: size,
|
|
238
245
|
translate: translate
|
|
239
|
-
}), [chipElementType, colorVariant, contrastMode, icon, isDisabled, label, odysseyDesignTokens, onClick, onRemove, size, testId, translate]);
|
|
246
|
+
}), [t, chipElementType, colorVariant, contrastMode, icon, isDisabled, label, odysseyDesignTokens, onClick, onRemove, size, testId, translate]);
|
|
240
247
|
return (0, _jsxRuntime.jsx)(_MuiPropsContext.MuiPropsContext.Consumer, {
|
|
241
248
|
children: renderTag
|
|
242
249
|
});
|
package/dist/cjs/Tag.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.cjs","names":["_react","require","_styled","_interopRequireDefault","_index","_MuiPropsContext","_OdysseyDesignTokensContext","_TagListContext","_useContrastMode","_jsxRuntime","e","__esModule","default","tagSizeValues","exports","tagColorVariants","getChipColors","colorVariant","contrastMode","odysseyDesignTokens","colors","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","styled","_Chip2","shouldForwardProp","prop","includes","clickable","size","backgroundColor","color","borderColor","paddingBlock","Spacing1","Tag","isDisabled","label","onClick","onRemove","testId","translate","useOdysseyDesignTokens","chipElementType","useContext","TagListContext","useContrastModeContext","renderTag","useCallback","muiProps","jsx","as","Boolean","CloseCircleFilledIcon","disabled","onDelete","MuiPropsContext","Consumer","children","MemoizedTag","memo","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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,2BAAA,GAAAL,OAAA;AAIA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAA4E,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAxB5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBO,MAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,CAAC,QAAQ,EAAE,OAAO,C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CAAC,GAAG,IAAA+E,uCAAsB,EAAC,CAAC;EAEjD,MAAMC,SAAS,GAAG,IAAAC,kBAAW,EAC1BC,QAA6B,IAC5B,IAAA3F,WAAA,CAAA4F,GAAA,EAAC5B,SAAS;IAAA,GACJ2B,QAAQ;IACZ,iBAAeb,UAAW;IAC1Be,EAAE,EAAER,eAAgB;IACpBf,SAAS,EAAEwB,OAAO,CAACd,OAAO,CAAE;IAC5BxE,YAAY,EAAEA,YAAa;IAC3BC,YAAY,EAAEA,YAAa;IAC3B,WAASyE,MAAO;IAChB3D,UAAU,EAAE,IAAAvB,WAAA,CAAA4F,GAAA,EAACjG,MAAA,CAAAoG,qBAAqB,IAAE,CAAE;IACtCC,QAAQ,EAAElB,UAAW;IACrBpD,IAAI,EAAEA,IAAK;IACXqD,KAAK,EAAEA,KAAM;IACbrE,mBAAmB,EAAEA,mBAAoB;IACzCsE,OAAO,EAAEA,OAAQ;IACjBiB,QAAQ,EAAEhB,QAAS;IACnBV,IAAI,EAAEA,IAAK;IACXY,SAAS,EAAEA;EAAU,CACtB,CACF,EACD,CACEE,eAAe,EACf7E,YAAY,EACZC,YAAY,EACZiB,IAAI,EACJoD,UAAU,EACVC,KAAK,EACLrE,mBAAmB,EACnBsE,OAAO,EACPC,QAAQ,EACRV,IAAI,EACJW,MAAM,EACNC,SAAS,CAEb,CAAC;EAED,OAAO,IAAAnF,WAAA,CAAA4F,GAAA,EAAChG,gBAAA,CAAAsG,eAAe,CAACC,QAAQ;IAAAC,QAAA,EAAEX;EAAS,CAA2B,CAAC;AACzE,CAAC;AAED,MAAMY,WAAW,GAAAhG,OAAA,CAAAwE,GAAA,GAAG,IAAAyB,WAAI,EAACzB,GAAG,CAAC;AAC7BwB,WAAW,CAACE,WAAW,GAAG,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Tag.cjs","names":["_react","require","_styled","_interopRequireDefault","_index","_MuiPropsContext","_OdysseyDesignTokensContext","_TagListContext","_useContrastMode","_reactI18next","_jsxRuntime","e","__esModule","default","tagSizeValues","exports","tagColorVariants","getChipColors","colorVariant","contrastMode","odysseyDesignTokens","colors","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","styled","_Chip2","shouldForwardProp","prop","includes","clickable","size","backgroundColor","color","borderColor","paddingBlock","Spacing1","Tag","isDisabled","label","onClick","onRemove","testId","translate","t","useTranslation","useOdysseyDesignTokens","chipElementType","useContext","TagListContext","useContrastModeContext","renderTag","useCallback","muiProps","jsx","as","Boolean","CloseCircleFilledIcon","role","titleAccess","disabled","onDelete","MuiPropsContext","Consumer","children","MemoizedTag","memo","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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,2BAAA,GAAAL,OAAA;AAIA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAA+C,IAAAS,WAAA,GAAAT,OAAA;AAAA,SAAAE,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAzB/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBO,MAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU;AAElD,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAC9B,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,MAAM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
|
const BLACK_FONT_COLOR = "#000000";
|
|
22
22
|
const WHITE_FONT_COLOR = "#FFFFFF";
|
|
23
|
-
const generateContrastColors = (
|
|
23
|
+
const generateContrastColors = ({
|
|
24
|
+
backgroundColor,
|
|
25
|
+
backgroundContrastColor,
|
|
26
|
+
odysseyDesignTokens
|
|
27
|
+
}) => {
|
|
24
28
|
const rgbFromHex = (0, _hexToRgb.isValidHexString)(backgroundColor) ? (0, _hexToRgb.hexToRgb)(backgroundColor) : (0, _hexToRgb.hexToRgb)(odysseyDesignTokens.HueNeutralWhite);
|
|
25
29
|
const {
|
|
26
30
|
red,
|
|
@@ -30,7 +34,7 @@ const generateContrastColors = (backgroundColor, odysseyDesignTokens) => {
|
|
|
30
34
|
const luminance = 0.2126 * red + 0.7152 * green + 0.0722 * blue;
|
|
31
35
|
const luminanceValueInEdgeRange = luminance > LUMINANCE_EDGE_MIN && luminance < LUMINANCE_EDGE_MAX;
|
|
32
36
|
const isLight = luminance > LUMINANCE_THRESHOLD;
|
|
33
|
-
const fontColor = luminanceValueInEdgeRange ? BLACK_FONT_COLOR : isLight ? odysseyDesignTokens.TypographyColorBody : WHITE_FONT_COLOR;
|
|
37
|
+
const fontColor = backgroundContrastColor || (luminanceValueInEdgeRange ? BLACK_FONT_COLOR : isLight ? odysseyDesignTokens.TypographyColorBody : WHITE_FONT_COLOR);
|
|
34
38
|
const calculatedFontColorInRgb = (0, _hexToRgb.hexToRgb)(fontColor);
|
|
35
39
|
const lightFontColorInRgb = (0, _hexToRgb.hexToRgb)(WHITE_FONT_COLOR);
|
|
36
40
|
const darkFontColorInRgb = (0, _hexToRgb.hexToRgb)(luminanceValueInEdgeRange ? BLACK_FONT_COLOR : odysseyDesignTokens.TypographyColorBody);
|