@aleph-alpha/ui-library 6.0.0 → 6.2.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 (55) hide show
  1. package/config.d.ts +28 -4
  2. package/config.js +141 -23
  3. package/dist/system/components/UiTagsInput/UiTagsInput.vue.d.ts +2 -0
  4. package/dist/system/components/UiTagsInput/UiTagsInputItemDelete.vue.d.ts +2 -1
  5. package/dist/system/components/UiTagsInput/types.d.ts +21 -2
  6. package/dist/system/components/core/sidebar/utils.d.ts +9 -0
  7. package/dist/system/components/core/tags-input/TagsInputItemDelete.vue.d.ts +5 -0
  8. package/dist/system/icons/story-sidebar-icons.json +8 -0
  9. package/dist/system/lib.js +6106 -5997
  10. package/dist/system/patterns/UiLayout/UiLayoutContent.vue.d.ts +39 -0
  11. package/dist/system/patterns/UiLayout/index.d.ts +2 -0
  12. package/dist/system/patterns/UiLayout/layout-shell.d.ts +944 -0
  13. package/dist/system/patterns/UiLayout/types.d.ts +43 -0
  14. package/dist/system/patterns/index.d.ts +1 -0
  15. package/dist/system/story-sidebar-icons.json +8 -0
  16. package/docs/public-docs/migration-guide.md +402 -0
  17. package/docs/public-docs/quick-start.md +19 -10
  18. package/package.json +7 -4
  19. package/src/components/UiAlert/UiAlert.stories.ts +732 -0
  20. package/src/components/UiAlert/__tests__/UiAlert.test.ts +57 -11
  21. package/src/components/UiChip/UiChip.stories.ts +756 -2
  22. package/src/components/UiChip/UiChip.vue +7 -6
  23. package/src/components/UiChip/__tests__/UiChip.test.ts +38 -61
  24. package/src/components/UiDrawer/UiDrawer.stories.ts +665 -0
  25. package/src/components/UiDrawer/__tests__/UiDrawer.test.ts +6 -190
  26. package/src/components/UiLabel/UiLabel.stories.ts +691 -16
  27. package/src/components/UiLabel/__tests__/UiLabel.test.ts +18 -26
  28. package/src/components/UiSheet/UiSheet.stories.ts +751 -0
  29. package/src/components/UiSheet/__tests__/UiSheet.test.ts +6 -190
  30. package/src/components/UiSlider/UiSlider.stories.ts +716 -0
  31. package/src/components/UiSlider/__tests__/UiSlider.test.ts +8 -45
  32. package/src/components/UiSwitch/UiSwitch.stories.ts +11 -5
  33. package/src/components/UiTagsInput/UiTagsInput.stories.ts +850 -4
  34. package/src/components/UiTagsInput/UiTagsInput.vue +34 -0
  35. package/src/components/UiTagsInput/UiTagsInputItemDelete.vue +4 -1
  36. package/src/components/UiTagsInput/__tests__/UiTagsInput.test.ts +113 -29
  37. package/src/components/UiTagsInput/types.ts +24 -2
  38. package/src/components/core/sheet/SheetContent.vue +6 -1
  39. package/src/components/core/sidebar/Sidebar.vue +21 -5
  40. package/src/components/core/sidebar/utils.ts +10 -0
  41. package/src/components/core/switch/index.ts +8 -7
  42. package/src/components/core/tags-input/TagsInput.vue +4 -1
  43. package/src/components/core/tags-input/TagsInputItem.vue +13 -1
  44. package/src/components/core/tags-input/TagsInputItemDelete.vue +40 -7
  45. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +1234 -0
  46. package/src/patterns/UiLayout/UiLayoutContent.vue +98 -0
  47. package/src/patterns/UiLayout/__tests__/UiLayoutContent.test.ts +97 -0
  48. package/src/patterns/UiLayout/index.ts +2 -0
  49. package/src/patterns/UiLayout/layout-shell.ts +64 -15
  50. package/src/patterns/UiLayout/types.ts +44 -0
  51. package/src/patterns/index.ts +1 -0
  52. package/src/theme/Typography.stories.ts +125 -133
  53. package/tokens.json +8132 -2475
  54. package/dist/system/icons/mobile-device-frame.png +0 -0
  55. package/dist/system/mobile-device-frame.png +0 -0
