@porsche-design-system/components-react 4.3.0 → 4.4.0-rc.1

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/cjs/lib/components/popover.wrapper.cjs +4 -3
  3. package/esm/lib/components/popover.wrapper.d.ts +26 -2
  4. package/esm/lib/components/popover.wrapper.mjs +5 -4
  5. package/package.json +2 -2
  6. package/ssr/cjs/components/dist/styles/esm/styles-entry.cjs +354 -143
  7. package/ssr/cjs/components/dist/utils/esm/utils-entry.cjs +1 -1
  8. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/components/popover.wrapper.cjs +5 -4
  9. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/banner.cjs +15 -5
  10. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/dialog-base.cjs +3 -7
  11. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.cjs +3 -0
  12. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/fc-dismiss-button.cjs +16 -0
  13. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/flyout.cjs +14 -1
  14. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/inline-notification.cjs +2 -2
  15. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/modal.cjs +14 -1
  16. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/popover.cjs +65 -16
  17. package/ssr/cjs/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/sheet.cjs +14 -1
  18. package/ssr/esm/components/dist/styles/esm/styles-entry.mjs +354 -144
  19. package/ssr/esm/components/dist/utils/esm/utils-entry.mjs +1 -1
  20. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/popover.wrapper.mjs +6 -5
  21. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/banner.mjs +15 -5
  22. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/dialog-base.mjs +3 -7
  23. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/drilldown.mjs +3 -0
  24. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/fc-dismiss-button.mjs +14 -0
  25. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/flyout.mjs +14 -1
  26. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/inline-notification.mjs +2 -2
  27. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/modal.mjs +14 -1
  28. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/popover.mjs +66 -17
  29. package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/sheet.mjs +14 -1
  30. package/ssr/esm/lib/components/popover.wrapper.d.ts +26 -2
  31. package/ssr/esm/lib/dsr-components/banner.d.ts +2 -0
  32. package/ssr/esm/lib/dsr-components/dialog-base.d.ts +2 -2
  33. package/ssr/esm/lib/dsr-components/drilldown.d.ts +1 -0
  34. package/ssr/esm/lib/dsr-components/fc-dismiss-button.d.ts +16 -0
  35. package/ssr/esm/lib/dsr-components/flyout.d.ts +1 -0
  36. package/ssr/esm/lib/dsr-components/modal.d.ts +1 -0
  37. package/ssr/esm/lib/dsr-components/popover.d.ts +16 -7
  38. package/ssr/esm/lib/dsr-components/sheet.d.ts +1 -0
@@ -3480,7 +3480,7 @@ const hasShowPickerSupport = () => (hasDocument &&
3480
3480
  'showPicker' in HTMLInputElement.prototype &&
3481
3481
  CSS.supports('selector(::-webkit-calendar-picker-indicator)'));
3482
3482
 
3483
- const prefix = `[Porsche Design System v${"4.3.0"}]` // this part isn't covered by unit tests
3483
+ const prefix = `[Porsche Design System v${"4.4.0-rc.1"}]` // this part isn't covered by unit tests
3484
3484
  ;
