@wordpress/ui 0.10.0 → 0.11.1-next.v.202604091042.0

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 (245) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/CONTRIBUTING.md +25 -0
  3. package/README.md +22 -2
  4. package/build/alert-dialog/context.cjs +6 -1
  5. package/build/alert-dialog/context.cjs.map +2 -2
  6. package/build/alert-dialog/popup.cjs +105 -33
  7. package/build/alert-dialog/popup.cjs.map +4 -4
  8. package/build/alert-dialog/root.cjs +106 -6
  9. package/build/alert-dialog/root.cjs.map +2 -2
  10. package/build/alert-dialog/trigger.cjs +4 -14
  11. package/build/alert-dialog/trigger.cjs.map +3 -3
  12. package/build/alert-dialog/types.cjs.map +1 -1
  13. package/build/button/button.cjs +16 -6
  14. package/build/button/button.cjs.map +3 -3
  15. package/build/card/content.cjs +3 -3
  16. package/build/card/content.cjs.map +1 -1
  17. package/build/card/full-bleed.cjs +3 -3
  18. package/build/card/full-bleed.cjs.map +1 -1
  19. package/build/card/header.cjs +3 -3
  20. package/build/card/header.cjs.map +1 -1
  21. package/build/card/root.cjs +3 -3
  22. package/build/card/root.cjs.map +1 -1
  23. package/build/card/title.cjs +3 -3
  24. package/build/card/title.cjs.map +1 -1
  25. package/build/collapsible-card/header.cjs +3 -3
  26. package/build/collapsible-card/header.cjs.map +2 -2
  27. package/build/empty-state/title.cjs.map +2 -2
  28. package/build/form/primitives/field/description.cjs +17 -4
  29. package/build/form/primitives/field/description.cjs.map +3 -3
  30. package/build/form/primitives/field/details.cjs +3 -3
  31. package/build/form/primitives/field/details.cjs.map +2 -2
  32. package/build/form/primitives/field/label.cjs +3 -3
  33. package/build/form/primitives/field/label.cjs.map +2 -2
  34. package/build/form/primitives/fieldset/description.cjs +20 -4
  35. package/build/form/primitives/fieldset/description.cjs.map +3 -3
  36. package/build/form/primitives/fieldset/details.cjs +3 -3
  37. package/build/form/primitives/fieldset/details.cjs.map +2 -2
  38. package/build/form/primitives/fieldset/legend.cjs +3 -3
  39. package/build/form/primitives/fieldset/legend.cjs.map +2 -2
  40. package/build/form/primitives/input/input.cjs +23 -7
  41. package/build/form/primitives/input/input.cjs.map +3 -3
  42. package/build/form/primitives/input-layout/input-layout.cjs +10 -0
  43. package/build/form/primitives/input-layout/input-layout.cjs.map +3 -3
  44. package/build/form/primitives/select/trigger.cjs +3 -3
  45. package/build/form/primitives/select/trigger.cjs.map +2 -2
  46. package/build/form/primitives/textarea/textarea.cjs +20 -1
  47. package/build/form/primitives/textarea/textarea.cjs.map +3 -3
  48. package/build/index.cjs +3 -0
  49. package/build/index.cjs.map +2 -2
  50. package/build/link/link.cjs +16 -6
  51. package/build/link/link.cjs.map +3 -3
  52. package/build/popover/arrow.cjs +94 -0
  53. package/build/popover/arrow.cjs.map +7 -0
  54. package/build/popover/close.cjs +45 -0
  55. package/build/popover/close.cjs.map +7 -0
  56. package/build/popover/context.cjs +76 -0
  57. package/build/popover/context.cjs.map +7 -0
  58. package/build/popover/description.cjs +70 -0
  59. package/build/popover/description.cjs.map +7 -0
  60. package/build/popover/index.cjs +49 -0
  61. package/build/popover/index.cjs.map +7 -0
  62. package/build/popover/popup.cjs +138 -0
  63. package/build/popover/popup.cjs.map +7 -0
  64. package/build/popover/root.cjs +35 -0
  65. package/build/popover/root.cjs.map +7 -0
  66. package/build/popover/title.cjs +56 -0
  67. package/build/popover/title.cjs.map +7 -0
  68. package/build/popover/trigger.cjs +38 -0
  69. package/build/popover/trigger.cjs.map +7 -0
  70. package/build/popover/types.cjs +19 -0
  71. package/build/popover/types.cjs.map +7 -0
  72. package/build/text/text.cjs +20 -5
  73. package/build/text/text.cjs.map +3 -3
  74. package/build/utils/use-deprioritized-initial-focus.cjs.map +2 -2
  75. package/build-module/alert-dialog/context.mjs +6 -1
  76. package/build-module/alert-dialog/context.mjs.map +2 -2
  77. package/build-module/alert-dialog/popup.mjs +107 -33
  78. package/build-module/alert-dialog/popup.mjs.map +4 -4
  79. package/build-module/alert-dialog/root.mjs +113 -7
  80. package/build-module/alert-dialog/root.mjs.map +2 -2
  81. package/build-module/alert-dialog/trigger.mjs +4 -4
  82. package/build-module/alert-dialog/trigger.mjs.map +3 -3
  83. package/build-module/button/button.mjs +16 -6
  84. package/build-module/button/button.mjs.map +3 -3
  85. package/build-module/card/content.mjs +3 -3
  86. package/build-module/card/content.mjs.map +1 -1
  87. package/build-module/card/full-bleed.mjs +3 -3
  88. package/build-module/card/full-bleed.mjs.map +1 -1
  89. package/build-module/card/header.mjs +3 -3
  90. package/build-module/card/header.mjs.map +1 -1
  91. package/build-module/card/root.mjs +3 -3
  92. package/build-module/card/root.mjs.map +1 -1
  93. package/build-module/card/title.mjs +3 -3
  94. package/build-module/card/title.mjs.map +1 -1
  95. package/build-module/collapsible-card/header.mjs +3 -3
  96. package/build-module/collapsible-card/header.mjs.map +2 -2
  97. package/build-module/empty-state/title.mjs.map +2 -2
  98. package/build-module/form/primitives/field/description.mjs +17 -4
  99. package/build-module/form/primitives/field/description.mjs.map +3 -3
  100. package/build-module/form/primitives/field/details.mjs +3 -3
  101. package/build-module/form/primitives/field/details.mjs.map +2 -2
  102. package/build-module/form/primitives/field/label.mjs +3 -3
  103. package/build-module/form/primitives/field/label.mjs.map +2 -2
  104. package/build-module/form/primitives/fieldset/description.mjs +20 -4
  105. package/build-module/form/primitives/fieldset/description.mjs.map +3 -3
  106. package/build-module/form/primitives/fieldset/details.mjs +3 -3
  107. package/build-module/form/primitives/fieldset/details.mjs.map +2 -2
  108. package/build-module/form/primitives/fieldset/legend.mjs +3 -3
  109. package/build-module/form/primitives/fieldset/legend.mjs.map +2 -2
  110. package/build-module/form/primitives/input/input.mjs +23 -7
  111. package/build-module/form/primitives/input/input.mjs.map +3 -3
  112. package/build-module/form/primitives/input-layout/input-layout.mjs +10 -0
  113. package/build-module/form/primitives/input-layout/input-layout.mjs.map +3 -3
  114. package/build-module/form/primitives/select/trigger.mjs +3 -3
  115. package/build-module/form/primitives/select/trigger.mjs.map +2 -2
  116. package/build-module/form/primitives/textarea/textarea.mjs +20 -1
  117. package/build-module/form/primitives/textarea/textarea.mjs.map +3 -3
  118. package/build-module/index.mjs +2 -0
  119. package/build-module/index.mjs.map +2 -2
  120. package/build-module/link/link.mjs +16 -6
  121. package/build-module/link/link.mjs.map +3 -3
  122. package/build-module/popover/arrow.mjs +59 -0
  123. package/build-module/popover/arrow.mjs.map +7 -0
  124. package/build-module/popover/close.mjs +20 -0
  125. package/build-module/popover/close.mjs.map +7 -0
  126. package/build-module/popover/context.mjs +57 -0
  127. package/build-module/popover/context.mjs.map +7 -0
  128. package/build-module/popover/description.mjs +35 -0
  129. package/build-module/popover/description.mjs.map +7 -0
  130. package/build-module/popover/index.mjs +18 -0
  131. package/build-module/popover/index.mjs.map +7 -0
  132. package/build-module/popover/popup.mjs +105 -0
  133. package/build-module/popover/popup.mjs.map +7 -0
  134. package/build-module/popover/root.mjs +10 -0
  135. package/build-module/popover/root.mjs.map +7 -0
  136. package/build-module/popover/title.mjs +31 -0
  137. package/build-module/popover/title.mjs.map +7 -0
  138. package/build-module/popover/trigger.mjs +13 -0
  139. package/build-module/popover/trigger.mjs.map +7 -0
  140. package/build-module/popover/types.mjs +1 -0
  141. package/build-module/popover/types.mjs.map +7 -0
  142. package/build-module/text/text.mjs +20 -5
  143. package/build-module/text/text.mjs.map +3 -3
  144. package/build-module/utils/use-deprioritized-initial-focus.mjs.map +2 -2
  145. package/build-types/alert-dialog/context.d.ts +6 -3
  146. package/build-types/alert-dialog/context.d.ts.map +1 -1
  147. package/build-types/alert-dialog/popup.d.ts.map +1 -1
  148. package/build-types/alert-dialog/root.d.ts +2 -8
  149. package/build-types/alert-dialog/root.d.ts.map +1 -1
  150. package/build-types/alert-dialog/stories/index.story.d.ts +18 -6
  151. package/build-types/alert-dialog/stories/index.story.d.ts.map +1 -1
  152. package/build-types/alert-dialog/trigger.d.ts +2 -1
  153. package/build-types/alert-dialog/trigger.d.ts.map +1 -1
  154. package/build-types/alert-dialog/types.d.ts +57 -26
  155. package/build-types/alert-dialog/types.d.ts.map +1 -1
  156. package/build-types/button/button.d.ts.map +1 -1
  157. package/build-types/card/stories/index.story.d.ts.map +1 -1
  158. package/build-types/empty-state/title.d.ts.map +1 -1
  159. package/build-types/form/primitives/field/description.d.ts.map +1 -1
  160. package/build-types/form/primitives/fieldset/description.d.ts.map +1 -1
  161. package/build-types/form/primitives/input/input.d.ts.map +1 -1
  162. package/build-types/form/primitives/input-layout/input-layout.d.ts.map +1 -1
  163. package/build-types/form/primitives/textarea/textarea.d.ts.map +1 -1
  164. package/build-types/form/stories/shared.d.ts.map +1 -1
  165. package/build-types/index.d.ts +1 -0
  166. package/build-types/index.d.ts.map +1 -1
  167. package/build-types/link/link.d.ts.map +1 -1
  168. package/build-types/popover/arrow.d.ts +10 -0
  169. package/build-types/popover/arrow.d.ts.map +1 -0
  170. package/build-types/popover/close.d.ts +11 -0
  171. package/build-types/popover/close.d.ts.map +1 -0
  172. package/build-types/popover/context.d.ts +22 -0
  173. package/build-types/popover/context.d.ts.map +1 -0
  174. package/build-types/popover/description.d.ts +10 -0
  175. package/build-types/popover/description.d.ts.map +1 -0
  176. package/build-types/popover/index.d.ts +9 -0
  177. package/build-types/popover/index.d.ts.map +1 -0
  178. package/build-types/popover/popup.d.ts +11 -0
  179. package/build-types/popover/popup.d.ts.map +1 -0
  180. package/build-types/popover/root.d.ts +37 -0
  181. package/build-types/popover/root.d.ts.map +1 -0
  182. package/build-types/popover/stories/index.story.d.ts +211 -0
  183. package/build-types/popover/stories/index.story.d.ts.map +1 -0
  184. package/build-types/popover/stories/utils.d.ts +25 -0
  185. package/build-types/popover/stories/utils.d.ts.map +1 -0
  186. package/build-types/popover/test/index.test.d.ts +2 -0
  187. package/build-types/popover/test/index.test.d.ts.map +1 -0
  188. package/build-types/popover/title.d.ts +20 -0
  189. package/build-types/popover/title.d.ts.map +1 -0
  190. package/build-types/popover/trigger.d.ts +10 -0
  191. package/build-types/popover/trigger.d.ts.map +1 -0
  192. package/build-types/popover/types.d.ts +83 -0
  193. package/build-types/popover/types.d.ts.map +1 -0
  194. package/build-types/text/stories/index.story.d.ts +4 -0
  195. package/build-types/text/stories/index.story.d.ts.map +1 -1
  196. package/build-types/text/text.d.ts.map +1 -1
  197. package/build-types/utils/use-deprioritized-initial-focus.d.ts +6 -5
  198. package/build-types/utils/use-deprioritized-initial-focus.d.ts.map +1 -1
  199. package/package.json +11 -11
  200. package/src/alert-dialog/context.tsx +12 -4
  201. package/src/alert-dialog/popup.tsx +91 -33
  202. package/src/alert-dialog/root.tsx +191 -13
  203. package/src/alert-dialog/stories/index.story.tsx +116 -65
  204. package/src/alert-dialog/style.module.css +11 -0
  205. package/src/alert-dialog/test/index.test.tsx +1265 -347
  206. package/src/alert-dialog/trigger.tsx +2 -2
  207. package/src/alert-dialog/types.ts +59 -28
  208. package/src/button/button.tsx +2 -0
  209. package/src/button/style.module.css +4 -0
  210. package/src/card/stories/index.story.tsx +0 -1
  211. package/src/card/style.module.css +1 -1
  212. package/src/card/test/index.test.tsx +0 -1
  213. package/src/empty-state/title.tsx +0 -1
  214. package/src/form/primitives/field/description.tsx +6 -1
  215. package/src/form/primitives/fieldset/description.tsx +9 -1
  216. package/src/form/primitives/input/input.tsx +6 -1
  217. package/src/form/primitives/input/style.module.css +4 -0
  218. package/src/form/primitives/input-layout/input-layout.tsx +2 -0
  219. package/src/form/primitives/textarea/textarea.tsx +10 -1
  220. package/src/form/stories/shared.tsx +4 -2
  221. package/src/index.ts +1 -0
  222. package/src/link/link.tsx +2 -0
  223. package/src/link/style.module.css +10 -0
  224. package/src/popover/arrow.tsx +49 -0
  225. package/src/popover/close.tsx +24 -0
  226. package/src/popover/context.tsx +100 -0
  227. package/src/popover/description.tsx +34 -0
  228. package/src/popover/index.ts +9 -0
  229. package/src/popover/popup.tsx +106 -0
  230. package/src/popover/root.tsx +41 -0
  231. package/src/popover/stories/index.story.tsx +1315 -0
  232. package/src/popover/stories/utils.tsx +91 -0
  233. package/src/popover/style.module.css +64 -0
  234. package/src/popover/test/index.test.tsx +727 -0
  235. package/src/popover/title.tsx +50 -0
  236. package/src/popover/trigger.tsx +17 -0
  237. package/src/popover/types.ts +113 -0
  238. package/src/text/stories/index.story.tsx +4 -2
  239. package/src/text/style.module.css +26 -0
  240. package/src/text/test/index.test.tsx +1 -4
  241. package/src/text/text.tsx +8 -1
  242. package/src/utils/css/field.module.css +4 -1
  243. package/src/utils/css/focus.module.css +7 -5
  244. package/src/utils/css/global-css-defense.module.css +117 -0
  245. package/src/utils/use-deprioritized-initial-focus.ts +5 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.11.0-next.0 (2026-04-09)
