@okta/odyssey-react-mui 1.0.2 → 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 +54 -0
- package/README.md +1 -1
- package/dist/Autocomplete.js +20 -3
- package/dist/Autocomplete.js.map +1 -1
- package/dist/Banner.js +3 -1
- package/dist/Banner.js.map +1 -1
- package/dist/Box.js +8 -4
- package/dist/Box.js.map +1 -1
- package/dist/Button.js +3 -1
- package/dist/Button.js.map +1 -1
- package/dist/Callout.js +2 -0
- package/dist/Callout.js.map +1 -1
- package/dist/Checkbox.js +6 -2
- package/dist/Checkbox.js.map +1 -1
- package/dist/CheckboxGroup.js +5 -7
- package/dist/CheckboxGroup.js.map +1 -1
- package/dist/CircularProgress.js +2 -0
- package/dist/CircularProgress.js.map +1 -1
- package/dist/Dialog.js +2 -0
- package/dist/Dialog.js.map +1 -1
- package/dist/Field.js.map +1 -1
- package/dist/FieldError.js +2 -0
- package/dist/FieldError.js.map +1 -1
- package/dist/FieldHint.js +2 -0
- package/dist/FieldHint.js.map +1 -1
- package/dist/FieldLabel.js +3 -1
- package/dist/FieldLabel.js.map +1 -1
- package/dist/Fieldset.js +3 -1
- package/dist/Fieldset.js.map +1 -1
- package/dist/Form.js +5 -3
- package/dist/Form.js.map +1 -1
- package/dist/Link.js +3 -1
- package/dist/Link.js.map +1 -1
- package/dist/MenuButton.js +8 -2
- package/dist/MenuButton.js.map +1 -1
- package/dist/MenuItem.js +6 -2
- package/dist/MenuItem.js.map +1 -1
- package/dist/NativeSelect.js +3 -1
- package/dist/NativeSelect.js.map +1 -1
- package/dist/OdysseyCacheProvider.js +4 -1
- package/dist/OdysseyCacheProvider.js.map +1 -1
- package/dist/OdysseyProvider.js +12 -5
- package/dist/OdysseyProvider.js.map +1 -1
- package/dist/OdysseyThemeProvider.js +8 -7
- package/dist/OdysseyThemeProvider.js.map +1 -1
- package/dist/OdysseyTranslationProvider.js +1 -1
- package/dist/OdysseyTranslationProvider.js.map +1 -1
- package/dist/OdysseyTranslationProvider.types.js +1 -1
- package/dist/OdysseyTranslationProvider.types.js.map +1 -1
- package/dist/PasswordField.js +18 -9
- package/dist/PasswordField.js.map +1 -1
- package/dist/Radio.js +2 -0
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +5 -2
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchField.js +11 -10
- package/dist/SearchField.js.map +1 -1
- package/dist/Select.js +39 -35
- package/dist/Select.js.map +1 -1
- package/dist/SeleniumProps.js +2 -0
- package/dist/SeleniumProps.js.map +1 -0
- package/dist/Status.js +4 -2
- package/dist/Status.js.map +1 -1
- package/dist/Tabs.js +11 -4
- package/dist/Tabs.js.map +1 -1
- package/dist/Tag.js +4 -2
- package/dist/Tag.js.map +1 -1
- package/dist/TagList.js +3 -1
- package/dist/TagList.js.map +1 -1
- package/dist/TextField.js +6 -2
- package/dist/TextField.js.map +1 -1
- package/dist/Toast.js +2 -0
- package/dist/Toast.js.map +1 -1
- package/dist/Tooltip.js +2 -0
- package/dist/Tooltip.js.map +1 -1
- package/dist/Typography.js +71 -59
- 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} +5 -2
- package/dist/i18n.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/labs/DatePicker.js +4 -2
- package/dist/labs/DatePicker.js.map +1 -1
- package/dist/labs/PaginatedTable.js +6 -4
- package/dist/labs/PaginatedTable.js.map +1 -1
- package/dist/labs/StaticTable.js +9 -4
- package/dist/labs/StaticTable.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 +29 -4
- package/dist/src/Autocomplete.d.ts.map +1 -1
- package/dist/src/Banner.d.ts +3 -2
- package/dist/src/Banner.d.ts.map +1 -1
- package/dist/src/Box.d.ts +9 -2
- package/dist/src/Box.d.ts.map +1 -1
- package/dist/src/Button.d.ts +3 -2
- package/dist/src/Button.d.ts.map +1 -1
- package/dist/src/Callout.d.ts +3 -2
- package/dist/src/Callout.d.ts.map +1 -1
- package/dist/src/Checkbox.d.ts +8 -3
- package/dist/src/Checkbox.d.ts.map +1 -1
- package/dist/src/CheckboxGroup.d.ts +3 -6
- package/dist/src/CheckboxGroup.d.ts.map +1 -1
- package/dist/src/CircularProgress.d.ts +3 -2
- package/dist/src/CircularProgress.d.ts.map +1 -1
- package/dist/src/Dialog.d.ts +3 -2
- package/dist/src/Dialog.d.ts.map +1 -1
- package/dist/src/Field.d.ts +2 -1
- package/dist/src/Field.d.ts.map +1 -1
- package/dist/src/FieldError.d.ts +3 -2
- package/dist/src/FieldError.d.ts.map +1 -1
- package/dist/src/FieldHint.d.ts +3 -2
- package/dist/src/FieldHint.d.ts.map +1 -1
- package/dist/src/FieldLabel.d.ts +3 -2
- package/dist/src/FieldLabel.d.ts.map +1 -1
- package/dist/src/Fieldset.d.ts +3 -2
- package/dist/src/Fieldset.d.ts.map +1 -1
- package/dist/src/Form.d.ts +3 -2
- package/dist/src/Form.d.ts.map +1 -1
- package/dist/src/Link.d.ts +3 -2
- package/dist/src/Link.d.ts.map +1 -1
- package/dist/src/MenuButton.d.ts +12 -3
- package/dist/src/MenuButton.d.ts.map +1 -1
- package/dist/src/MenuItem.d.ts +5 -4
- package/dist/src/MenuItem.d.ts.map +1 -1
- package/dist/src/NativeSelect.d.ts +56 -2
- package/dist/src/NativeSelect.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/OdysseyTranslationProvider.types.d.ts +1 -1
- package/dist/src/OdysseyTranslationProvider.types.d.ts.map +1 -1
- package/dist/src/PasswordField.d.ts +78 -2
- package/dist/src/PasswordField.d.ts.map +1 -1
- package/dist/src/Radio.d.ts +3 -2
- package/dist/src/Radio.d.ts.map +1 -1
- package/dist/src/RadioGroup.d.ts +8 -3
- package/dist/src/RadioGroup.d.ts.map +1 -1
- package/dist/src/SearchField.d.ts +58 -2
- package/dist/src/SearchField.d.ts.map +1 -1
- package/dist/src/Select.d.ts +7 -2
- package/dist/src/Select.d.ts.map +1 -1
- package/dist/src/SeleniumProps.d.ts +20 -0
- package/dist/src/SeleniumProps.d.ts.map +1 -0
- package/dist/src/Status.d.ts +3 -2
- package/dist/src/Status.d.ts.map +1 -1
- package/dist/src/Tabs.d.ts +9 -3
- package/dist/src/Tabs.d.ts.map +1 -1
- package/dist/src/Tag.d.ts +3 -2
- package/dist/src/Tag.d.ts.map +1 -1
- package/dist/src/TagList.d.ts +3 -2
- package/dist/src/TagList.d.ts.map +1 -1
- package/dist/src/TextField.d.ts +86 -2
- package/dist/src/TextField.d.ts.map +1 -1
- package/dist/src/Toast.d.ts +3 -2
- package/dist/src/Toast.d.ts.map +1 -1
- package/dist/src/Tooltip.d.ts +3 -2
- package/dist/src/Tooltip.d.ts.map +1 -1
- package/dist/src/Typography.d.ts +14 -49
- 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} +20 -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/labs/DatePicker.d.ts +5 -1
- package/dist/src/labs/DatePicker.d.ts.map +1 -1
- package/dist/src/labs/PaginatedTable.d.ts.map +1 -1
- package/dist/src/labs/StaticTable.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 +118 -73
- 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 +7 -6
- package/src/Autocomplete.tsx +56 -4
- package/src/Banner.tsx +11 -2
- package/src/Box.tsx +11 -5
- package/src/Button.tsx +6 -1
- package/src/Callout.tsx +5 -3
- package/src/Checkbox.tsx +14 -4
- package/src/CheckboxGroup.tsx +6 -10
- package/src/CircularProgress.tsx +5 -1
- package/src/Dialog.tsx +5 -2
- package/src/Field.tsx +2 -0
- package/src/FieldError.tsx +5 -3
- package/src/FieldHint.tsx +9 -3
- package/src/FieldLabel.tsx +5 -3
- package/src/Fieldset.tsx +4 -1
- package/src/Form.tsx +7 -4
- package/src/Link.tsx +18 -3
- package/src/MenuButton.tsx +33 -4
- package/src/MenuItem.tsx +11 -6
- package/src/NativeSelect.tsx +7 -2
- package/src/OdysseyCacheProvider.tsx +9 -1
- package/src/OdysseyProvider.tsx +18 -8
- package/src/OdysseyThemeProvider.tsx +12 -8
- package/src/OdysseyTranslationProvider.test.tsx +2 -2
- package/src/OdysseyTranslationProvider.tsx +1 -1
- package/src/OdysseyTranslationProvider.types.ts +1 -0
- package/src/PasswordField.tsx +37 -13
- package/src/Radio.tsx +5 -1
- package/src/RadioGroup.tsx +12 -4
- package/src/SearchField.tsx +23 -15
- package/src/Select.tsx +154 -149
- package/src/SeleniumProps.ts +20 -0
- package/src/Status.tsx +15 -3
- package/src/Tabs.tsx +18 -4
- package/src/Tag.tsx +12 -3
- package/src/TagList.tsx +4 -2
- package/src/TextField.tsx +14 -2
- package/src/Toast.tsx +4 -1
- package/src/Tooltip.tsx +4 -1
- package/src/Typography.tsx +76 -54
- package/src/createShadowDom.ts +46 -0
- package/src/{OdysseyI18n.ts → i18n.ts} +4 -2
- package/src/index.ts +1 -0
- package/src/labs/DatePicker.tsx +15 -7
- package/src/labs/PaginatedTable.tsx +12 -3
- package/src/labs/README.md +2 -2
- package/src/labs/StaticTable.tsx +13 -3
- 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 +69 -18
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _ScopedCssBaseline from "@mui/material/ScopedCssBaseline";
|
|
2
1
|
/*!
|
|
3
2
|
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
4
3
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -22,21 +21,23 @@ const OdysseyThemeProvider = _ref => {
|
|
|
22
21
|
let {
|
|
23
22
|
children,
|
|
24
23
|
designTokensOverride,
|
|
24
|
+
shadowRootElement,
|
|
25
25
|
themeOverride
|
|
26
26
|
} = _ref;
|
|
27
27
|
const odysseyTokens = useMemo(() => ({
|
|
28
28
|
...Tokens,
|
|
29
29
|
...designTokensOverride
|
|
30
30
|
}), [designTokensOverride]);
|
|
31
|
-
const odysseyTheme = useMemo(() => createOdysseyMuiTheme(
|
|
31
|
+
const odysseyTheme = useMemo(() => createOdysseyMuiTheme({
|
|
32
|
+
odysseyTokens,
|
|
33
|
+
shadowRootElement
|
|
34
|
+
}), [odysseyTokens, shadowRootElement]);
|
|
32
35
|
const customOdysseyTheme = useMemo(() => themeOverride && createTheme(deepmerge(odysseyTheme, themeOverride)), [odysseyTheme, themeOverride]);
|
|
33
36
|
return _jsx(MuiThemeProvider, {
|
|
34
37
|
theme: customOdysseyTheme ?? odysseyTheme,
|
|
35
|
-
children: _jsx(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children: children
|
|
39
|
-
})
|
|
38
|
+
children: _jsx(OdysseyDesignTokensContext.Provider, {
|
|
39
|
+
value: odysseyTokens,
|
|
40
|
+
children: children
|
|
40
41
|
})
|
|
41
42
|
});
|
|
42
43
|
};
|
|
@@ -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","
|
|
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"}
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export const supportedLanguages = ["cs", "da", "de", "el", "en", "es", "fi", "fr", "hu", "id", "it", "ja", "ko", "ms", "nb", "nl_NL", "ok_PL", "ok_SK", "pl", "pt_BR", "ro", "ru", "sv", "th", "tr", "uk", "zh_CN", "zh_TW"];
|
|
13
|
+
export const supportedLanguages = ["cs", "da", "de", "el", "en", "es", "fi", "fr", "hu", "id", "it", "ja", "ko", "ms", "nb", "nl_NL", "ok_PL", "ok_SK", "pl", "pt_BR", "ro", "ru", "sv", "th", "tr", "uk", "vi", "zh_CN", "zh_TW"];
|
|
14
14
|
//# sourceMappingURL=OdysseyTranslationProvider.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OdysseyTranslationProvider.types.js","names":["supportedLanguages"],"sources":["../src/OdysseyTranslationProvider.types.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\nexport const supportedLanguages = [\n \"cs\", // Czech\n \"da\", // Danish\n \"de\", // German\n \"el\", // Greek\n \"en\", // English\n \"es\", // Spanish\n \"fi\", // Finnish\n \"fr\", // French\n \"hu\", // Hungarian\n \"id\", // Indonesian\n \"it\", // Italian\n \"ja\", // Japanese\n \"ko\", // Korean\n \"ms\", // Malaysian\n \"nb\", // Norwegian\n \"nl_NL\", // Dutch\n \"ok_PL\", // (Test Language) Pseudo-loc\n \"ok_SK\", // (Test Language) Show Keys\n \"pl\", // Polish\n \"pt_BR\", // Portuguese (Brazil)\n \"ro\", // Romanian\n \"ru\", // Russian\n \"sv\", // Swedish\n \"th\", // Thai\n \"tr\", // Turkish\n \"uk\", // Ukrainian\n \"zh_CN\", // Chinese (PRC)\n \"zh_TW\", // Chinese\n] as const;\n\nexport type SupportedLanguages = (typeof supportedLanguages)[number];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,kBAAkB,GAAG,CAChC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,CACC"}
|
|
1
|
+
{"version":3,"file":"OdysseyTranslationProvider.types.js","names":["supportedLanguages"],"sources":["../src/OdysseyTranslationProvider.types.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\nexport const supportedLanguages = [\n \"cs\", // Czech\n \"da\", // Danish\n \"de\", // German\n \"el\", // Greek\n \"en\", // English\n \"es\", // Spanish\n \"fi\", // Finnish\n \"fr\", // French\n \"hu\", // Hungarian\n \"id\", // Indonesian\n \"it\", // Italian\n \"ja\", // Japanese\n \"ko\", // Korean\n \"ms\", // Malaysian\n \"nb\", // Norwegian\n \"nl_NL\", // Dutch\n \"ok_PL\", // (Test Language) Pseudo-loc\n \"ok_SK\", // (Test Language) Show Keys\n \"pl\", // Polish\n \"pt_BR\", // Portuguese (Brazil)\n \"ro\", // Romanian\n \"ru\", // Russian\n \"sv\", // Swedish\n \"th\", // Thai\n \"tr\", // Turkish\n \"uk\", // Ukrainian\n \"vi\", // Vietnamese\n \"zh_CN\", // Chinese (PRC)\n \"zh_TW\", // Chinese\n] as const;\n\nexport type SupportedLanguages = (typeof supportedLanguages)[number];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,kBAAkB,GAAG,CAChC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,CACC"}
|
package/dist/PasswordField.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _InputBase from "@mui/material/InputBase";
|
|
2
2
|
import _InputAdornment from "@mui/material/InputAdornment";
|
|
3
|
+
import _IconButton from "@mui/material/IconButton";
|
|
3
4
|
/*!
|
|
4
5
|
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
5
6
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -13,8 +14,8 @@ import _InputAdornment from "@mui/material/InputAdornment";
|
|
|
13
14
|
*/
|
|
14
15
|
import { forwardRef, memo, useCallback, useState } from "react";
|
|
15
16
|
import { ShowIcon, HideIcon } from "./icons.generated/index.js";
|
|
16
|
-
import { Button } from "./Button.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,14 +26,20 @@ 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,
|
|
32
|
+
name: nameOverride,
|
|
30
33
|
onChange,
|
|
31
34
|
onFocus,
|
|
32
35
|
onBlur,
|
|
33
36
|
placeholder,
|
|
37
|
+
testId,
|
|
34
38
|
value
|
|
35
39
|
} = _ref;
|
|
40
|
+
const {
|
|
41
|
+
t
|
|
42
|
+
} = useTranslation();
|
|
36
43
|
const [inputType, setInputType] = useState("password");
|
|
37
44
|
const togglePasswordVisibility = useCallback(() => {
|
|
38
45
|
setInputType(inputType => inputType === "password" ? "text" : "password");
|
|
@@ -46,18 +53,20 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
46
53
|
"aria-describedby": ariaDescribedBy,
|
|
47
54
|
autoComplete: autoCompleteType,
|
|
48
55
|
autoFocus: hasInitialFocus,
|
|
49
|
-
|
|
56
|
+
"data-se": testId,
|
|
57
|
+
endAdornment: hasShowPassword && _jsx(_InputAdornment, {
|
|
50
58
|
position: "end",
|
|
51
|
-
children: _jsx(
|
|
52
|
-
|
|
53
|
-
endIcon: inputType === "password" ? _jsx(ShowIcon, {}) : _jsx(HideIcon, {}),
|
|
59
|
+
children: _jsx(_IconButton, {
|
|
60
|
+
"aria-label": inputType === "password" ? t("passwordfield.icon.label.show") : t("passwordfield.icon.label.hide"),
|
|
54
61
|
onClick: togglePasswordVisibility,
|
|
55
|
-
|
|
56
|
-
variant: "floating"
|
|
62
|
+
children: inputType === "password" ? _jsx(ShowIcon, {}) : _jsx(HideIcon, {})
|
|
57
63
|
})
|
|
58
64
|
}),
|
|
59
65
|
id: id,
|
|
60
|
-
|
|
66
|
+
inputProps: {
|
|
67
|
+
role: "textbox"
|
|
68
|
+
},
|
|
69
|
+
name: nameOverride ?? id,
|
|
61
70
|
onChange: onChange,
|
|
62
71
|
onFocus: onFocus,
|
|
63
72
|
onBlur: onBlur,
|
|
@@ -68,7 +77,7 @@ const PasswordField = forwardRef((_ref, ref) => {
|
|
|
68
77
|
type: inputType,
|
|
69
78
|
value: value
|
|
70
79
|
});
|
|
71
|
-
}, [autoCompleteType, hasInitialFocus, togglePasswordVisibility, inputType, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, ref, value]);
|
|
80
|
+
}, [autoCompleteType, hasInitialFocus, t, togglePasswordVisibility, inputType, nameOverride, onChange, onFocus, onBlur, placeholder, isOptional, isReadOnly, hasShowPassword, ref, testId, value]);
|
|
72
81
|
return _jsx(Field, {
|
|
73
82
|
errorMessage: errorMessage,
|
|
74
83
|
fieldType: "single",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","names":["forwardRef","memo","useCallback","useState","ShowIcon","HideIcon","
|
|
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":"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"}
|
package/dist/Radio.js
CHANGED
|
@@ -20,12 +20,14 @@ const Radio = _ref => {
|
|
|
20
20
|
isInvalid,
|
|
21
21
|
label,
|
|
22
22
|
name,
|
|
23
|
+
testId,
|
|
23
24
|
value
|
|
24
25
|
} = _ref;
|
|
25
26
|
return _jsx(_FormControlLabel, {
|
|
26
27
|
checked: isChecked,
|
|
27
28
|
className: isInvalid ? "Mui-error" : "",
|
|
28
29
|
control: _jsx(_Radio, {}),
|
|
30
|
+
"data-se": testId,
|
|
29
31
|
disabled: isDisabled,
|
|
30
32
|
label: label,
|
|
31
33
|
name: name,
|
package/dist/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","names":["memo","jsx","_jsx","Radio","_ref","isChecked","isDisabled","isInvalid","label","name","value","_FormControlLabel","checked","className","control","_Radio","disabled","MemoizedRadio","displayName"],"sources":["../src/Radio.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 { Radio as MuiRadio } from \"@mui/material\";\nimport { memo } from \"react\";\n\nimport { FormControlLabel } from \"@mui/material\";\n\nexport type RadioProps = {\n /**\n * If `true`, the Radio is selected\n */\n isChecked?: boolean;\n /**\n * If `true`, the Radio is disabled\n */\n isDisabled?: boolean;\n /**\n * If `true`, the Radio has an invalid value\n */\n isInvalid?: boolean;\n /**\n * The label text for the Radio\n */\n label: string;\n /**\n * The name attribute of the Radio\n */\n name?: string;\n /**\n * The value attribute of the Radio\n */\n value: string;\n};\n\nconst Radio = ({\n isChecked,\n isDisabled,\n isInvalid,\n label,\n name,\n value,\n}: RadioProps) => (\n <FormControlLabel\n checked={isChecked}\n className={isInvalid ? \"Mui-error\" : \"\"}\n control={<MuiRadio />}\n disabled={isDisabled}\n label={label}\n name={name}\n value={value}\n />\n);\n\nconst MemoizedRadio = memo(Radio);\nMemoizedRadio.displayName = \"Radio\";\n\nexport { MemoizedRadio as Radio };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;
|
|
1
|
+
{"version":3,"file":"Radio.js","names":["memo","jsx","_jsx","Radio","_ref","isChecked","isDisabled","isInvalid","label","name","testId","value","_FormControlLabel","checked","className","control","_Radio","disabled","MemoizedRadio","displayName"],"sources":["../src/Radio.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 { Radio as MuiRadio } from \"@mui/material\";\nimport { memo } from \"react\";\n\nimport { FormControlLabel } from \"@mui/material\";\n\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type RadioProps = {\n /**\n * If `true`, the Radio is selected\n */\n isChecked?: boolean;\n /**\n * If `true`, the Radio is disabled\n */\n isDisabled?: boolean;\n /**\n * If `true`, the Radio has an invalid value\n */\n isInvalid?: boolean;\n /**\n * The label text for the Radio\n */\n label: string;\n /**\n * The name attribute of the Radio\n */\n name?: string;\n /**\n * The value attribute of the Radio\n */\n value: string;\n} & SeleniumProps;\n\nconst Radio = ({\n isChecked,\n isDisabled,\n isInvalid,\n label,\n name,\n testId,\n value,\n}: RadioProps) => (\n <FormControlLabel\n checked={isChecked}\n className={isInvalid ? \"Mui-error\" : \"\"}\n control={<MuiRadio />}\n data-se={testId}\n disabled={isDisabled}\n label={label}\n name={name}\n value={value}\n />\n);\n\nconst MemoizedRadio = memo(Radio);\nMemoizedRadio.displayName = \"Radio\";\n\nexport { MemoizedRadio as Radio };\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAASA,IAAI,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAiC7B,MAAMC,KAAK,GAAGC,IAAA;EAAA,IAAC;IACbC,SAAS;IACTC,UAAU;IACVC,SAAS;IACTC,KAAK;IACLC,IAAI;IACJC,MAAM;IACNC;EACU,CAAC,GAAAP,IAAA;EAAA,OACXF,IAAA,CAAAU,iBAAA;IACEC,OAAO,EAAER,SAAU;IACnBS,SAAS,EAAEP,SAAS,GAAG,WAAW,GAAG,EAAG;IACxCQ,OAAO,EAAEb,IAAA,CAAAc,MAAA,IAAW,CAAE;IACtB,WAASN,MAAO;IAChBO,QAAQ,EAAEX,UAAW;IACrBE,KAAK,EAAEA,KAAM;IACbC,IAAI,EAAEA,IAAK;IACXE,KAAK,EAAEA;EAAM,CACd,CAAC;AAAA,CACH;AAED,MAAMO,aAAa,GAAGlB,IAAI,CAACG,KAAK,CAAC;AACjCe,aAAa,CAACC,WAAW,GAAG,OAAO;AAEnC,SAASD,aAAa,IAAIf,KAAK"}
|
package/dist/RadioGroup.js
CHANGED
|
@@ -22,7 +22,9 @@ const RadioGroup = _ref => {
|
|
|
22
22
|
id: idOverride,
|
|
23
23
|
isDisabled,
|
|
24
24
|
label,
|
|
25
|
+
name: nameOverride,
|
|
25
26
|
onChange,
|
|
27
|
+
testId,
|
|
26
28
|
value
|
|
27
29
|
} = _ref;
|
|
28
30
|
const renderFieldComponent = useCallback(_ref2 => {
|
|
@@ -32,14 +34,15 @@ const RadioGroup = _ref => {
|
|
|
32
34
|
} = _ref2;
|
|
33
35
|
return _jsx(_RadioGroup, {
|
|
34
36
|
"aria-describedby": ariaDescribedBy,
|
|
37
|
+
"data-se": testId,
|
|
35
38
|
defaultValue: defaultValue,
|
|
36
39
|
id: id,
|
|
37
|
-
name: id,
|
|
40
|
+
name: nameOverride ?? id,
|
|
38
41
|
onChange: onChange,
|
|
39
42
|
value: value,
|
|
40
43
|
children: children
|
|
41
44
|
});
|
|
42
|
-
}, [children, defaultValue, onChange, value]);
|
|
45
|
+
}, [children, defaultValue, nameOverride, onChange, testId, value]);
|
|
43
46
|
return _jsx(Field, {
|
|
44
47
|
errorMessage: errorMessage,
|
|
45
48
|
fieldType: "group",
|
package/dist/RadioGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","names":["memo","useCallback","Field","jsx","_jsx","RadioGroup","_ref","children","defaultValue","errorMessage","hint","id","idOverride","isDisabled","label","onChange","value","renderFieldComponent","_ref2","ariaDescribedBy","_RadioGroup","
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","names":["memo","useCallback","Field","jsx","_jsx","RadioGroup","_ref","children","defaultValue","errorMessage","hint","id","idOverride","isDisabled","label","name","nameOverride","onChange","testId","value","renderFieldComponent","_ref2","ariaDescribedBy","_RadioGroup","fieldType","hasVisibleLabel","MemoizedRadioGroup","displayName"],"sources":["../src/RadioGroup.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 { RadioGroup as MuiRadioGroup } from \"@mui/material\";\nimport { ChangeEventHandler, memo, ReactElement, useCallback } from \"react\";\n\nimport { Radio, RadioProps } from \"./Radio\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type RadioGroupProps = {\n /**\n * The Radio components within the group. Must include two or more.\n */\n children: Array<ReactElement<typeof Radio>>;\n /**\n * The text value of the Radio that should be selected by default\n */\n defaultValue?: string;\n /**\n * The error text for an invalid RadioGroup\n */\n errorMessage?: string;\n /**\n * Optional hint text\n */\n hint?: string;\n /**\n * The id of the `input` element.\n */\n id?: string;\n /**\n * Disables the whole RadioGroup\n */\n isDisabled?: boolean;\n /**\n * The text label for the RadioGroup\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 * Listen for changes in the browser that change `value`\n */\n onChange?: ChangeEventHandler<EventTarget>;\n /**\n * The `value` on the selected Radio\n */\n value?: RadioProps[\"value\"];\n} & SeleniumProps;\n\nconst RadioGroup = ({\n children,\n defaultValue,\n errorMessage,\n hint,\n id: idOverride,\n isDisabled,\n label,\n name: nameOverride,\n onChange,\n testId,\n value,\n}: RadioGroupProps) => {\n const renderFieldComponent = useCallback(\n ({ ariaDescribedBy, id }) => (\n <MuiRadioGroup\n aria-describedby={ariaDescribedBy}\n data-se={testId}\n defaultValue={defaultValue}\n id={id}\n name={nameOverride ?? id}\n onChange={onChange}\n value={value}\n >\n {children}\n </MuiRadioGroup>\n ),\n [children, defaultValue, nameOverride, onChange, testId, value]\n );\n\n return (\n <Field\n errorMessage={errorMessage}\n fieldType=\"group\"\n hasVisibleLabel={false}\n hint={hint}\n id={idOverride}\n isDisabled={isDisabled}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedRadioGroup = memo(RadioGroup);\nMemoizedRadioGroup.displayName = \"RadioGroup\";\n\nexport { MemoizedRadioGroup as RadioGroup };\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA,SAA6BA,IAAI,EAAgBC,WAAW,QAAQ,OAAO;AAAC,SAGnEC,KAAK;AAAA,SAAAC,GAAA,IAAAC,IAAA;AA8Cd,MAAMC,UAAU,GAAGC,IAAA,IAYI;EAAA,IAZH;IAClBC,QAAQ;IACRC,YAAY;IACZC,YAAY;IACZC,IAAI;IACJC,EAAE,EAAEC,UAAU;IACdC,UAAU;IACVC,KAAK;IACLC,IAAI,EAAEC,YAAY;IAClBC,QAAQ;IACRC,MAAM;IACNC;EACe,CAAC,GAAAb,IAAA;EAChB,MAAMc,oBAAoB,GAAGnB,WAAW,CACtCoB,KAAA;IAAA,IAAC;MAAEC,eAAe;MAAEX;IAAG,CAAC,GAAAU,KAAA;IAAA,OACtBjB,IAAA,CAAAmB,WAAA;MACE,oBAAkBD,eAAgB;MAClC,WAASJ,MAAO;MAChBV,YAAY,EAAEA,YAAa;MAC3BG,EAAE,EAAEA,EAAG;MACPI,IAAI,EAAEC,YAAY,IAAIL,EAAG;MACzBM,QAAQ,EAAEA,QAAS;MACnBE,KAAK,EAAEA,KAAM;MAAAZ,QAAA,EAEZA;IAAQ,CACI,CAAC;EAAA,CACjB,EACD,CAACA,QAAQ,EAAEC,YAAY,EAAEQ,YAAY,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,CAChE,CAAC;EAED,OACEf,IAAA,CAACF,KAAK;IACJO,YAAY,EAAEA,YAAa;IAC3Be,SAAS,EAAC,OAAO;IACjBC,eAAe,EAAE,KAAM;IACvBf,IAAI,EAAEA,IAAK;IACXC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,KAAK,EAAEA,KAAM;IACbM,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMM,kBAAkB,GAAG1B,IAAI,CAACK,UAAU,CAAC;AAC3CqB,kBAAkB,CAACC,WAAW,GAAG,YAAY;AAE7C,SAASD,kBAAkB,IAAIrB,UAAU"}
|
package/dist/SearchField.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _InputBase from "@mui/material/InputBase";
|
|
2
2
|
import _InputAdornment from "@mui/material/InputAdornment";
|
|
3
|
+
import _IconButton from "@mui/material/IconButton";
|
|
3
4
|
/*!
|
|
4
5
|
* Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
5
6
|
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
@@ -16,7 +17,6 @@ import { useState, useEffect } from "react";
|
|
|
16
17
|
import { forwardRef, memo, useCallback } from "react";
|
|
17
18
|
import { CloseCircleFilledIcon, SearchIcon } from "./icons.generated/index.js";
|
|
18
19
|
import { Field } from "./Field.js";
|
|
19
|
-
import { Button } from "./Button.js";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
21
|
const SearchField = forwardRef((_ref, ref) => {
|
|
22
22
|
let {
|
|
@@ -25,11 +25,13 @@ const SearchField = forwardRef((_ref, ref) => {
|
|
|
25
25
|
id: idOverride,
|
|
26
26
|
isDisabled = false,
|
|
27
27
|
label,
|
|
28
|
+
name: nameOverride,
|
|
28
29
|
onChange: onChangeProp,
|
|
29
30
|
onFocus,
|
|
30
31
|
onBlur,
|
|
31
32
|
onClear: onClearProp,
|
|
32
33
|
placeholder,
|
|
34
|
+
testId,
|
|
33
35
|
value: controlledValue
|
|
34
36
|
} = _ref;
|
|
35
37
|
const [uncontrolledValue, setUncontrolledValue] = useState("");
|
|
@@ -55,23 +57,22 @@ const SearchField = forwardRef((_ref, ref) => {
|
|
|
55
57
|
"aria-describedby": ariaDescribedBy,
|
|
56
58
|
autoComplete: autoCompleteType,
|
|
57
59
|
autoFocus: hasInitialFocus,
|
|
60
|
+
"data-se": testId,
|
|
58
61
|
endAdornment: uncontrolledValue && _jsx(_InputAdornment, {
|
|
59
62
|
position: "end",
|
|
60
|
-
children: _jsx(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
label: "",
|
|
63
|
+
children: _jsx(_IconButton, {
|
|
64
|
+
"aria-label": "Clear",
|
|
65
|
+
disabled: isDisabled,
|
|
64
66
|
onClick: onClear,
|
|
65
67
|
size: "small",
|
|
66
|
-
|
|
67
|
-
variant: "floating"
|
|
68
|
+
children: _jsx(CloseCircleFilledIcon, {})
|
|
68
69
|
})
|
|
69
70
|
}),
|
|
70
71
|
id: id,
|
|
71
|
-
name: id,
|
|
72
|
+
name: nameOverride ?? id,
|
|
73
|
+
onBlur: onBlur,
|
|
72
74
|
onChange: onChange,
|
|
73
75
|
onFocus: onFocus,
|
|
74
|
-
onBlur: onBlur,
|
|
75
76
|
placeholder: placeholder,
|
|
76
77
|
ref: ref,
|
|
77
78
|
startAdornment: _jsx(_InputAdornment, {
|
|
@@ -81,7 +82,7 @@ const SearchField = forwardRef((_ref, ref) => {
|
|
|
81
82
|
type: "search",
|
|
82
83
|
value: controlledValue === undefined ? uncontrolledValue : controlledValue
|
|
83
84
|
});
|
|
84
|
-
}, [autoCompleteType, hasInitialFocus, isDisabled,
|
|
85
|
+
}, [autoCompleteType, controlledValue, hasInitialFocus, isDisabled, nameOverride, onBlur, onChange, onClear, onFocus, placeholder, ref, testId, uncontrolledValue]);
|
|
85
86
|
return _jsx(Field, {
|
|
86
87
|
fieldType: "single",
|
|
87
88
|
hasVisibleLabel: false,
|
package/dist/SearchField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchField.js","names":["useState","useEffect","forwardRef","memo","useCallback","CloseCircleFilledIcon","SearchIcon","Field","
|
|
1
|
+
{"version":3,"file":"SearchField.js","names":["useState","useEffect","forwardRef","memo","useCallback","CloseCircleFilledIcon","SearchIcon","Field","jsx","_jsx","SearchField","_ref","ref","autoCompleteType","hasInitialFocus","id","idOverride","isDisabled","label","name","nameOverride","onChange","onChangeProp","onFocus","onBlur","onClear","onClearProp","placeholder","testId","value","controlledValue","uncontrolledValue","setUncontrolledValue","event","currentTarget","undefined","renderFieldComponent","_ref2","ariaDescribedBy","_InputBase","autoComplete","autoFocus","endAdornment","_InputAdornment","position","children","_IconButton","disabled","onClick","size","startAdornment","type","fieldType","hasVisibleLabel","isOptional","MemoizedSearchField","displayName"],"sources":["../src/SearchField.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 { useState, useEffect } from \"react\";\nimport { InputAdornment, InputBase, IconButton } from \"@mui/material\";\nimport {\n ChangeEventHandler,\n FocusEventHandler,\n forwardRef,\n InputHTMLAttributes,\n memo,\n useCallback,\n} from \"react\";\n\nimport { CloseCircleFilledIcon, SearchIcon } from \"./icons.generated\";\nimport { Field } from \"./Field\";\nimport type { SeleniumProps } from \"./SeleniumProps\";\n\nexport type SearchFieldProps = {\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?: InputHTMLAttributes<HTMLInputElement>[\"autoComplete\"];\n /**\n * If `true`, the component will receive focus automatically.\n */\n hasInitialFocus?: boolean;\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 * This label won't show up visually, but it's required for accessibility.\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 clear button is pressed.\n */\n onClear?: () => void;\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 SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(\n (\n {\n autoCompleteType,\n hasInitialFocus,\n id: idOverride,\n isDisabled = false,\n label,\n name: nameOverride,\n onChange: onChangeProp,\n onFocus,\n onBlur,\n onClear: onClearProp,\n placeholder,\n testId,\n value: controlledValue,\n },\n ref\n ) => {\n const [uncontrolledValue, setUncontrolledValue] = useState(\"\");\n\n const onChange: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement> =\n useCallback(\n (event) => {\n setUncontrolledValue(event.currentTarget.value);\n onChangeProp?.(event);\n },\n [onChangeProp]\n );\n\n const onClear = useCallback(() => {\n setUncontrolledValue(\"\");\n onClearProp?.();\n }, [onClearProp]);\n\n useEffect(() => {\n if (controlledValue !== undefined) {\n setUncontrolledValue(controlledValue);\n }\n }, [controlledValue]);\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 uncontrolledValue && (\n <InputAdornment position=\"end\">\n <IconButton\n aria-label=\"Clear\"\n disabled={isDisabled}\n onClick={onClear}\n size=\"small\"\n >\n <CloseCircleFilledIcon />\n </IconButton>\n </InputAdornment>\n )\n }\n id={id}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n ref={ref}\n startAdornment={\n <InputAdornment position=\"start\">\n <SearchIcon />\n </InputAdornment>\n }\n type=\"search\"\n value={\n controlledValue === undefined ? uncontrolledValue : controlledValue\n }\n />\n ),\n [\n autoCompleteType,\n controlledValue,\n hasInitialFocus,\n isDisabled,\n nameOverride,\n onBlur,\n onChange,\n onClear,\n onFocus,\n placeholder,\n ref,\n testId,\n uncontrolledValue,\n ]\n );\n\n return (\n <Field\n fieldType=\"single\"\n hasVisibleLabel={false}\n id={idOverride}\n isDisabled={isDisabled}\n isOptional={true}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n }\n);\n\nconst MemoizedSearchField = memo(SearchField);\nMemoizedSearchField.displayName = \"SearchField\";\n\nexport { MemoizedSearchField as SearchField };\n"],"mappings":"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"}
|
package/dist/Select.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _Select from "@mui/material/Select";
|
|
2
2
|
import _MenuItem from "@mui/material/MenuItem";
|
|
3
|
+
import _Checkbox from "@mui/material/Checkbox";
|
|
3
4
|
import _ListSubheader from "@mui/material/ListSubheader";
|
|
4
5
|
import _Box from "@mui/material/Box";
|
|
5
6
|
import _Chip from "@mui/material/Chip";
|
|
@@ -15,12 +16,11 @@ import _Chip from "@mui/material/Chip";
|
|
|
15
16
|
* See the License for the specific language governing permissions and limitations under the License.
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
|
-
import {
|
|
19
|
-
import { Checkbox } from "./Checkbox.js";
|
|
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,
|
|
@@ -29,10 +29,12 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
29
29
|
isMultiSelect = false,
|
|
30
30
|
isOptional = false,
|
|
31
31
|
label,
|
|
32
|
+
name: nameOverride,
|
|
32
33
|
onBlur,
|
|
33
34
|
onChange: onChangeProp,
|
|
34
35
|
onFocus,
|
|
35
36
|
value,
|
|
37
|
+
testId,
|
|
36
38
|
options
|
|
37
39
|
} = _ref;
|
|
38
40
|
if (typeof value === "undefined") {
|
|
@@ -54,20 +56,15 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
54
56
|
onChangeProp(event, child);
|
|
55
57
|
}
|
|
56
58
|
}, [isMultiSelect, onChangeProp, setSelectedValue]);
|
|
57
|
-
const normalizedOptions = options.map(option => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
text: option,
|
|
67
|
-
value: option,
|
|
68
|
-
type: "option"
|
|
69
|
-
};
|
|
70
|
-
});
|
|
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]);
|
|
71
68
|
const renderValue = useCallback(selected => {
|
|
72
69
|
if (typeof selected === "string") {
|
|
73
70
|
return undefined;
|
|
@@ -88,7 +85,7 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
88
85
|
children: renderedChips
|
|
89
86
|
});
|
|
90
87
|
}, [normalizedOptions]);
|
|
91
|
-
const children = normalizedOptions.map(option => {
|
|
88
|
+
const children = useMemo(() => normalizedOptions.map(option => {
|
|
92
89
|
if (option.type === "heading") {
|
|
93
90
|
return _jsx(_ListSubheader, {
|
|
94
91
|
children: option.text
|
|
@@ -96,24 +93,31 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
96
93
|
}
|
|
97
94
|
return _jsxs(_MenuItem, {
|
|
98
95
|
value: option.value,
|
|
99
|
-
children: [isMultiSelect && _jsx(
|
|
100
|
-
|
|
96
|
+
children: [isMultiSelect && _jsx(_Checkbox, {
|
|
97
|
+
checked: selectedValue.includes(option.value)
|
|
101
98
|
}), option.text]
|
|
102
99
|
}, option.value);
|
|
103
|
-
});
|
|
104
|
-
const renderFieldComponent = useCallback(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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]);
|
|
117
121
|
return _jsx(Field, {
|
|
118
122
|
errorMessage: errorMessage,
|
|
119
123
|
fieldType: "single",
|
|
@@ -125,7 +129,7 @@ const Select = forwardRef((_ref, ref) => {
|
|
|
125
129
|
label: label,
|
|
126
130
|
renderFieldComponent: renderFieldComponent
|
|
127
131
|
});
|
|
128
|
-
}
|
|
132
|
+
};
|
|
129
133
|
const MemoizedSelect = memo(Select);
|
|
130
134
|
MemoizedSelect.displayName = "Select";
|
|
131
135
|
export { MemoizedSelect as Select };
|