@aleph-alpha/ui-library 6.0.0 → 6.1.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/config.d.ts +28 -4
- package/config.js +99 -23
- package/dist/system/components/UiTagsInput/UiTagsInput.vue.d.ts +2 -0
- package/dist/system/components/UiTagsInput/UiTagsInputItemDelete.vue.d.ts +2 -1
- package/dist/system/components/UiTagsInput/types.d.ts +21 -2
- package/dist/system/components/core/tags-input/TagsInputItemDelete.vue.d.ts +5 -0
- package/dist/system/icons/story-sidebar-icons.json +7 -0
- package/dist/system/lib.js +1752 -1708
- package/dist/system/story-sidebar-icons.json +7 -0
- package/docs/public-docs/migration-guide.md +402 -0
- package/docs/public-docs/quick-start.md +19 -10
- package/package.json +4 -1
- package/src/components/UiAlert/UiAlert.stories.ts +732 -0
- package/src/components/UiAlert/__tests__/UiAlert.test.ts +57 -11
- package/src/components/UiChip/UiChip.stories.ts +756 -2
- package/src/components/UiChip/UiChip.vue +7 -6
- package/src/components/UiChip/__tests__/UiChip.test.ts +38 -61
- package/src/components/UiDrawer/UiDrawer.stories.ts +665 -0
- package/src/components/UiDrawer/__tests__/UiDrawer.test.ts +6 -190
- package/src/components/UiLabel/UiLabel.stories.ts +691 -16
- package/src/components/UiLabel/__tests__/UiLabel.test.ts +18 -26
- package/src/components/UiSheet/UiSheet.stories.ts +751 -0
- package/src/components/UiSheet/__tests__/UiSheet.test.ts +6 -190
- package/src/components/UiSlider/UiSlider.stories.ts +716 -0
- package/src/components/UiSlider/__tests__/UiSlider.test.ts +8 -45
- package/src/components/UiSwitch/UiSwitch.stories.ts +11 -5
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +850 -4
- package/src/components/UiTagsInput/UiTagsInput.vue +34 -0
- package/src/components/UiTagsInput/UiTagsInputItemDelete.vue +4 -1
- package/src/components/UiTagsInput/__tests__/UiTagsInput.test.ts +113 -29
- package/src/components/UiTagsInput/types.ts +24 -2
- package/src/components/core/sheet/SheetContent.vue +6 -1
- package/src/components/core/switch/index.ts +8 -7
- package/src/components/core/tags-input/TagsInput.vue +4 -1
- package/src/components/core/tags-input/TagsInputItem.vue +13 -1
- package/src/components/core/tags-input/TagsInputItemDelete.vue +40 -7
- package/src/theme/Typography.stories.ts +125 -133
- package/tokens.json +8132 -2475
- package/dist/system/icons/mobile-device-frame.png +0 -0
- package/dist/system/mobile-device-frame.png +0 -0
|
@@ -1,20 +1,66 @@
|
|
|
1
1
|
import { render } from '@testing-library/vue';
|
|
2
2
|
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import { defineComponent } from 'vue';
|
|
3
4
|
import UiAlert from '../UiAlert.vue';
|
|
5
|
+
import { AlertVariantIconNames, AlertVariants } from '../constants';
|
|
6
|
+
|
|
7
|
+
// The alert role, the assertive live-region semantics, the announcement fired
|
|
8
|
+
// by mounting, and the composed dismiss flow are covered by the play functions
|
|
9
|
+
// in `UiAlert.stories.ts`, which drive a real browser. What stays here is the
|
|
10
|
+
// variant-to-icon mapping and the `icon` slot override — prop plumbing that
|
|
11
|
+
// needs no browser, and that would otherwise be asserted against Lucide's
|
|
12
|
+
// internal markup.
|
|
13
|
+
const UiIconStub = defineComponent({
|
|
14
|
+
name: 'UiIcon',
|
|
15
|
+
props: {
|
|
16
|
+
name: { type: String, default: '' },
|
|
17
|
+
},
|
|
18
|
+
template: '<i data-testid="alert-icon" :data-icon-name="name" />',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Renders `UiAlert` with the icon replaced by a stub that records the icon
|
|
23
|
+
* name it was asked for.
|
|
24
|
+
* @param props Props forwarded to `UiAlert`.
|
|
25
|
+
* @param slots Slots forwarded to `UiAlert`.
|
|
26
|
+
* @returns The testing-library render result.
|
|
27
|
+
*/
|
|
28
|
+
function renderAlert(props: Record<string, unknown> = {}, slots = {}) {
|
|
29
|
+
return render(UiAlert, {
|
|
30
|
+
props,
|
|
31
|
+
slots: { default: 'Message', ...slots },
|
|
32
|
+
global: { stubs: { UiIcon: UiIconStub } },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
4
35
|
|
|
5
36
|
describe('UiAlert', () => {
|
|
6
|
-
test('
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
37
|
+
test.each(AlertVariants)('maps the %s variant to its icon', (variant) => {
|
|
38
|
+
const { getByTestId } = renderAlert({ variant });
|
|
39
|
+
|
|
40
|
+
expect(getByTestId('alert-icon')).toHaveAttribute(
|
|
41
|
+
'data-icon-name',
|
|
42
|
+
AlertVariantIconNames[variant],
|
|
43
|
+
);
|
|
11
44
|
});
|
|
12
45
|
|
|
13
|
-
test('
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
expect(
|
|
46
|
+
test('falls back to the default icon for an unknown variant', () => {
|
|
47
|
+
// The variant is typed, so only a miswired consumer can reach this — the
|
|
48
|
+
// component still resolves an icon rather than rendering none.
|
|
49
|
+
const { getByTestId } = renderAlert({ variant: 'nope' });
|
|
50
|
+
|
|
51
|
+
expect(getByTestId('alert-icon')).toHaveAttribute(
|
|
52
|
+
'data-icon-name',
|
|
53
|
+
AlertVariantIconNames.default,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('lets the icon slot replace the variant icon', () => {
|
|
58
|
+
const { getByTestId, queryByTestId } = renderAlert(
|
|
59
|
+
{},
|
|
60
|
+
{ icon: '<span data-testid="custom-icon">!</span>' },
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect(getByTestId('custom-icon')).toBeInTheDocument();
|
|
64
|
+
expect(queryByTestId('alert-icon')).not.toBeInTheDocument();
|
|
19
65
|
});
|
|
20
66
|
});
|