@keycloakify/keycloak-account-ui 25.0.1-rc.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/KeycloakAccountUi.d.ts +3 -0
- package/KeycloakAccountUi.js +29 -0
- package/KeycloakAccountUi.js.map +1 -0
- package/LICENSE +2 -0
- package/README.md +39 -0
- package/account-security/AccountRow.d.ts +8 -0
- package/account-security/AccountRow.js +36 -0
- package/account-security/AccountRow.js.map +1 -0
- package/account-security/DeviceActivity.d.ts +2 -0
- package/account-security/DeviceActivity.js +70 -0
- package/account-security/DeviceActivity.js.map +1 -0
- package/account-security/LinkedAccounts.d.ts +2 -0
- package/account-security/LinkedAccounts.js +25 -0
- package/account-security/LinkedAccounts.js.map +1 -0
- package/account-security/SigningIn.d.ts +2 -0
- package/account-security/SigningIn.js +65 -0
- package/account-security/SigningIn.js.map +1 -0
- package/api/constants.d.ts +2 -0
- package/api/constants.js +3 -0
- package/api/constants.js.map +1 -0
- package/api/methods.d.ts +25 -0
- package/api/methods.js +73 -0
- package/api/methods.js.map +1 -0
- package/api/parse-links.d.ts +5 -0
- package/api/parse-links.js +23 -0
- package/api/parse-links.js.map +1 -0
- package/api/parse-response.d.ts +3 -0
- package/api/parse-response.js +40 -0
- package/api/parse-response.js.map +1 -0
- package/api/representations.d.ts +202 -0
- package/api/representations.js +3 -0
- package/api/representations.js.map +1 -0
- package/api/request.d.ts +12 -0
- package/api/request.js +33 -0
- package/api/request.js.map +1 -0
- package/api.d.ts +13 -0
- package/api.js +52 -0
- package/api.js.map +1 -0
- package/applications/Applications.d.ts +2 -0
- package/applications/Applications.js +52 -0
- package/applications/Applications.js.map +1 -0
- package/components/datalist/EmptyRow.d.ts +5 -0
- package/components/datalist/EmptyRow.js +20 -0
- package/components/datalist/EmptyRow.js.map +1 -0
- package/components/page/Page.d.ts +7 -0
- package/components/page/Page.js +6 -0
- package/components/page/Page.js.map +1 -0
- package/content/ContentComponent.d.ts +2 -0
- package/content/ContentComponent.js +36 -0
- package/content/ContentComponent.js.map +1 -0
- package/content/fetchContent.d.ts +3 -0
- package/content/fetchContent.js +6 -0
- package/content/fetchContent.js.map +1 -0
- package/environment.d.ts +25 -0
- package/environment.js +3 -0
- package/environment.js.map +1 -0
- package/groups/Groups.d.ts +2 -0
- package/groups/Groups.js +45 -0
- package/groups/Groups.js.map +1 -0
- package/i18n.d.ts +4 -0
- package/i18n.js +31 -0
- package/i18n.js.map +1 -0
- package/oid4vci/Oid4Vci.d.ts +2 -0
- package/oid4vci/Oid4Vci.js +54 -0
- package/oid4vci/Oid4Vci.js.map +1 -0
- package/package.json +428 -0
- package/personal-info/PersonalInfo.d.ts +2 -0
- package/personal-info/PersonalInfo.js +63 -0
- package/personal-info/PersonalInfo.js.map +1 -0
- package/resources/EditTheResource.d.ts +8 -0
- package/resources/EditTheResource.js +36 -0
- package/resources/EditTheResource.js.map +1 -0
- package/resources/PermissionRequest.d.ts +7 -0
- package/resources/PermissionRequest.js +39 -0
- package/resources/PermissionRequest.js.map +1 -0
- package/resources/ResourceToolbar.d.ts +12 -0
- package/resources/ResourceToolbar.js +24 -0
- package/resources/ResourceToolbar.js.map +1 -0
- package/resources/Resources.d.ts +2 -0
- package/resources/Resources.js +13 -0
- package/resources/Resources.js.map +1 -0
- package/resources/ResourcesTab.d.ts +5 -0
- package/resources/ResourcesTab.js +103 -0
- package/resources/ResourcesTab.js.map +1 -0
- package/resources/ShareTheResource.d.ts +9 -0
- package/resources/ShareTheResource.js +70 -0
- package/resources/ShareTheResource.js.map +1 -0
- package/resources/SharedWith.d.ts +6 -0
- package/resources/SharedWith.js +8 -0
- package/resources/SharedWith.js.map +1 -0
- package/root/ErrorPage.d.ts +5 -0
- package/root/ErrorPage.js +29 -0
- package/root/ErrorPage.js.map +1 -0
- package/root/Header.d.ts +1 -0
- package/root/Header.js +31 -0
- package/root/Header.js.map +1 -0
- package/root/PageNav.d.ts +23 -0
- package/root/PageNav.js +44 -0
- package/root/PageNav.js.map +1 -0
- package/root/Root.d.ts +1 -0
- package/root/Root.js +12 -0
- package/root/Root.js.map +1 -0
- package/root/header.module.css +3 -0
- package/routes.d.ts +15 -0
- package/routes.js +69 -0
- package/routes.js.map +1 -0
- package/src/KeycloakAccountUi.tsx +36 -0
- package/src/account-security/AccountRow.tsx +136 -0
- package/src/account-security/DeviceActivity.tsx +253 -0
- package/src/account-security/LinkedAccounts.tsx +86 -0
- package/src/account-security/SigningIn.tsx +251 -0
- package/src/api/constants.ts +2 -0
- package/src/api/methods.ts +158 -0
- package/src/api/parse-links.ts +28 -0
- package/src/api/parse-response.ts +53 -0
- package/src/api/representations.ts +219 -0
- package/src/api/request.ts +74 -0
- package/src/api.ts +127 -0
- package/src/applications/Applications.tsx +282 -0
- package/src/components/datalist/EmptyRow.tsx +26 -0
- package/src/components/page/Page.tsx +27 -0
- package/src/content/ContentComponent.tsx +62 -0
- package/src/content/fetchContent.ts +13 -0
- package/src/environment.ts +31 -0
- package/src/global.d.ts +4 -0
- package/src/groups/Groups.tsx +142 -0
- package/src/i18n.ts +47 -0
- package/src/i18next.d.ts +10 -0
- package/src/oid4vci/Oid4Vci.tsx +136 -0
- package/src/personal-info/PersonalInfo.tsx +184 -0
- package/src/resources/EditTheResource.tsx +101 -0
- package/src/resources/PermissionRequest.tsx +129 -0
- package/src/resources/ResourceToolbar.tsx +87 -0
- package/src/resources/Resources.tsx +39 -0
- package/src/resources/ResourcesTab.tsx +410 -0
- package/src/resources/ShareTheResource.tsx +217 -0
- package/src/resources/SharedWith.tsx +26 -0
- package/src/root/ErrorPage.tsx +65 -0
- package/src/root/Header.tsx +62 -0
- package/src/root/PageNav.tsx +154 -0
- package/src/root/Root.tsx +20 -0
- package/src/root/header.module.css +3 -0
- package/src/routes.tsx +85 -0
- package/src/ui-shared/alerts/Alerts.tsx +86 -0
- package/src/ui-shared/buttons/FormSubmitButton.tsx +47 -0
- package/src/ui-shared/context/ErrorPage.tsx +60 -0
- package/src/ui-shared/context/HelpContext.tsx +30 -0
- package/src/ui-shared/context/KeycloakContext.tsx +97 -0
- package/src/ui-shared/context/environment.ts +50 -0
- package/src/ui-shared/continue-cancel/ContinueCancelModal.tsx +75 -0
- package/src/ui-shared/controls/FormErrorText.tsx +23 -0
- package/src/ui-shared/controls/FormLabel.tsx +40 -0
- package/src/ui-shared/controls/HelpItem.tsx +43 -0
- package/src/ui-shared/controls/NumberControl.tsx +89 -0
- package/src/ui-shared/controls/PasswordControl.tsx +71 -0
- package/src/ui-shared/controls/PasswordInput.tsx +50 -0
- package/src/ui-shared/controls/SwitchControl.tsx +67 -0
- package/src/ui-shared/controls/TextAreaControl.tsx +60 -0
- package/src/ui-shared/controls/TextControl.tsx +74 -0
- package/src/ui-shared/controls/keycloak-text-area/KeycloakTextArea.tsx +23 -0
- package/src/ui-shared/controls/select-control/SelectControl.tsx +75 -0
- package/src/ui-shared/controls/select-control/SingleSelectControl.tsx +107 -0
- package/src/ui-shared/controls/select-control/TypeaheadSelectControl.tsx +283 -0
- package/src/ui-shared/icons/IconMapper.tsx +63 -0
- package/src/ui-shared/index.ts +1 -0
- package/src/ui-shared/main.ts +62 -0
- package/src/ui-shared/masthead/DefaultAvatar.tsx +109 -0
- package/src/ui-shared/masthead/KeycloakDropdown.tsx +47 -0
- package/src/ui-shared/masthead/Masthead.tsx +145 -0
- package/src/ui-shared/scroll-form/FormPanel.tsx +29 -0
- package/src/ui-shared/scroll-form/FormTitle.tsx +28 -0
- package/src/ui-shared/scroll-form/ScrollForm.tsx +98 -0
- package/src/ui-shared/scroll-form/ScrollPanel.tsx +21 -0
- package/src/ui-shared/scroll-form/form-title.module.css +4 -0
- package/src/ui-shared/scroll-form/scroll-form.module.css +8 -0
- package/src/ui-shared/select/KeycloakSelect.tsx +49 -0
- package/src/ui-shared/select/SingleSelect.tsx +85 -0
- package/src/ui-shared/select/TypeaheadSelect.tsx +196 -0
- package/src/ui-shared/user-profile/LocaleSelector.tsx +51 -0
- package/src/ui-shared/user-profile/MultiInputComponent.tsx +146 -0
- package/src/ui-shared/user-profile/OptionsComponent.tsx +60 -0
- package/src/ui-shared/user-profile/SelectComponent.tsx +106 -0
- package/src/ui-shared/user-profile/TextAreaComponent.tsx +23 -0
- package/src/ui-shared/user-profile/TextComponent.tsx +30 -0
- package/src/ui-shared/user-profile/UserProfileFields.tsx +246 -0
- package/src/ui-shared/user-profile/UserProfileGroup.tsx +70 -0
- package/src/ui-shared/user-profile/utils.ts +161 -0
- package/src/ui-shared/utils/createNamedContext.ts +11 -0
- package/src/ui-shared/utils/isDefined.ts +3 -0
- package/src/ui-shared/utils/useRequiredContext.ts +24 -0
- package/src/ui-shared/utils/useStorageItem.ts +51 -0
- package/src/ui-shared/utils/useStoredState.ts +38 -0
- package/src/utils/formatDate.ts +18 -0
- package/src/utils/isRecord.ts +2 -0
- package/src/utils/joinPath.ts +22 -0
- package/src/utils/usePromise.ts +74 -0
- package/ui-shared/alerts/Alerts.d.ts +17 -0
- package/ui-shared/alerts/Alerts.js +27 -0
- package/ui-shared/alerts/Alerts.js.map +1 -0
- package/ui-shared/buttons/FormSubmitButton.d.ts +10 -0
- package/ui-shared/buttons/FormSubmitButton.js +26 -0
- package/ui-shared/buttons/FormSubmitButton.js.map +1 -0
- package/ui-shared/context/ErrorPage.d.ts +5 -0
- package/ui-shared/context/ErrorPage.js +24 -0
- package/ui-shared/context/ErrorPage.js.map +1 -0
- package/ui-shared/context/HelpContext.d.ts +9 -0
- package/ui-shared/context/HelpContext.js +14 -0
- package/ui-shared/context/HelpContext.js.map +1 -0
- package/ui-shared/context/KeycloakContext.d.ts +12 -0
- package/ui-shared/context/KeycloakContext.js +53 -0
- package/ui-shared/context/KeycloakContext.js.map +1 -0
- package/ui-shared/context/environment.d.ts +36 -0
- package/ui-shared/context/environment.js +27 -0
- package/ui-shared/context/environment.js.map +1 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.d.ts +15 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.js +27 -0
- package/ui-shared/continue-cancel/ContinueCancelModal.js.map +1 -0
- package/ui-shared/controls/FormErrorText.d.ts +5 -0
- package/ui-shared/controls/FormErrorText.js +19 -0
- package/ui-shared/controls/FormErrorText.js.map +1 -0
- package/ui-shared/controls/FormLabel.d.ts +13 -0
- package/ui-shared/controls/FormLabel.js +20 -0
- package/ui-shared/controls/FormLabel.js.map +1 -0
- package/ui-shared/controls/HelpItem.d.ts +9 -0
- package/ui-shared/controls/HelpItem.js +9 -0
- package/ui-shared/controls/HelpItem.js.map +1 -0
- package/ui-shared/controls/NumberControl.d.ts +13 -0
- package/ui-shared/controls/NumberControl.js +32 -0
- package/ui-shared/controls/NumberControl.js.map +1 -0
- package/ui-shared/controls/PasswordControl.d.ts +9 -0
- package/ui-shared/controls/PasswordControl.js +25 -0
- package/ui-shared/controls/PasswordControl.js.map +1 -0
- package/ui-shared/controls/PasswordInput.d.ts +7 -0
- package/ui-shared/controls/PasswordInput.js +25 -0
- package/ui-shared/controls/PasswordInput.js.map +1 -0
- package/ui-shared/controls/SwitchControl.d.ts +11 -0
- package/ui-shared/controls/SwitchControl.js +29 -0
- package/ui-shared/controls/SwitchControl.js.map +1 -0
- package/ui-shared/controls/TextAreaControl.d.ts +8 -0
- package/ui-shared/controls/TextAreaControl.js +12 -0
- package/ui-shared/controls/TextAreaControl.js.map +1 -0
- package/ui-shared/controls/TextControl.d.ts +10 -0
- package/ui-shared/controls/TextControl.js +24 -0
- package/ui-shared/controls/TextControl.js.map +1 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.d.ts +4 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.js +5 -0
- package/ui-shared/controls/keycloak-text-area/KeycloakTextArea.js.map +1 -0
- package/ui-shared/controls/select-control/SelectControl.d.ts +31 -0
- package/ui-shared/controls/select-control/SelectControl.js +28 -0
- package/ui-shared/controls/select-control/SelectControl.js.map +1 -0
- package/ui-shared/controls/select-control/SingleSelectControl.d.ts +3 -0
- package/ui-shared/controls/select-control/SingleSelectControl.js +41 -0
- package/ui-shared/controls/select-control/SingleSelectControl.js.map +1 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.d.ts +3 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.js +138 -0
- package/ui-shared/controls/select-control/TypeaheadSelectControl.js.map +1 -0
- package/ui-shared/icons/IconMapper.d.ts +5 -0
- package/ui-shared/icons/IconMapper.js +40 -0
- package/ui-shared/icons/IconMapper.js.map +1 -0
- package/ui-shared/index.d.ts +1 -0
- package/ui-shared/index.js +2 -0
- package/ui-shared/index.js.map +1 -0
- package/ui-shared/main.d.ts +31 -0
- package/ui-shared/main.js +29 -0
- package/ui-shared/main.js.map +1 -0
- package/ui-shared/masthead/DefaultAvatar.d.ts +7 -0
- package/ui-shared/masthead/DefaultAvatar.js +26 -0
- package/ui-shared/masthead/DefaultAvatar.js.map +1 -0
- package/ui-shared/masthead/KeycloakDropdown.d.ts +10 -0
- package/ui-shared/masthead/KeycloakDropdown.js +23 -0
- package/ui-shared/masthead/KeycloakDropdown.js.map +1 -0
- package/ui-shared/masthead/Masthead.d.ts +22 -0
- package/ui-shared/masthead/Masthead.js +55 -0
- package/ui-shared/masthead/Masthead.js.map +1 -0
- package/ui-shared/scroll-form/FormPanel.d.ts +8 -0
- package/ui-shared/scroll-form/FormPanel.js +9 -0
- package/ui-shared/scroll-form/FormPanel.js.map +1 -0
- package/ui-shared/scroll-form/FormTitle.d.ts +8 -0
- package/ui-shared/scroll-form/FormTitle.js +19 -0
- package/ui-shared/scroll-form/FormTitle.js.map +1 -0
- package/ui-shared/scroll-form/ScrollForm.d.ts +15 -0
- package/ui-shared/scroll-form/ScrollForm.js +38 -0
- package/ui-shared/scroll-form/ScrollForm.js.map +1 -0
- package/ui-shared/scroll-form/ScrollPanel.d.ts +7 -0
- package/ui-shared/scroll-form/ScrollPanel.js +18 -0
- package/ui-shared/scroll-form/ScrollPanel.js.map +1 -0
- package/ui-shared/select/KeycloakSelect.d.ts +30 -0
- package/ui-shared/select/KeycloakSelect.js +31 -0
- package/ui-shared/select/KeycloakSelect.js.map +1 -0
- package/ui-shared/select/SingleSelect.d.ts +4 -0
- package/ui-shared/select/SingleSelect.js +46 -0
- package/ui-shared/select/SingleSelect.js.map +1 -0
- package/ui-shared/select/TypeaheadSelect.d.ts +2 -0
- package/ui-shared/select/TypeaheadSelect.js +96 -0
- package/ui-shared/select/TypeaheadSelect.js.map +1 -0
- package/ui-shared/user-profile/LocaleSelector.d.ts +7 -0
- package/ui-shared/user-profile/LocaleSelector.js +28 -0
- package/ui-shared/user-profile/LocaleSelector.js.map +1 -0
- package/ui-shared/user-profile/MultiInputComponent.d.ts +15 -0
- package/ui-shared/user-profile/MultiInputComponent.js +61 -0
- package/ui-shared/user-profile/MultiInputComponent.js.map +1 -0
- package/ui-shared/user-profile/OptionsComponent.d.ts +2 -0
- package/ui-shared/user-profile/OptionsComponent.js +28 -0
- package/ui-shared/user-profile/OptionsComponent.js.map +1 -0
- package/ui-shared/user-profile/SelectComponent.d.ts +2 -0
- package/ui-shared/user-profile/SelectComponent.js +55 -0
- package/ui-shared/user-profile/SelectComponent.js.map +1 -0
- package/ui-shared/user-profile/TextAreaComponent.d.ts +2 -0
- package/ui-shared/user-profile/TextAreaComponent.js +11 -0
- package/ui-shared/user-profile/TextAreaComponent.js.map +1 -0
- package/ui-shared/user-profile/TextComponent.d.ts +2 -0
- package/ui-shared/user-profile/TextComponent.js +14 -0
- package/ui-shared/user-profile/TextComponent.js.map +1 -0
- package/ui-shared/user-profile/UserProfileFields.d.ts +39 -0
- package/ui-shared/user-profile/UserProfileFields.js +112 -0
- package/ui-shared/user-profile/UserProfileFields.js.map +1 -0
- package/ui-shared/user-profile/UserProfileGroup.d.ts +12 -0
- package/ui-shared/user-profile/UserProfileGroup.js +15 -0
- package/ui-shared/user-profile/UserProfileGroup.js.map +1 -0
- package/ui-shared/user-profile/utils.d.ts +32 -0
- package/ui-shared/user-profile/utils.js +79 -0
- package/ui-shared/user-profile/utils.js.map +1 -0
- package/ui-shared/utils/createNamedContext.d.ts +3 -0
- package/ui-shared/utils/createNamedContext.js +7 -0
- package/ui-shared/utils/createNamedContext.js.map +1 -0
- package/ui-shared/utils/isDefined.d.ts +1 -0
- package/ui-shared/utils/isDefined.js +4 -0
- package/ui-shared/utils/isDefined.js.map +1 -0
- package/ui-shared/utils/useRequiredContext.d.ts +9 -0
- package/ui-shared/utils/useRequiredContext.js +17 -0
- package/ui-shared/utils/useRequiredContext.js.map +1 -0
- package/ui-shared/utils/useStorageItem.d.ts +10 -0
- package/ui-shared/utils/useStorageItem.js +40 -0
- package/ui-shared/utils/useStorageItem.js.map +1 -0
- package/ui-shared/utils/useStoredState.d.ts +13 -0
- package/ui-shared/utils/useStoredState.js +21 -0
- package/ui-shared/utils/useStoredState.js.map +1 -0
- package/utils/formatDate.d.ts +4 -0
- package/utils/formatDate.js +12 -0
- package/utils/formatDate.js.map +1 -0
- package/utils/isRecord.d.ts +1 -0
- package/utils/isRecord.js +2 -0
- package/utils/isRecord.js.map +1 -0
- package/utils/joinPath.d.ts +1 -0
- package/utils/joinPath.js +18 -0
- package/utils/joinPath.js.map +1 -0
- package/utils/usePromise.d.ts +41 -0
- package/utils/usePromise.js +55 -0
- package/utils/usePromise.js.map +1 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Avatar,
|
|
3
|
+
AvatarProps,
|
|
4
|
+
Brand,
|
|
5
|
+
BrandProps,
|
|
6
|
+
DropdownItem,
|
|
7
|
+
} from "@patternfly/react-core";
|
|
8
|
+
import {
|
|
9
|
+
PageHeader,
|
|
10
|
+
PageHeaderProps,
|
|
11
|
+
PageHeaderTools,
|
|
12
|
+
PageHeaderToolsGroup,
|
|
13
|
+
PageHeaderToolsItem,
|
|
14
|
+
} from "@patternfly/react-core/deprecated";
|
|
15
|
+
import { TFunction } from "i18next";
|
|
16
|
+
import Keycloak, { type KeycloakTokenParsed } from "keycloak-js";
|
|
17
|
+
import { ReactNode } from "react";
|
|
18
|
+
import { useTranslation } from "react-i18next";
|
|
19
|
+
import { DefaultAvatar } from "@keycloakify/keycloak-account-ui/ui-shared/masthead/DefaultAvatar";
|
|
20
|
+
import { KeycloakDropdown } from "@keycloakify/keycloak-account-ui/ui-shared/masthead/KeycloakDropdown";
|
|
21
|
+
|
|
22
|
+
function loggedInUserName(
|
|
23
|
+
token: KeycloakTokenParsed | undefined,
|
|
24
|
+
t: TFunction,
|
|
25
|
+
) {
|
|
26
|
+
if (!token) {
|
|
27
|
+
return t("unknownUser");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const givenName = token.given_name;
|
|
31
|
+
const familyName = token.family_name;
|
|
32
|
+
const preferredUsername = token.preferred_username;
|
|
33
|
+
|
|
34
|
+
if (givenName && familyName) {
|
|
35
|
+
return t("fullName", { givenName, familyName });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return givenName || familyName || preferredUsername || t("unknownUser");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type BrandLogo = BrandProps & {
|
|
42
|
+
href: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type KeycloakMastheadProps = PageHeaderProps & {
|
|
46
|
+
keycloak: Keycloak;
|
|
47
|
+
brand: BrandLogo;
|
|
48
|
+
avatar?: AvatarProps;
|
|
49
|
+
features?: {
|
|
50
|
+
hasLogout?: boolean;
|
|
51
|
+
hasManageAccount?: boolean;
|
|
52
|
+
hasUsername?: boolean;
|
|
53
|
+
};
|
|
54
|
+
kebabDropdownItems?: ReactNode[];
|
|
55
|
+
dropdownItems?: ReactNode[];
|
|
56
|
+
toolbarItems?: ReactNode[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const KeycloakMasthead = ({
|
|
60
|
+
keycloak,
|
|
61
|
+
brand: { href: brandHref, ...brandProps },
|
|
62
|
+
avatar,
|
|
63
|
+
features: {
|
|
64
|
+
hasLogout = true,
|
|
65
|
+
hasManageAccount = true,
|
|
66
|
+
hasUsername = true,
|
|
67
|
+
} = {},
|
|
68
|
+
kebabDropdownItems,
|
|
69
|
+
dropdownItems = [],
|
|
70
|
+
toolbarItems,
|
|
71
|
+
...rest
|
|
72
|
+
}: KeycloakMastheadProps) => {
|
|
73
|
+
const { t } = useTranslation();
|
|
74
|
+
const extraItems = [];
|
|
75
|
+
if (hasManageAccount) {
|
|
76
|
+
extraItems.push(
|
|
77
|
+
<DropdownItem
|
|
78
|
+
key="manageAccount"
|
|
79
|
+
onClick={() => keycloak.accountManagement()}
|
|
80
|
+
>
|
|
81
|
+
{t("manageAccount")}
|
|
82
|
+
</DropdownItem>,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (hasLogout) {
|
|
86
|
+
extraItems.push(
|
|
87
|
+
<DropdownItem key="signOut" onClick={() => keycloak.logout()}>
|
|
88
|
+
{t("signOut")}
|
|
89
|
+
</DropdownItem>,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const picture = keycloak.idTokenParsed?.picture;
|
|
94
|
+
return (
|
|
95
|
+
<PageHeader
|
|
96
|
+
{...rest}
|
|
97
|
+
logo={<Brand {...brandProps} />}
|
|
98
|
+
logoProps={{ href: brandHref }}
|
|
99
|
+
headerTools={
|
|
100
|
+
<PageHeaderTools>
|
|
101
|
+
<PageHeaderToolsGroup>
|
|
102
|
+
<PageHeaderToolsItem
|
|
103
|
+
visibility={{
|
|
104
|
+
md: "hidden",
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<KeycloakDropdown
|
|
108
|
+
data-testid="options-kebab"
|
|
109
|
+
isKebab
|
|
110
|
+
dropDownItems={[
|
|
111
|
+
...(kebabDropdownItems || dropdownItems),
|
|
112
|
+
extraItems,
|
|
113
|
+
]}
|
|
114
|
+
/>
|
|
115
|
+
</PageHeaderToolsItem>
|
|
116
|
+
<PageHeaderToolsItem>{toolbarItems}</PageHeaderToolsItem>
|
|
117
|
+
<PageHeaderToolsItem
|
|
118
|
+
visibility={{
|
|
119
|
+
default: "hidden",
|
|
120
|
+
md: "visible",
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<KeycloakDropdown
|
|
124
|
+
data-testid="options"
|
|
125
|
+
dropDownItems={[...dropdownItems, extraItems]}
|
|
126
|
+
title={
|
|
127
|
+
hasUsername
|
|
128
|
+
? loggedInUserName(keycloak.idTokenParsed, t)
|
|
129
|
+
: undefined
|
|
130
|
+
}
|
|
131
|
+
/>
|
|
132
|
+
</PageHeaderToolsItem>
|
|
133
|
+
</PageHeaderToolsGroup>
|
|
134
|
+
{picture || avatar?.src ? (
|
|
135
|
+
<Avatar {...{ src: picture, alt: t("avatar"), ...avatar }} />
|
|
136
|
+
) : (
|
|
137
|
+
<DefaultAvatar {...avatar} />
|
|
138
|
+
)}
|
|
139
|
+
</PageHeaderTools>
|
|
140
|
+
}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default KeycloakMasthead;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Card, CardBody, CardHeader, CardTitle } from "@patternfly/react-core";
|
|
2
|
+
import { PropsWithChildren, useId } from "react";
|
|
3
|
+
import { FormTitle } from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/FormTitle";
|
|
4
|
+
|
|
5
|
+
type FormPanelProps = {
|
|
6
|
+
title: string;
|
|
7
|
+
scrollId?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const FormPanel = ({
|
|
12
|
+
title,
|
|
13
|
+
children,
|
|
14
|
+
scrollId,
|
|
15
|
+
className,
|
|
16
|
+
}: PropsWithChildren<FormPanelProps>) => {
|
|
17
|
+
const id = useId();
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Card id={id} className={className} isFlat>
|
|
21
|
+
<CardHeader className="kc-form-panel__header">
|
|
22
|
+
<CardTitle tabIndex={0}>
|
|
23
|
+
<FormTitle id={scrollId} title={title} />
|
|
24
|
+
</CardTitle>
|
|
25
|
+
</CardHeader>
|
|
26
|
+
<CardBody className="kc-form-panel__body">{children}</CardBody>
|
|
27
|
+
</Card>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Title, TitleProps } from "@patternfly/react-core";
|
|
2
|
+
|
|
3
|
+
import style from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/form-title.module.css";
|
|
4
|
+
|
|
5
|
+
type FormTitleProps = Omit<TitleProps, "headingLevel"> & {
|
|
6
|
+
id?: string;
|
|
7
|
+
title: string;
|
|
8
|
+
headingLevel?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const FormTitle = ({
|
|
12
|
+
id,
|
|
13
|
+
title,
|
|
14
|
+
headingLevel = "h1",
|
|
15
|
+
size = "xl",
|
|
16
|
+
...rest
|
|
17
|
+
}: FormTitleProps) => (
|
|
18
|
+
<Title
|
|
19
|
+
headingLevel={headingLevel}
|
|
20
|
+
size={size}
|
|
21
|
+
className={style.title}
|
|
22
|
+
id={id}
|
|
23
|
+
tabIndex={0} // so that jumpLink sends focus to the section for a11y
|
|
24
|
+
{...rest}
|
|
25
|
+
>
|
|
26
|
+
{title}
|
|
27
|
+
</Title>
|
|
28
|
+
);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Grid,
|
|
3
|
+
GridItem,
|
|
4
|
+
GridProps,
|
|
5
|
+
JumpLinks,
|
|
6
|
+
JumpLinksItem,
|
|
7
|
+
PageSection,
|
|
8
|
+
} from "@patternfly/react-core";
|
|
9
|
+
import { Fragment, ReactNode, useMemo } from "react";
|
|
10
|
+
import { FormPanel } from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/FormPanel";
|
|
11
|
+
import { ScrollPanel } from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/ScrollPanel";
|
|
12
|
+
|
|
13
|
+
import style from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/scroll-form.module.css";
|
|
14
|
+
|
|
15
|
+
export const mainPageContentId = "kc-main-content-page-container";
|
|
16
|
+
|
|
17
|
+
type ScrollSection = {
|
|
18
|
+
title: string;
|
|
19
|
+
panel: ReactNode;
|
|
20
|
+
isHidden?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type ScrollFormProps = GridProps & {
|
|
24
|
+
label: string;
|
|
25
|
+
sections: ScrollSection[];
|
|
26
|
+
borders?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const spacesToHyphens = (string: string): string => {
|
|
30
|
+
return string.replace(/\s+/g, "-");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const ScrollForm = ({
|
|
34
|
+
label,
|
|
35
|
+
sections,
|
|
36
|
+
borders = false,
|
|
37
|
+
...rest
|
|
38
|
+
}: ScrollFormProps) => {
|
|
39
|
+
const shownSections = useMemo(
|
|
40
|
+
() => sections.filter(({ isHidden }) => !isHidden),
|
|
41
|
+
[sections],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Grid hasGutter {...rest}>
|
|
46
|
+
<GridItem md={8} sm={12}>
|
|
47
|
+
{shownSections.map(({ title, panel }) => {
|
|
48
|
+
const scrollId = spacesToHyphens(title.toLowerCase());
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Fragment key={title}>
|
|
52
|
+
{borders ? (
|
|
53
|
+
<FormPanel
|
|
54
|
+
scrollId={scrollId}
|
|
55
|
+
title={title}
|
|
56
|
+
className={style.panel}
|
|
57
|
+
>
|
|
58
|
+
{panel}
|
|
59
|
+
</FormPanel>
|
|
60
|
+
) : (
|
|
61
|
+
<ScrollPanel scrollId={scrollId} title={title}>
|
|
62
|
+
{panel}
|
|
63
|
+
</ScrollPanel>
|
|
64
|
+
)}
|
|
65
|
+
</Fragment>
|
|
66
|
+
);
|
|
67
|
+
})}
|
|
68
|
+
</GridItem>
|
|
69
|
+
<GridItem md={4} sm={12} order={{ default: "-1", md: "1" }}>
|
|
70
|
+
<PageSection className={style.sticky}>
|
|
71
|
+
<JumpLinks
|
|
72
|
+
isVertical
|
|
73
|
+
// scrollableSelector has to point to the id of the element whose scrollTop changes
|
|
74
|
+
// to scroll the entire main section, it has to be the pf-v5-c-page__main
|
|
75
|
+
scrollableSelector={`#${mainPageContentId}`}
|
|
76
|
+
label={label}
|
|
77
|
+
offset={100}
|
|
78
|
+
>
|
|
79
|
+
{shownSections.map(({ title }) => {
|
|
80
|
+
const scrollId = spacesToHyphens(title.toLowerCase());
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
// note that JumpLinks currently does not work with spaces in the href
|
|
84
|
+
<JumpLinksItem
|
|
85
|
+
key={title}
|
|
86
|
+
href={`#${scrollId}`}
|
|
87
|
+
data-testid={`jump-link-${scrollId}`}
|
|
88
|
+
>
|
|
89
|
+
{title}
|
|
90
|
+
</JumpLinksItem>
|
|
91
|
+
);
|
|
92
|
+
})}
|
|
93
|
+
</JumpLinks>
|
|
94
|
+
</PageSection>
|
|
95
|
+
</GridItem>
|
|
96
|
+
</Grid>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-no-useless-fragment */
|
|
2
|
+
// See: https://github.com/i18next/react-i18next/issues/1543
|
|
3
|
+
import { HTMLProps } from "react";
|
|
4
|
+
import { FormTitle } from "@keycloakify/keycloak-account-ui/ui-shared/scroll-form/FormTitle";
|
|
5
|
+
|
|
6
|
+
type ScrollPanelProps = HTMLProps<HTMLFormElement> & {
|
|
7
|
+
title: string;
|
|
8
|
+
scrollId: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const ScrollPanel = (props: ScrollPanelProps) => {
|
|
12
|
+
const { title, children, scrollId, ...rest } = props;
|
|
13
|
+
return (
|
|
14
|
+
<section {...rest} style={{ marginTop: "var(--pf-v5-global--spacer--lg)" }}>
|
|
15
|
+
<>
|
|
16
|
+
<FormTitle id={scrollId} title={title} />
|
|
17
|
+
{children}
|
|
18
|
+
</>
|
|
19
|
+
</section>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ChipGroupProps, SelectProps } from "@patternfly/react-core";
|
|
2
|
+
import { SingleSelect } from "@keycloakify/keycloak-account-ui/ui-shared/select/SingleSelect";
|
|
3
|
+
import { TypeaheadSelect } from "@keycloakify/keycloak-account-ui/ui-shared/select/TypeaheadSelect";
|
|
4
|
+
|
|
5
|
+
export type Variant = `${SelectVariant}`;
|
|
6
|
+
|
|
7
|
+
export enum SelectVariant {
|
|
8
|
+
single = "single",
|
|
9
|
+
typeahead = "typeahead",
|
|
10
|
+
typeaheadMulti = "typeaheadMulti",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const propertyToString = (prop: string | number | undefined) =>
|
|
14
|
+
typeof prop === "number" ? prop + "px" : prop;
|
|
15
|
+
|
|
16
|
+
export type KeycloakSelectProps<> = Omit<
|
|
17
|
+
SelectProps,
|
|
18
|
+
"name" | "toggle" | "selected" | "onClick" | "onSelect"
|
|
19
|
+
> & {
|
|
20
|
+
toggleId?: string;
|
|
21
|
+
onFilter?: (value: string) => JSX.Element[];
|
|
22
|
+
onClear?: () => void;
|
|
23
|
+
variant?: Variant;
|
|
24
|
+
isDisabled?: boolean;
|
|
25
|
+
menuAppendTo?: string;
|
|
26
|
+
maxHeight?: string | number;
|
|
27
|
+
width?: string | number;
|
|
28
|
+
toggleIcon?: React.ReactElement;
|
|
29
|
+
direction?: "up" | "down";
|
|
30
|
+
placeholderText?: string;
|
|
31
|
+
onSelect?: (value: string | number | object) => void;
|
|
32
|
+
onToggle: (val: boolean) => void;
|
|
33
|
+
selections?: string | string[] | number | number[];
|
|
34
|
+
validated?: "success" | "warning" | "error" | "default";
|
|
35
|
+
typeAheadAriaLabel?: string;
|
|
36
|
+
chipGroupProps?: Omit<ChipGroupProps, "children" | "ref">;
|
|
37
|
+
chipGroupComponent?: React.ReactNode;
|
|
38
|
+
footer?: React.ReactNode;
|
|
39
|
+
};
|
|
40
|
+
export const KeycloakSelect = ({
|
|
41
|
+
variant = SelectVariant.single,
|
|
42
|
+
...rest
|
|
43
|
+
}: KeycloakSelectProps) => {
|
|
44
|
+
if (variant === SelectVariant.single) {
|
|
45
|
+
return <SingleSelect {...rest} />;
|
|
46
|
+
} else {
|
|
47
|
+
return <TypeaheadSelect {...rest} variant={variant} />;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MenuToggle,
|
|
3
|
+
Select,
|
|
4
|
+
SelectList,
|
|
5
|
+
SelectOptionProps,
|
|
6
|
+
} from "@patternfly/react-core";
|
|
7
|
+
import { Children, useRef, useState } from "react";
|
|
8
|
+
import { KeycloakSelectProps, propertyToString } from "@keycloakify/keycloak-account-ui/ui-shared/select/KeycloakSelect";
|
|
9
|
+
|
|
10
|
+
type SingleSelectProps = Omit<KeycloakSelectProps, "variant">;
|
|
11
|
+
|
|
12
|
+
export const SingleSelect = ({
|
|
13
|
+
toggleId,
|
|
14
|
+
onToggle,
|
|
15
|
+
onSelect,
|
|
16
|
+
selections,
|
|
17
|
+
isOpen,
|
|
18
|
+
menuAppendTo,
|
|
19
|
+
direction,
|
|
20
|
+
width,
|
|
21
|
+
maxHeight,
|
|
22
|
+
toggleIcon,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: SingleSelectProps) => {
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const ref = useRef<HTMLElement>();
|
|
29
|
+
const toggle = () => {
|
|
30
|
+
setOpen(!open);
|
|
31
|
+
onToggle(!open);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const append = () => {
|
|
35
|
+
if (menuAppendTo === "parent") {
|
|
36
|
+
return ref.current?.parentElement || "inline";
|
|
37
|
+
}
|
|
38
|
+
return "inline";
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const childArray = Children.toArray(
|
|
42
|
+
children,
|
|
43
|
+
) as React.ReactElement<SelectOptionProps>[];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Select
|
|
47
|
+
ref={ref}
|
|
48
|
+
maxMenuHeight={propertyToString(maxHeight)}
|
|
49
|
+
isScrollable
|
|
50
|
+
popperProps={{
|
|
51
|
+
appendTo: append(),
|
|
52
|
+
direction,
|
|
53
|
+
width: propertyToString(width),
|
|
54
|
+
}}
|
|
55
|
+
{...props}
|
|
56
|
+
onClick={toggle}
|
|
57
|
+
onOpenChange={() => setOpen(false)}
|
|
58
|
+
selected={selections}
|
|
59
|
+
onSelect={(_, value) => {
|
|
60
|
+
onSelect?.(value || "");
|
|
61
|
+
toggle();
|
|
62
|
+
}}
|
|
63
|
+
toggle={(ref) => (
|
|
64
|
+
<MenuToggle
|
|
65
|
+
id={toggleId}
|
|
66
|
+
ref={ref}
|
|
67
|
+
className={className}
|
|
68
|
+
onClick={toggle}
|
|
69
|
+
isExpanded={isOpen}
|
|
70
|
+
aria-label={props["aria-label"]}
|
|
71
|
+
icon={toggleIcon}
|
|
72
|
+
isFullWidth
|
|
73
|
+
>
|
|
74
|
+
{childArray.find((c) => c.props.value === selections)?.props
|
|
75
|
+
.children ||
|
|
76
|
+
selections ||
|
|
77
|
+
props["aria-label"]}
|
|
78
|
+
</MenuToggle>
|
|
79
|
+
)}
|
|
80
|
+
isOpen={isOpen}
|
|
81
|
+
>
|
|
82
|
+
<SelectList>{children}</SelectList>
|
|
83
|
+
</Select>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Chip,
|
|
4
|
+
ChipGroup,
|
|
5
|
+
MenuFooter,
|
|
6
|
+
MenuToggle,
|
|
7
|
+
MenuToggleStatus,
|
|
8
|
+
Select,
|
|
9
|
+
SelectList,
|
|
10
|
+
SelectOptionProps,
|
|
11
|
+
TextInputGroup,
|
|
12
|
+
TextInputGroupMain,
|
|
13
|
+
TextInputGroupUtilities,
|
|
14
|
+
} from "@patternfly/react-core";
|
|
15
|
+
import { TimesIcon } from "@patternfly/react-icons";
|
|
16
|
+
import { Children, useRef, useState } from "react";
|
|
17
|
+
import {
|
|
18
|
+
KeycloakSelectProps,
|
|
19
|
+
SelectVariant,
|
|
20
|
+
propertyToString,
|
|
21
|
+
} from "@keycloakify/keycloak-account-ui/ui-shared/select/KeycloakSelect";
|
|
22
|
+
|
|
23
|
+
export const TypeaheadSelect = ({
|
|
24
|
+
toggleId,
|
|
25
|
+
onSelect,
|
|
26
|
+
onToggle,
|
|
27
|
+
onFilter,
|
|
28
|
+
variant,
|
|
29
|
+
validated,
|
|
30
|
+
placeholderText,
|
|
31
|
+
maxHeight,
|
|
32
|
+
width,
|
|
33
|
+
toggleIcon,
|
|
34
|
+
direction,
|
|
35
|
+
selections,
|
|
36
|
+
typeAheadAriaLabel,
|
|
37
|
+
chipGroupComponent,
|
|
38
|
+
chipGroupProps,
|
|
39
|
+
footer,
|
|
40
|
+
children,
|
|
41
|
+
...rest
|
|
42
|
+
}: KeycloakSelectProps) => {
|
|
43
|
+
const [filterValue, setFilterValue] = useState("");
|
|
44
|
+
const [focusedItemIndex, setFocusedItemIndex] = useState<number>(0);
|
|
45
|
+
const textInputRef = useRef<HTMLInputElement>();
|
|
46
|
+
|
|
47
|
+
const childArray = Children.toArray(
|
|
48
|
+
children,
|
|
49
|
+
) as React.ReactElement<SelectOptionProps>[];
|
|
50
|
+
|
|
51
|
+
const toggle = () => {
|
|
52
|
+
onToggle?.(!rest.isOpen);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onInputKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
56
|
+
const focusedItem = childArray[focusedItemIndex];
|
|
57
|
+
onToggle?.(true);
|
|
58
|
+
|
|
59
|
+
switch (event.key) {
|
|
60
|
+
case "Enter": {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
|
|
63
|
+
if (variant !== SelectVariant.typeaheadMulti) {
|
|
64
|
+
setFilterValue(focusedItem.props.value);
|
|
65
|
+
} else {
|
|
66
|
+
setFilterValue("");
|
|
67
|
+
}
|
|
68
|
+
onSelect?.(focusedItem.props.value);
|
|
69
|
+
onToggle?.(false);
|
|
70
|
+
setFocusedItemIndex(0);
|
|
71
|
+
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case "Escape": {
|
|
75
|
+
onToggle?.(false);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "Backspace": {
|
|
79
|
+
if (variant === SelectVariant.typeahead) {
|
|
80
|
+
onSelect?.("");
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "ArrowUp":
|
|
85
|
+
case "ArrowDown": {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
|
|
88
|
+
let indexToFocus = 0;
|
|
89
|
+
|
|
90
|
+
if (event.key === "ArrowUp") {
|
|
91
|
+
if (focusedItemIndex === 0) {
|
|
92
|
+
indexToFocus = childArray.length - 1;
|
|
93
|
+
} else {
|
|
94
|
+
indexToFocus = focusedItemIndex - 1;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (event.key === "ArrowDown") {
|
|
99
|
+
if (focusedItemIndex === childArray.length - 1) {
|
|
100
|
+
indexToFocus = 0;
|
|
101
|
+
} else {
|
|
102
|
+
indexToFocus = focusedItemIndex + 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
setFocusedItemIndex(indexToFocus);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Select
|
|
114
|
+
{...rest}
|
|
115
|
+
onClick={toggle}
|
|
116
|
+
onOpenChange={() => onToggle?.(false)}
|
|
117
|
+
onSelect={(_, value) => onSelect?.(value || "")}
|
|
118
|
+
maxMenuHeight={propertyToString(maxHeight)}
|
|
119
|
+
popperProps={{ direction, width: propertyToString(width) }}
|
|
120
|
+
toggle={(ref) => (
|
|
121
|
+
<MenuToggle
|
|
122
|
+
ref={ref}
|
|
123
|
+
id={toggleId}
|
|
124
|
+
variant="typeahead"
|
|
125
|
+
onClick={() => onToggle?.(true)}
|
|
126
|
+
icon={toggleIcon}
|
|
127
|
+
isExpanded={rest.isOpen}
|
|
128
|
+
isFullWidth
|
|
129
|
+
status={validated === "error" ? MenuToggleStatus.danger : undefined}
|
|
130
|
+
>
|
|
131
|
+
<TextInputGroup isPlain>
|
|
132
|
+
<TextInputGroupMain
|
|
133
|
+
placeholder={placeholderText}
|
|
134
|
+
value={
|
|
135
|
+
variant === SelectVariant.typeahead && selections
|
|
136
|
+
? (selections as string)
|
|
137
|
+
: filterValue
|
|
138
|
+
}
|
|
139
|
+
onClick={toggle}
|
|
140
|
+
onChange={(_, value) => {
|
|
141
|
+
setFilterValue(value);
|
|
142
|
+
onFilter?.(value);
|
|
143
|
+
}}
|
|
144
|
+
onKeyDown={(event) => onInputKeyDown(event)}
|
|
145
|
+
autoComplete="off"
|
|
146
|
+
innerRef={textInputRef}
|
|
147
|
+
role="combobox"
|
|
148
|
+
isExpanded={rest.isOpen}
|
|
149
|
+
aria-controls="select-typeahead-listbox"
|
|
150
|
+
aria-label={typeAheadAriaLabel}
|
|
151
|
+
>
|
|
152
|
+
{variant === SelectVariant.typeaheadMulti &&
|
|
153
|
+
Array.isArray(selections) &&
|
|
154
|
+
(chipGroupComponent ? (
|
|
155
|
+
chipGroupComponent
|
|
156
|
+
) : (
|
|
157
|
+
<ChipGroup {...chipGroupProps}>
|
|
158
|
+
{selections.map((selection, index: number) => (
|
|
159
|
+
<Chip
|
|
160
|
+
key={index}
|
|
161
|
+
onClick={(ev) => {
|
|
162
|
+
ev.stopPropagation();
|
|
163
|
+
onSelect?.(selection);
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
{selection}
|
|
167
|
+
</Chip>
|
|
168
|
+
))}
|
|
169
|
+
</ChipGroup>
|
|
170
|
+
))}
|
|
171
|
+
</TextInputGroupMain>
|
|
172
|
+
<TextInputGroupUtilities>
|
|
173
|
+
{!!filterValue && (
|
|
174
|
+
<Button
|
|
175
|
+
variant="plain"
|
|
176
|
+
onClick={() => {
|
|
177
|
+
onSelect?.("");
|
|
178
|
+
setFilterValue("");
|
|
179
|
+
onFilter?.("");
|
|
180
|
+
textInputRef?.current?.focus();
|
|
181
|
+
}}
|
|
182
|
+
aria-label="Clear input value"
|
|
183
|
+
>
|
|
184
|
+
<TimesIcon aria-hidden />
|
|
185
|
+
</Button>
|
|
186
|
+
)}
|
|
187
|
+
</TextInputGroupUtilities>
|
|
188
|
+
</TextInputGroup>
|
|
189
|
+
</MenuToggle>
|
|
190
|
+
)}
|
|
191
|
+
>
|
|
192
|
+
<SelectList>{children}</SelectList>
|
|
193
|
+
{footer && <MenuFooter>{footer}</MenuFooter>}
|
|
194
|
+
</Select>
|
|
195
|
+
);
|
|
196
|
+
};
|