@kodaris/krubble-components 1.0.31 → 1.0.32
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/breaking-changes.json +4 -0
- package/custom-elements.json +221 -15
- package/dist/dialog/dialog.d.ts +24 -1
- package/dist/dialog/dialog.d.ts.map +1 -1
- package/dist/dialog/dialog.js +93 -17
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/krubble-components.bundled.js +97 -22
- package/dist/krubble-components.bundled.js.map +1 -1
- package/dist/krubble-components.bundled.min.js +53 -28
- package/dist/krubble-components.bundled.min.js.map +1 -1
- package/dist/krubble-components.umd.js +97 -22
- package/dist/krubble-components.umd.js.map +1 -1
- package/dist/krubble-components.umd.min.js +68 -43
- package/dist/krubble-components.umd.min.js.map +1 -1
- package/dist/monaco/monaco.d.ts +35 -0
- package/dist/monaco/monaco.d.ts.map +1 -0
- package/dist/monaco/monaco.js +130 -0
- package/dist/monaco/monaco.js.map +1 -0
- package/package.json +14 -1
package/dist/dialog/dialog.js
CHANGED
|
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { LitElement, html, css } from 'lit';
|
|
8
|
-
import { customElement, state } from 'lit/decorators.js';
|
|
8
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
9
10
|
let KRDialogHeader = class KRDialogHeader extends LitElement {
|
|
10
11
|
render() {
|
|
11
12
|
return html `<slot></slot>`;
|
|
@@ -13,8 +14,11 @@ let KRDialogHeader = class KRDialogHeader extends LitElement {
|
|
|
13
14
|
};
|
|
14
15
|
KRDialogHeader.styles = css `
|
|
15
16
|
:host {
|
|
16
|
-
display:
|
|
17
|
-
padding:
|
|
17
|
+
display: flex;
|
|
18
|
+
padding: 0 24px;
|
|
19
|
+
align-items: center;
|
|
20
|
+
height: 64px;
|
|
21
|
+
flex-shrink: 0;
|
|
18
22
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -36,7 +40,9 @@ let KRDialogContent = class KRDialogContent extends LitElement {
|
|
|
36
40
|
KRDialogContent.styles = css `
|
|
37
41
|
:host {
|
|
38
42
|
display: block;
|
|
39
|
-
padding:
|
|
43
|
+
padding: 24px;
|
|
44
|
+
overflow: auto;
|
|
45
|
+
flex: 1 1 auto;
|
|
40
46
|
}
|
|
41
47
|
`;
|
|
42
48
|
KRDialogContent = __decorate([
|
|
@@ -51,7 +57,10 @@ let KRDialogFooter = class KRDialogFooter extends LitElement {
|
|
|
51
57
|
KRDialogFooter.styles = css `
|
|
52
58
|
:host {
|
|
53
59
|
display: flex;
|
|
54
|
-
padding:
|
|
60
|
+
padding: 0 24px;
|
|
61
|
+
align-items: center;
|
|
62
|
+
height: 64px;
|
|
63
|
+
flex-shrink: 0;
|
|
55
64
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
56
65
|
gap: 12px;
|
|
57
66
|
justify-content: flex-end;
|
|
@@ -102,18 +111,27 @@ export class KRDialogRef {
|
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
/**
|
|
105
|
-
* Generic dialog component that
|
|
114
|
+
* Generic dialog component that supports both declarative and programmatic usage.
|
|
115
|
+
*
|
|
116
|
+
* Declarative: place `<kr-dialog>` in HTML with slotted content and call `.open()` / `.close()`.
|
|
117
|
+
* Programmatic: use `KRDialog.open(Component, config)` to create and show a dialog.
|
|
106
118
|
*
|
|
107
119
|
* @element kr-dialog
|
|
120
|
+
*
|
|
121
|
+
* @slot - Default slot for declarative dialog content (kr-dialog-header, kr-dialog-content, kr-dialog-footer)
|
|
122
|
+
*
|
|
123
|
+
* @fires close - Fired when a declarative dialog is closed
|
|
108
124
|
*/
|
|
109
125
|
let KRDialog = class KRDialog extends LitElement {
|
|
110
126
|
constructor() {
|
|
111
127
|
super(...arguments);
|
|
112
128
|
this._dialogRef = null;
|
|
113
129
|
this._contentElement = null;
|
|
130
|
+
this.opened = false;
|
|
131
|
+
this.width = '560px';
|
|
114
132
|
this._handleDocumentKeyDown = (e) => {
|
|
115
133
|
if (e.key === 'Escape') {
|
|
116
|
-
this.
|
|
134
|
+
this.close();
|
|
117
135
|
}
|
|
118
136
|
};
|
|
119
137
|
}
|
|
@@ -121,11 +139,46 @@ let KRDialog = class KRDialog extends LitElement {
|
|
|
121
139
|
super.disconnectedCallback();
|
|
122
140
|
document.removeEventListener('keydown', this._handleDocumentKeyDown);
|
|
123
141
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
142
|
+
updated(changedProperties) {
|
|
143
|
+
super.updated(changedProperties);
|
|
144
|
+
if (changedProperties.has('opened')) {
|
|
145
|
+
if (this.opened) {
|
|
146
|
+
document.addEventListener('keydown', this._handleDocumentKeyDown);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
document.removeEventListener('keydown', this._handleDocumentKeyDown);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Opens the dialog (declarative mode).
|
|
155
|
+
*/
|
|
156
|
+
open() {
|
|
157
|
+
this.opened = true;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Closes the dialog.
|
|
161
|
+
* In programmatic mode (has _dialogRef), delegates to the dialog ref.
|
|
162
|
+
* In declarative mode, sets opened=false and dispatches close event.
|
|
163
|
+
*/
|
|
164
|
+
close() {
|
|
165
|
+
if (this._dialogRef) {
|
|
166
|
+
this._dialogRef.close(undefined);
|
|
167
|
+
return;
|
|
128
168
|
}
|
|
169
|
+
this.opened = false;
|
|
170
|
+
this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Opens a dialog programmatically by creating a component and injecting it.
|
|
174
|
+
*/
|
|
175
|
+
static open(component, config) {
|
|
176
|
+
// Only remove other programmatic dialogs (those with a _dialogRef)
|
|
177
|
+
document.querySelectorAll('kr-dialog').forEach((el) => {
|
|
178
|
+
if (el._dialogRef) {
|
|
179
|
+
el.remove();
|
|
180
|
+
}
|
|
181
|
+
});
|
|
129
182
|
const dialogRef = new KRDialogRef();
|
|
130
183
|
const dialog = document.createElement('kr-dialog');
|
|
131
184
|
dialogRef.setDialogElement(dialog);
|
|
@@ -137,20 +190,20 @@ let KRDialog = class KRDialog extends LitElement {
|
|
|
137
190
|
content.data = config.data;
|
|
138
191
|
}
|
|
139
192
|
dialog._contentElement = content;
|
|
193
|
+
dialog.opened = true;
|
|
140
194
|
document.body.appendChild(dialog);
|
|
141
|
-
document.addEventListener('keydown', dialog._handleDocumentKeyDown);
|
|
142
195
|
return dialogRef;
|
|
143
196
|
}
|
|
144
197
|
_handleBackdropClick(e) {
|
|
145
198
|
if (e.target.classList.contains('backdrop')) {
|
|
146
|
-
this.
|
|
199
|
+
this.close();
|
|
147
200
|
}
|
|
148
201
|
}
|
|
149
202
|
render() {
|
|
150
203
|
return html `
|
|
151
204
|
<div class="backdrop" @click=${this._handleBackdropClick}></div>
|
|
152
|
-
<div class="dialog">
|
|
153
|
-
${this._contentElement}
|
|
205
|
+
<div class="dialog" style=${styleMap({ width: this.width })}>
|
|
206
|
+
${this._contentElement ? this._contentElement : html `<slot></slot>`}
|
|
154
207
|
</div>
|
|
155
208
|
`;
|
|
156
209
|
}
|
|
@@ -160,11 +213,15 @@ KRDialog.styles = css `
|
|
|
160
213
|
position: fixed;
|
|
161
214
|
inset: 0;
|
|
162
215
|
z-index: 10000;
|
|
163
|
-
display:
|
|
216
|
+
display: none;
|
|
164
217
|
align-items: center;
|
|
165
218
|
justify-content: center;
|
|
166
219
|
}
|
|
167
220
|
|
|
221
|
+
:host([opened]) {
|
|
222
|
+
display: flex;
|
|
223
|
+
}
|
|
224
|
+
|
|
168
225
|
.backdrop {
|
|
169
226
|
position: absolute;
|
|
170
227
|
inset: 0;
|
|
@@ -178,13 +235,32 @@ KRDialog.styles = css `
|
|
|
178
235
|
border-radius: 12px;
|
|
179
236
|
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
|
|
180
237
|
max-height: 90vh;
|
|
238
|
+
overflow: hidden;
|
|
239
|
+
display: flex;
|
|
240
|
+
flex-direction: column;
|
|
241
|
+
width: 560px;
|
|
242
|
+
max-width: calc(100vw - 48px);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
::slotted(kr-dialog-header),
|
|
246
|
+
::slotted(kr-dialog-footer) {
|
|
247
|
+
flex-shrink: 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
::slotted(kr-dialog-content) {
|
|
251
|
+
flex: 1 1 auto;
|
|
181
252
|
overflow: auto;
|
|
182
|
-
min-width: 300px;
|
|
183
253
|
}
|
|
184
254
|
`;
|
|
185
255
|
__decorate([
|
|
186
256
|
state()
|
|
187
257
|
], KRDialog.prototype, "_contentElement", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
property({ type: Boolean, reflect: true })
|
|
260
|
+
], KRDialog.prototype, "opened", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
property({ type: String })
|
|
263
|
+
], KRDialog.prototype, "width", void 0);
|
|
188
264
|
KRDialog = __decorate([
|
|
189
265
|
customElement('kr-dialog')
|
|
190
266
|
], KRDialog);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EA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CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,SAAS,CAAC;IACnB,CAAC;IAQO,oBAAoB,CAAC,CAAQ;QACnC,IAAK,CAAC,CAAC,MAAsB,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA;qCACsB,IAAI,CAAC,oBAAoB;kCAC5B,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;UACvD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAA,eAAe;;KAEtE,CAAC;IACJ,CAAC;;AAlJe,eAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C3B,AA3CqB,CA2CpB;AAKM;IADP,KAAK,EAAE;iDAC0C;AAGlD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAC5B;AAGf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACX;AAvDL,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAoJpB"}
|
|
@@ -1364,6 +1364,12 @@ KRContextMenu = __decorate$c([
|
|
|
1364
1364
|
t$1('kr-context-menu')
|
|
1365
1365
|
], KRContextMenu);
|
|
1366
1366
|
|
|
1367
|
+
/**
|
|
1368
|
+
* @license
|
|
1369
|
+
* Copyright 2018 Google LLC
|
|
1370
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1371
|
+
*/const n="important",i=" !"+n,o$1=e$2(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"style"!==t$1.name||t$1.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`},"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:""):s[t]=e;}}return E}});
|
|
1372
|
+
|
|
1367
1373
|
var __decorate$b = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1368
1374
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1369
1375
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1377,8 +1383,11 @@ let KRDialogHeader = class KRDialogHeader extends i$2 {
|
|
|
1377
1383
|
};
|
|
1378
1384
|
KRDialogHeader.styles = i$5 `
|
|
1379
1385
|
:host {
|
|
1380
|
-
display:
|
|
1381
|
-
padding:
|
|
1386
|
+
display: flex;
|
|
1387
|
+
padding: 0 24px;
|
|
1388
|
+
align-items: center;
|
|
1389
|
+
height: 64px;
|
|
1390
|
+
flex-shrink: 0;
|
|
1382
1391
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
1383
1392
|
}
|
|
1384
1393
|
|
|
@@ -1399,7 +1408,9 @@ let KRDialogContent = class KRDialogContent extends i$2 {
|
|
|
1399
1408
|
KRDialogContent.styles = i$5 `
|
|
1400
1409
|
:host {
|
|
1401
1410
|
display: block;
|
|
1402
|
-
padding:
|
|
1411
|
+
padding: 24px;
|
|
1412
|
+
overflow: auto;
|
|
1413
|
+
flex: 1 1 auto;
|
|
1403
1414
|
}
|
|
1404
1415
|
`;
|
|
1405
1416
|
KRDialogContent = __decorate$b([
|
|
@@ -1413,7 +1424,10 @@ let KRDialogFooter = class KRDialogFooter extends i$2 {
|
|
|
1413
1424
|
KRDialogFooter.styles = i$5 `
|
|
1414
1425
|
:host {
|
|
1415
1426
|
display: flex;
|
|
1416
|
-
padding:
|
|
1427
|
+
padding: 0 24px;
|
|
1428
|
+
align-items: center;
|
|
1429
|
+
height: 64px;
|
|
1430
|
+
flex-shrink: 0;
|
|
1417
1431
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
1418
1432
|
gap: 12px;
|
|
1419
1433
|
justify-content: flex-end;
|
|
@@ -1463,18 +1477,27 @@ class KRDialogRef {
|
|
|
1463
1477
|
}
|
|
1464
1478
|
}
|
|
1465
1479
|
/**
|
|
1466
|
-
* Generic dialog component that
|
|
1480
|
+
* Generic dialog component that supports both declarative and programmatic usage.
|
|
1481
|
+
*
|
|
1482
|
+
* Declarative: place `<kr-dialog>` in HTML with slotted content and call `.open()` / `.close()`.
|
|
1483
|
+
* Programmatic: use `KRDialog.open(Component, config)` to create and show a dialog.
|
|
1467
1484
|
*
|
|
1468
1485
|
* @element kr-dialog
|
|
1486
|
+
*
|
|
1487
|
+
* @slot - Default slot for declarative dialog content (kr-dialog-header, kr-dialog-content, kr-dialog-footer)
|
|
1488
|
+
*
|
|
1489
|
+
* @fires close - Fired when a declarative dialog is closed
|
|
1469
1490
|
*/
|
|
1470
1491
|
let KRDialog = class KRDialog extends i$2 {
|
|
1471
1492
|
constructor() {
|
|
1472
1493
|
super(...arguments);
|
|
1473
1494
|
this._dialogRef = null;
|
|
1474
1495
|
this._contentElement = null;
|
|
1496
|
+
this.opened = false;
|
|
1497
|
+
this.width = '560px';
|
|
1475
1498
|
this._handleDocumentKeyDown = (e) => {
|
|
1476
1499
|
if (e.key === 'Escape') {
|
|
1477
|
-
this.
|
|
1500
|
+
this.close();
|
|
1478
1501
|
}
|
|
1479
1502
|
};
|
|
1480
1503
|
}
|
|
@@ -1482,11 +1505,46 @@ let KRDialog = class KRDialog extends i$2 {
|
|
|
1482
1505
|
super.disconnectedCallback();
|
|
1483
1506
|
document.removeEventListener('keydown', this._handleDocumentKeyDown);
|
|
1484
1507
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
if (
|
|
1488
|
-
|
|
1508
|
+
updated(changedProperties) {
|
|
1509
|
+
super.updated(changedProperties);
|
|
1510
|
+
if (changedProperties.has('opened')) {
|
|
1511
|
+
if (this.opened) {
|
|
1512
|
+
document.addEventListener('keydown', this._handleDocumentKeyDown);
|
|
1513
|
+
}
|
|
1514
|
+
else {
|
|
1515
|
+
document.removeEventListener('keydown', this._handleDocumentKeyDown);
|
|
1516
|
+
}
|
|
1489
1517
|
}
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Opens the dialog (declarative mode).
|
|
1521
|
+
*/
|
|
1522
|
+
open() {
|
|
1523
|
+
this.opened = true;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Closes the dialog.
|
|
1527
|
+
* In programmatic mode (has _dialogRef), delegates to the dialog ref.
|
|
1528
|
+
* In declarative mode, sets opened=false and dispatches close event.
|
|
1529
|
+
*/
|
|
1530
|
+
close() {
|
|
1531
|
+
if (this._dialogRef) {
|
|
1532
|
+
this._dialogRef.close(undefined);
|
|
1533
|
+
return;
|
|
1534
|
+
}
|
|
1535
|
+
this.opened = false;
|
|
1536
|
+
this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }));
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Opens a dialog programmatically by creating a component and injecting it.
|
|
1540
|
+
*/
|
|
1541
|
+
static open(component, config) {
|
|
1542
|
+
// Only remove other programmatic dialogs (those with a _dialogRef)
|
|
1543
|
+
document.querySelectorAll('kr-dialog').forEach((el) => {
|
|
1544
|
+
if (el._dialogRef) {
|
|
1545
|
+
el.remove();
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1490
1548
|
const dialogRef = new KRDialogRef();
|
|
1491
1549
|
const dialog = document.createElement('kr-dialog');
|
|
1492
1550
|
dialogRef.setDialogElement(dialog);
|
|
@@ -1498,20 +1556,20 @@ let KRDialog = class KRDialog extends i$2 {
|
|
|
1498
1556
|
content.data = config.data;
|
|
1499
1557
|
}
|
|
1500
1558
|
dialog._contentElement = content;
|
|
1559
|
+
dialog.opened = true;
|
|
1501
1560
|
document.body.appendChild(dialog);
|
|
1502
|
-
document.addEventListener('keydown', dialog._handleDocumentKeyDown);
|
|
1503
1561
|
return dialogRef;
|
|
1504
1562
|
}
|
|
1505
1563
|
_handleBackdropClick(e) {
|
|
1506
1564
|
if (e.target.classList.contains('backdrop')) {
|
|
1507
|
-
this.
|
|
1565
|
+
this.close();
|
|
1508
1566
|
}
|
|
1509
1567
|
}
|
|
1510
1568
|
render() {
|
|
1511
1569
|
return b `
|
|
1512
1570
|
<div class="backdrop" @click=${this._handleBackdropClick}></div>
|
|
1513
|
-
<div class="dialog">
|
|
1514
|
-
${this._contentElement}
|
|
1571
|
+
<div class="dialog" style=${o$1({ width: this.width })}>
|
|
1572
|
+
${this._contentElement ? this._contentElement : b `<slot></slot>`}
|
|
1515
1573
|
</div>
|
|
1516
1574
|
`;
|
|
1517
1575
|
}
|
|
@@ -1521,11 +1579,15 @@ KRDialog.styles = i$5 `
|
|
|
1521
1579
|
position: fixed;
|
|
1522
1580
|
inset: 0;
|
|
1523
1581
|
z-index: 10000;
|
|
1524
|
-
display:
|
|
1582
|
+
display: none;
|
|
1525
1583
|
align-items: center;
|
|
1526
1584
|
justify-content: center;
|
|
1527
1585
|
}
|
|
1528
1586
|
|
|
1587
|
+
:host([opened]) {
|
|
1588
|
+
display: flex;
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1529
1591
|
.backdrop {
|
|
1530
1592
|
position: absolute;
|
|
1531
1593
|
inset: 0;
|
|
@@ -1539,13 +1601,32 @@ KRDialog.styles = i$5 `
|
|
|
1539
1601
|
border-radius: 12px;
|
|
1540
1602
|
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
|
|
1541
1603
|
max-height: 90vh;
|
|
1604
|
+
overflow: hidden;
|
|
1605
|
+
display: flex;
|
|
1606
|
+
flex-direction: column;
|
|
1607
|
+
width: 560px;
|
|
1608
|
+
max-width: calc(100vw - 48px);
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
::slotted(kr-dialog-header),
|
|
1612
|
+
::slotted(kr-dialog-footer) {
|
|
1613
|
+
flex-shrink: 0;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
::slotted(kr-dialog-content) {
|
|
1617
|
+
flex: 1 1 auto;
|
|
1542
1618
|
overflow: auto;
|
|
1543
|
-
min-width: 300px;
|
|
1544
1619
|
}
|
|
1545
1620
|
`;
|
|
1546
1621
|
__decorate$b([
|
|
1547
1622
|
r$1()
|
|
1548
1623
|
], KRDialog.prototype, "_contentElement", void 0);
|
|
1624
|
+
__decorate$b([
|
|
1625
|
+
n$1({ type: Boolean, reflect: true })
|
|
1626
|
+
], KRDialog.prototype, "opened", void 0);
|
|
1627
|
+
__decorate$b([
|
|
1628
|
+
n$1({ type: String })
|
|
1629
|
+
], KRDialog.prototype, "width", void 0);
|
|
1549
1630
|
KRDialog = __decorate$b([
|
|
1550
1631
|
t$1('kr-dialog')
|
|
1551
1632
|
], KRDialog);
|
|
@@ -1863,12 +1944,6 @@ KRSnackbar = KRSnackbar_1 = __decorate$a([
|
|
|
1863
1944
|
t$1('kr-snackbar')
|
|
1864
1945
|
], KRSnackbar);
|
|
1865
1946
|
|
|
1866
|
-
/**
|
|
1867
|
-
* @license
|
|
1868
|
-
* Copyright 2018 Google LLC
|
|
1869
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
1870
|
-
*/const n="important",i=" !"+n,o$1=e$2(class extends i$1{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"style"!==t$1.name||t$1.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes("-")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`},"")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes("-")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r="string"==typeof e&&e.endsWith(i);t.includes("-")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:""):s[t]=e;}}return E}});
|
|
1871
|
-
|
|
1872
1947
|
var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
|
|
1873
1948
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1874
1949
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|