@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.
Files changed (88) hide show
  1. package/dist/action-group/action-group.component.d.ts +13 -0
  2. package/dist/action-group/action-group.component.js +63 -0
  3. package/dist/action-group/index.d.ts +1 -0
  4. package/dist/action-group/index.js +1 -0
  5. package/dist/action-group/index.stories.d.ts +25 -0
  6. package/dist/action-group/index.stories.js +59 -0
  7. package/dist/astro.d.ts +6 -1
  8. package/dist/astro.js +6 -1
  9. package/dist/astro.js.map +1 -1
  10. package/dist/badge/badge-group.component.d.ts +13 -0
  11. package/dist/badge/badge-group.component.js +62 -0
  12. package/dist/badge/badge-group.stories.d.ts +41 -0
  13. package/dist/badge/badge-group.stories.js +62 -0
  14. package/dist/badge/index.d.ts +1 -0
  15. package/dist/badge/index.js +1 -0
  16. package/dist/button/index.js +1 -1
  17. package/dist/button-bar/button-bar-item.d.ts +14 -0
  18. package/dist/button-bar/button-bar-item.js +202 -0
  19. package/dist/button-bar/button-bar.d.ts +20 -0
  20. package/dist/button-bar/button-bar.js +127 -0
  21. package/dist/button-bar/index.constants.d.ts +6 -0
  22. package/dist/button-bar/index.constants.js +5 -0
  23. package/dist/button-bar/index.context.d.ts +4 -0
  24. package/dist/button-bar/index.context.js +2 -0
  25. package/dist/button-bar/index.d.ts +3 -0
  26. package/dist/button-bar/index.js +3 -0
  27. package/dist/{types/button-group → button-bar}/index.stories.d.ts +2 -2
  28. package/dist/button-bar/index.stories.js +107 -0
  29. package/dist/button-bar/index.utils.d.ts +6 -0
  30. package/dist/button-bar/index.utils.js +31 -0
  31. package/dist/button-bar/index.utils.test.d.ts +1 -0
  32. package/dist/button-bar/index.utils.test.js +53 -0
  33. package/dist/button-group/button-group-item.d.ts +6 -8
  34. package/dist/button-group/button-group-item.js +11 -167
  35. package/dist/button-group/button-group.d.ts +9 -7
  36. package/dist/button-group/button-group.js +16 -58
  37. package/dist/button-group/index.constants.d.ts +4 -1
  38. package/dist/button-group/index.constants.js +3 -5
  39. package/dist/dialog/dialog-actions.js +11 -10
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +2 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/meta/index.js +10 -0
  44. package/dist/meta/index.js.map +1 -1
  45. package/dist/meta/serialize.js +1 -0
  46. package/dist/meta.json +199 -24
  47. package/dist/pagination/pagination.component.js +15 -15
  48. package/dist/quantic-components.js +395 -86
  49. package/dist/quantic-components.js.map +1 -1
  50. package/dist/quantic-components.min.js +215 -155
  51. package/dist/quantic-components.min.js.map +1 -1
  52. package/dist/register.js.map +1 -1
  53. package/dist/shared/meta.types.d.ts +4 -0
  54. package/dist/tabs/index.stories.js +1 -1
  55. package/dist/tag/index.d.ts +1 -0
  56. package/dist/tag/index.js +1 -0
  57. package/dist/tag/tag-group.component.d.ts +13 -0
  58. package/dist/tag/tag-group.component.js +62 -0
  59. package/dist/tag/tag-group.stories.d.ts +34 -0
  60. package/dist/tag/tag-group.stories.js +65 -0
  61. package/dist/types/action-group/action-group.component.d.ts +13 -0
  62. package/dist/types/action-group/index.d.ts +1 -0
  63. package/dist/types/action-group/index.stories.d.ts +25 -0
  64. package/dist/types/astro.d.ts +6 -1
  65. package/dist/types/badge/badge-group.component.d.ts +13 -0
  66. package/dist/types/badge/badge-group.stories.d.ts +41 -0
  67. package/dist/types/badge/index.d.ts +1 -0
  68. package/dist/types/button-bar/button-bar-item.d.ts +14 -0
  69. package/dist/types/button-bar/button-bar.d.ts +20 -0
  70. package/dist/types/button-bar/index.constants.d.ts +6 -0
  71. package/dist/types/button-bar/index.context.d.ts +4 -0
  72. package/dist/types/button-bar/index.d.ts +3 -0
  73. package/dist/{button-group → types/button-bar}/index.stories.d.ts +2 -2
  74. package/dist/types/button-bar/index.utils.d.ts +6 -0
  75. package/dist/types/button-bar/index.utils.test.d.ts +1 -0
  76. package/dist/types/button-group/button-group-item.d.ts +6 -8
  77. package/dist/types/button-group/button-group.d.ts +9 -7
  78. package/dist/types/button-group/index.constants.d.ts +4 -1
  79. package/dist/types/index.d.ts +2 -0
  80. package/dist/types/shared/meta.types.d.ts +4 -0
  81. package/dist/types/tag/index.d.ts +1 -0
  82. package/dist/types/tag/tag-group.component.d.ts +13 -0
  83. package/dist/types/tag/tag-group.stories.d.ts +34 -0
  84. package/package.json +4 -3
  85. package/dist/button-group/index.context.d.ts +0 -4
  86. package/dist/button-group/index.context.js +0 -2
  87. package/dist/button-group/index.stories.js +0 -107
  88. package/dist/types/button-group/index.context.d.ts +0 -4