6
+
7
+ ### Breaking Changes
8
+
9
+ - `Text`: Apply `margin: 0`, removing user-agent margins when the component renders as block-level elements (for example `p` or `h1`–`h6` via `render` prop) ([#76970](https://github.com/WordPress/gutenberg/pull/76970)).
10
+ - `AlertDialog`: Revise component API ([#76937](https://github.com/WordPress/gutenberg/pull/76937)):
11
+ - `AlertDialog.Root`: moved `intent` prop to `AlertDialog.Popup`;
12
+ - `AlertDialog.Popup`: moved `onConfirm` prop to `AlertDialog.Root` (now optional; supports async handlers, `{ close: false }` to keep the dialog open, and `{ error: '...' }` to display a built-in error message);
13
+ - `AlertDialog.Popup`: removed `loading` prop (async flows are now handled internally via `Promise`-returning `onConfirm`);
14
+ - `AlertDialog.Popup`: made `children` optional in favor of a new `description` prop, which describes the alert dialog semantically.
15
+
16
+ ### New Features
17
+
18
+ - Add `Popover` primitive ([#76438](https://github.com/WordPress/gutenberg/pull/76438)).
19
+
20
+ ### Bug Fixes
21
+
22
+ - `Card`: Set default foreground color on `Card.Root` so content and `currentColor` icons (for example the `CollapsibleCard` chevron) are themeable by default ([#77013](https://github.com/WordPress/gutenberg/pull/77013)).
23
+
24
+ ### Enhancements
25
+
26
+ - Add defensive styles against global WordPress stylesheets like common.css and forms.css ([#76783](https://github.com/WordPress/gutenberg/pull/76783)).
27
+
28
+ ### Internal
29
+
30
+ - `AlertDialog`: Rewrite internals to use Base UI's `AlertDialog` primitives directly instead of `Dialog` wrappers. Introduces an internal state machine for async confirm flows ([#76937](https://github.com/WordPress/gutenberg/pull/76937)).
31
+
5
32
  ## 0.10.0 (2026-04-01)
6
33
 
7
34
  ### New Features
package/CONTRIBUTING.md CHANGED
@@ -132,3 +132,28 @@ If a higher layer sets `.special-button { --button-bg: red; }`, that override wi
132
132
  ### Disabled State Styling
133
133
 
134
134
  For components built on Base UI, use the `data-disabled` attribute when styling disabled states rather than targeting `disabled` or `aria-disabled` directly. Base UI applies `data-disabled` consistently regardless of whether the underlying implementation uses the native `disabled` attribute or `aria-disabled` (which depends on the `focusableWhenDisabled` prop). This keeps styles decoupled from the specific HTML attribute and avoids verbose selectors that would need to target both.
135
+
136
+ ### Global CSS defense (wp-admin)
137
+
138
+ WordPress loads broad, **unlayered** global styles in the admin (`common.css`, `forms.css`) that target bare elements (`input`, `button`, `a`, `p`, headings, and so on). In the cascade, **unlayered rules always win over layered rules**, no matter how specific the layered selector is. That means normal `@wordpress/ui` styles, which live in `@layer wp-ui-*`, can be overridden by admin CSS and components may look wrong in wp-admin (borders, focus rings, typography, colors, and more).
139
+
140
+ **What it is:** [`global-css-defense.module.css`](src/utils/css/global-css-defense.module.css) is a shared, **unlayered** stylesheet that defines small, class-scoped rules (for example `.input`, `.textarea`, `.button`, `.a`, `p.p`, `:is(h1,…,h6).heading`, `.div`). Those classes are applied on the actual DOM nodes that need protection. Because the declarations are unlayered and use classes, they compete with admin styles on similar footing and can win by specificity.
141
+
142
+ **How it works (custom property bridge):** Each defended property is expressed with an internal custom property and a fallback, for example:
143
+
144
+ ```css
145
+ .input {
146
+ font-size: var( --_gcd-input-font-size, inherit );
147
+ }
148
+ ```
149
+
150
+ - The **fallback** encodes the default that `@wordpress/ui` wants when nothing else is set, so many components need no extra declarations.
151
+ - A component’s **layered** module can set `--_gcd-*` on a wrapper or the element itself. Custom property resolution is not blocked by cascade layers the same way longhand properties are, so the layered stylesheet can still supply the real token values while the unlayered rule applies them in a context where admin CSS would otherwise win.
152
+
153
+ Use the `--_gcd-*` prefix only inside this package; treat these variables as implementation details, not public theming API.
154
+
155
+ **When to use it:** Whenever you introduce or change a primitive that renders a native element commonly styled by wp-admin globals, wire in the matching defense class from `global-css-defense.module.css` (see existing usages in `Button`, `Input`, `Textarea`, `Link`, `Text`, field descriptions, and related form primitives). If admin styles affect a new element type, extend the defense module with a new class and the same bridge pattern rather than duplicating unlayered overrides inside individual components.
156
+
157
+ **Testing:** In Storybook, enable **WordPress global CSS** from the toolbar and compare stories with that mode on and off; appearance should match aside from intentional differences.
158
+
159
+ Long term, Core may reduce the need for this by [scoping](https://core.trac.wordpress.org/ticket/64939). Until then, this module is the supported way to keep components predictable inside wp-admin.
package/README.md CHANGED
@@ -24,16 +24,36 @@ Install using NPM:
24
24
  npm install @wordpress/ui
25
25
  ```
26
26
 
27
- As an implementation of the design system and companion to the `@wordpress/theme` package, these components depend on CSS custom properties defined by the theme package. This is managed on your behalf in a WordPress admin page context, but you will need to install and include the base theme stylesheet yourself if you're using the components in an application outside WordPress:
27
+ ## Setup
28
+
29
+ As an implementation of the design system and companion to the `@wordpress/theme` package, these components depend on CSS custom properties defined by the theme package. What you need to set up depends on whether you're building for a WordPress context, and how much of the theming features you want to use.
30
+
31
+ ### Within WordPress
32
+
33
+ Stylesheets are managed on your behalf in a WordPress context, so you don't need to worry about loading them yourself.
34
+
35
+ ### Outside WordPress
36
+
37
+ While the components ship with basic fallbacks for every CSS custom property, it's recommended that you install and load the design tokens stylesheet to support the full range of theming capabilities:
28
38
 
29
39
  ```
30
40
  npm install @wordpress/theme
31
41
  ```
32
42
 
33
- ```tsx
43
+ ```js
34
44
  import '@wordpress/theme/design-tokens.css';
35
45
  ```
36
46
 
47
+ This stylesheet is universal and does not have a separate RTL version.
48
+
49
+ Also, to ensure that portaled popovers appear correctly, add these isolation styles to your application's layout root element:
50
+
51
+ ```css
52
+ .root {
53
+ isolation: isolate;
54
+ }
55
+ ```
56
+
37
57
  ## Usage
38
58
 
39
59
  ### Basic Component Usage
@@ -24,8 +24,13 @@ __export(context_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(context_exports);
26
26
  var import_element = require("@wordpress/element");
27
+ var noop = async () => {
28
+ };
27
29
  var AlertDialogContext = (0, import_element.createContext)({
28
- intent: "default"
30
+ phase: "idle",
31
+ showSpinner: false,
32
+ errorMessage: void 0,
33
+ confirm: noop
29
34
  });
30
35
  // Annotate the CommonJS export names for ESM import in node:
31
36
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alert-dialog/context.tsx"],
4
- "sourcesContent": ["import { createContext } from '@wordpress/element';\nimport type { RootProps } from './types';\n\ntype Intent = NonNullable< RootProps[ 'intent' ] >;\n\ninterface AlertDialogContextValue {\n\tintent: Intent;\n}\n\nconst AlertDialogContext = createContext< AlertDialogContextValue >( {\n\tintent: 'default',\n} );\n\nexport { AlertDialogContext };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAS9B,IAAM,yBAAqB,8BAA0C;AAAA,EACpE,QAAQ;AACT,CAAE;",
4
+ "sourcesContent": ["import { createContext } from '@wordpress/element';\n\ntype Phase = 'idle' | 'pending' | 'closing';\n\ninterface AlertDialogContextValue {\n\tphase: Phase;\n\tshowSpinner: boolean;\n\terrorMessage?: string;\n\tconfirm: () => Promise< void >;\n}\n\nconst noop = async () => {};\n\nconst AlertDialogContext = createContext< AlertDialogContextValue >( {\n\tphase: 'idle',\n\tshowSpinner: false,\n\terrorMessage: undefined,\n\tconfirm: noop,\n} );\n\nexport { AlertDialogContext };\nexport type { Phase };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAW9B,IAAM,OAAO,YAAY;AAAC;AAE1B,IAAM,yBAAqB,8BAA0C;AAAA,EACpE,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAAA,EACd,SAAS;AACV,CAAE;",
6
6
  "names": []
7
7
  }
@@ -30,59 +30,131 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // packages/ui/src/alert-dialog/popup.tsx
31
31
  var popup_exports = {};
32
32
  __export(popup_exports, {
33
- Popup: () => Popup2
33
+ Popup: () => Popup
34
34
  });
35
35
  module.exports = __toCommonJS(popup_exports);
36
+ var import_alert_dialog = require("@base-ui/react/alert-dialog");
37
+ var import_clsx = __toESM(require("clsx"));
36
38
  var import_element = require("@wordpress/element");
37
39
  var import_i18n = require("@wordpress/i18n");
40
+ var import_theme = require("@wordpress/theme");
38
41
  var import_button = require("../button/index.cjs");
39
- var Dialog = __toESM(require("../dialog/index.cjs"));
42
+
43
+ // packages/ui/src/dialog/style.module.css
44
+ if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='6520ba3376']")) {
45
+ const style = document.createElement("style");
46
+ style.setAttribute("data-wp-hash", "6520ba3376");
47
+ style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity .2s ease-out}}._8acaa98861620d4d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-font-size-md,13px);left:50%;line-height:var(--wpds-font-line-height-md,24px);max-height:calc(100vh - var(--wpds-dimension-padding-2xl, 24px)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:auto;padding:var(--wpds-dimension-padding-2xl,24px);position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--wpds-dimension-padding-2xl, 24px)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity .2s cubic-bezier(1,0,.2,1),transform .2s cubic-bezier(1,0,.2,1);&[data-open]{transition:opacity .2s cubic-bezier(.29,0,0,1),transform .2s cubic-bezier(.29,0,0,1)}}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100vh}}._76fb3b28fcbd45fc__header{align-items:center;display:flex;justify-content:space-between;margin-bottom:var(--wpds-dimension-gap-lg,16px)}.f636832002af749e__title{color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-size:var(--wpds-font-size-xl,20px);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-xl,32px);margin:0}._00eeb4f220cddae3__footer{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);justify-content:flex-end;margin-top:var(--wpds-dimension-gap-lg,16px);padding-top:var(--wpds-dimension-padding-lg,16px)}}'));
48
+ document.head.appendChild(style);
49
+ }
50
+ var style_default = { "backdrop": "_074affe4c56b4f2f__backdrop", "popup": "_8acaa98861620d4d__popup", "is-small": "_7acfa67ebf092988__is-small", "is-medium": "_1eeeed880cb5769d__is-medium", "is-large": "_99f900b2267e22d0__is-large", "is-stretch": "b49f7ff9c06fe387__is-stretch", "is-full": "dcd4c2f5036cbf1a__is-full", "header": "_76fb3b28fcbd45fc__header", "title": "f636832002af749e__title", "footer": "_00eeb4f220cddae3__footer" };
51
+
52
+ // packages/ui/src/alert-dialog/popup.tsx
53
+ var import_lock_unlock = require("../lock-unlock.cjs");
54
+ var import_stack = require("../stack/index.cjs");
55
+ var import_text = require("../text/index.cjs");
40
56
  var import_context = require("./context.cjs");
41
57
 
42
58
  // packages/ui/src/alert-dialog/style.module.css
43
- if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='35295c8521']")) {
59
+ if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='113a8b8edd']")) {
44
60
  const style = document.createElement("style");
