@designbyadrian/react-interactive-input 2.0.3 → 3.1.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 +39 -4
- package/dist/react-interactive-input.cjs.js +7 -15
- package/dist/react-interactive-input.es.js +408 -678
- package/dist/types/InteractiveInput.d.ts +10 -3
- package/dist/types/MaskedInput.d.ts +14 -2
- package/dist/types/masks.d.ts +9 -2
- package/dist/types/utils.d.ts +26 -2
- package/package.json +30 -20
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<center>
|
|
2
|
-
<img src="assets/interactive-input-
|
|
2
|
+
<img src="assets/interactive-input-banner.svg" alt="" width="100%" aria-hidden="true" />
|
|
3
3
|
<h1>React Interactive Input</h1>
|
|
4
4
|
</center>
|
|
5
5
|
|
|
@@ -50,11 +50,26 @@ function MyComponent() {
|
|
|
50
50
|
|
|
51
51
|
The `InteractiveInput` component accepts all properties of the HTMLInputElement element, especially the following attributes:
|
|
52
52
|
|
|
53
|
-
- `value`: The
|
|
54
|
-
- `onChange`: A callback function that receives
|
|
53
|
+
- `value`: The controlled numeric value of the input field.
|
|
54
|
+
- `onChange`: A callback function that receives a change event when the value changes.
|
|
55
55
|
- `step`: The amount to increment or decrement the value when scrubbing.
|
|
56
56
|
- `min`: The minimum value allowed.
|
|
57
57
|
- `max`: The maximum value allowed.
|
|
58
|
+
- `modifiers`: Multipliers applied to `step` while a modifier key is held during scrubbing. Defaults to `{ shiftKey: 0.1, altKey: 1, ctrlKey: 1, metaKey: 1 }`.
|
|
59
|
+
|
|
60
|
+
## Scrubbing behavior
|
|
61
|
+
|
|
62
|
+
- A **plain click** focuses the field for manual text editing; scrubbing only starts once the pointer moves more than a few pixels horizontally. While the field is focused, dragging selects text as in a regular input.
|
|
63
|
+
- Scrubbing works with mouse, touch and pen (Pointer Events), and keeps working when the pointer leaves the element thanks to pointer capture.
|
|
64
|
+
- Modifier keys are read live from the pointer, so pressing or releasing e.g. <kbd>Shift</kbd> mid-drag changes the scrub speed immediately, without value jumps.
|
|
65
|
+
- Pressing <kbd>Escape</kbd> during a drag cancels it and restores the value from before the drag.
|
|
66
|
+
- After a scrub the field is blurred, so the next click-and-drag scrubs again.
|
|
67
|
+
|
|
68
|
+
## Change events and controlled usage
|
|
69
|
+
|
|
70
|
+
All change events delivered to `onChange` — from typing, scrubbing, and arrow-key stepping alike — are **genuine React ChangeEvents**: `event.target` is the real input element and `event.target.value` is always a string in canonical dot-decimal format (a typed `1,5` is delivered as `"1.5"`), mirroring how native number inputs expose a locale-independent DOM value.
|
|
71
|
+
|
|
72
|
+
In-progress editing states are emitted as-is: an emptied field emits `""` and a lone minus emits `"-"`. Parse with `parseFloat` and decide what to do with `NaN` in your host (typically: keep the previous value). While the field is focused, the component never overwrites the text with values echoed back through the `value` prop, so typing `-10`, `0.5`, or deleting everything and retyping works without artefacts. On blur, the text is normalized (`007` becomes `7`, `1.` becomes `1`, a lone `-` becomes empty) and reconciled with the `value` prop.
|
|
58
73
|
|
|
59
74
|
## Components
|
|
60
75
|
|
|
@@ -68,7 +83,7 @@ The main component for interactive input behavior.
|
|
|
68
83
|
|
|
69
84
|
A custom input component featuring input masking specifically designed to address limitations with negative numbers in standard HTML input elements. This component ensures that negative values are properly formatted and accepted by the input field, preventing unexpected behavior or errors when handling signed numbers.
|
|
70
85
|
|
|
71
|
-
You can provide your own masking function to customize the behavior of the input field.
|
|
86
|
+
You can provide your own masking function to customize the behavior of the input field. A mask is a pure function `(rawValue: string, previousValue: string) => string` that returns the text to display — return `previousValue` to reject an edit.
|
|
72
87
|
|
|
73
88
|
Example:
|
|
74
89
|
|
|
@@ -113,6 +128,26 @@ yarn dev
|
|
|
113
128
|
|
|
114
129
|
The project will be available at `http://localhost:6006`.
|
|
115
130
|
|
|
131
|
+
## Releasing
|
|
132
|
+
|
|
133
|
+
Releases are tag-driven. Pushing a version tag runs the [release workflow](.github/workflows/release-package.yml), which tests, publishes to npm, creates a GitHub Release, and deploys Storybook to [GitHub Pages](https://designbyadrian.github.io/react-interactive-input).
|
|
134
|
+
|
|
135
|
+
1. Bump the version in `package.json` and commit (e.g. `2.1.0`).
|
|
136
|
+
2. Create and push a matching tag:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
git tag v2.1.0
|
|
140
|
+
git push origin v2.1.0
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
3. The workflow validates the tag, runs tests, publishes to npm, creates a GitHub Release, and deploys Storybook.
|
|
144
|
+
|
|
145
|
+
The tag **must** match `package.json` exactly (`v2.1.0` ↔ `"version": "2.1.0"`). Publishing the same version twice will fail.
|
|
146
|
+
|
|
147
|
+
Prerequisite: configure [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/) for this package with GitHub Actions — user `designbyadrian`, repository `react-interactive-input`, workflow filename `release-package.yml`, allowed action `npm publish`. No `NPM_TOKEN` secret is required. GitHub Pages should use the `gh-pages` branch as its source.
|
|
148
|
+
|
|
149
|
+
For a local Storybook deploy without releasing, use `npm run deploy-storybook`.
|
|
150
|
+
|
|
116
151
|
## License
|
|
117
152
|
|
|
118
153
|
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more information.
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react");var q={exports:{}},D={};/**
|
|
2
2
|
* @license React
|
|
3
|
-
* react-jsx-runtime.production.
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
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
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
13
|
-
* Copyright (c)
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+ie+e}}var ue=!1,ee;{var Ke=typeof WeakMap=="function"?WeakMap:Map;ee=new Ke}function Re(e,r){if(!e||ue)return"";{var t=ee.get(e);if(t!==void 0)return t}var n;ue=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var l;l=oe.current,oe.current=null,We();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(_){n=_}Reflect.construct(e,[],o)}else{try{o.call()}catch(_){n=_}e.call(o.prototype)}}else{try{throw Error()}catch(_){n=_}e()}}catch(_){if(_&&n&&typeof _.stack=="string"){for(var a=_.stack.split(`
|
|
19
|
-
`),b=n.stack.split(`
|
|
20
|
-
`),d=a.length-1,m=b.length-1;d>=1&&m>=0&&a[d]!==b[m];)m--;for(;d>=1&&m>=0;d--,m--)if(a[d]!==b[m]){if(d!==1||m!==1)do if(d--,m--,m<0||a[d]!==b[m]){var k=`
|
|
21
|
-
`+a[d].replace(" at new "," at ");return e.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",e.displayName)),typeof e=="function"&&ee.set(e,k),k}while(d>=1&&m>=0);break}}}finally{ue=!1,oe.current=l,Ye(),Error.prepareStackTrace=s}var W=e?e.displayName||e.name:"",M=W?Q(W):"";return typeof e=="function"&&ee.set(e,M),M}function Ue(e,r,t){return Re(e,!1)}function Ne(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function re(e,r,t){if(e==null)return"";if(typeof e=="function")return Re(e,Ne(e));if(typeof e=="string")return Q(e);switch(e){case x:return Q("Suspense");case p:return Q("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return Ue(e.render);case w:return re(e.type,r,t);case c:{var n=e,s=n._payload,l=n._init;try{return re(l(s),r,t)}catch{}}}return""}var q=Object.prototype.hasOwnProperty,_e={},we=j.ReactDebugCurrentFrame;function te(e){if(e){var r=e._owner,t=re(e.type,e._source,r?r.type:null);we.setExtraStackFrame(t)}else we.setExtraStackFrame(null)}function qe(e,r,t,n,s){{var l=Function.call.bind(q);for(var o in e)if(l(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var b=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(d){a=d}a&&!(a instanceof Error)&&(te(s),i("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),te(null)),a instanceof Error&&!(a.message in _e)&&(_e[a.message]=!0,te(s),i("Failed %s type: %s",t,a.message),te(null))}}}var Be=Array.isArray;function se(e){return Be(e)}function Je(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Xe(e){try{return Se(e),!1}catch{return!0}}function Se(e){return""+e}function Te(e){if(Xe(e))return i("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Je(e)),Se(e)}var B=j.ReactCurrentOwner,ze={key:!0,ref:!0,__self:!0,__source:!0},Ce,Oe,le;le={};function Ge(e){if(q.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function He(e){if(q.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ze(e,r){if(typeof e.ref=="string"&&B.current&&r&&B.current.stateNode!==r){var t=P(B.current.type);le[t]||(i('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',P(B.current.type),e.ref),le[t]=!0)}}function Qe(e,r){{var t=function(){Ce||(Ce=!0,i("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function er(e,r){{var t=function(){Oe||(Oe=!0,i("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var rr=function(e,r,t,n,s,l,o){var a={$$typeof:g,type:e,key:r,ref:t,props:o,_owner:l};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function tr(e,r,t,n,s){{var l,o={},a=null,b=null;t!==void 0&&(Te(t),a=""+t),He(r)&&(Te(r.key),a=""+r.key),Ge(r)&&(b=r.ref,Ze(r,s));for(l in r)q.call(r,l)&&!ze.hasOwnProperty(l)&&(o[l]=r[l]);if(e&&e.defaultProps){var d=e.defaultProps;for(l in d)o[l]===void 0&&(o[l]=d[l])}if(a||b){var m=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&Qe(o,m),b&&er(o,m)}return rr(e,a,b,s,n,B.current,o)}}var ce=j.ReactCurrentOwner,Pe=j.ReactDebugCurrentFrame;function $(e){if(e){var r=e._owner,t=re(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(t)}else Pe.setExtraStackFrame(null)}var fe;fe=!1;function de(e){return typeof e=="object"&&e!==null&&e.$$typeof===g}function ke(){{if(ce.current){var e=P(ce.current.type);if(e)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function nr(e){return""}var xe={};function ar(e){{var r=ke();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+t+">.")}return r}}function je(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=ar(r);if(xe[t])return;xe[t]=!0;var n="";e&&e._owner&&e._owner!==ce.current&&(n=" It was passed a child from "+P(e._owner.type)+"."),$(e),i('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),$(null)}}function De(e,r){{if(typeof e!="object")return;if(se(e))for(var t=0;t<e.length;t++){var n=e[t];de(n)&&je(n,r)}else if(de(e))e._store&&(e._store.validated=!0);else if(e){var s=I(e);if(typeof s=="function"&&s!==e.entries)for(var l=s.call(e),o;!(o=l.next()).done;)de(o.value)&&je(o.value,r)}}}function or(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===v||r.$$typeof===w))t=r.propTypes;else return;if(t){var n=P(r);qe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!fe){fe=!0;var s=P(r);i("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&i("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ir(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){$(e),i("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),$(null);break}}e.ref!==null&&($(e),i("Invalid attribute `ref` supplied to `React.Fragment`."),$(null))}}var Fe={};function Ae(e,r,t,n,s,l){{var o=G(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var b=nr();b?a+=b:a+=ke();var d;e===null?d="null":se(e)?d="array":e!==void 0&&e.$$typeof===g?(d="<"+(P(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):d=typeof e,i("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",d,a)}var m=tr(e,r,t,s,l);if(m==null)return m;if(o){var k=r.children;if(k!==void 0)if(n)if(se(k)){for(var W=0;W<k.length;W++)De(k[W],e);Object.freeze&&Object.freeze(k)}else i("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 De(k,e)}if(q.call(r,"key")){var M=P(e),_=Object.keys(r).filter(function(dr){return dr!=="key"}),ve=_.length>0?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}";if(!Fe[M+ve]){var fr=_.length>0?"{"+_.join(": ..., ")+": ...}":"{}";i(`A props object containing a "key" prop is being spread into JSX:
|
|
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:
|
|
26
18
|
let props = %s;
|
|
27
19
|
<%s {...props} />
|
|
28
20
|
React keys must be passed directly to JSX without using spread:
|
|
29
21
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
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;
|