@mintplayer/web-components 2.1.1 → 2.3.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/a11y/index.mjs +26 -2
- package/a11y/src/dismiss-stack.d.ts +25 -0
- package/a11y/src/error-text.d.ts +41 -0
- package/a11y/src/focus-restore.d.ts +116 -0
- package/a11y/src/focus-trap.d.ts +69 -0
- package/a11y/src/form-associated.d.ts +48 -0
- package/a11y/src/host-aria.d.ts +154 -0
- package/a11y/src/index.d.ts +16 -0
- package/a11y/src/inert-regions.d.ts +52 -0
- package/a11y/src/live-announcer.d.ts +8 -0
- package/a11y/src/roving-focus.d.ts +118 -0
- package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
- package/a11y/src/testing/index.d.ts +1 -0
- package/accordion/index.d.ts +1 -0
- package/accordion/index.mjs +549 -0
- package/accordion/src/components/index.d.ts +3 -0
- package/accordion/src/components/mp-accordion-tab.d.ts +30 -0
- package/accordion/src/components/mp-accordion.d.ts +66 -0
- package/accordion/src/index.d.ts +3 -0
- package/accordion/src/styles/index.d.ts +1 -0
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.d.ts +1 -0
- package/carousel/index.mjs +994 -0
- package/carousel/src/components/index.d.ts +1 -0
- package/carousel/src/components/mp-carousel.d.ts +58 -0
- package/carousel/src/index.d.ts +3 -0
- package/carousel/src/styles/index.d.ts +1 -0
- package/carousel/src/types/carousel.d.ts +10 -0
- package/carousel/src/types/index.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +59 -1
- package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
- package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
- package/chunks/form-associated-axmc5sY0.mjs +58 -0
- package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
- package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
- package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
- package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
- package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
- package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
- package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
- package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
- package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
- package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
- package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
- package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
- package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
- package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
- package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
- package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
- package/chunks/roving-focus-CrL9982a.mjs +129 -0
- package/code-snippet/index.mjs +21 -13
- package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +50 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/labels.d.ts +30 -0
- package/datepicker/index.mjs +45 -22
- package/datepicker/src/mp-datepicker.element.d.ts +30 -0
- package/datetime-picker/index.mjs +15 -9
- package/dock/index.mjs +365 -209
- package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
- package/dropdown-menu/index.mjs +135 -90
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
- package/file-manager/index.mjs +279 -214
- package/file-manager/src/components/mp-file-manager.d.ts +22 -0
- package/file-manager/src/types/messages.d.ts +9 -0
- package/multi-range/index.mjs +26 -10
- package/multi-range/src/mint-multi-range.element.d.ts +7 -0
- package/navbar/index.mjs +53 -39
- package/navbar/src/components/mp-navbar.d.ts +1 -0
- package/otp-input/index.mjs +82 -48
- package/otp-input/src/mint-otp-input.element.d.ts +31 -3
- package/overlay/index.mjs +2 -258
- package/overlay/src/overlay-controller.d.ts +64 -4
- package/package.json +21 -1
- package/pagination/index.mjs +1 -1
- package/query-builder/index.mjs +117 -87
- package/query-builder/src/model/messages.d.ts +9 -0
- package/radio/index.mjs +2 -160
- package/radio/src/components/mp-radio.d.ts +58 -3
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.mjs +145 -0
- package/radio-group/src/components/mp-radio-group.d.ts +52 -0
- package/radio-group/src/index.d.ts +1 -0
- package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
- package/ribbon/index.mjs +316 -304
- package/ribbon/src/mp-ribbon.element.d.ts +16 -0
- package/scheduler/index.mjs +219 -132
- package/scheduler/src/components/mp-scheduler.d.ts +3 -0
- package/scheduler/src/views/base-view.d.ts +23 -0
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +60 -3
- package/shell/index.mjs +142 -31
- package/shell/src/components/mp-shell.d.ts +1 -0
- package/signature-pad/index.d.ts +1 -0
- package/signature-pad/index.mjs +230 -0
- package/signature-pad/src/index.d.ts +2 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
- package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
- package/signature-pad/src/types/signature.d.ts +12 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +7 -0
- package/splitter/src/index.d.ts +1 -1
- package/swiper-core/index.d.ts +1 -0
- package/swiper-core/index.mjs +184 -0
- package/swiper-core/src/index-machine.d.ts +59 -0
- package/swiper-core/src/index.d.ts +4 -0
- package/swiper-core/src/keymap.d.ts +2 -0
- package/swiper-core/src/models/index.d.ts +1 -0
- package/swiper-core/src/models/types.d.ts +99 -0
- package/swiper-core/src/pointer-arbiter.d.ts +45 -0
- package/tab-control/index.mjs +1 -1
- package/tile-manager/index.mjs +110 -93
- package/timeline/index.mjs +138 -54
- package/timeline/src/components/mp-timeline.d.ts +15 -0
- package/timepicker/index.mjs +1 -1
- package/timepicker/src/mp-time-list.element.d.ts +13 -4
- package/timepicker/src/mp-timepicker.element.d.ts +29 -0
- package/toggle-button/index.mjs +1 -1
- package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
- package/tree-select/index.mjs +233 -121
- package/tree-select/src/components/mp-tree-select.d.ts +37 -0
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +10 -1
- package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
- package/dropdown/src/styles/dropdown.styles.d.ts +0 -2
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { html as a, unsafeCSS as d, LitElement as b, nothing as p } from "lit";
|
|
2
|
+
import { query as c } from "lit/decorators.js";
|
|
3
|
+
import "lit/directives/ref.js";
|
|
4
|
+
import { H as g } from "../chunks/host-aria-WSGs7SPQ.mjs";
|
|
5
|
+
a`<!-- Rendered dynamically by render(). This file exists only so the codegen-wc
|
|
6
|
+
target emits a \`styles\` export from the sibling .scss. -->`;
|
|
7
|
+
const f = d(`:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
border: 1px solid var(--bs-border-color, #dee2e6);
|
|
12
|
+
border-radius: var(--bs-border-radius, 0.375rem);
|
|
13
|
+
background-color: var(--bs-body-bg, #fff);
|
|
14
|
+
font-family: inherit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
canvas {
|
|
18
|
+
display: block;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
height: auto;
|
|
21
|
+
touch-action: none;
|
|
22
|
+
cursor: crosshair;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.controls {
|
|
26
|
+
display: flex;
|
|
27
|
+
gap: 0.25rem;
|
|
28
|
+
padding: 0.25rem;
|
|
29
|
+
border-top: 1px solid var(--bs-border-color, #dee2e6);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
input.form-control {
|
|
33
|
+
flex: 1 1 auto;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
padding: 0.25rem 0.5rem;
|
|
36
|
+
font-size: 0.875rem;
|
|
37
|
+
line-height: 1.5;
|
|
38
|
+
color: var(--bs-body-color, #212529);
|
|
39
|
+
background-color: var(--bs-body-bg, #fff);
|
|
40
|
+
background-clip: padding-box;
|
|
41
|
+
border: 1px solid var(--bs-border-color, #dee2e6);
|
|
42
|
+
border-radius: var(--bs-border-radius-sm, 0.25rem);
|
|
43
|
+
outline: 0;
|
|
44
|
+
}
|
|
45
|
+
input.form-control:focus {
|
|
46
|
+
border-color: var(--bs-primary, #0d6efd);
|
|
47
|
+
box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb, 13, 110, 253), 0.25);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
button.control-btn {
|
|
51
|
+
flex: 0 0 auto;
|
|
52
|
+
padding: 0.25rem 0.5rem;
|
|
53
|
+
font-size: 0.875rem;
|
|
54
|
+
line-height: 1.5;
|
|
55
|
+
color: var(--bs-secondary, #6c757d);
|
|
56
|
+
background-color: transparent;
|
|
57
|
+
border: 1px solid var(--bs-secondary, #6c757d);
|
|
58
|
+
border-radius: var(--bs-border-radius-sm, 0.25rem);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
button.control-btn:hover {
|
|
62
|
+
color: #fff;
|
|
63
|
+
background-color: var(--bs-secondary, #6c757d);
|
|
64
|
+
}
|
|
65
|
+
button.control-btn:focus-visible {
|
|
66
|
+
outline: 2px solid var(--bs-primary, #0d6efd);
|
|
67
|
+
outline-offset: 2px;
|
|
68
|
+
}`);
|
|
69
|
+
var y = Object.defineProperty, u = (o, t, e, i) => {
|
|
70
|
+
for (var r = void 0, s = o.length - 1, n; s >= 0; s--)
|
|
71
|
+
(n = o[s]) && (r = n(t, e, r) || r);
|
|
72
|
+
return r && y(t, e, r), r;
|
|
73
|
+
};
|
|
74
|
+
class l extends b {
|
|
75
|
+
constructor() {
|
|
76
|
+
super(...arguments), this.width = 500, this.height = 300, this.inputLabel = null, this.typeLabel = "Type your signature", this.undoLabel = "Undo", this.clearLabel = "Clear", this.showAccessibilityToggle = !0, this.ariaLabelForRender = null, this.ariaLabelledByForSync = null, this.ariaDescribedByForSync = null, this._signature = { strokes: [] }, this._isDrawing = !1, this._context = null, this.hostAria = new g(this, {
|
|
77
|
+
referenceTarget: () => this.canvasEl ?? null
|
|
78
|
+
}), this.onPointerStart = (t) => {
|
|
79
|
+
t.preventDefault(), this._isDrawing = !0;
|
|
80
|
+
const e = this.toCanvasPoint(t);
|
|
81
|
+
this._signature.strokes.push({ points: [e] }), this._signature = { ...this._signature }, this._context && (this._context.strokeStyle = "black", this._context.beginPath(), this._context.moveTo(e.x, e.y)), this.dispatchSignatureChange();
|
|
82
|
+
}, this.onPointerMove = (t) => {
|
|
83
|
+
if (!this._isDrawing) return;
|
|
84
|
+
t.preventDefault();
|
|
85
|
+
const e = this.toCanvasPoint(t);
|
|
86
|
+
this._signature.strokes.at(-1)?.points.push(e), this._signature = { ...this._signature }, this._context && (this._context.lineTo(e.x, e.y), this._context.stroke()), this.dispatchSignatureChange();
|
|
87
|
+
}, this.onPointerEnd = (t) => {
|
|
88
|
+
this._isDrawing && (t.preventDefault(), this._isDrawing = !1);
|
|
89
|
+
}, this.onTypedInput = (t) => {
|
|
90
|
+
const e = t.target.value;
|
|
91
|
+
this._signature = { ...this._signature, text: e || void 0 }, this.redraw(), this.dispatchSignatureChange();
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
static {
|
|
95
|
+
this.styles = [f];
|
|
96
|
+
}
|
|
97
|
+
static {
|
|
98
|
+
this.properties = {
|
|
99
|
+
signature: { attribute: !1 },
|
|
100
|
+
width: { attribute: "width", type: Number, reflect: !0 },
|
|
101
|
+
height: { attribute: "height", type: Number, reflect: !0 },
|
|
102
|
+
inputLabel: { attribute: "input-label", type: String, reflect: !1 },
|
|
103
|
+
typeLabel: { attribute: "type-label", type: String, reflect: !1 },
|
|
104
|
+
undoLabel: { attribute: "undo-label", type: String, reflect: !1 },
|
|
105
|
+
clearLabel: { attribute: "clear-label", type: String, reflect: !1 },
|
|
106
|
+
// Default-true boolean: presence-style attributes cannot express "off",
|
|
107
|
+
// so the attribute takes an explicit "false" (any other value, including
|
|
108
|
+
// bare presence, means true).
|
|
109
|
+
showAccessibilityToggle: {
|
|
110
|
+
attribute: "show-accessibility-toggle",
|
|
111
|
+
converter: { fromAttribute: (t) => t !== "false" },
|
|
112
|
+
reflect: !1
|
|
113
|
+
},
|
|
114
|
+
// Not a real property; listed so a host aria-label change re-renders. The
|
|
115
|
+
// consumer's aria-label wins over inputLabel, same precedence as every
|
|
116
|
+
// other control in the library.
|
|
117
|
+
ariaLabelForRender: { attribute: "aria-label", type: String, reflect: !1 },
|
|
118
|
+
// Phantom too: reference attributes are re-resolved in updated().
|
|
119
|
+
ariaLabelledByForSync: { attribute: "aria-labelledby", type: String, reflect: !1 },
|
|
120
|
+
ariaDescribedByForSync: { attribute: "aria-describedby", type: String, reflect: !1 }
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
get signature() {
|
|
124
|
+
return this._signature;
|
|
125
|
+
}
|
|
126
|
+
set signature(t) {
|
|
127
|
+
const e = this._signature;
|
|
128
|
+
this._signature = t ?? { strokes: [] }, this.requestUpdate("signature", e);
|
|
129
|
+
}
|
|
130
|
+
connectedCallback() {
|
|
131
|
+
super.connectedCallback(), typeof window < "u" && window.addEventListener("pointerup", this.onPointerEnd);
|
|
132
|
+
}
|
|
133
|
+
disconnectedCallback() {
|
|
134
|
+
super.disconnectedCallback(), typeof window < "u" && window.removeEventListener("pointerup", this.onPointerEnd);
|
|
135
|
+
}
|
|
136
|
+
/** Focus the pad = focus its typed-signature input (the keyboard entry point). */
|
|
137
|
+
focus(t) {
|
|
138
|
+
const e = this.typedInputEl;
|
|
139
|
+
e ? e.focus(t) : super.focus(t);
|
|
140
|
+
}
|
|
141
|
+
undo() {
|
|
142
|
+
this._signature.strokes.length && (this._signature = { ...this._signature, strokes: this._signature.strokes.slice(0, -1) }, this.requestUpdate(), this.redraw(), this.dispatchSignatureChange());
|
|
143
|
+
}
|
|
144
|
+
clear() {
|
|
145
|
+
!this._signature.strokes.length && !this._signature.text || (this._signature = { strokes: [] }, this.requestUpdate(), this.redraw(), this.dispatchSignatureChange());
|
|
146
|
+
}
|
|
147
|
+
firstUpdated() {
|
|
148
|
+
this._context = this.canvasEl?.getContext("2d", { willReadFrequently: !0 }) ?? null, this.redraw();
|
|
149
|
+
}
|
|
150
|
+
updated(t) {
|
|
151
|
+
this.hostAria.syncReferences(), (t.has("signature") || t.has("width") || t.has("height")) && this.redraw();
|
|
152
|
+
}
|
|
153
|
+
/* ---- Drawing ---- */
|
|
154
|
+
/**
|
|
155
|
+
* Map a pointer event into canvas BITMAP coordinates. `offsetX/offsetY` are
|
|
156
|
+
* CSS pixels of the rendered box; when the canvas is CSS-sized (e.g.
|
|
157
|
+
* `width: 100%`) those disagree with the `width`/`height` drawing space and
|
|
158
|
+
* every stroke would land offset and stretched. Scaling by
|
|
159
|
+
* bitmap-size / rendered-rect keeps drawing correct under any CSS sizing.
|
|
160
|
+
*/
|
|
161
|
+
toCanvasPoint(t) {
|
|
162
|
+
const e = this.canvasEl;
|
|
163
|
+
if (!e) return { x: t.offsetX, y: t.offsetY };
|
|
164
|
+
const i = e.getBoundingClientRect();
|
|
165
|
+
return !i.width || !i.height ? { x: t.offsetX, y: t.offsetY } : {
|
|
166
|
+
x: (t.clientX - i.left) * (e.width / i.width),
|
|
167
|
+
y: (t.clientY - i.top) * (e.height / i.height)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Repaint the canvas from the model: every stroke, then the typed text. */
|
|
171
|
+
redraw() {
|
|
172
|
+
const t = this._context;
|
|
173
|
+
if (!t) return;
|
|
174
|
+
const { strokes: e, text: i } = this._signature;
|
|
175
|
+
t.clearRect(0, 0, this.width, this.height), t.fillStyle = "black", t.strokeStyle = "black";
|
|
176
|
+
for (const r of e) {
|
|
177
|
+
const [s, ...n] = r.points;
|
|
178
|
+
if (s) {
|
|
179
|
+
t.beginPath(), t.moveTo(s.x, s.y);
|
|
180
|
+
for (const h of n)
|
|
181
|
+
t.lineTo(h.x, h.y);
|
|
182
|
+
t.stroke();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
i && (t.font = `${Math.min(this.height * 0.35, 64)}px "Segoe Script", "Brush Script MT", cursive`, t.textBaseline = "middle", t.fillText(i, 12, this.height / 2, this.width - 24));
|
|
186
|
+
}
|
|
187
|
+
dispatchSignatureChange() {
|
|
188
|
+
this.dispatchEvent(new CustomEvent("signature-change", {
|
|
189
|
+
detail: this._signature,
|
|
190
|
+
bubbles: !0,
|
|
191
|
+
composed: !0
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
/* ---- Render ---- */
|
|
195
|
+
render() {
|
|
196
|
+
const t = this.getAttribute("aria-label") ?? this.inputLabel ?? "Signature pad";
|
|
197
|
+
return a`
|
|
198
|
+
<canvas
|
|
199
|
+
width=${this.width}
|
|
200
|
+
height=${this.height}
|
|
201
|
+
role="img"
|
|
202
|
+
aria-label=${t}
|
|
203
|
+
@pointerdown=${this.onPointerStart}
|
|
204
|
+
@pointermove=${this.onPointerMove}
|
|
205
|
+
></canvas>
|
|
206
|
+
<div class="controls">
|
|
207
|
+
${this.showAccessibilityToggle ? a`<input
|
|
208
|
+
class="form-control"
|
|
209
|
+
type="text"
|
|
210
|
+
aria-label=${this.typeLabel}
|
|
211
|
+
placeholder=${this.typeLabel}
|
|
212
|
+
.value=${this._signature.text ?? ""}
|
|
213
|
+
@input=${this.onTypedInput}
|
|
214
|
+
/>` : p}
|
|
215
|
+
<button type="button" class="control-btn" @click=${() => this.undo()}>${this.undoLabel}</button>
|
|
216
|
+
<button type="button" class="control-btn" @click=${() => this.clear()}>${this.clearLabel}</button>
|
|
217
|
+
</div>
|
|
218
|
+
`;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
u([
|
|
222
|
+
c("canvas")
|
|
223
|
+
], l.prototype, "canvasEl");
|
|
224
|
+
u([
|
|
225
|
+
c("input.form-control")
|
|
226
|
+
], l.prototype, "typedInputEl");
|
|
227
|
+
typeof customElements < "u" && !customElements.get("mp-signature-pad") && customElements.define("mp-signature-pad", l);
|
|
228
|
+
export {
|
|
229
|
+
l as MpSignaturePadElement
|
|
230
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { Signature } from './types/signature';
|
|
3
|
+
/**
|
|
4
|
+
* mp-signature-pad — freehand signature capture with a typed alternative.
|
|
5
|
+
*
|
|
6
|
+
* Freehand drawing is inherently pointer-only — there is no keyboard
|
|
7
|
+
* equivalent for a hand-drawn stroke. The typed-signature input below the
|
|
8
|
+
* canvas is the accessible alternative: its value is stored on
|
|
9
|
+
* `Signature.text` and rendered onto the canvas in a script font, so a
|
|
10
|
+
* keyboard-only user produces the same artifact through the same model.
|
|
11
|
+
* Undo and Clear are plain buttons in the tab order.
|
|
12
|
+
*
|
|
13
|
+
* Properties / attributes:
|
|
14
|
+
* - `signature` (property only) the full model: `{ strokes, text }`.
|
|
15
|
+
* - `width` / `height` canvas dimensions in pixels.
|
|
16
|
+
* - `input-label` accessible name of the canvas (role="img");
|
|
17
|
+
* a host `aria-label` wins, as everywhere in
|
|
18
|
+
* the library. Defaults to 'Signature pad'.
|
|
19
|
+
* - `type-label` / `undo-label` / `clear-label` control labels.
|
|
20
|
+
* - `show-accessibility-toggle` shows the typed alternative; default true
|
|
21
|
+
* (it is the only keyboard path), switch off
|
|
22
|
+
* with an explicit "false" value.
|
|
23
|
+
*
|
|
24
|
+
* Events (bubbles + composed):
|
|
25
|
+
* - `signature-change` detail = the current Signature, on every mutation
|
|
26
|
+
* (stroke point, typed character, undo, clear).
|
|
27
|
+
*/
|
|
28
|
+
export declare class MpSignaturePadElement extends LitElement {
|
|
29
|
+
static styles: import('lit').CSSResult[];
|
|
30
|
+
static properties: {
|
|
31
|
+
signature: {
|
|
32
|
+
attribute: boolean;
|
|
33
|
+
};
|
|
34
|
+
width: {
|
|
35
|
+
attribute: string;
|
|
36
|
+
type: NumberConstructor;
|
|
37
|
+
reflect: boolean;
|
|
38
|
+
};
|
|
39
|
+
height: {
|
|
40
|
+
attribute: string;
|
|
41
|
+
type: NumberConstructor;
|
|
42
|
+
reflect: boolean;
|
|
43
|
+
};
|
|
44
|
+
inputLabel: {
|
|
45
|
+
attribute: string;
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
reflect: boolean;
|
|
48
|
+
};
|
|
49
|
+
typeLabel: {
|
|
50
|
+
attribute: string;
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
reflect: boolean;
|
|
53
|
+
};
|
|
54
|
+
undoLabel: {
|
|
55
|
+
attribute: string;
|
|
56
|
+
type: StringConstructor;
|
|
57
|
+
reflect: boolean;
|
|
58
|
+
};
|
|
59
|
+
clearLabel: {
|
|
60
|
+
attribute: string;
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
64
|
+
showAccessibilityToggle: {
|
|
65
|
+
attribute: string;
|
|
66
|
+
converter: {
|
|
67
|
+
fromAttribute: (v: string | null) => boolean;
|
|
68
|
+
};
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
ariaLabelForRender: {
|
|
72
|
+
attribute: string;
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
reflect: boolean;
|
|
75
|
+
};
|
|
76
|
+
ariaLabelledByForSync: {
|
|
77
|
+
attribute: string;
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
reflect: boolean;
|
|
80
|
+
};
|
|
81
|
+
ariaDescribedByForSync: {
|
|
82
|
+
attribute: string;
|
|
83
|
+
type: StringConstructor;
|
|
84
|
+
reflect: boolean;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
inputLabel: string | null;
|
|
90
|
+
typeLabel: string;
|
|
91
|
+
undoLabel: string;
|
|
92
|
+
clearLabel: string;
|
|
93
|
+
/**
|
|
94
|
+
* Shows the typed alternative. Named and defaulted exactly like
|
|
95
|
+
* bs-color-picker's showAccessibilityToggle: ON by default (the typed
|
|
96
|
+
* input is the only keyboard path a canvas can have), switched off with
|
|
97
|
+
* show-accessibility-toggle="false" only for deliberate draw-only flows
|
|
98
|
+
* that accept losing keyboard operability.
|
|
99
|
+
*/
|
|
100
|
+
showAccessibilityToggle: boolean;
|
|
101
|
+
/** Mirror of the host aria-label attribute; exists only to trigger re-renders. */
|
|
102
|
+
ariaLabelForRender: string | null;
|
|
103
|
+
ariaLabelledByForSync: string | null;
|
|
104
|
+
ariaDescribedByForSync: string | null;
|
|
105
|
+
private _signature;
|
|
106
|
+
private _isDrawing;
|
|
107
|
+
private _context;
|
|
108
|
+
private canvasEl?;
|
|
109
|
+
private typedInputEl?;
|
|
110
|
+
/** Tier-2 naming: host aria-labelledby/-describedby resolve to the canvas. */
|
|
111
|
+
private readonly hostAria;
|
|
112
|
+
get signature(): Signature;
|
|
113
|
+
set signature(next: Signature | null | undefined);
|
|
114
|
+
connectedCallback(): void;
|
|
115
|
+
disconnectedCallback(): void;
|
|
116
|
+
/** Focus the pad = focus its typed-signature input (the keyboard entry point). */
|
|
117
|
+
focus(options?: FocusOptions): void;
|
|
118
|
+
undo(): void;
|
|
119
|
+
clear(): void;
|
|
120
|
+
protected firstUpdated(): void;
|
|
121
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
122
|
+
/**
|
|
123
|
+
* Map a pointer event into canvas BITMAP coordinates. `offsetX/offsetY` are
|
|
124
|
+
* CSS pixels of the rendered box; when the canvas is CSS-sized (e.g.
|
|
125
|
+
* `width: 100%`) those disagree with the `width`/`height` drawing space and
|
|
126
|
+
* every stroke would land offset and stretched. Scaling by
|
|
127
|
+
* bitmap-size / rendered-rect keeps drawing correct under any CSS sizing.
|
|
128
|
+
*/
|
|
129
|
+
private toCanvasPoint;
|
|
130
|
+
private onPointerStart;
|
|
131
|
+
private onPointerMove;
|
|
132
|
+
private onPointerEnd;
|
|
133
|
+
private onTypedInput;
|
|
134
|
+
/** Repaint the canvas from the model: every stroke, then the typed text. */
|
|
135
|
+
private redraw;
|
|
136
|
+
private dispatchSignatureChange;
|
|
137
|
+
protected render(): TemplateResult;
|
|
138
|
+
}
|
|
139
|
+
declare global {
|
|
140
|
+
interface HTMLElementTagNameMap {
|
|
141
|
+
'mp-signature-pad': MpSignaturePadElement;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Point {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Stroke {
|
|
6
|
+
points: Point[];
|
|
7
|
+
}
|
|
8
|
+
export interface Signature {
|
|
9
|
+
strokes: Stroke[];
|
|
10
|
+
/** Typed-signature alternative for users who cannot draw with a pointer. */
|
|
11
|
+
text?: string;
|
|
12
|
+
}
|
package/splitter/index.mjs
CHANGED
|
@@ -76,6 +76,13 @@ export declare class MpSplitter extends LitElement {
|
|
|
76
76
|
* valuemax = (panels[i].size + panels[i+1].size - minPanelSize) as %.
|
|
77
77
|
*/
|
|
78
78
|
private updateDividerAriaValues;
|
|
79
|
+
/**
|
|
80
|
+
* updatePanelsFromSlot clears with innerHTML = '' — a focused divider is
|
|
81
|
+
* destroyed on every slot change (panes added/removed while the user is
|
|
82
|
+
* mid-resize), dropping focus to <body>. Keyed by position: divider N still
|
|
83
|
+
* separates the same region after a rebuild.
|
|
84
|
+
*/
|
|
85
|
+
private readonly dividerFocusRestore;
|
|
79
86
|
private updatePanelsFromSlot;
|
|
80
87
|
/**
|
|
81
88
|
* Read each panel-wrapper's measured pixel size and persist it as the
|
package/splitter/src/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { ResizeState } from './types';
|
|
|
7
7
|
export { ResizeManager } from './managers';
|
|
8
8
|
export type { ResizeManagerOptions } from './managers';
|
|
9
9
|
export { InputHandler, normalizePointerEvent } from './input';
|
|
10
|
-
export type { InputHandlerCallbacks, NormalizedPointerEvent } from './input';
|
|
10
|
+
export type { InputHandlerCallbacks, NormalizedPointerEvent, ResizeKey } from './input';
|
|
11
11
|
export { splitterStyles } from './styles';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
constructor(t, s = {}) {
|
|
3
|
+
this.callbacks = s, this.origin = null, this.locked = !1, this.dragging = !1, this.lastDeltaPx = 0, this.startTimer = null, this.destroyed = !1, this.orientation = t.orientation, this.thresholdPx = t.swipeThresholdPx ?? r.DEFAULT_THRESHOLD_PX, this.startDelayMs = t.startDelayMs ?? r.DEFAULT_START_DELAY_MS;
|
|
4
|
+
}
|
|
5
|
+
static {
|
|
6
|
+
this.DEFAULT_THRESHOLD_PX = 3;
|
|
7
|
+
}
|
|
8
|
+
static {
|
|
9
|
+
this.DEFAULT_START_DELAY_MS = 20;
|
|
10
|
+
}
|
|
11
|
+
setOrientation(t) {
|
|
12
|
+
this.orientation = t;
|
|
13
|
+
}
|
|
14
|
+
/** `touch-action` the consumer should set on the gesture surface. */
|
|
15
|
+
get touchAction() {
|
|
16
|
+
return this.orientation === "horizontal" ? "pan-y" : "pan-x";
|
|
17
|
+
}
|
|
18
|
+
pointerDown(t, s) {
|
|
19
|
+
this.destroyed || (this.reset(), this.origin = { x: t, y: s }, this.startTimer = setTimeout(() => {
|
|
20
|
+
this.startTimer = null, !(this.destroyed || !this.origin) && (this.dragging = !0, this.callbacks.onDragStart?.(), this.callbacks.onDragMove?.(this.lastDeltaPx));
|
|
21
|
+
}, this.startDelayMs));
|
|
22
|
+
}
|
|
23
|
+
/** Returns true when the caller should preventDefault() on this move event. */
|
|
24
|
+
pointerMove(t, s) {
|
|
25
|
+
if (!this.origin) return !1;
|
|
26
|
+
const i = Math.abs(t - this.origin.x), e = Math.abs(s - this.origin.y), n = this.orientation === "horizontal" ? i : e, a = this.orientation === "horizontal" ? e : i;
|
|
27
|
+
return !this.locked && n > this.thresholdPx && n >= a && (this.locked = !0), this.lastDeltaPx = this.orientation === "horizontal" ? t - this.origin.x : s - this.origin.y, this.dragging && this.callbacks.onDragMove?.(this.lastDeltaPx), this.locked;
|
|
28
|
+
}
|
|
29
|
+
/** Returns true when the caller should preventDefault() on the end event. */
|
|
30
|
+
pointerUp() {
|
|
31
|
+
const t = this.locked;
|
|
32
|
+
if (this.startTimer !== null)
|
|
33
|
+
return this.reset(), this.callbacks.onTap?.(), !1;
|
|
34
|
+
if (this.dragging) {
|
|
35
|
+
const s = this.lastDeltaPx;
|
|
36
|
+
this.reset(), this.callbacks.onDragEnd?.(s);
|
|
37
|
+
} else
|
|
38
|
+
this.reset();
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
/** Abandon the gesture without emitting anything (e.g. pointercancel). */
|
|
42
|
+
abort() {
|
|
43
|
+
this.reset();
|
|
44
|
+
}
|
|
45
|
+
destroy() {
|
|
46
|
+
this.destroyed = !0, this.reset();
|
|
47
|
+
}
|
|
48
|
+
reset() {
|
|
49
|
+
this.startTimer !== null && (clearTimeout(this.startTimer), this.startTimer = null), this.origin = null, this.locked = !1, this.dragging = !1, this.lastDeltaPx = 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
class l {
|
|
53
|
+
constructor(t, s = {}, i) {
|
|
54
|
+
this.host = t, this.callbacks = s, this.index = 0, this.pending = null, this.animating = !1, this.dragRatio = 0, this.dragging = !1, this.count = i.count, this.wrap = i.wrap ?? !0, this.durationMs = i.durationMs ?? 500, this.minimumOffsetPx = i.minimumOffsetPx ?? 50, this.prefersReducedMotion = i.prefersReducedMotion;
|
|
55
|
+
}
|
|
56
|
+
// ---- config / state -------------------------------------------------------
|
|
57
|
+
setConfig(t) {
|
|
58
|
+
t.count !== void 0 && (this.count = t.count, this.index >= this.count && (this.commit(Math.max(0, this.count - 1)), this.host.applyOffsetRatio(this.index))), t.wrap !== void 0 && (this.wrap = t.wrap), t.durationMs !== void 0 && (this.durationMs = t.durationMs), t.minimumOffsetPx !== void 0 && (this.minimumOffsetPx = t.minimumOffsetPx), t.prefersReducedMotion !== void 0 && (this.prefersReducedMotion = t.prefersReducedMotion);
|
|
59
|
+
}
|
|
60
|
+
getIndex() {
|
|
61
|
+
return this.index;
|
|
62
|
+
}
|
|
63
|
+
get isAnimating() {
|
|
64
|
+
return this.animating;
|
|
65
|
+
}
|
|
66
|
+
// ---- navigation -----------------------------------------------------------
|
|
67
|
+
next() {
|
|
68
|
+
this.relative(1);
|
|
69
|
+
}
|
|
70
|
+
previous() {
|
|
71
|
+
this.relative(-1);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Navigate to an absolute index. Out-of-range targets are a no-op (never
|
|
75
|
+
* wrapped — wrapping is a property of *relative* movement). `animate: false`
|
|
76
|
+
* jumps instantly with no events beyond `onIndexChange`.
|
|
77
|
+
*/
|
|
78
|
+
goto(t, s = {}) {
|
|
79
|
+
if (!(t < 0 || t >= this.count)) {
|
|
80
|
+
if (this.interrupt(), s.animate === !1) {
|
|
81
|
+
this.endDragState(), this.commit(t), this.host.applyOffsetRatio(this.index);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
t === this.index && !this.dragging || this.transitionTo(t, t);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
intent(t) {
|
|
88
|
+
switch (t) {
|
|
89
|
+
case "previous":
|
|
90
|
+
return this.previous();
|
|
91
|
+
case "next":
|
|
92
|
+
return this.next();
|
|
93
|
+
case "first":
|
|
94
|
+
return this.goto(0);
|
|
95
|
+
case "last":
|
|
96
|
+
return this.goto(Math.max(0, this.count - 1));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
relative(t) {
|
|
100
|
+
this.interrupt();
|
|
101
|
+
const s = this.index + t, i = this.resolve(s);
|
|
102
|
+
i !== null && (!this.wrap && i === this.index && !this.dragging || this.transitionTo(s, i));
|
|
103
|
+
}
|
|
104
|
+
// ---- drag -----------------------------------------------------------------
|
|
105
|
+
/** A drag began: interrupt any in-flight transition so the finger owns the track. */
|
|
106
|
+
beginDrag() {
|
|
107
|
+
this.interrupt(), this.dragging = !0, this.dragRatio = 0;
|
|
108
|
+
}
|
|
109
|
+
/** Live drag update. Content follows the pointer: positive delta drags backwards. */
|
|
110
|
+
dragBy(t, s) {
|
|
111
|
+
if (!this.dragging || s <= 0) return;
|
|
112
|
+
let i = t / s;
|
|
113
|
+
if (!this.wrap) {
|
|
114
|
+
const e = this.index - i;
|
|
115
|
+
e < 0 && (i = this.index), e > this.count - 1 && (i = this.index - (this.count - 1));
|
|
116
|
+
}
|
|
117
|
+
this.dragRatio = i, this.host.applyOffsetRatio(this.index - i);
|
|
118
|
+
}
|
|
119
|
+
/** Drag release: commit when past the threshold, snap back otherwise. */
|
|
120
|
+
endDrag(t, s) {
|
|
121
|
+
if (!this.dragging) return;
|
|
122
|
+
const e = Math.abs(t) >= this.minimumOffsetPx ? this.index + (t < 0 ? 1 : -1) : this.index, n = this.resolve(e);
|
|
123
|
+
if (n === null || !this.wrap && n === this.index && e !== this.index) {
|
|
124
|
+
this.transitionTo(this.index, this.index);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.transitionTo(e, n);
|
|
128
|
+
}
|
|
129
|
+
// ---- internals ------------------------------------------------------------
|
|
130
|
+
/** Wrap (or clamp) a raw target into the committed range; null when empty. */
|
|
131
|
+
resolve(t) {
|
|
132
|
+
return this.count <= 0 ? null : t >= 0 && t < this.count ? t : this.wrap ? (t % this.count + this.count) % this.count : Math.min(Math.max(t, 0), this.count - 1);
|
|
133
|
+
}
|
|
134
|
+
/** Finish (commit) an in-flight transition so a new owner can take the track. */
|
|
135
|
+
interrupt() {
|
|
136
|
+
this.pending?.finish();
|
|
137
|
+
}
|
|
138
|
+
endDragState() {
|
|
139
|
+
this.dragging = !1, this.dragRatio = 0;
|
|
140
|
+
}
|
|
141
|
+
transitionTo(t, s) {
|
|
142
|
+
this.interrupt();
|
|
143
|
+
const i = this.index - this.dragRatio;
|
|
144
|
+
this.endDragState();
|
|
145
|
+
const e = this.prefersReducedMotion?.() ? 0 : this.durationMs;
|
|
146
|
+
this.callbacks.onAnimationStart?.();
|
|
147
|
+
const n = () => {
|
|
148
|
+
this.animating = !1, this.pending = null, this.commit(s), this.host.applyOffsetRatio(this.index), this.callbacks.onAnimationEnd?.();
|
|
149
|
+
};
|
|
150
|
+
if (e <= 0 || i === t) {
|
|
151
|
+
n();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.animating = !0, this.pending = this.host.runTransition(i, t, e, n);
|
|
155
|
+
}
|
|
156
|
+
commit(t) {
|
|
157
|
+
t !== this.index && (this.index = t, this.callbacks.onIndexChange?.(t));
|
|
158
|
+
}
|
|
159
|
+
destroy() {
|
|
160
|
+
this.pending?.cancel(), this.pending = null, this.animating = !1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const o = {
|
|
164
|
+
horizontal: {
|
|
165
|
+
ArrowLeft: "previous",
|
|
166
|
+
ArrowRight: "next",
|
|
167
|
+
Home: "first",
|
|
168
|
+
End: "last"
|
|
169
|
+
},
|
|
170
|
+
vertical: {
|
|
171
|
+
ArrowUp: "previous",
|
|
172
|
+
ArrowDown: "next",
|
|
173
|
+
Home: "first",
|
|
174
|
+
End: "last"
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
function d(h, t) {
|
|
178
|
+
return o[t][h] ?? null;
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
l as IndexMachine,
|
|
182
|
+
r as PointerArbiter,
|
|
183
|
+
d as keyToIntent
|
|
184
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IndexMachineCallbacks, IndexMachineConfig, IndexMachineHost, SwipeIntent } from './models';
|
|
2
|
+
/**
|
|
3
|
+
* Slide-index state machine over a plain `count`, with transitions.
|
|
4
|
+
*
|
|
5
|
+
* Positions leave the machine only as a unit-free `offsetRatio` in slide units
|
|
6
|
+
* (see {@link IndexMachineHost}), so the host is free to realise motion as a
|
|
7
|
+
* transform, a scroll offset, or a timed crossfade. Wrap-around/clamping lives
|
|
8
|
+
* HERE, so buttons, keyboard, and drag release all obey one rule. During a
|
|
9
|
+
* wrapping relative move the visual target transiently leaves [0, count-1]
|
|
10
|
+
* (-1 or `count` — the host's wrap cells); the committed index is always
|
|
11
|
+
* wrapped back into range.
|
|
12
|
+
*
|
|
13
|
+
* Interruption: starting any navigation (or a new drag) finishes an in-flight
|
|
14
|
+
* transition first — `finish()` jumps it to its end state and commits.
|
|
15
|
+
*/
|
|
16
|
+
export declare class IndexMachine {
|
|
17
|
+
private readonly host;
|
|
18
|
+
private readonly callbacks;
|
|
19
|
+
private index;
|
|
20
|
+
private count;
|
|
21
|
+
private wrap;
|
|
22
|
+
private durationMs;
|
|
23
|
+
private minimumOffsetPx;
|
|
24
|
+
private prefersReducedMotion?;
|
|
25
|
+
private pending;
|
|
26
|
+
private animating;
|
|
27
|
+
private dragRatio;
|
|
28
|
+
private dragging;
|
|
29
|
+
constructor(host: IndexMachineHost, callbacks: IndexMachineCallbacks | undefined, config: IndexMachineConfig);
|
|
30
|
+
setConfig(config: Partial<IndexMachineConfig>): void;
|
|
31
|
+
getIndex(): number;
|
|
32
|
+
get isAnimating(): boolean;
|
|
33
|
+
next(): void;
|
|
34
|
+
previous(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Navigate to an absolute index. Out-of-range targets are a no-op (never
|
|
37
|
+
* wrapped — wrapping is a property of *relative* movement). `animate: false`
|
|
38
|
+
* jumps instantly with no events beyond `onIndexChange`.
|
|
39
|
+
*/
|
|
40
|
+
goto(target: number, opts?: {
|
|
41
|
+
animate?: boolean;
|
|
42
|
+
}): void;
|
|
43
|
+
intent(intent: SwipeIntent): void;
|
|
44
|
+
private relative;
|
|
45
|
+
/** A drag began: interrupt any in-flight transition so the finger owns the track. */
|
|
46
|
+
beginDrag(): void;
|
|
47
|
+
/** Live drag update. Content follows the pointer: positive delta drags backwards. */
|
|
48
|
+
dragBy(deltaPx: number, extentPx: number): void;
|
|
49
|
+
/** Drag release: commit when past the threshold, snap back otherwise. */
|
|
50
|
+
endDrag(deltaPx: number, extentPx: number): void;
|
|
51
|
+
/** Wrap (or clamp) a raw target into the committed range; null when empty. */
|
|
52
|
+
private resolve;
|
|
53
|
+
/** Finish (commit) an in-flight transition so a new owner can take the track. */
|
|
54
|
+
interrupt(): void;
|
|
55
|
+
private endDragState;
|
|
56
|
+
private transitionTo;
|
|
57
|
+
private commit;
|
|
58
|
+
destroy(): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types';
|