@canonical/react-ds-global 0.10.0-experimental.8
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 +28 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/index.js +2 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/types/index.js +2 -0
- package/dist/esm/lib/types/index.js.map +1 -0
- package/dist/esm/lib/types/polymorphic.js +2 -0
- package/dist/esm/lib/types/polymorphic.js.map +1 -0
- package/dist/esm/storybook/decorators.js +16 -0
- package/dist/esm/storybook/decorators.js.map +1 -0
- package/dist/esm/ui/Badge/Badge.js +21 -0
- package/dist/esm/ui/Badge/Badge.js.map +1 -0
- package/dist/esm/ui/Badge/hooks/useBadge.js +23 -0
- package/dist/esm/ui/Badge/hooks/useBadge.js.map +1 -0
- package/dist/esm/ui/Badge/index.js +4 -0
- package/dist/esm/ui/Badge/index.js.map +1 -0
- package/dist/esm/ui/Badge/styles.css +21 -0
- package/dist/esm/ui/Badge/types.js +3 -0
- package/dist/esm/ui/Badge/types.js.map +1 -0
- package/dist/esm/ui/Button/Button.js +10 -0
- package/dist/esm/ui/Button/Button.js.map +1 -0
- package/dist/esm/ui/Button/index.js +2 -0
- package/dist/esm/ui/Button/index.js.map +1 -0
- package/dist/esm/ui/Button/styles.css +63 -0
- package/dist/esm/ui/Button/types.js +12 -0
- package/dist/esm/ui/Button/types.js.map +1 -0
- package/dist/esm/ui/Card/Card.js +16 -0
- package/dist/esm/ui/Card/Card.js.map +1 -0
- package/dist/esm/ui/Card/common/Image/Image.js +14 -0
- package/dist/esm/ui/Card/common/Image/Image.js.map +1 -0
- package/dist/esm/ui/Card/common/Image/index.js +2 -0
- package/dist/esm/ui/Card/common/Image/index.js.map +1 -0
- package/dist/esm/ui/Card/common/Image/styles.css +7 -0
- package/dist/esm/ui/Card/common/Image/types.js +3 -0
- package/dist/esm/ui/Card/common/Image/types.js.map +1 -0
- package/dist/esm/ui/Card/common/Section/Section.js +13 -0
- package/dist/esm/ui/Card/common/Section/Section.js.map +1 -0
- package/dist/esm/ui/Card/common/Section/index.js +2 -0
- package/dist/esm/ui/Card/common/Section/index.js.map +1 -0
- package/dist/esm/ui/Card/common/Section/styles.css +6 -0
- package/dist/esm/ui/Card/common/Section/types.js +3 -0
- package/dist/esm/ui/Card/common/Section/types.js.map +1 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/ThumbnailSection.js +14 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/ThumbnailSection.js.map +1 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/index.js +2 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/index.js.map +1 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/styles.css +11 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/types.js +3 -0
- package/dist/esm/ui/Card/common/ThumbnailSection/types.js.map +1 -0
- package/dist/esm/ui/Card/common/index.js +4 -0
- package/dist/esm/ui/Card/common/index.js.map +1 -0
- package/dist/esm/ui/Card/index.js +3 -0
- package/dist/esm/ui/Card/index.js.map +1 -0
- package/dist/esm/ui/Card/styles.css +23 -0
- package/dist/esm/ui/Card/types.js +3 -0
- package/dist/esm/ui/Card/types.js.map +1 -0
- package/dist/esm/ui/Chip/Chip.js +15 -0
- package/dist/esm/ui/Chip/Chip.js.map +1 -0
- package/dist/esm/ui/Chip/index.js +4 -0
- package/dist/esm/ui/Chip/index.js.map +1 -0
- package/dist/esm/ui/Chip/styles.css +86 -0
- package/dist/esm/ui/Chip/types.js +2 -0
- package/dist/esm/ui/Chip/types.js.map +1 -0
- package/dist/esm/ui/Icon/Icon.js +15 -0
- package/dist/esm/ui/Icon/Icon.js.map +1 -0
- package/dist/esm/ui/Icon/index.js +4 -0
- package/dist/esm/ui/Icon/index.js.map +1 -0
- package/dist/esm/ui/Icon/styles.css +12 -0
- package/dist/esm/ui/Icon/types.js +3 -0
- package/dist/esm/ui/Icon/types.js.map +1 -0
- package/dist/esm/ui/Link/Link.js +15 -0
- package/dist/esm/ui/Link/Link.js.map +1 -0
- package/dist/esm/ui/Link/index.js +4 -0
- package/dist/esm/ui/Link/index.js.map +1 -0
- package/dist/esm/ui/Link/styles.css +25 -0
- package/dist/esm/ui/Link/types.js +3 -0
- package/dist/esm/ui/Link/types.js.map +1 -0
- package/dist/esm/ui/Rule/Rule.js +16 -0
- package/dist/esm/ui/Rule/Rule.js.map +1 -0
- package/dist/esm/ui/Rule/index.js +4 -0
- package/dist/esm/ui/Rule/index.js.map +1 -0
- package/dist/esm/ui/Rule/styles.css +16 -0
- package/dist/esm/ui/Rule/types.js +3 -0
- package/dist/esm/ui/Rule/types.js.map +1 -0
- package/dist/esm/ui/Section/Section.js +21 -0
- package/dist/esm/ui/Section/Section.js.map +1 -0
- package/dist/esm/ui/Section/constants.js +2 -0
- package/dist/esm/ui/Section/constants.js.map +1 -0
- package/dist/esm/ui/Section/index.js +4 -0
- package/dist/esm/ui/Section/index.js.map +1 -0
- package/dist/esm/ui/Section/styles.css +50 -0
- package/dist/esm/ui/Section/types.js +3 -0
- package/dist/esm/ui/Section/types.js.map +1 -0
- package/dist/esm/ui/SkipLink/SkipLink.js +20 -0
- package/dist/esm/ui/SkipLink/SkipLink.js.map +1 -0
- package/dist/esm/ui/SkipLink/index.js +4 -0
- package/dist/esm/ui/SkipLink/index.js.map +1 -0
- package/dist/esm/ui/SkipLink/styles.css +21 -0
- package/dist/esm/ui/SkipLink/types.js +3 -0
- package/dist/esm/ui/SkipLink/types.js.map +1 -0
- package/dist/esm/ui/Tooltip/Tooltip.js +18 -0
- package/dist/esm/ui/Tooltip/Tooltip.js.map +1 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js +40 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/TooltipArea.js.map +1 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/index.js +4 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/index.js.map +1 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/styles.css +13 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/types.js +2 -0
- package/dist/esm/ui/Tooltip/common/TooltipArea/types.js.map +1 -0
- package/dist/esm/ui/Tooltip/common/index.js +2 -0
- package/dist/esm/ui/Tooltip/common/index.js.map +1 -0
- package/dist/esm/ui/Tooltip/index.js +6 -0
- package/dist/esm/ui/Tooltip/index.js.map +1 -0
- package/dist/esm/ui/Tooltip/styles.css +122 -0
- package/dist/esm/ui/Tooltip/types.js +2 -0
- package/dist/esm/ui/Tooltip/types.js.map +1 -0
- package/dist/esm/ui/Tooltip/withTooltip.js +18 -0
- package/dist/esm/ui/Tooltip/withTooltip.js.map +1 -0
- package/dist/esm/ui/documentation/documentation/Layout/Layout.js +21 -0
- package/dist/esm/ui/documentation/documentation/Layout/Layout.js.map +1 -0
- package/dist/esm/ui/documentation/documentation/Layout/index.js +4 -0
- package/dist/esm/ui/documentation/documentation/Layout/index.js.map +1 -0
- package/dist/esm/ui/documentation/documentation/Layout/types.js +3 -0
- package/dist/esm/ui/documentation/documentation/Layout/types.js.map +1 -0
- package/dist/esm/ui/documentation/index.js +2 -0
- package/dist/esm/ui/documentation/index.js.map +1 -0
- package/dist/esm/ui/hooks/index.js +6 -0
- package/dist/esm/ui/hooks/index.js.map +1 -0
- package/dist/esm/ui/hooks/useDelayedToggle/index.js +3 -0
- package/dist/esm/ui/hooks/useDelayedToggle/index.js.map +1 -0
- package/dist/esm/ui/hooks/useDelayedToggle/types.js +2 -0
- package/dist/esm/ui/hooks/useDelayedToggle/types.js.map +1 -0
- package/dist/esm/ui/hooks/useDelayedToggle/useDelayedToggle.js +45 -0
- package/dist/esm/ui/hooks/useDelayedToggle/useDelayedToggle.js.map +1 -0
- package/dist/esm/ui/hooks/usePopup/index.js +3 -0
- package/dist/esm/ui/hooks/usePopup/index.js.map +1 -0
- package/dist/esm/ui/hooks/usePopup/types.js +2 -0
- package/dist/esm/ui/hooks/usePopup/types.js.map +1 -0
- package/dist/esm/ui/hooks/usePopup/usePopup.js +93 -0
- package/dist/esm/ui/hooks/usePopup/usePopup.js.map +1 -0
- package/dist/esm/ui/hooks/useResizeObserver/index.js +3 -0
- package/dist/esm/ui/hooks/useResizeObserver/index.js.map +1 -0
- package/dist/esm/ui/hooks/useResizeObserver/types.js +2 -0
- package/dist/esm/ui/hooks/useResizeObserver/types.js.map +1 -0
- package/dist/esm/ui/hooks/useResizeObserver/useResizeObserver.js +32 -0
- package/dist/esm/ui/hooks/useResizeObserver/useResizeObserver.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowDimensions/index.js +3 -0
- package/dist/esm/ui/hooks/useWindowDimensions/index.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowDimensions/types.js +2 -0
- package/dist/esm/ui/hooks/useWindowDimensions/types.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowDimensions/useWindowDimensions.js +47 -0
- package/dist/esm/ui/hooks/useWindowDimensions/useWindowDimensions.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowFitment/index.js +3 -0
- package/dist/esm/ui/hooks/useWindowFitment/index.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowFitment/types.js +2 -0
- package/dist/esm/ui/hooks/useWindowFitment/types.js.map +1 -0
- package/dist/esm/ui/hooks/useWindowFitment/useWindowFitment.js +221 -0
- package/dist/esm/ui/hooks/useWindowFitment/useWindowFitment.js.map +1 -0
- package/dist/esm/ui/index.js +11 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/index.d.ts.map +1 -0
- package/dist/types/lib/types/index.d.ts +2 -0
- package/dist/types/lib/types/index.d.ts.map +1 -0
- package/dist/types/lib/types/polymorphic.d.ts +24 -0
- package/dist/types/lib/types/polymorphic.d.ts.map +1 -0
- package/dist/types/storybook/decorators.d.ts +15 -0
- package/dist/types/storybook/decorators.d.ts.map +1 -0
- package/dist/types/ui/Badge/Badge.d.ts +11 -0
- package/dist/types/ui/Badge/Badge.d.ts.map +1 -0
- package/dist/types/ui/Badge/hooks/useBadge.d.ts +7 -0
- package/dist/types/ui/Badge/hooks/useBadge.d.ts.map +1 -0
- package/dist/types/ui/Badge/index.d.ts +3 -0
- package/dist/types/ui/Badge/index.d.ts.map +1 -0
- package/dist/types/ui/Badge/types.d.ts +42 -0
- package/dist/types/ui/Badge/types.d.ts.map +1 -0
- package/dist/types/ui/Button/Button.d.ts +6 -0
- package/dist/types/ui/Button/Button.d.ts.map +1 -0
- package/dist/types/ui/Button/index.d.ts +3 -0
- package/dist/types/ui/Button/index.d.ts.map +1 -0
- package/dist/types/ui/Button/types.d.ts +22 -0
- package/dist/types/ui/Button/types.d.ts.map +1 -0
- package/dist/types/ui/Card/Card.d.ts +24 -0
- package/dist/types/ui/Card/Card.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Image/Image.d.ts +14 -0
- package/dist/types/ui/Card/common/Image/Image.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Image/index.d.ts +3 -0
- package/dist/types/ui/Card/common/Image/index.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Image/types.d.ts +5 -0
- package/dist/types/ui/Card/common/Image/types.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Section/Section.d.ts +13 -0
- package/dist/types/ui/Card/common/Section/Section.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Section/index.d.ts +3 -0
- package/dist/types/ui/Card/common/Section/index.d.ts.map +1 -0
- package/dist/types/ui/Card/common/Section/types.d.ts +6 -0
- package/dist/types/ui/Card/common/Section/types.d.ts.map +1 -0
- package/dist/types/ui/Card/common/ThumbnailSection/ThumbnailSection.d.ts +13 -0
- package/dist/types/ui/Card/common/ThumbnailSection/ThumbnailSection.d.ts.map +1 -0
- package/dist/types/ui/Card/common/ThumbnailSection/index.d.ts +3 -0
- package/dist/types/ui/Card/common/ThumbnailSection/index.d.ts.map +1 -0
- package/dist/types/ui/Card/common/ThumbnailSection/types.d.ts +12 -0
- package/dist/types/ui/Card/common/ThumbnailSection/types.d.ts.map +1 -0
- package/dist/types/ui/Card/common/index.d.ts +4 -0
- package/dist/types/ui/Card/common/index.d.ts.map +1 -0
- package/dist/types/ui/Card/index.d.ts +3 -0
- package/dist/types/ui/Card/index.d.ts.map +1 -0
- package/dist/types/ui/Card/types.d.ts +10 -0
- package/dist/types/ui/Card/types.d.ts.map +1 -0
- package/dist/types/ui/Chip/Chip.d.ts +10 -0
- package/dist/types/ui/Chip/Chip.d.ts.map +1 -0
- package/dist/types/ui/Chip/index.d.ts +3 -0
- package/dist/types/ui/Chip/index.d.ts.map +1 -0
- package/dist/types/ui/Chip/types.d.ts +27 -0
- package/dist/types/ui/Chip/types.d.ts.map +1 -0
- package/dist/types/ui/Icon/Icon.d.ts +13 -0
- package/dist/types/ui/Icon/Icon.d.ts.map +1 -0
- package/dist/types/ui/Icon/index.d.ts +3 -0
- package/dist/types/ui/Icon/index.d.ts.map +1 -0
- package/dist/types/ui/Icon/types.d.ts +13 -0
- package/dist/types/ui/Icon/types.d.ts.map +1 -0
- package/dist/types/ui/Link/Link.d.ts +10 -0
- package/dist/types/ui/Link/Link.d.ts.map +1 -0
- package/dist/types/ui/Link/index.d.ts +3 -0
- package/dist/types/ui/Link/index.d.ts.map +1 -0
- package/dist/types/ui/Link/types.d.ts +13 -0
- package/dist/types/ui/Link/types.d.ts.map +1 -0
- package/dist/types/ui/Rule/Rule.d.ts +12 -0
- package/dist/types/ui/Rule/Rule.d.ts.map +1 -0
- package/dist/types/ui/Rule/index.d.ts +3 -0
- package/dist/types/ui/Rule/index.d.ts.map +1 -0
- package/dist/types/ui/Rule/types.d.ts +11 -0
- package/dist/types/ui/Rule/types.d.ts.map +1 -0
- package/dist/types/ui/Section/Section.d.ts +12 -0
- package/dist/types/ui/Section/Section.d.ts.map +1 -0
- package/dist/types/ui/Section/constants.d.ts +2 -0
- package/dist/types/ui/Section/constants.d.ts.map +1 -0
- package/dist/types/ui/Section/index.d.ts +3 -0
- package/dist/types/ui/Section/index.d.ts.map +1 -0
- package/dist/types/ui/Section/types.d.ts +22 -0
- package/dist/types/ui/Section/types.d.ts.map +1 -0
- package/dist/types/ui/SkipLink/SkipLink.d.ts +16 -0
- package/dist/types/ui/SkipLink/SkipLink.d.ts.map +1 -0
- package/dist/types/ui/SkipLink/index.d.ts +3 -0
- package/dist/types/ui/SkipLink/index.d.ts.map +1 -0
- package/dist/types/ui/SkipLink/types.d.ts +16 -0
- package/dist/types/ui/SkipLink/types.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/Tooltip.d.ts +12 -0
- package/dist/types/ui/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/TooltipArea.d.ts +10 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/TooltipArea.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/index.d.ts +3 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/index.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/types.d.ts +35 -0
- package/dist/types/ui/Tooltip/common/TooltipArea/types.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/common/index.d.ts +2 -0
- package/dist/types/ui/Tooltip/common/index.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/index.d.ts +5 -0
- package/dist/types/ui/Tooltip/index.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/types.d.ts +16 -0
- package/dist/types/ui/Tooltip/types.d.ts.map +1 -0
- package/dist/types/ui/Tooltip/withTooltip.d.ts +11 -0
- package/dist/types/ui/Tooltip/withTooltip.d.ts.map +1 -0
- package/dist/types/ui/documentation/documentation/Layout/Layout.d.ts +10 -0
- package/dist/types/ui/documentation/documentation/Layout/Layout.d.ts.map +1 -0
- package/dist/types/ui/documentation/documentation/Layout/index.d.ts +3 -0
- package/dist/types/ui/documentation/documentation/Layout/index.d.ts.map +1 -0
- package/dist/types/ui/documentation/documentation/Layout/types.d.ts +8 -0
- package/dist/types/ui/documentation/documentation/Layout/types.d.ts.map +1 -0
- package/dist/types/ui/documentation/index.d.ts +2 -0
- package/dist/types/ui/documentation/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/index.d.ts +6 -0
- package/dist/types/ui/hooks/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/useDelayedToggle/index.d.ts +3 -0
- package/dist/types/ui/hooks/useDelayedToggle/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/useDelayedToggle/types.d.ts +27 -0
- package/dist/types/ui/hooks/useDelayedToggle/types.d.ts.map +1 -0
- package/dist/types/ui/hooks/useDelayedToggle/useDelayedToggle.d.ts +13 -0
- package/dist/types/ui/hooks/useDelayedToggle/useDelayedToggle.d.ts.map +1 -0
- package/dist/types/ui/hooks/usePopup/index.d.ts +3 -0
- package/dist/types/ui/hooks/usePopup/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/usePopup/types.d.ts +65 -0
- package/dist/types/ui/hooks/usePopup/types.d.ts.map +1 -0
- package/dist/types/ui/hooks/usePopup/usePopup.d.ts +19 -0
- package/dist/types/ui/hooks/usePopup/usePopup.d.ts.map +1 -0
- package/dist/types/ui/hooks/useResizeObserver/index.d.ts +3 -0
- package/dist/types/ui/hooks/useResizeObserver/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/useResizeObserver/types.d.ts +7 -0
- package/dist/types/ui/hooks/useResizeObserver/types.d.ts.map +1 -0
- package/dist/types/ui/hooks/useResizeObserver/useResizeObserver.d.ts +8 -0
- package/dist/types/ui/hooks/useResizeObserver/useResizeObserver.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowDimensions/index.d.ts +3 -0
- package/dist/types/ui/hooks/useWindowDimensions/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowDimensions/types.d.ts +21 -0
- package/dist/types/ui/hooks/useWindowDimensions/types.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowDimensions/useWindowDimensions.d.ts +6 -0
- package/dist/types/ui/hooks/useWindowDimensions/useWindowDimensions.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowFitment/index.d.ts +3 -0
- package/dist/types/ui/hooks/useWindowFitment/index.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowFitment/types.d.ts +73 -0
- package/dist/types/ui/hooks/useWindowFitment/types.d.ts.map +1 -0
- package/dist/types/ui/hooks/useWindowFitment/useWindowFitment.d.ts +4 -0
- package/dist/types/ui/hooks/useWindowFitment/useWindowFitment.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +11 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
const componentCssClassName = "ds layout";
|
|
4
|
+
const items = [
|
|
5
|
+
{ id: 1, content: "Item 1" },
|
|
6
|
+
{ id: 2, content: "Item 2" },
|
|
7
|
+
{ id: 3, content: "Item 3" },
|
|
8
|
+
{ id: 4, content: "Item 4" },
|
|
9
|
+
{ id: 5, content: "Item 5" },
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* description of the Layout component
|
|
13
|
+
* @returns {React.ReactElement} - Rendered Layout
|
|
14
|
+
*/
|
|
15
|
+
const Layout = ({ id, children, className, style, }) => {
|
|
16
|
+
return (_jsxs("div", { id: id, style: style, className: [componentCssClassName, className, "flexible-grid"]
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join(" "), children: [_jsxs("header", { children: [_jsx("span", { class: "title", children: "Title" }), "\"", _jsxs("ul", { children: [_jsx("li", { children: "Intro" }), _jsx("li", { children: "Guidelines" }), _jsx("li", { children: "Vocabulary" }), _jsx("li", { children: "AI Studio" })] }), _jsx("span", { children: "Search" })] }), _jsxs("aside", { children: [_jsx("span", { class: "title", children: "Filter" }), _jsx("span", { children: "Platforms" }), _jsx("span", { children: "Tiers" })] }), _jsx("nav", { children: "Navigation" }), _jsx("main", { children: items.map((item) => (_jsx("div", { children: item.content }, item.id))) })] }));
|
|
19
|
+
};
|
|
20
|
+
export default Layout;
|
|
21
|
+
//# sourceMappingURL=Layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../../../../src/ui/documentation/documentation/Layout/Layout.tsx"],"names":[],"mappings":";AAIA,OAAO,cAAc,CAAC;AAEtB,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAE1C,MAAM,KAAK,GAAG;IACb,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC5B,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC5B,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC5B,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE;IAC5B,EAAE,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE;CAC5B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,EACf,EAAE,EACF,QAAQ,EACR,SAAS,EACT,KAAK,GACQ,EAAsB,EAAE;IACrC,OAAO,CACN,eACC,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,CAAC,qBAAqB,EAAE,SAAS,EAAE,eAAe,CAAC;aAC5D,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEX,6BACC,eAAM,KAAK,EAAC,OAAO,sBAAa,QAEhC,yBACC,iCAAc,EACd,sCAAmB,EACnB,sCAAmB,EACnB,qCAAkB,IACd,EACL,oCAAmB,IACX,EACT,4BACC,eAAM,KAAK,EAAC,OAAO,uBAAc,EACjC,uCAAsB,EACtB,mCAAkB,IACX,EACR,uCAAqB,EACrB,yBACE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACpB,wBAAoB,IAAI,CAAC,OAAO,IAAtB,IAAI,CAAC,EAAE,CAAsB,CACvC,CAAC,GACI,IACF,CACN,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ui/documentation/documentation/Layout/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/ui/documentation/documentation/Layout/types.ts"],"names":[],"mappings":"AAAA,mDAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/documentation/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to toggle a flag with a delay.
|
|
4
|
+
* Allows the caller to `activate()` or `deactivate()` some flag
|
|
5
|
+
* @param activateDelay The delay in milliseconds before setting the flag to true.
|
|
6
|
+
* @param deactivateDelay The delay in milliseconds before setting the flag to false.
|
|
7
|
+
* @param onActivate A callback to be called when the flag is set to true.
|
|
8
|
+
* @param onDeactivate A callback to be called when the flag is set to false.
|
|
9
|
+
* @returns The current state of the flag, functions to activate and deactivate the flag.
|
|
10
|
+
*/
|
|
11
|
+
const useDelayedToggle = ({ activateDelay = 150, deactivateDelay = 150, onActivate, onDeactivate, }) => {
|
|
12
|
+
const [flag, setFlag] = useState(false);
|
|
13
|
+
const flagTimeout = useRef(undefined);
|
|
14
|
+
const replaceTimer = useCallback((newTimer) => {
|
|
15
|
+
if (flagTimeout.current) {
|
|
16
|
+
clearTimeout(flagTimeout.current);
|
|
17
|
+
}
|
|
18
|
+
flagTimeout.current = newTimer;
|
|
19
|
+
}, []);
|
|
20
|
+
const activate = useCallback((event) => {
|
|
21
|
+
replaceTimer(setTimeout(() => {
|
|
22
|
+
setFlag(true);
|
|
23
|
+
if (onActivate)
|
|
24
|
+
onActivate(event);
|
|
25
|
+
}, activateDelay));
|
|
26
|
+
}, [activateDelay, replaceTimer, onActivate]);
|
|
27
|
+
const deactivate = useCallback((event) => {
|
|
28
|
+
replaceTimer(setTimeout(() => {
|
|
29
|
+
setFlag(false);
|
|
30
|
+
if (onDeactivate)
|
|
31
|
+
onDeactivate(event);
|
|
32
|
+
}, deactivateDelay));
|
|
33
|
+
}, [deactivateDelay, replaceTimer, onDeactivate]);
|
|
34
|
+
// Cleanup
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
if (flagTimeout.current) {
|
|
38
|
+
clearTimeout(flagTimeout.current);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
return { flag, activate, deactivate };
|
|
43
|
+
};
|
|
44
|
+
export default useDelayedToggle;
|
|
45
|
+
//# sourceMappingURL=useDelayedToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDelayedToggle.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useDelayedToggle/useDelayedToggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjE;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,aAAa,GAAG,GAAG,EACnB,eAAe,GAAG,GAAG,EACrB,UAAU,EACV,YAAY,GACU,EAA0B,EAAE;IAClD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,MAAM,CACxB,SAAS,CACV,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,QAAwC,EAAE,EAAE;QAC3C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACxB,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QACD,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAAY,EAAE,EAAE;QACf,YAAY,CACV,UAAU,CAAC,GAAG,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,UAAU;gBAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC,EAAE,aAAa,CAAC,CAClB,CAAC;IACJ,CAAC,EACD,CAAC,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,CAC1C,CAAC;IAEF,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,KAAY,EAAE,EAAE;QACf,YAAY,CACV,UAAU,CAAC,GAAG,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,IAAI,YAAY;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC,EAAE,eAAe,CAAC,CACpB,CAAC;IACJ,CAAC,EACD,CAAC,eAAe,EAAE,YAAY,EAAE,YAAY,CAAC,CAC9C,CAAC;IAEF,UAAU;IACV,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACxB,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACxC,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/usePopup/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/usePopup/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useCallback, useEffect, useId, useState, } from "react";
|
|
2
|
+
import { useDelayedToggle } from "../useDelayedToggle/index.js";
|
|
3
|
+
import { useWindowFitment } from "../useWindowFitment/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Manages the state of a popup.
|
|
6
|
+
* @param isOpen An override for the open state.
|
|
7
|
+
* @param deactivateDelay The delay in milliseconds before setting the flag to false.
|
|
8
|
+
* @param activateDelay The delay in milliseconds before setting the flag to true.
|
|
9
|
+
* @param onEnter A callback to be called when the mouse enters the target element.
|
|
10
|
+
* @param onLeave A callback to be called when the mouse leaves the target element.
|
|
11
|
+
* @param onFocus A callback to be called when the target element is focused.
|
|
12
|
+
* @param onBlur A callback to be called when the target element loses focus.
|
|
13
|
+
* @param onShow A callback to be called when the popup is shown.
|
|
14
|
+
* @param onHide A callback to be called when the popup is hidden.
|
|
15
|
+
* @param closeOnEscape Whether the popup should close when the escape key is pressed. Defaults to true.
|
|
16
|
+
* @param props The props to be passed to the useWindowFitment hook.
|
|
17
|
+
* @returns The current state of the popup, and event handlers for the target element.
|
|
18
|
+
*/
|
|
19
|
+
const usePopup = ({ isOpen: isOpenProp, deactivateDelay, activateDelay, onEnter, onLeave, onFocus, onBlur, onShow, onHide, closeOnEscape = true, ...props }) => {
|
|
20
|
+
const isServer = typeof window === "undefined";
|
|
21
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
22
|
+
const popupId = useId();
|
|
23
|
+
const { flag: isOpenHook, deactivate: close, activate: open, } = useDelayedToggle({
|
|
24
|
+
activateDelay,
|
|
25
|
+
deactivateDelay,
|
|
26
|
+
onActivate: onShow,
|
|
27
|
+
onDeactivate: onHide,
|
|
28
|
+
});
|
|
29
|
+
// Apply open override
|
|
30
|
+
const isOpen = typeof isOpenProp === "boolean" ? isOpenProp : isOpenHook;
|
|
31
|
+
const { targetRef, popupRef, bestPosition, popupPositionStyle } = useWindowFitment({
|
|
32
|
+
...props,
|
|
33
|
+
isOpen: isOpen,
|
|
34
|
+
});
|
|
35
|
+
const handleTriggerFocus = useCallback((event) => {
|
|
36
|
+
if (isServer)
|
|
37
|
+
return;
|
|
38
|
+
setIsFocused(true);
|
|
39
|
+
open(event.nativeEvent);
|
|
40
|
+
if (onFocus)
|
|
41
|
+
onFocus(event);
|
|
42
|
+
}, [open, onFocus, isServer]);
|
|
43
|
+
const handleTriggerBlur = useCallback((event) => {
|
|
44
|
+
if (isServer)
|
|
45
|
+
return;
|
|
46
|
+
setIsFocused(false);
|
|
47
|
+
close(event.nativeEvent);
|
|
48
|
+
if (onBlur)
|
|
49
|
+
onBlur(event);
|
|
50
|
+
}, [close, onBlur, isServer]);
|
|
51
|
+
const isDisabled = useCallback((el) => el?.disabled, []);
|
|
52
|
+
const handleTriggerEnter = useCallback((event) => {
|
|
53
|
+
if (isServer || isDisabled(event.target))
|
|
54
|
+
return;
|
|
55
|
+
open(event.nativeEvent);
|
|
56
|
+
if (onEnter)
|
|
57
|
+
onEnter(event);
|
|
58
|
+
}, [open, onEnter, isServer, isDisabled]);
|
|
59
|
+
const handleTriggerLeave = useCallback((event) => {
|
|
60
|
+
if (isServer || isDisabled(event.target))
|
|
61
|
+
return;
|
|
62
|
+
close(event.nativeEvent);
|
|
63
|
+
if (onLeave)
|
|
64
|
+
onLeave(event);
|
|
65
|
+
}, [close, onLeave, isServer, isDisabled]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (isServer || !closeOnEscape || !isOpen)
|
|
68
|
+
return;
|
|
69
|
+
const handleEscape = (event) => {
|
|
70
|
+
if (event.key === "Escape")
|
|
71
|
+
close(event);
|
|
72
|
+
};
|
|
73
|
+
document.addEventListener("keydown", handleEscape);
|
|
74
|
+
return () => {
|
|
75
|
+
document.removeEventListener("keydown", handleEscape);
|
|
76
|
+
};
|
|
77
|
+
}, [close, closeOnEscape, isOpen, isServer]);
|
|
78
|
+
return {
|
|
79
|
+
handleTriggerBlur,
|
|
80
|
+
handleTriggerEnter,
|
|
81
|
+
handleTriggerFocus,
|
|
82
|
+
handleTriggerLeave,
|
|
83
|
+
isFocused,
|
|
84
|
+
isOpen,
|
|
85
|
+
popupId,
|
|
86
|
+
popupRef,
|
|
87
|
+
targetRef,
|
|
88
|
+
bestPosition,
|
|
89
|
+
popupPositionStyle,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export default usePopup;
|
|
93
|
+
//# sourceMappingURL=usePopup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useP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QAAQ,EAAE,UAAU,CAAC,CACvC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,IAAI,CAAC,aAAa,IAAI,CAAC,MAAM;YAAE,OAAO;QAElD,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC5C,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ;gBAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QAEnD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE7C,OAAO;QACL,iBAAiB;QACjB,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,SAAS;QACT,MAAM;QACN,OAAO;QACP,QAAQ;QACR,SAAS;QACT,YAAY;QACZ,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to observe the size of an element.
|
|
4
|
+
* @param element The element to observe.
|
|
5
|
+
* @returns The size of the element.
|
|
6
|
+
*/
|
|
7
|
+
export default function useResizeObserver(element) {
|
|
8
|
+
const [size, setSize] = useState({
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
});
|
|
12
|
+
const isServer = typeof window === "undefined";
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!element || isServer)
|
|
15
|
+
return;
|
|
16
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
17
|
+
if (entry) {
|
|
18
|
+
const rect = entry.contentRect;
|
|
19
|
+
setSize({
|
|
20
|
+
width: rect.width,
|
|
21
|
+
height: rect.height,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
observer.observe(element);
|
|
26
|
+
return () => {
|
|
27
|
+
observer.disconnect();
|
|
28
|
+
};
|
|
29
|
+
}, [element, isServer]);
|
|
30
|
+
return size;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useResizeObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useResizeObserver/useResizeObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG5C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,OAAyB;IAEzB,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAA0B;QACxD,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IAE/C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,OAAO,IAAI,QAAQ;YAAE,OAAO;QAEjC,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE;YAC9C,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC;gBAC/B,OAAO,CAAC;oBACN,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1B,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAExB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { debounce } from "@canonical/utils";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to get the window dimensions and scroll position.
|
|
5
|
+
*/
|
|
6
|
+
export default function useWindowDimensions({ onResize, onScroll, resizeDelay = 100, scrollDelay = 100, } = {}) {
|
|
7
|
+
const isServer = typeof window === "undefined";
|
|
8
|
+
const [windowWidth, setWindowWidth] = useState(isServer ? 0 : window.innerWidth);
|
|
9
|
+
const [windowHeight, setWindowHeight] = useState(isServer ? 0 : window.innerHeight);
|
|
10
|
+
const [scrollHeight, setScrollHeight] = useState(isServer ? 0 : window.scrollY);
|
|
11
|
+
const [scrollWidth, setScrollWidth] = useState(isServer ? 0 : window.scrollX);
|
|
12
|
+
const result = useMemo(() => ({
|
|
13
|
+
windowWidth,
|
|
14
|
+
windowHeight,
|
|
15
|
+
scrollWidth,
|
|
16
|
+
scrollHeight,
|
|
17
|
+
}), [windowWidth, windowHeight, scrollWidth, scrollHeight]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (isServer)
|
|
20
|
+
return;
|
|
21
|
+
const handleResize = debounce(() => {
|
|
22
|
+
setWindowWidth(window.innerWidth);
|
|
23
|
+
setWindowHeight(window.innerHeight);
|
|
24
|
+
if (onResize)
|
|
25
|
+
onResize(result);
|
|
26
|
+
}, resizeDelay);
|
|
27
|
+
const handleScroll = debounce(() => {
|
|
28
|
+
setScrollWidth(window.scrollX);
|
|
29
|
+
setScrollHeight(window.scrollY);
|
|
30
|
+
if (onScroll)
|
|
31
|
+
onScroll(result);
|
|
32
|
+
}, scrollDelay);
|
|
33
|
+
window.addEventListener("resize", handleResize);
|
|
34
|
+
window.addEventListener("scroll", handleScroll);
|
|
35
|
+
// Initial trigger in case the values need to be passed immediately after mount
|
|
36
|
+
void handleResize();
|
|
37
|
+
void handleScroll();
|
|
38
|
+
return () => {
|
|
39
|
+
handleResize.cancel();
|
|
40
|
+
handleScroll.cancel();
|
|
41
|
+
window.removeEventListener("resize", handleResize);
|
|
42
|
+
window.removeEventListener("scroll", handleScroll);
|
|
43
|
+
};
|
|
44
|
+
}, [onResize, onScroll, resizeDelay, scrollDelay, result, isServer]);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=useWindowDimensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowDimensions.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowDimensions/useWindowDimensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMrD;;GAEG;A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AC;QAEhB,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE;YACjC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC/B,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAChC,IAAI,QAAQ;gBAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,EAAE,WAAW,CAAC,CAAC;QAEhB,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAChD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAEhD,+EAA+E;QAC/E,KAAK,YAAY,EAAE,CAAC;QACpB,KAAK,YAAY,EAAE,CAAC;QAEpB,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,MAAM,EAAE,CAAC;YACtB,YAAY,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YACnD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACrD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAErE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowFitment/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowFitment/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, } from "react";
|
|
2
|
+
import { useResizeObserver } from "../useResizeObserver/index.js";
|
|
3
|
+
import { useWindowDimensions } from "../useWindowDimensions/index.js";
|
|
4
|
+
const useWindowFitment = ({ preferredDirections = ["top", "bottom", "left", "right"], distance = "0px", gutter = "0px", maxWidth = "350px", resizeDelay = 150, scrollDelay = 150, onBestPositionChange, autoFit = false, }) => {
|
|
5
|
+
const isServer = typeof window === "undefined";
|
|
6
|
+
const targetRef = useRef(null);
|
|
7
|
+
const popupRef = useRef(null);
|
|
8
|
+
const prevBestPosition = useRef(undefined);
|
|
9
|
+
const windowDimensions = useWindowDimensions({ resizeDelay, scrollDelay });
|
|
10
|
+
const targetSize = useResizeObserver(targetRef?.current);
|
|
11
|
+
const popupSize = useResizeObserver(popupRef?.current);
|
|
12
|
+
/** The distance, in pixels, between the target and the popup. */
|
|
13
|
+
const distanceAsPixelsNumber = useMemo(() => Number.parseInt(distance, 10) || 0, [distance]);
|
|
14
|
+
/** The bounds of the window, accounting for the `gutter` prop. */
|
|
15
|
+
const bounds = useMemo(() => {
|
|
16
|
+
if (isServer)
|
|
17
|
+
return;
|
|
18
|
+
const gutterValues = gutter
|
|
19
|
+
.split(" ")
|
|
20
|
+
.map((val) => Number.parseInt(val, 10));
|
|
21
|
+
const topGutter = gutterValues[0] || 0;
|
|
22
|
+
const rightGutter = gutterValues[1] || gutterValues[0] || 0;
|
|
23
|
+
const bottomGutter = gutterValues[2] || gutterValues[0] || 0;
|
|
24
|
+
const leftGutter = gutterValues[3] || gutterValues[1] || gutterValues[0] || 0;
|
|
25
|
+
return {
|
|
26
|
+
top: topGutter,
|
|
27
|
+
left: leftGutter,
|
|
28
|
+
right: windowDimensions.windowWidth - rightGutter,
|
|
29
|
+
bottom: windowDimensions.windowHeight - bottomGutter,
|
|
30
|
+
};
|
|
31
|
+
}, [gutter, windowDimensions, isServer]);
|
|
32
|
+
/**
|
|
33
|
+
* Calculate the relative position of the popup when oriented in a given direction.
|
|
34
|
+
* @param direction The side of the target element to position the popup on.
|
|
35
|
+
* @param targetRect The bounding client rect of the target element.
|
|
36
|
+
* @param popupRect The bounding client rect of the popup element.
|
|
37
|
+
* @returns The calculated relative position of the popup.
|
|
38
|
+
*/
|
|
39
|
+
const calculateRelativePosition = useCallback((direction, targetRect, popupRect) => {
|
|
40
|
+
let left = 0;
|
|
41
|
+
let top = 0;
|
|
42
|
+
if (isServer) {
|
|
43
|
+
return {
|
|
44
|
+
left,
|
|
45
|
+
top,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/*
|
|
49
|
+
We use left and top offsets to position the popup relative to the target element.
|
|
50
|
+
Then, we apply a margin on the opposite side of the popup to create a buffer zone between the target and the popup, to prevent a mouseleave event when moving from the target to the popup.
|
|
51
|
+
The fake margin is already included in `targetRect` dimensions, as it is rendered hidden at least once before the popup is shown.
|
|
52
|
+
In cases where `targetRect` is not included in the calculation, we add `distanceAsPixelsNumber` to account for the fake margin.
|
|
53
|
+
*/
|
|
54
|
+
// horizontal offset
|
|
55
|
+
switch (direction) {
|
|
56
|
+
case "top":
|
|
57
|
+
case "bottom":
|
|
58
|
+
left = (targetRect.width - popupRect.width) / 2;
|
|
59
|
+
break;
|
|
60
|
+
case "right":
|
|
61
|
+
left = targetRect.width;
|
|
62
|
+
break;
|
|
63
|
+
case "left":
|
|
64
|
+
left = -(popupRect.width + distanceAsPixelsNumber);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
// vertical offset
|
|
68
|
+
switch (direction) {
|
|
69
|
+
case "top":
|
|
70
|
+
top = -(popupRect.height + distanceAsPixelsNumber);
|
|
71
|
+
break;
|
|
72
|
+
case "bottom":
|
|
73
|
+
top = targetRect.height;
|
|
74
|
+
break;
|
|
75
|
+
case "right":
|
|
76
|
+
case "left":
|
|
77
|
+
top = (targetRect.height - popupRect.height) / 2;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
return { left, top };
|
|
81
|
+
}, [distanceAsPixelsNumber, isServer]);
|
|
82
|
+
/**
|
|
83
|
+
* Check if the popup fits within the window. Accounts for `gutter` prop.
|
|
84
|
+
* @param candidatePosition The absolute position of the popup
|
|
85
|
+
* @param popupRect The bounding client rect of the popup element.
|
|
86
|
+
* @returns Whether the popup fits within the window.
|
|
87
|
+
*/
|
|
88
|
+
const fitsInWindow = useCallback((candidatePosition, popupRect) => {
|
|
89
|
+
if (isServer || !bounds)
|
|
90
|
+
return false;
|
|
91
|
+
// Absolute position of the popup's vertices, relative to the viewport
|
|
92
|
+
const vertices = {
|
|
93
|
+
top: candidatePosition.top,
|
|
94
|
+
right: candidatePosition.left + popupRect.width,
|
|
95
|
+
bottom: candidatePosition.top + popupRect.height,
|
|
96
|
+
left: candidatePosition.left,
|
|
97
|
+
};
|
|
98
|
+
return (vertices.top >= bounds.top &&
|
|
99
|
+
vertices.right <= bounds.right &&
|
|
100
|
+
vertices.bottom <= bounds.bottom &&
|
|
101
|
+
vertices.left >= bounds.left);
|
|
102
|
+
}, [bounds, isServer]);
|
|
103
|
+
/**
|
|
104
|
+
* Find the best position for the popup based on the preferred directions.
|
|
105
|
+
* @param targetRect The bounding client rect of the target element.
|
|
106
|
+
* @param popupRect The bounding client rect of the popup element.
|
|
107
|
+
* @returns The best absolute position for the popup.
|
|
108
|
+
*/
|
|
109
|
+
const findBestPosition = useCallback((targetRect, popupRect, preferredDirections) => {
|
|
110
|
+
if (isServer)
|
|
111
|
+
return;
|
|
112
|
+
let fallbackPosition;
|
|
113
|
+
if (!preferredDirections.length) {
|
|
114
|
+
throw new Error("Preferred directions must not be empty.");
|
|
115
|
+
}
|
|
116
|
+
for (const direction of preferredDirections) {
|
|
117
|
+
const relativePosition = calculateRelativePosition(direction, targetRect, popupRect);
|
|
118
|
+
const absolutePosition = {
|
|
119
|
+
top: targetRect.top + relativePosition.top,
|
|
120
|
+
left: targetRect.left + relativePosition.left,
|
|
121
|
+
};
|
|
122
|
+
const autoFitOffset = { top: 0, left: 0 };
|
|
123
|
+
if (autoFit && bounds) {
|
|
124
|
+
// Adjust position if it overflows the bounds
|
|
125
|
+
if (absolutePosition.top < bounds.top) {
|
|
126
|
+
autoFitOffset.top = bounds.top - absolutePosition.top;
|
|
127
|
+
absolutePosition.top = bounds.top;
|
|
128
|
+
}
|
|
129
|
+
else if (absolutePosition.top + popupRect.height > bounds.bottom) {
|
|
130
|
+
autoFitOffset.top =
|
|
131
|
+
bounds.bottom - (absolutePosition.top + popupRect.height);
|
|
132
|
+
absolutePosition.top = bounds.bottom - popupRect.height;
|
|
133
|
+
}
|
|
134
|
+
if (absolutePosition.left < bounds.left) {
|
|
135
|
+
autoFitOffset.left = -1 * (bounds.left - absolutePosition.left);
|
|
136
|
+
absolutePosition.left = bounds.left;
|
|
137
|
+
}
|
|
138
|
+
else if (absolutePosition.left + popupRect.width > bounds.right) {
|
|
139
|
+
autoFitOffset.left =
|
|
140
|
+
-1 * (bounds.right - (absolutePosition.left + popupRect.width));
|
|
141
|
+
absolutePosition.left = bounds.right - popupRect.width;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const bestPositionForName = {
|
|
145
|
+
positionName: direction,
|
|
146
|
+
position: absolutePosition,
|
|
147
|
+
fits: fitsInWindow(absolutePosition, popupRect),
|
|
148
|
+
autoFitOffset,
|
|
149
|
+
};
|
|
150
|
+
// Save the calculated position as a fallback in case no other position fits.
|
|
151
|
+
fallbackPosition ||= bestPositionForName;
|
|
152
|
+
// If this position fits, use it.
|
|
153
|
+
if (bestPositionForName.fits) {
|
|
154
|
+
return bestPositionForName;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// biome-ignore lint/style/noNonNullAssertion: Fallback position is always defined here, due to the loop above and the thrown error if preferredDirections is empty.
|
|
158
|
+
return fallbackPosition;
|
|
159
|
+
}, [calculateRelativePosition, fitsInWindow, isServer, autoFit, bounds]);
|
|
160
|
+
/** The best possible position for the popup. */
|
|
161
|
+
const bestPosition = useMemo(() => {
|
|
162
|
+
if (!isServer &&
|
|
163
|
+
targetRef.current &&
|
|
164
|
+
popupRef.current &&
|
|
165
|
+
windowDimensions &&
|
|
166
|
+
popupSize &&
|
|
167
|
+
targetSize)
|
|
168
|
+
return findBestPosition(targetRef.current.getBoundingClientRect(), popupRef.current.getBoundingClientRect(), preferredDirections);
|
|
169
|
+
}, [
|
|
170
|
+
findBestPosition,
|
|
171
|
+
preferredDirections,
|
|
172
|
+
windowDimensions,
|
|
173
|
+
popupSize,
|
|
174
|
+
targetSize,
|
|
175
|
+
isServer,
|
|
176
|
+
]);
|
|
177
|
+
/** Notify the consumer when the best position changes. */
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (bestPosition?.positionName !== prevBestPosition.current?.positionName) {
|
|
180
|
+
prevBestPosition.current = bestPosition;
|
|
181
|
+
if (onBestPositionChange)
|
|
182
|
+
onBestPositionChange(bestPosition);
|
|
183
|
+
}
|
|
184
|
+
}, [bestPosition, onBestPositionChange]);
|
|
185
|
+
const fakeMargin = useMemo(() => {
|
|
186
|
+
let side = "Top";
|
|
187
|
+
switch (bestPosition?.positionName) {
|
|
188
|
+
case "top":
|
|
189
|
+
side = "Bottom";
|
|
190
|
+
break;
|
|
191
|
+
case "bottom":
|
|
192
|
+
side = "Top";
|
|
193
|
+
break;
|
|
194
|
+
case "left":
|
|
195
|
+
side = "Right";
|
|
196
|
+
break;
|
|
197
|
+
case "right":
|
|
198
|
+
side = "Left";
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
[`margin${side}`]: `${distanceAsPixelsNumber}px`,
|
|
203
|
+
};
|
|
204
|
+
}, [bestPosition, distanceAsPixelsNumber]);
|
|
205
|
+
/** The style object to be applied to the popup element. */
|
|
206
|
+
const popupPositionStyle = useMemo(() => ({
|
|
207
|
+
maxWidth: maxWidth,
|
|
208
|
+
top: bestPosition?.position?.top || 0,
|
|
209
|
+
left: bestPosition?.position?.left || 0,
|
|
210
|
+
// Fake margin around the popup to prevent a mouseleave event when moving from the target to the popup.
|
|
211
|
+
...fakeMargin,
|
|
212
|
+
}), [bestPosition, maxWidth, fakeMargin]);
|
|
213
|
+
return {
|
|
214
|
+
targetRef,
|
|
215
|
+
popupRef,
|
|
216
|
+
bestPosition,
|
|
217
|
+
popupPositionStyle,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export default useWindowFitment;
|
|
221
|
+
//# sourceMappingURL=useWindowFitment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowFitment.js","sourceRoot":"","sources":["../../../../../src/ui/hooks/useWindowFitment/useWindowFitment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAStE,MAAM,gBAAgB,GAAG,CAAC,EACxB,mBAAmB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EACxD,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,KAAK,EACd,QAAQ,GAAG,OAAO,EAClB,WAAW,GAAG,GAAG,EACjB,WAAW,GAAG,GAAG,EACjB,oBAAoB,EACpB,OAAO,GAAG,KAAK,GACO,EAA0B,EAAE;IAClD,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACrD,MAAM,gBAAgB,GAAG,MAAM,CAA2B,SAAS,CAAC,CAAC;IAErE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC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