@@ -0,0 +1,107 @@
1
+ import { story } from '../shared/story';
2
+ import { ButtonBarSize } from './index.constants';
3
+ export default {
4
+ title: 'Components/Actions/Button Bar',
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 bar',
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
+ `);
@@ -0,0 +1,6 @@
1
+ export interface FocusStopCandidate {
2
+ tabbable: boolean;
3
+ active: boolean;
4
+ }
5
+ export declare function resolveFocusStop(items: FocusStopCandidate[], hasSynced: boolean): number | null;
6
+ export declare function nextFocusIndex(key: string, current: number, count: number): number | null;
@@ -0,0 +1,31 @@
1
+ const KEY_STEPS = {
2
+ ArrowRight: 1,
3
+ ArrowDown: 1,
4
+ ArrowLeft: -1,
5
+ ArrowUp: -1,
6
+ Home: 'first',
7
+ End: 'last',
8
+ };
9
+ export function resolveFocusStop(items, hasSynced) {
10
+ if (!items.length)
11
+ return null;
12
+ if (hasSynced) {
13
+ const tabbable = items.findIndex((item) => item.tabbable);
14
+ if (tabbable !== -1)
15
+ return tabbable;
16
+ }
17
+ const active = items.findIndex((item) => item.active);
18
+ return active === -1 ? 0 : active;
19
+ }
20
+ export function nextFocusIndex(key, current, count) {
21
+ const step = KEY_STEPS[key];
22
+ if (step === undefined)
23
+ return null;
24
+ if (count < 2 || current < 0 || current >= count)
25
+ return null;
26
+ if (step === 'first')
27
+ return 0;
28
+ if (step === 'last')
29
+ return count - 1;
30
+ return (current + step + count) % count;
31
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { nextFocusIndex, resolveFocusStop } from './index.utils';
3
+ const item = (tabbable, active = false) => ({ tabbable, active });
4
+ describe('resolveFocusStop', () => {
5
+ it('starts on the active item', () => {
6
+ expect(resolveFocusStop([item(true), item(true, true), item(true)], false)).toBe(1);
7
+ });
8
+ it('starts on the first item when none is active', () => {
9
+ expect(resolveFocusStop([item(true), item(true)], false)).toBe(0);
10
+ });
11
+ it('keeps the existing stop once synced, so a resync does not move focus', () => {
12
+ expect(resolveFocusStop([item(false), item(true), item(false, true)], true)).toBe(1);
13
+ });
14
+ it('rehomes the stop when the item holding it is gone', () => {
15
+ expect(resolveFocusStop([item(false), item(false, true)], true)).toBe(1);
16
+ expect(resolveFocusStop([item(false), item(false)], true)).toBe(0);
17
+ });
18
+ it('has nothing to do without items', () => {
19
+ expect(resolveFocusStop([], false)).toBeNull();
20
+ expect(resolveFocusStop([], true)).toBeNull();
21
+ });
22
+ });
23
+ describe('nextFocusIndex', () => {
24
+ it('moves forward and back', () => {
25
+ expect(nextFocusIndex('ArrowRight', 0, 3)).toBe(1);
26
+ expect(nextFocusIndex('ArrowLeft', 2, 3)).toBe(1);
27
+ });
28
+ it('treats the vertical arrows the same, so a wrapped bar still navigates', () => {
29
+ expect(nextFocusIndex('ArrowDown', 0, 3)).toBe(1);
30
+ expect(nextFocusIndex('ArrowUp', 1, 3)).toBe(0);
31
+ });
32
+ it('wraps at both ends', () => {
33
+ expect(nextFocusIndex('ArrowRight', 2, 3)).toBe(0);
34
+ expect(nextFocusIndex('ArrowLeft', 0, 3)).toBe(2);
35
+ });
36
+ it('jumps to the ends', () => {
37
+ expect(nextFocusIndex('Home', 2, 3)).toBe(0);
38
+ expect(nextFocusIndex('End', 0, 3)).toBe(2);
39
+ });
40
+ it('ignores keys it does not own, so Tab and Enter still behave natively', () => {
41
+ expect(nextFocusIndex('Tab', 0, 3)).toBeNull();
42
+ expect(nextFocusIndex('Enter', 0, 3)).toBeNull();
43
+ expect(nextFocusIndex(' ', 0, 3)).toBeNull();
44
+ });
45
+ it('does nothing without at least two items', () => {
46
+ expect(nextFocusIndex('ArrowRight', 0, 1)).toBeNull();
47
+ expect(nextFocusIndex('ArrowRight', 0, 0)).toBeNull();
48
+ });
49
+ it('does nothing when the event came from outside the items', () => {
50
+ expect(nextFocusIndex('ArrowRight', -1, 3)).toBeNull();
51
+ expect(nextFocusIndex('ArrowRight', 3, 3)).toBeNull();
52
+ });
53
+ });
@@ -1,11 +1,9 @@
1
- import { ButtonGroupSize } from './index.constants';
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
- export declare class ButtonGroupItem extends QuanticElement {
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 { 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 ButtonGroupItem = class ButtonGroupItem 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
- 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: 'Individual button within a quantic-button-group. ' +
42
- 'Renders as a native button with shared sizing from the parent group context and a toggle-style active state.',
43
- category: 'action',
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);
@@ -1,10 +1,12 @@
1
- import { ButtonGroupSize } from './index.constants';
2
- import { QuanticElement } from '../shared/quantic-element';
1
+ import { ButtonBar } from '../button-bar/button-bar';
3
2
  import type { ComponentMeta } from '../shared/meta.types';
4
- export declare class ButtonGroup extends QuanticElement {
3
+ /**
4
+ * @deprecated Renamed to `ButtonBar` (`quantic-button-bar`). This element
5
+ * never grouped buttons: it joins borders and gives its items a pressed state, which is a
6
+ * button bar. Removed in the next major. For a spaced row of related actions use
7
+ * `ActionGroup`; the `ButtonGroup` name is retired rather than reused.
8
+ */
9
+ export declare class ButtonGroup extends ButtonBar {
5
10
  static meta: ComponentMeta;
6
- size: ButtonGroupSize;
7
- ariaLabel: string | null;
8
- static styles: import("lit").CSSResult;
9
- render(): import("lit").TemplateResult<1>;
11
+ protected defaultLabel: string;
10
12
  }
@@ -4,73 +4,31 @@ 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 { css, html } from 'lit';
8
- import { provide } from '@lit/context';
9
- import { ButtonGroupSize } 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 ButtonGroup = class ButtonGroup extends QuanticElement {
7
+ import { quanticElement } from '../shared/quantic-element';
8
+ import { ButtonBar } from '../button-bar/button-bar';
9
+ /**
10
+ * @deprecated Renamed to `ButtonBar` (`quantic-button-bar`). This element
11
+ * never grouped buttons: it joins borders and gives its items a pressed state, which is a
12
+ * button bar. Removed in the next major. For a spaced row of related actions use
13
+ * `ActionGroup`; the `ButtonGroup` name is retired rather than reused.
14
+ */
15
+ let ButtonGroup = class ButtonGroup extends ButtonBar {
14
16
  constructor() {
15
17
  super(...arguments);
16
- this.size = ButtonGroupSize.Medium;
17
- this.ariaLabel = null;
18
- }
19
- render() {
20
- return html `
21
- <div
22
- class="container"
23
- role="toolbar"
24
- aria-label=${this.ariaLabel || 'Button group'}
25
- >
26
- <slot></slot>
27
- </div>
28
- `;
18
+ this.defaultLabel = 'Button group';
29
19
  }
30
20
  };
31
21
  ButtonGroup.meta = {
22
+ ...ButtonBar.meta,
32
23
  tag: 'quantic-button-group',
33
- description: 'Toolbar container that groups multiple action buttons with joined borders and shared sizing. ' +
34
- 'Use when two or more related actions should appear as a single cohesive control.',
35
- category: 'action',
24
+ description: 'Deprecated alias of quantic-button-bar. Use quantic-button-bar.',
25
+ deprecated: {
26
+ use: 'quantic-button-bar',
27
+ reason: 'The name describes a row of buttons, which this is not. Use quantic-action-group for that.',
28
+ },
36
29
  slots: { '': { description: 'One or more quantic-button-group-item elements.' } },
37
30
  subComponents: ['quantic-button-group-item'],
38
- relatedTo: ['quantic-button'],
39
31
  };
40
- ButtonGroup.styles = css `
41
- :host {
42
- --quantic-component-button-group-padding-block: var(--quantic-spacing-2);
43
- --quantic-component-button-group-padding-inline: var(--quantic-spacing-3);
44
- --quantic-component-button-group-font-size: var(
45
- --quantic-font-size-body-sm
46
- );
47
- --quantic-component-button-group-line-height: var(
48
- --quantic-line-height-body-sm
49
- );
50
- --quantic-component-button-group-item-max-width: var(--quantic-width-xxs);
51
- --quantic-component-button-group-border-radius: var(--quantic-radius-md);
52
- --quantic-component-button-group-border-color: var(
53
- --quantic-border-primary
54
- );
55
-
56
- max-width: 100%;
57
- display: inline-flex;
58
- overflow: visible;
59
- }
60
-
61
- .container {
62
- display: inline-flex;
63
- border: 1px solid var(--quantic-component-button-group-border-color);
64
- border-radius: var(--quantic-component-button-group-border-radius);
65
- }
66
- `;
67
- __decorate([
68
- provide({ context: sizeContext }),
69
- prop({ type: 'ButtonGroupSize', options: Object.values(ButtonGroupSize), default: ButtonGroupSize.Medium, description: 'Size applied to all child items via context.' })
70
- ], ButtonGroup.prototype, "size", void 0);
71
- __decorate([
72
- prop({ type: 'string', attribute: 'aria-label', description: 'Accessible label for the toolbar role.' })
73
- ], ButtonGroup.prototype, "ariaLabel", void 0);
74
32
  ButtonGroup = __decorate([
75
33
  quanticElement('quantic-button-group')
76
34
  ], ButtonGroup);
@@ -1,6 +1,9 @@
1
+ import { ButtonBarSize } from '../button-bar/index.constants';
2
+ /** @deprecated Renamed to `ButtonBarSize`. Removed in the next major. */
1
3
  export declare const ButtonGroupSize: {
2
4
  readonly Small: "sm";
3
5
  readonly Medium: "md";
4
6
  readonly Large: "lg";
5
7
  };
6
- export type ButtonGroupSize = (typeof ButtonGroupSize)[keyof typeof ButtonGroupSize];
8
+ /** @deprecated Renamed to `ButtonBarSize`. Removed in the next major. */
9
+ export type ButtonGroupSize = ButtonBarSize;
@@ -1,5 +1,3 @@
1
- export const ButtonGroupSize = {
2
- Small: 'sm',
3
- Medium: 'md',
4
- Large: 'lg',
5
- };
1
+ import { ButtonBarSize } from '../button-bar/index.constants';
2
+ /** @deprecated Renamed to `ButtonBarSize`. Removed in the next major. */
3
+ export const ButtonGroupSize = ButtonBarSize;
@@ -6,34 +6,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { css } from 'lit';
8
8
  import { html } from 'lit/static-html.js';
9
+ import { ActionGroup } from '../action-group/action-group.component';
9
10
  import { quanticElement, QuanticElement } from '../shared/quantic-element';
11
+ ActionGroup.ensureDefined();
10
12
  let DialogActions = class DialogActions extends QuanticElement {
11
13
  render() {
12
14
  return html `
13
- <div class="main">
15
+ <quantic-action-group aria-label="">
14
16
  <slot></slot>
15
- </div>
17
+ </quantic-action-group>
16
18
  `;
17
19
  }
18
20
  };
19
21
  DialogActions.meta = {
20
22
  tag: 'quantic-dialog-actions',
21
- description: 'Footer actions bar sub-component for quantic-dialog. ' +
22
- 'Lays out action buttons (confirm/cancel) flush to the right.',
23
+ description: 'Footer actions bar for quantic-dialog. ' +
24
+ 'Lays action buttons out as a quantic-action-group, flush to the right.',
23
25
  category: 'feedback',
24
26
  slots: { '': { description: 'Action buttons, typically quantic-button elements.' } },
25
- relatedTo: ['quantic-dialog', 'quantic-button'],
27
+ subComponents: ['quantic-action-group'],
28
+ relatedTo: ['quantic-dialog', 'quantic-button', 'quantic-action-group'],
26
29
  };
27
30
  DialogActions.styles = css `
28
31
  :host {
29
32
  display: block;
30
33
  }
31
34
 
32
- .main {
33
- display: flex;
34
- align-items: center;
35
- justify-content: flex-end;
36
- gap: var(--quantic-spacing-3);
35
+ quantic-action-group {
36
+ width: fit-content;
37
+ margin-inline-start: auto;
37
38
  }
38
39
  `;
39
40
  DialogActions = __decorate([
package/dist/index.d.ts CHANGED
@@ -3,7 +3,9 @@ export * from './combobox';
3
3
  export * from './badge';
4
4
  export * from './capacity-bar';
5
5
  export * from './button';
6
+ export * from './action-group';
6
7
  export * from './button-group';
8
+ export * from './button-bar';
7
9
  export * from './card';
8
10
  export * from './code-input';
9
11
  export * from './checkbox';
package/dist/index.js CHANGED
@@ -3,7 +3,9 @@ export * from './combobox';
3
3
  export * from './badge';
4
4
  export * from './capacity-bar';
5
5
  export * from './button';
6
+ export * from './action-group';
6
7
  export * from './button-group';
8
+ export * from './button-bar';
7
9
  export * from './card';
8
10
  export * from './code-input';
9
11
  export * from './checkbox';