@pega/cosmos-react-core 10.0.0-build.9.11 → 10.0.0-build.9.13
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/AppHeader.d.ts.map +1 -1
- package/lib/components/AppShell/AppHeader.js +46 -3
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppNavigationPanel.d.ts.map +1 -1
- package/lib/components/AppShell/AppNavigationPanel.js +12 -3
- package/lib/components/AppShell/AppNavigationPanel.js.map +1 -1
- package/lib/components/AppShell/AppShell.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.js +40 -10
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShell.styles.d.ts +8 -0
- package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppShell.styles.js +53 -3
- package/lib/components/AppShell/AppShell.styles.js.map +1 -1
- package/lib/components/AppShell/AppShell.types.d.ts +50 -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 +2 -0
- package/lib/components/AppShell/AppShellContext.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellContext.js.map +1 -1
- package/lib/components/AppShell/AppShellList.d.ts.map +1 -1
- package/lib/components/AppShell/AppShellList.js +2 -1
- package/lib/components/AppShell/AppShellList.js.map +1 -1
- package/lib/components/AppShell/AppTopNav.styles.d.ts.map +1 -1
- package/lib/components/AppShell/AppTopNav.styles.js +5 -1
- package/lib/components/AppShell/AppTopNav.styles.js.map +1 -1
- package/lib/components/AppShell/DocumentTabs.styles.d.ts.map +1 -1
- package/lib/components/AppShell/DocumentTabs.styles.js +4 -2
- package/lib/components/AppShell/DocumentTabs.styles.js.map +1 -1
- package/lib/components/AppShell/HeaderActionButton.d.ts +20 -0
- package/lib/components/AppShell/HeaderActionButton.d.ts.map +1 -0
- package/lib/components/AppShell/HeaderActionButton.js +78 -0
- package/lib/components/AppShell/HeaderActionButton.js.map +1 -0
- package/lib/components/AppShell/Panel/Panel.d.ts +15 -0
- package/lib/components/AppShell/Panel/Panel.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/Panel.js +80 -0
- package/lib/components/AppShell/Panel/Panel.js.map +1 -0
- package/lib/components/AppShell/Panel/Panel.styles.d.ts +188 -0
- package/lib/components/AppShell/Panel/Panel.styles.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/Panel.styles.js +85 -0
- package/lib/components/AppShell/Panel/Panel.styles.js.map +1 -0
- package/lib/components/AppShell/Panel/Panel.test-ids.d.ts +2 -0
- package/lib/components/AppShell/Panel/Panel.test-ids.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/Panel.test-ids.js +3 -0
- package/lib/components/AppShell/Panel/Panel.test-ids.js.map +1 -0
- package/lib/components/AppShell/Panel/Panel.types.d.ts +33 -0
- package/lib/components/AppShell/Panel/Panel.types.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/Panel.types.js +2 -0
- package/lib/components/AppShell/Panel/Panel.types.js.map +1 -0
- package/lib/components/AppShell/Panel/PanelHeaderActions.d.ts +8 -0
- package/lib/components/AppShell/Panel/PanelHeaderActions.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/PanelHeaderActions.js +17 -0
- package/lib/components/AppShell/Panel/PanelHeaderActions.js.map +1 -0
- package/lib/components/AppShell/Panel/index.d.ts +4 -0
- package/lib/components/AppShell/Panel/index.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/index.js +4 -0
- package/lib/components/AppShell/Panel/index.js.map +1 -0
- package/lib/components/AppShell/Panel/usePanel.d.ts +12 -0
- package/lib/components/AppShell/Panel/usePanel.d.ts.map +1 -0
- package/lib/components/AppShell/Panel/usePanel.js +30 -0
- package/lib/components/AppShell/Panel/usePanel.js.map +1 -0
- package/lib/components/AppShell/TopNavDrawerProvider.d.ts +5 -1
- package/lib/components/AppShell/TopNavDrawerProvider.d.ts.map +1 -1
- package/lib/components/AppShell/TopNavDrawerProvider.js +18 -3
- package/lib/components/AppShell/TopNavDrawerProvider.js.map +1 -1
- package/lib/components/AppShell/TouchAppShell.d.ts +1 -1
- package/lib/components/AppShell/TouchAppShell.d.ts.map +1 -1
- package/lib/components/AppShell/TouchAppShell.js +34 -7
- package/lib/components/AppShell/TouchAppShell.js.map +1 -1
- package/lib/components/AppShell/TouchAppShell.styles.d.ts.map +1 -1
- package/lib/components/AppShell/TouchAppShell.styles.js +10 -0
- package/lib/components/AppShell/TouchAppShell.styles.js.map +1 -1
- package/lib/components/AppShell/headerActionUtils.d.ts +12 -0
- package/lib/components/AppShell/headerActionUtils.d.ts.map +1 -0
- package/lib/components/AppShell/headerActionUtils.js +69 -0
- package/lib/components/AppShell/headerActionUtils.js.map +1 -0
- package/lib/components/AppShell/index.d.ts +2 -1
- package/lib/components/AppShell/index.d.ts.map +1 -1
- package/lib/components/AppShell/index.js.map +1 -1
- package/lib/components/Drawer/Drawer.d.ts +12 -1
- package/lib/components/Drawer/Drawer.d.ts.map +1 -1
- package/lib/components/Drawer/Drawer.js +22 -23
- package/lib/components/Drawer/Drawer.js.map +1 -1
- package/lib/components/Drawer/ResizeHandle.d.ts +9 -2
- package/lib/components/Drawer/ResizeHandle.d.ts.map +1 -1
- package/lib/components/Drawer/ResizeHandle.js +41 -17
- package/lib/components/Drawer/ResizeHandle.js.map +1 -1
- package/lib/components/Link/Link.d.ts +2 -0
- package/lib/components/Link/Link.d.ts.map +1 -1
- package/lib/components/Link/Link.js +2 -2
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/Location/LocationInput.d.ts +1 -1
- package/lib/components/Location/LocationInput.d.ts.map +1 -1
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Signature/Signature.d.ts +28 -0
- package/lib/components/Signature/Signature.d.ts.map +1 -0
- package/lib/components/Signature/Signature.js +397 -0
- package/lib/components/Signature/Signature.js.map +1 -0
- package/lib/components/Signature/Signature.styles.d.ts +197 -0
- package/lib/components/Signature/Signature.styles.d.ts.map +1 -0
- package/lib/components/Signature/Signature.styles.js +119 -0
- package/lib/components/Signature/Signature.styles.js.map +1 -0
- package/lib/components/Signature/Signature.test-ids.d.ts +2 -0
- package/lib/components/Signature/Signature.test-ids.d.ts.map +1 -0
- package/lib/components/Signature/Signature.test-ids.js +3 -0
- package/lib/components/Signature/Signature.test-ids.js.map +1 -0
- package/lib/components/Signature/index.d.ts +4 -0
- package/lib/components/Signature/index.d.ts.map +1 -0
- package/lib/components/Signature/index.js +3 -0
- package/lib/components/Signature/index.js.map +1 -0
- package/lib/hooks/useBreakpoint.d.ts.map +1 -1
- package/lib/hooks/useBreakpoint.js +3 -1
- package/lib/hooks/useBreakpoint.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +23 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +23 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +24 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +23 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -46,11 +46,21 @@ StyledSplitViewPanel.defaultProps = defaultThemeProp;
|
|
|
46
46
|
export const StyledPortalTouchDialog = styled(TouchDialog)(({ theme }) => css `
|
|
47
47
|
&& {
|
|
48
48
|
background: ${theme.components.agent.background};
|
|
49
|
+
overflow: visible;
|
|
49
50
|
pointer-events: auto;
|
|
50
51
|
inset-inline: 0;
|
|
51
52
|
inset-block-end: var(--appshell-hard-bottom-offset, 0);
|
|
52
53
|
border-end-start-radius: 0;
|
|
53
54
|
border-end-end-radius: 0;
|
|
55
|
+
|
|
56
|
+
&::after {
|
|
57
|
+
content: '';
|
|
58
|
+
position: absolute;
|
|
59
|
+
inset-block-start: 100%;
|
|
60
|
+
inset-inline: 0;
|
|
61
|
+
height: calc(var(--appshell-hard-bottom-offset, 0rem) - var(--marking-height, 0rem));
|
|
62
|
+
background: ${theme.components.agent.background};
|
|
63
|
+
}
|
|
54
64
|
}
|
|
55
65
|
`);
|
|
56
66
|
StyledPortalTouchDialog.defaultProps = defaultThemeProp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TouchAppShell.styles.js","sourceRoot":"","sources":["../../../src/components/AppShell/TouchAppShell.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,gCAAgC,EAChC,YAAY,EACb,MAAM,mBAAmB,CAA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AAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEzD,OAAO,GAAG,CAAA;;aAEC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;6BACX,aAAa;8BACZ,YAAY;iBACzB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAa,CAAC;gCACnC,KAAK,CAAC,IAAI,CAAC,OAAO;;;;mCAIf,KAAK,CAAC,IAAI,CAAC,OAAO;QAC7C,gBAAgB;;;MAGlB,OAAO;QACT,GAAG,CAAA;;;;sBAIe,WAAW;;sBAEX,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC;;KAEjD;;MAEC,WAAW;;;;;GAKd,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,0BAA0B,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { createGlobalStyle, css, type DefaultTheme } from 'styled-components';\nimport { rem, transparentize } from 'polished';\nimport { useContext } from 'react';\n\nimport { StyledAlert } from '../Badges/Alert';\nimport { StyledLink } from '../Link/Link';\nimport { StyledBareButton } from '../Button/BareButton';\nimport Button from '../Button';\nimport { StyledDrawer } from '../Drawer';\nimport { TouchDialog } from '../Dialog';\nimport Flex from '../Flex';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport { ellipsisOverflow } from '../../styles/mixins';\nimport { useDirection } from '../../hooks';\n\nimport AppShellContext from './AppShellContext';\nimport {\n menuButtonWidth,\n mobileHeaderHeight,\n StyledCountIcon,\n StyledNavItemIconBox,\n StyledNavList,\n StyledNavListItem,\n StyledNavListItemVisualContainer,\n StyledAppNav\n} from './AppShell.styles';\nimport { navContrastColors } from './style-utils';\n\nexport const TouchAppShellGlobalStyle = createGlobalStyle<{\n hasBottomTouchPanel?: boolean;\n isMobileNav?: boolean;\n theme?: DefaultTheme;\n}>`\n :root,\n :host {\n --appshell-bottom-panel-offset: ${({ hasBottomTouchPanel }) =>\n hasBottomTouchPanel ? '4rem' : '0rem'};\n --appshell-bottom-panel-gap: ${({ hasBottomTouchPanel, theme }) =>\n hasBottomTouchPanel ? `calc(2 * ${theme?.base.spacing})` : '0rem'};\n --appshell-bottom-offset: ${({ hasBottomTouchPanel, isMobileNav }) =>\n `calc(var(--appshell-hard-bottom-offset) + ${isMobileNav ? mobileHeaderHeight : '0rem'}${\n hasBottomTouchPanel ? ' + var(--appshell-bottom-panel-offset)' : ''\n })`};\n }\n`;\n\nexport const StyledMainTouchAppShell = styled.div<{ active?: boolean }>(\n ({ active, theme }) => css`\n ${active &&\n css`\n background: ${theme.base.colors.black};\n `}\n `\n);\n\nStyledMainTouchAppShell.defaultProps = defaultThemeProp;\n\nexport const StyledSplitViewPanel = styled.div<{ active?: boolean }>(({ active, theme }) => {\n const splitViewHeight = active\n ? 'calc(var(--appshell-bottom-panel-offset, 0rem) + var(--appshell-bottom-panel-gap, 0rem))'\n : '0rem';\n\n return css`\n position: fixed;\n inset-block-end: var(--appshell-hard-bottom-offset, 0);\n inset-inline: 0;\n height: ${splitViewHeight};\n background: ${theme.base.colors.black};\n `;\n});\n\nStyledSplitViewPanel.defaultProps = defaultThemeProp;\n\nexport const StyledPortalTouchDialog = styled(TouchDialog)(\n ({ theme }) => css`\n && {\n background: ${theme.components.agent.background};\n pointer-events: auto;\n inset-inline: 0;\n inset-block-end: var(--appshell-hard-bottom-offset, 0);\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n }\n `\n);\n\nStyledPortalTouchDialog.defaultProps = defaultThemeProp;\n\nexport const StyledMobileMoreMenu = styled(StyledAppNav)`\n width: 100%;\n height: 100%;\n\n /* Reserve top space for the app header + top nav, but NOT the document\n tabs strip - the mobile menu drawer covers content above the tab strip\n too. */\n padding-block-start: calc(var(--appshell-top-offset, 0rem) - var(--document-tabs-height, 0rem));\n padding-block-end: var(--appshell-bottom-offset, ${mobileHeaderHeight});\n`;\n\nStyledMobileMoreMenu.defaultProps = defaultThemeProp;\n\nexport const StyledMobileNav = styled(Flex)<{ hasBottomTouchPanel?: boolean }>(({\n theme,\n hasBottomTouchPanel\n}) => {\n const { rtl } = useDirection();\n const {\n base: {\n 'hit-area': { 'finger-min': hitAreaFinger },\n 'border-radius': borderRadius,\n 'font-size': fontSize,\n 'font-scale': fontScale\n },\n components: {\n button: { 'focus-shadow': focusShadow, 'border-width': borderWidth },\n text\n }\n } = theme;\n const mobileNavColor = theme.components['app-shell'].nav.background;\n const { foreground } = navContrastColors(theme);\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n z-index: calc(${theme.base['z-index'].drawer} + 1);\n background: ${mobileNavColor};\n border-radius: calc(2 * ${borderRadius});\n color: ${foreground};\n padding: 0.5rem;\n position: fixed;\n --mobile-nav-offset: ${hasBottomTouchPanel ? '0rem' : '0.75rem'};\n inset-block-start: calc(\n 100dvh - var(--appshell-bottom-offset, ${mobileHeaderHeight}) + var(--mobile-nav-offset)\n );\n inset-inline-start: 50%;\n transform: translateX(${rtl ? '50%' : '-50%'});\n box-shadow: ${theme.base.shadow.low};\n\n & + ${StyledDrawer} ${StyledDrawer} {\n width: 100%;\n }\n\n > div:has(> ${StyledNavList}),\n > div:has(> ${StyledNavList}) > ${StyledNavList}, > ${StyledNavList} {\n display: contents;\n\n ${StyledNavListItem} {\n padding: 0;\n margin: 0;\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n\n ${StyledBareButton}, ${StyledLink} {\n flex-direction: column;\n justify-content: center;\n width: ${rem(menuButtonWidth(theme))};\n height: calc(0.25rem + ${hitAreaFinger});\n border-radius: calc(2 * ${borderRadius});\n border: ${borderWidth} solid transparent;\n padding-block: calc(0.5 * ${theme.base.spacing});\n\n &::before {\n width: 0;\n }\n\n span:not(${StyledCountIcon}) {\n width: inherit;\n text-align: center;\n padding-inline: calc(0.5 * ${theme.base.spacing});\n }\n\n &:enabled:focus-visible,\n &:not([disabled]):focus-visible {\n box-shadow: ${focusShadow};\n }\n\n ${StyledNavListItemVisualContainer} {\n padding: 0;\n margin: 0;\n\n ${StyledNavItemIconBox} {\n display: flex;\n }\n }\n }\n }\n }\n `;\n});\n\nStyledMobileNav.defaultProps = defaultThemeProp;\n\nexport const StyledMobileMoreMenuButton = styled(Button)(({ theme }) => {\n const {\n base: {\n 'hit-area': { 'finger-min': hitAreaFinger },\n 'border-radius': borderRadius,\n 'font-size': fontSize,\n 'font-scale': fontScale\n },\n components: {\n button: { 'border-width': borderWidth },\n text\n }\n } = theme;\n const { navOpen } = useContext(AppShellContext);\n const { foreground } = navContrastColors(theme);\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n flex-direction: column;\n width: ${rem(menuButtonWidth(theme))};\n height: calc(0.25rem + ${hitAreaFinger});\n border-radius: calc(2 * ${borderRadius});\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n padding-block: calc(0.5 * ${theme.base.spacing});\n\n span {\n width: inherit;\n padding-inline: calc(0.5 * ${theme.base.spacing});\n ${ellipsisOverflow}\n }\n\n ${navOpen &&\n css`\n &::before {\n content: '';\n position: absolute;\n inset: calc(${borderWidth} * -1);\n border-radius: inherit;\n background: ${transparentize(0.85, foreground)};\n }\n `}\n\n ${StyledAlert} {\n position: absolute;\n inset-block-start: calc(0.625rem / 2);\n inset-inline-start: calc(50% + (0.625rem / 2));\n }\n `;\n});\n\nStyledMobileMoreMenuButton.defaultProps = defaultThemeProp;\n"]}
|
|
1
|
+
{"version":3,"file":"TouchAppShell.styles.js","sourceRoot":"","sources":["../../../src/components/AppShell/TouchAppShell.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,iBAAiB,EAAE,GAAG,EAAqB,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EA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'styled-components';\nimport { rem, transparentize } from 'polished';\nimport { useContext } from 'react';\n\nimport { StyledAlert } from '../Badges/Alert';\nimport { StyledLink } from '../Link/Link';\nimport { StyledBareButton } from '../Button/BareButton';\nimport Button from '../Button';\nimport { StyledDrawer } from '../Drawer';\nimport { TouchDialog } from '../Dialog';\nimport Flex from '../Flex';\nimport { defaultThemeProp } from '../../theme';\nimport { calculateFontSize } from '../../styles';\nimport type { FontSize } from '../../styles';\nimport { ellipsisOverflow } from '../../styles/mixins';\nimport { useDirection } from '../../hooks';\n\nimport AppShellContext from './AppShellContext';\nimport {\n menuButtonWidth,\n mobileHeaderHeight,\n StyledCountIcon,\n StyledNavItemIconBox,\n StyledNavList,\n StyledNavListItem,\n StyledNavListItemVisualContainer,\n StyledAppNav\n} from './AppShell.styles';\nimport { navContrastColors } from './style-utils';\n\nexport const TouchAppShellGlobalStyle = createGlobalStyle<{\n hasBottomTouchPanel?: boolean;\n isMobileNav?: boolean;\n theme?: DefaultTheme;\n}>`\n :root,\n :host {\n --appshell-bottom-panel-offset: ${({ hasBottomTouchPanel }) =>\n hasBottomTouchPanel ? '4rem' : '0rem'};\n --appshell-bottom-panel-gap: ${({ hasBottomTouchPanel, theme }) =>\n hasBottomTouchPanel ? `calc(2 * ${theme?.base.spacing})` : '0rem'};\n --appshell-bottom-offset: ${({ hasBottomTouchPanel, isMobileNav }) =>\n `calc(var(--appshell-hard-bottom-offset) + ${isMobileNav ? mobileHeaderHeight : '0rem'}${\n hasBottomTouchPanel ? ' + var(--appshell-bottom-panel-offset)' : ''\n })`};\n }\n`;\n\nexport const StyledMainTouchAppShell = styled.div<{ active?: boolean }>(\n ({ active, theme }) => css`\n ${active &&\n css`\n background: ${theme.base.colors.black};\n `}\n `\n);\n\nStyledMainTouchAppShell.defaultProps = defaultThemeProp;\n\nexport const StyledSplitViewPanel = styled.div<{ active?: boolean }>(({ active, theme }) => {\n const splitViewHeight = active\n ? 'calc(var(--appshell-bottom-panel-offset, 0rem) + var(--appshell-bottom-panel-gap, 0rem))'\n : '0rem';\n\n return css`\n position: fixed;\n inset-block-end: var(--appshell-hard-bottom-offset, 0);\n inset-inline: 0;\n height: ${splitViewHeight};\n background: ${theme.base.colors.black};\n `;\n});\n\nStyledSplitViewPanel.defaultProps = defaultThemeProp;\n\nexport const StyledPortalTouchDialog = styled(TouchDialog)(\n ({ theme }) => css`\n && {\n background: ${theme.components.agent.background};\n overflow: visible;\n pointer-events: auto;\n inset-inline: 0;\n inset-block-end: var(--appshell-hard-bottom-offset, 0);\n border-end-start-radius: 0;\n border-end-end-radius: 0;\n\n &::after {\n content: '';\n position: absolute;\n inset-block-start: 100%;\n inset-inline: 0;\n height: calc(var(--appshell-hard-bottom-offset, 0rem) - var(--marking-height, 0rem));\n background: ${theme.components.agent.background};\n }\n }\n `\n);\n\nStyledPortalTouchDialog.defaultProps = defaultThemeProp;\n\nexport const StyledMobileMoreMenu = styled(StyledAppNav)`\n width: 100%;\n height: 100%;\n\n /* Reserve top space for the app header + top nav, but NOT the document\n tabs strip - the mobile menu drawer covers content above the tab strip\n too. */\n padding-block-start: calc(var(--appshell-top-offset, 0rem) - var(--document-tabs-height, 0rem));\n padding-block-end: var(--appshell-bottom-offset, ${mobileHeaderHeight});\n`;\n\nStyledMobileMoreMenu.defaultProps = defaultThemeProp;\n\nexport const StyledMobileNav = styled(Flex)<{ hasBottomTouchPanel?: boolean }>(({\n theme,\n hasBottomTouchPanel\n}) => {\n const { rtl } = useDirection();\n const {\n base: {\n 'hit-area': { 'finger-min': hitAreaFinger },\n 'border-radius': borderRadius,\n 'font-size': fontSize,\n 'font-scale': fontScale\n },\n components: {\n button: { 'focus-shadow': focusShadow, 'border-width': borderWidth },\n text\n }\n } = theme;\n const mobileNavColor = theme.components['app-shell'].nav.background;\n const { foreground } = navContrastColors(theme);\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n z-index: calc(${theme.base['z-index'].drawer} + 1);\n background: ${mobileNavColor};\n border-radius: calc(2 * ${borderRadius});\n color: ${foreground};\n padding: 0.5rem;\n position: fixed;\n --mobile-nav-offset: ${hasBottomTouchPanel ? '0rem' : '0.75rem'};\n inset-block-start: calc(\n 100dvh - var(--appshell-bottom-offset, ${mobileHeaderHeight}) + var(--mobile-nav-offset)\n );\n inset-inline-start: 50%;\n transform: translateX(${rtl ? '50%' : '-50%'});\n box-shadow: ${theme.base.shadow.low};\n\n & + ${StyledDrawer} ${StyledDrawer} {\n width: 100%;\n }\n\n > div:has(> ${StyledNavList}),\n > div:has(> ${StyledNavList}) > ${StyledNavList}, > ${StyledNavList} {\n display: contents;\n\n ${StyledNavListItem} {\n padding: 0;\n margin: 0;\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n\n ${StyledBareButton}, ${StyledLink} {\n flex-direction: column;\n justify-content: center;\n width: ${rem(menuButtonWidth(theme))};\n height: calc(0.25rem + ${hitAreaFinger});\n border-radius: calc(2 * ${borderRadius});\n border: ${borderWidth} solid transparent;\n padding-block: calc(0.5 * ${theme.base.spacing});\n\n &::before {\n width: 0;\n }\n\n span:not(${StyledCountIcon}) {\n width: inherit;\n text-align: center;\n padding-inline: calc(0.5 * ${theme.base.spacing});\n }\n\n &:enabled:focus-visible,\n &:not([disabled]):focus-visible {\n box-shadow: ${focusShadow};\n }\n\n ${StyledNavListItemVisualContainer} {\n padding: 0;\n margin: 0;\n\n ${StyledNavItemIconBox} {\n display: flex;\n }\n }\n }\n }\n }\n `;\n});\n\nStyledMobileNav.defaultProps = defaultThemeProp;\n\nexport const StyledMobileMoreMenuButton = styled(Button)(({ theme }) => {\n const {\n base: {\n 'hit-area': { 'finger-min': hitAreaFinger },\n 'border-radius': borderRadius,\n 'font-size': fontSize,\n 'font-scale': fontScale\n },\n components: {\n button: { 'border-width': borderWidth },\n text\n }\n } = theme;\n const { navOpen } = useContext(AppShellContext);\n const { foreground } = navContrastColors(theme);\n const fontSizes = calculateFontSize(fontSize, fontScale);\n\n return css`\n flex-direction: column;\n width: ${rem(menuButtonWidth(theme))};\n height: calc(0.25rem + ${hitAreaFinger});\n border-radius: calc(2 * ${borderRadius});\n font-size: ${fontSizes[text.secondary['font-size'] as FontSize]};\n padding-block: calc(0.5 * ${theme.base.spacing});\n\n span {\n width: inherit;\n padding-inline: calc(0.5 * ${theme.base.spacing});\n ${ellipsisOverflow}\n }\n\n ${navOpen &&\n css`\n &::before {\n content: '';\n position: absolute;\n inset: calc(${borderWidth} * -1);\n border-radius: inherit;\n background: ${transparentize(0.85, foreground)};\n }\n `}\n\n ${StyledAlert} {\n position: absolute;\n inset-block-start: calc(0.625rem / 2);\n inset-inline-start: calc(50% + (0.625rem / 2));\n }\n `;\n});\n\nStyledMobileMoreMenuButton.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionPopoverProps, ActionProps, UtilItemProps } from './AppShell.types';
|
|
2
|
+
import type { PanelProps } from './Panel/Panel.types';
|
|
3
|
+
interface HeaderActionUtilOptions {
|
|
4
|
+
panel1?: PanelProps;
|
|
5
|
+
popover?: ActionPopoverProps;
|
|
6
|
+
/** Localized text announced for navigation actions, which open in a new tab. */
|
|
7
|
+
newTabHint: string;
|
|
8
|
+
}
|
|
9
|
+
/** Maps header actions to util items for the navigation drawer, where the header is not rendered. */
|
|
10
|
+
declare const getHeaderActionUtilItems: (actions: ActionProps[], { panel1, popover, newTabHint }: HeaderActionUtilOptions) => UtilItemProps[];
|
|
11
|
+
export default getHeaderActionUtilItems;
|
|
12
|
+
//# sourceMappingURL=headerActionUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerActionUtils.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/headerActionUtils.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAyBtD,UAAU,uBAAuB;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qGAAqG;AACrG,QAAA,MAAM,wBAAwB,GAC5B,SAAS,WAAW,EAAE,EACtB,iCAAiC,uBAAuB,KACvD,aAAa,EA0DZ,CAAC;AAEL,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import VisuallyHiddenText from '../VisuallyHiddenText';
|
|
5
|
+
import { AppShellDrawerContext } from './AppShellContext';
|
|
6
|
+
/** Runs the action when its drawer opens, so a popover action can set the content it renders, and closes the drawer once that content is cleared. */
|
|
7
|
+
const PopoverDrawerView = ({ onOpen, children }) => {
|
|
8
|
+
const { closeDrawer } = useContext(AppShellDrawerContext);
|
|
9
|
+
const hadContent = useRef(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
onOpen();
|
|
12
|
+
}, []);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (children !== null && children !== undefined) {
|
|
15
|
+
hadContent.current = true;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
if (!hadContent.current)
|
|
19
|
+
return undefined;
|
|
20
|
+
// Deferred past the drawer's own refresh, which re-opens it in a parent effect of this render.
|
|
21
|
+
const timeoutId = setTimeout(closeDrawer);
|
|
22
|
+
return () => clearTimeout(timeoutId);
|
|
23
|
+
}, [children]);
|
|
24
|
+
return _jsx(_Fragment, { children: children });
|
|
25
|
+
};
|
|
26
|
+
/** Maps header actions to util items for the navigation drawer, where the header is not rendered. */
|
|
27
|
+
const getHeaderActionUtilItems = (actions, { panel1, popover, newTabHint }) => actions.map(action => {
|
|
28
|
+
const { id, label, icon, count } = action;
|
|
29
|
+
// The nav list references the count by a label-based id, which breaks when the label has spaces.
|
|
30
|
+
const countId = `${id.replace(/\s+/g, '-')}-count`;
|
|
31
|
+
const needsCountRef = !!count && /\s/.test(label);
|
|
32
|
+
const base = {
|
|
33
|
+
name: label,
|
|
34
|
+
count,
|
|
35
|
+
visual: icon || needsCountRef ? (_jsxs(_Fragment, { children: [icon && _jsx(Icon, { name: icon }), needsCountRef && _jsx(VisuallyHiddenText, { id: countId, children: String(count) })] })) : undefined,
|
|
36
|
+
...(needsCountRef && { 'aria-labelledby': countId })
|
|
37
|
+
};
|
|
38
|
+
if (action.type === 'navigation') {
|
|
39
|
+
const hintId = `${id}-new-tab-hint`;
|
|
40
|
+
return {
|
|
41
|
+
...base,
|
|
42
|
+
visual: (_jsxs(_Fragment, { children: [base.visual, _jsx(VisuallyHiddenText, { id: hintId, children: newTabHint })] })),
|
|
43
|
+
'aria-labelledby': needsCountRef ? `${countId} ${hintId}` : hintId,
|
|
44
|
+
onClick: () => {
|
|
45
|
+
action.onClick();
|
|
46
|
+
window.open(action.href, '_blank', 'noopener,noreferrer');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (action.renderTarget === 'popover') {
|
|
51
|
+
return {
|
|
52
|
+
...base,
|
|
53
|
+
drawerHeader: label,
|
|
54
|
+
drawerView: (_jsx(PopoverDrawerView, { onOpen: action.onClick, children: popover?.actionId === id ? popover.children : null }, id)),
|
|
55
|
+
onDrawerClose: popover?.onDismiss
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
...base,
|
|
60
|
+
onClick: () => {
|
|
61
|
+
if (action.renderTarget === 'panel1' && panel1?.actionId === id)
|
|
62
|
+
panel1.onClose?.();
|
|
63
|
+
else
|
|
64
|
+
action.onClick();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
export default getHeaderActionUtilItems;
|
|
69
|
+
//# sourceMappingURL=headerActionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerActionUtils.js","sourceRoot":"","sources":["../../../src/components/AppShell/headerActionUtils.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,qJAAqJ;AACrJ,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAgD,EAAE,EAAE;IAC/F,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,CAAC;IACX,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChD,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;YAC1B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAC1C,+FAA+F;QAC/F,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC1C,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC,CAAC;AASF,qGAAqG;AACrG,MAAM,wBAAwB,GAAG,CAC/B,OAAsB,EACtB,EAAE,MAAM,EAAE,OAAO,EAAE,UA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qB,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,CACV,KAAC,iBAAiB,IAAU,MAAM,EAAE,MAAM,CAAC,OAAO,YAC/C,OAAO,EAAE,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAD7B,EAAE,CAEN,CACrB;YACD,aAAa,EAAE,OAAO,EAAE,SAAS;SAClC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,MAAM,CAAC,YAAY,KAAK,QAAQ,IAAI,MAAM,EAAE,QAAQ,KAAK,EAAE;gBAAE,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;;gBAC/E,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,eAAe,wBAAwB,CAAC","sourcesContent":["import { useContext, useEffect, useRef } from 'react';\nimport type { ReactNode } from 'react';\n\nimport Icon from '../Icon';\nimport VisuallyHiddenText from '../VisuallyHiddenText';\n\nimport type { ActionPopoverProps, ActionProps, UtilItemProps } from './AppShell.types';\nimport { AppShellDrawerContext } from './AppShellContext';\nimport type { PanelProps } from './Panel/Panel.types';\n\n/** Runs the action when its drawer opens, so a popover action can set the content it renders, and closes the drawer once that content is cleared. */\nconst PopoverDrawerView = ({ onOpen, children }: { onOpen: () => void; children?: ReactNode }) => {\n const { closeDrawer } = useContext(AppShellDrawerContext);\n const hadContent = useRef(false);\n\n useEffect(() => {\n onOpen();\n }, []);\n\n useEffect(() => {\n if (children !== null && children !== undefined) {\n hadContent.current = true;\n return undefined;\n }\n if (!hadContent.current) return undefined;\n // Deferred past the drawer's own refresh, which re-opens it in a parent effect of this render.\n const timeoutId = setTimeout(closeDrawer);\n return () => clearTimeout(timeoutId);\n }, [children]);\n\n return <>{children}</>;\n};\n\ninterface HeaderActionUtilOptions {\n panel1?: PanelProps;\n popover?: ActionPopoverProps;\n /** Localized text announced for navigation actions, which open in a new tab. */\n newTabHint: string;\n}\n\n/** Maps header actions to util items for the navigation drawer, where the header is not rendered. */\nconst getHeaderActionUtilItems = (\n actions: ActionProps[],\n { panel1, popover, newTabHint }: HeaderActionUtilOptions\n): UtilItemProps[] =>\n actions.map(action => {\n const { id, label, icon, count } = action;\n // The nav list references the count by a label-based id, which breaks when the label has spaces.\n const countId = `${id.replace(/\\s+/g, '-')}-count`;\n const needsCountRef = !!count && /\\s/.test(label);\n const base = {\n name: label,\n count,\n visual:\n icon || needsCountRef ? (\n <>\n {icon && <Icon name={icon} />}\n {needsCountRef && <VisuallyHiddenText id={countId}>{String(count)}</VisuallyHiddenText>}\n </>\n ) : undefined,\n ...(needsCountRef && { 'aria-labelledby': countId })\n };\n\n if (action.type === 'navigation') {\n const hintId = `${id}-new-tab-hint`;\n\n return {\n ...base,\n visual: (\n <>\n {base.visual}\n <VisuallyHiddenText id={hintId}>{newTabHint}</VisuallyHiddenText>\n </>\n ),\n 'aria-labelledby': needsCountRef ? `${countId} ${hintId}` : hintId,\n onClick: () => {\n action.onClick();\n window.open(action.href, '_blank', 'noopener,noreferrer');\n }\n };\n }\n\n if (action.renderTarget === 'popover') {\n return {\n ...base,\n drawerHeader: label,\n drawerView: (\n <PopoverDrawerView key={id} onOpen={action.onClick}>\n {popover?.actionId === id ? popover.children : null}\n </PopoverDrawerView>\n ),\n onDrawerClose: popover?.onDismiss\n };\n }\n\n return {\n ...base,\n onClick: () => {\n if (action.renderTarget === 'panel1' && panel1?.actionId === id) panel1.onClose?.();\n else action.onClick();\n }\n };\n });\n\nexport default getHeaderActionUtilItems;\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { default } from './AppShell';
|
|
2
2
|
export { default as AppShellList } from './AppShellList';
|
|
3
3
|
export type { AppShellListProps } from './AppShellList';
|
|
4
|
-
export type { AppHeaderProps, AppShellProps, ContextSwitcherProps, DrawerItemProps, DrawerListProps, NavOrientation, ShareAppConfig, PortalSwitcherConfig, DocumentTab, DocumentTabsProps, DocumentTabGroup, NotificationsProps } from './AppShell.types';
|
|
4
|
+
export type { ActionPopoverProps, ActionProps, ActionRenderTarget, AppHeaderProps, AppShellProps, ContextSwitcherProps, DrawerItemProps, DrawerListProps, NavigationActionProps, NavOrientation, RenderActionProps, ShareAppConfig, PortalSwitcherConfig, DocumentTab, DocumentTabsProps, DocumentTabGroup, NotificationsProps } from './AppShell.types';
|
|
5
|
+
export type { PanelActionProps, PanelProps } from './Panel/Panel.types';
|
|
5
6
|
export { default as AppShellContext, AppShellDrawerContext } from './AppShellContext';
|
|
6
7
|
export { default as ContextSwitcher } from './ContextSwitcher';
|
|
7
8
|
export { default as ThemeSwitcher } from './ThemeSwitcher';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/AppShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsBzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { default } from './AppShell';\nexport { default as AppShellList } from './AppShellList';\nexport type { AppShellListProps } from './AppShellList';\nexport type {\n ActionPopoverProps,\n ActionProps,\n ActionRenderTarget,\n AppHeaderProps,\n AppShellProps,\n ContextSwitcherProps,\n DrawerItemProps,\n DrawerListProps,\n NavigationActionProps,\n NavOrientation,\n RenderActionProps,\n ShareAppConfig,\n PortalSwitcherConfig,\n DocumentTab,\n DocumentTabsProps,\n DocumentTabGroup,\n NotificationsProps\n} from './AppShell.types';\nexport type { PanelActionProps, PanelProps } from './Panel/Panel.types';\nexport { default as AppShellContext, AppShellDrawerContext } from './AppShellContext';\nexport { default as ContextSwitcher } from './ContextSwitcher';\nexport { default as ThemeSwitcher } from './ThemeSwitcher';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionComponent, ReactNode } from 'react';
|
|
1
|
+
import type { FunctionComponent, ReactNode, TransitionEventHandler } from 'react';
|
|
2
2
|
import type { AsProp, BaseProps, ForwardProps } from '../../types';
|
|
3
3
|
export interface DrawerProps extends AsProp, BaseProps {
|
|
4
4
|
/**
|
|
@@ -40,6 +40,14 @@ export interface DrawerProps extends AsProp, BaseProps {
|
|
|
40
40
|
* @internal Can only be used with one drawer at a time.
|
|
41
41
|
*/
|
|
42
42
|
resizeable?: boolean;
|
|
43
|
+
/** Accessible label for the resize handle. */
|
|
44
|
+
resizeLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* CSS custom property that stores the resizable width. Set a unique one when another resizable drawer can be open at the same time.
|
|
47
|
+
* @default '--resize-drawer-width'
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
resizeProperty?: string;
|
|
43
51
|
/** Callback fired after Drawer opens. */
|
|
44
52
|
onAfterOpen?: () => void;
|
|
45
53
|
/** Callback fired after Drawer closes. */
|
|
@@ -48,6 +56,8 @@ export interface DrawerProps extends AsProp, BaseProps {
|
|
|
48
56
|
onBeforeOpen?: () => void;
|
|
49
57
|
/** Callback fired before Drawer closes. */
|
|
50
58
|
onBeforeClose?: () => void;
|
|
59
|
+
/** Callback fired when a transition ends on the Drawer. */
|
|
60
|
+
onTransitionEnd?: TransitionEventHandler<HTMLDivElement>;
|
|
51
61
|
/** Callback fired when a click action occurs outside of the Drawer. */
|
|
52
62
|
onOuterClick?: () => void;
|
|
53
63
|
/**
|
|
@@ -59,6 +69,7 @@ export interface DrawerProps extends AsProp, BaseProps {
|
|
|
59
69
|
type State = 'open' | 'closed' | 'opening' | 'closing';
|
|
60
70
|
export declare const StyledDrawer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Partial<DrawerProps & {
|
|
61
71
|
state: State;
|
|
72
|
+
$resizeProperty: string;
|
|
62
73
|
}>>> & string;
|
|
63
74
|
export declare const Drawer: FunctionComponent<DrawerProps & ForwardProps>;
|
|
64
75
|
export default Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/Drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,SAAS,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/Drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,SAAS,EAET,sBAAsB,EAGvB,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAanE,MAAM,WAAW,WAAY,SAAQ,MAA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,7 +9,7 @@ import { resizeDrawerKeyboardStep, resizeDrawerMaxWidth, resizeDrawerMinWidth }
|
|
|
9
9
|
import ResizeHandle from './ResizeHandle';
|
|
10
10
|
const drawerMinWidth = remToPx(resizeDrawerMinWidth);
|
|
11
11
|
export const StyledDrawer = styled.div(props => {
|
|
12
|
-
const { state, shadow, position, placement, transitionSpeed, size, resizeable, theme } = props;
|
|
12
|
+
const { state, shadow, position, placement, transitionSpeed, size, resizeable, $resizeProperty = '--resize-drawer-width', theme } = props;
|
|
13
13
|
let dimension = 'horizontal';
|
|
14
14
|
let axis = 'X';
|
|
15
15
|
let anchor = 'top';
|
|
@@ -41,7 +41,7 @@ export const StyledDrawer = styled.div(props => {
|
|
|
41
41
|
|
|
42
42
|
${resizeable &&
|
|
43
43
|
css `
|
|
44
|
-
width: ${dimension === 'horizontal' ?
|
|
44
|
+
width: ${dimension === 'horizontal' ? `var(${$resizeProperty})` : '100%'};
|
|
45
45
|
`}
|
|
46
46
|
|
|
47
47
|
${position === 'fixed' &&
|
|
@@ -55,7 +55,7 @@ export const StyledDrawer = styled.div(props => {
|
|
|
55
55
|
});
|
|
56
56
|
StyledDrawer.defaultProps = defaultThemeProp;
|
|
57
57
|
export const Drawer = forwardRef(function Drawer(props, ref) {
|
|
58
|
-
const { open = false, shadow = false, position = 'absolute', children, placement = 'right', transitionSpeed, size = '100%', resizeable = false, onAfterOpen, onAfterClose, onBeforeOpen, onBeforeClose, onOuterClick, nullWhenClosed = false, ...restProps } = props;
|
|
58
|
+
const { open = false, shadow = false, position = 'absolute', children, placement = 'right', transitionSpeed, size = '100%', resizeable = false, resizeLabel, resizeProperty = '--resize-drawer-width', onAfterOpen, onAfterClose, onBeforeOpen, onBeforeClose, onTransitionEnd: onTransitionEndProp, onOuterClick, nullWhenClosed = false, ...restProps } = props;
|
|
59
59
|
const drawerRef = useConsolidatedRef(ref);
|
|
60
60
|
const { ltr, rtl } = useDirection();
|
|
61
61
|
const [state, setState] = useState(open ? 'open' : 'closed');
|
|
@@ -83,11 +83,12 @@ export const Drawer = forwardRef(function Drawer(props, ref) {
|
|
|
83
83
|
onAfterClose?.();
|
|
84
84
|
}
|
|
85
85
|
}, [open, state, prevState, onBeforeOpen, onBeforeClose, onAfterOpen, onAfterClose]);
|
|
86
|
-
const
|
|
87
|
-
if (e.target
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
const handleTransitionEnd = useCallback((e) => {
|
|
87
|
+
if (e.target === drawerRef.current && e.propertyName === 'transform') {
|
|
88
|
+
setState(open ? 'open' : 'closed');
|
|
89
|
+
}
|
|
90
|
+
onTransitionEndProp?.(e);
|
|
91
|
+
}, [open, onTransitionEndProp]);
|
|
91
92
|
const dragStartXRef = useRef();
|
|
92
93
|
useEffect(() => {
|
|
93
94
|
if (!resizeable || !drawerRef.current)
|
|
@@ -95,15 +96,15 @@ export const Drawer = forwardRef(function Drawer(props, ref) {
|
|
|
95
96
|
const targetNode = getChildOfRootNode(drawerRef);
|
|
96
97
|
if (!targetNode)
|
|
97
98
|
return;
|
|
98
|
-
if (!targetNode.style.getPropertyValue(
|
|
99
|
-
targetNode.style.setProperty(
|
|
99
|
+
if (!targetNode.style.getPropertyValue(resizeProperty)) {
|
|
100
|
+
targetNode.style.setProperty(resizeProperty, size);
|
|
100
101
|
}
|
|
101
|
-
}, [drawerRef.current]);
|
|
102
|
+
}, [drawerRef.current, resizeProperty]);
|
|
102
103
|
const handleResize = useCallback((e) => {
|
|
103
104
|
const targetNode = getChildOfRootNode(drawerRef);
|
|
104
105
|
const rect = drawerRef.current?.getBoundingClientRect();
|
|
105
106
|
if (!rect || !targetNode)
|
|
106
|
-
return;
|
|
107
|
+
return undefined;
|
|
107
108
|
dragStartXRef.current = e.clientX;
|
|
108
109
|
const ac = new AbortController();
|
|
109
110
|
targetNode.addEventListener('mousemove', moveEvent => {
|
|
@@ -113,12 +114,10 @@ export const Drawer = forwardRef(function Drawer(props, ref) {
|
|
|
113
114
|
const widthDiff = placement === 'right' ? initialX - moveEvent.clientX : moveEvent.clientX - initialX;
|
|
114
115
|
const newWidth = Math.max(widthDiff + rect.width, parseInt(drawerMinWidth, 10));
|
|
115
116
|
// Set root-level CSS variable to communicate width to AppShell
|
|
116
|
-
targetNode.style.setProperty(
|
|
117
|
+
targetNode.style.setProperty(resizeProperty, `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`);
|
|
117
118
|
}, { passive: true, signal: ac.signal });
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}, { once: true });
|
|
121
|
-
}, [placement]);
|
|
119
|
+
return () => ac.abort();
|
|
120
|
+
}, [placement, resizeProperty]);
|
|
122
121
|
const keyboardResize = useCallback((e, grabbed) => {
|
|
123
122
|
if (!grabbed)
|
|
124
123
|
return;
|
|
@@ -133,12 +132,12 @@ export const Drawer = forwardRef(function Drawer(props, ref) {
|
|
|
133
132
|
e.stopPropagation();
|
|
134
133
|
const resizeDirection = (e.code === 'ArrowLeft' ? 1 : -1) * (placement === 'right' ? 1 : -1);
|
|
135
134
|
const newWidth = Math.max(rect.width + resizeDirection * resizeStep, parseInt(drawerMinWidth, 10));
|
|
136
|
-
targetNode.style.setProperty(
|
|
137
|
-
}, [placement]);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return state === 'closed' && !open && nullWhenClosed ? null : (_jsxs(StyledDrawer, { ref: drawerRef, position: position, shadow: shadow && open, transitionSpeed: transitionSpeed, placement: placement, size: size, resizeable: resizeable, open: open, state: state, onTransitionEnd:
|
|
135
|
+
targetNode.style.setProperty(resizeProperty, `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`);
|
|
136
|
+
}, [placement, resizeProperty]);
|
|
137
|
+
// The handle sits on the drawer edge facing the page content.
|
|
138
|
+
const handleAtEnd = (placement === 'left' && ltr) || (placement === 'right' && rtl);
|
|
139
|
+
const renderResizeHandle = resizeable && state === 'open' && (placement === 'left' || placement === 'right');
|
|
140
|
+
return state === 'closed' && !open && nullWhenClosed ? null : (_jsxs(StyledDrawer, { ref: drawerRef, position: position, shadow: shadow && open, transitionSpeed: transitionSpeed, placement: placement, size: size, resizeable: resizeable, "$resizeProperty": resizeProperty, open: open, state: state, onTransitionEnd: handleTransitionEnd, ...restProps, children: [children, renderResizeHandle && (_jsx(ResizeHandle, { onMouseDown: handleResize, onKeyDown: keyboardResize, contextualLabel: resizeLabel, edge: handleAtEnd ? 'end' : 'start' }))] }));
|
|
142
141
|
});
|
|
143
142
|
export default Drawer;
|
|
144
143
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/Drawer/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAS7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,MAAM,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AA6DrD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAA0C,KAAK,CAAC,EAAE;IACtF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI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BAAuB,EACvB,SAAS,cAAc,KAAK,QAAQ,OAAO,oBAAoB,GAAG,CACnE,CAAC;IACJ,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,MAAM,kBAAkB,GACtB,UAAU;QACV,KAAK,KAAK,MAAM;QAChB,CAAC,CAAC,SAAS,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC;IAEpE,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,MAAC,YAAY,IACX,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,IAAI,IAAI,EACtB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,KAC5B,SAAS,aAEZ,QAAQ,EACR,kBAAkB,IAAI,KAAC,YAAY,IAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,GAAI,IAChF,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useEffect, useCallback, forwardRef, useState, useRef } from 'react';\nimport type {\n Ref,\n FunctionComponent,\n ReactNode,\n TransitionEvent,\n MouseEvent as ReactMouseEvent,\n KeyboardEvent as ReactKeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { remToPx } from 'polished';\n\nimport { useOuterEvent, useConsolidatedRef, usePrevious, useDirection } from '../../hooks';\nimport type { AsProp, BaseProps, ForwardProps } from '../../types';\nimport { getChildOfRootNode, reflow } from '../../utils';\nimport { defaultThemeProp } from '../../theme';\nimport {\n resizeDrawerKeyboardStep,\n resizeDrawerMaxWidth,\n resizeDrawerMinWidth\n} from '../../styles/constants';\n\nimport ResizeHandle from './ResizeHandle';\n\nconst drawerMinWidth = remToPx(resizeDrawerMinWidth);\n\nexport interface DrawerProps extends AsProp, BaseProps {\n /**\n * If true, the Drawer will be visible.\n * @default false\n */\n open: boolean;\n /** Content of the Drawer. */\n children?: ReactNode;\n /**\n * Determines whether a drop shadow should be visible along the edge of the Drawer for contrast purposes.\n * @default false\n */\n shadow?: boolean;\n /**\n * Used to determine which side of the viewport the Drawer should open from.\n * @default 'right'\n */\n placement?: 'top' | 'right' | 'bottom' | 'left';\n /**\n * The position of the Drawer.\n * @default 'absolute'\n */\n position?: 'absolute' | 'fixed';\n /**\n * Determines the speed of the transition. This value comes from `theme.base.animation.speed`.\n * @default '0.25s'\n */\n transitionSpeed?: string;\n /**\n * The width or height that the Drawer will open to, depending on its placement.\n * If `resizeable`, is true this value will be overridden by the width set by the user.\n * @default '100%'\n */\n size?: string;\n /**\n * If true, the Drawer will be resizable. Will not be applied if `placement` is set to `top` or `bottom`.\n * @default false\n * @internal Can only be used with one drawer at a time.\n */\n resizeable?: boolean;\n /** Callback fired after Drawer opens. */\n onAfterOpen?: () => void;\n /** Callback fired after Drawer closes. */\n onAfterClose?: () => void;\n /** Callback fired before Drawer opens. */\n onBeforeOpen?: () => void;\n /** Callback fired before Drawer closes. */\n onBeforeClose?: () => void;\n /** Callback fired when a click action occurs outside of the Drawer. */\n onOuterClick?: () => void;\n /**\n * If true, removes the component from the real DOM when closed. For full virtual DOM unmount(if necessary), perform at a parent level.\n * @default false\n */\n nullWhenClosed?: boolean;\n}\n\ntype State = 'open' | 'closed' | 'opening' | 'closing';\n\nexport const StyledDrawer = styled.div<Partial<DrawerProps & { state: State }>>(props => {\n const { state, shadow, position, placement, transitionSpeed, size, resizeable, theme } = props;\n let dimension = 'horizontal';\n let axis = 'X';\n let anchor = 'top';\n\n if (placement === 'top' || placement === 'bottom') {\n dimension = 'vertical';\n axis = 'Y';\n anchor = 'left';\n }\n\n const translate = state === 'open' || state === 'opening' ? 0 : '100%';\n const speed = transitionSpeed || theme.base.animation.speed;\n\n return css`\n z-index: ${theme.base['z-index'].drawer};\n position: ${position};\n ${placement}: 0;\n ${anchor}: 0;\n height: ${dimension === 'vertical' ? size : '100%'};\n width: ${dimension === 'horizontal' ? size : '100%'};\n transition-property: transform, box-shadow, opacity;\n transition-duration: max(${speed}, 0.0001s);\n transition-timing-function: ${theme.base.animation.timing.ease};\n transform: ${state === 'open'\n ? 'none'\n : `translate${axis}(${placement === 'top' || placement === 'left' ? '-' : ''}${translate})`};\n\n ${shadow &&\n css`\n box-shadow: ${theme.base.shadow.high};\n `}\n\n ${resizeable &&\n css`\n width: ${dimension === 'horizontal' ? 'var(--resize-drawer-width)' : '100%'};\n `}\n\n ${position === 'fixed' &&\n (placement === 'left' || placement === 'right') &&\n css`\n /* stylelint-disable unit-allowed-list, length-zero-no-unit */\n padding-${placement}: env(safe-area-inset-${placement}, 0px);\n /* stylelint-enable unit-allowed-list, length-zero-no-unit */\n `}\n `;\n});\n\nStyledDrawer.defaultProps = defaultThemeProp;\n\nexport const Drawer: FunctionComponent<DrawerProps & ForwardProps> = forwardRef(function Drawer(\n props: DrawerProps,\n ref: Ref<HTMLElement>\n) {\n const {\n open = false,\n shadow = false,\n position = 'absolute',\n children,\n placement = 'right',\n transitionSpeed,\n size = '100%',\n resizeable = false,\n onAfterOpen,\n onAfterClose,\n onBeforeOpen,\n onBeforeClose,\n onOuterClick,\n nullWhenClosed = false,\n ...restProps\n } = props;\n\n const drawerRef = useConsolidatedRef(ref);\n const { ltr, rtl } = useDirection();\n\n const [state, setState] = useState<State>(open ? 'open' : 'closed');\n\n let prevState = usePrevious(state);\n if (!prevState) prevState = state;\n\n useOuterEvent(\n 'mousedown',\n [drawerRef],\n useCallback(() => {\n if (open) onOuterClick?.();\n }, [open, onOuterClick])\n );\n\n useEffect(() => {\n if (open && (state === 'closed' || state === 'closing')) {\n onBeforeOpen?.();\n reflow(drawerRef.current);\n setState('opening');\n } else if (!open && (state === 'open' || state === 'opening')) {\n onBeforeClose?.();\n setState('closing');\n } else if (open && state === 'open' && prevState !== 'open') {\n onAfterOpen?.();\n } else if (!open && state === 'closed' && prevState !== 'closed') {\n onAfterClose?.();\n }\n }, [open, state, prevState, onBeforeOpen, onBeforeClose, onAfterOpen, onAfterClose]);\n\n const onTransitionEnd = useCallback(\n (e: TransitionEvent): void => {\n if (e.target !== drawerRef.current || e.propertyName !== 'transform') return;\n setState(open ? 'open' : 'closed');\n },\n [open]\n );\n\n const dragStartXRef = useRef<number>();\n\n useEffect(() => {\n if (!resizeable || !drawerRef.current) return;\n const targetNode = getChildOfRootNode(drawerRef);\n if (!targetNode) return;\n if (!targetNode.style.getPropertyValue('--resize-drawer-width')) {\n targetNode.style.setProperty('--resize-drawer-width', size);\n }\n }, [drawerRef.current]);\n\n const handleResize = useCallback(\n (e: ReactMouseEvent) => {\n const targetNode = getChildOfRootNode(drawerRef);\n const rect = drawerRef.current?.getBoundingClientRect();\n if (!rect || !targetNode) return;\n\n dragStartXRef.current = e.clientX;\n\n const ac = new AbortController();\n targetNode.addEventListener(\n 'mousemove',\n moveEvent => {\n if (!dragStartXRef.current || !rect.width) return;\n\n const initialX = dragStartXRef.current;\n const widthDiff =\n placement === 'right' ? initialX - moveEvent.clientX : moveEvent.clientX - initialX;\n\n const newWidth = Math.max(widthDiff + rect.width, parseInt(drawerMinWidth, 10));\n\n // Set root-level CSS variable to communicate width to AppShell\n targetNode.style.setProperty(\n '--resize-drawer-width',\n `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`\n );\n },\n { passive: true, signal: ac.signal }\n );\n\n targetNode.addEventListener(\n 'mouseup',\n () => {\n ac.abort();\n },\n { once: true }\n );\n },\n [placement]\n );\n\n const keyboardResize = useCallback(\n (e: ReactKeyboardEvent, grabbed: boolean) => {\n if (!grabbed) return;\n const targetNode = getChildOfRootNode(drawerRef);\n const resizeStep = document.documentElement.clientWidth * resizeDrawerKeyboardStep;\n const rect = drawerRef.current?.getBoundingClientRect();\n if (!rect || !targetNode) return;\n if (e.code !== 'ArrowLeft' && e.code !== 'ArrowRight') return;\n e.preventDefault();\n e.stopPropagation();\n\n const resizeDirection = (e.code === 'ArrowLeft' ? 1 : -1) * (placement === 'right' ? 1 : -1);\n\n const newWidth = Math.max(\n rect.width + resizeDirection * resizeStep,\n parseInt(drawerMinWidth, 10)\n );\n targetNode.style.setProperty(\n '--resize-drawer-width',\n `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`\n );\n },\n [placement]\n );\n\n const renderResizeHandle =\n resizeable &&\n state === 'open' &&\n ((placement === 'left' && rtl) || (placement === 'right' && ltr));\n\n return state === 'closed' && !open && nullWhenClosed ? null : (\n <StyledDrawer\n ref={drawerRef}\n position={position}\n shadow={shadow && open}\n transitionSpeed={transitionSpeed}\n placement={placement}\n size={size}\n resizeable={resizeable}\n open={open}\n state={state}\n onTransitionEnd={onTransitionEnd}\n {...restProps}\n >\n {children}\n {renderResizeHandle && <ResizeHandle onMouseDown={handleResize} onKeyDown={keyboardResize} />}\n </StyledDrawer>\n );\n});\n\nexport default Drawer;\n"]}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/components/Drawer/Drawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAU7E,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;A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S,aAEZ,QAAQ,EACR,kBAAkB,IAAI,CACrB,KAAC,YAAY,IACX,WAAW,EAAE,YAAY,EACzB,SAAS,EAAE,cAAc,EACzB,eAAe,EAAE,WAAW,EAC5B,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,GACnC,CACH,IACY,CAChB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC","sourcesContent":["import { useEffect, useCallback, forwardRef, useState, useRef } from 'react';\nimport type {\n Ref,\n FunctionComponent,\n ReactNode,\n TransitionEvent,\n TransitionEventHandler,\n MouseEvent as ReactMouseEvent,\n KeyboardEvent as ReactKeyboardEvent\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { remToPx } from 'polished';\n\nimport { useOuterEvent, useConsolidatedRef, usePrevious, useDirection } from '../../hooks';\nimport type { AsProp, BaseProps, ForwardProps } from '../../types';\nimport { getChildOfRootNode, reflow } from '../../utils';\nimport { defaultThemeProp } from '../../theme';\nimport {\n resizeDrawerKeyboardStep,\n resizeDrawerMaxWidth,\n resizeDrawerMinWidth\n} from '../../styles/constants';\n\nimport ResizeHandle from './ResizeHandle';\n\nconst drawerMinWidth = remToPx(resizeDrawerMinWidth);\n\nexport interface DrawerProps extends AsProp, BaseProps {\n /**\n * If true, the Drawer will be visible.\n * @default false\n */\n open: boolean;\n /** Content of the Drawer. */\n children?: ReactNode;\n /**\n * Determines whether a drop shadow should be visible along the edge of the Drawer for contrast purposes.\n * @default false\n */\n shadow?: boolean;\n /**\n * Used to determine which side of the viewport the Drawer should open from.\n * @default 'right'\n */\n placement?: 'top' | 'right' | 'bottom' | 'left';\n /**\n * The position of the Drawer.\n * @default 'absolute'\n */\n position?: 'absolute' | 'fixed';\n /**\n * Determines the speed of the transition. This value comes from `theme.base.animation.speed`.\n * @default '0.25s'\n */\n transitionSpeed?: string;\n /**\n * The width or height that the Drawer will open to, depending on its placement.\n * If `resizeable`, is true this value will be overridden by the width set by the user.\n * @default '100%'\n */\n size?: string;\n /**\n * If true, the Drawer will be resizable. Will not be applied if `placement` is set to `top` or `bottom`.\n * @default false\n * @internal Can only be used with one drawer at a time.\n */\n resizeable?: boolean;\n /** Accessible label for the resize handle. */\n resizeLabel?: string;\n /**\n * CSS custom property that stores the resizable width. Set a unique one when another resizable drawer can be open at the same time.\n * @default '--resize-drawer-width'\n * @internal\n */\n resizeProperty?: string;\n /** Callback fired after Drawer opens. */\n onAfterOpen?: () => void;\n /** Callback fired after Drawer closes. */\n onAfterClose?: () => void;\n /** Callback fired before Drawer opens. */\n onBeforeOpen?: () => void;\n /** Callback fired before Drawer closes. */\n onBeforeClose?: () => void;\n /** Callback fired when a transition ends on the Drawer. */\n onTransitionEnd?: TransitionEventHandler<HTMLDivElement>;\n /** Callback fired when a click action occurs outside of the Drawer. */\n onOuterClick?: () => void;\n /**\n * If true, removes the component from the real DOM when closed. For full virtual DOM unmount(if necessary), perform at a parent level.\n * @default false\n */\n nullWhenClosed?: boolean;\n}\n\ntype State = 'open' | 'closed' | 'opening' | 'closing';\n\nexport const StyledDrawer = styled.div<\n Partial<DrawerProps & { state: State; $resizeProperty: string }>\n>(props => {\n const {\n state,\n shadow,\n position,\n placement,\n transitionSpeed,\n size,\n resizeable,\n $resizeProperty = '--resize-drawer-width',\n theme\n } = props;\n let dimension = 'horizontal';\n let axis = 'X';\n let anchor = 'top';\n\n if (placement === 'top' || placement === 'bottom') {\n dimension = 'vertical';\n axis = 'Y';\n anchor = 'left';\n }\n\n const translate = state === 'open' || state === 'opening' ? 0 : '100%';\n const speed = transitionSpeed || theme.base.animation.speed;\n\n return css`\n z-index: ${theme.base['z-index'].drawer};\n position: ${position};\n ${placement}: 0;\n ${anchor}: 0;\n height: ${dimension === 'vertical' ? size : '100%'};\n width: ${dimension === 'horizontal' ? size : '100%'};\n transition-property: transform, box-shadow, opacity;\n transition-duration: max(${speed}, 0.0001s);\n transition-timing-function: ${theme.base.animation.timing.ease};\n transform: ${state === 'open'\n ? 'none'\n : `translate${axis}(${placement === 'top' || placement === 'left' ? '-' : ''}${translate})`};\n\n ${shadow &&\n css`\n box-shadow: ${theme.base.shadow.high};\n `}\n\n ${resizeable &&\n css`\n width: ${dimension === 'horizontal' ? `var(${$resizeProperty})` : '100%'};\n `}\n\n ${position === 'fixed' &&\n (placement === 'left' || placement === 'right') &&\n css`\n /* stylelint-disable unit-allowed-list, length-zero-no-unit */\n padding-${placement}: env(safe-area-inset-${placement}, 0px);\n /* stylelint-enable unit-allowed-list, length-zero-no-unit */\n `}\n `;\n});\n\nStyledDrawer.defaultProps = defaultThemeProp;\n\nexport const Drawer: FunctionComponent<DrawerProps & ForwardProps> = forwardRef(function Drawer(\n props: DrawerProps,\n ref: Ref<HTMLElement>\n) {\n const {\n open = false,\n shadow = false,\n position = 'absolute',\n children,\n placement = 'right',\n transitionSpeed,\n size = '100%',\n resizeable = false,\n resizeLabel,\n resizeProperty = '--resize-drawer-width',\n onAfterOpen,\n onAfterClose,\n onBeforeOpen,\n onBeforeClose,\n onTransitionEnd: onTransitionEndProp,\n onOuterClick,\n nullWhenClosed = false,\n ...restProps\n } = props;\n\n const drawerRef = useConsolidatedRef(ref);\n const { ltr, rtl } = useDirection();\n\n const [state, setState] = useState<State>(open ? 'open' : 'closed');\n\n let prevState = usePrevious(state);\n if (!prevState) prevState = state;\n\n useOuterEvent(\n 'mousedown',\n [drawerRef],\n useCallback(() => {\n if (open) onOuterClick?.();\n }, [open, onOuterClick])\n );\n\n useEffect(() => {\n if (open && (state === 'closed' || state === 'closing')) {\n onBeforeOpen?.();\n reflow(drawerRef.current);\n setState('opening');\n } else if (!open && (state === 'open' || state === 'opening')) {\n onBeforeClose?.();\n setState('closing');\n } else if (open && state === 'open' && prevState !== 'open') {\n onAfterOpen?.();\n } else if (!open && state === 'closed' && prevState !== 'closed') {\n onAfterClose?.();\n }\n }, [open, state, prevState, onBeforeOpen, onBeforeClose, onAfterOpen, onAfterClose]);\n\n const handleTransitionEnd = useCallback(\n (e: TransitionEvent<HTMLDivElement>): void => {\n if (e.target === drawerRef.current && e.propertyName === 'transform') {\n setState(open ? 'open' : 'closed');\n }\n onTransitionEndProp?.(e);\n },\n [open, onTransitionEndProp]\n );\n\n const dragStartXRef = useRef<number>();\n\n useEffect(() => {\n if (!resizeable || !drawerRef.current) return;\n const targetNode = getChildOfRootNode(drawerRef);\n if (!targetNode) return;\n if (!targetNode.style.getPropertyValue(resizeProperty)) {\n targetNode.style.setProperty(resizeProperty, size);\n }\n }, [drawerRef.current, resizeProperty]);\n\n const handleResize = useCallback(\n (e: ReactMouseEvent) => {\n const targetNode = getChildOfRootNode(drawerRef);\n const rect = drawerRef.current?.getBoundingClientRect();\n if (!rect || !targetNode) return undefined;\n\n dragStartXRef.current = e.clientX;\n\n const ac = new AbortController();\n targetNode.addEventListener(\n 'mousemove',\n moveEvent => {\n if (!dragStartXRef.current || !rect.width) return;\n\n const initialX = dragStartXRef.current;\n const widthDiff =\n placement === 'right' ? initialX - moveEvent.clientX : moveEvent.clientX - initialX;\n\n const newWidth = Math.max(widthDiff + rect.width, parseInt(drawerMinWidth, 10));\n\n // Set root-level CSS variable to communicate width to AppShell\n targetNode.style.setProperty(\n resizeProperty,\n `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`\n );\n },\n { passive: true, signal: ac.signal }\n );\n\n return () => ac.abort();\n },\n [placement, resizeProperty]\n );\n\n const keyboardResize = useCallback(\n (e: ReactKeyboardEvent, grabbed: boolean) => {\n if (!grabbed) return;\n const targetNode = getChildOfRootNode(drawerRef);\n const resizeStep = document.documentElement.clientWidth * resizeDrawerKeyboardStep;\n const rect = drawerRef.current?.getBoundingClientRect();\n if (!rect || !targetNode) return;\n if (e.code !== 'ArrowLeft' && e.code !== 'ArrowRight') return;\n e.preventDefault();\n e.stopPropagation();\n\n const resizeDirection = (e.code === 'ArrowLeft' ? 1 : -1) * (placement === 'right' ? 1 : -1);\n\n const newWidth = Math.max(\n rect.width + resizeDirection * resizeStep,\n parseInt(drawerMinWidth, 10)\n );\n targetNode.style.setProperty(\n resizeProperty,\n `clamp(${drawerMinWidth}, ${newWidth}px, ${resizeDrawerMaxWidth})`\n );\n },\n [placement, resizeProperty]\n );\n\n // The handle sits on the drawer edge facing the page content.\n const handleAtEnd = (placement === 'left' && ltr) || (placement === 'right' && rtl);\n const renderResizeHandle =\n resizeable && state === 'open' && (placement === 'left' || placement === 'right');\n\n return state === 'closed' && !open && nullWhenClosed ? null : (\n <StyledDrawer\n ref={drawerRef}\n position={position}\n shadow={shadow && open}\n transitionSpeed={transitionSpeed}\n placement={placement}\n size={size}\n resizeable={resizeable}\n $resizeProperty={resizeProperty}\n open={open}\n state={state}\n onTransitionEnd={handleTransitionEnd}\n {...restProps}\n >\n {children}\n {renderResizeHandle && (\n <ResizeHandle\n onMouseDown={handleResize}\n onKeyDown={keyboardResize}\n contextualLabel={resizeLabel}\n edge={handleAtEnd ? 'end' : 'start'}\n />\n )}\n </StyledDrawer>\n );\n});\n\nexport default Drawer;\n"]}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
2
2
|
export interface ResizeHandleProps {
|
|
3
3
|
onKeyDown: (e: ReactKeyboardEvent, grabbed: boolean) => void;
|
|
4
|
-
onMouseDown: (e: ReactMouseEvent) => void;
|
|
4
|
+
onMouseDown: (e: ReactMouseEvent) => (() => void) | void;
|
|
5
5
|
contextualLabel?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Inline edge of the container the handle is attached to.
|
|
8
|
+
* @default 'start'
|
|
9
|
+
*/
|
|
10
|
+
edge?: 'start' | 'end';
|
|
6
11
|
}
|
|
7
|
-
export declare const StyledResizeHandle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").
|
|
12
|
+
export declare const StyledResizeHandle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
13
|
+
$edge?: "start" | "end";
|
|
14
|
+
}>> & string;
|
|
8
15
|
declare const ResizeHandle: import("react").ForwardRefExoticComponent<ResizeHandleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
9
16
|
export default ResizeHandle;
|
|
10
17
|
//# sourceMappingURL=ResizeHandle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/ResizeHandle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,IAAI,eAAe,EAC7B,aAAa,IAAI,kBAAkB,EACpC,MAAM,OAAO,CAAC;AAef,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,WAAW,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ResizeHandle.d.ts","sourceRoot":"","sources":["../../../src/components/Drawer/ResizeHandle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,UAAU,IAAI,eAAe,EAC7B,aAAa,IAAI,kBAAkB,EACpC,MAAM,OAAO,CAAC;AAef,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,WAAW,EAAE,CAAC,CAAC,EAAE,eAAe,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CACxB;AAyBD,eAAO,MAAM,kBAAkB;YAAwB,OAAO,GAAG,KAAK;YAsCpE,CAAC;AAIH,QAAA,MAAM,YAAY,8GAsFhB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState } from 'react';
|
|
2
|
+
import { forwardRef, useRef, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { hideVisually } from 'polished';
|
|
5
5
|
import Button, { StyledButton } from '../Button';
|
|
@@ -31,10 +31,11 @@ const StyledResizeButton = styled(Button)(({ rotateIcon }) => {
|
|
|
31
31
|
`}
|
|
32
32
|
`;
|
|
33
33
|
});
|
|
34
|
-
export const StyledResizeHandle = styled.div(({ theme }) => {
|
|
34
|
+
export const StyledResizeHandle = styled.div(({ theme, $edge }) => {
|
|
35
|
+
const atEnd = $edge === 'end';
|
|
35
36
|
return css `
|
|
36
37
|
position: absolute;
|
|
37
|
-
inset-inline-start: 0;
|
|
38
|
+
${atEnd ? 'inset-inline-end' : 'inset-inline-start'}: 0;
|
|
38
39
|
inset-block: 0;
|
|
39
40
|
inline-size: 0.125rem;
|
|
40
41
|
background-color: transparent;
|
|
@@ -47,6 +48,11 @@ export const StyledResizeHandle = styled.div(({ theme }) => {
|
|
|
47
48
|
position: absolute;
|
|
48
49
|
inset: 0;
|
|
49
50
|
width: calc(${theme.base['hit-area'].compact} * 0.75);
|
|
51
|
+
|
|
52
|
+
${atEnd &&
|
|
53
|
+
css `
|
|
54
|
+
inset-inline: auto 0;
|
|
55
|
+
`}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
&:hover {
|
|
@@ -56,22 +62,32 @@ export const StyledResizeHandle = styled.div(({ theme }) => {
|
|
|
56
62
|
${StyledButton} {
|
|
57
63
|
position: absolute;
|
|
58
64
|
inset-block-start: 50%;
|
|
59
|
-
inset-inline-start: calc(-2 * ${theme.base.spacing});
|
|
65
|
+
inset-inline-start: ${atEnd ? 'auto' : `calc(-2 * ${theme.base.spacing})`};
|
|
66
|
+
inset-inline-end: ${atEnd ? `calc(-2 * ${theme.base.spacing})` : 'auto'};
|
|
60
67
|
translate: 0 -50%;
|
|
61
68
|
box-shadow: ${theme.base.shadow.focus};
|
|
62
69
|
}
|
|
63
70
|
`;
|
|
64
71
|
});
|
|
65
72
|
StyledResizeHandle.defaultProps = defaultThemeProp;
|
|
66
|
-
const ResizeHandle = forwardRef(function ResizeHandle({ onMouseDown, onKeyDown, contextualLabel }, ref) {
|
|
73
|
+
const ResizeHandle = forwardRef(function ResizeHandle({ onMouseDown, onKeyDown, contextualLabel, edge = 'start' }, ref) {
|
|
67
74
|
const resizeHandleRef = useConsolidatedRef(ref);
|
|
68
75
|
const t = useI18n();
|
|
69
76
|
const [mouseGrabbed, setMouseGrabbed] = useState(false);
|
|
70
77
|
const [keyboardGrabbed, setKeyboardGrabbed] = useState(false);
|
|
78
|
+
const buttonRef = useRef(null);
|
|
79
|
+
const endMouseResizeRef = useRef();
|
|
71
80
|
useEscape(() => {
|
|
72
|
-
|
|
81
|
+
endMouseResizeRef.current?.();
|
|
73
82
|
setKeyboardGrabbed(false);
|
|
74
83
|
});
|
|
84
|
+
// Escape only cancels the grab, so it must not reach containers that close on Escape.
|
|
85
|
+
useEscape(e => {
|
|
86
|
+
if (!keyboardGrabbed)
|
|
87
|
+
return;
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
setKeyboardGrabbed(false);
|
|
90
|
+
}, buttonRef, [keyboardGrabbed]);
|
|
75
91
|
const handleKeyDown = (e) => {
|
|
76
92
|
if (e.code === 'Space') {
|
|
77
93
|
e.preventDefault();
|
|
@@ -88,21 +104,29 @@ const ResizeHandle = forwardRef(function ResizeHandle({ onMouseDown, onKeyDown,
|
|
|
88
104
|
const targetNode = getChildOfRootNode(resizeHandleRef);
|
|
89
105
|
if (!targetNode)
|
|
90
106
|
return;
|
|
107
|
+
const stopResize = onMouseDown?.(e);
|
|
108
|
+
const abortController = new AbortController();
|
|
91
109
|
targetNode.style.setProperty('user-select', 'none');
|
|
92
110
|
setMouseGrabbed(true);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
111
|
+
endMouseResizeRef.current = () => {
|
|
112
|
+
endMouseResizeRef.current = undefined;
|
|
113
|
+
abortController.abort();
|
|
114
|
+
if (typeof stopResize === 'function')
|
|
115
|
+
stopResize();
|
|
116
|
+
targetNode.style.removeProperty('user-select');
|
|
117
|
+
setMouseGrabbed(false);
|
|
118
|
+
};
|
|
119
|
+
['mouseup', 'pointercancel'].forEach(eventName => {
|
|
120
|
+
targetNode.addEventListener(eventName, () => endMouseResizeRef.current?.(), {
|
|
121
|
+
signal: abortController.signal
|
|
122
|
+
});
|
|
123
|
+
});
|
|
101
124
|
};
|
|
102
125
|
const label = contextualLabel || t('resize');
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
const instructions = !mouseGrabbed && !keyboardGrabbed
|
|
127
|
+
? t('drag_handle_activate_description')
|
|
128
|
+
: t('drag_handle_cancel_description');
|
|
129
|
+
return (_jsx(StyledResizeHandle, { "$edge": edge, onMouseDown: handleMouseDown, ref: resizeHandleRef, children: _jsx(StyledResizeButton, { ref: buttonRef, tabIndex: 0, icon: true, label: !mouseGrabbed && !keyboardGrabbed ? label : undefined, "aria-label": instructions, onKeyDown: handleKeyDown, onBlur: () => {
|
|
106
130
|
setKeyboardGrabbed(false);
|
|
107
131
|
}, rotateIcon: keyboardGrabbed, children: _jsx(Icon, { name: keyboardGrabbed ? 'arrow-micro-up-down' : 'drag' }) }) }));
|
|
108
132
|
});
|