@telia/teddy 0.0.39 → 0.0.40

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.
@@ -6,4 +6,7 @@ require("../navigation-menu.cjs");
6
6
  const components_navigationMenu_globalNavigation_globalNavigationMyPages = require("./global-navigation-my-pages.cjs");
7
7
  require("./utils.cjs");
8
8
  require("../../box/box.cjs");
9
+ require("../../../utils/useSize.cjs");
10
+ require("../../../utils/generate-styling/index.cjs");
11
+ require("../../../utils/useCallbackRef.cjs");
9
12
  exports.Desktop = components_navigationMenu_globalNavigation_globalNavigationMyPages.Desktop;
@@ -4,6 +4,9 @@ import "../navigation-menu.js";
4
4
  import { D } from "./global-navigation-my-pages.js";
5
5
  import "./utils.js";
6
6
  import "../../box/box.js";
7
+ import "../../../utils/useSize.js";
8
+ import "../../../utils/generate-styling/index.js";
9
+ import "../../../utils/useCallbackRef.js";
7
10
  export {
8
11
  D as Desktop
9
12
  };
@@ -19,20 +19,29 @@ const utils_composeRefs = require("../../../utils/composeRefs.cjs");
19
19
  require("../../badge/badge.cjs");
20
20
  require("../../badge/alert-badge.cjs");
21
21
  const components_badge_counterBadge = require("../../badge/counter-badge.cjs");
22
+ const utils_useSize = require("../../../utils/useSize.cjs");
23
+ const utils_generateStyling_index = require("../../../utils/generate-styling/index.cjs");
24
+ const utils_useCallbackRef = require("../../../utils/useCallbackRef.cjs");
22
25
  const components_flex_flex = require("../../flex/flex.cjs");
23
26
  const components_accordion_index = require("../../accordion/index.cjs");
24
27
  const components_visuallyHidden_visuallyHidden = require("../../visually-hidden/visually-hidden.cjs");
25
28
  const components_link_link = require("../../link/link.cjs");
26
29
  const components_list_index = require("../../list/index.cjs");
27
30
  const styles = {
28
- "teddy-global-navigation": "_teddy-global-navigation_1t5v4_1",
29
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1t5v4_6",
30
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1t5v4_9",
31
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1t5v4_6",
32
- "teddy-global-navigation__link": "_teddy-global-navigation__link_1t5v4_26",
33
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1t5v4_29",
34
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1t5v4_32",
35
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1t5v4_35"
31
+ "teddy-global-navigation": "_teddy-global-navigation_1ue02_1",
32
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1ue02_6",
33
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1ue02_9",
34
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1ue02_6",
35
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1ue02_26",
36
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1ue02_29",
37
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1ue02_32",
38
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1ue02_35",
39
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1ue02_43",
40
+ "expand-viewport": "_expand-viewport_1ue02_1",
41
+ "close-viewport": "_close-viewport_1ue02_1",
42
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1ue02_53",
43
+ "expand-top-menu": "_expand-top-menu_1ue02_1",
44
+ "close-top-menu": "_close-top-menu_1ue02_1"
36
45
  };
37
46
  function MyPages(props) {
38
47
  var _a, _b;
@@ -186,15 +195,79 @@ const ShoppingCart = React.forwardRef(() => {
186
195
  ] });
187
196
  });
188
197
  ShoppingCart.displayName = "ShoppingCart";
