@quieto/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +142 -2
- package/custom-elements.json +6126 -0
- package/dist/components/qds-accordion/qds-accordion.d.ts +39 -0
- package/dist/components/qds-accordion/qds-accordion.d.ts.map +1 -0
- package/dist/components/qds-accordion/qds-accordion.js +130 -0
- package/dist/components/qds-accordion/qds-accordion.js.map +1 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.d.ts +68 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.d.ts.map +1 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.js +247 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.js.map +1 -0
- package/dist/components/qds-button/qds-button.d.ts +92 -0
- package/dist/components/qds-button/qds-button.d.ts.map +1 -0
- package/dist/components/qds-button/qds-button.js +418 -0
- package/dist/components/qds-button/qds-button.js.map +1 -0
- package/dist/components/qds-card/qds-card.d.ts +48 -0
- package/dist/components/qds-card/qds-card.d.ts.map +1 -0
- package/dist/components/qds-card/qds-card.js +152 -0
- package/dist/components/qds-card/qds-card.js.map +1 -0
- package/dist/components/qds-checkbox/qds-checkbox.d.ts +85 -0
- package/dist/components/qds-checkbox/qds-checkbox.d.ts.map +1 -0
- package/dist/components/qds-checkbox/qds-checkbox.js +316 -0
- package/dist/components/qds-checkbox/qds-checkbox.js.map +1 -0
- package/dist/components/qds-chip/qds-chip.d.ts +79 -0
- package/dist/components/qds-chip/qds-chip.d.ts.map +1 -0
- package/dist/components/qds-chip/qds-chip.js +314 -0
- package/dist/components/qds-chip/qds-chip.js.map +1 -0
- package/dist/components/qds-input/qds-input.d.ts +64 -0
- package/dist/components/qds-input/qds-input.d.ts.map +1 -0
- package/dist/components/qds-input/qds-input.js +224 -0
- package/dist/components/qds-input/qds-input.js.map +1 -0
- package/dist/components/qds-modal/qds-modal.d.ts +76 -0
- package/dist/components/qds-modal/qds-modal.d.ts.map +1 -0
- package/dist/components/qds-modal/qds-modal.js +362 -0
- package/dist/components/qds-modal/qds-modal.js.map +1 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.d.ts +47 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.d.ts.map +1 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.js +180 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.js.map +1 -0
- package/dist/components/qds-radio/qds-radio.d.ts +62 -0
- package/dist/components/qds-radio/qds-radio.d.ts.map +1 -0
- package/dist/components/qds-radio/qds-radio.js +213 -0
- package/dist/components/qds-radio/qds-radio.js.map +1 -0
- package/dist/components/qds-radio-group/qds-radio-group.d.ts +72 -0
- package/dist/components/qds-radio-group/qds-radio-group.d.ts.map +1 -0
- package/dist/components/qds-radio-group/qds-radio-group.js +317 -0
- package/dist/components/qds-radio-group/qds-radio-group.js.map +1 -0
- package/dist/components/qds-stack/qds-stack.d.ts +46 -0
- package/dist/components/qds-stack/qds-stack.d.ts.map +1 -0
- package/dist/components/qds-stack/qds-stack.js +149 -0
- package/dist/components/qds-stack/qds-stack.js.map +1 -0
- package/dist/components/qds-tab/qds-tab.d.ts +55 -0
- package/dist/components/qds-tab/qds-tab.d.ts.map +1 -0
- package/dist/components/qds-tab/qds-tab.js +162 -0
- package/dist/components/qds-tab/qds-tab.js.map +1 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.d.ts +32 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.d.ts.map +1 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.js +72 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.js.map +1 -0
- package/dist/components/qds-tabs/qds-tabs.d.ts +54 -0
- package/dist/components/qds-tabs/qds-tabs.d.ts.map +1 -0
- package/dist/components/qds-tabs/qds-tabs.js +196 -0
- package/dist/components/qds-tabs/qds-tabs.js.map +1 -0
- package/dist/components/qds-text-field/qds-text-field.d.ts +94 -0
- package/dist/components/qds-text-field/qds-text-field.d.ts.map +1 -0
- package/dist/components/qds-text-field/qds-text-field.js +332 -0
- package/dist/components/qds-text-field/qds-text-field.js.map +1 -0
- package/dist/components/qds-toggle/qds-toggle.d.ts +68 -0
- package/dist/components/qds-toggle/qds-toggle.d.ts.map +1 -0
- package/dist/components/qds-toggle/qds-toggle.js +260 -0
- package/dist/components/qds-toggle/qds-toggle.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/qds-element.d.ts +31 -0
- package/dist/internal/qds-element.d.ts.map +1 -0
- package/dist/internal/qds-element.js +68 -0
- package/dist/internal/qds-element.js.map +1 -0
- package/dist/internal/qds-text-control.d.ts +79 -0
- package/dist/internal/qds-text-control.d.ts.map +1 -0
- package/dist/internal/qds-text-control.js +159 -0
- package/dist/internal/qds-text-control.js.map +1 -0
- package/package.json +125 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* A stack of `qds-accordion-item` sections.
|
|
5
|
+
*
|
|
6
|
+
* Adds two things the items cannot do alone: `exclusive`, which keeps at most one
|
|
7
|
+
* item open, and arrow-key movement between headings (Up, Down, Home, End), as
|
|
8
|
+
* the ARIA accordion pattern recommends. Tab still moves through the headings
|
|
9
|
+
* and into open panels as usual.
|
|
10
|
+
*
|
|
11
|
+
* The open state lives on each item, so it is rendered correctly from the
|
|
12
|
+
* server. `exclusive` holds however an item opens — by the user, from code, or
|
|
13
|
+
* in markup; when markup opens several, the first stays open.
|
|
14
|
+
*
|
|
15
|
+
* @element qds-accordion
|
|
16
|
+
*
|
|
17
|
+
* @slot - The `qds-accordion-item` sections.
|
|
18
|
+
*
|
|
19
|
+
* @csspart base - The wrapper around the items.
|
|
20
|
+
*
|
|
21
|
+
* @cssprop [--qds-component-accordion-border-width] - Divider thickness, including the top border.
|
|
22
|
+
* @cssprop [--qds-component-accordion-color-border-rest] - Divider color.
|
|
23
|
+
*/
|
|
24
|
+
export declare class QdsAccordion extends QdsElement {
|
|
25
|
+
#private;
|
|
26
|
+
static styles: import("lit").CSSResult[];
|
|
27
|
+
/** Keeps at most one item open: opening one closes the others. */
|
|
28
|
+
exclusive: boolean;
|
|
29
|
+
constructor();
|
|
30
|
+
protected firstUpdated(): void;
|
|
31
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'qds-accordion': QdsAccordion;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=qds-accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-accordion.d.ts","sourceRoot":"","sources":["../../../src/components/qds-accordion/qds-accordion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,YAAa,SAAQ,UAAU;;IAC1C,OAAgB,MAAM,4BASpB;IAEF,kEAAkE;IAElE,SAAS,UAAS;;cAYC,YAAY,IAAI,IAAI;cAMpB,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAyDtD,MAAM,IAAI,cAAc;CAKlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,YAAY,CAAC;KAC/B;CACF"}
|
|
@@ -0,0 +1,130 @@
|
|
|
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 { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
import { QdsAccordionItem } from '../qds-accordion-item/qds-accordion-item.js';
|
|
11
|
+
/**
|
|
12
|
+
* A stack of `qds-accordion-item` sections.
|
|
13
|
+
*
|
|
14
|
+
* Adds two things the items cannot do alone: `exclusive`, which keeps at most one
|
|
15
|
+
* item open, and arrow-key movement between headings (Up, Down, Home, End), as
|
|
16
|
+
* the ARIA accordion pattern recommends. Tab still moves through the headings
|
|
17
|
+
* and into open panels as usual.
|
|
18
|
+
*
|
|
19
|
+
* The open state lives on each item, so it is rendered correctly from the
|
|
20
|
+
* server. `exclusive` holds however an item opens — by the user, from code, or
|
|
21
|
+
* in markup; when markup opens several, the first stays open.
|
|
22
|
+
*
|
|
23
|
+
* @element qds-accordion
|
|
24
|
+
*
|
|
25
|
+
* @slot - The `qds-accordion-item` sections.
|
|
26
|
+
*
|
|
27
|
+
* @csspart base - The wrapper around the items.
|
|
28
|
+
*
|
|
29
|
+
* @cssprop [--qds-component-accordion-border-width] - Divider thickness, including the top border.
|
|
30
|
+
* @cssprop [--qds-component-accordion-color-border-rest] - Divider color.
|
|
31
|
+
*/
|
|
32
|
+
let QdsAccordion = class QdsAccordion extends QdsElement {
|
|
33
|
+
static { this.styles = [
|
|
34
|
+
QdsElement.baseStyles,
|
|
35
|
+
css `
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
border-block-start: var(--qds-component-accordion-border-width, 0.0625rem) solid
|
|
39
|
+
var(--qds-component-accordion-color-border-rest, #e2e8f0);
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
]; }
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
/** Keeps at most one item open: opening one closes the others. */
|
|
46
|
+
this.exclusive = false;
|
|
47
|
+
this.#handleOpen = (event) => {
|
|
48
|
+
const opened = event.target;
|
|
49
|
+
// Only this accordion's own items: a nested accordion's events bubble here too.
|
|
50
|
+
if (opened.parentElement !== this)
|
|
51
|
+
return;
|
|
52
|
+
this.#enforceExclusive(opened);
|
|
53
|
+
};
|
|
54
|
+
this.#handleKeydown = (event) => {
|
|
55
|
+
// Alt+Up and the like belong to the browser.
|
|
56
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
57
|
+
return;
|
|
58
|
+
const items = this.#items.filter((item) => !item.disabled);
|
|
59
|
+
// Keydown from inside an item is retargeted to the item host here.
|
|
60
|
+
const current = items.indexOf(event.target);
|
|
61
|
+
if (current === -1)
|
|
62
|
+
return;
|
|
63
|
+
// Only act when focus is on a heading, not on something inside an open panel.
|
|
64
|
+
const focused = event.target.shadowRoot?.activeElement;
|
|
65
|
+
if (focused?.id !== 'trigger')
|
|
66
|
+
return;
|
|
67
|
+
let next;
|
|
68
|
+
switch (event.key) {
|
|
69
|
+
case 'ArrowDown':
|
|
70
|
+
next = (current + 1) % items.length;
|
|
71
|
+
break;
|
|
72
|
+
case 'ArrowUp':
|
|
73
|
+
next = (current - 1 + items.length) % items.length;
|
|
74
|
+
break;
|
|
75
|
+
case 'Home':
|
|
76
|
+
next = 0;
|
|
77
|
+
break;
|
|
78
|
+
case 'End':
|
|
79
|
+
next = items.length - 1;
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
items[next].focus();
|
|
86
|
+
};
|
|
87
|
+
this.addEventListener('qds-accordion-item-opened', this.#handleOpen);
|
|
88
|
+
this.addEventListener('keydown', this.#handleKeydown);
|
|
89
|
+
}
|
|
90
|
+
get #items() {
|
|
91
|
+
return [...this.querySelectorAll(':scope > qds-accordion-item')];
|
|
92
|
+
}
|
|
93
|
+
firstUpdated() {
|
|
94
|
+
// Items opened in markup may have upgraded before this element was
|
|
95
|
+
// listening, so check once everything has rendered.
|
|
96
|
+
void this.updateComplete.then(() => this.#enforceExclusive());
|
|
97
|
+
}
|
|
98
|
+
updated(changed) {
|
|
99
|
+
if (changed.has('exclusive') && this.hasUpdated)
|
|
100
|
+
this.#enforceExclusive();
|
|
101
|
+
}
|
|
102
|
+
/** Close every item but `keep` — by default, the first open one. */
|
|
103
|
+
#enforceExclusive(keep) {
|
|
104
|
+
if (!this.exclusive)
|
|
105
|
+
return;
|
|
106
|
+
const items = this.#items;
|
|
107
|
+
const kept = keep ?? items.find((item) => item.open);
|
|
108
|
+
for (const item of items) {
|
|
109
|
+
// Set directly rather than through a click, so closing the others does not
|
|
110
|
+
// fire qds-close for changes the user did not make.
|
|
111
|
+
if (item !== kept)
|
|
112
|
+
item.open = false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
#handleOpen;
|
|
116
|
+
#handleKeydown;
|
|
117
|
+
render() {
|
|
118
|
+
// On slotchange too: an item added later with `open` already set does not
|
|
119
|
+
// announce itself, and is reconciled here the same way as initial markup.
|
|
120
|
+
return html `<div part="base"><slot @slotchange=${() => this.#enforceExclusive()}></slot></div>`;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
__decorate([
|
|
124
|
+
property({ type: Boolean, reflect: true })
|
|
125
|
+
], QdsAccordion.prototype, "exclusive", void 0);
|
|
126
|
+
QdsAccordion = __decorate([
|
|
127
|
+
customElement('qds-accordion')
|
|
128
|
+
], QdsAccordion);
|
|
129
|
+
export { QdsAccordion };
|
|
130
|
+
//# sourceMappingURL=qds-accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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W,CAAC,IAAI,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC5E,CAAC;IAED,oEAAoE;IACpE,iBAAiB,CAAC,IAAuB;QACvC,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,2EAA2E;YAC3E,oDAAoD;YACpD,IAAI,IAAI,KAAK,IAAI;gBAAE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACvC,CAAC;IACH,CAAC;IAED,WAAW,CAKT;IAEF,cAAc,CAgCZ;IAEO,MAAM;QACb,0EAA0E;QAC1E,0EAA0E;QAC1E,OAAO,IAAI,CAAA,sCAAsC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;IAClG,CAAC;;AA/ED;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACzB;AAdP,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA8FxB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
export type QdsAccordionItemHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
|
+
/**
|
|
5
|
+
* One collapsible section of a `qds-accordion`.
|
|
6
|
+
*
|
|
7
|
+
* Follows the ARIA accordion pattern: a heading wrapping a button that reports
|
|
8
|
+
* `aria-expanded`, and a panel labelled by that button. The heading level is
|
|
9
|
+
* configurable because it has to fit the outline of the page around it — an
|
|
10
|
+
* accordion under an h2 needs h3 headings, not whatever the component assumed.
|
|
11
|
+
*
|
|
12
|
+
* A closed panel is `hidden="until-found"` rather than plainly hidden, so the
|
|
13
|
+
* browser's find-in-page can search collapsed content and opens the item when
|
|
14
|
+
* it finds a match. Where that is not supported it behaves as `hidden`.
|
|
15
|
+
*
|
|
16
|
+
* Works on its own as a single disclosure, too.
|
|
17
|
+
*
|
|
18
|
+
* @element qds-accordion-item
|
|
19
|
+
*
|
|
20
|
+
* @slot - The panel content.
|
|
21
|
+
* @slot heading - The heading text, in place of the `heading` attribute when it needs markup.
|
|
22
|
+
*
|
|
23
|
+
* @fires {CustomEvent<void>} qds-open - Fired when the user opens the item.
|
|
24
|
+
* @fires {CustomEvent<void>} qds-close - Fired when the user closes the item.
|
|
25
|
+
*
|
|
26
|
+
* @csspart heading - The element carrying the heading role.
|
|
27
|
+
* @csspart trigger - The button that opens and closes the panel.
|
|
28
|
+
* @csspart icon - The chevron.
|
|
29
|
+
* @csspart panel - The collapsible region.
|
|
30
|
+
*
|
|
31
|
+
* @cssprop [--qds-component-accordion-border-width] - Divider thickness.
|
|
32
|
+
* @cssprop [--qds-component-accordion-duration] - Chevron rotation duration.
|
|
33
|
+
* @cssprop [--qds-component-accordion-color-border-rest] - Divider color.
|
|
34
|
+
* @cssprop [--qds-component-accordion-trigger-gap] - Space between the heading text and the chevron.
|
|
35
|
+
* @cssprop [--qds-component-accordion-trigger-padding-block] - Trigger vertical padding.
|
|
36
|
+
* @cssprop [--qds-component-accordion-trigger-padding-inline] - Trigger horizontal padding.
|
|
37
|
+
* @cssprop [--qds-component-accordion-trigger-font-size] - Heading size.
|
|
38
|
+
* @cssprop [--qds-component-accordion-trigger-font-weight] - Heading weight.
|
|
39
|
+
* @cssprop [--qds-component-accordion-trigger-line-height] - Heading line height.
|
|
40
|
+
* @cssprop [--qds-component-accordion-trigger-color-content-{state}] - Heading color: `rest`, `disabled`.
|
|
41
|
+
* @cssprop [--qds-component-accordion-trigger-color-background-hover] - Trigger fill under the pointer.
|
|
42
|
+
* @cssprop [--qds-component-accordion-panel-padding-block] - Panel vertical padding.
|
|
43
|
+
* @cssprop [--qds-component-accordion-panel-padding-inline] - Panel horizontal padding.
|
|
44
|
+
* @cssprop [--qds-component-accordion-panel-font-size] - Panel text size.
|
|
45
|
+
* @cssprop [--qds-component-accordion-panel-line-height] - Panel line height.
|
|
46
|
+
* @cssprop [--qds-component-accordion-panel-color-content-rest] - Panel text color.
|
|
47
|
+
*/
|
|
48
|
+
export declare class QdsAccordionItem extends QdsElement {
|
|
49
|
+
#private;
|
|
50
|
+
static shadowRootOptions: ShadowRootInit;
|
|
51
|
+
static styles: import("lit").CSSResult[];
|
|
52
|
+
/** Whether the panel is shown. */
|
|
53
|
+
get open(): boolean;
|
|
54
|
+
set open(open: boolean);
|
|
55
|
+
/** Prevents opening or closing, and takes the heading out of the tab order. */
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
/** The heading text. */
|
|
58
|
+
heading: string;
|
|
59
|
+
/** The heading level, to fit the page outline. */
|
|
60
|
+
headingLevel: QdsAccordionItemHeadingLevel;
|
|
61
|
+
render(): TemplateResult;
|
|
62
|
+
}
|
|
63
|
+
declare global {
|
|
64
|
+
interface HTMLElementTagNameMap {
|
|
65
|
+
'qds-accordion-item': QdsAccordionItem;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=qds-accordion-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-accordion-item.d.ts","sourceRoot":"","sources":["../../../src/components/qds-accordion-item/qds-accordion-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,4BAA4B,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBACa,gBAAiB,SAAQ,UAAU;;IAC9C,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAEF,OAAgB,MAAM,4BA0FpB;IAEF,kCAAkC;IAClC,IACI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,EAarB;IAID,+EAA+E;IAE/E,QAAQ,UAAS;IAEjB,wBAAwB;IAExB,OAAO,SAAM;IAEb,kDAAkD;IAElD,YAAY,EAAE,4BAA4B,CAAK;IAyBtC,MAAM,IAAI,cAAc;CA+BlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,gBAAgB,CAAC;KACxC;CACF"}
|
|
@@ -0,0 +1,247 @@
|
|
|
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, isServer, nothing } from 'lit';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
/**
|
|
11
|
+
* One collapsible section of a `qds-accordion`.
|
|
12
|
+
*
|
|
13
|
+
* Follows the ARIA accordion pattern: a heading wrapping a button that reports
|
|
14
|
+
* `aria-expanded`, and a panel labelled by that button. The heading level is
|
|
15
|
+
* configurable because it has to fit the outline of the page around it — an
|
|
16
|
+
* accordion under an h2 needs h3 headings, not whatever the component assumed.
|
|
17
|
+
*
|
|
18
|
+
* A closed panel is `hidden="until-found"` rather than plainly hidden, so the
|
|
19
|
+
* browser's find-in-page can search collapsed content and opens the item when
|
|
20
|
+
* it finds a match. Where that is not supported it behaves as `hidden`.
|
|
21
|
+
*
|
|
22
|
+
* Works on its own as a single disclosure, too.
|
|
23
|
+
*
|
|
24
|
+
* @element qds-accordion-item
|
|
25
|
+
*
|
|
26
|
+
* @slot - The panel content.
|
|
27
|
+
* @slot heading - The heading text, in place of the `heading` attribute when it needs markup.
|
|
28
|
+
*
|
|
29
|
+
* @fires {CustomEvent<void>} qds-open - Fired when the user opens the item.
|
|
30
|
+
* @fires {CustomEvent<void>} qds-close - Fired when the user closes the item.
|
|
31
|
+
*
|
|
32
|
+
* @csspart heading - The element carrying the heading role.
|
|
33
|
+
* @csspart trigger - The button that opens and closes the panel.
|
|
34
|
+
* @csspart icon - The chevron.
|
|
35
|
+
* @csspart panel - The collapsible region.
|
|
36
|
+
*
|
|
37
|
+
* @cssprop [--qds-component-accordion-border-width] - Divider thickness.
|
|
38
|
+
* @cssprop [--qds-component-accordion-duration] - Chevron rotation duration.
|
|
39
|
+
* @cssprop [--qds-component-accordion-color-border-rest] - Divider color.
|
|
40
|
+
* @cssprop [--qds-component-accordion-trigger-gap] - Space between the heading text and the chevron.
|
|
41
|
+
* @cssprop [--qds-component-accordion-trigger-padding-block] - Trigger vertical padding.
|
|
42
|
+
* @cssprop [--qds-component-accordion-trigger-padding-inline] - Trigger horizontal padding.
|
|
43
|
+
* @cssprop [--qds-component-accordion-trigger-font-size] - Heading size.
|
|
44
|
+
* @cssprop [--qds-component-accordion-trigger-font-weight] - Heading weight.
|
|
45
|
+
* @cssprop [--qds-component-accordion-trigger-line-height] - Heading line height.
|
|
46
|
+
* @cssprop [--qds-component-accordion-trigger-color-content-{state}] - Heading color: `rest`, `disabled`.
|
|
47
|
+
* @cssprop [--qds-component-accordion-trigger-color-background-hover] - Trigger fill under the pointer.
|
|
48
|
+
* @cssprop [--qds-component-accordion-panel-padding-block] - Panel vertical padding.
|
|
49
|
+
* @cssprop [--qds-component-accordion-panel-padding-inline] - Panel horizontal padding.
|
|
50
|
+
* @cssprop [--qds-component-accordion-panel-font-size] - Panel text size.
|
|
51
|
+
* @cssprop [--qds-component-accordion-panel-line-height] - Panel line height.
|
|
52
|
+
* @cssprop [--qds-component-accordion-panel-color-content-rest] - Panel text color.
|
|
53
|
+
*/
|
|
54
|
+
let QdsAccordionItem = class QdsAccordionItem extends QdsElement {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
this.#open = false;
|
|
58
|
+
/** Prevents opening or closing, and takes the heading out of the tab order. */
|
|
59
|
+
this.disabled = false;
|
|
60
|
+
/** The heading text. */
|
|
61
|
+
this.heading = '';
|
|
62
|
+
/** The heading level, to fit the page outline. */
|
|
63
|
+
this.headingLevel = 3;
|
|
64
|
+
}
|
|
65
|
+
static { this.shadowRootOptions = {
|
|
66
|
+
...QdsElement.shadowRootOptions,
|
|
67
|
+
delegatesFocus: true,
|
|
68
|
+
}; }
|
|
69
|
+
static { this.styles = [
|
|
70
|
+
QdsElement.baseStyles,
|
|
71
|
+
css `
|
|
72
|
+
:host {
|
|
73
|
+
display: block;
|
|
74
|
+
font-family: var(--qds-typography-font-family-sans, inherit);
|
|
75
|
+
border-block-end: var(--qds-component-accordion-border-width, 0.0625rem) solid
|
|
76
|
+
var(--qds-component-accordion-color-border-rest, #e2e8f0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.heading {
|
|
80
|
+
margin: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
button {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: space-between;
|
|
87
|
+
gap: var(--qds-component-accordion-trigger-gap, 0.75rem);
|
|
88
|
+
width: 100%;
|
|
89
|
+
margin: 0;
|
|
90
|
+
padding: var(--qds-component-accordion-trigger-padding-block, 0.75rem)
|
|
91
|
+
var(--qds-component-accordion-trigger-padding-inline, 0.5rem);
|
|
92
|
+
|
|
93
|
+
font: inherit;
|
|
94
|
+
font-size: var(--qds-component-accordion-trigger-font-size, 1rem);
|
|
95
|
+
font-weight: var(--qds-component-accordion-trigger-font-weight, 500);
|
|
96
|
+
line-height: var(--qds-component-accordion-trigger-line-height, 1.375);
|
|
97
|
+
text-align: start;
|
|
98
|
+
color: var(--qds-component-accordion-trigger-color-content-rest, #0f172a);
|
|
99
|
+
|
|
100
|
+
background: none;
|
|
101
|
+
border: 0;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
button:where(:hover) {
|
|
106
|
+
background-color: var(--qds-component-accordion-trigger-color-background-hover, #f1f5f9);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
button:focus-visible {
|
|
110
|
+
outline: var(--_focus-ring);
|
|
111
|
+
outline-offset: -0.125rem;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
button:disabled {
|
|
115
|
+
color: var(--qds-component-accordion-trigger-color-content-disabled, #64748b);
|
|
116
|
+
background: none;
|
|
117
|
+
cursor: not-allowed;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.icon {
|
|
121
|
+
flex: none;
|
|
122
|
+
width: 1em;
|
|
123
|
+
height: 1em;
|
|
124
|
+
transition: rotate var(--qds-component-accordion-duration, 120ms);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([open]) .icon {
|
|
128
|
+
rotate: 180deg;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.panel {
|
|
132
|
+
padding: 0 var(--qds-component-accordion-panel-padding-inline, 0.5rem)
|
|
133
|
+
var(--qds-component-accordion-panel-padding-block, 0.75rem);
|
|
134
|
+
font-size: var(--qds-component-accordion-panel-font-size, 0.875rem);
|
|
135
|
+
line-height: var(--qds-component-accordion-panel-line-height, 1.5);
|
|
136
|
+
color: var(--qds-component-accordion-panel-color-content-rest, #0f172a);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* until-found panels are hidden with content-visibility rather than
|
|
141
|
+
* display:none, so they keep their padding box unless it is removed.
|
|
142
|
+
*/
|
|
143
|
+
.panel[hidden] {
|
|
144
|
+
padding: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@media (prefers-reduced-motion: reduce) {
|
|
148
|
+
.icon {
|
|
149
|
+
transition: none;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@media (forced-colors: active) {
|
|
154
|
+
button:disabled {
|
|
155
|
+
color: GrayText;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
`,
|
|
159
|
+
]; }
|
|
160
|
+
/** Whether the panel is shown. */
|
|
161
|
+
get open() {
|
|
162
|
+
return this.#open;
|
|
163
|
+
}
|
|
164
|
+
set open(open) {
|
|
165
|
+
const old = this.#open;
|
|
166
|
+
this.#open = open;
|
|
167
|
+
this.requestUpdate('open', old);
|
|
168
|
+
// Announced from the setter, synchronously, so that qds-accordion can enforce
|
|
169
|
+
// exclusive however the item opened — a click or code — and in the order
|
|
170
|
+
// items were opened: when two open in one tick, the last one wins.
|
|
171
|
+
// Not before the first render: the open state in markup is reconciled by the
|
|
172
|
+
// accordion itself, keeping the first, as native exclusive <details> does.
|
|
173
|
+
// qds-open is the public event, and only fires for the user.
|
|
174
|
+
if (open && !old && this.hasUpdated && !isServer) {
|
|
175
|
+
this.dispatchEvent(new Event('qds-accordion-item-opened', { bubbles: true }));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
#open;
|
|
179
|
+
#setOpen(open) {
|
|
180
|
+
if (open === this.open)
|
|
181
|
+
return;
|
|
182
|
+
this.open = open;
|
|
183
|
+
this.dispatchEvent(new CustomEvent(open ? 'qds-open' : 'qds-close', { bubbles: true, composed: true }));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Find-in-page matched text in the collapsed panel. The browser has already
|
|
187
|
+
* revealed it; mirror that into `open` so the item's state and aria-expanded
|
|
188
|
+
* agree. Listened for on the panel itself: beforematch is not composed, so it
|
|
189
|
+
* never reaches the host.
|
|
190
|
+
*/
|
|
191
|
+
#handleBeforeMatch() {
|
|
192
|
+
this.#setOpen(true);
|
|
193
|
+
}
|
|
194
|
+
#handleClick() {
|
|
195
|
+
if (this.disabled)
|
|
196
|
+
return;
|
|
197
|
+
this.#setOpen(!this.open);
|
|
198
|
+
}
|
|
199
|
+
render() {
|
|
200
|
+
return html `
|
|
201
|
+
<div class="heading" part="heading" role="heading" aria-level=${this.headingLevel}>
|
|
202
|
+
<button
|
|
203
|
+
id="trigger"
|
|
204
|
+
part="trigger"
|
|
205
|
+
type="button"
|
|
206
|
+
aria-expanded=${String(this.open)}
|
|
207
|
+
aria-controls="panel"
|
|
208
|
+
?disabled=${this.disabled}
|
|
209
|
+
@click=${this.#handleClick}
|
|
210
|
+
>
|
|
211
|
+
<slot name="heading">${this.heading}</slot>
|
|
212
|
+
<svg class="icon" part="icon" viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
|
|
213
|
+
<polyline points="4 6 8 10 12 6"></polyline>
|
|
214
|
+
</svg>
|
|
215
|
+
</button>
|
|
216
|
+
</div>
|
|
217
|
+
<div
|
|
218
|
+
id="panel"
|
|
219
|
+
class="panel"
|
|
220
|
+
part="panel"
|
|
221
|
+
role="region"
|
|
222
|
+
aria-labelledby="trigger"
|
|
223
|
+
hidden=${this.open ? nothing : 'until-found'}
|
|
224
|
+
@beforematch=${this.#handleBeforeMatch}
|
|
225
|
+
>
|
|
226
|
+
<slot></slot>
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: Boolean, reflect: true })
|
|
233
|
+
], QdsAccordionItem.prototype, "open", null);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: Boolean, reflect: true })
|
|
236
|
+
], QdsAccordionItem.prototype, "disabled", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property()
|
|
239
|
+
], QdsAccordionItem.prototype, "heading", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property({ type: Number, attribute: 'heading-level' })
|
|
242
|
+
], QdsAccordionItem.prototype, "headingLevel", void 0);
|
|
243
|
+
QdsAccordionItem = __decorate([
|
|
244
|
+
customElement('qds-accordion-item')
|
|
245
|
+
], QdsAccordionItem);
|
|
246
|
+
export { QdsAccordionItem };
|
|
247
|
+
//# sourceMappingURL=qds-accordion-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-accordion-item.js","sourceRoot":"","sources":["../../../src/components/qds-accordion-item/qds-accordion-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QAuHL,UAAK,GAAG,KAAK,CAAC;QAEd,+EAA+E;QAE/E,aAAQ,GAAG,KAAK,CAAC;QAEjB,wBAAwB;QAExB,YAAO,GAAG,EAAE,CAAC;QAEb,kDAAkD;QAElD,iBAAY,GAAiC,CAAC,CAAC;IAwDjD,CAAC;aA1LiB,sBAAiB,GAAmB;QAClD,GAAG,UAAU,CAAC,iBAAiB;QAC/B,cAAc,EAAE,IAAI;KACrB,AAHgC,CAG/B;aAEc,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;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CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;sEACuD,IAAI,CAAC,YAAY;;;;;0BAK7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;sBAErB,IAAI,CAAC,QAAQ;mBAChB,IAAI,CAAC,YAAY;;iCAEH,IAAI,CAAC,OAAO;;;;;;;;;;;;iBAY5B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;uBAC7B,IAAI,CAAC,kBAAkB;;;;KAIzC,CAAC;IACJ,CAAC;;AAtFD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAG1C;AAqBD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAC1B;AAIjB;IADC,QAAQ,EAAE;iDACE;AAIb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;sDACR;AAnIpC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA2L5B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
export type QdsButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
4
|
+
export type QdsButtonSize = 'sm' | 'md' | 'lg';
|
|
5
|
+
export type QdsButtonType = 'button' | 'submit' | 'reset';
|
|
6
|
+
/**
|
|
7
|
+
* A button.
|
|
8
|
+
*
|
|
9
|
+
* Every visual property resolves through the component tier of the token system,
|
|
10
|
+
* so `--qds-component-button-*` is simultaneously the token API and the styling
|
|
11
|
+
* API — overriding one of those variables is the supported way to restyle a
|
|
12
|
+
* button, and it is the same variable the design tokens define.
|
|
13
|
+
*
|
|
14
|
+
* When it submits a form, `event.submitter` is not the `qds-button` itself: a
|
|
15
|
+
* custom element cannot be a submitter, so it submits through a temporary native
|
|
16
|
+
* button carrying its `name` and `value`, which exists only while the submit
|
|
17
|
+
* event is being dispatched. Read `event.submitter.value` (or
|
|
18
|
+
* `new FormData(form, event.submitter)`) inside the submit handler, and give
|
|
19
|
+
* buttons distinct values to tell them apart.
|
|
20
|
+
*
|
|
21
|
+
* @element qds-button
|
|
22
|
+
*
|
|
23
|
+
* @slot - The button label.
|
|
24
|
+
* @slot start - Content before the label, typically an icon.
|
|
25
|
+
* @slot end - Content after the label, typically an icon.
|
|
26
|
+
*
|
|
27
|
+
* @fires {CustomEvent<void>} qds-click - Fired on activation. Not fired when
|
|
28
|
+
* disabled or loading. Prefer this over listening for `click`, which a disabled
|
|
29
|
+
* host can still receive.
|
|
30
|
+
*
|
|
31
|
+
* @csspart button - The native button element.
|
|
32
|
+
* @csspart label - The wrapper around the default slot.
|
|
33
|
+
*
|
|
34
|
+
* @cssprop [--qds-component-button-border-radius] - Corner radius.
|
|
35
|
+
* @cssprop [--qds-component-button-border-width] - Border thickness.
|
|
36
|
+
* @cssprop [--qds-component-button-font-weight] - Label weight.
|
|
37
|
+
* @cssprop [--qds-component-button-duration] - State transition duration.
|
|
38
|
+
* @cssprop [--qds-component-button-{variant}-color-background-{state}] - Background per variant and state.
|
|
39
|
+
* @cssprop [--qds-component-button-{variant}-color-content-{state}] - Label color per variant and state.
|
|
40
|
+
* @cssprop [--qds-component-button-{variant}-color-border-{state}] - Border color per variant and state.
|
|
41
|
+
* @cssprop [--qds-component-button-{size}-padding-block] - Vertical padding per size.
|
|
42
|
+
* @cssprop [--qds-component-button-{size}-padding-inline] - Horizontal padding per size.
|
|
43
|
+
*/
|
|
44
|
+
export declare class QdsButton extends QdsElement {
|
|
45
|
+
#private;
|
|
46
|
+
/**
|
|
47
|
+
* `delegatesFocus` makes the host focusable by forwarding focus to the inner
|
|
48
|
+
* button, so `qds-button.focus()` and tab order behave like a native button
|
|
49
|
+
* without the host needing its own tabindex.
|
|
50
|
+
*/
|
|
51
|
+
static shadowRootOptions: ShadowRootInit;
|
|
52
|
+
/**
|
|
53
|
+
* Form association is what lets a button inside shadow DOM submit the form
|
|
54
|
+
* around it. `attachInternals().form` finds the containing form across the
|
|
55
|
+
* shadow boundary, which `HTMLFormElement`'s own logic cannot do — a plain
|
|
56
|
+
* shadow-DOM button silently fails to submit.
|
|
57
|
+
*/
|
|
58
|
+
static formAssociated: boolean;
|
|
59
|
+
static styles: import("lit").CSSResult[];
|
|
60
|
+
/** Visual emphasis. */
|
|
61
|
+
variant: QdsButtonVariant;
|
|
62
|
+
/** Control size. */
|
|
63
|
+
size: QdsButtonSize;
|
|
64
|
+
/** Behavior within a form. */
|
|
65
|
+
type: QdsButtonType;
|
|
66
|
+
/** Prevents interaction and removes the button from the tab order. */
|
|
67
|
+
disabled: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Shows a spinner and blocks activation, while keeping the button focusable so
|
|
70
|
+
* focus is not lost mid-interaction.
|
|
71
|
+
*/
|
|
72
|
+
loading: boolean;
|
|
73
|
+
/** Stretches the button to fill its container. */
|
|
74
|
+
fullWidth: boolean;
|
|
75
|
+
/** Accessible name, for when the button has no text (an icon-only button). */
|
|
76
|
+
label: string | null;
|
|
77
|
+
/** Submitted as the name of this button's entry when it submits a form. */
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* Submitted with `name` when this button submits a form, and reported as the
|
|
81
|
+
* dialog's `returnValue` when it submits a `<form method="dialog">`.
|
|
82
|
+
*/
|
|
83
|
+
value: string;
|
|
84
|
+
constructor();
|
|
85
|
+
render(): TemplateResult;
|
|
86
|
+
}
|
|
87
|
+
declare global {
|
|
88
|
+
interface HTMLElementTagNameMap {
|
|
89
|
+
'qds-button': QdsButton;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=qds-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-button.d.ts","sourceR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