3485
3485
  const consoleError$1 = (...messages) => {
3486
3486
  console.error(prefix, ...messages);
@@ -1,24 +1,25 @@
1
1
  "use client";
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { forwardRef, useRef } from 'react';
4
- import { usePrefix, useBrowserLayoutEffect, useMergedClass } from '../../hooks.mjs';
4
+ import { useEventCallback, usePrefix, useBrowserLayoutEffect, useMergedClass } from '../../hooks.mjs';
5
5
  import { syncRef } from '../../utils.mjs';
6
6
  import { DSRPopover } from '../dsr-components/popover.mjs';
7
7
 
8
- const PPopover = /*#__PURE__*/ forwardRef(({ aria, description, direction = 'bottom', className, children, ...rest }, ref) => {
8
+ const PPopover = /*#__PURE__*/ forwardRef(({ aria, compact, description, direction = 'bottom', onDismiss, open, className, children, ...rest }, ref) => {
9
9
  const elementRef = useRef(undefined);
10
+ useEventCallback(elementRef, 'dismiss', onDismiss);
10
11
  const WebComponentTag = usePrefix('p-popover');
11
- const propsToSync = [aria, description, direction];
12
+ const propsToSync = [aria, compact, description, direction, open];
12
13
  useBrowserLayoutEffect(() => {
13
14
  const { current } = elementRef;
14
- ['aria', 'description', 'direction'].forEach((propName, i) => (current[propName] = propsToSync[i]));
15
+ ['aria', 'compact', 'description', 'direction', 'open'].forEach((propName, i) => (current[propName] = propsToSync[i]));
15
16
  }, propsToSync);
16
17
  const props = {
17
18
  ...rest,
18
19
  // @ts-ignore
19
20
  ...(!process.browser
20
21
  ? {
21
- children: (jsx(DSRPopover, { aria, description, direction, children })),
22
+ children: (jsx(DSRPopover, { aria, compact, description, direction, open, children })),
22
23
  }
23
24
  : {
24
25
  children,
@@ -1,12 +1,11 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { Component } from 'react';
3
- import '../../provider.mjs';
4
2
  import { splitChildren } from '../../splitChildren.mjs';
3
+ import { Component } from 'react';
5
4
  import { minifyCss } from '../../minifyCss.mjs';
6
5
  import { getBannerCss as getComponentCss$18 } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
7
6
  import { createTopLayerController, getBannerAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
7
+ import { FCDismissButton } from './fc-dismiss-button.mjs';
8
8
  import { NotificationBase } from './notification-base.mjs';
9
- import { PButton } from '../components/button.wrapper.mjs';
10
9
 
11
10
  /**
12
11
  * @slot {"name": "heading", "description": "Defines the heading of the banner. Can be used as an alternative to the `heading` prop for rich content." }
@@ -21,6 +20,12 @@ class DSRBanner extends Component {
21
20
  refDismiss;
22
21
  hasHeadingSlot;
23
22
  hasDescriptionSlot;
23
+ // Tracks whether the document-level Escape listener is currently registered (guards the idempotent sync below).
24
+ hasKeydownListener = false;
25
+ // Tracks the component's first render. While `true`, the entry transition (`@starting-style`) is suppressed so an
26
+ // initially-open banner (`open=true` on page load) appears instantly instead of sliding/fading in; flipped to `false`
27
+ // in `componentDidLoad`, so every later (user-triggered) open keeps the entry animation.
28
+ isInitialRender = true;
24
29
  topLayer = createTopLayerController({
25
30
  getElement: () => this.props.refPopover,
26
31
  isShown: () => !!this.props.refPopover?.matches(':popover-open'),
@@ -33,8 +38,13 @@ class DSRBanner extends Component {
33
38
  const hasDescriptionSlot = namedSlotChildren.filter(({ props: { slot } }) => slot === 'description').length > 0;
34
39
  const headingText = this.props.heading ? this.props.heading : namedSlotChildren.find(({ props: { slot } }) => slot === 'heading')?.props.children;
35
40
  const style = minifyCss(getComponentCss$18(this.props.open, this.props.position, this.props.state, this.props.dismissButton, !!(this.props.heading || hasHeadingSlot)));
36
- return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx("div", { popover: "manual", "aria-hidden": this.props.open ? 'false' : 'true', ...getBannerAriaAttributes(this.props.state, headingText), children: jsx(NotificationBase, { heading: this.props.heading, headingTag: this.props.headingTag, hasHeadingSlot: hasHeadingSlot, description: this.props.description, hasDescriptionSlot: hasDescriptionSlot, ...(this.props.dismissButton && {
37
- dismissButton: (jsx(PButton, { className: "dismiss", type: "button", variant: "secondary", icon: "close", hideLabel: true, compact: true, ...(headingText ? { aria: { 'aria-description': headingText } } : {}), children: "Close banner" })),
41
+ return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style + (this.props.open ? '[popover]{display:grid!important}' : '') } }), jsx("div", { popover: "manual",
42
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
43
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
44
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
45
+ // `inert` avoids that and mirrors the pattern used by `p-modal` / `p-popover` / `p-drilldown`.
46
+ inert: !this.props.open, ...getBannerAriaAttributes(this.props.state, headingText), children: jsx(NotificationBase, { heading: this.props.heading, headingTag: this.props.headingTag, hasHeadingSlot: hasHeadingSlot, description: this.props.description, hasDescriptionSlot: hasDescriptionSlot, ...(this.props.dismissButton && {
47
+ dismissButton: (jsx(FCDismissButton, { label: "Close banner", ariaDescription: headingText || undefined })),
38
48
  }) }) })] }), this.props.children] }));
39
49
  }
40
50
  }
@@ -1,12 +1,8 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import 'react';
3
- import '../../provider.mjs';
4
- import { PButton } from '../components/button.wrapper.mjs';
2
+ import { FCDismissButton } from './fc-dismiss-button.mjs';
5
3
 
6
- const DialogBase = ({ children,
7
- // host,
8
- inert, containerClass, ariaAttributes, dismissable = false, header, footer, subFooter, }) => {
9
- return (jsx("dialog", { inert: inert, tabIndex: -1, ...(ariaAttributes ?? {}), children: jsx("div", { className: "scroller", children: jsxs("div", { className: containerClass, children: [dismissable && (jsx(PButton, { className: "dismiss", compact: true, type: "button", hideLabel: true, icon: "close", children: `Dismiss ${containerClass}` })), header, children, footer, subFooter] }) }) }));
4
+ const DialogBase = ({ children, inert, containerClass, ariaAttributes, onMouseDown, dismissable = false, header, footer, subFooter, }) => {
5
+ return (jsx("dialog", { inert: inert, tabIndex: -1, ...(ariaAttributes ?? {}), children: jsx("div", { className: "scroller", children: jsxs("div", { className: containerClass, children: [dismissable && jsx(FCDismissButton, { label: `Dismiss ${containerClass}` }), header, children, footer, subFooter] }) }) }));
10
6
  };
11
7
 
12
8
  export { DialogBase };
@@ -24,6 +24,9 @@ class DSRDrilldown extends Component {
24
24
  dialog;
25
25
  drawer;
26
26
  isDesktop = false;
27
+ // Tracks whether the current pointer gesture started inside the drawer (not on the backdrop). Lets `onClickDialog`
28
+ // skip dismissal when a selection is dragged out of the drawer and released on the backdrop.
29
+ isPointerDownInside = false;
27
30
  async componentWillLoad() {
28
31
  this.props.defineDrilldownItemElements();
29
32
  const activeItem = this.props.drilldownItemElements.find((item) => item.identifier === this.props.activeIdentifier);
@@ -0,0 +1,14 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Shared dismiss/close button used across dialog-based (flyout/modal/sheet) and notification-based
5
+ * (banner/inline-notification/toast) components. Renders a native `<button className="dismiss">` with the close icon
6
+ * inlined as a CSS mask (see `fc-dismiss-button-styles.ts`) — so it needs neither a nested `p-button` nor a `p-icon`
7
+ * (avoiding the async CDN icon fetch). Each consumer supplies the variant/positioning styling via the `.dismiss` class.
8
+ * The visible label text is visually hidden but exposed to assistive technology as the accessible name.
9
+ */
10
+ const FCDismissButton = ({ label, ariaDescription, }) => {
11
+ return (jsx("button", { className: "dismiss", type: "button", ...(ariaDescription ? { 'aria-description': ariaDescription } : {}), children: jsx("span", { children: label }) }));
12
+ };
13
+
14
+ export { FCDismissButton };
@@ -23,6 +23,9 @@ class DSRFlyout extends Component {
23
23
  hasHeader;
24
24
  hasFooter;
25
25
  hasSubFooter;
26
+ // Tracks whether the current pointer gesture started inside the panel (not on the backdrop). Lets `onClickDialog`
27
+ // skip dismissal when a selection is dragged out of the panel and released on the backdrop.
28
+ isPointerDownInside = false;
26
29
  topLayer = createTopLayerController({
27
30
  getElement: () => this.props.dialog,
28
31
  isShown: () => !!this.props.dialog?.open,
@@ -35,7 +38,17 @@ class DSRFlyout extends Component {
35
38
  const hasFooter = namedSlotChildren.filter(({ props: { slot } }) => slot === 'footer').length > 0;
36
39
  const hasSubFooter = namedSlotChildren.filter(({ props: { slot } }) => slot === 'sub-footer').length > 0;
37
40
  const style = minifyCss(getComponentCss$V(this.props.open, this.props.background, this.props.backdrop, this.props.position, hasHeader, hasFooter, hasSubFooter, this.props.footerBehavior, this.props.fullscreen));
38
- return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase, { host: null, dismissable: true, containerClass: "flyout", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, footer: hasFooter ? jsx("slot", { name: "footer" }) : undefined, subFooter: hasSubFooter ? jsx("slot", { name: "sub-footer" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
41
+ return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase
42
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
43
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
44
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
45
+ // `inert` avoids that and mirrors the pattern used by `p-modal` / `p-popover` / `p-drilldown`.
46
+ , {
47
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
48
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
49
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
50
+ // `inert` avoids that and mirrors the pattern used by `p-modal` / `p-popover` / `p-drilldown`.
51
+ inert: !this.props.open, dismissable: true, containerClass: "flyout", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, footer: hasFooter ? jsx("slot", { name: "footer" }) : undefined, subFooter: hasSubFooter ? jsx("slot", { name: "sub-footer" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
39
52
  'aria-modal': true,
40
53
  ...{ 'aria-label': hasHeader ? namedSlotChildren.find(({ props: { slot } }) => slot === 'header')?.props.children : 'Flyout' },
41
54
  ...parseAndGetAriaAttributes(this.props.aria),
@@ -5,8 +5,8 @@ import { splitChildren } from '../../splitChildren.mjs';
5
5
  import { minifyCss } from '../../minifyCss.mjs';
6
6
  import { getInlineNotificationCss as getComponentCss$S } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
7
7
  import { getInlineNotificationAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
8
+ import { FCDismissButton } from './fc-dismiss-button.mjs';
8
9
  import { NotificationBase } from './notification-base.mjs';
9
- import { PButton } from '../components/button.wrapper.mjs';
10
10
  import { PButtonPure } from '../components/button-pure.wrapper.mjs';
11
11
 
12
12
  /**
@@ -24,7 +24,7 @@ class DSRInlineNotification extends Component {
24
24
  return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(NotificationBase, { ...getInlineNotificationAriaAttributes(this.props.state, headingText), heading: this.props.heading, headingTag: this.props.headingTag, hasHeadingSlot: hasHeadingSlot, description: this.props.description, ...(this.props.actionLabel && {
25
25
  actionLabel: (jsx(PButtonPure, { className: "action", icon: this.props.actionIcon, loading: this.props.actionLoading, children: this.props.actionLabel })),
26
26
  }), ...(this.props.dismissButton && {
27
- dismissButton: (jsx(PButton, { className: "dismiss", type: "button", variant: "secondary", icon: "close", hideLabel: true, compact: true, ...(headingText ? { aria: { 'aria-description': headingText } } : {}), children: "Close notification" })),
27
+ dismissButton: (jsx(FCDismissButton, { label: "Close notification", ariaDescription: headingText || undefined })),
28
28
  }) })] }), this.props.children] }));
29
29
  }
30
30
  }
@@ -20,6 +20,9 @@ class DSRModal extends Component {
20
20
  footer;
21
21
  hasHeader;
22
22
  hasFooter;
23
+ // Tracks whether the current pointer gesture started inside the panel (not on the backdrop). Lets `onClickDialog`
24
+ // skip dismissal when a selection is dragged out of the panel and released on the backdrop.
25
+ isPointerDownInside = false;
23
26
  topLayer = createTopLayerController({
24
27
  getElement: () => this.props.dialog,
25
28
  isShown: () => !!this.props.dialog?.open,
@@ -33,7 +36,17 @@ class DSRModal extends Component {
33
36
  this.props.disableCloseButton ? false : this.props.dismissButton;
34
37
  // TODO: why do we validate only when opened?
35
38
  const style = minifyCss(getComponentCss$C(this.props.open, this.props.background, this.props.backdrop, this.props.fullscreen, this.props.dismissButton, hasHeader, hasFooter));
36
- return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase, { host: null, inert: !this.props.open, dismissable: this.props.dismissButton ?? undefined, containerClass: "modal", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, footer: hasFooter ? jsx("slot", { name: "footer" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
39
+ return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase
40
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
41
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
42
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
43
+ // `inert` avoids that and mirrors the pattern used by `p-flyout` / `p-popover` / `p-drilldown`.
44
+ , {
45
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
46
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
47
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
48
+ // `inert` avoids that and mirrors the pattern used by `p-flyout` / `p-popover` / `p-drilldown`.
49
+ inert: !this.props.open, dismissable: this.props.dismissButton ?? undefined, containerClass: "modal", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, footer: hasFooter ? jsx("slot", { name: "footer" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
37
50
  'aria-modal': true,
38
51
  ...(hasHeader && { 'aria-label': this.props.ariaLabel }),
39
52
  ...parseAndGetAriaAttributes(this.props.aria),
@@ -1,35 +1,84 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { Component } from 'react';
3
- import '../../provider.mjs';
4
2
  import { splitChildren } from '../../splitChildren.mjs';
3
+ import { Component } from 'react';
5
4
  import { minifyCss } from '../../minifyCss.mjs';
6
5
  import { getPopoverCss as getComponentCss$v } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
7
- import { getHasNativePopoverSupport, parseAndGetAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
8
- import { PIcon } from '../components/icon.wrapper.mjs';
6
+ import { createTopLayerController, parseAndGetAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
9
7
 
10
8
  /**
11
- * @slot {"name": "", "description": "Default slot for the popover content." }
9
+ * @slot {"name": "", "description": "Default slot for the popover content. Ignored when the `description` prop is set, which takes precedence." }
12
10
  * @slot {"name": "button", "description": "Renders a custom trigger button. When used, the default info button is replaced." }
11
+ *
12
+ * @controlled {"props": ["open"], "event": "dismiss"}
13
13
  */
14
+ // The panel is a native `[popover="manual"]` element that the component promotes to the `#top-layer` itself, so it
15
+ // always renders above surrounding content regardless of ancestor stacking contexts. The component supports two modes:
16
+ // - uncontrolled: `open` is omitted and the component owns visibility via the internal `isOpen` state (toggled by the
17
+ // default info button or a slotted trigger); dismissal closes it directly.
18
+ // - controlled: `open` is a boolean and the consumer owns visibility via a slotted `button`; dismissal only emits
19
+ // `dismiss` and the consumer flips `open`. See `isControlled` / `effectiveOpen` for how the two are reconciled.
14
20
  class DSRPopover extends Component {
15
21
  host;
16
22
  isOpen = false;
17
- popover;
18
- button;
19
- slottedButton;
20
- arrow;
23
+ // Tracks the component's first render. While `true`, the entry transition (`@starting-style`) is suppressed so an
24
+ // initially-open popover (`open=true` on page load) appears instantly instead of fading in; flipped to `false` in
25
+ // `componentDidLoad`, so every later (user-triggered) open keeps the fade-in.
26
+ isInitialRender = true;
27
+ // The `[popover]` panel element on the #top-layer that holds the content and the arrow.
28
+ refPopover;
29
+ // The default info button rendered in the Shadow DOM (only present when no `button` slot is used).
30
+ refButton;
31
+ // The `<slot name="button">` element (only present when a custom trigger is projected); its assigned element is the
32
+ // actual trigger, see `triggerElement`.
33
+ refSlotButton;
34
+ // The visual arrow pointing from the panel to the trigger; positioned by Floating UI's `arrow` middleware.
35
+ refArrow;
36
+ // Teardown for the active Floating UI `autoUpdate` subscription; `undefined` while not positioning.
21
37
  cleanUpAutoUpdate;
22
- hasNativePopoverSupport = getHasNativePopoverSupport();
23
- // TODO: This should be updated when slot is changed
24
- hasSlottedButton;
38
+ // The trigger element `autoUpdate` is currently anchored to, so it can be rebound when the trigger identity changes.
39
+ boundTriggerElement;
40
+ // Tracks whether the document-level dismiss listeners (outside click / Escape / pointer) are currently registered.
41
+ hasDismissListeners = false;
42
+ // Tracks whether a pointer button is currently pressed. Lets `onFocusout` defer pointer-driven focus loss (a click on
43
+ // an outside element, already handled by `onClickOutside`) to that handler, so a single outside pointer interaction
44
+ // emits `dismiss` once instead of twice. `onFocusout` then only dismisses on keyboard focus moves (Tab / Shift+Tab).
45
+ isPointerInteraction = false;
46
+ // Tracks whether the current pointer gesture *started* inside the trigger or panel. A `click` only fires on the
47
+ // nearest common ancestor of `mousedown`/`mouseup`, so pressing inside the panel (e.g. starting a text selection),
48
+ // dragging out and releasing outside retargets the resulting `click` to an ancestor *outside* the popover. Without
49
+ // this flag `onClickOutside` would then wrongly dismiss. Captured at `pointerdown` time (where `composedPath()` is
50
+ // still valid) and consumed on the following `click`, so dismissal only happens when the gesture started outside too.
51
+ isPointerDownInside = false;
52
+ // Keeps the panel on the #top-layer during its fade-out (Chromium via `overlay`; Safari/Firefox via a deferred hide).
53
+ topLayer = createTopLayerController({
54
+ getElement: () => this.props.refPopover,
55
+ isShown: () => !!this.props.refPopover?.matches(':popover-open'),
56
+ show: () => this.props.refPopover?.showPopover(),
57
+ hide: () => this.props.refPopover?.hidePopover(),
58
+ });
59
+ get isControlled() {
60
+ // Controlled mode is opted into purely by passing a boolean `open`; an omitted (`undefined`) prop means the
61
+ // component manages its own visibility.
62
+ return typeof this.props.open === 'boolean';
63
+ }
64
+ get effectiveOpen() {
65
+ // Single source of truth for "is the panel currently open", regardless of mode: the consumer-owned `open` prop in
66
+ // controlled mode, the internal `isOpen` state otherwise. All render/positioning/dismissal logic reads this.
67
+ return this.props.isControlled ? this.props.open : this.props.isOpen;
68
+ }
69
+ get triggerElement() {
70
+ // Resolves the element that actually acts as the trigger: the default info button in the Shadow DOM, or — when a
71
+ // custom trigger is projected through the `button` slot — the assigned light-DOM element itself (not the `<slot>`).
72
+ // Using the assigned element gives Floating UI an accurate anchor rect and lets `:host` use `display: contents`.
73
+ // Kept correct across dynamic slot changes by the `observeChildren` re-render in `connectedCallback`.
74
+ return this.props.refButton ?? ((this.props.refSlotButton)?.assignedElements()[0]);
75
+ }
25
76
  render() {
26
77
  const { namedSlotChildren} = splitChildren(this.props.children);
27
78
  const hasSlottedButton = namedSlotChildren.filter(({ props: { slot } }) => slot === 'button').length > 0;
28
- const style = minifyCss(getComponentCss$v()).replace(/(:host {[\S\s]+?})[\S\s]+(button {[\S\s]+?})[\S\s]+(.icon {[\S\s]+?})[\S\s]+(.label {[\S\s]+?})[\S\s]+/, '$1\n$2\n$3\n$4');
29
- return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(Fragment, { children: [hasSlottedButton ? (jsx("slot", { name: "button" })) : (jsxs("button", { type: "button", ...parseAndGetAriaAttributes({
30
- ...parseAndGetAriaAttributes(this.props.aria),
31
- ...{ 'aria-expanded': this.props.isOpen },
32
- }), children: [jsx(PIcon, { className: "icon", name: "information" }), jsx("span", { className: "label", children: "More information" })] })), this.props.isOpen && (jsxs("div", { popover: "auto", children: [jsx("div", { className: "arrow" }), jsx("div", { className: "content", children: this.props.description ? jsx("p", { children: this.props.description }) : jsx("slot", {}) })] }))] })] }), this.props.children] }));
79
+ const id = 'popover';
80
+ const style = minifyCss(getComponentCss$v(this.props.effectiveOpen, this.props.compact, this.props.isInitialRender).replace(/(:host {[\S\s]+?})[\S\s]+(button {[\S\s]+?})[\S\s]+(.icon {[\S\s]+?})[\S\s]+(.label {[\S\s]+?})[\S\s]+/, '$1\n$2\n$3\n$4'));
81
+ return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(Fragment, { children: [hasSlottedButton ? (jsx("slot", { name: "button" })) : (jsx("button", { type: "button", "aria-label": "More information", "aria-details": id, ...parseAndGetAriaAttributes(this.props.aria), "aria-expanded": this.props.effectiveOpen ? 'true' : 'false' })), jsxs("div", { id: id, popover: "manual", inert: !this.props.effectiveOpen, children: [jsx("div", { className: "arrow" }), this.props.description ? jsx("p", { children: this.props.description }) : jsx("slot", {})] })] })] }), this.props.children] }));
33
82
  }
34
83
  }
35
84
 
@@ -17,6 +17,9 @@ class DSRSheet extends Component {
17
17
  dialog;
18
18
  scroller;
19
19
  hasHeader;
20
+ // Tracks whether the current pointer gesture started inside the panel (not on the backdrop). Lets `onClickDialog`
21
+ // skip dismissal when a selection is dragged out of the panel and released on the backdrop.
22
+ isPointerDownInside = false;
20
23
  topLayer = createTopLayerController({
21
24
  getElement: () => this.props.dialog,
22
25
  isShown: () => !!this.props.dialog?.open,
@@ -28,7 +31,17 @@ class DSRSheet extends Component {
28
31
  const hasHeader = namedSlotChildren.filter(({ props: { slot } }) => slot === 'header').length > 0;
29
32
  if (this.props.open) ;
30
33
  const style = minifyCss(getComponentCss$n(this.props.open, this.props.background, this.props.dismissButton));
31
- return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase, { host: null, inert: !this.props.open, dismissable: this.props.dismissButton ?? undefined, containerClass: "sheet", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
34
+ return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(DialogBase
35
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
36
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
37
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
38
+ // `inert` avoids that and mirrors the pattern used by `p-modal` / `p-popover` / `p-drilldown`.
39
+ , {
40
+ // `inert` (not `aria-hidden`) removes the panel from the a11y tree AND prevents focus while closed / during the
41
+ // fade-out. Using `aria-hidden` here triggers a browser warning when a focusable descendant still holds focus
42
+ // during the closing transition ("Blocked aria-hidden on an element because its descendant retained focus").
43
+ // `inert` avoids that and mirrors the pattern used by `p-modal` / `p-popover` / `p-drilldown`.
44
+ inert: !this.props.open, dismissable: this.props.dismissButton ?? undefined, containerClass: "sheet", header: hasHeader ? jsx("slot", { name: "header" }) : undefined, ariaAttributes: parseAndGetAriaAttributes({
32
45
  'aria-modal': true,
33
46
  ...(hasHeader && {
34
47
  'aria-label': namedSlotChildren.filter(({ props: { slot } }) => slot === 'header').length > 0 && namedSlotChildren.find(({ props: { slot } }) => slot === 'header')?.props.children,
@@ -6,7 +6,11 @@ export type PPopoverProps = BaseProps & {
6
6
  */
7
7
  aria?: SelectedAriaAttributes<PopoverAriaAttribute>;
8
8
  /**
9
- * Sets the text content displayed inside the popover panel when it is open, providing contextual help or information.
9
+ * Reduces padding and spacing for a more compact layout, useful in space-constrained interfaces.
10
+ */
11
+ compact?: boolean;
12
+ /**
13
+ * Sets the text content displayed inside the popover panel when it is open, providing contextual help or information. Takes precedence over the default slot when both are provided.
10
14
  */
11
15
  description?: string;
12
16
  /**
@@ -14,6 +18,14 @@ export type PPopoverProps = BaseProps & {
14
18
  * @default 'bottom'
15
19
  */
16
20
  direction?: PopoverDirection;
21
+ /**
22
+ * Emitted in controlled mode when the user requests to close the popover via the Escape key, an outside click, or when keyboard focus leaves the popover (Tab / Shift+Tab).
23
+ */
24
+ onDismiss?: (event: CustomEvent<void>) => void;
25
+ /**
26
+ * Controls whether the popover is visible. When set (controlled mode), visibility follows this prop and the consumer owns the open state via a slotted `button`. When omitted (uncontrolled mode), the component manages visibility itself.
27
+ */
28
+ open?: boolean;
17
29
  };
18
30
  export declare const PPopover: import("react").ForwardRefExoticComponent<Omit<import("react").DOMAttributes<{}>, "onChange" | "onInput" | "onToggle"> & Pick<import("react").HTMLAttributes<{}>, "suppressHydrationWarning" | "autoFocus" | "className" | "dir" | "hidden" | "id" | "inert" | "inputMode" | "lang" | "slot" | "style" | "tabIndex" | "title" | "translate" | "role"> & {
19
31
  /**
@@ -21,7 +33,11 @@ export declare const PPopover: import("react").ForwardRefExoticComponent<Omit<im
21
33
  */
22
34
  aria?: SelectedAriaAttributes<PopoverAriaAttribute>;
23
35
  /**
24
- * Sets the text content displayed inside the popover panel when it is open, providing contextual help or information.
36
+ * Reduces padding and spacing for a more compact layout, useful in space-constrained interfaces.
37
+ */
38
+ compact?: boolean;
39
+ /**
40
+ * Sets the text content displayed inside the popover panel when it is open, providing contextual help or information. Takes precedence over the default slot when both are provided.
25
41
  */
26
42
  description?: string;
27
43
  /**
@@ -29,6 +45,14 @@ export declare const PPopover: import("react").ForwardRefExoticComponent<Omit<im
29
45
  * @default 'bottom'
30
46
  */
31
47
  direction?: PopoverDirection;
48
+ /**
49
+ * Emitted in controlled mode when the user requests to close the popover via the Escape key, an outside click, or when keyboard focus leaves the popover (Tab / Shift+Tab).
50
+ */
51
+ onDismiss?: (event: CustomEvent<void>) => void;
52
+ /**
53
+ * Controls whether the popover is visible. When set (controlled mode), visibility follows this prop and the consumer owns the open state via a slotted `button`. When omitted (uncontrolled mode), the component manages visibility itself.
54
+ */
55
+ open?: boolean;
32
56
  } & {
33
57
  children?: import("react").ReactNode | undefined;
34
58
  } & import("react").RefAttributes<HTMLElement>>;
@@ -13,6 +13,8 @@ export declare class DSRBanner extends Component<any> {
13
13
  private refDismiss;
14
14
  private hasHeadingSlot;
15
15
  private hasDescriptionSlot;
16
+ private hasKeydownListener;
17
+ private isInitialRender;
16
18
  private topLayer;
17
19
  render(): JSX.Element;
18
20
  }
@@ -3,13 +3,13 @@ import type { FC } from 'react';
3
3
  import type { JSX } from 'react';
4
4
  type DialogBaseProps = {
5
5
  children?: JSX.Element;
6
- host: HTMLElement;
7
- inert?: boolean;
6
+ inert: boolean;
8
7
  dialogRef?: (el: HTMLDialogElement) => void;
9
8
  scrollerRef?: (el: HTMLDivElement) => void;
10
9
  containerClass: 'flyout' | 'modal' | 'sheet';
11
10
  onCancel?: (e: Event) => void;
12
11
  onClick?: (e: MouseEvent) => void;
12
+ onMouseDown?: (e: MouseEvent) => void;
13
13
  onTransitionEnd?: (e: TransitionEvent) => void;
14
14
  onDismiss?: () => void;
15
15
  ariaAttributes?: AriaAttributes;
@@ -16,6 +16,7 @@ export declare class DSRDrilldown extends Component<any> {
16
16
  private dialog;
17
17
  private drawer;
18
18
  private isDesktop;
19
+ private isPointerDownInside;
19
20
  componentWillLoad(): Promise<void>;
20
21
  render(): JSX.Element;
21
22
  }
@@ -0,0 +1,16 @@
1
+ import type { FC } from 'react';
2
+ type FCDismissButtonProps = {
3
+ /** Accessible (visually hidden) label of the dismiss button. */
4
+ label: string;
5
+ /** Optional value forwarded as `aria-description` to provide additional context (e.g. the notification heading). */
6
+ ariaDescription?: string;
7
+ };
8
+ /**
9
+ * Shared dismiss/close button used across dialog-based (flyout/modal/sheet) and notification-based
10
+ * (banner/inline-notification/toast) components. Renders a native `<button className="dismiss">` with the close icon
11
+ * inlined as a CSS mask (see `fc-dismiss-button-styles.ts`) — so it needs neither a nested `p-button` nor a `p-icon`
12
+ * (avoiding the async CDN icon fetch). Each consumer supplies the variant/positioning styling via the `.dismiss` class.
13
+ * The visible label text is visually hidden but exposed to assistive technology as the accessible name.
14
+ */
15
+ export declare const FCDismissButton: FC<FCDismissButtonProps>;
16
+ export {};
@@ -17,6 +17,7 @@ export declare class DSRFlyout extends Component<any> {
17
17
  private hasHeader;
18
18
  private hasFooter;
19
19
  private hasSubFooter;
20
+ private isPointerDownInside;
20
21
  private topLayer;
21
22
  render(): JSX.Element;
22
23
  }
@@ -14,6 +14,7 @@ export declare class DSRModal extends Component<any> {
14
14
  private footer;
15
15
  private hasHeader;
16
16
  private hasFooter;
17
+ private isPointerDownInside;
17
18
  private topLayer;
18
19
  render(): JSX.Element;
19
20
  }
@@ -1,18 +1,27 @@
1
1
  import { Component } from 'react';
2
2
  import type { JSX } from 'react';
3
3
  /**
4
- * @slot {"name": "", "description": "Default slot for the popover content." }
4
+ * @slot {"name": "", "description": "Default slot for the popover content. Ignored when the `description` prop is set, which takes precedence." }
5
5
  * @slot {"name": "button", "description": "Renders a custom trigger button. When used, the default info button is replaced." }
6
+ *
7
+ * @controlled {"props": ["open"], "event": "dismiss"}
6
8
  */
7
9
  export declare class DSRPopover extends Component<any> {
8
10
  host: HTMLElement;
9
11
  private isOpen;
10
- private popover;
11
- private button;
12
- private slottedButton;
13
- private arrow;
12
+ private isInitialRender;
13
+ private refPopover;
14
+ private refButton;
15
+ private refSlotButton;
16
+ private refArrow;
14
17
  private cleanUpAutoUpdate;
15
- private hasNativePopoverSupport;
16
- private hasSlottedButton;
18
+ private boundTriggerElement;
19
+ private hasDismissListeners;
20
+ private isPointerInteraction;
21
+ private isPointerDownInside;
22
+ private topLayer;
23
+ private get isControlled();
24
+ private get effectiveOpen();
25
+ private get triggerElement();
17
26
  render(): JSX.Element;
18
27
  }
@@ -11,6 +11,7 @@ export declare class DSRSheet extends Component<any> {
11
11
  private dialog;
12
12
  private scroller;
13
13
  private hasHeader;
14
+ private isPointerDownInside;
14
15
  private topLayer;
15
16
  render(): JSX.Element;
16
17
  }