@aleph-alpha/ui-library 2.2.0 → 2.4.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 (76) hide show
  1. package/dist/system/components/UiAlert/UiAlert.vue.d.ts +1 -0
  2. package/dist/system/components/UiAlert/constants.d.ts +16 -2
  3. package/dist/system/components/UiResizable/UiResizableHandle.vue.d.ts +22 -0
  4. package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +31 -0
  5. package/dist/system/components/UiResizable/UiResizablePanelGroup.vue.d.ts +23 -0
  6. package/dist/system/components/UiResizable/index.d.ts +4 -0
  7. package/dist/system/components/UiResizable/types.d.ts +37 -0
  8. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +5 -0
  9. package/dist/system/components/UiToggle/types.d.ts +13 -0
  10. package/dist/system/components/core/resizable/ResizableHandle.vue.d.ts +27 -0
  11. package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +32 -0
  12. package/dist/system/components/core/resizable/ResizablePanelGroup.vue.d.ts +28 -0
  13. package/dist/system/components/core/resizable/index.d.ts +3 -0
  14. package/dist/system/components/core/sidebar/Sidebar.vue.d.ts +7 -0
  15. package/dist/system/components/core/sidebar/SidebarResizeHandle.vue.d.ts +16 -0
  16. package/dist/system/components/core/sidebar/index.d.ts +16 -0
  17. package/dist/system/components/core/sidebar/utils.d.ts +4 -0
  18. package/dist/system/components/index.d.ts +1 -0
  19. package/dist/system/lib/heightTransition.d.ts +5 -0
  20. package/dist/system/lib/useDrag.d.ts +52 -0
  21. package/dist/system/lib.js +22198 -19966
  22. package/dist/system/patterns/UiDataTable/UiDataTable.vue.d.ts +22 -3
  23. package/dist/system/patterns/UiDataTable/UiDataTableColumnFilter.vue.d.ts +14 -0
  24. package/dist/system/patterns/UiDataTable/constants.d.ts +13 -0
  25. package/dist/system/patterns/UiDataTable/index.d.ts +2 -0
  26. package/dist/system/patterns/UiDataTable/types.d.ts +32 -1
  27. package/dist/system/patterns/UiSidebar/UiSidebar.vue.d.ts +1 -0
  28. package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +6 -0
  29. package/package.json +2 -2
  30. package/src/components/UiAlert/UiAlert.stories.ts +3 -15
  31. package/src/components/UiAlert/UiAlert.vue +16 -10
  32. package/src/components/UiAlert/constants.ts +21 -2
  33. package/src/components/UiResizable/UiResizable.stories.ts +424 -0
  34. package/src/components/UiResizable/UiResizableHandle.vue +17 -0
  35. package/src/components/UiResizable/UiResizablePanel.vue +30 -0
  36. package/src/components/UiResizable/UiResizablePanelGroup.vue +27 -0
  37. package/src/components/UiResizable/__tests__/UiResizableHandle.test.ts +64 -0
  38. package/src/components/UiResizable/__tests__/UiResizablePanel.test.ts +82 -0
  39. package/src/components/UiResizable/__tests__/UiResizablePanelGroup.test.ts +79 -0
  40. package/src/components/UiResizable/index.ts +4 -0
  41. package/src/components/UiResizable/types.ts +50 -0
  42. package/src/components/UiTable/__tests__/UiTableRow.test.ts +14 -5
  43. package/src/components/UiToggle/UiToggle.vue +18 -1
  44. package/src/components/UiToggle/__tests__/UiToggle.test.ts +33 -3
  45. package/src/components/UiToggle/types.ts +13 -0
  46. package/src/components/core/accordion/AccordionContent.vue +36 -1
  47. package/src/components/core/resizable/ResizableHandle.vue +45 -0
  48. package/src/components/core/resizable/ResizablePanel.vue +21 -0
  49. package/src/components/core/resizable/ResizablePanelGroup.vue +31 -0
  50. package/src/components/core/resizable/index.ts +3 -0
  51. package/src/components/core/sidebar/Sidebar.vue +208 -2
  52. package/src/components/core/sidebar/SidebarRail.vue +1 -2
  53. package/src/components/core/sidebar/SidebarResizeHandle.vue +46 -0
  54. package/src/components/core/sidebar/index.ts +17 -0
  55. package/src/components/core/sidebar/utils.ts +4 -0
  56. package/src/components/core/table/TableRow.vue +1 -1
  57. package/src/components/core/toggle/index.ts +2 -2
  58. package/src/components/index.ts +1 -0
  59. package/src/lib/heightTransition.ts +27 -0
  60. package/src/lib/useDrag.stories.ts +295 -0
  61. package/src/lib/useDrag.ts +212 -0
  62. package/src/patterns/UiDataTable/UiDataTable.stories.ts +348 -0
  63. package/src/patterns/UiDataTable/UiDataTable.vue +558 -22
  64. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +83 -0
  65. package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +4 -13
  66. package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +329 -0
  67. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +194 -0
  68. package/src/patterns/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +11 -0
  69. package/src/patterns/UiDataTable/constants.ts +15 -0
  70. package/src/patterns/UiDataTable/index.ts +2 -0
  71. package/src/patterns/UiDataTable/types.ts +33 -0
  72. package/src/patterns/UiSidebar/UiSidebar.stories.ts +42 -1
  73. package/src/patterns/UiSidebar/UiSidebar.vue +20 -0
  74. package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +13 -36
  75. package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +204 -2
  76. package/src/patterns/UiSidebar/__tests__/UiSidebarRail.test.ts +14 -0
