@lvl99dotcom/paintcanvas 0.5.0 → 0.7.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/README.md +2 -2
- package/dist/lib/brushes/configRanges/index.d.ts +17 -0
- package/dist/lib/brushes/configRanges/index.js +31 -1
- package/dist/lib/brushes/params/index.d.ts +2 -1
- package/dist/lib/brushes/params/index.js +7 -4
- package/dist/lib/brushes/types/index.d.ts +8 -0
- package/dist/lib/classes/Layer/index.d.ts +10 -0
- package/dist/lib/classes/Layer/index.js +15 -1
- package/dist/lib/classes/LayerAutosave/index.d.ts +9 -15
- package/dist/lib/classes/LayerAutosave/index.js +30 -43
- package/dist/lib/classes/LayerStack/index.d.ts +15 -0
- package/dist/lib/classes/LayerStack/index.js +26 -2
- package/dist/lib/classes/PaintCanvas/index.d.ts +36 -5
- package/dist/lib/classes/PaintCanvas/index.js +45 -14
- package/dist/lib/classes/PngEncoder/index.d.ts +41 -0
- package/dist/lib/classes/PngEncoder/index.js +104 -0
- package/dist/lib/classes/ProfileGraphs/index.d.ts +87 -0
- package/dist/lib/classes/ProfileGraphs/index.js +148 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +1 -1
- package/dist/lib/classes/SettingsAutosave/index.js +2 -1
- package/dist/lib/classes/UiSettings/index.d.ts +24 -2
- package/dist/lib/classes/UiSettings/index.js +32 -7
- package/dist/lib/messages/schema.d.ts +720 -0
- package/dist/lib/presets/schema.d.ts +360 -0
- package/dist/lib/presets/schema.js +8 -1
- package/dist/lib/profiles/index.d.ts +61 -0
- package/dist/lib/profiles/index.js +131 -0
- package/dist/lib/profiles/schema.d.ts +73 -0
- package/dist/lib/profiles/schema.js +53 -0
- package/dist/lib/rendering/sample/index.d.ts +11 -0
- package/dist/lib/rendering/sample/index.js +36 -5
- package/dist/lib/settings/index.d.ts +2 -1
- package/dist/lib/settings/index.js +4 -1
- package/dist/lib/settings/schema.d.ts +53 -1
- package/dist/lib/settings/schema.js +9 -2
- package/dist/lib/storage/index.d.ts +26 -0
- package/dist/lib/storage/index.js +38 -1
- package/dist/lib/validation/validators.generated.js +13061 -3675
- package/dist/lib/version/index.d.ts +25 -0
- package/dist/lib/version/index.js +35 -0
- package/dist/locales/en-GB.js +35 -0
- package/dist/locales/en-US.js +35 -0
- package/dist/locales/fr.js +35 -0
- package/dist/locales/ja.js +35 -0
- package/dist/locales/ko.js +35 -0
- package/dist/locales/zh-Hans.js +35 -0
- package/dist/locales/zh-Hant.js +35 -0
- package/dist/package.js +1 -1
- package/dist/ui/ask/index.d.ts +48 -0
- package/dist/ui/ask/index.js +67 -0
- package/dist/ui/base/index.d.ts +8 -1
- package/dist/ui/base/index.js +19 -4
- package/dist/ui/elements/PaintCanvas/index.d.ts +13 -3
- package/dist/ui/elements/PaintCanvas/index.js +25 -6
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +15 -7
- package/dist/ui/elements/PcAppSettings/index.js +53 -62
- package/dist/ui/elements/PcBrushConfig/index.d.ts +26 -14
- package/dist/ui/elements/PcBrushConfig/index.js +214 -145
- package/dist/ui/elements/PcBrushConfig/style.js +1 -1
- package/dist/ui/elements/PcBrushTest/index.d.ts +1 -0
- package/dist/ui/elements/PcBrushTest/index.js +15 -9
- package/dist/ui/elements/PcBrushTest/style.js +1 -1
- package/dist/ui/elements/PcButton/index.d.ts +12 -3
- package/dist/ui/elements/PcButton/index.js +18 -10
- package/dist/ui/elements/PcButtonMenu/index.d.ts +88 -0
- package/dist/ui/elements/PcButtonMenu/index.js +125 -0
- package/dist/ui/elements/PcCanvas/index.d.ts +15 -1
- package/dist/ui/elements/PcCanvas/index.js +42 -19
- package/dist/ui/elements/PcCanvas/style.js +1 -1
- package/dist/ui/elements/PcClipboardTools/index.d.ts +11 -7
- package/dist/ui/elements/PcClipboardTools/index.js +30 -29
- package/dist/ui/elements/PcDialog/index.d.ts +46 -10
- package/dist/ui/elements/PcDialog/index.js +102 -51
- package/dist/ui/elements/PcDialogWindow/index.d.ts +141 -0
- package/dist/ui/elements/PcDialogWindow/index.js +385 -0
- package/dist/ui/elements/PcInputSettings/index.d.ts +2 -1
- package/dist/ui/elements/PcInputSettings/index.js +9 -15
- package/dist/ui/elements/PcLayerItem/index.d.ts +21 -6
- package/dist/ui/elements/PcLayerItem/index.js +53 -26
- package/dist/ui/elements/PcLayerItem/style.js +1 -1
- package/dist/ui/elements/PcPanelBrushes/index.d.ts +3 -2
- package/dist/ui/elements/PcPanelBrushes/index.js +7 -5
- package/dist/ui/elements/PcPanelBrushes/style.js +1 -1
- package/dist/ui/elements/PcPanelColours/index.js +2 -2
- package/dist/ui/elements/PcPanelColours/style.js +1 -1
- package/dist/ui/elements/PcPanelLayers/index.js +1 -1
- package/dist/ui/elements/PcPanelLayers/style.js +1 -1
- package/dist/ui/elements/PcProfileEditor/index.d.ts +103 -0
- package/dist/ui/elements/PcProfileEditor/index.js +259 -0
- package/dist/ui/elements/PcProfileGraph/index.d.ts +84 -0
- package/dist/ui/elements/PcProfileGraph/index.js +317 -0
- package/dist/ui/elements/PcShortcutSettings/index.js +9 -13
- package/dist/ui/elements/PcSliderRange/index.d.ts +147 -0
- package/dist/ui/elements/PcSliderRange/index.js +308 -0
- package/dist/ui/elements/PcStats/index.d.ts +19 -4
- package/dist/ui/elements/PcStats/index.js +29 -13
- package/dist/ui/elements/PcToggleCheckbox/index.d.ts +13 -2
- package/dist/ui/elements/PcToggleCheckbox/index.js +27 -8
- package/dist/ui/elements/PcToolSettings/index.d.ts +1 -0
- package/dist/ui/elements/PcToolSettings/index.js +14 -14
- package/dist/ui/elements/PcVersion/index.d.ts +12 -0
- package/dist/ui/elements/PcVersion/index.js +43 -0
- package/dist/ui/icons/images/icon-profile-graph@2x.js +3 -0
- package/dist/ui/icons/index.d.ts +1 -1
- package/dist/ui/icons/index.js +2 -0
- package/dist/ui/index.d.ts +9 -2
- package/dist/ui/index.js +9 -2
- package/dist/ui/layout/index.d.ts +2 -2
- package/dist/ui/layout/index.js +2 -2
- package/dist/ui/styles/index.d.ts +21 -1
- package/dist/ui/styles/index.js +73 -14
- package/locales/en-GB.json +35 -0
- package/locales/en-US.json +35 -0
- package/locales/fr.json +35 -0
- package/locales/ja.json +35 -0
- package/locales/ko.json +35 -0
- package/locales/zh-Hans.json +35 -0
- package/locales/zh-Hant.json +35 -0
- package/package.json +25 -23
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type PropertyValues } from "lit";
|
|
2
2
|
import { PcElement } from "../../base";
|
|
3
3
|
import "../PcButton";
|
|
4
|
+
import "../PcDialogWindow";
|
|
4
5
|
import type { ButtonVariant } from "../PcButton";
|
|
5
6
|
/** A button in a dialog */
|
|
6
7
|
export interface DialogChoice {
|
|
@@ -12,14 +13,27 @@ export interface DialogChoice {
|
|
|
12
13
|
/** The button's style instead (e.g. `dismiss`: pink text without a background) */
|
|
13
14
|
variant?: ButtonVariant;
|
|
14
15
|
}
|
|
15
|
-
/**
|
|
16
|
+
/** A text field in a dialog, e.g. for a name */
|
|
17
|
+
export interface DialogField {
|
|
18
|
+
label: string;
|
|
19
|
+
/** The text it starts with */
|
|
20
|
+
value: string;
|
|
21
|
+
}
|
|
22
|
+
/** What `pc-choose` gives: the chosen value, and the field's text when the dialog has a field */
|
|
23
|
+
export interface DialogChoiceDetail {
|
|
24
|
+
value: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
/** What `pc-choose` gives when the dialog is dismissed (Escape, or a press outside it) */
|
|
16
28
|
export declare const CANCEL_CHOICE = "cancel";
|
|
17
29
|
/**
|
|
18
|
-
* A modal window asking the user to choose
|
|
19
|
-
*
|
|
20
|
-
* unless a choice gives its own `variant`).
|
|
21
|
-
*
|
|
22
|
-
*
|
|
30
|
+
* A modal window asking the user to choose (a `<pc-dialog-window>` over a shaded page), with a heading, a message, an
|
|
31
|
+
* optional text field (`field`, e.g. for a name), any content of its own, and its choices, each on its own row (the
|
|
32
|
+
* cancel choice and those marked `cancelling` in pink, the others purple, unless a choice gives its own `variant`).
|
|
33
|
+
*
|
|
34
|
+
* Focus moves to the field, or else the first choice, when it opens. Fires `pc-choose` with the chosen value (and the
|
|
35
|
+
* field's `text`): Enter in the field chooses the first choice that isn't cancelling; Escape and a press outside it
|
|
36
|
+
* choose `cancel`, unless it's not `dismissible`. `inline` shows it over its nearest positioned ancestor only.
|
|
23
37
|
*
|
|
24
38
|
* @example
|
|
25
39
|
* html`<pc-dialog heading="Delete layer" message='Delete "Sketch"?'
|
|
@@ -37,6 +51,16 @@ export declare class PcDialog extends PcElement {
|
|
|
37
51
|
choices: {
|
|
38
52
|
attribute: boolean;
|
|
39
53
|
};
|
|
54
|
+
field: {
|
|
55
|
+
attribute: boolean;
|
|
56
|
+
};
|
|
57
|
+
dismissible: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
};
|
|
60
|
+
inline: {
|
|
61
|
+
type: BooleanConstructor;
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
40
64
|
translations: {
|
|
41
65
|
attribute: boolean;
|
|
42
66
|
};
|
|
@@ -52,12 +76,24 @@ export declare class PcDialog extends PcElement {
|
|
|
52
76
|
heading: string;
|
|
53
77
|
message: string;
|
|
54
78
|
choices: readonly DialogChoice[];
|
|
79
|
+
/** A text field to fill in, if any */
|
|
80
|
+
field?: DialogField;
|
|
81
|
+
/** Whether Escape and a press outside it choose `cancel` */
|
|
82
|
+
dismissible: boolean;
|
|
83
|
+
/** Whether it covers only its nearest positioned ancestor, leaving the rest of the page usable */
|
|
84
|
+
inline: boolean;
|
|
55
85
|
constructor();
|
|
56
86
|
firstUpdated(changed: PropertyValues<this>): void;
|
|
57
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Move focus to the field (selecting its text), or else the first choice, once the window has opened (nothing in it
|
|
89
|
+
* can take focus before) and the choice has rendered its button.
|
|
90
|
+
*/
|
|
91
|
+
private focusFirst;
|
|
92
|
+
/**
|
|
93
|
+
* Choose one of the choices (or `cancel`), giving the field's text when there's a field.
|
|
94
|
+
*/
|
|
58
95
|
choose(value: string): void;
|
|
59
|
-
private readonly
|
|
60
|
-
|
|
61
|
-
disconnectedCallback(): void;
|
|
96
|
+
private readonly onFieldKeyDown;
|
|
97
|
+
private readonly onDismiss;
|
|
62
98
|
render(): import("lit").TemplateResult<1>;
|
|
63
99
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { PcElement, defineElement, emit } from "../../base/index.js";
|
|
2
2
|
import "../PcButton/index.js";
|
|
3
|
+
import "../PcDialogWindow/index.js";
|
|
3
4
|
import { css, html, nothing } from "lit";
|
|
4
5
|
// src/ui/elements/PcDialog/index.ts
|
|
5
|
-
/** What `pc-choose` gives when the dialog is dismissed
|
|
6
|
+
/** What `pc-choose` gives when the dialog is dismissed (Escape, or a press outside it) */
|
|
6
7
|
var CANCEL_CHOICE = "cancel";
|
|
7
8
|
/**
|
|
8
|
-
* A modal window asking the user to choose
|
|
9
|
-
*
|
|
10
|
-
* unless a choice gives its own `variant`).
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* A modal window asking the user to choose (a `<pc-dialog-window>` over a shaded page), with a heading, a message, an
|
|
10
|
+
* optional text field (`field`, e.g. for a name), any content of its own, and its choices, each on its own row (the
|
|
11
|
+
* cancel choice and those marked `cancelling` in pink, the others purple, unless a choice gives its own `variant`).
|
|
12
|
+
*
|
|
13
|
+
* Focus moves to the field, or else the first choice, when it opens. Fires `pc-choose` with the chosen value (and the
|
|
14
|
+
* field's `text`): Enter in the field chooses the first choice that isn't cancelling; Escape and a press outside it
|
|
15
|
+
* choose `cancel`, unless it's not `dismissible`. `inline` shows it over its nearest positioned ancestor only.
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
15
18
|
* html`<pc-dialog heading="Delete layer" message='Delete "Sketch"?'
|
|
@@ -21,32 +24,20 @@ var PcDialog = class extends PcElement {
|
|
|
21
24
|
...PcElement.properties,
|
|
22
25
|
heading: { type: String },
|
|
23
26
|
message: { type: String },
|
|
24
|
-
choices: { attribute: false }
|
|
27
|
+
choices: { attribute: false },
|
|
28
|
+
field: { attribute: false },
|
|
29
|
+
dismissible: { type: Boolean },
|
|
30
|
+
inline: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
reflect: true
|
|
33
|
+
}
|
|
25
34
|
};
|
|
26
35
|
static styles = [PcElement.styles, css`
|
|
27
36
|
:host {
|
|
28
|
-
|
|
29
|
-
z-index: 20;
|
|
30
|
-
inset: 0;
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
padding: var(--pc-space-3);
|
|
35
|
-
background: var(--pc-backdrop);
|
|
37
|
+
display: contents;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
width: 100%;
|
|
40
|
-
max-width: 400px;
|
|
41
|
-
flex-direction: column;
|
|
42
|
-
gap: var(--pc-space-2);
|
|
43
|
-
padding: var(--pc-space-3);
|
|
44
|
-
border-radius: var(--pc-radius);
|
|
45
|
-
background: var(--pc-surface-raised);
|
|
46
|
-
color: var(--pc-text);
|
|
47
|
-
box-shadow: var(--pc-shadow);
|
|
48
|
-
font-family: var(--pc-font);
|
|
49
|
-
font-size: var(--pc-font-size);
|
|
39
|
+
pc-dialog-window {
|
|
40
|
+
--pc-dialog-width: 400px;
|
|
50
41
|
}
|
|
51
42
|
h2 {
|
|
52
43
|
margin: 0;
|
|
@@ -55,6 +46,30 @@ var PcDialog = class extends PcElement {
|
|
|
55
46
|
p {
|
|
56
47
|
margin: 0;
|
|
57
48
|
}
|
|
49
|
+
.body {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
gap: var(--pc-space-2);
|
|
53
|
+
}
|
|
54
|
+
label {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: var(--pc-space-1);
|
|
58
|
+
}
|
|
59
|
+
input {
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
width: 100%;
|
|
62
|
+
min-height: var(--pc-control-size);
|
|
63
|
+
padding: 0 var(--pc-space-2);
|
|
64
|
+
border: 1px solid var(--pc-border);
|
|
65
|
+
border-radius: var(--pc-radius-small);
|
|
66
|
+
background: var(--pc-surface);
|
|
67
|
+
color: var(--pc-text);
|
|
68
|
+
font: inherit;
|
|
69
|
+
}
|
|
70
|
+
input:focus-visible {
|
|
71
|
+
outline: var(--pc-focus-width) solid var(--pc-focus);
|
|
72
|
+
}
|
|
58
73
|
.choices {
|
|
59
74
|
display: flex;
|
|
60
75
|
flex-direction: column;
|
|
@@ -66,41 +81,77 @@ var PcDialog = class extends PcElement {
|
|
|
66
81
|
this.heading = "";
|
|
67
82
|
this.message = "";
|
|
68
83
|
this.choices = [];
|
|
84
|
+
this.dismissible = true;
|
|
85
|
+
this.inline = false;
|
|
69
86
|
}
|
|
70
87
|
firstUpdated(changed) {
|
|
71
88
|
super.firstUpdated(changed);
|
|
89
|
+
this.focusFirst();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Move focus to the field (selecting its text), or else the first choice, once the window has opened (nothing in it
|
|
93
|
+
* can take focus before) and the choice has rendered its button.
|
|
94
|
+
*/
|
|
95
|
+
async focusFirst() {
|
|
96
|
+
await this.renderRoot.querySelector("pc-dialog-window").updateComplete;
|
|
97
|
+
const field = this.renderRoot.querySelector("input");
|
|
98
|
+
if (field) {
|
|
99
|
+
field.focus();
|
|
100
|
+
field.select();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
72
103
|
const first = this.renderRoot.querySelector("pc-button");
|
|
73
|
-
if (first)
|
|
104
|
+
if (!first) return;
|
|
105
|
+
await first.updateComplete;
|
|
106
|
+
first.focus();
|
|
74
107
|
}
|
|
75
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Choose one of the choices (or `cancel`), giving the field's text when there's a field.
|
|
110
|
+
*/
|
|
76
111
|
choose(value) {
|
|
77
|
-
|
|
112
|
+
const text = this.renderRoot.querySelector("input")?.value;
|
|
113
|
+
emit(this, "pc-choose", text === void 0 ? { value } : {
|
|
114
|
+
value,
|
|
115
|
+
text
|
|
116
|
+
});
|
|
78
117
|
}
|
|
79
|
-
|
|
80
|
-
if (event.key !== "
|
|
118
|
+
onFieldKeyDown = (event) => {
|
|
119
|
+
if (event.key !== "Enter") return;
|
|
120
|
+
const choice = this.choices.find((item) => item.value !== "cancel" && !item.cancelling);
|
|
121
|
+
if (!choice) return;
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
this.choose(choice.value);
|
|
124
|
+
};
|
|
125
|
+
onDismiss = (event) => {
|
|
81
126
|
event.preventDefault();
|
|
82
127
|
this.choose(CANCEL_CHOICE);
|
|
83
128
|
};
|
|
84
|
-
connectedCallback() {
|
|
85
|
-
super.connectedCallback();
|
|
86
|
-
window.addEventListener("keydown", this.onKeyDown);
|
|
87
|
-
}
|
|
88
|
-
disconnectedCallback() {
|
|
89
|
-
super.disconnectedCallback();
|
|
90
|
-
window.removeEventListener("keydown", this.onKeyDown);
|
|
91
|
-
}
|
|
92
129
|
render() {
|
|
93
|
-
|
|
130
|
+
const field = this.field;
|
|
131
|
+
return html`<pc-dialog-window
|
|
94
132
|
part="dialog"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
133
|
+
open
|
|
134
|
+
shaded
|
|
135
|
+
closable="false"
|
|
136
|
+
.dismissible=${this.dismissible}
|
|
137
|
+
?inline=${this.inline}
|
|
138
|
+
description=${this.message || nothing}
|
|
139
|
+
@pc-dismiss=${this.onDismiss}
|
|
99
140
|
>
|
|
100
|
-
<h2
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
141
|
+
<h2 slot="header-middle" part="heading">${this.heading}</h2>
|
|
142
|
+
<div slot="body" class="body">
|
|
143
|
+
${this.message ? html`<p part="message">${this.message}</p>` : nothing}
|
|
144
|
+
${field ? html`<label part="field">
|
|
145
|
+
${field.label}
|
|
146
|
+
<input
|
|
147
|
+
type="text"
|
|
148
|
+
.value=${field.value}
|
|
149
|
+
@keydown=${this.onFieldKeyDown}
|
|
150
|
+
/>
|
|
151
|
+
</label>` : nothing}
|
|
152
|
+
<slot></slot>
|
|
153
|
+
</div>
|
|
154
|
+
<div slot="footer-middle" class="choices" part="choices">
|
|
104
155
|
${this.choices.map((choice) => html`<pc-button
|
|
105
156
|
variant=${choice.variant ?? (choice.value === "cancel" || choice.cancelling ? "cancel" : "accent")}
|
|
106
157
|
data-value=${choice.value}
|
|
@@ -108,7 +159,7 @@ var PcDialog = class extends PcElement {
|
|
|
108
159
|
>${choice.label}</pc-button
|
|
109
160
|
>`)}
|
|
110
161
|
</div>
|
|
111
|
-
</
|
|
162
|
+
</pc-dialog-window>`;
|
|
112
163
|
}
|
|
113
164
|
};
|
|
114
165
|
defineElement("pc-dialog", PcDialog);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type PropertyValues } from "lit";
|
|
2
|
+
import { PcElement } from "../../base";
|
|
3
|
+
/** Why the user asked to close a dialog window: its ⨉ button, the Escape key, or a press outside it */
|
|
4
|
+
export type DialogCloseReason = "close" | "escape" | "outside";
|
|
5
|
+
/** Event fired when the user asks to close a dialog window (detail: `{ reason }`); cancel it to keep the window open */
|
|
6
|
+
export declare const DIALOG_DISMISS_EVENT = "pc-dismiss";
|
|
7
|
+
/**
|
|
8
|
+
* A window over the page, built on the browser's `<dialog>`: centred in the viewport, never bigger than it, with a
|
|
9
|
+
* header, a body and a footer. While it's `open`, the rest of the page can't be used or scrolled and keyboard focus stays
|
|
10
|
+
* in it (moving to its first control, and back to where it was once it closes).
|
|
11
|
+
*
|
|
12
|
+
* Content goes in its slots: `header-start`, `header-middle` (which names the window for screen readers, unless it has a
|
|
13
|
+
* `label`; `description` describes it), `header-end`, `body` (or no slot), `footer-start`, `footer-middle` and `footer-end`. The body scrolls when
|
|
14
|
+
* there's too much to fit, keeping the header and footer in view. The header and footer only show with content (or the
|
|
15
|
+
* ⨉ button).
|
|
16
|
+
*
|
|
17
|
+
* Options:
|
|
18
|
+
* - `closable` (on by default; `closable="false"` turns it off): a ⨉ button at the top right.
|
|
19
|
+
* - `shaded`: shade the page under it.
|
|
20
|
+
* - `dismissible` (on by default; `dismissible="false"` turns it off): a press outside it closes it.
|
|
21
|
+
* - `inline`: cover only its nearest positioned ancestor instead of the whole page, which stays usable (and scrolls).
|
|
22
|
+
*
|
|
23
|
+
* The ⨉ button, a press outside it (while `dismissible`) and Escape (while `closable` or `dismissible`) fire a cancellable
|
|
24
|
+
* `pc-dismiss` event (detail: `{ reason }`, one of `close`, `outside` or `escape`); unless it's cancelled, the window
|
|
25
|
+
* closes (`open` becomes false). `--pc-dialog-width` sets its width (fitted to its content by default).
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* html`<pc-dialog-window open shaded label="Keyboard shortcuts" @pc-dismiss=${close}>
|
|
29
|
+
* <h2 slot="header-middle">Keyboard shortcuts</h2>
|
|
30
|
+
* <pc-shortcut-settings slot="body" .settings=${settings}></pc-shortcut-settings>
|
|
31
|
+
* <pc-button slot="footer-end" @click=${close}>Done</pc-button>
|
|
32
|
+
* </pc-dialog-window>`
|
|
33
|
+
*/
|
|
34
|
+
export declare class PcDialogWindow extends PcElement {
|
|
35
|
+
static properties: {
|
|
36
|
+
open: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
reflect: boolean;
|
|
39
|
+
};
|
|
40
|
+
closable: {
|
|
41
|
+
converter: {
|
|
42
|
+
fromAttribute: (value: string | null) => boolean;
|
|
43
|
+
toAttribute: (value: boolean) => "" | "false";
|
|
44
|
+
};
|
|
45
|
+
reflect: boolean;
|
|
46
|
+
};
|
|
47
|
+
shaded: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
reflect: boolean;
|
|
50
|
+
};
|
|
51
|
+
dismissible: {
|
|
52
|
+
converter: {
|
|
53
|
+
fromAttribute: (value: string | null) => boolean;
|
|
54
|
+
toAttribute: (value: boolean) => "" | "false";
|
|
55
|
+
};
|
|
56
|
+
reflect: boolean;
|
|
57
|
+
};
|
|
58
|
+
inline: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
reflect: boolean;
|
|
61
|
+
};
|
|
62
|
+
label: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
};
|
|
65
|
+
description: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
};
|
|
68
|
+
filled: {
|
|
69
|
+
state: boolean;
|
|
70
|
+
};
|
|
71
|
+
translations: {
|
|
72
|
+
attribute: boolean;
|
|
73
|
+
};
|
|
74
|
+
icons: {
|
|
75
|
+
attribute: boolean;
|
|
76
|
+
};
|
|
77
|
+
theme: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
reflect: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
static styles: import("lit").CSSResultGroup[];
|
|
83
|
+
/** Whether it's shown */
|
|
84
|
+
open: boolean;
|
|
85
|
+
/** Whether it has a ⨉ button at the top right */
|
|
86
|
+
closable: boolean;
|
|
87
|
+
/** Whether the page under it is shaded */
|
|
88
|
+
shaded: boolean;
|
|
89
|
+
/** Whether a press outside it closes it */
|
|
90
|
+
dismissible: boolean;
|
|
91
|
+
/** Whether it covers only its nearest positioned ancestor, leaving the rest of the page usable */
|
|
92
|
+
inline: boolean;
|
|
93
|
+
/** Its name for screen readers, instead of its `header-middle` content */
|
|
94
|
+
label?: string;
|
|
95
|
+
/** A description for screen readers, e.g. the question a prompt asks */
|
|
96
|
+
description?: string;
|
|
97
|
+
/** The names of its header and footer slots that have content */
|
|
98
|
+
filled: ReadonlySet<string>;
|
|
99
|
+
/** Whether it's keeping the page from scrolling */
|
|
100
|
+
private scrollLocked;
|
|
101
|
+
/** What had focus before it opened, to give it back to if it's taken out of the page while open */
|
|
102
|
+
private returnFocus;
|
|
103
|
+
/** Whether the `<dialog>` was last shown inline (not modal) */
|
|
104
|
+
private shownInline;
|
|
105
|
+
/** Whether the press being made started outside the window */
|
|
106
|
+
private pressedOutside;
|
|
107
|
+
constructor();
|
|
108
|
+
/** The `<dialog>` it's built on */
|
|
109
|
+
private get dialog();
|
|
110
|
+
/**
|
|
111
|
+
* Ask to close the window, as the user would: fires `pc-dismiss` (detail: `{ reason }`), and closes it unless that's
|
|
112
|
+
* cancelled.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* dialogWindow.requestClose("close");
|
|
116
|
+
*/
|
|
117
|
+
requestClose(reason: DialogCloseReason): void;
|
|
118
|
+
connectedCallback(): void;
|
|
119
|
+
disconnectedCallback(): void;
|
|
120
|
+
protected firstUpdated(changed: PropertyValues<this>): void;
|
|
121
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
122
|
+
/**
|
|
123
|
+
* Show or close the `<dialog>` to match `open` (modal unless `inline`), keeping the page from scrolling while a modal
|
|
124
|
+
* window is open.
|
|
125
|
+
*/
|
|
126
|
+
private syncOpen;
|
|
127
|
+
/** Keep the page from scrolling while a modal window is open in it, and let it scroll again otherwise */
|
|
128
|
+
private syncScrollLock;
|
|
129
|
+
/** Note which header and footer slots have content: only those (and the header and footer with them) are shown */
|
|
130
|
+
private updateRegions;
|
|
131
|
+
/** Whether any of a header's or footer's slots have content */
|
|
132
|
+
private hasRegion;
|
|
133
|
+
private readonly onKeyDown;
|
|
134
|
+
private readonly onCancel;
|
|
135
|
+
private readonly onClose;
|
|
136
|
+
private readonly onPointerDown;
|
|
137
|
+
private readonly onClick;
|
|
138
|
+
/** A header or footer's start, middle and end slots */
|
|
139
|
+
private renderRegion;
|
|
140
|
+
render(): import("lit").TemplateResult<1>;
|
|
141
|
+
}
|