@starasia/input 1.0.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 +103 -0
- package/dist/Input.d.ts +3 -0
- package/dist/Suggestion.d.ts +10 -0
- package/dist/functions.d.ts +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/input.es.js +1231 -0
- package/dist/input.umd.js +371 -0
- package/dist/types.d.ts +20 -0
- package/dist/useComponentVisible.d.ts +5 -0
- package/package.json +37 -0
|
@@ -0,0 +1,371 @@
|
|
|
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");
|
|
33
|
+
|
|
34
|
+
* {
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:root {
|
|
40
|
+
/* spacing */
|
|
41
|
+
--starasia-ui-input-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
|
|
42
|
+
--starasia-ui-input-spacing-sm: var(--starasia-ui-spacing-sm, 8px);
|
|
43
|
+
--starasia-ui-input-spacing-ms: var(--starasia-ui-spacing-12, 12px);
|
|
44
|
+
--starasia-ui-input-spacing-md: var(--starasia-ui-spacing-lg, 16px);
|
|
45
|
+
--starasia-ui-input-spacing-lg: var(--starasia-ui-spacing-xl, 24px);
|
|
46
|
+
|
|
47
|
+
/* color */
|
|
48
|
+
/* blue */
|
|
49
|
+
--starasia-ui-input-color-primary-blue: var(
|
|
50
|
+
--starasia-ui-color-blue-700,
|
|
51
|
+
#1d4ed8
|
|
52
|
+
);
|
|
53
|
+
--starasia-ui-input-color-secondary-blue: var(
|
|
54
|
+
--starasia-ui-color-blue-500,
|
|
55
|
+
#3b82f6
|
|
56
|
+
);
|
|
57
|
+
--starasia-ui-input-color-tertiary-blue: var(
|
|
58
|
+
--starasia-ui-color-blue-300,
|
|
59
|
+
#93c5fd
|
|
60
|
+
);
|
|
61
|
+
--starasia-ui-input-color-quaternary-blue: var(
|
|
62
|
+
--starasia-ui-color-blue-100,
|
|
63
|
+
#dbeafe
|
|
64
|
+
);
|
|
65
|
+
--starasia-ui-input-color-quinary-blue: var(
|
|
66
|
+
--starasia-ui-color-blue-50,
|
|
67
|
+
#eff6ff
|
|
68
|
+
);
|
|
69
|
+
/* gray */
|
|
70
|
+
--starasia-ui-input-color-primary-gray: var(
|
|
71
|
+
--starasia-ui-color-gray-700,
|
|
72
|
+
#374151
|
|
73
|
+
);
|
|
74
|
+
--starasia-ui-input-color-secondary-gray: var(
|
|
75
|
+
--starasia-ui-color-gray-500,
|
|
76
|
+
#6b7280
|
|
77
|
+
);
|
|
78
|
+
--starasia-ui-input-color-tertiary-gray: var(
|
|
79
|
+
--starasia-ui-color-gray-300,
|
|
80
|
+
#d1d5db
|
|
81
|
+
);
|
|
82
|
+
--starasia-ui-input-color-quaternary-gray: var(
|
|
83
|
+
--starasia-ui-color-gray-100,
|
|
84
|
+
#f3f4f6
|
|
85
|
+
);
|
|
86
|
+
--starasia-ui-input-color-quinary-gray: var(
|
|
87
|
+
--starasia-ui-color-gray-50,
|
|
88
|
+
#f9fafb
|
|
89
|
+
);
|
|
90
|
+
/* red */
|
|
91
|
+
--starasia-ui-input-color-primary-red: var(
|
|
92
|
+
--starasia-ui-color-red-700,
|
|
93
|
+
#b91c1c
|
|
94
|
+
);
|
|
95
|
+
--starasia-ui-input-color-secondary-red: var(
|
|
96
|
+
--starasia-ui-color-red-500,
|
|
97
|
+
#ef4444
|
|
98
|
+
);
|
|
99
|
+
--starasia-ui-input-color-tertiary-red: var(
|
|
100
|
+
--starasia-ui-color-red-300,
|
|
101
|
+
#fca5a5
|
|
102
|
+
);
|
|
103
|
+
--starasia-ui-input-color-quaternary-red: var(
|
|
104
|
+
--starasia-ui-color-red-100,
|
|
105
|
+
#fee2e2
|
|
106
|
+
);
|
|
107
|
+
--starasia-ui-input-color-quinary-red: var(
|
|
108
|
+
--starasia-ui-color-red-50,
|
|
109
|
+
#fef2f2
|
|
110
|
+
);
|
|
111
|
+
/* yellow */
|
|
112
|
+
--starasia-ui-input-color-primary-yellow: var(
|
|
113
|
+
--starasia-ui-color-yellow-700,
|
|
114
|
+
#a16207
|
|
115
|
+
);
|
|
116
|
+
--starasia-ui-input-color-secondary-yellow: var(
|
|
117
|
+
--starasia-ui-color-yellow-500,
|
|
118
|
+
#eab308
|
|
119
|
+
);
|
|
120
|
+
--starasia-ui-input-color-tertiary-yellow: var(
|
|
121
|
+
--starasia-ui-color-yellow-300,
|
|
122
|
+
#fde047
|
|
123
|
+
);
|
|
124
|
+
--starasia-ui-input-color-quaternary-yellow: var(
|
|
125
|
+
--starasia-ui-color-yellow-100,
|
|
126
|
+
#fef9c3
|
|
127
|
+
);
|
|
128
|
+
--starasia-ui-input-color-quinary-yellow: var(
|
|
129
|
+
--starasia-ui-color-yellow-50,
|
|
130
|
+
#fefce8
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
/* text color */
|
|
134
|
+
--starasia-ui-text-default: var(--starasia-ui-color-gray-900);
|
|
135
|
+
--starasia-ui-color-text: var(--starasia-ui-text-default);
|
|
136
|
+
|
|
137
|
+
/* border width */
|
|
138
|
+
--starasia-ui-input-border-width: var(--starasia-ui-border, 1px);
|
|
139
|
+
|
|
140
|
+
/* border color */
|
|
141
|
+
--starasia-ui-color-border: rgba(120, 134, 127, 0.2);
|
|
142
|
+
|
|
143
|
+
/* height */
|
|
144
|
+
--starasia-ui-input-height-sm: var(--starasia-ui-h-8, 32px);
|
|
145
|
+
/* --starasia-ui-input-height-md: var(--starasia-ui-h-10, 40px); */
|
|
146
|
+
--starasia-ui-input-height-md: 38px;
|
|
147
|
+
--starasia-ui-input-height-lg: var(--starasia-ui-h-12, 48px);
|
|
148
|
+
|
|
149
|
+
/* border radius */
|
|
150
|
+
--starasia-ui-input-border-radius-sm: var(--starasia-ui-radii-md, 8px);
|
|
151
|
+
--starasia-ui-input-border-radius-md: var(--starasia-ui-radii-md, 8px);
|
|
152
|
+
--starasia-ui-input-border-radius-lg: var(--starasia-ui-radii-lg, 12px);
|
|
153
|
+
|
|
154
|
+
--starasia-ui-input-placeholder-color: var(
|
|
155
|
+
--starasia-ui-color-gray-200,
|
|
156
|
+
#c9cecc
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.starasia-input-container {
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
overflow: hidden;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
/* gap: var(--starasia-ui-input-spacing-sm); */
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.starasia-input-container:has(input:focus) {
|
|
169
|
+
border-color: var(--starasia-ui-input-color-primary-blue);
|
|
170
|
+
box-shadow: 0px 0px 0px 2px var(--starasia-ui-input-color-quaternary-blue);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.starasia-input-container:has(input:disabled)
|
|
174
|
+
.starasia-input-container-icon-left {
|
|
175
|
+
background-color: #f2f3f2;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.starasia-input-container:has(input:disabled)
|
|
179
|
+
.starasia-input-container-icon-right {
|
|
180
|
+
background-color: #f2f3f2;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.starasia-input-container:has(input:disabled) {
|
|
184
|
+
/* border-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
185
|
+
/* background-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
186
|
+
border-color: rgba(120, 134, 127, 0.2);
|
|
187
|
+
background-color: #f2f3f2;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.starasia-input-container:has(input:disabled) input {
|
|
191
|
+
color: #939e99 !important;
|
|
192
|
+
border-color: rgba(120, 134, 127, 0.2);
|
|
193
|
+
background-color: #f2f3f2;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.starasia-input-outline.starasia-input-container-error {
|
|
197
|
+
border-color: var(--starasia-ui-input-color-secondary-red) !important;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.starasia-input-filled.starasia-input-container-error {
|
|
201
|
+
border-color: var(--starasia-ui-input-color-secondary-red) !important;
|
|
202
|
+
background-color: var(--starasia-ui-input-color-quinary-red);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.starasia-input-flushed.starasia-input-container-error {
|
|
206
|
+
border-color: var(--starasia-ui-input-color-secondary-red) !important;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.starasia-input-outline.starasia-input-container-warning {
|
|
210
|
+
border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.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);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.starasia-input-flushed.starasia-input-container-warning {
|
|
219
|
+
border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.starasia-input-outline {
|
|
223
|
+
border-color: var(--starasia-ui-color-border);
|
|
224
|
+
background-color: transparent;
|
|
225
|
+
border-width: var(--starasia-ui-input-border-width);
|
|
226
|
+
border-style: solid;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.starasia-input-filled {
|
|
230
|
+
border-width: var(--starasia-ui-input-border-width);
|
|
231
|
+
border-style: solid;
|
|
232
|
+
border-color: var(--starasia-ui-input-color-quinary-gray);
|
|
233
|
+
background-color: var(--starasia-ui-input-color-quinary-gray);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.starasia-input-flushed.starasia-input-container:has(input:focus) {
|
|
237
|
+
box-shadow: none;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.starasia-input-flushed {
|
|
241
|
+
border-bottom: var(--starasia-ui-input-border-width) solid
|
|
242
|
+
var(--starasia-ui-input-color-tertiary-gray);
|
|
243
|
+
border-bottom-left-radius: 0 !important;
|
|
244
|
+
border-bottom-right-radius: 0 !important;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.starasia-input-container.sm {
|
|
248
|
+
height: var(--starasia-ui-input-height-sm);
|
|
249
|
+
border-radius: var(--starasia-ui-input-border-radius-sm);
|
|
250
|
+
font-size: var(--starasia-ui-fontSizes-sm, 12px);
|
|
251
|
+
/* padding-inline: var(--starasia-ui-input-spacing-sm); */
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.starasia-input-container.md {
|
|
255
|
+
height: var(--starasia-ui-input-height-md);
|
|
256
|
+
border-radius: var(--starasia-ui-input-border-radius-md);
|
|
257
|
+
font-size: var(--starasia-ui-fontSizes-md, 14px);
|
|
258
|
+
/* padding-inline: var(--starasia-ui-input-spacing-ms); */
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.starasia-input-container.lg {
|
|
262
|
+
height: var(--starasia-ui-input-height-lg);
|
|
263
|
+
border-radius: var(--starasia-ui-input-border-radius-lg);
|
|
264
|
+
font-size: var(--starasia-ui-fontSizes-lg, 16px);
|
|
265
|
+
/* padding-inline: var(--starasia-ui-input-spacing-ms); */
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.starasia-input-preview-container {
|
|
269
|
+
width: 100%;
|
|
270
|
+
position: relative;
|
|
271
|
+
z-index: 1;
|
|
272
|
+
height: 100%;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.starasia-input-placeholder {
|
|
276
|
+
position: absolute;
|
|
277
|
+
top: 50%;
|
|
278
|
+
left: 8px;
|
|
279
|
+
transform: translateY(-50%);
|
|
280
|
+
font-family: "Poppins", serif;
|
|
281
|
+
color: var(--starasia-ui-input-placeholder-color);
|
|
282
|
+
font-weight: var(--starasia-ui-fontWeights-normal, 300);
|
|
283
|
+
pointer-events: none;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.starasia-input-placeholder-highlighted {
|
|
287
|
+
color: var(--starasia-ui-input-color-primary-gray);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.starasia-input-preview-container
|
|
291
|
+
.starasia-input:focus
|
|
292
|
+
+ .starasia-input-placeholder {
|
|
293
|
+
display: none;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.starasia-input {
|
|
297
|
+
width: 100%;
|
|
298
|
+
box-sizing: border-box;
|
|
299
|
+
height: 100%;
|
|
300
|
+
border: none;
|
|
301
|
+
outline: none;
|
|
302
|
+
font-family: "Poppins", serif;
|
|
303
|
+
font-size: inherit;
|
|
304
|
+
font-weight: var(--starasia-ui-fontWeights-medium, 400);
|
|
305
|
+
background: transparent;
|
|
306
|
+
color: var(--starasia-ui-color-text);
|
|
307
|
+
padding-inline: var(--starasia-ui-input-spacing-sm) !important;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* .starasia-input-container:not(:has(.starasia-input-container-icon-left)) .starasia-input {
|
|
311
|
+
padding-inline: 12px !important;
|
|
312
|
+
} */
|
|
313
|
+
/* just icon */
|
|
314
|
+
|
|
315
|
+
/* INPUT ICON */
|
|
316
|
+
.starasia-input-container-icon-left {
|
|
317
|
+
display: flex;
|
|
318
|
+
height: 100%;
|
|
319
|
+
align-items: center;
|
|
320
|
+
padding-left: 12px;
|
|
321
|
+
background: transparent;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.starasia-input-container-icon-right {
|
|
325
|
+
display: flex;
|
|
326
|
+
height: 100%;
|
|
327
|
+
align-items: center;
|
|
328
|
+
padding-right: 12px;
|
|
329
|
+
background: transparent;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* INPUT ADDONS */
|
|
333
|
+
.starasia-input-container-addons-left {
|
|
334
|
+
background-color: rgba(120, 134, 127, 0.1);
|
|
335
|
+
height: 100%;
|
|
336
|
+
display: flex;
|
|
337
|
+
padding-inline: var(--starasia-ui-input-spacing-ms);
|
|
338
|
+
align-items: center;
|
|
339
|
+
justify-content: center;
|
|
340
|
+
font-family: "Poppins", serif;
|
|
341
|
+
color: var(--starasia-ui-input-color-secondary-gray);
|
|
342
|
+
border-right: 1px solid var(--starasia-ui-color-border);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.starasia-input-container-addons-right {
|
|
346
|
+
background-color: rgba(120, 134, 127, 0.1);
|
|
347
|
+
height: 100%;
|
|
348
|
+
display: flex;
|
|
349
|
+
padding-inline: var(--starasia-ui-input-spacing-ms);
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: center;
|
|
352
|
+
font-family: "Poppins", serif;
|
|
353
|
+
color: var(--starasia-ui-input-color-secondary-gray);
|
|
354
|
+
border-left: 1px solid var(--starasia-ui-color-border);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.starasia-input-container:has(input:disabled)
|
|
358
|
+
.starasia-input-container-addons-right {
|
|
359
|
+
background-color: rgba(120, 134, 127, 0.3) !important;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.starasia-input-container:has(input:disabled)
|
|
363
|
+
.starasia-input-container-addons-left {
|
|
364
|
+
background-color: rgba(120, 134, 127, 0.3) !important;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.starasia-input::placeholder {
|
|
368
|
+
color: var(--starasia-ui-input-placeholder-color);
|
|
369
|
+
font-weight: var(--starasia-ui-fontWeights-normal, 300);
|
|
370
|
+
}
|
|
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"})});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export interface IconInputProps extends React.SVGProps<SVGSVGElement> {
|
|
3
|
+
}
|
|
4
|
+
export interface IInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
5
|
+
leftIcon?: React.ReactElement<IconInputProps>;
|
|
6
|
+
rightIcon?: React.ReactElement<IconInputProps>;
|
|
7
|
+
leftAddons?: ReactNode;
|
|
8
|
+
rightAddons?: ReactNode;
|
|
9
|
+
onClickLeftIcon?: () => void;
|
|
10
|
+
onClickRightIcon?: () => void;
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
status?: "error" | "warning" | "disable" | "default";
|
|
13
|
+
inputUse?: "icon" | "addons";
|
|
14
|
+
variant?: "outline" | "filled" | "flushed";
|
|
15
|
+
highlightPlaceholder?: string;
|
|
16
|
+
currency?: boolean;
|
|
17
|
+
fullWidth?: boolean;
|
|
18
|
+
options?: string[];
|
|
19
|
+
onOptionChange?: (e: string) => void;
|
|
20
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@starasia/input",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "input component for starasia UI",
|
|
5
|
+
"author": "Prawito Hudoro",
|
|
6
|
+
"main": "dist/input.umd.js",
|
|
7
|
+
"module": "dist/input.es.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/*.js",
|
|
11
|
+
"dist/*.d.ts",
|
|
12
|
+
"dist/*.map",
|
|
13
|
+
"dist/*.css"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"dev": "vite --config vite.config.ts --port 3000",
|
|
17
|
+
"build": "vite build --config vite.config.ts"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.11.16",
|
|
27
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
28
|
+
"tsconfig-paths": "^4.2.0",
|
|
29
|
+
"typescript": "^5.3.3",
|
|
30
|
+
"vite": "^5.0.12",
|
|
31
|
+
"vite-plugin-dts": "^3.7.2",
|
|
32
|
+
"react": "^18.2.0",
|
|
33
|
+
"react-dom": "^18.2.0",
|
|
34
|
+
"@types/react": "^18.2.55",
|
|
35
|
+
"@types/react-dom": "^18.2.19"
|
|
36
|
+
}
|
|
37
|
+
}
|