198
+ const scrollDistanceDownThreshold = 200;
199
+ const scrollDistanceUpThreshold = 50;
200
+ const ANIMATION_DURATION = 300;
189
201
  const Desktop = React.forwardRef(() => {
190
202
  const rootContext = React.useContext(RootContext);
203
+ const [hideMenu, setHideMenu] = React.useState(false);
204
+ const lastScrollDirection = React.useRef();
205
+ const scrollStartPos = React.useRef(0);
206
+ const lastScrollPos = React.useRef(0);
207
+ const topMenuRef = React.useRef(null);
208
+ const viewPortRef = React.useRef(null);
209
+ const viewPortSize = utils_useSize.useSize(viewPortRef.current);
210
+ const topMenuSize = utils_useSize.useSize(topMenuRef.current);
211
+ const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
212
+ const viewPortHeight = (viewPortSize == null ? void 0 : viewPortSize.height) ? `${viewPortSize.height}px` : void 0;
213
+ const animationTimer = React.useRef(0);
214
+ const handleScroll = () => {
215
+ let compensateHight = 0;
216
+ if (animationTimer.current > 0) {
217
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
218
+ if (animationTimer.current + ANIMATION_DURATION > currentTime) {
219
+ compensateHight = ((topMenuSize == null ? void 0 : topMenuSize.height) || 0) + ((viewPortSize == null ? void 0 : viewPortSize.height) || 0);
220
+ } else {
221
+ animationTimer.current = 0;
222
+ }
223
+ }
224
+ const scrollY = window.scrollY;
225
+ const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
226
+ const scrollDistance = Math.abs(scrollStartPos.current - scrollY);
227
+ if (scrollDirection !== lastScrollDirection.current) {
228
+ scrollStartPos.current = scrollY;
229
+ }
230
+ if (!hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "down" && scrollDistance > scrollDistanceDownThreshold + compensateHight) {
231
+ setHideMenu(true);
232
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
233
+ animationTimer.current = currentTime;
234
+ }
235
+ if (hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "up" && scrollDistance > scrollDistanceUpThreshold + compensateHight || scrollY === 0) {
236
+ setHideMenu(false);
237
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
238
+ animationTimer.current = currentTime;
239
+ }
240
+ lastScrollDirection.current = scrollDirection;
241
+ lastScrollPos.current = scrollY;
242
+ };
243
+ const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
244
+ React.useEffect(() => {
245
+ window.addEventListener("scroll", throttledScrollHandler);
246
+ return () => {
247
+ window.removeEventListener("scroll", throttledScrollHandler);
248
+ };
249
+ }, [throttledScrollHandler]);
191
250
  if (!rootContext)
192
251
  return null;
252
+ function resetAndShowMenu() {
253
+ lastScrollDirection.current = null;
254
+ scrollStartPos.current = window.scrollY;
255
+ lastScrollPos.current = window.scrollY;
256
+ setHideMenu(false);
257
+ }
193
258
  const { setSelectedMenuItem, linkComponent: Link } = rootContext;
194
259
  const currentLocation = rootContext.pathname;
195
260
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
196
- /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuList, { children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: link.link, children: link.name }) }) }, link.name)) }),
197
- components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsxs(components_navigationMenu_navigationMenu.NavigationMenu.List, { value: link.name, children: [
261
+ /* @__PURE__ */ jsxRuntime.jsx(
262
+ "div",
263
+ {
264
+ style: utils_generateStyling_index.mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
265
+ className: styles[`${rootClassName}__top-menu-wrapper`],
266
+ "data-state": hideMenu ? "closed" : "open",
267
+ children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link, { href: link.link, children: link.name }) }) }, link.name)) })
268
+ }
269
+ ),
270
+ components_navigationMenu_globalNavigation_utils.LINKS.map((link) => /* @__PURE__ */ jsxRuntime.jsxs(components_navigationMenu_navigationMenu.NavigationMenu.List, { onFocus: resetAndShowMenu, value: link.name, children: [
198
271
  link.links.map((subLink) => /* @__PURE__ */ jsxRuntime.jsxs(components_navigationMenu_navigationMenu.NavigationMenu.Item, { value: subLink.name, children: [
199
272
  subLink.name === "Logo" ? /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsxRuntime.jsx(Link, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsxRuntime.jsx(
200
273
  "img",
@@ -239,10 +312,34 @@ const Desktop = React.forwardRef(() => {
239
312
  /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(ShoppingCart, {}) }),
240
313
  /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(MyPages, {}) })
241
314
  ] }, link.name)),
242
- /* @__PURE__ */ jsxRuntime.jsx(components_navigationMenu_navigationMenu.NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
315
+ /* @__PURE__ */ jsxRuntime.jsx(
316
+ "div",
317
+ {
318
+ style: utils_generateStyling_index.mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
319
+ className: styles[`${rootClassName}__viewport-wrapper`],
320
+ "data-state": hideMenu ? "closed" : "open",
321
+ children: /* @__PURE__ */ jsxRuntime.jsx(
322
+ components_navigationMenu_navigationMenu.NavigationMenu.Viewport,
323
+ {
324
+ onFocus: resetAndShowMenu,
325
+ ref: viewPortRef,
326
+ className: styles[`${rootClassName}__viewport`]
327
+ }
328
+ )
329
+ }
330
+ )
243
331
  ] });
244
332
  });