45
- style.setAttribute("data-wp-hash", "35295c8521");
46
- style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-compositions{._2ddc2fc9155a1dad__irreversible-action{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-error-strong,#cc1818);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-error-strong-active,#b90000);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-error-strong,#f2efef);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-error-strong-active,#f2efef)}}"));
61
+ style.setAttribute("data-wp-hash", "113a8b8edd");
62
+ style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._837a6eb481252f50__header{margin-bottom:var(--wpds-dimension-gap-lg,16px)}.dbff6618234a2a93__error-message{align-self:flex-end;color:var(--wpds-color-fg-content-error,#470000)}}@layer wp-ui-compositions{._2ddc2fc9155a1dad__irreversible-action{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-error-strong,#cc1818);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-error-strong-active,#b90000);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-error-strong,#f2efef);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-error-strong-active,#f2efef)}}"));
47
63
  document.head.appendChild(style);
48
64
  }
49
- var style_default = { "irreversible-action": "_2ddc2fc9155a1dad__irreversible-action" };
65
+ var style_default2 = { "header": "_837a6eb481252f50__header", "error-message": "dbff6618234a2a93__error-message", "irreversible-action": "_2ddc2fc9155a1dad__irreversible-action" };
50
66
 
51
67
  // packages/ui/src/alert-dialog/popup.tsx
52
68
  var import_jsx_runtime = require("react/jsx-runtime");
53
- var Popup2 = (0, import_element.forwardRef)(
69
+ var ThemeProvider = (0, import_lock_unlock.unlock)(import_theme.privateApis).ThemeProvider;
70
+ var Popup = (0, import_element.forwardRef)(
54
71
  function AlertDialogPopup({
72
+ className,
73
+ intent = "default",
55
74
  title,
75
+ description,
56
76
  children,
57
- onConfirm,
58
77
  confirmButtonText = (0, import_i18n.__)("OK"),
59
78
  cancelButtonText = (0, import_i18n.__)("Cancel"),
60
- loading
79
+ ...props
61
80
  }, ref) {
62
- const { intent } = (0, import_element.useContext)(import_context.AlertDialogContext);
63
- const ConfirmButton = loading !== void 0 ? import_button.Button : Dialog.Action;
64
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Dialog.Popup, { ref, children: [
65
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog.Title, { children: title }) }),
66
- children,
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Dialog.Footer, { children: [
68
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- Dialog.Action,
70
- {
71
- variant: "minimal",
72
- disabled: loading || void 0,
73
- children: cancelButtonText
74
- }
75
- ),
76
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
- ConfirmButton,
78
- {
79
- className: intent === "irreversible" ? style_default["irreversible-action"] : void 0,
80
- onClick: onConfirm,
81
- loading,
82
- children: confirmButtonText
83
- }
84
- )
85
- ] })
81
+ const { phase, showSpinner, errorMessage, confirm } = (0, import_element.useContext)(import_context.AlertDialogContext);
82
+ const confirmClassName = intent === "irreversible" ? style_default2["irreversible-action"] : void 0;
83
+ const buttonsDisabled = phase !== "idle" || void 0;
84
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_alert_dialog.AlertDialog.Portal, { children: [
85
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert_dialog.AlertDialog.Backdrop, { className: style_default.backdrop }),
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
87
+ import_alert_dialog.AlertDialog.Popup,
88
+ {
89
+ ref,
90
+ className: (0, import_clsx.default)(
91
+ style_default.popup,
92
+ className,
93
+ style_default["is-medium"]
94
+ ),
95
+ ...props,
96
+ children: [
97
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
98
+ import_stack.Stack,
99
+ {
100
+ direction: "column",
101
+ gap: "sm",
102
+ className: style_default2.header,
103
+ children: [
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ import_text.Text,
106
+ {
107
+ variant: "heading-xl",
108
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert_dialog.AlertDialog.Title, {}),
109
+ className: style_default.title,
110
+ children: title
111
+ }
112
+ ),
113
+ description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
+ import_text.Text,
115
+ {
116
+ variant: "body-md",
117
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert_dialog.AlertDialog.Description, {}),
118
+ children: description
119
+ }
120
+ )
121
+ ]
122
+ }
123
+ ),
124
+ children,
125
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_stack.Stack, { direction: "column", gap: "md", children: [
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: style_default.footer, children: [
127
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
128
+ import_alert_dialog.AlertDialog.Close,
129
+ {
130
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "minimal" }),
131
+ disabled: buttonsDisabled,
132
+ children: cancelButtonText
133
+ }
134
+ ),
135
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
136
+ import_button.Button,
137
+ {
138
+ className: confirmClassName,
139
+ onClick: confirm,
140
+ loading: showSpinner || void 0,
141
+ disabled: buttonsDisabled,
142
+ children: confirmButtonText
143
+ }
144
+ )
145
+ ] }),
146
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
+ import_text.Text,
148
+ {
149
+ variant: "body-sm",
150
+ className: style_default2["error-message"],
151
+ children: errorMessage
152
+ }
153
+ )
154
+ ] })
155
+ ]
156
+ }
157
+ ) })
86
158
  ] });
