@ctrliq/quantic-components 1.82.0 → 1.83.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/astro.d.ts +3 -1
- package/dist/astro.js +3 -1
- package/dist/astro.js.map +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button-bar/button-bar-item.d.ts +11 -0
- package/dist/button-bar/button-bar-item.js +191 -0
- package/dist/button-bar/button-bar.d.ts +11 -0
- package/dist/button-bar/button-bar.js +76 -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-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 +17 -58
- package/dist/button-group/index.constants.d.ts +4 -1
- package/dist/button-group/index.constants.js +3 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/meta/index.js +4 -0
- package/dist/meta/index.js.map +1 -1
- package/dist/meta/serialize.js +1 -0
- package/dist/meta.json +92 -22
- package/dist/pagination/pagination.component.js +15 -15
- package/dist/quantic-components.js +131 -73
- package/dist/quantic-components.js.map +1 -1
- package/dist/quantic-components.min.js +148 -142
- 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/types/astro.d.ts +3 -1
- package/dist/types/button-bar/button-bar-item.d.ts +11 -0
- package/dist/types/button-bar/button-bar.d.ts +11 -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-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 +1 -0
- package/dist/types/shared/meta.types.d.ts +4 -0
- package/package.json +1 -1
- 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
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,11 @@
|
|
|
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
|
+
disabled: boolean;
|
|
8
|
+
active: boolean;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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 { consume } from '@lit/context';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { sizeContext } from './index.context';
|
|
11
|
+
import { quanticElement, QuanticElement } from '../shared/quantic-element';
|
|
12
|
+
import { prop } from '../shared/component-meta.decorators';
|
|
13
|
+
let ButtonBarItem = class ButtonBarItem extends QuanticElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
this.active = false;
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const classes = classMap({
|
|
21
|
+
main: true,
|
|
22
|
+
[`size--${this.size}`]: !!this.size,
|
|
23
|
+
[`is-active`]: this.active,
|
|
24
|
+
});
|
|
25
|
+
return html `
|
|
26
|
+
<button
|
|
27
|
+
type="button"
|
|
28
|
+
class=${classes}
|
|
29
|
+
tabindex=${this.disabled ? -1 : 0}
|
|
30
|
+
?disabled=${this.disabled}
|
|
31
|
+
aria-pressed=${this.active ? 'true' : 'false'}
|
|
32
|
+
>
|
|
33
|
+
<div class="content">
|
|
34
|
+
<slot></slot>
|
|
35
|
+
</div>
|
|
36
|
+
</button>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
ButtonBarItem.meta = {
|
|
41
|
+
tag: 'quantic-button-bar-item',
|
|
42
|
+
description: 'Single segment within a quantic-button-bar. ' +
|
|
43
|
+
'Renders as a native button with shared sizing from the parent context and a pressed state via active.',
|
|
44
|
+
category: 'action',
|
|
45
|
+
slots: { '': { description: 'Button label or icon content.' } },
|
|
46
|
+
relatedTo: ['quantic-button-bar', 'quantic-button'],
|
|
47
|
+
};
|
|
48
|
+
ButtonBarItem.styles = css `
|
|
49
|
+
:host {
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([disabled]) {
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
opacity: 0.5;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.main {
|
|
59
|
+
position: relative;
|
|
60
|
+
appearance: none;
|
|
61
|
+
background-color: transparent;
|
|
62
|
+
border: none;
|
|
63
|
+
border-right: 1px solid var(--quantic-border-primary);
|
|
64
|
+
font-family: var(--quantic-font-family-body);
|
|
65
|
+
font-weight: var(--quantic-font-weight-semibold);
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
text-align: center;
|
|
69
|
+
display: block;
|
|
70
|
+
width: 100%;
|
|
71
|
+
color: var(--quantic-text-primary);
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
outline: none;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
padding: var(
|
|
76
|
+
--quantic-component-button-bar-padding-block,
|
|
77
|
+
var(--quantic-internal-button-bar-item-padding-block)
|
|
78
|
+
)
|
|
79
|
+
var(
|
|
80
|
+
--quantic-component-button-bar-padding-inline,
|
|
81
|
+
var(--quantic-internal-button-bar-item-padding-inline)
|
|
82
|
+
);
|
|
83
|
+
font-size: var(
|
|
84
|
+
--quantic-component-button-bar-font-size,
|
|
85
|
+
var(--quantic-internal-button-bar-item-font-size)
|
|
86
|
+
);
|
|
87
|
+
line-height: var(
|
|
88
|
+
--quantic-component-button-bar-line-height,
|
|
89
|
+
var(--quantic-internal-button-bar-item-line-height)
|
|
90
|
+
);
|
|
91
|
+
transition:
|
|
92
|
+
background-color 0.2s ease-in-out,
|
|
93
|
+
color 0.2s ease-in-out;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host(:last-of-type) .main {
|
|
97
|
+
border-right: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.main::before {
|
|
101
|
+
content: '';
|
|
102
|
+
display: block;
|
|
103
|
+
position: absolute;
|
|
104
|
+
inset: 0;
|
|
105
|
+
border-radius: var(--quantic-radius-sm);
|
|
106
|
+
border: 2px solid var(--quantic-focus-ring);
|
|
107
|
+
transition: all 0.2s ease-in-out;
|
|
108
|
+
opacity: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.main:focus-visible::before {
|
|
112
|
+
inset: -4px;
|
|
113
|
+
opacity: 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.main:hover {
|
|
117
|
+
background-color: var(--quantic-bg-secondary-hover);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.content {
|
|
121
|
+
display: block;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
text-overflow: ellipsis;
|
|
124
|
+
max-width: var(--quantic-component-button-bar-item-max-width);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.is-active {
|
|
128
|
+
background-color: var(--quantic-bg-active);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.size--sm {
|
|
132
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-1);
|
|
133
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-2);
|
|
134
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
135
|
+
--quantic-font-size-body-xs
|
|
136
|
+
);
|
|
137
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
138
|
+
--quantic-line-height-body-xs
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.size--md {
|
|
143
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-2);
|
|
144
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
145
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
146
|
+
--quantic-font-size-body-sm
|
|
147
|
+
);
|
|
148
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
149
|
+
--quantic-line-height-body-sm
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.size--lg {
|
|
154
|
+
--quantic-internal-button-bar-item-padding-block: 10px;
|
|
155
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
156
|
+
--quantic-internal-button-bar-item-font-size: var(
|
|
157
|
+
--quantic-font-size-body-md
|
|
158
|
+
);
|
|
159
|
+
--quantic-internal-button-bar-item-line-height: var(
|
|
160
|
+
--quantic-line-height-body-md
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
::slotted(*) {
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
__decorate([
|
|
170
|
+
consume({ context: sizeContext, subscribe: true })
|
|
171
|
+
], ButtonBarItem.prototype, "size", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
prop({
|
|
174
|
+
type: 'boolean',
|
|
175
|
+
default: 'false',
|
|
176
|
+
description: 'Prevents interaction and reduces opacity.',
|
|
177
|
+
reflect: true,
|
|
178
|
+
})
|
|
179
|
+
], ButtonBarItem.prototype, "disabled", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
prop({
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
default: 'false',
|
|
184
|
+
description: 'Marks this item as the currently selected/active option.',
|
|
185
|
+
reflect: true,
|
|
186
|
+
})
|
|
187
|
+
], ButtonBarItem.prototype, "active", void 0);
|
|
188
|
+
ButtonBarItem = __decorate([
|
|
189
|
+
quanticElement('quantic-button-bar-item')
|
|
190
|
+
], ButtonBarItem);
|
|
191
|
+
export { ButtonBarItem };
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
protected defaultLabel: string;
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
let ButtonBar = class ButtonBar extends QuanticElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.size = ButtonBarSize.Medium;
|
|
17
|
+
this.ariaLabel = null;
|
|
18
|
+
this.defaultLabel = 'Button bar';
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
return html `
|
|
22
|
+
<div
|
|
23
|
+
class="container"
|
|
24
|
+
role="toolbar"
|
|
25
|
+
aria-label=${this.ariaLabel || this.defaultLabel}
|
|
26
|
+
>
|
|
27
|
+
<slot></slot>
|
|
28
|
+
</div>
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
ButtonBar.meta = {
|
|
33
|
+
tag: 'quantic-button-bar',
|
|
34
|
+
description: 'Toolbar of related buttons joined into one cohesive control, with shared sizing. ' +
|
|
35
|
+
'Use for switching between views or modes, and for a compact run of icon actions. ' +
|
|
36
|
+
'Items carry aria-pressed via active, so a set can behave as exclusive options or as independent toggles. ' +
|
|
37
|
+
'Prefer quantic-button for a standalone action, and quantic-tabs when each segment reveals a panel.',
|
|
38
|
+
category: 'action',
|
|
39
|
+
slots: { '': { description: 'One or more quantic-button-bar-item elements.' } },
|
|
40
|
+
subComponents: ['quantic-button-bar-item'],
|
|
41
|
+
relatedTo: ['quantic-button'],
|
|
42
|
+
};
|
|
43
|
+
ButtonBar.styles = css `
|
|
44
|
+
:host {
|
|
45
|
+
--quantic-internal-button-bar-item-padding-block: var(--quantic-spacing-2);
|
|
46
|
+
--quantic-internal-button-bar-item-padding-inline: var(--quantic-spacing-3);
|
|
47
|
+
--quantic-internal-button-bar-item-font-size: var(--quantic-font-size-body-sm);
|
|
48
|
+
--quantic-internal-button-bar-item-line-height: var(--quantic-line-height-body-sm);
|
|
49
|
+
--quantic-component-button-bar-item-max-width: var(--quantic-width-xxs);
|
|
50
|
+
--quantic-component-button-bar-border-radius: var(--quantic-radius-md);
|
|
51
|
+
--quantic-component-button-bar-border-color: var(
|
|
52
|
+
--quantic-border-primary
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
max-width: 100%;
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
overflow: visible;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.container {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
border: 1px solid var(--quantic-component-button-bar-border-color);
|
|
63
|
+
border-radius: var(--quantic-component-button-bar-border-radius);
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
__decorate([
|
|
67
|
+
provide({ context: sizeContext }),
|
|
68
|
+
prop({ type: 'ButtonBarSize', options: Object.values(ButtonBarSize), default: ButtonBarSize.Medium, description: 'Size applied to all child items via context.' })
|
|
69
|
+
], ButtonBar.prototype, "size", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
prop({ type: 'string', attribute: 'aria-label', description: 'Accessible label for the group.' })
|
|
72
|
+
], ButtonBar.prototype, "ariaLabel", void 0);
|
|
73
|
+
ButtonBar = __decorate([
|
|
74
|
+
quanticElement('quantic-button-bar')
|
|
75
|
+
], ButtonBar);
|
|
76
|
+
export { ButtonBar };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { story } from '../shared/story';
|
|
2
|
+
import { ButtonBarSize } from './index.constants';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/Actions/Button Group',
|
|
5
|
+
component: 'quantic-button-bar',
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
size: {
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
options: Object.values(ButtonBarSize),
|
|
11
|
+
description: 'The size of the button group',
|
|
12
|
+
},
|
|
13
|
+
items: {
|
|
14
|
+
control: 'object',
|
|
15
|
+
description: 'Array of button labels',
|
|
16
|
+
},
|
|
17
|
+
activeIndex: {
|
|
18
|
+
control: 'number',
|
|
19
|
+
description: 'Index of the active button (optional)',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const base = story({
|
|
24
|
+
args: {
|
|
25
|
+
size: undefined,
|
|
26
|
+
items: ['Text', 'Text', 'Text'],
|
|
27
|
+
activeIndex: undefined,
|
|
28
|
+
},
|
|
29
|
+
}).render(({ size, items, activeIndex }) => {
|
|
30
|
+
const sizeAttr = size ? `size="${size}"` : '';
|
|
31
|
+
const itemsHtml = items
|
|
32
|
+
.map((item, index) => `<quantic-button-bar-item ${activeIndex === index ? 'active' : ''}>${item}</quantic-button-bar-item>`)
|
|
33
|
+
.join('');
|
|
34
|
+
return `<quantic-button-bar ${sizeAttr}>${itemsHtml}</quantic-button-bar>`;
|
|
35
|
+
});
|
|
36
|
+
export const Default = base;
|
|
37
|
+
export const Small = base.override({ size: ButtonBarSize.Small });
|
|
38
|
+
export const Medium = base.override({ size: ButtonBarSize.Medium });
|
|
39
|
+
export const Large = base.override({ size: ButtonBarSize.Large });
|
|
40
|
+
export const WithActiveItem = base.override({ activeIndex: 1 });
|
|
41
|
+
export const ManyItems = base.override({
|
|
42
|
+
items: ['Text', 'Text', 'Text', 'Text', 'Text', 'Text', 'Text', 'Text'],
|
|
43
|
+
});
|
|
44
|
+
export const WithIcons = story().render(() => `
|
|
45
|
+
<quantic-button-bar>
|
|
46
|
+
<quantic-button-bar-item>
|
|
47
|
+
<quantic-icon-lucide-align-left size="xs"></quantic-icon-lucide-align-left>
|
|
48
|
+
</quantic-button-bar-item>
|
|
49
|
+
<quantic-button-bar-item active>
|
|
50
|
+
<quantic-icon-lucide-align-center size="xs"></quantic-icon-lucide-align-center>
|
|
51
|
+
</quantic-button-bar-item>
|
|
52
|
+
<quantic-button-bar-item>
|
|
53
|
+
<quantic-icon-lucide-align-right size="xs"></quantic-icon-lucide-align-right>
|
|
54
|
+
</quantic-button-bar-item>
|
|
55
|
+
</quantic-button-bar>
|
|
56
|
+
`);
|
|
57
|
+
export const WithIconsAndText = story().render(() => `
|
|
58
|
+
<quantic-button-bar>
|
|
59
|
+
<quantic-button-bar-item>
|
|
60
|
+
<quantic-icon-lucide-chevron-left size="xs"></quantic-icon-lucide-chevron-left>
|
|
61
|
+
</quantic-button-bar-item>
|
|
62
|
+
<quantic-button-bar-item>
|
|
63
|
+
Text
|
|
64
|
+
</quantic-button-bar-item>
|
|
65
|
+
<quantic-button-bar-item active>
|
|
66
|
+
<quantic-icon-lucide-plus size="xs"></quantic-icon-lucide-plus>
|
|
67
|
+
</quantic-button-bar-item>
|
|
68
|
+
<quantic-button-bar-item>
|
|
69
|
+
<quantic-icon-lucide-chevron-right size="xs"></quantic-icon-lucide-chevron-right>
|
|
70
|
+
</quantic-button-bar-item>
|
|
71
|
+
</quantic-button-bar>
|
|
72
|
+
`);
|
|
73
|
+
export const Disabled = story().render(() => `
|
|
74
|
+
<quantic-button-bar>
|
|
75
|
+
<quantic-button-bar-item>Text</quantic-button-bar-item>
|
|
76
|
+
<quantic-button-bar-item disabled>Disabled item</quantic-button-bar-item>
|
|
77
|
+
<quantic-button-bar-item>Text</quantic-button-bar-item>
|
|
78
|
+
</quantic-button-bar>
|
|
79
|
+
`);
|
|
80
|
+
export const WithClickEvent = story({
|
|
81
|
+
args: { size: ButtonBarSize.Medium, items: [], activeIndex: undefined },
|
|
82
|
+
}).render(({ size }) => `
|
|
83
|
+
<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
84
|
+
<quantic-button-bar size="${size}">
|
|
85
|
+
<quantic-button-bar-item onclick="handleClick('Option 1')">Option 1</quantic-button-bar-item>
|
|
86
|
+
<quantic-button-bar-item onclick="handleClick('Option 2')">Option 2</quantic-button-bar-item>
|
|
87
|
+
<quantic-button-bar-item onclick="handleClick('Option 3')">Option 3</quantic-button-bar-item>
|
|
88
|
+
</quantic-button-bar>
|
|
89
|
+
<quantic-card variant="solid" size="sm" id="output">
|
|
90
|
+
Click a button to see the event
|
|
91
|
+
</quantic-card>
|
|
92
|
+
</div>
|
|
93
|
+
<script>
|
|
94
|
+
function handleClick(option) {
|
|
95
|
+
document.getElementById('output').textContent = option + ' clicked at ' + new Date().toLocaleTimeString();
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
`);
|
|
99
|
+
export const WithLongText = story().render(() => `
|
|
100
|
+
<quantic-button-bar>
|
|
101
|
+
<quantic-button-bar-item>Short</quantic-button-bar-item>
|
|
102
|
+
<quantic-button-bar-item>Text</quantic-button-bar-item>
|
|
103
|
+
<quantic-button-bar-item>This is a very long button text that should be clamped with ellipsis</quantic-button-bar-item>
|
|
104
|
+
<quantic-button-bar-item>Medium</quantic-button-bar-item>
|
|
105
|
+
<quantic-button-bar-item>Text</quantic-button-bar-item>
|
|
106
|
+
</quantic-button-bar>
|
|
107
|
+
`);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { QuanticElement } from '../shared/quantic-element';
|
|
1
|
+
import { ButtonBarItem } from '../button-bar/button-bar-item';
|
|
3
2
|
import type { ComponentMeta } from '../shared/meta.types';
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Renamed to `ButtonBarItem` (`quantic-button-bar-item`).
|
|
5
|
+
* Removed in the next major.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ButtonGroupItem extends ButtonBarItem {
|
|
5
8
|
static meta: ComponentMeta;
|
|
6
|
-
size?: ButtonGroupSize;
|
|
7
|
-
disabled: boolean;
|
|
8
|
-
active: boolean;
|
|
9
|
-
static styles: import("lit").CSSResult;
|
|
10
|
-
render(): import("lit").TemplateResult<1>;
|
|
11
9
|
}
|
|
@@ -4,177 +4,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let ButtonGroupItem = class ButtonGroupItem extends
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.disabled = false;
|
|
17
|
-
this.active = false;
|
|
18
|
-
}
|
|
19
|
-
render() {
|
|
20
|
-
const classes = classMap({
|
|
21
|
-
main: true,
|
|
22
|
-
[`size--${this.size}`]: !!this.size,
|
|
23
|
-
[`is-active`]: this.active,
|
|
24
|
-
});
|
|
25
|
-
return html `
|
|
26
|
-
<button
|
|
27
|
-
class=${classes}
|
|
28
|
-
tabindex=${this.disabled ? -1 : 0}
|
|
29
|
-
?disabled=${this.disabled}
|
|
30
|
-
aria-pressed=${this.active ? 'true' : 'false'}
|
|
31
|
-
>
|
|
32
|
-
<div class="content">
|
|
33
|
-
<slot></slot>
|
|
34
|
-
</div>
|
|
35
|
-
</button>
|
|
36
|
-
`;
|
|
37
|
-
}
|
|
7
|
+
import { quanticElement } from '../shared/quantic-element';
|
|
8
|
+
import { ButtonBarItem } from '../button-bar/button-bar-item';
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Renamed to `ButtonBarItem` (`quantic-button-bar-item`).
|
|
11
|
+
* Removed in the next major.
|
|
12
|
+
*/
|
|
13
|
+
let ButtonGroupItem = class ButtonGroupItem extends ButtonBarItem {
|
|
38
14
|
};
|
|
39
15
|
ButtonGroupItem.meta = {
|
|
16
|
+
...ButtonBarItem.meta,
|
|
40
17
|
tag: 'quantic-button-group-item',
|
|
41
|
-
description: '
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
slots: { '': { description: 'Button label or icon content.' } },
|
|
45
|
-
relatedTo: ['quantic-button-group', 'quantic-button'],
|
|
18
|
+
description: 'Deprecated alias of quantic-button-bar-item. Use quantic-button-bar-item.',
|
|
19
|
+
deprecated: { use: 'quantic-button-bar-item' },
|
|
20
|
+
relatedTo: ['quantic-button-group'],
|
|
46
21
|
};
|
|
47
|
-
ButtonGroupItem.styles = css `
|
|
48
|
-
:host {
|
|
49
|
-
display: inline-flex;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
:host([disabled]) {
|
|
53
|
-
pointer-events: none;
|
|
54
|
-
opacity: 0.5;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.main {
|
|
58
|
-
position: relative;
|
|
59
|
-
appearance: none;
|
|
60
|
-
background-color: transparent;
|
|
61
|
-
border: none;
|
|
62
|
-
border-right: 1px solid var(--quantic-border-primary);
|
|
63
|
-
font-family: var(--quantic-font-family-body);
|
|
64
|
-
font-weight: var(--quantic-font-weight-semibold);
|
|
65
|
-
white-space: nowrap;
|
|
66
|
-
text-decoration: none;
|
|
67
|
-
text-align: center;
|
|
68
|
-
display: block;
|
|
69
|
-
align-items: center;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
gap: var(--quantic-spacing-2);
|
|
72
|
-
width: 100%;
|
|
73
|
-
color: var(--quantic-text-primary);
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
outline: none;
|
|
76
|
-
box-sizing: border-box;
|
|
77
|
-
padding: var(--quantic-component-button-group-padding-block)
|
|
78
|
-
var(--quantic-component-button-group-padding-inline);
|
|
79
|
-
font-size: var(--quantic-component-button-group-font-size);
|
|
80
|
-
line-height: var(--quantic-component-button-group-line-height);
|
|
81
|
-
transition:
|
|
82
|
-
background-color 0.2s ease-in-out,
|
|
83
|
-
color 0.2s ease-in-out;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
:host(:last-of-type) .main {
|
|
87
|
-
border-right: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.main::before {
|
|
91
|
-
content: '';
|
|
92
|
-
display: block;
|
|
93
|
-
position: absolute;
|
|
94
|
-
inset: 0;
|
|
95
|
-
border-radius: var(--quantic-radius-sm);
|
|
96
|
-
border: 2px solid var(--quantic-focus-ring);
|
|
97
|
-
transition: all 0.2s ease-in-out;
|
|
98
|
-
opacity: 0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.main:focus-visible::before {
|
|
102
|
-
inset: -4px;
|
|
103
|
-
opacity: 1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.main:hover {
|
|
107
|
-
background-color: var(--quantic-bg-secondary-hover);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.content {
|
|
111
|
-
display: block;
|
|
112
|
-
overflow: hidden;
|
|
113
|
-
text-overflow: ellipsis;
|
|
114
|
-
max-width: var(--quantic-component-button-group-item-max-width);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.is-active {
|
|
118
|
-
background-color: var(--quantic-bg-active);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.size--sm {
|
|
122
|
-
--quantic-component-button-group-padding-block: var(--quantic-spacing-1);
|
|
123
|
-
--quantic-component-button-group-padding-inline: var(--quantic-spacing-2);
|
|
124
|
-
--quantic-component-button-group-font-size: var(
|
|
125
|
-
--quantic-font-size-body-xs
|
|
126
|
-
);
|
|
127
|
-
--quantic-component-button-group-line-height: var(
|
|
128
|
-
--quantic-line-height-body-xs
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.size--md {
|
|
133
|
-
--quantic-component-button-group-padding-block: var(--quantic-spacing-2);
|
|
134
|
-
--quantic-component-button-group-padding-inline: var(--quantic-spacing-3);
|
|
135
|
-
--quantic-component-button-group-font-size: var(
|
|
136
|
-
--quantic-font-size-body-sm
|
|
137
|
-
);
|
|
138
|
-
--quantic-component-button-group-line-height: var(
|
|
139
|
-
--quantic-line-height-body-sm
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.size--lg {
|
|
144
|
-
--quantic-component-button-group-padding-block: 10px;
|
|
145
|
-
--quantic-component-button-group-padding-inline: var(--quantic-spacing-3);
|
|
146
|
-
--quantic-component-button-group-font-size: var(
|
|
147
|
-
--quantic-font-size-body-md
|
|
148
|
-
);
|
|
149
|
-
--quantic-component-button-group-line-height: var(
|
|
150
|
-
--quantic-line-height-body-md
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
::slotted(*) {
|
|
155
|
-
display: flex;
|
|
156
|
-
align-items: center;
|
|
157
|
-
}
|
|
158
|
-
`;
|
|
159
|
-
__decorate([
|
|
160
|
-
consume({ context: sizeContext, subscribe: true })
|
|
161
|
-
], ButtonGroupItem.prototype, "size", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
prop({
|
|
164
|
-
type: 'boolean',
|
|
165
|
-
default: 'false',
|
|
166
|
-
description: 'Prevents interaction and reduces opacity.',
|
|
167
|
-
reflect: true,
|
|
168
|
-
})
|
|
169
|
-
], ButtonGroupItem.prototype, "disabled", void 0);
|
|
170
|
-
__decorate([
|
|
171
|
-
prop({
|
|
172
|
-
type: 'boolean',
|
|
173
|
-
default: 'false',
|
|
174
|
-
description: 'Marks this item as the currently selected/active option.',
|
|
175
|
-
reflect: true,
|
|
176
|
-
})
|
|
177
|
-
], ButtonGroupItem.prototype, "active", void 0);
|
|
178
22
|
ButtonGroupItem = __decorate([
|
|
179
23
|
quanticElement('quantic-button-group-item')
|
|
180
24
|
], ButtonGroupItem);
|