@okta/odyssey-react-mui 1.22.0 → 1.23.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/CHANGELOG.md +19 -0
- package/dist/@types/i18next.d.js.map +1 -1
- package/dist/Autocomplete.js +30 -0
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Callout.js +12 -24
- package/dist/Callout.js.map +1 -1
- package/dist/DataTable/useScrollIndication.js +7 -3
- package/dist/DataTable/useScrollIndication.js.map +1 -1
- package/dist/FileUploader/FileUploadIllustration.js.map +1 -0
- package/dist/FileUploader/FileUploadPreview.js.map +1 -0
- package/dist/{labs/FileUpload.js → FileUploader/FileUploader.js} +6 -5
- package/dist/FileUploader/FileUploader.js.map +1 -0
- package/dist/FileUploader/index.js +13 -0
- package/dist/FileUploader/index.js.map +1 -0
- package/dist/OdysseyProvider.js +4 -0
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/Radio.js +2 -2
- package/dist/Radio.js.map +1 -1
- package/dist/Select.js +36 -0
- package/dist/Select.js.map +1 -1
- package/dist/{labs/Switch.js → Switch.js} +7 -7
- package/dist/Switch.js.map +1 -0
- package/dist/Tabs.js +7 -9
- package/dist/Tabs.js.map +1 -1
- package/dist/Tag.js +102 -4
- package/dist/Tag.js.map +1 -1
- package/dist/TextField.js +16 -39
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.js +2 -2
- package/dist/Toast.js.map +1 -1
- package/dist/createShadowDomElements.js +1 -0
- package/dist/createShadowDomElements.js.map +1 -1
- package/dist/i18n.js +1 -1
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.scss +92 -4
- package/dist/labs/DataView/DataView.js +64 -25
- package/dist/labs/DataView/DataView.js.map +1 -1
- package/dist/labs/DataView/TableLayoutContent.js +17 -3
- package/dist/labs/DataView/TableLayoutContent.js.map +1 -1
- package/dist/labs/DataView/componentTypes.js.map +1 -1
- package/dist/labs/DateField.js +2 -0
- package/dist/labs/DateField.js.map +1 -1
- package/dist/labs/DatePicker.js +5 -1
- package/dist/labs/DatePicker.js.map +1 -1
- package/dist/labs/SideNav/OktaLogo.js +36 -0
- package/dist/labs/SideNav/OktaLogo.js.map +1 -0
- package/dist/labs/SideNav/SideNav.js +125 -36
- package/dist/labs/SideNav/SideNav.js.map +1 -1
- package/dist/labs/SideNav/SideNavHeader.js +33 -10
- package/dist/labs/SideNav/SideNavHeader.js.map +1 -1
- package/dist/labs/SideNav/types.js.map +1 -1
- package/dist/labs/TopNav.js +2 -1
- package/dist/labs/TopNav.js.map +1 -1
- package/dist/labs/index.js +0 -2
- package/dist/labs/index.js.map +1 -1
- package/dist/labs/useDateFieldsTranslations.js +1 -1
- package/dist/labs/useDateFieldsTranslations.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +3 -1
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +30 -0
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Callout.d.ts +11 -23
- package/dist/src/Callout.d.ts.map +1 -1
- package/dist/src/DataTable/useScrollIndication.d.ts.map +1 -1
- package/dist/src/FileUploader/FileUploadIllustration.d.ts.map +1 -0
- package/dist/src/{labs → FileUploader}/FileUploadPreview.d.ts +2 -2
- package/dist/src/FileUploader/FileUploadPreview.d.ts.map +1 -0
- package/dist/src/{labs/FileUpload.d.ts → FileUploader/FileUploader.d.ts} +5 -4
- package/dist/src/FileUploader/FileUploader.d.ts.map +1 -0
- package/dist/src/FileUploader/index.d.ts +13 -0
- package/dist/src/FileUploader/index.d.ts.map +1 -0
- package/dist/src/NativeSelect.d.ts +1 -1
- package/dist/src/OdysseyProvider.d.ts.map +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts +1 -1
- package/dist/src/OdysseyTranslationProvider.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts +1 -1
- package/dist/src/SearchField.d.ts +1 -1
- package/dist/src/Select.d.ts +36 -0
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/{labs/Switch.d.ts → Switch.d.ts} +3 -3
- package/dist/src/Switch.d.ts.map +1 -0
- package/dist/src/Tabs.d.ts +6 -8
- package/dist/src/Tabs.d.ts.map +1 -1
- package/dist/src/Tag.d.ts +7 -1
- package/dist/src/Tag.d.ts.map +1 -1
- package/dist/src/TextField.d.ts +17 -40
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/createShadowDomElements.d.ts.map +1 -1
- package/dist/src/i18n.d.ts +2 -2
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/labs/DataView/DataView.d.ts +1 -1
- package/dist/src/labs/DataView/DataView.d.ts.map +1 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts +2 -1
- package/dist/src/labs/DataView/TableLayoutContent.d.ts.map +1 -1
- package/dist/src/labs/DataView/componentTypes.d.ts +10 -0
- package/dist/src/labs/DataView/componentTypes.d.ts.map +1 -1
- package/dist/src/labs/DateField.d.ts +2 -2
- package/dist/src/labs/DateField.d.ts.map +1 -1
- package/dist/src/labs/DatePicker.d.ts +2 -2
- package/dist/src/labs/DatePicker.d.ts.map +1 -1
- package/dist/{test-selectors/odysseyTestSelectors.js → src/labs/SideNav/OktaLogo.d.ts} +3 -9
- package/dist/src/labs/SideNav/OktaLogo.d.ts.map +1 -0
- package/dist/src/labs/SideNav/SideNav.d.ts +2 -1
- package/dist/src/labs/SideNav/SideNav.d.ts.map +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts +1 -1
- package/dist/src/labs/SideNav/SideNavHeader.d.ts.map +1 -1
- package/dist/src/labs/SideNav/types.d.ts +28 -5
- package/dist/src/labs/SideNav/types.d.ts.map +1 -1
- package/dist/src/labs/TopNav.d.ts +1 -0
- package/dist/src/labs/TopNav.d.ts.map +1 -1
- package/dist/src/labs/index.d.ts +0 -2
- package/dist/src/labs/index.d.ts.map +1 -1
- package/dist/src/properties/ts/odyssey-react-mui.d.ts +2 -0
- package/dist/src/properties/ts/odyssey-react-mui.d.ts.map +1 -1
- package/dist/src/test-selectors/getByQuerySelector.d.ts +148 -0
- package/dist/src/test-selectors/getByQuerySelector.d.ts.map +1 -0
- package/{src/test-selectors/odysseyTestSelectors.ts → dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts} +3 -11
- package/dist/src/test-selectors/getComputedAccessibleErrorMessageText.d.ts.map +1 -0
- package/dist/src/test-selectors/{featureTestSelector.d.ts → getComputedAccessibleText.d.ts} +11 -19
- package/dist/src/test-selectors/getComputedAccessibleText.d.ts.map +1 -0
- package/dist/src/test-selectors/index.d.ts +2 -2
- package/dist/src/test-selectors/index.d.ts.map +1 -1
- package/dist/src/test-selectors/interpolateString.d.ts +15 -0
- package/dist/src/test-selectors/interpolateString.d.ts.map +1 -0
- package/dist/src/test-selectors/linkedHtmlSelectors.d.ts +24 -0
- package/dist/src/test-selectors/linkedHtmlSelectors.d.ts.map +1 -0
- package/dist/src/test-selectors/queryOdysseySelector.d.ts +5755 -0
- package/dist/src/test-selectors/queryOdysseySelector.d.ts.map +1 -0
- package/dist/src/test-selectors/querySelector.d.ts +59 -3613
- package/dist/src/test-selectors/querySelector.d.ts.map +1 -1
- package/dist/src/test-selectors/sanityChecks.d.ts +18 -0
- package/dist/src/test-selectors/sanityChecks.d.ts.map +1 -0
- package/dist/src/test-selectors/testSelector.d.ts +46 -0
- package/dist/src/test-selectors/testSelector.d.ts.map +1 -0
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/test-selectors/getByQuerySelector.js +64 -0
- package/dist/test-selectors/getByQuerySelector.js.map +1 -0
- package/dist/test-selectors/getComputedAccessibleErrorMessageText.js +25 -0
- package/dist/test-selectors/getComputedAccessibleErrorMessageText.js.map +1 -0
- package/dist/test-selectors/getComputedAccessibleText.js +24 -0
- package/dist/test-selectors/getComputedAccessibleText.js.map +1 -0
- package/dist/test-selectors/index.js +2 -2
- package/dist/test-selectors/index.js.map +1 -1
- package/{src/test-selectors/featureTestSelector.ts → dist/test-selectors/interpolateString.js} +11 -27
- package/dist/test-selectors/interpolateString.js.map +1 -0
- package/dist/test-selectors/linkedHtmlSelectors.js +34 -0
- package/dist/test-selectors/linkedHtmlSelectors.js.map +1 -0
- package/dist/test-selectors/queryOdysseySelector.js +26 -0
- package/dist/test-selectors/queryOdysseySelector.js.map +1 -0
- package/dist/test-selectors/querySelector.js +82 -58
- package/dist/test-selectors/querySelector.js.map +1 -1
- package/dist/test-selectors/sanityChecks.js +33 -0
- package/dist/test-selectors/sanityChecks.js.map +1 -0
- package/dist/test-selectors/testSelector.js +2 -0
- package/dist/test-selectors/testSelector.js.map +1 -0
- package/dist/test-selectors/testSelectors.json +1 -1
- package/dist/theme/components.js +0 -1
- package/dist/theme/components.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.setup.js +3 -0
- package/package.json +5 -4
- package/scripts/generateTestSelectorsJson.ts +1 -1
- package/src/@types/i18next.d.ts +1 -1
- package/src/Autocomplete.tsx +32 -0
- package/src/Callout.tsx +13 -25
- package/src/DataTable/useScrollIndication.tsx +9 -2
- package/src/{labs → FileUploader}/FileUploadPreview.tsx +3 -3
- package/src/{labs/FileUpload.tsx → FileUploader/FileUploader.tsx} +7 -6
- package/src/FileUploader/index.ts +13 -0
- package/src/OdysseyCacheProvider.test.tsx +1 -0
- package/src/OdysseyProvider.tsx +6 -1
- package/src/Radio.tsx +2 -2
- package/src/Select.tsx +38 -0
- package/src/{labs/Switch.tsx → Switch.tsx} +10 -10
- package/src/Tabs.tsx +8 -10
- package/src/Tag.tsx +134 -3
- package/src/TextField.tsx +18 -41
- package/src/Toast.tsx +1 -1
- package/src/createShadowDomElements.ts +3 -0
- package/src/i18n.ts +3 -3
- package/src/index.ts +6 -1
- package/src/labs/DataView/DataView.test.tsx +158 -0
- package/src/labs/DataView/DataView.tsx +98 -50
- package/src/labs/DataView/TableLayoutContent.tsx +28 -1
- package/src/labs/DataView/componentTypes.ts +13 -0
- package/src/labs/DateField.tsx +3 -0
- package/src/labs/DatePicker.tsx +12 -1
- package/src/labs/SideNav/OktaLogo.tsx +39 -0
- package/src/labs/SideNav/SideNav.tsx +187 -51
- package/src/labs/SideNav/SideNavHeader.tsx +30 -7
- package/src/labs/SideNav/types.ts +32 -5
- package/src/labs/TopNav.tsx +3 -1
- package/src/labs/index.ts +0 -3
- package/src/labs/useDateFieldsTranslations.ts +1 -1
- package/src/properties/odyssey-react-mui.properties +2 -1
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/test-selectors/getByQuerySelector.ts +176 -0
- package/src/test-selectors/getComputedAccessibleErrorMessageText.ts +52 -0
- package/src/test-selectors/getComputedAccessibleText.ts +36 -0
- package/src/test-selectors/index.ts +2 -2
- package/src/test-selectors/interpolateString.ts +41 -0
- package/src/test-selectors/linkedHtmlSelectors.ts +73 -0
- package/src/test-selectors/queryOdysseySelector.ts +36 -0
- package/src/test-selectors/querySelector.ts +221 -170
- package/src/test-selectors/sanityChecks.ts +53 -0
- package/src/test-selectors/testSelector.ts +143 -0
- package/src/theme/components.tsx +0 -2
- package/dist/labs/FileUpload.js.map +0 -1
- package/dist/labs/FileUploadIllustration.js.map +0 -1
- package/dist/labs/FileUploadPreview.js.map +0 -1
- package/dist/labs/Switch.js.map +0 -1
- package/dist/src/labs/FileUpload.d.ts.map +0 -1
- package/dist/src/labs/FileUploadIllustration.d.ts.map +0 -1
- package/dist/src/labs/FileUploadPreview.d.ts.map +0 -1
- package/dist/src/labs/Switch.d.ts.map +0 -1
- package/dist/src/test-selectors/featureTestSelector.d.ts.map +0 -1
- package/dist/src/test-selectors/odysseyTestSelectors.d.ts +0 -120
- package/dist/src/test-selectors/odysseyTestSelectors.d.ts.map +0 -1
- package/dist/test-selectors/featureTestSelector.js +0 -2
- package/dist/test-selectors/featureTestSelector.js.map +0 -1
- package/dist/test-selectors/odysseyTestSelectors.js.map +0 -1
- /package/dist/{labs → FileUploader}/FileUploadIllustration.js +0 -0
- /package/dist/{labs → FileUploader}/FileUploadPreview.js +0 -0
- /package/dist/src/{labs → FileUploader}/FileUploadIllustration.d.ts +0 -0
- /package/src/{labs → FileUploader}/FileUploadIllustration.tsx +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.23.0](https://github.com/okta/odyssey/compare/v1.19.0...v1.23.0) (2024-09-19)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add additional action button and menu slot to table ([#2334](https://github.com/okta/odyssey/issues/2334)) ([52b3f38](https://github.com/okta/odyssey/commit/52b3f3832adc442e0219be16fe8a4d96cf100a4e))
|
|
11
|
+
- adds a generic top nav component ([#2296](https://github.com/okta/odyssey/issues/2296)) ([6f3165f](https://github.com/okta/odyssey/commit/6f3165f9fd4a1d1743c975b72132d4ec186d09bb))
|
|
12
|
+
- adds new Shadow DOM export with better naming ([#2338](https://github.com/okta/odyssey/issues/2338)) ([0997e36](https://github.com/okta/odyssey/commit/0997e36afd4d241f5b3960528aff2865fb6d6ac3))
|
|
13
|
+
- automatically scroll to the first isSelected SideNavItem ([#2325](https://github.com/okta/odyssey/issues/2325)) ([52ce441](https://github.com/okta/odyssey/commit/52ce44137ffe5601cfa6044782a21afb5449167e))
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- Add missing props to Storybook ([#2313](https://github.com/okta/odyssey/issues/2313)) ([bbf96a2](https://github.com/okta/odyssey/commit/bbf96a257160b922c0ebc31b1c5dec1fe31c35b4))
|
|
18
|
+
- fixes translations not working with TypeScript ([#2354](https://github.com/okta/odyssey/issues/2354)) ([37653ee](https://github.com/okta/odyssey/commit/37653ee47c2fab8b54dec26efd5115f6633c2977))
|
|
19
|
+
- **odyssey-design-tokens:** using correct weights in SB ([#2363](https://github.com/okta/odyssey/issues/2363)) ([2dfa614](https://github.com/okta/odyssey/commit/2dfa614cd4c09d71d8624be690ae788e134a74ba))
|
|
20
|
+
- **odyssey-react-mui:** Add min-heights to keep correct heights ([#2324](https://github.com/okta/odyssey/issues/2324)) ([40d5a50](https://github.com/okta/odyssey/commit/40d5a5070ebfab1b650066e91b451c0ef4b3f2d8))
|
|
21
|
+
- remove invalid pseudo element from theme overrides ([#2310](https://github.com/okta/odyssey/issues/2310)) ([fea0793](https://github.com/okta/odyssey/commit/fea0793acf0800494270a87e4e5d65129942b99e))
|
|
22
|
+
- select multioption not rendering text when you use an options object ([#2323](https://github.com/okta/odyssey/issues/2323)) ([4bafbb9](https://github.com/okta/odyssey/commit/4bafbb99e03e52ad572fba9049013c058c75da38))
|
|
23
|
+
- Update Test Selector types and improve functionality ([#2333](https://github.com/okta/odyssey/issues/2333)) ([7039009](https://github.com/okta/odyssey/commit/703900947861dfb36b8996414130a8db3414ccfa))
|
|
24
|
+
|
|
6
25
|
## [1.22.0](https://github.com/okta/odyssey/compare/v1.19.0...v1.22.0) (2024-09-05)
|
|
7
26
|
|
|
8
27
|
### Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18next.d.js","names":[],"sources":["../../src/@types/i18next.d.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport \"i18next\";\nimport { translation as en } from \"../properties/ts/odyssey-react-mui\";\n\ndeclare module \"i18next\" {\n interface CustomTypeOptions {\n resources: {\n
|
|
1
|
+
{"version":3,"file":"i18next.d.js","names":[],"sources":["../../src/@types/i18next.d.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport \"i18next\";\nimport { translation as en } from \"../properties/ts/odyssey-react-mui\";\n\ndeclare module \"i18next\" {\n interface CustomTypeOptions {\n resources: {\n translation: typeof en;\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAAS"}
|
package/dist/Autocomplete.js
CHANGED
|
@@ -19,6 +19,36 @@ import { Field } from "./Field.js";
|
|
|
19
19
|
import { ComponentControlledState, useInputValues, getControlState } from "./inputUtils.js";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
21
|
import { createElement as _createElement } from "react";
|
|
22
|
+
export const AutocompleteTestSelector = {
|
|
23
|
+
accessibleText: {
|
|
24
|
+
errorMessage: "errorMessage",
|
|
25
|
+
hint: "description",
|
|
26
|
+
label: "label"
|
|
27
|
+
},
|
|
28
|
+
children: {
|
|
29
|
+
list: {
|
|
30
|
+
children: {
|
|
31
|
+
listItem: {
|
|
32
|
+
elementSelector: {
|
|
33
|
+
method: "ByRole",
|
|
34
|
+
options: {
|
|
35
|
+
label: "name"
|
|
36
|
+
},
|
|
37
|
+
role: "option"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
isControlledElement: true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
elementSelector: {
|
|
45
|
+
method: "ByRole",
|
|
46
|
+
options: {
|
|
47
|
+
label: "name"
|
|
48
|
+
},
|
|
49
|
+
role: "combobox"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
22
52
|
const ListboxContainer = styled.div`
|
|
23
53
|
width: 100%;
|
|
24
54
|
height: 100%;
|
package/dist/Autocomplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.js","names":["createContext","forwardRef","memo","useCallback","useContext","useEffect","useMemo","useRef","useState","styled","VariableSizeList","useTranslation","Field","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","createElement","_createElement","ListboxContainer","div","Autocomplete","ariaDescribedBy","defaultValue","errorMessage","errorMessageList","hasMultipleChoices","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","isVirtualized","isVirtualizedProp","hint","HintLinkComponent","label","name","nameOverride","noOptionsText","onBlur","onChange","onChangeProp","onInputChange","onInputChangeProp","onFocus","options","value","getIsOptionEqualToValue","testId","translate","t","controlledStateRef","controlledValue","uncontrolledValue","Boolean","defaultValueProp","undefined","valueProps","controlState","current","inputValueProp","CONTROLLED","renderInput","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","htmlFor","renderFieldComponent","errorMessageElementId","labelElementId","_InputBase","inputProps","required","Row","data","index","setItemSize","style","rowRef","firstChild","firstElementChild","height","clientHeight","baseOption","key","props","styles","ref","children","OuterListboxContext","OuterListboxElementType","outerProps","useResetCache","length","resetCacheRef","resetAfterIndex","ListboxComponent","listHeight","setListHeight","other","itemData","flatMap","item","concat","sizeMap","getListBoxHeight","COMBINED_LISTBOX_PADDING","OVERSCAN_ROW_COUNT","itemsHeightCalculated","map","_","reduce","prevItemHeight","nextItemHeight","gridRef","size","getItemSize","Provider","innerElementType","itemCount","itemSize","width","outerElementType","overscanCount","event","reason","details","_Autocomplete","clearText","closeText","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","fullWidth","loading","multiple","openText","readOnly","isOptionEqualToValue","MemoizedAutocomplete","displayName"],"sources":["../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n InputBase,\n UseAutocompleteProps,\n AutocompleteValue,\n AutocompleteRenderInputParams,\n} from \"@mui/material\";\nimport {\n createContext,\n forwardRef,\n HTMLAttributes,\n memo,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { VariableSizeList, ListChildComponentProps } from \"react-window\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\n\ntype 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?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\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?: UseAutocompleteProps<\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 * 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?: UseAutocompleteProps<\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?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n\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 /**\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} & 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 ListboxContainer = styled.div`\n width: 100%;\n height: 100%;\n`;\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 hasMultipleChoices,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n isVirtualized: isVirtualizedProp = false,\n hint,\n HintLinkComponent,\n label,\n name: nameOverride,\n noOptionsText,\n onBlur,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n onFocus,\n options,\n value,\n getIsOptionEqualToValue,\n testId,\n translate,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const { t } = useTranslation();\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const isVirtualized = useRef(Boolean(isVirtualizedProp));\n\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n defaultValue: defaultValueProp,\n value: value,\n controlState: controlledStateRef.current,\n });\n\n const inputValueProp = useMemo(() => {\n if (controlledStateRef.current === ComponentControlledState.CONTROLLED) {\n return { inputValue };\n }\n return undefined;\n }, [inputValue]);\n\n const renderInput = useCallback(\n ({\n InputLabelProps,\n InputProps,\n ...params\n }: AutocompleteRenderInputParams) => (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n //@ts-expect-error htmlFor does not exist ont he InputLabelProps for autocomplete\n id={InputLabelProps.htmlFor}\n isFullWidth={isFullWidth}\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({\n ariaDescribedBy,\n id,\n errorMessageElementId,\n labelElementId,\n }) => (\n <InputBase\n {...params}\n {...InputProps}\n inputProps={{\n ...params.inputProps,\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n \"data-se\": testId,\n }}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [\n ariaDescribedBy,\n errorMessage,\n errorMessageList,\n hint,\n HintLinkComponent,\n isFullWidth,\n isOptional,\n label,\n nameOverride,\n testId,\n ],\n );\n\n const Row = ({\n data,\n index,\n setItemSize,\n style,\n }: ListChildComponentProps & { setItemSize: SetItemSize }) => {\n const rowRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (rowRef.current) {\n /**\n * Checking for child height to workaround a bug where the clientHeight of the row isn't updated correctly\n * @see here if you need to know more: https://github.com/bvaughn/react-window/issues/582#issuecomment-1883074908\n */\n const firstChild = rowRef.current.firstElementChild;\n const height = firstChild\n ? firstChild.clientHeight\n : rowRef.current.clientHeight;\n\n setItemSize(height);\n }\n }, [index, rowRef, setItemSize]);\n\n const baseOption = data[index];\n const { key, props } = baseOption;\n\n /**\n * react-window calculates the absolute positions of the list items, via an inline style, so\n * we need to add it to each list item that is being rendered in the viewable list window.\n * @see here if you need to know more: https://github.com/bvaughn/react-window?tab=readme-ov-file#why-is-my-list-blank-when-i-scroll\n */\n const styles = useMemo(\n () => ({\n ...style,\n height: \"auto\",\n }),\n [style],\n );\n\n return (\n <div ref={rowRef}>\n <li {...props} key={key} style={styles} />\n </div>\n );\n };\n\n const OuterListboxContext = createContext({});\n\n const OuterListboxElementType = forwardRef<HTMLDivElement>((props, ref) => {\n const outerProps = useContext(OuterListboxContext);\n return <div ref={ref} {...props} {...outerProps} />;\n });\n\n const useResetCache = (length: number) => {\n const resetCacheRef = useRef<VariableSizeList>(null);\n useEffect(() => {\n if (resetCacheRef.current) {\n resetCacheRef.current.resetAfterIndex(0, true);\n }\n }, [length]);\n return resetCacheRef;\n };\n\n const ListboxComponent = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLElement>\n >(function (props, ref) {\n const [listHeight, setListHeight] = useState(0);\n\n const { children, ...other } = props;\n const itemData: ReactElement[] = (children as ReactElement[]).flatMap(\n (item: ReactElement & { children?: ReactElement[] }) =>\n [item].concat(item.children || []),\n );\n\n const sizeMap = useRef<number[]>([]);\n\n const getListBoxHeight = useCallback(() => {\n // 8px of padding top/bottom applied by MUI\n const COMBINED_LISTBOX_PADDING = 16;\n\n if (itemData.length > OVERSCAN_ROW_COUNT) {\n // has a max-height of 40vh set in CSS. This is only set because height needs to be a number\n return 99999;\n } else {\n const itemsHeightCalculated = itemData\n .map((_, index) => sizeMap.current[index] || 0)\n .reduce(\n (prevItemHeight, nextItemHeight) => prevItemHeight + nextItemHeight,\n 0,\n );\n return COMBINED_LISTBOX_PADDING + itemsHeightCalculated;\n }\n }, [itemData, sizeMap]);\n\n useEffect(() => {\n if (sizeMap.current.length && itemData.length) {\n setListHeight(getListBoxHeight());\n }\n }, [getListBoxHeight, itemData, sizeMap]);\n\n // The number of items (rows or columns) to render outside of the visible area for performance and scrolling reasons\n const OVERSCAN_ROW_COUNT = 8;\n\n const gridRef = useResetCache(itemData.length);\n\n const setItemSize = useCallback<SetItemSize>(\n (size) => {\n gridRef?.current?.resetAfterIndex(0, true);\n sizeMap.current = sizeMap.current.concat(size);\n },\n [gridRef, sizeMap],\n );\n const getItemSize = useCallback(\n // using 45px as a sane default here to avoid a lot of content shift on repaint\n (index: number) => sizeMap.current[index] || 45,\n [sizeMap],\n );\n\n return (\n <ListboxContainer ref={ref}>\n <OuterListboxContext.Provider value={other}>\n <VariableSizeList\n innerElementType=\"ul\"\n itemData={itemData}\n itemCount={itemData.length}\n itemSize={getItemSize}\n height={listHeight}\n width=\"100%\"\n ref={gridRef}\n outerElementType={OuterListboxElementType}\n overscanCount={OVERSCAN_ROW_COUNT}\n >\n {({ data, index, style }) => (\n <Row\n data={data}\n index={index}\n style={style}\n setItemSize={setItemSize}\n />\n )}\n </VariableSizeList>\n </OuterListboxContext.Provider>\n </ListboxContainer>\n );\n });\n\n const onChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"]\n >\n >(\n (event, value, reason, details) => {\n onChangeProp?.(event, value, reason, details);\n },\n [onChangeProp],\n );\n\n const onInputChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"]\n >\n >(\n (event, value, reason) => {\n onInputChangeProp?.(event, value, reason);\n },\n [onInputChangeProp],\n );\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // conditionally provide the ListboxComponent if this needs to be virtualized\n {...(isVirtualized.current && {\n ListboxComponent,\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 id={idOverride}\n fullWidth={isFullWidth}\n loading={isLoading}\n multiple={hasMultipleChoices}\n noOptionsText={noOptionsText}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n openText={t(\"open.text\")}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n isOptionEqualToValue={getIsOptionEqualToValue}\n translate={translate}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,SACEA,aAAa,EACbC,UAAU,EAEVC,IAAI,EAEJC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,gBAAgB,QAAiC,cAAc;AACxE,SAASC,cAAc,QAAQ,eAAe;AAAC,SAEtCC,KAAK;AAAA,SAIZC,wBAAwB,EACxBC,cAAc,EACdC,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,aAAA,IAAAC,cAAA;AAkKjB,MAAMC,gBAAgB,GAAGX,MAAM,CAACY,GAAI;AACpC;AACA;AACA,CAAC;AAED,MAAMC,YAAY,GAAGA,CAInB;EACAC,eAAe;EACfC,YAAY;EACZC,YAAY;EACZC,gBAAgB;EAChBC,kBAAkB;EAClBC,EAAE,EAAEC,UAAU;EACdC,UAAU;EACVC,oBAAoB;EACpBC,UAAU;EACVC,W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AW,EAAEA,WAAY;IACzB+E,oBAAoB,EAAE9F,uBAAwB;IAC9CE,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAGD,MAAM6F,oBAAoB,GAAGlJ,IAAI,CAACoB,YAAY,CAAwB;AAEtE8H,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAI9H,YAAY"}
|
|
1
|
+
{"version":3,"file":"Autocomplete.js","names":["createContext","forwardRef","memo","useCallback","useContext","useEffect","useMemo","useRef","useState","styled","VariableSizeList","useTranslation","Field","ComponentControlledState","useInputValues","getControlState","jsx","_jsx","createElement","_createElement","AutocompleteTestSelector","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","ListboxContainer","div","Autocomplete","ariaDescribedBy","defaultValue","errorMessageList","hasMultipleChoices","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","isVirtualized","isVirtualizedProp","HintLinkComponent","name","nameOverride","noOptionsText","onBlur","onChange","onChangeProp","onInputChange","onInputChangeProp","onFocus","value","getIsOptionEqualToValue","testId","translate","t","controlledStateRef","controlledValue","uncontrolledValue","Boolean","defaultValueProp","undefined","valueProps","controlState","current","inputValueProp","CONTROLLED","renderInput","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","htmlFor","renderFieldComponent","errorMessageElementId","labelElementId","_InputBase","inputProps","required","Row","data","index","setItemSize","style","rowRef","firstChild","firstElementChild","height","clientHeight","baseOption","key","props","styles","ref","OuterListboxContext","OuterListboxElementType","outerProps","useResetCache","length","resetCacheRef","resetAfterIndex","ListboxComponent","listHeight","setListHeight","other","itemData","flatMap","item","concat","sizeMap","getListBoxHeight","COMBINED_LISTBOX_PADDING","OVERSCAN_ROW_COUNT","itemsHeightCalculated","map","_","reduce","prevItemHeight","nextItemHeight","gridRef","size","getItemSize","Provider","innerElementType","itemCount","itemSize","width","outerElementType","overscanCount","event","reason","details","_Autocomplete","clearText","closeText","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","fullWidth","loading","multiple","openText","readOnly","isOptionEqualToValue","MemoizedAutocomplete","displayName"],"sources":["../src/Autocomplete.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n Autocomplete as MuiAutocomplete,\n AutocompleteProps as MuiAutocompleteProps,\n InputBase,\n UseAutocompleteProps,\n AutocompleteValue,\n AutocompleteRenderInputParams,\n} from \"@mui/material\";\nimport {\n createContext,\n forwardRef,\n HTMLAttributes,\n memo,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { VariableSizeList, ListChildComponentProps } from \"react-window\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Field } from \"./Field\";\nimport { FieldComponentProps } from \"./FieldComponentProps\";\nimport type { HtmlProps } from \"./HtmlProps\";\nimport {\n ComponentControlledState,\n useInputValues,\n getControlState,\n} from \"./inputUtils\";\nimport { TestSelector } from \"./test-selectors\";\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\ntype 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?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"defaultValue\"];\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?: UseAutocompleteProps<\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 * 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?: UseAutocompleteProps<\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?: UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n\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 /**\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} & 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 ListboxContainer = styled.div`\n width: 100%;\n height: 100%;\n`;\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 hasMultipleChoices,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n isVirtualized: isVirtualizedProp = false,\n hint,\n HintLinkComponent,\n label,\n name: nameOverride,\n noOptionsText,\n onBlur,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n onFocus,\n options,\n value,\n getIsOptionEqualToValue,\n testId,\n translate,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const { t } = useTranslation();\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n\n const isVirtualized = useRef(Boolean(isVirtualizedProp));\n\n const defaultValueProp = useMemo<\n | AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >\n | undefined\n >(() => {\n if (hasMultipleChoices) {\n if (value === undefined) {\n return defaultValue;\n }\n return [] as AutocompleteValue<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >;\n }\n return value === undefined ? defaultValue : undefined;\n }, [defaultValue, hasMultipleChoices, value]);\n\n const valueProps = useInputValues({\n defaultValue: defaultValueProp,\n value: value,\n controlState: controlledStateRef.current,\n });\n\n const inputValueProp = useMemo(() => {\n if (controlledStateRef.current === ComponentControlledState.CONTROLLED) {\n return { inputValue };\n }\n return undefined;\n }, [inputValue]);\n\n const renderInput = useCallback(\n ({\n InputLabelProps,\n InputProps,\n ...params\n }: AutocompleteRenderInputParams) => (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n //@ts-expect-error htmlFor does not exist ont he InputLabelProps for autocomplete\n id={InputLabelProps.htmlFor}\n isFullWidth={isFullWidth}\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({\n ariaDescribedBy,\n id,\n errorMessageElementId,\n labelElementId,\n }) => (\n <InputBase\n {...params}\n {...InputProps}\n inputProps={{\n ...params.inputProps,\n \"aria-errormessage\": errorMessageElementId,\n \"aria-labelledby\": labelElementId,\n \"data-se\": testId,\n }}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [\n ariaDescribedBy,\n errorMessage,\n errorMessageList,\n hint,\n HintLinkComponent,\n isFullWidth,\n isOptional,\n label,\n nameOverride,\n testId,\n ],\n );\n\n const Row = ({\n data,\n index,\n setItemSize,\n style,\n }: ListChildComponentProps & { setItemSize: SetItemSize }) => {\n const rowRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (rowRef.current) {\n /**\n * Checking for child height to workaround a bug where the clientHeight of the row isn't updated correctly\n * @see here if you need to know more: https://github.com/bvaughn/react-window/issues/582#issuecomment-1883074908\n */\n const firstChild = rowRef.current.firstElementChild;\n const height = firstChild\n ? firstChild.clientHeight\n : rowRef.current.clientHeight;\n\n setItemSize(height);\n }\n }, [index, rowRef, setItemSize]);\n\n const baseOption = data[index];\n const { key, props } = baseOption;\n\n /**\n * react-window calculates the absolute positions of the list items, via an inline style, so\n * we need to add it to each list item that is being rendered in the viewable list window.\n * @see here if you need to know more: https://github.com/bvaughn/react-window?tab=readme-ov-file#why-is-my-list-blank-when-i-scroll\n */\n const styles = useMemo(\n () => ({\n ...style,\n height: \"auto\",\n }),\n [style],\n );\n\n return (\n <div ref={rowRef}>\n <li {...props} key={key} style={styles} />\n </div>\n );\n };\n\n const OuterListboxContext = createContext({});\n\n const OuterListboxElementType = forwardRef<HTMLDivElement>((props, ref) => {\n const outerProps = useContext(OuterListboxContext);\n return <div ref={ref} {...props} {...outerProps} />;\n });\n\n const useResetCache = (length: number) => {\n const resetCacheRef = useRef<VariableSizeList>(null);\n useEffect(() => {\n if (resetCacheRef.current) {\n resetCacheRef.current.resetAfterIndex(0, true);\n }\n }, [length]);\n return resetCacheRef;\n };\n\n const ListboxComponent = forwardRef<\n HTMLDivElement,\n HTMLAttributes<HTMLElement>\n >(function (props, ref) {\n const [listHeight, setListHeight] = useState(0);\n\n const { children, ...other } = props;\n const itemData: ReactElement[] = (children as ReactElement[]).flatMap(\n (item: ReactElement & { children?: ReactElement[] }) =>\n [item].concat(item.children || []),\n );\n\n const sizeMap = useRef<number[]>([]);\n\n const getListBoxHeight = useCallback(() => {\n // 8px of padding top/bottom applied by MUI\n const COMBINED_LISTBOX_PADDING = 16;\n\n if (itemData.length > OVERSCAN_ROW_COUNT) {\n // has a max-height of 40vh set in CSS. This is only set because height needs to be a number\n return 99999;\n } else {\n const itemsHeightCalculated = itemData\n .map((_, index) => sizeMap.current[index] || 0)\n .reduce(\n (prevItemHeight, nextItemHeight) => prevItemHeight + nextItemHeight,\n 0,\n );\n return COMBINED_LISTBOX_PADDING + itemsHeightCalculated;\n }\n }, [itemData, sizeMap]);\n\n useEffect(() => {\n if (sizeMap.current.length && itemData.length) {\n setListHeight(getListBoxHeight());\n }\n }, [getListBoxHeight, itemData, sizeMap]);\n\n // The number of items (rows or columns) to render outside of the visible area for performance and scrolling reasons\n const OVERSCAN_ROW_COUNT = 8;\n\n const gridRef = useResetCache(itemData.length);\n\n const setItemSize = useCallback<SetItemSize>(\n (size) => {\n gridRef?.current?.resetAfterIndex(0, true);\n sizeMap.current = sizeMap.current.concat(size);\n },\n [gridRef, sizeMap],\n );\n const getItemSize = useCallback(\n // using 45px as a sane default here to avoid a lot of content shift on repaint\n (index: number) => sizeMap.current[index] || 45,\n [sizeMap],\n );\n\n return (\n <ListboxContainer ref={ref}>\n <OuterListboxContext.Provider value={other}>\n <VariableSizeList\n innerElementType=\"ul\"\n itemData={itemData}\n itemCount={itemData.length}\n itemSize={getItemSize}\n height={listHeight}\n width=\"100%\"\n ref={gridRef}\n outerElementType={OuterListboxElementType}\n overscanCount={OVERSCAN_ROW_COUNT}\n >\n {({ data, index, style }) => (\n <Row\n data={data}\n index={index}\n style={style}\n setItemSize={setItemSize}\n />\n )}\n </VariableSizeList>\n </OuterListboxContext.Provider>\n </ListboxContainer>\n );\n });\n\n const onChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onChange\"]\n >\n >(\n (event, value, reason, details) => {\n onChangeProp?.(event, value, reason, details);\n },\n [onChangeProp],\n );\n\n const onInputChange = useCallback<\n NonNullable<\n UseAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"onInputChange\"]\n >\n >(\n (event, value, reason) => {\n onInputChangeProp?.(event, value, reason);\n },\n [onInputChangeProp],\n );\n\n return (\n <MuiAutocomplete\n {...valueProps}\n {...inputValueProp}\n // conditionally provide the ListboxComponent if this needs to be virtualized\n {...(isVirtualized.current && {\n ListboxComponent,\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 id={idOverride}\n fullWidth={isFullWidth}\n loading={isLoading}\n multiple={hasMultipleChoices}\n noOptionsText={noOptionsText}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n openText={t(\"open.text\")}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n isOptionEqualToValue={getIsOptionEqualToValue}\n translate={translate}\n />\n );\n};\n\n// Need the `typeof Autocomplete` because generics don't get passed through\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n// @ts-expect-error displayName is expected to not be on `typeof Autocomplete`\nMemoizedAutocomplete.displayName = \"Autocomplete\";\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA,SACEA,aAAa,EACbC,UAAU,EAEVC,IAAI,EAEJC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,gBAAgB,QAAiC,cAAc;AACxE,SAASC,cAAc,QAAQ,eAAe;AAAC,SAEtCC,KAAK;AAAA,SAIZC,wBAAwB,EACxBC,cAAc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,iBAAiB,GAAGiF,KAAK,EAAE/E,KAAK,EAAEgF,MAAM,CAAC;EAC3C,CAAC,EACD,CAAClF,iBAAiB,CACpB,CAAC;EAED,OACE1C,IAAA,CAAA8H,aAAA;IAAA,GACMvE,UAAU;IAAA,GACVG,cAAc;IAAA,IAEb1B,aAAa,CAACyB,OAAO,IAAI;MAC5BsC;IACF,CAAC;IAED,iBAAepE,UAAW;IAC1BoG,SAAS,EAAE/E,CAAC,CAAC,YAAY,CAAE;IAC3BgF,SAAS,EAAEhF,CAAC,CAAC,YAAY,CAAE;IAC3BiF,oBAAoB,EAAE3G,kBAAmB;IACzC4G,QAAQ,EAAEvG,UAAW;IACrBwG,QAAQ,EAAEzG,oBAAqB;IAC/B0G,qBAAqB,EAAE,IAAK;IAC5B7G,EAAE,EAAEC,UAAW;IACf6G,SAAS,EAAEzG,WAAY;IACvB0G,OAAO,EAAEzG,SAAU;IACnB0G,QAAQ,EAAEjH,kBAAmB;IAC7Be,aAAa,EAAEA,aAAc;IAC7BC,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBE,aAAa,EAAEA,aAAc;IAC7BE,OAAO,EAAEA,OAAQ;IACjB6F,QAAQ,EAAExF,CAAC,CAAC,WAAW,CAAE;IACzBnC,OAAO,EAAEA,OAAQ;IACjB4H,QAAQ,EAAE1G,UAAW;IACrB6B,WAAW,EAAEA,WAAY;IACzB8E,oBAAoB,EAAE7F,uBAAwB;IAC9CE,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAGD,MAAM4F,oBAAoB,GAAG1J,IAAI,CAACiC,YAAY,CAAwB;AAEtEyH,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIzH,YAAY"}
|
package/dist/Callout.js
CHANGED
|
@@ -22,40 +22,28 @@ import { Paragraph } from "./Typography.js";
|
|
|
22
22
|
import { useUniqueId } from "./useUniqueId.js";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
-
export const
|
|
26
|
-
|
|
25
|
+
export const CalloutTestSelector = {
|
|
26
|
+
accessibleText: {
|
|
27
|
+
text: "description",
|
|
28
|
+
title: "label"
|
|
29
|
+
},
|
|
30
|
+
children: {
|
|
27
31
|
link: {
|
|
28
|
-
|
|
32
|
+
elementSelector: {
|
|
29
33
|
method: "ByRole",
|
|
30
34
|
options: {
|
|
31
|
-
|
|
35
|
+
linkText: "name"
|
|
32
36
|
},
|
|
33
|
-
role: "link"
|
|
34
|
-
templateVariableNames: ["linkText"]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
text: {
|
|
38
|
-
selector: {
|
|
39
|
-
method: "ByText",
|
|
40
|
-
templateVariableNames: ["text"],
|
|
41
|
-
text: "${text}"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
title: {
|
|
45
|
-
selector: {
|
|
46
|
-
method: "ByText",
|
|
47
|
-
templateVariableNames: ["title"],
|
|
48
|
-
text: "${title}"
|
|
37
|
+
role: "link"
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
40
|
},
|
|
52
|
-
|
|
41
|
+
elementSelector: {
|
|
53
42
|
method: "ByRole",
|
|
54
43
|
options: {
|
|
55
|
-
|
|
44
|
+
title: "name"
|
|
56
45
|
},
|
|
57
|
-
role: "
|
|
58
|
-
templateVariableNames: ["role", "title"]
|
|
46
|
+
role: ["alert", "status"]
|
|
59
47
|
}
|
|
60
48
|
};
|
|
61
49
|
export const calloutRoleValues = ["status", "alert"];
|
package/dist/Callout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Callout.js","names":["styled","memo","useTranslation","useOdysseyDesignTokens","Paragraph","useUniqueId","jsx","_jsx","jsxs","_jsxs","
|
|
1
|
+
{"version":3,"file":"Callout.js","names":["styled","memo","useTranslation","useOdysseyDesignTokens","Paragraph","useUniqueId","jsx","_jsx","jsxs","_jsxs","CalloutTestSelector","accessibleText","text","title","children","link","elementSelector","method","options","linkText","role","calloutRoleValues","calloutSeverityValues","ContentContainer","shouldForwardProp","prop","odysseyDesignTokens","marginBlockStart","Spacing4","Callout","linkUrl","severity","testId","translate","t","titleId","_Alert","variant","_AlertTitle","id","_Box","component","_Link","href","MemoizedCallout","displayName"],"sources":["../src/Callout.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 styled from \"@emotion/styled\";\nimport { Alert, AlertTitle, Box, Link as MuiLink } from \"@mui/material\";\nimport { memo, ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\n\nimport type { HtmlProps } from \"./HtmlProps\";\nimport {\n DesignTokens,\n useOdysseyDesignTokens,\n} from \"./OdysseyDesignTokensContext\";\nimport { type TestSelector } from \"./test-selectors\";\nimport { Paragraph } from \"./Typography\";\nimport { useUniqueId } from \"./useUniqueId\";\n\nexport const CalloutTestSelector = {\n accessibleText: {\n text: \"description\",\n title: \"label\",\n },\n children: {\n link: {\n elementSelector: {\n method: \"ByRole\",\n options: {\n linkText: \"name\",\n },\n role: \"link\",\n },\n },\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n title: \"name\",\n },\n role: [\"alert\", \"status\"],\n },\n} as const satisfies TestSelector;\n\nexport const calloutRoleValues = [\"status\", \"alert\"] as const;\nexport const calloutSeverityValues = [\n \"success\",\n \"info\",\n \"warning\",\n \"error\",\n] as const;\n\nexport type CalloutProps = {\n /**\n * Used to optionally pass a text list to the component\n */\n children?: ReactNode;\n /**\n * Sets the ARIA role of the Callout\n * (\"status\" for something that dynamically updates, \"alert\" for errors, null for something\n * unchanging)\n */\n role?: (typeof calloutRoleValues)[number];\n /**\n * Determine the color and icon of the Callout\n */\n severity: (typeof calloutSeverityValues)[number];\n /**\n * The text content of the Callout\n */\n text?: string;\n /**\n * The title of the Callout\n */\n title?: string;\n} & (\n | {\n children?: never;\n text: string;\n }\n | {\n children: ReactNode;\n text?: never;\n }\n) &\n (\n | {\n /**\n * If linkUrl is not undefined, this is the text of the link.\n * If left blank, it defaults to \"Learn more\".\n * Note that linkText does nothing if linkUrl is not defined\n */\n linkUrl: string;\n /**\n * If defined, the Toast will include a link to the URL\n */\n linkText: string;\n }\n | {\n linkUrl?: never;\n linkText?: never;\n }\n ) &\n Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst ContentContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})(({ odysseyDesignTokens }: { odysseyDesignTokens: DesignTokens }) => ({\n \"& > * + *\": {\n marginBlockStart: odysseyDesignTokens.Spacing4,\n },\n}));\n\nconst Callout = ({\n children,\n linkText,\n linkUrl,\n role,\n severity,\n testId,\n text,\n title,\n translate,\n}: CalloutProps) => {\n const { t } = useTranslation();\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const titleId = useUniqueId();\n\n return (\n <Alert\n aria-label={t(`severity.${severity}`)}\n aria-labelledby={titleId}\n data-se={testId}\n role={role}\n severity={severity}\n variant=\"callout\"\n >\n {title && (\n <AlertTitle aria-hidden id={titleId} translate={translate}>\n {title}\n </AlertTitle>\n )}\n\n <ContentContainer odysseyDesignTokens={odysseyDesignTokens}>\n {children && <Box component=\"div\">{children}</Box>}\n {text && <Paragraph>{text}</Paragraph>}\n {linkUrl && (\n <Box>\n <MuiLink href={linkUrl} variant=\"monochrome\">\n {linkText}\n </MuiLink>\n </Box>\n )}\n </ContentContainer>\n </Alert>\n );\n};\n\nconst MemoizedCallout = memo(Callout);\nMemoizedCallout.displayName =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@@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { useCallback, useEffect, useRef } from "react";
|
|
14
|
+
import { useOdysseyDesignTokens } from "../OdysseyDesignTokensContext.js";
|
|
14
15
|
export const useScrollIndication = ({
|
|
15
16
|
tableOuterContainer,
|
|
16
17
|
tableInnerContainer,
|
|
@@ -20,6 +21,7 @@ export const useScrollIndication = ({
|
|
|
20
21
|
}) => {
|
|
21
22
|
const animationFrameIdRef = useRef(null);
|
|
22
23
|
const resizeObserverRef = useRef(null);
|
|
24
|
+
const odysseyDesignTokens = useOdysseyDesignTokens();
|
|
23
25
|
const checkScrollIndicators = useCallback(() => {
|
|
24
26
|
if (!tableOuterContainer || !tableInnerContainer) return;
|
|
25
27
|
const containerWidth = tableOuterContainer.clientWidth;
|
|
@@ -30,7 +32,9 @@ export const useScrollIndication = ({
|
|
|
30
32
|
setIsTableContainerScrolledToEnd(containerEndScrollPosition >= contentWidth - 16);
|
|
31
33
|
}, [tableInnerContainer, tableOuterContainer, setIsTableContainerScrolledToEnd, setIsTableContainerScrolledToStart]);
|
|
32
34
|
useEffect(() => {
|
|
33
|
-
if (resizeObserverRef.current)
|
|
35
|
+
if (typeof ResizeObserver === "undefined" || resizeObserverRef.current) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
34
38
|
let debounceTimer;
|
|
35
39
|
resizeObserverRef.current = new ResizeObserver(() => {
|
|
36
40
|
clearTimeout(debounceTimer);
|
|
@@ -41,7 +45,7 @@ export const useScrollIndication = ({
|
|
|
41
45
|
animationFrameIdRef.current = null;
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
|
-
setTableInnerContainerWidth(tableInnerContainer?.clientWidth ? `${tableInnerContainer.clientWidth}px` : "100%");
|
|
48
|
+
setTableInnerContainerWidth(tableInnerContainer?.clientWidth ? `${tableInnerContainer.clientWidth - Number(odysseyDesignTokens.BorderWidthMain) * 2}px` : "100%");
|
|
45
49
|
}, 100);
|
|
46
50
|
});
|
|
47
51
|
if (tableOuterContainer && tableOuterContainer.parentElement) {
|
|
@@ -58,7 +62,7 @@ export const useScrollIndication = ({
|
|
|
58
62
|
animationFrameIdRef.current = null;
|
|
59
63
|
}
|
|
60
64
|
};
|
|
61
|
-
}, [checkScrollIndicators, setTableInnerContainerWidth, tableOuterContainer, tableInnerContainer, setIsTableContainerScrolledToStart, setIsTableContainerScrolledToEnd]);
|
|
65
|
+
}, [checkScrollIndicators, setTableInnerContainerWidth, tableOuterContainer, tableInnerContainer, setIsTableContainerScrolledToStart, setIsTableContainerScrolledToEnd, odysseyDesignTokens.BorderWidthMain]);
|
|
62
66
|
useEffect(() => {
|
|
63
67
|
tableInnerContainer?.addEventListener("scroll", checkScrollIndicators);
|
|
64
68
|
return () => tableInnerContainer?.removeEventListener("scroll", checkScrollIndicators);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollIndication.js","names":["useCallback","useEffect","useRef","useScrollIndication","tableOuterContainer","tableInnerContainer","setIsTableContainerScrolledToStart","setIsTableContainerScrolledToEnd","setTableInnerContainerWidth","animationFrameIdRef","resizeObserverRef","checkScrollIndicators","containerWidth","clientWidth","contentWidth","scrollWidth","containerStartScrollPosition","scrollLeft","containerEndScrollPosition","
|
|
1
|
+
{"version":3,"file":"useScrollIndication.js","names":["useCallback","useEffect","useRef","useOdysseyDesignTokens","useScrollIndication","tableOuterContainer","tableInnerContainer","setIsTableContainerScrolledToStart","setIsTableContainerScrolledToEnd","setTableInnerContainerWidth","animationFrameIdRef","resizeObserverRef","odysseyDesignTokens","checkScrollIndicators","containerWidth","clientWidth","contentWidth","scrollWidth","containerStartScrollPosition","scrollLeft","containerEndScrollPosition","ResizeObserver","current","debounceTimer","clearTimeout","setTimeout","requestAnimationFrame","Number","BorderWidthMain","parentElement","observe","disconnect","cancelAnimationFrame","addEventListener","removeEventListener"],"sources":["../../src/DataTable/useScrollIndication.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 Dispatch,\n SetStateAction,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useOdysseyDesignTokens } from \"../OdysseyDesignTokensContext\";\n\ntype UseScrollIndicationProps = {\n tableOuterContainer: HTMLDivElement | null;\n tableInnerContainer: HTMLDivElement | null;\n setIsTableContainerScrolledToStart: Dispatch<SetStateAction<boolean>>;\n setIsTableContainerScrolledToEnd: Dispatch<SetStateAction<boolean>>;\n setTableInnerContainerWidth: Dispatch<SetStateAction<string>>;\n};\nexport const useScrollIndication = ({\n tableOuterContainer,\n tableInnerContainer,\n setIsTableContainerScrolledToStart,\n setIsTableContainerScrolledToEnd,\n setTableInnerContainerWidth,\n}: UseScrollIndicationProps) => {\n const animationFrameIdRef = useRef<number | null>(null);\n\n const resizeObserverRef = useRef<ResizeObserver | null>(null);\n\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const checkScrollIndicators = useCallback(() => {\n if (!tableOuterContainer || !tableInnerContainer) return;\n\n const containerWidth = tableOuterContainer.clientWidth;\n const contentWidth = tableInnerContainer.scrollWidth;\n const containerStartScrollPosition = tableInnerContainer.scrollLeft;\n const containerEndScrollPosition =\n containerStartScrollPosition + containerWidth;\n\n setIsTableContainerScrolledToStart(containerStartScrollPosition <= 16);\n setIsTableContainerScrolledToEnd(\n containerEndScrollPosition >= contentWidth - 16,\n );\n }, [\n tableInnerContainer,\n tableOuterContainer,\n setIsTableContainerScrolledToEnd,\n setIsTableContainerScrolledToStart,\n ]);\n\n useEffect(() => {\n // Avoid creating multiple observers or if ResizeObserver is unsupported\n if (typeof ResizeObserver === \"undefined\" || resizeObserverRef.current) {\n return;\n }\n\n let debounceTimer: ReturnType<typeof setTimeout>;\n\n resizeObserverRef.current = new ResizeObserver(() => {\n clearTimeout(debounceTimer);\n debounceTimer = setTimeout(() => {\n if (!animationFrameIdRef.current) {\n animationFrameIdRef.current = requestAnimationFrame(() => {\n checkScrollIndicators();\n animationFrameIdRef.current = null;\n });\n }\n\n setTableInnerContainerWidth(\n tableInnerContainer?.clientWidth\n ? `${tableInnerContainer.clientWidth - Number(odysseyDesignTokens.BorderWidthMain) * 2}px` // Account for the border on the outer container\n : \"100%\",\n );\n }, 100); // debounce delay\n });\n\n if (tableOuterContainer && tableOuterContainer.parentElement) {\n resizeObserverRef.current.observe(tableOuterContainer.parentElement);\n }\n\n return () => {\n if (resizeObserverRef.current) {\n resizeObserverRef.current.disconnect();\n resizeObserverRef.current = null;\n }\n clearTimeout(debounceTimer); // Ensure timer is cleared on component unmount\n if (animationFrameIdRef.current) {\n cancelAnimationFrame(animationFrameIdRef.current);\n animationFrameIdRef.current = null;\n }\n };\n }, [\n checkScrollIndicators,\n setTableInnerContainerWidth,\n tableOuterContainer,\n tableInnerContainer,\n setIsTableContainerScrolledToStart,\n setIsTableContainerScrolledToEnd,\n odysseyDesignTokens.BorderWidthMain,\n ]);\n\n useEffect(() => {\n tableInnerContainer?.addEventListener(\"scroll\", checkScrollIndicators);\n return () =>\n tableInnerContainer?.removeEventListener(\"scroll\", checkScrollIndicators);\n }, [tableInnerContainer, checkScrollIndicators]); // Re-run when innerContainerRef changes\n\n // Initial check to set state correctly on mount\n useEffect(() => {\n checkScrollIndicators();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAGEA,WAAW,EACXC,SAAS,EACTC,MAAM,QACD,OAAO;AAAC,SACNC,sBAAsB;AAS/B,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;E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ens","jsx","_jsx","jsxs","_jsxs","UploadIllustrationContainer","div","odysseyDesignTokens","marginBlockEnd","Spacing3","padding","backgroundColor","HueNeutral50","borderRadius","svg","display","width","Spacing8","height","FileUploadIllustration","children","viewBox","fill","xmlns","d","HueNeutral200","MemoizedFileUploadIllustration","displayName"],"sources":["../../src/FileUploader/FileUploadIllustration.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo } from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../OdysseyDesignTokensContext\";\n\nconst UploadIllustrationContainer = styled.div<{\n odysseyDesignTokens: DesignTokens;\n}>(({ odysseyDesignTokens }) => ({\n marginBlockEnd: odysseyDesignTokens.Spacing3,\n padding: odysseyDesignTokens.Spacing3,\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n borderRadius: \"50%\",\n\n svg: {\n display: \"flex\",\n width: odysseyDesignTokens.Spacing8,\n height: odysseyDesignTokens.Spacing8,\n },\n}));\n\nconst FileUploadIllustration = () => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <UploadIllustrationContainer\n aria-hidden=\"true\"\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 44 45\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M32.0763 11.001C29.3564 3.7855 21.6595 -0.565827 13.7765 0.726748C5.35441 2.10773 -0.676662 9.50714 0.0603005 17.8612C0.441865 22.1865 2.56458 25.9787 5.71703 28.614L8.28246 25.545C5.90122 23.5544 4.32811 20.7209 4.04483 17.5097C3.50262 11.3633 7.94433 5.73648 14.4238 4.67404C20.9164 3.60944 27.0806 7.52016 28.6895 13.5191C28.9239 14.3932 29.7162 15.001 30.6212 15.001H32.9114C36.8985 15.001 39.9997 18.0938 39.9997 21.7505C39.9997 24.3423 38.4576 26.6352 36.1259 27.7678L37.8736 31.3658C41.4737 29.6171 43.9997 25.9917 43.9997 21.7505C43.9997 15.7428 38.963 11.001 32.9114 11.001H32.0763Z\"\n fill={odysseyDesignTokens.HueNeutral200}\n />\n <path\n d=\"M23.9994 29.3277V44.5H19.9994V29.3289L14.4142 34.9141L11.5858 32.0857L19.7373 23.9342C20.9869 22.6845 23.0131 22.6845 24.2627 23.9342L32.4142 32.0857L29.5858 34.9141L23.9994 29.3277Z\"\n fill={odysseyDesignTokens.HueNeutral200}\n />\n </svg>\n </UploadIllustrationContainer>\n );\n};\n\nconst MemoizedFileUploadIllustration = memo(FileUploadIllustration);\nMemoizedFileUploadIllustration.displayName = \"FileUploadIllustration\";\n\nexport { MemoizedFileUploadIllustration as FileUploadIllustration };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,OAAO;AAC5B,OAAOC,MAAM,MAAM,iBAAiB;AAAC,SAGnCC,sBAAsB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAIxB,MAAMC,2BAA2B,GAAGN,MAAM,CAACO,GAAG,CAE3C,CAAC;EAAEC;AAAoB,CAAC,MAAM;EAC/BC,cAAc,EAAED,mBAAmB,CAACE,QAAQ;EAC5CC,OAAO,EAAEH,mBAAmB,CAACE,QAAQ;EACrCE,eAAe,EAAEJ,mBAAmB,CAACK,YAAY;EACjDC,YAAY,EAAE,KAAK;EAEnBC,GAAG,EAAE;IACHC,OAAO,EAAE,MAAM;IACfC,KAAK,EAAET,mBAAmB,CAACU,QAAQ;IACnCC,MAAM,EAAEX,mBAAmB,CAACU;EAC9B;AACF,CAAC,CAAC,CAAC;AAEH,MAAME,sBAAsB,GAAGA,CAAA,KAAM;EACnC,MAAMZ,mBAAmB,GAAGP,sBAAsB,CAAC,CAAC;EAEpD,OACEE,IAAA,CAACG,2BAA2B;IAC1B,eAAY,MAAM;IAClBE,mBAAmB,EAAEA,mBAAoB;IAAAa,QAAA,EAEzChB,KAAA;MACE,eAAY,MAAM;MAClBiB,OAAO,EAAC,WAAW;MACnBC,IAAI,EAAC,MAAM;MACXC,KAAK,EAAC,4BAA4B;MAAAH,QAAA,GAElClB,IAAA;QACEsB,CAAC,EAAC,ilBAAilB;QACnlBF,IAAI,EAAEf,mBAAmB,CAACkB;MAAc,CACzC,CAAC,EACFvB,IAAA;QACEsB,CAAC,EAAC,wLAAwL;QAC1LF,IAAI,EAAEf,mBAAmB,CAACkB;MAAc,CACzC,CAAC;IAAA,CACC;EAAC,CACqB,CAAC;AAElC,CAAC;AAED,MAAMC,8BAA8B,GAAG5B,IAAI,CAACqB,sBAAsB,CAAC;AACnEO,8BAA8B,CAACC,WAAW,GAAG,wBAAwB;AAErE,SAASD,8BAA8B,IAAIP,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploadPreview.js","names":["memo","useCallback","styled","useTranslation","useOdysseyDesignTokens","DeleteIcon","MuiPropsContext","Tooltip","jsx","_jsx","jsxs","_jsxs","PreviewContainer","div","isDisabled","odysseyDesignTokens","color","TypographyColorDisabled","marginBlockStart","Spacing2","pointerEvents","UploadedFileContainer","display","justifyContent","alignItems","button","transform","padding","Spacing1","borderRadius","BorderRadiusMain","transition","TransitionTimingMain","backgroundColor","HueNeutral100","borderColor","FocusOutlineColorPrimary","boxShadow","outline","FocusOutlineWidthMain","FocusOutlineStyle","UploadedFile","name","onFileRemove","t","deleteHandler","renderDeleteButton","muiProps","_IconButton","onClick","size","children","tabIndex","ariaType","placement","text","Consumer","FileUploadPreview","fileNames","map","index","MemoizedFileUploadPreview","displayName"],"sources":["../../src/FileUploader/FileUploadPreview.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, useCallback } from \"react\";\nimport styled from \"@emotion/styled\";\nimport { IconButton } from \"@mui/material\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { FileUploaderProps } from \"./FileUploader\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { DeleteIcon } from \"../icons.generated\";\nimport { MuiPropsContext, MuiPropsContextType } from \"../MuiPropsContext\";\nimport { Tooltip } from \"../Tooltip\";\n\nconst PreviewContainer = styled.div<{\n isDisabled: FileUploaderProps[\"isDisabled\"];\n odysseyDesignTokens: DesignTokens;\n}>(({ isDisabled, odysseyDesignTokens }) => ({\n color: isDisabled ? odysseyDesignTokens.TypographyColorDisabled : \"inherit\",\n marginBlockStart: odysseyDesignTokens.Spacing2,\n pointerEvents: isDisabled ? \"none\" : \"auto\",\n}));\n\nconst UploadedFileContainer = styled.div<{ odysseyDesignTokens: DesignTokens }>(\n {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n\n button: {\n transform: \"scale(0)\",\n },\n\n \"&:hover, &:focus-within, &:focus\": {\n button: {\n transform: \"scale(1)\",\n },\n },\n },\n ({ odysseyDesignTokens }) => ({\n padding: `${odysseyDesignTokens.Spacing1} ${odysseyDesignTokens.Spacing2}`,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n transition: `background-color ${odysseyDesignTokens.TransitionTimingMain}`,\n\n \"&:hover, &:focus-within\": {\n backgroundColor: odysseyDesignTokens.HueNeutral100,\n },\n\n \"&:focus\": {\n borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,\n boxShadow: `0 0 0 2px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,\n outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,\n },\n }),\n);\n\ntype UploadedFileProps = {\n name: string;\n onFileRemove?: (name: string) => void;\n};\n\nconst UploadedFile = ({ name, onFileRemove }: UploadedFileProps) => {\n const { t } = useTranslation();\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const deleteHandler = useCallback(() => {\n onFileRemove?.(name);\n }, [onFileRemove, name]);\n\n const renderDeleteButton = useCallback(\n (muiProps: MuiPropsContextType) => {\n return (\n <IconButton\n {...muiProps}\n aria-label={t(\"fileupload.removefile.text\")}\n onClick={deleteHandler}\n size=\"small\"\n >\n <DeleteIcon />\n </IconButton>\n );\n },\n [deleteHandler, t],\n );\n\n return (\n <UploadedFileContainer\n // tabindex added to make this element focusable\n tabIndex={0}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {name}\n <Tooltip\n ariaType=\"description\"\n placement=\"top\"\n text={t(\"fileupload.removefile.text\")}\n >\n <MuiPropsContext.Consumer>\n {renderDeleteButton}\n </MuiPropsContext.Consumer>\n </Tooltip>\n </UploadedFileContainer>\n );\n};\n\ntype FileUploadPreviewProps = {\n fileNames: string[];\n isDisabled: FileUploaderProps[\"isDisabled\"];\n onFileRemove?: (name: string) => void;\n};\n\nconst FileUploadPreview = ({\n fileNames,\n isDisabled,\n onFileRemove,\n}: FileUploadPreviewProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n return (\n <PreviewContainer\n data-file-preview-container=\"true\"\n isDisabled={isDisabled}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {fileNames?.map((name, index) => (\n <UploadedFile\n key={`${index}-${name}`}\n onFileRemove={onFileRemove}\n name={name}\n />\n ))}\n </PreviewContainer>\n );\n};\n\nconst MemoizedFileUploadPreview = memo(FileUploadPreview);\nMemoizedFileUploadPreview.displayName = \"FileUploadPreview\";\n\nexport { MemoizedFileUploadPreview as FileUploadPreview };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,EAAEC,WAAW,QAAQ,OAAO;AACzC,OAAOC,MAAM,MAAM,iBAAiB;AAEpC,SAASC,cAAc,QAAQ,eAAe;AAAC,SAI7CC,sBAAsB;AAAA,SAGfC,UAAU;AAAA,SACVC,eAAe;AAAA,SACfC,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEhB,MAAMC,gBAAgB,GAAGV,MAAM,CAACW,GAAG,CAGhC,CAAC;EAAEC,UAAU;EAAEC;AAAoB,CAAC,MAAM;EAC3CC,KAAK,EAAEF,UAAU,GAAGC,mBAAmB,CAACE,uBAAuB,GAAG,SAAS;EAC3EC,gBAAgB,EAAEH,mBAAmB,CAACI,QAAQ;EAC9CC,aAAa,EAAEN,UAAU,GAAG,MAAM,GAAG;AACvC,CAAC,CAAC,CAAC;AAEH,MAAMO,qBAAqB,GAAGnB,MAAM,CAACW,GAAG,CACtC;EACES,OAAO,EAAE,MAAM;EACfC,cAAc,EAAE,eAAe;EAC/BC,UAAU,EAAE,QAAQ;EAEpBC,MAAM,EAAE;IACNC,SAAS,EAAE;EACb,CAAC;EAED,kCAAkC,EAAE;IAClCD,MAAM,EAAE;MACNC,SAAS,EAAE;IACb;EACF;AACF,CAAC,EACD,CAAC;EAAEX;AAAoB,CAAC,MAAM;EAC5BY,OAAO,EAAG,GAAEZ,mBAAmB,CAACa,QAAS,IAAGb,mBAAmB,CAACI,QAAS,EAAC;EAC1EU,YAAY,EAAEd,mBAAmB,CAACe,gBAAgB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,4BAA4B,CAAE;MAAAO,QAAA,EAEtC1C,IAAA,CAACH,eAAe,CAACkD,QAAQ;QAAAL,QAAA,EACtBL;MAAkB,CACK;IAAC,CACpB,CAAC;EAAA,CACW,CAAC;AAE5B,CAAC;AAQD,MAAMW,iBAAiB,GAAGA,CAAC;EACzBC,SAAS;EACT5C,UAAU;EACV6B;AACsB,CAAC,KAAK;EAC5B,MAAM5B,mBAAmB,GAAGX,sBAAsB,CAAC,CAAC;EAEpD,OACEK,IAAA,CAACG,gBAAgB;IACf,+BAA4B,MAAM;IAClCE,UAAU,EAAEA,UAAW;IACvBC,mBAAmB,EAAEA,mBAAoB;IAAAoC,QAAA,EAExCO,SAAS,EAAEC,GAAG,CAAC,CAACjB,IAAI,EAAEkB,KAAK,KAC1BnD,IAAA,CAACgC,YAAY;MAEXE,YAAY,EAAEA,YAAa;MAC3BD,IAAI,EAAEA;IAAK,GAFL,GAAEkB,KAAM,IAAGlB,IAAK,EAGvB,CACF;EAAC,CACc,CAAC;AAEvB,CAAC;AAED,MAAMmB,yBAAyB,GAAG7D,IAAI,CAACyD,iBAAiB,CAAC;AACzDI,yBAAyB,CAACC,WAAW,GAAG,mBAAmB;AAE3D,SAASD,yBAAyB,IAAIJ,iBAAiB"}
|
|
@@ -78,7 +78,7 @@ const ButtonAndInfoContainer = styled.div({
|
|
|
78
78
|
const CenterAlignedSupportText = styled.div({
|
|
79
79
|
textAlign: "center"
|
|
80
80
|
});
|
|
81
|
-
const
|
|
81
|
+
const FileUploader = ({
|
|
82
82
|
acceptedFileTypes,
|
|
83
83
|
errorMessage,
|
|
84
84
|
id,
|
|
@@ -192,7 +192,8 @@ const FileUpload = ({
|
|
|
192
192
|
})]
|
|
193
193
|
});
|
|
194
194
|
};
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
export {
|
|
198
|
-
|
|
195
|
+
const MemoizedFileUploader = memo(FileUploader);
|
|
196
|
+
MemoizedFileUploader.displayName = "FileUploader";
|
|
197
|
+
export { MemoizedFileUploader as FileUpload };
|
|
198
|
+
export { MemoizedFileUploader as FileUploader };
|
|
199
|
+
//# sourceMappingURL=FileUploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUploader.js","names":["memo","useCallback","useEffect","useRef","useState","styled","useTranslation","Button","UploadIcon","Field","FileUploadPreview","FileUploadIllustration","useOdysseyDesignTokens","Support","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","fileUploadTypes","fileUploadVariants","BaseInputWrapper","div","position","alignSelf","input","width","height","opacity","InputContainer","display","alignItems","justifyContent","borderStyle","hasError","odysseyDesignTokens","padding","Spacing6","Spacing3","border","PaletteDangerMain","HueNeutral300","borderRadius","BorderRadiusMain","transition","TransitionTimingMain","borderColor","HueNeutral700","FocusOutlineColorPrimary","boxShadow","outline","FocusOutlineWidthMain","FocusOutlineStyle","outlineOffset","FocusOutlineOffsetTight","backgroundColor","HueNeutral50","BorderColorDisabled","color","TypographyColorDisabled","ButtonAndInfoContainer","flexDirection","CenterAlignedSupportText","textAlign","FileUploader","acceptedFileTypes","errorMessage","id","isDisabled","isFullWidth","isOptional","hint","HintLinkComponent","label","onChange","type","variant","t","inputRef","filesToUpload","setFilesToUpload","updateFilesToUpload","event","files","target","length","mergedFiles","value","triggerFileInputClick","current","click","removeFileFromFilesToUploadList","name","deletedFileFilteredOut","filter","file","renderFileInput","ariaDescribedBy","errorMessageElementId","labelElementId","acceptedFileTypesAsString","join","Input","accept","disabled","multiple","ref","title","children","onClick","startIcon","Boolean","fieldType","hasVisibleLabel","renderFieldComponent","fileNames","map","onFileRemove","MemoizedFileUploader","displayName","FileUpload"],"sources":["../../src/FileUploader/FileUploader.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 ChangeEvent,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { Button } from \"../Button\";\nimport { UploadIcon } from \"../icons.generated\";\nimport { Field, RenderFieldComponentProps } from \"../Field\";\nimport { FieldComponentProps } from \"../FieldComponentProps\";\nimport { FileUploadPreview } from \"./FileUploadPreview\";\nimport { FileUploadIllustration } from \"./FileUploadIllustration\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../OdysseyDesignTokensContext\";\nimport { Support } from \"../Typography\";\n\nexport const fileUploadTypes = [\"single\", \"multiple\"] as const;\nexport const fileUploadVariants = [\n \"button\",\n \"dragAndDrop\",\n \"dragAndDropWithIcon\",\n] as const;\n\nconst BaseInputWrapper = styled.div({\n position: \"relative\",\n alignSelf: \"flex-start\",\n\n input: {\n position: \"absolute\",\n width: \"100%\",\n height: \"100%\",\n opacity: 0,\n },\n});\n\nconst InputContainer = styled(BaseInputWrapper)<{\n odysseyDesignTokens: DesignTokens;\n hasError: boolean;\n}>(\n {\n display: \"flex\",\n alignSelf: \"unset\",\n alignItems: \"center\",\n justifyContent: \"center\",\n\n \"&:has(input:focus)\": {\n borderStyle: \"solid\",\n },\n },\n ({ hasError, odysseyDesignTokens }) => ({\n padding: `${odysseyDesignTokens.Spacing6} ${odysseyDesignTokens.Spacing3}`,\n border: hasError\n ? `1px solid ${odysseyDesignTokens.PaletteDangerMain}`\n : `1px dashed ${odysseyDesignTokens.HueNeutral300}`,\n borderRadius: odysseyDesignTokens.BorderRadiusMain,\n transition: `border-color ${odysseyDesignTokens.TransitionTimingMain}, box-shadow ${odysseyDesignTokens.TransitionTimingMain}`,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.HueNeutral700,\n },\n\n \"&:has(input:focus)\": {\n borderColor: odysseyDesignTokens.FocusOutlineColorPrimary,\n boxShadow: `0 0 0 1px ${odysseyDesignTokens.FocusOutlineColorPrimary}`,\n outline: `${odysseyDesignTokens.FocusOutlineWidthMain} ${odysseyDesignTokens.FocusOutlineStyle} transparent`,\n outlineOffset: odysseyDesignTokens.FocusOutlineOffsetTight,\n },\n\n \"&:has(input:disabled)\": {\n backgroundColor: odysseyDesignTokens.HueNeutral50,\n border: `1px solid ${odysseyDesignTokens.BorderColorDisabled}`,\n color: odysseyDesignTokens.TypographyColorDisabled,\n\n \"&:hover\": {\n borderColor: odysseyDesignTokens.BorderColorDisabled,\n },\n },\n }),\n);\n\nconst ButtonAndInfoContainer = styled.div({\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n justifyContent: \"center\",\n});\n\nconst CenterAlignedSupportText = styled.div({\n textAlign: \"center\",\n});\n\nexport type FileUploaderProps = {\n /**\n * an array of file types the user is able to upload. @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers for examples\n */\n acceptedFileTypes?: string[];\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * Function that is called when the list of ifles to upload is changed\n */\n onChange: (files: File[]) => void;\n /**\n * Either `single` or `multiple`. If `multiple`, multiple files can be uploaded\n */\n type?: (typeof fileUploadTypes)[number];\n /**\n * Either `button`, `dragAndDrop` or `dragAndDropWithIcon`. Will determine how component appears visually\n */\n variant: (typeof fileUploadVariants)[number];\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n>;\n\nconst FileUploader = ({\n acceptedFileTypes,\n errorMessage,\n id,\n isDisabled = false,\n isFullWidth,\n isOptional,\n hint,\n HintLinkComponent,\n label,\n onChange,\n type,\n variant,\n}: FileUploaderProps) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n const { t } = useTranslation();\n const inputRef = useRef<HTMLInputElement>(null);\n const [filesToUpload, setFilesToUpload] = useState<File[]>([]);\n\n useEffect(() => {\n onChange(filesToUpload);\n }, [filesToUpload, onChange]);\n\n const updateFilesToUpload = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const { files } = event.target;\n\n if (files && files.length > 0) {\n const mergedFiles =\n type === \"multiple\"\n ? [...filesToUpload, ...files]\n : ([...files] satisfies File[] as File[]);\n\n setFilesToUpload(mergedFiles);\n }\n\n // reset input value to allow re-upload of a file with the same name\n event.target.value = \"\";\n },\n [type, filesToUpload],\n );\n\n const triggerFileInputClick = useCallback(() => {\n inputRef.current?.click();\n }, [inputRef]);\n\n const removeFileFromFilesToUploadList = useCallback<(name: string) => void>(\n (name) => {\n const deletedFileFilteredOut = filesToUpload.filter(\n (file) => file.name !== name,\n );\n setFilesToUpload(deletedFileFilteredOut);\n },\n [filesToUpload],\n );\n\n const renderFileInput = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: RenderFieldComponentProps) => {\n const acceptedFileTypesAsString = acceptedFileTypes?.join(\",\");\n\n const Input = () => (\n <input\n accept={acceptedFileTypesAsString}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n aria-labelledby={labelElementId}\n disabled={isDisabled}\n id={id}\n multiple={type === \"multiple\"}\n onChange={updateFilesToUpload}\n ref={inputRef}\n title=\"\"\n type=\"file\"\n />\n );\n\n if (variant === \"button\") {\n return (\n <>\n <BaseInputWrapper>\n <Input />\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </BaseInputWrapper>\n </>\n );\n }\n\n return (\n <>\n <InputContainer\n hasError={Boolean(errorMessage)}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Input />\n <ButtonAndInfoContainer>\n {variant === \"dragAndDropWithIcon\" && <FileUploadIllustration />}\n <CenterAlignedSupportText>\n <Support color=\"textSecondary\">\n {t(\"fileupload.prompt.text\")}\n </Support>\n </CenterAlignedSupportText>\n <Button\n isDisabled={isDisabled}\n label={t(\"fileupload.button.text\")}\n onClick={triggerFileInputClick}\n startIcon={<UploadIcon />}\n variant=\"secondary\"\n />\n </ButtonAndInfoContainer>\n </InputContainer>\n </>\n );\n },\n [\n acceptedFileTypes,\n errorMessage,\n isDisabled,\n inputRef,\n odysseyDesignTokens,\n triggerFileInputClick,\n t,\n type,\n updateFilesToUpload,\n variant,\n ],\n );\n\n return (\n <>\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={id}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth && variant !== \"button\"}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFileInput}\n />\n {filesToUpload.length > 0 && (\n <FileUploadPreview\n fileNames={filesToUpload.map((file) => file.name)}\n onFileRemove={removeFileFromFilesToUploadList}\n isDisabled={isDisabled}\n />\n )}\n </>\n );\n};\n\nconst MemoizedFileUploader = memo(FileUploader);\nMemoizedFileUploader.displayName = \"FileUploader\";\n\nexport { MemoizedFileUploader as FileUpload };\nexport { MemoizedFileUploader as FileUploader };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EAEJC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,cAAc,QAAQ,eAAe;AAAC,SAEtCC,MAAM;AAAA,SACNC,UAAU;AAAA,SACVC,KAAK;AAAA,SAELC,iBAAiB;AAAA,SACjBC,sBAAsB;AAAA,SAE7BC,sBAAsB;AAAA,SAGfC,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA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AAC;UAAW,CACpB,CAAC;QAAA,CACoB,CAAC;MAAA,CACX;IAAC,CACjB,CAAC;EAEP,CAAC,EACD,CACEX,iBAAiB,EACjBC,YAAY,EACZE,UAAU,EACVU,QAAQ,EACR3C,mBAAmB,EACnBqD,qBAAqB,EACrBX,CAAC,EACDF,IAAI,EACJM,mBAAmB,EACnBL,OAAO,CAEX,CAAC;EAED,OACE5D,KAAA,CAAAE,SAAA;IAAA0F,QAAA,GACE9F,IAAA,CAACN,KAAK;MACJ0D,YAAY,EAAEA,YAAa;MAC3B8C,SAAS,EAAC,QAAQ;MAClBC,eAAe;MACf1C,IAAI,EAAEA,IAAK;MACXC,iBAAiB,EAAEA,iBAAkB;MACrCL,EAAE,EAAEA,EAAG;MACPC,UAAU,EAAEA,UAAW;MACvBC,WAAW,EAAEA,WAAW,IAAIO,OAAO,KAAK,QAAS;MACjDN,UAAU,EAAEA,UAAW;MACvBG,KAAK,EAAEA,KAAM;MACbyC,oBAAoB,EAAElB;IAAgB,CACvC,CAAC,EACDjB,aAAa,CAACM,MAAM,GAAG,CAAC,IACvBvE,IAAA,CAACL,iBAAiB;MAChB0G,SAAS,EAAEpC,aAAa,CAACqC,GAAG,CAAErB,IAAI,IAAKA,IAAI,CAACH,IAAI,CAAE;MAClDyB,YAAY,EAAE1B,+BAAgC;MAC9CvB,UAAU,EAAEA;IAAW,CACxB,CACF;EAAA,CACD,CAAC;AAEP,CAAC;AAED,MAAMkD,oBAAoB,GAAGvH,IAAI,CAACiE,YAAY,CAAC;AAC/CsD,oBAAoB,CAACC,WAAW,GAAG,cAAc;AAEjD,SAASD,oBAAoB,IAAIE,UAAU;AAC3C,SAASF,oBAAoB,IAAItD,YAAY"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
3
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
4
|
+
*
|
|
5
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
8
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
9
|
+
*
|
|
10
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from "./FileUploader.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/FileUploader/index.ts"],"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\nexport * from \"./FileUploader\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVA"}
|
package/dist/OdysseyProvider.js
CHANGED
|
@@ -16,6 +16,9 @@ import { OdysseyCacheProvider } from "./OdysseyCacheProvider.js";
|
|
|
16
16
|
import { OdysseyThemeProvider } from "./OdysseyThemeProvider.js";
|
|
17
17
|
import { OdysseyTranslationProvider } from "./OdysseyTranslationProvider.js";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const scopedCssBaselineStyles = {
|
|
20
|
+
height: "inherit"
|
|
21
|
+
};
|
|
19
22
|
const OdysseyProvider = ({
|
|
20
23
|
children,
|
|
21
24
|
designTokensOverride,
|
|
@@ -39,6 +42,7 @@ const OdysseyProvider = ({
|
|
|
39
42
|
shadowRootElement: shadowRootElement || shadowDomElement,
|
|
40
43
|
themeOverride: themeOverride,
|
|
41
44
|
children: _jsx(_ScopedCssBaseline, {
|
|
45
|
+
sx: scopedCssBaselineStyles,
|
|
42
46
|
children: _jsx(OdysseyTranslationProvider, {
|
|
43
47
|
languageCode: languageCode,
|
|
44
48
|
translationOverrides: translationOverrides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","OdysseyProvider","children","designTokensOverride","emotionRoot","emotionRootElement","shadowDomElement","shadowRootElement","languageCode","nonce","stylisPlugins","themeOverride","translationOverrides","hasShadowDom","Boolean","_ScopedCssBaseline","MemoizedThemeProvider"],"sources":["../src/OdysseyProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, ReactNode } from \"react\";\nimport { ScopedCssBaseline } from \"@mui/material\";\n\nimport {\n OdysseyCacheProvider,\n OdysseyCacheProviderProps,\n} from \"./OdysseyCacheProvider\";\nimport {\n OdysseyThemeProvider,\n OdysseyThemeProviderProps,\n} from \"./OdysseyThemeProvider\";\nimport {\n OdysseyTranslationProvider,\n OdysseyTranslationProviderProps,\n} from \"./OdysseyTranslationProvider\";\nimport { DefaultSupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nexport type OdysseyProviderProps<\n SupportedLanguages extends string = DefaultSupportedLanguages,\n> = OdysseyCacheProviderProps &\n OdysseyThemeProviderProps &\n OdysseyTranslationProviderProps<SupportedLanguages> & {\n children: ReactNode;\n };\n\nconst OdysseyProvider = <SupportedLanguages extends string>({\n children,\n designTokensOverride,\n emotionRoot,\n emotionRootElement,\n shadowDomElement,\n shadowRootElement,\n languageCode,\n nonce,\n stylisPlugins,\n themeOverride,\n translationOverrides,\n}: OdysseyProviderProps<SupportedLanguages>) => (\n <OdysseyCacheProvider\n emotionRoot={emotionRoot}\n emotionRootElement={emotionRootElement}\n hasShadowDom={Boolean(shadowRootElement || shadowDomElement)}\n nonce={nonce}\n stylisPlugins={stylisPlugins}\n >\n <OdysseyThemeProvider\n designTokensOverride={designTokensOverride}\n shadowRootElement={shadowRootElement || shadowDomElement}\n themeOverride={themeOverride}\n >\n <ScopedCssBaseline>\n <OdysseyTranslationProvider<SupportedLanguages>\n languageCode={languageCode}\n translationOverrides={translationOverrides}\n >\n {children}\n </OdysseyTranslationProvider>\n </ScopedCssBaseline>\n </OdysseyThemeProvider>\n </OdysseyCacheProvider>\n);\n\nconst MemoizedThemeProvider = memo(OdysseyProvider) as typeof OdysseyProvider;\n\nexport { MemoizedThemeProvider as OdysseyProvider };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAmB,OAAO;AAAC,SAItCC,oBAAoB;AAAA,SAIpBC,oBAAoB;AAAA,SAIpBC,0BAA0B;AAAA,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","scopedCssBaselineStyles","height","OdysseyProvider","children","designTokensOverride","emotionRoot","emotionRootElement","shadowDomElement","shadowRootElement","languageCode","nonce","stylisPlugins","themeOverride","translationOverrides","hasShadowDom","Boolean","_ScopedCssBaseline","sx","MemoizedThemeProvider"],"sources":["../src/OdysseyProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { memo, ReactNode } from \"react\";\nimport { ScopedCssBaseline } from \"@mui/material\";\n\nimport {\n OdysseyCacheProvider,\n OdysseyCacheProviderProps,\n} from \"./OdysseyCacheProvider\";\nimport {\n OdysseyThemeProvider,\n OdysseyThemeProviderProps,\n} from \"./OdysseyThemeProvider\";\nimport {\n OdysseyTranslationProvider,\n OdysseyTranslationProviderProps,\n} from \"./OdysseyTranslationProvider\";\nimport { DefaultSupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nconst scopedCssBaselineStyles = {\n height: \"inherit\",\n};\n\nexport type OdysseyProviderProps<\n SupportedLanguages extends string = DefaultSupportedLanguages,\n> = OdysseyCacheProviderProps &\n OdysseyThemeProviderProps &\n OdysseyTranslationProviderProps<SupportedLanguages> & {\n children: ReactNode;\n };\n\nconst OdysseyProvider = <SupportedLanguages extends string>({\n children,\n designTokensOverride,\n emotionRoot,\n emotionRootElement,\n shadowDomElement,\n shadowRootElement,\n languageCode,\n nonce,\n stylisPlugins,\n themeOverride,\n translationOverrides,\n}: OdysseyProviderProps<SupportedLanguages>) => (\n <OdysseyCacheProvider\n emotionRoot={emotionRoot}\n emotionRootElement={emotionRootElement}\n hasShadowDom={Boolean(shadowRootElement || shadowDomElement)}\n nonce={nonce}\n stylisPlugins={stylisPlugins}\n >\n <OdysseyThemeProvider\n designTokensOverride={designTokensOverride}\n shadowRootElement={shadowRootElement || shadowDomElement}\n themeOverride={themeOverride}\n >\n {/* This component creates a div; for flexibility of layout of children, make it inherit its parent's height */}\n <ScopedCssBaseline sx={scopedCssBaselineStyles}>\n <OdysseyTranslationProvider<SupportedLanguages>\n languageCode={languageCode}\n translationOverrides={translationOverrides}\n >\n {children}\n </OdysseyTranslationProvider>\n </ScopedCssBaseline>\n </OdysseyThemeProvider>\n </OdysseyCacheProvider>\n);\n\nconst MemoizedThemeProvider = memo(OdysseyProvider) as typeof OdysseyProvider;\n\nexport { MemoizedThemeProvider as OdysseyProvider };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAmB,OAAO;AAAC,SAItCC,oBAAoB;AAAA,SAIpBC,oBAAoB;AAAA,SAIpBC,0BAA0B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAK5B,MAAMC,uBAAuB,GAAG;EAC9BC,MAAM,EAAE;AACV,CAAC;AAUD,MAAMC,eAAe,GAAGA,CAAoC;EAC1DC,QAAQ;EACRC,oBAAoB;EACpBC,WAAW;EACXC,kBAAkB;EAClBC,gBAAgB;EAChBC,iBAAiB;EACjBC,YAAY;EACZC,KAAK;EACLC,aAAa;EACbC,aAAa;EACbC;AACwC,CAAC,KACzCd,IAAA,CAACJ,oBAAoB;EACnBU,WAAW,EAAEA,WAAY;EACzBC,kBAAkB,EAAEA,kBAAmB;EACvCQ,YAAY,EAAEC,OAAO,CAACP,iBAAiB,IAAID,gBAAgB,CAAE;EAC7DG,KAAK,EAAEA,KAAM;EACbC,aAAa,EAAEA,aAAc;EAAAR,QAAA,EAE7BJ,IAAA,CAACH,oBAAoB;IACnBQ,oBAAoB,EAAEA,oBAAqB;IAC3CI,iBAAiB,EAAEA,iBAAiB,IAAID,gBAAiB;IACzDK,aAAa,EAAEA,aAAc;IAAAT,QAAA,EAG7BJ,IAAA,CAAAiB,kBAAA;MAAmBC,EAAE,EAAEjB,uBAAwB;MAAAG,QAAA,EAC7CJ,IAAA,CAACF,0BAA0B;QACzBY,YAAY,EAAEA,YAAa;QAC3BI,oBAAoB,EAAEA,oBAAqB;QAAAV,QAAA,EAE1CA;MAAQ,CACiB;IAAC,CACZ;EAAC,CACA;AAAC,CACH,CACvB;AAED,MAAMe,qBAAqB,GAAGxB,IAAI,CAACQ,eAAe,CAA2B;AAE7E,SAASgB,qBAAqB,IAAIhB,eAAe"}
|
package/dist/Radio.js
CHANGED
|
@@ -21,14 +21,14 @@ const Radio = ({
|
|
|
21
21
|
hint,
|
|
22
22
|
inputRef,
|
|
23
23
|
isChecked,
|
|
24
|
-
isDisabled
|
|
24
|
+
isDisabled,
|
|
25
25
|
isInvalid,
|
|
26
26
|
label: labelProp,
|
|
27
27
|
name,
|
|
28
28
|
testId,
|
|
29
29
|
translate,
|
|
30
30
|
value,
|
|
31
|
-
isReadOnly
|
|
31
|
+
isReadOnly,
|
|
32
32
|
onChange: onChangeProp,
|
|
33
33
|
onBlur: onBlurProp,
|
|
34
34
|
onClick
|