@@ -1,12 +1,31 @@
1
+ import { Row, Table } from '@tanstack/vue-table';
1
2
  import { UiDataTableProps } from './types';
2
3
  declare const _default: <TData, TValue>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
4
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & UiDataTableProps<TData, TValue> & Partial<{}>> & import('vue').PublicProps;
4
5
  expose(exposed: import('vue').ShallowUnwrapRef<{
5
- table: import('@tanstack/vue-table').Table<TData>;
6
+ table: Table<TData>;
6
7
  }>): void;
7
8
  attrs: any;
8
- slots: {
9
- empty?(_: {}): any;
9
+ slots: Readonly<{
10
+ /** Content rendered in the empty state cell. */
11
+ empty(): unknown;
12
+ /** Content rendered in a separate table row after an expanded data row. */
13
+ 'expanded-row'(props: {
14
+ /** The expanded TanStack row instance. */
15
+ row: Row<TData>;
16
+ /** The TanStack table instance. */
17
+ table: Table<TData>;
18
+ }): unknown;
19
+ }> & {
20
+ /** Content rendered in the empty state cell. */
21
+ empty(): unknown;
22
+ /** Content rendered in a separate table row after an expanded data row. */
23
+ 'expanded-row'(props: {
24
+ /** The expanded TanStack row instance. */
25
+ row: Row<TData>;
26
+ /** The TanStack table instance. */
27
+ table: Table<TData>;
28
+ }): unknown;
10
29
  };
11
30
  emit: {};
12
31
  }>) => import('vue').VNode & {
@@ -0,0 +1,14 @@
1
+ import { UiDataTableColumnFilterProps } from './types';
2
+ declare const _default: <TData>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & UiDataTableColumnFilterProps<TData> & Partial<{}>> & import('vue').PublicProps;
4
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
5
+ attrs: any;
6
+ slots: {};
7
+ emit: {};
8
+ }>) => import('vue').VNode & {
9
+ __ctx?: Awaited<typeof __VLS_setup>;
10
+ };
11
+ export default _default;
12
+ type __VLS_PrettifyLocal<T> = {
13
+ [K in keyof T]: T[K];
14
+ } & {};
@@ -25,6 +25,10 @@ export declare const DATA_TABLE_LABELS: {
25
25
  readonly filterPlaceholder: "Search...";
26
26
  readonly searchAllColumns: "Search all columns";
27
27
  readonly filterByColumn: (column: string) => string;
28
+ /** UiDataTableColumnFilter */
29
+ readonly columns: "Columns";
30
+ readonly toggleColumns: "Toggle columns";
31
+ readonly columnVisibility: "Column visibility";
28
32
  };
29
33
  export type DataTableLabels = typeof DATA_TABLE_LABELS;
30
34
  /** Labels for UiDataTableColumnHeader */
@@ -66,3 +70,12 @@ export interface ToolbarLabels {
66
70
  /** Function to generate aria label for column filter */
67
71
  filterByColumn?: (column: string) => string;
68
72
  }
73
+ /** Labels for UiDataTableColumnFilter */
74
+ export interface ColumnFilterLabels {
75
+ /** Visible label for the trigger button. */
76
+ columns?: string;
77
+ /** Accessible label for the trigger button. */
78
+ toggleColumns?: string;
79
+ /** Dropdown section label. */
80
+ columnVisibility?: string;
81
+ }
@@ -1,6 +1,8 @@
1
1
  export { default as UiDataTable } from './UiDataTable.vue';
