@cloudscape-design/components 3.0.600 → 3.0.601
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/app-layout/classic.d.ts +5 -1
- package/app-layout/classic.d.ts.map +1 -1
- package/app-layout/classic.js +1 -1
- package/app-layout/classic.js.map +1 -1
- package/app-layout/implementation.d.ts +5 -1
- package/app-layout/implementation.d.ts.map +1 -1
- package/app-layout/implementation.js.map +1 -1
- package/app-layout/interfaces.d.ts +2 -0
- package/app-layout/interfaces.d.ts.map +1 -1
- package/app-layout/interfaces.js.map +1 -1
- package/app-layout/internal.d.ts +5 -1
- package/app-layout/internal.d.ts.map +1 -1
- package/app-layout/visual-refresh/context.d.ts +3 -3
- package/app-layout/visual-refresh/context.d.ts.map +1 -1
- package/app-layout/visual-refresh/context.js +1 -1
- package/app-layout/visual-refresh/context.js.map +1 -1
- package/app-layout/visual-refresh/index.d.ts +5 -1
- package/app-layout/visual-refresh/index.d.ts.map +1 -1
- package/app-layout/visual-refresh/index.js.map +1 -1
- package/app-layout/widget.d.ts +2 -2
- package/app-layout/widget.d.ts.map +1 -1
- package/app-layout/widget.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +2 -1
- package/button-dropdown/internal.js.map +1 -1
- package/calendar/grid/index.d.ts +1 -1
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js +16 -28
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js.map +1 -1
- package/date-range-picker/calendar/grids/grid.d.ts +1 -1
- package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/grid.js +4 -4
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/index.js +14 -28
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/grids/styles.css.js +27 -25
- package/date-range-picker/calendar/grids/styles.scoped.css +54 -54
- package/date-range-picker/calendar/grids/styles.selectors.js +27 -25
- package/internal/direction.d.ts +9 -0
- package/internal/direction.d.ts.map +1 -0
- package/internal/direction.js +15 -0
- package/internal/direction.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal/utils/handle-key.d.ts +13 -0
- package/internal/utils/handle-key.d.ts.map +1 -0
- package/internal/utils/handle-key.js +37 -0
- package/internal/utils/handle-key.js.map +1 -0
- package/package.json +1 -1
- package/segmented-control/internal-segmented-control.d.ts.map +1 -1
- package/segmented-control/internal-segmented-control.js +5 -6
- package/segmented-control/internal-segmented-control.js.map +1 -1
- package/table/body-cell/styles.css.js +43 -42
- package/table/body-cell/styles.scoped.css +203 -200
- package/table/body-cell/styles.selectors.js +43 -42
- package/table/body-cell/td-element.js +1 -1
- package/table/body-cell/td-element.js.map +1 -1
- package/table/index.d.ts.map +1 -1
- package/table/index.js +3 -0
- package/table/index.js.map +1 -1
- package/table/table-role/grid-navigation.js +8 -8
- package/table/table-role/grid-navigation.js.map +1 -1
- package/table/table-role/utils.js +1 -1
- package/table/table-role/utils.js.map +1 -1
- package/tabs/scroll-utils.d.ts +4 -4
- package/tabs/scroll-utils.d.ts.map +1 -1
- package/tabs/scroll-utils.js +14 -14
- package/tabs/scroll-utils.js.map +1 -1
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +25 -50
- package/tabs/tab-header-bar.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/context.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE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d,cAAc;YACd,SAAS,EACT,SAAS,EAAE,WAAW,EACtB,UAAU;YACV,SAAS;YACT,kBAAkB;QAGpB,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,EAAE;gBACL,kBAAkB,EAAE,YAAY;gBAChC,eAAe,EAAE,CAAC;gBAClB,sBAAsB;aACvB;YAED,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B,IACjE,QAAQ,CACsB,CACP,CACO,CACtC,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, {\n createContext,\n useCallback,\n useEffect,\n useLayoutEffect,\n useImperativeHandle,\n useRef,\n useState,\n useContext,\n} from 'react';\nimport { applyDefaults } from '../defaults';\nimport { AppLayoutContext } from '../../internal/context/app-layout-context';\nimport { DynamicOverlapContext } from '../../internal/context/dynamic-overlap-context';\nimport { AppLayoutProps } from '../interfaces';\nimport { fireNonCancelableEvent } from '../../internal/events';\nimport { FocusControlRefs, useFocusControl } from '../utils/use-focus-control';\nimport { getSplitPanelDefaultSize } from '../../split-panel/utils/size-utils';\nimport { isDevelopment } from '../../internal/is-development';\nimport { getSplitPanelPosition } from './split-panel';\nimport { useControllable } from '../../internal/hooks/use-controllable';\nimport { SplitPanelFocusControlRefs, useSplitPanelFocusControl } from '../utils/use-split-panel-focus-control';\nimport { SplitPanelSideToggleProps } from '../../internal/context/split-panel-context';\nimport { useObservedElement } from '../utils/use-observed-element';\nimport { useMobile } from '../../internal/hooks/use-mobile';\nimport { useStableCallback, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport useResize from '../utils/use-resize';\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport useBackgroundOverlap from './use-background-overlap';\nimport { useDrawers } from '../utils/use-drawers';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\n\ninterface AppLayoutInternals extends AppLayoutProps {\n activeDrawerId: string | null;\n drawers: Array<AppLayoutProps.Drawer> | undefined;\n drawersAriaLabel: string | undefined;\n drawersOverflowAriaLabel: string | undefined;\n drawersOverflowWithBadgeAriaLabel: string | undefined;\n drawersRefs: FocusControlRefs;\n drawerSize: number;\n drawersMinWidth: number;\n drawersMaxWidth: number;\n drawerRef: React.Ref<HTMLElement>;\n resizeHandle: React.ReactElement;\n drawersTriggerCount: number;\n handleDrawersClick: (activeDrawerId: string | null, skipFocusControl?: boolean) => void;\n handleSplitPanelClick: () => void;\n handleNavigationClick: (isOpen: boolean) => void;\n handleSplitPanelPreferencesChange: (detail: AppLayoutProps.SplitPanelPreferences) => void;\n handleSplitPanelResize: (newSize: number) => void;\n handleToolsClick: (value: boolean, skipFocusControl?: boolean) => void;\n hasBackgroundOverlap: boolean;\n hasDefaultToolsWidth: boolean;\n hasDrawerViewportOverlay: boolean;\n hasNotificationsContent: boolean;\n hasOpenDrawer?: boolean;\n hasStickyBackground: boolean;\n isBackgroundOverlapDisabled: boolean;\n isMobile: boolean;\n isNavigationOpen: boolean;\n isSplitPanelForcedPosition: boolean;\n isSplitPanelOpen?: boolean;\n isToolsOpen: boolean;\n layoutElement: React.Ref<HTMLElement>;\n layoutWidth: number;\n loseToolsFocus: () => void;\n loseDrawersFocus: () => void;\n mainElement: React.Ref<HTMLDivElement>;\n mainOffsetLeft: number;\n navigationRefs: FocusControlRefs;\n notificationsElement: React.Ref<HTMLDivElement>;\n notificationsHeight: number;\n offsetBottom: number;\n setHasStickyBackground: (value: boolean) => void;\n setSplitPanelReportedSize: (value: number) => void;\n setSplitPanelReportedHeaderHeight: (value: number) => void;\n headerHeight: number;\n footerHeight: number;\n splitPanelControlId: string;\n splitPanelMaxWidth: number;\n splitPanelMinWidth: number;\n splitPanelPosition: AppLayoutProps.SplitPanelPosition;\n splitPanelReportedSize: number;\n splitPanelReportedHeaderHeight: number;\n splitPanelToggle: SplitPanelSideToggleProps;\n setSplitPanelToggle: (toggle: SplitPanelSideToggleProps) => void;\n splitPanelDisplayed: boolean;\n splitPanelRefs: SplitPanelFocusControlRefs;\n toolsControlId: string;\n toolsRefs: FocusControlRefs;\n __embeddedViewMode?: boolean;\n}\n\n/**\n * The default values are destructured in the context instantiation to\n * prevent downstream Typescript errors. This could likely be replaced\n * by a context interface definition that extends the AppLayout interface.\n */\nconst AppLayoutInternalsContext = createContext<AppLayoutInternals | null>(null);\n\ninterface AppLayoutProviderInternalsProps extends AppLayoutProps {\n children: React.ReactNode;\n}\n\nexport function useAppLayoutInternals() {\n const ctx = useContext(AppLayoutInternalsContext);\n if (!ctx) {\n throw new Error('Invariant violation: this context is only available inside app layout');\n }\n return ctx;\n}\n\nexport const AppLayoutInternalsProvider = React.forwardRef(\n (\n {\n toolsHide,\n toolsOpen: controlledToolsOpen,\n navigationHide,\n navigationOpen: controlledNavigationOpen,\n contentType = 'default',\n headerSelector = '#b #h',\n footerSelector = '#b #h',\n children,\n splitPanel,\n ...props\n }: AppLayoutProviderInternalsProps,\n forwardRef: React.Ref<AppLayoutProps.Ref>\n ) => {\n const isMobile = useMobile();\n\n // Private API for embedded view mode\n const __embeddedViewMode = Boolean((props as any).__embeddedViewMode);\n\n if (isDevelopment) {\n if (controlledToolsOpen && toolsHide) {\n warnOnce(\n 'AppLayout',\n `You have enabled both the \\`toolsOpen\\` prop and the \\`toolsHide\\` prop. This is not supported. Set \\`toolsOpen\\` to \\`false\\` when you set \\`toolsHide\\` to \\`true\\`.`\n );\n }\n }\n\n const [hasStickyBackground, setHasStickyBackground] = useState(false);\n\n /**\n * Set the default values for minimum and maximum content width.\n */\n const geckoMaxCssLength = ((1 << 30) - 1) / 60;\n const halfGeckoMaxCssLength = geckoMaxCssLength / 2;\n // CSS lengths in Gecko are limited to at most (1<<30)-1 app units (Gecko uses 60 as app unit).\n // Limit the maxContentWidth to the half of the upper boundary (≈4230^2) to be on the safe side.\n const maxContentWidth =\n props.maxContentWidth && props.maxContentWidth > halfGeckoMaxCssLength\n ? halfGeckoMaxCssLength\n : props.maxContentWidth ?? 0;\n const minContentWidth = props.minContentWidth ?? 280;\n\n /**\n * Determine the default state of the Navigation and Tools drawers.\n * Mobile viewports should be closed by default under all circumstances.\n * If the navigationOpen prop has been set then that should take precedence\n * over the contentType prop. Desktop viewports that do not have the\n * navigationOpen or contentType props set will use the default contentType.\n */\n const contentTypeDefaults = applyDefaults(contentType, { maxContentWidth, minContentWidth }, true);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Navigation drawer. The logic\n * for determining the default state is colocated with the Navigation component.\n *\n * The callback that will be passed to the Navigation and MobileToolbar\n * components to handle the click events that will change the state\n * of the Navigation drawer. It will set the Navigation state with the\n * useControllable hook and also fire the onNavigationChange function to\n * emit the state change.\n */\n const [isNavigationOpen = false, setIsNavigationOpen] = useControllable(\n controlledNavigationOpen,\n props.onNavigationChange,\n isMobile ? false : contentTypeDefaults.navigationOpen,\n { componentName: 'AppLayout', controlledProp: 'navigationOpen', changeHandler: 'onNavigationChange' }\n );\n\n const { refs: navigationRefs, setFocus: focusNavButtons } = useFocusControl(isNavigationOpen);\n\n const handleNavigationClick = useStableCallback(function handleNavigationChange(isOpen: boolean) {\n setIsNavigationOpen(isOpen);\n focusNavButtons();\n fireNonCancelableEvent(props.onNavigationChange, { open: isOpen });\n });\n\n useEffect(() => {\n // Close navigation drawer on mobile so that the main content is visible\n if (isMobile) {\n handleNavigationClick(false);\n }\n }, [isMobile, handleNavigationClick]);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Tools drawer. The logic\n * for determining the default state is colocated with the Tools component.\n *\n * The callback that will be passed to the Navigation and MobileToolbar\n * components to handle the click events that will change the state\n * of the Tools drawer. It will set the Tools state with the\n * useControllable hook and also fire the onToolsChange function to\n * emit the state change.\n */\n const toolsWidth = props.toolsWidth ?? 290;\n const hasDefaultToolsWidth = props.toolsWidth === undefined;\n\n const [isToolsOpen = false, setIsToolsOpen] = useControllable(\n controlledToolsOpen,\n props.onToolsChange,\n isMobile ? false : contentTypeDefaults.toolsOpen,\n { componentName: 'AppLayout', controlledProp: 'toolsOpen', changeHandler: 'onToolsChange' }\n );\n\n const {\n refs: toolsRefs,\n setFocus: focusToolsButtons,\n loseFocus: loseToolsFocus,\n } = useFocusControl(isToolsOpen, true);\n\n const handleToolsClick = useCallback(\n function handleToolsChange(isOpen: boolean, skipFocusControl?: boolean) {\n setIsToolsOpen(isOpen);\n !skipFocusControl && focusToolsButtons();\n fireNonCancelableEvent(props.onToolsChange, { open: isOpen });\n },\n [props.onToolsChange, setIsToolsOpen, focusToolsButtons]\n );\n\n /**\n * Query the DOM for the header and footer elements based on the selectors provided\n * by the properties and pass the heights to the custom property definitions.\n */\n const headerHeight = useObservedElement(headerSelector);\n const footerHeight = useObservedElement(footerSelector);\n\n /**\n * Set the default values for the minimum and maximum Split Panel width when it is\n * in the side position. The useLayoutEffect will compute the available space in the\n * DOM for the Split Panel given the current state. The minimum and maximum\n * widths will potentially trigger a side effect that will put the Split Panel into\n * a forced position on the bottom.\n */\n const splitPanelMinWidth = 280;\n const [splitPanelMaxWidth, setSplitPanelMaxWidth] = useState(splitPanelMinWidth);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Split Panel. By default\n * the Split Panel should always be closed on page load.\n *\n * The callback that will be passed to the SplitPanel component\n * to handle the click events that will change the state of the SplitPanel\n * to open or closed given the current state. It will set the isSplitPanelOpen\n * controlled state and fire the onSplitPanelToggle event.\n */\n const [isSplitPanelOpen, setIsSplitPanelOpen] = useControllable(\n props.splitPanelOpen,\n props.onSplitPanelToggle,\n false,\n { componentName: 'AppLayout', controlledProp: 'splitPanelOpen', changeHandler: 'onSplitPanelToggle' }\n );\n\n /**\n * The useControllable hook will manage the controlled or uncontrolled\n * state of the splitPanelPreferences. By default the splitPanelPreferences\n * is undefined. When set the object shape should have a single key to indicate\n * either bottom or side position.\n *\n * The callback that will handle changes to the splitPanelPreferences\n * object that will determine if the SplitPanel is rendered either on the\n * bottom of the viewport or within the Tools container.\n */\n const [splitPanelPreferences, setSplitPanelPreferences] = useControllable(\n props.splitPanelPreferences,\n props.onSplitPanelPreferencesChange,\n undefined,\n {\n componentName: 'AppLayout',\n controlledProp: 'splitPanelPreferences',\n changeHandler: 'onSplitPanelPreferencesChange',\n }\n );\n\n const { refs: splitPanelRefs, setLastInteraction: setSplitPanelLastInteraction } = useSplitPanelFocusControl([\n splitPanelPreferences,\n isSplitPanelOpen,\n ]);\n\n const handleSplitPanelClick = useCallback(\n function handleSplitPanelChange() {\n setIsSplitPanelOpen(!isSplitPanelOpen);\n setSplitPanelLastInteraction({ type: isSplitPanelOpen ? 'close' : 'open' });\n fireNonCancelableEvent(props.onSplitPanelToggle, { open: !isSplitPanelOpen });\n },\n [props.onSplitPanelToggle, isSplitPanelOpen, setIsSplitPanelOpen, setSplitPanelLastInteraction]\n );\n\n /**\n * The Split Panel will be in forced (bottom) position if the defined minimum width is\n * greater than the maximum width. In other words, the maximum width is the currently\n * available horizontal space based on all other components that are rendered. If the\n * minimum width exceeds this value then there is not enough horizontal space and we must\n * force it to the bottom position.\n */\n const [isSplitPanelForcedPosition, setSplitPanelForcedPosition] = useState(false);\n const splitPanelPosition = getSplitPanelPosition(isSplitPanelForcedPosition, splitPanelPreferences);\n\n useLayoutEffect(\n function handleSplitPanelForcePosition() {\n setSplitPanelForcedPosition(splitPanelMinWidth > splitPanelMaxWidth);\n },\n [splitPanelMaxWidth, splitPanelMinWidth]\n );\n\n /**\n * The useControllable hook will set the default size of the SplitPanel based\n * on the default position set in the splitPanelPreferences. The logic for the\n * default size is contained in the SplitPanel component. The splitPanelControlledSize\n * will be bound to the size property in the SplitPanel context for rendering.\n *\n * The callback that will be passed to the SplitPanel component\n * to handle the resize events that will change the size of the SplitPanel.\n * It will set the splitPanelControlledSize controlled state and fire the\n * onSplitPanelResize event.\n */\n const [splitPanelReportedSize, setSplitPanelReportedSize] = useState(0);\n const [splitPanelReportedHeaderHeight, setSplitPanelReportedHeaderHeight] = useState(0);\n const [splitPanelToggle, setSplitPanelToggle] = useState<SplitPanelSideToggleProps>({\n displayed: false,\n ariaLabel: undefined,\n });\n const splitPanelDisplayed = !!(splitPanelToggle.displayed || isSplitPanelOpen) && !!splitPanel;\n const splitPanelControlId = useUniqueId('split-panel-');\n const toolsControlId = useUniqueId('tools-');\n\n const [splitPanelSize, setSplitPanelSize] = useControllable(\n props.splitPanelSize,\n props.onSplitPanelResize,\n getSplitPanelDefaultSize(splitPanelPosition),\n { componentName: 'AppLayout', controlledProp: 'splitPanelSize', changeHandler: 'onSplitPanelResize' }\n );\n\n const handleSplitPanelResize = useCallback(\n (size: number) => {\n setSplitPanelSize(size);\n fireNonCancelableEvent(props.onSplitPanelResize, { size });\n },\n [props.onSplitPanelResize, setSplitPanelSize]\n );\n\n const handleSplitPanelPreferencesChange = useCallback(\n function handleSplitPanelChange(detail: AppLayoutProps.SplitPanelPreferences) {\n setSplitPanelPreferences(detail);\n setSplitPanelLastInteraction({ type: 'position' });\n fireNonCancelableEvent(props.onSplitPanelPreferencesChange, detail);\n },\n [props.onSplitPanelPreferencesChange, setSplitPanelPreferences, setSplitPanelLastInteraction]\n );\n\n const {\n drawers,\n activeDrawer,\n activeDrawerId,\n minDrawerSize: drawersMinWidth,\n onActiveDrawerChange,\n onActiveDrawerResize,\n activeDrawerSize,\n ...drawersProps\n } = useDrawers(props, props.ariaLabels, {\n ariaLabels: props.ariaLabels,\n toolsHide,\n toolsOpen: isToolsOpen,\n tools: props.tools,\n toolsWidth,\n onToolsToggle: handleToolsClick,\n });\n\n const [drawersMaxWidth, setDrawersMaxWidth] = useState(toolsWidth);\n const hasDrawers = !!drawers && drawers.length > 0;\n\n const {\n refs: drawersRefs,\n setFocus: focusDrawersButtons,\n loseFocus: loseDrawersFocus,\n } = useFocusControl(!!activeDrawerId, true, activeDrawerId);\n\n const drawerRef = useRef<HTMLDivElement>(null);\n const { resizeHandle, drawerSize } = useResize(drawerRef, {\n onActiveDrawerResize,\n activeDrawerSize,\n activeDrawer,\n drawersRefs,\n isToolsOpen,\n drawersMaxWidth,\n });\n\n const handleDrawersClick = (id: string | null, skipFocusControl?: boolean) => {\n const newActiveDrawerId = id !== activeDrawerId ? id : null;\n\n onActiveDrawerChange(newActiveDrawerId);\n\n !skipFocusControl && focusDrawersButtons();\n };\n\n let drawersTriggerCount = drawers ? drawers.length : !toolsHide ? 1 : 0;\n if (splitPanelDisplayed && splitPanelPosition === 'side') {\n drawersTriggerCount++;\n }\n const hasOpenDrawer =\n !!activeDrawerId ||\n (!toolsHide && isToolsOpen) ||\n (splitPanelDisplayed && splitPanelPosition === 'side' && isSplitPanelOpen);\n const hasDrawerViewportOverlay =\n isMobile && (!!activeDrawerId || (!navigationHide && isNavigationOpen) || (!toolsHide && isToolsOpen));\n\n /**\n * The Layout element is not necessarily synonymous with the client\n * viewport width. There can be content in the horizontal viewport\n * that exists on either side of the AppLayout. This resize observer\n * will set the custom property of the Layout element width that\n * is used for various horizontal constraints such as the maximum\n * allowed width of the Tools container.\n *\n * The offsetLeft of the Main will return the distance that the\n * Main element has from the left edge of the Layout component.\n * The offsetLeft value can vary based on the presence and state\n * of the Navigation as well as content gaps in the grid definition.\n * This value is used to determine the max width constraint calculation\n * for the Tools container.\n */\n const [layoutContainerQuery, layoutElement] = useContainerQuery(rect => rect.contentBoxWidth);\n const layoutWidth = layoutContainerQuery ?? 0;\n\n const mainElement = useRef<HTMLDivElement>(null);\n const [mainOffsetLeft, setMainOffsetLeft] = useState(0);\n\n const { hasBackgroundOverlap, updateBackgroundOverlapHeight } = useBackgroundOverlap({\n contentHeader: props.contentHeader,\n disableContentHeaderOverlap: props.disableContentHeaderOverlap,\n layoutElement,\n });\n\n useLayoutEffect(\n function handleMainOffsetLeft() {\n setMainOffsetLeft(mainElement?.current?.offsetLeft ?? 0);\n },\n [layoutWidth, isNavigationOpen, isToolsOpen, splitPanelReportedSize]\n );\n\n /**\n * On mobile viewports the navigation and tools drawers are adjusted to a fixed position\n * that consumes 100% of the viewport height and width. The body content could potentially\n * be scrollable underneath the drawer. In order to prevent this a CSS class needs to be\n * added to the document body that sets overflow to hidden.\n */\n useEffect(\n function handleBodyScroll() {\n if (isMobile && (isNavigationOpen || isToolsOpen || !!activeDrawer)) {\n document.body.classList.add(styles['block-body-scroll']);\n } else {\n document.body.classList.remove(styles['block-body-scroll']);\n }\n\n // Ensure the CSS class is removed from the body on side effect cleanup\n return function cleanup() {\n document.body.classList.remove(styles['block-body-scroll']);\n };\n },\n [isMobile, isNavigationOpen, isToolsOpen, activeDrawer]\n );\n\n /**\n * Because the notifications slot does not give us any direction insight into\n * what the state of the child content is we need to have a mechanism for\n * tracking the height of the notifications and whether or not it has content.\n * The height of the notifications is an integer that will be used as a custom\n * property on the Layout component to determine what the sticky offset should\n * be if there are sticky notifications. This could be any number including\n * zero based on how the child content renders. The hasNotificationsContent boolean\n * is simply centralizing the logic of the notifications height being > 0 such\n * that it is not repeated in various components (such as MobileToolbar) that need to\n * know if the notifications slot is empty.\n */\n const [notificationsContainerQuery, notificationsElement] = useContainerQuery(rect => rect.contentBoxHeight);\n\n const notificationsHeight = notificationsContainerQuery ?? 0;\n const hasNotificationsContent = notificationsHeight > 0;\n /**\n * Determine the offsetBottom value based on the presence of a footer element and\n * the SplitPanel component. Ignore the SplitPanel if it is not in the bottom\n * position. Use the size property if it is open and the header height if it is closed.\n */\n let offsetBottom = footerHeight;\n\n if (splitPanelDisplayed && splitPanelPosition === 'bottom') {\n if (isSplitPanelOpen) {\n offsetBottom += splitPanelReportedSize;\n } else {\n offsetBottom += splitPanelReportedHeaderHeight;\n }\n }\n\n /**\n * Warning! This is a hack! In order to accurately calculate if there is adequate\n * horizontal space for the Split Panel to be in the side position we need two values\n * that are not available in JavaScript.\n *\n * The first is the the content gap on the right which is stored in a design token\n * and applied in the Layout CSS:\n *\n * $contentGapRight: #{awsui.$space-layout-content-horizontal};\n *\n * The second is the width of the element that has the circular buttons for the\n * Tools and Split Panel. This could be suppressed given the state of the Tools\n * drawer returning a zero value. It would, however, be rendered if the Split Panel\n * were to move into the side position. This is calculated in the Tools CSS and\n * the Trigger button CSS with design tokens:\n *\n * padding: awsui.$space-scaled-s awsui.$space-layout-toggle-padding;\n * width: awsui.$space-layout-toggle-diameter;\n *\n * These values will be defined below as static integers that are rough approximations\n * of their computed width when rendered in the DOM, but doubled to ensure adequate\n * spacing for the Split Panel to be in side position.\n */\n useLayoutEffect(\n function handleSplitPanelMaxWidth() {\n const contentGapRight = 50; // Approximately 24px when rendered but doubled for safety\n const toolsFormOffsetWidth = 120; // Approximately 60px when rendered but doubled for safety\n const getPanelOffsetWidth = () => {\n if (drawers) {\n return activeDrawerId ? drawerSize : 0;\n }\n return isToolsOpen ? toolsWidth : 0;\n };\n\n setSplitPanelMaxWidth(\n layoutWidth -\n mainOffsetLeft -\n minContentWidth -\n contentGapRight -\n toolsFormOffsetWidth -\n getPanelOffsetWidth()\n );\n\n setDrawersMaxWidth(layoutWidth - mainOffsetLeft - minContentWidth - contentGapRight - toolsFormOffsetWidth);\n },\n [\n activeDrawerId,\n drawerSize,\n drawers,\n isNavigationOpen,\n isToolsOpen,\n layoutWidth,\n mainOffsetLeft,\n minContentWidth,\n toolsWidth,\n ]\n );\n\n /**\n * The useImperativeHandle hook in conjunction with the forwardRef function\n * in the AppLayout component definition expose the following callable\n * functions to component consumers when they put a ref as a property on\n * their component implementation.\n */\n useImperativeHandle(\n forwardRef,\n function createImperativeHandle() {\n return {\n closeNavigationIfNecessary: function () {\n isMobile && handleNavigationClick(false);\n },\n openTools: function () {\n handleToolsClick(true);\n },\n focusToolsClose: () => {\n if (hasDrawers) {\n focusDrawersButtons(true);\n } else {\n focusToolsButtons(true);\n }\n },\n focusActiveDrawer: () => focusDrawersButtons(true),\n focusSplitPanel: () => splitPanelRefs.slider.current?.focus(),\n };\n },\n [\n isMobile,\n handleNavigationClick,\n handleToolsClick,\n focusToolsButtons,\n focusDrawersButtons,\n splitPanelRefs.slider,\n hasDrawers,\n ]\n );\n\n return (\n <AppLayoutInternalsContext.Provider\n value={{\n ...props,\n activeDrawerId,\n contentType,\n drawers,\n drawersAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawers,\n drawersOverflowAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawersOverflow,\n drawersOverflowWithBadgeAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawersOverflowWithBadge,\n drawersRefs,\n drawersMinWidth,\n drawersMaxWidth,\n drawerSize,\n drawerRef,\n resizeHandle,\n drawersTriggerCount,\n headerHeight,\n footerHeight,\n hasDefaultToolsWidth,\n hasDrawerViewportOverlay,\n handleDrawersClick,\n handleNavigationClick,\n handleSplitPanelClick,\n handleSplitPanelPreferencesChange,\n handleSplitPanelResize,\n handleToolsClick,\n hasBackgroundOverlap,\n hasNotificationsContent,\n hasOpenDrawer,\n hasStickyBackground,\n isBackgroundOverlapDisabled: props.disableContentHeaderOverlap || !hasBackgroundOverlap,\n isMobile,\n isNavigationOpen: isNavigationOpen ?? false,\n isSplitPanelForcedPosition,\n isSplitPanelOpen,\n isToolsOpen,\n layoutElement,\n layoutWidth,\n loseToolsFocus,\n loseDrawersFocus,\n mainElement,\n mainOffsetLeft,\n maxContentWidth,\n minContentWidth,\n navigationHide,\n navigationRefs,\n notificationsElement,\n notificationsHeight,\n offsetBottom,\n setHasStickyBackground,\n setSplitPanelReportedSize,\n setSplitPanelReportedHeaderHeight,\n splitPanel,\n splitPanelControlId,\n splitPanelDisplayed,\n splitPanelMaxWidth,\n splitPanelMinWidth,\n splitPanelPosition,\n splitPanelPreferences,\n splitPanelReportedSize,\n splitPanelReportedHeaderHeight,\n splitPanelSize,\n splitPanelToggle,\n setSplitPanelToggle,\n splitPanelRefs,\n toolsControlId,\n toolsHide,\n toolsOpen: isToolsOpen,\n toolsWidth,\n toolsRefs,\n __embeddedViewMode,\n }}\n >\n <AppLayoutContext.Provider\n value={{\n stickyOffsetBottom: offsetBottom,\n stickyOffsetTop: 0, // not used in this design. Sticky headers read a CSS-var instead\n setHasStickyBackground,\n }}\n >\n <DynamicOverlapContext.Provider value={updateBackgroundOverlapHeight}>\n {children}\n </DynamicOverlapContext.Provider>\n </AppLayoutContext.Provider>\n </AppLayoutInternalsContext.Provider>\n );\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/context.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,UAAU,GACX,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAEvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAoB,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAA8B,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAE/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAA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f,cAAc;YACd,cAAc;YACd,oBAAoB;YACpB,mBAAmB;YACnB,YAAY;YACZ,sBAAsB;YACtB,yBAAyB;YACzB,iCAAiC;YACjC,UAAU;YACV,mBAAmB;YACnB,mBAAmB;YACnB,kBAAkB;YAClB,kBAAkB;YAClB,kBAAkB;YAClB,qBAAqB;YACrB,sBAAsB;YACtB,8BAA8B;YAC9B,cAAc;YACd,gBAAgB;YAChB,mBAAmB;YACnB,cAAc;YACd,cAAc;YACd,SAAS,EACT,SAAS,EAAE,WAAW,EACtB,UAAU;YACV,SAAS;YACT,kBAAkB;QAGpB,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,EAAE;gBACL,kBAAkB,EAAE,YAAY;gBAChC,eAAe,EAAE,CAAC;gBAClB,sBAAsB;aACvB;YAED,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B,IACjE,QAAQ,CACsB,CACP,CACO,CACtC,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, {\n createContext,\n useCallback,\n useEffect,\n useLayoutEffect,\n useImperativeHandle,\n useRef,\n useState,\n useContext,\n} from 'react';\nimport { applyDefaults } from '../defaults';\nimport { AppLayoutContext } from '../../internal/context/app-layout-context';\nimport { DynamicOverlapContext } from '../../internal/context/dynamic-overlap-context';\nimport { AppLayoutProps, AppLayoutPropsWithDefaults } from '../interfaces';\nimport { fireNonCancelableEvent } from '../../internal/events';\nimport { FocusControlRefs, useFocusControl } from '../utils/use-focus-control';\nimport { getSplitPanelDefaultSize } from '../../split-panel/utils/size-utils';\nimport { isDevelopment } from '../../internal/is-development';\nimport { getSplitPanelPosition } from './split-panel';\nimport { useControllable } from '../../internal/hooks/use-controllable';\nimport { SplitPanelFocusControlRefs, useSplitPanelFocusControl } from '../utils/use-split-panel-focus-control';\nimport { SplitPanelSideToggleProps } from '../../internal/context/split-panel-context';\nimport { useObservedElement } from '../utils/use-observed-element';\nimport { useMobile } from '../../internal/hooks/use-mobile';\nimport { useStableCallback, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport useResize from '../utils/use-resize';\nimport styles from './styles.css.js';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport useBackgroundOverlap from './use-background-overlap';\nimport { useDrawers } from '../utils/use-drawers';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\n\ninterface AppLayoutInternals extends AppLayoutProps {\n activeDrawerId: string | null;\n drawers: Array<AppLayoutProps.Drawer> | undefined;\n drawersAriaLabel: string | undefined;\n drawersOverflowAriaLabel: string | undefined;\n drawersOverflowWithBadgeAriaLabel: string | undefined;\n drawersRefs: FocusControlRefs;\n drawerSize: number;\n drawersMinWidth: number;\n drawersMaxWidth: number;\n drawerRef: React.Ref<HTMLElement>;\n resizeHandle: React.ReactElement;\n drawersTriggerCount: number;\n handleDrawersClick: (activeDrawerId: string | null, skipFocusControl?: boolean) => void;\n handleSplitPanelClick: () => void;\n handleNavigationClick: (isOpen: boolean) => void;\n handleSplitPanelPreferencesChange: (detail: AppLayoutProps.SplitPanelPreferences) => void;\n handleSplitPanelResize: (newSize: number) => void;\n handleToolsClick: (value: boolean, skipFocusControl?: boolean) => void;\n hasDefaultToolsWidth: boolean;\n hasBackgroundOverlap: boolean;\n hasDrawerViewportOverlay: boolean;\n hasNotificationsContent: boolean;\n hasOpenDrawer?: boolean;\n hasStickyBackground: boolean;\n isBackgroundOverlapDisabled: boolean;\n isMobile: boolean;\n isNavigationOpen: boolean;\n isSplitPanelForcedPosition: boolean;\n isSplitPanelOpen?: boolean;\n isToolsOpen: boolean;\n layoutElement: React.Ref<HTMLElement>;\n layoutWidth: number;\n loseToolsFocus: () => void;\n loseDrawersFocus: () => void;\n mainElement: React.Ref<HTMLDivElement>;\n mainOffsetLeft: number;\n navigationRefs: FocusControlRefs;\n notificationsElement: React.Ref<HTMLDivElement>;\n notificationsHeight: number;\n offsetBottom: number;\n setHasStickyBackground: (value: boolean) => void;\n setSplitPanelReportedSize: (value: number) => void;\n setSplitPanelReportedHeaderHeight: (value: number) => void;\n headerHeight: number;\n footerHeight: number;\n splitPanelControlId: string;\n splitPanelMaxWidth: number;\n splitPanelMinWidth: number;\n splitPanelPosition: AppLayoutProps.SplitPanelPosition;\n splitPanelReportedSize: number;\n splitPanelReportedHeaderHeight: number;\n splitPanelToggle: SplitPanelSideToggleProps;\n setSplitPanelToggle: (toggle: SplitPanelSideToggleProps) => void;\n splitPanelDisplayed: boolean;\n splitPanelRefs: SplitPanelFocusControlRefs;\n toolsControlId: string;\n toolsRefs: FocusControlRefs;\n __embeddedViewMode?: boolean;\n}\n\n/**\n * The default values are destructured in the context instantiation to\n * prevent downstream Typescript errors. This could likely be replaced\n * by a context interface definition that extends the AppLayout interface.\n */\nconst AppLayoutInternalsContext = createContext<AppLayoutInternals | null>(null);\n\ninterface AppLayoutProviderInternalsProps extends AppLayoutPropsWithDefaults {\n children: React.ReactNode;\n}\n\nexport function useAppLayoutInternals() {\n const ctx = useContext(AppLayoutInternalsContext);\n if (!ctx) {\n throw new Error('Invariant violation: this context is only available inside app layout');\n }\n return ctx;\n}\n\nexport const AppLayoutInternalsProvider = React.forwardRef(\n (\n {\n toolsHide,\n toolsOpen: controlledToolsOpen,\n navigationHide,\n navigationOpen: controlledNavigationOpen,\n contentType,\n headerSelector,\n footerSelector,\n children,\n splitPanel,\n ...props\n }: AppLayoutProviderInternalsProps,\n forwardRef: React.Ref<AppLayoutProps.Ref>\n ) => {\n const isMobile = useMobile();\n\n // Private API for embedded view mode\n const __embeddedViewMode = Boolean((props as any).__embeddedViewMode);\n\n if (isDevelopment) {\n if (controlledToolsOpen && toolsHide) {\n warnOnce(\n 'AppLayout',\n `You have enabled both the \\`toolsOpen\\` prop and the \\`toolsHide\\` prop. This is not supported. Set \\`toolsOpen\\` to \\`false\\` when you set \\`toolsHide\\` to \\`true\\`.`\n );\n }\n }\n\n const [hasStickyBackground, setHasStickyBackground] = useState(false);\n\n /**\n * Set the default values for minimum and maximum content width.\n */\n const geckoMaxCssLength = ((1 << 30) - 1) / 60;\n const halfGeckoMaxCssLength = geckoMaxCssLength / 2;\n // CSS lengths in Gecko are limited to at most (1<<30)-1 app units (Gecko uses 60 as app unit).\n // Limit the maxContentWidth to the half of the upper boundary (≈4230^2) to be on the safe side.\n const maxContentWidth =\n props.maxContentWidth && props.maxContentWidth > halfGeckoMaxCssLength\n ? halfGeckoMaxCssLength\n : props.maxContentWidth ?? 0;\n const minContentWidth = props.minContentWidth ?? 280;\n\n /**\n * Determine the default state of the Navigation and Tools drawers.\n * Mobile viewports should be closed by default under all circumstances.\n * If the navigationOpen prop has been set then that should take precedence\n * over the contentType prop. Desktop viewports that do not have the\n * navigationOpen or contentType props set will use the default contentType.\n */\n const contentTypeDefaults = applyDefaults(contentType, { maxContentWidth, minContentWidth }, true);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Navigation drawer. The logic\n * for determining the default state is colocated with the Navigation component.\n *\n * The callback that will be passed to the Navigation and MobileToolbar\n * components to handle the click events that will change the state\n * of the Navigation drawer. It will set the Navigation state with the\n * useControllable hook and also fire the onNavigationChange function to\n * emit the state change.\n */\n const [isNavigationOpen = false, setIsNavigationOpen] = useControllable(\n controlledNavigationOpen,\n props.onNavigationChange,\n isMobile ? false : contentTypeDefaults.navigationOpen,\n { componentName: 'AppLayout', controlledProp: 'navigationOpen', changeHandler: 'onNavigationChange' }\n );\n\n const { refs: navigationRefs, setFocus: focusNavButtons } = useFocusControl(isNavigationOpen);\n\n const handleNavigationClick = useStableCallback(function handleNavigationChange(isOpen: boolean) {\n setIsNavigationOpen(isOpen);\n focusNavButtons();\n fireNonCancelableEvent(props.onNavigationChange, { open: isOpen });\n });\n\n useEffect(() => {\n // Close navigation drawer on mobile so that the main content is visible\n if (isMobile) {\n handleNavigationClick(false);\n }\n }, [isMobile, handleNavigationClick]);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Tools drawer. The logic\n * for determining the default state is colocated with the Tools component.\n *\n * The callback that will be passed to the Navigation and MobileToolbar\n * components to handle the click events that will change the state\n * of the Tools drawer. It will set the Tools state with the\n * useControllable hook and also fire the onToolsChange function to\n * emit the state change.\n */\n const toolsWidth = props.toolsWidth ?? 290;\n const hasDefaultToolsWidth = props.toolsWidth === undefined;\n\n const [isToolsOpen = false, setIsToolsOpen] = useControllable(\n controlledToolsOpen,\n props.onToolsChange,\n isMobile ? false : contentTypeDefaults.toolsOpen,\n { componentName: 'AppLayout', controlledProp: 'toolsOpen', changeHandler: 'onToolsChange' }\n );\n\n const {\n refs: toolsRefs,\n setFocus: focusToolsButtons,\n loseFocus: loseToolsFocus,\n } = useFocusControl(isToolsOpen, true);\n\n const handleToolsClick = useCallback(\n function handleToolsChange(isOpen: boolean, skipFocusControl?: boolean) {\n setIsToolsOpen(isOpen);\n !skipFocusControl && focusToolsButtons();\n fireNonCancelableEvent(props.onToolsChange, { open: isOpen });\n },\n [props.onToolsChange, setIsToolsOpen, focusToolsButtons]\n );\n\n /**\n * Query the DOM for the header and footer elements based on the selectors provided\n * by the properties and pass the heights to the custom property definitions.\n */\n const headerHeight = useObservedElement(headerSelector);\n const footerHeight = useObservedElement(footerSelector);\n\n /**\n * Set the default values for the minimum and maximum Split Panel width when it is\n * in the side position. The useLayoutEffect will compute the available space in the\n * DOM for the Split Panel given the current state. The minimum and maximum\n * widths will potentially trigger a side effect that will put the Split Panel into\n * a forced position on the bottom.\n */\n const splitPanelMinWidth = 280;\n const [splitPanelMaxWidth, setSplitPanelMaxWidth] = useState(splitPanelMinWidth);\n\n /**\n * The useControllable hook will set the default value and manage either\n * the controlled or uncontrolled state of the Split Panel. By default\n * the Split Panel should always be closed on page load.\n *\n * The callback that will be passed to the SplitPanel component\n * to handle the click events that will change the state of the SplitPanel\n * to open or closed given the current state. It will set the isSplitPanelOpen\n * controlled state and fire the onSplitPanelToggle event.\n */\n const [isSplitPanelOpen, setIsSplitPanelOpen] = useControllable(\n props.splitPanelOpen,\n props.onSplitPanelToggle,\n false,\n { componentName: 'AppLayout', controlledProp: 'splitPanelOpen', changeHandler: 'onSplitPanelToggle' }\n );\n\n /**\n * The useControllable hook will manage the controlled or uncontrolled\n * state of the splitPanelPreferences. By default the splitPanelPreferences\n * is undefined. When set the object shape should have a single key to indicate\n * either bottom or side position.\n *\n * The callback that will handle changes to the splitPanelPreferences\n * object that will determine if the SplitPanel is rendered either on the\n * bottom of the viewport or within the Tools container.\n */\n const [splitPanelPreferences, setSplitPanelPreferences] = useControllable(\n props.splitPanelPreferences,\n props.onSplitPanelPreferencesChange,\n undefined,\n {\n componentName: 'AppLayout',\n controlledProp: 'splitPanelPreferences',\n changeHandler: 'onSplitPanelPreferencesChange',\n }\n );\n\n const { refs: splitPanelRefs, setLastInteraction: setSplitPanelLastInteraction } = useSplitPanelFocusControl([\n splitPanelPreferences,\n isSplitPanelOpen,\n ]);\n\n const handleSplitPanelClick = useCallback(\n function handleSplitPanelChange() {\n setIsSplitPanelOpen(!isSplitPanelOpen);\n setSplitPanelLastInteraction({ type: isSplitPanelOpen ? 'close' : 'open' });\n fireNonCancelableEvent(props.onSplitPanelToggle, { open: !isSplitPanelOpen });\n },\n [props.onSplitPanelToggle, isSplitPanelOpen, setIsSplitPanelOpen, setSplitPanelLastInteraction]\n );\n\n /**\n * The Split Panel will be in forced (bottom) position if the defined minimum width is\n * greater than the maximum width. In other words, the maximum width is the currently\n * available horizontal space based on all other components that are rendered. If the\n * minimum width exceeds this value then there is not enough horizontal space and we must\n * force it to the bottom position.\n */\n const [isSplitPanelForcedPosition, setSplitPanelForcedPosition] = useState(false);\n const splitPanelPosition = getSplitPanelPosition(isSplitPanelForcedPosition, splitPanelPreferences);\n\n useLayoutEffect(\n function handleSplitPanelForcePosition() {\n setSplitPanelForcedPosition(splitPanelMinWidth > splitPanelMaxWidth);\n },\n [splitPanelMaxWidth, splitPanelMinWidth]\n );\n\n /**\n * The useControllable hook will set the default size of the SplitPanel based\n * on the default position set in the splitPanelPreferences. The logic for the\n * default size is contained in the SplitPanel component. The splitPanelControlledSize\n * will be bound to the size property in the SplitPanel context for rendering.\n *\n * The callback that will be passed to the SplitPanel component\n * to handle the resize events that will change the size of the SplitPanel.\n * It will set the splitPanelControlledSize controlled state and fire the\n * onSplitPanelResize event.\n */\n const [splitPanelReportedSize, setSplitPanelReportedSize] = useState(0);\n const [splitPanelReportedHeaderHeight, setSplitPanelReportedHeaderHeight] = useState(0);\n const [splitPanelToggle, setSplitPanelToggle] = useState<SplitPanelSideToggleProps>({\n displayed: false,\n ariaLabel: undefined,\n });\n const splitPanelDisplayed = !!(splitPanelToggle.displayed || isSplitPanelOpen) && !!splitPanel;\n const splitPanelControlId = useUniqueId('split-panel-');\n const toolsControlId = useUniqueId('tools-');\n\n const [splitPanelSize, setSplitPanelSize] = useControllable(\n props.splitPanelSize,\n props.onSplitPanelResize,\n getSplitPanelDefaultSize(splitPanelPosition),\n { componentName: 'AppLayout', controlledProp: 'splitPanelSize', changeHandler: 'onSplitPanelResize' }\n );\n\n const handleSplitPanelResize = useCallback(\n (size: number) => {\n setSplitPanelSize(size);\n fireNonCancelableEvent(props.onSplitPanelResize, { size });\n },\n [props.onSplitPanelResize, setSplitPanelSize]\n );\n\n const handleSplitPanelPreferencesChange = useCallback(\n function handleSplitPanelChange(detail: AppLayoutProps.SplitPanelPreferences) {\n setSplitPanelPreferences(detail);\n setSplitPanelLastInteraction({ type: 'position' });\n fireNonCancelableEvent(props.onSplitPanelPreferencesChange, detail);\n },\n [props.onSplitPanelPreferencesChange, setSplitPanelPreferences, setSplitPanelLastInteraction]\n );\n\n const {\n drawers,\n activeDrawer,\n activeDrawerId,\n minDrawerSize: drawersMinWidth,\n onActiveDrawerChange,\n onActiveDrawerResize,\n activeDrawerSize,\n ...drawersProps\n } = useDrawers(props, props.ariaLabels, {\n ariaLabels: props.ariaLabels,\n toolsHide,\n toolsOpen: isToolsOpen,\n tools: props.tools,\n toolsWidth,\n onToolsToggle: handleToolsClick,\n });\n\n const [drawersMaxWidth, setDrawersMaxWidth] = useState(toolsWidth);\n const hasDrawers = !!drawers && drawers.length > 0;\n\n const {\n refs: drawersRefs,\n setFocus: focusDrawersButtons,\n loseFocus: loseDrawersFocus,\n } = useFocusControl(!!activeDrawerId, true, activeDrawerId);\n\n const drawerRef = useRef<HTMLDivElement>(null);\n const { resizeHandle, drawerSize } = useResize(drawerRef, {\n onActiveDrawerResize,\n activeDrawerSize,\n activeDrawer,\n drawersRefs,\n isToolsOpen,\n drawersMaxWidth,\n });\n\n const handleDrawersClick = (id: string | null, skipFocusControl?: boolean) => {\n const newActiveDrawerId = id !== activeDrawerId ? id : null;\n\n onActiveDrawerChange(newActiveDrawerId);\n\n !skipFocusControl && focusDrawersButtons();\n };\n\n let drawersTriggerCount = drawers ? drawers.length : !toolsHide ? 1 : 0;\n if (splitPanelDisplayed && splitPanelPosition === 'side') {\n drawersTriggerCount++;\n }\n const hasOpenDrawer =\n !!activeDrawerId ||\n (!toolsHide && isToolsOpen) ||\n (splitPanelDisplayed && splitPanelPosition === 'side' && isSplitPanelOpen);\n const hasDrawerViewportOverlay =\n isMobile && (!!activeDrawerId || (!navigationHide && isNavigationOpen) || (!toolsHide && isToolsOpen));\n\n /**\n * The Layout element is not necessarily synonymous with the client\n * viewport width. There can be content in the horizontal viewport\n * that exists on either side of the AppLayout. This resize observer\n * will set the custom property of the Layout element width that\n * is used for various horizontal constraints such as the maximum\n * allowed width of the Tools container.\n *\n * The offsetLeft of the Main will return the distance that the\n * Main element has from the left edge of the Layout component.\n * The offsetLeft value can vary based on the presence and state\n * of the Navigation as well as content gaps in the grid definition.\n * This value is used to determine the max width constraint calculation\n * for the Tools container.\n */\n const [layoutContainerQuery, layoutElement] = useContainerQuery(rect => rect.contentBoxWidth);\n const layoutWidth = layoutContainerQuery ?? 0;\n\n const mainElement = useRef<HTMLDivElement>(null);\n const [mainOffsetLeft, setMainOffsetLeft] = useState(0);\n\n const { hasBackgroundOverlap, updateBackgroundOverlapHeight } = useBackgroundOverlap({\n contentHeader: props.contentHeader,\n disableContentHeaderOverlap: props.disableContentHeaderOverlap,\n layoutElement,\n });\n\n useLayoutEffect(\n function handleMainOffsetLeft() {\n setMainOffsetLeft(mainElement?.current?.offsetLeft ?? 0);\n },\n [layoutWidth, isNavigationOpen, isToolsOpen, splitPanelReportedSize]\n );\n\n /**\n * On mobile viewports the navigation and tools drawers are adjusted to a fixed position\n * that consumes 100% of the viewport height and width. The body content could potentially\n * be scrollable underneath the drawer. In order to prevent this a CSS class needs to be\n * added to the document body that sets overflow to hidden.\n */\n useEffect(\n function handleBodyScroll() {\n if (isMobile && (isNavigationOpen || isToolsOpen || !!activeDrawer)) {\n document.body.classList.add(styles['block-body-scroll']);\n } else {\n document.body.classList.remove(styles['block-body-scroll']);\n }\n\n // Ensure the CSS class is removed from the body on side effect cleanup\n return function cleanup() {\n document.body.classList.remove(styles['block-body-scroll']);\n };\n },\n [isMobile, isNavigationOpen, isToolsOpen, activeDrawer]\n );\n\n /**\n * Because the notifications slot does not give us any direction insight into\n * what the state of the child content is we need to have a mechanism for\n * tracking the height of the notifications and whether or not it has content.\n * The height of the notifications is an integer that will be used as a custom\n * property on the Layout component to determine what the sticky offset should\n * be if there are sticky notifications. This could be any number including\n * zero based on how the child content renders. The hasNotificationsContent boolean\n * is simply centralizing the logic of the notifications height being > 0 such\n * that it is not repeated in various components (such as MobileToolbar) that need to\n * know if the notifications slot is empty.\n */\n const [notificationsContainerQuery, notificationsElement] = useContainerQuery(rect => rect.contentBoxHeight);\n\n const notificationsHeight = notificationsContainerQuery ?? 0;\n const hasNotificationsContent = notificationsHeight > 0;\n /**\n * Determine the offsetBottom value based on the presence of a footer element and\n * the SplitPanel component. Ignore the SplitPanel if it is not in the bottom\n * position. Use the size property if it is open and the header height if it is closed.\n */\n let offsetBottom = footerHeight;\n\n if (splitPanelDisplayed && splitPanelPosition === 'bottom') {\n if (isSplitPanelOpen) {\n offsetBottom += splitPanelReportedSize;\n } else {\n offsetBottom += splitPanelReportedHeaderHeight;\n }\n }\n\n /**\n * Warning! This is a hack! In order to accurately calculate if there is adequate\n * horizontal space for the Split Panel to be in the side position we need two values\n * that are not available in JavaScript.\n *\n * The first is the the content gap on the right which is stored in a design token\n * and applied in the Layout CSS:\n *\n * $contentGapRight: #{awsui.$space-layout-content-horizontal};\n *\n * The second is the width of the element that has the circular buttons for the\n * Tools and Split Panel. This could be suppressed given the state of the Tools\n * drawer returning a zero value. It would, however, be rendered if the Split Panel\n * were to move into the side position. This is calculated in the Tools CSS and\n * the Trigger button CSS with design tokens:\n *\n * padding: awsui.$space-scaled-s awsui.$space-layout-toggle-padding;\n * width: awsui.$space-layout-toggle-diameter;\n *\n * These values will be defined below as static integers that are rough approximations\n * of their computed width when rendered in the DOM, but doubled to ensure adequate\n * spacing for the Split Panel to be in side position.\n */\n useLayoutEffect(\n function handleSplitPanelMaxWidth() {\n const contentGapRight = 50; // Approximately 24px when rendered but doubled for safety\n const toolsFormOffsetWidth = 120; // Approximately 60px when rendered but doubled for safety\n const getPanelOffsetWidth = () => {\n if (drawers) {\n return activeDrawerId ? drawerSize : 0;\n }\n return isToolsOpen ? toolsWidth : 0;\n };\n\n setSplitPanelMaxWidth(\n layoutWidth -\n mainOffsetLeft -\n minContentWidth -\n contentGapRight -\n toolsFormOffsetWidth -\n getPanelOffsetWidth()\n );\n\n setDrawersMaxWidth(layoutWidth - mainOffsetLeft - minContentWidth - contentGapRight - toolsFormOffsetWidth);\n },\n [\n activeDrawerId,\n drawerSize,\n drawers,\n isNavigationOpen,\n isToolsOpen,\n layoutWidth,\n mainOffsetLeft,\n minContentWidth,\n toolsWidth,\n ]\n );\n\n /**\n * The useImperativeHandle hook in conjunction with the forwardRef function\n * in the AppLayout component definition expose the following callable\n * functions to component consumers when they put a ref as a property on\n * their component implementation.\n */\n useImperativeHandle(\n forwardRef,\n function createImperativeHandle() {\n return {\n closeNavigationIfNecessary: function () {\n isMobile && handleNavigationClick(false);\n },\n openTools: function () {\n handleToolsClick(true);\n },\n focusToolsClose: () => {\n if (hasDrawers) {\n focusDrawersButtons(true);\n } else {\n focusToolsButtons(true);\n }\n },\n focusActiveDrawer: () => focusDrawersButtons(true),\n focusSplitPanel: () => splitPanelRefs.slider.current?.focus(),\n };\n },\n [\n isMobile,\n handleNavigationClick,\n handleToolsClick,\n focusToolsButtons,\n focusDrawersButtons,\n splitPanelRefs.slider,\n hasDrawers,\n ]\n );\n\n return (\n <AppLayoutInternalsContext.Provider\n value={{\n ...props,\n activeDrawerId,\n contentType,\n drawers,\n drawersAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawers,\n drawersOverflowAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawersOverflow,\n drawersOverflowWithBadgeAriaLabel: drawersProps.ariaLabelsWithDrawers?.drawersOverflowWithBadge,\n drawersRefs,\n drawersMinWidth,\n drawersMaxWidth,\n drawerSize,\n drawerRef,\n resizeHandle,\n drawersTriggerCount,\n headerHeight,\n footerHeight,\n hasDefaultToolsWidth,\n hasDrawerViewportOverlay,\n handleDrawersClick,\n handleNavigationClick,\n handleSplitPanelClick,\n handleSplitPanelPreferencesChange,\n handleSplitPanelResize,\n handleToolsClick,\n hasBackgroundOverlap,\n hasNotificationsContent,\n hasOpenDrawer,\n hasStickyBackground,\n isBackgroundOverlapDisabled: props.disableContentHeaderOverlap || !hasBackgroundOverlap,\n isMobile,\n isNavigationOpen: isNavigationOpen ?? false,\n isSplitPanelForcedPosition,\n isSplitPanelOpen,\n isToolsOpen,\n layoutElement,\n layoutWidth,\n loseToolsFocus,\n loseDrawersFocus,\n mainElement,\n mainOffsetLeft,\n maxContentWidth,\n minContentWidth,\n navigationHide,\n navigationRefs,\n notificationsElement,\n notificationsHeight,\n offsetBottom,\n setHasStickyBackground,\n setSplitPanelReportedSize,\n setSplitPanelReportedHeaderHeight,\n splitPanel,\n splitPanelControlId,\n splitPanelDisplayed,\n splitPanelMaxWidth,\n splitPanelMinWidth,\n splitPanelPosition,\n splitPanelPreferences,\n splitPanelReportedSize,\n splitPanelReportedHeaderHeight,\n splitPanelSize,\n splitPanelToggle,\n setSplitPanelToggle,\n splitPanelRefs,\n toolsControlId,\n toolsHide,\n toolsOpen: isToolsOpen,\n toolsWidth,\n toolsRefs,\n __embeddedViewMode,\n }}\n >\n <AppLayoutContext.Provider\n value={{\n stickyOffsetBottom: offsetBottom,\n stickyOffsetTop: 0, // not used in this design. Sticky headers read a CSS-var instead\n setHasStickyBackground,\n }}\n >\n <DynamicOverlapContext.Provider value={updateBackgroundOverlapHeight}>\n {children}\n </DynamicOverlapContext.Provider>\n </AppLayoutContext.Provider>\n </AppLayoutInternalsContext.Provider>\n );\n }\n);\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AppLayoutProps } from '../interfaces';
|
|
3
|
-
declare const AppLayoutWithRef: React.ForwardRefExoticComponent<AppLayoutProps &
|
|
3
|
+
declare const AppLayoutWithRef: React.ForwardRefExoticComponent<AppLayoutProps & {
|
|
4
|
+
contentType: AppLayoutProps.ContentType;
|
|
5
|
+
headerSelector: string;
|
|
6
|
+
footerSelector: string;
|
|
7
|
+
} & React.RefAttributes<AppLayoutProps.Ref>>;
|
|
4
8
|
export default AppLayoutWithRef;
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAA8B,MAAM,eAAe,CAAC;AAa3E,QAAA,MAAM,gBAAgB;;;;4CAiCpB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,SAAS,CAC1D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,SAAS,CAC1D,KAAiC,EACjC,GAAkC;IAElC,OAAO,CACL,oBAAC,0BAA0B,oBAAK,KAAK,IAAE,GAAG,EAAE,GAAG;QAC7C,oBAAC,UAAU;YACT,oBAAC,MAAM;gBACL,oBAAC,UAAU,OAAG;gBAEd,oBAAC,UAAU,OAAG;gBAEd,oBAAC,aAAa,OAAG;gBAEjB,oBAAC,aAAa,OAAG;gBAEjB,oBAAC,WAAW,OAAG;gBAEf,oBAAC,MAAM,OAAG;gBAEV,oBAAC,IAAI,OAAG;gBAER,oBAAC,UAAU,CAAC,MAAM,OAAG;gBAErB,oBAAC,KAAK;oBACJ,oBAAC,UAAU,CAAC,IAAI,OAAG,CACb;gBAER,oBAAC,OAAO,OAAG,CACJ,CACE,CACc,CAC9B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { AppLayoutInternalsProvider } from './context';\nimport { AppLayoutProps, AppLayoutPropsWithDefaults } from '../interfaces';\nimport Background from './background';\nimport Breadcrumbs from './breadcrumbs';\nimport Drawers from './drawers';\nimport Header from './header';\nimport Layout from './layout';\nimport Main from './main';\nimport MobileToolbar from './mobile-toolbar';\nimport Navigation from './navigation';\nimport Notifications from './notifications';\nimport SplitPanel from './split-panel';\nimport Tools from './tools';\n\nconst AppLayoutWithRef = React.forwardRef(function AppLayout(\n props: AppLayoutPropsWithDefaults,\n ref: React.Ref<AppLayoutProps.Ref>\n) {\n return (\n <AppLayoutInternalsProvider {...props} ref={ref}>\n <SplitPanel>\n <Layout>\n <Background />\n\n <Navigation />\n\n <MobileToolbar />\n\n <Notifications />\n\n <Breadcrumbs />\n\n <Header />\n\n <Main />\n\n <SplitPanel.Bottom />\n\n <Tools>\n <SplitPanel.Side />\n </Tools>\n\n <Drawers />\n </Layout>\n </SplitPanel>\n </AppLayoutInternalsProvider>\n );\n});\n\nexport default AppLayoutWithRef;\n"]}
|
package/app-layout/widget.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AppLayoutProps } from './interfaces';
|
|
3
|
-
type AppLayoutType = React.ForwardRefExoticComponent<
|
|
2
|
+
import { AppLayoutProps, AppLayoutPropsWithDefaults } from './interfaces';
|
|
3
|
+
type AppLayoutType = React.ForwardRefExoticComponent<AppLayoutPropsWithDefaults & React.RefAttributes<AppLayoutProps.Ref>>;
|
|
4
4
|
export declare function createWidgetizedAppLayout(AppLayoutLoader?: AppLayoutType): AppLayoutType;
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/app-layout/widget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../../src/app-layout/widget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAI1E,KAAK,aAAa,GAAG,KAAK,CAAC,yBAAyB,CAClD,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CACrE,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,eAAe,CAAC,EAAE,aAAa,GAAG,aAAa,CASxF"}
|
package/app-layout/widget.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/app-layout/widget.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../../src/app-layout/widget.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAM3D,MAAM,UAAU,yBAAyB,CAAC,eAA+B;IACvE,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACrC,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;QACrC,IAAI,SAAS,IAAI,aAAa,CAAC,iBAAiB,CAAC,IAAI,eAAe,EAAE;YACpE,OAAO,oBAAC,eAAe,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAAC;SACjD;QAED,OAAO,oBAAC,uBAAuB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { getGlobalFlag } from '../internal/utils/global-flags';\nimport { AppLayoutProps, AppLayoutPropsWithDefaults } from './interfaces';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { AppLayoutImplementation } from './implementation';\n\ntype AppLayoutType = React.ForwardRefExoticComponent<\n AppLayoutPropsWithDefaults & React.RefAttributes<AppLayoutProps.Ref>\n>;\n\nexport function createWidgetizedAppLayout(AppLayoutLoader?: AppLayoutType): AppLayoutType {\n return React.forwardRef((props, ref) => {\n const isRefresh = useVisualRefresh();\n if (isRefresh && getGlobalFlag('appLayoutWidget') && AppLayoutLoader) {\n return <AppLayoutLoader ref={ref} {...props} />;\n }\n\n return <AppLayoutImplementation ref={ref} {...props} />;\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAkBhF,QAAA,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/button-dropdown/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAkBhF,QAAA,MAAM,sBAAsB,6GAoS3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -41,7 +41,8 @@ const InternalButtonDropdown = React.forwardRef((_a, ref) => {
|
|
|
41
41
|
items,
|
|
42
42
|
onItemClick,
|
|
43
43
|
onItemFollow,
|
|
44
|
-
|
|
44
|
+
// Scroll is unnecessary when moving focus back to the dropdown trigger.
|
|
45
|
+
onReturnFocus: () => { var _a; return (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); },
|
|
45
46
|
expandToViewport,
|
|
46
47
|
hasExpandableGroups: expandableGroups,
|
|
47
48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cAAc,EAAE,IAAI,EACpB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB,CACU,CACL,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { ButtonDropdownProps, InternalButtonDropdownProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport Dropdown from '../internal/components/dropdown';\nimport ItemsList from './items-list';\nimport { useButtonDropdown } from './utils/use-button-dropdown';\nimport OptionsList from '../internal/components/options-list';\nimport { InternalButton, InternalButtonProps } from '../button/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport InternalBox from '../box/internal';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode/index.js';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel.js';\n\nconst InternalButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n children,\n onItemClick,\n onItemFollow,\n customTriggerBuilder,\n expandToViewport,\n ariaLabel,\n title,\n description,\n preferCenter,\n mainAction,\n __internalRootRef,\n ...props\n }: InternalButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const isInRestrictedView = useMobile();\n const dropdownId = useUniqueId('dropdown');\n for (const item of items) {\n checkSafeUrl('ButtonDropdown', item.href);\n }\n if (mainAction) {\n checkSafeUrl('ButtonDropdown', mainAction.href);\n }\n\n if (isDevelopment) {\n if (mainAction && variant !== 'primary' && variant !== 'normal') {\n warnOnce('ButtonDropdown', 'Main action is only supported for \"primary\" and \"normal\" component variant.');\n }\n }\n const isMainAction = mainAction && (variant === 'primary' || variant === 'normal');\n const isVisualRefresh = useVisualRefresh();\n\n const {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n } = useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n onReturnFocus: () => triggerRef.current?.focus(),\n expandToViewport,\n hasExpandableGroups: expandableGroups,\n isInRestrictedView,\n });\n\n const handleMouseEvent = () => {\n setIsUsingMouse(true);\n };\n\n const baseProps = getBaseProps(props);\n\n const mainActionRef = useRef<HTMLElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n\n useForwardFocus(ref, isMainAction ? mainActionRef : triggerRef);\n\n const clickHandler = () => {\n if (!loading && !disabled) {\n // Prevent moving highlight on mobiles to avoid disabled state reason popup if defined.\n toggleDropdown({ moveHighlightOnOpen: !isInRestrictedView });\n }\n };\n\n const canBeOpened = !loading && !disabled;\n\n const triggerVariant = variant === 'navigation' ? undefined : variant === 'inline-icon' ? 'inline-icon' : variant;\n const iconProps: Partial<ButtonProps & { __iconClass?: string }> =\n variant === 'icon' || variant === 'inline-icon'\n ? {\n iconName: 'ellipsis',\n }\n : {\n iconName: 'caret-down-filled',\n iconAlign: 'right',\n __iconClass: canBeOpened && isOpen ? styles['rotate-up'] : styles['rotate-down'],\n };\n\n const baseTriggerProps: InternalButtonProps = {\n className: clsx(styles['trigger-button'], styles['test-utils-button-trigger']),\n ...iconProps,\n variant: triggerVariant,\n loading,\n loadingText,\n disabled,\n onClick: (event: Event) => {\n event.preventDefault();\n clickHandler();\n },\n ariaLabel,\n ariaExpanded: canBeOpened && isOpen,\n formAction: 'none',\n __nativeAttributes: {\n 'aria-haspopup': true,\n },\n };\n\n const triggerId = useUniqueId('awsui-button-dropdown__trigger');\n\n const triggerHasBadge = () => {\n const flatItems = items.flatMap(item => {\n if ('items' in item) {\n return item.items;\n }\n return item;\n });\n\n return (\n variant === 'icon' &&\n !!flatItems?.find(item => {\n if ('badge' in item) {\n return item.badge;\n }\n })\n );\n };\n\n let trigger: React.ReactNode = null;\n if (customTriggerBuilder) {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n {customTriggerBuilder({\n testUtilsClass: styles['test-utils-button-trigger'],\n ariaExpanded: canBeOpened && isOpen,\n onClick: clickHandler,\n triggerRef,\n ariaLabel,\n disabled,\n isOpen,\n })}\n </div>\n );\n } else if (isMainAction) {\n const { text, iconName, iconAlt, iconSvg, iconUrl, external, externalIconAriaLabel, ...mainActionProps } =\n mainAction;\n const mainActionIconProps = external\n ? ({ iconName: 'external', iconAlign: 'right' } as const)\n : ({ iconName, iconAlt, iconSvg, iconUrl } as const);\n const mainActionAriaLabel = externalIconAriaLabel\n ? `${mainAction.ariaLabel ?? mainAction.text} ${mainAction.externalIconAriaLabel}`\n : undefined;\n\n trigger = (\n <div role=\"group\" aria-label={ariaLabel} className={styles['split-trigger-wrapper']}>\n <div\n className={clsx(styles['trigger-item'], styles['split-trigger'])}\n // Close dropdown upon main action click unless event is cancelled.\n onClick={closeDropdown}\n // Prevent keyboard events from propagation to the button dropdown handler.\n onKeyDown={e => e.stopPropagation()}\n onKeyUp={e => e.stopPropagation()}\n >\n <InternalButton\n ref={mainActionRef}\n {...mainActionProps}\n {...mainActionIconProps}\n className={styles['trigger-button']}\n variant={variant}\n ariaLabel={mainActionAriaLabel}\n formAction=\"none\"\n >\n {text}\n </InternalButton>\n </div>\n <div\n className={clsx(\n styles['trigger-item'],\n styles['dropdown-trigger'],\n isVisualRefresh && styles['visual-refresh']\n )}\n >\n <InternalButton ref={triggerRef} {...baseTriggerProps} />\n </div>\n </div>\n );\n } else {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n <InternalButton ref={triggerRef} id={triggerId} {...baseTriggerProps} badge={triggerHasBadge()}>\n {children}\n </InternalButton>\n </div>\n );\n }\n\n const hasHeader = title || description;\n const headerId = useUniqueId('awsui-button-dropdown__header');\n\n const shouldLabelWithTrigger = !ariaLabel && !mainAction && variant !== 'icon' && variant !== 'inline-icon';\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n return (\n <div\n {...baseProps}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={handleMouseEvent}\n onMouseMove={handleMouseEvent}\n className={clsx(styles['button-dropdown'], styles[`variant-${variant}`], baseProps.className)}\n aria-owns={expandToViewport && isOpen ? dropdownId : undefined}\n ref={__internalRootRef}\n >\n <Dropdown\n open={canBeOpened && isOpen}\n stretchWidth={false}\n stretchTriggerHeight={variant === 'navigation'}\n expandToViewport={expandToViewport}\n preferCenter={preferCenter}\n onDropdownClose={() => toggleDropdown()}\n trigger={trigger}\n dropdownId={dropdownId}\n >\n {hasHeader && (\n <div className={styles.header} id={headerId}>\n {title && (\n <div className={styles.title}>\n <InternalBox\n fontSize=\"heading-s\"\n fontWeight=\"bold\"\n color=\"inherit\"\n tagOverride=\"h2\"\n margin={{ vertical: 'n', horizontal: 'n' }}\n >\n {title}\n </InternalBox>\n </div>\n )}\n {description && (\n <InternalBox fontSize=\"body-s\">\n <span className={styles.description}>{description}</span>\n </InternalBox>\n )}\n </div>\n )}\n <OptionsList\n open={canBeOpened && isOpen}\n position=\"static\"\n role=\"menu\"\n decreaseBlockMargin={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={hasHeader ? headerId : shouldLabelWithTrigger ? triggerId : undefined}\n statusType=\"finished\"\n >\n <ItemsList\n items={items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n hasExpandableGroups={expandableGroups}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n lastInDropdown={true}\n highlightItem={highlightItem}\n expandToViewport={expandToViewport}\n variant={variant}\n />\n </OptionsList>\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default InternalButtonDropdown;\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/button-dropdown/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,WAAW,MAAM,qCAAqC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAEtE,MAAM,sBAAsB,GAAG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AU,EAAC,UAAU;gBAErB,oBAAC,SAAS,IACR,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,gBAAgB,EACrC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,IAAI,EACpB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,OAAO,GAChB,CACU,CACL,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport styles from './styles.css.js';\nimport { ButtonDropdownProps, InternalButtonDropdownProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport Dropdown from '../internal/components/dropdown';\nimport ItemsList from './items-list';\nimport { useButtonDropdown } from './utils/use-button-dropdown';\nimport OptionsList from '../internal/components/options-list';\nimport { InternalButton, InternalButtonProps } from '../button/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport InternalBox from '../box/internal';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode/index.js';\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel.js';\n\nconst InternalButtonDropdown = React.forwardRef(\n (\n {\n items,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n expandableGroups = false,\n children,\n onItemClick,\n onItemFollow,\n customTriggerBuilder,\n expandToViewport,\n ariaLabel,\n title,\n description,\n preferCenter,\n mainAction,\n __internalRootRef,\n ...props\n }: InternalButtonDropdownProps,\n ref: React.Ref<ButtonDropdownProps.Ref>\n ) => {\n const isInRestrictedView = useMobile();\n const dropdownId = useUniqueId('dropdown');\n for (const item of items) {\n checkSafeUrl('ButtonDropdown', item.href);\n }\n if (mainAction) {\n checkSafeUrl('ButtonDropdown', mainAction.href);\n }\n\n if (isDevelopment) {\n if (mainAction && variant !== 'primary' && variant !== 'normal') {\n warnOnce('ButtonDropdown', 'Main action is only supported for \"primary\" and \"normal\" component variant.');\n }\n }\n const isMainAction = mainAction && (variant === 'primary' || variant === 'normal');\n const isVisualRefresh = useVisualRefresh();\n\n const {\n isOpen,\n targetItem,\n isHighlighted,\n isKeyboardHighlight,\n isExpanded,\n highlightItem,\n onKeyDown,\n onKeyUp,\n onItemActivate,\n onGroupToggle,\n toggleDropdown,\n closeDropdown,\n setIsUsingMouse,\n } = useButtonDropdown({\n items,\n onItemClick,\n onItemFollow,\n // Scroll is unnecessary when moving focus back to the dropdown trigger.\n onReturnFocus: () => triggerRef.current?.focus({ preventScroll: true }),\n expandToViewport,\n hasExpandableGroups: expandableGroups,\n isInRestrictedView,\n });\n\n const handleMouseEvent = () => {\n setIsUsingMouse(true);\n };\n\n const baseProps = getBaseProps(props);\n\n const mainActionRef = useRef<HTMLElement>(null);\n const triggerRef = useRef<HTMLElement>(null);\n\n useForwardFocus(ref, isMainAction ? mainActionRef : triggerRef);\n\n const clickHandler = () => {\n if (!loading && !disabled) {\n // Prevent moving highlight on mobiles to avoid disabled state reason popup if defined.\n toggleDropdown({ moveHighlightOnOpen: !isInRestrictedView });\n }\n };\n\n const canBeOpened = !loading && !disabled;\n\n const triggerVariant = variant === 'navigation' ? undefined : variant === 'inline-icon' ? 'inline-icon' : variant;\n const iconProps: Partial<ButtonProps & { __iconClass?: string }> =\n variant === 'icon' || variant === 'inline-icon'\n ? {\n iconName: 'ellipsis',\n }\n : {\n iconName: 'caret-down-filled',\n iconAlign: 'right',\n __iconClass: canBeOpened && isOpen ? styles['rotate-up'] : styles['rotate-down'],\n };\n\n const baseTriggerProps: InternalButtonProps = {\n className: clsx(styles['trigger-button'], styles['test-utils-button-trigger']),\n ...iconProps,\n variant: triggerVariant,\n loading,\n loadingText,\n disabled,\n onClick: (event: Event) => {\n event.preventDefault();\n clickHandler();\n },\n ariaLabel,\n ariaExpanded: canBeOpened && isOpen,\n formAction: 'none',\n __nativeAttributes: {\n 'aria-haspopup': true,\n },\n };\n\n const triggerId = useUniqueId('awsui-button-dropdown__trigger');\n\n const triggerHasBadge = () => {\n const flatItems = items.flatMap(item => {\n if ('items' in item) {\n return item.items;\n }\n return item;\n });\n\n return (\n variant === 'icon' &&\n !!flatItems?.find(item => {\n if ('badge' in item) {\n return item.badge;\n }\n })\n );\n };\n\n let trigger: React.ReactNode = null;\n if (customTriggerBuilder) {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n {customTriggerBuilder({\n testUtilsClass: styles['test-utils-button-trigger'],\n ariaExpanded: canBeOpened && isOpen,\n onClick: clickHandler,\n triggerRef,\n ariaLabel,\n disabled,\n isOpen,\n })}\n </div>\n );\n } else if (isMainAction) {\n const { text, iconName, iconAlt, iconSvg, iconUrl, external, externalIconAriaLabel, ...mainActionProps } =\n mainAction;\n const mainActionIconProps = external\n ? ({ iconName: 'external', iconAlign: 'right' } as const)\n : ({ iconName, iconAlt, iconSvg, iconUrl } as const);\n const mainActionAriaLabel = externalIconAriaLabel\n ? `${mainAction.ariaLabel ?? mainAction.text} ${mainAction.externalIconAriaLabel}`\n : undefined;\n\n trigger = (\n <div role=\"group\" aria-label={ariaLabel} className={styles['split-trigger-wrapper']}>\n <div\n className={clsx(styles['trigger-item'], styles['split-trigger'])}\n // Close dropdown upon main action click unless event is cancelled.\n onClick={closeDropdown}\n // Prevent keyboard events from propagation to the button dropdown handler.\n onKeyDown={e => e.stopPropagation()}\n onKeyUp={e => e.stopPropagation()}\n >\n <InternalButton\n ref={mainActionRef}\n {...mainActionProps}\n {...mainActionIconProps}\n className={styles['trigger-button']}\n variant={variant}\n ariaLabel={mainActionAriaLabel}\n formAction=\"none\"\n >\n {text}\n </InternalButton>\n </div>\n <div\n className={clsx(\n styles['trigger-item'],\n styles['dropdown-trigger'],\n isVisualRefresh && styles['visual-refresh']\n )}\n >\n <InternalButton ref={triggerRef} {...baseTriggerProps} />\n </div>\n </div>\n );\n } else {\n trigger = (\n <div className={styles['dropdown-trigger']}>\n <InternalButton ref={triggerRef} id={triggerId} {...baseTriggerProps} badge={triggerHasBadge()}>\n {children}\n </InternalButton>\n </div>\n );\n }\n\n const hasHeader = title || description;\n const headerId = useUniqueId('awsui-button-dropdown__header');\n\n const shouldLabelWithTrigger = !ariaLabel && !mainAction && variant !== 'icon' && variant !== 'inline-icon';\n\n const { loadingButtonCount } = useFunnel();\n useEffect(() => {\n if (loading) {\n loadingButtonCount.current++;\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n loadingButtonCount.current--;\n };\n }\n }, [loading, loadingButtonCount]);\n\n return (\n <div\n {...baseProps}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={handleMouseEvent}\n onMouseMove={handleMouseEvent}\n className={clsx(styles['button-dropdown'], styles[`variant-${variant}`], baseProps.className)}\n aria-owns={expandToViewport && isOpen ? dropdownId : undefined}\n ref={__internalRootRef}\n >\n <Dropdown\n open={canBeOpened && isOpen}\n stretchWidth={false}\n stretchTriggerHeight={variant === 'navigation'}\n expandToViewport={expandToViewport}\n preferCenter={preferCenter}\n onDropdownClose={() => toggleDropdown()}\n trigger={trigger}\n dropdownId={dropdownId}\n >\n {hasHeader && (\n <div className={styles.header} id={headerId}>\n {title && (\n <div className={styles.title}>\n <InternalBox\n fontSize=\"heading-s\"\n fontWeight=\"bold\"\n color=\"inherit\"\n tagOverride=\"h2\"\n margin={{ vertical: 'n', horizontal: 'n' }}\n >\n {title}\n </InternalBox>\n </div>\n )}\n {description && (\n <InternalBox fontSize=\"body-s\">\n <span className={styles.description}>{description}</span>\n </InternalBox>\n )}\n </div>\n )}\n <OptionsList\n open={canBeOpened && isOpen}\n position=\"static\"\n role=\"menu\"\n decreaseBlockMargin={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={hasHeader ? headerId : shouldLabelWithTrigger ? triggerId : undefined}\n statusType=\"finished\"\n >\n <ItemsList\n items={items}\n onItemActivate={onItemActivate}\n onGroupToggle={onGroupToggle}\n hasExpandableGroups={expandableGroups}\n targetItem={targetItem}\n isHighlighted={isHighlighted}\n isKeyboardHighlight={isKeyboardHighlight}\n isExpanded={isExpanded}\n lastInDropdown={true}\n highlightItem={highlightItem}\n expandToViewport={expandToViewport}\n variant={variant}\n />\n </OptionsList>\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default InternalButtonDropdown;\n"]}
|
package/calendar/grid/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface GridProps {
|
|
|
29
29
|
renderDate: (date: Date) => string;
|
|
30
30
|
renderDateAnnouncement: (date: Date, isOnCurrentDate: boolean) => string;
|
|
31
31
|
isSameDate: (date: Date, baseDate: Date) => boolean;
|
|
32
|
-
onGridKeyDownHandler: (event: React.KeyboardEvent) => void;
|
|
32
|
+
onGridKeyDownHandler: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
33
33
|
}
|
|
34
34
|
export default function Grid({ isDateEnabled, focusedDate, focusableDate, onSelectDate, selectedDate, ariaLabelledby, header, rows, isCurrentPage, renderDate, renderDateAnnouncement, isSameDate, onGridKeyDownHandler, }: GridProps): JSX.Element;
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;;;;;;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9C,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,aAAa;oBAChD,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,EAAE,SAAS;iBAC3C,CAAC;gBAEF,8BAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAc,MAAM,IACtD,UAAU,CAAC,IAAI,CAAC,CACZ;gBAEP,oBAAC,gBAAgB,QAAE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAoB,CAC/E,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every date is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - dates are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - date announcements are not interruptive and can be missed if navigating fast.\n */\n\nexport interface GridProps {\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangePage: (date: Date) => void;\n selectedDate: Date | null;\n ariaLabelledby: string;\n header?: React.ReactNode;\n rows: ReadonlyArray<ReadonlyArray<Date>>;\n isCurrentPage: (date: Date) => boolean;\n renderDate: (date: Date) => string;\n renderDateAnnouncement: (date: Date, isOnCurrentDate: boolean) => string;\n isSameDate: (date: Date, baseDate: Date) => boolean;\n onGridKeyDownHandler: (event: React.KeyboardEvent) => void;\n}\n\nexport default function Grid({\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n selectedDate,\n ariaLabelledby,\n header,\n rows,\n isCurrentPage,\n renderDate,\n renderDateAnnouncement,\n isSameDate,\n onGridKeyDownHandler,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding date button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const rowLength = rows[0].length;\n\n const denseGrid = rowLength > 3;\n\n return (\n <table\n role=\"grid\"\n className={clsx(styles['calendar-grid'], denseGrid && styles['calendar-grid-dense'])}\n aria-labelledby={ariaLabelledby}\n >\n {header}\n <tbody onKeyDown={onGridKeyDownHandler}>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex} className={styles['calendar-row']}>\n {row.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDate(date, focusableDate);\n const isSelected = !!selectedDate && isSameDate(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isCurrentDate = isSameDate(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n return (\n <td\n key={`${rowIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n tabIndex={tabIndex}\n aria-current={isCurrentDate ? 'date' : undefined}\n aria-selected={isEnabled ? isSelected : undefined}\n aria-disabled={!isEnabled}\n // Do not attach click event when the date is disabled, otherwise VO+safari announces clickable\n onClick={isEnabled ? () => onSelectDate(date) : undefined}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date'], {\n [styles['calendar-date-current-page']]: isCurrentPage(date),\n [styles['calendar-date-enabled']]: isEnabled,\n [styles['calendar-date-selected']]: isSelected,\n [styles['calendar-date-current']]: isCurrentDate,\n [styles['calendar-date-dense']]: denseGrid,\n })}\n >\n <span className={styles['date-inner']} aria-hidden=\"true\">\n {renderDate(date)}\n </span>\n {/* Screen-reader announcement for the focused date. */}\n <ScreenreaderOnly>{renderDateAnnouncement(date, isCurrentDate)}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,gBAAgB,MAAM,sDAAsD,CAAC;AAmCpF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,MAAM,EACN,IAAI,EACJ,aAAa,EACb,UAAU,EACV,sBAAsB,EACtB,UAAU,EACV,oBAAoB,GACV;IACV,MAAM,cAAc,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAC;IAE1D,6EAA6E;IAC7E,iFAAiF;IACjF,iBAAiB,CAAC,GAAG,EAAE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AC,CAAC;aACf;YAED,OAAO,CACL,4BACE,GAAG,EAAE,GAAG,QAAQ,IAAI,SAAS,EAAE,EAC/B,GAAG,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAChD,QAAQ,EAAE,QAAQ,kBACJ,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,mBACjC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,mBAClC,CAAC,SAAS;gBACzB,+FAA+F;gBAC/F,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EACzD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE;oBACrE,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC;oBAC3D,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,SAAS;oBAC5C,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,EAAE,UAAU;oBAC9C,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,EAAE,aAAa;oBAChD,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,EAAE,SAAS;iBAC3C,CAAC;gBAEF,8BAAM,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,iBAAc,MAAM,IACtD,UAAU,CAAC,IAAI,CAAC,CACZ;gBAEP,oBAAC,gBAAgB,QAAE,sBAAsB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAoB,CAC/E,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every date is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - dates are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - date announcements are not interruptive and can be missed if navigating fast.\n */\n\nexport interface GridProps {\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangePage: (date: Date) => void;\n selectedDate: Date | null;\n ariaLabelledby: string;\n header?: React.ReactNode;\n rows: ReadonlyArray<ReadonlyArray<Date>>;\n isCurrentPage: (date: Date) => boolean;\n renderDate: (date: Date) => string;\n renderDateAnnouncement: (date: Date, isOnCurrentDate: boolean) => string;\n isSameDate: (date: Date, baseDate: Date) => boolean;\n onGridKeyDownHandler: (event: React.KeyboardEvent<HTMLElement>) => void;\n}\n\nexport default function Grid({\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n selectedDate,\n ariaLabelledby,\n header,\n rows,\n isCurrentPage,\n renderDate,\n renderDateAnnouncement,\n isSameDate,\n onGridKeyDownHandler,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding date button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const rowLength = rows[0].length;\n\n const denseGrid = rowLength > 3;\n\n return (\n <table\n role=\"grid\"\n className={clsx(styles['calendar-grid'], denseGrid && styles['calendar-grid-dense'])}\n aria-labelledby={ariaLabelledby}\n >\n {header}\n <tbody onKeyDown={onGridKeyDownHandler}>\n {rows.map((row, rowIndex) => (\n <tr key={rowIndex} className={styles['calendar-row']}>\n {row.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDate(date, focusableDate);\n const isSelected = !!selectedDate && isSameDate(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isCurrentDate = isSameDate(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n return (\n <td\n key={`${rowIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n tabIndex={tabIndex}\n aria-current={isCurrentDate ? 'date' : undefined}\n aria-selected={isEnabled ? isSelected : undefined}\n aria-disabled={!isEnabled}\n // Do not attach click event when the date is disabled, otherwise VO+safari announces clickable\n onClick={isEnabled ? () => onSelectDate(date) : undefined}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-date'], {\n [styles['calendar-date-current-page']]: isCurrentPage(date),\n [styles['calendar-date-enabled']]: isEnabled,\n [styles['calendar-date-selected']]: isSelected,\n [styles['calendar-date-current']]: isCurrentDate,\n [styles['calendar-date-dense']]: denseGrid,\n })}\n >\n <span className={styles['date-inner']} aria-hidden=\"true\">\n {renderDate(date)}\n </span>\n {/* Screen-reader announcement for the focused date. */}\n <ScreenreaderOnly>{renderDateAnnouncement(date, isCurrentDate)}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
@@ -8,5 +8,5 @@ export default function useCalendarGridKeyboardNavigation({ baseDate, focusableD
|
|
|
8
8
|
onChangePage: (date: Date) => void;
|
|
9
9
|
onFocusDate: (date: null | Date) => void;
|
|
10
10
|
onSelectDate: (date: Date) => void;
|
|
11
|
-
}): (event: React.KeyboardEvent) => void;
|
|
11
|
+
}): (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
12
12
|
//# sourceMappingURL=use-calendar-grid-keyboard-navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar-grid-keyboard-navigation.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/use-calendar-grid-keyboard-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-keyboard-navigation.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/use-calendar-grid-keyboard-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAc9C,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAC,EACxD,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC,qBAAqB,CAAC;IACnD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC,WAUsC,mBAAmB,CAAC,WAAW,CAAC,UAiCtE"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { isSameMonth, isSameYear } from 'date-fns';
|
|
4
4
|
import { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek, moveNextMonth, movePrevMonth, moveMonthDown, moveMonthUp, } from '../utils/navigation';
|
|
5
5
|
import { KeyCode } from '../../internal/keycode';
|
|
6
|
+
import handleKey from '../../internal/utils/handle-key';
|
|
6
7
|
export default function useCalendarGridKeyboardNavigation({ baseDate, focusableDate, granularity, isDateEnabled, onChangePage, onFocusDate, onSelectDate, }) {
|
|
7
8
|
const isMonthPicker = granularity === 'month';
|
|
8
9
|
const moveDown = isMonthPicker ? moveMonthDown : moveNextWeek;
|
|
@@ -12,36 +13,23 @@ export default function useCalendarGridKeyboardNavigation({ baseDate, focusableD
|
|
|
12
13
|
const isSamePage = isMonthPicker ? isSameYear : isSameMonth;
|
|
13
14
|
const onGridKeyDownHandler = (event) => {
|
|
14
15
|
let updatedFocusDate;
|
|
15
|
-
|
|
16
|
+
const keys = [KeyCode.up, KeyCode.down, KeyCode.left, KeyCode.right, KeyCode.space, KeyCode.enter];
|
|
17
|
+
if (focusableDate === null || keys.indexOf(event.keyCode) === -1) {
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
case KeyCode.left:
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
updatedFocusDate = moveLeft(focusableDate, isDateEnabled);
|
|
34
|
-
break;
|
|
35
|
-
case KeyCode.up:
|
|
36
|
-
event.preventDefault();
|
|
37
|
-
updatedFocusDate = moveUp(focusableDate, isDateEnabled);
|
|
38
|
-
break;
|
|
39
|
-
case KeyCode.down:
|
|
40
|
-
event.preventDefault();
|
|
41
|
-
updatedFocusDate = moveDown(focusableDate, isDateEnabled);
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
return;
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
handleKey(event, {
|
|
22
|
+
onActivate: () => {
|
|
23
|
+
onFocusDate(null);
|
|
24
|
+
onSelectDate(focusableDate);
|
|
25
|
+
},
|
|
26
|
+
onBlockEnd: () => (updatedFocusDate = moveDown(focusableDate, isDateEnabled)),
|
|
27
|
+
onBlockStart: () => (updatedFocusDate = moveUp(focusableDate, isDateEnabled)),
|
|
28
|
+
onInlineStart: () => (updatedFocusDate = moveLeft(focusableDate, isDateEnabled)),
|
|
29
|
+
onInlineEnd: () => (updatedFocusDate = moveRight(focusableDate, isDateEnabled)),
|
|
30
|
+
});
|
|
31
|
+
if (!updatedFocusDate) {
|
|
32
|
+
return;
|
|
45
33
|
}
|
|
46
34
|
if (!isSamePage(updatedFocusDate, baseDate)) {
|
|
47
35
|
onChangePage(updatedFocusDate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-calendar-grid-keyboard-navigation.js","sourceRoot":"","sources":["../../../../src/calendar/grid/use-calendar-grid-keyboard-navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-calendar-grid-keyboard-navigation.js","sourceRoot":"","sources":["../../../../src/calendar/grid/use-calendar-grid-keyboard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AI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;YAChE,OAAO;SACR;QAED,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,SAAS,CAAC,KAAK,EAAE;YACf,UAAU,EAAE,GAAG,EAAE;gBACf,WAAW,CAAC,IAAI,CAAC,CAAC;gBAClB,YAAY,CAAC,aAAa,CAAC,CAAC;YAC9B,CAAC;YACD,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB,GAAG,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAC7E,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAC7E,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB,GAAG,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAChF,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,gBAAgB,GAAG,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;SAChF,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO;SACR;QAED,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE;YAC3C,YAAY,CAAC,gBAAgB,CAAC,CAAC;SAChC;QACD,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport { isSameMonth, isSameYear } from 'date-fns';\nimport { CalendarProps } from '../interfaces';\nimport {\n moveNextDay,\n movePrevDay,\n moveNextWeek,\n movePrevWeek,\n moveNextMonth,\n movePrevMonth,\n moveMonthDown,\n moveMonthUp,\n} from '../utils/navigation';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey from '../../internal/utils/handle-key';\n\nexport default function useCalendarGridKeyboardNavigation({\n baseDate,\n focusableDate,\n granularity,\n isDateEnabled,\n onChangePage,\n onFocusDate,\n onSelectDate,\n}: {\n baseDate: Date;\n focusableDate: Date | null;\n granularity: CalendarProps.Granularity;\n isDateEnabled: CalendarProps.IsDateEnabledFunction;\n onChangePage: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onSelectDate: (date: Date) => void;\n}) {\n const isMonthPicker = granularity === 'month';\n\n const moveDown = isMonthPicker ? moveMonthDown : moveNextWeek;\n const moveLeft = isMonthPicker ? movePrevMonth : movePrevDay;\n const moveRight = isMonthPicker ? moveNextMonth : moveNextDay;\n const moveUp = isMonthPicker ? moveMonthUp : movePrevWeek;\n\n const isSamePage = isMonthPicker ? isSameYear : isSameMonth;\n\n const onGridKeyDownHandler = (event: React.KeyboardEvent<HTMLElement>) => {\n let updatedFocusDate;\n\n const keys = [KeyCode.up, KeyCode.down, KeyCode.left, KeyCode.right, KeyCode.space, KeyCode.enter];\n\n if (focusableDate === null || keys.indexOf(event.keyCode) === -1) {\n return;\n }\n\n event.preventDefault();\n\n handleKey(event, {\n onActivate: () => {\n onFocusDate(null);\n onSelectDate(focusableDate);\n },\n onBlockEnd: () => (updatedFocusDate = moveDown(focusableDate, isDateEnabled)),\n onBlockStart: () => (updatedFocusDate = moveUp(focusableDate, isDateEnabled)),\n onInlineStart: () => (updatedFocusDate = moveLeft(focusableDate, isDateEnabled)),\n onInlineEnd: () => (updatedFocusDate = moveRight(focusableDate, isDateEnabled)),\n });\n\n if (!updatedFocusDate) {\n return;\n }\n\n if (!isSamePage(updatedFocusDate, baseDate)) {\n onChangePage(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n return onGridKeyDownHandler;\n}\n"]}
|
|
@@ -23,7 +23,7 @@ export interface GridProps {
|
|
|
23
23
|
focusedDate: Date | null;
|
|
24
24
|
focusedDateRef: React.RefObject<HTMLTableCellElement>;
|
|
25
25
|
onSelectDate: (date: Date) => void;
|
|
26
|
-
onGridKeyDownHandler: (e: React.KeyboardEvent) => void;
|
|
26
|
+
onGridKeyDownHandler: (e: React.KeyboardEvent<HTMLElement>) => void;
|
|
27
27
|
onFocusedDateChange: React.Dispatch<React.SetStateAction<Date | null>>;
|
|
28
28
|
isDateEnabled: DateRangePickerProps.IsDateEnabledFunction;
|
|
29
29
|
locale: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAcvC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMlE;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAEtD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,oBAAoB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAcvC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMlE;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAEtD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,oBAAoB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACpE,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAEvE,aAAa,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAE1D,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,cAAc,EAEd,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EAEb,MAAM,EACN,WAAW,EACX,cAAc,EACd,cAAc,EAEd,SAAS,GACV,EAAE,SAAS,eAsIX"}
|
|
@@ -79,10 +79,10 @@ export function Grid({ baseDate, selectedStartDate, selectedEndDate, rangeStartD
|
|
|
79
79
|
[styles['range-end-date']]: isRangeEndDate,
|
|
80
80
|
[styles['no-range']]: isSelected && onlyOneSelected,
|
|
81
81
|
[styles['in-range']]: dateIsInRange,
|
|
82
|
-
[styles['in-range-border-
|
|
83
|
-
[styles['in-range-border-
|
|
84
|
-
[styles['in-range-border-
|
|
85
|
-
[styles['in-range-border-
|
|
82
|
+
[styles['in-range-border-block-start']]: !!inRangeStartWeek || date.getDate() <= 7,
|
|
83
|
+
[styles['in-range-border-block-end']]: !!inRangeEndWeek || date.getDate() > getDaysInMonth(date) - 7,
|
|
84
|
+
[styles['in-range-border-inline-start']]: dateIndex === 0 || date.getDate() === 1 || isRangeStartDate,
|
|
85
|
+
[styles['in-range-border-inline-end']]: dateIndex === week.length - 1 || isLastDayOfMonth(date) || isRangeEndDate,
|
|
86
86
|
[styles.today]: isToday(date),
|
|
87
87
|
}), "aria-selected": isEnabled ? isSelected || dateIsInRange : undefined, "aria-current": isToday(date) ? 'date' : undefined, "data-date": formatDate(date), "aria-disabled": !isEnabled, tabIndex: tabIndex }, handlers),
|
|
88
88
|
React.createElement("span", { className: styles['day-inner'], "aria-hidden": "true" }, date.getDate()),
|