@@ -0,0 +1,98 @@
1
+ <script setup lang="ts">
2
+ import type { UiLayoutContentProps, UiLayoutContentSidebarMode } from './types';
3
+ import { computed, useSlots } from 'vue';
4
+ import { cn } from '@/lib/utils';
5
+
6
+ defineOptions({
7
+ name: 'UiLayoutContent',
8
+ inheritAttrs: false,
9
+ });
10
+
11
+ const props = withDefaults(defineProps<UiLayoutContentProps>(), {
12
+ as: 'main',
13
+ sidebarMode: 'default',
14
+ });
15
+
16
+ defineSlots<{
17
+ /** Page content; in a split or sidebar view, the primary part. */
18
+ default(): unknown;
19
+ /** Trailing part of a split view. Providing it draws the divider. */
20
+ split?(): unknown;
21
+ /**
22
+ * Secondary content, always locked to the right edge, without a surface or
23
+ * radius of its own. Its share of the content box is set by `sidebarMode`.
24
+ */
25
+ sidebar?(): unknown;
26
+ }>();
27
+
28
+ const slots = useSlots();
29
+
30
+ /** Column spans of the primary content and the sidebar, per mode. */
31
+ const SIDEBAR_MODE_SPANS: Record<
32
+ UiLayoutContentSidebarMode,
33
+ { content: string; sidebar: string }
34
+ > = {
35
+ default: { content: 'col-span-8', sidebar: 'col-span-4' },
36
+ wide: { content: 'col-span-7', sidebar: 'col-span-5' },
37
+ max: { content: 'col-span-6', sidebar: 'col-span-6' },
38
+ };
39
+
40
+ const sidebarSpans = computed(() => SIDEBAR_MODE_SPANS[props.sidebarMode]);
41
+ </script>
42
+
43
+ <template>
44
+ <!-- The 48px margin on the left and right of the content area lives on the
45
+ container as padding, so the content area still fills the space its
46
+ layout parent gives it. Below the desktop breakpoint (1200px) — toward
47
+ the minimum desktop size of 1024px — the margin compacts to 32px. The
48
+ content box
49
+ is a sheet, so it carries background/surface/secondary itself. In the
50
+ sidebar view the primary area is the sheet instead — it carries the
51
+ surface, the 12px radius, and its own margins — while the sidebar stays
52
+ on the base layer, without a surface or radius of its own. -->
53
+ <component
54
+ :is="props.as"
55
+ v-bind="$attrs"
56
+ :class="
57
+ cn(
58
+ 'block w-full min-w-0',
59
+ slots.sidebar
60
+ ? ''
61
+ : 'bg-background-surface-secondary px-8 lg-min:px-12',
62
+ $attrs.class ?? '',
63
+ )
64
+ "
65
+ >
66
+ <!-- The sidebar view: secondary content locked to the right edge, its
67
+ share of the 12 columns set by `sidebarMode`. The primary area is the
68
+ rounded sheet; the sidebar has no surface of its own. -->
69
+ <div v-if="slots.sidebar" class="grid h-full min-h-0 grid-cols-12">
70
+ <div
71
+ :class="
72
+ cn(
73
+ 'min-w-0 rounded-xl bg-background-surface-secondary px-8 lg-min:px-12',
74
+ sidebarSpans.content,
75
+ )
76
+ "
77
+ >
78
+ <slot />
79
+ </div>
80
+ <div :class="cn('min-w-0 px-8 lg-min:px-12', sidebarSpans.sidebar)">
81
+ <slot name="sidebar" />
82
+ </div>
83
+ </div>
84
+
85
+ <!-- The split view: a border divides the content box into two equal
86
+ parts, and each part keeps a 28px margin from it. -->
87
+ <div v-else-if="slots.split" class="grid h-full min-h-0 grid-cols-2">
88
+ <div class="min-w-0 pr-7">
89
+ <slot />
90
+ </div>
91
+ <div class="min-w-0 border-l border-background-surface-primary pl-7">
92
+ <slot name="split" />
93
+ </div>
94
+ </div>
95
+
96
+ <slot v-else />
97
+ </component>
98
+ </template>
@@ -0,0 +1,97 @@
1
+ import { render } from '@testing-library/vue';
2
+ import { describe, expect, test } from 'vitest';
3
+ import UiLayoutContent from '../UiLayoutContent.vue';
4
+
5
+ describe('UiLayoutContent', () => {
6
+ test('renders a main landmark with the responsive left/right margin and the sheet surface', () => {
7
+ const { getByRole } = render(UiLayoutContent, {
8
+ slots: { default: 'Page content' },
9
+ });
10
+ // 32px toward the minimum desktop size, 48px from the xl breakpoint up.
11
+ expect(getByRole('main')).toHaveClass(
12
+ 'px-8',
13
+ 'lg-min:px-12',
14
+ 'bg-background-surface-secondary',
15
+ );
16
+ });
17
+
18
+ test('renders as another element via the as prop', () => {
19
+ const { container, queryByRole } = render(UiLayoutContent, {
20
+ props: { as: 'div' },
21
+ slots: { default: 'Nested content' },
22
+ });
23
+ expect(queryByRole('main')).not.toBeInTheDocument();
24
+ expect(container.querySelector('div.px-8')).toBeInTheDocument();
25
+ });
26
+
27
+ test('merges custom classes with the content margin', () => {
28
+ const { getByRole } = render(UiLayoutContent, {
29
+ attrs: { class: 'shadow-lg' },
30
+ slots: { default: 'Page content' },
31
+ });
32
+ expect(getByRole('main')).toHaveClass('px-8', 'lg-min:px-12', 'shadow-lg');
33
+ });
34
+
35
+ test('draws the split view when the split slot is present', () => {
36
+ const { container, getByText } = render(UiLayoutContent, {
37
+ slots: { default: '<p>Leading</p>', split: '<p>Trailing</p>' },
38
+ });
39
+ expect(getByText('Leading')).toBeInTheDocument();
40
+ expect(getByText('Trailing')).toBeInTheDocument();
41
+ // Two equal parts with the divider between them, each keeping its 28px
42
+ // margin toward it.
43
+ expect(container.querySelector('.grid-cols-2')).toBeInTheDocument();
44
+ expect(container.querySelector('.border-l')).toHaveClass('pl-7');
45
+ expect(getByText('Leading').parentElement).toHaveClass('pr-7');
46
+ });
47
+
48
+ test('renders no split scaffolding without the split slot', () => {
49
+ const { container } = render(UiLayoutContent, {
50
+ slots: { default: 'Solo content' },
51
+ });
52
+ expect(container.querySelector('.grid-cols-2')).not.toBeInTheDocument();
53
+ expect(container.querySelector('.border-l')).not.toBeInTheDocument();
54
+ });
55
+
56
+ test('locks the sidebar to the right, with the sheet and radius on the primary area', () => {
57
+ const { getByRole, getByText } = render(UiLayoutContent, {
58
+ slots: { default: '<p>Primary</p>', sidebar: '<p>Secondary</p>' },
59
+ });
60
+ // The root steps back to the base layer; the primary area is the rounded
61
+ // sheet, and each area carries its own responsive margins.
62
+ expect(getByRole('main')).not.toHaveClass(
63
+ 'px-8',
64
+ 'bg-background-surface-secondary',
65
+ );
66
+ expect(getByText('Primary').parentElement).toHaveClass(
67
+ 'bg-background-surface-secondary',
68
+ 'rounded-xl',
69
+ 'px-8',
70
+ 'lg-min:px-12',
71
+ );
72
+ // The sidebar has no surface or radius of its own.
73
+ const sidebar = getByText('Secondary').parentElement!;
74
+ expect(sidebar).toHaveClass('px-8', 'lg-min:px-12');
75
+ expect(sidebar.className).not.toMatch(/\bbg-|\brounded-/);
76
+ // Locked to the right: the sidebar is the last of the two areas.
77
+ expect(sidebar.previousElementSibling).toBe(
78
+ getByText('Primary').parentElement,
79
+ );
80
+ });
81
+
82
+ test.each([
83
+ ['default', 'col-span-8', 'col-span-4'],
84
+ ['wide', 'col-span-7', 'col-span-5'],
85
+ ['max', 'col-span-6', 'col-span-6'],
86
+ ] as const)(
87
+ 'splits the columns %s: %s to %s',
88
+ (sidebarMode, contentSpan, sidebarSpan) => {
89
+ const { getByText } = render(UiLayoutContent, {
90
+ props: { sidebarMode },
91
+ slots: { default: '<p>Primary</p>', sidebar: '<p>Secondary</p>' },
92
+ });
93
+ expect(getByText('Primary').parentElement).toHaveClass(contentSpan);
94
+ expect(getByText('Secondary').parentElement).toHaveClass(sidebarSpan);
95
+ },
96
+ );
97
+ });
@@ -0,0 +1,2 @@
1
+ export { default as UiLayoutContent } from './UiLayoutContent.vue';
2
+ export type * from './types';
@@ -68,13 +68,34 @@ const WORDMARK = `
68
68
  </span>
69
69
  `;