2
+ export { default as UiDataTableColumnFilter } from './UiDataTableColumnFilter.vue';
2
3
  export { default as UiDataTableColumnHeader } from './UiDataTableColumnHeader.vue';
3
4
  export { default as UiDataTablePagination } from './UiDataTablePagination.vue';
4
5
  export { default as UiDataTableToolbar } from './UiDataTableToolbar.vue';
5
6
  export * from './types';
6
7
  export * from './constants';
8
+ export * from '../../lib/useDrag';
@@ -1,5 +1,5 @@
1
1
  import { Column, ColumnDef, Row, Table } from '@tanstack/vue-table';
2
- import { ColumnHeaderLabels, PaginationLabels, ToolbarLabels } from './constants';
2
+ import { ColumnHeaderLabels, ColumnFilterLabels, PaginationLabels, ToolbarLabels } from './constants';
3
3
  /**
4
4
  * A feature-rich data table with sorting, filtering, and pagination.
5
5
  * Use for displaying and managing large datasets with interactive features.
@@ -40,6 +40,22 @@ export type UiDataTableProps<TData, TValue> = {
40
40
  * @example (item) => router.push(`/details/${item.id}`)
41
41
  */
42
42
  onRowClick?: (item: TData) => void;
43
+ /**
44
+ * Enables drag-and-drop reordering for table columns.
45
+ * @default false
46
+ */
47
+ draggableColumns?: boolean;
48
+ /**
49
+ * Callback when column order changes through drag-and-drop.
50
+ * Receives TanStack column IDs in their new order.
51
+ */
52
+ onColumnOrderChange?: (columnOrder: string[]) => void;
53
+ /**
54
+ * Function that determines whether a row can be expanded.
55
+ * Provide an `expanded-row` slot and toggle `row.toggleExpanded()` from a cell.
56
+ * @example (row) => row.original.children.length > 0
57
+ */
58
+ getRowCanExpand?: (row: Row<TData>) => boolean;
43
59
  };
44
60
  /**
45
61
  * Props for the UiDataTableColumnHeader component.
@@ -115,3 +131,18 @@ export type UiDataTableToolbarProps<TData> = {
115
131
  */
116
132
  labels?: ToolbarLabels;
117
133
  };
134
+ /**
135
+ * Props for the UiDataTableColumnFilter component.
136
+ */
137
+ export type UiDataTableColumnFilterProps<TData> = {
138
+ /**
139
+ * The TanStack Table instance.
140
+ * @internal
141
+ */
142
+ table: Table<TData>;
143
+ /**
144
+ * Custom labels for i18n support.
145
+ * Partial object that merges with defaults.
146
+ */
147
+ labels?: ColumnFilterLabels;
148
+ };
@@ -11,6 +11,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('../../compo
11
11
  collapsible: "offcanvas" | "icon" | "none";
12
12
  variant: "sidebar" | "floating" | "inset";
13
13
  side: "left" | "right";
14
+ resizable: boolean;
14
15
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
15
16
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
17
  export default _default;
@@ -32,6 +32,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
32
32
  collapsible: "offcanvas" | "icon" | "none";
33
33
  variant: "sidebar" | "floating" | "inset";
34
34
  side: "left" | "right";
35
+ resizable: boolean;
35
36
  }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
36
37
  P: {};
37
38
  B: {};
@@ -43,6 +44,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
43
44
  collapsible: "offcanvas" | "icon" | "none";
44
45
  variant: "sidebar" | "floating" | "inset";
45
46
  side: "left" | "right";
47
+ resizable: boolean;
46
48
  }>;
47
49
  __isFragment?: never;
48
50
  __isTeleport?: never;
@@ -51,6 +53,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
51
53
  collapsible: "offcanvas" | "icon" | "none";
52
54
  variant: "sidebar" | "floating" | "inset";
53
55
  side: "left" | "right";
56
+ resizable: boolean;
54
57
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
55
58
  $slots: {
56
59
  default?(_: {}): any;
@@ -105,6 +108,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
105
108
  collapsible: "offcanvas" | "icon" | "none";
106
109
  variant: "sidebar" | "floating" | "inset";
107
110
  side: "left" | "right";
111
+ resizable: boolean;
108
112
  }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
