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