70
70
 
71
+ /** The layout switch: mode buttons hanging in the middle of the bar. */
72
+ const LAYOUT_ACTIONS = `
73
+ <template #layout-actions>
74
+ <UiFloatActionItems v-model="layout" aria-label="Layout actions">
75
+ <UiTooltip content="Focus layout" side="bottom">
76
+ <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
77
+ <UiIcon name="scan" size="s" />
78
+ </UiFloatActionItems>
79
+ </UiTooltip>
80
+ <UiTooltip content="Split layout" side="bottom">
81
+ <UiFloatActionItems type="button" value="split" aria-label="Split layout">
82
+ <UiIcon name="panel-right" size="s" />
83
+ </UiFloatActionItems>
84
+ </UiTooltip>
85
+ </UiFloatActionItems>
86
+ </template>
87
+ `;
88
+
71
89
  /**
72
90
  * The bar: wordmark and sidebar toggle leading, layout switch and profile
73
91
  * trailing. The bar is a sibling of the sidebar rather than an ancestor, so the
74
92
  * toggle takes the same `open` ref the sidebar is bound to instead of reaching
75
93
  * for the sidebar context.
94
+ * @param layoutActions Whether the bar carries the layout switch.
95
+ * @returns Template string for the bar.
76
96
  */
77
- const TOP_BAR = `
97
+ function topBar(layoutActions = true) {
98
+ return `
78
99
  <UiTopBar