245
333
  Desktop.displayName = "Desktop";
334
+ function useDebounceCallback(callback, delay) {
335
+ const handleCallback = utils_useCallbackRef.useCallbackRef(callback);
336
+ const debounceTimerRef = React.useRef(0);
337
+ React.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
338
+ return React.useCallback(() => {
339
+ window.clearTimeout(debounceTimerRef.current);
340
+ debounceTimerRef.current = window.setTimeout(handleCallback, delay);
341
+ }, [handleCallback, delay]);
342
+ }
246
343
  function Mobile(props) {
247
344
  const rootContext = React.useContext(RootContext);
248
345
  const drawerRef = React.useRef(null);
@@ -17,20 +17,29 @@ import { useComposedRefs } from "../../../utils/composeRefs.js";
17
17
  import "../../badge/badge.js";
18
18
  import "../../badge/alert-badge.js";
19
19
  import { CounterBadge } from "../../badge/counter-badge.js";
20
+ import { useSize } from "../../../utils/useSize.js";
21
+ import { mergeStyles } from "../../../utils/generate-styling/index.js";
22
+ import { useCallbackRef } from "../../../utils/useCallbackRef.js";
20
23
  import { Flex } from "../../flex/flex.js";
21
24
  import { Accordion } from "../../accordion/index.js";
22
25
  import { VisuallyHidden } from "../../visually-hidden/visually-hidden.js";
23
26
  import { Link } from "../../link/link.js";
24
27
  import { List } from "../../list/index.js";
25
28
  const styles = {
26
- "teddy-global-navigation": "_teddy-global-navigation_1t5v4_1",
27
- "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1t5v4_6",
28
- "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1t5v4_9",
29
- "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1t5v4_6",
30
- "teddy-global-navigation__link": "_teddy-global-navigation__link_1t5v4_26",
31
- "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1t5v4_29",
32
- "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1t5v4_32",
33
- "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1t5v4_35"
29
+ "teddy-global-navigation": "_teddy-global-navigation_1ue02_1",
30
+ "teddy-global-navigation__mobile-trigger": "_teddy-global-navigation__mobile-trigger_1ue02_6",
31
+ "teddy-global-navigation__mobile-header": "_teddy-global-navigation__mobile-header_1ue02_9",
32
+ "teddy-global-navigation__mobile": "_teddy-global-navigation__mobile_1ue02_6",
33
+ "teddy-global-navigation__link": "_teddy-global-navigation__link_1ue02_26",
34
+ "teddy-global-navigation__viewport": "_teddy-global-navigation__viewport_1ue02_29",
35
+ "teddy-global-navigation__item-wrapper": "_teddy-global-navigation__item-wrapper_1ue02_32",
36
+ "teddy-global-navigation__item-count": "_teddy-global-navigation__item-count_1ue02_35",
37
+ "teddy-global-navigation__viewport-wrapper": "_teddy-global-navigation__viewport-wrapper_1ue02_43",
38
+ "expand-viewport": "_expand-viewport_1ue02_1",
39
+ "close-viewport": "_close-viewport_1ue02_1",
40
+ "teddy-global-navigation__top-menu-wrapper": "_teddy-global-navigation__top-menu-wrapper_1ue02_53",
41
+ "expand-top-menu": "_expand-top-menu_1ue02_1",
42
+ "close-top-menu": "_close-top-menu_1ue02_1"
34
43
  };
35
44
  function MyPages(props) {
36
45
  var _a, _b;
@@ -184,15 +193,79 @@ const ShoppingCart = React__default.forwardRef(() => {
184
193
  ] });
185
194
  });
186
195
  ShoppingCart.displayName = "ShoppingCart";
