@sealpixel/ui 1.0.0-rc.0 → 1.0.0-rc.2
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.md +1 -1
- package/dist/theme.js +6 -6
- package/package.json +5 -5
- package/dist/components/lumbra-button.d.ts +0 -28
- package/dist/components/lumbra-button.d.ts.map +0 -1
- package/dist/components/lumbra-button.js +0 -87
- package/dist/components/lumbra-button.js.map +0 -1
- package/dist/components/lumbra-editor.d.ts +0 -226
- package/dist/components/lumbra-editor.d.ts.map +0 -1
- package/dist/components/lumbra-editor.js +0 -873
- package/dist/components/lumbra-editor.js.map +0 -1
- package/dist/components/lumbra-nav.d.ts +0 -48
- package/dist/components/lumbra-nav.d.ts.map +0 -1
- package/dist/components/lumbra-nav.js +0 -159
- package/dist/components/lumbra-nav.js.map +0 -1
- package/dist/components/lumbra-slider.d.ts +0 -48
- package/dist/components/lumbra-slider.d.ts.map +0 -1
- package/dist/components/lumbra-slider.js +0 -168
- package/dist/components/lumbra-slider.js.map +0 -1
- package/dist/components/lumbra-stage.d.ts +0 -92
- package/dist/components/lumbra-stage.d.ts.map +0 -1
- package/dist/components/lumbra-stage.js +0 -344
- package/dist/components/lumbra-stage.js.map +0 -1
- package/dist/components/lumbra-toolbar.d.ts +0 -30
- package/dist/components/lumbra-toolbar.d.ts.map +0 -1
- package/dist/components/lumbra-toolbar.js +0 -127
- package/dist/components/lumbra-toolbar.js.map +0 -1
- package/dist/components/pincel-button.d.ts +0 -28
- package/dist/components/pincel-button.d.ts.map +0 -1
- package/dist/components/pincel-button.js +0 -87
- package/dist/components/pincel-button.js.map +0 -1
- package/dist/components/pincel-editor.d.ts +0 -195
- package/dist/components/pincel-editor.d.ts.map +0 -1
- package/dist/components/pincel-editor.js +0 -794
- package/dist/components/pincel-editor.js.map +0 -1
- package/dist/components/pincel-nav.d.ts +0 -33
- package/dist/components/pincel-nav.d.ts.map +0 -1
- package/dist/components/pincel-nav.js +0 -147
- package/dist/components/pincel-nav.js.map +0 -1
- package/dist/components/pincel-slider.d.ts +0 -48
- package/dist/components/pincel-slider.d.ts.map +0 -1
- package/dist/components/pincel-slider.js +0 -168
- package/dist/components/pincel-slider.js.map +0 -1
- package/dist/components/pincel-stage.d.ts +0 -66
- package/dist/components/pincel-stage.d.ts.map +0 -1
- package/dist/components/pincel-stage.js +0 -233
- package/dist/components/pincel-stage.js.map +0 -1
- package/dist/components/pincel-toolbar.d.ts +0 -30
- package/dist/components/pincel-toolbar.d.ts.map +0 -1
- package/dist/components/pincel-toolbar.js +0 -127
- package/dist/components/pincel-toolbar.js.map +0 -1
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement, svg } from 'lit';
|
|
2
|
-
import { GestureController } from '../controllers/gesture-controller.js';
|
|
3
|
-
import { base } from '../theme.js';
|
|
4
|
-
/**
|
|
5
|
-
* Shows the preview on a canvas, fitted and zoomable, with an SVG overlay in
|
|
6
|
-
* image pixel coordinates for tool gizmos. Tier-A hints (CSS filter and
|
|
7
|
-
* transform) are applied to the canvas until the next preview arrives.
|
|
8
|
-
*/
|
|
9
|
-
export class PincelStage extends LitElement {
|
|
10
|
-
static { this.styles = [
|
|
11
|
-
base,
|
|
12
|
-
css `
|
|
13
|
-
:host {
|
|
14
|
-
display: block;
|
|
15
|
-
position: relative;
|
|
16
|
-
overflow: hidden;
|
|
17
|
-
background-color: var(--pincel-color-bg);
|
|
18
|
-
background-image:
|
|
19
|
-
linear-gradient(45deg, var(--pincel-stage-checker-a) 25%, transparent 25%),
|
|
20
|
-
linear-gradient(-45deg, var(--pincel-stage-checker-a) 25%, transparent 25%),
|
|
21
|
-
linear-gradient(45deg, transparent 75%, var(--pincel-stage-checker-a) 75%),
|
|
22
|
-
linear-gradient(-45deg, transparent 75%, var(--pincel-stage-checker-a) 75%);
|
|
23
|
-
background-size: 16px 16px;
|
|
24
|
-
background-position: 0 0, 0 8px, 8px -8px, -8px 0;
|
|
25
|
-
touch-action: none;
|
|
26
|
-
user-select: none;
|
|
27
|
-
}
|
|
28
|
-
.viewport {
|
|
29
|
-
position: absolute;
|
|
30
|
-
inset: 0;
|
|
31
|
-
}
|
|
32
|
-
.content {
|
|
33
|
-
position: absolute;
|
|
34
|
-
left: 0;
|
|
35
|
-
top: 0;
|
|
36
|
-
transform-origin: 0 0;
|
|
37
|
-
will-change: transform;
|
|
38
|
-
}
|
|
39
|
-
canvas {
|
|
40
|
-
display: block;
|
|
41
|
-
image-rendering: auto;
|
|
42
|
-
transform-origin: 50% 50%;
|
|
43
|
-
box-shadow: var(--pincel-shadow, none);
|
|
44
|
-
}
|
|
45
|
-
svg.overlay {
|
|
46
|
-
position: absolute;
|
|
47
|
-
left: 0;
|
|
48
|
-
top: 0;
|
|
49
|
-
overflow: visible;
|
|
50
|
-
pointer-events: none;
|
|
51
|
-
}
|
|
52
|
-
svg.overlay [data-interactive] {
|
|
53
|
-
pointer-events: all;
|
|
54
|
-
}
|
|
55
|
-
.status {
|
|
56
|
-
position: absolute;
|
|
57
|
-
right: var(--pincel-space);
|
|
58
|
-
bottom: var(--pincel-space);
|
|
59
|
-
padding: 3px 9px;
|
|
60
|
-
border-radius: 999px;
|
|
61
|
-
background: color-mix(in srgb, var(--pincel-color-surface) 85%, transparent);
|
|
62
|
-
color: var(--pincel-color-fg-muted);
|
|
63
|
-
font-size: 12px;
|
|
64
|
-
font-variant-numeric: tabular-nums;
|
|
65
|
-
pointer-events: none;
|
|
66
|
-
backdrop-filter: blur(6px);
|
|
67
|
-
}
|
|
68
|
-
.pending {
|
|
69
|
-
position: absolute;
|
|
70
|
-
left: var(--pincel-space);
|
|
71
|
-
top: var(--pincel-space);
|
|
72
|
-
width: 8px;
|
|
73
|
-
height: 8px;
|
|
74
|
-
border-radius: 50%;
|
|
75
|
-
background: var(--pincel-color-accent);
|
|
76
|
-
opacity: 0.8;
|
|
77
|
-
}
|
|
78
|
-
`,
|
|
79
|
-
]; }
|
|
80
|
-
static { this.properties = {
|
|
81
|
-
preview: { attribute: false },
|
|
82
|
-
pending: { type: Boolean },
|
|
83
|
-
overlay: { attribute: false },
|
|
84
|
-
hintFilter: { attribute: false },
|
|
85
|
-
hintTransform: { attribute: false },
|
|
86
|
-
zoom: { type: Number },
|
|
87
|
-
panEnabled: { type: Boolean },
|
|
88
|
-
}; }
|
|
89
|
-
constructor() {
|
|
90
|
-
super();
|
|
91
|
-
this.canvas = null;
|
|
92
|
-
this.drawnVersion = -1;
|
|
93
|
-
this.pan = { x: 0, y: 0 };
|
|
94
|
-
this.fitted = false;
|
|
95
|
-
this.resizeObserver = null;
|
|
96
|
-
this.gestures = new GestureController(this, {
|
|
97
|
-
drag: (e) => {
|
|
98
|
-
if (!this.panEnabled)
|
|
99
|
-
return;
|
|
100
|
-
this.pan = { x: this.pan.x + e.dx, y: this.pan.y + e.dy };
|
|
101
|
-
this.requestUpdate();
|
|
102
|
-
},
|
|
103
|
-
pinch: (e) => this.zoomAround(e.scale, e.cx, e.cy, e.dx, e.dy),
|
|
104
|
-
wheelZoom: (e) => this.zoomAround(e.factor, e.cx, e.cy, 0, 0),
|
|
105
|
-
wheelPan: (e) => {
|
|
106
|
-
this.pan = { x: this.pan.x + e.dx, y: this.pan.y + e.dy };
|
|
107
|
-
this.requestUpdate();
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
this.preview = null;
|
|
111
|
-
this.pending = false;
|
|
112
|
-
this.overlay = null;
|
|
113
|
-
this.hintFilter = '';
|
|
114
|
-
this.hintTransform = '';
|
|
115
|
-
this.zoom = 1;
|
|
116
|
-
this.panEnabled = true;
|
|
117
|
-
}
|
|
118
|
-
get geometry() {
|
|
119
|
-
return this.preview?.geometry ?? null;
|
|
120
|
-
}
|
|
121
|
-
get imageWidth() {
|
|
122
|
-
return this.preview?.image.width ?? 0;
|
|
123
|
-
}
|
|
124
|
-
get imageHeight() {
|
|
125
|
-
return this.preview?.image.height ?? 0;
|
|
126
|
-
}
|
|
127
|
-
/** Converts a client point into preview image pixels. */
|
|
128
|
-
toImage(clientX, clientY) {
|
|
129
|
-
const r = this.getBoundingClientRect();
|
|
130
|
-
return {
|
|
131
|
-
x: (clientX - r.left - this.pan.x) / this.zoom,
|
|
132
|
-
y: (clientY - r.top - this.pan.y) / this.zoom,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
fit() {
|
|
136
|
-
const w = this.imageWidth;
|
|
137
|
-
const h = this.imageHeight;
|
|
138
|
-
if (!w || !h)
|
|
139
|
-
return;
|
|
140
|
-
const r = this.getBoundingClientRect();
|
|
141
|
-
const margin = 24;
|
|
142
|
-
const zoom = Math.min((r.width - margin) / w, (r.height - margin) / h, 4);
|
|
143
|
-
this.zoom = Math.max(zoom, 0.01);
|
|
144
|
-
this.pan = { x: (r.width - w * this.zoom) / 2, y: (r.height - h * this.zoom) / 2 };
|
|
145
|
-
this.fitted = true;
|
|
146
|
-
this.requestUpdate();
|
|
147
|
-
this.viewChanged();
|
|
148
|
-
}
|
|
149
|
-
/** Zoom or pan changed: overlays scale their gizmos by zoom and must re-render. */
|
|
150
|
-
viewChanged() {
|
|
151
|
-
this.dispatchEvent(new CustomEvent('stage-view', { detail: { zoom: this.zoom, pan: this.pan } }));
|
|
152
|
-
}
|
|
153
|
-
connectedCallback() {
|
|
154
|
-
super.connectedCallback();
|
|
155
|
-
this.resizeObserver = new ResizeObserver(() => {
|
|
156
|
-
if (this.fitted)
|
|
157
|
-
this.fit();
|
|
158
|
-
});
|
|
159
|
-
this.resizeObserver.observe(this);
|
|
160
|
-
}
|
|
161
|
-
disconnectedCallback() {
|
|
162
|
-
super.disconnectedCallback();
|
|
163
|
-
this.resizeObserver?.disconnect();
|
|
164
|
-
}
|
|
165
|
-
firstUpdated() {
|
|
166
|
-
this.canvas = this.renderRoot.querySelector('canvas');
|
|
167
|
-
this.gestures.attach(this.renderRoot.querySelector('.viewport'));
|
|
168
|
-
}
|
|
169
|
-
updated(changed) {
|
|
170
|
-
if (changed.has('preview'))
|
|
171
|
-
this.draw();
|
|
172
|
-
}
|
|
173
|
-
draw() {
|
|
174
|
-
const canvas = this.canvas;
|
|
175
|
-
const preview = this.preview;
|
|
176
|
-
if (!canvas || !preview)
|
|
177
|
-
return;
|
|
178
|
-
const { image } = preview;
|
|
179
|
-
const sizeChanged = canvas.width !== image.width || canvas.height !== image.height;
|
|
180
|
-
if (sizeChanged) {
|
|
181
|
-
canvas.width = image.width;
|
|
182
|
-
canvas.height = image.height;
|
|
183
|
-
}
|
|
184
|
-
if (preview.version !== this.drawnVersion || sizeChanged) {
|
|
185
|
-
const ctx = canvas.getContext('2d');
|
|
186
|
-
if (ctx) {
|
|
187
|
-
const data = new Uint8ClampedArray(image.data.byteLength);
|
|
188
|
-
data.set(image.data);
|
|
189
|
-
ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);
|
|
190
|
-
}
|
|
191
|
-
this.drawnVersion = preview.version;
|
|
192
|
-
// A real preview landed: drop tier-A hints.
|
|
193
|
-
this.hintFilter = '';
|
|
194
|
-
this.hintTransform = '';
|
|
195
|
-
}
|
|
196
|
-
if (!this.fitted || sizeChanged)
|
|
197
|
-
this.fit();
|
|
198
|
-
}
|
|
199
|
-
zoomAround(factor, cx, cy, dx, dy) {
|
|
200
|
-
const next = Math.min(16, Math.max(0.05, this.zoom * factor));
|
|
201
|
-
const k = next / this.zoom;
|
|
202
|
-
this.pan = { x: cx - (cx - this.pan.x) * k + dx, y: cy - (cy - this.pan.y) * k + dy };
|
|
203
|
-
this.zoom = next;
|
|
204
|
-
this.fitted = false;
|
|
205
|
-
this.requestUpdate();
|
|
206
|
-
this.viewChanged();
|
|
207
|
-
}
|
|
208
|
-
render() {
|
|
209
|
-
const w = this.imageWidth;
|
|
210
|
-
const h = this.imageHeight;
|
|
211
|
-
const transform = `translate(${this.pan.x}px, ${this.pan.y}px) scale(${this.zoom})`;
|
|
212
|
-
return html `
|
|
213
|
-
<div class="viewport" part="viewport">
|
|
214
|
-
<div class="content" style="transform:${transform}">
|
|
215
|
-
<canvas
|
|
216
|
-
part="canvas"
|
|
217
|
-
width=${w}
|
|
218
|
-
height=${h}
|
|
219
|
-
style="filter:${this.hintFilter || 'none'};transform:${this.hintTransform || 'none'}"
|
|
220
|
-
role="img"
|
|
221
|
-
aria-label="preview"
|
|
222
|
-
></canvas>
|
|
223
|
-
${this.overlay
|
|
224
|
-
? svg `<svg class="overlay" part="overlay" width=${w} height=${h} viewBox="0 0 ${w} ${h}">${this.overlay}</svg>`
|
|
225
|
-
: null}
|
|
226
|
-
</div>
|
|
227
|
-
</div>
|
|
228
|
-
${this.pending ? html `<div class="pending" aria-hidden="true"></div>` : null}
|
|
229
|
-
<div class="status" part="status" aria-hidden="true">${Math.round(this.zoom * 100)}%</div>
|
|
230
|
-
`;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
//# sourceMappingURL=pincel-stage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pincel-stage.js","sourceRoot":"","sources":["../../src/components/pincel-stage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAuB,MAAM,KAAK,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;aACzB,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkEF;KACF,AArEqB,CAqEpB;aAEc,eAAU,GAAG;QAC3B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;QAC1B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC7B,UAAU,EAAE,EAAE,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AC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAEQ,MAAM;QACb,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QAC3B,MAAM,SAAS,GAAG,aAAa,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,IAAI,CAAC,IAAI,GAAG,CAAC;QACpF,OAAO,IAAI,CAAA;;gDAEiC,SAAS;;;oBAGrC,CAAC;qBACA,CAAC;4BACM,IAAI,CAAC,UAAU,IAAI,MAAM,cAAc,IAAI,CAAC,aAAa,IAAI,MAAM;;;;YAKnF,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,GAAG,CAAA,6CAA6C,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,QAAQ;YAC/G,CAAC,CAAC,IACN;;;QAGF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,gDAAgD,CAAC,CAAC,CAAC,IAAI;6DACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;KACnF,CAAC;IACJ,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import type { UiTool } from '../tool.js';
|
|
3
|
-
/** Tool switcher with roving tabindex. Horizontal on narrow layouts, vertical on wide. */
|
|
4
|
-
export declare class PincelToolbar extends LitElement {
|
|
5
|
-
static styles: import("lit").CSSResult[];
|
|
6
|
-
static properties: {
|
|
7
|
-
tools: {
|
|
8
|
-
attribute: boolean;
|
|
9
|
-
};
|
|
10
|
-
active: {
|
|
11
|
-
type: StringConstructor;
|
|
12
|
-
};
|
|
13
|
-
orientation: {
|
|
14
|
-
type: StringConstructor;
|
|
15
|
-
reflect: boolean;
|
|
16
|
-
};
|
|
17
|
-
t: {
|
|
18
|
-
attribute: boolean;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
tools: UiTool[];
|
|
22
|
-
active: string | null;
|
|
23
|
-
orientation: 'horizontal' | 'vertical';
|
|
24
|
-
t: (key: string) => string;
|
|
25
|
-
constructor();
|
|
26
|
-
render(): import("lit").TemplateResult<1>;
|
|
27
|
-
private select;
|
|
28
|
-
private onKeydown;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=pincel-toolbar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pincel-toolbar.d.ts","sourceRoot":"","sources":["../../src/components/pincel-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,0FAA0F;AAC1F,qBAAa,aAAc,SAAQ,UAAU;IAC3C,OAAgB,MAAM,4BA4EpB;IAEF,OAAgB,UAAU;;;;;;;;;;;;;;MAKxB;IAEM,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,YAAY,GAAG,UAAU,CAAC;IACvC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;;IAU1B,MAAM;IAkBf,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,SAAS,CAiBf;CACH"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement } from 'lit';
|
|
2
|
-
import { base } from '../theme.js';
|
|
3
|
-
/** Tool switcher with roving tabindex. Horizontal on narrow layouts, vertical on wide. */
|
|
4
|
-
export class PincelToolbar extends LitElement {
|
|
5
|
-
static { this.styles = [
|
|
6
|
-
base,
|
|
7
|
-
css `
|
|
8
|
-
:host {
|
|
9
|
-
display: flex;
|
|
10
|
-
padding: 4px;
|
|
11
|
-
background: var(--pincel-color-surface);
|
|
12
|
-
border-top: 1px solid var(--pincel-color-border);
|
|
13
|
-
overflow: auto;
|
|
14
|
-
scrollbar-width: thin;
|
|
15
|
-
}
|
|
16
|
-
.tools {
|
|
17
|
-
display: flex;
|
|
18
|
-
gap: 4px;
|
|
19
|
-
/* Centres when it fits, scrolls from the first button when it does not. */
|
|
20
|
-
margin: auto;
|
|
21
|
-
}
|
|
22
|
-
:host([orientation='vertical']) {
|
|
23
|
-
border-top: none;
|
|
24
|
-
border-right: 1px solid var(--pincel-color-border);
|
|
25
|
-
}
|
|
26
|
-
:host([orientation='vertical']) .tools {
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
margin: 0;
|
|
29
|
-
}
|
|
30
|
-
button {
|
|
31
|
-
min-width: var(--pincel-touch-target);
|
|
32
|
-
min-height: calc(var(--pincel-touch-target) + 10px);
|
|
33
|
-
border: 1px solid transparent;
|
|
34
|
-
border-radius: var(--pincel-radius);
|
|
35
|
-
background: transparent;
|
|
36
|
-
color: var(--pincel-color-fg-muted);
|
|
37
|
-
font: inherit;
|
|
38
|
-
font-size: 11px;
|
|
39
|
-
font-weight: 500;
|
|
40
|
-
letter-spacing: 0.01em;
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
display: flex;
|
|
43
|
-
flex-direction: column;
|
|
44
|
-
align-items: center;
|
|
45
|
-
justify-content: center;
|
|
46
|
-
gap: 4px;
|
|
47
|
-
padding: 6px 4px;
|
|
48
|
-
max-width: 100%;
|
|
49
|
-
transition:
|
|
50
|
-
background var(--pincel-transition),
|
|
51
|
-
color var(--pincel-transition);
|
|
52
|
-
}
|
|
53
|
-
button:hover {
|
|
54
|
-
color: var(--pincel-color-fg);
|
|
55
|
-
background: var(--pincel-color-surface-2);
|
|
56
|
-
}
|
|
57
|
-
button[aria-pressed='true'] {
|
|
58
|
-
color: var(--pincel-color-accent);
|
|
59
|
-
background: var(--pincel-color-accent-soft, var(--pincel-color-surface-2));
|
|
60
|
-
}
|
|
61
|
-
.icon {
|
|
62
|
-
font-size: 20px;
|
|
63
|
-
line-height: 1;
|
|
64
|
-
width: 28px;
|
|
65
|
-
height: 28px;
|
|
66
|
-
display: grid;
|
|
67
|
-
place-items: center;
|
|
68
|
-
border-radius: 8px;
|
|
69
|
-
}
|
|
70
|
-
button[aria-pressed='true'] .icon {
|
|
71
|
-
background: var(--pincel-color-accent);
|
|
72
|
-
color: var(--pincel-color-accent-fg);
|
|
73
|
-
}
|
|
74
|
-
.label {
|
|
75
|
-
max-width: 100%;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
text-overflow: ellipsis;
|
|
78
|
-
white-space: nowrap;
|
|
79
|
-
}
|
|
80
|
-
`,
|
|
81
|
-
]; }
|
|
82
|
-
static { this.properties = {
|
|
83
|
-
tools: { attribute: false },
|
|
84
|
-
active: { type: String },
|
|
85
|
-
orientation: { type: String, reflect: true },
|
|
86
|
-
t: { attribute: false },
|
|
87
|
-
}; }
|
|
88
|
-
constructor() {
|
|
89
|
-
super();
|
|
90
|
-
this.onKeydown = (e) => {
|
|
91
|
-
const keys = this.orientation === 'vertical' ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight'];
|
|
92
|
-
const dir = e.key === keys[0] ? -1 : e.key === keys[1] ? 1 : 0;
|
|
93
|
-
if (dir === 0)
|
|
94
|
-
return;
|
|
95
|
-
e.preventDefault();
|
|
96
|
-
const idx = Math.max(0, this.tools.findIndex((t) => t.id === this.active));
|
|
97
|
-
const next = this.tools[(idx + dir + this.tools.length) % this.tools.length];
|
|
98
|
-
if (next) {
|
|
99
|
-
this.select(next.id);
|
|
100
|
-
this.updateComplete.then(() => this.renderRoot.querySelector(`[data-tool="${next.id}"]`)?.focus());
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
this.tools = [];
|
|
104
|
-
this.active = null;
|
|
105
|
-
this.orientation = 'horizontal';
|
|
106
|
-
this.t = (k) => k;
|
|
107
|
-
}
|
|
108
|
-
render() {
|
|
109
|
-
return html `<div class="tools" role="toolbar" aria-orientation=${this.orientation} @keydown=${this.onKeydown}>
|
|
110
|
-
${this.tools.map((tool, i) => html `<button
|
|
111
|
-
part="tool"
|
|
112
|
-
type="button"
|
|
113
|
-
data-tool=${tool.id}
|
|
114
|
-
aria-pressed=${this.active === tool.id ? 'true' : 'false'}
|
|
115
|
-
tabindex=${this.active === tool.id || (this.active === null && i === 0) ? 0 : -1}
|
|
116
|
-
@click=${() => this.select(tool.id)}
|
|
117
|
-
>
|
|
118
|
-
<span class="icon" aria-hidden="true">${tool.icon}</span>
|
|
119
|
-
<span class="label">${this.t(tool.label)}</span>
|
|
120
|
-
</button>`)}
|
|
121
|
-
</div>`;
|
|
122
|
-
}
|
|
123
|
-
select(id) {
|
|
124
|
-
this.dispatchEvent(new CustomEvent('tool-select', { detail: id, bubbles: true, composed: true }));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=pincel-toolbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pincel-toolbar.js","sourceRoot":"","sources":["../../src/components/pincel-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,0FAA0F;AAC1F,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyEF;KACF,AA5EqB,CA4EpB;aAEc,eAAU,GAAG;QAC3B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC3B,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5C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