79
100
  ref="topBarRef"
80
101
  class="shrink-0"
@@ -90,20 +111,7 @@ const TOP_BAR = `
90
111
  />
91
112
  </template>
92
113
 
93
- <template #layout-actions>
94
- <UiFloatActionItems v-model="layout" aria-label="Layout actions">
95
- <UiTooltip content="Focus layout" side="bottom">
96
- <UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
97
- <UiIcon name="scan" size="s" />
98
- </UiFloatActionItems>
99
- </UiTooltip>
100
- <UiTooltip content="Split layout" side="bottom">
101
- <UiFloatActionItems type="button" value="split" aria-label="Split layout">
102
- <UiIcon name="panel-right" size="s" />
103
- </UiFloatActionItems>
104
- </UiTooltip>
105
- </UiFloatActionItems>
106
- </template>
114
+ ${layoutActions ? LAYOUT_ACTIONS : ''}
107
115
 
108
116
  <!-- The avatar opens the card of Patterns/UiProfileCard, hanging from the
109
117
  end of the bar so it stays inside the shell rather than off its edge.
@@ -112,6 +120,9 @@ const TOP_BAR = `
112
120
  <template #profile>${profileCard()}</template>
113
121
  </UiTopBar>
114
122
  `;
123
+ }
124
+
125
+ const TOP_BAR = topBar();
115
126
 
116
127
  /**
117
128
  * A menu row.
@@ -637,6 +648,44 @@ export function renderShell(defaultOpen = true, rows = 6, historyRounds = 1) {
637
648
  });
638
649
  }
639
650
 
651
+ /**
652
+ * The shell with a caller-supplied content column: the same bar and sidebar,
653
+ * with the page column handed in by the story instead of the built-in filler.
654
+ * The template must bring its own landmark (e.g. `UiLayoutContent`). The bar
655
+ * carries no layout switch here — the content stories show one arrangement
656
+ * each, so there is no mode to change.
657
+ * @param contentTemplate Template string for the content column.
658
+ * @param extraComponents Components the content template uses.
659
+ * @returns Story render definition.
660
+ */
661
+ export function renderShellWith(
662
+ contentTemplate: string,
663
+ extraComponents: Record<string, unknown> = {},
664
+ ) {
665
+ return () => ({
666
+ components: { ...components, ...extraComponents },
667
+ setup() {
668
+ return shellSetup(true);
669
+ },
670
+ template: `
671
+ <UiFadeMask
672
+ position="bottom"
673
+ background="primary"
674
+ class="flex h-svh w-full flex-col overflow-hidden"
675
+ :style="shellStyle"
676
+ >
677
+ ${topBar(false)}
678
+
679
+ <div class="flex min-h-0 w-full flex-1">
680
+ ${SIDEBAR}
681
+
682
+ ${contentTemplate}
683
+ </div>
684
+ </UiFadeMask>
685
+ `,
686
+ });
687
+ }
688
+
640
689
  /**
641
690
  * The same arrangement on a phone: the bar keeps its place in the column, and
642
691
  * the sidebar leaves the flow to slide in over the content beneath it.
@@ -0,0 +1,44 @@
1
+ /**
2
+ * How the content box is divided between the primary content and the sidebar
3
+ * when the `sidebar` slot is filled, in columns of the 12-column layout grid.
4
+ */
5
+ export type UiLayoutContentSidebarMode = 'default' | 'wide' | 'max';
6
+
7
+ /**
8
+ * Container for the primary content area — the main part of an application
9
+ * layout. It renders the sheet surface (`background/surface/secondary`) and
10
+ * carries the design system's 48px margin on its left and right edges — 32px
11
+ * below the `desktop` breakpoint (1200px), toward the minimum desktop size of
12
+ * 1024px — so pages start from the same inset instead of each carrying its
13
+ * own spacing. Divide the space inside it with a 12-column grid and 24px
14
+ * gutters.
15
+ *
16
+ * Slots: `default` for the page content; `split` for a split view — a border
17
+ * divides the content box into two equal parts, each keeping a 28px margin
18
+ * from the divider and a 6-column grid of its own; and `sidebar` for
19
+ * secondary content — locked to the right edge and sized by `sidebarMode`.
20
+ * In the sidebar view the primary area is the rounded sheet (12px radius)
21
+ * while the sidebar has no surface of its own; both keep 48px margins.
22
+ * @category Layout
23
+ * @useCases main content area, page body, layout grid container, split view, secondary sidebar
24
+ * @keywords layout, content, main, margin, grid, page, split, sidebar
25
+ * @related UiSidebar, UiTopBar
26
+ */
27
+ export interface UiLayoutContentProps {
28
+ /**
29
+ * The element the content area renders as. Defaults to `main`, so the
30
+ * content area is exposed as the page's main landmark; pass another tag
31
+ * when the page already has a `main` landmark.
32
+ * @type {string}
33
+ * @default 'main'
34
+ */
35
+ as?: string;
36
+ /**
37
+ * Column split between the primary content and the sidebar, applied when
38
+ * the `sidebar` slot is filled: `default` is 8 to 4, `wide` is 7 to 5, and
39
+ * `max` is 6 to 6.
40
+ * @type {'default' | 'wide' | 'max'}
41
+ * @default 'default'
42
+ */
43
+ sidebarMode?: UiLayoutContentSidebarMode;
44
+ }
@@ -6,6 +6,7 @@ export * from './UiDataTable';
6
6
  export * from './UiDatePicker';
7
7
  export * from './UiFileUpload';
8
8
  export * from './UiFloatActions';
9
+ export * from './UiLayout';
9
10
  export * from './UiPlaceholder';
10
11
  export * from './UiProfileCard';
11
12
  export * from './UiSidebar';