@starasia/input 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/input.umd.js CHANGED
@@ -1,35 +1,4 @@
1
- (function(N,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(N=typeof globalThis<"u"?globalThis:N||self,d(N.Input={},N.React))})(this,function(N,d){"use strict";var tr={exports:{}},J={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its 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 mr;function Mr(){if(mr)return J;mr=1;var t=d,u=Symbol.for("react.element"),y=Symbol.for("react.fragment"),x=Object.prototype.hasOwnProperty,E=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function F(D,l,S){var v,R={},j=null,A=null;S!==void 0&&(j=""+S),l.key!==void 0&&(j=""+l.key),l.ref!==void 0&&(A=l.ref);for(v in l)x.call(l,v)&&!p.hasOwnProperty(v)&&(R[v]=l[v]);if(D&&D.defaultProps)for(v in l=D.defaultProps,l)R[v]===void 0&&(R[v]=l[v]);return{$$typeof:u,type:D,key:j,ref:A,props:R,_owner:E.current}}return J.Fragment=y,J.jsx=F,J.jsxs=F,J}var G={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its 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 wr;function Kr(){return wr||(wr=1,process.env.NODE_ENV!=="production"&&function(){var t=d,u=Symbol.for("react.element"),y=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),D=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),Z=Symbol.iterator,z="@@iterator";function or(r){if(r===null||typeof r!="object")return null;var n=Z&&r[Z]||r[z];return typeof n=="function"?n:null}var c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(r){{for(var n=arguments.length,a=new Array(n>1?n-1:0),e=1;e<n;e++)a[e-1]=arguments[e];U("error",r,a)}}function U(r,n,a){{var e=c.ReactDebugCurrentFrame,s=e.getStackAddendum();s!==""&&(n+="%s",a=a.concat([s]));var f=a.map(function(o){return String(o)});f.unshift("Warning: "+n),Function.prototype.apply.call(console[r],console,f)}}var L=!1,B=!1,sr=!1,Q=!1,$=!1,H;H=Symbol.for("react.module.reference");function ur(r){return!!(typeof r=="string"||typeof r=="function"||r===x||r===p||$||r===E||r===S||r===v||Q||r===A||L||B||sr||typeof r=="object"&&r!==null&&(r.$$typeof===j||r.$$typeof===R||r.$$typeof===F||r.$$typeof===D||r.$$typeof===l||r.$$typeof===H||r.getModuleId!==void 0))}function lr(r,n,a){var e=r.displayName;if(e)return e;var s=n.displayName||n.name||"";return s!==""?a+"("+s+")":a}function m(r){return r.displayName||"Context"}function g(r){if(r==null)return null;if(typeof r.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case x:return"Fragment";case y:return"Portal";case p:return"Profiler";case E:return"StrictMode";case S:return"Suspense";case v:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case D:var n=r;return m(n)+".Consumer";case F:var a=r;return m(a._context)+".Provider";case l:return lr(r,r.render,"ForwardRef");case R:var e=r.displayName||null;return e!==null?e:g(r.type)||"Memo";case j:{var s=r,f=s._payload,o=s._init;try{return g(o(f))}catch{return null}}}return null}var w=Object.assign,O=0,V,P,W,Cr,Sr,Tr,kr;function jr(){}jr.__reactDisabledLog=!0;function $r(){{if(O===0){V=console.log,P=console.info,W=console.warn,Cr=console.error,Sr=console.group,Tr=console.groupCollapsed,kr=console.groupEnd;var r={configurable:!0,enumerable:!0,value:jr,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}O++}}function rn(){{if(O--,O===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:w({},r,{value:V}),info:w({},r,{value:P}),warn:w({},r,{value:W}),error:w({},r,{value:Cr}),group:w({},r,{value:Sr}),groupCollapsed:w({},r,{value:Tr}),groupEnd:w({},r,{value:kr})})}O<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var cr=c.ReactCurrentDispatcher,fr;function rr(r,n,a){{if(fr===void 0)try{throw Error()}catch(s){var e=s.stack.trim().match(/\n( *(at )?)/);fr=e&&e[1]||""}return`
18
- `+fr+r}}var dr=!1,nr;{var nn=typeof WeakMap=="function"?WeakMap:Map;nr=new nn}function Or(r,n){if(!r||dr)return"";{var a=nr.get(r);if(a!==void 0)return a}var e;dr=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var f;f=cr.current,cr.current=null,$r();try{if(n){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(k){e=k}Reflect.construct(r,[],o)}else{try{o.call()}catch(k){e=k}r.call(o.prototype)}}else{try{throw Error()}catch(k){e=k}r()}}catch(k){if(k&&e&&typeof k.stack=="string"){for(var i=k.stack.split(`
19
- `),T=e.stack.split(`
20
- `),h=i.length-1,b=T.length-1;h>=1&&b>=0&&i[h]!==T[b];)b--;for(;h>=1&&b>=0;h--,b--)if(i[h]!==T[b]){if(h!==1||b!==1)do if(h--,b--,b<0||i[h]!==T[b]){var I=`
21
- `+i[h].replace(" at new "," at ");return r.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",r.displayName)),typeof r=="function"&&nr.set(r,I),I}while(h>=1&&b>=0);break}}}finally{dr=!1,cr.current=f,rn(),Error.prepareStackTrace=s}var K=r?r.displayName||r.name:"",Y=K?rr(K):"";return typeof r=="function"&&nr.set(r,Y),Y}function an(r,n,a){return Or(r,!1)}function en(r){var n=r.prototype;return!!(n&&n.isReactComponent)}function ar(r,n,a){if(r==null)return"";if(typeof r=="function")return Or(r,en(r));if(typeof r=="string")return rr(r);switch(r){case S:return rr("Suspense");case v:return rr("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case l:return an(r.render);case R:return ar(r.type,n,a);case j:{var e=r,s=e._payload,f=e._init;try{return ar(f(s),n,a)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,Pr={},Ir=c.ReactDebugCurrentFrame;function er(r){if(r){var n=r._owner,a=ar(r.type,r._source,n?n.type:null);Ir.setExtraStackFrame(a)}else Ir.setExtraStackFrame(null)}function tn(r,n,a,e,s){{var f=Function.call.bind(X);for(var o in r)if(f(r,o)){var i=void 0;try{if(typeof r[o]!="function"){var T=Error((e||"React class")+": "+a+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}i=r[o](n,o,e,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(h){i=h}i&&!(i instanceof Error)&&(er(s),_("%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).",e||"React class",a,o,typeof i),er(null)),i instanceof Error&&!(i.message in Pr)&&(Pr[i.message]=!0,er(s),_("Failed %s type: %s",a,i.message),er(null))}}}var on=Array.isArray;function pr(r){return on(r)}function sn(r){{var n=typeof Symbol=="function"&&Symbol.toStringTag,a=n&&r[Symbol.toStringTag]||r.constructor.name||"Object";return a}}function un(r){try{return Dr(r),!1}catch{return!0}}function Dr(r){return""+r}function Ar(r){if(un(r))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",sn(r)),Dr(r)}var q=c.ReactCurrentOwner,ln={key:!0,ref:!0,__self:!0,__source:!0},Fr,Lr,vr;vr={};function cn(r){if(X.call(r,"ref")){var n=Object.getOwnPropertyDescriptor(r,"ref").get;if(n&&n.isReactWarning)return!1}return r.ref!==void 0}function fn(r){if(X.call(r,"key")){var n=Object.getOwnPropertyDescriptor(r,"key").get;if(n&&n.isReactWarning)return!1}return r.key!==void 0}function dn(r,n){if(typeof r.ref=="string"&&q.current&&n&&q.current.stateNode!==n){var a=g(q.current.type);vr[a]||(_('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',g(q.current.type),r.ref),vr[a]=!0)}}function pn(r,n){{var a=function(){Fr||(Fr=!0,_("%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)",n))};a.isReactWarning=!0,Object.defineProperty(r,"key",{get:a,configurable:!0})}}function vn(r,n){{var a=function(){Lr||(Lr=!0,_("%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)",n))};a.isReactWarning=!0,Object.defineProperty(r,"ref",{get:a,configurable:!0})}}var gn=function(r,n,a,e,s,f,o){var i={$$typeof:u,type:r,key:n,ref:a,props:o,_owner:f};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:e}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function hn(r,n,a,e,s){{var f,o={},i=null,T=null;a!==void 0&&(Ar(a),i=""+a),fn(n)&&(Ar(n.key),i=""+n.key),cn(n)&&(T=n.ref,dn(n,s));for(f in n)X.call(n,f)&&!ln.hasOwnProperty(f)&&(o[f]=n[f]);if(r&&r.defaultProps){var h=r.defaultProps;for(f in h)o[f]===void 0&&(o[f]=h[f])}if(i||T){var b=typeof r=="function"?r.displayName||r.name||"Unknown":r;i&&pn(o,b),T&&vn(o,b)}return gn(r,i,T,s,e,q.current,o)}}var gr=c.ReactCurrentOwner,Vr=c.ReactDebugCurrentFrame;function M(r){if(r){var n=r._owner,a=ar(r.type,r._source,n?n.type:null);Vr.setExtraStackFrame(a)}else Vr.setExtraStackFrame(null)}var hr;hr=!1;function br(r){return typeof r=="object"&&r!==null&&r.$$typeof===u}function Nr(){{if(gr.current){var r=g(gr.current.type);if(r)return`
22
-
23
- Check the render method of \``+r+"`."}return""}}function bn(r){{if(r!==void 0){var n=r.fileName.replace(/^.*[\\\/]/,""),a=r.lineNumber;return`
24
-
25
- Check your code at `+n+":"+a+"."}return""}}var Wr={};function yn(r){{var n=Nr();if(!n){var a=typeof r=="string"?r:r.displayName||r.name;a&&(n=`
26
-
27
- Check the top-level render call using <`+a+">.")}return n}}function Yr(r,n){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var a=yn(n);if(Wr[a])return;Wr[a]=!0;var e="";r&&r._owner&&r._owner!==gr.current&&(e=" It was passed a child from "+g(r._owner.type)+"."),M(r),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,e),M(null)}}function zr(r,n){{if(typeof r!="object")return;if(pr(r))for(var a=0;a<r.length;a++){var e=r[a];br(e)&&Yr(e,n)}else if(br(r))r._store&&(r._store.validated=!0);else if(r){var s=or(r);if(typeof s=="function"&&s!==r.entries)for(var f=s.call(r),o;!(o=f.next()).done;)br(o.value)&&Yr(o.value,n)}}}function mn(r){{var n=r.type;if(n==null||typeof n=="string")return;var a;if(typeof n=="function")a=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===l||n.$$typeof===R))a=n.propTypes;else return;if(a){var e=g(n);tn(a,r.props,"prop",e,r)}else if(n.PropTypes!==void 0&&!hr){hr=!0;var s=g(n);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function wn(r){{for(var n=Object.keys(r.props),a=0;a<n.length;a++){var e=n[a];if(e!=="children"&&e!=="key"){M(r),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",e),M(null);break}}r.ref!==null&&(M(r),_("Invalid attribute `ref` supplied to `React.Fragment`."),M(null))}}var Ur={};function Br(r,n,a,e,s,f){{var o=ur(r);if(!o){var i="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(i+=" 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 T=bn(s);T?i+=T:i+=Nr();var h;r===null?h="null":pr(r)?h="array":r!==void 0&&r.$$typeof===u?(h="<"+(g(r.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):h=typeof r,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",h,i)}var b=hn(r,n,a,s,f);if(b==null)return b;if(o){var I=n.children;if(I!==void 0)if(e)if(pr(I)){for(var K=0;K<I.length;K++)zr(I[K],r);Object.freeze&&Object.freeze(I)}else _("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 zr(I,r)}if(X.call(n,"key")){var Y=g(r),k=Object.keys(n).filter(function(Sn){return Sn!=="key"}),yr=k.length>0?"{key: someKey, "+k.join(": ..., ")+": ...}":"{key: someKey}";if(!Ur[Y+yr]){var Cn=k.length>0?"{"+k.join(": ..., ")+": ...}":"{}";_(`A props object containing a "key" prop is being spread into JSX:
28
- let props = %s;
29
- <%s {...props} />
30
- React keys must be passed directly to JSX without using spread:
31
- let props = %s;
32
- <%s key={someKey} {...props} />`,yr,Y,Cn,Y),Ur[Y+yr]=!0}}return r===x?wn(b):mn(b),b}}function xn(r,n,a){return Br(r,n,a,!0)}function En(r,n,a){return Br(r,n,a,!1)}var Rn=En,_n=xn;G.Fragment=x,G.jsx=Rn,G.jsxs=_n}()),G}process.env.NODE_ENV==="production"?tr.exports=Mr():tr.exports=Kr();var C=tr.exports;const Jr=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
1
+ (function(f,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],i):(f=typeof globalThis<"u"?globalThis:f||self,i(f.Input={},f.jsxRuntime,f.React))})(this,function(f,i,t){"use strict";const D=`@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
33
2
 
34
3
  * {
35
4
  margin: 0;
@@ -48,86 +17,86 @@ React keys must be passed directly to JSX without using spread:
48
17
  /* blue */
49
18
  --starasia-ui-input-color-primary-blue: var(
50
19
  --starasia-ui-color-blue-700,
51
- #1d4ed8
20
+ #1976d2
52
21
  );
53
22
  --starasia-ui-input-color-secondary-blue: var(
54
23
  --starasia-ui-color-blue-500,
55
- #3b82f6
24
+ #2196f3
56
25
  );
57
26
  --starasia-ui-input-color-tertiary-blue: var(
58
27
  --starasia-ui-color-blue-300,
59
- #93c5fd
28
+ #64b5f6
60
29
  );
61
30
  --starasia-ui-input-color-quaternary-blue: var(
62
31
  --starasia-ui-color-blue-100,
63
- #dbeafe
32
+ #bbdefb
64
33
  );
65
34
  --starasia-ui-input-color-quinary-blue: var(
66
35
  --starasia-ui-color-blue-50,
67
- #eff6ff
36
+ #e3f2fd
68
37
  );
69
38
  /* gray */
70
39
  --starasia-ui-input-color-primary-gray: var(
71
40
  --starasia-ui-color-gray-700,
72
- #374151
41
+ #48504c
73
42
  );
74
43
  --starasia-ui-input-color-secondary-gray: var(
75
44
  --starasia-ui-color-gray-500,
76
- #6b7280
45
+ #78867f
77
46
  );
78
47
  --starasia-ui-input-color-tertiary-gray: var(
79
48
  --starasia-ui-color-gray-300,
80
- #d1d5db
49
+ #aeb6b2
81
50
  );
82
51
  --starasia-ui-input-color-quaternary-gray: var(
83
52
  --starasia-ui-color-gray-100,
84
- #f3f4f6
53
+ #eff3f8
85
54
  );
86
55
  --starasia-ui-input-color-quinary-gray: var(
87
56
  --starasia-ui-color-gray-50,
88
- #f9fafb
57
+ #fffeff
89
58
  );
90
59
  /* red */
91
60
  --starasia-ui-input-color-primary-red: var(
92
61
  --starasia-ui-color-red-700,
93
- #b91c1c
62
+ #a4133c
94
63
  );
95
64
  --starasia-ui-input-color-secondary-red: var(
96
65
  --starasia-ui-color-red-500,
97
- #ef4444
66
+ #ff4d6d
98
67
  );
99
68
  --starasia-ui-input-color-tertiary-red: var(
100
69
  --starasia-ui-color-red-300,
101
- #fca5a5
70
+ #ff8fa3
102
71
  );
103
72
  --starasia-ui-input-color-quaternary-red: var(
104
73
  --starasia-ui-color-red-100,
105
- #fee2e2
74
+ #ffccd5
106
75
  );
107
76
  --starasia-ui-input-color-quinary-red: var(
108
77
  --starasia-ui-color-red-50,
109
- #fef2f2
78
+ #fff0f3
110
79
  );
111
- /* yellow */
112
- --starasia-ui-input-color-primary-yellow: var(
113
- --starasia-ui-color-yellow-700,
114
- #a16207
80
+ /* orange */
81
+ --starasia-ui-input-color-primary-orange: var(
82
+ --starasia-ui-color-orange-700,
83
+ #986800
115
84
  );
116
- --starasia-ui-input-color-secondary-yellow: var(
117
- --starasia-ui-color-yellow-500,
118
- #eab308
85
+ --starasia-ui-input-color-secondary-orange: var(
86
+ --starasia-ui-color-orange-500,
87
+ #d2a03a
119
88
  );
120
- --starasia-ui-input-color-tertiary-yellow: var(
121
- --starasia-ui-color-yellow-300,
122
- #fde047
89
+ --starasia-ui-input-color-tertiary-orange: var(
90
+ --starasia-ui-color-orange-300,
91
+ #ffcb69
123
92
  );
124
- --starasia-ui-input-color-quaternary-yellow: var(
125
- --starasia-ui-color-yellow-100,
126
- #fef9c3
93
+ --starasia-ui-input-color-quaternary-orange: var(
94
+ --starasia-ui-color-orange-100,
95
+ #fff5c1
127
96
  );
128
- --starasia-ui-input-color-quinary-yellow: var(
129
- --starasia-ui-color-yellow-50,
130
- #fefce8
97
+ --starasia-ui-input-color-quinary-orange: var(
98
+ --starasia-ui-color-orange-50,
99
+ #faf6e0
131
100
  );
132
101
 
133
102
  /* text color */
@@ -207,16 +176,16 @@ React keys must be passed directly to JSX without using spread:
207
176
  }
208
177
 
209
178
  .starasia-input-outline.starasia-input-container-warning {
210
- border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
179
+ border-color: var(--starasia-ui-input-color-secondary-orange) !important;
211
180
  }
212
181
 
213
182
  .starasia-input-filled.starasia-input-container-warning {
214
- border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
215
- background-color: var(--starasia-ui-input-color-quinary-yellow);
183
+ border-color: var(--starasia-ui-input-color-secondary-orange) !important;
184
+ background-color: var(--starasia-ui-input-color-quinary-orange);
216
185
  }
217
186
 
218
187
  .starasia-input-flushed.starasia-input-container-warning {
219
- border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
188
+ border-color: var(--starasia-ui-input-color-secondary-orange) !important;
220
189
  }
221
190
 
222
191
  .starasia-input-outline {
@@ -368,4 +337,4 @@ React keys must be passed directly to JSX without using spread:
368
337
  color: var(--starasia-ui-input-placeholder-color);
369
338
  font-weight: var(--starasia-ui-fontWeights-normal, 300);
370
339
  }
371
- `,xr=t=>{if(t==="sm")return 16;if(t==="md")return 16;if(t==="lg")return 20},Er=t=>t==="default"?"#939E99":t==="error"?"#EF4444":t==="warning"?"#EAB308":"#939E99",Rr=t=>t==="default"?"#939E99":t==="error"?"#EF4444":t==="warning"?"#EAB308":"#939E99",Gr=d.forwardRef(({options:t,value:u,setValue:y,isComponentVisible:x,onOptionChange:E},p)=>{const[F,D]=d.useState([]),l=d.useRef(null),S=()=>{if(p!=null&&p.current&&l.current){const v=window.innerHeight,R=p==null?void 0:p.current.getBoundingClientRect(),j=l.current.getBoundingClientRect(),A=R.bottom+j.height;l.current.style.left=`${R.left}px`,l.current.style.width=`${R.width}px`,A>=v-10?l.current.style.top=`${R.top-j.height-5}px`:l.current.style.top=`${R.top+R.height}px`}};return d.useEffect(()=>(window.addEventListener("scroll",S),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S),window.removeEventListener("resize",S)}),[p,l]),d.useEffect(()=>{S()},[x]),d.useEffect(()=>{D((t==null?void 0:t.filter(v=>v.toLowerCase().startsWith(u.toLowerCase())))||[])},[u,t]),C.jsx("div",{ref:l,style:{position:"fixed",padding:"8px",boxSizing:"border-box",boxShadow:"0px 8px 12px 0px rgba(0, 0, 0, 0.08)",borderRadius:"8px",background:"white",overflow:"auto",zIndex:5e4},children:F==null?void 0:F.map(v=>Hr(v,u,y,E))})}),Hr=(t,u,y,x)=>{const E=t.toLowerCase().indexOf(u.toLowerCase());return C.jsxs("p",{style:{fontFamily:"Poppins",color:"#c9cecc",fontWeight:500,padding:"8px 14px",cursor:"pointer"},onClick:()=>{y(t),x&&x(t)},children:[t.slice(0,E),C.jsx("span",{style:{color:"#374151"},children:t.slice(E,E+u.length)}),t.slice(E+u.length)]})};function Xr(t){const[u,y]=d.useState(t),x=d.useRef(null),E=p=>{x.current&&!x.current.contains(p.target)&&y(!1)};return d.useEffect(()=>(document.addEventListener("click",E,!0),()=>{document.removeEventListener("click",E,!0)}),[]),{ref:x,isComponentVisible:u,setIsComponentVisible:y}}const _r="starasia-input-styles";(t=>{if(!document.getElementById(_r)){const u=document.createElement("style");u.id=_r,u.textContent=t,document.head.appendChild(u)}})(Jr);function qr(t){return Number(t.replace(/\./g,""))}const ir=t=>{let u=t.replace(/[^\d]/g,"");return u=u.replace(/^0+(?=\d)/,""),u.replace(/\B(?=(\d{3})+(?!\d))/g,".")},Zr=d.forwardRef((t,u)=>{const{leftIcon:y,rightIcon:x,size:E="md",status:p="default",inputUse:F="icon",variant:D="outline",leftAddons:l,rightAddons:S,onClickLeftIcon:v,onClickRightIcon:R,highlightPlaceholder:j,currency:A,fullWidth:Z=!1,options:z,onOptionChange:or,...c}=t;{const[_,U]=d.useState(!0),[L,B]=d.useState(""),[sr,Q]=d.useState(""),{isComponentVisible:$,ref:H,setIsComponentVisible:ur}=Xr(!1),lr=()=>{ur(m=>!m)};return d.useEffect(()=>{typeof c.value=="string"&&c.value.length||c.defaultValue||typeof c.value=="number"?U(!1):U(!0)},[c.value,c.defaultValue]),d.useEffect(()=>{B(A?ir(String(c.value)):c.value||"")},[c]),C.jsxs("div",{className:`starasia-input-container starasia-input-${D} starasia-input-container-${p} ${E} `,style:{width:Z?"auto":"max-content",position:"relative"},ref:H,onClick:lr,children:[l?C.jsx("div",{className:"starasia-input-container-addons-left",children:l}):null,y?C.jsx("div",{className:"starasia-input-container-icon-left",children:d.cloneElement(y,{width:xr(E),color:Er(c.disabled?"disable":p),onClick:v,style:{color:`${Er(c.disabled?"disable":p)}`}})}):null,C.jsxs("div",{className:"starasia-input-preview-container",children:[C.jsx("input",{className:"starasia-input",...c,placeholder:"",disabled:p==="disable"?!0:c.disabled,ref:u,onChange:m=>{let g=A?ir(m.target.value):m.target.value;const w=m.target.selectionStart;if(A)if(sr==="Backspace")if(typeof w=="number"&&L[w]==="."){let O=g.slice(0,w-1),V=g.slice(w,g.length);g=ir(O+V);const P=L.length-1,W=g.length-1;setTimeout(()=>m.target.setSelectionRange(w-(P-W)<0?0:w-(P-W),w-(P-W)<0?0:w-(P-W)),0)}else{const O=L.length-1,V=g.length-1;let P=w+1-(O-V);setTimeout(()=>m.target.setSelectionRange(P<0?0:P,P<0?0:P),0)}else{const O=L.length-1,V=g.length-1;setTimeout(()=>m.target.setSelectionRange(w+(V-O)-1,w+(V-O)-1),0)}B(g),m.target.value?U(!1):U(!0),c.onChange&&c.onChange({...m,target:{...m.target,value:A?String(qr(g)):g,name:m.target.name}}),Q("")},value:L,onKeyDown:m=>{m.key==="Backspace"&&Q(m.key),c.onKeyDown&&c.onKeyDown(m)}}),_?Qr(c.placeholder,j):null]}),x?C.jsx("div",{className:"starasia-input-container-icon-right",children:d.cloneElement(x,{width:xr(E),color:Rr(c.disabled?"disable":p),onClick:R,style:{color:`${Rr(c.disabled?"disable":p)}`}})}):null,S?C.jsx("div",{className:"starasia-input-container-addons-right",children:S}):null,L&&$&&(z!=null&&z.length)?C.jsx(Gr,{options:z,value:L,setValue:B,ref:H,isComponentVisible:$,onOptionChange:or}):null]})}}),Qr=(t,u)=>{if(!t||!u)return C.jsx("p",{className:"starasia-input-placeholder",children:t||""});const y=t.toLowerCase().indexOf(u.toLowerCase());return y===-1?C.jsx("p",{className:"starasia-input-placeholder",children:t}):C.jsxs("p",{className:"starasia-input-placeholder",children:[t.slice(0,y),C.jsx("span",{className:"starasia-input-placeholder-highlighted",children:t.slice(y,y+u.length)}),t.slice(y+u.length)]})};N.Input=Zr,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
340
+ `,q=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},z=n=>n==="default"?"#939E99":n==="error"?"#EF4444":n==="warning"?"#EAB308":"#939E99",j=n=>n==="default"?"#939E99":n==="error"?"#EF4444":n==="warning"?"#EAB308":"#939E99",O=t.forwardRef(({options:n,value:a,setValue:o,isComponentVisible:l,onOptionChange:u},e)=>{const[k,V]=t.useState([]),c=t.useRef(null),h=()=>{if(e!=null&&e.current&&c.current){const v=window.innerHeight,b=e==null?void 0:e.current.getBoundingClientRect(),C=c.current.getBoundingClientRect(),m=b.bottom+C.height;c.current.style.left=`${b.left}px`,c.current.style.width=`${b.width}px`,m>=v-10?c.current.style.top=`${b.top-C.height-5}px`:c.current.style.top=`${b.top+b.height}px`}};return t.useEffect(()=>(window.addEventListener("scroll",h),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h),window.removeEventListener("resize",h)}),[e,c]),t.useEffect(()=>{h()},[l]),t.useEffect(()=>{V((n==null?void 0:n.filter(v=>v.toLowerCase().startsWith(a.toLowerCase())))||[])},[a,n]),i.jsx("div",{ref:c,style:{position:"fixed",padding:"8px",boxSizing:"border-box",boxShadow:"0px 8px 12px 0px rgba(0, 0, 0, 0.08)",borderRadius:"8px",background:"white",overflow:"auto",zIndex:5e4},children:k==null?void 0:k.map(v=>W(v,a,o,u))})}),W=(n,a,o,l)=>{const u=n.toLowerCase().indexOf(a.toLowerCase());return i.jsxs("p",{style:{fontFamily:"Poppins",color:"#c9cecc",fontWeight:500,padding:"8px 14px",cursor:"pointer"},onClick:()=>{o(n),l&&l(n)},children:[n.slice(0,u),i.jsx("span",{style:{color:"#374151"},children:n.slice(u,u+a.length)}),n.slice(u+a.length)]})};function A(n){const[a,o]=t.useState(n),l=t.useRef(null),u=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return t.useEffect(()=>(document.addEventListener("click",u,!0),()=>{document.removeEventListener("click",u,!0)}),[]),{ref:l,isComponentVisible:a,setIsComponentVisible:o}}const T="starasia-input-styles";(n=>{if(!document.getElementById(T)){const a=document.createElement("style");a.id=T,a.textContent=n,document.head.appendChild(a)}})(D);function K(n){return Number(n.replace(/\./g,""))}const N=n=>{let a=n.replace(/[^\d]/g,"");return a=a.replace(/^0+(?=\d)/,""),a.replace(/\B(?=(\d{3})+(?!\d))/g,".")},F=t.forwardRef((n,a)=>{const{leftIcon:o,rightIcon:l,size:u="md",status:e="default",inputUse:k="icon",variant:V="outline",leftAddons:c,rightAddons:h,onClickLeftIcon:v,onClickRightIcon:b,highlightPlaceholder:C,currency:m,fullWidth:U=!1,options:S,onOptionChange:M,...r}=n;{const[Y,E]=t.useState(!0),[y,I]=t.useState(""),[G,$]=t.useState(""),{isComponentVisible:B,ref:P,setIsComponentVisible:J}=A(!1),Q=()=>{J(s=>!s)};return t.useEffect(()=>{typeof r.value=="string"&&r.value.length||r.defaultValue||typeof r.value=="number"?E(!1):E(!0)},[r.value,r.defaultValue]),t.useEffect(()=>{I(m?N(String(r.value)):r.value||"")},[r]),i.jsxs("div",{className:`starasia-input-container starasia-input-${V} starasia-input-container-${e} ${u} `,style:{width:U?"auto":"max-content",position:"relative"},ref:P,onClick:Q,children:[c?i.jsx("div",{className:"starasia-input-container-addons-left",children:c}):null,o?i.jsx("div",{className:"starasia-input-container-icon-left",children:t.cloneElement(o,{width:q(u),color:z(r.disabled?"disable":e),onClick:v,style:{color:`${z(r.disabled?"disable":e)}`}})}):null,i.jsxs("div",{className:"starasia-input-preview-container",children:[i.jsx("input",{className:"starasia-input",...r,placeholder:"",disabled:e==="disable"?!0:r.disabled,ref:a,onChange:s=>{let p=m?N(s.target.value):s.target.value;const d=s.target.selectionStart;if(m)if(G==="Backspace")if(typeof d=="number"&&y[d]==="."){let x=p.slice(0,d-1),w=p.slice(d,p.length);p=N(x+w);const g=y.length-1,L=p.length-1;setTimeout(()=>s.target.setSelectionRange(d-(g-L)<0?0:d-(g-L),d-(g-L)<0?0:d-(g-L)),0)}else{const x=y.length-1,w=p.length-1;let g=d+1-(x-w);setTimeout(()=>s.target.setSelectionRange(g<0?0:g,g<0?0:g),0)}else{const x=y.length-1,w=p.length-1;setTimeout(()=>s.target.setSelectionRange(d+(w-x)-1,d+(w-x)-1),0)}I(p),s.target.value?E(!1):E(!0),r.onChange&&r.onChange({...s,target:{...s.target,value:m?String(K(p)):p,name:s.target.name}}),$("")},value:y,onKeyDown:s=>{s.key==="Backspace"&&$(s.key),r.onKeyDown&&r.onKeyDown(s)}}),Y?H(r.placeholder,C):null]}),l?i.jsx("div",{className:"starasia-input-container-icon-right",children:t.cloneElement(l,{width:q(u),color:j(r.disabled?"disable":e),onClick:b,style:{color:`${j(r.disabled?"disable":e)}`}})}):null,h?i.jsx("div",{className:"starasia-input-container-addons-right",children:h}):null,y&&B&&(S!=null&&S.length)?i.jsx(O,{options:S,value:y,setValue:I,ref:P,isComponentVisible:B,onOptionChange:M}):null]})}}),H=(n,a)=>{if(!n||!a)return i.jsx("p",{className:"starasia-input-placeholder",children:n||""});const o=n.toLowerCase().indexOf(a.toLowerCase());return o===-1?i.jsx("p",{className:"starasia-input-placeholder",children:n}):i.jsxs("p",{className:"starasia-input-placeholder",children:[n.slice(0,o),i.jsx("span",{className:"starasia-input-placeholder-highlighted",children:n.slice(o,o+a.length)}),n.slice(o+a.length)]})};f.Input=F,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/input",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "input component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/input.umd.js",
@@ -12,16 +12,16 @@
12
12
  "dist/*.map",
13
13
  "dist/*.css"
14
14
  ],
15
- "scripts": {
16
- "dev": "vite --config vite.config.ts --port 3000",
17
- "build": "vite build --config vite.config.ts"
18
- },
19
15
  "keywords": [],
20
16
  "license": "ISC",
21
17
  "type": "module",
22
18
  "engines": {
23
19
  "node": ">=18.0.0"
24
20
  },
21
+ "peerDependencies": {
22
+ "react": ">=18.0.0 <20.0.0",
23
+ "react-dom": ">=18.0.0 <20.0.0"
24
+ },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.11.16",
27
27
  "@vitejs/plugin-react": "^4.2.1",
@@ -33,5 +33,9 @@
33
33
  "react-dom": "^18.2.0",
34
34
  "@types/react": "^18.2.55",
35
35
  "@types/react-dom": "^18.2.19"
36
+ },
37
+ "scripts": {
38
+ "dev": "vite --config vite.config.ts --port 3000",
39
+ "build": "vite build --config vite.config.ts"
36
40
  }
37
- }
41
+ }