@okta/odyssey-react-mui 1.1.1 → 1.2.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 +22 -0
- package/dist/Autocomplete.js +12 -1
- package/dist/Autocomplete.js.map +1 -1
- package/dist/OdysseyCacheProvider.js +4 -1
- package/dist/OdysseyCacheProvider.js.map +1 -1
- package/dist/OdysseyProvider.js +5 -1
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/OdysseyThemeProvider.js +5 -1
- package/dist/OdysseyThemeProvider.js.map +1 -1
- package/dist/OdysseyTranslationProvider.js +1 -1
- package/dist/OdysseyTranslationProvider.js.map +1 -1
- package/dist/PasswordField.js +11 -3
- package/dist/PasswordField.js.map +1 -1
- package/dist/Select.js +34 -33
- package/dist/Select.js.map +1 -1
- package/dist/Typography.js +0 -22
- package/dist/Typography.js.map +1 -1
- package/dist/createShadowDom.js +26 -0
- package/dist/createShadowDom.js.map +1 -0
- package/dist/{OdysseyI18n.js → i18n.js} +3 -2
- package/dist/i18n.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/labs/datePickerTheme.js +4 -2
- package/dist/labs/datePickerTheme.js.map +1 -1
- package/dist/properties/ts/odyssey-react-mui.js +2 -0
- package/dist/properties/ts/odyssey-react-mui.js.map +1 -1
- package/dist/src/Autocomplete.d.ts +23 -3
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/OdysseyCacheProvider.d.ts +6 -1
- package/dist/src/OdysseyCacheProvider.d.ts.map +1 -1
- package/dist/src/OdysseyProvider.d.ts +1 -1
- package/dist/src/OdysseyProvider.d.ts.map +1 -1
- package/dist/src/OdysseyThemeProvider.d.ts +2 -1
- package/dist/src/OdysseyThemeProvider.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 +8 -0
- package/dist/src/PasswordField.d.ts.map +1 -1
- package/dist/src/Select.d.ts +1 -54
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/Typography.d.ts +11 -15
- package/dist/src/Typography.d.ts.map +1 -1
- package/dist/src/createShadowDom.d.ts +16 -0
- package/dist/src/createShadowDom.d.ts.map +1 -0
- package/dist/src/{OdysseyI18n.d.ts → i18n.d.ts} +5 -2
- package/dist/src/i18n.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/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/theme/components.d.ts +4 -1
- package/dist/src/theme/components.d.ts.map +1 -1
- package/dist/src/theme/createOdysseyMuiTheme.d.ts +23 -0
- package/dist/src/theme/createOdysseyMuiTheme.d.ts.map +1 -0
- package/dist/src/theme/mixins.d.ts +3 -1
- package/dist/src/theme/mixins.d.ts.map +1 -1
- package/dist/src/theme/palette.d.ts +3 -1
- package/dist/src/theme/palette.d.ts.map +1 -1
- package/dist/src/theme/shape.d.ts +3 -1
- package/dist/src/theme/shape.d.ts.map +1 -1
- package/dist/src/theme/spacing.d.ts +3 -1
- package/dist/src/theme/spacing.d.ts.map +1 -1
- package/dist/src/theme/theme.d.ts +1 -8
- package/dist/src/theme/theme.d.ts.map +1 -1
- package/dist/src/theme/typography.d.ts +3 -1
- package/dist/src/theme/typography.d.ts.map +1 -1
- package/dist/theme/components.js +80 -63
- package/dist/theme/components.js.map +1 -1
- package/dist/theme/createOdysseyMuiTheme.js +51 -0
- package/dist/theme/createOdysseyMuiTheme.js.map +1 -0
- package/dist/theme/mixins.js +4 -1
- package/dist/theme/mixins.js.map +1 -1
- package/dist/theme/palette.js +4 -1
- package/dist/theme/palette.js.map +1 -1
- package/dist/theme/shape.js +4 -1
- package/dist/theme/shape.js.map +1 -1
- package/dist/theme/spacing.js +4 -1
- package/dist/theme/spacing.js.map +1 -1
- package/dist/theme/theme.js +1 -20
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/typography.js +4 -1
- package/dist/theme/typography.js.map +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/Autocomplete.tsx +44 -3
- package/src/OdysseyCacheProvider.tsx +9 -1
- package/src/OdysseyProvider.tsx +9 -2
- package/src/OdysseyThemeProvider.tsx +8 -2
- package/src/OdysseyTranslationProvider.test.tsx +2 -2
- package/src/OdysseyTranslationProvider.tsx +1 -1
- package/src/PasswordField.tsx +24 -8
- package/src/Select.tsx +147 -152
- package/src/Typography.tsx +0 -26
- package/src/createShadowDom.ts +46 -0
- package/src/{OdysseyI18n.ts → i18n.ts} +2 -2
- package/src/index.ts +1 -0
- package/src/labs/datePickerTheme.tsx +2 -2
- package/src/properties/odyssey-react-mui.properties +2 -0
- package/src/properties/ts/odyssey-react-mui.ts +1 -1
- package/src/theme/components.tsx +26 -9
- package/src/theme/createOdysseyMuiTheme.ts +47 -0
- package/src/theme/mixins.ts +5 -1
- package/src/theme/palette.ts +5 -3
- package/src/theme/shape.ts +5 -1
- package/src/theme/spacing.ts +5 -3
- package/src/theme/theme.ts +1 -26
- package/src/theme/typography.ts +5 -3
- package/dist/OdysseyI18n.js.map +0 -1
- package/dist/src/OdysseyI18n.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.2.0](https://github.com/okta/odyssey/compare/v1.1.1...v1.2.0) (2023-09-29)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- adds ability to use Shadow DOM with Odyssey ([#1966](https://github.com/okta/odyssey/issues/1966)) ([6b52246](https://github.com/okta/odyssey/commit/6b5224662982d7e214457292d0ab168719dc8c29))
|
|
11
|
+
- hide selected Autocomplete items ([#1984](https://github.com/okta/odyssey/issues/1984)) ([11aa9ee](https://github.com/okta/odyssey/commit/11aa9ee0211e7f5b2c2512d77ee7efd8b4c7426e))
|
|
12
|
+
- **odyssey-react-mui:** adding new prop for PasswordField to control show password button ([58ad6c8](https://github.com/okta/odyssey/commit/58ad6c8027d963a557fc501acba7ebc5724e2410))
|
|
13
|
+
- **odyssey-react-mui:** renamed prop to hasShowPassword and changed default to true ([6c3b8d2](https://github.com/okta/odyssey/commit/6c3b8d2d8486afbee6869a12c5320f2ea152dc5a))
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- id and name not changing in Storybook ([#1987](https://github.com/okta/odyssey/issues/1987)) ([2f57e15](https://github.com/okta/odyssey/commit/2f57e156f27c64954e8aa39662198d9c04ff9518))
|
|
18
|
+
- **odyssey-react-mui:** add mising prop errorMessage to autocomplete ([1c1360c](https://github.com/okta/odyssey/commit/1c1360cd33f74b5d91f961ed859ab0972633995d))
|
|
19
|
+
- **odyssey-react-mui:** add props onBlur, onFocus, id, name ([66ad838](https://github.com/okta/odyssey/commit/66ad838821ba18c3ee4c24f729b89c76eb62df3e))
|
|
20
|
+
- **odyssey-react-mui:** address PR comments ([f10a903](https://github.com/okta/odyssey/commit/f10a903cece4f873f91a588b3b603d96b6055eb1))
|
|
21
|
+
- **odyssey-react-mui:** fixing issue with t function type by upgrading package ([c0b8343](https://github.com/okta/odyssey/commit/c0b834326afda7e42aacb64af174def159c31e90))
|
|
22
|
+
- **odyssey-react-mui:** fixing tests to use getByRole and canvas ([cd7feed](https://github.com/okta/odyssey/commit/cd7feed17147397e5f79eed31e31d59ee17f562d))
|
|
23
|
+
- **odyssey-react-mui:** localizing the aria-label for the PasswordField component ([e9d332a](https://github.com/okta/odyssey/commit/e9d332a5f691742609533e679bb58d7f910c9a1b))
|
|
24
|
+
- **odyssey-react-mui:** toggle aria label based on password ([405fd71](https://github.com/okta/odyssey/commit/405fd7155d8ac9bb5b697bbb8b4dad3c021a0e63))
|
|
25
|
+
- **odyssey-react-mui:** updating descriptions for props ([12b9587](https://github.com/okta/odyssey/commit/12b9587cda9058ff00180e0cc7b2bcb4debeb27f))
|
|
26
|
+
- removed classes prop from Typography components ([#1989](https://github.com/okta/odyssey/issues/1989)) ([889f369](https://github.com/okta/odyssey/commit/889f3697582da68f71f2db801c1e7702a29fd9f5))
|
|
27
|
+
|
|
6
28
|
## [1.1.1](https://github.com/okta/odyssey/compare/v1.1.0...v1.1.1) (2023-09-15)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @okta/odyssey-react-mui
|
package/dist/Autocomplete.js
CHANGED
|
@@ -16,7 +16,9 @@ import { Field } from "./Field.js";
|
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
const Autocomplete = _ref => {
|
|
18
18
|
let {
|
|
19
|
+
errorMessage,
|
|
19
20
|
hasMultipleChoices,
|
|
21
|
+
id: idOverride,
|
|
20
22
|
isCustomValueAllowed,
|
|
21
23
|
isDisabled,
|
|
22
24
|
isLoading,
|
|
@@ -24,8 +26,11 @@ const Autocomplete = _ref => {
|
|
|
24
26
|
isReadOnly,
|
|
25
27
|
hint,
|
|
26
28
|
label,
|
|
29
|
+
name: nameOverride,
|
|
30
|
+
onBlur,
|
|
27
31
|
onChange,
|
|
28
32
|
onInputChange,
|
|
33
|
+
onFocus,
|
|
29
34
|
options,
|
|
30
35
|
value,
|
|
31
36
|
testId
|
|
@@ -37,6 +42,7 @@ const Autocomplete = _ref => {
|
|
|
37
42
|
...params
|
|
38
43
|
} = _ref2;
|
|
39
44
|
return _jsx(Field, {
|
|
45
|
+
errorMessage: errorMessage,
|
|
40
46
|
fieldType: "single",
|
|
41
47
|
hasVisibleLabel: true,
|
|
42
48
|
id: InputLabelProps.htmlFor,
|
|
@@ -53,21 +59,26 @@ const Autocomplete = _ref => {
|
|
|
53
59
|
...InputProps,
|
|
54
60
|
"aria-describedby": ariaDescribedBy,
|
|
55
61
|
id: id,
|
|
62
|
+
name: nameOverride ?? id,
|
|
56
63
|
required: !isOptional
|
|
57
64
|
});
|
|
58
65
|
}
|
|
59
66
|
});
|
|
60
|
-
}, [hint, isOptional, label]);
|
|
67
|
+
}, [errorMessage, hint, isOptional, label, nameOverride]);
|
|
61
68
|
return _jsx(_Autocomplete, {
|
|
62
69
|
"aria-disabled": isDisabled,
|
|
63
70
|
"data-se": testId,
|
|
64
71
|
disableCloseOnSelect: hasMultipleChoices,
|
|
65
72
|
disabled: isDisabled,
|
|
66
73
|
freeSolo: isCustomValueAllowed,
|
|
74
|
+
filterSelectedOptions: true,
|
|
75
|
+
id: idOverride,
|
|
67
76
|
loading: isLoading,
|
|
68
77
|
multiple: hasMultipleChoices,
|
|
78
|
+
onBlur: onBlur,
|
|
69
79
|
onChange: onChange,
|
|
70
80
|
onInputChange: onInputChange,
|
|
81
|
+
onFocus: onFocus,
|
|
71
82
|
options: options,
|
|
72
83
|
readOnly: isReadOnly,
|
|
73
84
|
renderInput: renderInput,
|
package/dist/Autocomplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.js","names":["memo","useCallback","Field","jsx","_jsx","Autocomplete","_ref","hasMultipleChoices","isCustomValueAllowed","isDisabled","isLoading","isOptional","isReadOnly","hint","label","onChange","onInputChange","options","value","testId","renderInput","_ref2","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","
|
|
1
|
+
{"version":3,"file":"Autocomplete.js","names":["memo","useCallback","Field","jsx","_jsx","Autocomplete","_ref","errorMessage","hasMultipleChoices","id","idOverride","isCustomValueAllowed","isDisabled","isLoading","isOptional","isReadOnly","hint","label","name","nameOverride","onBlur","onChange","onInputChange","onFocus","options","value","testId","renderInput","_ref2","InputLabelProps","InputProps","params","fieldType","hasVisibleLabel","htmlFor","renderFieldComponent","_ref3","ariaDescribedBy","_InputBase","required","_Autocomplete","disableCloseOnSelect","disabled","freeSolo","filterSelectedOptions","loading","multiple","readOnly","MemoizedAutocomplete"],"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} from \"@mui/material\";\nimport { memo, useCallback } from \"react\";\n\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type AutocompleteProps<\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n> = {\n /**\n * The error message for the Select\n */\n errorMessage?: string;\n /**\n * Enables multiple choice selection\n */\n hasMultipleChoices?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"multiple\"];\n /**\n * The hint text for the Autocomplete input\n */\n hint?: string;\n /**\n * The id attribute of the Select\n */\n id?: string;\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 * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\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 name of the `input` element. Defaults to the `id` if not set.\n */\n name?: 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?: MuiAutocompleteProps<\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: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"options\"];\n /**\n * The value of the Autocomplete input\n */\n value?: MuiAutocompleteProps<\n OptionType,\n HasMultipleChoices,\n undefined,\n IsCustomValueAllowed\n >[\"value\"];\n} & SeleniumProps;\n\nconst Autocomplete = <\n OptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined\n>({\n errorMessage,\n hasMultipleChoices,\n id: idOverride,\n isCustomValueAllowed,\n isDisabled,\n isLoading,\n isOptional = false,\n isReadOnly,\n hint,\n label,\n name: nameOverride,\n onBlur,\n onChange,\n onInputChange,\n onFocus,\n options,\n value,\n testId,\n}: AutocompleteProps<OptionType, HasMultipleChoices, IsCustomValueAllowed>) => {\n const renderInput = useCallback(\n ({ InputLabelProps, InputProps, ...params }) => (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n id={InputLabelProps.htmlFor}\n hint={hint}\n label={label}\n isOptional={isOptional}\n renderFieldComponent={({ ariaDescribedBy, id }) => (\n <InputBase\n {...params}\n {...InputProps}\n aria-describedby={ariaDescribedBy}\n id={id}\n name={nameOverride ?? id}\n required={!isOptional}\n />\n )}\n />\n ),\n [errorMessage, hint, isOptional, label, nameOverride]\n );\n\n return (\n <MuiAutocomplete\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 data-se={testId}\n disableCloseOnSelect={hasMultipleChoices}\n disabled={isDisabled}\n freeSolo={isCustomValueAllowed}\n filterSelectedOptions={true}\n id={idOverride}\n loading={isLoading}\n multiple={hasMultipleChoices}\n onBlur={onBlur}\n onChange={onChange}\n onInputChange={onInputChange}\n onFocus={onFocus}\n options={options}\n readOnly={isReadOnly}\n renderInput={renderInput}\n value={value}\n />\n );\n};\n\nconst MemoizedAutocomplete = memo(Autocomplete) as typeof Autocomplete;\n\nexport { MemoizedAutocomplete as Autocomplete };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOA,SAASA,IAAI,EAAEC,WAAW,QAAQ,OAAO;AAAC,SAEjCC,KAAK;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAqId,MAAMC,YAAY,GAAGC,IAAA,IAuB0D;EAAA,IAnB7E;IACAC,YAAY;IACZC,kBAAkB;IAClBC,EAAE,EAAEC,UAAU;IACdC,oBAAoB;IACpBC,UAAU;IACVC,SAAS;IACTC,UAAU,GAAG,KAAK;IAClBC,UAAU;IACVC,IAAI;IACJC,KAAK;IACLC,IAAI,EAAEC,YAAY;IAClBC,MAAM;IACNC,QAAQ;IACRC,aAAa;IACbC,OAAO;IACPC,OAAO;IACPC,KAAK;IACLC;EACuE,CAAC,GAAApB,IAAA;EACxE,MAAMqB,WAAW,GAAG1B,WAAW,CAC7B2B,KAAA;IAAA,IAAC;MAAEC,eAAe;MAAEC,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,IAAI,CAACK,YAAY,CAAwB;AAEtE,SAAS2C,oBAAoB,IAAI3C,YAAY"}
|
|
@@ -18,15 +18,18 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
18
|
const OdysseyCacheProvider = _ref => {
|
|
19
19
|
let {
|
|
20
20
|
children,
|
|
21
|
+
emotionRootElement,
|
|
21
22
|
nonce,
|
|
22
23
|
stylisPlugins
|
|
23
24
|
} = _ref;
|
|
24
25
|
const uniqueAlphabeticalId = useUniqueAlphabeticalId();
|
|
25
26
|
const emotionCache = useMemo(() => createCache({
|
|
27
|
+
container: emotionRootElement,
|
|
26
28
|
key: uniqueAlphabeticalId,
|
|
27
29
|
nonce: nonce || window.cspNonce,
|
|
30
|
+
prepend: Boolean(emotionRootElement),
|
|
28
31
|
stylisPlugins
|
|
29
|
-
}), [nonce, stylisPlugins, uniqueAlphabeticalId]);
|
|
32
|
+
}), [emotionRootElement, nonce, stylisPlugins, uniqueAlphabeticalId]);
|
|
30
33
|
return _jsx(CacheProvider, {
|
|
31
34
|
value: emotionCache,
|
|
32
35
|
children: children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","CacheProvider","memo","useMemo","useUniqueAlphabeticalId","jsx","_jsx","OdysseyCacheProvider","_ref","children","nonce","stylisPlugins","uniqueAlphabeticalId","emotionCache","key","window","cspNonce","value","MemoizedOdysseyCacheProvider","displayName"],"sources":["../src/OdysseyCacheProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\ndeclare global {\n interface Window {\n cspNonce: string;\n }\n}\n\nimport createCache, { StylisPlugin } from \"@emotion/cache\";\nimport { CacheProvider } from \"@emotion/react\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId\";\n\nexport type OdysseyCacheProviderProps = {\n children: ReactNode;\n nonce?: string;\n stylisPlugins?: StylisPlugin[];\n};\n\nconst OdysseyCacheProvider = ({\n children,\n nonce,\n stylisPlugins,\n}: OdysseyCacheProviderProps) => {\n const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n const emotionCache = useMemo(\n () =>\n createCache({\n key: uniqueAlphabeticalId,\n nonce: nonce || window.cspNonce,\n stylisPlugins,\n }),\n [nonce, stylisPlugins, uniqueAlphabeticalId]\n );\n\n return <CacheProvider value={emotionCache}>{children}</CacheProvider>;\n};\n\nconst MemoizedOdysseyCacheProvider = memo(OdysseyCacheProvider);\nMemoizedOdysseyCacheProvider.displayName = \"OdysseyCacheProvider\";\n\nexport { MemoizedOdysseyCacheProvider as OdysseyCacheProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,WAAW,MAAwB,gBAAgB;AAC1D,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,IAAI,EAAaC,OAAO,QAAQ,OAAO;AAAC,SAExCC,uBAAuB;AAAA,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"file":"OdysseyCacheProvider.js","names":["createCache","CacheProvider","memo","useMemo","useUniqueAlphabeticalId","jsx","_jsx","OdysseyCacheProvider","_ref","children","emotionRootElement","nonce","stylisPlugins","uniqueAlphabeticalId","emotionCache","container","key","window","cspNonce","prepend","Boolean","value","MemoizedOdysseyCacheProvider","displayName"],"sources":["../src/OdysseyCacheProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\ndeclare global {\n interface Window {\n cspNonce: string;\n }\n}\n\nimport createCache, { StylisPlugin } from \"@emotion/cache\";\nimport { CacheProvider } from \"@emotion/react\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { useUniqueAlphabeticalId } from \"./useUniqueAlphabeticalId\";\n\nexport type OdysseyCacheProviderProps = {\n children: ReactNode;\n /**\n * Emotion renders into this HTML element.\n * When enabling this prop, Emotion renders at the top of this component rather than the bottom like it does in the HTML `<head>`.\n */\n emotionRootElement?: HTMLStyleElement;\n nonce?: string;\n stylisPlugins?: StylisPlugin[];\n};\n\nconst OdysseyCacheProvider = ({\n children,\n emotionRootElement,\n nonce,\n stylisPlugins,\n}: OdysseyCacheProviderProps) => {\n const uniqueAlphabeticalId = useUniqueAlphabeticalId();\n\n const emotionCache = useMemo(\n () =>\n createCache({\n container: emotionRootElement,\n key: uniqueAlphabeticalId,\n nonce: nonce || window.cspNonce,\n prepend: Boolean(emotionRootElement),\n stylisPlugins,\n }),\n [emotionRootElement, nonce, stylisPlugins, uniqueAlphabeticalId]\n );\n\n return <CacheProvider value={emotionCache}>{children}</CacheProvider>;\n};\n\nconst MemoizedOdysseyCacheProvider = memo(OdysseyCacheProvider);\nMemoizedOdysseyCacheProvider.displayName = \"OdysseyCacheProvider\";\n\nexport { MemoizedOdysseyCacheProvider as OdysseyCacheProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,WAAW,MAAwB,gBAAgB;AAC1D,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,IAAI,EAAaC,OAAO,QAAQ,OAAO;AAAC,SAExCC,uBAAuB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAahC,MAAMC,oBAAoB,GAAGC,IAAA,IAKI;EAAA,IALH;IAC5BC,QAAQ;IACRC,kBAAkB;IAClBC,KAAK;IACLC;EACyB,CAAC,GAAAJ,IAAA;EAC1B,MAAMK,oBAAoB,GAAGT,uBAAuB,CAAC,CAAC;EAEtD,MAAMU,YAAY,GAAGX,OAAO,CAC1B,MACEH,WAAW,CAAC;IACVe,SAAS,EAAEL,kBAAkB;IAC7BM,GAAG,EAAEH,oBAAoB;IACzBF,KAAK,EAAEA,KAAK,IAAIM,MAAM,CAACC,QAAQ;IAC/BC,OAAO,EAAEC,OAAO,CAACV,kBAAkB,CAAC;IACpCE;EACF,CAAC,CAAC,EACJ,CAACF,kBAAkB,EAAEC,KAAK,EAAEC,aAAa,EAAEC,oBAAoB,CACjE,CAAC;EAED,OAAOP,IAAA,CAACL,aAAa;IAACoB,KAAK,EAAEP,YAAa;IAAAL,QAAA,EAAEA;EAAQ,CAAgB,CAAC;AACvE,CAAC;AAED,MAAMa,4BAA4B,GAAGpB,IAAI,CAACK,oBAAoB,CAAC;AAC/De,4BAA4B,CAACC,WAAW,GAAG,sBAAsB;AAEjE,SAASD,4BAA4B,IAAIf,oBAAoB"}
|
package/dist/OdysseyProvider.js
CHANGED
|
@@ -20,6 +20,8 @@ const OdysseyProvider = _ref => {
|
|
|
20
20
|
let {
|
|
21
21
|
children,
|
|
22
22
|
designTokensOverride,
|
|
23
|
+
emotionRootElement,
|
|
24
|
+
shadowRootElement,
|
|
23
25
|
languageCode,
|
|
24
26
|
nonce,
|
|
25
27
|
stylisPlugins,
|
|
@@ -27,11 +29,13 @@ const OdysseyProvider = _ref => {
|
|
|
27
29
|
translationOverrides
|
|
28
30
|
} = _ref;
|
|
29
31
|
return _jsx(OdysseyCacheProvider, {
|
|
32
|
+
emotionRootElement: emotionRootElement,
|
|
30
33
|
nonce: nonce,
|
|
31
34
|
stylisPlugins: stylisPlugins,
|
|
32
35
|
children: _jsx(OdysseyThemeProvider, {
|
|
33
|
-
themeOverride: themeOverride,
|
|
34
36
|
designTokensOverride: designTokensOverride,
|
|
37
|
+
shadowRootElement: shadowRootElement,
|
|
38
|
+
themeOverride: themeOverride,
|
|
35
39
|
children: _jsx(_ScopedCssBaseline, {
|
|
36
40
|
children: _jsx(OdysseyTranslationProvider, {
|
|
37
41
|
languageCode: languageCode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","OdysseyProvider","_ref","children","designTokensOverride","languageCode","nonce","stylisPlugins","themeOverride","translationOverrides","_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\";\n\nexport type OdysseyProviderProps = OdysseyCacheProviderProps &\n OdysseyThemeProviderProps &\n OdysseyTranslationProviderProps & {\n children: ReactNode;\n };\n\nconst OdysseyProvider = ({\n children,\n designTokensOverride,\n languageCode,\n nonce,\n stylisPlugins,\n themeOverride,\n translationOverrides,\n}: OdysseyProviderProps) => (\n <OdysseyCacheProvider
|
|
1
|
+
{"version":3,"file":"OdysseyProvider.js","names":["memo","OdysseyCacheProvider","OdysseyThemeProvider","OdysseyTranslationProvider","jsx","_jsx","OdysseyProvider","_ref","children","designTokensOverride","emotionRootElement","shadowRootElement","languageCode","nonce","stylisPlugins","themeOverride","translationOverrides","_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\";\n\nexport type OdysseyProviderProps = OdysseyCacheProviderProps &\n OdysseyThemeProviderProps &\n OdysseyTranslationProviderProps & {\n children: ReactNode;\n };\n\nconst OdysseyProvider = ({\n children,\n designTokensOverride,\n emotionRootElement,\n shadowRootElement,\n languageCode,\n nonce,\n stylisPlugins,\n themeOverride,\n translationOverrides,\n}: OdysseyProviderProps) => (\n <OdysseyCacheProvider\n emotionRootElement={emotionRootElement}\n nonce={nonce}\n stylisPlugins={stylisPlugins}\n >\n <OdysseyThemeProvider\n designTokensOverride={designTokensOverride}\n shadowRootElement={shadowRootElement}\n themeOverride={themeOverride}\n >\n <ScopedCssBaseline>\n <OdysseyTranslationProvider\n languageCode={languageCode}\n translationOverrides={translationOverrides}\n >\n {children}\n </OdysseyTranslationProvider>\n </ScopedCssBaseline>\n </OdysseyThemeProvider>\n </OdysseyCacheProvider>\n);\n\nconst MemoizedThemeProvider = memo(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;AAU5B,MAAMC,eAAe,GAAGC,IAAA;EAAA,IAAC;IACvBC,QAAQ;IACRC,oBAAoB;IACpBC,kBAAkB;IAClBC,iBAAiB;IACjBC,YAAY;IACZC,KAAK;IACLC,aAAa;IACbC,aAAa;IACbC;EACoB,CAAC,GAAAT,IAAA;EAAA,OACrBF,IAAA,CAACJ,oBAAoB;IACnBS,kBAAkB,EAAEA,kBAAmB;IACvCG,KAAK,EAAEA,KAAM;IACbC,aAAa,EAAEA,aAAc;IAAAN,QAAA,EAE7BH,IAAA,CAACH,oBAAoB;MACnBO,oBAAoB,EAAEA,oBAAqB;MAC3CE,iBAAiB,EAAEA,iBAAkB;MACrCI,aAAa,EAAEA,aAAc;MAAAP,QAAA,EAE7BH,IAAA,CAAAY,kBAAA;QAAAT,QAAA,EACEH,IAAA,CAACF,0BAA0B;UACzBS,YAAY,EAAEA,YAAa;UAC3BI,oBAAoB,EAAEA,oBAAqB;UAAAR,QAAA,EAE1CA;QAAQ,CACiB;MAAC,CACZ;IAAC,CACA;EAAC,CACH,CAAC;AAAA,CACxB;AAED,MAAMU,qBAAqB,GAAGlB,IAAI,CAACM,eAAe,CAAC;AAEnD,SAASY,qBAAqB,IAAIZ,eAAe"}
|
|
@@ -21,13 +21,17 @@ const OdysseyThemeProvider = _ref => {
|
|
|
21
21
|
let {
|
|
22
22
|
children,
|
|
23
23
|
designTokensOverride,
|
|
24
|
+
shadowRootElement,
|
|
24
25
|
themeOverride
|
|
25
26
|
} = _ref;
|
|
26
27
|
const odysseyTokens = useMemo(() => ({
|
|
27
28
|
...Tokens,
|
|
28
29
|
...designTokensOverride
|
|
29
30
|
}), [designTokensOverride]);
|
|
30
|
-
const odysseyTheme = useMemo(() => createOdysseyMuiTheme(
|
|
31
|
+
const odysseyTheme = useMemo(() => createOdysseyMuiTheme({
|
|
32
|
+
odysseyTokens,
|
|
33
|
+
shadowRootElement
|
|
34
|
+
}), [odysseyTokens, shadowRootElement]);
|
|
31
35
|
const customOdysseyTheme = useMemo(() => themeOverride && createTheme(deepmerge(odysseyTheme, themeOverride)), [odysseyTheme, themeOverride]);
|
|
32
36
|
return _jsx(MuiThemeProvider, {
|
|
33
37
|
theme: customOdysseyTheme ?? odysseyTheme,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyThemeProvider.js","names":["createTheme","ThemeProvider","MuiThemeProvider","memo","useMemo","deepmerge","createOdysseyMuiTheme","Tokens","OdysseyDesignTokensContext","jsx","_jsx","OdysseyThemeProvider","_ref","children","designTokensOverride","themeOverride","odysseyTokens","odysseyTheme","customOdysseyTheme","theme","Provider","value","MemoizedOdysseyThemeProvider"],"sources":["../src/OdysseyThemeProvider.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 createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { ThemeOptions } from \"@mui/material\";\nimport { deepmerge } from \"@mui/utils\";\nimport { createOdysseyMuiTheme, DesignTokensOverride } from \"./theme\";\nimport * as Tokens from \"@okta/odyssey-design-tokens\";\nimport { OdysseyDesignTokensContext } from \"./OdysseyDesignTokensContext\";\n\nexport type OdysseyThemeProviderProps = {\n children: ReactNode;\n designTokensOverride?: DesignTokensOverride;\n themeOverride?: ThemeOptions;\n};\n\nconst OdysseyThemeProvider = ({\n children,\n designTokensOverride,\n themeOverride,\n}: OdysseyThemeProviderProps) => {\n const odysseyTokens = useMemo(\n () => ({ ...Tokens, ...designTokensOverride }),\n [designTokensOverride]\n );\n const odysseyTheme = useMemo(\n ()
|
|
1
|
+
{"version":3,"file":"OdysseyThemeProvider.js","names":["createTheme","ThemeProvider","MuiThemeProvider","memo","useMemo","deepmerge","createOdysseyMuiTheme","Tokens","OdysseyDesignTokensContext","jsx","_jsx","OdysseyThemeProvider","_ref","children","designTokensOverride","shadowRootElement","themeOverride","odysseyTokens","odysseyTheme","customOdysseyTheme","theme","Provider","value","MemoizedOdysseyThemeProvider"],"sources":["../src/OdysseyThemeProvider.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 createTheme,\n ThemeProvider as MuiThemeProvider,\n} from \"@mui/material/styles\";\nimport { memo, ReactNode, useMemo } from \"react\";\n\nimport { ThemeOptions } from \"@mui/material\";\nimport { deepmerge } from \"@mui/utils\";\nimport { createOdysseyMuiTheme, DesignTokensOverride } from \"./theme\";\nimport * as Tokens from \"@okta/odyssey-design-tokens\";\nimport { OdysseyDesignTokensContext } from \"./OdysseyDesignTokensContext\";\n\nexport type OdysseyThemeProviderProps = {\n children: ReactNode;\n designTokensOverride?: DesignTokensOverride;\n shadowRootElement?: HTMLDivElement;\n themeOverride?: ThemeOptions;\n};\n\nconst OdysseyThemeProvider = ({\n children,\n designTokensOverride,\n shadowRootElement,\n themeOverride,\n}: OdysseyThemeProviderProps) => {\n const odysseyTokens = useMemo(\n () => ({ ...Tokens, ...designTokensOverride }),\n [designTokensOverride]\n );\n const odysseyTheme = useMemo(\n () =>\n createOdysseyMuiTheme({\n odysseyTokens,\n shadowRootElement,\n }),\n [odysseyTokens, shadowRootElement]\n );\n\n const customOdysseyTheme = useMemo(\n () => themeOverride && createTheme(deepmerge(odysseyTheme, themeOverride)),\n [odysseyTheme, themeOverride]\n );\n\n return (\n <MuiThemeProvider theme={customOdysseyTheme ?? odysseyTheme}>\n <OdysseyDesignTokensContext.Provider value={odysseyTokens}>\n {children}\n </OdysseyDesignTokensContext.Provider>\n </MuiThemeProvider>\n );\n};\n\nconst MemoizedOdysseyThemeProvider = memo(OdysseyThemeProvider);\n\nexport { MemoizedOdysseyThemeProvider as OdysseyThemeProvider };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,WAAW,EACXC,aAAa,IAAIC,gBAAgB,QAC5B,sBAAsB;AAC7B,SAASC,IAAI,EAAaC,OAAO,QAAQ,OAAO;AAGhD,SAASC,SAAS,QAAQ,YAAY;AAAC,SAC9BC,qBAAqB;AAC9B,OAAO,KAAKC,MAAM,MAAM,6BAA6B;AAAC,SAC7CC,0BAA0B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AASnC,MAAMC,oBAAoB,GAAGC,IAAA,IAKI;EAAA,IALH;IAC5BC,QAAQ;IACRC,oBAAoB;IACpBC,iBAAiB;IACjBC;EACyB,CAAC,GAAAJ,IAAA;EAC1B,MAAMK,aAAa,GAAGb,OAAO,CAC3B,OAAO;IAAE,GAAGG,MAAM;IAAE,GAAGO;EAAqB,CAAC,CAAC,EAC9C,CAACA,oBAAoB,CACvB,CAAC;EACD,MAAMI,YAAY,GAAGd,OAAO,CAC1B,MACEE,qBAAqB,CAAC;IACpBW,aAAa;IACbF;EACF,CAAC,CAAC,EACJ,CAACE,aAAa,EAAEF,iBAAiB,CACnC,CAAC;EAED,MAAMI,kBAAkB,GAAGf,OAAO,CAChC,MAAMY,aAAa,IAAIhB,WAAW,CAACK,SAAS,CAACa,YAAY,EAAEF,aAAa,CAAC,CAAC,EAC1E,CAACE,YAAY,EAAEF,aAAa,CAC9B,CAAC;EAED,OACEN,IAAA,CAACR,gBAAgB;IAACkB,KAAK,EAAED,kBAAkB,IAAID,YAAa;IAAAL,QAAA,EAC1DH,IAAA,CAACF,0BAA0B,CAACa,QAAQ;MAACC,KAAK,EAAEL,aAAc;MAAAJ,QAAA,EACvDA;IAAQ,CAC0B;EAAC,CACtB,CAAC;AAEvB,CAAC;AAED,MAAMU,4BAA4B,GAAGpB,IAAI,CAACQ,oBAAoB,CAAC;AAE/D,SAASY,4BAA4B,IAAIZ,oBAAoB"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { useEffect } from "react";
|
|
14
|
-
import i18n,
|
|
14
|
+
import { i18n, defaultNS, resources } from "./i18n.js";
|
|
15
15
|
import { I18nextProvider } from "react-i18next";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
const mergeBundleOverrides = (languageCode, translationOverrides) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","jsx","_jsx","mergeBundleOverrides","languageCode","translationOverrides","bundle","overrides","OdysseyTranslationProvider","_ref","children","changeLanguage","window","navigator","language","Object","keys","forEach","addResourceBundle"],"sources":["../src/OdysseyTranslationProvider.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 { ReactNode, useEffect } from \"react\";\n\nimport { SupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nimport i18n,
|
|
1
|
+
{"version":3,"file":"OdysseyTranslationProvider.js","names":["useEffect","i18n","defaultNS","resources","I18nextProvider","jsx","_jsx","mergeBundleOverrides","languageCode","translationOverrides","bundle","overrides","OdysseyTranslationProvider","_ref","children","changeLanguage","window","navigator","language","Object","keys","forEach","addResourceBundle"],"sources":["../src/OdysseyTranslationProvider.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 { ReactNode, useEffect } from \"react\";\n\nimport { SupportedLanguages } from \"./OdysseyTranslationProvider.types\";\n\nimport { i18n, defaultNS, resources } from \"./i18n\";\nimport { I18nextProvider } from \"react-i18next\";\n\nexport type TranslationOverrides = {\n [key in SupportedLanguages]?: Partial<(typeof resources)[\"en\"]>;\n};\n\nconst mergeBundleOverrides = (\n languageCode: SupportedLanguages,\n translationOverrides: TranslationOverrides\n) => {\n const bundle = resources[languageCode];\n const overrides = translationOverrides[languageCode];\n return {\n ...bundle,\n ...overrides,\n };\n};\n\nexport type OdysseyTranslationProviderProps = {\n children: ReactNode;\n languageCode?: SupportedLanguages;\n translationOverrides?: TranslationOverrides;\n};\n\nexport const OdysseyTranslationProvider = ({\n children,\n languageCode,\n translationOverrides,\n}: OdysseyTranslationProviderProps) => {\n useEffect(() => {\n // Defaults to the browser's language if available otherwise `en` will be used\n i18n.changeLanguage(languageCode || window.navigator.language);\n }, [languageCode]);\n\n useEffect(() => {\n if (translationOverrides) {\n Object.keys(translationOverrides).forEach((language) => {\n const bundle = mergeBundleOverrides(\n language as SupportedLanguages,\n translationOverrides\n );\n i18n.addResourceBundle(language, defaultNS, bundle);\n });\n }\n }, [translationOverrides]);\n\n return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,SAAS,QAAQ,OAAO;AAAC,SAIpCC,IAAI,EAAEC,SAAS,EAAEC,SAAS;AACnC,SAASC,eAAe,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMhD,MAAMC,oBAAoB,GAAGA,CAC3BC,YAAgC,EAChCC,oBAA0C,KACvC;EACH,MAAMC,MAAM,GAAGP,SAAS,CAACK,YAAY,CAAC;EACtC,MAAMG,SAAS,GAAGF,oBAAoB,CAACD,YAAY,CAAC;EACpD,OAAO;IACL,GAAGE,MAAM;IACT,GAAGC;EACL,CAAC;AACH,CAAC;AAQD,OAAO,MAAMC,0BAA0B,GAAGC,IAAA,IAIH;EAAA,IAJI;IACzCC,QAAQ;IACRN,YAAY;IACZC;EAC+B,CAAC,GAAAI,IAAA;EAChCb,SAAS,CAAC,MAAM;IAEdC,IAAI,CAACc,cAAc,CAACP,YAAY,IAAIQ,MAAM,CAACC,SAAS,CAACC,QAAQ,CAAC;EAChE,CAAC,EAAE,CAACV,YAAY,CAAC,CAAC;EAElBR,SAAS,CAAC,MAAM;IACd,IAAIS,oBAAoB,EAAE;MACxBU,MAAM,CAACC,IAAI,CAACX,oBAAoB,CAAC,CAACY,OAAO,CAAEH,QAAQ,IAAK;QACtD,MAAMR,MAAM,GAAGH,oBAAoB,CACjCW,QAAQ,EACRT,oBACF,CAAC;QACDR,IAAI,CAACqB,iBAAiB,CAACJ,QAAQ,EAAEhB,SAAS,EAAEQ,MAAM,CAAC;MACrD,CAAC,CAAC;IACJ;EACF,CAAC,EAAE,CAACD,oBAAoB,CAAC,CAAC;EAE1B,OAAOH,IAAA,CAACF,eAAe;IAACH,IAAI,EAAEA,IAAK;IAAAa,QAAA,EAAEA;EAAQ,CAAkB,CAAC;AAClE,CAAC"}
|
package/dist/PasswordField.js
CHANGED
|
@@ -15,6 +15,7 @@ import _IconButton from "@mui/material/IconButton";
|
|
|
15
15
|
import { forwardRef, memo, useCallback, useState } from "react";
|
|
16
16
|
import { ShowIcon, HideIcon } from "./icons.generated/index.js";
|
|
17
17
|
import { Field } from "./Field.js";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
const PasswordField = forwardRef((_ref, ref) => {
|
|
20
21
|
let {
|
|
@@ -25,6 +26,7 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
25
26
|
id: idOverride,
|
|
26
27
|
isDisabled = false,
|
|
27
28
|
isOptional = false,
|
|
29
|
+
hasShowPassword = true,
|
|
28
30
|
isReadOnly,
|
|
29
31
|
label,
|
|
30
32
|
name: nameOverride,
|
|
@@ -35,6 +37,9 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
35
37
|
testId,
|
|
36
38
|
value
|
|
37
39
|
} = _ref;
|
|
40
|
+
const {
|
|
41
|
+
t
|
|
42
|
+
} = useTranslation();
|
|
38
43
|
const [inputType, setInputType] = useState("password");
|
|
39
44
|
const togglePasswordVisibility = useCallback(() => {
|
|
40
45
|
setInputType(inputType => inputType === "password" ? "text" : "password");
|
|
@@ -49,15 +54,18 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
49
54
|
autoComplete: autoCompleteType,
|
|
50
55
|
autoFocus: hasInitialFocus,
|
|
51
56
|
"data-se": testId,
|
|
52
|
-
endAdornment: _jsx(_InputAdornment, {
|
|
57
|
+
endAdornment: hasShowPassword && _jsx(_InputAdornment, {
|
|
53
58
|
position: "end",
|
|
54
59
|
children: _jsx(_IconButton, {
|
|
55
|
-
"aria-label": "
|
|
60
|
+
"aria-label": inputType === "password" ? t("passwordfield.icon.label.show") : t("passwordfield.icon.label.hide"),
|
|
56
61
|
onClick: togglePasswordVisibility,
|
|
57
62
|
children: inputType === "password" ? _jsx(ShowIcon, {}) : _jsx(HideIcon, {})
|
|
58
63
|
})
|
|
59
64
|
}),
|
|
60
65
|
id: id,
|
|
66
|
+
inputProps: {
|
|
67
|
+
role: "textbox"
|
|
68
|
+
},
|
|
61
69
|
name: nameOverride ?? id,
|
|
62
70
|
onChange: onChange,
|
|
63
71
|
onFocus: onFocus,
|
|
@@ -69,7 +77,7 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
69
77
|
type: inputType,
|
|
70
78
|
value: value
|
|
71
79
|
});
|
|
72
|
-
}, [autoCompleteType, hasInitialFocus, togglePasswordVisibility, inputType, nameOverride, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, ref, testId, value]);
|
|
80
|
+
}, [autoCompleteType, hasInitialFocus, t, togglePasswordVisibility, inputType, nameOverride, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, hasShowPassword, ref, testId, value]);
|
|
73
81
|
return _jsx(Field, {
|
|
74
82
|
errorMessage: errorMessage,
|
|
75
83
|
fieldType: "single",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useState","ShowIcon","HideIcon","Field","jsx","_jsx","PasswordField","_ref","ref","autoCompleteType","errorMessage","hasInitialFocus","hint","id","idOverride","isDisabled","isOptional","isReadOnly","label","name","nameOverride","onChange","onFocus","onBlur","placeholder","testId","value","inputType","setInputType","togglePasswordVisibility","renderFieldComponent","_ref2","ariaDescribedBy","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","onClick","readOnly","required","type","fieldType","hasVisibleLabel","MemoizedPasswordField","displayName"],"sources":["../src/PasswordField.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 { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n memo,\n useCallback,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type PasswordFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: \"current-password\" | \"new-password\";\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * It prevents the user from changing the value of the field\n */\n isReadOnly?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: string;\n} & SeleniumProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n autoCompleteType,\n errorMessage,\n hasInitialFocus,\n hint,\n id: idOverride,\n isDisabled = false,\n isOptional = false,\n isReadOnly,\n label,\n name: nameOverride,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const [inputType, setInputType] = useState(\"password\");\n\n const togglePasswordVisibility = useCallback(() => {\n setInputType((inputType) =>\n inputType === \"password\" ? \"text\" : \"password\"\n );\n }, []);\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <InputBase\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n <InputAdornment position=\"end\">\n
|
|
1
|
+
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useState","ShowIcon","HideIcon","Field","useTranslation","jsx","_jsx","PasswordField","_ref","ref","autoCompleteType","errorMessage","hasInitialFocus","hint","id","idOverride","isDisabled","isOptional","hasShowPassword","isReadOnly","label","name","nameOverride","onChange","onFocus","onBlur","placeholder","testId","value","t","inputType","setInputType","togglePasswordVisibility","renderFieldComponent","_ref2","ariaDescribedBy","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","onClick","inputProps","role","readOnly","required","type","fieldType","hasVisibleLabel","MemoizedPasswordField","displayName"],"sources":["../src/PasswordField.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 { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n memo,\n useCallback,\n useState,\n} from \"react\";\n\nimport { ShowIcon, HideIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\nimport { useTranslation } from \"react-i18next\";\n\nexport type PasswordFieldProps = {\n /**\n * This prop helps users to fill forms faster, especially on mobile devices.\n * The name can be confusing, as it's more like an autofill.\n * You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill).\n */\n autoCompleteType?: \"current-password\" | \"new-password\";\n /**\n * If `error` is not undefined, the `input` will indicate an error.\n */\n errorMessage?: string;\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\n /**\n * If `true`, the show/hide icon is not shown to the user\n */\n hasShowPassword?: boolean;\n /**\n * The helper text content.\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * If `true`, the component is disabled.\n */\n isDisabled?: boolean;\n /**\n * If `true`, the `input` element is not required.\n */\n isOptional?: boolean;\n /**\n * It prevents the user from changing the value of the field\n */\n isReadOnly?: boolean;\n /**\n * The label for the `input` element.\n */\n label: string;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n /**\n * Callback fired when the `input` element loses focus.\n */\n onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * Callback fired when the value is changed.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;\n /**\n * Callback fired when the `input` element get focus.\n */\n onFocus?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>;\n /**\n * The short hint displayed in the `input` before the user enters a value.\n */\n placeholder?: string;\n /**\n * The value of the `input` element, required for a controlled component.\n */\n value?: string;\n} & SeleniumProps;\n\nconst PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(\n (\n {\n autoCompleteType,\n errorMessage,\n hasInitialFocus,\n hint,\n id: idOverride,\n isDisabled = false,\n isOptional = false,\n hasShowPassword = true,\n isReadOnly,\n label,\n name: nameOverride,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n testId,\n value,\n },\n ref\n ) => {\n const { t } = useTranslation();\n const [inputType, setInputType] = useState(\"password\");\n\n const togglePasswordVisibility = useCallback(() => {\n setInputType((inputType) =>\n inputType === \"password\" ? \"text\" : \"password\"\n );\n }, []);\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <InputBase\n aria-describedby={ariaDescribedBy}\n autoComplete={autoCompleteType}\n /* eslint-disable-next-line jsx-a11y/no-autofocus */\n autoFocus={hasInitialFocus}\n data-se={testId}\n endAdornment={\n hasShowPassword && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label={\n inputType === \"password\"\n ? t(\"passwordfield.icon.label.show\")\n : t(\"passwordfield.icon.label.hide\")\n }\n onClick={togglePasswordVisibility}\n >\n {inputType === \"password\" ? <ShowIcon /> : <HideIcon />}\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n inputProps={{ role: \"textbox\" }}\n name={nameOverride ?? id}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n placeholder={placeholder}\n readOnly={isReadOnly}\n ref={ref}\n required={!isOptional}\n type={inputType}\n value={value}\n />\n ),\n [\n autoCompleteType,\n hasInitialFocus,\n t,\n togglePasswordVisibility,\n inputType,\n nameOverride,\n onChange,\n onFocus,\n onBlur,\n placeholder,\n isOptional,\n isReadOnly,\n hasShowPassword,\n ref,\n testId,\n value,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedPasswordField = memo(PasswordField);\nMemoizedPasswordField.displayName = \"PasswordField\";\n\nexport { MemoizedPasswordField as PasswordField };\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAGEA,UAAU,EACVC,IAAI,EACJC,WAAW,EACXC,QAAQ,QACH,OAAO;AAAC,SAENC,QAAQ,EAAEC,QAAQ;AAAA,SAClBC,KAAK;AAEd,SAASC,cAAc,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAuE/C,MAAMC,aAAa,GAAGV,UAAU,CAC9B,CAAAW,IAAA,EAoBEC,GAAG,KACA;EAAA,IApBH;IACEC,gBAAgB;IAChBC,YAAY;IACZC,eAAe;IACfC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,UAAU,GAAG,KAAK;IAClBC,UAAU,GAAG,KAAK;IAClBC,eAAe,GAAG,IAAI;IACtBC,UAAU;IACVC,KAAK;IACLC,IAAI,EAAEC,YAAY;IAClBC,QAAQ;IACRC,OAAO;IACPC,MAAM;IACNC,WAAW;IACXC,MAAM;IACNC;EACF,CAAC,GAAApB,IAAA;EAGD,MAAM;IAAEqB;EAAE,CAAC,GAAGzB,cAAc,CAAC,CAAC;EAC9B,MAAM,CAAC0B,SAAS,EAAEC,YAAY,CAAC,GAAG/B,Q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BAAgB,EAChBE,eAAe,EACfiB,CAAC,EACDG,wBAAwB,EACxBF,SAAS,EACTR,YAAY,EACZC,QAAQ,EACRC,OAAO,EACPC,MAAM,EACNC,WAAW,EACXT,UAAU,EACVE,UAAU,EACVD,eAAe,EACfT,GAAG,EACHkB,MAAM,EACNC,KAAK,CAET,CAAC;EAED,OACEtB,IAAA,CAACH,KAAK;IACJQ,YAAY,EAAEA,YAAa;IAC3BuC,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACftC,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEA,UAAW;IACvBG,KAAK,EAAEA,KAAM;IACba,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMmB,qBAAqB,GAAGtD,IAAI,CAACS,aAAa,CAAC;AACjD6C,qBAAqB,CAACC,WAAW,GAAG,eAAe;AAEnD,SAASD,qBAAqB,IAAI7C,aAAa"}
|
package/dist/Select.js
CHANGED
|
@@ -16,11 +16,11 @@ import _Chip from "@mui/material/Chip";
|
|
|
16
16
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import { memo, useCallback, useMemo, useState } from "react";
|
|
20
20
|
import { Field } from "./Field.js";
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
-
const Select =
|
|
23
|
+
const Select = _ref => {
|
|
24
24
|
let {
|
|
25
25
|
errorMessage,
|
|
26
26
|
hint,
|
|
@@ -56,20 +56,15 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
56
56
|
onChangeProp(event, child);
|
|
57
57
|
}
|
|
58
58
|
}, [isMultiSelect, onChangeProp, setSelectedValue]);
|
|
59
|
-
const normalizedOptions = options.map(option => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
text: option,
|
|
69
|
-
value: option,
|
|
70
|
-
type: "option"
|
|
71
|
-
};
|
|
72
|
-
});
|
|
59
|
+
const normalizedOptions = useMemo(() => options.map(option => typeof option === "object" ? {
|
|
60
|
+
text: option.text,
|
|
61
|
+
value: option.value || option.text,
|
|
62
|
+
type: option.type === "heading" ? "heading" : "option"
|
|
63
|
+
} : {
|
|
64
|
+
text: option,
|
|
65
|
+
value: option,
|
|
66
|
+
type: "option"
|
|
67
|
+
}), [options]);
|
|
73
68
|
const renderValue = useCallback(selected => {
|
|
74
69
|
if (typeof selected === "string") {
|
|
75
70
|
return undefined;
|
|
@@ -90,7 +85,7 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
90
85
|
children: renderedChips
|
|
91
86
|
});
|
|
92
87
|
}, [normalizedOptions]);
|
|
93
|
-
const children = normalizedOptions.map(option => {
|
|
88
|
+
const children = useMemo(() => normalizedOptions.map(option => {
|
|
94
89
|
if (option.type === "heading") {
|
|
95
90
|
return _jsx(_ListSubheader, {
|
|
96
91
|
children: option.text
|
|
@@ -102,21 +97,27 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
102
97
|
checked: selectedValue.includes(option.value)
|
|
103
98
|
}), option.text]
|
|
104
99
|
}, option.value);
|
|
105
|
-
});
|
|
106
|
-
const renderFieldComponent = useCallback(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
100
|
+
}), [isMultiSelect, normalizedOptions, selectedValue]);
|
|
101
|
+
const renderFieldComponent = useCallback(_ref2 => {
|
|
102
|
+
let {
|
|
103
|
+
ariaDescribedBy,
|
|
104
|
+
id
|
|
105
|
+
} = _ref2;
|
|
106
|
+
return _jsx(_Select, {
|
|
107
|
+
"aria-describedby": ariaDescribedBy,
|
|
108
|
+
children: children,
|
|
109
|
+
"data-se": testId,
|
|
110
|
+
id: id,
|
|
111
|
+
labelId: label,
|
|
112
|
+
multiple: isMultiSelect,
|
|
113
|
+
name: nameOverride ?? id,
|
|
114
|
+
onBlur: onBlur,
|
|
115
|
+
onChange: onChange,
|
|
116
|
+
onFocus: onFocus,
|
|
117
|
+
renderValue: isMultiSelect ? renderValue : undefined,
|
|
118
|
+
value: selectedValue
|
|
119
|
+
});
|
|
120
|
+
}, [children, isMultiSelect, label, nameOverride, onBlur, onChange, onFocus, renderValue, selectedValue, testId]);
|
|
120
121
|
return _jsx(Field, {
|
|
121
122
|
errorMessage: errorMessage,
|
|
122
123
|
fieldType: "single",
|
|
@@ -128,7 +129,7 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
128
129
|
label: label,
|
|
129
130
|
renderFieldComponent: renderFieldComponent
|
|
130
131
|
});
|
|
131
|
-
}
|
|
132
|
+
};
|
|
132
133
|
const MemoizedSelect = memo(Select);
|
|
133
134
|
MemoizedSelect.displayName = "Select";
|
|
134
135
|
export { MemoizedSelect as Select };
|
package/dist/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["forwardRef","memo","useCallback","useState","Field","jsx","_jsx","jsxs","_jsxs","Select","_ref","ref","errorMessage","hint","id","idOverride","isDisabled","isMultiSelect","isOptional","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","value","testId","options","selectedValue","setSelectedValue","event","child","target","split","normalizedOptions","map","option","text","type","renderValue","selected","undefined","renderedChips","item","selectedOption","find","_Chip","filter","Boolean","length","_Box","children","_ListSubheader","_MenuItem","_Checkbox","checked","includes","renderFieldComponent","_Select","multiple","labelId","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { ReactNode, forwardRef, memo, useCallback, useState } from \"react\";\nimport {\n Box,\n Chip,\n Checkbox as MuiCheckbox,\n ListSubheader,\n MenuItem,\n Select as MuiSelect,\n SelectChangeEvent,\n} from \"@mui/material\";\nimport { SelectProps as MuiSelectProps } from \"@mui/material\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n};\n\nexport type SelectProps = {\n /**\n * The error message for the Select\n */\n errorMessage?: string;\n /**\n * The hint text for the Select\n */\n hint?: string;\n /**\n * The id attribute of the Select\n */\n id?: string;\n /**\n * If `true`, the Select is disabled\n */\n isDisabled?: boolean;\n /**\n * If `true`, the Select allows multiple selections\n */\n isMultiSelect?: boolean;\n /**\n * If `true`, the Select is optional\n */\n isOptional?: boolean;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: string | string[];\n} & SeleniumProps;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst Select = forwardRef<HTMLSelectElement, SelectProps>(\n (\n {\n errorMessage,\n hint,\n id: idOverride,\n isDisabled = false,\n isMultiSelect = false,\n isOptional = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n value,\n testId,\n options,\n },\n ref\n ) => {\n // If there's no value set, we set it to a blank string (if it's a single-select)\n // or an empty array (if it's a multi-select)\n if (typeof value === \"undefined\") {\n value = isMultiSelect ? [] : \"\";\n }\n\n const [selectedValue, setSelectedValue] = useState<string | string[]>(\n value\n );\n\n const onChange = useCallback(\n (event: SelectChangeEvent<string | string[]>, child: ReactNode) => {\n const {\n target: { value },\n } = event;\n\n // Set the field value, with some additional logic to handle array values\n // for multi-selects\n if (isMultiSelect) {\n setSelectedValue(\n typeof value === \"string\" ? value.split(\",\") : value\n );\n } else {\n setSelectedValue(value);\n }\n\n // Trigger the onChange event, if one has been passed\n if (onChangeProp) {\n onChangeProp(event, child);\n }\n },\n [isMultiSelect, onChangeProp, setSelectedValue]\n );\n\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const normalizedOptions = options.map((option) => {\n if (typeof option === \"object\") {\n return {\n text: option.text,\n value: option.value || option.text,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n };\n }\n\n return { text: option, value: option, type: \"option\" };\n });\n\n const renderValue = useCallback(\n (selected: string | string[]) => {\n // If the selected value isn't an array, then we don't need to display\n // chips and should fall back to the default render behavior\n if (typeof selected === \"string\") {\n return undefined;\n }\n\n // Convert the selected options array into <Chip>s\n const renderedChips = selected\n .map((item: string) => {\n const selectedOption = normalizedOptions.find(\n (option) => option.value === item\n );\n\n if (!selectedOption) {\n return null;\n }\n\n return <Chip key={item} label={selectedOption.text} />;\n })\n .filter(Boolean);\n\n if (renderedChips.length === 0) {\n return null;\n }\n\n // We need the <Box> to surround the <Chip>s for\n // proper styling\n return <Box>{renderedChips}</Box>;\n },\n [normalizedOptions]\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const children = normalizedOptions.map((option) => {\n if (option.type === \"heading\") {\n return <ListSubheader key={option.text}>{option.text}</ListSubheader>;\n }\n\n return (\n <MenuItem key={option.value} value={option.value}>\n {isMultiSelect && (\n <MuiCheckbox checked={selectedValue.includes(option.value)} />\n )}\n {option.text}\n </MenuItem>\n );\n });\n\n const renderFieldComponent = useCallback(\n () => (\n <MuiSelect\n children={children}\n data-se={testId}\n id={idOverride}\n multiple={isMultiSelect}\n name={nameOverride ?? idOverride}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n ref={ref}\n renderValue={isMultiSelect ? renderValue : undefined}\n value={selectedValue}\n labelId={label}\n />\n ),\n [\n children,\n idOverride,\n isMultiSelect,\n label,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n ref,\n renderValue,\n selectedValue,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAoBA,UAAU,EAAEC,IAAI,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SAWlEC,KAAK;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AA+Ed,MAAMC,MAAM,GAAGT,UAAU,CACvB,CAAAU,IAAA,EAiBEC,GAAG,KACA;EAAA,IAjBH;IACEC,YAAY;IACZC,IAAI;IACJC,EAAE,EAAEC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ACAW,MAAM,CAACC,IAAI;IAAA,GAJCD,MAAM,CAACX,KAKZ,CAAC;EAEf,CAAC,CAAC;EAEF,MAAMgC,oBAAoB,GAAGxD,WAAW,CACtC,MACEI,IAAA,CAAAqD,OAAA;IACEP,QAAQ,EAAEA,QAAS;IACnB,WAASzB,MAAO;IAChBb,EAAE,EAAEC,UAAW;IACf6C,QAAQ,EAAE3C,aAAc;IACxBG,IAAI,EAAEC,YAAY,IAAIN,UAAW;IACjCO,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEA,QAAS;IACnBE,OAAO,EAAEA,OAAQ;IACjBd,GAAG,EAAEA,GAAI;IACT6B,WAAW,EAAEvB,aAAa,GAAGuB,WAAW,GAAGE,SAAU;IACrDhB,KAAK,EAAEG,aAAc;IACrBgC,OAAO,EAAE1C;EAAM,CAChB,CACF,EACD,CACEiC,QAAQ,EACRrC,UAAU,EACVE,aAAa,EACbE,KAAK,EACLE,YAAY,EACZC,MAAM,EACNC,QAAQ,EACRE,OAAO,EACPd,GAAG,EACH6B,WAAW,EACXX,aAAa,EACbF,MAAM,CAEV,CAAC;EAED,OACErB,IAAA,CAACF,KAAK;IACJQ,YAAY,EAAEA,YAAa;IAC3BkD,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACflD,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBE,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbuC,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CACF,CAAC;AAED,MAAMM,cAAc,GAAG/D,IAAI,CAACQ,MAAM,CAAC;AACnCuD,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIvD,MAAM"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["memo","useCallback","useMemo","useState","Field","jsx","_jsx","jsxs","_jsxs","Select","_ref","errorMessage","hint","id","idOverride","isDisabled","isMultiSelect","isOptional","label","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","value","testId","options","selectedValue","setSelectedValue","event","child","target","split","normalizedOptions","map","option","text","type","renderValue","selected","undefined","renderedChips","item","selectedOption","find","_Chip","filter","Boolean","length","_Box","children","_ListSubheader","_MenuItem","_Checkbox","checked","includes","renderFieldComponent","_ref2","ariaDescribedBy","_Select","labelId","multiple","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { ReactNode, memo, useCallback, useMemo, useState } from \"react\";\nimport {\n Box,\n Chip,\n Checkbox as MuiCheckbox,\n ListSubheader,\n MenuItem,\n Select as MuiSelect,\n SelectChangeEvent,\n} from \"@mui/material\";\nimport { SelectProps as MuiSelectProps } from \"@mui/material\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n};\n\nexport type SelectProps = {\n /**\n * The error message for the Select\n */\n errorMessage?: string;\n /**\n * The hint text for the Select\n */\n hint?: string;\n /**\n * The id attribute of the Select\n */\n id?: string;\n /**\n * If `true`, the Select is disabled\n */\n isDisabled?: boolean;\n /**\n * If `true`, the Select allows multiple selections\n */\n isMultiSelect?: boolean;\n /**\n * If `true`, the Select is optional\n */\n isOptional?: boolean;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * The name of the `input` element. Defaults to the `id` if not set.\n */\n name?: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: string | string[];\n} & SeleniumProps;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst Select = ({\n errorMessage,\n hint,\n id: idOverride,\n isDisabled = false,\n isMultiSelect = false,\n isOptional = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n value,\n testId,\n options,\n}: SelectProps) => {\n // If there's no value set, we set it to a blank string (if it's a single-select)\n // or an empty array (if it's a multi-select)\n if (typeof value === \"undefined\") {\n value = isMultiSelect ? [] : \"\";\n }\n\n const [selectedValue, setSelectedValue] = useState<string | string[]>(value);\n\n const onChange = useCallback(\n (event: SelectChangeEvent<string | string[]>, child: ReactNode) => {\n const {\n target: { value },\n } = event;\n\n // Set the field value, with some additional logic to handle array values\n // for multi-selects\n if (isMultiSelect) {\n setSelectedValue(typeof value === \"string\" ? value.split(\",\") : value);\n } else {\n setSelectedValue(value);\n }\n\n // Trigger the onChange event, if one has been passed\n if (onChangeProp) {\n onChangeProp(event, child);\n }\n },\n [isMultiSelect, onChangeProp, setSelectedValue]\n );\n\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const normalizedOptions = useMemo(\n () =>\n options.map((option) =>\n typeof option === \"object\"\n ? {\n text: option.text,\n value: option.value || option.text,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n }\n : { text: option, value: option, type: \"option\" }\n ),\n [options]\n );\n\n const renderValue = useCallback(\n (selected: string | string[]) => {\n // If the selected value isn't an array, then we don't need to display\n // chips and should fall back to the default render behavior\n if (typeof selected === \"string\") {\n return undefined;\n }\n\n // Convert the selected options array into <Chip>s\n const renderedChips = selected\n .map((item: string) => {\n const selectedOption = normalizedOptions.find(\n (option) => option.value === item\n );\n\n if (!selectedOption) {\n return null;\n }\n\n return <Chip key={item} label={selectedOption.text} />;\n })\n .filter(Boolean);\n\n if (renderedChips.length === 0) {\n return null;\n }\n\n // We need the <Box> to surround the <Chip>s for\n // proper styling\n return <Box>{renderedChips}</Box>;\n },\n [normalizedOptions]\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const children = useMemo(\n () =>\n normalizedOptions.map((option) => {\n if (option.type === \"heading\") {\n return <ListSubheader key={option.text}>{option.text}</ListSubheader>;\n }\n\n return (\n <MenuItem key={option.value} value={option.value}>\n {isMultiSelect && (\n <MuiCheckbox checked={selectedValue.includes(option.value)} />\n )}\n {option.text}\n </MenuItem>\n );\n }),\n [isMultiSelect, normalizedOptions, selectedValue]\n );\n\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <MuiSelect\n aria-describedby={ariaDescribedBy}\n children={children}\n data-se={testId}\n id={id}\n labelId={label}\n multiple={isMultiSelect}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={isMultiSelect ? renderValue : undefined}\n value={selectedValue}\n />\n ),\n [\n children,\n isMultiSelect,\n label,\n nameOverride,\n onBlur,\n onChange,\n onFocus,\n renderValue,\n selectedValue,\n testId,\n ]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \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