@opengovsg/oui 0.0.28 → 0.0.29
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/dist/cjs/badge/badge.cjs +4 -4
- package/dist/cjs/badge/use-badge.cjs +6 -6
- package/dist/cjs/banner/banner.cjs +3 -3
- package/dist/cjs/button/button.cjs +4 -4
- package/dist/cjs/calendar/calendar-bottom-content.cjs +3 -3
- package/dist/cjs/calendar/calendar-header.cjs +2 -2
- package/dist/cjs/calendar/calendar-month-day-selector.cjs +4 -4
- package/dist/cjs/calendar/calendar.cjs +4 -4
- package/dist/cjs/calendar/hooks/use-calendar-selectors.cjs +4 -4
- package/dist/cjs/calendar/utils.cjs +3 -3
- package/dist/cjs/combo-box/combo-box-fuzzy.cjs +6 -6
- package/dist/cjs/combo-box/combo-box-item.cjs +2 -2
- package/dist/cjs/combo-box/combo-box.cjs +4 -4
- package/dist/cjs/date-field/date-field.cjs +3 -3
- package/dist/cjs/date-picker/date-picker.cjs +3 -3
- package/dist/cjs/date-range-picker/date-range-picker.cjs +5 -5
- package/dist/cjs/field/field.cjs +2 -2
- package/dist/cjs/file-dropzone/file-dropzone.cjs +11 -11
- package/dist/cjs/file-dropzone/file-info.cjs +3 -3
- package/dist/cjs/govt-banner/govt-banner.cjs +3 -3
- package/dist/cjs/hooks/use-callback-ref.cjs +4 -4
- package/dist/cjs/hooks/use-controllable-state.cjs +2 -2
- package/dist/cjs/hooks/use-draggable.cjs +8 -8
- package/dist/cjs/index.cjs +84 -65
- package/dist/cjs/input/input.cjs +2 -2
- package/dist/cjs/menu/menu.cjs +8 -8
- package/dist/cjs/modal/modal-body.cjs +2 -2
- package/dist/cjs/modal/modal-content.cjs +3 -3
- package/dist/cjs/modal/modal-footer.cjs +2 -2
- package/dist/cjs/modal/modal-header.cjs +2 -2
- package/dist/cjs/modal/modal.cjs +3 -3
- package/dist/cjs/navbar/index.cjs +25 -0
- package/dist/cjs/navbar/navbar-brand.cjs +28 -0
- package/dist/cjs/navbar/navbar-content.cjs +33 -0
- package/dist/cjs/navbar/navbar-context.cjs +14 -0
- package/dist/cjs/navbar/navbar-item.cjs +29 -0
- package/dist/cjs/navbar/navbar-menu/i18n.cjs +23 -0
- package/dist/cjs/navbar/navbar-menu/item.cjs +44 -0
- package/dist/cjs/navbar/navbar-menu/menu.cjs +62 -0
- package/dist/cjs/navbar/navbar-menu/toggle.cjs +94 -0
- package/dist/cjs/navbar/navbar.cjs +26 -0
- package/dist/cjs/navbar/use-navbar.cjs +116 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/Overlay.cjs +55 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/PortalProvider.cjs +23 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs +208 -0
- package/dist/cjs/node_modules/.pnpm/@react-aria_ssr@3.9.10_react@19.2.3/node_modules/@react-aria/ssr/dist/SSRProvider.cjs +104 -0
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/Icon.cjs +4 -4
- package/dist/cjs/node_modules/.pnpm/lucide-react@0.475.0_react@19.2.3/node_modules/lucide-react/dist/esm/createLucideIcon.cjs +3 -3
- package/dist/cjs/pagination/hooks/use-pagination.cjs +7 -7
- package/dist/cjs/pagination/pagination.cjs +6 -6
- package/dist/cjs/pagination/use-pagination-item.cjs +3 -3
- package/dist/cjs/pagination/use-pagination.cjs +8 -8
- package/dist/cjs/range-calendar/range-calendar.cjs +6 -6
- package/dist/cjs/ripple/use-ripple.cjs +4 -4
- package/dist/cjs/select/select.cjs +3 -3
- package/dist/cjs/spinner/use-spinner.cjs +3 -3
- package/dist/cjs/system/react-utils/children.cjs +26 -0
- package/dist/cjs/system/react-utils/context.cjs +3 -3
- package/dist/cjs/system/react-utils/refs.cjs +3 -3
- package/dist/cjs/system/utils.cjs +2 -2
- package/dist/cjs/tabs/tabs.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-item.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-list.cjs +4 -4
- package/dist/cjs/tag-field/tag-field-root.cjs +14 -14
- package/dist/cjs/tag-field/tag-field-state-context.cjs +2 -2
- package/dist/cjs/tag-field/tag-field-tag-list.cjs +3 -3
- package/dist/cjs/tag-field/tag-field-trigger.cjs +2 -2
- package/dist/cjs/tag-field/tag-field.cjs +3 -3
- package/dist/cjs/tag-field/use-tag-field-state.cjs +6 -6
- package/dist/cjs/tag-field/use-tag-field.cjs +4 -4
- package/dist/cjs/text-area/text-area.cjs +2 -2
- package/dist/cjs/toast/toast.cjs +1 -1
- package/dist/cjs/toggle/toggle.cjs +3 -3
- package/dist/esm/button/button.js +1 -1
- package/dist/esm/calendar/calendar-month-day-selector.js +2 -2
- package/dist/esm/combo-box/combo-box.js +1 -1
- package/dist/esm/date-picker/date-picker.js +1 -1
- package/dist/esm/date-range-picker/date-range-picker.js +2 -2
- package/dist/esm/file-dropzone/file-dropzone.js +1 -1
- package/dist/esm/index.js +33 -24
- package/dist/esm/menu/menu.js +2 -2
- package/dist/esm/navbar/index.js +10 -0
- package/dist/esm/navbar/navbar-brand.js +26 -0
- package/dist/esm/navbar/navbar-content.js +31 -0
- package/dist/esm/navbar/navbar-context.js +11 -0
- package/dist/esm/navbar/navbar-item.js +27 -0
- package/dist/esm/navbar/navbar-menu/i18n.js +21 -0
- package/dist/esm/navbar/navbar-menu/item.js +42 -0
- package/dist/esm/navbar/navbar-menu/menu.js +60 -0
- package/dist/esm/navbar/navbar-menu/toggle.js +92 -0
- package/dist/esm/navbar/navbar.js +24 -0
- package/dist/esm/navbar/use-navbar.js +114 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/Overlay.js +52 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/PortalProvider.js +20 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/usePreventScroll.js +206 -0
- package/dist/esm/node_modules/.pnpm/@react-aria_ssr@3.9.10_react@19.2.3/node_modules/@react-aria/ssr/dist/SSRProvider.js +102 -0
- package/dist/esm/pagination/use-pagination-item.js +1 -1
- package/dist/esm/select/select.js +1 -1
- package/dist/esm/system/react-utils/children.js +23 -0
- package/dist/esm/tag-field/tag-field.js +1 -1
- package/dist/esm/toast/toast.js +1 -1
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/navbar/index.d.ts +17 -0
- package/dist/types/navbar/index.d.ts.map +1 -0
- package/dist/types/navbar/navbar-brand.d.ts +6 -0
- package/dist/types/navbar/navbar-brand.d.ts.map +1 -0
- package/dist/types/navbar/navbar-content.d.ts +14 -0
- package/dist/types/navbar/navbar-content.d.ts.map +1 -0
- package/dist/types/navbar/navbar-context.d.ts +174 -0
- package/dist/types/navbar/navbar-context.d.ts.map +1 -0
- package/dist/types/navbar/navbar-item.d.ts +11 -0
- package/dist/types/navbar/navbar-item.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/i18n.d.ts +3 -0
- package/dist/types/navbar/navbar-menu/i18n.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/item.d.ts +16 -0
- package/dist/types/navbar/navbar-menu/item.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/menu.d.ts +11 -0
- package/dist/types/navbar/navbar-menu/menu.d.ts.map +1 -0
- package/dist/types/navbar/navbar-menu/toggle.d.ts +12 -0
- package/dist/types/navbar/navbar-menu/toggle.d.ts.map +1 -0
- package/dist/types/navbar/navbar.d.ts +6 -0
- package/dist/types/navbar/navbar.d.ts.map +1 -0
- package/dist/types/navbar/use-navbar.d.ts +131 -0
- package/dist/types/navbar/use-navbar.d.ts.map +1 -0
- package/dist/types/system/react-utils/children.d.ts +10 -0
- package/dist/types/system/react-utils/children.d.ts.map +1 -0
- package/dist/types/system/react-utils/index.d.ts +5 -3
- package/dist/types/system/react-utils/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
8
|
+
var utils = require('../../system/utils.cjs');
|
|
9
|
+
var navbarContext = require('../navbar-context.cjs');
|
|
10
|
+
var refs = require('../../system/react-utils/refs.cjs');
|
|
11
|
+
|
|
12
|
+
const NavbarMenuItem = utils.forwardRef(
|
|
13
|
+
(props, ref) => {
|
|
14
|
+
const { className, children, isActive, ...otherProps } = props;
|
|
15
|
+
const domRef = refs.useDomRef(ref);
|
|
16
|
+
const { isMenuOpen, classNames } = navbarContext.useNavbarContext();
|
|
17
|
+
const renderProps = reactAriaComponents.useRenderProps({
|
|
18
|
+
className: reactAriaComponents.composeRenderProps(
|
|
19
|
+
className,
|
|
20
|
+
(className2, renderProps2) => ouiTheme.navbarMenuItemStyles({
|
|
21
|
+
className: ouiTheme.cn(classNames?.menuItem, className2),
|
|
22
|
+
...renderProps2
|
|
23
|
+
})
|
|
24
|
+
),
|
|
25
|
+
values: {
|
|
26
|
+
isActive: !!isActive
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30
|
+
"li",
|
|
31
|
+
{
|
|
32
|
+
ref: domRef,
|
|
33
|
+
className: renderProps.className,
|
|
34
|
+
"data-active": ouiTheme.dataAttr(isActive),
|
|
35
|
+
"data-open": ouiTheme.dataAttr(isMenuOpen),
|
|
36
|
+
...otherProps,
|
|
37
|
+
children
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
NavbarMenuItem.displayName = "NavbarMenuItem";
|
|
43
|
+
|
|
44
|
+
exports.NavbarMenuItem = NavbarMenuItem;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var Overlay = require('../../node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/Overlay.cjs');
|
|
7
|
+
var reactAria = require('react-aria');
|
|
8
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
9
|
+
var utils = require('../../system/utils.cjs');
|
|
10
|
+
var navbarContext = require('../navbar-context.cjs');
|
|
11
|
+
var refs = require('../../system/react-utils/refs.cjs');
|
|
12
|
+
|
|
13
|
+
const NavbarMenu = utils.forwardRef(
|
|
14
|
+
({ className, children, portalContainer, style, onKeyDown, ...props }, ref) => {
|
|
15
|
+
const domRef = refs.useDomRef(ref);
|
|
16
|
+
const {
|
|
17
|
+
slots,
|
|
18
|
+
isMenuOpen,
|
|
19
|
+
height,
|
|
20
|
+
classNames,
|
|
21
|
+
setIsMenuOpen,
|
|
22
|
+
domRef: parentRef,
|
|
23
|
+
menuRef
|
|
24
|
+
} = navbarContext.useNavbarContext();
|
|
25
|
+
const handleKeyDown = (e) => {
|
|
26
|
+
if (e.key === "Escape") {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
setIsMenuOpen(false);
|
|
29
|
+
menuRef.current?.focus();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
if (!isMenuOpen) return null;
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
Overlay.Overlay,
|
|
35
|
+
{
|
|
36
|
+
disableFocusManagement: true,
|
|
37
|
+
portalContainer: portalContainer ?? parentRef.current ?? void 0,
|
|
38
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
+
"ul",
|
|
40
|
+
{
|
|
41
|
+
ref: domRef,
|
|
42
|
+
className: slots.menu?.({
|
|
43
|
+
className: ouiTheme.cn(classNames?.menu, className)
|
|
44
|
+
}),
|
|
45
|
+
"data-open": ouiTheme.dataAttr(isMenuOpen),
|
|
46
|
+
style: {
|
|
47
|
+
...style,
|
|
48
|
+
// @ts-expect-error due to not having any type declaration for CSS variables in React style prop
|
|
49
|
+
"--navbar-height": typeof height === "number" ? `${height}px` : height
|
|
50
|
+
},
|
|
51
|
+
onKeyDown: reactAria.chain(handleKeyDown, onKeyDown),
|
|
52
|
+
...props,
|
|
53
|
+
children
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
NavbarMenu.displayName = "NavbarMenu";
|
|
61
|
+
|
|
62
|
+
exports.NavbarMenu = NavbarMenu;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var $670gB$react = require('react');
|
|
7
|
+
var reactAria = require('react-aria');
|
|
8
|
+
var reactAriaComponents = require('react-aria-components');
|
|
9
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
10
|
+
var navbarContext = require('../navbar-context.cjs');
|
|
11
|
+
var i18n = require('./i18n.cjs');
|
|
12
|
+
|
|
13
|
+
const NavbarMenuToggle = ({
|
|
14
|
+
icon,
|
|
15
|
+
className,
|
|
16
|
+
onChange,
|
|
17
|
+
classNames,
|
|
18
|
+
size = "sm",
|
|
19
|
+
radius,
|
|
20
|
+
isIconOnly = true,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const {
|
|
24
|
+
slots,
|
|
25
|
+
classNames: contextClassNames,
|
|
26
|
+
isMenuOpen,
|
|
27
|
+
setIsMenuOpen,
|
|
28
|
+
menuRef,
|
|
29
|
+
position
|
|
30
|
+
} = navbarContext.useNavbarContext();
|
|
31
|
+
const shouldScrollToTop = (isMenuOpen2) => {
|
|
32
|
+
if (!isMenuOpen2 || position === "sticky" || typeof window === "undefined") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
window.scrollTo({ top: 0, behavior: "instant" });
|
|
36
|
+
};
|
|
37
|
+
const formatMessage = reactAria.useMessageFormatter(i18n.i18nStrings);
|
|
38
|
+
const toggleStyles = $670gB$react.useMemo(() => {
|
|
39
|
+
return ouiTheme.buttonStyles({
|
|
40
|
+
variant: "unstyled",
|
|
41
|
+
size,
|
|
42
|
+
radius,
|
|
43
|
+
isIconOnly,
|
|
44
|
+
className: slots.toggle({
|
|
45
|
+
className: ouiTheme.cn(
|
|
46
|
+
contextClassNames?.toggle,
|
|
47
|
+
className ?? classNames?.toggle
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
}, [
|
|
52
|
+
className,
|
|
53
|
+
classNames?.toggle,
|
|
54
|
+
contextClassNames?.toggle,
|
|
55
|
+
isIconOnly,
|
|
56
|
+
radius,
|
|
57
|
+
size,
|
|
58
|
+
slots
|
|
59
|
+
]);
|
|
60
|
+
const child = $670gB$react.useMemo(() => {
|
|
61
|
+
if (typeof icon === "function") {
|
|
62
|
+
return icon(isMenuOpen ?? false);
|
|
63
|
+
}
|
|
64
|
+
return icon || /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
"span",
|
|
66
|
+
{
|
|
67
|
+
className: slots.toggleIcon({
|
|
68
|
+
class: ouiTheme.cn(contextClassNames?.toggleIcon, classNames?.toggleIcon)
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}, [
|
|
73
|
+
icon,
|
|
74
|
+
slots,
|
|
75
|
+
classNames?.toggleIcon,
|
|
76
|
+
contextClassNames?.toggleIcon,
|
|
77
|
+
isMenuOpen
|
|
78
|
+
]);
|
|
79
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
reactAriaComponents.ToggleButton,
|
|
81
|
+
{
|
|
82
|
+
"aria-label": isMenuOpen ? formatMessage("closeMenu") : formatMessage("openMenu"),
|
|
83
|
+
ref: menuRef,
|
|
84
|
+
"data-open": ouiTheme.dataAttr(isMenuOpen),
|
|
85
|
+
className: toggleStyles,
|
|
86
|
+
isSelected: isMenuOpen,
|
|
87
|
+
onChange: reactAria.chain(onChange, shouldScrollToTop, setIsMenuOpen),
|
|
88
|
+
...props,
|
|
89
|
+
children: child
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
exports.NavbarMenuToggle = NavbarMenuToggle;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var reactAria = require('react-aria');
|
|
7
|
+
var children = require('../system/react-utils/children.cjs');
|
|
8
|
+
var utils = require('../system/utils.cjs');
|
|
9
|
+
var navbarContext = require('./navbar-context.cjs');
|
|
10
|
+
var menu = require('./navbar-menu/menu.cjs');
|
|
11
|
+
var useNavbar = require('./use-navbar.cjs');
|
|
12
|
+
|
|
13
|
+
const Navbar = utils.forwardRef((props, ref) => {
|
|
14
|
+
const { children: children$1, ...otherProps } = props;
|
|
15
|
+
const context = useNavbar.useNavbar({ ...otherProps, ref });
|
|
16
|
+
const Component = context.Component;
|
|
17
|
+
const [childrenWithoutMenu, menu$1] = children.pickChildren(children$1, menu.NavbarMenu);
|
|
18
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
19
|
+
/* @__PURE__ */ jsxRuntime.jsx("header", { ...context.getWrapperProps(), children: childrenWithoutMenu }),
|
|
20
|
+
menu$1
|
|
21
|
+
] });
|
|
22
|
+
return /* @__PURE__ */ jsxRuntime.jsx(navbarContext.NavbarProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsx(reactAria.FocusScope, { contain: context.isMenuOpen, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ...context.getBaseProps(), children: content }) }) });
|
|
23
|
+
});
|
|
24
|
+
Navbar.displayName = "Navbar";
|
|
25
|
+
|
|
26
|
+
exports.Navbar = Navbar;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
var $670gB$react = require('react');
|
|
6
|
+
var usePreventScroll = require('../node_modules/.pnpm/@react-aria_overlays@3.30.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/@react-aria/overlays/dist/usePreventScroll.cjs');
|
|
7
|
+
var utils$2 = require('@react-aria/utils');
|
|
8
|
+
var utils$1 = require('@react-stately/utils');
|
|
9
|
+
var useDeepCompare = require('use-deep-compare');
|
|
10
|
+
var ouiTheme = require('@opengovsg/oui-theme');
|
|
11
|
+
var utils = require('../system/utils.cjs');
|
|
12
|
+
var refs = require('../system/react-utils/refs.cjs');
|
|
13
|
+
|
|
14
|
+
function useNavbar(originalProps) {
|
|
15
|
+
const [
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
as,
|
|
19
|
+
height = "4rem",
|
|
20
|
+
shouldBlockScroll = true,
|
|
21
|
+
isMenuOpen: isMenuOpenProp,
|
|
22
|
+
isMenuDefaultOpen,
|
|
23
|
+
onMenuOpenChange = () => {
|
|
24
|
+
},
|
|
25
|
+
className,
|
|
26
|
+
classNames,
|
|
27
|
+
...otherProps
|
|
28
|
+
},
|
|
29
|
+
variantProps
|
|
30
|
+
] = utils.mapPropsVariants(originalProps, ouiTheme.navbarStyles.variantKeys);
|
|
31
|
+
const Component = as || "nav";
|
|
32
|
+
const domRef = refs.useDomRef(ref);
|
|
33
|
+
const menuRef = $670gB$react.useRef(null);
|
|
34
|
+
const prevWidth = $670gB$react.useRef(0);
|
|
35
|
+
const navHeight = $670gB$react.useRef(0);
|
|
36
|
+
const handleMenuOpenChange = $670gB$react.useCallback(
|
|
37
|
+
(isOpen) => {
|
|
38
|
+
onMenuOpenChange(isOpen || false);
|
|
39
|
+
},
|
|
40
|
+
[onMenuOpenChange]
|
|
41
|
+
);
|
|
42
|
+
const [isMenuOpen, setIsMenuOpen] = utils$1.useControlledState(
|
|
43
|
+
isMenuOpenProp,
|
|
44
|
+
isMenuDefaultOpen ?? false,
|
|
45
|
+
handleMenuOpenChange
|
|
46
|
+
);
|
|
47
|
+
const updateWidth = $670gB$react.useCallback(() => {
|
|
48
|
+
if (domRef.current) {
|
|
49
|
+
const width = domRef.current.offsetWidth;
|
|
50
|
+
if (width !== prevWidth.current) {
|
|
51
|
+
prevWidth.current = width;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}, [domRef]);
|
|
55
|
+
usePreventScroll.usePreventScroll({
|
|
56
|
+
isDisabled: !(shouldBlockScroll && isMenuOpen)
|
|
57
|
+
});
|
|
58
|
+
utils$2.useResizeObserver({
|
|
59
|
+
ref: domRef,
|
|
60
|
+
onResize: () => {
|
|
61
|
+
const currentWidth = domRef.current?.offsetWidth;
|
|
62
|
+
const scrollWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
63
|
+
if (currentWidth && currentWidth + scrollWidth == prevWidth.current) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (currentWidth !== prevWidth.current) {
|
|
67
|
+
updateWidth();
|
|
68
|
+
setIsMenuOpen(false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
$670gB$react.useEffect(() => {
|
|
73
|
+
updateWidth();
|
|
74
|
+
navHeight.current = domRef.current?.offsetHeight || 0;
|
|
75
|
+
}, [domRef, updateWidth]);
|
|
76
|
+
const slots = useDeepCompare.useDeepCompareMemo(
|
|
77
|
+
() => ouiTheme.navbarStyles({
|
|
78
|
+
...variantProps
|
|
79
|
+
}),
|
|
80
|
+
[variantProps]
|
|
81
|
+
);
|
|
82
|
+
const baseStyles = ouiTheme.cn(classNames?.base, className);
|
|
83
|
+
const getBaseProps = (props = {}) => ({
|
|
84
|
+
...utils$2.mergeProps(otherProps, props),
|
|
85
|
+
"data-menu-open": ouiTheme.dataAttr(isMenuOpen),
|
|
86
|
+
ref: domRef,
|
|
87
|
+
className: slots.base({ class: ouiTheme.cn(baseStyles, props?.className) }),
|
|
88
|
+
style: {
|
|
89
|
+
"--navbar-height": typeof height === "number" ? `${height}px` : height,
|
|
90
|
+
...otherProps?.style,
|
|
91
|
+
...props?.style
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const getWrapperProps = (props = {}) => ({
|
|
95
|
+
...props,
|
|
96
|
+
"data-menu-open": ouiTheme.dataAttr(isMenuOpen),
|
|
97
|
+
className: slots.wrapper({
|
|
98
|
+
class: ouiTheme.cn(classNames?.wrapper, props?.className)
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
Component,
|
|
103
|
+
slots,
|
|
104
|
+
domRef,
|
|
105
|
+
height,
|
|
106
|
+
isMenuOpen,
|
|
107
|
+
classNames,
|
|
108
|
+
setIsMenuOpen,
|
|
109
|
+
menuRef,
|
|
110
|
+
getBaseProps,
|
|
111
|
+
getWrapperProps,
|
|
112
|
+
position: variantProps.position ?? "sticky"
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
exports.useNavbar = useNavbar;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PortalProvider = require('./PortalProvider.cjs');
|
|
4
|
+
var interactions = require('@react-aria/interactions');
|
|
5
|
+
var focus = require('@react-aria/focus');
|
|
6
|
+
var $670gB$react = require('react');
|
|
7
|
+
var $4AOtR$reactdom = require('react-dom');
|
|
8
|
+
var SSRProvider = require('../../../../../@react-aria_ssr@3.9.10_react@19.2.3/node_modules/@react-aria/ssr/dist/SSRProvider.cjs');
|
|
9
|
+
require('@react-aria/utils');
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const $337b884510726a0d$export$a2200b96afd16271 = /*#__PURE__*/ ($670gB$react).createContext(null);
|
|
29
|
+
function $337b884510726a0d$export$c6fdb837b070b4ff(props) {
|
|
30
|
+
let isSSR = (SSRProvider.useIsSSR)();
|
|
31
|
+
let { portalContainer: portalContainer = isSSR ? null : document.body, isExiting: isExiting } = props;
|
|
32
|
+
let [contain, setContain] = ($670gB$react.useState)(false);
|
|
33
|
+
let contextValue = ($670gB$react.useMemo)(()=>({
|
|
34
|
+
contain: contain,
|
|
35
|
+
setContain: setContain
|
|
36
|
+
}), [
|
|
37
|
+
contain,
|
|
38
|
+
setContain
|
|
39
|
+
]);
|
|
40
|
+
let { getContainer: getContainer } = (PortalProvider.useUNSAFE_PortalContext)();
|
|
41
|
+
if (!props.portalContainer && getContainer) portalContainer = getContainer();
|
|
42
|
+
if (!portalContainer) return null;
|
|
43
|
+
let contents = props.children;
|
|
44
|
+
if (!props.disableFocusManagement) contents = /*#__PURE__*/ ($670gB$react).createElement((focus.FocusScope), {
|
|
45
|
+
restoreFocus: true,
|
|
46
|
+
contain: (props.shouldContainFocus || contain) && !isExiting
|
|
47
|
+
}, contents);
|
|
48
|
+
contents = /*#__PURE__*/ ($670gB$react).createElement($337b884510726a0d$export$a2200b96afd16271.Provider, {
|
|
49
|
+
value: contextValue
|
|
50
|
+
}, /*#__PURE__*/ ($670gB$react).createElement((interactions.ClearPressResponder), null, contents));
|
|
51
|
+
return /*#__PURE__*/ ($4AOtR$reactdom).createPortal(contents, portalContainer);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.Overlay = $337b884510726a0d$export$c6fdb837b070b4ff;
|
|
55
|
+
exports.OverlayContext = $337b884510726a0d$export$a2200b96afd16271;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var $670gB$react = require('react');
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const $96b38030c423d352$export$60d741e20e0aa309 = /*#__PURE__*/ ($670gB$react.createContext)({});
|
|
17
|
+
function $96b38030c423d352$export$9fc1347d4195ccb3() {
|
|
18
|
+
var _useContext;
|
|
19
|
+
return (_useContext = ($670gB$react.useContext)($96b38030c423d352$export$60d741e20e0aa309)) !== null && _useContext !== void 0 ? _useContext : {};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.PortalContext = $96b38030c423d352$export$60d741e20e0aa309;
|
|
23
|
+
exports.useUNSAFE_PortalContext = $96b38030c423d352$export$9fc1347d4195ccb3;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@react-aria/utils');
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const $49c51c25361d4cd2$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
17
|
+
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
18
|
+
let $49c51c25361d4cd2$var$preventScrollCount = 0;
|
|
19
|
+
let $49c51c25361d4cd2$var$restore;
|
|
20
|
+
function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18(options = {}) {
|
|
21
|
+
let { isDisabled: isDisabled } = options;
|
|
22
|
+
(utils.useLayoutEffect)(()=>{
|
|
23
|
+
if (isDisabled) return;
|
|
24
|
+
$49c51c25361d4cd2$var$preventScrollCount++;
|
|
25
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 1) {
|
|
26
|
+
if ((utils.isIOS)()) $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollMobileSafari();
|
|
27
|
+
else $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollStandard();
|
|
28
|
+
}
|
|
29
|
+
return ()=>{
|
|
30
|
+
$49c51c25361d4cd2$var$preventScrollCount--;
|
|
31
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 0) $49c51c25361d4cd2$var$restore();
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
isDisabled
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
38
|
+
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
39
|
+
function $49c51c25361d4cd2$var$preventScrollStandard() {
|
|
40
|
+
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
41
|
+
return (utils.chain)(scrollbarWidth > 0 && // Use scrollbar-gutter when supported because it also works for fixed positioned elements.
|
|
42
|
+
('scrollbarGutter' in document.documentElement.style ? $49c51c25361d4cd2$var$setStyle(document.documentElement, 'scrollbarGutter', 'stable') : $49c51c25361d4cd2$var$setStyle(document.documentElement, 'paddingRight', `${scrollbarWidth}px`)), $49c51c25361d4cd2$var$setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
43
|
+
}
|
|
44
|
+
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
45
|
+
// it still scrolls the page in many situations:
|
|
46
|
+
//
|
|
47
|
+
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
48
|
+
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
49
|
+
// it, so it becomes scrollable.
|
|
50
|
+
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
51
|
+
// This may cause even fixed position elements to scroll off the screen.
|
|
52
|
+
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
53
|
+
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
54
|
+
//
|
|
55
|
+
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
56
|
+
//
|
|
57
|
+
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
58
|
+
// on the window.
|
|
59
|
+
// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at
|
|
60
|
+
// the top or bottom. Work around a bug where this does not work when the element does not actually overflow
|
|
61
|
+
// by preventing default in a `touchmove` event. This is best effort: we can't prevent default when pinch
|
|
62
|
+
// zooming or when an element contains text selection, which may allow scrolling in some cases.
|
|
63
|
+
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
64
|
+
// 4. When focus moves to an input, create an off screen input and focus that temporarily. This prevents
|
|
65
|
+
// Safari from scrolling the page. After a small delay, focus the real input and scroll it into view
|
|
66
|
+
// ourselves, without scrolling the whole page.
|
|
67
|
+
function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
68
|
+
let scrollable;
|
|
69
|
+
let allowTouchMove = false;
|
|
70
|
+
let onTouchStart = (e)=>{
|
|
71
|
+
// Store the nearest scrollable parent element from the element that the user touched.
|
|
72
|
+
let target = e.target;
|
|
73
|
+
scrollable = (utils.isScrollable)(target) ? target : (utils.getScrollParent)(target, true);
|
|
74
|
+
allowTouchMove = false;
|
|
75
|
+
// If the target is selected, don't preventDefault in touchmove to allow user to adjust selection.
|
|
76
|
+
let selection = target.ownerDocument.defaultView.getSelection();
|
|
77
|
+
if (selection && !selection.isCollapsed && selection.containsNode(target, true)) allowTouchMove = true;
|
|
78
|
+
// If this is a focused input element with a selected range, allow user to drag the selection handles.
|
|
79
|
+
if ('selectionStart' in target && 'selectionEnd' in target && target.selectionStart < target.selectionEnd && target.ownerDocument.activeElement === target) allowTouchMove = true;
|
|
80
|
+
};
|
|
81
|
+
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
82
|
+
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
83
|
+
// the window instead.
|
|
84
|
+
// This must be applied before the touchstart event as of iOS 26, so inject it as a <style> element.
|
|
85
|
+
let style = document.createElement('style');
|
|
86
|
+
style.textContent = `
|
|
87
|
+
@layer {
|
|
88
|
+
* {
|
|
89
|
+
overscroll-behavior: contain;
|
|
90
|
+
}
|
|
91
|
+
}`.trim();
|
|
92
|
+
document.head.prepend(style);
|
|
93
|
+
let onTouchMove = (e)=>{
|
|
94
|
+
// Allow pinch-zooming.
|
|
95
|
+
if (e.touches.length === 2 || allowTouchMove) return;
|
|
96
|
+
// Prevent scrolling the window.
|
|
97
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// overscroll-behavior should prevent scroll chaining, but currently does not
|
|
102
|
+
// if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452
|
|
103
|
+
// This checks that both the width and height do not overflow, otherwise we might
|
|
104
|
+
// block horizontal scrolling too. In that case, adding `touch-action: pan-x` to
|
|
105
|
+
// the element will prevent vertical page scrolling. We can't add that automatically
|
|
106
|
+
// because it must be set before the touchstart event.
|
|
107
|
+
if (scrollable.scrollHeight === scrollable.clientHeight && scrollable.scrollWidth === scrollable.clientWidth) e.preventDefault();
|
|
108
|
+
};
|
|
109
|
+
let onBlur = (e)=>{
|
|
110
|
+
let target = e.target;
|
|
111
|
+
let relatedTarget = e.relatedTarget;
|
|
112
|
+
if (relatedTarget && (utils.willOpenKeyboard)(relatedTarget)) {
|
|
113
|
+
// Focus without scrolling the whole page, and then scroll into view manually.
|
|
114
|
+
relatedTarget.focus({
|
|
115
|
+
preventScroll: true
|
|
116
|
+
});
|
|
117
|
+
$49c51c25361d4cd2$var$scrollIntoViewWhenReady(relatedTarget, (utils.willOpenKeyboard)(target));
|
|
118
|
+
} else if (!relatedTarget) {
|
|
119
|
+
var _target_parentElement;
|
|
120
|
+
// When tapping the Done button on the keyboard, focus moves to the body.
|
|
121
|
+
// FocusScope will then restore focus back to the input. Later when tapping
|
|
122
|
+
// the same input again, it is already focused, so no blur event will fire,
|
|
123
|
+
// resulting in the flow above never running and Safari's native scrolling occurring.
|
|
124
|
+
// Instead, move focus to the parent focusable element (e.g. the dialog).
|
|
125
|
+
let focusable = (_target_parentElement = target.parentElement) === null || _target_parentElement === void 0 ? void 0 : _target_parentElement.closest('[tabindex]');
|
|
126
|
+
focusable === null || focusable === void 0 ? void 0 : focusable.focus({
|
|
127
|
+
preventScroll: true
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
// Override programmatic focus to scroll into view without scrolling the whole page.
|
|
132
|
+
let focus = HTMLElement.prototype.focus;
|
|
133
|
+
HTMLElement.prototype.focus = function(opts) {
|
|
134
|
+
// Track whether the keyboard was already visible before.
|
|
135
|
+
let wasKeyboardVisible = document.activeElement != null && (utils.willOpenKeyboard)(document.activeElement);
|
|
136
|
+
// Focus the element without scrolling the page.
|
|
137
|
+
focus.call(this, {
|
|
138
|
+
...opts,
|
|
139
|
+
preventScroll: true
|
|
140
|
+
});
|
|
141
|
+
if (!opts || !opts.preventScroll) $49c51c25361d4cd2$var$scrollIntoViewWhenReady(this, wasKeyboardVisible);
|
|
142
|
+
};
|
|
143
|
+
let removeEvents = (utils.chain)($49c51c25361d4cd2$var$addEvent(document, 'touchstart', onTouchStart, {
|
|
144
|
+
passive: false,
|
|
145
|
+
capture: true
|
|
146
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'touchmove', onTouchMove, {
|
|
147
|
+
passive: false,
|
|
148
|
+
capture: true
|
|
149
|
+
}), $49c51c25361d4cd2$var$addEvent(document, 'blur', onBlur, true));
|
|
150
|
+
return ()=>{
|
|
151
|
+
removeEvents();
|
|
152
|
+
style.remove();
|
|
153
|
+
HTMLElement.prototype.focus = focus;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
157
|
+
function $49c51c25361d4cd2$var$setStyle(element, style, value) {
|
|
158
|
+
let cur = element.style[style];
|
|
159
|
+
element.style[style] = value;
|
|
160
|
+
return ()=>{
|
|
161
|
+
element.style[style] = cur;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Adds an event listener to an element, and returns a function to remove it.
|
|
165
|
+
function $49c51c25361d4cd2$var$addEvent(target, event, handler, options) {
|
|
166
|
+
// internal function, so it's ok to ignore the difficult to fix type error
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
target.addEventListener(event, handler, options);
|
|
169
|
+
return ()=>{
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
target.removeEventListener(event, handler, options);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function $49c51c25361d4cd2$var$scrollIntoViewWhenReady(target, wasKeyboardVisible) {
|
|
175
|
+
if (wasKeyboardVisible || !$49c51c25361d4cd2$var$visualViewport) // If the keyboard was already visible, scroll the target into view immediately.
|
|
176
|
+
$49c51c25361d4cd2$var$scrollIntoView(target);
|
|
177
|
+
else // Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
178
|
+
// measure the correct position to scroll to.
|
|
179
|
+
$49c51c25361d4cd2$var$visualViewport.addEventListener('resize', ()=>$49c51c25361d4cd2$var$scrollIntoView(target), {
|
|
180
|
+
once: true
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function $49c51c25361d4cd2$var$scrollIntoView(target) {
|
|
184
|
+
let root = document.scrollingElement || document.documentElement;
|
|
185
|
+
let nextTarget = target;
|
|
186
|
+
while(nextTarget && nextTarget !== root){
|
|
187
|
+
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
188
|
+
let scrollable = (utils.getScrollParent)(nextTarget);
|
|
189
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== nextTarget) {
|
|
190
|
+
let scrollableRect = scrollable.getBoundingClientRect();
|
|
191
|
+
let targetRect = nextTarget.getBoundingClientRect();
|
|
192
|
+
if (targetRect.top < scrollableRect.top || targetRect.bottom > scrollableRect.top + nextTarget.clientHeight) {
|
|
193
|
+
let bottom = scrollableRect.bottom;
|
|
194
|
+
if ($49c51c25361d4cd2$var$visualViewport) bottom = Math.min(bottom, $49c51c25361d4cd2$var$visualViewport.offsetTop + $49c51c25361d4cd2$var$visualViewport.height);
|
|
195
|
+
// Center within the viewport.
|
|
196
|
+
let adjustment = targetRect.top - scrollableRect.top - ((bottom - scrollableRect.top) / 2 - targetRect.height / 2);
|
|
197
|
+
scrollable.scrollTo({
|
|
198
|
+
// Clamp to the valid range to prevent over-scrolling.
|
|
199
|
+
top: Math.max(0, Math.min(scrollable.scrollHeight - scrollable.clientHeight, scrollable.scrollTop + adjustment)),
|
|
200
|
+
behavior: 'smooth'
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
nextTarget = scrollable.parentElement;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
exports.usePreventScroll = $49c51c25361d4cd2$export$ee0f7cc6afcd1c18;
|