@lvl99dotcom/paintcanvas 0.3.0 → 0.4.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 +1 -1
- package/dist/lib/brushes/StrokeEngine/index.d.ts +2 -2
- package/dist/lib/brushes/StrokeEngine/index.js +26 -28
- package/dist/lib/classes/BrushSettings/index.d.ts +24 -0
- package/dist/lib/classes/BrushSettings/index.js +35 -1
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +17 -6
- package/dist/lib/classes/KeyboardShortcuts/index.js +81 -18
- package/dist/lib/classes/PaintCanvas/index.d.ts +77 -27
- package/dist/lib/classes/PaintCanvas/index.js +143 -42
- package/dist/lib/classes/PaintCanvas/tool.d.ts +15 -0
- package/dist/lib/classes/PaintCanvas/tool.js +18 -0
- package/dist/lib/classes/Palette/index.d.ts +58 -0
- package/dist/lib/classes/Palette/index.js +92 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +52 -0
- package/dist/lib/classes/SettingsAutosave/index.js +96 -0
- package/dist/lib/classes/ShortcutSettings/index.d.ts +63 -0
- package/dist/lib/classes/ShortcutSettings/index.js +110 -0
- package/dist/lib/palette/index.d.ts +49 -0
- package/dist/lib/palette/index.js +82 -0
- package/dist/lib/palette/schema.d.ts +45 -0
- package/dist/lib/palette/schema.js +41 -0
- package/dist/lib/rendering/cursors/index.d.ts +2 -0
- package/dist/lib/rendering/cursors/index.js +3 -1
- package/dist/lib/rendering/sample/index.js +3 -2
- package/dist/lib/settings/index.d.ts +63 -0
- package/dist/lib/settings/index.js +91 -0
- package/dist/lib/settings/schema.d.ts +150 -0
- package/dist/lib/settings/schema.js +102 -0
- package/dist/lib/storage/index.d.ts +36 -5
- package/dist/lib/storage/index.js +87 -29
- package/dist/lib/utils/colour/index.d.ts +72 -0
- package/dist/lib/utils/colour/index.js +154 -0
- package/dist/lib/utils/shortcuts/index.d.ts +174 -11
- package/dist/lib/utils/shortcuts/index.js +391 -145
- package/dist/lib/validation/validators.generated.d.ts +5 -0
- package/dist/lib/validation/validators.generated.js +872 -1
- package/dist/locales/en-GB.js +87 -1
- package/dist/locales/en-US.js +87 -1
- package/dist/locales/fr.js +87 -1
- package/dist/locales/ja.js +87 -1
- package/dist/locales/ko.js +87 -1
- package/dist/locales/zh-Hans.js +87 -1
- package/dist/locales/zh-Hant.js +87 -1
- package/dist/package.js +1 -1
- package/dist/ui/elements/PaintCanvas/index.d.ts +49 -47
- package/dist/ui/elements/PaintCanvas/index.js +128 -169
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +59 -0
- package/dist/ui/elements/PcAppSettings/index.js +222 -0
- package/dist/ui/elements/PcBrushConfig/index.js +1 -0
- package/dist/ui/elements/PcButton/index.js +1 -0
- package/dist/ui/elements/PcCanvas/index.d.ts +1 -1
- package/dist/ui/elements/PcCanvas/index.js +7 -5
- package/dist/ui/elements/PcColourPair/index.d.ts +43 -0
- package/dist/ui/elements/PcColourPair/index.js +125 -0
- package/dist/ui/elements/PcContextMenu/index.d.ts +70 -33
- package/dist/ui/elements/PcContextMenu/index.js +128 -97
- package/dist/ui/elements/PcDialog/index.js +1 -0
- package/dist/ui/elements/PcIconToggle/index.js +1 -0
- package/dist/ui/elements/PcLayerItem/index.d.ts +13 -34
- package/dist/ui/elements/PcLayerItem/index.js +39 -91
- package/dist/ui/elements/PcLayerItem/style.js +1 -1
- package/dist/ui/elements/PcMenu/index.d.ts +93 -0
- package/dist/ui/elements/PcMenu/index.js +204 -0
- package/dist/ui/elements/PcPane/index.d.ts +118 -0
- package/dist/ui/elements/PcPane/index.js +357 -0
- package/dist/ui/elements/PcPanel/index.d.ts +26 -8
- package/dist/ui/elements/PcPanel/index.js +76 -8
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.d.ts +20 -6
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.js +20 -15
- package/dist/ui/elements/PcPanelBrushes/style.js +3 -0
- package/dist/ui/elements/PcPanelColours/index.d.ts +171 -0
- package/dist/ui/elements/PcPanelColours/index.js +650 -0
- package/dist/ui/elements/PcPanelColours/style.js +3 -0
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.d.ts +17 -4
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.js +17 -10
- package/dist/ui/elements/PcPanelLayers/style.js +3 -0
- package/dist/ui/elements/PcShortcutSettings/index.d.ts +69 -0
- package/dist/ui/elements/PcShortcutSettings/index.js +273 -0
- package/dist/ui/elements/PcThemePicker/index.js +1 -0
- package/dist/ui/elements/PcToast/index.js +1 -0
- package/dist/ui/elements/PcToolSettings/index.js +2 -1
- package/dist/ui/elements/PcToolbar/index.d.ts +47 -12
- package/dist/ui/elements/PcToolbar/index.js +77 -56
- package/dist/ui/elements/PcToolbar/style.js +1 -1
- package/dist/ui/index.d.ts +7 -1
- package/dist/ui/index.js +8 -2
- package/dist/ui/tokens/index.js +3 -1
- package/locales/en-GB.json +87 -1
- package/locales/en-US.json +87 -1
- package/locales/fr.json +87 -1
- package/locales/ja.json +87 -1
- package/locales/ko.json +87 -1
- package/locales/zh-Hans.json +87 -1
- package/locales/zh-Hant.json +87 -1
- package/package.json +1 -1
- package/dist/ui/elements/PcBrushMenu/style.js +0 -3
- package/dist/ui/elements/PcLayersMenu/style.js +0 -3
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type PropertyValues } from "lit";
|
|
2
|
+
import { PcElement } from "../../base";
|
|
3
|
+
import { type KeyCombo } from "../../../lib/utils/shortcuts";
|
|
4
|
+
import "../PcIcon";
|
|
5
|
+
/** Longest shortcut label shown on a menu item (characters); longer ones are left out */
|
|
6
|
+
export declare const MAX_SHORTCUT_LABEL_LENGTH = 3;
|
|
7
|
+
/** An item in a context menu */
|
|
8
|
+
export interface MenuItem {
|
|
9
|
+
/** What `pc-select` gives when it's chosen */
|
|
10
|
+
value: string;
|
|
11
|
+
label: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Shown in the cancelling colour, e.g. for deleting */
|
|
14
|
+
danger?: boolean;
|
|
15
|
+
/** Makes the item a toggle, showing a checkmark on its left while on */
|
|
16
|
+
checked?: boolean;
|
|
17
|
+
/** Name of an icon to show on its left (see `icons`), when it isn't a toggle */
|
|
18
|
+
icon?: string;
|
|
19
|
+
/** The action's keyboard shortcut, shown on its right as symbols (e.g. ⌘S) when 3 characters or fewer */
|
|
20
|
+
shortcut?: KeyCombo;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A list of menu items, e.g. a layer's actions (see `pc-context-menu` for a button that opens one). While `open`, it shows its items at `x`, `y` (in the page's viewport) and takes
|
|
24
|
+
* keyboard focus: arrow keys, Home and End move between items, Enter or Space chooses one, and Escape or Tab closes it.
|
|
25
|
+
* Items can show a checkmark (toggles) or an icon on their left, and their keyboard shortcut on their right; long
|
|
26
|
+
* labels wrap.
|
|
27
|
+
* Fires `pc-select` with the chosen item's value, and `pc-close` when it should close (after choosing, Escape, Tab, or a
|
|
28
|
+
* press outside it and its `anchor`). The implementer sets `open` to false in response.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* html`<pc-menu open .x=${10} .y=${20} label="Layer actions" .items=${items}
|
|
32
|
+
* @pc-select=${(e) => act(e.detail.value)} @pc-close=${close}></pc-menu>`
|
|
33
|
+
*/
|
|
34
|
+
export declare class PcMenu extends PcElement {
|
|
35
|
+
static properties: {
|
|
36
|
+
open: {
|
|
37
|
+
type: BooleanConstructor;
|
|
38
|
+
reflect: boolean;
|
|
39
|
+
};
|
|
40
|
+
items: {
|
|
41
|
+
attribute: boolean;
|
|
42
|
+
};
|
|
43
|
+
label: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
};
|
|
46
|
+
x: {
|
|
47
|
+
type: NumberConstructor;
|
|
48
|
+
};
|
|
49
|
+
y: {
|
|
50
|
+
type: NumberConstructor;
|
|
51
|
+
};
|
|
52
|
+
anchor: {
|
|
53
|
+
attribute: boolean;
|
|
54
|
+
};
|
|
55
|
+
translations: {
|
|
56
|
+
attribute: boolean;
|
|
57
|
+
};
|
|
58
|
+
icons: {
|
|
59
|
+
attribute: boolean;
|
|
60
|
+
};
|
|
61
|
+
theme: {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
reflect: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
static styles: import("lit").CSSResultGroup[];
|
|
67
|
+
open: boolean;
|
|
68
|
+
items: readonly MenuItem[];
|
|
69
|
+
/** Names the menu for screen readers */
|
|
70
|
+
label: string;
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
/** The element that opens it (e.g. a `pc-context-menu`'s button): pressing it doesn't count as pressing outside */
|
|
74
|
+
anchor?: Element;
|
|
75
|
+
private readonly onPointerDown;
|
|
76
|
+
constructor();
|
|
77
|
+
connectedCallback(): void;
|
|
78
|
+
disconnectedCallback(): void;
|
|
79
|
+
updated(changed: PropertyValues<this>): void;
|
|
80
|
+
/** The enabled items' buttons */
|
|
81
|
+
private buttons;
|
|
82
|
+
/** Tell listeners the menu should close */
|
|
83
|
+
close(): void;
|
|
84
|
+
/** Choose an item, then close */
|
|
85
|
+
private choose;
|
|
86
|
+
/** Move focus between items, or close */
|
|
87
|
+
private onKeyDown;
|
|
88
|
+
/** An item's left side: a checkmark while a toggle is on, its icon, or empty space */
|
|
89
|
+
private renderStart;
|
|
90
|
+
/** An item's right side: its shortcut's label, if short enough */
|
|
91
|
+
private renderEnd;
|
|
92
|
+
render(): import("lit").TemplateResult<1>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { PcElement, defineElement, emit } from "../../base/index.js";
|
|
2
|
+
import { ariaKeyShortcut, shortcutLabel } from "../../../lib/utils/shortcuts/index.js";
|
|
3
|
+
import "../PcIcon/index.js";
|
|
4
|
+
import { css, html, nothing } from "lit";
|
|
5
|
+
// src/ui/elements/PcMenu/index.ts
|
|
6
|
+
/** Longest shortcut label shown on a menu item (characters); longer ones are left out */
|
|
7
|
+
var MAX_SHORTCUT_LABEL_LENGTH = 3;
|
|
8
|
+
/**
|
|
9
|
+
* Whether a menu item has something to show on its left: a checkmark or an icon.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* hasStart({ value: "grid", label: "Grid", checked: false }); // true
|
|
13
|
+
*/
|
|
14
|
+
var hasStart = (item) => item.checked !== void 0 || item.icon !== void 0;
|
|
15
|
+
/**
|
|
16
|
+
* A list of menu items, e.g. a layer's actions (see `pc-context-menu` for a button that opens one). While `open`, it shows its items at `x`, `y` (in the page's viewport) and takes
|
|
17
|
+
* keyboard focus: arrow keys, Home and End move between items, Enter or Space chooses one, and Escape or Tab closes it.
|
|
18
|
+
* Items can show a checkmark (toggles) or an icon on their left, and their keyboard shortcut on their right; long
|
|
19
|
+
* labels wrap.
|
|
20
|
+
* Fires `pc-select` with the chosen item's value, and `pc-close` when it should close (after choosing, Escape, Tab, or a
|
|
21
|
+
* press outside it and its `anchor`). The implementer sets `open` to false in response.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* html`<pc-menu open .x=${10} .y=${20} label="Layer actions" .items=${items}
|
|
25
|
+
* @pc-select=${(e) => act(e.detail.value)} @pc-close=${close}></pc-menu>`
|
|
26
|
+
*/
|
|
27
|
+
var PcMenu = class extends PcElement {
|
|
28
|
+
static properties = {
|
|
29
|
+
...PcElement.properties,
|
|
30
|
+
open: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
reflect: true
|
|
33
|
+
},
|
|
34
|
+
items: { attribute: false },
|
|
35
|
+
label: { type: String },
|
|
36
|
+
x: { type: Number },
|
|
37
|
+
y: { type: Number },
|
|
38
|
+
anchor: { attribute: false }
|
|
39
|
+
};
|
|
40
|
+
static styles = [PcElement.styles, css`
|
|
41
|
+
:host {
|
|
42
|
+
position: fixed;
|
|
43
|
+
z-index: 10;
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
:host([open]) {
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
49
|
+
[role="menu"] {
|
|
50
|
+
display: flex;
|
|
51
|
+
min-width: 160px;
|
|
52
|
+
max-width: min(320px, calc(100vw - 2 * var(--pc-space-3)));
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
padding: var(--pc-space-1) 0;
|
|
55
|
+
border-radius: var(--pc-radius);
|
|
56
|
+
background: var(--pc-surface-raised);
|
|
57
|
+
box-shadow: var(--pc-shadow);
|
|
58
|
+
}
|
|
59
|
+
button {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: baseline;
|
|
62
|
+
gap: var(--pc-space-2);
|
|
63
|
+
padding: var(--pc-space-2) var(--pc-space-3);
|
|
64
|
+
border: 0;
|
|
65
|
+
background: transparent;
|
|
66
|
+
color: var(--pc-text);
|
|
67
|
+
font-family: var(--pc-font);
|
|
68
|
+
font-size: var(--pc-font-size);
|
|
69
|
+
text-align: start;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
}
|
|
72
|
+
button:hover:not(:disabled),
|
|
73
|
+
button:focus-visible {
|
|
74
|
+
background: var(--pc-surface-hover);
|
|
75
|
+
outline: none;
|
|
76
|
+
}
|
|
77
|
+
button:focus-visible {
|
|
78
|
+
box-shadow: inset 0 0 0 var(--pc-focus-width) var(--pc-focus);
|
|
79
|
+
}
|
|
80
|
+
button.danger {
|
|
81
|
+
color: var(--pc-dismiss-text);
|
|
82
|
+
}
|
|
83
|
+
.start {
|
|
84
|
+
/* Icons as tall as the text, so items with icons are no taller */
|
|
85
|
+
--pc-icon-size: 1.2em;
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
width: var(--pc-icon-size);
|
|
88
|
+
flex: none;
|
|
89
|
+
align-self: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
}
|
|
92
|
+
.label {
|
|
93
|
+
flex: 1;
|
|
94
|
+
overflow-wrap: anywhere;
|
|
95
|
+
}
|
|
96
|
+
.end {
|
|
97
|
+
flex: none;
|
|
98
|
+
color: var(--pc-text-muted);
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
}
|
|
101
|
+
button:disabled {
|
|
102
|
+
color: var(--pc-text-muted);
|
|
103
|
+
cursor: default;
|
|
104
|
+
}
|
|
105
|
+
`];
|
|
106
|
+
onPointerDown = (event) => {
|
|
107
|
+
const path = event.composedPath();
|
|
108
|
+
if (this.open && !path.includes(this) && !(this.anchor && path.includes(this.anchor))) this.close();
|
|
109
|
+
};
|
|
110
|
+
constructor() {
|
|
111
|
+
super();
|
|
112
|
+
this.open = false;
|
|
113
|
+
this.items = [];
|
|
114
|
+
this.label = "";
|
|
115
|
+
this.x = 0;
|
|
116
|
+
this.y = 0;
|
|
117
|
+
}
|
|
118
|
+
connectedCallback() {
|
|
119
|
+
super.connectedCallback();
|
|
120
|
+
document.addEventListener("pointerdown", this.onPointerDown, true);
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback() {
|
|
123
|
+
super.disconnectedCallback();
|
|
124
|
+
document.removeEventListener("pointerdown", this.onPointerDown, true);
|
|
125
|
+
}
|
|
126
|
+
updated(changed) {
|
|
127
|
+
this.style.left = `${this.x}px`;
|
|
128
|
+
this.style.top = `${this.y}px`;
|
|
129
|
+
if (changed.has("open") && this.open) this.buttons()[0]?.focus();
|
|
130
|
+
}
|
|
131
|
+
/** The enabled items' buttons */
|
|
132
|
+
buttons() {
|
|
133
|
+
return [...this.renderRoot.querySelectorAll("button")].filter((button) => !button.disabled);
|
|
134
|
+
}
|
|
135
|
+
/** Tell listeners the menu should close */
|
|
136
|
+
close() {
|
|
137
|
+
emit(this, "pc-close");
|
|
138
|
+
}
|
|
139
|
+
/** Choose an item, then close */
|
|
140
|
+
choose(item) {
|
|
141
|
+
emit(this, "pc-select", { value: item.value });
|
|
142
|
+
this.close();
|
|
143
|
+
}
|
|
144
|
+
/** Move focus between items, or close */
|
|
145
|
+
onKeyDown(event) {
|
|
146
|
+
const buttons = this.buttons();
|
|
147
|
+
const index = buttons.indexOf(this.renderRoot.activeElement);
|
|
148
|
+
const last = buttons.length - 1;
|
|
149
|
+
const target = {
|
|
150
|
+
ArrowDown: index >= last ? 0 : index + 1,
|
|
151
|
+
ArrowUp: index <= 0 ? last : index - 1,
|
|
152
|
+
Home: 0,
|
|
153
|
+
End: last
|
|
154
|
+
}[event.key];
|
|
155
|
+
if (target !== void 0) {
|
|
156
|
+
event.preventDefault();
|
|
157
|
+
buttons[target]?.focus();
|
|
158
|
+
} else if (event.key === "Escape" || event.key === "Tab") {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
this.close();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** An item's left side: a checkmark while a toggle is on, its icon, or empty space */
|
|
164
|
+
renderStart(item) {
|
|
165
|
+
const content = item.checked !== void 0 ? item.checked ? "✔" : nothing : item.icon ? html`<pc-icon name=${item.icon}></pc-icon>` : nothing;
|
|
166
|
+
return html`<span part="item-start" class="start" aria-hidden="true"
|
|
167
|
+
>${content}</span
|
|
168
|
+
>`;
|
|
169
|
+
}
|
|
170
|
+
/** An item's right side: its shortcut's label, if short enough */
|
|
171
|
+
renderEnd(item) {
|
|
172
|
+
const label = item.shortcut && shortcutLabel(item.shortcut);
|
|
173
|
+
return label && [...label].length <= 3 ? html`<span part="item-end" class="end" aria-hidden="true"
|
|
174
|
+
>${label}</span
|
|
175
|
+
>` : nothing;
|
|
176
|
+
}
|
|
177
|
+
render() {
|
|
178
|
+
const showStart = this.items.some(hasStart);
|
|
179
|
+
return html`<div
|
|
180
|
+
part="menu"
|
|
181
|
+
role="menu"
|
|
182
|
+
aria-label=${this.label}
|
|
183
|
+
@keydown=${this.onKeyDown}
|
|
184
|
+
>
|
|
185
|
+
${this.items.map((item) => html`<button
|
|
186
|
+
part="item"
|
|
187
|
+
type="button"
|
|
188
|
+
role=${item.checked === void 0 ? "menuitem" : "menuitemcheckbox"}
|
|
189
|
+
aria-checked=${item.checked === void 0 ? nothing : String(item.checked)}
|
|
190
|
+
aria-keyshortcuts=${item.shortcut ? ariaKeyShortcut(item.shortcut) : nothing}
|
|
191
|
+
class=${item.danger ? "danger" : nothing}
|
|
192
|
+
?disabled=${item.disabled}
|
|
193
|
+
data-value=${item.value}
|
|
194
|
+
@click=${() => this.choose(item)}
|
|
195
|
+
>
|
|
196
|
+
${showStart ? this.renderStart(item) : nothing}<span class="label"
|
|
197
|
+
>${item.label}</span
|
|
198
|
+
>${this.renderEnd(item)}
|
|
199
|
+
</button>`)}
|
|
200
|
+
</div>`;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
defineElement("pc-menu", PcMenu);
|
|
204
|
+
export { MAX_SHORTCUT_LABEL_LENGTH, PcMenu };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { nothing, type PropertyValues, type TemplateResult } from "lit";
|
|
2
|
+
import { PcElement } from "../../base";
|
|
3
|
+
import { PcPanel } from "../PcPanel";
|
|
4
|
+
import type { SideMode } from "../../layout";
|
|
5
|
+
/** Which way a pane's start, middle and end run */
|
|
6
|
+
export type PaneOrientation = "vertical" | "horizontal";
|
|
7
|
+
/** Which edge of the layout a pane is on: panels opened from its rail, and its floating box, go the other way */
|
|
8
|
+
export type PaneEdge = "left" | "right" | "top" | "bottom";
|
|
9
|
+
/** Event fired when a floating pane is shown or collapsed (detail: `{ collapsed }`) */
|
|
10
|
+
export declare const PANE_COLLAPSE_EVENT = "pc-collapse";
|
|
11
|
+
/**
|
|
12
|
+
* An area where buttons and panels are shown or docked, e.g. a side of the `<paint-canvas>` layout. Its content goes in
|
|
13
|
+
* its `start`, `middle` and `end` slots (content without a slot goes at the start), which run down a `vertical` pane
|
|
14
|
+
* (the default) or across a `horizontal` one; the middle takes the space left.
|
|
15
|
+
*
|
|
16
|
+
* Its `mode` sets how it shows its panels (`PcPanel`s, e.g. `<pc-panel-layers>`):
|
|
17
|
+
* - `docked`: as they are.
|
|
18
|
+
* - `rail`: as a column of buttons (with each panel's icon, name and badge) that open one panel at a time over the
|
|
19
|
+
* canvas, beside the pane (away from its `edge`). Focus moves into the panel; Escape, a press outside it or its
|
|
20
|
+
* button again closes it, and focus goes back to the button.
|
|
21
|
+
* - `floating`: the pane floats over the canvas as a box that collapses to a button (`collapsed`, named with its
|
|
22
|
+
* `label`), firing `pc-collapse` when it's shown or collapsed.
|
|
23
|
+
*
|
|
24
|
+
* Panes made for one purpose extend it and put their own content in its regions (see `renderStart`, `renderMiddle`
|
|
25
|
+
* and `renderEnd`), e.g. `<pc-toolbar>`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* html`<pc-pane edge="right" mode="rail" label="Panels"><pc-panel-layers .app=${app}></pc-panel-layers></pc-pane>`
|
|
29
|
+
*/
|
|
30
|
+
export declare class PcPane extends PcElement {
|
|
31
|
+
static properties: {
|
|
32
|
+
orientation: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
reflect: boolean;
|
|
35
|
+
};
|
|
36
|
+
mode: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
reflect: boolean;
|
|
39
|
+
};
|
|
40
|
+
edge: {
|
|
41
|
+
type: StringConstructor;
|
|
42
|
+
reflect: boolean;
|
|
43
|
+
};
|
|
44
|
+
label: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
};
|
|
47
|
+
collapsed: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
reflect: boolean;
|
|
50
|
+
};
|
|
51
|
+
openPanel: {
|
|
52
|
+
state: boolean;
|
|
53
|
+
};
|
|
54
|
+
translations: {
|
|
55
|
+
attribute: boolean;
|
|
56
|
+
};
|
|
57
|
+
icons: {
|
|
58
|
+
attribute: boolean;
|
|
59
|
+
};
|
|
60
|
+
theme: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
static styles: import("lit").CSSResultGroup[];
|
|
66
|
+
/** Which way its start, middle and end run (`vertical` by default) */
|
|
67
|
+
orientation: PaneOrientation;
|
|
68
|
+
/** How it shows its panels (`docked` by default) */
|
|
69
|
+
mode: SideMode;
|
|
70
|
+
/** Which edge of the layout it's on (`left` by default) */
|
|
71
|
+
edge: PaneEdge;
|
|
72
|
+
/** Names it, e.g. on its button when floating and collapsed */
|
|
73
|
+
label: string;
|
|
74
|
+
/** Whether it's collapsed to a button while floating (true until opened) */
|
|
75
|
+
collapsed: boolean;
|
|
76
|
+
/** The panel open from its rail, if any */
|
|
77
|
+
openPanel?: PcPanel;
|
|
78
|
+
/** The panels in it */
|
|
79
|
+
private panels;
|
|
80
|
+
/** The rail button that opened the open panel, to return focus to */
|
|
81
|
+
private opener?;
|
|
82
|
+
private readonly panelObserver;
|
|
83
|
+
private readonly onDocumentPointerDown;
|
|
84
|
+
private readonly onKeyDown;
|
|
85
|
+
constructor();
|
|
86
|
+
connectedCallback(): void;
|
|
87
|
+
disconnectedCallback(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Open a panel over the canvas from its rail button (closing any other), or close it if it's open. Focus moves into
|
|
90
|
+
* the panel: to the first thing in it that takes focus, or the panel itself.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* pane.togglePanel(pane.querySelector("pc-panel-layers"));
|
|
94
|
+
*/
|
|
95
|
+
togglePanel(panel: PcPanel, opener?: HTMLElement): void;
|
|
96
|
+
/**
|
|
97
|
+
* Close the panel open from the rail, moving focus back to its rail button if asked.
|
|
98
|
+
*/
|
|
99
|
+
closePanel(returnFocus: boolean): void;
|
|
100
|
+
/** Show or collapse the floating pane, telling listeners */
|
|
101
|
+
private toggleCollapsed;
|
|
102
|
+
/** Follow the panels slotted into it */
|
|
103
|
+
private onSlotChange;
|
|
104
|
+
/** Show the panels for the mode: hidden behind the rail (except the open one, beside the pane) or as they are */
|
|
105
|
+
private syncPanels;
|
|
106
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
107
|
+
/** Content of its own at its start, before what's slotted there */
|
|
108
|
+
protected renderStart(): TemplateResult | typeof nothing;
|
|
109
|
+
/** Content of its own in its middle, before what's slotted there */
|
|
110
|
+
protected renderMiddle(): TemplateResult | typeof nothing;
|
|
111
|
+
/** Content of its own at its end, before what's slotted there */
|
|
112
|
+
protected renderEnd(): TemplateResult | typeof nothing;
|
|
113
|
+
/** The rail: a button per panel */
|
|
114
|
+
private renderRail;
|
|
115
|
+
/** The button that shows or collapses a floating pane */
|
|
116
|
+
private renderCollapse;
|
|
117
|
+
render(): TemplateResult<1>;
|
|
118
|
+
}
|