@festo-ui/react 10.0.0-dev.826 → 10.0.0-dev.828

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.
@@ -1,27 +1,20 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import classnames from "classnames";
3
- import { Children, cloneElement, forwardRef, isValidElement, useCallback, useEffect, useRef, useState } from "react";
3
+ import { Children, cloneElement, forwardRef, isValidElement, useCallback, useLayoutEffect, useRef, useState } from "react";
4
4
  import { useForkRef } from "../../utils/useForkRef.js";
5
5
  const Breadcrumb = /*#__PURE__*/ forwardRef(({ locations, onClick, children, className, ...props }, ref)=>{
6
- const containerRef = useRef(null);
7
- const measureRef = useRef(null);
8
- const combinedRef = useForkRef(ref, containerRef);
6
+ const navRef = useRef(null);
7
+ const combinedRef = useForkRef(ref, navRef);
9
8
  const [isMobile, setIsMobile] = useState(false);
10
- function isValidHtmlChildElement(child) {
11
- return /*#__PURE__*/ isValidElement(child);
12
- }
13
- const childrenList = Children.toArray(children).filter(isValidHtmlChildElement);
14
- const listItems = locations ? locations.map((location, index)=>{
15
- const isCurrent = index === locations.length - 1;
16
- return /*#__PURE__*/ jsx("li", {
9
+ const childrenList = Children.toArray(children).filter((child)=>/*#__PURE__*/ isValidElement(child));
10
+ const listItems = locations ? locations.map((location, index)=>/*#__PURE__*/ jsx("li", {
17
11
  children: /*#__PURE__*/ jsx("a", {
18
12
  href: location.url,
19
- onClick: (e)=>onClick ? onClick(e) : void 0,
20
- "aria-current": isCurrent ? 'page' : void 0,
13
+ onClick: (e)=>onClick?.(e),
14
+ "aria-current": index === locations.length - 1 ? 'page' : void 0,
21
15
  children: location.label
22
16
  })
23
- }, location.url);
24
- }) : childrenList.map((child, index)=>{
17
+ }, location.url)) : childrenList.map((child, index)=>{
25
18
  const isCurrent = index === childrenList.length - 1;
26
19
  const content = isCurrent ? /*#__PURE__*/ cloneElement(child, {
27
20
  'aria-current': child.props['aria-current'] ?? 'page'
@@ -31,61 +24,37 @@ const Breadcrumb = /*#__PURE__*/ forwardRef(({ locations, onClick, children, cla
31
24
  }, child.key ?? index);
32
25
  });
33
26
  const measure = useCallback(()=>{
34
- const container = containerRef.current;
35
- const measureElement = measureRef.current;
36
- if (!container || !measureElement) return;
37
- const availableWidth = container.clientWidth;
38
- const contentWidth = measureElement.scrollWidth;
39
- const nextIsMobile = contentWidth > availableWidth;
40
- setIsMobile((previous)=>previous === nextIsMobile ? previous : nextIsMobile);
27
+ const nav = navRef.current;
28
+ const ol = nav?.querySelector('ol');
29
+ if (!nav || !ol) return;
30
+ const wasMobile = nav.classList.contains('fwe-breadcrumb--mobile');
31
+ if (wasMobile) nav.classList.remove('fwe-breadcrumb--mobile');
32
+ const lastItem = ol.lastElementChild;
33
+ if (lastItem) lastItem.style.flexShrink = '0';
34
+ const containerRight = ol.getBoundingClientRect().right;
35
+ const nextIsMobile = Array.from(ol.children).some((item)=>item.getBoundingClientRect().right > containerRight);
36
+ if (lastItem) lastItem.style.flexShrink = '';
37
+ if (wasMobile) nav.classList.add('fwe-breadcrumb--mobile');
38
+ setIsMobile(nextIsMobile);
41
39
  }, []);
42
- useEffect(()=>{
40
+ useLayoutEffect(()=>{
43
41
  measure();
44
- });
45
- useEffect(()=>{
46
- const container = containerRef.current;
47
- const measureElement = measureRef.current;
48
- if (!container || !measureElement) return;
49
- if ('undefined' == typeof ResizeObserver) {
50
- window.addEventListener('resize', measure);
51
- return ()=>window.removeEventListener('resize', measure);
52
- }
42
+ const nav = navRef.current;
43
+ if (!nav) return;
53
44
  const observer = new ResizeObserver(()=>measure());
54
- observer.observe(container);
55
- observer.observe(measureElement);
45
+ observer.observe(nav);
56
46
  return ()=>observer.disconnect();
57
47
  }, [
58
48
  measure
59
49
  ]);
60
- return /*#__PURE__*/ jsxs("div", {
61
- className: className,
62
- children: [
63
- /*#__PURE__*/ jsx("nav", {
64
- className: classnames('fwe-breadcrumb'),
65
- ref: measureRef,
66
- style: {
67
- position: 'absolute',
68
- visibility: 'hidden',
69
- pointerEvents: 'none',
70
- whiteSpace: 'nowrap',
71
- height: 0,
72
- overflow: 'hidden'
73
- },
74
- "aria-hidden": "true",
75
- children: /*#__PURE__*/ jsx("ol", {
76
- children: listItems
77
- })
78
- }),
79
- /*#__PURE__*/ jsx("nav", {
80
- ...props,
81
- className: classnames('fwe-breadcrumb', isMobile && 'fwe-breadcrumb--mobile'),
82
- ref: combinedRef,
83
- "aria-label": "Breadcrumb",
84
- children: /*#__PURE__*/ jsx("ol", {
85
- children: listItems
86
- })
87
- })
88
- ]
50
+ return /*#__PURE__*/ jsx("nav", {
51
+ ...props,
52
+ className: classnames('fwe-breadcrumb', isMobile && 'fwe-breadcrumb--mobile', className),
53
+ ref: combinedRef,
54
+ "aria-label": "Breadcrumb",
55
+ children: /*#__PURE__*/ jsx("ol", {
56
+ children: listItems
57
+ })
89
58
  });
90
59
  });
91
60
  Breadcrumb.displayName = 'Breadcrumb';
@@ -5,7 +5,7 @@ import classnames from "classnames";
5
5
  import { forwardRef, useRef } from "react";
6
6
  import { useControlled } from "../../../utils/useControlled.js";
7
7
  import { useForkRef } from "../../../utils/useForkRef.js";
8
- const Popover = /*#__PURE__*/ forwardRef(({ children, className, 'data-testid': dataTestId, style, containerClassName, content, position, fallbackPositions, isOpen, openOnHover = false, openByDefault = false, onChange, flip: enableFlip = true, showArrow = true, onTriggerClick, stopPropagation = false, ...props }, ref)=>{
8
+ const Popover = /*#__PURE__*/ forwardRef(({ children, className, style, containerClassName, content, position, fallbackPositions, isOpen, openOnHover = false, openByDefault = false, onChange, flip: enableFlip = true, showArrow = true, onTriggerClick, stopPropagation = false, ...props }, ref)=>{
9
9
  const [showPopover, setShowPopover] = useControlled({
10
10
  controlled: isOpen,
11
11
  default: openByDefault
@@ -83,7 +83,6 @@ const Popover = /*#__PURE__*/ forwardRef(({ children, className, 'data-testid':
83
83
  height: 8
84
84
  }),
85
85
  /*#__PURE__*/ jsx("div", {
86
- "data-testid": dataTestId,
87
86
  className: classnames('fwe-popover', containerClassName),
88
87
  children: content
89
88
  })
@@ -1,5 +1,6 @@
1
1
  import { type ComponentPropsWithoutRef } from 'react';
2
2
  export interface PopoverMenuItemProps extends Omit<ComponentPropsWithoutRef<'button'>, 'onClick'> {
3
+ readonly 'data-testid'?: string;
3
4
  readonly text: string;
4
5
  readonly icon: React.ReactNode;
5
6
  readonly onClick?: (data: unknown) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@festo-ui/react",
3
- "version": "10.0.0-dev.826",
3
+ "version": "10.0.0-dev.828",
4
4
  "author": "Festo UI (styleguide@festo.com)",
5
5
  "copyright": "Copyright (c) 2025 Festo SE & Co. KG. All rights reserved.",
6
6
  "license": "apache-2.0",