@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,76 @@
|
|
|
1
|
+
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
export type QdsModalSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
/**
|
|
5
|
+
* A modal dialog.
|
|
6
|
+
*
|
|
7
|
+
* Built on the native `<dialog>` and `showModal()`, which is what provides the
|
|
8
|
+
* hard parts: the dialog renders in the top layer above everything, the rest of
|
|
9
|
+
* the page becomes inert (unreachable by Tab, click, or screen reader), focus
|
|
10
|
+
* moves into the dialog on open and returns to where it was on close, and
|
|
11
|
+
* Escape closes it. None of that is reimplemented here.
|
|
12
|
+
*
|
|
13
|
+
* Escape always closes the dialog. Clicking the backdrop does only with
|
|
14
|
+
* `light-dismiss`, since a stray click should not throw away a half-filled form.
|
|
15
|
+
*
|
|
16
|
+
* @element qds-modal
|
|
17
|
+
*
|
|
18
|
+
* @slot - The body.
|
|
19
|
+
* @slot heading - The title, in place of the `heading` attribute when it needs markup.
|
|
20
|
+
* @slot footer - Actions, typically buttons, aligned to the inline end.
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent<void>} qds-open - Fired after the dialog opens.
|
|
23
|
+
* @fires {CustomEvent<{ returnValue: string }>} qds-close - Fired after the
|
|
24
|
+
* dialog closes, however it was closed. `returnValue` is the value passed to
|
|
25
|
+
* `close()`, or the `value` of the `<form method="dialog">` button that closed it.
|
|
26
|
+
*
|
|
27
|
+
* @csspart dialog - The native dialog element.
|
|
28
|
+
* @csspart header - The row holding the heading and the close button.
|
|
29
|
+
* @csspart heading - The heading.
|
|
30
|
+
* @csspart close - The close button.
|
|
31
|
+
* @csspart body - The wrapper around the default slot.
|
|
32
|
+
*
|
|
33
|
+
* @cssprop [--qds-component-modal-padding] - Inner padding.
|
|
34
|
+
* @cssprop [--qds-component-modal-gap] - Space between the header, body, and footer.
|
|
35
|
+
* @cssprop [--qds-component-modal-border-radius] - Corner radius.
|
|
36
|
+
* @cssprop [--qds-component-modal-border-width] - Border thickness.
|
|
37
|
+
* @cssprop [--qds-component-modal-box-shadow] - Shadow.
|
|
38
|
+
* @cssprop [--qds-component-modal-duration] - Open animation duration.
|
|
39
|
+
* @cssprop [--qds-component-modal-color-background-rest] - Fill.
|
|
40
|
+
* @cssprop [--qds-component-modal-color-border-rest] - Border color.
|
|
41
|
+
* @cssprop [--qds-component-modal-color-content-rest] - Text color.
|
|
42
|
+
* @cssprop [--qds-component-modal-header-font-size] - Heading size.
|
|
43
|
+
* @cssprop [--qds-component-modal-header-font-weight] - Heading weight.
|
|
44
|
+
* @cssprop [--qds-component-modal-header-line-height] - Heading line height.
|
|
45
|
+
* @cssprop [--qds-component-modal-backdrop-color-background-rest] - Backdrop color.
|
|
46
|
+
* @cssprop [--qds-component-modal-backdrop-opacity] - Backdrop opacity.
|
|
47
|
+
* @cssprop [--qds-component-modal-{size}-max-width] - Maximum width per size.
|
|
48
|
+
*/
|
|
49
|
+
export declare class QdsModal extends QdsElement {
|
|
50
|
+
#private;
|
|
51
|
+
static styles: import("lit").CSSResult[];
|
|
52
|
+
/** Whether the dialog is open. Setting it opens or closes the dialog. */
|
|
53
|
+
open: boolean;
|
|
54
|
+
/** The title. Also the dialog's accessible name. */
|
|
55
|
+
heading: string;
|
|
56
|
+
/** Maximum width. */
|
|
57
|
+
size: QdsModalSize;
|
|
58
|
+
/** Closes the dialog when the backdrop is clicked, as well as on Escape. */
|
|
59
|
+
lightDismiss: boolean;
|
|
60
|
+
/** Accessible name for the close button. */
|
|
61
|
+
closeLabel: string;
|
|
62
|
+
private readonly dialog;
|
|
63
|
+
constructor();
|
|
64
|
+
/** Opens the dialog. */
|
|
65
|
+
show(): void;
|
|
66
|
+
/** Closes the dialog, reporting `returnValue` in the `qds-close` event. */
|
|
67
|
+
close(returnValue?: string): void;
|
|
68
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
69
|
+
render(): TemplateResult;
|
|
70
|
+
}
|
|
71
|
+
declare global {
|
|
72
|
+
interface HTMLElementTagNameMap {
|
|
73
|
+
'qds-modal': QdsModal;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=qds-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-modal.d.ts","sourceRoot":"","sources":["../../../src/components/qds-modal/qds-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGnF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,OAAgB,MAAM,4BAgJpB;IAEF,yEAAyE;IAEzE,IAAI,UAAS;IAEb,oDAAoD;IAEpD,OAAO,SAAM;IAEb,qBAAqB;IAErB,IAAI,EAAE,YAAY,CAAQ;IAE1B,4EAA4E;IAE5E,YAAY,UAAS;IAErB,4CAA4C;IAE5C,UAAU,SAAW;IAGrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;;IAO5C,wBAAwB;IACxB,IAAI,IAAI,IAAI;IAIZ,2EAA2E;IAC3E,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;cAQd,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAoFtD,MAAM,IAAI,cAAc;CA8BlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|
|
@@ -0,0 +1,362 @@
|
|
|
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, nothing } from 'lit';
|
|
8
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
/**
|
|
11
|
+
* A modal dialog.
|
|
12
|
+
*
|
|
13
|
+
* Built on the native `<dialog>` and `showModal()`, which is what provides the
|
|
14
|
+
* hard parts: the dialog renders in the top layer above everything, the rest of
|
|
15
|
+
* the page becomes inert (unreachable by Tab, click, or screen reader), focus
|
|
16
|
+
* moves into the dialog on open and returns to where it was on close, and
|
|
17
|
+
* Escape closes it. None of that is reimplemented here.
|
|
18
|
+
*
|
|
19
|
+
* Escape always closes the dialog. Clicking the backdrop does only with
|
|
20
|
+
* `light-dismiss`, since a stray click should not throw away a half-filled form.
|
|
21
|
+
*
|
|
22
|
+
* @element qds-modal
|
|
23
|
+
*
|
|
24
|
+
* @slot - The body.
|
|
25
|
+
* @slot heading - The title, in place of the `heading` attribute when it needs markup.
|
|
26
|
+
* @slot footer - Actions, typically buttons, aligned to the inline end.
|
|
27
|
+
*
|
|
28
|
+
* @fires {CustomEvent<void>} qds-open - Fired after the dialog opens.
|
|
29
|
+
* @fires {CustomEvent<{ returnValue: string }>} qds-close - Fired after the
|
|
30
|
+
* dialog closes, however it was closed. `returnValue` is the value passed to
|
|
31
|
+
* `close()`, or the `value` of the `<form method="dialog">` button that closed it.
|
|
32
|
+
*
|
|
33
|
+
* @csspart dialog - The native dialog element.
|
|
34
|
+
* @csspart header - The row holding the heading and the close button.
|
|
35
|
+
* @csspart heading - The heading.
|
|
36
|
+
* @csspart close - The close button.
|
|
37
|
+
* @csspart body - The wrapper around the default slot.
|
|
38
|
+
*
|
|
39
|
+
* @cssprop [--qds-component-modal-padding] - Inner padding.
|
|
40
|
+
* @cssprop [--qds-component-modal-gap] - Space between the header, body, and footer.
|
|
41
|
+
* @cssprop [--qds-component-modal-border-radius] - Corner radius.
|
|
42
|
+
* @cssprop [--qds-component-modal-border-width] - Border thickness.
|
|
43
|
+
* @cssprop [--qds-component-modal-box-shadow] - Shadow.
|
|
44
|
+
* @cssprop [--qds-component-modal-duration] - Open animation duration.
|
|
45
|
+
* @cssprop [--qds-component-modal-color-background-rest] - Fill.
|
|
46
|
+
* @cssprop [--qds-component-modal-color-border-rest] - Border color.
|
|
47
|
+
* @cssprop [--qds-component-modal-color-content-rest] - Text color.
|
|
48
|
+
* @cssprop [--qds-component-modal-header-font-size] - Heading size.
|
|
49
|
+
* @cssprop [--qds-component-modal-header-font-weight] - Heading weight.
|
|
50
|
+
* @cssprop [--qds-component-modal-header-line-height] - Heading line height.
|
|
51
|
+
* @cssprop [--qds-component-modal-backdrop-color-background-rest] - Backdrop color.
|
|
52
|
+
* @cssprop [--qds-component-modal-backdrop-opacity] - Backdrop opacity.
|
|
53
|
+
* @cssprop [--qds-component-modal-{size}-max-width] - Maximum width per size.
|
|
54
|
+
*/
|
|
55
|
+
let QdsModal = class QdsModal extends QdsElement {
|
|
56
|
+
static { this.styles = [
|
|
57
|
+
QdsElement.baseStyles,
|
|
58
|
+
css `
|
|
59
|
+
:host {
|
|
60
|
+
display: contents;
|
|
61
|
+
|
|
62
|
+
--_max-width: var(--qds-component-modal-md-max-width, 32rem);
|
|
63
|
+
--_padding: var(--qds-component-modal-padding, 1.5rem);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([size='sm']) {
|
|
67
|
+
--_max-width: var(--qds-component-modal-sm-max-width, 24rem);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host([size='lg']) {
|
|
71
|
+
--_max-width: var(--qds-component-modal-lg-max-width, 48rem);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
dialog {
|
|
75
|
+
width: calc(100% - 2 * var(--qds-spacing-400, 1rem));
|
|
76
|
+
max-width: var(--_max-width);
|
|
77
|
+
max-height: calc(100% - 2 * var(--qds-spacing-400, 1rem));
|
|
78
|
+
margin: auto;
|
|
79
|
+
padding: 0;
|
|
80
|
+
|
|
81
|
+
font-family: var(--qds-typography-font-family-sans, inherit);
|
|
82
|
+
color: var(--qds-component-modal-color-content-rest, #0f172a);
|
|
83
|
+
|
|
84
|
+
background-color: var(--qds-component-modal-color-background-rest, #f8fafc);
|
|
85
|
+
border: var(--qds-component-modal-border-width, 0.0625rem) solid
|
|
86
|
+
var(--qds-component-modal-color-border-rest, #e2e8f0);
|
|
87
|
+
border-radius: var(--qds-component-modal-border-radius, 0.5rem);
|
|
88
|
+
box-shadow: var(
|
|
89
|
+
--qds-component-modal-box-shadow,
|
|
90
|
+
0 0.375rem 1rem 0.0625rem rgb(15 23 42 / 0.2)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
/* Scrolling inside the dialog must not chain to the page behind it. */
|
|
94
|
+
overscroll-behavior: contain;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
dialog[open] {
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
animation: enter var(--qds-component-modal-duration, 200ms) ease-out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* ::backdrop inherits custom properties from the dialog, so the tokens
|
|
105
|
+
* reach it. The color and opacity are separate tokens, which is why the
|
|
106
|
+
* opacity is applied with color-mix rather than to the whole pseudo-element.
|
|
107
|
+
*/
|
|
108
|
+
dialog::backdrop {
|
|
109
|
+
background-color: color-mix(
|
|
110
|
+
in srgb,
|
|
111
|
+
var(--qds-component-modal-backdrop-color-background-rest, #020617)
|
|
112
|
+
calc(var(--qds-component-modal-backdrop-opacity, 0.5) * 100%),
|
|
113
|
+
transparent
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@keyframes enter {
|
|
118
|
+
from {
|
|
119
|
+
opacity: 0;
|
|
120
|
+
translate: 0 0.5rem;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.header {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: flex-start;
|
|
127
|
+
justify-content: space-between;
|
|
128
|
+
gap: var(--qds-component-modal-gap, 1rem);
|
|
129
|
+
padding: var(--_padding) var(--_padding) 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.heading {
|
|
133
|
+
margin: 0;
|
|
134
|
+
font-size: var(--qds-component-modal-header-font-size, 1.25rem);
|
|
135
|
+
font-weight: var(--qds-component-modal-header-font-weight, 600);
|
|
136
|
+
line-height: var(--qds-component-modal-header-line-height, 1.375);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.close {
|
|
140
|
+
display: inline-grid;
|
|
141
|
+
place-items: center;
|
|
142
|
+
flex: none;
|
|
143
|
+
width: 2rem;
|
|
144
|
+
height: 2rem;
|
|
145
|
+
margin: -0.25rem -0.5rem 0 0;
|
|
146
|
+
padding: 0;
|
|
147
|
+
|
|
148
|
+
color: inherit;
|
|
149
|
+
background: none;
|
|
150
|
+
border: 0;
|
|
151
|
+
border-radius: var(--qds-semantic-radius-default, 0.375rem);
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.close:hover {
|
|
156
|
+
background-color: var(--qds-semantic-color-background-subtle, #f1f5f9);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.close:focus-visible {
|
|
160
|
+
outline: var(--_focus-ring);
|
|
161
|
+
outline-offset: 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.close svg {
|
|
165
|
+
width: 1rem;
|
|
166
|
+
height: 1rem;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.body {
|
|
170
|
+
flex: 1;
|
|
171
|
+
min-height: 0;
|
|
172
|
+
overflow-y: auto;
|
|
173
|
+
padding: var(--qds-component-modal-gap, 1rem) var(--_padding);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* Unwrapped, like qds-card's regions: an empty footer slot is
|
|
178
|
+
* display: contents and takes no space at all.
|
|
179
|
+
*/
|
|
180
|
+
::slotted([slot='footer']) {
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-wrap: wrap;
|
|
183
|
+
justify-content: flex-end;
|
|
184
|
+
gap: var(--qds-spacing-200, 0.5rem);
|
|
185
|
+
padding: 0 var(--_padding) var(--_padding);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@media (prefers-reduced-motion: reduce) {
|
|
189
|
+
dialog[open] {
|
|
190
|
+
animation: none;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@media (forced-colors: active) {
|
|
195
|
+
dialog {
|
|
196
|
+
border-color: CanvasText;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
`,
|
|
200
|
+
]; }
|
|
201
|
+
constructor() {
|
|
202
|
+
super();
|
|
203
|
+
/** Whether the dialog is open. Setting it opens or closes the dialog. */
|
|
204
|
+
this.open = false;
|
|
205
|
+
/** The title. Also the dialog's accessible name. */
|
|
206
|
+
this.heading = '';
|
|
207
|
+
/** Maximum width. */
|
|
208
|
+
this.size = 'md';
|
|
209
|
+
/** Closes the dialog when the backdrop is clicked, as well as on Escape. */
|
|
210
|
+
this.lightDismiss = false;
|
|
211
|
+
/** Accessible name for the close button. */
|
|
212
|
+
this.closeLabel = 'Close';
|
|
213
|
+
/**
|
|
214
|
+
* `<form method="dialog">` closes the nearest ancestor dialog in its own tree.
|
|
215
|
+
* A form slotted into this component has none — the dialog is in the shadow
|
|
216
|
+
* root — so natively it would do nothing. Do what it would have done.
|
|
217
|
+
*/
|
|
218
|
+
this.#handleSubmit = (event) => {
|
|
219
|
+
const form = event.target;
|
|
220
|
+
if (form.method !== 'dialog' || form.closest('qds-modal') !== this)
|
|
221
|
+
return;
|
|
222
|
+
// Read now: a qds-button submits through a temporary submitter that is gone
|
|
223
|
+
// once the event has been dispatched.
|
|
224
|
+
const submitter = event.submitter;
|
|
225
|
+
const returnValue = submitter?.value ?? '';
|
|
226
|
+
// Decide after the event has reached every listener, as the native dialog
|
|
227
|
+
// does: one on the document runs after this one, and may still cancel. No
|
|
228
|
+
// preventDefault here — natively this form, with no dialog ancestor, does
|
|
229
|
+
// nothing anyway.
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
if (!event.defaultPrevented)
|
|
232
|
+
this.close(returnValue);
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
/** Whether the current press started outside the dialog box. */
|
|
236
|
+
this.#pressedOnBackdrop = false;
|
|
237
|
+
this.addEventListener('submit', this.#handleSubmit);
|
|
238
|
+
}
|
|
239
|
+
/** Opens the dialog. */
|
|
240
|
+
show() {
|
|
241
|
+
this.open = true;
|
|
242
|
+
}
|
|
243
|
+
/** Closes the dialog, reporting `returnValue` in the `qds-close` event. */
|
|
244
|
+
close(returnValue) {
|
|
245
|
+
if (!this.dialog?.open) {
|
|
246
|
+
this.open = false;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.dialog.close(returnValue);
|
|
250
|
+
}
|
|
251
|
+
updated(changed) {
|
|
252
|
+
if (!changed.has('open'))
|
|
253
|
+
return;
|
|
254
|
+
if (this.open && !this.dialog.open) {
|
|
255
|
+
// showModal, not show: only the modal form makes the page inert and
|
|
256
|
+
// renders in the top layer.
|
|
257
|
+
this.dialog.showModal();
|
|
258
|
+
this.dispatchEvent(new CustomEvent('qds-open', { bubbles: true, composed: true }));
|
|
259
|
+
}
|
|
260
|
+
else if (!this.open && this.dialog.open) {
|
|
261
|
+
this.dialog.close();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** The dialog closed, by Escape, a dialog form, close(), or `open = false`. */
|
|
265
|
+
#handleClose() {
|
|
266
|
+
this.open = false;
|
|
267
|
+
this.dispatchEvent(new CustomEvent('qds-close', {
|
|
268
|
+
detail: { returnValue: this.dialog.returnValue },
|
|
269
|
+
bubbles: true,
|
|
270
|
+
composed: true,
|
|
271
|
+
}));
|
|
272
|
+
this.dialog.returnValue = '';
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* `<form method="dialog">` closes the nearest ancestor dialog in its own tree.
|
|
276
|
+
* A form slotted into this component has none — the dialog is in the shadow
|
|
277
|
+
* root — so natively it would do nothing. Do what it would have done.
|
|
278
|
+
*/
|
|
279
|
+
#handleSubmit;
|
|
280
|
+
/** Whether the current press started outside the dialog box. */
|
|
281
|
+
#pressedOnBackdrop;
|
|
282
|
+
/**
|
|
283
|
+
* Whether a pointer event lies outside the dialog's box. The target alone
|
|
284
|
+
* cannot say: the dialog is also the target for a click on its own border,
|
|
285
|
+
* and for the release of a drag that started inside it.
|
|
286
|
+
*/
|
|
287
|
+
#isOutside(event) {
|
|
288
|
+
const box = this.dialog.getBoundingClientRect();
|
|
289
|
+
return (event.clientX < box.left ||
|
|
290
|
+
event.clientX > box.right ||
|
|
291
|
+
event.clientY < box.top ||
|
|
292
|
+
event.clientY > box.bottom);
|
|
293
|
+
}
|
|
294
|
+
#handlePointerDown(event) {
|
|
295
|
+
this.#pressedOnBackdrop = event.target === this.dialog && this.#isOutside(event);
|
|
296
|
+
}
|
|
297
|
+
#handleClick(event) {
|
|
298
|
+
// Both the press and the release must be on the backdrop: a text selection
|
|
299
|
+
// dragged out of the dialog ends with a click on it too.
|
|
300
|
+
const pressedOnBackdrop = this.#pressedOnBackdrop;
|
|
301
|
+
this.#pressedOnBackdrop = false;
|
|
302
|
+
if (this.lightDismiss &&
|
|
303
|
+
pressedOnBackdrop &&
|
|
304
|
+
event.target === this.dialog &&
|
|
305
|
+
this.#isOutside(event)) {
|
|
306
|
+
this.dialog.close();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
render() {
|
|
310
|
+
return html `
|
|
311
|
+
<dialog
|
|
312
|
+
part="dialog"
|
|
313
|
+
aria-labelledby="heading"
|
|
314
|
+
@close=${this.#handleClose}
|
|
315
|
+
@pointerdown=${this.#handlePointerDown}
|
|
316
|
+
@click=${this.#handleClick}
|
|
317
|
+
>
|
|
318
|
+
<div class="header" part="header">
|
|
319
|
+
<h2 id="heading" class="heading" part="heading">
|
|
320
|
+
<slot name="heading">${this.heading}</slot>
|
|
321
|
+
</h2>
|
|
322
|
+
<button
|
|
323
|
+
class="close"
|
|
324
|
+
part="close"
|
|
325
|
+
type="button"
|
|
326
|
+
aria-label=${this.closeLabel || nothing}
|
|
327
|
+
@click=${() => this.dialog.close()}
|
|
328
|
+
>
|
|
329
|
+
<svg viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round">
|
|
330
|
+
<path d="M4 4l8 8M12 4l-8 8"></path>
|
|
331
|
+
</svg>
|
|
332
|
+
</button>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="body" part="body"><slot></slot></div>
|
|
335
|
+
<slot name="footer"></slot>
|
|
336
|
+
</dialog>
|
|
337
|
+
`;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
__decorate([
|
|
341
|
+
property({ type: Boolean, reflect: true })
|
|
342
|
+
], QdsModal.prototype, "open", void 0);
|
|
343
|
+
__decorate([
|
|
344
|
+
property()
|
|
345
|
+
], QdsModal.prototype, "heading", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
property({ reflect: true })
|
|
348
|
+
], QdsModal.prototype, "size", void 0);
|
|
349
|
+
__decorate([
|
|
350
|
+
property({ type: Boolean, reflect: true, attribute: 'light-dismiss' })
|
|
351
|
+
], QdsModal.prototype, "lightDismiss", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ attribute: 'close-label' })
|
|
354
|
+
], QdsModal.prototype, "closeLabel", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
query('dialog')
|
|
357
|
+
], QdsModal.prototype, "dialog", void 0);
|
|
358
|
+
QdsModal = __decorate([
|
|
359
|
+
customElement('qds-modal')
|
|
360
|
+
], QdsModal);
|
|
361
|
+
export { QdsModal };
|
|
362
|
+
//# sourceMappingURL=qds-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-modal.js","sourceRoot":"","sources":["../../../src/components/qds-modal/qds-modal.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;aACtB,WAAM,GAAG;QACvB,UA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,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCAC9B;AAIb;IADC,QAAQ,EAAE;yCACE;AAIb;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sCACF;AAI1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;8CAClD;AAIrB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;4CAClB;AAGJ;IADhB,KAAK,CAAC,QAAQ,CAAC;wCAC4B;AAxKjC,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA+SpB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
export type QdsProgressBarVariant = 'primary' | 'success' | 'warning' | 'error';
|
|
4
|
+
/**
|
|
5
|
+
* Shows how far along a task is.
|
|
6
|
+
*
|
|
7
|
+
* Determinate when `value` is set, indeterminate when it is not — for work whose
|
|
8
|
+
* length is unknown. The indeterminate state is announced as busy with no
|
|
9
|
+
* percentage, rather than as 0%, which would claim the task had not started.
|
|
10
|
+
*
|
|
11
|
+
* Needs an accessible name: set `label` to say what is progressing ("Uploading
|
|
12
|
+
* report.pdf"). It is not shown visibly; put visible text beside the bar if
|
|
13
|
+
* sighted users need it too.
|
|
14
|
+
*
|
|
15
|
+
* @element qds-progress-bar
|
|
16
|
+
*
|
|
17
|
+
* @csspart track - The full-width background, carrying the progressbar role.
|
|
18
|
+
* @csspart indicator - The filled portion.
|
|
19
|
+
*
|
|
20
|
+
* @cssprop [--qds-component-progress-bar-height] - Bar thickness.
|
|
21
|
+
* @cssprop [--qds-component-progress-bar-border-radius] - Corner radius of the track and indicator.
|
|
22
|
+
* @cssprop [--qds-component-progress-bar-duration] - How long the indicator takes to move to a new value.
|
|
23
|
+
* @cssprop [--qds-component-progress-bar-color-background-rest] - Track color.
|
|
24
|
+
* @cssprop [--qds-component-progress-bar-{variant}-color-background-rest] - Indicator color per variant.
|
|
25
|
+
*/
|
|
26
|
+
export declare class QdsProgressBar extends QdsElement {
|
|
27
|
+
#private;
|
|
28
|
+
static styles: import("lit").CSSResult[];
|
|
29
|
+
/**
|
|
30
|
+
* Progress from 0 to `max`. Leave unset for an indeterminate bar. Values
|
|
31
|
+
* outside the range are clamped.
|
|
32
|
+
*/
|
|
33
|
+
value: number | null;
|
|
34
|
+
/** The value that means complete. */
|
|
35
|
+
max: number;
|
|
36
|
+
/** Accessible name: what is progressing. */
|
|
37
|
+
label: string;
|
|
38
|
+
/** Indicator color. */
|
|
39
|
+
variant: QdsProgressBarVariant;
|
|
40
|
+
render(): TemplateResult;
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
interface HTMLElementTagNameMap {
|
|
44
|
+
'qds-progress-bar': QdsProgressBar;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=qds-progress-bar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-progress-bar.d.ts","sourceRoot":"","sources":["../../../src/components/qds-progress-bar/qds-progress-bar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,cAAe,SAAQ,UAAU;;IAC5C,OAAgB,MAAM,4BAoFpB;IAEF;;;OAGG;IAEH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE5B,qCAAqC;IAErC,GAAG,SAAO;IAEV,4CAA4C;IAE5C,KAAK,SAAM;IAEX,uBAAuB;IAEvB,OAAO,EAAE,qBAAqB,CAAa;IASlC,MAAM,IAAI,cAAc;CAwBlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;CACF"}
|
|
@@ -0,0 +1,180 @@
|
|
|
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, nothing } from 'lit';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
10
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
11
|
+
/**
|
|
12
|
+
* Shows how far along a task is.
|
|
13
|
+
*
|
|
14
|
+
* Determinate when `value` is set, indeterminate when it is not — for work whose
|
|
15
|
+
* length is unknown. The indeterminate state is announced as busy with no
|
|
16
|
+
* percentage, rather than as 0%, which would claim the task had not started.
|
|
17
|
+
*
|
|
18
|
+
* Needs an accessible name: set `label` to say what is progressing ("Uploading
|
|
19
|
+
* report.pdf"). It is not shown visibly; put visible text beside the bar if
|
|
20
|
+
* sighted users need it too.
|
|
21
|
+
*
|
|
22
|
+
* @element qds-progress-bar
|
|
23
|
+
*
|
|
24
|
+
* @csspart track - The full-width background, carrying the progressbar role.
|
|
25
|
+
* @csspart indicator - The filled portion.
|
|
26
|
+
*
|
|
27
|
+
* @cssprop [--qds-component-progress-bar-height] - Bar thickness.
|
|
28
|
+
* @cssprop [--qds-component-progress-bar-border-radius] - Corner radius of the track and indicator.
|
|
29
|
+
* @cssprop [--qds-component-progress-bar-duration] - How long the indicator takes to move to a new value.
|
|
30
|
+
* @cssprop [--qds-component-progress-bar-color-background-rest] - Track color.
|
|
31
|
+
* @cssprop [--qds-component-progress-bar-{variant}-color-background-rest] - Indicator color per variant.
|
|
32
|
+
*/
|
|
33
|
+
let QdsProgressBar = class QdsProgressBar extends QdsElement {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
/**
|
|
37
|
+
* Progress from 0 to `max`. Leave unset for an indeterminate bar. Values
|
|
38
|
+
* outside the range are clamped.
|
|
39
|
+
*/
|
|
40
|
+
this.value = null;
|
|
41
|
+
/** The value that means complete. */
|
|
42
|
+
this.max = 100;
|
|
43
|
+
/** Accessible name: what is progressing. */
|
|
44
|
+
this.label = '';
|
|
45
|
+
/** Indicator color. */
|
|
46
|
+
this.variant = 'primary';
|
|
47
|
+
}
|
|
48
|
+
static { this.styles = [
|
|
49
|
+
QdsElement.baseStyles,
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: block;
|
|
53
|
+
|
|
54
|
+
--_fill: var(--qds-component-progress-bar-primary-color-background-rest, #2563eb);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([variant='success']) {
|
|
58
|
+
--_fill: var(--qds-component-progress-bar-success-color-background-rest, #059669);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([variant='warning']) {
|
|
62
|
+
--_fill: var(--qds-component-progress-bar-warning-color-background-rest, #d97706);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([variant='error']) {
|
|
66
|
+
--_fill: var(--qds-component-progress-bar-error-color-background-rest, #dc2626);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.track {
|
|
70
|
+
position: relative;
|
|
71
|
+
height: var(--qds-component-progress-bar-height, 0.5rem);
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
background-color: var(--qds-component-progress-bar-color-background-rest, #e2e8f0);
|
|
74
|
+
border-radius: var(--qds-component-progress-bar-border-radius, 9999px);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.indicator {
|
|
78
|
+
height: 100%;
|
|
79
|
+
background-color: var(--_fill);
|
|
80
|
+
border-radius: inherit;
|
|
81
|
+
transition: width var(--qds-component-progress-bar-duration, 200ms) ease-out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.indeterminate .indicator {
|
|
85
|
+
position: absolute;
|
|
86
|
+
width: 40%;
|
|
87
|
+
animation: slide 1.4s ease-in-out infinite;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Travels toward the inline end, so it reverses under RTL. */
|
|
91
|
+
@keyframes slide {
|
|
92
|
+
from {
|
|
93
|
+
inset-inline-start: -40%;
|
|
94
|
+
}
|
|
95
|
+
to {
|
|
96
|
+
inset-inline-start: 100%;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* Without motion an indeterminate bar has to say "working" some other way.
|
|
102
|
+
* A slow pulse across the whole track does, without anything travelling.
|
|
103
|
+
*/
|
|
104
|
+
@media (prefers-reduced-motion: reduce) {
|
|
105
|
+
.indicator {
|
|
106
|
+
transition: none;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.indeterminate .indicator {
|
|
110
|
+
inset-inline-start: 0;
|
|
111
|
+
width: 100%;
|
|
112
|
+
animation: pulse 2s ease-in-out infinite;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@keyframes pulse {
|
|
116
|
+
50% {
|
|
117
|
+
opacity: 0.4;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (forced-colors: active) {
|
|
123
|
+
.track {
|
|
124
|
+
border: 0.0625rem solid CanvasText;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.indicator {
|
|
128
|
+
background-color: Highlight;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`,
|
|
132
|
+
]; }
|
|
133
|
+
/** The value clamped to 0..max, or null when indeterminate. */
|
|
134
|
+
get #clamped() {
|
|
135
|
+
if (this.value === null || Number.isNaN(this.value))
|
|
136
|
+
return null;
|
|
137
|
+
const max = this.max > 0 ? this.max : 100;
|
|
138
|
+
return Math.min(Math.max(this.value, 0), max);
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
const value = this.#clamped;
|
|
142
|
+
const max = this.max > 0 ? this.max : 100;
|
|
143
|
+
const indeterminate = value === null;
|
|
144
|
+
return html `
|
|
145
|
+
<div
|
|
146
|
+
class=${indeterminate ? 'track indeterminate' : 'track'}
|
|
147
|
+
part="track"
|
|
148
|
+
role="progressbar"
|
|
149
|
+
aria-label=${this.label || nothing}
|
|
150
|
+
aria-valuemin="0"
|
|
151
|
+
aria-valuemax=${max}
|
|
152
|
+
aria-valuenow=${indeterminate ? nothing : value}
|
|
153
|
+
aria-busy=${indeterminate ? 'true' : nothing}
|
|
154
|
+
>
|
|
155
|
+
<div
|
|
156
|
+
class="indicator"
|
|
157
|
+
part="indicator"
|
|
158
|
+
style=${styleMap(indeterminate ? {} : { width: `${(value / max) * 100}%` })}
|
|
159
|
+
></div>
|
|
160
|
+
</div>
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Number })
|
|
166
|
+
], QdsProgressBar.prototype, "value", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
property({ type: Number })
|
|
169
|
+
], QdsProgressBar.prototype, "max", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
property()
|
|
172
|
+
], QdsProgressBar.prototype, "label", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
property({ reflect: true })
|
|
175
|
+
], QdsProgressBar.prototype, "variant", void 0);
|
|
176
|
+
QdsProgressBar = __decorate([
|
|
177
|
+
customElement('qds-progress-bar')
|
|
178
|
+
], QdsProgressBar);
|
|
179
|
+
export { QdsProgressBar };
|
|
180
|
+
//# sourceMappingURL=qds-progress-bar.js.map
|