@bwui/vue 0.1.14 → 0.1.15
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/README.md +3 -0
- package/dist/chrome.d.ts +183 -0
- package/dist/chrome.js +287 -0
- package/dist/combobox.d.ts +223 -8
- package/dist/combobox.js +571 -85
- package/dist/date-picker.d.ts +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -1
- package/dist/pages.js +10 -4
- package/dist/primitives.d.ts +174 -15
- package/dist/primitives.js +178 -15
- package/package.json +10 -7
- package/src/chrome.ts +385 -0
- package/src/combobox.ts +625 -61
- package/src/index.ts +33 -1
- package/src/pages.ts +10 -4
- package/src/primitives.ts +278 -32
package/README.md
CHANGED
|
@@ -14,3 +14,6 @@ import { Homepage, ContactForm, Combobox } from "@bwui/vue";
|
|
|
14
14
|
|
|
15
15
|
Four jobs: `<Homepage>`, `<Landing>`, `<ContactForm>` plus form primitives
|
|
16
16
|
(`Field`, `Input`, `Combobox`, `DatePicker`, `DateRangePicker`, `TimeInput`).
|
|
17
|
+
`Card` ships with region primitives (`CardHeader`, `CardBody`, `CardFooter`,
|
|
18
|
+
`CardMedia`, `CardTitle`, `CardDescription`). `Combobox` covers single and
|
|
19
|
+
multiple modes against the raised contract (GAP-CMB-18, GAP-CRD-4).
|
package/dist/chrome.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue mirrors for Tabs (H01), Avatar (A05) and Breadcrumbs (H02).
|
|
3
|
+
* Class and a11y contracts match packages/react/src/chrome.tsx as far as
|
|
4
|
+
* practical for Vue 3 (provide/inject, update:value).
|
|
5
|
+
*/
|
|
6
|
+
import { type PropType } from 'vue';
|
|
7
|
+
export type TabsVariant = 'underline' | 'pill';
|
|
8
|
+
export declare const Tabs: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
9
|
+
id: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
value: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
variant: {
|
|
18
|
+
type: PropType<TabsVariant>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
+
id: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
value: {
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
variant: {
|
|
33
|
+
type: PropType<TabsVariant>;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
}>> & Readonly<{
|
|
37
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
38
|
+
}>, {
|
|
39
|
+
id: string;
|
|
40
|
+
variant: TabsVariant;
|
|
41
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
42
|
+
export declare const TabList: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
45
|
+
export declare const Tab: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
46
|
+
value: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
required: true;
|
|
49
|
+
};
|
|
50
|
+
badge: {
|
|
51
|
+
type: PropType<string | number | boolean>;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
54
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
57
|
+
value: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
required: true;
|
|
60
|
+
};
|
|
61
|
+
badge: {
|
|
62
|
+
type: PropType<string | number | boolean>;
|
|
63
|
+
default: undefined;
|
|
64
|
+
};
|
|
65
|
+
}>> & Readonly<{}>, {
|
|
66
|
+
badge: string | number | boolean;
|
|
67
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
68
|
+
export declare const TabPanel: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
69
|
+
value: {
|
|
70
|
+
type: StringConstructor;
|
|
71
|
+
required: true;
|
|
72
|
+
};
|
|
73
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
76
|
+
value: {
|
|
77
|
+
type: StringConstructor;
|
|
78
|
+
required: true;
|
|
79
|
+
};
|
|
80
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
81
|
+
/** ADR-125 size steps for Avatar (AVR-003). */
|
|
82
|
+
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
83
|
+
/** Avatar corner treatment (AVR-004). */
|
|
84
|
+
export type AvatarShape = 'circle' | 'square';
|
|
85
|
+
/**
|
|
86
|
+
* Avatar (A05 / R10). Pass exactly one content shape: `src`+`alt`, `initials`,
|
|
87
|
+
* or `overflow`. Matches React `Avatar` class and a11y carriers (AVR-070).
|
|
88
|
+
*/
|
|
89
|
+
export declare const Avatar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
90
|
+
size: {
|
|
91
|
+
type: PropType<AvatarSize>;
|
|
92
|
+
default: string;
|
|
93
|
+
};
|
|
94
|
+
shape: {
|
|
95
|
+
type: PropType<AvatarShape>;
|
|
96
|
+
default: string;
|
|
97
|
+
};
|
|
98
|
+
src: {
|
|
99
|
+
type: StringConstructor;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
alt: {
|
|
103
|
+
type: StringConstructor;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
initials: {
|
|
107
|
+
type: StringConstructor;
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
overflow: {
|
|
111
|
+
type: NumberConstructor;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
117
|
+
size: {
|
|
118
|
+
type: PropType<AvatarSize>;
|
|
119
|
+
default: string;
|
|
120
|
+
};
|
|
121
|
+
shape: {
|
|
122
|
+
type: PropType<AvatarShape>;
|
|
123
|
+
default: string;
|
|
124
|
+
};
|
|
125
|
+
src: {
|
|
126
|
+
type: StringConstructor;
|
|
127
|
+
default: undefined;
|
|
128
|
+
};
|
|
129
|
+
alt: {
|
|
130
|
+
type: StringConstructor;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
initials: {
|
|
134
|
+
type: StringConstructor;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
137
|
+
overflow: {
|
|
138
|
+
type: NumberConstructor;
|
|
139
|
+
default: undefined;
|
|
140
|
+
};
|
|
141
|
+
}>> & Readonly<{}>, {
|
|
142
|
+
size: AvatarSize;
|
|
143
|
+
shape: AvatarShape;
|
|
144
|
+
src: string;
|
|
145
|
+
alt: string;
|
|
146
|
+
initials: string;
|
|
147
|
+
overflow: number;
|
|
148
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
149
|
+
export type BreadcrumbItem = {
|
|
150
|
+
/** Intermediate crumbs with href render as links. The last crumb is never a link. */
|
|
151
|
+
href?: string;
|
|
152
|
+
label: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Breadcrumbs (H02 / R57): trail of ancestors ending in the current page.
|
|
156
|
+
* Last crumb is always unlinked with aria-current="page", even if href is set.
|
|
157
|
+
* Empty items renders nothing so a host :empty rule can collapse the region.
|
|
158
|
+
*/
|
|
159
|
+
export declare const Breadcrumbs: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
160
|
+
items: {
|
|
161
|
+
type: PropType<BreadcrumbItem[]>;
|
|
162
|
+
required: true;
|
|
163
|
+
};
|
|
164
|
+
/** Accessible name for the nav. Override for locales; default matches the Django shell. */
|
|
165
|
+
label: {
|
|
166
|
+
type: StringConstructor;
|
|
167
|
+
default: string;
|
|
168
|
+
};
|
|
169
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
170
|
+
[key: string]: any;
|
|
171
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
172
|
+
items: {
|
|
173
|
+
type: PropType<BreadcrumbItem[]>;
|
|
174
|
+
required: true;
|
|
175
|
+
};
|
|
176
|
+
/** Accessible name for the nav. Override for locales; default matches the Django shell. */
|
|
177
|
+
label: {
|
|
178
|
+
type: StringConstructor;
|
|
179
|
+
default: string;
|
|
180
|
+
};
|
|
181
|
+
}>> & Readonly<{}>, {
|
|
182
|
+
label: string;
|
|
183
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/chrome.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue mirrors for Tabs (H01), Avatar (A05) and Breadcrumbs (H02).
|
|
3
|
+
* Class and a11y contracts match packages/react/src/chrome.tsx as far as
|
|
4
|
+
* practical for Vue 3 (provide/inject, update:value).
|
|
5
|
+
*/
|
|
6
|
+
import { defineComponent, h, provide, inject, ref, onBeforeUnmount, } from 'vue';
|
|
7
|
+
import { cn } from './cn';
|
|
8
|
+
const tabsKey = Symbol('bw-tabs');
|
|
9
|
+
function useTabs() {
|
|
10
|
+
const ctx = inject(tabsKey, null);
|
|
11
|
+
if (!ctx)
|
|
12
|
+
throw new Error('Tabs parts must be used within <Tabs>');
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
15
|
+
export const Tabs = defineComponent({
|
|
16
|
+
name: 'BwTabs',
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
props: {
|
|
19
|
+
id: { type: String, default: 'bw-tabs' },
|
|
20
|
+
value: { type: String, required: true },
|
|
21
|
+
variant: { type: String, default: 'underline' },
|
|
22
|
+
},
|
|
23
|
+
emits: ['update:value'],
|
|
24
|
+
setup(props, { slots, attrs, emit }) {
|
|
25
|
+
const tabEls = new Map();
|
|
26
|
+
const tabOrder = ref([]);
|
|
27
|
+
const valueRef = ref(props.value);
|
|
28
|
+
const registerTab = (tabValue, el) => {
|
|
29
|
+
if (el) {
|
|
30
|
+
tabEls.set(tabValue, el);
|
|
31
|
+
if (!tabOrder.value.includes(tabValue)) {
|
|
32
|
+
tabOrder.value = [...tabOrder.value, tabValue];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
tabEls.delete(tabValue);
|
|
37
|
+
tabOrder.value = tabOrder.value.filter((v) => v !== tabValue);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const onValueChange = (next) => {
|
|
41
|
+
valueRef.value = next;
|
|
42
|
+
emit('update:value', next);
|
|
43
|
+
};
|
|
44
|
+
const onListKeyDown = (event) => {
|
|
45
|
+
const keys = tabOrder.value;
|
|
46
|
+
if (!keys.length)
|
|
47
|
+
return;
|
|
48
|
+
const active = document.activeElement;
|
|
49
|
+
let currentIndex = -1;
|
|
50
|
+
for (let i = 0; i < keys.length; i++) {
|
|
51
|
+
if (tabEls.get(keys[i]) === active) {
|
|
52
|
+
currentIndex = i;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (currentIndex < 0)
|
|
57
|
+
currentIndex = Math.max(0, keys.indexOf(valueRef.value));
|
|
58
|
+
const rtl = (typeof document !== 'undefined' &&
|
|
59
|
+
(document.documentElement.getAttribute('dir') === 'rtl' ||
|
|
60
|
+
document.body.getAttribute('dir') === 'rtl')) ||
|
|
61
|
+
false;
|
|
62
|
+
let next = currentIndex;
|
|
63
|
+
if (event.key === 'ArrowRight') {
|
|
64
|
+
next = rtl ? (currentIndex - 1 + keys.length) % keys.length : (currentIndex + 1) % keys.length;
|
|
65
|
+
}
|
|
66
|
+
else if (event.key === 'ArrowLeft') {
|
|
67
|
+
next = rtl ? (currentIndex + 1) % keys.length : (currentIndex - 1 + keys.length) % keys.length;
|
|
68
|
+
}
|
|
69
|
+
else if (event.key === 'Home') {
|
|
70
|
+
next = 0;
|
|
71
|
+
}
|
|
72
|
+
else if (event.key === 'End') {
|
|
73
|
+
next = keys.length - 1;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
tabEls.get(keys[next])?.focus();
|
|
80
|
+
// Manual activation: arrows move focus only; Enter/Space/click select.
|
|
81
|
+
};
|
|
82
|
+
provide(tabsKey, {
|
|
83
|
+
id: () => props.id,
|
|
84
|
+
value: valueRef,
|
|
85
|
+
onValueChange,
|
|
86
|
+
variant: () => props.variant,
|
|
87
|
+
registerTab,
|
|
88
|
+
tabOrder,
|
|
89
|
+
tabEls,
|
|
90
|
+
});
|
|
91
|
+
return () => {
|
|
92
|
+
valueRef.value = props.value;
|
|
93
|
+
const { class: _class, ...rest } = attrs;
|
|
94
|
+
return h('div', {
|
|
95
|
+
...rest,
|
|
96
|
+
class: cn('bw-tabs', `bw-tabs--${props.variant}`, String(attrs.class || '')),
|
|
97
|
+
'data-bw-tabs-id': props.id,
|
|
98
|
+
onKeydown: onListKeyDown,
|
|
99
|
+
}, slots.default?.());
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
export const TabList = defineComponent({
|
|
104
|
+
name: 'BwTabList',
|
|
105
|
+
inheritAttrs: false,
|
|
106
|
+
setup(_, { slots, attrs }) {
|
|
107
|
+
return () => {
|
|
108
|
+
const { class: _class, ...rest } = attrs;
|
|
109
|
+
return h('div', {
|
|
110
|
+
...rest,
|
|
111
|
+
class: cn('bw-tabs__list', String(attrs.class || '')),
|
|
112
|
+
role: 'tablist',
|
|
113
|
+
}, slots.default?.());
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
export const Tab = defineComponent({
|
|
118
|
+
name: 'BwTab',
|
|
119
|
+
inheritAttrs: false,
|
|
120
|
+
props: {
|
|
121
|
+
value: { type: String, required: true },
|
|
122
|
+
badge: { type: [String, Number, Boolean], default: undefined },
|
|
123
|
+
},
|
|
124
|
+
setup(props, { slots, attrs }) {
|
|
125
|
+
const tabs = useTabs();
|
|
126
|
+
const elRef = ref(null);
|
|
127
|
+
const setRef = (el) => {
|
|
128
|
+
elRef.value = el ?? null;
|
|
129
|
+
tabs.registerTab(props.value, elRef.value);
|
|
130
|
+
};
|
|
131
|
+
onBeforeUnmount(() => tabs.registerTab(props.value, null));
|
|
132
|
+
return () => {
|
|
133
|
+
const selected = tabs.value.value === props.value;
|
|
134
|
+
const tabId = `bw-tab-${tabs.id()}-${props.value}`;
|
|
135
|
+
const panelId = `bw-tabpanel-${tabs.id()}-${props.value}`;
|
|
136
|
+
const badgeContent = slots.badge?.() ?? (props.badge != null && props.badge !== false ? props.badge : null);
|
|
137
|
+
const { class: _class, ...rest } = attrs;
|
|
138
|
+
return h('button', {
|
|
139
|
+
...rest,
|
|
140
|
+
ref: setRef,
|
|
141
|
+
type: 'button',
|
|
142
|
+
role: 'tab',
|
|
143
|
+
id: tabId,
|
|
144
|
+
class: cn('bw-tabs__tab', selected && 'bw-tabs__tab--active', String(attrs.class || '')),
|
|
145
|
+
'aria-selected': selected,
|
|
146
|
+
'aria-controls': panelId,
|
|
147
|
+
tabindex: selected ? 0 : -1,
|
|
148
|
+
...(selected ? { 'data-bw-active': '' } : {}),
|
|
149
|
+
onClick: () => tabs.onValueChange(props.value),
|
|
150
|
+
onKeydown: (event) => {
|
|
151
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
tabs.onValueChange(props.value);
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
}, [
|
|
157
|
+
h('span', { class: 'bw-tabs__label' }, slots.default?.()),
|
|
158
|
+
badgeContent != null
|
|
159
|
+
? h('span', { class: 'bw-tabs__badge' }, badgeContent)
|
|
160
|
+
: null,
|
|
161
|
+
]);
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
export const TabPanel = defineComponent({
|
|
166
|
+
name: 'BwTabPanel',
|
|
167
|
+
inheritAttrs: false,
|
|
168
|
+
props: {
|
|
169
|
+
value: { type: String, required: true },
|
|
170
|
+
},
|
|
171
|
+
setup(props, { slots, attrs }) {
|
|
172
|
+
const tabs = useTabs();
|
|
173
|
+
return () => {
|
|
174
|
+
const selected = tabs.value.value === props.value;
|
|
175
|
+
const panelId = `bw-tabpanel-${tabs.id()}-${props.value}`;
|
|
176
|
+
const tabId = `bw-tab-${tabs.id()}-${props.value}`;
|
|
177
|
+
const { class: _class, ...rest } = attrs;
|
|
178
|
+
return h('div', {
|
|
179
|
+
...rest,
|
|
180
|
+
id: panelId,
|
|
181
|
+
role: 'tabpanel',
|
|
182
|
+
class: cn('bw-tabs__panel', String(attrs.class || '')),
|
|
183
|
+
'aria-labelledby': tabId,
|
|
184
|
+
hidden: !selected,
|
|
185
|
+
tabindex: selected ? 0 : undefined,
|
|
186
|
+
}, slots.default?.());
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
/**
|
|
191
|
+
* Avatar (A05 / R10). Pass exactly one content shape: `src`+`alt`, `initials`,
|
|
192
|
+
* or `overflow`. Matches React `Avatar` class and a11y carriers (AVR-070).
|
|
193
|
+
*/
|
|
194
|
+
export const Avatar = defineComponent({
|
|
195
|
+
name: 'BwAvatar',
|
|
196
|
+
inheritAttrs: false,
|
|
197
|
+
props: {
|
|
198
|
+
size: { type: String, default: 'md' },
|
|
199
|
+
shape: { type: String, default: 'circle' },
|
|
200
|
+
src: { type: String, default: undefined },
|
|
201
|
+
alt: { type: String, default: undefined },
|
|
202
|
+
initials: { type: String, default: undefined },
|
|
203
|
+
overflow: { type: Number, default: undefined },
|
|
204
|
+
},
|
|
205
|
+
setup(props, { attrs }) {
|
|
206
|
+
return () => {
|
|
207
|
+
const rootClass = (...parts) => cn('bw-avatar', `bw-avatar--size-${props.size}`, `bw-avatar--shape-${props.shape}`, ...parts, String(attrs.class || ''));
|
|
208
|
+
const ariaLabel = attrs['aria-label'] ??
|
|
209
|
+
attrs.ariaLabel;
|
|
210
|
+
if (props.src != null) {
|
|
211
|
+
const { class: _c, 'aria-label': _a, ariaLabel: _al, ...rest } = attrs;
|
|
212
|
+
// Vue SSR collapses alt="" to a boolean attribute; keep the empty
|
|
213
|
+
// string in the VNode so the DOM still treats the image as decorative.
|
|
214
|
+
const alt = props.alt ?? '';
|
|
215
|
+
return h('span', { ...rest, class: rootClass() }, [
|
|
216
|
+
h('img', {
|
|
217
|
+
class: 'bw-avatar__image',
|
|
218
|
+
src: props.src,
|
|
219
|
+
alt,
|
|
220
|
+
}),
|
|
221
|
+
]);
|
|
222
|
+
}
|
|
223
|
+
if (props.overflow !== undefined) {
|
|
224
|
+
const { class: _c, 'aria-label': _a, ariaLabel: _al, ...rest } = attrs;
|
|
225
|
+
return h('span', {
|
|
226
|
+
...rest,
|
|
227
|
+
class: rootClass('bw-avatar--overflow'),
|
|
228
|
+
...(ariaLabel ? { role: 'img', 'aria-label': ariaLabel } : {}),
|
|
229
|
+
}, [
|
|
230
|
+
h('span', {
|
|
231
|
+
class: 'bw-avatar__initials',
|
|
232
|
+
...(ariaLabel ? { 'aria-hidden': true } : {}),
|
|
233
|
+
}, `+${props.overflow}`),
|
|
234
|
+
]);
|
|
235
|
+
}
|
|
236
|
+
const { class: _c, 'aria-label': _a, ariaLabel: _al, ...rest } = attrs;
|
|
237
|
+
const label = ariaLabel ?? props.initials;
|
|
238
|
+
return h('span', {
|
|
239
|
+
...rest,
|
|
240
|
+
class: rootClass('bw-avatar--initials'),
|
|
241
|
+
role: 'img',
|
|
242
|
+
'aria-label': label,
|
|
243
|
+
}, [h('span', { class: 'bw-avatar__initials', 'aria-hidden': true }, props.initials)]);
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
/**
|
|
248
|
+
* Breadcrumbs (H02 / R57): trail of ancestors ending in the current page.
|
|
249
|
+
* Last crumb is always unlinked with aria-current="page", even if href is set.
|
|
250
|
+
* Empty items renders nothing so a host :empty rule can collapse the region.
|
|
251
|
+
*/
|
|
252
|
+
export const Breadcrumbs = defineComponent({
|
|
253
|
+
name: 'BwBreadcrumbs',
|
|
254
|
+
inheritAttrs: false,
|
|
255
|
+
props: {
|
|
256
|
+
items: { type: Array, required: true },
|
|
257
|
+
/** Accessible name for the nav. Override for locales; default matches the Django shell. */
|
|
258
|
+
label: { type: String, default: 'Breadcrumb' },
|
|
259
|
+
},
|
|
260
|
+
setup(props, { attrs }) {
|
|
261
|
+
return () => {
|
|
262
|
+
if (!props.items.length)
|
|
263
|
+
return null;
|
|
264
|
+
const { class: _class, ...rest } = attrs;
|
|
265
|
+
return h('nav', {
|
|
266
|
+
...rest,
|
|
267
|
+
class: cn('bw-breadcrumbs', String(attrs.class || '')),
|
|
268
|
+
'aria-label': props.label,
|
|
269
|
+
}, [
|
|
270
|
+
h('ol', { class: 'bw-breadcrumbs__list' }, props.items.map((item, i) => {
|
|
271
|
+
const last = i === props.items.length - 1;
|
|
272
|
+
let child;
|
|
273
|
+
if (item.href && !last) {
|
|
274
|
+
child = h('a', { class: 'bw-breadcrumbs__link', href: item.href }, item.label);
|
|
275
|
+
}
|
|
276
|
+
else if (last) {
|
|
277
|
+
child = h('span', { class: 'bw-breadcrumbs__current', 'aria-current': 'page' }, item.label);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
child = h('span', { class: 'bw-breadcrumbs__text' }, item.label);
|
|
281
|
+
}
|
|
282
|
+
return h('li', { key: `${item.label}-${i}`, class: 'bw-breadcrumbs__item' }, [child]);
|
|
283
|
+
})),
|
|
284
|
+
]);
|
|
285
|
+
};
|
|
286
|
+
},
|
|
287
|
+
});
|