@aleph-alpha/ui-library 2.2.0 → 2.3.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.
- package/dist/system/components/UiToggle/UiToggle.vue.d.ts +5 -0
- package/dist/system/components/UiToggle/types.d.ts +13 -0
- package/dist/system/lib/heightTransition.d.ts +5 -0
- package/dist/system/lib/useDrag.d.ts +52 -0
- package/dist/system/lib.js +16727 -16225
- package/dist/system/patterns/UiDataTable/UiDataTable.vue.d.ts +22 -3
- package/dist/system/patterns/UiDataTable/UiDataTableColumnFilter.vue.d.ts +14 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +13 -0
- package/dist/system/patterns/UiDataTable/index.d.ts +2 -0
- package/dist/system/patterns/UiDataTable/types.d.ts +32 -1
- package/package.json +1 -1
- package/src/components/UiTable/__tests__/UiTableRow.test.ts +14 -5
- package/src/components/UiToggle/UiToggle.vue +18 -1
- package/src/components/UiToggle/__tests__/UiToggle.test.ts +33 -3
- package/src/components/UiToggle/types.ts +13 -0
- package/src/components/core/accordion/AccordionContent.vue +36 -1
- package/src/components/core/table/TableRow.vue +1 -1
- package/src/components/core/toggle/index.ts +2 -2
- package/src/lib/heightTransition.ts +27 -0
- package/src/lib/useDrag.stories.ts +295 -0
- package/src/lib/useDrag.ts +212 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +348 -0
- package/src/patterns/UiDataTable/UiDataTable.vue +558 -22
- package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +83 -0
- package/src/patterns/UiDataTable/UiDataTableColumnHeader.vue +4 -13
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +329 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnFilter.test.ts +194 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTableColumnHeader.test.ts +11 -0
- package/src/patterns/UiDataTable/constants.ts +15 -0
- package/src/patterns/UiDataTable/index.ts +2 -0
- package/src/patterns/UiDataTable/types.ts +33 -0
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +13 -36
|
@@ -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:
|
|
6
|
+
table: Table<TData>;
|
|
6
7
|
}>): void;
|
|
7
8
|
attrs: any;
|
|
8
|
-
slots: {
|
|
9
|
-
empty
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import '@testing-library/jest-dom/vitest';
|
|
2
1
|
import { render } from '@testing-library/vue';
|
|
3
2
|
import { describe, expect, test } from 'vitest';
|
|
4
3
|
import UiTableRow from '../UiTableRow.vue';
|
|
@@ -10,7 +9,7 @@ describe('UiTableRow', () => {
|
|
|
10
9
|
slots: { default: '<td>Cell</td>' },
|
|
11
10
|
});
|
|
12
11
|
|
|
13
|
-
expect(getByRole('row')).
|
|
12
|
+
expect(getByRole('row').className).toContain('hover:bg-muted');
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
test('uses muted-subtle hover fill by default', () => {
|
|
@@ -18,18 +17,28 @@ describe('UiTableRow', () => {
|
|
|
18
17
|
slots: { default: '<td>Cell</td>' },
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
expect(getByRole('row')).
|
|
20
|
+
expect(getByRole('row').className).toContain(
|
|
22
21
|
'hover:bg-background-surface-muted-subtle',
|
|
23
22
|
);
|
|
24
23
|
});
|
|
25
24
|
|
|
25
|
+
test('does not apply row hover fill when hovering a button inside the row', () => {
|
|
26
|
+
const { getByRole } = render(UiTableRow, {
|
|
27
|
+
slots: { default: '<td><button type="button">Expand</button></td>' },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(getByRole('row').className).toContain(
|
|
31
|
+
'has-[button:hover]:hover:bg-transparent',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
26
35
|
test('applies data-state="selected" when selected prop is true', () => {
|
|
27
36
|
const { getByRole } = render(UiTableRow, {
|
|
28
37
|
props: { selected: true },
|
|
29
38
|
slots: { default: '<td>Cell</td>' },
|
|
30
39
|
});
|
|
31
40
|
|
|
32
|
-
expect(getByRole('row')
|
|
41
|
+
expect(getByRole('row').getAttribute('data-state')).toBe('selected');
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
test('defaults to not selected', () => {
|
|
@@ -37,6 +46,6 @@ describe('UiTableRow', () => {
|
|
|
37
46
|
slots: { default: '<td>Cell</td>' },
|
|
38
47
|
});
|
|
39
48
|
|
|
40
|
-
expect(getByRole('row')
|
|
49
|
+
expect(getByRole('row').hasAttribute('data-state')).toBe(false);
|
|
41
50
|
});
|
|
42
51
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { Toggle as ShadcnToggle } from '@/components/core/toggle';
|
|
3
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
3
4
|
import type { UiToggleProps } from './types';
|
|
4
5
|
|
|
5
6
|
defineOptions({
|
|
@@ -10,19 +11,35 @@ const props = withDefaults(defineProps<UiToggleProps>(), {
|
|
|
10
11
|
disabled: false,
|
|
11
12
|
variant: 'default',
|
|
12
13
|
size: 'default',
|
|
14
|
+
active: undefined,
|
|
15
|
+
leftIcon: undefined,
|
|
16
|
+
rightIcon: undefined,
|
|
13
17
|
});
|
|
14
18
|
|
|
15
19
|
const modelValue = defineModel<boolean>();
|
|
20
|
+
|
|
21
|
+
function handleUpdateModelValue(value: boolean) {
|
|
22
|
+
if (props.active !== undefined) return;
|
|
23
|
+
|
|
24
|
+
modelValue.value = value;
|
|
25
|
+
}
|
|
16
26
|
</script>
|
|
17
27
|
|
|
18
28
|
<template>
|
|
19
29
|
<ShadcnToggle
|
|
20
|
-
|
|
30
|
+
:model-value="props.active ?? modelValue"
|
|
21
31
|
:default-value="props.defaultValue"
|
|
22
32
|
:disabled="props.disabled"
|
|
23
33
|
:variant="props.variant"
|
|
24
34
|
:size="props.size"
|
|
35
|
+
@update:model-value="handleUpdateModelValue"
|
|
25
36
|
>
|
|
37
|
+
<slot name="left-icon">
|
|
38
|
+
<UiIcon v-if="props.leftIcon" :name="props.leftIcon" :size="16" />
|
|
39
|
+
</slot>
|
|
26
40
|
<slot />
|
|
41
|
+
<slot name="right-icon">
|
|
42
|
+
<UiIcon v-if="props.rightIcon" :name="props.rightIcon" :size="16" />
|
|
43
|
+
</slot>
|
|
27
44
|
</ShadcnToggle>
|
|
28
45
|
</template>
|
|
@@ -25,6 +25,14 @@ describe('UiToggle', () => {
|
|
|
25
25
|
expect(getByRole('button')).toHaveAttribute('data-state', 'off');
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
test('uses active prop as controlled visual state', () => {
|
|
29
|
+
const { getByRole } = render(UiToggle, {
|
|
30
|
+
props: { active: true },
|
|
31
|
+
slots: { default: 'Toggle' },
|
|
32
|
+
});
|
|
33
|
+
expect(getByRole('button')).toHaveAttribute('data-state', 'on');
|
|
34
|
+
});
|
|
35
|
+
|
|
28
36
|
test('uses muted-subtle hover fill', () => {
|
|
29
37
|
const { getByRole } = render(UiToggle, {
|
|
30
38
|
slots: { default: 'Toggle' },
|
|
@@ -34,6 +42,16 @@ describe('UiToggle', () => {
|
|
|
34
42
|
);
|
|
35
43
|
});
|
|
36
44
|
|
|
45
|
+
test('uses outlined button border by default', () => {
|
|
46
|
+
const { getByRole } = render(UiToggle, {
|
|
47
|
+
slots: { default: 'Toggle' },
|
|
48
|
+
});
|
|
49
|
+
expect(getByRole('button')).toHaveClass(
|
|
50
|
+
'border',
|
|
51
|
+
'border-border-button-outlined',
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
37
55
|
test('is disabled when disabled prop is true', () => {
|
|
38
56
|
const { getByRole } = render(UiToggle, {
|
|
39
57
|
props: { disabled: true },
|
|
@@ -58,11 +76,15 @@ describe('UiToggle', () => {
|
|
|
58
76
|
});
|
|
59
77
|
const toggle = container.querySelector('button');
|
|
60
78
|
expect(toggle).toHaveClass('bg-transparent');
|
|
61
|
-
expect(toggle).toHaveClass('
|
|
79
|
+
expect(toggle).toHaveClass('border-border-button-outlined');
|
|
80
|
+
expect(toggle).toHaveClass('data-[state=on]:bg-background-accent-soft');
|
|
81
|
+
expect(toggle).toHaveClass('data-[state=on]:text-content-on-accent-soft');
|
|
62
82
|
expect(toggle).toHaveClass('data-[state=on]:border-accent-default');
|
|
63
|
-
expect(toggle).toHaveClass('data-[state=open]:bg-accent');
|
|
83
|
+
expect(toggle).toHaveClass('data-[state=open]:bg-background-accent-soft');
|
|
84
|
+
expect(toggle).toHaveClass('data-[state=open]:text-content-on-accent-soft');
|
|
64
85
|
expect(toggle).toHaveClass('data-[state=open]:border-accent-default');
|
|
65
|
-
expect(toggle).toHaveClass('aria-pressed:bg-accent');
|
|
86
|
+
expect(toggle).toHaveClass('aria-pressed:bg-background-accent-soft');
|
|
87
|
+
expect(toggle).toHaveClass('aria-pressed:text-content-on-accent-soft');
|
|
66
88
|
expect(toggle).toHaveClass('aria-pressed:border-accent-default');
|
|
67
89
|
});
|
|
68
90
|
|
|
@@ -83,4 +105,12 @@ describe('UiToggle', () => {
|
|
|
83
105
|
const toggle = container.querySelector('button');
|
|
84
106
|
expect(toggle).toHaveClass('h-10');
|
|
85
107
|
});
|
|
108
|
+
|
|
109
|
+
test('renders left and right icons', () => {
|
|
110
|
+
const { container } = render(UiToggle, {
|
|
111
|
+
props: { leftIcon: 'columns3', rightIcon: 'chevron-down' },
|
|
112
|
+
slots: { default: 'Toggle' },
|
|
113
|
+
});
|
|
114
|
+
expect(container.querySelectorAll('[data-slot="icon"]')).toHaveLength(2);
|
|
115
|
+
});
|
|
86
116
|
});
|
|
@@ -16,6 +16,11 @@ export interface UiToggleProps {
|
|
|
16
16
|
* Use when you do not need to control its state.
|
|
17
17
|
*/
|
|
18
18
|
defaultValue?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Controlled visual active state. Useful when another component, such as a dropdown,
|
|
21
|
+
* owns the active/open state.
|
|
22
|
+
*/
|
|
23
|
+
active?: boolean;
|
|
19
24
|
/**
|
|
20
25
|
* Whether the toggle is disabled.
|
|
21
26
|
* @default false
|
|
@@ -31,4 +36,12 @@ export interface UiToggleProps {
|
|
|
31
36
|
* @default 'default'
|
|
32
37
|
*/
|
|
33
38
|
size?: 'default' | 'sm' | 'lg';
|
|
39
|
+
/**
|
|
40
|
+
* Optional icon rendered before the default slot.
|
|
41
|
+
*/
|
|
42
|
+
leftIcon?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Optional icon rendered after the default slot.
|
|
45
|
+
*/
|
|
46
|
+
rightIcon?: string;
|
|
34
47
|
}
|
|
@@ -16,10 +16,45 @@ const delegatedProps = reactiveOmit(props, 'class');
|
|
|
16
16
|
<AccordionContent
|
|
17
17
|
data-slot="accordion-content"
|
|
18
18
|
v-bind="delegatedProps"
|
|
19
|
-
class="
|
|
19
|
+
class="ui-accordion-content overflow-hidden text-sm"
|
|
20
20
|
>
|
|
21
21
|
<div :class="cn('pt-0 pb-4', props.class)">
|
|
22
22
|
<slot />
|
|
23
23
|
</div>
|
|
24
24
|
</AccordionContent>
|
|
25
25
|
</template>
|
|
26
|
+
|
|
27
|
+
<style scoped>
|
|
28
|
+
.ui-accordion-content[data-state='open'] {
|
|
29
|
+
animation: ui-accordion-down 200ms linear;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ui-accordion-content[data-state='closed'] {
|
|
33
|
+
animation: ui-accordion-up 200ms linear;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@media (prefers-reduced-motion: reduce) {
|
|
37
|
+
.ui-accordion-content[data-state='open'],
|
|
38
|
+
.ui-accordion-content[data-state='closed'] {
|
|
39
|
+
animation-duration: 1ms;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@keyframes ui-accordion-down {
|
|
44
|
+
from {
|
|
45
|
+
height: 0;
|
|
46
|
+
}
|
|
47
|
+
to {
|
|
48
|
+
height: var(--reka-accordion-content-height);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes ui-accordion-up {
|
|
53
|
+
from {
|
|
54
|
+
height: var(--reka-accordion-content-height);
|
|
55
|
+
}
|
|
56
|
+
to {
|
|
57
|
+
height: 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -14,7 +14,7 @@ const props = defineProps<{
|
|
|
14
14
|
:data-state="props.dataState"
|
|
15
15
|
:class="
|
|
16
16
|
cn(
|
|
17
|
-
'hover:bg-background-surface-muted-subtle data-[state=selected]:bg-muted border-b transition-colors',
|
|
17
|
+
'hover:bg-background-surface-muted-subtle has-[button:hover]:hover:bg-transparent data-[state=selected]:bg-muted border-b transition-colors',
|
|
18
18
|
props.class,
|
|
19
19
|
)
|
|
20
20
|
"
|
|
@@ -8,10 +8,10 @@ export const toggleVariants = cva(
|
|
|
8
8
|
variants: {
|
|
9
9
|
variant: {
|
|
10
10
|
default:
|
|
11
|
-
'bg-transparent data-[state=on]:bg-accent-default data-[state=on]:text-accent-default-foreground data-[state=on]:hover:bg-accent-default data-[state=on]:hover:text-accent-default-foreground data-[state=open]:bg-accent-default data-[state=open]:text-accent-default-foreground data-[state=open]:hover:bg-accent-default data-[state=open]:hover:text-accent-default-foreground aria-pressed:bg-accent-default aria-pressed:text-accent-default-foreground aria-pressed:hover:bg-accent-default aria-pressed:hover:text-accent-default-foreground',
|
|
11
|
+
'border border-border-button-outlined bg-transparent data-[state=on]:bg-accent-default data-[state=on]:text-accent-default-foreground data-[state=on]:hover:bg-accent-default data-[state=on]:hover:text-accent-default-foreground data-[state=open]:bg-accent-default data-[state=open]:text-accent-default-foreground data-[state=open]:hover:bg-accent-default data-[state=open]:hover:text-accent-default-foreground aria-pressed:bg-accent-default aria-pressed:text-accent-default-foreground aria-pressed:hover:bg-accent-default aria-pressed:hover:text-accent-default-foreground',
|
|
12
12
|
outline:
|
|
13
13
|
'border border-input bg-transparent shadow-sm focus-visible:border-ring data-[state=on]:bg-accent-default data-[state=on]:text-accent-default-foreground data-[state=on]:hover:bg-accent-default data-[state=on]:hover:text-accent-default-foreground data-[state=open]:bg-accent-default data-[state=open]:text-accent-default-foreground data-[state=open]:hover:bg-accent-default data-[state=open]:hover:text-accent-default-foreground aria-pressed:bg-accent-default aria-pressed:text-accent-default-foreground aria-pressed:hover:bg-accent-default aria-pressed:hover:text-accent-default-foreground',
|
|
14
|
-
soft: 'bg-transparent data-[state=on]:
|
|
14
|
+
soft: 'border border-border-button-outlined bg-transparent data-[state=on]:border-accent-default data-[state=on]:bg-background-accent-soft data-[state=on]:text-content-on-accent-soft data-[state=on]:hover:bg-background-accent-soft data-[state=on]:hover:text-content-on-accent-soft data-[state=open]:border-accent-default data-[state=open]:bg-background-accent-soft data-[state=open]:text-content-on-accent-soft data-[state=open]:hover:bg-background-accent-soft data-[state=open]:hover:text-content-on-accent-soft aria-pressed:border-accent-default aria-pressed:bg-background-accent-soft aria-pressed:text-content-on-accent-soft aria-pressed:hover:bg-background-accent-soft aria-pressed:hover:text-content-on-accent-soft',
|
|
15
15
|
},
|
|
16
16
|
size: {
|
|
17
17
|
default: 'h-9 px-2 min-w-9',
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const heightTransitionClass =
|
|
2
|
+
'transition-[height] duration-200 ease-linear overflow-hidden';
|
|
3
|
+
|
|
4
|
+
function forceHeightReflow(node: HTMLElement) {
|
|
5
|
+
node.getBoundingClientRect();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function onHeightTransitionEnter(el: Element) {
|
|
9
|
+
const node = el as HTMLElement;
|
|
10
|
+
node.style.height = '0px';
|
|
11
|
+
forceHeightReflow(node);
|
|
12
|
+
node.style.height = `${node.scrollHeight}px`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function onHeightTransitionAfterEnter(el: Element) {
|
|
16
|
+
(el as HTMLElement).style.height = '';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function onHeightTransitionBeforeLeave(el: Element) {
|
|
20
|
+
const node = el as HTMLElement;
|
|
21
|
+
node.style.height = `${node.scrollHeight}px`;
|
|
22
|
+
forceHeightReflow(node);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function onHeightTransitionLeave(el: Element) {
|
|
26
|
+
(el as HTMLElement).style.height = '0px';
|
|
27
|
+
}
|