@ctrliq/quantic-components 1.82.0 → 1.84.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/action-group/action-group.component.d.ts +13 -0
- package/dist/action-group/action-group.component.js +63 -0
- package/dist/action-group/index.d.ts +1 -0
- package/dist/action-group/index.js +1 -0
- package/dist/action-group/index.stories.d.ts +25 -0
- package/dist/action-group/index.stories.js +59 -0
- package/dist/astro.d.ts +6 -1
- package/dist/astro.js +6 -1
- package/dist/astro.js.map +1 -1
- package/dist/badge/badge-group.component.d.ts +13 -0
- package/dist/badge/badge-group.component.js +62 -0
- package/dist/badge/badge-group.stories.d.ts +41 -0
- package/dist/badge/badge-group.stories.js +62 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +1 -0
- package/dist/button/index.js +1 -1
- package/dist/button-bar/button-bar-item.d.ts +14 -0
- package/dist/button-bar/button-bar-item.js +202 -0
- package/dist/button-bar/button-bar.d.ts +20 -0
- package/dist/button-bar/button-bar.js +127 -0
- package/dist/button-bar/index.constants.d.ts +6 -0
- package/dist/button-bar/index.constants.js +5 -0
- package/dist/button-bar/index.context.d.ts +4 -0
- package/dist/button-bar/index.context.js +2 -0
- package/dist/button-bar/index.d.ts +3 -0
- package/dist/button-bar/index.js +3 -0
- package/dist/{types/button-group → button-bar}/index.stories.d.ts +2 -2
- package/dist/button-bar/index.stories.js +107 -0
- package/dist/button-bar/index.utils.d.ts +6 -0
- package/dist/button-bar/index.utils.js +31 -0
- package/dist/button-bar/index.utils.test.d.ts +1 -0
- package/dist/button-bar/index.utils.test.js +53 -0
- package/dist/button-group/button-group-item.d.ts +6 -8
- package/dist/button-group/button-group-item.js +11 -167
- package/dist/button-group/button-group.d.ts +9 -7
- package/dist/button-group/button-group.js +16 -58
- package/dist/button-group/index.constants.d.ts +4 -1
- package/dist/button-group/index.constants.js +3 -5
- package/dist/dialog/dialog-actions.js +11 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/meta/index.js +10 -0
- package/dist/meta/index.js.map +1 -1
- package/dist/meta/serialize.js +1 -0
- package/dist/meta.json +199 -24
- package/dist/pagination/pagination.component.js +15 -15
- package/dist/quantic-components.js +395 -86
- package/dist/quantic-components.js.map +1 -1
- package/dist/quantic-components.min.js +215 -155
- package/dist/quantic-components.min.js.map +1 -1
- package/dist/register.js.map +1 -1
- package/dist/shared/meta.types.d.ts +4 -0
- package/dist/tabs/index.stories.js +1 -1
- package/dist/tag/index.d.ts +1 -0
- package/dist/tag/index.js +1 -0
- package/dist/tag/tag-group.component.d.ts +13 -0
- package/dist/tag/tag-group.component.js +62 -0
- package/dist/tag/tag-group.stories.d.ts +34 -0
- package/dist/tag/tag-group.stories.js +65 -0
- package/dist/types/action-group/action-group.component.d.ts +13 -0
- package/dist/types/action-group/index.d.ts +1 -0
- package/dist/types/action-group/index.stories.d.ts +25 -0
- package/dist/types/astro.d.ts +6 -1
- package/dist/types/badge/badge-group.component.d.ts +13 -0
- package/dist/types/badge/badge-group.stories.d.ts +41 -0
- package/dist/types/badge/index.d.ts +1 -0
- package/dist/types/button-bar/button-bar-item.d.ts +14 -0
- package/dist/types/button-bar/button-bar.d.ts +20 -0
- package/dist/types/button-bar/index.constants.d.ts +6 -0
- package/dist/types/button-bar/index.context.d.ts +4 -0
- package/dist/types/button-bar/index.d.ts +3 -0
- package/dist/{button-group → types/button-bar}/index.stories.d.ts +2 -2
- package/dist/types/button-bar/index.utils.d.ts +6 -0
- package/dist/types/button-bar/index.utils.test.d.ts +1 -0
- package/dist/types/button-group/button-group-item.d.ts +6 -8
- package/dist/types/button-group/button-group.d.ts +9 -7
- package/dist/types/button-group/index.constants.d.ts +4 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/shared/meta.types.d.ts +4 -0
- package/dist/types/tag/index.d.ts +1 -0
- package/dist/types/tag/tag-group.component.d.ts +13 -0
- package/dist/types/tag/tag-group.stories.d.ts +34 -0
- package/package.json +4 -3
- package/dist/button-group/index.context.d.ts +0 -4
- package/dist/button-group/index.context.js +0 -2
- package/dist/button-group/index.stories.js +0 -107
- package/dist/types/button-group/index.context.d.ts +0 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QuanticElement } from '../shared/quantic-element';
|
|
2
|
+
import type { ComponentMeta } from '../shared/meta.types';
|
|
3
|
+
export declare class BadgeGroup extends QuanticElement {
|
|
4
|
+
static meta: ComponentMeta;
|
|
5
|
+
ariaLabel: string | null;
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
render(): import("lit").TemplateResult<1>;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'quantic-badge-group': BadgeGroup;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html } from 'lit';
|
|
8
|
+
import { QuanticElement, quanticElement } from '../shared/quantic-element';
|
|
9
|
+
import { prop } from '../shared/component-meta.decorators';
|
|
10
|
+
let BadgeGroup = class BadgeGroup extends QuanticElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.ariaLabel = null;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return html `
|
|
17
|
+
<div class="group" role="group" aria-label=${this.ariaLabel ?? 'Badges'}>
|
|
18
|
+
<slot></slot>
|
|
19
|
+
</div>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
BadgeGroup.meta = {
|
|
24
|
+
tag: 'quantic-badge-group',
|
|
25
|
+
description: 'A run of quantic-badge or quantic-status-badge sharing one accessible name and a consistent gap. ' +
|
|
26
|
+
'Wraps across lines, and each badge keeps its own size. Gap: --quantic-component-badge-group-gap. ' +
|
|
27
|
+
'Use quantic-tag-group for tags.',
|
|
28
|
+
category: 'display',
|
|
29
|
+
slots: {
|
|
30
|
+
'': {
|
|
31
|
+
description: 'quantic-badge or quantic-status-badge elements.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
subComponents: ['quantic-badge', 'quantic-status-badge'],
|
|
35
|
+
relatedTo: ['quantic-badge', 'quantic-tag-group'],
|
|
36
|
+
};
|
|
37
|
+
BadgeGroup.styles = css `
|
|
38
|
+
:host {
|
|
39
|
+
display: block;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.group {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: var(
|
|
47
|
+
--quantic-component-badge-group-gap,
|
|
48
|
+
var(--quantic-spacing-1)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
__decorate([
|
|
53
|
+
prop({
|
|
54
|
+
type: 'string',
|
|
55
|
+
attribute: 'aria-label',
|
|
56
|
+
description: 'Accessible name for the group.',
|
|
57
|
+
})
|
|
58
|
+
], BadgeGroup.prototype, "ariaLabel", void 0);
|
|
59
|
+
BadgeGroup = __decorate([
|
|
60
|
+
quanticElement('quantic-badge-group')
|
|
61
|
+
], BadgeGroup);
|
|
62
|
+
export { BadgeGroup };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BadgeColor, BadgeSize } from './index.constants';
|
|
2
|
+
interface Args {
|
|
3
|
+
label: string | undefined;
|
|
4
|
+
size: BadgeSize;
|
|
5
|
+
color: BadgeColor;
|
|
6
|
+
badges: string[];
|
|
7
|
+
}
|
|
8
|
+
declare const _default: {
|
|
9
|
+
title: string;
|
|
10
|
+
component: string;
|
|
11
|
+
tags: string[];
|
|
12
|
+
argTypes: {
|
|
13
|
+
label: {
|
|
14
|
+
control: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
size: {
|
|
18
|
+
control: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
options: ("xs" | "sm" | "md" | "lg")[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
color: {
|
|
25
|
+
control: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
options: ("success" | "error" | "warning" | "gray" | "brand" | "gray-blue" | "blue-light" | "blue" | "indigo" | "purple" | "pink" | "orange")[];
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
badges: {
|
|
32
|
+
control: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export default _default;
|
|
38
|
+
export declare const Default: import("../shared/story").StoryObject<Args>;
|
|
39
|
+
export declare const WithAccessibleName: import("../shared/story").StoryObject<Args>;
|
|
40
|
+
export declare const Wrapping: import("../shared/story").StoryObject<Args>;
|
|
41
|
+
export declare const StatusBadges: import("../shared/story").StoryObject<object>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { story } from '../shared/story';
|
|
2
|
+
import { BadgeColor, BadgeSize } from './index.constants';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/Display/Badge/BadgeGroup',
|
|
5
|
+
component: 'quantic-badge-group',
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
label: {
|
|
9
|
+
control: 'text',
|
|
10
|
+
description: 'Accessible name for the group. Defaults to "Badges".',
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
control: { type: 'select' },
|
|
14
|
+
options: Object.values(BadgeSize),
|
|
15
|
+
description: 'Size set on each badge. The group does not own sizing.',
|
|
16
|
+
},
|
|
17
|
+
color: {
|
|
18
|
+
control: { type: 'select' },
|
|
19
|
+
options: Object.values(BadgeColor),
|
|
20
|
+
description: 'Color set on each badge',
|
|
21
|
+
},
|
|
22
|
+
badges: {
|
|
23
|
+
control: 'object',
|
|
24
|
+
description: 'Badge labels',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const base = story({
|
|
29
|
+
args: {
|
|
30
|
+
label: undefined,
|
|
31
|
+
size: BadgeSize.Small,
|
|
32
|
+
color: BadgeColor.Gray,
|
|
33
|
+
badges: ['Backgrounds', 'Email signatures', 'Headers'],
|
|
34
|
+
},
|
|
35
|
+
}).render(({ label, size, color, badges }) => {
|
|
36
|
+
const labelAttr = label === undefined ? '' : `aria-label="${label}"`;
|
|
37
|
+
const items = badges
|
|
38
|
+
.map((badge) => `<quantic-badge color="${color}" size="${size}">${badge}</quantic-badge>`)
|
|
39
|
+
.join('');
|
|
40
|
+
return `<quantic-badge-group ${labelAttr}>${items}</quantic-badge-group>`;
|
|
41
|
+
});
|
|
42
|
+
export const Default = base;
|
|
43
|
+
export const WithAccessibleName = base.override({ label: 'Asset types' });
|
|
44
|
+
// No gap, axis or wrap props on purpose: the rhythm is a decision, not a knob.
|
|
45
|
+
export const Wrapping = base.override({
|
|
46
|
+
badges: [
|
|
47
|
+
'Backgrounds',
|
|
48
|
+
'Email signatures',
|
|
49
|
+
'Headers',
|
|
50
|
+
'Social graphics',
|
|
51
|
+
'Slide templates',
|
|
52
|
+
'Press kits',
|
|
53
|
+
'Advisory cards',
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
export const StatusBadges = story().render(() => `
|
|
57
|
+
<quantic-badge-group aria-label="Service status">
|
|
58
|
+
<quantic-status-badge color="success" size="sm">Running</quantic-status-badge>
|
|
59
|
+
<quantic-status-badge color="warning" size="sm">Degraded</quantic-status-badge>
|
|
60
|
+
<quantic-status-badge color="error" size="sm">Offline</quantic-status-badge>
|
|
61
|
+
</quantic-badge-group>
|
|
62
|
+
`);
|
package/dist/badge/index.d.ts
CHANGED
package/dist/badge/index.js
CHANGED
package/dist/button/index.js
CHANGED
|
@@ -115,7 +115,7 @@ Button.meta = {
|
|
|
115
115
|
'Supports icon-only mode and polymorphic rendering as an <a> or <span>. ' +
|
|
116
116
|
'Prefer over quantic-icon-label when the element needs to be interactive.',
|
|
117
117
|
category: 'action',
|
|
118
|
-
relatedTo: ['quantic-button-
|
|
118
|
+
relatedTo: ['quantic-button-bar', 'quantic-icon-label'],
|
|
119
119
|
};
|
|
120
120
|
Button.formAssociated = true;
|
|
121
121
|
Button.styles = css `
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ButtonBarSize } from './index.constants';
|
|
2
|
+
import { QuanticElement } from '../shared/quantic-element';
|
|
3
|
+
import type { ComponentMeta } from '../shared/meta.types';
|
|
4
|
+
export declare class ButtonBarItem extends QuanticElement {
|
|
5
|
+
static meta: ComponentMeta;
|
|
6
|
+
size?: ButtonBarSize;
|
|
7
|
+
tabbable: boolean;
|
|
8
|
+
private innerButton?;
|
|
9
|
+
focus(options?: FocusOptions): void;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
active: boolean;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
render(): import("lit").TemplateResult<1>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html } from 'lit';
|
|
8
|
+
import { query, state } from 'lit/decorators.js';
|
|
9
|
+
import { consume } from '@lit/context';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
+
import { sizeContext } from './index.context';
|
|
12
|
+
import { quanticElement, QuanticElement } from '../shared/quantic-element';
|
|
13
|
+
import { prop } from '../shared/component-meta.decorators';
|
|
14
|
+
let ButtonBarItem = class ButtonBarItem extends QuanticElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.tabbable = true;
|
|
18
|
+
this.disabled = false;
|
|
19
|
+
this.active = false;
|
|
20
|
+
}
|
|
21
|
+
focus(options) {
|
|
22
|
+
this.innerButton?.focus(options);
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
const classes = classMap({
|
|
26
|
+
main: true,
|
|
27
|
+
[`size--${this.size}`]: !!this.size,
|
|
28
|
+
[`is-active`]: this.active,
|
|
29
|
+
});
|
|
30
|
+
return html `
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
class=${classes}
|
|
34
|
+
tabindex=${this.disabled || !this.tabbable ? -1 : 0}
|
|
35
|
+
?disabled=${this.disabled}
|
|
36
|
+
aria-pressed=${this.active ? 'true' : 'false'}
|
|
37
|
+
>
|
|
38
|
+
<div class="content">
|
|
39
|
+
<slot></slot>
|
|
40
|
+
</div>
|
|
41
|
+
</button>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
ButtonBarItem.meta = {
|
|
46
|
+
tag: 'quantic-button-bar-item',
|
|
47
|
+
description: 'Single segment within a quantic-button-bar. ' +
|
|
48
|
+
'Renders as a native button with shared sizing from the parent context and a pressed state via active.',
|
|
49
|
+
category: 'action',
|
|
50
|
+
slots: { '': { description: 'Button label or icon content.' } },
|
|
51
|
+
relatedTo: ['quantic-button-bar', 'quantic-button'],
|
|
52
|
+
};
|
|
53
|
+
ButtonBarItem.styles = css `
|
|
54
|
+
:host {
|
|
55
|
+
display: inline-flex;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([disabled]) {
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
opacity: 0.5;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.main {
|
|
64
|
+
position: relative;
|
|
65
|
+
appearance: none;
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
border: none;
|
|
68
|
+
border-right: 1px solid var(--quantic-border-primary);
|
|
69
|
+
font-family: var(--quantic-font-family-body);
|
|
70
|
+
font-weight: var(--quantic-font-weight-semibold);
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
text-decoration: none;
|
|
73
|
+
text-align: center;
|
|
74
|
+
display: block;
|
|
75
|
+
width: 100%;
|
|
76
|
+
color: var(--quantic-text-primary);
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
outline: none;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
padding: var(
|
|
81
|
+
--quantic-component-button-bar-padding-block,
|
|
82
|
+
var(--quantic-internal-button-bar-item-padding-block)
|
|
83
|
+
)
|
|
84
|
+
var(
|
|
85
|
+
--quantic-component-button-bar-padding-inline,
|
|
86
|
+
var(--quantic-internal-button-bar-item-padding-inline)
|
|
87
|
+
);
|
|
88
|
+
font-size: var(
|
|
89
|
+
--quantic-component-button-bar-font-size,
|
|
90
|
+
var(--quantic-internal-button-bar-item-font-size)
|
|
91
|
+
);
|
|
92
|
+
line-height: var(
|
|
93
|
+
--quantic-component-button-bar-line-height,
|
|
94
|
+
var(--quantic-internal-button-bar-item-line-height)
|
|
95
|
+
);
|
|
96
|
+
transition:
|
|
97
|
+
background-color 0.2s ease-in-out,
|
|
98
|
+
color 0.2s ease-in-out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:host(:last-of-type) .main {
|
|
102
|
+
border-right: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.main::before {
|
|
106
|
+
content: '';
|
|
107
|
+
display: block;
|
|
108
|
+
position: absolute;
|
|
109
|
+
inset: 0;
|
|
110
|
+
border-radius: var(--quantic-radius-sm);
|
|
111
|
+
border: 2px solid var(--quantic-focus-ring);
|
|
112
|
+
transition: all 0.2s ease-in-out;
|
|
113
|
+
opacity: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.main:focus-visible::before {
|
|
117
|
+
inset: -4px;
|
|
118
|
+
opacity: 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.main:hover {
|
|
122
|
+
background-color: var(--quantic-bg-secondary-hover);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.content {
|
|
126
|
+
display: block;
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
text-overflow: ellipsis;
|
|
129
|
+
max-width: var(--quantic-component-button-bar-item-max-width);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.is-active {
|
|
133
|
+
background-color: var(--quantic-bg-active);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.size--sm {
|
|
137
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-1);
|
|
138
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-2);
|
|
139
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
140
|
+
--quantic-font-size-body-xs
|
|
141
|
+
);
|
|
142
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
143
|
+
--quantic-line-height-body-xs
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.size--md {
|
|
148
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-2);
|
|
149
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
150
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
151
|
+
--quantic-font-size-body-sm
|
|
152
|
+
);
|
|
153
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
154
|
+
--quantic-line-height-body-sm
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.size--lg {
|
|
159
|
+
--quantic-internal-button-bar-item-padding-block: 10px;
|
|
160
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
161
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
162
|
+
--quantic-font-size-body-md
|
|
163
|
+
);
|
|
164
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
165
|
+
--quantic-line-height-body-md
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
::slotted(*) {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
}
|
|
173
|
+
`;
|
|
174
|
+
__decorate([
|
|
175
|
+
consume({ context: sizeContext, subscribe: true })
|
|
176
|
+
], ButtonBarItem.prototype, "size", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
state()
|
|
179
|
+
], ButtonBarItem.prototype, "tabbable", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
query('button')
|
|
182
|
+
], ButtonBarItem.prototype, "innerButton", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
prop({
|
|
185
|
+
type: 'boolean',
|
|
186
|
+
default: 'false',
|
|
187
|
+
description: 'Prevents interaction and reduces opacity.',
|
|
188
|
+
reflect: true,
|
|
189
|
+
})
|
|
190
|
+
], ButtonBarItem.prototype, "disabled", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
prop({
|
|
193
|
+
type: 'boolean',
|
|
194
|
+
default: 'false',
|
|
195
|
+
description: 'Marks this item as the currently selected/active option.',
|
|
196
|
+
reflect: true,
|
|
197
|
+
})
|
|
198
|
+
], ButtonBarItem.prototype, "active", void 0);
|
|
199
|
+
ButtonBarItem = __decorate([
|
|
200
|
+
quanticElement('quantic-button-bar-item')
|
|
201
|
+
], ButtonBarItem);
|
|
202
|
+
export { ButtonBarItem };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonBarSize } from './index.constants';
|
|
2
|
+
import { QuanticElement } from '../shared/quantic-element';
|
|
3
|
+
import type { ComponentMeta } from '../shared/meta.types';
|
|
4
|
+
export declare class ButtonBar extends QuanticElement {
|
|
5
|
+
static meta: ComponentMeta;
|
|
6
|
+
size: ButtonBarSize;
|
|
7
|
+
ariaLabel: string | null;
|
|
8
|
+
private disabledObserver?;
|
|
9
|
+
private hasSynced;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
private get items();
|
|
13
|
+
private setFocusStop;
|
|
14
|
+
private syncFocusStop;
|
|
15
|
+
private handleFocusIn;
|
|
16
|
+
private handleKeydown;
|
|
17
|
+
static styles: import("lit").CSSResult;
|
|
18
|
+
protected defaultLabel: string;
|
|
19
|
+
render(): import("lit").TemplateResult<1>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html } from 'lit';
|
|
8
|
+
import { provide } from '@lit/context';
|
|
9
|
+
import { ButtonBarSize } from './index.constants';
|
|
10
|
+
import { sizeContext } from './index.context';
|
|
11
|
+
import { quanticElement, QuanticElement } from '../shared/quantic-element';
|
|
12
|
+
import { prop } from '../shared/component-meta.decorators';
|
|
13
|
+
import { nextFocusIndex, resolveFocusStop } from './index.utils';
|
|
14
|
+
const ITEM_TAGS = 'quantic-button-bar-item, quantic-button-group-item';
|
|
15
|
+
let ButtonBar = class ButtonBar extends QuanticElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.size = ButtonBarSize.Medium;
|
|
19
|
+
this.ariaLabel = null;
|
|
20
|
+
this.hasSynced = false;
|
|
21
|
+
this.defaultLabel = 'Button bar';
|
|
22
|
+
}
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.disabledObserver = new MutationObserver(() => this.syncFocusStop());
|
|
26
|
+
this.disabledObserver.observe(this, {
|
|
27
|
+
attributeFilter: ['disabled'],
|
|
28
|
+
subtree: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
this.disabledObserver?.disconnect();
|
|
34
|
+
this.disabledObserver = undefined;
|
|
35
|
+
}
|
|
36
|
+
get items() {
|
|
37
|
+
return [...this.querySelectorAll(ITEM_TAGS)].filter((item) => item.parentElement === this && !item.disabled);
|
|
38
|
+
}
|
|
39
|
+
setFocusStop(items, index) {
|
|
40
|
+
items.forEach((item, position) => {
|
|
41
|
+
item.tabbable = position === index;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
syncFocusStop() {
|
|
45
|
+
const items = this.items;
|
|
46
|
+
const stop = resolveFocusStop(items, this.hasSynced);
|
|
47
|
+
if (stop === null)
|
|
48
|
+
return;
|
|
49
|
+
this.hasSynced = true;
|
|
50
|
+
this.setFocusStop(items, stop);
|
|
51
|
+
}
|
|
52
|
+
handleFocusIn(event) {
|
|
53
|
+
const items = this.items;
|
|
54
|
+
const focused = items.findIndex((item) => item.contains(event.target));
|
|
55
|
+
if (focused !== -1)
|
|
56
|
+
this.setFocusStop(items, focused);
|
|
57
|
+
}
|
|
58
|
+
handleKeydown(event) {
|
|
59
|
+
const items = this.items;
|
|
60
|
+
const current = items.findIndex((item) => item.contains(event.target));
|
|
61
|
+
const next = nextFocusIndex(event.key, current, items.length);
|
|
62
|
+
if (next === null)
|
|
63
|
+
return;
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
this.setFocusStop(items, next);
|
|
66
|
+
items[next].focus();
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
return html `
|
|
70
|
+
<div
|
|
71
|
+
class="container"
|
|
72
|
+
role="toolbar"
|
|
73
|
+
aria-label=${this.ariaLabel ?? this.defaultLabel}
|
|
74
|
+
@keydown=${this.handleKeydown}
|
|
75
|
+
@focusin=${this.handleFocusIn}
|
|
76
|
+
>
|
|
77
|
+
<slot @slotchange=${() => this.syncFocusStop()}></slot>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
ButtonBar.meta = {
|
|
83
|
+
tag: 'quantic-button-bar',
|
|
84
|
+
description: 'Toolbar of related buttons joined into one cohesive control, with shared sizing. ' +
|
|
85
|
+
'Use for switching between views or modes, and for a compact run of icon actions. ' +
|
|
86
|
+
'Items carry aria-pressed via active, so a set can behave as exclusive options or as independent toggles. ' +
|
|
87
|
+
'Focus follows the toolbar pattern: one tab stop, arrow keys move between items, Home and End jump to the ends. ' +
|
|
88
|
+
'Prefer quantic-button for a standalone action, and quantic-tabs when each segment reveals a panel.',
|
|
89
|
+
category: 'action',
|
|
90
|
+
slots: { '': { description: 'One or more quantic-button-bar-item elements.' } },
|
|
91
|
+
subComponents: ['quantic-button-bar-item'],
|
|
92
|
+
relatedTo: ['quantic-button'],
|
|
93
|
+
};
|
|
94
|
+
ButtonBar.styles = css `
|
|
95
|
+
:host {
|
|
96
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-2);
|
|
97
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
98
|
+
--quantic-internal-button-bar-item-font-size: var(--quantic-font-size-body-sm);
|
|
99
|
+
--quantic-internal-button-bar-item-line-height: var(--quantic-line-height-body-sm);
|
|
100
|
+
--quantic-component-button-bar-item-max-width: var(--quantic-width-xxs);
|
|
101
|
+
--quantic-component-button-bar-border-radius: var(--quantic-radius-md);
|
|
102
|
+
--quantic-component-button-bar-border-color: var(
|
|
103
|
+
--quantic-border-primary
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
max-width: 100%;
|
|
107
|
+
display: inline-flex;
|
|
108
|
+
overflow: visible;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.container {
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
border: 1px solid var(--quantic-component-button-bar-border-color);
|
|
114
|
+
border-radius: var(--quantic-component-button-bar-border-radius);
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
__decorate([
|
|
118
|
+
provide({ context: sizeContext }),
|
|
119
|
+
prop({ type: 'ButtonBarSize', options: Object.values(ButtonBarSize), default: ButtonBarSize.Medium, description: 'Size applied to all child items via context.' })
|
|
120
|
+
], ButtonBar.prototype, "size", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
prop({ type: 'string', attribute: 'aria-label', description: 'Accessible label for the group.' })
|
|
123
|
+
], ButtonBar.prototype, "ariaLabel", void 0);
|
|
124
|
+
ButtonBar = __decorate([
|
|
125
|
+
quanticElement('quantic-button-bar')
|
|
126
|
+
], ButtonBar);
|
|
127
|
+
export { ButtonBar };
|