@aleph-alpha/ui-library 6.3.2 → 6.3.4
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.
- package/config.js +2 -0
- package/dist/system/components/UiFileUploadBox/types.d.ts +8 -5
- package/dist/system/components/UiStepper/context.d.ts +8 -0
- package/dist/system/components/core/range-calendar/RangeCalendar.vue.d.ts +24 -24
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +14776 -14598
- package/dist/system/patterns/UiLayout/layout-shell.d.ts +217 -5
- package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +227 -0
- package/dist/system/story-sidebar-icons.json +7 -0
- package/package.json +1 -1
- package/src/components/UiAccordion/UiAccordion.stories.ts +1079 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +734 -0
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +8 -5
- package/src/components/UiDropdownMenu/UiDropdownMenuTrigger.vue +3 -1
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +389 -3
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +55 -75
- package/src/components/UiFileUploadBox/__tests__/UiFileUploadBox.test.ts +44 -0
- package/src/components/UiFileUploadBox/types.ts +8 -5
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +723 -0
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +819 -7
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +8 -3
- package/src/components/UiResizable/UiResizable.stories.ts +1215 -5
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +1017 -4
- package/src/components/UiSnackbar/UiSnackbar.vue +3 -2
- package/src/components/UiSnackbar/UiSnackbarContent.vue +1 -1
- package/src/components/UiSnackbar/__tests__/UiSnackbar.test.ts +3 -1
- package/src/components/UiStepper/UiStepper.stories.ts +566 -2
- package/src/components/UiStepper/UiStepper.vue +14 -1
- package/src/components/UiStepper/UiStepperItem.vue +22 -4
- package/src/components/UiStepper/__tests__/UiStepper.test.ts +66 -0
- package/src/components/UiStepper/context.ts +10 -0
- package/src/components/core/calendar/Calendar.vue +234 -2
- package/src/components/core/calendar/CalendarCellTrigger.vue +1 -1
- package/src/components/core/navigation-menu/NavigationMenuList.vue +1 -1
- package/src/components/core/range-calendar/RangeCalendar.vue +254 -6
- package/src/components/core/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +846 -17
- package/src/patterns/UiDatePicker/UiDatePicker.vue +9 -0
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +13 -8
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +23 -17
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +138 -113
- package/src/patterns/UiFileUpload/UiFileUpload.vue +1 -1
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +2 -2
- package/src/patterns/UiLayout/UiLayout.stories.ts +25 -0
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +359 -0
- package/src/patterns/UiLayout/UiLayoutContent.vue +45 -23
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +13 -0
- package/src/patterns/UiLayout/layout-shell.ts +159 -13
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +245 -36
- package/src/patterns/UiTopBar/UiTopBar.vue +4 -2
- package/src/patterns/UiTopBar/accessory-dropdown.ts +97 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentPublicInstance } from 'vue';
|
|
2
|
+
import type { UiLayoutContentSidebarMode } from './types';
|
|
2
3
|
import { useResizeObserver } from '@vueuse/core';
|
|
3
4
|
import { computed, ref } from 'vue';
|
|
4
5
|
import { UiAvatar, UiAvatarFallback } from '../../components/UiAvatar';
|
|
@@ -33,6 +34,12 @@ import {
|
|
|
33
34
|
UiSidebarTrigger,
|
|
34
35
|
} from '../UiSidebar';
|
|
35
36
|
import { UiTopBar } from '../UiTopBar';
|
|
37
|
+
import {
|
|
38
|
+
ACCESSORY_DROPDOWN,
|
|
39
|
+
ACCESSORY_DROPDOWN_COMPONENTS,
|
|
40
|
+
accessoryDropdownSource,
|
|
41
|
+
accessoryDropdownState,
|
|
42
|
+
} from '../UiTopBar/accessory-dropdown';
|
|
36
43
|
|
|
37
44
|
/*
|
|
38
45
|
* There is no layout component: the shell is just these patterns arranged, the
|
|
@@ -46,6 +53,50 @@ type NavItem = {
|
|
|
46
53
|
title: string;
|
|
47
54
|
};
|
|
48
55
|
|
|
56
|
+
/**
|
|
57
|
+
* How the content area is arranged. `focus` is the plain twelve columns,
|
|
58
|
+
* `split` fills the `split` slot, and `sidebar` fills the `sidebar` slot at
|
|
59
|
+
* whichever `sidebarMode` is picked. Modals are not a slot mode — they are an
|
|
60
|
+
* overlay above `focus` — so they stay in their own stories.
|
|
61
|
+
*/
|
|
62
|
+
export type ContentMode = 'focus' | 'split' | 'sidebar';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Id of the content region the bar's layout switch points at with
|
|
66
|
+
* `aria-controls`, so the relation between the two is programmatic rather than
|
|
67
|
+
* only visual. Any shell that renders the switch has to carry it on its
|
|
68
|
+
* content column, or the reference dangles.
|
|
69
|
+
*/
|
|
70
|
+
export const CONTENT_REGION_ID = 'layout-content';
|
|
71
|
+
|
|
72
|
+
/** How each sidebar mode reads in the switch and in the announcement. */
|
|
73
|
+
export const SIDEBAR_MODE_LABELS: Record<UiLayoutContentSidebarMode, string> = {
|
|
74
|
+
default: '8 to 4',
|
|
75
|
+
wide: '7 to 5',
|
|
76
|
+
max: '6 to 6',
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A grid the demo draws: the utility class that lays it out, and how many
|
|
81
|
+
* columns to fill it with. The class is written out rather than built from the
|
|
82
|
+
* number so it survives UnoCSS's static scan.
|
|
83
|
+
*/
|
|
84
|
+
type DemoGrid = [className: string, columns: number];
|
|
85
|
+
|
|
86
|
+
/** The primary area's grid in each sidebar mode, mirroring the split. */
|
|
87
|
+
const SIDEBAR_PRIMARY_GRID: Record<UiLayoutContentSidebarMode, DemoGrid> = {
|
|
88
|
+
default: ['grid-cols-8', 8],
|
|
89
|
+
wide: ['grid-cols-7', 7],
|
|
90
|
+
max: ['grid-cols-6', 6],
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** The sidebar area's grid in each mode — the other side of the same split. */
|
|
94
|
+
const SIDEBAR_AREA_GRID: Record<UiLayoutContentSidebarMode, DemoGrid> = {
|
|
95
|
+
default: ['grid-cols-4', 4],
|
|
96
|
+
wide: ['grid-cols-5', 5],
|
|
97
|
+
max: ['grid-cols-6', 6],
|
|
98
|
+
};
|
|
99
|
+
|
|
49
100
|
/** The Aleph Alpha mark, inlined so it fills with `currentColor`. */
|
|
50
101
|
const BRAND_MARK = `
|
|
51
102
|
<svg
|
|
@@ -69,34 +120,59 @@ const WORDMARK = `
|
|
|
69
120
|
`;
|
|
70
121
|
|
|
71
122
|
/** The layout switch: mode buttons hanging in the middle of the bar. */
|
|
72
|
-
const
|
|
73
|
-
<template #layout-actions>
|
|
123
|
+
const LAYOUT_SWITCH = `
|
|
74
124
|
<UiFloatActionItems v-model="layout" aria-label="Layout actions">
|
|
75
125
|
<UiTooltip content="Focus layout" side="bottom">
|
|
76
|
-
<UiFloatActionItems
|
|
126
|
+
<UiFloatActionItems
|
|
127
|
+
type="button"
|
|
128
|
+
value="focus"
|
|
129
|
+
aria-label="Focus layout"
|
|
130
|
+
aria-controls="${CONTENT_REGION_ID}"
|
|
131
|
+
>
|
|
77
132
|
<UiIcon name="scan" size="s" />
|
|
78
133
|
</UiFloatActionItems>
|
|
79
134
|
</UiTooltip>
|
|
80
135
|
<UiTooltip content="Split layout" side="bottom">
|
|
81
|
-
<UiFloatActionItems
|
|
136
|
+
<UiFloatActionItems
|
|
137
|
+
type="button"
|
|
138
|
+
value="split"
|
|
139
|
+
aria-label="Split layout"
|
|
140
|
+
aria-controls="${CONTENT_REGION_ID}"
|
|
141
|
+
>
|
|
82
142
|
<UiIcon name="panel-right" size="s" />
|
|
83
143
|
</UiFloatActionItems>
|
|
84
144
|
</UiTooltip>
|
|
85
145
|
</UiFloatActionItems>
|
|
86
|
-
</template>
|
|
87
146
|
`;
|
|
88
147
|
|
|
89
148
|
/**
|
|
90
|
-
* The bar:
|
|
91
|
-
*
|
|
149
|
+
* The middle of the bar: the accessibility menu, followed by the layout switch
|
|
150
|
+
* when the bar carries one.
|
|
151
|
+
* @param layoutSwitch Whether to include the layout switch.
|
|
152
|
+
* @returns Template string for the `layout-actions` slot.
|
|
153
|
+
*/
|
|
154
|
+
function layoutActions(layoutSwitch: boolean): string {
|
|
155
|
+
return `
|
|
156
|
+
<template #layout-actions>
|
|
157
|
+
<div class="flex items-center gap-4">
|
|
158
|
+
${ACCESSORY_DROPDOWN}
|
|
159
|
+
${layoutSwitch ? LAYOUT_SWITCH : ''}
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The bar: wordmark and sidebar toggle leading, accessibility menu, layout
|
|
167
|
+
* switch and profile trailing. The bar is a sibling of the sidebar rather than an ancestor, so the
|
|
92
168
|
* toggle takes the same `open` ref the sidebar is bound to instead of reaching
|
|
93
169
|
* for the sidebar context. It carries the toggle only while the sidebar is
|
|
94
170
|
* expanded — collapsed, the icon rail shows its own through `start-action`,
|
|
95
171
|
* so the control sits on the column it reopens.
|
|
96
|
-
* @param
|
|
172
|
+
* @param layoutSwitch Whether the bar carries the layout switch.
|
|
97
173
|
* @returns Template string for the bar.
|
|
98
174
|
*/
|
|
99
|
-
function topBar(
|
|
175
|
+
function topBar(layoutSwitch = true) {
|
|
100
176
|
return `
|
|
101
177
|
<UiTopBar
|
|
102
178
|
ref="topBarRef"
|
|
@@ -112,7 +188,7 @@ function topBar(layoutActions = true) {
|
|
|
112
188
|
/>
|
|
113
189
|
</template>
|
|
114
190
|
|
|
115
|
-
${layoutActions
|
|
191
|
+
${layoutActions(layoutSwitch)}
|
|
116
192
|
|
|
117
193
|
<!-- The avatar opens the card of Patterns/UiProfileCard, hanging from the
|
|
118
194
|
end of the bar so it stays inside the shell rather than off its edge.
|
|
@@ -546,6 +622,36 @@ function shellSetup(
|
|
|
546
622
|
|
|
547
623
|
const selected = ref<NavItem>({ title: selectedTitle });
|
|
548
624
|
|
|
625
|
+
// One ref for the content arrangement, shared by the bar's layout switch and
|
|
626
|
+
// the content area's own switch, so neither can drift from what is rendered.
|
|
627
|
+
const layout = ref<ContentMode>('focus');
|
|
628
|
+
const sidebarMode = ref<UiLayoutContentSidebarMode>('default');
|
|
629
|
+
|
|
630
|
+
// Switching mode replaces the content region without moving focus, so the
|
|
631
|
+
// change is announced instead of happening silently (WCAG 4.1.3).
|
|
632
|
+
const layoutStatus = computed(() => {
|
|
633
|
+
if (layout.value === 'split') return 'Split view';
|
|
634
|
+
if (layout.value === 'sidebar') {
|
|
635
|
+
return `Sidebar view, ${SIDEBAR_MODE_LABELS[sidebarMode.value]}`;
|
|
636
|
+
}
|
|
637
|
+
return 'Focus view';
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
// The columns each area draws, so the demo's grid overlay matches the split
|
|
641
|
+
// the component is actually applying. The class and the count travel together
|
|
642
|
+
// because the overlay needs both: one to lay the grid out, one to fill it.
|
|
643
|
+
const primaryColumns = computed<DemoGrid>(() => {
|
|
644
|
+
if (layout.value === 'focus') return ['grid-cols-12', 12];
|
|
645
|
+
if (layout.value === 'split') return ['grid-cols-6', 6];
|
|
646
|
+
return SIDEBAR_PRIMARY_GRID[sidebarMode.value];
|
|
647
|
+
});
|
|
648
|
+
const sidebarColumns = computed(() => SIDEBAR_AREA_GRID[sidebarMode.value]);
|
|
649
|
+
|
|
650
|
+
const primaryGridClass = computed(() => primaryColumns.value[0]);
|
|
651
|
+
const primaryColumnCount = computed(() => primaryColumns.value[1]);
|
|
652
|
+
const sidebarGridClass = computed(() => sidebarColumns.value[0]);
|
|
653
|
+
const sidebarColumnCount = computed(() => sidebarColumns.value[1]);
|
|
654
|
+
|
|
549
655
|
/**
|
|
550
656
|
* Whether a nav row is the one currently shown in the content column.
|
|
551
657
|
* @param title Row title to compare against the selection.
|
|
@@ -577,27 +683,36 @@ function shellSetup(
|
|
|
577
683
|
|
|
578
684
|
return {
|
|
579
685
|
...profileCardState(),
|
|
686
|
+
...accessoryDropdownState(),
|
|
580
687
|
agentItems,
|
|
581
688
|
appItems,
|
|
582
689
|
chats,
|
|
690
|
+
contentRegionId: CONTENT_REGION_ID,
|
|
583
691
|
isActive,
|
|
584
|
-
layout
|
|
692
|
+
layout,
|
|
693
|
+
layoutStatus,
|
|
585
694
|
// What the pill in the mobile bar switches between; the pill reads whatever
|
|
586
695
|
// is picked, so the two never drift apart.
|
|
587
696
|
model: ref('Phoenix 1.2'),
|
|
588
697
|
models: ['Model 1', 'Phoenix 1.2', 'Model 3', 'Model 4'],
|
|
589
698
|
mobileItems,
|
|
590
699
|
open: ref(defaultOpen),
|
|
700
|
+
primaryColumnCount,
|
|
701
|
+
primaryGridClass,
|
|
591
702
|
primaryItems,
|
|
592
703
|
select,
|
|
593
704
|
selected,
|
|
594
705
|
shellStyle,
|
|
706
|
+
sidebarColumnCount,
|
|
707
|
+
sidebarGridClass,
|
|
708
|
+
sidebarMode,
|
|
595
709
|
topBarRef,
|
|
596
710
|
};
|
|
597
711
|
}
|
|
598
712
|
|
|
599
713
|
const components = {
|
|
600
714
|
...PROFILE_CARD_COMPONENTS,
|
|
715
|
+
...ACCESSORY_DROPDOWN_COMPONENTS,
|
|
601
716
|
UiAvatar,
|
|
602
717
|
UiAvatarFallback,
|
|
603
718
|
UiDropdownMenu,
|
|
@@ -651,7 +766,12 @@ export function renderShell(defaultOpen = true, rows = 6, historyRounds = 1) {
|
|
|
651
766
|
<div class="flex min-h-0 w-full flex-1">
|
|
652
767
|
${SIDEBAR}
|
|
653
768
|
|
|
654
|
-
|
|
769
|
+
<!-- the id is what the bar's layout switch references, so the
|
|
770
|
+
reference resolves even though this shell has no mode to pick -->
|
|
771
|
+
<main
|
|
772
|
+
id="${CONTENT_REGION_ID}"
|
|
773
|
+
class="bg-background relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden mx-2"
|
|
774
|
+
>
|
|
655
775
|
${content(rows)}
|
|
656
776
|
</main>
|
|
657
777
|
</div>
|
|
@@ -668,11 +788,15 @@ export function renderShell(defaultOpen = true, rows = 6, historyRounds = 1) {
|
|
|
668
788
|
* each, so there is no mode to change.
|
|
669
789
|
* @param contentTemplate Template string for the content column.
|
|
670
790
|
* @param extraComponents Components the content template uses.
|
|
791
|
+
* @param layoutActions Whether the bar carries the layout switch. A template
|
|
792
|
+
* that turns it on has to put `CONTENT_REGION_ID` on its content column, which
|
|
793
|
+
* is what the switch's `aria-controls` points at.
|
|
671
794
|
* @returns Story render definition.
|
|
672
795
|
*/
|
|
673
796
|
export function renderShellWith(
|
|
674
797
|
contentTemplate: string,
|
|
675
798
|
extraComponents: Record<string, unknown> = {},
|
|
799
|
+
layoutActions = false,
|
|
676
800
|
) {
|
|
677
801
|
return () => ({
|
|
678
802
|
components: { ...components, ...extraComponents },
|
|
@@ -686,7 +810,7 @@ export function renderShellWith(
|
|
|
686
810
|
class="flex h-svh w-full flex-col overflow-hidden"
|
|
687
811
|
:style="shellStyle"
|
|
688
812
|
>
|
|
689
|
-
${topBar(
|
|
813
|
+
${topBar(layoutActions)}
|
|
690
814
|
|
|
691
815
|
<div class="flex min-h-0 w-full flex-1">
|
|
692
816
|
${SIDEBAR}
|
|
@@ -763,6 +887,28 @@ export const templateSource = `<!-- one fade for the shell: the band spans both
|
|
|
763
887
|
<template v-if="open" #sidebar-toggle>
|
|
764
888
|
<UiSidebarTrigger v-model:open="open" tooltip="Toggle sidebar" />
|
|
765
889
|
</template>
|
|
890
|
+
|
|
891
|
+
<!-- the middle of the bar: the accessibility menu, then the layout switch.
|
|
892
|
+
both are Tab stops, in the order they are written here -->
|
|
893
|
+
<template #layout-actions>
|
|
894
|
+
<div class="flex items-center gap-4">
|
|
895
|
+
${accessoryDropdownSource(' ')}
|
|
896
|
+
|
|
897
|
+
<UiFloatActionItems v-model="layout" aria-label="Layout actions">
|
|
898
|
+
<UiTooltip content="Focus layout" side="bottom">
|
|
899
|
+
<UiFloatActionItems type="button" value="focus" aria-label="Focus layout">
|
|
900
|
+
<UiIcon name="scan" size="s" />
|
|
901
|
+
</UiFloatActionItems>
|
|
902
|
+
</UiTooltip>
|
|
903
|
+
<UiTooltip content="Split layout" side="bottom">
|
|
904
|
+
<UiFloatActionItems type="button" value="split" aria-label="Split layout">
|
|
905
|
+
<UiIcon name="panel-right" size="s" />
|
|
906
|
+
</UiFloatActionItems>
|
|
907
|
+
</UiTooltip>
|
|
908
|
+
</UiFloatActionItems>
|
|
909
|
+
</div>
|
|
910
|
+
</template>
|
|
911
|
+
|
|
766
912
|
<!-- the avatar and the card it opens are Patterns/UiProfileCard -->
|
|
767
913
|
<template #profile><ProfileCard /></template>
|
|
768
914
|
</UiTopBar>
|