87
159
  }
88
160
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/alert-dialog/popup.tsx", "../../src/alert-dialog/style.module.css"],
4
- "sourcesContent": ["import { forwardRef, useContext } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '../button';\nimport * as Dialog from '../dialog';\nimport { AlertDialogContext } from './context';\nimport styles from './style.module.css';\nimport type { PopupProps } from './types';\n\nconst Popup = forwardRef< HTMLDivElement, PopupProps >(\n\tfunction AlertDialogPopup(\n\t\t{\n\t\t\ttitle,\n\t\t\tchildren,\n\t\t\tonConfirm,\n\t\t\tconfirmButtonText = __( 'OK' ),\n\t\t\tcancelButtonText = __( 'Cancel' ),\n\t\t\tloading,\n\t\t},\n\t\tref\n\t) {\n\t\tconst { intent } = useContext( AlertDialogContext );\n\n\t\t// When `loading` is provided, the consumer controls when the dialog\n\t\t// closes (async flow). Use a plain Button so clicking confirm doesn't\n\t\t// auto-close \u2014 the consumer sets `open={false}` after their operation.\n\t\tconst ConfirmButton = loading !== undefined ? Button : Dialog.Action;\n\n\t\treturn (\n\t\t\t<Dialog.Popup ref={ ref }>\n\t\t\t\t<Dialog.Header>\n\t\t\t\t\t<Dialog.Title>{ title }</Dialog.Title>\n\t\t\t\t</Dialog.Header>\n\t\t\t\t{ children }\n\t\t\t\t<Dialog.Footer>\n\t\t\t\t\t<Dialog.Action\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\tdisabled={ loading || undefined }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ cancelButtonText }\n\t\t\t\t\t</Dialog.Action>\n\t\t\t\t\t<ConfirmButton\n\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\tintent === 'irreversible'\n\t\t\t\t\t\t\t\t? styles[ 'irreversible-action' ]\n\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={ onConfirm }\n\t\t\t\t\t\tloading={ loading }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmButtonText }\n\t\t\t\t\t</ConfirmButton>\n\t\t\t\t</Dialog.Footer>\n\t\t\t</Dialog.Popup>\n\t\t);\n\t}\n);\n\nexport { Popup };\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='35295c8521']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"35295c8521\");\n\tstyle.appendChild(document.createTextNode(\"@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-compositions{._2ddc2fc9155a1dad__irreversible-action{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-error-strong,#cc1818);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-error-strong-active,#b90000);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-error-strong,#f2efef);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-error-strong-active,#f2efef)}}\"));\n\tdocument.head.appendChild(style);\n}\nexport default {\"irreversible-action\":\"_2ddc2fc9155a1dad__irreversible-action\"};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,eAAAA;AAAA;AAAA;AAAA,qBAAuC;AACvC,kBAAmB;AACnB,oBAAuB;AACvB,aAAwB;AACxB,qBAAmC;;;ACJnC,IAAI,OAAO,aAAa,eAAe,QAAQ,IAAI,aAAa,UAAU,CAAC,SAAS,KAAK,cAAc,kCAAkC,GAAG;AAC3I,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,aAAa,gBAAgB,YAAY;AAC/C,QAAM,YAAY,SAAS,eAAe,ugBAAugB,CAAC;AACljB,WAAS,KAAK,YAAY,KAAK;AAChC;AACA,IAAO,gBAAQ,EAAC,uBAAsB,yCAAwC;;;ADwBzE;AAtBL,IAAMC,aAAQ;AAAA,EACb,SAAS,iBACR;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA,wBAAoB,gBAAI,IAAK;AAAA,IAC7B,uBAAmB,gBAAI,QAAS;AAAA,IAChC;AAAA,EACD,GACA,KACC;AACD,UAAM,EAAE,OAAO,QAAI,2BAAY,iCAAmB;AAKlD,UAAM,gBAAgB,YAAY,SAAY,uBAAgB;AAE9D,WACC,6CAAQ,cAAP,EAAa,KACb;AAAA,kDAAQ,eAAP,EACA,sDAAQ,cAAP,EAAe,iBAAO,GACxB;AAAA,MACE;AAAA,MACF,6CAAQ,eAAP,EACA;AAAA;AAAA,UAAQ;AAAA,UAAP;AAAA,YACA,SAAQ;AAAA,YACR,UAAW,WAAW;AAAA,YAEpB;AAAA;AAAA,QACH;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACA,WACC,WAAW,iBACR,cAAQ,qBAAsB,IAC9B;AAAA,YAEJ,SAAU;AAAA,YACV;AAAA,YAEE;AAAA;AAAA,QACH;AAAA,SACD;AAAA,OACD;AAAA,EAEF;AACD;",
6
- "names": ["Popup", "Popup"]
3
+ "sources": ["../../src/alert-dialog/popup.tsx", "../../src/dialog/style.module.css", "../../src/alert-dialog/style.module.css"],
4
+ "sourcesContent": ["import { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport clsx from 'clsx';\nimport { forwardRef, useContext } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\ttype ThemeProvider as ThemeProviderType,\n\tprivateApis as themePrivateApis,\n} from '@wordpress/theme';\n\nimport { Button } from '../button';\nimport dialogStyles from '../dialog/style.module.css';\nimport { unlock } from '../lock-unlock';\nimport { Stack } from '../stack';\nimport { Text } from '../text';\nimport { AlertDialogContext } from './context';\nimport alertDialogStyles from './style.module.css';\nimport type { PopupProps } from './types';\n\nconst ThemeProvider: typeof ThemeProviderType =\n\tunlock( themePrivateApis ).ThemeProvider;\n\nconst Popup = forwardRef< HTMLDivElement, PopupProps >(\n\tfunction AlertDialogPopup(\n\t\t{\n\t\t\tclassName,\n\t\t\tintent = 'default',\n\t\t\ttitle,\n\t\t\tdescription,\n\t\t\tchildren,\n\t\t\tconfirmButtonText = __( 'OK' ),\n\t\t\tcancelButtonText = __( 'Cancel' ),\n\t\t\t...props\n\t\t},\n\t\tref\n\t) {\n\t\tconst { phase, showSpinner, errorMessage, confirm } =\n\t\t\tuseContext( AlertDialogContext );\n\n\t\tconst confirmClassName =\n\t\t\tintent === 'irreversible'\n\t\t\t\t? alertDialogStyles[ 'irreversible-action' ]\n\t\t\t\t: undefined;\n\n\t\tconst buttonsDisabled = phase !== 'idle' || undefined;\n\n\t\treturn (\n\t\t\t<_AlertDialog.Portal>\n\t\t\t\t<_AlertDialog.Backdrop className={ dialogStyles.backdrop } />\n\t\t\t\t<ThemeProvider>\n\t\t\t\t\t<_AlertDialog.Popup\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\tdialogStyles.popup,\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\tdialogStyles[ 'is-medium' ]\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Stack\n\t\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\t\t\tclassName={ alertDialogStyles.header }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\tvariant=\"heading-xl\"\n\t\t\t\t\t\t\t\trender={ <_AlertDialog.Title /> }\n\t\t\t\t\t\t\t\tclassName={ dialogStyles.title }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t{ description && (\n\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\tvariant=\"body-md\"\n\t\t\t\t\t\t\t\t\trender={ <_AlertDialog.Description /> }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<Stack direction=\"column\" gap=\"md\">\n\t\t\t\t\t\t\t<div className={ dialogStyles.footer }>\n\t\t\t\t\t\t\t\t<_AlertDialog.Close\n\t\t\t\t\t\t\t\t\trender={ <Button variant=\"minimal\" /> }\n\t\t\t\t\t\t\t\t\tdisabled={ buttonsDisabled }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ cancelButtonText }\n\t\t\t\t\t\t\t\t</_AlertDialog.Close>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName={ confirmClassName }\n\t\t\t\t\t\t\t\t\tonClick={ confirm }\n\t\t\t\t\t\t\t\t\tloading={ showSpinner || undefined }\n\t\t\t\t\t\t\t\t\tdisabled={ buttonsDisabled }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ confirmButtonText }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\t\t\tvariant=\"body-sm\"\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\talertDialogStyles[ 'error-message' ]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Stack>\n\t\t\t\t\t</_AlertDialog.Popup>\n\t\t\t\t</ThemeProvider>\n\t\t\t</_AlertDialog.Portal>\n\t\t);\n\t}\n);\n\nexport { Popup };\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='6520ba3376']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"6520ba3376\");\n\tstyle.appendChild(document.createTextNode(\"@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._074affe4c56b4f2f__backdrop{background-color:#00000059;inset:0;position:fixed;z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0}&[data-open]{opacity:1}@media not (prefers-reduced-motion){transition:opacity .2s ease-out}}._8acaa98861620d4d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-lg,8px);box-shadow:var(--wpds-elevation-lg,0 5px 15px 0 #00000014,0 15px 27px 0 #00000012,0 30px 36px 0 #0000000a,0 50px 43px 0 #00000005);box-sizing:border-box;color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-font-family-body,-apple-system,system-ui,\\\"Segoe UI\\\",\\\"Roboto\\\",\\\"Oxygen-Sans\\\",\\\"Ubuntu\\\",\\\"Cantarell\\\",\\\"Helvetica Neue\\\",sans-serif);font-size:var(--wpds-font-size-md,13px);left:50%;line-height:var(--wpds-font-line-height-md,24px);max-height:calc(100vh - var(--wpds-dimension-padding-2xl, 24px)*2);min-width:var(--wpds-dimension-surface-width-sm,320px);overflow:auto;padding:var(--wpds-dimension-padding-2xl,24px);position:fixed;top:50%;transform:translate(-50%,-50%);width:calc(100vw - var(--wpds-dimension-padding-2xl, 24px)*2);z-index:var(--wp-ui-dialog-z-index,initial);&[data-ending-style],&[data-starting-style]{opacity:0;transform:translate(-50%,-50%) scale(.9)}@media not (prefers-reduced-motion){transition:opacity .2s cubic-bezier(1,0,.2,1),transform .2s cubic-bezier(1,0,.2,1);&[data-open]{transition:opacity .2s cubic-bezier(.29,0,0,1),transform .2s cubic-bezier(.29,0,0,1)}}@media (min-width:480px){min-width:var(--wpds-dimension-surface-width-md,400px)}&._7acfa67ebf092988__is-small{max-width:var(--wpds-dimension-surface-width-md,400px)}&._1eeeed880cb5769d__is-medium{max-width:var(--wpds-dimension-surface-width-lg,560px)}&._99f900b2267e22d0__is-large{max-width:var(--wpds-dimension-surface-width-2xl,960px)}&.b49f7ff9c06fe387__is-stretch{max-width:none}&.dcd4c2f5036cbf1a__is-full{height:100vh}}._76fb3b28fcbd45fc__header{align-items:center;display:flex;justify-content:space-between;margin-bottom:var(--wpds-dimension-gap-lg,16px)}.f636832002af749e__title{color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-size:var(--wpds-font-size-xl,20px);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-xl,32px);margin:0}._00eeb4f220cddae3__footer{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px);justify-content:flex-end;margin-top:var(--wpds-dimension-gap-lg,16px);padding-top:var(--wpds-dimension-padding-lg,16px)}}\"));\n\tdocument.head.appendChild(style);\n}\nexport default {\"backdrop\":\"_074affe4c56b4f2f__backdrop\",\"popup\":\"_8acaa98861620d4d__popup\",\"is-small\":\"_7acfa67ebf092988__is-small\",\"is-medium\":\"_1eeeed880cb5769d__is-medium\",\"is-large\":\"_99f900b2267e22d0__is-large\",\"is-stretch\":\"b49f7ff9c06fe387__is-stretch\",\"is-full\":\"dcd4c2f5036cbf1a__is-full\",\"header\":\"_76fb3b28fcbd45fc__header\",\"title\":\"f636832002af749e__title\",\"footer\":\"_00eeb4f220cddae3__footer\"};\n", "if (typeof document !== 'undefined' && process.env.NODE_ENV !== 'test' && !document.head.querySelector(\"style[data-wp-hash='113a8b8edd']\")) {\n\tconst style = document.createElement(\"style\");\n\tstyle.setAttribute(\"data-wp-hash\", \"113a8b8edd\");\n\tstyle.appendChild(document.createTextNode(\"@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._837a6eb481252f50__header{margin-bottom:var(--wpds-dimension-gap-lg,16px)}.dbff6618234a2a93__error-message{align-self:flex-end;color:var(--wpds-color-fg-content-error,#470000)}}@layer wp-ui-compositions{._2ddc2fc9155a1dad__irreversible-action{--wp-ui-button-background-color:var(--wpds-color-bg-interactive-error-strong,#cc1818);--wp-ui-button-background-color-active:var(--wpds-color-bg-interactive-error-strong-active,#b90000);--wp-ui-button-foreground-color:var(--wpds-color-fg-interactive-error-strong,#f2efef);--wp-ui-button-foreground-color-active:var(--wpds-color-fg-interactive-error-strong-active,#f2efef)}}\"));\n\tdocument.head.appendChild(style);\n}\nexport default {\"header\":\"_837a6eb481252f50__header\",\"error-message\":\"dbff6618234a2a93__error-message\",\"irreversible-action\":\"_2ddc2fc9155a1dad__irreversible-action\"};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAC5C,kBAAiB;AACjB,qBAAuC;AACvC,kBAAmB;AACnB,mBAGO;AAEP,oBAAuB;;;ACTvB,IAAI,OAAO,aAAa,eAAe,QAAQ,IAA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GACD;AAAA,OACD;AAAA,EAEF;AACD;",
6
+ "names": ["style_default", "themePrivateApis", "style_default", "_AlertDialog", "clsx"]
7
7
  }
@@ -24,23 +24,123 @@ __export(root_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(root_exports);
26
26
  var import_alert_dialog = require("@base-ui/react/alert-dialog");
27
+ var import_a11y = require("@wordpress/a11y");
27
28
  var import_element = require("@wordpress/element");
28
29
  var import_context = require("./context.cjs");
29
30
  var import_jsx_runtime = require("react/jsx-runtime");
31
+ function isThenable(value) {
32
+ return value !== null && value !== void 0 && typeof value.then === "function";
33
+ }
30
34
  function Root({
31
- intent = "default",
32
35
  children,
33
- open,
36
+ open: openProp,
34
37
  onOpenChange,
35
- defaultOpen
38
+ defaultOpen,
39
+ onConfirm
36
40
  }) {
37
- const contextValue = (0, import_element.useMemo)(() => ({ intent }), [intent]);
41
+ const [internalOpen, setInternalOpen] = (0, import_element.useState)(defaultOpen ?? false);
42
+ const [phase, setPhase] = (0, import_element.useState)("idle");
43
+ const [showSpinner, setShowSpinner] = (0, import_element.useState)(false);
44
+ const [errorMessage, setErrorMessage] = (0, import_element.useState)();
45
+ const actionsRef = (0, import_element.useRef)(null);
46
+ const onConfirmRef = (0, import_element.useRef)(onConfirm);
47
+ onConfirmRef.current = onConfirm;
48
+ const phaseRef = (0, import_element.useRef)(phase);
49
+ phaseRef.current = phase;
50
+ const confirmIdRef = (0, import_element.useRef)(0);
51
+ const effectiveOpen = openProp ?? internalOpen;
52
+ (0, import_element.useEffect)(() => {
53
+ if (effectiveOpen && phase === "closing") {
54
+ phaseRef.current = "idle";
55
+ setPhase("idle");
56
+ setShowSpinner(false);
57
+ }
58
+ }, [effectiveOpen, phase]);
59
+ const handleOpenChange = (0, import_element.useCallback)(
60
+ (nextOpen, eventDetails) => {
61
+ if (!nextOpen && phaseRef.current === "pending") {
62
+ return;
63
+ }
64
+ if (!nextOpen && phaseRef.current === "idle") {
65
+ phaseRef.current = "closing";
66
+ setPhase("closing");
67
+ }
68
+ setInternalOpen(nextOpen);
69
+ onOpenChange?.(nextOpen, eventDetails);
70
+ },
71
+ [onOpenChange]
72
+ );
73
+ const confirm = (0, import_element.useCallback)(async () => {
74
+ if (phaseRef.current !== "idle") {
75
+ return;
76
+ }
77
+ phaseRef.current = "pending";
78
+ setPhase("pending");
79
+ setErrorMessage(void 0);
80
+ const id = ++confirmIdRef.current;
81
+ try {
82
+ const rawResult = onConfirmRef.current?.();
83
+ if (isThenable(rawResult)) {
84
+ setShowSpinner(true);
85
+ }
86
+ const result = await Promise.resolve(rawResult);
87
+ if (confirmIdRef.current !== id) {
88
+ return;
89
+ }
90
+ if (result?.error) {
91
+ phaseRef.current = "idle";
92
+ setPhase("idle");
93
+ setShowSpinner(false);
94
+ setErrorMessage(result.error);
95
+ (0, import_a11y.speak)(result.error, "assertive");
96
+ return;
97
+ }
98
+ const shouldClose = result?.close !== false;
99
+ if (shouldClose) {
100
+ phaseRef.current = "closing";
101
+ setPhase("closing");
102
+ actionsRef.current?.close();
103
+ } else {
104
+ phaseRef.current = "idle";
105
+ setPhase("idle");
106
+ setShowSpinner(false);
107
+ }
108
+ } catch (error) {
109
+ if (confirmIdRef.current !== id) {
110
+ return;
111
+ }
112
+ phaseRef.current = "idle";
113
+ setPhase("idle");
114
+ setShowSpinner(false);
115
+ console.error(error);
116
+ }
117
+ }, []);
118
+ const handleOpenChangeComplete = (0, import_element.useCallback)((open) => {
119
+ if (!open) {
120
+ confirmIdRef.current++;
121
+ phaseRef.current = "idle";
122
+ setPhase("idle");
123
+ setShowSpinner(false);
124
+ setErrorMessage(void 0);
125
+ }
126
+ }, []);
127
+ const contextValue = (0, import_element.useMemo)(
128
+ () => ({
129
+ phase,
130
+ showSpinner,
131
+ errorMessage,
132
+ confirm
133
+ }),
134
+ [phase, showSpinner, errorMessage, confirm]
135
+ );
38
136
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
39
137
  import_alert_dialog.AlertDialog.Root,
40
138
  {
41
- open,
42
- onOpenChange,
139
+ open: effectiveOpen,
43
140
  defaultOpen,
141
+ onOpenChange: handleOpenChange,
142
+ onOpenChangeComplete: handleOpenChangeComplete,
143
+ actionsRef,
44
144
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.AlertDialogContext.Provider, { value: contextValue, children })
45
145
  }
46
146
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alert-dialog/root.tsx"],
4
- "sourcesContent": ["import { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport { useMemo } from '@wordpress/element';\nimport { AlertDialogContext } from './context';\nimport type { RootProps } from './types';\n\n/**\n * A dialog that requires a user response to proceed.\n *\n * Use `AlertDialog.Trigger` to render a button that opens the dialog.\n * Use `AlertDialog.Popup` to render the dialog content.\n * The `AlertDialog.Trigger` is optional \u2014 the dialog can also be controlled\n * via `open` / `onOpenChange` props.\n *\n * ## Use cases\n *\n * - **Default intent**: Standard confirmation dialog for reversible actions.\n * - **Irreversible intent**: Confirmation dialog for irreversible actions that\n * cannot be undone. The confirm button uses error/danger coloring.\n *\n * For use cases outside the standard confirm/cancel pattern, use the lower-level\n * `Dialog` component directly.\n *\n * See the [Destructive Actions guidelines](?path=/docs/design-system-patterns-destructive-actions--docs)\n * for more details on when to use each pattern.\n */\nfunction Root( {\n\tintent = 'default',\n\tchildren,\n\topen,\n\tonOpenChange,\n\tdefaultOpen,\n}: RootProps ) {\n\tconst contextValue = useMemo( () => ( { intent } ), [ intent ] );\n\n\treturn (\n\t\t<_AlertDialog.Root\n\t\t\topen={ open }\n\t\t\tonOpenChange={ onOpenChange }\n\t\t\tdefaultOpen={ defaultOpen }\n\t\t>\n\t\t\t<AlertDialogContext.Provider value={ contextValue }>\n\t\t\t\t{ children }\n\t\t\t</AlertDialogContext.Provider>\n\t\t</_AlertDialog.Root>\n\t);\n}\n\nexport { Root };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAC5C,qBAAwB;AACxB,qBAAmC;AAsChC;AAfH,SAAS,KAAM;AAAA,EACd,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAe;AACd,QAAM,mBAAe,wBAAS,OAAQ,EAAE,OAAO,IAAK,CAAE,MAAO,CAAE;AAE/D,SACC;AAAA,IAAC,oBAAAA,YAAa;AAAA,IAAb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,sDAAC,kCAAmB,UAAnB,EAA4B,OAAQ,cAClC,UACH;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["import { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport { speak } from '@wordpress/a11y';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\n\nimport { AlertDialogContext } from './context';\nimport type { Phase } from './context';\nimport type { RootProps } from './types';\n\nfunction isThenable( value: unknown ): value is PromiseLike< unknown > {\n\treturn (\n\t\tvalue !== null &&\n\t\tvalue !== undefined &&\n\t\ttypeof ( value as PromiseLike< unknown > ).then === 'function'\n\t);\n}\n\n/**\n * A dialog that requires a user response to proceed.\n *\n * Use `AlertDialog.Trigger` to render a button that opens the dialog.\n * Use `AlertDialog.Popup` to render the dialog content.\n * The `AlertDialog.Trigger` is optional \u2014 the dialog can also be controlled\n * via `open` / `onOpenChange` props.\n *\n * For use cases outside the standard confirm/cancel pattern, use the lower-level\n * `Dialog` component directly.\n *\n * See the [Destructive Actions guidelines](https://wordpress.github.io/gutenberg/?path=/docs/design-system-patterns-destructive-actions--docs)\n * for more details on when to use each pattern.\n */\nfunction Root( {\n\tchildren,\n\topen: openProp,\n\tonOpenChange,\n\tdefaultOpen,\n\tonConfirm,\n}: RootProps ) {\n\tconst [ internalOpen, setInternalOpen ] = useState( defaultOpen ?? false );\n\n\t// Internal state machine for the confirm-and-close lifecycle.\n\t//\n\t// Phase transitions:\n\t//\n\t// idle \u2500\u2500> pending \u2500\u2500> closing \u2500\u2500> idle\n\t// (confirm (success, (animation\n\t// clicked) close) complete)\n\t//\n\t// idle \u2500\u2500> pending \u2500\u2500> idle\n\t// (confirm (error, or\n\t// clicked) {close:false})\n\t//\n\t// idle \u2500\u2500> closing \u2500\u2500> idle\n\t// (cancel/ (animation\n\t// escape) complete)\n\t//\n\t// `showSpinner` tracks whether the confirm button shows a loading\n\t// indicator. It is orthogonal to `phase`:\n\t//\n\t// Scenario | pending | closing\n\t// --------------------------+---------+---------\n\t// Sync onConfirm | false | false\n\t// Async onConfirm (success) | true | true\n\t// Async onConfirm (error) | true | n/a (-> idle)\n\t// Cancel / Escape | n/a | false\n\t//\n\t// Buttons are disabled whenever phase !== 'idle'.\n\t// Dismiss (Escape / Cancel) is blocked during 'pending'.\n\tconst [ phase, setPhase ] = useState< Phase >( 'idle' );\n\tconst [ showSpinner, setShowSpinner ] = useState( false );\n\tconst [ errorMessage, setErrorMessage ] = useState< string >();\n\n\tconst actionsRef = useRef< _AlertDialog.Root.Actions | null >( null );\n\n\tconst onConfirmRef = useRef( onConfirm );\n\tonConfirmRef.current = onConfirm;\n\n\t// Ref keeps phase accessible synchronously from callbacks that may\n\t// run between a setState call and the subsequent React re-render.\n\tconst phaseRef = useRef( phase );\n\tphaseRef.current = phase;\n\n\t// Generation counter \u2014 safety net for the edge case where the component\n\t// unmounts while an async confirm is in flight. Also incremented when\n\t// the dialog finishes closing, so a stale promise settling after a\n\t// dismiss+reopen cycle is silently discarded.\n\tconst confirmIdRef = useRef( 0 );\n\n\tconst effectiveOpen = openProp ?? internalOpen;\n\n\t// Safety net: if the consumer keeps `open={true}` after a confirm\n\t// (i.e. does not react to `onOpenChange`), the phase would be stuck\n\t// at 'closing'. Detect the contradiction and reset to idle.\n\tuseEffect( () => {\n\t\tif ( effectiveOpen && phase === 'closing' ) {\n\t\t\tphaseRef.current = 'idle';\n\t\t\tsetPhase( 'idle' );\n\t\t\tsetShowSpinner( false );\n\t\t}\n\t}, [ effectiveOpen, phase ] );\n\n\tconst handleOpenChange = useCallback(\n\t\t(\n\t\t\tnextOpen: boolean,\n\t\t\teventDetails: _AlertDialog.Root.ChangeEventDetails\n\t\t) => {\n\t\t\t// Block dismiss while a confirm action is pending.\n\t\t\tif ( ! nextOpen && phaseRef.current === 'pending' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! nextOpen && phaseRef.current === 'idle' ) {\n\t\t\t\tphaseRef.current = 'closing';\n\t\t\t\tsetPhase( 'closing' );\n\t\t\t}\n\n\t\t\tsetInternalOpen( nextOpen );\n\t\t\tonOpenChange?.( nextOpen, eventDetails );\n\t\t},\n\t\t[ onOpenChange ]\n\t);\n\n\tconst confirm = useCallback( async () => {\n\t\tif ( phaseRef.current !== 'idle' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tphaseRef.current = 'pending';\n\t\tsetPhase( 'pending' );\n\t\tsetErrorMessage( undefined );\n\n\t\tconst id = ++confirmIdRef.current;\n\n\t\ttry {\n\t\t\tconst rawResult = onConfirmRef.current?.();\n\n\t\t\t// Show spinner only for async handlers (Promises).\n\t\t\t// Sync handlers resolve in the same tick \u2014 no spinner needed.\n\t\t\tif ( isThenable( rawResult ) ) {\n\t\t\t\tsetShowSpinner( true );\n\t\t\t}\n\n\t\t\tconst result = await Promise.resolve( rawResult );\n\n\t\t\t// Discard if the component unmounted or the dialog was\n\t\t\t// dismissed and reopened while the promise was in flight.\n\t\t\tif ( confirmIdRef.current !== id ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// An error message implies the dialog should stay open.\n\t\t\tif ( result?.error ) {\n\t\t\t\tphaseRef.current = 'idle';\n\t\t\t\tsetPhase( 'idle' );\n\t\t\t\tsetShowSpinner( false );\n\t\t\t\tsetErrorMessage( result.error );\n\t\t\t\tspeak( result.error, 'assertive' );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst shouldClose = result?.close !== false;\n\n\t\t\tif ( shouldClose ) {\n\t\t\t\tphaseRef.current = 'closing';\n\t\t\t\tsetPhase( 'closing' );\n\t\t\t\tactionsRef.current?.close();\n\t\t\t} else {\n\t\t\t\tphaseRef.current = 'idle';\n\t\t\t\tsetPhase( 'idle' );\n\t\t\t\tsetShowSpinner( false );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tif ( confirmIdRef.current !== id ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tphaseRef.current = 'idle';\n\t\t\tsetPhase( 'idle' );\n\t\t\tsetShowSpinner( false );\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( error );\n\t\t}\n\t}, [] );\n\n\tconst handleOpenChangeComplete = useCallback( ( open: boolean ) => {\n\t\tif ( ! open ) {\n\t\t\t// Invalidate any in-flight async so a stale promise settling\n\t\t\t// after dismiss+reopen doesn't close the new session.\n\t\t\tconfirmIdRef.current++;\n\t\t\tphaseRef.current = 'idle';\n\t\t\tsetPhase( 'idle' );\n\t\t\tsetShowSpinner( false );\n\t\t\tsetErrorMessage( undefined );\n\t\t}\n\t}, [] );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tphase,\n\t\t\tshowSpinner,\n\t\t\terrorMessage,\n\t\t\tconfirm,\n\t\t} ),\n\t\t[ phase, showSpinner, errorMessage, confirm ]\n\t);\n\n\treturn (\n\t\t<_AlertDialog.Root\n\t\t\topen={ effectiveOpen }\n\t\t\tdefaultOpen={ defaultOpen }\n\t\t\tonOpenChange={ handleOpenChange }\n\t\t\tonOpenChangeComplete={ handleOpenChangeComplete }\n\t\t\tactionsRef={ actionsRef }\n\t\t>\n\t\t\t<AlertDialogContext.Provider value={ contextValue }>\n\t\t\t\t{ children }\n\t\t\t</AlertDialogContext.Provider>\n\t\t</_AlertDialog.Root>\n\t);\n}\n\nexport { Root };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C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ACf,sBAAuB;AAAA,MACvB;AAAA,MAEA,sDAAC,kCAAmB,UAAnB,EAA4B,OAAQ,cAClC,UACH;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["_AlertDialog"]
7
7
  }
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,28 +15,20 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // packages/ui/src/alert-dialog/trigger.tsx
31
21
  var trigger_exports = {};
32
22
  __export(trigger_exports, {
33
- Trigger: () => Trigger2
23
+ Trigger: () => Trigger
34
24
  });
35
25
  module.exports = __toCommonJS(trigger_exports);
26
+ var import_alert_dialog = require("@base-ui/react/alert-dialog");
36
27
  var import_element = require("@wordpress/element");
37
- var Dialog = __toESM(require("../dialog/index.cjs"));
38
28
  var import_jsx_runtime = require("react/jsx-runtime");
39
- var Trigger2 = (0, import_element.forwardRef)(
29
+ var Trigger = (0, import_element.forwardRef)(
40
30
  function AlertDialogTrigger(props, ref) {
41
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog.Trigger, { ref, ...props });
31
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert_dialog.AlertDialog.Trigger, { ref, ...props });
42
32
  }
43
33
  );
44
34
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alert-dialog/trigger.tsx"],
4
- "sourcesContent": ["import { forwardRef } from '@wordpress/element';\n\nimport * as Dialog from '../dialog';\nimport type { TriggerProps } from './types';\n\n/**\n * Renders a button that opens the alert dialog when clicked.\n */\nconst Trigger = forwardRef< HTMLButtonElement, TriggerProps >(\n\tfunction AlertDialogTrigger( props, ref ) {\n\t\treturn <Dialog.Trigger ref={ ref } { ...props } />;\n\t}\n);\n\nexport { Trigger };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;AAAA,qBAA2B;AAE3B,aAAwB;AAQf;AAFT,IAAMA,eAAU;AAAA,EACf,SAAS,mBAAoB,OAAO,KAAM;AACzC,WAAO,4CAAQ,gBAAP,EAAe,KAAc,GAAG,OAAQ;AAAA,EACjD;AACD;",
6
- "names": ["Trigger"]
4
+ "sourcesContent": ["import { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport { forwardRef } from '@wordpress/element';\n\nimport type { TriggerProps } from './types';\n\n/**\n * Renders a button that opens the alert dialog when clicked.\n */\nconst Trigger = forwardRef< HTMLButtonElement, TriggerProps >(\n\tfunction AlertDialogTrigger( props, ref ) {\n\t\treturn <_AlertDialog.Trigger ref={ ref } { ...props } />;\n\t}\n);\n\nexport { Trigger };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4C;AAC5C,qBAA2B;AASlB;AAFT,IAAM,cAAU;AAAA,EACf,SAAS,mBAAoB,OAAO,KAAM;AACzC,WAAO,4CAAC,oBAAAA,YAAa,SAAb,EAAqB,KAAc,GAAG,OAAQ;AAAA,EACvD;AACD;",
6
+ "names": ["_AlertDialog"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/alert-dialog/types.ts"],
4
- "sourcesContent": ["import type { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport type { ReactNode } from 'react';\n\nimport type { TriggerProps as DialogTriggerProps } from '../dialog/types';\n\nexport interface RootProps\n\textends Pick<\n\t\t_AlertDialog.Root.Props,\n\t\t'open' | 'onOpenChange' | 'defaultOpen'\n\t> {\n\t/**\n\t * The content to be rendered inside the component. Typically includes\n\t * `AlertDialog.Trigger` and `AlertDialog.Popup`.\n\t */\n\tchildren: ReactNode;\n\n\t/**\n\t * The semantic intent of the dialog, which determines its styling.\n\t *\n\t * All intents use `role=\"alertdialog\"`, are always modal, and block\n\t * backdrop click dismissal. Escape key and the cancel/confirm buttons\n\t * still dismiss the dialog.\n\t *\n\t * - `'default'`: Standard confirmation dialog for reversible actions.\n\t * - `'irreversible'`: Confirmation dialog for irreversible actions that\n\t * cannot be undone. The confirm button uses error/danger coloring.\n\t *\n\t * @default 'default'\n\t */\n\tintent?: 'default' | 'irreversible';\n}\n\nexport type TriggerProps = DialogTriggerProps;\n\nexport interface PopupProps {\n\t/**\n\t * The title displayed in the dialog header. This serves as both the\n\t * visible heading and the accessible label for the dialog.\n\t */\n\ttitle: string;\n\n\t/**\n\t * The message content displayed in the dialog body.\n\t */\n\tchildren: ReactNode;\n\n\t/**\n\t * Callback fired when the user confirms the action.\n\t */\n\tonConfirm: () => void;\n\n\t/**\n\t * Custom text for the confirm button.\n\t *\n\t * @default 'OK'\n\t */\n\tconfirmButtonText?: string;\n\n\t/**\n\t * Custom text for the cancel button.\n\t *\n\t * @default 'Cancel'\n\t */\n\tcancelButtonText?: string;\n\n\t/**\n\t * Whether the confirm action is in a loading state (e.g. an async\n\t * operation is in progress). When `true`, the confirm button shows a\n\t * spinner and the cancel button is disabled.\n\t *\n\t * **Important:** Passing this prop \u2014 even as `false` \u2014 opts into\n\t * manual-close mode: the confirm button will no longer auto-close the\n\t * dialog. The consumer is responsible for setting `open={false}` when\n\t * the operation completes. Omit the prop entirely for the default\n\t * auto-close-on-confirm behavior.\n\t *\n\t * To implement an async confirm flow, use controlled mode\n\t * (`open` / `onOpenChange`) and manage the loading state externally:\n\t * prevent closing in `onOpenChange` while loading, and set\n\t * `open={false}` once the operation completes.\n\t */\n\tloading?: boolean;\n}\n"],
4
+ "sourcesContent": ["import type { AlertDialog as _AlertDialog } from '@base-ui/react/alert-dialog';\nimport type { ReactNode } from 'react';\n\nimport type { ComponentProps } from '../utils/types';\n\n/**\n * The return type of `onConfirm`. Return `void` (or nothing) to auto-close\n * the dialog after the confirm handler completes. Return `{ close: false }`\n * to keep the dialog open (e.g. for validation errors).\n *\n * Return `{ error: '...' }` to display a built-in error message below the\n * action buttons. When `error` is provided, the dialog stays open\n * regardless of the `close` value.\n */\nexport type ConfirmResult = void | { close?: boolean; error?: string };\n\nexport interface RootProps\n\textends Pick<\n\t\t_AlertDialog.Root.Props,\n\t\t'open' | 'onOpenChange' | 'defaultOpen'\n\t> {\n\t/**\n\t * The content to be rendered inside the component. Typically includes\n\t * `AlertDialog.Trigger` and `AlertDialog.Popup`.\n\t */\n\tchildren: ReactNode;\n\n\t/**\n\t * Callback fired when the user confirms the action.\n\t *\n\t * - Synchronous handlers: the dialog closes immediately after the\n\t * handler returns.\n\t * - Async handlers: the dialog enters a \"pending\" state (buttons\n\t * disabled, spinner shown on the confirm button) until the promise\n\t * settles.\n\t *\n\t * Return `{ close: false }` to keep the dialog open after the handler\n\t * completes (e.g. for server-side validation). Return `void` or\n\t * `{ close: true }` to close the dialog (the default).\n\t *\n\t * Return `{ error: '...' }` to show a built-in error message below\n\t * the action buttons. The dialog stays open regardless of the `close`\n\t * value. The error is announced to screen readers and is automatically\n\t * cleared on the next confirm attempt or when the dialog reopens.\n\t *\n\t * If the promise rejects (or the handler throws) without returning an\n\t * `error`, the dialog stays open and returns to idle without showing\n\t * a visible error message. The error is logged to the console.\n\t * To show a user-facing message on failure, catch the error and\n\t * return `{ close: false, error: '...' }`.\n\t */\n\tonConfirm?: () => ConfirmResult | Promise< ConfirmResult >;\n}\n\nexport interface TriggerProps extends ComponentProps< 'button' > {\n\t/**\n\t * The content to be rendered inside the component.\n\t */\n\tchildren?: ReactNode;\n}\n\nexport interface PopupProps\n\textends ComponentProps< 'div' >,\n\t\tPick< _AlertDialog.Popup.Props, 'initialFocus' | 'finalFocus' > {\n\t/**\n\t * The semantic intent of the dialog, which determines its styling.\n\t *\n\t * All intents use `role=\"alertdialog\"`, are always modal, and block\n\t * backdrop click dismissal. Escape key and the cancel/confirm buttons\n\t * still dismiss the dialog.\n\t *\n\t * - `'default'`: Standard confirmation dialog for reversible actions.\n\t * - `'irreversible'`: Confirmation dialog for irreversible actions that\n\t * cannot be undone. The confirm button uses error/danger coloring.\n\t *\n\t * @default 'default'\n\t */\n\tintent?: 'default' | 'irreversible';\n\n\t/**\n\t * The title displayed in the dialog header. This serves as both the\n\t * visible heading and the accessible label (`aria-labelledby`) for the\n\t * dialog. Must be a plain string to ensure a predictable accessible name.\n\t */\n\ttitle: string;\n\n\t/**\n\t * An optional description displayed below the title. Rendered using\n\t * Base UI's `AlertDialog.Description` for proper `aria-describedby`\n\t * association with the dialog. Must be a plain string to ensure a\n\t * predictable accessible description.\n\t */\n\tdescription?: string;\n\n\t/**\n\t * Optional body content displayed between the description and the\n\t * action buttons. Use for supplementary details or form fields.\n\t */\n\tchildren?: ReactNode;\n\n\t/**\n\t * Custom text for the confirm button.\n\t *\n\t * @default 'OK'\n\t */\n\tconfirmButtonText?: string;\n\n\t/**\n\t * Custom text for the cancel button.\n\t *\n\t * @default 'Cancel'\n\t */\n\tcancelButtonText?: string;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }