@canonical/react-ds-global 0.29.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/esm/lib/_work_in_progress/IconSection/IconSection.js +1 -1
- package/dist/esm/lib/_work_in_progress/IconSection/IconSection.js.map +1 -1
- package/dist/esm/lib/_work_in_progress/index.js +13 -0
- package/dist/esm/lib/_work_in_progress/index.js.map +1 -0
- package/dist/esm/lib/component/Accordion/common/Item/styles.css +19 -50
- package/dist/esm/lib/component/Accordion/styles.css +5 -1
- package/dist/esm/lib/component/Announcement/Announcement.js +5 -3
- package/dist/esm/lib/component/Announcement/Announcement.js.map +1 -1
- package/dist/esm/lib/component/Announcement/index.js +1 -0
- package/dist/esm/lib/component/Announcement/index.js.map +1 -1
- package/dist/esm/lib/component/Announcement/styles.css +60 -36
- package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js +1 -1
- package/dist/esm/lib/component/Breadcrumbs/common/Item/Item.js.map +1 -1
- package/dist/esm/lib/component/Button/Button.js +13 -5
- package/dist/esm/lib/component/Button/Button.js.map +1 -1
- package/dist/esm/lib/component/Button/styles.css +135 -39
- package/dist/esm/lib/component/Card/Card.js +9 -6
- package/dist/esm/lib/component/Card/Card.js.map +1 -1
- package/dist/esm/lib/component/Card/common/Content/styles.css +1 -1
- package/dist/esm/lib/component/Card/common/Footer/Footer.js +1 -1
- package/dist/esm/lib/component/Card/common/Footer/styles.css +1 -1
- package/dist/esm/lib/component/Card/common/Header/styles.css +1 -1
- package/dist/esm/lib/component/Card/common/index.js +0 -1
- package/dist/esm/lib/component/Card/common/index.js.map +1 -1
- package/dist/esm/lib/component/Card/styles.css +8 -8
- package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js +94 -0
- package/dist/esm/lib/component/ContextualMenu/ContextualMenu.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js +32 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/Item.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/index.js +2 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/index.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/styles.css +93 -0
- package/dist/esm/lib/component/ContextualMenu/common/Item/types.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/MenuContext.js +12 -0
- package/dist/esm/lib/component/ContextualMenu/common/MenuContext.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js +109 -0
- package/dist/esm/lib/component/ContextualMenu/common/SubMenu/SubMenu.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/common/SubMenu/index.js +2 -0
- package/dist/esm/lib/component/ContextualMenu/common/SubMenu/index.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/index.js +2 -0
- package/dist/esm/lib/component/ContextualMenu/index.js.map +1 -0
- package/dist/esm/lib/component/ContextualMenu/styles.css +86 -0
- package/dist/esm/lib/component/ContextualMenu/types.js.map +1 -0
- package/dist/esm/lib/component/Popover/Popover.js +50 -0
- package/dist/esm/lib/component/Popover/Popover.js.map +1 -0
- package/dist/esm/lib/component/Popover/index.js +2 -0
- package/dist/esm/lib/component/Popover/index.js.map +1 -0
- package/dist/esm/lib/component/Popover/styles.css +65 -0
- package/dist/esm/lib/component/Popover/types.js +2 -0
- package/dist/esm/lib/component/Popover/types.js.map +1 -0
- package/dist/esm/lib/component/Tabs/Tabs.js +27 -0
- package/dist/esm/lib/component/Tabs/Tabs.js.map +1 -0
- package/dist/esm/lib/component/Tabs/common/Item/Item.js +20 -0
- package/dist/esm/lib/component/Tabs/common/Item/Item.js.map +1 -0
- package/dist/esm/lib/component/Tabs/common/Item/index.js +3 -0
- package/dist/esm/lib/component/Tabs/common/Item/index.js.map +1 -0
- package/dist/esm/lib/component/Tabs/common/Item/styles.css +75 -0
- package/dist/esm/lib/component/Tabs/common/Item/types.js +2 -0
- package/dist/esm/lib/component/Tabs/common/Item/types.js.map +1 -0
- package/dist/esm/lib/component/Tabs/common/index.js +2 -0
- package/dist/esm/lib/component/Tabs/common/index.js.map +1 -0
- package/dist/esm/lib/component/Tabs/index.js +3 -0
- package/dist/esm/lib/component/Tabs/index.js.map +1 -0
- package/dist/esm/lib/component/Tabs/styles.css +37 -0
- package/dist/esm/lib/component/Tabs/types.js +2 -0
- package/dist/esm/lib/component/Tabs/types.js.map +1 -0
- package/dist/esm/lib/component/Tile/Tile.js +6 -1
- package/dist/esm/lib/component/Tile/Tile.js.map +1 -1
- package/dist/esm/lib/component/Tile/common/Content/styles.css +17 -8
- package/dist/esm/lib/component/Tile/common/Header/styles.css +15 -12
- package/dist/esm/lib/component/Tile/styles.css +19 -53
- package/dist/esm/lib/component/Tooltip/Tooltip.js +6 -4
- package/dist/esm/lib/component/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js +47 -25
- package/dist/esm/lib/component/Tooltip/common/TooltipArea/TooltipArea.js.map +1 -1
- package/dist/esm/lib/component/Tooltip/styles.css +146 -81
- package/dist/esm/lib/component/Tooltip/withTooltip.js +3 -3
- package/dist/esm/lib/component/Tooltip/withTooltip.js.map +1 -1
- package/dist/esm/lib/component/index.js +17 -0
- package/dist/esm/lib/component/index.js.map +1 -0
- package/dist/esm/lib/group/index.js +3 -0
- package/dist/esm/lib/group/index.js.map +1 -0
- package/dist/esm/lib/hooks/index.js +2 -1
- package/dist/esm/lib/hooks/index.js.map +1 -1
- package/dist/esm/lib/hooks/useContextualMenu/index.js +3 -0
- package/dist/esm/lib/hooks/useContextualMenu/index.js.map +1 -0
- package/dist/esm/lib/hooks/useContextualMenu/types.js +2 -0
- package/dist/esm/lib/hooks/useContextualMenu/types.js.map +1 -0
- package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js +175 -0
- package/dist/esm/lib/hooks/useContextualMenu/useContextualMenu.js.map +1 -0
- package/dist/esm/lib/hooks/useDisclosure/index.js +3 -0
- package/dist/esm/lib/hooks/useDisclosure/index.js.map +1 -0
- package/dist/esm/lib/hooks/useDisclosure/types.js +2 -0
- package/dist/esm/lib/hooks/useDisclosure/types.js.map +1 -0
- package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js +230 -0
- package/dist/esm/lib/hooks/useDisclosure/useDisclosure.js.map +1 -0
- package/dist/esm/lib/hooks/useResizeObserver/useResizeObserver.js +37 -7
- package/dist/esm/lib/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
- package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js +9 -0
- package/dist/esm/lib/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -1
- package/dist/esm/lib/hooks/useWindowFitment/index.js +1 -0
- package/dist/esm/lib/hooks/useWindowFitment/index.js.map +1 -1
- package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js +25 -0
- package/dist/esm/lib/hooks/useWindowFitment/readingDirection.js.map +1 -0
- package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js +211 -21
- package/dist/esm/lib/hooks/useWindowFitment/useWindowFitment.js.map +1 -1
- package/dist/esm/lib/index.js +8 -25
- package/dist/esm/lib/index.js.map +1 -1
- package/dist/esm/lib/pattern/index.js +3 -0
- package/dist/esm/lib/pattern/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/Spinner/Spinner.js +35 -0
- package/dist/esm/lib/subcomponent/Spinner/Spinner.js.map +1 -0
- package/dist/esm/lib/subcomponent/Spinner/index.js +2 -0
- package/dist/esm/lib/subcomponent/Spinner/index.js.map +1 -0
- package/dist/esm/lib/subcomponent/Spinner/styles.css +50 -0
- package/dist/esm/lib/subcomponent/Spinner/types.js +2 -0
- package/dist/esm/lib/subcomponent/Spinner/types.js.map +1 -0
- package/dist/esm/lib/subcomponent/index.js +3 -0
- package/dist/esm/lib/subcomponent/index.js.map +1 -0
- package/dist/esm/lib/types/link.js +2 -0
- package/dist/esm/lib/types/link.js.map +1 -0
- package/dist/types/lib/_work_in_progress/Link/types.d.ts +1 -1
- package/dist/types/lib/_work_in_progress/Link/types.d.ts.map +1 -1
- package/dist/types/lib/_work_in_progress/index.d.ts +12 -0
- package/dist/types/lib/_work_in_progress/index.d.ts.map +1 -0
- package/dist/types/lib/component/Announcement/Announcement.d.ts +2 -2
- package/dist/types/lib/component/Announcement/Announcement.d.ts.map +1 -1
- package/dist/types/lib/component/Announcement/index.d.ts.map +1 -1
- package/dist/types/lib/component/Announcement/types.d.ts +17 -6
- package/dist/types/lib/component/Announcement/types.d.ts.map +1 -1
- package/dist/types/lib/component/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/types/lib/component/Breadcrumbs/common/Item/Item.d.ts +1 -1
- package/dist/types/lib/component/Breadcrumbs/common/Item/Item.d.ts.map +1 -1
- package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts +8 -13
- package/dist/types/lib/component/Breadcrumbs/common/Item/types.d.ts.map +1 -1
- package/dist/types/lib/component/Breadcrumbs/types.d.ts +8 -1
- package/dist/types/lib/component/Breadcrumbs/types.d.ts.map +1 -1
- package/dist/types/lib/component/Button/Button.d.ts +3 -1
- package/dist/types/lib/component/Button/Button.d.ts.map +1 -1
- package/dist/types/lib/component/Button/types.d.ts +8 -4
- package/dist/types/lib/component/Button/types.d.ts.map +1 -1
- package/dist/types/lib/component/Card/Card.d.ts +3 -5
- package/dist/types/lib/component/Card/Card.d.ts.map +1 -1
- package/dist/types/lib/component/Card/common/Footer/Footer.d.ts +1 -1
- package/dist/types/lib/component/Card/common/Footer/types.d.ts +1 -1
- package/dist/types/lib/component/Card/common/index.d.ts +0 -1
- package/dist/types/lib/component/Card/common/index.d.ts.map +1 -1
- package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts +15 -0
- package/dist/types/lib/component/ContextualMenu/ContextualMenu.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts +14 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/Item.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/index.d.ts +3 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/index.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/types.d.ts +11 -0
- package/dist/types/lib/component/ContextualMenu/common/Item/types.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts +19 -0
- package/dist/types/lib/component/ContextualMenu/common/MenuContext.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts +15 -0
- package/dist/types/lib/component/ContextualMenu/common/SubMenu/SubMenu.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/common/SubMenu/index.d.ts +2 -0
- package/dist/types/lib/component/ContextualMenu/common/SubMenu/index.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/index.d.ts +3 -0
- package/dist/types/lib/component/ContextualMenu/index.d.ts.map +1 -0
- package/dist/types/lib/component/ContextualMenu/types.d.ts +30 -0
- package/dist/types/lib/component/ContextualMenu/types.d.ts.map +1 -0
- package/dist/types/lib/component/Popover/Popover.d.ts +16 -0
- package/dist/types/lib/component/Popover/Popover.d.ts.map +1 -0
- package/dist/types/lib/component/Popover/index.d.ts +3 -0
- package/dist/types/lib/component/Popover/index.d.ts.map +1 -0
- package/dist/types/lib/component/Popover/types.d.ts +24 -0
- package/dist/types/lib/component/Popover/types.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/Tabs.d.ts +18 -0
- package/dist/types/lib/component/Tabs/Tabs.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/common/Item/Item.d.ts +15 -0
- package/dist/types/lib/component/Tabs/common/Item/Item.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/common/Item/index.d.ts +3 -0
- package/dist/types/lib/component/Tabs/common/Item/index.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/common/Item/types.d.ts +18 -0
- package/dist/types/lib/component/Tabs/common/Item/types.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/common/index.d.ts +2 -0
- package/dist/types/lib/component/Tabs/common/index.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/index.d.ts +3 -0
- package/dist/types/lib/component/Tabs/index.d.ts.map +1 -0
- package/dist/types/lib/component/Tabs/types.d.ts +46 -0
- package/dist/types/lib/component/Tabs/types.d.ts.map +1 -0
- package/dist/types/lib/component/Tile/Tile.d.ts +2 -0
- package/dist/types/lib/component/Tile/Tile.d.ts.map +1 -1
- package/dist/types/lib/component/Tile/common/Content/types.d.ts +1 -1
- package/dist/types/lib/component/Tile/common/Header/types.d.ts +1 -1
- package/dist/types/lib/component/Tile/types.d.ts +4 -5
- package/dist/types/lib/component/Tile/types.d.ts.map +1 -1
- package/dist/types/lib/component/Tooltip/Tooltip.d.ts +1 -1
- package/dist/types/lib/component/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts +2 -2
- package/dist/types/lib/component/Tooltip/common/TooltipArea/TooltipArea.d.ts.map +1 -1
- package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts +14 -2
- package/dist/types/lib/component/Tooltip/common/TooltipArea/types.d.ts.map +1 -1
- package/dist/types/lib/component/Tooltip/types.d.ts +6 -0
- package/dist/types/lib/component/Tooltip/types.d.ts.map +1 -1
- package/dist/types/lib/component/Tooltip/withTooltip.d.ts +10 -3
- package/dist/types/lib/component/Tooltip/withTooltip.d.ts.map +1 -1
- package/dist/types/lib/component/index.d.ts +16 -0
- package/dist/types/lib/component/index.d.ts.map +1 -0
- package/dist/types/lib/group/index.d.ts +2 -0
- package/dist/types/lib/group/index.d.ts.map +1 -0
- package/dist/types/lib/hooks/index.d.ts +2 -1
- package/dist/types/lib/hooks/index.d.ts.map +1 -1
- package/dist/types/lib/hooks/useContextualMenu/index.d.ts +3 -0
- package/dist/types/lib/hooks/useContextualMenu/index.d.ts.map +1 -0
- package/dist/types/lib/hooks/useContextualMenu/types.d.ts +71 -0
- package/dist/types/lib/hooks/useContextualMenu/types.d.ts.map +1 -0
- package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts +20 -0
- package/dist/types/lib/hooks/useContextualMenu/useContextualMenu.d.ts.map +1 -0
- package/dist/types/lib/hooks/useDisclosure/index.d.ts +3 -0
- package/dist/types/lib/hooks/useDisclosure/index.d.ts.map +1 -0
- package/dist/types/lib/hooks/useDisclosure/types.d.ts +103 -0
- package/dist/types/lib/hooks/useDisclosure/types.d.ts.map +1 -0
- package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts +32 -0
- package/dist/types/lib/hooks/useDisclosure/useDisclosure.d.ts.map +1 -0
- package/dist/types/lib/hooks/useResizeObserver/useResizeObserver.d.ts +6 -0
- package/dist/types/lib/hooks/useResizeObserver/useResizeObserver.d.ts.map +1 -1
- package/dist/types/lib/hooks/useWindowDimensions/useWindowDimensions.d.ts.map +1 -1
- package/dist/types/lib/hooks/useWindowFitment/index.d.ts +1 -0
- package/dist/types/lib/hooks/useWindowFitment/index.d.ts.map +1 -1
- package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts +14 -0
- package/dist/types/lib/hooks/useWindowFitment/readingDirection.d.ts.map +1 -0
- package/dist/types/lib/hooks/useWindowFitment/types.d.ts +75 -4
- package/dist/types/lib/hooks/useWindowFitment/types.d.ts.map +1 -1
- package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts +44 -2
- package/dist/types/lib/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +5 -25
- package/dist/types/lib/index.d.ts.map +1 -1
- package/dist/types/lib/pattern/index.d.ts +2 -0
- package/dist/types/lib/pattern/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/Spinner/Spinner.d.ts +24 -0
- package/dist/types/lib/subcomponent/Spinner/Spinner.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/Spinner/index.d.ts +3 -0
- package/dist/types/lib/subcomponent/Spinner/index.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/Spinner/types.d.ts +17 -0
- package/dist/types/lib/subcomponent/Spinner/types.d.ts.map +1 -0
- package/dist/types/lib/subcomponent/index.d.ts +2 -0
- package/dist/types/lib/subcomponent/index.d.ts.map +1 -0
- package/dist/types/lib/types/index.d.ts +1 -0
- package/dist/types/lib/types/index.d.ts.map +1 -1
- package/dist/types/lib/types/link.d.ts +26 -0
- package/dist/types/lib/types/link.d.ts.map +1 -0
- package/package.json +16 -19
- package/dist/esm/lib/component/Card/common/Thumbnail/Thumbnail.js +0 -21
- package/dist/esm/lib/component/Card/common/Thumbnail/Thumbnail.js.map +0 -1
- package/dist/esm/lib/component/Card/common/Thumbnail/index.js +0 -2
- package/dist/esm/lib/component/Card/common/Thumbnail/index.js.map +0 -1
- package/dist/esm/lib/component/Card/common/Thumbnail/styles.css +0 -39
- package/dist/esm/lib/component/Card/common/Thumbnail/types.js.map +0 -1
- package/dist/esm/lib/hooks/usePopup/index.js +0 -3
- package/dist/esm/lib/hooks/usePopup/index.js.map +0 -1
- package/dist/esm/lib/hooks/usePopup/types.js.map +0 -1
- package/dist/esm/lib/hooks/usePopup/usePopup.js +0 -93
- package/dist/esm/lib/hooks/usePopup/usePopup.js.map +0 -1
- package/dist/esm/storybook/decorators.js +0 -16
- package/dist/esm/storybook/decorators.js.map +0 -1
- package/dist/types/lib/component/Card/common/Thumbnail/Thumbnail.d.ts +0 -23
- package/dist/types/lib/component/Card/common/Thumbnail/Thumbnail.d.ts.map +0 -1
- package/dist/types/lib/component/Card/common/Thumbnail/index.d.ts +0 -3
- package/dist/types/lib/component/Card/common/Thumbnail/index.d.ts.map +0 -1
- package/dist/types/lib/component/Card/common/Thumbnail/types.d.ts +0 -27
- package/dist/types/lib/component/Card/common/Thumbnail/types.d.ts.map +0 -1
- package/dist/types/lib/hooks/usePopup/index.d.ts +0 -3
- package/dist/types/lib/hooks/usePopup/index.d.ts.map +0 -1
- package/dist/types/lib/hooks/usePopup/types.d.ts +0 -65
- package/dist/types/lib/hooks/usePopup/types.d.ts.map +0 -1
- package/dist/types/lib/hooks/usePopup/usePopup.d.ts +0 -19
- package/dist/types/lib/hooks/usePopup/usePopup.d.ts.map +0 -1
- package/dist/types/storybook/decorators.d.ts +0 -15
- package/dist/types/storybook/decorators.d.ts.map +0 -1
- /package/dist/esm/lib/component/{Card/common/Thumbnail → ContextualMenu/common/Item}/types.js +0 -0
- /package/dist/esm/lib/{hooks/usePopup → component/ContextualMenu}/types.js +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getItemId } from "@canonical/utils";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { MENU_PLACEMENT, useWindowFitment } from "../../../../hooks/index.js";
|
|
6
|
+
import Item from "../Item/index.js";
|
|
7
|
+
import { useMenuContext } from "../MenuContext.js";
|
|
8
|
+
/**
|
|
9
|
+
* One node in a (possibly nested) contextual menu. A leaf renders a plain item;
|
|
10
|
+
* a submenu parent renders the item plus a positioned nested popup for its
|
|
11
|
+
* children (see {@link SubMenuParent}). The hook that positions the popup runs
|
|
12
|
+
* ONLY for submenu parents — leaves render a bare item — so a menu of leaves
|
|
13
|
+
* spins up no positioning machinery.
|
|
14
|
+
*/
|
|
15
|
+
const SubMenu = ({ item }) => {
|
|
16
|
+
const { getItemProps, onSelectItem } = useMenuContext();
|
|
17
|
+
if (item.items?.length) {
|
|
18
|
+
return _jsx(SubMenuParent, { item: item });
|
|
19
|
+
}
|
|
20
|
+
return (_jsx(Item, { item: item, itemProps: getItemProps(item), onSelect: () => onSelectItem(item) }));
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A submenu parent: the item plus its nested `role="menu"` popup. All nodes
|
|
24
|
+
* share the ONE menu state from {@link useMenuContext}; this component only
|
|
25
|
+
* decides the submenu's visibility and position. The submenu is shown when the
|
|
26
|
+
* keyboard path descends through this parent
|
|
27
|
+
* (`getNodeStatus(item).inHighlightedBranch`) or the parent is hovered, and is
|
|
28
|
+
* positioned by its own {@link useWindowFitment} anchored to the parent item —
|
|
29
|
+
* opening to the reading-direction leading edge, top-aligned, flipping side and
|
|
30
|
+
* alignment as space runs out.
|
|
31
|
+
*/
|
|
32
|
+
const SubMenuParent = ({ item }) => {
|
|
33
|
+
const { getItemProps, getMenuProps, getNodeStatus, onSelectItem } = useMenuContext();
|
|
34
|
+
const children = item.items ?? [];
|
|
35
|
+
const status = getNodeStatus(item);
|
|
36
|
+
// The submenu is keyboard-open when the highlight is in a DESCENDANT of this
|
|
37
|
+
// parent — not when the parent itself is the highlighted item. `inHighlighted
|
|
38
|
+
// Branch` is true in both cases, so subtract `highlighted`: otherwise ArrowLeft
|
|
39
|
+
// (which moves the highlight back onto the parent) would leave the submenu open.
|
|
40
|
+
const keyboardOpen = status.inHighlightedBranch && !status.highlighted;
|
|
41
|
+
const [hovered, setHovered] = useState(false);
|
|
42
|
+
const open = keyboardOpen || hovered;
|
|
43
|
+
// MENU_PLACEMENT is a stable module constant and logical, so the hook mirrors
|
|
44
|
+
// it in RTL from this item's own writing direction — no per-submenu dir read.
|
|
45
|
+
const { targetRef, popupRef, popupPositionStyle, bestPosition } = useWindowFitment({ preferredDirections: MENU_PLACEMENT, autoFit: true });
|
|
46
|
+
// The item carries both the roving props and the fitment target ref. The
|
|
47
|
+
// tree's getItemProps already returns a `ref` (it registers the node for
|
|
48
|
+
// roving focus); COMPOSE ours with it rather than replacing it, or the
|
|
49
|
+
// submenu parent loses its focus registration.
|
|
50
|
+
const baseItemProps = getItemProps(item);
|
|
51
|
+
const navRef = baseItemProps.ref;
|
|
52
|
+
const itemProps = {
|
|
53
|
+
...baseItemProps,
|
|
54
|
+
ref: (node) => {
|
|
55
|
+
targetRef.current = node;
|
|
56
|
+
if (typeof navRef === "function")
|
|
57
|
+
navRef(node);
|
|
58
|
+
else if (navRef)
|
|
59
|
+
navRef.current = node;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
// On keyboard open, move focus to the submenu's roving tab stop (the newly
|
|
63
|
+
// highlighted child the tree already set tabindex=0 on).
|
|
64
|
+
// @note Impure — moves DOM focus.
|
|
65
|
+
const surfaceRef = useRef(null);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!open || !keyboardOpen || typeof window === "undefined")
|
|
68
|
+
return;
|
|
69
|
+
const surface = surfaceRef.current;
|
|
70
|
+
if (!surface)
|
|
71
|
+
return;
|
|
72
|
+
const id = requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
73
|
+
surface
|
|
74
|
+
.querySelector('[role="menuitem"][tabindex="0"]')
|
|
75
|
+
?.focus();
|
|
76
|
+
}));
|
|
77
|
+
return () => cancelAnimationFrame(id);
|
|
78
|
+
}, [open, keyboardOpen]);
|
|
79
|
+
const menuProps = getMenuProps({
|
|
80
|
+
label: item.label,
|
|
81
|
+
ref: popupRef,
|
|
82
|
+
});
|
|
83
|
+
// Render the popup ONLY while open. A closed submenu mounts no popup, so its
|
|
84
|
+
// `popupRef` stays null and `useWindowFitment` measures nothing — no
|
|
85
|
+
// ResizeObserver, no reposition, and crucially no measure→reposition→measure
|
|
86
|
+
// feedback across a tree of always-mounted hidden popups (which froze the UI).
|
|
87
|
+
const submenuSurface = open ? (_jsx("div", { className: [
|
|
88
|
+
"ds",
|
|
89
|
+
"contextual-menu__surface",
|
|
90
|
+
"submenu",
|
|
91
|
+
"modal",
|
|
92
|
+
bestPosition?.positionName,
|
|
93
|
+
]
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.join(" "), "aria-hidden": false, "data-positioned": bestPosition ? "true" : undefined, style: popupPositionStyle, ref: (el) => {
|
|
96
|
+
surfaceRef.current = el;
|
|
97
|
+
if (typeof menuProps.ref === "function")
|
|
98
|
+
menuProps.ref(el);
|
|
99
|
+
else if (menuProps.ref)
|
|
100
|
+
menuProps.ref.current = el;
|
|
101
|
+
}, ...menuProps, children: children.map((child) => (
|
|
102
|
+
// Recurse: a submenu child may itself be a submenu parent.
|
|
103
|
+
_jsx(SubMenu, { item: child }, getItemId(child)))) })) : null;
|
|
104
|
+
return (_jsxs("div", { className: "submenu-anchor", onPointerEnter: () => setHovered(true), onPointerLeave: () => setHovered(false), children: [_jsx(Item, { item: item, itemProps: itemProps, onSelect: () => onSelectItem(item) }), submenuSurface && typeof window !== "undefined"
|
|
105
|
+
? createPortal(submenuSurface, document.body)
|
|
106
|
+
: null] }));
|
|
107
|
+
};
|
|
108
|
+
export default SubMenu;
|
|
109
|
+
//# sourceMappingURL=SubMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubMenu.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/SubMenu/SubMenu.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/ContextualMenu/common/SubMenu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/component/ContextualMenu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* Component tokens — sourced from @canonical/design-tokens.
|
|
2
|
+
Mapped strictly to the Figma "Contextual Menu" frame: white background
|
|
3
|
+
(color-background) on the modal surface, a drop shadow (no border), and a
|
|
4
|
+
muted 1px divider between groups. */
|
|
5
|
+
:root {
|
|
6
|
+
--contextual-menu-color-divider: var(--color-border-muted);
|
|
7
|
+
--contextual-menu-divider-width: var(--dimension-stroke-thickness-medium);
|
|
8
|
+
--contextual-menu-min-width: 12rem;
|
|
9
|
+
--contextual-menu-max-width: 20rem;
|
|
10
|
+
/* Three-layer drop shadow from the Figma effect. */
|
|
11
|
+
--contextual-menu-shadow:
|
|
12
|
+
0 1px 1px 0 rgba(0, 0, 0, 0.15), 0 2px 2px -1px rgba(0, 0, 0, 0.15),
|
|
13
|
+
0 0 3px 0 rgba(0, 0, 0, 0.2);
|
|
14
|
+
--contextual-menu-motion-duration: 0.12s;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ds.contextual-menu {
|
|
18
|
+
display: inline-block;
|
|
19
|
+
|
|
20
|
+
> .trigger {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.ds.contextual-menu__surface {
|
|
26
|
+
position: fixed;
|
|
27
|
+
z-index: var(--z-index-overlay, 100);
|
|
28
|
+
min-width: var(--contextual-menu-min-width);
|
|
29
|
+
max-width: var(--contextual-menu-max-width);
|
|
30
|
+
/* A menu (or submenu) taller than the viewport scrolls INSIDE itself instead
|
|
31
|
+
of overflowing off-screen — otherwise keyboard-navigating to an item below
|
|
32
|
+
the fold would move the highlight to an item that is not visible. The
|
|
33
|
+
highlighted item is scrolled into view on keyboard nav (see Item). */
|
|
34
|
+
max-block-size: calc(100dvh - 2 * var(--dimension-200, 16px));
|
|
35
|
+
overflow-y: auto;
|
|
36
|
+
overscroll-behavior: contain;
|
|
37
|
+
/* Read the surface channel directly on this element so the `.modal` surface
|
|
38
|
+
applied here resolves (a :root intermediate would see it unset). */
|
|
39
|
+
background-color: var(--surface-color-background, var(--color-background));
|
|
40
|
+
box-shadow: var(--contextual-menu-shadow);
|
|
41
|
+
|
|
42
|
+
/* CSS-only enter/exit animation. */
|
|
43
|
+
opacity: 0;
|
|
44
|
+
visibility: hidden;
|
|
45
|
+
transition:
|
|
46
|
+
opacity var(--contextual-menu-motion-duration) ease-in-out,
|
|
47
|
+
visibility var(--contextual-menu-motion-duration) allow-discrete;
|
|
48
|
+
|
|
49
|
+
&[aria-hidden="false"] {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
visibility: visible;
|
|
52
|
+
|
|
53
|
+
@starting-style {
|
|
54
|
+
opacity: 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* A submenu mounts on open but is positioned a frame later; keep it hidden
|
|
59
|
+
until `data-positioned` so it never paints at the fallback top:0/left:0. */
|
|
60
|
+
&.submenu[aria-hidden="false"]:not([data-positioned="true"]) {
|
|
61
|
+
opacity: 0;
|
|
62
|
+
visibility: hidden;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@media (prefers-reduced-motion: reduce) {
|
|
66
|
+
transition: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Every group reserves a 1px top border so group heights never shift when a
|
|
70
|
+
divider is / isn't drawn (no layout drift). It is transparent by default and
|
|
71
|
+
only coloured between groups, where the muted divider is wanted (Figma:
|
|
72
|
+
group border-top, color-border-muted, stroke-thickness-medium). */
|
|
73
|
+
.group {
|
|
74
|
+
border-block-start: var(--contextual-menu-divider-width, 1px) solid
|
|
75
|
+
transparent;
|
|
76
|
+
}
|
|
77
|
+
.group + .group {
|
|
78
|
+
border-block-start-color: var(--contextual-menu-color-divider);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* The submenu-anchor wraps a submenu-parent item for hover detection; it must
|
|
82
|
+
not disturb the vertical item flow, so it lays out like the item it wraps. */
|
|
83
|
+
.submenu-anchor {
|
|
84
|
+
display: block;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/component/ContextualMenu/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { OVERLAY_PLACEMENT, useDisclosure } from "../../hooks/index.js";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
// The popover content sits on the `contrasted` surface so it stands out from
|
|
6
|
+
// the page behind it (dark chip on a light UI, light on a dark UI).
|
|
7
|
+
const componentCssClassName = "ds popover";
|
|
8
|
+
const contentSurfaceClassName = "contrasted";
|
|
9
|
+
/**
|
|
10
|
+
* A popover reveals supplementary content anchored to a trigger. It renders as a
|
|
11
|
+
* native `<details>`/`<summary>` so the toggle works without JavaScript; once
|
|
12
|
+
* hydrated, positioning, outside-click and Escape dismissal are layered on via
|
|
13
|
+
* the disclosure hook.
|
|
14
|
+
*
|
|
15
|
+
* `import { Popover } from "@canonical/react-ds-global";`
|
|
16
|
+
*
|
|
17
|
+
* @implements dso:global.component.popover
|
|
18
|
+
*/
|
|
19
|
+
const Popover = ({ trigger, children, className, open, onOpenChange, preferredDirections, distance, gutter, maxWidth, autoFit, closeOnEscape, closeOnOutsideClick, ...props }) => {
|
|
20
|
+
const { isOpen, targetRef, popupRef, popupPositionStyle, popupId, bestPosition, getToggleProps, getContentProps, } = useDisclosure({
|
|
21
|
+
mode: "click",
|
|
22
|
+
isOpen: open,
|
|
23
|
+
// Auto-fit by default, opening toward the reading direction first.
|
|
24
|
+
// OVERLAY_PLACEMENT is logical (inline-*), so the hook mirrors it in RTL.
|
|
25
|
+
preferredDirections: preferredDirections ?? OVERLAY_PLACEMENT,
|
|
26
|
+
distance,
|
|
27
|
+
gutter,
|
|
28
|
+
maxWidth,
|
|
29
|
+
autoFit: autoFit ?? true,
|
|
30
|
+
closeOnEscape,
|
|
31
|
+
closeOnOutsideClick,
|
|
32
|
+
onShow: () => onOpenChange?.(true),
|
|
33
|
+
onHide: () => onOpenChange?.(false),
|
|
34
|
+
});
|
|
35
|
+
const toggleProps = getToggleProps();
|
|
36
|
+
const contentProps = getContentProps();
|
|
37
|
+
// Once hydrated, the disclosure hook owns the toggle: intercept the summary
|
|
38
|
+
// click so the native <details> toggle does not fight the hook, and drive the
|
|
39
|
+
// open state from the hook instead. Without JS, the native toggle is the
|
|
40
|
+
// baseline and this handler never runs.
|
|
41
|
+
const handleSummaryClick = useCallback((event) => {
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
toggleProps.onClick?.(event);
|
|
44
|
+
}, [toggleProps]);
|
|
45
|
+
return (_jsxs("details", { className: [componentCssClassName, bestPosition?.positionName, className]
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(" "), open: isOpen, ref: targetRef, ...props, children: [_jsx("summary", { className: "trigger", "aria-controls": toggleProps["aria-controls"], onClick: handleSummaryClick, onKeyDown: toggleProps.onKeyDown, children: trigger }), _jsx("div", { className: ["content", contentSurfaceClassName].join(" "), id: popupId, ref: popupRef, role: "dialog", "aria-hidden": !isOpen, "data-positioned": bestPosition ? "true" : undefined, style: popupPositionStyle, onPointerEnter: contentProps.onPointerEnter, children: children })] }));
|
|
48
|
+
};
|
|
49
|
+
export default Popover;
|
|
50
|
+
//# sourceMappingURL=Popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../../../../src/lib/component/Popover/Popover.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,oEAAoE;AACpE,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAC3C,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,CAAC,EACf,OAAO,EACP,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,aAAa,EACb,mBAAmB,EACnB,GAAG,KAAK,EACK,EAAsB,EAAE;IACrC,MAAM,EACJ,MAAM,EACN,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,GAAG,aAAa,CAAC;QAChB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,IAAI;QACZ,mEAAmE;QACnE,0EAA0E;QAC1E,mBAAmB,EAAE,mBAAmB,IAAI,iBAAiB;QAC7D,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,OAAO,EAAE,OAAO,IAAI,IAAI;QACxB,aAAa;QACb,mBAAmB;QACnB,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC;QAClC,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC;KACpC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IAEvC,4EAA4E;IAC5E,8EAA8E;IAC9E,yEAAyE;IACzE,wCAAwC;IACxC,MAAM,kBAAkB,GAAG,WAAW,CACpC,CAAC,KAAuB,EAAE,EAAE;QAC1B,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,OAAO,CACL,mBACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC;aACtE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,EACZ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,SAA0C,KAC3C,KAAK,aAGT,kBACE,SAAS,EAAC,SAAS,mBAGJ,WAAW,CAAC,eAAe,CAAC,EAC3C,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,WAAW,CAAC,SAAS,YAE/B,OAAO,GACA,EACV,cACE,SAAS,EAAE,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EACzD,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,QAAQ,EACb,IAAI,EAAC,QAAQ,iBAEA,CAAC,MAAM,qBAMH,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAClD,KAAK,EAAE,kBAAkB,EACzB,cAAc,EAAE,YAAY,CAAC,cAAc,YAE1C,QAAQ,GACL,IACE,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/component/Popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* Component tokens — sourced from @canonical/design-tokens */
|
|
2
|
+
:root {
|
|
3
|
+
--popover-color-border: var(--color-border);
|
|
4
|
+
--popover-border-radius: 0;
|
|
5
|
+
--popover-border-width: 1px;
|
|
6
|
+
--popover-padding-vertical: var(--dimension-100);
|
|
7
|
+
--popover-padding-horizontal: var(--dimension-200);
|
|
8
|
+
--popover-motion-duration: 0.12s;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.ds.popover {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: inline-block;
|
|
14
|
+
|
|
15
|
+
> .trigger {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
list-style: none;
|
|
18
|
+
|
|
19
|
+
/* Remove the native disclosure triangle; the trigger content owns the affordance. */
|
|
20
|
+
&::-webkit-details-marker {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
> .content {
|
|
26
|
+
position: fixed;
|
|
27
|
+
z-index: var(--z-index-overlay, 100);
|
|
28
|
+
/* Read the surface channels directly on .content so the `.contrasted`
|
|
29
|
+
surface applied to this element resolves (a :root intermediate would see
|
|
30
|
+
them unset and fall back to the base colours). */
|
|
31
|
+
background-color: var(--surface-color-background, var(--color-background));
|
|
32
|
+
color: var(--surface-color-text, var(--color-text));
|
|
33
|
+
border: var(--popover-border-width, 1px) solid var(--popover-color-border);
|
|
34
|
+
border-radius: var(--popover-border-radius);
|
|
35
|
+
padding-block: var(--popover-padding-vertical);
|
|
36
|
+
padding-inline: var(--popover-padding-horizontal);
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
CSS-only enter/exit animation. `allow-discrete` transitions `visibility`
|
|
40
|
+
(a discrete property) alongside `opacity`; `@starting-style` supplies the
|
|
41
|
+
opening frame so the fade-in runs. No JavaScript timing.
|
|
42
|
+
*/
|
|
43
|
+
opacity: 0;
|
|
44
|
+
visibility: hidden;
|
|
45
|
+
transition:
|
|
46
|
+
opacity var(--popover-motion-duration) ease-in-out,
|
|
47
|
+
visibility var(--popover-motion-duration) allow-discrete;
|
|
48
|
+
|
|
49
|
+
/* Visible only when open (aria-hidden="false") AND positioned
|
|
50
|
+
(data-positioned) — so the content never paints at the unresolved
|
|
51
|
+
top:0/left:0 fallback, and the fade runs from the anchored position. */
|
|
52
|
+
&[aria-hidden="false"][data-positioned="true"] {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
visibility: visible;
|
|
55
|
+
|
|
56
|
+
@starting-style {
|
|
57
|
+
opacity: 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@media (prefers-reduced-motion: reduce) {
|
|
62
|
+
transition: none;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/component/Popover/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Item } from "./common/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
const componentCssClassName = "ds tabs";
|
|
5
|
+
/**
|
|
6
|
+
* A tabs component organises related content into separate sections, letting
|
|
7
|
+
* users move between them by selecting labelled tab headers. This navigational
|
|
8
|
+
* variant is data-driven: it takes a `navigationRoot` item and renders its
|
|
9
|
+
* direct children as tabs, each a link (via `LinkComponent`, default `"a"`), so
|
|
10
|
+
* tabs are deep-linkable and drive the active section from the URL; the
|
|
11
|
+
* consumer owns what each tab points at.
|
|
12
|
+
*
|
|
13
|
+
* `import { Tabs } from "@canonical/react-ds-global";`
|
|
14
|
+
*
|
|
15
|
+
* @implements dso:global.component.tabs
|
|
16
|
+
*/
|
|
17
|
+
const Tabs = ({ navigationRoot, LinkComponent = "a", currentUrl, className, listClassName, ...props }) => {
|
|
18
|
+
// Only the root's direct children are rendered (the root is a container).
|
|
19
|
+
const items = navigationRoot.items ?? [];
|
|
20
|
+
return (_jsx("nav", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: _jsx("ul", { className: ["tabs-list", listClassName].filter(Boolean).join(" "), children: items.map((item, index) => (_jsx(Item
|
|
21
|
+
// Prefer the item's own identity (key, then url — both meant to be
|
|
22
|
+
// unique); fall back to the positional index so keys stay unique
|
|
23
|
+
// even when two tabs share a label or a label changes.
|
|
24
|
+
, { item: item, active: item.url != null && item.url === currentUrl, LinkComponent: LinkComponent }, item.key ?? item.url ?? index))) }) }));
|
|
25
|
+
};
|
|
26
|
+
export default Tabs;
|
|
27
|
+
//# sourceMappingURL=Tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tabs/Tabs.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,cAAc,EACd,aAAa,GAAG,GAAG,EACnB,UAAU,EACV,SAAS,EACT,aAAa,EACb,GAAG,KAAK,EACE,EAAsB,EAAE;IAClC,0EAA0E;IAC1E,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;IACzC,OAAO,CACL,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAET,aAAI,SAAS,EAAE,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAClE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,KAAC,IAAI;YACH,mEAAmE;YACnE,iEAAiE;YACjE,uDAAuD;gBAEvD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,KAAK,UAAU,EACnD,aAAa,EAAE,aAAa,IAHvB,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,IAAI,KAAK,CAIlC,CACH,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds tabs-item";
|
|
4
|
+
/**
|
|
5
|
+
* Tabs Item — the internal renderer for a single tab. Not a public
|
|
6
|
+
* subcomponent: Tabs iterates `navigationRoot.items` and renders one of these
|
|
7
|
+
* per child.
|
|
8
|
+
*
|
|
9
|
+
* Renders an `<li>` whose content is a link when the item has a `url` (via the
|
|
10
|
+
* `LinkComponent`, default `"a"`) or inert text otherwise — never a button.
|
|
11
|
+
* The active tab is marked `aria-current="page"`.
|
|
12
|
+
*/
|
|
13
|
+
const Item = ({ item, active, LinkComponent, }) => {
|
|
14
|
+
const { url, label, disabled, className } = item;
|
|
15
|
+
const Link = LinkComponent;
|
|
16
|
+
const inert = !url;
|
|
17
|
+
return (_jsx("li", { className: [componentCssClassName, className].filter(Boolean).join(" "), "data-active": active || undefined, "data-inert": inert || undefined, "data-disabled": disabled || undefined, children: url ? (_jsx(Link, { className: "tabs-link", href: disabled ? undefined : url, "aria-current": active ? "page" : undefined, children: label })) : (_jsx("span", { className: "tabs-link", "aria-current": active ? "page" : undefined, children: label })) }));
|
|
18
|
+
};
|
|
19
|
+
export default Item;
|
|
20
|
+
//# sourceMappingURL=Item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/Tabs/common/Item/Item.tsx"],"names":[],"mappings":";AAEA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,IAAI,EACJ,MAAM,EACN,aAAa,GACH,EAAsB,EAAE;IAClC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACjD,MAAM,IAAI,GAAG,aAAa,CAAC;IAC3B,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC;IACnB,OAAO,CACL,aACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,iBAC1D,MAAM,IAAI,SAAS,gBACpB,KAAK,IAAI,SAAS,mBACf,QAAQ,IAAI,SAAS,YAEnC,GAAG,CAAC,CAAC,CAAC,CACL,KAAC,IAAI,IACH,SAAS,EAAC,WAAW,EACrB,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,kBAClB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAExC,KAAK,GACD,CACR,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,WAAW,kBAAe,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,YAClE,KAAK,GACD,CACR,GACE,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/Tabs/common/Item/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tabs Item styles (internal renderer)
|
|
3
|
+
*
|
|
4
|
+
* Figma (node 4388-106316): each tab is text with `--dimension-200` (16px)
|
|
5
|
+
* horizontal padding, no gap to its neighbours. The tab shows a bottom border
|
|
6
|
+
* on hover (muted) and when active (highlighted); an inert tab (no url) is
|
|
7
|
+
* muted with no hover affordance.
|
|
8
|
+
*
|
|
9
|
+
* Baseline grid: the tab box snaps to the typographic baseline grid — its
|
|
10
|
+
* min block-size and vertical padding are whole multiples of --baseline-height
|
|
11
|
+
* (1bU = 8px), so the strip sits on the same grid as surrounding text.
|
|
12
|
+
*/
|
|
13
|
+
:root {
|
|
14
|
+
--tabs-tab-border-width: var(--dimension-strokeThickness-large, 2px);
|
|
15
|
+
--tabs-tab-padding-inline: var(--space-200); /* 16px */
|
|
16
|
+
/* 5bU = 40px tab height on the 8px baseline grid. */
|
|
17
|
+
--tabs-tab-min-block-size: calc(var(--baseline-height) * 5);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ds.tabs-item {
|
|
21
|
+
display: flex;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ds.tabs-item .tabs-link {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
/* Baseline-snapped block size; vertical padding kept to baseline units so the
|
|
29
|
+
label's line box centres on the grid. */
|
|
30
|
+
min-block-size: var(--tabs-tab-min-block-size);
|
|
31
|
+
padding-block: var(--space-100); /* 1bU */
|
|
32
|
+
padding-inline: var(--tabs-tab-padding-inline);
|
|
33
|
+
font: var(--typography-text-primary);
|
|
34
|
+
color: var(--color-text);
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
|
|
38
|
+
/* Transparent underline reserved so the row never shifts when a border
|
|
39
|
+
appears on hover/active. */
|
|
40
|
+
border-bottom: var(--tabs-tab-border-width) solid transparent;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Hover: a muted bottom border hints the tab is navigable, and settles faster
|
|
44
|
+
than the active/selection change (below). Not on the active tab (it already
|
|
45
|
+
shows the highlighted border), nor on inert or disabled tabs (they are not
|
|
46
|
+
interactive). */
|
|
47
|
+
.ds.tabs-item:not([data-active]):not([data-inert]):not([data-disabled])
|
|
48
|
+
.tabs-link:hover {
|
|
49
|
+
border-bottom-color: var(--color-border-muted);
|
|
50
|
+
transition-duration: var(--motion-duration-fast);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Active tab: highlighted underline over the strip's muted baseline. */
|
|
54
|
+
.ds.tabs-item[data-active] .tabs-link,
|
|
55
|
+
.ds.tabs-item .tabs-link[aria-current="page"] {
|
|
56
|
+
border-bottom-color: var(--color-border-highlighted);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Inert (no url) or disabled tabs: muted, non-interactive, no hover
|
|
60
|
+
affordance. */
|
|
61
|
+
.ds.tabs-item[data-inert] .tabs-link,
|
|
62
|
+
.ds.tabs-item[data-disabled] .tabs-link {
|
|
63
|
+
color: var(--color-text-muted);
|
|
64
|
+
cursor: default;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Motion: the border transitions on the medium duration by default; the hover
|
|
68
|
+
rule above overrides it to the faster duration, so hover feedback is snappier
|
|
69
|
+
than the active/selection settle. */
|
|
70
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
71
|
+
.ds.tabs-item .tabs-link {
|
|
72
|
+
transition: border-bottom-color var(--motion-duration-medium)
|
|
73
|
+
var(--motion-easing-standard);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/lib/component/Tabs/common/Item/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/lib/component/Tabs/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tabs/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tabs styles
|
|
3
|
+
* @implements dso:global.component.tabs
|
|
4
|
+
*
|
|
5
|
+
* DSL anatomy mapping:
|
|
6
|
+
* - layout.type: stack, layout.direction: horizontal -> flex row of tabs
|
|
7
|
+
* - edges: tabs-tab (1..*), slot default -> the <li> children of .tabs-list
|
|
8
|
+
*
|
|
9
|
+
* Figma (node 4388-106316): a horizontal strip of tabs with no gap between
|
|
10
|
+
* them, over a full-width muted bottom border; the strip fills its container
|
|
11
|
+
* and scrolls horizontally on overflow.
|
|
12
|
+
*/
|
|
13
|
+
:root {
|
|
14
|
+
--tabs-border-width: var(--dimension-strokeThickness-medium, 1px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.ds.tabs {
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ds.tabs .tabs-list {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: row;
|
|
24
|
+
/* No gap between tabs (Figma). */
|
|
25
|
+
gap: 0;
|
|
26
|
+
margin: 0;
|
|
27
|
+
padding: 0;
|
|
28
|
+
list-style: none;
|
|
29
|
+
|
|
30
|
+
/* Full-width muted baseline; the active tab paints a highlighted segment
|
|
31
|
+
over it (see Tabs.Tab). */
|
|
32
|
+
border-bottom: var(--tabs-border-width) solid var(--color-border-muted);
|
|
33
|
+
|
|
34
|
+
/* Overflow: the strip scrolls horizontally when the tabs exceed the
|
|
35
|
+
container width (Figma "Overflow"). */
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tabs/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Content, Header } from "./common/index.js";
|
|
3
3
|
import "./styles.css";
|
|
4
|
-
|
|
4
|
+
// The Tile always provides a surface: it establishes its own `.surface`
|
|
5
|
+
// context (so its background and foreground channels resolve, and step when
|
|
6
|
+
// nested), unlike the Card which is not a surface.
|
|
7
|
+
const componentCssClassName = "ds tile surface";
|
|
5
8
|
/**
|
|
6
9
|
* The tile component is a flexible surface used to group related information
|
|
7
10
|
* and actions into a single, recognizable unit. It acts as a container that
|
|
8
11
|
* creates a clear boundary between different pieces of content, making complex
|
|
9
12
|
* layouts easier to scan and organize.
|
|
10
13
|
*
|
|
14
|
+
* `import { Tile } from "@canonical/react-ds-global";`
|
|
15
|
+
*
|
|
11
16
|
* @implements ds:global.component.tile
|
|
12
17
|
*/
|
|
13
18
|
const Tile = ({ children, className, ...props }) => (_jsx("div", { className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tile/Tile.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../../../../src/lib/component/Tile/Tile.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,cAAc,CAAC;AAEtB,wEAAwE;AACxE,4EAA4E;AAC5E,mDAAmD;AACnD,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAG,CAAC,EACZ,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACE,EAAsB,EAAE,CAAC,CACnC,cACE,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KACnE,KAAK,YAGR,QAAQ,GACL,CACP,CAAC;AAEF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AAEvB,eAAe,IAAI,CAAC"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tile.Content styles
|
|
3
|
-
* @implements
|
|
3
|
+
* @implements ds:global.subcomponent.tile-content
|
|
4
4
|
*
|
|
5
5
|
* DSL anatomy mapping:
|
|
6
|
-
* - layout.type: stack
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
6
|
+
* - layout.type: stack, layout.direction: vertical -> flex column
|
|
7
|
+
* - spacing.padding.top: dimension/100, spacing.padding.bottom: dimension/200,
|
|
8
|
+
* spacing.internal.horizontal: dimension/200 -> top 100, bottom 200,
|
|
9
|
+
* sides 200. With a header above (padding-bottom 100), the two sections read
|
|
10
|
+
* as top 100 / sides 200 / bottom 200 with the sections meeting in between.
|
|
9
11
|
*/
|
|
12
|
+
:root {
|
|
13
|
+
--tile-content-padding-top: var(--dimension-100);
|
|
14
|
+
--tile-content-padding-bottom: var(--dimension-200);
|
|
15
|
+
--tile-content-padding-inline: var(--dimension-200);
|
|
16
|
+
--tile-content-gap: var(--dimension-100);
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
.ds.tile-content {
|
|
11
|
-
/* layout.type: stack, layout.direction: vertical */
|
|
12
20
|
display: flex;
|
|
13
21
|
flex-direction: column;
|
|
22
|
+
gap: var(--tile-content-gap);
|
|
14
23
|
|
|
15
|
-
|
|
16
|
-
padding: var(--tile-content-padding
|
|
17
|
-
|
|
24
|
+
padding-block-start: var(--tile-content-padding-top);
|
|
25
|
+
padding-block-end: var(--tile-content-padding-bottom);
|
|
26
|
+
padding-inline: var(--tile-content-padding-inline);
|
|
18
27
|
}
|