@designbyadrian/react-interactive-input 3.1.0 → 3.1.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.
@@ -1,22 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react");var q={exports:{}},D={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var ee;function ue(){if(ee)return D;ee=1;var a=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function R(v,u,d){var N=null;if(d!==void 0&&(N=""+d),u.key!==void 0&&(N=""+u.key),"key"in u){d={};for(var E in u)E!=="key"&&(d[E]=u[E])}else d=u;return u=d.ref,{$$typeof:a,type:v,key:N,ref:u!==void 0?u:null,props:d}}return D.Fragment=f,D.jsx=R,D.jsxs=R,D}var L={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var te;function ie(){return te||(te=1,process.env.NODE_ENV!=="production"&&(function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===k?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case P:return"Fragment";case C:return"Profiler";case I:return"StrictMode";case s:return"Suspense";case p:return"SuspenseList";case T: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 F:return"Portal";case X:return e.displayName||"Context";case M:return(e._context.displayName||"Context")+".Consumer";case o:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case b:return n=e.displayName||null,n!==null?n:a(e.type)||"Memo";case S:n=e._payload,e=e._init;try{return a(e(n))}catch{}}return null}function f(e){return""+e}function R(e){try{f(e);var n=!1}catch{n=!0}if(n){n=console;var c=n.error,i=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",i),f(e)}}function v(e){if(e===P)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)return"<...>";try{var n=a(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function u(){var e=w.A;return e===null?null:e.getOwner()}function d(){return Error("react-stack-top-frame")}function N(e){if(V.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function E(e,n){function c(){r||(r=!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)",n))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function x(){var e=a(this.type);return g[e]||(g[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?e:null}function j(e,n,c,i,U,B){var l=c.ref;return e={$$typeof:O,type:e,key:n,props:c,_owner:i},(l!==void 0?l:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:x}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),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:U}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function m(e,n,c,i,U,B){var l=n.children;if(l!==void 0)if(i)if(H(l)){for(i=0;i<l.length;i++)A(l[i]);Object.freeze&&Object.freeze(l)}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 A(l);if(V.call(n,"key")){l=a(e);var Y=Object.keys(n).filter(function(oe){return oe!=="key"});i=0<Y.length?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}",W[l+i]||(Y=0<Y.length?"{"+Y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
- let props = %s;
19
- <%s {...props} />
20
- React keys must be passed directly to JSX without using spread:
21
- let props = %s;
22
- <%s key={someKey} {...props} />`,i,l,Y,l),W[l+i]=!0)}if(l=null,c!==void 0&&(R(c),l=""+c),N(n)&&(R(n.key),l=""+n.key),"key"in n){c={};for(var K in n)K!=="key"&&(c[K]=n[K])}else c=n;return l&&E(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),j(e,l,c,u(),U,B)}function A(e){_(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(e._payload.status==="fulfilled"?_(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function _(e){return typeof e=="object"&&e!==null&&e.$$typeof===O}var h=y,O=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),X=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),w=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,H=Array.isArray,t=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(e){return e()}};var r,g={},$=h.react_stack_bottom_frame.bind(h,d)(),z=t(v(d)),W={};L.Fragment=P,L.jsx=function(e,n,c){var i=1e4>w.recentlyCreatedOwnerStacks++;return m(e,n,c,!1,i?Error("react-stack-top-frame"):$,i?t(v(e)):z)},L.jsxs=function(e,n,c){var i=1e4>w.recentlyCreatedOwnerStacks++;return m(e,n,c,!0,i?Error("react-stack-top-frame"):$,i?t(v(e)):z)}})()),L}var re;function le(){return re||(re=1,process.env.NODE_ENV==="production"?q.exports=ue():q.exports=ie()),q.exports}var ae=le();const fe=/^-?\d*[.,]?\d*$/,ne=(a,f)=>fe.test(a)?a:f,Z=a=>{const f=a.toString().split(".");return f.length>1?f[1].length:0},se=a=>a.replace(",","."),Q=a=>parseFloat(se(a)),J=a=>Number.isFinite(a)?String(a):"",de=a=>J(Q(a)),G=(a,f)=>{var v;if(a.value===f)return;const R=(v=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value"))==null?void 0:v.set;R?R.call(a,f):a.value=f,a.dispatchEvent(new Event("input",{bubbles:!0})),R&&(a.value=a.value)},ce=y.forwardRef(({defaultValue:a,mask:f=ne,onBlur:R,onChange:v,onFocus:u,onKeyDown:d,step:N=1,value:E,...x},j)=>{const m=y.useRef(null);y.useImperativeHandle(j,()=>m.current);const[A,_]=y.useState(E??(a!=null?String(a):"")),h=y.useRef(A);h.current=A;const O=y.useRef(!1),F=f===ne;y.useEffect(()=>{E===void 0||O.current||_(E)},[E]);const P=o=>{const s=o.target,p=s.value,b=f(p,h.current);if(b!==p){const T=s.selectionStart??p.length,k=Math.min(b.length,Math.max(0,T-(p.length-b.length)));s.value=b,s.setSelectionRange(k,k);return}if(h.current=b,_(b),!v)return;const S=se(b);if(S!==b){const T=s.selectionStart??b.length,k=s.selectionEnd??b.length;s.value=S,v(o),s.value=b,s.setSelectionRange(T,k)}else v(o)},I=o=>{const s=m.current;if(!s)return;const p=Q(h.current),b=Number(N)||1,S=Z(b);let T=(Number.isFinite(p)?p:0)+o*b;const k=x.min!==void 0?Number(x.min):NaN,w=x.max!==void 0?Number(x.max):NaN;Number.isNaN(k)||(T=Math.max(T,k)),Number.isNaN(w)||(T=Math.min(T,w)),G(s,T.toFixed(S))},C=o=>{d==null||d(o),!o.defaultPrevented&&(o.key==="ArrowUp"?(o.preventDefault(),I(1)):o.key==="ArrowDown"&&(o.preventDefault(),I(-1)))},M=o=>{O.current=!0,u==null||u(o)},X=o=>{O.current=!1;const s=h.current,p=F?de(s):s;p!==s?G(o.target,p):E!==void 0&&E!==s&&_(E),R==null||R(o)};return ae.jsx("input",{inputMode:"decimal",...x,type:"text",ref:m,value:A,onBlur:X,onChange:P,onFocus:M,onKeyDown:C})}),me=["metaKey","ctrlKey","altKey","shiftKey"],be=3,Ee=y.forwardRef(({value:a,modifiers:f={altKey:1,ctrlKey:1,metaKey:1,shiftKey:.1},style:R={},onBlur:v,onFocus:u,onKeyDown:d,onPointerCancel:N,onPointerDown:E,onPointerMove:x,onPointerUp:j,...m},A)=>{const _=y.useRef(null),[h,O]=y.useState(!1),[F,P]=y.useState(!1),I=m.step?+m.step:1,C=m.min!==void 0?+m.min:void 0,M=m.max!==void 0?+m.max:void 0,X={cursor:h&&!F?void 0:"ew-resize",touchAction:"none",...R};y.useEffect(()=>()=>{const t=_.current;t!=null&&t.scrubbing&&(document.body.style.cursor=t.previousBodyCursor)},[]);const o=t=>{for(const r of me)if(t[r])return f[r]??1;return 1},s=(t,r,g)=>{if(_.current=null,!!r.scrubbing){P(!1),document.body.style.cursor=r.previousBodyCursor;try{t.releasePointerCapture(r.pointerId)}catch{}g&&G(t,J(r.startValue)),t.blur()}},p=t=>{if(E==null||E(t),t.defaultPrevented||t.button!==0||m.disabled||m.readOnly)return;const r=t.currentTarget;if(document.activeElement===r)return;let g=Q(r.value);Number.isFinite(g)||(g=Number(m.defaultValue??C??0)||0),_.current={pointerId:t.pointerId,startX:t.clientX,lastX:t.clientX,startValue:g,accumulated:g,scrubbing:!1,previousBodyCursor:""}},b=t=>{x==null||x(t);const r=_.current;if(!r||r.pointerId!==t.pointerId)return;const g=t.currentTarget;if(t.buttons===0){_.current=null;return}if(!r.scrubbing){if(Math.abs(t.clientX-r.startX)<be)return;r.scrubbing=!0,r.lastX=t.clientX,P(!0),r.previousBodyCursor=document.body.style.cursor,document.body.style.cursor="ew-resize";try{g.setPointerCapture(t.pointerId)}catch{}}const $=o(t),z=I*$,W=Z(I)+Z($);r.accumulated+=(t.clientX-r.lastX)*z,r.lastX=t.clientX,C!==void 0&&(r.accumulated=Math.max(r.accumulated,C)),M!==void 0&&(r.accumulated=Math.min(r.accumulated,M));const e=+r.accumulated.toFixed(W);Number.isNaN(e)||G(g,J(e))},S=t=>{const r=_.current;!r||r.pointerId!==t.pointerId||s(t.currentTarget,r,!1)},T=t=>{j==null||j(t),S(t)},k=t=>{N==null||N(t),S(t)},w=t=>{const r=_.current;if(t.key==="Escape"&&(r!=null&&r.scrubbing)){t.preventDefault(),s(t.currentTarget,r,!0);return}d==null||d(t)},V=t=>{O(!0),u==null||u(t)},H=t=>{O(!1),v==null||v(t)};return ae.jsx(ce,{...m,ref:A,defaultValue:m.defaultValue??0,style:X,value:a!==void 0?J(a):void 0,onBlur:H,onFocus:V,onKeyDown:w,onPointerCancel:k,onPointerDown:p,onPointerMove:b,onPointerUp:T})});exports.InteractiveInput=Ee;exports.MaskedInput=ce;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),l=require("react"),Y=/^-?\d*[.,]?\d*$/,_=(r,i)=>Y.test(r)?r:i,z=r=>{const i=r.toString().split(".");return i.length>1?i[1].length:0},D=r=>r.replace(",","."),F=r=>parseFloat(D(r)),A=r=>Number.isFinite(r)?String(r):"",$=r=>A(F(r)),j=(r,i)=>{var m;if(r.value===i)return;const b=(m=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value"))==null?void 0:m.set;b?b.call(r,i):r.value=i,r.dispatchEvent(new Event("input",{bubbles:!0})),b&&(r.value=r.value)},P=l.forwardRef(({defaultValue:r,mask:i=_,onBlur:b,onChange:m,onFocus:N,onKeyDown:v,step:S=1,value:o,...h},E)=>{const u=l.useRef(null);l.useImperativeHandle(E,()=>u.current);const[M,d]=l.useState(o??(r!=null?String(r):"")),x=l.useRef(M);x.current=M;const R=l.useRef(!1),C=i===_;l.useEffect(()=>{o===void 0||R.current||d(o)},[o]);const X=c=>{const n=c.target,a=n.value,s=i(a,x.current);if(s!==a){const f=n.selectionStart??a.length,g=Math.min(s.length,Math.max(0,f-(a.length-s.length)));n.value=s,n.setSelectionRange(g,g);return}if(x.current=s,d(s),!m)return;const I=D(s);if(I!==s){const f=n.selectionStart??s.length,g=n.selectionEnd??s.length;n.value=I,m(c),n.value=s,n.setSelectionRange(f,g)}else m(c)},p=c=>{const n=u.current;if(!n)return;const a=F(x.current),s=Number(S)||1,I=z(s);let f=(Number.isFinite(a)?a:0)+c*s;const g=h.min!==void 0?Number(h.min):NaN,O=h.max!==void 0?Number(h.max):NaN;Number.isNaN(g)||(f=Math.max(f,g)),Number.isNaN(O)||(f=Math.min(f,O)),j(n,f.toFixed(I))},T=c=>{v==null||v(c),!c.defaultPrevented&&(c.key==="ArrowUp"?(c.preventDefault(),p(1)):c.key==="ArrowDown"&&(c.preventDefault(),p(-1)))},k=c=>{R.current=!0,N==null||N(c)},V=c=>{R.current=!1;const n=x.current,a=C?$(n):n;a!==n?j(c.target,a):o!==void 0&&o!==n&&d(o),b==null||b(c)};return w.jsx("input",{inputMode:"decimal",...h,type:"text",ref:u,value:M,onBlur:V,onChange:X,onFocus:k,onKeyDown:T})}),J=["metaKey","ctrlKey","altKey","shiftKey"],Q=3,U=l.forwardRef(({value:r,modifiers:i={altKey:1,ctrlKey:1,metaKey:1,shiftKey:.1},style:b={},onBlur:m,onFocus:N,onKeyDown:v,onPointerCancel:S,onPointerDown:o,onPointerMove:h,onPointerUp:E,...u},M)=>{const d=l.useRef(null),[x,R]=l.useState(!1),[C,X]=l.useState(!1),p=u.step?+u.step:1,T=u.min!==void 0?+u.min:void 0,k=u.max!==void 0?+u.max:void 0,V={cursor:x&&!C?void 0:"ew-resize",touchAction:"none",...b};l.useEffect(()=>()=>{const t=d.current;t!=null&&t.scrubbing&&(document.body.style.cursor=t.previousBodyCursor)},[]);const c=t=>{for(const e of J)if(t[e])return i[e]??1;return 1},n=(t,e,y)=>{if(d.current=null,!!e.scrubbing){X(!1),document.body.style.cursor=e.previousBodyCursor;try{t.releasePointerCapture(e.pointerId)}catch{}y&&j(t,A(e.startValue)),t.blur()}},a=t=>{if(o==null||o(t),t.defaultPrevented||t.button!==0||u.disabled||u.readOnly)return;const e=t.currentTarget;if(document.activeElement===e)return;let y=F(e.value);Number.isFinite(y)||(y=Number(u.defaultValue??T??0)||0),d.current={pointerId:t.pointerId,startX:t.clientX,lastX:t.clientX,startValue:y,accumulated:y,scrubbing:!1,previousBodyCursor:""}},s=t=>{h==null||h(t);const e=d.current;if(!e||e.pointerId!==t.pointerId)return;const y=t.currentTarget;if(t.buttons===0){d.current=null;return}if(!e.scrubbing){if(Math.abs(t.clientX-e.startX)<Q)return;e.scrubbing=!0,e.lastX=t.clientX,X(!0),e.previousBodyCursor=document.body.style.cursor,document.body.style.cursor="ew-resize";try{y.setPointerCapture(t.pointerId)}catch{}}const H=c(t),L=p*H,G=z(p)+z(H);e.accumulated+=(t.clientX-e.lastX)*L,e.lastX=t.clientX,T!==void 0&&(e.accumulated=Math.max(e.accumulated,T)),k!==void 0&&(e.accumulated=Math.min(e.accumulated,k));const K=+e.accumulated.toFixed(G);Number.isNaN(K)||j(y,A(K))},I=t=>{const e=d.current;!e||e.pointerId!==t.pointerId||n(t.currentTarget,e,!1)},f=t=>{E==null||E(t),I(t)},g=t=>{S==null||S(t),I(t)},O=t=>{const e=d.current;if(t.key==="Escape"&&(e!=null&&e.scrubbing)){t.preventDefault(),n(t.currentTarget,e,!0);return}v==null||v(t)},q=t=>{R(!0),N==null||N(t)},B=t=>{R(!1),m==null||m(t)};return w.jsx(P,{...u,ref:M,defaultValue:u.defaultValue??0,style:V,value:r!==void 0?A(r):void 0,onBlur:B,onFocus:q,onKeyDown:O,onPointerCancel:g,onPointerDown:a,onPointerMove:s,onPointerUp:f})});exports.InteractiveInput=U;exports.MaskedInput=P;
@@ -1,421 +1,144 @@
1
- import le, { forwardRef as se, useRef as q, useImperativeHandle as fe, useState as Z, useEffect as oe } from "react";
2
- var U = { exports: {} }, $ = {};
3
- /**
4
- * @license React
5
- * react-jsx-runtime.production.js
6
- *
7
- * Copyright (c) Meta Platforms, Inc. and affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
- var te;
13
- function de() {
14
- if (te) return $;
15
- te = 1;
16
- var a = Symbol.for("react.transitional.element"), f = Symbol.for("react.fragment");
17
- function R(v, u, d) {
18
- var g = null;
19
- if (d !== void 0 && (g = "" + d), u.key !== void 0 && (g = "" + u.key), "key" in u) {
20
- d = {};
21
- for (var E in u)
22
- E !== "key" && (d[E] = u[E]);
23
- } else d = u;
24
- return u = d.ref, {
25
- $$typeof: a,
26
- type: v,
27
- key: g,
28
- ref: u !== void 0 ? u : null,
29
- props: d
30
- };
31
- }
32
- return $.Fragment = f, $.jsx = R, $.jsxs = R, $;
33
- }
34
- var D = {};
35
- /**
36
- * @license React
37
- * react-jsx-runtime.development.js
38
- *
39
- * Copyright (c) Meta Platforms, Inc. and affiliates.
40
- *
41
- * This source code is licensed under the MIT license found in the
42
- * LICENSE file in the root directory of this source tree.
43
- */
44
- var re;
45
- function me() {
46
- return re || (re = 1, process.env.NODE_ENV !== "production" && (function() {
47
- function a(e) {
48
- if (e == null) return null;
49
- if (typeof e == "function")
50
- return e.$$typeof === k ? null : e.displayName || e.name || null;
51
- if (typeof e == "string") return e;
52
- switch (e) {
53
- case A:
54
- return "Fragment";
55
- case I:
56
- return "Profiler";
57
- case j:
58
- return "StrictMode";
59
- case s:
60
- return "Suspense";
61
- case p:
62
- return "SuspenseList";
63
- case T:
64
- return "Activity";
65
- }
66
- if (typeof e == "object")
67
- switch (typeof e.tag == "number" && console.error(
68
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
- ), e.$$typeof) {
70
- case Y:
71
- return "Portal";
72
- case F:
73
- return e.displayName || "Context";
74
- case C:
75
- return (e._context.displayName || "Context") + ".Consumer";
76
- case c:
77
- var n = e.render;
78
- return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
- case b:
80
- return n = e.displayName || null, n !== null ? n : a(e.type) || "Memo";
81
- case x:
82
- n = e._payload, e = e._init;
83
- try {
84
- return a(e(n));
85
- } catch {
86
- }
87
- }
88
- return null;
89
- }
90
- function f(e) {
91
- return "" + e;
92
- }
93
- function R(e) {
94
- try {
95
- f(e);
96
- var n = !1;
97
- } catch {
98
- n = !0;
99
- }
100
- if (n) {
101
- n = console;
102
- var o = n.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
- return o.call(
104
- n,
105
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- i
107
- ), f(e);
108
- }
109
- }
110
- function v(e) {
111
- if (e === A) return "<>";
112
- if (typeof e == "object" && e !== null && e.$$typeof === x)
113
- return "<...>";
114
- try {
115
- var n = a(e);
116
- return n ? "<" + n + ">" : "<...>";
117
- } catch {
118
- return "<...>";
119
- }
120
- }
121
- function u() {
122
- var e = P.A;
123
- return e === null ? null : e.getOwner();
124
- }
125
- function d() {
126
- return Error("react-stack-top-frame");
127
- }
128
- function g(e) {
129
- if (L.call(e, "key")) {
130
- var n = Object.getOwnPropertyDescriptor(e, "key").get;
131
- if (n && n.isReactWarning) return !1;
132
- }
133
- return e.key !== void 0;
134
- }
135
- function E(e, n) {
136
- function o() {
137
- r || (r = !0, console.error(
138
- "%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)",
139
- n
140
- ));
141
- }
142
- o.isReactWarning = !0, Object.defineProperty(e, "key", {
143
- get: o,
144
- configurable: !0
145
- });
146
- }
147
- function N() {
148
- var e = a(this.type);
149
- return y[e] || (y[e] = !0, console.error(
150
- "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."
151
- )), e = this.props.ref, e !== void 0 ? e : null;
152
- }
153
- function w(e, n, o, i, W, B) {
154
- var l = o.ref;
155
- return e = {
156
- $$typeof: S,
157
- type: e,
158
- key: n,
159
- props: o,
160
- _owner: i
161
- }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
162
- enumerable: !1,
163
- get: N
164
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
165
- configurable: !1,
166
- enumerable: !1,
167
- writable: !0,
168
- value: 0
169
- }), Object.defineProperty(e, "_debugInfo", {
170
- configurable: !1,
171
- enumerable: !1,
172
- writable: !0,
173
- value: null
174
- }), Object.defineProperty(e, "_debugStack", {
175
- configurable: !1,
176
- enumerable: !1,
177
- writable: !0,
178
- value: W
179
- }), Object.defineProperty(e, "_debugTask", {
180
- configurable: !1,
181
- enumerable: !1,
182
- writable: !0,
183
- value: B
184
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
185
- }
186
- function m(e, n, o, i, W, B) {
187
- var l = n.children;
188
- if (l !== void 0)
189
- if (i)
190
- if (H(l)) {
191
- for (i = 0; i < l.length; i++)
192
- O(l[i]);
193
- Object.freeze && Object.freeze(l);
194
- } else
195
- console.error(
196
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
- );
198
- else O(l);
199
- if (L.call(n, "key")) {
200
- l = a(e);
201
- var M = Object.keys(n).filter(function(ie) {
202
- return ie !== "key";
203
- });
204
- i = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", z[l + i] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
205
- `A props object containing a "key" prop is being spread into JSX:
206
- let props = %s;
207
- <%s {...props} />
208
- React keys must be passed directly to JSX without using spread:
209
- let props = %s;
210
- <%s key={someKey} {...props} />`,
211
- i,
212
- l,
213
- M,
214
- l
215
- ), z[l + i] = !0);
216
- }
217
- if (l = null, o !== void 0 && (R(o), l = "" + o), g(n) && (R(n.key), l = "" + n.key), "key" in n) {
218
- o = {};
219
- for (var K in n)
220
- K !== "key" && (o[K] = n[K]);
221
- } else o = n;
222
- return l && E(
223
- o,
224
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
225
- ), w(
226
- e,
227
- l,
228
- o,
229
- u(),
230
- W,
231
- B
232
- );
233
- }
234
- function O(e) {
235
- _(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === x && (e._payload.status === "fulfilled" ? _(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
236
- }
237
- function _(e) {
238
- return typeof e == "object" && e !== null && e.$$typeof === S;
239
- }
240
- var h = le, S = Symbol.for("react.transitional.element"), Y = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), j = Symbol.for("react.strict_mode"), I = Symbol.for("react.profiler"), C = Symbol.for("react.consumer"), F = Symbol.for("react.context"), c = Symbol.for("react.forward_ref"), s = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), b = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), T = Symbol.for("react.activity"), k = Symbol.for("react.client.reference"), P = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, H = Array.isArray, t = console.createTask ? console.createTask : function() {
241
- return null;
242
- };
243
- h = {
244
- react_stack_bottom_frame: function(e) {
245
- return e();
246
- }
247
- };
248
- var r, y = {}, X = h.react_stack_bottom_frame.bind(
249
- h,
250
- d
251
- )(), V = t(v(d)), z = {};
252
- D.Fragment = A, D.jsx = function(e, n, o) {
253
- var i = 1e4 > P.recentlyCreatedOwnerStacks++;
254
- return m(
255
- e,
256
- n,
257
- o,
258
- !1,
259
- i ? Error("react-stack-top-frame") : X,
260
- i ? t(v(e)) : V
261
- );
262
- }, D.jsxs = function(e, n, o) {
263
- var i = 1e4 > P.recentlyCreatedOwnerStacks++;
264
- return m(
265
- e,
266
- n,
267
- o,
268
- !0,
269
- i ? Error("react-stack-top-frame") : X,
270
- i ? t(v(e)) : V
271
- );
272
- };
273
- })()), D;
274
- }
275
- var ne;
276
- function be() {
277
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? U.exports = de() : U.exports = me()), U.exports;
278
- }
279
- var ce = be();
280
- const Ee = /^-?\d*[.,]?\d*$/, ae = (a, f) => Ee.test(a) ? a : f, Q = (a) => {
281
- const f = a.toString().split(".");
282
- return f.length > 1 ? f[1].length : 0;
283
- }, ue = (a) => a.replace(",", "."), ee = (a) => parseFloat(ue(a)), J = (a) => Number.isFinite(a) ? String(a) : "", ve = (a) => J(ee(a)), G = (a, f) => {
284
- var v;
285
- if (a.value === f) return;
286
- const R = (v = Object.getOwnPropertyDescriptor(
1
+ import { jsx as B } from "react/jsx-runtime";
2
+ import { forwardRef as j, useRef as k, useImperativeHandle as J, useState as K, useEffect as L } from "react";
3
+ const Q = /^-?\d*[.,]?\d*$/, w = (r, u) => Q.test(r) ? r : u, V = (r) => {
4
+ const u = r.toString().split(".");
5
+ return u.length > 1 ? u[1].length : 0;
6
+ }, P = (r) => r.replace(",", "."), z = (r) => parseFloat(P(r)), A = (r) => Number.isFinite(r) ? String(r) : "", U = (r) => A(z(r)), O = (r, u) => {
7
+ var f;
8
+ if (r.value === u) return;
9
+ const m = (f = Object.getOwnPropertyDescriptor(
287
10
  HTMLInputElement.prototype,
288
11
  "value"
289
- )) == null ? void 0 : v.set;
290
- R ? R.call(a, f) : a.value = f, a.dispatchEvent(new Event("input", { bubbles: !0 })), R && (a.value = a.value);
291
- }, Re = se(
12
+ )) == null ? void 0 : f.set;
13
+ m ? m.call(r, u) : r.value = u, r.dispatchEvent(new Event("input", { bubbles: !0 })), m && (r.value = r.value);
14
+ }, W = j(
292
15
  ({
293
- defaultValue: a,
294
- mask: f = ae,
295
- onBlur: R,
296
- onChange: v,
297
- onFocus: u,
298
- onKeyDown: d,
299
- step: g = 1,
300
- value: E,
301
- ...N
302
- }, w) => {
303
- const m = q(null);
304
- fe(
305
- w,
306
- () => m.current
16
+ defaultValue: r,
17
+ mask: u = w,
18
+ onBlur: m,
19
+ onChange: f,
20
+ onFocus: g,
21
+ onKeyDown: N,
22
+ step: R = 1,
23
+ value: l,
24
+ ...b
25
+ }, E) => {
26
+ const i = k(null);
27
+ J(
28
+ E,
29
+ () => i.current
307
30
  );
308
- const [O, _] = Z(
309
- E ?? (a != null ? String(a) : "")
310
- ), h = q(O);
311
- h.current = O;
312
- const S = q(!1), Y = f === ae;
313
- oe(() => {
314
- E === void 0 || S.current || _(E);
315
- }, [E]);
316
- const A = (c) => {
317
- const s = c.target, p = s.value, b = f(p, h.current);
318
- if (b !== p) {
319
- const T = s.selectionStart ?? p.length, k = Math.min(
320
- b.length,
321
- Math.max(0, T - (p.length - b.length))
31
+ const [p, o] = K(
32
+ l ?? (r != null ? String(r) : "")
33
+ ), v = k(p);
34
+ v.current = p;
35
+ const I = k(!1), C = u === w;
36
+ L(() => {
37
+ l === void 0 || I.current || o(l);
38
+ }, [l]);
39
+ const X = (c) => {
40
+ const n = c.target, a = n.value, s = u(a, v.current);
41
+ if (s !== a) {
42
+ const d = n.selectionStart ?? a.length, h = Math.min(
43
+ s.length,
44
+ Math.max(0, d - (a.length - s.length))
322
45
  );
323
- s.value = b, s.setSelectionRange(k, k);
46
+ n.value = s, n.setSelectionRange(h, h);
324
47
  return;
325
48
  }
326
- if (h.current = b, _(b), !v) return;
327
- const x = ue(b);
328
- if (x !== b) {
329
- const T = s.selectionStart ?? b.length, k = s.selectionEnd ?? b.length;
330
- s.value = x, v(c), s.value = b, s.setSelectionRange(T, k);
49
+ if (v.current = s, o(s), !f) return;
50
+ const x = P(s);
51
+ if (x !== s) {
52
+ const d = n.selectionStart ?? s.length, h = n.selectionEnd ?? s.length;
53
+ n.value = x, f(c), n.value = s, n.setSelectionRange(d, h);
331
54
  } else
332
- v(c);
333
- }, j = (c) => {
334
- const s = m.current;
335
- if (!s) return;
336
- const p = ee(h.current), b = Number(g) || 1, x = Q(b);
337
- let T = (Number.isFinite(p) ? p : 0) + c * b;
338
- const k = N.min !== void 0 ? Number(N.min) : NaN, P = N.max !== void 0 ? Number(N.max) : NaN;
339
- Number.isNaN(k) || (T = Math.max(T, k)), Number.isNaN(P) || (T = Math.min(T, P)), G(s, T.toFixed(x));
340
- }, I = (c) => {
341
- d == null || d(c), !c.defaultPrevented && (c.key === "ArrowUp" ? (c.preventDefault(), j(1)) : c.key === "ArrowDown" && (c.preventDefault(), j(-1)));
342
- }, C = (c) => {
343
- S.current = !0, u == null || u(c);
344
- }, F = (c) => {
345
- S.current = !1;
346
- const s = h.current, p = Y ? ve(s) : s;
347
- p !== s ? G(c.target, p) : E !== void 0 && E !== s && _(E), R == null || R(c);
55
+ f(c);
56
+ }, M = (c) => {
57
+ const n = i.current;
58
+ if (!n) return;
59
+ const a = z(v.current), s = Number(R) || 1, x = V(s);
60
+ let d = (Number.isFinite(a) ? a : 0) + c * s;
61
+ const h = b.min !== void 0 ? Number(b.min) : NaN, T = b.max !== void 0 ? Number(b.max) : NaN;
62
+ Number.isNaN(h) || (d = Math.max(d, h)), Number.isNaN(T) || (d = Math.min(d, T)), O(n, d.toFixed(x));
348
63
  };
349
- return /* @__PURE__ */ ce.jsx(
64
+ return /* @__PURE__ */ B(
350
65
  "input",
351
66
  {
352
67
  inputMode: "decimal",
353
- ...N,
68
+ ...b,
354
69
  type: "text",
355
- ref: m,
356
- value: O,
357
- onBlur: F,
358
- onChange: A,
359
- onFocus: C,
360
- onKeyDown: I
70
+ ref: i,
71
+ value: p,
72
+ onBlur: (c) => {
73
+ I.current = !1;
74
+ const n = v.current, a = C ? U(n) : n;
75
+ a !== n ? O(c.target, a) : l !== void 0 && l !== n && o(l), m == null || m(c);
76
+ },
77
+ onChange: X,
78
+ onFocus: (c) => {
79
+ I.current = !0, g == null || g(c);
80
+ },
81
+ onKeyDown: (c) => {
82
+ N == null || N(c), !c.defaultPrevented && (c.key === "ArrowUp" ? (c.preventDefault(), M(1)) : c.key === "ArrowDown" && (c.preventDefault(), M(-1)));
83
+ }
361
84
  }
362
85
  );
363
86
  }
364
- ), _e = [
87
+ ), Z = [
365
88
  "metaKey",
366
89
  "ctrlKey",
367
90
  "altKey",
368
91
  "shiftKey"
369
- ], pe = 3, he = se(
92
+ ], tt = 3, nt = j(
370
93
  ({
371
- value: a,
372
- modifiers: f = {
94
+ value: r,
95
+ modifiers: u = {
373
96
  altKey: 1,
374
97
  ctrlKey: 1,
375
98
  metaKey: 1,
376
99
  shiftKey: 0.1
377
100
  },
378
- style: R = {},
379
- onBlur: v,
380
- onFocus: u,
381
- onKeyDown: d,
382
- onPointerCancel: g,
383
- onPointerDown: E,
384
- onPointerMove: N,
385
- onPointerUp: w,
386
- ...m
387
- }, O) => {
388
- const _ = q(null), [h, S] = Z(!1), [Y, A] = Z(!1), j = m.step ? +m.step : 1, I = m.min !== void 0 ? +m.min : void 0, C = m.max !== void 0 ? +m.max : void 0, F = {
389
- cursor: h && !Y ? void 0 : "ew-resize",
101
+ style: m = {},
102
+ onBlur: f,
103
+ onFocus: g,
104
+ onKeyDown: N,
105
+ onPointerCancel: R,
106
+ onPointerDown: l,
107
+ onPointerMove: b,
108
+ onPointerUp: E,
109
+ ...i
110
+ }, p) => {
111
+ const o = k(null), [v, I] = K(!1), [C, X] = K(!1), M = i.step ? +i.step : 1, S = i.min !== void 0 ? +i.min : void 0, F = i.max !== void 0 ? +i.max : void 0, D = {
112
+ cursor: v && !C ? void 0 : "ew-resize",
390
113
  touchAction: "none",
391
- ...R
114
+ ...m
392
115
  };
393
- oe(
116
+ L(
394
117
  () => () => {
395
- const t = _.current;
118
+ const t = o.current;
396
119
  t != null && t.scrubbing && (document.body.style.cursor = t.previousBodyCursor);
397
120
  },
398
121
  []
399
122
  );
400
123
  const c = (t) => {
401
- for (const r of _e)
402
- if (t[r]) return f[r] ?? 1;
124
+ for (const e of Z)
125
+ if (t[e]) return u[e] ?? 1;
403
126
  return 1;
404
- }, s = (t, r, y) => {
405
- if (_.current = null, !!r.scrubbing) {
406
- A(!1), document.body.style.cursor = r.previousBodyCursor;
127
+ }, n = (t, e, y) => {
128
+ if (o.current = null, !!e.scrubbing) {
129
+ X(!1), document.body.style.cursor = e.previousBodyCursor;
407
130
  try {
408
- t.releasePointerCapture(r.pointerId);
131
+ t.releasePointerCapture(e.pointerId);
409
132
  } catch {
410
133
  }
411
- y && G(t, J(r.startValue)), t.blur();
134
+ y && O(t, A(e.startValue)), t.blur();
412
135
  }
413
- }, p = (t) => {
414
- if (E == null || E(t), t.defaultPrevented || t.button !== 0 || m.disabled || m.readOnly) return;
415
- const r = t.currentTarget;
416
- if (document.activeElement === r) return;
417
- let y = ee(r.value);
418
- Number.isFinite(y) || (y = Number(m.defaultValue ?? I ?? 0) || 0), _.current = {
136
+ }, a = (t) => {
137
+ if (l == null || l(t), t.defaultPrevented || t.button !== 0 || i.disabled || i.readOnly) return;
138
+ const e = t.currentTarget;
139
+ if (document.activeElement === e) return;
140
+ let y = z(e.value);
141
+ Number.isFinite(y) || (y = Number(i.defaultValue ?? S ?? 0) || 0), o.current = {
419
142
  pointerId: t.pointerId,
420
143
  startX: t.clientX,
421
144
  lastX: t.clientX,
@@ -424,66 +147,66 @@ const Ee = /^-?\d*[.,]?\d*$/, ae = (a, f) => Ee.test(a) ? a : f, Q = (a) => {
424
147
  scrubbing: !1,
425
148
  previousBodyCursor: ""
426
149
  };
427
- }, b = (t) => {
428
- N == null || N(t);
429
- const r = _.current;
430
- if (!r || r.pointerId !== t.pointerId) return;
150
+ }, s = (t) => {
151
+ b == null || b(t);
152
+ const e = o.current;
153
+ if (!e || e.pointerId !== t.pointerId) return;
431
154
  const y = t.currentTarget;
432
155
  if (t.buttons === 0) {
433
- _.current = null;
156
+ o.current = null;
434
157
  return;
435
158
  }
436
- if (!r.scrubbing) {
437
- if (Math.abs(t.clientX - r.startX) < pe) return;
438
- r.scrubbing = !0, r.lastX = t.clientX, A(!0), r.previousBodyCursor = document.body.style.cursor, document.body.style.cursor = "ew-resize";
159
+ if (!e.scrubbing) {
160
+ if (Math.abs(t.clientX - e.startX) < tt) return;
161
+ e.scrubbing = !0, e.lastX = t.clientX, X(!0), e.previousBodyCursor = document.body.style.cursor, document.body.style.cursor = "ew-resize";
439
162
  try {
440
163
  y.setPointerCapture(t.pointerId);
441
164
  } catch {
442
165
  }
443
166
  }
444
- const X = c(t), V = j * X, z = Q(j) + Q(X);
445
- r.accumulated += (t.clientX - r.lastX) * V, r.lastX = t.clientX, I !== void 0 && (r.accumulated = Math.max(r.accumulated, I)), C !== void 0 && (r.accumulated = Math.min(r.accumulated, C));
446
- const e = +r.accumulated.toFixed(z);
447
- Number.isNaN(e) || G(y, J(e));
167
+ const H = c(t), $ = M * H, q = V(M) + V(H);
168
+ e.accumulated += (t.clientX - e.lastX) * $, e.lastX = t.clientX, S !== void 0 && (e.accumulated = Math.max(e.accumulated, S)), F !== void 0 && (e.accumulated = Math.min(e.accumulated, F));
169
+ const _ = +e.accumulated.toFixed(q);
170
+ Number.isNaN(_) || O(y, A(_));
448
171
  }, x = (t) => {
449
- const r = _.current;
450
- !r || r.pointerId !== t.pointerId || s(t.currentTarget, r, !1);
172
+ const e = o.current;
173
+ !e || e.pointerId !== t.pointerId || n(t.currentTarget, e, !1);
174
+ }, d = (t) => {
175
+ E == null || E(t), x(t);
176
+ }, h = (t) => {
177
+ R == null || R(t), x(t);
451
178
  }, T = (t) => {
452
- w == null || w(t), x(t);
453
- }, k = (t) => {
454
- g == null || g(t), x(t);
455
- }, P = (t) => {
456
- const r = _.current;
457
- if (t.key === "Escape" && (r != null && r.scrubbing)) {
458
- t.preventDefault(), s(t.currentTarget, r, !0);
179
+ const e = o.current;
180
+ if (t.key === "Escape" && (e != null && e.scrubbing)) {
181
+ t.preventDefault(), n(t.currentTarget, e, !0);
459
182
  return;
460
183
  }
461
- d == null || d(t);
462
- }, L = (t) => {
463
- S(!0), u == null || u(t);
464
- }, H = (t) => {
465
- S(!1), v == null || v(t);
184
+ N == null || N(t);
185
+ }, G = (t) => {
186
+ I(!0), g == null || g(t);
187
+ }, Y = (t) => {
188
+ I(!1), f == null || f(t);
466
189
  };
467
- return /* @__PURE__ */ ce.jsx(
468
- Re,
190
+ return /* @__PURE__ */ B(
191
+ W,
469
192
  {
470
- ...m,
471
- ref: O,
472
- defaultValue: m.defaultValue ?? 0,
473
- style: F,
474
- value: a !== void 0 ? J(a) : void 0,
475
- onBlur: H,
476
- onFocus: L,
477
- onKeyDown: P,
478
- onPointerCancel: k,
479
- onPointerDown: p,
480
- onPointerMove: b,
481
- onPointerUp: T
193
+ ...i,
194
+ ref: p,
195
+ defaultValue: i.defaultValue ?? 0,
196
+ style: D,
197
+ value: r !== void 0 ? A(r) : void 0,
198
+ onBlur: Y,
199
+ onFocus: G,
200
+ onKeyDown: T,
201
+ onPointerCancel: h,
202
+ onPointerDown: a,
203
+ onPointerMove: s,
204
+ onPointerUp: d
482
205
  }
483
206
  );
484
207
  }
485
208
  );
486
209
  export {
487
- he as InteractiveInput,
488
- Re as MaskedInput
210
+ nt as InteractiveInput,
211
+ W as MaskedInput
489
212
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@designbyadrian/react-interactive-input",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Adjust values in numeric input boxes by clicking and dragging horizontally, just like in Blender and similar 3D applications.",
5
5
  "keywords": [
6
6
  "react",