@net-advantage/nabs-ui-signature 0.30.0 → 0.32.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.
@@ -1,6 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("react");function n(e,t){let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function r(e,t){if(t.length!==0){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n+=1)e.lineTo(t[n].x,t[n].y);e.stroke()}}function i(e,t,n){e.fillStyle=n,e.fillRect(0,0,t.width,t.height)}var a=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),o=e((e=>{process.env.NODE_ENV!==`production`&&(function(){function t(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(typeof e.tag==`number`&&console.error(`Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.`),e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var n=e.render;return e=e.displayName,e||=(e=n.displayName||n.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return n=e.displayName||null,n===null?t(e.type)||`Memo`:n;case E:n=e._payload,e=e._init;try{return t(e(n))}catch{}}return null}function n(e){return``+e}function r(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,i=typeof Symbol==`function`&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||`Object`;return r.call(t,`The provided key is an unsupported type %s. This value must be coerced to a string before using it here.`,i),n(e)}}function i(e){if(e===_)return`<>`;if(typeof e==`object`&&e&&e.$$typeof===E)return`<...>`;try{var n=t(e);return n?`<`+n+`>`:`<...>`}catch{return`<...>`}}function a(){var e=k.A;return e===null?null:e.getOwner()}function o(){return Error(`react-stack-top-frame`)}function s(e){if(A.call(e,`key`)){var t=Object.getOwnPropertyDescriptor(e,`key`).get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function c(e,t){function n(){N||(N=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function l(){var e=t(this.type);return P[e]||(P[e]=!0,console.error(`Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.`)),e=this.props.ref,e===void 0?null:e}function u(e,t,n,r,i,a){var o=n.ref;return e={$$typeof:h,type:e,key:t,props:n,_owner:r},(o===void 0?null:o)===null?Object.defineProperty(e,"ref",{enumerable:!1,value:null}):Object.defineProperty(e,"ref",{enumerable:!1,get:l}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:a}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function d(e,n,i,o,l,d){var p=n.children;if(p!==void 0)if(o)if(j(p)){for(o=0;o<p.length;o++)f(p[o]);Object.freeze&&Object.freeze(p)}else console.error(`React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.`);else f(p);if(A.call(n,`key`)){p=t(e);var m=Object.keys(n).filter(function(e){return e!==`key`});o=0<m.length?`{key: someKey, `+m.join(`: ..., `)+`: ...}`:`{key: someKey}`,L[p+o]||(m=0<m.length?`{`+m.join(`: ..., `)+`: ...}`:`{}`,console.error(`A props object containing a "key" prop is being spread into JSX:
2
- let props = %s;
3
- <%s {...props} />
4
- React keys must be passed directly to JSX without using spread:
5
- let props = %s;
6
- <%s key={someKey} {...props} />`,o,p,m,p),L[p+o]=!0)}if(p=null,i!==void 0&&(r(i),p=``+i),s(n)&&(r(n.key),p=``+n.key),`key`in n)for(var h in i={},n)h!==`key`&&(i[h]=n[h]);else i=n;return p&&c(i,typeof e==`function`?e.displayName||e.name||`Unknown`:e),u(e,p,i,a(),l,d)}function f(e){p(e)?e._store&&(e._store.validated=1):typeof e==`object`&&e&&e.$$typeof===E&&(e._payload.status===`fulfilled`?p(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function p(e){return typeof e==`object`&&!!e&&e.$$typeof===h}var m=require("react"),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.client.reference`),k=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,j=Array.isArray,M=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(e){return e()}};var N,P={},F=m.react_stack_bottom_frame.bind(m,o)(),I=M(i(o)),L={};e.Fragment=_,e.jsx=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!1,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)},e.jsxs=function(e,t,n){var r=1e4>k.recentlyCreatedOwnerStacks++;return d(e,t,n,!0,r?Error(`react-stack-top-frame`):F,r?M(i(e)):I)}})()})),s=e(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=a():t.exports=o()}))();function c({label:e=`Signature`,helperText:a=`Use your mouse to draw your signature.`,value:o=``,disabled:c=!1,className:l=``,labelClassName:u=``,helperTextClassName:d=``,padClassName:f=``,canvasClassName:p=``,id:m,width:h=720,height:g=240,backgroundColor:_=`#ffffff`,penColor:v=`#0f172a`,penWidth:y=2.5,onChange:b,onBeginStroke:x,onEndStroke:S,onClear:C}){let w=(0,t.useId)(),T=m??`nabs-ui-signature-${w.replace(/:/g,``)}`,E=(0,t.useRef)(null),D=(0,t.useRef)(null),O=(0,t.useRef)(!1),k=(0,t.useRef)([]),[A,j]=(0,t.useState)(!o),M=[`nabs-ui-signature`,c?`nabs-ui-signature--disabled`:``,l].filter(Boolean).join(` `),N=[`nabs-ui-signature__label`,u].filter(Boolean).join(` `),P=[`nabs-ui-signature__helper`,d].filter(Boolean).join(` `),F=[`nabs-ui-signature__pad`,f].filter(Boolean).join(` `),I=[`nabs-ui-signature__canvas`,p].filter(Boolean).join(` `);(0,t.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let n=window.devicePixelRatio||1,r=Math.round(h),a=Math.round(g);if(e.width=Math.round(r*n),e.height=Math.round(a*n),e.style.width=`${r}px`,e.style.height=`${a}px`,D.current=t,t.lineCap=`round`,t.lineJoin=`round`,t.lineWidth=y*n,t.strokeStyle=v,t.scale(n,n),i(t,e,_),o){let e=new Image;e.onload=()=>{t.clearRect(0,0,r,a),t.fillStyle=_,t.fillRect(0,0,r,a),t.drawImage(e,0,0,r,a),j(!1)},e.src=o}return()=>{D.current=null}},[_,v,y,o,h,g]);let L=e=>{b?.(e.toDataURL(`image/png`))},R=e=>{if(c||O.current)return;let t=E.current,r=D.current;!t||!r||(`pointerId`in e&&typeof e.pointerId==`number`&&t.setPointerCapture&&t.setPointerCapture(e.pointerId),O.current=!0,k.current=[n(e,t)],r.beginPath(),r.moveTo(k.current[0].x,k.current[0].y),x?.())},z=e=>{if(c||!O.current)return;let t=E.current,r=D.current;if(!t||!r)return;let i=n(e,t);k.current.push(i),r.lineTo(i.x,i.y),r.stroke(),j(!1)},B=e=>{let t=E.current,n=D.current;if(!(!t||!n||!O.current)){if(e&&`pointerId`in e&&typeof e.pointerId==`number`&&t.releasePointerCapture)try{t.releasePointerCapture(e.pointerId)}catch{}O.current=!1,r(n,k.current),k.current=[],L(t),S?.()}};return(0,s.jsxs)(`div`,{className:M,children:[(0,s.jsx)(`div`,{className:N,id:`${T}-label`,children:e}),a?(0,s.jsx)(`div`,{className:P,children:a}):null,(0,s.jsxs)(`div`,{className:F,children:[(0,s.jsx)(`canvas`,{id:T,ref:E,className:I,role:`img`,"aria-labelledby":`${T}-label`,"aria-label":e,onPointerDown:R,onPointerMove:z,onPointerUp:B,onPointerCancel:B,onPointerLeave:B,onMouseDown:R,onMouseMove:z,onMouseUp:B,onMouseLeave:B}),(0,s.jsx)(`div`,{className:`nabs-ui-signature__placeholder`,"aria-hidden":`true`,children:A?`Draw here`:null})]}),(0,s.jsx)(`div`,{className:`nabs-ui-signature__actions`,children:(0,s.jsx)(`button`,{type:`button`,className:`nabs-ui-signature__clearButton`,onClick:()=>{let e=E.current,t=D.current;!e||!t||(t.clearRect(0,0,e.width,e.height),i(t,e,_),j(!0),b?.(``),C?.())},disabled:c||A,children:`Clear`})})]})}exports.Signature=c;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("react/jsx-runtime");function n(e,t){let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function r(e,t){if(t.length!==0){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n+=1)e.lineTo(t[n].x,t[n].y);e.stroke()}}function i(e,t,n){e.fillStyle=n,e.fillRect(0,0,t.width,t.height)}function a({label:a=`Signature`,helperText:o=`Use your mouse to draw your signature.`,value:s=``,disabled:c=!1,className:l=``,labelClassName:u=``,helperTextClassName:d=``,padClassName:f=``,canvasClassName:p=``,id:m,width:h=720,height:g=240,backgroundColor:_=`#ffffff`,penColor:v=`#0f172a`,penWidth:y=2.5,onChange:b,onBeginStroke:x,onEndStroke:S,onClear:C}){let w=(0,e.useId)(),T=m??`nabs-ui-signature-${w.replace(/:/g,``)}`,E=(0,e.useRef)(null),D=(0,e.useRef)(null),O=(0,e.useRef)(!1),k=(0,e.useRef)([]),[A,j]=(0,e.useState)(!s),M=[`nabs-ui-signature`,c?`nabs-ui-signature--disabled`:``,l].filter(Boolean).join(` `),N=[`nabs-ui-signature__label`,u].filter(Boolean).join(` `),P=[`nabs-ui-signature__helper`,d].filter(Boolean).join(` `),F=[`nabs-ui-signature__pad`,f].filter(Boolean).join(` `),I=[`nabs-ui-signature__canvas`,p].filter(Boolean).join(` `);(0,e.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let n=window.devicePixelRatio||1,r=Math.round(h),a=Math.round(g);if(e.width=Math.round(r*n),e.height=Math.round(a*n),e.style.width=`${r}px`,e.style.height=`${a}px`,D.current=t,t.lineCap=`round`,t.lineJoin=`round`,t.lineWidth=y*n,t.strokeStyle=v,t.scale(n,n),i(t,e,_),s){let e=new Image;e.onload=()=>{t.clearRect(0,0,r,a),t.fillStyle=_,t.fillRect(0,0,r,a),t.drawImage(e,0,0,r,a),j(!1)},e.src=s}return()=>{D.current=null}},[_,v,y,s,h,g]);let L=e=>{b?.(e.toDataURL(`image/png`))},R=e=>{if(c||O.current)return;let t=E.current,r=D.current;!t||!r||(`pointerId`in e&&typeof e.pointerId==`number`&&t.setPointerCapture&&t.setPointerCapture(e.pointerId),O.current=!0,k.current=[n(e,t)],r.beginPath(),r.moveTo(k.current[0].x,k.current[0].y),x?.())},z=e=>{if(c||!O.current)return;let t=E.current,r=D.current;if(!t||!r)return;let i=n(e,t);k.current.push(i),r.lineTo(i.x,i.y),r.stroke(),j(!1)},B=e=>{let t=E.current,n=D.current;if(!(!t||!n||!O.current)){if(e&&`pointerId`in e&&typeof e.pointerId==`number`&&t.releasePointerCapture)try{t.releasePointerCapture(e.pointerId)}catch{}O.current=!1,r(n,k.current),k.current=[],L(t),S?.()}};return(0,t.jsxs)(`div`,{className:M,children:[(0,t.jsx)(`div`,{className:N,id:`${T}-label`,children:a}),o?(0,t.jsx)(`div`,{className:P,children:o}):null,(0,t.jsxs)(`div`,{className:F,children:[(0,t.jsx)(`canvas`,{id:T,ref:E,className:I,role:`img`,"aria-labelledby":`${T}-label`,"aria-label":a,onPointerDown:R,onPointerMove:z,onPointerUp:B,onPointerCancel:B,onPointerLeave:B,onMouseDown:R,onMouseMove:z,onMouseUp:B,onMouseLeave:B}),(0,t.jsx)(`div`,{className:`nabs-ui-signature__placeholder`,"aria-hidden":`true`,children:A?`Draw here`:null})]}),(0,t.jsx)(`div`,{className:`nabs-ui-signature__actions`,children:(0,t.jsx)(`button`,{type:`button`,className:`nabs-ui-signature__clearButton`,onClick:()=>{let e=E.current,t=D.current;!e||!t||(t.clearRect(0,0,e.width,e.height),i(t,e,_),j(!0),b?.(``),C?.())},disabled:c||A,children:`Clear`})})]})}exports.Signature=a;
@@ -1,10 +1,5 @@
1
1
  import { useEffect as e, useId as t, useRef as n, useState as r } from "react";
2
- //#region \0rolldown/runtime.js
3
- var i = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), a = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
4
- if (typeof require < "u") return require.apply(this, arguments);
5
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
6
- });
7
- //#endregion
2
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
8
3
  //#region src/signature.utils.ts
9
4
  function o(e, t) {
10
5
  let n = t.getBoundingClientRect();
@@ -24,279 +19,103 @@ function c(e, t, n) {
24
19
  e.fillStyle = n, e.fillRect(0, 0, t.width, t.height);
25
20
  }
26
21
  //#endregion
27
- //#region ../../node_modules/.pnpm/react@19.2.7/node_modules/react/cjs/react-jsx-runtime.production.js
28
- var l = /* @__PURE__ */ i(((e) => {
29
- var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
30
- function r(e, n, r) {
31
- var i = null;
32
- if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
33
- else r = n;
34
- return n = r.ref, {
35
- $$typeof: t,
36
- type: e,
37
- key: i,
38
- ref: n === void 0 ? null : n,
39
- props: r
40
- };
41
- }
42
- e.Fragment = n, e.jsx = r, e.jsxs = r;
43
- })), u = /* @__PURE__ */ i(((e) => {
44
- process.env.NODE_ENV !== "production" && (function() {
45
- function t(e) {
46
- if (e == null) return null;
47
- if (typeof e == "function") return e.$$typeof === k ? null : e.displayName || e.name || null;
48
- if (typeof e == "string") return e;
49
- switch (e) {
50
- case v: return "Fragment";
51
- case b: return "Profiler";
52
- case y: return "StrictMode";
53
- case w: return "Suspense";
54
- case T: return "SuspenseList";
55
- case O: return "Activity";
56
- }
57
- if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
58
- case _: return "Portal";
59
- case S: return e.displayName || "Context";
60
- case x: return (e._context.displayName || "Context") + ".Consumer";
61
- case C:
62
- var n = e.render;
63
- return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
64
- case E: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
65
- case D:
66
- n = e._payload, e = e._init;
67
- try {
68
- return t(e(n));
69
- } catch {}
70
- }
71
- return null;
72
- }
73
- function n(e) {
74
- return "" + e;
75
- }
76
- function r(e) {
77
- try {
78
- n(e);
79
- var t = !1;
80
- } catch {
81
- t = !0;
82
- }
83
- if (t) {
84
- t = console;
85
- var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
87
- }
88
- }
89
- function i(e) {
90
- if (e === v) return "<>";
91
- if (typeof e == "object" && e && e.$$typeof === D) return "<...>";
92
- try {
93
- var n = t(e);
94
- return n ? "<" + n + ">" : "<...>";
95
- } catch {
96
- return "<...>";
97
- }
98
- }
99
- function o() {
100
- var e = A.A;
101
- return e === null ? null : e.getOwner();
102
- }
103
- function s() {
104
- return Error("react-stack-top-frame");
105
- }
106
- function c(e) {
107
- if (j.call(e, "key")) {
108
- var t = Object.getOwnPropertyDescriptor(e, "key").get;
109
- if (t && t.isReactWarning) return !1;
110
- }
111
- return e.key !== void 0;
112
- }
113
- function l(e, t) {
114
- function n() {
115
- P || (P = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
116
- }
117
- n.isReactWarning = !0, Object.defineProperty(e, "key", {
118
- get: n,
119
- configurable: !0
120
- });
121
- }
122
- function u() {
123
- var e = t(this.type);
124
- return F[e] || (F[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
125
- }
126
- function d(e, t, n, r, i, a) {
127
- var o = n.ref;
128
- return e = {
129
- $$typeof: g,
130
- type: e,
131
- key: t,
132
- props: n,
133
- _owner: r
134
- }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
135
- enumerable: !1,
136
- value: null
137
- }) : Object.defineProperty(e, "ref", {
138
- enumerable: !1,
139
- get: u
140
- }), e._store = {}, Object.defineProperty(e._store, "validated", {
141
- configurable: !1,
142
- enumerable: !1,
143
- writable: !0,
144
- value: 0
145
- }), Object.defineProperty(e, "_debugInfo", {
146
- configurable: !1,
147
- enumerable: !1,
148
- writable: !0,
149
- value: null
150
- }), Object.defineProperty(e, "_debugStack", {
151
- configurable: !1,
152
- enumerable: !1,
153
- writable: !0,
154
- value: i
155
- }), Object.defineProperty(e, "_debugTask", {
156
- configurable: !1,
157
- enumerable: !1,
158
- writable: !0,
159
- value: a
160
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
161
- }
162
- function f(e, n, i, a, s, u) {
163
- var f = n.children;
164
- if (f !== void 0) if (a) if (M(f)) {
165
- for (a = 0; a < f.length; a++) p(f[a]);
166
- Object.freeze && Object.freeze(f);
167
- } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
168
- else p(f);
169
- if (j.call(n, "key")) {
170
- f = t(e);
171
- var m = Object.keys(n).filter(function(e) {
172
- return e !== "key";
173
- });
174
- a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", R[f + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, f, m, f), R[f + a] = !0);
175
- }
176
- if (f = null, i !== void 0 && (r(i), f = "" + i), c(n) && (r(n.key), f = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
177
- else i = n;
178
- return f && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), d(e, f, i, o(), s, u);
179
- }
180
- function p(e) {
181
- m(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === D && (e._payload.status === "fulfilled" ? m(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
182
- }
183
- function m(e) {
184
- return typeof e == "object" && !!e && e.$$typeof === g;
185
- }
186
- var h = a("react"), g = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), S = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), O = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
187
- return null;
188
- };
189
- h = { react_stack_bottom_frame: function(e) {
190
- return e();
191
- } };
192
- var P, F = {}, I = h.react_stack_bottom_frame.bind(h, s)(), L = N(i(s)), R = {};
193
- e.Fragment = v, e.jsx = function(e, t, n) {
194
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
195
- return f(e, t, n, !1, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
196
- }, e.jsxs = function(e, t, n) {
197
- var r = 1e4 > A.recentlyCreatedOwnerStacks++;
198
- return f(e, t, n, !0, r ? Error("react-stack-top-frame") : I, r ? N(i(e)) : L);
199
- };
200
- })();
201
- })), d = (/* @__PURE__ */ i(((e, t) => {
202
- process.env.NODE_ENV === "production" ? t.exports = l() : t.exports = u();
203
- })))();
204
- function f({ label: i = "Signature", helperText: a = "Use your mouse to draw your signature.", value: l = "", disabled: u = !1, className: f = "", labelClassName: p = "", helperTextClassName: m = "", padClassName: h = "", canvasClassName: g = "", id: _, width: v = 720, height: y = 240, backgroundColor: b = "#ffffff", penColor: x = "#0f172a", penWidth: S = 2.5, onChange: C, onBeginStroke: w, onEndStroke: T, onClear: E }) {
205
- let D = t(), O = _ ?? `nabs-ui-signature-${D.replace(/:/g, "")}`, k = n(null), A = n(null), j = n(!1), M = n([]), [N, P] = r(!l), F = [
22
+ //#region src/Signature.tsx
23
+ function l({ label: l = "Signature", helperText: u = "Use your mouse to draw your signature.", value: d = "", disabled: f = !1, className: p = "", labelClassName: m = "", helperTextClassName: h = "", padClassName: g = "", canvasClassName: _ = "", id: v, width: y = 720, height: b = 240, backgroundColor: x = "#ffffff", penColor: S = "#0f172a", penWidth: C = 2.5, onChange: w, onBeginStroke: T, onEndStroke: E, onClear: D }) {
24
+ let O = t(), k = v ?? `nabs-ui-signature-${O.replace(/:/g, "")}`, A = n(null), j = n(null), M = n(!1), N = n([]), [P, F] = r(!d), I = [
206
25
  "nabs-ui-signature",
207
- u ? "nabs-ui-signature--disabled" : "",
208
- f
209
- ].filter(Boolean).join(" "), I = ["nabs-ui-signature__label", p].filter(Boolean).join(" "), L = ["nabs-ui-signature__helper", m].filter(Boolean).join(" "), R = ["nabs-ui-signature__pad", h].filter(Boolean).join(" "), z = ["nabs-ui-signature__canvas", g].filter(Boolean).join(" ");
26
+ f ? "nabs-ui-signature--disabled" : "",
27
+ p
28
+ ].filter(Boolean).join(" "), L = ["nabs-ui-signature__label", m].filter(Boolean).join(" "), R = ["nabs-ui-signature__helper", h].filter(Boolean).join(" "), z = ["nabs-ui-signature__pad", g].filter(Boolean).join(" "), B = ["nabs-ui-signature__canvas", _].filter(Boolean).join(" ");
210
29
  e(() => {
211
- let e = k.current;
30
+ let e = A.current;
212
31
  if (!e) return;
213
32
  let t = e.getContext("2d");
214
33
  if (!t) return;
215
- let n = window.devicePixelRatio || 1, r = Math.round(v), i = Math.round(y);
216
- if (e.width = Math.round(r * n), e.height = Math.round(i * n), e.style.width = `${r}px`, e.style.height = `${i}px`, A.current = t, t.lineCap = "round", t.lineJoin = "round", t.lineWidth = S * n, t.strokeStyle = x, t.scale(n, n), c(t, e, b), l) {
34
+ let n = window.devicePixelRatio || 1, r = Math.round(y), i = Math.round(b);
35
+ if (e.width = Math.round(r * n), e.height = Math.round(i * n), e.style.width = `${r}px`, e.style.height = `${i}px`, j.current = t, t.lineCap = "round", t.lineJoin = "round", t.lineWidth = C * n, t.strokeStyle = S, t.scale(n, n), c(t, e, x), d) {
217
36
  let e = new Image();
218
37
  e.onload = () => {
219
- t.clearRect(0, 0, r, i), t.fillStyle = b, t.fillRect(0, 0, r, i), t.drawImage(e, 0, 0, r, i), P(!1);
220
- }, e.src = l;
38
+ t.clearRect(0, 0, r, i), t.fillStyle = x, t.fillRect(0, 0, r, i), t.drawImage(e, 0, 0, r, i), F(!1);
39
+ }, e.src = d;
221
40
  }
222
41
  return () => {
223
- A.current = null;
42
+ j.current = null;
224
43
  };
225
44
  }, [
226
- b,
227
45
  x,
228
46
  S,
229
- l,
230
- v,
231
- y
47
+ C,
48
+ d,
49
+ y,
50
+ b
232
51
  ]);
233
- let B = (e) => {
234
- C?.(e.toDataURL("image/png"));
235
- }, V = (e) => {
236
- if (u || j.current) return;
237
- let t = k.current, n = A.current;
238
- !t || !n || ("pointerId" in e && typeof e.pointerId == "number" && t.setPointerCapture && t.setPointerCapture(e.pointerId), j.current = !0, M.current = [o(e, t)], n.beginPath(), n.moveTo(M.current[0].x, M.current[0].y), w?.());
52
+ let V = (e) => {
53
+ w?.(e.toDataURL("image/png"));
239
54
  }, H = (e) => {
240
- if (u || !j.current) return;
241
- let t = k.current, n = A.current;
55
+ if (f || M.current) return;
56
+ let t = A.current, n = j.current;
57
+ !t || !n || ("pointerId" in e && typeof e.pointerId == "number" && t.setPointerCapture && t.setPointerCapture(e.pointerId), M.current = !0, N.current = [o(e, t)], n.beginPath(), n.moveTo(N.current[0].x, N.current[0].y), T?.());
58
+ }, U = (e) => {
59
+ if (f || !M.current) return;
60
+ let t = A.current, n = j.current;
242
61
  if (!t || !n) return;
243
62
  let r = o(e, t);
244
- M.current.push(r), n.lineTo(r.x, r.y), n.stroke(), P(!1);
245
- }, U = (e) => {
246
- let t = k.current, n = A.current;
247
- if (!(!t || !n || !j.current)) {
63
+ N.current.push(r), n.lineTo(r.x, r.y), n.stroke(), F(!1);
64
+ }, W = (e) => {
65
+ let t = A.current, n = j.current;
66
+ if (!(!t || !n || !M.current)) {
248
67
  if (e && "pointerId" in e && typeof e.pointerId == "number" && t.releasePointerCapture) try {
249
68
  t.releasePointerCapture(e.pointerId);
250
69
  } catch {}
251
- j.current = !1, s(n, M.current), M.current = [], B(t), T?.();
70
+ M.current = !1, s(n, N.current), N.current = [], V(t), E?.();
252
71
  }
253
72
  };
254
- return /* @__PURE__ */ (0, d.jsxs)("div", {
255
- className: F,
73
+ return /* @__PURE__ */ a("div", {
74
+ className: I,
256
75
  children: [
257
- /* @__PURE__ */ (0, d.jsx)("div", {
258
- className: I,
259
- id: `${O}-label`,
260
- children: i
261
- }),
262
- a ? /* @__PURE__ */ (0, d.jsx)("div", {
76
+ /* @__PURE__ */ i("div", {
263
77
  className: L,
264
- children: a
265
- }) : null,
266
- /* @__PURE__ */ (0, d.jsxs)("div", {
78
+ id: `${k}-label`,
79
+ children: l
80
+ }),
81
+ u ? /* @__PURE__ */ i("div", {
267
82
  className: R,
268
- children: [/* @__PURE__ */ (0, d.jsx)("canvas", {
269
- id: O,
270
- ref: k,
271
- className: z,
83
+ children: u
84
+ }) : null,
85
+ /* @__PURE__ */ a("div", {
86
+ className: z,
87
+ children: [/* @__PURE__ */ i("canvas", {
88
+ id: k,
89
+ ref: A,
90
+ className: B,
272
91
  role: "img",
273
- "aria-labelledby": `${O}-label`,
274
- "aria-label": i,
275
- onPointerDown: V,
276
- onPointerMove: H,
277
- onPointerUp: U,
278
- onPointerCancel: U,
279
- onPointerLeave: U,
280
- onMouseDown: V,
281
- onMouseMove: H,
282
- onMouseUp: U,
283
- onMouseLeave: U
284
- }), /* @__PURE__ */ (0, d.jsx)("div", {
92
+ "aria-labelledby": `${k}-label`,
93
+ "aria-label": l,
94
+ onPointerDown: H,
95
+ onPointerMove: U,
96
+ onPointerUp: W,
97
+ onPointerCancel: W,
98
+ onPointerLeave: W,
99
+ onMouseDown: H,
100
+ onMouseMove: U,
101
+ onMouseUp: W,
102
+ onMouseLeave: W
103
+ }), /* @__PURE__ */ i("div", {
285
104
  className: "nabs-ui-signature__placeholder",
286
105
  "aria-hidden": "true",
287
- children: N ? "Draw here" : null
106
+ children: P ? "Draw here" : null
288
107
  })]
289
108
  }),
290
- /* @__PURE__ */ (0, d.jsx)("div", {
109
+ /* @__PURE__ */ i("div", {
291
110
  className: "nabs-ui-signature__actions",
292
- children: /* @__PURE__ */ (0, d.jsx)("button", {
111
+ children: /* @__PURE__ */ i("button", {
293
112
  type: "button",
294
113
  className: "nabs-ui-signature__clearButton",
295
114
  onClick: () => {
296
- let e = k.current, t = A.current;
297
- !e || !t || (t.clearRect(0, 0, e.width, e.height), c(t, e, b), P(!0), C?.(""), E?.());
115
+ let e = A.current, t = j.current;
116
+ !e || !t || (t.clearRect(0, 0, e.width, e.height), c(t, e, x), F(!0), w?.(""), D?.());
298
117
  },
299
- disabled: u || N,
118
+ disabled: f || P,
300
119
  children: "Clear"
301
120
  })
302
121
  })
@@ -304,4 +123,4 @@ function f({ label: i = "Signature", helperText: a = "Use your mouse to draw you
304
123
  });
305
124
  }
306
125
  //#endregion
307
- export { f as Signature };
126
+ export { l as Signature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@net-advantage/nabs-ui-signature",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "Reusable signature pad control for the Nabs UI library.",
5
5
  "type": "module",
6
6
  "main": "./dist/nabs-ui-signature.cjs",