@bwui/vue 0.1.14 → 0.1.16

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.
@@ -45,8 +45,8 @@ export declare const DatePicker: import("vue").DefineComponent<import("vue").Ext
45
45
  }>> & Readonly<{
46
46
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
47
47
  }>, {
48
- disabled: boolean;
49
48
  required: boolean;
49
+ disabled: boolean;
50
50
  modelValue: string;
51
51
  placeholder: string;
52
52
  panelLabel: string;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- export { Button, ButtonLink, Badge, Chip, Card, Alert, AlertTitle, AlertBody, Banner, Stack, Cluster, Grid, Inset, Container, Centre, VisuallyHidden, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Switch, CopyButton, Checkbox, Radio, Slider, TimeInput, DateTimeInput, InputGroup, SkipLink, ThemeToggle, Segmented, NumberStepper, Topbar, PageHeader, } from './primitives';
1
+ export { Button, ButtonLink, Badge, Chip, Card, CardHeader, CardTitle, CardDescription, CardBody, CardMedia, CardFooter, Alert, AlertTitle, AlertBody, Banner, Stack, Cluster, Grid, Inset, Container, Centre, VisuallyHidden, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Switch, CopyButton, Checkbox, Radio, Slider, TimeInput, DateTimeInput, InputGroup, SkipLink, ThemeToggle, Segmented, NumberStepper, Topbar, PageHeader, } from './primitives';
2
+ export type { ButtonVariant, ButtonSize, ButtonFit } from './primitives';
3
+ export type { CardSize, CardSurface, CardElevation, CardRadius, CardHeaderRecipe, CardFooterRecipe, CardMediaRecipe, } from './primitives';
2
4
  export { Combobox } from './combobox';
3
- export type { ComboboxOption } from './combobox';
5
+ export type { ComboboxOption, ComboboxSize } from './combobox';
6
+ export { Tabs, TabList, Tab, TabPanel, Avatar, Breadcrumbs, } from './chrome';
7
+ export type { TabsVariant, AvatarSize, AvatarShape, BreadcrumbItem, } from './chrome';
4
8
  export { DatePicker, DateRangePicker } from './date-picker';
5
9
  export { Homepage, Landing, ContactForm } from './pages';
6
10
  export { Modal } from './modal';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export { Button, ButtonLink, Badge, Chip, Card, Alert, AlertTitle, AlertBody, Banner, Stack, Cluster, Grid, Inset, Container, Centre, VisuallyHidden, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Switch, CopyButton, Checkbox, Radio, Slider, TimeInput, DateTimeInput, InputGroup, SkipLink, ThemeToggle, Segmented, NumberStepper, Topbar, PageHeader, } from './primitives';
1
+ export { Button, ButtonLink, Badge, Chip, Card, CardHeader, CardTitle, CardDescription, CardBody, CardMedia, CardFooter, Alert, AlertTitle, AlertBody, Banner, Stack, Cluster, Grid, Inset, Container, Centre, VisuallyHidden, Field, Form, FormActions, Label, Hint, FieldError, Input, Textarea, Select, Switch, CopyButton, Checkbox, Radio, Slider, TimeInput, DateTimeInput, InputGroup, SkipLink, ThemeToggle, Segmented, NumberStepper, Topbar, PageHeader, } from './primitives';
2
2
  export { Combobox } from './combobox';
3
+ export { Tabs, TabList, Tab, TabPanel, Avatar, Breadcrumbs, } from './chrome';
3
4
  export { DatePicker, DateRangePicker } from './date-picker';
4
5
  export { Homepage, Landing, ContactForm } from './pages';
5
6
  export { Modal } from './modal';
package/dist/pages.js CHANGED
@@ -29,7 +29,7 @@ export const Homepage = defineComponent({
29
29
  h('main', { id: 'main' }, [
30
30
  h('section', { class: 'bw-hero', style: { padding: 'var(--bw-space-12) var(--bw-space-6)' } }, [
31
31
  h(Stack, { style: { maxWidth: '40rem' } }, () => [
32
- h('h1', { class: 'bw-text-display-md' }, props.title),
32
+ h('h1', { class: 'bw-display-lg' }, props.title),
33
33
  h('p', { class: 'bw-body-lg', style: { color: 'var(--bw-color-fg-muted)' } }, props.description),
34
34
  h(Cluster, () => [
35
35
  h(ButtonLink, { href: '/gallery/forms', variant: 'primary', size: 'lg' }, () => 'Get started'),
@@ -72,7 +72,7 @@ export const Landing = defineComponent({
72
72
  ]),
73
73
  h('main', { id: 'main', style: { padding: 'var(--bw-space-12) var(--bw-space-6)' } }, [
74
74
  h(Stack, { class: 'bw-centre', style: { textAlign: 'center' } }, () => [
75
- h('h1', { class: 'bw-text-display-sm' }, props.title),
75
+ h('h1', { class: 'bw-heading-xl' }, props.title),
76
76
  h('p', { class: 'bw-body-lg', style: { color: 'var(--bw-color-fg-muted)' } }, props.description),
77
77
  h(Cluster, { style: { justifyContent: 'center' } }, () => [
78
78
  h(ButtonLink, { href: '/gallery/forms', variant: 'primary', size: 'lg' }, () => 'Start free'),
@@ -100,7 +100,7 @@ export const ContactForm = defineComponent({
100
100
  h(SkipLink),
101
101
  h('main', { id: 'main', style: { padding: 'var(--bw-space-10) var(--bw-space-6)', maxWidth: '32rem', marginInline: 'auto' } }, [
102
102
  h(Stack, () => [
103
- h('h1', { class: 'bw-text-title-lg' }, 'Contact'),
103
+ h('h1', { class: 'bw-heading-xl' }, 'Contact'),
104
104
  h(Form, { onSubmit: (e) => e.preventDefault() }, () => [
105
105
  h(Field, () => [
106
106
  h(Label, { for: 'bw-contact-name' }, () => 'Name'),
@@ -113,7 +113,13 @@ export const ContactForm = defineComponent({
113
113
  ]),
114
114
  h(Field, () => [
115
115
  h(Label, { for: 'bw-contact-topic' }, () => 'Topic'),
116
- h(Combobox, { id: 'bw-contact-topic', name: 'topic', options: props.topics, placeholder: 'Search topics' }),
116
+ h(Combobox, {
117
+ id: 'bw-contact-topic',
118
+ name: 'topic',
119
+ options: props.topics,
120
+ placeholder: 'Search topics',
121
+ ariaLabel: 'Topic',
122
+ }),
117
123
  ]),
118
124
  h(Field, () => [
119
125
  h(Label, { for: 'bw-contact-date' }, () => 'Preferred date'),
@@ -1,7 +1,19 @@
1
1
  import { type PropType } from 'vue';
2
- type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'solid';
3
- type ButtonSize = 'sm' | 'md' | 'lg';
2
+ /**
3
+ * Closed grammar (BTN-002). `solid` is the early-draft name of primary:
4
+ * DEPRECATED, accepted and rendered as `bw-btn--primary`. `outline` was never
5
+ * a shipped class and is not accepted.
6
+ */
7
+ export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'solid';
8
+ /** Five ADR-125 steps (BTN-003). Every step emits `bw-btn--size-<step>`. */
9
+ export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
+ /** Width behaviour (ADR-126 section 3). `fill` is not accepted with icon-only. */
11
+ export type ButtonFit = 'auto' | 'fill';
4
12
  export declare const Button: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
+ type: {
14
+ type: PropType<"button" | "submit" | "reset">;
15
+ default: string;
16
+ };
5
17
  variant: {
6
18
  type: PropType<ButtonVariant>;
7
19
  default: string;
@@ -10,13 +22,29 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
10
22
  type: PropType<ButtonSize>;
11
23
  default: string;
12
24
  };
13
- type: {
14
- type: PropType<"button" | "submit" | "reset">;
25
+ fit: {
26
+ type: PropType<ButtonFit>;
15
27
  default: string;
16
28
  };
29
+ loading: {
30
+ type: BooleanConstructor;
31
+ default: boolean;
32
+ };
33
+ iconOnly: {
34
+ type: BooleanConstructor;
35
+ default: boolean;
36
+ };
37
+ disabled: {
38
+ type: BooleanConstructor;
39
+ default: boolean;
40
+ };
17
41
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
18
42
  [key: string]: any;
19
43
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
44
+ type: {
45
+ type: PropType<"button" | "submit" | "reset">;
46
+ default: string;
47
+ };
20
48
  variant: {
21
49
  type: PropType<ButtonVariant>;
22
50
  default: string;
@@ -25,14 +53,30 @@ export declare const Button: import("vue").DefineComponent<import("vue").Extract
25
53
  type: PropType<ButtonSize>;
26
54
  default: string;
27
55
  };
28
- type: {
29
- type: PropType<"button" | "submit" | "reset">;
56
+ fit: {
57
+ type: PropType<ButtonFit>;
30
58
  default: string;
31
59
  };
60
+ loading: {
61
+ type: BooleanConstructor;
62
+ default: boolean;
63
+ };
64
+ iconOnly: {
65
+ type: BooleanConstructor;
66
+ default: boolean;
67
+ };
68
+ disabled: {
69
+ type: BooleanConstructor;
70
+ default: boolean;
71
+ };
32
72
  }>> & Readonly<{}>, {
33
73
  type: "button" | "reset" | "submit";
34
74
  variant: ButtonVariant;
35
75
  size: ButtonSize;
76
+ disabled: boolean;
77
+ loading: boolean;
78
+ fit: ButtonFit;
79
+ iconOnly: boolean;
36
80
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
37
81
  export declare const ButtonLink: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
38
82
  href: {
@@ -47,6 +91,22 @@ export declare const ButtonLink: import("vue").DefineComponent<import("vue").Ext
47
91
  type: PropType<ButtonSize>;
48
92
  default: string;
49
93
  };
94
+ fit: {
95
+ type: PropType<ButtonFit>;
96
+ default: string;
97
+ };
98
+ loading: {
99
+ type: BooleanConstructor;
100
+ default: boolean;
101
+ };
102
+ iconOnly: {
103
+ type: BooleanConstructor;
104
+ default: boolean;
105
+ };
106
+ disabled: {
107
+ type: BooleanConstructor;
108
+ default: boolean;
109
+ };
50
110
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
51
111
  [key: string]: any;
52
112
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -62,9 +122,29 @@ export declare const ButtonLink: import("vue").DefineComponent<import("vue").Ext
62
122
  type: PropType<ButtonSize>;
63
123
  default: string;
64
124
  };
125
+ fit: {
126
+ type: PropType<ButtonFit>;
127
+ default: string;
128
+ };
129
+ loading: {
130
+ type: BooleanConstructor;
131
+ default: boolean;
132
+ };
133
+ iconOnly: {
134
+ type: BooleanConstructor;
135
+ default: boolean;
136
+ };
137
+ disabled: {
138
+ type: BooleanConstructor;
139
+ default: boolean;
140
+ };
65
141
  }>> & Readonly<{}>, {
66
142
  variant: ButtonVariant;
67
143
  size: ButtonSize;
144
+ disabled: boolean;
145
+ loading: boolean;
146
+ fit: ButtonFit;
147
+ iconOnly: boolean;
68
148
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
69
149
  export type BadgeVariant = 'neutral' | 'outline' | 'success' | 'warning' | 'danger' | 'info' | 'default' | 'secondary';
70
150
  export type BadgeSize = 'sm' | 'md';
@@ -150,8 +230,8 @@ export declare const Chip: import("vue").DefineComponent<import("vue").ExtractPr
150
230
  }>> & Readonly<{
151
231
  onDismiss?: ((...args: any[]) => any) | undefined;
152
232
  }>, {
153
- toggle: boolean;
154
233
  variant: ChipVariant;
234
+ toggle: boolean;
155
235
  size: ChipSize;
156
236
  href: string;
157
237
  selected: boolean;
@@ -161,6 +241,9 @@ export type CardSize = 'sm' | 'md' | 'lg';
161
241
  export type CardSurface = 'default' | 'raised' | 'tint' | 'inverse' | 'muted';
162
242
  export type CardElevation = '0' | '1' | '2' | '3';
163
243
  export type CardRadius = 'default' | 'sm' | 'lg' | 'xl' | 'none';
244
+ export type CardHeaderRecipe = 'plain' | 'bordered' | 'muted' | 'inverse' | 'accent';
245
+ export type CardFooterRecipe = 'plain' | 'muted' | 'actions';
246
+ export type CardMediaRecipe = 'bleed' | 'inset' | 'icon';
164
247
  export declare const Card: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
165
248
  size: {
166
249
  type: PropType<CardSize>;
@@ -190,6 +273,14 @@ export declare const Card: import("vue").DefineComponent<import("vue").ExtractPr
190
273
  type: StringConstructor;
191
274
  default: undefined;
192
275
  };
276
+ target: {
277
+ type: StringConstructor;
278
+ default: undefined;
279
+ };
280
+ rel: {
281
+ type: StringConstructor;
282
+ default: undefined;
283
+ };
193
284
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
194
285
  [key: string]: any;
195
286
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
@@ -221,6 +312,14 @@ export declare const Card: import("vue").DefineComponent<import("vue").ExtractPr
221
312
  type: StringConstructor;
222
313
  default: undefined;
223
314
  };
315
+ target: {
316
+ type: StringConstructor;
317
+ default: undefined;
318
+ };
319
+ rel: {
320
+ type: StringConstructor;
321
+ default: undefined;
322
+ };
224
323
  }>> & Readonly<{}>, {
225
324
  size: CardSize;
226
325
  href: string;
@@ -229,6 +328,66 @@ export declare const Card: import("vue").DefineComponent<import("vue").ExtractPr
229
328
  elevation: CardElevation;
230
329
  radius: CardRadius;
231
330
  interactive: boolean;
331
+ target: string;
332
+ rel: string;
333
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
334
+ export declare const CardHeader: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
335
+ recipe: {
336
+ type: PropType<CardHeaderRecipe>;
337
+ default: undefined;
338
+ };
339
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
340
+ [key: string]: any;
341
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
342
+ recipe: {
343
+ type: PropType<CardHeaderRecipe>;
344
+ default: undefined;
345
+ };
346
+ }>> & Readonly<{}>, {
347
+ recipe: CardHeaderRecipe;
348
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
349
+ /**
350
+ * The card heading is an `h3` (a card usually sits under a section `h2`).
351
+ * Django's `_card.html` emits `h2`; the difference is GAP-CRD-3.
352
+ */
353
+ export declare const CardTitle: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
354
+ [key: string]: any;
355
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
356
+ export declare const CardDescription: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
357
+ [key: string]: any;
358
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
359
+ export declare const CardBody: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
360
+ [key: string]: any;
361
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
362
+ export declare const CardMedia: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
363
+ recipe: {
364
+ type: PropType<CardMediaRecipe>;
365
+ default: undefined;
366
+ };
367
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
368
+ [key: string]: any;
369
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
370
+ recipe: {
371
+ type: PropType<CardMediaRecipe>;
372
+ default: undefined;
373
+ };
374
+ }>> & Readonly<{}>, {
375
+ recipe: CardMediaRecipe;
376
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
377
+ export declare const CardFooter: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
378
+ recipe: {
379
+ type: PropType<CardFooterRecipe>;
380
+ default: undefined;
381
+ };
382
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
383
+ [key: string]: any;
384
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
385
+ recipe: {
386
+ type: PropType<CardFooterRecipe>;
387
+ default: undefined;
388
+ };
389
+ }>> & Readonly<{}>, {
390
+ recipe: CardFooterRecipe;
232
391
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
233
392
  export declare const Alert: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
234
393
  variant: {
@@ -606,8 +765,8 @@ export declare const Segmented: import("vue").DefineComponent<import("vue").Extr
606
765
  }>> & Readonly<{
607
766
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
608
767
  }>, {
609
- disabled: boolean;
610
768
  size: SegmentedSize;
769
+ disabled: boolean;
611
770
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
612
771
  export type NumberStepperSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
613
772
  /**
@@ -712,17 +871,17 @@ export declare const NumberStepper: import("vue").DefineComponent<import("vue").
712
871
  }>> & Readonly<{
713
872
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
714
873
  }>, {
715
- disabled: boolean;
716
874
  value: number | undefined;
717
- 'aria-label': string | undefined;
875
+ 'aria-labelledby': string | undefined;
718
876
  size: NumberStepperSize;
877
+ 'aria-label': string | undefined;
878
+ disabled: boolean;
879
+ readOnly: boolean;
719
880
  min: number | undefined;
720
881
  max: number | undefined;
721
882
  step: number;
722
- readOnly: boolean;
723
883
  decrementLabel: string;
724
884
  incrementLabel: string;
725
- 'aria-labelledby': string | undefined;
726
885
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
727
886
  export declare const Topbar: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
728
887
  [key: string]: any;
@@ -766,9 +925,9 @@ export declare const PageHeader: import("vue").DefineComponent<import("vue").Ext
766
925
  };
767
926
  }>> & Readonly<{}>, {
768
927
  title: undefined;
928
+ loading: boolean;
769
929
  surface: PageHeaderSurface;
770
930
  description: undefined;
771
- loading: boolean;
772
931
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
773
932
  type DescriptionListLayout = 'stacked' | 'inline';
774
933
  /**
@@ -878,10 +1037,10 @@ export declare const CopyButton: import("vue").DefineComponent<import("vue").Ext
878
1037
  }>> & Readonly<{
879
1038
  onCopy?: ((...args: any[]) => any) | undefined;
880
1039
  }>, {
881
- disabled: boolean;
882
- label: string;
883
1040
  value: string;
1041
+ label: string;
884
1042
  size: InputSize;
1043
+ disabled: boolean;
885
1044
  target: string;
886
1045
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
887
1046
  export {};
@@ -1,34 +1,119 @@
1
1
  let bwCopySeq = 0;
2
2
  import { defineComponent, h, ref } from 'vue';
3
3
  import { cn } from './cn';
4
+ function buttonClasses(variant, size, iconOnly, fit, className) {
5
+ return cn('bw-btn', `bw-btn--${variant === 'solid' ? 'primary' : variant}`, `bw-btn--size-${size}`, iconOnly && 'bw-btn--icon-only', fit === 'fill' && 'bw-btn--fit-fill', className);
6
+ }
7
+ /** ICO-008: an icon-only control with no accessible name is a render error. */
8
+ function assertNamed(iconOnly, props) {
9
+ if (!iconOnly)
10
+ return;
11
+ const label = typeof props['aria-label'] === 'string' ? props['aria-label'].trim() : '';
12
+ if (!label && !props['aria-labelledby']) {
13
+ throw new Error('Button iconOnly requires aria-label (or aria-labelledby): an icon-only ' +
14
+ 'button with no accessible name is a WCAG 4.1.2 failure (ICO-008).');
15
+ }
16
+ }
17
+ /** ADR-060 section 3: no silent no-op. An icon-only control is a square, so `fill` has no meaning. */
18
+ function assertFit(iconOnly, fit) {
19
+ if (fit !== 'auto' && fit !== 'fill') {
20
+ throw new Error(`Button fit must be "auto" or "fill", got ${JSON.stringify(fit)}.`);
21
+ }
22
+ if (iconOnly && fit === 'fill') {
23
+ throw new Error('Button fit="fill" cannot be combined with iconOnly: an icon-only button is a square at its ' +
24
+ 'size step, so fill would do nothing (ADR-060 section 3).');
25
+ }
26
+ }
27
+ /** Same glyph as the Django spinner partial: aria-hidden; the host carries aria-busy. */
28
+ function ButtonSpinner() {
29
+ return h('svg', {
30
+ class: 'bw-spinner',
31
+ viewBox: '0 0 24 24',
32
+ fill: 'none',
33
+ stroke: 'currentColor',
34
+ 'stroke-width': 2,
35
+ 'stroke-linecap': 'round',
36
+ 'aria-hidden': 'true',
37
+ }, [h('path', { d: 'M21 12a9 9 0 1 1-6.219-8.56' })]);
38
+ }
39
+ function buttonInner(loading, iconOnly, children) {
40
+ if (!loading)
41
+ return children;
42
+ return iconOnly ? [ButtonSpinner()] : [ButtonSpinner(), children];
43
+ }
44
+ const buttonSharedProps = {
45
+ variant: { type: String, default: 'primary' },
46
+ size: { type: String, default: 'md' },
47
+ fit: { type: String, default: 'auto' },
48
+ loading: { type: Boolean, default: false },
49
+ iconOnly: { type: Boolean, default: false },
50
+ disabled: { type: Boolean, default: false },
51
+ };
4
52
  export const Button = defineComponent({
5
53
  name: 'BwButton',
54
+ inheritAttrs: false,
6
55
  props: {
7
- variant: { type: String, default: 'primary' },
8
- size: { type: String, default: 'md' },
56
+ ...buttonSharedProps,
9
57
  type: { type: String, default: 'button' },
10
58
  },
11
59
  setup(props, { slots, attrs }) {
12
- return () => h('button', {
13
- ...attrs,
14
- type: props.type,
15
- class: cn('bw-btn', `bw-btn--${props.variant}`, props.size !== 'md' && `bw-btn--size-${props.size}`, String(attrs.class || '')),
16
- }, slots.default?.());
60
+ return () => {
61
+ const { class: cls, ...rest } = attrs;
62
+ assertNamed(props.iconOnly, rest);
63
+ assertFit(props.iconOnly, props.fit);
64
+ return h('button', {
65
+ ...rest,
66
+ type: props.type,
67
+ class: buttonClasses(props.variant, props.size, props.iconOnly, props.fit, String(cls || '')),
68
+ disabled: props.disabled || props.loading || undefined,
69
+ 'aria-busy': props.loading ? true : undefined,
70
+ }, buttonInner(props.loading, props.iconOnly, slots.default?.()));
71
+ };
17
72
  },
18
73
  });
19
74
  export const ButtonLink = defineComponent({
20
75
  name: 'BwButtonLink',
76
+ inheritAttrs: false,
21
77
  props: {
78
+ ...buttonSharedProps,
22
79
  href: { type: String, required: true },
23
- variant: { type: String, default: 'primary' },
24
- size: { type: String, default: 'md' },
25
80
  },
26
81
  setup(props, { slots, attrs }) {
27
- return () => h('a', {
28
- ...attrs,
29
- href: props.href,
30
- class: cn('bw-btn', `bw-btn--${props.variant}`, props.size !== 'md' && `bw-btn--size-${props.size}`, String(attrs.class || '')),
31
- }, slots.default?.());
82
+ return () => {
83
+ const { class: cls, ...rest } = attrs;
84
+ assertNamed(props.iconOnly, rest);
85
+ assertFit(props.iconOnly, props.fit);
86
+ const classes = buttonClasses(props.variant, props.size, props.iconOnly, props.fit, String(cls || ''));
87
+ if (props.disabled || props.loading) {
88
+ // Not operable: no href and no handler (BTN-001). Disabled takes the
89
+ // flat colours; busy keeps the variant colours (BTN-031).
90
+ const inert = { ...rest };
91
+ for (const key of [
92
+ 'onClick',
93
+ 'onAuxclick',
94
+ 'onAuxClick',
95
+ 'target',
96
+ 'rel',
97
+ 'download',
98
+ 'hreflang',
99
+ 'hrefLang',
100
+ 'ping',
101
+ ]) {
102
+ delete inert[key];
103
+ }
104
+ return h('span', {
105
+ ...inert,
106
+ class: cn(classes, props.disabled && !props.loading && 'bw-btn--disabled'),
107
+ 'aria-disabled': 'true',
108
+ 'aria-busy': props.loading ? true : undefined,
109
+ }, buttonInner(props.loading, props.iconOnly, slots.default?.()));
110
+ }
111
+ return h('a', {
112
+ ...rest,
113
+ class: classes,
114
+ href: props.href,
115
+ }, slots.default?.());
116
+ };
32
117
  },
33
118
  });
34
119
  function resolveBadgeVariant(variant) {
@@ -103,6 +188,8 @@ export const Chip = defineComponent({
103
188
  // Card (docs/components/card.md): the same modifier grammar as React. `md` is
104
189
  // the base inset and emits a class only when asked for; `href` renders an
105
190
  // anchor and implies interactive; `bordered` is the APP-002 flat hairline mode.
191
+ // Region primitives (GAP-CRD-4) match React `CardHeader` / Body / Footer /
192
+ // Media / Title / Description and their recipe modifiers.
106
193
  export const Card = defineComponent({
107
194
  name: 'BwCard',
108
195
  inheritAttrs: false,
@@ -114,15 +201,91 @@ export const Card = defineComponent({
114
201
  radius: { type: String, default: undefined },
115
202
  interactive: { type: Boolean, default: false },
116
203
  href: { type: String, default: undefined },
204
+ target: { type: String, default: undefined },
205
+ rel: { type: String, default: undefined },
117
206
  },
118
207
  setup(props, { slots, attrs }) {
119
208
  return () => {
120
209
  const linked = props.href !== undefined;
121
210
  const classes = cn('bw-card', (props.interactive || linked) && 'bw-card--interactive', props.bordered && 'bw-card--bordered', props.size && `bw-card--size-${props.size}`, props.radius && props.radius !== 'default' && props.radius !== 'lg' && `bw-card--radius-${props.radius}`, props.surface && props.surface !== 'default' && `bw-card--surface-${props.surface}`, props.elevation && props.elevation !== '1' && `bw-card--elevation-${props.elevation}`, String(attrs.class || ''));
122
- return h(linked ? 'a' : 'div', { ...attrs, class: classes, ...(linked ? { href: props.href } : {}) }, slots.default?.());
211
+ return h(linked ? 'a' : 'div', {
212
+ ...attrs,
213
+ class: classes,
214
+ ...(linked
215
+ ? {
216
+ href: props.href,
217
+ ...(props.target !== undefined ? { target: props.target } : {}),
218
+ ...(props.rel !== undefined ? { rel: props.rel } : {}),
219
+ }
220
+ : {}),
221
+ }, slots.default?.());
123
222
  };
124
223
  },
125
224
  });
225
+ export const CardHeader = defineComponent({
226
+ name: 'BwCardHeader',
227
+ inheritAttrs: false,
228
+ props: {
229
+ recipe: { type: String, default: undefined },
230
+ },
231
+ setup(props, { slots, attrs }) {
232
+ return () => h('div', {
233
+ ...attrs,
234
+ class: cn('bw-card__header', props.recipe && props.recipe !== 'plain' && `bw-card__header--${props.recipe}`, String(attrs.class || '')),
235
+ }, slots.default?.());
236
+ },
237
+ });
238
+ /**
239
+ * The card heading is an `h3` (a card usually sits under a section `h2`).
240
+ * Django's `_card.html` emits `h2`; the difference is GAP-CRD-3.
241
+ */
242
+ export const CardTitle = defineComponent({
243
+ name: 'BwCardTitle',
244
+ inheritAttrs: false,
245
+ setup(_props, { slots, attrs }) {
246
+ return () => h('h3', { ...attrs, class: cn('bw-card__title', String(attrs.class || '')) }, slots.default?.());
247
+ },
248
+ });
249
+ export const CardDescription = defineComponent({
250
+ name: 'BwCardDescription',
251
+ inheritAttrs: false,
252
+ setup(_props, { slots, attrs }) {
253
+ return () => h('p', { ...attrs, class: cn('bw-card__description', String(attrs.class || '')) }, slots.default?.());
254
+ },
255
+ });
256
+ export const CardBody = defineComponent({
257
+ name: 'BwCardBody',
258
+ inheritAttrs: false,
259
+ setup(_props, { slots, attrs }) {
260
+ return () => h('div', { ...attrs, class: cn('bw-card__body', String(attrs.class || '')) }, slots.default?.());
261
+ },
262
+ });
263
+ export const CardMedia = defineComponent({
264
+ name: 'BwCardMedia',
265
+ inheritAttrs: false,
266
+ props: {
267
+ recipe: { type: String, default: undefined },
268
+ },
269
+ setup(props, { slots, attrs }) {
270
+ return () => h('div', {
271
+ ...attrs,
272
+ class: cn('bw-card__media', props.recipe && `bw-card__media--${props.recipe}`, String(attrs.class || '')),
273
+ }, slots.default?.());
274
+ },
275
+ });
276
+ export const CardFooter = defineComponent({
277
+ name: 'BwCardFooter',
278
+ inheritAttrs: false,
279
+ props: {
280
+ recipe: { type: String, default: undefined },
281
+ },
282
+ setup(props, { slots, attrs }) {
283
+ return () => h('div', {
284
+ ...attrs,
285
+ class: cn('bw-card__footer', props.recipe && props.recipe !== 'plain' && `bw-card__footer--${props.recipe}`, String(attrs.class || '')),
286
+ }, slots.default?.());
287
+ },
288
+ });
126
289
  export const Alert = defineComponent({
127
290
  name: 'BwAlert',
128
291
  props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bwui/vue",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Vue 3 adapter for Brickwork: typed components bound to the Brickwork token substrate and bw-* class contract.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,11 +25,12 @@
25
25
  "vue": "^3.4.0"
26
26
  },
27
27
  "dependencies": {
28
- "@bwui/css": "0.1.14",
29
- "@bwui/tokens": "0.1.14"
28
+ "@bwui/css": "0.1.16",
29
+ "@bwui/tokens": "0.1.16"
30
30
  },
31
31
  "devDependencies": {
32
32
  "typescript": "^5",
33
+ "vitest": "^4.1.12",
33
34
  "vue": "^3.5.0"
34
35
  },
35
36
  "repository": {
@@ -40,6 +41,7 @@
40
41
  "access": "public"
41
42
  },
42
43
  "scripts": {
43
- "build": "tsc -p tsconfig.json"
44
+ "build": "tsc -p tsconfig.json",
45
+ "test": "vitest run"
44
46
  }
45
47
  }