@aleph-alpha/ui-library 6.3.0 → 6.3.2

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.
@@ -430,8 +430,12 @@ export declare function renderShell(defaultOpen?: boolean, rows?: number, histor
430
430
  mobileTransitionDuration: string;
431
431
  resizable: boolean;
432
432
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
433
- $slots: {
434
- default?(_: {}): any;
433
+ $slots: Readonly<{
434
+ default(): unknown;
435
+ 'start-action'(): unknown;
436
+ }> & {
437
+ default(): unknown;
438
+ 'start-action'(): unknown;
435
439
  };
436
440
  });
437
441
  UiSidebarContent: {
@@ -1374,8 +1378,12 @@ export declare function renderShellWith(contentTemplate: string, extraComponents
1374
1378
  mobileTransitionDuration: string;
1375
1379
  resizable: boolean;
1376
1380
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
1377
- $slots: {
1378
- default?(_: {}): any;
1381
+ $slots: Readonly<{
1382
+ default(): unknown;
1383
+ 'start-action'(): unknown;
1384
+ }> & {
1385
+ default(): unknown;
1386
+ 'start-action'(): unknown;
1379
1387
  };
1380
1388
  });
1381
1389
  UiSidebarContent: {
@@ -2316,8 +2324,12 @@ export declare function renderMobileShell(defaultOpen?: boolean, rows?: number,
2316
2324
  mobileTransitionDuration: string;
2317
2325
  resizable: boolean;
2318
2326
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
2319
- $slots: {
2320
- default?(_: {}): any;
2327
+ $slots: Readonly<{
2328
+ default(): unknown;
2329
+ 'start-action'(): unknown;
2330
+ }> & {
2331
+ default(): unknown;
2332
+ 'start-action'(): unknown;
2321
2333
  };
2322
2334
  });
2323
2335
  UiSidebarContent: {
@@ -2833,7 +2845,7 @@ export declare function renderMobileShell(defaultOpen?: boolean, rows?: number,
2833
2845
  template: string;
2834
2846
  };
2835
2847
  /** What the arrangement looks like in a product, with the scaffolding removed. */
2836
- export declare const templateSource = "<!-- one fade for the shell: the band spans both columns on the bottom edge -->\n<UiFadeMask\n position=\"bottom\"\n background=\"primary\"\n class=\"flex h-svh w-full flex-col overflow-hidden\"\n :style=\"shellStyle\"\n>\n <!-- full-width bar; its toggle drives the same ref the sidebar is bound to,\n which is what `v-model:open` on the trigger is for: the bar is the\n sidebar's sibling, so there is no context for it to reach -->\n <UiTopBar ref=\"topBarRef\" class=\"shrink-0\" leading-width=\"calc(var(--sidebar-width, 16rem) - 1rem)\">\n <template #logo><AppWordmark /></template>\n <template #sidebar-toggle>\n <UiSidebarTrigger v-model:open=\"open\" tooltip=\"Toggle sidebar\" tooltip-side=\"bottom\" />\n </template>\n <!-- the avatar and the card it opens are Patterns/UiProfileCard -->\n <template #profile><ProfileCard /></template>\n </UiTopBar>\n\n <!-- the row beneath: sidebar column + content column -->\n <div class=\"flex min-h-0 w-full flex-1\">\n <!-- isolate: rows raise their own icons, which would otherwise escape the\n column and land over the shell's fade -->\n <UiSidebar v-model:open=\"open\" collapsible=\"icon\" class=\"isolate\" role=\"navigation\" aria-label=\"Main\">\n <UiSidebarContent>\u2026</UiSidebarContent>\n </UiSidebar>\n\n <main class=\"bg-background flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden\">\n <PageHeading />\n <!-- bottom padding matches the fade band so the last row clears it -->\n <div class=\"min-h-0 flex-1 overflow-y-auto pb-16 md:pb-24\"><PageContent /></div>\n </main>\n </div>\n</UiFadeMask>";
2848
+ export declare const templateSource = "<!-- one fade for the shell: the band spans both columns on the bottom edge -->\n<UiFadeMask\n position=\"bottom\"\n background=\"primary\"\n class=\"flex h-svh w-full flex-col overflow-hidden\"\n :style=\"shellStyle\"\n>\n <!-- full-width bar; its toggle drives the same ref the sidebar is bound to,\n which is what `v-model:open` on the trigger is for: the bar is the\n sidebar's sibling, so there is no context for it to reach. The bar only\n carries it while the sidebar is expanded \u2014 collapsed, the rail shows its\n own (see `start-action` below) -->\n <UiTopBar ref=\"topBarRef\" class=\"shrink-0\" leading-width=\"calc(var(--sidebar-width, 16rem) - 1rem)\">\n <template #logo><AppWordmark /></template>\n <template v-if=\"open\" #sidebar-toggle>\n <UiSidebarTrigger v-model:open=\"open\" tooltip=\"Toggle sidebar\" />\n </template>\n <!-- the avatar and the card it opens are Patterns/UiProfileCard -->\n <template #profile><ProfileCard /></template>\n </UiTopBar>\n\n <!-- the row beneath: sidebar column + content column -->\n <div class=\"flex min-h-0 w-full flex-1\">\n <!-- isolate: rows raise their own icons, which would otherwise escape the\n column and land over the shell's fade -->\n <UiSidebar v-model:open=\"open\" collapsible=\"icon\" class=\"isolate\" role=\"navigation\" aria-label=\"Main\">\n <!-- rendered only while the bound `open` is false: the collapsed rail\n carries the toggle the bar gave up, and inside the sidebar the\n trigger reads the context, so it takes no binding of its own -->\n <template #start-action>\n <UiSidebarMenu>\n <UiSidebarMenuItem>\n <UiSidebarTrigger tooltip=\"Toggle sidebar\" />\n </UiSidebarMenuItem>\n </UiSidebarMenu>\n </template>\n <UiSidebarContent>\u2026</UiSidebarContent>\n </UiSidebar>\n\n <main class=\"bg-background flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden\">\n <PageHeading />\n <!-- bottom padding matches the fade band so the last row clears it -->\n <div class=\"min-h-0 flex-1 overflow-y-auto pb-16 md:pb-24\"><PageContent /></div>\n </main>\n </div>\n</UiFadeMask>";
2837
2849
  /** The same shell on a phone: mobile bar slots, and a page that slides aside. */
2838
2850
  export declare const mobileTemplateSource = "<div class=\"relative h-svh w-full overflow-hidden\" :style=\"shellStyle\">\n <!-- the bar floats over both layers: mobile slots, no surface of its own -->\n <UiTopBar ref=\"topBarRef\" class=\"absolute inset-x-0 top-0 z-20 bg-transparent\">\n <template #logo><AppWordmark /></template>\n <template #mobile-logo><WorkspacePill /></template>\n <template #mobile-layout-actions>\n <MenuButton :aria-expanded=\"open\" @click=\"open = !open\" />\n </template>\n </UiTopBar>\n\n <!-- the base layer never moves, so it is a plain column, not the drawer; it\n starts below the bar, which is showing its controls -->\n <div class=\"absolute inset-0 isolate flex\" :style=\"{ paddingTop: 'var(--sidebar-offset-top, 3.75rem)' }\">\n <UiSidebar\n v-model:open=\"open\"\n collapsible=\"none\"\n class=\"h-full w-full\"\n role=\"navigation\"\n aria-label=\"Main\"\n :aria-hidden=\"open ? undefined : 'true'\"\n :inert=\"open ? undefined : true\"\n >\n <!-- the fade stays inside the scroll area here, so it dissolves the\n history above the profile row instead of over it -->\n <UiFadeMask position=\"bottom\" background=\"primary\" class=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n <UiSidebarContent>\u2026</UiSidebarContent>\n </UiFadeMask>\n <!-- the same card as on a wide screen, opening upwards from the row that\n replaces the avatar the bar gave up -->\n <UiSidebarFooter><ProfileCard /></UiSidebarFooter>\n </UiSidebar>\n </div>\n\n <!-- the sheet is what slides, revealing the layer it was covering; it runs\n the full height and fades at both ends, so the bar floats on the top one -->\n <main\n class=\"bg-background absolute inset-0 flex flex-col overflow-hidden transition-transform duration-200 ease-out\"\n :class=\"open ? 'translate-x-full' : 'translate-x-0'\"\n :inert=\"open || undefined\"\n >\n <!-- one mask, a band on each edge: the page fades under the bar and again\n at the bottom -->\n <UiFadeMask position=\"both\" background=\"secondary\" class=\"flex min-h-0 flex-1 flex-col overflow-hidden\">\n <!-- bottom padding matches the fade band so the last row clears it -->\n <div class=\"min-h-0 flex-1 overflow-y-auto pb-16 md:pb-24\" :style=\"{ paddingTop: 'var(--sidebar-offset-top, 3.75rem)' }\">\n <PageHeading />\n <PageContent />\n </div>\n </UiFadeMask>\n </main>\n</div>";
2839
2851
  export {};
@@ -1,7 +1,27 @@
1
1
  declare function __VLS_template(): {
2
2
  attrs: Partial<{}>;
3
- slots: {
4
- default?(_: {}): any;
3
+ slots: Readonly<{
4
+ /** Sidebar body — content, groups, and footer. */
5
+ default(): unknown;
6
+ /**
7
+ * Rendered at the top of the sidebar only while a bound `open` is `false`,
8
+ * so the collapsed icon rail can carry its own control — typically a
9
+ * `UiSidebarTrigger` that expands it again. Requires the controlled API
10
+ * (`v-model:open`); an uncontrolled sidebar never renders this slot, since
11
+ * the wrapper cannot see the state the core manages internally.
12
+ */
13
+ 'start-action'(): unknown;
14
+ }> & {
15
+ /** Sidebar body — content, groups, and footer. */
16
+ default(): unknown;
17
+ /**
18
+ * Rendered at the top of the sidebar only while a bound `open` is `false`,
19
+ * so the collapsed icon rail can carry its own control — typically a
20
+ * `UiSidebarTrigger` that expands it again. Requires the controlled API
21
+ * (`v-model:open`); an uncontrolled sidebar never renders this slot, since
22
+ * the wrapper cannot see the state the core manages internally.
23
+ */
24
+ 'start-action'(): unknown;
5
25
  };
6
26
  refs: {};
7
27
  rootEl: any;
@@ -59,8 +59,12 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
59
59
  mobileTransitionDuration: string;
60
60
  resizable: boolean;
61
61
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
62
- $slots: {
63
- default?(_: {}): any;
62
+ $slots: Readonly<{
63
+ default(): unknown;
64
+ 'start-action'(): unknown;
65
+ }> & {
66
+ default(): unknown;
67
+ 'start-action'(): unknown;
64
68
  };
65
69
  });
66
70
  UiSidebarContent: {
@@ -134,8 +138,12 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
134
138
  mobileTransitionDuration: string;
135
139
  resizable: boolean;
136
140
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
137
- $slots: {
138
- default?(_: {}): any;
141
+ $slots: Readonly<{
142
+ default(): unknown;
143
+ 'start-action'(): unknown;
144
+ }> & {
145
+ default(): unknown;
146
+ 'start-action'(): unknown;
139
147
  };
140
148
  });
141
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "6.3.0",
3
+ "version": "6.3.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -870,6 +870,94 @@ export const Sizes: Story = {
870
870
  },
871
871
  };
872
872
 
873
+ const IconsizesTemplateSource = `<script setup lang="ts">
874
+ import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
875
+ </script>
876
+
877
+ <template>
878
+ <div class="grid gap-4 md:grid-cols-4">
879
+ <!-- icon-xs is only available on the ghost variant -->
880
+ <UiButton variant="ghost" size="icon-xs" aria-label="Close">
881
+ <UiIcon name="Image" />
882
+ </UiButton>
883
+ <UiButton size="icon-sm" aria-label="Close">
884
+ <UiIcon name="Image" />
885
+ </UiButton>
886
+ <UiButton size="icon" aria-label="Close">
887
+ <UiIcon name="Image" />
888
+ </UiButton>
889
+ <UiButton size="icon-lg" aria-label="Close">
890
+ <UiIcon name="Image" />
891
+ </UiButton>
892
+ </div>
893
+ </template>`;
894
+
895
+ /**
896
+ * Icon-only button size guidance.
897
+ */
898
+ export const IconSizes: Story = {
899
+ render: (args) => ({
900
+ components: { UiButton, UiIcon },
901
+ setup() {
902
+ return { UiButton, UiIcon, args };
903
+ },
904
+ template: `
905
+ <section class="flex flex-col gap-6 rounded-lg bg-background-surface-primary p-4">
906
+ <div>
907
+ <h2 class="heading-s text-content-on-surface-primary">Sizes</h2>
908
+ <p class="body-14-regular mt-2 text-content-on-surface-primary">
909
+ Buttons come in three sizes: small, default and large. Buttons should match in size.
910
+ </p>
911
+ </div>
912
+
913
+ <div class="grid gap-3 md:grid-cols-4">
914
+ <div v-if="args.variant === 'ghost'" class="flex flex-col gap-3">
915
+ <h3 class="label-14-medium text-center text-content-on-surface-primary">Extra Small Icon</h3>
916
+ <div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
917
+ <UiButton :variant="args.variant" size="icon-xs" aria-label="Close">
918
+ <UiIcon name="Image" />
919
+ </UiButton>
920
+ </div>
921
+ </div>
922
+ <div class="flex flex-col gap-3">
923
+ <h3 class="label-14-medium text-center text-content-on-surface-primary">Small Icon</h3>
924
+ <div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
925
+ <UiButton :variant="args.variant" size="icon-sm" aria-label="Close">
926
+ <UiIcon name="Image" />
927
+ </UiButton>
928
+ </div>
929
+ </div>
930
+
931
+ <div class="flex flex-col gap-3">
932
+ <h3 class="label-14-medium text-center text-content-on-surface-primary">Default Icon</h3>
933
+ <div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
934
+ <UiButton :variant="args.variant" size="icon" aria-label="Close">
935
+ <UiIcon name="Image" />
936
+ </UiButton>
937
+ </div>
938
+ </div>
939
+
940
+ <div class="flex flex-col gap-3">
941
+ <h3 class="label-14-medium text-center text-content-on-surface-primary">Large Icon</h3>
942
+ <div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
943
+ <UiButton :variant="args.variant" size="icon-lg" aria-label="Close">
944
+ <UiIcon name="Image" />
945
+ </UiButton>
946
+ </div>
947
+ </div>
948
+ </div>
949
+ </section>
950
+ `,
951
+ }),
952
+ parameters: {
953
+ docs: {
954
+ source: {
955
+ code: IconsizesTemplateSource,
956
+ },
957
+ },
958
+ },
959
+ };
960
+
873
961
  const iconUsageTemplateSource = `<script setup lang="ts">
874
962
  import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
875
963
 
@@ -16,7 +16,7 @@ import { UiIcon } from '../UiIcon';
16
16
  import { UiInput } from '../UiInput';
17
17
 
18
18
  /**
19
- * Modal dialog (reka-ui + design tokens). **`UiDialogContent`** defaults to **`max-w-[50vw]`**; use **`maxWidth`** with a preset (`max-w-sm` … `max-w-2xl`, `max-w-none`, etc.) to override. Built-in title/description headers include a dismiss control unless **`show-close-button`** is false or you use the **`#header`** slot (then add your own **`UiDialogClose`**).
19
+ * Modal dialog (reka-ui + design tokens). **`UiDialogContent`** defaults to **`max-w-[50vw]`**; use **`maxWidth`** with a preset (`max-w-sm` … `max-w-2xl`, `max-w-none`, etc.) to override. A dismiss control is pinned to the top-right corner of the panel (8px from the top and right edges) unless **`show-close-button`** is false or you use the **`#header`** slot (then add your own **`UiDialogClose`**).
20
20
  * @category Components
21
21
  * @useCases forms, confirmations, settings, multi-step flows
22
22
  */
@@ -123,7 +123,7 @@ export const Default: Story = {
123
123
  description="Make changes to your profile here. Click save when done."
124
124
  >
125
125
  <p class="body-14-regular text-content-on-surface-secondary">
126
- Dialog body content goes in the default slot. The header includes a close control; Cancel in actions also closes.
126
+ Dialog body content goes in the default slot. The top-right close control dismisses; Cancel in actions also closes.
127
127
  </p>
128
128
  <template #actions>
129
129
  <UiDialogClose as-child>
@@ -355,14 +355,14 @@ import {
355
355
  </UiDialogTrigger>
356
356
  <UiDialogContent title="Notifications" max-width="max-w-md">
357
357
  <p class="body-14-regular text-content-on-surface-secondary">
358
- No description or footer actions — header still includes a close control (and Escape / overlay click).
358
+ No description or footer actions — the top-right close control is still shown (and Escape / overlay click).
359
359
  </p>
360
360
  </UiDialogContent>
361
361
  </UiDialog>
362
362
  </template>`;
363
363
 
364
364
  /**
365
- * Title only: no `description`, no `#actions` slot; header close is still shown by default.
365
+ * Title only: no `description`, no `#actions` slot; the top-right close is still shown by default.
366
366
  */
367
367
  export const TitleOnly: Story = {
368
368
  render: (args) => ({
@@ -382,7 +382,7 @@ export const TitleOnly: Story = {
382
382
  </UiDialogTrigger>
383
383
  <UiDialogContent title="Notifications" max-width="max-w-md">
384
384
  <p class="body-14-regular text-content-on-surface-secondary">
385
- No description or footer actions — header still includes a close control (and Escape / overlay click).
385
+ No description or footer actions — the top-right close control is still shown (and Escape / overlay click).
386
386
  </p>
387
387
  </UiDialogContent>
388
388
  </UiDialog>
@@ -749,22 +749,53 @@ export const WithForm: Story = {
749
749
  },
750
750
  };
751
751
 
752
+ /**
753
+ * Static preview panel used by the Accessibility story so the dialog is visible
754
+ * inline (a real `UiDialogContent` is portalled and modal, so two themes cannot
755
+ * be open side by side). It mirrors the panel markup and classes of
756
+ * `UiDialogContent` / core `DialogContent`, including the top-right close
757
+ * control 8px from the top and right edges. `inert` keeps the preview out of
758
+ * the tab order and the accessibility tree — it is an image of the dialog, not
759
+ * an operable one.
760
+ */
761
+ const accessibilityDialogPreview = `
762
+ <div
763
+ inert
764
+ class="relative flex w-full max-w-md flex-col gap-4 rounded-lg border border-border-surface-default bg-background-surface-modal p-6 shadow-lg"
765
+ >
766
+ <UiButton
767
+ type="button"
768
+ variant="ghost"
769
+ class="absolute top-2 right-2 size-9 shrink-0 p-0"
770
+ aria-label="Close dialog"
771
+ >
772
+ <UiIcon name="x" :size="20" aria-hidden="true" />
773
+ </UiButton>
774
+ <div class="flex min-w-0 flex-col gap-2 pe-8 text-left">
775
+ <p class="heading-s text-content-on-surface-primary">Edit profile</p>
776
+ <p class="body-14-regular text-content-on-surface-muted">
777
+ Make changes to your profile here. Click save when done.
778
+ </p>
779
+ </div>
780
+ <p class="body-14-regular text-content-on-surface-secondary">
781
+ Dialog body.
782
+ </p>
783
+ <div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
784
+ <UiButton variant="outline">Cancel</UiButton>
785
+ <UiButton>Save changes</UiButton>
786
+ </div>
787
+ </div>
788
+ `;
789
+
752
790
  /**
753
791
  * Accessibility guidance for labelled triggers, dialog naming, focus trap, and contrast.
792
+ * Shows the dialog panel inline (default vs. accessible theme) as a static preview.
754
793
  */
755
794
  export const Accessibility: Story = {
756
795
  render: () => ({
757
796
  components: {
758
- UiDialog,
759
- UiDialogClose,
760
- UiDialogContent,
761
- UiDialogTrigger,
762
797
  UiButton,
763
- },
764
- setup() {
765
- const defaultOpen = ref(false);
766
- const accessibleOpen = ref(false);
767
- return { defaultOpen, accessibleOpen };
798
+ UiIcon,
768
799
  },
769
800
  template: `
770
801
  <section class="flex flex-col gap-6 p-4">
@@ -792,25 +823,7 @@ export const Accessibility: Story = {
792
823
  Default
793
824
  </h3>
794
825
  <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
795
- <UiDialog v-model:open="defaultOpen">
796
- <UiDialogTrigger as-child>
797
- <UiButton variant="outline">Open dialog</UiButton>
798
- </UiDialogTrigger>
799
- <UiDialogContent
800
- title="Edit profile"
801
- description="Make changes to your profile here. Click save when done."
802
- >
803
- <p class="body-14-regular text-content-on-surface-secondary">
804
- Dialog body.
805
- </p>
806
- <template #actions>
807
- <UiDialogClose as-child>
808
- <UiButton variant="outline">Cancel</UiButton>
809
- </UiDialogClose>
810
- <UiButton>Save changes</UiButton>
811
- </template>
812
- </UiDialogContent>
813
- </UiDialog>
826
+ ${accessibilityDialogPreview}
814
827
  </div>
815
828
  </div>
816
829
 
@@ -819,25 +832,7 @@ export const Accessibility: Story = {
819
832
  Accessible
820
833
  </h3>
821
834
  <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
822
- <UiDialog v-model:open="accessibleOpen">
823
- <UiDialogTrigger as-child>
824
- <UiButton variant="outline">Open dialog</UiButton>
825
- </UiDialogTrigger>
826
- <UiDialogContent
827
- title="Edit profile"
828
- description="Make changes to your profile here. Click save when done."
829
- >
830
- <p class="body-14-regular text-content-on-surface-secondary">
831
- Dialog body.
832
- </p>
833
- <template #actions>
834
- <UiDialogClose as-child>
835
- <UiButton variant="outline">Cancel</UiButton>
836
- </UiDialogClose>
837
- <UiButton>Save changes</UiButton>
838
- </template>
839
- </UiDialogContent>
840
- </UiDialog>
835
+ ${accessibilityDialogPreview}
841
836
  </div>
842
837
  </div>
843
838
  </div>
@@ -897,8 +892,15 @@ async function expectClosedDialog(body: ReturnType<typeof within>) {
897
892
 
898
893
  /**
899
894
  * The dialog the test stories drive: a labelled panel with Cancel, Save, and
900
- * the header close control. Closed on load, so a play function can open it the
895
+ * the corner close control. Closed on load, so a play function can open it the
901
896
  * way a user would.
897
+ *
898
+ * The panel carries its production `position: fixed` inline: the Vitest
899
+ * browser project's lazily generated stylesheet does not include the core
900
+ * panel's `fixed` utility (safelisting it restyles unrelated stories), and
901
+ * without it the panel is no containing block for the pinned close control,
902
+ * so the geometry assertions in `CloseButtonPlacement` would measure against
903
+ * the viewport.
902
904
  */
903
905
  function renderTestDialog() {
904
906
  return {
@@ -922,6 +924,7 @@ function renderTestDialog() {
922
924
  max-width="max-w-[50vw]"
923
925
  title="Edit profile"
924
926
  description="Make changes to your profile here. Click save when done."
927
+ style="position: fixed"
925
928
  >
926
929
  <p class="body-14-regular text-content-on-surface-secondary">
927
930
  Dialog body content goes in the default slot.
@@ -977,7 +980,7 @@ export const PointerInteraction: Story = {
977
980
  });
978
981
 
979
982
  await step(
980
- 'interaction: the header close control dismisses the dialog',
983
+ 'interaction: the top-right close control dismisses the dialog',
981
984
  async () => {
982
985
  onUpdateOpen.mockClear();
983
986
  await userEvent.click(trigger);
@@ -992,6 +995,100 @@ export const PointerInteraction: Story = {
992
995
  },
993
996
  };
994
997
 
998
+ /**
999
+ * The built-in close control is pinned to the top-right corner of the panel,
1000
+ * 8px from the top and right edges, while the panel keeps its original
1001
+ * padding. Hidden test-only story.
1002
+ */
1003
+ export const CloseButtonPlacement: Story = {
1004
+ name: 'test - Close Button Placement',
1005
+ tags: ['!dev', '!autodocs'],
1006
+ parameters: {
1007
+ chromatic: { disableSnapshot: true },
1008
+ docs: {
1009
+ description: {
1010
+ story:
1011
+ 'Opens the dialog and measures the close control: 8px from the top and right edges of the panel, without overlapping the header text.',
1012
+ },
1013
+ },
1014
+ },
1015
+ render: renderTestDialog,
1016
+ play: async ({ canvasElement, step }) => {
1017
+ // Scenario (UiDialog): the close control sits in the top-right corner of
1018
+ // the panel with an 8px inset on both sides. Geometry is asserted inside
1019
+ // waitFor because the panel zooms in while opening.
1020
+ onUpdateOpen.mockClear();
1021
+ const canvas = within(canvasElement);
1022
+ const body = within(document.body);
1023
+ const trigger = canvas.getByRole('button', { name: 'Open dialog' });
1024
+
1025
+ await userEvent.click(trigger);
1026
+ const dialog = await expectOpenDialog(body);
1027
+ const close = body.getByRole('button', { name: 'Close dialog' });
1028
+
1029
+ // `top-2` / `right-2` inset from the panel's padding box, so the panel's
1030
+ // border (clientTop / clientLeft) is subtracted from the border-box rect.
1031
+ // The panel is centered with translate(-50%), which lands it on half-pixel
1032
+ // boundaries, so geometry is asserted with a 1px tolerance.
1033
+ await step(
1034
+ 'interaction: the close control sits 8px from the top edge of the panel',
1035
+ async () => {
1036
+ await waitFor(async () => {
1037
+ const dialogBox = dialog.getBoundingClientRect();
1038
+ const closeBox = close.getBoundingClientRect();
1039
+ const panelInnerTop = dialogBox.top + dialog.clientTop;
1040
+ const inset = closeBox.top - panelInnerTop;
1041
+ await expect(Math.abs(inset - 8)).toBeLessThanOrEqual(1);
1042
+ });
1043
+ },
1044
+ );
1045
+
1046
+ await step(
1047
+ 'interaction: the close control sits 8px from the right edge of the panel',
1048
+ async () => {
1049
+ await waitFor(async () => {
1050
+ const dialogBox = dialog.getBoundingClientRect();
1051
+ const closeBox = close.getBoundingClientRect();
1052
+ const panelInnerRight = dialogBox.right - dialog.clientLeft;
1053
+ const inset = panelInnerRight - closeBox.right;
1054
+ await expect(Math.abs(inset - 8)).toBeLessThanOrEqual(1);
1055
+ });
1056
+ },
1057
+ );
1058
+
1059
+ await step(
1060
+ 'interaction: the header text does not underlap the close control',
1061
+ async () => {
1062
+ const titleBox = body.getByText('Edit profile').getBoundingClientRect();
1063
+ const closeBox = close.getBoundingClientRect();
1064
+ await expect(titleBox.right).toBeLessThanOrEqual(closeBox.left);
1065
+ },
1066
+ );
1067
+
1068
+ await step(
1069
+ 'interaction: the panel keeps its original padding around the body',
1070
+ async () => {
1071
+ const dialogBox = dialog.getBoundingClientRect();
1072
+ const bodyTextBox = body
1073
+ .getByText('Dialog body content goes in the default slot.')
1074
+ .getBoundingClientRect();
1075
+ // Core DialogContent applies p-6 (24px); the corner-pinned close
1076
+ // control must not change the horizontal content inset (measured
1077
+ // from the padding box, i.e. inside the 1px panel border).
1078
+ const panelInnerLeft = dialogBox.left + dialog.clientLeft;
1079
+ const panelInnerRight = dialogBox.right - dialog.clientLeft;
1080
+ const insetLeft = bodyTextBox.left - panelInnerLeft;
1081
+ const insetRight = panelInnerRight - bodyTextBox.right;
1082
+ await expect(Math.abs(insetLeft - 24)).toBeLessThanOrEqual(1);
1083
+ await expect(Math.abs(insetRight - 24)).toBeLessThanOrEqual(1);
1084
+ },
1085
+ );
1086
+
1087
+ await userEvent.keyboard('{Escape}');
1088
+ await expectClosedDialog(body);
1089
+ },
1090
+ };
1091
+
995
1092
  /**
996
1093
  * Reaching the dialog, moving through its controls, and dismissing it without
997
1094
  * a pointer. Hidden test-only story.
@@ -66,44 +66,35 @@ const showBuiltInHeaderChrome = computed(
66
66
  :max-width="maxWidth"
67
67
  :class="cn('gap-4')"
68
68
  >
69
+ <UiDialogClose v-if="showCloseButton && !showHeaderSlot" as-child>
70
+ <UiButton
71
+ type="button"
72
+ variant="ghost"
73
+ class="absolute top-2 right-2 size-9 shrink-0 p-0"
74
+ :aria-label="ariaLabelCloseDialog"
75
+ >
76
+ <UiIcon name="x" :size="20" aria-hidden="true" />
77
+ </UiButton>
78
+ </UiDialogClose>
79
+
69
80
  <template v-if="showHeaderSlot">
70
81
  <slot name="header" />
71
82
  </template>
72
83
  <template v-else-if="showBuiltInHeaderChrome">
73
- <div class="flex items-start justify-between gap-4">
74
- <DialogHeader class="min-w-0 flex-1 gap-2 text-left">
75
- <DialogTitle v-if="showTitleBlock">{{ title }}</DialogTitle>
76
- <DialogTitle v-else class="sr-only">{{ ariaTitle }}</DialogTitle>
77
- <DialogDescription v-if="showDescription">{{
78
- description
79
- }}</DialogDescription>
80
- </DialogHeader>
81
- <UiDialogClose v-if="showCloseButton" as-child>
82
- <UiButton
83
- type="button"
84
- variant="ghost"
85
- class="size-9 shrink-0 p-0"
86
- :aria-label="ariaLabelCloseDialog"
87
- >
88
- <UiIcon name="x" :size="20" aria-hidden="true" />
89
- </UiButton>
90
- </UiDialogClose>
91
- </div>
84
+ <DialogHeader
85
+ :class="
86
+ cn('min-w-0 gap-2 text-left', showCloseButton ? 'pe-8' : undefined)
87
+ "
88
+ >
89
+ <DialogTitle v-if="showTitleBlock">{{ title }}</DialogTitle>
90
+ <DialogTitle v-else class="sr-only">{{ ariaTitle }}</DialogTitle>
91
+ <DialogDescription v-if="showDescription">{{
92
+ description
93
+ }}</DialogDescription>
94
+ </DialogHeader>
92
95
  </template>
93
96
  <template v-else>
94
- <div class="flex items-start justify-between gap-4">
95
- <DialogTitle class="sr-only">{{ ariaTitle }}</DialogTitle>
96
- <UiDialogClose v-if="showCloseButton" as-child>
97
- <UiButton
98
- type="button"
99
- variant="ghost"
100
- class="ms-auto size-9 shrink-0 p-0"
101
- :aria-label="ariaLabelCloseDialog"
102
- >
103
- <UiIcon name="x" :size="20" aria-hidden="true" />
104
- </UiButton>
105
- </UiDialogClose>
106
- </div>
97
+ <DialogTitle class="sr-only">{{ ariaTitle }}</DialogTitle>
107
98
  </template>
108
99
 
109
100
  <div class="flex min-h-0 flex-1 flex-col">
@@ -86,7 +86,7 @@ export type UiDialogContentProps = UiDialogSubComponentCommonProps &
86
86
  ariaTitle?: string;
87
87
 
88
88
  /**
89
- * Accessible name for the built-in header close button (when `showCloseButton` is true).
89
+ * Accessible name for the built-in close button (when `showCloseButton` is true).
90
90
  * @default 'Close dialog'
91
91
  */
92
92
  ariaLabelCloseDialog?: string;
@@ -97,7 +97,8 @@ export type UiDialogContentProps = UiDialogSubComponentCommonProps &
97
97
  maxWidth?: UiDialogContentMaxWidth;
98
98
 
99
99
  /**
100
- * When `true` and you are **not** using the `#header` slot, shows a header **Close** control (icon button).
100
+ * When `true` and you are **not** using the `#header` slot, shows a **Close** control (icon button)
101
+ * pinned to the top-right corner of the panel, 8px from the top and right edges.
101
102
  * Set to `false` if the dialog is closed only via `#actions` or programmatically.
102
103
  * @default true
103
104
  */