@pega/cosmos-react-core 3.0.0-dev.22.0 → 3.0.0-dev.23.2
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/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +18 -10
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +2 -0
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +2 -0
- package/lib/components/AppShell/AppShell.types.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.types.js.map +1 -1
- package/lib/components/AppShell/AppShellContext.d.ts +3 -1
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js +3 -1
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/AppShellSearch.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellSearch.js +11 -3
- package/lib/components/AppShell/AppShellSearch.js.map +1 -1
- package/lib/components/AppShell/AppShellSearch.styles.d.ts +1 -1
- package/lib/components/AppShell/AppShellSearch.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellSearch.styles.js +7 -4
- package/lib/components/AppShell/AppShellSearch.styles.js.map +1 -1
- package/lib/components/AppShell/Drawer.d.ts.map +1 -1
- package/lib/components/AppShell/Drawer.js +6 -2
- package/lib/components/AppShell/Drawer.js.map +1 -1
- package/lib/components/AppShell/NavigationList.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationList.js +4 -3
- package/lib/components/AppShell/NavigationList.js.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.d.ts.map +1 -1
- package/lib/components/AppShell/NavigationListItemWrapper.js +66 -9
- package/lib/components/AppShell/NavigationListItemWrapper.js.map +1 -1
- package/lib/components/Button/BareRoleButton.d.ts.map +1 -1
- package/lib/components/Button/BareRoleButton.js +3 -1
- package/lib/components/Button/BareRoleButton.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.d.ts +3 -1
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/components/DateTime/DurationDisplay.js +3 -3
- package/lib/components/DateTime/DurationDisplay.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +4 -3
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js +6 -7
- package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +8 -7
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/NumberUnit.d.ts.map +1 -1
- package/lib/components/DateTime/Input/Duration/NumberUnit.js +30 -33
- package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/Time.d.ts.map +1 -1
- package/lib/components/DateTime/Input/Duration/Time.js +5 -4
- package/lib/components/DateTime/Input/Duration/Time.js.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +21 -24
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.js +22 -23
- package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +5 -4
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +8 -3
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Input/utils.js +2 -1
- package/lib/components/DateTime/Input/utils.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +15 -5
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Weeks.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Weeks.js +14 -6
- package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
- package/lib/components/DateTime/utils.d.ts +2 -2
- package/lib/components/DateTime/utils.d.ts.map +1 -1
- package/lib/components/DateTime/utils.js +18 -4
- package/lib/components/DateTime/utils.js.map +1 -1
- package/lib/components/HTML/HTML.d.ts.map +1 -1
- package/lib/components/HTML/HTML.js +13 -13
- package/lib/components/HTML/HTML.js.map +1 -1
- package/lib/components/RadioButton/RadioButton.d.ts +3 -1
- package/lib/components/RadioButton/RadioButton.d.ts.map +1 -1
- package/lib/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +11 -17
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useTransitionState.js +1 -1
- package/lib/hooks/useTransitionState.js.map +1 -1
- package/lib/i18n/default.d.ts +11 -17
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +11 -17
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +11 -17
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/init.js +1 -1
- package/lib/init.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useEffect, useRef, useState, useContext } from 'react';
|
|
3
3
|
import { useBreakpoint, useI18n } from '../../hooks';
|
|
4
4
|
import Icon from '../Icon';
|
|
5
5
|
import SearchInput from '../SearchInput';
|
|
6
6
|
import NavigationListItemWrapper from './NavigationListItemWrapper';
|
|
7
|
-
import { StyledAppShellSearchButton, StyledAppshellSearchContainer, StyledAppShellSearchDecoration,
|
|
7
|
+
import { StyledAppShellSearchButton, StyledAppshellSearchContainer, StyledAppShellSearchDecoration, StyledSearch } from './AppShellSearch.styles';
|
|
8
|
+
import AppShellContext from './AppShellContext';
|
|
8
9
|
export const AppShellSearch = ({ collapsed, searchLabel, searchInput }) => {
|
|
9
10
|
const btnElRef = useRef(null);
|
|
11
|
+
const formElRef = useRef(null);
|
|
10
12
|
const searchRef = useRef();
|
|
11
13
|
const t = useI18n();
|
|
12
14
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
13
15
|
const isMediumOrAbove = useBreakpoint('md');
|
|
16
|
+
const { navState, mobileNavOpen } = useContext(AppShellContext);
|
|
14
17
|
const onMenuToggle = state => {
|
|
15
18
|
setMenuOpen(state === 'open');
|
|
16
19
|
};
|
|
@@ -26,6 +29,11 @@ export const AppShellSearch = ({ collapsed, searchLabel, searchInput }) => {
|
|
|
26
29
|
btnElRef.current?.removeEventListener('keydown', onTab);
|
|
27
30
|
};
|
|
28
31
|
}, [searchRef, menuOpen]);
|
|
29
|
-
|
|
32
|
+
const searchFormProps = {
|
|
33
|
+
role: 'search',
|
|
34
|
+
'aria-label': searchLabel,
|
|
35
|
+
onSubmit: (e) => e.preventDefault()
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(StyledSearch, { collapsed: collapsed, isMediumOrAbove: isMediumOrAbove, children: navState === 'closed' && !mobileNavOpen ? (_jsx(NavigationListItemWrapper, { childElementRef: formElRef, label: t('search_placeholder_default'), tooltipLabel: t('search_placeholder_default'), onMenuToggle: onMenuToggle, content: _jsx(StyledAppshellSearchContainer, { children: _jsx(SearchInput, { ...searchInput, resultsPopover: false, ref: searchRef }) }), children: _jsx("form", { ...searchFormProps, ref: formElRef, children: _jsx(StyledAppShellSearchButton, { ref: btnElRef, children: _jsx(StyledAppShellSearchDecoration, { children: _jsx(Icon, { name: 'search' }) }) }) }) })) : (_jsx("form", { ...searchFormProps, children: _jsx(SearchInput, { ...searchInput }) })) }));
|
|
30
38
|
};
|
|
31
39
|
//# sourceMappingURL=AppShellSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellSearch.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellSearch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AppShellSearch.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellSearch.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAa,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAEzC,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,EAC9B,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAQhD,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,EACtD,SAAS,EACT,WAAW,EACX,WAAW,EACZ,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,MAAM,CAAkB,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,MAAM,EAAoB,CAAC;IAC7C,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,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AE,YAAY,EAC1B,OAAO,EACL,KAAC,6BAA6B,cAC5B,KAAC,WAAW,OAAK,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,GAAI,GACzC,YAGlC,kBAAU,eAAe,EAAE,GAAG,EAAE,SAAS,YACvC,KAAC,0BAA0B,IAAC,GAAG,EAAE,QAAQ,YACvC,KAAC,8BAA8B,cAC7B,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG,GACS,GACN,GACxB,GACmB,CAC7B,CAAC,CAAC,CAAC,CACF,kBAAU,eAAe,YACvB,KAAC,WAAW,OAAK,WAAW,GAAI,GAC3B,CACR,GACY,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { FC, useEffect, useRef, useState, useContext, FormEvent } from 'react';\n\nimport { useBreakpoint, useI18n } from '../../hooks';\nimport Icon from '../Icon';\nimport SearchInput from '../SearchInput';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport { AppShellProps, NavListItemWrapperProps } from './AppShell.types';\nimport {\n StyledAppShellSearchButton,\n StyledAppshellSearchContainer,\n StyledAppShellSearchDecoration,\n StyledSearch\n} from './AppShellSearch.styles';\nimport AppShellContext from './AppShellContext';\n\nexport interface AppShellSearchProps {\n collapsed: boolean;\n searchLabel: string;\n searchInput: AppShellProps['searchInput'];\n}\n\nexport const AppShellSearch: FC<AppShellSearchProps> = ({\n collapsed,\n searchLabel,\n searchInput\n}) => {\n const btnElRef = useRef<HTMLButtonElement>(null);\n const formElRef = useRef<HTMLFormElement>(null);\n const searchRef = useRef<HTMLInputElement>();\n const t = useI18n();\n const [menuOpen, setMenuOpen] = useState(false);\n const isMediumOrAbove = useBreakpoint('md');\n const { navState, mobileNavOpen } = useContext(AppShellContext);\n\n const onMenuToggle: NavListItemWrapperProps['onMenuToggle'] = state => {\n setMenuOpen(state === 'open');\n };\n\n useEffect(() => {\n const onTab = (e: KeyboardEvent) => {\n if (menuOpen && e.key === 'Tab') {\n e.preventDefault();\n searchRef.current?.focus();\n }\n };\n btnElRef.current?.addEventListener('keydown', onTab);\n return () => {\n btnElRef.current?.removeEventListener('keydown', onTab);\n };\n }, [searchRef, menuOpen]);\n\n const searchFormProps = {\n role: 'search',\n 'aria-label': searchLabel,\n onSubmit: (e: FormEvent) => e.preventDefault()\n };\n\n return (\n <StyledSearch collapsed={collapsed} isMediumOrAbove={isMediumOrAbove}>\n {navState === 'closed' && !mobileNavOpen ? (\n <NavigationListItemWrapper\n childElementRef={formElRef}\n label={t('search_placeholder_default')}\n tooltipLabel={t('search_placeholder_default')}\n onMenuToggle={onMenuToggle}\n content={\n <StyledAppshellSearchContainer>\n <SearchInput {...searchInput} resultsPopover={false} ref={searchRef} />\n </StyledAppshellSearchContainer>\n }\n >\n <form {...searchFormProps} ref={formElRef}>\n <StyledAppShellSearchButton ref={btnElRef}>\n <StyledAppShellSearchDecoration>\n <Icon name='search' />\n </StyledAppShellSearchDecoration>\n </StyledAppShellSearchButton>\n </form>\n </NavigationListItemWrapper>\n ) : (\n <form {...searchFormProps}>\n <SearchInput {...searchInput} />\n </form>\n )}\n </StyledSearch>\n );\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const StyledSearch: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
2
2
|
collapsed: boolean;
|
|
3
3
|
isMediumOrAbove: boolean;
|
|
4
4
|
}, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellSearch.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellSearch.styles.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"AppShellSearch.styles.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellSearch.styles.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,YAAY;eAA2B,OAAO;qBAAmB,OAAO;SA2JpF,CAAC;AAIF,eAAO,MAAM,8BAA8B,yGAYzC,CAAC;AAIH,eAAO,MAAM,0BAA0B,oNAQtC,CAAC;AAIF,eAAO,MAAM,6BAA6B,yGAIxC,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { StyledText } from '../Text';
|
|
|
12
12
|
import { StyledBackdrop } from '../Backdrop';
|
|
13
13
|
import { StyledEmptyState } from '../EmptyState';
|
|
14
14
|
import { navWidth } from './AppShell.styles';
|
|
15
|
-
export const
|
|
15
|
+
export const StyledSearch = styled.div(({ theme, collapsed, isMediumOrAbove }) => {
|
|
16
16
|
const backgroundColor = tryCatch(() => lighten(0.1, theme.components['app-shell'].nav['background-color']));
|
|
17
17
|
const maxCollapsedSize = theme.components.input.height;
|
|
18
18
|
const activeColor = tryCatch(() => mix(0.85, theme.base.palette.dark, theme.base.palette.interactive));
|
|
@@ -20,13 +20,16 @@ export const StyledSearchForm = styled.form(({ theme, collapsed, isMediumOrAbove
|
|
|
20
20
|
return css `
|
|
21
21
|
flex-shrink: 0;
|
|
22
22
|
justify-content: center;
|
|
23
|
-
padding: ${theme.base.spacing} 0;
|
|
24
23
|
--background-color: ${backgroundColor};
|
|
25
24
|
|
|
26
25
|
${StyledMenuListContainer} {
|
|
27
26
|
background: transparent;
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
> form {
|
|
30
|
+
padding: ${theme.base.spacing} 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
30
33
|
header {
|
|
31
34
|
${StyledText} {
|
|
32
35
|
color: ${theme.base.palette.light};
|
|
@@ -118,7 +121,7 @@ export const StyledSearchForm = styled.form(({ theme, collapsed, isMediumOrAbove
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
> ${StyledSearchInput} {
|
|
124
|
+
form > ${StyledSearchInput} {
|
|
122
125
|
margin: 0 calc((${navWidth} - ${theme.base['hit-area']['mouse-min']}) / 2);
|
|
123
126
|
${collapsed &&
|
|
124
127
|
isMediumOrAbove &&
|
|
@@ -156,7 +159,7 @@ export const StyledSearchForm = styled.form(({ theme, collapsed, isMediumOrAbove
|
|
|
156
159
|
}
|
|
157
160
|
`;
|
|
158
161
|
});
|
|
159
|
-
|
|
162
|
+
StyledSearch.defaultProps = defaultThemeProp;
|
|
160
163
|
export const StyledAppShellSearchDecoration = styled.div(({ theme }) => {
|
|
161
164
|
return css `
|
|
162
165
|
width: ${theme.components.input.height};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppShellSearch.styles.js","sourceRoot":"","sources":["../../../src/components/AppShell/AppShellSearch.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"AppShellSearch.styles.js","sourceRoot":"","sources":["../../../src/components/AppSh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from '../../theme';\nimport { tryCatch } from '../../utils';\nimport BareButton from '../Button/BareButton';\nimport { StyledLink } from '../Link';\nimport { StyledMenuItem } from '../Menu';\nimport { StyledMenu, StyledMenuListContainer } from '../Menu/Menu.styles';\nimport { StyledSearchInput } from '../SearchInput';\nimport {\n StyledCancelButton,\n StyledFiltersPopover,\n StyledResultsPopover,\n StyledSearchButton\n} from '../SearchInput/SearchInput.styles';\nimport { StyledText } from '../Text';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledEmptyState } from '../EmptyState';\n\nimport { navWidth } from './AppShell.styles';\n\nexport const StyledSearch = styled.div<{ collapsed: boolean; isMediumOrAbove: boolean }>(\n ({ theme, collapsed, isMediumOrAbove }) => {\n const backgroundColor = tryCatch(() =>\n lighten(0.1, theme.components['app-shell'].nav['background-color'])\n );\n const maxCollapsedSize = theme.components.input.height;\n const activeColor = tryCatch(() =>\n mix(0.85, theme.base.palette.dark, theme.base.palette.interactive)\n );\n const hoverColor = tryCatch(() =>\n mix(0.95, theme.base.palette.dark, theme.base.palette.interactive)\n );\n\n return css`\n flex-shrink: 0;\n justify-content: center;\n --background-color: ${backgroundColor};\n\n ${StyledMenuListContainer} {\n background: transparent;\n }\n\n > form {\n padding: ${theme.base.spacing} 0;\n }\n\n header {\n ${StyledText} {\n color: ${theme.base.palette.light};\n }\n }\n\n ${StyledBackdrop} {\n background: transparent;\n }\n\n ${StyledEmptyState} {\n span,\n svg {\n color: ${theme.base.palette.light};\n }\n }\n\n ${StyledMenu} {\n &[data-active-scope='true'] [data-current='true'] {\n background-color: ${activeColor};\n }\n\n ${StyledLink} {\n color: ${theme.base.palette.light};\n }\n }\n\n ${StyledMenuItem} {\n color: ${theme.base.palette.light};\n\n li {\n color: ${theme.base.palette.light};\n }\n\n &:focus-within {\n background-color: ${activeColor};\n }\n\n &:hover:not([aria-disabled='true']) {\n background-color: ${hoverColor};\n }\n }\n\n ${StyledFiltersPopover}, ${StyledResultsPopover} {\n background-color: ${backgroundColor};\n z-index: calc(${theme.base['z-index'].backdrop} + 1);\n }\n\n ${StyledSearchInput} {\n border: none;\n background: transparent;\n\n ${StyledSearchButton} {\n transition: borderRadius calc(${theme.base.animation.speed} * 2);\n border: none;\n }\n\n ${StyledCancelButton} {\n color: rgba(255, 255, 255, 0.9);\n }\n\n input {\n border-color: ${backgroundColor};\n\n &::placeholder {\n color: rgba(255, 255, 255, 0.4);\n }\n\n &:focus:not([disabled]) {\n border-color: ${backgroundColor};\n }\n }\n\n input,\n ${StyledSearchButton} {\n background: ${backgroundColor};\n color: rgba(255, 255, 255, 0.7);\n border: transparent;\n\n &:focus-within {\n border: transparent;\n }\n }\n\n &:focus-within {\n ${StyledSearchButton} {\n color: rgba(255, 255, 255, 0.9);\n }\n }\n }\n\n form > ${StyledSearchInput} {\n margin: 0 calc((${navWidth} - ${theme.base['hit-area']['mouse-min']}) / 2);\n ${collapsed &&\n isMediumOrAbove &&\n css`\n overflow: hidden;\n `}\n background: ${backgroundColor};\n\n ${collapsed &&\n isMediumOrAbove &&\n css`\n ${StyledSearchButton} {\n border-radius: calc(\n ${theme.base['border-radius']} * ${theme.components['search-input']['border-radius']}\n );\n height: ${maxCollapsedSize};\n width: ${maxCollapsedSize};\n padding: 0;\n\n > :not(:first-child) {\n display: none;\n }\n }\n\n input {\n padding: 0;\n max-width: 0;\n overflow: hidden;\n }\n\n ${StyledCancelButton} {\n display: none;\n }\n `}\n }\n `;\n }\n);\n\nStyledSearch.defaultProps = defaultThemeProp;\n\nexport const StyledAppShellSearchDecoration = styled.div(({ theme }) => {\n return css`\n width: ${theme.components.input.height};\n height: ${theme.components.input.height};\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--background-color);\n color: rgba(255, 255, 255, 0.7);\n margin: 0 auto;\n `;\n});\n\nStyledAppShellSearchDecoration.defaultProps = defaultThemeProp;\n\nexport const StyledAppShellSearchButton = styled(BareButton)`\n width: 100%;\n &:focus {\n ${StyledAppShellSearchDecoration} {\n outline: none;\n box-shadow: inset ${props => props.theme.base.shadow['focus-inverted']};\n }\n }\n`;\n\nStyledAppShellSearchButton.defaultProps = defaultThemeProp;\n\nexport const StyledAppshellSearchContainer = styled.div(({ theme: { base } }) => {\n return css`\n padding: ${base.spacing};\n `;\n});\n\nStyledAppshellSearchContainer.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,SAAS,EAAE,MAAM,OAAO,CAAC;AAuBtD,UAAU,eAAe;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;sGASE,eAAe;AAPlB,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsB,SAAS,EAAE,MAAM,OAAO,CAAC;AAuBtD,UAAU,eAAe;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;sGASE,eAAe;AAPlB,wBA+EE"}
|
|
@@ -7,7 +7,7 @@ import Flex from '../Flex';
|
|
|
7
7
|
import Icon, { registerIcon } from '../Icon';
|
|
8
8
|
import * as arrowLeftIcon from '../Icon/icons/arrow-left.icon';
|
|
9
9
|
import Text from '../Text';
|
|
10
|
-
import { useDirection, useI18n, useTheme } from '../../hooks';
|
|
10
|
+
import { useDirection, useElement, useI18n, useOuterEvent, useTheme } from '../../hooks';
|
|
11
11
|
import Configuration from '../Configuration';
|
|
12
12
|
import { tryCatch } from '../../utils';
|
|
13
13
|
import AppShellContext from './AppShellContext';
|
|
@@ -16,6 +16,7 @@ registerIcon(arrowLeftIcon);
|
|
|
16
16
|
export default ({ content, header, onDrawerOpen, onDrawerClose, drawerOpen, setDrawerOpen }) => {
|
|
17
17
|
const { focusedImperatively } = useContext(AppShellContext);
|
|
18
18
|
const returnFocusRef = useRef();
|
|
19
|
+
const [drawerEl, setDrawerEl] = useElement();
|
|
19
20
|
const theme = useTheme();
|
|
20
21
|
const backButtonRef = useRef(null);
|
|
21
22
|
const appShellBg = tryCatch(() => lighten(0.1, theme.components['app-shell'].nav['background-color']));
|
|
@@ -33,6 +34,9 @@ export default ({ content, header, onDrawerOpen, onDrawerClose, drawerOpen, setD
|
|
|
33
34
|
};
|
|
34
35
|
const { ltr, rtl } = useDirection();
|
|
35
36
|
const t = useI18n();
|
|
37
|
+
useOuterEvent('click', [drawerEl], () => {
|
|
38
|
+
setDrawerOpen(false);
|
|
39
|
+
});
|
|
36
40
|
return (_jsx(Configuration, { theme: appShellTheme, children: _jsxs(Drawer, { as: StyledDrawerWrapper, position: 'fixed', placement: 'left', open: drawerOpen, nullWhenClosed: true, onBeforeOpen: () => {
|
|
37
41
|
returnFocusRef.current = document.activeElement ?? undefined;
|
|
38
42
|
}, onAfterOpen: () => {
|
|
@@ -44,6 +48,6 @@ export default ({ content, header, onDrawerOpen, onDrawerClose, drawerOpen, setD
|
|
|
44
48
|
}, onAfterClose: () => {
|
|
45
49
|
onDrawerClose?.();
|
|
46
50
|
returnFocusRef.current?.focus();
|
|
47
|
-
}, children: [_jsxs(Flex, { as: StyledDrawerHeading, container: { alignItems: 'center' }, children: [rtl && _jsx(Text, { children: header }), _jsx(BareButton, { as: StyledDrawerBackButton, ref: backButtonRef, onClick: () => setDrawerOpen(false), "aria-label": t('close_noun', [header]), children: _jsx(Icon, { name: 'arrow-left' }) }), ltr && _jsx(Text, { children: header })] }), _jsx(Flex, { as: StyledDrawerListContainer, container: { direction: 'column' }, children: content })] }) }));
|
|
51
|
+
}, ref: setDrawerEl, children: [_jsxs(Flex, { as: StyledDrawerHeading, container: { alignItems: 'center' }, children: [rtl && _jsx(Text, { children: header }), _jsx(BareButton, { as: StyledDrawerBackButton, ref: backButtonRef, onClick: () => setDrawerOpen(false), "aria-label": t('close_noun', [header]), children: _jsx(Icon, { name: 'arrow-left' }) }), ltr && _jsx(Text, { children: header })] }), _jsx(Flex, { as: StyledDrawerListContainer, container: { direction: 'column' }, children: content })] }) }));
|
|
48
52
|
};
|
|
49
53
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/AppShell/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/AppShell/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,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AC,EAAE,EAAE,mBAAmB,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,aAC/D,GAAG,IAAI,KAAC,IAAI,cAAE,MAAM,GAAQ,EAC7B,KAAC,UAAU,IACT,EAAE,EAAE,sBAAsB,EAC1B,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,gBACvB,CAAC,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,CAAC,YAErC,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GACf,EACZ,GAAG,IAAI,KAAC,IAAI,cAAE,MAAM,GAAQ,IACxB,EACP,KAAC,IAAI,IAAC,EAAE,EAAE,yBAAyB,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,YACpE,OAAO,GACH,IACA,GACK,CACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useContext, useRef, ReactNode } from 'react';\nimport { lighten } from 'polished';\n\nimport BareButton from '../Button/BareButton';\nimport Drawer from '../Drawer';\nimport Flex from '../Flex';\nimport Icon, { registerIcon } from '../Icon';\nimport * as arrowLeftIcon from '../Icon/icons/arrow-left.icon';\nimport Text from '../Text';\nimport { useDirection, useElement, useI18n, useOuterEvent, useTheme } from '../../hooks';\nimport Configuration from '../Configuration';\nimport { tryCatch } from '../../utils';\n\nimport AppShellContext from './AppShellContext';\nimport {\n StyledDrawerWrapper,\n StyledDrawerBackButton,\n StyledDrawerHeading,\n StyledDrawerListContainer\n} from './Drawer.styles';\n\nregisterIcon(arrowLeftIcon);\n\ninterface DrawerViewProps {\n content: ReactNode;\n header: string;\n onDrawerOpen?: () => void;\n onDrawerClose?: () => void;\n drawerOpen: boolean;\n setDrawerOpen: (open: boolean) => void;\n}\n\nexport default ({\n content,\n header,\n onDrawerOpen,\n onDrawerClose,\n drawerOpen,\n setDrawerOpen\n}: DrawerViewProps) => {\n const { focusedImperatively } = useContext(AppShellContext);\n const returnFocusRef = useRef<HTMLElement>();\n const [drawerEl, setDrawerEl] = useElement();\n const theme = useTheme();\n\n const backButtonRef = useRef<HTMLButtonElement>(null);\n const appShellBg = tryCatch(() =>\n lighten(0.1, theme.components['app-shell'].nav['background-color'])\n );\n const appShellTheme = {\n base: {\n palette: {\n 'primary-background': appShellBg,\n 'foreground-color': 'rgba(255, 255, 255, 0.7)',\n interactive: theme.base.colors.blue.light\n },\n shadow: {\n focus: theme.base.shadow['focus-inverted']\n }\n }\n };\n\n const { ltr, rtl } = useDirection();\n const t = useI18n();\n\n useOuterEvent('click', [drawerEl], () => {\n setDrawerOpen(false);\n });\n\n return (\n <Configuration theme={appShellTheme}>\n <Drawer\n as={StyledDrawerWrapper}\n position='fixed'\n placement='left'\n open={drawerOpen}\n nullWhenClosed\n onBeforeOpen={() => {\n returnFocusRef.current = (document.activeElement as HTMLElement) ?? undefined;\n }}\n onAfterOpen={() => {\n if (backButtonRef.current && document.activeElement !== backButtonRef.current) {\n focusedImperatively.current = true;\n backButtonRef.current.focus();\n }\n onDrawerOpen?.();\n }}\n onAfterClose={() => {\n onDrawerClose?.();\n returnFocusRef.current?.focus();\n }}\n ref={setDrawerEl}\n >\n <Flex as={StyledDrawerHeading} container={{ alignItems: 'center' }}>\n {rtl && <Text>{header}</Text>}\n <BareButton\n as={StyledDrawerBackButton}\n ref={backButtonRef}\n onClick={() => setDrawerOpen(false)}\n aria-label={t('close_noun', [header])}\n >\n <Icon name='arrow-left' />\n </BareButton>\n {ltr && <Text>{header}</Text>}\n </Flex>\n <Flex as={StyledDrawerListContainer} container={{ direction: 'column' }}>\n {content}\n </Flex>\n </Drawer>\n </Configuration>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,EAAE,EASH,MAAM,OAAO,CAAC;AAsBf,OAAO,EACL,gBAAgB,EAEhB,YAAY,EAEb,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"NavigationList.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,EAAE,EASH,MAAM,OAAO,CAAC;AAsBf,OAAO,EACL,gBAAgB,EAEhB,YAAY,EAEb,MAAM,kBAAkB,CAAC;AAoF1B,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,gBAAgB,CAsHnD,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,YAAY,CA6CpC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -16,6 +16,7 @@ const NavigationMenu = props => {
|
|
|
16
16
|
const { navOpen } = useContext(AppShellContext);
|
|
17
17
|
const { visual, primary, secondary, href, onClick, items, onDismiss, actions, forwardedRef, ...restProps } = props;
|
|
18
18
|
const uid = useUID();
|
|
19
|
+
const { navState } = useContext(AppShellContext);
|
|
19
20
|
const [collapsed, setCollapsed] = useState(true);
|
|
20
21
|
const toggleCollapsed = useCallback((e) => {
|
|
21
22
|
e.stopPropagation();
|
|
@@ -30,11 +31,11 @@ const NavigationMenu = props => {
|
|
|
30
31
|
}, menuRef);
|
|
31
32
|
const { end } = useDirection();
|
|
32
33
|
return (_createElement(StyledNavListItem, { ...restProps, key: primary, nestedListCollapsed: collapsed, ref: menuRef },
|
|
33
|
-
_jsxs(BareButton, { id: uid, ref: itemRef, tabIndex: collapsed ? 0 : -1, "aria-expanded": !collapsed, "aria-controls": `${uid}-menu`, "aria-label": primary, onClick: toggleCollapsed, children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), _jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon })] }),
|
|
34
|
+
_jsxs(BareButton, { id: uid, ref: itemRef, tabIndex: collapsed ? 0 : -1, "aria-expanded": !collapsed, "aria-controls": `${uid}-menu`, "aria-label": primary, onClick: toggleCollapsed, children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), navState === 'open' && _jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon })] }),
|
|
34
35
|
_jsx(NavigationList, { id: `${uid}-menu`, nestedList: true, items: items, collapsed: !navOpen || collapsed })));
|
|
35
36
|
};
|
|
36
37
|
export const NavigationListItem = ({ visual, primary, secondary, href, onClick, items, collapseItems = false, dismissible = false, onDismiss, actions, forwardedRef, isMenuItem, ...restProps }) => {
|
|
37
|
-
const { navOpen } = useContext(AppShellContext);
|
|
38
|
+
const { navOpen, navState } = useContext(AppShellContext);
|
|
38
39
|
const t = useI18n();
|
|
39
40
|
const listItemRef = useConsolidatedRef(forwardedRef);
|
|
40
41
|
const hasItems = (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);
|
|
@@ -80,7 +81,7 @@ export const NavigationListItem = ({ visual, primary, secondary, href, onClick,
|
|
|
80
81
|
return (_createElement(StyledNavListItem, { ...restProps, key: primary, nestedListCollapsed: true },
|
|
81
82
|
_jsx(NavigationListItemWrapper, { tooltipLabel: secondary ? `${primary} ${secondary}` : primary, label: primary, childElementRef: listItemRef, items: actions || items || caseItems, children: _jsxs(Component, { ...compProps, ref: listItemRef, ...(navOpen && isMenuItem
|
|
82
83
|
? { tabIndex: -1, role: 'menuitem', 'aria-label': primary }
|
|
83
|
-
: {}), children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), (hasItems || actions) && _jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon })] }) }),
|
|
84
|
+
: {}), children: [visual, secondary ? (_jsxs(Flex, { container: { direction: 'column', alignItems: 'start' }, children: [_jsx("span", { children: primary }), _jsx(Text, { variant: 'secondary', children: secondary })] })) : (_jsx("span", { children: primary })), (hasItems || actions) && navState === 'open' && (_jsx(Icon, { name: `caret-${end}`, as: StyledAppShellNavIcon }))] }) }),
|
|
84
85
|
dismissible && navOpen && (_jsx(Button, { icon: true, variant: 'simple', as: StyledCaseClose, onClick: onDismiss, "aria-label": t('dismiss_case'), children: _jsx(Icon, { name: 'times' }) })),
|
|
85
86
|
hasItems && (
|
|
86
87
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAGL,cAAc,EAGd,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,OAAO,EACP,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAOpE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,cAAc,GAAqB,KAAK,CAAC,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU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AI,IAAzD,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAAsC,CAAC;QAC3F,CAAC,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n ElementType,\n FC,\n isValidElement,\n MouseEvent,\n MouseEventHandler,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n useTheme,\n useArrows,\n useConsolidatedRef,\n useDirection,\n useUID,\n useI18n,\n useEscape\n} from '../../hooks';\nimport ExpandCollapse from '../ExpandCollapse';\nimport BareButton from '../Button/BareButton';\nimport Flex from '../Flex';\nimport Icon from '../Icon';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport Link from '../Link';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport {\n NavListItemProps,\n NavListItemWrapperProps,\n NavListProps,\n NavMenuProps\n} from './AppShell.types';\nimport {\n StyledNavList,\n StyledNestedNavList,\n StyledAppShellNavIcon,\n StyledNavListItem,\n StyledCaseClose\n} from './AppShell.styles';\nimport AppShellContext from './AppShellContext';\n\nconst NavigationMenu: FC<NavMenuProps> = props => {\n const { navOpen } = useContext(AppShellContext);\n const {\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n onDismiss,\n actions,\n forwardedRef,\n ...restProps\n } = props;\n\n const uid = useUID();\n\n const [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation();\n setCollapsed(state => !state);\n },\n [setCollapsed]\n );\n\n const itemRef = useConsolidatedRef(forwardedRef);\n\n const menuRef = useRef<HTMLLIElement>(null);\n\n useArrows(menuRef, { selector: '[role=\"menuitem\"]', cycle: true });\n\n useEscape(() => {\n setCollapsed(true);\n itemRef.current?.focus();\n }, menuRef);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed={collapsed} ref={menuRef}>\n <BareButton\n id={uid}\n ref={itemRef}\n tabIndex={collapsed ? 0 : -1}\n aria-expanded={!collapsed}\n aria-controls={`${uid}-menu`}\n aria-label={primary}\n onClick={toggleCollapsed}\n >\n {visual}\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />\n </BareButton>\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <NavigationList\n id={`${uid}-menu`}\n nestedList\n items={items}\n collapsed={!navOpen || collapsed}\n />\n </StyledNavListItem>\n );\n};\n\nexport const NavigationListItem: FC<NavListItemProps> = ({\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n collapseItems = false,\n dismissible = false,\n onDismiss,\n actions,\n forwardedRef,\n isMenuItem,\n ...restProps\n}) => {\n const { navOpen } = useContext(AppShellContext);\n\n const t = useI18n();\n const listItemRef = useConsolidatedRef(forwardedRef);\n\n const hasItems =\n (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);\n const compProps: {\n href?: string;\n onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>;\n actions?: NavListItemProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n 'aria-label'?: string;\n } = {\n onClick: (e: MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>) => {\n e.stopPropagation();\n onClick?.(e);\n },\n href,\n 'aria-label': primary\n };\n\n let caseItems: NavListItemWrapperProps['items'] | undefined;\n if (onDismiss) {\n caseItems = [\n {\n primary: t('go_to_noun', [primary]),\n onClick\n },\n {\n primary: t('dismiss_case'),\n onClick: onDismiss\n }\n ];\n }\n\n let Component: ElementType;\n\n if (href) {\n Component = Link;\n } else {\n Component = BareButton;\n }\n\n useEffect(() => {\n if (!navOpen && actions) {\n const node = document.getElementsByTagName('body')[0];\n const clickEvent = document.createEvent('MouseEvent');\n clickEvent.initEvent('mousedown', true, true);\n node.dispatchEvent(clickEvent);\n }\n if (navOpen && isMenuItem && listItemRef.current?.parentElement?.matches(':first-child'))\n listItemRef.current?.focus();\n }, [navOpen]);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed>\n {/* forwardedRef typed as 'any' due to ambiguity of Component element type */}\n <NavigationListItemWrapper\n tooltipLabel={secondary ? `${primary} ${secondary}` : primary}\n label={primary}\n childElementRef={listItemRef}\n items={actions || items || caseItems}\n >\n <Component\n {...compProps}\n ref={listItemRef}\n {...(navOpen && isMenuItem\n ? { tabIndex: -1, role: 'menuitem', 'aria-label': primary }\n : {})}\n >\n {visual}\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n {(hasItems || actions) && <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />}\n </Component>\n </NavigationListItemWrapper>\n {dismissible && navOpen && (\n <Button\n icon\n variant='simple'\n as={StyledCaseClose}\n onClick={onDismiss}\n aria-label={t('dismiss_case')}\n >\n <Icon name='times' />\n </Button>\n )}\n {hasItems && (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n <NavigationList nestedList items={actions || items} collapsed={!navOpen || collapseItems} />\n )}\n </StyledNavListItem>\n );\n};\n\nconst NavigationList: FC<NavListProps> = ({ items = [], nestedList, id, collapsed }) => {\n let Component: ElementType = StyledNavList;\n let ItemComponent: ElementType;\n const { navOpen } = useContext(AppShellContext);\n\n let fwdProps: {\n as?: ElementType;\n forwardedAs?: ElementType;\n nullWhenCollapsed?: boolean;\n transitionSpeed?: string;\n collapsed: boolean;\n } = {\n collapsed: !!collapsed\n };\n\n const {\n base: { animation }\n } = useTheme();\n\n if (nestedList) {\n fwdProps = {\n as: ExpandCollapse,\n forwardedAs: 'ul',\n nullWhenCollapsed: true,\n transitionSpeed: items.length >= 10 ? `calc(2 * ${animation.speed})` : animation.speed,\n ...fwdProps\n };\n\n Component = StyledNestedNavList;\n }\n\n return (\n <Component {...(nestedList ? { role: 'menu', id } : {})} {...fwdProps}>\n {items.map(item => {\n if (isValidElement(item)) return item;\n\n if (item.items && item.items.length > 0 && navOpen) {\n ItemComponent = NavigationMenu;\n } else {\n ItemComponent = NavigationListItem;\n }\n return <ItemComponent key={item.id || item.primary} isMenuItem={nestedList} {...item} />;\n })}\n </Component>\n );\n};\n\nexport default NavigationList;\n"]}
|
|
1
|
+
{"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAGL,cAAc,EAGd,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,MAAM,EACN,OAAO,EACP,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC;AAG/B,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AAOpE,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,cAAc,GAAqB,KAAK,CAAC,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,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O,EAAE;gBAClD,aAAa,GAAG,cAAc,CAAC;aAChC;iBAAM;gBACL,aAAa,GAAG,kBAAkB,CAAC;aACpC;YACD,OAAO,KAAC,aAAa,IAA+B,UAAU,EAAE,UAAU,KAAM,IAAI,IAAzD,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAAsC,CAAC;QAC3F,CAAC,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n ElementType,\n FC,\n isValidElement,\n MouseEvent,\n MouseEventHandler,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\n\nimport {\n useTheme,\n useArrows,\n useConsolidatedRef,\n useDirection,\n useUID,\n useI18n,\n useEscape\n} from '../../hooks';\nimport ExpandCollapse from '../ExpandCollapse';\nimport BareButton from '../Button/BareButton';\nimport Flex from '../Flex';\nimport Icon from '../Icon';\nimport Text from '../Text';\nimport Button from '../Button';\nimport { OmitStrict } from '../../types';\nimport { PopoverProps } from '../Popover';\nimport Link from '../Link';\n\nimport NavigationListItemWrapper from './NavigationListItemWrapper';\nimport {\n NavListItemProps,\n NavListItemWrapperProps,\n NavListProps,\n NavMenuProps\n} from './AppShell.types';\nimport {\n StyledNavList,\n StyledNestedNavList,\n StyledAppShellNavIcon,\n StyledNavListItem,\n StyledCaseClose\n} from './AppShell.styles';\nimport AppShellContext from './AppShellContext';\n\nconst NavigationMenu: FC<NavMenuProps> = props => {\n const { navOpen } = useContext(AppShellContext);\n const {\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n onDismiss,\n actions,\n forwardedRef,\n ...restProps\n } = props;\n\n const uid = useUID();\n\n const { navState } = useContext(AppShellContext);\n const [collapsed, setCollapsed] = useState(true);\n\n const toggleCollapsed = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n e.stopPropagation();\n setCollapsed(state => !state);\n },\n [setCollapsed]\n );\n\n const itemRef = useConsolidatedRef(forwardedRef);\n\n const menuRef = useRef<HTMLLIElement>(null);\n\n useArrows(menuRef, { selector: '[role=\"menuitem\"]', cycle: true });\n\n useEscape(() => {\n setCollapsed(true);\n itemRef.current?.focus();\n }, menuRef);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed={collapsed} ref={menuRef}>\n <BareButton\n id={uid}\n ref={itemRef}\n tabIndex={collapsed ? 0 : -1}\n aria-expanded={!collapsed}\n aria-controls={`${uid}-menu`}\n aria-label={primary}\n onClick={toggleCollapsed}\n >\n {visual}\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n {navState === 'open' && <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />}\n </BareButton>\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <NavigationList\n id={`${uid}-menu`}\n nestedList\n items={items}\n collapsed={!navOpen || collapsed}\n />\n </StyledNavListItem>\n );\n};\n\nexport const NavigationListItem: FC<NavListItemProps> = ({\n visual,\n primary,\n secondary,\n href,\n onClick,\n items,\n collapseItems = false,\n dismissible = false,\n onDismiss,\n actions,\n forwardedRef,\n isMenuItem,\n ...restProps\n}) => {\n const { navOpen, navState } = useContext(AppShellContext);\n const t = useI18n();\n const listItemRef = useConsolidatedRef(forwardedRef);\n\n const hasItems =\n (Array.isArray(items) && items.length > 0) || (Array.isArray(actions) && actions.length > 0);\n const compProps: {\n href?: string;\n onClick?: MouseEventHandler<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>;\n actions?: NavListItemProps['actions'];\n popover?: OmitStrict<PopoverProps, 'show' | 'target' | 'children'>;\n 'aria-label'?: string;\n } = {\n onClick: (e: MouseEvent<HTMLAnchorElement | HTMLButtonElement | HTMLDivElement>) => {\n e.stopPropagation();\n onClick?.(e);\n },\n href,\n 'aria-label': primary\n };\n\n let caseItems: NavListItemWrapperProps['items'] | undefined;\n if (onDismiss) {\n caseItems = [\n {\n primary: t('go_to_noun', [primary]),\n onClick\n },\n {\n primary: t('dismiss_case'),\n onClick: onDismiss\n }\n ];\n }\n\n let Component: ElementType;\n\n if (href) {\n Component = Link;\n } else {\n Component = BareButton;\n }\n\n useEffect(() => {\n if (!navOpen && actions) {\n const node = document.getElementsByTagName('body')[0];\n const clickEvent = document.createEvent('MouseEvent');\n clickEvent.initEvent('mousedown', true, true);\n node.dispatchEvent(clickEvent);\n }\n if (navOpen && isMenuItem && listItemRef.current?.parentElement?.matches(':first-child'))\n listItemRef.current?.focus();\n }, [navOpen]);\n\n const { end } = useDirection();\n\n return (\n <StyledNavListItem {...restProps} key={primary} nestedListCollapsed>\n {/* forwardedRef typed as 'any' due to ambiguity of Component element type */}\n <NavigationListItemWrapper\n tooltipLabel={secondary ? `${primary} ${secondary}` : primary}\n label={primary}\n childElementRef={listItemRef}\n items={actions || items || caseItems}\n >\n <Component\n {...compProps}\n ref={listItemRef}\n {...(navOpen && isMenuItem\n ? { tabIndex: -1, role: 'menuitem', 'aria-label': primary }\n : {})}\n >\n {visual}\n {secondary ? (\n <Flex container={{ direction: 'column', alignItems: 'start' }}>\n <span>{primary}</span>\n <Text variant='secondary'>{secondary}</Text>\n </Flex>\n ) : (\n <span>{primary}</span>\n )}\n {(hasItems || actions) && navState === 'open' && (\n <Icon name={`caret-${end}`} as={StyledAppShellNavIcon} />\n )}\n </Component>\n </NavigationListItemWrapper>\n {dismissible && navOpen && (\n <Button\n icon\n variant='simple'\n as={StyledCaseClose}\n onClick={onDismiss}\n aria-label={t('dismiss_case')}\n >\n <Icon name='times' />\n </Button>\n )}\n {hasItems && (\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n <NavigationList nestedList items={actions || items} collapsed={!navOpen || collapseItems} />\n )}\n </StyledNavListItem>\n );\n};\n\nconst NavigationList: FC<NavListProps> = ({ items = [], nestedList, id, collapsed }) => {\n let Component: ElementType = StyledNavList;\n let ItemComponent: ElementType;\n const { navOpen } = useContext(AppShellContext);\n\n let fwdProps: {\n as?: ElementType;\n forwardedAs?: ElementType;\n nullWhenCollapsed?: boolean;\n transitionSpeed?: string;\n collapsed: boolean;\n } = {\n collapsed: !!collapsed\n };\n\n const {\n base: { animation }\n } = useTheme();\n\n if (nestedList) {\n fwdProps = {\n as: ExpandCollapse,\n forwardedAs: 'ul',\n nullWhenCollapsed: true,\n transitionSpeed: items.length >= 10 ? `calc(2 * ${animation.speed})` : animation.speed,\n ...fwdProps\n };\n\n Component = StyledNestedNavList;\n }\n\n return (\n <Component {...(nestedList ? { role: 'menu', id } : {})} {...fwdProps}>\n {items.map(item => {\n if (isValidElement(item)) return item;\n\n if (item.items && item.items.length > 0 && navOpen) {\n ItemComponent = NavigationMenu;\n } else {\n ItemComponent = NavigationListItem;\n }\n return <ItemComponent key={item.id || item.primary} isMenuItem={nestedList} {...item} />;\n })}\n </Component>\n );\n};\n\nexport default NavigationList;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationListItemWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NavigationListItemWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA2C,MAAM,OAAO,CAAC;AAYpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAsC3D,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,uBAAuB,CA8KhD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -8,8 +8,10 @@ import Popover from '../Popover';
|
|
|
8
8
|
import Menu from '../Menu';
|
|
9
9
|
import { StyledMenuListContainer } from '../Menu/Menu.styles';
|
|
10
10
|
import { defaultThemeProp } from '../../theme';
|
|
11
|
+
import { calculateFontSize } from '../../styles';
|
|
11
12
|
import AppShellContext from './AppShellContext';
|
|
12
13
|
const StyledNavigationPopover = styled.div(({ theme }) => {
|
|
14
|
+
const headingFontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']).s;
|
|
13
15
|
return css `
|
|
14
16
|
background-color: ${theme.components['app-shell'].nav['background-color']};
|
|
15
17
|
&,
|
|
@@ -19,6 +21,12 @@ const StyledNavigationPopover = styled.div(({ theme }) => {
|
|
|
19
21
|
header {
|
|
20
22
|
color: ${theme.base.palette.light};
|
|
21
23
|
border-bottom: none;
|
|
24
|
+
opacity: 0.7;
|
|
25
|
+
|
|
26
|
+
h2 {
|
|
27
|
+
font-weight: ${theme.base['font-weight']['semi-bold']};
|
|
28
|
+
font-size: ${headingFontSize};
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -37,19 +45,38 @@ const StyledNavigationPopover = styled.div(({ theme }) => {
|
|
|
37
45
|
StyledNavigationPopover.defaultProps = defaultThemeProp;
|
|
38
46
|
const ListItemWrapper = props => {
|
|
39
47
|
const { children, childElementRef, label, tooltipLabel, items = [], content, onMenuToggle } = props;
|
|
40
|
-
const { navOpen } = useContext(AppShellContext);
|
|
48
|
+
const { navOpen, collapsedHoverMenus } = useContext(AppShellContext);
|
|
41
49
|
const popoverRef = useRef(null);
|
|
42
50
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
43
51
|
const { end } = useDirection();
|
|
52
|
+
const mousedOverMenu = useRef(false);
|
|
53
|
+
const hidePopoverTimeout = useRef();
|
|
44
54
|
const focusWithin = useFocusWithin([popoverRef, childElementRef]);
|
|
45
55
|
const prevFocusWithin = usePrevious(focusWithin);
|
|
46
|
-
const closePopover = () => {
|
|
56
|
+
const closePopover = (focusChildEl = true) => {
|
|
47
57
|
if (popoverOpen) {
|
|
48
58
|
setPopoverOpen(false);
|
|
49
|
-
|
|
59
|
+
if (focusChildEl) {
|
|
60
|
+
childElementRef.current?.focus();
|
|
61
|
+
}
|
|
62
|
+
if (hidePopoverTimeout.current) {
|
|
63
|
+
clearTimeout(hidePopoverTimeout.current);
|
|
64
|
+
hidePopoverTimeout.current = null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const onMouseEnterContent = () => {
|
|
69
|
+
if (collapsedHoverMenus) {
|
|
70
|
+
mousedOverMenu.current = true;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const onMouseLeaveContent = () => {
|
|
74
|
+
if (mousedOverMenu.current && collapsedHoverMenus) {
|
|
75
|
+
mousedOverMenu.current = false;
|
|
76
|
+
closePopover();
|
|
50
77
|
}
|
|
51
78
|
};
|
|
52
|
-
useOuterEvent('click', [popoverRef], closePopover);
|
|
79
|
+
useOuterEvent('click', [popoverRef], () => closePopover());
|
|
53
80
|
useEffect(() => {
|
|
54
81
|
const onClick = (e) => {
|
|
55
82
|
if ((items.length || content) && !navOpen) {
|
|
@@ -66,13 +93,43 @@ const ListItemWrapper = props => {
|
|
|
66
93
|
setPopoverOpen(true);
|
|
67
94
|
}
|
|
68
95
|
};
|
|
96
|
+
const onMouseOut = (e) => {
|
|
97
|
+
if (hidePopoverTimeout.current) {
|
|
98
|
+
clearTimeout(hidePopoverTimeout.current);
|
|
99
|
+
hidePopoverTimeout.current = null;
|
|
100
|
+
}
|
|
101
|
+
const tag = e.relatedTarget.tagName;
|
|
102
|
+
// If the mouse is mousing out from this nav item onto another nav item
|
|
103
|
+
if (['A', 'BUTTON', 'FORM'].includes(tag)) {
|
|
104
|
+
closePopover(false);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
hidePopoverTimeout.current = window.setTimeout(() => {
|
|
108
|
+
if (!mousedOverMenu.current) {
|
|
109
|
+
closePopover(false);
|
|
110
|
+
}
|
|
111
|
+
}, 1000);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
69
114
|
childElementRef.current?.addEventListener('click', onClick);
|
|
70
115
|
childElementRef.current?.addEventListener('keydown', onKeyDown);
|
|
116
|
+
if (collapsedHoverMenus) {
|
|
117
|
+
childElementRef.current?.addEventListener('mouseenter', onClick);
|
|
118
|
+
childElementRef.current?.addEventListener('mouseleave', onMouseOut);
|
|
119
|
+
}
|
|
71
120
|
return () => {
|
|
72
121
|
childElementRef.current?.removeEventListener('click', onClick);
|
|
73
122
|
childElementRef.current?.removeEventListener('keydown', onKeyDown);
|
|
123
|
+
if (collapsedHoverMenus) {
|
|
124
|
+
childElementRef.current?.removeEventListener('mouseenter', onClick);
|
|
125
|
+
childElementRef.current?.removeEventListener('mouseleave', onMouseOut);
|
|
126
|
+
}
|
|
127
|
+
if (hidePopoverTimeout.current) {
|
|
128
|
+
clearTimeout(hidePopoverTimeout.current);
|
|
129
|
+
hidePopoverTimeout.current = null;
|
|
130
|
+
}
|
|
74
131
|
};
|
|
75
|
-
}, [items, content, navOpen]);
|
|
132
|
+
}, [items, content, navOpen, closePopover, collapsedHoverMenus]);
|
|
76
133
|
useEffect(() => {
|
|
77
134
|
onMenuToggle?.(popoverOpen ? 'open' : 'close');
|
|
78
135
|
}, [popoverOpen]);
|
|
@@ -81,9 +138,9 @@ const ListItemWrapper = props => {
|
|
|
81
138
|
setPopoverOpen(false);
|
|
82
139
|
}
|
|
83
140
|
}, [focusWithin, prevFocusWithin]);
|
|
84
|
-
useEscape(closePopover, childElementRef, [childElementRef]);
|
|
85
|
-
useEscape(closePopover, popoverRef, [popoverRef]);
|
|
86
|
-
return (_jsxs(_Fragment, { children: [children, !navOpen && (_jsxs(_Fragment, { children: [!popoverOpen && (_jsx(Tooltip, { target: childElementRef.current, placement: end, showDelay: 'none', hideDelay: 'none', children: tooltipLabel })), popoverOpen && (items.length || content) && (_jsx(Popover, { target: childElementRef.current, placement: `${end}-start`, ref: popoverRef, as: StyledNavigationPopover, arrow: true, children: content
|
|
141
|
+
useEscape(() => closePopover(), childElementRef, [childElementRef]);
|
|
142
|
+
useEscape(() => closePopover(), popoverRef, [popoverRef]);
|
|
143
|
+
return (_jsxs(_Fragment, { children: [children, !navOpen && (_jsxs(_Fragment, { children: [!popoverOpen && (_jsx(Tooltip, { target: childElementRef.current, placement: end, showDelay: 'none', hideDelay: 'none', children: tooltipLabel })), popoverOpen && (items.length || content) && (_jsx(Popover, { target: childElementRef.current, placement: `${end}-start`, ref: popoverRef, as: StyledNavigationPopover, arrow: true, children: content ? (_jsx("div", { onMouseEnter: onMouseEnterContent, onMouseLeave: onMouseLeaveContent, children: content })) : (_jsx(Menu, { mode: 'action', variant: 'flyout', focusControlEl: childElementRef.current ?? undefined, scrollAt: 99, items: items.map(item => {
|
|
87
144
|
return {
|
|
88
145
|
id: (item.primary || item.text),
|
|
89
146
|
primary: (item.primary || item.text),
|
|
@@ -94,7 +151,7 @@ const ListItemWrapper = props => {
|
|
|
94
151
|
setPopoverOpen(false);
|
|
95
152
|
}
|
|
96
153
|
};
|
|
97
|
-
}), header: _jsx(Text, { variant: 'h2', children: label }) })) }))] }))] }));
|
|
154
|
+
}), header: _jsx(Text, { variant: 'h2', children: label }), onMouseEnter: onMouseEnterContent, onMouseLeave: onMouseLeaveContent })) }))] }))] }));
|
|
98
155
|
};
|
|
99
156
|
export default ListItemWrapper;
|
|
100
157
|
//# sourceMappingURL=NavigationListItemWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationListItemWrapper.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAA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CAAC,IAAI,CAAW;oCACzC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAW;oCAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;oCACf,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;wCAChB,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;wCAClB,cAAc,CAAC,KAAK,CAAC,CAAC;oCACxB,CAAC;iCACF,CAAC;4BACJ,CAAC,CAAC,EACF,MAAM,EAAE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAQ,GACzC,CACH,GACO,CACX,IACA,CACJ,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, useContext, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useDirection, useEscape, useFocusWithin, useOuterEvent, usePrevious } from '../../hooks';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\nimport Popover from '../Popover';\nimport Menu from '../Menu';\nimport { StyledMenuListContainer } from '../Menu/Menu.styles';\nimport { defaultThemeProp } from '../../theme';\n\nimport { NavListItemWrapperProps } from './AppShell.types';\nimport AppShellContext from './AppShellContext';\n\nconst StyledNavigationPopover = styled.div(({ theme }) => {\n return css`\n background-color: ${theme.components['app-shell'].nav['background-color']};\n &,\n ${StyledMenuListContainer} {\n background-color: ${theme.components['app-shell'].nav['background-color']};\n\n header {\n color: ${theme.base.palette.light};\n border-bottom: none;\n }\n }\n\n ${StyledMenuListContainer} li {\n color: rgba(255, 255, 255, 0.7);\n background-color: transparent;\n\n &:hover,\n &[data-current='true'] {\n color: #ffffff;\n background-color: rgba(255, 255, 255, 0.05);\n }\n }\n `;\n});\n\nStyledNavigationPopover.defaultProps = defaultThemeProp;\n\nconst ListItemWrapper: FC<NavListItemWrapperProps> = props => {\n const {\n children,\n childElementRef,\n label,\n tooltipLabel,\n items = [],\n content,\n onMenuToggle\n } = props;\n const { navOpen } = useContext(AppShellContext);\n const popoverRef = useRef<HTMLDivElement>(null);\n const [popoverOpen, setPopoverOpen] = useState(false);\n const { end } = useDirection();\n\n const focusWithin = useFocusWithin([popoverRef, childElementRef]);\n const prevFocusWithin = usePrevious(focusWithin);\n\n const closePopover = () => {\n if (popoverOpen) {\n setPopoverOpen(false);\n childElementRef.current?.focus();\n }\n };\n\n useOuterEvent('click', [popoverRef], closePopover);\n\n useEffect(() => {\n const onClick = (e: Event) => {\n if ((items.length || content) && !navOpen) {\n e.stopPropagation();\n e.preventDefault();\n setPopoverOpen(true);\n }\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Tab' && !content) {\n setPopoverOpen(false);\n }\n if (e.key === 'Enter' && items.length) {\n setPopoverOpen(true);\n }\n };\n\n childElementRef.current?.addEventListener('click', onClick);\n childElementRef.current?.addEventListener('keydown', onKeyDown);\n return () => {\n childElementRef.current?.removeEventListener('click', onClick);\n childElementRef.current?.removeEventListener('keydown', onKeyDown);\n };\n }, [items, content, navOpen]);\n\n useEffect(() => {\n onMenuToggle?.(popoverOpen ? 'open' : 'close');\n }, [popoverOpen]);\n\n useEffect(() => {\n if (!focusWithin && prevFocusWithin) {\n setPopoverOpen(false);\n }\n }, [focusWithin, prevFocusWithin]);\n\n useEscape(closePopover, childElementRef, [childElementRef]);\n\n useEscape(closePopover, popoverRef, [popoverRef]);\n\n return (\n <>\n {children}\n {!navOpen && (\n <>\n {!popoverOpen && (\n <Tooltip\n target={childElementRef.current}\n placement={end}\n showDelay='none'\n hideDelay='none'\n >\n {tooltipLabel}\n </Tooltip>\n )}\n {popoverOpen && (items.length || content) && (\n <Popover\n target={childElementRef.current}\n placement={`${end}-start`}\n ref={popoverRef}\n as={StyledNavigationPopover}\n arrow\n >\n {content || (\n <Menu\n mode='action'\n variant='flyout'\n focusControlEl={childElementRef.current ?? undefined}\n scrollAt={99}\n items={items.map(item => {\n return {\n id: (item.primary || item.text) as string,\n primary: (item.primary || item.text) as string,\n href: item.href,\n onClick: (_, e) => {\n e.stopPropagation();\n item.onClick?.(e);\n setPopoverOpen(false);\n }\n };\n })}\n header={<Text variant='h2'>{label}</Text>}\n />\n )}\n </Popover>\n )}\n </>\n )}\n </>\n );\n};\n\nexport default ListItemWrapper;\n"]}
|
|
1
|
+
{"version":3,"file":"NavigationListItemWrapper.js","sourceRoot":"","sources":["../../../src/components/AppShell/NavigationListItemWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IACvD,MAAM,eAAe,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,OAAO,GAAG,CAAA;wBACY,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAA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BAAuB,EAC3B,KAAK,kBAEJ,OAAO,CAAC,CAAC,CAAC,CACT,cAAK,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,YACtE,OAAO,GACJ,CACP,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IACH,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,QAAQ,EAChB,cAAc,EAAE,eAAe,CAAC,OAAO,IAAI,SAAS,EACpD,QAAQ,EAAE,EAAE,EACZ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gCACtB,OAAO;oCACL,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAW;oCACzC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAW;oCAC9C,IAAI,EAAE,IAAI,CAAC,IAAI;oCACf,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;wCAChB,CAAC,CAAC,eAAe,EAAE,CAAC;wCACpB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;wCAClB,cAAc,CAAC,KAAK,CAAC,CAAC;oCACxB,CAAC;iCACF,CAAC;4BACJ,CAAC,CAAC,EACF,MAAM,EAAE,KAAC,IAAI,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAQ,EACzC,YAAY,EAAE,mBAAmB,EACjC,YAAY,EAAE,mBAAmB,GACjC,CACH,GACO,CACX,IACA,CACJ,IACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { FC, useContext, useEffect, useRef, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { useDirection, useEscape, useFocusWithin, useOuterEvent, usePrevious } from '../../hooks';\nimport Text from '../Text';\nimport Tooltip from '../Tooltip';\nimport Popover from '../Popover';\nimport Menu from '../Menu';\nimport { StyledMenuListContainer } from '../Menu/Menu.styles';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\n\nimport { NavListItemWrapperProps } from './AppShell.types';\nimport AppShellContext from './AppShellContext';\n\nconst StyledNavigationPopover = styled.div(({ theme }) => {\n const headingFontSize = calculateFontSize(theme.base['font-size'], theme.base['font-scale']).s;\n return css`\n background-color: ${theme.components['app-shell'].nav['background-color']};\n &,\n ${StyledMenuListContainer} {\n background-color: ${theme.components['app-shell'].nav['background-color']};\n\n header {\n color: ${theme.base.palette.light};\n border-bottom: none;\n opacity: 0.7;\n\n h2 {\n font-weight: ${theme.base['font-weight']['semi-bold']};\n font-size: ${headingFontSize};\n }\n }\n }\n\n ${StyledMenuListContainer} li {\n color: rgba(255, 255, 255, 0.7);\n background-color: transparent;\n\n &:hover,\n &[data-current='true'] {\n color: #ffffff;\n background-color: rgba(255, 255, 255, 0.05);\n }\n }\n `;\n});\n\nStyledNavigationPopover.defaultProps = defaultThemeProp;\n\nconst ListItemWrapper: FC<NavListItemWrapperProps> = props => {\n const {\n children,\n childElementRef,\n label,\n tooltipLabel,\n items = [],\n content,\n onMenuToggle\n } = props;\n const { navOpen, collapsedHoverMenus } = useContext(AppShellContext);\n const popoverRef = useRef<HTMLDivElement>(null);\n const [popoverOpen, setPopoverOpen] = useState(false);\n const { end } = useDirection();\n const mousedOverMenu = useRef(false);\n const hidePopoverTimeout = useRef<number | null>();\n const focusWithin = useFocusWithin([popoverRef, childElementRef]);\n const prevFocusWithin = usePrevious(focusWithin);\n\n const closePopover = (focusChildEl: boolean = true) => {\n if (popoverOpen) {\n setPopoverOpen(false);\n if (focusChildEl) {\n childElementRef.current?.focus();\n }\n if (hidePopoverTimeout.current) {\n clearTimeout(hidePopoverTimeout.current);\n hidePopoverTimeout.current = null;\n }\n }\n };\n\n const onMouseEnterContent = () => {\n if (collapsedHoverMenus) {\n mousedOverMenu.current = true;\n }\n };\n\n const onMouseLeaveContent = () => {\n if (mousedOverMenu.current && collapsedHoverMenus) {\n mousedOverMenu.current = false;\n closePopover();\n }\n };\n\n useOuterEvent('click', [popoverRef], () => closePopover());\n\n useEffect(() => {\n const onClick = (e: Event) => {\n if ((items.length || content) && !navOpen) {\n e.stopPropagation();\n e.preventDefault();\n setPopoverOpen(true);\n }\n };\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Tab' && !content) {\n setPopoverOpen(false);\n }\n if (e.key === 'Enter' && items.length) {\n setPopoverOpen(true);\n }\n };\n\n const onMouseOut = (e: MouseEvent) => {\n if (hidePopoverTimeout.current) {\n clearTimeout(hidePopoverTimeout.current);\n hidePopoverTimeout.current = null;\n }\n const tag = (e.relatedTarget as HTMLElement).tagName;\n\n // If the mouse is mousing out from this nav item onto another nav item\n if (['A', 'BUTTON', 'FORM'].includes(tag)) {\n closePopover(false);\n } else {\n hidePopoverTimeout.current = window.setTimeout(() => {\n if (!mousedOverMenu.current) {\n closePopover(false);\n }\n }, 1000);\n }\n };\n\n childElementRef.current?.addEventListener('click', onClick);\n childElementRef.current?.addEventListener('keydown', onKeyDown);\n if (collapsedHoverMenus) {\n childElementRef.current?.addEventListener('mouseenter', onClick);\n childElementRef.current?.addEventListener('mouseleave', onMouseOut);\n }\n return () => {\n childElementRef.current?.removeEventListener('click', onClick);\n childElementRef.current?.removeEventListener('keydown', onKeyDown);\n if (collapsedHoverMenus) {\n childElementRef.current?.removeEventListener('mouseenter', onClick);\n childElementRef.current?.removeEventListener('mouseleave', onMouseOut);\n }\n if (hidePopoverTimeout.current) {\n clearTimeout(hidePopoverTimeout.current);\n hidePopoverTimeout.current = null;\n }\n };\n }, [items, content, navOpen, closePopover, collapsedHoverMenus]);\n\n useEffect(() => {\n onMenuToggle?.(popoverOpen ? 'open' : 'close');\n }, [popoverOpen]);\n\n useEffect(() => {\n if (!focusWithin && prevFocusWithin) {\n setPopoverOpen(false);\n }\n }, [focusWithin, prevFocusWithin]);\n\n useEscape(() => closePopover(), childElementRef, [childElementRef]);\n\n useEscape(() => closePopover(), popoverRef, [popoverRef]);\n\n return (\n <>\n {children}\n {!navOpen && (\n <>\n {!popoverOpen && (\n <Tooltip\n target={childElementRef.current}\n placement={end}\n showDelay='none'\n hideDelay='none'\n >\n {tooltipLabel}\n </Tooltip>\n )}\n {popoverOpen && (items.length || content) && (\n <Popover\n target={childElementRef.current}\n placement={`${end}-start`}\n ref={popoverRef}\n as={StyledNavigationPopover}\n arrow\n >\n {content ? (\n <div onMouseEnter={onMouseEnterContent} onMouseLeave={onMouseLeaveContent}>\n {content}\n </div>\n ) : (\n <Menu\n mode='action'\n variant='flyout'\n focusControlEl={childElementRef.current ?? undefined}\n scrollAt={99}\n items={items.map(item => {\n return {\n id: (item.primary || item.text) as string,\n primary: (item.primary || item.text) as string,\n href: item.href,\n onClick: (_, e) => {\n e.stopPropagation();\n item.onClick?.(e);\n setPopoverOpen(false);\n }\n };\n })}\n header={<Text variant='h2'>{label}</Text>}\n onMouseEnter={onMouseEnterContent}\n onMouseLeave={onMouseLeaveContent}\n />\n )}\n </Popover>\n )}\n </>\n )}\n </>\n );\n};\n\nexport default ListItemWrapper;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BareRoleButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/BareRoleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGjG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACvD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"BareRoleButton.d.ts","sourceRoot":"","sources":["../../../src/components/Button/BareRoleButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGjG,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACvD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,oBAAoB,yGAEhC,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,GAAG,YAAY,CAiCzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
export const StyledBareRoleButton = styled.div
|
|
4
|
+
export const StyledBareRoleButton = styled.div `
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
`;
|
|
5
7
|
const BareRoleButton = forwardRef(({ children, onClick, onKeyDown, ...restProps }, ref) => {
|
|
6
8
|
return (_jsx(StyledBareRoleButton, { ...restProps, tabIndex: 0, role: 'button', onKeyDown: (e) => {
|
|
7
9
|
if ((e.key === ' ' || e.key === 'Enter') && e.target === e.currentTarget) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BareRoleButton.js","sourceRoot":"","sources":["../../../src/components/Button/BareRoleButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgE,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAWvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"BareRoleButton.js","sourceRoot":"","sources":["../../../src/components/Button/BareRoleButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgE,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAWvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE7C,CAAC;AAEF,MAAM,cAAc,GAA0D,UAAU,CACtF,CACE,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAuB,EACnE,GAA+B,EAC/B,EAAE;IACF,OAAO,CACL,KAAC,oBAAoB,OACf,SAAS,EACb,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,CAAC,CAAgC,EAAE,EAAE;YAC9C,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,aAAa,EAAE;gBACvE,CAAC,CAAC,aAAgC,CAAC,KAAK,EAAE,CAAC;aAC7C;YAED,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC,EACD,OAAO,EAAE,CAAC,CAA6B,EAAE,EAAE;YACzC,IACE,CAAC,CAAC,MAAM,YAAY,OAAO;gBAC3B,mEAAmE;gBACnE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,2CAA2C,CAAC,KAAK,CAAC,CAAC,aAAa;gBAEjF,OAAO;YAET,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,EACD,GAAG,EAAE,GAAG,YAEP,QAAQ,GACY,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, Ref, MouseEvent, KeyboardEvent, ReactNode, FunctionComponent } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface BareRoleButtonProps extends BaseProps {\n children: ReactNode;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n onKeyDown?: (e: KeyboardEvent<HTMLDivElement>) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledBareRoleButton = styled.div`\n cursor: pointer;\n`;\n\nconst BareRoleButton: FunctionComponent<BareRoleButtonProps & ForwardProps> = forwardRef(\n (\n { children, onClick, onKeyDown, ...restProps }: BareRoleButtonProps,\n ref: BareRoleButtonProps['ref']\n ) => {\n return (\n <StyledBareRoleButton\n {...restProps}\n tabIndex={0}\n role='button'\n onKeyDown={(e: KeyboardEvent<HTMLDivElement>) => {\n if ((e.key === ' ' || e.key === 'Enter') && e.target === e.currentTarget) {\n (e.currentTarget as HTMLDivElement).click();\n }\n\n return onKeyDown?.(e);\n }}\n onClick={(e: MouseEvent<HTMLDivElement>) => {\n if (\n e.target instanceof Element &&\n // Ignore clicks on other interactive elements within this element.\n e.target.closest(\"button, a, [role='button'], [role='link']\") !== e.currentTarget\n )\n return;\n\n return onClick?.(e);\n }}\n ref={ref}\n >\n {children}\n </StyledBareRoleButton>\n );\n }\n);\n\nexport default BareRoleButton;\n"]}
|