109
113
  P: {};
110
114
  B: {};
@@ -116,6 +120,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
116
120
  collapsible: "offcanvas" | "icon" | "none";
117
121
  variant: "sidebar" | "floating" | "inset";
118
122
  side: "left" | "right";
123
+ resizable: boolean;
119
124
  }>;
120
125
  __isFragment?: never;
121
126
  __isTeleport?: never;
@@ -124,6 +129,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
124
129
  collapsible: "offcanvas" | "icon" | "none";
125
130
  variant: "sidebar" | "floating" | "inset";
126
131
  side: "left" | "right";
132
+ resizable: boolean;
127
133
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
128
134
  $slots: {
129
135
  default?(_: {}): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -106,7 +106,7 @@
106
106
  "date-fns": "4.1.0",
107
107
  "lucide-vue-next": "1.0.0",
108
108
  "radix-vue": "^1.9.17",
109
- "reka-ui": "^2.7.0",
109
+ "reka-ui": "^2.9.2",
110
110
  "shiki": "^3.0.0",
111
111
  "tailwind-merge": "^3.4.0",
112
112
  "vue-sonner": "^2.0.9",
@@ -1,7 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
2
  import { UiAlert, UiAlertDescription, UiAlertTitle } from './index';
3
3
  import { AlertVariants } from './constants';
4
- import { UiIcon } from '../UiIcon';
5
4
 
6
5
  /**
7
6
  * UiAlert is a static, contextual message that calls attention to status information (info, success, warning, destructive).
@@ -29,12 +28,11 @@ export default meta;
29
28
  type Story = StoryObj<typeof UiAlert>;
30
29
 
31
30
  const defaultTemplateSource = `<script setup lang="ts">
32
- import { UiAlert, UiAlertDescription, UiAlertTitle, UiIcon } from '@aleph-alpha/ui-library'
31
+ import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
33
32
  </script>
34
33
 
35
34
  <template>
36
35
  <UiAlert>
37
- <UiIcon name="circle-check" :size="16" />
38
36
  <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
39
37
  <UiAlertDescription>
40
38
  This is an alert with icon, title and description.
@@ -51,14 +49,12 @@ export const Default: Story = {
51
49
  UiAlert,
52
50
  UiAlertDescription,
53
51
  UiAlertTitle,
54
- UiIcon,
55
52
  },
56
53
  setup() {
57
54
  return { args };
58
55
  },
59
56
  template: `
60
57
  <UiAlert :variant="args.variant">
61
- <UiIcon name="circle-check" :size="16" />
62
58
  <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
63
59
  <UiAlertDescription>
64
60
  This is an alert with icon, title and description.
@@ -76,12 +72,11 @@ export const Default: Story = {
76
72
  };
77
73
 
78
74
  const destructiveTemplateSource = `<script setup lang="ts">
79
- import { UiAlert, UiAlertDescription, UiAlertTitle, UiIcon } from '@aleph-alpha/ui-library'
75
+ import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
80
76
  </script>
81
77
 
82
78
  <template>
83
79
  <UiAlert variant="destructive">
84
- <UiIcon name="circle-x" :size="16" />
85
80
  <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
86
81
  <UiAlertDescription>
87
82
  <p>Please verify your billing information and try again.</p>
@@ -103,11 +98,9 @@ export const Destructive: Story = {
103
98
  UiAlert,
104
99
  UiAlertDescription,
105
100
  UiAlertTitle,
106
- UiIcon,
107
101
  },
108
102
  template: `
109
103
  <UiAlert variant="destructive">
110
- <UiIcon name="circle-x" :size="16" />
111
104
  <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
112
105
  <UiAlertDescription>
113
106
  <p>Please verify your billing information and try again.</p>
@@ -130,13 +123,12 @@ export const Destructive: Story = {
130
123
  };
131
124
 
132
125
  const allVariantsTemplateSource = `<script setup lang="ts">
133
- import { UiAlert, UiAlertDescription, UiAlertTitle, UiIcon } from '@aleph-alpha/ui-library'
126
+ import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
134
127
  </script>
135
128
 
136
129
  <template>
137
130
  <div class="flex flex-col gap-4">
138
131
  <UiAlert>
139
- <UiIcon name="circle-check" :size="16" />
140
132
  <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
141
133
  <UiAlertDescription>
142
134
  This is an alert with icon, title and description.
@@ -144,7 +136,6 @@ import { UiAlert, UiAlertDescription, UiAlertTitle, UiIcon } from '@aleph-alpha/
144
136
  </UiAlert>
145
137
 
146
138
  <UiAlert variant="destructive">
147
- <UiIcon name="circle-x" :size="16" />
148
139
  <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
149
140
  <UiAlertDescription>
150
141
  <p>Please verify your billing information and try again.</p>
@@ -167,12 +158,10 @@ export const AllVariants: Story = {
167
158
  UiAlert,
168
159
  UiAlertDescription,
169
160
  UiAlertTitle,
170
- UiIcon,
171
161
  },
172
162
  template: `
173
163
  <div class="flex flex-col gap-4">
174
164
  <UiAlert>
175
- <UiIcon name="circle-check" :size="16" />
176
165
  <UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
177
166
  <UiAlertDescription>
178
167
  This is an alert with icon, title and description.
@@ -180,7 +169,6 @@ export const AllVariants: Story = {
180
169
  </UiAlert>
181
170
 
182
171
  <UiAlert variant="destructive">
183
- <UiIcon name="circle-x" :size="16" />
184
172
  <UiAlertTitle>Unable to process your payment.</UiAlertTitle>
185
173
  <UiAlertDescription>
186
174
  <p>Please verify your billing information and try again.</p>
@@ -1,27 +1,33 @@
1
1
  <script setup lang="ts">
2
2
  import { Alert as ShadcnAlert } from '@/components/core/alert';
3
3
 
4
- import { UiAlertProps } from './types';
4
+ import type { UiAlertProps } from './types';
5
+ import UiIcon from '../UiIcon/UiIcon.vue';
6
+ import { AlertVariantIconNames, AlertVariants } from './constants';
7
+ import { computed } from 'vue';
5
8
 
6
9
  defineOptions({
7
10
  name: 'UiAlert',
8
11
  });
9
12
 
10
- withDefaults(defineProps<UiAlertProps>(), {
13
+ const props = withDefaults(defineProps<UiAlertProps>(), {
11
14
  variant: 'default',
12
15
  });
13
16
 
14
- /**
15
- * shadcn-vue `Alert` styles are optimized for SVG icons (`has-[>svg]...`).
16
- * Our `UiIcon` renders as `<span data-slot="icon" ... />`, so we mirror the same
17
- * layout rules for `[data-slot=icon]` to keep alignment consistent.
18
- */
19
- const uiIconLayoutClasses =
20
- 'has-[>[data-slot=icon]]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>[data-slot=icon]]:gap-x-3 [&>[data-slot=icon]]:size-4 [&>[data-slot=icon]]:translate-y-0.5 [&>[data-slot=icon]]:text-current';
17
+ const alertVariantIcons = new Map(
18
+ AlertVariants.map((variant) => [variant, AlertVariantIconNames[variant]]),
19
+ );
20
+
21
+ const alertIcon = computed(
22
+ () => alertVariantIcons.get(props.variant) ?? AlertVariantIconNames.default,
23
+ );
21
24
  </script>
22
25
 
23
26
  <template>
24
- <ShadcnAlert :variant :class="uiIconLayoutClasses">
27
+ <ShadcnAlert :variant>
28
+ <slot name="icon">
29
+ <UiIcon :name="alertIcon" :size="16" />
30
+ </slot>
25
31
  <slot />
26
32
  </ShadcnAlert>
27
33
  </template>
@@ -1,3 +1,22 @@
1
- import { UiAlertVariants } from './types';
1
+ import type { UiAlertVariants } from './types';
2
2
 
3
- export const AlertVariants: UiAlertVariants[] = ['default', 'destructive'];
3
+ /**
4
+ * Supported visual variants for `UiAlert`.
5
+ *
6
+ * Keep this list aligned with `UiAlertVariants` so Storybook controls and
7
+ * variant iteration stay type-safe when variants are added or removed.
8
+ */
9
+ export const AlertVariants = [
10
+ 'default',
11
+ 'destructive',
12
+ ] as const satisfies readonly UiAlertVariants[];
13
+
14
+ /**
15
+ * Default icon names for each alert variant.
16
+ *
17
+ * Consumers can override the rendered icon through the `icon` slot.
18
+ */
19
+ export const AlertVariantIconNames = {
20
+ default: 'circle-check',
21
+ destructive: 'circle-alert',
22
+ } as const satisfies Record<UiAlertVariants, string>;