@aleph-alpha/ui-library 6.2.1 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/system/components/UiButtonGroup/index.d.ts +1 -0
  2. package/dist/system/components/UiDialog/types.d.ts +3 -2
  3. package/dist/system/components/UiInputGroup/UiInputGroup.vue.d.ts +20 -0
  4. package/dist/system/components/UiInputGroup/UiInputGroupAddon.vue.d.ts +20 -0
  5. package/dist/system/components/UiInputGroup/UiInputGroupButton.vue.d.ts +17 -0
  6. package/dist/system/components/UiInputGroup/UiInputGroupInput.vue.d.ts +11 -0
  7. package/dist/system/components/UiInputGroup/UiInputGroupTextarea.vue.d.ts +11 -0
  8. package/dist/system/components/UiInputGroup/index.d.ts +7 -0
  9. package/dist/system/components/UiInputGroup/types.d.ts +151 -0
  10. package/dist/system/components/UiLabel/UiLabel.vue.d.ts +3 -1
  11. package/dist/system/components/UiLabel/types.d.ts +7 -0
  12. package/dist/system/components/core/input-group/InputGroup.vue.d.ts +25 -0
  13. package/dist/system/components/core/input-group/InputGroupAddon.vue.d.ts +25 -0
  14. package/dist/system/components/core/input-group/InputGroupButton.vue.d.ts +28 -0
  15. package/dist/system/components/core/input-group/InputGroupInput.vue.d.ts +12 -0
  16. package/dist/system/components/core/input-group/InputGroupText.vue.d.ts +21 -0
  17. package/dist/system/components/core/input-group/InputGroupTextarea.vue.d.ts +12 -0
  18. package/dist/system/components/core/input-group/index.d.ts +18 -0
  19. package/dist/system/components/index.d.ts +1 -0
  20. package/dist/system/lib.js +14622 -14279
  21. package/package.json +2 -2
  22. package/src/components/UiButtonGroup/index.ts +4 -0
  23. package/src/components/UiDialog/UiDialog.stories.ts +151 -54
  24. package/src/components/UiDialog/UiDialogContent.vue +23 -32
  25. package/src/components/UiDialog/types.ts +3 -2
  26. package/src/components/UiField/UiField.stories.ts +329 -52
  27. package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
  28. package/src/components/UiInput/UiInput.stories.ts +3 -1
  29. package/src/components/UiInput/UiInput.vue +26 -5
  30. package/src/components/UiInputGroup/UiInputGroup.stories.ts +2083 -0
  31. package/src/components/UiInputGroup/UiInputGroup.vue +18 -0
  32. package/src/components/UiInputGroup/UiInputGroupAddon.vue +18 -0
  33. package/src/components/UiInputGroup/UiInputGroupButton.vue +30 -0
  34. package/src/components/UiInputGroup/UiInputGroupInput.vue +16 -0
  35. package/src/components/UiInputGroup/UiInputGroupTextarea.vue +16 -0
  36. package/src/components/UiInputGroup/__tests__/UiInputGroup.test.ts +195 -0
  37. package/src/components/UiInputGroup/index.ts +10 -0
  38. package/src/components/UiInputGroup/types.ts +171 -0
  39. package/src/components/UiLabel/UiLabel.vue +7 -2
  40. package/src/components/UiLabel/types.ts +8 -0
  41. package/src/components/core/button/index.ts +23 -13
  42. package/src/components/core/button-group/ButtonGroupText.vue +4 -0
  43. package/src/components/core/button-group/index.ts +6 -2
  44. package/src/components/core/field/FieldError.vue +1 -1
  45. package/src/components/core/field/FieldLabel.vue +1 -1
  46. package/src/components/core/field/index.ts +7 -1
  47. package/src/components/core/input/Input.vue +4 -1
  48. package/src/components/core/input-group/InputGroup.vue +27 -0
  49. package/src/components/core/input-group/InputGroupAddon.vue +53 -0
  50. package/src/components/core/input-group/InputGroupButton.vue +35 -0
  51. package/src/components/core/input-group/InputGroupInput.vue +65 -0
  52. package/src/components/core/input-group/InputGroupText.vue +26 -0
  53. package/src/components/core/input-group/InputGroupTextarea.vue +62 -0
  54. package/src/components/core/input-group/index.ts +103 -0
  55. package/src/components/core/label/Label.vue +1 -1
  56. package/src/components/index.ts +1 -0
  57. package/src/theme/Typography.stories.ts +144 -6
  58. package/src/theme/__tests__/typography.test.ts +136 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "6.2.1",
3
+ "version": "6.3.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -90,8 +90,8 @@
90
90
  "@aleph-alpha/eslint-config-frontend": "0.7.1",
91
91
  "@aleph-alpha/prettier-config-frontend": "2.1.1",
92
92
  "@aleph-alpha/storybook-addon-filters": "0.0.1",
93
- "@aleph-alpha/storybook-addon-sidebar": "0.0.1",
94
93
  "@aleph-alpha/storybook-addon-theming": "0.0.1",
94
+ "@aleph-alpha/storybook-addon-sidebar": "0.0.1",
95
95
  "@aleph-alpha/tsconfig-frontend": "0.7.3"
96
96
  },
97
97
  "peerDependencies": {
@@ -1,2 +1,6 @@
1
1
  export { default as UiButtonGroup } from './UiButtonGroup.vue';
2
+
3
+ // Pure presentational wrapper with no extra logic — re-exported from core.
4
+ export { ButtonGroupText as UiButtonGroupText } from '@/components/core/button-group';
5
+
2
6
  export type { UiButtonGroupProps, UiButtonGroupOrientation } from './types';
@@ -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
  */