@jfrader/ui 0.5.0 → 0.5.1
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/dist/accordion-DLul6vIl.js +205 -0
- package/dist/accordion.js +1 -1
- package/dist/{announcement-bar-B58xempt.js → announcement-bar-Dlbq5-9D.js} +1 -1
- package/dist/announcement-bar.js +1 -1
- package/dist/avatar-CaGJHy1N.js +145 -0
- package/dist/{avatar-group-DOQQuV51.js → avatar-group-M1opAQEG.js} +1 -1
- package/dist/avatar-group.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge-CjM5Agqk.js +119 -0
- package/dist/badge.js +1 -1
- package/dist/{bottom-sheet-DPJBFkie.js → bottom-sheet-DjZOPq4k.js} +10 -9
- package/dist/bottom-sheet.js +1 -1
- package/dist/{breadcrumbs-Cfw_hgt2.js → breadcrumbs-BDK_LiwH.js} +10 -3
- package/dist/breadcrumbs.js +1 -1
- package/dist/{button-C92uYFJW.js → button-NLY0h6EJ.js} +7 -7
- package/dist/button.js +1 -1
- package/dist/{calendar-B3Svu0X2.js → calendar-BzJdv_SZ.js} +3 -1
- package/dist/calendar.js +1 -1
- package/dist/card-Ca4KQKYQ.js +154 -0
- package/dist/card.js +1 -1
- package/dist/carousel-B7OrvD6J.js +474 -0
- package/dist/carousel.js +1 -1
- package/dist/{checkbox-cFquiSdy.js → checkbox-DKSzExj2.js} +16 -15
- package/dist/checkbox.js +1 -1
- package/dist/{chip-group-DTQd_M-G.js → chip-group-DjQ0_6Y9.js} +2 -1
- package/dist/chip-group.js +1 -1
- package/dist/{code-block-ahnRi-g8.js → code-block-B5we2lZa.js} +75 -74
- package/dist/code-block.js +1 -1
- package/dist/{combobox-Bhzvu9ma.js → combobox-DFFqOBCi.js} +114 -109
- package/dist/combobox.js +1 -1
- package/dist/command-palette-BmQu2w4H.js +391 -0
- package/dist/command-palette.js +1 -1
- package/dist/comment-thread-ASaXDcGo.js +1410 -0
- package/dist/comment-thread.js +2 -0
- package/dist/context-menu-__1c2Dk9.js +370 -0
- package/dist/context-menu.js +2 -0
- package/dist/{copy-button-ByiA6D3R.js → copy-button-DCSLcYS-.js} +1 -1
- package/dist/copy-button.js +1 -1
- package/dist/{date-picker-5zKSSuFF.js → date-picker-BiPN7yeK.js} +4 -4
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker-DQpUeKqV.js +570 -0
- package/dist/date-range-picker.js +1 -1
- package/dist/{dialog-ciiv9H2b.js → dialog-BX1zYMs-.js} +2 -1
- package/dist/dialog.js +1 -1
- package/dist/{divider-DYoJf0I_.js → divider-Cp7aNbhM.js} +21 -20
- package/dist/divider.js +1 -1
- package/dist/elastic-slider-BG6K019r.js +395 -0
- package/dist/elastic-slider.js +2 -0
- package/dist/{expandable-card-C-qJcZ14.js → expandable-card-rUATve0o.js} +8 -1
- package/dist/expandable-card.js +1 -1
- package/dist/expanding-search-BxOwtdwt.js +238 -0
- package/dist/expanding-search.js +2 -0
- package/dist/file-dropzone-BuXm3Tea.js +457 -0
- package/dist/file-dropzone.js +1 -1
- package/dist/{filter-toolbar-D5KEKTSe.js → filter-toolbar-Cy5Hqur-.js} +4 -2
- package/dist/filter-toolbar.js +1 -1
- package/dist/{hover-card-B-nrCIy2.js → hover-card-CoMJKg1g.js} +7 -7
- package/dist/hover-card.js +1 -1
- package/dist/{image-compare-ciuhPtQZ.js → image-compare-BxY8Ykzt.js} +1 -1
- package/dist/image-compare.js +1 -1
- package/dist/index.js +81 -76
- package/dist/{json-viewer-BcySQfjZ.js → json-viewer-DgWqyU75.js} +7 -3
- package/dist/json-viewer.js +1 -1
- package/dist/mention-input-sq61si9L.js +600 -0
- package/dist/mention-input.js +1 -1
- package/dist/menu-DDKgmK2F.js +295 -0
- package/dist/menu.js +1 -1
- package/dist/{metric-card-Bh9K4fZs.js → metric-card--lVTz5Wn.js} +2 -2
- package/dist/metric-card.js +1 -1
- package/dist/{multi-select-Pce_IYnz.js → multi-select-DG1BCFX7.js} +14 -6
- package/dist/multi-select.js +1 -1
- package/dist/{navigation-sP5fiuQS.js → navigation-CC26JDr-.js} +20 -14
- package/dist/navigation.js +1 -1
- package/dist/{overlay-layer-SeUyyEPD.js → overlay-layer-qEbpEtb8.js} +16 -2
- package/dist/{pagination-DmXZ8E85.js → pagination-BfkeWbmP.js} +23 -22
- package/dist/pagination.js +1 -1
- package/dist/pill-BaS-uIbn.js +58 -0
- package/dist/pill.js +1 -1
- package/dist/popover-CErIw2q3.js +125 -0
- package/dist/popover.js +1 -1
- package/dist/{progress-CbOWBUdA.js → progress-DAQkfhPd.js} +1 -1
- package/dist/progress.js +1 -1
- package/dist/{radio-cards-D2QZENI_.js → radio-cards-Cu9cBssN.js} +35 -34
- package/dist/radio-cards.js +1 -1
- package/dist/{radio-group-E6mMRgo7.js → radio-group-TIK0-iPX.js} +18 -15
- package/dist/radio-group.js +1 -1
- package/dist/{resizable-panels-BhjUVXZZ.js → resizable-panels-DUpQEpwG.js} +3 -2
- package/dist/resizable-panels.js +1 -1
- package/dist/{search-field-IxF0IJXm.js → search-field-DMvho0KQ.js} +2 -2
- package/dist/search-field.js +1 -1
- package/dist/{segmented-control-yO1K1nbi.js → segmented-control-8ZUGnsZm.js} +2 -1
- package/dist/segmented-control.js +1 -1
- package/dist/{select-n_H52W1Z.js → select-D5rhJ8gi.js} +3 -2
- package/dist/select.js +1 -1
- package/dist/{signature-pad-q2SAsrdD.js → signature-pad-_bTeguN9.js} +256 -251
- package/dist/signature-pad.js +1 -1
- package/dist/slider-DVG6-Awh.js +308 -0
- package/dist/slider.js +1 -1
- package/dist/{sortable-data-table-tirqlLY2.js → sortable-data-table-CYKT_Ng7.js} +2 -2
- package/dist/sortable-data-table.js +1 -1
- package/dist/{split-button-Cb3EHs64.js → split-button-BCw4zZom.js} +75 -81
- package/dist/split-button.js +1 -1
- package/dist/{swipe-actions-DiZC57-3.js → swipe-actions-CBuJREU1.js} +4 -2
- package/dist/swipe-actions.js +1 -1
- package/dist/switch-C1WrKrf-.js +145 -0
- package/dist/switch.js +1 -1
- package/dist/tabs-XluwRjgg.js +210 -0
- package/dist/tabs.js +1 -1
- package/dist/{text-field-C8TWG-tY.js → text-field-hU72iSVS.js} +15 -13
- package/dist/text-field.js +1 -1
- package/dist/{textarea-BrW0XcG_.js → textarea-3k4Y0QQ3.js} +18 -16
- package/dist/textarea.js +1 -1
- package/dist/theme-root.js +1 -1
- package/dist/theme-switch-C505TtU8.js +166 -0
- package/dist/theme-switch.js +2 -0
- package/dist/{time-picker-Db8D49cP.js → time-picker-CPlhW0tr.js} +26 -20
- package/dist/time-picker.js +1 -1
- package/dist/{timeline-k3nURuCP.js → timeline-B0uAAVfT.js} +8 -2
- package/dist/timeline.js +1 -1
- package/dist/{toast-BHxI32ZA.js → toast-B7wo3sX1.js} +98 -79
- package/dist/{toast-stack-DqrAzdg5.js → toast-stack-B40VpS4M.js} +18 -4
- package/dist/toast-stack.js +1 -1
- package/dist/toast.js +1 -1
- package/dist/{toggle-group-fcjzpifI.js → toggle-group-B2fpFZwV.js} +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip-BvgVTCTN.js +120 -0
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-C2liIxqy.js → tree-view-j8qLqkb_.js} +5 -1
- package/dist/tree-view.js +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +1 -1
- package/dist/types/components/command-palette/command-palette.d.ts +1 -1
- package/dist/types/components/comment-thread/comment-thread.d.ts +118 -0
- package/dist/types/components/comment-thread/index.d.ts +1 -0
- package/dist/types/components/comment-thread/thread-core.d.ts +96 -0
- package/dist/types/components/comment-thread/thread-parts.d.ts +114 -0
- package/dist/types/components/context-menu/context-menu.d.ts +55 -0
- package/dist/types/components/context-menu/index.d.ts +2 -0
- package/dist/types/components/date-range-picker/date-range-picker.d.ts +1 -1
- package/dist/types/components/elastic-slider/elastic-slider.d.ts +53 -0
- package/dist/types/components/elastic-slider/index.d.ts +1 -0
- package/dist/types/components/expanding-search/expanding-search.d.ts +22 -0
- package/dist/types/components/expanding-search/index.d.ts +1 -0
- package/dist/types/components/menu/menu.d.ts +50 -7
- package/dist/types/components/pagination/pagination.d.ts +1 -1
- package/dist/types/components/radio-cards/radio-cards.d.ts +1 -1
- package/dist/types/components/radio-group/radio-group.d.ts +1 -1
- package/dist/types/components/slider/slider-style.d.ts +14 -0
- package/dist/types/components/slider/slider.d.ts +2 -10
- package/dist/types/components/slider/use-slider-interaction.d.ts +79 -0
- package/dist/types/components/split-button/split-button.d.ts +2 -2
- package/dist/types/components/tabs/tabs.d.ts +1 -1
- package/dist/types/components/text-field/text-field.d.ts +1 -1
- package/dist/types/components/textarea/textarea.d.ts +1 -1
- package/dist/types/components/theme-switch/index.d.ts +1 -0
- package/dist/types/components/theme-switch/theme-switch.d.ts +33 -0
- package/dist/types/components/tooltip/tooltip.d.ts +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/overlay/overlay-layer.d.ts +20 -0
- package/dist/types/overlay/use-overlay-floating.d.ts +9 -2
- package/dist/{use-overlay-floating-DvJifLpF.js → use-overlay-floating-Bx2jBKAA.js} +8 -6
- package/dist/use-slider-interaction-ChL-208h.js +234 -0
- package/package.json +22 -2
- package/dist/accordion-xCI_u0BV.js +0 -198
- package/dist/avatar-BahDVO9t.js +0 -132
- package/dist/badge-B_sLygxU.js +0 -108
- package/dist/card-D-aI2QHx.js +0 -158
- package/dist/carousel-IvPqN-oM.js +0 -472
- package/dist/command-palette-BQ5LleGb.js +0 -384
- package/dist/date-range-picker-B5uFWsm-.js +0 -562
- package/dist/file-dropzone-pR4v7owg.js +0 -457
- package/dist/mention-input-BcQKX2EJ.js +0 -599
- package/dist/menu-xwOOUtWP.js +0 -275
- package/dist/pill-DO2gHzMb.js +0 -56
- package/dist/popover-QHcEvf9c.js +0 -119
- package/dist/slider-t0B5cecO.js +0 -477
- package/dist/switch-qwv8jQnR.js +0 -142
- package/dist/tabs-CAVJndX1.js +0 -203
- package/dist/tooltip-CkeiW9C1.js +0 -113
- package/dist/{theme-root-BbTBuLMQ.js → theme-root-Bs1U3uPA.js} +2 -2
|
@@ -5,113 +5,117 @@ import { n as r, r as i } from "./media-8yrN85VT.js";
|
|
|
5
5
|
import { t as a } from "./use-controlled-state-DpeVQZNR.js";
|
|
6
6
|
import { t as o } from "./visually-hidden-BJdvqqvn.js";
|
|
7
7
|
import { t as s } from "./renderable-DzcIj1Lo.js";
|
|
8
|
-
import { t as c } from "./button-
|
|
9
|
-
import { t as l } from "./radio-group-
|
|
8
|
+
import { t as c } from "./button-NLY0h6EJ.js";
|
|
9
|
+
import { t as l } from "./radio-group-TIK0-iPX.js";
|
|
10
10
|
import { useEffect as u, useId as ee, useImperativeHandle as te, useLayoutEffect as d, useRef as f, useState as ne } from "react";
|
|
11
11
|
import { vars as p } from "@jfrader/tokens/vars";
|
|
12
12
|
import { jsx as m, jsxs as h } from "@emotion/react/jsx-runtime";
|
|
13
13
|
import { useMergeRefs as re } from "@floating-ui/react";
|
|
14
14
|
import { base as g } from "@jfrader/tokens";
|
|
15
15
|
//#region src/components/signature-pad/signature-pad.tsx
|
|
16
|
-
var _ = 600, v = 260, ie = 4096,
|
|
16
|
+
var _ = 600, v = 260, ie = 4096, y = 1e5, ae = 1e3, oe = 2, se = 3, ce = 60, le = 8e3, ue = 500, de = [], b = (e) => s(e) && e !== "", x = {
|
|
17
17
|
fine: 2,
|
|
18
18
|
medium: 4,
|
|
19
19
|
bold: 7
|
|
20
|
-
},
|
|
20
|
+
}, S = {
|
|
21
21
|
black: g.color.signatureInkBlack,
|
|
22
22
|
blue: g.color.signatureInkBlue,
|
|
23
23
|
violet: g.color.signatureInkViolet
|
|
24
|
-
},
|
|
24
|
+
}, fe = {
|
|
25
25
|
black: "--ui-color-text",
|
|
26
26
|
blue: "--ui-color-info",
|
|
27
27
|
violet: "--ui-color-accent"
|
|
28
|
-
},
|
|
28
|
+
}, C = class extends Error {
|
|
29
29
|
code;
|
|
30
30
|
constructor(e, t) {
|
|
31
31
|
super(t), this.code = e, this.name = "SignatureExportError";
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
function
|
|
33
|
+
}, w = 0;
|
|
34
|
+
function pe() {
|
|
35
35
|
let e = /* @__PURE__ */ new Uint32Array(2);
|
|
36
|
-
return globalThis.crypto?.getRandomValues?.(e), [++
|
|
36
|
+
return globalThis.crypto?.getRandomValues?.(e), [++w, ...e].map((e) => e.toString(36)).join("-");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function me(e) {
|
|
39
39
|
let t = 0;
|
|
40
|
-
if (!Array.isArray(e) || e.length >
|
|
40
|
+
if (!Array.isArray(e) || e.length > ae) return !1;
|
|
41
41
|
for (let n of e) {
|
|
42
|
-
if (!n || typeof n.id != "string" || !Object.hasOwn(
|
|
42
|
+
if (!n || typeof n.id != "string" || !Object.hasOwn(x, n.width) || !Object.hasOwn(S, n.color) || !Number.isFinite(n.startTime) || n.startTime < 0 || !Array.isArray(n.points) || !n.points.length) return !1;
|
|
43
43
|
let e = 0;
|
|
44
44
|
for (let r of n.points) {
|
|
45
|
-
if (++t >
|
|
45
|
+
if (++t > y || !r || !Number.isFinite(r.x) || !Number.isFinite(r.y) || r.x < 0 || r.x > _ || r.y < 0 || r.y > v || !Number.isFinite(r.time) || r.time < e || r.pressure !== null && (!Number.isFinite(r.pressure) || r.pressure < 0 || r.pressure > 1)) return !1;
|
|
46
46
|
e = r.time;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return !0;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
if (!
|
|
51
|
+
function T(e) {
|
|
52
|
+
if (!me(e)) throw new C("invalid", "Invalid signature strokes.");
|
|
53
53
|
}
|
|
54
|
-
var
|
|
55
|
-
function
|
|
56
|
-
if (
|
|
57
|
-
let t = [];
|
|
58
|
-
for (let
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
var E = (e, t, n) => Math.min(n, Math.max(t, e));
|
|
55
|
+
function D(e) {
|
|
56
|
+
if (me(e)) return e;
|
|
57
|
+
let t = [], n = 0;
|
|
58
|
+
for (let r of Array.isArray(e) ? e.slice(0, ae) : []) {
|
|
59
|
+
if (n >= y) break;
|
|
60
|
+
if (!r || !Object.hasOwn(x, r.width) || !Object.hasOwn(S, r.color) || !Array.isArray(r.points)) continue;
|
|
61
|
+
let e = 0, i = [];
|
|
62
|
+
for (let t of r.points) {
|
|
63
|
+
if (n >= y) break;
|
|
64
|
+
n++, t && Number.isFinite(t.x) && Number.isFinite(t.y) && (Number.isFinite(t.time) && (e = Math.max(e, t.time)), i.push({
|
|
65
|
+
x: E(t.x, 0, _),
|
|
66
|
+
y: E(t.y, 0, v),
|
|
67
|
+
pressure: Number.isFinite(t.pressure) ? E(t.pressure, 0, 1) : null,
|
|
68
|
+
time: e
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
i.length && t.push({
|
|
72
|
+
...r,
|
|
73
|
+
startTime: Number.isFinite(r.startTime) ? Math.max(0, r.startTime) : 0,
|
|
74
|
+
points: i
|
|
71
75
|
});
|
|
72
76
|
}
|
|
73
77
|
return t;
|
|
74
78
|
}
|
|
75
|
-
var
|
|
79
|
+
var he = (e) => e.reduce((e, t) => e + t.points.length, 0), O = (e, t) => ({
|
|
76
80
|
x: (e.x + t.x) / 2,
|
|
77
81
|
y: (e.y + t.y) / 2,
|
|
78
82
|
time: (e.time + t.time) / 2,
|
|
79
83
|
pressure: e.pressure === null || t.pressure === null ? null : (e.pressure + t.pressure) / 2
|
|
80
|
-
}),
|
|
81
|
-
function
|
|
84
|
+
}), k = (e, t) => x[t] * (e.pressure === null ? 1 : .25 + e.pressure * .75);
|
|
85
|
+
function A(e) {
|
|
82
86
|
let t = [];
|
|
83
87
|
for (let n = 1; n < e.points.length; n++) {
|
|
84
|
-
let r = e.points[n - 1], i = e.points[n], a = n === 1 ? r :
|
|
88
|
+
let r = e.points[n - 1], i = e.points[n], a = n === 1 ? r : O(e.points[n - 2], r), o = n === e.points.length - 1 ? i : O(r, i);
|
|
85
89
|
t.push({
|
|
86
90
|
from: a,
|
|
87
91
|
control: r,
|
|
88
92
|
to: o,
|
|
89
|
-
width: (
|
|
93
|
+
width: (k(r, e.width) + k(i, e.width)) / 2
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
return t;
|
|
93
97
|
}
|
|
94
|
-
function
|
|
98
|
+
function ge(e, t, n) {
|
|
95
99
|
for (let r of t) {
|
|
96
100
|
if (e.strokeStyle = e.fillStyle = n[r.color], e.lineCap = e.lineJoin = "round", r.points.length === 1) {
|
|
97
101
|
let t = r.points[0];
|
|
98
|
-
e.beginPath(), e.arc(t.x, t.y,
|
|
102
|
+
e.beginPath(), e.arc(t.x, t.y, k(t, r.width) / 2, 0, Math.PI * 2), e.fill();
|
|
99
103
|
}
|
|
100
|
-
for (let t of
|
|
104
|
+
for (let t of A(r)) e.lineWidth = t.width, e.beginPath(), e.moveTo(t.from.x, t.from.y), e.quadraticCurveTo(t.control.x, t.control.y, t.to.x, t.to.y), e.stroke();
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
|
-
function
|
|
104
|
-
if (
|
|
107
|
+
function j(e, t) {
|
|
108
|
+
if (T(e), !e.length) throw new C("empty", "Cannot export an empty signature.");
|
|
105
109
|
let n = 0, r = 0, i = _, a = v;
|
|
106
110
|
if (t.crop !== !1) {
|
|
107
111
|
n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
|
|
108
112
|
for (let t of e) for (let e of t.points) {
|
|
109
|
-
let o =
|
|
113
|
+
let o = x[t.width] / 2 + oe;
|
|
110
114
|
n = Math.min(n, e.x - o), r = Math.min(r, e.y - o), i = Math.max(i, e.x + o), a = Math.max(a, e.y + o);
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
|
-
let o = t.scale ??
|
|
114
|
-
if (!Number.isFinite(o) || o <= 0 || Math.ceil(s * o) > ie || Math.ceil(c * o) > ie) throw new
|
|
117
|
+
let o = t.scale ?? se, s = i - n, c = a - r;
|
|
118
|
+
if (!Number.isFinite(o) || o <= 0 || Math.ceil(s * o) > ie || Math.ceil(c * o) > ie) throw new C("size", "Signature export exceeds the dimension budget.");
|
|
115
119
|
return {
|
|
116
120
|
left: n,
|
|
117
121
|
top: r,
|
|
@@ -120,46 +124,46 @@ function A(e, t) {
|
|
|
120
124
|
scale: o
|
|
121
125
|
};
|
|
122
126
|
}
|
|
123
|
-
function
|
|
124
|
-
let n =
|
|
125
|
-
if (typeof document > "u") throw new
|
|
127
|
+
function _e(e, t = {}) {
|
|
128
|
+
let n = j(e, t);
|
|
129
|
+
if (typeof document > "u") throw new C("encoder", "Canvas rendering is unavailable.");
|
|
126
130
|
let r = document.createElement("canvas");
|
|
127
131
|
r.width = Math.ceil(n.width * n.scale), r.height = Math.ceil(n.height * n.scale);
|
|
128
132
|
let i = r.getContext("2d");
|
|
129
|
-
if (!i) throw new
|
|
130
|
-
return i.scale(n.scale, n.scale), i.translate(-n.left, -n.top),
|
|
133
|
+
if (!i) throw new C("encoder", "Canvas rendering is unavailable.");
|
|
134
|
+
return i.scale(n.scale, n.scale), i.translate(-n.left, -n.top), ge(i, e, S), r;
|
|
131
135
|
}
|
|
132
|
-
function
|
|
136
|
+
function ve(e, t = {}) {
|
|
133
137
|
return new Promise((n, r) => {
|
|
134
138
|
try {
|
|
135
|
-
|
|
139
|
+
_e(e, t).toBlob((e) => e ? n(e) : r(new C("encoder", "PNG encoding failed.")), "image/png");
|
|
136
140
|
} catch (e) {
|
|
137
141
|
r(e);
|
|
138
142
|
}
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
|
-
function
|
|
142
|
-
let n =
|
|
143
|
-
let t =
|
|
145
|
+
function ye(e, t = {}) {
|
|
146
|
+
let n = j(e, t), r = e.map((e) => {
|
|
147
|
+
let t = S[e.color];
|
|
144
148
|
if (e.points.length === 1) {
|
|
145
149
|
let n = e.points[0];
|
|
146
|
-
return `<circle cx="${n.x}" cy="${n.y}" r="${
|
|
150
|
+
return `<circle cx="${n.x}" cy="${n.y}" r="${k(n, e.width) / 2}" fill="${t}"/>`;
|
|
147
151
|
}
|
|
148
|
-
return
|
|
152
|
+
return A(e).map((e) => `<path d="M ${e.from.x} ${e.from.y} Q ${e.control.x} ${e.control.y} ${e.to.x} ${e.to.y}" fill="none" stroke="${t}" stroke-width="${e.width}" stroke-linecap="round" stroke-linejoin="round"/>`).join("");
|
|
149
153
|
}).join("");
|
|
150
154
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${n.left} ${n.top} ${n.width} ${n.height}" width="${Math.ceil(n.width * n.scale)}" height="${Math.ceil(n.height * n.scale)}">${r}</svg>`;
|
|
151
155
|
}
|
|
152
|
-
var
|
|
156
|
+
var be = e({
|
|
153
157
|
display: "grid",
|
|
154
158
|
gap: p.space[3],
|
|
155
159
|
minInlineSize: 0,
|
|
156
160
|
color: p.color.text,
|
|
157
161
|
fontFamily: p.font.sans,
|
|
158
162
|
fontSize: p.textSize.sm
|
|
159
|
-
}),
|
|
163
|
+
}), xe = e({
|
|
160
164
|
position: "relative",
|
|
161
165
|
minInlineSize: 0
|
|
162
|
-
}),
|
|
166
|
+
}), Se = e({
|
|
163
167
|
display: "block",
|
|
164
168
|
boxSizing: "border-box",
|
|
165
169
|
inlineSize: "100%",
|
|
@@ -175,7 +179,7 @@ var xe = e({
|
|
|
175
179
|
borderColor: "CanvasText",
|
|
176
180
|
color: "CanvasText"
|
|
177
181
|
}
|
|
178
|
-
}),
|
|
182
|
+
}), Ce = e({
|
|
179
183
|
position: "absolute",
|
|
180
184
|
insetInline: p.space[4],
|
|
181
185
|
insetBlockEnd: p.space[8],
|
|
@@ -189,30 +193,30 @@ var xe = e({
|
|
|
189
193
|
transitionProperty: "opacity",
|
|
190
194
|
transitionDuration: p.motion.duration.base,
|
|
191
195
|
[i]: { transitionDuration: "0s" }
|
|
192
|
-
}),
|
|
196
|
+
}), we = e({
|
|
193
197
|
display: "flex",
|
|
194
198
|
flexWrap: "wrap",
|
|
195
199
|
alignItems: "center",
|
|
196
200
|
gap: p.space[3]
|
|
197
|
-
}),
|
|
198
|
-
function
|
|
199
|
-
let
|
|
200
|
-
present:
|
|
201
|
+
}), Te = e({ fontWeight: p.fontWeight.medium }), Ee = e({ color: p.color.textMuted }), De = e({ color: p.color.dangerText }), M = (e, t) => e === t || JSON.stringify(e) === JSON.stringify(t);
|
|
202
|
+
function N({ ref: e, apiRef: n, value: r, defaultValue: i = de, onValueChange: s, color: p, defaultColor: g = "black", onColorChange: ie, width: oe, defaultWidth: se = "medium", onWidthChange: C, label: w, description: T, error: E, signer: O, hint: k, disabled: A = !1, readOnly: j = !1, required: N = !1, replay: Oe = !0, download: ke = !1, fileName: Ae = "signature", historyLimit: je = ce, messages: P, icons: Me, exportOptions: F, slotProps: I, className: Ne, sx: Pe, dir: Fe, style: Ie, onPointerDown: Le, onPointerMove: Re, onPointerUp: ze, onPointerCancel: Be, onLostPointerCapture: Ve, onKeyDown: He, "aria-labelledby": Ue, "aria-describedby": We, ...L }) {
|
|
203
|
+
let R = ee(), z = f(null), Ge = re([z, e]), Ke = f(i), [B = de, qe] = a(r, Ke.current, s), [Je = "black", Ye] = a(p, g, ie), [Xe = "medium", Ze] = a(oe, se, C), V = f({
|
|
204
|
+
present: B,
|
|
201
205
|
past: [],
|
|
202
206
|
future: []
|
|
203
|
-
}),
|
|
207
|
+
}), H = f(null), U = f(null), W = f(null), Qe = f(null), [$e, et] = ne({
|
|
204
208
|
text: "",
|
|
205
209
|
revision: 0
|
|
206
210
|
});
|
|
207
|
-
function
|
|
208
|
-
|
|
211
|
+
function G(e) {
|
|
212
|
+
et((t) => ({
|
|
209
213
|
text: e,
|
|
210
214
|
revision: t.revision + 1
|
|
211
215
|
}));
|
|
212
216
|
}
|
|
213
|
-
let [
|
|
214
|
-
function
|
|
215
|
-
let t =
|
|
217
|
+
let [tt, nt] = ne(!1), [, rt] = ne(0), K = A || j, it = Number.isFinite(je) && je > 0 ? Math.floor(je) : ce;
|
|
218
|
+
function q(e = U.current ? [...V.current.present, U.current.stroke] : V.current.present) {
|
|
219
|
+
let t = z.current;
|
|
216
220
|
if (!t) return;
|
|
217
221
|
let n = t.getBoundingClientRect();
|
|
218
222
|
if (n.width <= 0 || n.height <= 0 || t.clientWidth <= 0 || t.clientHeight <= 0) return;
|
|
@@ -221,120 +225,120 @@ function M({ ref: e, apiRef: n, value: r, defaultValue: i = fe, onValueChange: s
|
|
|
221
225
|
let s = t.getContext("2d");
|
|
222
226
|
if (!s) return;
|
|
223
227
|
s.setTransform(1, 0, 0, 1, 0, 0), s.clearRect(0, 0, t.width, t.height), s.setTransform(t.width / _, 0, 0, t.height / v, 0, 0);
|
|
224
|
-
let c = r.getComputedStyle(t), l = r.matchMedia("(forced-colors: active)").matches, u = Object.fromEntries(Object.entries(
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
function q() {
|
|
228
|
-
U.current !== null && R.current?.ownerDocument.defaultView?.cancelAnimationFrame(U.current), U.current = null, rt(!1), K();
|
|
228
|
+
let c = r.getComputedStyle(t), l = r.matchMedia("(forced-colors: active)").matches, u = Object.fromEntries(Object.entries(fe).map(([e, t]) => [e, l ? c.color : c.getPropertyValue(t).trim()]));
|
|
229
|
+
ge(s, D(e), u);
|
|
229
230
|
}
|
|
230
231
|
function J() {
|
|
231
|
-
|
|
232
|
+
W.current !== null && z.current?.ownerDocument.defaultView?.cancelAnimationFrame(W.current), W.current = null, nt(!1), q();
|
|
232
233
|
}
|
|
233
234
|
function Y() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
J(), G(P.replayComplete);
|
|
236
|
+
}
|
|
237
|
+
function X() {
|
|
238
|
+
let e = U.current?.pointerId;
|
|
239
|
+
U.current = null;
|
|
240
|
+
let t = z.current;
|
|
241
|
+
e !== void 0 && t?.hasPointerCapture(e) && t.releasePointerCapture(e), q();
|
|
238
242
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
243
|
+
function at(e, t, n) {
|
|
244
|
+
M(e, V.current.present) || (J(), X(), H.current = {
|
|
241
245
|
value: e,
|
|
242
246
|
history: t,
|
|
243
247
|
status: n
|
|
244
|
-
},
|
|
248
|
+
}, qe(e));
|
|
245
249
|
}
|
|
246
|
-
function
|
|
247
|
-
let e =
|
|
248
|
-
if (
|
|
250
|
+
function ot() {
|
|
251
|
+
let e = V.current;
|
|
252
|
+
if (K || !e.past.length) return;
|
|
249
253
|
let t = e.past[e.past.length - 1];
|
|
250
|
-
|
|
254
|
+
at(t, {
|
|
251
255
|
present: t,
|
|
252
256
|
past: e.past.slice(0, -1),
|
|
253
|
-
future: [e.present, ...e.future].slice(0,
|
|
254
|
-
},
|
|
257
|
+
future: [e.present, ...e.future].slice(0, it)
|
|
258
|
+
}, P.undone);
|
|
255
259
|
}
|
|
256
|
-
function
|
|
257
|
-
let e =
|
|
258
|
-
if (
|
|
260
|
+
function st() {
|
|
261
|
+
let e = V.current;
|
|
262
|
+
if (K || !e.future.length) return;
|
|
259
263
|
let t = e.future[0];
|
|
260
|
-
|
|
264
|
+
at(t, {
|
|
261
265
|
present: t,
|
|
262
|
-
past: [...e.past, e.present].slice(-
|
|
266
|
+
past: [...e.past, e.present].slice(-it),
|
|
263
267
|
future: e.future.slice(1)
|
|
264
|
-
},
|
|
268
|
+
}, P.redone);
|
|
265
269
|
}
|
|
266
270
|
function Z(e, t) {
|
|
267
|
-
let n =
|
|
268
|
-
|
|
271
|
+
let n = V.current;
|
|
272
|
+
at(e, {
|
|
269
273
|
present: e,
|
|
270
|
-
past: [...n.past, n.present].slice(-
|
|
274
|
+
past: [...n.past, n.present].slice(-it),
|
|
271
275
|
future: []
|
|
272
276
|
}, t);
|
|
273
277
|
}
|
|
274
278
|
function ct() {
|
|
275
|
-
|
|
279
|
+
K || Z(de, P.cleared);
|
|
276
280
|
}
|
|
277
281
|
function lt() {
|
|
278
|
-
|
|
279
|
-
let e =
|
|
280
|
-
if (
|
|
282
|
+
J(), X();
|
|
283
|
+
let e = D(V.current.present), t = z.current?.ownerDocument.defaultView;
|
|
284
|
+
if (A || !e.length || !t) return;
|
|
281
285
|
if (t.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
282
|
-
|
|
286
|
+
Y();
|
|
283
287
|
return;
|
|
284
288
|
}
|
|
285
289
|
let n = [], r = 0;
|
|
286
290
|
e.forEach((t, i) => {
|
|
287
|
-
let a = e[i - 1], o = a ? Math.min(
|
|
291
|
+
let a = e[i - 1], o = a ? Math.min(ue, Math.max(0, t.startTime - a.startTime - a.points.at(-1).time)) : 0, s = t.points.at(-1).time;
|
|
288
292
|
n.push({
|
|
289
293
|
stroke: t,
|
|
290
294
|
offset: r + o
|
|
291
295
|
}), r += o + s;
|
|
292
296
|
});
|
|
293
|
-
let i = r >
|
|
294
|
-
|
|
297
|
+
let i = r > le ? le / r : 1, a = t.performance.now();
|
|
298
|
+
nt(!0);
|
|
295
299
|
let o = (e) => {
|
|
296
300
|
let s = (e - a) / i;
|
|
297
|
-
|
|
301
|
+
q(n.flatMap(({ stroke: e, offset: t }) => {
|
|
298
302
|
if (s < t) return [];
|
|
299
303
|
let n = e.points.filter((e) => e.time <= s - t);
|
|
300
304
|
return n.length ? [{
|
|
301
305
|
...e,
|
|
302
306
|
points: n
|
|
303
307
|
}] : [];
|
|
304
|
-
})), s >= r ?
|
|
308
|
+
})), s >= r ? Y() : W.current = t.requestAnimationFrame(o);
|
|
305
309
|
};
|
|
306
|
-
|
|
310
|
+
W.current = t.requestAnimationFrame(o);
|
|
307
311
|
}
|
|
308
312
|
let Q = f(null);
|
|
309
313
|
u(() => {
|
|
310
|
-
process.env.NODE_ENV !== "production" && (
|
|
311
|
-
}, [
|
|
312
|
-
|
|
313
|
-
present:
|
|
314
|
+
process.env.NODE_ENV !== "production" && (me(B) ? Q.current = null : (Q.current === null || !M(Q.current, B)) && (Q.current = B, console.warn("SignaturePad: value contains malformed strokes; invalid samples are skipped when drawing and exports reject with an \"invalid\" SignatureExportError.")));
|
|
315
|
+
}, [B]), d(() => {
|
|
316
|
+
M(B, V.current.present) || (X(), J(), H.current && M(B, H.current.value) ? (V.current = H.current.history, G(H.current.status)) : V.current = {
|
|
317
|
+
present: B,
|
|
314
318
|
past: [],
|
|
315
319
|
future: []
|
|
316
|
-
},
|
|
320
|
+
}, H.current = null, rt((e) => e + 1)), W.current === null && q(U.current ? [...V.current.present, U.current.stroke] : V.current.present);
|
|
317
321
|
}), d(() => {
|
|
318
|
-
|
|
319
|
-
}, [
|
|
322
|
+
K && (X(), J());
|
|
323
|
+
}, [K]);
|
|
320
324
|
let $ = f({
|
|
321
|
-
draw:
|
|
322
|
-
completeReplay:
|
|
325
|
+
draw: q,
|
|
326
|
+
completeReplay: Y,
|
|
323
327
|
reset: () => {
|
|
324
|
-
|
|
328
|
+
K || Z(Ke.current, P.reset);
|
|
325
329
|
}
|
|
326
330
|
});
|
|
327
331
|
d(() => {
|
|
328
332
|
$.current = {
|
|
329
|
-
draw:
|
|
330
|
-
completeReplay:
|
|
333
|
+
draw: q,
|
|
334
|
+
completeReplay: Y,
|
|
331
335
|
reset: () => {
|
|
332
|
-
|
|
336
|
+
K || Z(Ke.current, P.reset);
|
|
333
337
|
}
|
|
334
338
|
};
|
|
335
339
|
}), d(() => {
|
|
336
|
-
let e =
|
|
337
|
-
|
|
340
|
+
let e = z.current, t = e.ownerDocument.defaultView, n = () => {
|
|
341
|
+
W.current === null && $.current.draw();
|
|
338
342
|
}, r = new ResizeObserver(n);
|
|
339
343
|
r.observe(e);
|
|
340
344
|
let i = new MutationObserver(n);
|
|
@@ -349,7 +353,7 @@ function M({ ref: e, apiRef: n, value: r, defaultValue: i = fe, onValueChange: s
|
|
|
349
353
|
let a = t.matchMedia("(forced-colors: active)");
|
|
350
354
|
a.addEventListener("change", n);
|
|
351
355
|
let o = t.matchMedia("(prefers-reduced-motion: reduce)"), s = () => {
|
|
352
|
-
o.matches &&
|
|
356
|
+
o.matches && W.current !== null && $.current.completeReplay();
|
|
353
357
|
};
|
|
354
358
|
o.addEventListener("change", s);
|
|
355
359
|
let c = t.matchMedia(`(resolution: ${t.devicePixelRatio}dppx)`), l = () => {
|
|
@@ -362,233 +366,234 @@ function M({ ref: e, apiRef: n, value: r, defaultValue: i = fe, onValueChange: s
|
|
|
362
366
|
});
|
|
363
367
|
};
|
|
364
368
|
return u?.addEventListener("reset", ee), () => {
|
|
365
|
-
r.disconnect(), i.disconnect(), a.removeEventListener("change", n), o.removeEventListener("change", s), c.removeEventListener("change", l), t.removeEventListener("resize", n), u?.removeEventListener("reset", ee),
|
|
369
|
+
r.disconnect(), i.disconnect(), a.removeEventListener("change", n), o.removeEventListener("change", s), c.removeEventListener("change", l), t.removeEventListener("resize", n), u?.removeEventListener("reset", ee), W.current !== null && t.cancelAnimationFrame(W.current), W.current = null, U.current = null;
|
|
366
370
|
};
|
|
367
371
|
}, []);
|
|
368
372
|
function ut(e) {
|
|
369
|
-
return
|
|
373
|
+
return z.current && G(P.exported), e;
|
|
370
374
|
}
|
|
371
375
|
function dt(e) {
|
|
372
|
-
if (
|
|
376
|
+
if (K || e.key !== "Home" && e.key !== "End") return;
|
|
373
377
|
let t = e.currentTarget.querySelectorAll("input[type=\"radio\"]:not(:disabled)"), n = e.key === "Home" ? t[0] : t[t.length - 1];
|
|
374
378
|
n && (e.preventDefault(), n.focus(), n.click());
|
|
375
379
|
}
|
|
376
380
|
te(n, () => ({
|
|
377
|
-
focus: () =>
|
|
381
|
+
focus: () => z.current?.focus(),
|
|
378
382
|
clear: ct,
|
|
379
|
-
undo:
|
|
380
|
-
redo:
|
|
383
|
+
undo: ot,
|
|
384
|
+
redo: st,
|
|
381
385
|
replay: lt,
|
|
382
|
-
stopReplay:
|
|
383
|
-
toDataURL: (e) => ut(
|
|
384
|
-
toBlob: (e) =>
|
|
385
|
-
toSvg: (e) => ut(
|
|
386
|
+
stopReplay: J,
|
|
387
|
+
toDataURL: (e) => ut(_e(V.current.present, e ?? F).toDataURL("image/png")),
|
|
388
|
+
toBlob: (e) => ve(V.current.present, e ?? F).then(ut),
|
|
389
|
+
toSvg: (e) => ut(ye(V.current.present, e ?? F))
|
|
386
390
|
}));
|
|
387
391
|
function ft(e, t) {
|
|
388
|
-
let n =
|
|
392
|
+
let n = z.current, r = n.getBoundingClientRect(), i = n.clientWidth, a = n.clientHeight;
|
|
389
393
|
if (i <= 0 || a <= 0 || !Number.isFinite(e.clientX) || !Number.isFinite(e.clientY)) return;
|
|
390
394
|
let o = t.stroke.points, s = Math.max(o.at(-1)?.time ?? 0, Number.isFinite(e.timeStamp) ? e.timeStamp - t.started : 0), c = {
|
|
391
395
|
x: Math.max(0, Math.min(_, (e.clientX - r.left - n.clientLeft) / i * _)),
|
|
392
396
|
y: Math.max(0, Math.min(v, (e.clientY - r.top - n.clientTop) / a * v)),
|
|
393
397
|
pressure: e.pointerType === "pen" && Number.isFinite(e.pressure) ? Math.max(0, Math.min(1, e.pressure)) : null,
|
|
394
398
|
time: s
|
|
395
|
-
}, l = o.at(-1), u =
|
|
399
|
+
}, l = o.at(-1), u = y - he(D(V.current.present));
|
|
396
400
|
(!l || l.x !== c.x || l.y !== c.y) && o.length < u && o.push(c);
|
|
397
401
|
}
|
|
398
402
|
function pt(e) {
|
|
399
|
-
let t =
|
|
403
|
+
let t = U.current;
|
|
400
404
|
if (!t || e.pointerId !== t.pointerId) return;
|
|
401
405
|
let n = e.nativeEvent.getCoalescedEvents?.() ?? [];
|
|
402
406
|
for (let e of n) ft(e, t);
|
|
403
|
-
ft(e.nativeEvent, t),
|
|
407
|
+
ft(e.nativeEvent, t), q([...V.current.present, t.stroke]);
|
|
404
408
|
}
|
|
405
409
|
async function mt(e) {
|
|
406
410
|
try {
|
|
407
|
-
let t = e === "png" ? await
|
|
411
|
+
let t = e === "png" ? await ve(V.current.present, F) : new Blob([ye(V.current.present, F)], { type: "image/svg+xml" }), n = z.current?.ownerDocument;
|
|
408
412
|
if (!n) return;
|
|
409
413
|
let r = URL.createObjectURL(t);
|
|
410
414
|
try {
|
|
411
415
|
let t = n.createElement("a");
|
|
412
|
-
t.href = r, t.download = `${
|
|
416
|
+
t.href = r, t.download = `${Ae.replace(/[\\/\u0000-\u001f:*?"<>|]/g, "_") || "signature"}.${e}`, t.click(), G(P.exported);
|
|
413
417
|
} finally {
|
|
414
418
|
URL.revokeObjectURL(r);
|
|
415
419
|
}
|
|
416
420
|
} catch {
|
|
417
|
-
|
|
421
|
+
z.current && G(P.exportFailed);
|
|
418
422
|
}
|
|
419
423
|
}
|
|
420
|
-
let ht =
|
|
424
|
+
let ht = V.current, gt = [
|
|
421
425
|
{
|
|
422
426
|
action: "undo",
|
|
423
|
-
disabled:
|
|
424
|
-
run:
|
|
427
|
+
disabled: K || !ht.past.length,
|
|
428
|
+
run: ot
|
|
425
429
|
},
|
|
426
430
|
{
|
|
427
431
|
action: "redo",
|
|
428
|
-
disabled:
|
|
429
|
-
run:
|
|
432
|
+
disabled: K || !ht.future.length,
|
|
433
|
+
run: st
|
|
430
434
|
},
|
|
431
|
-
...
|
|
432
|
-
action:
|
|
433
|
-
disabled:
|
|
434
|
-
run:
|
|
435
|
+
...Oe ? [{
|
|
436
|
+
action: tt ? "stop" : "replay",
|
|
437
|
+
disabled: A || !B.length,
|
|
438
|
+
run: tt ? J : lt
|
|
435
439
|
}] : [],
|
|
436
440
|
{
|
|
437
441
|
action: "clear",
|
|
438
|
-
disabled:
|
|
442
|
+
disabled: K || !B.length,
|
|
439
443
|
run: ct
|
|
440
444
|
},
|
|
441
|
-
...
|
|
445
|
+
...ke ? [{
|
|
442
446
|
action: "png",
|
|
443
|
-
disabled:
|
|
447
|
+
disabled: A || !B.length,
|
|
444
448
|
run: () => {
|
|
445
449
|
mt("png");
|
|
446
450
|
}
|
|
447
451
|
}, {
|
|
448
452
|
action: "svg",
|
|
449
|
-
disabled:
|
|
453
|
+
disabled: A || !B.length,
|
|
450
454
|
run: () => {
|
|
451
455
|
mt("svg");
|
|
452
456
|
}
|
|
453
457
|
}] : []
|
|
454
458
|
];
|
|
455
459
|
return /* @__PURE__ */ m(t, {
|
|
456
|
-
className: [
|
|
457
|
-
styles: [
|
|
458
|
-
sx:
|
|
460
|
+
className: [Ne, I?.root?.className].filter(Boolean).join(" "),
|
|
461
|
+
styles: [be, I?.root?.css],
|
|
462
|
+
sx: Pe,
|
|
459
463
|
children: (e) => /* @__PURE__ */ h("div", {
|
|
460
464
|
"data-ui": "signature-pad",
|
|
461
|
-
"data-state":
|
|
465
|
+
"data-state": B.length ? "signed" : "empty",
|
|
462
466
|
className: e,
|
|
463
|
-
dir:
|
|
464
|
-
style:
|
|
467
|
+
dir: Fe,
|
|
468
|
+
style: Ie,
|
|
465
469
|
children: [
|
|
466
|
-
|
|
467
|
-
id: `${
|
|
468
|
-
className:
|
|
469
|
-
css: [
|
|
470
|
-
children:
|
|
470
|
+
b(w) && /* @__PURE__ */ m("span", {
|
|
471
|
+
id: `${R}-label`,
|
|
472
|
+
className: I?.label?.className,
|
|
473
|
+
css: [Te, I?.label?.css],
|
|
474
|
+
children: w
|
|
471
475
|
}),
|
|
472
476
|
/* @__PURE__ */ m("span", {
|
|
473
|
-
id: `${
|
|
477
|
+
id: `${R}-state`,
|
|
474
478
|
css: o,
|
|
475
|
-
children:
|
|
479
|
+
children: B.length ? P.signed : P.empty
|
|
476
480
|
}),
|
|
477
481
|
/* @__PURE__ */ m("span", {
|
|
478
|
-
id: `${
|
|
482
|
+
id: `${R}-shortcuts`,
|
|
479
483
|
css: o,
|
|
480
|
-
children:
|
|
484
|
+
children: P.shortcuts
|
|
481
485
|
}),
|
|
482
486
|
/* @__PURE__ */ h("div", {
|
|
483
|
-
css:
|
|
487
|
+
css: xe,
|
|
484
488
|
children: [/* @__PURE__ */ m("canvas", {
|
|
485
|
-
...
|
|
486
|
-
ref:
|
|
489
|
+
...L,
|
|
490
|
+
ref: Ge,
|
|
487
491
|
role: "img",
|
|
488
|
-
tabIndex:
|
|
489
|
-
"aria-roledescription":
|
|
490
|
-
"aria-disabled":
|
|
491
|
-
"data-readonly":
|
|
492
|
-
"aria-invalid":
|
|
492
|
+
tabIndex: A ? -1 : L.tabIndex ?? 0,
|
|
493
|
+
"aria-roledescription": P.roleDescription,
|
|
494
|
+
"aria-disabled": A || void 0,
|
|
495
|
+
"data-readonly": j || void 0,
|
|
496
|
+
"aria-invalid": b(E) ? !0 : L["aria-invalid"],
|
|
493
497
|
"aria-labelledby": [
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
!
|
|
498
|
+
Ue,
|
|
499
|
+
b(w) && `${R}-label`,
|
|
500
|
+
!L["aria-label"] && `${R}-state`
|
|
497
501
|
].filter(Boolean).join(" ") || void 0,
|
|
498
502
|
"aria-describedby": [
|
|
499
|
-
|
|
500
|
-
`${
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
503
|
+
We,
|
|
504
|
+
`${R}-state`,
|
|
505
|
+
`${R}-shortcuts`,
|
|
506
|
+
N && `${R}-required`,
|
|
507
|
+
b(T) && `${R}-description`,
|
|
508
|
+
b(E) && `${R}-error`
|
|
504
509
|
].filter(Boolean).join(" "),
|
|
505
|
-
className:
|
|
506
|
-
css: [
|
|
510
|
+
className: I?.canvas?.className,
|
|
511
|
+
css: [Se, I?.canvas?.css],
|
|
507
512
|
onPointerDown: (e) => {
|
|
508
|
-
if (
|
|
509
|
-
|
|
513
|
+
if (Le?.(e), e.defaultPrevented || K || !e.isPrimary || e.button !== 0 || U.current || B.length >= ae || he(D(B)) >= y || e.currentTarget.clientWidth <= 0 || e.currentTarget.clientHeight <= 0) return;
|
|
514
|
+
J(), H.current = null;
|
|
510
515
|
let t = Number.isFinite(e.timeStamp) ? e.timeStamp : 0;
|
|
511
|
-
|
|
516
|
+
Qe.current ??= t;
|
|
512
517
|
let n = {
|
|
513
518
|
pointerId: e.pointerId,
|
|
514
519
|
started: t,
|
|
515
520
|
stroke: {
|
|
516
|
-
id:
|
|
521
|
+
id: pe(),
|
|
517
522
|
points: [],
|
|
518
|
-
color:
|
|
519
|
-
width:
|
|
520
|
-
startTime: Math.max(0, t -
|
|
523
|
+
color: Je,
|
|
524
|
+
width: Xe,
|
|
525
|
+
startTime: Math.max(0, t - Qe.current)
|
|
521
526
|
}
|
|
522
527
|
};
|
|
523
|
-
|
|
528
|
+
U.current = n;
|
|
524
529
|
try {
|
|
525
530
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
526
531
|
} catch {
|
|
527
|
-
|
|
532
|
+
U.current = null;
|
|
528
533
|
return;
|
|
529
534
|
}
|
|
530
|
-
ft(e.nativeEvent, n),
|
|
535
|
+
ft(e.nativeEvent, n), q([...ht.present, n.stroke]), e.preventDefault();
|
|
531
536
|
},
|
|
532
537
|
onPointerMove: (e) => {
|
|
533
|
-
|
|
538
|
+
Re?.(e), e.defaultPrevented || pt(e);
|
|
534
539
|
},
|
|
535
540
|
onPointerUp: (e) => {
|
|
536
|
-
if (
|
|
541
|
+
if (ze?.(e), U.current?.pointerId !== e.pointerId) return;
|
|
537
542
|
if (e.defaultPrevented) {
|
|
538
|
-
|
|
543
|
+
X();
|
|
539
544
|
return;
|
|
540
545
|
}
|
|
541
546
|
pt(e);
|
|
542
|
-
let t =
|
|
543
|
-
|
|
547
|
+
let t = U.current.stroke;
|
|
548
|
+
X(), t.points.length && Z([...V.current.present, t], P.added);
|
|
544
549
|
},
|
|
545
550
|
onPointerCancel: (e) => {
|
|
546
|
-
|
|
551
|
+
Be?.(e), U.current?.pointerId === e.pointerId && X();
|
|
547
552
|
},
|
|
548
553
|
onLostPointerCapture: (e) => {
|
|
549
|
-
|
|
554
|
+
Ve?.(e), U.current?.pointerId === e.pointerId && X();
|
|
550
555
|
},
|
|
551
556
|
onKeyDown: (e) => {
|
|
552
|
-
if (
|
|
557
|
+
if (He?.(e), e.defaultPrevented || e.target !== e.currentTarget) return;
|
|
553
558
|
let t = e.key.toLowerCase();
|
|
554
|
-
t === "escape" && (
|
|
559
|
+
t === "escape" && (tt || U.current) ? (J(), X(), e.preventDefault(), e.stopPropagation()) : !K && (e.metaKey || e.ctrlKey) && (t === "z" || t === "y") ? (t === "y" || e.shiftKey ? st() : ot(), e.preventDefault()) : !K && (t === "delete" || t === "backspace") && (ct(), e.preventDefault());
|
|
555
560
|
},
|
|
556
|
-
children:
|
|
557
|
-
}), (
|
|
561
|
+
children: P.fallback
|
|
562
|
+
}), (b(k) || b(O)) && /* @__PURE__ */ h("div", {
|
|
558
563
|
"aria-hidden": "true",
|
|
559
564
|
"data-ui": "signature-pad-guide",
|
|
560
|
-
className:
|
|
561
|
-
css: [
|
|
562
|
-
children: [!
|
|
565
|
+
className: I?.guide?.className,
|
|
566
|
+
css: [Ce, I?.guide?.css],
|
|
567
|
+
children: [!B.length && b(k) && /* @__PURE__ */ m("span", { children: k }), b(O) && /* @__PURE__ */ m("span", { children: O })]
|
|
563
568
|
})]
|
|
564
569
|
}),
|
|
565
570
|
/* @__PURE__ */ h("div", {
|
|
566
571
|
"data-ui": "signature-pad-toolbar",
|
|
567
|
-
className:
|
|
568
|
-
css: [
|
|
572
|
+
className: I?.toolbar?.className,
|
|
573
|
+
css: [we, I?.toolbar?.css],
|
|
569
574
|
children: [
|
|
570
575
|
/* @__PURE__ */ m(l, {
|
|
571
|
-
"aria-label":
|
|
576
|
+
"aria-label": P.ink,
|
|
572
577
|
orientation: "horizontal",
|
|
573
|
-
value:
|
|
574
|
-
onValueChange: (e) =>
|
|
575
|
-
disabled:
|
|
578
|
+
value: Je,
|
|
579
|
+
onValueChange: (e) => Ye(e),
|
|
580
|
+
disabled: K,
|
|
576
581
|
onKeyDown: dt,
|
|
577
|
-
children: Object.keys(
|
|
582
|
+
children: Object.keys(S).map((e) => /* @__PURE__ */ m(l.Radio, {
|
|
578
583
|
value: e,
|
|
579
|
-
label:
|
|
584
|
+
label: P.colors[e]
|
|
580
585
|
}, e))
|
|
581
586
|
}),
|
|
582
587
|
/* @__PURE__ */ m(l, {
|
|
583
|
-
"aria-label":
|
|
588
|
+
"aria-label": P.nib,
|
|
584
589
|
orientation: "horizontal",
|
|
585
|
-
value:
|
|
586
|
-
onValueChange: (e) =>
|
|
587
|
-
disabled:
|
|
590
|
+
value: Xe,
|
|
591
|
+
onValueChange: (e) => Ze(e),
|
|
592
|
+
disabled: K,
|
|
588
593
|
onKeyDown: dt,
|
|
589
|
-
children: Object.keys(
|
|
594
|
+
children: Object.keys(x).map((e) => /* @__PURE__ */ m(l.Radio, {
|
|
590
595
|
value: e,
|
|
591
|
-
label:
|
|
596
|
+
label: P.widths[e]
|
|
592
597
|
}, e))
|
|
593
598
|
}),
|
|
594
599
|
gt.map(({ action: e, disabled: t, run: n }) => /* @__PURE__ */ h(c, {
|
|
@@ -596,45 +601,45 @@ function M({ ref: e, apiRef: n, value: r, defaultValue: i = fe, onValueChange: s
|
|
|
596
601
|
variant: "outline",
|
|
597
602
|
disabled: t,
|
|
598
603
|
onClick: n,
|
|
599
|
-
className:
|
|
600
|
-
css:
|
|
601
|
-
children: [
|
|
604
|
+
className: I?.action?.className,
|
|
605
|
+
css: I?.action?.css,
|
|
606
|
+
children: [b(Me?.[e]) && /* @__PURE__ */ m("span", {
|
|
602
607
|
"aria-hidden": "true",
|
|
603
|
-
children:
|
|
604
|
-
}),
|
|
608
|
+
children: Me?.[e]
|
|
609
|
+
}), P.actions[e]]
|
|
605
610
|
}, e))
|
|
606
611
|
]
|
|
607
612
|
}),
|
|
608
|
-
|
|
609
|
-
id: `${
|
|
613
|
+
N && /* @__PURE__ */ m("span", {
|
|
614
|
+
id: `${R}-required`,
|
|
610
615
|
css: o,
|
|
611
|
-
children:
|
|
616
|
+
children: P.required
|
|
612
617
|
}),
|
|
613
|
-
|
|
614
|
-
id: `${
|
|
615
|
-
className:
|
|
616
|
-
css: [
|
|
617
|
-
children:
|
|
618
|
+
b(T) && /* @__PURE__ */ m("div", {
|
|
619
|
+
id: `${R}-description`,
|
|
620
|
+
className: I?.description?.className,
|
|
621
|
+
css: [Ee, I?.description?.css],
|
|
622
|
+
children: T
|
|
618
623
|
}),
|
|
619
|
-
|
|
620
|
-
id: `${
|
|
624
|
+
b(E) && /* @__PURE__ */ m("div", {
|
|
625
|
+
id: `${R}-error`,
|
|
621
626
|
role: "alert",
|
|
622
|
-
className:
|
|
623
|
-
css: [
|
|
624
|
-
children:
|
|
627
|
+
className: I?.error?.className,
|
|
628
|
+
css: [De, I?.error?.css],
|
|
629
|
+
children: E
|
|
625
630
|
}),
|
|
626
631
|
/* @__PURE__ */ m("div", {
|
|
627
632
|
role: "status",
|
|
628
633
|
"aria-live": "polite",
|
|
629
634
|
"aria-atomic": "true",
|
|
630
|
-
className:
|
|
631
|
-
css: [o,
|
|
632
|
-
children:
|
|
635
|
+
className: I?.status?.className,
|
|
636
|
+
css: [o, I?.status?.css],
|
|
637
|
+
children: $e.text && /* @__PURE__ */ m("span", { children: $e.text }, $e.revision)
|
|
633
638
|
})
|
|
634
639
|
]
|
|
635
640
|
})
|
|
636
641
|
});
|
|
637
642
|
}
|
|
638
|
-
|
|
643
|
+
N.displayName = "SignaturePad";
|
|
639
644
|
//#endregion
|
|
640
|
-
export {
|
|
645
|
+
export { ye as i, N as n, ve as r, C as t };
|