196
+ const scrollDistanceDownThreshold = 200;
197
+ const scrollDistanceUpThreshold = 50;
198
+ const ANIMATION_DURATION = 300;
187
199
  const Desktop = React__default.forwardRef(() => {
188
200
  const rootContext = React__default.useContext(RootContext);
201
+ const [hideMenu, setHideMenu] = React__default.useState(false);
202
+ const lastScrollDirection = React__default.useRef();
203
+ const scrollStartPos = React__default.useRef(0);
204
+ const lastScrollPos = React__default.useRef(0);
205
+ const topMenuRef = React__default.useRef(null);
206
+ const viewPortRef = React__default.useRef(null);
207
+ const viewPortSize = useSize(viewPortRef.current);
208
+ const topMenuSize = useSize(topMenuRef.current);
209
+ const topMenuHeight = (topMenuSize == null ? void 0 : topMenuSize.height) ? `${topMenuSize.height}px` : void 0;
210
+ const viewPortHeight = (viewPortSize == null ? void 0 : viewPortSize.height) ? `${viewPortSize.height}px` : void 0;
211
+ const animationTimer = React__default.useRef(0);
212
+ const handleScroll = () => {
213
+ let compensateHight = 0;
214
+ if (animationTimer.current > 0) {
215
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
216
+ if (animationTimer.current + ANIMATION_DURATION > currentTime) {
217
+ compensateHight = ((topMenuSize == null ? void 0 : topMenuSize.height) || 0) + ((viewPortSize == null ? void 0 : viewPortSize.height) || 0);
218
+ } else {
219
+ animationTimer.current = 0;
220
+ }
221
+ }
222
+ const scrollY = window.scrollY;
223
+ const scrollDirection = scrollY > lastScrollPos.current ? "down" : "up";
224
+ const scrollDistance = Math.abs(scrollStartPos.current - scrollY);
225
+ if (scrollDirection !== lastScrollDirection.current) {
226
+ scrollStartPos.current = scrollY;
227
+ }
228
+ if (!hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "down" && scrollDistance > scrollDistanceDownThreshold + compensateHight) {
229
+ setHideMenu(true);
230
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
231
+ animationTimer.current = currentTime;
232
+ }
233
+ if (hideMenu && scrollDirection === lastScrollDirection.current && scrollDirection === "up" && scrollDistance > scrollDistanceUpThreshold + compensateHight || scrollY === 0) {
234
+ setHideMenu(false);
235
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
236
+ animationTimer.current = currentTime;
237
+ }
238
+ lastScrollDirection.current = scrollDirection;
239
+ lastScrollPos.current = scrollY;
240
+ };
241
+ const throttledScrollHandler = useDebounceCallback(handleScroll, 5);
242
+ React__default.useEffect(() => {
243
+ window.addEventListener("scroll", throttledScrollHandler);
244
+ return () => {
245
+ window.removeEventListener("scroll", throttledScrollHandler);
246
+ };
247
+ }, [throttledScrollHandler]);
189
248
  if (!rootContext)
190
249
  return null;
250
+ function resetAndShowMenu() {
251
+ lastScrollDirection.current = null;
252
+ scrollStartPos.current = window.scrollY;
253
+ lastScrollPos.current = window.scrollY;
254
+ setHideMenu(false);
255
+ }
191
256
  const { setSelectedMenuItem, linkComponent: Link2 } = rootContext;
192
257
  const currentLocation = rootContext.pathname;
193
258
  return /* @__PURE__ */ jsxs(Fragment, { children: [
194
- /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) }) }, link.name)) }),
195
- LINKS.map((link) => /* @__PURE__ */ jsxs(NavigationMenu.List, { value: link.name, children: [
259
+ /* @__PURE__ */ jsx(
260
+ "div",
261
+ {
262
+ style: mergeStyles({ ["--teddy-top-menu-height"]: topMenuHeight }),
263
+ className: styles[`${rootClassName}__top-menu-wrapper`],
264
+ "data-state": hideMenu ? "closed" : "open",
265
+ children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuList, { onFocus: resetAndShowMenu, ref: topMenuRef, children: LINKS.map((link) => /* @__PURE__ */ jsx(NavigationMenu.TopMenuItem, { children: /* @__PURE__ */ jsx(NavigationMenu.TopMenuTrigger, { value: link.name, asChild: true, children: /* @__PURE__ */ jsx(Link2, { href: link.link, children: link.name }) }) }, link.name)) })
266
+ }
267
+ ),
268
+ LINKS.map((link) => /* @__PURE__ */ jsxs(NavigationMenu.List, { onFocus: resetAndShowMenu, value: link.name, children: [
196
269
  link.links.map((subLink) => /* @__PURE__ */ jsxs(NavigationMenu.Item, { value: subLink.name, children: [
197
270
  subLink.name === "Logo" ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, variant: "button", children: subLink.appKey === rootContext.appKey || rootContext.appKey === "storybook" ? /* @__PURE__ */ jsx(Link2, { href: subLink.link, onClick: () => setSelectedMenuItem(""), children: /* @__PURE__ */ jsx(
198
271
  "img",
@@ -237,10 +310,34 @@ const Desktop = React__default.forwardRef(() => {
237
310
  /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(ShoppingCart, {}) }),
238
311
  /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(MyPages, {}) })
239
312
  ] }, link.name)),
240
- /* @__PURE__ */ jsx(NavigationMenu.Viewport, { className: styles[`${rootClassName}__viewport`] })
313
+ /* @__PURE__ */ jsx(
314
+ "div",
315
+ {
316
+ style: mergeStyles({ ["--teddy-viewport-wrapper-height"]: viewPortHeight }),
317
+ className: styles[`${rootClassName}__viewport-wrapper`],
318
+ "data-state": hideMenu ? "closed" : "open",
319
+ children: /* @__PURE__ */ jsx(
320
+ NavigationMenu.Viewport,
321
+ {
322
+ onFocus: resetAndShowMenu,
323
+ ref: viewPortRef,
324
+ className: styles[`${rootClassName}__viewport`]
325
+ }
326
+ )
327
+ }
328
+ )
241
329
  ] });
242
330
  });
243
331
  Desktop.displayName = "Desktop";
332
+ function useDebounceCallback(callback, delay) {
333
+ const handleCallback = useCallbackRef(callback);
334
+ const debounceTimerRef = React__default.useRef(0);
335
+ React__default.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
336
+ return React__default.useCallback(() => {
337
+ window.clearTimeout(debounceTimerRef.current);
338
+ debounceTimerRef.current = window.setTimeout(handleCallback, delay);
339
+ }, [handleCallback, delay]);
340
+ }
244
341
  function Mobile(props) {
245
342
  const rootContext = React__default.useContext(RootContext);
246
343
  const drawerRef = React__default.useRef(null);
package/dist/style.css CHANGED
@@ -3319,47 +3319,100 @@
3319
3319
  height: 0;
3320
3320
  }
3321
3321
  }
3322
- }._teddy-global-navigation_1t5v4_1 {
3322
+ }._teddy-global-navigation_1ue02_1 {
3323
3323
  position: sticky;
3324
3324
  inset: 0 0 auto 0;
3325
3325
  z-index: 39;
3326
3326
  }
3327
- ._teddy-global-navigation__mobile-trigger_1t5v4_6 {
3327
+ ._teddy-global-navigation__mobile-trigger_1ue02_6 {
3328
3328
  border-inline: var(--teddy-border-width-xs) solid var(--teddy-color-border-weak);
3329
3329
  }
3330
- ._teddy-global-navigation__mobile-header_1t5v4_9[data-state=open] {
3330
+ ._teddy-global-navigation__mobile-header_1ue02_9[data-state=open] {
3331
3331
  border-bottom: var(--teddy-border-width-xs) solid var(--teddy-color-border-weak);
3332
3332
  }
3333
- ._teddy-global-navigation__mobile_1t5v4_6 {
3333
+ ._teddy-global-navigation__mobile_1ue02_6 {
3334
3334
  padding: var(--teddy-spacing-25) var(--teddy-spacing-200);
3335
3335
  border-bottom: var(--teddy-border-width-sm) solid var(--teddy-color-border-weak);
3336
3336
  }
3337
- ._teddy-global-navigation__mobile_1t5v4_6::before {
3337
+ ._teddy-global-navigation__mobile_1ue02_6::before {
3338
3338
  content: "";
3339
3339
  display: block;
3340
3340
  width: var(--width-for-centering-element);
3341
3341
  }
3342
- ._teddy-global-navigation__mobile_1t5v4_6::after {
3342
+ ._teddy-global-navigation__mobile_1ue02_6::after {
3343
3343
  content: "";
3344
3344
  display: block;
3345
3345
  width: var(--width-for-centering-element);
3346
3346
  }
3347
- ._teddy-global-navigation__link_1t5v4_26 {
3347
+ ._teddy-global-navigation__link_1ue02_26 {
3348
3348
  text-decoration: none;
3349
3349
  }
3350
- ._teddy-global-navigation__viewport_1t5v4_29 {
3350
+ ._teddy-global-navigation__viewport_1ue02_29 {
3351
3351
  height: var(--radix-navigation-menu-viewport-height, calc(3.25rem * var(--teddy-scale)));
3352
3352
  }
3353
- ._teddy-global-navigation__item-wrapper_1t5v4_32 {
3353
+ ._teddy-global-navigation__item-wrapper_1ue02_32 {
3354
3354
  position: relative;
3355
3355
  }
3356
- ._teddy-global-navigation__item-count_1t5v4_35 {
3356
+ ._teddy-global-navigation__item-count_1ue02_35 {
3357
3357
  display: flex;
3358
3358
  justify-content: center;
3359
3359
  align-items: center;
3360
3360
  position: absolute;
3361
3361
  left: 15px;
3362
3362
  top: -6px;
3363
+ }
3364
+ ._teddy-global-navigation__viewport-wrapper_1ue02_43 {
3365
+ overflow: hidden;
3366
+ }
3367
+ ._teddy-global-navigation__viewport-wrapper_1ue02_43[data-state=open] {
3368
+ animation: _expand-viewport_1ue02_1 var(--teddy-motion-duration-300) ease;
3369
+ }
3370
+ ._teddy-global-navigation__viewport-wrapper_1ue02_43[data-state=closed] {
3371
+ animation: _close-viewport_1ue02_1 var(--teddy-motion-duration-300) ease;
3372
+ height: 0;
3373
+ }
3374
+ ._teddy-global-navigation__top-menu-wrapper_1ue02_53 {
3375
+ overflow: hidden;
3376
+ transition: height var(--teddy-motion-duration-300) ease;
3377
+ }
3378
+ ._teddy-global-navigation__top-menu-wrapper_1ue02_53[data-state=open] {
3379
+ height: var(--teddy-top-menu-height, 3.25rem);
3380
+ }
3381
+ ._teddy-global-navigation__top-menu-wrapper_1ue02_53[data-state=closed] {
3382
+ height: 0;
3383
+ }
3384
+
3385
+ @keyframes _expand-viewport_1ue02_1 {
3386
+ 0% {
3387
+ height: 0;
3388
+ }
3389
+ 100% {
3390
+ height: var(--teddy-viewport-wrapper-height);
3391
+ }
3392
+ }
3393
+ @keyframes _close-viewport_1ue02_1 {
3394
+ 0% {
3395
+ height: var(--teddy-viewport-wrapper-height);
3396
+ }
3397
+ 100% {
3398
+ height: 0;
3399
+ }
3400
+ }
3401
+ @keyframes _expand-top-menu_1ue02_1 {
3402
+ 0% {
3403
+ height: 0;
3404
+ }
3405
+ 100% {
3406
+ height: var(--teddy-top-menu-height);
3407
+ }
3408
+ }
3409
+ @keyframes _close-top-menu_1ue02_1 {
3410
+ 0% {
3411
+ height: var(--teddy-top-menu-height);
3412
+ }
3413
+ 100% {
3414
+ height: 0;
3415
+ }
3363
3416
  }@layer icon, toggle;
3364
3417
  ._teddy-toggle__input_m5h3g_2::before {
3365
3418
  box-sizing: border-box;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ function _interopNamespaceDefault(e) {
5
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
+ if (e) {
7
+ for (const k in e) {
8
+ if (k !== "default") {
9
+ const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
+ function useCallbackRef(callback) {
22
+ const callbackRef = React__namespace.useRef(callback);
23
+ React__namespace.useEffect(() => {
24
+ callbackRef.current = callback;
25
+ });
26
+ return React__namespace.useMemo(() => (...args) => {
27
+ var _a;
28
+ return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
29
+ }, []);
30
+ }
31
+ exports.useCallbackRef = useCallbackRef;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A custom hook that converts a callback to a ref to avoid triggering re-renders when passed as a
3
+ * prop or avoid re-executing effects when passed as a dependency
4
+ */
5
+ declare function useCallbackRef<T extends (...args: unknown[]) => unknown>(callback: T | undefined): T;
6
+ export { useCallbackRef };
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ function useCallbackRef(callback) {
3
+ const callbackRef = React.useRef(callback);
4
+ React.useEffect(() => {
5
+ callbackRef.current = callback;
6
+ });
7
+ return React.useMemo(() => (...args) => {
8
+ var _a;
9
+ return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
10
+ }, []);
11
+ }
12
+ export {
13
+ useCallbackRef
14
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ function _interopNamespaceDefault(e) {
5
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
6
+ if (e) {
7
+ for (const k in e) {
8
+ if (k !== "default") {
9
+ const d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: () => e[k]
13
+ });
14
+ }
15
+ }
16
+ }
17
+ n.default = e;
18
+ return Object.freeze(n);
19
+ }
20
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
21
+ const useLayoutEffect = (globalThis == null ? void 0 : globalThis.document) ? React__namespace.useLayoutEffect : () => {
22
+ };
23
+ exports.useLayoutEffect = useLayoutEffect;
@@ -0,0 +1,36 @@
1
+ import * as React from 'react';
2
+ /**
3
+ This utilities is a copy from Radix UI.
4
+
5
+
6
+ MIT License
7
+
8
+ Copyright (c) 2022 WorkOS
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ */
28
+ /**
29
+ * On the server, React emits a warning when calling `useLayoutEffect`.
30
+ * This is because neither `useLayoutEffect` nor `useEffect` run on the server.
31
+ * We use this safe version which suppresses the warning by replacing it with a noop on the server.
32
+ *
33
+ * See: https://reactjs.org/docs/hooks-reference.html#uselayouteffect
34
+ */
35
+ declare const useLayoutEffect: typeof React.useLayoutEffect;
36
+ export { useLayoutEffect };
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ const useLayoutEffect = (globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
3
+ };
4
+ export {
5
+ useLayoutEffect
6
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const utils_useLayoutEffect = require("./useLayoutEffect.cjs");
5
+ function useSize(element) {
6
+ const [size, setSize] = React.useState(void 0);
7
+ utils_useLayoutEffect.useLayoutEffect(() => {
8
+ if (element) {
9
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
10
+ const resizeObserver = new ResizeObserver((entries) => {
11
+ if (!Array.isArray(entries)) {
12
+ return;
13
+ }
14
+ if (!entries.length) {
15
+ return;
16
+ }
17
+ const entry = entries[0];
18
+ let width;
19
+ let height;
20
+ if ("borderBoxSize" in entry) {
21
+ const borderSizeEntry = entry["borderBoxSize"];
22
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
23
+ width = borderSize["inlineSize"];
24
+ height = borderSize["blockSize"];
25
+ } else {
26
+ width = element.offsetWidth;
27
+ height = element.offsetHeight;
28
+ }
29
+ setSize({ width, height });
30
+ });
31
+ resizeObserver.observe(element, { box: "border-box" });
32
+ return () => resizeObserver.unobserve(element);
33
+ } else {
34
+ setSize(void 0);
35
+ }
36
+ }, [element]);
37
+ return size;
38
+ }
39
+ exports.useSize = useSize;
@@ -0,0 +1,31 @@
1
+ /**
2
+ This utilities is a copy from Radix UI.
3
+
4
+
5
+ MIT License
6
+
7
+ Copyright (c) 2022 WorkOS
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ */
27
+ declare function useSize(element: HTMLElement | null): {
28
+ width: number;
29
+ height: number;
30
+ } | undefined;
31
+ export { useSize };
@@ -0,0 +1,39 @@
1
+ import React__default from "react";
2
+ import { useLayoutEffect } from "./useLayoutEffect.js";
3
+ function useSize(element) {
4
+ const [size, setSize] = React__default.useState(void 0);
5
+ useLayoutEffect(() => {
6
+ if (element) {
7
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
8
+ const resizeObserver = new ResizeObserver((entries) => {
9
+ if (!Array.isArray(entries)) {
10
+ return;
11
+ }
12
+ if (!entries.length) {
13
+ return;
14
+ }
15
+ const entry = entries[0];
16
+ let width;
17
+ let height;
18
+ if ("borderBoxSize" in entry) {
19
+ const borderSizeEntry = entry["borderBoxSize"];
20
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
21
+ width = borderSize["inlineSize"];
22
+ height = borderSize["blockSize"];
23
+ } else {
24
+ width = element.offsetWidth;
25
+ height = element.offsetHeight;
26
+ }
27
+ setSize({ width, height });
28
+ });
29
+ resizeObserver.observe(element, { box: "border-box" });
30
+ return () => resizeObserver.unobserve(element);
31
+ } else {
32
+ setSize(void 0);
33
+ }
34
+ }, [element]);
35
+ return size;
36
+ }
37
+ export {
38
+ useSize
39
+ };
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "pnpm": ">=8"
21
21
  },
22
22
  "private": false,
23
- "version": "0.0.39",
23
+ "version": "0.0.40",
24
24
  "sideEffects": [
25
25
  "**/*.css"
26
26
  ],